text: "use strict";
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
      if (k2 === undefined) k2 = k;
      Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  }) : (function(o, m, k, k2) {
      if (k2 === undefined) k2 = k;
      o[k2] = m[k];
  }));
  var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
      Object.defineProperty(o, "default", { enumerable: true, value: v });
  }) : function(o, v) {
      o["default"] = v;
  });
  var __importStar = (this && this.__importStar) || function (mod) {
      if (mod && mod.__esModule) return mod;
      var result = {};
      if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
      __setModuleDefault(result, mod);
      return result;
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  const DMP = __importStar(require("diff-match-patch"));
  const dmp = new DMP.diff_match_patch();
  const OPERATIONS = {
      replace(currentValue, nextValue) {
          return nextValue;
      },
      set(currentValue, nextValue) {
          return nextValue;
      },
      setIfMissing(currentValue, nextValue) {
          return currentValue === undefined ? nextValue : currentValue;
      },
      unset(currentValue, nextValue) {
          return undefined;
      },
      diffMatchPatch(currentValue, nextValue) {
          return dmp.patch_apply(dmp.patch_fromText(nextValue), currentValue)[0];
      }
  };
  const SUPPORTED_PATCH_TYPES = Object.keys(OPERATIONS);
  function apply(value, patch) {
      if (!SUPPORTED_PATCH_TYPES.includes(patch.type)) {
          throw new Error(`Received patch of unsupported type: "${JSON.stringify(patch.type)}" for string. This is most likely a bug.`);
      }
      if (patch.path.length > 0) {
          throw new Error(`Cannot apply deep operations on string values. Received patch with type "${patch.type}" and path "${patch.path.join('.')} that targeted the value "${JSON.stringify(value)}"`);
      }
      return OPERATIONS[patch.type](value, patch.value);
  }
  exports.default = apply;
  //# sourceMappingURL=string.js.map