You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@jsonurl/jsonurl

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsonurl/jsonurl - npm Package Compare versions

Comparing version

to
1.1.7

4

dist/jsonurl.min.js
/*!
* jsonurl.js v1.1.6
* jsonurl.js v1.1.7
* (c) 2022 David MacCormack
* Released under the MIT License.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).JsonURL=t()}(this,(function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&o(e,t)}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function a(e,t,r){return(a=s()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&o(i,r.prototype),i}).apply(null,arguments)}function u(e){var t="function"==typeof Map?new Map:void 0;return(u=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return a(e,arguments,i(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),o(n,e)})(e)}function c(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function l(e){var t=s();return function(){var r,n=i(e);if(t){var o=i(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return c(this,r)}}var p="JSON->URL: expected literal value",h="JSON->URL: unexpected character",f="JSON->URL: unexpected end of text inside composite",d="JSON->URL: unexpected text after composite",y="JSON->URL: MaxParseValues exceeded",v="JSON->URL: the empty string is not allowed",w="JSON->URL: invalid escape sequence",m="JSON->URL: invalid percent-encoded sequence",x="JSON->URL: expected object value";function O(e,t){return void 0===t?e:e+" at position "+t}var b=16,A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,6,6,48,10,20,20,6,6,20,6,6,6,6,6,6,6,6,6,6,6,6,6,20,6,0,48,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,0,6,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,6,0];function g(e){return e>127?0:A[e]}var E=function(){function t(r){e(this,t),this.setOrDefault(r,"allowEmptyUnquotedValues"),this.setOrDefault(r,"allowEmptyUnquotedKeys"),this.setOrDefault(r,"AQF"),this.setOrDefault(r,"coerceNullToEmptyString"),this.setOrDefault(r,"ignoreNullArrayMembers"),this.setOrDefault(r,"ignoreNullObjectMembers"),this.setOrDefault(r,"impliedArray"),this.setOrDefault(r,"impliedObject"),this.setOrDefault(r,"impliedStringLiterals"),this.setOrDefault(r,"noEmptyComposite"),this.setOrDefault(r,"wwwFormUrlEncoded")}return r(t,[{key:"setOrDefault",value:function(e,t,r){void 0!==e&&t in e?t in this||(this[t]=e[t]):void 0===r||t in this||(this[t]=r)}},{key:"setOverride",value:function(e,t){void 0!==e&&t in e&&(this[t]=e[t])}},{key:"setOrDefaultInt",value:function(e,t,r){this.setOrDefault(e,t,void 0===r?r:parseInt(r))}},{key:"isPresentAndTrue",value:function(e){return e in this&&this[e]}}]),t}(),S=function(t){n(o,t);var i=l(o);function o(t,r){var n;return e(this,o),(n=i.call(this,t)).setOrDefault(t,"emptyValue"),n.setOrDefault(r,"emptyValue",{}),n.setOverride(t,"getMissingValue"),n.setOrDefaultInt(t,"maxParseChars"),n.setOrDefaultInt(r,"maxParseChars",32768),n.setOrDefaultInt(t,"maxParseDepth"),n.setOrDefaultInt(r,"maxParseDepth",32),n.setOrDefaultInt(t,"maxParseValues"),n.setOrDefaultInt(r,"maxParseValues",4096),n.setOrDefault(t,"nullValue"),n.setOrDefault(r,"nullValue",null),n}return r(o,[{key:"getMissingValue",value:function(e,t){throw new SyntaxError(O(x,t))}}]),o}(E),L=function(t){n(o,t);var i=l(o);function o(t){var r;e(this,o),r=i.call(this,t);var n=!(void 0===t||!("impliedStringLiterals"in t)||!t.impliedStringLiterals)||void 0;return r.setOrDefault(t,"allowEmptyUnquotedValues",n),r.setOrDefault(t,"allowEmptyUnquotedKeys",n),r.setOrDefault(t,"callFunctions"),r.setOrDefault(t,"isImplied"),r.setOrDefault(t,"ignoreNullArrayMembers",n),r.setOrDefault(t,"ignoreNullObjectMembers",n),r.setOrDefault(t,"ignoreUndefinedArrayMembers",n),r.setOrDefault(t,"ignoreUndefinedObjectMembers",n),r.isImplied=r.isImplied||r.impliedArray||r.impliedObject,r}return r(o)}(E);var U=/\+/g,V=/ /g,k=/(![\s\S]?)/g,j=/^[-A-Za-z0-9._~!$*;=@?/ ][-A-Za-z0-9._~!$*;=@?/' ]*$/,C=/^[-A-Za-z0-9._~!$*,;=@?/(): ]+$/,D=/^-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?$/,R=/[(),:]|%2[04]|%3B/gi,P={"%20":"+","%24":"$","(":"%28",")":"%29",",":"%2C",":":"%3A","%3B":";"},N=/[!(),:]|%2[01489C]|%3[AB]/gi,J={"%20":"+","%21":"!!","!":"!!","%24":"$","%28":"!(","(":"!(","%29":"!)",")":"!)","+":"!+","%2C":"!,",",":"!,","%3A":"!:",":":"!:","%3B":";"},T=40,F=41,I=44,M=58,_=38,q=48,B=65,$=97,Q=new Array(111);Q[33]="!",Q[40]="(",Q[41]=")",Q[43]="+",Q[44]=",",Q[45]=",",Q[48]="0",Q[49]="1",Q[50]="2",Q[51]="3",Q[52]="4",Q[53]="5",Q[54]="6",Q[55]="7",Q[56]="8",Q[57]="9",Q[58]=":",Q[116]="t",Q[102]="f",Q[110]="n";var K="",z=" ";function Z(e,t){var r=t?N:R,n=t?J:P;return encodeURIComponent(e).replace(r,(function(e){var t=n[e];return void 0===t?e:t}))}function G(e,t){switch(t){case q:return 0;case 49:return 1;case 50:return 2;case 51:return 3;case 52:return 4;case 53:return 5;case 54:return 6;case 55:return 7;case 56:return 8;case 57:return 9;case B:case $:return 10;case 66:case 98:return 11;case 67:case 99:return 12;case 68:case 100:return 13;case 69:case 101:return 14;case 70:case 102:return 15;default:throw new SyntaxError(O(m,e))}}function H(e){if(e.coerceNullToEmptyString)return W(e,!1);if(e.impliedStringLiterals)throw new SyntaxError("JSON->URL: can not represent null with implied strings");return"null"}function W(e,t){if(t?e.allowEmptyUnquotedKeys:e.allowEmptyUnquotedValues)return K;if(e.AQF)return"!e";if(e.impliedStringLiterals)throw new SyntaxError(v);return"''"}!function(e){var t=e.toJsonURLText_Array,r=e.toJsonURLText_Boolean,n=e.toJsonURLText_Number,i=e.toJsonURLText_Object,o=e.toJsonURLText_String;Object.defineProperty(Array.prototype,"toJsonURLText",{value:t}),Object.defineProperty(Boolean.prototype,"toJsonURLText",{value:r}),Object.defineProperty(Number.prototype,"toJsonURLText",{value:n}),Object.defineProperty(Object.prototype,"toJsonURLText",{value:i}),Object.defineProperty(String.prototype,"toJsonURLText",{value:o})}({toJsonURLText_Array:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=void 0;return this.forEach((function(n){if("function"==typeof n){if(!e.callFunctions)return;for(;"function"==typeof n;)n=n()}if(void 0===n){if(e.ignoreUndefinedArrayMembers)return;n=H(e)}else if(null===n){if(e.ignoreNullArrayMembers)return;n=H(e)}else n=n.toJsonURLText(e,t+1);void 0===r?r=n:!e.wwwFormUrlEncoded||t>0?r+=","+n:r+="&"+n})),!e.isImplied||t>0?void 0===r?"()":"("+r+")":void 0===r?K:r},toJsonURLText_Boolean:function(){return!0===this?"true":"false"},toJsonURLText_Number:function(e){var t=String(this);return e.impliedStringLiterals&&-1!==t.indexOf("+")?Z(t,e):t},toJsonURLText_Object:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=void 0,n=Object.keys(this),i=this;return n.forEach((function(n){if(null!=n){var o=i[n];if("function"==typeof o){if(!e.callFunctions)return;for(;"function"==typeof o;)o=o()}if(void 0===o){if(e.ignoreUndefinedObjectMembers)return;o=H(e)}else if(null===o){if(e.ignoreNullObjectMembers)return;o=H(e)}else o=o.toJsonURLText(e,t+1);var s=n.toJsonURLText(e,t,!0);void 0===r?r=!e.wwwFormUrlEncoded||t>0?s+":"+o:s+"="+o:!e.wwwFormUrlEncoded||t>0?r+=","+s+":"+o:r+="&"+s+"="+o}})),!e.isImplied||t>0?(e.noEmptyComposite&&void 0===r&&(r=":"),void 0===r?"()":"("+r+")"):void 0===r?K:r},toJsonURLText_String:function(e,t,r){if(0===this.length)return W(e,r);if(e.impliedStringLiterals)return Z(this,e.AQF);if("true"===(n=this)||"false"===n||"null"===n||D.test(n))return!0===r?this:e.AQF?-1==this.indexOf("+")?"!"+this:this.replace("+","!+"):-1==this.indexOf("+")?"'"+this+"'":encodeURIComponent(this);var n;if(e.AQF)return Z(this,!0);if(j.test(this))return-1==this.indexOf(z)?this:this.replace(V,"+");if(C.test(this))return-1==this.indexOf(z)?"'"+this+"'":"'"+this.replace(V,"+")+"'";var i=Z(this);return 39==i.charCodeAt(0)?"%27"+i.substring(1):i}});var X=function(){function t(r,n,i,o){e(this,t),this.text=r,this.pos=this.markPos=n,this.end=i,this.options=o}return r(t,[{key:"skipAmps",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.text,r=this.end,n=this.pos;if(e)for(;n<r&&t.charCodeAt(n)===_;)n++;else if(n<r&&t.charCodeAt(n)===_){for(n++;n<r&&t.charCodeAt(n)===_;n++);n!==r&&n--}this.pos=n}},{key:"structChar",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.options.wwwFormUrlEncoded){var t=this.text.charCodeAt(this.pos);switch(t){case _:case 61:if(e)return;return this.pos++,t}}var r=this.pos,n=this.ordinal();switch(n){case I:case M:if(e)return void(this.pos=r);case T:case F:return n;default:return void(this.pos=r)}}},{key:"ordinal",value:function(e){return void 0!==e?this.text.charCodeAt(e):this.text.charCodeAt(this.pos++)}},{key:"accept",value:function(e){var t=this.pos;return this.ordinal()===e||(this.pos=t,!1)}},{key:"acceptPlus",value:function(){return 43==this.text.charCodeAt(this.pos)&&(this.pos++,!0)}},{key:"done",value:function(){return this.end<=this.pos}},{key:"validateLiteral",value:function(e,t){for(var r=this.text,n=this.end;e<n;e++){switch(g(r.charCodeAt(e))&t){case 0:throw new SyntaxError(O(h,e));case b:return e;case 8:return e+1;default:continue}}}},{key:"findLiteralEnd",value:function(){var e=this.text,t=this.end,r=this.pos,n=39===e.charCodeAt(r);n&&r++;var i=n?28:18;if(void 0!==(r=this.validateLiteral(r,i)))return r;if(n)throw new SyntaxError(O("JSON->URL: quoted string still open",r));return t}},{key:"isEmptyObject",value:function(){if(this.options.noEmptyComposite){var e=this.pos;if(!this.accept(M))return!1;var t=this.pos,r=this.accept(F);return this.pos=r?t:e,r}return!1}},{key:"parseLiteral",value:function(e){var t=this.pos,r=this.options,n=this.findLiteralEnd();if(void 0===e&&(e=this.ordinal(n)==M),n<=t)return function(e,t){if(t)return K;throw new SyntaxError(O(v,e))}(t,e?this.options.allowEmptyUnquotedKeys:this.options.allowEmptyUnquotedValues);if(!0===r.impliedStringLiterals)return this.parseStringLiteral(n,!0);var i=this.parseTrueFalseNull(n,e);if(void 0!==i)return i;var o=this.parseNumberLiteral(n,e);return void 0!==o?o:this.parseStringLiteral(n,!1)}},{key:"parseDigits",value:function(e){for(var t,r=!1;this.pos<e;)switch(this.ordinal()){case q:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:t=this.pos,r=!0;continue;default:return this.pos=t,r}return this.pos=t,r}},{key:"parseExponentValue",value:function(e){return!(e<=this.pos)&&(this.acceptPlus()||this.accept(45),this.parseDigits(e))}},{key:"parseExponent",value:function(e){var t=this.pos;switch(this.ordinal()){case 69:case 101:if(this.parseExponentValue(e))return!0}return this.pos=t,!1}},{key:"parseFraction",value:function(e){var t=this.pos;return!(e<=t)&&(!(!this.accept(46)||!this.parseDigits(e))||(this.pos=t,!1))}},{key:"parseInteger",value:function(e){return!(e<=this.pos)&&(!!this.accept(q)||this.parseDigits(e))}},{key:"parseNumberLiteral",value:function(e,t){var r=this.text,n=this.pos;if(this.accept(45),this.parseInteger(e)&&(this.parseFraction(e),this.parseExponent(e),this.pos===e)){var i=decodeURIComponent(r.substring(n,e));return t?i:Number(i)}this.pos=n}},{key:"parseStringLiteral",value:function(e,t){var r=this.text,n=this.pos,i=t||39!==r.charCodeAt(n)?r.substring(n,e):r.substring(n+1,e-1);return i=decodeURIComponent(i.replace(U,z)),this.pos=e,i}},{key:"parseTrueFalseNull",value:function(e,t){var r,n,i,o,s,a=this.text,u=this.pos;switch(e-u){case 4:if(r=a.charCodeAt(u),n=a.charCodeAt(u+1),i=a.charCodeAt(u+2),o=a.charCodeAt(u+3),116===r&&114===n&&117===i&&101===o)return this.pos=e,!t||"true";if(110===r&&117===n&&108===i&&108===o)return this.pos=e,t?"null":this.newNullValue();break;case 5:if(r=a.charCodeAt(u),n=a.charCodeAt(u+1),i=a.charCodeAt(u+2),o=a.charCodeAt(u+3),s=a.charCodeAt(u+4),102===r&&n===$&&108===i&&115===o&&101===s)return this.pos=e,!!t&&"false"}}},{key:"newEmptyValue",value:function(){var e=this.options;if(e.noEmptyComposite)return[];var t=e.emptyValue;return"function"==typeof t?t():t}},{key:"newNullValue",value:function(){var e=this.options,t=e.nullValue;return"function"==typeof t&&(t=t()),null==t&&e.coerceNullToEmptyString&&(t=K),t}}]),t}(),Y=function(t){n(o,t);var i=l(o);function o(t,r,n,s){return e(this,o),i.call(this,t,r,n,s)}return r(o,[{key:"ordinal",value:function(e){var t,r,n=e||this.pos,i=this.text.charCodeAt(n);return 37===i?(t=function(e,t,r){if(r<=t+1)throw new SyntaxError(O(m,t));return G(t,e.charCodeAt(t))<<4|G(t,e.charCodeAt(t+1))}(this.text,n+1,this.end),r=3):(t=i,r=1),void 0===e&&(this.pos+=r),t}},{key:"acceptPlus",value:function(){return this.accept(43)}},{key:"findLiteralEnd",value:function(){for(var e=this.end,t=this.pos,r=this.text,n=t;;){if(e<=this.pos)return this.pos=t,e;switch(50&g(r.charCodeAt(this.pos))){case 48:if(this.options.wwwFormUrlEncoded)return n=this.pos,this.pos=t,n;case 0:throw new SyntaxError(O(h,n))}switch(this.ordinal()){case T:case F:case M:case I:return this.pos=t,n;case 33:if(this.pos===e)throw new SyntaxError(O(w,n));this.ordinal(),n=this.pos;break;default:n=this.pos}}}},{key:"parseStringLiteral",value:function(e){var t=this.text,r=this.pos,n=decodeURIComponent(t.substring(r,e).replace(U,z));return this.pos=e,"!e"===n?K:n.replace(k,(function(e,t,n){if(2===e.length){var i=e.charCodeAt(1),o=Q[i];if(void 0!==o)return o}throw new SyntaxError(O(w,r+n))}))}}]),o}(X),ee=function(t){n(o,t);var i=l(o);function o(t){var r;return e(this,o),(r=i.call(this)).limits=t,r.parseDepth=0,r}return r(o,[{key:"replaceAndPush",value:function(e,t,r){if(this[this.parseDepth]=t,++this.parseDepth>=this.limits.maxParseDepth)throw new Error(O("JSON->URL: MaxParseDepth exceeded",e));this.push(r)}},{key:"replace",value:function(e){this[this.parseDepth]=e}},{key:"depth",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return e&&(this.parseDepth--,this.pop()),this.parseDepth}}]),o}(u(Array)),te=function(t){n(o,t);var i=l(o);function o(t){var r;return e(this,o),(r=i.call(this)).limits=t,r.numValues=0,r}return r(o,[{key:"popObjectValue",value:function(e,t){t=t||this.pop();var r=this.pop(),n=this[this.length-1];return null===t&&e.isPresentAndTrue("ignoreNullObjectMembers")||(n[r]=t),n}},{key:"popArrayValue",value:function(e,t){t=t||this.pop();var r=this[this.length-1];return null===t&&e.isPresentAndTrue("ignoreNullArrayMembers")||r.push(t),r}},{key:"checkValueLimit",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this.numValues+=t,this.numValues>this.limits.maxParseValues+1)throw new Error(O(y,e))}},{key:"appendArrayValue",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this.checkValueLimit(e,r),this.push(t)}}]),o}(u(Array));function re(e){for(;"function"==typeof e;)e=e();return e}function ne(e,t,r,n){return"number"==typeof e?"number"!=typeof t&&(r=t):r=e,(r=re(r))instanceof S||(r=new S(r,n)),r}function ie(e,t,r,n){return n.AQF?new Y(e,t,r,n):new X(e,t,r,n)}function oe(e,t){return"number"==typeof e?e:t}function se(e,t,r,n,i){if(void 0!==e){n=ne(t,r,n,i),e=String(e);var o=oe(t,0),s=oe(r,e.length);if(s<=o){if(void 0!==n.impliedArray)return n.impliedArray;if(void 0!==n.impliedObject)return n.impliedObject;throw new SyntaxError(O("JSON->URL: expected value",0))}if(s>n.maxParseChars)throw new Error("JSON->URL: MaxParseChars exceeded");var a=n.wwwFormUrlEncoded&&(n.impliedObject||n.impliedArray),u=new te(n),c=new ee(n),l=ie(e,o,s,n);if(void 0!==n.impliedObject)u.push(n.impliedObject),c.push(6);else if(void 0!==n.impliedArray)u.push(n.impliedArray),c.push(2);else{if(l.structChar(!0)!==T){var y=l.parseLiteral(!1);if(l.done())return y;throw new SyntaxError(O(p,0))}c.push(1)}for(a&&l.skipAmps(!0);;){if(l.done())throw new SyntaxError(O(f,l.pos));var v=void 0,w=void 0,m=void 0;switch(c[c.depth()]){case 1:switch(l.structChar(!0)){case T:u.appendArrayValue(l.pos,[]),c.replaceAndPush(l.pos,3,1);continue;case F:if(-1===c.depth(!0)){if(l.done())return l.newEmptyValue();throw new SyntaxError(O(d,l.pos))}if(u.appendArrayValue(l.pos,l.newEmptyValue()),0===c.depth()&&(a&&l.skipAmps(),l.done())){if(n.impliedArray)return u.popArrayValue(n);if(n.impliedObject)return u.popObjectValue(n);throw new SyntaxError(O(f,l.pos))}continue}switch(u.checkValueLimit(l.pos),v=(w=l.isEmptyObject())?{}:l.parseLiteral(),m=l.pos,l.structChar()){case _:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,m));case I:c.replace(2),u.appendArrayValue(m,[]),u.push(v),u.popArrayValue(n);continue;case F:switch(w?u.push({}):u.appendArrayValue(m,[v]),c.depth(!0)){case-1:if(l.pos===s)return u[0];throw new SyntaxError(O(d,m));case 0:if(a&&l.skipAmps(),l.done()){if(n.impliedArray)return u.popArrayValue(n);if(n.impliedObject)return u.popObjectValue(n);throw new SyntaxError(O(f,m))}}continue;case 61:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,m));case M:c.replace(4),u.push({},v);continue;default:throw new SyntaxError(O(p,m))}case 2:if(l.accept(T)){c.replaceAndPush(l.pos,3,1);continue}if(u.checkValueLimit(l.pos),v=l.parseLiteral(!1),a&&l.skipAmps(),l.done()){if(0===c.depth()&&n.impliedArray)return u.popArrayValue(n,v);throw new SyntaxError(O(f,s))}c.replace(3),u.push(v);continue;case 3:switch(u.popArrayValue(n),l.structChar()){case _:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,l.pos));case I:c.replace(2);continue;case F:switch(c.depth(!0)){case-1:if(l.done()&&!n.impliedArray)return u[0];throw new SyntaxError(O(d,l.pos));case 0:if(a&&l.skipAmps(),l.done()){if(n.impliedArray)return u.popArrayValue(n);if(n.impliedObject)return u.popObjectValue(n);throw new SyntaxError(O(f,l.pos))}}continue}throw new SyntaxError(O("JSON->URL: expected comma or close paren",l.pos));case 4:if(l.accept(T)){c.replaceAndPush(l.pos,5,1);continue}if(u.checkValueLimit(l.pos),v=l.parseLiteral(!1),a&&l.skipAmps(),l.done()){if(0===c.depth()&&n.impliedObject)return u.popObjectValue(n,v);throw new SyntaxError(O(f,s))}c.replace(5),u.push(v);continue;case 5:switch(u.popObjectValue(n),m=l.pos,l.structChar()){case _:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,m));case I:c.replace(6);continue;case F:switch(c.depth(!0)){case-1:if(l.done()&&!n.impliedObject)return u[0];throw new SyntaxError(O(d,l.pos));case 0:if(a&&l.skipAmps(),l.done()){if(n.impliedArray)return u.popArrayValue(n);if(n.impliedObject)return u.popObjectValue(n);throw new SyntaxError(O(d,l.pos))}}continue}throw new SyntaxError(O("JSON->URL: expected comma, open paren, or close paren",l.pos));case 6:if(v=l.parseLiteral(!0),a&&l.skipAmps(),l.done()){if(n.impliedObject&&0==c.depth())return u.push(v,n.getMissingValue(v)),u.popObjectValue(n);throw new SyntaxError(O(f,s))}switch(l.structChar()){case 61:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,l.pos));case M:break;case _:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,l.pos));case I:if(n.impliedObject&&0==c.depth()){u.push(v,n.getMissingValue(v)),u.popObjectValue(n);continue}default:throw new SyntaxError(O(x,l.pos))}c.replace(4),u.push(v);continue;default:throw new SyntaxError(O("JSON->URL: internal error",l.pos))}}}}return function(){function t(r){for(e(this,t);"function"==typeof r;)r=r();void 0===r&&(r={}),this.maxParseDepth="number"==typeof r.maxParseDepth?parseInt(r.maxParseDepth):32,this.maxParseValues="number"==typeof r.maxParseValues?parseInt(r.maxParseValues):4096,this.maxParseChars="number"==typeof r.maxParseChars?parseInt(r.maxParseChars):32768,this.emptyValue=void 0===r.emptyValue?{}:r.emptyValue,this.nullValue=void 0===r.nullValue?null:r.nullValue}return r(t,[{key:"parseLiteral",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4?arguments[4]:void 0;void 0!==e&&(e=String(e)),void 0===r&&(r=e.length);var o=ie(e,t,r,ne(i));return o.parseLiteral(n)}},{key:"parse",value:function(e,t,r,n){return se(e,t,r,n,this)}}],[{key:"parse",value:function(e,t,r,n){return se(e,t,r,n,void 0)}},{key:"stringify",value:function(e,t){if(void 0!==e)return t=new L(re(t)),null===e?H(t):e.toJsonURLText(t,0)}}]),t}()}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).JsonURL=t()}(this,(function(){"use strict";const e="JSON->URL: expected literal value",t="JSON->URL: unexpected character",r="JSON->URL: unexpected end of text inside composite",s="JSON->URL: unexpected text after composite",i="JSON->URL: the empty string is not allowed",n="JSON->URL: invalid escape sequence",o="JSON->URL: invalid percent-encoded sequence",a="JSON->URL: expected object value";function p(e,t){return void 0===t?e:e+" at position "+t}const u=16,c=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,6,6,48,10,20,20,6,6,20,6,6,6,6,6,6,6,6,6,6,6,6,6,20,6,0,48,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,0,6,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,6,0];function l(e){return e>127?0:c[e]}class h{constructor(e){this.setOrDefault(e,"allowEmptyUnquotedValues"),this.setOrDefault(e,"allowEmptyUnquotedKeys"),this.setOrDefault(e,"AQF"),this.setOrDefault(e,"coerceNullToEmptyString"),this.setOrDefault(e,"ignoreNullArrayMembers"),this.setOrDefault(e,"ignoreNullObjectMembers"),this.setOrDefault(e,"impliedArray"),this.setOrDefault(e,"impliedObject"),this.setOrDefault(e,"impliedStringLiterals"),this.setOrDefault(e,"noEmptyComposite"),this.setOrDefault(e,"wwwFormUrlEncoded")}setOrDefault(e,t,r){void 0!==e&&t in e?t in this||(this[t]=e[t]):void 0===r||t in this||(this[t]=r)}setOverride(e,t){void 0!==e&&t in e&&(this[t]=e[t])}setOrDefaultInt(e,t,r){this.setOrDefault(e,t,void 0===r?r:parseInt(r))}isPresentAndTrue(e){return e in this&&this[e]}}class d extends h{constructor(e,t){super(e),this.setOrDefault(e,"emptyValue"),this.setOrDefault(t,"emptyValue",{}),this.setOverride(e,"getMissingValue"),this.setOrDefaultInt(e,"maxParseChars"),this.setOrDefaultInt(t,"maxParseChars",32768),this.setOrDefaultInt(e,"maxParseDepth"),this.setOrDefaultInt(t,"maxParseDepth",32),this.setOrDefaultInt(e,"maxParseValues"),this.setOrDefaultInt(t,"maxParseValues",4096),this.setOrDefault(e,"nullValue"),this.setOrDefault(t,"nullValue",null)}getMissingValue(e,t){throw new SyntaxError(p(a,t))}}class f extends h{constructor(e){super(e);const t=!(void 0===e||!("impliedStringLiterals"in e)||!e.impliedStringLiterals)||void 0;this.setOrDefault(e,"allowEmptyUnquotedValues",t),this.setOrDefault(e,"allowEmptyUnquotedKeys",t),this.setOrDefault(e,"callFunctions"),this.setOrDefault(e,"isImplied"),this.setOrDefault(e,"ignoreNullArrayMembers",t),this.setOrDefault(e,"ignoreNullObjectMembers",t),this.setOrDefault(e,"ignoreUndefinedArrayMembers",t),this.setOrDefault(e,"ignoreUndefinedObjectMembers",t),this.isImplied=this.isImplied||this.impliedArray||this.impliedObject}}function m(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),s=1;s<t;s++)r[s-1]=arguments[s];return e.toJsonURLText.apply(e,r)}const w=/\+/g,y=/ /g,x=/(![\s\S]?)/g,O=/^[-A-Za-z0-9._~!$*;=@?/ ][-A-Za-z0-9._~!$*;=@?/' ]*$/,A=/^[-A-Za-z0-9._~!$*,;=@?/(): ]+$/,g=/^-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?$/,E=/[(),:]|%2[04]|%3B/gi,b={"%20":"+","%24":"$","(":"%28",")":"%29",",":"%2C",":":"%3A","%3B":";"},S=/[!(),:]|%2[01489C]|%3[AB]/gi,v={"%20":"+","%21":"!!","!":"!!","%24":"$","%28":"!(","(":"!(","%29":"!)",")":"!)","+":"!+","%2C":"!,",",":"!,","%3A":"!:",":":"!:","%3B":";"},L=40,U=41,V=44,C=58,D=38,j=48,R=65,N=97,P=new Array(111);P[33]="!",P[40]="(",P[41]=")",P[43]="+",P[44]=",",P[45]=",",P[48]="0",P[49]="1",P[50]="2",P[51]="3",P[52]="4",P[53]="5",P[54]="6",P[55]="7",P[56]="8",P[57]="9",P[58]=":",P[116]="t",P[102]="f",P[110]="n";const J="",F=" ";function T(e,t){const r=t?S:E,s=t?v:b;return encodeURIComponent(e).replace(r,(function(e){const t=s[e];return void 0===t?e:t}))}function I(e,t){switch(t){case j:return 0;case 49:return 1;case 50:return 2;case 51:return 3;case 52:return 4;case 53:return 5;case 54:return 6;case 55:return 7;case 56:return 8;case 57:return 9;case R:case N:return 10;case 66:case 98:return 11;case 67:case 99:return 12;case 68:case 100:return 13;case 69:case 101:return 14;case 70:case 102:return 15;default:throw new SyntaxError(p(o,e))}}function k(e){if(e.coerceNullToEmptyString)return M(e,!1);if(e.impliedStringLiterals)throw new SyntaxError("JSON->URL: can not represent null with implied strings");return"null"}function M(e,t){if(t?e.allowEmptyUnquotedKeys:e.allowEmptyUnquotedValues)return J;if(e.AQF)return"!e";if(e.impliedStringLiterals)throw new SyntaxError(i);return"''"}!function(e){let{toJsonURLText_Array:t,toJsonURLText_Boolean:r,toJsonURLText_Number:s,toJsonURLText_Object:i,toJsonURLText_String:n}=e;Object.defineProperty(Array.prototype,"toJsonURLText",{value:t}),Object.defineProperty(Boolean.prototype,"toJsonURLText",{value:r}),Object.defineProperty(Number.prototype,"toJsonURLText",{value:s}),Object.defineProperty(Object.prototype,"toJsonURLText",{value:i}),Object.defineProperty(String.prototype,"toJsonURLText",{value:n})}({toJsonURLText_Array:function(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.forEach((function(s){if("function"==typeof s){if(!t.callFunctions)return;for(;"function"==typeof s;)s=s()}if(void 0===s){if(t.ignoreUndefinedArrayMembers)return;s=k(t)}else if(null===s){if(t.ignoreNullArrayMembers)return;s=k(t)}else s=m(s,t,r+1);void 0===e?e=s:!t.wwwFormUrlEncoded||r>0?e+=","+s:e+="&"+s})),!t.isImplied||r>0?void 0===e?"()":"("+e+")":void 0===e?J:e},toJsonURLText_Boolean:function(){return!0===this?"true":"false"},toJsonURLText_Number:function(e){const t=String(this);return e.impliedStringLiterals&&-1!==t.indexOf("+")?T(t,e):t},toJsonURLText_Object:function(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const s=Object.keys(this),i=this;return s.forEach((function(s){if(null==s)return;let n=i[s];if("function"==typeof n){if(!t.callFunctions)return;for(;"function"==typeof n;)n=n()}if(void 0===n){if(t.ignoreUndefinedObjectMembers)return;n=k(t)}else if(null===n){if(t.ignoreNullObjectMembers)return;n=k(t)}else n=m(n,t,r+1);const o=m(s,t,r,!0);void 0===e?e=!t.wwwFormUrlEncoded||r>0?o+":"+n:o+"="+n:!t.wwwFormUrlEncoded||r>0?e+=","+o+":"+n:e+="&"+o+"="+n})),!t.isImplied||r>0?(t.noEmptyComposite&&void 0===e&&(e=":"),void 0===e?"()":"("+e+")"):void 0===e?J:e},toJsonURLText_String:function(e,t,r){if(0===this.length)return M(e,r);if(e.impliedStringLiterals)return T(this,e.AQF);if("true"===(s=this)||"false"===s||"null"===s||g.test(s))return!0===r?this:e.AQF?-1==this.indexOf("+")?"!"+this:this.replace("+","!+"):-1==this.indexOf("+")?"'"+this+"'":encodeURIComponent(this);var s;if(e.AQF)return T(this,!0);if(O.test(this))return-1==this.indexOf(F)?this:this.replace(y,"+");if(A.test(this))return-1==this.indexOf(F)?"'"+this+"'":"'"+this.replace(y,"+")+"'";let i=T(this);return 39==i.charCodeAt(0)?"%27"+i.substring(1):i}});class _{constructor(e,t,r,s){this.text=e,this.pos=this.markPos=t,this.end=r,this.options=s}skipAmps(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=this.text,r=this.end;let s=this.pos;if(e)for(;s<r&&t.charCodeAt(s)===D;)s++;else if(s<r&&t.charCodeAt(s)===D){for(s++;s<r&&t.charCodeAt(s)===D;s++);s!==r&&s--}this.pos=s}structChar(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.options.wwwFormUrlEncoded){const t=this.text.charCodeAt(this.pos);switch(t){case D:case 61:if(e)return;return this.pos++,t}}const t=this.pos,r=this.ordinal();switch(r){case V:case C:if(e)return void(this.pos=t);case L:case U:return r;default:return void(this.pos=t)}}ordinal(e){return void 0!==e?this.text.charCodeAt(e):this.text.charCodeAt(this.pos++)}accept(e){const t=this.pos;return this.ordinal()===e||(this.pos=t,!1)}acceptPlus(){return 43==this.text.charCodeAt(this.pos)&&(this.pos++,!0)}done(){return this.end<=this.pos}validateLiteral(e,r){const s=this.text,i=this.end;for(;e<i;e++){switch(l(s.charCodeAt(e))&r){case 0:throw new SyntaxError(p(t,e));case u:return e;case 8:return e+1;default:continue}}}findLiteralEnd(){const e=this.text,t=this.end;let r=this.pos;const s=39===e.charCodeAt(r);s&&r++;const i=s?28:18;if(r=this.validateLiteral(r,i),void 0!==r)return r;if(s)throw new SyntaxError(p("JSON->URL: quoted string still open",r));return t}isEmptyObject(){if(this.options.noEmptyComposite){const e=this.pos;if(!this.accept(C))return!1;const t=this.pos,r=this.accept(U);return this.pos=r?t:e,r}return!1}parseLiteral(e){const t=this.pos,r=this.options,s=this.findLiteralEnd();if(void 0===e&&(e=this.ordinal(s)==C),s<=t){return function(e,t){if(t)return J;throw new SyntaxError(p(i,e))}(t,e?this.options.allowEmptyUnquotedKeys:this.options.allowEmptyUnquotedValues)}if(!0===r.impliedStringLiterals)return this.parseStringLiteral(s,!0);const n=this.parseTrueFalseNull(s,e);if(void 0!==n)return n;const o=this.parseNumberLiteral(s,e);return void 0!==o?o:this.parseStringLiteral(s,!1)}parseDigits(e){let t,r=!1;for(;this.pos<e;)switch(this.ordinal()){case j:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:t=this.pos,r=!0;continue;default:return this.pos=t,r}return this.pos=t,r}parseExponentValue(e){return!(e<=this.pos)&&(this.acceptPlus()||this.accept(45),this.parseDigits(e))}parseExponent(e){const t=this.pos;switch(this.ordinal()){case 69:case 101:if(this.parseExponentValue(e))return!0}return this.pos=t,!1}parseFraction(e){const t=this.pos;return!(e<=t)&&(!(!this.accept(46)||!this.parseDigits(e))||(this.pos=t,!1))}parseInteger(e){return!(e<=this.pos)&&(!!this.accept(j)||this.parseDigits(e))}parseNumberLiteral(e,t){const r=this.text,s=this.pos;if(this.accept(45),this.parseInteger(e)&&(this.parseFraction(e),this.parseExponent(e),this.pos===e)){const i=decodeURIComponent(r.substring(s,e));return t?i:Number(i)}this.pos=s}parseStringLiteral(e,t){const r=this.text,s=this.pos;let i=t||39!==r.charCodeAt(s)?r.substring(s,e):r.substring(s+1,e-1);return i=decodeURIComponent(i.replace(w,F)),this.pos=e,i}parseTrueFalseNull(e,t){const r=this.text,s=this.pos;let i,n,o,a,p;switch(e-s){case 4:if(i=r.charCodeAt(s),n=r.charCodeAt(s+1),o=r.charCodeAt(s+2),a=r.charCodeAt(s+3),116===i&&114===n&&117===o&&101===a)return this.pos=e,!t||"true";if(110===i&&117===n&&108===o&&108===a)return this.pos=e,t?"null":this.newNullValue();break;case 5:if(i=r.charCodeAt(s),n=r.charCodeAt(s+1),o=r.charCodeAt(s+2),a=r.charCodeAt(s+3),p=r.charCodeAt(s+4),102===i&&n===N&&108===o&&115===a&&101===p)return this.pos=e,!!t&&"false"}}newEmptyValue(){const e=this.options;if(e.noEmptyComposite)return[];const t=e.emptyValue;return"function"==typeof t?t():t}newNullValue(){const e=this.options;let t=e.nullValue;return"function"==typeof t&&(t=t()),null==t&&e.coerceNullToEmptyString&&(t=J),t}}class q extends _{constructor(e,t,r,s){super(e,t,r,s)}ordinal(e){const t=e||this.pos,r=this.text.charCodeAt(t);let s,i;return 37===r?(s=function(e,t,r){if(r<=t+1)throw new SyntaxError(p(o,t));return I(t,e.charCodeAt(t))<<4|I(t,e.charCodeAt(t+1))}(this.text,t+1,this.end),i=3):(s=r,i=1),void 0===e&&(this.pos+=i),s}acceptPlus(){return this.accept(43)}findLiteralEnd(){const e=this.end,r=this.pos,s=this.text;let i=r;for(;;){if(e<=this.pos)return this.pos=r,e;switch(50&l(s.charCodeAt(this.pos))){case 48:if(this.options.wwwFormUrlEncoded)return i=this.pos,this.pos=r,i;case 0:throw new SyntaxError(p(t,i))}switch(this.ordinal()){case L:case U:case C:case V:return this.pos=r,i;case 33:if(this.pos===e)throw new SyntaxError(p(n,i));this.ordinal(),i=this.pos;break;default:i=this.pos}}}parseStringLiteral(e){const t=this.text,r=this.pos,s=decodeURIComponent(t.substring(r,e).replace(w,F));return this.pos=e,"!e"===s?J:s.replace(x,(function(e,t,s){if(2===e.length){const t=e.charCodeAt(1),r=P[t];if(void 0!==r)return r}throw new SyntaxError(p(n,r+s))}))}}class $ extends Array{constructor(e){super(),this.limits=e,this.parseDepth=0}replaceAndPush(e,t,r){if(this[this.parseDepth]=t,++this.parseDepth>=this.limits.maxParseDepth)throw new Error(p("JSON->URL: MaxParseDepth exceeded",e));this.push(r)}replace(e){this[this.parseDepth]=e}depth(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&(this.parseDepth--,this.pop()),this.parseDepth}}class B extends Array{constructor(e){super(),this.limits=e,this.numValues=0}popObjectValue(e){let t=this.pop(),r=this.pop(),s=this[this.length-1];return null===t&&e.isPresentAndTrue("ignoreNullObjectMembers")||(s[r]=t),s}popArrayValue(e){let t=this.pop(),r=this[this.length-1];return null===t&&e.isPresentAndTrue("ignoreNullArrayMembers")||r.push(t),r}checkValueLimit(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this.numValues+=t,this.numValues>this.limits.maxParseValues+1)throw new Error(p("JSON->URL: MaxParseValues exceeded",e))}appendArrayValue(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this.checkValueLimit(e,r),this.push(t)}}function Q(e){for(;"function"==typeof e;)e=e();return e}function K(e,t,r,s){return"number"==typeof e?"number"!=typeof t&&(r=t):r=e,(r=Q(r))instanceof d||(r=new d(r,s)),r}function z(e,t,r,s){return s.AQF?new q(e,t,r,s):new _(e,t,r,s)}function Z(e,t){return"number"==typeof e?e:t}function G(i,n,o,u,c){if(void 0===i)return;u=K(n,o,u,c),i=String(i);const l=Z(n,0),h=Z(o,i.length);if(h<=l){if(void 0!==u.impliedArray)return u.impliedArray;if(void 0!==u.impliedObject)return u.impliedObject;throw new SyntaxError(p("JSON->URL: expected value",0))}if(h>u.maxParseChars)throw new Error("JSON->URL: MaxParseChars exceeded");const d=u.wwwFormUrlEncoded&&(u.impliedObject||u.impliedArray),f=new B(u),m=new $(u),w=z(i,l,h,u);if(void 0!==u.impliedObject)f.push(u.impliedObject),m.push(6);else if(void 0!==u.impliedArray)f.push(u.impliedArray),m.push(2);else{if(w.structChar(!0)!==L){const t=w.parseLiteral(!1);if(w.done())return t;throw new SyntaxError(p(e,0))}m.push(1)}for(d&&w.skipAmps(!0);;){if(w.done())throw new SyntaxError(p(r,w.pos));let i,n,o;switch(m[m.depth()]){case 1:switch(w.structChar(!0)){case L:f.appendArrayValue(w.pos,[]),m.replaceAndPush(w.pos,3,1);continue;case U:if(-1===m.depth(!0)){if(w.done())return w.newEmptyValue();throw new SyntaxError(p(s,w.pos))}if(f.appendArrayValue(w.pos,w.newEmptyValue()),0===m.depth()&&(d&&w.skipAmps(),w.done())){if(u.impliedArray)return f.popArrayValue(u);if(u.impliedObject)return f.popObjectValue(u);throw new SyntaxError(p(r,w.pos))}continue}switch(f.checkValueLimit(w.pos),n=w.isEmptyObject(),i=n?{}:w.parseLiteral(),o=w.pos,w.structChar()){case D:if(!u.wwwFormUrlEncoded||m.depth()>0)throw new SyntaxError(p(t,o));case V:m.replace(2),f.appendArrayValue(o,[]),f.push(i),f.popArrayValue(u);continue;case U:switch(n?f.push({}):f.appendArrayValue(o,[i]),m.depth(!0)){case-1:if(w.pos===h)return f[0];throw new SyntaxError(p(s,o));case 0:if(d&&w.skipAmps(),w.done()){if(u.impliedArray)return f.popArrayValue(u);if(u.impliedObject)return f.popObjectValue(u);throw new SyntaxError(p(r,o))}}continue;case 61:if(!u.wwwFormUrlEncoded||m.depth()>0)throw new SyntaxError(p(t,o));case C:m.replace(4),f.push({},i);continue;default:throw new SyntaxError(p(e,o))}case 2:if(w.accept(L)){m.replaceAndPush(w.pos,3,1);continue}if(f.checkValueLimit(w.pos),i=w.parseLiteral(!1),d&&w.skipAmps(),w.done()){if(0===m.depth()&&u.impliedArray)return f.push(i),f.popArrayValue(u);throw new SyntaxError(p(r,h))}m.replace(3),f.push(i);continue;case 3:switch(f.popArrayValue(u),w.structChar()){case D:if(!u.wwwFormUrlEncoded||m.depth()>0)throw new SyntaxError(p(t,w.pos));case V:m.replace(2);continue;case U:switch(m.depth(!0)){case-1:if(w.done()&&!u.impliedArray)return f[0];throw new SyntaxError(p(s,w.pos));case 0:if(d&&w.skipAmps(),w.done()){if(u.impliedArray)return f.popArrayValue(u);if(u.impliedObject)return f.popObjectValue(u);throw new SyntaxError(p(r,w.pos))}}continue}throw new SyntaxError(p("JSON->URL: expected comma or close paren",w.pos));case 4:if(w.accept(L)){m.replaceAndPush(w.pos,5,1);continue}if(f.checkValueLimit(w.pos),i=w.parseLiteral(!1),d&&w.skipAmps(),w.done()){if(0===m.depth()&&u.impliedObject)return f.push(i),f.popObjectValue(u);throw new SyntaxError(p(r,h))}m.replace(5),f.push(i);continue;case 5:switch(f.popObjectValue(u),o=w.pos,w.structChar()){case D:if(!u.wwwFormUrlEncoded||m.depth()>0)throw new SyntaxError(p(t,o));case V:m.replace(6);continue;case U:switch(m.depth(!0)){case-1:if(w.done()&&!u.impliedObject)return f[0];throw new SyntaxError(p(s,w.pos));case 0:if(d&&w.skipAmps(),w.done()){if(u.impliedArray)return f.popArrayValue(u);if(u.impliedObject)return f.popObjectValue(u);throw new SyntaxError(p(s,w.pos))}}continue}throw new SyntaxError(p("JSON->URL: expected comma, open paren, or close paren",w.pos));case 6:if(i=w.parseLiteral(!0),d&&w.skipAmps(),w.done()){if(u.impliedObject&&0==m.depth())return f.push(i,u.getMissingValue(i)),f.popObjectValue(u);throw new SyntaxError(p(r,h))}switch(w.structChar()){case 61:if(!u.wwwFormUrlEncoded||m.depth()>0)throw new SyntaxError(p(t,w.pos));case C:break;case D:if(!u.wwwFormUrlEncoded||m.depth()>0)throw new SyntaxError(p(t,w.pos));case V:if(u.impliedObject&&0==m.depth()){f.push(i,u.getMissingValue(i)),f.popObjectValue(u);continue}default:throw new SyntaxError(p(a,w.pos))}m.replace(4),f.push(i);continue;default:throw new SyntaxError(p("JSON->URL: internal error",w.pos))}}}return class{constructor(e){for(;"function"==typeof e;)e=e();void 0===e&&(e={}),this.maxParseDepth="number"==typeof e.maxParseDepth?parseInt(e.maxParseDepth):32,this.maxParseValues="number"==typeof e.maxParseValues?parseInt(e.maxParseValues):4096,this.maxParseChars="number"==typeof e.maxParseChars?parseInt(e.maxParseChars):32768,this.emptyValue=void 0===e.emptyValue?{}:e.emptyValue,this.nullValue=void 0===e.nullValue?null:e.nullValue}parseLiteral(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4?arguments[4]:void 0;void 0!==e&&(e=String(e)),void 0===r&&(r=e.length);return z(e,t,r,K(i)).parseLiteral(s)}static parse(e,t,r,s){return G(e,t,r,s,void 0)}parse(e,t,r,s){return G(e,t,r,s,this)}static stringify(e,t){if(void 0!==e)return t=new f(Q(t)),null===e?k(t):m(e,t,0)}}}));
/*!
* jsonurl.js v1.1.6
* jsonurl.js v1.1.7
* (c) 2022 David MacCormack
* Released under the MIT License.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).JsonURL=t()}(this,(function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&o(e,t)}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function a(e,t,r){return(a=s()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&o(i,r.prototype),i}).apply(null,arguments)}function u(e){var t="function"==typeof Map?new Map:void 0;return(u=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return a(e,arguments,i(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),o(n,e)})(e)}function c(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function l(e){var t=s();return function(){var r,n=i(e);if(t){var o=i(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return c(this,r)}}var p="JSON->URL: expected literal value",h="JSON->URL: unexpected character",f="JSON->URL: unexpected end of text inside composite",d="JSON->URL: unexpected text after composite",y="JSON->URL: MaxParseValues exceeded",v="JSON->URL: the empty string is not allowed",w="JSON->URL: invalid escape sequence",m="JSON->URL: invalid percent-encoded sequence",x="JSON->URL: expected object value";function O(e,t){return void 0===t?e:e+" at position "+t}var b=16,A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,6,6,48,10,20,20,6,6,20,6,6,6,6,6,6,6,6,6,6,6,6,6,20,6,0,48,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,0,6,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,6,0];function g(e){return e>127?0:A[e]}var E,S=function(){function t(r){e(this,t),this.setOrDefault(r,"allowEmptyUnquotedValues"),this.setOrDefault(r,"allowEmptyUnquotedKeys"),this.setOrDefault(r,"AQF"),this.setOrDefault(r,"coerceNullToEmptyString"),this.setOrDefault(r,"ignoreNullArrayMembers"),this.setOrDefault(r,"ignoreNullObjectMembers"),this.setOrDefault(r,"impliedArray"),this.setOrDefault(r,"impliedObject"),this.setOrDefault(r,"impliedStringLiterals"),this.setOrDefault(r,"noEmptyComposite"),this.setOrDefault(r,"wwwFormUrlEncoded")}return r(t,[{key:"setOrDefault",value:function(e,t,r){void 0!==e&&t in e?t in this||(this[t]=e[t]):void 0===r||t in this||(this[t]=r)}},{key:"setOverride",value:function(e,t){void 0!==e&&t in e&&(this[t]=e[t])}},{key:"setOrDefaultInt",value:function(e,t,r){this.setOrDefault(e,t,void 0===r?r:parseInt(r))}},{key:"isPresentAndTrue",value:function(e){return e in this&&this[e]}}]),t}(),V=function(t){n(o,t);var i=l(o);function o(t,r){var n;return e(this,o),(n=i.call(this,t)).setOrDefault(t,"emptyValue"),n.setOrDefault(r,"emptyValue",{}),n.setOverride(t,"getMissingValue"),n.setOrDefaultInt(t,"maxParseChars"),n.setOrDefaultInt(r,"maxParseChars",32768),n.setOrDefaultInt(t,"maxParseDepth"),n.setOrDefaultInt(r,"maxParseDepth",32),n.setOrDefaultInt(t,"maxParseValues"),n.setOrDefaultInt(r,"maxParseValues",4096),n.setOrDefault(t,"nullValue"),n.setOrDefault(r,"nullValue",null),n}return r(o,[{key:"getMissingValue",value:function(e,t){throw new SyntaxError(O(x,t))}}]),o}(S),k=function(t){n(o,t);var i=l(o);function o(t){var r;e(this,o),r=i.call(this,t);var n=!(void 0===t||!("impliedStringLiterals"in t)||!t.impliedStringLiterals)||void 0;return r.setOrDefault(t,"allowEmptyUnquotedValues",n),r.setOrDefault(t,"allowEmptyUnquotedKeys",n),r.setOrDefault(t,"callFunctions"),r.setOrDefault(t,"isImplied"),r.setOrDefault(t,"ignoreNullArrayMembers",n),r.setOrDefault(t,"ignoreNullObjectMembers",n),r.setOrDefault(t,"ignoreUndefinedArrayMembers",n),r.setOrDefault(t,"ignoreUndefinedObjectMembers",n),r.isImplied=r.isImplied||r.impliedArray||r.impliedObject,r}return r(o)}(S);function L(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return"boolean"==typeof e||e instanceof Boolean?E.toJsonURLText_Boolean.apply(e,r):"number"==typeof e||e instanceof Number?E.toJsonURLText_Number.apply(e,r):"string"==typeof e||e instanceof String?E.toJsonURLText_String.apply(e,r):Array.isArray(e)?E.toJsonURLText_Array.apply(e,r):E.toJsonURLText_Object.apply(e,r)}var U=/\+/g,C=/ /g,D=/(![\s\S]?)/g,j=/^[-A-Za-z0-9._~!$*;=@?/ ][-A-Za-z0-9._~!$*;=@?/' ]*$/,P=/^[-A-Za-z0-9._~!$*,;=@?/(): ]+$/,R=/^-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?$/,N=/[(),:]|%2[04]|%3B/gi,F={"%20":"+","%24":"$","(":"%28",")":"%29",",":"%2C",":":"%3A","%3B":";"},J=/[!(),:]|%2[01489C]|%3[AB]/gi,T={"%20":"+","%21":"!!","!":"!!","%24":"$","%28":"!(","(":"!(","%29":"!)",")":"!)","+":"!+","%2C":"!,",",":"!,","%3A":"!:",":":"!:","%3B":";"},I=40,M=41,_=44,q=58,B=38,$=48,Q=65,K=97,z=new Array(111);z[33]="!",z[40]="(",z[41]=")",z[43]="+",z[44]=",",z[45]=",",z[48]="0",z[49]="1",z[50]="2",z[51]="3",z[52]="4",z[53]="5",z[54]="6",z[55]="7",z[56]="8",z[57]="9",z[58]=":",z[116]="t",z[102]="f",z[110]="n";var Z="",G=" ";function H(e,t){var r=t?J:N,n=t?T:F;return encodeURIComponent(e).replace(r,(function(e){var t=n[e];return void 0===t?e:t}))}function W(e,t){switch(t){case $:return 0;case 49:return 1;case 50:return 2;case 51:return 3;case 52:return 4;case 53:return 5;case 54:return 6;case 55:return 7;case 56:return 8;case 57:return 9;case Q:case K:return 10;case 66:case 98:return 11;case 67:case 99:return 12;case 68:case 100:return 13;case 69:case 101:return 14;case 70:case 102:return 15;default:throw new SyntaxError(O(m,e))}}function X(e){if(e.coerceNullToEmptyString)return Y(e,!1);if(e.impliedStringLiterals)throw new SyntaxError("JSON->URL: can not represent null with implied strings");return"null"}function Y(e,t){if(t?e.allowEmptyUnquotedKeys:e.allowEmptyUnquotedValues)return Z;if(e.AQF)return"!e";if(e.impliedStringLiterals)throw new SyntaxError(v);return"''"}E={toJsonURLText_Array:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=void 0;return this.forEach((function(n){if("function"==typeof n){if(!e.callFunctions)return;for(;"function"==typeof n;)n=n()}if(void 0===n){if(e.ignoreUndefinedArrayMembers)return;n=X(e)}else if(null===n){if(e.ignoreNullArrayMembers)return;n=X(e)}else n=L(n,e,t+1);void 0===r?r=n:!e.wwwFormUrlEncoded||t>0?r+=","+n:r+="&"+n})),!e.isImplied||t>0?void 0===r?"()":"("+r+")":void 0===r?Z:r},toJsonURLText_Boolean:function(){return!0===this?"true":"false"},toJsonURLText_Number:function(e){var t=String(this);return e.impliedStringLiterals&&-1!==t.indexOf("+")?H(t,e):t},toJsonURLText_Object:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=void 0,n=Object.keys(this),i=this;return n.forEach((function(n){if(null!=n){var o=i[n];if("function"==typeof o){if(!e.callFunctions)return;for(;"function"==typeof o;)o=o()}if(void 0===o){if(e.ignoreUndefinedObjectMembers)return;o=X(e)}else if(null===o){if(e.ignoreNullObjectMembers)return;o=X(e)}else o=L(o,e,t+1);var s=L(n,e,t,!0);void 0===r?r=!e.wwwFormUrlEncoded||t>0?s+":"+o:s+"="+o:!e.wwwFormUrlEncoded||t>0?r+=","+s+":"+o:r+="&"+s+"="+o}})),!e.isImplied||t>0?(e.noEmptyComposite&&void 0===r&&(r=":"),void 0===r?"()":"("+r+")"):void 0===r?Z:r},toJsonURLText_String:function(e,t,r){if(0===this.length)return Y(e,r);if(e.impliedStringLiterals)return H(this,e.AQF);if("true"===(n=this)||"false"===n||"null"===n||R.test(n))return!0===r?this:e.AQF?-1==this.indexOf("+")?"!"+this:this.replace("+","!+"):-1==this.indexOf("+")?"'"+this+"'":encodeURIComponent(this);var n;if(e.AQF)return H(this,!0);if(j.test(this))return-1==this.indexOf(G)?this:this.replace(C,"+");if(P.test(this))return-1==this.indexOf(G)?"'"+this+"'":"'"+this.replace(C,"+")+"'";var i=H(this);return 39==i.charCodeAt(0)?"%27"+i.substring(1):i}};var ee=function(){function t(r,n,i,o){e(this,t),this.text=r,this.pos=this.markPos=n,this.end=i,this.options=o}return r(t,[{key:"skipAmps",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.text,r=this.end,n=this.pos;if(e)for(;n<r&&t.charCodeAt(n)===B;)n++;else if(n<r&&t.charCodeAt(n)===B){for(n++;n<r&&t.charCodeAt(n)===B;n++);n!==r&&n--}this.pos=n}},{key:"structChar",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.options.wwwFormUrlEncoded){var t=this.text.charCodeAt(this.pos);switch(t){case B:case 61:if(e)return;return this.pos++,t}}var r=this.pos,n=this.ordinal();switch(n){case _:case q:if(e)return void(this.pos=r);case I:case M:return n;default:return void(this.pos=r)}}},{key:"ordinal",value:function(e){return void 0!==e?this.text.charCodeAt(e):this.text.charCodeAt(this.pos++)}},{key:"accept",value:function(e){var t=this.pos;return this.ordinal()===e||(this.pos=t,!1)}},{key:"acceptPlus",value:function(){return 43==this.text.charCodeAt(this.pos)&&(this.pos++,!0)}},{key:"done",value:function(){return this.end<=this.pos}},{key:"validateLiteral",value:function(e,t){for(var r=this.text,n=this.end;e<n;e++){switch(g(r.charCodeAt(e))&t){case 0:throw new SyntaxError(O(h,e));case b:return e;case 8:return e+1;default:continue}}}},{key:"findLiteralEnd",value:function(){var e=this.text,t=this.end,r=this.pos,n=39===e.charCodeAt(r);n&&r++;var i=n?28:18;if(void 0!==(r=this.validateLiteral(r,i)))return r;if(n)throw new SyntaxError(O("JSON->URL: quoted string still open",r));return t}},{key:"isEmptyObject",value:function(){if(this.options.noEmptyComposite){var e=this.pos;if(!this.accept(q))return!1;var t=this.pos,r=this.accept(M);return this.pos=r?t:e,r}return!1}},{key:"parseLiteral",value:function(e){var t=this.pos,r=this.options,n=this.findLiteralEnd();if(void 0===e&&(e=this.ordinal(n)==q),n<=t)return function(e,t){if(t)return Z;throw new SyntaxError(O(v,e))}(t,e?this.options.allowEmptyUnquotedKeys:this.options.allowEmptyUnquotedValues);if(!0===r.impliedStringLiterals)return this.parseStringLiteral(n,!0);var i=this.parseTrueFalseNull(n,e);if(void 0!==i)return i;var o=this.parseNumberLiteral(n,e);return void 0!==o?o:this.parseStringLiteral(n,!1)}},{key:"parseDigits",value:function(e){for(var t,r=!1;this.pos<e;)switch(this.ordinal()){case $:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:t=this.pos,r=!0;continue;default:return this.pos=t,r}return this.pos=t,r}},{key:"parseExponentValue",value:function(e){return!(e<=this.pos)&&(this.acceptPlus()||this.accept(45),this.parseDigits(e))}},{key:"parseExponent",value:function(e){var t=this.pos;switch(this.ordinal()){case 69:case 101:if(this.parseExponentValue(e))return!0}return this.pos=t,!1}},{key:"parseFraction",value:function(e){var t=this.pos;return!(e<=t)&&(!(!this.accept(46)||!this.parseDigits(e))||(this.pos=t,!1))}},{key:"parseInteger",value:function(e){return!(e<=this.pos)&&(!!this.accept($)||this.parseDigits(e))}},{key:"parseNumberLiteral",value:function(e,t){var r=this.text,n=this.pos;if(this.accept(45),this.parseInteger(e)&&(this.parseFraction(e),this.parseExponent(e),this.pos===e)){var i=decodeURIComponent(r.substring(n,e));return t?i:Number(i)}this.pos=n}},{key:"parseStringLiteral",value:function(e,t){var r=this.text,n=this.pos,i=t||39!==r.charCodeAt(n)?r.substring(n,e):r.substring(n+1,e-1);return i=decodeURIComponent(i.replace(U,G)),this.pos=e,i}},{key:"parseTrueFalseNull",value:function(e,t){var r,n,i,o,s,a=this.text,u=this.pos;switch(e-u){case 4:if(r=a.charCodeAt(u),n=a.charCodeAt(u+1),i=a.charCodeAt(u+2),o=a.charCodeAt(u+3),116===r&&114===n&&117===i&&101===o)return this.pos=e,!t||"true";if(110===r&&117===n&&108===i&&108===o)return this.pos=e,t?"null":this.newNullValue();break;case 5:if(r=a.charCodeAt(u),n=a.charCodeAt(u+1),i=a.charCodeAt(u+2),o=a.charCodeAt(u+3),s=a.charCodeAt(u+4),102===r&&n===K&&108===i&&115===o&&101===s)return this.pos=e,!!t&&"false"}}},{key:"newEmptyValue",value:function(){var e=this.options;if(e.noEmptyComposite)return[];var t=e.emptyValue;return"function"==typeof t?t():t}},{key:"newNullValue",value:function(){var e=this.options,t=e.nullValue;return"function"==typeof t&&(t=t()),null==t&&e.coerceNullToEmptyString&&(t=Z),t}}]),t}(),te=function(t){n(o,t);var i=l(o);function o(t,r,n,s){return e(this,o),i.call(this,t,r,n,s)}return r(o,[{key:"ordinal",value:function(e){var t,r,n=e||this.pos,i=this.text.charCodeAt(n);return 37===i?(t=function(e,t,r){if(r<=t+1)throw new SyntaxError(O(m,t));return W(t,e.charCodeAt(t))<<4|W(t,e.charCodeAt(t+1))}(this.text,n+1,this.end),r=3):(t=i,r=1),void 0===e&&(this.pos+=r),t}},{key:"acceptPlus",value:function(){return this.accept(43)}},{key:"findLiteralEnd",value:function(){for(var e=this.end,t=this.pos,r=this.text,n=t;;){if(e<=this.pos)return this.pos=t,e;switch(50&g(r.charCodeAt(this.pos))){case 48:if(this.options.wwwFormUrlEncoded)return n=this.pos,this.pos=t,n;case 0:throw new SyntaxError(O(h,n))}switch(this.ordinal()){case I:case M:case q:case _:return this.pos=t,n;case 33:if(this.pos===e)throw new SyntaxError(O(w,n));this.ordinal(),n=this.pos;break;default:n=this.pos}}}},{key:"parseStringLiteral",value:function(e){var t=this.text,r=this.pos,n=decodeURIComponent(t.substring(r,e).replace(U,G));return this.pos=e,"!e"===n?Z:n.replace(D,(function(e,t,n){if(2===e.length){var i=e.charCodeAt(1),o=z[i];if(void 0!==o)return o}throw new SyntaxError(O(w,r+n))}))}}]),o}(ee),re=function(t){n(o,t);var i=l(o);function o(t){var r;return e(this,o),(r=i.call(this)).limits=t,r.parseDepth=0,r}return r(o,[{key:"replaceAndPush",value:function(e,t,r){if(this[this.parseDepth]=t,++this.parseDepth>=this.limits.maxParseDepth)throw new Error(O("JSON->URL: MaxParseDepth exceeded",e));this.push(r)}},{key:"replace",value:function(e){this[this.parseDepth]=e}},{key:"depth",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return e&&(this.parseDepth--,this.pop()),this.parseDepth}}]),o}(u(Array)),ne=function(t){n(o,t);var i=l(o);function o(t){var r;return e(this,o),(r=i.call(this)).limits=t,r.numValues=0,r}return r(o,[{key:"popObjectValue",value:function(e,t){t=t||this.pop();var r=this.pop(),n=this[this.length-1];return null===t&&e.isPresentAndTrue("ignoreNullObjectMembers")||(n[r]=t),n}},{key:"popArrayValue",value:function(e,t){t=t||this.pop();var r=this[this.length-1];return null===t&&e.isPresentAndTrue("ignoreNullArrayMembers")||r.push(t),r}},{key:"checkValueLimit",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this.numValues+=t,this.numValues>this.limits.maxParseValues+1)throw new Error(O(y,e))}},{key:"appendArrayValue",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this.checkValueLimit(e,r),this.push(t)}}]),o}(u(Array));function ie(e){for(;"function"==typeof e;)e=e();return e}function oe(e,t,r,n){return"number"==typeof e?"number"!=typeof t&&(r=t):r=e,(r=ie(r))instanceof V||(r=new V(r,n)),r}function se(e,t,r,n){return n.AQF?new te(e,t,r,n):new ee(e,t,r,n)}function ae(e,t){return"number"==typeof e?e:t}function ue(e,t,r,n,i){if(void 0!==e){n=oe(t,r,n,i),e=String(e);var o=ae(t,0),s=ae(r,e.length);if(s<=o){if(void 0!==n.impliedArray)return n.impliedArray;if(void 0!==n.impliedObject)return n.impliedObject;throw new SyntaxError(O("JSON->URL: expected value",0))}if(s>n.maxParseChars)throw new Error("JSON->URL: MaxParseChars exceeded");var a=n.wwwFormUrlEncoded&&(n.impliedObject||n.impliedArray),u=new ne(n),c=new re(n),l=se(e,o,s,n);if(void 0!==n.impliedObject)u.push(n.impliedObject),c.push(6);else if(void 0!==n.impliedArray)u.push(n.impliedArray),c.push(2);else{if(l.structChar(!0)!==I){var y=l.parseLiteral(!1);if(l.done())return y;throw new SyntaxError(O(p,0))}c.push(1)}for(a&&l.skipAmps(!0);;){if(l.done())throw new SyntaxError(O(f,l.pos));var v=void 0,w=void 0,m=void 0;switch(c[c.depth()]){case 1:switch(l.structChar(!0)){case I:u.appendArrayValue(l.pos,[]),c.replaceAndPush(l.pos,3,1);continue;case M:if(-1===c.depth(!0)){if(l.done())return l.newEmptyValue();throw new SyntaxError(O(d,l.pos))}if(u.appendArrayValue(l.pos,l.newEmptyValue()),0===c.depth()&&(a&&l.skipAmps(),l.done())){if(n.impliedArray)return u.popArrayValue(n);if(n.impliedObject)return u.popObjectValue(n);throw new SyntaxError(O(f,l.pos))}continue}switch(u.checkValueLimit(l.pos),v=(w=l.isEmptyObject())?{}:l.parseLiteral(),m=l.pos,l.structChar()){case B:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,m));case _:c.replace(2),u.appendArrayValue(m,[]),u.push(v),u.popArrayValue(n);continue;case M:switch(w?u.push({}):u.appendArrayValue(m,[v]),c.depth(!0)){case-1:if(l.pos===s)return u[0];throw new SyntaxError(O(d,m));case 0:if(a&&l.skipAmps(),l.done()){if(n.impliedArray)return u.popArrayValue(n);if(n.impliedObject)return u.popObjectValue(n);throw new SyntaxError(O(f,m))}}continue;case 61:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,m));case q:c.replace(4),u.push({},v);continue;default:throw new SyntaxError(O(p,m))}case 2:if(l.accept(I)){c.replaceAndPush(l.pos,3,1);continue}if(u.checkValueLimit(l.pos),v=l.parseLiteral(!1),a&&l.skipAmps(),l.done()){if(0===c.depth()&&n.impliedArray)return u.popArrayValue(n,v);throw new SyntaxError(O(f,s))}c.replace(3),u.push(v);continue;case 3:switch(u.popArrayValue(n),l.structChar()){case B:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,l.pos));case _:c.replace(2);continue;case M:switch(c.depth(!0)){case-1:if(l.done()&&!n.impliedArray)return u[0];throw new SyntaxError(O(d,l.pos));case 0:if(a&&l.skipAmps(),l.done()){if(n.impliedArray)return u.popArrayValue(n);if(n.impliedObject)return u.popObjectValue(n);throw new SyntaxError(O(f,l.pos))}}continue}throw new SyntaxError(O("JSON->URL: expected comma or close paren",l.pos));case 4:if(l.accept(I)){c.replaceAndPush(l.pos,5,1);continue}if(u.checkValueLimit(l.pos),v=l.parseLiteral(!1),a&&l.skipAmps(),l.done()){if(0===c.depth()&&n.impliedObject)return u.popObjectValue(n,v);throw new SyntaxError(O(f,s))}c.replace(5),u.push(v);continue;case 5:switch(u.popObjectValue(n),m=l.pos,l.structChar()){case B:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,m));case _:c.replace(6);continue;case M:switch(c.depth(!0)){case-1:if(l.done()&&!n.impliedObject)return u[0];throw new SyntaxError(O(d,l.pos));case 0:if(a&&l.skipAmps(),l.done()){if(n.impliedArray)return u.popArrayValue(n);if(n.impliedObject)return u.popObjectValue(n);throw new SyntaxError(O(d,l.pos))}}continue}throw new SyntaxError(O("JSON->URL: expected comma, open paren, or close paren",l.pos));case 6:if(v=l.parseLiteral(!0),a&&l.skipAmps(),l.done()){if(n.impliedObject&&0==c.depth())return u.push(v,n.getMissingValue(v)),u.popObjectValue(n);throw new SyntaxError(O(f,s))}switch(l.structChar()){case 61:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,l.pos));case q:break;case B:if(!n.wwwFormUrlEncoded||c.depth()>0)throw new SyntaxError(O(h,l.pos));case _:if(n.impliedObject&&0==c.depth()){u.push(v,n.getMissingValue(v)),u.popObjectValue(n);continue}default:throw new SyntaxError(O(x,l.pos))}c.replace(4),u.push(v);continue;default:throw new SyntaxError(O("JSON->URL: internal error",l.pos))}}}}return function(){function t(r){for(e(this,t);"function"==typeof r;)r=r();void 0===r&&(r={}),this.maxParseDepth="number"==typeof r.maxParseDepth?parseInt(r.maxParseDepth):32,this.maxParseValues="number"==typeof r.maxParseValues?parseInt(r.maxParseValues):4096,this.maxParseChars="number"==typeof r.maxParseChars?parseInt(r.maxParseChars):32768,this.emptyValue=void 0===r.emptyValue?{}:r.emptyValue,this.nullValue=void 0===r.nullValue?null:r.nullValue}return r(t,[{key:"parseLiteral",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4?arguments[4]:void 0;void 0!==e&&(e=String(e)),void 0===r&&(r=e.length);var o=se(e,t,r,oe(i));return o.parseLiteral(n)}},{key:"parse",value:function(e,t,r,n){return ue(e,t,r,n,this)}}],[{key:"parse",value:function(e,t,r,n){return ue(e,t,r,n,void 0)}},{key:"stringify",value:function(e,t){if(void 0!==e)return t=new k(ie(t)),null===e?X(t):L(e,t,0)}}]),t}()}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).JsonURL=t()}(this,(function(){"use strict";const e="JSON->URL: expected literal value",t="JSON->URL: unexpected character",r="JSON->URL: unexpected end of text inside composite",s="JSON->URL: unexpected text after composite",i="JSON->URL: the empty string is not allowed",n="JSON->URL: invalid escape sequence",o="JSON->URL: invalid percent-encoded sequence",a="JSON->URL: expected object value";function p(e,t){return void 0===t?e:e+" at position "+t}const u=16,c=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,6,6,48,10,20,20,6,6,20,6,6,6,6,6,6,6,6,6,6,6,6,6,20,6,0,48,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,0,6,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,6,0];function l(e){return e>127?0:c[e]}class h{constructor(e){this.setOrDefault(e,"allowEmptyUnquotedValues"),this.setOrDefault(e,"allowEmptyUnquotedKeys"),this.setOrDefault(e,"AQF"),this.setOrDefault(e,"coerceNullToEmptyString"),this.setOrDefault(e,"ignoreNullArrayMembers"),this.setOrDefault(e,"ignoreNullObjectMembers"),this.setOrDefault(e,"impliedArray"),this.setOrDefault(e,"impliedObject"),this.setOrDefault(e,"impliedStringLiterals"),this.setOrDefault(e,"noEmptyComposite"),this.setOrDefault(e,"wwwFormUrlEncoded")}setOrDefault(e,t,r){void 0!==e&&t in e?t in this||(this[t]=e[t]):void 0===r||t in this||(this[t]=r)}setOverride(e,t){void 0!==e&&t in e&&(this[t]=e[t])}setOrDefaultInt(e,t,r){this.setOrDefault(e,t,void 0===r?r:parseInt(r))}isPresentAndTrue(e){return e in this&&this[e]}}class d extends h{constructor(e,t){super(e),this.setOrDefault(e,"emptyValue"),this.setOrDefault(t,"emptyValue",{}),this.setOverride(e,"getMissingValue"),this.setOrDefaultInt(e,"maxParseChars"),this.setOrDefaultInt(t,"maxParseChars",32768),this.setOrDefaultInt(e,"maxParseDepth"),this.setOrDefaultInt(t,"maxParseDepth",32),this.setOrDefaultInt(e,"maxParseValues"),this.setOrDefaultInt(t,"maxParseValues",4096),this.setOrDefault(e,"nullValue"),this.setOrDefault(t,"nullValue",null)}getMissingValue(e,t){throw new SyntaxError(p(a,t))}}class f extends h{constructor(e){super(e);const t=!(void 0===e||!("impliedStringLiterals"in e)||!e.impliedStringLiterals)||void 0;this.setOrDefault(e,"allowEmptyUnquotedValues",t),this.setOrDefault(e,"allowEmptyUnquotedKeys",t),this.setOrDefault(e,"callFunctions"),this.setOrDefault(e,"isImplied"),this.setOrDefault(e,"ignoreNullArrayMembers",t),this.setOrDefault(e,"ignoreNullObjectMembers",t),this.setOrDefault(e,"ignoreUndefinedArrayMembers",t),this.setOrDefault(e,"ignoreUndefinedObjectMembers",t),this.isImplied=this.isImplied||this.impliedArray||this.impliedObject}}let m;function w(e,...t){return"boolean"==typeof e||e instanceof Boolean?m.toJsonURLText_Boolean.apply(e,t):"number"==typeof e||e instanceof Number?m.toJsonURLText_Number.apply(e,t):"string"==typeof e||e instanceof String?m.toJsonURLText_String.apply(e,t):Array.isArray(e)?m.toJsonURLText_Array.apply(e,t):m.toJsonURLText_Object.apply(e,t)}const y=/\+/g,x=/ /g,A=/(![\s\S]?)/g,O=/^[-A-Za-z0-9._~!$*;=@?/ ][-A-Za-z0-9._~!$*;=@?/' ]*$/,E=/^[-A-Za-z0-9._~!$*,;=@?/(): ]+$/,S=/^-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?$/,b=/[(),:]|%2[04]|%3B/gi,g={"%20":"+","%24":"$","(":"%28",")":"%29",",":"%2C",":":"%3A","%3B":";"},V=/[!(),:]|%2[01489C]|%3[AB]/gi,L={"%20":"+","%21":"!!","!":"!!","%24":"$","%28":"!(","(":"!(","%29":"!)",")":"!)","+":"!+","%2C":"!,",",":"!,","%3A":"!:",":":"!:","%3B":";"},U=40,C=41,D=44,v=58,N=38,j=48,R=65,P=97,J=new Array(111);J[33]="!",J[40]="(",J[41]=")",J[43]="+",J[44]=",",J[45]=",",J[48]="0",J[49]="1",J[50]="2",J[51]="3",J[52]="4",J[53]="5",J[54]="6",J[55]="7",J[56]="8",J[57]="9",J[58]=":",J[116]="t",J[102]="f",J[110]="n";const F="",I=" ";function T(e,t){const r=t?V:b,s=t?L:g;return encodeURIComponent(e).replace(r,(function(e){const t=s[e];return void 0===t?e:t}))}function k(e,t){switch(t){case j:return 0;case 49:return 1;case 50:return 2;case 51:return 3;case 52:return 4;case 53:return 5;case 54:return 6;case 55:return 7;case 56:return 8;case 57:return 9;case R:case P:return 10;case 66:case 98:return 11;case 67:case 99:return 12;case 68:case 100:return 13;case 69:case 101:return 14;case 70:case 102:return 15;default:throw new SyntaxError(p(o,e))}}function M(e){if(e.coerceNullToEmptyString)return _(e,!1);if(e.impliedStringLiterals)throw new SyntaxError("JSON->URL: can not represent null with implied strings");return"null"}function _(e,t){if(t?e.allowEmptyUnquotedKeys:e.allowEmptyUnquotedValues)return F;if(e.AQF)return"!e";if(e.impliedStringLiterals)throw new SyntaxError(i);return"''"}m={toJsonURLText_Array:function(e={},t=0){let r;return this.forEach((function(s){if("function"==typeof s){if(!e.callFunctions)return;for(;"function"==typeof s;)s=s()}if(void 0===s){if(e.ignoreUndefinedArrayMembers)return;s=M(e)}else if(null===s){if(e.ignoreNullArrayMembers)return;s=M(e)}else s=w(s,e,t+1);void 0===r?r=s:!e.wwwFormUrlEncoded||t>0?r+=","+s:r+="&"+s})),!e.isImplied||t>0?void 0===r?"()":"("+r+")":void 0===r?F:r},toJsonURLText_Boolean:function(){return!0===this?"true":"false"},toJsonURLText_Number:function(e){const t=String(this);return e.impliedStringLiterals&&-1!==t.indexOf("+")?T(t,e):t},toJsonURLText_Object:function(e={},t=0){let r;const s=Object.keys(this),i=this;return s.forEach((function(s){if(null==s)return;let n=i[s];if("function"==typeof n){if(!e.callFunctions)return;for(;"function"==typeof n;)n=n()}if(void 0===n){if(e.ignoreUndefinedObjectMembers)return;n=M(e)}else if(null===n){if(e.ignoreNullObjectMembers)return;n=M(e)}else n=w(n,e,t+1);const o=w(s,e,t,!0);void 0===r?r=!e.wwwFormUrlEncoded||t>0?o+":"+n:o+"="+n:!e.wwwFormUrlEncoded||t>0?r+=","+o+":"+n:r+="&"+o+"="+n})),!e.isImplied||t>0?(e.noEmptyComposite&&void 0===r&&(r=":"),void 0===r?"()":"("+r+")"):void 0===r?F:r},toJsonURLText_String:function(e,t,r){if(0===this.length)return _(e,r);if(e.impliedStringLiterals)return T(this,e.AQF);if("true"===(s=this)||"false"===s||"null"===s||S.test(s))return!0===r?this:e.AQF?-1==this.indexOf("+")?"!"+this:this.replace("+","!+"):-1==this.indexOf("+")?"'"+this+"'":encodeURIComponent(this);var s;if(e.AQF)return T(this,!0);if(O.test(this))return-1==this.indexOf(I)?this:this.replace(x,"+");if(E.test(this))return-1==this.indexOf(I)?"'"+this+"'":"'"+this.replace(x,"+")+"'";let i=T(this);return 39==i.charCodeAt(0)?"%27"+i.substring(1):i}};class q{constructor(e,t,r,s){this.text=e,this.pos=this.markPos=t,this.end=r,this.options=s}skipAmps(e=!1){const t=this.text,r=this.end;let s=this.pos;if(e)for(;s<r&&t.charCodeAt(s)===N;)s++;else if(s<r&&t.charCodeAt(s)===N){for(s++;s<r&&t.charCodeAt(s)===N;s++);s!==r&&s--}this.pos=s}structChar(e=!1){if(this.options.wwwFormUrlEncoded){const t=this.text.charCodeAt(this.pos);switch(t){case N:case 61:if(e)return;return this.pos++,t}}const t=this.pos,r=this.ordinal();switch(r){case D:case v:if(e)return void(this.pos=t);case U:case C:return r;default:return void(this.pos=t)}}ordinal(e){return void 0!==e?this.text.charCodeAt(e):this.text.charCodeAt(this.pos++)}accept(e){const t=this.pos;return this.ordinal()===e||(this.pos=t,!1)}acceptPlus(){return 43==this.text.charCodeAt(this.pos)&&(this.pos++,!0)}done(){return this.end<=this.pos}validateLiteral(e,r){const s=this.text,i=this.end;for(;e<i;e++){switch(l(s.charCodeAt(e))&r){case 0:throw new SyntaxError(p(t,e));case u:return e;case 8:return e+1;default:continue}}}findLiteralEnd(){const e=this.text,t=this.end;let r=this.pos;const s=39===e.charCodeAt(r);s&&r++;const i=s?28:18;if(r=this.validateLiteral(r,i),void 0!==r)return r;if(s)throw new SyntaxError(p("JSON->URL: quoted string still open",r));return t}isEmptyObject(){if(this.options.noEmptyComposite){const e=this.pos;if(!this.accept(v))return!1;const t=this.pos,r=this.accept(C);return this.pos=r?t:e,r}return!1}parseLiteral(e){const t=this.pos,r=this.options,s=this.findLiteralEnd();if(void 0===e&&(e=this.ordinal(s)==v),s<=t){return function(e,t){if(t)return F;throw new SyntaxError(p(i,e))}(t,e?this.options.allowEmptyUnquotedKeys:this.options.allowEmptyUnquotedValues)}if(!0===r.impliedStringLiterals)return this.parseStringLiteral(s,!0);const n=this.parseTrueFalseNull(s,e);if(void 0!==n)return n;const o=this.parseNumberLiteral(s,e);return void 0!==o?o:this.parseStringLiteral(s,!1)}parseDigits(e){let t,r=!1;for(;this.pos<e;)switch(this.ordinal()){case j:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:t=this.pos,r=!0;continue;default:return this.pos=t,r}return this.pos=t,r}parseExponentValue(e){return!(e<=this.pos)&&(this.acceptPlus()||this.accept(45),this.parseDigits(e))}parseExponent(e){const t=this.pos;switch(this.ordinal()){case 69:case 101:if(this.parseExponentValue(e))return!0}return this.pos=t,!1}parseFraction(e){const t=this.pos;return!(e<=t)&&(!(!this.accept(46)||!this.parseDigits(e))||(this.pos=t,!1))}parseInteger(e){return!(e<=this.pos)&&(!!this.accept(j)||this.parseDigits(e))}parseNumberLiteral(e,t){const r=this.text,s=this.pos;if(this.accept(45),this.parseInteger(e)&&(this.parseFraction(e),this.parseExponent(e),this.pos===e)){const i=decodeURIComponent(r.substring(s,e));return t?i:Number(i)}this.pos=s}parseStringLiteral(e,t){const r=this.text,s=this.pos;let i=t||39!==r.charCodeAt(s)?r.substring(s,e):r.substring(s+1,e-1);return i=decodeURIComponent(i.replace(y,I)),this.pos=e,i}parseTrueFalseNull(e,t){const r=this.text,s=this.pos;let i,n,o,a,p;switch(e-s){case 4:if(i=r.charCodeAt(s),n=r.charCodeAt(s+1),o=r.charCodeAt(s+2),a=r.charCodeAt(s+3),116===i&&114===n&&117===o&&101===a)return this.pos=e,!t||"true";if(110===i&&117===n&&108===o&&108===a)return this.pos=e,t?"null":this.newNullValue();break;case 5:if(i=r.charCodeAt(s),n=r.charCodeAt(s+1),o=r.charCodeAt(s+2),a=r.charCodeAt(s+3),p=r.charCodeAt(s+4),102===i&&n===P&&108===o&&115===a&&101===p)return this.pos=e,!!t&&"false"}}newEmptyValue(){const e=this.options;if(e.noEmptyComposite)return[];const t=e.emptyValue;return"function"==typeof t?t():t}newNullValue(){const e=this.options;let t=e.nullValue;return"function"==typeof t&&(t=t()),null==t&&e.coerceNullToEmptyString&&(t=F),t}}class $ extends q{constructor(e,t,r,s){super(e,t,r,s)}ordinal(e){const t=e||this.pos,r=this.text.charCodeAt(t);let s,i;return 37===r?(s=function(e,t,r){if(r<=t+1)throw new SyntaxError(p(o,t));return k(t,e.charCodeAt(t))<<4|k(t,e.charCodeAt(t+1))}(this.text,t+1,this.end),i=3):(s=r,i=1),void 0===e&&(this.pos+=i),s}acceptPlus(){return this.accept(43)}findLiteralEnd(){const e=this.end,r=this.pos,s=this.text;let i=r;for(;;){if(e<=this.pos)return this.pos=r,e;switch(50&l(s.charCodeAt(this.pos))){case 48:if(this.options.wwwFormUrlEncoded)return i=this.pos,this.pos=r,i;case 0:throw new SyntaxError(p(t,i))}switch(this.ordinal()){case U:case C:case v:case D:return this.pos=r,i;case 33:if(this.pos===e)throw new SyntaxError(p(n,i));this.ordinal(),i=this.pos;break;default:i=this.pos}}}parseStringLiteral(e){const t=this.text,r=this.pos,s=decodeURIComponent(t.substring(r,e).replace(y,I));return this.pos=e,"!e"===s?F:s.replace(A,(function(e,t,s){if(2===e.length){const t=e.charCodeAt(1),r=J[t];if(void 0!==r)return r}throw new SyntaxError(p(n,r+s))}))}}class B extends Array{constructor(e){super(),this.limits=e,this.parseDepth=0}replaceAndPush(e,t,r){if(this[this.parseDepth]=t,++this.parseDepth>=this.limits.maxParseDepth)throw new Error(p("JSON->URL: MaxParseDepth exceeded",e));this.push(r)}replace(e){this[this.parseDepth]=e}depth(e=!1){return e&&(this.parseDepth--,this.pop()),this.parseDepth}}class Q extends Array{constructor(e){super(),this.limits=e,this.numValues=0}popObjectValue(e){let t=this.pop(),r=this.pop(),s=this[this.length-1];return null===t&&e.isPresentAndTrue("ignoreNullObjectMembers")||(s[r]=t),s}popArrayValue(e){let t=this.pop(),r=this[this.length-1];return null===t&&e.isPresentAndTrue("ignoreNullArrayMembers")||r.push(t),r}checkValueLimit(e,t=1){if(this.numValues+=t,this.numValues>this.limits.maxParseValues+1)throw new Error(p("JSON->URL: MaxParseValues exceeded",e))}appendArrayValue(e,t,r=1){this.checkValueLimit(e,r),this.push(t)}}function K(e){for(;"function"==typeof e;)e=e();return e}function z(e,t,r,s){return"number"==typeof e?"number"!=typeof t&&(r=t):r=e,(r=K(r))instanceof d||(r=new d(r,s)),r}function Z(e,t,r,s){return s.AQF?new $(e,t,r,s):new q(e,t,r,s)}function G(e,t){return"number"==typeof e?e:t}function H(i,n,o,u,c){if(void 0===i)return;u=z(n,o,u,c),i=String(i);const l=G(n,0),h=G(o,i.length);if(h<=l){if(void 0!==u.impliedArray)return u.impliedArray;if(void 0!==u.impliedObject)return u.impliedObject;throw new SyntaxError(p("JSON->URL: expected value",0))}if(h>u.maxParseChars)throw new Error("JSON->URL: MaxParseChars exceeded");const d=u.wwwFormUrlEncoded&&(u.impliedObject||u.impliedArray),f=new Q(u),m=new B(u),w=Z(i,l,h,u);if(void 0!==u.impliedObject)f.push(u.impliedObject),m.push(6);else if(void 0!==u.impliedArray)f.push(u.impliedArray),m.push(2);else{if(w.structChar(!0)!==U){const t=w.parseLiteral(!1);if(w.done())return t;throw new SyntaxError(p(e,0))}m.push(1)}for(d&&w.skipAmps(!0);;){if(w.done())throw new SyntaxError(p(r,w.pos));let i,n,o;switch(m[m.depth()]){case 1:switch(w.structChar(!0)){case U:f.appendArrayValue(w.pos,[]),m.replaceAndPush(w.pos,3,1);continue;case C:if(-1===m.depth(!0)){if(w.done())return w.newEmptyValue();throw new SyntaxError(p(s,w.pos))}if(f.appendArrayValue(w.pos,w.newEmptyValue()),0===m.depth()&&(d&&w.skipAmps(),w.done())){if(u.impliedArray)return f.popArrayValue(u);if(u.impliedObject)return f.popObjectValue(u);throw new SyntaxError(p(r,w.pos))}continue}switch(f.checkValueLimit(w.pos),n=w.isEmptyObject(),i=n?{}:w.parseLiteral(),o=w.pos,w.structChar()){case N:if(!u.wwwFormUrlEncoded||m.depth()>0)throw new SyntaxError(p(t,o));case D:m.replace(2),f.appendArrayValue(o,[]),f.push(i),f.popArrayValue(u);continue;case C:switch(n?f.push({}):f.appendArrayValue(o,[i]),m.depth(!0)){case-1:if(w.pos===h)return f[0];throw new SyntaxError(p(s,o));case 0:if(d&&w.skipAmps(),w.done()){if(u.impliedArray)return f.popArrayValue(u);if(u.impliedObject)return f.popObjectValue(u);throw new SyntaxError(p(r,o))}}continue;case 61:if(!u.wwwFormUrlEncoded||m.depth()>0)throw new SyntaxError(p(t,o));case v:m.replace(4),f.push({},i);continue;default:throw new SyntaxError(p(e,o))}case 2:if(w.accept(U)){m.replaceAndPush(w.pos,3,1);continue}if(f.checkValueLimit(w.pos),i=w.parseLiteral(!1),d&&w.skipAmps(),w.done()){if(0===m.depth()&&u.impliedArray)return f.push(i),f.popArrayValue(u);throw new SyntaxError(p(r,h))}m.replace(3),f.push(i);continue;case 3:switch(f.popArrayValue(u),w.structChar()){case N:if(!u.wwwFormUrlEncoded||m.depth()>0)throw new SyntaxError(p(t,w.pos));case D:m.replace(2);continue;case C:switch(m.depth(!0)){case-1:if(w.done()&&!u.impliedArray)return f[0];throw new SyntaxError(p(s,w.pos));case 0:if(d&&w.skipAmps(),w.done()){if(u.impliedArray)return f.popArrayValue(u);if(u.impliedObject)return f.popObjectValue(u);throw new SyntaxError(p(r,w.pos))}}continue}throw new SyntaxError(p("JSON->URL: expected comma or close paren",w.pos));case 4:if(w.accept(U)){m.replaceAndPush(w.pos,5,1);continue}if(f.checkValueLimit(w.pos),i=w.parseLiteral(!1),d&&w.skipAmps(),w.done()){if(0===m.depth()&&u.impliedObject)return f.push(i),f.popObjectValue(u);throw new SyntaxError(p(r,h))}m.replace(5),f.push(i);continue;case 5:switch(f.popObjectValue(u),o=w.pos,w.structChar()){case N:if(!u.wwwFormUrlEncoded||m.depth()>0)throw new SyntaxError(p(t,o));case D:m.replace(6);continue;case C:switch(m.depth(!0)){case-1:if(w.done()&&!u.impliedObject)return f[0];throw new SyntaxError(p(s,w.pos));case 0:if(d&&w.skipAmps(),w.done()){if(u.impliedArray)return f.popArrayValue(u);if(u.impliedObject)return f.popObjectValue(u);throw new SyntaxError(p(s,w.pos))}}continue}throw new SyntaxError(p("JSON->URL: expected comma, open paren, or close paren",w.pos));case 6:if(i=w.parseLiteral(!0),d&&w.skipAmps(),w.done()){if(u.impliedObject&&0==m.depth())return f.push(i,u.getMissingValue(i)),f.popObjectValue(u);throw new SyntaxError(p(r,h))}switch(w.structChar()){case 61:if(!u.wwwFormUrlEncoded||m.depth()>0)throw new SyntaxError(p(t,w.pos));case v:break;case N:if(!u.wwwFormUrlEncoded||m.depth()>0)throw new SyntaxError(p(t,w.pos));case D:if(u.impliedObject&&0==m.depth()){f.push(i,u.getMissingValue(i)),f.popObjectValue(u);continue}default:throw new SyntaxError(p(a,w.pos))}m.replace(4),f.push(i);continue;default:throw new SyntaxError(p("JSON->URL: internal error",w.pos))}}}return class{constructor(e){for(;"function"==typeof e;)e=e();void 0===e&&(e={}),this.maxParseDepth="number"==typeof e.maxParseDepth?parseInt(e.maxParseDepth):32,this.maxParseValues="number"==typeof e.maxParseValues?parseInt(e.maxParseValues):4096,this.maxParseChars="number"==typeof e.maxParseChars?parseInt(e.maxParseChars):32768,this.emptyValue=void 0===e.emptyValue?{}:e.emptyValue,this.nullValue=void 0===e.nullValue?null:e.nullValue}parseLiteral(e,t=0,r,s=!1,i){void 0!==e&&(e=String(e)),void 0===r&&(r=e.length);return Z(e,t,r,z(i)).parseLiteral(s)}static parse(e,t,r,s){return H(e,t,r,s,void 0)}parse(e,t,r,s){return H(e,t,r,s,this)}static stringify(e,t){if(void 0!==e)return t=new f(K(t)),null===e?M(t):w(e,t,0)}}}));
{
"name": "@jsonurl/jsonurl",
"version": "1.1.6",
"version": "1.1.7",
"publishConfig": {

@@ -34,3 +34,2 @@ "access": "public"

"homepage": "https://www.jsonurl.org/",
"peerDependencies": {},
"devDependencies": {

@@ -40,14 +39,14 @@ "@babel/cli": "^7.15.4",

"@babel/preset-env": "^7.15.4",
"@rollup/plugin-alias": "^3.1.9",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-replace": "^3.0.1",
"babel-jest": "^27.1.0",
"editorconfig": "^0.15.3",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jest": "^26.0.0",
"eslint-plugin-prettier": "^3.4.1",
"jest": "^27.1.0",
"@rollup/plugin-alias": "^4.0.0",
"@rollup/plugin-babel": "^6.0.0",
"@rollup/plugin-replace": "^5.0.0",
"babel-jest": "^29.2.0",
"editorconfig": "^1.0.0",
"eslint": "^8.25.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^27.1.2",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.2.0",
"jsdoc": "^3.6.7",
"prettier": "^2.3.0",
"prettier": "^2.7.1",
"rollup": "^2.56.3",

@@ -54,0 +53,0 @@ "rollup-plugin-eslint": "^7.0.0",

@@ -54,4 +54,4 @@ # JSON→URL

<script
src="https://cdn.jsdelivr.net/npm/@jsonurl/jsonurl@1.1.6"
integrity="sha512-XwwFcB+WGRTO/klfJWwRoi0xGhMVvZyioqS1p/kyOyHc9o/EExDVXTCsIwldO05Ad9R9E1zwgNZhVPNNqyhrFQ=="
src="https://cdn.jsdelivr.net/npm/@jsonurl/jsonurl@1.1.7"
integrity="sha512-5dbEkq6X5f3wvvLg43JjSbTU90d/UPu8VV+aFmlPnqKgoUZJlq4hmug6EelX7TJgLLsqtm0VMooPMH1Vd1O3Vg=="
crossorigin="anonymous"></script>

@@ -58,0 +58,0 @@ ```

@@ -9,4 +9,4 @@ # Security Policy

| ------- | ------------------ |
| 1.1.6 | :white_check_mark: |
| < 1.1.6 | :x: |
| 1.1.7 | :white_check_mark: |
| < 1.1.7 | :x: |

@@ -13,0 +13,0 @@ ## Reporting a Vulnerability

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display