xslt-processor 5.0.10 → 5.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** @type {any} */
|
|
2
|
-
var XsltProcessor=(()=>{var zn=Object.defineProperty,Za=Object.defineProperties,ec=Object.getOwnPropertyDescriptor,tc=Object.getOwnPropertyDescriptors,nc=Object.getOwnPropertyNames,gi=Object.getOwnPropertySymbols;var Ni=Object.prototype.hasOwnProperty,rc=Object.prototype.propertyIsEnumerable;var xi=(s,e,t)=>e in s?zn(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,X=(s,e)=>{for(var t in e||(e={}))Ni.call(e,t)&&xi(s,t,e[t]);if(gi)for(var t of gi(e))rc.call(e,t)&&xi(s,t,e[t]);return s},I=(s,e)=>Za(s,tc(e));var g=(s,e)=>()=>(s&&(e=s(s=0)),e);var ze=(s,e)=>{for(var t in e)zn(s,t,{get:e[t],enumerable:!0})},ic=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of nc(e))!Ni.call(s,r)&&r!==t&&zn(s,r,{get:()=>e[r],enumerable:!(n=ec(e,r))||n.enumerable});return s};var U=s=>ic(zn({},"__esModule",{value:!0}),s);var b=(s,e,t)=>new Promise((n,r)=>{var i=c=>{try{a(t.next(c))}catch(u){r(u)}},o=c=>{try{a(t.throw(c))}catch(u){r(u)}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(i,o);a((t=t.apply(s,e)).next())});var N,_=g(()=>{N=class{}});var Ot,vt,bi=g(()=>{_();Ot=class extends N{constructor(e){super(),this.value=e}evaluate(e){return this.value}toString(){return`"${this.value}"`}},vt=class extends N{constructor(e){super(),this.value=e}evaluate(e){return this.value}toString(){return this.value.toString()}}});var Te,v,Pi,Ti,_r,Xi,je=g(()=>{Te={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_FRAGMENT_NODE:11,NAMESPACE_NODE:13},v="http://www.w3.org/2001/XMLSchema",Pi="http://www.w3.org/2005/xqt-errors",Ti="http://www.w3.org/2005/xpath-functions",_r="http://www.w3.org/2005/xpath-functions/collation/codepoint",Xi=["last","position","count","id","local-name","namespace-uri","name","string","concat","starts-with","contains","substring-before","substring-after","substring","string-length","normalize-space","translate","boolean","not","true","false","lang","number","sum","floor","ceiling","round"]});function ne(s){return new nt("XPST0003",`Grammar violation: ${s}`)}function Rt(s,e="name"){return new nt("XPST0008",`Unresolved ${e} reference: ${s}`)}function Si(s){return new nt("XPST0010",`Unsupported axis: ${s}`)}function Ci(s,e,t){return new nt("XPST0017",`Function ${s} expects ${e}, got ${t} arguments`)}function pe(s,e,t){let n=t?`Type mismatch in ${t}: expected ${s}, got ${e}`:`Type mismatch: expected ${s}, got ${e}`;return new Mr("XPTY0004",n)}function wi(s,e){return new jn("FORG0001",`Cannot cast ${JSON.stringify(s)} to ${e}`)}var te,nt,jn,Mr,_e=g(()=>{je();te=class s extends Error{constructor(e,t,n=!1,r=!1){super(`${e}: ${t}`),Object.setPrototypeOf(this,s.prototype),this.code=e,this.isStatic=n,this.isDynamic=r,this.name="XPathError",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}getQName(){return`err:${this.code}`}getErrorURI(){return`${Pi}#${this.code}`}},nt=class s extends te{constructor(e,t){super(e,t,!0,!1),Object.setPrototypeOf(this,s.prototype),this.name="XPathStaticError"}},jn=class s extends te{constructor(e,t){super(e,t,!1,!0),Object.setPrototypeOf(this,s.prototype),this.name="XPathDynamicError"}},Mr=class s extends jn{constructor(e,t){super(e,t),Object.setPrototypeOf(this,s.prototype),this.name="XPathTypeError"}}});var xe,Ai=g(()=>{_();_e();xe=class extends N{constructor(e){super(),this.name=e}evaluate(e){if(!e.variables)throw Rt(`$${this.name}`,"variable");if(!(this.name in e.variables))throw Rt(`$${this.name}`,"variable");return e.variables[this.name]}toString(){return`$${this.name}`}}});var Ne,Oi=g(()=>{_();Ne=class extends N{constructor(e,t,n=[]){super(),this.axis=e,this.nodeTest=t,this.predicates=n}evaluate(e){let t=e==null?void 0:e.node;if(!t&&this.axis==="self"&&(e==null?void 0:e.contextItem)!==void 0){let r=e.contextItem;return this.predicates.length===0?[r]:this.applyPredicatesToAtomicItem(r,e)}if(!t)return[];let n=this.getNodesByAxis(t,e);return n=n.filter(r=>this.matchesNodeTest(r,e)),n=this.applyPredicates(n,e),n}applyPredicatesToAtomicItem(e,t){let n=I(X({},t),{contextItem:e,position:1,size:1});for(let r of this.predicates){let i=r.evaluate(n);if(typeof i=="number"){if(i!==1)return[]}else if(!this.toBoolean(i))return[]}return[e]}getNodesByAxis(e,t){switch(this.axis){case"child":return this.getChildNodes(e);case"parent":return e.parentNode?[e.parentNode]:[];case"self":return[e];case"attribute":return e.attributes?Array.from(e.attributes):Array.from(e.childNodes||[]).filter(n=>n.nodeType===2);case"descendant":return this.getDescendants(e,!1);case"descendant-or-self":return this.getDescendants(e,!0);case"ancestor":return this.getAncestors(e,!1);case"ancestor-or-self":return this.getAncestors(e,!0);case"following-sibling":return this.getFollowingSiblings(e);case"preceding-sibling":return this.getPrecedingSiblings(e);case"following":return this.getFollowing(e);case"preceding":return this.getPreceding(e);case"namespace":return this.getNamespaceNodes(e);case"self-and-siblings":return t!=null&&t.nodeList?t.nodeList.filter(n=>n.nodeType!==2):[e];default:return[]}}getChildNodes(e){return Array.from(e.childNodes||[]).filter(n=>n.nodeType!==2)}getDescendants(e,t){let n=[];t&&n.push(e);let r=i=>{for(let o of this.getChildNodes(i))n.push(o),r(o)};return r(e),n}getAncestors(e,t){let n=[];t&&n.push(e);let r=e.parentNode;for(;r;)n.push(r),r=r.parentNode;return n}getFollowingSiblings(e){let t=[],n=e.nextSibling;for(;n;)t.push(n),n=n.nextSibling;return t}getPrecedingSiblings(e){let t=[],n=e.previousSibling;for(;n;)t.unshift(n),n=n.previousSibling;return t}getFollowing(e){let t=[],n=e.nextSibling;for(;n;)t.push(n),t.push(...this.getDescendants(n,!1)),n=n.nextSibling;let r=e.parentNode;for(;r;){for(n=r.nextSibling;n;)t.push(n),t.push(...this.getDescendants(n,!1)),n=n.nextSibling;r=r.parentNode}return t}getPreceding(e){let t=[],n=e.previousSibling;for(;n;){t.unshift(n);let i=this.getDescendants(n,!1);t.unshift(...i),n=n.previousSibling}let r=e.parentNode;for(;r;){for(n=r.previousSibling;n;){t.unshift(n);let i=this.getDescendants(n,!1);t.unshift(...i),n=n.previousSibling}r=r.parentNode}return t}getNamespaceNodes(e){var r,i;if(!e||e.nodeType!==1)return[];let t={},n=e;for(;n;){let o=Array.from(n.attributes||[]);for(let a of o){let c=a.nodeName||a.localName||"",u=(i=(r=a.nodeValue)!=null?r:a.textContent)!=null?i:"";if(c==="xmlns")""in t||(t[""]=u);else if(c.startsWith("xmlns:")){let l=c.substring(6);l in t||(t[l]=u)}}n=n.parentNode}return"xml"in t||(t.xml="http://www.w3.org/XML/1998/namespace"),Object.entries(t).map(([o,a])=>({nodeType:13,nodeName:o,localName:o,prefix:o,namespaceURI:a,namespaceUri:a,nodeValue:a,textContent:a,parentNode:e,ownerDocument:e.ownerDocument}))}matchesNodeTest(e,t,n=this.nodeTest){var o,a;let r=e.nodeType,i=(c,u)=>{var h,m;if(!u.includes(r))return!1;if(c.endsWith(":*")){let d=c.slice(0,-2),y=(h=t==null?void 0:t.namespaces)==null?void 0:h[d];return y?(e.namespaceURI||e.namespaceUri||"")===y:!1}let l=c.indexOf(":");if(l>0){let d=c.substring(0,l),y=c.substring(l+1),E=(m=t==null?void 0:t.namespaces)==null?void 0:m[d];if(!E)return!1;let T=e.localName||e.nodeName&&this.extractLocalName(e.nodeName),P=e.namespaceURI||e.namespaceUri||"";return T===y&&P===E}return(e.localName||this.extractLocalName(e.nodeName))===c};switch(n.type){case"wildcard":if(n.name&&n.name.endsWith(":*")){let u=n.name.slice(0,-2),l=(o=t==null?void 0:t.namespaces)==null?void 0:o[u];if(!l)return!1;let p=e.namespaceURI||e.namespaceUri||"";return(r===1||r===2||r===13)&&p===l}return r===1||r===2||r===13;case"name":return i(n.name,[1,2,13]);case"element":return r!==1?!1:!n.name||n.isWildcardName?!0:i(n.name,[1]);case"attribute":return r!==2?!1:!n.name||n.isWildcardName?!0:i(n.name,[2]);case"schema-element":return i(n.name,[1]);case"schema-attribute":return i(n.name,[2]);case"document-node":if(r!==9)return!1;if(!n.elementTest)return!0;let c=e.documentElement||Array.from(e.childNodes||[]).find(u=>u.nodeType===1);return c?this.matchesNodeTest(c,t,n.elementTest):!1;case"node-type":switch(n.nodeType){case"node":return!0;case"text":return r===3;case"comment":return r===8;case"processing-instruction":return r===7;default:return!1}case"processing-instruction":return r!==7?!1:n.target?((a=e.target)!=null?a:e.nodeName)===n.target:!0;default:return!1}}applyPredicates(e,t){let n=e;for(let r of this.predicates){let i=[],o=n.length;for(let a=0;a<n.length;a++){let c=I(X({},t),{node:n[a],position:a+1,size:o}),u=r.evaluate(c);typeof u=="number"?u===a+1&&i.push(n[a]):this.toBoolean(u)&&i.push(n[a])}n=i}return n}toBoolean(e){return typeof e=="boolean"?e:typeof e=="number"?e!==0&&!isNaN(e):typeof e=="string"||Array.isArray(e)?e.length>0:!!e}extractLocalName(e){if(!e)return"";let t=e.indexOf(":");return t>0?e.substring(t+1):e}}});var Ee,vi=g(()=>{_();Ee=class extends N{constructor(e,t=!1){super(),this.steps=e,this.absolute=t}evaluate(e){let t;if(this.absolute){let n=this.getDocumentRoot(e==null?void 0:e.node);t=n?[n]:[]}else e!=null&&e.node?t=[e.node]:(e==null?void 0:e.contextItem)!==void 0?t=[{__atomicContextItem:e.contextItem}]:t=[];for(let n of this.steps){let r=[];for(let i of t)if(i&&i.__atomicContextItem!==void 0){let o=I(X({},e),{contextItem:i.__atomicContextItem}),a=n.evaluate(o);r.push(...a)}else{let o=I(X({},e),{node:i}),a=n.evaluate(o);r.push(...a)}t=this.uniqueNodes(r)}return t}getDocumentRoot(e){if(!e)return null;let t=e;for(;t.parentNode;)t=t.parentNode;return t}uniqueNodes(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}}});var It,_t,Ri=g(()=>{_();It=class extends N{constructor(e,t){super(),this.expression=e,this.predicates=t||[]}evaluate(e){let t=this.expression.evaluate(e);Array.isArray(t)||(t=t==null?[]:[t]);for(let n of this.predicates)t=this.applyPredicate(t,n,e);return t}applyPredicate(e,t,n){let r=[];for(let i=0;i<e.length;i++){let o=e[i],a=I(X({},n),{node:(o==null?void 0:o.nodeType)!==void 0?o:n.node,position:i+1,size:e.length});this.testPredicate(t,a)&&r.push(o)}return r}testPredicate(e,t){let n=e.evaluate(t);return typeof n=="number"?n===t.position:this.toBoolean(n)}toBoolean(e){return typeof e=="boolean"?e:typeof e=="number"?e!==0&&!isNaN(e):typeof e=="string"||Array.isArray(e)?e.length>0:e!=null}},_t=class extends N{constructor(e,t){super(),this.filterExpr=e,this.pathExpr=t}evaluate(e){let t=this.filterExpr.evaluate(e);if(!Array.isArray(t))return[];let n=[];for(let r of t){let i=I(X({},e),{node:(r==null?void 0:r.nodeType)!==void 0?r:e.node}),o=this.pathExpr.evaluate(i);Array.isArray(o)?n.push(...o):o!=null&&n.push(o)}return n}}});function Mt(s){var e;if(s==null||typeof s!="object"||typeof s.nodeType!="number")return null;if(s.nodeType===3||s.nodeType===2){let t=s.nodeValue;return t!=null&&t!=="null"?String(t):""}if(s.nodeType===1||s.nodeType===9){let t=s.childNodes;if(!t||t.length===0)return"";let n="";for(let r of t)if(r.nodeType===3){let i=r.nodeValue;i!=null&&i!=="null"&&(n+=String(i))}else r.nodeType===1&&(n+=(e=Mt(r))!=null?e:"");return n}return null}var kr=g(()=>{});var kt,Ii=g(()=>{_();kr();kt=class extends N{constructor(e,t){super(),this.operator=e,this.operand=t}evaluate(e){let t=this.operand.evaluate(e),n=this.atomize(t);if(n===null)return null;let r=this.toNumber(n);return this.operator==="+"?r:-r}atomize(e){if(e==null)return null;if(!Array.isArray(e)){let t=Mt(e);return t!==null?t:e}return e.length===0?null:this.atomize(e[0])}toNumber(e){if(typeof e=="number")return e;if(typeof e=="boolean")return e?1:0;if(typeof e=="string"){let t=e.trim();return t===""?NaN:Number(t)}return Number(e)}toString(){return`${this.operator}${this.operand.toString()}`}}});var rt,_i=g(()=>{_();rt=class extends N{constructor(e,t,n){super(),this.left=e,this.right=t,this.operator=n}evaluate(e){let t=this.left.evaluate(e),n=this.right.evaluate(e);return this.compare(t,n,this.operator)}compare(e,t,n){let r=Array.isArray(e),i=Array.isArray(t);return r&&i?this.compareNodeSets(e,t,n):r?this.compareNodeSetToValue(e,t,n):i?this.compareValueToNodeSet(e,t,n):this.comparePrimitives(e,t,n)}compareNodeSets(e,t,n){for(let r of e){let i=this.getStringValue(r);for(let o of t){let a=this.getStringValue(o);if(this.comparePrimitives(i,a,n))return!0}}return!1}compareNodeSetToValue(e,t,n){for(let r of e){let i=typeof t=="number"?Number(this.getStringValue(r)):this.getStringValue(r);if(this.comparePrimitives(i,t,n))return!0}return!1}compareValueToNodeSet(e,t,n){for(let r of t){let i=typeof e=="number"?Number(this.getStringValue(r)):this.getStringValue(r);if(this.comparePrimitives(e,i,n))return!0}return!1}comparePrimitives(e,t,n){switch(n){case"=":return e==t;case"!=":return e!=t;case"<":return Number(e)<Number(t);case">":return Number(e)>Number(t);case"<=":return Number(e)<=Number(t);case">=":return Number(e)>=Number(t);default:throw new Error(`Unknown operator: ${n}`)}}getStringValue(e){if(!e)return"";if(e.nodeType===3||e.nodeType===2)return e.nodeValue||e.textContent||"";if(e.textContent!==void 0)return e.textContent;if(e.childNodes){let t="";for(let n of Array.from(e.childNodes))n.nodeType===3?t+=n.nodeValue||"":n.nodeType===1&&(t+=this.getStringValue(n));return t}return String(e)}}});var Ye,Mi=g(()=>{_();kr();Ye=class extends N{constructor(e,t,n){super(),this.left=e,this.right=t,this.operator=n}evaluate(e){let t=this.left.evaluate(e),n=this.right.evaluate(e),r=this.atomize(t),i=this.atomize(n);if(r===null||i===null)return null;let o=this.toNumber(r),a=this.toNumber(i);switch(this.operator){case"+":return o+a;case"-":return o-a;case"*":return o*a;case"div":return o/a;case"idiv":if(a===0)throw new Error("XPDY0002: Integer division by zero");return Math.trunc(o/a);case"mod":if(a===0)throw new Error("XPDY0002: Modulo by zero");return o-Math.trunc(o/a)*a;default:throw new Error(`Unknown arithmetic operator: ${this.operator}`)}}atomize(e){if(e==null)return null;if(typeof e=="object"&&"numberValue"in e&&typeof e.numberValue=="function")return e.numberValue();if(!Array.isArray(e)){let t=Mt(e);return t!==null?t:e}return e.length===0?null:this.atomize(e[0])}toNumber(e){if(typeof e=="number")return e;if(typeof e=="boolean")return e?1:0;if(typeof e=="string"){let t=e.trim();return t===""?NaN:Number(t)}return Number(e)}toString(){return`${this.left.toString()} ${this.operator} ${this.right.toString()}`}}});var it,ki=g(()=>{_();it=class extends N{constructor(e,t,n){super(),this.left=e,this.right=t,this.operator=n}toBoolean(e){return e==null?!1:typeof e=="boolean"?e:Array.isArray(e)?e.length===0?!1:e.length===1?this.toBoolean(e[0]):!0:typeof e=="number"?e!==0&&!isNaN(e):typeof e=="string"?e.length>0:!!e}evaluate(e){let t=this.toBoolean(this.left.evaluate(e));if(this.operator==="and")return t?this.toBoolean(this.right.evaluate(e)):!1;if(this.operator==="or")return t?!0:this.toBoolean(this.right.evaluate(e));throw new Error(`Unknown logical operator: ${this.operator}`)}}});var Dt,Di=g(()=>{_();Dt=class extends N{constructor(e,t,n){super(),this.test=e,this.thenExpr=t,this.elseExpr=n}toBoolean(e){return e==null?!1:typeof e=="boolean"?e:Array.isArray(e)?e.length===0?!1:e.length===1?this.toBoolean(e[0]):!0:typeof e=="number"?e!==0&&!isNaN(e):typeof e=="string"?e.length>0:!!e}evaluate(e){return this.toBoolean(this.test.evaluate(e))?this.thenExpr.evaluate(e):this.elseExpr.evaluate(e)}}});var Vt,Vi=g(()=>{_();Vt=class extends N{constructor(e,t){super(),this.bindings=e,this.returnExpr=t}evaluate(e){let t=e.variables?X({},e.variables):{},n=I(X({},e),{variables:t}),r=[];return this.evaluateBinding(0,n,r),r}evaluateBinding(e,t,n){var a;if(e>=this.bindings.length){let c=this.returnExpr.evaluate(t);this.appendResult(n,c);return}let r=this.bindings[e],i=this.normalizeSequence(r.expression.evaluate(t)),o=i.length;for(let c=0;c<o;c++){let u=i[c],l=I(X({},(a=t.variables)!=null?a:{}),{[r.variable]:u}),p=I(X({},t),{variables:l,node:this.resolveNode(u,t),position:c+1,size:o});this.evaluateBinding(e+1,p,n)}}normalizeSequence(e){return e==null?[]:Array.isArray(e)?e:[e]}appendResult(e,t){if(t!=null){if(Array.isArray(t)){e.push(...t);return}e.push(t)}}resolveNode(e,t){return e&&typeof e=="object"&&"nodeType"in e?e:t.node}}});var Ft,Fi=g(()=>{_();Ft=class extends N{constructor(e,t,n){super(),this.quantifier=e,this.bindings=t,this.satisfiesExpr=n}evaluate(e){let t=e.variables?X({},e.variables):{},n=I(X({},e),{variables:t});return this.quantifier==="some"?this.evaluateSome(0,n):this.evaluateEvery(0,n)}evaluateSome(e,t){var i;if(e>=this.bindings.length)return this.toBoolean(this.satisfiesExpr.evaluate(t));let n=this.bindings[e],r=this.normalizeSequence(n.expression.evaluate(t));for(let o=0;o<r.length;o++){let a=r[o],c=I(X({},(i=t.variables)!=null?i:{}),{[n.variable]:a}),u=I(X({},t),{variables:c,node:this.resolveNode(a,t),position:o+1,size:r.length});if(this.evaluateSome(e+1,u))return!0}return!1}evaluateEvery(e,t){var i;if(e>=this.bindings.length)return this.toBoolean(this.satisfiesExpr.evaluate(t));let n=this.bindings[e],r=this.normalizeSequence(n.expression.evaluate(t));if(r.length===0)return!0;for(let o=0;o<r.length;o++){let a=r[o],c=I(X({},(i=t.variables)!=null?i:{}),{[n.variable]:a}),u=I(X({},t),{variables:c,node:this.resolveNode(a,t),position:o+1,size:r.length});if(!this.evaluateEvery(e+1,u))return!1}return!0}normalizeSequence(e){return e==null?[]:Array.isArray(e)?e:[e]}resolveNode(e,t){return e&&typeof e=="object"&&"nodeType"in e?e:t.node}toBoolean(e){return e==null?!1:typeof e=="boolean"?e:typeof e=="number"?e!==0&&!isNaN(e):typeof e=="string"||Array.isArray(e)?e.length>0:!!e}}});var M,be=g(()=>{je();M=class{constructor(e,t=v,n,r){this.name=e;this.namespace=t;this.baseType=n;this.primitive=r}get qualifiedName(){return`{${this.namespace}}${this.name}`}}});var Dr={};ze(Dr,{ITEM_TYPE:()=>st,OccurrenceIndicator:()=>Me,SequenceType:()=>Ge,createAtomicSequenceType:()=>at,createEmptySequenceType:()=>ot,createItemSequenceType:()=>de});function ot(){return new Ge("empty","ONE")}function de(s,e="ONE"){return new Ge(s,e)}function at(s,e="ONE"){let t={name:s.name,namespace:s.namespace,atomicType:s,matches:n=>{if(n==null)return!1;try{return s.validate(n)}catch(r){return!1}}};return new Ge(t,e)}var Me,Ge,st,Qe=g(()=>{Me=(r=>(r.EXACTLY_ONE="ONE",r.ZERO_OR_ONE="?",r.ZERO_OR_MORE="*",r.ONE_OR_MORE="+",r))(Me||{}),Ge=class{constructor(e,t="ONE"){if(e==="empty"&&t!=="ONE")throw new Error("empty-sequence() must have exactly one occurrence");this.itemType=e,this.occurrence=t}getItemType(){return this.itemType}getOccurrence(){return this.occurrence}isEmptySequence(){return this.itemType==="empty"}allowsZeroItems(){return this.isEmptySequence()||this.occurrence==="?"||this.occurrence==="*"}allowsMultipleItems(){return this.occurrence==="*"||this.occurrence==="+"}requiresItems(){return!this.allowsZeroItems()}toString(){if(this.isEmptySequence())return"empty-sequence()";let e=this.itemType.name,t=this.occurrence==="ONE"?"":this.occurrence;return e+t}getMinCardinality(){return this.isEmptySequence()||this.allowsZeroItems()?0:1}getMaxCardinality(){return this.allowsMultipleItems()?1/0:1}isCompatibleWith(e){if(e.isEmptySequence())return this.allowsZeroItems();let t=e.getMinCardinality(),n=e.getMaxCardinality(),r=this.getMinCardinality(),i=this.getMaxCardinality();if(t<r||n>i&&i!==1/0)return!1;if(this.itemType!=="empty"&&e.itemType!=="empty"){let o=this.itemType,a=e.itemType;return o.isWildcard?!0:o.name===a.name}return this.itemType==="empty"?e.isEmptySequence():!0}},st={name:"item()",isWildcard:!0,matches:()=>!0}});var Xe,Yn,Gn,Qn,Kn,Hn,Jn,Zn,lc,$i=g(()=>{Xe=class{constructor(e,t,n,r,i){this.name=e,this.nodeKind=t,this.nodeName=n,this.nodeType=r,this.isWildcardName=i}matches(e){return!(!e||typeof e!="object"||e.nodeType!==this.nodeKind||this.nodeName&&!this.isWildcardName&&e.localName!==this.nodeName&&e.nodeName!==this.nodeName||this.nodeType&&e.type!==this.nodeType)}},Yn=class extends Xe{constructor(){super("node()","node")}matches(){return!0}},Gn=class extends Xe{constructor(e,t){let n=e?t?`element(${e}, ${t})`:`element(${e})`:"element()";super(n,"element",e,t,!e)}},Qn=class extends Xe{constructor(e,t){let n=e?t?`attribute(${e}, ${t})`:`attribute(${e})`:"attribute()";super(n,"attribute",e,t,!e)}},Kn=class extends Xe{constructor(e){let t=e?`document-node(${e.name})`:"document-node()";super(t,"document",void 0,void 0,!0),this.elementTest=e}matches(e){return super.matches(e)?this.elementTest&&e.documentElement?this.elementTest.matches(e.documentElement):!0:!1}},Hn=class extends Xe{constructor(){super("text()","text")}},Jn=class extends Xe{constructor(){super("comment()","comment")}},Zn=class extends Xe{constructor(e){let t=e?`processing-instruction(${e})`:"processing-instruction()";super(t,"processing-instruction",e,void 0,!e)}},lc={node:new Yn,element:new Gn,attribute:new Qn,documentNode:new Kn,text:new Hn,comment:new Jn,processingInstruction:new Zn}});var er={};ze(er,{UnionItemType:()=>ct,createUnionType:()=>Li,isUnionType:()=>Ui});function Li(...s){return new ct(s)}function Ui(s){return s instanceof ct}var ct,$t=g(()=>{ct=class s{constructor(e){this.isWildcard=!1;if(e.length===0)throw new Error("Union type must have at least one member type");if(e.length===1)throw new Error("Union type must have at least two member types (use the single type directly)");if(e.some(t=>t==="empty"))throw new Error("empty-sequence() cannot be used in union types");this.memberTypes=e,this.name=e.map(t=>t.name).join(" | ")}matches(e){return this.memberTypes.some(t=>t.matches(e))}getMemberTypes(){return[...this.memberTypes]}containsType(e){return this.memberTypes.some(t=>t.name===e)}flatten(){let e=[];for(let n of this.memberTypes)if(n instanceof s){let r=n.flatten();e.push(...r.memberTypes)}else e.push(n);let t=e.filter((n,r,i)=>i.findIndex(o=>o.name===n.name)===r);return new s(t)}getMostGeneralAtomicType(){let e=this.memberTypes.filter(i=>i.atomicType!==void 0).map(i=>i.atomicType);return e.length===0?void 0:e.some(i=>i.name==="string")?e.find(i=>i.name==="string"):e.some(i=>i.name==="double")?e.find(i=>i.name==="double"):e.some(i=>i.name==="decimal")?e.find(i=>i.name==="decimal"):e[0]}toString(){return this.name}}});function Wi(s,e){let{isUnionType:t}=($t(),U(er));if(t(e))return e.matches(s);let n=e.isMapTest,r=e.isArrayTest,i=e.isFunctionTest;return n||r||i?e.matches(s):e.isWildcard?s!=null:e.matches(s)}function Se(s,e){let t=Array.isArray(s)?s:[s].filter(c=>c!==void 0);if(t.length===0)return e.isEmptySequence()?{matches:!0,itemCount:0}:e.allowsZeroItems()?{matches:!0,itemCount:0}:{matches:!1,itemCount:0,reason:`Empty sequence not allowed by ${e.toString()}`};if(e.isEmptySequence())return{matches:!1,itemCount:t.length,reason:`Expected empty sequence but got ${t.length} item(s)`};let n=e.getItemType();if(n==="empty")return{matches:!1,itemCount:t.length,reason:"Expected empty sequence"};let r=n,i=t.findIndex(c=>!Wi(c,r));if(i!==-1){let c=t[i],u;try{typeof c=="object"&&c!==null?u=JSON.stringify(c):u=String(c)}catch(l){u="[complex value]"}return{matches:!1,itemCount:t.length,reason:`Item ${i} (${u}) does not match ${r.name}`}}let o=e.getOccurrence(),a=t.length;switch(o){case"ONE":return a===1?{matches:!0,itemCount:a}:{matches:!1,itemCount:a,reason:`Expected exactly one item but got ${a}`};case"?":return a<=1?{matches:!0,itemCount:a}:{matches:!1,itemCount:a,reason:`Expected zero or one item but got ${a}`};case"*":return{matches:!0,itemCount:a};case"+":return a>=1?{matches:!0,itemCount:a}:{matches:!1,itemCount:0,reason:"Expected one or more items but got none"};default:return{matches:!1,itemCount:a,reason:`Unknown occurrence indicator: ${o}`}}}var tr=g(()=>{Qe()});function qi(s){return!s||typeof s!="object"?!1:typeof s.nodeType=="string"||typeof s.nodeName=="string"||typeof s.textContent=="string"}function Bi(s){return!s.childNodes||s.childNodes.length===0?!1:s.childNodes.every(e=>e.nodeType==="element")}function zi(s){if(s.typedValue!==void 0){if(s.type){let e=ye(s.type);return{value:s.typedValue,type:e}}return{value:s.typedValue,type:void 0}}if(s.type){let e=ye(s.type),t=nr(s);if(e)try{return{value:e.cast(t),type:e}}catch(n){return{value:t,type:void 0}}}return{value:nr(s),type:void 0}}function nr(s){if(s.nodeType==="text"||s.nodeType==="attribute"||s.nodeType==="comment")return s.value||s.textContent||"";if(s.nodeType==="processing-instruction")return s.value||"";if(s.nodeType==="element"||s.nodeType==="document"){if(s.textContent)return s.textContent;if(!s.childNodes)return"";let e="";for(let t of s.childNodes)t.nodeType==="text"?e+=t.value||t.textContent||"":t.nodeType==="element"&&(e+=nr(t));return e}return""}function rr(s,e=!1){if(s==null)return{values:[],type:void 0,isEmpty:!0};if(Array.isArray(s)){let t=[],n,r=!1,i="";for(let o of s){let a=rr(o,e);if(a.error){r=!0,i=a.error;break}t.push(...a.values),a.type&&!n&&(n=a.type)}return{values:t,type:n,isEmpty:t.length===0,error:r?i:void 0}}if(qi(s)){if(e&&Bi(s))return{values:[],type:void 0,isEmpty:!1,error:"FOTY0012"};let{value:t,type:n}=zi(s);return{values:t!==void 0?[t]:[],type:n,isEmpty:t===void 0}}return{values:[s],type:void 0,isEmpty:!1}}var Vr=g(()=>{ke()});function Q(s){return s&&typeof s=="object"&&s.__isMap===!0}var ut,De=g(()=>{Vr();_e();ut=class{constructor(e){this.entries=e}evaluate(e){let t={};for(let n of this.entries){let r=n.key.evaluate(e),i=rr(r);if(i.error)throw pe("atomic value","value with error","map key");if(i.isEmpty||i.values.length===0)throw pe("atomic value","empty sequence","map key");if(i.values.length>1)throw pe("single atomic value","sequence","map key");let o=i.values[0],a=String(o),c=n.value.evaluate(e);t[a]=c}return this.createMap(t)}createMap(e){let t=Object.create(null);return t.__isMap=!0,Object.assign(t,e),t}}});function re(s){return s&&typeof s=="object"&&s.__isArray===!0}function B(s){return{__isArray:!0,members:s}}function pc(s){return s.members.length}function Fr(s,e){if(e<1||e>s.members.length)throw new Error(`FOAY0001: Array index ${e} out of bounds (array size: ${s.members.length})`);return s.members[e-1]}var lt,pt,Ve=g(()=>{lt=class{constructor(e){this.items=e}evaluate(e){let t=[];for(let n of this.items){let r=n.evaluate(e);t.push(r)}return B(t)}toString(){return`[${this.items.map(t=>t.toString()).join(", ")}]`}},pt=class{constructor(e){this.expr=e}evaluate(e){let t=this.expr.evaluate(e),n=this.toSequence(t);return B(n)}toSequence(e){return e==null?[]:Array.isArray(e)?e:re(e)?[e]:[e]}toString(){return`array { ${this.expr.toString()} }`}}});var Lt={};ze(Lt,{createTypedArrayTest:()=>Yi,createTypedMapTest:()=>ji,isTypedArrayTest:()=>Qi,isTypedMapTest:()=>Gi});function ji(s,e){let t=s===null&&e===null;return{name:hc(s,e),isMapTest:!0,keyType:s,valueType:e,isWildcard:t,namespace:void 0,matches(r){if(!Q(r))return!1;if(t)return!0;let i=Object.entries(r).filter(([o])=>!o.startsWith("_")&&!o.startsWith("__"));for(let[o,a]of i)if(s!==null&&!Se(o,s).matches||e!==null&&!Se(a,e).matches)return!1;return!0}}}function Yi(s){let e=s===null;return{name:mc(s),isArrayTest:!0,memberType:s,isWildcard:e,namespace:void 0,matches(n){if(!re(n))return!1;if(e)return!0;let r=n.members||[];for(let i of r)if(!Se(i,s).matches)return!1;return!0}}}function hc(s,e){if(s===null&&e===null)return"map(*)";let t=s?s.toString():"*",n=e?e.toString():"*";return`map(${t}, ${n})`}function mc(s){return s===null?"array(*)":`array(${s.toString()})`}function Gi(s){return s.isMapTest===!0}function Qi(s){return s.isArrayTest===!0}var ht=g(()=>{De();Ve();tr()});var Ki=g(()=>{ke()});var Ut,Wt,qt,Bt,mt=g(()=>{be();Ut=class extends M{constructor(){super("anyAtomicType",v)}validate(e){return e!=null&&typeof e!="object"}cast(e){return e}},Wt=class extends M{constructor(e){super("untypedAtomic",v,e,e)}validate(e){return typeof e=="string"}cast(e){return String(e)}},qt=class extends M{constructor(e){super("string",v,e,void 0)}validate(e){return typeof e=="string"}cast(e){if(e==null)throw new Error("Cannot cast null or undefined to xs:string");return String(e)}},Bt=class extends M{constructor(e){super("boolean",v,e,void 0)}validate(e){return typeof e=="boolean"}cast(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1;throw new Error(`Cannot cast "${e}" to xs:boolean`)}if(typeof e=="number"){if(e===0)return!1;if(e===1)return!0;throw new Error(`Cannot cast ${e} to xs:boolean`)}throw new Error(`Cannot cast ${typeof e} to xs:boolean`)}}});var zt,jt,Yt,Gt,ft=g(()=>{be();zt=class extends M{constructor(e){super("decimal",v,e,void 0)}validate(e){return typeof e=="number"?isFinite(e):!1}cast(e){if(typeof e=="number"&&isFinite(e))return e;if(typeof e=="string"){let t=parseFloat(e);if(!isFinite(t))throw new Error(`Cannot cast "${e}" to xs:decimal`);return t}if(typeof e=="boolean")return e?1:0;throw new Error(`Cannot cast ${typeof e} to xs:decimal`)}},jt=class extends M{constructor(e){super("float",v,e,void 0)}validate(e){return typeof e=="number"}cast(e){if(typeof e=="number")return e;if(typeof e=="string"){if(e==="INF")return 1/0;if(e==="-INF")return-1/0;if(e==="NaN")return NaN;let t=parseFloat(e);if(isNaN(t))throw new Error(`Cannot cast "${e}" to xs:float`);return t}if(typeof e=="boolean")return e?1:0;throw new Error(`Cannot cast ${typeof e} to xs:float`)}},Yt=class extends M{constructor(e){super("double",v,e,void 0)}validate(e){return typeof e=="number"}cast(e){if(typeof e=="number")return e;if(typeof e=="string"){if(e==="INF")return 1/0;if(e==="-INF")return-1/0;if(e==="NaN")return NaN;let t=parseFloat(e);if(isNaN(t))throw new Error(`Cannot cast "${e}" to xs:double`);return t}if(typeof e=="boolean")return e?1:0;throw new Error(`Cannot cast ${typeof e} to xs:double`)}},Gt=class extends M{constructor(e,t){super("integer",v,e,t)}validate(e){return typeof e=="number"&&Number.isInteger(e)&&isFinite(e)}cast(e){let t=this.baseType.cast(e),n=Math.trunc(t);if(!isFinite(n))throw new Error(`Cannot cast ${e} to xs:integer`);return n}}});function Hi(s){let e=s.match(/^(-)?P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/);if(!e)throw new Error(`Invalid duration format: "${s}"`);if(!e.slice(2).some(i=>i!==void 0))throw new Error(`Invalid duration format: "${s}"`);let n=!!e[1],r=n?-1:1;return{negative:n,years:r*(parseInt(e[2])||0),months:r*(parseInt(e[3])||0),days:r*(parseInt(e[4])||0),hours:r*(parseInt(e[5])||0),minutes:r*(parseInt(e[6])||0),seconds:r*(parseFloat(e[7])||0)}}function Ji(s){let e=s.match(/^(\d{2}):(\d{2}):(\d{2}(?:\.\d+)?)(?:Z|([+-])(\d{2}):(\d{2}))?$/);if(!e)throw new Error(`Invalid time format: "${s}"`);let t=parseInt(e[1],10),n=parseInt(e[2],10),r=parseFloat(e[3]);if(t<0||t>23)throw new Error(`Invalid hours value: ${t}`);if(n<0||n>59)throw new Error(`Invalid minutes value: ${n}`);if(r<0||r>=60)throw new Error(`Invalid seconds value: ${r}`);let i;return e[4]&&(i={sign:e[4],hours:parseInt(e[5],10),minutes:parseInt(e[6],10)}),{hours:t,minutes:n,seconds:r,timezone:i}}var Qt,Kt,Ht,Jt,Ke=g(()=>{be();Qt=class extends M{constructor(e){super("duration",v,e,void 0)}validate(e){return typeof e=="object"&&e!==null&&"years"in e}cast(e){if(this.validate(e))return e;if(typeof e=="string")return Hi(e);throw new Error(`Cannot cast ${typeof e} to xs:duration`)}},Kt=class extends M{constructor(e){super("dateTime",v,e,void 0)}validate(e){return e instanceof Date}cast(e){if(e instanceof Date)return e;if(typeof e=="string"){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid dateTime value: "${e}"`);return t}throw new Error(`Cannot cast ${typeof e} to xs:dateTime`)}},Ht=class extends M{constructor(e,t){super("date",v,e,t)}validate(e){return e instanceof Date}cast(e){let t=this.baseType.cast(e),n=new Date(t);return n.setHours(0,0,0,0),n}},Jt=class extends M{constructor(e,t){super("time",v,e,t)}validate(e){return typeof e=="object"&&e!==null&&"hours"in e}cast(e){if(this.validate(e))return e;if(typeof e=="string")return Ji(e);throw new Error(`Cannot cast ${typeof e} to xs:time`)}}});var Zt,en,tn,nn,rn,He=g(()=>{be();Zt=class extends M{constructor(e){super("gYearMonth",v,e,void 0)}validate(e){return typeof e=="object"&&e!==null&&"year"in e&&"month"in e}cast(e){if(this.validate(e))return e;if(typeof e=="string"){let t=e.match(/^(-?\d{4})-(\d{2})$/);if(!t)throw new Error(`Invalid gYearMonth format: "${e}"`);let n=parseInt(t[1],10),r=parseInt(t[2],10);if(r<1||r>12)throw new Error(`Invalid month value: ${r}`);return{year:n,month:r}}throw new Error(`Cannot cast ${typeof e} to xs:gYearMonth`)}},en=class extends M{constructor(e){super("gYear",v,e,void 0)}validate(e){return typeof e=="object"&&e!==null&&"year"in e}cast(e){if(this.validate(e))return e;if(typeof e=="string"){let t=e.match(/^(-?\d{4})$/);if(!t)throw new Error(`Invalid gYear format: "${e}"`);return{year:parseInt(t[1],10)}}throw new Error(`Cannot cast ${typeof e} to xs:gYear`)}},tn=class extends M{constructor(e){super("gMonthDay",v,e,void 0)}validate(e){return typeof e=="object"&&e!==null&&"month"in e&&"day"in e}cast(e){if(this.validate(e))return e;if(typeof e=="string"){let t=e.match(/^--(\d{2})-(\d{2})$/);if(!t)throw new Error(`Invalid gMonthDay format: "${e}"`);let n=parseInt(t[1],10),r=parseInt(t[2],10);if(n<1||n>12)throw new Error(`Invalid month value: ${n}`);if(r<1||r>31)throw new Error(`Invalid day value: ${r}`);return{month:n,day:r}}throw new Error(`Cannot cast ${typeof e} to xs:gMonthDay`)}},nn=class extends M{constructor(e){super("gDay",v,e,void 0)}validate(e){return typeof e=="object"&&e!==null&&"day"in e}cast(e){if(this.validate(e))return e;if(typeof e=="string"){let t=e.match(/^---(\d{2})$/);if(!t)throw new Error(`Invalid gDay format: "${e}"`);let n=parseInt(t[1],10);if(n<1||n>31)throw new Error(`Invalid day value: ${n}`);return{day:n}}throw new Error(`Cannot cast ${typeof e} to xs:gDay`)}},rn=class extends M{constructor(e){super("gMonth",v,e,void 0)}validate(e){return typeof e=="object"&&e!==null&&"month"in e}cast(e){if(this.validate(e))return e;if(typeof e=="string"){let t=e.match(/^--(\d{2})$/);if(!t)throw new Error(`Invalid gMonth format: "${e}"`);let n=parseInt(t[1],10);if(n<1||n>12)throw new Error(`Invalid month value: ${n}`);return{month:n}}throw new Error(`Cannot cast ${typeof e} to xs:gMonth`)}}});var sn,on,ir=g(()=>{be();sn=class extends M{constructor(e){super("hexBinary",v,e,void 0)}validate(e){return typeof e=="string"?/^[0-9A-Fa-f]*$/.test(e)&&e.length%2===0:e instanceof Uint8Array}cast(e){if(typeof e=="string"){if(!this.validate(e))throw new Error(`Invalid hexBinary format: "${e}"`);return e.toUpperCase()}if(e instanceof Uint8Array)return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("").toUpperCase();throw new Error(`Cannot cast ${typeof e} to xs:hexBinary`)}},on=class extends M{constructor(e){super("base64Binary",v,e,void 0)}validate(e){return typeof e=="string"?/^[A-Za-z0-9+/]*={0,2}$/.test(e)&&e.length%4===0:e instanceof Uint8Array}cast(e){if(typeof e=="string"){if(!this.validate(e))throw new Error(`Invalid base64Binary format: "${e}"`);return e}if(e instanceof Uint8Array){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="",r=0,i=e.length;for(;r<i;){let o=e[r++],a=r<i,c=a?e[r++]:0,u=r<i,l=u?e[r++]:0,p=o<<16|c<<8|l;n+=t[p>>18&63],n+=t[p>>12&63],n+=a?t[p>>6&63]:"=",n+=u?t[p&63]:"="}return n}throw new Error(`Cannot cast ${typeof e} to xs:base64Binary`)}}});var an,cn,sr=g(()=>{be();an=class extends M{constructor(e){super("anyURI",v,e,void 0)}validate(e){return typeof e=="string"}cast(e){if(typeof e=="string")return e;throw new Error(`Cannot cast ${typeof e} to xs:anyURI`)}},cn=class extends M{constructor(e){super("QName",v,e,void 0)}validate(e){return typeof e=="object"&&e!==null&&"localName"in e&&"namespaceURI"in e}cast(e){if(this.validate(e))return e;if(typeof e=="string"){let t=e.split(":");if(t.length===1)return{localName:t[0],namespaceURI:"",prefix:void 0};if(t.length===2)return{localName:t[1],namespaceURI:"",prefix:t[0]}}throw new Error(`Cannot cast ${typeof e} to xs:QName`)}}});var K,$r=g(()=>{be();K=class extends M{constructor(t,n,r,i,o){super(t,v,n,r);this.min=i;this.max=o}validate(t){return!(typeof t!="number"||!Number.isInteger(t)||!isFinite(t)||!Number.isSafeInteger(t)||this.min!==void 0&&t<this.min||this.max!==void 0&&t>this.max)}cast(t){let n=this.baseType.cast(t);if(!Number.isSafeInteger(n))throw new Error(`Value ${n} is not a safe integer for ${this.name}`);if(this.min!==void 0&&n<this.min)throw new Error(`Value ${n} is below minimum ${this.min} for ${this.name}`);if(this.max!==void 0&&n>this.max)throw new Error(`Value ${n} is above maximum ${this.max} for ${this.name}`);return n}}});var ss={};ze(ss,{ARRAY_NAMESPACE:()=>is,FN_NAMESPACE:()=>un,MAP_NAMESPACE:()=>rs,MATH_NAMESPACE:()=>ln,createFunctionItem:()=>Zi,createFunctionTest:()=>es,createFunctionType:()=>ts,describeFunctionType:()=>ns,isFunctionItem:()=>ge});function Zi(s,e,t,n,r){return{__isFunctionItem:!0,implementation:s,arity:e,name:t,namespace:n,type:r}}function es(s=null,e=null,t){var o,a;let n=(o=t==null?void 0:t.isWildcard)!=null?o:s===null&&e===null,r=Array.isArray(s)?s.length:void 0;return{name:n?"function(*)":`function(${(a=s==null?void 0:s.map(c=>c.toString()).join(", "))!=null?a:""})`+(e?` as ${e.toString()}`:""),isFunctionTest:!0,isWildcard:n,parameterTypes:s!=null?s:void 0,returnType:e!=null?e:void 0,matches(c){if(c==null)return!1;let u=typeof c=="object"&&c.__isFunctionItem===!0||typeof c=="function",l=typeof c=="object"&&(c==null?void 0:c.__isMap)===!0,p=typeof c=="object"&&(c==null?void 0:c.__isArray)===!0;if(!u&&!l&&!p)return!1;if(n)return!0;if(r!==void 0){let h=l||p?1:typeof c=="function"?c.length:typeof(c==null?void 0:c.arity)=="number"?c.arity:void 0;if(h!==void 0&&h!==r)return!1}return!0}}}function ge(s){return s&&typeof s=="object"&&s.__isFunctionItem===!0}function ts(s,e){return{kind:"function",parameterTypes:s,returnType:e,arity:s.length}}function ns(s){return`function(${s.parameterTypes.map(t=>String(t)).join(", ")}) as ${s.returnType}`}var un,ln,rs,is,pn=g(()=>{un="http://www.w3.org/2005/xpath-functions",ln="http://www.w3.org/2005/xpath-functions/math",rs="http://www.w3.org/2005/xpath-functions/map",is="http://www.w3.org/2005/xpath-functions/array"});var os=g(()=>{});var as=g(()=>{os()});function ye(s){return kc[s]}function O(s,e){let t=ye(e);if(!t)throw new Error(`Unknown atomic type: ${e}`);return t.cast(s)}var z,fc,dc,yc,ie,gc,xc,Nc,hn,Ec,bc,Pc,Tc,Xc,Sc,Cc,wc,Ac,Oc,vc,or,cs,us,ls,Rc,ps,Ic,Lr,_c,hs,ms,fs,Mc,kc,ke=g(()=>{be();be();Qe();$i();tr();ht();$t();Ki();Vr();mt();ft();Ke();Ke();He();ir();sr();$r();pn();as();mt();mt();mt();mt();ft();ft();ft();ft();Ke();Ke();Ke();Ke();He();He();He();He();He();ir();ir();sr();sr();$r();z=new Ut,fc=new Wt(z),dc=new qt(z),yc=new Bt(z),ie=new zt(z),gc=new jt(z),xc=new Yt(z),Nc=new Qt(z),hn=new Kt(z),Ec=new Ht(hn,hn),bc=new Jt(hn,hn),Pc=new an(z),Tc=new cn(z),Xc=new Zt(z),Sc=new en(z),Cc=new tn(z),wc=new nn(z),Ac=new rn(z),Oc=new sn(z),vc=new on(z),or=new Gt(ie,ie),cs=new K("long",or,ie,-9223372036854776e3,9223372036854776e3),us=new K("int",cs,ie,-2147483648,2147483647),ls=new K("short",us,ie,-32768,32767),Rc=new K("byte",ls,ie,-128,127),ps=new K("nonPositiveInteger",or,ie,void 0,0),Ic=new K("negativeInteger",ps,ie,void 0,-1),Lr=new K("nonNegativeInteger",or,ie,0,void 0),_c=new K("positiveInteger",Lr,ie,1,void 0),hs=new K("unsignedLong",Lr,ie,0,18446744073709552e3),ms=new K("unsignedInt",hs,ie,0,4294967295),fs=new K("unsignedShort",ms,ie,0,65535),Mc=new K("unsignedByte",fs,ie,0,255),kc={anyAtomicType:z,untypedAtomic:fc,string:dc,boolean:yc,decimal:ie,float:gc,double:xc,integer:or,duration:Nc,dateTime:hn,date:Ec,time:bc,anyURI:Pc,QName:Tc,gYearMonth:Xc,gYear:Sc,gMonthDay:Cc,gDay:wc,gMonth:Ac,hexBinary:Oc,base64Binary:vc,long:cs,int:us,short:ls,byte:Rc,nonPositiveInteger:ps,negativeInteger:Ic,nonNegativeInteger:Lr,positiveInteger:_c,unsignedLong:hs,unsignedInt:ms,unsignedShort:fs,unsignedByte:Mc}});var mn,ds=g(()=>{ke();_();mn=class extends N{constructor(t,n){super();this.expression=t;this.sequenceType=n}evaluate(t){let n=this.expression.evaluate(t);return Se(n,this.sequenceType).matches}}});var fn,ys=g(()=>{ke();Qe();_();fn=class extends N{constructor(t,n){super();this.expression=t;this.sequenceType=n}evaluate(t){let n=this.expression.evaluate(t),r=Array.isArray(n)?n:n==null?[]:[n];if(r.length>1)return!1;if(r.length===0)return this.sequenceType.getOccurrence()==="?";let i=r[0],o=this.sequenceType.getItemType();if(o==="empty"||!o.atomicType)return!1;try{return O(i,o.atomicType.name),!0}catch(a){return!1}}}});var dn,gs=g(()=>{_();tr();dn=class extends N{constructor(t,n){super();this.expression=t;this.sequenceType=n}evaluate(t){var i;let n=this.expression.evaluate(t),r=Se(n,this.sequenceType);if(!r.matches){let o=(i=r.reason)!=null?i:`Value does not match ${this.sequenceType.toString()}`;throw new Error(`Treat expression type mismatch: ${o}`)}return n}}});var Ce,xs=g(()=>{_();Ce=class extends N{constructor(e,t){super(),this.left=e,this.right=t}evaluate(e){let t=this.left.evaluate(e),n=this.right.evaluate(e),r=Array.isArray(t)?t:[],i=Array.isArray(n)?n:[];return this.unionNodes(r,i)}unionNodes(e,t){let n=new Set,r=[];for(let i of e)n.has(i)||(n.add(i),r.push(i));for(let i of t)n.has(i)||(n.add(i),r.push(i));return this.sortByDocumentOrder(r)}sortByDocumentOrder(e){return e.sort((t,n)=>{if(t===n)return 0;if(typeof t.compareDocumentPosition=="function"){let r=t.compareDocumentPosition(n);if(r&4)return-1;if(r&2)return 1}return 0})}}});function Dc(s){let e;return s==null?e=[]:Array.isArray(s)?e=s:e=[s],{items:e,isEmpty:()=>e.length===0,first:()=>e[0],last:()=>e[e.length-1],length:()=>e.length}}function Vc(s){return s==null?[]:Array.isArray(s)?s:[s]}function Fc(...s){let e=[];for(let t of s)Array.isArray(t)?e.push(...t):t!=null&&e.push(t);return e}function Ns(s){return!s||typeof s!="object"?!1:typeof s.nodeType=="string"||typeof s.nodeName=="string"||typeof s.textContent=="string"}function $c(s){return Ns(s)?`${s.nodeType}:${s.nodeName||s.localName||""}:${s.__id||""}`:String(s)}var yn,gn,xn,Ur,Es=g(()=>{_();yn=class extends N{constructor(t){super();this.operands=t;if(t.length<2)throw new Error("CommaExpression requires at least 2 operands")}evaluate(t){let n=[];for(let r of this.operands){let i=r.evaluate(t);Array.isArray(i)?n.push(...i):i!=null&&n.push(i)}return n.length>0?n:[]}getOperands(){return this.operands}toString(){return this.operands.map(t=>t.toString()).join(", ")}},gn=class extends N{constructor(t,n){super();this.startExpr=t;this.endExpr=n}evaluate(t){let n=this.startExpr.evaluate(t),r=this.endExpr.evaluate(t),i,o;try{let c=Array.isArray(n)?n[0]:n,u=Array.isArray(r)?r[0]:r;i=this.toInteger(c),o=this.toInteger(u)}catch(c){throw new Error(`Range expression operands must be integers: ${String(c)}`)}if(i>o)return[];let a=[];for(let c=i;c<=o;c++)a.push(c);return a}toInteger(t){if(typeof t=="number")return Math.trunc(t);if(typeof t=="string"){let n=parseInt(t,10);if(isNaN(n))throw new Error(`Cannot convert "${t}" to integer`);return n}if(typeof t=="boolean")return t?1:0;throw new Error(`Cannot convert ${typeof t} to integer`)}toString(){return`${this.startExpr.toString()} to ${this.endExpr.toString()}`}},xn=class extends N{evaluate(e){return[]}toString(){return"empty-sequence()"}},Ur=class extends N{constructor(t){super();this.operand=t}evaluate(t){return this.operand.evaluate(t)}getOperand(){return this.operand}toString(){return`(${this.operand.toString()})`}}});var Nn,bs=g(()=>{_();Nn=class extends N{constructor(e){super(),this.expression=e}evaluate(e){return this.expression.evaluate(e)}test(e){let t=this.evaluate(e);return typeof t=="number"?t===(e==null?void 0:e.position):this.toBoolean(t)}toBoolean(e){return typeof e=="boolean"?e:typeof e=="number"?e!==0&&!isNaN(e):typeof e=="string"||Array.isArray(e)?e.length>0:!!e}}});var Wr,Ps=g(()=>{_();Wr=class extends N{constructor(t,n,r){super();this.left=t;this.operator=n;this.right=r}evaluate(t){let n=this.left.evaluate(t),r=this.right.evaluate(t),i=this.atomize(n),o=this.atomize(r);if(i===void 0||o===void 0)throw new Error("Value comparison requires non-empty sequences");return this.compare(i,o,this.operator)}atomize(t){if(t!=null){if(Array.isArray(t)){if(t.length===0)return;if(t.length===1)return t[0];throw new Error("Value comparison requires single atomic values")}return this.isNode(t)?this.getNodeStringValue(t):t}}compare(t,n,r){let[i,o]=this.promoteTypes(t,n);switch(r){case"eq":return this.equal(i,o);case"ne":return!this.equal(i,o);case"lt":return this.lessThan(i,o);case"le":return this.lessThan(i,o)||this.equal(i,o);case"gt":return this.greaterThan(i,o);case"ge":return this.greaterThan(i,o)||this.equal(i,o);default:throw new Error(`Unknown comparison operator: ${r}`)}}promoteTypes(t,n){return typeof t=="number"&&typeof n=="number"?[t,n]:typeof t=="number"?[t,this.toNumber(n)]:typeof n=="number"?[this.toNumber(t),n]:typeof t=="string"&&typeof n=="string"?[t,n]:typeof t=="string"?[t,this.valueToString(n)]:typeof n=="string"?[this.valueToString(t),n]:typeof t=="boolean"||typeof n=="boolean"?[this.toBoolean(t),this.toBoolean(n)]:[t,n]}equal(t,n){return typeof t!=typeof n||typeof t=="number"&&isNaN(t)&&isNaN(n)?!1:t===n}lessThan(t,n){if(typeof t=="number"&&typeof n=="number"||typeof t=="string"&&typeof n=="string")return t<n;throw new Error(`Cannot compare ${typeof t} with ${typeof n}`)}greaterThan(t,n){if(typeof t=="number"&&typeof n=="number"||typeof t=="string"&&typeof n=="string")return t>n;throw new Error(`Cannot compare ${typeof t} with ${typeof n}`)}toNumber(t){if(typeof t=="number")return t;if(typeof t=="boolean")return t?1:0;if(typeof t=="string"){let n=parseFloat(t);return isNaN(n)?NaN:n}return NaN}valueToString(t){return typeof t=="string"?t:typeof t=="number"?String(t):typeof t=="boolean"?t?"true":"false":this.isNode(t)?this.getNodeStringValue(t):String(t)}toBoolean(t){return typeof t=="boolean"?t:typeof t=="number"?t!==0&&!isNaN(t):typeof t=="string"||Array.isArray(t)?t.length>0:!!t}isNode(t){return t&&typeof t=="object"&&("nodeType"in t||"nodeName"in t)}getNodeStringValue(t){return t.textContent!==void 0?String(t.textContent):t.nodeValue!==void 0?String(t.nodeValue):t.value!==void 0?String(t.value):""}toString(){return`${this.left.toString()} ${this.operator} ${this.right.toString()}`}}});var qr,Ts=g(()=>{_();qr=class extends N{constructor(t,n,r){super();this.left=t;this.operator=n;this.right=r}evaluate(t){let n=this.left.evaluate(t),r=this.right.evaluate(t),i=this.flatten(n),o=this.flatten(r);if(i.length===0||o.length===0)return!1;for(let a of i)for(let c of o)if(this.compareValues(a,c,this.operator))return!0;return!1}flatten(t){if(t==null)return[];if(Array.isArray(t)){let n=[];for(let r of t)r!=null&&n.push(r);return n}return[t]}compareValues(t,n,r){let i=this.getComparableValue(t),o=this.getComparableValue(n),[a,c]=this.promoteTypes(i,o);switch(r){case"=":return this.equal(a,c);case"!=":return!this.equal(a,c);case"<":return this.lessThan(a,c);case"<=":return this.lessThan(a,c)||this.equal(a,c);case">":return this.greaterThan(a,c);case">=":return this.greaterThan(a,c)||this.equal(a,c);default:throw new Error(`Unknown comparison operator: ${r}`)}}getComparableValue(t){if(t!=null)return this.isNode(t)?this.getNodeStringValue(t):t}promoteTypes(t,n){return typeof t=="number"&&typeof n=="number"?[t,n]:typeof t=="number"?[t,this.toNumber(n)]:typeof n=="number"?[this.toNumber(t),n]:typeof t=="string"&&typeof n=="string"?[t,n]:typeof t=="string"?[t,this.valueToString(n)]:typeof n=="string"?[this.valueToString(t),n]:typeof t=="boolean"||typeof n=="boolean"?[this.toBoolean(t),this.toBoolean(n)]:[t,n]}equal(t,n){return typeof t!=typeof n||typeof t=="number"&&isNaN(t)&&isNaN(n)?!1:t===n}lessThan(t,n){if(typeof t=="number"&&typeof n=="number"||typeof t=="string"&&typeof n=="string")return t<n;throw new Error(`Cannot compare ${typeof t} with ${typeof n}`)}greaterThan(t,n){if(typeof t=="number"&&typeof n=="number"||typeof t=="string"&&typeof n=="string")return t>n;throw new Error(`Cannot compare ${typeof t} with ${typeof n}`)}toNumber(t){if(typeof t=="number")return t;if(typeof t=="boolean")return t?1:0;if(typeof t=="string"){let n=parseFloat(t);return isNaN(n)?NaN:n}return NaN}valueToString(t){return typeof t=="string"?t:typeof t=="number"?String(t):typeof t=="boolean"?t?"true":"false":this.isNode(t)?this.getNodeStringValue(t):String(t)}toBoolean(t){return typeof t=="boolean"?t:typeof t=="number"?t!==0&&!isNaN(t):typeof t=="string"||Array.isArray(t)?t.length>0:!!t}isNode(t){return t&&typeof t=="object"&&("nodeType"in t||"nodeName"in t)}getNodeStringValue(t){return t.textContent!==void 0?String(t.textContent):t.nodeValue!==void 0?String(t.nodeValue):t.value!==void 0?String(t.value):""}toString(){return`${this.left.toString()} ${this.operator} ${this.right.toString()}`}}});var Br,Xs=g(()=>{_();Br=class extends N{constructor(t,n,r){super();this.left=t;this.operator=n;this.right=r}evaluate(t){let n=this.left.evaluate(t),r=this.right.evaluate(t),i=this.extractNode(n),o=this.extractNode(r);if(!this.isNode(i)||!this.isNode(o))throw new Error("Node comparison requires node operands");switch(this.operator){case"is":return this.isIdentical(i,o);case"<<":return this.isDocumentOrderBefore(i,o);case">>":return this.isDocumentOrderAfter(i,o);default:throw new Error(`Unknown node comparison operator: ${this.operator}`)}}extractNode(t){if(t!=null){if(this.isNode(t))return t;if(Array.isArray(t))return t.length===0?void 0:(t.length===1,t[0])}}isIdentical(t,n){return t.__id!==void 0&&n.__id!==void 0?t.__id===n.__id:t===n}isDocumentOrderBefore(t,n){let r=this.getDocumentPosition(t),i=this.getDocumentPosition(n);return r!==-1&&i!==-1?r<i:this.compareDocumentOrder(t,n)<0}isDocumentOrderAfter(t,n){let r=this.getDocumentPosition(t),i=this.getDocumentPosition(n);return r!==-1&&i!==-1?r>i:this.compareDocumentOrder(t,n)>0}getDocumentPosition(t){return t.__documentPosition!==void 0?t.__documentPosition:-1}compareDocumentOrder(t,n){if(t===n)return 0;let r=this.getAncestors(t),i=this.getAncestors(n),o=0;for(;o<r.length&&o<i.length&&r[o]===i[o];)o++;if(o===r.length)return-1;if(o===i.length)return 1;let a=r[o],c=i[o],u=this.getChildPosition(a),l=this.getChildPosition(c);return u<l?-1:u>l?1:0}getAncestors(t){let n=[t],r=t;for(;r&&r.parentNode;)r=r.parentNode,n.unshift(r);return n}getChildPosition(t){if(!t.parentNode)return 0;let r=t.parentNode.childNodes||[];for(let i=0;i<r.length;i++)if(r[i]===t)return i;return-1}isNode(t){return t&&typeof t=="object"&&("nodeType"in t||"nodeName"in t)}toString(){return`${this.left.toString()} ${this.operator} ${this.right.toString()}`}}});var we,En=g(()=>{je();we=class{constructor(){this.elementId=0}convert(e,t){if(e==null)return null;typeof e!="string"&&(e=String(e));let n=e.trim();if(n==="")return null;try{let r=JSON.parse(n);return this.createDocumentNode(r,t)}catch(r){if(t!=null&&t.fallback&&typeof t.fallback=="function")try{let i=t.fallback(n);return this.createDocumentNode(i,t)}catch(i){return null}return t!=null&&t.liberal?this.liberalParse(n,t):null}}createDocumentNode(e,t){this.elementId=0;let n=this.valueToElement(e,"root",t),r={nodeType:Te.DOCUMENT_NODE,nodeName:"#document",localName:"#document",childNodes:[n],documentElement:n};return n.ownerDocument=r,r}valueToElement(e,t,n,r){let i={nodeType:Te.ELEMENT_NODE,nodeName:t,localName:t,childNodes:[],attributes:[]};if(e==null)return i;if(typeof e=="object"&&!Array.isArray(e)){let o=[],a=new Set;for(let c in e)if(Object.prototype.hasOwnProperty.call(e,c)){if(a.has(c)){if((n==null?void 0:n.duplicates)==="reject")throw new Error(`Duplicate key: ${c}`);if((n==null?void 0:n.duplicates)==="use-first")continue}a.add(c);let u=this.sanitizeElementName(c),l=this.valueToElement(e[c],u,n,i);o.push(l)}i.childNodes=o}else if(Array.isArray(e)){let o=e.map((a,c)=>this.valueToElement(a,"item",n,i));i.childNodes=o}else if(typeof e=="string"){let o={nodeType:Te.TEXT_NODE,nodeName:"#text",localName:"#text",textContent:e};i.childNodes=[o],i.textContent=e}else if(typeof e=="number"){let o=String(e),a={nodeType:Te.TEXT_NODE,nodeName:"#text",localName:"#text",textContent:o};i.childNodes=[a],i.textContent=o}else if(typeof e=="boolean"){let o=e?"true":"false",a={nodeType:Te.TEXT_NODE,nodeName:"#text",localName:"#text",textContent:o};i.childNodes=[a],i.textContent=o}return i}sanitizeElementName(e){if(/^[a-zA-Z_][\w.-]*$/.test(e))return e;let t=e.replace(/[^a-zA-Z0-9_.-]/g,"_");return/^[a-zA-Z_]/.test(t)||(t="_"+t),(!t||t==="_")&&(t="item"),t}liberalParse(e,t){try{let n=e.replace(/,(\s*[}\]])/g,"$1");n=n.replace(/'/g,'"');let r=JSON.parse(n);return this.createDocumentNode(r,t)}catch(n){return null}}}});function Ss(s,e,t){if(!ge(t))throw new Error("fn:for-each: second argument must be a function");let n=t;if(e==null)return[];let r=Array.isArray(e)?e:[e],i=[];for(let o of r){let a=n.implementation(o);Array.isArray(a)?i.push(...a):a!=null&&i.push(a)}return i.length===0?[]:i}function Cs(s,e,t){if(!ge(t))throw new Error("fn:filter: second argument must be a function");let n=t;if(e==null)return[];let i=(Array.isArray(e)?e:[e]).filter(o=>!!n.implementation(o));return i.length===0?[]:i}function ws(s,e,t,n){if(!ge(n))throw new Error("fn:fold-left: third argument must be a function");let r=n;if(e==null)return t;let i=Array.isArray(e)?e:[e],o=t;for(let a of i)o=r.implementation(o,a);return o}function As(s,e,t,n){if(!ge(n))throw new Error("fn:fold-right: third argument must be a function");let r=n;if(e==null)return t;let i=Array.isArray(e)?e:[e],o=t;for(let a=i.length-1;a>=0;a--)o=r.implementation(i[a],o);return o}function Os(s,e,t,n){if(!ge(n))throw new Error("fn:for-each-pair: third argument must be a function");let r=n;if(e==null||t===null||t===void 0)return[];let i=Array.isArray(e)?e:[e],o=Array.isArray(t)?t:[t],a=[],c=Math.min(i.length,o.length);for(let u=0;u<c;u++){let l=r.implementation(i[u],o[u]);Array.isArray(l)?a.push(...l):l!=null&&a.push(l)}return a.length===0?[]:a}function vs(s,e,t){if(!ge(e))throw new Error("fn:apply: first argument must be a function");let n=e;if(t==null)return n.implementation();let r=Array.isArray(t)?t:[t];return n.implementation(...r)}function Rs(s,e){if(!ge(e))throw new Error("fn:function-name: argument must be a function");let t=e;return t.name?t.namespace?`Q{${t.namespace}}${t.name}`:t.name:null}function Is(s,e){if(!ge(e))throw new Error("fn:function-arity: argument must be a function");return e.arity}var _s=g(()=>{pn()});function Ms(s){return Math.PI}function ks(s,e){let t=H(e);return Math.exp(t)}function Ds(s,e){let t=H(e);return Math.pow(10,t)}function Vs(s,e){let t=H(e);return Math.log(t)}function Fs(s,e){let t=H(e);return Math.log10(t)}function $s(s,e,t){let n=H(e),r=H(t);return Math.pow(n,r)}function Ls(s,e){let t=H(e);return Math.sqrt(t)}function Us(s,e){let t=H(e);return Math.sin(t)}function Ws(s,e){let t=H(e);return Math.cos(t)}function qs(s,e){let t=H(e);return Math.tan(t)}function Bs(s,e){let t=H(e);return Math.asin(t)}function zs(s,e){let t=H(e);return Math.acos(t)}function js(s,e){let t=H(e);return Math.atan(t)}function Ys(s,e,t){let n=H(e),r=H(t);return Math.atan2(n,r)}function H(s){return s==null?NaN:Array.isArray(s)?s.length===0?NaN:H(s[0]):Number(s)}var Gs=g(()=>{});function zr(s){return s==null?null:Array.isArray(s)?s.length>0?s[0]:null:s}function jr(s){return s==null?[]:Array.isArray(s)?s.length>1?s.slice(1):[]:[]}function Qs(s){return ar(s)}function Ks(s){let e=ar(s);if(e.length>1)throw pe("zero or one item",`sequence of ${e.length} items`,"fn:zero-or-one");return e.length===0?null:e[0]}function Hs(s){let e=ar(s);if(e.length===0)throw pe("one or more items","empty sequence","fn:one-or-more");return e}function Js(s){let e=ar(s);if(e.length!==1)throw pe("exactly one item",e.length===0?"empty sequence":`sequence of ${e.length} items`,"fn:exactly-one");return e[0]}function ar(s){return s==null?[]:Array.isArray(s)?s:[s]}var Yr=g(()=>{_e()});function eo(s,e){let t=Array.isArray(e)?e:e?[e]:[];return t.length===0?[]:t.filter(n=>dt(n)?!t.some(r=>!dt(r)||n===r?!1:ro(n,r)):!1)}function to(s,e){let t=Array.isArray(e)?e:e?[e]:[];return t.length===0?[]:t.filter(n=>dt(n)?!t.some(r=>!dt(r)||n===r?!1:ro(r,n)):!1)}function no(s,e,t,n){let r=Array.isArray(e)?e:e?[e]:[];if(r.length<=1)return e;let i=r.map((o,a)=>({item:o,index:a}));return n&&typeof n=="object"&&n.__isFunctionItem?i.sort((o,a)=>{let c=n.implementation(o.item),u=n.implementation(a.item);return Zs(c,u)}):i.sort((o,a)=>Zs(o.item,a.item)),i.map(o=>o.item)}function dt(s){return s!=null&&typeof s=="object"&&("nodeType"in s||"localName"in s)}function ro(s,e){if(!dt(s)||!dt(e))return!1;let t=e.parent||e.parentNode,n=0,r=1e4,i=new Set;for(;t&&n<r&&!i.has(t);){if(i.add(t),t===s)return!0;t=t.parent||t.parentNode,n++}return!1}function Zs(s,e){if(Array.isArray(s)&&s.length>0&&(s=s[0]),Array.isArray(e)&&e.length>0&&(e=e[0]),s==null&&e==null)return 0;if(s==null)return-1;if(e==null)return 1;if(typeof s=="number"&&typeof e=="number")return s-e;let t=String(s),n=String(e);return t.localeCompare(n)}var io=g(()=>{Yr()});function so(s,e){let t=String(e);if(typeof process!="undefined"&&process.env){let n=process.env[t];return n!==void 0?n:null}return null}function oo(s){return typeof process!="undefined"&&process.env?Object.keys(process.env):[]}var ao=g(()=>{});function lo(s,e,t,n){let r=e==null?"":String(e),i=String(t),o=n?String(n):"";try{let a="";o.includes("i")&&(a+="i"),o.includes("m")&&(a+="m"),o.includes("s")&&(a+="s"),o.includes("x")&&(a+="x");let c=new RegExp(i,a+"g"),u=[],l=0,p;for(;(p=c.exec(r))!==null;)p.index>l&&u.push({type:"non-match",value:r.substring(l,p.index)}),u.push({type:"match",value:p[0],groups:p.slice(1).map(h=>h||"")}),l=c.lastIndex;return l<r.length&&u.push({type:"non-match",value:r.substring(l)}),u.length===0&&u.push({type:"non-match",value:r}),u}catch(a){throw new Error(`Invalid regular expression: ${i}`)}}function po(s,e,t,n){if(e==null)return"";let r=Array.isArray(e)?e.length>0?Number(e[0]):0:Number(e),i=String(t),o=Math.floor(r),a=o<0,c=Math.abs(o);if(i==="1")return String(o);if(i==="01")return String(Math.abs(o)).padStart(2,"0");if(i==="a")return co(c,"a");if(i==="A")return co(c,"A");if(i==="i")return uo(c).toLowerCase();if(i==="I")return uo(c);if(i==="w")return Gr(c);if(i==="W")return Gr(c).replace(/^\w/,l=>l.toUpperCase());let u=i.match(/^(0+)$/);if(u){let l=u[1].length;return String(c).padStart(l,"0")}return String(o)}function ho(s,e,t,n){if(e==null)return"NaN";let r=Array.isArray(e)?e.length>0?Number(e[0]):NaN:Number(e);if(isNaN(r))return"NaN";if(!isFinite(r))return r>0?"Infinity":"-Infinity";let o=String(t).split("."),a=o[0]||"0",c=o[1]||"",u=(a.match(/0/g)||[]).length,l=(c.match(/0/g)||[]).length,p=c.length,h;if(l>0||p>0){let E=Math.max(l,Math.min(p,6));h=r.toFixed(E)}else h=String(Math.round(r));let[m,d]=h.split("."),y=m.padStart(u,"0");return d!==void 0?`${y}.${d}`:y}function co(s,e){if(s<=0)return"";let t=e.charCodeAt(0),n="",r=s;for(;r>0;)r--,n=String.fromCharCode(t+r%26)+n,r=Math.floor(r/26);return n}function uo(s){if(s<=0||s>=4e3)return String(s);let e=[{value:1e3,numeral:"M"},{value:900,numeral:"CM"},{value:500,numeral:"D"},{value:400,numeral:"CD"},{value:100,numeral:"C"},{value:90,numeral:"XC"},{value:50,numeral:"L"},{value:40,numeral:"XL"},{value:10,numeral:"X"},{value:9,numeral:"IX"},{value:5,numeral:"V"},{value:4,numeral:"IV"},{value:1,numeral:"I"}],t="",n=s;for(let{value:r,numeral:i}of e)for(;n>=r;)t+=i,n-=r;return t}function Gr(s){if(s===0)return"zero";if(s<0)return"negative "+Gr(-s);let e=["","one","two","three","four","five","six","seven","eight","nine"],t=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],n=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],r=["","thousand","million","billion","trillion"],i="",o=0;for(;s>0;){let a=s%1e3;a!==0&&(i=zc(a,e,t,n)+(r[o]?" "+r[o]:"")+(i?" ":"")+i),s=Math.floor(s/1e3),o++}return i.trim()}function zc(s,e,t,n){let r="",i=Math.floor(s/100);i>0&&(r+=e[i]+" hundred");let o=s%100;if(o>=20){r&&(r+=" ");let a=Math.floor(o/10),c=o%10;r+=n[a],c>0&&(r+=" "+e[c])}else o>=10?(r&&(r+=" "),r+=t[o-10]):o>0&&(r&&(r+=" "),r+=e[o]);return r}var mo=g(()=>{});function J(s,e){if(Array.isArray(s)&&!re(s))if(s.length===1)s=s[0];else throw s.length===0?new Error(`XPTY0004: ${e} requires an array, got empty sequence`):new Error(`XPTY0004: ${e} requires a single array, got sequence of ${s.length} items`);if(!re(s))throw new Error(`XPTY0004: ${e} requires an array, got ${typeof s}`);return s}function fo(s,e,t){if(!Number.isInteger(e))throw new Error(`XPTY0004: ${t} position must be an integer, got ${e}`);if(e<1||e>s.members.length)throw new Error(`FOAY0001: ${t} position ${e} is out of bounds (array size: ${s.members.length})`)}function yo(s,e){return J(e,"array:size").members.length}function go(s,e,t){let n=J(e,"array:get");return fo(n,t,"array:get"),n.members[t-1]}function xo(s,e,t,n){let r=J(e,"array:put");fo(r,t,"array:put");let i=[...r.members];return i[t-1]=n,B(i)}function No(s,e,t){let n=J(e,"array:append");return B([...n.members,t])}function Eo(s,e,t,n){let r=J(e,"array:subarray");if(!Number.isInteger(t))throw new Error(`XPTY0004: array:subarray start must be an integer, got ${t}`);if(t<1)throw new Error(`FOAY0001: array:subarray start ${t} must be >= 1`);if(t>r.members.length+1)throw new Error(`FOAY0001: array:subarray start ${t} is out of bounds (array size: ${r.members.length})`);let i=t-1;if(n===void 0)return B(r.members.slice(i));if(!Number.isInteger(n))throw new Error(`XPTY0004: array:subarray length must be an integer, got ${n}`);if(n<0)throw new Error(`FOAY0002: array:subarray length ${n} must be >= 0`);if(i+n>r.members.length)throw new Error(`FOAY0001: array:subarray range [${t}, ${t+n-1}] exceeds array bounds`);return B(r.members.slice(i,i+n))}function bo(s,e,t){let n=J(e,"array:remove"),r=Array.isArray(t)?t:[t];for(let a of r){if(!Number.isInteger(a))throw new Error(`XPTY0004: array:remove position must be an integer, got ${a}`);if(a<1||a>n.members.length)throw new Error(`FOAY0001: array:remove position ${a} is out of bounds (array size: ${n.members.length})`)}let i=new Set(r.map(a=>a-1)),o=n.members.filter((a,c)=>!i.has(c));return B(o)}function Po(s,e,t,n){let r=J(e,"array:insert-before");if(!Number.isInteger(t))throw new Error(`XPTY0004: array:insert-before position must be an integer, got ${t}`);if(t<1||t>r.members.length+1)throw new Error(`FOAY0001: array:insert-before position ${t} is out of bounds (valid range: 1 to ${r.members.length+1})`);let i=[...r.members];return i.splice(t-1,0,n),B(i)}function To(s,e){let t=J(e,"array:head");if(t.members.length===0)throw new Error("FOAY0001: array:head called on empty array");return t.members[0]}function Xo(s,e){let t=J(e,"array:tail");if(t.members.length===0)throw new Error("FOAY0001: array:tail called on empty array");return B(t.members.slice(1))}function So(s,e){let t=J(e,"array:reverse");return B([...t.members].reverse())}function Co(s,e){let t=Array.isArray(e)?e:[e],n=[];for(let r of t){if(r==null)continue;let i=J(r,"array:join");n.push(...i.members)}return B(n)}function wo(s,e){let t=[],n=r=>{if(re(r))for(let i of r.members)n(i);else if(Array.isArray(r))for(let i of r)n(i);else t.push(r)};return n(e),t}function Ao(s,e,t){let n=J(e,"array:for-each");if(!t||typeof t!="function"&&!t.__isFunctionItem)throw new Error("XPTY0004: array:for-each requires a function as second argument");let r=t.__isFunctionItem?t.implementation:t,i=n.members.map((o,a)=>r(o));return B(i)}function Oo(s,e,t){let n=J(e,"array:filter");if(!t||typeof t!="function"&&!t.__isFunctionItem)throw new Error("XPTY0004: array:filter requires a function as second argument");let r=t.__isFunctionItem?t.implementation:t,i=n.members.filter(o=>{let a=r(o);return typeof a=="boolean"?a:typeof a=="number"?a!==0&&!isNaN(a):typeof a=="string"||Array.isArray(a)?a.length>0:!!a});return B(i)}function vo(s,e,t,n){let r=J(e,"array:fold-left");if(!n||typeof n!="function"&&!n.__isFunctionItem)throw new Error("XPTY0004: array:fold-left requires a function as third argument");let i=n.__isFunctionItem?n.implementation:n,o=t;for(let a of r.members)o=i(o,a);return o}function Ro(s,e,t,n){let r=J(e,"array:fold-right");if(!n||typeof n!="function"&&!n.__isFunctionItem)throw new Error("XPTY0004: array:fold-right requires a function as third argument");let i=n.__isFunctionItem?n.implementation:n,o=t;for(let a=r.members.length-1;a>=0;a--)o=i(r.members[a],o);return o}function Io(s,e,t,n){let r=J(e,"array:sort"),i=n&&(n.__isFunctionItem?n.implementation:n),o=r.members.map((a,c)=>({member:a,idx:c}));return o.sort((a,c)=>{let u=i?i(a.member):a.member,l=i?i(c.member):c.member;if(Array.isArray(u)&&(u=u[0]),Array.isArray(l)&&(l=l[0]),typeof u=="number"&&typeof l=="number")return u-l;let p=String(u!=null?u:""),h=String(l!=null?l:""),m=p.localeCompare(h);return m!==0?m:a.idx-c.idx}),B(o.map(a=>a.member))}var _o=g(()=>{Ve()});function Fe(s,e){if(Array.isArray(s)&&!Q(s))if(s.length===1)s=s[0];else throw s.length===0?new Error(`XPTY0004: ${e} requires a map, got empty sequence`):new Error(`XPTY0004: ${e} requires a single map, got sequence of ${s.length} items`);if(!Q(s))throw new Error(`XPTY0004: ${e} requires a map, got ${typeof s}`);return s}function Mo(s){let e=Object.create(null);return e.__isMap=!0,Object.assign(e,s),e}function ko(s,e){let t=Fe(e,"map:size");return Object.keys(t).filter(n=>!n.startsWith("__")).length}function Do(s,e){let t=Fe(e,"map:keys");return Object.keys(t).filter(n=>!n.startsWith("__"))}function Vo(s,e,t){let n=Fe(e,"map:contains"),r=String(t);return Object.prototype.hasOwnProperty.call(n,r)}function Fo(s,e,t){let n=Fe(e,"map:get"),r=String(t);if(Object.prototype.hasOwnProperty.call(n,r))return n[r]}function $o(s,e,t,n){let r=Fe(e,"map:put"),i=String(t),o=Mo(r);return o[i]=n,o}function Lo(s,e,t){let n=String(e),r=Object.create(null);return r.__isMap=!0,r[n]=t,r}function Uo(s,e,t){let n=Array.isArray(e)?e:[e],r="use-last";t&&Q(t)&&t.duplicates!==void 0&&(r=String(t.duplicates));let i=["use-first","use-last","combine","reject"];if(!i.includes(r))throw new Error(`XPST0003: Invalid duplicates option '${r}'. Must be one of: ${i.join(", ")}`);let o=Object.create(null);o.__isMap=!0;let a={};for(let c of n){let u=Fe(c,"map:merge");for(let l of Object.keys(u))l.startsWith("__")||(a[l]||(a[l]=0),a[l]++,r==="use-first"?l in o||(o[l]=u[l]):r==="use-last"?o[l]=u[l]:r==="combine"?l in o?Array.isArray(o[l])?o[l].push(u[l]):o[l]=[o[l],u[l]]:o[l]=u[l]:r==="reject"&&(o[l]=u[l]))}if(r==="reject"){for(let c in a)if(a[c]>1)throw new Error(`XUST0003: Duplicate key '${c}' found in map:merge with duplicates='reject'`)}return o}function Wo(s,e,t){let n=Fe(e,"map:for-each");if(!t||typeof t!="function"&&!t.__isFunctionItem)throw new Error("XPTY0004: map:for-each requires a function as second argument");let r=t.__isFunctionItem?t.implementation:t,i=Object.create(null);i.__isMap=!0;for(let o of Object.keys(n)){if(o.startsWith("__"))continue;let a=n[o];i[o]=r(o,a)}return i}function qo(s,e,t){let n=Fe(e,"map:remove"),r=Array.isArray(t)?t:[t],i=new Set(r.map(a=>String(a))),o=Mo(n);for(let a of Array.from(i))Object.prototype.hasOwnProperty.call(o,a)&&delete o[a];return o}var Bo=g(()=>{De()});function Kr(s){if(s===null)return null;if(Array.isArray(s))return B(s.map(Kr));if(typeof s=="object"){let e=Object.create(null);e.__isMap=!0;for(let[t,n]of Object.entries(s))e[t]=Kr(n);return e}if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return s;throw new te("FOJS0001","Unsupported JSON value type")}function Qc(s){let e="",t=0,n=!1,r="",i=!1;for(;t<s.length;){let o=s[t],a=t+1<s.length?s[t+1]:"";if(n){if(i){e+=o,i=!1,t++;continue}if(o==="\\"){e+=o,i=!0,t++;continue}if(o===r){e+='"',n=!1,t++;continue}r==="'"&&o==='"'?e+='\\"':e+=o,t++;continue}if(o==='"'||o==="'"){n=!0,r=o,e+='"',t++;continue}if(o==="/"&&a==="/"){for(t+=2;t<s.length&&s[t]!==`
|
|
2
|
+
var XsltProcessor=(()=>{var zn=Object.defineProperty,Za=Object.defineProperties,ec=Object.getOwnPropertyDescriptor,tc=Object.getOwnPropertyDescriptors,nc=Object.getOwnPropertyNames,gi=Object.getOwnPropertySymbols;var Ni=Object.prototype.hasOwnProperty,rc=Object.prototype.propertyIsEnumerable;var xi=(s,e,t)=>e in s?zn(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,X=(s,e)=>{for(var t in e||(e={}))Ni.call(e,t)&&xi(s,t,e[t]);if(gi)for(var t of gi(e))rc.call(e,t)&&xi(s,t,e[t]);return s},I=(s,e)=>Za(s,tc(e));var g=(s,e)=>()=>(s&&(e=s(s=0)),e);var ze=(s,e)=>{for(var t in e)zn(s,t,{get:e[t],enumerable:!0})},ic=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of nc(e))!Ni.call(s,r)&&r!==t&&zn(s,r,{get:()=>e[r],enumerable:!(n=ec(e,r))||n.enumerable});return s};var U=s=>ic(zn({},"__esModule",{value:!0}),s);var b=(s,e,t)=>new Promise((n,r)=>{var i=c=>{try{a(t.next(c))}catch(u){r(u)}},o=c=>{try{a(t.throw(c))}catch(u){r(u)}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(i,o);a((t=t.apply(s,e)).next())});var N,_=g(()=>{N=class{}});var Ot,Rt,bi=g(()=>{_();Ot=class extends N{constructor(e){super(),this.value=e}evaluate(e){return this.value}toString(){return`"${this.value}"`}},Rt=class extends N{constructor(e){super(),this.value=e}evaluate(e){return this.value}toString(){return this.value.toString()}}});var Te,R,Pi,Ti,_r,Xi,je=g(()=>{Te={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_FRAGMENT_NODE:11,NAMESPACE_NODE:13},R="http://www.w3.org/2001/XMLSchema",Pi="http://www.w3.org/2005/xqt-errors",Ti="http://www.w3.org/2005/xpath-functions",_r="http://www.w3.org/2005/xpath-functions/collation/codepoint",Xi=["last","position","count","id","local-name","namespace-uri","name","string","concat","starts-with","contains","substring-before","substring-after","substring","string-length","normalize-space","translate","boolean","not","true","false","lang","number","sum","floor","ceiling","round"]});function ne(s){return new nt("XPST0003",`Grammar violation: ${s}`)}function vt(s,e="name"){return new nt("XPST0008",`Unresolved ${e} reference: ${s}`)}function Si(s){return new nt("XPST0010",`Unsupported axis: ${s}`)}function Ci(s,e,t){return new nt("XPST0017",`Function ${s} expects ${e}, got ${t} arguments`)}function pe(s,e,t){let n=t?`Type mismatch in ${t}: expected ${s}, got ${e}`:`Type mismatch: expected ${s}, got ${e}`;return new Mr("XPTY0004",n)}function wi(s,e){return new jn("FORG0001",`Cannot cast ${JSON.stringify(s)} to ${e}`)}var te,nt,jn,Mr,_e=g(()=>{je();te=class s extends Error{constructor(e,t,n=!1,r=!1){super(`${e}: ${t}`),Object.setPrototypeOf(this,s.prototype),this.code=e,this.isStatic=n,this.isDynamic=r,this.name="XPathError",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}getQName(){return`err:${this.code}`}getErrorURI(){return`${Pi}#${this.code}`}},nt=class s extends te{constructor(e,t){super(e,t,!0,!1),Object.setPrototypeOf(this,s.prototype),this.name="XPathStaticError"}},jn=class s extends te{constructor(e,t){super(e,t,!1,!0),Object.setPrototypeOf(this,s.prototype),this.name="XPathDynamicError"}},Mr=class s extends jn{constructor(e,t){super(e,t),Object.setPrototypeOf(this,s.prototype),this.name="XPathTypeError"}}});var xe,Ai=g(()=>{_();_e();xe=class extends N{constructor(e){super(),this.name=e}evaluate(e){if(!e.variables)throw vt(`$${this.name}`,"variable");if(!(this.name in e.variables))throw vt(`$${this.name}`,"variable");return e.variables[this.name]}toString(){return`$${this.name}`}}});var Ne,Oi=g(()=>{_();Ne=class extends N{constructor(e,t,n=[]){super(),this.axis=e,this.nodeTest=t,this.predicates=n}evaluate(e){let t=e==null?void 0:e.node;if(!t&&this.axis==="self"&&(e==null?void 0:e.contextItem)!==void 0){let r=e.contextItem;return this.predicates.length===0?[r]:this.applyPredicatesToAtomicItem(r,e)}if(!t)return[];let n=this.getNodesByAxis(t,e);return n=n.filter(r=>this.matchesNodeTest(r,e)),n=this.applyPredicates(n,e),n}applyPredicatesToAtomicItem(e,t){let n=I(X({},t),{contextItem:e,position:1,size:1});for(let r of this.predicates){let i=r.evaluate(n);if(typeof i=="number"){if(i!==1)return[]}else if(!this.toBoolean(i))return[]}return[e]}getNodesByAxis(e,t){switch(this.axis){case"child":return this.getChildNodes(e);case"parent":return e.parentNode?[e.parentNode]:[];case"self":return[e];case"attribute":return e.attributes?Array.from(e.attributes):Array.from(e.childNodes||[]).filter(n=>n.nodeType===2);case"descendant":return this.getDescendants(e,!1);case"descendant-or-self":return this.getDescendants(e,!0);case"ancestor":return this.getAncestors(e,!1);case"ancestor-or-self":return this.getAncestors(e,!0);case"following-sibling":return this.getFollowingSiblings(e);case"preceding-sibling":return this.getPrecedingSiblings(e);case"following":return this.getFollowing(e);case"preceding":return this.getPreceding(e);case"namespace":return this.getNamespaceNodes(e);case"self-and-siblings":return t!=null&&t.nodeList?t.nodeList.filter(n=>n.nodeType!==2):[e];default:return[]}}getChildNodes(e){return Array.from(e.childNodes||[]).filter(n=>n.nodeType!==2)}getDescendants(e,t){let n=[];t&&n.push(e);let r=i=>{for(let o of this.getChildNodes(i))n.push(o),r(o)};return r(e),n}getAncestors(e,t){let n=[];t&&n.push(e);let r=e.parentNode;for(;r;)n.push(r),r=r.parentNode;return n}getFollowingSiblings(e){let t=[],n=e.nextSibling;for(;n;)t.push(n),n=n.nextSibling;return t}getPrecedingSiblings(e){let t=[],n=e.previousSibling;for(;n;)t.unshift(n),n=n.previousSibling;return t}getFollowing(e){let t=[],n=e.nextSibling;for(;n;)t.push(n),t.push(...this.getDescendants(n,!1)),n=n.nextSibling;let r=e.parentNode;for(;r;){for(n=r.nextSibling;n;)t.push(n),t.push(...this.getDescendants(n,!1)),n=n.nextSibling;r=r.parentNode}return t}getPreceding(e){let t=[],n=e.previousSibling;for(;n;){t.unshift(n);let i=this.getDescendants(n,!1);t.unshift(...i),n=n.previousSibling}let r=e.parentNode;for(;r;){for(n=r.previousSibling;n;){t.unshift(n);let i=this.getDescendants(n,!1);t.unshift(...i),n=n.previousSibling}r=r.parentNode}return t}getNamespaceNodes(e){var r,i;if(!e||e.nodeType!==1)return[];let t={},n=e;for(;n;){let o=Array.from(n.attributes||[]);for(let a of o){let c=a.nodeName||a.localName||"",u=(i=(r=a.nodeValue)!=null?r:a.textContent)!=null?i:"";if(c==="xmlns")""in t||(t[""]=u);else if(c.startsWith("xmlns:")){let l=c.substring(6);l in t||(t[l]=u)}}n=n.parentNode}return"xml"in t||(t.xml="http://www.w3.org/XML/1998/namespace"),Object.entries(t).map(([o,a])=>({nodeType:13,nodeName:o,localName:o,prefix:o,namespaceURI:a,namespaceUri:a,nodeValue:a,textContent:a,parentNode:e,ownerDocument:e.ownerDocument}))}matchesNodeTest(e,t,n=this.nodeTest){var o,a;let r=e.nodeType,i=(c,u)=>{var h,m;if(!u.includes(r))return!1;if(c.endsWith(":*")){let d=c.slice(0,-2),y=(h=t==null?void 0:t.namespaces)==null?void 0:h[d];return y?(e.namespaceURI||e.namespaceUri||"")===y:!1}let l=c.indexOf(":");if(l>0){let d=c.substring(0,l),y=c.substring(l+1),E=(m=t==null?void 0:t.namespaces)==null?void 0:m[d];if(!E)return!1;let T=e.localName||e.nodeName&&this.extractLocalName(e.nodeName),P=e.namespaceURI||e.namespaceUri||"";return T===y&&P===E}return(e.localName||this.extractLocalName(e.nodeName))===c};switch(n.type){case"wildcard":if(n.name&&n.name.endsWith(":*")){let u=n.name.slice(0,-2),l=(o=t==null?void 0:t.namespaces)==null?void 0:o[u];if(!l)return!1;let p=e.namespaceURI||e.namespaceUri||"";return(r===1||r===2||r===13)&&p===l}return r===1||r===2||r===13;case"name":return i(n.name,[1,2,13]);case"element":return r!==1?!1:!n.name||n.isWildcardName?!0:i(n.name,[1]);case"attribute":return r!==2?!1:!n.name||n.isWildcardName?!0:i(n.name,[2]);case"schema-element":return i(n.name,[1]);case"schema-attribute":return i(n.name,[2]);case"document-node":if(r!==9)return!1;if(!n.elementTest)return!0;let c=e.documentElement||Array.from(e.childNodes||[]).find(u=>u.nodeType===1);return c?this.matchesNodeTest(c,t,n.elementTest):!1;case"node-type":switch(n.nodeType){case"node":return!0;case"text":return r===3;case"comment":return r===8;case"processing-instruction":return r===7;default:return!1}case"processing-instruction":return r!==7?!1:n.target?((a=e.target)!=null?a:e.nodeName)===n.target:!0;default:return!1}}applyPredicates(e,t){let n=e;for(let r of this.predicates){let i=[],o=n.length;for(let a=0;a<n.length;a++){let c=I(X({},t),{node:n[a],position:a+1,size:o}),u=r.evaluate(c);typeof u=="number"?u===a+1&&i.push(n[a]):this.toBoolean(u)&&i.push(n[a])}n=i}return n}toBoolean(e){return typeof e=="boolean"?e:typeof e=="number"?e!==0&&!isNaN(e):typeof e=="string"||Array.isArray(e)?e.length>0:!!e}extractLocalName(e){if(!e)return"";let t=e.indexOf(":");return t>0?e.substring(t+1):e}}});var Ee,Ri=g(()=>{_();Ee=class extends N{constructor(e,t=!1){super(),this.steps=e,this.absolute=t}evaluate(e){let t;if(this.absolute){let n=this.getDocumentRoot(e==null?void 0:e.node);t=n?[n]:[]}else e!=null&&e.node?t=[e.node]:(e==null?void 0:e.contextItem)!==void 0?t=[{__atomicContextItem:e.contextItem}]:t=[];for(let n of this.steps){let r=[];for(let i of t)if(i&&i.__atomicContextItem!==void 0){let o=I(X({},e),{contextItem:i.__atomicContextItem}),a=n.evaluate(o);r.push(...a)}else{let o=I(X({},e),{node:i}),a=n.evaluate(o);r.push(...a)}t=this.uniqueNodes(r)}return t}getDocumentRoot(e){if(!e)return null;let t=e;for(;t.parentNode;)t=t.parentNode;return t}uniqueNodes(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}}});var It,_t,vi=g(()=>{_();It=class extends N{constructor(e,t){super(),this.expression=e,this.predicates=t||[]}evaluate(e){let t=this.expression.evaluate(e);Array.isArray(t)||(t=t==null?[]:[t]);for(let n of this.predicates)t=this.applyPredicate(t,n,e);return t}applyPredicate(e,t,n){let r=[];for(let i=0;i<e.length;i++){let o=e[i],a=I(X({},n),{node:(o==null?void 0:o.nodeType)!==void 0?o:n.node,position:i+1,size:e.length});this.testPredicate(t,a)&&r.push(o)}return r}testPredicate(e,t){let n=e.evaluate(t);return typeof n=="number"?n===t.position:this.toBoolean(n)}toBoolean(e){return typeof e=="boolean"?e:typeof e=="number"?e!==0&&!isNaN(e):typeof e=="string"||Array.isArray(e)?e.length>0:e!=null}},_t=class extends N{constructor(e,t){super(),this.filterExpr=e,this.pathExpr=t}evaluate(e){let t=this.filterExpr.evaluate(e);if(!Array.isArray(t))return[];let n=[];for(let r of t){let i=I(X({},e),{node:(r==null?void 0:r.nodeType)!==void 0?r:e.node}),o=this.pathExpr.evaluate(i);Array.isArray(o)?n.push(...o):o!=null&&n.push(o)}return n}}});function Mt(s){var e;if(s==null||typeof s!="object"||typeof s.nodeType!="number")return null;if(s.nodeType===3||s.nodeType===2){let t=s.nodeValue;return t!=null&&t!=="null"?String(t):""}if(s.nodeType===1||s.nodeType===9){let t=s.childNodes;if(!t||t.length===0)return"";let n="";for(let r of t)if(r.nodeType===3){let i=r.nodeValue;i!=null&&i!=="null"&&(n+=String(i))}else r.nodeType===1&&(n+=(e=Mt(r))!=null?e:"");return n}return null}var kr=g(()=>{});var kt,Ii=g(()=>{_();kr();kt=class extends N{constructor(e,t){super(),this.operator=e,this.operand=t}evaluate(e){let t=this.operand.evaluate(e),n=this.atomize(t);if(n===null)return null;let r=this.toNumber(n);return this.operator==="+"?r:-r}atomize(e){if(e==null)return null;if(!Array.isArray(e)){let t=Mt(e);return t!==null?t:e}return e.length===0?null:this.atomize(e[0])}toNumber(e){if(typeof e=="number")return e;if(typeof e=="boolean")return e?1:0;if(typeof e=="string"){let t=e.trim();return t===""?NaN:Number(t)}return Number(e)}toString(){return`${this.operator}${this.operand.toString()}`}}});var rt,_i=g(()=>{_();rt=class extends N{constructor(e,t,n){super(),this.left=e,this.right=t,this.operator=n}evaluate(e){let t=this.left.evaluate(e),n=this.right.evaluate(e);return this.compare(t,n,this.operator)}compare(e,t,n){let r=Array.isArray(e),i=Array.isArray(t);return r&&i?this.compareNodeSets(e,t,n):r?this.compareNodeSetToValue(e,t,n):i?this.compareValueToNodeSet(e,t,n):this.comparePrimitives(e,t,n)}compareNodeSets(e,t,n){for(let r of e){let i=this.getStringValue(r);for(let o of t){let a=this.getStringValue(o);if(this.comparePrimitives(i,a,n))return!0}}return!1}compareNodeSetToValue(e,t,n){for(let r of e){let i=typeof t=="number"?Number(this.getStringValue(r)):this.getStringValue(r);if(this.comparePrimitives(i,t,n))return!0}return!1}compareValueToNodeSet(e,t,n){for(let r of t){let i=typeof e=="number"?Number(this.getStringValue(r)):this.getStringValue(r);if(this.comparePrimitives(e,i,n))return!0}return!1}comparePrimitives(e,t,n){switch(n){case"=":return e==t;case"!=":return e!=t;case"<":return Number(e)<Number(t);case">":return Number(e)>Number(t);case"<=":return Number(e)<=Number(t);case">=":return Number(e)>=Number(t);default:throw new Error(`Unknown operator: ${n}`)}}getStringValue(e){if(!e)return"";if(e.nodeType===3||e.nodeType===2)return e.nodeValue||e.textContent||"";if(e.textContent!==void 0)return e.textContent;if(e.childNodes){let t="";for(let n of Array.from(e.childNodes))n.nodeType===3?t+=n.nodeValue||"":n.nodeType===1&&(t+=this.getStringValue(n));return t}return String(e)}}});var Ye,Mi=g(()=>{_();kr();Ye=class extends N{constructor(e,t,n){super(),this.left=e,this.right=t,this.operator=n}evaluate(e){let t=this.left.evaluate(e),n=this.right.evaluate(e),r=this.atomize(t),i=this.atomize(n);if(r===null||i===null)return null;let o=this.toNumber(r),a=this.toNumber(i);switch(this.operator){case"+":return o+a;case"-":return o-a;case"*":return o*a;case"div":return o/a;case"idiv":if(a===0)throw new Error("XPDY0002: Integer division by zero");return Math.trunc(o/a);case"mod":if(a===0)throw new Error("XPDY0002: Modulo by zero");return o-Math.trunc(o/a)*a;default:throw new Error(`Unknown arithmetic operator: ${this.operator}`)}}atomize(e){if(e==null)return null;if(typeof e=="object"&&"numberValue"in e&&typeof e.numberValue=="function")return e.numberValue();if(!Array.isArray(e)){let t=Mt(e);return t!==null?t:e}return e.length===0?null:this.atomize(e[0])}toNumber(e){if(typeof e=="number")return e;if(typeof e=="boolean")return e?1:0;if(typeof e=="string"){let t=e.trim();return t===""?NaN:Number(t)}return Number(e)}toString(){return`${this.left.toString()} ${this.operator} ${this.right.toString()}`}}});var it,ki=g(()=>{_();it=class extends N{constructor(e,t,n){super(),this.left=e,this.right=t,this.operator=n}toBoolean(e){return e==null?!1:typeof e=="boolean"?e:Array.isArray(e)?e.length===0?!1:e.length===1?this.toBoolean(e[0]):!0:typeof e=="number"?e!==0&&!isNaN(e):typeof e=="string"?e.length>0:!!e}evaluate(e){let t=this.toBoolean(this.left.evaluate(e));if(this.operator==="and")return t?this.toBoolean(this.right.evaluate(e)):!1;if(this.operator==="or")return t?!0:this.toBoolean(this.right.evaluate(e));throw new Error(`Unknown logical operator: ${this.operator}`)}}});var Dt,Di=g(()=>{_();Dt=class extends N{constructor(e,t,n){super(),this.test=e,this.thenExpr=t,this.elseExpr=n}toBoolean(e){return e==null?!1:typeof e=="boolean"?e:Array.isArray(e)?e.length===0?!1:e.length===1?this.toBoolean(e[0]):!0:typeof e=="number"?e!==0&&!isNaN(e):typeof e=="string"?e.length>0:!!e}evaluate(e){return this.toBoolean(this.test.evaluate(e))?this.thenExpr.evaluate(e):this.elseExpr.evaluate(e)}}});var Vt,Vi=g(()=>{_();Vt=class extends N{constructor(e,t){super(),this.bindings=e,this.returnExpr=t}evaluate(e){let t=e.variables?X({},e.variables):{},n=I(X({},e),{variables:t}),r=[];return this.evaluateBinding(0,n,r),r}evaluateBinding(e,t,n){var a;if(e>=this.bindings.length){let c=this.returnExpr.evaluate(t);this.appendResult(n,c);return}let r=this.bindings[e],i=this.normalizeSequence(r.expression.evaluate(t)),o=i.length;for(let c=0;c<o;c++){let u=i[c],l=I(X({},(a=t.variables)!=null?a:{}),{[r.variable]:u}),p=I(X({},t),{variables:l,node:this.resolveNode(u,t),position:c+1,size:o});this.evaluateBinding(e+1,p,n)}}normalizeSequence(e){return e==null?[]:Array.isArray(e)?e:[e]}appendResult(e,t){if(t!=null){if(Array.isArray(t)){e.push(...t);return}e.push(t)}}resolveNode(e,t){return e&&typeof e=="object"&&"nodeType"in e?e:t.node}}});var Ft,Fi=g(()=>{_();Ft=class extends N{constructor(e,t,n){super(),this.quantifier=e,this.bindings=t,this.satisfiesExpr=n}evaluate(e){let t=e.variables?X({},e.variables):{},n=I(X({},e),{variables:t});return this.quantifier==="some"?this.evaluateSome(0,n):this.evaluateEvery(0,n)}evaluateSome(e,t){var i;if(e>=this.bindings.length)return this.toBoolean(this.satisfiesExpr.evaluate(t));let n=this.bindings[e],r=this.normalizeSequence(n.expression.evaluate(t));for(let o=0;o<r.length;o++){let a=r[o],c=I(X({},(i=t.variables)!=null?i:{}),{[n.variable]:a}),u=I(X({},t),{variables:c,node:this.resolveNode(a,t),position:o+1,size:r.length});if(this.evaluateSome(e+1,u))return!0}return!1}evaluateEvery(e,t){var i;if(e>=this.bindings.length)return this.toBoolean(this.satisfiesExpr.evaluate(t));let n=this.bindings[e],r=this.normalizeSequence(n.expression.evaluate(t));if(r.length===0)return!0;for(let o=0;o<r.length;o++){let a=r[o],c=I(X({},(i=t.variables)!=null?i:{}),{[n.variable]:a}),u=I(X({},t),{variables:c,node:this.resolveNode(a,t),position:o+1,size:r.length});if(!this.evaluateEvery(e+1,u))return!1}return!0}normalizeSequence(e){return e==null?[]:Array.isArray(e)?e:[e]}resolveNode(e,t){return e&&typeof e=="object"&&"nodeType"in e?e:t.node}toBoolean(e){return e==null?!1:typeof e=="boolean"?e:typeof e=="number"?e!==0&&!isNaN(e):typeof e=="string"||Array.isArray(e)?e.length>0:!!e}}});var M,be=g(()=>{je();M=class{constructor(e,t=R,n,r){this.name=e;this.namespace=t;this.baseType=n;this.primitive=r}get qualifiedName(){return`{${this.namespace}}${this.name}`}}});var Dr={};ze(Dr,{ITEM_TYPE:()=>st,OccurrenceIndicator:()=>Me,SequenceType:()=>Ge,createAtomicSequenceType:()=>at,createEmptySequenceType:()=>ot,createItemSequenceType:()=>de});function ot(){return new Ge("empty","ONE")}function de(s,e="ONE"){return new Ge(s,e)}function at(s,e="ONE"){let t={name:s.name,namespace:s.namespace,atomicType:s,matches:n=>{if(n==null)return!1;try{return s.validate(n)}catch(r){return!1}}};return new Ge(t,e)}var Me,Ge,st,Qe=g(()=>{Me=(r=>(r.EXACTLY_ONE="ONE",r.ZERO_OR_ONE="?",r.ZERO_OR_MORE="*",r.ONE_OR_MORE="+",r))(Me||{}),Ge=class{constructor(e,t="ONE"){if(e==="empty"&&t!=="ONE")throw new Error("empty-sequence() must have exactly one occurrence");this.itemType=e,this.occurrence=t}getItemType(){return this.itemType}getOccurrence(){return this.occurrence}isEmptySequence(){return this.itemType==="empty"}allowsZeroItems(){return this.isEmptySequence()||this.occurrence==="?"||this.occurrence==="*"}allowsMultipleItems(){return this.occurrence==="*"||this.occurrence==="+"}requiresItems(){return!this.allowsZeroItems()}toString(){if(this.isEmptySequence())return"empty-sequence()";let e=this.itemType.name,t=this.occurrence==="ONE"?"":this.occurrence;return e+t}getMinCardinality(){return this.isEmptySequence()||this.allowsZeroItems()?0:1}getMaxCardinality(){return this.allowsMultipleItems()?1/0:1}isCompatibleWith(e){if(e.isEmptySequence())return this.allowsZeroItems();let t=e.getMinCardinality(),n=e.getMaxCardinality(),r=this.getMinCardinality(),i=this.getMaxCardinality();if(t<r||n>i&&i!==1/0)return!1;if(this.itemType!=="empty"&&e.itemType!=="empty"){let o=this.itemType,a=e.itemType;return o.isWildcard?!0:o.name===a.name}return this.itemType==="empty"?e.isEmptySequence():!0}},st={name:"item()",isWildcard:!0,matches:()=>!0}});var Xe,Yn,Gn,Qn,Kn,Hn,Jn,Zn,lc,$i=g(()=>{Xe=class{constructor(e,t,n,r,i){this.name=e,this.nodeKind=t,this.nodeName=n,this.nodeType=r,this.isWildcardName=i}matches(e){return!(!e||typeof e!="object"||e.nodeType!==this.nodeKind||this.nodeName&&!this.isWildcardName&&e.localName!==this.nodeName&&e.nodeName!==this.nodeName||this.nodeType&&e.type!==this.nodeType)}},Yn=class extends Xe{constructor(){super("node()","node")}matches(){return!0}},Gn=class extends Xe{constructor(e,t){let n=e?t?`element(${e}, ${t})`:`element(${e})`:"element()";super(n,"element",e,t,!e)}},Qn=class extends Xe{constructor(e,t){let n=e?t?`attribute(${e}, ${t})`:`attribute(${e})`:"attribute()";super(n,"attribute",e,t,!e)}},Kn=class extends Xe{constructor(e){let t=e?`document-node(${e.name})`:"document-node()";super(t,"document",void 0,void 0,!0),this.elementTest=e}matches(e){return super.matches(e)?this.elementTest&&e.documentElement?this.elementTest.matches(e.documentElement):!0:!1}},Hn=class extends Xe{constructor(){super("text()","text")}},Jn=class extends Xe{constructor(){super("comment()","comment")}},Zn=class extends Xe{constructor(e){let t=e?`processing-instruction(${e})`:"processing-instruction()";super(t,"processing-instruction",e,void 0,!e)}},lc={node:new Yn,element:new Gn,attribute:new Qn,documentNode:new Kn,text:new Hn,comment:new Jn,processingInstruction:new Zn}});var er={};ze(er,{UnionItemType:()=>ct,createUnionType:()=>Li,isUnionType:()=>Ui});function Li(...s){return new ct(s)}function Ui(s){return s instanceof ct}var ct,$t=g(()=>{ct=class s{constructor(e){this.isWildcard=!1;if(e.length===0)throw new Error("Union type must have at least one member type");if(e.length===1)throw new Error("Union type must have at least two member types (use the single type directly)");if(e.some(t=>t==="empty"))throw new Error("empty-sequence() cannot be used in union types");this.memberTypes=e,this.name=e.map(t=>t.name).join(" | ")}matches(e){return this.memberTypes.some(t=>t.matches(e))}getMemberTypes(){return[...this.memberTypes]}containsType(e){return this.memberTypes.some(t=>t.name===e)}flatten(){let e=[];for(let n of this.memberTypes)if(n instanceof s){let r=n.flatten();e.push(...r.memberTypes)}else e.push(n);let t=e.filter((n,r,i)=>i.findIndex(o=>o.name===n.name)===r);return new s(t)}getMostGeneralAtomicType(){let e=this.memberTypes.filter(i=>i.atomicType!==void 0).map(i=>i.atomicType);return e.length===0?void 0:e.some(i=>i.name==="string")?e.find(i=>i.name==="string"):e.some(i=>i.name==="double")?e.find(i=>i.name==="double"):e.some(i=>i.name==="decimal")?e.find(i=>i.name==="decimal"):e[0]}toString(){return this.name}}});function Wi(s,e){let{isUnionType:t}=($t(),U(er));if(t(e))return e.matches(s);let n=e.isMapTest,r=e.isArrayTest,i=e.isFunctionTest;return n||r||i?e.matches(s):e.isWildcard?s!=null:e.matches(s)}function Se(s,e){let t=Array.isArray(s)?s:[s].filter(c=>c!==void 0);if(t.length===0)return e.isEmptySequence()?{matches:!0,itemCount:0}:e.allowsZeroItems()?{matches:!0,itemCount:0}:{matches:!1,itemCount:0,reason:`Empty sequence not allowed by ${e.toString()}`};if(e.isEmptySequence())return{matches:!1,itemCount:t.length,reason:`Expected empty sequence but got ${t.length} item(s)`};let n=e.getItemType();if(n==="empty")return{matches:!1,itemCount:t.length,reason:"Expected empty sequence"};let r=n,i=t.findIndex(c=>!Wi(c,r));if(i!==-1){let c=t[i],u;try{typeof c=="object"&&c!==null?u=JSON.stringify(c):u=String(c)}catch(l){u="[complex value]"}return{matches:!1,itemCount:t.length,reason:`Item ${i} (${u}) does not match ${r.name}`}}let o=e.getOccurrence(),a=t.length;switch(o){case"ONE":return a===1?{matches:!0,itemCount:a}:{matches:!1,itemCount:a,reason:`Expected exactly one item but got ${a}`};case"?":return a<=1?{matches:!0,itemCount:a}:{matches:!1,itemCount:a,reason:`Expected zero or one item but got ${a}`};case"*":return{matches:!0,itemCount:a};case"+":return a>=1?{matches:!0,itemCount:a}:{matches:!1,itemCount:0,reason:"Expected one or more items but got none"};default:return{matches:!1,itemCount:a,reason:`Unknown occurrence indicator: ${o}`}}}var tr=g(()=>{Qe()});function qi(s){return!s||typeof s!="object"?!1:typeof s.nodeType=="string"||typeof s.nodeName=="string"||typeof s.textContent=="string"}function Bi(s){return!s.childNodes||s.childNodes.length===0?!1:s.childNodes.every(e=>e.nodeType==="element")}function zi(s){if(s.typedValue!==void 0){if(s.type){let e=ye(s.type);return{value:s.typedValue,type:e}}return{value:s.typedValue,type:void 0}}if(s.type){let e=ye(s.type),t=nr(s);if(e)try{return{value:e.cast(t),type:e}}catch(n){return{value:t,type:void 0}}}return{value:nr(s),type:void 0}}function nr(s){if(s.nodeType==="text"||s.nodeType==="attribute"||s.nodeType==="comment")return s.value||s.textContent||"";if(s.nodeType==="processing-instruction")return s.value||"";if(s.nodeType==="element"||s.nodeType==="document"){if(s.textContent)return s.textContent;if(!s.childNodes)return"";let e="";for(let t of s.childNodes)t.nodeType==="text"?e+=t.value||t.textContent||"":t.nodeType==="element"&&(e+=nr(t));return e}return""}function rr(s,e=!1){if(s==null)return{values:[],type:void 0,isEmpty:!0};if(Array.isArray(s)){let t=[],n,r=!1,i="";for(let o of s){let a=rr(o,e);if(a.error){r=!0,i=a.error;break}t.push(...a.values),a.type&&!n&&(n=a.type)}return{values:t,type:n,isEmpty:t.length===0,error:r?i:void 0}}if(qi(s)){if(e&&Bi(s))return{values:[],type:void 0,isEmpty:!1,error:"FOTY0012"};let{value:t,type:n}=zi(s);return{values:t!==void 0?[t]:[],type:n,isEmpty:t===void 0}}return{values:[s],type:void 0,isEmpty:!1}}var Vr=g(()=>{ke()});function Q(s){return s&&typeof s=="object"&&s.__isMap===!0}var ut,De=g(()=>{Vr();_e();ut=class{constructor(e){this.entries=e}evaluate(e){let t={};for(let n of this.entries){let r=n.key.evaluate(e),i=rr(r);if(i.error)throw pe("atomic value","value with error","map key");if(i.isEmpty||i.values.length===0)throw pe("atomic value","empty sequence","map key");if(i.values.length>1)throw pe("single atomic value","sequence","map key");let o=i.values[0],a=String(o),c=n.value.evaluate(e);t[a]=c}return this.createMap(t)}createMap(e){let t=Object.create(null);return t.__isMap=!0,Object.assign(t,e),t}}});function re(s){return s&&typeof s=="object"&&s.__isArray===!0}function B(s){return{__isArray:!0,members:s}}function pc(s){return s.members.length}function Fr(s,e){if(e<1||e>s.members.length)throw new Error(`FOAY0001: Array index ${e} out of bounds (array size: ${s.members.length})`);return s.members[e-1]}var lt,pt,Ve=g(()=>{lt=class{constructor(e){this.items=e}evaluate(e){let t=[];for(let n of this.items){let r=n.evaluate(e);t.push(r)}return B(t)}toString(){return`[${this.items.map(t=>t.toString()).join(", ")}]`}},pt=class{constructor(e){this.expr=e}evaluate(e){let t=this.expr.evaluate(e),n=this.toSequence(t);return B(n)}toSequence(e){return e==null?[]:Array.isArray(e)?e:re(e)?[e]:[e]}toString(){return`array { ${this.expr.toString()} }`}}});var Lt={};ze(Lt,{createTypedArrayTest:()=>Yi,createTypedMapTest:()=>ji,isTypedArrayTest:()=>Qi,isTypedMapTest:()=>Gi});function ji(s,e){let t=s===null&&e===null;return{name:hc(s,e),isMapTest:!0,keyType:s,valueType:e,isWildcard:t,namespace:void 0,matches(r){if(!Q(r))return!1;if(t)return!0;let i=Object.entries(r).filter(([o])=>!o.startsWith("_")&&!o.startsWith("__"));for(let[o,a]of i)if(s!==null&&!Se(o,s).matches||e!==null&&!Se(a,e).matches)return!1;return!0}}}function Yi(s){let e=s===null;return{name:mc(s),isArrayTest:!0,memberType:s,isWildcard:e,namespace:void 0,matches(n){if(!re(n))return!1;if(e)return!0;let r=n.members||[];for(let i of r)if(!Se(i,s).matches)return!1;return!0}}}function hc(s,e){if(s===null&&e===null)return"map(*)";let t=s?s.toString():"*",n=e?e.toString():"*";return`map(${t}, ${n})`}function mc(s){return s===null?"array(*)":`array(${s.toString()})`}function Gi(s){return s.isMapTest===!0}function Qi(s){return s.isArrayTest===!0}var ht=g(()=>{De();Ve();tr()});var Ki=g(()=>{ke()});var Ut,Wt,qt,Bt,mt=g(()=>{be();Ut=class extends M{constructor(){super("anyAtomicType",R)}validate(e){return e!=null&&typeof e!="object"}cast(e){return e}},Wt=class extends M{constructor(e){super("untypedAtomic",R,e,e)}validate(e){return typeof e=="string"}cast(e){return String(e)}},qt=class extends M{constructor(e){super("string",R,e,void 0)}validate(e){return typeof e=="string"}cast(e){if(e==null)throw new Error("Cannot cast null or undefined to xs:string");return String(e)}},Bt=class extends M{constructor(e){super("boolean",R,e,void 0)}validate(e){return typeof e=="boolean"}cast(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1;throw new Error(`Cannot cast "${e}" to xs:boolean`)}if(typeof e=="number"){if(e===0)return!1;if(e===1)return!0;throw new Error(`Cannot cast ${e} to xs:boolean`)}throw new Error(`Cannot cast ${typeof e} to xs:boolean`)}}});var zt,jt,Yt,Gt,ft=g(()=>{be();zt=class extends M{constructor(e){super("decimal",R,e,void 0)}validate(e){return typeof e=="number"?isFinite(e):!1}cast(e){if(typeof e=="number"&&isFinite(e))return e;if(typeof e=="string"){let t=parseFloat(e);if(!isFinite(t))throw new Error(`Cannot cast "${e}" to xs:decimal`);return t}if(typeof e=="boolean")return e?1:0;throw new Error(`Cannot cast ${typeof e} to xs:decimal`)}},jt=class extends M{constructor(e){super("float",R,e,void 0)}validate(e){return typeof e=="number"}cast(e){if(typeof e=="number")return e;if(typeof e=="string"){if(e==="INF")return 1/0;if(e==="-INF")return-1/0;if(e==="NaN")return NaN;let t=parseFloat(e);if(isNaN(t))throw new Error(`Cannot cast "${e}" to xs:float`);return t}if(typeof e=="boolean")return e?1:0;throw new Error(`Cannot cast ${typeof e} to xs:float`)}},Yt=class extends M{constructor(e){super("double",R,e,void 0)}validate(e){return typeof e=="number"}cast(e){if(typeof e=="number")return e;if(typeof e=="string"){if(e==="INF")return 1/0;if(e==="-INF")return-1/0;if(e==="NaN")return NaN;let t=parseFloat(e);if(isNaN(t))throw new Error(`Cannot cast "${e}" to xs:double`);return t}if(typeof e=="boolean")return e?1:0;throw new Error(`Cannot cast ${typeof e} to xs:double`)}},Gt=class extends M{constructor(e,t){super("integer",R,e,t)}validate(e){return typeof e=="number"&&Number.isInteger(e)&&isFinite(e)}cast(e){let t=this.baseType.cast(e),n=Math.trunc(t);if(!isFinite(n))throw new Error(`Cannot cast ${e} to xs:integer`);return n}}});function Hi(s){let e=s.match(/^(-)?P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/);if(!e)throw new Error(`Invalid duration format: "${s}"`);if(!e.slice(2).some(i=>i!==void 0))throw new Error(`Invalid duration format: "${s}"`);let n=!!e[1],r=n?-1:1;return{negative:n,years:r*(parseInt(e[2])||0),months:r*(parseInt(e[3])||0),days:r*(parseInt(e[4])||0),hours:r*(parseInt(e[5])||0),minutes:r*(parseInt(e[6])||0),seconds:r*(parseFloat(e[7])||0)}}function Ji(s){let e=s.match(/^(\d{2}):(\d{2}):(\d{2}(?:\.\d+)?)(?:Z|([+-])(\d{2}):(\d{2}))?$/);if(!e)throw new Error(`Invalid time format: "${s}"`);let t=parseInt(e[1],10),n=parseInt(e[2],10),r=parseFloat(e[3]);if(t<0||t>23)throw new Error(`Invalid hours value: ${t}`);if(n<0||n>59)throw new Error(`Invalid minutes value: ${n}`);if(r<0||r>=60)throw new Error(`Invalid seconds value: ${r}`);let i;return e[4]&&(i={sign:e[4],hours:parseInt(e[5],10),minutes:parseInt(e[6],10)}),{hours:t,minutes:n,seconds:r,timezone:i}}var Qt,Kt,Ht,Jt,Ke=g(()=>{be();Qt=class extends M{constructor(e){super("duration",R,e,void 0)}validate(e){return typeof e=="object"&&e!==null&&"years"in e}cast(e){if(this.validate(e))return e;if(typeof e=="string")return Hi(e);throw new Error(`Cannot cast ${typeof e} to xs:duration`)}},Kt=class extends M{constructor(e){super("dateTime",R,e,void 0)}validate(e){return e instanceof Date}cast(e){if(e instanceof Date)return e;if(typeof e=="string"){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid dateTime value: "${e}"`);return t}throw new Error(`Cannot cast ${typeof e} to xs:dateTime`)}},Ht=class extends M{constructor(e,t){super("date",R,e,t)}validate(e){return e instanceof Date}cast(e){let t=this.baseType.cast(e),n=new Date(t);return n.setHours(0,0,0,0),n}},Jt=class extends M{constructor(e,t){super("time",R,e,t)}validate(e){return typeof e=="object"&&e!==null&&"hours"in e}cast(e){if(this.validate(e))return e;if(typeof e=="string")return Ji(e);throw new Error(`Cannot cast ${typeof e} to xs:time`)}}});var Zt,en,tn,nn,rn,He=g(()=>{be();Zt=class extends M{constructor(e){super("gYearMonth",R,e,void 0)}validate(e){return typeof e=="object"&&e!==null&&"year"in e&&"month"in e}cast(e){if(this.validate(e))return e;if(typeof e=="string"){let t=e.match(/^(-?\d{4})-(\d{2})$/);if(!t)throw new Error(`Invalid gYearMonth format: "${e}"`);let n=parseInt(t[1],10),r=parseInt(t[2],10);if(r<1||r>12)throw new Error(`Invalid month value: ${r}`);return{year:n,month:r}}throw new Error(`Cannot cast ${typeof e} to xs:gYearMonth`)}},en=class extends M{constructor(e){super("gYear",R,e,void 0)}validate(e){return typeof e=="object"&&e!==null&&"year"in e}cast(e){if(this.validate(e))return e;if(typeof e=="string"){let t=e.match(/^(-?\d{4})$/);if(!t)throw new Error(`Invalid gYear format: "${e}"`);return{year:parseInt(t[1],10)}}throw new Error(`Cannot cast ${typeof e} to xs:gYear`)}},tn=class extends M{constructor(e){super("gMonthDay",R,e,void 0)}validate(e){return typeof e=="object"&&e!==null&&"month"in e&&"day"in e}cast(e){if(this.validate(e))return e;if(typeof e=="string"){let t=e.match(/^--(\d{2})-(\d{2})$/);if(!t)throw new Error(`Invalid gMonthDay format: "${e}"`);let n=parseInt(t[1],10),r=parseInt(t[2],10);if(n<1||n>12)throw new Error(`Invalid month value: ${n}`);if(r<1||r>31)throw new Error(`Invalid day value: ${r}`);return{month:n,day:r}}throw new Error(`Cannot cast ${typeof e} to xs:gMonthDay`)}},nn=class extends M{constructor(e){super("gDay",R,e,void 0)}validate(e){return typeof e=="object"&&e!==null&&"day"in e}cast(e){if(this.validate(e))return e;if(typeof e=="string"){let t=e.match(/^---(\d{2})$/);if(!t)throw new Error(`Invalid gDay format: "${e}"`);let n=parseInt(t[1],10);if(n<1||n>31)throw new Error(`Invalid day value: ${n}`);return{day:n}}throw new Error(`Cannot cast ${typeof e} to xs:gDay`)}},rn=class extends M{constructor(e){super("gMonth",R,e,void 0)}validate(e){return typeof e=="object"&&e!==null&&"month"in e}cast(e){if(this.validate(e))return e;if(typeof e=="string"){let t=e.match(/^--(\d{2})$/);if(!t)throw new Error(`Invalid gMonth format: "${e}"`);let n=parseInt(t[1],10);if(n<1||n>12)throw new Error(`Invalid month value: ${n}`);return{month:n}}throw new Error(`Cannot cast ${typeof e} to xs:gMonth`)}}});var sn,on,ir=g(()=>{be();sn=class extends M{constructor(e){super("hexBinary",R,e,void 0)}validate(e){return typeof e=="string"?/^[0-9A-Fa-f]*$/.test(e)&&e.length%2===0:e instanceof Uint8Array}cast(e){if(typeof e=="string"){if(!this.validate(e))throw new Error(`Invalid hexBinary format: "${e}"`);return e.toUpperCase()}if(e instanceof Uint8Array)return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("").toUpperCase();throw new Error(`Cannot cast ${typeof e} to xs:hexBinary`)}},on=class extends M{constructor(e){super("base64Binary",R,e,void 0)}validate(e){return typeof e=="string"?/^[A-Za-z0-9+/]*={0,2}$/.test(e)&&e.length%4===0:e instanceof Uint8Array}cast(e){if(typeof e=="string"){if(!this.validate(e))throw new Error(`Invalid base64Binary format: "${e}"`);return e}if(e instanceof Uint8Array){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="",r=0,i=e.length;for(;r<i;){let o=e[r++],a=r<i,c=a?e[r++]:0,u=r<i,l=u?e[r++]:0,p=o<<16|c<<8|l;n+=t[p>>18&63],n+=t[p>>12&63],n+=a?t[p>>6&63]:"=",n+=u?t[p&63]:"="}return n}throw new Error(`Cannot cast ${typeof e} to xs:base64Binary`)}}});var an,cn,sr=g(()=>{be();an=class extends M{constructor(e){super("anyURI",R,e,void 0)}validate(e){return typeof e=="string"}cast(e){if(typeof e=="string")return e;throw new Error(`Cannot cast ${typeof e} to xs:anyURI`)}},cn=class extends M{constructor(e){super("QName",R,e,void 0)}validate(e){return typeof e=="object"&&e!==null&&"localName"in e&&"namespaceURI"in e}cast(e){if(this.validate(e))return e;if(typeof e=="string"){let t=e.split(":");if(t.length===1)return{localName:t[0],namespaceURI:"",prefix:void 0};if(t.length===2)return{localName:t[1],namespaceURI:"",prefix:t[0]}}throw new Error(`Cannot cast ${typeof e} to xs:QName`)}}});var K,$r=g(()=>{be();K=class extends M{constructor(t,n,r,i,o){super(t,R,n,r);this.min=i;this.max=o}validate(t){return!(typeof t!="number"||!Number.isInteger(t)||!isFinite(t)||!Number.isSafeInteger(t)||this.min!==void 0&&t<this.min||this.max!==void 0&&t>this.max)}cast(t){let n=this.baseType.cast(t);if(!Number.isSafeInteger(n))throw new Error(`Value ${n} is not a safe integer for ${this.name}`);if(this.min!==void 0&&n<this.min)throw new Error(`Value ${n} is below minimum ${this.min} for ${this.name}`);if(this.max!==void 0&&n>this.max)throw new Error(`Value ${n} is above maximum ${this.max} for ${this.name}`);return n}}});var ss={};ze(ss,{ARRAY_NAMESPACE:()=>is,FN_NAMESPACE:()=>un,MAP_NAMESPACE:()=>rs,MATH_NAMESPACE:()=>ln,createFunctionItem:()=>Zi,createFunctionTest:()=>es,createFunctionType:()=>ts,describeFunctionType:()=>ns,isFunctionItem:()=>ge});function Zi(s,e,t,n,r){return{__isFunctionItem:!0,implementation:s,arity:e,name:t,namespace:n,type:r}}function es(s=null,e=null,t){var o,a;let n=(o=t==null?void 0:t.isWildcard)!=null?o:s===null&&e===null,r=Array.isArray(s)?s.length:void 0;return{name:n?"function(*)":`function(${(a=s==null?void 0:s.map(c=>c.toString()).join(", "))!=null?a:""})`+(e?` as ${e.toString()}`:""),isFunctionTest:!0,isWildcard:n,parameterTypes:s!=null?s:void 0,returnType:e!=null?e:void 0,matches(c){if(c==null)return!1;let u=typeof c=="object"&&c.__isFunctionItem===!0||typeof c=="function",l=typeof c=="object"&&(c==null?void 0:c.__isMap)===!0,p=typeof c=="object"&&(c==null?void 0:c.__isArray)===!0;if(!u&&!l&&!p)return!1;if(n)return!0;if(r!==void 0){let h=l||p?1:typeof c=="function"?c.length:typeof(c==null?void 0:c.arity)=="number"?c.arity:void 0;if(h!==void 0&&h!==r)return!1}return!0}}}function ge(s){return s&&typeof s=="object"&&s.__isFunctionItem===!0}function ts(s,e){return{kind:"function",parameterTypes:s,returnType:e,arity:s.length}}function ns(s){return`function(${s.parameterTypes.map(t=>String(t)).join(", ")}) as ${s.returnType}`}var un,ln,rs,is,pn=g(()=>{un="http://www.w3.org/2005/xpath-functions",ln="http://www.w3.org/2005/xpath-functions/math",rs="http://www.w3.org/2005/xpath-functions/map",is="http://www.w3.org/2005/xpath-functions/array"});var os=g(()=>{});var as=g(()=>{os()});function ye(s){return kc[s]}function O(s,e){let t=ye(e);if(!t)throw new Error(`Unknown atomic type: ${e}`);return t.cast(s)}var z,fc,dc,yc,ie,gc,xc,Nc,hn,Ec,bc,Pc,Tc,Xc,Sc,Cc,wc,Ac,Oc,Rc,or,cs,us,ls,vc,ps,Ic,Lr,_c,hs,ms,fs,Mc,kc,ke=g(()=>{be();be();Qe();$i();tr();ht();$t();Ki();Vr();mt();ft();Ke();Ke();He();ir();sr();$r();pn();as();mt();mt();mt();mt();ft();ft();ft();ft();Ke();Ke();Ke();Ke();He();He();He();He();He();ir();ir();sr();sr();$r();z=new Ut,fc=new Wt(z),dc=new qt(z),yc=new Bt(z),ie=new zt(z),gc=new jt(z),xc=new Yt(z),Nc=new Qt(z),hn=new Kt(z),Ec=new Ht(hn,hn),bc=new Jt(hn,hn),Pc=new an(z),Tc=new cn(z),Xc=new Zt(z),Sc=new en(z),Cc=new tn(z),wc=new nn(z),Ac=new rn(z),Oc=new sn(z),Rc=new on(z),or=new Gt(ie,ie),cs=new K("long",or,ie,-9223372036854776e3,9223372036854776e3),us=new K("int",cs,ie,-2147483648,2147483647),ls=new K("short",us,ie,-32768,32767),vc=new K("byte",ls,ie,-128,127),ps=new K("nonPositiveInteger",or,ie,void 0,0),Ic=new K("negativeInteger",ps,ie,void 0,-1),Lr=new K("nonNegativeInteger",or,ie,0,void 0),_c=new K("positiveInteger",Lr,ie,1,void 0),hs=new K("unsignedLong",Lr,ie,0,18446744073709552e3),ms=new K("unsignedInt",hs,ie,0,4294967295),fs=new K("unsignedShort",ms,ie,0,65535),Mc=new K("unsignedByte",fs,ie,0,255),kc={anyAtomicType:z,untypedAtomic:fc,string:dc,boolean:yc,decimal:ie,float:gc,double:xc,integer:or,duration:Nc,dateTime:hn,date:Ec,time:bc,anyURI:Pc,QName:Tc,gYearMonth:Xc,gYear:Sc,gMonthDay:Cc,gDay:wc,gMonth:Ac,hexBinary:Oc,base64Binary:Rc,long:cs,int:us,short:ls,byte:vc,nonPositiveInteger:ps,negativeInteger:Ic,nonNegativeInteger:Lr,positiveInteger:_c,unsignedLong:hs,unsignedInt:ms,unsignedShort:fs,unsignedByte:Mc}});var mn,ds=g(()=>{ke();_();mn=class extends N{constructor(t,n){super();this.expression=t;this.sequenceType=n}evaluate(t){let n=this.expression.evaluate(t);return Se(n,this.sequenceType).matches}}});var fn,ys=g(()=>{ke();Qe();_();fn=class extends N{constructor(t,n){super();this.expression=t;this.sequenceType=n}evaluate(t){let n=this.expression.evaluate(t),r=Array.isArray(n)?n:n==null?[]:[n];if(r.length>1)return!1;if(r.length===0)return this.sequenceType.getOccurrence()==="?";let i=r[0],o=this.sequenceType.getItemType();if(o==="empty"||!o.atomicType)return!1;try{return O(i,o.atomicType.name),!0}catch(a){return!1}}}});var dn,gs=g(()=>{_();tr();dn=class extends N{constructor(t,n){super();this.expression=t;this.sequenceType=n}evaluate(t){var i;let n=this.expression.evaluate(t),r=Se(n,this.sequenceType);if(!r.matches){let o=(i=r.reason)!=null?i:`Value does not match ${this.sequenceType.toString()}`;throw new Error(`Treat expression type mismatch: ${o}`)}return n}}});var Ce,xs=g(()=>{_();Ce=class extends N{constructor(e,t){super(),this.left=e,this.right=t}evaluate(e){let t=this.left.evaluate(e),n=this.right.evaluate(e),r=Array.isArray(t)?t:[],i=Array.isArray(n)?n:[];return this.unionNodes(r,i)}unionNodes(e,t){let n=new Set,r=[];for(let i of e)n.has(i)||(n.add(i),r.push(i));for(let i of t)n.has(i)||(n.add(i),r.push(i));return this.sortByDocumentOrder(r)}sortByDocumentOrder(e){return e.sort((t,n)=>{if(t===n)return 0;if(typeof t.compareDocumentPosition=="function"){let r=t.compareDocumentPosition(n);if(r&4)return-1;if(r&2)return 1}return 0})}}});function Dc(s){let e;return s==null?e=[]:Array.isArray(s)?e=s:e=[s],{items:e,isEmpty:()=>e.length===0,first:()=>e[0],last:()=>e[e.length-1],length:()=>e.length}}function Vc(s){return s==null?[]:Array.isArray(s)?s:[s]}function Fc(...s){let e=[];for(let t of s)Array.isArray(t)?e.push(...t):t!=null&&e.push(t);return e}function Ns(s){return!s||typeof s!="object"?!1:typeof s.nodeType=="string"||typeof s.nodeName=="string"||typeof s.textContent=="string"}function $c(s){return Ns(s)?`${s.nodeType}:${s.nodeName||s.localName||""}:${s.__id||""}`:String(s)}var yn,gn,xn,Ur,Es=g(()=>{_();yn=class extends N{constructor(t){super();this.operands=t;if(t.length<2)throw new Error("CommaExpression requires at least 2 operands")}evaluate(t){let n=[];for(let r of this.operands){let i=r.evaluate(t);Array.isArray(i)?n.push(...i):i!=null&&n.push(i)}return n.length>0?n:[]}getOperands(){return this.operands}toString(){return this.operands.map(t=>t.toString()).join(", ")}},gn=class extends N{constructor(t,n){super();this.startExpr=t;this.endExpr=n}evaluate(t){let n=this.startExpr.evaluate(t),r=this.endExpr.evaluate(t),i,o;try{let c=Array.isArray(n)?n[0]:n,u=Array.isArray(r)?r[0]:r;i=this.toInteger(c),o=this.toInteger(u)}catch(c){throw new Error(`Range expression operands must be integers: ${String(c)}`)}if(i>o)return[];let a=[];for(let c=i;c<=o;c++)a.push(c);return a}toInteger(t){if(typeof t=="number")return Math.trunc(t);if(typeof t=="string"){let n=parseInt(t,10);if(isNaN(n))throw new Error(`Cannot convert "${t}" to integer`);return n}if(typeof t=="boolean")return t?1:0;throw new Error(`Cannot convert ${typeof t} to integer`)}toString(){return`${this.startExpr.toString()} to ${this.endExpr.toString()}`}},xn=class extends N{evaluate(e){return[]}toString(){return"empty-sequence()"}},Ur=class extends N{constructor(t){super();this.operand=t}evaluate(t){return this.operand.evaluate(t)}getOperand(){return this.operand}toString(){return`(${this.operand.toString()})`}}});var Nn,bs=g(()=>{_();Nn=class extends N{constructor(e){super(),this.expression=e}evaluate(e){return this.expression.evaluate(e)}test(e){let t=this.evaluate(e);return typeof t=="number"?t===(e==null?void 0:e.position):this.toBoolean(t)}toBoolean(e){return typeof e=="boolean"?e:typeof e=="number"?e!==0&&!isNaN(e):typeof e=="string"||Array.isArray(e)?e.length>0:!!e}}});var Wr,Ps=g(()=>{_();Wr=class extends N{constructor(t,n,r){super();this.left=t;this.operator=n;this.right=r}evaluate(t){let n=this.left.evaluate(t),r=this.right.evaluate(t),i=this.atomize(n),o=this.atomize(r);if(i===void 0||o===void 0)throw new Error("Value comparison requires non-empty sequences");return this.compare(i,o,this.operator)}atomize(t){if(t!=null){if(Array.isArray(t)){if(t.length===0)return;if(t.length===1)return t[0];throw new Error("Value comparison requires single atomic values")}return this.isNode(t)?this.getNodeStringValue(t):t}}compare(t,n,r){let[i,o]=this.promoteTypes(t,n);switch(r){case"eq":return this.equal(i,o);case"ne":return!this.equal(i,o);case"lt":return this.lessThan(i,o);case"le":return this.lessThan(i,o)||this.equal(i,o);case"gt":return this.greaterThan(i,o);case"ge":return this.greaterThan(i,o)||this.equal(i,o);default:throw new Error(`Unknown comparison operator: ${r}`)}}promoteTypes(t,n){return typeof t=="number"&&typeof n=="number"?[t,n]:typeof t=="number"?[t,this.toNumber(n)]:typeof n=="number"?[this.toNumber(t),n]:typeof t=="string"&&typeof n=="string"?[t,n]:typeof t=="string"?[t,this.valueToString(n)]:typeof n=="string"?[this.valueToString(t),n]:typeof t=="boolean"||typeof n=="boolean"?[this.toBoolean(t),this.toBoolean(n)]:[t,n]}equal(t,n){return typeof t!=typeof n||typeof t=="number"&&isNaN(t)&&isNaN(n)?!1:t===n}lessThan(t,n){if(typeof t=="number"&&typeof n=="number"||typeof t=="string"&&typeof n=="string")return t<n;throw new Error(`Cannot compare ${typeof t} with ${typeof n}`)}greaterThan(t,n){if(typeof t=="number"&&typeof n=="number"||typeof t=="string"&&typeof n=="string")return t>n;throw new Error(`Cannot compare ${typeof t} with ${typeof n}`)}toNumber(t){if(typeof t=="number")return t;if(typeof t=="boolean")return t?1:0;if(typeof t=="string"){let n=parseFloat(t);return isNaN(n)?NaN:n}return NaN}valueToString(t){return typeof t=="string"?t:typeof t=="number"?String(t):typeof t=="boolean"?t?"true":"false":this.isNode(t)?this.getNodeStringValue(t):String(t)}toBoolean(t){return typeof t=="boolean"?t:typeof t=="number"?t!==0&&!isNaN(t):typeof t=="string"||Array.isArray(t)?t.length>0:!!t}isNode(t){return t&&typeof t=="object"&&("nodeType"in t||"nodeName"in t)}getNodeStringValue(t){return t.textContent!==void 0?String(t.textContent):t.nodeValue!==void 0?String(t.nodeValue):t.value!==void 0?String(t.value):""}toString(){return`${this.left.toString()} ${this.operator} ${this.right.toString()}`}}});var qr,Ts=g(()=>{_();qr=class extends N{constructor(t,n,r){super();this.left=t;this.operator=n;this.right=r}evaluate(t){let n=this.left.evaluate(t),r=this.right.evaluate(t),i=this.flatten(n),o=this.flatten(r);if(i.length===0||o.length===0)return!1;for(let a of i)for(let c of o)if(this.compareValues(a,c,this.operator))return!0;return!1}flatten(t){if(t==null)return[];if(Array.isArray(t)){let n=[];for(let r of t)r!=null&&n.push(r);return n}return[t]}compareValues(t,n,r){let i=this.getComparableValue(t),o=this.getComparableValue(n),[a,c]=this.promoteTypes(i,o);switch(r){case"=":return this.equal(a,c);case"!=":return!this.equal(a,c);case"<":return this.lessThan(a,c);case"<=":return this.lessThan(a,c)||this.equal(a,c);case">":return this.greaterThan(a,c);case">=":return this.greaterThan(a,c)||this.equal(a,c);default:throw new Error(`Unknown comparison operator: ${r}`)}}getComparableValue(t){if(t!=null)return this.isNode(t)?this.getNodeStringValue(t):t}promoteTypes(t,n){return typeof t=="number"&&typeof n=="number"?[t,n]:typeof t=="number"?[t,this.toNumber(n)]:typeof n=="number"?[this.toNumber(t),n]:typeof t=="string"&&typeof n=="string"?[t,n]:typeof t=="string"?[t,this.valueToString(n)]:typeof n=="string"?[this.valueToString(t),n]:typeof t=="boolean"||typeof n=="boolean"?[this.toBoolean(t),this.toBoolean(n)]:[t,n]}equal(t,n){return typeof t!=typeof n||typeof t=="number"&&isNaN(t)&&isNaN(n)?!1:t===n}lessThan(t,n){if(typeof t=="number"&&typeof n=="number"||typeof t=="string"&&typeof n=="string")return t<n;throw new Error(`Cannot compare ${typeof t} with ${typeof n}`)}greaterThan(t,n){if(typeof t=="number"&&typeof n=="number"||typeof t=="string"&&typeof n=="string")return t>n;throw new Error(`Cannot compare ${typeof t} with ${typeof n}`)}toNumber(t){if(typeof t=="number")return t;if(typeof t=="boolean")return t?1:0;if(typeof t=="string"){let n=parseFloat(t);return isNaN(n)?NaN:n}return NaN}valueToString(t){return typeof t=="string"?t:typeof t=="number"?String(t):typeof t=="boolean"?t?"true":"false":this.isNode(t)?this.getNodeStringValue(t):String(t)}toBoolean(t){return typeof t=="boolean"?t:typeof t=="number"?t!==0&&!isNaN(t):typeof t=="string"||Array.isArray(t)?t.length>0:!!t}isNode(t){return t&&typeof t=="object"&&("nodeType"in t||"nodeName"in t)}getNodeStringValue(t){return t.textContent!==void 0?String(t.textContent):t.nodeValue!==void 0?String(t.nodeValue):t.value!==void 0?String(t.value):""}toString(){return`${this.left.toString()} ${this.operator} ${this.right.toString()}`}}});var Br,Xs=g(()=>{_();Br=class extends N{constructor(t,n,r){super();this.left=t;this.operator=n;this.right=r}evaluate(t){let n=this.left.evaluate(t),r=this.right.evaluate(t),i=this.extractNode(n),o=this.extractNode(r);if(!this.isNode(i)||!this.isNode(o))throw new Error("Node comparison requires node operands");switch(this.operator){case"is":return this.isIdentical(i,o);case"<<":return this.isDocumentOrderBefore(i,o);case">>":return this.isDocumentOrderAfter(i,o);default:throw new Error(`Unknown node comparison operator: ${this.operator}`)}}extractNode(t){if(t!=null){if(this.isNode(t))return t;if(Array.isArray(t))return t.length===0?void 0:(t.length===1,t[0])}}isIdentical(t,n){return t.__id!==void 0&&n.__id!==void 0?t.__id===n.__id:t===n}isDocumentOrderBefore(t,n){let r=this.getDocumentPosition(t),i=this.getDocumentPosition(n);return r!==-1&&i!==-1?r<i:this.compareDocumentOrder(t,n)<0}isDocumentOrderAfter(t,n){let r=this.getDocumentPosition(t),i=this.getDocumentPosition(n);return r!==-1&&i!==-1?r>i:this.compareDocumentOrder(t,n)>0}getDocumentPosition(t){return t.__documentPosition!==void 0?t.__documentPosition:-1}compareDocumentOrder(t,n){if(t===n)return 0;let r=this.getAncestors(t),i=this.getAncestors(n),o=0;for(;o<r.length&&o<i.length&&r[o]===i[o];)o++;if(o===r.length)return-1;if(o===i.length)return 1;let a=r[o],c=i[o],u=this.getChildPosition(a),l=this.getChildPosition(c);return u<l?-1:u>l?1:0}getAncestors(t){let n=[t],r=t;for(;r&&r.parentNode;)r=r.parentNode,n.unshift(r);return n}getChildPosition(t){if(!t.parentNode)return 0;let r=t.parentNode.childNodes||[];for(let i=0;i<r.length;i++)if(r[i]===t)return i;return-1}isNode(t){return t&&typeof t=="object"&&("nodeType"in t||"nodeName"in t)}toString(){return`${this.left.toString()} ${this.operator} ${this.right.toString()}`}}});var we,En=g(()=>{je();we=class{constructor(){this.elementId=0}convert(e,t){if(e==null)return null;typeof e!="string"&&(e=String(e));let n=e.trim();if(n==="")return null;try{let r=JSON.parse(n);return this.createDocumentNode(r,t)}catch(r){if(t!=null&&t.fallback&&typeof t.fallback=="function")try{let i=t.fallback(n);return this.createDocumentNode(i,t)}catch(i){return null}return t!=null&&t.liberal?this.liberalParse(n,t):null}}createDocumentNode(e,t){this.elementId=0;let n=this.valueToElement(e,"root",t),r={nodeType:Te.DOCUMENT_NODE,nodeName:"#document",localName:"#document",childNodes:[n],documentElement:n};return n.ownerDocument=r,r}valueToElement(e,t,n,r){let i={nodeType:Te.ELEMENT_NODE,nodeName:t,localName:t,childNodes:[],attributes:[]};if(e==null)return i;if(typeof e=="object"&&!Array.isArray(e)){let o=[],a=new Set;for(let c in e)if(Object.prototype.hasOwnProperty.call(e,c)){if(a.has(c)){if((n==null?void 0:n.duplicates)==="reject")throw new Error(`Duplicate key: ${c}`);if((n==null?void 0:n.duplicates)==="use-first")continue}a.add(c);let u=this.sanitizeElementName(c),l=this.valueToElement(e[c],u,n,i);o.push(l)}i.childNodes=o}else if(Array.isArray(e)){let o=e.map((a,c)=>this.valueToElement(a,"item",n,i));i.childNodes=o}else if(typeof e=="string"){let o={nodeType:Te.TEXT_NODE,nodeName:"#text",localName:"#text",textContent:e};i.childNodes=[o],i.textContent=e}else if(typeof e=="number"){let o=String(e),a={nodeType:Te.TEXT_NODE,nodeName:"#text",localName:"#text",textContent:o};i.childNodes=[a],i.textContent=o}else if(typeof e=="boolean"){let o=e?"true":"false",a={nodeType:Te.TEXT_NODE,nodeName:"#text",localName:"#text",textContent:o};i.childNodes=[a],i.textContent=o}return i}sanitizeElementName(e){if(/^[a-zA-Z_][\w.-]*$/.test(e))return e;let t=e.replace(/[^a-zA-Z0-9_.-]/g,"_");return/^[a-zA-Z_]/.test(t)||(t="_"+t),(!t||t==="_")&&(t="item"),t}liberalParse(e,t){try{let n=e.replace(/,(\s*[}\]])/g,"$1");n=n.replace(/'/g,'"');let r=JSON.parse(n);return this.createDocumentNode(r,t)}catch(n){return null}}}});function Ss(s,e,t){if(!ge(t))throw new Error("fn:for-each: second argument must be a function");let n=t;if(e==null)return[];let r=Array.isArray(e)?e:[e],i=[];for(let o of r){let a=n.implementation(o);Array.isArray(a)?i.push(...a):a!=null&&i.push(a)}return i.length===0?[]:i}function Cs(s,e,t){if(!ge(t))throw new Error("fn:filter: second argument must be a function");let n=t;if(e==null)return[];let i=(Array.isArray(e)?e:[e]).filter(o=>!!n.implementation(o));return i.length===0?[]:i}function ws(s,e,t,n){if(!ge(n))throw new Error("fn:fold-left: third argument must be a function");let r=n;if(e==null)return t;let i=Array.isArray(e)?e:[e],o=t;for(let a of i)o=r.implementation(o,a);return o}function As(s,e,t,n){if(!ge(n))throw new Error("fn:fold-right: third argument must be a function");let r=n;if(e==null)return t;let i=Array.isArray(e)?e:[e],o=t;for(let a=i.length-1;a>=0;a--)o=r.implementation(i[a],o);return o}function Os(s,e,t,n){if(!ge(n))throw new Error("fn:for-each-pair: third argument must be a function");let r=n;if(e==null||t===null||t===void 0)return[];let i=Array.isArray(e)?e:[e],o=Array.isArray(t)?t:[t],a=[],c=Math.min(i.length,o.length);for(let u=0;u<c;u++){let l=r.implementation(i[u],o[u]);Array.isArray(l)?a.push(...l):l!=null&&a.push(l)}return a.length===0?[]:a}function Rs(s,e,t){if(!ge(e))throw new Error("fn:apply: first argument must be a function");let n=e;if(t==null)return n.implementation();let r=Array.isArray(t)?t:[t];return n.implementation(...r)}function vs(s,e){if(!ge(e))throw new Error("fn:function-name: argument must be a function");let t=e;return t.name?t.namespace?`Q{${t.namespace}}${t.name}`:t.name:null}function Is(s,e){if(!ge(e))throw new Error("fn:function-arity: argument must be a function");return e.arity}var _s=g(()=>{pn()});function Ms(s){return Math.PI}function ks(s,e){let t=H(e);return Math.exp(t)}function Ds(s,e){let t=H(e);return Math.pow(10,t)}function Vs(s,e){let t=H(e);return Math.log(t)}function Fs(s,e){let t=H(e);return Math.log10(t)}function $s(s,e,t){let n=H(e),r=H(t);return Math.pow(n,r)}function Ls(s,e){let t=H(e);return Math.sqrt(t)}function Us(s,e){let t=H(e);return Math.sin(t)}function Ws(s,e){let t=H(e);return Math.cos(t)}function qs(s,e){let t=H(e);return Math.tan(t)}function Bs(s,e){let t=H(e);return Math.asin(t)}function zs(s,e){let t=H(e);return Math.acos(t)}function js(s,e){let t=H(e);return Math.atan(t)}function Ys(s,e,t){let n=H(e),r=H(t);return Math.atan2(n,r)}function H(s){return s==null?NaN:Array.isArray(s)?s.length===0?NaN:H(s[0]):Number(s)}var Gs=g(()=>{});function zr(s){return s==null?null:Array.isArray(s)?s.length>0?s[0]:null:s}function jr(s){return s==null?[]:Array.isArray(s)?s.length>1?s.slice(1):[]:[]}function Qs(s){return ar(s)}function Ks(s){let e=ar(s);if(e.length>1)throw pe("zero or one item",`sequence of ${e.length} items`,"fn:zero-or-one");return e.length===0?null:e[0]}function Hs(s){let e=ar(s);if(e.length===0)throw pe("one or more items","empty sequence","fn:one-or-more");return e}function Js(s){let e=ar(s);if(e.length!==1)throw pe("exactly one item",e.length===0?"empty sequence":`sequence of ${e.length} items`,"fn:exactly-one");return e[0]}function ar(s){return s==null?[]:Array.isArray(s)?s:[s]}var Yr=g(()=>{_e()});function eo(s,e){let t=Array.isArray(e)?e:e?[e]:[];return t.length===0?[]:t.filter(n=>dt(n)?!t.some(r=>!dt(r)||n===r?!1:ro(n,r)):!1)}function to(s,e){let t=Array.isArray(e)?e:e?[e]:[];return t.length===0?[]:t.filter(n=>dt(n)?!t.some(r=>!dt(r)||n===r?!1:ro(r,n)):!1)}function no(s,e,t,n){let r=Array.isArray(e)?e:e?[e]:[];if(r.length<=1)return e;let i=r.map((o,a)=>({item:o,index:a}));return n&&typeof n=="object"&&n.__isFunctionItem?i.sort((o,a)=>{let c=n.implementation(o.item),u=n.implementation(a.item);return Zs(c,u)}):i.sort((o,a)=>Zs(o.item,a.item)),i.map(o=>o.item)}function dt(s){return s!=null&&typeof s=="object"&&("nodeType"in s||"localName"in s)}function ro(s,e){if(!dt(s)||!dt(e))return!1;let t=e.parent||e.parentNode,n=0,r=1e4,i=new Set;for(;t&&n<r&&!i.has(t);){if(i.add(t),t===s)return!0;t=t.parent||t.parentNode,n++}return!1}function Zs(s,e){if(Array.isArray(s)&&s.length>0&&(s=s[0]),Array.isArray(e)&&e.length>0&&(e=e[0]),s==null&&e==null)return 0;if(s==null)return-1;if(e==null)return 1;if(typeof s=="number"&&typeof e=="number")return s-e;let t=String(s),n=String(e);return t.localeCompare(n)}var io=g(()=>{Yr()});function so(s,e){let t=String(e);if(typeof process!="undefined"&&process.env){let n=process.env[t];return n!==void 0?n:null}return null}function oo(s){return typeof process!="undefined"&&process.env?Object.keys(process.env):[]}var ao=g(()=>{});function lo(s,e,t,n){let r=e==null?"":String(e),i=String(t),o=n?String(n):"";try{let a="";o.includes("i")&&(a+="i"),o.includes("m")&&(a+="m"),o.includes("s")&&(a+="s"),o.includes("x")&&(a+="x");let c=new RegExp(i,a+"g"),u=[],l=0,p;for(;(p=c.exec(r))!==null;)p.index>l&&u.push({type:"non-match",value:r.substring(l,p.index)}),u.push({type:"match",value:p[0],groups:p.slice(1).map(h=>h||"")}),l=c.lastIndex;return l<r.length&&u.push({type:"non-match",value:r.substring(l)}),u.length===0&&u.push({type:"non-match",value:r}),u}catch(a){throw new Error(`Invalid regular expression: ${i}`)}}function po(s,e,t,n){if(e==null)return"";let r=Array.isArray(e)?e.length>0?Number(e[0]):0:Number(e),i=String(t),o=Math.floor(r),a=o<0,c=Math.abs(o);if(i==="1")return String(o);if(i==="01")return String(Math.abs(o)).padStart(2,"0");if(i==="a")return co(c,"a");if(i==="A")return co(c,"A");if(i==="i")return uo(c).toLowerCase();if(i==="I")return uo(c);if(i==="w")return Gr(c);if(i==="W")return Gr(c).replace(/^\w/,l=>l.toUpperCase());let u=i.match(/^(0+)$/);if(u){let l=u[1].length;return String(c).padStart(l,"0")}return String(o)}function ho(s,e,t,n){if(e==null)return"NaN";let r=Array.isArray(e)?e.length>0?Number(e[0]):NaN:Number(e);if(isNaN(r))return"NaN";if(!isFinite(r))return r>0?"Infinity":"-Infinity";let o=String(t).split("."),a=o[0]||"0",c=o[1]||"",u=(a.match(/0/g)||[]).length,l=(c.match(/0/g)||[]).length,p=c.length,h;if(l>0||p>0){let E=Math.max(l,Math.min(p,6));h=r.toFixed(E)}else h=String(Math.round(r));let[m,d]=h.split("."),y=m.padStart(u,"0");return d!==void 0?`${y}.${d}`:y}function co(s,e){if(s<=0)return"";let t=e.charCodeAt(0),n="",r=s;for(;r>0;)r--,n=String.fromCharCode(t+r%26)+n,r=Math.floor(r/26);return n}function uo(s){if(s<=0||s>=4e3)return String(s);let e=[{value:1e3,numeral:"M"},{value:900,numeral:"CM"},{value:500,numeral:"D"},{value:400,numeral:"CD"},{value:100,numeral:"C"},{value:90,numeral:"XC"},{value:50,numeral:"L"},{value:40,numeral:"XL"},{value:10,numeral:"X"},{value:9,numeral:"IX"},{value:5,numeral:"V"},{value:4,numeral:"IV"},{value:1,numeral:"I"}],t="",n=s;for(let{value:r,numeral:i}of e)for(;n>=r;)t+=i,n-=r;return t}function Gr(s){if(s===0)return"zero";if(s<0)return"negative "+Gr(-s);let e=["","one","two","three","four","five","six","seven","eight","nine"],t=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],n=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],r=["","thousand","million","billion","trillion"],i="",o=0;for(;s>0;){let a=s%1e3;a!==0&&(i=zc(a,e,t,n)+(r[o]?" "+r[o]:"")+(i?" ":"")+i),s=Math.floor(s/1e3),o++}return i.trim()}function zc(s,e,t,n){let r="",i=Math.floor(s/100);i>0&&(r+=e[i]+" hundred");let o=s%100;if(o>=20){r&&(r+=" ");let a=Math.floor(o/10),c=o%10;r+=n[a],c>0&&(r+=" "+e[c])}else o>=10?(r&&(r+=" "),r+=t[o-10]):o>0&&(r&&(r+=" "),r+=e[o]);return r}var mo=g(()=>{});function J(s,e){if(Array.isArray(s)&&!re(s))if(s.length===1)s=s[0];else throw s.length===0?new Error(`XPTY0004: ${e} requires an array, got empty sequence`):new Error(`XPTY0004: ${e} requires a single array, got sequence of ${s.length} items`);if(!re(s))throw new Error(`XPTY0004: ${e} requires an array, got ${typeof s}`);return s}function fo(s,e,t){if(!Number.isInteger(e))throw new Error(`XPTY0004: ${t} position must be an integer, got ${e}`);if(e<1||e>s.members.length)throw new Error(`FOAY0001: ${t} position ${e} is out of bounds (array size: ${s.members.length})`)}function yo(s,e){return J(e,"array:size").members.length}function go(s,e,t){let n=J(e,"array:get");return fo(n,t,"array:get"),n.members[t-1]}function xo(s,e,t,n){let r=J(e,"array:put");fo(r,t,"array:put");let i=[...r.members];return i[t-1]=n,B(i)}function No(s,e,t){let n=J(e,"array:append");return B([...n.members,t])}function Eo(s,e,t,n){let r=J(e,"array:subarray");if(!Number.isInteger(t))throw new Error(`XPTY0004: array:subarray start must be an integer, got ${t}`);if(t<1)throw new Error(`FOAY0001: array:subarray start ${t} must be >= 1`);if(t>r.members.length+1)throw new Error(`FOAY0001: array:subarray start ${t} is out of bounds (array size: ${r.members.length})`);let i=t-1;if(n===void 0)return B(r.members.slice(i));if(!Number.isInteger(n))throw new Error(`XPTY0004: array:subarray length must be an integer, got ${n}`);if(n<0)throw new Error(`FOAY0002: array:subarray length ${n} must be >= 0`);if(i+n>r.members.length)throw new Error(`FOAY0001: array:subarray range [${t}, ${t+n-1}] exceeds array bounds`);return B(r.members.slice(i,i+n))}function bo(s,e,t){let n=J(e,"array:remove"),r=Array.isArray(t)?t:[t];for(let a of r){if(!Number.isInteger(a))throw new Error(`XPTY0004: array:remove position must be an integer, got ${a}`);if(a<1||a>n.members.length)throw new Error(`FOAY0001: array:remove position ${a} is out of bounds (array size: ${n.members.length})`)}let i=new Set(r.map(a=>a-1)),o=n.members.filter((a,c)=>!i.has(c));return B(o)}function Po(s,e,t,n){let r=J(e,"array:insert-before");if(!Number.isInteger(t))throw new Error(`XPTY0004: array:insert-before position must be an integer, got ${t}`);if(t<1||t>r.members.length+1)throw new Error(`FOAY0001: array:insert-before position ${t} is out of bounds (valid range: 1 to ${r.members.length+1})`);let i=[...r.members];return i.splice(t-1,0,n),B(i)}function To(s,e){let t=J(e,"array:head");if(t.members.length===0)throw new Error("FOAY0001: array:head called on empty array");return t.members[0]}function Xo(s,e){let t=J(e,"array:tail");if(t.members.length===0)throw new Error("FOAY0001: array:tail called on empty array");return B(t.members.slice(1))}function So(s,e){let t=J(e,"array:reverse");return B([...t.members].reverse())}function Co(s,e){let t=Array.isArray(e)?e:[e],n=[];for(let r of t){if(r==null)continue;let i=J(r,"array:join");n.push(...i.members)}return B(n)}function wo(s,e){let t=[],n=r=>{if(re(r))for(let i of r.members)n(i);else if(Array.isArray(r))for(let i of r)n(i);else t.push(r)};return n(e),t}function Ao(s,e,t){let n=J(e,"array:for-each");if(!t||typeof t!="function"&&!t.__isFunctionItem)throw new Error("XPTY0004: array:for-each requires a function as second argument");let r=t.__isFunctionItem?t.implementation:t,i=n.members.map((o,a)=>r(o));return B(i)}function Oo(s,e,t){let n=J(e,"array:filter");if(!t||typeof t!="function"&&!t.__isFunctionItem)throw new Error("XPTY0004: array:filter requires a function as second argument");let r=t.__isFunctionItem?t.implementation:t,i=n.members.filter(o=>{let a=r(o);return typeof a=="boolean"?a:typeof a=="number"?a!==0&&!isNaN(a):typeof a=="string"||Array.isArray(a)?a.length>0:!!a});return B(i)}function Ro(s,e,t,n){let r=J(e,"array:fold-left");if(!n||typeof n!="function"&&!n.__isFunctionItem)throw new Error("XPTY0004: array:fold-left requires a function as third argument");let i=n.__isFunctionItem?n.implementation:n,o=t;for(let a of r.members)o=i(o,a);return o}function vo(s,e,t,n){let r=J(e,"array:fold-right");if(!n||typeof n!="function"&&!n.__isFunctionItem)throw new Error("XPTY0004: array:fold-right requires a function as third argument");let i=n.__isFunctionItem?n.implementation:n,o=t;for(let a=r.members.length-1;a>=0;a--)o=i(r.members[a],o);return o}function Io(s,e,t,n){let r=J(e,"array:sort"),i=n&&(n.__isFunctionItem?n.implementation:n),o=r.members.map((a,c)=>({member:a,idx:c}));return o.sort((a,c)=>{let u=i?i(a.member):a.member,l=i?i(c.member):c.member;if(Array.isArray(u)&&(u=u[0]),Array.isArray(l)&&(l=l[0]),typeof u=="number"&&typeof l=="number")return u-l;let p=String(u!=null?u:""),h=String(l!=null?l:""),m=p.localeCompare(h);return m!==0?m:a.idx-c.idx}),B(o.map(a=>a.member))}var _o=g(()=>{Ve()});function Fe(s,e){if(Array.isArray(s)&&!Q(s))if(s.length===1)s=s[0];else throw s.length===0?new Error(`XPTY0004: ${e} requires a map, got empty sequence`):new Error(`XPTY0004: ${e} requires a single map, got sequence of ${s.length} items`);if(!Q(s))throw new Error(`XPTY0004: ${e} requires a map, got ${typeof s}`);return s}function Mo(s){let e=Object.create(null);return e.__isMap=!0,Object.assign(e,s),e}function ko(s,e){let t=Fe(e,"map:size");return Object.keys(t).filter(n=>!n.startsWith("__")).length}function Do(s,e){let t=Fe(e,"map:keys");return Object.keys(t).filter(n=>!n.startsWith("__"))}function Vo(s,e,t){let n=Fe(e,"map:contains"),r=String(t);return Object.prototype.hasOwnProperty.call(n,r)}function Fo(s,e,t){let n=Fe(e,"map:get"),r=String(t);if(Object.prototype.hasOwnProperty.call(n,r))return n[r]}function $o(s,e,t,n){let r=Fe(e,"map:put"),i=String(t),o=Mo(r);return o[i]=n,o}function Lo(s,e,t){let n=String(e),r=Object.create(null);return r.__isMap=!0,r[n]=t,r}function Uo(s,e,t){let n=Array.isArray(e)?e:[e],r="use-last";t&&Q(t)&&t.duplicates!==void 0&&(r=String(t.duplicates));let i=["use-first","use-last","combine","reject"];if(!i.includes(r))throw new Error(`XPST0003: Invalid duplicates option '${r}'. Must be one of: ${i.join(", ")}`);let o=Object.create(null);o.__isMap=!0;let a={};for(let c of n){let u=Fe(c,"map:merge");for(let l of Object.keys(u))l.startsWith("__")||(a[l]||(a[l]=0),a[l]++,r==="use-first"?l in o||(o[l]=u[l]):r==="use-last"?o[l]=u[l]:r==="combine"?l in o?Array.isArray(o[l])?o[l].push(u[l]):o[l]=[o[l],u[l]]:o[l]=u[l]:r==="reject"&&(o[l]=u[l]))}if(r==="reject"){for(let c in a)if(a[c]>1)throw new Error(`XUST0003: Duplicate key '${c}' found in map:merge with duplicates='reject'`)}return o}function Wo(s,e,t){let n=Fe(e,"map:for-each");if(!t||typeof t!="function"&&!t.__isFunctionItem)throw new Error("XPTY0004: map:for-each requires a function as second argument");let r=t.__isFunctionItem?t.implementation:t,i=Object.create(null);i.__isMap=!0;for(let o of Object.keys(n)){if(o.startsWith("__"))continue;let a=n[o];i[o]=r(o,a)}return i}function qo(s,e,t){let n=Fe(e,"map:remove"),r=Array.isArray(t)?t:[t],i=new Set(r.map(a=>String(a))),o=Mo(n);for(let a of Array.from(i))Object.prototype.hasOwnProperty.call(o,a)&&delete o[a];return o}var Bo=g(()=>{De()});function Kr(s){if(s===null)return null;if(Array.isArray(s))return B(s.map(Kr));if(typeof s=="object"){let e=Object.create(null);e.__isMap=!0;for(let[t,n]of Object.entries(s))e[t]=Kr(n);return e}if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return s;throw new te("FOJS0001","Unsupported JSON value type")}function Qc(s){let e="",t=0,n=!1,r="",i=!1;for(;t<s.length;){let o=s[t],a=t+1<s.length?s[t+1]:"";if(n){if(i){e+=o,i=!1,t++;continue}if(o==="\\"){e+=o,i=!0,t++;continue}if(o===r){e+='"',n=!1,t++;continue}r==="'"&&o==='"'?e+='\\"':e+=o,t++;continue}if(o==='"'||o==="'"){n=!0,r=o,e+='"',t++;continue}if(o==="/"&&a==="/"){for(t+=2;t<s.length&&s[t]!==`
|
|
3
3
|
`&&s[t]!=="\r";)t++;continue}if(o==="/"&&a==="*"){for(t+=2;t<s.length-1;){if(s[t]==="*"&&s[t+1]==="/"){t+=2;break}t++}continue}if(o===","){let c=t+1;for(;c<s.length&&/[\s\n\r\t]/.test(s[c]);)c++;for(;c<s.length;)if(s[c]==="/"&&c+1<s.length&&s[c+1]==="/"){for(c+=2;c<s.length&&s[c]!==`
|
|
4
|
-
`&&s[c]!=="\r";)c++;for(;c<s.length&&/[\s\n\r\t]/.test(s[c]);)c++}else if(s[c]==="/"&&c+1<s.length&&s[c+1]==="*"){for(c+=2;c<s.length-1;){if(s[c]==="*"&&s[c+1]==="/"){c+=2;break}c++}for(;c<s.length&&/[\s\n\r\t]/.test(s[c]);)c++}else break;if(c<s.length&&(s[c]==="}"||s[c]==="]")){for(t++;t<c;)/[\s\n\r\t]/.test(s[t])&&(e+=s[t]),t++;continue}}e+=o,t++}return e}function zo(s,e){if(typeof s!="string")throw new te("XPTY0004","parse-json: first argument must be a string");let t={liberal:!1,duplicates:"use-last"};if(e&&Q(e)){e.liberal===!0&&(t.liberal=!0);let r=e.duplicates;typeof r=="string"&&(t.duplicates=r)}try{if(t.duplicates!=="use-last")throw new te("FOJS0001",'Only duplicates="use-last" is supported');let n=t.liberal?Qc(s):s,r=JSON.parse(n);return Kr(r)}catch(n){throw new te("FOJS0001","parse-json: "+(n&&n.message?n.message:String(n)))}}function Yo(s,e,t){return typeof s=="string"?zo(s,e):zo(e,t)}function cr(s){if(s==null)return null;if(re(s))return s.members.map(cr);if(Q(s)){let e={};for(let[t,n]of Object.entries(s))t.startsWith("__")||(e[t]=cr(n));return e}if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return s;if(Array.isArray(s))return s.map(cr);throw new te("FOJS0002",`Cannot serialize value of type ${typeof s}`)}function Qr(s,e){let t={indent:void 0,method:"json"};if(e&&Q(e)){let n=e.indent;typeof n=="number"&&(t.indent=n);let r=e.method;typeof r=="string"&&(t.method=r)}try{let n;Array.isArray(s)?s.length===0?n=null:s.length===1?n=s[0]:n=s:n=s;let r=cr(n),i=t.indent!==void 0?t.indent:void 0;return JSON.stringify(r,null,i)}catch(n){throw n instanceof te?n:new te("FOJS0002","serialize: "+(n&&n.message?n.message:String(n)))}}function Go(s,e,t){return t!==void 0||s&&typeof s=="object"&&!("__isMap"in s)&&!("__isArray"in s)&&e!==void 0?Qr(e,t):Qr(s,e)}function jo(s,e){if(s==null||s==="")return null;if(typeof s!="string")throw new te("XPTY0004","json-to-xml: first argument must be a string or null");let t={liberal:!1,duplicates:"reject"};if(e&&Q(e)){e.liberal===!0&&(t.liberal=!0);let r=e.duplicates;typeof r=="string"&&(t.duplicates=r)}try{return new we().convert(s,t)}catch(n){throw new te("FOJS0001","json-to-xml: "+(n&&n.message?n.message:String(n)))}}function Qo(s,e,t){if(typeof s=="string"||s===null||s===void 0)return jo(s,e);if(typeof s!="object")throw new te("XPTY0004","json-to-xml: first argument must be a string or null");return jo(e,t)}var Ko=g(()=>{De();Ve();_e();En();je()});function Ho(s,e){let t=Je(s),n=Je(e);if(!n)throw new Error("FOCA0002: Invalid QName: empty string");let r=n.indexOf(":");if(r!==-1){let i=n.substring(0,r),o=n.substring(r+1);if(!Hr(i)||!Hr(o))throw new Error(`FOCA0002: Invalid QName: ${n}`);if(!t)throw new Error(`FONS0004: No namespace for prefix: ${i}`)}else if(!Hr(n))throw new Error(`FOCA0002: Invalid QName: ${n}`);return t?`{${t}}${n}`:n}function Jo(s,e){var c,u;let t=Je(s);if(!t)return null;let n=Jr(e);if(!n)throw new Error("FORG0001: Second argument to resolve-QName must be an element");let r=t.indexOf(":");if(r===-1){let l=(u=(c=n.getAttribute)==null?void 0:c.call(n,"xmlns"))!=null?u:"";return l?`{${l}}${t}`:t}let i=t.substring(0,r),o=t.substring(r+1),a=ia(n,i);if(!a)throw new Error(`FONS0004: No namespace for prefix: ${i}`);return`{${a}}${t}`}function Zo(s){let e=Je(s);if(!e)return null;let t=e;if(e.startsWith("{")){let r=e.indexOf("}");r!==-1&&(t=e.substring(r+1))}let n=t.indexOf(":");return n===-1?null:t.substring(0,n)}function ea(s){let e=Je(s);if(!e)return null;let t=e;if(e.startsWith("{")){let r=e.indexOf("}");r!==-1&&(t=e.substring(r+1))}let n=t.indexOf(":");return n===-1?t:t.substring(n+1)}function ta(s){let e=Je(s);if(!e)return null;if(e.startsWith("{")){let t=e.indexOf("}");if(t!==-1)return e.substring(1,t)}return null}function na(s){let e=Jr(s);if(!e)throw new Error("FORG0001: Argument to in-scope-prefixes must be an element");let t=new Set;t.add("xml");let n=e;for(;n;){if("attributes"in n&&n.attributes){let r=n.attributes;if(typeof r.getNamedItem=="function")for(let i=0;i<r.length;i++){let o=r.item(i);if(o){let a=o.name||o.nodeName;a==="xmlns"?t.add(""):a.startsWith("xmlns:")&&t.add(a.substring(6))}}else if(Array.isArray(r)){for(let i of r)if(i&&typeof i=="object"){let o=i.name||i.nodeName;o==="xmlns"?t.add(""):o&&typeof o=="string"&&o.startsWith("xmlns:")&&t.add(o.substring(6))}}else for(let i of Object.keys(r))i==="xmlns"?t.add(""):i.startsWith("xmlns:")&&t.add(i.substring(6))}n=n.parentNode}return Array.from(t)}function ra(s,e){let t=Je(s),n=Jr(e);if(!n)throw new Error("FORG0001: Second argument to namespace-uri-for-prefix must be an element");return t==="xml"?"http://www.w3.org/XML/1998/namespace":ia(n,t)}function Je(s){var e;if(s==null)return"";if(Array.isArray(s)){if(s.length===0)return"";s=s[0]}return typeof s=="object"&&s!==null&&"textContent"in s?(e=s.textContent)!=null?e:"":String(s)}function Jr(s){if(s==null)return null;if(Array.isArray(s)){if(s.length===0)return null;s=s[0]}if(typeof s=="object"&&s!==null&&"nodeType"in s){let e=s;if(e.nodeType===Te.ELEMENT_NODE)return e}return null}function Hr(s){if(!s)return!1;let e=s.charAt(0);return/[0-9\-.]/.test(e)||s.includes(":")?!1:/^[a-zA-Z_][\w.\-]*$/.test(s)}function ia(s,e){var n;let t=s;for(;t;){let r=e?`xmlns:${e}`:"xmlns",i=(n=t.getAttribute)==null?void 0:n.call(t,r);if(i!=null)return i;t=t.parentNode}return null}var sa=g(()=>{je()});function oa(s,e,t){var i;let n=bn(s);if(n==="")return null;let r=e!==void 0?bn(e):(i=t==null?void 0:t.baseUri)!=null?i:"";try{return r?new URL(n,r).toString():new URL(n).toString()}catch(o){return null}}function aa(s){let e=bn(s);return encodeURIComponent(e).replace(/[!'()*]/g,t=>"%"+t.charCodeAt(0).toString(16).toUpperCase())}function ca(s){let e=bn(s);return encodeURI(e)}function ua(s){let e=bn(s);return encodeURI(e).replace(/\+/g,"%2B").replace(/'/g,"%27").replace(/"/g,"%22").replace(/</g,"%3C").replace(/>/g,"%3E")}function bn(s){if(s==null)return"";if(Array.isArray(s)){if(s.length===0)return"";s=s[0]}return String(s)}var la=g(()=>{});function pa(s,e){var r;let t=Ae(s,e);if(!t)return null;let n=t.nodeType;return n!==1&&n!==2&&n!==7?null:(r=t.nodeName)!=null?r:null}function ha(s,e){var r;let t=Ae(s,e);if(!t||t.nodeType!==1)return null;let n=(r=t.getAttribute)==null?void 0:r.call(t,"xsi:nil");return n==="true"||n==="1"}function ma(s){if(s==null)return[];let e=Array.isArray(s)?s:[s],t=[];for(let n of e)t.push(Zc(n));return t}function Zr(s,e){var r,i;let t=Ae(s,e);if(!t)return null;if("baseURI"in t&&t.baseURI)return t.baseURI;let n=(r=t.getAttribute)==null?void 0:r.call(t,"xml:base");return n||(t.parentNode&&ur(t.parentNode)?Zr([t.parentNode],e):(i=e.baseUri)!=null?i:null)}function fa(s,e){let t=Ae(s,e);return!t||t.nodeType!==9?null:"documentURI"in t&&t.documentURI?t.documentURI:null}function da(s,e){let t=Ae(s,e);if(!t)return null;let n=t,r=0,i=new Set;for(;n.parentNode&&r<1e4;){if(i.has(n))return n;i.add(n),n=n.parentNode,r++}return n}function ya(s,e,t){var o,a;let n=eu(s).toLowerCase();if(!n)return!1;let r=e!==void 0?Ae(e,t):t.node;if(!r)return!1;let i=r;for(;i;){let c=((o=i.getAttribute)==null?void 0:o.call(i,"xml:lang"))||((a=i.getAttribute)==null?void 0:a.call(i,"lang"));if(c){let u=c.toLowerCase();return u===n||u.startsWith(n+"-")}i=i.parentNode}return!1}function ga(s,e){let t=Ae(s,e);if(!t)return"";let n=Symbol.for("__xpath_node_id__");if(!t[n]){let r=Date.now().toString(36),i=Math.random().toString(36).substring(2,8),o=Math.floor(Math.random()*1e4).toString(36);t[n]=`n${r}${i}${o}`}return t[n]}function xa(s,e){let t=Ae(s,e);if(!t)return"";let n=[],r=t,i=0,o=new Set;for(;r&&i<1e4&&!o.has(r);){o.add(r);let a=tu(r);a&&n.unshift(a),r=r.parentNode,i++}return"/"+n.join("/")}function Na(s,e){let t=Ae(s,e);return t&&"childNodes"in t&&Array.isArray(t.childNodes)?t.childNodes.length>0:!1}function Ae(s,e){var t;if(s==null)return(t=e.node)!=null?t:null;if(Array.isArray(s)){if(s.length===0)return null;s=s[0]}return ur(s)?s:null}function ur(s){return typeof s=="object"&&s!==null&&"nodeType"in s}function Ea(s){return s.textContent!==void 0?s.textContent:s.nodeType===1||s.nodeType===9?ba(s):String(s)}function ba(s){var t;let e=[];if("childNodes"in s&&Array.isArray(s.childNodes))for(let n of s.childNodes)n.nodeType===3?e.push((t=n.textContent)!=null?t:""):n.nodeType===1&&e.push(ba(n));return e.join("")}function Zc(s){return s==null?"":typeof s=="string"||typeof s=="number"||typeof s=="boolean"?s:ur(s)?Ea(s):String(s)}function eu(s){if(s==null)return"";if(Array.isArray(s)){if(s.length===0)return"";s=s[0]}return ur(s)?Ea(s):String(s)}function tu(s){let e=s.nodeName||"node()";switch(s.nodeType){case 1:let n=s.parentNode;if(n&&"childNodes"in n&&Array.isArray(n.childNodes)){let r=n.childNodes.filter(i=>i.nodeType===1&&i.nodeName===e);if(r.length>1){let i=r.indexOf(s)+1;return`${e}[${i}]`}}return e;case 2:return`@${e}`;case 3:return"text()";case 7:return`processing-instruction(${e})`;case 8:return"comment()";case 9:return"";default:return"node()"}}var Pa=g(()=>{});var Xa={};ze(Xa,{XPathFunctionCall:()=>Pe,getBuiltInFunction:()=>Pn,getBuiltInFunctionArity:()=>lr});function Pn(s){return yt[s]}function lr(s){return ru[s]}var Ta,yt,ru,Pe,Tn=g(()=>{_();En();ke();_e();_s();Gs();io();Yr();ao();mo();_o();Bo();Ko();sa();la();Pa();Ta=s=>{var e;if(s&&typeof s=="object"){if(typeof s.stringValue=="function")return s.stringValue();if(Array.isArray(s)){if(s.length===0)return"";let t=s[0];return(e=t==null?void 0:t.textContent)!=null?e:String(t)}if(typeof s.textContent=="string")return s.textContent;if(s.nodeValue!==void 0&&s.nodeValue!==null)return String(s.nodeValue)}return String(s!=null?s:"")},yt={"upper-case":(s,e)=>Ta(e).toUpperCase(),"lower-case":(s,e)=>Ta(e).toLowerCase(),concat:(s,...e)=>e.map(t=>String(t)).join(""),"string-join":(s,e,t="")=>Array.isArray(e)?e.map(n=>String(n)).join(String(t)):String(e),substring:(s,e,t,n)=>{let r=String(e),i=Math.round(Number(t))-1;if(n===void 0)return r.substring(Math.max(0,i));let o=Math.round(Number(n)),a=Math.max(0,i);return r.substring(a,a+o)},"string-length":(s,e)=>String(e).length,"normalize-space":(s,e)=>String(e).trim().replace(/\s+/g," "),contains:(s,e,t)=>String(e).includes(String(t)),"starts-with":(s,e,t)=>String(e).startsWith(String(t)),"ends-with":(s,e,t)=>String(e).endsWith(String(t)),translate:(s,e,t,n)=>{let r=String(e),i=String(t),o=String(n),a="";for(let c of r){let u=i.indexOf(c);u===-1?a+=c:u<o.length&&(a+=o[u])}return a},replace:(s,e,t,n)=>{let r=new RegExp(String(t),"g");return String(e).replace(r,String(n))},matches:(s,e,t)=>new RegExp(String(t)).test(String(e)),tokenize:(s,e,t="\\s+")=>{let n=new RegExp(String(t));return String(e).split(n).filter(r=>r.length>0)},abs:(s,e)=>Math.abs(Number(e)),ceiling:(s,e)=>Math.ceil(Number(e)),floor:(s,e)=>Math.floor(Number(e)),round:(s,e)=>Math.round(Number(e)),"round-half-to-even":(s,e,t=0)=>{let n=Math.pow(10,Number(t)),r=Number(e)*n,i=Math.floor(r);return r-i===.5?(i%2===0?i:i+1)/n:Math.round(r)/n},number:(s,e)=>Number(e),true:()=>!0,false:()=>!1,not:(s,e)=>!e,boolean:(s,e)=>typeof e=="boolean"?e:typeof e=="number"?e!==0&&!isNaN(e):typeof e=="string"||Array.isArray(e)?e.length>0:!!e,count:(s,e)=>Array.isArray(e)?e.length:e==null?0:1,sum:(s,e)=>Array.isArray(e)?e.reduce((t,n)=>t+(Number(n)||0),0):Number(e)||0,avg:(s,e)=>Array.isArray(e)?e.length===0?null:e.reduce((n,r)=>n+(Number(r)||0),0)/e.length:Number(e),min:(s,e)=>Array.isArray(e)?e.length===0?null:Math.min(...e.map(t=>Number(t))):Number(e),max:(s,e)=>Array.isArray(e)?e.length===0?null:Math.max(...e.map(t=>Number(t))):Number(e),empty:(s,e)=>e==null?!0:Array.isArray(e)?e.length===0:!1,exists:(s,e)=>e==null?!1:Array.isArray(e)?e.length>0:!0,reverse:(s,e)=>Array.isArray(e)?[...e].reverse():[e],"distinct-values":(s,e)=>Array.isArray(e)?Array.from(new Set(e)):[e],subsequence:(s,e,t,n)=>{Array.isArray(e)||(e=[e]);let r=Math.round(Number(t))-1;if(n===void 0)return e.slice(Math.max(0,r));let i=Math.round(Number(n));return e.slice(Math.max(0,r),Math.max(0,r)+i)},"insert-before":(s,e,t,n)=>{Array.isArray(e)||(e=e===null?[]:[e]),Array.isArray(n)||(n=[n]);let r=Math.max(0,Math.round(Number(t))-1);return[...e.slice(0,r),...n,...e.slice(r)]},remove:(s,e,t)=>{Array.isArray(e)||(e=[e]);let n=Math.round(Number(t))-1;return n<0||n>=e.length?e:[...e.slice(0,n),...e.slice(n+1)]},position:s=>{var e;return(e=s.position)!=null?e:0},last:s=>{var e;return(e=s.size)!=null?e:0},string:(s,e)=>{var t,n,r,i;return e===void 0?(n=(t=s.node)==null?void 0:t.textContent)!=null?n:"":Array.isArray(e)&&e.length>0?(i=(r=e[0])==null?void 0:r.textContent)!=null?i:String(e[0]):String(e)},"local-name":(s,e)=>{var n;let t=e?Array.isArray(e)?e[0]:e:s.node;return(n=t==null?void 0:t.localName)!=null?n:""},"namespace-uri":(s,e)=>{var n;let t=e?Array.isArray(e)?e[0]:e:s.node;return(n=t==null?void 0:t.namespaceUri)!=null?n:""},name:(s,e)=>{var n;let t=e?Array.isArray(e)?e[0]:e:s.node;return(n=t==null?void 0:t.nodeName)!=null?n:""},"generate-id":(s,e)=>ga(e,s),path:(s,e)=>xa(e,s),"has-children":(s,e)=>Na(e,s),"for-each":Ss,filter:Cs,"fold-left":ws,"fold-right":As,"for-each-pair":Os,sort:no,apply:vs,"function-name":Rs,"function-arity":Is,"math:pi":Ms,"math:exp":ks,"math:exp10":Ds,"math:log":Vs,"math:log10":Fs,"math:pow":$s,"math:sqrt":Ls,"math:sin":Us,"math:cos":Ws,"math:tan":qs,"math:asin":Bs,"math:acos":zs,"math:atan":js,"math:atan2":Ys,head:(s,e)=>zr(e),tail:(s,e)=>jr(e),innermost:eo,outermost:to,"environment-variable":so,"available-environment-variables":oo,"array:size":yo,"array:get":go,"array:put":xo,"array:append":No,"array:subarray":Eo,"array:remove":bo,"array:insert-before":Po,"array:head":To,"array:tail":Xo,"array:reverse":So,"array:join":Co,"array:flatten":wo,"array:for-each":Ao,"array:filter":Oo,"array:fold-left":vo,"array:fold-right":Ro,"array:sort":Io,"map:size":ko,"map:keys":Do,"map:contains":Vo,"map:get":Fo,"map:put":$o,"map:entry":Lo,"map:merge":Uo,"map:for-each":Wo,"map:remove":qo,"parse-json":Yo,serialize:Go,"json-to-xml":Qo,"analyze-string":lo,"format-integer":po,"format-number":ho,"xs:string":(s,e)=>O(e,"string"),"xs:boolean":(s,e)=>O(e,"boolean"),"xs:decimal":(s,e)=>O(e,"decimal"),"xs:float":(s,e)=>O(e,"float"),"xs:double":(s,e)=>O(e,"double"),"xs:integer":(s,e)=>O(e,"integer"),"xs:duration":(s,e)=>O(e,"duration"),"xs:dateTime":(s,e)=>O(e,"dateTime"),"xs:date":(s,e)=>O(e,"date"),"xs:time":(s,e)=>O(e,"time"),"xs:anyURI":(s,e)=>O(e,"anyURI"),"xs:QName":(s,e)=>O(e,"QName"),"xs:untypedAtomic":(s,e)=>O(e,"untypedAtomic"),"xs:gYearMonth":(s,e)=>O(e,"gYearMonth"),"xs:gYear":(s,e)=>O(e,"gYear"),"xs:gMonthDay":(s,e)=>O(e,"gMonthDay"),"xs:gDay":(s,e)=>O(e,"gDay"),"xs:gMonth":(s,e)=>O(e,"gMonth"),"xs:hexBinary":(s,e)=>O(e,"hexBinary"),"xs:base64Binary":(s,e)=>O(e,"base64Binary"),"xs:long":(s,e)=>O(e,"long"),"xs:int":(s,e)=>O(e,"int"),"xs:short":(s,e)=>O(e,"short"),"xs:byte":(s,e)=>O(e,"byte"),"xs:nonPositiveInteger":(s,e)=>O(e,"nonPositiveInteger"),"xs:negativeInteger":(s,e)=>O(e,"negativeInteger"),"xs:nonNegativeInteger":(s,e)=>O(e,"nonNegativeInteger"),"xs:positiveInteger":(s,e)=>O(e,"positiveInteger"),"xs:unsignedLong":(s,e)=>O(e,"unsignedLong"),"xs:unsignedInt":(s,e)=>O(e,"unsignedInt"),"xs:unsignedShort":(s,e)=>O(e,"unsignedShort"),"xs:unsignedByte":(s,e)=>O(e,"unsignedByte"),QName:(s,e,t)=>Ho(e,t),"resolve-QName":(s,e,t)=>Jo(e,t),"prefix-from-QName":(s,e)=>Zo(e),"local-name-from-QName":(s,e)=>ea(e),"namespace-uri-from-QName":(s,e)=>ta(e),"in-scope-prefixes":(s,e)=>na(e),"namespace-uri-for-prefix":(s,e,t)=>ra(e,t),"resolve-uri":(s,e,t)=>oa(e,t,s),"encode-for-uri":(s,e)=>aa(e),"iri-to-uri":(s,e)=>ca(e),"escape-html-uri":(s,e)=>ua(e),root:(s,e)=>da(e,s),"base-uri":(s,e)=>Zr(e,s),"document-uri":(s,e)=>fa(e,s),nilled:(s,e)=>ha(e,s),"node-name":(s,e)=>pa(e,s),data:(s,e)=>ma(e),lang:(s,e,t)=>ya(e,t,s),"zero-or-one":(s,e)=>Ks(e),"one-or-more":(s,e)=>Hs(e),"exactly-one":(s,e)=>Js(e),unordered:(s,e)=>Qs(e)},ru={concat:[2,1/0],substring:[2,3],"string-join":[1,2],"normalize-space":[0,1],"string-length":[0,1],"local-name":[0,1],"namespace-uri":[0,1],name:[0,1],"generate-id":[0,1],path:[0,1],"has-children":[0,1],round:[1,2],"round-half-to-even":[1,2],string:[0,1],number:[0,1],replace:[3,4],matches:[2,3],tokenize:[1,3],"regex-group":[1,1],"current-group":[0,0],"current-grouping-key":[0,0],subsequence:[2,3],"insert-before":[3,3],remove:[2,2],"for-each":[2,2],filter:[2,2],"fold-left":[3,3],"fold-right":[3,3],"for-each-pair":[3,3],sort:[1,3],apply:[2,2],"function-name":[1,1],"function-arity":[1,1],"math:pi":[0,0],"math:exp":[1,1],"math:exp10":[1,1],"math:log":[1,1],"math:log10":[1,1],"math:pow":[2,2],"math:sqrt":[1,1],"math:sin":[1,1],"math:cos":[1,1],"math:tan":[1,1],"math:asin":[1,1],"math:acos":[1,1],"math:atan":[1,1],"math:atan2":[2,2],head:[1,1],tail:[1,1],innermost:[1,1],outermost:[1,1],"environment-variable":[1,1],"available-environment-variables":[0,0],"array:size":[1,1],"array:get":[2,2],"array:put":[3,3],"array:append":[2,2],"array:subarray":[2,3],"array:remove":[2,2],"array:insert-before":[3,3],"array:head":[1,1],"array:tail":[1,1],"array:reverse":[1,1],"array:join":[1,1],"array:flatten":[1,1],"array:for-each":[2,2],"array:filter":[2,2],"array:fold-left":[3,3],"array:fold-right":[3,3],"array:sort":[1,3],"map:size":[1,1],"map:keys":[1,1],"map:contains":[2,2],"map:get":[2,2],"map:put":[3,3],"map:entry":[2,2],"map:merge":[1,2],"map:for-each":[2,2],"map:remove":[2,2],"parse-json":[1,2],serialize:[1,2],"json-to-xml":[1,2],"analyze-string":[2,3],"format-integer":[2,3],"format-number":[2,3],"xs:string":[1,1],"xs:boolean":[1,1],"xs:decimal":[1,1],"xs:float":[1,1],"xs:double":[1,1],"xs:integer":[1,1],"xs:duration":[1,1],"xs:dateTime":[1,1],"xs:date":[1,1],"xs:time":[1,1],"xs:anyURI":[1,1],"xs:QName":[1,1],"xs:untypedAtomic":[1,1],"xs:gYearMonth":[1,1],"xs:gYear":[1,1],"xs:gMonthDay":[1,1],"xs:gDay":[1,1],"xs:gMonth":[1,1],"xs:hexBinary":[1,1],"xs:base64Binary":[1,1],"xs:long":[1,1],"xs:int":[1,1],"xs:short":[1,1],"xs:byte":[1,1],"xs:nonPositiveInteger":[1,1],"xs:negativeInteger":[1,1],"xs:nonNegativeInteger":[1,1],"xs:positiveInteger":[1,1],"xs:unsignedLong":[1,1],"xs:unsignedInt":[1,1],"xs:unsignedShort":[1,1],"xs:unsignedByte":[1,1],QName:[2,2],"resolve-QName":[2,2],"prefix-from-QName":[1,1],"local-name-from-QName":[1,1],"namespace-uri-from-QName":[1,1],"in-scope-prefixes":[1,1],"namespace-uri-for-prefix":[2,2],"resolve-uri":[1,2],"encode-for-uri":[1,1],"iri-to-uri":[1,1],"escape-html-uri":[1,1],root:[0,1],"base-uri":[0,1],"document-uri":[1,1],nilled:[1,1],"node-name":[1,1],data:[1,1],lang:[1,2],"zero-or-one":[1,1],"one-or-more":[1,1],"exactly-one":[1,1],unordered:[1,1]};Pe=class extends N{constructor(t,n){super();this.jsonConverter=new we;this.name=t,this.args=n}evaluate(t){var i,o,a,c,u,l;let n=this.args.map(p=>p.evaluate(t)),r=this.getConstructorType();if(r){if(n.length!==1)throw Ci(this.name,"1",n.length);let p=n[0];if(Array.isArray(p)){if(p.length===0)throw pe("single item","empty sequence",`constructor function ${this.name}`);if(p.length!==1)throw pe("single item",`sequence of ${p.length} items`,`constructor function ${this.name}`);return this.castConstructorValue(r,p[0])}if(p==null)throw pe("single item","empty sequence",`constructor function ${this.name}`);return this.castConstructorValue(r,p)}switch(this.name){case"last":return(i=t.size)!=null?i:0;case"position":return(o=t.position)!=null?o:0;case"count":return Array.isArray(n[0])?n[0].length:0;case"local-name":return this.localName(n,t);case"namespace-uri":return this.namespaceUri(n,t);case"name":return this.nodeName(n,t);case"string":return this.stringValue(n,t);case"concat":return n.map(h=>this.convertToString(h)).join("");case"starts-with":return this.convertToString(n[0]).startsWith(this.convertToString(n[1]));case"contains":return this.convertToString(n[0]).includes(this.convertToString(n[1]));case"substring-before":return this.substringBefore(n);case"substring-after":return this.substringAfter(n);case"substring":return this.substring(n);case"string-length":return this.stringLength(n,t);case"normalize-space":return this.normalizeSpace(n,t);case"translate":return this.translate(n);case"boolean":return this.toBoolean(n[0]);case"not":return!this.toBoolean(n[0]);case"true":return!0;case"false":return!1;case"lang":return this.lang(n,t);case"number":return this.toNumber(n,t);case"sum":return this.sum(n);case"floor":return Math.floor(Number(n[0]));case"ceiling":return Math.ceil(Number(n[0]));case"round":return Math.round(Number(n[0]));case"json-to-xml":return this.jsonToXml(n,t);case"regex-group":{let h=Math.floor(Number(n[0])),m=(a=t.extensions)==null?void 0:a.regexGroups;return m&&h>=0&&h<m.length&&(c=m[h])!=null?c:""}case"current-group":{let h=(u=t.extensions)==null?void 0:u.currentGroup;return h!=null?h:[]}case"current-grouping-key":{let h=(l=t.extensions)==null?void 0:l.currentGroupingKey;return h!=null?h:""}default:if(t.functions&&typeof t.functions[this.name]=="function")return t.functions[this.name](t,...n);let p=yt[this.name];if(!p&&this.name.startsWith("fn:")){let h=this.name.substring(3);p=yt[h]}if(!p&&this.name.startsWith("Q{")){let{namespace:h,localName:m}=this.parseEQName(this.name);p=yt[m],!p&&h==="http://www.w3.org/2005/xpath-functions/math"&&(p=yt["math:"+m]),!p&&h==="http://www.w3.org/2005/xpath-functions/array"&&(p=yt["array:"+m])}if(p)return p(t,...n);throw Rt(this.name,"function")}}parseEQName(t){let n=t.match(/^Q\{([^}]*)\}(.+)$/);return n?{namespace:n[1],localName:n[2]}:{namespace:"",localName:t}}getConstructorType(){if(!this.name.includes(":"))return;let[t,n]=this.name.split(":");if(n&&t==="xs")return ye(n)}castConstructorValue(t,n){try{return t.cast(n)}catch(r){throw wi(n,this.name)}}toBoolean(t){return typeof t=="boolean"?t:typeof t=="number"?t!==0&&!isNaN(t):typeof t=="string"||Array.isArray(t)?t.length>0:!!t}toNumber(t,n){let r=o=>{let a=o.trim();return a.length===0?NaN:Number(a)};if(t.length===0)return r(this.stringValue([],n));let i=t[0];if(typeof i=="object"&&i!==null&&"numberValue"in i&&typeof i.numberValue=="function")return i.numberValue();if(Array.isArray(i)){if(i.length===0)return NaN;let o=i[0],a=this.getNodeStringValue(o);return r(a)}return typeof i=="string"?r(i):Number(i)}stringValue(t,n){var i,o;if(t.length===0)return(o=(i=n.node)==null?void 0:i.textContent)!=null?o:"";let r=t[0];return Array.isArray(r)&&r.length>0?this.getNodeStringValue(r[0]):String(r)}convertToString(t){if(Array.isArray(t)){if(t.length===0)return"";let n=t[0];return this.getNodeStringValue(n)}return String(t)}getNodeStringValue(t){var n;return t?typeof t=="string"?t:typeof t=="number"?String(t):typeof t=="boolean"?t?"true":"false":typeof t.textContent=="string"?t.textContent:t.nodeType===3||t.nodeType===2?(n=t.nodeValue)!=null?n:"":t.nodeType===1||t.nodeType===9||t.nodeType===11?this.getDescendantTextContent(t):t.nodeValue!==void 0&&t.nodeValue!==null?String(t.nodeValue):"":""}getDescendantTextContent(t){var r;if(!t.childNodes||t.childNodes.length===0)return"";let n="";for(let i=0;i<t.childNodes.length;i++){let o=t.childNodes[i];o.nodeType===3?n+=(r=o.nodeValue)!=null?r:"":o.nodeType===1&&(n+=this.getDescendantTextContent(o))}return n}stringLength(t,n){return t.length===0?this.stringValue([],n).length:this.convertToString(t[0]).length}normalizeSpace(t,n){return(t.length===0?this.stringValue([],n):this.convertToString(t[0])).trim().replace(/\s+/g," ")}substringBefore(t){let n=this.convertToString(t[0]),r=this.convertToString(t[1]),i=n.indexOf(r);return i===-1?"":n.substring(0,i)}substringAfter(t){let n=this.convertToString(t[0]),r=this.convertToString(t[1]),i=n.indexOf(r);return i===-1?"":n.substring(i+r.length)}substring(t){let n=this.convertToString(t[0]),r=Math.round(Number(t[1]))-1;if(t.length===2)return n.substring(Math.max(0,r));let i=Math.round(Number(t[2])),o=Math.max(0,r),a=Math.min(i-(o-r),n.length-o);return n.substring(o,o+a)}translate(t){let n=this.convertToString(t[0]),r=this.convertToString(t[1]),i=this.convertToString(t[2]),o="";for(let a of n){let c=r.indexOf(a);c===-1?o+=a:c<i.length&&(o+=i[c])}return o}localName(t,n){var i;let r=this.getNodeArg(t,n);return(i=r==null?void 0:r.localName)!=null?i:""}namespaceUri(t,n){var i;let r=this.getNodeArg(t,n);return(i=r==null?void 0:r.namespaceUri)!=null?i:""}nodeName(t,n){var i;let r=this.getNodeArg(t,n);return(i=r==null?void 0:r.nodeName)!=null?i:""}getNodeArg(t,n){return t.length>0&&Array.isArray(t[0])&&t[0].length>0?t[0][0]:n.node}sum(t){let n=t[0];return Array.isArray(n)?n.reduce((r,i)=>{var a;let o=Number((a=i==null?void 0:i.textContent)!=null?a:this.getNodeStringValue(i));return r+(isNaN(o)?0:o)},0):0}lang(t,n){var o,a;let r=String(t[0]).toLowerCase(),i=n.node;for(;i;){let c=((o=i.getAttribute)==null?void 0:o.call(i,"xml:lang"))||((a=i.getAttribute)==null?void 0:a.call(i,"lang"));if(c){let u=c.toLowerCase();return u===r||u.startsWith(r+"-")}i=i.parentNode}return!1}jsonToXml(t,n){if(n.xsltVersion&&n.xsltVersion!=="3.0")throw new Error('json-to-xml() is only supported in XSLT 3.0. Use version="3.0" in your stylesheet.');let r=t.length>0?String(t[0]):null,i;t.length>1&&typeof t[1]=="object"&&t[1]!==null&&(i=this.mapToOptions(t[1]));let o=this.jsonConverter.convert(r,i);return o?[o]:[]}mapToOptions(t){let n={};if(t.liberal!==void 0&&(n.liberal=!!t.liberal),t.duplicates!==void 0){let r=String(t.duplicates).toLowerCase();(r==="reject"||r==="use-first"||r==="retain")&&(n.duplicates=r)}return t.validate!==void 0&&(n.validate=!!t.validate),t.escape!==void 0&&(n.escape=!!t.escape),t.fallback!==void 0&&typeof t.fallback=="function"&&(n.fallback=t.fallback),n}}});var Xn,ei=g(()=>{_();Xn=class extends N{constructor(e,t){super(),this.bindings=e,this.returnExpr=t}evaluate(e){var r;let t=X({},(r=e.variables)!=null?r:{}),n=I(X({},e),{variables:t});for(let i of this.bindings){let o=i.expression.evaluate(n);t[i.variable]=o,n=I(X({},n),{variables:X({},t)})}return this.returnExpr.evaluate(n)}toString(){return`let ${this.bindings.map(t=>`$${t.variable} := ${t.expression}`).join(", ")} return ${this.returnExpr}`}}});var Sn,ti=g(()=>{_();Sn=class extends N{constructor(e,t){super(),this.left=e,this.right=t}evaluate(e){let t=this.left.evaluate(e),n=this.normalizeToSequence(t);if(n.length===0)return[];let r=[],i=n.length;for(let o=0;o<i;o++){let a=n[o],c=I(X({},e),{position:o+1,size:i});this.isNode(a)&&(c.node=a),c.contextItem=a;let u=this.right.evaluate(c);this.appendResults(r,u)}return r}normalizeToSequence(e){return e==null?[]:Array.isArray(e)?e:[e]}isNode(e){return e&&typeof e=="object"&&"nodeType"in e}appendResults(e,t){t!=null&&(Array.isArray(t)?e.push(...t):e.push(t))}toString(){return`${this.left} ! ${this.right}`}}});var Cn,ni=g(()=>{_();Cn=class extends N{constructor(e,t){super(),this.left=e,this.right=t}evaluate(e){let t=this.left.evaluate(e),n=this.right.evaluate(e),r=this.atomizeToString(t),i=this.atomizeToString(n);return r+i}atomizeToString(e){return e==null?"":typeof e=="object"&&"stringValue"in e&&typeof e.stringValue=="function"?e.stringValue():Array.isArray(e)?e.length===0?"":this.valueToString(e[0]):this.valueToString(e)}valueToString(e){return e==null?"":typeof e=="object"&&"stringValue"in e&&typeof e.stringValue=="function"?e.stringValue():typeof e=="string"?e:typeof e=="number"?Number.isNaN(e)?"NaN":e===1/0?"INF":e===-1/0?"-INF":String(e):typeof e=="boolean"?e?"true":"false":this.isNode(e)?this.getNodeStringValue(e):String(e)}isNode(e){return e&&typeof e=="object"&&"nodeType"in e}getNodeStringValue(e){return e?e.nodeType===3||e.nodeType===4?e.nodeValue||"":e.nodeType===2?e.value||e.nodeValue||"":e.nodeType===1||e.nodeType===9?e.textContent||"":(e.nodeType===7||e.nodeType===8)&&e.nodeValue||"":""}toString(){return`${this.left} || ${this.right}`}}});function ri(s){let e=[],t="",n=0;for(;n<s.length;){let r=s[n];if(r==="\\"&&n+1<s.length)switch(s[n+1]){case"`":t+="`",n+=2;break;case"{":t+="{",n+=2;break;case"}":t+="}",n+=2;break;case"n":t+=`
|
|
5
|
-
`,n+=2;break;case"r":t+="\r",n+=2;break;case"t":t+=" ",n+=2;break;case"\\":t+="\\",n+=2;break;default:t+=r,n++}else if(r==="{"&&n+1<s.length&&s[n+1]!=="{"){t.length>0&&(e.push(t),t="");let i=1,o=n+1;for(;o<s.length&&i>0;)s[o]==="{"&&s[o-1]!=="\\"?i++:s[o]==="}"&&s[o-1]!=="\\"&&i--,o++;if(i!==0)throw new Error("Unclosed expression in string template");let a=s.substring(n+1,o-1);e.push({expressionString:a}),n=o}else t+=r,n++}return t.length>0&&e.push(t),e}var wn,ii=g(()=>{wn=class{constructor(e){this.parts=e}evaluate(e){let t=[];for(let n of this.parts)if(typeof n=="string")t.push(n);else{let r=n.evaluate(e);t.push(this.valueToString(r))}return t.join("")}valueToString(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number")return Number.isNaN(e)?"NaN":e===1/0?"INF":e===-1/0?"-INF":String(e);if(typeof e=="boolean")return e?"true":"false";if(Array.isArray(e))return e.length===0?"":this.valueToString(e[0]);if(typeof e=="object"&&e!==null){if("nodeType"in e&&e.nodeType)return this.getNodeStringValue(e);if(typeof e.toString=="function"){let t=e.toString();if(t!=="[object Object]")return t}}return String(e)}getNodeStringValue(e){return e.textContent!==void 0?String(e.textContent):e.nodeType===3?e.data||e.textContent||"":e.nodeType===1||e.nodeType===9?this.getDescendantTextContent(e):""}getDescendantTextContent(e){var n,r;let t=[];if("childNodes"in e&&Array.isArray(e.childNodes))for(let i of e.childNodes)i.nodeType===3?t.push((r=(n=i.textContent)!=null?n:i.data)!=null?r:""):i.nodeType===1&&t.push(this.getDescendantTextContent(i));return t.join("")}}});var An,si=g(()=>{_();Tn();An=class extends N{constructor(e,t,n){super(),this.input=e,this.functionName=t,this.args=n}evaluate(e){let t=[this.input,...this.args];return new Pe(this.functionName,t).evaluate(e)}toString(){let e=this.args.length>0?this.args.map(t=>t.toString()).join(", "):"";return`${this.input} => ${this.functionName}(${e})`}}});var On,oi=g(()=>{pn();_();Tn();On=class extends N{constructor(e,t){super(),this.name=e,this.arity=t}evaluate(e){let t=this.resolveFunction(e);if(!t)throw new Error(`Unknown function: ${this.name}#${this.arity}`);return t}resolveFunction(e){let{namespace:t,localName:n}=this.parseNameWithNamespace(this.name,e),r=t,i=Pn(n),o=n;if(!i&&r===ln&&(i=Pn("math:"+n),o="math:"+n),i){if(lr(o)!==void 0&&!this.arityMatches(o,this.arity))throw new Error(`Function ${this.name} does not accept ${this.arity} arguments`);return{__isFunctionItem:!0,implementation:(...u)=>i(e,...u),arity:this.arity,name:n,namespace:r}}if(e.functionRegistry){let a=e.functionRegistry[n]||e.functionRegistry[this.name];if(a)return{__isFunctionItem:!0,implementation:a,arity:this.arity,name:n,namespace:r}}if(e.functions){let a=e.functions[this.name]||e.functions[n];if(a)return{__isFunctionItem:!0,implementation:a,arity:this.arity,name:n,namespace:r}}return null}arityMatches(e,t){let r={concat:[2,1/0],substring:[2,3],"string-join":[1,2],"normalize-space":[0,1],"string-length":[0,1],"local-name":[0,1],"namespace-uri":[0,1],name:[0,1],round:[1,2],"format-number":[2,3]}[e];return r?t>=r[0]&&t<=r[1]:t>=0&&t<=10}parseNameWithNamespace(e,t){if(e.startsWith("Q{")){let r=e.match(/^Q\{([^}]*)\}(.+)$/);if(r){let[,i,o]=r;return{namespace:i||void 0,localName:o}}}let n=e.indexOf(":");if(n>0){let r=e.substring(0,n),i=e.substring(n+1),o;return r==="fn"?o=un:r==="math"?o=ln:t.namespaces&&t.namespaces[r]&&(o=t.namespaces[r]),{namespace:o,localName:i}}return{namespace:un,localName:e}}toString(){return`${this.name}#${this.arity}`}}});var vn,ai=g(()=>{_();vn=class extends N{constructor(e,t,n){super(),this.params=e,this.body=t,this.returnType=n}evaluate(e){var i;let t=X({},(i=e.variables)!=null?i:{}),n=this;return{__isFunctionItem:!0,implementation:function(...o){let a=X({},t);for(let u=0;u<n.params.length;u++){let l=n.params[u],p=u<o.length?o[u]:null;a[l.name]=p}let c=I(X({},e),{variables:a});return n.body.evaluate(c)},arity:this.params.length,name:void 0,namespace:void 0}}toString(){let t=`function(${this.params.map(n=>{let r=`$${n.name}`;return n.type&&(r+=` as ${n.type}`),r}).join(", ")})`;return this.returnType&&(t+=` as ${this.returnType}`),t+=` { ${this.body} }`,t}}});function iu(s){return s&&typeof s=="object"&&s.__isFunctionItem===!0}var gt,ci=g(()=>{_();De();Ve();gt=class extends N{constructor(e,t){super(),this.functionExpr=e,this.args=t}evaluate(e){let t=this.functionExpr.evaluate(e);if(Q(t)){if(this.args.length!==1)throw new Error(`Map lookup expects 1 argument but got ${this.args.length}`);let n=String(this.args[0].evaluate(e)),r=t[n];if(r===void 0)throw new Error(`XPDY0002: Key "${n}" not found in map`);return r}if(re(t)){if(this.args.length!==1)throw new Error(`Array lookup expects 1 argument but got ${this.args.length}`);let n=Number(this.args[0].evaluate(e));return Fr(t,n)}if(iu(t)){let n=t;if(n.arity!==this.args.length)throw new Error(`Function expects ${n.arity} arguments but got ${this.args.length}`);let r=this.args.map(i=>i.evaluate(e));return n.implementation(...r)}if(typeof t=="function"){let n=this.args.map(r=>r.evaluate(e));return t(...n)}throw new Error("Dynamic function call: expression does not evaluate to a function item")}toString(){let e=this.args.map(t=>t.toString()).join(", ");return`${this.functionExpr}(${e})`}}});function su(s,e,t,n){return new xt(s,e,t,n)}function Sa(s){return new xt(s,null)}function ou(s,e){let t=new class extends N{evaluate(){return e}toString(){return JSON.stringify(e)}};return new xt(s,t)}function cu(s,e){return Sa(s).evaluate(e)}var xt,au,Ca=g(()=>{_();xt=class extends N{constructor(e,t,n,r){super(),this.tryExpr=e,this.catchExpr=t||null,this.errorPattern=n||null,this.errorVariableName=r||null}evaluate(e){try{let t=this.tryExpr.evaluate(e);return t&&typeof t=="object"&&typeof t.catch=="function"?t.catch(n=>this.handleError(n,e)):t}catch(t){return this.catchExpr?this.handleError(t,e):void 0}}handleError(e,t){let n=this.createCaughtError(e);if(this.errorPattern&&!this.matchesErrorPattern(n,this.errorPattern))throw e;let r={node:t.node,position:t.position,size:t.size,variables:t.variables?new Map(t.variables):new Map,functions:t.functions||{}};return this.errorVariableName&&r.variables.set(this.errorVariableName,n),r.variables.set("err:code",n.code),r.variables.set("err:description",n.description),r.variables.set("err:value",n.value),this.catchExpr.evaluate(r)}createCaughtError(e){let t="UNKNOWN",n="Unknown error",r="dynamic";return typeof e=="string"?n=e:e&&typeof e=="object"&&(e.message&&(n=e.message),e.code&&(t=e.code),e.type&&(r=e.type)),{code:t,description:n,value:e,stack:e==null?void 0:e.stack,type:r}}matchesErrorPattern(e,t){return t==="*"?!0:e.code===t||e.code.includes(t)}toString(){let e=`try { ${this.tryExpr.toString()} }`;return this.catchExpr&&(e+=" catch",this.errorPattern&&(e+=` (${this.errorPattern})`),e+=` { ${this.catchExpr.toString()} }`),e}};au={XPTY0004:"XPTY0004",FOAR0001:"FOAR0001",FORG0001:"FORG0001",FONS0004:"FONS0004",FORG0004:"FORG0004",FORG0005:"FORG0005",XPST0008:"XPST0008",XPTY0019:"XPTY0019",FODF1310:"FODF1310",XPST0051:"XPST0051"}});var ui,Rn,li=g(()=>{Ve();De();ui=(r=>(r.NCNAME="NCNAME",r.INTEGER_LITERAL="INTEGER_LITERAL",r.PARENTHESIZED_EXPR="PARENTHESIZED_EXPR",r.WILDCARD="WILDCARD",r))(ui||{}),Rn=class{constructor(e,t){this.baseExpr=e;this.keySpecifier=t}evaluate(e){let t;if(this.baseExpr)t=this.baseExpr.evaluate(e);else if(t=e.contextItem,t===void 0)throw new Error("XPDY0002: Context item is undefined for unary lookup");if(Q(t))return this.lookupInMap(t,this.keySpecifier,e);if(re(t))return this.lookupInArray(t,this.keySpecifier,e);throw new Error("XPTY0004: Lookup operator can only be applied to maps and arrays")}lookupInMap(e,t,n){switch(t.type){case"NCNAME":let r=t.value;return e[r];case"INTEGER_LITERAL":let i=t.value.toString();return e[i];case"PARENTHESIZED_EXPR":let a=t.value.evaluate(n),c=this.atomizeToString(a);return e[c];case"WILDCARD":return Object.keys(e).filter(u=>!u.startsWith("__")).map(u=>e[u]);default:throw new Error("FOAY0001: Invalid key specifier for map lookup")}}lookupInArray(e,t,n){switch(t.type){case"INTEGER_LITERAL":let r=t.value;if(r<1)throw new Error("FOAY0001: Array index must be positive");if(r>e.members.length)throw new Error("FOAY0001: Array index out of bounds");return e.members[r-1];case"PARENTHESIZED_EXPR":let o=t.value.evaluate(n),a=this.atomizeToNumber(o);if(a<1)throw new Error("FOAY0001: Array index must be positive");if(a>e.members.length)throw new Error("FOAY0001: Array index out of bounds");return e.members[a-1];case"WILDCARD":return this.flattenArrayMembers(e.members);case"NCNAME":throw new Error("XPTY0004: NCName key not valid for array lookup");default:throw new Error("FOAY0001: Invalid key specifier for array lookup")}}flattenArrayMembers(e){let t=[];for(let n of e)re(n)?t.push(...this.flattenArrayMembers(n.members)):t.push(n);return t}atomizeToString(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return e.toString();if(Array.isArray(e))return e.length===0?"":e.length===1?this.atomizeToString(e[0]):this.atomizeToString(e[0]);if(typeof e=="object"&&e.$isXPathMap)throw new Error("XPTY0004: Cannot atomize a map to string");if(typeof e=="object"&&(e.nodeType||e.nodeName||e.textContent))return(e.textContent||e.value||"").toString();if(typeof e=="function")throw new Error("XPTY0004: Cannot atomize a function item");try{return String(e)}catch(t){throw new Error("XPTY0004: Cannot atomize value")}}atomizeToNumber(e){if(e==null)throw new Error("XPTY0004: Cannot convert empty sequence to number");if(typeof e=="number")return e;if(typeof e=="string"){let t=parseFloat(e);if(isNaN(t))throw new Error("FORG0001: Invalid number");return t}if(typeof e=="boolean")throw new Error("XPTY0004: Cannot convert boolean to number for array index");if(Array.isArray(e)){if(e.length===0)throw new Error("XPTY0004: Cannot convert empty sequence to number");if(e.length===1)return this.atomizeToNumber(e[0]);throw new Error("XPTY0004: Cannot convert sequence to single number")}if(typeof e=="object"&&e.$isXPathMap)throw new Error("XPTY0004: Cannot atomize a map to number");if(typeof e=="object"&&(e.nodeType||e.nodeName||e.textContent)){let t=(e.textContent||e.value||"").toString(),n=parseFloat(t);if(isNaN(n))throw new Error("FORG0001: Invalid number from node");return n}throw typeof e=="function"?new Error("XPTY0004: Cannot atomize a function item"):new Error("FORG0001: Cannot convert to number")}toString(){let e=this.baseExpr?this.baseExpr.toString():"",t;switch(this.keySpecifier.type){case"NCNAME":t=this.keySpecifier.value;break;case"INTEGER_LITERAL":t=this.keySpecifier.value.toString();break;case"PARENTHESIZED_EXPR":t=`(${this.keySpecifier.value})`;break;case"WILDCARD":t="*";break;default:t="?"}return e+"?"+t}}});var $e={};ze($e,{CommaExpression:()=>yn,EmptySequenceExpression:()=>xn,FilteredPathExpression:()=>_t,GeneralComparisonExpression:()=>qr,JsonToXmlConverter:()=>we,KeySpecifierType:()=>ui,NodeComparisonExpression:()=>Br,ParenthesizedExpression:()=>Ur,RangeExpression:()=>gn,StringTemplateExpression:()=>wn,TryExpression:()=>xt,ValueComparisonExpression:()=>Wr,XPathArithmeticExpression:()=>Ye,XPathArrowExpression:()=>An,XPathBinaryExpression:()=>rt,XPathCastableExpression:()=>fn,XPathConditionalExpression:()=>Dt,XPathCurlyBraceArrayConstructor:()=>pt,XPathDynamicFunctionCall:()=>gt,XPathExpression:()=>N,XPathFilterExpression:()=>It,XPathForExpression:()=>Vt,XPathFunctionCall:()=>Pe,XPathInlineFunctionExpression:()=>vn,XPathInstanceOfExpression:()=>mn,XPathLetExpression:()=>Xn,XPathLocationPath:()=>Ee,XPathLogicalExpression:()=>it,XPathLookupExpression:()=>Rn,XPathMapConstructorExpression:()=>ut,XPathNamedFunctionRef:()=>On,XPathNumberLiteral:()=>vt,XPathPredicate:()=>Nn,XPathQuantifiedExpression:()=>Ft,XPathSimpleMapExpression:()=>Sn,XPathSquareBracketArrayConstructor:()=>lt,XPathStep:()=>Ne,XPathStringConcatExpression:()=>Cn,XPathStringLiteral:()=>Ot,XPathTreatExpression:()=>dn,XPathUnaryExpression:()=>kt,XPathUnionExpression:()=>Ce,XPathVariableReference:()=>xe,XSLT3ErrorCodes:()=>au,concatenateSequences:()=>Fc,createSequence:()=>Dc,createTryExpression:()=>su,createTryOnly:()=>Sa,createTryWithFallback:()=>ou,createXPathArray:()=>B,flattenSequence:()=>Vc,getArrayMember:()=>Fr,getArraySize:()=>pc,getBuiltInFunction:()=>Pn,getBuiltInFunctionArity:()=>lr,getNodeId:()=>$c,isXPathArray:()=>re,isXPathMap:()=>Q,isXPathNode:()=>Ns,parseStringTemplate:()=>ri,safeEvaluate:()=>cu});var ce=g(()=>{_();bi();Ai();Oi();vi();Ri();Ii();_i();Mi();ki();Di();Vi();Fi();ds();ys();gs();xs();Es();bs();Ps();Ts();Xs();Tn();En();ei();ti();ni();ii();si();oi();ai();ci();Ca();De();Ve();li()});var Mu={};ze(Mu,{ExprContext:()=>qe,XDocument:()=>ue,XNode:()=>k,XPath:()=>tt,XmlParser:()=>Ue,Xslt:()=>Ir,domDocumentToXDocument:()=>Ia,xmlEscapeText:()=>_n,xmlTransformedText:()=>Mn});var C=class{constructor(e,t){this.type=e,this.lexeme=t}};var Ei="1.0",sc={ancestor:{type:"LOCATION",value:"ancestor"},"ancestor-or-self":{type:"LOCATION",value:"ancestor-or-self"},attribute:{type:"LOCATION",value:"attribute"},child:{type:"LOCATION",value:"child"},descendant:{type:"LOCATION",value:"descendant"},"descendant-or-self":{type:"LOCATION",value:"descendant-or-self"},following:{type:"LOCATION",value:"following"},"following-sibling":{type:"LOCATION",value:"following-sibling"},namespace:{type:"LOCATION",value:"namespace"},parent:{type:"LOCATION",value:"parent"},preceding:{type:"LOCATION",value:"preceding"},"preceding-sibling":{type:"LOCATION",value:"preceding-sibling"},self:{type:"LOCATION",value:"self"},node:{type:"NODE_TYPE",value:"node"},text:{type:"NODE_TYPE",value:"text"},comment:{type:"NODE_TYPE",value:"comment"},"processing-instruction":{type:"NODE_TYPE",value:"processing-instruction"},and:{type:"OPERATOR",value:"and"},or:{type:"OPERATOR",value:"or"},div:{type:"OPERATOR",value:"div"},mod:{type:"OPERATOR",value:"mod"},last:{type:"FUNCTION",value:"last"},position:{type:"FUNCTION",value:"position"},count:{type:"FUNCTION",value:"count"},id:{type:"FUNCTION",value:"id"},"local-name":{type:"FUNCTION",value:"local-name"},"namespace-uri":{type:"FUNCTION",value:"namespace-uri"},name:{type:"FUNCTION",value:"name"},string:{type:"FUNCTION",value:"string"},concat:{type:"FUNCTION",value:"concat"},"starts-with":{type:"FUNCTION",value:"starts-with"},contains:{type:"FUNCTION",value:"contains"},"substring-before":{type:"FUNCTION",value:"substring-before"},"substring-after":{type:"FUNCTION",value:"substring-after"},substring:{type:"FUNCTION",value:"substring"},"string-length":{type:"FUNCTION",value:"string-length"},"normalize-space":{type:"FUNCTION",value:"normalize-space"},translate:{type:"FUNCTION",value:"translate"},boolean:{type:"FUNCTION",value:"boolean"},not:{type:"FUNCTION",value:"not"},true:{type:"FUNCTION",value:"true"},false:{type:"FUNCTION",value:"false"},lang:{type:"FUNCTION",value:"lang"},number:{type:"FUNCTION",value:"number"},sum:{type:"FUNCTION",value:"sum"},floor:{type:"FUNCTION",value:"floor"},ceiling:{type:"FUNCTION",value:"ceiling"},round:{type:"FUNCTION",value:"round"}},oc={if:{type:"RESERVED_WORD",value:"if"},then:{type:"RESERVED_WORD",value:"then"},else:{type:"RESERVED_WORD",value:"else"},for:{type:"RESERVED_WORD",value:"for"},in:{type:"RESERVED_WORD",value:"in"},return:{type:"RESERVED_WORD",value:"return"},some:{type:"RESERVED_WORD",value:"some"},every:{type:"RESERVED_WORD",value:"every"},satisfies:{type:"RESERVED_WORD",value:"satisfies"},instance:{type:"RESERVED_WORD",value:"instance"},of:{type:"RESERVED_WORD",value:"of"},cast:{type:"RESERVED_WORD",value:"cast"},as:{type:"RESERVED_WORD",value:"as"},castable:{type:"RESERVED_WORD",value:"castable"},treat:{type:"RESERVED_WORD",value:"treat"},to:{type:"RESERVED_WORD",value:"to"}},ac={let:{type:"RESERVED_WORD",value:"let"},function:{type:"RESERVED_WORD",value:"function"}},cc={map:{type:"RESERVED_WORD",value:"map"},array:{type:"RESERVED_WORD",value:"array"}};function uc(s){let e=X({},sc);return s!=="1.0"&&Object.assign(e,oc),(s==="3.0"||s==="3.1")&&Object.assign(e,ac),s==="3.1"&&Object.assign(e,cc),e}var Ie=class{constructor(e){var t;typeof e=="object"?this.version=(t=e.version)!=null?t:Ei:this.version=e!=null?e:Ei,this.reservedWords=uc(this.version)}getVersion(){return this.version}registerFunctions(e){this.additionalFunctions||(this.additionalFunctions=new Set);for(let t of e)this.additionalFunctions.add(t)}isAlpha(e){return/^[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]$/.test(e)}isAlphaNumeric(e){return/^[a-zA-Z0-9_\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0300-\u036F\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]$/.test(e)}isNumber(e){return/^[0-9]$/.test(e)}isWhitespace(e){return/^[\s\t\n\r]$/.test(e)}peek(){return this.expression[this.current]}peekNext(){return this.expression[this.current+1]}next(){return this.expression[this.current++]}match(e){return this.current>=this.expression.length||this.expression[this.current]!==e?!1:(this.current++,!0)}parseIdentifier(e){let t=e;for(;this.current<this.expression.length;){let r=this.expression[this.current];if(this.isAlphaNumeric(r))t+=this.next();else if(r==="-"){let i=this.expression[this.current+1];if(i&&this.isAlphaNumeric(i))for(this.current++,t+="-";this.current<this.expression.length&&this.isAlphaNumeric(this.expression[this.current]);)t+=this.next();else break}else break}let n=this.reservedWords[t.toLowerCase()];if(n)return new C(n.type,t);if(this.additionalFunctions&&this.additionalFunctions.has(t))return new C("FUNCTION",t);if(t.length>0)return new C("IDENTIFIER",t);throw new Error(`Invalid identifier: ${t}`)}parseString(e){let t="";for(;this.current<this.expression.length&&this.expression[this.current]!==e;)t+=this.next();if(this.current>=this.expression.length)throw new Error("Unterminated string literal");return this.next(),new C("STRING",t)}parseStringTemplate(){let e="",t=0;for(;this.current<this.expression.length;){let n=this.expression[this.current];if(n==="\\"&&this.current+1<this.expression.length){let r=this.expression[this.current+1];if(r==="`"||r==="{"||r==="}"||r==="n"||r==="r"||r==="t"||r==="\\"){e+=n,this.next(),e+=this.next();continue}}if(n==="`"&&t===0)return this.next(),new C("STRING_TEMPLATE",e);n==="{"?t++:n==="}"&&t--,e+=this.next()}throw new Error("Unterminated string template")}parseNumber(e){let t=e;for(;this.current<this.expression.length&&this.isNumber(this.expression[this.current])&&this.expression[this.current]!==".";)t+=this.next();if(this.current<this.expression.length&&this.expression[this.current]===".")for(t+=this.next();this.current<this.expression.length&&this.isNumber(this.expression[this.current]);)t+=this.next();if(t.length>0)return new C("NUMBER",t);throw new Error(`Invalid number: ${t}`)}parseEQName(){this.next();let e="";for(;this.current<this.expression.length&&this.expression[this.current]!=="}";)e+=this.next();if(this.current>=this.expression.length)throw new Error("Unterminated EQName: missing '}' after URI");this.next();let t="";if(this.current<this.expression.length&&this.isAlpha(this.expression[this.current]))for(;this.current<this.expression.length;){let r=this.expression[this.current];if(this.isAlphaNumeric(r)||r==="-"||r==="_")t+=this.next();else break}if(t.length===0)throw new Error(`EQName missing local name after '}': Q{${e}}`);let n=`Q{${e}}${t}`;return new C("EQNAME",n)}scanToken(){let e=this.next();if(this.isWhitespace(e))return null;switch(e){case"@":return new C("AT",e);case"$":return new C("DOLLAR",e);case"|":return this.match("|")?new C("CONCAT","||"):new C("PIPE",e);case"#":return new C("HASH",e);case"{":return new C("OPEN_CURLY_BRACKET",e);case"}":return new C("CLOSE_CURLY_BRACKET",e);case"[":return new C("OPEN_SQUARE_BRACKET",e);case"]":return new C("CLOSE_SQUARE_BRACKET",e);case"(":return new C("OPEN_PAREN",e);case")":return new C("CLOSE_PAREN",e);case"+":return new C("PLUS",e);case"-":return new C("MINUS",e);case"*":return new C("ASTERISK",e);case",":return new C("COMMA",e);case"?":return new C("QUESTION",e);case"Q":return this.peek()==="{"?this.parseEQName():this.parseIdentifier(e);case".":return this.match(".")?new C("DOT_DOT",".."):this.peek()&&this.isNumber(this.peek())?this.parseNumber(e):new C("DOT",e);case"/":return this.match("/")?new C("DOUBLE_SLASH","//"):new C("SLASH",e);case":":return this.match(":")?new C("COLON_COLON","::"):this.match("=")?new C("ASSIGNMENT",":="):new C("COLON",e);case"=":return this.match(">")?new C("FAT_ARROW","=>"):new C("EQUALS",e);case"!":return this.match("=")?new C("NOT_EQUALS","!="):new C("SIMPLE_MAP",e);case"<":return this.match("=")?new C("LESS_THAN_OR_EQUAL","<="):new C("LESS_THAN",e);case">":return this.match("=")?new C("GREATER_THAN_OR_EQUAL",">="):new C("GREATER_THAN",e);case"'":return this.parseString("'");case'"':return this.parseString('"');case"`":return this.parseStringTemplate();default:if(this.isNumber(e))return this.parseNumber(e);if(this.isAlpha(e))return this.parseIdentifier(e);throw new Error(`Unexpected character: ${e}`)}}scan(e){for(this.expression=e,this.tokens=[],this.current=0;this.current<this.expression.length;){let t=this.scanToken();t!==null&&this.tokens.push(t)}return this.tokens}};ce();Qe();je();var uu=(s,e)=>(new Set(s).has(e)||s.push(e),Array.from(new Set(s)));function wa(s){var r,i,o,a,c,u,l,p,h,m;let e=s!=null&&s.reservedFunctionNames?new Set(s.reservedFunctionNames):new Set(Xi),t=(r=s==null?void 0:s.defaultCollation)!=null?r:_r,n=uu((i=s==null?void 0:s.collations)!=null?i:[_r],t);return{schemaTypes:(o=s==null?void 0:s.schemaTypes)!=null?o:{},elementDeclarations:(a=s==null?void 0:s.elementDeclarations)!=null?a:{},attributeDeclarations:(c=s==null?void 0:s.attributeDeclarations)!=null?c:{},defaultElementNamespace:(u=s==null?void 0:s.defaultElementNamespace)!=null?u:"",defaultTypeNamespace:(l=s==null?void 0:s.defaultTypeNamespace)!=null?l:v,functionSignatures:(p=s==null?void 0:s.functionSignatures)!=null?p:{},defaultFunctionNamespace:(h=s==null?void 0:s.defaultFunctionNamespace)!=null?h:Ti,reservedFunctionNames:e,collations:n,defaultCollation:t,variableTypes:(m=s==null?void 0:s.variableTypes)!=null?m:{},contextItemType:s==null?void 0:s.contextItemType}}function Aa(s){let e=[],t=new Set;for(let n of s.functions)t.has(n.name)&&e.push(`Duplicate function name: ${n.name}`),t.add(n.name),n.minArgs<0&&e.push(`Function ${n.name}: minArgs cannot be negative`),n.maxArgs!==void 0&&n.maxArgs<n.minArgs&&e.push(`Function ${n.name}: maxArgs cannot be less than minArgs`),typeof n.implementation!="function"&&e.push(`Function ${n.name}: implementation must be a function`);return e}_e();var Oa={XPWD0001:{code:"XPWD0001",severity:"deprecation",category:"deprecation",title:"Namespace axis deprecated",description:"The namespace axis (namespace::) is deprecated in XPath 2.0 and may not be supported in all implementations. Consider using fn:namespace-uri-for-prefix() or fn:in-scope-prefixes() instead.",migration:"Replace namespace::* with fn:in-scope-prefixes(.) to get namespace prefixes, or use fn:namespace-uri-for-prefix($prefix, .) to get namespace URIs.",specReference:"XPath 2.0 Section 3.2.1.1"},XPWD0002:{code:"XPWD0002",severity:"deprecation",category:"deprecation",title:"Implicit string conversion",description:"Implicit conversion of node-sets to strings using the first node is deprecated. In XPath 2.0, this requires explicit conversion using fn:string() or data().",migration:"Use fn:string($nodeset) or fn:data($nodeset) for explicit conversion.",specReference:"XPath 2.0 Appendix I.2"},XPWC0001:{code:"XPWC0001",severity:"warning",category:"compatibility",title:"XPath 1.0 compatibility mode active",description:"XPath 1.0 compatibility mode is enabled. Some XPath 2.0 type safety features are relaxed to maintain backward compatibility.",migration:"Consider migrating to XPath 2.0 semantics for improved type safety.",specReference:"XPath 2.0 Section 3.6"},XPWC0002:{code:"XPWC0002",severity:"warning",category:"compatibility",title:"String comparison in XPath 2.0",description:"String comparisons in XPath 2.0 are performed using Unicode codepoint collation by default, which may produce different results than XPath 1.0.",migration:"Use explicit collation specification if locale-specific comparison is needed.",specReference:"XPath 2.0 Appendix I.4"},XPWC0003:{code:"XPWC0003",severity:"warning",category:"compatibility",title:"Empty sequence handling differs",description:"In XPath 2.0, operations on empty sequences may return empty sequences instead of NaN or false as in XPath 1.0.",migration:"Use explicit empty sequence handling with fn:empty() or default values.",specReference:"XPath 2.0 Appendix I.3"},XPWT0001:{code:"XPWT0001",severity:"warning",category:"type-coercion",title:"Implicit numeric conversion",description:"Value is being implicitly converted to a number. In XPath 2.0, this requires explicit conversion in strict mode.",migration:"Use xs:decimal(), xs:double(), or number() for explicit conversion.",specReference:"XPath 2.0 Appendix I.2"},XPWT0002:{code:"XPWT0002",severity:"warning",category:"type-coercion",title:"Implicit boolean conversion",description:"Value is being implicitly converted to boolean using XPath 1.0 rules. In XPath 2.0, this is called Effective Boolean Value (EBV).",migration:"Use fn:boolean() for explicit conversion.",specReference:"XPath 2.0 Section 2.4.3"},XPWT0003:{code:"XPWT0003",severity:"info",category:"type-coercion",title:"Numeric type promotion",description:"Numeric value is being promoted in the type hierarchy (integer \u2192 decimal \u2192 float \u2192 double). This may result in precision loss.",migration:"Consider using explicit casting if precision is important.",specReference:"XPath 2.0 Appendix B.1"},XPWB0001:{code:"XPWB0001",severity:"warning",category:"behavior-change",title:"Arithmetic with empty sequence",description:"In XPath 2.0, arithmetic operations with empty sequences return empty sequences, not NaN as in XPath 1.0.",migration:"Handle empty sequences explicitly before arithmetic operations.",specReference:"XPath 2.0 Appendix I.3"},XPWB0002:{code:"XPWB0002",severity:"warning",category:"behavior-change",title:"Comparison with empty sequence",description:"In XPath 2.0, value comparisons (eq, ne, etc.) with empty sequences return empty sequences, not false.",migration:"Use fn:empty() or fn:exists() to check for empty sequences before comparison.",specReference:"XPath 2.0 Appendix I.3"},XPWB0003:{code:"XPWB0003",severity:"warning",category:"behavior-change",title:"Multiple values in singleton context",description:"A sequence with multiple items is being used where a single item is expected. In XPath 2.0, this may raise a type error.",migration:"Use predicates or fn:head() to select a single item.",specReference:"XPath 2.0 Section 2.4.4"},XPWB0004:{code:"XPWB0004",severity:"warning",category:"behavior-change",title:"String value of nodes",description:"The string value of typed nodes in XPath 2.0 may differ from XPath 1.0 when schema type information is present.",migration:"Use fn:string() for consistent string conversion.",specReference:"XPath 2.0 Appendix I.1"},XPWP0001:{code:"XPWP0001",severity:"info",category:"performance",title:"Descendant axis on large document",description:"Using descendant or descendant-or-self axis on large documents may impact performance. Consider using more specific path expressions.",migration:"Use more specific paths or indexes if available."},XPWP0002:{code:"XPWP0002",severity:"info",category:"performance",title:"General comparison on sequences",description:"General comparisons (=, !=, etc.) on sequences perform existential quantification, which may be slower than value comparisons on single items.",migration:"Use value comparisons (eq, ne, etc.) when comparing single values.",specReference:"XPath 2.0 Section 3.5.2"}},lu={enabled:!0,minSeverity:"info",suppressCategories:[],suppressCodes:[],handler:()=>{},logToConsole:!1,maxWarnings:100,emitOnce:!0},va={info:0,warning:1,deprecation:2},pi=class{constructor(e){this.warnings=[];this.emittedCodes=new Set;this.config=X(X({},lu),e)}emit(e,t,n){if(!this.config.enabled)return;let r=Oa[e];if(!r){this.addWarning({code:e,message:`Unknown warning: ${e}`,severity:"warning",category:"compatibility",context:t,expression:n});return}if(this.config.suppressCodes.includes(e)||this.config.suppressCategories.includes(r.category)||va[r.severity]<va[this.config.minSeverity]||this.config.emitOnce&&this.emittedCodes.has(e)||this.warnings.length>=this.config.maxWarnings)return;let i={code:r.code,message:r.description,severity:r.severity,category:r.category,context:t,expression:n};this.addWarning(i),this.emittedCodes.add(e)}emitCustom(e){this.config.enabled&&(this.warnings.length>=this.config.maxWarnings||this.config.emitOnce&&this.emittedCodes.has(e.code)||(this.addWarning(e),this.emittedCodes.add(e.code)))}addWarning(e){if(this.warnings.push(e),this.config.handler&&this.config.handler(e),this.config.logToConsole){let t=e.severity==="deprecation"?"[DEPRECATED]":e.severity==="warning"?"[WARNING]":"[INFO]";console.warn(`${t} ${e.code}: ${e.message}`)}}getWarnings(){return this.warnings}getWarningsBySeverity(e){return this.warnings.filter(t=>t.severity===e)}getWarningsByCategory(e){return this.warnings.filter(t=>t.category===e)}hasWarnings(){return this.warnings.length>0}count(){return this.warnings.length}clear(){this.warnings=[],this.emittedCodes.clear()}formatReport(){if(this.warnings.length===0)return"No warnings.";let e=[];e.push(`XPath Warnings Report (${this.warnings.length} warning${this.warnings.length===1?"":"s"}):`),e.push("");let t={};for(let n of this.warnings){let r=n.category;t[r]||(t[r]=[]),t[r].push(n)}for(let n of Object.keys(t)){let r=t[n];e.push(`## ${pu(n)}`);for(let i of r){let o=Oa[i.code];e.push(` ${i.code}: ${(o==null?void 0:o.title)||i.message}`),i.context&&e.push(` Context: ${i.context}`),o!=null&&o.migration&&e.push(` Migration: ${o.migration}`)}e.push("")}return e.join(`
|
|
6
|
-
`)}};function pu(s){switch(s){case"deprecation":return"Deprecated Features";case"compatibility":return"Compatibility Issues";case"performance":return"Performance Considerations";case"type-coercion":return"Type Coercion";case"behavior-change":return"Behavior Changes";default:return s}}function hi(s){return new pi(s)}var Nt=class{constructor(e){this.tokens=[];this.current=0;var t,n,r,i;if(this.options={strict:(t=e==null?void 0:e.strict)!=null?t:!0,version:e==null?void 0:e.version,cache:e==null?void 0:e.cache,extensions:e==null?void 0:e.extensions,enableNamespaceAxis:(n=e==null?void 0:e.enableNamespaceAxis)!=null?n:!1,staticContext:(r=e==null?void 0:e.staticContext)!=null?r:wa(),xpath10CompatibilityMode:(i=e==null?void 0:e.xpath10CompatibilityMode)!=null?i:!1,warningConfig:e==null?void 0:e.warningConfig,warningCollector:e==null?void 0:e.warningCollector},this.staticContext=this.options.staticContext,this.options.warningCollector?this.warningCollector=this.options.warningCollector:this.options.warningConfig?this.warningCollector=hi(this.options.warningConfig):this.warningCollector=hi({logToConsole:!1}),this.options.extensions){let o=Aa(this.options.extensions);if(o.length>0)throw new Error(`Invalid XSLT extensions: ${o.join(", ")}`);this.extensions=this.options.extensions}}getWarningCollector(){return this.warningCollector}ensureVersionSupport(e,t){var r;let n=(r=this.options.version)!=null?r:t;if(this.options.version=n,this.options.strict!==!1&&!e.includes(n))throw new Error(`XPath version ${n} is not supported by ${this.constructor.name}. Supported versions: ${e.join(", ")}`)}getOptions(){return this.options}parse(e){if(this.tokens=e,this.current=0,this.options.xpath10CompatibilityMode&&this.options.version&&this.options.version!=="1.0"&&this.warningCollector.emit("XPWC0001",`XPath ${this.options.version} with compatibility mode`,e.map(n=>n.lexeme).join("")),e.length===0)throw ne("Empty expression");let t=this.parseExpr();if(!this.isAtEnd())throw ne(`Unexpected token: ${this.peek().lexeme}`);return t}peek(){return this.tokens[this.current]}peekNext(){return this.tokens[this.current+1]}previous(){return this.tokens[this.current-1]}isAtEnd(){return this.current>=this.tokens.length}advance(){return this.isAtEnd()||this.current++,this.previous()}check(e){return this.isAtEnd()?!1:this.peek().type===e}checkLexeme(e){return this.isAtEnd()?!1:this.peek().lexeme===e}match(...e){for(let t of e)if(this.check(t))return this.advance(),!0;return!1}consume(e,t){var n,r;if(this.check(e))return this.advance();throw ne(`${t}. Got: ${(r=(n=this.peek())==null?void 0:n.lexeme)!=null?r:"EOF"}`)}parseExpr(){return this.parseOrExpr()}parseOrExpr(){let e=this.parseAndExpr();for(;this.check("OPERATOR")&&this.peek().lexeme==="or";){this.advance();let t=this.parseAndExpr();e=new it(e,t,"or")}return e}parseAndExpr(){let e=this.parseEqualityExpr();for(;this.check("OPERATOR")&&this.peek().lexeme==="and";){this.advance();let t=this.parseEqualityExpr();e=new it(e,t,"and")}return e}parseEqualityExpr(){let e=this.parseRelationalExpr();for(;this.match("EQUALS","NOT_EQUALS");){let t=this.previous().lexeme,n=this.parseRelationalExpr();e=new rt(e,n,t)}return e}parseRelationalExpr(){let e=this.parseAdditiveExpr();for(;this.match("LESS_THAN","GREATER_THAN","LESS_THAN_OR_EQUAL","GREATER_THAN_OR_EQUAL");){let t=this.previous().lexeme,n=this.parseAdditiveExpr();e=new rt(e,n,t)}return e}parseAdditiveExpr(){let e=this.parseMultiplicativeExpr();for(;this.match("PLUS","MINUS");){let t=this.previous().lexeme,n=this.parseMultiplicativeExpr();e=new Ye(e,n,t)}return e}parseMultiplicativeExpr(){let e=this.parseUnaryExpr();for(;;)if(this.match("ASTERISK")){let t=this.parseUnaryExpr();e=new Ye(e,t,"*")}else if(this.check("OPERATOR")&&(this.peek().lexeme==="div"||this.peek().lexeme==="mod")){let t=this.advance().lexeme,n=this.parseUnaryExpr();e=new Ye(e,n,t)}else break;return e}parseUnaryExpr(){if(this.match("MINUS")){let e=this.parseUnaryExpr();return new kt("-",e)}return this.parseUnionExpr()}parseUnionExpr(){let e=this.parsePathExpr();for(;this.match("PIPE");){let t=this.parsePathExpr();e=new Ce(e,t)}return e}parsePathExpr(){if(this.check("SLASH")||this.check("DOUBLE_SLASH"))return this.parseLocationPath();if(this.isStepStart())return this.parseLocationPath();let e=this.parseFilterExpr();if(this.match("SLASH","DOUBLE_SLASH")){let t=this.previous().type==="DOUBLE_SLASH",n=this.parseRelativeLocationPath();t&&n.unshift(new Ne("descendant-or-self",{type:"node-type",nodeType:"node"}));let r=new Ee(n,!1);return new _t(e,r)}return e}isStepStart(){if(this.isAtEnd())return!1;let e=this.peek(),t=this.peekNext(),n=["element","attribute","schema-element","schema-attribute","document-node","node","text","comment","processing-instruction"];if((e.type==="IDENTIFIER"||e.type==="NODE_TYPE")&&(t==null?void 0:t.type)==="OPEN_PAREN"&&n.includes(e.lexeme.toLowerCase()))return!0;if(this.isFunctionCallStart())return!1;if(e.type==="DOT"||e.type==="DOT_DOT"||e.type==="AT"||e.type==="LOCATION"||e.type==="NODE_TYPE"||e.type==="ASTERISK")return!0;if(e.type==="IDENTIFIER"||e.type==="OPERATOR"||e.type==="FUNCTION"){let r=this.peekNext();return!r||r.type!=="OPEN_PAREN"}return!1}parseLocationPath(){let e=!1,t=[];return this.match("SLASH")?(e=!0,!this.isAtEnd()&&this.isStepStart()&&t.push(...this.parseRelativeLocationPath())):this.match("DOUBLE_SLASH")?(e=!0,t.push(new Ne("descendant-or-self",{type:"node-type",nodeType:"node"})),t.push(...this.parseRelativeLocationPath())):t.push(...this.parseRelativeLocationPath()),new Ee(t,e)}parseRelativeLocationPath(){let e=[];for(e.push(this.parseStep());this.match("SLASH","DOUBLE_SLASH");)this.previous().type==="DOUBLE_SLASH"&&e.push(new Ne("descendant-or-self",{type:"node-type",nodeType:"node"})),e.push(this.parseStep());return e}parseStep(){if(this.match("DOT"))return new Ne("self",{type:"node-type",nodeType:"node"});if(this.match("DOT_DOT"))return new Ne("parent",{type:"node-type",nodeType:"node"});let e="child";if(this.match("AT"))e="attribute";else if(this.check("LOCATION")){let r=this.peekNext();r&&r.type==="COLON_COLON"&&(e=this.advance().lexeme,this.advance())}if(e==="namespace"){if(!this.options.enableNamespaceAxis)throw Si("namespace");this.warnNamespaceAxis()}let t=this.parseNodeTest(),n=this.parsePredicates();return new Ne(e,t,n)}parseNodeTest(){var e,t;if(this.match("ASTERISK"))return{type:"wildcard"};if(this.check("NODE_TYPE")||this.check("IDENTIFIER")||this.check("LOCATION")||this.check("FUNCTION")||this.check("OPERATOR")){let n=this.peekNext();if(n&&n.type==="OPEN_PAREN"){let r=this.advance().lexeme.toLowerCase();if(this.advance(),r==="element")return this.parseElementTest();if(r==="attribute")return this.parseAttributeTest();if(r==="document-node")return this.parseDocumentNodeTest();if(r==="schema-element"){let i=this.parseNameOrWildcard();return this.consume("CLOSE_PAREN","Expected ')' after schema-element name"),{type:"schema-element",name:i}}if(r==="schema-attribute"){let i=this.parseNameOrWildcard();return this.consume("CLOSE_PAREN","Expected ')' after schema-attribute name"),{type:"schema-attribute",name:i}}if(r==="node"||r==="text"||r==="comment"||r==="processing-instruction"){if(r==="processing-instruction"&&this.check("STRING")){let i=this.advance().lexeme;return this.consume("CLOSE_PAREN","Expected ')' after processing-instruction target"),{type:"processing-instruction",target:i}}return this.consume("CLOSE_PAREN","Expected ')' after node type"),{type:"node-type",nodeType:r}}}}if(this.check("IDENTIFIER")||this.check("LOCATION")||this.check("FUNCTION")||this.check("NODE_TYPE")||this.check("OPERATOR")){let n=this.advance().lexeme;if(this.match("COLON")){if(this.match("ASTERISK"))return{type:"wildcard",name:`${n}:*`};if(this.check("IDENTIFIER")||this.check("LOCATION")||this.check("FUNCTION")||this.check("NODE_TYPE")||this.check("OPERATOR")){let r=this.advance().lexeme;return{type:"name",name:`${n}:${r}`}}throw new Error("Expected local name after namespace prefix")}return{type:"name",name:n}}throw ne(`Expected node test, got: ${(t=(e=this.peek())==null?void 0:e.lexeme)!=null?t:"EOF"}`)}parsePredicates(){let e=[];for(;this.match("OPEN_SQUARE_BRACKET");){let t=this.parseExpr();this.consume("CLOSE_SQUARE_BRACKET","Expected ']' after predicate"),e.push(new Nn(t))}return e}parseFilterExpr(){let e=this.parsePrimaryExpr(),t=[];for(;this.check("OPEN_SQUARE_BRACKET");)t.push(...this.parsePredicates());return t.length>0?new It(e,t):e}parsePrimaryExpr(){var e,t;if(this.match("DOLLAR")){let n=this.parseVariableReferenceName();return new xe(n)}if(this.match("OPEN_PAREN")){if(this.check("CLOSE_PAREN"))return this.advance(),new xn;let n=this.parseExpr();return this.consume("CLOSE_PAREN","Expected ')' after expression"),n}if(this.check("STRING")){let n=this.advance().lexeme;return new Ot(n)}if(this.check("NUMBER")){let n=parseFloat(this.advance().lexeme);return new vt(n)}if(this.isFunctionCallStart())return this.parseFunctionCall();throw ne(`Unexpected token in primary expression: ${(t=(e=this.peek())==null?void 0:e.lexeme)!=null?t:"EOF"}`)}parseFunctionCall(){let e=this.advance().lexeme;if(e.startsWith("Q{"))this.consume("OPEN_PAREN","Expected '(' after function name");else if(this.match("COLON")){let n=this.advance();if(!this.isNcNameToken(n.type))throw ne("Expected local name after namespace prefix");e=`${e}:${n.lexeme}`}e.startsWith("Q{")||this.consume("OPEN_PAREN","Expected '(' after function name");let t=[];if(!this.check("CLOSE_PAREN"))do t.push(this.parseExpr());while(this.match("COMMA"));return this.consume("CLOSE_PAREN","Expected ')' after function arguments"),new Pe(e,t)}isFunctionCallStart(){var i,o,a;if(this.isAtEnd())return!1;let e=this.peek(),t=this.peekNext(),r=["element","attribute","schema-element","schema-attribute","document-node","node","text","comment","processing-instruction"].includes((a=(o=(i=e.lexeme)==null?void 0:i.toLowerCase)==null?void 0:o.call(i))!=null?a:"");if(e.type==="EQNAME"&&(t==null?void 0:t.type)==="OPEN_PAREN")return!0;if(this.isFunctionNameToken(e.type)&&(t==null?void 0:t.type)==="OPEN_PAREN")return!r;if(this.isFunctionNameToken(e.type)&&(t==null?void 0:t.type)==="COLON"){let c=this.tokens[this.current+2],u=this.tokens[this.current+3];if(c&&this.isFunctionNameToken(c.type)&&(u==null?void 0:u.type)==="OPEN_PAREN")return!0}return!1}warnNamespaceAxis(){this.warningCollector.emit("XPWD0001","namespace:: axis",this.tokens.map(e=>e.lexeme).join(""))}isFunctionNameToken(e){return e==="IDENTIFIER"||e==="FUNCTION"||e==="OPERATOR"||e==="LOCATION"||e==="EQNAME"}parseVariableReferenceName(){var n,r;if(this.check("EQNAME"))return this.advance().lexeme;let e=this.peek();if(!e||!this.isNcNameToken(e.type))throw ne(`Expected variable name after $. Got: ${(n=e==null?void 0:e.lexeme)!=null?n:"EOF"}`);let t=this.advance().lexeme;if(this.match("COLON")){let i=this.peek();if(!i||!this.isNcNameToken(i.type))throw ne(`Expected local name after namespace prefix in variable reference. Got: ${(r=i==null?void 0:i.lexeme)!=null?r:"EOF"}`);t=`${t}:${this.advance().lexeme}`}return t}isNcNameToken(e){return e==="IDENTIFIER"||e==="FUNCTION"||e==="OPERATOR"||e==="LOCATION"||e==="NODE_TYPE"}parseNameOrWildcard(){let e="";if(this.match("ASTERISK"))return"*";if(this.check("EQNAME"))return this.advance().lexeme;if((this.check("IDENTIFIER")||this.check("NODE_TYPE")||this.check("FUNCTION")||this.check("LOCATION")||this.check("OPERATOR"))&&(e=this.advance().lexeme,this.match("COLON"))){if(this.match("ASTERISK"))return`${e}:*`;(this.check("IDENTIFIER")||this.check("NODE_TYPE")||this.check("FUNCTION")||this.check("LOCATION")||this.check("OPERATOR"))&&(e+=":"+this.advance().lexeme)}return e}parseElementTest(){if(this.check("CLOSE_PAREN"))return this.advance(),{type:"element"};let e=this.parseNameOrWildcard(),t;return this.match("COMMA")&&(this.check("IDENTIFIER")||this.check("NODE_TYPE")||this.check("FUNCTION")||this.check("LOCATION"))&&(t=this.parseNameOrWildcard()),this.consume("CLOSE_PAREN","Expected ')' after element test"),{type:"element",name:e==="*"?void 0:e,elementType:t,isWildcardName:e==="*"}}parseAttributeTest(){if(this.check("CLOSE_PAREN"))return this.advance(),{type:"attribute"};let e=this.parseNameOrWildcard(),t;return this.match("COMMA")&&(this.check("IDENTIFIER")||this.check("NODE_TYPE")||this.check("FUNCTION")||this.check("LOCATION"))&&(t=this.parseNameOrWildcard()),this.consume("CLOSE_PAREN","Expected ')' after attribute test"),{type:"attribute",name:e==="*"?void 0:e,elementType:t,isWildcardName:e==="*"}}parseDocumentNodeTest(){if(this.check("CLOSE_PAREN"))return this.advance(),{type:"document-node"};let e=this.parseNodeTest();return this.consume("CLOSE_PAREN","Expected ')' after document-node test"),{type:"document-node",elementTest:e}}};var In=class extends Nt{constructor(e){super(e),this.ensureVersionSupport(["1.0"],"1.0")}};ce();ke();var Et=class extends Nt{constructor(e){super(e),this.ensureVersionSupport(["2.0","3.0","3.1"],"2.0")}parseExpr(){return this.checkReservedWord("for")?this.parseForExpr():this.checkReservedWord("some")||this.checkReservedWord("every")?this.parseQuantifiedExpr():super.parseExpr()}parseUnionExpr(){let e=this.parseInstanceOfExpr();for(;this.match("PIPE");){let t=this.parseInstanceOfExpr();e=new Ce(e,t)}return e}parsePrimaryExpr(){if(this.check("RESERVED_WORD")&&this.peek().lexeme==="if")return this.parseIfExpr();if(this.check("DOLLAR")){this.advance();let e=this.parseVariableReferenceName();return new xe(e)}return super.parsePrimaryExpr()}parseInstanceOfExpr(){let e=this.parseTreatExpr();if(this.checkReservedWord("instance")){this.advance(),this.consumeReservedWord("of","Expected 'of' after 'instance'");let t=this.parseSequenceType();e=new mn(e,t)}return e}parseTreatExpr(){let e=this.parseCastableExpr();if(this.checkReservedWord("treat")){this.advance(),this.consumeReservedWord("as","Expected 'as' after 'treat'");let t=this.parseSequenceType();e=new dn(e,t)}return e}parseCastableExpr(){let e=this.parsePathExpr();if(this.checkReservedWord("castable")){this.advance(),this.consumeReservedWord("as","Expected 'as' after 'castable'");let t=this.parseSequenceType();e=new fn(e,t)}return e}parseIfExpr(){this.advance(),this.consume("OPEN_PAREN","Expected '(' after 'if'");let e=this.parseExpr();if(this.consume("CLOSE_PAREN","Expected ')' after if test expression"),!(this.check("RESERVED_WORD")&&this.peek().lexeme==="then"))throw new Error("Expected 'then' in conditional expression");this.advance();let t=this.parseExpr();if(!(this.check("RESERVED_WORD")&&this.peek().lexeme==="else"))throw new Error("Expected 'else' in conditional expression");this.advance();let n=this.parseExpr();return new Dt(e,t,n)}parseQuantifiedExpr(){let e=this.consumeReservedWordOneOf(["some","every"],"Expected 'some' or 'every' at start of quantified expression"),t=[];do t.push(this.parseForBinding());while(this.match("COMMA"));this.consumeReservedWord("satisfies","Expected 'satisfies' after quantified expression bindings");let n=this.parseExpr();return new Ft(e,t,n)}parseForExpr(){this.consumeReservedWord("for","Expected 'for' at start of for expression");let e=[];do e.push(this.parseForBinding());while(this.match("COMMA"));this.consumeReservedWord("return","Expected 'return' in for expression");let t=this.parseExpr();return new Vt(e,t)}parseForBinding(){this.consume("DOLLAR","Expected '$' after 'for'");let e=this.consume("IDENTIFIER","Expected variable name in for binding").lexeme;this.consumeReservedWord("in","Expected 'in' after variable name in for clause");let t=this.parseExpr();return{variable:e,expression:t}}parseSequenceType(){if(this.checkName("empty-sequence"))return this.advance(),this.consume("OPEN_PAREN","Expected '(' after empty-sequence"),this.consume("CLOSE_PAREN","Expected ')' after empty-sequence"),ot();if(this.checkName("item")){this.advance(),this.consume("OPEN_PAREN","Expected '(' after item"),this.consume("CLOSE_PAREN","Expected ')' after item()");let i=this.parseOccurrenceIndicator();return de(st,i)}if(this.checkName("map")){this.advance(),this.consume("OPEN_PAREN","Expected '(' after map");let i=null,o=null;this.match("ASTERISK")?this.consume("CLOSE_PAREN","Expected ')' after map(*)"):(i=this.parseSequenceType(),this.consume("COMMA","Expected ',' after key type in map()"),o=this.parseSequenceType(),this.consume("CLOSE_PAREN","Expected ')' after map type"));let a=this.parseOccurrenceIndicator(),{createTypedMapTest:c}=(ht(),U(Lt)),u=c(i,o);return de(u,a)}if(this.checkName("array")){this.advance(),this.consume("OPEN_PAREN","Expected '(' after array");let i=null;this.match("ASTERISK")?this.consume("CLOSE_PAREN","Expected ')' after array(*)"):(i=this.parseSequenceType(),this.consume("CLOSE_PAREN","Expected ')' after array type"));let o=this.parseOccurrenceIndicator(),{createTypedArrayTest:a}=(ht(),U(Lt)),c=a(i);return de(c,o)}let e=this.parseQName(),t=this.parseOccurrenceIndicator(),n=this.stripPrefix(e),r=ye(n);if(!r)throw new Error(`Unknown atomic type: ${e}`);return at(r,t)}parseAdditiveExpr(){let e=this.parseRangeExpr();for(;this.match("PLUS","MINUS");){let t=this.previous().lexeme,n=this.parseRangeExpr();e=new(ce(),U($e)).XPathArithmeticExpression(e,n,t)}return e}parseRangeExpr(){let e=this.parseMultiplicativeExpr();if(this.checkReservedWord("to")){this.advance();let t=this.parseMultiplicativeExpr();e=new gn(e,t)}return e}parseOccurrenceIndicator(){return this.match("QUESTION")?"?":this.match("ASTERISK")?"*":this.match("PLUS")?"+":"ONE"}parseQName(){let e=this.consumeNameToken("Expected type name in SequenceType");if(this.match("COLON")){let t=this.consumeNameToken("Expected local name after : in SequenceType").lexeme;return`${e.lexeme}:${t}`}return e.lexeme}stripPrefix(e){let t=e.split(":");return t.length===2?t[1]:t[0]}consumeNameToken(e){var t,n;if(this.isNameToken())return this.advance();throw new Error(`${e}. Got: ${(n=(t=this.peek())==null?void 0:t.lexeme)!=null?n:"EOF"}`)}isNameToken(){if(this.isAtEnd())return!1;let e=this.peek().type;return e==="IDENTIFIER"||e==="FUNCTION"||e==="NODE_TYPE"||e==="OPERATOR"||e==="LOCATION"||e==="RESERVED_WORD"}checkName(e){return this.isNameToken()&&this.peek().lexeme===e}checkReservedWord(e){return this.check("RESERVED_WORD")&&this.peek().lexeme===e}consumeReservedWord(e,t){var n,r;if(this.checkReservedWord(e)){this.advance();return}throw new Error(`${t}. Got: ${(r=(n=this.peek())==null?void 0:n.lexeme)!=null?r:"EOF"}`)}consumeReservedWordOneOf(e,t){var n,r;for(let i of e)if(this.checkReservedWord(i))return this.advance(),i;throw new Error(`${t}. Got: ${(r=(n=this.peek())==null?void 0:n.lexeme)!=null?r:"EOF"}`)}};ce();ei();ti();ni();ii();si();oi();ai();ci();ke();_e();var bt=class extends Et{constructor(e){let t=e?X({},e):{};t.version||(t.version="3.0"),super(t),this.ensureVersionSupport(["3.0","3.1"],"3.0")}parseExpr(){if(this.checkReservedWordInternal("let"))return this.parseLetExpr();let e=this.parseExprSingle();if(this.check("COMMA")){let t=[e];for(;this.match("COMMA");)t.push(this.parseExprSingle());return new yn(t)}return e}parseExprSingle(){return this.checkReservedWordInternal("let")?this.parseLetExpr():super.parseExpr()}parseAdditiveExpr(){let e=this.parseStringConcatExpr();for(;this.match("PLUS","MINUS");){let t=this.previous().lexeme,n=this.parseStringConcatExpr();e=new(ce(),U($e)).XPathArithmeticExpression(e,n,t)}return e}parseStringConcatExpr(){let e=this.parseRangeExpr();for(;this.match("CONCAT");){let t=this.parseRangeExpr();e=new Cn(e,t)}return e}parseUnionExpr(){let e=this.parseSimpleMapExpr();for(;this.match("PIPE");){let t=this.parseSimpleMapExpr();e=new(ce(),U($e)).XPathUnionExpression(e,t)}return e}parseSimpleMapExpr(){let e=this.parseInstanceOfExprInternal();for(;this.match("SIMPLE_MAP");){let t=this.parseInstanceOfExprInternal();e=new Sn(e,t)}return e}parseInstanceOfExprInternal(){let e=this.parseTreatExprInternal();if(this.checkReservedWordInternal("instance")){this.advance(),this.consumeReservedWordInternal("of","Expected 'of' after 'instance'");let t=this.parseSequenceTypeInternal();e=new(ce(),U($e)).XPathInstanceOfExpression(e,t)}return e}parseTreatExprInternal(){let e=this.parseCastableExprInternal();if(this.checkReservedWordInternal("treat")){this.advance(),this.consumeReservedWordInternal("as","Expected 'as' after 'treat'");let t=this.parseSequenceTypeInternal();e=new(ce(),U($e)).XPathTreatExpression(e,t)}return e}parseCastableExprInternal(){let e=this.parseArrowExpr();if(this.checkReservedWordInternal("castable")){this.advance(),this.consumeReservedWordInternal("as","Expected 'as' after 'castable'");let t=this.parseSequenceTypeInternal();e=new(ce(),U($e)).XPathCastableExpression(e,t)}return e}parseArrowExpr(){let e=this.parsePathExpr();for(;this.match("FAT_ARROW");){let t,n=[];if(this.check("DOLLAR")){this.advance();let r=this.parseVariableReferenceName();if(t=new xe(r),this.consume("OPEN_PAREN","Expected '(' after function variable in arrow expression"),!this.check("CLOSE_PAREN"))do n.push(this.parseExprSingle());while(this.match("COMMA"));this.consume("CLOSE_PAREN","Expected ')' after arrow expression arguments"),e=new gt(t,[e,...n])}else{let r=this.advance().lexeme;if(this.match("COLON")){let i=this.advance();r=`${r}:${i.lexeme}`}if(this.consume("OPEN_PAREN","Expected '(' after function name in arrow expression"),!this.check("CLOSE_PAREN"))do n.push(this.parseExprSingle());while(this.match("COMMA"));this.consume("CLOSE_PAREN","Expected ')' after arrow expression arguments"),e=new An(e,r,n)}}return e}parseFunctionCall(){let e=this.advance().lexeme;if(this.match("COLON")){let n=this.advance();e=`${e}:${n.lexeme}`}this.consume("OPEN_PAREN","Expected '(' after function name");let t=[];if(!this.check("CLOSE_PAREN"))do t.push(this.parseExprSingle());while(this.match("COMMA"));return this.consume("CLOSE_PAREN","Expected ')' after function arguments"),new Pe(e,t)}parsePrimaryExpr(){if(this.check("STRING_TEMPLATE")){let e=this.advance().lexeme;return this.parseStringTemplateFromLexeme(e)}return this.match("DOLLAR")?new xe(this.parseVariableReferenceName()):this.checkReservedWordInternal("function")?this.parseInlineFunction():this.isFunctionRefStart()?this.parseNamedFunctionRef():super.parsePrimaryExpr()}isStepStart(){return this.isFunctionRefStart()?!1:super.isStepStart()}parseFilterExpr(){let e=this.parsePrimaryExpr();if(this.check("OPEN_PAREN")){this.advance();let n=[];if(!this.check("CLOSE_PAREN"))do n.push(this.parseExprSingle());while(this.match("COMMA"));this.consume("CLOSE_PAREN","Expected ')' after function arguments"),e=new gt(e,n)}let t=[];for(;this.check("OPEN_SQUARE_BRACKET");)t.push(...this.parsePredicates());if(t.length>0){let n=(ce(),U($e)).XPathFilterExpression;return new n(e,t)}return e}isFunctionRefStart(){if(this.isAtEnd())return!1;let e=this.peek();if(e.type==="EQNAME"){let t=this.peekNext();return(t==null?void 0:t.type)==="HASH"}if(e.type==="IDENTIFIER"||e.type==="FUNCTION"||e.type==="OPERATOR"||e.type==="LOCATION"){let t=1,n=!1;for(;t<this.tokens.length-this.current;){let r=this.tokens[this.current+t];if(!r)break;if(r.type==="HASH"){n=!0;break}if(r.type==="MINUS"||r.type==="COLON"||r.type==="IDENTIFIER"||r.type==="FUNCTION"||r.type==="OPERATOR"||r.type==="LOCATION"||r.type==="NODE_TYPE")t++;else break}return n}return!1}parseNamedFunctionRef(){let e=this.advance().lexeme;for(;!this.isAtEnd()&&!this.check("HASH")&&(this.match("MINUS")||this.match("COLON"));){let r=this.previous().lexeme,i=this.peek();if(i&&(i.type==="IDENTIFIER"||i.type==="FUNCTION"||i.type==="OPERATOR"||i.type==="LOCATION"||i.type==="NODE_TYPE"))this.advance(),e=`${e}${r}${i.lexeme}`;else throw ne(`Expected name after '${r}' in function reference`)}this.consume("HASH","Expected '#' in function reference");let t=this.consume("NUMBER","Expected arity number after '#'"),n=parseInt(t.lexeme,10);if(isNaN(n)||n<0)throw ne(`Invalid function arity: ${t.lexeme}`);return new On(e,n)}parseInlineFunction(){this.advance(),this.consume("OPEN_PAREN","Expected '(' after 'function'");let e=[];if(!this.check("CLOSE_PAREN"))do{this.consume("DOLLAR","Expected '$' before parameter name");let r=this.consume("IDENTIFIER","Expected parameter name").lexeme,i;this.checkReservedWordInternal("as")&&(this.advance(),i=this.parseSequenceTypeInternal()),e.push({name:r,type:i})}while(this.match("COMMA"));this.consume("CLOSE_PAREN","Expected ')' after function parameters");let t;this.checkReservedWordInternal("as")&&(this.advance(),t=this.parseSequenceTypeInternal()),this.consume("OPEN_CURLY_BRACKET","Expected '{' before function body");let n=this.parseExpr();return this.consume("CLOSE_CURLY_BRACKET","Expected '}' after function body"),new vn(e,n,t)}parseLetExpr(){this.consumeReservedWordInternal("let","Expected 'let'");let e=[];do e.push(this.parseLetBinding());while(this.match("COMMA"));this.consumeReservedWordInternal("return","Expected 'return' in let expression");let t=this.parseExpr();return new Xn(e,t)}parseLetBinding(){this.consume("DOLLAR","Expected '$' before variable name in let binding");let t=this.consumeNameTokenInternal("Expected variable name in let binding").lexeme,n;this.checkReservedWordInternal("as")&&(this.advance(),n=this.parseSequenceTypeInternal()),this.consume("ASSIGNMENT","Expected ':=' after variable name in let binding");let r=this.parseExprSingle();return{variable:t,expression:r,type:n}}checkReservedWordInternal(e){return this.check("RESERVED_WORD")&&this.peek().lexeme===e}consumeReservedWordInternal(e,t){var n,r;if(this.checkReservedWordInternal(e)){this.advance();return}throw ne(`${t}. Got: ${(r=(n=this.peek())==null?void 0:n.lexeme)!=null?r:"EOF"}`)}parseSequenceTypeInternal(){if(this.checkNameInternal("empty-sequence"))return this.advance(),this.consume("OPEN_PAREN","Expected '(' after empty-sequence"),this.consume("CLOSE_PAREN","Expected ')' after empty-sequence"),ot();if(this.checkNameInternal("item")){this.advance(),this.consume("OPEN_PAREN","Expected '(' after item"),this.consume("CLOSE_PAREN","Expected ')' after item()");let i=this.parseOccurrenceIndicatorInternal();return de(st,i)}if(this.checkNameInternal("map")){this.advance(),this.consume("OPEN_PAREN","Expected '(' after map");let i=null,o=null;this.match("ASTERISK")?this.consume("CLOSE_PAREN","Expected ')' after map(*)"):(i=this.parseSequenceTypeInternal(),this.consume("COMMA","Expected ',' after key type in map()"),o=this.parseSequenceTypeInternal(),this.consume("CLOSE_PAREN","Expected ')' after map type"));let a=this.parseOccurrenceIndicatorInternal(),{createTypedMapTest:c}=(ht(),U(Lt)),u=c(i,o);return de(u,a)}if(this.checkNameInternal("array")){this.advance(),this.consume("OPEN_PAREN","Expected '(' after array");let i=null;this.match("ASTERISK")?this.consume("CLOSE_PAREN","Expected ')' after array(*)"):(i=this.parseSequenceTypeInternal(),this.consume("CLOSE_PAREN","Expected ')' after array type"));let o=this.parseOccurrenceIndicatorInternal(),{createTypedArrayTest:a}=(ht(),U(Lt)),c=a(i);return de(c,o)}if(this.checkReservedWordInternal("function")){this.advance(),this.consume("OPEN_PAREN","Expected '(' after function");let i=null;if(this.match("ASTERISK"))this.consume("CLOSE_PAREN","Expected ')' after function(*)");else if(this.check("CLOSE_PAREN"))i=[],this.advance();else{i=[];do i.push(this.parseSequenceTypeInternal());while(this.match("COMMA"));this.consume("CLOSE_PAREN","Expected ')' after function parameter types")}let o=null;this.checkReservedWordInternal("as")&&(this.advance(),o=this.parseSequenceTypeInternal());let a=this.parseOccurrenceIndicatorInternal(),{createFunctionTest:c}=(pn(),U(ss)),u=c(i,o,{isWildcard:i===null&&o===null});return de(u,a)}let e=this.parseQNameInternal(),t=this.parseOccurrenceIndicatorInternal(),n=this.stripPrefixInternal(e),r=ye(n);if(!r)throw ne(`Unknown atomic type: ${e}`);return at(r,t)}parseOccurrenceIndicatorInternal(){return this.match("QUESTION")?"?":this.match("ASTERISK")?"*":this.match("PLUS")?"+":"ONE"}parseQNameInternal(){let e=this.consumeNameTokenInternal("Expected type name");if(this.match("COLON")){let t=this.consumeNameTokenInternal("Expected local name after :").lexeme;return`${e.lexeme}:${t}`}return e.lexeme}stripPrefixInternal(e){let t=e.split(":");return t.length===2?t[1]:t[0]}consumeNameTokenInternal(e){var t,n;if(this.isNameTokenInternal())return this.advance();throw ne(`${e}. Got: ${(n=(t=this.peek())==null?void 0:t.lexeme)!=null?n:"EOF"}`)}isNameTokenInternal(){if(this.isAtEnd())return!1;let e=this.peek().type;return e==="IDENTIFIER"||e==="FUNCTION"||e==="NODE_TYPE"||e==="OPERATOR"||e==="LOCATION"||e==="RESERVED_WORD"}checkNameInternal(e){return this.isNameTokenInternal()&&this.peek().lexeme===e}parseStringTemplateFromLexeme(e){let t=ri(e),n=[];for(let r of t)if(typeof r=="string")n.push(r);else if(r.expressionString.trim().length===0)n.push("");else{let a=new Ie({version:"3.1"}).scan(r.expressionString),c=this.constructor,l=new c().parse(a);n.push(l)}return new wn(n)}};De();Ve();li();var pr=class extends bt{constructor(e){let t=e?X({},e):{};t.version||(t.version="3.1"),super(t),this.ensureVersionSupport(["3.1"],"3.1")}parsePrimaryExpr(){var e,t,n;return this.check("RESERVED_WORD")&&this.peek().lexeme==="map"&&((e=this.peekNext())==null?void 0:e.type)==="OPEN_CURLY_BRACKET"?this.parseMapConstructor():this.check("RESERVED_WORD")&&this.peek().lexeme==="array"&&((t=this.peekNext())==null?void 0:t.type)==="OPEN_CURLY_BRACKET"?this.parseCurlyArrayConstructor():this.check("RESERVED_WORD")&&(this.peek().lexeme==="map"||this.peek().lexeme==="array")&&((n=this.peekNext())==null?void 0:n.type)==="COLON"?this.parseNamespacedFunctionCall():this.check("OPEN_SQUARE_BRACKET")?this.parseSquareBracketArrayConstructor():this.check("QUESTION")?this.parseLookupExpr(null):super.parsePrimaryExpr()}parseNamespacedFunctionCall(){let e=this.advance().lexeme;if(this.consume("COLON",`Expected ':' after '${e}'`),!this.check("IDENTIFIER")&&!this.check("FUNCTION"))throw new Error(`Expected function name after '${e}:'`);let t=this.advance().lexeme,n=`${e}:${t}`;this.consume("OPEN_PAREN",`Expected '(' after '${n}'`);let r=[];if(!this.check("CLOSE_PAREN"))do r.push(this.parseExprSingle());while(this.match("COMMA"));this.consume("CLOSE_PAREN","Expected ')' after function arguments");let{XPathFunctionCall:i}=(Tn(),U(Xa));return new i(n,r)}parseMapConstructor(){this.advance(),this.consume("OPEN_CURLY_BRACKET","Expected '{' after 'map'");let e=[];if(this.check("CLOSE_CURLY_BRACKET"))return this.advance(),new ut(e);do{let t=this.parseExprSingle();this.consume("COLON","Expected ':' after map key");let n=this.parseExprSingle();e.push({key:t,value:n})}while(this.match("COMMA"));return this.consume("CLOSE_CURLY_BRACKET","Expected '}' after map entries"),new ut(e)}parseSquareBracketArrayConstructor(){this.advance();let e=[];if(this.check("CLOSE_SQUARE_BRACKET"))return this.advance(),new lt(e);do{let t=this.parseExprSingle();e.push(t)}while(this.match("COMMA"));return this.consume("CLOSE_SQUARE_BRACKET","Expected ']' after array items"),new lt(e)}parseCurlyArrayConstructor(){if(this.advance(),this.consume("OPEN_CURLY_BRACKET","Expected '{' after 'array'"),this.check("CLOSE_CURLY_BRACKET"))return this.advance(),new pt({evaluate:()=>[],toString:()=>"()"});let e=this.parseExpr();return this.consume("CLOSE_CURLY_BRACKET","Expected '}' after array expression"),new pt(e)}parseFilterExpr(){let e=super.parseFilterExpr();for(;this.check("QUESTION");)e=this.parseLookupExpr(e);return e}parseLookupExpr(e){var n,r,i,o,a;this.consume("QUESTION","Expected ? for lookup operator");let t;if(this.match("ASTERISK"))t={type:"WILDCARD"};else if(this.check("OPEN_PAREN")){this.advance();let c=this.parseExpr();this.consume("CLOSE_PAREN","Expected ')' after lookup expression"),t={type:"PARENTHESIZED_EXPR",value:c}}else if(this.check("NUMBER")){let c=this.advance(),u=parseInt(c.lexeme,10);t={type:"INTEGER_LITERAL",value:u}}else if(((n=this.peek())==null?void 0:n.type)==="IDENTIFIER"||((r=this.peek())==null?void 0:r.type)==="FUNCTION"||((i=this.peek())==null?void 0:i.type)==="OPERATOR"||((o=this.peek())==null?void 0:o.type)==="LOCATION"||((a=this.peek())==null?void 0:a.type)==="NODE_TYPE"){let c=this.advance().lexeme;t={type:"NCNAME",value:c}}else throw new Error("Expected key specifier after ?");return new Rn(e,t)}parseSequenceType(){let e=super.parseSequenceType();if(this.check("PIPE")){let t=[e];for(;this.match("PIPE");){let c=super.parseSequenceType();t.push(c)}let{createUnionType:n}=($t(),U(er)),{createItemSequenceType:r}=(Qe(),U(Dr)),i=t.map(c=>{if(c.getItemType&&typeof c.getItemType=="function"){let u=c.getItemType();if(u==="empty")throw new Error("empty-sequence() cannot be used in union types");return u}return c}),o=e.getOccurrence?e.getOccurrence():"ONE",a=n(...i);return r(a,o)}return e}parseSequenceTypeInternal(){let e=super.parseSequenceTypeInternal();if(this.check("PIPE")){let t=[e];for(;this.match("PIPE");){let c=super.parseSequenceTypeInternal();t.push(c)}let{createUnionType:n}=($t(),U(er)),{createItemSequenceType:r}=(Qe(),U(Dr)),i=t.map(c=>{if(c.getItemType&&typeof c.getItemType=="function"){let u=c.getItemType();if(u==="empty")throw new Error("empty-sequence() cannot be used in union types");return u}return c}),o=e.getOccurrence?e.getOccurrence():"ONE",a=n(...i);return r(a,o)}return e}};function Ra(s="1.0",e){let t=I(X({},e),{version:s});switch(s){case"1.0":return new In(t);case"2.0":return new Et(t);case"3.0":return new bt(t);case"3.1":return new pr(t);default:throw new Error(`Unsupported XPath version: ${s}`)}}ce();var Le=class Le{constructor(e,t,n,r,i){this.id=Math.random()*(Number.MAX_SAFE_INTEGER-1)+1,this.childNodes=[],this.visited=!1,this.escape=!0,this.fromXslText=!1,this.siblingPosition=-1,this.init(e,t,n,r,i)}init(e,t,n,r,i){this.nodeType=e-0,this.nodeName=`${t}`,this.nodeValue=`${n}`,this.ownerDocument=r,this.namespaceUri=i||null,[this.prefix,this.localName]=this.qualifiedNameToParts(`${t}`),this.firstChild=null,this.lastChild=null,this.nextSibling=null,this.previousSibling=null,this.parentNode=null}qualifiedNameToParts(e){return e.includes(":")?e.split(":"):[null,e]}domTraverseElements(e,t,n){let r;if(t&&(r=t.call(null,e),typeof r=="boolean"&&!r))return!1;for(let i=e.firstChild;i;i=i.nextSibling)if(i.nodeType==1&&(r=this.domTraverseElements.call(this,i,t,n),typeof r=="boolean"&&!r))return!1;if(n&&(r=n.call(null,e),typeof r=="boolean"&&!r))return!1}static recycle(e){if(e){if(e.constructor.name==="XDocument"){this.recycle(e.documentElement);return}if(e.constructor==this){this._unusedXNodes.push(e);for(let t=0;t<e.childNodes.length;++t)this.recycle(e.childNodes[t]);e.childNodes.length=0,e.init.call(0,"","",null)}}}static create(e,t,n,r,i){if(this._unusedXNodes.length>0){let o=this._unusedXNodes.pop();return o.init(e,t,n,r,i),o}return new Le(e,t,n,r,i)}static clone(e,t){let n=new Le(e.nodeType,e.nodeName,e.nodeValue,t,e.namespaceUri);n.id=e.id;for(let r of e.childNodes)n.appendChild(Le.clone(r,n));return n}appendChild(e){this.childNodes.length===0&&(this.firstChild=e),e.previousSibling=this.lastChild,e.nextSibling=null,this.lastChild&&(this.lastChild.nextSibling=e),e.parentNode=this,this.lastChild=e,this.childNodes.push(e)}replaceChild(e,t){if(t!=e){for(let n=0;n<this.childNodes.length;++n)if(this.childNodes[n]==t){this.childNodes[n]=e;let r=t.parentNode;t.parentNode=null,e.parentNode=r,r=t.previousSibling,t.previousSibling=null,e.previousSibling=r,e.previousSibling&&(e.previousSibling.nextSibling=e),r=t.nextSibling,t.nextSibling=null,e.nextSibling=r,e.nextSibling&&(e.nextSibling.previousSibling=e),this.firstChild==t&&(this.firstChild=e),this.lastChild==t&&(this.lastChild=e);break}}}insertBefore(e,t){if(t==e||t.parentNode!=this)return;e.parentNode&&e.parentNode.removeChild(e);let n=[];for(let r of this.childNodes)r==t&&(n.push(e),e.parentNode=this,e.previousSibling=t.previousSibling,t.previousSibling=e,e.previousSibling&&(e.previousSibling.nextSibling=e),e.nextSibling=t,this.firstChild==t&&(this.firstChild=e)),n.push(r);this.childNodes=n}removeChild(e){let t=[];for(let n of this.childNodes)n!=e?t.push(n):(n.previousSibling&&(n.previousSibling.nextSibling=n.nextSibling),n.nextSibling&&(n.nextSibling.previousSibling=n.previousSibling),this.firstChild==n&&(this.firstChild=n.nextSibling),this.lastChild==n&&(this.lastChild=n.previousSibling));this.childNodes=t}hasAttributes(){return this.childNodes.filter(t=>t.nodeType===2).length>0}setAttribute(e,t){let n=this.childNodes.filter(i=>i.nodeType===2);for(let i=0;i<n.length;++i)if(n[i].nodeName==e){n[i].nodeValue=`${t}`;return}let r=Le.create(2,e,t,this);r.parentNode=this,this.appendChild(r)}setAttributeNS(e,t,n){let r=this.childNodes.filter(o=>o.nodeType===2);for(let o=0;o<r.length;++o){let a=r[o];if(a.namespaceUri==e&&a.localName==this.qualifiedNameToParts(`${t}`)[1]){a.nodeValue=`${n}`,a.nodeName=`${t}`,a.prefix=this.qualifiedNameToParts(`${t}`)[0];return}}let i=Le.create(2,t,n,this,e);i.parentNode=this,this.appendChild(i)}getAttributeValue(e){let t=this.childNodes.filter(n=>n.nodeType===2);for(let n=0;n<t.length;++n)if(t[n].nodeName===e)return t[n].nodeValue;return null}getAttributeNS(e,t){let n=this.childNodes.filter(r=>r.nodeType===2);for(let r=0;r<n.length;++r){let i=n[r];if(i.namespaceUri===e&&i.localName===t)return i.nodeValue}return null}hasAttribute(e){let t=this.childNodes.filter(n=>n.nodeType===2);for(let n=0;n<t.length;++n)if(t[n].nodeName===e)return!0;return!1}hasAttributeNS(e,t){let n=this.childNodes.filter(r=>r.nodeType===2);for(let r=0;r<n.length;++r){let i=n[r];if(i.namespaceUri===e&&i.localName===t)return!0}return!1}removeAttribute(e){let t=[];for(let n=0;n<this.childNodes.length;++n){let r=this.childNodes[n];if(r.nodeType!==2){t.push(r);continue}r.nodeName!==e&&t.push(r)}this.childNodes=t}removeAttributeNS(e,t){let n=[];for(let r=0;r<this.childNodes.length;++r){let i=this.childNodes[r];if(i.nodeType!==2){n.push(i);continue}(i.localName!==t||i.namespaceUri!==e)&&n.push(i)}this.childNodes=n}getElementsByTagName(e){let t=[],n=this;return e=="*"?this.domTraverseElements(this,r=>{n!=r&&t.push(r)},null):this.domTraverseElements(this,r=>{n!=r&&r.nodeName==e&&t.push(r)},null),t}getElementsByTagNameNS(e,t){let n=[],r=this;return e=="*"&&t=="*"?this.domTraverseElements(this,i=>{r!=i&&n.push(i)},null):e=="*"?this.domTraverseElements(this,i=>{r!=i&&i.localName==t&&n.push(i)},null):t=="*"?this.domTraverseElements(this,i=>{r!=i&&i.namespaceUri==e&&n.push(i)},null):this.domTraverseElements(this,i=>{r!=i&&i.localName==t&&i.namespaceUri==e&&n.push(i)},null),n}getElementById(e){let t=null;return this.domTraverseElements(this,n=>{if(n.getAttributeValue("id")==e)return t=n,!1},null),t}getAncestorByLocalName(e){if(!(this.parentNode===null||this.parentNode===void 0))return this.parentNode.localName===e?this.parentNode:this.parentNode.getAncestorByLocalName(e)}getAncestorById(e){if(!(this.parentNode===null||this.parentNode===void 0))return this.parentNode.id===e?this.parentNode:this.parentNode.getAncestorById(e)}toString(){return`${this.nodeType}, ${this.nodeName}, ${this.nodeValue}`}};Le._unusedXNodes=[];var k=Le;var ue=class extends k{constructor(){super(9,"#document",null,null),this.documentElement=null}appendChild(e){super.appendChild(e),e.nodeType===1&&!this.documentElement&&(this.documentElement=e)}createElement(e){return k.create(1,e,null,this)}createElementNS(e,t){return k.create(1,t,null,this,e)}createDocumentFragment(){return k.create(11,"#document-fragment",null,this)}createTextNode(e){return k.create(3,"#text",e,this)}createAttribute(e){return k.create(2,e,null,this)}createAttributeNS(e,t){return k.create(2,t,null,this,e)}createComment(e){return k.create(8,"#comment",e,this)}createCDATASection(e){return k.create(4,"#cdata-section",e,this)}createDTDSection(e){return k.create(10,"#dtd-section",e,this)}createProcessingInstruction(e,t){return k.create(7,e,t,this)}};function Ia(s){if(s.nodeType===9){let n=new ue,r=s.childNodes;for(let i=0;i<r.length;i++){let o=hr(r[i],n);o&&(o.siblingPosition=n.childNodes.length,n.appendChild(o))}return n}let e=new ue,t=hr(s,e);return t&&(t.siblingPosition=0,e.appendChild(t)),e}function hr(s,e){switch(s.nodeType){case 1:{let t=s,n=k.create(1,t.nodeName,null,e,t.namespaceURI);n.prefix=t.prefix||null,n.localName=t.localName||t.nodeName;let r=t.attributes;for(let o=0;o<r.length;o++){let a=r[o],c=k.create(2,a.name,a.value,n,a.namespaceURI);c.prefix=a.prefix||null,c.localName=a.localName||a.name,c.parentNode=n,c.siblingPosition=n.childNodes.length,n.appendChild(c)}let i=s.childNodes;for(let o=0;o<i.length;o++){let a=hr(i[o],e);a&&(a.siblingPosition=n.childNodes.length,n.appendChild(a))}return n}case 3:return k.create(3,"#text",s.nodeValue||"",e);case 4:return k.create(4,"#cdata-section",s.nodeValue||"",e);case 8:return k.create(8,"#comment",s.nodeValue||"",e);case 7:{let t=s;return k.create(7,t.target,t.data,e)}case 10:{let t=s;return k.create(10,"#dtd-section",t.name,e)}case 11:{let t=k.create(11,"#document-fragment",null,e),n=s.childNodes;for(let r=0;r<n.length;r++){let i=hr(n[r],e);i&&(i.siblingPosition=t.childNodes.length,t.appendChild(i))}return t}default:return null}}function Ze(s,e){return s.getAttributeValue(e)}function W(s,e,t){return s.setAttribute(e,t)}function V(s,e){return s.appendChild(e)}function ae(s,e){return s.createTextNode(e)}function et(s,e){return s.createElement(e)}function mr(s,e){return s.createCDATASection(e)}function Tt(s,e){return s.createComment(e)}function Oe(s){return s.createDocumentFragment()}function mi(s,e){return s.createDTDSection(e)}function _a(s,e,t){return s.createProcessingInstruction(e,t)}var mu={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:"\xA0",copy:"\xA9",reg:"\xAE",times:"\xD7",divide:"\xF7",euro:"\u20AC",pound:"\xA3",yen:"\xA5",cent:"\xA2",sect:"\xA7",para:"\xB6",hellip:"\u2026",middot:"\xB7",deg:"\xB0"};function Xt(s){if(!s)return s;let e=s.replace(/&([a-zA-Z]+);/g,(t,n)=>{let r=n.toLowerCase();return mu[r]||t});return e=e.replace(/&#(\d+);/g,(t,n)=>{try{let r=parseInt(n,10);return String.fromCharCode(r)}catch(r){return t}}),e=e.replace(/&#[xX]([0-9a-fA-F]+);/g,(t,n)=>{try{let r=parseInt(n,16);return String.fromCharCode(r)}catch(r){return t}}),e}function me(s,e=!1){if(!s)return"";let t="";switch(s.nodeType){case 10:return`<!DOCTYPE ${s.nodeValue}>`;case 3:case 4:case 2:return s.nodeValue;case 1:case 9:case 11:if(!e){let r=s,i=r.innerText;if(i!==void 0)return i;let o=r.textContent;if(o!==void 0)return o}let n=s.childNodes.filter(r=>r.nodeType!==2);for(let r=0;r<n.length;++r)t+=me(n[r]);return t}}function di(s,e=!1){if(!s)return"";let t="";switch(s.nodeType){case 2:case 3:t+=s.nodeValue;break;case 4:t+=s.nodeValue;break;case 9:case 11:case 1:if(!e){let r=s,i=r.innerText;if(i!==void 0)return i;let o=r.textContent;if(o!==void 0)return o}let n=s.childNodes.length;for(let r=0;r<n;++r)t+=me(s.childNodes[r]);break}return t}function Mn(s,e={cData:!0,escape:!0,selfClosingTags:!0,outputMethod:"xml"}){let t=[];return kn(s,t,e),t.join("")}function kn(s,e,t){if(s.visited)return;let n=s.nodeType,r=s.nodeValue;if(n===3){let i=s.fromXslText===!0;if(s.nodeValue&&(i||s.nodeValue.trim()!=="")){let o=s.escape&&t.escape?_n(s.nodeValue):gu(s.nodeValue);e.push(o)}}else if(n===4)t.outputMethod==="text"?e.push(r):t.cData?e.push(_n(r)):e.push(`<![CDATA[${r}]]>`);else if(n==8)t.outputMethod!=="text"&&e.push(`<!--${r}-->`);else if(n===7)t.outputMethod!=="text"&&(r&&r.trim()?e.push(`<?${s.nodeName} ${r}?>`):e.push(`<?${s.nodeName}?>`));else if(n==1)t.outputMethod==="text"?yu(s,e,t):s.nodeName!==null&&s.nodeName!==void 0?fu(s,e,t):du(s,e,t);else if(n===9||n===11){let i=s.firstChild?[]:s.childNodes;if(s.firstChild){let o=s.firstChild;for(;o;)i.push(o),o=o.nextSibling}i.sort((o,a)=>o.siblingPosition-a.siblingPosition);for(let o=0;o<i.length;++o)kn(i[o],e,t)}s.visited=!0}function fu(s,e,t){e.push(`<${fr(s)}`);let n=[];if(s.firstChild){let i=s.firstChild;for(;i;)i.nodeType===2&&n.push(i),i=i.nextSibling}n.length===0&&(n=s.childNodes.filter(i=>i.nodeType===2));for(let i=0;i<n.length;++i){let o=n[i];o&&(t.outputMethod==="html"&&o.nodeName==="xmlns"&&o.nodeValue==="http://www.w3.org/1999/xhtml"||o.nodeName&&o.nodeValue!==null&&o.nodeValue!==void 0&&e.push(` ${fr(o)}="${xu(o.nodeValue)}"`))}let r=[];if(s.firstChild){let i=s.firstChild;for(;i;)i.nodeType!==2&&r.push(i),i=i.nextSibling}if(r.length===0&&(r=s.childNodes.filter(i=>i.nodeType!==2)),r=r.sort((i,o)=>i.siblingPosition-o.siblingPosition),r.length===0)t.outputMethod==="html"&&["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"].includes(s.nodeName)?e.push(">"):t.selfClosingTags?e.push("/>"):e.push(`></${fr(s)}>`);else{e.push(">");for(let i=0;i<r.length;++i)kn(r[i],e,t);e.push(`</${fr(s)}>`)}}function du(s,e,t){let n=[];if(s.firstChild){let r=s.firstChild;for(;r;)n.push(r),r=r.nextSibling}else n=s.childNodes;n=n.sort((r,i)=>r.siblingPosition-i.siblingPosition);for(let r=0;r<n.length;++r)kn(n[r],e,t)}function yu(s,e,t){let n=[];if(s.firstChild){let r=s.firstChild;for(;r;)n.push(r),r=r.nextSibling}else n=s.childNodes;n=n.sort((r,i)=>r.siblingPosition-i.siblingPosition);for(let r=0;r<n.length;++r)kn(n[r],e,t)}function fr(s){let e=s.nodeName;return s.prefix&&e.indexOf(`${s.prefix}:`)!=0?`${s.prefix}:${e}`:e}function gu(s){return`${s}`.replace(/</g,"<").replace(/>/g,">")}function _n(s){return`${s}`.replace(/&/g,"&").replace(/&amp;/g,"&").replace(/</g,"<").replace(/>/g,">")}function xu(s){return _n(s).replace(/"/g,""")}function f(s,e){let t=Ze(s,e);return t&&Xt(t)}function fi(s){if(!s)return null;let e=s.nodeType;if(e===3||e===4){let t=s.nodeValue?s.nodeValue.trim():"";return t.length>0?t:null}if(e===8)return null;if(e===9||e===11){let t=s.childNodes||[],n=[];for(let r=0;r<t.length;r++){let i=t[r],o=fi(i);o!==null&&n.push(o)}return n.length===0?null:n.length===1?n[0]:n}if(e===1){let t={},n=s,r=n.attributes&&n.attributes.length>0;if(r)for(let u=0;u<n.attributes.length;u++){let l=n.attributes[u];t["@"+l.nodeName]=l.nodeValue}let i=n.childNodes||[],o="",a=!1,c={};for(let u=0;u<i.length;u++){let l=i[u],p=l.nodeType;if(p===3||p===4){let h=l.nodeValue?l.nodeValue.trim():"";h.length>0&&(o+=h)}else if(p===1){a=!0;let h=l,m=h.localName||h.nodeName,d=fi(l);d!==null&&(c[m]?(Array.isArray(c[m])||(c[m]=[c[m]]),c[m].push(d)):c[m]=d)}}if(Object.assign(t,c),!a&&o.length>0){if(!r&&Object.keys(c).length===0)return o;t["#text"]=o}return Object.keys(t).length===0?null:t}return null}function Ma(s){if(!s)return"xml";let e=s.nodeType;if(e===9||e===11){let t=s.childNodes||[],n=0,r=0,i=!1;for(let o=0;o<t.length;o++){let a=t[o];a.nodeType===1?n++:a.nodeType===3&&(a.nodeValue?a.nodeValue.trim():"").length>0&&(r++,i=!0)}return n===0&&i?"text":"xml"}return(e===3||e===4)&&(s.nodeValue?s.nodeValue.trim():"").length>0?"text":"xml"}function ka(s){if(!s)return"{}";let e=s;if(s.nodeType===9||s.nodeType===11){let o=s.childNodes||[];for(let a=0;a<o.length;a++)if(o[a].nodeType===1){e=o[a];break}}let t=e,n=t.localName||t.nodeName,r={},i=fi(e);i===null?r[n]={}:(typeof i=="object"&&Array.isArray(i),r[n]=i);try{let o=JSON.parse(JSON.stringify(r));return JSON.stringify(o)}catch(o){return JSON.stringify(r)}}var dr=`[ \r
|
|
7
|
-
]+`,yr=`(${dr})?=(${dr})?`,Fa="&#[0-9]+;|&#x[0-9a-fA-F]+;",$a=`${dr}version${yr}("1\\.0"|'1\\.0')`,Nu="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF\u0100-\u0131\u0134-\u013E\u0141-\u0148\u014A-\u017E\u0180-\u01C3\u01CD-\u01F0\u01F4-\u01F5\u01FA-\u0217\u0250-\u02A8\u02BB-\u02C1\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03CE\u03D0-\u03D6\u03DA\u03DC\u03DE\u03E0\u03E2-\u03F3\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E-\u0481\u0490-\u04C4\u04C7-\u04C8\u04CB-\u04CC\u04D0-\u04EB\u04EE-\u04F5\u04F8-\u04F9\u0531-\u0556\u0559\u0561-\u0586\u05D0-\u05EA\u05F0-\u05F2\u0621-\u063A\u0641-\u064A\u0671-\u06B7\u06BA-\u06BE\u06C0-\u06CE\u06D0-\u06D3\u06D5\u06E5-\u06E6\u0905-\u0939\u093D\u0958-\u0961\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09DC-\u09DD\u09DF-\u09E1\u09F0-\u09F1\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33\u0A35-\u0A36\u0A38-\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8B\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0AE0\u0B05-\u0B0C\u0B0F-\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B36-\u0B39\u0B3D\u0B5C-\u0B5D\u0B5F-\u0B61\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB5\u0BB7-\u0BB9\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C60-\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CDE\u0CE0-\u0CE1\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D28\u0D2A-\u0D39\u0D60-\u0D61\u0E01-\u0E2E\u0E30\u0E32-\u0E33\u0E40-\u0E45\u0E81-\u0E82\u0E84\u0E87-\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA-\u0EAB\u0EAD-\u0EAE\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0F40-\u0F47\u0F49-\u0F69\u10A0-\u10C5\u10D0-\u10F6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110B-\u110C\u110E-\u1112\u113C\u113E\u1140\u114C\u114E\u1150\u1154-\u1155\u1159\u115F-\u1161\u1163\u1165\u1167\u1169\u116D-\u116E\u1172-\u1173\u1175\u119E\u11A8\u11AB\u11AE-\u11AF\u11B7-\u11B8\u11BA\u11BC-\u11C2\u11EB\u11F0\u11F9\u1E00-\u1E9B\u1EA0-\u1EF9\u1F00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2126\u212A-\u212B\u212E\u2180-\u2182\u3041-\u3094\u30A1-\u30FA\u3105-\u312C\uAC00-\uD7A3",Eu="\u4E00-\u9FA5\u3007\u3021-\u3029",La="\u0300-\u0345\u0360-\u0361\u0483-\u0486\u0591-\u05A1\u05A3-\u05B9\u05BB-\u05BD\u05BF\u05C1-\u05C2\u05C4\u064B-\u0652\u0670\u06D6-\u06DC\u06DD-\u06DF\u06E0-\u06E4\u06E7-\u06E8\u06EA-\u06ED\u0901-\u0903\u093C\u093E-\u094C\u094D\u0951-\u0954\u0962-\u0963\u0981-\u0983\u09BC\u09BE\u09BF\u09C0-\u09C4\u09C7-\u09C8\u09CB-\u09CD\u09D7\u09E2-\u09E3\u0A02\u0A3C\u0A3E\u0A3F\u0A40-\u0A42\u0A47-\u0A48\u0A4B-\u0A4D\u0A70-\u0A71\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0B01-\u0B03\u0B3C\u0B3E-\u0B43\u0B47-\u0B48\u0B4B-\u0B4D\u0B56-\u0B57\u0B82-\u0B83\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C01-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55-\u0C56\u0C82-\u0C83\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5-\u0CD6\u0D02-\u0D03\u0D3E-\u0D43\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB-\u0EBC\u0EC8-\u0ECD\u0F18-\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86-\u0F8B\u0F90-\u0F95\u0F97\u0F99-\u0FAD\u0FB1-\u0FB7\u0FB9\u20D0-\u20DC\u20E1\u302A-\u302F\u3099\u309A",Ua="0-9\u0660-\u0669\u06F0-\u06F9\u0966-\u096F\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE7-\u0BEF\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29",Wa="\xB7\u02D0\u02D1\u0387\u0640\u0E46\u0EC6\u3005\u3031-\u3035\u309D-\u309E\u30FC-\u30FE",gr=Nu+Eu,bu=`${gr+Ua}\\._:${La}${Wa}-`,xr=`[${gr}_:][${bu}]*`,Pu=`&${xr};`,Da=`${Pu}|${Fa}`,Tu=`"(([^<&"]|${Da})*)"|'(([^<&']|${Da})*)'`,qa=`(${xr})${yr}(${Tu})`,Ba=`${dr}version${yr}("1\\.1"|'1\\.1')`,za=":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD",Xu=za+"\\.0-9\xB7\u0300-\u036F\u203F-\u2040-",Nr=`[${za}][${Xu}]*`,Su=`&${Nr};`,Va=`${Su}|${Fa}`,Cu=`"(([^<&"]|${Va})*)"|'(([^<&']|${Va})*)'`,ja=`(${Nr})${yr}(${Cu})`,wu=`${gr+Ua}\\._${La}${Wa}-`,rg=`[${gr}_][${wu}]*`;var Ue=class{constructor(){this.regexEmpty=/\/$/;this.XML10_TAGNAME_REGEXP=new RegExp(`^(${xr})`);this.XML10_ATTRIBUTE_REGEXP=new RegExp(qa,"g");this.XML11_TAGNAME_REGEXP=new RegExp(`^(${Nr})`);this.XML11_ATTRIBUTE_REGEXP=new RegExp(ja,"g");this.lenientHtmlTags=["hr","link","meta"]}xmlParse(e){return e.toUpperCase().startsWith("<!DOCTYPE HTML")?this.htmlParse(e):this.xmlStrictParse(e)}namespaceMapAt(e){let t={xmlns:"http://www.w3.org/2000/xmlns/",xml:"http://www.w3.org/XML/1998/namespace"},n=e;for(;n!==null;){for(let r=0;r<n.childNodes.length;r++){let i=n.childNodes[r];if(i.nodeType===2)if(i.nodeName.startsWith("xmlns:")){let o=i.nodeName.split(":")[1];o in t||(t[o]=i.nodeValue)}else i.nodeName=="xmlns"&&(""in t||(t[""]=i.nodeValue||null))}n=n.parentNode}return t}htmlParse(e){let t=new ue,n=t,r=[],i=n;r.push(i);let o=!1,a=!1,c=!1,u=0;for(let l=0;l<e.length;++l){let p=e.charAt(l);if(o){if(!c&&p==="'")a=!a;else if(!a&&p==='"')c=!c;else if(!a&&!c&&p===">"){let h=e.slice(u,l);if(h.charAt(0)==="/")r.pop(),i=r[r.length-1];else if(h.charAt(0)!=="!"){let m=h.match(this.regexEmpty),d=this.XML10_TAGNAME_REGEXP.exec(h)[1],y=et(t,d),E;for(;E=this.XML10_ATTRIBUTE_REGEXP.exec(h);){let T=Xt(E[5]||E[7]||"");W(y,E[1],T)}y.siblingPosition=i.childNodes.length,V(i,y),!m&&!this.lenientHtmlTags.includes(d)&&(i=y,r.push(y))}u=l+1,o=!1,a=!1,c=!1}}else if(p==="<"){let h=e.slice(u,l);if(h&&i!==n&&V(i,ae(t,h)),e.slice(l+1,l+4)==="!--"){let m=e.slice(l+4).indexOf("-->");if(m>=0){let d=Tt(t,e.slice(l+4,l+m+4));V(i,d),l+=m+6}}else if(e.slice(l+1,l+9)==="!DOCTYPE"){let m=e.slice(l+9).indexOf(">");if(m>=0){let d=e.slice(l+9,l+m+9).trimStart(),y=mi(t,d);V(i,y),l+=m+d.length+5}}else o=!0;u=l+1}}return t}xmlStrictParse(e){let t,n;if(e.match(/^<\?xml/))if(e.search(new RegExp($a))===5)t=this.XML10_TAGNAME_REGEXP,n=this.XML10_ATTRIBUTE_REGEXP;else if(e.search(new RegExp(Ba))===5)t=this.XML11_TAGNAME_REGEXP,n=this.XML11_ATTRIBUTE_REGEXP;else throw new Error("XML VersionInfo has an unknown version number.");else t=this.XML10_TAGNAME_REGEXP,n=this.XML10_ATTRIBUTE_REGEXP;let r=new ue,i=r,o=[],a=i;o.push(a);let c=!1,u=!1,l=!1,p=0;for(let h=0;h<e.length;++h){let m=e.charAt(h);if(c&&!l&&m==="'")u=!u;else if(c&&!u&&m==='"')l=!l;else if(c&&m===">"&&!u&&!l){let d=e.slice(p,h);if(d.charAt(0)==="/")o.pop(),a=o[o.length-1];else if(d.charAt(0)!=="?"){if(d.charAt(0)!=="!"){let y=d.match(this.regexEmpty),E=t.exec(d)[1],T=et(r,E),P;for(;P=n.exec(d);){let w=Xt(P[5]||P[7]||"");W(T,P[1],w)}T.siblingPosition=a.childNodes.length,V(a,T),y||(a=T,o.push(T));let A=this.namespaceMapAt(T);T.prefix!==null?T.prefix in A&&(T.namespaceUri=A[T.prefix]):""in A&&(T.namespaceUri=A[""]);for(let w=0;w<T.childNodes.length;++w){let F=T.childNodes[w];F.nodeType===2&&F.prefix!==null&&F.prefix in A&&(F.namespaceUri=A[F.prefix])}}}p=h+1,c=!1,u=!1,l=!1}else if(!c&&m==="<"){let d=e.slice(p,h);if(d&&a!==i&&V(a,ae(r,Xt(d))),e.slice(h+1,h+4)==="!--"){let y=e.slice(h+4).indexOf("-->");if(y>=0){let E=Tt(r,e.slice(h+4,h+y+4));V(a,E),h+=y+6}}else if(e.slice(h+1,h+9)==="![CDATA["){let y=e.slice(h+9).indexOf("]]>");if(y>=0){let E=mr(r,e.slice(h+9,h+y+9));V(a,E),h+=y+11}}else if(e.slice(h+1,h+9)==="!DOCTYPE"){let y=e.slice(h+9).indexOf(">");if(y>=0){let E=e.slice(h+9,h+y+9).trimStart(),T=mi(r,E);V(a,T),h+=y+E.length+5}}else c=!0;p=h+1}}return i}};function Er(s,e){return X({node:s,position:1,size:1},e)}var Z=class{constructor(e){this.value=e,this.type="node-set"}stringValue(){return this.value.length===0?"":me(this.value[0])}booleanValue(){return this.value.length>0}numberValue(){return parseInt(this.stringValue())-0}nodeSetValue(){return this.value}};var G=class{constructor(e){this.value=e,this.type="string"}stringValue(){return String(this.value)}booleanValue(){return this.value.length>0}numberValue(){let e=String(this.value).trim();return e.length===0?NaN:Number(e)}nodeSetValue(){throw this}};var fe=class{constructor(e){this.value=e,this.type="number"}stringValue(){return`${this.value}`}booleanValue(){return!!this.value}numberValue(){return this.value-0}nodeSetValue(){throw this}};var R=class{constructor(e){this.value=e,this.type="boolean"}stringValue(){return`${this.value}`}booleanValue(){return this.value}numberValue(){return this.value?1:0}nodeSetValue(){throw this}};var St=class{constructor(e){this.value=e,this.type="map"}stringValue(){let e={};for(let t in this.value)t!=="__isMap"&&(e[t]=this.value[t]);return JSON.stringify(e)}booleanValue(){return!0}numberValue(){return NaN}nodeSetValue(){return[]}};var Ct=class{constructor(e){this.value=e,this.type="array"}stringValue(){return JSON.stringify(this.value.members||[])}booleanValue(){return!0}numberValue(){return NaN}nodeSetValue(){return[]}};var wt=class{constructor(e){this.value=e,this.type="function"}stringValue(){return`function ${this.value.name?`${this.value.name}#${this.value.arity}`:`(anonymous)#${this.value.arity}`}`}booleanValue(){return!0}numberValue(){return NaN}nodeSetValue(){return[]}};En();var br=class{exprContextToXPathContext(e){let t=e.nodeList[e.position],n=this.adaptXNode(t),r=e.nodeList.map(a=>this.adaptXNode(a)),i={},o=e;for(;o;)!i.regexGroups&&o.regexGroups&&(i.regexGroups=o.regexGroups),!i.currentGroup&&o.currentGroup&&(i.currentGroup=o.currentGroup),!i.currentGroupingKey&&o.currentGroupingKey!==void 0&&(i.currentGroupingKey=o.currentGroupingKey),o=o.parent;return Er(n,{position:e.position+1,size:e.nodeList.length,nodeList:r,variables:this.convertVariables(e),functions:this.createCustomFunctions(e),namespaces:e.knownNamespaces,xsltVersion:e.xsltVersion,extensions:Object.keys(i).length>0?i:void 0})}adaptXNode(e){if(!e)throw new Error("Cannot adapt undefined XPath node.");let t=e;return"textContent"in t||Object.defineProperty(t,"textContent",{get(){return this._getTextContent()},enumerable:!0,configurable:!0}),"_getTextContent"in t||(t._getTextContent=function(){if(this.nodeType===3||this.nodeType===2)return this.nodeValue||"";if(!this.childNodes)return"";let n="";for(let r of this.childNodes)r.nodeType===3?n+=r.nodeValue||"":r.nodeType===1&&(n+=this._getTextContent.call(r));return n}),"attributes"in t||Object.defineProperty(t,"attributes",{get(){return this.childNodes?this.childNodes.filter(n=>n.nodeType===2):[]},enumerable:!0,configurable:!0}),"getAttribute"in t||(t.getAttribute=function(n){return this.getAttributeValue?this.getAttributeValue(n):null}),t}xPathNodeToXNode(e){return e?e instanceof k?e:this.convertXPathNodeToXNode(e):null}getTextContent(e){if(e.nodeType===3||e.nodeType===2)return e.nodeValue||"";if(!e.childNodes)return"";let t="";for(let n of e.childNodes)n.nodeType===3?t+=n.nodeValue||"":n.nodeType===1&&(t+=this.getTextContent(n));return t}convertVariables(e){let t={},n=[],r=e;for(;r;)n.push(r),r=r.parent;for(let i=n.length-1;i>=0;i--){let a=n[i].variables||{};for(let c in a){if(!Object.prototype.hasOwnProperty.call(a,c))continue;let u=a[c];if(u&&typeof u=="object"&&"stringValue"in u){let l=u;l.type==="node-set"?t[c]=u.nodeSetValue().map(p=>this.adaptXNode(p)):l.type==="string"?t[c]=u.stringValue():l.type==="number"?t[c]=u.numberValue():l.type==="boolean"?t[c]=u.booleanValue():l.type==="map"||l.type==="array"||l.type==="function"?t[c]=l.value:t[c]=u.stringValue()}else t[c]=u}}return t}createCustomFunctions(e){let t={};t.key=(r,i,o)=>{var c;let a=(c=e.keys)==null?void 0:c[i];return a&&a[o]?a[o].nodeSetValue().map(l=>this.adaptXNode(l)):[]},t.current=r=>{let i=e.nodeList[e.position];return[this.adaptXNode(i)]},t["format-number"]=(r,i,o,a)=>{let c=e.decimalFormatSettings;return this.formatXsltNumberPicture(Number(i),String(o),c)},t["xml-to-json"]=(r,i)=>{if(e.xsltVersion!=="3.0")throw new Error('xml-to-json() is only supported in XSLT 3.0. Use version="3.0" in your stylesheet.');let o=Array.isArray(i)?i[0]:i;return o?this.xmlToJson(o):'""'},t["json-to-xml"]=(r,i)=>{if(e.xsltVersion!=="3.0")throw new Error('json-to-xml() is only supported in XSLT 3.0. Use version="3.0" in your stylesheet.');let o=Array.isArray(i)?i[0]:i;if(!o)return[];let c=new we().convert(String(o));if(!c)return null;let u=e.nodeList&&e.nodeList.length>0?e.nodeList[0].ownerDocument:null,l=this.convertXPathNodeToXNode(c,u);return l?[l]:[]},t["system-property"]=(r,i)=>{let o=String(i),a={"xsl:version":e.xsltVersion||"1.0","xsl:vendor":"Design Liquido","xsl:vendor-url":"https://github.com/DesignLiquido/xslt-processor"};return e.systemProperties&&e.systemProperties[o]?e.systemProperties[o]:a[o]||""},t["element-available"]=(r,i)=>{let o=String(i),a=["xsl:apply-imports","xsl:apply-templates","xsl:attribute","xsl:attribute-set","xsl:call-template","xsl:choose","xsl:comment","xsl:copy","xsl:copy-of","xsl:decimal-format","xsl:element","xsl:fallback","xsl:for-each","xsl:if","xsl:import","xsl:include","xsl:key","xsl:message","xsl:namespace-alias","xsl:number","xsl:otherwise","xsl:output","xsl:param","xsl:preserve-space","xsl:processing-instruction","xsl:sort","xsl:strip-space","xsl:stylesheet","xsl:template","xsl:text","xsl:transform","xsl:value-of","xsl:variable","xsl:when","xsl:with-param"],c=o.startsWith("xsl:")?o:`xsl:${o}`;return a.indexOf(c)>=0||a.indexOf(o)>=0},t["function-available"]=(r,i)=>{let o=String(i),a=["boolean","ceiling","concat","contains","count","false","floor","id","lang","last","local-name","name","namespace-uri","normalize-space","not","number","position","round","starts-with","string","string-length","substring","substring-after","substring-before","sum","translate","true"],c=["current","document","element-available","format-number","function-available","generate-id","key","system-property","unparsed-entity-uri"],u=["matches","ends-with","xml-to-json","json-to-xml"];return[...a,...c,...u].indexOf(o)>=0},t.document=(r,i,o)=>{var a,c;if(e.documentLoader){let u=Array.isArray(i)?((a=i[0])==null?void 0:a.textContent)||String(i[0]||""):String(i||"");if(!u)return e.root?[this.adaptXNode(e.root)]:[];try{let l=e.documentLoader(u);if(l)return[this.adaptXNode(l)]}catch(l){((c=e.warningsCallback)!=null?c:console.warn)(`document() failed to load: ${u}`,l)}}return[]},t["unparsed-entity-uri"]=(r,i)=>{let o=String(i);return e.unparsedEntities&&e.unparsedEntities[o]?e.unparsedEntities[o]:""};let n=e;for(;n;){if(n.userDefinedFunctions){n.userDefinedFunctions.forEach((r,i)=>{t[i]||(t[i]=(o,...a)=>r.executor(e,r.functionDef,a))});break}n=n.parent}return t}formatXsltNumberPicture(e,t,n){if(Number.isNaN(e))return n.naN;if(!Number.isFinite(e))return e<0?`${n.minusSign}${n.infinity}`:n.infinity;let r=t.split(n.patternSeparator),i=e<0,o=(i&&r.length>1?r[1]:r[0])||"",a=Math.abs(e),c=new Set([n.digit,n.zeroDigit,n.groupingSeparator,n.decimalSeparator]),u=-1,l=-1;for(let L=0;L<o.length;L++)c.has(o[L])&&(u===-1&&(u=L),l=L);if(u===-1)return o;let p=o.slice(0,u),h=o.slice(l+1),m=o.slice(u,l+1),d=a;o.includes(n.percent)&&(d*=100),o.includes(n.perMille)&&(d*=1e3);let y=m.indexOf(n.decimalSeparator),E=y>=0?m.slice(0,y):m,T=y>=0?m.slice(y+1):"",P=E.split("").filter(L=>L===n.zeroDigit).length,A=T.split("").filter(L=>L===n.zeroDigit).length,w=T.split("").filter(L=>L===n.zeroDigit||L===n.digit).length,F=w>0?d.toFixed(w):Math.round(d).toString(),[j,Y=""]=F.split(".");for(j.length<P&&(j=this.leftPad(j,P,n.zeroDigit));Y.length>A&&Y.endsWith(n.zeroDigit);)Y=Y.slice(0,-1);let ee=E.lastIndexOf(n.groupingSeparator);if(ee>=0){let L=E.slice(ee+1).split("").filter(Bn=>Bn===n.zeroDigit||Bn===n.digit).length;L>0&&(j=this.applyGrouping(j,n.groupingSeparator,L))}let q=Y.length>0?`${j}${n.decimalSeparator}${Y}`:j;return i&&r.length<2?`${n.minusSign}${p}${q}${h}`:`${p}${q}${h}`}applyGrouping(e,t,n){if(n<=0||e.length<=n)return e;let r=[];for(let i=e.length;i>0;i-=n){let o=Math.max(0,i-n);r.unshift(e.slice(o,i))}return r.join(t)}leftPad(e,t,n){if(e.length>=t)return e;let r=n&&n.length>0?n.charAt(0):"0",i=t-e.length,o="";for(let a=0;a<i;a++)o+=r;return o+e}convertXPathNodeToXNode(e,t){if(!e)return null;let n;if(e.nodeType===9){if(e.childNodes&&e.childNodes.length>0){let r=e.childNodes[0],i=this.convertXPathNodeToXNode(r,t);return i?(n=i,n):null}return null}else if(e.nodeType===3){let r=e.textContent||"";n=new k(3,"#text",r,t)}else if(n=new k(1,e.nodeName||"element","",t),e.namespaceUri&&(n.namespaceUri=e.namespaceUri),e.childNodes&&e.childNodes.length>0){for(let r=0;r<e.childNodes.length;r++){let i=e.childNodes[r],o=this.convertXPathNodeToXNode(i,t);o&&(o.parentNode=n,n.childNodes.push(o))}n.childNodes.length>0&&(n.firstChild=n.childNodes[0],n.lastChild=n.childNodes[n.childNodes.length-1])}return n}xmlToJson(e){if(!e)return'""';let t=me(e,!0);return JSON.stringify(t)}wrapResult(e,t){if(e==null)return new Z([]);if(Array.isArray(e)){let n=e.map(r=>this.xPathNodeToXNode(r)).filter(r=>r!==null);return n.length>0||e.length===0?new Z(n):new G(e.map(r=>String(r)).join(" "))}if(typeof e=="string")return new G(e);if(typeof e=="number")return new fe(e);if(typeof e=="boolean")return new R(e);if(typeof e=="object"){if(e.__isMap)return new St(e);if(e.__isArray)return new Ct(e);if(e.__isFunctionItem)return new wt(e)}return new Z([])}clearCache(){}};ce();var ve=class{constructor(e,t){this.xpathExpression=e,this.nodeConverter=t,e instanceof Ee&&(this.absolute=e.absolute,this.steps=e.steps.map((n,r)=>({axis:n.axis,nodeTest:n.nodeTest,predicates:n.predicates,hasPositionalPredicate:!1,predicate:n.predicates||[],evaluate:i=>{let o=this.nodeConverter.exprContextToXPathContext(i),a=n.evaluate(o);return this.nodeConverter.wrapResult(a,i)}})))}evaluate(e){let t=this.nodeConverter.exprContextToXPathContext(e),n=this.xpathExpression.evaluate(t);return this.nodeConverter.wrapResult(n,e)}};var Re=class extends ve{constructor(e,t){super(e,t),this.absolute=e.absolute,this.steps=e.steps.map(n=>({axis:n.axis,nodeTest:n.nodeTest,predicates:n.predicates||[],predicate:n.predicates||[],hasPositionalPredicate:this.hasPositionalPredicate(n.predicates||[])}))}hasPositionalPredicate(e){return!1}appendStep(e){this.steps.push(e)}prependStep(e){this.steps.unshift(e)}};var We=class extends ve{constructor(e,t,n,r){super(e,t),this.expr1=n,this.expr2=r}};var tt=class{constructor(){this.lexers=new Map;this.parsers=new Map;this.parseCache=new Map;this.nodeConverter=new br}getLexer(e){let t=e||"1.0";return this.lexers.has(t)||this.lexers.set(t,new Ie({version:t})),this.lexers.get(t)}getParser(e){let t=e||"1.0";return this.parsers.has(t)||this.parsers.set(t,Ra(t)),this.parsers.get(t)}xPathParse(e,t,n="1.0"){let r=`${e}:${t||""}:${n}`;if(this.parseCache.has(r))return this.parseCache.get(r);let i=this.getLexer(n),o=this.getParser(n),a=i.scan(e),c=o.parse(a),u=this.wrapExpression(c,t);return this.parseCache.set(r,u),u}xPathEval(e,t){let n=t.xsltVersion||"1.0",r=n==="3.0"?"3.1":n;return this.xPathParse(e,void 0,r).evaluate(t)}xPathSort(e,t){if(t.length===0)return;let n=[];for(let i=0;i<e.contextSize();++i){let o=e.nodeList[i],a={node:o,key:[]},c=e.clone([o],0);for(let u of t){let l=u.expr.evaluate(c),p;u.type==="text"?p=l.stringValue():u.type==="number"&&(p=l.numberValue()),a.key.push({value:p,order:u.order})}a.key.push({value:i,order:"ascending"}),n.push(a)}n.sort(this.xPathSortByKey);let r=[];for(let i=0;i<n.length;++i){let o=n[i].node;o.siblingPosition=i,r.push(o)}e.nodeList=r,e.setNode(0)}xPathSortByKey(e,t){for(let n=0;n<e.key.length;++n){let r=e.key[n].order==="descending"?-1:1;if(e.key[n].value>t.key[n].value)return 1*r;if(e.key[n].value<t.key[n].value)return-1*r}return 0}wrapExpression(e,t){if(e instanceof Ee)return t&&e.steps.length>0&&!e.absolute&&(e.steps[0].axis=t),new Re(e,this.nodeConverter);if(e instanceof Ce){let n=this.wrapExpression(e.left,t),r=this.wrapExpression(e.right,t);return new We(e,this.nodeConverter,n,r)}return new ve(e,this.nodeConverter)}clearCache(){this.parseCache.clear(),this.nodeConverter.clearCache()}};var Ya={label:"[number]",prec:35,re:new RegExp("^\\d+(\\.\\d*)?"),key:void 0};var qe=class s{constructor(e,t="1.0",n,r,i,o,a,c,u,l,p,h){this.nodeList=e,this.xsltVersion=t,this.position=n||0,this.variables=i||{},this.keys=(a==null?void 0:a.keys)||{},this.knownNamespaces=o||{},this.parent=a||null,this.caseInsensitive=c||!1,this.ignoreAttributesWithoutValue=u||!1,this.returnOnFirstMatch=l||!1,this.ignoreNonElementNodesForNTA=p||!1,this.inApplyTemplates=!1,this.baseTemplateMatched=!1,this.warningsCallback=h!=null?h:a==null?void 0:a.warningsCallback,this.decimalFormatSettings=r||{decimalSeparator:".",groupingSeparator:",",infinity:"Infinity",minusSign:"-",naN:"NaN",percent:"%",perMille:"\u2030",zeroDigit:"0",digit:"#",patternSeparator:";"},a?this.root=a.root:this.nodeList[this.position].nodeType==9?this.root=this.nodeList[this.position]:this.root=this.nodeList[this.position].ownerDocument}clone(e,t){return new s(e||this.nodeList,this.xsltVersion,typeof t!="undefined"?t:this.position,this.decimalFormatSettings,Object.create(this.variables||{}),this.knownNamespaces,this,this.caseInsensitive,this.ignoreAttributesWithoutValue,this.returnOnFirstMatch,this.ignoreNonElementNodesForNTA,this.warningsCallback)}setVariable(e,t){if(t instanceof G||t instanceof R||t instanceof fe||t instanceof Z||t instanceof St||t instanceof Ct||t instanceof wt){this.variables[e]=t;return}t==="true"?this.variables[e]=new R(!0):t==="false"?this.variables[e]=new R(!1):Ya.re.test(String(t))?this.variables[e]=new fe(t):this.variables[e]=new G(t)}getVariable(e){return typeof this.variables[e]!="undefined"?this.variables[e]:this.parent?this.parent.getVariable(e):null}getRegexGroup(e){var t;return this.regexGroups&&e>=0&&e<this.regexGroups.length?(t=this.regexGroups[e])!=null?t:"":this.parent?this.parent.getRegexGroup(e):""}setNode(e){this.position=e}contextSize(){return this.nodeList.length}isCaseInsensitive(){return this.caseInsensitive}setCaseInsensitive(e){return this.caseInsensitive=e}isIgnoreAttributesWithoutValue(){return this.ignoreAttributesWithoutValue}setIgnoreAttributesWithoutValue(e){return this.ignoreAttributesWithoutValue=e}isReturnOnFirstMatch(){return this.returnOnFirstMatch}setReturnOnFirstMatch(e){return this.returnOnFirstMatch=e}isIgnoreNonElementNodesForNTA(){return this.ignoreNonElementNodesForNTA}setIgnoreNonElementNodesForNTA(e){return this.ignoreNonElementNodesForNTA=e}};var Dn=class{expressionMatch(e,t){if(e instanceof Re)return this.locationExpressionMatch(e,t);if(e instanceof We)return this.unionExpressionMatch(e,t);try{return e.evaluate(t).nodeSetValue()}catch(n){return[]}}locationExpressionMatch(e,t){if(!e.steps||e.steps.length<=0){if(e.absolute){let n=t.nodeList[t.position];return n.nodeName==="#document"?[n]:[]}return[t.nodeList[t.position]]}return e.absolute?e.steps[0].axis==="self"?this.absoluteXsltMatchByDocumentNode(e,t):this.absoluteXsltMatch(e,t):this.relativeXsltMatch(e,t)}unionExpressionMatch(e,t){return this.expressionMatch(e.expr1,t).concat(this.expressionMatch(e.expr2,t))}absoluteXsltMatchByDocumentNode(e,t){let n=t.clone([t.root],0),r=e.evaluate(n).nodeSetValue(),i=[];for(let o of r)o.id===t.nodeList[t.position].id&&i.push(o);return i}absoluteXsltMatch(e,t){var c;let n=t.root.childNodes.find(u=>u.nodeName!=="#dtd-section");if(!n)return[];let r=t.clone([n],0),i=e.evaluate(r).nodeSetValue(),o=[],a;t.nodeList.length===1&&t.nodeList[0].nodeName==="#document"?a=[t.nodeList[0].childNodes.find(u=>u.nodeName!=="#dtd-section")]:a=t.nodeList;for(let u of i)u.id===((c=a[t.position])==null?void 0:c.id)&&o.push(u);return o}relativeXsltMatch(e,t){let n=t.clone(),r=e.evaluate(n).nodeSetValue();return r.length===1&&r[0].nodeName==="#document"?[r[0].childNodes[0]]:r}};var Vn=class{constructor(){this.value=new R(!0)}evaluate(){return this.value}};var Fn=class{evaluate(e){return new R(e.nodeList[e.position].nodeType==8)}};var $n=class{evaluate(e){let t=e.nodeList[e.position];return new R(t.nodeType==1||t.nodeType==2)}};var Ln=class{constructor(e){if(this.name=e,e.indexOf(":")>0){let t=e.split(":");this.namespacePrefix=t[0],this.name=t[1]}this.re=new RegExp(`^${e}$`,"i")}evaluate(e){let t=e.nodeList[e.position];return this.namespacePrefix!==void 0?e.knownNamespaces[this.namespacePrefix]!==t.namespaceUri?new R(!1):e.caseInsensitive?t.localName.length!==this.name.length?new R(!1):new R(this.re.test(t.localName)):new R(t.localName===this.name):e.caseInsensitive?t.nodeName.length!==this.name.length?new R(!1):new R(this.re.test(t.nodeName)):new R(t.nodeName===this.name)}};var Un=class{constructor(e){this.regex=new RegExp(`^${e}:`),this.nsprefix=e}evaluate(e){let t=e.nodeList[e.position];return new R(t.nodeName.match(this.regex))}};var Wn=class{constructor(e){this.target=e}evaluate(e){let t=e.nodeList[e.position];return new R(t.nodeType==7&&(!this.target||t.nodeName==this.target))}};var qn=class{evaluate(e){return new R(e.nodeList[e.position].nodeType==3)}};function At(s){switch(s.type){case"function":case"variable":case"attribute-set":return`${s.type}:${s.name||""}`;case"template":return s.name?`template:name:${s.name}`:s.match?`template:match:${s.mode||"#default"}:${s.match}`:"template:unknown";case"mode":return`mode:${s.name||"#default"}`;default:return`unknown:${s.type}`}}function Ga(s,e){return s.visibility==="private"?e:!0}function Qa(s){return s.visibility==="final"?!1:s.overridable}var Pr=class{constructor(){this.packages=new Map;this.loading=new Set}register(e){let t=this.makePackageKey(e.name,e.version);this.packages.set(t,e)}get(e,t){if(!t)return this.packages.get(e);let n=this.makePackageKey(e,t),r=this.packages.get(n);if(r)return r;if(!/[*<>=,]/.test(t))return;let o=[];if(this.packages.forEach((a,c)=>{a.name===e&&a.version&&this.satisfiesVersion(a.version,t)&&o.push(a)}),o.length!==0)return o.sort((a,c)=>this.compareVersions(c.version,a.version)),o[0]}satisfiesVersion(e,t){return t.includes(",")?t.split(",").map(r=>r.trim()).every(r=>this.satisfiesSingleConstraint(e,r)):this.satisfiesSingleConstraint(e,t)}satisfiesSingleConstraint(e,t){if(t.includes("*")){let a=t.replace(/\*$/,"").replace(/\.$/,"");if(!a)return!0;let c=e.split("."),u=a.split(".");for(let l=0;l<u.length;l++)if(c[l]!==u[l])return!1;return!0}let n=t.match(/^(>=|<=|>|<|=)?(.+)$/);if(!n)return!1;let r=n[1]||"=",i=n[2].trim(),o=this.compareVersions(e,i);switch(r){case">=":return o>=0;case">":return o>0;case"<=":return o<=0;case"<":return o<0;default:return o===0}}compareVersions(e,t){let n=e.split(".").map(o=>parseInt(o,10)||0),r=t.split(".").map(o=>parseInt(o,10)||0),i=Math.max(n.length,r.length);for(let o=0;o<i;o++){let a=n[o]||0,c=r[o]||0;if(a<c)return-1;if(a>c)return 1}return 0}has(e,t){let n=this.makePackageKey(e,t);return this.packages.has(n)}beginLoading(e){return this.loading.has(e)?!1:(this.loading.add(e),!0)}endLoading(e){this.loading.delete(e)}isLoading(e){return this.loading.has(e)}makePackageKey(e,t){return t?`${e}@${t}`:e}clear(){this.packages.clear(),this.loading.clear()}};var Tr=class{static validatePattern(e){let t=[];(e.includes("ancestor::")||e.includes("ancestor-or-self::"))&&t.push("Ancestor axes are not permitted in streamable patterns"),e.includes("parent::")&&t.push("Parent axis is not permitted in streamable patterns"),(e.includes("preceding::")||e.includes("preceding-sibling::"))&&t.push("Preceding axes are not permitted in streamable patterns");let n=e.match(/\[.*\]/g);if(n)for(let r of n)r.includes("[")&&r.includes("]")&&r.includes("[[")&&t.push("Nested predicates are not permitted in streamable patterns");return{isStreamable:t.length===0,issues:t}}static toStreamablePath(e){let t=e.split("/").filter(n=>n.length>0);return t.length===0?null:{path:t.map(n=>n.split("[")[0]),fromRoot:e.startsWith("/"),hasPredicates:e.includes("["),hasForwardAxis:e.includes("::"),isDeterministic:!0}}};var Xr=class{constructor(){this.elementStack=[];this.depth=0;this.activeCopies=new Map;this.mergeSources=[];this.isStreaming=!1;this.lookaheadBuffer=[]}startStreaming(){this.elementStack=[],this.depth=0,this.activeCopies.clear(),this.isStreaming=!0}endStreaming(){this.isStreaming=!1,this.activeCopies.clear(),this.lookaheadBuffer=[]}registerCopy(e){this.activeCopies.set(e.id,e)}unregisterCopy(e){this.activeCopies.delete(e)}getActiveCopies(){return Array.from(this.activeCopies.values()).filter(e=>e.isActive)}enterElement(e){this.elementStack.push(e),this.depth++}exitElement(){return this.depth--,this.elementStack.pop()}getCurrentPath(){return[...this.elementStack]}getDepth(){return this.depth}isStreamingActive(){return this.isStreaming}bufferEvent(e){this.lookaheadBuffer.push(e)}getBufferedEvents(){return this.lookaheadBuffer}clearBuffer(){this.lookaheadBuffer=[]}};var Sr=class{constructor(){this.copies=new Map;this.copyIdCounter=0}createCopy(e){let t=`copy-${++this.copyIdCounter}`,n={id:t,handler:e,isActive:!0,eventQueue:[],currentDepth:0};return this.copies.set(t,n),n}distributeEvent(e){return b(this,null,function*(){for(let t of Array.from(this.copies.values()))t.isActive&&t.eventQueue.push(e)})}closeCopy(e){let t=this.copies.get(e);t&&(t.isActive=!1)}getCopy(e){return this.copies.get(e)}clear(){this.copies.clear(),this.copyIdCounter=0}};var Cr=class{constructor(){this.sources=[]}addSource(e){this.sources.push(e)}getNextMergeGroup(){if(this.sources.every(r=>r.isExhausted))return[];let e=null,t=null;for(let r of this.sources)!r.isExhausted&&r.buffer.length>0&&e===null&&(e=r,t=r.buffer[0]);if(e===null)return[];let n=[];for(;e.buffer.length>0&&n.length<1;)n.push(e.buffer.shift());return n}isComplete(){return this.sources.every(e=>e.isExhausted&&e.buffer.length===0)}clear(){this.sources=[]}};var wr=class{static detectMode(e){var n;let t=(n=e.getAttributeValue)==null?void 0:n.call(e,"streamable");return t==="yes"?"streamed":"non-consuming"}static isTemplateBodyStreamable(e){let t=["xsl:variable","xsl:result-document","xsl:for-each"];return!0}};var Ar=class{parse(e,t){return b(this,null,function*(){let r=new Ue().xmlParse(e);yield t({type:"document-start",depth:0});for(let i of r.childNodes)yield this.emitNode(i,t,0);yield t({type:"document-end",depth:0})})}canStream(e){return b(this,null,function*(){return!0})}emitNode(e,t,n){return b(this,null,function*(){var r,i,o,a,c;switch(e.nodeType){case 9:{for(let u of e.childNodes)yield this.emitNode(u,t,n);return}case 1:{let u=e.childNodes.filter(h=>h.nodeType===2),l=u.length>0?new Map:void 0;if(l)for(let h of u)l.set(h.nodeName,`${(r=h.nodeValue)!=null?r:""}`),yield t({type:"attribute",name:h.nodeName,namespaceUri:h.namespaceUri||void 0,content:`${(i=h.nodeValue)!=null?i:""}`,depth:n+1});let p=e.childNodes.filter(h=>h.nodeType!==2);yield t({type:"start-element",name:e.nodeName,namespaceUri:e.namespaceUri||void 0,attributes:l,selfClosing:p.length===0,depth:n+1});for(let h of p)yield this.emitNode(h,t,n+1);yield t({type:"end-element",name:e.nodeName,namespaceUri:e.namespaceUri||void 0,depth:n+1});return}case 3:case 4:{let u=`${(o=e.nodeValue)!=null?o:""}`;u.length>0&&(yield t({type:"text",content:u,depth:n+1}));return}case 8:{yield t({type:"comment",content:`${(a=e.nodeValue)!=null?a:""}`,depth:n+1});return}case 7:{yield t({type:"processing-instruction",name:e.nodeName,content:`${(c=e.nodeValue)!=null?c:""}`,depth:n+1});return}default:return}})}};var Or=class{constructor(e){this.context=new Xr;this.copyManager=new Sr;this.mergeCoordinator=new Cr;this.enabled=!1;this.parser=new Ar;this.xPath=e.xPath,this.version=e.version}setVersion(e){this.version=e}isEnabled(){return this.enabled}getContext(){return this.context}getCopyManager(){return this.copyManager}getMergeCoordinator(){return this.mergeCoordinator}setParser(e){this.parser=e}validatePattern(e){return Tr.validatePattern(e)}detectMode(e){return wr.detectMode(e)}processStream(e,t,n,r){return b(this,null,function*(){if(!this.version||parseFloat(this.version)<3)throw new Error("<xsl:stream> is only supported in XSLT 3.0 or later.");let i=f(t,"select");if(!i)throw new Error('<xsl:stream> requires a "select" attribute specifying the input document.');let o=this.enabled;this.enabled=!0,this.context.startStreaming();try{let a=e.clone(),c=this.xPath.xPathEval(i,a),u=[];c.type==="node-set"?u=c.nodeSetValue():c.type==="node"&&(u=[c]);for(let l of u)yield r.processChildren(e,t,n)}finally{this.enabled=o,this.context.endStreaming(),this.copyManager.clear()}})}processFork(e,t,n,r){return b(this,null,function*(){if(!this.enabled)throw new Error("<xsl:fork> can only be used within <xsl:stream>.");for(let i of t.childNodes)if(r.isXsltElement(i,"fork-sequence")){let o=this.copyManager.createCopy(a=>b(this,null,function*(){yield r.processChildren(e,i,n)}));this.context.registerCopy(o)}})}processMerge(e,t,n,r){return b(this,null,function*(){if(!this.version||parseFloat(this.version)<3)throw new Error("<xsl:merge> is only supported in XSLT 3.0 or later.");let i=[];for(let o of t.childNodes)if(r.isXsltElement(o,"merge-source")){let a=f(o,"select");if(!a)throw new Error('<xsl:merge-source> requires a "select" attribute.');let c={select:a,mergeKeys:[],position:0,isExhausted:!1,buffer:[]};for(let p of o.childNodes)if(r.isXsltElement(p,"merge-key")){let h=f(p,"select"),m=f(p,"order")||"ascending";c.mergeKeys.push({select:h||".",order:m})}let u=this.xPath.xPathEval(a,e),l=u.nodeSetValue?u.nodeSetValue():[];c.buffer=Array.isArray(l)?l.slice():l?[l]:[],c.isExhausted=c.buffer.length===0,i.push(c)}if(i.length===0)throw new Error("<xsl:merge> requires at least one <xsl:merge-source> child element.");for(let o of i)this.mergeCoordinator.addSource(o);try{if(i.some(a=>a.buffer.length>0))for(let a of i){for(;a.buffer.length>0;){let c=a.buffer.shift(),u=e.clone([c],0);for(let l of t.childNodes)r.isXsltElement(l,"merge-action")&&(yield r.processChildren(u,l,n))}a.isExhausted=!0}}finally{this.mergeCoordinator.clear()}})}reset(){this.enabled=!1,this.context.endStreaming(),this.copyManager.clear(),this.mergeCoordinator.clear()}};function Au(s){let e=s.nodeTest;if(s.predicate&&s.predicate.length>0||s.predicates&&s.predicates.length>0)return .5;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case"wildcard":return e.name&&e.name.endsWith(":*")?-.25:-.5;case"node-type":return e.nodeType==="processing-instruction"&&e.name?0:-.5;case"processing-instruction":return e.target||e.name?0:-.5;case"name":return 0;default:return 0}return e instanceof Vn||e instanceof $n||e instanceof qn||e instanceof Fn?-.5:e instanceof Wn?e.target?0:-.5:e instanceof Un?-.25:(e instanceof Ln,0)}function Ou(s){if(!s.steps||s.steps.length===0)return s.absolute?-.5:0;if(s.steps.length>1)return .5;let e=s.steps[0],t=e.axis;return t&&t!=="child"&&t!=="attribute"&&t!=="self-and-siblings"?.5:Au(e)}function vu(s,e){let t=s.getAttributeValue("mode");return e?e==="#all"||t==="#all"?!0:t===e:!t||t==="#default"}function Ru(s){return s.nodeType!==1?!1:(s.namespaceUri==="http://www.w3.org/1999/XSL/Transform"||s.prefix==="xsl")&&s.localName==="template"}function Iu(s,e){try{let t=e.xPathParse(s);return t instanceof Re?Ou(t):.5}catch(t){return 0}}function vr(s,e,t,n){var o;let r=[],i=0;for(let a of s.childNodes){if(!Ru(a)||!vu(a,e))continue;let c=a.getAttributeValue("match");if(!c)continue;let u=a.getAttributeValue("priority"),l=u?parseFloat(u):null,p=n==null?void 0:n.get(a),h=0;if(p){let d=Number.MAX_SAFE_INTEGER/2,y=-p.importDepth*d,E=(o=p.order)!=null?o:0;h=y+E}let m=Ka(c);for(let d of m){let y=Iu(d,t),E=l!==null&&!isNaN(l)?l:y;r.push({template:a,explicitPriority:l!==null&&!isNaN(l)?l:null,defaultPriority:y,effectivePriority:E,importPrecedence:h,documentOrder:i++,matchPattern:d})}}return r}function Ka(s){let e=[],t="",n=0,r=!1,i=!1;for(let o=0;o<s.length;o++){let a=s[o];a==="'"&&!i?(r=!r,t+=a):a==='"'&&!r?(i=!i,t+=a):!r&&!i?a==="["||a==="("?(n++,t+=a):a==="]"||a===")"?(n--,t+=a):a==="|"&&n===0?(e.push(t.trim()),t=""):t+=a:t+=a}return t.trim()&&e.push(t.trim()),e}function _u(s,e,t,n,r){if(e==="/")return s.nodeName==="#document";if(e.startsWith("@")){if(s.nodeType!==2)return!1;let i=e.substring(1);if(i==="*")return!0;let o=s.localName||s.nodeName,a=i.includes(":")?i.substring(i.indexOf(":")+1):i;return o===a||s.nodeName===i}if(e==="*"&&s.nodeType===1||!e.includes("/")&&!e.includes("[")&&!e.startsWith("@")&&(e===s.nodeName||e===s.localName))return!0;if(e.includes("/")||e.includes("["))try{let i=e.startsWith("/")?e:"//"+e,o=t.clone([t.root],0);if(r.xPathEval(i,o).nodeSetValue().some(u=>u.id===s.id))return!0}catch(i){}if(!e.includes("/")&&!e.includes("[")&&!e.startsWith("@"))try{let i=t.clone([s],0),o=r.xPathParse(e,"self-and-siblings");if(n.expressionMatch(o,i).some(c=>c.id===s.id))return!0}catch(i){}return!1}function yi(s,e,t,n,r){let i=Ka(e);for(let o of i)if(_u(s,o,t,n,r))return!0;return!1}function Be(s,e,t,n,r){let i=r!=null?r:console.warn,o=[],a=e.nodeList[e.position];for(let l of s)try{yi(a,l.matchPattern,e,t,n)&&o.push(l)}catch(p){i(`Failed to match pattern "${l.matchPattern}":`,p)}if(o.length===0)return{selectedTemplate:null,hasConflict:!1,conflictingTemplates:[]};o.sort((l,p)=>l.importPrecedence!==p.importPrecedence?p.importPrecedence-l.importPrecedence:l.effectivePriority!==p.effectivePriority?p.effectivePriority-l.effectivePriority:p.documentOrder-l.documentOrder);let c=o[0],u=o.filter(l=>l.importPrecedence===c.importPrecedence&&l.effectivePriority===c.effectivePriority);return{selectedTemplate:c.template,hasConflict:u.length>1,conflictingTemplates:u.length>1?u:[],originalComponent:c.originalComponent}}function Ha(s,e,t){if(!s.hasConflict||s.conflictingTemplates.length<2)return;let n=s.conflictingTemplates.map(i=>`"${i.matchPattern}" (priority: ${i.effectivePriority})`).join(", ");(t!=null?t:console.warn)(`XSLT Warning: Ambiguous template match for node <${e.nodeName}>. Multiple templates match with equal priority: ${n}. Using the last one in document order.`)}var Rr=class{constructor(){this.accumulators=new Map;this.accumulatorStates=new Map}registerAccumulator(e){this.accumulators.set(e.name,e),this.accumulatorStates.set(e.name,{currentValue:null,valueStack:[]})}getAccumulator(e){return this.accumulators.get(e)}getAllAccumulators(){return Array.from(this.accumulators.values())}getAccumulatorState(e){return this.accumulatorStates.get(e)}setAccumulatorState(e,t){this.accumulatorStates.set(e,t)}clear(){this.accumulators.clear(),this.accumulatorStates.clear()}};var Ir=class{constructor(e={cData:!0,escape:!0,selfClosingTags:!0,parameters:[]}){this.styleSheetStack=[];this.importedStylesheets=new Map;this.templateSourceMap=new Map;this.currentTemplateStack=[];this.packageRegistry=new Pr;this.currentPackage=null;this.currentOverrideContext=null;this.accumulatorRegistry=new Rr;this.xPath=new tt,this.xmlParser=new Ue,this.matchResolver=new Dn,this.options={cData:e.cData===!0,escape:e.escape===!0,selfClosingTags:e.selfClosingTags===!0,outputMethod:e.outputMethod,parameters:e.parameters||[]},this.outputMethod=e.outputMethod||"xml",this.outputOmitXmlDeclaration="no",this.outputVersion="",this.itemSeparator="",this.stripSpacePatterns=[],this.preserveSpacePatterns=[],this.namespaceAliases=new Map,this.supportedExtensions=new Set(["http://www.w3.org/1999/XSL/Transform"]),this.attributeSets=new Map,this.userDefinedFunctions=new Map,this.resultDocuments=new Map,this.decimalFormatSettings={decimalSeparator:".",groupingSeparator:",",infinity:"Infinity",minusSign:"-",naN:"NaN",percent:"%",perMille:"\u2030",zeroDigit:"0",digit:"#",patternSeparator:";"},this.firstTemplateRan=!1,this.forwardsCompatible=!1,this.warningsCallback=console.warn.bind(console),this.fetchFunction=e.fetchFunction||(t=>b(this,null,function*(){let n=typeof globalThis!="undefined"&&typeof globalThis.fetch=="function"?globalThis.fetch:null;if(!n)throw new Error("No global fetch implementation available. Please provide options.fetchFunction or use a runtime that exposes globalThis.fetch.");return(yield n(t)).text()})),this.streamingProcessor=new Or({xPath:this.xPath,version:""})}xsltProcess(e,t){return b(this,null,function*(){let n=yield this.xsltProcessToDocument(e,t);if(this.outputMethod==="json")return ka(n);let r=this.outputMethod;this.outputMethod==="adaptive"&&(r=Ma(n));let i=r;return r==="html"&&this.outputVersion==="5.0"&&(i="html"),Mn(n,{cData:this.options.cData,escape:this.options.escape,selfClosingTags:this.options.selfClosingTags,outputMethod:i,outputVersion:this.outputVersion,itemSeparator:this.itemSeparator})})}xsltProcessToDocument(e,t){return b(this,null,function*(){let n=new ue;this.outputDocument=n;let r=new qe([e]);if(r.warningsCallback=this.warningsCallback,this.options.parameters.length>0)for(let i of this.options.parameters)r.setVariable(i.name,this.toNodeValue(i.value));return yield this.xsltProcessContext(r,t,this.outputDocument),n})}xsltProcessContext(e,t,n){return b(this,null,function*(){if(e.warningsCallback||(e.warningsCallback=this.warningsCallback),!this.isXsltElement(t))t.nodeType===1&&!this.isExtensionElementSupported(t)?yield this.xsltExtensionElement(e,t,n):yield this.xsltPassThrough(e,t,n);else{let r,i,o,a;switch(t.localName){case"apply-imports":yield this.xsltApplyImports(e,t,n);break;case"apply-templates":yield this.xsltApplyTemplates(e,t,n);break;case"analyze-string":yield this.xsltAnalyzeString(e,t,n);break;case"attribute":yield this.xsltAttribute(e,t,n);break;case"attribute-set":break;case"call-template":yield this.xsltCallTemplate(e,t,n);break;case"choose":yield this.xsltChoose(e,t,n);break;case"comment":yield this.xsltComment(e,t,n);break;case"copy":r=this.xsltCopy(n||this.outputDocument,e.nodeList[e.position]),r&&(yield this.xsltChildNodes(e,t,r));break;case"copy-of":i=f(t,"select"),o=this.xPath.xPathEval(i,e);let c=n||this.outputDocument;if(o.type==="node-set"){a=o.nodeSetValue();for(let p=0;p<a.length;++p)this.xsltCopyOf(c,a[p])}else{let p=ae(this.outputDocument,o.stringValue());p.siblingPosition=c.childNodes.length,V(c,p)}break;case"accumulator":this.xsltAccumulator(e,t);break;case"accumulator-rule":throw new Error("<xsl:accumulator-rule> must be a child of <xsl:accumulator>.");case"decimal-format":this.xsltDecimalFormat(e,t);break;case"evaluate":yield this.xsltEvaluate(e,t,n);break;case"element":yield this.xsltElement(e,t,n);break;case"fallback":let u=t.parentNode;if(!(u&&u.nodeType===1&&!this.isExtensionElementSupported(u)))throw new Error("<xsl:fallback> must be a direct child of an extension element");yield this.xsltChildNodes(e,t,n);break;case"for-each":yield this.xsltForEach(e,t,n);break;case"for-each-group":yield this.xsltForEachGroup(e,t,n);break;case"function":this.xsltFunction(e,t);break;case"iterate":yield this.xsltIterate(e,t,n);break;case"try":yield this.xsltTry(e,t,n);break;case"if":yield this.xsltIf(e,t,n);break;case"import":yield this.xsltImport(e,t,n);break;case"include":yield this.xsltInclude(e,t,n);break;case"key":this.xsltKey(e,t);break;case"matching-substring":throw new Error("<xsl:matching-substring> must be a child of <xsl:analyze-string>.");case"message":yield this.xsltMessage(e,t);break;case"namespace":yield this.xsltNamespace(e,t,n);break;case"namespace-alias":this.xsltNamespaceAlias(t);break;case"non-matching-substring":throw new Error("<xsl:non-matching-substring> must be a child of <xsl:analyze-string>.");case"on-empty":throw new Error("<xsl:on-empty> must be a child of a sequence-generating instruction like <xsl:for-each>, <xsl:for-each-group>, or <xsl:apply-templates>.");case"on-non-empty":throw new Error("<xsl:on-non-empty> must be a child of a sequence-generating instruction like <xsl:for-each>, <xsl:for-each-group>, or <xsl:apply-templates>.");case"number":this.xsltNumber(e,t,n);break;case"otherwise":throw new Error("<xsl:otherwise> must be a child of <xsl:choose>.");case"output":this.outputMethod=f(t,"method"),this.outputOmitXmlDeclaration=f(t,"omit-xml-declaration"),this.outputVersion=f(t,"version")||"",this.itemSeparator=f(t,"item-separator")||"";break;case"package":yield this.xsltPackage(e,t,n);break;case"use-package":yield this.xsltUsePackage(e,t,n);break;case"expose":this.xsltExpose(e,t);break;case"accept":this.xsltAccept(e,t);break;case"override":yield this.xsltOverride(e,t,n);break;case"original":yield this.xsltOriginal(e,t,n);break;case"param":yield this.xsltVariable(e,t,!1);break;case"preserve-space":this.xsltPreserveSpace(t);break;case"perform-sort":yield this.xsltPerformSort(e,t,n);break;case"processing-instruction":yield this.xsltProcessingInstruction(e,t,n);break;case"result-document":yield this.xsltResultDocument(e,t);break;case"sequence":yield this.xsltSequence(e,t,n);break;case"sort":this.xsltSort(e,t);break;case"strip-space":this.xsltStripSpace(t);break;case"stylesheet":case"transform":yield this.xsltTransformOrStylesheet(e,t,n);break;case"stream":yield this.xsltStream(e,t,n);break;case"fork":yield this.xsltFork(e,t,n);break;case"merge":yield this.xsltMerge(e,t,n);break;case"mode":this.currentPackage&&this.xsltMode(e,t);break;case"template":yield this.xsltTemplate(e,t,n);break;case"text":this.xsltText(e,t,n);break;case"value-of":this.xsltValueOf(e,t,n);break;case"variable":yield this.xsltVariable(e,t,!0);break;case"when":throw new Error("<xsl:when> must be a child of <xsl:choose>.");case"with-param":throw new Error("<xsl:with-param> must be a child of <xsl:call-template> or <xsl:apply-templates>.");default:yield this.xsltUnknownInstruction(e,t,n)}}})}xsltUnknownInstruction(e,t,n){return b(this,null,function*(){let r=`xsl:${t.localName}`;if(this.forwardsCompatible){let i=this.getFallbackElement(t);i&&(yield this.xsltChildNodes(e,i,n));return}throw new Error(`Unknown XSLT instruction: <${r}>. This element is not supported in XSLT 1.0. If this is a future XSLT version feature, use version="2.0" or higher to enable forwards-compatible processing mode.`)})}xsltApplyTemplates(e,t,n){return b(this,null,function*(){var d,y,E;let r=f(t,"select"),i=[];r?i=this.xPath.xPathEval(r,e).nodeSetValue():i=e.nodeList[e.position].childNodes;let o=this.findConditionalChild(t,"on-empty"),a=this.findConditionalChild(t,"on-non-empty");if(i.length===0){o&&(yield this.xsltChildNodes(e.clone(),o,n));return}if(a){yield this.xsltChildNodes(e.clone(),a,n);return}let u=f(t,"mode")||null,l=t.ownerDocument.documentElement,p=vr(l,u,this.xPath,this.templateSourceMap);p=p.concat(this.collectAcceptedTemplates(u));let h=e.clone();yield this.xsltWithParam(h,t);let m=h.clone(i);for(let T=0;T<m.contextSize();++T){let P=m.nodeList[T];if(P.nodeType===3){if(!this.xsltPassText(P))continue;let A=h.clone([P],0);A.inApplyTemplates=!0;let w=Be(p,A,this.matchResolver,this.xPath,this.warningsCallback);if(w.selectedTemplate){let F=this.templateSourceMap.get(w.selectedTemplate),j=f(w.selectedTemplate,"match"),Y=f(w.selectedTemplate,"mode");this.currentTemplateStack.push({template:w.selectedTemplate,stylesheetDepth:(d=F==null?void 0:F.importDepth)!=null?d:0,mode:Y||u,match:j});let ee=this.currentOverrideContext,q=w.originalComponent||w.selectedTemplate.__originalComponent;q&&(this.currentOverrideContext=q);try{yield this.xsltChildNodes(A,w.selectedTemplate,n)}finally{this.currentTemplateStack.pop(),this.currentOverrideContext=ee}}else{let F=e.clone([P],0);this.commonLogicTextNode(F,P,n)}}else{let A=m.clone([P],0);A.inApplyTemplates=!0;let w=Be(p,A,this.matchResolver,this.xPath,this.warningsCallback);if(w.hasConflict&&Ha(w,P,this.warningsCallback),w.selectedTemplate){let F=this.templateSourceMap.get(w.selectedTemplate),j=f(w.selectedTemplate,"match"),Y=f(w.selectedTemplate,"mode");this.currentTemplateStack.push({template:w.selectedTemplate,stylesheetDepth:(y=F==null?void 0:F.importDepth)!=null?y:0,mode:Y||u,match:j});let ee=this.currentOverrideContext,q=w.originalComponent||w.selectedTemplate.__originalComponent;q&&(this.currentOverrideContext=q);try{yield this.xsltChildNodes(A,w.selectedTemplate,n)}finally{this.currentTemplateStack.pop(),this.currentOverrideContext=ee}}else if(P.nodeType===1&&P.childNodes&&P.childNodes.length>0){let F=P.childNodes.filter(j=>j.nodeType!==2);for(let j=0;j<F.length;++j){let Y=F[j];if(Y.nodeType===3){let ee=h.clone([Y],0);ee.inApplyTemplates=!0;let q=Be(p,ee,this.matchResolver,this.xPath,this.warningsCallback);q.selectedTemplate?yield this.xsltChildNodes(ee,q.selectedTemplate,n):this.commonLogicTextNode(ee,Y,n)}else{let ee=h.clone([Y],0);ee.inApplyTemplates=!0;let q=Be(p,ee,this.matchResolver,this.xPath,this.warningsCallback);if(q.selectedTemplate){let L=this.templateSourceMap.get(q.selectedTemplate),Bn=f(q.selectedTemplate,"match"),Ja=f(q.selectedTemplate,"mode");this.currentTemplateStack.push({template:q.selectedTemplate,stylesheetDepth:(E=L==null?void 0:L.importDepth)!=null?E:0,mode:Ja||u,match:Bn});try{yield this.xsltChildNodes(ee,q.selectedTemplate,n)}finally{this.currentTemplateStack.pop()}}else Y.nodeType===1&&(yield this.applyBuiltInTemplate(Y,p,u,h,n))}}}else P.nodeType===3&&this.commonLogicTextNode(A,P,n)}}})}applyBuiltInTemplate(e,t,n,r,i){return b(this,null,function*(){var a;if(!e.childNodes||e.childNodes.length===0)return;let o=e.childNodes.filter(c=>c.nodeType!==2&&c.nodeName!=="#dtd-section");for(let c of o)if(c.nodeType===3){let u=r.clone([c],0);u.inApplyTemplates=!0;let l=Be(t,u,this.matchResolver,this.xPath,this.warningsCallback);if(l.selectedTemplate){let p=this.currentOverrideContext,h=l.originalComponent||l.selectedTemplate.__originalComponent;h&&(this.currentOverrideContext=h);try{yield this.xsltChildNodes(u,l.selectedTemplate,i)}finally{this.currentOverrideContext=p}}else this.commonLogicTextNode(u,c,i)}else{let u=r.clone([c],0);u.inApplyTemplates=!0;let l=Be(t,u,this.matchResolver,this.xPath,this.warningsCallback);if(l.selectedTemplate){let p=this.templateSourceMap.get(l.selectedTemplate),h=f(l.selectedTemplate,"match"),m=f(l.selectedTemplate,"mode");this.currentTemplateStack.push({template:l.selectedTemplate,stylesheetDepth:(a=p==null?void 0:p.importDepth)!=null?a:0,mode:m||n,match:h});let d=this.currentOverrideContext,y=l.originalComponent||l.selectedTemplate.__originalComponent;y&&(this.currentOverrideContext=y);try{yield this.xsltChildNodes(u,l.selectedTemplate,i)}finally{this.currentTemplateStack.pop(),this.currentOverrideContext=d}}else c.nodeType===1&&(yield this.applyBuiltInTemplate(c,t,n,r,i))}})}xsltApplyImports(e,t,n){return b(this,null,function*(){if(this.currentTemplateStack.length===0)throw new Error("<xsl:apply-imports> can only be used within a template");let r=this.currentTemplateStack[this.currentTemplateStack.length-1],{stylesheetDepth:i,mode:o}=r,a=e.nodeList[e.position],c=t.ownerDocument.documentElement,u=[];c&&u.push(c),this.importedStylesheets.forEach(T=>{if(T)if(T.nodeType===9){let P=T.childNodes.find(A=>A.nodeType===1);P&&u.push(P)}else T.nodeType===1&&u.push(T)});let l=[],p=0;for(let T of u){let P=vr(T,o,this.xPath,this.templateSourceMap);for(let A of P)A.documentOrder+=p;p+=P.length,l=l.concat(P)}let h=l.filter(T=>{let P=this.templateSourceMap.get(T.template);return P&&P.importDepth>i});if(h.length===0)return;let m=e.clone([a],0),d=Be(h,m,this.matchResolver,this.xPath,this.warningsCallback);if(!d.selectedTemplate)return;let y=e.clone();yield this.xsltWithParam(y,t);let E=this.templateSourceMap.get(d.selectedTemplate);if(E){let T=f(d.selectedTemplate,"match"),P=f(d.selectedTemplate,"mode");this.currentTemplateStack.push({template:d.selectedTemplate,stylesheetDepth:E.importDepth,mode:P||o,match:T});let A=this.currentOverrideContext,w=d.originalComponent||d.selectedTemplate.__originalComponent;w&&(this.currentOverrideContext=w);try{yield this.xsltChildNodes(y,d.selectedTemplate,n)}finally{this.currentTemplateStack.pop(),this.currentOverrideContext=A}}})}xsltAttribute(e,t,n){return b(this,null,function*(){let r=f(t,"name"),i=this.xsltAttributeValue(r,e),o=Oe(this.outputDocument);yield this.xsltChildNodes(e,t,o);let a=di(o);if(n&&(W(n,i,a),i.includes(":"))){let c=i.split(":")[0];if(c!=="xmlns"){let l=f(t,"namespace")||this.resolveNamespaceUriForPrefix(t,c);if(l){let p=`xmlns:${c}`;this.isNamespaceDeclaredOnAncestor(n,p,l)||W(n,p,l)}}}})}xsltCallTemplate(e,t,n){return b(this,null,function*(){let r=f(t,"name"),i=t.ownerDocument.documentElement,o=e.clone();yield this.xsltWithParam(o,t);let a=null;if(this.currentPackage&&this.currentPackage.usedPackages.forEach(c=>{c.acceptedComponents.forEach(u=>{u.type==="template"&&u.name===r&&u.isAccepted&&(a=this.getEffectiveComponent(u).node)})}),a){yield this.xsltChildNodes(o,a,n);return}for(let c=0;c<i.childNodes.length;++c){let u=i.childNodes[c];if(u.nodeType===1&&this.isXsltElement(u,"template")&&Ze(u,"name")===r){yield this.xsltChildNodes(o,u,n);break}}})}xsltChoose(e,t,n){return b(this,null,function*(){for(let r of t.childNodes)if(r.nodeType===1){if(this.isXsltElement(r,"when")){let i=f(r,"test");if(this.xPath.xPathEval(i,e).booleanValue()){yield this.xsltChildNodes(e,r,n);break}}else if(this.isXsltElement(r,"otherwise")){yield this.xsltChildNodes(e,r,n);break}}})}xsltCopy(e,t){if(t.nodeType==1){let n=et(this.outputDocument,t.nodeName);if(t.namespaceUri!==null&&t.namespaceUri!==void 0){let r=t.prefix||(t.nodeName.includes(":")?t.nodeName.split(":")[0]:null),i=r?`xmlns:${r}`:"xmlns";this.isNamespaceDeclaredOnAncestor(e,i,t.namespaceUri)||W(n,i,t.namespaceUri)}return n.siblingPosition=e.childNodes.length,V(e,n),n}if(t.nodeType==3){if(this.shouldStripWhitespaceNode(t))return null;let n=ae(this.outputDocument,t.nodeValue);n.siblingPosition=e.childNodes.length,V(e,n)}else if(t.nodeType==4){let n=mr(this.outputDocument,t.nodeValue);n.siblingPosition=e.childNodes.length,V(e,n)}else if(t.nodeType==8){let n=Tt(this.outputDocument,t.nodeValue);n.siblingPosition=e.childNodes.length,V(e,n)}else if(t.nodeType==2&&(W(e,t.nodeName,t.nodeValue),t.prefix&&t.namespaceUri&&t.prefix!=="xmlns"&&!t.nodeName.startsWith("xmlns"))){let n=`xmlns:${t.prefix}`;this.isNamespaceDeclaredOnAncestor(e,n,t.namespaceUri)||W(e,n,t.namespaceUri)}return null}xsltComment(e,t,n){return b(this,null,function*(){let r=Oe(this.outputDocument);yield this.xsltChildNodes(e,t,r);let i=me(r),o=Tt(this.outputDocument,i);(n||this.outputDocument).appendChild(o)})}xsltProcessingInstruction(e,t,n){return b(this,null,function*(){let r=f(t,"name");if(!r)throw new Error('<xsl:processing-instruction> requires a "name" attribute');let i=this.xsltAttributeValue(r,e);if(!i)throw new Error("<xsl:processing-instruction> target name cannot be empty");if(i.toLowerCase()==="xml")throw new Error('Processing instruction target cannot be "xml"');if(!/^[a-zA-Z_][a-zA-Z0-9_:.-]*$/.test(i))throw new Error(`Invalid processing instruction target: "${i}"`);let o=Oe(this.outputDocument);yield this.xsltChildNodes(e,t,o);let a=me(o),c=_a(this.outputDocument,i,a),u=n||this.outputDocument;V(u,c)})}xsltCopyOf(e,t){if(t.nodeType==11||t.nodeType==9)for(let n=0;n<t.childNodes.length;++n)this.xsltCopyOf(e,t.childNodes[n]);else{let n=this.xsltCopy(e,t);if(n)for(let r=0;r<t.childNodes.length;++r)this.xsltCopyOf(n,t.childNodes[r])}}xsltDecimalFormat(e,t){let n=f(t,"name"),r=f(t,"decimal-separator"),i=f(t,"grouping-separator"),o=f(t,"infinity"),a=f(t,"minus-sign"),c=f(t,"NaN"),u=f(t,"percent"),l=f(t,"per-mille"),p=f(t,"zero-digit"),h=f(t,"digit"),m=f(t,"pattern-separator");this.decimalFormatSettings={name:n||this.decimalFormatSettings.name,decimalSeparator:r||this.decimalFormatSettings.decimalSeparator,groupingSeparator:i||this.decimalFormatSettings.groupingSeparator,infinity:o||this.decimalFormatSettings.infinity,minusSign:a||this.decimalFormatSettings.minusSign,naN:c||this.decimalFormatSettings.naN,percent:u||this.decimalFormatSettings.percent,perMille:l||this.decimalFormatSettings.perMille,zeroDigit:p||this.decimalFormatSettings.zeroDigit,digit:h||this.decimalFormatSettings.digit,patternSeparator:m||this.decimalFormatSettings.patternSeparator},e.decimalFormatSettings=this.decimalFormatSettings}xsltElement(e,t,n){return b(this,null,function*(){let r=f(t,"name"),i=this.xsltAttributeValue(r,e),o=et(this.outputDocument,i),a=f(t,"use-attribute-sets");a&&(yield this.applyAttributeSets(e,o,a)),o.siblingPosition=(n||this.outputDocument).childNodes.length,V(n||this.outputDocument,o);let c=e.clone();yield this.xsltChildNodes(c,t,o)})}xsltAccumulator(e,t){let n=f(t,"name");if(!n)throw new Error('<xsl:accumulator> requires a "name" attribute');let r=f(t,"initial-value")||"()",i=f(t,"as")||"xs:anyAtomicType*",o=f(t,"streamable")||"no",a=o==="yes"||o==="true"||o==="1",c=[];for(let l=0;l<t.childNodes.length;l++){let p=t.childNodes[l];if(p.nodeType===1&&p.nodeName==="accumulator-rule"){let h=f(p,"match");if(!h)throw new Error('<xsl:accumulator-rule> requires a "match" attribute');let m=f(p,"select");if(!m)throw new Error('<xsl:accumulator-rule> requires a "select" attribute');let d=f(p,"phase");c.push({match:h,select:m,phase:d==="start"||d==="end"?d:void 0})}}let u={name:n,initialValue:r,as:i,rules:c,streamable:a};this.accumulatorRegistry.registerAccumulator(u);try{let l=this.xPath.xPathEval(r,e),p={currentValue:l,valueStack:[l]};this.accumulatorRegistry.setAccumulatorState(n,p)}catch(l){let p={currentValue:null,valueStack:[null]};this.accumulatorRegistry.setAccumulatorState(n,p)}}evaluateAccumulatorRules(e,t){let n=this.accumulatorRegistry.getAllAccumulators();for(let r of n){let i=this.accumulatorRegistry.getAccumulatorState(r.name);if(i)for(let o of r.rules)try{let a=e.clone([t],0),c=this.xsltMatch(o.match,a);if(c&&c.length>0){let l=e.clone([t],0);l.setVariable("value",new G(i.currentValue?String(i.currentValue):""));let p=this.xPath.xPathEval(o.select,l);i.currentValue=p}}catch(a){this.warningsCallback&&this.warningsCallback(`Error evaluating accumulator rule for ${r.name}: ${a}`)}}}getAccumulatorValue(e){let t=this.accumulatorRegistry.getAccumulatorState(e);return t?t.currentValue:null}xsltForEach(e,t,n){return b(this,null,function*(){let r=f(t,"select"),i=this.xPath.xPathEval(r,e).nodeSetValue(),o=this.findConditionalChild(t,"on-empty"),a=this.findConditionalChild(t,"on-non-empty");if(i.length===0){o&&(yield this.xsltChildNodes(e.clone(),o,n));return}if(a){yield this.xsltChildNodes(e.clone(),a,n);return}let c=e.clone(i);if(this.xsltSort(c,t),c.nodeList.filter(l=>l.parentNode!==null&&l.parentNode!==void 0).length<=0)throw new Error("Nodes with no parents defined.");for(let l=0;l<c.contextSize();++l)yield this.xsltChildNodesExcludingConditional(c.clone(c.nodeList,l),t,n)})}xsltForEachGroup(e,t,n){return b(this,null,function*(){let r=f(t,"select"),i=f(t,"group-by"),o=f(t,"group-adjacent"),a=f(t,"group-starting-with"),c=f(t,"group-ending-with"),u=this.findConditionalChild(t,"on-empty"),l=this.findConditionalChild(t,"on-non-empty");if(!r)throw new Error("<xsl:for-each-group> requires a select attribute.");let p=[i,o,a,c].filter(d=>d);if(p.length===0)throw new Error("<xsl:for-each-group> requires one of: group-by, group-adjacent, group-starting-with, or group-ending-with.");if(p.length>1)throw new Error("<xsl:for-each-group> can only have one grouping method.");let h=this.xPath.xPathEval(r,e).nodeSetValue();if(h.length===0){u&&(yield this.xsltChildNodes(e.clone(),u,n));return}let m;if(i)m=this.groupByKey(h,i,e);else if(o)m=this.groupAdjacent(h,o,e);else if(a)m=this.groupStartingWith(h,a,e);else if(c)m=this.groupEndingWith(h,c,e);else return;if(l){yield this.xsltChildNodes(e.clone(),l,n);return}for(let d=0;d<m.length;d++){let y=m[d],E=e.clone(y.items,0);E.currentGroup=y.items,E.currentGroupingKey=y.key,yield this.xsltChildNodesExcludingConditional(E,t,n)}})}groupByKey(e,t,n){let r=new Map,i=[];for(let o of e){let a=n.clone([o],0),u=this.xPath.xPathEval(t,a).stringValue();r.has(u)||(r.set(u,{key:u,items:[]}),i.push(u)),r.get(u).items.push(o)}return i.map(o=>r.get(o))}groupAdjacent(e,t,n){let r=[],i=null,o=[];for(let a of e){let c=n.clone([a],0),l=this.xPath.xPathEval(t,c).stringValue();i===null||l!==i?(o.length>0&&r.push({key:i,items:o}),i=l,o=[a]):o.push(a)}return o.length>0&&r.push({key:i,items:o}),r}patternToSelfExpression(e){return e.includes("::")||e.startsWith("/")||e.startsWith("(")?e:`self::${e}`}groupStartingWith(e,t,n){let r=[],i=[],o=0,a=this.patternToSelfExpression(t);for(let c of e){let u=n.clone([c],0),l=this.xPath.xPathEval(a,u).booleanValue();l&&i.length>0?(r.push({key:o++,items:i}),i=[c]):l&&i.length===0?i=[c]:i.push(c)}return i.length>0&&r.push({key:o,items:i}),r}groupEndingWith(e,t,n){let r=[],i=[],o=0,a=this.patternToSelfExpression(t);for(let c of e){i.push(c);let u=n.clone([c],0);this.xPath.xPathEval(a,u).booleanValue()&&(r.push({key:o++,items:i}),i=[])}return i.length>0&&r.push({key:o,items:i}),r}xsltIterate(e,t,n){return b(this,null,function*(){let r=f(t,"select");if(!r)throw new Error("<xsl:iterate> requires a select attribute.");let i=this.xPath.xPathEval(r,e).nodeSetValue();if(i.length===0){let u=Array.from(t.childNodes||[]).filter(l=>l.nodeType===1&&this.isXsltElement(l,"on-completion"));if(u.length>0){let l=u[0],p=e.clone([],0);yield this.xsltChildNodes(p,l,n)}return}let o={},a=Array.from(t.childNodes||[]).filter(u=>u.nodeType===1&&u.localName==="param"&&this.isXsltElement(u));for(let u of a){let l=f(u,"name");if(!l)throw new Error("<xsl:param> in <xsl:iterate> requires a name attribute.");let p=f(u,"select"),h=new G("");p&&(h=this.xPath.xPathEval(p,e)),o[l]=h}for(let u=0;u<i.length;u++){let l=i[u],p=e.clone([l],0);for(let d in o)p.variables[d]=o[d];let h=Array.from(t.childNodes||[]);for(let d of h){if(d.nodeType===1){let y=d;if(this.isXsltElement(y)&&(y.localName==="param"||y.localName==="on-completion"||y.localName==="next-iteration"))continue}yield this.xsltProcessContext(p,d,n)}let m=Array.from(t.childNodes||[]).filter(d=>d.nodeType===1&&this.isXsltElement(d,"next-iteration"));if(m.length>0){let d=m[0],y=Array.from(d.childNodes||[]).filter(E=>E.nodeType===1&&this.isXsltElement(E,"with-param"));for(let E of y){let T=f(E,"name");if(!T)throw new Error("<xsl:with-param> requires a name attribute.");let P=f(E,"select");if(P){let A=this.xPath.xPathEval(P,p);o[T]=A}}}}let c=Array.from(t.childNodes||[]).filter(u=>u.nodeType===1&&this.isXsltElement(u,"on-completion"));if(c.length>0){let u=c[0],l=e.clone();for(let p in o)l.variables[p]=o[p];yield this.xsltChildNodes(l,u,n)}})}xsltTry(e,t,n){return b(this,null,function*(){let r=Array.from(t.childNodes||[]).filter(o=>o.nodeType===1&&!this.isXsltElement(o,"catch")),i=Array.from(t.childNodes||[]).filter(o=>o.nodeType===1&&this.isXsltElement(o,"catch"));try{for(let o of r)yield this.xsltProcessContext(e,o,n)}catch(o){let a="err:UNKNOWN";o&&typeof o=="object"&&(o.code?a=o.code:o.message&&(o.message.includes("division by zero")||o.message.includes("div 0")?a="err:FOAR0001":o.message.includes("undefined")&&(a="err:XPDY0002")));let c=!1;for(let u of i){let l=f(u,"errors");if(!l)c=!0;else{let p=l.split("|").map(h=>h.trim());for(let h of p){if(h==="*"||h===a){c=!0;break}if(h.endsWith("*")){let m=h.slice(0,-1);if(a.startsWith(m)){c=!0;break}}}}if(c){yield this.xsltChildNodes(e,u,n);return}}if(!c&&i.length>0)throw o}})}xsltEvaluate(e,t,n){return b(this,null,function*(){let r=f(t,"xpath");if(!r)throw new Error("<xsl:evaluate> requires an xpath attribute.");let i=this.xPath.xPathEval(r,e).stringValue(),o=null,a=f(t,"context-item");if(a){let l=this.xPath.xPathEval(a,e).nodeSetValue();l.length>0&&(o=l[0])}let c;o?c=e.clone([o],0):c=e.clone();try{let u=this.xPath.xPathEval(i,c),l=n||this.outputDocument;if(u.type==="node-set"){let p=u.nodeSetValue();for(let h of p)this.xsltCopyOf(l,h)}else if(u.type==="array"&&u.arrayValue){let p=u.arrayValue();for(let h of p){let m=ae(this.outputDocument,h.stringValue());m.siblingPosition=l.childNodes.length,V(l,m)}}else{let p=ae(this.outputDocument,u.stringValue());p.siblingPosition=l.childNodes.length,V(l,p)}}catch(u){throw new Error(`Dynamic XPath evaluation error in xsl:evaluate: ${u.message}`)}})}xsltIf(e,t,n){return b(this,null,function*(){let r=f(t,"test");this.xPath.xPathEval(r,e).booleanValue()&&(yield this.xsltChildNodes(e,t,n))})}xsltImportOrInclude(e,t,n,r){return b(this,null,function*(){let i=r?"xsl:import":"xsl:include",o=t.childNodes.filter(d=>d.nodeName==="href");if(o.length<=0)throw new Error(`<${i}> with no href attribute defined.`);let c=o[0].nodeValue;if(this.importedStylesheets.has(c))return;let u=yield this.fetchFunction(c),l=this.xmlParser.xmlParse(u),p=this.styleSheetStack.length>0?this.styleSheetStack[this.styleSheetStack.length-1].importDepth:0,h={importDepth:r?p+1:p,href:c,order:this.importedStylesheets.size};this.styleSheetStack.push(h),this.importedStylesheets.set(c,l);let m=l.childNodes[0];m&&this.mapTemplatesFromStylesheet(m,h),yield this.xsltChildNodes(e,m,n),this.styleSheetStack.pop()})}xsltImport(e,t,n){return b(this,null,function*(){yield this.xsltImportOrInclude(e,t,n,!0)})}xsltInclude(e,t,n){return b(this,null,function*(){yield this.xsltImportOrInclude(e,t,n,!1)})}xsltPackage(e,t,n){return b(this,null,function*(){let r=f(t,"version")||this.version;if(!r||parseFloat(r)<3)throw new Error("<xsl:package> is only supported in XSLT 3.0 or later.");let i=f(t,"name"),o=f(t,"package-version"),a=f(t,"declared-modes")||"yes",c=f(t,"input-type-annotations")||"unspecified";if(!i)throw new Error('<xsl:package> requires a "name" attribute.');let u=o?`${i}@${o}`:i,l=this.packageRegistry.isLoading(u);l||this.packageRegistry.beginLoading(u);let p={name:i,version:o,root:t,components:new Map,usedPackages:new Map,isTopLevel:this.currentPackage===null,overrides:new Map,modes:new Map,declaredModes:a,inputTypeAnnotations:c},h=this.currentPackage;this.currentPackage=p;try{this.packageRegistry.register(p),yield this.xsltTransformOrStylesheet(e,t,n)}finally{l||this.packageRegistry.endLoading(u),this.currentPackage=h}})}loadAndRegisterPackage(e,t,n){return b(this,null,function*(){let r=n?`${e}@${n}`:e;if(!this.packageRegistry.beginLoading(r))throw new Error(`Circular package dependency detected: "${r}".`);try{let i=t;if(t.nodeType===9){for(let o of t.childNodes)if(o.nodeType===1&&this.isXsltElement(o,"package")){i=o;break}}if(i&&this.isXsltElement(i,"package")){e&&!f(i,"name")&&W(i,"name",e),n&&!f(i,"package-version")&&W(i,"package-version",n);let o=new qe([i]);yield this.xsltPackage(o,i)}else throw new Error("Package document does not contain an xsl:package root element.")}finally{this.packageRegistry.endLoading(r)}})}xsltUsePackage(e,t,n){return b(this,null,function*(){if(!this.currentPackage)throw new Error("<xsl:use-package> can only appear as a child of <xsl:package>.");let r=f(t,"name"),i=f(t,"package-version");if(!r)throw new Error('<xsl:use-package> requires a "name" attribute.');let o=i?`${r}@${i}`:r;if(this.packageRegistry.isLoading(o))throw new Error(`Circular package dependency detected: "${o}".`);let a=this.packageRegistry.get(r,i);if(!a&&this.packageLoader)try{let l=yield this.packageLoader(r,i);l&&(yield this.loadAndRegisterPackage(r,l,i),a=this.packageRegistry.get(r,i))}catch(l){if(l instanceof Error&&l.message.includes("Circular package dependency"))throw l}if(!a)throw new Error(`Package "${r}"${i?`@${i}`:""} not found. `+(this.packageLoader?"Package loader failed to load the package.":"Packages must be loaded before they can be used."));let c={package:a,acceptedComponents:new Map},u=i?`${r}@${i}`:r;this.currentPackage.usedPackages.set(u,c);for(let l of t.childNodes)this.isXsltElement(l,"accept")?this.xsltAccept(e,l):this.isXsltElement(l,"override")&&(yield this.xsltOverride(e,l,n));yield this.registerAcceptedVariables(e),this.registerUserDefinedFunctionsInContext(e),a.components.forEach((l,p)=>{if(l.visibility==="abstract"&&!this.currentPackage.overrides.has(p))throw new Error(`Abstract component "${l.name||l.match||p}" from package "${r}" must be overridden.`)})})}xsltExpose(e,t){if(!this.currentPackage)throw new Error("<xsl:expose> can only appear as a child of <xsl:package>.");let n=f(t,"component"),r=f(t,"names"),i=f(t,"visibility")||"public";if(!n)throw new Error('<xsl:expose> requires a "component" attribute (template, function, variable, attribute-set, mode).');let o=r==="*"?["*"]:r?r.split(/\s+/):[];if(o.length===0)throw new Error('<xsl:expose> requires a "names" attribute.');for(let a of o){let c=this.findComponentInPackageRoot(this.currentPackage.root,n,a==="*"?null:a);if(c){let u={type:n,name:c.name||(a!=="*"?a:void 0),match:c.match,mode:c.mode,visibility:i,overridable:i!=="final",node:c.node,priority:c.priority},l=At(u);this.currentPackage.components.set(l,u)}}}findComponentInPackageRoot(e,t,n){for(let r of e.childNodes)if(r.nodeType===1){if(t==="template"&&this.isXsltElement(r,"template")){let i=f(r,"name"),o=f(r,"match"),a=f(r,"mode");if(n){if(i===n)return{node:r,name:i,match:o,mode:a}}else return{node:r,name:i,match:o,mode:a}}else if(t==="function"&&this.isXsltElement(r,"function")){let i=f(r,"name");if(!n||i===n)return{node:r,name:i}}else if(t==="variable"&&this.isXsltElement(r,"variable")){let i=f(r,"name");if(!n||i===n)return{node:r,name:i}}else if(t==="attribute-set"&&this.isXsltElement(r,"attribute-set")){let i=f(r,"name");if(!n||i===n)return{node:r,name:i}}}return null}xsltAccept(e,t){if(!this.currentPackage)throw new Error("<xsl:accept> can only appear as a child of <xsl:use-package>.");let n=f(t,"component"),r=f(t,"names"),i=f(t,"visibility");if(!n)throw new Error('<xsl:accept> requires a "component" attribute.');if(!r)throw new Error('<xsl:accept> requires a "names" attribute.');let o=r==="*"?["*"]:r.split(/\s+/),a=t.parentNode;if(!a||!this.isXsltElement(a,"use-package"))throw new Error("<xsl:accept> must be a child of <xsl:use-package>.");let c=f(a,"name"),u=f(a,"package-version"),l=u?`${c}@${u}`:c,p=this.currentPackage.usedPackages.get(l);if(!p)throw new Error(`Internal error: used package "${l}" not found.`);let h=this.findComponentsInPackage(p.package,n,o);for(let m of h){if(!Ga(m,!1)){let E=m.name||m.match||"unnamed";throw new Error(`Cannot accept private component "${E}" of type "${n}" from package "${p.package.name}".`)}let d=I(X({},m),{sourcePackage:p.package.name,isAccepted:!0,effectiveVisibility:i||m.visibility}),y=At(d);p.acceptedComponents.set(y,d)}}xsltOverride(e,t,n){return b(this,null,function*(){if(!this.currentPackage)throw new Error("<xsl:override> can only appear as a child of <xsl:use-package>.");let r=t.parentNode;if(!r||!this.isXsltElement(r,"use-package"))throw new Error("<xsl:override> must be a child of <xsl:use-package>.");let i=f(r,"name"),o=f(r,"package-version"),a=o?`${i}@${o}`:i,c=this.currentPackage.usedPackages.get(a);if(!c)throw new Error(`Internal error: used package "${a}" not found.`);for(let u=0;u<t.childNodes.length;u++){let l=t.childNodes[u];if(l.nodeType!==1)continue;let p=l.localName,h=null,m=null,d=null;switch(p){case"template":h="template",m=f(l,"name"),d=f(l,"match");break;case"function":h="function",m=f(l,"name");break;case"variable":h="variable",m=f(l,"name");break;case"attribute-set":h="attribute-set",m=f(l,"name");break;default:throw new Error(`<xsl:override> does not support <xsl:${p}> elements.`)}if(!h)continue;let y;if(c.acceptedComponents.forEach(P=>{P.type===h&&(m&&P.name===m||d&&P.match===d)&&(y=P)}),y||c.package.components.forEach(P=>{P.type===h&&(m&&P.name===m||d&&P.match===d)&&(y=P)}),!y){let P=m||d||"unnamed";throw new Error(`Cannot override component "${P}" of type "${h}": component not found in package "${c.package.name}".`)}if(!Qa(y)){let P=m||d||"unnamed";throw new Error(`Cannot override component "${P}" of type "${h}": component is marked as "final" in package "${c.package.name}".`)}let E={type:h,name:m||void 0,match:d||void 0,mode:f(l,"mode")||void 0,visibility:y.visibility,overridable:!1,node:l,sourcePackage:this.currentPackage.name,isAccepted:!1,effectiveVisibility:y.visibility};E.originalComponent=y,E.node.__originalComponent=y;let T=At(y);this.currentPackage.overrides.set(T,E),h==="function"&&this.xsltFunction(e,l)}})}findComponentsInPackage(e,t,n){let r=[],i=n.includes("*");return e.components.forEach((o,a)=>{if(o.type!==t)return;if(i){r.push(o);return}let c=this.getComponentNameForMatching(o);c&&n.includes(c)&&r.push(o)}),r}getComponentNameForMatching(e){switch(e.type){case"function":case"variable":case"attribute-set":case"mode":return e.name||null;case"template":return e.name||null;default:return null}}xsltOriginal(e,t,n){return b(this,null,function*(){if(!this.currentOverrideContext&&this.currentTemplateStack.length>0){let a=this.currentTemplateStack[this.currentTemplateStack.length-1].template.__originalComponent;a&&(this.currentOverrideContext=a)}if(!this.currentOverrideContext)throw new Error("<xsl:original> can only be used within an overriding component.");let r=this.currentOverrideContext,i=r.node;switch(r.type){case"template":yield this.xsltChildNodes(e,i,n);break;case"function":throw new Error("<xsl:original> for functions should be called as a function, not as an element.");case"variable":yield this.xsltVariable(e,i,!0);break;case"attribute-set":r.name&&n&&(yield this.applyAttributeSets(e,n,r.name));break;default:throw new Error(`<xsl:original> does not support component type "${r.type}".`)}})}xsltMode(e,t){if(!this.currentPackage)throw new Error("<xsl:mode> can only appear as a child of <xsl:package>.");let n=f(t,"name");if(!n)throw new Error('<xsl:mode> requires a "name" attribute.');let r=f(t,"visibility")||"public",i=f(t,"streamable"),o=f(t,"on-no-match"),a=f(t,"on-multiple-match"),c=i==="yes";this.currentPackage.modes||(this.currentPackage.modes=new Map);let u={name:n,visibility:r,streamable:c,onNoMatch:o,onMultipleMatch:a};this.currentPackage.modes.set(n,u);let l=At({type:"mode",name:n,visibility:r});this.currentPackage.components.has(l)||this.currentPackage.components.set(l,{type:"mode",name:n,visibility:r,overridable:!1,node:t})}getEffectiveComponent(e){if(!this.currentPackage)return e;let t=At(e);return this.currentPackage.overrides.get(t)||e}collectAcceptedTemplates(e){let t=[];return this.currentPackage&&this.currentPackage.usedPackages.forEach((n,r)=>{n.acceptedComponents.forEach((i,o)=>{if(i.type==="template"&&i.isAccepted){let a=this.getEffectiveComponent(i),c=a.node,l=a!==i?i:void 0,p=f(c,"mode")||null;if((e||null)!==p)return;let m=f(c,"match");if(!m)return;let d=f(c,"priority"),y=d?parseFloat(d):null,E=i.priority||0,T=y!==null&&!isNaN(y)?y:E;t.push({template:c,explicitPriority:y!==null&&!isNaN(y)?y:null,defaultPriority:E,effectivePriority:T,importPrecedence:0,documentOrder:0,matchPattern:m,originalComponent:l})}})}),t}xsltStream(e,t,n){return b(this,null,function*(){this.streamingProcessor.setVersion(this.version);let r={processChildren:(i,o,a)=>this.xsltChildNodes(i,o,a),isXsltElement:(i,o)=>this.isXsltElement(i,o)};yield this.streamingProcessor.processStream(e,t,n,r)})}xsltFork(e,t,n){return b(this,null,function*(){let r={processChildren:(i,o,a)=>this.xsltChildNodes(i,o,a),isXsltElement:(i,o)=>this.isXsltElement(i,o)};yield this.streamingProcessor.processFork(e,t,n,r)})}xsltMerge(e,t,n){return b(this,null,function*(){this.streamingProcessor.setVersion(this.version);let r={processChildren:(i,o,a)=>this.xsltChildNodes(i,o,a),isXsltElement:(i,o)=>this.isXsltElement(i,o)};yield this.streamingProcessor.processMerge(e,t,n,r)})}xsltKey(e,t){let n=f(t,"name"),r=f(t,"match"),i=f(t,"use");if(!n||!r||!i){let a="<xsl:key> missing required parameters: ";throw n||(a+="name, "),r||(a+="match, "),i||(a+="use, "),a=a.slice(0,-2),new Error(a)}n in e.keys||(e.keys[n]={});let o=this.collectAllDescendants(e.root);for(let a of o)if(yi(a,r,e,this.matchResolver,this.xPath)){let c=e.clone([a]),l=this.xPath.xPathEval(i,c).stringValue();l in e.keys[n]?e.keys[n][l].nodeSetValue().push(a):e.keys[n][l]=new Z([a])}}collectAllDescendants(e){let t=[];for(let n of e.childNodes||[])t.push(n),t.push(...this.collectAllDescendants(n));return t}xsltMessage(e,t){return b(this,null,function*(){let n=Oe(this.outputDocument);yield this.xsltChildNodes(e,t,n);let r=me(n),i=f(t,"terminate")||"no";if(console.log(`[xsl:message] ${r}`),i==="yes")throw new Error(`xsl:message terminated: ${r}`)})}xsltNamespaceAlias(e){let t=f(e,"stylesheet-prefix"),n=f(e,"result-prefix");if(!t||!n)throw new Error("<xsl:namespace-alias> requires both stylesheet-prefix and result-prefix attributes.");this.namespaceAliases.set(t,n)}xsltNumber(e,t,n){let r=f(t,"value"),i=f(t,"level")||"single",o=f(t,"count"),a=f(t,"from"),c=f(t,"format")||"1",u=f(t,"lang"),l=f(t,"letter-value"),p=f(t,"grouping-separator"),h=f(t,"grouping-size"),m;if(r){let T=this.xPath.xPathEval(r,e);m=[Math.round(T.numberValue())]}else m=this.xsltNumberCount(e,i,o,a);let d=this.xsltFormatNumbers(m,c,p,h),y=ae(this.outputDocument,d),E=n||this.outputDocument;y.siblingPosition=E.childNodes.length,V(E,y)}xsltNumberCount(e,t,n,r){let i=e.nodeList[e.position],o=n||i.nodeName;switch(t){case"single":{let a=i;for(;a;){if(this.nodeMatchesPattern(a,o)){let c=1,u=a.previousSibling;for(;u;)this.nodeMatchesPattern(u,o)&&c++,u=u.previousSibling;return[c]}if(r&&this.nodeMatchesPattern(a,r))break;a=a.parentNode}return[0]}case"multiple":{let a=[],c=i,u=[];for(;c&&(this.nodeMatchesPattern(c,o)&&u.push(c),!(r&&this.nodeMatchesPattern(c,r)));)c=c.parentNode;for(let l=u.length-1;l>=0;l--){let p=u[l],h=1,m=p.previousSibling;for(;m;)this.nodeMatchesPattern(m,o)&&h++,m=m.previousSibling;a.push(h)}return a.length>0?a:[0]}case"any":{let a=0,c=this.getAllPrecedingNodes(i,r);this.nodeMatchesPattern(i,o)&&(a=1);for(let u of c)this.nodeMatchesPattern(u,o)&&a++;return[a]}default:return[1]}}nodeMatchesPattern(e,t){return t.includes("|")?t.split("|").map(r=>r.trim()).some(r=>this.nodeMatchesSinglePattern(e,r)):this.nodeMatchesSinglePattern(e,t)}nodeMatchesSinglePattern(e,t){return t==="*"?e.nodeType===1:t==="node()"?!0:t==="text()"?e.nodeType===3:t==="comment()"?e.nodeType===8:t.startsWith("processing-instruction")?e.nodeType===7:e.nodeName===t||e.localName===t}getAllPrecedingNodes(e,t=null){let n=[],r=e.previousSibling;for(;r;){if(t&&this.nodeMatchesPattern(r,t))return this.collectDescendants(r,n),n;n.push(r),this.collectDescendants(r,n),r=r.previousSibling}let i=e.parentNode;for(;i;){if(t&&this.nodeMatchesPattern(i,t))return n;let o=i.previousSibling;for(;o;){if(t&&this.nodeMatchesPattern(o,t))return this.collectDescendants(o,n),n;n.push(o),this.collectDescendants(o,n),o=o.previousSibling}i=i.parentNode}return n}collectDescendants(e,t){for(let n of e.childNodes)n.nodeType===1&&(t.push(n),this.collectDescendants(n,t))}xsltFormatNumbers(e,t,n,r){if(e.length===0)return"0";let{tokens:i,separators:o}=this.parseFormatString(t),a=[];for(let u=0;u<e.length;u++){let l=Math.min(u,i.length-1),p=i[l]||"1",h=this.xsltFormatNumber(e[u],p,n,r);a.push(h)}if(a.length===1)return a[0];let c=a[0];for(let u=1;u<a.length;u++){let l=Math.min(u-1,o.length-1),p=o.length>0?o[l]:".";c+=p+a[u]}return c}parseFormatString(e){let t=[],n=[],r=/^(0*1|[aAiI])/,i=e,o=!1;for(;i.length>0;){let a=i.match(r);if(a)t.push(a[1]),i=i.substring(a[1].length),o=!0;else{if(o&&t.length>0){let c=1;for(;c<i.length&&!i.substring(c).match(r);)c++;n.push(i.substring(0,c)),i=i.substring(c)}else i=i.substring(1);o=!1}}if(t.length===0&&t.push("1"),n.length===0&&t.length>1)for(let a=1;a<t.length;a++)n.push(".");return{tokens:t,separators:n}}xsltFormatNumber(e,t,n,r){if(t.match(/^0+1$/)){let a=t.length,c=e.toString().padStart(a,"0");if(n&&r){let u=parseInt(r,10);u>0&&!isNaN(u)&&(c=this.applyGrouping(c,n,u))}return c}let i=t.charAt(0),o;switch(i){case"1":if(o=e.toString(),t.length>1&&t.match(/^0+1$/)){let a=t.length;o=e.toString().padStart(a,"0")}break;case"a":o=this.numberToAlpha(e,!1);break;case"A":o=this.numberToAlpha(e,!0);break;case"i":o=this.numberToRoman(e).toLowerCase();break;case"I":o=this.numberToRoman(e);break;default:o=e.toString()}if(n&&r){let a=parseInt(r,10);a>0&&!isNaN(a)&&(o=this.applyGrouping(o,n,a))}return o}numberToAlpha(e,t){if(e<=0)return"";let n="";for(;e>0;)e--,n=String.fromCharCode(e%26+(t?65:97))+n,e=Math.floor(e/26);return n}numberToRoman(e){if(e<=0||e>3999)return e.toString();let t=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]],n="";for(let[r,i]of t)for(;e>=r;)n+=i,e-=r;return n}applyGrouping(e,t,n){let r=e.split("."),i=r[0],o=r[1],a="",c=0;for(let u=i.length-1;u>=0;u--)c>0&&c%n===0&&(a=t+a),a=i[u]+a,c++;return o?a+"."+o:a}xsltSort(e,t){let n=[];for(let r of t.childNodes)if(r.nodeType==1&&this.isXsltElement(r,"sort")){let i=f(r,"select"),o=this.xPath.xPathParse(i),a=f(r,"data-type")||"text",c=f(r,"order")||"ascending";n.push({expr:o,type:a,order:c})}this.xPath.xPathSort(e,n)}resolveNamespaceUriForPrefix(e,t){let n=t?`xmlns:${t}`:"xmlns",r=e;for(;r;){let i=r.childNodes.filter(o=>o.nodeType===2);for(let o of i)if(o.nodeName===n||t&&o.prefix==="xmlns"&&o.localName===t||!t&&o.nodeName==="xmlns")return o.nodeValue;r=r.parentNode}return null}isNamespaceDeclaredOnAncestor(e,t,n){let r=e;for(;r;){if(Ze(r,t)===n)return!0;r=r.parentNode}return!1}parseWhitespacePattern(e,t){if(e==="*")return{namespaceUri:null,localName:"*",isWildcard:!0};if(e.includes(":")){let[n,r]=e.split(":"),i=this.resolveNamespaceUriForPrefix(t,n);return{namespaceUri:i!=null?i:null,localName:r||"*",isWildcard:r==="*"}}return{namespaceUri:null,localName:e,isWildcard:!1}}xsltStripSpace(e){let t=f(e,"elements");if(t){let n=t.trim().split(/\s+/);for(let r of n)this.stripSpacePatterns.push(this.parseWhitespacePattern(r,e))}}xsltPreserveSpace(e){let t=f(e,"elements");if(t){let n=t.trim().split(/\s+/);for(let r of n)this.preserveSpacePatterns.push(this.parseWhitespacePattern(r,e))}}shouldStripWhitespaceNode(e){if(!e.nodeValue||!e.nodeValue.match(/^\s*$/)||this.stripSpacePatterns.length===0)return!1;let t=e.parentNode;if(!t||t.nodeType!==1)return!1;let n=t;for(;n&&n.nodeType===1;){let i=Ze(n,"xml:space");if(i==="preserve")return!1;if(i==="default")break;n=n.parentNode}let r=t.localName||t.nodeName;for(let i of this.preserveSpacePatterns)if(this.matchesNamePattern(r,i,t))return!1;for(let i of this.stripSpacePatterns)if(this.matchesNamePattern(r,i,t))return!0;return!1}matchesNamePattern(e,t,n){var i;let r=(i=n.namespaceUri)!=null?i:this.resolveNamespaceUriForPrefix(n,n.prefix||null);if(t.namespaceUri!==null){if(r!==t.namespaceUri)return!1}else if(!t.isWildcard&&r)return!1;return t.isWildcard?!0:e===t.localName}xsltTemplate(e,t,n){return b(this,null,function*(){if(!e.inApplyTemplates&&e.baseTemplateMatched)return;let r=f(t,"match");if(!r)return;let i=this.xsltMatch(r,e,"self-and-siblings");if(i.length>0){this.firstTemplateRan=!0,e.inApplyTemplates||(e.baseTemplateMatched=!0);let o=e.clone(i,0);yield this.xsltChildNodes(o,t,n)}})}xsltText(e,t,n){let r=me(t),i=ae(this.outputDocument,r);i.fromXslText=!0;let o=t.childNodes.filter(c=>c.nodeType===2&&c.nodeName==="disable-output-escaping");o.length>0&&o[0].nodeValue==="yes"&&(i.escape=!1);let a=n||this.outputDocument;i.siblingPosition=a.childNodes.length,a.appendChild(i)}validateStylesheetAttributes(e,t){let n=e.childNodes.filter(a=>a.nodeType===2),r=["version","id","extension-element-prefixes","exclude-result-prefixes","default-collation"],i=["xmlns"],o=!1;for(let a of n){let c=a.nodeName,u=a.nodeValue;if(a.prefix==="xmlns"){t.knownNamespaces[a.localName]=u;continue}if(c==="xmlns"){t.knownNamespaces[""]=u;continue}if(c==="version"){o=!0;let l=parseFloat(u);if(isNaN(l)||l<=0)throw new Error(`XSLT version not defined or invalid. Actual resolved version: ${u||"(none)"}.`);l>1&&!["2.0","3.0"].includes(u)?(this.forwardsCompatible=!0,this.version=u,t.xsltVersion="1.0",this.warningsCallback(`XSLT Warning: Stylesheet version "${u}" is not directly supported. Entering forwards-compatible processing mode (XSLT 1.0 Section 2.5).`)):(this.version=u,t.xsltVersion=u);continue}if(c==="extension-element-prefixes"){let l=u.split(/\s+/);for(let p of l)if(p&&!/^[a-zA-Z_:][\w:.-]*$/.test(p))throw new Error(`Invalid prefix in extension-element-prefixes: "${p}". Prefixes must be valid QNames.`);continue}if(c==="exclude-result-prefixes"){if(u!=="#all"){let l=u.split(/\s+/);for(let p of l)if(p&&!/^[a-zA-Z_:][\w:.-]*$/.test(p))throw new Error(`Invalid prefix in exclude-result-prefixes: "${p}". Prefixes must be valid QNames or "#all".`)}continue}if(c==="default-collation"){if(!u||u.trim().length===0)throw new Error("The default-collation attribute must contain a URI.");continue}if(c==="id"){if(!/^[a-zA-Z_:][\w:.-]*$/.test(u))throw new Error(`Invalid id attribute value: "${u}". IDs must be valid NCNames.`);continue}}}xsltTransformOrStylesheet(e,t,n){return b(this,null,function*(){var u;let r={importDepth:0,href:"(main stylesheet)",order:0};this.mapTemplatesFromStylesheet(t,r),this.collectAttributeSets(t),this.collectUserDefinedFunctions(t,e),this.registerUserDefinedFunctionsInContext(e),this.validateStylesheetAttributes(t,e);let i=!1;for(let l of t.childNodes)if(l.nodeType===1)if(this.isXsltElement(l,"import")){if(i)throw new Error("<xsl:import> should be the first child node of <xsl:stylesheet> or <xsl:transform>.")}else i=!0;let o=[],a=[];for(let l of t.childNodes)l.nodeType===1&&this.isXsltElement(l,"template")?a.push(l):o.push(l);let c=e.clone();for(let l of o)yield this.xsltProcessContext(c,l,n);if(a.length>0){let l=vr(t,null,this.xPath,this.templateSourceMap),p=[];for(let h of l)try{let m=this.xsltMatch(h.matchPattern,c);m.length>0&&p.push({priority:h,matchedNodes:m})}catch(m){this.warningsCallback(`Failed to match pattern "${h.matchPattern}":`,m)}if(p.length>0){let h=p.find(A=>A.priority.matchPattern==="/"),m;h?m=h:(p.sort((A,w)=>A.priority.importPrecedence!==w.priority.importPrecedence?w.priority.importPrecedence-A.priority.importPrecedence:A.priority.effectivePriority!==w.priority.effectivePriority?w.priority.effectivePriority-A.priority.effectivePriority:w.priority.documentOrder-A.priority.documentOrder),m=p[0]);let d=p.filter(A=>A.priority.importPrecedence===m.priority.importPrecedence&&A.priority.effectivePriority===m.priority.effectivePriority);if(d.length>1){let A=d.map(w=>`"${w.priority.matchPattern}" (priority: ${w.priority.effectivePriority})`).join(", ");this.warningsCallback(`XSLT Warning: Ambiguous template match. Multiple templates match with equal priority: ${A}. Using the last one in document order.`)}this.firstTemplateRan=!0,c.baseTemplateMatched=!0;let y=c.clone(m.matchedNodes,0),E=this.templateSourceMap.get(m.priority.template),T=f(m.priority.template,"match"),P=f(m.priority.template,"mode");this.currentTemplateStack.push({template:m.priority.template,stylesheetDepth:(u=E==null?void 0:E.importDepth)!=null?u:0,mode:P||null,match:T}),yield this.xsltChildNodes(y,m.priority.template,n),this.currentTemplateStack.pop()}else{let h=e.nodeList[e.position];h&&(yield this.applyBuiltInTemplate(h,l,null,e,n))}}})}xsltValueOf(e,t,n){let r=f(t,"select"),i=e.nodeList[e.position],o=this.xPath.xPathEval(r,e);if(i&&i.nodeName==="#document"&&(o.stringValue()===""||o instanceof Z&&o.nodeSetValue().length===0)){let l=i.childNodes.find(p=>p.nodeName!=="#dtd-section");if(l){let p=e.clone([l],0);o=this.xPath.xPathEval(r,p)}}let a=o.stringValue(),c=ae(this.outputDocument,a),u=n||this.outputDocument;c.siblingPosition=u.childNodes.length,u.appendChild(c)}xsltSequence(e,t,n){return b(this,null,function*(){let r=f(t,"select"),i=n||this.outputDocument;if(r){let o=this.xPath.xPathEval(r,e);if(o.type==="node-set"){let a=o.nodeSetValue();for(let c of a)this.xsltCopyOf(i,c)}else{let a=ae(this.outputDocument,o.stringValue());a.siblingPosition=i.childNodes.length,V(i,a)}}else yield this.xsltChildNodes(e,t,n)})}xsltAnalyzeString(e,t,n){return b(this,null,function*(){let r=f(t,"select"),i=f(t,"regex"),o=f(t,"flags")||"";if(!r)throw new Error("<xsl:analyze-string> requires a select attribute.");if(!i)throw new Error("<xsl:analyze-string> requires a regex attribute.");let c=this.xPath.xPathEval(r,e).stringValue(),u=null,l=null;for(let y of t.childNodes)if(y.nodeType===1&&this.isXsltElement(y)){if(y.localName==="matching-substring")u=y;else if(y.localName==="non-matching-substring")l=y;else if(y.localName==="fallback")continue}let p="g";for(let y of o)switch(y){case"i":p+="i";break;case"m":p+="m";break;case"s":p+="s";break}let h;try{h=new RegExp(i,p)}catch(y){throw new Error(`Invalid regular expression in xsl:analyze-string: ${i}`)}let m=0,d;for(;(d=h.exec(c))!==null;){let y=d.index,E=y+d[0].length;if(y>m&&l){let T=c.substring(m,y);yield this.processAnalyzeStringContent(e,l,n,T,null)}if(u){let T=d.slice(0);yield this.processAnalyzeStringContent(e,u,n,d[0],T)}m=E,d[0].length===0&&h.lastIndex++}if(m<c.length&&l){let y=c.substring(m);yield this.processAnalyzeStringContent(e,l,n,y,null)}})}processAnalyzeStringContent(e,t,n,r,i){return b(this,null,function*(){let o=ae(this.outputDocument,r),a=e.clone([o],0);i&&(a.regexGroups=i),yield this.xsltChildNodes(a,t,n)})}xsltFunction(e,t){let n=f(t,"name"),r=f(t,"as"),i=f(t,"override");if(!n)throw new Error('<xsl:function> requires a "name" attribute.');if(!n.includes(":"))throw new Error(`<xsl:function> name "${n}" must be in a namespace (use a prefixed name like "my:functionName").`);let o=i==="yes"||i==="true";this.userDefinedFunctions.has(n)&&!o||this.userDefinedFunctions.set(n,t)}coerceToType(e,t){switch(t.replace(/^xs:/,"").toLowerCase()){case"integer":case"int":case"double":case"decimal":case"number":return new fe(e.numberValue());case"string":return new G(e.stringValue());case"boolean":return new R(e.booleanValue());default:return e}}toNodeValue(e){return e&&typeof e=="object"&&"stringValue"in e?e:e&&typeof e=="object"&&"nodeType"in e?new Z([e]):Array.isArray(e)?new Z(e):typeof e=="number"?new fe(e):typeof e=="boolean"?new R(e):new G(String(e!=null?e:""))}executeUserDefinedFunction(e,t,n){return b(this,null,function*(){return this.executeUserDefinedFunctionSync(e,t,n)})}executeUserDefinedFunctionSync(e,t,n){let r=e.clone();r.variables=X({},e.variables);let i=[];for(let o of t.childNodes)o.nodeType===1&&this.isXsltElement(o,"param")&&i.push(o);for(let o=0;o<i.length;o++){let a=f(i[o],"name");if(a)if(o<n.length){let c=f(i[o],"as"),u=this.toNodeValue(n[o]);c&&(u=this.coerceToType(u,c)),r.setVariable(a,u)}else{let c=f(i[o],"select");if(c){let u=this.xPath.xPathEval(c,r);r.setVariable(a,u)}else r.setVariable(a,new G(""))}}for(let o of t.childNodes)if(o.nodeType===1){if(this.isXsltElement(o,"sequence")){let a=f(o,"select");if(a){let c=this.xPath.xPathEval(a,r);return c.type==="number"?c.numberValue():c.type==="boolean"?c.booleanValue():c.type==="node-set"?c.nodeSetValue():c.stringValue()}}else if(this.isXsltElement(o,"value-of")){let a=f(o,"select");if(a)return this.xPath.xPathEval(a,r).stringValue()}}return""}xsltResultDocument(e,t){return b(this,null,function*(){let n=f(t,"href")||"",r=f(t,"method")||this.outputMethod||"xml",i=f(t,"omit-xml-declaration")||this.outputOmitXmlDeclaration,o=this.xsltAttributeValue(n,e);if(!o)throw new Error('<xsl:result-document> requires a non-empty "href" attribute.');if(this.resultDocuments.has(o))throw new Error(`<xsl:result-document>: A document has already been created with href="${o}".`);let a=new ue;yield this.xsltChildNodes(e,t,a);let c=Mn(a,{cData:this.options.cData,escape:this.options.escape,selfClosingTags:this.options.selfClosingTags,outputMethod:r,outputVersion:this.outputVersion,itemSeparator:this.itemSeparator});this.resultDocuments.set(o,c)})}getResultDocuments(){return this.resultDocuments}setPackageLoader(e){this.packageLoader=e}registerPackage(e,t,n){return b(this,null,function*(){yield this.loadAndRegisterPackage(e,t,n)})}xsltPerformSort(e,t,n){return b(this,null,function*(){let r=f(t,"select"),i;if(r)i=this.xPath.xPathEval(r,e).nodeSetValue();else{let c=[];for(let l of t.childNodes)l.nodeType===1&&!this.isXsltElement(l,"sort")&&c.push(l);let u=Oe(this.outputDocument);for(let l of c)yield this.xsltProcessContext(e,l,u);i=Array.from(u.childNodes)}if(i.length===0)return;let o=e.clone(i);this.xsltSort(o,t);let a=n||this.outputDocument;for(let c of o.nodeList)this.xsltCopyOf(a,c)})}xsltNamespace(e,t,n){return b(this,null,function*(){let r=f(t,"name"),i=f(t,"select");if(!r&&r!=="")throw new Error('<xsl:namespace> requires a "name" attribute.');let o=this.xsltAttributeValue(r,e),a;if(i)a=this.xPath.xPathEval(i,e).stringValue();else{let u=Oe(this.outputDocument);yield this.xsltChildNodes(e,t,u),a=me(u)}if(!a)throw new Error("<xsl:namespace> requires a non-empty namespace URI.");let c=n||this.outputDocument;c.nodeType===1&&(o?W(c,`xmlns:${o}`,a):W(c,"xmlns",a))})}xsltVariable(e,t,n){return b(this,null,function*(){let r=f(t,"name"),i=f(t,"select"),o;if(t.childNodes.filter(c=>c.nodeType!==2).length>0){let c=Oe(t.ownerDocument);yield this.xsltChildNodes(e,t,c),o=new Z([c])}else if(i)o=this.xPath.xPathEval(i,e);else{let c=this.options.parameters.filter(u=>u.name===r);c.length>0?o=this.toNodeValue(c[0].value):o=new G("")}(n||!e.getVariable(r))&&e.setVariable(r,o)})}registerAcceptedVariables(e){return b(this,null,function*(){this.currentPackage&&this.currentPackage.usedPackages.forEach((t,n)=>{t.acceptedComponents.forEach((r,i)=>{r.type==="variable"&&r.name&&r.isAccepted&&this.xsltVariable(e,r.node,!1)})})})}xsltChildNodes(e,t,n){return b(this,null,function*(){let r=e.clone();for(let i=0;i<t.childNodes.length;++i){let o=t.childNodes[i];o.nodeType!==2&&(yield this.xsltProcessContext(r,o,n))}})}xsltChildNodesExcludingConditional(e,t,n){return b(this,null,function*(){let r=e.clone();for(let i=0;i<t.childNodes.length;++i){let o=t.childNodes[i];o.nodeType!==2&&(o.nodeType===1&&this.isXsltElement(o)&&(o.localName==="on-empty"||o.localName==="on-non-empty")||(yield this.xsltProcessContext(r,o,n)))}})}findConditionalChild(e,t){for(let n of e.childNodes)if(n.nodeType===1&&this.isXsltElement(n,t))return n;return null}commonLogicTextNode(e,t,n){if(n){if(this.shouldStripWhitespaceNode(t))return;let r=t.nodeValue;this.version&&parseFloat(this.version)>=3&&(r=this.xsltTextValueTemplate(r,e));let i=ae(this.outputDocument,r);i.siblingPosition=n.childNodes.length,V(n,i)}}xsltPassThrough(e,t,n){return b(this,null,function*(){switch(t.nodeType){case 3:this.xsltPassText(t)&&this.commonLogicTextNode(e,t,n);break;case 1:let r,i=e;r=e.nodeList[e.position];let o,a=t.nodeName,c=t.namespaceUri,u=t.prefix||"",l=this.namespaceAliases.get(u);if(l){let m=t.localName||t.nodeName;l==="#default"?(a=m,c=this.resolveNamespaceUriForPrefix(t,null)):(a=`${l}:${m}`,c=this.resolveNamespaceUriForPrefix(t,l))}if(o=et(this.outputDocument,a),o.siblingPosition=(n||this.outputDocument).childNodes.length,V(n||this.outputDocument,o),l)l==="#default"?c&&W(o,"xmlns",c):c&&W(o,`xmlns:${l}`,c);else if(c){let m=u||(a.includes(":")?a.split(":")[0]:null),d=m?`xmlns:${m}`:"xmlns";this.isNamespaceDeclaredOnAncestor(n,d,c)||W(o,d,c)}let p=t.childNodes.find(m=>(m==null?void 0:m.nodeType)===2&&m.nodeName==="use-attribute-sets");p&&(yield this.applyAttributeSets(i,o,p.nodeValue)),yield this.xsltChildNodes(i,t,o);let h=t.childNodes.filter(m=>(m==null?void 0:m.nodeType)===2&&m.nodeName!=="use-attribute-sets");for(let m of h){let d=m.nodeName,y=this.xsltAttributeValue(m.nodeValue,i);if(W(o,d,y),m.prefix&&m.namespaceUri&&m.prefix!=="xmlns"&&!m.nodeName.startsWith("xmlns")){let E=`xmlns:${m.prefix}`;this.isNamespaceDeclaredOnAncestor(o,E,m.namespaceUri)||W(o,E,m.namespaceUri)}}break;default:yield this.xsltChildNodes(e,t,n)}})}xsltPassText(e){if(!e.nodeValue.match(/^\s*$/))return!0;let t=e.parentNode;if(this.isXsltElement(t,"text"))return!0;for(;t&&t.nodeType==1;){let n=Ze(t,"xml:space");if(n){if(n=="default")return!1;if(n=="preserve")return!0}t=t.parentNode}return!1}findAttributeInContext(e,t){return t.nodeList[t.position].childNodes.find(n=>n.nodeType===2&&n.nodeName===e)}xsltAttributeValue(e,t){let n=e.split("{");if(n.length===1)return e;let r="";for(let i=0;i<n.length;++i){let o=n[i].split("}");if(o.length!=2){r+=n[i];continue}let a=this.xPath.xPathEval(o[0],t).stringValue();r+=a+o[1]}return r}xsltTextValueTemplate(e,t){if(!e)return e;let n="",r=0;for(;r<e.length;){let i=e[r];if(i==="{"){if(r+1<e.length&&e[r+1]==="{"){n+="{",r+=2;continue}let o=1,a=r+1,c="";for(;a<e.length&&o>0;){if(e[a]==="{")o++;else if(e[a]==="}"&&(o--,o===0))break;c+=e[a],a++}if(o===0){try{let u=this.xPath.xPathEval(c,t).stringValue();n+=u}catch(u){throw new Error(`Error evaluating text value template expression "${c}": ${u.message}`)}r=a+1}else n+=i,r++}else if(i==="}"){if(r+1<e.length&&e[r+1]==="}"){n+="}",r+=2;continue}n+=i,r++}else n+=i,r++}return n}xsltMatch(e,t,n){let r=this.xPath.xPathParse(e,n);return this.matchResolver.expressionMatch(r,t)}xsltWithParam(e,t){return b(this,null,function*(){for(let n of t.childNodes)n.nodeType===1&&this.isXsltElement(n,"with-param")&&(yield this.xsltVariable(e,n,!0))})}mapTemplatesFromStylesheet(e,t){for(let n of e.childNodes)n.nodeType===1&&(this.isXsltElement(n,"template")?this.templateSourceMap.set(n,t):(this.isXsltElement(n,"stylesheet")||this.isXsltElement(n,"transform")||this.isXsltElement(n,"package"))&&this.mapTemplatesFromStylesheet(n,t))}collectAttributeSets(e){for(let t of e.childNodes)if(t.nodeType===1&&this.isXsltElement(t,"attribute-set")){let n=f(t,"name"),r=t.childNodes.filter(i=>i.nodeType===1&&this.isXsltElement(i,"attribute"));if(n){let i=this.attributeSets.get(n);i&&i.length?this.attributeSets.set(n,[...i,...r]):this.attributeSets.set(n,r)}}}collectUserDefinedFunctions(e,t){for(let n of e.childNodes)n.nodeType===1&&this.isXsltElement(n,"function")&&this.xsltFunction(t,n)}registerUserDefinedFunctionsInContext(e){if(this.userDefinedFunctions.size===0&&!this.hasAcceptedFunctions())return;let t=new Map;this.userDefinedFunctions.forEach((n,r)=>{t.set(r,{functionDef:n,executor:(i,o,a)=>this.executeUserDefinedFunctionSync(i,o,a)})}),this.registerAcceptedFunctions(t),e.userDefinedFunctions=t}hasAcceptedFunctions(){if(!this.currentPackage)return!1;let e=!1;return this.currentPackage.usedPackages.forEach(t=>{t.acceptedComponents.forEach(n=>{n.type==="function"&&n.isAccepted&&(e=!0)})}),e}registerAcceptedFunctions(e){this.currentPackage&&this.currentPackage.usedPackages.forEach((t,n)=>{t.acceptedComponents.forEach((r,i)=>{if(r.type==="function"&&r.name&&r.isAccepted){let o=this.getEffectiveComponent(r);e.set(r.name,{functionDef:o.node,executor:(a,c,u)=>this.executeUserDefinedFunctionSync(a,c,u)})}})})}applyAttributeSets(e,t,n){return b(this,null,function*(){if(!n||!n.trim())return;let r=n.trim().split(/\s+/),i=new Set;for(let o of r)yield this.applyAttributeSet(e,t,o,i)})}applyAttributeSet(e,t,n,r){return b(this,null,function*(){if(r.has(n))return;r.add(n);let i=this.attributeSets.get(n);if(i)for(let o of i){let a=null,c=o.parentNode;if(c&&(a=f(c,"use-attribute-sets")),a)for(let m of a.trim().split(/\s+/))m&&(yield this.applyAttributeSet(e,t,m,r));let u=f(o,"name"),l=this.xsltAttributeValue(u,e),p=Oe(this.outputDocument);yield this.xsltChildNodes(e,o,p);let h=di(p);W(t,l,h)}})}isExtensionElementSupported(e){if(e.nodeType!==1)return!0;let t=e.namespaceUri;return!t||this.isXsltElement(e)?!0:!!this.supportedExtensions.has(t)}getFallbackElement(e){for(let t of e.childNodes)if(t.nodeType===1&&this.isXsltElement(t,"fallback"))return t;return null}xsltExtensionElement(e,t,n){return b(this,null,function*(){let r=this.getFallbackElement(t);r?yield this.xsltChildNodes(e,r,n):yield this.xsltPassThrough(e,t,n)})}isXsltElement(e,t){return t&&e.localName!=t?!1:e.namespaceUri?e.namespaceUri==="http://www.w3.org/1999/XSL/Transform":e.prefix==="xsl"}};return U(Mu);})();
|
|
4
|
+
`&&s[c]!=="\r";)c++;for(;c<s.length&&/[\s\n\r\t]/.test(s[c]);)c++}else if(s[c]==="/"&&c+1<s.length&&s[c+1]==="*"){for(c+=2;c<s.length-1;){if(s[c]==="*"&&s[c+1]==="/"){c+=2;break}c++}for(;c<s.length&&/[\s\n\r\t]/.test(s[c]);)c++}else break;if(c<s.length&&(s[c]==="}"||s[c]==="]")){for(t++;t<c;)/[\s\n\r\t]/.test(s[t])&&(e+=s[t]),t++;continue}}e+=o,t++}return e}function zo(s,e){if(typeof s!="string")throw new te("XPTY0004","parse-json: first argument must be a string");let t={liberal:!1,duplicates:"use-last"};if(e&&Q(e)){e.liberal===!0&&(t.liberal=!0);let r=e.duplicates;typeof r=="string"&&(t.duplicates=r)}try{if(t.duplicates!=="use-last")throw new te("FOJS0001",'Only duplicates="use-last" is supported');let n=t.liberal?Qc(s):s,r=JSON.parse(n);return Kr(r)}catch(n){throw new te("FOJS0001","parse-json: "+(n&&n.message?n.message:String(n)))}}function Yo(s,e,t){return typeof s=="string"?zo(s,e):zo(e,t)}function cr(s){if(s==null)return null;if(re(s))return s.members.map(cr);if(Q(s)){let e={};for(let[t,n]of Object.entries(s))t.startsWith("__")||(e[t]=cr(n));return e}if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return s;if(Array.isArray(s))return s.map(cr);throw new te("FOJS0002",`Cannot serialize value of type ${typeof s}`)}function Qr(s,e){let t={indent:void 0,method:"json"};if(e&&Q(e)){let n=e.indent;typeof n=="number"&&(t.indent=n);let r=e.method;typeof r=="string"&&(t.method=r)}try{let n;Array.isArray(s)?s.length===0?n=null:s.length===1?n=s[0]:n=s:n=s;let r=cr(n),i=t.indent!==void 0?t.indent:void 0;return JSON.stringify(r,null,i)}catch(n){throw n instanceof te?n:new te("FOJS0002","serialize: "+(n&&n.message?n.message:String(n)))}}function Go(s,e,t){return t!==void 0||s&&typeof s=="object"&&!("__isMap"in s)&&!("__isArray"in s)&&e!==void 0?Qr(e,t):Qr(s,e)}function jo(s,e){if(s==null||s==="")return null;if(typeof s!="string")throw new te("XPTY0004","json-to-xml: first argument must be a string or null");let t={liberal:!1,duplicates:"reject"};if(e&&Q(e)){e.liberal===!0&&(t.liberal=!0);let r=e.duplicates;typeof r=="string"&&(t.duplicates=r)}try{return new we().convert(s,t)}catch(n){throw new te("FOJS0001","json-to-xml: "+(n&&n.message?n.message:String(n)))}}function Qo(s,e,t){if(typeof s=="string"||s===null||s===void 0)return jo(s,e);if(typeof s!="object")throw new te("XPTY0004","json-to-xml: first argument must be a string or null");return jo(e,t)}var Ko=g(()=>{De();Ve();_e();En();je()});function Ho(s,e){let t=Je(s),n=Je(e);if(!n)throw new Error("FOCA0002: Invalid QName: empty string");let r=n.indexOf(":");if(r!==-1){let i=n.substring(0,r),o=n.substring(r+1);if(!Hr(i)||!Hr(o))throw new Error(`FOCA0002: Invalid QName: ${n}`);if(!t)throw new Error(`FONS0004: No namespace for prefix: ${i}`)}else if(!Hr(n))throw new Error(`FOCA0002: Invalid QName: ${n}`);return t?`{${t}}${n}`:n}function Jo(s,e){var c,u;let t=Je(s);if(!t)return null;let n=Jr(e);if(!n)throw new Error("FORG0001: Second argument to resolve-QName must be an element");let r=t.indexOf(":");if(r===-1){let l=(u=(c=n.getAttribute)==null?void 0:c.call(n,"xmlns"))!=null?u:"";return l?`{${l}}${t}`:t}let i=t.substring(0,r),o=t.substring(r+1),a=ia(n,i);if(!a)throw new Error(`FONS0004: No namespace for prefix: ${i}`);return`{${a}}${t}`}function Zo(s){let e=Je(s);if(!e)return null;let t=e;if(e.startsWith("{")){let r=e.indexOf("}");r!==-1&&(t=e.substring(r+1))}let n=t.indexOf(":");return n===-1?null:t.substring(0,n)}function ea(s){let e=Je(s);if(!e)return null;let t=e;if(e.startsWith("{")){let r=e.indexOf("}");r!==-1&&(t=e.substring(r+1))}let n=t.indexOf(":");return n===-1?t:t.substring(n+1)}function ta(s){let e=Je(s);if(!e)return null;if(e.startsWith("{")){let t=e.indexOf("}");if(t!==-1)return e.substring(1,t)}return null}function na(s){let e=Jr(s);if(!e)throw new Error("FORG0001: Argument to in-scope-prefixes must be an element");let t=new Set;t.add("xml");let n=e;for(;n;){if("attributes"in n&&n.attributes){let r=n.attributes;if(typeof r.getNamedItem=="function")for(let i=0;i<r.length;i++){let o=r.item(i);if(o){let a=o.name||o.nodeName;a==="xmlns"?t.add(""):a.startsWith("xmlns:")&&t.add(a.substring(6))}}else if(Array.isArray(r)){for(let i of r)if(i&&typeof i=="object"){let o=i.name||i.nodeName;o==="xmlns"?t.add(""):o&&typeof o=="string"&&o.startsWith("xmlns:")&&t.add(o.substring(6))}}else for(let i of Object.keys(r))i==="xmlns"?t.add(""):i.startsWith("xmlns:")&&t.add(i.substring(6))}n=n.parentNode}return Array.from(t)}function ra(s,e){let t=Je(s),n=Jr(e);if(!n)throw new Error("FORG0001: Second argument to namespace-uri-for-prefix must be an element");return t==="xml"?"http://www.w3.org/XML/1998/namespace":ia(n,t)}function Je(s){var e;if(s==null)return"";if(Array.isArray(s)){if(s.length===0)return"";s=s[0]}return typeof s=="object"&&s!==null&&"textContent"in s?(e=s.textContent)!=null?e:"":String(s)}function Jr(s){if(s==null)return null;if(Array.isArray(s)){if(s.length===0)return null;s=s[0]}if(typeof s=="object"&&s!==null&&"nodeType"in s){let e=s;if(e.nodeType===Te.ELEMENT_NODE)return e}return null}function Hr(s){if(!s)return!1;let e=s.charAt(0);return/[0-9\-.]/.test(e)||s.includes(":")?!1:/^[a-zA-Z_][\w.\-]*$/.test(s)}function ia(s,e){var n;let t=s;for(;t;){let r=e?`xmlns:${e}`:"xmlns",i=(n=t.getAttribute)==null?void 0:n.call(t,r);if(i!=null)return i;t=t.parentNode}return null}var sa=g(()=>{je()});function oa(s,e,t){var i;let n=bn(s);if(n==="")return null;let r=e!==void 0?bn(e):(i=t==null?void 0:t.baseUri)!=null?i:"";try{return r?new URL(n,r).toString():new URL(n).toString()}catch(o){return null}}function aa(s){let e=bn(s);return encodeURIComponent(e).replace(/[!'()*]/g,t=>"%"+t.charCodeAt(0).toString(16).toUpperCase())}function ca(s){let e=bn(s);return encodeURI(e)}function ua(s){let e=bn(s);return encodeURI(e).replace(/\+/g,"%2B").replace(/'/g,"%27").replace(/"/g,"%22").replace(/</g,"%3C").replace(/>/g,"%3E")}function bn(s){if(s==null)return"";if(Array.isArray(s)){if(s.length===0)return"";s=s[0]}return String(s)}var la=g(()=>{});function pa(s,e){var r;let t=Ae(s,e);if(!t)return null;let n=t.nodeType;return n!==1&&n!==2&&n!==7?null:(r=t.nodeName)!=null?r:null}function ha(s,e){var r;let t=Ae(s,e);if(!t||t.nodeType!==1)return null;let n=(r=t.getAttribute)==null?void 0:r.call(t,"xsi:nil");return n==="true"||n==="1"}function ma(s){if(s==null)return[];let e=Array.isArray(s)?s:[s],t=[];for(let n of e)t.push(Zc(n));return t}function Zr(s,e){var r,i;let t=Ae(s,e);if(!t)return null;if("baseURI"in t&&t.baseURI)return t.baseURI;let n=(r=t.getAttribute)==null?void 0:r.call(t,"xml:base");return n||(t.parentNode&&ur(t.parentNode)?Zr([t.parentNode],e):(i=e.baseUri)!=null?i:null)}function fa(s,e){let t=Ae(s,e);return!t||t.nodeType!==9?null:"documentURI"in t&&t.documentURI?t.documentURI:null}function da(s,e){let t=Ae(s,e);if(!t)return null;let n=t,r=0,i=new Set;for(;n.parentNode&&r<1e4;){if(i.has(n))return n;i.add(n),n=n.parentNode,r++}return n}function ya(s,e,t){var o,a;let n=eu(s).toLowerCase();if(!n)return!1;let r=e!==void 0?Ae(e,t):t.node;if(!r)return!1;let i=r;for(;i;){let c=((o=i.getAttribute)==null?void 0:o.call(i,"xml:lang"))||((a=i.getAttribute)==null?void 0:a.call(i,"lang"));if(c){let u=c.toLowerCase();return u===n||u.startsWith(n+"-")}i=i.parentNode}return!1}function ga(s,e){let t=Ae(s,e);if(!t)return"";let n=Symbol.for("__xpath_node_id__");if(!t[n]){let r=Date.now().toString(36),i=Math.random().toString(36).substring(2,8),o=Math.floor(Math.random()*1e4).toString(36);t[n]=`n${r}${i}${o}`}return t[n]}function xa(s,e){let t=Ae(s,e);if(!t)return"";let n=[],r=t,i=0,o=new Set;for(;r&&i<1e4&&!o.has(r);){o.add(r);let a=tu(r);a&&n.unshift(a),r=r.parentNode,i++}return"/"+n.join("/")}function Na(s,e){let t=Ae(s,e);return t&&"childNodes"in t&&Array.isArray(t.childNodes)?t.childNodes.length>0:!1}function Ae(s,e){var t;if(s==null)return(t=e.node)!=null?t:null;if(Array.isArray(s)){if(s.length===0)return null;s=s[0]}return ur(s)?s:null}function ur(s){return typeof s=="object"&&s!==null&&"nodeType"in s}function Ea(s){return s.textContent!==void 0?s.textContent:s.nodeType===1||s.nodeType===9?ba(s):String(s)}function ba(s){var t;let e=[];if("childNodes"in s&&Array.isArray(s.childNodes))for(let n of s.childNodes)n.nodeType===3?e.push((t=n.textContent)!=null?t:""):n.nodeType===1&&e.push(ba(n));return e.join("")}function Zc(s){return s==null?"":typeof s=="string"||typeof s=="number"||typeof s=="boolean"?s:ur(s)?Ea(s):String(s)}function eu(s){if(s==null)return"";if(Array.isArray(s)){if(s.length===0)return"";s=s[0]}return ur(s)?Ea(s):String(s)}function tu(s){let e=s.nodeName||"node()";switch(s.nodeType){case 1:let n=s.parentNode;if(n&&"childNodes"in n&&Array.isArray(n.childNodes)){let r=n.childNodes.filter(i=>i.nodeType===1&&i.nodeName===e);if(r.length>1){let i=r.indexOf(s)+1;return`${e}[${i}]`}}return e;case 2:return`@${e}`;case 3:return"text()";case 7:return`processing-instruction(${e})`;case 8:return"comment()";case 9:return"";default:return"node()"}}var Pa=g(()=>{});var Xa={};ze(Xa,{XPathFunctionCall:()=>Pe,getBuiltInFunction:()=>Pn,getBuiltInFunctionArity:()=>lr});function Pn(s){return yt[s]}function lr(s){return ru[s]}var Ta,yt,ru,Pe,Tn=g(()=>{_();En();ke();_e();_s();Gs();io();Yr();ao();mo();_o();Bo();Ko();sa();la();Pa();Ta=s=>{var e;if(s&&typeof s=="object"){if(typeof s.stringValue=="function")return s.stringValue();if(Array.isArray(s)){if(s.length===0)return"";let t=s[0];return(e=t==null?void 0:t.textContent)!=null?e:String(t)}if(typeof s.textContent=="string")return s.textContent;if(s.nodeValue!==void 0&&s.nodeValue!==null)return String(s.nodeValue)}return String(s!=null?s:"")},yt={"upper-case":(s,e)=>Ta(e).toUpperCase(),"lower-case":(s,e)=>Ta(e).toLowerCase(),concat:(s,...e)=>e.map(t=>String(t)).join(""),"string-join":(s,e,t="")=>Array.isArray(e)?e.map(n=>String(n)).join(String(t)):String(e),substring:(s,e,t,n)=>{let r=String(e),i=Math.round(Number(t))-1;if(n===void 0)return r.substring(Math.max(0,i));let o=Math.round(Number(n)),a=Math.max(0,i);return r.substring(a,a+o)},"string-length":(s,e)=>String(e).length,"normalize-space":(s,e)=>String(e).trim().replace(/\s+/g," "),contains:(s,e,t)=>String(e).includes(String(t)),"starts-with":(s,e,t)=>String(e).startsWith(String(t)),"ends-with":(s,e,t)=>String(e).endsWith(String(t)),translate:(s,e,t,n)=>{let r=String(e),i=String(t),o=String(n),a="";for(let c of r){let u=i.indexOf(c);u===-1?a+=c:u<o.length&&(a+=o[u])}return a},replace:(s,e,t,n)=>{let r=new RegExp(String(t),"g");return String(e).replace(r,String(n))},matches:(s,e,t)=>new RegExp(String(t)).test(String(e)),tokenize:(s,e,t="\\s+")=>{let n=new RegExp(String(t));return String(e).split(n).filter(r=>r.length>0)},abs:(s,e)=>Math.abs(Number(e)),ceiling:(s,e)=>Math.ceil(Number(e)),floor:(s,e)=>Math.floor(Number(e)),round:(s,e)=>Math.round(Number(e)),"round-half-to-even":(s,e,t=0)=>{let n=Math.pow(10,Number(t)),r=Number(e)*n,i=Math.floor(r);return r-i===.5?(i%2===0?i:i+1)/n:Math.round(r)/n},number:(s,e)=>Number(e),true:()=>!0,false:()=>!1,not:(s,e)=>!e,boolean:(s,e)=>typeof e=="boolean"?e:typeof e=="number"?e!==0&&!isNaN(e):typeof e=="string"||Array.isArray(e)?e.length>0:!!e,count:(s,e)=>Array.isArray(e)?e.length:e==null?0:1,sum:(s,e)=>Array.isArray(e)?e.reduce((t,n)=>t+(Number(n)||0),0):Number(e)||0,avg:(s,e)=>Array.isArray(e)?e.length===0?null:e.reduce((n,r)=>n+(Number(r)||0),0)/e.length:Number(e),min:(s,e)=>Array.isArray(e)?e.length===0?null:Math.min(...e.map(t=>Number(t))):Number(e),max:(s,e)=>Array.isArray(e)?e.length===0?null:Math.max(...e.map(t=>Number(t))):Number(e),empty:(s,e)=>e==null?!0:Array.isArray(e)?e.length===0:!1,exists:(s,e)=>e==null?!1:Array.isArray(e)?e.length>0:!0,reverse:(s,e)=>Array.isArray(e)?[...e].reverse():[e],"distinct-values":(s,e)=>Array.isArray(e)?Array.from(new Set(e)):[e],subsequence:(s,e,t,n)=>{Array.isArray(e)||(e=[e]);let r=Math.round(Number(t))-1;if(n===void 0)return e.slice(Math.max(0,r));let i=Math.round(Number(n));return e.slice(Math.max(0,r),Math.max(0,r)+i)},"insert-before":(s,e,t,n)=>{Array.isArray(e)||(e=e===null?[]:[e]),Array.isArray(n)||(n=[n]);let r=Math.max(0,Math.round(Number(t))-1);return[...e.slice(0,r),...n,...e.slice(r)]},remove:(s,e,t)=>{Array.isArray(e)||(e=[e]);let n=Math.round(Number(t))-1;return n<0||n>=e.length?e:[...e.slice(0,n),...e.slice(n+1)]},position:s=>{var e;return(e=s.position)!=null?e:0},last:s=>{var e;return(e=s.size)!=null?e:0},string:(s,e)=>{var t,n,r,i;return e===void 0?(n=(t=s.node)==null?void 0:t.textContent)!=null?n:"":Array.isArray(e)&&e.length>0?(i=(r=e[0])==null?void 0:r.textContent)!=null?i:String(e[0]):String(e)},"local-name":(s,e)=>{var n;let t=e?Array.isArray(e)?e[0]:e:s.node;return(n=t==null?void 0:t.localName)!=null?n:""},"namespace-uri":(s,e)=>{var n;let t=e?Array.isArray(e)?e[0]:e:s.node;return(n=t==null?void 0:t.namespaceUri)!=null?n:""},name:(s,e)=>{var n;let t=e?Array.isArray(e)?e[0]:e:s.node;return(n=t==null?void 0:t.nodeName)!=null?n:""},"generate-id":(s,e)=>ga(e,s),path:(s,e)=>xa(e,s),"has-children":(s,e)=>Na(e,s),"for-each":Ss,filter:Cs,"fold-left":ws,"fold-right":As,"for-each-pair":Os,sort:no,apply:Rs,"function-name":vs,"function-arity":Is,"math:pi":Ms,"math:exp":ks,"math:exp10":Ds,"math:log":Vs,"math:log10":Fs,"math:pow":$s,"math:sqrt":Ls,"math:sin":Us,"math:cos":Ws,"math:tan":qs,"math:asin":Bs,"math:acos":zs,"math:atan":js,"math:atan2":Ys,head:(s,e)=>zr(e),tail:(s,e)=>jr(e),innermost:eo,outermost:to,"environment-variable":so,"available-environment-variables":oo,"array:size":yo,"array:get":go,"array:put":xo,"array:append":No,"array:subarray":Eo,"array:remove":bo,"array:insert-before":Po,"array:head":To,"array:tail":Xo,"array:reverse":So,"array:join":Co,"array:flatten":wo,"array:for-each":Ao,"array:filter":Oo,"array:fold-left":Ro,"array:fold-right":vo,"array:sort":Io,"map:size":ko,"map:keys":Do,"map:contains":Vo,"map:get":Fo,"map:put":$o,"map:entry":Lo,"map:merge":Uo,"map:for-each":Wo,"map:remove":qo,"parse-json":Yo,serialize:Go,"json-to-xml":Qo,"analyze-string":lo,"format-integer":po,"format-number":ho,"xs:string":(s,e)=>O(e,"string"),"xs:boolean":(s,e)=>O(e,"boolean"),"xs:decimal":(s,e)=>O(e,"decimal"),"xs:float":(s,e)=>O(e,"float"),"xs:double":(s,e)=>O(e,"double"),"xs:integer":(s,e)=>O(e,"integer"),"xs:duration":(s,e)=>O(e,"duration"),"xs:dateTime":(s,e)=>O(e,"dateTime"),"xs:date":(s,e)=>O(e,"date"),"xs:time":(s,e)=>O(e,"time"),"xs:anyURI":(s,e)=>O(e,"anyURI"),"xs:QName":(s,e)=>O(e,"QName"),"xs:untypedAtomic":(s,e)=>O(e,"untypedAtomic"),"xs:gYearMonth":(s,e)=>O(e,"gYearMonth"),"xs:gYear":(s,e)=>O(e,"gYear"),"xs:gMonthDay":(s,e)=>O(e,"gMonthDay"),"xs:gDay":(s,e)=>O(e,"gDay"),"xs:gMonth":(s,e)=>O(e,"gMonth"),"xs:hexBinary":(s,e)=>O(e,"hexBinary"),"xs:base64Binary":(s,e)=>O(e,"base64Binary"),"xs:long":(s,e)=>O(e,"long"),"xs:int":(s,e)=>O(e,"int"),"xs:short":(s,e)=>O(e,"short"),"xs:byte":(s,e)=>O(e,"byte"),"xs:nonPositiveInteger":(s,e)=>O(e,"nonPositiveInteger"),"xs:negativeInteger":(s,e)=>O(e,"negativeInteger"),"xs:nonNegativeInteger":(s,e)=>O(e,"nonNegativeInteger"),"xs:positiveInteger":(s,e)=>O(e,"positiveInteger"),"xs:unsignedLong":(s,e)=>O(e,"unsignedLong"),"xs:unsignedInt":(s,e)=>O(e,"unsignedInt"),"xs:unsignedShort":(s,e)=>O(e,"unsignedShort"),"xs:unsignedByte":(s,e)=>O(e,"unsignedByte"),QName:(s,e,t)=>Ho(e,t),"resolve-QName":(s,e,t)=>Jo(e,t),"prefix-from-QName":(s,e)=>Zo(e),"local-name-from-QName":(s,e)=>ea(e),"namespace-uri-from-QName":(s,e)=>ta(e),"in-scope-prefixes":(s,e)=>na(e),"namespace-uri-for-prefix":(s,e,t)=>ra(e,t),"resolve-uri":(s,e,t)=>oa(e,t,s),"encode-for-uri":(s,e)=>aa(e),"iri-to-uri":(s,e)=>ca(e),"escape-html-uri":(s,e)=>ua(e),root:(s,e)=>da(e,s),"base-uri":(s,e)=>Zr(e,s),"document-uri":(s,e)=>fa(e,s),nilled:(s,e)=>ha(e,s),"node-name":(s,e)=>pa(e,s),data:(s,e)=>ma(e),lang:(s,e,t)=>ya(e,t,s),"zero-or-one":(s,e)=>Ks(e),"one-or-more":(s,e)=>Hs(e),"exactly-one":(s,e)=>Js(e),unordered:(s,e)=>Qs(e)},ru={concat:[2,1/0],substring:[2,3],"string-join":[1,2],"normalize-space":[0,1],"string-length":[0,1],"local-name":[0,1],"namespace-uri":[0,1],name:[0,1],"generate-id":[0,1],path:[0,1],"has-children":[0,1],round:[1,2],"round-half-to-even":[1,2],string:[0,1],number:[0,1],replace:[3,4],matches:[2,3],tokenize:[1,3],"regex-group":[1,1],"current-group":[0,0],"current-grouping-key":[0,0],subsequence:[2,3],"insert-before":[3,3],remove:[2,2],"for-each":[2,2],filter:[2,2],"fold-left":[3,3],"fold-right":[3,3],"for-each-pair":[3,3],sort:[1,3],apply:[2,2],"function-name":[1,1],"function-arity":[1,1],"math:pi":[0,0],"math:exp":[1,1],"math:exp10":[1,1],"math:log":[1,1],"math:log10":[1,1],"math:pow":[2,2],"math:sqrt":[1,1],"math:sin":[1,1],"math:cos":[1,1],"math:tan":[1,1],"math:asin":[1,1],"math:acos":[1,1],"math:atan":[1,1],"math:atan2":[2,2],head:[1,1],tail:[1,1],innermost:[1,1],outermost:[1,1],"environment-variable":[1,1],"available-environment-variables":[0,0],"array:size":[1,1],"array:get":[2,2],"array:put":[3,3],"array:append":[2,2],"array:subarray":[2,3],"array:remove":[2,2],"array:insert-before":[3,3],"array:head":[1,1],"array:tail":[1,1],"array:reverse":[1,1],"array:join":[1,1],"array:flatten":[1,1],"array:for-each":[2,2],"array:filter":[2,2],"array:fold-left":[3,3],"array:fold-right":[3,3],"array:sort":[1,3],"map:size":[1,1],"map:keys":[1,1],"map:contains":[2,2],"map:get":[2,2],"map:put":[3,3],"map:entry":[2,2],"map:merge":[1,2],"map:for-each":[2,2],"map:remove":[2,2],"parse-json":[1,2],serialize:[1,2],"json-to-xml":[1,2],"analyze-string":[2,3],"format-integer":[2,3],"format-number":[2,3],"xs:string":[1,1],"xs:boolean":[1,1],"xs:decimal":[1,1],"xs:float":[1,1],"xs:double":[1,1],"xs:integer":[1,1],"xs:duration":[1,1],"xs:dateTime":[1,1],"xs:date":[1,1],"xs:time":[1,1],"xs:anyURI":[1,1],"xs:QName":[1,1],"xs:untypedAtomic":[1,1],"xs:gYearMonth":[1,1],"xs:gYear":[1,1],"xs:gMonthDay":[1,1],"xs:gDay":[1,1],"xs:gMonth":[1,1],"xs:hexBinary":[1,1],"xs:base64Binary":[1,1],"xs:long":[1,1],"xs:int":[1,1],"xs:short":[1,1],"xs:byte":[1,1],"xs:nonPositiveInteger":[1,1],"xs:negativeInteger":[1,1],"xs:nonNegativeInteger":[1,1],"xs:positiveInteger":[1,1],"xs:unsignedLong":[1,1],"xs:unsignedInt":[1,1],"xs:unsignedShort":[1,1],"xs:unsignedByte":[1,1],QName:[2,2],"resolve-QName":[2,2],"prefix-from-QName":[1,1],"local-name-from-QName":[1,1],"namespace-uri-from-QName":[1,1],"in-scope-prefixes":[1,1],"namespace-uri-for-prefix":[2,2],"resolve-uri":[1,2],"encode-for-uri":[1,1],"iri-to-uri":[1,1],"escape-html-uri":[1,1],root:[0,1],"base-uri":[0,1],"document-uri":[1,1],nilled:[1,1],"node-name":[1,1],data:[1,1],lang:[1,2],"zero-or-one":[1,1],"one-or-more":[1,1],"exactly-one":[1,1],unordered:[1,1]};Pe=class extends N{constructor(t,n){super();this.jsonConverter=new we;this.name=t,this.args=n}evaluate(t){var i,o,a,c,u,l;let n=this.args.map(p=>p.evaluate(t)),r=this.getConstructorType();if(r){if(n.length!==1)throw Ci(this.name,"1",n.length);let p=n[0];if(Array.isArray(p)){if(p.length===0)throw pe("single item","empty sequence",`constructor function ${this.name}`);if(p.length!==1)throw pe("single item",`sequence of ${p.length} items`,`constructor function ${this.name}`);return this.castConstructorValue(r,p[0])}if(p==null)throw pe("single item","empty sequence",`constructor function ${this.name}`);return this.castConstructorValue(r,p)}switch(this.name){case"last":return(i=t.size)!=null?i:0;case"position":return(o=t.position)!=null?o:0;case"count":return Array.isArray(n[0])?n[0].length:0;case"local-name":return this.localName(n,t);case"namespace-uri":return this.namespaceUri(n,t);case"name":return this.nodeName(n,t);case"string":return this.stringValue(n,t);case"concat":return n.map(h=>this.convertToString(h)).join("");case"starts-with":return this.convertToString(n[0]).startsWith(this.convertToString(n[1]));case"contains":return this.convertToString(n[0]).includes(this.convertToString(n[1]));case"substring-before":return this.substringBefore(n);case"substring-after":return this.substringAfter(n);case"substring":return this.substring(n);case"string-length":return this.stringLength(n,t);case"normalize-space":return this.normalizeSpace(n,t);case"translate":return this.translate(n);case"boolean":return this.toBoolean(n[0]);case"not":return!this.toBoolean(n[0]);case"true":return!0;case"false":return!1;case"lang":return this.lang(n,t);case"number":return this.toNumber(n,t);case"sum":return this.sum(n);case"floor":return Math.floor(Number(n[0]));case"ceiling":return Math.ceil(Number(n[0]));case"round":return Math.round(Number(n[0]));case"json-to-xml":return this.jsonToXml(n,t);case"regex-group":{let h=Math.floor(Number(n[0])),m=(a=t.extensions)==null?void 0:a.regexGroups;return m&&h>=0&&h<m.length&&(c=m[h])!=null?c:""}case"current-group":{let h=(u=t.extensions)==null?void 0:u.currentGroup;return h!=null?h:[]}case"current-grouping-key":{let h=(l=t.extensions)==null?void 0:l.currentGroupingKey;return h!=null?h:""}default:if(t.functions&&typeof t.functions[this.name]=="function")return t.functions[this.name](t,...n);let p=yt[this.name];if(!p&&this.name.startsWith("fn:")){let h=this.name.substring(3);p=yt[h]}if(!p&&this.name.startsWith("Q{")){let{namespace:h,localName:m}=this.parseEQName(this.name);p=yt[m],!p&&h==="http://www.w3.org/2005/xpath-functions/math"&&(p=yt["math:"+m]),!p&&h==="http://www.w3.org/2005/xpath-functions/array"&&(p=yt["array:"+m])}if(p)return p(t,...n);throw vt(this.name,"function")}}parseEQName(t){let n=t.match(/^Q\{([^}]*)\}(.+)$/);return n?{namespace:n[1],localName:n[2]}:{namespace:"",localName:t}}getConstructorType(){if(!this.name.includes(":"))return;let[t,n]=this.name.split(":");if(n&&t==="xs")return ye(n)}castConstructorValue(t,n){try{return t.cast(n)}catch(r){throw wi(n,this.name)}}toBoolean(t){return typeof t=="boolean"?t:typeof t=="number"?t!==0&&!isNaN(t):typeof t=="string"||Array.isArray(t)?t.length>0:!!t}toNumber(t,n){let r=o=>{let a=o.trim();return a.length===0?NaN:Number(a)};if(t.length===0)return r(this.stringValue([],n));let i=t[0];if(typeof i=="object"&&i!==null&&"numberValue"in i&&typeof i.numberValue=="function")return i.numberValue();if(Array.isArray(i)){if(i.length===0)return NaN;let o=i[0],a=this.getNodeStringValue(o);return r(a)}return typeof i=="string"?r(i):Number(i)}stringValue(t,n){var i,o;if(t.length===0)return(o=(i=n.node)==null?void 0:i.textContent)!=null?o:"";let r=t[0];return Array.isArray(r)&&r.length>0?this.getNodeStringValue(r[0]):String(r)}convertToString(t){if(Array.isArray(t)){if(t.length===0)return"";let n=t[0];return this.getNodeStringValue(n)}return String(t)}getNodeStringValue(t){var n;return t?typeof t=="string"?t:typeof t=="number"?String(t):typeof t=="boolean"?t?"true":"false":typeof t.textContent=="string"?t.textContent:t.nodeType===3||t.nodeType===2?(n=t.nodeValue)!=null?n:"":t.nodeType===1||t.nodeType===9||t.nodeType===11?this.getDescendantTextContent(t):t.nodeValue!==void 0&&t.nodeValue!==null?String(t.nodeValue):"":""}getDescendantTextContent(t){var r;if(!t.childNodes||t.childNodes.length===0)return"";let n="";for(let i=0;i<t.childNodes.length;i++){let o=t.childNodes[i];o.nodeType===3?n+=(r=o.nodeValue)!=null?r:"":o.nodeType===1&&(n+=this.getDescendantTextContent(o))}return n}stringLength(t,n){return t.length===0?this.stringValue([],n).length:this.convertToString(t[0]).length}normalizeSpace(t,n){return(t.length===0?this.stringValue([],n):this.convertToString(t[0])).trim().replace(/\s+/g," ")}substringBefore(t){let n=this.convertToString(t[0]),r=this.convertToString(t[1]),i=n.indexOf(r);return i===-1?"":n.substring(0,i)}substringAfter(t){let n=this.convertToString(t[0]),r=this.convertToString(t[1]),i=n.indexOf(r);return i===-1?"":n.substring(i+r.length)}substring(t){let n=this.convertToString(t[0]),r=Math.round(Number(t[1]))-1;if(t.length===2)return n.substring(Math.max(0,r));let i=Math.round(Number(t[2])),o=Math.max(0,r),a=Math.min(i-(o-r),n.length-o);return n.substring(o,o+a)}translate(t){let n=this.convertToString(t[0]),r=this.convertToString(t[1]),i=this.convertToString(t[2]),o="";for(let a of n){let c=r.indexOf(a);c===-1?o+=a:c<i.length&&(o+=i[c])}return o}localName(t,n){var i;let r=this.getNodeArg(t,n);return(i=r==null?void 0:r.localName)!=null?i:""}namespaceUri(t,n){var i;let r=this.getNodeArg(t,n);return(i=r==null?void 0:r.namespaceUri)!=null?i:""}nodeName(t,n){var i;let r=this.getNodeArg(t,n);return(i=r==null?void 0:r.nodeName)!=null?i:""}getNodeArg(t,n){return t.length>0&&Array.isArray(t[0])&&t[0].length>0?t[0][0]:n.node}sum(t){let n=t[0];return Array.isArray(n)?n.reduce((r,i)=>{var a;let o=Number((a=i==null?void 0:i.textContent)!=null?a:this.getNodeStringValue(i));return r+(isNaN(o)?0:o)},0):0}lang(t,n){var o,a;let r=String(t[0]).toLowerCase(),i=n.node;for(;i;){let c=((o=i.getAttribute)==null?void 0:o.call(i,"xml:lang"))||((a=i.getAttribute)==null?void 0:a.call(i,"lang"));if(c){let u=c.toLowerCase();return u===r||u.startsWith(r+"-")}i=i.parentNode}return!1}jsonToXml(t,n){if(n.xsltVersion&&n.xsltVersion!=="3.0")throw new Error('json-to-xml() is only supported in XSLT 3.0. Use version="3.0" in your stylesheet.');let r=t.length>0?String(t[0]):null,i;t.length>1&&typeof t[1]=="object"&&t[1]!==null&&(i=this.mapToOptions(t[1]));let o=this.jsonConverter.convert(r,i);return o?[o]:[]}mapToOptions(t){let n={};if(t.liberal!==void 0&&(n.liberal=!!t.liberal),t.duplicates!==void 0){let r=String(t.duplicates).toLowerCase();(r==="reject"||r==="use-first"||r==="retain")&&(n.duplicates=r)}return t.validate!==void 0&&(n.validate=!!t.validate),t.escape!==void 0&&(n.escape=!!t.escape),t.fallback!==void 0&&typeof t.fallback=="function"&&(n.fallback=t.fallback),n}}});var Xn,ei=g(()=>{_();Xn=class extends N{constructor(e,t){super(),this.bindings=e,this.returnExpr=t}evaluate(e){var r;let t=X({},(r=e.variables)!=null?r:{}),n=I(X({},e),{variables:t});for(let i of this.bindings){let o=i.expression.evaluate(n);t[i.variable]=o,n=I(X({},n),{variables:X({},t)})}return this.returnExpr.evaluate(n)}toString(){return`let ${this.bindings.map(t=>`$${t.variable} := ${t.expression}`).join(", ")} return ${this.returnExpr}`}}});var Sn,ti=g(()=>{_();Sn=class extends N{constructor(e,t){super(),this.left=e,this.right=t}evaluate(e){let t=this.left.evaluate(e),n=this.normalizeToSequence(t);if(n.length===0)return[];let r=[],i=n.length;for(let o=0;o<i;o++){let a=n[o],c=I(X({},e),{position:o+1,size:i});this.isNode(a)&&(c.node=a),c.contextItem=a;let u=this.right.evaluate(c);this.appendResults(r,u)}return r}normalizeToSequence(e){return e==null?[]:Array.isArray(e)?e:[e]}isNode(e){return e&&typeof e=="object"&&"nodeType"in e}appendResults(e,t){t!=null&&(Array.isArray(t)?e.push(...t):e.push(t))}toString(){return`${this.left} ! ${this.right}`}}});var Cn,ni=g(()=>{_();Cn=class extends N{constructor(e,t){super(),this.left=e,this.right=t}evaluate(e){let t=this.left.evaluate(e),n=this.right.evaluate(e),r=this.atomizeToString(t),i=this.atomizeToString(n);return r+i}atomizeToString(e){return e==null?"":typeof e=="object"&&"stringValue"in e&&typeof e.stringValue=="function"?e.stringValue():Array.isArray(e)?e.length===0?"":this.valueToString(e[0]):this.valueToString(e)}valueToString(e){return e==null?"":typeof e=="object"&&"stringValue"in e&&typeof e.stringValue=="function"?e.stringValue():typeof e=="string"?e:typeof e=="number"?Number.isNaN(e)?"NaN":e===1/0?"INF":e===-1/0?"-INF":String(e):typeof e=="boolean"?e?"true":"false":this.isNode(e)?this.getNodeStringValue(e):String(e)}isNode(e){return e&&typeof e=="object"&&"nodeType"in e}getNodeStringValue(e){return e?e.nodeType===3||e.nodeType===4?e.nodeValue||"":e.nodeType===2?e.value||e.nodeValue||"":e.nodeType===1||e.nodeType===9?e.textContent||"":(e.nodeType===7||e.nodeType===8)&&e.nodeValue||"":""}toString(){return`${this.left} || ${this.right}`}}});function ri(s){let e=[],t="",n=0;for(;n<s.length;){let r=s[n];if(r==="\\"&&n+1<s.length)switch(s[n+1]){case"`":t+="`",n+=2;break;case"{":t+="{",n+=2;break;case"}":t+="}",n+=2;break;case"n":t+=`
|
|
5
|
+
`,n+=2;break;case"r":t+="\r",n+=2;break;case"t":t+=" ",n+=2;break;case"\\":t+="\\",n+=2;break;default:t+=r,n++}else if(r==="{"&&n+1<s.length&&s[n+1]!=="{"){t.length>0&&(e.push(t),t="");let i=1,o=n+1;for(;o<s.length&&i>0;)s[o]==="{"&&s[o-1]!=="\\"?i++:s[o]==="}"&&s[o-1]!=="\\"&&i--,o++;if(i!==0)throw new Error("Unclosed expression in string template");let a=s.substring(n+1,o-1);e.push({expressionString:a}),n=o}else t+=r,n++}return t.length>0&&e.push(t),e}var wn,ii=g(()=>{wn=class{constructor(e){this.parts=e}evaluate(e){let t=[];for(let n of this.parts)if(typeof n=="string")t.push(n);else{let r=n.evaluate(e);t.push(this.valueToString(r))}return t.join("")}valueToString(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number")return Number.isNaN(e)?"NaN":e===1/0?"INF":e===-1/0?"-INF":String(e);if(typeof e=="boolean")return e?"true":"false";if(Array.isArray(e))return e.length===0?"":this.valueToString(e[0]);if(typeof e=="object"&&e!==null){if("nodeType"in e&&e.nodeType)return this.getNodeStringValue(e);if(typeof e.toString=="function"){let t=e.toString();if(t!=="[object Object]")return t}}return String(e)}getNodeStringValue(e){return e.textContent!==void 0?String(e.textContent):e.nodeType===3?e.data||e.textContent||"":e.nodeType===1||e.nodeType===9?this.getDescendantTextContent(e):""}getDescendantTextContent(e){var n,r;let t=[];if("childNodes"in e&&Array.isArray(e.childNodes))for(let i of e.childNodes)i.nodeType===3?t.push((r=(n=i.textContent)!=null?n:i.data)!=null?r:""):i.nodeType===1&&t.push(this.getDescendantTextContent(i));return t.join("")}}});var An,si=g(()=>{_();Tn();An=class extends N{constructor(e,t,n){super(),this.input=e,this.functionName=t,this.args=n}evaluate(e){let t=[this.input,...this.args];return new Pe(this.functionName,t).evaluate(e)}toString(){let e=this.args.length>0?this.args.map(t=>t.toString()).join(", "):"";return`${this.input} => ${this.functionName}(${e})`}}});var On,oi=g(()=>{pn();_();Tn();On=class extends N{constructor(e,t){super(),this.name=e,this.arity=t}evaluate(e){let t=this.resolveFunction(e);if(!t)throw new Error(`Unknown function: ${this.name}#${this.arity}`);return t}resolveFunction(e){let{namespace:t,localName:n}=this.parseNameWithNamespace(this.name,e),r=t,i=Pn(n),o=n;if(!i&&r===ln&&(i=Pn("math:"+n),o="math:"+n),i){if(lr(o)!==void 0&&!this.arityMatches(o,this.arity))throw new Error(`Function ${this.name} does not accept ${this.arity} arguments`);return{__isFunctionItem:!0,implementation:(...u)=>i(e,...u),arity:this.arity,name:n,namespace:r}}if(e.functionRegistry){let a=e.functionRegistry[n]||e.functionRegistry[this.name];if(a)return{__isFunctionItem:!0,implementation:a,arity:this.arity,name:n,namespace:r}}if(e.functions){let a=e.functions[this.name]||e.functions[n];if(a)return{__isFunctionItem:!0,implementation:a,arity:this.arity,name:n,namespace:r}}return null}arityMatches(e,t){let r={concat:[2,1/0],substring:[2,3],"string-join":[1,2],"normalize-space":[0,1],"string-length":[0,1],"local-name":[0,1],"namespace-uri":[0,1],name:[0,1],round:[1,2],"format-number":[2,3]}[e];return r?t>=r[0]&&t<=r[1]:t>=0&&t<=10}parseNameWithNamespace(e,t){if(e.startsWith("Q{")){let r=e.match(/^Q\{([^}]*)\}(.+)$/);if(r){let[,i,o]=r;return{namespace:i||void 0,localName:o}}}let n=e.indexOf(":");if(n>0){let r=e.substring(0,n),i=e.substring(n+1),o;return r==="fn"?o=un:r==="math"?o=ln:t.namespaces&&t.namespaces[r]&&(o=t.namespaces[r]),{namespace:o,localName:i}}return{namespace:un,localName:e}}toString(){return`${this.name}#${this.arity}`}}});var Rn,ai=g(()=>{_();Rn=class extends N{constructor(e,t,n){super(),this.params=e,this.body=t,this.returnType=n}evaluate(e){var i;let t=X({},(i=e.variables)!=null?i:{}),n=this;return{__isFunctionItem:!0,implementation:function(...o){let a=X({},t);for(let u=0;u<n.params.length;u++){let l=n.params[u],p=u<o.length?o[u]:null;a[l.name]=p}let c=I(X({},e),{variables:a});return n.body.evaluate(c)},arity:this.params.length,name:void 0,namespace:void 0}}toString(){let t=`function(${this.params.map(n=>{let r=`$${n.name}`;return n.type&&(r+=` as ${n.type}`),r}).join(", ")})`;return this.returnType&&(t+=` as ${this.returnType}`),t+=` { ${this.body} }`,t}}});function iu(s){return s&&typeof s=="object"&&s.__isFunctionItem===!0}var gt,ci=g(()=>{_();De();Ve();gt=class extends N{constructor(e,t){super(),this.functionExpr=e,this.args=t}evaluate(e){let t=this.functionExpr.evaluate(e);if(Q(t)){if(this.args.length!==1)throw new Error(`Map lookup expects 1 argument but got ${this.args.length}`);let n=String(this.args[0].evaluate(e)),r=t[n];if(r===void 0)throw new Error(`XPDY0002: Key "${n}" not found in map`);return r}if(re(t)){if(this.args.length!==1)throw new Error(`Array lookup expects 1 argument but got ${this.args.length}`);let n=Number(this.args[0].evaluate(e));return Fr(t,n)}if(iu(t)){let n=t;if(n.arity!==this.args.length)throw new Error(`Function expects ${n.arity} arguments but got ${this.args.length}`);let r=this.args.map(i=>i.evaluate(e));return n.implementation(...r)}if(typeof t=="function"){let n=this.args.map(r=>r.evaluate(e));return t(...n)}throw new Error("Dynamic function call: expression does not evaluate to a function item")}toString(){let e=this.args.map(t=>t.toString()).join(", ");return`${this.functionExpr}(${e})`}}});function su(s,e,t,n){return new xt(s,e,t,n)}function Sa(s){return new xt(s,null)}function ou(s,e){let t=new class extends N{evaluate(){return e}toString(){return JSON.stringify(e)}};return new xt(s,t)}function cu(s,e){return Sa(s).evaluate(e)}var xt,au,Ca=g(()=>{_();xt=class extends N{constructor(e,t,n,r){super(),this.tryExpr=e,this.catchExpr=t||null,this.errorPattern=n||null,this.errorVariableName=r||null}evaluate(e){try{let t=this.tryExpr.evaluate(e);return t&&typeof t=="object"&&typeof t.catch=="function"?t.catch(n=>this.handleError(n,e)):t}catch(t){return this.catchExpr?this.handleError(t,e):void 0}}handleError(e,t){let n=this.createCaughtError(e);if(this.errorPattern&&!this.matchesErrorPattern(n,this.errorPattern))throw e;let r={node:t.node,position:t.position,size:t.size,variables:t.variables?new Map(t.variables):new Map,functions:t.functions||{}};return this.errorVariableName&&r.variables.set(this.errorVariableName,n),r.variables.set("err:code",n.code),r.variables.set("err:description",n.description),r.variables.set("err:value",n.value),this.catchExpr.evaluate(r)}createCaughtError(e){let t="UNKNOWN",n="Unknown error",r="dynamic";return typeof e=="string"?n=e:e&&typeof e=="object"&&(e.message&&(n=e.message),e.code&&(t=e.code),e.type&&(r=e.type)),{code:t,description:n,value:e,stack:e==null?void 0:e.stack,type:r}}matchesErrorPattern(e,t){return t==="*"?!0:e.code===t||e.code.includes(t)}toString(){let e=`try { ${this.tryExpr.toString()} }`;return this.catchExpr&&(e+=" catch",this.errorPattern&&(e+=` (${this.errorPattern})`),e+=` { ${this.catchExpr.toString()} }`),e}};au={XPTY0004:"XPTY0004",FOAR0001:"FOAR0001",FORG0001:"FORG0001",FONS0004:"FONS0004",FORG0004:"FORG0004",FORG0005:"FORG0005",XPST0008:"XPST0008",XPTY0019:"XPTY0019",FODF1310:"FODF1310",XPST0051:"XPST0051"}});var ui,vn,li=g(()=>{Ve();De();ui=(r=>(r.NCNAME="NCNAME",r.INTEGER_LITERAL="INTEGER_LITERAL",r.PARENTHESIZED_EXPR="PARENTHESIZED_EXPR",r.WILDCARD="WILDCARD",r))(ui||{}),vn=class{constructor(e,t){this.baseExpr=e;this.keySpecifier=t}evaluate(e){let t;if(this.baseExpr)t=this.baseExpr.evaluate(e);else if(t=e.contextItem,t===void 0)throw new Error("XPDY0002: Context item is undefined for unary lookup");if(Q(t))return this.lookupInMap(t,this.keySpecifier,e);if(re(t))return this.lookupInArray(t,this.keySpecifier,e);throw new Error("XPTY0004: Lookup operator can only be applied to maps and arrays")}lookupInMap(e,t,n){switch(t.type){case"NCNAME":let r=t.value;return e[r];case"INTEGER_LITERAL":let i=t.value.toString();return e[i];case"PARENTHESIZED_EXPR":let a=t.value.evaluate(n),c=this.atomizeToString(a);return e[c];case"WILDCARD":return Object.keys(e).filter(u=>!u.startsWith("__")).map(u=>e[u]);default:throw new Error("FOAY0001: Invalid key specifier for map lookup")}}lookupInArray(e,t,n){switch(t.type){case"INTEGER_LITERAL":let r=t.value;if(r<1)throw new Error("FOAY0001: Array index must be positive");if(r>e.members.length)throw new Error("FOAY0001: Array index out of bounds");return e.members[r-1];case"PARENTHESIZED_EXPR":let o=t.value.evaluate(n),a=this.atomizeToNumber(o);if(a<1)throw new Error("FOAY0001: Array index must be positive");if(a>e.members.length)throw new Error("FOAY0001: Array index out of bounds");return e.members[a-1];case"WILDCARD":return this.flattenArrayMembers(e.members);case"NCNAME":throw new Error("XPTY0004: NCName key not valid for array lookup");default:throw new Error("FOAY0001: Invalid key specifier for array lookup")}}flattenArrayMembers(e){let t=[];for(let n of e)re(n)?t.push(...this.flattenArrayMembers(n.members)):t.push(n);return t}atomizeToString(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return e.toString();if(Array.isArray(e))return e.length===0?"":e.length===1?this.atomizeToString(e[0]):this.atomizeToString(e[0]);if(typeof e=="object"&&e.$isXPathMap)throw new Error("XPTY0004: Cannot atomize a map to string");if(typeof e=="object"&&(e.nodeType||e.nodeName||e.textContent))return(e.textContent||e.value||"").toString();if(typeof e=="function")throw new Error("XPTY0004: Cannot atomize a function item");try{return String(e)}catch(t){throw new Error("XPTY0004: Cannot atomize value")}}atomizeToNumber(e){if(e==null)throw new Error("XPTY0004: Cannot convert empty sequence to number");if(typeof e=="number")return e;if(typeof e=="string"){let t=parseFloat(e);if(isNaN(t))throw new Error("FORG0001: Invalid number");return t}if(typeof e=="boolean")throw new Error("XPTY0004: Cannot convert boolean to number for array index");if(Array.isArray(e)){if(e.length===0)throw new Error("XPTY0004: Cannot convert empty sequence to number");if(e.length===1)return this.atomizeToNumber(e[0]);throw new Error("XPTY0004: Cannot convert sequence to single number")}if(typeof e=="object"&&e.$isXPathMap)throw new Error("XPTY0004: Cannot atomize a map to number");if(typeof e=="object"&&(e.nodeType||e.nodeName||e.textContent)){let t=(e.textContent||e.value||"").toString(),n=parseFloat(t);if(isNaN(n))throw new Error("FORG0001: Invalid number from node");return n}throw typeof e=="function"?new Error("XPTY0004: Cannot atomize a function item"):new Error("FORG0001: Cannot convert to number")}toString(){let e=this.baseExpr?this.baseExpr.toString():"",t;switch(this.keySpecifier.type){case"NCNAME":t=this.keySpecifier.value;break;case"INTEGER_LITERAL":t=this.keySpecifier.value.toString();break;case"PARENTHESIZED_EXPR":t=`(${this.keySpecifier.value})`;break;case"WILDCARD":t="*";break;default:t="?"}return e+"?"+t}}});var $e={};ze($e,{CommaExpression:()=>yn,EmptySequenceExpression:()=>xn,FilteredPathExpression:()=>_t,GeneralComparisonExpression:()=>qr,JsonToXmlConverter:()=>we,KeySpecifierType:()=>ui,NodeComparisonExpression:()=>Br,ParenthesizedExpression:()=>Ur,RangeExpression:()=>gn,StringTemplateExpression:()=>wn,TryExpression:()=>xt,ValueComparisonExpression:()=>Wr,XPathArithmeticExpression:()=>Ye,XPathArrowExpression:()=>An,XPathBinaryExpression:()=>rt,XPathCastableExpression:()=>fn,XPathConditionalExpression:()=>Dt,XPathCurlyBraceArrayConstructor:()=>pt,XPathDynamicFunctionCall:()=>gt,XPathExpression:()=>N,XPathFilterExpression:()=>It,XPathForExpression:()=>Vt,XPathFunctionCall:()=>Pe,XPathInlineFunctionExpression:()=>Rn,XPathInstanceOfExpression:()=>mn,XPathLetExpression:()=>Xn,XPathLocationPath:()=>Ee,XPathLogicalExpression:()=>it,XPathLookupExpression:()=>vn,XPathMapConstructorExpression:()=>ut,XPathNamedFunctionRef:()=>On,XPathNumberLiteral:()=>Rt,XPathPredicate:()=>Nn,XPathQuantifiedExpression:()=>Ft,XPathSimpleMapExpression:()=>Sn,XPathSquareBracketArrayConstructor:()=>lt,XPathStep:()=>Ne,XPathStringConcatExpression:()=>Cn,XPathStringLiteral:()=>Ot,XPathTreatExpression:()=>dn,XPathUnaryExpression:()=>kt,XPathUnionExpression:()=>Ce,XPathVariableReference:()=>xe,XSLT3ErrorCodes:()=>au,concatenateSequences:()=>Fc,createSequence:()=>Dc,createTryExpression:()=>su,createTryOnly:()=>Sa,createTryWithFallback:()=>ou,createXPathArray:()=>B,flattenSequence:()=>Vc,getArrayMember:()=>Fr,getArraySize:()=>pc,getBuiltInFunction:()=>Pn,getBuiltInFunctionArity:()=>lr,getNodeId:()=>$c,isXPathArray:()=>re,isXPathMap:()=>Q,isXPathNode:()=>Ns,parseStringTemplate:()=>ri,safeEvaluate:()=>cu});var ce=g(()=>{_();bi();Ai();Oi();Ri();vi();Ii();_i();Mi();ki();Di();Vi();Fi();ds();ys();gs();xs();Es();bs();Ps();Ts();Xs();Tn();En();ei();ti();ni();ii();si();oi();ai();ci();Ca();De();Ve();li()});var Mu={};ze(Mu,{ExprContext:()=>qe,XDocument:()=>ue,XNode:()=>k,XPath:()=>tt,XmlParser:()=>Ue,Xslt:()=>Ir,domDocumentToXDocument:()=>Ia,xmlEscapeText:()=>_n,xmlTransformedText:()=>Mn});var C=class{constructor(e,t){this.type=e,this.lexeme=t}};var Ei="1.0",sc={ancestor:{type:"LOCATION",value:"ancestor"},"ancestor-or-self":{type:"LOCATION",value:"ancestor-or-self"},attribute:{type:"LOCATION",value:"attribute"},child:{type:"LOCATION",value:"child"},descendant:{type:"LOCATION",value:"descendant"},"descendant-or-self":{type:"LOCATION",value:"descendant-or-self"},following:{type:"LOCATION",value:"following"},"following-sibling":{type:"LOCATION",value:"following-sibling"},namespace:{type:"LOCATION",value:"namespace"},parent:{type:"LOCATION",value:"parent"},preceding:{type:"LOCATION",value:"preceding"},"preceding-sibling":{type:"LOCATION",value:"preceding-sibling"},self:{type:"LOCATION",value:"self"},node:{type:"NODE_TYPE",value:"node"},text:{type:"NODE_TYPE",value:"text"},comment:{type:"NODE_TYPE",value:"comment"},"processing-instruction":{type:"NODE_TYPE",value:"processing-instruction"},and:{type:"OPERATOR",value:"and"},or:{type:"OPERATOR",value:"or"},div:{type:"OPERATOR",value:"div"},mod:{type:"OPERATOR",value:"mod"},last:{type:"FUNCTION",value:"last"},position:{type:"FUNCTION",value:"position"},count:{type:"FUNCTION",value:"count"},id:{type:"FUNCTION",value:"id"},"local-name":{type:"FUNCTION",value:"local-name"},"namespace-uri":{type:"FUNCTION",value:"namespace-uri"},name:{type:"FUNCTION",value:"name"},string:{type:"FUNCTION",value:"string"},concat:{type:"FUNCTION",value:"concat"},"starts-with":{type:"FUNCTION",value:"starts-with"},contains:{type:"FUNCTION",value:"contains"},"substring-before":{type:"FUNCTION",value:"substring-before"},"substring-after":{type:"FUNCTION",value:"substring-after"},substring:{type:"FUNCTION",value:"substring"},"string-length":{type:"FUNCTION",value:"string-length"},"normalize-space":{type:"FUNCTION",value:"normalize-space"},translate:{type:"FUNCTION",value:"translate"},boolean:{type:"FUNCTION",value:"boolean"},not:{type:"FUNCTION",value:"not"},true:{type:"FUNCTION",value:"true"},false:{type:"FUNCTION",value:"false"},lang:{type:"FUNCTION",value:"lang"},number:{type:"FUNCTION",value:"number"},sum:{type:"FUNCTION",value:"sum"},floor:{type:"FUNCTION",value:"floor"},ceiling:{type:"FUNCTION",value:"ceiling"},round:{type:"FUNCTION",value:"round"}},oc={if:{type:"RESERVED_WORD",value:"if"},then:{type:"RESERVED_WORD",value:"then"},else:{type:"RESERVED_WORD",value:"else"},for:{type:"RESERVED_WORD",value:"for"},in:{type:"RESERVED_WORD",value:"in"},return:{type:"RESERVED_WORD",value:"return"},some:{type:"RESERVED_WORD",value:"some"},every:{type:"RESERVED_WORD",value:"every"},satisfies:{type:"RESERVED_WORD",value:"satisfies"},instance:{type:"RESERVED_WORD",value:"instance"},of:{type:"RESERVED_WORD",value:"of"},cast:{type:"RESERVED_WORD",value:"cast"},as:{type:"RESERVED_WORD",value:"as"},castable:{type:"RESERVED_WORD",value:"castable"},treat:{type:"RESERVED_WORD",value:"treat"},to:{type:"RESERVED_WORD",value:"to"}},ac={let:{type:"RESERVED_WORD",value:"let"},function:{type:"RESERVED_WORD",value:"function"}},cc={map:{type:"RESERVED_WORD",value:"map"},array:{type:"RESERVED_WORD",value:"array"}};function uc(s){let e=X({},sc);return s!=="1.0"&&Object.assign(e,oc),(s==="3.0"||s==="3.1")&&Object.assign(e,ac),s==="3.1"&&Object.assign(e,cc),e}var Ie=class{constructor(e){var t;typeof e=="object"?this.version=(t=e.version)!=null?t:Ei:this.version=e!=null?e:Ei,this.reservedWords=uc(this.version)}getVersion(){return this.version}registerFunctions(e){this.additionalFunctions||(this.additionalFunctions=new Set);for(let t of e)this.additionalFunctions.add(t)}isAlpha(e){return/^[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]$/.test(e)}isAlphaNumeric(e){return/^[a-zA-Z0-9_\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0300-\u036F\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]$/.test(e)}isNumber(e){return/^[0-9]$/.test(e)}isWhitespace(e){return/^[\s\t\n\r]$/.test(e)}peek(){return this.expression[this.current]}peekNext(){return this.expression[this.current+1]}next(){return this.expression[this.current++]}match(e){return this.current>=this.expression.length||this.expression[this.current]!==e?!1:(this.current++,!0)}parseIdentifier(e){let t=e;for(;this.current<this.expression.length;){let r=this.expression[this.current];if(this.isAlphaNumeric(r))t+=this.next();else if(r==="-"){let i=this.expression[this.current+1];if(i&&this.isAlphaNumeric(i))for(this.current++,t+="-";this.current<this.expression.length&&this.isAlphaNumeric(this.expression[this.current]);)t+=this.next();else break}else break}let n=this.reservedWords[t.toLowerCase()];if(n)return new C(n.type,t);if(this.additionalFunctions&&this.additionalFunctions.has(t))return new C("FUNCTION",t);if(t.length>0)return new C("IDENTIFIER",t);throw new Error(`Invalid identifier: ${t}`)}parseString(e){let t="";for(;this.current<this.expression.length&&this.expression[this.current]!==e;)t+=this.next();if(this.current>=this.expression.length)throw new Error("Unterminated string literal");return this.next(),new C("STRING",t)}parseStringTemplate(){let e="",t=0;for(;this.current<this.expression.length;){let n=this.expression[this.current];if(n==="\\"&&this.current+1<this.expression.length){let r=this.expression[this.current+1];if(r==="`"||r==="{"||r==="}"||r==="n"||r==="r"||r==="t"||r==="\\"){e+=n,this.next(),e+=this.next();continue}}if(n==="`"&&t===0)return this.next(),new C("STRING_TEMPLATE",e);n==="{"?t++:n==="}"&&t--,e+=this.next()}throw new Error("Unterminated string template")}parseNumber(e){let t=e;for(;this.current<this.expression.length&&this.isNumber(this.expression[this.current])&&this.expression[this.current]!==".";)t+=this.next();if(this.current<this.expression.length&&this.expression[this.current]===".")for(t+=this.next();this.current<this.expression.length&&this.isNumber(this.expression[this.current]);)t+=this.next();if(t.length>0)return new C("NUMBER",t);throw new Error(`Invalid number: ${t}`)}parseEQName(){this.next();let e="";for(;this.current<this.expression.length&&this.expression[this.current]!=="}";)e+=this.next();if(this.current>=this.expression.length)throw new Error("Unterminated EQName: missing '}' after URI");this.next();let t="";if(this.current<this.expression.length&&this.isAlpha(this.expression[this.current]))for(;this.current<this.expression.length;){let r=this.expression[this.current];if(this.isAlphaNumeric(r)||r==="-"||r==="_")t+=this.next();else break}if(t.length===0)throw new Error(`EQName missing local name after '}': Q{${e}}`);let n=`Q{${e}}${t}`;return new C("EQNAME",n)}scanToken(){let e=this.next();if(this.isWhitespace(e))return null;switch(e){case"@":return new C("AT",e);case"$":return new C("DOLLAR",e);case"|":return this.match("|")?new C("CONCAT","||"):new C("PIPE",e);case"#":return new C("HASH",e);case"{":return new C("OPEN_CURLY_BRACKET",e);case"}":return new C("CLOSE_CURLY_BRACKET",e);case"[":return new C("OPEN_SQUARE_BRACKET",e);case"]":return new C("CLOSE_SQUARE_BRACKET",e);case"(":return new C("OPEN_PAREN",e);case")":return new C("CLOSE_PAREN",e);case"+":return new C("PLUS",e);case"-":return new C("MINUS",e);case"*":return new C("ASTERISK",e);case",":return new C("COMMA",e);case"?":return new C("QUESTION",e);case"Q":return this.peek()==="{"?this.parseEQName():this.parseIdentifier(e);case".":return this.match(".")?new C("DOT_DOT",".."):this.peek()&&this.isNumber(this.peek())?this.parseNumber(e):new C("DOT",e);case"/":return this.match("/")?new C("DOUBLE_SLASH","//"):new C("SLASH",e);case":":return this.match(":")?new C("COLON_COLON","::"):this.match("=")?new C("ASSIGNMENT",":="):new C("COLON",e);case"=":return this.match(">")?new C("FAT_ARROW","=>"):new C("EQUALS",e);case"!":return this.match("=")?new C("NOT_EQUALS","!="):new C("SIMPLE_MAP",e);case"<":return this.match("=")?new C("LESS_THAN_OR_EQUAL","<="):new C("LESS_THAN",e);case">":return this.match("=")?new C("GREATER_THAN_OR_EQUAL",">="):new C("GREATER_THAN",e);case"'":return this.parseString("'");case'"':return this.parseString('"');case"`":return this.parseStringTemplate();default:if(this.isNumber(e))return this.parseNumber(e);if(this.isAlpha(e))return this.parseIdentifier(e);throw new Error(`Unexpected character: ${e}`)}}scan(e){for(this.expression=e,this.tokens=[],this.current=0;this.current<this.expression.length;){let t=this.scanToken();t!==null&&this.tokens.push(t)}return this.tokens}};ce();Qe();je();var uu=(s,e)=>(new Set(s).has(e)||s.push(e),Array.from(new Set(s)));function wa(s){var r,i,o,a,c,u,l,p,h,m;let e=s!=null&&s.reservedFunctionNames?new Set(s.reservedFunctionNames):new Set(Xi),t=(r=s==null?void 0:s.defaultCollation)!=null?r:_r,n=uu((i=s==null?void 0:s.collations)!=null?i:[_r],t);return{schemaTypes:(o=s==null?void 0:s.schemaTypes)!=null?o:{},elementDeclarations:(a=s==null?void 0:s.elementDeclarations)!=null?a:{},attributeDeclarations:(c=s==null?void 0:s.attributeDeclarations)!=null?c:{},defaultElementNamespace:(u=s==null?void 0:s.defaultElementNamespace)!=null?u:"",defaultTypeNamespace:(l=s==null?void 0:s.defaultTypeNamespace)!=null?l:R,functionSignatures:(p=s==null?void 0:s.functionSignatures)!=null?p:{},defaultFunctionNamespace:(h=s==null?void 0:s.defaultFunctionNamespace)!=null?h:Ti,reservedFunctionNames:e,collations:n,defaultCollation:t,variableTypes:(m=s==null?void 0:s.variableTypes)!=null?m:{},contextItemType:s==null?void 0:s.contextItemType}}function Aa(s){let e=[],t=new Set;for(let n of s.functions)t.has(n.name)&&e.push(`Duplicate function name: ${n.name}`),t.add(n.name),n.minArgs<0&&e.push(`Function ${n.name}: minArgs cannot be negative`),n.maxArgs!==void 0&&n.maxArgs<n.minArgs&&e.push(`Function ${n.name}: maxArgs cannot be less than minArgs`),typeof n.implementation!="function"&&e.push(`Function ${n.name}: implementation must be a function`);return e}_e();var Oa={XPWD0001:{code:"XPWD0001",severity:"deprecation",category:"deprecation",title:"Namespace axis deprecated",description:"The namespace axis (namespace::) is deprecated in XPath 2.0 and may not be supported in all implementations. Consider using fn:namespace-uri-for-prefix() or fn:in-scope-prefixes() instead.",migration:"Replace namespace::* with fn:in-scope-prefixes(.) to get namespace prefixes, or use fn:namespace-uri-for-prefix($prefix, .) to get namespace URIs.",specReference:"XPath 2.0 Section 3.2.1.1"},XPWD0002:{code:"XPWD0002",severity:"deprecation",category:"deprecation",title:"Implicit string conversion",description:"Implicit conversion of node-sets to strings using the first node is deprecated. In XPath 2.0, this requires explicit conversion using fn:string() or data().",migration:"Use fn:string($nodeset) or fn:data($nodeset) for explicit conversion.",specReference:"XPath 2.0 Appendix I.2"},XPWC0001:{code:"XPWC0001",severity:"warning",category:"compatibility",title:"XPath 1.0 compatibility mode active",description:"XPath 1.0 compatibility mode is enabled. Some XPath 2.0 type safety features are relaxed to maintain backward compatibility.",migration:"Consider migrating to XPath 2.0 semantics for improved type safety.",specReference:"XPath 2.0 Section 3.6"},XPWC0002:{code:"XPWC0002",severity:"warning",category:"compatibility",title:"String comparison in XPath 2.0",description:"String comparisons in XPath 2.0 are performed using Unicode codepoint collation by default, which may produce different results than XPath 1.0.",migration:"Use explicit collation specification if locale-specific comparison is needed.",specReference:"XPath 2.0 Appendix I.4"},XPWC0003:{code:"XPWC0003",severity:"warning",category:"compatibility",title:"Empty sequence handling differs",description:"In XPath 2.0, operations on empty sequences may return empty sequences instead of NaN or false as in XPath 1.0.",migration:"Use explicit empty sequence handling with fn:empty() or default values.",specReference:"XPath 2.0 Appendix I.3"},XPWT0001:{code:"XPWT0001",severity:"warning",category:"type-coercion",title:"Implicit numeric conversion",description:"Value is being implicitly converted to a number. In XPath 2.0, this requires explicit conversion in strict mode.",migration:"Use xs:decimal(), xs:double(), or number() for explicit conversion.",specReference:"XPath 2.0 Appendix I.2"},XPWT0002:{code:"XPWT0002",severity:"warning",category:"type-coercion",title:"Implicit boolean conversion",description:"Value is being implicitly converted to boolean using XPath 1.0 rules. In XPath 2.0, this is called Effective Boolean Value (EBV).",migration:"Use fn:boolean() for explicit conversion.",specReference:"XPath 2.0 Section 2.4.3"},XPWT0003:{code:"XPWT0003",severity:"info",category:"type-coercion",title:"Numeric type promotion",description:"Numeric value is being promoted in the type hierarchy (integer \u2192 decimal \u2192 float \u2192 double). This may result in precision loss.",migration:"Consider using explicit casting if precision is important.",specReference:"XPath 2.0 Appendix B.1"},XPWB0001:{code:"XPWB0001",severity:"warning",category:"behavior-change",title:"Arithmetic with empty sequence",description:"In XPath 2.0, arithmetic operations with empty sequences return empty sequences, not NaN as in XPath 1.0.",migration:"Handle empty sequences explicitly before arithmetic operations.",specReference:"XPath 2.0 Appendix I.3"},XPWB0002:{code:"XPWB0002",severity:"warning",category:"behavior-change",title:"Comparison with empty sequence",description:"In XPath 2.0, value comparisons (eq, ne, etc.) with empty sequences return empty sequences, not false.",migration:"Use fn:empty() or fn:exists() to check for empty sequences before comparison.",specReference:"XPath 2.0 Appendix I.3"},XPWB0003:{code:"XPWB0003",severity:"warning",category:"behavior-change",title:"Multiple values in singleton context",description:"A sequence with multiple items is being used where a single item is expected. In XPath 2.0, this may raise a type error.",migration:"Use predicates or fn:head() to select a single item.",specReference:"XPath 2.0 Section 2.4.4"},XPWB0004:{code:"XPWB0004",severity:"warning",category:"behavior-change",title:"String value of nodes",description:"The string value of typed nodes in XPath 2.0 may differ from XPath 1.0 when schema type information is present.",migration:"Use fn:string() for consistent string conversion.",specReference:"XPath 2.0 Appendix I.1"},XPWP0001:{code:"XPWP0001",severity:"info",category:"performance",title:"Descendant axis on large document",description:"Using descendant or descendant-or-self axis on large documents may impact performance. Consider using more specific path expressions.",migration:"Use more specific paths or indexes if available."},XPWP0002:{code:"XPWP0002",severity:"info",category:"performance",title:"General comparison on sequences",description:"General comparisons (=, !=, etc.) on sequences perform existential quantification, which may be slower than value comparisons on single items.",migration:"Use value comparisons (eq, ne, etc.) when comparing single values.",specReference:"XPath 2.0 Section 3.5.2"}},lu={enabled:!0,minSeverity:"info",suppressCategories:[],suppressCodes:[],handler:()=>{},logToConsole:!1,maxWarnings:100,emitOnce:!0},Ra={info:0,warning:1,deprecation:2},pi=class{constructor(e){this.warnings=[];this.emittedCodes=new Set;this.config=X(X({},lu),e)}emit(e,t,n){if(!this.config.enabled)return;let r=Oa[e];if(!r){this.addWarning({code:e,message:`Unknown warning: ${e}`,severity:"warning",category:"compatibility",context:t,expression:n});return}if(this.config.suppressCodes.includes(e)||this.config.suppressCategories.includes(r.category)||Ra[r.severity]<Ra[this.config.minSeverity]||this.config.emitOnce&&this.emittedCodes.has(e)||this.warnings.length>=this.config.maxWarnings)return;let i={code:r.code,message:r.description,severity:r.severity,category:r.category,context:t,expression:n};this.addWarning(i),this.emittedCodes.add(e)}emitCustom(e){this.config.enabled&&(this.warnings.length>=this.config.maxWarnings||this.config.emitOnce&&this.emittedCodes.has(e.code)||(this.addWarning(e),this.emittedCodes.add(e.code)))}addWarning(e){if(this.warnings.push(e),this.config.handler&&this.config.handler(e),this.config.logToConsole){let t=e.severity==="deprecation"?"[DEPRECATED]":e.severity==="warning"?"[WARNING]":"[INFO]";console.warn(`${t} ${e.code}: ${e.message}`)}}getWarnings(){return this.warnings}getWarningsBySeverity(e){return this.warnings.filter(t=>t.severity===e)}getWarningsByCategory(e){return this.warnings.filter(t=>t.category===e)}hasWarnings(){return this.warnings.length>0}count(){return this.warnings.length}clear(){this.warnings=[],this.emittedCodes.clear()}formatReport(){if(this.warnings.length===0)return"No warnings.";let e=[];e.push(`XPath Warnings Report (${this.warnings.length} warning${this.warnings.length===1?"":"s"}):`),e.push("");let t={};for(let n of this.warnings){let r=n.category;t[r]||(t[r]=[]),t[r].push(n)}for(let n of Object.keys(t)){let r=t[n];e.push(`## ${pu(n)}`);for(let i of r){let o=Oa[i.code];e.push(` ${i.code}: ${(o==null?void 0:o.title)||i.message}`),i.context&&e.push(` Context: ${i.context}`),o!=null&&o.migration&&e.push(` Migration: ${o.migration}`)}e.push("")}return e.join(`
|
|
6
|
+
`)}};function pu(s){switch(s){case"deprecation":return"Deprecated Features";case"compatibility":return"Compatibility Issues";case"performance":return"Performance Considerations";case"type-coercion":return"Type Coercion";case"behavior-change":return"Behavior Changes";default:return s}}function hi(s){return new pi(s)}var Nt=class{constructor(e){this.tokens=[];this.current=0;var t,n,r,i;if(this.options={strict:(t=e==null?void 0:e.strict)!=null?t:!0,version:e==null?void 0:e.version,cache:e==null?void 0:e.cache,extensions:e==null?void 0:e.extensions,enableNamespaceAxis:(n=e==null?void 0:e.enableNamespaceAxis)!=null?n:!1,staticContext:(r=e==null?void 0:e.staticContext)!=null?r:wa(),xpath10CompatibilityMode:(i=e==null?void 0:e.xpath10CompatibilityMode)!=null?i:!1,warningConfig:e==null?void 0:e.warningConfig,warningCollector:e==null?void 0:e.warningCollector},this.staticContext=this.options.staticContext,this.options.warningCollector?this.warningCollector=this.options.warningCollector:this.options.warningConfig?this.warningCollector=hi(this.options.warningConfig):this.warningCollector=hi({logToConsole:!1}),this.options.extensions){let o=Aa(this.options.extensions);if(o.length>0)throw new Error(`Invalid XSLT extensions: ${o.join(", ")}`);this.extensions=this.options.extensions}}getWarningCollector(){return this.warningCollector}ensureVersionSupport(e,t){var r;let n=(r=this.options.version)!=null?r:t;if(this.options.version=n,this.options.strict!==!1&&!e.includes(n))throw new Error(`XPath version ${n} is not supported by ${this.constructor.name}. Supported versions: ${e.join(", ")}`)}getOptions(){return this.options}parse(e){if(this.tokens=e,this.current=0,this.options.xpath10CompatibilityMode&&this.options.version&&this.options.version!=="1.0"&&this.warningCollector.emit("XPWC0001",`XPath ${this.options.version} with compatibility mode`,e.map(n=>n.lexeme).join("")),e.length===0)throw ne("Empty expression");let t=this.parseExpr();if(!this.isAtEnd())throw ne(`Unexpected token: ${this.peek().lexeme}`);return t}peek(){return this.tokens[this.current]}peekNext(){return this.tokens[this.current+1]}previous(){return this.tokens[this.current-1]}isAtEnd(){return this.current>=this.tokens.length}advance(){return this.isAtEnd()||this.current++,this.previous()}check(e){return this.isAtEnd()?!1:this.peek().type===e}checkLexeme(e){return this.isAtEnd()?!1:this.peek().lexeme===e}match(...e){for(let t of e)if(this.check(t))return this.advance(),!0;return!1}consume(e,t){var n,r;if(this.check(e))return this.advance();throw ne(`${t}. Got: ${(r=(n=this.peek())==null?void 0:n.lexeme)!=null?r:"EOF"}`)}parseExpr(){return this.parseOrExpr()}parseOrExpr(){let e=this.parseAndExpr();for(;this.check("OPERATOR")&&this.peek().lexeme==="or";){this.advance();let t=this.parseAndExpr();e=new it(e,t,"or")}return e}parseAndExpr(){let e=this.parseEqualityExpr();for(;this.check("OPERATOR")&&this.peek().lexeme==="and";){this.advance();let t=this.parseEqualityExpr();e=new it(e,t,"and")}return e}parseEqualityExpr(){let e=this.parseRelationalExpr();for(;this.match("EQUALS","NOT_EQUALS");){let t=this.previous().lexeme,n=this.parseRelationalExpr();e=new rt(e,n,t)}return e}parseRelationalExpr(){let e=this.parseAdditiveExpr();for(;this.match("LESS_THAN","GREATER_THAN","LESS_THAN_OR_EQUAL","GREATER_THAN_OR_EQUAL");){let t=this.previous().lexeme,n=this.parseAdditiveExpr();e=new rt(e,n,t)}return e}parseAdditiveExpr(){let e=this.parseMultiplicativeExpr();for(;this.match("PLUS","MINUS");){let t=this.previous().lexeme,n=this.parseMultiplicativeExpr();e=new Ye(e,n,t)}return e}parseMultiplicativeExpr(){let e=this.parseUnaryExpr();for(;;)if(this.match("ASTERISK")){let t=this.parseUnaryExpr();e=new Ye(e,t,"*")}else if(this.check("OPERATOR")&&(this.peek().lexeme==="div"||this.peek().lexeme==="mod")){let t=this.advance().lexeme,n=this.parseUnaryExpr();e=new Ye(e,n,t)}else break;return e}parseUnaryExpr(){if(this.match("MINUS")){let e=this.parseUnaryExpr();return new kt("-",e)}return this.parseUnionExpr()}parseUnionExpr(){let e=this.parsePathExpr();for(;this.match("PIPE");){let t=this.parsePathExpr();e=new Ce(e,t)}return e}parsePathExpr(){if(this.check("SLASH")||this.check("DOUBLE_SLASH"))return this.parseLocationPath();if(this.isStepStart())return this.parseLocationPath();let e=this.parseFilterExpr();if(this.match("SLASH","DOUBLE_SLASH")){let t=this.previous().type==="DOUBLE_SLASH",n=this.parseRelativeLocationPath();t&&n.unshift(new Ne("descendant-or-self",{type:"node-type",nodeType:"node"}));let r=new Ee(n,!1);return new _t(e,r)}return e}isStepStart(){if(this.isAtEnd())return!1;let e=this.peek(),t=this.peekNext(),n=["element","attribute","schema-element","schema-attribute","document-node","node","text","comment","processing-instruction"];if((e.type==="IDENTIFIER"||e.type==="NODE_TYPE")&&(t==null?void 0:t.type)==="OPEN_PAREN"&&n.includes(e.lexeme.toLowerCase()))return!0;if(this.isFunctionCallStart())return!1;if(e.type==="DOT"||e.type==="DOT_DOT"||e.type==="AT"||e.type==="LOCATION"||e.type==="NODE_TYPE"||e.type==="ASTERISK")return!0;if(e.type==="IDENTIFIER"||e.type==="OPERATOR"||e.type==="FUNCTION"){let r=this.peekNext();return!r||r.type!=="OPEN_PAREN"}return!1}parseLocationPath(){let e=!1,t=[];return this.match("SLASH")?(e=!0,!this.isAtEnd()&&this.isStepStart()&&t.push(...this.parseRelativeLocationPath())):this.match("DOUBLE_SLASH")?(e=!0,t.push(new Ne("descendant-or-self",{type:"node-type",nodeType:"node"})),t.push(...this.parseRelativeLocationPath())):t.push(...this.parseRelativeLocationPath()),new Ee(t,e)}parseRelativeLocationPath(){let e=[];for(e.push(this.parseStep());this.match("SLASH","DOUBLE_SLASH");)this.previous().type==="DOUBLE_SLASH"&&e.push(new Ne("descendant-or-self",{type:"node-type",nodeType:"node"})),e.push(this.parseStep());return e}parseStep(){if(this.match("DOT"))return new Ne("self",{type:"node-type",nodeType:"node"});if(this.match("DOT_DOT"))return new Ne("parent",{type:"node-type",nodeType:"node"});let e="child";if(this.match("AT"))e="attribute";else if(this.check("LOCATION")){let r=this.peekNext();r&&r.type==="COLON_COLON"&&(e=this.advance().lexeme,this.advance())}if(e==="namespace"){if(!this.options.enableNamespaceAxis)throw Si("namespace");this.warnNamespaceAxis()}let t=this.parseNodeTest(),n=this.parsePredicates();return new Ne(e,t,n)}parseNodeTest(){var e,t;if(this.match("ASTERISK"))return{type:"wildcard"};if(this.check("NODE_TYPE")||this.check("IDENTIFIER")||this.check("LOCATION")||this.check("FUNCTION")||this.check("OPERATOR")){let n=this.peekNext();if(n&&n.type==="OPEN_PAREN"){let r=this.advance().lexeme.toLowerCase();if(this.advance(),r==="element")return this.parseElementTest();if(r==="attribute")return this.parseAttributeTest();if(r==="document-node")return this.parseDocumentNodeTest();if(r==="schema-element"){let i=this.parseNameOrWildcard();return this.consume("CLOSE_PAREN","Expected ')' after schema-element name"),{type:"schema-element",name:i}}if(r==="schema-attribute"){let i=this.parseNameOrWildcard();return this.consume("CLOSE_PAREN","Expected ')' after schema-attribute name"),{type:"schema-attribute",name:i}}if(r==="node"||r==="text"||r==="comment"||r==="processing-instruction"){if(r==="processing-instruction"&&this.check("STRING")){let i=this.advance().lexeme;return this.consume("CLOSE_PAREN","Expected ')' after processing-instruction target"),{type:"processing-instruction",target:i}}return this.consume("CLOSE_PAREN","Expected ')' after node type"),{type:"node-type",nodeType:r}}}}if(this.check("IDENTIFIER")||this.check("LOCATION")||this.check("FUNCTION")||this.check("NODE_TYPE")||this.check("OPERATOR")){let n=this.advance().lexeme;if(this.match("COLON")){if(this.match("ASTERISK"))return{type:"wildcard",name:`${n}:*`};if(this.check("IDENTIFIER")||this.check("LOCATION")||this.check("FUNCTION")||this.check("NODE_TYPE")||this.check("OPERATOR")){let r=this.advance().lexeme;return{type:"name",name:`${n}:${r}`}}throw new Error("Expected local name after namespace prefix")}return{type:"name",name:n}}throw ne(`Expected node test, got: ${(t=(e=this.peek())==null?void 0:e.lexeme)!=null?t:"EOF"}`)}parsePredicates(){let e=[];for(;this.match("OPEN_SQUARE_BRACKET");){let t=this.parseExpr();this.consume("CLOSE_SQUARE_BRACKET","Expected ']' after predicate"),e.push(new Nn(t))}return e}parseFilterExpr(){let e=this.parsePrimaryExpr(),t=[];for(;this.check("OPEN_SQUARE_BRACKET");)t.push(...this.parsePredicates());return t.length>0?new It(e,t):e}parsePrimaryExpr(){var e,t;if(this.match("DOLLAR")){let n=this.parseVariableReferenceName();return new xe(n)}if(this.match("OPEN_PAREN")){if(this.check("CLOSE_PAREN"))return this.advance(),new xn;let n=this.parseExpr();return this.consume("CLOSE_PAREN","Expected ')' after expression"),n}if(this.check("STRING")){let n=this.advance().lexeme;return new Ot(n)}if(this.check("NUMBER")){let n=parseFloat(this.advance().lexeme);return new Rt(n)}if(this.isFunctionCallStart())return this.parseFunctionCall();throw ne(`Unexpected token in primary expression: ${(t=(e=this.peek())==null?void 0:e.lexeme)!=null?t:"EOF"}`)}parseFunctionCall(){let e=this.advance().lexeme;if(e.startsWith("Q{"))this.consume("OPEN_PAREN","Expected '(' after function name");else if(this.match("COLON")){let n=this.advance();if(!this.isNcNameToken(n.type))throw ne("Expected local name after namespace prefix");e=`${e}:${n.lexeme}`}e.startsWith("Q{")||this.consume("OPEN_PAREN","Expected '(' after function name");let t=[];if(!this.check("CLOSE_PAREN"))do t.push(this.parseExpr());while(this.match("COMMA"));return this.consume("CLOSE_PAREN","Expected ')' after function arguments"),new Pe(e,t)}isFunctionCallStart(){var i,o,a;if(this.isAtEnd())return!1;let e=this.peek(),t=this.peekNext(),r=["element","attribute","schema-element","schema-attribute","document-node","node","text","comment","processing-instruction"].includes((a=(o=(i=e.lexeme)==null?void 0:i.toLowerCase)==null?void 0:o.call(i))!=null?a:"");if(e.type==="EQNAME"&&(t==null?void 0:t.type)==="OPEN_PAREN")return!0;if(this.isFunctionNameToken(e.type)&&(t==null?void 0:t.type)==="OPEN_PAREN")return!r;if(this.isFunctionNameToken(e.type)&&(t==null?void 0:t.type)==="COLON"){let c=this.tokens[this.current+2],u=this.tokens[this.current+3];if(c&&this.isFunctionNameToken(c.type)&&(u==null?void 0:u.type)==="OPEN_PAREN")return!0}return!1}warnNamespaceAxis(){this.warningCollector.emit("XPWD0001","namespace:: axis",this.tokens.map(e=>e.lexeme).join(""))}isFunctionNameToken(e){return e==="IDENTIFIER"||e==="FUNCTION"||e==="OPERATOR"||e==="LOCATION"||e==="EQNAME"}parseVariableReferenceName(){var n,r;if(this.check("EQNAME"))return this.advance().lexeme;let e=this.peek();if(!e||!this.isNcNameToken(e.type))throw ne(`Expected variable name after $. Got: ${(n=e==null?void 0:e.lexeme)!=null?n:"EOF"}`);let t=this.advance().lexeme;if(this.match("COLON")){let i=this.peek();if(!i||!this.isNcNameToken(i.type))throw ne(`Expected local name after namespace prefix in variable reference. Got: ${(r=i==null?void 0:i.lexeme)!=null?r:"EOF"}`);t=`${t}:${this.advance().lexeme}`}return t}isNcNameToken(e){return e==="IDENTIFIER"||e==="FUNCTION"||e==="OPERATOR"||e==="LOCATION"||e==="NODE_TYPE"||e==="RESERVED_WORD"}parseNameOrWildcard(){let e="";if(this.match("ASTERISK"))return"*";if(this.check("EQNAME"))return this.advance().lexeme;if((this.check("IDENTIFIER")||this.check("NODE_TYPE")||this.check("FUNCTION")||this.check("LOCATION")||this.check("OPERATOR"))&&(e=this.advance().lexeme,this.match("COLON"))){if(this.match("ASTERISK"))return`${e}:*`;(this.check("IDENTIFIER")||this.check("NODE_TYPE")||this.check("FUNCTION")||this.check("LOCATION")||this.check("OPERATOR"))&&(e+=":"+this.advance().lexeme)}return e}parseElementTest(){if(this.check("CLOSE_PAREN"))return this.advance(),{type:"element"};let e=this.parseNameOrWildcard(),t;return this.match("COMMA")&&(this.check("IDENTIFIER")||this.check("NODE_TYPE")||this.check("FUNCTION")||this.check("LOCATION"))&&(t=this.parseNameOrWildcard()),this.consume("CLOSE_PAREN","Expected ')' after element test"),{type:"element",name:e==="*"?void 0:e,elementType:t,isWildcardName:e==="*"}}parseAttributeTest(){if(this.check("CLOSE_PAREN"))return this.advance(),{type:"attribute"};let e=this.parseNameOrWildcard(),t;return this.match("COMMA")&&(this.check("IDENTIFIER")||this.check("NODE_TYPE")||this.check("FUNCTION")||this.check("LOCATION"))&&(t=this.parseNameOrWildcard()),this.consume("CLOSE_PAREN","Expected ')' after attribute test"),{type:"attribute",name:e==="*"?void 0:e,elementType:t,isWildcardName:e==="*"}}parseDocumentNodeTest(){if(this.check("CLOSE_PAREN"))return this.advance(),{type:"document-node"};let e=this.parseNodeTest();return this.consume("CLOSE_PAREN","Expected ')' after document-node test"),{type:"document-node",elementTest:e}}};var In=class extends Nt{constructor(e){super(e),this.ensureVersionSupport(["1.0"],"1.0")}};ce();ke();var Et=class extends Nt{constructor(e){super(e),this.ensureVersionSupport(["2.0","3.0","3.1"],"2.0")}parseExpr(){return this.checkReservedWord("for")?this.parseForExpr():this.checkReservedWord("some")||this.checkReservedWord("every")?this.parseQuantifiedExpr():super.parseExpr()}parseUnionExpr(){let e=this.parseInstanceOfExpr();for(;this.match("PIPE");){let t=this.parseInstanceOfExpr();e=new Ce(e,t)}return e}parsePrimaryExpr(){if(this.check("RESERVED_WORD")&&this.peek().lexeme==="if")return this.parseIfExpr();if(this.check("DOLLAR")){this.advance();let e=this.parseVariableReferenceName();return new xe(e)}return super.parsePrimaryExpr()}parseInstanceOfExpr(){let e=this.parseTreatExpr();if(this.checkReservedWord("instance")){this.advance(),this.consumeReservedWord("of","Expected 'of' after 'instance'");let t=this.parseSequenceType();e=new mn(e,t)}return e}parseTreatExpr(){let e=this.parseCastableExpr();if(this.checkReservedWord("treat")){this.advance(),this.consumeReservedWord("as","Expected 'as' after 'treat'");let t=this.parseSequenceType();e=new dn(e,t)}return e}parseCastableExpr(){let e=this.parsePathExpr();if(this.checkReservedWord("castable")){this.advance(),this.consumeReservedWord("as","Expected 'as' after 'castable'");let t=this.parseSequenceType();e=new fn(e,t)}return e}parseIfExpr(){this.advance(),this.consume("OPEN_PAREN","Expected '(' after 'if'");let e=this.parseExpr();if(this.consume("CLOSE_PAREN","Expected ')' after if test expression"),!(this.check("RESERVED_WORD")&&this.peek().lexeme==="then"))throw new Error("Expected 'then' in conditional expression");this.advance();let t=this.parseExpr();if(!(this.check("RESERVED_WORD")&&this.peek().lexeme==="else"))throw new Error("Expected 'else' in conditional expression");this.advance();let n=this.parseExpr();return new Dt(e,t,n)}parseQuantifiedExpr(){let e=this.consumeReservedWordOneOf(["some","every"],"Expected 'some' or 'every' at start of quantified expression"),t=[];do t.push(this.parseForBinding());while(this.match("COMMA"));this.consumeReservedWord("satisfies","Expected 'satisfies' after quantified expression bindings");let n=this.parseExpr();return new Ft(e,t,n)}parseForExpr(){this.consumeReservedWord("for","Expected 'for' at start of for expression");let e=[];do e.push(this.parseForBinding());while(this.match("COMMA"));this.consumeReservedWord("return","Expected 'return' in for expression");let t=this.parseExpr();return new Vt(e,t)}parseForBinding(){this.consume("DOLLAR","Expected '$' after 'for'");let e=this.consume("IDENTIFIER","Expected variable name in for binding").lexeme;this.consumeReservedWord("in","Expected 'in' after variable name in for clause");let t=this.parseExpr();return{variable:e,expression:t}}parseSequenceType(){if(this.checkName("empty-sequence"))return this.advance(),this.consume("OPEN_PAREN","Expected '(' after empty-sequence"),this.consume("CLOSE_PAREN","Expected ')' after empty-sequence"),ot();if(this.checkName("item")){this.advance(),this.consume("OPEN_PAREN","Expected '(' after item"),this.consume("CLOSE_PAREN","Expected ')' after item()");let i=this.parseOccurrenceIndicator();return de(st,i)}if(this.checkName("map")){this.advance(),this.consume("OPEN_PAREN","Expected '(' after map");let i=null,o=null;this.match("ASTERISK")?this.consume("CLOSE_PAREN","Expected ')' after map(*)"):(i=this.parseSequenceType(),this.consume("COMMA","Expected ',' after key type in map()"),o=this.parseSequenceType(),this.consume("CLOSE_PAREN","Expected ')' after map type"));let a=this.parseOccurrenceIndicator(),{createTypedMapTest:c}=(ht(),U(Lt)),u=c(i,o);return de(u,a)}if(this.checkName("array")){this.advance(),this.consume("OPEN_PAREN","Expected '(' after array");let i=null;this.match("ASTERISK")?this.consume("CLOSE_PAREN","Expected ')' after array(*)"):(i=this.parseSequenceType(),this.consume("CLOSE_PAREN","Expected ')' after array type"));let o=this.parseOccurrenceIndicator(),{createTypedArrayTest:a}=(ht(),U(Lt)),c=a(i);return de(c,o)}let e=this.parseQName(),t=this.parseOccurrenceIndicator(),n=this.stripPrefix(e),r=ye(n);if(!r)throw new Error(`Unknown atomic type: ${e}`);return at(r,t)}parseAdditiveExpr(){let e=this.parseRangeExpr();for(;this.match("PLUS","MINUS");){let t=this.previous().lexeme,n=this.parseRangeExpr();e=new(ce(),U($e)).XPathArithmeticExpression(e,n,t)}return e}parseRangeExpr(){let e=this.parseMultiplicativeExpr();if(this.checkReservedWord("to")){this.advance();let t=this.parseMultiplicativeExpr();e=new gn(e,t)}return e}parseOccurrenceIndicator(){return this.match("QUESTION")?"?":this.match("ASTERISK")?"*":this.match("PLUS")?"+":"ONE"}parseQName(){let e=this.consumeNameToken("Expected type name in SequenceType");if(this.match("COLON")){let t=this.consumeNameToken("Expected local name after : in SequenceType").lexeme;return`${e.lexeme}:${t}`}return e.lexeme}stripPrefix(e){let t=e.split(":");return t.length===2?t[1]:t[0]}consumeNameToken(e){var t,n;if(this.isNameToken())return this.advance();throw new Error(`${e}. Got: ${(n=(t=this.peek())==null?void 0:t.lexeme)!=null?n:"EOF"}`)}isNameToken(){if(this.isAtEnd())return!1;let e=this.peek().type;return e==="IDENTIFIER"||e==="FUNCTION"||e==="NODE_TYPE"||e==="OPERATOR"||e==="LOCATION"||e==="RESERVED_WORD"}checkName(e){return this.isNameToken()&&this.peek().lexeme===e}checkReservedWord(e){return this.check("RESERVED_WORD")&&this.peek().lexeme===e}consumeReservedWord(e,t){var n,r;if(this.checkReservedWord(e)){this.advance();return}throw new Error(`${t}. Got: ${(r=(n=this.peek())==null?void 0:n.lexeme)!=null?r:"EOF"}`)}consumeReservedWordOneOf(e,t){var n,r;for(let i of e)if(this.checkReservedWord(i))return this.advance(),i;throw new Error(`${t}. Got: ${(r=(n=this.peek())==null?void 0:n.lexeme)!=null?r:"EOF"}`)}};ce();ei();ti();ni();ii();si();oi();ai();ci();ke();_e();var bt=class extends Et{constructor(e){let t=e?X({},e):{};t.version||(t.version="3.0"),super(t),this.ensureVersionSupport(["3.0","3.1"],"3.0")}parseExpr(){if(this.checkReservedWordInternal("let"))return this.parseLetExpr();let e=this.parseExprSingle();if(this.check("COMMA")){let t=[e];for(;this.match("COMMA");)t.push(this.parseExprSingle());return new yn(t)}return e}parseExprSingle(){return this.checkReservedWordInternal("let")?this.parseLetExpr():super.parseExpr()}parseAdditiveExpr(){let e=this.parseStringConcatExpr();for(;this.match("PLUS","MINUS");){let t=this.previous().lexeme,n=this.parseStringConcatExpr();e=new(ce(),U($e)).XPathArithmeticExpression(e,n,t)}return e}parseStringConcatExpr(){let e=this.parseRangeExpr();for(;this.match("CONCAT");){let t=this.parseRangeExpr();e=new Cn(e,t)}return e}parseUnionExpr(){let e=this.parseSimpleMapExpr();for(;this.match("PIPE");){let t=this.parseSimpleMapExpr();e=new(ce(),U($e)).XPathUnionExpression(e,t)}return e}parseSimpleMapExpr(){let e=this.parseInstanceOfExprInternal();for(;this.match("SIMPLE_MAP");){let t=this.parseInstanceOfExprInternal();e=new Sn(e,t)}return e}parseInstanceOfExprInternal(){let e=this.parseTreatExprInternal();if(this.checkReservedWordInternal("instance")){this.advance(),this.consumeReservedWordInternal("of","Expected 'of' after 'instance'");let t=this.parseSequenceTypeInternal();e=new(ce(),U($e)).XPathInstanceOfExpression(e,t)}return e}parseTreatExprInternal(){let e=this.parseCastableExprInternal();if(this.checkReservedWordInternal("treat")){this.advance(),this.consumeReservedWordInternal("as","Expected 'as' after 'treat'");let t=this.parseSequenceTypeInternal();e=new(ce(),U($e)).XPathTreatExpression(e,t)}return e}parseCastableExprInternal(){let e=this.parseArrowExpr();if(this.checkReservedWordInternal("castable")){this.advance(),this.consumeReservedWordInternal("as","Expected 'as' after 'castable'");let t=this.parseSequenceTypeInternal();e=new(ce(),U($e)).XPathCastableExpression(e,t)}return e}parseArrowExpr(){let e=this.parsePathExpr();for(;this.match("FAT_ARROW");){let t,n=[];if(this.check("DOLLAR")){this.advance();let r=this.parseVariableReferenceName();if(t=new xe(r),this.consume("OPEN_PAREN","Expected '(' after function variable in arrow expression"),!this.check("CLOSE_PAREN"))do n.push(this.parseExprSingle());while(this.match("COMMA"));this.consume("CLOSE_PAREN","Expected ')' after arrow expression arguments"),e=new gt(t,[e,...n])}else{let r=this.advance().lexeme;if(this.match("COLON")){let i=this.advance();r=`${r}:${i.lexeme}`}if(this.consume("OPEN_PAREN","Expected '(' after function name in arrow expression"),!this.check("CLOSE_PAREN"))do n.push(this.parseExprSingle());while(this.match("COMMA"));this.consume("CLOSE_PAREN","Expected ')' after arrow expression arguments"),e=new An(e,r,n)}}return e}parseFunctionCall(){let e=this.advance().lexeme;if(this.match("COLON")){let n=this.advance();e=`${e}:${n.lexeme}`}this.consume("OPEN_PAREN","Expected '(' after function name");let t=[];if(!this.check("CLOSE_PAREN"))do t.push(this.parseExprSingle());while(this.match("COMMA"));return this.consume("CLOSE_PAREN","Expected ')' after function arguments"),new Pe(e,t)}parsePrimaryExpr(){if(this.check("STRING_TEMPLATE")){let e=this.advance().lexeme;return this.parseStringTemplateFromLexeme(e)}return this.match("DOLLAR")?new xe(this.parseVariableReferenceName()):this.checkReservedWordInternal("function")?this.parseInlineFunction():this.isFunctionRefStart()?this.parseNamedFunctionRef():super.parsePrimaryExpr()}isStepStart(){return this.isFunctionRefStart()?!1:super.isStepStart()}parseFilterExpr(){let e=this.parsePrimaryExpr();if(this.check("OPEN_PAREN")){this.advance();let n=[];if(!this.check("CLOSE_PAREN"))do n.push(this.parseExprSingle());while(this.match("COMMA"));this.consume("CLOSE_PAREN","Expected ')' after function arguments"),e=new gt(e,n)}let t=[];for(;this.check("OPEN_SQUARE_BRACKET");)t.push(...this.parsePredicates());if(t.length>0){let n=(ce(),U($e)).XPathFilterExpression;return new n(e,t)}return e}isFunctionRefStart(){if(this.isAtEnd())return!1;let e=this.peek();if(e.type==="EQNAME"){let t=this.peekNext();return(t==null?void 0:t.type)==="HASH"}if(e.type==="IDENTIFIER"||e.type==="FUNCTION"||e.type==="OPERATOR"||e.type==="LOCATION"){let t=1,n=!1;for(;t<this.tokens.length-this.current;){let r=this.tokens[this.current+t];if(!r)break;if(r.type==="HASH"){n=!0;break}if(r.type==="MINUS"||r.type==="COLON"||r.type==="IDENTIFIER"||r.type==="FUNCTION"||r.type==="OPERATOR"||r.type==="LOCATION"||r.type==="NODE_TYPE")t++;else break}return n}return!1}parseNamedFunctionRef(){let e=this.advance().lexeme;for(;!this.isAtEnd()&&!this.check("HASH")&&(this.match("MINUS")||this.match("COLON"));){let r=this.previous().lexeme,i=this.peek();if(i&&(i.type==="IDENTIFIER"||i.type==="FUNCTION"||i.type==="OPERATOR"||i.type==="LOCATION"||i.type==="NODE_TYPE"))this.advance(),e=`${e}${r}${i.lexeme}`;else throw ne(`Expected name after '${r}' in function reference`)}this.consume("HASH","Expected '#' in function reference");let t=this.consume("NUMBER","Expected arity number after '#'"),n=parseInt(t.lexeme,10);if(isNaN(n)||n<0)throw ne(`Invalid function arity: ${t.lexeme}`);return new On(e,n)}parseInlineFunction(){this.advance(),this.consume("OPEN_PAREN","Expected '(' after 'function'");let e=[];if(!this.check("CLOSE_PAREN"))do{this.consume("DOLLAR","Expected '$' before parameter name");let r=this.consume("IDENTIFIER","Expected parameter name").lexeme,i;this.checkReservedWordInternal("as")&&(this.advance(),i=this.parseSequenceTypeInternal()),e.push({name:r,type:i})}while(this.match("COMMA"));this.consume("CLOSE_PAREN","Expected ')' after function parameters");let t;this.checkReservedWordInternal("as")&&(this.advance(),t=this.parseSequenceTypeInternal()),this.consume("OPEN_CURLY_BRACKET","Expected '{' before function body");let n=this.parseExpr();return this.consume("CLOSE_CURLY_BRACKET","Expected '}' after function body"),new Rn(e,n,t)}parseLetExpr(){this.consumeReservedWordInternal("let","Expected 'let'");let e=[];do e.push(this.parseLetBinding());while(this.match("COMMA"));this.consumeReservedWordInternal("return","Expected 'return' in let expression");let t=this.parseExpr();return new Xn(e,t)}parseLetBinding(){this.consume("DOLLAR","Expected '$' before variable name in let binding");let t=this.consumeNameTokenInternal("Expected variable name in let binding").lexeme,n;this.checkReservedWordInternal("as")&&(this.advance(),n=this.parseSequenceTypeInternal()),this.consume("ASSIGNMENT","Expected ':=' after variable name in let binding");let r=this.parseExprSingle();return{variable:t,expression:r,type:n}}checkReservedWordInternal(e){return this.check("RESERVED_WORD")&&this.peek().lexeme===e}consumeReservedWordInternal(e,t){var n,r;if(this.checkReservedWordInternal(e)){this.advance();return}throw ne(`${t}. Got: ${(r=(n=this.peek())==null?void 0:n.lexeme)!=null?r:"EOF"}`)}parseSequenceTypeInternal(){if(this.checkNameInternal("empty-sequence"))return this.advance(),this.consume("OPEN_PAREN","Expected '(' after empty-sequence"),this.consume("CLOSE_PAREN","Expected ')' after empty-sequence"),ot();if(this.checkNameInternal("item")){this.advance(),this.consume("OPEN_PAREN","Expected '(' after item"),this.consume("CLOSE_PAREN","Expected ')' after item()");let i=this.parseOccurrenceIndicatorInternal();return de(st,i)}if(this.checkNameInternal("map")){this.advance(),this.consume("OPEN_PAREN","Expected '(' after map");let i=null,o=null;this.match("ASTERISK")?this.consume("CLOSE_PAREN","Expected ')' after map(*)"):(i=this.parseSequenceTypeInternal(),this.consume("COMMA","Expected ',' after key type in map()"),o=this.parseSequenceTypeInternal(),this.consume("CLOSE_PAREN","Expected ')' after map type"));let a=this.parseOccurrenceIndicatorInternal(),{createTypedMapTest:c}=(ht(),U(Lt)),u=c(i,o);return de(u,a)}if(this.checkNameInternal("array")){this.advance(),this.consume("OPEN_PAREN","Expected '(' after array");let i=null;this.match("ASTERISK")?this.consume("CLOSE_PAREN","Expected ')' after array(*)"):(i=this.parseSequenceTypeInternal(),this.consume("CLOSE_PAREN","Expected ')' after array type"));let o=this.parseOccurrenceIndicatorInternal(),{createTypedArrayTest:a}=(ht(),U(Lt)),c=a(i);return de(c,o)}if(this.checkReservedWordInternal("function")){this.advance(),this.consume("OPEN_PAREN","Expected '(' after function");let i=null;if(this.match("ASTERISK"))this.consume("CLOSE_PAREN","Expected ')' after function(*)");else if(this.check("CLOSE_PAREN"))i=[],this.advance();else{i=[];do i.push(this.parseSequenceTypeInternal());while(this.match("COMMA"));this.consume("CLOSE_PAREN","Expected ')' after function parameter types")}let o=null;this.checkReservedWordInternal("as")&&(this.advance(),o=this.parseSequenceTypeInternal());let a=this.parseOccurrenceIndicatorInternal(),{createFunctionTest:c}=(pn(),U(ss)),u=c(i,o,{isWildcard:i===null&&o===null});return de(u,a)}let e=this.parseQNameInternal(),t=this.parseOccurrenceIndicatorInternal(),n=this.stripPrefixInternal(e),r=ye(n);if(!r)throw ne(`Unknown atomic type: ${e}`);return at(r,t)}parseOccurrenceIndicatorInternal(){return this.match("QUESTION")?"?":this.match("ASTERISK")?"*":this.match("PLUS")?"+":"ONE"}parseQNameInternal(){let e=this.consumeNameTokenInternal("Expected type name");if(this.match("COLON")){let t=this.consumeNameTokenInternal("Expected local name after :").lexeme;return`${e.lexeme}:${t}`}return e.lexeme}stripPrefixInternal(e){let t=e.split(":");return t.length===2?t[1]:t[0]}consumeNameTokenInternal(e){var t,n;if(this.isNameTokenInternal())return this.advance();throw ne(`${e}. Got: ${(n=(t=this.peek())==null?void 0:t.lexeme)!=null?n:"EOF"}`)}isNameTokenInternal(){if(this.isAtEnd())return!1;let e=this.peek().type;return e==="IDENTIFIER"||e==="FUNCTION"||e==="NODE_TYPE"||e==="OPERATOR"||e==="LOCATION"||e==="RESERVED_WORD"}checkNameInternal(e){return this.isNameTokenInternal()&&this.peek().lexeme===e}parseStringTemplateFromLexeme(e){let t=ri(e),n=[];for(let r of t)if(typeof r=="string")n.push(r);else if(r.expressionString.trim().length===0)n.push("");else{let a=new Ie({version:"3.1"}).scan(r.expressionString),c=this.constructor,l=new c().parse(a);n.push(l)}return new wn(n)}};De();Ve();li();var pr=class extends bt{constructor(e){let t=e?X({},e):{};t.version||(t.version="3.1"),super(t),this.ensureVersionSupport(["3.1"],"3.1")}parsePrimaryExpr(){var e,t,n;return this.check("RESERVED_WORD")&&this.peek().lexeme==="map"&&((e=this.peekNext())==null?void 0:e.type)==="OPEN_CURLY_BRACKET"?this.parseMapConstructor():this.check("RESERVED_WORD")&&this.peek().lexeme==="array"&&((t=this.peekNext())==null?void 0:t.type)==="OPEN_CURLY_BRACKET"?this.parseCurlyArrayConstructor():this.check("RESERVED_WORD")&&(this.peek().lexeme==="map"||this.peek().lexeme==="array")&&((n=this.peekNext())==null?void 0:n.type)==="COLON"?this.parseNamespacedFunctionCall():this.check("OPEN_SQUARE_BRACKET")?this.parseSquareBracketArrayConstructor():this.check("QUESTION")?this.parseLookupExpr(null):super.parsePrimaryExpr()}parseNamespacedFunctionCall(){let e=this.advance().lexeme;if(this.consume("COLON",`Expected ':' after '${e}'`),!this.check("IDENTIFIER")&&!this.check("FUNCTION"))throw new Error(`Expected function name after '${e}:'`);let t=this.advance().lexeme,n=`${e}:${t}`;this.consume("OPEN_PAREN",`Expected '(' after '${n}'`);let r=[];if(!this.check("CLOSE_PAREN"))do r.push(this.parseExprSingle());while(this.match("COMMA"));this.consume("CLOSE_PAREN","Expected ')' after function arguments");let{XPathFunctionCall:i}=(Tn(),U(Xa));return new i(n,r)}parseMapConstructor(){this.advance(),this.consume("OPEN_CURLY_BRACKET","Expected '{' after 'map'");let e=[];if(this.check("CLOSE_CURLY_BRACKET"))return this.advance(),new ut(e);do{let t=this.parseExprSingle();this.consume("COLON","Expected ':' after map key");let n=this.parseExprSingle();e.push({key:t,value:n})}while(this.match("COMMA"));return this.consume("CLOSE_CURLY_BRACKET","Expected '}' after map entries"),new ut(e)}parseSquareBracketArrayConstructor(){this.advance();let e=[];if(this.check("CLOSE_SQUARE_BRACKET"))return this.advance(),new lt(e);do{let t=this.parseExprSingle();e.push(t)}while(this.match("COMMA"));return this.consume("CLOSE_SQUARE_BRACKET","Expected ']' after array items"),new lt(e)}parseCurlyArrayConstructor(){if(this.advance(),this.consume("OPEN_CURLY_BRACKET","Expected '{' after 'array'"),this.check("CLOSE_CURLY_BRACKET"))return this.advance(),new pt({evaluate:()=>[],toString:()=>"()"});let e=this.parseExpr();return this.consume("CLOSE_CURLY_BRACKET","Expected '}' after array expression"),new pt(e)}parseFilterExpr(){let e=super.parseFilterExpr();for(;this.check("QUESTION");)e=this.parseLookupExpr(e);return e}parseLookupExpr(e){var n,r,i,o,a;this.consume("QUESTION","Expected ? for lookup operator");let t;if(this.match("ASTERISK"))t={type:"WILDCARD"};else if(this.check("OPEN_PAREN")){this.advance();let c=this.parseExpr();this.consume("CLOSE_PAREN","Expected ')' after lookup expression"),t={type:"PARENTHESIZED_EXPR",value:c}}else if(this.check("NUMBER")){let c=this.advance(),u=parseInt(c.lexeme,10);t={type:"INTEGER_LITERAL",value:u}}else if(((n=this.peek())==null?void 0:n.type)==="IDENTIFIER"||((r=this.peek())==null?void 0:r.type)==="FUNCTION"||((i=this.peek())==null?void 0:i.type)==="OPERATOR"||((o=this.peek())==null?void 0:o.type)==="LOCATION"||((a=this.peek())==null?void 0:a.type)==="NODE_TYPE"){let c=this.advance().lexeme;t={type:"NCNAME",value:c}}else throw new Error("Expected key specifier after ?");return new vn(e,t)}parseSequenceType(){let e=super.parseSequenceType();if(this.check("PIPE")){let t=[e];for(;this.match("PIPE");){let c=super.parseSequenceType();t.push(c)}let{createUnionType:n}=($t(),U(er)),{createItemSequenceType:r}=(Qe(),U(Dr)),i=t.map(c=>{if(c.getItemType&&typeof c.getItemType=="function"){let u=c.getItemType();if(u==="empty")throw new Error("empty-sequence() cannot be used in union types");return u}return c}),o=e.getOccurrence?e.getOccurrence():"ONE",a=n(...i);return r(a,o)}return e}parseSequenceTypeInternal(){let e=super.parseSequenceTypeInternal();if(this.check("PIPE")){let t=[e];for(;this.match("PIPE");){let c=super.parseSequenceTypeInternal();t.push(c)}let{createUnionType:n}=($t(),U(er)),{createItemSequenceType:r}=(Qe(),U(Dr)),i=t.map(c=>{if(c.getItemType&&typeof c.getItemType=="function"){let u=c.getItemType();if(u==="empty")throw new Error("empty-sequence() cannot be used in union types");return u}return c}),o=e.getOccurrence?e.getOccurrence():"ONE",a=n(...i);return r(a,o)}return e}};function va(s="1.0",e){let t=I(X({},e),{version:s});switch(s){case"1.0":return new In(t);case"2.0":return new Et(t);case"3.0":return new bt(t);case"3.1":return new pr(t);default:throw new Error(`Unsupported XPath version: ${s}`)}}ce();var Le=class Le{constructor(e,t,n,r,i){this.id=Math.random()*(Number.MAX_SAFE_INTEGER-1)+1,this.childNodes=[],this.visited=!1,this.escape=!0,this.fromXslText=!1,this.siblingPosition=-1,this.init(e,t,n,r,i)}init(e,t,n,r,i){this.nodeType=e-0,this.nodeName=`${t}`,this.nodeValue=`${n}`,this.ownerDocument=r,this.namespaceUri=i||null,[this.prefix,this.localName]=this.qualifiedNameToParts(`${t}`),this.firstChild=null,this.lastChild=null,this.nextSibling=null,this.previousSibling=null,this.parentNode=null}qualifiedNameToParts(e){return e.includes(":")?e.split(":"):[null,e]}domTraverseElements(e,t,n){let r;if(t&&(r=t.call(null,e),typeof r=="boolean"&&!r))return!1;for(let i=e.firstChild;i;i=i.nextSibling)if(i.nodeType==1&&(r=this.domTraverseElements.call(this,i,t,n),typeof r=="boolean"&&!r))return!1;if(n&&(r=n.call(null,e),typeof r=="boolean"&&!r))return!1}static recycle(e){if(e){if(e.constructor.name==="XDocument"){this.recycle(e.documentElement);return}if(e.constructor==this){this._unusedXNodes.push(e);for(let t=0;t<e.childNodes.length;++t)this.recycle(e.childNodes[t]);e.childNodes.length=0,e.init.call(0,"","",null)}}}static create(e,t,n,r,i){if(this._unusedXNodes.length>0){let o=this._unusedXNodes.pop();return o.init(e,t,n,r,i),o}return new Le(e,t,n,r,i)}static clone(e,t){let n=new Le(e.nodeType,e.nodeName,e.nodeValue,t,e.namespaceUri);n.id=e.id;for(let r of e.childNodes)n.appendChild(Le.clone(r,n));return n}appendChild(e){this.childNodes.length===0&&(this.firstChild=e),e.previousSibling=this.lastChild,e.nextSibling=null,this.lastChild&&(this.lastChild.nextSibling=e),e.parentNode=this,this.lastChild=e,this.childNodes.push(e)}replaceChild(e,t){if(t!=e){for(let n=0;n<this.childNodes.length;++n)if(this.childNodes[n]==t){this.childNodes[n]=e;let r=t.parentNode;t.parentNode=null,e.parentNode=r,r=t.previousSibling,t.previousSibling=null,e.previousSibling=r,e.previousSibling&&(e.previousSibling.nextSibling=e),r=t.nextSibling,t.nextSibling=null,e.nextSibling=r,e.nextSibling&&(e.nextSibling.previousSibling=e),this.firstChild==t&&(this.firstChild=e),this.lastChild==t&&(this.lastChild=e);break}}}insertBefore(e,t){if(t==e||t.parentNode!=this)return;e.parentNode&&e.parentNode.removeChild(e);let n=[];for(let r of this.childNodes)r==t&&(n.push(e),e.parentNode=this,e.previousSibling=t.previousSibling,t.previousSibling=e,e.previousSibling&&(e.previousSibling.nextSibling=e),e.nextSibling=t,this.firstChild==t&&(this.firstChild=e)),n.push(r);this.childNodes=n}removeChild(e){let t=[];for(let n of this.childNodes)n!=e?t.push(n):(n.previousSibling&&(n.previousSibling.nextSibling=n.nextSibling),n.nextSibling&&(n.nextSibling.previousSibling=n.previousSibling),this.firstChild==n&&(this.firstChild=n.nextSibling),this.lastChild==n&&(this.lastChild=n.previousSibling));this.childNodes=t}hasAttributes(){return this.childNodes.filter(t=>t.nodeType===2).length>0}setAttribute(e,t){let n=this.childNodes.filter(i=>i.nodeType===2);for(let i=0;i<n.length;++i)if(n[i].nodeName==e){n[i].nodeValue=`${t}`;return}let r=Le.create(2,e,t,this);r.parentNode=this,this.appendChild(r)}setAttributeNS(e,t,n){let r=this.childNodes.filter(o=>o.nodeType===2);for(let o=0;o<r.length;++o){let a=r[o];if(a.namespaceUri==e&&a.localName==this.qualifiedNameToParts(`${t}`)[1]){a.nodeValue=`${n}`,a.nodeName=`${t}`,a.prefix=this.qualifiedNameToParts(`${t}`)[0];return}}let i=Le.create(2,t,n,this,e);i.parentNode=this,this.appendChild(i)}getAttributeValue(e){let t=this.childNodes.filter(n=>n.nodeType===2);for(let n=0;n<t.length;++n)if(t[n].nodeName===e)return t[n].nodeValue;return null}getAttributeNS(e,t){let n=this.childNodes.filter(r=>r.nodeType===2);for(let r=0;r<n.length;++r){let i=n[r];if(i.namespaceUri===e&&i.localName===t)return i.nodeValue}return null}hasAttribute(e){let t=this.childNodes.filter(n=>n.nodeType===2);for(let n=0;n<t.length;++n)if(t[n].nodeName===e)return!0;return!1}hasAttributeNS(e,t){let n=this.childNodes.filter(r=>r.nodeType===2);for(let r=0;r<n.length;++r){let i=n[r];if(i.namespaceUri===e&&i.localName===t)return!0}return!1}removeAttribute(e){let t=[];for(let n=0;n<this.childNodes.length;++n){let r=this.childNodes[n];if(r.nodeType!==2){t.push(r);continue}r.nodeName!==e&&t.push(r)}this.childNodes=t}removeAttributeNS(e,t){let n=[];for(let r=0;r<this.childNodes.length;++r){let i=this.childNodes[r];if(i.nodeType!==2){n.push(i);continue}(i.localName!==t||i.namespaceUri!==e)&&n.push(i)}this.childNodes=n}getElementsByTagName(e){let t=[],n=this;return e=="*"?this.domTraverseElements(this,r=>{n!=r&&t.push(r)},null):this.domTraverseElements(this,r=>{n!=r&&r.nodeName==e&&t.push(r)},null),t}getElementsByTagNameNS(e,t){let n=[],r=this;return e=="*"&&t=="*"?this.domTraverseElements(this,i=>{r!=i&&n.push(i)},null):e=="*"?this.domTraverseElements(this,i=>{r!=i&&i.localName==t&&n.push(i)},null):t=="*"?this.domTraverseElements(this,i=>{r!=i&&i.namespaceUri==e&&n.push(i)},null):this.domTraverseElements(this,i=>{r!=i&&i.localName==t&&i.namespaceUri==e&&n.push(i)},null),n}getElementById(e){let t=null;return this.domTraverseElements(this,n=>{if(n.getAttributeValue("id")==e)return t=n,!1},null),t}getAncestorByLocalName(e){if(!(this.parentNode===null||this.parentNode===void 0))return this.parentNode.localName===e?this.parentNode:this.parentNode.getAncestorByLocalName(e)}getAncestorById(e){if(!(this.parentNode===null||this.parentNode===void 0))return this.parentNode.id===e?this.parentNode:this.parentNode.getAncestorById(e)}toString(){return`${this.nodeType}, ${this.nodeName}, ${this.nodeValue}`}};Le._unusedXNodes=[];var k=Le;var ue=class extends k{constructor(){super(9,"#document",null,null),this.documentElement=null}appendChild(e){super.appendChild(e),e.nodeType===1&&!this.documentElement&&(this.documentElement=e)}createElement(e){return k.create(1,e,null,this)}createElementNS(e,t){return k.create(1,t,null,this,e)}createDocumentFragment(){return k.create(11,"#document-fragment",null,this)}createTextNode(e){return k.create(3,"#text",e,this)}createAttribute(e){return k.create(2,e,null,this)}createAttributeNS(e,t){return k.create(2,t,null,this,e)}createComment(e){return k.create(8,"#comment",e,this)}createCDATASection(e){return k.create(4,"#cdata-section",e,this)}createDTDSection(e){return k.create(10,"#dtd-section",e,this)}createProcessingInstruction(e,t){return k.create(7,e,t,this)}};function Ia(s){if(s.nodeType===9){let n=new ue,r=s.childNodes;for(let i=0;i<r.length;i++){let o=hr(r[i],n);o&&(o.siblingPosition=n.childNodes.length,n.appendChild(o))}return n}let e=new ue,t=hr(s,e);return t&&(t.siblingPosition=0,e.appendChild(t)),e}function hr(s,e){switch(s.nodeType){case 1:{let t=s,n=k.create(1,t.nodeName,null,e,t.namespaceURI);n.prefix=t.prefix||null,n.localName=t.localName||t.nodeName;let r=t.attributes;for(let o=0;o<r.length;o++){let a=r[o],c=k.create(2,a.name,a.value,n,a.namespaceURI);c.prefix=a.prefix||null,c.localName=a.localName||a.name,c.parentNode=n,c.siblingPosition=n.childNodes.length,n.appendChild(c)}let i=s.childNodes;for(let o=0;o<i.length;o++){let a=hr(i[o],e);a&&(a.siblingPosition=n.childNodes.length,n.appendChild(a))}return n}case 3:return k.create(3,"#text",s.nodeValue||"",e);case 4:return k.create(4,"#cdata-section",s.nodeValue||"",e);case 8:return k.create(8,"#comment",s.nodeValue||"",e);case 7:{let t=s;return k.create(7,t.target,t.data,e)}case 10:{let t=s;return k.create(10,"#dtd-section",t.name,e)}case 11:{let t=k.create(11,"#document-fragment",null,e),n=s.childNodes;for(let r=0;r<n.length;r++){let i=hr(n[r],e);i&&(i.siblingPosition=t.childNodes.length,t.appendChild(i))}return t}default:return null}}function Ze(s,e){return s.getAttributeValue(e)}function W(s,e,t){return s.setAttribute(e,t)}function V(s,e){return s.appendChild(e)}function ae(s,e){return s.createTextNode(e)}function et(s,e){return s.createElement(e)}function mr(s,e){return s.createCDATASection(e)}function Tt(s,e){return s.createComment(e)}function Oe(s){return s.createDocumentFragment()}function mi(s,e){return s.createDTDSection(e)}function _a(s,e,t){return s.createProcessingInstruction(e,t)}var mu={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:"\xA0",copy:"\xA9",reg:"\xAE",times:"\xD7",divide:"\xF7",euro:"\u20AC",pound:"\xA3",yen:"\xA5",cent:"\xA2",sect:"\xA7",para:"\xB6",hellip:"\u2026",middot:"\xB7",deg:"\xB0"};function Xt(s){if(!s)return s;let e=s.replace(/&([a-zA-Z]+);/g,(t,n)=>{let r=n.toLowerCase();return mu[r]||t});return e=e.replace(/&#(\d+);/g,(t,n)=>{try{let r=parseInt(n,10);return String.fromCharCode(r)}catch(r){return t}}),e=e.replace(/&#[xX]([0-9a-fA-F]+);/g,(t,n)=>{try{let r=parseInt(n,16);return String.fromCharCode(r)}catch(r){return t}}),e}function me(s,e=!1){if(!s)return"";let t="";switch(s.nodeType){case 10:return`<!DOCTYPE ${s.nodeValue}>`;case 3:case 4:case 2:return s.nodeValue;case 1:case 9:case 11:if(!e){let r=s,i=r.innerText;if(i!==void 0)return i;let o=r.textContent;if(o!==void 0)return o}let n=s.childNodes.filter(r=>r.nodeType!==2);for(let r=0;r<n.length;++r)t+=me(n[r]);return t}}function di(s,e=!1){if(!s)return"";let t="";switch(s.nodeType){case 2:case 3:t+=s.nodeValue;break;case 4:t+=s.nodeValue;break;case 9:case 11:case 1:if(!e){let r=s,i=r.innerText;if(i!==void 0)return i;let o=r.textContent;if(o!==void 0)return o}let n=s.childNodes.length;for(let r=0;r<n;++r)t+=me(s.childNodes[r]);break}return t}function Mn(s,e={cData:!0,escape:!0,selfClosingTags:!0,outputMethod:"xml"}){let t=[];return kn(s,t,e),t.join("")}function kn(s,e,t){if(s.visited)return;let n=s.nodeType,r=s.nodeValue;if(n===3){let i=s.fromXslText===!0;if(s.nodeValue&&(i||s.nodeValue.trim()!=="")){let o=s.escape&&t.escape?_n(s.nodeValue):gu(s.nodeValue);e.push(o)}}else if(n===4)t.outputMethod==="text"?e.push(r):t.cData?e.push(_n(r)):e.push(`<![CDATA[${r}]]>`);else if(n==8)t.outputMethod!=="text"&&e.push(`<!--${r}-->`);else if(n===7)t.outputMethod!=="text"&&(r&&r.trim()?e.push(`<?${s.nodeName} ${r}?>`):e.push(`<?${s.nodeName}?>`));else if(n==1)t.outputMethod==="text"?yu(s,e,t):s.nodeName!==null&&s.nodeName!==void 0?fu(s,e,t):du(s,e,t);else if(n===9||n===11){let i=s.firstChild?[]:s.childNodes;if(s.firstChild){let o=s.firstChild;for(;o;)i.push(o),o=o.nextSibling}i.sort((o,a)=>o.siblingPosition-a.siblingPosition);for(let o=0;o<i.length;++o)kn(i[o],e,t)}s.visited=!0}function fu(s,e,t){e.push(`<${fr(s)}`);let n=[];if(s.firstChild){let i=s.firstChild;for(;i;)i.nodeType===2&&n.push(i),i=i.nextSibling}n.length===0&&(n=s.childNodes.filter(i=>i.nodeType===2));for(let i=0;i<n.length;++i){let o=n[i];o&&(t.outputMethod==="html"&&o.nodeName==="xmlns"&&o.nodeValue==="http://www.w3.org/1999/xhtml"||o.nodeName&&o.nodeValue!==null&&o.nodeValue!==void 0&&e.push(` ${fr(o)}="${xu(o.nodeValue)}"`))}let r=[];if(s.firstChild){let i=s.firstChild;for(;i;)i.nodeType!==2&&r.push(i),i=i.nextSibling}if(r.length===0&&(r=s.childNodes.filter(i=>i.nodeType!==2)),r=r.sort((i,o)=>i.siblingPosition-o.siblingPosition),r.length===0)t.outputMethod==="html"&&["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"].includes(s.nodeName)?e.push(">"):t.selfClosingTags?e.push("/>"):e.push(`></${fr(s)}>`);else{e.push(">");for(let i=0;i<r.length;++i)kn(r[i],e,t);e.push(`</${fr(s)}>`)}}function du(s,e,t){let n=[];if(s.firstChild){let r=s.firstChild;for(;r;)n.push(r),r=r.nextSibling}else n=s.childNodes;n=n.sort((r,i)=>r.siblingPosition-i.siblingPosition);for(let r=0;r<n.length;++r)kn(n[r],e,t)}function yu(s,e,t){let n=[];if(s.firstChild){let r=s.firstChild;for(;r;)n.push(r),r=r.nextSibling}else n=s.childNodes;n=n.sort((r,i)=>r.siblingPosition-i.siblingPosition);for(let r=0;r<n.length;++r)kn(n[r],e,t)}function fr(s){let e=s.nodeName;return s.prefix&&e.indexOf(`${s.prefix}:`)!=0?`${s.prefix}:${e}`:e}function gu(s){return`${s}`.replace(/</g,"<").replace(/>/g,">")}function _n(s){return`${s}`.replace(/&/g,"&").replace(/&amp;/g,"&").replace(/</g,"<").replace(/>/g,">")}function xu(s){return _n(s).replace(/"/g,""")}function f(s,e){let t=Ze(s,e);return t&&Xt(t)}function fi(s){if(!s)return null;let e=s.nodeType;if(e===3||e===4){let t=s.nodeValue?s.nodeValue.trim():"";return t.length>0?t:null}if(e===8)return null;if(e===9||e===11){let t=s.childNodes||[],n=[];for(let r=0;r<t.length;r++){let i=t[r],o=fi(i);o!==null&&n.push(o)}return n.length===0?null:n.length===1?n[0]:n}if(e===1){let t={},n=s,r=n.attributes&&n.attributes.length>0;if(r)for(let u=0;u<n.attributes.length;u++){let l=n.attributes[u];t["@"+l.nodeName]=l.nodeValue}let i=n.childNodes||[],o="",a=!1,c={};for(let u=0;u<i.length;u++){let l=i[u],p=l.nodeType;if(p===3||p===4){let h=l.nodeValue?l.nodeValue.trim():"";h.length>0&&(o+=h)}else if(p===1){a=!0;let h=l,m=h.localName||h.nodeName,d=fi(l);d!==null&&(c[m]?(Array.isArray(c[m])||(c[m]=[c[m]]),c[m].push(d)):c[m]=d)}}if(Object.assign(t,c),!a&&o.length>0){if(!r&&Object.keys(c).length===0)return o;t["#text"]=o}return Object.keys(t).length===0?null:t}return null}function Ma(s){if(!s)return"xml";let e=s.nodeType;if(e===9||e===11){let t=s.childNodes||[],n=0,r=0,i=!1;for(let o=0;o<t.length;o++){let a=t[o];a.nodeType===1?n++:a.nodeType===3&&(a.nodeValue?a.nodeValue.trim():"").length>0&&(r++,i=!0)}return n===0&&i?"text":"xml"}return(e===3||e===4)&&(s.nodeValue?s.nodeValue.trim():"").length>0?"text":"xml"}function ka(s){if(!s)return"{}";let e=s;if(s.nodeType===9||s.nodeType===11){let o=s.childNodes||[];for(let a=0;a<o.length;a++)if(o[a].nodeType===1){e=o[a];break}}let t=e,n=t.localName||t.nodeName,r={},i=fi(e);i===null?r[n]={}:(typeof i=="object"&&Array.isArray(i),r[n]=i);try{let o=JSON.parse(JSON.stringify(r));return JSON.stringify(o)}catch(o){return JSON.stringify(r)}}var dr=`[ \r
|
|
7
|
+
]+`,yr=`(${dr})?=(${dr})?`,Fa="&#[0-9]+;|&#x[0-9a-fA-F]+;",$a=`${dr}version${yr}("1\\.0"|'1\\.0')`,Nu="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF\u0100-\u0131\u0134-\u013E\u0141-\u0148\u014A-\u017E\u0180-\u01C3\u01CD-\u01F0\u01F4-\u01F5\u01FA-\u0217\u0250-\u02A8\u02BB-\u02C1\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03CE\u03D0-\u03D6\u03DA\u03DC\u03DE\u03E0\u03E2-\u03F3\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E-\u0481\u0490-\u04C4\u04C7-\u04C8\u04CB-\u04CC\u04D0-\u04EB\u04EE-\u04F5\u04F8-\u04F9\u0531-\u0556\u0559\u0561-\u0586\u05D0-\u05EA\u05F0-\u05F2\u0621-\u063A\u0641-\u064A\u0671-\u06B7\u06BA-\u06BE\u06C0-\u06CE\u06D0-\u06D3\u06D5\u06E5-\u06E6\u0905-\u0939\u093D\u0958-\u0961\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09DC-\u09DD\u09DF-\u09E1\u09F0-\u09F1\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33\u0A35-\u0A36\u0A38-\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8B\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0AE0\u0B05-\u0B0C\u0B0F-\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B36-\u0B39\u0B3D\u0B5C-\u0B5D\u0B5F-\u0B61\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB5\u0BB7-\u0BB9\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C60-\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CDE\u0CE0-\u0CE1\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D28\u0D2A-\u0D39\u0D60-\u0D61\u0E01-\u0E2E\u0E30\u0E32-\u0E33\u0E40-\u0E45\u0E81-\u0E82\u0E84\u0E87-\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA-\u0EAB\u0EAD-\u0EAE\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0F40-\u0F47\u0F49-\u0F69\u10A0-\u10C5\u10D0-\u10F6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110B-\u110C\u110E-\u1112\u113C\u113E\u1140\u114C\u114E\u1150\u1154-\u1155\u1159\u115F-\u1161\u1163\u1165\u1167\u1169\u116D-\u116E\u1172-\u1173\u1175\u119E\u11A8\u11AB\u11AE-\u11AF\u11B7-\u11B8\u11BA\u11BC-\u11C2\u11EB\u11F0\u11F9\u1E00-\u1E9B\u1EA0-\u1EF9\u1F00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2126\u212A-\u212B\u212E\u2180-\u2182\u3041-\u3094\u30A1-\u30FA\u3105-\u312C\uAC00-\uD7A3",Eu="\u4E00-\u9FA5\u3007\u3021-\u3029",La="\u0300-\u0345\u0360-\u0361\u0483-\u0486\u0591-\u05A1\u05A3-\u05B9\u05BB-\u05BD\u05BF\u05C1-\u05C2\u05C4\u064B-\u0652\u0670\u06D6-\u06DC\u06DD-\u06DF\u06E0-\u06E4\u06E7-\u06E8\u06EA-\u06ED\u0901-\u0903\u093C\u093E-\u094C\u094D\u0951-\u0954\u0962-\u0963\u0981-\u0983\u09BC\u09BE\u09BF\u09C0-\u09C4\u09C7-\u09C8\u09CB-\u09CD\u09D7\u09E2-\u09E3\u0A02\u0A3C\u0A3E\u0A3F\u0A40-\u0A42\u0A47-\u0A48\u0A4B-\u0A4D\u0A70-\u0A71\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0B01-\u0B03\u0B3C\u0B3E-\u0B43\u0B47-\u0B48\u0B4B-\u0B4D\u0B56-\u0B57\u0B82-\u0B83\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C01-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55-\u0C56\u0C82-\u0C83\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5-\u0CD6\u0D02-\u0D03\u0D3E-\u0D43\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB-\u0EBC\u0EC8-\u0ECD\u0F18-\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86-\u0F8B\u0F90-\u0F95\u0F97\u0F99-\u0FAD\u0FB1-\u0FB7\u0FB9\u20D0-\u20DC\u20E1\u302A-\u302F\u3099\u309A",Ua="0-9\u0660-\u0669\u06F0-\u06F9\u0966-\u096F\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE7-\u0BEF\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29",Wa="\xB7\u02D0\u02D1\u0387\u0640\u0E46\u0EC6\u3005\u3031-\u3035\u309D-\u309E\u30FC-\u30FE",gr=Nu+Eu,bu=`${gr+Ua}\\._:${La}${Wa}-`,xr=`[${gr}_:][${bu}]*`,Pu=`&${xr};`,Da=`${Pu}|${Fa}`,Tu=`"(([^<&"]|${Da})*)"|'(([^<&']|${Da})*)'`,qa=`(${xr})${yr}(${Tu})`,Ba=`${dr}version${yr}("1\\.1"|'1\\.1')`,za=":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD",Xu=za+"\\.0-9\xB7\u0300-\u036F\u203F-\u2040-",Nr=`[${za}][${Xu}]*`,Su=`&${Nr};`,Va=`${Su}|${Fa}`,Cu=`"(([^<&"]|${Va})*)"|'(([^<&']|${Va})*)'`,ja=`(${Nr})${yr}(${Cu})`,wu=`${gr+Ua}\\._${La}${Wa}-`,rg=`[${gr}_][${wu}]*`;var Ue=class{constructor(){this.regexEmpty=/\/$/;this.XML10_TAGNAME_REGEXP=new RegExp(`^(${xr})`);this.XML10_ATTRIBUTE_REGEXP=new RegExp(qa,"g");this.XML11_TAGNAME_REGEXP=new RegExp(`^(${Nr})`);this.XML11_ATTRIBUTE_REGEXP=new RegExp(ja,"g");this.lenientHtmlTags=["hr","link","meta"]}xmlParse(e){return e.toUpperCase().startsWith("<!DOCTYPE HTML")?this.htmlParse(e):this.xmlStrictParse(e)}namespaceMapAt(e){let t={xmlns:"http://www.w3.org/2000/xmlns/",xml:"http://www.w3.org/XML/1998/namespace"},n=e;for(;n!==null;){for(let r=0;r<n.childNodes.length;r++){let i=n.childNodes[r];if(i.nodeType===2)if(i.nodeName.startsWith("xmlns:")){let o=i.nodeName.split(":")[1];o in t||(t[o]=i.nodeValue)}else i.nodeName=="xmlns"&&(""in t||(t[""]=i.nodeValue||null))}n=n.parentNode}return t}htmlParse(e){let t=new ue,n=t,r=[],i=n;r.push(i);let o=!1,a=!1,c=!1,u=0;for(let l=0;l<e.length;++l){let p=e.charAt(l);if(o){if(!c&&p==="'")a=!a;else if(!a&&p==='"')c=!c;else if(!a&&!c&&p===">"){let h=e.slice(u,l);if(h.charAt(0)==="/")r.pop(),i=r[r.length-1];else if(h.charAt(0)!=="!"){let m=h.match(this.regexEmpty),d=this.XML10_TAGNAME_REGEXP.exec(h)[1],y=et(t,d),E;for(;E=this.XML10_ATTRIBUTE_REGEXP.exec(h);){let T=Xt(E[5]||E[7]||"");W(y,E[1],T)}y.siblingPosition=i.childNodes.length,V(i,y),!m&&!this.lenientHtmlTags.includes(d)&&(i=y,r.push(y))}u=l+1,o=!1,a=!1,c=!1}}else if(p==="<"){let h=e.slice(u,l);if(h&&i!==n&&V(i,ae(t,h)),e.slice(l+1,l+4)==="!--"){let m=e.slice(l+4).indexOf("-->");if(m>=0){let d=Tt(t,e.slice(l+4,l+m+4));V(i,d),l+=m+6}}else if(e.slice(l+1,l+9)==="!DOCTYPE"){let m=e.slice(l+9).indexOf(">");if(m>=0){let d=e.slice(l+9,l+m+9).trimStart(),y=mi(t,d);V(i,y),l+=m+d.length+5}}else o=!0;u=l+1}}return t}xmlStrictParse(e){let t,n;if(e.match(/^<\?xml/))if(e.search(new RegExp($a))===5)t=this.XML10_TAGNAME_REGEXP,n=this.XML10_ATTRIBUTE_REGEXP;else if(e.search(new RegExp(Ba))===5)t=this.XML11_TAGNAME_REGEXP,n=this.XML11_ATTRIBUTE_REGEXP;else throw new Error("XML VersionInfo has an unknown version number.");else t=this.XML10_TAGNAME_REGEXP,n=this.XML10_ATTRIBUTE_REGEXP;let r=new ue,i=r,o=[],a=i;o.push(a);let c=!1,u=!1,l=!1,p=0;for(let h=0;h<e.length;++h){let m=e.charAt(h);if(c&&!l&&m==="'")u=!u;else if(c&&!u&&m==='"')l=!l;else if(c&&m===">"&&!u&&!l){let d=e.slice(p,h);if(d.charAt(0)==="/")o.pop(),a=o[o.length-1];else if(d.charAt(0)!=="?"){if(d.charAt(0)!=="!"){let y=d.match(this.regexEmpty),E=t.exec(d)[1],T=et(r,E),P;for(;P=n.exec(d);){let w=Xt(P[5]||P[7]||"");W(T,P[1],w)}T.siblingPosition=a.childNodes.length,V(a,T),y||(a=T,o.push(T));let A=this.namespaceMapAt(T);T.prefix!==null?T.prefix in A&&(T.namespaceUri=A[T.prefix]):""in A&&(T.namespaceUri=A[""]);for(let w=0;w<T.childNodes.length;++w){let F=T.childNodes[w];F.nodeType===2&&F.prefix!==null&&F.prefix in A&&(F.namespaceUri=A[F.prefix])}}}p=h+1,c=!1,u=!1,l=!1}else if(!c&&m==="<"){let d=e.slice(p,h);if(d&&a!==i&&V(a,ae(r,Xt(d))),e.slice(h+1,h+4)==="!--"){let y=e.slice(h+4).indexOf("-->");if(y>=0){let E=Tt(r,e.slice(h+4,h+y+4));V(a,E),h+=y+6}}else if(e.slice(h+1,h+9)==="![CDATA["){let y=e.slice(h+9).indexOf("]]>");if(y>=0){let E=mr(r,e.slice(h+9,h+y+9));V(a,E),h+=y+11}}else if(e.slice(h+1,h+9)==="!DOCTYPE"){let y=e.slice(h+9).indexOf(">");if(y>=0){let E=e.slice(h+9,h+y+9).trimStart(),T=mi(r,E);V(a,T),h+=y+E.length+5}}else c=!0;p=h+1}}return i}};function Er(s,e){return X({node:s,position:1,size:1},e)}var Z=class{constructor(e){this.value=e,this.type="node-set"}stringValue(){return this.value.length===0?"":me(this.value[0])}booleanValue(){return this.value.length>0}numberValue(){return parseInt(this.stringValue())-0}nodeSetValue(){return this.value}};var G=class{constructor(e){this.value=e,this.type="string"}stringValue(){return String(this.value)}booleanValue(){return this.value.length>0}numberValue(){let e=String(this.value).trim();return e.length===0?NaN:Number(e)}nodeSetValue(){throw this}};var fe=class{constructor(e){this.value=e,this.type="number"}stringValue(){return`${this.value}`}booleanValue(){return!!this.value}numberValue(){return this.value-0}nodeSetValue(){throw this}};var v=class{constructor(e){this.value=e,this.type="boolean"}stringValue(){return`${this.value}`}booleanValue(){return this.value}numberValue(){return this.value?1:0}nodeSetValue(){throw this}};var St=class{constructor(e){this.value=e,this.type="map"}stringValue(){let e={};for(let t in this.value)t!=="__isMap"&&(e[t]=this.value[t]);return JSON.stringify(e)}booleanValue(){return!0}numberValue(){return NaN}nodeSetValue(){return[]}};var Ct=class{constructor(e){this.value=e,this.type="array"}stringValue(){return JSON.stringify(this.value.members||[])}booleanValue(){return!0}numberValue(){return NaN}nodeSetValue(){return[]}};var wt=class{constructor(e){this.value=e,this.type="function"}stringValue(){return`function ${this.value.name?`${this.value.name}#${this.value.arity}`:`(anonymous)#${this.value.arity}`}`}booleanValue(){return!0}numberValue(){return NaN}nodeSetValue(){return[]}};En();var br=class{exprContextToXPathContext(e){let t=e.nodeList[e.position],n=this.adaptXNode(t),r=e.nodeList.map(a=>this.adaptXNode(a)),i={},o=e;for(;o;)!i.regexGroups&&o.regexGroups&&(i.regexGroups=o.regexGroups),!i.currentGroup&&o.currentGroup&&(i.currentGroup=o.currentGroup),!i.currentGroupingKey&&o.currentGroupingKey!==void 0&&(i.currentGroupingKey=o.currentGroupingKey),o=o.parent;return Er(n,{position:e.position+1,size:e.nodeList.length,nodeList:r,variables:this.convertVariables(e),functions:this.createCustomFunctions(e),namespaces:e.knownNamespaces,xsltVersion:e.xsltVersion,extensions:Object.keys(i).length>0?i:void 0})}adaptXNode(e){if(!e)throw new Error("Cannot adapt undefined XPath node.");let t=e;return"textContent"in t||Object.defineProperty(t,"textContent",{get(){return this._getTextContent()},enumerable:!0,configurable:!0}),"_getTextContent"in t||(t._getTextContent=function(){if(this.nodeType===3||this.nodeType===2)return this.nodeValue||"";if(!this.childNodes)return"";let n="";for(let r of this.childNodes)r.nodeType===3?n+=r.nodeValue||"":r.nodeType===1&&(n+=this._getTextContent.call(r));return n}),"attributes"in t||Object.defineProperty(t,"attributes",{get(){return this.childNodes?this.childNodes.filter(n=>n.nodeType===2):[]},enumerable:!0,configurable:!0}),"getAttribute"in t||(t.getAttribute=function(n){return this.getAttributeValue?this.getAttributeValue(n):null}),t}xPathNodeToXNode(e){return e?e instanceof k?e:this.convertXPathNodeToXNode(e):null}getTextContent(e){if(e.nodeType===3||e.nodeType===2)return e.nodeValue||"";if(!e.childNodes)return"";let t="";for(let n of e.childNodes)n.nodeType===3?t+=n.nodeValue||"":n.nodeType===1&&(t+=this.getTextContent(n));return t}convertVariables(e){let t={},n=[],r=e;for(;r;)n.push(r),r=r.parent;for(let i=n.length-1;i>=0;i--){let a=n[i].variables||{};for(let c in a){if(!Object.prototype.hasOwnProperty.call(a,c))continue;let u=a[c];if(u&&typeof u=="object"&&"stringValue"in u){let l=u;l.type==="node-set"?t[c]=u.nodeSetValue().map(p=>this.adaptXNode(p)):l.type==="string"?t[c]=u.stringValue():l.type==="number"?t[c]=u.numberValue():l.type==="boolean"?t[c]=u.booleanValue():l.type==="map"||l.type==="array"||l.type==="function"?t[c]=l.value:t[c]=u.stringValue()}else t[c]=u}}return t}createCustomFunctions(e){let t={};t.key=(r,i,o)=>{var c;let a=(c=e.keys)==null?void 0:c[i];return a&&a[o]?a[o].nodeSetValue().map(l=>this.adaptXNode(l)):[]},t.current=r=>{let i=e.nodeList[e.position];return[this.adaptXNode(i)]},t["format-number"]=(r,i,o,a)=>{let c=e.decimalFormatSettings;return this.formatXsltNumberPicture(Number(i),String(o),c)},t["xml-to-json"]=(r,i)=>{if(e.xsltVersion!=="3.0")throw new Error('xml-to-json() is only supported in XSLT 3.0. Use version="3.0" in your stylesheet.');let o=Array.isArray(i)?i[0]:i;return o?this.xmlToJson(o):'""'},t["json-to-xml"]=(r,i)=>{if(e.xsltVersion!=="3.0")throw new Error('json-to-xml() is only supported in XSLT 3.0. Use version="3.0" in your stylesheet.');let o=Array.isArray(i)?i[0]:i;if(!o)return[];let c=new we().convert(String(o));if(!c)return null;let u=e.nodeList&&e.nodeList.length>0?e.nodeList[0].ownerDocument:null,l=this.convertXPathNodeToXNode(c,u);return l?[l]:[]},t["system-property"]=(r,i)=>{let o=String(i),a={"xsl:version":e.xsltVersion||"1.0","xsl:vendor":"Design Liquido","xsl:vendor-url":"https://github.com/DesignLiquido/xslt-processor"};return e.systemProperties&&e.systemProperties[o]?e.systemProperties[o]:a[o]||""},t["element-available"]=(r,i)=>{let o=String(i),a=["xsl:apply-imports","xsl:apply-templates","xsl:attribute","xsl:attribute-set","xsl:call-template","xsl:choose","xsl:comment","xsl:copy","xsl:copy-of","xsl:decimal-format","xsl:element","xsl:fallback","xsl:for-each","xsl:if","xsl:import","xsl:include","xsl:key","xsl:message","xsl:namespace-alias","xsl:number","xsl:otherwise","xsl:output","xsl:param","xsl:preserve-space","xsl:processing-instruction","xsl:sort","xsl:strip-space","xsl:stylesheet","xsl:template","xsl:text","xsl:transform","xsl:value-of","xsl:variable","xsl:when","xsl:with-param"],c=o.startsWith("xsl:")?o:`xsl:${o}`;return a.indexOf(c)>=0||a.indexOf(o)>=0},t["function-available"]=(r,i)=>{let o=String(i),a=["boolean","ceiling","concat","contains","count","false","floor","id","lang","last","local-name","name","namespace-uri","normalize-space","not","number","position","round","starts-with","string","string-length","substring","substring-after","substring-before","sum","translate","true"],c=["current","document","element-available","format-number","function-available","generate-id","key","system-property","unparsed-entity-uri"],u=["matches","ends-with","xml-to-json","json-to-xml"];return[...a,...c,...u].indexOf(o)>=0},t.document=(r,i,o)=>{var a,c;if(e.documentLoader){let u=Array.isArray(i)?((a=i[0])==null?void 0:a.textContent)||String(i[0]||""):String(i||"");if(!u)return e.root?[this.adaptXNode(e.root)]:[];try{let l=e.documentLoader(u);if(l)return[this.adaptXNode(l)]}catch(l){((c=e.warningsCallback)!=null?c:console.warn)(`document() failed to load: ${u}`,l)}}return[]},t["unparsed-entity-uri"]=(r,i)=>{let o=String(i);return e.unparsedEntities&&e.unparsedEntities[o]?e.unparsedEntities[o]:""};let n=e;for(;n;){if(n.userDefinedFunctions){n.userDefinedFunctions.forEach((r,i)=>{t[i]||(t[i]=(o,...a)=>r.executor(e,r.functionDef,a))});break}n=n.parent}return t}formatXsltNumberPicture(e,t,n){if(Number.isNaN(e))return n.naN;if(!Number.isFinite(e))return e<0?`${n.minusSign}${n.infinity}`:n.infinity;let r=t.split(n.patternSeparator),i=e<0,o=(i&&r.length>1?r[1]:r[0])||"",a=Math.abs(e),c=new Set([n.digit,n.zeroDigit,n.groupingSeparator,n.decimalSeparator]),u=-1,l=-1;for(let L=0;L<o.length;L++)c.has(o[L])&&(u===-1&&(u=L),l=L);if(u===-1)return o;let p=o.slice(0,u),h=o.slice(l+1),m=o.slice(u,l+1),d=a;o.includes(n.percent)&&(d*=100),o.includes(n.perMille)&&(d*=1e3);let y=m.indexOf(n.decimalSeparator),E=y>=0?m.slice(0,y):m,T=y>=0?m.slice(y+1):"",P=E.split("").filter(L=>L===n.zeroDigit).length,A=T.split("").filter(L=>L===n.zeroDigit).length,w=T.split("").filter(L=>L===n.zeroDigit||L===n.digit).length,F=w>0?d.toFixed(w):Math.round(d).toString(),[j,Y=""]=F.split(".");for(j.length<P&&(j=this.leftPad(j,P,n.zeroDigit));Y.length>A&&Y.endsWith(n.zeroDigit);)Y=Y.slice(0,-1);let ee=E.lastIndexOf(n.groupingSeparator);if(ee>=0){let L=E.slice(ee+1).split("").filter(Bn=>Bn===n.zeroDigit||Bn===n.digit).length;L>0&&(j=this.applyGrouping(j,n.groupingSeparator,L))}let q=Y.length>0?`${j}${n.decimalSeparator}${Y}`:j;return i&&r.length<2?`${n.minusSign}${p}${q}${h}`:`${p}${q}${h}`}applyGrouping(e,t,n){if(n<=0||e.length<=n)return e;let r=[];for(let i=e.length;i>0;i-=n){let o=Math.max(0,i-n);r.unshift(e.slice(o,i))}return r.join(t)}leftPad(e,t,n){if(e.length>=t)return e;let r=n&&n.length>0?n.charAt(0):"0",i=t-e.length,o="";for(let a=0;a<i;a++)o+=r;return o+e}convertXPathNodeToXNode(e,t){if(!e)return null;let n;if(e.nodeType===9){if(e.childNodes&&e.childNodes.length>0){let r=e.childNodes[0],i=this.convertXPathNodeToXNode(r,t);return i?(n=i,n):null}return null}else if(e.nodeType===3){let r=e.textContent||"";n=new k(3,"#text",r,t)}else if(n=new k(1,e.nodeName||"element","",t),e.namespaceUri&&(n.namespaceUri=e.namespaceUri),e.childNodes&&e.childNodes.length>0){for(let r=0;r<e.childNodes.length;r++){let i=e.childNodes[r],o=this.convertXPathNodeToXNode(i,t);o&&(o.parentNode=n,n.childNodes.push(o))}n.childNodes.length>0&&(n.firstChild=n.childNodes[0],n.lastChild=n.childNodes[n.childNodes.length-1])}return n}xmlToJson(e){if(!e)return'""';let t=me(e,!0);return JSON.stringify(t)}wrapResult(e,t){if(e==null)return new Z([]);if(Array.isArray(e)){let n=e.map(r=>this.xPathNodeToXNode(r)).filter(r=>r!==null);return n.length>0||e.length===0?new Z(n):new G(e.map(r=>String(r)).join(" "))}if(typeof e=="string")return new G(e);if(typeof e=="number")return new fe(e);if(typeof e=="boolean")return new v(e);if(typeof e=="object"){if(e.__isMap)return new St(e);if(e.__isArray)return new Ct(e);if(e.__isFunctionItem)return new wt(e)}return new Z([])}clearCache(){}};ce();var Re=class{constructor(e,t){this.xpathExpression=e,this.nodeConverter=t,e instanceof Ee&&(this.absolute=e.absolute,this.steps=e.steps.map((n,r)=>({axis:n.axis,nodeTest:n.nodeTest,predicates:n.predicates,hasPositionalPredicate:!1,predicate:n.predicates||[],evaluate:i=>{let o=this.nodeConverter.exprContextToXPathContext(i),a=n.evaluate(o);return this.nodeConverter.wrapResult(a,i)}})))}evaluate(e){let t=this.nodeConverter.exprContextToXPathContext(e),n=this.xpathExpression.evaluate(t);return this.nodeConverter.wrapResult(n,e)}};var ve=class extends Re{constructor(e,t){super(e,t),this.absolute=e.absolute,this.steps=e.steps.map(n=>({axis:n.axis,nodeTest:n.nodeTest,predicates:n.predicates||[],predicate:n.predicates||[],hasPositionalPredicate:this.hasPositionalPredicate(n.predicates||[])}))}hasPositionalPredicate(e){return!1}appendStep(e){this.steps.push(e)}prependStep(e){this.steps.unshift(e)}};var We=class extends Re{constructor(e,t,n,r){super(e,t),this.expr1=n,this.expr2=r}};var tt=class{constructor(){this.lexers=new Map;this.parsers=new Map;this.parseCache=new Map;this.nodeConverter=new br}getLexer(e){let t=e||"1.0";return this.lexers.has(t)||this.lexers.set(t,new Ie({version:t})),this.lexers.get(t)}getParser(e){let t=e||"1.0";return this.parsers.has(t)||this.parsers.set(t,va(t)),this.parsers.get(t)}xPathParse(e,t,n="1.0"){let r=`${e}:${t||""}:${n}`;if(this.parseCache.has(r))return this.parseCache.get(r);let i=this.getLexer(n),o=this.getParser(n),a=i.scan(e),c=o.parse(a),u=this.wrapExpression(c,t);return this.parseCache.set(r,u),u}xPathEval(e,t){let n=t.xsltVersion||"1.0",r=n==="3.0"?"3.1":n;return this.xPathParse(e,void 0,r).evaluate(t)}xPathSort(e,t){if(t.length===0)return;let n=[];for(let i=0;i<e.contextSize();++i){let o=e.nodeList[i],a={node:o,key:[]},c=e.clone([o],0);for(let u of t){let l=u.expr.evaluate(c),p;u.type==="text"?p=l.stringValue():u.type==="number"&&(p=l.numberValue()),a.key.push({value:p,order:u.order})}a.key.push({value:i,order:"ascending"}),n.push(a)}n.sort(this.xPathSortByKey);let r=[];for(let i=0;i<n.length;++i){let o=n[i].node;o.siblingPosition=i,r.push(o)}e.nodeList=r,e.setNode(0)}xPathSortByKey(e,t){for(let n=0;n<e.key.length;++n){let r=e.key[n].order==="descending"?-1:1;if(e.key[n].value>t.key[n].value)return 1*r;if(e.key[n].value<t.key[n].value)return-1*r}return 0}wrapExpression(e,t){if(e instanceof Ee)return t&&e.steps.length>0&&!e.absolute&&(e.steps[0].axis=t),new ve(e,this.nodeConverter);if(e instanceof Ce){let n=this.wrapExpression(e.left,t),r=this.wrapExpression(e.right,t);return new We(e,this.nodeConverter,n,r)}return new Re(e,this.nodeConverter)}clearCache(){this.parseCache.clear(),this.nodeConverter.clearCache()}};var Ya={label:"[number]",prec:35,re:new RegExp("^\\d+(\\.\\d*)?"),key:void 0};var qe=class s{constructor(e,t="1.0",n,r,i,o,a,c,u,l,p,h){this.nodeList=e,this.xsltVersion=t,this.position=n||0,this.variables=i||{},this.keys=(a==null?void 0:a.keys)||{},this.knownNamespaces=o||{},this.parent=a||null,this.caseInsensitive=c||!1,this.ignoreAttributesWithoutValue=u||!1,this.returnOnFirstMatch=l||!1,this.ignoreNonElementNodesForNTA=p||!1,this.inApplyTemplates=!1,this.baseTemplateMatched=!1,this.warningsCallback=h!=null?h:a==null?void 0:a.warningsCallback,this.decimalFormatSettings=r||{decimalSeparator:".",groupingSeparator:",",infinity:"Infinity",minusSign:"-",naN:"NaN",percent:"%",perMille:"\u2030",zeroDigit:"0",digit:"#",patternSeparator:";"},a?this.root=a.root:this.nodeList[this.position].nodeType==9?this.root=this.nodeList[this.position]:this.root=this.nodeList[this.position].ownerDocument}clone(e,t){return new s(e||this.nodeList,this.xsltVersion,typeof t!="undefined"?t:this.position,this.decimalFormatSettings,Object.create(this.variables||{}),this.knownNamespaces,this,this.caseInsensitive,this.ignoreAttributesWithoutValue,this.returnOnFirstMatch,this.ignoreNonElementNodesForNTA,this.warningsCallback)}setVariable(e,t){if(t instanceof G||t instanceof v||t instanceof fe||t instanceof Z||t instanceof St||t instanceof Ct||t instanceof wt){this.variables[e]=t;return}t==="true"?this.variables[e]=new v(!0):t==="false"?this.variables[e]=new v(!1):Ya.re.test(String(t))?this.variables[e]=new fe(t):this.variables[e]=new G(t)}getVariable(e){return typeof this.variables[e]!="undefined"?this.variables[e]:this.parent?this.parent.getVariable(e):null}getRegexGroup(e){var t;return this.regexGroups&&e>=0&&e<this.regexGroups.length?(t=this.regexGroups[e])!=null?t:"":this.parent?this.parent.getRegexGroup(e):""}setNode(e){this.position=e}contextSize(){return this.nodeList.length}isCaseInsensitive(){return this.caseInsensitive}setCaseInsensitive(e){return this.caseInsensitive=e}isIgnoreAttributesWithoutValue(){return this.ignoreAttributesWithoutValue}setIgnoreAttributesWithoutValue(e){return this.ignoreAttributesWithoutValue=e}isReturnOnFirstMatch(){return this.returnOnFirstMatch}setReturnOnFirstMatch(e){return this.returnOnFirstMatch=e}isIgnoreNonElementNodesForNTA(){return this.ignoreNonElementNodesForNTA}setIgnoreNonElementNodesForNTA(e){return this.ignoreNonElementNodesForNTA=e}};var Dn=class{expressionMatch(e,t){if(e instanceof ve)return this.locationExpressionMatch(e,t);if(e instanceof We)return this.unionExpressionMatch(e,t);try{return e.evaluate(t).nodeSetValue()}catch(n){return[]}}locationExpressionMatch(e,t){if(!e.steps||e.steps.length<=0){if(e.absolute){let n=t.nodeList[t.position];return n.nodeName==="#document"?[n]:[]}return[t.nodeList[t.position]]}return e.absolute?e.steps[0].axis==="self"?this.absoluteXsltMatchByDocumentNode(e,t):this.absoluteXsltMatch(e,t):this.relativeXsltMatch(e,t)}unionExpressionMatch(e,t){return this.expressionMatch(e.expr1,t).concat(this.expressionMatch(e.expr2,t))}absoluteXsltMatchByDocumentNode(e,t){let n=t.clone([t.root],0),r=e.evaluate(n).nodeSetValue(),i=[];for(let o of r)o.id===t.nodeList[t.position].id&&i.push(o);return i}absoluteXsltMatch(e,t){var c;let n=t.root.childNodes.find(u=>u.nodeName!=="#dtd-section");if(!n)return[];let r=t.clone([n],0),i=e.evaluate(r).nodeSetValue(),o=[],a;t.nodeList.length===1&&t.nodeList[0].nodeName==="#document"?a=[t.nodeList[0].childNodes.find(u=>u.nodeName!=="#dtd-section")]:a=t.nodeList;for(let u of i)u.id===((c=a[t.position])==null?void 0:c.id)&&o.push(u);return o}relativeXsltMatch(e,t){let n=t.clone(),r=e.evaluate(n).nodeSetValue();return r.length===1&&r[0].nodeName==="#document"?[r[0].childNodes[0]]:r}};var Vn=class{constructor(){this.value=new v(!0)}evaluate(){return this.value}};var Fn=class{evaluate(e){return new v(e.nodeList[e.position].nodeType==8)}};var $n=class{evaluate(e){let t=e.nodeList[e.position];return new v(t.nodeType==1||t.nodeType==2)}};var Ln=class{constructor(e){if(this.name=e,e.indexOf(":")>0){let t=e.split(":");this.namespacePrefix=t[0],this.name=t[1]}this.re=new RegExp(`^${e}$`,"i")}evaluate(e){let t=e.nodeList[e.position];return this.namespacePrefix!==void 0?e.knownNamespaces[this.namespacePrefix]!==t.namespaceUri?new v(!1):e.caseInsensitive?t.localName.length!==this.name.length?new v(!1):new v(this.re.test(t.localName)):new v(t.localName===this.name):e.caseInsensitive?t.nodeName.length!==this.name.length?new v(!1):new v(this.re.test(t.nodeName)):new v(t.nodeName===this.name)}};var Un=class{constructor(e){this.regex=new RegExp(`^${e}:`),this.nsprefix=e}evaluate(e){let t=e.nodeList[e.position];return new v(t.nodeName.match(this.regex))}};var Wn=class{constructor(e){this.target=e}evaluate(e){let t=e.nodeList[e.position];return new v(t.nodeType==7&&(!this.target||t.nodeName==this.target))}};var qn=class{evaluate(e){return new v(e.nodeList[e.position].nodeType==3)}};function At(s){switch(s.type){case"function":case"variable":case"attribute-set":return`${s.type}:${s.name||""}`;case"template":return s.name?`template:name:${s.name}`:s.match?`template:match:${s.mode||"#default"}:${s.match}`:"template:unknown";case"mode":return`mode:${s.name||"#default"}`;default:return`unknown:${s.type}`}}function Ga(s,e){return s.visibility==="private"?e:!0}function Qa(s){return s.visibility==="final"?!1:s.overridable}var Pr=class{constructor(){this.packages=new Map;this.loading=new Set}register(e){let t=this.makePackageKey(e.name,e.version);this.packages.set(t,e)}get(e,t){if(!t)return this.packages.get(e);let n=this.makePackageKey(e,t),r=this.packages.get(n);if(r)return r;if(!/[*<>=,]/.test(t))return;let o=[];if(this.packages.forEach((a,c)=>{a.name===e&&a.version&&this.satisfiesVersion(a.version,t)&&o.push(a)}),o.length!==0)return o.sort((a,c)=>this.compareVersions(c.version,a.version)),o[0]}satisfiesVersion(e,t){return t.includes(",")?t.split(",").map(r=>r.trim()).every(r=>this.satisfiesSingleConstraint(e,r)):this.satisfiesSingleConstraint(e,t)}satisfiesSingleConstraint(e,t){if(t.includes("*")){let a=t.replace(/\*$/,"").replace(/\.$/,"");if(!a)return!0;let c=e.split("."),u=a.split(".");for(let l=0;l<u.length;l++)if(c[l]!==u[l])return!1;return!0}let n=t.match(/^(>=|<=|>|<|=)?(.+)$/);if(!n)return!1;let r=n[1]||"=",i=n[2].trim(),o=this.compareVersions(e,i);switch(r){case">=":return o>=0;case">":return o>0;case"<=":return o<=0;case"<":return o<0;default:return o===0}}compareVersions(e,t){let n=e.split(".").map(o=>parseInt(o,10)||0),r=t.split(".").map(o=>parseInt(o,10)||0),i=Math.max(n.length,r.length);for(let o=0;o<i;o++){let a=n[o]||0,c=r[o]||0;if(a<c)return-1;if(a>c)return 1}return 0}has(e,t){let n=this.makePackageKey(e,t);return this.packages.has(n)}beginLoading(e){return this.loading.has(e)?!1:(this.loading.add(e),!0)}endLoading(e){this.loading.delete(e)}isLoading(e){return this.loading.has(e)}makePackageKey(e,t){return t?`${e}@${t}`:e}clear(){this.packages.clear(),this.loading.clear()}};var Tr=class{static validatePattern(e){let t=[];(e.includes("ancestor::")||e.includes("ancestor-or-self::"))&&t.push("Ancestor axes are not permitted in streamable patterns"),e.includes("parent::")&&t.push("Parent axis is not permitted in streamable patterns"),(e.includes("preceding::")||e.includes("preceding-sibling::"))&&t.push("Preceding axes are not permitted in streamable patterns");let n=e.match(/\[.*\]/g);if(n)for(let r of n)r.includes("[")&&r.includes("]")&&r.includes("[[")&&t.push("Nested predicates are not permitted in streamable patterns");return{isStreamable:t.length===0,issues:t}}static toStreamablePath(e){let t=e.split("/").filter(n=>n.length>0);return t.length===0?null:{path:t.map(n=>n.split("[")[0]),fromRoot:e.startsWith("/"),hasPredicates:e.includes("["),hasForwardAxis:e.includes("::"),isDeterministic:!0}}};var Xr=class{constructor(){this.elementStack=[];this.depth=0;this.activeCopies=new Map;this.mergeSources=[];this.isStreaming=!1;this.lookaheadBuffer=[]}startStreaming(){this.elementStack=[],this.depth=0,this.activeCopies.clear(),this.isStreaming=!0}endStreaming(){this.isStreaming=!1,this.activeCopies.clear(),this.lookaheadBuffer=[]}registerCopy(e){this.activeCopies.set(e.id,e)}unregisterCopy(e){this.activeCopies.delete(e)}getActiveCopies(){return Array.from(this.activeCopies.values()).filter(e=>e.isActive)}enterElement(e){this.elementStack.push(e),this.depth++}exitElement(){return this.depth--,this.elementStack.pop()}getCurrentPath(){return[...this.elementStack]}getDepth(){return this.depth}isStreamingActive(){return this.isStreaming}bufferEvent(e){this.lookaheadBuffer.push(e)}getBufferedEvents(){return this.lookaheadBuffer}clearBuffer(){this.lookaheadBuffer=[]}};var Sr=class{constructor(){this.copies=new Map;this.copyIdCounter=0}createCopy(e){let t=`copy-${++this.copyIdCounter}`,n={id:t,handler:e,isActive:!0,eventQueue:[],currentDepth:0};return this.copies.set(t,n),n}distributeEvent(e){return b(this,null,function*(){for(let t of Array.from(this.copies.values()))t.isActive&&t.eventQueue.push(e)})}closeCopy(e){let t=this.copies.get(e);t&&(t.isActive=!1)}getCopy(e){return this.copies.get(e)}clear(){this.copies.clear(),this.copyIdCounter=0}};var Cr=class{constructor(){this.sources=[]}addSource(e){this.sources.push(e)}getNextMergeGroup(){if(this.sources.every(r=>r.isExhausted))return[];let e=null,t=null;for(let r of this.sources)!r.isExhausted&&r.buffer.length>0&&e===null&&(e=r,t=r.buffer[0]);if(e===null)return[];let n=[];for(;e.buffer.length>0&&n.length<1;)n.push(e.buffer.shift());return n}isComplete(){return this.sources.every(e=>e.isExhausted&&e.buffer.length===0)}clear(){this.sources=[]}};var wr=class{static detectMode(e){var n;let t=(n=e.getAttributeValue)==null?void 0:n.call(e,"streamable");return t==="yes"?"streamed":"non-consuming"}static isTemplateBodyStreamable(e){let t=["xsl:variable","xsl:result-document","xsl:for-each"];return!0}};var Ar=class{parse(e,t){return b(this,null,function*(){let r=new Ue().xmlParse(e);yield t({type:"document-start",depth:0});for(let i of r.childNodes)yield this.emitNode(i,t,0);yield t({type:"document-end",depth:0})})}canStream(e){return b(this,null,function*(){return!0})}emitNode(e,t,n){return b(this,null,function*(){var r,i,o,a,c;switch(e.nodeType){case 9:{for(let u of e.childNodes)yield this.emitNode(u,t,n);return}case 1:{let u=e.childNodes.filter(h=>h.nodeType===2),l=u.length>0?new Map:void 0;if(l)for(let h of u)l.set(h.nodeName,`${(r=h.nodeValue)!=null?r:""}`),yield t({type:"attribute",name:h.nodeName,namespaceUri:h.namespaceUri||void 0,content:`${(i=h.nodeValue)!=null?i:""}`,depth:n+1});let p=e.childNodes.filter(h=>h.nodeType!==2);yield t({type:"start-element",name:e.nodeName,namespaceUri:e.namespaceUri||void 0,attributes:l,selfClosing:p.length===0,depth:n+1});for(let h of p)yield this.emitNode(h,t,n+1);yield t({type:"end-element",name:e.nodeName,namespaceUri:e.namespaceUri||void 0,depth:n+1});return}case 3:case 4:{let u=`${(o=e.nodeValue)!=null?o:""}`;u.length>0&&(yield t({type:"text",content:u,depth:n+1}));return}case 8:{yield t({type:"comment",content:`${(a=e.nodeValue)!=null?a:""}`,depth:n+1});return}case 7:{yield t({type:"processing-instruction",name:e.nodeName,content:`${(c=e.nodeValue)!=null?c:""}`,depth:n+1});return}default:return}})}};var Or=class{constructor(e){this.context=new Xr;this.copyManager=new Sr;this.mergeCoordinator=new Cr;this.enabled=!1;this.parser=new Ar;this.xPath=e.xPath,this.version=e.version}setVersion(e){this.version=e}isEnabled(){return this.enabled}getContext(){return this.context}getCopyManager(){return this.copyManager}getMergeCoordinator(){return this.mergeCoordinator}setParser(e){this.parser=e}validatePattern(e){return Tr.validatePattern(e)}detectMode(e){return wr.detectMode(e)}processStream(e,t,n,r){return b(this,null,function*(){if(!this.version||parseFloat(this.version)<3)throw new Error("<xsl:stream> is only supported in XSLT 3.0 or later.");let i=f(t,"select");if(!i)throw new Error('<xsl:stream> requires a "select" attribute specifying the input document.');let o=this.enabled;this.enabled=!0,this.context.startStreaming();try{let a=e.clone(),c=this.xPath.xPathEval(i,a),u=[];c.type==="node-set"?u=c.nodeSetValue():c.type==="node"&&(u=[c]);for(let l of u)yield r.processChildren(e,t,n)}finally{this.enabled=o,this.context.endStreaming(),this.copyManager.clear()}})}processFork(e,t,n,r){return b(this,null,function*(){if(!this.enabled)throw new Error("<xsl:fork> can only be used within <xsl:stream>.");for(let i of t.childNodes)if(r.isXsltElement(i,"fork-sequence")){let o=this.copyManager.createCopy(a=>b(this,null,function*(){yield r.processChildren(e,i,n)}));this.context.registerCopy(o)}})}processMerge(e,t,n,r){return b(this,null,function*(){if(!this.version||parseFloat(this.version)<3)throw new Error("<xsl:merge> is only supported in XSLT 3.0 or later.");let i=[];for(let o of t.childNodes)if(r.isXsltElement(o,"merge-source")){let a=f(o,"select");if(!a)throw new Error('<xsl:merge-source> requires a "select" attribute.');let c={select:a,mergeKeys:[],position:0,isExhausted:!1,buffer:[]};for(let p of o.childNodes)if(r.isXsltElement(p,"merge-key")){let h=f(p,"select"),m=f(p,"order")||"ascending";c.mergeKeys.push({select:h||".",order:m})}let u=this.xPath.xPathEval(a,e),l=u.nodeSetValue?u.nodeSetValue():[];c.buffer=Array.isArray(l)?l.slice():l?[l]:[],c.isExhausted=c.buffer.length===0,i.push(c)}if(i.length===0)throw new Error("<xsl:merge> requires at least one <xsl:merge-source> child element.");for(let o of i)this.mergeCoordinator.addSource(o);try{if(i.some(a=>a.buffer.length>0))for(let a of i){for(;a.buffer.length>0;){let c=a.buffer.shift(),u=e.clone([c],0);for(let l of t.childNodes)r.isXsltElement(l,"merge-action")&&(yield r.processChildren(u,l,n))}a.isExhausted=!0}}finally{this.mergeCoordinator.clear()}})}reset(){this.enabled=!1,this.context.endStreaming(),this.copyManager.clear(),this.mergeCoordinator.clear()}};function Au(s){let e=s.nodeTest;if(s.predicate&&s.predicate.length>0||s.predicates&&s.predicates.length>0)return .5;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case"wildcard":return e.name&&e.name.endsWith(":*")?-.25:-.5;case"node-type":return e.nodeType==="processing-instruction"&&e.name?0:-.5;case"processing-instruction":return e.target||e.name?0:-.5;case"name":return 0;default:return 0}return e instanceof Vn||e instanceof $n||e instanceof qn||e instanceof Fn?-.5:e instanceof Wn?e.target?0:-.5:e instanceof Un?-.25:(e instanceof Ln,0)}function Ou(s){if(!s.steps||s.steps.length===0)return s.absolute?-.5:0;if(s.steps.length>1)return .5;let e=s.steps[0],t=e.axis;return t&&t!=="child"&&t!=="attribute"&&t!=="self-and-siblings"?.5:Au(e)}function Ru(s,e){let t=s.getAttributeValue("mode");return e?e==="#all"||t==="#all"?!0:t===e:!t||t==="#default"}function vu(s){return s.nodeType!==1?!1:(s.namespaceUri==="http://www.w3.org/1999/XSL/Transform"||s.prefix==="xsl")&&s.localName==="template"}function Iu(s,e){try{let t=e.xPathParse(s);return t instanceof ve?Ou(t):.5}catch(t){return 0}}function Rr(s,e,t,n){var o;let r=[],i=0;for(let a of s.childNodes){if(!vu(a)||!Ru(a,e))continue;let c=a.getAttributeValue("match");if(!c)continue;let u=a.getAttributeValue("priority"),l=u?parseFloat(u):null,p=n==null?void 0:n.get(a),h=0;if(p){let d=Number.MAX_SAFE_INTEGER/2,y=-p.importDepth*d,E=(o=p.order)!=null?o:0;h=y+E}let m=Ka(c);for(let d of m){let y=Iu(d,t),E=l!==null&&!isNaN(l)?l:y;r.push({template:a,explicitPriority:l!==null&&!isNaN(l)?l:null,defaultPriority:y,effectivePriority:E,importPrecedence:h,documentOrder:i++,matchPattern:d})}}return r}function Ka(s){let e=[],t="",n=0,r=!1,i=!1;for(let o=0;o<s.length;o++){let a=s[o];a==="'"&&!i?(r=!r,t+=a):a==='"'&&!r?(i=!i,t+=a):!r&&!i?a==="["||a==="("?(n++,t+=a):a==="]"||a===")"?(n--,t+=a):a==="|"&&n===0?(e.push(t.trim()),t=""):t+=a:t+=a}return t.trim()&&e.push(t.trim()),e}function _u(s,e,t,n,r){if(e==="/")return s.nodeName==="#document";if(e.startsWith("@")){if(s.nodeType!==2)return!1;let i=e.substring(1);if(i==="*")return!0;let o=s.localName||s.nodeName,a=i.includes(":")?i.substring(i.indexOf(":")+1):i;return o===a||s.nodeName===i}if(e==="*"&&s.nodeType===1||!e.includes("/")&&!e.includes("[")&&!e.startsWith("@")&&(e===s.nodeName||e===s.localName))return!0;if(e.includes("/")||e.includes("["))try{let i=e.startsWith("/")?e:"//"+e,o=t.clone([t.root],0);if(r.xPathEval(i,o).nodeSetValue().some(u=>u.id===s.id))return!0}catch(i){}if(!e.includes("/")&&!e.includes("[")&&!e.startsWith("@"))try{let i=t.clone([s],0),o=r.xPathParse(e,"self-and-siblings");if(n.expressionMatch(o,i).some(c=>c.id===s.id))return!0}catch(i){}return!1}function yi(s,e,t,n,r){let i=Ka(e);for(let o of i)if(_u(s,o,t,n,r))return!0;return!1}function Be(s,e,t,n,r){let i=r!=null?r:console.warn,o=[],a=e.nodeList[e.position];for(let l of s)try{yi(a,l.matchPattern,e,t,n)&&o.push(l)}catch(p){i(`Failed to match pattern "${l.matchPattern}":`,p)}if(o.length===0)return{selectedTemplate:null,hasConflict:!1,conflictingTemplates:[]};o.sort((l,p)=>l.importPrecedence!==p.importPrecedence?p.importPrecedence-l.importPrecedence:l.effectivePriority!==p.effectivePriority?p.effectivePriority-l.effectivePriority:p.documentOrder-l.documentOrder);let c=o[0],u=o.filter(l=>l.importPrecedence===c.importPrecedence&&l.effectivePriority===c.effectivePriority);return{selectedTemplate:c.template,hasConflict:u.length>1,conflictingTemplates:u.length>1?u:[],originalComponent:c.originalComponent}}function Ha(s,e,t){if(!s.hasConflict||s.conflictingTemplates.length<2)return;let n=s.conflictingTemplates.map(i=>`"${i.matchPattern}" (priority: ${i.effectivePriority})`).join(", ");(t!=null?t:console.warn)(`XSLT Warning: Ambiguous template match for node <${e.nodeName}>. Multiple templates match with equal priority: ${n}. Using the last one in document order.`)}var vr=class{constructor(){this.accumulators=new Map;this.accumulatorStates=new Map}registerAccumulator(e){this.accumulators.set(e.name,e),this.accumulatorStates.set(e.name,{currentValue:null,valueStack:[]})}getAccumulator(e){return this.accumulators.get(e)}getAllAccumulators(){return Array.from(this.accumulators.values())}getAccumulatorState(e){return this.accumulatorStates.get(e)}setAccumulatorState(e,t){this.accumulatorStates.set(e,t)}clear(){this.accumulators.clear(),this.accumulatorStates.clear()}};var Ir=class{constructor(e={cData:!0,escape:!0,selfClosingTags:!0,parameters:[]}){this.styleSheetStack=[];this.importedStylesheets=new Map;this.templateSourceMap=new Map;this.currentTemplateStack=[];this.packageRegistry=new Pr;this.currentPackage=null;this.currentOverrideContext=null;this.accumulatorRegistry=new vr;this.xPath=new tt,this.xmlParser=new Ue,this.matchResolver=new Dn,this.options={cData:e.cData===!0,escape:e.escape===!0,selfClosingTags:e.selfClosingTags===!0,outputMethod:e.outputMethod,parameters:e.parameters||[]},this.outputMethod=e.outputMethod||"xml",this.outputOmitXmlDeclaration="no",this.outputVersion="",this.itemSeparator="",this.stripSpacePatterns=[],this.preserveSpacePatterns=[],this.namespaceAliases=new Map,this.supportedExtensions=new Set(["http://www.w3.org/1999/XSL/Transform"]),this.attributeSets=new Map,this.userDefinedFunctions=new Map,this.resultDocuments=new Map,this.decimalFormatSettings={decimalSeparator:".",groupingSeparator:",",infinity:"Infinity",minusSign:"-",naN:"NaN",percent:"%",perMille:"\u2030",zeroDigit:"0",digit:"#",patternSeparator:";"},this.firstTemplateRan=!1,this.forwardsCompatible=!1,this.warningsCallback=console.warn.bind(console),this.fetchFunction=e.fetchFunction||(t=>b(this,null,function*(){let n=typeof globalThis!="undefined"&&typeof globalThis.fetch=="function"?globalThis.fetch:null;if(!n)throw new Error("No global fetch implementation available. Please provide options.fetchFunction or use a runtime that exposes globalThis.fetch.");return(yield n(t)).text()})),this.streamingProcessor=new Or({xPath:this.xPath,version:""})}xsltProcess(e,t){return b(this,null,function*(){let n=yield this.xsltProcessToDocument(e,t);if(this.outputMethod==="json")return ka(n);let r=this.outputMethod;this.outputMethod==="adaptive"&&(r=Ma(n));let i=r;return r==="html"&&this.outputVersion==="5.0"&&(i="html"),Mn(n,{cData:this.options.cData,escape:this.options.escape,selfClosingTags:this.options.selfClosingTags,outputMethod:i,outputVersion:this.outputVersion,itemSeparator:this.itemSeparator})})}xsltProcessToDocument(e,t){return b(this,null,function*(){let n=new ue;this.outputDocument=n;let r=new qe([e]);if(r.warningsCallback=this.warningsCallback,this.options.parameters.length>0)for(let i of this.options.parameters)r.setVariable(i.name,this.toNodeValue(i.value));return yield this.xsltProcessContext(r,t,this.outputDocument),n})}xsltProcessContext(e,t,n){return b(this,null,function*(){if(e.warningsCallback||(e.warningsCallback=this.warningsCallback),!this.isXsltElement(t))t.nodeType===1&&!this.isExtensionElementSupported(t)?yield this.xsltExtensionElement(e,t,n):yield this.xsltPassThrough(e,t,n);else{let r,i,o,a;switch(t.localName){case"apply-imports":yield this.xsltApplyImports(e,t,n);break;case"apply-templates":yield this.xsltApplyTemplates(e,t,n);break;case"analyze-string":yield this.xsltAnalyzeString(e,t,n);break;case"attribute":yield this.xsltAttribute(e,t,n);break;case"attribute-set":break;case"call-template":yield this.xsltCallTemplate(e,t,n);break;case"choose":yield this.xsltChoose(e,t,n);break;case"comment":yield this.xsltComment(e,t,n);break;case"copy":r=this.xsltCopy(n||this.outputDocument,e.nodeList[e.position]),r&&(yield this.xsltChildNodes(e,t,r));break;case"copy-of":i=f(t,"select"),o=this.xPath.xPathEval(i,e);let c=n||this.outputDocument;if(o.type==="node-set"){a=o.nodeSetValue();for(let p=0;p<a.length;++p)this.xsltCopyOf(c,a[p])}else{let p=ae(this.outputDocument,o.stringValue());p.siblingPosition=c.childNodes.length,V(c,p)}break;case"accumulator":this.xsltAccumulator(e,t);break;case"accumulator-rule":throw new Error("<xsl:accumulator-rule> must be a child of <xsl:accumulator>.");case"decimal-format":this.xsltDecimalFormat(e,t);break;case"evaluate":yield this.xsltEvaluate(e,t,n);break;case"element":yield this.xsltElement(e,t,n);break;case"fallback":let u=t.parentNode;if(!(u&&u.nodeType===1&&!this.isExtensionElementSupported(u)))throw new Error("<xsl:fallback> must be a direct child of an extension element");yield this.xsltChildNodes(e,t,n);break;case"for-each":yield this.xsltForEach(e,t,n);break;case"for-each-group":yield this.xsltForEachGroup(e,t,n);break;case"function":this.xsltFunction(e,t);break;case"iterate":yield this.xsltIterate(e,t,n);break;case"try":yield this.xsltTry(e,t,n);break;case"if":yield this.xsltIf(e,t,n);break;case"import":yield this.xsltImport(e,t,n);break;case"include":yield this.xsltInclude(e,t,n);break;case"key":this.xsltKey(e,t);break;case"matching-substring":throw new Error("<xsl:matching-substring> must be a child of <xsl:analyze-string>.");case"message":yield this.xsltMessage(e,t);break;case"namespace":yield this.xsltNamespace(e,t,n);break;case"namespace-alias":this.xsltNamespaceAlias(t);break;case"non-matching-substring":throw new Error("<xsl:non-matching-substring> must be a child of <xsl:analyze-string>.");case"on-empty":throw new Error("<xsl:on-empty> must be a child of a sequence-generating instruction like <xsl:for-each>, <xsl:for-each-group>, or <xsl:apply-templates>.");case"on-non-empty":throw new Error("<xsl:on-non-empty> must be a child of a sequence-generating instruction like <xsl:for-each>, <xsl:for-each-group>, or <xsl:apply-templates>.");case"number":this.xsltNumber(e,t,n);break;case"otherwise":throw new Error("<xsl:otherwise> must be a child of <xsl:choose>.");case"output":this.outputMethod=f(t,"method"),this.outputOmitXmlDeclaration=f(t,"omit-xml-declaration"),this.outputVersion=f(t,"version")||"",this.itemSeparator=f(t,"item-separator")||"";break;case"package":yield this.xsltPackage(e,t,n);break;case"use-package":yield this.xsltUsePackage(e,t,n);break;case"expose":this.xsltExpose(e,t);break;case"accept":this.xsltAccept(e,t);break;case"override":yield this.xsltOverride(e,t,n);break;case"original":yield this.xsltOriginal(e,t,n);break;case"param":yield this.xsltVariable(e,t,!1);break;case"preserve-space":this.xsltPreserveSpace(t);break;case"perform-sort":yield this.xsltPerformSort(e,t,n);break;case"processing-instruction":yield this.xsltProcessingInstruction(e,t,n);break;case"result-document":yield this.xsltResultDocument(e,t);break;case"sequence":yield this.xsltSequence(e,t,n);break;case"sort":this.xsltSort(e,t);break;case"strip-space":this.xsltStripSpace(t);break;case"stylesheet":case"transform":yield this.xsltTransformOrStylesheet(e,t,n);break;case"stream":yield this.xsltStream(e,t,n);break;case"fork":yield this.xsltFork(e,t,n);break;case"merge":yield this.xsltMerge(e,t,n);break;case"mode":this.currentPackage&&this.xsltMode(e,t);break;case"template":yield this.xsltTemplate(e,t,n);break;case"text":this.xsltText(e,t,n);break;case"value-of":this.xsltValueOf(e,t,n);break;case"variable":yield this.xsltVariable(e,t,!0);break;case"when":throw new Error("<xsl:when> must be a child of <xsl:choose>.");case"with-param":throw new Error("<xsl:with-param> must be a child of <xsl:call-template> or <xsl:apply-templates>.");default:yield this.xsltUnknownInstruction(e,t,n)}}})}xsltUnknownInstruction(e,t,n){return b(this,null,function*(){let r=`xsl:${t.localName}`;if(this.forwardsCompatible){let i=this.getFallbackElement(t);i&&(yield this.xsltChildNodes(e,i,n));return}throw new Error(`Unknown XSLT instruction: <${r}>. This element is not supported in XSLT 1.0. If this is a future XSLT version feature, use version="2.0" or higher to enable forwards-compatible processing mode.`)})}xsltApplyTemplates(e,t,n){return b(this,null,function*(){var d,y,E;let r=f(t,"select"),i=[];r?i=this.xPath.xPathEval(r,e).nodeSetValue():i=e.nodeList[e.position].childNodes;let o=this.findConditionalChild(t,"on-empty"),a=this.findConditionalChild(t,"on-non-empty");if(i.length===0){o&&(yield this.xsltChildNodes(e.clone(),o,n));return}if(a){yield this.xsltChildNodes(e.clone(),a,n);return}let u=f(t,"mode")||null,l=t.ownerDocument.documentElement,p=Rr(l,u,this.xPath,this.templateSourceMap);p=p.concat(this.collectAcceptedTemplates(u));let h=e.clone();yield this.xsltWithParam(h,t);let m=h.clone(i);for(let T=0;T<m.contextSize();++T){let P=m.nodeList[T];if(P.nodeType===3){if(!this.xsltPassText(P))continue;let A=h.clone([P],0);A.inApplyTemplates=!0;let w=Be(p,A,this.matchResolver,this.xPath,this.warningsCallback);if(w.selectedTemplate){let F=this.templateSourceMap.get(w.selectedTemplate),j=f(w.selectedTemplate,"match"),Y=f(w.selectedTemplate,"mode");this.currentTemplateStack.push({template:w.selectedTemplate,stylesheetDepth:(d=F==null?void 0:F.importDepth)!=null?d:0,mode:Y||u,match:j});let ee=this.currentOverrideContext,q=w.originalComponent||w.selectedTemplate.__originalComponent;q&&(this.currentOverrideContext=q);try{yield this.xsltChildNodes(A,w.selectedTemplate,n)}finally{this.currentTemplateStack.pop(),this.currentOverrideContext=ee}}else{let F=e.clone([P],0);this.commonLogicTextNode(F,P,n)}}else{let A=m.clone([P],0);A.inApplyTemplates=!0;let w=Be(p,A,this.matchResolver,this.xPath,this.warningsCallback);if(w.hasConflict&&Ha(w,P,this.warningsCallback),w.selectedTemplate){let F=this.templateSourceMap.get(w.selectedTemplate),j=f(w.selectedTemplate,"match"),Y=f(w.selectedTemplate,"mode");this.currentTemplateStack.push({template:w.selectedTemplate,stylesheetDepth:(y=F==null?void 0:F.importDepth)!=null?y:0,mode:Y||u,match:j});let ee=this.currentOverrideContext,q=w.originalComponent||w.selectedTemplate.__originalComponent;q&&(this.currentOverrideContext=q);try{yield this.xsltChildNodes(A,w.selectedTemplate,n)}finally{this.currentTemplateStack.pop(),this.currentOverrideContext=ee}}else if(P.nodeType===1&&P.childNodes&&P.childNodes.length>0){let F=P.childNodes.filter(j=>j.nodeType!==2);for(let j=0;j<F.length;++j){let Y=F[j];if(Y.nodeType===3){let ee=h.clone([Y],0);ee.inApplyTemplates=!0;let q=Be(p,ee,this.matchResolver,this.xPath,this.warningsCallback);q.selectedTemplate?yield this.xsltChildNodes(ee,q.selectedTemplate,n):this.commonLogicTextNode(ee,Y,n)}else{let ee=h.clone([Y],0);ee.inApplyTemplates=!0;let q=Be(p,ee,this.matchResolver,this.xPath,this.warningsCallback);if(q.selectedTemplate){let L=this.templateSourceMap.get(q.selectedTemplate),Bn=f(q.selectedTemplate,"match"),Ja=f(q.selectedTemplate,"mode");this.currentTemplateStack.push({template:q.selectedTemplate,stylesheetDepth:(E=L==null?void 0:L.importDepth)!=null?E:0,mode:Ja||u,match:Bn});try{yield this.xsltChildNodes(ee,q.selectedTemplate,n)}finally{this.currentTemplateStack.pop()}}else Y.nodeType===1&&(yield this.applyBuiltInTemplate(Y,p,u,h,n))}}}else P.nodeType===3&&this.commonLogicTextNode(A,P,n)}}})}applyBuiltInTemplate(e,t,n,r,i){return b(this,null,function*(){var a;if(!e.childNodes||e.childNodes.length===0)return;let o=e.childNodes.filter(c=>c.nodeType!==2&&c.nodeName!=="#dtd-section");for(let c of o)if(c.nodeType===3){let u=r.clone([c],0);u.inApplyTemplates=!0;let l=Be(t,u,this.matchResolver,this.xPath,this.warningsCallback);if(l.selectedTemplate){let p=this.currentOverrideContext,h=l.originalComponent||l.selectedTemplate.__originalComponent;h&&(this.currentOverrideContext=h);try{yield this.xsltChildNodes(u,l.selectedTemplate,i)}finally{this.currentOverrideContext=p}}else this.commonLogicTextNode(u,c,i)}else{let u=r.clone([c],0);u.inApplyTemplates=!0;let l=Be(t,u,this.matchResolver,this.xPath,this.warningsCallback);if(l.selectedTemplate){let p=this.templateSourceMap.get(l.selectedTemplate),h=f(l.selectedTemplate,"match"),m=f(l.selectedTemplate,"mode");this.currentTemplateStack.push({template:l.selectedTemplate,stylesheetDepth:(a=p==null?void 0:p.importDepth)!=null?a:0,mode:m||n,match:h});let d=this.currentOverrideContext,y=l.originalComponent||l.selectedTemplate.__originalComponent;y&&(this.currentOverrideContext=y);try{yield this.xsltChildNodes(u,l.selectedTemplate,i)}finally{this.currentTemplateStack.pop(),this.currentOverrideContext=d}}else c.nodeType===1&&(yield this.applyBuiltInTemplate(c,t,n,r,i))}})}xsltApplyImports(e,t,n){return b(this,null,function*(){if(this.currentTemplateStack.length===0)throw new Error("<xsl:apply-imports> can only be used within a template");let r=this.currentTemplateStack[this.currentTemplateStack.length-1],{stylesheetDepth:i,mode:o}=r,a=e.nodeList[e.position],c=t.ownerDocument.documentElement,u=[];c&&u.push(c),this.importedStylesheets.forEach(T=>{if(T)if(T.nodeType===9){let P=T.childNodes.find(A=>A.nodeType===1);P&&u.push(P)}else T.nodeType===1&&u.push(T)});let l=[],p=0;for(let T of u){let P=Rr(T,o,this.xPath,this.templateSourceMap);for(let A of P)A.documentOrder+=p;p+=P.length,l=l.concat(P)}let h=l.filter(T=>{let P=this.templateSourceMap.get(T.template);return P&&P.importDepth>i});if(h.length===0)return;let m=e.clone([a],0),d=Be(h,m,this.matchResolver,this.xPath,this.warningsCallback);if(!d.selectedTemplate)return;let y=e.clone();yield this.xsltWithParam(y,t);let E=this.templateSourceMap.get(d.selectedTemplate);if(E){let T=f(d.selectedTemplate,"match"),P=f(d.selectedTemplate,"mode");this.currentTemplateStack.push({template:d.selectedTemplate,stylesheetDepth:E.importDepth,mode:P||o,match:T});let A=this.currentOverrideContext,w=d.originalComponent||d.selectedTemplate.__originalComponent;w&&(this.currentOverrideContext=w);try{yield this.xsltChildNodes(y,d.selectedTemplate,n)}finally{this.currentTemplateStack.pop(),this.currentOverrideContext=A}}})}xsltAttribute(e,t,n){return b(this,null,function*(){let r=f(t,"name"),i=this.xsltAttributeValue(r,e),o=Oe(this.outputDocument);yield this.xsltChildNodes(e,t,o);let a=di(o);if(n&&(W(n,i,a),i.includes(":"))){let c=i.split(":")[0];if(c!=="xmlns"){let l=f(t,"namespace")||this.resolveNamespaceUriForPrefix(t,c);if(l){let p=`xmlns:${c}`;this.isNamespaceDeclaredOnAncestor(n,p,l)||W(n,p,l)}}}})}xsltCallTemplate(e,t,n){return b(this,null,function*(){let r=f(t,"name"),i=t.ownerDocument.documentElement,o=e.clone();yield this.xsltWithParam(o,t);let a=null;if(this.currentPackage&&this.currentPackage.usedPackages.forEach(c=>{c.acceptedComponents.forEach(u=>{u.type==="template"&&u.name===r&&u.isAccepted&&(a=this.getEffectiveComponent(u).node)})}),a){yield this.xsltChildNodes(o,a,n);return}for(let c=0;c<i.childNodes.length;++c){let u=i.childNodes[c];if(u.nodeType===1&&this.isXsltElement(u,"template")&&Ze(u,"name")===r){yield this.xsltChildNodes(o,u,n);break}}})}xsltChoose(e,t,n){return b(this,null,function*(){for(let r of t.childNodes)if(r.nodeType===1){if(this.isXsltElement(r,"when")){let i=f(r,"test");if(this.xPath.xPathEval(i,e).booleanValue()){yield this.xsltChildNodes(e,r,n);break}}else if(this.isXsltElement(r,"otherwise")){yield this.xsltChildNodes(e,r,n);break}}})}xsltCopy(e,t){if(t.nodeType==1){let n=et(this.outputDocument,t.nodeName);if(t.namespaceUri!==null&&t.namespaceUri!==void 0){let r=t.prefix||(t.nodeName.includes(":")?t.nodeName.split(":")[0]:null),i=r?`xmlns:${r}`:"xmlns";this.isNamespaceDeclaredOnAncestor(e,i,t.namespaceUri)||W(n,i,t.namespaceUri)}return n.siblingPosition=e.childNodes.length,V(e,n),n}if(t.nodeType==3){if(this.shouldStripWhitespaceNode(t))return null;let n=ae(this.outputDocument,t.nodeValue);n.siblingPosition=e.childNodes.length,V(e,n)}else if(t.nodeType==4){let n=mr(this.outputDocument,t.nodeValue);n.siblingPosition=e.childNodes.length,V(e,n)}else if(t.nodeType==8){let n=Tt(this.outputDocument,t.nodeValue);n.siblingPosition=e.childNodes.length,V(e,n)}else if(t.nodeType==2&&(W(e,t.nodeName,t.nodeValue),t.prefix&&t.namespaceUri&&t.prefix!=="xmlns"&&!t.nodeName.startsWith("xmlns"))){let n=`xmlns:${t.prefix}`;this.isNamespaceDeclaredOnAncestor(e,n,t.namespaceUri)||W(e,n,t.namespaceUri)}return null}xsltComment(e,t,n){return b(this,null,function*(){let r=Oe(this.outputDocument);yield this.xsltChildNodes(e,t,r);let i=me(r),o=Tt(this.outputDocument,i);(n||this.outputDocument).appendChild(o)})}xsltProcessingInstruction(e,t,n){return b(this,null,function*(){let r=f(t,"name");if(!r)throw new Error('<xsl:processing-instruction> requires a "name" attribute');let i=this.xsltAttributeValue(r,e);if(!i)throw new Error("<xsl:processing-instruction> target name cannot be empty");if(i.toLowerCase()==="xml")throw new Error('Processing instruction target cannot be "xml"');if(!/^[a-zA-Z_][a-zA-Z0-9_:.-]*$/.test(i))throw new Error(`Invalid processing instruction target: "${i}"`);let o=Oe(this.outputDocument);yield this.xsltChildNodes(e,t,o);let a=me(o),c=_a(this.outputDocument,i,a),u=n||this.outputDocument;V(u,c)})}xsltCopyOf(e,t){if(t.nodeType==11||t.nodeType==9)for(let n=0;n<t.childNodes.length;++n)this.xsltCopyOf(e,t.childNodes[n]);else{let n=this.xsltCopy(e,t);if(n)for(let r=0;r<t.childNodes.length;++r)this.xsltCopyOf(n,t.childNodes[r])}}xsltDecimalFormat(e,t){let n=f(t,"name"),r=f(t,"decimal-separator"),i=f(t,"grouping-separator"),o=f(t,"infinity"),a=f(t,"minus-sign"),c=f(t,"NaN"),u=f(t,"percent"),l=f(t,"per-mille"),p=f(t,"zero-digit"),h=f(t,"digit"),m=f(t,"pattern-separator");this.decimalFormatSettings={name:n||this.decimalFormatSettings.name,decimalSeparator:r||this.decimalFormatSettings.decimalSeparator,groupingSeparator:i||this.decimalFormatSettings.groupingSeparator,infinity:o||this.decimalFormatSettings.infinity,minusSign:a||this.decimalFormatSettings.minusSign,naN:c||this.decimalFormatSettings.naN,percent:u||this.decimalFormatSettings.percent,perMille:l||this.decimalFormatSettings.perMille,zeroDigit:p||this.decimalFormatSettings.zeroDigit,digit:h||this.decimalFormatSettings.digit,patternSeparator:m||this.decimalFormatSettings.patternSeparator},e.decimalFormatSettings=this.decimalFormatSettings}xsltElement(e,t,n){return b(this,null,function*(){let r=f(t,"name"),i=this.xsltAttributeValue(r,e),o=et(this.outputDocument,i),a=f(t,"use-attribute-sets");a&&(yield this.applyAttributeSets(e,o,a)),o.siblingPosition=(n||this.outputDocument).childNodes.length,V(n||this.outputDocument,o);let c=e.clone();yield this.xsltChildNodes(c,t,o)})}xsltAccumulator(e,t){let n=f(t,"name");if(!n)throw new Error('<xsl:accumulator> requires a "name" attribute');let r=f(t,"initial-value")||"()",i=f(t,"as")||"xs:anyAtomicType*",o=f(t,"streamable")||"no",a=o==="yes"||o==="true"||o==="1",c=[];for(let l=0;l<t.childNodes.length;l++){let p=t.childNodes[l];if(p.nodeType===1&&p.nodeName==="accumulator-rule"){let h=f(p,"match");if(!h)throw new Error('<xsl:accumulator-rule> requires a "match" attribute');let m=f(p,"select");if(!m)throw new Error('<xsl:accumulator-rule> requires a "select" attribute');let d=f(p,"phase");c.push({match:h,select:m,phase:d==="start"||d==="end"?d:void 0})}}let u={name:n,initialValue:r,as:i,rules:c,streamable:a};this.accumulatorRegistry.registerAccumulator(u);try{let l=this.xPath.xPathEval(r,e),p={currentValue:l,valueStack:[l]};this.accumulatorRegistry.setAccumulatorState(n,p)}catch(l){let p={currentValue:null,valueStack:[null]};this.accumulatorRegistry.setAccumulatorState(n,p)}}evaluateAccumulatorRules(e,t){let n=this.accumulatorRegistry.getAllAccumulators();for(let r of n){let i=this.accumulatorRegistry.getAccumulatorState(r.name);if(i)for(let o of r.rules)try{let a=e.clone([t],0),c=this.xsltMatch(o.match,a);if(c&&c.length>0){let l=e.clone([t],0);l.setVariable("value",new G(i.currentValue?String(i.currentValue):""));let p=this.xPath.xPathEval(o.select,l);i.currentValue=p}}catch(a){this.warningsCallback&&this.warningsCallback(`Error evaluating accumulator rule for ${r.name}: ${a}`)}}}getAccumulatorValue(e){let t=this.accumulatorRegistry.getAccumulatorState(e);return t?t.currentValue:null}xsltForEach(e,t,n){return b(this,null,function*(){let r=f(t,"select"),i=this.xPath.xPathEval(r,e).nodeSetValue(),o=this.findConditionalChild(t,"on-empty"),a=this.findConditionalChild(t,"on-non-empty");if(i.length===0){o&&(yield this.xsltChildNodes(e.clone(),o,n));return}if(a){yield this.xsltChildNodes(e.clone(),a,n);return}let c=e.clone(i);this.xsltSort(c,t);for(let u=0;u<c.contextSize();++u)yield this.xsltChildNodesExcludingConditional(c.clone(c.nodeList,u),t,n)})}xsltForEachGroup(e,t,n){return b(this,null,function*(){let r=f(t,"select"),i=f(t,"group-by"),o=f(t,"group-adjacent"),a=f(t,"group-starting-with"),c=f(t,"group-ending-with"),u=this.findConditionalChild(t,"on-empty"),l=this.findConditionalChild(t,"on-non-empty");if(!r)throw new Error("<xsl:for-each-group> requires a select attribute.");let p=[i,o,a,c].filter(d=>d);if(p.length===0)throw new Error("<xsl:for-each-group> requires one of: group-by, group-adjacent, group-starting-with, or group-ending-with.");if(p.length>1)throw new Error("<xsl:for-each-group> can only have one grouping method.");let h=this.xPath.xPathEval(r,e).nodeSetValue();if(h.length===0){u&&(yield this.xsltChildNodes(e.clone(),u,n));return}let m;if(i)m=this.groupByKey(h,i,e);else if(o)m=this.groupAdjacent(h,o,e);else if(a)m=this.groupStartingWith(h,a,e);else if(c)m=this.groupEndingWith(h,c,e);else return;if(l){yield this.xsltChildNodes(e.clone(),l,n);return}for(let d=0;d<m.length;d++){let y=m[d],E=e.clone(y.items,0);E.currentGroup=y.items,E.currentGroupingKey=y.key,yield this.xsltChildNodesExcludingConditional(E,t,n)}})}groupByKey(e,t,n){let r=new Map,i=[];for(let o of e){let a=n.clone([o],0),u=this.xPath.xPathEval(t,a).stringValue();r.has(u)||(r.set(u,{key:u,items:[]}),i.push(u)),r.get(u).items.push(o)}return i.map(o=>r.get(o))}groupAdjacent(e,t,n){let r=[],i=null,o=[];for(let a of e){let c=n.clone([a],0),l=this.xPath.xPathEval(t,c).stringValue();i===null||l!==i?(o.length>0&&r.push({key:i,items:o}),i=l,o=[a]):o.push(a)}return o.length>0&&r.push({key:i,items:o}),r}patternToSelfExpression(e){return e.includes("::")||e.startsWith("/")||e.startsWith("(")?e:`self::${e}`}groupStartingWith(e,t,n){let r=[],i=[],o=0,a=this.patternToSelfExpression(t);for(let c of e){let u=n.clone([c],0),l=this.xPath.xPathEval(a,u).booleanValue();l&&i.length>0?(r.push({key:o++,items:i}),i=[c]):l&&i.length===0?i=[c]:i.push(c)}return i.length>0&&r.push({key:o,items:i}),r}groupEndingWith(e,t,n){let r=[],i=[],o=0,a=this.patternToSelfExpression(t);for(let c of e){i.push(c);let u=n.clone([c],0);this.xPath.xPathEval(a,u).booleanValue()&&(r.push({key:o++,items:i}),i=[])}return i.length>0&&r.push({key:o,items:i}),r}xsltIterate(e,t,n){return b(this,null,function*(){let r=f(t,"select");if(!r)throw new Error("<xsl:iterate> requires a select attribute.");let i=this.xPath.xPathEval(r,e).nodeSetValue();if(i.length===0){let u=Array.from(t.childNodes||[]).filter(l=>l.nodeType===1&&this.isXsltElement(l,"on-completion"));if(u.length>0){let l=u[0],p=e.clone([],0);yield this.xsltChildNodes(p,l,n)}return}let o={},a=Array.from(t.childNodes||[]).filter(u=>u.nodeType===1&&u.localName==="param"&&this.isXsltElement(u));for(let u of a){let l=f(u,"name");if(!l)throw new Error("<xsl:param> in <xsl:iterate> requires a name attribute.");let p=f(u,"select"),h=new G("");p&&(h=this.xPath.xPathEval(p,e)),o[l]=h}for(let u=0;u<i.length;u++){let l=i[u],p=e.clone([l],0);for(let d in o)p.variables[d]=o[d];let h=Array.from(t.childNodes||[]);for(let d of h){if(d.nodeType===1){let y=d;if(this.isXsltElement(y)&&(y.localName==="param"||y.localName==="on-completion"||y.localName==="next-iteration"))continue}yield this.xsltProcessContext(p,d,n)}let m=Array.from(t.childNodes||[]).filter(d=>d.nodeType===1&&this.isXsltElement(d,"next-iteration"));if(m.length>0){let d=m[0],y=Array.from(d.childNodes||[]).filter(E=>E.nodeType===1&&this.isXsltElement(E,"with-param"));for(let E of y){let T=f(E,"name");if(!T)throw new Error("<xsl:with-param> requires a name attribute.");let P=f(E,"select");if(P){let A=this.xPath.xPathEval(P,p);o[T]=A}}}}let c=Array.from(t.childNodes||[]).filter(u=>u.nodeType===1&&this.isXsltElement(u,"on-completion"));if(c.length>0){let u=c[0],l=e.clone();for(let p in o)l.variables[p]=o[p];yield this.xsltChildNodes(l,u,n)}})}xsltTry(e,t,n){return b(this,null,function*(){let r=Array.from(t.childNodes||[]).filter(o=>o.nodeType===1&&!this.isXsltElement(o,"catch")),i=Array.from(t.childNodes||[]).filter(o=>o.nodeType===1&&this.isXsltElement(o,"catch"));try{for(let o of r)yield this.xsltProcessContext(e,o,n)}catch(o){let a="err:UNKNOWN";o&&typeof o=="object"&&(o.code?a=o.code:o.message&&(o.message.includes("division by zero")||o.message.includes("div 0")?a="err:FOAR0001":o.message.includes("undefined")&&(a="err:XPDY0002")));let c=!1;for(let u of i){let l=f(u,"errors");if(!l)c=!0;else{let p=l.split("|").map(h=>h.trim());for(let h of p){if(h==="*"||h===a){c=!0;break}if(h.endsWith("*")){let m=h.slice(0,-1);if(a.startsWith(m)){c=!0;break}}}}if(c){yield this.xsltChildNodes(e,u,n);return}}if(!c&&i.length>0)throw o}})}xsltEvaluate(e,t,n){return b(this,null,function*(){let r=f(t,"xpath");if(!r)throw new Error("<xsl:evaluate> requires an xpath attribute.");let i=this.xPath.xPathEval(r,e).stringValue(),o=null,a=f(t,"context-item");if(a){let l=this.xPath.xPathEval(a,e).nodeSetValue();l.length>0&&(o=l[0])}let c;o?c=e.clone([o],0):c=e.clone();try{let u=this.xPath.xPathEval(i,c),l=n||this.outputDocument;if(u.type==="node-set"){let p=u.nodeSetValue();for(let h of p)this.xsltCopyOf(l,h)}else if(u.type==="array"&&u.arrayValue){let p=u.arrayValue();for(let h of p){let m=ae(this.outputDocument,h.stringValue());m.siblingPosition=l.childNodes.length,V(l,m)}}else{let p=ae(this.outputDocument,u.stringValue());p.siblingPosition=l.childNodes.length,V(l,p)}}catch(u){throw new Error(`Dynamic XPath evaluation error in xsl:evaluate: ${u.message}`)}})}xsltIf(e,t,n){return b(this,null,function*(){let r=f(t,"test");this.xPath.xPathEval(r,e).booleanValue()&&(yield this.xsltChildNodes(e,t,n))})}xsltImportOrInclude(e,t,n,r){return b(this,null,function*(){let i=r?"xsl:import":"xsl:include",o=t.childNodes.filter(d=>d.nodeName==="href");if(o.length<=0)throw new Error(`<${i}> with no href attribute defined.`);let c=o[0].nodeValue;if(this.importedStylesheets.has(c))return;let u=yield this.fetchFunction(c),l=this.xmlParser.xmlParse(u),p=this.styleSheetStack.length>0?this.styleSheetStack[this.styleSheetStack.length-1].importDepth:0,h={importDepth:r?p+1:p,href:c,order:this.importedStylesheets.size};this.styleSheetStack.push(h),this.importedStylesheets.set(c,l);let m=l.childNodes[0];m&&this.mapTemplatesFromStylesheet(m,h),yield this.xsltChildNodes(e,m,n),this.styleSheetStack.pop()})}xsltImport(e,t,n){return b(this,null,function*(){yield this.xsltImportOrInclude(e,t,n,!0)})}xsltInclude(e,t,n){return b(this,null,function*(){yield this.xsltImportOrInclude(e,t,n,!1)})}xsltPackage(e,t,n){return b(this,null,function*(){let r=f(t,"version")||this.version;if(!r||parseFloat(r)<3)throw new Error("<xsl:package> is only supported in XSLT 3.0 or later.");let i=f(t,"name"),o=f(t,"package-version"),a=f(t,"declared-modes")||"yes",c=f(t,"input-type-annotations")||"unspecified";if(!i)throw new Error('<xsl:package> requires a "name" attribute.');let u=o?`${i}@${o}`:i,l=this.packageRegistry.isLoading(u);l||this.packageRegistry.beginLoading(u);let p={name:i,version:o,root:t,components:new Map,usedPackages:new Map,isTopLevel:this.currentPackage===null,overrides:new Map,modes:new Map,declaredModes:a,inputTypeAnnotations:c},h=this.currentPackage;this.currentPackage=p;try{this.packageRegistry.register(p),yield this.xsltTransformOrStylesheet(e,t,n)}finally{l||this.packageRegistry.endLoading(u),this.currentPackage=h}})}loadAndRegisterPackage(e,t,n){return b(this,null,function*(){let r=n?`${e}@${n}`:e;if(!this.packageRegistry.beginLoading(r))throw new Error(`Circular package dependency detected: "${r}".`);try{let i=t;if(t.nodeType===9){for(let o of t.childNodes)if(o.nodeType===1&&this.isXsltElement(o,"package")){i=o;break}}if(i&&this.isXsltElement(i,"package")){e&&!f(i,"name")&&W(i,"name",e),n&&!f(i,"package-version")&&W(i,"package-version",n);let o=new qe([i]);yield this.xsltPackage(o,i)}else throw new Error("Package document does not contain an xsl:package root element.")}finally{this.packageRegistry.endLoading(r)}})}xsltUsePackage(e,t,n){return b(this,null,function*(){if(!this.currentPackage)throw new Error("<xsl:use-package> can only appear as a child of <xsl:package>.");let r=f(t,"name"),i=f(t,"package-version");if(!r)throw new Error('<xsl:use-package> requires a "name" attribute.');let o=i?`${r}@${i}`:r;if(this.packageRegistry.isLoading(o))throw new Error(`Circular package dependency detected: "${o}".`);let a=this.packageRegistry.get(r,i);if(!a&&this.packageLoader)try{let l=yield this.packageLoader(r,i);l&&(yield this.loadAndRegisterPackage(r,l,i),a=this.packageRegistry.get(r,i))}catch(l){if(l instanceof Error&&l.message.includes("Circular package dependency"))throw l}if(!a)throw new Error(`Package "${r}"${i?`@${i}`:""} not found. `+(this.packageLoader?"Package loader failed to load the package.":"Packages must be loaded before they can be used."));let c={package:a,acceptedComponents:new Map},u=i?`${r}@${i}`:r;this.currentPackage.usedPackages.set(u,c);for(let l of t.childNodes)this.isXsltElement(l,"accept")?this.xsltAccept(e,l):this.isXsltElement(l,"override")&&(yield this.xsltOverride(e,l,n));yield this.registerAcceptedVariables(e),this.registerUserDefinedFunctionsInContext(e),a.components.forEach((l,p)=>{if(l.visibility==="abstract"&&!this.currentPackage.overrides.has(p))throw new Error(`Abstract component "${l.name||l.match||p}" from package "${r}" must be overridden.`)})})}xsltExpose(e,t){if(!this.currentPackage)throw new Error("<xsl:expose> can only appear as a child of <xsl:package>.");let n=f(t,"component"),r=f(t,"names"),i=f(t,"visibility")||"public";if(!n)throw new Error('<xsl:expose> requires a "component" attribute (template, function, variable, attribute-set, mode).');let o=r==="*"?["*"]:r?r.split(/\s+/):[];if(o.length===0)throw new Error('<xsl:expose> requires a "names" attribute.');for(let a of o){let c=this.findComponentInPackageRoot(this.currentPackage.root,n,a==="*"?null:a);if(c){let u={type:n,name:c.name||(a!=="*"?a:void 0),match:c.match,mode:c.mode,visibility:i,overridable:i!=="final",node:c.node,priority:c.priority},l=At(u);this.currentPackage.components.set(l,u)}}}findComponentInPackageRoot(e,t,n){for(let r of e.childNodes)if(r.nodeType===1){if(t==="template"&&this.isXsltElement(r,"template")){let i=f(r,"name"),o=f(r,"match"),a=f(r,"mode");if(n){if(i===n)return{node:r,name:i,match:o,mode:a}}else return{node:r,name:i,match:o,mode:a}}else if(t==="function"&&this.isXsltElement(r,"function")){let i=f(r,"name");if(!n||i===n)return{node:r,name:i}}else if(t==="variable"&&this.isXsltElement(r,"variable")){let i=f(r,"name");if(!n||i===n)return{node:r,name:i}}else if(t==="attribute-set"&&this.isXsltElement(r,"attribute-set")){let i=f(r,"name");if(!n||i===n)return{node:r,name:i}}}return null}xsltAccept(e,t){if(!this.currentPackage)throw new Error("<xsl:accept> can only appear as a child of <xsl:use-package>.");let n=f(t,"component"),r=f(t,"names"),i=f(t,"visibility");if(!n)throw new Error('<xsl:accept> requires a "component" attribute.');if(!r)throw new Error('<xsl:accept> requires a "names" attribute.');let o=r==="*"?["*"]:r.split(/\s+/),a=t.parentNode;if(!a||!this.isXsltElement(a,"use-package"))throw new Error("<xsl:accept> must be a child of <xsl:use-package>.");let c=f(a,"name"),u=f(a,"package-version"),l=u?`${c}@${u}`:c,p=this.currentPackage.usedPackages.get(l);if(!p)throw new Error(`Internal error: used package "${l}" not found.`);let h=this.findComponentsInPackage(p.package,n,o);for(let m of h){if(!Ga(m,!1)){let E=m.name||m.match||"unnamed";throw new Error(`Cannot accept private component "${E}" of type "${n}" from package "${p.package.name}".`)}let d=I(X({},m),{sourcePackage:p.package.name,isAccepted:!0,effectiveVisibility:i||m.visibility}),y=At(d);p.acceptedComponents.set(y,d)}}xsltOverride(e,t,n){return b(this,null,function*(){if(!this.currentPackage)throw new Error("<xsl:override> can only appear as a child of <xsl:use-package>.");let r=t.parentNode;if(!r||!this.isXsltElement(r,"use-package"))throw new Error("<xsl:override> must be a child of <xsl:use-package>.");let i=f(r,"name"),o=f(r,"package-version"),a=o?`${i}@${o}`:i,c=this.currentPackage.usedPackages.get(a);if(!c)throw new Error(`Internal error: used package "${a}" not found.`);for(let u=0;u<t.childNodes.length;u++){let l=t.childNodes[u];if(l.nodeType!==1)continue;let p=l.localName,h=null,m=null,d=null;switch(p){case"template":h="template",m=f(l,"name"),d=f(l,"match");break;case"function":h="function",m=f(l,"name");break;case"variable":h="variable",m=f(l,"name");break;case"attribute-set":h="attribute-set",m=f(l,"name");break;default:throw new Error(`<xsl:override> does not support <xsl:${p}> elements.`)}if(!h)continue;let y;if(c.acceptedComponents.forEach(P=>{P.type===h&&(m&&P.name===m||d&&P.match===d)&&(y=P)}),y||c.package.components.forEach(P=>{P.type===h&&(m&&P.name===m||d&&P.match===d)&&(y=P)}),!y){let P=m||d||"unnamed";throw new Error(`Cannot override component "${P}" of type "${h}": component not found in package "${c.package.name}".`)}if(!Qa(y)){let P=m||d||"unnamed";throw new Error(`Cannot override component "${P}" of type "${h}": component is marked as "final" in package "${c.package.name}".`)}let E={type:h,name:m||void 0,match:d||void 0,mode:f(l,"mode")||void 0,visibility:y.visibility,overridable:!1,node:l,sourcePackage:this.currentPackage.name,isAccepted:!1,effectiveVisibility:y.visibility};E.originalComponent=y,E.node.__originalComponent=y;let T=At(y);this.currentPackage.overrides.set(T,E),h==="function"&&this.xsltFunction(e,l)}})}findComponentsInPackage(e,t,n){let r=[],i=n.includes("*");return e.components.forEach((o,a)=>{if(o.type!==t)return;if(i){r.push(o);return}let c=this.getComponentNameForMatching(o);c&&n.includes(c)&&r.push(o)}),r}getComponentNameForMatching(e){switch(e.type){case"function":case"variable":case"attribute-set":case"mode":return e.name||null;case"template":return e.name||null;default:return null}}xsltOriginal(e,t,n){return b(this,null,function*(){if(!this.currentOverrideContext&&this.currentTemplateStack.length>0){let a=this.currentTemplateStack[this.currentTemplateStack.length-1].template.__originalComponent;a&&(this.currentOverrideContext=a)}if(!this.currentOverrideContext)throw new Error("<xsl:original> can only be used within an overriding component.");let r=this.currentOverrideContext,i=r.node;switch(r.type){case"template":yield this.xsltChildNodes(e,i,n);break;case"function":throw new Error("<xsl:original> for functions should be called as a function, not as an element.");case"variable":yield this.xsltVariable(e,i,!0);break;case"attribute-set":r.name&&n&&(yield this.applyAttributeSets(e,n,r.name));break;default:throw new Error(`<xsl:original> does not support component type "${r.type}".`)}})}xsltMode(e,t){if(!this.currentPackage)throw new Error("<xsl:mode> can only appear as a child of <xsl:package>.");let n=f(t,"name");if(!n)throw new Error('<xsl:mode> requires a "name" attribute.');let r=f(t,"visibility")||"public",i=f(t,"streamable"),o=f(t,"on-no-match"),a=f(t,"on-multiple-match"),c=i==="yes";this.currentPackage.modes||(this.currentPackage.modes=new Map);let u={name:n,visibility:r,streamable:c,onNoMatch:o,onMultipleMatch:a};this.currentPackage.modes.set(n,u);let l=At({type:"mode",name:n,visibility:r});this.currentPackage.components.has(l)||this.currentPackage.components.set(l,{type:"mode",name:n,visibility:r,overridable:!1,node:t})}getEffectiveComponent(e){if(!this.currentPackage)return e;let t=At(e);return this.currentPackage.overrides.get(t)||e}collectAcceptedTemplates(e){let t=[];return this.currentPackage&&this.currentPackage.usedPackages.forEach((n,r)=>{n.acceptedComponents.forEach((i,o)=>{if(i.type==="template"&&i.isAccepted){let a=this.getEffectiveComponent(i),c=a.node,l=a!==i?i:void 0,p=f(c,"mode")||null;if((e||null)!==p)return;let m=f(c,"match");if(!m)return;let d=f(c,"priority"),y=d?parseFloat(d):null,E=i.priority||0,T=y!==null&&!isNaN(y)?y:E;t.push({template:c,explicitPriority:y!==null&&!isNaN(y)?y:null,defaultPriority:E,effectivePriority:T,importPrecedence:0,documentOrder:0,matchPattern:m,originalComponent:l})}})}),t}xsltStream(e,t,n){return b(this,null,function*(){this.streamingProcessor.setVersion(this.version);let r={processChildren:(i,o,a)=>this.xsltChildNodes(i,o,a),isXsltElement:(i,o)=>this.isXsltElement(i,o)};yield this.streamingProcessor.processStream(e,t,n,r)})}xsltFork(e,t,n){return b(this,null,function*(){let r={processChildren:(i,o,a)=>this.xsltChildNodes(i,o,a),isXsltElement:(i,o)=>this.isXsltElement(i,o)};yield this.streamingProcessor.processFork(e,t,n,r)})}xsltMerge(e,t,n){return b(this,null,function*(){this.streamingProcessor.setVersion(this.version);let r={processChildren:(i,o,a)=>this.xsltChildNodes(i,o,a),isXsltElement:(i,o)=>this.isXsltElement(i,o)};yield this.streamingProcessor.processMerge(e,t,n,r)})}xsltKey(e,t){let n=f(t,"name"),r=f(t,"match"),i=f(t,"use");if(!n||!r||!i){let a="<xsl:key> missing required parameters: ";throw n||(a+="name, "),r||(a+="match, "),i||(a+="use, "),a=a.slice(0,-2),new Error(a)}n in e.keys||(e.keys[n]={});let o=this.collectAllDescendants(e.root);for(let a of o)if(yi(a,r,e,this.matchResolver,this.xPath)){let c=e.clone([a]),l=this.xPath.xPathEval(i,c).stringValue();l in e.keys[n]?e.keys[n][l].nodeSetValue().push(a):e.keys[n][l]=new Z([a])}}collectAllDescendants(e){let t=[];for(let n of e.childNodes||[])t.push(n),t.push(...this.collectAllDescendants(n));return t}xsltMessage(e,t){return b(this,null,function*(){let n=Oe(this.outputDocument);yield this.xsltChildNodes(e,t,n);let r=me(n),i=f(t,"terminate")||"no";if(console.log(`[xsl:message] ${r}`),i==="yes")throw new Error(`xsl:message terminated: ${r}`)})}xsltNamespaceAlias(e){let t=f(e,"stylesheet-prefix"),n=f(e,"result-prefix");if(!t||!n)throw new Error("<xsl:namespace-alias> requires both stylesheet-prefix and result-prefix attributes.");this.namespaceAliases.set(t,n)}xsltNumber(e,t,n){let r=f(t,"value"),i=f(t,"level")||"single",o=f(t,"count"),a=f(t,"from"),c=f(t,"format")||"1",u=f(t,"lang"),l=f(t,"letter-value"),p=f(t,"grouping-separator"),h=f(t,"grouping-size"),m;if(r){let T=this.xPath.xPathEval(r,e);m=[Math.round(T.numberValue())]}else m=this.xsltNumberCount(e,i,o,a);let d=this.xsltFormatNumbers(m,c,p,h),y=ae(this.outputDocument,d),E=n||this.outputDocument;y.siblingPosition=E.childNodes.length,V(E,y)}xsltNumberCount(e,t,n,r){let i=e.nodeList[e.position],o=n||i.nodeName;switch(t){case"single":{let a=i;for(;a;){if(this.nodeMatchesPattern(a,o)){let c=1,u=a.previousSibling;for(;u;)this.nodeMatchesPattern(u,o)&&c++,u=u.previousSibling;return[c]}if(r&&this.nodeMatchesPattern(a,r))break;a=a.parentNode}return[0]}case"multiple":{let a=[],c=i,u=[];for(;c&&(this.nodeMatchesPattern(c,o)&&u.push(c),!(r&&this.nodeMatchesPattern(c,r)));)c=c.parentNode;for(let l=u.length-1;l>=0;l--){let p=u[l],h=1,m=p.previousSibling;for(;m;)this.nodeMatchesPattern(m,o)&&h++,m=m.previousSibling;a.push(h)}return a.length>0?a:[0]}case"any":{let a=0,c=this.getAllPrecedingNodes(i,r);this.nodeMatchesPattern(i,o)&&(a=1);for(let u of c)this.nodeMatchesPattern(u,o)&&a++;return[a]}default:return[1]}}nodeMatchesPattern(e,t){return t.includes("|")?t.split("|").map(r=>r.trim()).some(r=>this.nodeMatchesSinglePattern(e,r)):this.nodeMatchesSinglePattern(e,t)}nodeMatchesSinglePattern(e,t){return t==="*"?e.nodeType===1:t==="node()"?!0:t==="text()"?e.nodeType===3:t==="comment()"?e.nodeType===8:t.startsWith("processing-instruction")?e.nodeType===7:e.nodeName===t||e.localName===t}getAllPrecedingNodes(e,t=null){let n=[],r=e.previousSibling;for(;r;){if(t&&this.nodeMatchesPattern(r,t))return this.collectDescendants(r,n),n;n.push(r),this.collectDescendants(r,n),r=r.previousSibling}let i=e.parentNode;for(;i;){if(t&&this.nodeMatchesPattern(i,t))return n;let o=i.previousSibling;for(;o;){if(t&&this.nodeMatchesPattern(o,t))return this.collectDescendants(o,n),n;n.push(o),this.collectDescendants(o,n),o=o.previousSibling}i=i.parentNode}return n}collectDescendants(e,t){for(let n of e.childNodes)n.nodeType===1&&(t.push(n),this.collectDescendants(n,t))}xsltFormatNumbers(e,t,n,r){if(e.length===0)return"0";let{tokens:i,separators:o}=this.parseFormatString(t),a=[];for(let u=0;u<e.length;u++){let l=Math.min(u,i.length-1),p=i[l]||"1",h=this.xsltFormatNumber(e[u],p,n,r);a.push(h)}if(a.length===1)return a[0];let c=a[0];for(let u=1;u<a.length;u++){let l=Math.min(u-1,o.length-1),p=o.length>0?o[l]:".";c+=p+a[u]}return c}parseFormatString(e){let t=[],n=[],r=/^(0*1|[aAiI])/,i=e,o=!1;for(;i.length>0;){let a=i.match(r);if(a)t.push(a[1]),i=i.substring(a[1].length),o=!0;else{if(o&&t.length>0){let c=1;for(;c<i.length&&!i.substring(c).match(r);)c++;n.push(i.substring(0,c)),i=i.substring(c)}else i=i.substring(1);o=!1}}if(t.length===0&&t.push("1"),n.length===0&&t.length>1)for(let a=1;a<t.length;a++)n.push(".");return{tokens:t,separators:n}}xsltFormatNumber(e,t,n,r){if(t.match(/^0+1$/)){let a=t.length,c=e.toString().padStart(a,"0");if(n&&r){let u=parseInt(r,10);u>0&&!isNaN(u)&&(c=this.applyGrouping(c,n,u))}return c}let i=t.charAt(0),o;switch(i){case"1":if(o=e.toString(),t.length>1&&t.match(/^0+1$/)){let a=t.length;o=e.toString().padStart(a,"0")}break;case"a":o=this.numberToAlpha(e,!1);break;case"A":o=this.numberToAlpha(e,!0);break;case"i":o=this.numberToRoman(e).toLowerCase();break;case"I":o=this.numberToRoman(e);break;default:o=e.toString()}if(n&&r){let a=parseInt(r,10);a>0&&!isNaN(a)&&(o=this.applyGrouping(o,n,a))}return o}numberToAlpha(e,t){if(e<=0)return"";let n="";for(;e>0;)e--,n=String.fromCharCode(e%26+(t?65:97))+n,e=Math.floor(e/26);return n}numberToRoman(e){if(e<=0||e>3999)return e.toString();let t=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]],n="";for(let[r,i]of t)for(;e>=r;)n+=i,e-=r;return n}applyGrouping(e,t,n){let r=e.split("."),i=r[0],o=r[1],a="",c=0;for(let u=i.length-1;u>=0;u--)c>0&&c%n===0&&(a=t+a),a=i[u]+a,c++;return o?a+"."+o:a}xsltSort(e,t){let n=[];for(let r of t.childNodes)if(r.nodeType==1&&this.isXsltElement(r,"sort")){let i=f(r,"select"),o=this.xPath.xPathParse(i),a=f(r,"data-type")||"text",c=f(r,"order")||"ascending";n.push({expr:o,type:a,order:c})}this.xPath.xPathSort(e,n)}resolveNamespaceUriForPrefix(e,t){let n=t?`xmlns:${t}`:"xmlns",r=e;for(;r;){let i=r.childNodes.filter(o=>o.nodeType===2);for(let o of i)if(o.nodeName===n||t&&o.prefix==="xmlns"&&o.localName===t||!t&&o.nodeName==="xmlns")return o.nodeValue;r=r.parentNode}return null}isNamespaceDeclaredOnAncestor(e,t,n){let r=e;for(;r;){if(Ze(r,t)===n)return!0;r=r.parentNode}return!1}parseWhitespacePattern(e,t){if(e==="*")return{namespaceUri:null,localName:"*",isWildcard:!0};if(e.includes(":")){let[n,r]=e.split(":"),i=this.resolveNamespaceUriForPrefix(t,n);return{namespaceUri:i!=null?i:null,localName:r||"*",isWildcard:r==="*"}}return{namespaceUri:null,localName:e,isWildcard:!1}}xsltStripSpace(e){let t=f(e,"elements");if(t){let n=t.trim().split(/\s+/);for(let r of n)this.stripSpacePatterns.push(this.parseWhitespacePattern(r,e))}}xsltPreserveSpace(e){let t=f(e,"elements");if(t){let n=t.trim().split(/\s+/);for(let r of n)this.preserveSpacePatterns.push(this.parseWhitespacePattern(r,e))}}shouldStripWhitespaceNode(e){if(!e.nodeValue||!e.nodeValue.match(/^\s*$/)||this.stripSpacePatterns.length===0)return!1;let t=e.parentNode;if(!t||t.nodeType!==1)return!1;let n=t;for(;n&&n.nodeType===1;){let i=Ze(n,"xml:space");if(i==="preserve")return!1;if(i==="default")break;n=n.parentNode}let r=t.localName||t.nodeName;for(let i of this.preserveSpacePatterns)if(this.matchesNamePattern(r,i,t))return!1;for(let i of this.stripSpacePatterns)if(this.matchesNamePattern(r,i,t))return!0;return!1}matchesNamePattern(e,t,n){var i;let r=(i=n.namespaceUri)!=null?i:this.resolveNamespaceUriForPrefix(n,n.prefix||null);if(t.namespaceUri!==null){if(r!==t.namespaceUri)return!1}else if(!t.isWildcard&&r)return!1;return t.isWildcard?!0:e===t.localName}xsltTemplate(e,t,n){return b(this,null,function*(){if(!e.inApplyTemplates&&e.baseTemplateMatched)return;let r=f(t,"match");if(!r)return;let i=this.xsltMatch(r,e,"self-and-siblings");if(i.length>0){this.firstTemplateRan=!0,e.inApplyTemplates||(e.baseTemplateMatched=!0);let o=e.clone(i,0);yield this.xsltChildNodes(o,t,n)}})}xsltText(e,t,n){let r=me(t),i=ae(this.outputDocument,r);i.fromXslText=!0;let o=t.childNodes.filter(c=>c.nodeType===2&&c.nodeName==="disable-output-escaping");o.length>0&&o[0].nodeValue==="yes"&&(i.escape=!1);let a=n||this.outputDocument;i.siblingPosition=a.childNodes.length,a.appendChild(i)}validateStylesheetAttributes(e,t){let n=e.childNodes.filter(a=>a.nodeType===2),r=["version","id","extension-element-prefixes","exclude-result-prefixes","default-collation"],i=["xmlns"],o=!1;for(let a of n){let c=a.nodeName,u=a.nodeValue;if(a.prefix==="xmlns"){t.knownNamespaces[a.localName]=u;continue}if(c==="xmlns"){t.knownNamespaces[""]=u;continue}if(c==="version"){o=!0;let l=parseFloat(u);if(isNaN(l)||l<=0)throw new Error(`XSLT version not defined or invalid. Actual resolved version: ${u||"(none)"}.`);l>1&&!["2.0","3.0"].includes(u)?(this.forwardsCompatible=!0,this.version=u,t.xsltVersion="1.0",this.warningsCallback(`XSLT Warning: Stylesheet version "${u}" is not directly supported. Entering forwards-compatible processing mode (XSLT 1.0 Section 2.5).`)):(this.version=u,t.xsltVersion=u);continue}if(c==="extension-element-prefixes"){let l=u.split(/\s+/);for(let p of l)if(p&&!/^[a-zA-Z_:][\w:.-]*$/.test(p))throw new Error(`Invalid prefix in extension-element-prefixes: "${p}". Prefixes must be valid QNames.`);continue}if(c==="exclude-result-prefixes"){if(u!=="#all"){let l=u.split(/\s+/);for(let p of l)if(p&&!/^[a-zA-Z_:][\w:.-]*$/.test(p))throw new Error(`Invalid prefix in exclude-result-prefixes: "${p}". Prefixes must be valid QNames or "#all".`)}continue}if(c==="default-collation"){if(!u||u.trim().length===0)throw new Error("The default-collation attribute must contain a URI.");continue}if(c==="id"){if(!/^[a-zA-Z_:][\w:.-]*$/.test(u))throw new Error(`Invalid id attribute value: "${u}". IDs must be valid NCNames.`);continue}}}xsltTransformOrStylesheet(e,t,n){return b(this,null,function*(){var u;let r={importDepth:0,href:"(main stylesheet)",order:0};this.mapTemplatesFromStylesheet(t,r),this.collectAttributeSets(t),this.collectUserDefinedFunctions(t,e),this.registerUserDefinedFunctionsInContext(e),this.validateStylesheetAttributes(t,e);let i=!1;for(let l of t.childNodes)if(l.nodeType===1)if(this.isXsltElement(l,"import")){if(i)throw new Error("<xsl:import> should be the first child node of <xsl:stylesheet> or <xsl:transform>.")}else i=!0;let o=[],a=[];for(let l of t.childNodes)l.nodeType===1&&this.isXsltElement(l,"template")?a.push(l):o.push(l);let c=e.clone();for(let l of o)yield this.xsltProcessContext(c,l,n);if(a.length>0){let l=Rr(t,null,this.xPath,this.templateSourceMap),p=[];for(let h of l)try{let m=this.xsltMatch(h.matchPattern,c);m.length>0&&p.push({priority:h,matchedNodes:m})}catch(m){this.warningsCallback(`Failed to match pattern "${h.matchPattern}":`,m)}if(p.length>0){let h=p.find(A=>A.priority.matchPattern==="/"),m;h?m=h:(p.sort((A,w)=>A.priority.importPrecedence!==w.priority.importPrecedence?w.priority.importPrecedence-A.priority.importPrecedence:A.priority.effectivePriority!==w.priority.effectivePriority?w.priority.effectivePriority-A.priority.effectivePriority:w.priority.documentOrder-A.priority.documentOrder),m=p[0]);let d=p.filter(A=>A.priority.importPrecedence===m.priority.importPrecedence&&A.priority.effectivePriority===m.priority.effectivePriority);if(d.length>1){let A=d.map(w=>`"${w.priority.matchPattern}" (priority: ${w.priority.effectivePriority})`).join(", ");this.warningsCallback(`XSLT Warning: Ambiguous template match. Multiple templates match with equal priority: ${A}. Using the last one in document order.`)}this.firstTemplateRan=!0,c.baseTemplateMatched=!0;let y=c.clone(m.matchedNodes,0),E=this.templateSourceMap.get(m.priority.template),T=f(m.priority.template,"match"),P=f(m.priority.template,"mode");this.currentTemplateStack.push({template:m.priority.template,stylesheetDepth:(u=E==null?void 0:E.importDepth)!=null?u:0,mode:P||null,match:T}),yield this.xsltChildNodes(y,m.priority.template,n),this.currentTemplateStack.pop()}else{let h=e.nodeList[e.position];h&&(yield this.applyBuiltInTemplate(h,l,null,e,n))}}})}xsltValueOf(e,t,n){let r=f(t,"select"),i=e.nodeList[e.position],o=this.xPath.xPathEval(r,e);if(i&&i.nodeName==="#document"&&(o.stringValue()===""||o instanceof Z&&o.nodeSetValue().length===0)){let l=i.childNodes.find(p=>p.nodeName!=="#dtd-section");if(l){let p=e.clone([l],0);o=this.xPath.xPathEval(r,p)}}let a=o.stringValue(),c=ae(this.outputDocument,a),u=n||this.outputDocument;c.siblingPosition=u.childNodes.length,u.appendChild(c)}xsltSequence(e,t,n){return b(this,null,function*(){let r=f(t,"select"),i=n||this.outputDocument;if(r){let o=this.xPath.xPathEval(r,e);if(o.type==="node-set"){let a=o.nodeSetValue();for(let c of a)this.xsltCopyOf(i,c)}else{let a=ae(this.outputDocument,o.stringValue());a.siblingPosition=i.childNodes.length,V(i,a)}}else yield this.xsltChildNodes(e,t,n)})}xsltAnalyzeString(e,t,n){return b(this,null,function*(){let r=f(t,"select"),i=f(t,"regex"),o=f(t,"flags")||"";if(!r)throw new Error("<xsl:analyze-string> requires a select attribute.");if(!i)throw new Error("<xsl:analyze-string> requires a regex attribute.");let c=this.xPath.xPathEval(r,e).stringValue(),u=null,l=null;for(let y of t.childNodes)if(y.nodeType===1&&this.isXsltElement(y)){if(y.localName==="matching-substring")u=y;else if(y.localName==="non-matching-substring")l=y;else if(y.localName==="fallback")continue}let p="g";for(let y of o)switch(y){case"i":p+="i";break;case"m":p+="m";break;case"s":p+="s";break}let h;try{h=new RegExp(i,p)}catch(y){throw new Error(`Invalid regular expression in xsl:analyze-string: ${i}`)}let m=0,d;for(;(d=h.exec(c))!==null;){let y=d.index,E=y+d[0].length;if(y>m&&l){let T=c.substring(m,y);yield this.processAnalyzeStringContent(e,l,n,T,null)}if(u){let T=d.slice(0);yield this.processAnalyzeStringContent(e,u,n,d[0],T)}m=E,d[0].length===0&&h.lastIndex++}if(m<c.length&&l){let y=c.substring(m);yield this.processAnalyzeStringContent(e,l,n,y,null)}})}processAnalyzeStringContent(e,t,n,r,i){return b(this,null,function*(){let o=ae(this.outputDocument,r),a=e.clone([o],0);i&&(a.regexGroups=i),yield this.xsltChildNodes(a,t,n)})}xsltFunction(e,t){let n=f(t,"name"),r=f(t,"as"),i=f(t,"override");if(!n)throw new Error('<xsl:function> requires a "name" attribute.');if(!n.includes(":"))throw new Error(`<xsl:function> name "${n}" must be in a namespace (use a prefixed name like "my:functionName").`);let o=i==="yes"||i==="true";this.userDefinedFunctions.has(n)&&!o||this.userDefinedFunctions.set(n,t)}coerceToType(e,t){switch(t.replace(/^xs:/,"").toLowerCase()){case"integer":case"int":case"double":case"decimal":case"number":return new fe(e.numberValue());case"string":return new G(e.stringValue());case"boolean":return new v(e.booleanValue());default:return e}}toNodeValue(e){return e&&typeof e=="object"&&"stringValue"in e?e:e&&typeof e=="object"&&"nodeType"in e?new Z([e]):Array.isArray(e)?new Z(e):typeof e=="number"?new fe(e):typeof e=="boolean"?new v(e):new G(String(e!=null?e:""))}executeUserDefinedFunction(e,t,n){return b(this,null,function*(){return this.executeUserDefinedFunctionSync(e,t,n)})}executeUserDefinedFunctionSync(e,t,n){let r=e.clone();r.variables=X({},e.variables);let i=[];for(let o of t.childNodes)o.nodeType===1&&this.isXsltElement(o,"param")&&i.push(o);for(let o=0;o<i.length;o++){let a=f(i[o],"name");if(a)if(o<n.length){let c=f(i[o],"as"),u=this.toNodeValue(n[o]);c&&(u=this.coerceToType(u,c)),r.setVariable(a,u)}else{let c=f(i[o],"select");if(c){let u=this.xPath.xPathEval(c,r);r.setVariable(a,u)}else r.setVariable(a,new G(""))}}for(let o of t.childNodes)if(o.nodeType===1){if(this.isXsltElement(o,"sequence")){let a=f(o,"select");if(a){let c=this.xPath.xPathEval(a,r);return c.type==="number"?c.numberValue():c.type==="boolean"?c.booleanValue():c.type==="node-set"?c.nodeSetValue():c.stringValue()}}else if(this.isXsltElement(o,"value-of")){let a=f(o,"select");if(a)return this.xPath.xPathEval(a,r).stringValue()}}return""}xsltResultDocument(e,t){return b(this,null,function*(){let n=f(t,"href")||"",r=f(t,"method")||this.outputMethod||"xml",i=f(t,"omit-xml-declaration")||this.outputOmitXmlDeclaration,o=this.xsltAttributeValue(n,e);if(!o)throw new Error('<xsl:result-document> requires a non-empty "href" attribute.');if(this.resultDocuments.has(o))throw new Error(`<xsl:result-document>: A document has already been created with href="${o}".`);let a=new ue;yield this.xsltChildNodes(e,t,a);let c=Mn(a,{cData:this.options.cData,escape:this.options.escape,selfClosingTags:this.options.selfClosingTags,outputMethod:r,outputVersion:this.outputVersion,itemSeparator:this.itemSeparator});this.resultDocuments.set(o,c)})}getResultDocuments(){return this.resultDocuments}setPackageLoader(e){this.packageLoader=e}registerPackage(e,t,n){return b(this,null,function*(){yield this.loadAndRegisterPackage(e,t,n)})}xsltPerformSort(e,t,n){return b(this,null,function*(){let r=f(t,"select"),i;if(r)i=this.xPath.xPathEval(r,e).nodeSetValue();else{let c=[];for(let l of t.childNodes)l.nodeType===1&&!this.isXsltElement(l,"sort")&&c.push(l);let u=Oe(this.outputDocument);for(let l of c)yield this.xsltProcessContext(e,l,u);i=Array.from(u.childNodes)}if(i.length===0)return;let o=e.clone(i);this.xsltSort(o,t);let a=n||this.outputDocument;for(let c of o.nodeList)this.xsltCopyOf(a,c)})}xsltNamespace(e,t,n){return b(this,null,function*(){let r=f(t,"name"),i=f(t,"select");if(!r&&r!=="")throw new Error('<xsl:namespace> requires a "name" attribute.');let o=this.xsltAttributeValue(r,e),a;if(i)a=this.xPath.xPathEval(i,e).stringValue();else{let u=Oe(this.outputDocument);yield this.xsltChildNodes(e,t,u),a=me(u)}if(!a)throw new Error("<xsl:namespace> requires a non-empty namespace URI.");let c=n||this.outputDocument;c.nodeType===1&&(o?W(c,`xmlns:${o}`,a):W(c,"xmlns",a))})}xsltVariable(e,t,n){return b(this,null,function*(){let r=f(t,"name"),i=f(t,"select"),o;if(t.childNodes.filter(c=>c.nodeType!==2).length>0){let c=Oe(t.ownerDocument);yield this.xsltChildNodes(e,t,c),o=new Z([c])}else if(i)o=this.xPath.xPathEval(i,e);else{let c=this.options.parameters.filter(u=>u.name===r);c.length>0?o=this.toNodeValue(c[0].value):o=new G("")}(n||!e.getVariable(r))&&e.setVariable(r,o)})}registerAcceptedVariables(e){return b(this,null,function*(){this.currentPackage&&this.currentPackage.usedPackages.forEach((t,n)=>{t.acceptedComponents.forEach((r,i)=>{r.type==="variable"&&r.name&&r.isAccepted&&this.xsltVariable(e,r.node,!1)})})})}xsltChildNodes(e,t,n){return b(this,null,function*(){let r=e.clone();for(let i=0;i<t.childNodes.length;++i){let o=t.childNodes[i];o.nodeType!==2&&(yield this.xsltProcessContext(r,o,n))}})}xsltChildNodesExcludingConditional(e,t,n){return b(this,null,function*(){let r=e.clone();for(let i=0;i<t.childNodes.length;++i){let o=t.childNodes[i];o.nodeType!==2&&(o.nodeType===1&&this.isXsltElement(o)&&(o.localName==="on-empty"||o.localName==="on-non-empty")||(yield this.xsltProcessContext(r,o,n)))}})}findConditionalChild(e,t){for(let n of e.childNodes)if(n.nodeType===1&&this.isXsltElement(n,t))return n;return null}commonLogicTextNode(e,t,n){if(n){if(this.shouldStripWhitespaceNode(t))return;let r=t.nodeValue;this.version&&parseFloat(this.version)>=3&&(r=this.xsltTextValueTemplate(r,e));let i=ae(this.outputDocument,r);i.siblingPosition=n.childNodes.length,V(n,i)}}xsltPassThrough(e,t,n){return b(this,null,function*(){switch(t.nodeType){case 3:this.xsltPassText(t)&&this.commonLogicTextNode(e,t,n);break;case 1:let r,i=e;r=e.nodeList[e.position];let o,a=t.nodeName,c=t.namespaceUri,u=t.prefix||"",l=this.namespaceAliases.get(u);if(l){let m=t.localName||t.nodeName;l==="#default"?(a=m,c=this.resolveNamespaceUriForPrefix(t,null)):(a=`${l}:${m}`,c=this.resolveNamespaceUriForPrefix(t,l))}if(o=et(this.outputDocument,a),o.siblingPosition=(n||this.outputDocument).childNodes.length,V(n||this.outputDocument,o),l)l==="#default"?c&&W(o,"xmlns",c):c&&W(o,`xmlns:${l}`,c);else if(c){let m=u||(a.includes(":")?a.split(":")[0]:null),d=m?`xmlns:${m}`:"xmlns";this.isNamespaceDeclaredOnAncestor(n,d,c)||W(o,d,c)}let p=t.childNodes.find(m=>(m==null?void 0:m.nodeType)===2&&m.nodeName==="use-attribute-sets");p&&(yield this.applyAttributeSets(i,o,p.nodeValue)),yield this.xsltChildNodes(i,t,o);let h=t.childNodes.filter(m=>(m==null?void 0:m.nodeType)===2&&m.nodeName!=="use-attribute-sets");for(let m of h){let d=m.nodeName,y=this.xsltAttributeValue(m.nodeValue,i);if(W(o,d,y),m.prefix&&m.namespaceUri&&m.prefix!=="xmlns"&&!m.nodeName.startsWith("xmlns")){let E=`xmlns:${m.prefix}`;this.isNamespaceDeclaredOnAncestor(o,E,m.namespaceUri)||W(o,E,m.namespaceUri)}}break;default:yield this.xsltChildNodes(e,t,n)}})}xsltPassText(e){if(!e.nodeValue.match(/^\s*$/))return!0;let t=e.parentNode;if(this.isXsltElement(t,"text"))return!0;for(;t&&t.nodeType==1;){let n=Ze(t,"xml:space");if(n){if(n=="default")return!1;if(n=="preserve")return!0}t=t.parentNode}return!1}findAttributeInContext(e,t){return t.nodeList[t.position].childNodes.find(n=>n.nodeType===2&&n.nodeName===e)}xsltAttributeValue(e,t){let n=e.split("{");if(n.length===1)return e;let r="";for(let i=0;i<n.length;++i){let o=n[i].split("}");if(o.length!=2){r+=n[i];continue}let a=this.xPath.xPathEval(o[0],t).stringValue();r+=a+o[1]}return r}xsltTextValueTemplate(e,t){if(!e)return e;let n="",r=0;for(;r<e.length;){let i=e[r];if(i==="{"){if(r+1<e.length&&e[r+1]==="{"){n+="{",r+=2;continue}let o=1,a=r+1,c="";for(;a<e.length&&o>0;){if(e[a]==="{")o++;else if(e[a]==="}"&&(o--,o===0))break;c+=e[a],a++}if(o===0){try{let u=this.xPath.xPathEval(c,t).stringValue();n+=u}catch(u){throw new Error(`Error evaluating text value template expression "${c}": ${u.message}`)}r=a+1}else n+=i,r++}else if(i==="}"){if(r+1<e.length&&e[r+1]==="}"){n+="}",r+=2;continue}n+=i,r++}else n+=i,r++}return n}xsltMatch(e,t,n){let r=this.xPath.xPathParse(e,n);return this.matchResolver.expressionMatch(r,t)}xsltWithParam(e,t){return b(this,null,function*(){for(let n of t.childNodes)n.nodeType===1&&this.isXsltElement(n,"with-param")&&(yield this.xsltVariable(e,n,!0))})}mapTemplatesFromStylesheet(e,t){for(let n of e.childNodes)n.nodeType===1&&(this.isXsltElement(n,"template")?this.templateSourceMap.set(n,t):(this.isXsltElement(n,"stylesheet")||this.isXsltElement(n,"transform")||this.isXsltElement(n,"package"))&&this.mapTemplatesFromStylesheet(n,t))}collectAttributeSets(e){for(let t of e.childNodes)if(t.nodeType===1&&this.isXsltElement(t,"attribute-set")){let n=f(t,"name"),r=t.childNodes.filter(i=>i.nodeType===1&&this.isXsltElement(i,"attribute"));if(n){let i=this.attributeSets.get(n);i&&i.length?this.attributeSets.set(n,[...i,...r]):this.attributeSets.set(n,r)}}}collectUserDefinedFunctions(e,t){for(let n of e.childNodes)n.nodeType===1&&this.isXsltElement(n,"function")&&this.xsltFunction(t,n)}registerUserDefinedFunctionsInContext(e){if(this.userDefinedFunctions.size===0&&!this.hasAcceptedFunctions())return;let t=new Map;this.userDefinedFunctions.forEach((n,r)=>{t.set(r,{functionDef:n,executor:(i,o,a)=>this.executeUserDefinedFunctionSync(i,o,a)})}),this.registerAcceptedFunctions(t),e.userDefinedFunctions=t}hasAcceptedFunctions(){if(!this.currentPackage)return!1;let e=!1;return this.currentPackage.usedPackages.forEach(t=>{t.acceptedComponents.forEach(n=>{n.type==="function"&&n.isAccepted&&(e=!0)})}),e}registerAcceptedFunctions(e){this.currentPackage&&this.currentPackage.usedPackages.forEach((t,n)=>{t.acceptedComponents.forEach((r,i)=>{if(r.type==="function"&&r.name&&r.isAccepted){let o=this.getEffectiveComponent(r);e.set(r.name,{functionDef:o.node,executor:(a,c,u)=>this.executeUserDefinedFunctionSync(a,c,u)})}})})}applyAttributeSets(e,t,n){return b(this,null,function*(){if(!n||!n.trim())return;let r=n.trim().split(/\s+/),i=new Set;for(let o of r)yield this.applyAttributeSet(e,t,o,i)})}applyAttributeSet(e,t,n,r){return b(this,null,function*(){if(r.has(n))return;r.add(n);let i=this.attributeSets.get(n);if(i)for(let o of i){let a=null,c=o.parentNode;if(c&&(a=f(c,"use-attribute-sets")),a)for(let m of a.trim().split(/\s+/))m&&(yield this.applyAttributeSet(e,t,m,r));let u=f(o,"name"),l=this.xsltAttributeValue(u,e),p=Oe(this.outputDocument);yield this.xsltChildNodes(e,o,p);let h=di(p);W(t,l,h)}})}isExtensionElementSupported(e){if(e.nodeType!==1)return!0;let t=e.namespaceUri;return!t||this.isXsltElement(e)?!0:!!this.supportedExtensions.has(t)}getFallbackElement(e){for(let t of e.childNodes)if(t.nodeType===1&&this.isXsltElement(t,"fallback"))return t;return null}xsltExtensionElement(e,t,n){return b(this,null,function*(){let r=this.getFallbackElement(t);r?yield this.xsltChildNodes(e,r,n):yield this.xsltPassThrough(e,t,n)})}isXsltElement(e,t){return t&&e.localName!=t?!1:e.namespaceUri?e.namespaceUri==="http://www.w3.org/1999/XSL/Transform":e.prefix==="xsl"}};return U(Mu);})();
|
|
8
8
|
//# sourceMappingURL=xslt-processor.global.js.map
|