!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"!==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++;s0)||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;e5&&"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[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[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[e+2]){e+=2;break}return e}var f='"',c="'";function g(t,e){for(var r="",n="",i=!1;e"===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;s0?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[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);ethis.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);et.length)&&(e=t.length);for(var r=0,n=Array(e);r0&&(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=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?{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);r0){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;n0)){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",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: ");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",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;a0&&(s[e.textNodeName]=i):void 0!==i&&(s[e.textNodeName]=i),s}function xt(t){for(var e=Object.keys(t),r=0;r0&&(r="\n");const n=[];if(e.stopNodes&&Array.isArray(e.stopNodes))for(let t=0;te.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`,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}`:(s+=f+">",c&&""!==r&&(c.includes("/>")||c.includes("`):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${n}`: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;r0&&e.processEntities)for(let r=0;r","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],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{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+""+t+"${t}`;else if("object"==typeof t&&null!==t){const n=this.buildRawContent(t),i=this.buildAttributesForStopNode(t);e+=""===n?`<${r}${i}/>`:`<${r}${i}>${n}`}}else if("object"==typeof n&&null!==n){const t=this.buildRawContent(n),i=this.buildAttributesForStopNode(n);e+=""===t?`<${r}${i}/>`:`<${r}${i}>${t}`}else e+=`<${r}>${n}`}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=""+t+i}},It.prototype.closeTag=function(t){let e="";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":`>`+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+"0&&this.options.processEntities)for(let e=0;e