!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.fxb=e():t.fxb=e()}(this,()=>(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},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,{default:()=>$});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,i="";for(;r0?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 r=e[e.length-1];return void 0!==r.values&&t in r.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 s{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new i(this),this._keptAttrs=[]}push(t,e=null,r=null,i=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const s=this.path.length;let n=this.siblingStacks[s];n||(n={counts:new Map,total:0},this.siblingStacks[s]=n);const a=r?`${r}:${t}`:t,o=n.counts.get(a)||0,h=n.total;n.counts.set(a,o+1),n.total++;const p={tag:t,position:h,counter:o};null!=r&&(p.namespace=r),null!=e&&(p.values=e),this.path.push(p);const u=this.path.length,l=null!==i?i.keep:null;if(null!=l&&l.length>0&&e)for(let t=0;tthis.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 r=e.length-1;r>=0;r--)if(e[r].name===t)return e[r].value}hasAnyParentAttr(t){const e=this._keptAttrs;for(let r=e.length-1;r>=0;r--)if(e[r].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 r=t||this.separator;if(r===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(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.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=0&&e>=0;){const i=t[r];if("deep-wildcard"===i.type){if(r--,r<0)return!0;const i=t[r];let s=!1;for(let t=e;t>=0;t--)if(this._matchSegment(i,this.path[t],t===this.path.length-1)){e=t-1,r--,s=!0;break}if(!s)return!1}else{if(!this._matchSegment(i,this.path[e],e===this.path.length-1))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&&String(e.values[t.attrName])!==String(t.attrValue))return!1}if(void 0!==t.position){if(!r)return!1;const i=e.counter??0;if("first"===t.position&&0!==i)return!1;if("odd"===t.position&&i%2!=1)return!1;if("even"===t.position&&i%2!=0)return!1;if("nth"===t.position&&i!==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}}function n(t){return"number"==typeof t&&Object.is(t,-0)?"-0":String(t)}function a(t){return n(t).replace(/--/g,"- -").replace(/--/g,"- -").replace(/-$/,"- ")}function o(t){return n(t).replace(/\]\]>/g,"]]]]>")}function h(t){return n(t).replace(/"/g,""").replace(/'/g,"'")}const p=":A-Za-z_À-ÖØ-öø-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�",u=":A-Za-z_À-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",l=u+"\\-\\.\\d·̀-ͯ҇‿-⁀",c=(t,e,r="")=>{const i=`[${t.replace(":","")}][${e.replace(":","")}]*`;return{name:new RegExp(`^[${t}][${e}]*$`,r),ncName:new RegExp(`^${i}$`,r),qName:new RegExp(`^${i}(?::${i})?$`,r),nmToken:new RegExp(`^[${e}]+$`,r),nmTokens:new RegExp(`^[${e}]+(?:\\s+[${e}]+)*$`,r)}},f=c(p,p+"\\-\\.\\d·̀-ͯ‿-⁀"),d=c(u,l,"u"),g=":A-Za-z_",m=c(g,g+"\\-\\.\\d"),b=["name","ncName","qName","nmToken","nmTokens"],v=(t,{xmlVersion:e="1.0",asciiOnly:r=!1,maxCacheSize:i=2048}={})=>{if(!b.includes(t))throw new TypeError(`Unknown production "${t}". Must be one of: ${b.join(", ")}`);const s=((t="1.0",e=!1)=>e?m:"1.1"===t?d:f)(e,r)[t];let n=new Map;const a=t=>{const e=n.get(t);if(void 0!==e)return e;const r=s.test(t);return n.size{n=new Map},a};function N(t,e,r,i,s){return r.sanitizeName?s(t)?t:r.sanitizeName(t,{isAttribute:e,matcher:i.readOnly()}):t}function y(t,e){var i="";e.format&&(i="\n");var n=[];if(e.stopNodes&&Array.isArray(e.stopNodes))for(var a=0;ae.maxNestedTags)throw new Error("Maximum nested tags exceeded");if(!Array.isArray(t)){if(null!=t){var l=n(t);return E(l,e)}return""}for(var c=0;c":p+=y+"/>":S&&0!==S.length||!e.suppressEmptyNode?S&&S.endsWith(">")?p+=y+">"+S+r+"":(p+=y+">",S&&""!==r&&(S.includes("/>")||S.includes(""):p+=y+"/>",u=!0,i.pop()}else p+=("?xml"===g?"":r)+"<"+g+w(f[":@"],e,b,i,h)+"?>",u=!0,i.pop();else p+=r+"\x3c!--"+a(f[d][0][e.textNodeName])+"--\x3e",u=!0,i.pop();else u&&(p+=r),p+="",u=!1,i.pop();else{var j=f[d];b||(j=E(j=e.tagValueProcessor(g,j),e)),u&&(p+=r),p+=j=n(j),u=!1,i.pop()}}}return p}function x(t,e){if(!t||e.ignoreAttributes)return null;var r={},i=!1;for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s.startsWith(e.attributeNamePrefix)?s.substr(e.attributeNamePrefix.length):s]=h(t[s]),i=!0);return i?r:null}function P(t,e){if(!Array.isArray(t))return null!=t?n(t):"";for(var r="",i=0;i"+h+"":r+="<"+a+o+"/>"}}}return r}function S(t,e){var r="";if(t&&!e.ignoreAttributes)for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=t[i];!0===s&&e.suppressBooleanAttributes?r+=" "+i.substr(e.attributeNamePrefix.length):r+=" "+i.substr(e.attributeNamePrefix.length)+'="'+h(s)+'"'}return r}function _(t){for(var e=Object.keys(t),r=0;r0&&e.processEntities)for(var r=0;rt.length)&&(e=t.length);for(var r=0,i=Array(e);r=t.length?{done:!0}:{done:!1,value:t[i++]}}}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 k(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);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,sanitizeName:!1};function $(t){if(this.options=Object.assign({},T,t),this.options.stopNodes&&Array.isArray(this.options.stopNodes)&&(this.options.stopNodes=this.options.stopNodes.map(function(t){return"string"==typeof t&&t.startsWith("*.")?".."+t.substring(2):t})),this.stopNodeExpressions=[],this.options.stopNodes&&Array.isArray(this.options.stopNodes))for(var e=0;e=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(s);!(e=r()).done;){var i=e.value;if("string"==typeof i&&t===i)return!0;if(i instanceof RegExp&&i.test(t))return!0}}:function(){return!1},this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=D),this.processTextOrObjNode=G,this.options.format?(this.indentate=R,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function V(t,e,r,i,s){return r.sanitizeName?s(t)?t:r.sanitizeName(t,{isAttribute:e,matcher:i.readOnly()}):t}function G(t,e,r,i,s){var n=this.extractAttributes(t);if(i.push(e,n),this.checkStopNode(i)){var a=this.buildRawContent(t),o=this.buildAttributesForStopNode(t);return i.pop(),this.buildObjectNode(a,e,o,r)}var h=this.j2x(t,r+1,i,s);return i.pop(),"?"===e[0]?this.buildTextValNode("",e,h.attrStr,r,i):void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,h.attrStr,r,i):this.buildObjectNode(h.val,e,h.attrStr,r)}function R(t){return this.options.indentBy.repeat(t)}function D(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}return $.prototype.build=function(t){if(this.options.preserveOrder)return y(t,this.options);var e;Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&((e={})[this.options.arrayNodeName]=t,t=e);var r=new s,i=function(t,e){var r=t["?xml"];if(r&&"object"==typeof r){if(e.attributesGroupName&&r[e.attributesGroupName]){var i=r[e.attributesGroupName][e.attributeNamePrefix+"version"];if(i)return i}var s=r[e.attributeNamePrefix+"version"];if(s)return s}return"1.0"}(t,this.options),n=v("qName",{xmlVersion:i});return this.j2x(t,0,r,n).val},$.prototype.j2x=function(t,e,r,i){var s="",a="";if(this.options.maxNestedTags&&r.getDepth()>=this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");var o=this.options.jPath?r.toString():r,h=this.checkStopNode(r);for(var p in t)if(Object.prototype.hasOwnProperty.call(t,p)){var u=p===this.options.textNodeName||p===this.options.cdataPropName||p===this.options.commentPropName||this.options.attributesGroupName&&p===this.options.attributesGroupName||this.isAttribute(p)||"?"===p[0]?p:V(p,!1,this.options,r,i);if(void 0===t[p])this.isAttribute(p)&&(a+="");else if(null===t[p])this.isAttribute(p)||u===this.options.cdataPropName||u===this.options.commentPropName?a+="":"?"===u[0]?a+=this.indentate(e)+"<"+u+"?"+this.tagEndChar:a+=this.indentate(e)+"<"+u+"/"+this.tagEndChar;else if(t[p]instanceof Date)a+=this.buildTextValNode(t[p],u,"",e,r);else if("object"!=typeof t[p]){var l=this.isAttribute(p);if(l&&!this.ignoreAttributesFn(l,o)){var c=V(l,!0,this.options,r,i);s+=this.buildAttrPairStr(c,n(t[p]),h)}else if(!l)if(p===this.options.textNodeName){var f=this.options.tagValueProcessor(p,n(t[p]));a+=this.replaceEntitiesValue(f)}else{r.push(u);var d=this.checkStopNode(r);if(r.pop(),d){var g=n(t[p]);a+=""===g?this.indentate(e)+"<"+u+this.closeTag(u)+this.tagEndChar:this.indentate(e)+"<"+u+">"+g+""+S+""+a+"";else if("object"==typeof a&&null!==a){var o=this.buildRawContent(a),h=this.buildAttributesForStopNode(a);e+=""===o?"<"+r+h+"/>":"<"+r+h+">"+o+""}}else if("object"==typeof i&&null!==i){var p=this.buildRawContent(i),u=this.buildAttributesForStopNode(i);e+=""===p?"<"+r+u+"/>":"<"+r+u+">"+p+""}else e+="<"+r+">"+i+""}return e},$.prototype.buildAttributesForStopNode=function(t){if(!t||"object"!=typeof t)return"";var e="";if(this.options.attributesGroupName&&t[this.options.attributesGroupName]){var r=t[this.options.attributesGroupName];for(var i in r)if(Object.prototype.hasOwnProperty.call(r,i)){var s=i.startsWith(this.options.attributeNamePrefix)?i.substring(this.options.attributeNamePrefix.length):i,n=r[i];!0===n&&this.options.suppressBooleanAttributes?e+=" "+s:e+=" "+s+'="'+h(n)+'"'}}else for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){var o=this.isAttribute(a);if(o){var p=t[a];!0===p&&this.options.suppressBooleanAttributes?e+=" "+o:e+=" "+o+'="'+h(p)+'"'}}return e},$.prototype.buildObjectNode=function(t,e,r,i){if(""===t)return"?"===e[0]?this.indentate(i)+"<"+e+r+"?"+this.tagEndChar:this.indentate(i)+"<"+e+r+this.closeTag(e)+this.tagEndChar;if("?"===e[0])return this.indentate(i)+"<"+e+r+"?"+this.tagEndChar;var s=""+t+s},$.prototype.closeTag=function(t){var 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){var p=a(t);return this.indentate(i)+"\x3c!--"+p+"--\x3e"+this.newLine}if("?"===e[0])return this.indentate(i)+"<"+e+r+"?"+this.tagEndChar;var u=this.options.tagValueProcessor(e,t);return""===(u=n(u=this.replaceEntitiesValue(u)))?this.indentate(i)+"<"+e+r+this.closeTag(e)+this.tagEndChar:this.indentate(i)+"<"+e+r+">"+u+"0&&this.options.processEntities)for(var e=0;e