{"version":3,"file":"decode-uri-component-Bbm4I7s8.js","sources":["../../node_modules/decode-uri-component/index.js"],"sourcesContent":["const token = '%[a-f0-9]{2}';\nconst singleMatcher = new RegExp('(' + token + ')|([^%]+?)', 'gi');\nconst multiMatcher = new RegExp('(' + token + ')+', 'gi');\n\nfunction decodeComponents(components, split) {\n\ttry {\n\t\t// Try to decode the entire string first\n\t\treturn [decodeURIComponent(components.join(''))];\n\t} catch {\n\t\t// Do nothing\n\t}\n\n\tif (components.length === 1) {\n\t\treturn components;\n\t}\n\n\tsplit = split || 1;\n\n\t// Split the array in 2 parts\n\tconst left = components.slice(0, split);\n\tconst right = components.slice(split);\n\n\treturn Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));\n}\n\nfunction decode(input) {\n\ttry {\n\t\treturn decodeURIComponent(input);\n\t} catch {\n\t\tlet tokens = input.match(singleMatcher) || [];\n\n\t\tfor (let i = 1; i < tokens.length; i++) {\n\t\t\tinput = decodeComponents(tokens, i).join('');\n\n\t\t\ttokens = input.match(singleMatcher) || [];\n\t\t}\n\n\t\treturn input;\n\t}\n}\n\nfunction customDecodeURIComponent(input) {\n\t// Keep track of all the replacements and prefill the map with the `BOM`\n\tconst replaceMap = {\n\t\t'%FE%FF': '\\uFFFD\\uFFFD',\n\t\t'%FF%FE': '\\uFFFD\\uFFFD',\n\t};\n\n\tlet match = multiMatcher.exec(input);\n\twhile (match) {\n\t\ttry {\n\t\t\t// Decode as big chunks as possible\n\t\t\treplaceMap[match[0]] = decodeURIComponent(match[0]);\n\t\t} catch {\n\t\t\tconst result = decode(match[0]);\n\n\t\t\tif (result !== match[0]) {\n\t\t\t\treplaceMap[match[0]] = result;\n\t\t\t}\n\t\t}\n\n\t\tmatch = multiMatcher.exec(input);\n\t}\n\n\t// Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else\n\treplaceMap['%C2'] = '\\uFFFD';\n\n\tconst entries = Object.keys(replaceMap);\n\n\tfor (const key of entries) {\n\t\t// Replace all decoded components\n\t\tinput = input.replace(new RegExp(key, 'g'), replaceMap[key]);\n\t}\n\n\treturn input;\n}\n\nexport default function decodeUriComponent(encodedURI) {\n\tif (typeof encodedURI !== 'string') {\n\t\tthrow new TypeError('Expected `encodedURI` to be of type `string`, got `' + typeof encodedURI + '`');\n\t}\n\n\ttry {\n\t\t// Try the built in decoder first\n\t\treturn decodeURIComponent(encodedURI);\n\t} catch {\n\t\t// Fallback to a more advanced decoder\n\t\treturn customDecodeURIComponent(encodedURI);\n\t}\n}\n"],"names":["token","singleMatcher","multiMatcher","decodeComponents","components","split","left","right","decode","input","tokens","i","customDecodeURIComponent","replaceMap","match","result","entries","key","decodeUriComponent","encodedURI"],"mappings":"AAAA,MAAMA,EAAQ,eACRC,EAAgB,IAAI,OAAO,IAAMD,EAAQ,aAAc,IAAI,EAC3DE,EAAe,IAAI,OAAO,IAAMF,EAAQ,KAAM,IAAI,EAExD,SAASG,EAAiBC,EAAYC,EAAO,CAC5C,GAAI,CAEH,MAAO,CAAC,mBAAmBD,EAAW,KAAK,EAAE,CAAC,CAAC,CACjD,MAAS,CAET,CAEC,GAAIA,EAAW,SAAW,EACzB,OAAOA,EAGRC,EAAQA,GAAS,EAGjB,MAAMC,EAAOF,EAAW,MAAM,EAAGC,CAAK,EAChCE,EAAQH,EAAW,MAAMC,CAAK,EAEpC,OAAO,MAAM,UAAU,OAAO,KAAK,CAAA,EAAIF,EAAiBG,CAAI,EAAGH,EAAiBI,CAAK,CAAC,CACvF,CAEA,SAASC,EAAOC,EAAO,CACtB,GAAI,CACH,OAAO,mBAAmBA,CAAK,CACjC,MAAS,CACP,IAAIC,EAASD,EAAM,MAAMR,CAAa,GAAK,CAAE,EAE7C,QAASU,EAAI,EAAGA,EAAID,EAAO,OAAQC,IAClCF,EAAQN,EAAiBO,EAAQC,CAAC,EAAE,KAAK,EAAE,EAE3CD,EAASD,EAAM,MAAMR,CAAa,GAAK,CAAE,EAG1C,OAAOQ,CACT,CACA,CAEA,SAASG,EAAyBH,E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