@depup/fast-xml-parser 5.5.11-depup.1 → 5.10.1-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/fxp.min.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.fxp=e():t.fxp=e()}(this,()=>(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{XMLBuilder:()=>Dt,XMLParser:()=>yt,XMLValidator:()=>kt});var r=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",n=new RegExp("^["+r+"]["+r+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");function i(t,e){for(var r=[],n=e.exec(t);n;){var i=[];i.startIndex=e.lastIndex-n[0].length;for(var s=n.length,a=0;a<s;a++)i.push(n[a]);r.push(i),n=e.exec(t)}return r}var s=function(t){return!(null==n.exec(t))},a=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],o=["__proto__","constructor","prototype"],h={allowBooleanAttributes:!1,unpairedTags:[]};function l(t,e){e=Object.assign({},h,e);var r=[],n=!1,i=!1;"\ufeff"===t[0]&&(t=t.substr(1));for(var s=0;s<t.length;s++)if("<"===t[s]&&"?"===t[s+1]){if((s=p(t,s+=2)).err)return s}else{if("<"!==t[s]){if(u(t[s]))continue;return b("InvalidChar","char '"+t[s]+"' is not expected.",E(t,s))}var a=s;if("!"===t[++s]){s=d(t,s);continue}var o=!1;"/"===t[s]&&(o=!0,s++);for(var l="";s<t.length&&">"!==t[s]&&" "!==t[s]&&"\t"!==t[s]&&"\n"!==t[s]&&"\r"!==t[s];s++)l+=t[s];if("/"===(l=l.trim())[l.length-1]&&(l=l.substring(0,l.length-1),s--),!N(l))return b("InvalidTag",0===l.trim().length?"Invalid space after '<'.":"Tag '"+l+"' is an invalid name.",E(t,s));var f=g(t,s);if(!1===f)return b("InvalidAttr","Attributes for '"+l+"' have open quote.",E(t,s));var c=f.value;if(s=f.index,"/"===c[c.length-1]){var m=s-c.length,y=x(c=c.substring(0,c.length-1),e);if(!0!==y)return b(y.err.code,y.err.msg,E(t,m+y.err.line));n=!0}else if(o){if(!f.tagClosed)return b("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",E(t,s));if(c.trim().length>0)return b("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",E(t,a));if(0===r.length)return b("InvalidTag","Closing tag '"+l+"' has not been opened.",E(t,a));var w=r.pop();if(l!==w.tagName){var S=E(t,w.tagStartPos);return b("InvalidTag","Expected closing tag '"+w.tagName+"' (opened in line "+S.line+", col "+S.col+") instead of closing tag '"+l+"'.",E(t,a))}0==r.length&&(i=!0)}else{var T=x(c,e);if(!0!==T)return b(T.err.code,T.err.msg,E(t,s-c.length+T.err.line));if(!0===i)return b("InvalidXml","Multiple possible root nodes found.",E(t,s));-1!==e.unpairedTags.indexOf(l)||r.push({tagName:l,tagStartPos:a}),n=!0}for(s++;s<t.length;s++)if("<"===t[s]){if("!"===t[s+1]){s=d(t,++s);continue}if("?"!==t[s+1])break;if((s=p(t,++s)).err)return s}else if("&"===t[s]){var C=v(t,s);if(-1==C)return b("InvalidChar","char '&' is not expected.",E(t,s));s=C}else if(!0===i&&!u(t[s]))return b("InvalidXml","Extra text at the end",E(t,s));"<"===t[s]&&s--}return n?1==r.length?b("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",E(t,r[0].tagStartPos)):!(r.length>0)||b("InvalidXml","Invalid '"+JSON.stringify(r.map(function(t){return t.tagName}),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):b("InvalidXml","Start tag expected.",1)}function u(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function p(t,e){for(var r=e;e<t.length;e++)if("?"!=t[e]&&" "!=t[e]);else{var n=t.substr(r,e-r);if(e>5&&"xml"===n)return b("InvalidXml","XML declaration allowed only at the start of the document.",E(t,e));if("?"==t[e]&&">"==t[e+1]){e++;break}}return e}function d(t,e){if(t.length>e+5&&"-"===t[e+1]&&"-"===t[e+2]){for(e+=3;e<t.length;e++)if("-"===t[e]&&"-"===t[e+1]&&">"===t[e+2]){e+=2;break}}else if(t.length>e+8&&"D"===t[e+1]&&"O"===t[e+2]&&"C"===t[e+3]&&"T"===t[e+4]&&"Y"===t[e+5]&&"P"===t[e+6]&&"E"===t[e+7]){var r=1;for(e+=8;e<t.length;e++)if("<"===t[e])r++;else if(">"===t[e]&&0===--r)break}else if(t.length>e+9&&"["===t[e+1]&&"C"===t[e+2]&&"D"===t[e+3]&&"A"===t[e+4]&&"T"===t[e+5]&&"A"===t[e+6]&&"["===t[e+7])for(e+=8;e<t.length;e++)if("]"===t[e]&&"]"===t[e+1]&&">"===t[e+2]){e+=2;break}return e}var f='"',c="'";function g(t,e){for(var r="",n="",i=!1;e<t.length;e++){if(t[e]===f||t[e]===c)""===n?n=t[e]:n!==t[e]||(n="");else if(">"===t[e]&&""===n){i=!0;break}r+=t[e]}return""===n&&{value:r,index:e,tagClosed:i}}var m=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function x(t,e){for(var r=i(t,m),n={},s=0;s<r.length;s++){if(0===r[s][1].length)return b("InvalidAttr","Attribute '"+r[s][2]+"' has no space in starting.",w(r[s]));if(void 0!==r[s][3]&&void 0===r[s][4])return b("InvalidAttr","Attribute '"+r[s][2]+"' is without value.",w(r[s]));if(void 0===r[s][3]&&!e.allowBooleanAttributes)return b("InvalidAttr","boolean attribute '"+r[s][2]+"' is not allowed.",w(r[s]));var a=r[s][2];if(!y(a))return b("InvalidAttr","Attribute '"+a+"' is an invalid name.",w(r[s]));if(Object.prototype.hasOwnProperty.call(n,a))return b("InvalidAttr","Attribute '"+a+"' is repeated.",w(r[s]));n[a]=1}return!0}function v(t,e){if(";"===t[++e])return-1;if("#"===t[e])return function(t,e){var r=/\d/;for("x"===t[e]&&(e++,r=/[\da-fA-F]/);e<t.length;e++){if(";"===t[e])return e;if(!t[e].match(r))break}return-1}(t,++e);for(var r=0;e<t.length;e++,r++)if(!(t[e].match(/\w/)&&r<20)){if(";"===t[e])break;return-1}return e}function b(t,e,r){return{err:{code:t,msg:e,line:r.line||r,col:r.col}}}function y(t){return s(t)}function N(t){return s(t)}function E(t,e){var r=t.substring(0,e).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function w(t){return t.startIndex+t[1].length}var S=function(t){return a.includes(t)?"__"+t:t},T={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:function(){return!1},commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,r){return t},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:S};function C(t,e){if("string"==typeof t){var r=t.toLowerCase();if(a.some(function(t){return r===t.toLowerCase()}))throw new Error("[SECURITY] Invalid "+e+': "'+t+'" is a reserved JavaScript keyword that could cause prototype pollution');if(o.some(function(t){return r===t.toLowerCase()}))throw new Error("[SECURITY] Invalid "+e+': "'+t+'" is a reserved JavaScript keyword that could cause prototype pollution')}}function A(t){return"boolean"==typeof t?{enabled:t,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,maxEntityCount:100,allowedTags:null,tagFilter:null}:"object"==typeof t&&null!==t?{enabled:!1!==t.enabled,maxEntitySize:Math.max(1,null!=(e=t.maxEntitySize)?e:1e4),maxExpansionDepth:Math.max(1,null!=(r=t.maxExpansionDepth)?r:1e4),maxTotalExpansions:Math.max(1,null!=(n=t.maxTotalExpansions)?n:1/0),maxExpandedLength:Math.max(1,null!=(i=t.maxExpandedLength)?i:1e5),maxEntityCount:Math.max(1,null!=(s=t.maxEntityCount)?s:1e3),allowedTags:null!=(a=t.allowedTags)?a:null,tagFilter:null!=(o=t.tagFilter)?o:null}:A(!0);var e,r,n,i,s,a,o}var P,_=function(t){for(var e=Object.assign({},T,t),r=0,n=[{value:e.attributeNamePrefix,name:"attributeNamePrefix"},{value:e.attributesGroupName,name:"attributesGroupName"},{value:e.textNodeName,name:"textNodeName"},{value:e.cdataPropName,name:"cdataPropName"},{value:e.commentPropName,name:"commentPropName"}];r<n.length;r++){var i=n[r],s=i.value,a=i.name;s&&C(s,a)}return null===e.onDangerousProperty&&(e.onDangerousProperty=S),e.processEntities=A(e.processEntities),e.unpairedTagsSet=new Set(e.unpairedTags),e.stopNodes&&Array.isArray(e.stopNodes)&&(e.stopNodes=e.stopNodes.map(function(t){return"string"==typeof t&&t.startsWith("*.")?".."+t.substring(2):t})),e};P="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");var O=function(){function t(t){this.tagname=t,this.child=[],this[":@"]=Object.create(null)}var e=t.prototype;return e.add=function(t,e){var r;"__proto__"===t&&(t="#__proto__"),this.child.push(((r={})[t]=e,r))},e.addChild=function(t,e){var r,n;"__proto__"===t.tagname&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push(((r={})[t.tagname]=t.child,r[":@"]=t[":@"],r)):this.child.push(((n={})[t.tagname]=t.child,n)),void 0!==e&&(this.child[this.child.length-1][P]={startIndex:e})},t.getMetaDataSymbol=function(){return P},t}(),I=function(){function t(t){this.suppressValidationErr=!t,this.options=t}var e=t.prototype;return e.readDocType=function(t,e){var r=Object.create(null),n=0;if("O"!==t[e+3]||"C"!==t[e+4]||"T"!==t[e+5]||"Y"!==t[e+6]||"P"!==t[e+7]||"E"!==t[e+8])throw new Error("Invalid Tag instead of DOCTYPE");e+=9;for(var i=1,s=!1,a=!1;e<t.length;e++)if("<"!==t[e]||a)if(">"===t[e]){if(a?"-"===t[e-1]&&"-"===t[e-2]&&(a=!1,i--):i--,0===i)break}else"["===t[e]?s=!0:t[e];else{if(s&&$(t,"!ENTITY",e)){e+=7;var o=void 0,h=void 0,l=this.readEntityExp(t,e+1,this.suppressValidationErr);if(o=l[0],h=l[1],e=l[2],-1===h.indexOf("&")){if(!1!==this.options.enabled&&null!=this.options.maxEntityCount&&n>=this.options.maxEntityCount)throw new Error("Entity count ("+(n+1)+") exceeds maximum allowed ("+this.options.maxEntityCount+")");var u=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");r[o]={regx:RegExp("&"+u+";","g"),val:h},n++}}else if(s&&$(t,"!ELEMENT",e))e+=8,e=this.readElementExp(t,e+1).index;else if(s&&$(t,"!ATTLIST",e))e+=8;else if(s&&$(t,"!NOTATION",e))e+=9,e=this.readNotationExp(t,e+1,this.suppressValidationErr).index;else{if(!$(t,"!--",e))throw new Error("Invalid DOCTYPE");a=!0}i++}if(0!==i)throw new Error("Unclosed DOCTYPE");return{entities:r,i:e}},e.readEntityExp=function(t,e){for(var r=e=j(t,e);e<t.length&&!/\s/.test(t[e])&&'"'!==t[e]&&"'"!==t[e];)e++;var n=t.substring(r,e);if(M(n),e=j(t,e),!this.suppressValidationErr){if("SYSTEM"===t.substring(e,e+6).toUpperCase())throw new Error("External entities are not supported");if("%"===t[e])throw new Error("Parameter entities are not supported")}var i,s=this.readIdentifierVal(t,e,"entity");if(e=s[0],i=s[1],!1!==this.options.enabled&&null!=this.options.maxEntitySize&&i.length>this.options.maxEntitySize)throw new Error('Entity "'+n+'" size ('+i.length+") exceeds maximum allowed size ("+this.options.maxEntitySize+")");return[n,i,--e]},e.readNotationExp=function(t,e){for(var r=e=j(t,e);e<t.length&&!/\s/.test(t[e]);)e++;var n=t.substring(r,e);!this.suppressValidationErr&&M(n),e=j(t,e);var i=t.substring(e,e+6).toUpperCase();if(!this.suppressValidationErr&&"SYSTEM"!==i&&"PUBLIC"!==i)throw new Error('Expected SYSTEM or PUBLIC, found "'+i+'"');e+=i.length,e=j(t,e);var s=null,a=null;if("PUBLIC"===i){var o=this.readIdentifierVal(t,e,"publicIdentifier");if(e=o[0],s=o[1],'"'===t[e=j(t,e)]||"'"===t[e]){var h=this.readIdentifierVal(t,e,"systemIdentifier");e=h[0],a=h[1]}}else if("SYSTEM"===i){var l=this.readIdentifierVal(t,e,"systemIdentifier");if(e=l[0],a=l[1],!this.suppressValidationErr&&!a)throw new Error("Missing mandatory system identifier for SYSTEM notation")}return{notationName:n,publicIdentifier:s,systemIdentifier:a,index:--e}},e.readIdentifierVal=function(t,e,r){var n,i=t[e];if('"'!==i&&"'"!==i)throw new Error('Expected quoted string, found "'+i+'"');for(var s=++e;e<t.length&&t[e]!==i;)e++;if(n=t.substring(s,e),t[e]!==i)throw new Error("Unterminated "+r+" value");return[++e,n]},e.readElementExp=function(t,e){for(var r=e=j(t,e);e<t.length&&!/\s/.test(t[e]);)e++;var n=t.substring(r,e);if(!this.suppressValidationErr&&!s(n))throw new Error('Invalid element name: "'+n+'"');var i="";if("E"===t[e=j(t,e)]&&$(t,"MPTY",e))e+=4;else if("A"===t[e]&&$(t,"NY",e))e+=2;else if("("===t[e]){for(var a=++e;e<t.length&&")"!==t[e];)e++;if(i=t.substring(a,e),")"!==t[e])throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error('Invalid Element Expression, found "'+t[e]+'"');return{elementName:n,contentModel:i.trim(),index:e}},e.readAttlistExp=function(t,e){for(var r=e=j(t,e);e<t.length&&!/\s/.test(t[e]);)e++;var n=t.substring(r,e);for(M(n),r=e=j(t,e);e<t.length&&!/\s/.test(t[e]);)e++;var i=t.substring(r,e);if(!M(i))throw new Error('Invalid attribute name: "'+i+'"');e=j(t,e);var s="";if("NOTATION"===t.substring(e,e+8).toUpperCase()){if(s="NOTATION","("!==t[e=j(t,e+=8)])throw new Error("Expected '(', found \""+t[e]+'"');e++;for(var a=[];e<t.length&&")"!==t[e];){for(var o=e;e<t.length&&"|"!==t[e]&&")"!==t[e];)e++;var h=t.substring(o,e);if(!M(h=h.trim()))throw new Error('Invalid notation name: "'+h+'"');a.push(h),"|"===t[e]&&(e++,e=j(t,e))}if(")"!==t[e])throw new Error("Unterminated list of notations");e++,s+=" ("+a.join("|")+")"}else{for(var l=e;e<t.length&&!/\s/.test(t[e]);)e++;if(s+=t.substring(l,e),!this.suppressValidationErr&&!["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"].includes(s.toUpperCase()))throw new Error('Invalid attribute type: "'+s+'"')}e=j(t,e);var u="";if("#REQUIRED"===t.substring(e,e+8).toUpperCase())u="#REQUIRED",e+=8;else if("#IMPLIED"===t.substring(e,e+7).toUpperCase())u="#IMPLIED",e+=7;else{var p=this.readIdentifierVal(t,e,"ATTLIST");e=p[0],u=p[1]}return{elementName:n,attributeName:i,attributeType:s,defaultValue:u,index:e}},t}(),j=function(t,e){for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function $(t,e,r){for(var n=0;n<e.length;n++)if(e[n]!==t[r+n+1])return!1;return!0}function M(t){if(s(t))return t;throw new Error("Invalid entity name "+t)}const D=/^[-+]?0x[a-fA-F0-9]+$/,k=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,V={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original"};const F=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function L(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}const z=new Set(["push","pop","reset","updateCurrent","restore"]);class G{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null}push(t,e=null,r=null){this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const n=this.path.length;this.siblingStacks[n]||(this.siblingStacks[n]=new Map);const i=this.siblingStacks[n],s=r?`${r}:${t}`:t,a=i.get(s)||0;let o=0;for(const t of i.values())o+=t;i.set(s,a+1);const h={tag:t,position:o,counter:a};null!=r&&(h.namespace=r),null!=e&&(h.values=e),this.path.push(h)}pop(){if(0===this.path.length)return;this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null;const t=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),t}updateCurrent(t){if(this.path.length>0){const e=this.path[this.path.length-1];null!=t&&(e.values=t,this._frozenPathCache=null)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){if(0===this.path.length)return;const e=this.path[this.path.length-1];return e.values?.[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,e=!0){const r=t||this.separator;if(r===this.separator&&!0===e){if(null!==this._pathStringCache&&void 0!==this._pathStringCache)return this._pathStringCache;const t=this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(r);return this._pathStringCache=t,t}return this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(r)}toArray(){return this.path.map(t=>t.tag)}reset(){this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path=[],this.siblingStacks=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e],n=this.path[e],i=e===this.path.length-1;if(!this._matchSegment(r,n,i))return!1}return!0}_matchWithDeepWildcard(t){let e=this.path.length-1,r=t.length-1;for(;r>=0&&e>=0;){const n=t[r];if("deep-wildcard"===n.type){if(r--,r<0)return!0;const n=t[r];let i=!1;for(let t=e;t>=0;t--){const s=t===this.path.length-1;if(this._matchSegment(n,this.path[t],s)){e=t-1,r--,i=!0;break}}if(!i)return!1}else{const t=e===this.path.length-1;if(!this._matchSegment(n,this.path[e],t))return!1;e--,r--}}return r<0}_matchSegment(t,e,r){if("*"!==t.tag&&t.tag!==e.tag)return!1;if(void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace)return!1;if(void 0!==t.attrName){if(!r)return!1;if(!e.values||!(t.attrName in e.values))return!1;if(void 0!==t.attrValue){const r=e.values[t.attrName];if(String(r)!==String(t.attrValue))return!1}}if(void 0!==t.position){if(!r)return!1;const n=e.counter??0;if("first"===t.position&&0!==n)return!1;if("odd"===t.position&&n%2!=1)return!1;if("even"===t.position&&n%2!=0)return!1;if("nth"===t.position&&n!==t.positionValue)return!1}return!0}matchesAny(t){return t.matchesAny(this)}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>new Map(t))}}restore(t){this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path=t.path.map(t=>({...t})),this.siblingStacks=t.siblingStacks.map(t=>new Map(t))}readOnly(){return new Proxy(this,{get(t,e,r){if(z.has(e))return()=>{throw new TypeError(`Cannot call '${e}' on a read-only Matcher. Obtain a writable instance to mutate state.`)};if("path"===e)return null===t._frozenPathCache&&(t._frozenPathCache=Object.freeze(t.path.map(t=>Object.freeze({...t})))),t._frozenPathCache;if("siblingStacks"===e)return null===t._frozenSiblingsCache&&(t._frozenSiblingsCache=Object.freeze(t.siblingStacks.map(t=>Object.freeze(new Map(t))))),t._frozenSiblingsCache;const n=Reflect.get(t,e,r);return"function"==typeof n?n.bind(t):n},set(t,e){throw new TypeError(`Cannot set property '${String(e)}' on a read-only Matcher.`)},deleteProperty(t,e){throw new TypeError(`Cannot delete property '${String(e)}' from a read-only Matcher.`)}})}}class R{constructor(t,e={},r){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this.data=r,this._hasDeepWildcard=this.segments.some(t=>"deep-wildcard"===t.type),this._hasAttributeCondition=this.segments.some(t=>void 0!==t.attrName),this._hasPositionSelector=this.segments.some(t=>void 0!==t.position)}_parse(t){const e=[];let r=0,n="";for(;r<t.length;)t[r]===this.separator?r+1<t.length&&t[r+1]===this.separator?(n.trim()&&(e.push(this._parseSegment(n.trim())),n=""),e.push({type:"deep-wildcard"}),r+=2):(n.trim()&&e.push(this._parseSegment(n.trim())),n="",r++):(n+=t[r],r++);return n.trim()&&e.push(this._parseSegment(n.trim())),e}_parseSegment(t){const e={type:"tag"};let r=null,n=t;const i=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(i&&(n=i[1]+i[3],i[2])){const t=i[2].slice(1,-1);t&&(r=t)}let s,a,o=n;if(n.includes("::")){const e=n.indexOf("::");if(s=n.substring(0,e).trim(),o=n.substring(e+2).trim(),!s)throw new Error(`Invalid namespace in pattern: ${t}`)}let h=null;if(o.includes(":")){const t=o.lastIndexOf(":"),e=o.substring(0,t).trim(),r=o.substring(t+1).trim();["first","last","odd","even"].includes(r)||/^nth\(\d+\)$/.test(r)?(a=e,h=r):a=o}else a=o;if(!a)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=a,s&&(e.namespace=s),r)if(r.includes("=")){const t=r.indexOf("=");e.attrName=r.substring(0,t).trim(),e.attrValue=r.substring(t+1).trim()}else e.attrName=r.trim();if(h){const t=h.match(/^nth\((\d+)\)$/);t?(e.position="nth",e.positionValue=parseInt(t[1],10)):e.position=h}return e}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class B{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._patterns=new Set,this._sealed=!1}add(t){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(t.pattern))return this;if(this._patterns.add(t.pattern),t.hasDeepWildcard())return this._deepWildcards.push(t),this;const e=t.length,r=t.segments[t.segments.length-1],n=r?.tag;if(n&&"*"!==n){const r=`${e}:${n}`;this._byDepthAndTag.has(r)||this._byDepthAndTag.set(r,[]),this._byDepthAndTag.get(r).push(t)}else this._wildcardByDepth.has(e)||this._wildcardByDepth.set(e,[]),this._wildcardByDepth.get(e).push(t);return this}addAll(t){for(const e of t)this.add(e);return this}has(t){return this._patterns.has(t.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(t){return null!==this.findMatch(t)}findMatch(t){const e=t.getDepth(),r=`${e}:${t.getCurrentTag()}`,n=this._byDepthAndTag.get(r);if(n)for(let e=0;e<n.length;e++)if(t.matches(n[e]))return n[e];const i=this._wildcardByDepth.get(e);if(i)for(let e=0;e<i.length;e++)if(t.matches(i[e]))return i[e];for(let e=0;e<this._deepWildcards.length;e++)if(t.matches(this._deepWildcards[e]))return this._deepWildcards[e];return null}}function U(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return W(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?W(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function W(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Y(t,e){if(!t)return{};var r=e.attributesGroupName?t[e.attributesGroupName]:t;if(!r)return{};var n={};for(var i in r)i.startsWith(e.attributeNamePrefix)?n[i.substring(e.attributeNamePrefix.length)]=r[i]:n[i]=r[i];return n}function X(t){if(t&&"string"==typeof t){var e=t.indexOf(":");if(-1!==e&&e>0){var r=t.substring(0,e);if("xmlns"!==r)return r}}}var K=function(t){var e;this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:function(t,e){return ut(e,10,"&#")}},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:function(t,e){return ut(e,16,"&#x")}}},this.addExternalEntities=q,this.parseXml=tt,this.parseTextData=Z,this.resolveNameSpace=J,this.buildAttributesMap=H,this.isItStopNode=it,this.replaceEntitiesValue=rt,this.readStopNodeData=ht,this.saveTextToParentTag=nt,this.addChild=et,this.ignoreAttributesFn="function"==typeof(e=this.options.ignoreAttributes)?e:Array.isArray(e)?function(t){for(var r,n=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return L(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?L(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(e);!(r=n()).done;){var i=r.value;if("string"==typeof i&&t===i)return!0;if(i instanceof RegExp&&i.test(t))return!0}}:function(){return!1},this.entityExpansionCount=0,this.currentExpandedLength=0,this.matcher=new G,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new B;var r=this.options.stopNodes;if(r&&r.length>0){for(var n=0;n<r.length;n++){var i=r[n];"string"==typeof i?this.stopNodeExpressionsSet.add(new R(i)):i instanceof R&&this.stopNodeExpressionsSet.add(i)}this.stopNodeExpressionsSet.seal()}};function q(t){for(var e=Object.keys(t),r=0;r<e.length;r++){var n=e[r],i=n.replace(/[.\-+*:]/g,"\\.");this.lastEntities[n]={regex:new RegExp("&"+i+";","g"),val:t[n]}}}function Z(t,e,r,n,i,s,a){var o=this.options;if(void 0!==t&&(o.trimValues&&!n&&(t=t.trim()),t.length>0)){a||(t=this.replaceEntitiesValue(t,e,r));var h=o.jPath?r.toString():r,l=o.tagValueProcessor(e,t,h,i,s);return null==l?t:typeof l!=typeof t||l!==t?l:o.trimValues||t.trim()===t?lt(t,o.parseTagValue,o.numberParseOptions):t}}function J(t){if(this.options.removeNSPrefix){var e=t.split(":"),r="/"===t.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(t=r+e[1])}return t}var Q=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function H(t,e,r){var n=this.options;if(!0!==n.ignoreAttributes&&"string"==typeof t){for(var s=i(t,Q),a=s.length,o={},h=new Array(a),l=!1,u={},p=0;p<a;p++){var d=this.resolveNameSpace(s[p][1]),f=s[p][4];if(d.length&&void 0!==f){var c=f;n.trimValues&&(c=c.trim()),c=this.replaceEntitiesValue(c,r,this.readonlyMatcher),h[p]=c,u[d]=c,l=!0}}l&&"object"==typeof e&&e.updateCurrent&&e.updateCurrent(u);for(var g=n.jPath?e.toString():this.readonlyMatcher,m=!1,x=0;x<a;x++){var v=this.resolveNameSpace(s[x][1]);if(!this.ignoreAttributesFn(v,g)){var b=n.attributeNamePrefix+v;if(v.length)if(n.transformAttributeName&&(b=n.transformAttributeName(b)),b=dt(b,n),void 0!==s[x][4]){var y=h[x],N=n.attributeValueProcessor(v,y,g);o[b]=null==N?y:typeof N!=typeof y||N!==y?N:lt(y,n.parseAttributeValue,n.numberParseOptions),m=!0}else n.allowBooleanAttributes&&(o[b]=!0,m=!0)}}if(!m)return;if(n.attributesGroupName){var E={};return E[n.attributesGroupName]=o,E}return o}}var tt=function(t){t=t.replace(/\r\n?/g,"\n");var e=new O("!xml"),r=e,n="";this.matcher.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0,this.docTypeEntitiesKeys=[],this.lastEntitiesKeys=Object.keys(this.lastEntities),this.htmlEntitiesKeys=this.options.htmlEntities?Object.keys(this.htmlEntities):[];for(var i=this.options,s=new I(i.processEntities),a=t.length,o=0;o<a;o++)if("<"===t[o]){var h=t.charCodeAt(o+1);if(47===h){var l=st(t,">",o,"Closing Tag is not closed."),u=t.substring(o+2,l).trim();if(i.removeNSPrefix){var p=u.indexOf(":");-1!==p&&(u=u.substr(p+1))}u=pt(i.transformTagName,u,"",i).tagName,r&&(n=this.saveTextToParentTag(n,r,this.readonlyMatcher));var d=this.matcher.getCurrentTag();if(u&&i.unpairedTagsSet.has(u))throw new Error("Unpaired tag can not be used as closing tag: </"+u+">");d&&i.unpairedTagsSet.has(d)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,r=this.tagsNodeStack.pop(),n="",o=l}else if(63===h){var f=ot(t,o,!1,"?>");if(!f)throw new Error("Pi Tag is not closed.");if(n=this.saveTextToParentTag(n,r,this.readonlyMatcher),i.ignoreDeclaration&&"?xml"===f.tagName||i.ignorePiTags);else{var c=new O(f.tagName);c.add(i.textNodeName,""),f.tagName!==f.tagExp&&f.attrExpPresent&&(c[":@"]=this.buildAttributesMap(f.tagExp,this.matcher,f.tagName)),this.addChild(r,c,this.readonlyMatcher,o)}o=f.closeIndex+1}else if(33===h&&45===t.charCodeAt(o+2)&&45===t.charCodeAt(o+3)){var g=st(t,"--\x3e",o+4,"Comment is not closed.");if(i.commentPropName){var m,x=t.substring(o+4,g-2);n=this.saveTextToParentTag(n,r,this.readonlyMatcher),r.add(i.commentPropName,[(m={},m[i.textNodeName]=x,m)])}o=g}else if(33===h&&68===t.charCodeAt(o+2)){var v=s.readDocType(t,o);this.docTypeEntities=v.entities,this.docTypeEntitiesKeys=Object.keys(this.docTypeEntities)||[],o=v.i}else if(33===h&&91===t.charCodeAt(o+2)){var b=st(t,"]]>",o,"CDATA is not closed.")-2,y=t.substring(o+9,b);n=this.saveTextToParentTag(n,r,this.readonlyMatcher);var N,E=this.parseTextData(y,r.tagname,this.readonlyMatcher,!0,!1,!0,!0);null==E&&(E=""),i.cdataPropName?r.add(i.cdataPropName,[(N={},N[i.textNodeName]=y,N)]):r.add(i.textNodeName,E),o=b+2}else{var w=ot(t,o,i.removeNSPrefix);if(!w){var S=t.substring(Math.max(0,o-50),Math.min(a,o+50));throw new Error("readTagExp returned undefined at position "+o+'. Context: "'+S+'"')}var T=w.tagName,C=w.rawTagName,A=w.tagExp,P=w.attrExpPresent,_=w.closeIndex,j=pt(i.transformTagName,T,A,i);if(T=j.tagName,A=j.tagExp,i.strictReservedNames&&(T===i.commentPropName||T===i.cdataPropName||T===i.textNodeName||T===i.attributesGroupName))throw new Error("Invalid tag name: "+T);r&&n&&"!xml"!==r.tagname&&(n=this.saveTextToParentTag(n,r,this.readonlyMatcher,!1));var $=r;$&&i.unpairedTagsSet.has($.tagname)&&(r=this.tagsNodeStack.pop(),this.matcher.pop());var M=!1;A.length>0&&A.lastIndexOf("/")===A.length-1&&(M=!0,A="/"===T[T.length-1]?T=T.substr(0,T.length-1):A.substr(0,A.length-1),P=T!==A);var D,k=null;D=X(C),T!==e.tagname&&this.matcher.push(T,{},D),T!==A&&P&&(k=this.buildAttributesMap(A,this.matcher,T))&&Y(k,i),T!==e.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());var V=o;if(this.isCurrentNodeStopNode){var F="";if(M)o=w.closeIndex;else if(i.unpairedTagsSet.has(T))o=w.closeIndex;else{var L=this.readStopNodeData(t,C,_+1);if(!L)throw new Error("Unexpected end of "+C);o=L.i,F=L.tagContent}var z=new O(T);k&&(z[":@"]=k),z.add(i.textNodeName,F),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(r,z,this.readonlyMatcher,V)}else{if(M){var G=pt(i.transformTagName,T,A,i);T=G.tagName,A=G.tagExp;var R=new O(T);k&&(R[":@"]=k),this.addChild(r,R,this.readonlyMatcher,V),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else{if(i.unpairedTagsSet.has(T)){var B=new O(T);k&&(B[":@"]=k),this.addChild(r,B,this.readonlyMatcher,V),this.matcher.pop(),this.isCurrentNodeStopNode=!1,o=w.closeIndex;continue}var U=new O(T);if(this.tagsNodeStack.length>i.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(r),k&&(U[":@"]=k),this.addChild(r,U,this.readonlyMatcher,V),r=U}n="",o=_}}}else n+=t[o];return e.child};function et(t,e,r,n){this.options.captureMetaData||(n=void 0);var i=this.options.jPath?r.toString():r,s=this.options.updateTag(e.tagname,i,e[":@"]);!1===s||("string"==typeof s?(e.tagname=s,t.addChild(e,n)):t.addChild(e,n))}function rt(t,e,r){var n=this.options.processEntities;if(!n||!n.enabled)return t;if(n.allowedTags){var i=this.options.jPath?r.toString():r;if(!(Array.isArray(n.allowedTags)?n.allowedTags.includes(e):n.allowedTags(e,i)))return t}if(n.tagFilter){var s=this.options.jPath?r.toString():r;if(!n.tagFilter(e,s))return t}for(var a,o=U(this.docTypeEntitiesKeys);!(a=o()).done;){var h=a.value,l=this.docTypeEntities[h],u=t.match(l.regx);if(u){if(this.entityExpansionCount+=u.length,n.maxTotalExpansions&&this.entityExpansionCount>n.maxTotalExpansions)throw new Error("Entity expansion limit exceeded: "+this.entityExpansionCount+" > "+n.maxTotalExpansions);var p=t.length;if(t=t.replace(l.regx,l.val),n.maxExpandedLength&&(this.currentExpandedLength+=t.length-p,this.currentExpandedLength>n.maxExpandedLength))throw new Error("Total expanded content size exceeded: "+this.currentExpandedLength+" > "+n.maxExpandedLength)}}if(-1===t.indexOf("&"))return t;for(var d,f=U(this.lastEntitiesKeys);!(d=f()).done;){var c=d.value,g=this.lastEntities[c],m=t.match(g.regex);if(m&&(this.entityExpansionCount+=m.length,n.maxTotalExpansions&&this.entityExpansionCount>n.maxTotalExpansions))throw new Error("Entity expansion limit exceeded: "+this.entityExpansionCount+" > "+n.maxTotalExpansions);t=t.replace(g.regex,g.val)}if(-1===t.indexOf("&"))return t;for(var x,v=U(this.htmlEntitiesKeys);!(x=v()).done;){var b=x.value,y=this.htmlEntities[b],N=t.match(y.regex);if(N&&(this.entityExpansionCount+=N.length,n.maxTotalExpansions&&this.entityExpansionCount>n.maxTotalExpansions))throw new Error("Entity expansion limit exceeded: "+this.entityExpansionCount+" > "+n.maxTotalExpansions);t=t.replace(y.regex,y.val)}return t.replace(this.ampEntity.regex,this.ampEntity.val)}function nt(t,e,r,n){return t&&(void 0===n&&(n=0===e.child.length),void 0!==(t=this.parseTextData(t,e.tagname,r,!1,!!e[":@"]&&0!==Object.keys(e[":@"]).length,n))&&""!==t&&e.add(this.options.textNodeName,t),t=""),t}function it(){return 0!==this.stopNodeExpressionsSet.size&&this.matcher.matchesAny(this.stopNodeExpressionsSet)}function st(t,e,r,n){var i=t.indexOf(e,r);if(-1===i)throw new Error(n);return i+e.length-1}function at(t,e,r,n){var i=t.indexOf(e,r);if(-1===i)throw new Error(n);return i}function ot(t,e,r,n){void 0===n&&(n=">");var i=function(t,e,r){void 0===r&&(r=">");for(var n=0,i=[],s=t.length,a=r.charCodeAt(0),o=r.length>1?r.charCodeAt(1):-1,h=e;h<s;h++){var l=t.charCodeAt(h);if(n)l===n&&(n=0);else if(34===l||39===l)n=l;else if(l===a){if(-1===o)return{data:String.fromCharCode.apply(String,i),index:h};if(t.charCodeAt(h+1)===o)return{data:String.fromCharCode.apply(String,i),index:h}}else if(9===l){i.push(32);continue}i.push(l)}}(t,e+1,n);if(i){var s=i.data,a=i.index,o=s.search(/\s/),h=s,l=!0;-1!==o&&(h=s.substring(0,o),s=s.substring(o+1).trimStart());var u=h;if(r){var p=h.indexOf(":");-1!==p&&(l=(h=h.substr(p+1))!==i.data.substr(p+1))}return{tagName:h,tagExp:s,closeIndex:a,attrExpPresent:l,rawTagName:u}}}function ht(t,e,r){for(var n=r,i=1,s=t.length;r<s;r++)if("<"===t[r]){var a=t.charCodeAt(r+1);if(47===a){var o=at(t,">",r,e+" is not closed");if(t.substring(r+2,o).trim()===e&&0===--i)return{tagContent:t.substring(n,r),i:o};r=o}else if(63===a)r=st(t,"?>",r+1,"StopNode is not closed.");else if(33===a&&45===t.charCodeAt(r+2)&&45===t.charCodeAt(r+3))r=st(t,"--\x3e",r+3,"StopNode is not closed.");else if(33===a&&91===t.charCodeAt(r+2))r=st(t,"]]>",r,"StopNode is not closed.")-2;else{var h=ot(t,r,">");h&&((h&&h.tagName)===e&&"/"!==h.tagExp[h.tagExp.length-1]&&i++,r=h.closeIndex)}}}function lt(t,e,r){if(e&&"string"==typeof t){var n=t.trim();return"true"===n||"false"!==n&&function(t,e={}){if(e=Object.assign({},V,e),!t||"string"!=typeof t)return t;let r=t.trim();if(0===r.length)return t;if(void 0!==e.skipLike&&e.skipLike.test(r))return t;if("0"===r)return 0;if(e.hex&&D.test(r))return function(t){if(parseInt)return parseInt(t,16);if(Number.parseInt)return Number.parseInt(t,16);if(window&&window.parseInt)return window.parseInt(t,16);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}(r);if(isFinite(r)){if(r.includes("e")||r.includes("E"))return function(t,e,r){if(!r.eNotation)return t;const n=e.match(F);if(n){let i=n[1]||"";const s=-1===n[3].indexOf("e")?"E":"e",a=n[2],o=i?t[a.length+1]===s:t[a.length]===s;return a.length>1&&o?t:(1!==a.length||!n[3].startsWith(`.${s}`)&&n[3][0]!==s)&&a.length>0?r.leadingZeros&&!o?(e=(n[1]||"")+n[3],Number(e)):t:Number(e)}return t}(t,r,e);{const i=k.exec(r);if(i){const s=i[1]||"",a=i[2];let o=(n=i[3])&&-1!==n.indexOf(".")?("."===(n=n.replace(/0+$/,""))?n="0":"."===n[0]?n="0"+n:"."===n[n.length-1]&&(n=n.substring(0,n.length-1)),n):n;const h=s?"."===t[a.length+1]:"."===t[a.length];if(!e.leadingZeros&&(a.length>1||1===a.length&&!h))return t;{const n=Number(r),i=String(n);if(0===n)return n;if(-1!==i.search(/[eE]/))return e.eNotation?n:t;if(-1!==r.indexOf("."))return"0"===i||i===o||i===`${s}${o}`?n:t;let h=a?o:r;return a?h===i||s+h===i?n:t:h===i||h===s+i?n:t}}return t}}var n;return function(t,e,r){const n=e===1/0;switch(r.infinity.toLowerCase()){case"null":return null;case"infinity":return e;case"string":return n?"Infinity":"-Infinity";default:return t}}(t,Number(r),e)}(t,r)}return void 0!==t?t:""}function ut(t,e,r){var n=Number.parseInt(t,e);return n>=0&&n<=1114111?String.fromCodePoint(n):r+t+";"}function pt(t,e,r,n){if(t){var i=t(e);r===e&&(r=i),e=i}return{tagName:e=dt(e,n),tagExp:r}}function dt(t,e){if(o.includes(t))throw new Error('[SECURITY] Invalid name: "'+t+'" is a reserved JavaScript keyword that could cause prototype pollution');return a.includes(t)?e.onDangerousProperty(t):t}var ft=O.getMetaDataSymbol();function ct(t,e){if(!t||"object"!=typeof t)return{};if(!e)return t;var r={};for(var n in t)n.startsWith(e)?r[n.substring(e.length)]=t[n]:r[n]=t[n];return r}function gt(t,e,r,n){return mt(t,e,r,n)}function mt(t,e,r,n){for(var i,s={},a=0;a<t.length;a++){var o=t[a],h=xt(o);if(void 0!==h&&h!==e.textNodeName){var l=ct(o[":@"]||{},e.attributeNamePrefix);r.push(h,l)}if(h===e.textNodeName)void 0===i?i=o[h]:i+=""+o[h];else{if(void 0===h)continue;if(o[h]){var u=mt(o[h],e,r,n),p=bt(u,e);if(o[":@"]?vt(u,o[":@"],n,e):1!==Object.keys(u).length||void 0===u[e.textNodeName]||e.alwaysCreateTextNode?0===Object.keys(u).length&&(e.alwaysCreateTextNode?u[e.textNodeName]="":u=""):u=u[e.textNodeName],void 0!==o[ft]&&"object"==typeof u&&null!==u&&(u[ft]=o[ft]),void 0!==s[h]&&Object.prototype.hasOwnProperty.call(s,h))Array.isArray(s[h])||(s[h]=[s[h]]),s[h].push(u);else{var d=e.jPath?n.toString():n;e.isArray(h,d,p)?s[h]=[u]:s[h]=u}void 0!==h&&h!==e.textNodeName&&r.pop()}}}return"string"==typeof i?i.length>0&&(s[e.textNodeName]=i):void 0!==i&&(s[e.textNodeName]=i),s}function xt(t){for(var e=Object.keys(t),r=0;r<e.length;r++){var n=e[r];if(":@"!==n)return n}}function vt(t,e,r,n){if(e)for(var i=Object.keys(e),s=i.length,a=0;a<s;a++){var o=i[a],h=o.startsWith(n.attributeNamePrefix)?o.substring(n.attributeNamePrefix.length):o,l=n.jPath?r.toString()+"."+h:r;n.isArray(o,l,!0,!0)?t[o]=[e[o]]:t[o]=e[o]}}function bt(t,e){var r=e.textNodeName,n=Object.keys(t).length;return 0===n||!(1!==n||!t[r]&&"boolean"!=typeof t[r]&&0!==t[r])}var yt=function(){function t(t){this.externalEntities={},this.options=_(t)}var e=t.prototype;return e.parse=function(t,e){if("string"!=typeof t&&t.toString)t=t.toString();else if("string"!=typeof t)throw new Error("XML data is accepted in String or Bytes[] form.");if(e){!0===e&&(e={});var r=l(t,e);if(!0!==r)throw Error(r.err.msg+":"+r.err.line+":"+r.err.col)}var n=new K(this.options);n.addExternalEntities(this.externalEntities);var i=n.parseXml(t);return this.options.preserveOrder||void 0===i?i:gt(i,this.options,n.matcher,n.readonlyMatcher)},e.addEntity=function(t,e){if(-1!==e.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==t.indexOf("&")||-1!==t.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if("&"===e)throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e},t.getMetaDataSymbol=function(){return O.getMetaDataSymbol()},t}();function Nt(t,e){let r="";e.format&&e.indentBy.length>0&&(r="\n");const n=[];if(e.stopNodes&&Array.isArray(e.stopNodes))for(let t=0;t<e.stopNodes.length;t++){const r=e.stopNodes[t];"string"==typeof r?n.push(new R(r)):r instanceof R&&n.push(r)}return Et(t,e,r,new G,n)}function Et(t,e,r,n,i){let s="",a=!1;if(e.maxNestedTags&&n.getDepth()>e.maxNestedTags)throw new Error("Maximum nested tags exceeded");if(!Array.isArray(t)){if(null!=t){let r=t.toString();return r=_t(r,e),r}return""}for(let o=0;o<t.length;o++){const h=t[o],l=Ct(h);if(void 0===l)continue;const u=wt(h[":@"],e);n.push(l,u);const p=Pt(n,i);if(l===e.textNodeName){let t=h[l];p||(t=e.tagValueProcessor(l,t),t=_t(t,e)),a&&(s+=r),s+=t,a=!1,n.pop();continue}if(l===e.cdataPropName){a&&(s+=r),s+=`<![CDATA[${h[l][0][e.textNodeName]}]]>`,a=!1,n.pop();continue}if(l===e.commentPropName){s+=r+`\x3c!--${h[l][0][e.textNodeName]}--\x3e`,a=!0,n.pop();continue}if("?"===l[0]){const t=At(h[":@"],e,p),i="?xml"===l?"":r;let o=h[l][0][e.textNodeName];o=0!==o.length?" "+o:"",s+=i+`<${l}${o}${t}?>`,a=!0,n.pop();continue}let d=r;""!==d&&(d+=e.indentBy);const f=r+`<${l}${At(h[":@"],e,p)}`;let c;c=p?St(h[l],e):Et(h[l],e,d,n,i),-1!==e.unpairedTags.indexOf(l)?e.suppressUnpairedNode?s+=f+">":s+=f+"/>":c&&0!==c.length||!e.suppressEmptyNode?c&&c.endsWith(">")?s+=f+`>${c}${r}</${l}>`:(s+=f+">",c&&""!==r&&(c.includes("/>")||c.includes("</"))?s+=r+e.indentBy+c+r:s+=c,s+=`</${l}>`):s+=f+"/>",a=!0,n.pop()}return s}function wt(t,e){if(!t||e.ignoreAttributes)return null;const r={};let n=!1;for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[i.startsWith(e.attributeNamePrefix)?i.substr(e.attributeNamePrefix.length):i]=t[i],n=!0);return n?r:null}function St(t,e){if(!Array.isArray(t))return null!=t?t.toString():"";let r="";for(let n=0;n<t.length;n++){const i=t[n],s=Ct(i);if(s===e.textNodeName)r+=i[s];else if(s===e.cdataPropName)r+=i[s][0][e.textNodeName];else if(s===e.commentPropName)r+=i[s][0][e.textNodeName];else{if(s&&"?"===s[0])continue;if(s){const t=Tt(i[":@"],e),n=St(i[s],e);n&&0!==n.length?r+=`<${s}${t}>${n}</${s}>`:r+=`<${s}${t}/>`}}}return r}function Tt(t,e){let r="";if(t&&!e.ignoreAttributes)for(let n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;let i=t[n];!0===i&&e.suppressBooleanAttributes?r+=` ${n.substr(e.attributeNamePrefix.length)}`:r+=` ${n.substr(e.attributeNamePrefix.length)}="${i}"`}return r}function Ct(t){const e=Object.keys(t);for(let r=0;r<e.length;r++){const n=e[r];if(Object.prototype.hasOwnProperty.call(t,n)&&":@"!==n)return n}}function At(t,e,r){let n="";if(t&&!e.ignoreAttributes)for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;let s;r?s=t[i]:(s=e.attributeValueProcessor(i,t[i]),s=_t(s,e)),!0===s&&e.suppressBooleanAttributes?n+=` ${i.substr(e.attributeNamePrefix.length)}`:n+=` ${i.substr(e.attributeNamePrefix.length)}="${s}"`}return n}function Pt(t,e){if(!e||0===e.length)return!1;for(let r=0;r<e.length;r++)if(t.matches(e[r]))return!0;return!1}function _t(t,e){if(t&&t.length>0&&e.processEntities)for(let r=0;r<e.entities.length;r++){const n=e.entities[r];t=t.replace(n.regex,n.val)}return t}const Ot={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1,maxNestedTags:100,jPath:!0};function It(t){if(this.options=Object.assign({},Ot,t),this.options.stopNodes&&Array.isArray(this.options.stopNodes)&&(this.options.stopNodes=this.options.stopNodes.map(t=>"string"==typeof t&&t.startsWith("*.")?".."+t.substring(2):t)),this.stopNodeExpressions=[],this.options.stopNodes&&Array.isArray(this.options.stopNodes))for(let t=0;t<this.options.stopNodes.length;t++){const e=this.options.stopNodes[t];"string"==typeof e?this.stopNodeExpressions.push(new R(e)):e instanceof R&&this.stopNodeExpressions.push(e)}var e;!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn="function"==typeof(e=this.options.ignoreAttributes)?e:Array.isArray(e)?t=>{for(const r of e){if("string"==typeof r&&t===r)return!0;if(r instanceof RegExp&&r.test(t))return!0}}:()=>!1,this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=Mt),this.processTextOrObjNode=jt,this.options.format?(this.indentate=$t,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function jt(t,e,r,n){const i=this.extractAttributes(t);if(n.push(e,i),this.checkStopNode(n)){const i=this.buildRawContent(t),s=this.buildAttributesForStopNode(t);return n.pop(),this.buildObjectNode(i,e,s,r)}const s=this.j2x(t,r+1,n);return n.pop(),void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,s.attrStr,r,n):this.buildObjectNode(s.val,e,s.attrStr,r)}function $t(t){return this.options.indentBy.repeat(t)}function Mt(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}It.prototype.build=function(t){if(this.options.preserveOrder)return Nt(t,this.options);{Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t});const e=new G;return this.j2x(t,0,e).val}},It.prototype.j2x=function(t,e,r){let n="",i="";if(this.options.maxNestedTags&&r.getDepth()>=this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");const s=this.options.jPath?r.toString():r,a=this.checkStopNode(r);for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o))if(void 0===t[o])this.isAttribute(o)&&(i+="");else if(null===t[o])this.isAttribute(o)||o===this.options.cdataPropName?i+="":"?"===o[0]?i+=this.indentate(e)+"<"+o+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+o+"/"+this.tagEndChar;else if(t[o]instanceof Date)i+=this.buildTextValNode(t[o],o,"",e,r);else if("object"!=typeof t[o]){const h=this.isAttribute(o);if(h&&!this.ignoreAttributesFn(h,s))n+=this.buildAttrPairStr(h,""+t[o],a);else if(!h)if(o===this.options.textNodeName){let e=this.options.tagValueProcessor(o,""+t[o]);i+=this.replaceEntitiesValue(e)}else{r.push(o);const n=this.checkStopNode(r);if(r.pop(),n){const r=""+t[o];i+=""===r?this.indentate(e)+"<"+o+this.closeTag(o)+this.tagEndChar:this.indentate(e)+"<"+o+">"+r+"</"+o+this.tagEndChar}else i+=this.buildTextValNode(t[o],o,"",e,r)}}else if(Array.isArray(t[o])){const n=t[o].length;let s="",a="";for(let h=0;h<n;h++){const n=t[o][h];if(void 0===n);else if(null===n)"?"===o[0]?i+=this.indentate(e)+"<"+o+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+o+"/"+this.tagEndChar;else if("object"==typeof n)if(this.options.oneListGroup){r.push(o);const t=this.j2x(n,e+1,r);r.pop(),s+=t.val,this.options.attributesGroupName&&n.hasOwnProperty(this.options.attributesGroupName)&&(a+=t.attrStr)}else s+=this.processTextOrObjNode(n,o,e,r);else if(this.options.oneListGroup){let t=this.options.tagValueProcessor(o,n);t=this.replaceEntitiesValue(t),s+=t}else{r.push(o);const t=this.checkStopNode(r);if(r.pop(),t){const t=""+n;s+=""===t?this.indentate(e)+"<"+o+this.closeTag(o)+this.tagEndChar:this.indentate(e)+"<"+o+">"+t+"</"+o+this.tagEndChar}else s+=this.buildTextValNode(n,o,"",e,r)}}this.options.oneListGroup&&(s=this.buildObjectNode(s,o,a,e)),i+=s}else if(this.options.attributesGroupName&&o===this.options.attributesGroupName){const e=Object.keys(t[o]),r=e.length;for(let i=0;i<r;i++)n+=this.buildAttrPairStr(e[i],""+t[o][e[i]],a)}else i+=this.processTextOrObjNode(t[o],o,e,r);return{attrStr:n,val:i}},It.prototype.buildAttrPairStr=function(t,e,r){return r||(e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e)),this.options.suppressBooleanAttributes&&"true"===e?" "+t:" "+t+'="'+e+'"'},It.prototype.extractAttributes=function(t){if(!t||"object"!=typeof t)return null;const e={};let r=!1;if(this.options.attributesGroupName&&t[this.options.attributesGroupName]){const n=t[this.options.attributesGroupName];for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t.startsWith(this.options.attributeNamePrefix)?t.substring(this.options.attributeNamePrefix.length):t]=n[t],r=!0)}else for(let n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const i=this.isAttribute(n);i&&(e[i]=t[n],r=!0)}return r?e:null},It.prototype.buildRawContent=function(t){if("string"==typeof t)return t;if("object"!=typeof t||null===t)return String(t);if(void 0!==t[this.options.textNodeName])return t[this.options.textNodeName];let e="";for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;if(this.isAttribute(r))continue;if(this.options.attributesGroupName&&r===this.options.attributesGroupName)continue;const n=t[r];if(r===this.options.textNodeName)e+=n;else if(Array.isArray(n)){for(let t of n)if("string"==typeof t||"number"==typeof t)e+=`<${r}>${t}</${r}>`;else if("object"==typeof t&&null!==t){const n=this.buildRawContent(t),i=this.buildAttributesForStopNode(t);e+=""===n?`<${r}${i}/>`:`<${r}${i}>${n}</${r}>`}}else if("object"==typeof n&&null!==n){const t=this.buildRawContent(n),i=this.buildAttributesForStopNode(n);e+=""===t?`<${r}${i}/>`:`<${r}${i}>${t}</${r}>`}else e+=`<${r}>${n}</${r}>`}return e},It.prototype.buildAttributesForStopNode=function(t){if(!t||"object"!=typeof t)return"";let e="";if(this.options.attributesGroupName&&t[this.options.attributesGroupName]){const r=t[this.options.attributesGroupName];for(let t in r){if(!Object.prototype.hasOwnProperty.call(r,t))continue;const n=t.startsWith(this.options.attributeNamePrefix)?t.substring(this.options.attributeNamePrefix.length):t,i=r[t];!0===i&&this.options.suppressBooleanAttributes?e+=" "+n:e+=" "+n+'="'+i+'"'}}else for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;const n=this.isAttribute(r);if(n){const i=t[r];!0===i&&this.options.suppressBooleanAttributes?e+=" "+n:e+=" "+n+'="'+i+'"'}}return e},It.prototype.buildObjectNode=function(t,e,r,n){if(""===t)return"?"===e[0]?this.indentate(n)+"<"+e+r+"?"+this.tagEndChar:this.indentate(n)+"<"+e+r+this.closeTag(e)+this.tagEndChar;{let i="</"+e+this.tagEndChar,s="";return"?"===e[0]&&(s="?",i=""),!r&&""!==r||-1!==t.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===s.length?this.indentate(n)+`\x3c!--${t}--\x3e`+this.newLine:this.indentate(n)+"<"+e+r+s+this.tagEndChar+t+this.indentate(n)+i:this.indentate(n)+"<"+e+r+s+">"+t+i}},It.prototype.closeTag=function(t){let e="";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":`></${t}`,e},It.prototype.checkStopNode=function(t){if(!this.stopNodeExpressions||0===this.stopNodeExpressions.length)return!1;for(let e=0;e<this.stopNodeExpressions.length;e++)if(t.matches(this.stopNodeExpressions[e]))return!0;return!1},It.prototype.buildTextValNode=function(t,e,r,n,i){if(!1!==this.options.cdataPropName&&e===this.options.cdataPropName)return this.indentate(n)+`<![CDATA[${t}]]>`+this.newLine;if(!1!==this.options.commentPropName&&e===this.options.commentPropName)return this.indentate(n)+`\x3c!--${t}--\x3e`+this.newLine;if("?"===e[0])return this.indentate(n)+"<"+e+r+"?"+this.tagEndChar;{let i=this.options.tagValueProcessor(e,t);return i=this.replaceEntitiesValue(i),""===i?this.indentate(n)+"<"+e+r+this.closeTag(e)+this.tagEndChar:this.indentate(n)+"<"+e+r+">"+i+"</"+e+this.tagEndChar}},It.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const r=this.options.entities[e];t=t.replace(r.regex,r.val)}return t};const Dt=It;var kt={validate:l};return e})());
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.fxp=e():t.fxp=e()}(this,()=>(()=>{"use strict";var t={d:(e,i)=>{for(var r in i)t.o(i,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:i[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{XMLBuilder:()=>Ie,XMLParser:()=>ae,XMLValidator:()=>ke});var i=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",r=new RegExp("^["+i+"]["+i+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");function n(t,e){for(var i=[],r=e.exec(t);r;){var n=[];n.startIndex=e.lastIndex-r[0].length;for(var s=r.length,a=0;a<s;a++)n.push(r[a]);i.push(n),r=e.exec(t)}return i}var s=function(t){return!(null==r.exec(t))},a=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],o=["__proto__","constructor","prototype"],l={allowBooleanAttributes:!1,unpairedTags:[]};function p(t,e){e=Object.assign({},l,e);var i=[],r=!1,n=!1;"\ufeff"===t[0]&&(t=t.substr(1));for(var s=0;s<t.length;s++)if("<"===t[s]&&"?"===t[s+1]){if((s=c(t,s+=2)).err)return s}else{if("<"!==t[s]){if(h(t[s]))continue;return v("InvalidChar","char '"+t[s]+"' is not expected.",E(t,s))}var a=s;if("!"===t[++s]){s=u(t,s);continue}var o=!1;"/"===t[s]&&(o=!0,s++);for(var p="";s<t.length&&">"!==t[s]&&" "!==t[s]&&"\t"!==t[s]&&"\n"!==t[s]&&"\r"!==t[s];s++)p+=t[s];if("/"===(p=p.trim())[p.length-1]&&(p=p.substring(0,p.length-1),s--),!N(p))return v("InvalidTag",0===p.trim().length?"Invalid space after '<'.":"Tag '"+p+"' is an invalid name.",E(t,s));var d=g(t,s);if(!1===d)return v("InvalidAttr","Attributes for '"+p+"' have open quote.",E(t,s));var f=d.value;if(s=d.index,"/"===f[f.length-1]){var m=s-f.length,y=x(f=f.substring(0,f.length-1),e);if(!0!==y)return v(y.err.code,y.err.msg,E(t,m+y.err.line));r=!0}else if(o){if(!d.tagClosed)return v("InvalidTag","Closing tag '"+p+"' doesn't have proper closing.",E(t,s));if(f.trim().length>0)return v("InvalidTag","Closing tag '"+p+"' can't have attributes or invalid starting.",E(t,a));if(0===i.length)return v("InvalidTag","Closing tag '"+p+"' has not been opened.",E(t,a));var w=i.pop();if(p!==w.tagName){var S=E(t,w.tagStartPos);return v("InvalidTag","Expected closing tag '"+w.tagName+"' (opened in line "+S.line+", col "+S.col+") instead of closing tag '"+p+"'.",E(t,a))}0==i.length&&(n=!0)}else{var A=x(f,e);if(!0!==A)return v(A.err.code,A.err.msg,E(t,s-f.length+A.err.line));if(!0===n)return v("InvalidXml","Multiple possible root nodes found.",E(t,s));-1!==e.unpairedTags.indexOf(p)||i.push({tagName:p,tagStartPos:a}),r=!0}for(s++;s<t.length;s++)if("<"===t[s]){if("!"===t[s+1]){s=u(t,++s);continue}if("?"!==t[s+1])break;if((s=c(t,++s)).err)return s}else if("&"===t[s]){var T=b(t,s);if(-1==T)return v("InvalidChar","char '&' is not expected.",E(t,s));s=T}else if(!0===n&&!h(t[s]))return v("InvalidXml","Extra text at the end",E(t,s));"<"===t[s]&&s--}return r?1==i.length?v("InvalidTag","Unclosed tag '"+i[0].tagName+"'.",E(t,i[0].tagStartPos)):!(i.length>0)||v("InvalidXml","Invalid '"+JSON.stringify(i.map(function(t){return t.tagName}),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):v("InvalidXml","Start tag expected.",1)}function h(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function c(t,e){for(var i=e;e<t.length;e++)if("?"!=t[e]&&" "!=t[e]);else{var r=t.substr(i,e-i);if(e>5&&"xml"===r)return v("InvalidXml","XML declaration allowed only at the start of the document.",E(t,e));if("?"==t[e]&&">"==t[e+1]){e++;break}}return e}function u(t,e){if(t.length>e+5&&"-"===t[e+1]&&"-"===t[e+2]){for(e+=3;e<t.length;e++)if("-"===t[e]&&"-"===t[e+1]&&">"===t[e+2]){e+=2;break}}else if(t.length>e+8&&"D"===t[e+1]&&"O"===t[e+2]&&"C"===t[e+3]&&"T"===t[e+4]&&"Y"===t[e+5]&&"P"===t[e+6]&&"E"===t[e+7]){var i=1;for(e+=8;e<t.length;e++)if("<"===t[e])i++;else if(">"===t[e]&&0===--i)break}else if(t.length>e+9&&"["===t[e+1]&&"C"===t[e+2]&&"D"===t[e+3]&&"A"===t[e+4]&&"T"===t[e+5]&&"A"===t[e+6]&&"["===t[e+7])for(e+=8;e<t.length;e++)if("]"===t[e]&&"]"===t[e+1]&&">"===t[e+2]){e+=2;break}return e}var d='"',f="'";function g(t,e){for(var i="",r="",n=!1;e<t.length;e++){if(t[e]===d||t[e]===f)""===r?r=t[e]:r!==t[e]||(r="");else if(">"===t[e]&&""===r){n=!0;break}i+=t[e]}return""===r&&{value:i,index:e,tagClosed:n}}var m=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function x(t,e){for(var i=n(t,m),r={},s=0;s<i.length;s++){if(0===i[s][1].length)return v("InvalidAttr","Attribute '"+i[s][2]+"' has no space in starting.",w(i[s]));if(void 0!==i[s][3]&&void 0===i[s][4])return v("InvalidAttr","Attribute '"+i[s][2]+"' is without value.",w(i[s]));if(void 0===i[s][3]&&!e.allowBooleanAttributes)return v("InvalidAttr","boolean attribute '"+i[s][2]+"' is not allowed.",w(i[s]));var a=i[s][2];if(!y(a))return v("InvalidAttr","Attribute '"+a+"' is an invalid name.",w(i[s]));if(Object.prototype.hasOwnProperty.call(r,a))return v("InvalidAttr","Attribute '"+a+"' is repeated.",w(i[s]));r[a]=1}return!0}function b(t,e){if(";"===t[++e])return-1;if("#"===t[e])return function(t,e){var i=/\d/;for("x"===t[e]&&(e++,i=/[\da-fA-F]/);e<t.length;e++){if(";"===t[e])return e;if(!t[e].match(i))break}return-1}(t,++e);for(var i=0;e<t.length;e++,i++)if(!(t[e].match(/\w/)&&i<20)){if(";"===t[e])break;return-1}return e}function v(t,e,i){return{err:{code:t,msg:e,line:i.line||i,col:i.col}}}function y(t){return s(t)}function N(t){return s(t)}function E(t,e){var i=t.substring(0,e).split(/\r?\n/);return{line:i.length,col:i[i.length-1].length+1}}function w(t){return t.startIndex+t[1].length}var S=function(t){return a.includes(t)?"__"+t:t},A={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0,unicode:!1},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:function(){return!1},commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,entityDecoder:null,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,i){return t},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:S};function T(t,e){if("string"==typeof t){var i=t.toLowerCase();if(a.some(function(t){return i===t.toLowerCase()}))throw new Error("[SECURITY] Invalid "+e+': "'+t+'" is a reserved JavaScript keyword that could cause prototype pollution');if(o.some(function(t){return i===t.toLowerCase()}))throw new Error("[SECURITY] Invalid "+e+': "'+t+'" is a reserved JavaScript keyword that could cause prototype pollution')}}function _(t,e){return"boolean"==typeof t?{enabled:t,maxEntitySize:1e4,maxExpansionDepth:1e4,maxTotalExpansions:1/0,maxExpandedLength:1e5,maxEntityCount:1e3,allowedTags:null,tagFilter:null,appliesTo:"all"}:"object"==typeof t&&null!==t?{enabled:!1!==t.enabled,maxEntitySize:Math.max(1,null!=(i=t.maxEntitySize)?i:1e4),maxExpansionDepth:Math.max(1,null!=(r=t.maxExpansionDepth)?r:1e4),maxTotalExpansions:Math.max(1,null!=(n=t.maxTotalExpansions)?n:1/0),maxExpandedLength:Math.max(1,null!=(s=t.maxExpandedLength)?s:1e5),maxEntityCount:Math.max(1,null!=(a=t.maxEntityCount)?a:1e3),allowedTags:null!=(o=t.allowedTags)?o:null,tagFilter:null!=(l=t.tagFilter)?l:null,appliesTo:null!=(p=t.appliesTo)?p:"all"}:_(!0);var i,r,n,s,a,o,l,p}var C,P=function(t){for(var e=Object.assign({},A,t),i=0,r=[{value:e.attributeNamePrefix,name:"attributeNamePrefix"},{value:e.attributesGroupName,name:"attributesGroupName"},{value:e.textNodeName,name:"textNodeName"},{value:e.cdataPropName,name:"cdataPropName"},{value:e.commentPropName,name:"commentPropName"}];i<r.length;i++){var n=r[i],s=n.value,a=n.name;s&&T(s,a)}return null===e.onDangerousProperty&&(e.onDangerousProperty=S),e.processEntities=_(e.processEntities,e.htmlEntities),e.unpairedTagsSet=new Set(e.unpairedTags),e.stopNodes&&Array.isArray(e.stopNodes)&&(e.stopNodes=e.stopNodes.map(function(t){return"string"==typeof t&&t.startsWith("*.")?".."+t.substring(2):t})),e};C="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");var O=function(){function t(t){this.tagname=t,this.child=[],this[":@"]=Object.create(null)}var e=t.prototype;return e.add=function(t,e){var i;"__proto__"===t&&(t="#__proto__"),this.child.push(((i={})[t]=e,i))},e.addChild=function(t,e){var i,r;"__proto__"===t.tagname&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push(((i={})[t.tagname]=t.child,i[":@"]=t[":@"],i)):this.child.push(((r={})[t.tagname]=t.child,r)),void 0!==e&&(this.child[this.child.length-1][C]={startIndex:e})},t.getMetaDataSymbol=function(){return C},t}();const $=":A-Za-z_À-ÖØ-öø-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�",j=":A-Za-z_À-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",I=j+"\\-\\.\\d·̀-ͯ҇‿-⁀",k=(t,e,i="")=>{const r=`[${t.replace(":","")}][${e.replace(":","")}]*`;return{name:new RegExp(`^[${t}][${e}]*$`,i),ncName:new RegExp(`^${r}$`,i),qName:new RegExp(`^${r}(?::${r})?$`,i),nmToken:new RegExp(`^[${e}]+$`,i),nmTokens:new RegExp(`^[${e}]+(?:\\s+[${e}]+)*$`,i)}},L=k($,$+"\\-\\.\\d·̀-ͯ‿-⁀"),D=k(j,I,"u"),R=":A-Za-z_",M=k(R,R+"\\-\\.\\d"),V=(t,{xmlVersion:e="1.0",asciiOnly:i=!1}={})=>((t="1.0",e=!1)=>e?M:"1.1"===t?D:L)(e,i).qName.test(t);var q=function(){function t(t,e){this.suppressValidationErr=!t,this.options=t,this.xmlVersion=e||1}var e=t.prototype;return e.setXmlVersion=function(t){void 0===t&&(t=1),this.xmlVersion=t},e.readDocType=function(t,e){var i=Object.create(null),r=0;if("O"!==t[e+3]||"C"!==t[e+4]||"T"!==t[e+5]||"Y"!==t[e+6]||"P"!==t[e+7]||"E"!==t[e+8])throw new Error("Invalid Tag instead of DOCTYPE");e+=9;for(var n=1,s=!1,a=!1;e<t.length;e++)if("<"!==t[e]||a)if(">"===t[e]){if(a?"-"===t[e-1]&&"-"===t[e-2]&&(a=!1,n--):n--,0===n)break}else"["===t[e]?s=!0:t[e];else{if(s&&F(t,"!ENTITY",e)){e+=7;var o,l=void 0,p=this.readEntityExp(t,e+1,this.suppressValidationErr);if(o=p[0],l=p[1],e=p[2],-1===l.indexOf("&")){if(!1!==this.options.enabled&&null!=this.options.maxEntityCount&&r>=this.options.maxEntityCount)throw new Error("Entity count ("+(r+1)+") exceeds maximum allowed ("+this.options.maxEntityCount+")");i[o]=l,r++}}else if(s&&F(t,"!ELEMENT",e))e+=8,e=this.readElementExp(t,e+1).index;else if(s&&F(t,"!ATTLIST",e))e+=8;else if(s&&F(t,"!NOTATION",e))e+=9,e=this.readNotationExp(t,e+1,this.suppressValidationErr).index;else{if(!F(t,"!--",e))throw new Error("Invalid DOCTYPE");a=!0}n++}if(0!==n)throw new Error("Unclosed DOCTYPE");return{entities:i,i:e}},e.readEntityExp=function(t,e){for(var i=e=U(t,e);e<t.length&&!/\s/.test(t[e])&&'"'!==t[e]&&"'"!==t[e];)e++;var r=t.substring(i,e);if(B(r,{xmlVersion:this.xmlVersion}),e=U(t,e),!this.suppressValidationErr){if("SYSTEM"===t.substring(e,e+6).toUpperCase())throw new Error("External entities are not supported");if("%"===t[e])throw new Error("Parameter entities are not supported")}var n,s=this.readIdentifierVal(t,e,"entity");if(e=s[0],n=s[1],!1!==this.options.enabled&&null!=this.options.maxEntitySize&&n.length>this.options.maxEntitySize)throw new Error('Entity "'+r+'" size ('+n.length+") exceeds maximum allowed size ("+this.options.maxEntitySize+")");return[r,n,--e]},e.readNotationExp=function(t,e){for(var i=e=U(t,e);e<t.length&&!/\s/.test(t[e]);)e++;var r=t.substring(i,e);!this.suppressValidationErr&&B(r,{xmlVersion:this.xmlVersion}),e=U(t,e);var n=t.substring(e,e+6).toUpperCase();if(!this.suppressValidationErr&&"SYSTEM"!==n&&"PUBLIC"!==n)throw new Error('Expected SYSTEM or PUBLIC, found "'+n+'"');e+=n.length,e=U(t,e);var s=null,a=null;if("PUBLIC"===n){var o=this.readIdentifierVal(t,e,"publicIdentifier");if(e=o[0],s=o[1],'"'===t[e=U(t,e)]||"'"===t[e]){var l=this.readIdentifierVal(t,e,"systemIdentifier");e=l[0],a=l[1]}}else if("SYSTEM"===n){var p=this.readIdentifierVal(t,e,"systemIdentifier");if(e=p[0],a=p[1],!this.suppressValidationErr&&!a)throw new Error("Missing mandatory system identifier for SYSTEM notation")}return{notationName:r,publicIdentifier:s,systemIdentifier:a,index:--e}},e.readIdentifierVal=function(t,e,i){var r,n=t[e];if('"'!==n&&"'"!==n)throw new Error('Expected quoted string, found "'+n+'"');for(var s=++e;e<t.length&&t[e]!==n;)e++;if(r=t.substring(s,e),t[e]!==n)throw new Error("Unterminated "+i+" value");return[++e,r]},e.readElementExp=function(t,e){for(var i=e=U(t,e);e<t.length&&!/\s/.test(t[e]);)e++;var r=t.substring(i,e);if(!this.suppressValidationErr&&!V(r,{xmlVersion:this.xmlVersion}))throw new Error('Invalid element name: "'+r+'"');var n="";if("E"===t[e=U(t,e)]&&F(t,"MPTY",e))e+=4;else if("A"===t[e]&&F(t,"NY",e))e+=2;else if("("===t[e]){for(var s=++e;e<t.length&&")"!==t[e];)e++;if(n=t.substring(s,e),")"!==t[e])throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error('Invalid Element Expression, found "'+t[e]+'"');return{elementName:r,contentModel:n.trim(),index:e}},e.readAttlistExp=function(t,e){for(var i=e=U(t,e);e<t.length&&!/\s/.test(t[e]);)e++;var r=t.substring(i,e);for(B(r,{xmlVersion:this.xmlVersion}),i=e=U(t,e);e<t.length&&!/\s/.test(t[e]);)e++;var n=t.substring(i,e);if(!B(n,{xmlVersion:this.xmlVersion}))throw new Error('Invalid attribute name: "'+n+'"');e=U(t,e);var s="";if("NOTATION"===t.substring(e,e+8).toUpperCase()){if(s="NOTATION","("!==t[e=U(t,e+=8)])throw new Error("Expected '(', found \""+t[e]+'"');e++;for(var a=[];e<t.length&&")"!==t[e];){for(var o=e;e<t.length&&"|"!==t[e]&&")"!==t[e];)e++;var l=t.substring(o,e);if(!B(l=l.trim(),{xmlVersion:this.xmlVersion}))throw new Error('Invalid notation name: "'+l+'"');a.push(l),"|"===t[e]&&(e++,e=U(t,e))}if(")"!==t[e])throw new Error("Unterminated list of notations");e++,s+=" ("+a.join("|")+")"}else{for(var p=e;e<t.length&&!/\s/.test(t[e]);)e++;if(s+=t.substring(p,e),!this.suppressValidationErr&&!["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"].includes(s.toUpperCase()))throw new Error('Invalid attribute type: "'+s+'"')}e=U(t,e);var h="";if("#REQUIRED"===t.substring(e,e+8).toUpperCase())h="#REQUIRED",e+=8;else if("#IMPLIED"===t.substring(e,e+7).toUpperCase())h="#IMPLIED",e+=7;else{var c=this.readIdentifierVal(t,e,"ATTLIST");e=c[0],h=c[1]}return{elementName:r,attributeName:n,attributeType:s,defaultValue:h,index:e}},t}(),U=function(t,e){for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function F(t,e,i){for(var r=0;r<e.length;r++)if(e[r]!==t[i+r+1])return!1;return!0}function B(t,e){if(V(t,{xmlVersion:e}))return t;throw new Error("Invalid entity name "+t)}const G=[48,1632,1776,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,65296,120782,120792,120802,120812,120822,66720,68912,69734,69872,69942,70096,70384,70736,70864,71248,71360,71472,71904,72016,72688,72784,73040,73120,73552,92768,92864,93008,123200,123632,124144,125264,130032],X=new Map,W=1632,z=new Uint8Array(63904).fill(255);for(const t of G)for(let e=0;e<10;e++){const i=t+e;i<=65535?z[i-W]=e:X.set(i,e)}const Y=new Set([8722,65293,65123]),H=/^[-+]?0x[a-fA-F0-9]+$/,Q=/^0b[01]+$/,J=/^0o[0-7]+$/,Z=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,K={hex:!0,binary:!1,octal:!1,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original",unicode:!1};function tt(t,e={}){if(e=Object.assign({},K,e),!t||"string"!=typeof t)return t;let i=t.trim();if(0===i.length)return t;if(void 0!==e.skipLike&&e.skipLike.test(i))return t;if("0"===i)return 0;if(e.unicode&&(i=function(t){if("string"!=typeof t)return t;const e=t.length;if(0===e)return t;let i=-1;for(let r=0;r<e;r++){const n=t.charCodeAt(r);if(!(n>=48&&n<=57||45===n))if(n<W){if(Y.has(n)){i=r;break}}else if(n>=55296&&n<=56319){if(r+1<e){const e=t.charCodeAt(r+1);if(e>=56320&&e<=57343){const t=65536+(n-55296<<10)+(e-56320);if(X.has(t)){i=r;break}}}}else if(255!==z[n-W]||Y.has(n)){i=r;break}}if(-1===i)return t;const r=[];i>0&&r.push(t.slice(0,i));for(let n=i;n<e;n++){const i=t.charCodeAt(n);if(i>=48&&i<=57||45===i){r.push(t[n]);continue}if(i<W){r.push(Y.has(i)?"-":t[n]);continue}if(i>=55296&&i<=56319){if(n+1<e){const e=t.charCodeAt(n+1);if(e>=56320&&e<=57343){const t=65536+(i-55296<<10)+(e-56320),s=X.get(t);if(void 0!==s){r.push(String.fromCharCode(s+48)),n++;continue}}}r.push(t[n]);continue}if(Y.has(i)){r.push("-");continue}const s=z[i-W];r.push(255!==s?String.fromCharCode(s+48):t[n])}return r.join("")}(i),"0"===i))return 0;if(e.hex&&H.test(i))return it(i,16);if(e.binary&&Q.test(i))return it(i,2);if(e.octal&&J.test(i))return it(i,8);if(isFinite(i)){if(i.includes("e")||i.includes("E"))return function(t,e,i){if(!i.eNotation)return t;const r=e.match(et);if(r){let n=r[1]||"";const s=-1===r[3].indexOf("e")?"E":"e",a=r[2],o=n?t[a.length+1]===s:t[a.length]===s;return a.length>1&&o?t:(1!==a.length||!r[3].startsWith(`.${s}`)&&r[3][0]!==s)&&a.length>0?i.leadingZeros&&!o?(e=(r[1]||"")+r[3],Number(e)):t:Number(e)}return t}(t,i,e);{const n=Z.exec(i);if(n){const s=n[1]||"",a=n[2];let o=(r=n[3])&&-1!==r.indexOf(".")?("."===(r=r.replace(/0+$/,""))?r="0":"."===r[0]?r="0"+r:"."===r[r.length-1]&&(r=r.substring(0,r.length-1)),r):r;const l=s?"."===t[a.length+1]:"."===t[a.length];if(!e.leadingZeros&&(a.length>1||1===a.length&&!l))return t;{const r=Number(i),n=String(r);if(0===r)return r;if(-1!==n.search(/[eE]/))return e.eNotation?r:t;if(-1!==i.indexOf("."))return"0"===n||n===o||n===`${s}${o}`?r:t;let l=a?o:i;return a?l===n||s+l===n?r:t:l===n||l===s+n?r:t}}return t}}var r;return function(t,e,i){const r=e===1/0;switch(i.infinity.toLowerCase()){case"null":return null;case"infinity":return e;case"string":return r?"Infinity":"-Infinity";default:return t}}(t,Number(i),e)}const et=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function it(t,e){const i=t.trim();if(2!==e&&8!==e||(t=i.substring(2)),parseInt)return parseInt(t,e);if(Number.parseInt)return Number.parseInt(t,e);if(window&&window.parseInt)return window.parseInt(t,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}function rt(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=Array(e);i<e;i++)r[i]=t[i];return r}class nt{constructor(t){this._matcher=t}get separator(){return this._matcher.separator}getCurrentTag(){const t=this._matcher.path;return t.length>0?t[t.length-1].tag:void 0}getCurrentNamespace(){const t=this._matcher.path;return t.length>0?t[t.length-1].namespace:void 0}getAttrValue(t){const e=this._matcher.path;if(0!==e.length)return e[e.length-1].values?.[t]}hasAttr(t){const e=this._matcher.path;if(0===e.length)return!1;const i=e[e.length-1];return void 0!==i.values&&t in i.values}getAnyParentAttr(t){return this._matcher.getAnyParentAttr(t)}hasAnyParentAttr(t){return this._matcher.hasAnyParentAttr(t)}getPosition(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].position??0}getCounter(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(t,e=!0){return this._matcher.toString(t,e)}toArray(){return this._matcher.path.map(t=>t.tag)}matches(t){return this._matcher.matches(t)}matchesAny(t){return t.matchesAny(this._matcher)}}class st{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new nt(this),this._keptAttrs=[]}push(t,e=null,i=null,r=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const n=this.path.length;let s=this.siblingStacks[n];s||(s={counts:new Map,total:0},this.siblingStacks[n]=s);const a=i?`${i}:${t}`:t,o=s.counts.get(a)||0,l=s.total;s.counts.set(a,o+1),s.total++;const p={tag:t,position:l,counter:o};null!=i&&(p.namespace=i),null!=e&&(p.values=e),this.path.push(p);const h=this.path.length,c=null!==r?r.keep:null;if(null!=c&&c.length>0&&e)for(let t=0;t<c.length;t++){const i=c[t];void 0!==e[i]&&this._keptAttrs.push({depth:h,name:i,value:e[i]})}}pop(){if(0===this.path.length)return;this._pathStringCache=null;const t=this.path.pop();this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1);const e=this.path.length+1;for(;this._keptAttrs.length>0&&this._keptAttrs[this._keptAttrs.length-1].depth>=e;)this._keptAttrs.pop();return t}updateCurrent(t){if(this.path.length>0){const e=this.path[this.path.length-1];null!=t&&(e.values=t)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){if(0!==this.path.length)return this.path[this.path.length-1].values?.[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getAnyParentAttr(t){const e=this._keptAttrs;for(let i=e.length-1;i>=0;i--)if(e[i].name===t)return e[i].value}hasAnyParentAttr(t){const e=this._keptAttrs;for(let i=e.length-1;i>=0;i--)if(e[i].name===t)return!0;return!1}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,e=!0){const i=t||this.separator;if(i===this.separator&&!0===e){if(null!==this._pathStringCache)return this._pathStringCache;const t=this.path.map(t=>t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(i);return this._pathStringCache=t,t}return this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(i)}toArray(){return this.path.map(t=>t.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[],this._keptAttrs=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e<t.length;e++)if(!this._matchSegment(t[e],this.path[e],e===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(t){let e=this.path.length-1,i=t.length-1;for(;i>=0&&e>=0;){const r=t[i];if("deep-wildcard"===r.type){if(i--,i<0)return!0;const r=t[i];let n=!1;for(let t=e;t>=0;t--)if(this._matchSegment(r,this.path[t],t===this.path.length-1)){e=t-1,i--,n=!0;break}if(!n)return!1}else{if(!this._matchSegment(r,this.path[e],e===this.path.length-1))return!1;e--,i--}}return i<0}_matchSegment(t,e,i){if("*"!==t.tag&&t.tag!==e.tag)return!1;if(void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace)return!1;if(void 0!==t.attrName){if(!i)return!1;if(!e.values||!(t.attrName in e.values))return!1;if(void 0!==t.attrValue&&String(e.values[t.attrName])!==String(t.attrValue))return!1}if(void 0!==t.position){if(!i)return!1;const r=e.counter??0;if("first"===t.position&&0!==r)return!1;if("odd"===t.position&&r%2!=1)return!1;if("even"===t.position&&r%2!=0)return!1;if("nth"===t.position&&r!==t.positionValue)return!1}return!0}matchesAny(t){return t.matchesAny(this)}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>t?{counts:new Map(t.counts),total:t.total}:t),keptAttrs:this._keptAttrs.map(t=>({...t}))}}restore(t){this._pathStringCache=null,this.path=t.path.map(t=>({...t})),this.siblingStacks=t.siblingStacks.map(t=>t?{counts:new Map(t.counts),total:t.total}:t),this._keptAttrs=(t.keptAttrs||[]).map(t=>({...t}))}readOnly(){return this._view}}class at{constructor(t,e={},i){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this.data=i,this._hasDeepWildcard=this.segments.some(t=>"deep-wildcard"===t.type),this._hasAttributeCondition=this.segments.some(t=>void 0!==t.attrName),this._hasPositionSelector=this.segments.some(t=>void 0!==t.position)}_parse(t){const e=[];let i=0,r="";for(;i<t.length;)t[i]===this.separator?i+1<t.length&&t[i+1]===this.separator?(r.trim()&&(e.push(this._parseSegment(r.trim())),r=""),e.push({type:"deep-wildcard"}),i+=2):(r.trim()&&e.push(this._parseSegment(r.trim())),r="",i++):(r+=t[i],i++);return r.trim()&&e.push(this._parseSegment(r.trim())),e}_parseSegment(t){const e={type:"tag"};let i=null,r=t;const n=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(n&&(r=n[1]+n[3],n[2])){const t=n[2].slice(1,-1);t&&(i=t)}let s,a,o=r;if(r.includes("::")){const e=r.indexOf("::");if(s=r.substring(0,e).trim(),o=r.substring(e+2).trim(),!s)throw new Error(`Invalid namespace in pattern: ${t}`)}let l=null;if(o.includes(":")){const t=o.lastIndexOf(":"),e=o.substring(0,t).trim(),i=o.substring(t+1).trim();["first","last","odd","even"].includes(i)||/^nth\(\d+\)$/.test(i)?(a=e,l=i):a=o}else a=o;if(!a)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=a,s&&(e.namespace=s),i)if(i.includes("=")){const t=i.indexOf("=");e.attrName=i.substring(0,t).trim(),e.attrValue=i.substring(t+1).trim()}else e.attrName=i.trim();if(l){const t=l.match(/^nth\((\d+)\)$/);t?(e.position="nth",e.positionValue=parseInt(t[1],10)):e.position=l}return e}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class ot{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._deepByTerminalTag=new Map,this._patterns=new Set,this._sealed=!1}add(t){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(t.pattern))return this;if(this._patterns.add(t.pattern),t.hasDeepWildcard()){const e=t.segments[t.segments.length-1];if(e&&"deep-wildcard"!==e.type&&"*"!==e.tag){const i=e.tag;this._deepByTerminalTag.has(i)||this._deepByTerminalTag.set(i,[]),this._deepByTerminalTag.get(i).push(t)}else this._deepWildcards.push(t);return this}const e=t.length,i=t.segments[t.segments.length-1],r=i?.tag;if(r&&"*"!==r){const i=`${e}:${r}`;this._byDepthAndTag.has(i)||this._byDepthAndTag.set(i,[]),this._byDepthAndTag.get(i).push(t)}else this._wildcardByDepth.has(e)||this._wildcardByDepth.set(e,[]),this._wildcardByDepth.get(e).push(t);return this}addAll(t){for(const e of t)this.add(e);return this}has(t){return this._patterns.has(t.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(t){return null!==this.findMatch(t)}findMatch(t){const e=t.getDepth(),i=t.getCurrentTag(),r=`${e}:${i}`,n=this._byDepthAndTag.get(r);if(n)for(let e=0;e<n.length;e++)if(t.matches(n[e]))return n[e];const s=this._wildcardByDepth.get(e);if(s)for(let e=0;e<s.length;e++)if(t.matches(s[e]))return s[e];const a=this._deepByTerminalTag.get(i);if(a)for(let e=0;e<a.length;e++)if(t.matches(a[e]))return a[e];for(let e=0;e<this._deepWildcards.length;e++)if(t.matches(this._deepWildcards[e]))return this._deepWildcards[e];return null}}const lt={cent:"¢",pound:"£",curren:"¤",yen:"¥",euro:"€",dollar:"$",fnof:"ƒ",inr:"₹",af:"؋",birr:"ብር",peso:"₱",rub:"₽",won:"₩",yuan:"¥",cedil:"¸"},pt={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'},ht={nbsp:" ",copy:"©",reg:"®",trade:"™",mdash:"—",ndash:"–",hellip:"…",laquo:"«",raquo:"»",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",bull:"•",para:"¶",sect:"§",deg:"°",frac12:"½",frac14:"¼",frac34:"¾"},ct=Object.freeze({ALLOW:"allow",BLOCK:"block",THROW:"throw"}),ut=new Set("!?\\\\/[]$%{}^&*()<>|+");function dt(t){if("#"===t[0])throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t}"`);for(const e of t)if(ut.has(e))throw new Error(`[EntityReplacer] Invalid character '${e}' in entity name: "${t}"`);return t}function ft(...t){const e=Object.create(null);for(const i of t)if(i)for(const t of Object.keys(i)){const r=i[t];if("string"==typeof r)e[t]=r;else if(r&&"object"==typeof r&&void 0!==r.val){const i=r.val;"string"==typeof i&&(e[t]=i)}}return e}const gt="external",mt="base",xt="all",bt=Object.freeze({allow:0,leave:1,remove:2,throw:3}),vt=new Set([9,10,13]);class yt{constructor(t={}){var e;this._limit=t.limit||{},this._maxTotalExpansions=this._limit.maxTotalExpansions||0,this._maxExpandedLength=this._limit.maxExpandedLength||0,this._postCheck="function"==typeof t.postCheck?t.postCheck:t=>t,this._limitTiers=(e=this._limit.applyLimitsTo??gt)&&e!==gt?e===xt?new Set([xt]):e===mt?new Set([mt]):Array.isArray(e)?new Set(e):new Set([gt]):new Set([gt]),this._numericAllowed=t.numericAllowed??!0,this._baseMap=ft(pt,t.namedEntities||null),this._externalMap=Object.create(null),this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this._removeSet=new Set(t.remove&&Array.isArray(t.remove)?t.remove:[]),this._leaveSet=new Set(t.leave&&Array.isArray(t.leave)?t.leave:[]);const i=function(t){if(!t)return{xmlVersion:1,onLevel:bt.allow,nullLevel:bt.remove};const e=1.1===t.xmlVersion?1.1:1,i=bt[t.onNCR]??bt.allow,r=bt[t.nullNCR]??bt.remove;return{xmlVersion:e,onLevel:i,nullLevel:Math.max(r,bt.remove)}}(t.ncr);this._ncrXmlVersion=i.xmlVersion,this._ncrOnLevel=i.onLevel,this._ncrNullLevel=i.nullLevel,this._onExternalEntity="function"==typeof t.onExternalEntity?t.onExternalEntity:null,this._onInputEntity="function"==typeof t.onInputEntity?t.onInputEntity:null}_applyRegistrationHook(t,e,i,r){if(!t)return!0;const n=t(e,i);if(n===ct.BLOCK)return!1;if(n===ct.THROW)throw new Error(`[EntityDecoder] Registration of ${r} entity "&${e};" was rejected by hook`);return!0}setExternalEntities(t){if(t)for(const e of Object.keys(t))dt(e);if(!this._onExternalEntity)return void(this._externalMap=ft(t));const e=ft(t),i=Object.create(null);for(const[t,r]of Object.entries(e))this._applyRegistrationHook(this._onExternalEntity,t,r,"external")&&(i[t]=r);this._externalMap=i}addExternalEntity(t,e){dt(t),"string"==typeof e&&-1===e.indexOf("&")&&this._applyRegistrationHook(this._onExternalEntity,t,e,"external")&&(this._externalMap[t]=e)}addInputEntities(t){if(this._totalExpansions=0,this._expandedLength=0,!this._onInputEntity)return void(this._inputMap=ft(t));const e=ft(t),i=Object.create(null);for(const[t,r]of Object.entries(e))this._applyRegistrationHook(this._onInputEntity,t,r,"input")&&(i[t]=r);this._inputMap=i}reset(){return this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this}setXmlVersion(t){this._ncrXmlVersion=1.1===t?1.1:1}decode(t){if("string"!=typeof t||0===t.length)return t;if(-1===t.indexOf("&"))return t;const e=t,i=[],r=t.length;let n=0,s=0;const a=this._maxTotalExpansions>0,o=this._maxExpandedLength>0,l=a||o;for(;s<r;){if(38!==t.charCodeAt(s)){s++;continue}let e=s+1;for(;e<r&&59!==t.charCodeAt(e)&&e-s<=32;)e++;if(e>=r||59!==t.charCodeAt(e)){s++;continue}const p=t.slice(s+1,e);if(0===p.length){s++;continue}let h,c;if(this._removeSet.has(p))h="",void 0===c&&(c=gt);else{if(this._leaveSet.has(p)){s++;continue}if(35===p.charCodeAt(0)){const t=this._resolveNCR(p);if(void 0===t){s++;continue}h=t,c=mt}else{const t=this._resolveName(p);h=t?.value,c=t?.tier}}if(void 0!==h){if(s>n&&i.push(t.slice(n,s)),i.push(h),n=e+1,s=n,l&&this._tierCounts(c)){if(a&&(this._totalExpansions++,this._totalExpansions>this._maxTotalExpansions))throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`);if(o){const t=h.length-(p.length+2);if(t>0&&(this._expandedLength+=t,this._expandedLength>this._maxExpandedLength))throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`)}}}else s++}n<r&&i.push(t.slice(n));const p=0===i.length?t:i.join("");return this._postCheck(p,e)}_tierCounts(t){return!!this._limitTiers.has(xt)||this._limitTiers.has(t)}_resolveName(t){return t in this._inputMap?{value:this._inputMap[t],tier:gt}:t in this._externalMap?{value:this._externalMap[t],tier:gt}:t in this._baseMap?{value:this._baseMap[t],tier:mt}:void 0}_classifyNCR(t){return 0===t?this._ncrNullLevel:t>=55296&&t<=57343||1===this._ncrXmlVersion&&t>=1&&t<=31&&!vt.has(t)?bt.remove:-1}_applyNCRAction(t,e,i){switch(t){case bt.allow:return String.fromCodePoint(i);case bt.remove:return"";case bt.leave:return;case bt.throw:throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e}; (U+${i.toString(16).toUpperCase().padStart(4,"0")})`);default:return String.fromCodePoint(i)}}_resolveNCR(t){const e=t.charCodeAt(1);let i;if(i=120===e||88===e?parseInt(t.slice(2),16):parseInt(t.slice(1),10),Number.isNaN(i)||i<0||i>1114111)return;const r=this._classifyNCR(i);if(!this._numericAllowed&&r<bt.remove)return;const n=-1===r?this._ncrOnLevel:Math.max(this._ncrOnLevel,r);return this._applyNCRAction(n,t,i)}}const Nt=[{id:"sql-block-comment-open",description:"SQL block comment open: /* ... */ — unusual in legitimate user text",pattern:/\/\*/},{id:"sql-union-select",description:"UNION SELECT — most common SQL injection aggregation attack",pattern:/\bUNION\s{1,20}(?:ALL\s{1,20})?SELECT\b/i},{id:"sql-drop-table",description:"DROP TABLE — destructive DDL injection",pattern:/\bDROP\s{1,20}TABLE\b/i},{id:"sql-drop-database",description:"DROP DATABASE — destructive DDL injection",pattern:/\bDROP\s{1,20}DATABASE\b/i},{id:"sql-insert-into",description:"INSERT INTO — data injection",pattern:/\bINSERT\s{1,20}INTO\b/i},{id:"sql-delete-from",description:"DELETE FROM — data deletion injection",pattern:/\bDELETE\s{1,20}FROM\b/i},{id:"sql-update-set",description:"UPDATE ... SET — data modification injection",pattern:/\bUPDATE\b[\s\S]{1,60}\bSET\b/i},{id:"sql-exec-xp",description:"EXEC xp_ — MSSQL extended stored procedure execution",pattern:/\bEXEC(?:UTE)?\s{1,20}xp_/i},{id:"sql-tautology-string",description:'Classic string tautology: \' OR \'1\'=\'1 or " OR "1"="1"',pattern:/'\s{0,10}OR\s{0,10}'[^']{0,20}'\s*=\s*'[^']{0,20}/i},{id:"sql-tautology-numeric",description:"Numeric tautology: OR 1=1",pattern:/\bOR\s{1,10}1\s*=\s*1\b/i},{id:"sql-always-true-zero",description:"Numeric tautology: OR 0=0",pattern:/\bOR\s{1,10}0\s*=\s*0\b/i},{id:"sql-sleep-benchmark",description:"Time-based blind injection: SLEEP() or BENCHMARK()",pattern:/\b(?:SLEEP|BENCHMARK)\s*\(/i},{id:"sql-waitfor-delay",description:"MSSQL time-based blind injection: WAITFOR DELAY",pattern:/\bWAITFOR\s{1,20}DELAY\b/i},{id:"sql-char-function",description:"CHAR() function — used to obfuscate injected strings",pattern:/\bCHAR\s*\(\s*\d{1,3}/i},{id:"sql-information-schema",description:"INFORMATION_SCHEMA — reconnaissance query for table/column enumeration",pattern:/\bINFORMATION_SCHEMA\b/i}],Et=[...Nt,{id:"sql-line-comment",description:"SQL line comment: -- followed by whitespace or end of string",pattern:/--(?:\s|$)/},{id:"sql-stacked-query",description:"Stacked queries: semicolon immediately followed by a SQL keyword",pattern:/;\s{0,10}(?:SELECT|INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|EXEC)\b/i},{id:"sql-hex-encoding",description:"Hex-encoded string injection: 0x41414141 style (MySQL)",pattern:/\b0x[0-9a-f]{4,}/i}],wt=[{id:"html-script-open",description:"<script opening tag",pattern:/<script[\s>/]/i},{id:"html-script-close",description:"<\/script closing tag",pattern:/<\/script[\s>]/i},{id:"html-javascript-protocol",description:"javascript: URI scheme (with optional whitespace/encoding)",pattern:/j[\t\n\r ]*a[\t\n\r ]*v[\t\n\r ]*a[\t\n\r ]*s[\t\n\r ]*c[\t\n\r ]*r[\t\n\r ]*i[\t\n\r ]*p[\t\n\r ]*t[\t\n\r ]*:/i},{id:"html-vbscript-protocol",description:"vbscript: URI scheme",pattern:/vbscript[\t\n\r ]*:/i},{id:"html-data-html",description:"data:text/html URI — can execute scripts in browsers",pattern:/data[\t\n\r ]*:[\t\n\r ]*text\/html/i},{id:"html-data-xhtml",description:"data:application/xhtml+xml URI",pattern:/data[\t\n\r ]*:[\t\n\r ]*application\/xhtml/i},{id:"html-data-svg",description:"data:image/svg+xml URI — can execute scripts",pattern:/data[\t\n\r ]*:[\t\n\r ]*image\/svg\+xml/i},{id:"html-inline-event-handler",description:"Inline event handler attributes: onclick=, onerror=, onload=, etc.",pattern:/\bon\w{1,30}\s*=/i},{id:"html-entity-obfuscated-script",description:"HTML-entity-encoded <script (e.g. &#x3C;script or &lt;script)",pattern:/(?:&#x0*3[Cc];?|&#0*60;?|&lt;)\s*script/i},{id:"html-entity-obfuscated-javascript",description:'HTML-entity-encoded javascript: (partial — catches common &#106; or &#x6a; for "j")',pattern:/(?:&#x0*6[Aa];?|&#0*106;?)\s*(?:&#x0*61;?|a)[\s\S]{0,80}script\s*:/i},{id:"html-style-expression",description:"CSS expression() — IE-era code execution in style attributes",pattern:/style[\s\S]{0,20}expression\s*\(/i},{id:"html-object-embed",description:"<object or <embed tags that can load active content",pattern:/<(?:object|embed)[\s>/]/i},{id:"html-base-tag",description:"<base href= — can hijack all relative URLs on a page",pattern:/<base[\s>]/i},{id:"html-meta-refresh",description:'<meta http-equiv="refresh" — can redirect users',pattern:/<meta[\s\S]{0,40}http-equiv[\s\S]{0,20}refresh/i},{id:"html-srcdoc",description:"srcdoc= attribute on iframes — embeds HTML that can run scripts",pattern:/srcdoc\s*=/i},{id:"html-iframe",description:"<iframe tag",pattern:/<iframe[\s>/]/i},{id:"html-form",description:"<form tag — can be used for phishing / credential harvesting injection",pattern:/<form[\s>/]/i}],St=[{id:"xml-cdata-injection",description:"CDATA section injection: <![CDATA[ breaks out of text node context",pattern:/<!\[CDATA\[/i},{id:"xml-cdata-close",description:"CDATA close sequence: ]]> can terminate an enclosing CDATA section",pattern:/\]\]>/},{id:"xml-processing-instruction",description:"XML processing instruction: <?xml-stylesheet or <?php etc.",pattern:/<\?(?:xml[\- ]|php|asp)/i},{id:"xml-doctype-injection",description:"DOCTYPE declaration embedded in content — can define entities",pattern:/<!DOCTYPE(?:[\s[]|$)/i},{id:"xml-entity-system",description:"SYSTEM keyword — used in external entity declarations (XXE)",pattern:/\bSYSTEM\s+["']/i},{id:"xml-entity-public",description:"PUBLIC keyword — used in external entity declarations (XXE)",pattern:/\bPUBLIC\s+["']/i},{id:"xml-entity-declaration",description:"<!ENTITY declaration — defines entities, potential XXE or entity expansion",pattern:/<!ENTITY[\s%]/i},{id:"xml-billion-laughs",description:"Entity reference chaining / billion laughs: repeated &eX; style references",pattern:/(?:&\w{1,20};){3,}/},{id:"xml-namespace-confusion",description:"xmlns: attribute injection — can redefine namespaces to confuse parsers",pattern:/\bxmlns\s*(?::\w{1,40})?\s*=/i},{id:"xml-comment-injection",description:"\x3c!-- comment injection — can hide content from some parsers",pattern:/<!--/},{id:"xml-comment-close",description:"--\x3e closes an enclosing XML comment",pattern:/-->/},{id:"xml-pi-close",description:"?> closes an enclosing processing instruction",pattern:/\?>/}],At=[{id:"svg-script-element",description:"<script element inside SVG executes JavaScript",pattern:/<script[\s>/]/i},{id:"svg-xlink-href-javascript",description:"xlink:href with javascript: — classic SVG XSS via <a> or <use>",pattern:/xlink\s*:\s*href\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-href-javascript",description:"href= with javascript: in SVG context (<a>, <animate>, etc.)",pattern:/href\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-foreignobject",description:"<foreignObject embeds HTML inside SVG — can execute scripts",pattern:/<foreignObject[\s>/]/i},{id:"svg-use-external",description:"<use xlink:href or href pointing to external resource (non-fragment URL)",pattern:/<use[\s\S]{0,60}(?:xlink\s*:\s*)?href\s*=\s*(?:["'][^#]|[^"'#\s>])/i},{id:"svg-animate-href",description:'<animate attributeName="href" — can dynamically change href to javascript:',pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*href["']/i},{id:"svg-animate-xlinkhref",description:'<animate attributeName="xlink:href"',pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*xlink\s*:\s*href["']/i},{id:"svg-set-javascript",description:'<set to="javascript:..." — sets an attribute to a javascript: URI',pattern:/<set[\s\S]{0,80}to\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-event-handler",description:"SVG-specific event handler attributes: onload=, onerror=, onactivate=, etc.",pattern:/\bon(?:load|error|activate|begin|end|repeat|focus|blur|click|mouse\w{1,20}|key\w{1,20})\s*=/i},{id:"svg-handler-generic",description:"Generic on* handler catch-all for SVG attributes",pattern:/\bon\w{1,30}\s*=/i},{id:"svg-filter-feimage",description:"<feImage href= — filter primitive that can load external resources",pattern:/<feImage[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=/i},{id:"svg-image-external",description:"<image xlink:href with http/https or javascript protocol",pattern:/<image[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=\s*["']?\s*(?:https?|javascript)\s*:/i},{id:"svg-style-javascript",description:"style= attribute containing javascript: (e.g. background:url(javascript:...))",pattern:/style\s*=[\s\S]{0,60}javascript\s*:/i}],Tt=[{id:"shell-path-traversal-unix",description:"Unix path traversal: ../ — climbing the directory tree",pattern:/\.\.\//},{id:"shell-path-traversal-windows",description:"Windows path traversal: ..\\ — climbing the directory tree",pattern:/\.\.\\/},{id:"shell-path-traversal-encoded",description:"URL-encoded path traversal: %2e%2e or %2f variants",pattern:/%2e%2e|%2f\.\.|\.\.%2f/i},{id:"shell-null-byte",description:"Null byte injection: \\x00 or %00 — truncates strings in C-backed functions",pattern:/\x00|%00/},{id:"shell-semicolon",description:"Semicolon command separator: cmd1; cmd2",pattern:/;/},{id:"shell-pipe",description:"Pipe operator: cmd1 | cmd2",pattern:/\|/},{id:"shell-and-operator",description:"AND operator: cmd1 && cmd2",pattern:/&&/},{id:"shell-or-operator",description:"OR operator: cmd1 || cmd2",pattern:/\|\|/},{id:"shell-backtick",description:"Backtick command substitution: `cmd`",pattern:/`/},{id:"shell-dollar-paren",description:"Dollar-paren command substitution: $(cmd)",pattern:/\$\(/},{id:"shell-dollar-brace",description:"Dollar-brace variable expansion: ${var} — can be abused for injection",pattern:/\$\{/},{id:"shell-redirect-out",description:"Output redirection: cmd > file or cmd >> file",pattern:/>{1,2}/},{id:"shell-redirect-in",description:"Input redirection: cmd < file",pattern:/</},{id:"shell-newline-injection",description:"Newline injection: \\n or \\r — can inject new shell commands",pattern:/[\n\r]/},{id:"shell-glob-star",description:"Glob expansion: * or ? — can expand to unintended files",pattern:/[/\\][*?]/},{id:"shell-absolute-root",description:"Absolute root path injection: string starting with / or \\ (Windows UNC)",pattern:/^(?:\/|\\\\)/},{id:"shell-windows-drive",description:"Windows drive letter path injection: C:\\ or D:/",pattern:/^[a-zA-Z]:[/\\]/},{id:"shell-curl-wget",description:"curl/wget with URL or flags — can exfiltrate data or download payloads",pattern:/\b(?:curl|wget)\s+(?:https?:\/\/|ftp:\/\/|-)/i}],_t=[{id:"redos-nested-quantifier-plus",description:"Nested + quantifier inside a group with outer quantifier: (a+)+, (.+b)*, etc.",pattern:/\([^)]*\+[^)]*\)[+*]/},{id:"redos-nested-quantifier-star",description:"Nested * quantifier: (a*)* or (a*)+ — catastrophic backtracking",pattern:/\([^)]*\*[^)]*\)[*+]/},{id:"redos-nested-groups",description:"Doubly nested quantified groups: ((a+)+) — guaranteed catastrophic",pattern:/\(\([^)]{0,40}\)[+*]\)[+*]/},{id:"redos-alternation-overlap",description:"Overlapping alternation under quantifier: (a|a)+ — ambiguous NFA paths",pattern:/\(([^|()]{1,20})\|(?:\1)(?:\|[^|()]{1,20}){0,5}\)[+*?]{1,2}/},{id:"redos-star-plus-concat",description:"(x*x)+ pattern — triggers super-linear backtracking",pattern:/\([^)]{0,10}\*[^)]{0,10}\)[+*]/},{id:"redos-dot-star-greedy",description:"(.*){n,} or (.+){n,} — repeated greedy dot quantifiers",pattern:/\(\.[*+]\)\{?\d/},{id:"redos-large-repetition",description:"Very large fixed or range repetition count {1000,} or {1000,n} — denial of service via backtracking",pattern:/\{\d{4,}(?:,\d*)?\}/},{id:"redos-catastrophic-alternation",description:"Long alternation with many similar branches — polynomial backtracking risk",pattern:/\([^)]{0,200}(?:\|[^|)]{0,50}){9,}\)/}],Ct="[\"'\\s]*:",Pt=[{id:"nosql-where-operator",description:"$where — executes arbitrary JavaScript server-side in MongoDB",pattern:new RegExp(`\\$where${Ct}`,"i")},{id:"nosql-ne-operator",description:'$ne — "not equal" operator used to bypass equality checks',pattern:new RegExp(`\\$ne${Ct}`,"i")},{id:"nosql-gt-operator",description:'$gt — "greater than" used to bypass password/value checks',pattern:new RegExp(`\\$gte?${Ct}`,"i")},{id:"nosql-lt-operator",description:'$lt / $lte — "less than" bypass variants',pattern:new RegExp(`\\$lte?${Ct}`,"i")},{id:"nosql-regex-operator",description:"$regex — can be used to extract data character by character (blind injection)",pattern:new RegExp(`\\$regex${Ct}`,"i")},{id:"nosql-or-operator",description:"$or — logical OR; used to create always-true conditions",pattern:new RegExp(`\\$or${Ct}\\s*\\[`,"i")},{id:"nosql-and-operator",description:"$and — logical AND operator injection",pattern:new RegExp(`\\$and${Ct}\\s*\\[`,"i")},{id:"nosql-nor-operator",description:"$nor — logical NOR operator injection",pattern:new RegExp(`\\$nor${Ct}\\s*\\[`,"i")},{id:"nosql-exists-operator",description:"$exists — can enumerate fields to determine schema",pattern:new RegExp(`\\$exists${Ct}`,"i")},{id:"nosql-in-operator",description:"$in — matches any value in a list; can enumerate values",pattern:new RegExp(`\\$in${Ct}\\s*\\[`,"i")},{id:"nosql-expr-operator",description:"$expr — allows aggregation expressions in queries (MongoDB 3.6+)",pattern:new RegExp(`\\$expr${Ct}`,"i")},{id:"nosql-function-operator",description:"$function — executes arbitrary JavaScript in MongoDB 4.4+",pattern:new RegExp(`\\$function${Ct}`,"i")},{id:"nosql-accumulator-operator",description:"$accumulator — custom aggregation with arbitrary JS execution",pattern:new RegExp(`\\$accumulator${Ct}`,"i")},{id:"nosql-proto-pollution",description:"__proto__ — prototype pollution via object key injection",pattern:/__proto__/},{id:"nosql-constructor-prototype",description:"constructor.prototype — alternative prototype pollution vector (dot notation or JSON key)",pattern:/constructor[\s"':.,{\[]*prototype/i},{id:"nosql-proto-bracket",description:'["__proto__"] — bracket-notation prototype pollution',pattern:/\[["']__proto__["']\]/}],Ot=[{id:"log-crlf-injection",description:"CRLF injection: literal \\r or \\n embeds fake log lines",pattern:/[\r\n]/},{id:"log-url-encoded-crlf",description:"URL-encoded CRLF: %0d, %0a, %0D, %0A — decoded by some log parsers",pattern:/%0[dDaA]/},{id:"log-unicode-newline",description:"Unicode newline variants: U+2028 (line separator), U+2029 (paragraph separator)",pattern:/[\u2028\u2029]/},{id:"log-log4shell-jndi",description:"Log4Shell: ${jndi:...} triggers remote code execution in Apache Log4j",pattern:/\$\{jndi\s*:/i},{id:"log-log4shell-obfuscated",description:"Obfuscated Log4Shell: ${::-j}... lookup-bypass prefix used to evade WAF detection",pattern:/\$\{::-/},{id:"log-log4j-lookup",description:"Log4j lookup syntax: ${env:...}, ${sys:...}, ${ctx:...} — data exfiltration",pattern:/\$\{(?:env|sys|ctx|main|map|sd|web|docker|k8s|spring)\s*:/i},{id:"log-ssti-double-brace",description:"SSTI double-brace: {{expression}} — Jinja2, Twig, Handlebars, etc.",pattern:/\{\{[\s\S]{0,80}\}\}/},{id:"log-ssti-hash-brace",description:"SSTI hash-brace: #{expression} — Thymeleaf, Velocity, Ruby ERB",pattern:/#\{[\s\S]{0,80}\}/},{id:"log-ssti-dollar-brace",description:"SSTI/EL injection: ${expression with operators or method calls} — JSP EL, Freemarker, SpEL",pattern:/\$\{[^}]*(?:\.|\(|\*|\+|\bclass\b|\bruntime\b|\bprocess\b|\bexec\b)[^}]{0,80}\}/i},{id:"log-ssti-percent-tag",description:"SSTI ERB/ASP tag: <%= expression %> — Ruby ERB, ASP",pattern:/<%=[\s\S]{0,80}%>/},{id:"log-null-byte",description:"Null byte: \\x00 or %00 — can truncate log entries in C-backed loggers",pattern:/\x00|%00/},{id:"log-ansi-escape",description:"ANSI escape sequence: ESC[ — can manipulate terminal output when logs are tailed",pattern:/\x1b\[/}];function $t(t,e){const i=e.label??"CUSTOM";for(const r of e)if(r.pattern.test(t))return{context:i,id:r.id,description:r.description,pattern:r.pattern};return null}function jt(t,e){(function(t){if("string"!=typeof t)throw new TypeError("is-unsafe: first argument must be a string, got "+typeof t)})(t),function(t){if(!(t instanceof RegExp)){if(!Array.isArray(t))throw new TypeError("is-unsafe: second argument must be a PatternList (e.g. HTML), an array of PatternLists (e.g. [HTML, XML]), or a RegExp. Got: "+typeof t);if(0===t.length)throw new TypeError("is-unsafe: context must not be an empty array");if(Array.isArray(t[0]))for(const e of t)if(!Array.isArray(e)||0===e.length)throw new TypeError("is-unsafe: each context in the array must be a non-empty pattern array (PatternList)")}}(e);const{lists:i,regex:r}=function(t){return t instanceof RegExp?{lists:null,regex:t}:Array.isArray(t[0])?{lists:t,regex:null}:{lists:[t],regex:null}}(e);if(r)return r.test(t);for(const e of i)if(null!==$t(t,e))return!0;return!1}function It(){return It=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var r in i)({}).hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},It.apply(null,arguments)}function kt(t,e){if(!t)return{};var i=e.attributesGroupName?t[e.attributesGroupName]:t;if(!i)return{};var r={};for(var n in i)n.startsWith(e.attributeNamePrefix)?r[n.substring(e.attributeNamePrefix.length)]=i[n]:r[n]=i[n];return r}function Lt(t){if(t&&"string"==typeof t){var e=t.indexOf(":");if(-1!==e&&e>0){var i=t.substring(0,e);if("xmlns"!==i)return i}}}wt.label="HTML",St.label="XML",At.label="SVG",Nt.label="SQL",Et.label="SQL-STRICT",Tt.label="SHELL",_t.label="REDOS",Pt.label="NOSQL",Ot.label="LOG",Object.freeze({HTML:wt,XML:St,SVG:At,SQL:Nt,"SQL-STRICT":Et,SHELL:Tt,REDOS:_t,NOSQL:Pt,LOG:Ot});var Dt=function(t,e){var i;this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=Ut,this.parseTextData=Rt,this.resolveNameSpace=Mt,this.buildAttributesMap=qt,this.isItStopNode=Xt,this.replaceEntitiesValue=Bt,this.readStopNodeData=Ht,this.saveTextToParentTag=Gt,this.addChild=Ft,this.ignoreAttributesFn="function"==typeof(i=this.options.ignoreAttributes)?i:Array.isArray(i)?function(t){for(var e,r=function(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(i)return(i=i.call(t)).next.bind(i);if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return rt(t,e);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?rt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(i);!(e=r()).done;){var n=e.value;if("string"==typeof n&&t===n)return!0;if(n instanceof RegExp&&n.test(t))return!0}}:function(){return!1},this.entityExpansionCount=0,this.currentExpandedLength=0,this.doctypefound=!1;var r=It({},pt);this.options.entityDecoder?this.entityDecoder=this.options.entityDecoder:("object"==typeof this.options.htmlEntities?r=this.options.htmlEntities:!0===this.options.htmlEntities&&(r=It({},ht,lt)),this.entityDecoder=new yt({namedEntities:It({},r,e),numericAllowed:this.options.htmlEntities,limit:{maxTotalExpansions:this.options.processEntities.maxTotalExpansions,maxExpandedLength:this.options.processEntities.maxExpandedLength,applyLimitsTo:this.options.processEntities.appliesTo},onInputEntity:function(t,e){return jt(e,[wt,St])?ct.BLOCK:ct.ALLOW}})),this.matcher=new st,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new ot;var n=this.options.stopNodes;if(n&&n.length>0){for(var s=0;s<n.length;s++){var a=n[s];"string"==typeof a?this.stopNodeExpressionsSet.add(new at(a)):a instanceof at&&this.stopNodeExpressionsSet.add(a)}this.stopNodeExpressionsSet.seal()}};function Rt(t,e,i,r,n,s,a){var o=this.options;if(void 0!==t&&(o.trimValues&&!r&&(t=t.trim()),t.length>0)){a||(t=this.replaceEntitiesValue(t,e,i));var l=o.jPath?i.toString():i,p=o.tagValueProcessor(e,t,l,n,s);return null==p?t:typeof p!=typeof t||p!==t?p:o.trimValues||t.trim()===t?Qt(t,o.parseTagValue,o.numberParseOptions):t}}function Mt(t){if(this.options.removeNSPrefix){var e=t.split(":"),i="/"===t.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(t=i+e[1])}return t}var Vt=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function qt(t,e,i,r){void 0===r&&(r=!1);var s=this.options;if(!0===r||!0!==s.ignoreAttributes&&"string"==typeof t){for(var a=n(t,Vt),o=a.length,l={},p=new Array(o),h=!1,c={},u=0;u<o;u++){var d=this.resolveNameSpace(a[u][1]),f=a[u][4];if(d.length&&void 0!==f){var g=f;s.trimValues&&(g=g.trim()),g=this.replaceEntitiesValue(g,i,this.readonlyMatcher),p[u]=g,c[d]=g,h=!0}}h&&"object"==typeof e&&e.updateCurrent&&e.updateCurrent(c);for(var m=s.jPath?e.toString():this.readonlyMatcher,x=!1,b=0;b<o;b++){var v=this.resolveNameSpace(a[b][1]);if(!this.ignoreAttributesFn(v,m)){var y=s.attributeNamePrefix+v;if(v.length)if(s.transformAttributeName&&(y=s.transformAttributeName(y)),y=Zt(y,s),void 0!==a[b][4]){var N=p[b],E=s.attributeValueProcessor(v,N,m);l[y]=null==E?N:typeof E!=typeof N||E!==N?E:Qt(N,s.parseAttributeValue,s.numberParseOptions),x=!0}else s.allowBooleanAttributes&&(l[y]=!0,x=!0)}}if(!x)return;if(s.attributesGroupName&&!s.preserveOrder){var w={};return w[s.attributesGroupName]=l,w}return l}}var Ut=function(t){t=t.replace(/\r\n?/g,"\n");var e=new O("!xml"),i=e,r="";this.matcher.reset(),this.entityDecoder.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0,this.doctypefound=!1;for(var n=this.options,s=new q(n.processEntities),a=t.length,o=0;o<a;o++)if("<"===t[o]){var l=t.charCodeAt(o+1);if(47===l){var p=Wt(t,">",o,"Closing Tag is not closed."),h=t.substring(o+2,p).trim();if(n.removeNSPrefix){var c=h.indexOf(":");-1!==c&&(h=h.substr(c+1))}h=Jt(n.transformTagName,h,"",n).tagName,i&&(r=this.saveTextToParentTag(r,i,this.readonlyMatcher));var u=this.matcher.getCurrentTag();if(h&&n.unpairedTagsSet.has(h))throw new Error("Unpaired tag can not be used as closing tag: </"+h+">");u&&n.unpairedTagsSet.has(u)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,i=this.tagsNodeStack.pop(),r="",o=p}else if(63===l){var d=Yt(t,o,!1,"?>");if(!d)throw new Error("Pi Tag is not closed.");r=this.saveTextToParentTag(r,i,this.readonlyMatcher);var f=this.buildAttributesMap(d.tagExp,this.matcher,d.tagName,!0);if(f){var g=f[this.options.attributeNamePrefix+"version"];this.entityDecoder.setXmlVersion(Number(g)||1),s.setXmlVersion(Number(g)||1)}if(n.ignoreDeclaration&&"?xml"===d.tagName||n.ignorePiTags);else{var m=new O(d.tagName);m.add(n.textNodeName,""),d.tagName!==d.tagExp&&d.attrExpPresent&&!0!==n.ignoreAttributes&&(m[":@"]=f),this.addChild(i,m,this.readonlyMatcher,o)}o=d.closeIndex+1}else if(33===l&&45===t.charCodeAt(o+2)&&45===t.charCodeAt(o+3)){var x=Wt(t,"--\x3e",o+4,"Comment is not closed.");if(n.commentPropName){var b,v=t.substring(o+4,x-2);r=this.saveTextToParentTag(r,i,this.readonlyMatcher),i.add(n.commentPropName,[(b={},b[n.textNodeName]=v,b)])}o=x}else if(33===l&&68===t.charCodeAt(o+2)){if(this.doctypefound)throw new Error("Multiple DOCTYPE declarations found.");this.doctypefound=!0;var y=s.readDocType(t,o);this.entityDecoder.addInputEntities(y.entities),o=y.i}else if(33===l&&91===t.charCodeAt(o+2)){var N=Wt(t,"]]>",o,"CDATA is not closed.")-2,E=t.substring(o+9,N);r=this.saveTextToParentTag(r,i,this.readonlyMatcher);var w,S=this.parseTextData(E,i.tagname,this.readonlyMatcher,!0,!1,!0,!0);null==S&&(S=""),n.cdataPropName?i.add(n.cdataPropName,[(w={},w[n.textNodeName]=E,w)]):i.add(n.textNodeName,S),o=N+2}else{var A=Yt(t,o,n.removeNSPrefix);if(!A){var T=t.substring(Math.max(0,o-50),Math.min(a,o+50));throw new Error("readTagExp returned undefined at position "+o+'. Context: "'+T+'"')}var _=A.tagName,C=A.rawTagName,P=A.tagExp,$=A.attrExpPresent,j=A.closeIndex,I=Jt(n.transformTagName,_,P,n);if(_=I.tagName,P=I.tagExp,n.strictReservedNames&&(_===n.commentPropName||_===n.cdataPropName||_===n.textNodeName||_===n.attributesGroupName))throw new Error("Invalid tag name: "+_);i&&r&&"!xml"!==i.tagname&&(r=this.saveTextToParentTag(r,i,this.readonlyMatcher,!1));var k=i;k&&n.unpairedTagsSet.has(k.tagname)&&(i=this.tagsNodeStack.pop(),this.matcher.pop());var L=!1;P.length>0&&P.lastIndexOf("/")===P.length-1&&(L=!0,P="/"===_[_.length-1]?_=_.substr(0,_.length-1):P.substr(0,P.length-1),$=_!==P);var D,R=null;D=Lt(C),_!==e.tagname&&this.matcher.push(_,{},D),_!==P&&$&&(R=this.buildAttributesMap(P,this.matcher,_))&&kt(R,n),_!==e.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());var M=o;if(this.isCurrentNodeStopNode){var V="";if(L)o=A.closeIndex;else if(n.unpairedTagsSet.has(_))o=A.closeIndex;else{var U=this.readStopNodeData(t,C,j+1);if(!U)throw new Error("Unexpected end of "+C);o=U.i,V=U.tagContent}var F=new O(_);R&&(F[":@"]=R),F.add(n.textNodeName,V),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(i,F,this.readonlyMatcher,M)}else{if(L){var B=Jt(n.transformTagName,_,P,n);_=B.tagName,P=B.tagExp;var G=new O(_);R&&(G[":@"]=R),this.addChild(i,G,this.readonlyMatcher,M),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else{if(n.unpairedTagsSet.has(_)){var X=new O(_);R&&(X[":@"]=R),this.addChild(i,X,this.readonlyMatcher,M),this.matcher.pop(),this.isCurrentNodeStopNode=!1,o=A.closeIndex;continue}var W=new O(_);if(this.tagsNodeStack.length>n.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(i),R&&(W[":@"]=R),this.addChild(i,W,this.readonlyMatcher,M),i=W}r="",o=j}}}else r+=t[o];return e.child};function Ft(t,e,i,r){this.options.captureMetaData||(r=void 0);var n=this.options.jPath?i.toString():i,s=this.options.updateTag(e.tagname,n,e[":@"]);!1===s||("string"==typeof s?(e.tagname=s,t.addChild(e,r)):t.addChild(e,r))}function Bt(t,e,i){var r=this.options.processEntities;if(!r||!r.enabled)return t;if(r.allowedTags){var n=this.options.jPath?i.toString():i;if(!(Array.isArray(r.allowedTags)?r.allowedTags.includes(e):r.allowedTags(e,n)))return t}if(r.tagFilter){var s=this.options.jPath?i.toString():i;if(!r.tagFilter(e,s))return t}return this.entityDecoder.decode(t)}function Gt(t,e,i,r){return t&&(void 0===r&&(r=0===e.child.length),void 0!==(t=this.parseTextData(t,e.tagname,i,!1,!!e[":@"]&&0!==Object.keys(e[":@"]).length,r))&&""!==t&&e.add(this.options.textNodeName,t),t=""),t}function Xt(){return 0!==this.stopNodeExpressionsSet.size&&this.matcher.matchesAny(this.stopNodeExpressionsSet)}function Wt(t,e,i,r){var n=t.indexOf(e,i);if(-1===n)throw new Error(r);return n+e.length-1}function zt(t,e,i,r){var n=t.indexOf(e,i);if(-1===n)throw new Error(r);return n}function Yt(t,e,i,r){void 0===r&&(r=">");var n=function(t,e,i){void 0===i&&(i=">");for(var r=0,n=t.length,s=i.charCodeAt(0),a=i.length>1?i.charCodeAt(1):-1,o="",l=e,p=e;p<n;p++){var h=t.charCodeAt(p);if(r)h===r&&(r=0);else if(34===h||39===h)r=h;else if(h===s){if(-1===a)return{data:o+=t.substring(l,p),index:p};if(t.charCodeAt(p+1)===a)return{data:o+=t.substring(l,p),index:p}}else 9!==h||r||(o+=t.substring(l,p)+" ",l=p+1)}}(t,e+1,r);if(n){var s=n.data,a=n.index,o=s.search(/\s/),l=s,p=!0;-1!==o&&(l=s.substring(0,o),s=s.substring(o+1).trimStart());var h=l;if(i){var c=l.indexOf(":");-1!==c&&(p=(l=l.substr(c+1))!==n.data.substr(c+1))}return{tagName:l,tagExp:s,closeIndex:a,attrExpPresent:p,rawTagName:h}}}function Ht(t,e,i){for(var r=i,n=1,s=t.length;i<s;i++)if("<"===t[i]){var a=t.charCodeAt(i+1);if(47===a){var o=zt(t,">",i,e+" is not closed");if(t.substring(i+2,o).trim()===e&&0===--n)return{tagContent:t.substring(r,i),i:o};i=o}else if(63===a)i=Wt(t,"?>",i+1,"StopNode is not closed.");else if(33===a&&45===t.charCodeAt(i+2)&&45===t.charCodeAt(i+3))i=Wt(t,"--\x3e",i+3,"StopNode is not closed.");else if(33===a&&91===t.charCodeAt(i+2))i=Wt(t,"]]>",i,"StopNode is not closed.")-2;else{var l=Yt(t,i,!1);l&&((l&&l.tagName)===e&&"/"!==l.tagExp[l.tagExp.length-1]&&n++,i=l.closeIndex)}}}function Qt(t,e,i){if(e&&"string"==typeof t){var r=t.trim();return"true"===r||"false"!==r&&tt(t,i)}return void 0!==t?t:""}function Jt(t,e,i,r){if(t){var n=t(e);i===e&&(i=n),e=n}return{tagName:e=Zt(e,r),tagExp:i}}function Zt(t,e){if(o.includes(t))throw new Error('[SECURITY] Invalid name: "'+t+'" is a reserved JavaScript keyword that could cause prototype pollution');return a.includes(t)?e.onDangerousProperty(t):t}var Kt=O.getMetaDataSymbol();function te(t,e){if(!t||"object"!=typeof t)return{};if(!e)return t;var i={};for(var r in t)r.startsWith(e)?i[r.substring(e.length)]=t[r]:i[r]=t[r];return i}function ee(t,e,i,r){return ie(t,e,i,r)}function ie(t,e,i,r){for(var n,s={},a=0;a<t.length;a++){var o=t[a],l=re(o);if(void 0!==l&&l!==e.textNodeName){var p=te(o[":@"]||{},e.attributeNamePrefix);i.push(l,p)}if(l===e.textNodeName)void 0===n?n=o[l]:n+=""+o[l];else{if(void 0===l)continue;if(o[l]){var h=ie(o[l],e,i,r),c=se(h,e);if(0===Object.keys(h).length&&e.alwaysCreateTextNode&&(h[e.textNodeName]=""),o[":@"]?ne(h,o[":@"],r,e):1!==Object.keys(h).length||void 0===h[e.textNodeName]||e.alwaysCreateTextNode?0===Object.keys(h).length&&(e.alwaysCreateTextNode?h[e.textNodeName]="":h=""):h=h[e.textNodeName],void 0!==o[Kt]&&"object"==typeof h&&null!==h&&(h[Kt]=o[Kt]),void 0!==s[l]&&Object.prototype.hasOwnProperty.call(s,l))Array.isArray(s[l])||(s[l]=[s[l]]),s[l].push(h);else{var u=e.jPath?r.toString():r;e.isArray(l,u,c)?s[l]=[h]:s[l]=h}void 0!==l&&l!==e.textNodeName&&i.pop()}}}return"string"==typeof n?n.length>0&&(s[e.textNodeName]=n):void 0!==n&&(s[e.textNodeName]=n),s}function re(t){for(var e=Object.keys(t),i=0;i<e.length;i++){var r=e[i];if(":@"!==r)return r}}function ne(t,e,i,r){if(e)for(var n=Object.keys(e),s=n.length,a=0;a<s;a++){var o=n[a],l=o.startsWith(r.attributeNamePrefix)?o.substring(r.attributeNamePrefix.length):o,p=r.jPath?i.toString()+"."+l:i;r.isArray(o,p,!0,!0)?t[o]=[e[o]]:t[o]=e[o]}}function se(t,e){var i=e.textNodeName,r=Object.keys(t).length;return 0===r||!(1!==r||!t[i]&&"boolean"!=typeof t[i]&&0!==t[i])}var ae=function(){function t(t){this.externalEntities={},this.options=P(t)}var e=t.prototype;return e.parse=function(t,e){if("string"!=typeof t&&t.toString)t=t.toString();else if("string"!=typeof t)throw new Error("XML data is accepted in String or Bytes[] form.");if(e){!0===e&&(e={});var i=p(t,e);if(!0!==i)throw Error(i.err.msg+":"+i.err.line+":"+i.err.col)}var r=new Dt(this.options,this.externalEntities),n=r.parseXml(t);return this.options.preserveOrder||void 0===n?n:ee(n,this.options,r.matcher,r.readonlyMatcher)},e.addEntity=function(t,e){if(-1!==e.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==t.indexOf("&")||-1!==t.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if("&"===e)throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e},t.getMetaDataSymbol=function(){return O.getMetaDataSymbol()},t}();function oe(t){return String(t).replace(/--/g,"- -").replace(/--/g,"- -").replace(/-$/,"- ")}function le(t){return String(t).replace(/\]\]>/g,"]]]]><![CDATA[>")}function pe(t){return String(t).replace(/"/g,"&quot;").replace(/'/g,"&apos;")}const he=":A-Za-z_À-ÖØ-öø-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�",ce=":A-Za-z_À-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",ue=ce+"\\-\\.\\d·̀-ͯ҇‿-⁀",de=(t,e,i="")=>{const r=`[${t.replace(":","")}][${e.replace(":","")}]*`;return{name:new RegExp(`^[${t}][${e}]*$`,i),ncName:new RegExp(`^${r}$`,i),qName:new RegExp(`^${r}(?::${r})?$`,i),nmToken:new RegExp(`^[${e}]+$`,i),nmTokens:new RegExp(`^[${e}]+(?:\\s+[${e}]+)*$`,i)}},fe=de(he,he+"\\-\\.\\d·̀-ͯ‿-⁀"),ge=de(ce,ue,"u"),me=(t,{xmlVersion:e="1.0"}={})=>((t="1.0")=>"1.1"===t?ge:fe)(e).qName.test(t);function xe(t,e,i,r,n){return i.sanitizeName?me(t,{xmlVersion:n})?t:i.sanitizeName(t,{isAttribute:e,matcher:r.readOnly()}):t}function be(t,e){let i="";e.format&&(i="\n");const r=[];if(e.stopNodes&&Array.isArray(e.stopNodes))for(let t=0;t<e.stopNodes.length;t++){const i=e.stopNodes[t];"string"==typeof i?r.push(new at(i)):i instanceof at&&r.push(i)}const n=function(t,e){if(!Array.isArray(t)||0===t.length)return"1.0";const i=t[0];if("?xml"===we(i)){const t=i[":@"];if(t){const i=e.attributeNamePrefix+"version";if(t[i])return t[i]}}return"1.0"}(t,e);return ve(t,e,i,new st,r,n)}function ve(t,e,i,r,n,s){let a="",o=!1;if(e.maxNestedTags&&r.getDepth()>e.maxNestedTags)throw new Error("Maximum nested tags exceeded");if(!Array.isArray(t)){if(null!=t){let i=t.toString();return i=Te(i,e),i}return""}for(let l=0;l<t.length;l++){const p=t[l],h=we(p);if(void 0===h)continue;const c=h===e.textNodeName||h===e.cdataPropName||h===e.commentPropName||"?"===h[0]?h:xe(h,!1,e,r,s),u=ye(p[":@"],e);r.push(c,u);const d=Ae(r,n);if(c===e.textNodeName){let t=p[h];d||(t=e.tagValueProcessor(c,t),t=Te(t,e)),o&&(a+=i),a+=t,o=!1,r.pop();continue}if(c===e.cdataPropName){o&&(a+=i),a+=`<![CDATA[${le(p[h][0][e.textNodeName])}]]>`,o=!1,r.pop();continue}if(c===e.commentPropName){a+=i+`\x3c!--${oe(p[h][0][e.textNodeName])}--\x3e`,o=!0,r.pop();continue}if("?"===c[0]){a+=("?xml"===c?"":i)+`<${c}${Se(p[":@"],e,d,r,s)}?>`,o=!0,r.pop();continue}let f=i;""!==f&&(f+=e.indentBy);const g=i+`<${c}${Se(p[":@"],e,d,r,s)}`;let m;m=d?Ne(p[h],e):ve(p[h],e,f,r,n,s),-1!==e.unpairedTags.indexOf(c)?e.suppressUnpairedNode?a+=g+">":a+=g+"/>":m&&0!==m.length||!e.suppressEmptyNode?m&&m.endsWith(">")?a+=g+`>${m}${i}</${c}>`:(a+=g+">",m&&""!==i&&(m.includes("/>")||m.includes("</"))?a+=i+e.indentBy+m+i:a+=m,a+=`</${c}>`):a+=g+"/>",o=!0,r.pop()}return a}function ye(t,e){if(!t||e.ignoreAttributes)return null;const i={};let r=!1;for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n.startsWith(e.attributeNamePrefix)?n.substr(e.attributeNamePrefix.length):n]=pe(t[n]),r=!0);return r?i:null}function Ne(t,e){if(!Array.isArray(t))return null!=t?t.toString():"";let i="";for(let r=0;r<t.length;r++){const n=t[r],s=we(n);if(s===e.textNodeName)i+=n[s];else if(s===e.cdataPropName)i+=n[s][0][e.textNodeName];else if(s===e.commentPropName)i+=n[s][0][e.textNodeName];else{if(s&&"?"===s[0])continue;if(s){const t=Ee(n[":@"],e),r=Ne(n[s],e);r&&0!==r.length?i+=`<${s}${t}>${r}</${s}>`:i+=`<${s}${t}/>`}}}return i}function Ee(t,e){let i="";if(t&&!e.ignoreAttributes)for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;let n=t[r];!0===n&&e.suppressBooleanAttributes?i+=` ${r.substr(e.attributeNamePrefix.length)}`:i+=` ${r.substr(e.attributeNamePrefix.length)}="${pe(n)}"`}return i}function we(t){const e=Object.keys(t);for(let i=0;i<e.length;i++){const r=e[i];if(Object.prototype.hasOwnProperty.call(t,r)&&":@"!==r)return r}}function Se(t,e,i,r,n){let s="";if(t&&!e.ignoreAttributes)for(let a in t){if(!Object.prototype.hasOwnProperty.call(t,a))continue;const o=a.substr(e.attributeNamePrefix.length),l=i?o:xe(o,!0,e,r,n);let p;i?p=t[a]:(p=e.attributeValueProcessor(a,t[a]),p=Te(p,e)),!0===p&&e.suppressBooleanAttributes?s+=` ${l}`:s+=` ${l}="${pe(p)}"`}return s}function Ae(t,e){if(!e||0===e.length)return!1;for(let i=0;i<e.length;i++)if(t.matches(e[i]))return!0;return!1}function Te(t,e){if(t&&t.length>0&&e.processEntities)for(let i=0;i<e.entities.length;i++){const r=e.entities[i];t=t.replace(r.regex,r.val)}return t}const _e={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1,maxNestedTags:100,jPath:!0,sanitizeName:!1};function Ce(t){if(this.options=Object.assign({},_e,t),this.options.stopNodes&&Array.isArray(this.options.stopNodes)&&(this.options.stopNodes=this.options.stopNodes.map(t=>"string"==typeof t&&t.startsWith("*.")?".."+t.substring(2):t)),this.stopNodeExpressions=[],this.options.stopNodes&&Array.isArray(this.options.stopNodes))for(let t=0;t<this.options.stopNodes.length;t++){const e=this.options.stopNodes[t];"string"==typeof e?this.stopNodeExpressions.push(new at(e)):e instanceof at&&this.stopNodeExpressions.push(e)}var e;!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn="function"==typeof(e=this.options.ignoreAttributes)?e:Array.isArray(e)?t=>{for(const i of e){if("string"==typeof i&&t===i)return!0;if(i instanceof RegExp&&i.test(t))return!0}}:()=>!1,this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=je),this.processTextOrObjNode=Oe,this.options.format?(this.indentate=$e,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function Pe(t,e,i,r,n){return i.sanitizeName?me(t,{xmlVersion:n})?t:i.sanitizeName(t,{isAttribute:e,matcher:r.readOnly()}):t}function Oe(t,e,i,r,n){const s=this.extractAttributes(t);if(r.push(e,s),this.checkStopNode(r)){const n=this.buildRawContent(t),s=this.buildAttributesForStopNode(t);return r.pop(),this.buildObjectNode(n,e,s,i)}const a=this.j2x(t,i+1,r,n);return r.pop(),"?"===e[0]?this.buildTextValNode("",e,a.attrStr,i,r):void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,a.attrStr,i,r):this.buildObjectNode(a.val,e,a.attrStr,i)}function $e(t){return this.options.indentBy.repeat(t)}function je(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}Ce.prototype.build=function(t){if(this.options.preserveOrder)return be(t,this.options);{Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t});const e=new st,i=function(t,e){const i=t["?xml"];if(i&&"object"==typeof i){if(e.attributesGroupName&&i[e.attributesGroupName]){const t=i[e.attributesGroupName][e.attributeNamePrefix+"version"];if(t)return t}const t=i[e.attributeNamePrefix+"version"];if(t)return t}return"1.0"}(t,this.options);return this.j2x(t,0,e,i).val}},Ce.prototype.j2x=function(t,e,i,r){let n="",s="";if(this.options.maxNestedTags&&i.getDepth()>=this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");const a=this.options.jPath?i.toString():i,o=this.checkStopNode(i);for(let l in t){if(!Object.prototype.hasOwnProperty.call(t,l))continue;const p=l===this.options.textNodeName||l===this.options.cdataPropName||l===this.options.commentPropName||this.options.attributesGroupName&&l===this.options.attributesGroupName||this.isAttribute(l)||"?"===l[0]?l:Pe(l,!1,this.options,i,r);if(void 0===t[l])this.isAttribute(l)&&(s+="");else if(null===t[l])this.isAttribute(l)||p===this.options.cdataPropName||p===this.options.commentPropName?s+="":"?"===p[0]?s+=this.indentate(e)+"<"+p+"?"+this.tagEndChar:s+=this.indentate(e)+"<"+p+"/"+this.tagEndChar;else if(t[l]instanceof Date)s+=this.buildTextValNode(t[l],p,"",e,i);else if("object"!=typeof t[l]){const h=this.isAttribute(l);if(h&&!this.ignoreAttributesFn(h,a)){const e=Pe(h,!0,this.options,i,r);n+=this.buildAttrPairStr(e,""+t[l],o)}else if(!h)if(l===this.options.textNodeName){let e=this.options.tagValueProcessor(l,""+t[l]);s+=this.replaceEntitiesValue(e)}else{i.push(p);const r=this.checkStopNode(i);if(i.pop(),r){const i=""+t[l];s+=""===i?this.indentate(e)+"<"+p+this.closeTag(p)+this.tagEndChar:this.indentate(e)+"<"+p+">"+i+"</"+p+this.tagEndChar}else s+=this.buildTextValNode(t[l],p,"",e,i)}}else if(Array.isArray(t[l])){const n=t[l].length;let a="",o="";for(let h=0;h<n;h++){const n=t[l][h];if(void 0===n);else if(null===n)"?"===p[0]?s+=this.indentate(e)+"<"+p+"?"+this.tagEndChar:s+=this.indentate(e)+"<"+p+"/"+this.tagEndChar;else if("object"==typeof n)if(this.options.oneListGroup){i.push(p);const t=this.j2x(n,e+1,i,r);i.pop(),a+=t.val,this.options.attributesGroupName&&n.hasOwnProperty(this.options.attributesGroupName)&&(o+=t.attrStr)}else a+=this.processTextOrObjNode(n,p,e,i,r);else if(this.options.oneListGroup){let t=this.options.tagValueProcessor(p,n);t=this.replaceEntitiesValue(t),a+=t}else{i.push(p);const t=this.checkStopNode(i);if(i.pop(),t){const t=""+n;a+=""===t?this.indentate(e)+"<"+p+this.closeTag(p)+this.tagEndChar:this.indentate(e)+"<"+p+">"+t+"</"+p+this.tagEndChar}else a+=this.buildTextValNode(n,p,"",e,i)}}this.options.oneListGroup&&(a=this.buildObjectNode(a,p,o,e)),s+=a}else if(this.options.attributesGroupName&&l===this.options.attributesGroupName){const e=Object.keys(t[l]),s=e.length;for(let a=0;a<s;a++){const s=Pe(e[a],!0,this.options,i,r);n+=this.buildAttrPairStr(s,""+t[l][e[a]],o)}}else s+=this.processTextOrObjNode(t[l],p,e,i,r)}return{attrStr:n,val:s}},Ce.prototype.buildAttrPairStr=function(t,e,i){return i||(e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e)),this.options.suppressBooleanAttributes&&"true"===e?" "+t:" "+t+'="'+pe(e)+'"'},Ce.prototype.extractAttributes=function(t){if(!t||"object"!=typeof t)return null;const e={};let i=!1;if(this.options.attributesGroupName&&t[this.options.attributesGroupName]){const r=t[this.options.attributesGroupName];for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t.startsWith(this.options.attributeNamePrefix)?t.substring(this.options.attributeNamePrefix.length):t]=pe(r[t]),i=!0)}else for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;const n=this.isAttribute(r);n&&(e[n]=pe(t[r]),i=!0)}return i?e:null},Ce.prototype.buildRawContent=function(t){if("string"==typeof t)return t;if("object"!=typeof t||null===t)return String(t);if(void 0!==t[this.options.textNodeName])return t[this.options.textNodeName];let e="";for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;if(this.isAttribute(i))continue;if(this.options.attributesGroupName&&i===this.options.attributesGroupName)continue;const r=t[i];if(i===this.options.textNodeName)e+=r;else if(Array.isArray(r)){for(let t of r)if("string"==typeof t||"number"==typeof t)e+=`<${i}>${t}</${i}>`;else if("object"==typeof t&&null!==t){const r=this.buildRawContent(t),n=this.buildAttributesForStopNode(t);e+=""===r?`<${i}${n}/>`:`<${i}${n}>${r}</${i}>`}}else if("object"==typeof r&&null!==r){const t=this.buildRawContent(r),n=this.buildAttributesForStopNode(r);e+=""===t?`<${i}${n}/>`:`<${i}${n}>${t}</${i}>`}else e+=`<${i}>${r}</${i}>`}return e},Ce.prototype.buildAttributesForStopNode=function(t){if(!t||"object"!=typeof t)return"";let e="";if(this.options.attributesGroupName&&t[this.options.attributesGroupName]){const i=t[this.options.attributesGroupName];for(let t in i){if(!Object.prototype.hasOwnProperty.call(i,t))continue;const r=t.startsWith(this.options.attributeNamePrefix)?t.substring(this.options.attributeNamePrefix.length):t,n=i[t];!0===n&&this.options.suppressBooleanAttributes?e+=" "+r:e+=" "+r+'="'+n+'"'}}else for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;const r=this.isAttribute(i);if(r){const n=t[i];!0===n&&this.options.suppressBooleanAttributes?e+=" "+r:e+=" "+r+'="'+n+'"'}}return e},Ce.prototype.buildObjectNode=function(t,e,i,r){if(""===t)return"?"===e[0]?this.indentate(r)+"<"+e+i+"?"+this.tagEndChar:this.indentate(r)+"<"+e+i+this.closeTag(e)+this.tagEndChar;if("?"===e[0])return this.indentate(r)+"<"+e+i+"?"+this.tagEndChar;{let n="</"+e+this.tagEndChar,s="";return"?"===e[0]&&(s="?",n=""),!i&&""!==i||-1!==t.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===s.length?this.indentate(r)+`\x3c!--${t}--\x3e`+this.newLine:this.indentate(r)+"<"+e+i+s+this.tagEndChar+t+this.indentate(r)+n:this.indentate(r)+"<"+e+i+s+">"+t+n}},Ce.prototype.closeTag=function(t){let e="";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":`></${t}`,e},Ce.prototype.checkStopNode=function(t){if(!this.stopNodeExpressions||0===this.stopNodeExpressions.length)return!1;for(let e=0;e<this.stopNodeExpressions.length;e++)if(t.matches(this.stopNodeExpressions[e]))return!0;return!1},Ce.prototype.buildTextValNode=function(t,e,i,r,n){if(!1!==this.options.cdataPropName&&e===this.options.cdataPropName){const e=le(t);return this.indentate(r)+`<![CDATA[${e}]]>`+this.newLine}if(!1!==this.options.commentPropName&&e===this.options.commentPropName){const e=oe(t);return this.indentate(r)+`\x3c!--${e}--\x3e`+this.newLine}if("?"===e[0])return this.indentate(r)+"<"+e+i+"?"+this.tagEndChar;{let n=this.options.tagValueProcessor(e,t);return n=this.replaceEntitiesValue(n),""===n?this.indentate(r)+"<"+e+i+this.closeTag(e)+this.tagEndChar:this.indentate(r)+"<"+e+i+">"+n+"</"+e+this.tagEndChar}},Ce.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const i=this.options.entities[e];t=t.replace(i.regex,i.val)}return t};const Ie=Ce;var ke={validate:p};return e})());
2
2
  //# sourceMappingURL=fxp.min.js.map