!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:()=>It,XMLParser:()=>gt,XMLValidator:()=>jt});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,o=0;o"!==t[s]&&" "!==t[s]&&"\t"!==t[s]&&"\n"!==t[s]&&"\r"!==t[s];s++)u+=t[s];if("/"===(u=u.trim())[u.length-1]&&(u=u.substring(0,u.length-1),s--),!E(u))return N("InvalidTag",0===u.trim().length?"Invalid space after '<'.":"Tag '"+u+"' is an invalid name.",y(t,s));var f=g(t,s);if(!1===f)return N("InvalidAttr","Attributes for '"+u+"' have open quote.",y(t,s));var c=f.value;if(s=f.index,"/"===c[c.length-1]){var m=s-c.length,b=v(c=c.substring(0,c.length-1),e);if(!0!==b)return N(b.err.code,b.err.msg,y(t,m+b.err.line));r=!0}else if(a){if(!f.tagClosed)return N("InvalidTag","Closing tag '"+u+"' doesn't have proper closing.",y(t,s));if(c.trim().length>0)return N("InvalidTag","Closing tag '"+u+"' can't have attributes or invalid starting.",y(t,o));if(0===i.length)return N("InvalidTag","Closing tag '"+u+"' has not been opened.",y(t,o));var w=i.pop();if(u!==w.tagName){var S=y(t,w.tagStartPos);return N("InvalidTag","Expected closing tag '"+w.tagName+"' (opened in line "+S.line+", col "+S.col+") instead of closing tag '"+u+"'.",y(t,o))}0==i.length&&(n=!0)}else{var P=v(c,e);if(!0!==P)return N(P.err.code,P.err.msg,y(t,s-c.length+P.err.line));if(!0===n)return N("InvalidXml","Multiple possible root nodes found.",y(t,s));-1!==e.unpairedTags.indexOf(u)||i.push({tagName:u,tagStartPos:o}),r=!0}for(s++;s0)||N("InvalidXml","Invalid '"+JSON.stringify(i.map(function(t){return t.tagName}),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):N("InvalidXml","Start tag expected.",1)}function l(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function p(t,e){for(var i=e;e5&&"xml"===r)return N("InvalidXml","XML declaration allowed only at the start of the document.",y(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 i=1;for(e+=8;e"===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[e+2]){e+=2;break}return e}var f='"',c="'";function g(t,e){for(var i="",r="",n=!1;e"===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 v(t,e){for(var i=n(t,m),r={},s=0;s0?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][O]={startIndex:e})},t.getMetaDataSymbol=function(){return O},t}(),j=function(){function t(t){this.suppressValidationErr=!t,this.options=t}var e=t.prototype;return 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,o=!1;e"===t[e]){if(o?"-"===t[e-1]&&"-"===t[e-2]&&(o=!1,n--):n--,0===n)break}else"["===t[e]?s=!0:t[e];else{if(s&&$(t,"!ENTITY",e)){e+=7;var a=void 0,h=void 0,u=this.readEntityExp(t,e+1,this.suppressValidationErr);if(a=u[0],h=u[1],e=u[2],-1===h.indexOf("&")){if(!1!==this.options.enabled&&this.options.maxEntityCount&&r>=this.options.maxEntityCount)throw new Error("Entity count ("+(r+1)+") exceeds maximum allowed ("+this.options.maxEntityCount+")");var l=a.replace(/[.\-+*:]/g,"\\.");i[a]={regx:RegExp("&"+l+";","g"),val:h},r++}}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");o=!0}n++}if(0!==n)throw new Error("Unclosed DOCTYPE");return{entities:i,i:e}},e.readEntityExp=function(t,e){e=_(t,e);for(var i="";ethis.options.maxEntitySize)throw new Error('Entity "'+i+'" size ('+r.length+") exceeds maximum allowed size ("+this.options.maxEntitySize+")");return[i,r,--e]},e.readNotationExp=function(t,e){e=_(t,e);for(var i="";et.length)&&(e=t.length);for(var i=0,r=Array(e);i0&&(this.path[this.path.length-1].values=void 0);const r=this.path.length;this.siblingStacks[r]||(this.siblingStacks[r]=new Map);const n=this.siblingStacks[r],s=i?`${i}:${t}`:t,o=n.get(s)||0;let a=0;for(const t of n.values())a+=t;n.set(s,o+1);const h={tag:t,position:a,counter:o};null!=i&&(h.namespace=i),null!=e&&(h.values=e),this.path.push(h)}pop(){if(0===this.path.length)return;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)}}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 i=t||this.separator;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.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 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--){const s=t===this.path.length-1;if(this._matchSegment(r,this.path[t],s)){e=t-1,i--,n=!0;break}}if(!n)return!1}else{const t=e===this.path.length-1;if(!this._matchSegment(r,this.path[e],t))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){const i=e.values[t.attrName];if(String(i)!==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}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>new Map(t))}}restore(t){this.path=t.path.map(t=>({...t})),this.siblingStacks=t.siblingStacks.map(t=>new Map(t))}}class R{constructor(t,e={}){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),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(;i0){var i=t.substring(0,e);if("xmlns"!==i)return i}}}var W=function(t){var e;if(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 st(e,10,"&#")}},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:function(t,e){return st(e,16,"&#x")}}},this.addExternalEntities=Y,this.parseXml=J,this.parseTextData=X,this.resolveNameSpace=z,this.buildAttributesMap=Z,this.isItStopNode=tt,this.replaceEntitiesValue=Q,this.readStopNodeData=rt,this.saveTextToParentTag=H,this.addChild=K,this.ignoreAttributesFn="function"==typeof(e=this.options.ignoreAttributes)?e:Array.isArray(e)?function(t){for(var i,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 M(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)?M(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.")}(e);!(i=r()).done;){var n=i.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.matcher=new G,this.isCurrentNodeStopNode=!1,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodeExpressions=[];for(var i=0;i0)){o||(t=this.replaceEntitiesValue(t,e,i));var a=this.options.jPath?i.toString():i,h=this.options.tagValueProcessor(e,t,a,n,s);return null==h?t:typeof h!=typeof t||h!==t?h:this.options.trimValues||t.trim()===t?nt(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function z(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 q=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function Z(t,e,i){if(!0!==this.options.ignoreAttributes&&"string"==typeof t){for(var r=n(t,q),s=r.length,o={},a={},h=0;h0&&"object"==typeof e&&e.updateCurrent&&e.updateCurrent(a);for(var d=0;d",s,"Closing Tag is not closed."),a=t.substring(s+2,o).trim();if(this.options.removeNSPrefix){var h=a.indexOf(":");-1!==h&&(a=a.substr(h+1))}a=ot(this.options.transformTagName,a,"",this.options).tagName,i&&(r=this.saveTextToParentTag(r,i,this.matcher));var u=this.matcher.getCurrentTag();if(a&&-1!==this.options.unpairedTags.indexOf(a))throw new Error("Unpaired tag can not be used as closing tag: ");u&&-1!==this.options.unpairedTags.indexOf(u)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,i=this.tagsNodeStack.pop(),r="",s=o}else if("?"===t[s+1]){var l=it(t,s,!1,"?>");if(!l)throw new Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,i,this.matcher),this.options.ignoreDeclaration&&"?xml"===l.tagName||this.options.ignorePiTags);else{var p=new I(l.tagName);p.add(this.options.textNodeName,""),l.tagName!==l.tagExp&&l.attrExpPresent&&(p[":@"]=this.buildAttributesMap(l.tagExp,this.matcher,l.tagName)),this.addChild(i,p,this.matcher,s)}s=l.closeIndex+1}else if("!--"===t.substr(s+1,3)){var d=et(t,"--\x3e",s+4,"Comment is not closed.");if(this.options.commentPropName){var f,c=t.substring(s+4,d-2);r=this.saveTextToParentTag(r,i,this.matcher),i.add(this.options.commentPropName,[(f={},f[this.options.textNodeName]=c,f)])}s=d}else if("!D"===t.substr(s+1,2)){var g=n.readDocType(t,s);this.docTypeEntities=g.entities,s=g.i}else if("!["===t.substr(s+1,2)){var m=et(t,"]]>",s,"CDATA is not closed.")-2,v=t.substring(s+9,m);r=this.saveTextToParentTag(r,i,this.matcher);var x,N=this.parseTextData(v,i.tagname,this.matcher,!0,!1,!0,!0);null==N&&(N=""),this.options.cdataPropName?i.add(this.options.cdataPropName,[(x={},x[this.options.textNodeName]=v,x)]):i.add(this.options.textNodeName,N),s=m+2}else{var b=it(t,s,this.options.removeNSPrefix);if(!b){var E=t.substring(Math.max(0,s-50),Math.min(t.length,s+50));throw new Error("readTagExp returned undefined at position "+s+'. Context: "'+E+'"')}var y=b.tagName,w=b.rawTagName,S=b.tagExp,P=b.attrExpPresent,T=b.closeIndex,A=ot(this.options.transformTagName,y,S,this.options);if(y=A.tagName,S=A.tagExp,this.options.strictReservedNames&&(y===this.options.commentPropName||y===this.options.cdataPropName))throw new Error("Invalid tag name: "+y);i&&r&&"!xml"!==i.tagname&&(r=this.saveTextToParentTag(r,i,this.matcher,!1));var O=i;O&&-1!==this.options.unpairedTags.indexOf(O.tagname)&&(i=this.tagsNodeStack.pop(),this.matcher.pop());var C=!1;S.length>0&&S.lastIndexOf("/")===S.length-1&&(C=!0,S="/"===y[y.length-1]?y=y.substr(0,y.length-1):S.substr(0,S.length-1),P=y!==S);var _,$=null;_=B(w),y!==e.tagname&&this.matcher.push(y,{},_),y!==S&&P&&($=this.buildAttributesMap(S,this.matcher,y))&&U($,this.options),y!==e.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode(this.stopNodeExpressions,this.matcher));var V=s;if(this.isCurrentNodeStopNode){var D="";if(C)s=b.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(y))s=b.closeIndex;else{var k=this.readStopNodeData(t,w,T+1);if(!k)throw new Error("Unexpected end of "+w);s=k.i,D=k.tagContent}var F=new I(y);$&&(F[":@"]=$),F.add(this.options.textNodeName,D),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(i,F,this.matcher,V)}else{if(C){var L=ot(this.options.transformTagName,y,S,this.options);y=L.tagName,S=L.tagExp;var M=new I(y);$&&(M[":@"]=$),this.addChild(i,M,this.matcher,V),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else{if(-1!==this.options.unpairedTags.indexOf(y)){var G=new I(y);$&&(G[":@"]=$),this.addChild(i,G,this.matcher,V),this.matcher.pop(),this.isCurrentNodeStopNode=!1,s=b.closeIndex;continue}var R=new I(y);if(this.tagsNodeStack.length>this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(i),$&&(R[":@"]=$),this.addChild(i,R,this.matcher,V),i=R}r="",s=T}}else r+=t[s];return e.child};function K(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 Q(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}for(var o in this.docTypeEntities){var a=this.docTypeEntities[o],h=t.match(a.regx);if(h){if(this.entityExpansionCount+=h.length,r.maxTotalExpansions&&this.entityExpansionCount>r.maxTotalExpansions)throw new Error("Entity expansion limit exceeded: "+this.entityExpansionCount+" > "+r.maxTotalExpansions);var u=t.length;if(t=t.replace(a.regx,a.val),r.maxExpandedLength&&(this.currentExpandedLength+=t.length-u,this.currentExpandedLength>r.maxExpandedLength))throw new Error("Total expanded content size exceeded: "+this.currentExpandedLength+" > "+r.maxExpandedLength)}}if(-1===t.indexOf("&"))return t;for(var l in this.lastEntities){var p=this.lastEntities[l];t=t.replace(p.regex,p.val)}if(-1===t.indexOf("&"))return t;if(this.options.htmlEntities)for(var d in this.htmlEntities){var f=this.htmlEntities[d];t=t.replace(f.regex,f.val)}return t.replace(this.ampEntity.regex,this.ampEntity.val)}function H(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 tt(t,e){if(!t||0===t.length)return!1;for(var i=0;i");var n=function(t,e,i){var r;void 0===i&&(i=">");for(var n="",s=e;s",i,e+" is not closed");if(t.substring(i+2,s).trim()===e&&0===--n)return{tagContent:t.substring(r,i),i:s};i=s}else if("?"===t[i+1])i=et(t,"?>",i+1,"StopNode is not closed.");else if("!--"===t.substr(i+1,3))i=et(t,"--\x3e",i+3,"StopNode is not closed.");else if("!["===t.substr(i+1,2))i=et(t,"]]>",i,"StopNode is not closed.")-2;else{var o=it(t,i,">");o&&((o&&o.tagName)===e&&"/"!==o.tagExp[o.tagExp.length-1]&&n++,i=o.closeIndex)}}function nt(t,e,i){if(e&&"string"==typeof t){var r=t.trim();return"true"===r||"false"!==r&&function(t,e={}){if(e=Object.assign({},F,e),!t||"string"!=typeof t)return t;let i=t.trim();if(void 0!==e.skipLike&&e.skipLike.test(i))return t;if("0"===t)return 0;if(e.hex&&D.test(i))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")}(i);if(i.includes("e")||i.includes("E"))return function(t,e,i){if(!i.eNotation)return t;const r=e.match(L);if(r){let n=r[1]||"";const s=-1===r[3].indexOf("e")?"E":"e",o=r[2],a=n?t[o.length+1]===s:t[o.length]===s;return o.length>1&&a?t:1!==o.length||!r[3].startsWith(`.${s}`)&&r[3][0]!==s?i.leadingZeros&&!a?(e=(r[1]||"")+r[3],Number(e)):t:Number(e)}return t}(t,i,e);{const n=k.exec(i);if(n){const s=n[1]||"",o=n[2];let a=(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 h=s?"."===t[o.length+1]:"."===t[o.length];if(!e.leadingZeros&&(o.length>1||1===o.length&&!h))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===a||n===`${s}${a}`?r:t;let h=o?a:i;return o?h===n||s+h===n?r:t:h===n||h===s+n?r:t}}return t}var r}(t,i)}return void 0!==t?t:""}function st(t,e,i){var r=Number.parseInt(t,e);return r>=0&&r<=1114111?String.fromCodePoint(r):i+t+";"}function ot(t,e,i,r){if(t){var n=t(e);i===e&&(i=n),e=n}return{tagName:e=at(e,r),tagExp:i}}function at(t,e){if(a.includes(t))throw new Error('[SECURITY] Invalid name: "'+t+'" is a reserved JavaScript keyword that could cause prototype pollution');return o.includes(t)?e.onDangerousProperty(t):t}var ht=I.getMetaDataSymbol();function ut(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 lt(t,e,i){return pt(t,e,i)}function pt(t,e,i){for(var r,n={},s=0;s0&&(n[e.textNodeName]=r):void 0!==r&&(n[e.textNodeName]=r),n}function dt(t){for(var e=Object.keys(t),i=0;i0&&(i="\n");const r=[];if(e.stopNodes&&Array.isArray(e.stopNodes))for(let t=0;t`,o=!1,r.pop();continue}if(u===e.commentPropName){s+=i+`\x3c!--${h[u][0][e.textNodeName]}--\x3e`,o=!0,r.pop();continue}if("?"===u[0]){const t=yt(h[":@"],e,p),n="?xml"===u?"":i;let a=h[u][0][e.textNodeName];a=0!==a.length?" "+a:"",s+=n+`<${u}${a}${t}?>`,o=!0,r.pop();continue}let d=i;""!==d&&(d+=e.indentBy);const f=i+`<${u}${yt(h[":@"],e,p)}`;let c;c=p?Nt(h[u],e):vt(h[u],e,d,r,n),-1!==e.unpairedTags.indexOf(u)?e.suppressUnpairedNode?s+=f+">":s+=f+"/>":c&&0!==c.length||!e.suppressEmptyNode?c&&c.endsWith(">")?s+=f+`>${c}${i}`:(s+=f+">",c&&""!==i&&(c.includes("/>")||c.includes("`):s+=f+"/>",o=!0,r.pop()}return s}function xt(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]=t[n],r=!0);return r?i:null}function Nt(t,e){if(!Array.isArray(t))return null!=t?t.toString():"";let i="";for(let r=0;r${r}`:i+=`<${s}${t}/>`}}}return i}function bt(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)}="${n}"`}return i}function Et(t){const e=Object.keys(t);for(let i=0;i0&&e.processEntities)for(let i=0;i","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1,jPath:!0};function Tt(t){if(this.options=Object.assign({},Pt,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 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=Ct),this.processTextOrObjNode=At,this.options.format?(this.indentate=Ot,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function At(t,e,i,r){const n=this.extractAttributes(t);if(r.push(e,n),this.checkStopNode(r)){const n=this.buildRawContent(t),s=this.buildAttributesForStopNode(t);return r.pop(),this.buildObjectNode(n,e,s,i)}const s=this.j2x(t,i+1,r);return r.pop(),void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,s.attrStr,i,r):this.buildObjectNode(s.val,e,s.attrStr,i)}function Ot(t){return this.options.indentBy.repeat(t)}function Ct(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}Tt.prototype.build=function(t){if(this.options.preserveOrder)return mt(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}},Tt.prototype.j2x=function(t,e,i){let r="",n="";const s=this.options.jPath?i.toString():i,o=this.checkStopNode(i);for(let a in t)if(Object.prototype.hasOwnProperty.call(t,a))if(void 0===t[a])this.isAttribute(a)&&(n+="");else if(null===t[a])this.isAttribute(a)||a===this.options.cdataPropName?n+="":"?"===a[0]?n+=this.indentate(e)+"<"+a+"?"+this.tagEndChar:n+=this.indentate(e)+"<"+a+"/"+this.tagEndChar;else if(t[a]instanceof Date)n+=this.buildTextValNode(t[a],a,"",e,i);else if("object"!=typeof t[a]){const h=this.isAttribute(a);if(h&&!this.ignoreAttributesFn(h,s))r+=this.buildAttrPairStr(h,""+t[a],o);else if(!h)if(a===this.options.textNodeName){let e=this.options.tagValueProcessor(a,""+t[a]);n+=this.replaceEntitiesValue(e)}else{i.push(a);const r=this.checkStopNode(i);if(i.pop(),r){const i=""+t[a];n+=""===i?this.indentate(e)+"<"+a+this.closeTag(a)+this.tagEndChar:this.indentate(e)+"<"+a+">"+i+""+t+"${t}`;else if("object"==typeof t&&null!==t){const r=this.buildRawContent(t),n=this.buildAttributesForStopNode(t);e+=""===r?`<${i}${n}/>`:`<${i}${n}>${r}`}}else if("object"==typeof r&&null!==r){const t=this.buildRawContent(r),n=this.buildAttributesForStopNode(r);e+=""===t?`<${i}${n}/>`:`<${i}${n}>${t}`}else e+=`<${i}>${r}`}return e},Tt.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},Tt.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;{let n=""+t+n}},Tt.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(r)+`\x3c!--${t}--\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+"0&&this.options.processEntities)for(let e=0;e