2 lines
39 KiB
JavaScript
2 lines
39 KiB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.XMLParser=e():t.XMLParser=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,{default:()=>vt});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 a=n.length,s=0;s<a;s++)i.push(n[s]);r.push(i),n=e.exec(t)}return r}var a=function(t){return!(null==n.exec(t))},s=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],o=["__proto__","constructor","prototype"],h=function(t){return s.includes(t)?"__"+t:t},l={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:h};function u(t,e){if("string"==typeof t){var r=t.toLowerCase();if(s.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 d(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!=(a=t.maxEntityCount)?a:1e3),allowedTags:null!=(s=t.allowedTags)?s:null,tagFilter:null!=(o=t.tagFilter)?o:null}:d(!0);var e,r,n,i,a,s,o}var p,f=function(t){for(var e=Object.assign({},l,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],a=i.value,s=i.name;a&&u(a,s)}return null===e.onDangerousProperty&&(e.onDangerousProperty=h),e.processEntities=d(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 g=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}(),c=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,a=!1,s=!1;e<t.length;e++)if("<"!==t[e]||s)if(">"===t[e]){if(s?"-"===t[e-1]&&"-"===t[e-2]&&(s=!1,i--):i--,0===i)break}else"["===t[e]?a=!0:t[e];else{if(a&&v(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(a&&v(t,"!ELEMENT",e))e+=8,e=this.readElementExp(t,e+1).index;else if(a&&v(t,"!ATTLIST",e))e+=8;else if(a&&v(t,"!NOTATION",e))e+=9,e=this.readNotationExp(t,e+1,this.suppressValidationErr).index;else{if(!v(t,"!--",e))throw new Error("Invalid DOCTYPE");s=!0}i++}if(0!==i)throw new Error("Unclosed DOCTYPE");return{entities:r,i:e}},e.readEntityExp=function(t,e){for(var r=e=m(t,e);e<t.length&&!/\s/.test(t[e])&&'"'!==t[e]&&"'"!==t[e];)e++;var n=t.substring(r,e);if(x(n),e=m(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,a=this.readIdentifierVal(t,e,"entity");if(e=a[0],i=a[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=m(t,e);e<t.length&&!/\s/.test(t[e]);)e++;var n=t.substring(r,e);!this.suppressValidationErr&&x(n),e=m(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=m(t,e);var a=null,s=null;if("PUBLIC"===i){var o=this.readIdentifierVal(t,e,"publicIdentifier");if(e=o[0],a=o[1],'"'===t[e=m(t,e)]||"'"===t[e]){var h=this.readIdentifierVal(t,e,"systemIdentifier");e=h[0],s=h[1]}}else if("SYSTEM"===i){var l=this.readIdentifierVal(t,e,"systemIdentifier");if(e=l[0],s=l[1],!this.suppressValidationErr&&!s)throw new Error("Missing mandatory system identifier for SYSTEM notation")}return{notationName:n,publicIdentifier:a,systemIdentifier:s,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 a=++e;e<t.length&&t[e]!==i;)e++;if(n=t.substring(a,e),t[e]!==i)throw new Error("Unterminated "+r+" value");return[++e,n]},e.readElementExp=function(t,e){for(var r=e=m(t,e);e<t.length&&!/\s/.test(t[e]);)e++;var n=t.substring(r,e);if(!this.suppressValidationErr&&!a(n))throw new Error('Invalid element name: "'+n+'"');var i="";if("E"===t[e=m(t,e)]&&v(t,"MPTY",e))e+=4;else if("A"===t[e]&&v(t,"NY",e))e+=2;else if("("===t[e]){for(var s=++e;e<t.length&&")"!==t[e];)e++;if(i=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:n,contentModel:i.trim(),index:e}},e.readAttlistExp=function(t,e){for(var r=e=m(t,e);e<t.length&&!/\s/.test(t[e]);)e++;var n=t.substring(r,e);for(x(n),r=e=m(t,e);e<t.length&&!/\s/.test(t[e]);)e++;var i=t.substring(r,e);if(!x(i))throw new Error('Invalid attribute name: "'+i+'"');e=m(t,e);var a="";if("NOTATION"===t.substring(e,e+8).toUpperCase()){if(a="NOTATION","("!==t[e=m(t,e+=8)])throw new Error("Expected '(', found \""+t[e]+'"');e++;for(var s=[];e<t.length&&")"!==t[e];){for(var o=e;e<t.length&&"|"!==t[e]&&")"!==t[e];)e++;var h=t.substring(o,e);if(!x(h=h.trim()))throw new Error('Invalid notation name: "'+h+'"');s.push(h),"|"===t[e]&&(e++,e=m(t,e))}if(")"!==t[e])throw new Error("Unterminated list of notations");e++,a+=" ("+s.join("|")+")"}else{for(var l=e;e<t.length&&!/\s/.test(t[e]);)e++;if(a+=t.substring(l,e),!this.suppressValidationErr&&!["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"].includes(a.toUpperCase()))throw new Error('Invalid attribute type: "'+a+'"')}e=m(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 d=this.readIdentifierVal(t,e,"ATTLIST");e=d[0],u=d[1]}return{elementName:n,attributeName:i,attributeType:a,defaultValue:u,index:e}},t}(),m=function(t,e){for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function v(t,e,r){for(var n=0;n<e.length;n++)if(e[n]!==t[r+n+1])return!1;return!0}function x(t){if(a(t))return t;throw new Error("Invalid entity name "+t)}const y=/^[-+]?0x[a-fA-F0-9]+$/,E=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,b={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original"};const N=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;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}const S=new Set(["push","pop","reset","updateCurrent","restore"]);class T{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],a=r?`${r}:${t}`:t,s=i.get(a)||0;let o=0;for(const t of i.values())o+=t;i.set(a,s+1);const h={tag:t,position:o,counter:s};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 a=t===this.path.length-1;if(this._matchSegment(n,this.path[t],a)){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(S.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 C{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 a,s,o=n;if(n.includes("::")){const e=n.indexOf("::");if(a=n.substring(0,e).trim(),o=n.substring(e+2).trim(),!a)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)?(s=e,h=r):s=o}else s=o;if(!s)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=s,a&&(e.namespace=a),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 _{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 I(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 A(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)?A(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 A(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 P(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 O(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 M=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 K(e,10,"&#")}},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:function(t,e){return K(e,16,"&#x")}}},this.addExternalEntities=D,this.parseXml=z,this.parseTextData=k,this.resolveNameSpace=j,this.buildAttributesMap=F,this.isItStopNode=W,this.replaceEntitiesValue=$,this.readStopNodeData=X,this.saveTextToParentTag=U,this.addChild=L,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 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.")}(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 T,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new _;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 C(i)):i instanceof C&&this.stopNodeExpressionsSet.add(i)}this.stopNodeExpressionsSet.seal()}};function D(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 k(t,e,r,n,i,a,s){var o=this.options;if(void 0!==t&&(o.trimValues&&!n&&(t=t.trim()),t.length>0)){s||(t=this.replaceEntitiesValue(t,e,r));var h=o.jPath?r.toString():r,l=o.tagValueProcessor(e,t,h,i,a);return null==l?t:typeof l!=typeof t||l!==t?l:o.trimValues||t.trim()===t?G(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 V=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function F(t,e,r){var n=this.options;if(!0!==n.ignoreAttributes&&"string"==typeof t){for(var a=i(t,V),s=a.length,o={},h=new Array(s),l=!1,u={},d=0;d<s;d++){var p=this.resolveNameSpace(a[d][1]),f=a[d][4];if(p.length&&void 0!==f){var g=f;n.trimValues&&(g=g.trim()),g=this.replaceEntitiesValue(g,r,this.readonlyMatcher),h[d]=g,u[p]=g,l=!0}}l&&"object"==typeof e&&e.updateCurrent&&e.updateCurrent(u);for(var c=n.jPath?e.toString():this.readonlyMatcher,m=!1,v=0;v<s;v++){var x=this.resolveNameSpace(a[v][1]);if(!this.ignoreAttributesFn(x,c)){var y=n.attributeNamePrefix+x;if(x.length)if(n.transformAttributeName&&(y=n.transformAttributeName(y)),y=q(y,n),void 0!==a[v][4]){var E=h[v],b=n.attributeValueProcessor(x,E,c);o[y]=null==b?E:typeof b!=typeof E||b!==E?b:G(E,n.parseAttributeValue,n.numberParseOptions),m=!0}else n.allowBooleanAttributes&&(o[y]=!0,m=!0)}}if(!m)return;if(n.attributesGroupName){var N={};return N[n.attributesGroupName]=o,N}return o}}var z=function(t){t=t.replace(/\r\n?/g,"\n");var e=new g("!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,a=new c(i.processEntities),s=t.length,o=0;o<s;o++)if("<"===t[o]){var h=t.charCodeAt(o+1);if(47===h){var l=R(t,">",o,"Closing Tag is not closed."),u=t.substring(o+2,l).trim();if(i.removeNSPrefix){var d=u.indexOf(":");-1!==d&&(u=u.substr(d+1))}u=Z(i.transformTagName,u,"",i).tagName,r&&(n=this.saveTextToParentTag(n,r,this.readonlyMatcher));var p=this.matcher.getCurrentTag();if(u&&i.unpairedTagsSet.has(u))throw new Error("Unpaired tag can not be used as closing tag: </"+u+">");p&&i.unpairedTagsSet.has(p)&&(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=B(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 m=new g(f.tagName);m.add(i.textNodeName,""),f.tagName!==f.tagExp&&f.attrExpPresent&&(m[":@"]=this.buildAttributesMap(f.tagExp,this.matcher,f.tagName)),this.addChild(r,m,this.readonlyMatcher,o)}o=f.closeIndex+1}else if(33===h&&45===t.charCodeAt(o+2)&&45===t.charCodeAt(o+3)){var v=R(t,"--\x3e",o+4,"Comment is not closed.");if(i.commentPropName){var x,y=t.substring(o+4,v-2);n=this.saveTextToParentTag(n,r,this.readonlyMatcher),r.add(i.commentPropName,[(x={},x[i.textNodeName]=y,x)])}o=v}else if(33===h&&68===t.charCodeAt(o+2)){var E=a.readDocType(t,o);this.docTypeEntities=E.entities,this.docTypeEntitiesKeys=Object.keys(this.docTypeEntities)||[],o=E.i}else if(33===h&&91===t.charCodeAt(o+2)){var b=R(t,"]]>",o,"CDATA is not closed.")-2,N=t.substring(o+9,b);n=this.saveTextToParentTag(n,r,this.readonlyMatcher);var w,S=this.parseTextData(N,r.tagname,this.readonlyMatcher,!0,!1,!0,!0);null==S&&(S=""),i.cdataPropName?r.add(i.cdataPropName,[(w={},w[i.textNodeName]=N,w)]):r.add(i.textNodeName,S),o=b+2}else{var T=B(t,o,i.removeNSPrefix);if(!T){var C=t.substring(Math.max(0,o-50),Math.min(s,o+50));throw new Error("readTagExp returned undefined at position "+o+'. Context: "'+C+'"')}var _=T.tagName,I=T.rawTagName,A=T.tagExp,M=T.attrExpPresent,D=T.closeIndex,k=Z(i.transformTagName,_,A,i);if(_=k.tagName,A=k.tagExp,i.strictReservedNames&&(_===i.commentPropName||_===i.cdataPropName||_===i.textNodeName||_===i.attributesGroupName))throw new Error("Invalid tag name: "+_);r&&n&&"!xml"!==r.tagname&&(n=this.saveTextToParentTag(n,r,this.readonlyMatcher,!1));var j=r;j&&i.unpairedTagsSet.has(j.tagname)&&(r=this.tagsNodeStack.pop(),this.matcher.pop());var V=!1;A.length>0&&A.lastIndexOf("/")===A.length-1&&(V=!0,A="/"===_[_.length-1]?_=_.substr(0,_.length-1):A.substr(0,A.length-1),M=_!==A);var F,z=null;F=O(I),_!==e.tagname&&this.matcher.push(_,{},F),_!==A&&M&&(z=this.buildAttributesMap(A,this.matcher,_))&&P(z,i),_!==e.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());var L=o;if(this.isCurrentNodeStopNode){var $="";if(V)o=T.closeIndex;else if(i.unpairedTagsSet.has(_))o=T.closeIndex;else{var U=this.readStopNodeData(t,I,D+1);if(!U)throw new Error("Unexpected end of "+I);o=U.i,$=U.tagContent}var W=new g(_);z&&(W[":@"]=z),W.add(i.textNodeName,$),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(r,W,this.readonlyMatcher,L)}else{if(V){var Y=Z(i.transformTagName,_,A,i);_=Y.tagName,A=Y.tagExp;var X=new g(_);z&&(X[":@"]=z),this.addChild(r,X,this.readonlyMatcher,L),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else{if(i.unpairedTagsSet.has(_)){var G=new g(_);z&&(G[":@"]=z),this.addChild(r,G,this.readonlyMatcher,L),this.matcher.pop(),this.isCurrentNodeStopNode=!1,o=T.closeIndex;continue}var K=new g(_);if(this.tagsNodeStack.length>i.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(r),z&&(K[":@"]=z),this.addChild(r,K,this.readonlyMatcher,L),r=K}n="",o=D}}}else n+=t[o];return e.child};function L(t,e,r,n){this.options.captureMetaData||(n=void 0);var i=this.options.jPath?r.toString():r,a=this.options.updateTag(e.tagname,i,e[":@"]);!1===a||("string"==typeof a?(e.tagname=a,t.addChild(e,n)):t.addChild(e,n))}function $(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 a=this.options.jPath?r.toString():r;if(!n.tagFilter(e,a))return t}for(var s,o=I(this.docTypeEntitiesKeys);!(s=o()).done;){var h=s.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 d=t.length;if(t=t.replace(l.regx,l.val),n.maxExpandedLength&&(this.currentExpandedLength+=t.length-d,this.currentExpandedLength>n.maxExpandedLength))throw new Error("Total expanded content size exceeded: "+this.currentExpandedLength+" > "+n.maxExpandedLength)}}if(-1===t.indexOf("&"))return t;for(var p,f=I(this.lastEntitiesKeys);!(p=f()).done;){var g=p.value,c=this.lastEntities[g],m=t.match(c.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(c.regex,c.val)}if(-1===t.indexOf("&"))return t;for(var v,x=I(this.htmlEntitiesKeys);!(v=x()).done;){var y=v.value,E=this.htmlEntities[y],b=t.match(E.regex);if(b&&(this.entityExpansionCount+=b.length,n.maxTotalExpansions&&this.entityExpansionCount>n.maxTotalExpansions))throw new Error("Entity expansion limit exceeded: "+this.entityExpansionCount+" > "+n.maxTotalExpansions);t=t.replace(E.regex,E.val)}return t.replace(this.ampEntity.regex,this.ampEntity.val)}function U(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 W(){return 0!==this.stopNodeExpressionsSet.size&&this.matcher.matchesAny(this.stopNodeExpressionsSet)}function R(t,e,r,n){var i=t.indexOf(e,r);if(-1===i)throw new Error(n);return i+e.length-1}function Y(t,e,r,n){var i=t.indexOf(e,r);if(-1===i)throw new Error(n);return i}function B(t,e,r,n){void 0===n&&(n=">");var i=function(t,e,r){void 0===r&&(r=">");for(var n=0,i=[],a=t.length,s=r.charCodeAt(0),o=r.length>1?r.charCodeAt(1):-1,h=e;h<a;h++){var l=t.charCodeAt(h);if(n)l===n&&(n=0);else if(34===l||39===l)n=l;else if(l===s){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 a=i.data,s=i.index,o=a.search(/\s/),h=a,l=!0;-1!==o&&(h=a.substring(0,o),a=a.substring(o+1).trimStart());var u=h;if(r){var d=h.indexOf(":");-1!==d&&(l=(h=h.substr(d+1))!==i.data.substr(d+1))}return{tagName:h,tagExp:a,closeIndex:s,attrExpPresent:l,rawTagName:u}}}function X(t,e,r){for(var n=r,i=1,a=t.length;r<a;r++)if("<"===t[r]){var s=t.charCodeAt(r+1);if(47===s){var o=Y(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===s)r=R(t,"?>",r+1,"StopNode is not closed.");else if(33===s&&45===t.charCodeAt(r+2)&&45===t.charCodeAt(r+3))r=R(t,"--\x3e",r+3,"StopNode is not closed.");else if(33===s&&91===t.charCodeAt(r+2))r=R(t,"]]>",r,"StopNode is not closed.")-2;else{var h=B(t,r,">");h&&((h&&h.tagName)===e&&"/"!==h.tagExp[h.tagExp.length-1]&&i++,r=h.closeIndex)}}}function G(t,e,r){if(e&&"string"==typeof t){var n=t.trim();return"true"===n||"false"!==n&&function(t,e={}){if(e=Object.assign({},b,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&&y.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(N);if(n){let i=n[1]||"";const a=-1===n[3].indexOf("e")?"E":"e",s=n[2],o=i?t[s.length+1]===a:t[s.length]===a;return s.length>1&&o?t:(1!==s.length||!n[3].startsWith(`.${a}`)&&n[3][0]!==a)&&s.length>0?r.leadingZeros&&!o?(e=(n[1]||"")+n[3],Number(e)):t:Number(e)}return t}(t,r,e);{const i=E.exec(r);if(i){const a=i[1]||"",s=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=a?"."===t[s.length+1]:"."===t[s.length];if(!e.leadingZeros&&(s.length>1||1===s.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===`${a}${o}`?n:t;let h=s?o:r;return s?h===i||a+h===i?n:t:h===i||h===a+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 K(t,e,r){var n=Number.parseInt(t,e);return n>=0&&n<=1114111?String.fromCodePoint(n):r+t+";"}function Z(t,e,r,n){if(t){var i=t(e);r===e&&(r=i),e=i}return{tagName:e=q(e,n),tagExp:r}}function q(t,e){if(o.includes(t))throw new Error('[SECURITY] Invalid name: "'+t+'" is a reserved JavaScript keyword that could cause prototype pollution');return s.includes(t)?e.onDangerousProperty(t):t}var J=g.getMetaDataSymbol();function Q(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 H(t,e,r,n){return tt(t,e,r,n)}function tt(t,e,r,n){for(var i,a={},s=0;s<t.length;s++){var o=t[s],h=et(o);if(void 0!==h&&h!==e.textNodeName){var l=Q(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=tt(o[h],e,r,n),d=nt(u,e);if(o[":@"]?rt(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[J]&&"object"==typeof u&&null!==u&&(u[J]=o[J]),void 0!==a[h]&&Object.prototype.hasOwnProperty.call(a,h))Array.isArray(a[h])||(a[h]=[a[h]]),a[h].push(u);else{var p=e.jPath?n.toString():n;e.isArray(h,p,d)?a[h]=[u]:a[h]=u}void 0!==h&&h!==e.textNodeName&&r.pop()}}}return"string"==typeof i?i.length>0&&(a[e.textNodeName]=i):void 0!==i&&(a[e.textNodeName]=i),a}function et(t){for(var e=Object.keys(t),r=0;r<e.length;r++){var n=e[r];if(":@"!==n)return n}}function rt(t,e,r,n){if(e)for(var i=Object.keys(e),a=i.length,s=0;s<a;s++){var o=i[s],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 nt(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 it={allowBooleanAttributes:!1,unpairedTags:[]};function at(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function st(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 pt("InvalidXml","XML declaration allowed only at the start of the document.",ct(t,e));if("?"==t[e]&&">"==t[e+1]){e++;break}}return e}function ot(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}function ht(t,e){for(var r="",n="",i=!1;e<t.length;e++){if('"'===t[e]||"'"===t[e])""===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 lt=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function ut(t,e){for(var r=i(t,lt),n={},a=0;a<r.length;a++){if(0===r[a][1].length)return pt("InvalidAttr","Attribute '"+r[a][2]+"' has no space in starting.",mt(r[a]));if(void 0!==r[a][3]&&void 0===r[a][4])return pt("InvalidAttr","Attribute '"+r[a][2]+"' is without value.",mt(r[a]));if(void 0===r[a][3]&&!e.allowBooleanAttributes)return pt("InvalidAttr","boolean attribute '"+r[a][2]+"' is not allowed.",mt(r[a]));var s=r[a][2];if(!ft(s))return pt("InvalidAttr","Attribute '"+s+"' is an invalid name.",mt(r[a]));if(Object.prototype.hasOwnProperty.call(n,s))return pt("InvalidAttr","Attribute '"+s+"' is repeated.",mt(r[a]));n[s]=1}return!0}function dt(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 pt(t,e,r){return{err:{code:t,msg:e,line:r.line||r,col:r.col}}}function ft(t){return a(t)}function gt(t){return a(t)}function ct(t,e){var r=t.substring(0,e).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function mt(t){return t.startIndex+t[1].length}var vt=function(){function t(t){this.externalEntities={},this.options=f(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=function(t,e){e=Object.assign({},it,e);var r=[],n=!1,i=!1;"\ufeff"===t[0]&&(t=t.substr(1));for(var a=0;a<t.length;a++)if("<"===t[a]&&"?"===t[a+1]){if((a=st(t,a+=2)).err)return a}else{if("<"!==t[a]){if(at(t[a]))continue;return pt("InvalidChar","char '"+t[a]+"' is not expected.",ct(t,a))}var s=a;if("!"===t[++a]){a=ot(t,a);continue}var o=!1;"/"===t[a]&&(o=!0,a++);for(var h="";a<t.length&&">"!==t[a]&&" "!==t[a]&&"\t"!==t[a]&&"\n"!==t[a]&&"\r"!==t[a];a++)h+=t[a];if("/"===(h=h.trim())[h.length-1]&&(h=h.substring(0,h.length-1),a--),!gt(h))return pt("InvalidTag",0===h.trim().length?"Invalid space after '<'.":"Tag '"+h+"' is an invalid name.",ct(t,a));var l=ht(t,a);if(!1===l)return pt("InvalidAttr","Attributes for '"+h+"' have open quote.",ct(t,a));var u=l.value;if(a=l.index,"/"===u[u.length-1]){var d=a-u.length,p=ut(u=u.substring(0,u.length-1),e);if(!0!==p)return pt(p.err.code,p.err.msg,ct(t,d+p.err.line));n=!0}else if(o){if(!l.tagClosed)return pt("InvalidTag","Closing tag '"+h+"' doesn't have proper closing.",ct(t,a));if(u.trim().length>0)return pt("InvalidTag","Closing tag '"+h+"' can't have attributes or invalid starting.",ct(t,s));if(0===r.length)return pt("InvalidTag","Closing tag '"+h+"' has not been opened.",ct(t,s));var f=r.pop();if(h!==f.tagName){var g=ct(t,f.tagStartPos);return pt("InvalidTag","Expected closing tag '"+f.tagName+"' (opened in line "+g.line+", col "+g.col+") instead of closing tag '"+h+"'.",ct(t,s))}0==r.length&&(i=!0)}else{var c=ut(u,e);if(!0!==c)return pt(c.err.code,c.err.msg,ct(t,a-u.length+c.err.line));if(!0===i)return pt("InvalidXml","Multiple possible root nodes found.",ct(t,a));-1!==e.unpairedTags.indexOf(h)||r.push({tagName:h,tagStartPos:s}),n=!0}for(a++;a<t.length;a++)if("<"===t[a]){if("!"===t[a+1]){a=ot(t,++a);continue}if("?"!==t[a+1])break;if((a=st(t,++a)).err)return a}else if("&"===t[a]){var m=dt(t,a);if(-1==m)return pt("InvalidChar","char '&' is not expected.",ct(t,a));a=m}else if(!0===i&&!at(t[a]))return pt("InvalidXml","Extra text at the end",ct(t,a));"<"===t[a]&&a--}return n?1==r.length?pt("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",ct(t,r[0].tagStartPos)):!(r.length>0)||pt("InvalidXml","Invalid '"+JSON.stringify(r.map(function(t){return t.tagName}),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):pt("InvalidXml","Start tag expected.",1)}(t,e);if(!0!==r)throw Error(r.err.msg+":"+r.err.line+":"+r.err.col)}var n=new M(this.options);n.addExternalEntities(this.externalEntities);var i=n.parseXml(t);return this.options.preserveOrder||void 0===i?i:H(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 '
'");if("&"===e)throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e},t.getMetaDataSymbol=function(){return g.getMetaDataSymbol()},t}();return e})());
|
|
//# sourceMappingURL=fxparser.min.js.map
|