var hasExcape=/~/;var escapeMatcher=/~[01]/g;function escapeReplacer(e){switch(e){case"~1":return"/";case"~0":return"~"}throw new Error("Invalid tilde escape: "+e)}function untilde(e){if(!hasExcape.test(e))return e;return e.replace(escapeMatcher,escapeReplacer)}function setter(e,r,t){var n;var i;if(r[1]==="constructor"&&r[2]==="prototype")return e;if(r[1]==="__proto__")return e;for(var o=1,a=r.length;o<a;){n=untilde(r[o++]);i=a>o;if(typeof e[n]==="undefined"){if(Array.isArray(e)&&n==="-"){n=e.length}if(i){if(r[o]!==""&&r[o]<Infinity||r[o]==="-")e[n]=[];else e[n]={}}}if(!i)break;e=e[n]}var c=e[n];if(t===undefined)delete e[n];else e[n]=t;return c}function compilePointer(e){if(typeof e==="string"){e=e.split("/");if(e[0]==="")return e;throw new Error("Invalid JSON pointer.")}else if(Array.isArray(e)){return e}throw new Error("Invalid JSON pointer.")}function get(e,r){if(typeof e!=="object")throw new Error("Invalid input object.");r=compilePointer(r);var t=r.length;if(t===1)return e;for(var n=1;n<t;){e=e[untilde(r[n++])];if(t===n)return e;if(typeof e!=="object")return undefined}}function set(e,r,t){if(typeof e!=="object")throw new Error("Invalid input object.");r=compilePointer(r);if(r.length===0)throw new Error("Invalid JSON pointer for set.");return setter(e,r,t)}function compile(e){var r=compilePointer(e);return{get:function(e){return get(e,r)},set:function(e,t){return set(e,r,t)}}}var get_1=get;var set_1=set;var compile_1=compile;var jsonpointer={get:get_1,set:set_1,compile:compile_1};export{jsonpointer as j};