/*! * https://github.com/Starcounter-Jack/JSON-Patch * (c) 2017-2022 Joachim Wester * MIT licensed */var Q=function(){var e=function(r,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,f){n.__proto__=f}||function(n,f){for(var i in f)f.hasOwnProperty(i)&&(n[i]=f[i])},e(r,t)};return function(r,t){e(r,t);function n(){this.constructor=r}r.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),z=Object.prototype.hasOwnProperty;function P(e,r){return z.call(e,r)}function R(e){if(Array.isArray(e)){for(var r=new Array(e.length),t=0;t=48&&n<=57){r++;continue}return!1}return!0}function w(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function D(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function L(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var r=0,t=e.length;r0&&v[p-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(t&&(d===void 0&&(a[l]===void 0?d=v.slice(0,p).join("/"):p==c-1&&(d=r.path),d!==void 0&&g(r,0,e,d))),p++,Array.isArray(a)){if(l==="-")l=a.length;else{if(t&&!I(l))throw new u("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",i,r,e);I(l)&&(l=~~l)}if(p>=c){if(t&&r.op==="add"&&l>a.length)throw new u("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",i,r,e);var s=K[r.op].call(r,a,l,e);if(s.test===!1)throw new u("Test operation failed","TEST_OPERATION_FAILED",i,r,e);return s}}else if(p>=c){var s=O[r.op].call(r,a,l,e);if(s.test===!1)throw new u("Test operation failed","TEST_OPERATION_FAILED",i,r,e);return s}if(a=a[l],t&&p0)throw new u('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",r,e,t);if((e.op==="move"||e.op==="copy")&&typeof e.from!="string")throw new u("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",r,e,t);if((e.op==="add"||e.op==="replace"||e.op==="test")&&e.value===void 0)throw new u("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",r,e,t);if((e.op==="add"||e.op==="replace"||e.op==="test")&&L(e.value))throw new u("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",r,e,t);if(t){if(e.op=="add"){var f=e.path.split("/").length,i=n.split("/").length;if(f!==i+1&&f!==i)throw new u("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",r,e,t)}else if(e.op==="replace"||e.op==="remove"||e.op==="_get"){if(e.path!==n)throw new u("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",r,e,t)}else if(e.op==="move"||e.op==="copy"){var s={op:"_get",path:e.from,value:void 0},o=S([s],t);if(o&&o.name==="OPERATION_PATH_UNRESOLVABLE")throw new u("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",r,e,t)}}}else throw new u("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",r,e,t)}function S(e,r,t){try{if(!Array.isArray(e))throw new u("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(r)T(h(r),h(e),t||!0);else{t=t||y;for(var n=0;n0&&(e.patches=[],e.callback&&e.callback(n)),n}function C(e,r,t,n,f){if(r===e)return;typeof r.toJSON=="function"&&(r=r.toJSON());for(var i=R(r),s=R(e),o=!1,v=s.length-1;v>=0;v--){var a=s[v],p=e[a];if(P(r,a)&&!(r[a]===void 0&&p!==void 0&&Array.isArray(r)===!1)){var c=r[a];typeof p=="object"&&p!=null&&typeof c=="object"&&c!=null&&Array.isArray(p)===Array.isArray(c)?C(p,c,t,n+"/"+w(a),f):p!==c&&(f&&t.push({op:"test",path:n+"/"+w(a),value:h(p)}),t.push({op:"replace",path:n+"/"+w(a),value:h(c)}))}else Array.isArray(e)===Array.isArray(r)?(f&&t.push({op:"test",path:n+"/"+w(a),value:h(p)}),t.push({op:"remove",path:n+"/"+w(a)}),o=!0):(f&&t.push({op:"test",path:n,value:e}),t.push({op:"replace",path:n,value:r}))}if(!o&&i.length==s.length)return;for(var v=0;v