@jinntec/fore 2.0.0 → 2.1.0

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.
package/dist/fore-dev.js CHANGED
@@ -1,9 +1,9 @@
1
- function e(e,t,n,r){const a={op:t,func:n,data:r};return e.push(a),a}function t(e,t){return e}class n{constructor(){this.program=[]}test(t,n){return e(this.program,5,t,void 0===n?null:n)}jump(t){return e(this.program,3,null,t)}record(n,r){return e(this.program,4,void 0===r?t:r,n)}bad(t=1){return e(this.program,1,null,t)}accept(){return e(this.program,0,null,null)}fail(t){return e(this.program,2,t||null,null)}}class r{constructor(e,t,n){this.programLength=e,this.maxFromByPc=t,this.maxSurvivorFromByPc=n}static fromProgram(e){const t=e.length,n=[],a=[];return e.forEach((e=>{n.push(0),a.push(0)})),e.forEach(((e,r)=>{switch(e.op){case 2:if(null===e.func)return;if(r+1>=t)throw new Error("Invalid program: program could run past end");n[r+1]+=1;break;case 1:case 4:if(r+1>=t)throw new Error("Invalid program: program could run past end");n[r+1]+=1;break;case 3:e.data.forEach((e=>{if(e<0||e>=t)throw new Error("Invalid program: program could run past end");n[e]+=1}));break;case 5:if(r+1>=t)throw new Error("Invalid program: program could run past end");a[r+1]+=1;break;case 0:a[r]+=1}})),new r(t,n,a)}static createStub(e){const t=[],n=[];for(let r=0;r<e;++r)t.push(e),n.push(e);return new r(e,t,n)}}class a{constructor(e){this.acceptingTraces=e,this.success=e.length>0}}class o{constructor(e){this.t=0,this.i=0,this.h=new Uint16Array(e),this.l=new Uint8Array(e)}getBadness(e){return this.l[e]}add(e,t){this.l[e]=t>255?255:t;const n=function(e,t,n,r,a){let o=r,s=a;for(;o<s;){const r=o+s>>>1;n<t[e[r]]?s=r:o=r+1}return o}(this.h,this.l,t,this.i,this.t);this.h.copyWithin(n+1,n,this.t),this.h[n]=e,this.t+=1}reschedule(e,t){const n=Math.max(this.l[e],t>255?255:t);if(this.l[e]!==n){const t=this.h.indexOf(e,this.i);if(t<0||t>=this.t)return void(this.l[e]=n);this.h.copyWithin(t,t+1,this.t),this.t-=1,this.add(e,n)}}getNextPc(){return this.i>=this.t?null:this.h[this.i++]}reset(){this.t=0,this.i=0,this.l.fill(0)}}class s{constructor(e){this.o=[];let t=e.length;e.forEach((e=>{this.o.push(e>0?t:-1),t+=e})),this.u=new Uint16Array(t)}clear(){this.u.fill(0,0,this.o.length)}add(e,t){const n=this.u[t],r=this.o[t];this.u[t]+=1,this.u[r+n]=e}has(e){return this.u[e]>0}forEach(e,t){const n=this.u[e],r=this.o[e];for(let e=r;e<r+n;++e)t(this.u[e])}}function i(e,t,n=!1){return null===e?t:Array.isArray(e)?(-1===e.indexOf(t)&&(n&&(e=e.slice()),e.push(t)),e):e===t?e:[e,t]}class l{constructor(e,t){this.prefixes=e,this.record=t}}function c(e,t){let n;if(null===t){if(!Array.isArray(e))return e;n=e}else n=e===l.EMPTY?[]:Array.isArray(e)?e:[e];return new l(n,t)}l.EMPTY=new l([],null);class u{constructor(e){this.p=[],this.v=[];for(let t=0;t<e;++t)this.p.push(0),this.v.push(null)}mergeTraces(e,t,n,r,a,o){let s=!1;return n.forEach(t,(t=>{const n=this.trace(t,r,a,o);var l,c,u;c=n,u=s,e=null===(l=e)?c:null===c?l:Array.isArray(c)?c.reduce(((e,t)=>i(e,t,e===c)),l):i(l,c,u),s=e===n})),e}trace(e,t,n,r){switch(this.p[e]){case 2:return this.v[e];case 1:return null}this.p[e]=1;let a=null;const o=t[e];if(null!==o)a=o;else if(!n.has(e))throw new Error("Trace without source at pc "+e);if(a=this.mergeTraces(a,e,n,t,n,r),null!==a){const t=r[e];null!==t&&(a=c(a,t))}return this.v[e]=a,this.p[e]=2,a}buildSurvivorTraces(e,t,n,r,a){for(let o=0,s=e.length;o<s;++o){if(!n.has(o)){t[o]=null;continue}this.v.fill(null),this.p.fill(0);const s=this.mergeTraces(null,o,n,e,r,a);if(null===s)throw new Error("No non-cyclic paths found to survivor "+o);t[o]=c(s,null)}this.v.fill(null)}}class p{constructor(e){this.g=[],this.k=[],this.m=[],this.A=new s(e.maxFromByPc),this.T=new s(e.maxSurvivorFromByPc),this.S=new u(e.programLength);for(let t=0;t<e.programLength;++t)this.g.push(null),this.k.push(null),this.m.push(null);this.k[0]=l.EMPTY}reset(e){this.A.clear(),this.T.clear(),this.g.fill(null),e&&(this.k.fill(null),this.m.fill(null),this.k[0]=l.EMPTY)}record(e,t){this.g[e]=t}has(e){return this.A.has(e)||null!==this.k[e]}add(e,t){this.A.add(e,t)}hasSurvivor(e){return this.T.has(e)}addSurvivor(e,t){this.T.add(e,t)}buildSurvivorTraces(){const e=this.k;this.S.buildSurvivorTraces(e,this.m,this.T,this.A,this.g),this.k=this.m,this.m=e}getTraces(e){const t=e.reduce(((e,t)=>i(e,this.k[t])),null);return null===t?[]:Array.isArray(t)?t:[t]}}class h{constructor(e){this.I=[],this.N=new o(e.programLength),this.M=new o(e.programLength),this.P=new p(e)}reset(){this.N.reset(),this.N.add(0,0),this.I.length=0,this.P.reset(!0)}getNextThreadPc(){return this.N.getNextPc()}step(e,t,n){const r=this.P.has(t);this.P.add(e,t);const a=this.N.getBadness(e)+n;r?this.N.reschedule(t,a):this.N.add(t,a)}stepToNextGeneration(e,t){const n=this.P.hasSurvivor(t);this.P.addSurvivor(e,t);const r=this.N.getBadness(e);n?this.M.reschedule(t,r):this.M.add(t,r)}accept(e){this.I.push(e),this.P.addSurvivor(e,e)}fail(e){}record(e,t){this.P.record(e,t)}nextGeneration(){this.P.buildSurvivorTraces(),this.P.reset(!1);const e=this.N;e.reset(),this.N=this.M,this.M=e}getAcceptingTraces(){return this.P.getTraces(this.I)}}class d{constructor(e){this.U=[],this.G=e,this.V=r.fromProgram(e),this.U.push(new h(this.V))}execute(e,t){const n=this.U.pop()||new h(this.V);n.reset();const r=e.length;let o,s=-1;do{let a=n.getNextThreadPc();if(null===a)break;for(++s,o=s>=r?null:e[s];null!==a;){const e=this.G[a];switch(e.op){case 0:null===o?n.accept(a):n.fail(a);break;case 2:{const r=e.func;if(null===r||r(t)){n.fail(a);break}n.step(a,a+1,0);break}case 1:n.step(a,a+1,e.data);break;case 5:if(null===o){n.fail(a);break}if(!(0,e.func)(o,e.data,t)){n.fail(a);break}n.stepToNextGeneration(a,a+1);break;case 3:{const t=e.data,r=t.length;if(0===r){n.fail(a);break}for(let e=0;e<r;++e)n.step(a,t[e],0);break}case 4:{const r=(0,e.func)(e.data,s,t);null!=r&&n.record(a,r),n.step(a,a+1,0);break}}a=n.getNextThreadPc()}n.nextGeneration()}while(null!==o);const i=new a(n.getAcceptingTraces());return n.reset(),this.U.push(n),i}}function m(e){return t=>t===e}function f(e,t){if(null===e||null===t)throw new Error("unescaped hyphen may not be used as a range endpoint");if(t<e)throw new Error("character range is in the wrong order");return n=>e<=n&&n<=t}function g(e){return!0}function y(){return!1}function w(e,t){return n=>e(n)||t(n)}function v(e,t){switch(t.kind){case"predicate":return void e.test(t.value);case"regexp":return void x(e,t.value,!1)}}function x(e,t,n){const r=e.program.length,a=e.jump([]);n&&(a.data.push(e.program.length),e.test((()=>!0)),e.jump([r]));const o=[];if(t.forEach((t=>{a.data.push(e.program.length),function(e,t){t.forEach((t=>{!function(e,t){const[n,{min:r,max:a}]=t;if(null!==a){for(let t=0;t<r;++t)v(e,n);for(let t=r;t<a;++t){const t=e.jump([]);t.data.push(e.program.length),v(e,n),t.data.push(e.program.length)}}else if(r>0){for(let t=0;t<r-1;++t)v(e,n);const t=e.program.length;v(e,n),e.jump([t]).data.push(e.program.length)}else{const t=e.program.length,r=e.jump([]);r.data.push(e.program.length),v(e,n),e.jump([t]),r.data.push(e.program.length)}}(e,t)}))}(e,t),o.push(e.jump([]))})),o.forEach((t=>{t.data.push(e.program.length)})),n){const t=e.program.length,n=e.jump([]);n.data.push(e.program.length),e.test((()=>!0)),e.jump([t]),n.data.push(e.program.length)}}function b(e,t){return{success:!0,offset:e,value:t}}function A(e){return b(e,void 0)}function E(e,t,n=!1){return{success:!1,offset:e,expected:t,fatal:n}}function N(e){return(t,n)=>{const r=n+e.length;return t.slice(n,r)===e?b(r,e):E(n,[e])}}function T(e,t){return(n,r)=>{const a=e(n,r);return a.success?b(a.offset,t(a.value)):a}}function B(e,t,n,r){return(a,o)=>{const s=e(a,o);return s.success?t(s.value)?s:E(o,n,r):s}}function I(e,t){return(n,r)=>{let a=null;for(const o of e){const e=o(n,r);if(e.success)return e;if(null===a||e.offset>a.offset?a=e:e.offset===a.offset&&void 0===t&&(a.expected=a.expected.concat(e.expected)),e.fatal)return e}return t=t||(null==a?void 0:a.expected)||[],a&&(a.expected=t),a||E(r,t)}}function C(e){return(t,n)=>{const r=e(t,n);return r.success||r.fatal?r:b(n,null)}}function S(e){return(t,n)=>{let r=[],a=n;for(;;){const n=e(t,a);if(!n.success){if(n.fatal)return n;break}if(r.push(n.value),n.offset===a)break;a=n.offset}return b(a,r)}}function O(e,t,n){return(r,a)=>{const o=e(r,a);if(!o.success)return o;const s=t(r,o.offset);return s.success?b(s.offset,n(o.value,s.value)):s}}function F(e){return O(e,S(e),((e,t)=>[e].concat(t)))}function D(e,t){return e}function k(e,t){return t}function R(e,t){return O(e,t,k)}function M(e,t){return O(e,t,D)}function U(e,t,n,r=!1){return R(e,r?$(M(t,n)):M(t,n))}function G(e,t){return(n,r)=>e(n,r).success?E(r,t):A(r)}function $(e){return(t,n)=>{const r=e(t,n);return r.success?r:E(r.offset,r.expected,!0)}}const L=(e,t)=>e.length===t?A(t):E(t,["end of input"]),H=["Lu","Ll","Lt","Lm","Lo","Mn","Mc","Me","Nd","Nl","No","Pc","Pd","Ps","Pe","Pi","Pf","Po","Zs","Zl","Zp","Sm","Sc","Sk","So","Cc","Cf","Co","Cn"],P={};function j(e){return e.codePointAt(0)}"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("").forEach(((e,t)=>{P[e]=t}));const _=e=>-1===e||-2===e;function X(e){return t=>!_(t)&&!e(t)}function q(e,t){return null===t?e:n=>e(n)&&!t(n)}const V=function(e,t){const n=new Map;let r=0;return["BasicLatin","Latin-1Supplement","LatinExtended-A","LatinExtended-B","IPAExtensions","SpacingModifierLetters","CombiningDiacriticalMarks","GreekandCoptic|Greek","Cyrillic","CyrillicSupplement","Armenian","Hebrew","Arabic","Syriac","ArabicSupplement","Thaana","NKo","Samaritan","Mandaic","SyriacSupplement","ArabicExtended-B","ArabicExtended-A","Devanagari","Bengali","Gurmukhi","Gujarati","Oriya","Tamil","Telugu","Kannada","Malayalam","Sinhala","Thai","Lao","Tibetan","Myanmar","Georgian","HangulJamo","Ethiopic","EthiopicSupplement","Cherokee","UnifiedCanadianAboriginalSyllabics","Ogham","Runic","Tagalog","Hanunoo","Buhid","Tagbanwa","Khmer","Mongolian","UnifiedCanadianAboriginalSyllabicsExtended","Limbu","TaiLe","NewTaiLue","KhmerSymbols","Buginese","TaiTham","CombiningDiacriticalMarksExtended","Balinese","Sundanese","Batak","Lepcha","OlChiki","CyrillicExtended-C","GeorgianExtended","SundaneseSupplement","VedicExtensions","PhoneticExtensions","PhoneticExtensionsSupplement","CombiningDiacriticalMarksSupplement","LatinExtendedAdditional","GreekExtended","GeneralPunctuation","SuperscriptsandSubscripts","CurrencySymbols","CombiningDiacriticalMarksforSymbols|CombiningMarksforSymbols","LetterlikeSymbols","NumberForms","Arrows","MathematicalOperators","MiscellaneousTechnical","ControlPictures","OpticalCharacterRecognition","EnclosedAlphanumerics","BoxDrawing","BlockElements","GeometricShapes","MiscellaneousSymbols","Dingbats","MiscellaneousMathematicalSymbols-A","SupplementalArrows-A","BraillePatterns","SupplementalArrows-B","MiscellaneousMathematicalSymbols-B","SupplementalMathematicalOperators","MiscellaneousSymbolsandArrows","Glagolitic","LatinExtended-C","Coptic","GeorgianSupplement","Tifinagh","EthiopicExtended","CyrillicExtended-A","SupplementalPunctuation","CJKRadicalsSupplement","KangxiRadicals",null,"IdeographicDescriptionCharacters","CJKSymbolsandPunctuation","Hiragana","Katakana","Bopomofo","HangulCompatibilityJamo","Kanbun","BopomofoExtended","CJKStrokes","KatakanaPhoneticExtensions","EnclosedCJKLettersandMonths","CJKCompatibility","CJKUnifiedIdeographsExtensionA","YijingHexagramSymbols","CJKUnifiedIdeographs","YiSyllables","YiRadicals","Lisu","Vai","CyrillicExtended-B","Bamum","ModifierToneLetters","LatinExtended-D","SylotiNagri","CommonIndicNumberForms","Phags-pa","Saurashtra","DevanagariExtended","KayahLi","Rejang","HangulJamoExtended-A","Javanese","MyanmarExtended-B","Cham","MyanmarExtended-A","TaiViet","MeeteiMayekExtensions","EthiopicExtended-A","LatinExtended-E","CherokeeSupplement","MeeteiMayek","HangulSyllables","HangulJamoExtended-B","HighSurrogates","HighPrivateUseSurrogates","LowSurrogates","PrivateUseArea|PrivateUse","CJKCompatibilityIdeographs","AlphabeticPresentationForms","ArabicPresentationForms-A","VariationSelectors","VerticalForms","CombiningHalfMarks","CJKCompatibilityForms","SmallFormVariants","ArabicPresentationForms-B","HalfwidthandFullwidthForms","Specials","LinearBSyllabary","LinearBIdeograms","AegeanNumbers","AncientGreekNumbers","AncientSymbols","PhaistosDisc",null,"Lycian","Carian","CopticEpactNumbers","OldItalic","Gothic","OldPermic","Ugaritic","OldPersian",null,"Deseret","Shavian","Osmanya","Osage","Elbasan","CaucasianAlbanian","Vithkuqi",null,"LinearA","LatinExtended-F",null,"CypriotSyllabary","ImperialAramaic","Palmyrene","Nabataean",null,"Hatran","Phoenician","Lydian",null,"MeroiticHieroglyphs","MeroiticCursive","Kharoshthi","OldSouthArabian","OldNorthArabian",null,"Manichaean","Avestan","InscriptionalParthian","InscriptionalPahlavi","PsalterPahlavi",null,"OldTurkic",null,"OldHungarian","HanifiRohingya",null,"RumiNumeralSymbols","Yezidi","ArabicExtended-C","OldSogdian","Sogdian","OldUyghur","Chorasmian","Elymaic","Brahmi","Kaithi","SoraSompeng","Chakma","Mahajani","Sharada","SinhalaArchaicNumbers","Khojki",null,"Multani","Khudawadi","Grantha",null,"Newa","Tirhuta",null,"Siddham","Modi","MongolianSupplement","Takri",null,"Ahom",null,"Dogra",null,"WarangCiti","DivesAkuru",null,"Nandinagari","ZanabazarSquare","Soyombo","UnifiedCanadianAboriginalSyllabicsExtended-A","PauCinHau","DevanagariExtended-A",null,"Bhaiksuki","Marchen",null,"MasaramGondi","GunjalaGondi",null,"Makasar","Kawi",null,"LisuSupplement","TamilSupplement","Cuneiform","CuneiformNumbersandPunctuation","EarlyDynasticCuneiform",null,"Cypro-Minoan","EgyptianHieroglyphs","EgyptianHieroglyphFormatControls",null,"AnatolianHieroglyphs",null,"BamumSupplement","Mro","Tangsa","BassaVah","PahawhHmong",null,"Medefaidrin",null,"Miao",null,"IdeographicSymbolsandPunctuation","Tangut","TangutComponents","KhitanSmallScript","TangutSupplement",null,"KanaExtended-B","KanaSupplement","KanaExtended-A","SmallKanaExtension","Nushu",null,"Duployan","ShorthandFormatControls",null,"ZnamennyMusicalNotation",null,"ByzantineMusicalSymbols","MusicalSymbols","AncientGreekMusicalNotation",null,"KaktovikNumerals","MayanNumerals","TaiXuanJingSymbols","CountingRodNumerals",null,"MathematicalAlphanumericSymbols","SuttonSignWriting",null,"LatinExtended-G","GlagoliticSupplement","CyrillicExtended-D",null,"NyiakengPuachueHmong",null,"Toto","Wancho",null,"NagMundari",null,"EthiopicExtended-B","MendeKikakui",null,"Adlam",null,"IndicSiyaqNumbers",null,"OttomanSiyaqNumbers",null,"ArabicMathematicalAlphabeticSymbols",null,"MahjongTiles","DominoTiles","PlayingCards","EnclosedAlphanumericSupplement","EnclosedIdeographicSupplement","MiscellaneousSymbolsandPictographs","Emoticons","OrnamentalDingbats","TransportandMapSymbols","AlchemicalSymbols","GeometricShapesExtended","SupplementalArrows-C","SupplementalSymbolsandPictographs","ChessSymbols","SymbolsandPictographsExtended-A","SymbolsforLegacyComputing",null,"CJKUnifiedIdeographsExtensionB",null,"CJKUnifiedIdeographsExtensionC","CJKUnifiedIdeographsExtensionD","CJKUnifiedIdeographsExtensionE","CJKUnifiedIdeographsExtensionF",null,"CJKCompatibilityIdeographsSupplement",null,"CJKUnifiedIdeographsExtensionG","CJKUnifiedIdeographsExtensionH",null,"Tags",null,"VariationSelectorsSupplement",null,"SupplementaryPrivateUseArea-A|PrivateUse","SupplementaryPrivateUseArea-B|PrivateUse"].forEach(((e,a)=>{const o=t[a];null!==e&&e.split("|").forEach((e=>{const t=n.get(e),a=f(r,r+o-1);n.set(e,t?w(t,a):a)})),r+=o})),n}(0,[128,128,128,208,96,80,112,144,256,48,96,112,256,80,48,64,64,64,32,16,48,96,128,128,128,128,128,128,128,128,128,128,128,128,256,160,96,256,384,32,96,640,32,96,32,32,32,32,128,176,80,80,48,96,32,32,144,80,128,64,64,80,48,16,48,16,48,128,64,64,256,256,112,48,48,48,80,64,112,256,256,64,32,160,128,32,96,256,192,48,16,256,128,128,256,256,96,32,128,48,80,96,32,128,128,224,16,16,64,96,96,48,96,16,32,48,16,256,256,6592,64,20992,1168,64,48,320,96,96,32,224,48,16,64,96,32,48,48,32,96,32,96,32,96,32,48,64,80,64,11184,80,896,128,1024,6400,512,80,688,16,16,16,32,32,144,240,16,128,128,64,80,64,48,128,32,64,32,48,32,48,32,64,32,80,48,48,80,48,64,80,64,384,64,64,64,32,32,48,48,32,32,32,64,32,96,96,32,32,32,64,64,32,32,48,80,80,48,128,64,288,32,64,64,48,64,64,48,32,128,80,48,80,48,96,32,80,48,48,80,128,128,128,96,160,128,96,32,80,48,80,176,80,80,96,96,64,96,80,96,16,64,96,160,112,80,64,96,80,304,32,96,80,16,64,1024,128,208,2624,112,1072,48,4e3,640,8576,576,48,96,48,144,688,96,96,160,64,32,6144,768,512,128,8816,16,256,48,64,400,2304,160,16,4688,208,48,256,256,80,112,32,32,96,32,128,1024,688,1104,256,48,96,112,80,320,48,64,464,48,736,32,224,32,96,784,80,64,80,176,256,256,48,112,96,256,256,768,80,48,128,128,128,256,256,112,144,256,1024,42720,32,4160,224,5776,7488,3088,544,1504,4944,4192,711760,128,128,240,65040,65536,65536]),Y=function(e){const t=new Map,n="bfUATCYATCPAQATAXATAOATBKJTBXCTBCZPATAQAZANAZADZPAXAQAXAbgUATAYDaATAZAaAGARAXAcAaAZAaAXAMBZADATBZAMAGASAMCTACWXACGDXXADHA3DAAPDAAtCAAFDBCAADCAABCCDBCCABCAABCCDCCAABCAAFCAADDAABCAABCBADCBDBGACADCGDCAEADACAEADACAEADAAPDAARDACAEADAABCBA7DFCAABCBDBABCCAJjDBAAGADaFRZDFLZNFEZGFAZAFAZQnvBAAADFAZACADABBFADCTACABDZBCATACCBACABACAABCQBACIDiCADBCCDCAXDDCADAXAABCBDBCyDvAhaAHEJBA1CAANDAgfBAABAClBBFATFDoTAOABBaBYABAHsOAHATAHBTAHBTAHABHGaBDGDTBBKcFXCTBYATBaBHKTAcATCGfFAGJHUKJTDGBHAmiBAATAGAHGcAaAHFFBHBaAHDGBKJGCaBGATNBAcAGAHAGdHaBBmYBAAHKGABNKJGgHIFBaATCFABBHAYBGVHDFAHIFAHCFAHEBBTOBAGYHCBBTABAGKBEGXZAGFBAcBBFHHGoFAHXcAHfIAG1HAIAHAGAICHHIDHAIBGAHGGJHBTBKJTAFAGOHAIBBAGHBBGBBBGVBAGGBAGABCGDBBHAGAICHDBBIBBBIBHAGABHIABDGBBAGCHBBBKJGBYBMFaAYAGATAHABBHBIABAGFBDGBBBGVBAGGBAGBBAGBBAGBBBHABAICHBBDHBBBHCBCHABGGDBAGABGKJHBGCHATABJHBIABAGIBAGCBAGVBAGGBAGBBAGEBBHAGAICHEBAHBIABAIBHABBGABOGBHBBBKJTAYABGGAHFBAHAIBBAGHBBGBBBGVBAGGBAGBBAGEBBHAGAIAHAIAHDBBIBBBIBHABGHBIABDGBBAGCHBBBKJaAGAMFBJHAGABAGFBCGCBAGDBCGBBAGABAGBBCGBBCGCBCGLBDIBHAIBBCICBAICHABBGABFIABNKJMCaFYAaABEHAICHAGHBAGCBAGWBAGPBBHAGAHCIDBAHCBAHDBGHBBAGCBBGABBGBHBBBKJBGTAMGaAGAHAIBTAGHBAGCBAGWBAGJBAGEBBHAGAIAHAIEBAHAIBBAIBHBBGIBBFGBBAGBHBBBKJBAGBIABLHBIBGIBAGCBAGoHBGAICHDBAICBAICHAGAaABDGCIAMGGCHBBBKJMIaAGFBAHAIBBAGRBCGXBAGIBAGABBGGBCHABDICHCBAHABAIHBFKJBBIBTABLGvHAGBHGBDYAGFFAHHTAKJTBBkGBBAGABAGEBAGXBAGABAGJHAGBHIGABBGEBAFABAHGBAKJBBGDBfGAaCTOaATAaCHBaFKJMJaAHAaAHAaAHAPAQAPAQAIBGHBAGjBDHNIAHETAHBGEHKBAHjBAaHHAaFBAaBTEaDTBBkGqIBHDIAHFIAHBIBHBGAKJTFGFIBHBGDHCGAICGBIGGCHDGMHAIBHBIFHAGAIAKJICHAaBClBACABECABBDqTAFADCmIFAABAGDBBGGBAGABAGDBBGoBAGDBBGgBAGDBBGGBAGABAGDBBGOBAG4BAGDBBmCBAABBHCTIMTBCGPaJBFiVBAABBDFBBOAmrJAAaATAGQUAGZPAQABCmKBAATCLCGHBGGRHCIABIGSHBIATBBIGRHBBLGMBAGCBAHBBLGzHBIAHGIHHAIBHKTCFATCYAGAHABBKJBFMJBFTFOATDHCcAHAKJBFGiFAG0BGGEHBGhHAGABEmFBAABJGeBAHCIDHBICBDIBHAIFHCBDaABCTBKJGdBBGEBKGrBDGZBFKJMABCahGWHBIBHABBTBG0IAHAIAHGBAHAIAHAIBHHIFHJBBHAKJBFKJBFTGFATFBBHNJAHPBwHDIAGuHAIAHEIAHAIEHAIBGHBCKJTGaJHIaITBBAHBIAGdIAHDIBHBIAHCGBKJGrHAIAHBICHAIAHCIBBHTDGjIHHHIBHBBCTEKJBCGCKJGdFFTBDIBGCqBBCCTHBHHCTAHMIAHGGDHAGFHAGBIAHBGABEDrF+DMFADhFkH/gVCAADHghBAADHCHDFBBCFBBDHCHDHCHDFBBCFBBDHBACABACABACABACADHCHDNBBDHEHDHEHDHEHDEBADBCDEAZADAZCDCBADBCDEAZCDDBBDBCDBAZCDHCEZCBBDCBADBCDEAZBBAUKcEOFTBRASAPARBSAPARATHVAWAcEUATIRASATDNBTCXAPAQATKXATANATJUAcEBAcJMAFABBMFXCPAQAFAMJXCPAQABAFMBCYgBOHMJDHAJCHLBOaBCAaDCAaBDACCDBCCDAaACAaBXACEaFCAaACAaACAaACDaADACDDAGDDAaBDBCBXECADDaAXAaBDAaAMPLiCADALDMAaBBDXEaEXBaDXAaBXAaBXAaGXAaeXBaBXAaAXAae3LEAAaHPAQAPAQAaTXBaGPAQA6QBAAXAadXYanXF6EBAABYaKBUM76NBAAMV62CAAXAaIXAa1XH6uBAAXA63DAAPAQAPAQAPAQAPAQAPAQAPAQAPAQAMdarXEPAQAXePAQAPAQAPAQAPAQAPAQAXP6/DAA3CCAAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAX+PAQAPAQAXfPAQA3BEAAavXUaBXFamBBafBA6oBAACvDvABCCDBAFCCADDACADFFBCBgjBAADAaFADHCCADABETDMATBDlBADABEDABBG3BGFATABNHAGWBIGGBAGGBAGGBAGGBAGGBAGGBAGGBAGGBAHfTBRASARASATCRASATARASATIOATBOATARASATBRASAPAQAPAQAPAQAPAQATEFATJOBTDOATAPATMaBTCPAQAPAQAPAQAPAQAOABhaZBA6YBAABL6VDAABZaLBDUATCaAFAGALAPAQAPAQAPAQAPAQAPAQAaBPAQAPAQAPAQAPAQAOAPAQBaALIHDIBOAFEaBLCFAGATAaBBAmVBAABBHBZBFBGAOAmZBAATAFCGABEGqBAmdBAABAaBMDaJGfajBLGPaeBAMJadMHaAMOafMJamMO6/EAAm/mBAa/mUIFAFAm2RAABCa2BIGnFFTBmLEAAFATCGPKJGBBTAtGAHAJCTAHJTAFAAbFBHBmFBAALJHBTFBHZWFIZBANDBA9FADHADCAAJFAZBADGAADDBATCDABCDAPCCADBECADABADABADAADBXFCCADAGAFBDAGGHAGCHAGDHAGWIBHBIAaDHABCMFaBYAaABFGzTDBHIBGxIPHBBHTBKJBFHRGFTCGATAGBHAKJGbHHTBGWHKIBBKTAGcBCHCIAGuHAIBHDIBHBICTMBAFAKJBDTBGEHAFAGIKJGEBAGoHFIBHBIBHBBIGCHAGHHAIABBKJBBTDGPFAGFaCGAIAHAIAGxHAGAHCGBHBGEHBGAHAGABXGBFATBGKIAHBIBTBGAFBIAHABJGFBBGFBBGFBIGGBAGGBADqZAFDDIFAZBBDjPBAAGiIBHAIBHAIBTAIAHABBKJBFmjuCABLGWBDGwhDgAA9/jBAmtFAABBmpBAABlDGBLDEBEGAHAGJXAGMBAGEBAGABAGBBAGBBAmrBAAZQBPmqFAAQAPAaPG/BBG1BGaABfGLYAaCHPTGPAQATABFHPTAOBNBPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQATBPAQATDNCTCBATDOAPAQAPAQAPAQATCXAOAXCBATAYATBBDGEBAmGCAABBcABATCYATCPAQATAXATAOATBKJTBXCTBCZPATAQAZANAZADZPAXAQAXAPAQATAPAQATBGJFAGsFBGeBCGFBBGFBBGFBBGCBCYBXAZAaAYBBAaAXDaBBJcCaBBBGLBAGZBAGSBAGBBAGOBBGNBhm6BAABETCBDMsBCaIL0MDaQMBaCBAaMBCaABuasHAhBCAAGcBCGwBOHAMaBDGfMDBIGTLAGHLABEGlHEBEGdBATAGjBDGHTALEBpCnDnmNBAABBKJBFCjBDDjBDGnBHGzBKTACKBACOBACGBACBBADKBADOBADGBADBhCBAAm2EAABIGVBJGHBXFFBAFpBAFIhEBAAGFBBGABAGrBAGBBCGABBGWBATAMHGWaBMGGeBHMIBvGSBAGBBEMEGVMFBCTAGZBETAB/G3BDMBGBMPBBMtGAHCBAHBBEHDGDBAGCBAGcBBHCBDHAMIBGTIBGGcMBTAGcMCBfGHaAGbHBBDMETGBIG1BCTGGVBBMHGSBEMHGRBGTDBLMGhPBAAmIBAAB2CyBMDyBGMFGjHDBHKJhlEAAMeBAGpBAHBOABBGBhKBAAHCGcMJGABHGVHKMDTEBVGRHDTDBlGUMGBTGWBIIAHAIAG0HOTGBDMTKJHAGBHBGABIHCIAGsICHDIBHBTBcATDHABJcABBGYBGKJBFHCGjHEIAHHBAKJTDGAIBGABHGiHATBGABIHBIAGvICHIIBGDTDHDTAIAHAKJGATAGATCBAMTBKGRBAGYICHCIBHAIAHBTFHAGBHAB9GGBAGABAGDBAGOBAGJTABFGuHAICHHBEKJBFHBIBBAGHBBGBBBGVBAGGBAGBBAGEBAHBGAIBHAIDBBIBBBICBBGABFIABEGEIBBBHGBCHEhKCAAG0ICHHIBHCIAHAGDTEKJTBBATAHAGCBdGvICHFIAHAIDHBIAHBGBTAGABHKJhlCAAGuICHDBBIDHBIAHBTWGDHBBhGvICHHIBHAIAHBTCGABKKJBFTMBSGqHAIAHAIBHFIAHAGATABFKJB1GaBBHCIBHDIAHEBDKJMBTCaAGGh4CAAGrICHIIAHBTAhjBAACfDfKJMIBLGHBBGABBGHBAGBBAGXIFBAIBBBHBIAHAGAIAGAIAHATCBIKJhFBAAGHBBGmICHDBBHBIDHAGATAGAIABaGAHJGnHFIAGAHDTHHABHGAHFIBHCGtHMIAHBTCGATEBMmIBAABGTJh1DAAGIBAGkIAHGBAHFIAHAGATEBJKJMSBCTBGdBBHVBAIAHGIAHBIAHBhIBAAGGBAGBBAGlHFBCHABAHBBAHGGAHABHKJBFGFBAGBBAGfIEBAHBBAIBHAIAHAGABGKJh1EAAGSHBIBTBBGHBGAIAGMBAGhIBHEBCIBHAIAHATMKJhVBAAGABOMUaHYDaQBMTAmZOAAhlBAAruBAABATEBKmDDAAhLpAAmgBAATBBMmvQAAcPHAGFHOhp+AAmGJAAh4GCAm4IAABGGeBAKJBDTBmOBAABAKJBFGdBBHETABJGvHGTEaDFDTAaABJKJBAMGBAGUBEGShvKAACfDfMWTDhkBAAmKBAABDHAGAI2BGHDFMB/FBTAFAHABKIBBNm3fBABHmVTAABpGIhmLCAFDBAFGBAFBBAmiEAABOGABcGCBBGABNGDBHmLGAAhDkAAmqBAABEGMBCGIBGGJBBaAHBTAcDhbJBAHtBBHWBI6zBAAB761DAABJamBBa7IBHCaCIFcHHHaBHGadHDa8BU6BBAAHCaAh5BAAMTBLMTBL6WBAABIMYhGCAACZDZCZDGBADRCZDZCABACBBBCABBCBBBCDBACHDDBADABADGBADKCZDZCBBACDBBCHBACGBADZCBBACDBACEBACABCCGBADZCZDZCZDZCZDZCZDZCZDZCZDbBBCYXADYXADFCYXADYXADFCYXADYXADFCYXADYXADFCYXADYXADFCADABBKx6/HAAH2aDHxaHHAaNHAaBTEBOHEBAHOhPRAADJGADTBFDFhUDAAHGBAHQBBHGBAHBBAHEBEF9BgHAhvBAAGsBCHGFGBBKJBDGAaAh/EAAGdHABQGrHDKJBEYAhPHAAGaFAHDKJhlLAAGGBAGDBAGBBAGOBAmEDAABBMIHGBoChDhHGFABDKJBDTBhQMAAM6aAMCYAMDhLBAAMsaAMOhBDAAGDBAGaBAGBBAGABBGABAGJBAGDBAGABAGABFGABDGABAGABAGABAGCBAGBBAGABBGABAGABAGABAGABAGABAGBBAGABBGDBAGGBAGDBAGDBAGABAGJBAGQBEGCBAGEBAGQBzXBhNEAAarBD6jBAABLaOBBaOBAaOBAakBJMM6gCAAB3acBMarBDaIBGaBBNaFhZCAA66DAAZE6XLAABDaQBCaMBC62BAABD6eBAABFaLBDaABOaLBDa3BHaJBFanBHadBBaBhNBAA6TFAABLaNBBaMBCaIBGatBAaGBHaNBDaIBGaIBG6SCAABAa2BkKJhFQAAmfbKABfm5ABABFmdDAABBmBaBABNmw0BAhewAAmdIAAhhXAAmKNBABEmfBBAhQxtCcABd8fBAAh/BAAnvDAAhP4PA99/PABB99/PA".split(""),r=H.map((()=>[]));let a=0,o=0;for(;o<n.length;){const e=P[n[o]],t=(31&e)-2;let s=1+P[n[o+1]];switch(32&e?(s+=P[n[o+2]]<<6,s+=P[n[o+3]]<<12,s+=P[n[o+4]]<<18,o+=5):o+=2,t){case-2:{let e=0;for(let t=a;t<a+s;++t)r[e].push(m(t)),e=(e+1)%2;break}case-1:break;default:{const e=r[t];1===s?e.push(m(a)):e.push(f(a,a+s-1));break}}a+=s}const s=new Map;return H.forEach(((e,n)=>{const a=r[n].reduce(w,y);t.set(e,a);const o=e.charAt(0),i=s.get(o)||[];s.set(o,i),i.push(a)})),s.forEach(((e,n)=>{t.set(n,e.reduce(w,y))})),t}();function z(e){return 32===e||9===e||10===e||13===e}const J=[m(j(":")),f(j("A"),j("Z")),m(j("_")),f(j("a"),j("z")),f(192,214),f(216,246),f(192,214),f(216,246),f(248,767),f(880,893),f(895,8191),f(8204,8205),f(8304,8591),f(11264,12271),f(12289,55295),f(63744,64975),f(65008,65533),f(65536,983039)].reduce(w),Q=[J,m(j("-")),m(j(".")),f(j("0"),j("9")),m(183),f(768,879),f(8255,8256)].reduce(w),K=Y.get("Nd"),W=X(K),Z=q(f(0,1114111),[Y.get("P"),Y.get("Z"),Y.get("C")].reduce(w)),ee=X(Z);function te(e){return 10!==e&&13!==e&&!_(e)}const ne={s:z,S:X(z),i:J,I:X(J),c:Q,C:X(Q),d:K,D:W,w:Z,W:ee},re=N("*"),ae=N("\\"),oe=N("{"),se=N("}"),ie=N("["),le=N("]"),ce=N("^"),ue=N("$"),pe=N(","),he=N("-"),de=N("("),me=N(")"),fe=N("."),ge=N("|"),ye=N("+"),we=N("?"),ve=N("-["),xe=j("0");function be(e){return[...e].map((e=>e.codePointAt(0)))}var Ae=Object.freeze({__proto__:null,compile:function(e,t={language:"xsd"}){const r=function(e){function t(e){return new Set(e.split("").map((e=>j(e))))}function n(e,t){const n=e.codePointAt(t);return void 0===n?E(t,["any character"]):b(t+String.fromCodePoint(n).length,n)}const r="xpath"===e.language?R(ae,I([T(N("n"),(()=>10)),T(N("r"),(()=>13)),T(N("t"),(()=>9)),T(I([ae,ge,fe,he,ce,we,re,ye,oe,se,ue,de,me,ie,le]),(e=>j(e)))])):R(ae,I([T(N("n"),(()=>10)),T(N("r"),(()=>13)),T(N("t"),(()=>9)),T(I([ae,ge,fe,he,ce,we,re,ye,oe,se,de,me,ie,le]),(e=>j(e)))]));function a(e,r){const a=t(r);return O(N(e),C(B(n,(e=>a.has(e)),r.split(""))),((e,t)=>function(e){const t=Y.get(e);if(null==t)throw new Error(e+" is not a valid unicode category");return t}(null===t?e:e+String.fromCodePoint(t))))}const o=I([a("L","ultmo"),a("M","nce"),a("N","dlo"),a("P","cdseifo"),a("Z","slp"),a("S","mcko"),a("C","cfon")]),s=[f(j("a"),j("z")),f(j("A"),j("Z")),f(j("0"),j("9")),m(45)].reduce(w),i=I([o,T(R(N("Is"),function(e){return(t,n)=>{const r=e(t,n);return r.success?b(r.offset,t.slice(n,r.offset)):r}}(F(B(n,s,["block identifier"])))),(t=>function(e,t){const n=V.get(e);if(void 0===n){if(t)return g;throw new Error(`The unicode block identifier "${e}" is not known.`)}return n}(t,"xpath"!==e.language)))]),l=U(N("\\p{"),i,se,!0),c=T(U(N("\\P{"),i,se,!0),X),u=R(ae,T(I("sSiIcCdDwW".split("").map((e=>N(e)))),(e=>ne[e]))),p=T(fe,(()=>te)),h=I([u,l,c]),d=t("\\[]"),y=I([r,B(n,(e=>!d.has(e)),["unescaped character"])]),v=I([T(he,(()=>null)),y]),x=O(v,R(he,v),f);function A(e,t){return[e].concat(t||[])}const k=T(function(e){return(t,n)=>{const r=e(t,n);return r.success?b(n,r.value):r}}(I([le,ve])),(()=>null)),H=j("-"),P=I([T(M(M(he,G(ie,["not ["])),k),(()=>H)),R(G(he,["not -"]),y)]),_=I([O(T(P,m),I([function(e,t){return _(e,t)},k]),A),O(I([x,h]),I([J,k]),A)]),z=I([O(T(y,m),I([_,k]),A),O(I([x,h]),I([J,k]),A)]);function J(e,t){return z(e,t)}const Q=T(z,(e=>e.reduce(w))),K=T(R(ce,Q),X),W=O(I([R(G(ce,["not ^"]),Q),K]),C(R(he,(function(e,t){return Z(e,t)}))),q),Z=U(ie,W,le,!0),ee="xpath"===e.language?I([T(r,m),h,Z,p,T(ce,(()=>e=>-1===e)),T(ue,(()=>e=>-2===e))]):I([T(r,m),h,Z,p]),be="xpath"===e.language?t(".\\?*+{}()|^$[]"):t(".\\?*+{}()|[]"),Ae=B(n,(e=>!be.has(e)),["NormalChar"]),Ee=T(R(ae,O(T(B(n,f(j("1"),j("9")),["digit"]),(e=>e-xe)),S(T(B(n,f(xe,j("9")),["digit"]),(e=>e-xe))),((e,t)=>{t.reduce(((e,t)=>10*e+t),e)}))),(e=>{throw new Error("Backreferences in XPath patterns are not yet implemented.")})),Ne="xpath"===e.language?I([T(Ae,(e=>({kind:"predicate",value:m(e)}))),T(ee,(e=>({kind:"predicate",value:e}))),T(U(de,R(C(N("?:")),Oe),me,!0),(e=>({kind:"regexp",value:e}))),Ee]):I([T(Ae,(e=>({kind:"predicate",value:m(e)}))),T(ee,(e=>({kind:"predicate",value:e}))),T(U(de,Oe,me,!0),(e=>({kind:"regexp",value:e})))]),Te=T(F(T(B(n,f(xe,j("9")),["digit"]),(e=>e-xe))),(e=>e.reduce(((e,t)=>10*e+t)))),Be=I([O(Te,R(pe,Te),((e,t)=>{if(t<e)throw new Error("quantifier range is in the wrong order");return{min:e,max:t}})),O(Te,pe,(e=>({min:e,max:null}))),T(Te,(e=>({min:e,max:e})))]),Ie="xpath"===e.language?O(I([T(we,(()=>({min:0,max:1}))),T(re,(()=>({min:0,max:null}))),T(ye,(()=>({min:1,max:null}))),U(oe,Be,se,!0)]),C(we),((e,t)=>e)):I([T(we,(()=>({min:0,max:1}))),T(re,(()=>({min:0,max:null}))),T(ye,(()=>({min:1,max:null}))),U(oe,Be,se,!0)]),Ce=S(O(Ne,T(C(Ie),(e=>null===e?{min:1,max:1}:e)),((e,t)=>[e,t]))),Se=O(Ce,S(R(ge,$(Ce))),((e,t)=>[e].concat(t)));function Oe(e,t){return Se(e,t)}const Fe=function(e){return O(e,L,D)}(Se);return function(e){let t;try{t=Fe(e,0)}catch(t){throw new Error(`Error parsing pattern "${e}": ${t instanceof Error?t.message:t}`)}return t.success?t.value:function(e,t,n){const r=n.map((e=>`"${e}"`));throw new Error(`Error parsing pattern "${e}" at offset ${t}: expected ${r.length>1?"one of "+r.join(", "):r[0]} but found "${e.slice(t,t+1)}"`)}(e,t.offset,t.expected)}}(t)(e),a=function(e){const t=new n;return e(t),new d(t.program)}((e=>{x(e,r,"xpath"===t.language),e.accept()}));return function(e){const n="xpath"===t.language?[-1,...be(e),-2]:be(e);return a.execute(n).success}}});function Ee(e,t){return{success:!0,offset:e,value:t}}function Ne(e){return Ee(e,void 0)}function Te(e,t,n=!1){return{success:!1,offset:e,expected:t,fatal:n}}function Be(e){return e>65535?2:1}function Ie(e,t){return(n,r)=>{const a=n.codePointAt(r);return void 0!==a&&e(a)?Ne(r+Be(a)):Te(r,t)}}function Ce(e,t){return(n,r)=>{const a=e(n,r);return a.success?Ee(a.offset,t(a.value)):a}}function Se(e){return(t,n)=>{let r=[],a=n;for(;;){const n=e(t,a);if(!n.success){if(n.fatal)return n;break}if(r.push(n.value),n.offset===a)break;a=n.offset}return Ee(a,r)}}function Oe(e){return(t,n)=>{let r=n;for(;;){const n=e(t,r);if(!n.success){if(n.fatal)return n;break}if(n.offset===r)break;r=n.offset}return Ne(r)}}function Fe(e,t,n){return(r,a)=>{const o=e(r,a);if(!o.success)return o;const s=t(r,o.offset);return s.success?Ee(s.offset,n(o.value,s.value)):s}}function De(e,t){return e}function ke(e,t){return t}function Re(e,t){return Fe(e,t,ke)}function Me(e,t){return Fe(e,t,De)}function Ue(e,t){return(n,r)=>e(n,r).success?Te(r,t):Ne(r)}function Ge(e){return(t,n)=>{const r=e(t,n);return r.success?r:Te(r.offset,r.expected,!0)}}const $e=(e,t)=>e.length===t?Ne(t):Te(t,["end of input"]);function Le(e){const t=[];let n=e.next();for(;!n.done;)t.push(n.value),n=e.next();return[t,n.value]}var He=Object.freeze({__proto__:null,codepoint:Ie,codepoints:function(e,t){return(n,r)=>{const a=r;for(;;){const t=n.codePointAt(r);if(void 0===t)break;if(!e(t))break;r+=t>65535?2:1}return void 0!==t&&r===a?Te(r,t):Ne(r)}},collect:Le,complete:function(e){return Fe(e,$e,De)},consume:function(e){return Ce(e,(()=>{}))},cut:Ge,delimited:function(e,t,n,r=!1){return Re(e,r?Ge(Me(t,n)):Me(t,n))},dispatch:function(e,t,n=0,r=[]){return(a,o)=>{const s=a.codePointAt(o+n);if(void 0===s)return Te(o,r);const i=e[s];return void 0===i?void 0===t?Te(o,r):t(a,o):i(a,o)}},end:$e,error:Te,except:function(e,t,n){return Re(Ue(t,n),e)},filter:function(e,t,n,r){return(a,o)=>{const s=e(a,o);return s.success?t(s.value)?s:Te(o,n,r):s}},filterUndefined:function(e){return Ce(e,(e=>e.filter((e=>void 0!==e))))},first:De,followed:Me,map:Ce,not:Ue,ok:Ne,okWithValue:Ee,optional:function(e){return(t,n)=>{const r=e(t,n);return r.success||r.fatal?r:Ee(n,null)}},or:function(e,t){return(n,r)=>{let a=null;for(const o of e){const e=o(n,r);if(e.success)return e;if(null===a||e.offset>a.offset?a=e:e.offset===a.offset&&void 0===t&&(a.expected=a.expected.concat(e.expected)),e.fatal)return e}return t=t||(null==a?void 0:a.expected)||[],a&&(a.expected=t),a||Te(r,t)}},peek:function(e){return(t,n)=>{const r=e(t,n);return r.success?Ee(n,r.value):r}},plus:function(e){return Fe(e,Se(e),((e,t)=>[e].concat(t)))},plusConsumed:function(e){return Fe(e,Oe(e),ke)},preceded:Re,range:function(e,t,n){return Ie((n=>e<=n&&n<=t),n||[`${String.fromCodePoint(e)}-${String.fromCodePoint(t)}`])},recognize:function(e){return(t,n)=>{const r=e(t,n);return r.success?Ee(r.offset,t.slice(n,r.offset)):r}},second:ke,sequence:function(...e){return(t,n)=>{const r=[];for(const a of e){const e=a(t,n);if(!e.success)return e;n=e.offset,r.push(e.value)}return Ee(n,r)}},sequenceConsumed:function(...e){return(t,n)=>{for(const r of e){const e=r(t,n);if(!e.success)return e;n=e.offset}return Ne(n)}},skipChars:function(e){return(t,n)=>{let r=e;for(;r>0;){const e=t.codePointAt(n);if(void 0===e)return Te(n,["any character"]);n+=Be(e),r-=1}return Ne(n)}},star:Se,starConsumed:Oe,start:(e,t)=>0===t?Ne(t):Te(t,["start of input"]),streaming:function(e){return function*(t,n){const r=e(t,n);return r.success&&(yield r.value),r}},streamingComplete:function(e){return function*(t,n){const r=yield*e(t,n);return r.success?$e(t,r.offset):r}},streamingFilterUndefined:function(e){return function*(t,n){const r=e(t,n);let a=r.next();for(;!a.done;){const e=a.value;void 0!==e&&(yield e),a=r.next()}return a.value}},streamingOptional:function(e){return function*(t,n){const[r,a]=Le(e(t,n));return a.success?(yield*r,a):a.fatal?a:Ne(n)}},streamingStar:function(e){return function*(t,n){for(;;){const[r,a]=Le(e(t,n));if(!a.success)return a.fatal?a:Ne(n);if(yield*r,n===a.offset)return Ne(n);n=a.offset}}},streamingThen:function(e,t){return function*(n,r){const a=yield*e(n,r);return a.success?yield*t(n,a.offset):a}},then:Fe,token:function(e){return(t,n)=>{const r=n+e.length;return t.slice(n,r)===e?Ee(r,e):Te(n,[e])}}});const Pe=function(e,t){const n={};function r(e,t){if(!("0"!==e&&"-0"!==e||"0"!==t&&"-0"!==t))return 0;var n=/(?:\+|(-))?(\d+)?(?:\.(\d+))?/;e=n.exec(e+"");var r=n.exec(t+""),a=!e[1];const o=!r[1];return t=(e[2]||"").replace(/^0*/,""),n=(r[2]||"").replace(/^0*/,""),e=e[3]||"",r=r[3]||"",a&&!o?1:!a&&o?-1:(a=a&&o,t.length>n.length?a?1:-1:t.length<n.length?a?-1:1:t>n?a?1:-1:t<n?a?-1:1:(t=Math.max(e.length,r.length),(n=e.padEnd(t,"0"))>(t=r.padEnd(t,"0"))?a?1:-1:n<t?a?-1:1:0))}function a(e,t){return!(-1<(e=e.toString()).indexOf(".")&&0===t)&&(!(e=/^[-+]?0*([1-9]\d*)?(?:\.((?:\d*[1-9])*)0*)?$/.exec(e))[2]||e[2].length<=t)}function o(e,t){switch(t){case"required":return/(Z)|([+-])([01]\d):([0-5]\d)$/.test(e.toString());case"prohibited":return!/(Z)|([+-])([01]\d):([0-5]\d)$/.test(e.toString());case"optional":return!0}}function s(e){switch(e){case 1:case 0:case 6:case 3:case 18:case 22:case 21:case 20:case 23:case 44:return{};case 4:return{ka:a,wa:function(e,t){return 1>r(e,t)},lc:function(e,t){return 0>r(e,t)},xa:function(e,t){return-1<r(e,t)},mc:function(e,t){return 0<r(e,t)}};case 9:case 8:case 7:case 11:case 12:case 13:case 15:case 14:return{Ba:o};default:return null}}var i={},l={};function c(e){return/^([+-]?(\d*(\.\d*)?([eE][+-]?\d*)?|INF)|NaN)$/.test(e)}function u(e){return/^[_:A-Za-z][-._:A-Za-z0-9]*$/.test(e)}function p(e){return u(e)&&/^[_A-Za-z]([-._A-Za-z0-9])*$/.test(e)}function h(e){return 1===(e=e.split(":")).length?p(e[0]):2===e.length&&(p(e[0])&&p(e[1]))}function d(e){return!/[\u0009\u000A\u000D]/.test(e)}function m(e){return p(e)}const f=new Map([[45,function(){return!0}],[46,function(){return!0}],[1,function(){return!0}],[0,function(e){return/^(0|1|true|false)$/.test(e)}],[6,function(e){return c(e)}],[3,c],[4,function(e){return/^[+-]?\d*(\.\d*)?$/.test(e)}],[18,function(e){return/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.test(e)}],[9,function(e){return/^-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?|(24:00:00(\.0+)?))(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[8,function(e){return/^(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?|(24:00:00(\.0+)?))(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[7,function(e){return/^-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[11,function(e){return/^-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[12,function(e){return/^-?([1-9][0-9]{3,}|0[0-9]{3})(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[13,function(e){return/^--(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[15,function(e){return/^---(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[14,function(e){return/^--(0[1-9]|1[0-2])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[22,function(e){return/^([0-9A-Fa-f]{2})*$/.test(e)}],[21,function(e){return new RegExp(/^((([A-Za-z0-9+/] ?){4})*((([A-Za-z0-9+/] ?){3}[A-Za-z0-9+/])|(([A-Za-z0-9+/] ?){2}[AEIMQUYcgkosw048] ?=)|(([A-Za-z0-9+/] ?)[AQgw] ?= ?=)))?$/).test(e)}],[20,function(){return!0}],[44,h],[48,d],[52,function(e){return d(e)&&!/^ | {2,}| $/.test(e)}],[51,function(e){return/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/.test(e)}],[50,function(e){return/^[-._:A-Za-z0-9]+$/.test(e)}],[25,u],[23,h],[24,p],[42,m],[41,m],[26,function(e){return p(e)}],[5,function(e){return/^[+-]?\d+$/.test(e)}],[16,function(e){return/^-?P[0-9]+(Y([0-9]+M)?|M)$/.test(e)}],[17,function(e){return/^-?P([0-9]+D)?(T([0-9]+H)?([0-9]+M)?([0-9]+(\.[0-9]+)?S)?)?$/.test(e)}]]);var g=Object.create(null);function y(e,t){if(!g[t])throw Error("Unknown type");return{type:t,value:e}}[{C:0,name:59},{C:0,name:46,parent:59,K:{whiteSpace:"preserve"}},{C:0,name:19,parent:46},{C:0,name:1,parent:46},{C:0,name:0,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:4,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:6,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:3,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:18,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:9,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:8,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:7,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:11,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:12,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:13,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:15,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:14,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:22,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:21,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:20,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:23,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:44,parent:46,K:{whiteSpace:"collapse"}},{C:1,name:10,R:9,K:{whiteSpace:"collapse",Ba:"required"}},{C:1,name:48,R:1,K:{whiteSpace:"replace"}},{C:1,name:52,R:48,K:{whiteSpace:"collapse"}},{C:1,name:51,R:52,K:{whiteSpace:"collapse"}},{C:1,name:50,R:52,K:{whiteSpace:"collapse"}},{C:2,name:49,type:50,K:{minLength:1,whiteSpace:"collapse"}},{C:1,name:25,R:52,K:{whiteSpace:"collapse"}},{C:1,name:24,R:25,K:{whiteSpace:"collapse"}},{C:1,name:42,R:24,K:{whiteSpace:"collapse"}},{C:1,name:41,R:24,K:{whiteSpace:"collapse"}},{C:2,name:43,type:41,K:{minLength:1,whiteSpace:"collapse"}},{C:1,name:26,R:24,K:{whiteSpace:"collapse"}},{C:2,name:40,type:26,K:{minLength:1,whiteSpace:"collapse"}},{C:0,name:5,parent:4,K:{ka:0,whiteSpace:"collapse"}},{C:1,name:27,R:5,K:{ka:0,wa:"0",whiteSpace:"collapse"}},{C:1,name:28,R:27,K:{ka:0,wa:"-1",whiteSpace:"collapse"}},{C:1,name:31,R:5,K:{ka:0,wa:"9223372036854775807",xa:"-9223372036854775808",whiteSpace:"collapse"}},{C:1,name:32,R:31,K:{ka:0,wa:"2147483647",xa:"-2147483648",whiteSpace:"collapse"}},{C:1,name:33,R:32,K:{ka:0,wa:"32767",xa:"-32768",whiteSpace:"collapse"}},{C:1,name:34,R:33,K:{ka:0,wa:"127",xa:"-128",whiteSpace:"collapse"}},{C:1,name:30,R:5,K:{ka:0,xa:"0",whiteSpace:"collapse"}},{C:1,name:36,R:30,K:{ka:0,wa:"18446744073709551615",xa:"0",whiteSpace:"collapse"}},{C:1,name:35,R:36,K:{ka:0,wa:"4294967295",xa:"0",whiteSpace:"collapse"}},{C:1,name:38,R:35,K:{ka:0,wa:"65535",xa:"0",whiteSpace:"collapse"}},{C:1,name:37,R:38,K:{ka:0,wa:"255",xa:"0",whiteSpace:"collapse"}},{C:1,name:29,R:30,K:{ka:0,xa:"1",whiteSpace:"collapse"}},{C:1,name:16,R:18,K:{whiteSpace:"collapse"}},{C:1,name:17,R:18,K:{whiteSpace:"collapse"}},{C:1,name:60,R:59},{C:3,name:39,Ca:[]},{C:1,name:61,R:60},{C:1,name:62,R:60},{C:0,name:53,parent:59},{C:1,name:54,R:53},{C:1,name:58,R:53},{C:1,name:47,R:53},{C:1,name:56,R:53},{C:1,name:57,R:53},{C:1,name:55,R:53},{C:3,name:2,Ca:[4,5,6,3]},{C:3,name:63,Ca:[]}].forEach((e=>{const t=e.name,n=e.K||{};switch(e.C){case 0:e=e.parent?g[e.parent]:null;var r=f.get(t)||null;g[t]={C:0,type:t,Ja:n,parent:e,fb:r,Oa:s(t),Ca:[]};break;case 1:e=g[e.R],r=f.get(t)||null,g[t]={C:1,type:t,Ja:n,parent:e,fb:r,Oa:e.Oa,Ca:[]};break;case 2:g[t]={C:2,type:t,Ja:n,parent:g[e.type],fb:null,Oa:i,Ca:[]};break;case 3:e=e.Ca.map((e=>g[e])),g[t]={C:3,type:t,Ja:n,parent:null,fb:null,Oa:l,Ca:e}}}));var w=y(!0,0),v=y(!1,0),x=(e="A wrong argument type was specified in a function call.")=>Error(`FORG0006: ${e}`),b=class{constructor(e,t){this.done=e,this.value=t}},A=new b(!0);function E(e){return new b(!1,e)}function N(e,t){if(3===t.C)return!!t.Ca.find((t=>N(e,t)));for(;e;){if(e.type===t.type)return!0;if(3===e.C)return!!e.Ca.find((e=>T(e.type,t.type)));e=e.parent}return!1}function T(e,t){return e===t||N(g[e],g[t])}var B=class{constructor(){this.value={next:()=>A}}gb(){return this}filter(){return this}first(){return null}O(){return[]}fa(){return!1}Pa(){return 0}G(){return!0}ua(){return!1}map(){return this}N(e){return e([])}Y(e){return e.empty?e.empty(this):e.default(this)}},I=class{constructor(e,t){this.type=e,this.value=t}};const C={0:"xs:boolean",1:"xs:string",2:"xs:numeric",3:"xs:double",4:"xs:decimal",5:"xs:integer",6:"xs:float",7:"xs:date",8:"xs:time",9:"xs:dateTime",10:"xs:dateTimeStamp",11:"xs:gYearMonth",12:"xs:gYear",13:"xs:gMonthDay",14:"xs:gMonth",15:"xs:gDay",16:"xs:yearMonthDuration",17:"xs:dayTimeDuration",18:"xs:duration",19:"xs:untypedAtomic",20:"xs:anyURI",21:"xs:base64Binary",22:"xs:hexBinary",23:"xs:QName",24:"xs:NCName",25:"xs:Name",26:"xs:ENTITY",27:"xs:nonPositiveInteger",28:"xs:negativeInteger",29:"xs:positiveInteger",30:"xs:nonNegativeInteger",31:"xs:long",32:"xs:int",33:"xs:short",34:"xs:byte",35:"xs:unsignedInt",36:"xs:unsignedLong",37:"xs:unsignedByte",38:"xs:unsignedShort",39:"xs:error",40:"xs:ENTITIES",41:"xs:IDREF",42:"xs:ID",43:"xs:IDREFS",44:"xs:NOTATION",45:"xs:anySimpleType",46:"xs:anyAtomicType",47:"attribute()",48:"xs:normalizedString",49:"xs:NMTOKENS",50:"xs:NMTOKEN",51:"xs:language",52:"xs:token",53:"node()",54:"element()",55:"document-node()",56:"text()",57:"processing-instruction()",58:"comment()",59:"item()",60:"function(*)",61:"map(*)",62:"array(*)",63:"none"},S={"xs:boolean":0,"xs:string":1,"xs:numeric":2,"xs:double":3,"xs:decimal":4,"xs:integer":5,"xs:float":6,"xs:date":7,"xs:time":8,"xs:dateTime":9,"xs:dateTimeStamp":10,"xs:gYearMonth":11,"xs:gYear":12,"xs:gMonthDay":13,"xs:gMonth":14,"xs:gDay":15,"xs:yearMonthDuration":16,"xs:dayTimeDuration":17,"xs:duration":18,"xs:untypedAtomic":19,"xs:anyURI":20,"xs:base64Binary":21,"xs:hexBinary":22,"xs:QName":23,"xs:NCName":24,"xs:Name":25,"xs:ENTITY":26,"xs:nonPositiveInteger":27,"xs:negativeInteger":28,"xs:positiveInteger":29,"xs:nonNegativeInteger":30,"xs:long":31,"xs:int":32,"xs:short":33,"xs:byte":34,"xs:unsignedInt":35,"xs:unsignedLong":36,"xs:unsignedByte":37,"xs:unsignedShort":38,"xs:error":39,"xs:ENTITIES":40,"xs:IDREF":41,"xs:ID":42,"xs:IDREFS":43,"xs:NOTATION":44,"xs:anySimpleType":45,"xs:anyAtomicType":46,"attribute()":47,"xs:normalizedString":48,"xs:NMTOKENS":49,"xs:NMTOKEN":50,"xs:language":51,"xs:token":52,"node()":53,"element()":54,"document-node()":55,"text()":56,"processing-instruction()":57,"comment()":58,"item()":59,"function(*)":60,"map(*)":61,"array(*)":62};function O(e){return 2===e.g?C[e.type]+"*":1===e.g?C[e.type]+"+":0===e.g?C[e.type]+"?":C[e.type]}function F(e){if("none"===e)throw Error('XPST0051: The type "none" could not be found');if(!e.startsWith("xs:")&&0<=e.indexOf(":"))throw Error(`XPST0081: Invalid prefix for input ${e}`);const t=S[e];if(void 0===t)throw Error(`XPST0051: The type "${e}" could not be found`);return t}function D(e){switch(e[e.length-1]){case"*":return{type:F(e.substr(0,e.length-1)),g:2};case"?":return{type:F(e.substr(0,e.length-1)),g:0};case"+":return{type:F(e.substr(0,e.length-1)),g:1};default:return{type:F(e),g:3}}}function k(e){const t=e.value;if(T(e.type,53))return!0;if(T(e.type,0))return t;if(T(e.type,1)||T(e.type,20)||T(e.type,19))return 0!==t.length;if(T(e.type,2))return!isNaN(t)&&0!==t;throw x(`Cannot determine the effective boolean value of a value with the type ${C[e.type]}`)}function R(e,t=0){e.h=t}var M=class{constructor(e){this.v=$,this.h=e;let t=!1;this.value={next:()=>t?A:(t=!0,E(e))},this.o=null}gb(){return this}filter(e){return e(this.h,0,this)?this:this.v.create()}first(){return this.h}O(){return[this.h]}fa(){return null===this.o&&(this.o=k(this.h)),this.o}Pa(){return 1}G(){return!1}ua(){return!0}map(e){return this.v.create(e(this.h,0,this))}N(e){return e([this.h])}Y(e){return e.m?e.m(this):e.default(this)}};const U=new B;function G(e=null,t=null){if(null===e)return U;if(Array.isArray(e))switch(e.length){case 0:return U;case 1:return new M(e[0]);default:return new class{constructor(e){this.o=$,this.h=e;let t=-1;this.value={next:()=>(t++,t>=e.length?A:E(e[t]))}}gb(){return this}filter(e){let t=-1;return this.o.create({next:()=>{for(t++;t<this.h.length&&!e(this.h[t],t,this);)t++;return t>=this.h.length?A:E(this.h[t])}})}first(){return this.h[0]}O(){return this.h}fa(){if(T(this.h[0].type,53))return!0;throw x("Cannot determine the effective boolean value of a sequence with a length higher than one.")}Pa(){return this.h.length}G(){return!1}ua(){return!1}map(e){let t=-1;return this.o.create({next:()=>++t>=this.h.length?A:E(e(this.h[t],t,this))},this.h.length)}N(e){return e(this.h)}Y(e){return e.multiple?e.multiple(this):e.default(this)}}(e)}return e.next?new class{constructor(e,t=null){this.D=$,this.value={next:t=>null!==this.o&&this.h>=this.o?A:void 0!==this.v[this.h]?E(this.v[this.h++]):(t=e.next(t)).done?(this.o=this.h,t):((this.l||2>this.h)&&(this.v[this.h]=t.value),this.h++,t)},this.l=!1,this.v=[],this.h=0,this.o=t}gb(){return this.D.create(this.O())}filter(e){let t=-1;const n=this.value;return this.D.create({next:r=>{for(t++,r=n.next(r);!r.done&&!e(r.value,t,this);)t++,r=n.next(0);return r}})}first(){if(void 0!==this.v[0])return this.v[0];const e=this.value.next(0);return R(this),e.done?null:e.value}O(){if(this.h>this.v.length&&this.o!==this.v.length)throw Error("Implementation error: Sequence Iterator has progressed.");const e=this.value;this.l=!0;let t=e.next(0);for(;!t.done;)t=e.next(0);return this.v}fa(){const e=this.value,t=this.h;R(this);var n=e.next(0);if(n.done)return R(this,t),!1;if(T((n=n.value).type,53))return R(this,t),!0;if(!e.next(0).done)throw x("Cannot determine the effective boolean value of a sequence with a length higher than one.");return R(this,t),k(n)}Pa(e=!1){if(null!==this.o)return this.o;if(e)return-1;e=this.h;const t=this.O().length;return R(this,e),t}G(){return 0===this.o||null===this.first()}ua(){if(null!==this.o)return 1===this.o;var e=this.value;const t=this.h;return R(this),e.next(0).done?(R(this,t),!1):(e=e.next(0),R(this,t),e.done)}map(e){let t=0;const n=this.value;return this.D.create({next:r=>(r=n.next(r)).done?A:E(e(r.value,t++,this))},this.o)}N(e,t){const n=this.value;let r;const a=[];let o=!0;return function(){for(let e=n.next(o?0:t);!e.done;e=n.next(t))o=!1,a.push(e.value);r=e(a).value}(),this.D.create({next:()=>r.next(0)})}Y(e){let t=null;const n=e=>{t=e.value,-1!==(e=e.Pa(!0))&&(this.o=e)};return this.D.create({next:r=>t?t.next(r):this.G()?(n(e.empty?e.empty(this):e.default(this)),t.next(r)):this.ua()?(n(e.m?e.m(this):e.default(this)),t.next(r)):(n(e.multiple?e.multiple(this):e.default(this)),t.next(r))})}}(e,t):new M(e)}var $={create:G,m:e=>new M(e),empty:()=>G(),aa:()=>G(w),V:()=>G(v)};function L(e){const t=[],n=e.value;return()=>{let e=0;return $.create({next:()=>{if(void 0!==t[e])return t[e++];const r=n.next(0);return r.done?r:t[e++]=r}})}}var H=class{constructor(e,t,n){this.namespaceURI=t||null,this.prefix=e||"",this.localName=n}za(){return this.prefix?this.prefix+":"+this.localName:this.localName}};var P=class extends I{constructor({j:e,arity:t,Xa:n=!1,J:r=!1,localName:a,namespaceURI:o,i:s,value:i}){for(super(60,null),this.value=i,this.J=r,r=-1,i=0;i<e.length;i++)4===e[i]&&(r=i);-1<r&&(i=Array(t-(e.length-1)).fill(e[r-1]),e=e.slice(0,r).concat(i)),this.o=e,this.v=t,this.ia=n,this.D=a,this.l=o,this.s=s}Xa(){return this.ia}};function j(e,t){const n=[];return 2!==e&&1!==e||n.push("type-1-or-type-2"),n.push(`type-${e}`),t&&n.push(`name-${t}`),n}function _(e){const t=e.node.nodeType;let n;return 2!==t&&1!==t||(n=e.node.localName),j(t,n)}function X(e){let t,n=e.nodeType;return 4===n&&(n=3),2!==n&&1!==n||(t=e.localName),j(n,t)}var q=class{getAllAttributes(e,t=null){return 1!==e.nodeType?[]:(e=Array.from(e.attributes),null===t?e:e.filter((e=>X(e).includes(t))))}getAttribute(e,t){return 1!==e.nodeType?null:e.getAttribute(t)}getChildNodes(e,t=null){return e=Array.from(e.childNodes),null===t?e:e.filter((e=>X(e).includes(t)))}getData(e){return 2===e.nodeType?e.value:e.data}getFirstChild(e,t=null){for(e=e.firstChild;e;e=e.nextSibling)if(null===t||X(e).includes(t))return e;return null}getLastChild(e,t=null){for(e=e.lastChild;e;e=e.previousSibling)if(null===t||X(e).includes(t))return e;return null}getNextSibling(e,t=null){for(e=e.nextSibling;e;e=e.nextSibling)if(null===t||X(e).includes(t))return e;return null}getParentNode(e,t=null){return(e=2===e.nodeType?e.ownerElement:e.parentNode)&&(null===t||X(e).includes(t))?e:null}getPreviousSibling(e,t=null){for(e=e.previousSibling;e;e=e.previousSibling)if(null===t||X(e).includes(t))return e;return null}};var V=new class{insertBefore(e,t,n){return e.insertBefore(t,n)}removeAttributeNS(e,t,n){return e.removeAttributeNS(t,n)}removeChild(e,t){return e.removeChild(t)}setAttributeNS(e,t,n,r){e.setAttributeNS(t,n,r)}setData(e,t){e.data=t}};class Y{constructor(e){this.h=e}insertBefore(e,t,n){return this.h.insertBefore(e,t,n)}removeAttributeNS(e,t,n){return this.h.removeAttributeNS(e,t,n)}removeChild(e,t){return this.h.removeChild(e,t)}setAttributeNS(e,t,n,r){this.h.setAttributeNS(e,t,n,r)}setData(e,t){this.h.setData(e,t)}}function z(e){return void 0!==e.Ra}function J(e,t,n){let r=null;return t&&(z(t.node)?r={F:t.F,offset:n,parent:t.node}:t.F&&(r=t.F)),{node:e,F:r}}function Q(e,t,n=null){return e.getAllAttributes(t.node,n).map((e=>J(e,t,e.nodeName)))}function K(e,t,n){return z(t=t.node)?(e=t.attributes.find((e=>n===e.name)))?e.value:null:(e=e.h.getAttribute(t,n))?e:null}function W(e,t,n=null){return e.getChildNodes(t.node,n).map(((e,n)=>J(e,t,n)))}function Z(e,t){return e.getData(t.node)}function ee(e,t,n=null){const r=t.node;return z(r)?e=r.childNodes[0]:((n=e.h.getFirstChild(r,n))&&10===n.nodeType&&(n=e.h.getNextSibling(n)),e=n),e?J(e,t,0):null}function te(e,t,n=null){var r=t.node;return z(r)?(e=r.childNodes.length-1,r=r.childNodes[e]):((r=e.h.getLastChild(r,n))&&10===r.nodeType&&(r=e.h.getPreviousSibling(r)),e=e.getChildNodes(t.node,n).length-1),r?J(r,t,e):null}function ne(e,t,n=null){const r=t.node,a=t.F;if(a)"number"==typeof a.offset&&r===a.parent.childNodes[a.offset]||"string"==typeof a.offset&&r===a.parent.attributes.find((e=>a.offset===e.nodeName))?(e=a.parent,t=a.F):(e=e.getParentNode(r,n),t=a);else{if(z(r))return null;e=e.getParentNode(r,n),t=null}return e?{node:e,F:t}:null}function re(e,t,n=null){const r=t.node;let a,o,s;const i=t.F;if(z(r))i&&(s=i.offset+1,a=i.parent.childNodes[s]);else{if(!i){for(a=r;a&&(!(a=e.h.getNextSibling(a,n))||10===a.nodeType););return a?{node:a,F:null}:null}s=i.offset+1,o=ne(e,t,null),a=e.getChildNodes(o.node,n)[s]}return a?J(a,o||ne(e,t,n),s):null}function ae(e,t,n=null){const r=t.node;let a,o;const s=t.F;let i;if(z(r))s&&(i=s.offset-1,a=s.parent.childNodes[i]);else{if(!s){for(a=r;a&&(!(a=e.h.getPreviousSibling(a,n))||10===a.nodeType););return a?{node:a,F:null}:null}i=s.offset-1,o=ne(e,t,null),a=e.getChildNodes(o.node,n)[i]}return a?J(a,o||ne(e,t,n),i):null}var oe=class{constructor(e){this.h=e,this.o=[]}getAllAttributes(e,t=null){return z(e)?e.attributes:this.h.getAllAttributes(e,t)}getChildNodes(e,t=null){return t=z(e)?e.childNodes:this.h.getChildNodes(e,t),9===e.nodeType?t.filter((e=>10!==e.nodeType)):t}getData(e){return z(e)?2===e.nodeType?e.value:e.data:this.h.getData(e)||""}getParentNode(e,t=null){return this.h.getParentNode(e,t)}},se=(e,t,n,r,a)=>a.N((([e])=>r.N((([t])=>{const n=e.value;if(0>=n||n>t.h.length)throw Error("FOAY0001: array position out of bounds.");return t.h[n-1]()})))),ie=class extends P{constructor(e){super({value:(e,t,n,r)=>se(0,0,0,$.m(this),r),localName:"get",namespaceURI:"http://www.w3.org/2005/xpath-functions/array",j:[{type:5,g:3}],arity:1,i:{type:59,g:2}}),this.type=62,this.h=e}};function le(e){switch(e.node.nodeType){case 2:return 47;case 1:return 54;case 3:case 4:return 56;case 7:return 57;case 8:return 58;case 9:return 55;default:return 53}}function ce(e){return{type:le(e),value:e}}function ue(e,t){return e=e.map((e=>e.first())),t(e)}function pe(e,t){var n=T(e.type,1)||T(e.type,20)||T(e.type,19),r=T(t.type,1)||T(t.type,20)||T(t.type,19);return n&&r?e.value===t.value:(n=T(e.type,4)||T(e.type,3)||T(e.type,6),r=T(t.type,4)||T(t.type,3)||T(t.type,6),n&&r?!(!isNaN(e.value)||!isNaN(t.value))||e.value===t.value:(n=T(e.type,0)||T(e.type,22)||T(e.type,18)||T(e.type,23)||T(e.type,44),r=T(t.type,0)||T(t.type,22)||T(t.type,18)||T(t.type,23)||T(t.type,44),!(!n||!r)&&e.value===t.value))}var he=(e,t,n,r,a)=>ue([r,a],(([e,t])=>(e=e.h.find((e=>pe(e.key,t))))?e.value():$.empty())),de=class extends P{constructor(e){super({j:[{type:59,g:3}],arity:1,localName:"get",namespaceURI:"http://www.w3.org/2005/xpath-functions/map",value:(e,t,n,r)=>he(0,0,0,$.m(this),r),i:{type:59,g:2}}),this.type=61,this.h=e}};function me(e,t){return e.h()===t.h()&&e.o()===t.o()}var fe=class{Za(){return 0}getHours(){return 0}getMinutes(){return 0}$a(){return 0}h(){return 0}o(){return 0}getSeconds(){return 0}ab(){return 0}na(){return!0}};function ge(e){var t=Math.abs(e.Za()),n=Math.abs(e.getHours());const r=Math.abs(e.getMinutes());return n=(n?`${n}H`:"")+(r?`${r}M`:"")+((e=Math.abs(e.getSeconds()))?`${e}S`:""),(t=""+(t?`${t}D`:""))&&n?`${t}T${n}`:t||(n?`T${n}`:"T0S")}var ye=class extends fe{constructor(e){if(super(),e>Number.MAX_SAFE_INTEGER||e<Number.MIN_SAFE_INTEGER)throw Error("FODT0002: Number of seconds given to construct DayTimeDuration overflows MAX_SAFE_INTEGER or MIN_SAFE_INTEGER");this.ca=e}Za(){return Math.trunc(this.ca/86400)}getHours(){return Math.trunc(this.ca%86400/3600)}getMinutes(){return Math.trunc(this.ca%3600/60)}o(){return this.ca}getSeconds(){const e=this.ca%60;return Object.is(-0,e)?0:e}na(){return!Object.is(-0,this.ca)&&0<=this.ca}toString(){return(this.na()?"P":"-P")+ge(this)}},we=(e,t,n,r,a,o)=>(e=86400*e+3600*t+60*n+r+a,new ye(o||0===e?e:-e)),ve=e=>(e=/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(?:T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.exec(e))?we(e[4]?parseInt(e[4],10):0,e[5]?parseInt(e[5],10):0,e[6]?parseInt(e[6],10):0,e[7]?parseInt(e[7],10):0,e[8]?parseFloat(e[8]):0,!e[1]):null,xe=e=>"Z"===(e=/^(Z)|([+-])([01]\d):([0-5]\d)$/.exec(e))[1]?we(0,0,0,0,0,!0):we(0,e[3]?parseInt(e[3],10):0,e[4]?parseInt(e[4],10):0,0,0,"+"===e[2]);function be(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot multiply xs:dayTimeDuration by NaN");if((e=e.ca*t)>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while multiplying xs:dayTimeDuration");return new ye(e<Number.MIN_SAFE_INTEGER||Object.is(-0,e)?0:e)}function Ae(e){return e?parseInt(e,10):null}function Ee(e){const t=(e+="").startsWith("-");return t&&(e=e.substring(1)),(t?"-":"")+e.padStart(4,"0")}function Ne(e){return(e+"").padStart(2,"0")}function Te(e){return 1===(e+="").split(".")[0].length&&(e=e.padStart(e.length+1,"0")),e}function Be(e){return 0===e.getHours()&&0===e.getMinutes()?"Z":(e.na()?"+":"-")+Ne(Math.abs(e.getHours()))+":"+Ne(Math.abs(e.getMinutes()))}function Ie(e){var t=/^(?:(-?\d{4,}))?(?:--?(\d\d))?(?:-{1,3}(\d\d))?(T)?(?:(\d\d):(\d\d):(\d\d))?(\.\d+)?(Z|(?:[+-]\d\d:\d\d))?$/.exec(e);e=t[1]?parseInt(t[1],10):null;const n=Ae(t[2]),r=Ae(t[3]),a=t[4],o=Ae(t[5]),s=Ae(t[6]),i=Ae(t[7]),l=t[8]?parseFloat(t[8]):0;if(t=t[9]?xe(t[9]):null,e&&(-271821>e||273860<e))throw Error("FODT0001: Datetime year is out of bounds");return a?new Oe(e,n,r,o,s,i,l,t,9):null!==o&&null!==s&&null!==i?new Oe(1972,12,31,o,s,i,l,t,8):null!==e&&null!==n&&null!==r?new Oe(e,n,r,0,0,0,0,t,7):null!==e&&null!==n?new Oe(e,n,1,0,0,0,0,t,11):null!==n&&null!==r?new Oe(1972,n,r,0,0,0,0,t,13):null!==e?new Oe(e,1,1,0,0,0,0,t,12):null!==n?new Oe(1972,n,1,0,0,0,0,t,14):new Oe(1972,12,r,0,0,0,0,t,15)}function Ce(e,t){switch(t){case 15:return new Oe(1972,12,e.o,0,0,0,0,e.X,15);case 14:return new Oe(1972,e.h,1,0,0,0,0,e.X,14);case 12:return new Oe(e.v,1,1,0,0,0,0,e.X,12);case 13:return new Oe(1972,e.h,e.o,0,0,0,0,e.X,13);case 11:return new Oe(e.v,e.h,1,0,0,0,0,e.X,11);case 8:return new Oe(1972,12,31,e.l,e.s,e.D,e.pa,e.X,8);case 7:return new Oe(e.v,e.h,e.o,0,0,0,0,e.X,7);default:return new Oe(e.v,e.h,e.o,e.l,e.s,e.D,e.pa,e.X,9)}}function Se(e,t){return t=e.X||t||xe("Z"),new Date(Date.UTC(e.v,e.h-1,e.o,e.l-t.getHours(),e.s-t.getMinutes(),e.D,1e3*e.pa))}var Oe=class{constructor(e,t,n,r,a,o,s,i,l=9){this.v=e,this.h=t,this.o=n+(24===r?1:0),this.l=24===r?0:r,this.s=a,this.D=o,this.pa=s,this.X=i,this.type=l}getDay(){return this.o}getHours(){return this.l}getMinutes(){return this.s}getMonth(){return this.h}getSeconds(){return this.D}getYear(){return this.v}toString(){switch(this.type){case 9:return Ee(this.v)+"-"+Ne(this.h)+"-"+Ne(this.o)+"T"+Ne(this.l)+":"+Ne(this.s)+":"+Te(this.D+this.pa)+(this.X?Be(this.X):"");case 7:return Ee(this.v)+"-"+Ne(this.h)+"-"+Ne(this.o)+(this.X?Be(this.X):"");case 8:return Ne(this.l)+":"+Ne(this.s)+":"+Te(this.D+this.pa)+(this.X?Be(this.X):"");case 15:return"---"+Ne(this.o)+(this.X?Be(this.X):"");case 14:return"--"+Ne(this.h)+(this.X?Be(this.X):"");case 13:return"--"+Ne(this.h)+"-"+Ne(this.o)+(this.X?Be(this.X):"");case 12:return Ee(this.v)+(this.X?Be(this.X):"");case 11:return Ee(this.v)+"-"+Ne(this.h)+(this.X?Be(this.X):"")}throw Error("Unexpected subType")}};function Fe(e,t,n){const r=Se(e,n).getTime();return r===(n=Se(t,n).getTime())?e.pa===t.pa?0:e.pa>t.pa?1:-1:r>n?1:-1}function De(e,t,n){return 0===Fe(e,t,n)}function ke(e,t,n){return e=(Se(e,n).getTime()-Se(t,n).getTime())/1e3,new ye(e)}function Re(e){throw Error(`Not implemented: adding durations to ${C[e.type]}`)}function Me(e){throw Error(`Not implemented: subtracting durations from ${C[e.type]}`)}function Ue(e,t){if(null===e)return null;switch(typeof e){case"boolean":return e?w:v;case"number":return y(e,3);case"string":return y(e,1);case"object":if("nodeType"in e)return ce({node:e,F:null});if(Array.isArray(e))return new ie(e.map((e=>void 0===e?()=>$.empty():L(e=null===(e=Ue(e))?$.empty():$.m(e)))));if(e instanceof Date){const t=Ie(e.toISOString());return y(t,t.type)}return new de(Object.keys(e).filter((t=>void 0!==e[t])).map((t=>{var n=Ue(e[t]);return n=null===n?$.empty():$.m(n),{key:y(t,1),value:L(n)}})))}throw Error(`Value ${String(e)} of type "${typeof e}" is not adaptable to an XPath value.`)}function Ge(e,t){if("number"!=typeof e&&("string"!=typeof e||!f.get(t)(e)))throw Error(`Cannot convert JavaScript value '${e}' to the XPath type ${C[t]} since it is not valid.`)}function $e(e,t,n){if(null===t)return null;switch(e){case 0:return t?w:v;case 1:return y(t+"",1);case 3:case 2:return Ge(t,3),y(+t,3);case 4:return Ge(t,e),y(+t,4);case 5:return Ge(t,e),y(0|t,5);case 6:return Ge(t,e),y(+t,6);case 7:case 8:case 9:case 11:case 12:case 13:case 14:case 15:if(!(t instanceof Date))throw Error(`The JavaScript value ${t} with type ${typeof t} is not a valid type to be converted to an XPath ${C[e]}.`);return y(Ce(Ie(t.toISOString()),e),e);case 53:case 47:case 55:case 54:case 56:case 57:case 58:if("object"!=typeof t||!("nodeType"in t))throw Error(`The JavaScript value ${t} with type ${typeof t} is not a valid type to be converted to an XPath ${C[e]}.`);return ce({node:t,F:null});case 59:case 61:return Ue(t);default:throw Error(`Values of the type "${C[e]}" can not be adapted from JavaScript to equivalent XPath values.`)}}function Le(e,t,n){if(0===n.g)return null===(t=$e(n.type,t))?[]:[t];if(2===n.g||1===n.g){if(!Array.isArray(t))throw Error(`The JavaScript value ${t} should be an array if it is to be converted to ${O(n)}.`);return t.map((e=>$e(n.type,e))).filter((e=>null!==e))}const r=$e(n.type,t);if(null===r)throw Error(`The JavaScript value ${t} should be a single entry if it is to be converted to ${O(n)}.`);return[r]}function He(e,t,n={type:59,g:0}){return $.create(Le(0,t,n))}var Pe=2**32;function je(e,t,n,r){return new ze({M:n,Aa:t,sa:r||e.sa,qa:e.qa},e.h,e.o)}function _e(e,t){let n=0;const r=t.value;return{next:a=>(a=r.next(a)).done?A:E(je(e,n++,a.value,t))}}function Xe(e){return e.h.hb||(e.h.hb=!0,e.h.ob=Ie((new Date).toISOString()),e.h.tb=ve("PT0S")),e.h.ob}function qe(e){return e.h.hb||(e.h.hb=!0,e.h.ob=Ie((new Date).toISOString()),e.h.tb=ve("PT0S")),e.h.tb}function Ve(e,t=null){return e=29421*(null!=t?t:e.o.h)%Pe,{pb:Math.floor(e),Yb:e/Pe}}function Ye(e,t){return new ze({M:e.M,Aa:e.Aa,sa:e.sa,qa:Object.assign(Object.create(null),e.qa,t)},e.h,e.o)}var ze=class{constructor(e,t={ob:null,tb:null,hb:!1},n=new class{constructor(){this.h=Math.abs(Math.floor(Math.random()*Pe)%Pe)}}){this.h=t,this.Aa=e.Aa,this.sa=e.sa,this.M=e.M,this.qa=e.qa||Object.create(null),this.o=n}},Je=class{constructor(e,t,n,r,a,o,s,i,l){this.debug=e,this.Ga=t,this.h=n,this.Ia=r,this.Ma=a,this.o=o,this.v=s,this.ib=i,this.Ua=l}};function Qe(e){let t=0,n=null,r=!0;return $.create({next:a=>{for(;t<e.length;){n||(n=e[t].value,r=!0);const o=n.next(r?0:a);if(r=!1,!o.done)return o;t++,n=null}return A}})}var Ke=(e,t,n)=>Error(`FORG0001: Cannot cast ${e} to ${C[t]}${n?`, ${n}`:""}`),We=e=>Error(`XPDY0002: ${e}`),Ze=e=>Error(`XPTY0004: ${e}`),et=e=>Error(`FOTY0013: Atomization is not supported for ${C[e]}.`),tt=e=>Error(`XPST0081: The prefix ${e} could not be resolved.`);function nt(e,t){if(T(e.type,46)||T(e.type,19)||T(e.type,0)||T(e.type,4)||T(e.type,3)||T(e.type,6)||T(e.type,5)||T(e.type,2)||T(e.type,23)||T(e.type,1))return $.create(e);const n=t.h;if(T(e.type,53)){const t=e.value;if(2===t.node.nodeType||3===t.node.nodeType)return $.create(y(Z(n,t),19));if(8===t.node.nodeType||7===t.node.nodeType)return $.create(y(Z(n,t),1));const r=[];return function e(a){if(8!==t.node.nodeType&&7!==t.node.nodeType){var o=a.nodeType;3===o||4===o?r.push(n.getData(a)):1!==o&&9!==o||n.getChildNodes(a).forEach((t=>{e(t)}))}}(t.node),$.create(y(r.join(""),19))}if(T(e.type,60)&&!T(e.type,62))throw et(e.type);if(T(e.type,62))return Qe(e.h.map((e=>rt(e(),t))));throw Error(`Atomizing ${e.type} is not implemented.`)}function rt(e,t){let n=!1;const r=e.value;let a=null;return $.create({next:()=>{for(;!n;){if(!a){var e=r.next(0);if(e.done){n=!0;break}a=nt(e.value,t).value}if(!(e=a.next(0)).done)return e;a=null}return A}})}function at(e){for(e=g[e];e&&0!==e.C;)e=e.parent;return e?e.type:null}function ot(e,t){const n=(t=g[t]).Ja;if(!n||!n.whiteSpace)return t.parent?ot(e,t.parent.type):e;switch(t.Ja.whiteSpace){case"replace":return e.replace(/[\u0009\u000A\u000D]/g," ");case"collapse":return e.replace(/[\u0009\u000A\u000D]/g," ").replace(/ {2,}/g," ").replace(/^ | $/g,"")}return e}function st(e,t){for(t=g[t];t&&null===t.fb;){if(2===t.C||3===t.C)return!0;t=t.parent}return!t||t.fb(e)}function it(e,t){for(;e;){if(e.Oa&&e.Oa[t])return e.Oa[t];e=e.parent}return()=>!0}function lt(e){return!e||(2===e.g||0===e.g)}function ct(e,t){return e(2)?e=>({u:!0,value:e}):e(0)?e=>({u:!0,value:e?1:0}):e(1)||e(19)?e=>{switch(e){case"NaN":return{u:!0,value:NaN};case"INF":case"+INF":return{u:!0,value:1/0};case"-INF":return{u:!0,value:-1/0};case"0":case"+0":return{u:!0,value:0};case"-0":return{u:!0,value:-0}}const n=parseFloat(e);return isNaN(n)?{u:!1,error:Ke(e,t)}:{u:!0,value:n}}:()=>({u:!1,error:Error(`XPTY0004: Casting not supported from given type to ${t} or any of its derived types.`)})}function ut(e){const t=Math.abs(e.ab());return(t?`${t}Y`:"")+(""+((e=Math.abs(e.$a()))?`${e}M`:""))||"0M"}var pt=class extends fe{constructor(e){if(super(),e>Number.MAX_SAFE_INTEGER||e<Number.MIN_SAFE_INTEGER)throw Error("FODT0002: Number of months given to construct YearMonthDuration overflows MAX_SAFE_INTEGER or MIN_SAFE_INTEGER");this.ea=e}$a(){const e=this.ea%12;return 0===e?0:e}h(){return this.ea}ab(){return Math.trunc(this.ea/12)}na(){return!Object.is(-0,this.ea)&&0<=this.ea}toString(){return(this.na()?"P":"-P")+ut(this)}},ht=e=>{var t=/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(?:T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.exec(e);if(t){if(e=!t[1],(t=12*(t[2]?parseInt(t[2],10):0)+(t[3]?parseInt(t[3],10):0))>Number.MAX_SAFE_INTEGER||!Number.isFinite(t))throw Error("FODT0002: Value overflow while constructing xs:yearMonthDuration");e=new pt(e||0===t?t:-t)}else e=null;return e};function dt(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot multiply xs:yearMonthDuration by NaN");if((e=Math.round(e.ea*t))>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while constructing xs:yearMonthDuration");return new pt(e<Number.MIN_SAFE_INTEGER||0===e?0:e)}var mt=class extends fe{constructor(e,t){super(),this.Va=e,this.Fa=t}Za(){return this.Fa.Za()}getHours(){return this.Fa.getHours()}getMinutes(){return this.Fa.getMinutes()}$a(){return this.Va.$a()}h(){return this.Va.h()}o(){return this.Fa.o()}getSeconds(){return this.Fa.getSeconds()}ab(){return this.Va.ab()}na(){return this.Va.na()&&this.Fa.na()}toString(){const e=this.na()?"P":"-P",t=ut(this.Va),n=ge(this.Fa);return"0M"===t?e+n:"T0S"===n?e+t:e+t+n}};const ft=[3,6,4,5];function gt(e){if(e(1)||e(19))return e=>({u:!0,value:e+""});if(e(20))return e=>({u:!0,value:e});if(e(23))return e=>({u:!0,value:e.prefix?`${e.prefix}:${e.localName}`:e.localName});if(e(44))return e=>({u:!0,value:e.toString()});if(e(2)){if(e(5)||e(4))return e=>({u:!0,value:(e+"").replace("e","E")});if(e(6)||e(3))return e=>isNaN(e)?{u:!0,value:"NaN"}:isFinite(e)?Object.is(e,-0)?{u:!0,value:"-0"}:{u:!0,value:(e+"").replace("e","E").replace("E+","E")}:{u:!0,value:(0>e?"-":"")+"INF"}}return e(9)||e(7)||e(8)||e(15)||e(14)||e(13)||e(12)||e(11)||e(16)||e(17)||e(18)?e=>({u:!0,value:e.toString()}):e(22)?e=>({u:!0,value:e.toUpperCase()}):e=>({u:!0,value:e+""})}const yt=[2,5,17,16];function wt(e,t){const n=t=>T(e,t);if(39===t)return()=>({u:!1,error:Error("FORG0001: Casting to xs:error is always invalid.")});switch(t){case 19:return function(e){const t=gt(e);return e=>(e=t(e)).u?{u:!0,value:y(e.value,19)}:e}(n);case 1:return function(e){const t=gt(e);return e=>(e=t(e)).u?{u:!0,value:y(e.value,1)}:e}(n);case 6:return function(e){const t=ct(e,6);return e=>(e=t(e)).u?{u:!0,value:y(e.value,6)}:e}(n);case 3:return function(e){const t=ct(e,3);return e=>(e=t(e)).u?{u:!0,value:y(e.value,3)}:e}(n);case 4:return function(e){return e(5)?e=>({u:!0,value:y(e,4)}):e(6)||e(3)?e=>isNaN(e)||!isFinite(e)?{u:!1,error:Error(`FOCA0002: Can not cast ${e} to xs:decimal`)}:Math.abs(e)>Number.MAX_VALUE?{u:!1,error:Error(`FOAR0002: Can not cast ${e} to xs:decimal, it is out of bounds for JavaScript numbers`)}:{u:!0,value:y(e,4)}:e(0)?e=>({u:!0,value:y(e?1:0,4)}):e(1)||e(19)?e=>{const t=parseFloat(e);return!isNaN(t)||isFinite(t)?{u:!0,value:y(t,4)}:{u:!1,error:Error(`FORG0001: Can not cast ${e} to xs:decimal`)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:decimal or any of its derived types.")})}(n);case 5:return function(e){return e(0)?e=>({u:!0,value:y(e?1:0,5)}):e(2)?e=>{const t=Math.trunc(e);return!isFinite(t)||isNaN(t)?{u:!1,error:Error(`FOCA0002: can not cast ${e} to xs:integer`)}:Number.isSafeInteger(t)?{u:!0,value:y(t,5)}:{u:!1,error:Error(`FOAR0002: can not cast ${e} to xs:integer, it is out of bounds for JavaScript numbers.`)}}:e(1)||e(19)?e=>{const t=parseInt(e,10);return isNaN(t)?{u:!1,error:Ke(e,5)}:Number.isSafeInteger(t)?{u:!0,value:y(t,5)}:{u:!1,error:Error(`FOCA0003: can not cast ${e} to xs:integer, it is out of bounds for JavaScript numbers.`)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:integer or any of its derived types.")})}(n);case 2:return function(e){var t=wt;return n=>{for(const r of ft){const a=t(e,r)(n);if(a.u)return a}return{u:!1,error:Error(`XPTY0004: Casting not supported from "${n}" given type to xs:numeric or any of its derived types.`)}}}(e);case 18:return function(e){return e(16)?e=>({u:!0,value:y(new mt(e,new ye(e.na()?0:-0)),18)}):e(17)?e=>({u:!0,value:y(e=new mt(new pt(e.na()?0:-0),e),18)}):e(18)?e=>({u:!0,value:y(e,18)}):e(19)||e(1)?e=>({u:!0,value:y(new mt(ht(e),ve(e)),18)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:duration or any of its derived types.")})}(n);case 16:return function(e){return e(18)&&!e(17)?e=>({u:!0,value:y(e.Va,16)}):e(17)?()=>({u:!0,value:y(ht("P0M"),16)}):e(19)||e(1)?e=>{const t=ht(e);return t?{u:!0,value:y(t,16)}:{u:!1,error:Ke(e,16)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:yearMonthDuration or any of its derived types.")})}(n);case 17:return function(e){return e(18)&&!e(16)?e=>({u:!0,value:y(e.Fa,17)}):e(16)?()=>({u:!0,value:y(ve("PT0.0S"),17)}):e(19)||e(1)?e=>{const t=ve(e);return t?{u:!0,value:y(t,17)}:{u:!1,error:Error(`FORG0001: Can not cast ${e} to xs:dayTimeDuration`)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:dayTimeDuration or any of its derived types.")})}(n);case 9:return function(e){return e(7)?e=>({u:!0,value:y(Ce(e,9),9)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),9)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:dateTime or any of its derived types.")})}(n);case 8:return function(e){return e(9)?e=>({u:!0,value:y(Ce(e,8),8)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),8)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:time or any of its derived types.")})}(n);case 7:return function(e){return e(9)?e=>({u:!0,value:y(Ce(e,7),7)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),7)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:date or any of its derived types.")})}(n);case 11:return function(e){return e(7)||e(9)?e=>({u:!0,value:y(Ce(e,11),11)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),11)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gYearMonth or any of its derived types.")})}(n);case 12:return function(e){return e(7)||e(9)?e=>({u:!0,value:y(Ce(e,12),12)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),12)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gYear or any of its derived types.")})}(n);case 13:return function(e){return e(7)||e(9)?e=>({u:!0,value:y(Ce(e,13),13)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),13)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gMonthDay or any of its derived types.")})}(n);case 15:return function(e){return e(7)||e(9)?e=>({u:!0,value:y(Ce(e,15),15)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),15)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gDay or any of its derived types.")})}(n);case 14:return function(e){return e(7)||e(9)?e=>({u:!0,value:y(Ce(e,14),14)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),14)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gMonth or any of its derived types.")})}(n);case 0:return function(e){return e(2)?e=>({u:!0,value:0===e||isNaN(e)?v:w}):e(1)||e(19)?e=>{switch(e){case"true":case"1":return{u:!0,value:w};case"false":case"0":return{u:!0,value:v};default:return{u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:boolean or any of its derived types.")}}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:boolean or any of its derived types.")})}(n);case 21:return function(e){return e(22)?e=>{let t="";for(let n=0;n<e.length;n+=2)t+=String.fromCharCode(parseInt(e.substr(n,2),16));return{u:!0,value:y(btoa(t),21)}}:e(1)||e(19)?e=>({u:!0,value:y(e,21)}):()=>({error:Error("XPTY0004: Casting not supported from given type to xs:base64Binary or any of its derived types."),u:!1})}(n);case 22:return function(e){return e(21)?e=>{let t="";for(let n=0,r=(e=atob(e)).length;n<r;n++)t+=Number(e.charCodeAt(n)).toString(16);return{u:!0,value:y(t.toUpperCase(),22)}}:e(1)||e(19)?e=>({u:!0,value:y(e,22)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:hexBinary or any of its derived types.")})}(n);case 20:return function(e){return e(1)||e(19)?e=>({u:!0,value:y(e,20)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:anyURI or any of its derived types.")})}(n);case 23:throw Error("Casting to xs:QName is not implemented.")}return()=>({u:!1,error:Error(`XPTY0004: Casting not supported from ${e} to ${t}.`)})}const vt=Object.create(null);function xt(e,t){if(19===e&&1===t)return e=>({u:!0,value:y(e,1)});if(44===t)return()=>({u:!1,error:Error("XPST0080: Casting to xs:NOTATION is not permitted.")});if(39===t)return()=>({u:!1,error:Error("FORG0001: Casting to xs:error is not permitted.")});if(45===e||45===t)return()=>({u:!1,error:Error("XPST0080: Casting from or to xs:anySimpleType is not permitted.")});if(46===e||46===t)return()=>({u:!1,error:Error("XPST0080: Casting from or to xs:anyAtomicType is not permitted.")});if(T(e,60)&&1===t)return()=>({u:!1,error:Error("FOTY0014: Casting from function item to xs:string is not permitted.")});if(e===t)return e=>({u:!0,value:{type:t,value:e}});const n=yt.includes(e)?e:at(e),r=yt.includes(t)?t:at(t);if(null===r||null===n)return()=>({u:!1,error:Error(`XPST0081: Can not cast: type ${r?C[e]:C[t]} is unknown.`)});const a=[];return 1!==n&&19!==n||a.push((e=>{const n=ot(e,t);return st(n,t)?{u:!0,value:n}:{u:!1,error:Ke(e,t,"pattern validation failed.")}})),n!==r&&(a.push(wt(n,r)),a.push((e=>({u:!0,value:e.value})))),19!==r&&1!==r||a.push((e=>st(e,t)?{u:!0,value:e}:{u:!1,error:Ke(e,t,"pattern validation failed.")})),a.push((e=>function(e,t){let n=g[t];for(;n;){if(n.Ja&&!Object.keys(n.Ja).every((t=>{if("whiteSpace"===t)return!0;const r=it(n,t);return!r||r(e,n.Ja[t])})))return!1;n=n.parent}return!0}(e,t)?{u:!0,value:e}:{u:!1,error:Ke(e,t,"pattern validation failed.")})),a.push((e=>({u:!0,value:{type:t,value:e}}))),e=>{e={u:!0,value:e};for(let t=0,n=a.length;t<n&&(e=a[t](e.value),!1!==e.u);++t);return e}}function bt(e,t){const n=e.type+1e4*t;let r=vt[n];return r||=vt[n]=xt(e.type,t),r.call(void 0,e.value,t)}function At(e,t){if(!0===(e=bt(e,t)).u)return e.value;throw e.error}function Et(e){let t=!1;return{next:()=>t?A:(t=!0,E(e))}}function Nt(e,t){return e===t||!(!e||!t||e.offset!==t.offset||e.parent!==t.parent)&&Nt(e.F,t.F)}function Tt(e,t){return!!(e===t||e.node===t.node&&Nt(e.F,t.F))}function Bt(e,t){const n=[];for(;t;t=ne(e,t,null))n.unshift(t);return n}function It(e,t){const n=[];for(;t;t=e.getParentNode(t,null))n.unshift(t);return n}function Ct(e,t,n,r){if(n.F||r.F||z(n.node)||z(r.node)){if(Tt(n,r))return 0;n=Bt(t,n),r=Bt(t,r);const o=n[0],s=r[0];if(!Tt(o,s))return t=e.findIndex((e=>Tt(e,o))),n=e.findIndex((e=>Tt(e,s))),-1===t&&(t=e.push(o)),-1===n&&(n=e.push(s)),t-n;e=1;for(var a=Math.min(n.length,r.length);e<a&&Tt(n[e],r[e]);++e);return n[e]?r[e]?function(e,t,n){var r=ne(e,t,null);for(let a=0,o=(e=W(e,r,null)).length;a<o;++a){if(r=e[a],Tt(r,t))return-1;if(Tt(r,n))return 1}}(t,n[e],r[e]):1:-1}if((n=n.node)===(a=r.node))return 0;if(r=It(t,n),n=It(t,a),r[0]!==n[0]){const a={node:r[0],F:null},o={node:n[0],F:null};return t=e.findIndex((e=>Tt(e,a))),n=e.findIndex((e=>Tt(e,o))),-1===t&&(t=e.push(a)),-1===n&&(n=e.push(o)),t-n}for(e=1,a=Math.min(r.length,n.length);e<a&&r[e]===n[e];++e);if(r=r[e],a=n[e],!r)return-1;if(!a)return 1;for(let o=0,s=(t=t.getChildNodes(n[e-1],null)).length;o<s;++o){if(e=t[o],e===r)return-1;if(e===a)return 1}}function St(e,t,n,r){const a=T(n.type,47),o=T(r.type,47);if(a&&!o){if(Tt(n=ne(t,n.value),r=r.value))return 1}else if(o&&!a){if(Tt(n=n.value,r=ne(t,r.value)))return-1}else if(a&&o){if(Tt(ne(t,r.value),ne(t,n.value)))return n.value.node.localName>r.value.node.localName?1:-1;n=ne(t,n.value),r=ne(t,r.value)}else n=n.value,r=r.value;return Ct(e,t,n,r)}function Ot(e,t,n){return St(e.o,e,t,n)}function Ft(e,t){return kt(t,((t,n)=>St(e.o,e,t,n))).filter(((e,t,n)=>0===t||!Tt(e.value,n[t-1].value)))}const Dt=(e,t)=>e<t?-1:0;function kt(e,t=Dt){if(1>=e.length)return e;var n=Math.floor(e.length/2);const r=kt(e.slice(0,n),t);for(e=kt(e.slice(n),t),n=[];r.length&&e.length;)0>t(r[0],e[0])?n.push(r.shift()):n.push(e.shift());return n.concat(r.concat(e))}var Rt=e;function Mt(e,t,n,r,a){if(T(e.type,t.type))return e;if(T(t.type,46)&&T(e.type,53)&&(e=nt(e,n).first()),T(e.type,t.type)||46===t.type)return e;if(T(e.type,19)){if(!(n=At(e,t.type)))throw Error(`XPTY0004 Unable to convert ${a?"return":"argument"} of type ${C[e.type]} to type ${O(t)} while calling ${r}`);return n}if(n=function(e,t){if(T(e.type,2)){if(T(e.type,6))return 3===t?y(e.value,3):null;if(T(e.type,4)){if(6===t)return y(e.value,6);if(3===t)return y(e.value,3)}return null}return T(e.type,20)&&1===t?y(e.value,1):null}(e,t.type),!n)throw Error(`XPTY0004 Unable to cast ${a?"return":"argument"} of type ${C[e.type]} to type ${O(t)} while calling ${r}`);return n}function Ut(e){switch(e){case 2:return"*";case 1:return"+";case 0:return"?";case 3:return""}}var Gt=(e,t,n,r,a)=>0===e.g?t.Y({default:()=>t.map((t=>Mt(t,e,n,r,a))),multiple:()=>{throw Error(`XPTY0004: Multiplicity of ${a?"function return value":"function argument"} of type ${C[e.type]}${Ut(e.g)} for ${r} is incorrect. Expected "?", but got "+".`)}}):1===e.g?t.Y({empty:()=>{throw Error(`XPTY0004: Multiplicity of ${a?"function return value":"function argument"} of type ${C[e.type]}${Ut(e.g)} for ${r} is incorrect. Expected "+", but got "empty-sequence()"`)},default:()=>t.map((t=>Mt(t,e,n,r,a)))}):2===e.g?t.map((t=>Mt(t,e,n,r,a))):t.Y({m:()=>t.map((t=>Mt(t,e,n,r,a))),default:()=>{throw Error(`XPTY0004: Multiplicity of ${a?"function return value":"function argument"} of type ${C[e.type]}${Ut(e.g)} for ${r} is incorrect. Expected exactly one`)}});function $t(e,t){return T(e,5)?y(t,5):T(e,6)?y(t,6):T(e,3)?y(t,3):y(t,4)}const Lt=[{la:"M",ja:1e3},{la:"CM",ja:900},{la:"D",ja:500},{la:"CD",ja:400},{la:"C",ja:100},{la:"XC",ja:90},{la:"L",ja:50},{la:"XL",ja:40},{la:"X",ja:10},{la:"IX",ja:9},{la:"V",ja:5},{la:"IV",ja:4},{la:"I",ja:1}];function Ht(e,t){const n=0>e;if(!(e=Math.abs(e)))return"-";let r=Lt.reduce(((t,n)=>{const r=Math.floor(e/n.ja);return e-=r*n.ja,t+n.la.repeat(r)}),"");return t&&(r=r.toLowerCase()),n&&(r=`-${r}`),r}const Pt="ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");function jt(e,t){const n=0>e;if(!(e=Math.abs(e)))return"-";let r,a="";for(;0<e;)r=(e-1)%Pt.length,a=Pt[r]+a,e=(e-r)/Pt.length|0;return t&&(a=a.toLowerCase()),n&&(a=`-${a}`),a}function _t(e,t,n=[]){return Array.from({length:t},((t,n)=>n+e)).filter((e=>!n.includes(e)))}const Xt=_t(1488,27,[1498,1501,1503,1507,1509]),qt=_t(1575,36,[1577,1595,1596,1597,1598,1599,1600,1609]),Vt="أبجدهوزحطيكلمنسعفصقرشتثخذضظغ".split(""),Yt=[[1e3,"غ"],[900,"ظ"],[800,"ض"],[700,"ذ"],[600,"خ"],[500,"ث"],[400,"ت"],[300,"ش"],[200,"ر"],[100,"ق"],[90,"ص"],[80,"ف"],[70,"ع"],[60,"س"],[50,"ن"],[40,"م"],[30,"ل"],[20,"ك"],[10,"ي"],[9,"ط"],[8,"ح"],[7,"ز"],[6,"و"],[5,"ه"],[4,"د"],[3,"ج"],[2,"ب"],[1,"أ"]],zt=[[400,"ת"],[300,"ש"],[200,"ר"],[100,"ק"],[90,"צ"],[80,"פ"],[70,"ע"],[60,"ס"],[50,"נ"],[40,"מ"],[30,"ל"],[20,"כ"],[10,"י"],[9,"ט"],[8,"ח"],[7,"ז"],[6,"ו"],[5,"ה"],[4,"ד"],[3,"ג"],[2,"ב"],[1,"א"]];function Jt(e,t=[]){var n=25;return t.sort(((e,t)=>e-t)),n-=t.length,function(r){const a=0>r;if(!(r=Math.abs(r)))return"-";const o=[];for(;0<r;){let a=e+(r-1)%n;t.forEach((e=>{a>=e&&a++})),o.unshift(String.fromCodePoint(a)),r=Math.floor((r-1)/n)}return r=o.join(""),a&&(r=`-${r}`),r}}const Qt=Jt(945,[962]),Kt=Jt(913,[930]);function Wt(e){return new Intl.NumberFormat([],{numberingSystem:"arab",useGrouping:!1}).format(e)}function Zt(e){return new Intl.NumberFormat([],{numberingSystem:"arabext",useGrouping:!1}).format(e)}const en=new Map([["A",function(e){return jt(e,!1)}],["a",function(e){return jt(e,!0)}],["I",function(e){return Ht(e,!1)}],["i",function(e){return Ht(e,!0)}],["lowerGreek",Qt],["α",Qt],["upperGreek",Kt],["Α",Kt],["arabicAbjadi",function(e){const t=0>e;return(e=Math.abs(e))?(e=Array(Math.floor((e-1)/Vt.length)+1).fill(Vt[(e-1)%Vt.length]).join(String.fromCodePoint(8204)),t&&(e=`-${e}`),e):"-"}],["arabicAbjadNumeral",function(e){const t=0>e;if(!(e=Math.abs(e)))return"-";var n=[],r=Math.floor(e/1e3);if(e-=1e3*r,1===r)n.push(Yt[0][1]);else if(1<r){for(const[e,t]of Yt){var a=e;const o=t;for(;r>=a;)n.push(o),r-=a}n.push(Yt[0][1])}for(const[t,o]of Yt)for(r=t,a=o;e>=r;)e-=r,n.push(a);return n=n.join(""),t&&(n=`-${n}`),n}],["arabicAlifBaTa",function(e){const t=0>e;return(e=Math.abs(e))?(e=Array(Math.floor((e-1)/qt.length)+1).fill(String.fromCodePoint(qt[(e-1)%qt.length])).join(String.fromCodePoint(8204)),t&&(e=`-${e}`),e):"-"}],["hebrewAlefBet",function(e){const t=0>e;if(!(e=Math.abs(e)))return"-";var n=Math.floor((e-1)/Xt.length);const r=String.fromCodePoint(1514);return(n=Array(n).fill(r)).push(String.fromCodePoint(Xt[(e-1)%Xt.length])),e=n.join(""),t&&(e=`-${e}`),e}],["hebrewNumeral",function(e){const t=0>e;if(!(e=Math.abs(e)))return"-";var n=[],r=Math.floor(e/400);e-=400*r;for(var a=0;a<r;a++)n.push("ת");for(const[t,o]of zt)for(r=t,a=o;e>=r;)e-=r,n.push(a);return"יה"===(e=n.slice(-2).join(""))&&n.splice(-2,2,"ט","ו"),"יו"===e&&n.splice(-2,2,"ט","ז"),n=n.join(""),t&&(n=`-${n}`),n}],["arabicIndicNumeral",Wt],["١",Wt],["٢",Wt],["٣",Wt],["٤",Wt],["٥",Wt],["٦",Wt],["٧",Wt],["٨",Wt],["٩",Wt],["persianNumeral",Zt],["۱",Zt],["۲",Zt],["۳",Zt],["۴",Zt],["۵",Zt],["۶",Zt],["۷",Zt],["۸",Zt],["۹",Zt]]);function tn(e,t,n,r,a,o){let s=!1;return $.create({next:()=>{if(s)return A;const t=a.first();if(!t)return s=!0,A;if((T(t.type,6)||T(t.type,3))&&(0===t.value||isNaN(t.value)||1/0===t.value||-1/0===t.value))return s=!0,E(t);var n;if(n=o?o.first().value:0,s=!0,function(e){if(Math.floor(e)===e||isNaN(e))return 0;const t=(e=/\d+(?:\.(\d*))?(?:[Ee](-)?(\d+))*/.exec(`${e}`))[1]?e[1].length:0;return e[3]?e[2]?t+parseInt(e[3],10):0>(e=t-parseInt(e[3],10))?0:e:t}(t.value)<n)return E(t);const r=[5,4,3,6].find((e=>T(t.type,e)));switch(n=function(e,t,n){return t&&0==e*n%1%.5?0==Math.floor(e*n)%2?Math.floor(e*n)/n:Math.ceil(e*n)/n:Math.round(e*n)/n}(At(t,4).value,e,Math.pow(10,n)),r){case 4:return E(y(n,4));case 3:return E(y(n,3));case 6:return E(y(n,6));case 5:return E(y(n,5))}}})}const nn=(e,t,n,r)=>rt(r,t).Y({empty:()=>$.m(y(NaN,3)),m:()=>{const e=bt(r.first(),3);return e.u?$.m(e.value):$.m(y(NaN,3))},multiple:()=>{throw Error("fn:number may only be called with zero or one values")}});const rn=(e,t,n,r=$.empty())=>(t=r.G()?Ve(e):Ve(e,function(e){let t=5381;for(let n=0;n<e.length;++n)t=33*t+e.charCodeAt(n),t%=Number.MAX_SAFE_INTEGER;return t}(At(r.first(),1).value)),function t(n){const r=(t,r,a,o)=>{if(o.G()||o.ua())return o;for(t=o.O(),r=n,a=t.length-1;1<a;a--){const n=t[o=(r=Ve(e,r).pb)%a];t[o]=t[a],t[a]=n}return $.create(t)};return $.m(new de([{key:y("number",1),value:()=>$.m(y(Ve(e,n).Yb,3))},{key:y("next",1),value:()=>$.m(new P({value:()=>t(Ve(e,n).pb),Xa:!0,localName:"",namespaceURI:"",j:[],arity:0,i:{type:61,g:3}}))},{key:y("permute",1),value:()=>$.m(new P({value:r,Xa:!0,localName:"",namespaceURI:"",j:[{type:59,g:2}],arity:1,i:{type:59,g:2}}))}]))}(t.pb));var an=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"abs",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:(e,t,n,r)=>r.map((e=>$t(e.type,Math.abs(e.value))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"format-integer",j:[{type:5,g:0},{type:1,g:3}],i:{type:1,g:3},callFunction:(e,t,n,r,a)=>(e=r.first(),a=a.first(),r.G()?$.m(y("",1)):(r=en.get(a.value),a=e.value,r?(r=r(a),$.m(y(r,1))):$.m(y(a.toString(),1))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"ceiling",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:(e,t,n,r)=>r.map((e=>$t(e.type,Math.ceil(e.value))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"floor",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:(e,t,n,r)=>r.map((e=>$t(e.type,Math.floor(e.value))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:tn.bind(null,!1)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round",j:[{type:2,g:0},{type:5,g:3}],i:{type:2,g:0},callFunction:tn.bind(null,!1)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round-half-to-even",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:tn.bind(null,!0)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round-half-to-even",j:[{type:2,g:0},{type:5,g:3}],i:{type:2,g:0},callFunction:tn.bind(null,!0)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"number",j:[{type:46,g:0}],i:{type:3,g:3},callFunction:nn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"number",j:[],i:{type:3,g:3},callFunction:(e,t,n)=>{const r=e.M&&Gt({type:46,g:0},$.m(e.M),t,"fn:number",!1);if(!r)throw We("fn:number needs an atomizable context item.");return nn(0,t,0,r)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"random-number-generator",j:[],i:{type:61,g:3},callFunction:rn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"random-number-generator",j:[{type:46,g:0}],i:{type:61,g:3},callFunction:rn}];function on(){throw Error("FOCH0002: No collations are supported")}function sn(e,t,n,r){if(null===t.M)throw We("The function which was called depends on dynamic context, which is absent.");return e(t,n,r,$.m(t.M))}const ln=(e,t,n,r)=>r.Y({empty:()=>$.m(y("",1)),default:()=>r.map((e=>{if(T(e.type,53)){const n=nt(e,t).first();return T(e.type,47)?At(n,1):n}return At(e,1)}))}),cn=(e,t,n,r,a)=>ue([a],(([e])=>rt(r,t).N((t=>(t=t.map((e=>At(e,1).value)).join(e.value),$.m(y(t,1))))))),un=(e,t,n,r)=>r.G()?$.m(y(0,5)):(e=r.first().value,$.m(y(Array.from(e).length,5))),pn=(e,t,n,r,a,o)=>{const s=tn(!1,0,0,0,a,null),i=null!==o?tn(!1,0,0,0,o,null):null;let l=!1,c=null,u=null,p=null;return $.create({next:()=>l?A:c||(c=r.first(),null!==c)?(u||=s.first(),!p&&o&&(p=null,p=i.first()),l=!0,E(y(Array.from(c.value).slice(Math.max(u.value-1,0),o?u.value+p.value-1:void 0).join(""),1))):(l=!0,E(y("",1)))})},hn=(e,t,n,r,a)=>r.G()||0===r.first().value.length?$.empty():(e=r.first().value,a=gn(a=a.first().value),$.create(e.split(a).map((e=>y(e,1))))),dn=(e,t,n,r)=>r.G()?$.m(y("",1)):(e=r.first().value.trim(),$.m(y(e.replace(/\s+/g," "),1))),mn=new Map,fn=new Map;function gn(e){if(fn.has(e))return fn.get(e);let t;try{t=new RegExp(e,"g")}catch(e){throw Error(`FORX0002: ${e}`)}if(t.test(""))throw Error(`FORX0003: the pattern ${e} matches the zero length string`);return fn.set(e,t),t}var yn=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"compare",j:[{type:1,g:0},{type:1,g:0}],i:{type:5,g:0},callFunction:(e,t,n,r,a)=>r.G()||a.G()?$.empty():(e=r.first().value)>(a=a.first().value)?$.m(y(1,5)):e<a?$.m(y(-1,5)):$.m(y(0,5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"compare",j:[{type:1,g:0},{type:1,g:0},{type:1,g:3}],i:{type:5,g:0},callFunction:on},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"concat",j:[{type:46,g:0},{type:46,g:0},4],i:{type:1,g:3},callFunction:(e,t,n,...r)=>(r=r.map((e=>rt(e,t).N((e=>$.m(y(e.map((e=>null===e?"":At(e,1).value)).join(""),1)))))),ue(r,(e=>$.m(y(e.map((e=>e.value)).join(""),1)))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"contains",j:[{type:1,g:0},{type:1,g:0},{type:1,g:0}],i:{type:0,g:3},callFunction:on},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"contains",j:[{type:1,g:0},{type:1,g:0}],i:{type:0,g:3},callFunction:(e,t,n,r,a)=>(e=r.G()?"":r.first().value,0===(a=a.G()?"":a.first().value).length?$.aa():0===e.length?$.V():e.includes(a)?$.aa():$.V())},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"ends-with",j:[{type:1,g:0},{type:1,g:0}],i:{type:0,g:3},callFunction:(e,t,n,r,a)=>0===(e=a.G()?"":a.first().value).length?$.aa():0===(r=r.G()?"":r.first().value).length?$.V():r.endsWith(e)?$.aa():$.V()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"ends-with",j:[{type:1,g:0},{type:1,g:0},{type:1,g:3}],i:{type:0,g:3},callFunction:on},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"normalize-space",j:[{type:1,g:0}],i:{type:1,g:3},callFunction:dn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"normalize-space",j:[],i:{type:1,g:3},callFunction:sn.bind(null,((e,t,n,r)=>dn(e,0,0,ln(0,t,0,r))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"starts-with",j:[{type:1,g:0},{type:1,g:0}],i:{type:0,g:3},callFunction:(e,t,n,r,a)=>0===(e=a.G()?"":a.first().value).length?$.aa():0===(r=r.G()?"":r.first().value).length?$.V():r.startsWith(e)?$.aa():$.V()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"starts-with",j:[{type:1,g:0},{type:1,g:0},{type:1,g:3}],i:{type:0,g:3},callFunction:on},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string",j:[{type:59,g:0}],i:{type:1,g:3},callFunction:ln},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string",j:[],i:{type:1,g:3},callFunction:sn.bind(null,ln)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring-before",j:[{type:1,g:0},{type:1,g:0}],i:{type:1,g:3},callFunction:(e,t,n,r,a)=>(e=r.G()?"":r.first().value,""===(a=a.G()?"":a.first().value)||-1===(a=e.indexOf(a))?$.m(y("",1)):$.m(y(e.substring(0,a),1)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring-after",j:[{type:1,g:0},{type:1,g:0}],i:{type:1,g:3},callFunction:(e,t,n,r,a)=>(e=r.G()?"":r.first().value,""===(a=a.G()?"":a.first().value)?$.m(y(e,1)):-1===(t=e.indexOf(a))?$.m(y("",1)):$.m(y(e.substring(t+a.length),1)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring",j:[{type:1,g:0},{type:3,g:3}],i:{type:1,g:3},callFunction:pn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring",j:[{type:1,g:0},{type:3,g:3},{type:3,g:3}],i:{type:1,g:3},callFunction:pn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"upper-case",j:[{type:1,g:0}],i:{type:1,g:3},callFunction:(e,t,n,r)=>r.G()?$.m(y("",1)):r.map((e=>y(e.value.toUpperCase(),1)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"lower-case",j:[{type:1,g:0}],i:{type:1,g:3},callFunction:(e,t,n,r)=>r.G()?$.m(y("",1)):r.map((e=>y(e.value.toLowerCase(),1)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-join",j:[{type:46,g:2},{type:1,g:3}],i:{type:1,g:3},callFunction:cn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-join",j:[{type:46,g:2}],i:{type:1,g:3},callFunction:(e,t,n,r)=>cn(0,t,0,r,$.m(y("",1)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-length",j:[{type:1,g:0}],i:{type:5,g:3},callFunction:un},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-length",j:[],i:{type:5,g:3},callFunction:sn.bind(null,((e,t,n,r)=>un(e,0,0,ln(0,t,0,r))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"tokenize",j:[{type:1,g:0},{type:1,g:3},{type:1,g:3}],i:{type:1,g:2},callFunction(){throw Error("Not implemented: Using flags in tokenize is not supported")}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"tokenize",j:[{type:1,g:0},{type:1,g:3}],i:{type:1,g:2},callFunction:hn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"tokenize",j:[{type:1,g:0}],i:{type:1,g:2},callFunction:(e,t,n,r)=>hn(e,0,0,dn(e,0,0,r),$.m(y(" ",1)))},{j:[{type:1,g:0},{type:1,g:3},{type:1,g:3}],callFunction:(e,t,n,r,a,o)=>ue([r,a,o],(([e,t,n])=>{e=Array.from(e?e.value:"");const r=Array.from(t.value),a=Array.from(n.value);return t=e.map((e=>r.includes(e)?(e=r.indexOf(e))<=a.length?a[e]:void 0:e)),$.m(y(t.join(""),1))})),localName:"translate",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:5,g:2}],callFunction:(e,t,n,r)=>r.N((e=>(e=e.map((e=>{if(9===(e=e.value)||10===e||13===e||32<=e&&55295>=e||57344<=e&&65533>=e||65536<=e&&1114111>=e)return String.fromCodePoint(e);throw Error("FOCH0001")})).join(""),$.m(y(e,1))))),localName:"codepoints-to-string",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:1,g:0}],callFunction:(e,t,n,r)=>ue([r],(([e])=>0===(e=e?e.value.split(""):[]).length?$.empty():$.create(e.map((e=>y(e.codePointAt(0),5)))))),localName:"string-to-codepoints",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:2}},{j:[{type:1,g:0}],callFunction:(e,t,n,r)=>ue([r],(([e])=>null===e||0===e.value.length?$.create(y("",1)):$.create(y(encodeURIComponent(e.value).replace(/[!'()*]/g,(e=>"%"+e.charCodeAt(0).toString(16).toUpperCase())),1)))),localName:"encode-for-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:1,g:0}],callFunction:(e,t,n,r)=>ue([r],(([e])=>null===e||0===e.value.length?$.create(y("",1)):$.create(y(e.value.replace(/([\u00A0-\uD7FF\uE000-\uFDCF\uFDF0-\uFFEF "<>{}|\\^`/\n\u007f\u0080-\u009f]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g,(e=>encodeURI(e))),1)))),localName:"iri-to-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:1,g:0},{type:1,g:0}],callFunction:(e,t,n,r,a)=>ue([r,a],(([e,t])=>{if(null===e||null===t)return $.empty();e=e.value;var n=t.value;if(e.length!==n.length)return $.V();for(t=e.split(""),e=n.split(""),n=0;n<t.length;n++)if(t[n].codePointAt(0)!==e[n].codePointAt(0))return $.V();return $.aa()})),localName:"codepoint-equal",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:0}},{j:[{type:1,g:0},{type:1,g:3}],callFunction:(e,t,n,r,a)=>ue([r,a],(([e,t])=>{e=e?e.value:"",t=t.value;let n=mn.get(t);if(!n){try{n=(0,Rt.compile)(t,{language:"xpath"})}catch(e){throw Error(`FORX0002: ${e}`)}mn.set(t,n)}return n(e)?$.aa():$.V()})),localName:"matches",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:1,g:0},{type:1,g:3},{type:1,g:3}],callFunction:(e,t,n,r,a,o)=>ue([r,a,o],(([e,t,n])=>{if(e=e?e.value:"",t=t.value,(n=n.value).includes("$0"))throw Error("Using $0 in fn:replace to replace substrings with full matches is not supported.");return n=n.split(/((?:\$\$)|(?:\\\$)|(?:\\\\))/).map((e=>{switch(e){case"\\$":return"$$";case"\\\\":return"\\";case"$$":throw Error('FORX0004: invalid replacement: "$$"');default:return e}})).join(""),t=gn(t),e=e.replace(t,n),$.m(y(e,1))})),localName:"replace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:1,g:0},{type:1,g:3},{type:1,g:3},{type:1,g:3}],localName:"replace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3},callFunction(){throw Error("Not implemented: Using flags in replace is not supported")}}];function wn(e,t,n,r,a){if(null===n.M)throw We(`The function ${e} depends on dynamic context, which is absent.`);return t(n,r,a,$.m(n.M))}const vn=(e,t,n,r)=>ue([r],(([e])=>{if(null===e)return $.empty();switch((e=e.value).node.nodeType){case 1:case 2:return $.m(y(new H(e.node.prefix,e.node.namespaceURI,e.node.localName),23));case 7:return $.m(y(new H("","",e.node.target),23));default:return $.empty()}})),xn=(e,t,n,r)=>r.Y({default:()=>ln(0,t,0,vn(0,0,0,r)),empty:()=>$.m(y("",1))}),bn=(e,t,n,r)=>rt(r,t),An=(e,t,n,r)=>ue([r],(([e])=>null!==(e=e?e.value:null)&&ee(t.h,e,null)?$.aa():$.V())),En=(e,t,n,r)=>ue([r],(([e])=>{function n(e){let t=0,n=e;for(;null!==n;)(e.node.nodeType!==n.node.nodeType?0:1===n.node.nodeType?n.node.localName===e.node.localName&&n.node.namespaceURI===e.node.namespaceURI:7===n.node.nodeType?n.node.target===e.node.target:1)&&t++,n=ae(r,n,null);return t}if(null===e)return $.empty();const r=t.h;let a="";for(e=e.value;null!==ne(t.h,e,null);e=ne(t.h,e,null))switch(e.node.nodeType){case 1:var o=e;a=`/Q{${o.node.namespaceURI||""}}${o.node.localName}[${n(o)}]${a}`;break;case 2:a=`/@${(o=e).node.namespaceURI?`Q{${o.node.namespaceURI}}`:""}${o.node.localName}${a}`;break;case 3:a=`/text()[${n(e)}]${a}`;break;case 7:a=`/processing-instruction(${(o=e).node.target})[${n(o)}]${a}`;break;case 8:a=`/comment()[${n(e)}]${a}`}return 9===e.node.nodeType?$.create(y(a||"/",1)):$.create(y("Q{http://www.w3.org/2005/xpath-functions}root()"+a,1))})),Nn=(e,t,n,r)=>r.map((e=>y(e.value.node.namespaceURI||"",20))),Tn=(e,t,n,r)=>r.Y({default:()=>r.map((e=>7===e.value.node.nodeType?y(e.value.node.target,1):y(e.value.node.localName||"",1))),empty:()=>$.m(y("",1))});function Bn(e,t,n){if(2===t.node.nodeType)return Tt(t,n);for(;n;){if(Tt(t,n))return!0;if(9===n.node.nodeType)break;n=ne(e,n,null)}return!1}const In=(e,t,n,r)=>r.map((e=>{if(!T(e.type,53))throw Error("XPTY0004 Argument passed to fn:root() should be of the type node()");let n;for(e=e.value;e;)n=e,e=ne(t.h,n,null);return ce(n)}));var Cn=[{j:[{type:53,g:0}],callFunction:xn,localName:"name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[],callFunction:wn.bind(null,"name",xn),localName:"name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:53,g:3}],callFunction:Nn,localName:"namespace-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:20,g:3}},{j:[],callFunction:wn.bind(null,"namespace-uri",Nn),localName:"namespace-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:20,g:3}},{j:[{type:53,g:2}],callFunction:(e,t,n,r)=>r.N((e=>e.length?(e=Ft(t.h,e).reduceRight(((e,n,r,a)=>r===a.length-1?(e.push(n),e):(Bn(t.h,n.value,e[0].value)||e.unshift(n),e)),[]),$.create(e)):$.empty())),localName:"innermost",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:2}},{j:[{type:53,g:2}],callFunction:(e,t,n,r)=>r.N((e=>e.length?(e=Ft(t.h,e).reduce(((e,n,r)=>0===r?(e.push(n),e):(Bn(t.h,e[e.length-1].value,n.value)||e.push(n),e)),[]),$.create(e)):$.empty()),1),localName:"outermost",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:2}},{j:[{type:53,g:0}],callFunction:An,localName:"has-children",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[],callFunction:wn.bind(null,"has-children",An),localName:"has-children",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:53,g:0}],callFunction:En,localName:"path",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:0}},{j:[],callFunction:wn.bind(null,"path",En),localName:"path",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:0}},{j:[{type:53,g:0}],callFunction:vn,localName:"node-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[],callFunction:wn.bind(null,"node-name",vn),localName:"node-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[{type:53,g:0}],callFunction:Tn,localName:"local-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[],callFunction:wn.bind(null,"local-name",Tn),localName:"local-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:53,g:0}],callFunction:In,localName:"root",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:0}},{j:[],callFunction:wn.bind(null,"root",In),localName:"root",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:0}},{j:[],callFunction:wn.bind(null,"data",bn),localName:"data",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}},{j:[{type:59,g:2}],callFunction:bn,localName:"data",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}}];function Sn(e,t){let n=0;const r=e.length;let a=!1,o=null;return{next:()=>{if(!a){for(;n<r;){o||=t(e[n],n,e);const r=o.next(0);if(o=null,!r.value)return E(!1);n++}return a=!0,E(!0)}return A}}}function On(e){return 1===(e=e.node.nodeType)||3===e}function Fn(e,t){if((T(e.type,4)||T(e.type,6))&&(T(t.type,4)||T(t.type,6))){var n=At(e,6),r=At(t,6);return n.value===r.value||isNaN(e.value)&&isNaN(t.value)}return(T(e.type,4)||T(e.type,6)||T(e.type,3))&&(T(t.type,4)||T(t.type,6)||T(t.type,3))?(n=At(e,3),r=At(t,3),n.value===r.value||isNaN(e.value)&&isNaN(t.value)):T(e.type,23)&&T(t.type,23)?e.value.namespaceURI===t.value.namespaceURI&&e.value.localName===t.value.localName:(T(e.type,9)||T(e.type,7)||T(e.type,8)||T(e.type,11)||T(e.type,12)||T(e.type,13)||T(e.type,14)||T(e.type,15))&&(T(t.type,9)||T(t.type,7)||T(t.type,8)||T(t.type,11)||T(t.type,12)||T(t.type,13)||T(t.type,14)||T(t.type,15))?De(e.value,t.value):(T(e.type,16)||T(e.type,17)||T(e.type,18))&&(T(t.type,16)||T(t.type,17)||T(t.type,17))?me(e.value,t.value):e.value===t.value}function Dn(e,t,n){const[r,a]=[t,n].map((t=>({type:1,value:t.reduce(((t,n)=>t+nt(n,e).first().value),"")})));return E(Fn(r,a))}function kn(e,t,n,r){for(;e.value&&T(e.value.type,56);){t.push(e.value);const a=re(r,e.value.value);if(e=n.next(0),a&&3!==a.node.nodeType)break}return e}function Rn(e,t,n,r,a){const o=t.h,s=r.value,i=a.value;let l,c=null,u=null,p=null;const h=[],d=[];return{next:()=>{for(;!l;)if(c||=s.next(0),c=kn(c,h,s,o),u||=i.next(0),u=kn(u,d,i,o),h.length||d.length){var r=Dn(t,h,d);if(h.length=0,d.length=0,!1===r.value)return l=!0,r}else{if(c.done||u.done)return l=!0,E(c.done===u.done);if(p||=Un(e,t,n,c.value,u.value),r=p.next(0),p=null,!1===r.value)return l=!0,r;u=c=null}return A}}}function Mn(e,t,n,r,a){return r=W(t.h,r.value),a=W(t.h,a.value),r=r.filter((e=>On(e))),a=a.filter((e=>On(e))),r=$.create(r.map((e=>ce(e)))),a=$.create(a.map((e=>ce(e)))),Rn(e,t,n,r,a)}function Un(e,t,n,r,a){if(T(r.type,46)&&T(a.type,46))return Et(Fn(r,a));if(T(r.type,61)&&T(a.type,61))return function(e,t,n,r,a){return r.h.length!==a.h.length?Et(!1):Sn(r.h,(r=>{const o=a.h.find((e=>Fn(e.key,r.key)));return o?Rn(e,t,n,r.value(),o.value()):Et(!1)}))}(e,t,n,r,a);if(T(r.type,62)&&T(a.type,62))return function(e,t,n,r,a){return r.h.length!==a.h.length?Et(!1):Sn(r.h,((r,o)=>(o=a.h[o],Rn(e,t,n,r(),o()))))}(e,t,n,r,a);if(T(r.type,53)&&T(a.type,53)){if(T(r.type,55)&&T(a.type,55))return Mn(e,t,n,r,a);if(T(r.type,54)&&T(a.type,54))return function(e,t,n,r,a){const o=Rn(e,t,n,vn(0,0,0,$.m(r)),vn(0,0,0,$.m(a))),s=Mn(e,t,n,r,a);r=Q(t.h,r.value).filter((e=>"http://www.w3.org/2000/xmlns/"!==e.node.namespaceURI)).sort(((e,t)=>e.node.nodeName>t.node.nodeName?1:-1)).map((e=>ce(e))),a=Q(t.h,a.value).filter((e=>"http://www.w3.org/2000/xmlns/"!==e.node.namespaceURI)).sort(((e,t)=>e.node.nodeName>t.node.nodeName?1:-1)).map((e=>ce(e)));const i=Rn(e,t,n,$.create(r),$.create(a));let l=!1;return{next:()=>{if(l)return A;var e=o.next(0);return!e.done&&!1===e.value||!(e=i.next(0)).done&&!1===e.value?(l=!0,e):(e=s.next(0),l=!0,e)}}}(e,t,n,r,a);if(T(r.type,47)&&T(a.type,47)||T(r.type,57)&&T(a.type,57)||T(r.type,58)&&T(a.type,58))return function(e,t,n,r,a){const o=Rn(e,t,n,vn(0,0,0,$.m(r)),vn(0,0,0,$.m(a)));let s=!1;return{next:()=>{if(s)return A;const e=o.next(0);return e.done||!1!==e.value?E(Fn(nt(r,t).first(),nt(a,t).first())):(s=!0,e)}}}(e,t,n,r,a)}return Et(!1)}var Gn=class extends ze{constructor(){super({M:null,Aa:-1,sa:$.empty(),qa:{}})}},$n=(e="Can not execute an updating expression in a non-updating context.")=>Error(`XUST0001: ${e}`),Ln=e=>Error(`XUTY0004: The attribute ${e.name}="${e.value}" follows a node that is not an attribute node.`),Hn=()=>Error("XUTY0005: The target of a insert expression with into must be a single element or document node."),Pn=()=>Error("XUTY0006: The target of a insert expression with before or after must be a single element, text, comment, or processing instruction node."),jn=()=>Error("XUTY0008: The target of a replace expression must be a single element, attribute, text, comment, or processing instruction node."),_n=()=>Error("XUTY0012: The target of a rename expression must be a single element, attribute, or processing instruction node."),Xn=e=>Error(`XUDY0017: The target ${e.outerHTML} is used in more than one replace value of expression.`),qn=e=>Error(`XUDY0021: Applying the updates will result in the XDM instance violating constraint: '${e}'`),Vn=e=>Error(`XUDY0023: The namespace binding ${e} is conflicting.`),Yn=e=>Error(`XUDY0024: The namespace binding ${e} is conflicting.`),zn=()=>Error("XUDY0027: The target for an insert, replace, or rename expression expression should not be empty.");function Jn(e,t,n){return t&&null!==t.M&&e.B?(null===e.nb&&(e.nb=L(e.h(new Gn,n).gb())),e=e.nb()):e=e.h(t,n),e}var Qn=class{constructor(e,t,n={B:!1,W:!1,P:"unsorted",subtree:!1},r=!1,a){this.o=e,this.ia=n.P||"unsorted",this.subtree=!!n.subtree,this.W=!!n.W,this.B=!!n.B,this.Ka=t,this.J=!1,this.nb=null,this.Nb=r,this.type=a}D(){return null}v(e){if(this.Ka.forEach((t=>t.v(e))),!this.Nb&&this.Ka.some((e=>e.J)))throw $n()}},Kn=class{constructor(e,t){this.I=e,this.da=t}},Wn=class{constructor(e){e&&"object"==typeof e&&"nodeType"in e&&("function"==typeof(e=e.ownerDocument||e).createElementNS&&"function"==typeof e.createProcessingInstruction&&"function"==typeof e.createTextNode&&"function"==typeof e.createComment&&(this.h=e)),this.h||(this.h=null)}createAttributeNS(e,t){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createAttributeNS(e,t)}createCDATASection(e){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createCDATASection(e)}createComment(e){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createComment(e)}createDocument(){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.implementation.createDocument(null,null,null)}createElementNS(e,t){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createElementNS(e,t)}createProcessingInstruction(e,t){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createProcessingInstruction(e,t)}createTextNode(e){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createTextNode(e)}};function Zn(e,t,n,r){return Q(r,e,`name-${t}`).some((e=>e.node.localName===t&&e.node.namespaceURI===n))}var er=(e,t,n)=>{t.forEach((t=>{n.insertBefore(e.node,t.node,null)}))},tr=(e,t,n,r)=>{const a=ne(n,e);var o=e.node.nodeType;if(2===o){if(t.some((e=>2!==e.node.nodeType)))throw Error('Constraint "If $target is an attribute node, $replacement must consist of zero or more attribute nodes." failed.');const o=a?a.node:null;r.removeAttributeNS(o,e.node.namespaceURI,e.node.localName),t.forEach((e=>{const t=e.node.localName,s=e.node.namespaceURI;if(Zn(a,t,s,n))throw qn(`An attribute ${s?`Q{${s}}${t}`:t} already exists.`);r.setAttributeNS(o,s,t,Z(n,e))}))}if(1===o||3===o||8===o||7===o){const s=(o=re(n,e))?o.node:null;r.removeChild(a.node,e.node),t.forEach((e=>{r.insertBefore(a.node,e.node,s)}))}},nr=(e,t,n,r)=>{if(rr(e,t),e.filter((e=>-1!==["insertInto","insertAttributes","replaceValue","rename"].indexOf(e.type))).forEach((e=>{switch(e.type){case"insertInto":er(e.target,e.content,r);break;case"insertAttributes":((e,t,n,r)=>{t.forEach((t=>{const a=t.node.localName,o=t.node.namespaceURI;if(Zn(e,a,o,n))throw qn(`An attribute ${o?`Q{${o}}${a}`:a} already exists.`);r.setAttributeNS(e.node,o,a,Z(n,t))}))})(e.target,e.content,t,r);break;case"rename":((e,t,n,r,a)=>{let o;switch(r||=new Wn(e?e.node:null),e.node.nodeType){case 1:const s=n.getAllAttributes(e.node),i=n.getChildNodes(e.node),l=r.createElementNS(t.namespaceURI,t.za());o={node:l,F:null},s.forEach((e=>{a.setAttributeNS(l,e.namespaceURI,e.nodeName,e.value)})),i.forEach((e=>{a.insertBefore(l,e,null)}));break;case 2:(t=r.createAttributeNS(t.namespaceURI,t.za())).value=Z(n,e),o={node:t,F:null};break;case 7:o={node:r.createProcessingInstruction(t.za(),Z(n,e)),F:null}}if(!ne(n,e))throw Error("Not supported: renaming detached nodes.");tr(e,[o],n,a)})(e.target,e.o,t,n,r);break;case"replaceValue":var a=e.target;if(e=e.o,2===a.node.nodeType){const n=ne(t,a);n?r.setAttributeNS(n.node,a.node.namespaceURI,a.node.localName,e):a.node.value=e}else r.setData(a.node,e)}})),e.filter((e=>-1!==["insertBefore","insertAfter","insertIntoAsFirst","insertIntoAsLast"].indexOf(e.type))).forEach((e=>{switch(e.type){case"insertAfter":((e,t,n,r)=>{const a=ne(n,e).node,o=(e=re(n,e))?e.node:null;t.forEach((e=>{r.insertBefore(a,e.node,o)}))})(e.target,e.content,t,r);break;case"insertBefore":((e,t,n,r)=>{const a=ne(n,e).node;t.forEach((t=>{r.insertBefore(a,t.node,e.node)}))})(e.target,e.content,t,r);break;case"insertIntoAsFirst":((e,t,n,r)=>{const a=(n=ee(n,e))?n.node:null;t.forEach((t=>{r.insertBefore(e.node,t.node,a)}))})(e.target,e.content,t,r);break;case"insertIntoAsLast":er(e.target,e.content,r)}})),e.filter((e=>"replaceNode"===e.type)).forEach((e=>{tr(e.target,e.o,t,r)})),e.filter((e=>"replaceElementContent"===e.type)).forEach((e=>{((e,t,n,r)=>{n.getChildNodes(e.node).forEach((t=>r.removeChild(e.node,t))),t&&r.insertBefore(e.node,t.node,null)})(e.target,e.text,t,r)})),e.filter((e=>"delete"===e.type)).forEach((e=>{e=e.target;var n=ne(t,e);(n=n?n.node:null)&&(2===e.node.nodeType?r.removeAttributeNS(n,e.node.namespaceURI,e.node.localName):r.removeChild(n,e.node))})),e.some((e=>"put"===e.type)))throw Error('Not implemented: the execution for pendingUpdate "put" is not yet implemented.')};const rr=(e,t)=>{function n(t,n){const r=new Set;e.filter((e=>e.type===t)).map((e=>e.target)).forEach((e=>{e=e?e.node:null,r.has(e)&&n(e),r.add(e)}))}n("rename",(e=>{throw Error(`XUDY0015: The target ${e.outerHTML} is used in more than one rename expression.`)})),n("replaceNode",(e=>{throw Error(`XUDY0016: The target ${e.outerHTML} is used in more than one replace expression.`)})),n("replaceValue",(e=>{throw Xn(e)})),n("replaceElementContent",(e=>{throw Xn(e)}));const r=new Map,a=e=>new H(e.node.prefix,e.node.namespaceURI,e.node.localName);e.filter((e=>"replaceNode"===e.type&&2===e.target.node.nodeType)).forEach((e=>{var n=ne(t,e.target);n=n?n.node:null;const o=r.get(n);o?o.push(...e.o.map(a)):r.set(n,e.o.map(a))})),e.filter((e=>"rename"===e.type&&2===e.target.node.nodeType)).forEach((e=>{var n=ne(t,e.target);if(n){n=n.node;var a=r.get(n);a?a.push(e.o):r.set(n,[e.o])}})),r.forEach((e=>{const t={};e.forEach((e=>{if(t[e.prefix]||(t[e.prefix]=e.namespaceURI),t[e.prefix]!==e.namespaceURI)throw Yn(e.namespaceURI)}))}))};var ar=(e,...t)=>e.concat(...t.filter(Boolean));function or(e){return e.J?(t,n)=>e.s(t,n):(t,n)=>{const r=e.h(t,n);return{next:()=>E({da:[],I:r.O()})}}}var sr=class extends Qn{constructor(e,t,n,r){super(e,t,n,!0,r),this.J=!0}h(){throw $n()}};function ir(e,t){return t((e=e.next(0)).value.da),$.create(e.value.I)}var lr=class extends sr{constructor(e,t,n,r){super(e,t,n,r),this.J=this.Ka.some((e=>e.J))}h(e,t){return this.A(e,t,this.Ka.map((e=>n=>e.h(n,t))))}s(e,t){let n=[];const r=this.A(e,t,this.Ka.map((e=>e.J?r=>ir(r=e.s(r,t),(e=>n=ar(n,e))):n=>e.h(n,t))));let a=!1;return{next:()=>{if(a)return A;const e=r.O();return a=!0,E(new Kn(e,n))}}}v(e){super.v(e),function(e){e.Ka.some((e=>e.J))&&(e.J=!0)}(this)}};const cr=["external","attribute","nodeName","nodeType","universal"],ur=cr.length;function pr(e,t){for(let n=0;n<ur;++n){if(t.h[n]<e.h[n])return 1;if(t.h[n]>e.h[n])return-1}return 0}var hr=class{constructor(e){if(this.h=cr.map((t=>e[t]||0)),Object.keys(e).some((e=>!cr.includes(e))))throw Error("Invalid specificity kind passed")}add(e){const t=cr.reduce(((t,n,r)=>(t[n]=this.h[r]+e.h[r],t)),Object.create(null));return new hr(t)}};const dr=()=>Ze("Expected base expression of a function call to evaluate to a sequence of single function item");function mr(e,t,n,r){const a=[];for(let o=0;o<t.length;++o){if(null===t[o]){a.push(null);continue}const s=Gt(e[o],t[o],n,r,!1);a.push(s)}return a}function fr(e,t){if(!T(e.type,60))throw Ze("Expected base expression to evaluate to a function item");if(e.v!==t)throw dr();return e}function gr(e,t,n,r,a,o,s){let i=0;return a=a.map((e=>e?null:o[i++](n))),0<=(a=mr(e.o,a,r,e.D)).indexOf(null)?function(e,t){const n=e.value,r=t.map((e=>null===e?null:L(e)));return t=t.reduce(((t,n,r)=>(null===n&&t.push(e.o[r]),t)),[]),t=new P({j:t,arity:t.length,Xa:!0,J:e.J,localName:"boundFunction",namespaceURI:e.l,i:e.s,value:function(e,t,a){const o=Array.from(arguments).slice(3),s=r.map((e=>null===e?o.shift():e()));return n.apply(void 0,[e,t,a].concat(s))}}),$.m(t)}(e,a):(t=t.apply(void 0,[n,r,s,...a]),Gt(e.s,t,r,e.D,!0))}var yr=class extends lr{constructor(e,t,n){super(new hr({external:1}),[e].concat(t.filter((e=>!!e))),{P:"unsorted",W:!1,subtree:!1,B:!1},n),this.ma=t.length,this.S=t.map((e=>null===e)),this.L=null,this.ya=e,this.La=t}s(e,t){if(!this.l||!this.l.J)return super.s(e,t);let n=[];const r=gr(this.l,((e,t,r,...a)=>ir(this.l.value(e,t,r,...a),(e=>{n=ar(n,e)}))),e,t,this.S,this.La.map((r=>()=>r.J?ir(r.s(e,t),(e=>{n=ar(n,e)})):Jn(r,e,t))),this.L);let a=!1;return{next:()=>{if(a)return A;const e=r.O();return a=!0,E({da:n,I:e})}}}A(e,t,[n,...r]){if(this.l)return gr(this.l,((e,t,n,...r)=>this.l.value(e,t,n,...r)),e,t,this.S,r,this.L);const a=n(e);return a.Y({default:()=>{throw dr()},m:()=>a.N((([n])=>{if((n=fr(n,this.ma)).J)throw Error("XUDY0038: The function returned by the PrimaryExpr of a dynamic function invocation can not be an updating function");return gr(n,n.value,e,t,this.S,r,this.L)}))})}v(e){if(this.L=la(e),super.v(e),this.ya.B){if(!(e=Jn(this.ya,null,null)).ua())throw dr();this.l=fr(e.first(),this.ma),this.l.J&&(this.J=!0)}}};const wr=(e,t,n,r,a,o)=>ue([r,a,o],(([e,t,n])=>{if(t=t.value,n=n.value,t>e.h.length||0>=t)throw Error("FOAY0001: subarray start out of bounds.");if(0>n)throw Error("FOAY0002: subarray length out of bounds.");if(t+n>e.h.length+1)throw Error("FOAY0001: subarray start + length out of bounds.");return $.m(new ie(e.h.slice(t-1,n+t-1)))})),vr=(e,t,n,r,a)=>ue([r],(([e])=>a.N((t=>{t=t.map((e=>e.value)).sort(((e,t)=>t-e)).filter(((e,t,n)=>n[t-1]!==e));const n=e.h.concat();for(let r=0,a=t.length;r<a;++r){const a=t[r];if(a>e.h.length||0>=a)throw Error("FOAY0001: subarray position out of bounds.");n.splice(a-1,1)}return $.m(new ie(n))})))),xr=e=>T(e,1)||T(e,20)||T(e,19),br=(e,t,n,r,a)=>0===r.length?0!==a.length:0!==a.length&&Un(e,t,n,r[0],a[0]).next(0).value?br(e,t,n,r.slice(1),a.slice(1)):r[0].value!=r[0].value||(xr(r[0].type)&&0!==a.length&&xr(a[0].type)||0!==a.length)&&r[0].value<a[0].value;function Ar(e){return T(e.type,62)?Qe(e.h.map((e=>e().N((e=>Qe(e.map(Ar))))))):$.m(e)}var Er=[{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"size",j:[{type:62,g:3}],i:{type:5,g:3},callFunction:(e,t,n,r)=>ue([r],(([e])=>$.m(y(e.h.length,5))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"get",j:[{type:62,g:3},{type:5,g:3}],i:{type:59,g:2},callFunction:se},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"put",j:[{type:62,g:3},{type:5,g:3},{type:59,g:2}],i:{type:62,g:3},callFunction:(e,t,n,r,a,o)=>ue([a,r],(([e,t])=>{if(0>=(e=e.value)||e>t.h.length)throw Error("FOAY0001: array position out of bounds.");return(t=t.h.concat()).splice(e-1,1,L(o)),$.m(new ie(t))}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"append",j:[{type:62,g:3},{type:59,g:2}],i:{type:62,g:3},callFunction:(e,t,n,r,a)=>ue([r],(([e])=>$.m(new ie(e.h.concat([L(a)])))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"subarray",j:[{type:62,g:3},{type:5,g:3},{type:5,g:3}],i:{type:62,g:3},callFunction:wr},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"subarray",j:[{type:62,g:3},{type:5,g:3}],i:{type:62,g:3},callFunction(e,t,n,r,a){const o=$.m(y(r.first().value.length-a.first().value+1,5));return wr(0,0,0,r,a,o)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"remove",j:[{type:62,g:3},{type:5,g:2}],i:{type:62,g:3},callFunction:vr},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"insert-before",j:[{type:62,g:3},{type:5,g:3},{type:59,g:2}],i:{type:62,g:3},callFunction:(e,t,n,r,a,o)=>ue([r,a],(([e,t])=>{if((t=t.value)>e.h.length+1||0>=t)throw Error("FOAY0001: subarray position out of bounds.");return(e=e.h.concat()).splice(t-1,0,L(o)),$.m(new ie(e))}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"head",j:[{type:62,g:3}],i:{type:59,g:2},callFunction:(e,t,n,r)=>se(0,0,0,r,$.m(y(1,5)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"tail",j:[{type:62,g:3}],i:{type:59,g:2},callFunction:(e,t,n,r)=>vr(0,0,0,r,$.m(y(1,5)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"reverse",j:[{type:62,g:3}],i:{type:62,g:3},callFunction:(e,t,n,r)=>ue([r],(([e])=>$.m(new ie(e.h.concat().reverse()))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"join",j:[{type:62,g:2}],i:{type:62,g:3},callFunction:(e,t,n,r)=>r.N((e=>(e=e.reduce(((e,t)=>e.concat(t.h)),[]),$.m(new ie(e)))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"for-each",j:[{type:62,g:3},{type:60,g:3}],i:{type:62,g:3},callFunction:(e,t,n,r,a)=>ue([r,a],(([r,a])=>{if(1!==a.v)throw Ze("The callback passed into array:for-each has a wrong arity.");return r=r.h.map((r=>L(a.value.call(void 0,e,t,n,mr(a.o,[r()],t,"array:for-each")[0])))),$.m(new ie(r))}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"filter",j:[{type:62,g:3},{type:60,g:3}],i:{type:62,g:3},callFunction:(e,t,n,r,a)=>ue([r,a],(([r,a])=>{if(1!==a.v)throw Ze("The callback passed into array:filter has a wrong arity.");const o=r.h.map((r=>{r=mr(a.o,[r()],t,"array:filter")[0];return(0,a.value)(e,t,n,r)})),s=[];let i=!1;return $.create({next:()=>{if(i)return A;for(let t=0,n=r.h.length;t<n;++t){var e=o[t].fa();s[t]=e}return e=r.h.filter(((e,t)=>s[t])),i=!0,E(new ie(e))}})}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"fold-left",j:[{type:62,g:3},{type:59,g:2},{type:60,g:3}],i:{type:59,g:2},callFunction:(e,t,n,r,a,o)=>ue([r,o],(([r,o])=>{if(2!==o.v)throw Ze("The callback passed into array:fold-left has a wrong arity.");return r.h.reduce(((r,a)=>(a=mr(o.o,[a()],t,"array:fold-left")[0],o.value.call(void 0,e,t,n,r,a))),a)}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"fold-right",j:[{type:62,g:3},{type:59,g:2},{type:60,g:3}],i:{type:59,g:2},callFunction:(e,t,n,r,a,o)=>ue([r,o],(([r,o])=>{if(2!==o.v)throw Ze("The callback passed into array:fold-right has a wrong arity.");return r.h.reduceRight(((r,a)=>(a=mr(o.o,[a()],t,"array:fold-right")[0],o.value.call(void 0,e,t,n,r,a))),a)}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"for-each-pair",j:[{type:62,g:3},{type:62,g:3},{type:60,g:3}],i:{type:62,g:3},callFunction:(e,t,n,r,a,o)=>ue([r,a,o],(([r,a,o])=>{if(2!==o.v)throw Ze("The callback passed into array:for-each-pair has a wrong arity.");const s=[];for(let i=0,l=Math.min(r.h.length,a.h.length);i<l;++i){const[l,c]=mr(o.o,[r.h[i](),a.h[i]()],t,"array:for-each-pair");s[i]=L(o.value.call(void 0,e,t,n,l,c))}return $.m(new ie(s))}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"sort",j:[{type:62,g:3}],i:{type:62,g:3},callFunction:(e,t,n,r)=>ue([r],(([r])=>(r=r.h.map((e=>e().O())),((e,t,n,r)=>(r.sort(((r,a)=>Rn(e,t,n,$.create(r),$.create(a)).next(0).value?0:br(e,t,n,r,a)?-1:1)),$.m(new ie(r.map((e=>()=>$.create(e)))))))(e,t,n,r))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"flatten",j:[{type:59,g:2}],i:{type:59,g:2},callFunction:(e,t,n,r)=>r.N((e=>Qe(e.map(Ar))))}];function Nr(e,t,n,r,a){return a.G()?a:$.m(At(a.first(),e))}var Tr=[{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"untypedAtomic",j:[{type:46,g:0}],i:{type:19,g:0},callFunction:Nr.bind(null,19)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"error",j:[{type:46,g:0}],i:{type:39,g:0},callFunction:Nr.bind(null,39)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"string",j:[{type:46,g:0}],i:{type:1,g:0},callFunction:Nr.bind(null,1)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"boolean",j:[{type:46,g:0}],i:{type:0,g:0},callFunction:Nr.bind(null,0)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"decimal",j:[{type:46,g:0}],i:{type:4,g:0},callFunction:Nr.bind(null,4)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"float",j:[{type:46,g:0}],i:{type:6,g:0},callFunction:Nr.bind(null,6)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"double",j:[{type:46,g:0}],i:{type:3,g:0},callFunction:Nr.bind(null,3)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"duration",j:[{type:46,g:0}],i:{type:18,g:0},callFunction:Nr.bind(null,18)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTime",j:[{type:46,g:0}],i:{type:9,g:0},callFunction:Nr.bind(null,9)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTimeStamp",j:[{type:46,g:0}],i:{type:10,g:0},callFunction:Nr.bind(null,10)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"time",j:[{type:46,g:0}],i:{type:8,g:0},callFunction:Nr.bind(null,8)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"date",j:[{type:46,g:0}],i:{type:7,g:0},callFunction:Nr.bind(null,7)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gYearMonth",j:[{type:46,g:0}],i:{type:11,g:0},callFunction:Nr.bind(null,11)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gYear",j:[{type:46,g:0}],i:{type:12,g:0},callFunction:Nr.bind(null,12)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gMonthDay",j:[{type:46,g:0}],i:{type:13,g:0},callFunction:Nr.bind(null,13)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gDay",j:[{type:46,g:0}],i:{type:15,g:0},callFunction:Nr.bind(null,15)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gMonth",j:[{type:46,g:0}],i:{type:14,g:0},callFunction:Nr.bind(null,14)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"hexBinary",j:[{type:46,g:0}],i:{type:22,g:0},callFunction:Nr.bind(null,22)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"base64Binary",j:[{type:46,g:0}],i:{type:21,g:0},callFunction:Nr.bind(null,21)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"QName",j:[{type:46,g:0}],i:{type:23,g:0},callFunction:(e,t,n,r)=>{if(r.G())return r;if(T((e=r.first()).type,2))throw Error("XPTY0004: The provided QName is not a string-like value.");if(!st(e=ot(e=At(e,1).value,23),23))throw Error("FORG0001: The provided QName is invalid.");if(!e.includes(":"))return n=n.$(""),$.m(y(new H("",n,e),23));const[a,o]=e.split(":");if(!(n=n.$(a)))throw Error(`FONS0004: The value ${e} can not be cast to a QName. Did you mean to use fn:QName?`);return $.m(y(new H(a,n,o),23))}},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"anyURI",j:[{type:46,g:0}],i:{type:20,g:0},callFunction:Nr.bind(null,20)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"normalizedString",j:[{type:46,g:0}],i:{type:48,g:0},callFunction:Nr.bind(null,48)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"token",j:[{type:46,g:0}],i:{type:52,g:0},callFunction:Nr.bind(null,52)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"language",j:[{type:46,g:0}],i:{type:51,g:0},callFunction:Nr.bind(null,51)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NMTOKEN",j:[{type:46,g:0}],i:{type:50,g:0},callFunction:Nr.bind(null,50)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NMTOKENS",j:[{type:46,g:0}],i:{type:49,g:2},callFunction:Nr.bind(null,49)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"Name",j:[{type:46,g:0}],i:{type:25,g:0},callFunction:Nr.bind(null,25)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NCName",j:[{type:46,g:0}],i:{type:24,g:0},callFunction:Nr.bind(null,24)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"ID",j:[{type:46,g:0}],i:{type:42,g:0},callFunction:Nr.bind(null,42)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"IDREF",j:[{type:46,g:0}],i:{type:41,g:0},callFunction:Nr.bind(null,41)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"IDREFS",j:[{type:46,g:0}],i:{type:43,g:2},callFunction:Nr.bind(null,43)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"ENTITY",j:[{type:46,g:0}],i:{type:26,g:0},callFunction:Nr.bind(null,26)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"ENTITIES",j:[{type:46,g:0}],i:{type:40,g:2},callFunction:Nr.bind(null,40)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"integer",j:[{type:46,g:0}],i:{type:5,g:0},callFunction:Nr.bind(null,5)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"nonPositiveInteger",j:[{type:46,g:0}],i:{type:27,g:0},callFunction:Nr.bind(null,27)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"negativeInteger",j:[{type:46,g:0}],i:{type:28,g:0},callFunction:Nr.bind(null,28)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"long",j:[{type:46,g:0}],i:{type:31,g:0},callFunction:Nr.bind(null,31)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"int",j:[{type:46,g:0}],i:{type:32,g:0},callFunction:Nr.bind(null,32)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"short",j:[{type:46,g:0}],i:{type:33,g:0},callFunction:Nr.bind(null,33)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"byte",j:[{type:46,g:0}],i:{type:34,g:0},callFunction:Nr.bind(null,34)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"nonNegativeInteger",j:[{type:46,g:0}],i:{type:30,g:0},callFunction:Nr.bind(null,30)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedLong",j:[{type:46,g:0}],i:{type:36,g:0},callFunction:Nr.bind(null,36)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedInt",j:[{type:46,g:0}],i:{type:35,g:0},callFunction:Nr.bind(null,35)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedShort",j:[{type:46,g:0}],i:{type:38,g:0},callFunction:Nr.bind(null,38)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedByte",j:[{type:46,g:0}],i:{type:37,g:0},callFunction:Nr.bind(null,37)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"positiveInteger",j:[{type:46,g:0}],i:{type:29,g:0},callFunction:Nr.bind(null,29)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"yearMonthDuration",j:[{type:46,g:0}],i:{type:16,g:0},callFunction:Nr.bind(null,16)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dayTimeDuration",j:[{type:46,g:0}],i:{type:17,g:0},callFunction:Nr.bind(null,17)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTimeStamp",j:[{type:46,g:0}],i:{type:10,g:0},callFunction:Nr.bind(null,10)}];const Br=(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.getYear(),5)),Ir=(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.getMonth(),5)),Cr=(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.getDay(),5)),Sr=(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.getHours(),5)),Or=(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.getMinutes(),5)),Fr=(e,t,n,r)=>(r.G()||(t=(e=$).m,r=r.first().value,r=t.call(e,y(r.D+r.pa,4))),r),Dr=(e,t,n,r)=>r.G()?r:(e=r.first().value.X)?$.m(y(e,17)):$.empty();var kr=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"dateTime",j:[{type:7,g:0},{type:8,g:0}],i:{type:9,g:0},callFunction:(e,t,n,r,a)=>{if(r.G())return r;if(a.G())return a;if(e=r.first().value,a=a.first().value,t=e.X,n=a.X,t||n){if(!t||n)if(!t&&n)t=n;else if(!me(t,n))throw Error("FORG0008: fn:dateTime: got a date and time value with different timezones.")}else t=null;return $.m(y(new Oe(e.getYear(),e.getMonth(),e.getDay(),a.getHours(),a.getMinutes(),a.getSeconds(),a.pa,t),9))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"year-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Br},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"month-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Ir},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"day-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Cr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Sr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Or},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-dateTime",j:[{type:9,g:0}],i:{type:4,g:0},callFunction:Fr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-dateTime",j:[{type:9,g:0}],i:{type:17,g:0},callFunction:Dr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"year-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:Br},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"month-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:Ir},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"day-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:Cr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-date",j:[{type:7,g:0}],i:{type:17,g:0},callFunction:Dr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-time",j:[{type:8,g:0}],i:{type:5,g:0},callFunction:Sr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-time",j:[{type:8,g:0}],i:{type:5,g:0},callFunction:Or},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-time",j:[{type:8,g:0}],i:{type:4,g:0},callFunction:Fr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-time",j:[{type:8,g:0}],i:{type:17,g:0},callFunction:Dr}];function Rr(e,t){const n=t.h,r=t.Ia,a=t.Ma;switch(e.node.nodeType){case 1:const s=r.createElementNS(e.node.namespaceURI,e.node.nodeName);for(var o of(n.getAllAttributes(e.node).forEach((e=>a.setAttributeNS(s,e.namespaceURI,e.nodeName,e.value))),W(n,e)))e=Rr(o,t),a.insertBefore(s,e.node,null);return{node:s,F:null};case 2:return(t=r.createAttributeNS(e.node.namespaceURI,e.node.nodeName)).value=Z(n,e),{node:t,F:null};case 4:return{node:r.createCDATASection(Z(n,e)),F:null};case 8:return{node:r.createComment(Z(n,e)),F:null};case 9:o=r.createDocument();for(const r of W(n,e))e=Rr(r,t),a.insertBefore(o,e.node,null);return{node:o,F:null};case 7:return{node:r.createProcessingInstruction(e.node.target,Z(n,e)),F:null};case 3:return{node:r.createTextNode(Z(n,e)),F:null}}}function Mr(e,t){const n=t.Ma;var r=t.Ia;const a=t.h;if(!z(e.node))return Rr(e,t).node;switch(e.node.nodeType){case 2:return(r=r.createAttributeNS(e.node.namespaceURI,e.node.nodeName)).value=Z(a,e),r;case 8:return r.createComment(Z(a,e));case 1:const o=e.node.prefix,s=e.node.localName,i=r.createElementNS(e.node.namespaceURI,o?o+":"+s:s);return W(a,e).forEach((e=>{e=Mr(e,t),n.insertBefore(i,e,null)})),Q(a,e).forEach((e=>{n.setAttributeNS(i,e.node.namespaceURI,e.node.nodeName,Z(a,e))})),i.normalize(),i;case 7:return r.createProcessingInstruction(e.node.target,Z(a,e));case 3:return r.createTextNode(Z(a,e))}}function Ur(e,t,n){var r=e.node;if(!(z(r)||n||e.F))return r;r=t.v;const a=[];return n?Mr(e,t):(e=function(e,t,n){let r=e;for(e=ne(n,r);null!==e;){if(2===r.node.nodeType)t.push(r.node.nodeName);else{const a=W(n,e);t.push(a.findIndex((e=>Tt(e,r))))}r=e,e=ne(n,r)}return r}(e,a,t.h),(n=r.get(e.node))||(n={node:Mr(e,t),F:null},r.set(e.node,n)),function(e,t,n){for(;0<t.length;){const r=t.pop();e="string"==typeof r?Q(n,e).find((e=>e.node.nodeName===r)):W(n,e)[r]}return e.node}(n,a,t.h))}const Gr=(e,t,n,r,a)=>r.N((e=>{let n="";for(let r=0;r<e.length;r++){const a=e[r],o=t.Ua&&T(a.type,53)?t.Ua.serializeToString(Ur(a.value,t,!1)):rt($.m(a),t).map((e=>At(e,1))).first().value;n+=`{type: ${C[a.type]}, value: ${o}}\n`}return void 0!==a&&(n+=a.first().value),t.ib.trace(n),$.create(e)}));var $r=[{j:[{type:59,g:2}],callFunction:Gr,localName:"trace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:1,g:3}],callFunction:Gr,localName:"trace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}}];const Lr=(e,t,n,r,a)=>{throw e=void 0===r||r.G()?new H("err","http://www.w3.org/2005/xqt-errors","FOER0000"):r.first().value,t="",void 0===a||a.G()||(t=`: ${a.first().value}`),Error(`${e.localName}${t}`)};var Hr=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[],i:{type:63,g:3},callFunction:Lr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[{type:23,g:0}],i:{type:63,g:3},callFunction:Lr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[{type:23,g:0},{type:1,g:3}],i:{type:63,g:3},callFunction:Lr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[{type:23,g:0},{type:1,g:3},{type:59,g:2}],i:{type:63,g:3},callFunction(){throw Error("Not implemented: Using an error object in error is not supported")}}];function Pr(e){return"string"==typeof e?e:(e=(new q).getChildNodes(e).find((e=>8===e.nodeType)))?e.data:"some expression"}var jr=class extends Error{constructor(e,t){super(e),this.position={end:{ha:t.end.ha,line:t.end.line,offset:t.end.offset},start:{ha:t.start.ha,line:t.start.line,offset:t.start.offset}}}};function _r(e,t){if(t instanceof Error)throw t;"string"!=typeof e&&(e=Pr(e));const n=mo(t);e=e.replace(/\r/g,"").split("\n");const r=Math.floor(Math.log10(Math.min(n.end.line+2,e.length)))+1;throw e=e.reduce(((e,t,a)=>{var o=a+1;if(2<n.start.line-o||2<o-n.end.line)return e;if(a=`${Array(r).fill(" ",0,Math.floor(Math.log10(o))+1-r).join("")}${o}: `,e.push(`${a}${t}`),o>=n.start.line&&o<=n.end.line){const r=o<n.end.line?t.length+a.length:n.end.ha-1+a.length;o=o>n.start.line?a.length:n.start.ha-1+a.length,t=" ".repeat(a.length)+Array.from(t.substring(0,o-a.length),(e=>"\t"===e?"\t":" ")).join("")+"^".repeat(r-o),e.push(t)}return e}),[]),t=fo(t).join("\n"),new jr(e.join("\n")+"\n\n"+t,n)}const Xr=Object.create(null);function qr(e,t){const n=new Map;for(let t=0;t<e.length+1;++t)n.set(t,new Map);return function r(a,o){if(0===a)return o;if(0===o)return a;if(n.get(a).has(o))return n.get(a).get(o);var s=0;return e[a-1]!==t[o-1]&&(s=1),s=Math.min(r(a-1,o)+1,r(a,o-1)+1,r(a-1,o-1)+s),n.get(a).set(o,s),s}(e.length,t.length)}function Vr(e){const t=Xr[e]?Xr[e]:Object.keys(Xr).map((t=>({name:t,qb:qr(e,t.slice(t.lastIndexOf(":")+1))}))).sort(((e,t)=>e.qb-t.qb)).slice(0,5).filter((t=>t.qb<e.length/2)).reduce(((e,t)=>e.concat(Xr[t.name])),[]).slice(0,5);return t.length?t.map((e=>`"Q{${e.namespaceURI}}${e.localName} (${e.j.map((e=>4===e?"...":O(e))).join(", ")})"`)).reduce(((e,t,n,r)=>0===n?e+t:e+(n!==r.length-1?", ":" or ")+t),"Did you mean ")+"?":"No similar functions found."}function Yr(e,t,n){var r=Xr[e+":"+t];return r&&(r=r.find((e=>e.j.some((e=>4===e))?e.j.length-1<=n:e.j.length===n)))?{j:r.j,arity:n,callFunction:r.callFunction,J:r.J,localName:t,namespaceURI:e,i:r.i}:null}function zr(e,t,n,r,a){Xr[e+":"+t]||(Xr[e+":"+t]=[]),Xr[e+":"+t].push({j:n,arity:n.length,callFunction:a,J:!1,localName:t,namespaceURI:e,i:r})}var Jr={xml:"http://www.w3.org/XML/1998/namespace",xs:"http://www.w3.org/2001/XMLSchema",fn:"http://www.w3.org/2005/xpath-functions",map:"http://www.w3.org/2005/xpath-functions/map",array:"http://www.w3.org/2005/xpath-functions/array",math:"http://www.w3.org/2005/xpath-functions/math",fontoxpath:"http://fontoxml.com/fontoxpath",local:"http://www.w3.org/2005/xquery-local-functions"},Qr=class{constructor(e,t,n,r){this.Da=[Object.create(null)],this.Ea=Object.create(null),this.s=e,this.ia=Object.keys(t).reduce(((e,n)=>(void 0===t[n]||(e[n]=`Q{}${n}[0]`),e)),Object.create(null)),this.o=Object.create(null),this.h=Object.create(null),this.v=n,this.l=r,this.D=[]}va(e,t,n){return Yr(e,t,n)}cb(e,t){return e?null:(e=this.ia[t],this.o[t]||(this.o[t]={name:t}),e)}Sa(e,t){const n=this.l(e,t);if(n)this.D.push({ac:e,arity:t,Bb:n});else if(""===e.prefix){if(this.v)return{namespaceURI:this.v,localName:e.localName}}else if(t=this.$(e.prefix,!0))return{namespaceURI:t,localName:e.localName};return n}$(e,t=!0){return t?Jr[e]?Jr[e]:(t=this.s(e),this.h[e]||(this.h[e]={namespaceURI:t,prefix:e}),void 0!==t||e?t:null):null}},Kr=(e,t)=>(e=2===e.node.nodeType?`${e.node.nodeName}="${Z(t,e)}"`:e.node.outerHTML,Error(`XQTY0024: The node ${e} follows a node that is not an attribute node or a namespace node.`)),Wr=e=>Error(`XQDY0044: The node name "${e.za()}" is invalid for a computed attribute constructor.`),Zr=()=>Error("XQST0045: Functions and variables may not be declared in one of the reserved namespace URIs."),ea=(e,t)=>Error(`XQST0049: The function or variable "Q{${e}}${t}" is declared more than once.`),ta=()=>Error("XQST0060: Functions declared in a module or as an external function must reside in a namespace."),na=()=>Error("XQST0066: A Prolog may contain at most one default function namespace declaration."),ra=()=>Error("XQST0070: The prefixes xml and xmlns may not be used in a namespace declaration or be bound to another namespaceURI."),aa=e=>Error(`XQDY0074: The value "${e}" of a name expressions cannot be converted to an expanded QName.`),oa=e=>Error(`XPST0081: The prefix "${e}" could not be resolved`);function sa(e,t){return`Q{${e||""}}${t}`}function ia(e,t){for(let n=e.length-1;0<=n;--n)if(t in e[n])return e[n][t]}function la(e){const t=new fa(e.o);for(let n=0;n<e.h+1;++n)t.D=[Object.assign(Object.create(null),t.D[0],e.D[n])],t.Da=[Object.assign(Object.create(null),t.Da[0],e.Da[n])],t.l=Object.assign(Object.create(null),e.l),t.Ea=e.Ea,t.v=e.v;return t}function ca(e){e.s++,e.h++,e.D[e.h]=Object.create(null),e.Da[e.h]=Object.create(null)}function ua(e,t,n,r,a){if(r=sa(t,n)+"~"+r,e.l[r])throw ea(t,n);e.l[r]=a}function pa(e,t,n){e.D[e.h][t]=n}function ha(e,t,n){return t=sa(t||"",n),e.Da[e.h][t]=`${t}[${e.s}]`}function da(e,t,n,r){e.Ea[`${sa(t||"",n)}[${e.s}]`]=r}function ma(e){e.D.length=e.h,e.Da.length=e.h,e.h--}var fa=class{constructor(e){this.o=e,this.s=this.h=0,this.D=[Object.create(null)],this.l=Object.create(null),this.v=null,this.Ea=e&&e.Ea,this.Da=e&&e.Da}va(e,t,n,r=!1){const a=this.l[sa(e,t)+"~"+n];return!a||r&&a.ub?null===this.o?null:this.o.va(e,t,n,r):a}cb(e,t){const n=ia(this.Da,sa(e,t));return n||(null===this.o?null:this.o.cb(e,t))}Sa(e,t){var n=e.prefix;const r=e.localName;return""===n&&this.v?{localName:r,namespaceURI:this.v}:n&&(n=this.$(n,!1))?{localName:r,namespaceURI:n}:null===this.o?null:this.o.Sa(e,t)}$(e,t=!0){const n=ia(this.D,e||"");return void 0===n?null===this.o?void 0:this.o.$(e||"",t):n}};function ga(e,t){"*"===t||Array.isArray(t)||(t=[t]);for(let n=1;n<e.length;++n){if(!Array.isArray(e[n]))continue;const r=e[n];if("*"===t||t.includes(r[0]))return r}return null}function ya(e){return 2>e.length?"":"object"==typeof e[1]?e[2]||"":e[1]||""}function wa(e,t){return Array.isArray(e)?"object"!=typeof(e=e[1])||Array.isArray(e)?null:t in e?e[t]:null:null}function va(e,t){return t.reduce(ga,e)}function xa(e,t){const n=[];for(let r=1;r<e.length;++r){if(!Array.isArray(e[r]))continue;const a=e[r];"*"!==t&&a[0]!==t||n.push(a)}return n}function ba(e){return{localName:ya(e),namespaceURI:wa(e,"URI"),prefix:wa(e,"prefix")}}function Aa(e){const t=ga(e,"typeDeclaration");if(!t||ga(t,"voidSequenceType"))return{type:59,g:2};const n=e=>{switch(e[0]){case"documentTest":return 55;case"elementTest":return 54;case"attributeTest":return 47;case"piTest":return 57;case"commentTest":return 58;case"textTest":return 56;case"anyKindTest":return 53;case"anyItemType":return 59;case"anyFunctionTest":case"functionTest":case"typedFunctionTest":return 60;case"anyMapTest":case"typedMapTest":return 61;case"anyArrayTest":case"typedArrayTest":return 62;case"atomicType":return F([wa(e,"prefix"),ya(e)].join(":"));case"parenthesizedItemType":return n(ga(e,"*"));default:throw Error(`Type declaration "${ga(t,"*")[0]}" is not supported.`)}};e={type:n(ga(t,"*")),g:3};let r=null;const a=ga(t,"occurrenceIndicator");switch(a&&(r=ya(a)),r){case"*":return e.g=2,e;case"?":return e.g=0,e;case"+":return e.g=1,e;case"":case null:return e}}function Ea(e,t,n){if("object"!=typeof e[1]||Array.isArray(e[1])){const r={};r[t]=n,e.splice(1,0,r)}else e[1][t]=n}function Na(e,t,n){return(e<<20)+(t<<12)+(n.charCodeAt(0)<<8)+n.charCodeAt(1)}var Ta={[Na(2,2,"idivOp")]:5,[Na(16,16,"addOp")]:16,[Na(16,16,"subtractOp")]:16,[Na(16,16,"divOp")]:4,[Na(16,2,"multiplyOp")]:16,[Na(16,2,"divOp")]:16,[Na(2,16,"multiplyOp")]:16,[Na(17,17,"addOp")]:17,[Na(17,17,"subtractOp")]:17,[Na(17,17,"divOp")]:4,[Na(17,2,"multiplyOp")]:17,[Na(17,2,"divOp")]:17,[Na(2,17,"multiplyOp")]:17,[Na(9,9,"subtractOp")]:17,[Na(7,7,"subtractOp")]:17,[Na(8,8,"subtractOp")]:17,[Na(9,16,"addOp")]:9,[Na(9,16,"subtractOp")]:9,[Na(9,17,"addOp")]:9,[Na(9,17,"subtractOp")]:9,[Na(7,16,"addOp")]:7,[Na(7,16,"subtractOp")]:7,[Na(7,17,"addOp")]:7,[Na(7,17,"subtractOp")]:7,[Na(8,17,"addOp")]:8,[Na(8,17,"subtractOp")]:8,[Na(9,16,"addOp")]:9,[Na(9,16,"subtractOp")]:9,[Na(9,17,"addOp")]:9,[Na(9,17,"subtractOp")]:9,[Na(7,17,"addOp")]:7,[Na(7,17,"subtractOp")]:7,[Na(7,16,"addOp")]:7,[Na(7,16,"subtractOp")]:7,[Na(8,17,"addOp")]:8,[Na(8,17,"subtractOp")]:8},Ba={[Na(2,2,"addOp")]:(e,t)=>e+t,[Na(2,2,"subtractOp")]:(e,t)=>e-t,[Na(2,2,"multiplyOp")]:(e,t)=>e*t,[Na(2,2,"divOp")]:(e,t)=>e/t,[Na(2,2,"modOp")]:(e,t)=>e%t,[Na(2,2,"idivOp")]:(e,t)=>Math.trunc(e/t),[Na(16,16,"addOp")]:function(e,t){return new pt(e.ea+t.ea)},[Na(16,16,"subtractOp")]:function(e,t){return new pt(e.ea-t.ea)},[Na(16,16,"divOp")]:function(e,t){return e.ea/t.ea},[Na(16,2,"multiplyOp")]:dt,[Na(16,2,"divOp")]:function(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot divide xs:yearMonthDuration by NaN");if((e=Math.round(e.ea/t))>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while dividing xs:yearMonthDuration");return new pt(e<Number.MIN_SAFE_INTEGER||0===e?0:e)},[Na(2,16,"multiplyOp")]:(e,t)=>dt(t,e),[Na(17,17,"addOp")]:function(e,t){return new ye(e.ca+t.ca)},[Na(17,17,"subtractOp")]:function(e,t){return new ye(e.ca-t.ca)},[Na(17,17,"divOp")]:function(e,t){if(0===t.ca)throw Error("FOAR0001: Division by 0");return e.ca/t.ca},[Na(17,2,"multiplyOp")]:be,[Na(17,2,"divOp")]:function(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot divide xs:dayTimeDuration by NaN");if((e=e.ca/t)>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while dividing xs:dayTimeDuration");return new ye(e<Number.MIN_SAFE_INTEGER||Object.is(-0,e)?0:e)},[Na(2,17,"multiplyOp")]:(e,t)=>be(t,e),[Na(9,9,"subtractOp")]:ke,[Na(7,7,"subtractOp")]:ke,[Na(8,8,"subtractOp")]:ke,[Na(9,16,"addOp")]:Re,[Na(9,16,"subtractOp")]:Me,[Na(9,17,"addOp")]:Re,[Na(9,17,"subtractOp")]:Me,[Na(7,16,"addOp")]:Re,[Na(7,16,"subtractOp")]:Me,[Na(7,17,"addOp")]:Re,[Na(7,17,"subtractOp")]:Me,[Na(8,17,"addOp")]:Re,[Na(8,17,"subtractOp")]:Me,[Na(9,16,"addOp")]:Re,[Na(9,16,"subtractOp")]:Me,[Na(9,17,"addOp")]:Re,[Na(9,17,"subtractOp")]:Me,[Na(7,17,"addOp")]:Re,[Na(7,17,"subtractOp")]:Me,[Na(7,16,"addOp")]:Re,[Na(7,16,"subtractOp")]:Me,[Na(8,17,"addOp")]:Re,[Na(8,17,"subtractOp")]:Me};function Ia(e,t){return T(e,5)&&T(t,5)?5:T(e,4)&&T(t,4)?4:T(e,6)&&T(t,6)?6:3}const Ca=[2,16,17,9,7,8];function Sa(e,t,n){function r(e,t){return{T:a?a(e):e,U:o?o(t):t}}let a=null,o=null;T(t,19)&&(a=e=>At(e,3),t=3),T(n,19)&&(o=e=>At(e,3),n=3);const s=Ca.filter((e=>T(t,e))),i=Ca.filter((e=>T(n,e)));if(s.includes(2)&&i.includes(2)){const a=Ba[Na(2,2,e)];let o=Ta[Na(2,2,e)];return o||=Ia(t,n),"divOp"===e&&5===o&&(o=4),"idivOp"===e?Oa(r,a)[0]:(e,t)=>{const{T:n,U:s}=r(e,t);return y(a(n.value,s.value),o)}}for(const t of s)for(const n of i){const a=Ba[Na(t,n,e)],o=Ta[Na(t,n,e)];if(a&&void 0!==o)return(e,t)=>{const{T:n,U:s}=r(e,t);return y(a(n.value,s.value),o)}}}function Oa(e,t){return[(n,r)=>{const{T:a,U:o}=e(n,r);if(0===o.value)throw Error("FOAR0001: Divisor of idiv operator cannot be (-)0");if(Number.isNaN(a.value)||Number.isNaN(o.value)||!Number.isFinite(a.value))throw Error("FOAR0002: One of the operands of idiv is NaN or the first operand is (-)INF");return Number.isFinite(a.value)&&!Number.isFinite(o.value)?y(0,5):y(t(a.value,o.value),5)},5]}const Fa=Object.create(null);var Da=class extends Qn{constructor(e,t,n,r,a){super(t.o.add(n.o),[t,n],{B:!1},!1,r),this.A=t,this.L=n,this.l=e,this.s=a}h(e,t){return rt(Jn(this.A,e,t),t).N((n=>0===n.length?$.empty():rt(Jn(this.L,e,t),t).N((e=>{if(0===e.length)return $.empty();if(1<n.length||1<e.length)throw Error('XPTY0004: the operands of the "'+this.l+'" operator should be empty or singleton.');const t=n[0];if(e=e[0],this.s&&this.type)return $.m(this.s(t,e));var r=t.type,a=e.type,o=this.l;const s=`${r}~${a}~${o}`;let i=Fa[s];if(i||=Fa[s]=Sa(o,r,a),!(r=i))throw Error(`XPTY0004: ${this.l} not available for types ${C[t.type]} and ${C[e.type]}`);return $.m(r(t,e))}))))}};function ka(e,t,n){const r=ba(va(e,["forClauseItem","typedVariableBinding","varName"]));(e=va(e,["forClauseItem","forExpr","sequenceExpr"]))&&(e=xa(e,"*").map((e=>n(e,t))),e.includes(void 0)||e.includes(null)||1===(e=Ra(e)).length&&Va(t,r.localName,e[0]))}function Ra(e){return e.filter(((e,t,n)=>n.findIndex((t=>t.type===e.type&&t.g===e.g))===t))}function Ma(e,t,n){const r=xa(e,"*"),a=ga(e,"atomicType");if(!a)return{type:59,g:2};if(F(wa(a,"prefix")+":"+a[2])===t.type)if(1===r.length){if(3===t.g)return n}else if(e=ga(e,"occurrenceIndicator")[1],t.g===function(e){switch(e){case"*":return 2;case"?":return 0;case"+":return 1;default:return 3}}(e))return n}function Ua(e,t){Ga(e,t)}function Ga(e,t){var n=Xa.get(e[0]);if(n)return n(e,t);for(n=1;n<e.length;n++)e[n]&&Ga(e[n],t)}const $a=(e,t)=>{var n=Ga(ga(e,"firstOperand")[1],t);const r=Ga(ga(e,"secondOperand")[1],t);var a=e[0];if(n&&r){if(!(t=function(e,t,n){var r=[2,53,59,46,47];if(r.includes(t)||r.includes(n))return 2;let a=null,o=null;T(t,19)&&(a=e=>At(e,3),t=3),T(n,19)&&(o=e=>At(e,3),n=3);var s=Ca.filter((e=>T(t,e)));if(r=Ca.filter((e=>T(n,e))),s.includes(2)&&r.includes(2)){var i=Ta[Na(2,2,e)];return void 0===i&&(i=Ia(t,n)),"divOp"===e&&5===i&&(i=4),"idivOp"===e?Oa((function(e,t){return{T:a?a(e):e,U:o?o(t):t}}),((e,t)=>Math.trunc(e/t)))[1]:i}for(i of s)for(const t of r)if(s=Ta[Na(i,t,e)],void 0!==s)return s}(a,n.type,r.type)))throw Error(`XPTY0004: ${a} not available for types ${O(n)} and ${O(r)}`);n={type:t,g:n.g},2!==t&&59!==t&&Ea(e,"type",n),e=n}else e={type:2,g:3};return e},La=(e,t)=>{Ga(ga(e,"firstOperand")[1],t),Ga(ga(e,"secondOperand")[1],t);e:{switch(e[0]){case"orOp":case"andOp":Ea(e,"type",t={type:0,g:3}),e=t;break e}e=void 0}return e},Ha=(e,t)=>{Ga(ga(e,"firstOperand")[1],t),Ga(ga(e,"secondOperand")[1],t);e:{switch(e[0]){case"unionOp":case"intersectOp":case"exceptOp":Ea(e,"type",t={type:53,g:2}),e=t;break e}e=void 0}return e},Pa=(e,t)=>(Ga(ga(e,"firstOperand")[1],t),Ga(ga(e,"secondOperand")[1],t),Ea(e,"type",t={type:0,g:3}),t),ja=(e,t)=>{Ga(ga(e,"firstOperand")[1],t),Ga(ga(e,"secondOperand")[1],t),t=wa(va(e,["firstOperand","*"]),"type");const n=wa(va(e,["secondOperand","*"]),"type");return Ea(e,"type",t={type:0,g:lt(t)||lt(n)?0:3}),t},_a=(e,t)=>{Ga(ga(e,"firstOperand")[1],t),Ga(ga(e,"secondOperand")[1],t),t=wa(va(e,["firstOperand","*"]),"type");const n=wa(va(e,["secondOperand","*"]),"type");return Ea(e,"type",t={type:0,g:lt(t)||lt(n)?0:3}),t},Xa=new Map([["unaryMinusOp",(e,t)=>((t=Ga(ga(e,"operand")[1],t))?T(t.type,2)?(Ea(e,"type",t={type:t.type,g:t.g}),e=t):(Ea(e,"type",t={type:3,g:3}),e=t):(Ea(e,"type",t={type:2,g:2}),e=t),e)],["unaryPlusOp",(e,t)=>((t=Ga(ga(e,"operand")[1],t))?T(t.type,2)?(Ea(e,"type",t={type:t.type,g:t.g}),e=t):(Ea(e,"type",t={type:3,g:3}),e=t):(Ea(e,"type",t={type:2,g:2}),e=t),e)],["addOp",$a],["subtractOp",$a],["divOp",$a],["idivOp",$a],["modOp",$a],["multiplyOp",$a],["andOp",La],["orOp",La],["sequenceExpr",(e,t)=>{const n=xa(e,"*"),r=n.map((e=>Ga(e,t)));return function(e,t,n){return t=0===t?{type:53,g:2}:1===t?n[0]:n.includes(void 0)||n.includes(null)||1<(t=Ra(n)).length?{type:59,g:2}:{type:t[0].type,g:2},t&&59!==t.type&&Ea(e,"type",t),t}(e,n.length,r)}],["unionOp",Ha],["intersectOp",Ha],["exceptOp",Ha],["stringConcatenateOp",(e,t)=>(Ga(ga(e,"firstOperand")[1],t),Ga(ga(e,"secondOperand")[1],t),Ea(e,"type",t={type:1,g:3}),t)],["rangeSequenceExpr",(e,t)=>(Ga(ga(e,"startExpr")[1],t),Ga(ga(e,"endExpr")[1],t),Ea(e,"type",t={type:5,g:1}),t)],["equalOp",Pa],["notEqualOp",Pa],["lessThanOrEqualOp",Pa],["lessThanOp",Pa],["greaterThanOrEqualOp",Pa],["greaterThanOp",Pa],["eqOp",ja],["neOp",ja],["ltOp",ja],["leOp",ja],["gtOp",ja],["geOp",ja],["isOp",_a],["nodeBeforeOp",_a],["nodeAfterOp",_a],["pathExpr",(e,t)=>{const n=ga(e,"rootExpr");return n&&n[1]&&Ga(n[1],t),xa(e,"stepExpr").map((e=>Ga(e,t))),function(e,t){var n=xa(e,"stepExpr");if(!n)return{type:59,g:2};for(const e of n){e:{n=e;var r=t;let o=null;if(!n)break e;var a=xa(n,"*");let s="";for(const e of a)switch(e[0]){case"filterExpr":o=wa(va(e,["*"]),"type");break;case"xpathAxis":s=e[1];t:{switch(s){case"attribute":o={type:47,g:2};break t;case"child":case"decendant":case"self":case"descendant-or-self":case"following-sibling":case"following":case"namespace":case"parent":case"ancestor":case"preceding-sibling":case"preceding":case"ancestor-or-self":o={type:53,g:2};break t}o=void 0}break;case"nameTest":if(a=ba(e),null!==a.namespaceURI)break;if("attribute"===s&&!a.prefix)break;void 0!==(a=r.$(a.prefix||""))&&Ea(e,"URI",a);break;case"lookup":o={type:59,g:2}}o&&59!==o.type&&Ea(n,"type",o)}r=wa(e,"type")}return r&&59!==r.type&&Ea(e,"type",r),r}(e,t)}],["contextItemExpr",()=>({type:59,g:2})],["ifThenElseExpr",(e,t)=>{Ga(ga(ga(e,"ifClause"),"*"),t);const n=Ga(ga(ga(e,"thenClause"),"*"),t);return t=Ga(ga(ga(e,"elseClause"),"*"),t),n&&t&&n.type===t.type&&n.g===t.g?(59!==n.type&&Ea(e,"type",n),e=n):e={type:59,g:2},e}],["instanceOfExpr",(e,t)=>(Ga(ga(e,"argExpr"),t),Ga(ga(e,"sequenceType"),t),Ea(e,"type",t={type:0,g:3}),t)],["integerConstantExpr",e=>{const t={type:5,g:3};return Ea(e,"type",t),t}],["doubleConstantExpr",e=>{const t={type:3,g:3};return Ea(e,"type",t),t}],["decimalConstantExpr",e=>{const t={type:4,g:3};return Ea(e,"type",t),t}],["stringConstantExpr",e=>{const t={type:1,g:3};return Ea(e,"type",t),t}],["functionCallExpr",(e,t)=>(xa(ga(e,"arguments"),"*").map((e=>Ga(e,t))),function(e,t){if(!t||!t.ga)return{type:59,g:2};const n=ga(e,"functionName");var r=ba(n);let a=r.localName;var o=r.prefix;let s=r.namespaceURI;if(r=xa(ga(e,"arguments"),"*"),null===s){if(!(o=t.ga.Sa({localName:a,prefix:o},r.length)))return{type:59,g:2};a=o.localName,s=o.namespaceURI,Ea(n,"URI",s),n[2]=a}return(t=t.ga.va(s,a,r.length))&&63!==t.i.type?(59!==t.i.type&&Ea(e,"type",t.i),t.i):{type:59,g:2}}(e,t))],["arrowExpr",(e,t)=>(Ga(ga(e,"argExpr")[1],t),function(e,t){if(!t||!t.ga)return{type:59,g:2};var n=ga(e,"EQName");if(!n)return{type:59,g:2};var r=ba(n);n=r.localName;const a=r.prefix;return r=xa(ga(e,"arguments"),"*"),(n=t.ga.Sa({localName:n,prefix:a},r.length))&&(t=t.ga.va(n.namespaceURI,n.localName,r.length+1))?(59!==t.i.type&&Ea(e,"type",t.i),t.i):{type:59,g:2}}(e,t))],["dynamicFunctionInvocationExpr",(e,t)=>(Ga(va(e,["functionItem","*"]),t),(e=ga(e,"arguments"))&&Ga(e,t),{type:59,g:2})],["namedFunctionRef",(e,t)=>function(e,t){if(!t||!t.ga)return{type:59,g:2};const n=ga(e,"functionName");var r=ba(n);let a=r.localName;var o=r.namespaceURI;const s=r.prefix;if(r=Number(va(e,["integerConstantExpr","value"])[1]),!o){if(!(o=t.ga.Sa({localName:a,prefix:s},r)))return{type:59,g:2};a=o.localName,Ea(n,"URI",o=o.namespaceURI)}return(t=t.ga.va(o,a,r)||null)?(59!==t.i.type&&63!==t.i.type&&Ea(e,"type",t.i),t.i):{type:59,g:2}}(e,t)],["inlineFunctionExpr",(e,t)=>(Ga(ga(e,"functionBody")[1],t),Ea(e,"type",t={type:60,g:3}),t)],["castExpr",e=>{var t=va(e,["singleType","atomicType"]);return 59!==(t={type:F(wa(t,"prefix")+":"+t[2]),g:3}).type&&Ea(e,"type",t),t}],["castableExpr",e=>{const t={type:0,g:3};return Ea(e,"type",t),t}],["simpleMapExpr",(e,t)=>{const n=xa(e,"pathExpr");let r;for(let e=0;e<n.length;e++)r=Ga(n[e],t);return null!=r?(59!==(t={type:r.type,g:2}).type&&Ea(e,"type",t),e=t):e={type:59,g:2},e}],["mapConstructor",(e,t)=>(xa(e,"mapConstructorEntry").map((e=>({key:Ga(va(e,["mapKeyExpr","*"]),t),value:Ga(va(e,["mapValueExpr","*"]),t)}))),function(e){const t={type:61,g:3};return Ea(e,"type",t),t}(e))],["arrayConstructor",(e,t)=>(xa(ga(e,"*"),"arrayElem").map((e=>Ga(e,t))),function(e){const t={type:62,g:3};return Ea(e,"type",t),t}(e))],["unaryLookup",e=>(ga(e,"NCName"),{type:59,g:2})],["typeswitchExpr",(e,t)=>{const n=Ga(ga(e,"argExpr")[1],t),r=xa(e,"typeswitchExprCaseClause").map((e=>Ga(va(e,["resultExpr"])[1],t)));return function(e,t,n,r){if(!t||n.includes(void 0))return{type:59,g:2};var a=xa(e,"typeswitchExprCaseClause");for(let s=0;s<n.length;s++){var o=ga(a[s],"*");switch(o[0]){case"sequenceType":if(o=Ma(o,t,n[s]))return 59!==o.type&&Ea(e,"type",o),o;continue;case"sequenceTypeUnion":for(r=xa(o,"*"),a=0;2>a;a++)if(o=Ma(r[a],t,n[s]))return 59!==o.type&&Ea(e,"type",o),o;default:return{type:59,g:2}}}return 59!==r.type&&Ea(e,"type",r),r}(e,n,r,Ga(va(e,["typeswitchExprDefaultClause","resultExpr"])[1],t))}],["quantifiedExpr",(e,t)=>(xa(e,"*").map((e=>Ga(e,t))),function(e){const t={type:0,g:3};return Ea(e,"type",t),t}(e))],["x:stackTrace",(e,t)=>Ga((e=xa(e,"*"))[0],t)],["queryBody",(e,t)=>Ga(e[1],t)],["flworExpr",(e,t)=>function(e,t){var n=Ga;let r=!1;for(var a=1;a<e.length;a++)switch(e[a][0]){case"letClause":qa(t);var o=e[a],s=t,i=n,l=va(o,["letClauseItem","typedVariableBinding","varName"]);l=ba(l),i=i((o=va(o,["letClauseItem","letExpr"]))[1],s),Va(s,l.localName,i);break;case"forClause":r=!0,qa(t),ka(e[a],t,n);break;case"whereClause":qa(t),n(s=e[a],t),Ea(s,"type",{type:0,g:3});break;case"orderByClause":qa(t);break;case"returnClause":return s=n,Ea(n=va(a=e[a],["*"]),"type",t=s(n,t)),Ea(a,"type",t),(n=t)?(r&&(n={type:n.type,g:2}),59!==n.type&&Ea(e,"type",n),n):{type:59,g:2};default:return(n=n(e[a],t))?(r&&(n={type:n.type,g:2}),59!==n.type&&Ea(e,"type",n),n):{type:59,g:2}}if(!(0<t.h))throw Error("Variable scope out of bound");t.h--,t.o.pop(),t.v.pop()}(e,t)],["varRef",(e,t)=>{const n=ba(ga(e,"name"));var r;e:{for(r=t.h;0<=r;r--){const e=t.o[r][n.localName];if(e){r=e;break e}}r=void 0}return r&&59!==r.type&&Ea(e,"type",r),null===n.namespaceURI&&(void 0!==(t=t.$(n.prefix))&&Ea(e,"URI",t)),r}]]);function qa(e){e.h++,e.o.push({}),e.v.push({})}function Va(e,t,n){if(e.o[e.h][t])throw Error(`Another variable of in the scope ${e.h} with the same name ${t} already exists`);e.o[e.h][t]=n}var Ya=class{constructor(e){this.h=0,this.ga=e,this.o=[{}],this.v=[{}]}$(e){for(let t=this.h;0<=t;t--){const n=this.v[t][e];if(void 0!==n)return n}return this.ga?this.ga.$(e):void 0}},za=class extends Qn{constructor(e,t){super(new hr({external:1}),e,{B:e.every((e=>e.B))},!1,t),this.l=e}h(e,t){return 0===this.l.length?$.m(new ie([])):Jn(this.l[0],e,t).N((e=>$.m(new ie(e.map((e=>L($.m(e))))))))}},Ja=class extends Qn{constructor(e,t){super(new hr({external:1}),e,{B:e.every((e=>e.B))},!1,t),this.l=e}h(e,t){return $.m(new ie(this.l.map((n=>L(Jn(n,e,t))))))}};function Qa(e){if(null===e)throw We("context is absent, it needs to be present to use axes.");if(!T(e.type,53))throw Error("XPTY0020: Axes can only be applied to nodes.");return e.value}var Ka=class extends Qn{constructor(e,t){t=t||{Qa:!1},super(e.o,[e],{P:"reverse-sorted",W:!1,subtree:!1,B:!1}),this.l=e,this.s=!!t.Qa}h(e,t){t=t.h,e=Qa(e.M);var n=this.l.D();return n=n&&(n.startsWith("name-")||"type-1"===n)?"type-1":null,$.create(function(e,t,n){let r=t;return{next:()=>{if(!r)return A;const t=r;return r=ne(e,t,n),E(ce(t))}}}(t,this.s?e:ne(t,e,n),n)).filter((e=>this.l.l(e)))}};const Wa=new Map([["type-1-or-type-2",["name","type-1","type-2"]],["type-1",["name"]],["type-2",["name"]]]);function Za(e,t){if(null===e)return t;if(null===t||e===t)return e;const n=e.startsWith("name-")?"name":e,r=t.startsWith("name-")?"name":t,a=Wa.get(n);return void 0!==a&&a.includes(r)?t:void 0!==(t=Wa.get(r))&&t.includes(n)?e:"empty"}var eo=class extends Qn{constructor(e,t){super(new hr({attribute:1}),[e],{P:"unsorted",subtree:!0,W:!0,B:!1}),this.l=e,this.s=Za(this.l.D(),t)}h(e,t){return t=t.h,1!==(e=Qa(e.M)).node.nodeType?$.empty():(e=Q(t,e,this.s).filter((e=>"http://www.w3.org/2000/xmlns/"!==e.node.namespaceURI)).map((e=>ce(e))).filter((e=>this.l.l(e))),$.create(e))}D(){return"type-1"}},to=class extends Qn{constructor(e,t){super(e.o,[e],{P:"sorted",subtree:!0,W:!0,B:!1}),this.s=e,this.l=Za(t,e.D())}h(e,t){const n=t.h,r=Qa(e.M);if(1!==(e=r.node.nodeType)&&9!==e)return $.empty();let a=null,o=!1;return $.create({next:()=>{for(;!o;){if(!a){if(a=ee(n,r,this.l),!a){o=!0;continue}return E(ce(a))}if(a=re(n,a,this.l))return E(ce(a));o=!0}return A}}).filter((e=>this.s.l(e)))}};function no(e,t,n){const r=t.node.nodeType;if(1!==r&&9!==r)return{next:()=>A};let a=ee(e,t,n);return{next(){if(!a)return A;const t=a;return a=re(e,a,n),E(t)}}}var ro=class extends Qn{constructor(e,t){t=t||{Qa:!1},super(e.o,[e],{B:!1,W:!1,P:"sorted",subtree:!0}),this.l=e,this.s=!!t.Qa,this.A=(e=this.l.D())&&(e.startsWith("name-")||"type-1"===e)||"type-1-or-type-2"===e?"type-1":null}h(e,t){return e=function(e,t,n){const r=[Et(t)];return{next:t=>{if(0<r.length&&0!=(1&t)&&r.shift(),!r.length)return A;for(t=r[0].next(0);t.done;){if(r.shift(),!r.length)return A;t=r[0].next(0)}return r.unshift(no(e,t.value,n)),E(ce(t.value))}}}(t=t.h,e=Qa(e.M),this.A),this.s||e.next(0),$.create(e).filter((e=>this.l.l(e)))}};function ao(e,t,n){var r=e.node.nodeType;if(1!==r&&9!==r)return e;for(r=te(t,e,n);null!==r;){if(1!==r.node.nodeType)return r;r=te(t,e=r,n)}return e}function oo(e,t,n=!1,r){if(n){let n=t,a=!1;return{next:()=>{if(a)return A;if(Tt(n,t))return n=ao(t,e,r),Tt(n,t)?(a=!0,A):E(ce(n));const o=n.node.nodeType,s=9===o||2===o?null:ae(e,n,r);return null!==s?(n=ao(s,e,r),E(ce(n))):(n=9===o?null:ne(e,n,r),Tt(n,t)?(a=!0,A):E(ce(n)))}}}const a=[no(e,t,r)];return{next:()=>{if(!a.length)return A;let t=a[0].next(0);for(;t.done;){if(a.shift(),!a.length)return A;t=a[0].next(0)}return a.unshift(no(e,t.value,r)),E(ce(t.value))}}}var so=class extends Qn{constructor(e){super(e.o,[e],{P:"sorted",W:!0,subtree:!1,B:!1}),this.l=e,this.s=(e=this.l.D())&&(e.startsWith("name-")||"type-1"===e)?"type-1":null}h(e,t){return t=t.h,e=Qa(e.M),$.create(function(e,t,n){const r=[];for(;t&&9!==t.node.nodeType;t=ne(e,t,null)){const a=re(e,t,n);a&&r.push(a)}let a=null;return{next:()=>{for(;a||r.length;){if(!a){a=oo(e,r[0],!1,n);var t=E(ce(r[0]));const o=re(e,r[0],n);return o?r[0]=o:r.shift(),t}if(!(t=a.next(0)).done)return t;a=null}return A}}}(t,e,this.s)).filter((e=>this.l.l(e)))}};var io=class extends Qn{constructor(e,t){super(e.o,[e],{P:"sorted",W:!0,subtree:!1,B:!1}),this.l=e,this.s=Za(this.l.D(),t)}h(e,t){return t=t.h,e=Qa(e.M),$.create(function(e,t,n){return{next:()=>(t=t&&re(e,t,n))?E(ce(t)):A}}(t,e,this.s)).filter((e=>this.l.l(e)))}},lo=class extends Qn{constructor(e,t){super(e.o,[e],{P:"reverse-sorted",W:!0,subtree:!0,B:!1}),this.l=e,this.s=Za(t,this.l.D())}h(e,t){return(e=ne(t=t.h,e=Qa(e.M),this.s))?(e=ce(e),this.l.l(e)?$.m(e):$.empty()):$.empty()}};var co=class extends Qn{constructor(e){super(e.o,[e],{B:!1,W:!0,P:"reverse-sorted",subtree:!1}),this.l=e,this.s=(e=this.l.D())&&(e.startsWith("name-")||"type-1"===e)?"type-1":null}h(e,t){return t=t.h,e=Qa(e.M),$.create(function(e,t,n){const r=[];for(;t&&9!==t.node.nodeType;t=ne(e,t,null)){const a=ae(e,t,n);null!==a&&r.push(a)}let a=null;return{next:()=>{for(;a||r.length;){a||=oo(e,r[0],!0,n);var t=a.next(0);if(t.done){a=null,t=ae(e,r[0],n);const o=E(ce(r[0]));return null===t?r.shift():r[0]=t,o}return t}return A}}}(t,e,this.s)).filter((e=>this.l.l(e)))}};var uo=class extends Qn{constructor(e,t){super(e.o,[e],{B:!1,W:!0,P:"reverse-sorted",subtree:!1}),this.l=e,this.s=Za(this.l.D(),t)}h(e,t){return t=t.h,e=Qa(e.M),$.create(function(e,t,n){return{next:()=>(t=t&&ae(e,t,n))?E(ce(t)):A}}(t,e,this.s)).filter((e=>this.l.l(e)))}},po=class extends Qn{constructor(e,t){super(e.o,[e],{P:"sorted",subtree:!0,W:!0,B:!1}),this.l=e,this.s=Za(this.l.D(),t)}h(e){return Qa(e.M),this.l.l(e.M)?$.m(e.M):$.empty()}D(){return this.s}},ho=class extends lr{constructor(e,t,n,r){super(e.o.add(t.o).add(n.o),[e,t,n],{B:e.B&&t.B&&n.B,W:t.W===n.W&&t.W,P:t.ia===n.ia?t.ia:"unsorted",subtree:t.subtree===n.subtree&&t.subtree},r),this.l=e}A(e,t,n){let r=null;const a=n[0](e);return $.create({next:t=>(r||(r=(a.fa()?n[1](e):n[2](e)).value),r.next(t))})}v(e){if(super.v(e),this.l.J)throw $n()}};function mo(e){return e.h instanceof Error?e.location:mo(e.h)}function fo(e){let t;return t=e.h instanceof jr?["Inner error:",e.h.message]:e.h instanceof Error?[e.h.toString()]:fo(e.h),t.push(` at <${e.o}>:${e.location.start.line}:${e.location.start.ha} - ${e.location.end.line}:${e.location.end.ha}`),t}var go=class{constructor(e,t,n){this.location=e,this.o=t,this.h=n}},yo=class extends lr{constructor(e,t,n){super(n.o,[n],{B:n.B,W:n.W,P:n.ia,subtree:n.subtree}),this.l=t,this.L={end:{ha:e.end.ha,line:e.end.line,offset:e.end.offset},start:{ha:e.start.ha,line:e.start.line,offset:e.start.offset}}}A(e,t,[n]){let r;try{r=n(e)}catch(e){throw new go(this.L,this.l,e)}return $.create({next:e=>{try{return r.value.next(e)}catch(e){throw new go(this.L,this.l,e)}}})}v(e){try{super.v(e)}catch(e){throw new go(this.L,this.l,e)}}};function wo(e,t,n,r){let a=[];const o=e.L(t,n,r,(n=>{if(e.l instanceof xo){return ir(wo(e.l,t,n,r),(e=>a=e))}let o=null;return $.create({next:()=>{for(;;){if(!o){var t=n.next(0);if(t.done)return A;t=e.l.s(t.value,r),o=ir(t,(e=>a=ar(a,e))).value}if(!(t=o.next(0)).done)return t;o=null}}})}));let s=!1;return{next:()=>{if(s)return A;const e=o.O();return s=!0,E(new Kn(e,a))}}}function vo(e,t,n,r){return e.L(t,n,r,(n=>{if(e.l instanceof xo)return vo(e.l,t,n,r);let a=null;return $.create({next:()=>{for(;;){if(!a){var t=n.next(0);if(t.done)return A;a=Jn(e.l,t.value,r).value}if(!(t=a.next(0)).done)return t;a=null}}})}))}var xo=class extends Qn{constructor(e,t,n,r){super(e,t,n,!0),this.l=r,this.J=this.l.J}h(e,t){return this.L(e,Et(e),t,(n=>{if(this.l instanceof xo)return vo(this.l,e,n,t);let r=null;return $.create({next:e=>{for(;;){if(!r){var a=n.next(0);if(a.done)return A;r=Jn(this.l,a.value,t).value}if(!(a=r.next(e)).done)return a;r=null}}})}))}s(e,t){return wo(this,e,Et(e),t)}v(e){super.v(e),this.J=this.l.J;for(const e of this.Ka)if(e!==this.l&&e.J)throw $n()}},bo=class extends xo{constructor(e,t,n,r){super(t.o.add(r.o),[t,r],{B:!1},r),this.S=e.prefix,this.ma=e.namespaceURI,this.Mb=e.localName,this.wb=null,this.A=n,this.La=null,this.ya=t}L(e,t,n,r){let a=null,o=null,s=0;return r({next:()=>{for(;;){if(!a){var e=t.next(0);if(e.done)return A;o=e.value,s=0,a=Jn(this.ya,o,n).value}const r=a.next(0);if(!r.done)return s++,e={[this.wb]:()=>$.m(r.value)},this.La&&(e[this.La]=()=>$.m(new I(5,s))),E(Ye(o,e));a=null}}})}v(e){if(this.S&&(this.ma=e.$(this.S),!this.ma&&this.S))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.S} in a for expression`);if(this.ya.v(e),ca(e),this.wb=ha(e,this.ma,this.Mb),this.A){if(this.A.prefix&&(this.A.namespaceURI=e.$(this.A.prefix),!this.A.namespaceURI&&this.A.prefix))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.S} in the positionalVariableBinding in a for expression`);this.La=ha(e,this.A.namespaceURI,this.A.localName)}if(this.l.v(e),ma(e),this.ya.J)throw $n();this.l.J&&(this.J=!0)}},Ao=class extends Qn{constructor(e,t,n){super(new hr({external:1}),[n],{B:!1,P:"unsorted"}),this.S=e.map((({name:e})=>e)),this.A=e.map((({type:e})=>e)),this.s=null,this.L=t,this.l=n}h(e,t){const n=new P({j:this.A,arity:this.A.length,Xa:!0,J:this.l.J,localName:"dynamic-function",namespaceURI:"",i:this.L,value:(n,r,a,...o)=>(n=Ye(je(e,-1,null,$.empty()),this.s.reduce(((e,t,n)=>(e[t]=L(o[n]),e)),Object.create(null))),Jn(this.l,n,t))});return $.m(n)}v(e){if(ca(e),this.s=this.S.map((t=>ha(e,t.namespaceURI,t.localName))),this.l.v(e),ma(e),this.l.J)throw Error("Not implemented: inline functions can not yet be updating.")}},Eo=class extends xo{constructor(e,t,n){if(super(t.o.add(n.o),[t,n],{B:!1,W:n.W,P:n.ia,subtree:n.subtree},n),e.prefix||e.namespaceURI)throw Error("Not implemented: let expressions with namespace usage.");this.A=e.prefix,this.S=e.namespaceURI,this.La=e.localName,this.ma=t,this.ya=null}L(e,t,n,r){return r({next:()=>{var e=t.next(0);return e.done?A:E(e=Ye(e=e.value,{[this.ya]:L(Jn(this.ma,e,n))}))}})}v(e){if(this.A&&(this.S=e.$(this.A),!this.S&&this.A))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.A} using in a for expression`);if(this.ma.v(e),ca(e),this.ya=ha(e,this.S,this.La),this.l.v(e),ma(e),this.J=this.l.J,this.ma.J)throw $n()}},No=class extends Qn{constructor(e,t){let n;switch(super(new hr({}),[],{B:!0,P:"sorted"},!1,t),t.type){case 5:n=y(parseInt(e,10),t.type);break;case 1:n=y(e,t.type);break;case 4:case 3:n=y(parseFloat(e),t.type);break;default:throw new TypeError("Type "+t+" not expected in a literal")}this.l=()=>$.m(n)}h(){return this.l()}},To=class extends Qn{constructor(e,t){super(new hr({external:1}),e.reduce(((e,{key:t,value:n})=>e.concat(t,n)),[]),{B:!1},!1,t),this.l=e}h(e,t){const n=this.l.map((n=>rt(Jn(n.key,e,t),t).Y({default:()=>{throw Error("XPTY0004: A key of a map should be a single atomizable value.")},m:e=>e})));return ue(n,(n=>$.m(new de(n.map(((n,r)=>({key:n,value:L(Jn(this.l[r].value,e,t))})))))))}},Bo=class extends Qn{constructor(e,t,n){super(new hr({external:1}),[],{B:!0},!1,n),this.s=t,this.A=e,this.l=null}h(){const e=new P({j:this.l.j,J:this.l.J,arity:this.s,localName:this.l.localName,namespaceURI:this.l.namespaceURI,i:this.l.i,value:this.l.callFunction});return $.m(e)}v(e){let t=this.A.namespaceURI,n=this.A.localName;const r=this.A.prefix;if(null===t){const a=e.Sa({localName:n,prefix:r},this.s);if(!a)throw Error(`XPST0017: The function ${r?r+":":""}${n} with arity ${this.s} could not be resolved. ${Vr(n)}`);t=a.namespaceURI,n=a.localName}if(this.l=e.va(t,n,this.s)||null,!this.l)throw e=this.A,Error(`XPST0017: Function ${e.namespaceURI?`Q{${e.namespaceURI}}`:e.prefix?`${e.prefix}:`:""}${e.localName} with arity of ${this.s} not registered. ${Vr(n)}`);super.v(e)}};const Io={5:5,27:5,28:5,31:5,32:5,33:5,34:5,30:5,36:5,35:5,38:5,37:5,29:5,4:4,6:6,3:3};var Co=class extends Qn{constructor(e,t,n){super(t.o,[t],{B:!1},!1,n),this.s=t,this.l=e}h(e,t){return rt(Jn(this.s,e,t),t).N((e=>{if(0===e.length)return $.empty();var t=e[0];if(this.type)return e="+"===this.l?+t.value:-t.value,0===t.type&&(e=Number.NaN),$.m(y(e,this.type.type));if(1<e.length)throw Error("XPTY0004: The operand to a unary operator must be a sequence with a length less than one");return T(t.type,19)?(t=At(t,3).value,$.m(y("+"===this.l?t:-t,3))):T(t.type,2)?"+"===this.l?$.m(t):$.m(y(-1*t.value,Io[t.type])):$.m(y(Number.NaN,3))}))}},So=class extends Qn{constructor(e,t){super(e.reduce(((e,t)=>e.add(t.o)),new hr({})),e,{B:e.every((e=>e.B))},!1,t),this.l=e,this.s=e.reduce(((e,t)=>Za(e,t.D())),null)}h(e,t){let n=0,r=null,a=!1,o=null;if(null!==e){const t=e.M;null!==t&&T(t.type,53)&&(o=_(t.value))}return $.create({next:()=>{if(!a){for(;n<this.l.length;){if(!r){const s=this.l[n];if(null!==o&&null!==s.D()&&!o.includes(s.D()))return n++,a=!0,E(v);r=Jn(s,e,t)}if(!1===r.fa())return a=!0,E(v);r=null,n++}return a=!0,E(w)}return A}})}D(){return this.s}},Oo=class extends Qn{constructor(e,t){let n;for(super(e.reduce(((e,t)=>0<pr(e,t.o)?e:t.o),new hr({})),e,{B:e.every((e=>e.B))},!1,t),t=0;t<e.length&&(void 0===n&&(n=e[t].D()),null!==n);++t)if(n!==e[t].D()){n=null;break}this.s=n,this.l=e}h(e,t){let n=0,r=null,a=!1,o=null;if(null!==e){const t=e.M;null!==t&&T(t.type,53)&&(o=_(t.value))}return $.create({next:()=>{if(!a){for(;n<this.l.length;){if(!r){const a=this.l[n];if(null!==o&&null!==a.D()&&!o.includes(a.D())){n++;continue}r=Jn(a,e,t)}if(!0===r.fa())return a=!0,E(w);r=null,n++}return a=!0,E(v)}return A}})}D(){return this.s}};function Fo(e,t){let n;return $.create({next:r=>{for(;;){if(!n){var a=e.value.next(r);if(a.done)return A;n=nt(a.value,t)}if(!(a=n.value.next(r)).done)return a;n=null}}})}function Do(e,t,n){function r(e,t){return{T:s?s(e):e,U:i?i(t):t}}function a(e){return T(t,e)&&T(n,e)}function o(e){return 0<e.filter((e=>T(t,e))).length&&0<e.filter((e=>T(n,e))).length}let s=null,i=null;if(T(t,19)&&T(n,19)?t=n=1:T(t,19)?(s=e=>At(e,n),t=n):T(n,19)&&(i=e=>At(e,t),n=t),T(t,23)&&T(n,23))return function(e,t){if("eqOp"===e)return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value.namespaceURI===a.value.namespaceURI&&r.value.localName===a.value.localName};if("neOp"===e)return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value.namespaceURI!==a.value.namespaceURI||r.value.localName!==a.value.localName};throw Error('XPTY0004: Only the "eq" and "ne" comparison is defined for xs:QName')}(e,r);if(a(0)||o([1,47,61])||o([2,47,61])||a(20)||a(22)||a(21)||o([1,20])){var l=function(e,t){switch(e){case"eqOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value===a.value};case"neOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value!==a.value};case"ltOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value<a.value};case"leOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value<=a.value};case"gtOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value>a.value};case"geOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value>=a.value}}}(e,r);if(void 0!==l)return l}if(a(16)&&(l=function(e,t){switch(e){case"ltOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value.ea<a.value.ea};case"leOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return me(r.value,a.value)||r.value.ea<a.value.ea};case"gtOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value.ea>a.value.ea};case"geOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return me(r.value,a.value)||r.value.ea>a.value.ea}}}(e,r),void 0!==l)||a(17)&&(l=function(e,t){switch(e){case"eqOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return me(r.value,a.value)};case"ltOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value.ca<a.value.ca};case"leOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return me(r.value,a.value)||r.value.ca<a.value.ca};case"gtOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value.ca>a.value.ca};case"geOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return me(r.value,a.value)||r.value.ca>a.value.ca}}}(e,r),void 0!==l)||a(18)&&(l=function(e,t){switch(e){case"eqOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return me(r.value,a.value)};case"neOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return!me(r.value,a.value)}}}(e,r),void 0!==l))return l;if((a(9)||a(7)||a(8))&&(l=function(e,t){switch(e){case"eqOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return De(a.value,o.value,qe(r))};case"neOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return!De(a.value,o.value,qe(r))};case"ltOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return e=qe(r),0>Fe(a.value,o.value,e)};case"leOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return(e=De(a.value,o.value,qe(r)))||(r=qe(r),e=0>Fe(a.value,o.value,r)),e};case"gtOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return e=qe(r),0<Fe(a.value,o.value,e)};case"geOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return(e=De(a.value,o.value,qe(r)))||(r=qe(r),e=0<Fe(a.value,o.value,r)),e}}}(e,r),void 0!==l))return l;if((a(11)||a(12)||a(13)||a(14)||a(15))&&(l=function(e,t){switch(e){case"eqOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return De(a.value,o.value,qe(r))};case"neOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return!De(a.value,o.value,qe(r))}}}(e,r),void 0!==l))return l;throw Error(`XPTY0004: ${e} not available for ${C[t]} and ${C[n]}`)}const ko=Object.create(null);function Ro(e,t,n){const r=`${t}~${n}~${e}`;let a=ko[r];return a||=ko[r]=Do(e,t,n),a}var Mo=class extends Qn{constructor(e,t,n){super(t.o.add(n.o),[t,n],{B:!1}),this.l=t,this.A=n,this.s=e}h(e,t){const n=Jn(this.l,e,t),r=Jn(this.A,e,t),a=Fo(n,t),o=Fo(r,t);return a.Y({empty:()=>$.empty(),m:()=>o.Y({empty:()=>$.empty(),m:()=>{const t=a.first(),n=o.first();return Ro(this.s,t.type,n.type)(t,n,e)?$.aa():$.V()},multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton.")}}),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton.")}})}};const Uo={equalOp:"eqOp",notEqualOp:"neOp",lessThanOrEqualOp:"leOp",lessThanOp:"ltOp",greaterThanOrEqualOp:"geOp",greaterThanOp:"gtOp"};var Go=class extends Qn{constructor(e,t,n){super(t.o.add(n.o),[t,n],{B:!1}),this.l=t,this.A=n,this.s=e}h(e,t){const n=Jn(this.l,e,t),r=Jn(this.A,e,t);return n.Y({empty:()=>$.V(),default:()=>r.Y({empty:()=>$.V(),default:()=>{const a=Fo(n,t),o=Fo(r,t);return function(e,t,n,r){return e=Uo[e],n.N((n=>t.filter((t=>{for(let s=0,i=n.length;s<i;++s){let i,l,c=n[s];var a=t.type,o=c.type;(T(a,19)||T(o,19))&&(T(a,2)?i=3:T(o,2)?l=3:T(a,17)?i=17:T(o,17)?l=17:T(a,16)?i=16:T(o,16)?l=16:T(a,19)?l=o:T(o,19)&&(i=a));const[u,p]=[l,i];if(a=u,o=p,a?t=At(t,a):o&&(c=At(c,o)),Ro(e,t.type,c.type)(t,c,r))return!0}return!1})).Y({default:()=>$.aa(),empty:()=>$.V()})))}(this.s,a,o,e)}})})}};function $o(e,t,n,r){if(!T(n,53)||!T(r,53))throw Error("XPTY0004: Sequences to compare are not nodes");switch(e){case"isOp":return function(e,t){return e!==t||47!==e&&53!==e&&54!==e&&55!==e&&56!==e&&57!==e&&58!==e?()=>!1:(e,t)=>Tt(e.first().value,t.first().value)}(n,r);case"nodeBeforeOp":return t?(e,n)=>0>Ot(t,e.first(),n.first()):void 0;case"nodeAfterOp":return t?(e,n)=>0<Ot(t,e.first(),n.first()):void 0;default:throw Error("Unexpected operator")}}var Lo=class extends Qn{constructor(e,t,n){super(t.o.add(n.o),[t,n],{B:!1}),this.l=t,this.A=n,this.s=e}h(e,t){const n=Jn(this.l,e,t),r=Jn(this.A,e,t);return n.Y({empty:()=>$.empty(),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton")},m:()=>r.Y({empty:()=>$.empty(),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton")},m:()=>{const a=n.first(),o=r.first();return $o(this.s,t.h,a.type,o.type)(n,r,e)?$.aa():$.V()}})})}};function Ho(e,t,n,r){return n.N((n=>{if(n.some((e=>!T(e.type,53))))throw Error(`XPTY0004: Sequences given to ${e} should only contain nodes.`);return"sorted"===r?$.create(n):"reverse-sorted"===r?$.create(n.reverse()):$.create(Ft(t,n))}))}var Po=class extends Qn{constructor(e,t,n,r){super(0<pr(t.o,n.o)?t.o:n.o,[t,n],{B:t.B&&n.B},!1,r),this.l=e,this.s=t,this.A=n}h(e,t){const n=Ho(this.l,t.h,Jn(this.s,e,t),this.s.ia);e=Ho(this.l,t.h,Jn(this.A,e,t),this.A.ia);const r=n.value,a=e.value;let o=null,s=null,i=!1,l=!1;return $.create({next:()=>{if(i)return A;for(;!l;){if(!o){var e=r.next(0);if(e.done)return i=!0,A;o=e.value}if(!s){if((e=a.next(0)).done){l=!0;break}s=e.value}if(Tt(o.value,s.value)){if(e=E(o),s=o=null,"intersectOp"===this.l)return e}else if(0>Ot(t.h,o,s)){if(e=E(o),o=null,"exceptOp"===this.l)return e}else s=null}return"exceptOp"===this.l?null!==o?(e=E(o),o=null,e):r.next(0):(i=!0,A)}})}},jo=class extends lr{constructor(e,t){super(e.reduce(((e,t)=>e.add(t.o)),new hr({})),e,{P:"unsorted",B:e.every((e=>e.B))},t)}A(e,t,n){return n.length?Qe(n.map((t=>t(e)))):$.empty()}},_o=class extends Qn{constructor(e,t,n){super(new hr({}).add(e.o),[e,t],{B:e.B&&t.B},!1,n),this.l=e,this.s=t}h(e,t){const n=_e(e,Jn(this.l,e,t));let r=null,a=null,o=!1;return $.create({next:e=>{for(;!o;){if(!r&&(r=n.next(e),r.done))return o=!0,A;a||=Jn(this.s,r.value,t);const s=a.value.next(e);if(!s.done)return s;r=a=null}}})}},Xo=class extends Qn{constructor(e,t,n){if(super(e.o,[e],{B:!1}),this.l=F(t.prefix?`${t.prefix}:${t.localName}`:t.localName),46===this.l||45===this.l||44===this.l)throw Error("XPST0080: Casting to xs:anyAtomicType, xs:anySimpleType or xs:NOTATION is not permitted.");if(t.namespaceURI)throw Error("Not implemented: castable as expressions with a namespace URI.");this.A=e,this.s=n}h(e,t){const n=rt(Jn(this.A,e,t),t);return n.Y({empty:()=>this.s?$.aa():$.V(),m:()=>n.map((e=>bt(e,this.l).u?w:v)),multiple:()=>$.V()})}},qo=class extends Qn{constructor(e,t,n){if(super(e.o,[e],{B:!1}),this.l=F(t.prefix?`${t.prefix}:${t.localName}`:t.localName),46===this.l||45===this.l||44===this.l)throw Error("XPST0080: Casting to xs:anyAtomicType, xs:anySimpleType or xs:NOTATION is not permitted.");if(t.namespaceURI)throw Error("Not implemented: casting expressions with a namespace URI.");this.A=e,this.s=n}h(e,t){const n=rt(Jn(this.A,e,t),t);return n.Y({empty:()=>{if(!this.s)throw Error("XPTY0004: Sequence to cast is empty while target type is singleton.");return $.empty()},m:()=>n.map((e=>At(e,this.l))),multiple:()=>{throw Error("XPTY0004: Sequence to cast is not singleton or empty.")}})}};function Vo(e,t){const n=e.value;let r=null,a=!1;return $.create({next:()=>{for(;!a;){if(!r){var e=n.next(0);if(e.done)return a=!0,E(w);r=t(e.value)}if(e=r.fa(),r=null,!1===e)return a=!0,E(v)}return A}})}var Yo=class extends Qn{constructor(e,t,n,r){super(e.o,[e],{B:!1},!1,r),this.A=e,this.s=t,this.l=n}h(e,t){const n=Jn(this.A,e,t);return n.Y({empty:()=>"?"===this.l||"*"===this.l?$.aa():$.V(),multiple:()=>"+"===this.l||"*"===this.l?Vo(n,(n=>{const r=$.m(n);return n=je(e,0,n,r),Jn(this.s,n,t)})):$.V(),m:()=>Vo(n,(n=>{const r=$.m(n);return n=je(e,0,n,r),Jn(this.s,n,t)}))})}};function zo(e,t){return!(null===e||null===t||!T(e.type,53)||!T(t.type,53))&&Tt(e.value,t.value)}function Jo(e){let t=e.next(0);if(t.done)return $.empty();let n=null,r=null;return $.create({next(a){if(t.done)return A;let o;n||(n=t.value.value);do{if(o=n.next(a),o.done){if(t=e.next(0),t.done)return o;n=t.value.value}}while(o.done||zo(o.value,r));return r=o.value,o}})}function Qo(e,t){const n=[];!function(){for(var e=t.next(0);!e.done;){const r=e.value.value;e={current:r.next(0),next:e=>r.next(e)},e.current.done||n.push(e),e=t.next(0)}}();let r=null,a=!1;return $.create({[Symbol.iterator](){return this},next:()=>{let t;a||(a=!0,n.every((e=>T(e.current.value.type,53)))&&n.sort(((t,n)=>Ot(e,t.current.value,n.current.value))));do{if(!n.length)return A;const r=n.shift();if(t=r.current,r.current=r.next(0),!T(t.value.type,53))return t;if(!r.current.done){let t=0,a=n.length-1,o=0;for(;t<=a;){o=Math.floor((t+a)/2);const s=Ot(e,r.current.value,n[o].current.value);if(0===s){t=o;break}0<s?t=o+1:a=o-1}n.splice(t,0,r)}}while(zo(t.value,r));return r=t.value,t}})}var Ko=class extends Qn{constructor(e,t){super(e.reduce(((e,t)=>0<pr(e,t.o)?e:t.o),new hr({})),e,{B:e.every((e=>e.B))},!1,t),this.l=e}h(e,t){if(this.l.every((e=>"sorted"===e.ia))){let n=0;return Qo(t.h,{next:()=>n>=this.l.length?A:E(Jn(this.l[n++],e,t))}).map((e=>{if(!T(e.type,53))throw Error("XPTY0004: The sequences to union are not of type node()*");return e}))}return Qe(this.l.map((n=>Jn(n,e,t)))).N((e=>{if(e.some((e=>!T(e.type,53))))throw Error("XPTY0004: The sequences to union are not of type node()*");return e=Ft(t.h,e),$.create(e)}))}};function Wo(e){return e.every((e=>null===e||T(e.type,5)||T(e.type,4)))||null!==e.map((e=>e?at(e.type):null)).reduce(((e,t)=>null===t||t===e?e:null))?e:e.every((e=>null===e||T(e.type,1)||T(e.type,20)))?e.map((e=>e?At(e,1):null)):e.every((e=>null===e||T(e.type,4)||T(e.type,6)))?e.map((e=>e?At(e,6):e)):e.every((e=>null===e||T(e.type,4)||T(e.type,6)||T(e.type,3)))?e.map((e=>e?At(e,3):e)):null}var Zo=class extends xo{constructor(e,t){super(new hr({}),[t,...e.map((e=>e.ba))],{B:!1,W:!1,P:"unsorted",subtree:!1},t),this.A=e}L(e,t,n,r){if(this.A[1])throw Error("More than one order spec is not supported for the order by clause.");const a=[];let o,s,i=!1,l=null;const c=this.A[0];return $.create({next:()=>{if(!i){for(var u=t.next(0);!u.done;)a.push(u.value),u=t.next(0);if(u=a.map((e=>c.ba.h(e,n))).map((e=>rt(e,n))),u.find((e=>!e.G()&&!e.ua())))throw Error("XPTY0004: Order by only accepts empty or singleton sequences");if(o=u.map((e=>e.first())),o=o.map((e=>null===e?e:T(19,e.type)?At(e,1):e)),function(e){return(e=e.find((e=>!!e)))?at(e.type):null}(o)&&(o=Wo(o),!o))throw Error("XPTY0004: Could not cast values");u=o.length,s=o.map(((e,t)=>t));for(let t=0;t<u;t++)if(t+1!==u)for(let n=t;0<=n;n--){const t=n,r=n+1;if(r===u)continue;const a=o[s[t]],i=o[s[r]];if(null!==i||null!==a){if(c.$b){if(null===a)continue;if(null===i&&null!==a){[s[t],s[r]]=[s[r],s[t]];continue}if(isNaN(i.value)&&null!==a&&!isNaN(a.value)){[s[t],s[r]]=[s[r],s[t]];continue}}else{if(null===i)continue;if(null===a&&null!==i){[s[t],s[r]]=[s[r],s[t]];continue}if(isNaN(a.value)&&null!==i&&!isNaN(i.value)){[s[t],s[r]]=[s[r],s[t]];continue}}Ro("gtOp",a.type,i.type)(a,i,e)&&([s[t],s[r]]=[s[r],s[t]])}}let p=c.zb?0:o.length-1;l=r({next:()=>c.zb?p>=o.length?A:E(a[s[p++]]):0>p?A:E(a[s[p--]])}).value,i=!0}return l.next(0)}})}},es=class extends Qn{constructor(e){super(e?e.o:new hr({}),e?[e]:[],{P:"sorted",subtree:!1,W:!1,B:!1}),this.l=e}h(e,t){if(null===e.M)throw We("context is absent, it needs to be present to use paths.");var n=t.h;let r=e.M.value;for(;9!==r.node.nodeType;)if(r=ne(n,r),null===r)throw Error("XPDY0050: the root node of the context node is not a document node.");return n=$.m(ce(r)),this.l?Jn(this.l,je(e,0,n.first(),n),t):n}},ts=class extends Qn{constructor(e){super(new hr({}),[],{P:"sorted"},!1,e)}h(e){if(null===e.M)throw We('context is absent, it needs to be present to use the "." operator');return $.m(e.M)}};var ns=class extends Qn{constructor(e,t){const n=e.every((e=>e.W)),r=e.every((e=>e.subtree));super(e.reduce(((e,t)=>e.add(t.o)),new hr({})),e,{B:!1,W:n,P:t?"sorted":"unsorted",subtree:r}),this.l=e,this.s=t}h(e,t){let n=!0;return this.l.reduce(((r,a,o)=>{const s=null===r?Et(e):_e(e,r);let i;if(r={next:e=>{if((e=s.next(e)).done)return A;if(null!==e.value.M&&!T(e.value.M.type,53)&&0<o)throw Error("XPTY0019: The result of E1 in a path expression E1/E2 should not evaluate to a sequence of nodes.");return E(Jn(a,e.value,t))}},this.s)switch(a.ia){case"reverse-sorted":const e=r;r={next:t=>(t=e.next(t)).done?t:E(t.value.N((e=>$.create(e.reverse()))))};case"sorted":if(a.subtree&&n){i=Jo(r);break}i=Qo(t.h,r);break;case"unsorted":return Jo(r).N((e=>$.create(function(e,t){let n=!1,r=!1;if(t.forEach((e=>{T(e.type,53)?n=!0:r=!0})),r&&n)throw Error("XPTY0018: The path operator should either return nodes or non-nodes. Mixed sequences are not allowed.");return n?Ft(e,t):t}(t.h,e))))}else i=Jo(r);return n=n&&a.W,i}),null)}D(){return this.l[0].D()}},rs=class extends Qn{constructor(e,t){super(e.o.add(t.o),[e,t],{B:e.B&&t.B,W:e.W,P:e.ia,subtree:e.subtree}),this.s=e,this.l=t}h(e,t){const n=Jn(this.s,e,t);if(this.l.B){const r=Jn(this.l,e,t);if(r.G())return r;const a=r.first();if(T(a.type,2)){let e=a.value;if(!Number.isInteger(e))return $.empty();const t=n.value;let r=!1;return $.create({next:()=>{if(!r){for(let n=t.next(0);!n.done;n=t.next(0))if(1==e--)return r=!0,n;r=!0}return A}})}return r.fa()?n:$.empty()}const r=n.value;let a=null,o=0,s=null;return $.create({next:i=>{let l=!1;for(;(!a||!a.done)&&(a||(a=r.next(l?0:i),l=!0),!a.done);){s||=Jn(this.l,je(e,o,a.value,n),t);var c=s.first();c=null!==c&&(T(c.type,2)?c.value===o+1:s.fa()),s=null;const r=a.value;if(a=null,o++,c)return E(r)}return a}})}D(){return this.s.D()}};function as(e,t,n){if(n=[n],T(e.type,62))if("*"===t)n.push(...e.h.map((e=>e())));else{if(!T(t.type,5))throw Error("XPTY0004: The key specifier is not an integer.");{const r=t.value;if(e.h.length<r||0>=r)throw Error("FOAY0001: Array index out of bounds");n.push(e.h[r-1]())}}else{if(!T(e.type,61))throw Error("XPTY0004: The provided context item is not a map or an array.");"*"===t?n.push(...e.h.map((e=>e.value()))):(e=e.h.find((e=>pe(e.key,t))))&&n.push(e.value())}return Qe(n)}function os(e,t,n,r,a){return"*"===t?as(e,t,n):(t=L(t=Jn(t,r,a))().N((t=>t.reduce(((t,n)=>as(e,n,t)),new B))),Qe([n,t]))}var ss=class extends Qn{constructor(e,t){super(e.o,[e].concat("*"===t?[]:[t]),{B:e.B,P:e.ia,subtree:e.subtree}),this.l=e,this.s=t}h(e,t){return Jn(this.l,e,t).N((n=>n.reduce(((n,r)=>os(r,this.s,n,e,t)),new B)))}D(){return this.l.D()}},is=class extends Qn{constructor(e,t){super(new hr({external:1}),"*"===e?[]:[e],{B:!1},!1,t),this.l=e}h(e,t){return os(e.M,this.l,new B,e,t)}},ls=class extends Qn{constructor(e,t,n,r){const a=t.map((e=>e.eb));t=t.map((e=>e.name)),super(a.reduce(((e,t)=>e.add(t.o)),n.o),a.concat(n),{B:!1},!1,r),this.s=e,this.A=t,this.L=a,this.S=n,this.l=null}h(e,t){let n=e;const r=this.l.map(((r,a)=>{const o=Jn(this.L[a],n,t).O();return n=Ye(e,{[r]:()=>$.create(o)}),o}));if(r.some((e=>0===e.length)))return"every"===this.s?$.aa():$.V();const a=Array(r.length).fill(0);a[0]=-1;for(var o=!0;o;){o=!1;for(let n=0,i=a.length;n<i;++n){var s=r[n];if(!(++a[n]>s.length-1)){for(o=Object.create(null),s=0;s<a.length;s++){const e=r[s][a[s]];o[this.l[s]]=()=>$.m(e)}if(o=Ye(e,o),(o=Jn(this.S,o,t)).fa()&&"some"===this.s)return $.aa();if(!o.fa()&&"every"===this.s)return $.V();o=!0;break}a[n]=0}}return"every"===this.s?$.aa():$.V()}v(e){this.l=[];for(let n=0,r=this.A.length;n<r;++n){this.L[n].v(e),ca(e);var t=this.A[n];const r=t.prefix?e.$(t.prefix):null;t=ha(e,r,t.localName),this.l[n]=t}this.S.v(e);for(let t=0,n=this.A.length;t<n;++t)ma(e)}},cs=class extends Qn{constructor(e){super(e,[],{B:!1})}h(e){return this.l(e.M)?$.aa():$.V()}},us=class extends cs{constructor(e){super(new hr({nodeType:1})),this.s=e}l(e){return!!T(e.type,53)&&(e=e.value.node.nodeType,3===this.s&&4===e||this.s===e)}D(){return`type-${this.s}`}},ps=class extends cs{constructor(e,t={kind:null}){const n=e.prefix,r=e.namespaceURI,a={};"*"!==(e=e.localName)&&(a.nodeName=1),a.nodeType=1,super(new hr(a)),this.s=e,this.L=r,this.A=n,this.S=t.kind}l(e){const t=T(e.type,54),n=T(e.type,47);return!(!t&&!n)&&(e=e.value,!(null!==this.S&&(1===this.S&&!t||2===this.S&&!n))&&(null===this.A&&""!==this.L&&"*"===this.s||("*"===this.A?"*"===this.s||this.s===e.node.localName:("*"===this.s||this.s===e.node.localName)&&(e.node.namespaceURI||null)===((""===this.A?t?this.L:null:this.L)||null))))}D(){return"*"===this.s?null===this.S?"type-1-or-type-2":`type-${this.S}`:`name-${this.s}`}v(e){if(null===this.L&&"*"!==this.A&&(this.L=e.$(this.A||"")||null,!this.L&&this.A))throw Error(`XPST0081: The prefix ${this.A} could not be resolved.`)}},hs=class extends cs{constructor(e){super(new hr({nodeName:1})),this.s=e}l(e){return T(e.type,57)&&e.value.node.target===this.s}D(){return"type-7"}},ds=class extends cs{constructor(e){super(new hr({})),this.s=e}l(e){return T(e.type,F(this.s.prefix?this.s.prefix+":"+this.s.localName:this.s.localName))}},ms=class extends Qn{constructor(e,t,n){super(new hr({}),[],{B:!1,P:"unsorted"}),this.A=n,this.s=t,this.L=e,this.l=null}h(e,t){if(!e.qa[this.l]){if(this.S)return this.S(e,t);throw Error("XQDY0054: The variable "+this.A+" is declared but not in scope.")}return e.qa[this.l]()}v(e){if(null===this.s&&this.L&&(this.s=e.$(this.L)),this.l=e.cb(this.s||"",this.A),!this.l)throw Error("XPST0008, The variable "+this.A+" is not in scope.");(e=e.Ea[this.l])&&(this.S=e)}},fs=class extends xo{constructor(e,t){super(new hr({}),[e,t],{B:!1,W:!1,P:"unsorted",subtree:!1},t),this.A=e}L(e,t,n,r){let a=null,o=null;return r({next:()=>{for(;;){if(!o){var e=t.next(0);if(e.done)return A;a=e.value,o=Jn(this.A,a,n)}e=o.fa();const r=a;if(o=a=null,e)return E(r)}}})}},gs=class{constructor(e){this.type=e}},ys=class extends gs{constructor(e){super("delete"),this.target=e}h(e){return{type:this.type,target:Ur(this.target,e,!1)}}},ws=class extends gs{constructor(e,t,n){super(n),this.target=e,this.content=t}h(e){return{type:this.type,target:Ur(this.target,e,!1),content:this.content.map((t=>Ur(t,e,!0)))}}},vs=class extends ws{constructor(e,t){super(e,t,"insertAfter")}},xs=class extends gs{constructor(e,t){super("insertAttributes"),this.target=e,this.content=t}h(e){return{type:this.type,target:Ur(this.target,e,!1),content:this.content.map((t=>Ur(t,e,!0)))}}},bs=class extends ws{constructor(e,t){super(e,t,"insertBefore")}},As=class extends ws{constructor(e,t){super(e,t,"insertIntoAsFirst")}},Es=class extends ws{constructor(e,t){super(e,t,"insertIntoAsLast")}},Ns=class extends ws{constructor(e,t){super(e,t,"insertInto")}},Ts=class extends gs{constructor(e,t){super("rename"),this.target=e,this.o=t.za?t:new H(t.prefix,t.namespaceURI,t.localName)}h(e){return{type:this.type,target:Ur(this.target,e,!1),newName:{prefix:this.o.prefix,namespaceURI:this.o.namespaceURI,localName:this.o.localName}}}},Bs=class extends gs{constructor(e,t){super("replaceElementContent"),this.target=e,this.text=t}h(e){return{type:this.type,target:Ur(this.target,e,!1),text:this.text?Ur(this.text,e,!0):null}}},Is=class extends gs{constructor(e,t){super("replaceNode"),this.target=e,this.o=t}h(e){return{type:this.type,target:Ur(this.target,e,!1),replacement:this.o.map((t=>Ur(t,e,!0)))}}},Cs=class extends gs{constructor(e,t){super("replaceValue"),this.target=e,this.o=t}h(e){return{type:this.type,target:Ur(this.target,e,!1),"string-value":this.o}}},Ss=(e,t)=>new Is(e,t),Os=class extends sr{constructor(e){super(new hr({}),[e],{B:!1,P:"unsorted"}),this.l=e}s(e,t){const n=or(this.l)(e,t),r=t.h;let a,o;return{next:()=>{if(!a){const e=n.next(0);if(e.value.I.some((e=>!T(e.type,53))))throw Error("XUTY0007: The target of a delete expression must be a sequence of zero or more nodes.");a=e.value.I,o=e.value.da}return a=a.filter((e=>ne(r,e.value))),E({da:ar(a.map((e=>new ys(e.value))),o),I:[]})}}}};function Fs(e,t,n,r,a,o){const s=t.h;return e.reduce((function e(t,n){return T(n.type,62)?(n.h.forEach((n=>n().O().forEach((n=>e(t,n))))),t):(t.push(n),t)}),[]).forEach(((e,i,l)=>{if(T(e.type,47)){if(a)throw o(e.value,s);n.push(e.value.node)}else if(T(e.type,46)||T(e.type,53)&&3===e.value.node.nodeType){const n=T(e.type,46)?At(nt(e,t).first(),1).value:Z(s,e.value);0!==i&&T(l[i-1].type,46)&&T(e.type,46)?(r.push({data:" "+n,Ra:!0,nodeType:3}),a=!0):n&&(r.push({data:""+n,Ra:!0,nodeType:3}),a=!0)}else if(T(e.type,55)){const i=[];W(s,e.value).forEach((e=>i.push(ce(e)))),a=Fs(i,t,n,r,a,o)}else{if(!T(e.type,53)){if(T(e.type,60))throw et(e.type);throw Error(`Atomizing ${e.type} is not implemented.`)}r.push(e.value.node),a=!0}})),a}function Ds(e,t,n){const r=[],a=[];let o=!1;return e.forEach((e=>{o=Fs(e,t,r,a,o,n)})),{attributes:r,Wa:a}}function ks(e,t,n,r,a){const o=[];switch(e){case 4:r.length&&o.push(new xs(t,r)),a.length&&o.push(new As(t,a));break;case 5:r.length&&o.push(new xs(t,r)),a.length&&o.push(new Es(t,a));break;case 3:r.length&&o.push(new xs(t,r)),a.length&&o.push(new Ns(t,a));break;case 2:r.length&&o.push(new xs(n,r)),a.length&&o.push(new bs(t,a));break;case 1:r.length&&o.push(new xs(n,r)),a.length&&o.push(new vs(t,a))}return o}var Rs=class extends sr{constructor(e,t,n){super(new hr({}),[e,n],{B:!1,P:"unsorted"}),this.L=e,this.l=t,this.A=n}s(e,t){const n=or(this.L)(e,t),r=or(this.A)(e,t),a=t.h;let o,s,i,l,c,u;return{next:()=>{if(!o){var e=n.next(0);const r=Ds([e.value.I],t,Ln);o=r.attributes.map((e=>({node:e,F:null}))),s=r.Wa.map((e=>({node:e,F:null}))),i=e.value.da}if(!l){if(0===(e=r.next(0)).value.I.length)throw zn();if(3<=this.l){if(1!==e.value.I.length)throw Hn();if(!T(e.value.I[0].type,54)&&!T(e.value.I[0].type,55))throw Hn()}else{if(1!==e.value.I.length)throw Pn();if(!(T(e.value.I[0].type,54)||T(e.value.I[0].type,56)||T(e.value.I[0].type,58)||T(e.value.I[0].type,57)))throw Pn();if(u=ne(a,e.value.I[0].value,null),null===u)throw Error(`XUDY0029: The target ${e.value.I[0].value.outerHTML} for inserting a node before or after must have a parent.`)}l=e.value.I[0],c=e.value.da}if(o.length){if(3<=this.l){if(!T(l.type,54))throw Error("XUTY0022: An insert expression specifies the insertion of an attribute node into a document node.")}else if(1!==u.node.nodeType)throw Error("XUDY0030: An insert expression specifies the insertion of an attribute node before or after a child of a document node.");o.reduce(((e,t)=>{const n=t.node.prefix||"";var r=t.node.prefix||"";const a=t.node.namespaceURI,o=r?l.value.node.lookupNamespaceURI(r):null;if(o&&o!==a)throw Vn(a);if((r=e[r])&&a!==r)throw Yn(a);return e[n]=t.node.namespaceURI,e}),{})}return E({I:[],da:ar(ks(this.l,l.value,u||null,o,s),i,c)})}}}};const Ms=()=>Ze("Casting not supported from given type to a single xs:string or xs:untypedAtomic or any of its derived types."),Us=/([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]|[\uD800-\uDB7F][\uDC00-\uDFFF])/,Gs=new RegExp(`${Us.source}${new RegExp(`(${Us.source}|[-.0-9·̀-ͯ‿⁀])`).source}*`,"g"),$s=e=>!!(e=e.match(Gs))&&1===e.length;function Ls(e,t){return rt(t,e).Y({m:e=>{if(T((e=e.first()).type,1)||T(e.type,19)){if(!$s(e.value))throw Error(`XQDY0041: The value "${e.value}" of a name expressions cannot be converted to a NCName.`);return $.m(e)}throw Ms()},default:()=>{throw Ms()}}).value}function Hs(e,t,n){return rt(n,t).Y({m:t=>{if(T((t=t.first()).type,23))return $.m(t);if(T(t.type,1)||T(t.type,19)){let n,r;if(1===(t=t.value.split(":")).length?t=t[0]:(n=t[0],r=e.$(n),t=t[1]),!$s(t)||n&&!$s(n))throw aa(n?`${n}:${t}`:t);if(n&&!r)throw aa(`${n}:${t}`);return $.m({type:23,value:new H(n,r,t)})}throw Ms()},default:()=>{throw Ms()}}).value}var Ps=class extends sr{constructor(e,t){super(new hr({}),[e,t],{B:!1,P:"unsorted"}),this.A=e,this.L=t,this.l=void 0}s(e,t){const n=or(this.A)(e,t),r=or(this.L)(e,t);return{next:()=>{const e=n.next(0);var a=e.value.I;if(0===a.length)throw zn();if(1!==a.length)throw _n();if(!T(a[0].type,54)&&!T(a[0].type,47)&&!T(a[0].type,57))throw _n();a=a[0];const o=r.next(0);e:{var s=this.l,i=$.create(o.value.I);switch(a.type){case 54:if(s=Hs(s,t,i).next(0).value.value,(i=a.value.node.lookupNamespaceURI(s.prefix))&&i!==s.namespaceURI)throw Vn(s.namespaceURI);break e;case 47:if((s=Hs(s,t,i).next(0).value.value).namespaceURI&&(i=a.value.node.lookupNamespaceURI(s.prefix))&&i!==s.namespaceURI)throw Vn(s.namespaceURI);break e;case 57:s=Ls(t,i).next(0).value.value,s=new H("",null,s);break e}s=void 0}return E({I:[],da:ar([new Ts(a.value,s)],e.value.da,o.value.da)})}}}v(e){this.l=la(e),super.v(e)}};var js=class extends sr{constructor(e,t,n){super(new hr({}),[t,n],{B:!1,P:"unsorted"}),this.L=e,this.l=t,this.A=n}s(e,t){const n=or(this.l)(e,t);return e=or(this.A)(e,t),this.L?function(e,t,n){let r,a,o,s,i=!1;return{next:()=>{if(i)return A;if(!o){var l=n.next(0);const t=rt($.create(l.value.I),e).map((e=>At(e,1))).O().map((e=>e.value)).join(" ");o=0===t.length?null:{node:e.Ia.createTextNode(t),F:null},s=l.value.da}if(!r){if(0===(l=t.next(0)).value.I.length)throw zn();if(1!==l.value.I.length)throw jn();if(!(T(l.value.I[0].type,54)||T(l.value.I[0].type,47)||T(l.value.I[0].type,56)||T(l.value.I[0].type,58)||T(l.value.I[0].type,57)))throw jn();r=l.value.I[0],a=l.value.da}if(T(r.type,54))return i=!0,E({I:[],da:ar([new Bs(r.value,o)],s,a)});if(T(r.type,47)||T(r.type,56)||T(r.type,58)||T(r.type,57)){if(l=o?Z(e.h,o):"",T(r.type,58)&&(l.includes("--")||l.endsWith("-")))throw Error(`XQDY0072: The content "${l}" for a comment node contains two adjacent hyphens or ends with a hyphen.`);if(T(r.type,57)&&l.includes("?>"))throw Error(`XQDY0026: The content "${l}" for a processing instruction node contains "?>".`);return i=!0,E({I:[],da:ar([new Cs(r.value,l)],s,a)})}}}}(t,n,e):function(e,t,n){let r,a,o;return{next:()=>{if(!r){var s=n.next(0),i=Ds([s.value.I],e,Yn);r={attributes:i.attributes.map((e=>({node:e,F:null}))),Wa:i.Wa.map((e=>({node:e,F:null})))},a=s.value.da}if(0===(i=t.next(0)).value.I.length)throw zn();if(1!==i.value.I.length)throw jn();if(!(T(i.value.I[0].type,54)||T(i.value.I[0].type,47)||T(i.value.I[0].type,56)||T(i.value.I[0].type,58)||T(i.value.I[0].type,57)))throw jn();if(o=ne(e.h,i.value.I[0].value,null),null===o)throw Error(`XUDY0009: The target ${i.value.I[0].value.outerHTML} for replacing a node must have a parent.`);if(s=i.value.I[0],i=i.value.da,T(s.type,47)){if(r.Wa.length)throw Error("XUTY0011: When replacing an attribute the new value must be zero or more attribute nodes.");r.attributes.reduce(((e,t)=>{const n=t.node.prefix||"";t=t.node.namespaceURI;var r=o.node.lookupNamespaceURI(n);if(r&&r!==t)throw Vn(t);if((r=e[n])&&t!==r)throw Yn(t);return e[n]=t,e}),{})}else if(r.attributes.length)throw Error("XUTY0010: When replacing an an element, text, comment, or processing instruction node the new value must be a single node.");return E({I:[],da:ar([Ss(s.value,[].concat(r.attributes,r.Wa))],a,i)})}}}(t,n,e)}};function _s(e){switch(e.type){case"delete":return new ys({node:e.target,F:null});case"insertAfter":return new vs({node:e.target,F:null},e.content.map((e=>({node:e,F:null}))));case"insertBefore":return new bs({node:e.target,F:null},e.content.map((e=>({node:e,F:null}))));case"insertInto":return new Ns({node:e.target,F:null},e.content.map((e=>({node:e,F:null}))));case"insertIntoAsFirst":return new As({node:e.target,F:null},e.content.map((e=>({node:e,F:null}))));case"insertIntoAsLast":return new Es({node:e.target,F:null},e.content.map((e=>({node:e,F:null}))));case"insertAttributes":return new xs({node:e.target,F:null},e.content.map((e=>({node:e,F:null}))));case"rename":return new Ts({node:e.target,F:null},e.newName);case"replaceNode":return new Is({node:e.target,F:null},e.replacement.map((e=>({node:e,F:null}))));case"replaceValue":return new Cs({node:e.target,F:null},e["string-value"]);case"replaceElementContent":return new Bs({node:e.target,F:null},e.text?{node:e.text,F:null}:null);default:throw Error(`Unexpected type "${e.type}" when parsing a transferable pending update.`)}}function Xs(e,t,n){if(t.find((t=>Tt(t,e))))return!0;const r=ne(n,e);return!!r&&Xs(r,t,n)}var qs=class extends sr{constructor(e,t,n){super(new hr({}),e.reduce(((e,t)=>(e.push(t.eb),e)),[t,n]),{B:!1,P:"unsorted"}),this.l=e,this.L=t,this.A=n,this.J=null}h(e,t){return ir(e=this.s(e,t),(()=>{}))}s(e,t){const n=t.h,r=t.Ia,a=t.Ma,o=[];let s,i,l;const c=[],u=[];return{next:()=>{if(c.length!==this.l.length)for(var p=c.length;p<this.l.length;p++){const n=this.l[p];var h=o[p];if(h||(o[p]=h=or(n.eb)(e,t)),1!==(h=h.next(0)).value.I.length||!T(h.value.I[0].type,53))throw Error("XUTY0013: The source expression of a copy modify expression must return a single node.");const r=ce(Rr(h.value.I[0].value,t));c.push(r.value),u.push(h.value.da),e=Ye(e,{[n.dc]:()=>$.m(r)})}return l||(s||=or(this.L)(e,t),l=s.next(0).value.da),l.forEach((e=>{if(e.target&&!Xs(e.target,c,n))throw Error(`XUDY0014: The target ${e.target.node.outerHTML} must be a node created by the copy clause.`);if("put"===e.type)throw Error("XUDY0037: The modify expression of a copy modify expression can not contain a fn:put.")})),p=l.map((e=>_s(e=e.h(t)))),nr(p,n,r,a),i||=or(this.A)(e,t),E({I:(p=i.next(0)).value.I,da:ar(p.value.da,...u)})}}}v(e){ca(e),this.l.forEach((t=>t.dc=ha(e,t.Gb.namespaceURI,t.Gb.localName))),super.v(e),ma(e),this.J=this.l.some((e=>e.eb.J))||this.A.J}};function Vs(e,t){return{node:{nodeType:2,Ra:!0,nodeName:e.za(),namespaceURI:e.namespaceURI,prefix:e.prefix,localName:e.localName,name:e.za(),value:t},F:null}}var Ys=class extends Qn{constructor(e,t){let n=t.mb||[];n=n.concat(e.Na||[]),super(new hr({}),n,{B:!1,P:"unsorted"}),e.Na?this.s=e.Na:this.name=new H(e.prefix,e.namespaceURI,e.localName),this.l=t,this.A=void 0}h(e,t){let n,r,a,o=!1;return $.create({next:()=>{if(o)return A;if(!r){if(this.s){if(!n){var s=this.s.h(e,t);n=Hs(this.A,t,s)}r=n.next(0).value.value}else r=this.name;if(r){if("xmlns"===r.prefix)throw Wr(r);if(""===r.prefix&&"xmlns"===r.localName)throw Wr(r);if("http://www.w3.org/2000/xmlns/"===r.namespaceURI)throw Wr(r);if("xml"===r.prefix&&"http://www.w3.org/XML/1998/namespace"!==r.namespaceURI)throw Wr(r);if(""!==r.prefix&&"xml"!==r.prefix&&"http://www.w3.org/XML/1998/namespace"===r.namespaceURI)throw Wr(r)}}return this.l.mb?(s=this.l.mb,a||(a=Qe(s.map((n=>rt(n.h(e,t),t).N((e=>$.m(y(e.map((e=>e.value)).join(" "),1))))))).N((e=>$.m(ce(Vs(r,e.map((e=>e.value)).join("")))))).value),a.next(0)):(o=!0,E(ce(Vs(r,this.l.value))))}})}v(e){if(this.A=la(e),this.name&&this.name.prefix&&!this.name.namespaceURI){const t=e.$(this.name.prefix);if(void 0===t&&this.name.prefix)throw tt(this.name.prefix);this.name.namespaceURI=t||null}super.v(e)}},zs=class extends Qn{constructor(e){super(e?e.o:new hr({}),e?[e]:[],{B:!1,P:"unsorted"}),this.l=e}h(e,t){const n={data:"",Ra:!0,nodeType:8},r={node:n,F:null};return this.l?rt(e=Jn(this.l,e,t),t).N((e=>{if(e=e.map((e=>At(e,1).value)).join(" "),-1!==e.indexOf("--\x3e"))throw Error('XQDY0072: The contents of the data of a comment may not include "--\x3e"');return n.data=e,$.m(ce(r))})):$.m(ce(r))}},Js=class extends Qn{constructor(e,t,n,r){super(new hr({}),r.concat(t).concat(e.Na||[]),{B:!1,P:"unsorted"}),e.Na?this.s=e.Na:this.l=new H(e.prefix,e.namespaceURI,e.localName),this.S=n.reduce(((e,t)=>{if(t.prefix in e)throw Error(`XQST0071: The namespace declaration with the prefix ${t.prefix} has already been declared on the constructed element.`);return e[t.prefix||""]=t.uri,e}),{}),this.L=t,this.ma=r,this.A=void 0}h(e,t){let n,r,a,o,s,i=!1,l=!1,c=!1;return $.create({next:()=>{if(c)return A;if(i||(n||=Qe(this.L.map((n=>Jn(n,e,t)))),r=n.O(),i=!0),!l){a||=this.ma.map((n=>Jn(n,e,t)));for(var u=[],p=0;p<a.length;p++){var h=a[p].O();u.push(h)}o=u,l=!0}if(this.s&&(s||(u=this.s.h(e,t),s=Hs(this.A,t,u)),this.l=s.next(0).value.value),"xmlns"===this.l.prefix||"http://www.w3.org/2000/xmlns/"===this.l.namespaceURI||"xml"===this.l.prefix&&"http://www.w3.org/XML/1998/namespace"!==this.l.namespaceURI||this.l.prefix&&"xml"!==this.l.prefix&&"http://www.w3.org/XML/1998/namespace"===this.l.namespaceURI)throw Error(`XQDY0096: The node name "${this.l.za()}" is invalid for a computed element constructor.`);const d={nodeType:1,Ra:!0,attributes:[],childNodes:[],nodeName:this.l.za(),namespaceURI:this.l.namespaceURI,prefix:this.l.prefix,localName:this.l.localName};for(u={node:d,F:null},r.forEach((e=>{d.attributes.push(e.value.node)})),(p=Ds(o,t,Kr)).attributes.forEach((e=>{if(d.attributes.find((t=>t.namespaceURI===e.namespaceURI&&t.localName===e.localName)))throw Error(`XQDY0025: The attribute ${e.name} does not have an unique name in the constructed element.`);d.attributes.push(e)})),p.Wa.forEach((e=>{d.childNodes.push(e)})),p=0;p<d.childNodes.length;p++){if(!z(h=d.childNodes[p])||3!==h.nodeType)continue;const e=d.childNodes[p-1];e&&z(e)&&3===e.nodeType&&(e.data+=h.data,d.childNodes.splice(p,1),p--)}return c=!0,E(ce(u))}})}v(e){if(ca(e),Object.keys(this.S).forEach((t=>pa(e,t,this.S[t]))),this.Ka.forEach((t=>t.v(e))),this.L.reduce(((t,n)=>{if(n.name){if(n=`Q{${null===n.name.namespaceURI?e.$(n.name.prefix):n.name.namespaceURI}}${n.name.localName}`,t.includes(n))throw Error(`XQST0040: The attribute ${n} does not have an unique name in the constructed element.`);t.push(n)}return t}),[]),this.l&&null===this.l.namespaceURI){const t=e.$(this.l.prefix);if(void 0===t&&this.l.prefix)throw tt(this.l.prefix);this.l.namespaceURI=t}this.A=la(e),ma(e)}};function Qs(e){if(/^xml$/i.test(e))throw Error(`XQDY0064: The target of a created PI may not be "${e}"`)}function Ks(e,t){return{node:{data:t,Ra:!0,nodeName:e,nodeType:7,target:e},F:null}}var Ws=class extends Qn{constructor(e,t){const n=e.vb?[e.vb].concat(t):[t];super(n.reduce(((e,t)=>e.add(t.o)),new hr({})),n,{B:!1,P:"unsorted"}),this.l=e,this.s=t}h(e,t){return rt(Jn(this.s,e,t),t).N((n=>{const r=n.map((e=>At(e,1).value)).join(" ");if(-1!==r.indexOf("?>"))throw Error('XQDY0026: The contents of the data of a processing instruction may not include "?>"');if(null!==this.l.Db)return Qs(n=this.l.Db),$.m(ce(Ks(n,r)));n=Jn(this.l.vb,e,t);const a=Ls(t,n);return $.create({next:()=>{var e=a.next(0);return e.done?e:(Qs(e=e.value.value),E(ce(Ks(e,r))))}})}))}},Zs=class extends Qn{constructor(e){super(e?e.o:new hr({}),e?[e]:[],{B:!1,P:"unsorted"}),this.l=e}h(e,t){return this.l?rt(e=Jn(this.l,e,t),t).N((e=>0===e.length?$.empty():(e={node:{data:e.map((e=>At(e,1).value)).join(" "),Ra:!0,nodeType:3},F:null},$.m(ce(e))))):$.empty()}},ei=class extends lr{constructor(e,t,n,r){super(new hr({}),[e,...t.map((e=>e.Xb)),n].concat(...t.map((e=>e.Fb.map((e=>e.Eb))))),{B:!1,W:!1,P:"unsorted",subtree:!1},r),this.L=e,this.l=t.length,this.S=t.map((e=>e.Fb))}A(e,t,n){return n[0](e).N((r=>{for(let a=0;a<this.l;a++)if(this.S[a].some((n=>{switch(n.bc){case"?":if(1<r.length)return!1;break;case"*":break;case"+":if(1>r.length)return!1;break;default:if(1!==r.length)return!1}const a=$.create(r);return r.every(((r,o)=>(r=je(e,o,r,a),Jn(n.Eb,r,t).fa())))})))return n[a+1](e);return n[this.l+1](e)}))}v(e){if(super.v(e),this.L.J)throw $n()}},ti={Z:!1,ra:!1},ni={Z:!0,ra:!1},ri={Z:!0,ra:!0};function ai(e){return e.Z?e.ra?ri:ni:ti}function oi(e,t){switch(e[0]){case"andOp":var n=wa(e,"type");return new So(ii("andOp",e,ai(t)),n);case"orOp":return n=wa(e,"type"),new Oo(ii("orOp",e,ai(t)),n);case"unaryPlusOp":return n=ga(ga(e,"operand"),"*"),e=wa(e,"type"),new Co("+",oi(n,t),e);case"unaryMinusOp":return n=ga(ga(e,"operand"),"*"),e=wa(e,"type"),new Co("-",oi(n,t),e);case"addOp":case"subtractOp":case"multiplyOp":case"divOp":case"idivOp":case"modOp":var r=e[0],a=oi(va(e,["firstOperand","*"]),ai(t));t=oi(va(e,["secondOperand","*"]),ai(t));const o=wa(e,"type"),s=wa(va(e,["firstOperand","*"]),"type"),i=wa(va(e,["secondOperand","*"]),"type");return s&&i&&wa(e,"type")&&(n=Sa(r,s.type,i.type)),new Da(r,a,t,o,n);case"sequenceExpr":return function(e,t){var n=xa(e,"*").map((e=>oi(e,t)));return 1===n.length?n[0]:(n=wa(e,"type"),new jo(xa(e,"*").map((e=>oi(e,t))),n))}(e,t);case"unionOp":return n=wa(e,"type"),new Ko([oi(va(e,["firstOperand","*"]),ai(t)),oi(va(e,["secondOperand","*"]),ai(t))],n);case"exceptOp":case"intersectOp":return n=wa(e,"type"),new Po(e[0],oi(va(e,["firstOperand","*"]),ai(t)),oi(va(e,["secondOperand","*"]),ai(t)),n);case"stringConcatenateOp":return function(e,t){const n=wa(e,"type");return e=[va(e,["firstOperand","*"]),va(e,["secondOperand","*"])],new yr(new Bo({localName:"concat",namespaceURI:"http://www.w3.org/2005/xpath-functions",prefix:""},e.length,n),e.map((e=>oi(e,ai(t)))),n)}(e,t);case"rangeSequenceExpr":return function(e,t){const n=wa(e,"type");e=[ga(ga(e,"startExpr"),"*"),ga(ga(e,"endExpr"),"*")];const r=new Bo({localName:"to",namespaceURI:"http://fontoxpath/operators",prefix:""},e.length,n);return new yr(r,e.map((e=>oi(e,ai(t)))),n)}(e,t);case"equalOp":case"notEqualOp":case"lessThanOrEqualOp":case"lessThanOp":case"greaterThanOrEqualOp":case"greaterThanOp":return ci("generalCompare",e,t);case"eqOp":case"neOp":case"ltOp":case"leOp":case"gtOp":case"geOp":return ci("valueCompare",e,t);case"isOp":case"nodeBeforeOp":case"nodeAfterOp":return ci("nodeCompare",e,t);case"pathExpr":return function(e,t){const n=wa(e,"type");var r=xa(e,"stepExpr");let a=!1;var o=r.map((e=>{var r=ga(e,"xpathAxis");let o;var s=xa(e,"*");const i=[];let l=null;for(const e of s)switch(e[0]){case"lookup":i.push(["lookup",li(e,t)]);break;case"predicate":case"predicates":for(const n of xa(e,"*"))s=oi(n,ai(t)),l=Za(l,s.D()),i.push(["predicate",s])}if(r)switch(a=!0,e=ga(e,"attributeTest anyElementTest piTest documentTest elementTest commentTest namespaceTest anyKindTest textTest anyFunctionTest typedFunctionTest schemaAttributeTest atomicType anyItemType parenthesizedItemType typedMapTest typedArrayTest nameTest Wildcard".split(" ")),e=si(e),ya(r)){case"ancestor":o=new Ka(e,{Qa:!1});break;case"ancestor-or-self":o=new Ka(e,{Qa:!0});break;case"attribute":o=new eo(e,l);break;case"child":o=new to(e,l);break;case"descendant":o=new ro(e,{Qa:!1});break;case"descendant-or-self":o=new ro(e,{Qa:!0});break;case"parent":o=new lo(e,l);break;case"following-sibling":o=new io(e,l);break;case"preceding-sibling":o=new uo(e,l);break;case"following":o=new so(e);break;case"preceding":o=new co(e);break;case"self":o=new po(e,l)}else o=oi(r=va(e,["filterExpr","*"]),ai(t));for(const e of i)switch(e[0]){case"lookup":o=new ss(o,e[1]);break;case"predicate":o=new rs(o,e[1])}return o.type=n,o}));return e=ga(e,"rootExpr"),!(r=a||null!==e||1<r.length)&&1===o.length||!e&&1===o.length&&"sorted"===o[0].ia?o[0]:e&&0===o.length?new es(null):(o=new ns(o,r),e?new es(o):o)}(e,t);case"contextItemExpr":return new ts(wa(e,"type"));case"functionCallExpr":return function(e,t){const n=ga(e,"functionName"),r=xa(ga(e,"arguments"),"*");return e=wa(e,"type"),new yr(new Bo(ba(n),r.length,e),r.map((e=>"argumentPlaceholder"===e[0]?null:oi(e,t))),e)}(e,t);case"inlineFunctionExpr":return function(e,t){const n=xa(ga(e,"paramList"),"*"),r=va(e,["functionBody","*"]),a=wa(e,"type");return new Ao(n.map((e=>({name:ba(ga(e,"varName")),type:Aa(e)}))),Aa(e),r?oi(r,t):new jo([],a))}(e,t);case"arrowExpr":return function(e,t){const n=wa(e,"type");var r=va(e,["argExpr","*"]);e=xa(e,"*").slice(1),r=[oi(r,t)];for(let o=0;o<e.length;o++)if("arguments"!==e[o][0]){if("arguments"===e[o+1][0]){var a=xa(e[o+1],"*");r=r.concat(a.map((e=>"argumentPlaceholder"===e[0]?null:oi(e,t))))}a="EQName"===e[o][0]?new Bo(ba(e[o]),r.length,n):oi(e[o],ai(t)),r=[new yr(a,r,n)]}return r[0]}(e,t);case"dynamicFunctionInvocationExpr":return function(e,t){const n=va(e,["functionItem","*"]),r=wa(e,"type");e=ga(e,"arguments");let a=[];return e&&(a=xa(e,"*").map((e=>"argumentPlaceholder"===e[0]?null:oi(e,t)))),new yr(oi(n,t),a,r)}(e,t);case"namedFunctionRef":return t=ga(e,"functionName"),n=wa(e,"type"),e=ya(va(e,["integerConstantExpr","value"])),new Bo(ba(t),parseInt(e,10),n);case"integerConstantExpr":return new No(ya(ga(e,"value")),{type:5,g:3});case"stringConstantExpr":return new No(ya(ga(e,"value")),{type:1,g:3});case"decimalConstantExpr":return new No(ya(ga(e,"value")),{type:4,g:3});case"doubleConstantExpr":return new No(ya(ga(e,"value")),{type:3,g:3});case"varRef":const{prefix:l,namespaceURI:c,localName:u}=ba(ga(e,"name"));return new ms(l,c,u);case"flworExpr":return function(e,t){var n=xa(e,"*");if(e=ga(n[n.length-1],"*"),1<(n=n.slice(0,-1)).length&&!t.Z)throw Error("XPST0003: Use of XQuery FLWOR expressions in XPath is no allowed");return n.reduceRight(((e,n)=>{switch(n[0]){case"forClause":for(var r=(n=xa(n,"*")).length-1;0<=r;--r){var a=n[r],o=va(a,["forExpr","*"]);const s=ga(a,"positionalVariableBinding");e=new bo(ba(va(a,["typedVariableBinding","varName"])),oi(o,ai(t)),s?ba(s):null,e)}return e;case"letClause":for(r=(n=xa(n,"*")).length-1;0<=r;--r)o=va(a=n[r],["letExpr","*"]),e=new Eo(ba(va(a,["typedVariableBinding","varName"])),oi(o,ai(t)),e);return e;case"whereClause":for(r=(n=xa(n,"*")).length-1;0<=r;--r)e=new fs(oi(n[r],t),e);return e;case"windowClause":case"groupByClause":case"countClause":throw Error(`Not implemented: ${n[0]} is not implemented yet.`);case"orderByClause":return function(e,t,n){return e=xa(e,"*"),new Zo(e.filter((e=>"stable"!==e[0])).map((e=>{var n=ga(e,"orderModifier"),r=n?ga(n,"orderingKind"):null;return n=n?ga(n,"emptyOrderingMode"):null,r=!r||"ascending"===ya(r),n=!n||"empty least"===ya(n),{ba:oi(va(e,["orderByExpr","*"]),t),zb:r,$b:n}})),n)}(n,t,e);default:throw Error(`Not implemented: ${n[0]} is not supported in a flwor expression`)}}),oi(e,t))}(e,t);case"quantifiedExpr":return function(e,t){const n=wa(e,"type"),r=ya(ga(e,"quantifier")),a=va(e,["predicateExpr","*"]);return e=xa(e,"quantifiedExprInClause").map((e=>({name:ba(va(e,["typedVariableBinding","varName"])),eb:oi(e=va(e,["sourceExpr","*"]),ai(t))}))),new ls(r,e,oi(a,ai(t)),n)}(e,t);case"ifThenElseExpr":return n=wa(e,"type"),new ho(oi(ga(ga(e,"ifClause"),"*"),ai(t)),oi(ga(ga(e,"thenClause"),"*"),t),oi(ga(ga(e,"elseClause"),"*"),t),n);case"instanceOfExpr":return n=oi(va(e,["argExpr","*"]),t),r=va(e,["sequenceType","*"]),a=va(e,["sequenceType","occurrenceIndicator"]),e=wa(e,"type"),new Yo(n,oi(r,ai(t)),a?ya(a):"",e);case"castExpr":return t=oi(ga(ga(e,"argExpr"),"*"),ai(t)),n=ga(e,"singleType"),e=ba(ga(n,"atomicType")),n=null!==ga(n,"optional"),new qo(t,e,n);case"castableExpr":return t=oi(ga(ga(e,"argExpr"),"*"),ai(t)),n=ga(e,"singleType"),e=ba(ga(n,"atomicType")),n=null!==ga(n,"optional"),new Xo(t,e,n);case"simpleMapExpr":return function(e,t){const n=wa(e,"type");return xa(e,"*").reduce(((e,r)=>null===e?oi(r,ai(t)):new _o(e,oi(r,ai(t)),n)),null)}(e,t);case"mapConstructor":return function(e,t){const n=wa(e,"type");return new To(xa(e,"mapConstructorEntry").map((e=>({key:oi(va(e,["mapKeyExpr","*"]),ai(t)),value:oi(va(e,["mapValueExpr","*"]),ai(t))}))),n)}(e,t);case"arrayConstructor":return function(e,t){const n=wa(e,"type"),r=xa(e=ga(e,"*"),"arrayElem").map((e=>oi(ga(e,"*"),ai(t))));switch(e[0]){case"curlyArray":return new za(r,n);case"squareArray":return new Ja(r,n);default:throw Error("Unrecognized arrayType: "+e[0])}}(e,t);case"unaryLookup":return n=wa(e,"type"),new is(li(e,t),n);case"typeswitchExpr":return function(e,t){if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const n=wa(e,"type"),r=oi(ga(ga(e,"argExpr"),"*"),t),a=xa(e,"typeswitchExprCaseClause").map((e=>{const n=0===xa(e,"sequenceTypeUnion").length?[ga(e,"sequenceType")]:xa(ga(e,"sequenceTypeUnion"),"sequenceType");return{Xb:oi(va(e,["resultExpr","*"]),t),Fb:n.map((e=>{const n=ga(e,"occurrenceIndicator");return{bc:n?ya(n):"",Eb:oi(ga(e,"*"),t)}}))}}));return e=oi(va(e,["typeswitchExprDefaultClause","resultExpr","*"]),t),new ei(r,a,e,n)}(e,t);case"elementConstructor":return function(e,t){if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const n=ba(ga(e,"tagName"));var r=ga(e,"attributeList");const a=r?xa(r,"attributeConstructor").map((e=>oi(e,ai(t)))):[];return r=r?xa(r,"namespaceDeclaration").map((e=>{const t=ga(e,"prefix");return{prefix:t?ya(t):"",uri:ya(ga(e,"uri"))}})):[],e=(e=ga(e,"elementContent"))?xa(e,"*").map((e=>oi(e,ai(t)))):[],new Js(n,a,r,e)}(e,t);case"attributeConstructor":return function(e,t){if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const n=ba(ga(e,"attributeName"));var r=ga(e,"attributeValue");return r=r?ya(r):null,e=(e=ga(e,"attributeValueExpr"))?xa(e,"*").map((e=>oi(e,ai(t)))):null,new Ys(n,{value:r,mb:e})}(e,t);case"computedAttributeConstructor":return(n=ga(e,"tagName"))?n=ba(n):(n=ga(e,"tagNameExpr"),n={Na:oi(ga(n,"*"),ai(t))}),e=oi(ga(ga(e,"valueExpr"),"*"),ai(t)),new Ys(n,{mb:[e]});case"computedCommentConstructor":if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");return e=(e=ga(e,"argExpr"))?oi(ga(e,"*"),ai(t)):null,new zs(e);case"computedTextConstructor":if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");return e=(e=ga(e,"argExpr"))?oi(ga(e,"*"),ai(t)):null,new Zs(e);case"computedElementConstructor":return function(e,t){var n=ga(e,"tagName");return n?n=ba(n):(n=ga(e,"tagNameExpr"),n={Na:oi(ga(n,"*"),ai(t))}),e=(e=ga(e,"contentExpr"))?xa(e,"*").map((e=>oi(e,ai(t)))):[],new Js(n,[],[],e)}(e,t);case"computedPIConstructor":if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");return n=ga(e,"piTargetExpr"),r=ga(e,"piTarget"),a=ga(e,"piValueExpr"),e=wa(e,"type"),new Ws({vb:n?oi(ga(n,"*"),ai(t)):null,Db:r?ya(r):null},a?oi(ga(a,"*"),ai(t)):new jo([],e));case"CDataSection":return new No(ya(e),{type:1,g:3});case"deleteExpr":return e=oi(va(e,["targetExpr","*"]),t),new Os(e);case"insertExpr":switch(n=oi(va(e,["sourceExpr","*"]),t),(a=xa(e,"*")[1])[0]){case"insertAfter":r=1;break;case"insertBefore":r=2;break;case"insertInto":r=(r=ga(a,"*"))?"insertAsFirst"===r[0]?4:5:3}return e=oi(va(e,["targetExpr","*"]),t),new Rs(n,r,e);case"renameExpr":return n=oi(va(e,["targetExpr","*"]),t),e=oi(va(e,["newNameExpr","*"]),t),new Ps(n,e);case"replaceExpr":return n=!!ga(e,"replaceValue"),r=oi(va(e,["targetExpr","*"]),t),e=oi(va(e,["replacementExpr","*"]),t),new js(n,r,e);case"transformExpr":return function(e,t){const n=xa(ga(e,"transformCopies"),"transformCopy").map((e=>{const n=ba(ga(ga(e,"varRef"),"name"));return{eb:oi(ga(ga(e,"copySource"),"*"),t),Gb:new H(n.prefix,n.namespaceURI,n.localName)}})),r=oi(ga(ga(e,"modifyExpr"),"*"),t);return e=oi(ga(ga(e,"returnExpr"),"*"),t),new qs(n,r,e)}(e,t);case"x:stackTrace":for(n=e[1],e=e[2];"x:stackTrace"===e[0];)e=e[2];return new yo(n,e[0],oi(e,t));default:return si(e)}}function si(e){switch(e[0]){case"nameTest":return new ps(ba(e));case"piTest":return(e=ga(e,"piTarget"))?new hs(ya(e)):new us(7);case"commentTest":return new us(8);case"textTest":return new us(3);case"documentTest":return new us(9);case"attributeTest":var t=(e=ga(e,"attributeName"))&&ga(e,"star");return!e||t?new us(2):new ps(ba(ga(e,"QName")),{kind:2});case"elementTest":return t=(e=ga(e,"elementName"))&&ga(e,"star"),!e||t?new us(1):new ps(ba(ga(e,"QName")),{kind:1});case"anyKindTest":return new ds({prefix:"",namespaceURI:null,localName:"node()"});case"anyMapTest":return new ds({prefix:"",namespaceURI:null,localName:"map(*)"});case"anyArrayTest":return new ds({prefix:"",namespaceURI:null,localName:"array(*)"});case"Wildcard":return ga(e,"star")?(t=ga(e,"uri"))?e=new ps({localName:"*",namespaceURI:ya(t),prefix:""}):(t=ga(e,"NCName"),e="star"===ga(e,"*")[0]?new ps({localName:ya(t),namespaceURI:null,prefix:"*"}):new ps({localName:"*",namespaceURI:null,prefix:ya(t)})):e=new ps({localName:"*",namespaceURI:null,prefix:"*"}),e;case"atomicType":return new ds(ba(e));case"anyItemType":return new ds({prefix:"",namespaceURI:null,localName:"item()"});default:throw Error("No selector counterpart for: "+e[0]+".")}}function ii(e,t,n){const r=[];return function t(a){const o=ga(ga(a,"firstOperand"),"*");a=ga(ga(a,"secondOperand"),"*"),o[0]===e?t(o):r.push(oi(o,n)),a[0]===e?t(a):r.push(oi(a,n))}(t),r}function li(e,t){switch((e=ga(e,"*"))[0]){case"NCName":return new No(ya(e),{type:1,g:3});case"star":return"*";default:return oi(e,ai(t))}}function ci(e,t,n){var r=va(t,["firstOperand","*"]);const a=va(t,["secondOperand","*"]);switch(r=oi(r,ai(n)),n=oi(a,ai(n)),e){case"valueCompare":return new Mo(t[0],r,n);case"nodeCompare":return new Lo(t[0],r,n);case"generalCompare":return new Go(t[0],r,n)}}function ui(e,t){return oi(e,t)}const pi=new Map;class hi{constructor(e,t,n,r,a,o){this.v=e,this.D=t,this.h=n,this.jb=r,this.o=a,this.l=o}}function di(e,t,n,r,a,o,s){let i=pi.get(e);i||(i=Object.create(null),pi.set(e,i)),(t=i[e=t+(o?"_DEBUG":"")])||(t=i[e]=[]),t.push(new hi(Object.values(n.h),Object.values(n.o),a,Object.keys(r).map((e=>({namespaceURI:r[e],prefix:e}))),s,n.D))}function mi(e){var t=new q;if("http://www.w3.org/2005/XQueryX"!==e.namespaceURI&&"http://www.w3.org/2005/XQueryX"!==e.namespaceURI&&"http://fontoxml.com/fontoxpath"!==e.namespaceURI&&"http://www.w3.org/2007/xquery-update-10"!==e.namespaceURI)throw Ze("The XML structure passed as an XQueryX program was not valid XQueryX");const n=["stackTrace"===e.localName?"x:stackTrace":e.localName],r=t.getAllAttributes(e);r&&0<r.length&&n.push(Array.from(r).reduce(((t,n)=>("start"===n.localName||"end"===n.localName&&"stackTrace"===e.localName?t[n.localName]=JSON.parse(n.value):"type"===n.localName?t[n.localName]=D(n.value):t[n.localName]=n.value,t)),{})),t=t.getChildNodes(e);for(const e of t)switch(e.nodeType){case 1:n.push(mi(e));break;case 3:n.push(e.data)}return n}const fi=Object.create(null);var gi=(e,t)=>{let n=fi[e];n||=fi[e]={Ha:[],Ta:[],oa:null,source:t.source};const r=n.oa||(()=>{});n.Ha=n.Ha.concat(t.Ha),n.Ta=n.Ta.concat(t.Ta),n.oa=e=>{r(e),t.oa&&t.oa(e)}},yi=(e,t)=>{const n=fi[t];if(!n)throw Error(`XQST0051: No modules found with the namespace uri ${t}`);n.Ha.forEach((n=>{n.bb&&ua(e,t,n.localName,n.arity,n)})),n.Ta.forEach((n=>{ha(e,t,n.localName),da(e,t,n.localName,((e,t)=>Jn(n.ba,e,t)))}))},wi=()=>{Object.keys(fi).forEach((e=>{if((e=fi[e]).oa)try{e.oa(e)}catch(t){e.oa=null,_r(e.source,t)}e.oa=null}))};function vi(e){return e.replace(/(\x0D\x0A)|(\x0D(?!\x0A))/g,String.fromCharCode(10))}var xi=t;function bi(e,t){return(n,r)=>t.has(r)?t.get(r):(n=e(n,r),t.set(r,n),n)}function Ai(e,t){return(0,xi.delimited)(t,e,t)}function Ei(e,t){return e.reverse().reduce(((e,t)=>(0,xi.preceded)(t,e)),t)}function Ni(e,t,n,r){return(0,xi.then)((0,xi.then)(e,t,((e,t)=>[e,t])),n,(([e,t],n)=>r(e,t,n)))}function Ti(e,t,n,r,a){return(0,xi.then)((0,xi.then)((0,xi.then)(e,t,((e,t)=>[e,t])),n,(([e,t],n)=>[e,t,n])),r,(([e,t,n],r)=>a(e,t,n,r)))}function Bi(e){return(0,xi.map)(e,(e=>[e]))}function Ii(e,t){return(0,xi.map)((0,xi.or)(e),(()=>t))}function Ci(e){return(t,n)=>(t=e.exec(t.substring(n)))&&0===t.index?(0,xi.okWithValue)(n+t[0].length,t[0]):(0,xi.error)(n,[e.source],!1)}var Si=(0,xi.or)([(0,xi.token)(" "),(0,xi.token)("\t"),(0,xi.token)("\r"),(0,xi.token)("\n")]),Oi=(0,xi.token)("(:"),Fi=(0,xi.token)(":)"),Di=(0,xi.token)("(#"),ki=(0,xi.token)("#)"),Ri=(0,xi.token)("("),Mi=(0,xi.token)(")"),Ui=(0,xi.token)("["),Gi=(0,xi.token)("]"),$i=(0,xi.token)("{"),Li=(0,xi.token)("}"),Hi=(0,xi.token)("{{"),Pi=(0,xi.token)("}}"),ji=(0,xi.token)("'"),_i=(0,xi.token)("''"),Xi=(0,xi.token)('"'),qi=(0,xi.token)('""'),Vi=(0,xi.token)("<![CDATA["),Yi=(0,xi.token)("]]>"),zi=(0,xi.token)("/>"),Ji=(0,xi.token)("</"),Qi=(0,xi.token)("\x3c!--"),Ki=(0,xi.token)("--\x3e"),Wi=(0,xi.token)("<?"),Zi=(0,xi.token)("?>"),el=(0,xi.token)("&#x"),tl=(0,xi.token)("&#"),nl=(0,xi.token)(":*"),rl=(0,xi.token)("*:"),al=(0,xi.token)(":="),ol=(0,xi.token)("&"),sl=(0,xi.token)(":"),il=(0,xi.token)(";"),ll=(0,xi.token)("*"),cl=(0,xi.token)("@"),ul=(0,xi.token)("$"),pl=(0,xi.token)("#"),hl=(0,xi.token)("%"),dl=(0,xi.token)("?"),ml=(0,xi.token)("="),fl=(0,xi.followed)((0,xi.token)("!"),(0,xi.not)((0,xi.peek)(ml),[])),gl=(0,xi.followed)((0,xi.token)("|"),(0,xi.not)((0,xi.peek)((0,xi.token)("|")),[])),yl=(0,xi.token)("||"),wl=(0,xi.token)("!="),vl=(0,xi.token)("<"),xl=(0,xi.token)("<<"),bl=(0,xi.token)("<="),Al=(0,xi.token)(">"),El=(0,xi.token)(">>"),Nl=(0,xi.token)(">="),Tl=(0,xi.token)(","),Bl=(0,xi.token)("."),Il=(0,xi.token)(".."),Cl=(0,xi.token)("+"),Sl=(0,xi.token)("-"),Ol=(0,xi.token)("/"),Fl=(0,xi.token)("//"),Dl=(0,xi.token)("=>"),kl=(0,xi.token)("e"),Rl=(0,xi.token)("E");(0,xi.token)("l"),(0,xi.token)("L"),(0,xi.token)("m"),(0,xi.token)("M");var Ml=(0,xi.token)("Q");(0,xi.token)("x"),(0,xi.token)("X");var Ul=(0,xi.token)("as"),Gl=(0,xi.token)("cast"),$l=(0,xi.token)("castable"),Ll=(0,xi.token)("treat"),Hl=(0,xi.token)("instance"),Pl=(0,xi.token)("of"),jl=(0,xi.token)("node"),_l=(0,xi.token)("nodes"),Xl=(0,xi.token)("delete"),ql=(0,xi.token)("value"),Vl=(0,xi.token)("function"),Yl=(0,xi.token)("map"),zl=(0,xi.token)("element"),Jl=(0,xi.token)("attribute"),Ql=(0,xi.token)("schema-element"),Kl=(0,xi.token)("intersect"),Wl=(0,xi.token)("except"),Zl=(0,xi.token)("union"),ec=(0,xi.token)("to"),tc=(0,xi.token)("is"),nc=(0,xi.token)("or"),rc=(0,xi.token)("and"),ac=(0,xi.token)("div"),oc=(0,xi.token)("idiv"),sc=(0,xi.token)("mod"),ic=(0,xi.token)("eq"),lc=(0,xi.token)("ne"),cc=(0,xi.token)("lt"),uc=(0,xi.token)("le"),pc=(0,xi.token)("gt"),hc=(0,xi.token)("ge"),dc=(0,xi.token)("amp"),mc=(0,xi.token)("quot"),fc=(0,xi.token)("apos"),gc=(0,xi.token)("if"),yc=(0,xi.token)("then"),wc=(0,xi.token)("else"),vc=(0,xi.token)("allowing"),xc=(0,xi.token)("empty"),bc=(0,xi.token)("at"),Ac=(0,xi.token)("in"),Ec=(0,xi.token)("for"),Nc=(0,xi.token)("let"),Tc=(0,xi.token)("where"),Bc=(0,xi.token)("collation"),Ic=(0,xi.token)("group"),Cc=(0,xi.token)("by"),Sc=(0,xi.token)("order"),Oc=(0,xi.token)("stable"),Fc=(0,xi.token)("return"),Dc=(0,xi.token)("array"),kc=(0,xi.token)("document"),Rc=(0,xi.token)("namespace"),Mc=(0,xi.token)("text"),Uc=(0,xi.token)("comment"),Gc=(0,xi.token)("processing-instruction"),$c=(0,xi.token)("lax"),Lc=(0,xi.token)("strict"),Hc=(0,xi.token)("validate"),Pc=(0,xi.token)("type"),jc=(0,xi.token)("declare"),_c=(0,xi.token)("default"),Xc=(0,xi.token)("boundary-space"),qc=(0,xi.token)("strip"),Vc=(0,xi.token)("preserve"),Yc=(0,xi.token)("no-preserve"),zc=(0,xi.token)("inherit"),Jc=(0,xi.token)("no-inherit"),Qc=(0,xi.token)("greatest"),Kc=(0,xi.token)("least"),Wc=(0,xi.token)("copy-namespaces"),Zc=(0,xi.token)("decimal-format"),eu=(0,xi.token)("case"),tu=(0,xi.token)("typeswitch"),nu=(0,xi.token)("some"),ru=(0,xi.token)("every"),au=(0,xi.token)("satisfies"),ou=(0,xi.token)("replace"),su=(0,xi.token)("with"),iu=(0,xi.token)("copy"),lu=(0,xi.token)("modify"),cu=(0,xi.token)("first"),uu=(0,xi.token)("last"),pu=(0,xi.token)("before"),hu=(0,xi.token)("after"),du=(0,xi.token)("into"),mu=(0,xi.token)("insert"),fu=(0,xi.token)("rename"),gu=(0,xi.token)("switch"),yu=(0,xi.token)("variable"),wu=(0,xi.token)("external"),vu=(0,xi.token)("updating"),xu=(0,xi.token)("import"),bu=(0,xi.token)("schema"),Au=(0,xi.token)("module"),Eu=(0,xi.token)("base-uri"),Nu=(0,xi.token)("construction"),Tu=(0,xi.token)("ordering"),Bu=(0,xi.token)("ordered"),Iu=(0,xi.token)("unordered"),Cu=(0,xi.token)("option"),Su=(0,xi.token)("context"),Ou=(0,xi.token)("item"),Fu=(0,xi.token)("xquery"),Du=(0,xi.token)("version"),ku=(0,xi.token)("encoding"),Ru=(0,xi.token)("document-node"),Mu=(0,xi.token)("namespace-node"),Uu=(0,xi.token)("schema-attribute"),Gu=(0,xi.token)("ascending"),$u=(0,xi.token)("descending"),Lu=(0,xi.token)("empty-sequence"),Hu=(0,xi.token)("child::"),Pu=(0,xi.token)("descendant::"),ju=(0,xi.token)("attribute::"),_u=(0,xi.token)("self::"),Xu=(0,xi.token)("descendant-or-self::"),qu=(0,xi.token)("following-sibling::"),Vu=(0,xi.token)("following::"),Yu=(0,xi.token)("parent::"),zu=(0,xi.token)("ancestor::"),Ju=(0,xi.token)("preceding-sibling::"),Qu=(0,xi.token)("preceding::"),Ku=(0,xi.token)("ancestor-or-self::"),Wu=(0,xi.token)("decimal-separator"),Zu=(0,xi.token)("grouping-separator"),ep=(0,xi.token)("infinity"),tp=(0,xi.token)("minus-sign"),np=(0,xi.token)("NaN"),rp=(0,xi.token)("per-mille"),ap=(0,xi.token)("zero-digit"),op=(0,xi.token)("digit"),sp=(0,xi.token)("pattern-separator"),ip=(0,xi.token)("exponent-separator"),lp=(0,xi.token)("schema-attribute("),cp=(0,xi.token)("document-node("),up=(0,xi.token)("processing-instruction("),pp=(0,xi.token)("processing-instruction()"),hp=(0,xi.token)("comment()"),dp=(0,xi.token)("text()"),mp=(0,xi.token)("namespace-node()"),fp=(0,xi.token)("node()"),gp=(0,xi.token)("item()"),yp=(0,xi.token)("empty-sequence()"),wp=new Map,vp=new Map,xp=(0,xi.or)([Ci(/[\t\n\r -\uD7FF\uE000\uFFFD]/),Ci(/[\uD800-\uDBFF][\uDC00-\uDFFF]/)]),bp=(0,xi.preceded)((0,xi.peek)((0,xi.not)((0,xi.or)([Oi,Fi]),['comment contents cannot contain "(:" or ":)"'])),xp),Ap=(0,xi.map)((0,xi.delimited)(Oi,(0,xi.star)((0,xi.or)([bp,function(e,t){return Ap(e,t)}])),Fi,!0),(e=>e.join(""))),Ep=(0,xi.or)([Si,Ap]),Np=(0,xi.map)((0,xi.plus)(Si),(e=>e.join(""))),Tp=bi((0,xi.map)((0,xi.star)(Ep),(e=>e.join(""))),wp),Bp=bi((0,xi.map)((0,xi.plus)(Ep),(e=>e.join(""))),vp);const Ip=(0,xi.or)([Ci(/[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]/),(0,xi.then)(Ci(/[\uD800-\uDB7F]/),Ci(/[\uDC00-\uDFFF]/),((e,t)=>e+t))]),Cp=(0,xi.or)([Ip,Ci(/[\-\.0-9\xB7\u0300-\u036F\u203F\u2040]/)]);var Sp=(0,xi.then)(Ip,(0,xi.star)(Cp),((e,t)=>e+t.join(""))),Op=(0,xi.map)(Sp,(e=>["prefix",e]));const Fp=(0,xi.or)([Ip,sl]),Dp=(0,xi.or)([Cp,sl]);(0,xi.then)(Fp,(0,xi.star)(Dp),((e,t)=>e+t.join("")));const kp=(0,xi.map)(Sp,(e=>[{prefix:"",URI:null},e])),Rp=(0,xi.then)(Sp,(0,xi.preceded)(sl,Sp),((e,t)=>[{prefix:e,URI:null},t]));var Mp=(0,xi.or)([Rp,kp]),Up=(0,xi.followed)(Ei([Ml,Tp,$i],(0,xi.map)((0,xi.star)(Ci(/[^{}]/)),(e=>e.join("").replace(/\s+/g," ").trim()))),Li);const Gp=(0,xi.then)(Up,Sp,((e,t)=>[e,t]));var $p=(0,xi.or)([(0,xi.map)(Gp,(e=>[{prefix:null,URI:e[0]},e[1]])),Mp]),Lp=(0,xi.or)([(0,xi.map)($p,(e=>["QName",...e])),(0,xi.map)(ll,(()=>["star"]))]),Hp=(0,xi.map)((0,xi.preceded)(ul,$p),(e=>["varRef",["name",...e]])),Pp=(0,xi.peek)((0,xi.or)([Ri,Xi,ji,Ep])),jp=(0,xi.map)((0,xi.or)([Hu,Pu,ju,_u,Xu,qu,Vu]),(e=>e.substring(0,e.length-2))),_p=(0,xi.map)((0,xi.or)([Yu,zu,Ju,Qu,Ku]),(e=>e.substring(0,e.length-2))),Xp=Ni(ol,(0,xi.or)([cc,pc,dc,mc,fc]),il,((e,t,n)=>e+t+n)),qp=(0,xi.or)([Ni(el,Ci(/[0-9a-fA-F]+/),il,((e,t,n)=>e+t+n)),Ni(tl,Ci(/[0-9]+/),il,((e,t,n)=>e+t+n))]),Vp=Ii([qi],'"'),Yp=Ii([_i],"'"),zp=Bi(Ii([hp],"commentTest")),Jp=Bi(Ii([dp],"textTest")),Qp=Bi(Ii([mp],"namespaceTest")),Kp=Bi(Ii([fp],"anyKindTest"));const Wp=Ci(/[0-9]+/),Zp=(0,xi.then)((0,xi.or)([(0,xi.then)(Bl,Wp,((e,t)=>e+t)),(0,xi.then)(Wp,(0,xi.optional)((0,xi.preceded)(Bl,Ci(/[0-9]*/))),((e,t)=>e+(null!==t?"."+t:"")))]),Ni((0,xi.or)([kl,Rl]),(0,xi.optional)((0,xi.or)([Cl,Sl])),Wp,((e,t,n)=>e+(t||"")+n)),((e,t)=>["doubleConstantExpr",["value",e+t]])),eh=(0,xi.or)([(0,xi.map)((0,xi.preceded)(Bl,Wp),(e=>["decimalConstantExpr",["value","."+e]])),(0,xi.then)((0,xi.followed)(Wp,Bl),(0,xi.optional)(Wp),((e,t)=>["decimalConstantExpr",["value",e+"."+(null!==t?t:"")]]))]);var th=(0,xi.map)(Wp,(e=>["integerConstantExpr",["value",e]])),nh=(0,xi.followed)((0,xi.or)([Zp,eh,th]),(0,xi.peek)((0,xi.not)(Ci(/[a-zA-Z]/),["no alphabetical characters after numeric literal"]))),rh=(0,xi.map)((0,xi.followed)(Bl,(0,xi.peek)((0,xi.not)(Bl,["context item should not be followed by another ."]))),(()=>["contextItemExpr"])),ah=(0,xi.or)([Dc,Jl,Uc,Ru,zl,Lu,Vl,gc,Ou,Yl,Mu,jl,Gc,Uu,Ql,gu,Mc,tu]),oh=Bi(Ii([dl],"argumentPlaceholder")),sh=(0,xi.or)([dl,ll,Cl]),ih=(0,xi.preceded)((0,xi.peek)((0,xi.not)(Ci(/[{}<&]/),["elementContentChar cannot be {, }, <, or &"])),xp),lh=(0,xi.map)((0,xi.delimited)(Vi,(0,xi.star)((0,xi.preceded)((0,xi.peek)((0,xi.not)(Yi,['CDataSection content may not contain "]]>"'])),xp)),Yi,!0),(e=>["CDataSection",e.join("")])),ch=(0,xi.preceded)((0,xi.peek)((0,xi.not)(Ci(/["{}<&]/),['quotAttrValueContentChar cannot be ", {, }, <, or &'])),xp),uh=(0,xi.preceded)((0,xi.peek)((0,xi.not)(Ci(/['{}<&]/),["aposAttrValueContentChar cannot be ', {, }, <, or &"])),xp),ph=(0,xi.map)((0,xi.star)((0,xi.or)([(0,xi.preceded)((0,xi.peek)((0,xi.not)(Sl,[])),xp),(0,xi.map)(Ei([Sl,(0,xi.peek)((0,xi.not)(Sl,[]))],xp),(e=>"-"+e))])),(e=>e.join(""))),hh=(0,xi.map)((0,xi.delimited)(Qi,ph,Ki,!0),(e=>["computedCommentConstructor",["argExpr",["stringConstantExpr",["value",e]]]]));const dh=(0,xi.filter)(Sp,(e=>"xml"!==e.toLowerCase()),['A processing instruction target cannot be "xml"']),mh=(0,xi.map)((0,xi.star)((0,xi.preceded)((0,xi.peek)((0,xi.not)(Zi,[])),xp)),(e=>e.join("")));var fh=(0,xi.then)((0,xi.preceded)(Wi,(0,xi.cut)(dh)),(0,xi.cut)((0,xi.followed)((0,xi.optional)((0,xi.preceded)(Np,mh)),Zi)),((e,t)=>["computedPIConstructor",["piTarget",e],["piValueExpr",["stringConstantExpr",["value",t]]]])),gh=(0,xi.map)(Fl,(()=>["stepExpr",["xpathAxis","descendant-or-self"],["anyKindTest"]])),yh=(0,xi.or)([$c,Lc]),wh=(0,xi.map)((0,xi.star)((0,xi.followed)(xp,(0,xi.peek)((0,xi.not)(ki,["Pragma contents should not contain '#)'"])))),(e=>e.join(""))),vh=(0,xi.map)((0,xi.followed)((0,xi.or)([ic,lc,cc,uc,pc,hc]),Pp),(e=>e+"Op")),xh=(0,xi.or)([(0,xi.followed)(Ii([tc],"isOp"),Pp),Ii([xl],"nodeBeforeOp"),Ii([El],"nodeAfterOp")]),bh=(0,xi.or)([Ii([ml],"equalOp"),Ii([wl],"notEqualOp"),Ii([bl],"lessThanOrEqualOp"),Ii([vl],"lessThanOp"),Ii([Nl],"greaterThanOrEqualOp"),Ii([Al],"greaterThanOp")]),Ah=(0,xi.map)(vu,(()=>["annotation",["annotationName","updating"]]));const Eh=(0,xi.or)([Vc,Yc]),Nh=(0,xi.or)([zc,Jc]);var Th=(0,xi.or)([Wu,Zu,ep,tp,np,hl,rp,ap,op,sp,ip]),Bh=(0,xi.map)(Ei([jc,Bp,Xc,Bp],(0,xi.or)([Vc,qc])),(e=>["boundarySpaceDecl",e])),Ih=(0,xi.map)(Ei([jc,Bp,Nu,Bp],(0,xi.or)([Vc,qc])),(e=>["constructionDecl",e])),Ch=(0,xi.map)(Ei([jc,Bp,Tu,Bp],(0,xi.or)([Bu,Iu])),(e=>["orderingModeDecl",e])),Sh=(0,xi.map)(Ei([jc,Bp,_c,Bp,Sc,Bp,xc,Bp],(0,xi.or)([Qc,Kc])),(e=>["emptyOrderDecl",e])),Oh=(0,xi.then)(Ei([jc,Bp,Wc,Bp],Eh),Ei([Tp,Tl,Tp],Nh),((e,t)=>["copyNamespacesDecl",["preserveMode",e],["inheritMode",t]]));function Fh(e){switch(e[0]){case"constantExpr":case"varRef":case"contextItemExpr":case"functionCallExpr":case"sequenceExpr":case"elementConstructor":case"computedElementConstructor":case"computedAttributeConstructor":case"computedDocumentConstructor":case"computedTextConstructor":case"computedCommentConstructor":case"computedNamespaceConstructor":case"computedPIConstructor":case"orderedExpr":case"unorderedExpr":case"namedFunctionRef":case"inlineFunctionExpr":case"dynamicFunctionInvocationExpr":case"mapConstructor":case"arrayConstructor":case"stringConstructor":case"unaryLookup":return e}return["sequenceExpr",e]}function Dh(e){if(!(1<=e&&55295>=e||57344<=e&&65533>=e||65536<=e&&1114111>=e))throw Error("XQST0090: The character reference "+e+" ("+e.toString(16)+") does not reference a valid codePoint.")}function kh(e){return e.replace(/(&[^;]+);/g,(e=>{if(/^&#x/.test(e))return Dh(e=parseInt(e.slice(3,-1),16)),String.fromCodePoint(e);if(/^&#/.test(e))return Dh(e=parseInt(e.slice(2,-1),10)),String.fromCodePoint(e);switch(e){case"&lt;":return"<";case"&gt;":return">";case"&amp;":return"&";case"&quot;":return String.fromCharCode(34);case"&apos;":return String.fromCharCode(39)}throw Error('XPST0003: Unknown character reference: "'+e+'"')}))}function Rh(e,t,n){if(!e.length)return[];let r=[e[0]];for(let t=1;t<e.length;++t){const n=r[r.length-1];"string"==typeof n&&"string"==typeof e[t]?r[r.length-1]=n+e[t]:r.push(e[t])}if("string"==typeof r[0]&&0===r.length)return[];if(r=r.reduce(((e,t,a)=>{if("string"!=typeof t)e.push(t);else if(n&&/^\s*$/.test(t)){const n=r[a+1];(n&&"CDataSection"===n[0]||(a=r[a-1])&&"CDataSection"===a[0])&&e.push(kh(t))}else e.push(kh(t));return e}),[]),!r.length)return r;if(1<r.length||t)for(e=0;e<r.length;e++)"string"==typeof r[e]&&(r[e]=["stringConstantExpr",["value",r[e]]]);return r}function Mh(e){return e[0].prefix?e[0].prefix+":"+e[1]:e[1]}var Uh=(0,xi.then)($p,(0,xi.optional)(dl),((e,t)=>null!==t?["singleType",["atomicType",...e],["optional"]]:["singleType",["atomicType",...e]])),Gh=(0,xi.map)($p,(e=>["atomicType",...e]));const $h=new Map;function Lh(e){function t(e,t){return t.reduce(((e,t)=>[t[0],["firstOperand",e],["secondOperand",t[1]]]),e)}function n(e,t,n){return(0,xi.then)(e,(0,xi.star)((0,xi.then)(Ai(t,Tp),(0,xi.cut)(e),((e,t)=>[e,t]))),n)}function r(e,t,n="firstOperand",r="secondOperand"){return(0,xi.then)(e,(0,xi.optional)((0,xi.then)(Ai(t,Tp),(0,xi.cut)(e),((e,t)=>[e,t]))),((e,t)=>null===t?e:[t[0],[n,e],[r,t[1]]]))}function a(t){return e.lb?(e,n)=>{if(!(e=t(e,n)).success)return e;const r=c.has(n)?c.get(n):{offset:n,line:-1,ha:-1},a=c.has(e.offset)?c.get(e.offset):{offset:e.offset,line:-1,ha:-1};return c.set(n,r),c.set(e.offset,a),(0,xi.okWithValue)(e.offset,["x:stackTrace",{start:r,end:a},e.value])}:t}function o(e,t){return J(e,t)}function s(e,t){return Ge(e,t)}function i(e,t){return a((0,xi.or)([Tt,Ft,Ht,Ct,ot,Gt,Dt,$t,kt,Mt,at]))(e,t)}function l(e,t){return n(i,Tl,((e,t)=>0===t.length?e:["sequenceExpr",e,...t.map((e=>e[1]))]))(e,t)}const c=new Map,u=(0,xi.preceded)(Ui,(0,xi.followed)(Ai(l,Tp),Gi)),p=(0,xi.map)(e.Ya?(0,xi.or)([Ai((0,xi.star)((0,xi.or)([Xp,qp,Vp,Ci(/[^"&]/)])),Xi),Ai((0,xi.star)((0,xi.or)([Xp,qp,Yp,Ci(/[^'&]/)])),ji)]):(0,xi.or)([Ai((0,xi.star)((0,xi.or)([Vp,Ci(/[^"]/)])),Xi),Ai((0,xi.star)((0,xi.or)([Yp,Ci(/[^']/)])),ji)]),(e=>e.join(""))),h=(0,xi.or)([(0,xi.map)(Ei([zl,Tp],(0,xi.delimited)((0,xi.followed)(Ri,Tp),(0,xi.then)(Lp,Ei([Tp,Tl,Tp],$p),((e,t)=>[["elementName",e],["typeName",...t]])),(0,xi.preceded)(Tp,Mi))),(([e,t])=>["elementTest",e,t])),(0,xi.map)(Ei([zl,Tp],(0,xi.delimited)(Ri,Lp,Mi)),(e=>["elementTest",["elementName",e]])),(0,xi.map)(Ei([zl,Tp],(0,xi.delimited)(Ri,Tp,Mi)),(()=>["elementTest"]))]),d=(0,xi.or)([(0,xi.map)($p,(e=>["QName",...e])),(0,xi.map)(ll,(()=>["star"]))]),m=(0,xi.or)([(0,xi.map)(Ei([Jl,Tp],(0,xi.delimited)((0,xi.followed)(Ri,Tp),(0,xi.then)(d,Ei([Tp,Tl,Tp],$p),((e,t)=>[["attributeName",e],["typeName",...t]])),(0,xi.preceded)(Tp,Mi))),(([e,t])=>["attributeTest",e,t])),(0,xi.map)(Ei([Jl,Tp],(0,xi.delimited)(Ri,d,Mi)),(e=>["attributeTest",["attributeName",e]])),(0,xi.map)(Ei([Jl,Tp],(0,xi.delimited)(Ri,Tp,Mi)),(()=>["attributeTest"]))]),f=(0,xi.map)(Ei([Ql,Tp,Ri],(0,xi.followed)($p,Mi)),(e=>["schemaElementTest",...e])),g=(0,xi.map)((0,xi.delimited)(lp,Ai($p,Tp),Mi),(e=>["schemaAttributeTest",...e])),y=(0,xi.map)((0,xi.preceded)(cp,(0,xi.followed)(Ai((0,xi.optional)((0,xi.or)([h,f])),Tp),Mi)),(e=>["documentTest",...e?[e]:[]])),w=(0,xi.or)([(0,xi.map)((0,xi.preceded)(up,(0,xi.followed)(Ai((0,xi.or)([Sp,p]),Tp),Mi)),(e=>["piTest",["piTarget",e]])),Bi(Ii([pp],"piTest"))]),v=(0,xi.or)([y,h,m,f,g,w,zp,Jp,Qp,Kp]),x=(0,xi.or)([(0,xi.map)((0,xi.preceded)(rl,Sp),(e=>["Wildcard",["star"],["NCName",e]])),Bi(Ii([ll],"Wildcard")),(0,xi.map)((0,xi.followed)(Up,ll),(e=>["Wildcard",["uri",e],["star"]])),(0,xi.map)((0,xi.followed)(Sp,nl),(e=>["Wildcard",["NCName",e],["star"]]))]),b=(0,xi.or)([x,(0,xi.map)($p,(e=>["nameTest",...e]))]),A=(0,xi.or)([v,b]),E=(0,xi.then)((0,xi.optional)(cl),A,((e,t)=>null!==e||"attributeTest"===t[0]||"schemaAttributeTest"===t[0]?["stepExpr",["xpathAxis","attribute"],t]:["stepExpr",["xpathAxis","child"],t])),N=(0,xi.or)([(0,xi.then)(jp,A,((e,t)=>["stepExpr",["xpathAxis",e],t])),E]),T=(0,xi.map)(Il,(()=>["stepExpr",["xpathAxis","parent"],["anyKindTest"]])),B=(0,xi.or)([(0,xi.then)(_p,A,((e,t)=>["stepExpr",["xpathAxis",e],t])),T]),I=(0,xi.map)((0,xi.star)((0,xi.preceded)(Tp,u)),(e=>0<e.length?["predicates",...e]:void 0)),C=(0,xi.then)((0,xi.or)([B,N]),I,((e,t)=>void 0===t?e:e.concat([t]))),S=(0,xi.or)([nh,(0,xi.map)(p,(t=>["stringConstantExpr",["value",e.Ya?kh(t):t]]))]),O=(0,xi.or)([(0,xi.delimited)(Ri,Ai(l,Tp),Mi),(0,xi.map)((0,xi.delimited)(Ri,Tp,Mi),(()=>["sequenceExpr"]))]),F=(0,xi.or)([i,oh]),D=(0,xi.map)((0,xi.delimited)(Ri,Ai((0,xi.optional)((0,xi.then)(F,(0,xi.star)((0,xi.preceded)(Ai(Tl,Tp),F)),((e,t)=>[e,...t]))),Tp),Mi),(e=>null!==e?e:[])),k=(0,xi.preceded)((0,xi.not)(Ni(ah,Tp,Ri,(()=>{})),["cannot use reseved keyword for function names"]),(0,xi.then)($p,(0,xi.preceded)(Tp,D),((e,t)=>["functionCallExpr",["functionName",...e],null!==t?["arguments",...t]:["arguments"]]))),R=(0,xi.then)($p,(0,xi.preceded)(pl,th),((e,t)=>["namedFunctionRef",["functionName",...e],t])),M=(0,xi.delimited)($i,Ai((0,xi.optional)(l),Tp),Li),U=(0,xi.map)(M,(e=>e||["sequenceExpr"])),G=(0,xi.or)([(0,xi.map)(yp,(()=>[["voidSequenceType"]])),(0,xi.then)(o,(0,xi.optional)((0,xi.preceded)(Tp,sh)),((e,t)=>[e,...null!==t?[["occurrenceIndicator",t]]:[]]))]),$=(0,xi.then)(Ei([hl,Tp],$p),(0,xi.optional)((0,xi.followed)((0,xi.then)(Ei([Ri,Tp],S),(0,xi.star)(Ei([Tl,Tp],S)),((e,t)=>e.concat(t))),Mi)),((e,t)=>["annotation",["annotationName",...e],...t?["arguments",t]:[]])),L=(0,xi.map)(Ei([Vl,Tp,Ri,Tp,ll,Tp],Mi),(()=>["anyFunctionTest"])),H=(0,xi.then)(Ei([Vl,Tp,Ri,Tp],(0,xi.optional)(n(G,Tl,((e,t)=>e.concat.apply(e,t.map((e=>e[1]))))))),Ei([Tp,Mi,Bp,Ul,Bp],G),((e,t)=>["typedFunctionTest",["paramTypeList",["sequenceType",...e||[]]],["sequenceType",...t]])),P=(0,xi.then)((0,xi.star)($),(0,xi.or)([L,H]),((e,t)=>[t[0],...e,...t.slice(1)])),j=(0,xi.map)(Ei([Yl,Tp,Ri,Tp,ll,Tp],Mi),(()=>["anyMapTest"])),_=(0,xi.then)(Ei([Yl,Tp,Ri,Tp],Gh),Ei([Tp,Tl],(0,xi.followed)(Ai(G,Tp),Mi)),((e,t)=>["typedMapTest",e,["sequenceType",...t]])),X=(0,xi.or)([j,_]),q=(0,xi.map)(Ei([Dc,Tp,Ri,Tp,ll,Tp],Mi),(()=>["anyArrayTest"])),V=(0,xi.map)(Ei([Dc,Tp,Ri],(0,xi.followed)(Ai(G,Tp),Mi)),(e=>["typedArrayTest",["sequenceType",...e]])),Y=(0,xi.or)([q,V]),z=(0,xi.map)((0,xi.delimited)(Ri,Ai(o,Tp),Mi),(e=>["parenthesizedItemType",e])),J=(0,xi.or)([v,Bi(Ii([gp],"anyItemType")),P,X,Y,Gh,z]),Q=(0,xi.map)(Ei([Ul,Bp],G),(e=>["typeDeclaration",...e])),K=(0,xi.then)((0,xi.preceded)(ul,$p),(0,xi.optional)((0,xi.preceded)(Bp,Q)),((e,t)=>["param",["varName",...e],...t?[t]:[]])),W=n(K,Tl,((e,t)=>[e,...t.map((e=>e[1]))])),Z=Ti((0,xi.star)($),Ei([Tp,Vl,Tp,Ri,Tp],(0,xi.optional)(W)),Ei([Tp,Mi,Tp],(0,xi.optional)((0,xi.map)(Ei([Ul,Tp],(0,xi.followed)(G,Tp)),(e=>["typeDeclaration",...e])))),U,((e,t,n,r)=>["inlineFunctionExpr",...e,["paramList",...t||[]],...n?[n]:[],["functionBody",r]])),ee=(0,xi.or)([R,Z]),te=(0,xi.map)(i,(e=>["mapKeyExpr",e])),ne=(0,xi.map)(i,(e=>["mapValueExpr",e])),re=(0,xi.then)(te,(0,xi.preceded)(Ai(sl,Tp),ne),((e,t)=>["mapConstructorEntry",e,t])),ae=(0,xi.preceded)(Yl,(0,xi.delimited)(Ai($i,Tp),(0,xi.map)((0,xi.optional)(n(re,Ai(Tl,Tp),((e,t)=>[e,...t.map((e=>e[1]))]))),(e=>e?["mapConstructor",...e]:["mapConstructor"])),(0,xi.preceded)(Tp,Li))),oe=(0,xi.map)((0,xi.delimited)(Ui,Ai((0,xi.optional)(n(i,Tl,((e,t)=>[e,...t.map((e=>e[1]))].map((e=>["arrayElem",e]))))),Tp),Gi),(e=>["squareArray",...null!==e?e:[]])),se=(0,xi.map)((0,xi.preceded)(Dc,(0,xi.preceded)(Tp,M)),(e=>["curlyArray",...null!==e?[["arrayElem",e]]:[]])),ie=(0,xi.map)((0,xi.or)([oe,se]),(e=>["arrayConstructor",e])),le=(0,xi.or)([Sp,th,O,ll]),ce=(0,xi.map)((0,xi.preceded)(dl,(0,xi.preceded)(Tp,le)),(e=>"*"===e?["unaryLookup",["star"]]:"string"==typeof e?["unaryLookup",["NCName",e]]:["unaryLookup",e])),ue=(0,xi.or)([Xp,qp,Ii([Hi],"{"),Ii([Pi],"}"),(0,xi.map)(M,(e=>e||["sequenceExpr"]))]),pe=(0,xi.or)([lh,function(e,t){return we(e,t)},ue,ih]),he=(0,xi.or)([(0,xi.map)(ch,(e=>e.replace(/[\x20\x0D\x0A\x09]/g," "))),ue]),de=(0,xi.or)([(0,xi.map)(uh,(e=>e.replace(/[\x20\x0D\x0A\x09]/g," "))),ue]),me=(0,xi.map)((0,xi.or)([Ai((0,xi.star)((0,xi.or)([Vp,he])),Xi),Ai((0,xi.star)((0,xi.or)([Yp,de])),ji)]),(e=>Rh(e,!1,!1))),fe=(0,xi.then)(Mp,(0,xi.preceded)(Ai(ml,(0,xi.optional)(Np)),me),((e,t)=>{if(""===e[0].prefix&&"xmlns"===e[1]){if(t.length&&"string"!=typeof t[0])throw Error("XQST0022: A namespace declaration may not contain enclosed expressions");return["namespaceDeclaration",t.length?["uri",t[0]]:["uri"]]}if("xmlns"===e[0].prefix){if(t.length&&"string"!=typeof t[0])throw Error("XQST0022: The namespace declaration for 'xmlns:"+e[1]+"' may not contain enclosed expressions");return["namespaceDeclaration",["prefix",e[1]],t.length?["uri",t[0]]:["uri"]]}return["attributeConstructor",["attributeName"].concat(e),0===t.length?["attributeValue"]:1===t.length&&"string"==typeof t[0]?["attributeValue",t[0]]:["attributeValueExpr"].concat(t)]})),ge=(0,xi.map)((0,xi.star)((0,xi.preceded)(Np,(0,xi.optional)(fe))),(e=>e.filter(Boolean))),ye=Ni((0,xi.preceded)(vl,Mp),ge,(0,xi.or)([(0,xi.map)(zi,(()=>null)),(0,xi.then)((0,xi.preceded)(Al,(0,xi.star)(pe)),Ei([Tp,Ji],(0,xi.followed)(Mp,(0,xi.then)((0,xi.optional)(Np),Al,(()=>null)))),((e,t)=>[Rh(e,!0,!0),t]))]),((e,t,n)=>{var r=n;if(n&&n.length){r=Mh(e);const t=Mh(n[1]);if(r!==t)throw Error('XQST0118: The start and the end tag of an element constructor must be equal. "'+r+'" does not match "'+t+'"');r=n[0]}return["elementConstructor",["tagName",...e],...t.length?[["attributeList",...t]]:[],...r&&r.length?[["elementContent",...r]]:[]]})),we=(0,xi.or)([ye,hh,fh]),ve=(0,xi.map)(Ei([kc,Tp],M),(e=>["computedDocumentConstructor",...e?[["argExpr",e]]:[]])),xe=(0,xi.map)(M,(e=>e?[["contentExpr",e]]:[])),be=(0,xi.then)(Ei([zl,Tp],(0,xi.or)([(0,xi.map)($p,(e=>["tagName",...e])),(0,xi.map)((0,xi.delimited)($i,Ai(l,Tp),Li),(e=>["tagNameExpr",e]))])),(0,xi.preceded)(Tp,xe),((e,t)=>["computedElementConstructor",e,...t])),Ae=(0,xi.then)((0,xi.preceded)(Jl,(0,xi.or)([(0,xi.map)(Ei([Pp,Tp],$p),(e=>["tagName",...e])),(0,xi.map)((0,xi.preceded)(Tp,(0,xi.delimited)($i,Ai(l,Tp),Li)),(e=>["tagNameExpr",e]))])),(0,xi.preceded)(Tp,M),((e,t)=>["computedAttributeConstructor",e,["valueExpr",t||["sequenceExpr"]]])),Ee=(0,xi.map)(M,(e=>e?[["prefixExpr",e]]:[])),Ne=(0,xi.map)(M,(e=>e?[["URIExpr",e]]:[])),Te=(0,xi.then)(Ei([Rc,Tp],(0,xi.or)([Op,Ee])),(0,xi.preceded)(Tp,Ne),((e,t)=>["computedNamespaceConstructor",...e,...t])),Be=(0,xi.map)(Ei([Mc,Tp],M),(e=>["computedTextConstructor",...e?[["argExpr",e]]:[]])),Ie=(0,xi.map)(Ei([Uc,Tp],M),(e=>["computedCommentConstructor",...e?[["argExpr",e]]:[]])),Ce=Ei([Gc,Tp],(0,xi.then)((0,xi.or)([(0,xi.map)(Sp,(e=>["piTarget",e])),(0,xi.map)((0,xi.delimited)($i,Ai(l,Tp),Li),(e=>["piTargetExpr",e]))]),(0,xi.preceded)(Tp,M),((e,t)=>["computedPIConstructor",e,...t?[["piValueExpr",t]]:[]]))),Se=(0,xi.or)([ve,be,Ae,Te,Be,Ie,Ce]),Oe=(0,xi.or)([we,Se]),Fe=(0,xi.or)([S,Hp,O,rh,k,Oe,ee,ae,ie,ce]),De=(0,xi.map)(Ei([dl,Tp],le),(e=>"*"===e?["lookup",["star"]]:"string"==typeof e?["lookup",["NCName",e]]:["lookup",e])),ke=(0,xi.then)((0,xi.map)(Fe,(e=>Fh(e))),(0,xi.star)((0,xi.or)([(0,xi.map)((0,xi.preceded)(Tp,u),(e=>["predicate",e])),(0,xi.map)((0,xi.preceded)(Tp,D),(e=>["argumentList",e])),(0,xi.preceded)(Tp,De)])),((e,t)=>{function n(){i&&1===o.length?s.push(["predicate",o[0]]):0!==o.length&&s.push(["predicates",...o]),o.length=0}function r(e){n(),0!==s.length?("sequenceExpr"===a[0][0]&&2<a[0].length&&(a=[["sequenceExpr",...a]]),a=[["filterExpr",...a],...s],s.length=0):e&&(a=[["filterExpr",...a]])}let a=[e];const o=[],s=[];let i=!1;for(const e of t)switch(e[0]){case"predicate":o.push(e[1]);break;case"lookup":i=!0,n(),s.push(e);break;case"argumentList":r(!1),1<a.length&&(a=[["sequenceExpr",["pathExpr",["stepExpr",...a]]]]),a=[["dynamicFunctionInvocationExpr",["functionItem",...a],...e[1].length?[["arguments",...e[1]]]:[]]];break;default:throw Error("unreachable")}return r(!0),a})),Re=(0,xi.or)([(0,xi.map)(ke,(e=>["stepExpr",...e])),C]),Me=(0,xi.followed)(Fe,(0,xi.peek)((0,xi.not)((0,xi.preceded)(Tp,(0,xi.or)([u,D,De])),["primary expression not followed by predicate, argumentList, or lookup"]))),Ue=(0,xi.or)([Ni(Re,(0,xi.preceded)(Tp,gh),(0,xi.preceded)(Tp,s),((e,t,n)=>["pathExpr",e,t,...n])),(0,xi.then)(Re,(0,xi.preceded)(Ai(Ol,Tp),s),((e,t)=>["pathExpr",e,...t])),Me,(0,xi.map)(Re,(e=>["pathExpr",e]))]),Ge=(0,xi.or)([Ni(Re,(0,xi.preceded)(Tp,gh),(0,xi.preceded)(Tp,s),((e,t,n)=>[e,t,...n])),(0,xi.then)(Re,(0,xi.preceded)(Ai(Ol,Tp),s),((e,t)=>[e,...t])),(0,xi.map)(Re,(e=>[e]))]),$e=(0,xi.or)([(0,xi.map)(Ei([Ol,Tp],Ge),(e=>["pathExpr",["rootExpr"],...e])),(0,xi.then)(gh,(0,xi.preceded)(Tp,Ge),((e,t)=>["pathExpr",["rootExpr"],e,...t])),(0,xi.map)((0,xi.followed)(Ol,(0,xi.not)((0,xi.preceded)(Tp,e.Ya?Ci(/[*<a-zA-Z]/):Ci(/[*a-zA-Z]/)),["Single rootExpr cannot be by followed by something that can be interpreted as a relative path"])),(()=>["pathExpr",["rootExpr"]]))]),Le=bi((0,xi.or)([Ue,$e]),$h),He=(0,xi.preceded)(Hc,(0,xi.then)((0,xi.optional)((0,xi.or)([(0,xi.map)((0,xi.preceded)(Tp,yh),(e=>["validationMode",e])),(0,xi.map)(Ei([Tp,Pc,Tp],$p),(e=>["type",...e]))])),(0,xi.delimited)((0,xi.preceded)(Tp,$i),Ai(l,Tp),Li),((e,t)=>["validateExpr",...e?[e]:[],["argExpr",t]]))),Pe=(0,xi.delimited)(Di,(0,xi.then)((0,xi.preceded)(Tp,$p),(0,xi.optional)((0,xi.preceded)(Bp,wh)),((e,t)=>t?["pragma",["pragmaName",e],["pragmaContents",t]]:["pragma",["pragmaName",e]])),(0,xi.preceded)(Tp,ki)),je=(0,xi.map)((0,xi.followed)((0,xi.plus)(Pe),(0,xi.preceded)(Tp,(0,xi.delimited)($i,Ai((0,xi.optional)(l),Tp),Li))),(e=>["extensionExpr",...e])),_e=a(n(Le,fl,((e,t)=>0===t.length?e:["simpleMapExpr","pathExpr"===e[0]?e:["pathExpr",["stepExpr",["filterExpr",Fh(e)]]]].concat(t.map((e=>"pathExpr"===(e=e[1])[0]?e:["pathExpr",["stepExpr",["filterExpr",Fh(e)]]])))))),Xe=(0,xi.or)([He,je,_e]),qe=(0,xi.or)([(0,xi.then)((0,xi.or)([Ii([Sl],"unaryMinusOp"),Ii([Cl],"unaryPlusOp")]),(0,xi.preceded)(Tp,(function(e,t){return qe(e,t)})),((e,t)=>[e,["operand",t]])),Xe]),Ve=(0,xi.or)([(0,xi.map)($p,(e=>["EQName",...e])),Hp,O]),Ye=(0,xi.then)(qe,(0,xi.star)(Ei([Tp,Dl,Tp],(0,xi.then)(Ve,(0,xi.preceded)(Tp,D),((e,t)=>[e,t])))),((e,t)=>t.reduce(((e,t)=>["arrowExpr",["argExpr",e],t[0],["arguments",...t[1]]]),e))),ze=(0,xi.then)(Ye,(0,xi.optional)(Ei([Tp,Gl,Bp,Ul,Pp,Tp],Uh)),((e,t)=>null!==t?["castExpr",["argExpr",e],t]:e)),Je=(0,xi.then)(ze,(0,xi.optional)(Ei([Tp,$l,Bp,Ul,Pp,Tp],Uh)),((e,t)=>null!==t?["castableExpr",["argExpr",e],t]:e)),Qe=(0,xi.then)(Je,(0,xi.optional)(Ei([Tp,Ll,Bp,Ul,Pp,Tp],G)),((e,t)=>null!==t?["treatExpr",["argExpr",e],["sequenceType",...t]]:e)),Ke=(0,xi.then)(Qe,(0,xi.optional)(Ei([Tp,Hl,Bp,Pl,Pp,Tp],G)),((e,t)=>null!==t?["instanceOfExpr",["argExpr",e],["sequenceType",...t]]:e)),We=n(Ke,(0,xi.followed)((0,xi.or)([Ii([Kl],"intersectOp"),Ii([Wl],"exceptOp")]),Pp),t),Ze=n(We,(0,xi.or)([Ii([gl],"unionOp"),(0,xi.followed)(Ii([Zl],"unionOp"),Pp)]),t),et=n(Ze,(0,xi.or)([Ii([ll],"multiplyOp"),(0,xi.followed)(Ii([ac],"divOp"),Pp),(0,xi.followed)(Ii([oc],"idivOp"),Pp),(0,xi.followed)(Ii([sc],"modOp"),Pp)]),t),tt=n(et,(0,xi.or)([Ii([Sl],"subtractOp"),Ii([Cl],"addOp")]),t),nt=n(r(tt,(0,xi.followed)(Ii([ec],"rangeSequenceExpr"),Pp),"startExpr","endExpr"),Ii([yl],"stringConcatenateOp"),t),rt=n(r(nt,(0,xi.or)([vh,xh,bh])),(0,xi.followed)(Ii([rc],"andOp"),Pp),t),at=n(rt,(0,xi.followed)(Ii([nc],"orOp"),Pp),t),ot=(0,xi.then)((0,xi.then)(Ei([gc,Tp,Ri,Tp],l),Ei([Tp,Mi,Tp,yc,Pp,Tp],i),((e,t)=>[e,t])),Ei([Tp,wc,Pp,Tp],i),((e,t)=>["ifThenElseExpr",["ifClause",e[0]],["thenClause",e[1]],["elseClause",t]])),st=(0,xi.delimited)(vc,Bp,xc),it=(0,xi.map)(Ei([bc,Bp,ul],$p),(e=>["positionalVariableBinding",...e])),lt=function(e,t,n,r,a,o){return(0,xi.then)((0,xi.then)((0,xi.then)((0,xi.then)(e,t,((e,t)=>[e,t])),n,(([e,t],n)=>[e,t,n])),r,(([e,t,n],r)=>[e,t,n,r])),a,(([e,t,n,r],a)=>o(e,t,n,r,a)))}((0,xi.preceded)(ul,(0,xi.cut)($p)),(0,xi.cut)((0,xi.preceded)(Tp,(0,xi.optional)(Q))),(0,xi.cut)((0,xi.preceded)(Tp,(0,xi.optional)(st))),(0,xi.cut)((0,xi.preceded)(Tp,(0,xi.optional)(it))),(0,xi.cut)((0,xi.preceded)(Ai(Ac,Tp),i)),((e,t,n,r,a)=>["forClauseItem",["typedVariableBinding",["varName",...e,...t?[t]:[]]],...n?[["allowingEmpty"]]:[],...r?[r]:[],["forExpr",a]])),ct=Ei([Ec,Bp],n(lt,Tl,((e,t)=>["forClause",e,...t.map((e=>e[1]))]))),ut=Ni((0,xi.preceded)(ul,$p),(0,xi.preceded)(Tp,(0,xi.optional)(Q)),(0,xi.preceded)(Ai(al,Tp),i),((e,t,n)=>["letClauseItem",["typedVariableBinding",["varName",...e],...t?[t]:[]],["letExpr",n]])),pt=(0,xi.map)(Ei([Nc,Tp],n(ut,Tl,((e,t)=>[e,...t.map((e=>e[1]))]))),(e=>["letClause",...e])),ht=(0,xi.or)([ct,pt]),dt=(0,xi.map)(Ei([Tc,Pp,Tp],i),(e=>["whereClause",e])),mt=(0,xi.map)((0,xi.preceded)(ul,$p),(e=>["varName",...e])),ft=(0,xi.then)((0,xi.preceded)(Tp,(0,xi.optional)(Q)),(0,xi.preceded)(Ai(al,Tp),i),((e,t)=>["groupVarInitialize",...e?[["typeDeclaration",...e]]:[],["varValue",t]])),gt=Ni(mt,(0,xi.optional)(ft),(0,xi.optional)((0,xi.map)((0,xi.preceded)(Ai(Bc,Tp),p),(e=>["collation",e]))),((e,t,n)=>["groupingSpec",e,...t?[t]:[],...n?[n]:[]])),yt=n(gt,Tl,((e,t)=>[e,...t.map((e=>e[1]))])),wt=(0,xi.map)(Ei([Ic,Bp,Cc,Tp],yt),(e=>["groupByClause",...e])),vt=Ni((0,xi.optional)((0,xi.or)([Gu,$u])),(0,xi.optional)(Ei([Tp,xc,Tp],(0,xi.or)([Qc,Kc].map((e=>(0,xi.map)(e,(e=>"empty "+e))))))),(0,xi.preceded)(Tp,(0,xi.optional)(Ei([Bc,Tp],p))),((e,t,n)=>e||t||n?["orderModifier",...e?[["orderingKind",e]]:[],...t?[["emptyOrderingMode",t]]:[],...n?[["collation",n]]:[]]:null)),xt=(0,xi.then)(i,(0,xi.preceded)(Tp,vt),((e,t)=>["orderBySpec",["orderByExpr",e],...t?[t]:[]])),bt=n(xt,Tl,((e,t)=>[e,...t.map((e=>e[1]))])),At=(0,xi.then)((0,xi.or)([(0,xi.map)(Ei([Sc,Bp],Cc),(()=>!1)),(0,xi.map)(Ei([Oc,Bp,Sc,Bp],Cc),(()=>!0))]),(0,xi.preceded)(Tp,bt),((e,t)=>["orderByClause",...e?[["stable"]]:[],...t])),Et=(0,xi.or)([ht,dt,wt,At]),Nt=(0,xi.map)(Ei([Fc,Tp],i),(e=>["returnClause",e])),Tt=Ni(ht,(0,xi.cut)((0,xi.star)((0,xi.preceded)(Tp,Et))),(0,xi.cut)((0,xi.preceded)(Tp,Nt)),((e,t,n)=>["flworExpr",e,...t,n])),Bt=n(G,gl,((e,t)=>0===t.length?["sequenceType",...e]:["sequenceTypeUnion",["sequenceType",...e],...t.map((e=>["sequenceType",...e[1]]))])),It=Ni(Ei([eu,Tp],(0,xi.optional)((0,xi.preceded)(ul,(0,xi.followed)((0,xi.followed)($p,Bp),Ul)))),(0,xi.preceded)(Tp,Bt),Ei([Bp,Fc,Bp],i),((e,t,n)=>["typeswitchExprCaseClause"].concat(e?[["variableBinding",...e]]:[],[t],[["resultExpr",n]]))),Ct=Ti((0,xi.preceded)(tu,Ai((0,xi.delimited)(Ri,Ai(l,Tp),Mi),Tp)),(0,xi.plus)((0,xi.followed)(It,Tp)),Ei([_c,Bp],(0,xi.optional)((0,xi.preceded)(ul,(0,xi.followed)($p,Bp)))),Ei([Fc,Bp],i),((e,t,n,r)=>["typeswitchExpr",["argExpr",e],...t,["typeswitchExprDefaultClause",...n||[],["resultExpr",r]]])),St=Ni((0,xi.preceded)(ul,$p),(0,xi.optional)((0,xi.preceded)(Bp,Q)),(0,xi.preceded)(Ai(Ac,Bp),i),((e,t,n)=>["quantifiedExprInClause",["typedVariableBinding",["varName",...e],...t?[t]:[]],["sourceExpr",n]])),Ot=n(St,Tl,((e,t)=>[e,...t.map((e=>e[1]))])),Ft=Ni((0,xi.or)([nu,ru]),(0,xi.preceded)(Bp,Ot),(0,xi.preceded)(Ai(au,Tp),i),((e,t,n)=>["quantifiedExpr",["quantifier",e],...t,["predicateExpr",n]])),Dt=(0,xi.map)(Ei([Xl,Bp,(0,xi.or)([_l,jl]),Bp],i),(e=>["deleteExpr",["targetExpr",e]])),kt=Ni(Ei([ou,Bp],(0,xi.optional)(Ei([ql,Bp,Pl],Bp))),Ei([jl,Bp],i),(0,xi.preceded)(Ai(su,Bp),i),((e,t,n)=>e?["replaceExpr",["replaceValue"],["targetExpr",t],["replacementExpr",n]]:["replaceExpr",["targetExpr",t],["replacementExpr",n]])),Rt=(0,xi.then)(Hp,(0,xi.preceded)(Ai(al,Tp),i),((e,t)=>["transformCopy",e,["copySource",t]])),Mt=Ni(Ei([iu,Bp],n(Rt,Tl,((e,t)=>[e,...t.map((e=>e[1]))]))),Ei([Tp,lu,Bp],i),(0,xi.preceded)(Ai(Fc,Bp),i),((e,t,n)=>["transformExpr",["transformCopies",...e],["modifyExpr",t],["returnExpr",n]])),Ut=(0,xi.or)([(0,xi.followed)((0,xi.map)((0,xi.optional)((0,xi.followed)(Ei([Ul,Bp],(0,xi.or)([(0,xi.map)(cu,(()=>["insertAsFirst"])),(0,xi.map)(uu,(()=>["insertAsLast"]))])),Bp)),(e=>e?["insertInto",e]:["insertInto"])),du),(0,xi.map)(hu,(()=>["insertAfter"])),(0,xi.map)(pu,(()=>["insertBefore"]))]),Gt=Ni(Ei([mu,Bp,(0,xi.or)([_l,jl]),Bp],i),(0,xi.preceded)(Bp,Ut),(0,xi.preceded)(Bp,i),((e,t,n)=>["insertExpr",["sourceExpr",e],t,["targetExpr",n]])),$t=(0,xi.then)(Ei([fu,Bp,jl,Tp],i),Ei([Bp,Ul,Bp],i),((e,t)=>["renameExpr",["targetExpr",e],["newNameExpr",t]])),Lt=(0,xi.then)((0,xi.plus)((0,xi.map)(Ei([eu,Bp],i),(e=>["switchCaseExpr",e]))),Ei([Bp,Fc,Bp],i),((e,t)=>["switchExprCaseClause",...e,["resultExpr",t]])),Ht=Ni(Ei([gu,Tp,Ri],l),Ei([Tp,Mi,Tp],(0,xi.plus)((0,xi.followed)(Lt,Tp))),Ei([_c,Bp,Fc,Bp],i),((e,t,n)=>["switchExpr",["argExpr",e],...t,["switchExprDefaultClause",["resultExpr",n]]])),Pt=(0,xi.map)(l,(e=>["queryBody",e])),jt=Ei([jc,Bp,Rc,Bp],(0,xi.cut)((0,xi.then)(Sp,(0,xi.preceded)(Ai(ml,Tp),p),((e,t)=>["namespaceDecl",["prefix",e],["uri",t]])))),_t=(0,xi.then)(Ei([yu,Bp,ul,Tp],(0,xi.then)($p,(0,xi.optional)((0,xi.preceded)(Tp,Q)),((e,t)=>[e,t]))),(0,xi.cut)((0,xi.or)([(0,xi.map)(Ei([Tp,al,Tp],i),(e=>["varValue",e])),(0,xi.map)(Ei([Bp,wu],(0,xi.optional)(Ei([Tp,al,Tp],i))),(e=>["external",...e?[["varValue",e]]:[]]))])),(([e,t],n)=>["varDecl",["varName",...e],...null!==t?[t]:[],n])),Xt=Ti(Ei([Vl,Bp,(0,xi.cut)((0,xi.peek)((0,xi.not)((0,xi.followed)(ah,(0,xi.not)(sl,[""])),["Cannot use reserved function name"])))],$p),(0,xi.cut)(Ei([Tp,Ri,Tp],(0,xi.optional)(W))),(0,xi.cut)(Ei([Tp,Mi],(0,xi.optional)(Ei([Bp,Ul,Bp],G)))),(0,xi.cut)((0,xi.preceded)(Tp,(0,xi.or)([(0,xi.map)(U,(e=>["functionBody",e])),(0,xi.map)(wu,(()=>["externalDefinition"]))]))),((e,t,n,r)=>["functionDecl",["functionName",...e],["paramList",...t||[]],...n?[["typeDeclaration",...n]]:[],r])),qt=Ei([jc,Bp],(0,xi.then)((0,xi.star)((0,xi.followed)((0,xi.or)([$,Ah]),Bp)),(0,xi.or)([_t,Xt]),((e,t)=>[t[0],...e,...t.slice(1)]))),Vt=(0,xi.then)(Ei([jc,Bp,_c,Bp],(0,xi.or)([zl,Vl])),Ei([Bp,Rc,Bp],p),((e,t)=>["defaultNamespaceDecl",["defaultNamespaceCategory",e],["uri",t]])),Yt=(0,xi.or)([(0,xi.map)((0,xi.followed)(Ei([Rc,Bp],Sp),(0,xi.preceded)(Tp,ml)),(e=>["namespacePrefix",e])),(0,xi.map)(Ei([_c,Bp,zl,Bp],Rc),(()=>["defaultElementNamespace"]))]),zt=Ei([xu,Bp,bu],Ni((0,xi.optional)((0,xi.preceded)(Bp,Yt)),(0,xi.preceded)(Tp,p),(0,xi.optional)((0,xi.then)(Ei([Bp,bc,Bp],p),(0,xi.star)(Ei([Tp,Tl,Tp],p)),((e,t)=>[e,...t]))),((e,t,n)=>["schemaImport",...e?[e]:[],["targetNamespace",t],...n?[n]:[]]))),Jt=Ei([xu,Bp,Au],Ni((0,xi.optional)((0,xi.followed)(Ei([Bp,Rc,Bp],Sp),(0,xi.preceded)(Tp,ml))),(0,xi.preceded)(Tp,p),(0,xi.optional)((0,xi.then)(Ei([Bp,bc,Bp],p),(0,xi.star)(Ei([Tp,Tl,Tp],p)),((e,t)=>[e,...t]))),((e,t)=>["moduleImport",["namespacePrefix",e],["targetNamespace",t]]))),Qt=(0,xi.or)([zt,Jt]),Kt=(0,xi.map)(Ei([jc,Bp,_c,Bp,Bc,Bp],p),(e=>["defaultCollationDecl",e])),Wt=(0,xi.map)(Ei([jc,Bp,Eu,Bp],p),(e=>["baseUriDecl",e])),Zt=(0,xi.then)(Ei([jc,Bp],(0,xi.or)([(0,xi.map)(Ei([Zc,Bp],$p),(e=>["decimalFormatName",...e])),(0,xi.map)(Ei([_c,Bp],Zc),(()=>null))])),(0,xi.star)((0,xi.then)((0,xi.preceded)(Bp,Th),(0,xi.preceded)(Ai(ml,Bp),p),((e,t)=>["decimalFormatParam",["decimalFormatParamName",e],["decimalFormatParamValue",t]]))),((e,t)=>["decimalFormatDecl",...e?[e]:[],...t])),en=(0,xi.or)([Bh,Kt,Wt,Ih,Ch,Sh,Oh,Zt]),tn=(0,xi.then)(Ei([jc,Bp,Cu,Bp],$p),(0,xi.preceded)(Bp,p),((e,t)=>["optionDecl",["optionName",e],["optionContents",t]])),nn=(0,xi.then)(Ei([jc,Bp,Su,Bp,Ou],(0,xi.optional)(Ei([Bp,Ul],J))),(0,xi.or)([(0,xi.map)((0,xi.preceded)(Ai(al,Tp),i),(e=>["varValue",e])),(0,xi.map)(Ei([Bp,wu],(0,xi.optional)((0,xi.preceded)(Ai(al,Tp),i))),(()=>["external"]))]),((e,t)=>["contextItemDecl",...e?[["contextItemType",e]]:[],t])),rn=(0,xi.then)((0,xi.star)((0,xi.followed)((0,xi.or)([Vt,en,jt,Qt]),(0,xi.cut)(Ai(il,Tp)))),(0,xi.star)((0,xi.followed)((0,xi.or)([nn,qt,tn]),(0,xi.cut)(Ai(il,Tp)))),((e,t)=>0===e.length&&0===t.length?null:["prolog",...e,...t])),an=Ei([Au,Bp,Rc,Bp],(0,xi.then)((0,xi.followed)(Sp,Ai(ml,Tp)),(0,xi.followed)(p,Ai(il,Tp)),((e,t)=>["moduleDecl",["prefix",e],["uri",t]]))),on=(0,xi.then)(an,(0,xi.preceded)(Tp,rn),((e,t)=>["libraryModule",e,...t?[t]:[]])),sn=(0,xi.then)(rn,(0,xi.preceded)(Tp,Pt),((e,t)=>["mainModule",...e?[e]:[],t])),ln=(0,xi.map)(Ei([Fu,Tp],(0,xi.followed)((0,xi.or)([(0,xi.then)((0,xi.preceded)(ku,Bp),p,(e=>["encoding",e])),(0,xi.then)(Ei([Du,Bp],p),(0,xi.optional)(Ei([Bp,ku,Bp],p)),((e,t)=>[["version",e],...t?[["encoding",t]]:[]]))]),(0,xi.preceded)(Tp,il))),(e=>["versionDecl",...e])),cn=(0,xi.then)((0,xi.optional)(Ai(ln,Tp)),(0,xi.or)([on,sn]),((e,t)=>["module",...e?[e]:[],t])),un=(0,xi.complete)(Ai(cn,Tp));return(e,t)=>{c.clear(),t=un(e,t);let n=1,r=1;for(let t=0;t<e.length+1;t++){if(c.has(t)){var a=c.get(t);a.line=r,a.ha=n}"\r"===(a=e[t])||"\n"===a?(r++,n=1):n++}return t}}const Hh=Lh({lb:!1,Ya:!1}),Ph=Lh({lb:!0,Ya:!1}),jh=Lh({lb:!1,Ya:!0}),_h=Lh({lb:!0,Ya:!0});function Xh(e,t){var n=!!t.Z;if(t=!!t.debug,wp.clear(),vp.clear(),$h.clear(),!0===(n=n?t?_h(e,0):jh(e,0):t?Ph(e,0):Hh(e,0)).success)return n.value;throw t=(e=e.substring(0,n.offset).split("\n"))[e.length-1].length+1,new go({start:{offset:n.offset,line:e.length,ha:t},end:{offset:n.offset+1,line:e.length,ha:t+1}},"",Error(`XPST0003: Failed to parse script. Expected ${[...new Set(n.expected)]}`))}const qh="http://www.w3.org/XML/1998/namespace http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2005/xpath-functions http://www.w3.org/2005/xpath-functions/math http://www.w3.org/2012/xquery http://www.w3.org/2005/xpath-functions/array http://www.w3.org/2005/xpath-functions/map".split(" ");function Vh(e,t,n,r){const a=[],o=[];xa(e,"*").forEach((e=>{switch(e[0]){case"moduleImport":case"namespaceDecl":case"defaultNamespaceDecl":case"functionDecl":case"varDecl":break;default:throw Error("Not implemented: only module imports, namespace declarations, and function declarations are implemented in XQuery modules")}}));const s=new Set;xa(e,"moduleImport").forEach((e=>{const n=ya(ga(e,"namespacePrefix"));if(e=ya(ga(e,"targetNamespace")),s.has(e))throw Error(`XQST0047: The namespace "${e}" is imported more than once.`);s.add(e),pa(t,n,e)})),xa(e,"namespaceDecl").forEach((e=>{const n=ya(ga(e,"prefix"));if(e=ya(ga(e,"uri")),"xml"===n||"xmlns"===n)throw ra();if("http://www.w3.org/XML/1998/namespace"===e||"http://www.w3.org/2000/xmlns/"===e)throw ra();pa(t,n,e)}));let i=null,l=null;for(const t of xa(e,"defaultNamespaceDecl")){const e=ya(ga(t,"defaultNamespaceCategory")),n=ya(ga(t,"uri"));if(!n)throw ta();if("http://www.w3.org/XML/1998/namespace"===n||"http://www.w3.org/2000/xmlns/"===n)throw ra();if("function"===e){if(i)throw na();i=n}else if("element"===e){if(l)throw na();l=n}}i&&(t.v=i),l&&pa(t,"",l),xa(e,"functionDecl").forEach((e=>{!function(e,t,n,r,a){var o=ga(e,"functionName"),s=wa(o,"prefix")||"";let i=wa(o,"URI");const l=ya(o);if(null===i&&(i=""===s?null===t.v?"http://www.w3.org/2005/xpath-functions":t.v:t.$(s),!i&&s))throw oa(s);if(qh.includes(i))throw Zr();if(s=xa(e,"annotation").map((e=>ga(e,"annotationName"))),o=s.every((e=>!wa(e,"URI")&&"private"!==ya(e))),s=s.some((e=>!wa(e,"URI")&&"updating"===ya(e))),!i)throw ta();const c=Aa(e),u=xa(ga(e,"paramList"),"param"),p=u.map((e=>ga(e,"varName"))),h=u.map((e=>Aa(e)));if(e=ga(e,"functionBody")){if(t.va(i,l,h.length))throw ea(i,l);if(!a)return;const u=ui(e[1],{ra:!1,Z:!0}),d=new fa(t),m=p.map((e=>{let n=wa(e,"URI");const r=wa(e,"prefix");return e=ya(e),r&&null===n&&(n=t.$(r||"")),ha(d,n,e)}));a=s?{j:h,arity:p.length,callFunction:(e,t,n,...r)=>(e=Ye(je(e,-1,null,$.empty()),m.reduce(((e,t,n)=>(e[t]=L(r[n]),e)),Object.create(null))),u.s(e,t)),ub:!1,J:!0,bb:o,localName:l,namespaceURI:i,i:c}:{j:h,arity:p.length,callFunction:(e,t,n,...r)=>(e=Ye(je(e,-1,null,$.empty()),m.reduce(((e,t,n)=>(e[t]=L(r[n]),e)),Object.create(null))),Jn(u,e,t)),ub:!1,J:!1,bb:o,localName:l,namespaceURI:i,i:c},n.push({ba:u,Cb:d}),r.push({arity:p.length,ba:u,yb:a,localName:l,namespaceURI:i,bb:o})}else{if(s)throw Error("Updating external function declarations are not supported");a={j:h,arity:p.length,callFunction:(e,t,n,...r)=>{const a=n.va(i,l,p.length,!0);if(!a)throw Error(`XPST0017: Function Q{${i}}${l} with arity of ${p.length} not registered. ${Vr(l)}`);if(a.i.type!==c.type||a.j.some(((e,t)=>e.type!==h[t].type)))throw Error("External function declaration types do not match actual function");return a.callFunction(e,t,n,...r)},ub:!0,J:!1,localName:l,namespaceURI:i,bb:o,i:c}}ua(t,i,l,p.length,a)}(e,t,a,o,n)}));const c=[];return xa(e,"varDecl").forEach((e=>{const r=ba(ga(e,"varName"));let o=r.namespaceURI;if(null===o&&(o=t.$(r.prefix),!o&&r.prefix))throw oa(r.prefix);if(qh.includes(o))throw Zr();var s=ga(e,"external");let i,l;if(e=ga(e,"varValue"),null!==s?null!==(s=ga(s,"varValue"))&&(i=ga(s,"*")):null!==e&&(i=ga(e,"*")),c.some((e=>e.namespaceURI===o&&e.localName===r.localName)))throw Error(`XQST0049: The variable ${o?`Q{${o}}`:""}${r.localName} has already been declared.`);if(ha(t,o||"",r.localName),n&&(i&&(l=ui(i,{ra:!1,Z:!0})),i&&!function(e,t,n){return(e=e.Ea[sa(t,n)])?e:null}(t,o||"",r.localName))){let e=null;da(t,o,r.localName,((t,n)=>(e||(e=L(Jn(l,t,n))),e()))),a.push({ba:l,Cb:new fa(t)}),c.push({ba:l,localName:r.localName,namespaceURI:o})}})),o.forEach((e=>{if(!e.yb.J&&e.ba.J)throw $n(`The function Q{${e.namespaceURI}}${e.localName} is updating but the %updating annotation is missing.`)})),{Ha:o.map((e=>e.yb)),Ta:c,source:r,oa:e=>{s.forEach((e=>{yi(t,e)})),a.forEach((({ba:t,Cb:n})=>{s.forEach((e=>{yi(n,e)})),e.Ha.forEach((e=>{n.va(e.namespaceURI,e.localName,e.arity,!0)||e.bb&&ua(n,e.namespaceURI,e.localName,e.arity,e)})),e.Ta.forEach((e=>{n.cb(e.namespaceURI,e.localName)||ha(n,e.namespaceURI,e.localName)})),t.v(n)}))}}}function Yh(e,t,n,r,a,o,s){const i=t.Z?"XQuery":"XPath";return n=t.Ga?null:function(e,t,n,r,a,o,s,i){return(e=pi.get(e))&&(t=e[t+(o?"_DEBUG":"")])&&(t=t.find((e=>e.o===s&&e.v.every((e=>n(e.prefix)===e.namespaceURI))&&e.D.every((e=>void 0!==r[e.name]))&&e.jb.every((e=>a[e.prefix]===e.namespaceURI))&&e.l.every((e=>{const t=i(e.ac,e.arity);return t&&t.namespaceURI===e.Bb.namespaceURI&&t.localName===e.Bb.localName})))))?{ba:t.h,ec:!1}:null}(e,i,n,r,a,t.debug,o,s),null!==n?{state:n.ec?1:2,ba:n.ba}:{state:0,Wb:"string"==typeof e?Xh(e,t):mi(e)}}function zh(e,t,n,r,a,o,s){const i=new Qr(n,r,o,s),l=new fa(i);switch(0<Object.keys(a).length&&wi(),Object.keys(a).forEach((e=>{const t=a[e];yi(l,t),pa(l,e,t)})),"string"==typeof e&&(e=vi(e)),(n=Yh(e,t,n,r,a,o,s)).state){case 2:return{ga:l,ba:n.ba};case 1:return n.ba.v(l),di(e,t.Z?"XQuery":"XPath",i,a,n.ba,t.debug,o),{ga:l,ba:n.ba};case 0:return n=function(e,t,n,r){const a=ga(e,"mainModule");if(!a)throw Error("Can not execute a library module.");const o=ga(a,"prolog");if(o){if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");wi(),(r=Vh(o,n,!0,r)).oa(r)}return Ga(e,new Ya(n)),oi(e=va(a,["queryBody","*"]),t)}(n.Wb,t,l,e),n.v(l),t.Ga||di(e,t.Z?"XQuery":"XPath",i,a,n,t.debug,o),{ga:l,ba:n}}}function Jh(e,t,n,r){e=e.first();const a=t.first().h.reduce(((e,t)=>(e[t.key.value]=L(t.value()),e)),Object.create(null));t=a["."]?a["."]():$.empty(),delete a["."];try{const{ba:o,ga:s}=zh(function(e){if(T(e.type,1))return e.value;if(T(e.type,54))return e.value.node;throw Ze(`Unable to convert selector argument of type ${C[e.type]} to either an ${C[1]} or an ${C[54]} representing an XQueryX program while calling 'fontoxpath:evaluate'`)}(e),{ra:!1,Z:!0,debug:r.debug,Ga:r.Ga},(e=>n.$(e)),Object.keys(a).reduce(((e,t)=>(e[t]=t,e)),{}),{},"http://www.w3.org/2005/xpath-functions",((e,t)=>n.Sa(e,t))),i=!t.G(),l=new ze({M:i?t.first():null,Aa:i?0:-1,sa:t,qa:Object.keys(a).reduce(((e,t)=>(e[s.cb(null,t)]=a[t],e)),Object.create(null))});return{fc:o.h(l,r).value,cc:e}}catch(t){_r(e.value,t)}}function Qh(e,t,n){if(1!==t.node.nodeType&&9!==t.node.nodeType)return[];const r=W(e,t).reduce(((t,r)=>{for(const a of Qh(e,r,n))t.push(a);return t}),[]);return n(t)&&r.unshift(t),r}const Kh=(e,t,n,r,a)=>{if(!(e=a.first()))throw We("The context is absent, it needs to be present to use id function.");if(!T(e.type,53))throw Ze("The context item is not a node, it needs to be node to use id function.");const o=t.h,s=r.O().reduce(((e,t)=>(t.value.split(/\s+/).forEach((t=>{e[t]=!0})),e)),Object.create(null));for(t=e.value;9!==t.node.nodeType;)if(null===(t=ne(o,t)))throw Error("FODC0001: the root node of the target node is not a document node.");return t=Qh(o,t,(e=>1===e.node.nodeType&&(!(!(e=K(o,e,"id"))||!s[e])&&(s[e]=!1,!0)))),$.create(t.map((e=>ce(e))))},Wh=(e,t,n,r,a)=>{if(!(e=a.first()))throw We("The context is absent, it needs to be present to use idref function.");if(!T(e.type,53))throw Ze("The context item is not a node, it needs to be node to use idref function.");const o=t.h,s=r.O().reduce(((e,t)=>(e[t.value]=!0,e)),Object.create(null));for(t=e.value;9!==t.node.nodeType;)if(null===(t=ne(o,t)))throw Error("FODC0001: the root node of the context node is not a document node.");return t=Qh(o,t,(e=>1===e.node.nodeType&&(!!(e=K(o,e,"idref"))&&e.split(/\s+/).some((e=>s[e]))))),$.create(t.map((e=>ce(e))))};function Zh(e){switch(typeof e){case"object":return Array.isArray(e)?$.m(new ie(e.map((e=>L(Zh(e)))))):null===e?$.empty():$.m(new de(Object.keys(e).map((t=>({key:y(t,1),value:L(Zh(e[t]))})))));case"number":return $.m(y(e,3));case"string":return $.m(y(e,1));case"boolean":return e?$.aa():$.V();default:throw Error("Unexpected type in JSON parse")}}const ed=(e,t,n,r,a)=>{const o=$.m(y("duplicates",1)),s=(e=he(0,0,0,a,o)).G()?"use-first":e.first().value;return r.N((e=>$.m(new de(e.reduce(((e,t)=>(t.h.forEach((t=>{const n=e.findIndex((e=>pe(e.key,t.key)));if(0<=n)switch(s){case"reject":throw Error("FOJS0003: Duplicate encountered when merging maps.");case"use-last":return void e.splice(n,1,t);case"combine":return void e.splice(n,1,{key:t.key,value:L($.create(e[n].value().O().concat(t.value().O())))});default:return}e.push(t)})),e)),[])))))};function td(e,t,n){let r=1;const a=e.value;e=e.Pa(!0);let o=null;const s=Math.max(t-1,0);return-1!==e&&(o=Math.max(0,(null===n?e:Math.max(0,Math.min(e,n+(t-1))))-s)),$.create({next:e=>{for(;r<t;)a.next(e),r++;return null!==n&&r>=t+n?A:(e=a.next(e),r++,e)}},o)}function nd(e){return e.map((e=>T(e.type,19)?At(e,3):e))}function rd(e){if((e=nd(e)).some((e=>Number.isNaN(e.value))))return[y(NaN,3)];if(!(e=Wo(e)))throw Error("FORG0006: Incompatible types to be converted to a common type");return e}const ad=(e,t,n,r,a,o)=>ue([a,o],(([e,t])=>{if(1/0===e.value)return $.empty();if(-1/0===e.value)return t&&1/0===t.value?$.empty():r;if(t){if(isNaN(t.value))return $.empty();1/0===t.value&&(t=null)}return isNaN(e.value)?$.empty():td(r,Math.round(e.value),t?Math.round(t.value):null)})),od=(e,t,n,r,a)=>{if(r.G())return a;if(!(e=Wo(e=nd(r.O()))))throw Error("FORG0006: Incompatible types to be converted to a common type");if(!e.every((e=>T(e.type,2))))throw Error("FORG0006: items passed to fn:sum are not all numeric.");return t=e.reduce(((e,t)=>e+t.value),0),e.every((e=>T(e.type,5)))?$.m(y(t,5)):e.every((e=>T(e.type,3)))?$.m(y(t,3)):e.every((e=>T(e.type,4)))?$.m(y(t,4)):$.m(y(t,6))};var sd=[].concat(Er,[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"boolean",j:[{type:59,g:2}],i:{type:0,g:3},callFunction:(e,t,n,r)=>r.fa()?$.aa():$.V()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"true",j:[],i:{type:0,g:3},callFunction:()=>$.aa()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"not",j:[{type:59,g:2}],i:{type:0,g:3},callFunction:(e,t,n,r)=>!1===r.fa()?$.aa():$.V()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"false",j:[],i:{type:0,g:3},callFunction:()=>$.V()}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"last",j:[],i:{type:5,g:3},callFunction:e=>{if(null===e.M)throw We("The fn:last() function depends on dynamic context, which is absent.");let t=!1;return $.create({next:()=>{if(t)return A;const n=e.sa.Pa();return t=!0,E(y(n,5))}},1)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"position",j:[],i:{type:5,g:3},callFunction:e=>{if(null===e.M)throw We("The fn:position() function depends on dynamic context, which is absent.");return $.m(y(e.Aa+1,5))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-dateTime",j:[],i:{type:10,g:3},callFunction:e=>$.m(y(Xe(e),10))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-date",j:[],i:{type:7,g:3},callFunction:e=>$.m(y(Ce(Xe(e),7),7))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-time",j:[],i:{type:8,g:3},callFunction:e=>$.m(y(Ce(Xe(e),8),8))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"implicit-timezone",j:[],i:{type:17,g:3},callFunction:e=>$.m(y(qe(e),17))}],Tr,kr,$r,[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"years-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.ab(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"months-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.$a(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"days-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.Za(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.getHours(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.getMinutes(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-duration",j:[{type:18,g:0}],i:{type:4,g:0},callFunction:(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.getSeconds(),4))}],Hr,[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"id",j:[{type:1,g:2},{type:53,g:3}],i:{type:54,g:2},callFunction:Kh},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"id",j:[{type:1,g:2}],i:{type:54,g:2},callFunction:(e,t,n,r)=>Kh(e,t,0,r,$.m(e.M))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"idref",j:[{type:1,g:2},{type:53,g:3}],i:{type:53,g:2},callFunction:Wh},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"idref",j:[{type:1,g:2}],i:{type:53,g:2},callFunction:(e,t,n,r)=>Wh(e,t,0,r,$.m(e.M))}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"parse-json",j:[{type:1,g:3}],i:{type:59,g:0},callFunction:(e,t,n,r)=>{let a;try{a=JSON.parse(r.first().value)}catch(e){throw Error("FOJS0001: parsed JSON string contains illegal JSON.")}return Zh(a)}}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"contains",j:[{type:61,g:3},{type:46,g:3}],i:{type:0,g:3},callFunction:(e,t,n,r,a)=>ue([r,a],(([e,t])=>e.h.some((e=>pe(e.key,t)))?$.aa():$.V()))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"entry",j:[{type:46,g:3},{type:59,g:2}],i:{type:61,g:3},callFunction:(e,t,n,r,a)=>r.map((e=>new de([{key:e,value:L(a)}])))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"for-each",j:[{type:61,g:3},{type:59,g:2}],i:{type:59,g:2},callFunction:(e,t,n,r,a)=>ue([r,a],(([r,a])=>Qe(r.h.map((r=>a.value.call(void 0,e,t,n,$.m(r.key),r.value()))))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"get",j:[{type:61,g:3},{type:46,g:3}],i:{type:59,g:2},callFunction:he},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"keys",j:[{type:61,g:3}],i:{type:46,g:2},callFunction:(e,t,n,r)=>ue([r],(([e])=>$.create(e.h.map((e=>e.key)))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"merge",j:[{type:61,g:2},{type:61,g:3}],i:{type:61,g:3},callFunction:ed},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"merge",j:[{type:61,g:2}],i:{type:61,g:3},callFunction:(e,t,n,r)=>ed(e,0,0,r,$.m(new de([{key:y("duplicates",1),value:()=>$.m(y("use-first",1))}])))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"put",j:[{type:61,g:3},{type:46,g:3},{type:59,g:2}],i:{type:61,g:3},callFunction:(e,t,n,r,a,o)=>ue([r,a],(([e,t])=>{const n=(e=e.h.concat()).findIndex((e=>pe(e.key,t)));return 0<=n?e.splice(n,1,{key:t,value:L(o)}):e.push({key:t,value:L(o)}),$.m(new de(e))}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"remove",j:[{type:61,g:3},{type:46,g:2}],i:{type:61,g:3},callFunction:(e,t,n,r,a)=>ue([r],(([e])=>{const t=e.h.concat();return a.N((e=>(e.forEach((e=>{const n=t.findIndex((t=>pe(t.key,e)));0<=n&&t.splice(n,1)})),$.m(new de(t)))))}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"size",j:[{type:61,g:3}],i:{type:5,g:3},callFunction:(e,t,n,r)=>r.map((e=>y(e.h.length,5)))}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"pi",j:[],i:{type:3,g:3},callFunction:()=>$.m(y(Math.PI,3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"exp",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.pow(Math.E,e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"exp10",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.pow(10,e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"log",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.log(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"log10",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.log10(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"pow",j:[{type:3,g:0},{type:2,g:3}],i:{type:3,g:0},callFunction:(e,t,n,r,a)=>a.N((([e])=>r.map((t=>1!==Math.abs(t.value)||Number.isFinite(e.value)?y(Math.pow(t.value,e.value),3):y(1,3)))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"sqrt",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.sqrt(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"sin",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.sin(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"cos",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.cos(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"tan",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.tan(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"asin",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.asin(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"acos",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.acos(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"atan",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.atan(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"atan2",j:[{type:3,g:0},{type:3,g:3}],i:{type:3,g:0},callFunction:(e,t,n,r,a)=>a.N((([e])=>r.map((t=>y(Math.atan2(t.value,e.value),3)))))}],Cn,an,[{namespaceURI:"http://fontoxpath/operators",localName:"to",j:[{type:5,g:0},{type:5,g:0}],i:{type:5,g:2},callFunction:(e,t,n,r,a)=>{if(e=r.first(),a=a.first(),null===e||null===a)return $.empty();let o=e.value;return a=a.value,o>a?$.empty():$.create({next:()=>E(y(o++,5))},a-o+1)}}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"QName",j:[{type:1,g:0},{type:1,g:3}],i:{type:23,g:3},callFunction:(e,t,n,r,a)=>ue([r,a],(([e,t])=>{if(!st(t=t.value,23))throw Error("FOCA0002: The provided QName is invalid.");if(null===(e=e&&e.value||null)&&t.includes(":"))throw Error("FOCA0002: The URI of a QName may not be empty if a prefix is provided.");if(r.G())return $.m(y(new H("",null,t),23));if(!t.includes(":"))return $.m(y(new H("",e,t),23));const[n,a]=t.split(":");return $.m(y(new H(n,e,a),23))}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"prefix-from-QName",j:[{type:23,g:0}],i:{type:24,g:0},callFunction:(e,t,n,r)=>ue([r],(([e])=>null===e?$.empty():(e=e.value).prefix?$.m(y(e.prefix,24)):$.empty()))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"local-name-from-QName",j:[{type:23,g:0}],i:{type:24,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(e.value.localName,24)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"namespace-uri-from-QName",j:[{type:23,g:0}],i:{type:20,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(e.value.namespaceURI||"",20)))}],[{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>r.Y({empty:()=>$.aa(),multiple:()=>$.V(),m:()=>$.V()}),localName:"empty",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>r.Y({empty:()=>$.V(),multiple:()=>$.aa(),m:()=>$.aa()}),localName:"exists",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>td(r,1,1),localName:"head",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:0}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>td(r,2,null),localName:"tail",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:5,g:3},{type:59,g:2}],callFunction:(e,t,n,r,a,o)=>r.G()?o:o.G()?r:(e=r.O(),0>(a=a.first().value-1)?a=0:a>e.length&&(a=e.length),t=e.slice(a),$.create(e.slice(0,a).concat(o.O(),t))),localName:"insert-before",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:5,g:3}],callFunction:(e,t,n,r,a)=>(e=a.first().value,!(r=r.O()).length||1>e||e>r.length||r.splice(e-1,1),$.create(r)),localName:"remove",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>r.N((e=>$.create(e.reverse()))),localName:"reverse",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:3,g:3}],callFunction:(e,t,n,r,a)=>ad(0,0,0,r,a,$.empty()),localName:"subsequence",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:3,g:3},{type:3,g:3}],callFunction:ad,localName:"subsequence",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>r,localName:"unordered",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:46,g:2}],callFunction:(e,t,n,r)=>{const a=rt(r,t).O();return $.create(a).filter(((e,t)=>a.slice(0,t).every((t=>!Fn(e,t)))))},localName:"distinct-values",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}},{j:[{type:46,g:2},{type:1,g:3}],callFunction(){throw Error("FOCH0002: No collations are supported")},localName:"distinct-values",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}},{j:[{type:46,g:2},{type:46,g:3}],callFunction:(e,t,n,r,a)=>a.N((([n])=>rt(r,t).map(((t,r)=>Ro("eqOp",t.type,n.type)(t,n,e)?y(r+1,5):y(-1,5))).filter((e=>-1!==e.value)))),localName:"index-of",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:2}},{j:[{type:46,g:2},{type:46,g:3},{type:1,g:3}],callFunction(){throw Error("FOCH0002: No collations are supported")},localName:"index-of",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:2}},{j:[{type:59,g:2},{type:59,g:2}],callFunction:(e,t,n,r,a)=>{let o=!1;const s=Rn(e,t,n,r,a);return $.create({next:()=>{if(o)return A;const e=s.next(0);return e.done?e:(o=!0,E(y(e.value,0)))}})},localName:"deep-equal",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:59,g:2},{type:59,g:2},{type:1,g:3}],callFunction(){throw Error("FOCH0002: No collations are supported")},localName:"deep-equal",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>{let a=!1;return $.create({next:()=>{if(a)return A;const e=r.Pa();return a=!0,E(y(e,5))}})},localName:"count",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:3}},{j:[{type:46,g:2}],callFunction:(e,t,n,r)=>{if(r.G())return r;if(!(e=Wo(e=nd(r.O()))))throw Error("FORG0006: Incompatible types to be converted to a common type");if(!e.every((e=>T(e.type,2))))throw Error("FORG0006: items passed to fn:avg are not all numeric.");return t=e.reduce(((e,t)=>e+t.value),0)/e.length,e.every((e=>T(e.type,5)||T(e.type,3)))?$.m(y(t,3)):e.every((e=>T(e.type,4)))?$.m(y(t,4)):$.m(y(t,6))},localName:"avg",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2}],callFunction:(e,t,n,r)=>r.G()?r:(e=rd(r.O()),$.m(e.reduce(((e,t)=>e.value<t.value?t:e)))),localName:"max",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2},{type:1,g:3}],callFunction(){throw Error("FOCH0002: No collations are supported")},localName:"max",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2}],callFunction:(e,t,n,r)=>r.G()?r:(e=rd(r.O()),$.m(e.reduce(((e,t)=>e.value>t.value?t:e)))),localName:"min",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2},{type:1,g:3}],callFunction(){throw Error("FOCH0002: No collations are supported")},localName:"min",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2}],callFunction:(e,t,n,r)=>od(e,t,0,r,$.m(y(0,5))),localName:"sum",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:3}},{j:[{type:46,g:2},{type:46,g:0}],callFunction:od,localName:"sum",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>{if(!r.G()&&!r.ua())throw Error("FORG0003: The argument passed to fn:zero-or-one contained more than one item.");return r},localName:"zero-or-one",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:0}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>{if(r.G())throw Error("FORG0004: The argument passed to fn:one-or-more was empty.");return r},localName:"one-or-more",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:1}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>{if(!r.ua())throw Error("FORG0005: The argument passed to fn:exactly-one is empty or contained more than one item.");return r},localName:"exactly-one",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:3}},{j:[{type:59,g:2},{type:60,g:3}],callFunction:(e,t,n,r,a)=>{if(r.G())return r;const o=a.first(),s=o.o;if(1!==s.length)throw Error("XPTY0004: signature of function passed to fn:filter is incompatible.");return r.filter((r=>{if(r=Gt(s[0],$.m(r),t,"fn:filter",!1),!(r=o.value.call(void 0,e,t,n,r)).ua()||!T(r.first().type,0))throw Error("XPTY0004: signature of function passed to fn:filter is incompatible.");return r.first().value}))},localName:"filter",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:60,g:3}],callFunction:(e,t,n,r,a)=>{if(r.G())return r;const o=a.first(),s=o.o;if(1!==s.length)throw Error("XPTY0004: signature of function passed to fn:for-each is incompatible.");const i=r.value;let l;return $.create({next:r=>{for(;;){if(!l){var a=i.next(0);if(a.done)return a;a=Gt(s[0],$.m(a.value),t,"fn:for-each",!1),l=o.value.call(void 0,e,t,n,a).value}if(!(a=l.next(r)).done)return a;l=null}}})},localName:"for-each",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:59,g:2},{type:60,g:3}],callFunction:(e,t,n,r,a,o)=>{if(r.G())return r;const s=o.first(),i=s.o;if(2!==i.length)throw Error("XPTY0004: signature of function passed to fn:fold-left is incompatible.");return r.N((r=>r.reduce(((r,a)=>(r=Gt(i[0],r,t,"fn:fold-left",!1),a=Gt(i[1],$.m(a),t,"fn:fold-left",!1),s.value.call(void 0,e,t,n,r,a))),a)))},localName:"fold-left",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:59,g:2},{type:60,g:3}],callFunction:(e,t,n,r,a,o)=>{if(r.G())return r;const s=o.first(),i=s.o;if(2!==i.length)throw Error("XPTY0004: signature of function passed to fn:fold-right is incompatible.");return r.N((r=>r.reduceRight(((r,a)=>(r=Gt(i[0],r,t,"fn:fold-right",!1),a=Gt(i[1],$.m(a),t,"fn:fold-right",!1),s.value.call(void 0,e,t,n,a,r))),a)))},localName:"fold-right",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>{if(!t.Ua)throw Error("serialize() called but no xmlSerializer set in execution parameters.");if(!(e=r.O()).every((e=>T(e.type,53))))throw Error("Expected argument to fn:serialize to resolve to a sequence of Nodes.");return $.m(y(e.map((e=>t.Ua.serializeToString(Ur(e.value,t,!1)))).join(""),1))},localName:"serialize",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}}],yn,[{j:[{type:59,g:3},{type:61,g:3}],callFunction:(e,t,n,r,a)=>{let o,s;return $.create({next:()=>{o||({fc:o,cc:s}=Jh(r,a,n,t));try{return o.next(0)}catch(e){_r(s.value,e)}}})},localName:"evaluate",namespaceURI:"http://fontoxml.com/fontoxpath",i:{type:59,g:2}},{j:[],callFunction:()=>$.m(y("3.30.0",1)),localName:"version",namespaceURI:"http://fontoxml.com/fontoxpath",i:{type:1,g:3}}],[{j:[{type:23,g:3},{type:5,g:3}],callFunction:(e,t,n,r,a)=>ue([r,a],(([e,t])=>{const r=n.va(e.value.namespaceURI,e.value.localName,t.value);return null===r?$.empty():(e=new P({j:r.j,arity:t.value,localName:e.value.localName,namespaceURI:e.value.namespaceURI,i:r.i,value:r.callFunction}),$.m(e))})),localName:"function-lookup",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{g:0,type:60}},{j:[{type:60,g:3}],callFunction:(e,t,n,r)=>ue([r],(([e])=>e.Xa()?$.empty():$.m(y(new H("",e.l,e.D),23)))),localName:"function-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[{type:60,g:3}],callFunction:(e,t,n,r)=>ue([r],(([e])=>$.m(y(e.v,5)))),localName:"function-arity",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:3}}]);class id{constructor(e){this.h=e}createAttributeNS(e,t){return this.h.createAttributeNS(e,t)}createCDATASection(e){return this.h.createCDATASection(e)}createComment(e){return this.h.createComment(e)}createDocument(){return this.h.createDocument()}createElementNS(e,t){return this.h.createElementNS(e,t)}createProcessingInstruction(e,t){return this.h.createProcessingInstruction(e,t)}createTextNode(e){return this.h.createTextNode(e)}}var ld=Symbol("IS_XPATH_VALUE_SYMBOL");function cd(e){return e&&"object"==typeof e&&"lookupNamespaceURI"in e?t=>e.lookupNamespaceURI(t||null):()=>null}function ud(e){return({prefix:t,localName:n})=>t?null:{namespaceURI:e,localName:n}}function pd(e,t,n,r,a,o){null==r&&(r=r||{});const s=a?{ib:a.logger||{trace:console.log.bind(console)},Ma:a.documentWriter,jb:a.moduleImports,Ab:a.namespaceResolver,Zb:a.functionNameResolver,Ia:a.nodesFactory,Ua:a.xmlSerializer}:{ib:{trace:console.log.bind(console)},jb:{},Ab:null,Ia:null,Ma:null,Ua:null},i=new oe(null===n?new q:n);n=s.jb||Object.create(null);var l=void 0===a.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":a.defaultFunctionNamespaceURI;const c=zh(e,o,s.Ab||cd(t),r,n,l,s.Zb||ud(l));e=t?He(0,t):$.empty(),t=!s.Ia&&o.Z?new Wn(t):new id(s.Ia),n=s.Ma?new Y(s.Ma):V,l=s.Ua;const u=Object.keys(r).reduce(((e,t)=>{const n=r[t];return e[`Q{}${t}[0]`]=n&&"object"==typeof n&&ld in n?()=>$.create(n.xb):()=>He(0,r[t]),e}),Object.create(null));let p;for(const e of Object.keys(c.ga.Ea))u[e]||(u[e]=()=>(0,c.ga.Ea[e])(p,h));p=new ze({M:e.first(),Aa:0,sa:e,qa:u});const h=new Je(o.debug,o.Ga,i,t,n,a.currentContext,new Map,s.ib,l);return{rb:p,sb:h,ba:c.ba}}function hd(e,t){const n={};let r=0,a=!1,o=null;return{next:()=>{if(a)return A;for(;r<e.h.length;){const a=e.h[r].key.value;if(!o){const i=e.h[r];var s=i.value().Y({default:e=>e,multiple:()=>{throw Error(`Serialization error: The value of an entry in a map is expected to be a single item or an empty sequence. Use arrays when putting multiple values in a map. The value of the key ${i.key.value} holds multiple items`)}}).first();if(null===s){n[a]=null,r++;continue}o=md(s,t)}s=o.next(0),o=null,n[a]=s.value,r++}return a=!0,E(n)}}}function dd(e,t){const n=[];let r=0,a=!1,o=null;return{next:()=>{if(a)return A;for(;r<e.h.length;){if(!o){var s=e.h[r]().Y({default:e=>e,multiple:()=>{throw Error("Serialization error: The value of an entry in an array is expected to be a single item or an empty sequence. Use nested arrays when putting multiple values in an array.")}}).first();if(null===s){n[r++]=null;continue}o=md(s,t)}s=o.next(0),o=null,n[r++]=s.value}return a=!0,E(n)}}}function md(e,t){if(T(e.type,61))return hd(e,t);if(T(e.type,62))return dd(e,t);if(T(e.type,23)){const t=e.value;return{next:()=>E(`Q{${t.namespaceURI||""}}${t.localName}`)}}switch(e.type){case 7:case 8:case 9:case 11:case 12:case 13:case 14:case 15:const n=e.value;return{next:()=>E(Se(n))};case 47:case 53:case 54:case 55:case 56:case 57:case 58:const r=e.value;return{next:()=>E(Ur(r,t,!1))};default:return{next:()=>E(e.value)}}}sd.forEach((e=>{zr(e.namespaceURI,e.localName,e.j,e.i,e.callFunction)}));var fd={ANY:0,NUMBER:1,STRING:2,BOOLEAN:3,NODES:7,FIRST_NODE:9,STRINGS:10,MAP:11,ARRAY:12,NUMBERS:13,ALL_RESULTS:14,ASYNC_ITERATOR:99};function gd(e,t,n,r){switch(n){case 3:return t.fa();case 2:return(t=rt(t,r).O()).length?t.map((e=>At(e,1).value)).join(" "):"";case 10:return(t=rt(t,r).O()).length?t.map((e=>e.value+"")):[];case 1:return null!==(t=t.first())&&T(t.type,2)?t.value:NaN;case 9:if(null===(t=t.first()))return null;if(!T(t.type,53))throw Error("Expected XPath "+Pr(e)+" to resolve to Node. Got "+C[t.type]);return Ur(t.value,r,!1);case 7:if(!(t=t.O()).every((e=>T(e.type,53))))throw Error("Expected XPath "+Pr(e)+" to resolve to a sequence of Nodes.");return t.map((e=>Ur(e.value,r,!1)));case 11:if(1!==(t=t.O()).length)throw Error("Expected XPath "+Pr(e)+" to resolve to a single map.");if(!T((t=t[0]).type,61))throw Error("Expected XPath "+Pr(e)+" to resolve to a map");return hd(t,r).next(0).value;case 12:if(1!==(t=t.O()).length)throw Error("Expected XPath "+Pr(e)+" to resolve to a single array.");if(!T((t=t[0]).type,62))throw Error("Expected XPath "+Pr(e)+" to resolve to an array");return dd(t,r).next(0).value;case 13:return t.O().map((t=>{if(!T(t.type,2))throw Error("Expected XPath "+Pr(e)+" to resolve to numbers");return t.value}));case 99:const n=t.value;let a=null,o=!1;const s=()=>{for(;!o;){if(!a){var e=n.next(0);if(e.done){o=!0;break}a=md(e.value,r)}return e=a.next(0),a=null,e}return Promise.resolve({done:!0,value:null})};return"asyncIterator"in Symbol?{[Symbol.asyncIterator](){return this},next:()=>new Promise((e=>e(s()))).catch((t=>{_r(e,t)}))}:{next:()=>new Promise((e=>e(s())))};case 14:return t.O().map((e=>md(e,r).next(0).value));default:return(t=t.O()).every((e=>T(e.type,53)&&!T(e.type,47)))?(t=t.map((e=>Ur(e.value,r,!1))),1===t.length?t[0]:t):1===t.length?T((t=t[0]).type,62)?dd(t,r).next(0).value:T(t.type,61)?hd(t,r).next(0).value:nt(t,r).first().value:rt($.create(t),r).O().map((e=>e.value))}}fd[fd.ANY]="ANY",fd[fd.NUMBER]="NUMBER",fd[fd.STRING]="STRING",fd[fd.BOOLEAN]="BOOLEAN",fd[fd.NODES]="NODES",fd[fd.FIRST_NODE]="FIRST_NODE",fd[fd.STRINGS]="STRINGS",fd[fd.MAP]="MAP",fd[fd.ARRAY]="ARRAY",fd[fd.NUMBERS]="NUMBERS",fd[fd.ALL_RESULTS]="ALL_RESULTS",fd[fd.ASYNC_ITERATOR]="ASYNC_ITERATOR";let yd=!1,wd=null;var vd={getPerformanceSummary(){const e=wd.getEntriesByType("measure").filter((e=>e.name.startsWith("XPath: ")));return Array.from(e.reduce(((e,t)=>{var n=t.name.substring(7);return e.has(n)?((n=e.get(n)).times+=1,n.totalDuration+=t.duration):e.set(n,{xpath:n,times:1,totalDuration:t.duration,average:0}),e}),new Map).values()).map((e=>(e.average=e.totalDuration/e.times,e))).sort(((e,t)=>t.totalDuration-e.totalDuration))},setPerformanceImplementation(e){wd=e},startProfiling(){if(null===wd)throw Error("Performance API object must be set using `profiler.setPerformanceImplementation` before starting to profile");wd.clearMarks(),wd.clearMeasures(),yd=!0},stopProfiling(){yd=!1}};let xd=0;const bd=(e,t,n,r,a,o)=>{if(a=a||0,!e||"string"!=typeof e&&!("nodeType"in e))throw new TypeError("Failed to execute 'evaluateXPath': xpathExpression must be a string or an element depicting an XQueryX DOM tree.");let s,i;o=o||{};try{const a=pd(e,t,n||null,r||{},o,{ra:"XQueryUpdate3.1"===o.language,Z:"XQuery3.1"===o.language||"XQueryUpdate3.1"===o.language,debug:!!o.debug,Ga:!!o.disableCache});var l=a.rb;s=a.sb,i=a.ba}catch(t){_r(e,t)}if(i.J)throw Error("XUST0001: Updating expressions should be evaluated as updating expressions");if(3===a&&t&&"object"==typeof t&&"nodeType"in t&&(n=i.D(),t=X(t),null!==n&&!t.includes(n)))return!1;try{t=e,yd&&("string"!=typeof t&&(t=Pr(t)),wd.mark(`${t}${0===xd?"":"@"+xd}`),xd++);const n=gd(e,Jn(i,l,s),a,s);return a=e,yd&&("string"!=typeof a&&(a=Pr(a)),xd--,l=`${a}${0===xd?"":"@"+xd}`,wd.measure(`XPath: ${a}`,l),wd.clearMarks(l)),n}catch(t){_r(e,t)}};function Ad(e,t,n,r,a){return bd(e,t,n,r,bd.Jb,a)}function Ed(e,t,n,r){return{pendingUpdateList:e.da.map((e=>e.h(r))),xdmValue:gd(t,$.create(e.I),n,r)}}function Nd(e,t,n){return{code:e,ta:t,H:n,isAstAccepted:!0}}function Td(e){return{isAstAccepted:!1,reason:e}}function Bd(e,t){return e.isAstAccepted?t(e):e}function Id(e,t){return e.isAstAccepted?t(e):[e,null]}function Cd(e,t,n){return Bd(e,(e=>{switch(e.ta.type){case 0:return e;case 1:return Bd(lm(n,e,"nodes"),(e=>Bd(lm(n,t,"contextItem"),(t=>Nd(`(function () {\n\t\t\t\t\t\t\tconst { done, value } = ${e.code}(${t.code}).next();\n\t\t\t\t\t\t\treturn done ? null : value;\n\t\t\t\t\t\t})()`,{type:0},[...e.H,...t.H])))));default:throw Error(`invalid generated code type to convert to value: ${e.ta.type}`)}}))}function Sd(e,t,n,r){return e=Cd(e,n,r),t&&0===t.type&&3===t.g?e:Bd(e,(e=>Nd(`!!${e.code}`,{type:0},e.H)))}function Od(e,t,n){return t?e.isAstAccepted&&0!==e.ta.type?Td("Atomization only implemented for single value"):T(t.type,1)?e:T(t.type,47)?Bd(lm(n,e,"attr"),(e=>Nd(`(${e.code} ? domFacade.getData(${e.code}) : null)`,{type:0},e.H))):Td("Atomization only implemented for string and attribute"):Td("Can not atomize value if type was not annotated")}function Fd(e,t,n,r){return r=Od(e=Cd(e,n,r),t,r),lt(t)?Bd(r,(e=>Nd(`${e.code} ?? ''`,{type:0},e.H))):r}function Dd(e,t,n){return Bd(lm(n,e,"node"),(e=>1===e.ta.type?e:t&&!T(t.type,53)?Td("Can not evaluate to node if expression does not result in nodes"):Nd(`(function () {\n\t\t\t\tif (${e.code} !== null && !${e.code}.nodeType) {\n\t\t\t\t\tthrow new Error('XPDY0050: The result of the expression was not a node');\n\t\t\t\t}\n\t\t\t\treturn ${e.code};\n\t\t\t})()`,{type:0},e.H)))}function kd(e,t){return Bd(e,(e=>Bd(t,(t=>{if(0!==e.ta.type||0!==t.ta.type)throw Error("can only use emitAnd with value expressions");return Nd(`${e.code} && ${t.code}`,{type:0},[...e.H,...t.H])}))))}function Rd(e,t,n,r){return(e=va(e,[t,"*"]))?r.h(e,n,r):[Td(`${t} expression not found`),null]}Object.assign(bd,{hc:14,ANY_TYPE:0,Ib:12,Jb:99,BOOLEAN_TYPE:3,Lb:9,Ob:11,Qb:7,Rb:13,NUMBER_TYPE:1,Sb:10,STRING_TYPE:2,ic:"XPath3.1",jc:"XQuery3.1",Vb:"XQueryUpdate3.1"}),Object.assign(bd,{ALL_RESULTS_TYPE:14,ANY_TYPE:0,ARRAY_TYPE:12,ASYNC_ITERATOR_TYPE:99,BOOLEAN_TYPE:3,FIRST_NODE_TYPE:9,MAP_TYPE:11,NODES_TYPE:7,NUMBERS_TYPE:13,NUMBER_TYPE:1,STRINGS_TYPE:10,STRING_TYPE:2,XPATH_3_1_LANGUAGE:"XPath3.1",XQUERY_3_1_LANGUAGE:"XQuery3.1",XQUERY_UPDATE_3_1_LANGUAGE:"XQueryUpdate3.1"});const Md={equalOp:"eqOp",notEqualOp:"neOp",lessThanOrEqualOp:"leOp",lessThanOp:"ltOp",greaterThanOrEqualOp:"geOp",greaterThanOp:"gtOp"},Ud={eqOp:"eqOp",neOp:"neOp",leOp:"geOp",ltOp:"gtOp",geOp:"leOp",gtOp:"ltOp"};function Gd(e,t,n,r){const a=wa(va(e,["firstOperand","*"]),"type"),o=wa(va(e,["secondOperand","*"]),"type");if(!a||!o)return Td("Can not generate code for value compare without both types");var s=[47,1];if(!s.includes(a.type)||!s.includes(o.type))return Td(`Unsupported types in compare: [${C[a.type]}, ${C[o.type]}]`);if(!(s=new Map([["eqOp","==="],["neOp","!=="]])).has(t))return Td(t+" not yet implemented");const i=s.get(t);return[t]=Rd(e,"firstOperand",n,r),t=Od(t=Cd(t,n,r),a,r),Bd(lm(r,t,"first"),(t=>{var[s]=Rd(e,"secondOperand",n,r);return s=Od(s=Cd(s,n,r),o,r),Bd(lm(r,s,"second"),(e=>{const n=[];return lt(a)&&n.push(`${t.code} === null`),lt(o)&&n.push(`${e.code} === null`),Nd(`(${n.length?`${n.join(" || ")} ? null : `:""}${t.code} ${i} ${e.code})`,{type:0},[...t.H,...e.H])}))}))}function $d(e,t,n,r,a,o){var s=wa(va(e,[t,"*"]),"type");const i=wa(va(e,[n,"*"]),"type");if(!s||!i)return Td("Can not generate code for general compare without both types");var l=[47,1];if(!l.includes(s.type)||!l.includes(i.type))return Td(`Unsupported types in compare: [${C[s.type]}, ${C[i.type]}]`);if(!(l=new Map([["eqOp","==="],["neOp","!=="]])).has(r))return Td(r+" not yet implemented");const c=l.get(r);return[t]=Rd(e,t,a,o),s=Od(t=Cd(t,a,o),s,o),Bd(lm(o,s,"single"),(t=>{const[r]=Rd(e,n,a,o);return Bd(lm(o,r,"multiple"),(e=>{if(1!==e.ta.type)return Td("can only generate general compare for a single value and a generator");const n=um(o,cm(o,"n")),r=Od(n,i,o);return Bd(a,(a=>Bd(r,(r=>Nd(`(function () {\n\t\t\t\t\t\t\t\t\tfor (const ${n.code} of ${e.code}(${a.code})) {\n\t\t\t\t\t\t\t\t\t\t${r.H.join("\n")}\n\t\t\t\t\t\t\t\t\t\tif (${r.code} ${c} ${t.code}) {\n\t\t\t\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t})()`,{type:0},[...t.H,...n.H,...a.H,...e.H])))))}))}))}function Ld(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}const Hd={"false#0":function(){return Nd("false",{type:0},[])},"local-name#0":Vd,"local-name#1":Vd,"name#0":qd,"name#1":qd,"not#1":function(e,t,n){var r=va(e,["arguments","*"]);return e=wa(r,"type"),[r]=n.h(r,t,n),Bd(t=Sd(r,e,t,n),(e=>Nd(`!${e.code}`,{type:0},e.H)))},"true#0":function(){return Nd("true",{type:0},[])}},Pd={"http://fontoxml.com/fontoxpath":["version#0"],"":["root#1","path#1"]};function jd(e,t,n,r){if(e.length!==t.length||t.some((e=>4===e)))return Td("Not supported: variadic function or mismatch in argument count");if(0===e.length)return Nd("",{type:0},[]);const[a,...o]=e,[s,...i]=t;return e=lm(r,function(e,t,n,r){const[a]=r.h(e,n,r);if(e=wa(e,"type"),!t||2===t.g||1===t.g)return Td("Not supported: sequence arguments with multiple items");if(T(t.type,53))return Dd(t=Cd(a,n,r),e,r);switch(t.type){case 59:return Cd(a,n,r);case 0:return Sd(a,e,n,r);case 1:return Fd(a,e,n,r)}return Td(`Argument types not supported: ${e?C[e.type]:"unknown"} -> ${C[t.type]}`)}(a,s,n,r),"arg"),0===o.length?e:Bd(e,(e=>Bd(jd(o,i,n,r),(t=>Nd(`${e.code}, ${t.code}`,{type:0},[...e.H,...t.H])))))}function _d(e,t,n){const{localName:r,namespaceURI:a}=ba(ga(e,"functionName")),o=xa(ga(e,"arguments"),"*");var s=o.length;const i=`${r}#${s}`,l=a===n.D;if(l){const r=Hd[i];if(void 0!==r)return r(e,t,n)}return(e=Pd[l?"":a])&&!e.includes(i)?Td(`Not supported: built-in function not on allow list: ${i}`):(s=Yr(a,r,s))?s.J?Td("Not supported: updating functions"):(t=Bd(t=jd(o,s.j,t,n),(e=>Nd(`runtimeLib.callFunction(domFacade, ${Ld(a)}, ${Ld(r)}, [${e.code}], options)`,{type:0},e.H))),function(e,t){return Bd(e,(e=>t&&2!==t.g&&1!==t.g&&([0,1].includes(t.type)||T(t.type,53))?e:Td(`Function return type ${C[t.type]} not supported`)))}(t,s.i)):Td(`Unknown function / arity: ${i}`)}function Xd(e,t,n,r){if((e=va(e,["arguments","*"]))&&"contextItemExpr"!==e[0]){const r=wa(e,"type");if(!r||!T(r.type,53))return Td("name function only implemented if arg is a node");[e]=n.h(e,t,n)}else e=function(e,t){return Bd(lm(t,e,"contextItem"),(e=>Nd(e.code,{type:0},[...e.H,`if (${e.code} === undefined || ${e.code} === null) {\n\t\t\t\t\tthrow errXPDY0002('The function which was called depends on dynamic context, which is absent.');\n\t\t\t\t}`])))}(t,n);return Bd(lm(n,t=Cd(e,t,n),"arg"),(e=>Nd(`(${e.code} ? ${r(e.code)} : '')`,{type:0},e.H)))}function qd(e,t,n){return Xd(e,t,n,(e=>`(((${e}.prefix || '').length !== 0 ? ${e}.prefix + ':' : '')\n\t\t+ (${e}.localName || ${e}.target || ''))`))}function Vd(e,t,n){return Xd(e,t,n,(e=>`(${e}.localName || ${e}.target || '')`))}function Yd(e,t,n,r){const[a,o]=Rd(e,"firstOperand",n,r);var s=wa(va(e,["firstOperand","*"]),"type");s=Sd(a,s,n,r);const[i,l]=Rd(e,"secondOperand",n,r);s=Bd(s,(a=>{var o=wa(va(e,["secondOperand","*"]),"type");return Bd(o=Sd(i,o,n,r),(e=>Nd(`(${a.code} ${t} ${e.code})`,{type:0},[...a.H,...e.H])))}));return[s,"&&"===t?Za(o,l):o===l?o:null]}function zd(e,t,n){return Bd(e,(e=>Bd(t,(t=>Bd(n,(n=>Nd(`for (${e.code}) {\n\t\t\t\t\t\t${t.H.join("\n")}\n\t\t\t\t\t\tif (!(${t.code})) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t${n.H.join("\n")}\n\t\t\t\t\t\t${n.code}\n\t\t\t\t\t}`,{type:2},e.H)))))))}function Jd(e,t,n,r,a){const o=t?`, "${t}"`:"";return t=Bd(r,(e=>Bd(a,(t=>Nd(`let ${e.code} = domFacade.getFirstChild(${t.code}${o});\n\t\t\t\t\t\t\t${e.code};\n\t\t\t\t\t\t\t${e.code} = domFacade.getNextSibling(${e.code}${o})`,{type:2},[...e.H,...t.H]))))),zd(t,e,n)}function Qd(e,t,n,r,a){const o=Za(t,"type-2"),s=Bd(a,(e=>Nd(`(${e.code} && ${e.code}.nodeType === /*ELEMENT_NODE*/ 1 ? domFacade.getAllAttributes(${e.code}${o?`, "${o}"`:""}) : [])`,{type:0},e.H)));return t=Bd(r,(e=>Bd(s,(t=>Nd(`const ${e.code} of ${t.code}`,{type:2},[...e.H,...t.H]))))),zd(t,e,n)}function Kd(e,t,n,r,a){const o=t?`, "${t}"`:"";return t=Bd(a,(e=>Nd(`domFacade.getParentNode(${e.code}${o})`,{type:0},e.H))),Wd(r,t,e,n)}function Wd(e,t,n,r){const a=kd(e,n);return Bd(e,(e=>Bd(t,(t=>Bd(a,(n=>Bd(r,(r=>Nd(`const ${e.code} = ${t.code};\n\t\t\t\t\t\t${n.H.join("\n")}\n\t\t\t\t\t\tif (${n.code}) {\n\t\t\t\t\t\t\t${r.H.join("\n")}\n\t\t\t\t\t\t\t${r.code}\n\t\t\t\t\t\t}`,{type:2},[...e.H,...t.H])))))))))}const Zd={Tb:"textTest",Kb:"elementTest",Pb:"nameTest",Ub:"Wildcard",Hb:"anyKindTest"};var em=Object.values(Zd);function tm(e,t,n,r){!function(e,t){if(null===e.namespaceURI&&"*"!==e.prefix){if(!(t=t.$(e.prefix||"")||null)&&e.prefix)throw Error(`XPST0081: The prefix ${e.prefix} could not be resolved.`);e.namespaceURI=t}}(e,r);const a=e.prefix,o=e.namespaceURI,s=e.localName;return Id(n,(e=>{var n=Nd(t?`${e.code}.nodeType\n\t\t\t\t\t\t&& (${e.code}.nodeType === /*ELEMENT_NODE*/ 1\n\t\t\t\t\t\t|| ${e.code}.nodeType === /*ATTRIBUTE_NODE*/ 2)`:`${e.code}.nodeType\n\t\t\t\t\t\t&& ${e.code}.nodeType === /*ELEMENT_NODE*/ 1`,{type:0},[]);if("*"===a)return"*"===s?[n,t?"type-1-or-type-2":"type-1"]:[kd(n,Nd(`${e.code}.localName === ${Ld(s)}`,{type:0},[])),`name-${s}`];n="*"===s?n:kd(n,Nd(`${e.code}.localName === ${Ld(s)}`,{type:0},[]));var r=Nd(Ld(o),{type:0},[]);return r=""===a&&t?Bd(r,(t=>Nd(`${e.code}.nodeType === /*ELEMENT_NODE*/ 1 ? ${t.code} : null`,{type:0},t.H))):r,r=Bd(r,(t=>Nd(`(${e.code}.namespaceURI || null) === ((${t.code}) || null)`,{type:0},t.H))),[kd(n,r),`name-${s}`]}))}function nm(e,t,n,r){var a=e[0];switch(a){case Zd.Kb:return function(e,t,n){const r=(e=ga(e,"elementName"))&&ga(e,"star");return null===e||r?[Bd(t,(e=>Nd(`${e.code}.nodeType === /*ELEMENT_NODE*/ 1`,{type:0},[]))),"type-1"]:tm(e=ba(ga(e,"QName")),!1,t,n)}(e,n,r);case Zd.Tb:return function(e){return[Bd(e,(e=>Nd(`(${e.code}.nodeType === /*TEXT_NODE*/ 3 ||\n\t\t\t\t${e.code}.nodeType === /* CDATA_SECTION_NODE */ 4)`,{type:0},[]))),"type-3"]}(n);case Zd.Pb:return tm(ba(e),t,n,r);case Zd.Ub:return ga(e,"star")?null!==(a=ga(e,"uri"))?e=tm({localName:"*",namespaceURI:ya(a),prefix:""},t,n,r):(a=ga(e,"NCName"),e="star"===ga(e,"*")[0]?tm({localName:ya(a),namespaceURI:null,prefix:"*"},t,n,r):tm({localName:"*",namespaceURI:null,prefix:ya(a)},t,n,r)):e=tm({localName:"*",namespaceURI:null,prefix:"*"},t,n,r),e;case Zd.Hb:return function(e){return[Bd(e,(e=>Nd(`!!${e.code}.nodeType`,{type:0},[]))),null]}(n);default:return[Td(`Test not implemented: '${a}`),null]}}function rm(e,t,n){const[r,a]=n.h(e,t,n);return[Sd(r,wa(e,"type"),t,n),a]}function am(e,t,n){e=e?xa(e,"*"):[];const[r,a]=e.reduce((([e,r],a)=>{if(!e)return rm(a,t,n);let o=r;return Id(e,(e=>{const[s,i]=rm(a,t,n);return o=Za(r,i),[Bd(s,(t=>Nd(`${e.code} && ${t.code}`,{type:0},[...e.H,...t.H]))),o]}))}),[null,null]);return[r?Bd(r,(e=>Nd(`(function () {\n\t\t\t\t\t\t\t${e.H.join("\n")}\n\t\t\t\t\t\t\treturn ${e.code};\n\t\t\t\t\t\t})()`,{type:0},[]))):null,a]}function om(e,t,n,r){if(0===e.length)return[Bd(n,(e=>Nd(`yield ${e.code};`,{type:2},e.H))),null];const[a,...o]=e;if(0<xa(a,"lookup").length)return[Td("Unsupported: lookups"),null];const s=um(r,cm(r,"contextItem"));e=ga(a,"predicates");const[i,l]=am(e,s,r);if(e=ga(a,"xpathAxis")){var c=ga(a,em);if(!c)return[Td("Unsupported test in step"),null];var u=ya(e);t="attribute"===u||"self"===u&&t;const[p,h]=nm(c,t,s,r);return c=null===i?p:kd(p,i),u=Za(h,l),[t]=om(o,t,s,r),function(e,t,n,r,a,o){switch(e=ya(e)){case"attribute":return[Qd(t,n,r,a,o),"type-1"];case"child":return[Jd(t,n,r,a,o),null];case"parent":return[Kd(t,n,r,a,o),null];case"self":return[Wd(a,o,t,r),n];default:return[Td(`Unsupported: the ${e} axis`),null]}}(e,c,u,t,s,n)}if(!(e=va(a,["filterExpr","*"])))return[Td("Unsupported: unknown step type"),null];const[p,h]=r.h(e,n,r);return[Bd(p,(e=>{const t=0===o.length?Nd("",{type:2},[]):Nd(`if (${s.code} !== null && !${s.code}.nodeType) {\n\t\t\t\t\t\t\t\t\tthrow new Error('XPTY0019: The result of E1 in a path expression E1/E2 should evaluate to a sequence of nodes.');\n\t\t\t\t\t\t\t\t}`,{type:2},[]),[a]=om(o,!0,s,r),l=null===i?a:Bd(i,(e=>Bd(a,(t=>Nd(`if (${e.code}) {\n\t\t\t\t\t\t\t\t\t${t.H.join("\n")}\n\t\t\t\t\t\t\t\t\t${t.code}\n\t\t\t\t\t\t\t\t}`,{type:2},e.H)))));return Bd(l,(r=>{switch(e.ta.type){case 1:return Bd(n,(n=>Nd(`for (const ${s.code} of ${e.code}(${n.code})) {\n\t\t\t\t\t\t\t\t\t${r.H.join("\n")}\n\t\t\t\t\t\t\t\t\t${r.code}\n\t\t\t\t\t\t\t\t}`,{type:2},[...s.H,...e.H,...t.H])));case 0:return Nd(`const ${s.code} = ${e.code};\n\t\t\t\t\t\t\t${t.code}\n\t\t\t\t\t\t\tif (${s.code} !== null) {\n\t\t\t\t\t\t\t\t${r.H.join("\n")}\n\t\t\t\t\t\t\t\t${r.code}\n\t\t\t\t\t\t\t}`,{type:2},[...s.H,...e.H,...t.H]);default:return Td("Unsupported generated code type for filterExpr")}}))})),h]}function sm(e,t,n){const r=xa(e,"stepExpr");if(1===r.length){const e=ga(r[0],"xpathAxis");if(e&&"self"===ya(e))return function(e,t,n){return Id(t,(t=>{if(0<xa(e,"lookup").length)return[Td("Unsupported: lookups"),null];var r=ga(e,"predicates");const[a,o]=am(r,t,n);if(!(r=ga(e,em)))return[Td("Unsupported test in step"),null];const[s,i]=nm(r,!0,t,n);r=null===a?s:kd(s,a);const l=Za(i,o);return[Bd(r,(e=>Nd(`((${e.code}) ? ${t.code} : null)`,{type:0},[...t.H,...e.H]))),l]}))}(r[0],t,n)}const a=um(n,cm(n,"contextItem"));t=(e=ga(e,"rootExpr"))?lm(n,function(e){return Bd(e,(e=>Nd(`(function () {\n\t\t\t\tlet n = ${e.code};\n\t\t\t\twhile (n.nodeType !== /*DOCUMENT_NODE*/9) {\n\t\t\t\t\tn = domFacade.getParentNode(n);\n\t\t\t\t\tif (n === null) {\n\t\t\t\t\t\tthrow new Error('XPDY0050: the root node of the context node is not a document node.');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn n;\n\t\t\t})()`,{type:0},e.H)))}(a),"root"):a;const[o,s]=om(r,!e,t,n);return[Bd(o,(e=>Nd(`(function* (${a.code}) {\n\t\t\t${e.H.join("\n")}\n\t\t\t${e.code}\n\t\t})`,{type:1},[]))),s]}function im(e,t,n){const r=e[0];switch(r){case"contextItemExpr":return[t,null];case"pathExpr":return sm(e,t,n);case"andOp":return Yd(e,"&&",t,n);case"orOp":return Yd(e,"||",t,n);case"stringConstantExpr":return[Nd(e=Ld(e=ga(e,"value")[1]||""),{type:0},[]),null];case"equalOp":case"notEqualOp":case"lessThanOrEqualOp":case"lessThanOp":case"greaterThanOrEqualOp":case"greaterThanOp":case"eqOp":case"neOp":case"ltOp":case"leOp":case"gtOp":case"geOp":case"isOp":case"nodeBeforeOp":case"nodeAfterOp":e:switch(r){case"eqOp":case"neOp":case"ltOp":case"leOp":case"gtOp":case"geOp":case"isOp":e=Gd(e,r,t,n);break e;case"equalOp":case"notEqualOp":case"lessThanOrEqualOp":case"lessThanOp":case"greaterThanOrEqualOp":case"greaterThanOp":const a=wa(va(e,["firstOperand","*"]),"type"),o=wa(va(e,["secondOperand","*"]),"type");e=a&&o?3===a.g&&3===o.g?Gd(e,Md[r],t,n):3===a.g?$d(e,"firstOperand","secondOperand",Md[r],t,n):3===o.g?$d(e,"secondOperand","firstOperand",Ud[Md[r]],t,n):Td("General comparison for sequences is not implemented"):Td("types of compare are not known");break e;default:e=Td(`Unsupported compare type: ${r}`)}return[e,null];case"functionCallExpr":return[_d(e,t,n),null];default:return[Td(`Unsupported: the base expression '${r}'.`),null]}}function lm(e,t,n){return Bd(t,(t=>{var r=e.o.get(t);return r||(r=Nd(r=cm(e,n),t.ta,[...t.H,`const ${r} = ${t.code};`]),e.o.set(t,r),e.o.set(r,r)),r}))}function cm(e,t="v"){const n=e.v.get(t)||0;return e.v.set(t,n+1),`${t}${n}`}function um(e,t){return t=Nd(t,{type:0},[]),e.o.set(t,t),t}function pm(e){const t=xa(e,"*");if("pathExpr"===e[0])return!0;for(const e of t)if(pm(e))return!0;return!1}class hm extends Error{constructor(e,t,n){var r=e.stack;r&&(r.includes(e.message)&&(r=r.substr(r.indexOf(e.message)+e.message.length).trim()),(r=r.split("\n")).splice(10),r=r.map((e=>e.startsWith(" ")||e.startsWith("\t")?e:` ${e}`)),r=r.join("\n")),super(`Custom XPath function Q{${n}}${t} raised:\n${e.message}\n${r}`)}}function dm(e,t,n){return 0===t.g?e.G()?null:md(e.first(),n).next(0).value:2===t.g||1===t.g?e.O().map((e=>{if(T(e.type,47))throw Error("Cannot pass attribute nodes to custom functions");return md(e,n).next(0).value})):md(e.first(),n).next(0).value}var mm={callFunction(e,t,n,r,a){const o=Yr(t,n,r.length);if(!o)throw Error("function not found for codegen function call");t=new ze({M:null,Aa:0,sa:$.empty(),qa:{}});const s=new oe(e);return e=new Je(!1,!1,s,null,null,a?a.currentContext:null,null),r=o.callFunction(t,e,null,...r.map(((e,t)=>He(0,e,o.j[t])))),dm(r,{type:59,g:0},e)},errXPDY0002:We};const fm={"http://www.w3.org/2005/XQueryX":"xqx","http://www.w3.org/2007/xquery-update-10":"xquf","http://fontoxml.com/fontoxpath":"x"};function gm(e,t,n,r,a){if("string"==typeof n)return 0===n.length?null:t.createTextNode(n);if(!Array.isArray(n))throw new TypeError("JsonML element should be an array or string");var o=function(e,t){switch(e){case"copySource":case"insertAfter":case"insertAsFirst":case"insertAsLast":case"insertBefore":case"insertInto":case"modifyExpr":case"newNameExpr":case"replacementExpr":case"replaceValue":case"returnExpr":case"sourceExpr":case"targetExpr":case"transformCopies":case"transformCopy":return{localName:e,kb:t||"http://www.w3.org/2005/XQueryX"};case"deleteExpr":case"insertExpr":case"renameExpr":case"replaceExpr":case"transformExpr":return{localName:e,kb:"http://www.w3.org/2007/xquery-update-10"};case"x:stackTrace":return{localName:"stackTrace",kb:"http://fontoxml.com/fontoxpath"};default:return{localName:e,kb:"http://www.w3.org/2005/XQueryX"}}}(n[0],r);r=o.localName,o=o.kb;const s=t.createElementNS(o,fm[o]+":"+r),i=n[1];var l=1;if("object"==typeof i&&!Array.isArray(i)){if(null!==i)for(var c of Object.keys(i))null!==(l=i[c])&&("type"===c?void 0!==l&&e.setAttributeNS(s,o,"fontoxpath:"+c,O(l)):("start"!==c&&"end"!==c||"stackTrace"!==r||(l=JSON.stringify(l)),a&&"prefix"===c&&""===l||e.setAttributeNS(s,o,fm[o]+":"+c,l)));l=2}for(let r=l,i=n.length;r<i;++r)c=gm(e,t,n[r],o,a),null!==c&&e.insertBefore(s,c,null);return s}const ym=new Map;function wm(e){var t;e:{if(t=pi.get(e))for(const e of Object.keys(t))if(t[e]&&t[e].length){t=t[e][0].h;break e}t=null}if(t)return t;if(ym.has(e))return ym.get(e);if(null===(t=va(t="string"==typeof e?Xh(e,{Z:!1}):mi(e),["mainModule","queryBody","*"])))throw Error("Library modules do not have a specificity");return t=ui(t,{ra:!1,Z:!1}),ym.set(e,t),t}var vm=new q;return void 0!==n&&(n.compareSpecificity=function(e,t){return pr(wm(e).o,wm(t).o)},n.compileXPathToJavaScript=function(e,t,n){if(n=n||{},t=t||0,"string"==typeof e){e=vi(e);var r={Z:"XQuery3.1"===n.language||"XQueryUpdate3.1"===n.language,debug:!1};try{var a=Xh(e,r)}catch(t){_r(e,t)}}else a=mi(e);if(!(e=ga(a,"mainModule")))return Td("Unsupported: XQuery Library modules are not supported.");if(ga(e,"prolog"))return Td("Unsupported: XQuery Prologs are not supported.");if(r=void 0===n.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":n.defaultFunctionNamespaceURI,e=new class{constructor(e,t){this.o=new Map,this.v=new Map,this.$=e,this.D=t,this.h=im}}(n.namespaceResolver||cd(null),r),Ga(a,n=new Ya(new fa(new Qr(e.$,{},r,n.functionNameResolver||ud("http://www.w3.org/2005/xpath-functions"))))),n=ga(a,"mainModule"))if(ga(n,"prolog"))e=Td("Unsupported: XQuery.");else{var o=va(n,["queryBody","*"]);n=um(e,"contextItem"),[r]=e.h(o,n,e);e:switch(o=wa(o,"type"),t){case 9:e=Dd(t=Cd(r,n,e),o,e);break e;case 7:e=function(e,t,n,r){return Bd(e,(e=>{switch(e.ta.type){case 1:return Bd(lm(r,e,"nodes"),(e=>Bd(lm(r,n,"contextItem"),(t=>Nd(`Array.from(${e.code}(${t.code}))`,{type:0},[...e.H,...t.H])))));case 0:return Bd(lm(r,Dd(e,t,r),"node"),(e=>Nd(`(${e.code} === null ? [] : [${e.code}])`,{type:0},e.H)));default:return Td("Unsupported code type to evaluate to nodes")}}))}(r,o,n,e);break e;case 3:e=Sd(r,o,n,e);break e;case 2:e=Fd(r,o,n,e);break e;default:e=Td(`Unsupported: the return type '${t}'.`)}e.isAstAccepted&&(e=`\n\t\t${e.H.join("\n")}\n\t\treturn ${e.code};`,t="\n\treturn (contextItem, domFacade, runtimeLib, options) => {\n\t\tconst {\n\t\t\terrXPDY0002,\n\t\t} = runtimeLib;",pm(a)&&(t+='\n\t\tif (!contextItem) {\n\t\t\tthrow errXPDY0002("Context is needed to evaluate the given path expression.");\n\t\t}\n\n\t\tif (!contextItem.nodeType) {\n\t\t\tthrow new Error("Context item must be subtype of node().");\n\t\t}\n\t\t'),e={code:t+(e+"}\n//# sourceURL=generated.js"),isAstAccepted:!0})}else e=Td("Unsupported: Can not execute a library module.");return e},n.domFacade=vm,n.evaluateXPath=bd,n.evaluateXPathToArray=function(e,t,n,r,a){return bd(e,t,n,r,bd.Ib,a)},n.evaluateXPathToAsyncIterator=Ad,n.evaluateXPathToBoolean=function(e,t,n,r,a){return bd(e,t,n,r,bd.BOOLEAN_TYPE,a)},n.evaluateXPathToFirstNode=function(e,t,n,r,a){return bd(e,t,n,r,bd.Lb,a)},n.evaluateXPathToMap=function(e,t,n,r,a){return bd(e,t,n,r,bd.Ob,a)},n.evaluateXPathToNodes=function(e,t,n,r,a){return bd(e,t,n,r,bd.Qb,a)},n.evaluateXPathToNumber=function(e,t,n,r,a){return bd(e,t,n,r,bd.NUMBER_TYPE,a)},n.evaluateXPathToNumbers=function(e,t,n,r,a){return bd(e,t,n,r,bd.Rb,a)},n.evaluateXPathToString=function(e,t,n,r,a){return bd(e,t,n,r,bd.STRING_TYPE,a)},n.evaluateXPathToStrings=function(e,t,n,r,a){return bd(e,t,n,r,bd.Sb,a)},n.evaluateUpdatingExpression=async function(e,t,n,r,a){let o,s,i;a=a||{},wi();try{const i=pd(e,t,n||null,r||{},a||{},{ra:!0,Z:!0,debug:!!a.debug,Ga:!!a.disableCache});var l=i.rb;o=i.sb,s=i.ba}catch(t){_r(e,t)}if(!s.J){for(l=[],e=Ad(e,t,n,r,Object.assign(Object.assign({},a),{language:"XQueryUpdate3.1"})),t=await e.next();!t.done;t=await e.next())l.push(t.value);return Promise.resolve({pendingUpdateList:[],xdmValue:l})}try{i=s.s(l,o).next(0)}catch(t){_r(e,t)}return Ed(i.value,e,a.returnType,o)},n.evaluateUpdatingExpressionSync=function(e,t,n,r,a){let o,s,i,l;a=a||{},wi();try{const l=pd(e,t,n||null,r||{},a||{},{ra:!0,Z:!0,debug:!!a.debug,Ga:!!a.disableCache});o=l.rb,s=l.sb,i=l.ba}catch(t){_r(e,t)}if(!i.J)return{pendingUpdateList:[],xdmValue:bd(e,t,n,r,a.i,Object.assign(Object.assign({},a),{language:bd.Vb}))};try{l=i.s(o,s).next(0)}catch(t){_r(e,t)}return Ed(l.value,e,a.returnType,s)},n.executeJavaScriptCompiledXPath=(e,t,n,r)=>(n=n||new q,e()(null!=t?t:null,n,mm,r)),n.executePendingUpdateList=function(e,t,n,r){t=new oe(t||new q),r=r?new Y(r):V,n=n?n=new id(n):null,e=e.map(_s),nr(e,t,n,r)},n.getBucketForSelector=function(e){return wm(e).D()},n.getBucketsForNode=X,n.precompileXPath=function(e){return Promise.resolve(e)},n.registerXQueryModule=function(e,t={debug:!1}){if(Ua(t=Xh(e,{Z:!0,debug:t.debug}),new Ya),!(t=ga(t,"libraryModule")))throw Error("XQuery module must be declared in a library module.");var n=ga(t,"moduleDecl"),r=ga(n,"uri");const a=ya(r);if(r=ya(n=ga(n,"prefix")),pa(n=new fa(new Qr((()=>null),Object.create(null),"http://www.w3.org/2005/xpath-functions",ud("http://www.w3.org/2005/xpath-functions"))),r,a),null!==(t=ga(t,"prolog"))){let r;try{r=Vh(t,n,!0,e)}catch(t){_r(e,t)}r.Ha.forEach((({namespaceURI:e})=>{if(a!==e)throw Error("XQST0048: Functions and variables declared in a module must reside in the module target namespace.")})),gi(a,r)}else gi(a,{Ha:[],Ta:[],oa:null,source:e});return a},n.registerCustomXPathFunction=function(e,t,n,r){const{namespaceURI:a,localName:o}=function(e){if("object"==typeof e)return e;if(2!==(e=e.split(":")).length)throw Error("Do not register custom functions in the default function namespace");const[t,n]=e;if(!(e=Jr[t])){if(e=`generated_namespace_uri_${t}`,Jr[t])throw Error("Prefix already registered: Do not register the same prefix twice.");Jr[t]=e}return{localName:n,namespaceURI:e}}(e);if(!a)throw ta();const s=t.map((e=>D(e))),i=D(n);zr(a,o,s,i,(function(e,t,n){var l=Array.from(arguments);l.splice(0,3),l=l.map(((e,n)=>dm(e,s[n],t)));const c={currentContext:t.o,domFacade:t.h.h};let u;try{u=r.apply(void 0,[c,...l])}catch(e){throw new hm(e,o,a)}return u&&"object"==typeof u&&Object.getOwnPropertySymbols(u).includes(ld)?$.create(u.xb):He(t.h,u,i)}))},n.parseScript=function(e,t,n,r=V){let a;e=vi(e);try{a=Xh(e,{Z:"XQuery3.1"===t.language||"XQueryUpdate3.1"===t.language,debug:t.debug})}catch(t){_r(e,t)}var o=new Qr(t.namespaceResolver||(()=>null),{},void 0===t.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":t.defaultFunctionNamespaceURI,t.functionNameResolver||(()=>null));o=new fa(o);var s=ga(a,["mainModule","libraryModule"]),i=ga(s,"moduleDecl");if(i){pa(o,ya(ga(i,"prefix")),i=ya(ga(i,"uri")))}return(s=ga(s,"prolog"))&&Vh(s,o,!1,e),!1!==t.annotateAst&&Ua(a,new Ya(o)),o=new q,t=gm(r,n,a,null,!1===t.kc),r.insertBefore(t,n.createComment(e),o.getFirstChild(t)),t},n.profiler=vd,n.createTypedValueFactory=function(e){return(t,n)=>(t=Le(new oe(null===n?new q:n),t,D(e)),{[ld]:!0,xb:t})},n.finalizeModuleRegistration=wi,n.Language={XPATH_3_1_LANGUAGE:"XPath3.1",XQUERY_3_1_LANGUAGE:"XQuery3.1",XQUERY_UPDATE_3_1_LANGUAGE:"XQueryUpdate3.1"},n.ReturnType=fd),n}.call("undefined"==typeof window?void 0:window,Ae,He);Pe.compareSpecificity,Pe.compileXPathToJavaScript;const je=Pe.createTypedValueFactory;Pe.domFacade,Pe.evaluateUpdatingExpression,Pe.evaluateUpdatingExpressionSync;const _e=Pe.evaluateXPath;Pe.evaluateXPathToArray,Pe.evaluateXPathToAsyncIterator;const Xe=Pe.evaluateXPathToBoolean,qe=Pe.evaluateXPathToFirstNode;Pe.evaluateXPathToMap;const Ve=Pe.evaluateXPathToNodes,Ye=Pe.evaluateXPathToNumber;Pe.evaluateXPathToNumbers;const ze=Pe.evaluateXPathToString,Je=Pe.evaluateXPathToStrings;Pe.executeJavaScriptCompiledXPath,Pe.executePendingUpdateList,Pe.finalizeModuleRegistration,Pe.getBucketForSelector;const Qe=Pe.getBucketsForNode;Pe.Language;const Ke=Pe.parseScript;Pe.precompileXPath,Pe.profiler;const We=Pe.registerCustomXPathFunction,Ze=Pe.registerXQueryModule;Pe.ReturnType;class et{constructor(e){this._onNodeTouched=e}getAllAttributes(e){return Array.from(e.attributes)}getAttribute(e,t){return e.getAttribute(t)}getChildNodes(e,t){const n=Array.from(e.childNodes).filter((e=>!t||Qe(e).includes(t)));return n.forEach((e=>this._onNodeTouched(e))),n}getData(e){return e.nodeType===Node.ATTRIBUTE_NODE?(this._onNodeTouched(e),e.value):(this._onNodeTouched(e.parentNode),e.data)}getFirstChild(e,t){for(const n of e.childNodes)if(!t||Qe(n).includes(t))return this._onNodeTouched(n),n;return null}getLastChild(e,t){const n=e.getChildNodes().filter((e=>!t||Qe(e).includes(t))),r=n[n.length-1];return r||null}getNextSibling(e,t){for(let n=e.nextSibling;n;n=n.nextSibling)if(!t||Qe(n).includes(t))return this._onNodeTouched(n),n;return null}getParentNode(e){return e.parentNode}getPreviousSibling(e,t){for(let{previousSibling:n}=e;n;n=n.previousSibling)if(!t||Qe(n).includes(t))return n;return null}}class tt{static contains(e,t){for(;t;){if(t===e)return!0;t=t.nodeType===Node.DOCUMENT_FRAGMENT_NODE?t.host:t.parentNode}return!1}static getClosest(e,t){for(;t&&!t.matches||!t.matches(e);)if(t.nodeType!==Node.DOCUMENT_FRAGMENT_NODE)if(t.nodeType!==Node.ATTRIBUTE_NODE){if(t.nodeType===Node.TEXT_NODE&&(t=t.parentNode),t.matches("fx-fore"))return null;if(!(t=t.parentNode))return null}else t=t.ownerElement;else t=t.host;return t}static getParentBindingElement(e){return!e.parentNode||e.parentNode.nodeType===Node.DOCUMENT_NODE&&e.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE?null:e.parentNode.closest("[ref]")}static isAbsolutePath(e){return null!=e&&(e.startsWith("/")||e.startsWith("instance("))}static isSelfReference(e){return"."===e||"./text()"===e||"text()"===e||""===e||null===e}static getInstanceId(e){if(!e)return"default";if(e.startsWith("instance()"))return"default";if(e.startsWith("instance(")){const t=e.substring(e.indexOf("(")+1);return t.substring(1,t.indexOf(")")-1)}return null}static resolveInstance(e,t){let n=tt.getInstanceId(t);if(n||(n=tt.getInstanceId(e.getAttribute("ref"))),null!==n)return n;const r=tt.getParentBindingElement(e);return r?this.resolveInstance(r,t):"default"}static getDocPath(e){const t=ze("path()",e),n=tt.shortenPath(t);return n.startsWith("/")?`${n}`:`/${n}`}static getPath(e,t){const n=ze("path()",e),r=tt.shortenPath(n);return r.startsWith("/")?`$${t}${r}`:`$${t}/${r}`}static shortenPath(e){const t=e.replaceAll(/(Q{(.*?)\})/g,""),n=t.substring(1,t.length);return n.substring(n.indexOf("/"),t.length)}static getBasePath(e){return e.split(":")[0]}}function nt(e,t,n,r){const a={};return function(o){if(a[o])return;const s={},i=[],l=[];for(l.push({node:o,processed:!1});l.length>0;){const o=l[l.length-1],{processed:c}=o,{node:u}=o;if(c)l.pop(),i.pop(),s[u]=!1,a[u]=!0,t&&0!==e[u].length||n.push(u);else{if(a[u]){l.pop();continue}if(s[u]){if(r){l.pop();continue}throw i.push(u),window.dispatchEvent(new CustomEvent("compute-exception",{composed:!1,bubbles:!0,detail:{path:i,message:"cyclic graph"}})),new Error(`Cyclic at ${i}`)}s[u]=!0,i.push(u);const t=e[u];for(let e=t.length-1;e>=0;e-=1)l.push({node:t[e],processed:!1});o.processed=!0}}}}function rt(e){this.nodes={},this.outgoingEdges={},this.incomingEdges={},this.circular=e&&!!e.circular}function at(e){const t=(new DOMParser).parseFromString(e,"application/xml"),n=(new DOMParser).parseFromString(['<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">',' <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>',' <xsl:strip-space elements="*"/>',' <xsl:template match="text()">',' <xsl:value-of select="normalize-space(.)"/>'," </xsl:template>",' <xsl:template match="node()|@*">'," <xsl:copy>",' <xsl:apply-templates select="node()|@*"/>'," </xsl:copy>"," </xsl:template>","</xsl:stylesheet>"].join("\n"),"application/xml"),r=new XSLTProcessor;r.importStylesheet(n);const a=r.transformToDocument(t);return(new XMLSerializer).serializeToString(a)}rt.prototype={size(){return Object.keys(this.nodes).length},addNode(e,t){this.hasNode(e)||(this.nodes[e]=2===arguments.length?t:e,this.outgoingEdges[e]=[],this.incomingEdges[e]=[])},removeNode(e){this.hasNode(e)&&(delete this.nodes[e],delete this.outgoingEdges[e],delete this.incomingEdges[e],[this.incomingEdges,this.outgoingEdges].forEach((t=>{Object.keys(t).forEach((n=>{const r=t[n].indexOf(e);r>=0&&t[n].splice(r,1)}),this)})))},hasNode(e){return Object.prototype.hasOwnProperty.call(this.nodes,e)},getNodeData(e){if(this.hasNode(e))return this.nodes[e];throw new Error(`Node does not exist: ${e}`)},setNodeData(e,t){if(!this.hasNode(e))throw new Error(`Node does not exist: ${e}`);this.nodes[e]=t},addDependency(e,t){if(!this.hasNode(e))throw new Error(`Node does not exist: ${e}`);if(!this.hasNode(t))throw new Error(`Node does not exist: ${t}`);return-1===this.outgoingEdges[e].indexOf(t)&&this.outgoingEdges[e].push(t),-1===this.incomingEdges[t].indexOf(e)&&this.incomingEdges[t].push(e),!0},removeDependency(e,t){let n;this.hasNode(e)&&(n=this.outgoingEdges[e].indexOf(t),n>=0&&this.outgoingEdges[e].splice(n,1)),this.hasNode(t)&&(n=this.incomingEdges[t].indexOf(e),n>=0&&this.incomingEdges[t].splice(n,1))},clone(){const e=this,t=new rt;return Object.keys(e.nodes).forEach((n=>{t.nodes[n]=e.nodes[n],t.outgoingEdges[n]=e.outgoingEdges[n].slice(0),t.incomingEdges[n]=e.incomingEdges[n].slice(0)})),t},directDependenciesOf(e){if(this.hasNode(e))return this.outgoingEdges[e].slice(0);throw new Error(`Node does not exist: ${e}`)},directDependantsOf(e){if(this.hasNode(e))return this.incomingEdges[e].slice(0);throw new Error(`Node does not exist: ${e}`)},dependenciesOf(e,t){if(this.hasNode(e)){const n=[];nt(this.outgoingEdges,t,n,this.circular)(e);const r=n.indexOf(e);return r>=0&&n.splice(r,1),n}throw new Error(`Node does not exist: ${e}`)},dependantsOf(e,t){if(this.hasNode(e)){const n=[];nt(this.incomingEdges,t,n,this.circular)(e);const r=n.indexOf(e);return r>=0&&n.splice(r,1),n}throw new Error(`Node does not exist: ${e}`)},entryNodes(){const e=this;return Object.keys(this.nodes).filter((t=>0===e.incomingEdges[t].length))},overallOrder(e){const t=this,n=[],r=Object.keys(this.nodes);if(0===r.length)return n;if(!this.circular){const e=nt(this.outgoingEdges,!1,[],this.circular);r.forEach((t=>{e(t)}))}const a=nt(this.outgoingEdges,e,n,this.circular);return r.filter((e=>0===t.incomingEdges[e].length)).forEach((e=>{a(e)})),this.circular&&r.filter((e=>-1===n.indexOf(e))).forEach((e=>a(e))),n}},rt.prototype.directDependentsOf=rt.prototype.directDependantsOf,rt.prototype.dependentsOf=rt.prototype.dependantsOf;const ot="http://www.w3.org/2002/xforms",st=new Map,it=[];function lt(e,t,n){return st.has(e)?st.get(e).set(t,n):st.set(e,new Map)}const ct=e=>{if(!e)return"http://www.w3.org/1999/xhtml"};function ut(e,t,n=null){t.nodeType===Node.TEXT_NODE&&(t=t.parentNode),t.nodeType===Node.ATTRIBUTE_NODE&&(t=t.ownerElement),t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&(t=t.parentNode.host);const r=("fx-fore"===t.localName?t:t.closest("fx-fore")).querySelectorAll(`[id='${e}']`);if(1===r.length){const e=r[0];return n&&e.localName!==n?null:e}const a=Ve("outermost(ancestor-or-self::fx-fore[1]/(descendant::fx-fore|descendant::*[@id = $id]))[not(self::fx-fore)]",t,null,{id:e},{namespaceResolver:ct});if(0===a.length)return null;if(1===a.length&&Xe("(ancestor::fx-fore | ancestor::fx-repeat)[last()]/self::fx-fore",a[0],null,null,{namespaceResolver:ct})){const e=a[0];return n&&e.localName!==n?null:e}for(const e of Ve("ancestor::fx-repeatitem => reverse()",t,null,null,{namespaceResolver:ct})){const t=a.filter((t=>tt.contains(e,t)));switch(t.length){case 0:break;case 1:{const e=t[0];return n&&e.localName!==n?null:e}default:{const e=t.find((e=>Ve("every $ancestor of ancestor::fx-repeatitem satisfies $ancestor is $ancestor/../child::fx-repeatitem[../@repeat-index]",e,null,{})));return e?n&&e.localName!==n?null:e:null}}}return null}const pt=(new DOMParser).parseFromString("<xml />","text/xml"),ht=new Map;function dt(e,t){const n=function(e,t){return st.has(e)&&st.get(e).get(t)||null}(e,t);if(n)return n;let r=function(e){if(!e.includes("instance"))return[];if(ht.has(e))return ht.get(e);const t=Ke(e,{},pt),n=Je('descendant::xqx:functionCallExpr\n\t\t\t\t[xqx:functionName = "instance"]\n\t\t\t\t/xqx:arguments\n\t\t\t\t/xqx:stringConstantExpr\n\t\t\t\t/xqx:value',t,null,{},{namespaceResolver:e=>"xqx"===e?"http://www.w3.org/2005/XQueryX":void 0});return ht.set(e,n),n}(e);if(0===r.length){const n=t.parentNode&&t.parentNode.nodeType===t.ELEMENT&&t.parentNode.closest("[ref]");if(n){const r=dt(n.getAttribute("ref"),n);return lt(e,t,r),r}r=["default"]}if(1===r.length){let n;if("default"===r[0]){const e=qe("ancestor-or-self::fx-fore[1]",t,null,null,{namespaceResolver:ct});n=e&&e.querySelector("fx-instance")}else n=ut(r[0],t,"fx-instance");if(n&&n.hasAttribute("xpath-default-namespace")){const r=n.getAttribute("xpath-default-namespace"),a=e=>{if(!e)return r};return lt(e,t,a),a}}r.length>1&&console.warn(`More than one instance is used in the query "${e}". The default namespace resolving will be used`);const a=ze("ancestor-or-self::*/@xpath-default-namespace[last()]",t)||"",o=function(e){return""===e?a:ze('ancestor-or-self::*/@*[name() = "xmlns:" || $prefix][last()]',t,null,{prefix:e})};return lt(e,t,o),o}function mt(e,t,n){return(t&&t.ownerDocument||t)===window.document?ct:dt(e,n)}function ft({prefix:e,localName:t},n){switch(t){case"context":case"base64encode":case"boolean-from-string":case"current":case"depends":case"event":case"fore-attr":case"index":case"instance":case"log":case"parse":case"local-date":case"local-dateTime":case"logtree":case"uri":case"uri-fragment":case"uri-host":case"uri-param":case"uri-path":case"uri-port":case"uri-query":case"uri-scheme":case"uri-scheme-specific-part":return{namespaceURI:ot,localName:t};default:return""===e&&it.includes(t)?{namespaceURI:"http://www.w3.org/2005/xquery-local-functions",localName:t}:"fn"===e||""===e?{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:t}:"local"===e?{namespaceURI:"http://www.w3.org/2005/xquery-local-functions",localName:t}:null}}function gt(e){let t=e;for(;t&&!("inScopeVariables"in t);)t=t.parentNode;if(!t)return{};const n={};if(t.inScopeVariables)for(const e of t.inScopeVariables.keys()){const r=t.inScopeVariables.get(e);r&&(r.nodeType?n[e]=r.value:n[e]=r)}return n}function yt(e,t,n,r={},a={}){try{const o=mt(e,t,n),s=gt(n);return _e(e,t,null,{...s,...r},_e.ALL_RESULTS_TYPE,{debug:!0,currentContext:{formElement:n,variables:r},moduleImports:{xf:ot},functionNameResolver:ft,namespaceResolver:o,language:a.language||yt.XPATH_3_1})}catch(t){return n.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,detail:{origin:n,message:`Expression '${e}' failed`,expr:e,level:"Error"}})),!1}}function wt(e,t,n){try{const r=mt(e,t,n),a=gt(n);return qe(e,t,null,a,{defaultFunctionNamespaceURI:ot,moduleImports:{xf:ot},currentContext:{formElement:n},functionNameResolver:ft,namespaceResolver:r})}catch(t){n.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,detail:{origin:n,message:`Expression '${e}' failed`,expr:e,level:"Error"}}))}}function vt(e,t,n){try{const r=mt(e,t,n),a=gt(n);return Ve(e,t,null,a,{currentContext:{formElement:n},functionNameResolver:ft,moduleImports:{xf:ot},namespaceResolver:r})}catch(t){n.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,detail:{origin:n,message:`Expression '${e}' failed`,expr:e,level:"Error"}}))}}function xt(e,t,n){try{const r=mt(e,t,n),a=gt(n);return Xe(e,t,null,a,{currentContext:{formElement:n},functionNameResolver:ft,moduleImports:{xf:ot},namespaceResolver:r})}catch(t){n.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,detail:{origin:n,message:`Expression '${e}' failed`,expr:e,level:"Error"}}))}}function bt(e,t,n,r=null,a=n){try{const a=mt(e,t,n),o=gt(n);return ze(e,t,r,o,{currentContext:{formElement:n},functionNameResolver:ft,moduleImports:{xf:ot},namespaceResolver:a})}catch(t){n.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,detail:{origin:n,message:`Expression '${e}' failed`,expr:e,level:"Error"}}))}}function At(e,t,n,r=null,a=n){try{const a=mt(e,t,n),o=gt(n);return Ye(e,t,r,o,{currentContext:{formElement:n},functionNameResolver:ft,moduleImports:{xf:ot},namespaceResolver:a})}catch(t){n.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,detail:{origin:n,message:`Expression '${e}' failed`,expr:e,level:"Error"}}))}}const Et=(e,t)=>{const n=e.currentContext.formElement;let r=null;if(r=t?ut(t,n):tt.getParentBindingElement(n),r){if("FX-REPEAT"===r.nodeName){const{nodeset:e}=r;for(let t=n;t;t=t.parentNode)if(t.parentNode===r){return e[Array.from(t.parentNode.children).indexOf(t)]}}return r.nodeset}return n.getInScopeContext()};function Nt(e,t){if(t&&t.nodeType===Node.ELEMENT_NODE&&t.children){const n=document.createElement("details");n.setAttribute("data-path",t.nodeName);const r=document.createElement("summary");let a,o=` <${t.nodeName}`;Array.from(t.attributes).forEach((e=>{o+=` ${e.nodeName}="${e.nodeValue}"`})),t.firstChild&&t.firstChild.nodeType===Node.TEXT_NODE&&""!==t.firstChild.data.trim()?(a=t.firstChild.nodeValue,o+=`>${a}</${t.nodeName}>`):o+=">",r.textContent=o,n.appendChild(r),0!==t.childElementCount?n.setAttribute("open","open"):r.setAttribute("style","list-style:none;"),e.appendChild(n),Array.from(t.children).forEach((e=>{Nt(n,e)}))}}We({namespaceURI:ot,localName:"context"},[],"item()?",Et),We({namespaceURI:ot,localName:"context"},["xs:string"],"item()?",Et),We({namespaceURI:ot,localName:"current"},["xs:string"],"item()?",((e,t)=>(e.currentContext.formElement,null))),We({namespaceURI:ot,localName:"element"},["xs:string"],"item()?",((e,t)=>{e.currentContext.formElement;return document.createElement(t)})),We({namespaceURI:ot,localName:"log"},["xs:string?"],"xs:string?",((e,t)=>{const{formElement:n}=e.currentContext,r=ut(t,n,"fx-instance");if(r){if("json"!==r.getAttribute("type")){return at((new XMLSerializer).serializeToString(r.getDefaultContext()))}console.warn("log() does not work for JSON yet")}return null})),We({namespaceURI:ot,localName:"fore-attr"},["xs:string?"],"xs:string?",((e,t)=>{const{formElement:n}=e.currentContext;let r=n;n.nodeType===Node.TEXT_NODE&&(r=n.parentNode);const a=r.closest("fx-fore");return a.hasAttribute(t)?a.getAttribute(t):null})),We({namespaceURI:ot,localName:"parse"},["xs:string?"],"element()?",((e,t)=>{const n=(new DOMParser).parseFromString(t,"application/xml");return console.log("parse",n),n.firstElementChild})),We({namespaceURI:ot,localName:"logtree"},["xs:string?"],"element()?",((e,t)=>{const{formElement:n}=e.currentContext,r=ut(t,n,"fx-instance");if(r){const t=document.createElement("div");t.setAttribute("class","logtree");const n=e.currentContext.formElement,a=n.querySelector(".logtree");a&&a.parentNode.removeChild(a);const o=Nt(t,r.getDefaultContext());o&&n.appendChild(o)}return null}));const Tt=(e,t)=>{const n=qe("ancestor-or-self::fx-fore[1]",e.currentContext.formElement,null,null,{namespaceResolver:ct});let r=null;null===t||"default"===t?r=n.getModel().getDefaultInstance():(r=n.getModel().getInstance(t),r||document.querySelector("fx-fore").dispatchEvent(new CustomEvent("error",{composed:!0,bubbles:!0,detail:{origin:"functions",message:`Instance not found '${localName}'`,level:"Error"}})));const a=r.getDefaultContext();return a||null};function Bt(e,t){const n=t.split(".");return 1==n.length?e[n[0]]:Bt(e[n[0]],n.slice(1).join("."))}function It(e){return e.closest("fx-fore")}function Ct(e,t){const n=tt.getClosest("[ref]",e),r=tt.getClosest("fx-fore",e),a=function(e){return It(e).getModel()}(e);if(null!==n){return r===n.closest("fx-fore")?n.nodeset:a.getDefaultInstance().getDefaultContext()}if(tt.isAbsolutePath(t)){const e=tt.getInstanceId(t);return e?a.getInstance(e).getDefaultContext():a.getDefaultInstance().getDefaultContext()}return a.getDefaultInstance().getDefaultContext()}function St(e,t){const n=function(e){return e&&e.nodeType&&e.nodeType===Node.ATTRIBUTE_NODE?e.ownerElement:e.nodeType===Node.ELEMENT_NODE?e:e.parentNode}(e);if("FX-FORE"===n.nodeName)return n.getModel().getDefaultInstance().getDefaultContext();const r=tt.getClosest("[ref]",n.parentNode);if(r&&("FX-GROUP"===r.nodeName||"FX-CONTROL"===r.nodeName))return r.nodeset;const a=tt.getClosest("fx-repeatitem",n);if(a)return"context"===e.nodeName?wt(e.nodeValue,a.nodeset,It(n)):a.nodeset;const o=n.closest(".fx-repeatitem");if(o){const e=o.parentNode,t=Array.from(e.children).indexOf(o);return tt.getClosest("fx-repeat-attributes",n).nodeset[t]}if(n.hasAttribute("context")){const e=Ct(n.parentNode,t);return wt(n.getAttribute("context"),e,It(n))}if(e.nodeType===Node.ATTRIBUTE_NODE&&"context"===e.nodeName){const r=Ct(e.ownerElement.parentNode,t);return wt(e.ownerElement.getAttribute("context"),r,It(n))}if(e.nodeType===Node.ATTRIBUTE_NODE&&"ref"===e.nodeName){if(e.ownerElement.hasAttribute("context")){const r=Ct(e.ownerElement.parentNode,t);return wt(e.ownerElement.getAttribute("context"),r,It(n))}return Ct(n.parentNode,t)}return Ct(n,t)}We({namespaceURI:ot,localName:"index"},["xs:string?"],"xs:integer?",((e,t)=>{const{formElement:n}=e.currentContext;if(null===t)return 1;const r=ut(t,n,"fx-repeat");return r?r.getAttribute("index"):Number(1)})),We({namespaceURI:ot,localName:"instance"},[],"item()?",(e=>Tt(e,null))),We({namespaceURI:ot,localName:"instance"},["xs:string?"],"item()?",Tt),We({namespaceURI:ot,localName:"depends"},["node()*"],"item()?",((e,t)=>t[0])),We({namespaceURI:ot,localName:"event"},["xs:string?"],"item()?",((e,t)=>{if(!t)return null;for(let n=e.currentContext.formElement;n;n=n.parentNode)if(n.currentEvent)return n.currentEvent.detail&&"object"==typeof n.currentEvent.detail&&t in n.currentEvent.detail?n.currentEvent.detail[t]:t.includes(".")?Bt(n.currentEvent,t):n.currentEvent[t]||null;return null})),Ze(`\n module namespace xf="${ot}";\n\n declare %public function xf:boolean-from-string($str as xs:string) as xs:boolean {\n lower-case($str) = "true" or $str = "1"\n };\n`),We({namespaceURI:ot,localName:"base64encode"},["xs:string?"],"xs:string?",((e,t)=>btoa(t))),We({namespaceURI:ot,localName:"local-date"},[],"xs:string?",((e,t)=>(new Date).toLocaleDateString())),We({namespaceURI:ot,localName:"local-dateTime"},[],"xs:string?",((e,t)=>(new Date).toLocaleString())),We({namespaceURI:ot,localName:"uri"},[],"xs:string?",((e,t)=>window.location.href)),We({namespaceURI:ot,localName:"uri-fragment"},[],"xs:string?",((e,t)=>window.location.hash)),We({namespaceURI:ot,localName:"uri-host"},[],"xs:string?",((e,t)=>window.location.host)),We({namespaceURI:ot,localName:"uri-query"},[],"xs:string?",((e,t)=>window.location.search)),We({namespaceURI:ot,localName:"uri-path"},[],"xs:string?",((e,t)=>new URL(window.location.href).pathname)),We({namespaceURI:ot,localName:"uri-port"},[],"xs:string?",((e,t)=>window.location.port)),We({namespaceURI:ot,localName:"uri-param"},["xs:string?"],"xs:string?",((e,t)=>{if(!t)return null;const n=window.location.search,r=new URLSearchParams(n).get(t);return r||""})),We({namespaceURI:ot,localName:"uri-scheme"},[],"xs:string?",((e,t)=>new URL(window.location.href).protocol)),We({namespaceURI:ot,localName:"uri-scheme-specific-part"},[],"xs:string?",((e,t)=>{const n=window.location.href;return n.substring(n.indexOf(":")+1,n.length)}));class Ot{static async loadHtml(e){try{const t=await fetch(e,{method:"GET",mode:"cors",credentials:"same-origin",headers:{"Content-Type":"text/html"}}),n=t.headers.get("content-type").toLowerCase();if(n.startsWith("text/html"))return t.text();Ot.dispatch(this,"error",{message:`Response has wrong contentType '${n}'. Should be 'text/html'`,level:"Error"})}catch(t){Ot.dispatch(this,"error",{message:`Html couldn't be loaded from '${e}'`,level:"Error"})}}static async loadForeFromSrc(e,t,n){t||Ot.dispatch(this,"error",{detail:{message:"No 'src' attribute present"}}),await Ot.loadHtml(t).then((r=>{const a=(new DOMParser).parseFromString(r,"text/html").querySelector(n);a||Ot.dispatch(this,"error",{detail:{message:`Fore element not found in '${t}'. Maybe wrapped within 'template' element?`}}),a.setAttribute("from-src",t);const o=e.attributes;return Array.from(o).forEach((e=>{"src"!==e.name&&a.setAttribute(e.name,e.value)})),e.replaceWith(a),a}))}static buildPredicates(e){let t="";return Array.from(e.attributes).forEach((e=>{t+=`[@${e.nodeName}]`})),t}static isWidget(e){if(e?.classList.contains("widget"))return!0;let t=e.parentNode;for(;t&&"FX-CONTROL"!==t.nodeName;){if(t?.classList?.contains("widget"))return!0;t=t.parentNode}return!1}static getDomNodeIndexString(e){const t=[];let n=e;for(;n&&n.parentNode;){const e=n.parentNode;if(e.childNodes&&e.childNodes.length>0){const r=[...e.childNodes].indexOf(n);t.unshift(r)}n=e}return t.join(".")}static getExpression(e){return e.startsWith("{")&&e.endsWith("}")?e.substring(1,e.length-1):e}static getFore(e){return e.nodeType===Node.TEXT_NODE?e.parentNode.closest("fx-fore"):e.closest("fx-fore")}static get ACTION_ELEMENTS(){return["FX-ACTION","FX-DELETE","FX-DISPATCH","FX-HIDE","FX-INSERT","FX-LOAD","FX-MESSAGE","FX-REBUILD","FX-RECALCULATE","FX-REFRESH","FX-RENEW","FX-RELOAD","FX-REPLACE","FX-RESET","FX-RETAIN","FX-RETURN","FX-REVALIDATE","FX-SEND","FX-SETFOCUS","FX-SETINDEX","FX-SETVALUE","FX-SHOW","FX-TOGGLE","FX-UPDATE"]}static createUUID(){const e=[],t="0123456789abcdef";for(let n=0;n<36;n+=1)e[n]=t.substr(Math.floor(16*Math.random()),1);e[14]="4",e[19]=t.substr(3&e[19]|8,1),e[8]=e[13]=e[18]=e[23]="-";return e.join("")}static get XFORMS_NAMESPACE_URI(){return"http://www.w3.org/2002/xforms"}static isActionElement(e){return Ot.ACTION_ELEMENTS.includes(e)}static get UI_ELEMENTS(){return["FX-ALERT","FX-CONTROL","FX-DIALOG","FX-FILENAME","FX-MEDIATYPE","FX-GROUP","FX-HINT","FX-ITEMS","FX-OUTPUT","FX-RANGE","FX-REPEAT","FX-REPEATITEM","FX-REPEAT-ATTRIBUTES","FX-SWITCH","FX-SECRET","FX-SELECT","FX-SUBMIT","FX-TEXTAREA","FX-TRIGGER","FX-UPLOAD","FX-VAR"]}static get MODEL_ELEMENTS(){return["FX-BIND","FX-FUNCTION","FX-MODEL","FX-INSTANCE","FX-SUBMISSION"]}static isUiElement(e){return Ot.UI_ELEMENTS.includes(e),Ot.UI_ELEMENTS.includes(e)}static async refreshChildren(e,t){return new Promise((n=>{const{children:r}=e;r&&Array.from(r).forEach((e=>{"FX-FORE"!==e.nodeName.toUpperCase()?Ot.isUiElement(e.nodeName)&&"function"==typeof e.refresh?e.refresh(t):"FX-MODEL"!==e.nodeName.toUpperCase()&&Ot.refreshChildren(e,t):n("done")})),n("done")}))}static copyDom(e){console.time("convert");const t=(new DOMParser).parseFromString("<fx-fore></fx-fore>","text/html");console.log("copyDom new doc",t),console.log("copyDom new body",t.body),console.log("copyDom new body",t.querySelector("fx-fore"));const n=t.querySelector("fx-fore");return this.convertFromSimple(e,n),n.removeAttribute("convert"),console.log("converted",n),console.timeEnd("convert"),n}static convertFromSimple(e,t){const n=e.childNodes;n&&Array.from(n).forEach((e=>{const n=`FX-${e.nodeName.toUpperCase()}`;if(Ot.MODEL_ELEMENTS.includes(n)||Ot.UI_ELEMENTS.includes(n)||Ot.ACTION_ELEMENTS.includes(n)){const r=t.ownerDocument.createElement(n);console.log("conv",e,r),t.appendChild(r),Ot.copyAttributes(e,r),Ot.convertFromSimple(e,r)}else{if(e.nodeType===Node.TEXT_NODE){const n=t.ownerDocument.createTextNode(e.textContent);t.appendChild(n)}if(e.nodeType===Node.ELEMENT_NODE){const n=t.ownerDocument.createElement(e.nodeName);t.appendChild(n),Ot.copyAttributes(e,t),Ot.convertFromSimple(e,n)}}}))}static copyAttributes(e,t){return Array.from(e.attributes).forEach((e=>{t.setAttribute(e.nodeName,e.nodeValue)}))}static getContentType(e,t){return"application/x-www-form-urlencoded"===t?"application/x-www-form-urlencoded; charset=UTF-8":"xml"===e.type?"application/xml; charset=UTF-8":"json"===e.type?"application/json":(console.warn("content-type unknown ",e.type),null)}static async handleResponse(e){const{status:t}=e;if(t>=400)throw alert(`response status: ${t} - failed to load data for '${this.src}' - stopping.`),new Error(`failed to load data - status: ${t}`);const n=e.headers.get("content-type").toLowerCase();if(n.startsWith("text/html"))return e.text().then((e=>(new DOMParser).parseFromString(e,"text/html")));if(n.startsWith("text/plain")||n.startsWith("text/markdown"))return e.text();if(n.startsWith("application/json"))return e.json();if(n.startsWith("application/xml")){const t=await e.text();return(new DOMParser).parseFromString(t,"application/xml")}return"done"}static evaluateAttributeTemplateExpression(e,t){const n=e.match(/{[^}]*}/g);return n&&n.forEach((n=>{console.log("match ",n);const r=n.substring(1,n.length-1),a=bt(r,St(t,r),t.getOwnerForm()),o=e.replaceAll(n,a);console.log("replacing ",e," with ",o),e=o})),e}static fadeInElement(e){let t=()=>(e.getAnimations&&e.getAnimations().map((e=>e.finish())),t=e.animate({opacity:[0,1]},600),t.finished);return t()}static fadeOutElement(e,t){let n=()=>(e.getAnimations&&e.getAnimations().map((e=>e.finish())),n=e.animate({opacity:[1,0]},t),n.finished);return n()}static async dispatch(e,t,n){if(!tt.contains(e?.ownerDocument,e))return;const r=new CustomEvent(t,{composed:!1,bubbles:!0,detail:n});r.listenerPromises=[],e.dispatchEvent(r),r.listenerPromises.length&&await Promise.all(r.listenerPromises)}static formatXml(e){for(var t=(e=e.replace(/(>)(<)(\/*)/g,"$1\n$2$3").replace(/ *(.*) +\n/g,"$1\n").replace(/(<.+>)(.+\n)/g,"$1\n$2")).split("\n"),n=0;n<t.length;n++){var r=t[n];Boolean(r.match(/<.+\/>/)),Boolean(r.match(/<\/.+>/)),Boolean(r.match(/<[^!].*>/))}}static stringifiedComponent(e){return`<${e.localName} ${Array.from(e.attributes).map((e=>`${e.name}="${e.value}"`)).join(" ")}>…</${e.localName}>`}}Ot.READONLY_DEFAULT=!1,Ot.REQUIRED_DEFAULT=!1,Ot.RELEVANT_DEFAULT=!0,Ot.CONSTRAINT_DEFAULT=!0,Ot.TYPE_DEFAULT="xs:string";class Ft extends HTMLElement{constructor(){super(),this.model=this.parentNode,this.attachShadow({mode:"open"}),this.originalInstance=null,this.partialInstance=null,this.credentials=""}connectedCallback(){this.hasAttribute("src")&&(this.src=this.getAttribute("src")),this.hasAttribute("id")?this.id=this.getAttribute("id"):this.id="default",this.credentials=this.hasAttribute("credentials")?this.getAttribute("credentials"):"same-origin",["same-origin","include","omit"].includes(this.credentials)||console.error(`fx-submission: the value of credentials is not valid. Expected 'same-origin', 'include' or 'omit' but got '${this.credentials}'`,this),this.hasAttribute("type")?this.type=this.getAttribute("type"):(this.type="xml",this.setAttribute("type",this.type));this.shadowRoot.innerHTML="\n <style>\n \n :host {\n display: none;\n }\n :host * {\n display:none;\n }\n ::slotted(*){\n display:none;\n }\n \n </style>\n \n \n ",this.partialInstance={}}async init(){return await this._initInstance(),console.log(`### <<<<< instance ${this.id} loaded >>>>> `),this.dispatchEvent(new CustomEvent("instance-loaded",{composed:!0,bubbles:!0,detail:{instance:this}})),this}reset(){this.instanceData=this.originalInstance.cloneNode(!0)}evalXPath(e){const t=this.parentElement.parentElement;return wt(e,this.getDefaultContext(),t)}getInstanceData(){return this.instanceData||this.createInstanceData(),this.instanceData}setInstanceData(e){e?this._setInitialData(e):this.createInstanceData()}getDefaultContext(){const e=this.getInstanceData();return"xml"===this.type?e.firstElementChild:e}async _initInstance(){if("#querystring"===this.src){const e=new URLSearchParams(location.search),t=(new DOMParser).parseFromString("<data></data>","application/xml"),n=t.firstElementChild;for(const r of e){const e=t.createElement(r[0]);e.appendChild(t.createTextNode(r[1])),n.appendChild(e)}this._setInitialData(t)}else this.src?await this._loadData():0!==this.childNodes.length&&this._useInlineData()}createInstanceData(){if("xml"===this.type){const e=(new DOMParser).parseFromString("<data></data>","application/xml");this.instanceData=e,this.originalInstance=this.instanceData.cloneNode(!0)}"json"===this.type&&(this.instanceData={},this.originalInstance=[...this.instanceData]),"text"===this.type&&(this.instanceData="",this.originalInstance="")}async _loadData(){const e=`${this.src}`;if(e.startsWith("localStore")){const t=e.substring(e.indexOf(":")+1),n=(new DOMParser).parseFromString("<data></data>","application/xml");if(this.instanceData=n,!t)return void console.warn("no key specified for localStore");const r=localStorage.getItem(t);if(!r)return console.warn(`Data for key ${t} cannot be found`),void this._useInlineData();const a=(new DOMParser).parseFromString(r,"application/xml");return void n.firstElementChild.replaceWith(a.firstElementChild)}const t=Ot.getContentType(this,"get");try{const n=await fetch(e,{method:"GET",credentials:this.credentials,mode:"cors",headers:{"Content-Type":t}}),r=await async function(e){const{status:t}=e;if(t>=400)throw alert(`response status: ${t} - failed to load data for '${this.src}' - stopping.`),new Error(`failed to load data - status: ${t}`);const n=e.headers.get("content-type").toLowerCase();if(n.startsWith("text/html"))return e.text().then((e=>(new DOMParser).parseFromString(e,"text/html")));if(n.startsWith("text/"))return e.text();if(n.startsWith("application/json"))return e.json();if(n.startsWith("application/xml")||n.startsWith("text/xml")){const t=await e.text();return(new DOMParser).parseFromString(t,"application/xml")}throw new Error(`unable to handle response content type: ${n}`)}(n);this._setInitialData(r)}catch(e){throw new Error(`failed loading data ${e}`)}}_setInitialData(e){this.instanceData=e,e.nodeType?this.originalInstance=this.instanceData.cloneNode(!0):this.originalInstance={...this.instanceData}}_getContentType(){return"xml"===this.type?"application/xml":"json"===this.type?"application/json":(console.warn("content-type unknown ",this.type),null)}_useInlineData(){if("xml"===this.type){const e=(new DOMParser).parseFromString(this.innerHTML,"application/xml");this._setInitialData(e)}else"json"===this.type?this._setInitialData(JSON.parse(this.textContent)):"html"===this.type?this._setInitialData(this.firstElementChild.children):"text"===this.type?this._setInitialData(this.textContent):console.warn("unknow type for data ",this.type)}}customElements.get("fx-instance")||customElements.define("fx-instance",Ft);class Dt{constructor(e,t,n,r,a,o,s,i,l){this.path=e,this.ref=t,this.constraint=o,this.readonly=n,this.relevant=r,this.required=a,this.type=s,this.node=i,this.bind=l,this.changed=!1,this.alerts=[],this.boundControls=[]}get value(){return this.node.nodeType?this.node.nodeType===Node.ATTRIBUTE_NODE?this.node.nodeValue:this.node.textContent:this.node}set value(e){e.nodeType===Node.DOCUMENT_NODE?this.node.replaceWith(e.firstElementChild):e.nodeType===Node.ELEMENT_NODE?this.node.replaceWith(e):this.node.nodeType===Node.ATTRIBUTE_NODE?this.node.nodeValue=e:this.node.textContent=e}addAlert(e){this.alerts.includes(e)||this.alerts.push(e)}cleanAlerts(){this.alerts=[]}}class kt extends HTMLElement{constructor(){super(),this.instances=[],this.modelItems=[],this.defaultContext={},this.changed=[],this.inited=!1,this.modelConstructed=!1,this.attachShadow({mode:"open"}),this.computes=0,this.fore={}}get formElement(){return this.parentElement}connectedCallback(){this.shadowRoot.innerHTML="\n <slot></slot>\n ",this.addEventListener("model-construct-done",(()=>{this.modelConstructed=!0}),{once:!0}),this.skipUpdate=!1,this.fore=this.parentNode}static lazyCreateModelItem(e,t,n){let r,a={};if(null==n)return null;if(a=n.nodeType===n.TEXT_NODE?n.parentNode:n,n.nodeType){const a=tt.resolveInstance(e,t);r=tt.getPath(n,a)}else r=null,a=n;const o=new Dt(r,t,Ot.READONLY_DEFAULT,Ot.RELEVANT_DEFAULT,Ot.REQUIRED_DEFAULT,Ot.CONSTRAINT_DEFAULT,Ot.TYPE_DEFAULT,a,this);return e.registerModelItem(o),o}async modelConstruct(){console.log(`### <<<<< dispatching model-construct for '${this.fore.id}' >>>>>`),Ot.dispatch(this,"model-construct",{model:this});const e=this.querySelectorAll("fx-instance");if(e.length>0){const t=[];e.forEach((e=>{t.push(e.init())})),await Promise.all(t),this.instances=Array.from(e),await Ot.dispatch(this,"model-construct-done",{model:this}),this.inited=!0,this.updateModel()}else console.log(`### <<<<< dispatching model-construct-done for '${this.fore.id}' >>>>>`),await this.dispatchEvent(new CustomEvent("model-construct-done",{composed:!1,bubbles:!0,detail:{model:this}}));this.inited=!0}registerModelItem(e){this.modelItems.push(e)}updateModel(){this.rebuild(),this.recalculate(),this.revalidate()}rebuild(){console.log(`### <<<<< rebuild() '${this.fore.id}' >>>>>`),this.mainGraph=new rt(!1),this.modelItems=[];const e=this.querySelectorAll("fx-model > fx-bind");0!==e.length?(e.forEach((e=>{e.init(this)})),console.log("mainGraph",this.mainGraph),console.log("rebuild mainGraph calc order",this.mainGraph.overallOrder()),Ot.dispatch(this,"rebuild-done",{maingraph:this.mainGraph}),console.log("mainGraph",this.mainGraph)):this.skipUpdate=!0}recalculate(){if(this.mainGraph){if(console.log(`### <<<<< recalculate() '${this.fore.id}' >>>>>`),this.computes=0,this.subgraph=new rt(!1),0!==this.changed.length){this.changed.forEach((e=>{if(this.subgraph.addNode(e.path,e.node),this.mainGraph.hasNode(e.path)){const t=this.mainGraph.dependantsOf(e.path,!1).reverse();0!==t.length&&t.forEach((t=>{const n=this.mainGraph.getNodeData(t);if(this.subgraph.addNode(t,n),t.includes(":")){const r=t.substring(0,t.indexOf(":"));this.subgraph.addNode(r,n);0!==this.mainGraph.dependentsOf(e.path,!1).indexOf(t)&&this.subgraph.addDependency(t,e.path)}}))}}));this.subgraph.overallOrder(!1).forEach((e=>{if(this.mainGraph.hasNode(e)){const t=this.mainGraph.getNodeData(e);this.compute(t,e)}}));const e=[...this.changed];this.formElement.toRefresh=e,this.changed=[],Ot.dispatch(this,"recalculate-done",{graph:this.subgraph,computes:this.computes})}else{this.mainGraph.overallOrder(!1).forEach((e=>{const t=this.mainGraph.getNodeData(e);this.compute(t,e)})),Ot.dispatch(this,"recalculate-done",{graph:this.mainGraph,computes:this.computes})}console.log("recalculate finished with modelItems ",this.modelItems)}}compute(e,t){const n=this.getModelItem(e);if(n&&t.includes(":")){const e=t.split(":")[1];if(e){const t=n.bind[e];if("calculate"===e){const e=yt(t,n.node,this);n.value=e,n.readonly=!0}else if("constraint"!==e&&"type"!==e&&t){const r=xt(t,n.node,this);n[e]=r}}this.computes+=1}}revalidate(){if(0===this.modelItems.length)return!0;console.log(`### <<<<< revalidate() '${this.fore.id}' >>>>>`);let e=!0;return this.modelItems.forEach((t=>{const{bind:n}=t;if(n){if("function"==typeof n.hasAttribute&&n.hasAttribute("constraint")){const r=n.getAttribute("constraint");if(r&&t.node){const n=xt(r,t.node,this);t.constraint=n,this.formElement.addToRefresh(t),n||(console.log("validation failed on modelitem ",t),e=!1)}}if("function"==typeof n.hasAttribute&&n.hasAttribute("required")){const r=n.getAttribute("required");if(r){const n=xt(r,t.node,this);t.required=n,this.formElement.addToRefresh(t),t.node.textContent||(console.log("node is required but has no value ",tt.getDocPath(t.node)),e=!1)}}}})),console.log("modelItems after revalidate: ",this.modelItems),e}addChanged(e){this.inited&&this.changed.push(e)}getModelItem(e){return this.modelItems.find((t=>t.node===e))}getDefaultContext(){return this.instances[0].getDefaultContext()}getDefaultInstance(){return this.instances[0]}getDefaultInstanceData(){return this.instances[0].getInstanceData()}getInstance(e){let t;if("default"===e&&(t=this.getDefaultInstance()),!t){t=Array.from(this.instances).find((t=>t.id===e)),this.fore.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE?this.fore.parentNode.host.closest("fx-fore"):this.fore.parentNode.closest("fx-fore")}if(!t){const n=this.fore.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE?this.fore.parentNode.host.closest("fx-fore"):this.fore.parentNode.closest("fx-fore");if(n){console.log("shared instances from parent",this.parentNode.id);t=n.getModel().instances.filter((e=>e.hasAttribute("shared"))).find((t=>t.id===e))}}return t||("default"===e?this.getDefaultInstance():(!t&&this.fore.strict&&Ot.dispatch(this,"error",{origin:this,message:`Instance '${e}' does not exist`,level:"Error"}),null))}evalBinding(e){return this.instances[0].evalXPath(e)}}kt.dataChanged=!1,customElements.get("fx-model")||customElements.define("fx-model",kt);const Rt=e=>class extends e{static get properties(){return{context:{type:Object},model:{type:Object},modelItem:{type:Object},nodeset:{type:Object},ref:{type:String},inScopeVariables:{type:Map}}}constructor(){super(),this.context=null,this.model=null,this.modelItem={},this.ref=this.hasAttribute("ref")?this.getAttribute("ref"):"",this.inScopeVariables=new Map}getModel(){if(this.model)return this.model;return this.getOwnerForm().querySelector("fx-model")}getOwnerForm(){let e=this;for(;e&&e.parentNode;){if("FX-FORE"===e.nodeName.toUpperCase())return e;e=e.parentNode instanceof DocumentFragment?e.parentNode.host:e.parentNode}return e}evalInContext(){if(!this.getModel())return;let e;if(this.hasAttribute("context")&&(e=St(this.getAttributeNode("context")||this,this.context)),this.hasAttribute("ref")&&(e=St(this.getAttributeNode("ref")||this,this.ref)),e||0===this.getModel().instances.length||(e=this.getModel().getDefaultInstance().getDefaultContext()),""===this.ref)this.nodeset=e;else if(Array.isArray(e))this.nodeset=yt(this.ref,e[0],this);else{if(!e)return;const{nodeType:t}=e;t&&!tt.isAbsolutePath(this.ref)?this.nodeset=wt(this.ref,e,this):[this.nodeset]=yt(this.ref,e,this)}}evaluateAttributeTemplateExpression(e,t){const n=e.match(/{[^}]*}/g);return n&&n.forEach((n=>{const r=n.substring(1,n.length-1),a=bt(r,St(t,r),this),o=e.replaceAll(n,a);e=o})),e}isNotBound(){return!this.hasAttribute("ref")}isBound(){return this.hasAttribute("ref")}getBindingExpr(){if(this.hasAttribute("ref"))return this.getAttribute("ref");const e=tt.getClosest("[ref]",this.parentNode);return e?e.getAttribute("ref"):"instance()"}getInstance(){if(this.ref.startsWith("instance(")){const e=tt.getInstanceId(this.ref);return this.getModel().getInstance(e)}return this.getModel().getInstance("default")}_getParentBindingElement(e){if(e.parentNode.host){const{host:t}=e.parentNode;if(t.hasAttribute("ref"))return t}else if(e.parentNode){if(e.parentNode.hasAttribute("ref"))return this.parentNode;this._getParentBindingElement(this.parentNode)}return null}getModelItem(){const e=this.getModel().getModelItem(this.nodeset);e&&(this.modelItem=e);const t=tt.getClosest("fx-repeatitem",this);let n;if(t){const{index:e}=t;n=Array.isArray(this.nodeset)?this.getModel().getModelItem(this.nodeset[e-1]):this.getModel().getModelItem(this.nodeset)}else n=this.getModel().getModelItem(this.nodeset);return n||kt.lazyCreateModelItem(this.getModel(),this.ref,this.nodeset)}getValue(){if(this.hasAttribute("value")){const e=this.getAttribute("value");try{return bt(e,St(this,e),this.getOwnerForm())}catch(e){console.error(e),Ot.dispatch(this,"error",{message:e})}}return this.textContent?this.textContent:null}getInScopeContext(){return St(this.getAttributeNode("ref")||this,this.ref)}setInScopeVariables(e){this.inScopeVariables=e}};class Mt extends(Rt(HTMLElement)){constructor(){super(),this.nodeset=[],this.model={},this.contextNode={},this.inited=!1}connectedCallback(){this.constraint=this.getAttribute("constraint"),this.ref=this.getAttribute("ref"),this.readonly=this.getAttribute("readonly"),this.required=this.getAttribute("required"),this.relevant=this.getAttribute("relevant"),this.type=this.hasAttribute("type")?this.getAttribute("type"):Mt.TYPE_DEFAULT,this.calculate=this.getAttribute("calculate")}init(e){this.model=e,this._getInstanceId(),this.bindType=this.getModel().getInstance(this.instanceId).type,"xml"===this.bindType&&(this._evalInContext(),this._buildBindGraph(),this._createModelItems()),this._processChildren(e)}_buildBindGraph(){"xml"===this.bindType&&this.nodeset.forEach((e=>{const t=tt.resolveInstance(this,this.ref),n=tt.getPath(e,t);this.model.mainGraph.addNode(n,e),this.calculate&&(this.model.mainGraph.addNode(`${n}:calculate`,e),this.model.mainGraph.addDependency(n,`${n}:calculate`));const r=this._getReferencesForProperty(this.calculate,e);if(0!==r.length&&this._addDependencies(r,e,n,"calculate"),!this.calculate){const t=this._getReferencesForProperty(this.readonly,e);0!==t.length?this._addDependencies(t,e,n,"readonly"):this.readonly&&this.model.mainGraph.addNode(`${n}:readonly`,e)}const a=this._getReferencesForProperty(this.required,e);0!==a.length?this._addDependencies(a,e,n,"required"):this.required&&this.model.mainGraph.addNode(`${n}:required`,e);const o=this._getReferencesForProperty(this.relevant,e);0!==o.length?this._addDependencies(o,e,n,"relevant"):this.relevant&&this.model.mainGraph.addNode(`${n}:relevant`,e);const s=this._getReferencesForProperty(this.constraint,e);0!==s.length?this._addDependencies(s,e,n,"constraint"):this.constraint&&(this.model.mainGraph.addNode(`${n}:constraint`,e),this.model.mainGraph.addDependency(n,`${n}:constraint`))}))}_addDependencies(e,t,n,r){const a=`${n}:${r}`;0!==e.length?(this.model.mainGraph.hasNode(a)||this.model.mainGraph.addNode(a,t),e.forEach((e=>{const t=tt.resolveInstance(this,n),r=tt.getPath(e,t);r.endsWith("text()[1]")||(this.model.mainGraph.hasNode(r)||this.model.mainGraph.addNode(r,e),this.model.mainGraph.addDependency(a,r))}))):this.model.mainGraph.addNode(a,t)}_processChildren(e){const t=this.querySelectorAll(":scope > fx-bind");Array.from(t).forEach((t=>{t.init(e)}))}getAlert(){if(this.hasAttribute("alert"))return this.getAttribute("alert");const e=this.querySelector("fx-alert");return e?e.innerHTML:null}_evalInContext(){const e=St(this.getAttributeNode("ref")||this,this.ref);if(this.nodeset=[],""===this.ref||null===this.ref)this.nodeset=e;else if(Array.isArray(e))e.forEach((t=>{if(tt.isSelfReference(this.ref))this.nodeset=e;else if(this.ref){vt(this.ref,t,this).forEach((e=>{this.nodeset.push(e)}))}}));else{"xml"===this.getModel().getInstance(this.instanceId).type?this.nodeset=vt(this.ref,e,this):this.nodeset=this.ref}}_createModelItems(){Array.isArray(this.nodeset)?Array.from(this.nodeset).forEach((e=>{this._createModelItem(e)})):this._createModelItem(this.nodeset)}_createModelItem(e){if(tt.isSelfReference(this.ref)){const e=tt.getClosest("fx-bind[ref]",this.parentElement);return void(e?e.required=this.required:console.error("no parent bound element"))}const t=e,n=tt.resolveInstance(this,this.ref),r=tt.getPath(e,n),a=new Dt(r,this.getBindingExpr(),Mt.READONLY_DEFAULT,Mt.RELEVANT_DEFAULT,Mt.REQUIRED_DEFAULT,Mt.CONSTRAINT_DEFAULT,this.type,t,this),o=this.getAlert();o&&a.addAlert(o),this.getModel().registerModelItem(a)}_getReferencesForProperty(e){return e?this.getReferences(e):[]}getReferences(e){const t=new Set,n=new et((e=>t.add(e)));return this.nodeset.forEach((t=>{bt(e,t,this,n)})),Array.from(t.values())}_initBooleanModelItemProperty(e,t){return xt(this[e],t,this)}static shortenPath(e){const t=e.split("/");let n="";for(let e=2;e<t.length;e+=1){const r=t[e];if(-1!==r.indexOf("{}")){n+=`/${r.split("{}")[1]}`}else n+=`/${r}`}return n}_getInstanceId(){const e=this.getBindingExpr();if(e.startsWith("instance("))this.instanceId=tt.getInstanceId(e);else{if(!this.instanceId&&"FX-BIND"===this.parentNode.nodeName){let e=this.parentNode;for(;e&&!this.instanceId;){const t=e.getBindingExpr();if(t.startsWith("instance("))return void(this.instanceId=tt.getInstanceId(t));if("FX-BIND"!==e.parentNode.nodeName){this.instanceId="default";break}e=e.parentNode}}this.instanceId="default"}}}Mt.READONLY_DEFAULT=!1,Mt.REQUIRED_DEFAULT=!1,Mt.RELEVANT_DEFAULT=!0,Mt.CONSTRAINT_DEFAULT=!0,Mt.TYPE_DEFAULT="xs:string",customElements.get("fx-bind")||customElements.define("fx-bind",Mt)
1
+ function e(e,t,n,r){const a={op:t,func:n,data:r};return e.push(a),a}function t(e,t){return e}class n{constructor(){this.program=[]}test(t,n){return e(this.program,5,t,void 0===n?null:n)}jump(t){return e(this.program,3,null,t)}record(n,r){return e(this.program,4,void 0===r?t:r,n)}bad(t=1){return e(this.program,1,null,t)}accept(){return e(this.program,0,null,null)}fail(t){return e(this.program,2,t||null,null)}}class r{constructor(e,t,n){this.programLength=e,this.maxFromByPc=t,this.maxSurvivorFromByPc=n}static fromProgram(e){const t=e.length,n=[],a=[];return e.forEach((e=>{n.push(0),a.push(0)})),e.forEach(((e,r)=>{switch(e.op){case 2:if(null===e.func)return;if(r+1>=t)throw new Error("Invalid program: program could run past end");n[r+1]+=1;break;case 1:case 4:if(r+1>=t)throw new Error("Invalid program: program could run past end");n[r+1]+=1;break;case 3:e.data.forEach((e=>{if(e<0||e>=t)throw new Error("Invalid program: program could run past end");n[e]+=1}));break;case 5:if(r+1>=t)throw new Error("Invalid program: program could run past end");a[r+1]+=1;break;case 0:a[r]+=1}})),new r(t,n,a)}static createStub(e){const t=[],n=[];for(let r=0;r<e;++r)t.push(e),n.push(e);return new r(e,t,n)}}class a{constructor(e){this.acceptingTraces=e,this.success=e.length>0}}class o{constructor(e){this.t=0,this.i=0,this.h=new Uint16Array(e),this.l=new Uint8Array(e)}getBadness(e){return this.l[e]}add(e,t){this.l[e]=t>255?255:t;const n=function(e,t,n,r,a){let o=r,s=a;for(;o<s;){const r=o+s>>>1;n<t[e[r]]?s=r:o=r+1}return o}(this.h,this.l,t,this.i,this.t);this.h.copyWithin(n+1,n,this.t),this.h[n]=e,this.t+=1}reschedule(e,t){const n=Math.max(this.l[e],t>255?255:t);if(this.l[e]!==n){const t=this.h.indexOf(e,this.i);if(t<0||t>=this.t)return void(this.l[e]=n);this.h.copyWithin(t,t+1,this.t),this.t-=1,this.add(e,n)}}getNextPc(){return this.i>=this.t?null:this.h[this.i++]}reset(){this.t=0,this.i=0,this.l.fill(0)}}class s{constructor(e){this.o=[];let t=e.length;e.forEach((e=>{this.o.push(e>0?t:-1),t+=e})),this.u=new Uint16Array(t)}clear(){this.u.fill(0,0,this.o.length)}add(e,t){const n=this.u[t],r=this.o[t];this.u[t]+=1,this.u[r+n]=e}has(e){return this.u[e]>0}forEach(e,t){const n=this.u[e],r=this.o[e];for(let e=r;e<r+n;++e)t(this.u[e])}}function i(e,t,n=!1){return null===e?t:Array.isArray(e)?(-1===e.indexOf(t)&&(n&&(e=e.slice()),e.push(t)),e):e===t?e:[e,t]}class l{constructor(e,t){this.prefixes=e,this.record=t}}function c(e,t){let n;if(null===t){if(!Array.isArray(e))return e;n=e}else n=e===l.EMPTY?[]:Array.isArray(e)?e:[e];return new l(n,t)}l.EMPTY=new l([],null);class u{constructor(e){this.p=[],this.v=[];for(let t=0;t<e;++t)this.p.push(0),this.v.push(null)}mergeTraces(e,t,n,r,a,o){let s=!1;return n.forEach(t,(t=>{const n=this.trace(t,r,a,o);var l,c,u;c=n,u=s,e=null===(l=e)?c:null===c?l:Array.isArray(c)?c.reduce(((e,t)=>i(e,t,e===c)),l):i(l,c,u),s=e===n})),e}trace(e,t,n,r){switch(this.p[e]){case 2:return this.v[e];case 1:return null}this.p[e]=1;let a=null;const o=t[e];if(null!==o)a=o;else if(!n.has(e))throw new Error("Trace without source at pc "+e);if(a=this.mergeTraces(a,e,n,t,n,r),null!==a){const t=r[e];null!==t&&(a=c(a,t))}return this.v[e]=a,this.p[e]=2,a}buildSurvivorTraces(e,t,n,r,a){for(let o=0,s=e.length;o<s;++o){if(!n.has(o)){t[o]=null;continue}this.v.fill(null),this.p.fill(0);const s=this.mergeTraces(null,o,n,e,r,a);if(null===s)throw new Error("No non-cyclic paths found to survivor "+o);t[o]=c(s,null)}this.v.fill(null)}}class h{constructor(e){this.g=[],this.k=[],this.m=[],this.A=new s(e.maxFromByPc),this.T=new s(e.maxSurvivorFromByPc),this.S=new u(e.programLength);for(let t=0;t<e.programLength;++t)this.g.push(null),this.k.push(null),this.m.push(null);this.k[0]=l.EMPTY}reset(e){this.A.clear(),this.T.clear(),this.g.fill(null),e&&(this.k.fill(null),this.m.fill(null),this.k[0]=l.EMPTY)}record(e,t){this.g[e]=t}has(e){return this.A.has(e)||null!==this.k[e]}add(e,t){this.A.add(e,t)}hasSurvivor(e){return this.T.has(e)}addSurvivor(e,t){this.T.add(e,t)}buildSurvivorTraces(){const e=this.k;this.S.buildSurvivorTraces(e,this.m,this.T,this.A,this.g),this.k=this.m,this.m=e}getTraces(e){const t=e.reduce(((e,t)=>i(e,this.k[t])),null);return null===t?[]:Array.isArray(t)?t:[t]}}class d{constructor(e){this.I=[],this.N=new o(e.programLength),this.M=new o(e.programLength),this.P=new h(e)}reset(){this.N.reset(),this.N.add(0,0),this.I.length=0,this.P.reset(!0)}getNextThreadPc(){return this.N.getNextPc()}step(e,t,n){const r=this.P.has(t);this.P.add(e,t);const a=this.N.getBadness(e)+n;r?this.N.reschedule(t,a):this.N.add(t,a)}stepToNextGeneration(e,t){const n=this.P.hasSurvivor(t);this.P.addSurvivor(e,t);const r=this.N.getBadness(e);n?this.M.reschedule(t,r):this.M.add(t,r)}accept(e){this.I.push(e),this.P.addSurvivor(e,e)}fail(e){}record(e,t){this.P.record(e,t)}nextGeneration(){this.P.buildSurvivorTraces(),this.P.reset(!1);const e=this.N;e.reset(),this.N=this.M,this.M=e}getAcceptingTraces(){return this.P.getTraces(this.I)}}class p{constructor(e){this.U=[],this.G=e,this.V=r.fromProgram(e),this.U.push(new d(this.V))}execute(e,t){const n=this.U.pop()||new d(this.V);n.reset();const r=e.length;let o,s=-1;do{let a=n.getNextThreadPc();if(null===a)break;for(++s,o=s>=r?null:e[s];null!==a;){const e=this.G[a];switch(e.op){case 0:null===o?n.accept(a):n.fail(a);break;case 2:{const r=e.func;if(null===r||r(t)){n.fail(a);break}n.step(a,a+1,0);break}case 1:n.step(a,a+1,e.data);break;case 5:if(null===o){n.fail(a);break}if(!(0,e.func)(o,e.data,t)){n.fail(a);break}n.stepToNextGeneration(a,a+1);break;case 3:{const t=e.data,r=t.length;if(0===r){n.fail(a);break}for(let e=0;e<r;++e)n.step(a,t[e],0);break}case 4:{const r=(0,e.func)(e.data,s,t);null!=r&&n.record(a,r),n.step(a,a+1,0);break}}a=n.getNextThreadPc()}n.nextGeneration()}while(null!==o);const i=new a(n.getAcceptingTraces());return n.reset(),this.U.push(n),i}}function m(e){return t=>t===e}function f(e,t){if(null===e||null===t)throw new Error("unescaped hyphen may not be used as a range endpoint");if(t<e)throw new Error("character range is in the wrong order");return n=>e<=n&&n<=t}function g(e){return!0}function y(){return!1}function w(e,t){return n=>e(n)||t(n)}function v(e,t){switch(t.kind){case"predicate":return void e.test(t.value);case"regexp":return void x(e,t.value,!1)}}function x(e,t,n){const r=e.program.length,a=e.jump([]);n&&(a.data.push(e.program.length),e.test((()=>!0)),e.jump([r]));const o=[];if(t.forEach((t=>{a.data.push(e.program.length),function(e,t){t.forEach((t=>{!function(e,t){const[n,{min:r,max:a}]=t;if(null!==a){for(let t=0;t<r;++t)v(e,n);for(let t=r;t<a;++t){const t=e.jump([]);t.data.push(e.program.length),v(e,n),t.data.push(e.program.length)}}else if(r>0){for(let t=0;t<r-1;++t)v(e,n);const t=e.program.length;v(e,n),e.jump([t]).data.push(e.program.length)}else{const t=e.program.length,r=e.jump([]);r.data.push(e.program.length),v(e,n),e.jump([t]),r.data.push(e.program.length)}}(e,t)}))}(e,t),o.push(e.jump([]))})),o.forEach((t=>{t.data.push(e.program.length)})),n){const t=e.program.length,n=e.jump([]);n.data.push(e.program.length),e.test((()=>!0)),e.jump([t]),n.data.push(e.program.length)}}function b(e,t){return{success:!0,offset:e,value:t}}function A(e){return b(e,void 0)}function E(e,t,n=!1){return{success:!1,offset:e,expected:t,fatal:n}}function N(e){return(t,n)=>{const r=n+e.length;return t.slice(n,r)===e?b(r,e):E(n,[e])}}function T(e,t){return(n,r)=>{const a=e(n,r);return a.success?b(a.offset,t(a.value)):a}}function B(e,t,n,r){return(a,o)=>{const s=e(a,o);return s.success?t(s.value)?s:E(o,n,r):s}}function I(e,t){return(n,r)=>{let a=null;for(const o of e){const e=o(n,r);if(e.success)return e;if(null===a||e.offset>a.offset?a=e:e.offset===a.offset&&void 0===t&&(a.expected=a.expected.concat(e.expected)),e.fatal)return e}return t=t||(null==a?void 0:a.expected)||[],a&&(a.expected=t),a||E(r,t)}}function C(e){return(t,n)=>{const r=e(t,n);return r.success||r.fatal?r:b(n,null)}}function O(e){return(t,n)=>{let r=[],a=n;for(;;){const n=e(t,a);if(!n.success){if(n.fatal)return n;break}if(r.push(n.value),n.offset===a)break;a=n.offset}return b(a,r)}}function S(e,t,n){return(r,a)=>{const o=e(r,a);if(!o.success)return o;const s=t(r,o.offset);return s.success?b(s.offset,n(o.value,s.value)):s}}function F(e){return S(e,O(e),((e,t)=>[e].concat(t)))}function D(e,t){return e}function k(e,t){return t}function R(e,t){return S(e,t,k)}function M(e,t){return S(e,t,D)}function U(e,t,n,r=!1){return R(e,r?$(M(t,n)):M(t,n))}function G(e,t){return(n,r)=>e(n,r).success?E(r,t):A(r)}function $(e){return(t,n)=>{const r=e(t,n);return r.success?r:E(r.offset,r.expected,!0)}}const L=(e,t)=>e.length===t?A(t):E(t,["end of input"]),P=["Lu","Ll","Lt","Lm","Lo","Mn","Mc","Me","Nd","Nl","No","Pc","Pd","Ps","Pe","Pi","Pf","Po","Zs","Zl","Zp","Sm","Sc","Sk","So","Cc","Cf","Co","Cn"],H={};function j(e){return e.codePointAt(0)}"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("").forEach(((e,t)=>{H[e]=t}));const _=e=>-1===e||-2===e;function X(e){return t=>!_(t)&&!e(t)}function q(e,t){return null===t?e:n=>e(n)&&!t(n)}const V=function(e,t){const n=new Map;let r=0;return["BasicLatin","Latin-1Supplement","LatinExtended-A","LatinExtended-B","IPAExtensions","SpacingModifierLetters","CombiningDiacriticalMarks","GreekandCoptic|Greek","Cyrillic","CyrillicSupplement","Armenian","Hebrew","Arabic","Syriac","ArabicSupplement","Thaana","NKo","Samaritan","Mandaic","SyriacSupplement","ArabicExtended-B","ArabicExtended-A","Devanagari","Bengali","Gurmukhi","Gujarati","Oriya","Tamil","Telugu","Kannada","Malayalam","Sinhala","Thai","Lao","Tibetan","Myanmar","Georgian","HangulJamo","Ethiopic","EthiopicSupplement","Cherokee","UnifiedCanadianAboriginalSyllabics","Ogham","Runic","Tagalog","Hanunoo","Buhid","Tagbanwa","Khmer","Mongolian","UnifiedCanadianAboriginalSyllabicsExtended","Limbu","TaiLe","NewTaiLue","KhmerSymbols","Buginese","TaiTham","CombiningDiacriticalMarksExtended","Balinese","Sundanese","Batak","Lepcha","OlChiki","CyrillicExtended-C","GeorgianExtended","SundaneseSupplement","VedicExtensions","PhoneticExtensions","PhoneticExtensionsSupplement","CombiningDiacriticalMarksSupplement","LatinExtendedAdditional","GreekExtended","GeneralPunctuation","SuperscriptsandSubscripts","CurrencySymbols","CombiningDiacriticalMarksforSymbols|CombiningMarksforSymbols","LetterlikeSymbols","NumberForms","Arrows","MathematicalOperators","MiscellaneousTechnical","ControlPictures","OpticalCharacterRecognition","EnclosedAlphanumerics","BoxDrawing","BlockElements","GeometricShapes","MiscellaneousSymbols","Dingbats","MiscellaneousMathematicalSymbols-A","SupplementalArrows-A","BraillePatterns","SupplementalArrows-B","MiscellaneousMathematicalSymbols-B","SupplementalMathematicalOperators","MiscellaneousSymbolsandArrows","Glagolitic","LatinExtended-C","Coptic","GeorgianSupplement","Tifinagh","EthiopicExtended","CyrillicExtended-A","SupplementalPunctuation","CJKRadicalsSupplement","KangxiRadicals",null,"IdeographicDescriptionCharacters","CJKSymbolsandPunctuation","Hiragana","Katakana","Bopomofo","HangulCompatibilityJamo","Kanbun","BopomofoExtended","CJKStrokes","KatakanaPhoneticExtensions","EnclosedCJKLettersandMonths","CJKCompatibility","CJKUnifiedIdeographsExtensionA","YijingHexagramSymbols","CJKUnifiedIdeographs","YiSyllables","YiRadicals","Lisu","Vai","CyrillicExtended-B","Bamum","ModifierToneLetters","LatinExtended-D","SylotiNagri","CommonIndicNumberForms","Phags-pa","Saurashtra","DevanagariExtended","KayahLi","Rejang","HangulJamoExtended-A","Javanese","MyanmarExtended-B","Cham","MyanmarExtended-A","TaiViet","MeeteiMayekExtensions","EthiopicExtended-A","LatinExtended-E","CherokeeSupplement","MeeteiMayek","HangulSyllables","HangulJamoExtended-B","HighSurrogates","HighPrivateUseSurrogates","LowSurrogates","PrivateUseArea|PrivateUse","CJKCompatibilityIdeographs","AlphabeticPresentationForms","ArabicPresentationForms-A","VariationSelectors","VerticalForms","CombiningHalfMarks","CJKCompatibilityForms","SmallFormVariants","ArabicPresentationForms-B","HalfwidthandFullwidthForms","Specials","LinearBSyllabary","LinearBIdeograms","AegeanNumbers","AncientGreekNumbers","AncientSymbols","PhaistosDisc",null,"Lycian","Carian","CopticEpactNumbers","OldItalic","Gothic","OldPermic","Ugaritic","OldPersian",null,"Deseret","Shavian","Osmanya","Osage","Elbasan","CaucasianAlbanian","Vithkuqi",null,"LinearA","LatinExtended-F",null,"CypriotSyllabary","ImperialAramaic","Palmyrene","Nabataean",null,"Hatran","Phoenician","Lydian",null,"MeroiticHieroglyphs","MeroiticCursive","Kharoshthi","OldSouthArabian","OldNorthArabian",null,"Manichaean","Avestan","InscriptionalParthian","InscriptionalPahlavi","PsalterPahlavi",null,"OldTurkic",null,"OldHungarian","HanifiRohingya",null,"RumiNumeralSymbols","Yezidi","ArabicExtended-C","OldSogdian","Sogdian","OldUyghur","Chorasmian","Elymaic","Brahmi","Kaithi","SoraSompeng","Chakma","Mahajani","Sharada","SinhalaArchaicNumbers","Khojki",null,"Multani","Khudawadi","Grantha",null,"Newa","Tirhuta",null,"Siddham","Modi","MongolianSupplement","Takri",null,"Ahom",null,"Dogra",null,"WarangCiti","DivesAkuru",null,"Nandinagari","ZanabazarSquare","Soyombo","UnifiedCanadianAboriginalSyllabicsExtended-A","PauCinHau","DevanagariExtended-A",null,"Bhaiksuki","Marchen",null,"MasaramGondi","GunjalaGondi",null,"Makasar","Kawi",null,"LisuSupplement","TamilSupplement","Cuneiform","CuneiformNumbersandPunctuation","EarlyDynasticCuneiform",null,"Cypro-Minoan","EgyptianHieroglyphs","EgyptianHieroglyphFormatControls",null,"AnatolianHieroglyphs",null,"BamumSupplement","Mro","Tangsa","BassaVah","PahawhHmong",null,"Medefaidrin",null,"Miao",null,"IdeographicSymbolsandPunctuation","Tangut","TangutComponents","KhitanSmallScript","TangutSupplement",null,"KanaExtended-B","KanaSupplement","KanaExtended-A","SmallKanaExtension","Nushu",null,"Duployan","ShorthandFormatControls",null,"ZnamennyMusicalNotation",null,"ByzantineMusicalSymbols","MusicalSymbols","AncientGreekMusicalNotation",null,"KaktovikNumerals","MayanNumerals","TaiXuanJingSymbols","CountingRodNumerals",null,"MathematicalAlphanumericSymbols","SuttonSignWriting",null,"LatinExtended-G","GlagoliticSupplement","CyrillicExtended-D",null,"NyiakengPuachueHmong",null,"Toto","Wancho",null,"NagMundari",null,"EthiopicExtended-B","MendeKikakui",null,"Adlam",null,"IndicSiyaqNumbers",null,"OttomanSiyaqNumbers",null,"ArabicMathematicalAlphabeticSymbols",null,"MahjongTiles","DominoTiles","PlayingCards","EnclosedAlphanumericSupplement","EnclosedIdeographicSupplement","MiscellaneousSymbolsandPictographs","Emoticons","OrnamentalDingbats","TransportandMapSymbols","AlchemicalSymbols","GeometricShapesExtended","SupplementalArrows-C","SupplementalSymbolsandPictographs","ChessSymbols","SymbolsandPictographsExtended-A","SymbolsforLegacyComputing",null,"CJKUnifiedIdeographsExtensionB",null,"CJKUnifiedIdeographsExtensionC","CJKUnifiedIdeographsExtensionD","CJKUnifiedIdeographsExtensionE","CJKUnifiedIdeographsExtensionF",null,"CJKCompatibilityIdeographsSupplement",null,"CJKUnifiedIdeographsExtensionG","CJKUnifiedIdeographsExtensionH",null,"Tags",null,"VariationSelectorsSupplement",null,"SupplementaryPrivateUseArea-A|PrivateUse","SupplementaryPrivateUseArea-B|PrivateUse"].forEach(((e,a)=>{const o=t[a];null!==e&&e.split("|").forEach((e=>{const t=n.get(e),a=f(r,r+o-1);n.set(e,t?w(t,a):a)})),r+=o})),n}(0,[128,128,128,208,96,80,112,144,256,48,96,112,256,80,48,64,64,64,32,16,48,96,128,128,128,128,128,128,128,128,128,128,128,128,256,160,96,256,384,32,96,640,32,96,32,32,32,32,128,176,80,80,48,96,32,32,144,80,128,64,64,80,48,16,48,16,48,128,64,64,256,256,112,48,48,48,80,64,112,256,256,64,32,160,128,32,96,256,192,48,16,256,128,128,256,256,96,32,128,48,80,96,32,128,128,224,16,16,64,96,96,48,96,16,32,48,16,256,256,6592,64,20992,1168,64,48,320,96,96,32,224,48,16,64,96,32,48,48,32,96,32,96,32,96,32,48,64,80,64,11184,80,896,128,1024,6400,512,80,688,16,16,16,32,32,144,240,16,128,128,64,80,64,48,128,32,64,32,48,32,48,32,64,32,80,48,48,80,48,64,80,64,384,64,64,64,32,32,48,48,32,32,32,64,32,96,96,32,32,32,64,64,32,32,48,80,80,48,128,64,288,32,64,64,48,64,64,48,32,128,80,48,80,48,96,32,80,48,48,80,128,128,128,96,160,128,96,32,80,48,80,176,80,80,96,96,64,96,80,96,16,64,96,160,112,80,64,96,80,304,32,96,80,16,64,1024,128,208,2624,112,1072,48,4e3,640,8576,576,48,96,48,144,688,96,96,160,64,32,6144,768,512,128,8816,16,256,48,64,400,2304,160,16,4688,208,48,256,256,80,112,32,32,96,32,128,1024,688,1104,256,48,96,112,80,320,48,64,464,48,736,32,224,32,96,784,80,64,80,176,256,256,48,112,96,256,256,768,80,48,128,128,128,256,256,112,144,256,1024,42720,32,4160,224,5776,7488,3088,544,1504,4944,4192,711760,128,128,240,65040,65536,65536]),Y=function(e){const t=new Map,n="bfUATCYATCPAQATAXATAOATBKJTBXCTBCZPATAQAZANAZADZPAXAQAXAbgUATAYDaATAZAaAGARAXAcAaAZAaAXAMBZADATBZAMAGASAMCTACWXACGDXXADHA3DAAPDAAtCAAFDBCAADCAABCCDBCCABCAABCCDCCAABCAAFCAADDAABCAABCBADCBDBGACADCGDCAEADACAEADACAEADAAPDAARDACAEADAABCBA7DFCAABCBDBABCCAJjDBAAGADaFRZDFLZNFEZGFAZAFAZQnvBAAADFAZACADABBFADCTACABDZBCATACCBACABACAABCQBACIDiCADBCCDCAXDDCADAXAABCBDBCyDvAhaAHEJBA1CAANDAgfBAABAClBBFATFDoTAOABBaBYABAHsOAHATAHBTAHBTAHABHGaBDGDTBBKcFXCTBYATBaBHKTAcATCGfFAGJHUKJTDGBHAmiBAATAGAHGcAaAHFFBHBaAHDGBKJGCaBGATNBAcAGAHAGdHaBBmYBAAHKGABNKJGgHIFBaATCFABBHAYBGVHDFAHIFAHCFAHEBBTOBAGYHCBBTABAGKBEGXZAGFBAcBBFHHGoFAHXcAHfIAG1HAIAHAGAICHHIDHAIBGAHGGJHBTBKJTAFAGOHAIBBAGHBBGBBBGVBAGGBAGABCGDBBHAGAICHDBBIBBBIBHAGABHIABDGBBAGCHBBBKJGBYBMFaAYAGATAHABBHBIABAGFBDGBBBGVBAGGBAGBBAGBBAGBBBHABAICHBBDHBBBHCBCHABGGDBAGABGKJHBGCHATABJHBIABAGIBAGCBAGVBAGGBAGBBAGEBBHAGAICHEBAHBIABAIBHABBGABOGBHBBBKJTAYABGGAHFBAHAIBBAGHBBGBBBGVBAGGBAGBBAGEBBHAGAIAHAIAHDBBIBBBIBHABGHBIABDGBBAGCHBBBKJaAGAMFBJHAGABAGFBCGCBAGDBCGBBAGABAGBBCGBBCGCBCGLBDIBHAIBBCICBAICHABBGABFIABNKJMCaFYAaABEHAICHAGHBAGCBAGWBAGPBBHAGAHCIDBAHCBAHDBGHBBAGCBBGABBGBHBBBKJBGTAMGaAGAHAIBTAGHBAGCBAGWBAGJBAGEBBHAGAIAHAIEBAHAIBBAIBHBBGIBBFGBBAGBHBBBKJBAGBIABLHBIBGIBAGCBAGoHBGAICHDBAICBAICHAGAaABDGCIAMGGCHBBBKJMIaAGFBAHAIBBAGRBCGXBAGIBAGABBGGBCHABDICHCBAHABAIHBFKJBBIBTABLGvHAGBHGBDYAGFFAHHTAKJTBBkGBBAGABAGEBAGXBAGABAGJHAGBHIGABBGEBAFABAHGBAKJBBGDBfGAaCTOaATAaCHBaFKJMJaAHAaAHAaAHAPAQAPAQAIBGHBAGjBDHNIAHETAHBGEHKBAHjBAaHHAaFBAaBTEaDTBBkGqIBHDIAHFIAHBIBHBGAKJTFGFIBHBGDHCGAICGBIGGCHDGMHAIBHBIFHAGAIAKJICHAaBClBACABECABBDqTAFADCmIFAABAGDBBGGBAGABAGDBBGoBAGDBBGgBAGDBBGGBAGABAGDBBGOBAG4BAGDBBmCBAABBHCTIMTBCGPaJBFiVBAABBDFBBOAmrJAAaATAGQUAGZPAQABCmKBAATCLCGHBGGRHCIABIGSHBIATBBIGRHBBLGMBAGCBAHBBLGzHBIAHGIHHAIBHKTCFATCYAGAHABBKJBFMJBFTFOATDHCcAHAKJBFGiFAG0BGGEHBGhHAGABEmFBAABJGeBAHCIDHBICBDIBHAIFHCBDaABCTBKJGdBBGEBKGrBDGZBFKJMABCahGWHBIBHABBTBG0IAHAIAHGBAHAIAHAIBHHIFHJBBHAKJBFKJBFTGFATFBBHNJAHPBwHDIAGuHAIAHEIAHAIEHAIBGHBCKJTGaJHIaITBBAHBIAGdIAHDIBHBIAHCGBKJGrHAIAHBICHAIAHCIBBHTDGjIHHHIBHBBCTEKJBCGCKJGdFFTBDIBGCqBBCCTHBHHCTAHMIAHGGDHAGFHAGBIAHBGABEDrF+DMFADhFkH/gVCAADHghBAADHCHDFBBCFBBDHCHDHCHDFBBCFBBDHBACABACABACABACADHCHDNBBDHEHDHEHDHEHDEBADBCDEAZADAZCDCBADBCDEAZCDDBBDBCDBAZCDHCEZCBBDCBADBCDEAZBBAUKcEOFTBRASAPARBSAPARATHVAWAcEUATIRASATDNBTCXAPAQATKXATANATJUAcEBAcJMAFABBMFXCPAQAFAMJXCPAQABAFMBCYgBOHMJDHAJCHLBOaBCAaDCAaBDACCDBCCDAaACAaBXACEaFCAaACAaACAaACDaADACDDAGDDAaBDBCBXECADDaAXAaBDAaAMPLiCADALDMAaBBDXEaEXBaDXAaBXAaBXAaGXAaeXBaBXAaAXAae3LEAAaHPAQAPAQAaTXBaGPAQA6QBAAXAadXYanXF6EBAABYaKBUM76NBAAMV62CAAXAaIXAa1XH6uBAAXA63DAAPAQAPAQAPAQAPAQAPAQAPAQAPAQAMdarXEPAQAXePAQAPAQAPAQAPAQAPAQAXP6/DAA3CCAAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQAX+PAQAPAQAXfPAQA3BEAAavXUaBXFamBBafBA6oBAACvDvABCCDBAFCCADDACADFFBCBgjBAADAaFADHCCADABETDMATBDlBADABEDABBG3BGFATABNHAGWBIGGBAGGBAGGBAGGBAGGBAGGBAGGBAGGBAHfTBRASARASATCRASATARASATIOATBOATARASATBRASAPAQAPAQAPAQAPAQATEFATJOBTDOATAPATMaBTCPAQAPAQAPAQAPAQAOABhaZBA6YBAABL6VDAABZaLBDUATCaAFAGALAPAQAPAQAPAQAPAQAPAQAaBPAQAPAQAPAQAPAQAOAPAQBaALIHDIBOAFEaBLCFAGATAaBBAmVBAABBHBZBFBGAOAmZBAATAFCGABEGqBAmdBAABAaBMDaJGfajBLGPaeBAMJadMHaAMOafMJamMO6/EAAm/mBAa/mUIFAFAm2RAABCa2BIGnFFTBmLEAAFATCGPKJGBBTAtGAHAJCTAHJTAFAAbFBHBmFBAALJHBTFBHZWFIZBANDBA9FADHADCAAJFAZBADGAADDBATCDABCDAPCCADBECADABADABADAADBXFCCADAGAFBDAGGHAGCHAGDHAGWIBHBIAaDHABCMFaBYAaABFGzTDBHIBGxIPHBBHTBKJBFHRGFTCGATAGBHAKJGbHHTBGWHKIBBKTAGcBCHCIAGuHAIBHDIBHBICTMBAFAKJBDTBGEHAFAGIKJGEBAGoHFIBHBIBHBBIGCHAGHHAIABBKJBBTDGPFAGFaCGAIAHAIAGxHAGAHCGBHBGEHBGAHAGABXGBFATBGKIAHBIBTBGAFBIAHABJGFBBGFBBGFBIGGBAGGBADqZAFDDIFAZBBDjPBAAGiIBHAIBHAIBTAIAHABBKJBFmjuCABLGWBDGwhDgAA9/jBAmtFAABBmpBAABlDGBLDEBEGAHAGJXAGMBAGEBAGABAGBBAGBBAmrBAAZQBPmqFAAQAPAaPG/BBG1BGaABfGLYAaCHPTGPAQATABFHPTAOBNBPAQAPAQAPAQAPAQAPAQAPAQAPAQAPAQATBPAQATDNCTCBATDOAPAQAPAQAPAQATCXAOAXCBATAYATBBDGEBAmGCAABBcABATCYATCPAQATAXATAOATBKJTBXCTBCZPATAQAZANAZADZPAXAQAXAPAQATAPAQATBGJFAGsFBGeBCGFBBGFBBGFBBGCBCYBXAZAaAYBBAaAXDaBBJcCaBBBGLBAGZBAGSBAGBBAGOBBGNBhm6BAABETCBDMsBCaIL0MDaQMBaCBAaMBCaABuasHAhBCAAGcBCGwBOHAMaBDGfMDBIGTLAGHLABEGlHEBEGdBATAGjBDGHTALEBpCnDnmNBAABBKJBFCjBDDjBDGnBHGzBKTACKBACOBACGBACBBADKBADOBADGBADBhCBAAm2EAABIGVBJGHBXFFBAFpBAFIhEBAAGFBBGABAGrBAGBBCGABBGWBATAMHGWaBMGGeBHMIBvGSBAGBBEMEGVMFBCTAGZBETAB/G3BDMBGBMPBBMtGAHCBAHBBEHDGDBAGCBAGcBBHCBDHAMIBGTIBGGcMBTAGcMCBfGHaAGbHBBDMETGBIG1BCTGGVBBMHGSBEMHGRBGTDBLMGhPBAAmIBAAB2CyBMDyBGMFGjHDBHKJhlEAAMeBAGpBAHBOABBGBhKBAAHCGcMJGABHGVHKMDTEBVGRHDTDBlGUMGBTGWBIIAHAIAG0HOTGBDMTKJHAGBHBGABIHCIAGsICHDIBHBTBcATDHABJcABBGYBGKJBFHCGjHEIAHHBAKJTDGAIBGABHGiHATBGABIHBIAGvICHIIBGDTDHDTAIAHAKJGATAGATCBAMTBKGRBAGYICHCIBHAIAHBTFHAGBHAB9GGBAGABAGDBAGOBAGJTABFGuHAICHHBEKJBFHBIBBAGHBBGBBBGVBAGGBAGBBAGEBAHBGAIBHAIDBBIBBBICBBGABFIABEGEIBBBHGBCHEhKCAAG0ICHHIBHCIAHAGDTEKJTBBATAHAGCBdGvICHFIAHAIDHBIAHBGBTAGABHKJhlCAAGuICHDBBIDHBIAHBTWGDHBBhGvICHHIBHAIAHBTCGABKKJBFTMBSGqHAIAHAIBHFIAHAGATABFKJB1GaBBHCIBHDIAHEBDKJMBTCaAGGh4CAAGrICHIIAHBTAhjBAACfDfKJMIBLGHBBGABBGHBAGBBAGXIFBAIBBBHBIAHAGAIAGAIAHATCBIKJhFBAAGHBBGmICHDBBHBIDHAGATAGAIABaGAHJGnHFIAGAHDTHHABHGAHFIBHCGtHMIAHBTCGATEBMmIBAABGTJh1DAAGIBAGkIAHGBAHFIAHAGATEBJKJMSBCTBGdBBHVBAIAHGIAHBIAHBhIBAAGGBAGBBAGlHFBCHABAHBBAHGGAHABHKJBFGFBAGBBAGfIEBAHBBAIBHAIAHAGABGKJh1EAAGSHBIBTBBGHBGAIAGMBAGhIBHEBCIBHAIAHATMKJhVBAAGABOMUaHYDaQBMTAmZOAAhlBAAruBAABATEBKmDDAAhLpAAmgBAATBBMmvQAAcPHAGFHOhp+AAmGJAAh4GCAm4IAABGGeBAKJBDTBmOBAABAKJBFGdBBHETABJGvHGTEaDFDTAaABJKJBAMGBAGUBEGShvKAACfDfMWTDhkBAAmKBAABDHAGAI2BGHDFMB/FBTAFAHABKIBBNm3fBABHmVTAABpGIhmLCAFDBAFGBAFBBAmiEAABOGABcGCBBGABNGDBHmLGAAhDkAAmqBAABEGMBCGIBGGJBBaAHBTAcDhbJBAHtBBHWBI6zBAAB761DAABJamBBa7IBHCaCIFcHHHaBHGadHDa8BU6BBAAHCaAh5BAAMTBLMTBL6WBAABIMYhGCAACZDZCZDGBADRCZDZCABACBBBCABBCBBBCDBACHDDBADABADGBADKCZDZCBBACDBBCHBACGBADZCBBACDBACEBACABCCGBADZCZDZCZDZCZDZCZDZCZDZCZDbBBCYXADYXADFCYXADYXADFCYXADYXADFCYXADYXADFCYXADYXADFCADABBKx6/HAAH2aDHxaHHAaNHAaBTEBOHEBAHOhPRAADJGADTBFDFhUDAAHGBAHQBBHGBAHBBAHEBEF9BgHAhvBAAGsBCHGFGBBKJBDGAaAh/EAAGdHABQGrHDKJBEYAhPHAAGaFAHDKJhlLAAGGBAGDBAGBBAGOBAmEDAABBMIHGBoChDhHGFABDKJBDTBhQMAAM6aAMCYAMDhLBAAMsaAMOhBDAAGDBAGaBAGBBAGABBGABAGJBAGDBAGABAGABFGABDGABAGABAGABAGCBAGBBAGABBGABAGABAGABAGABAGABAGBBAGABBGDBAGGBAGDBAGDBAGABAGJBAGQBEGCBAGEBAGQBzXBhNEAAarBD6jBAABLaOBBaOBAaOBAakBJMM6gCAAB3acBMarBDaIBGaBBNaFhZCAA66DAAZE6XLAABDaQBCaMBC62BAABD6eBAABFaLBDaABOaLBDa3BHaJBFanBHadBBaBhNBAA6TFAABLaNBBaMBCaIBGatBAaGBHaNBDaIBGaIBG6SCAABAa2BkKJhFQAAmfbKABfm5ABABFmdDAABBmBaBABNmw0BAhewAAmdIAAhhXAAmKNBABEmfBBAhQxtCcABd8fBAAh/BAAnvDAAhP4PA99/PABB99/PA".split(""),r=P.map((()=>[]));let a=0,o=0;for(;o<n.length;){const e=H[n[o]],t=(31&e)-2;let s=1+H[n[o+1]];switch(32&e?(s+=H[n[o+2]]<<6,s+=H[n[o+3]]<<12,s+=H[n[o+4]]<<18,o+=5):o+=2,t){case-2:{let e=0;for(let t=a;t<a+s;++t)r[e].push(m(t)),e=(e+1)%2;break}case-1:break;default:{const e=r[t];1===s?e.push(m(a)):e.push(f(a,a+s-1));break}}a+=s}const s=new Map;return P.forEach(((e,n)=>{const a=r[n].reduce(w,y);t.set(e,a);const o=e.charAt(0),i=s.get(o)||[];s.set(o,i),i.push(a)})),s.forEach(((e,n)=>{t.set(n,e.reduce(w,y))})),t}();function z(e){return 32===e||9===e||10===e||13===e}const J=[m(j(":")),f(j("A"),j("Z")),m(j("_")),f(j("a"),j("z")),f(192,214),f(216,246),f(192,214),f(216,246),f(248,767),f(880,893),f(895,8191),f(8204,8205),f(8304,8591),f(11264,12271),f(12289,55295),f(63744,64975),f(65008,65533),f(65536,983039)].reduce(w),Q=[J,m(j("-")),m(j(".")),f(j("0"),j("9")),m(183),f(768,879),f(8255,8256)].reduce(w),K=Y.get("Nd"),W=X(K),Z=q(f(0,1114111),[Y.get("P"),Y.get("Z"),Y.get("C")].reduce(w)),ee=X(Z);function te(e){return 10!==e&&13!==e&&!_(e)}const ne={s:z,S:X(z),i:J,I:X(J),c:Q,C:X(Q),d:K,D:W,w:Z,W:ee},re=N("*"),ae=N("\\"),oe=N("{"),se=N("}"),ie=N("["),le=N("]"),ce=N("^"),ue=N("$"),he=N(","),de=N("-"),pe=N("("),me=N(")"),fe=N("."),ge=N("|"),ye=N("+"),we=N("?"),ve=N("-["),xe=j("0");function be(e){return[...e].map((e=>e.codePointAt(0)))}var Ae=Object.freeze({__proto__:null,compile:function(e,t={language:"xsd"}){const r=function(e){function t(e){return new Set(e.split("").map((e=>j(e))))}function n(e,t){const n=e.codePointAt(t);return void 0===n?E(t,["any character"]):b(t+String.fromCodePoint(n).length,n)}const r="xpath"===e.language?R(ae,I([T(N("n"),(()=>10)),T(N("r"),(()=>13)),T(N("t"),(()=>9)),T(I([ae,ge,fe,de,ce,we,re,ye,oe,se,ue,pe,me,ie,le]),(e=>j(e)))])):R(ae,I([T(N("n"),(()=>10)),T(N("r"),(()=>13)),T(N("t"),(()=>9)),T(I([ae,ge,fe,de,ce,we,re,ye,oe,se,pe,me,ie,le]),(e=>j(e)))]));function a(e,r){const a=t(r);return S(N(e),C(B(n,(e=>a.has(e)),r.split(""))),((e,t)=>function(e){const t=Y.get(e);if(null==t)throw new Error(e+" is not a valid unicode category");return t}(null===t?e:e+String.fromCodePoint(t))))}const o=I([a("L","ultmo"),a("M","nce"),a("N","dlo"),a("P","cdseifo"),a("Z","slp"),a("S","mcko"),a("C","cfon")]),s=[f(j("a"),j("z")),f(j("A"),j("Z")),f(j("0"),j("9")),m(45)].reduce(w),i=I([o,T(R(N("Is"),function(e){return(t,n)=>{const r=e(t,n);return r.success?b(r.offset,t.slice(n,r.offset)):r}}(F(B(n,s,["block identifier"])))),(t=>function(e,t){const n=V.get(e);if(void 0===n){if(t)return g;throw new Error(`The unicode block identifier "${e}" is not known.`)}return n}(t,"xpath"!==e.language)))]),l=U(N("\\p{"),i,se,!0),c=T(U(N("\\P{"),i,se,!0),X),u=R(ae,T(I("sSiIcCdDwW".split("").map((e=>N(e)))),(e=>ne[e]))),h=T(fe,(()=>te)),d=I([u,l,c]),p=t("\\[]"),y=I([r,B(n,(e=>!p.has(e)),["unescaped character"])]),v=I([T(de,(()=>null)),y]),x=S(v,R(de,v),f);function A(e,t){return[e].concat(t||[])}const k=T(function(e){return(t,n)=>{const r=e(t,n);return r.success?b(n,r.value):r}}(I([le,ve])),(()=>null)),P=j("-"),H=I([T(M(M(de,G(ie,["not ["])),k),(()=>P)),R(G(de,["not -"]),y)]),_=I([S(T(H,m),I([function(e,t){return _(e,t)},k]),A),S(I([x,d]),I([J,k]),A)]),z=I([S(T(y,m),I([_,k]),A),S(I([x,d]),I([J,k]),A)]);function J(e,t){return z(e,t)}const Q=T(z,(e=>e.reduce(w))),K=T(R(ce,Q),X),W=S(I([R(G(ce,["not ^"]),Q),K]),C(R(de,(function(e,t){return Z(e,t)}))),q),Z=U(ie,W,le,!0),ee="xpath"===e.language?I([T(r,m),d,Z,h,T(ce,(()=>e=>-1===e)),T(ue,(()=>e=>-2===e))]):I([T(r,m),d,Z,h]),be="xpath"===e.language?t(".\\?*+{}()|^$[]"):t(".\\?*+{}()|[]"),Ae=B(n,(e=>!be.has(e)),["NormalChar"]),Ee=T(R(ae,S(T(B(n,f(j("1"),j("9")),["digit"]),(e=>e-xe)),O(T(B(n,f(xe,j("9")),["digit"]),(e=>e-xe))),((e,t)=>{t.reduce(((e,t)=>10*e+t),e)}))),(e=>{throw new Error("Backreferences in XPath patterns are not yet implemented.")})),Ne="xpath"===e.language?I([T(Ae,(e=>({kind:"predicate",value:m(e)}))),T(ee,(e=>({kind:"predicate",value:e}))),T(U(pe,R(C(N("?:")),Se),me,!0),(e=>({kind:"regexp",value:e}))),Ee]):I([T(Ae,(e=>({kind:"predicate",value:m(e)}))),T(ee,(e=>({kind:"predicate",value:e}))),T(U(pe,Se,me,!0),(e=>({kind:"regexp",value:e})))]),Te=T(F(T(B(n,f(xe,j("9")),["digit"]),(e=>e-xe))),(e=>e.reduce(((e,t)=>10*e+t)))),Be=I([S(Te,R(he,Te),((e,t)=>{if(t<e)throw new Error("quantifier range is in the wrong order");return{min:e,max:t}})),S(Te,he,(e=>({min:e,max:null}))),T(Te,(e=>({min:e,max:e})))]),Ie="xpath"===e.language?S(I([T(we,(()=>({min:0,max:1}))),T(re,(()=>({min:0,max:null}))),T(ye,(()=>({min:1,max:null}))),U(oe,Be,se,!0)]),C(we),((e,t)=>e)):I([T(we,(()=>({min:0,max:1}))),T(re,(()=>({min:0,max:null}))),T(ye,(()=>({min:1,max:null}))),U(oe,Be,se,!0)]),Ce=O(S(Ne,T(C(Ie),(e=>null===e?{min:1,max:1}:e)),((e,t)=>[e,t]))),Oe=S(Ce,O(R(ge,$(Ce))),((e,t)=>[e].concat(t)));function Se(e,t){return Oe(e,t)}const Fe=function(e){return S(e,L,D)}(Oe);return function(e){let t;try{t=Fe(e,0)}catch(t){throw new Error(`Error parsing pattern "${e}": ${t instanceof Error?t.message:t}`)}return t.success?t.value:function(e,t,n){const r=n.map((e=>`"${e}"`));throw new Error(`Error parsing pattern "${e}" at offset ${t}: expected ${r.length>1?"one of "+r.join(", "):r[0]} but found "${e.slice(t,t+1)}"`)}(e,t.offset,t.expected)}}(t)(e),a=function(e){const t=new n;return e(t),new p(t.program)}((e=>{x(e,r,"xpath"===t.language),e.accept()}));return function(e){const n="xpath"===t.language?[-1,...be(e),-2]:be(e);return a.execute(n).success}}});function Ee(e,t){return{success:!0,offset:e,value:t}}function Ne(e){return Ee(e,void 0)}function Te(e,t,n=!1){return{success:!1,offset:e,expected:t,fatal:n}}function Be(e){return e>65535?2:1}function Ie(e,t){return(n,r)=>{const a=n.codePointAt(r);return void 0!==a&&e(a)?Ne(r+Be(a)):Te(r,t)}}function Ce(e,t){return(n,r)=>{const a=e(n,r);return a.success?Ee(a.offset,t(a.value)):a}}function Oe(e){return(t,n)=>{let r=[],a=n;for(;;){const n=e(t,a);if(!n.success){if(n.fatal)return n;break}if(r.push(n.value),n.offset===a)break;a=n.offset}return Ee(a,r)}}function Se(e){return(t,n)=>{let r=n;for(;;){const n=e(t,r);if(!n.success){if(n.fatal)return n;break}if(n.offset===r)break;r=n.offset}return Ne(r)}}function Fe(e,t,n){return(r,a)=>{const o=e(r,a);if(!o.success)return o;const s=t(r,o.offset);return s.success?Ee(s.offset,n(o.value,s.value)):s}}function De(e,t){return e}function ke(e,t){return t}function Re(e,t){return Fe(e,t,ke)}function Me(e,t){return Fe(e,t,De)}function Ue(e,t){return(n,r)=>e(n,r).success?Te(r,t):Ne(r)}function Ge(e){return(t,n)=>{const r=e(t,n);return r.success?r:Te(r.offset,r.expected,!0)}}const $e=(e,t)=>e.length===t?Ne(t):Te(t,["end of input"]);function Le(e){const t=[];let n=e.next();for(;!n.done;)t.push(n.value),n=e.next();return[t,n.value]}var Pe=Object.freeze({__proto__:null,codepoint:Ie,codepoints:function(e,t){return(n,r)=>{const a=r;for(;;){const t=n.codePointAt(r);if(void 0===t)break;if(!e(t))break;r+=t>65535?2:1}return void 0!==t&&r===a?Te(r,t):Ne(r)}},collect:Le,complete:function(e){return Fe(e,$e,De)},consume:function(e){return Ce(e,(()=>{}))},cut:Ge,delimited:function(e,t,n,r=!1){return Re(e,r?Ge(Me(t,n)):Me(t,n))},dispatch:function(e,t,n=0,r=[]){return(a,o)=>{const s=a.codePointAt(o+n);if(void 0===s)return Te(o,r);const i=e[s];return void 0===i?void 0===t?Te(o,r):t(a,o):i(a,o)}},end:$e,error:Te,except:function(e,t,n){return Re(Ue(t,n),e)},filter:function(e,t,n,r){return(a,o)=>{const s=e(a,o);return s.success?t(s.value)?s:Te(o,n,r):s}},filterUndefined:function(e){return Ce(e,(e=>e.filter((e=>void 0!==e))))},first:De,followed:Me,map:Ce,not:Ue,ok:Ne,okWithValue:Ee,optional:function(e){return(t,n)=>{const r=e(t,n);return r.success||r.fatal?r:Ee(n,null)}},or:function(e,t){return(n,r)=>{let a=null;for(const o of e){const e=o(n,r);if(e.success)return e;if(null===a||e.offset>a.offset?a=e:e.offset===a.offset&&void 0===t&&(a.expected=a.expected.concat(e.expected)),e.fatal)return e}return t=t||(null==a?void 0:a.expected)||[],a&&(a.expected=t),a||Te(r,t)}},peek:function(e){return(t,n)=>{const r=e(t,n);return r.success?Ee(n,r.value):r}},plus:function(e){return Fe(e,Oe(e),((e,t)=>[e].concat(t)))},plusConsumed:function(e){return Fe(e,Se(e),ke)},preceded:Re,range:function(e,t,n){return Ie((n=>e<=n&&n<=t),n||[`${String.fromCodePoint(e)}-${String.fromCodePoint(t)}`])},recognize:function(e){return(t,n)=>{const r=e(t,n);return r.success?Ee(r.offset,t.slice(n,r.offset)):r}},second:ke,sequence:function(...e){return(t,n)=>{const r=[];for(const a of e){const e=a(t,n);if(!e.success)return e;n=e.offset,r.push(e.value)}return Ee(n,r)}},sequenceConsumed:function(...e){return(t,n)=>{for(const r of e){const e=r(t,n);if(!e.success)return e;n=e.offset}return Ne(n)}},skipChars:function(e){return(t,n)=>{let r=e;for(;r>0;){const e=t.codePointAt(n);if(void 0===e)return Te(n,["any character"]);n+=Be(e),r-=1}return Ne(n)}},star:Oe,starConsumed:Se,start:(e,t)=>0===t?Ne(t):Te(t,["start of input"]),streaming:function(e){return function*(t,n){const r=e(t,n);return r.success&&(yield r.value),r}},streamingComplete:function(e){return function*(t,n){const r=yield*e(t,n);return r.success?$e(t,r.offset):r}},streamingFilterUndefined:function(e){return function*(t,n){const r=e(t,n);let a=r.next();for(;!a.done;){const e=a.value;void 0!==e&&(yield e),a=r.next()}return a.value}},streamingOptional:function(e){return function*(t,n){const[r,a]=Le(e(t,n));return a.success?(yield*r,a):a.fatal?a:Ne(n)}},streamingStar:function(e){return function*(t,n){for(;;){const[r,a]=Le(e(t,n));if(!a.success)return a.fatal?a:Ne(n);if(yield*r,n===a.offset)return Ne(n);n=a.offset}}},streamingThen:function(e,t){return function*(n,r){const a=yield*e(n,r);return a.success?yield*t(n,a.offset):a}},then:Fe,token:function(e){return(t,n)=>{const r=n+e.length;return t.slice(n,r)===e?Ee(r,e):Te(n,[e])}}});const He=function(e,t){const n={};function r(e,t){if(!("0"!==e&&"-0"!==e||"0"!==t&&"-0"!==t))return 0;var n=/(?:\+|(-))?(\d+)?(?:\.(\d+))?/;e=n.exec(e+"");var r=n.exec(t+""),a=!e[1];const o=!r[1];return t=(e[2]||"").replace(/^0*/,""),n=(r[2]||"").replace(/^0*/,""),e=e[3]||"",r=r[3]||"",a&&!o?1:!a&&o?-1:(a=a&&o,t.length>n.length?a?1:-1:t.length<n.length?a?-1:1:t>n?a?1:-1:t<n?a?-1:1:(t=Math.max(e.length,r.length),(n=e.padEnd(t,"0"))>(t=r.padEnd(t,"0"))?a?1:-1:n<t?a?-1:1:0))}function a(e,t){return!(-1<(e=e.toString()).indexOf(".")&&0===t)&&(!(e=/^[-+]?0*([1-9]\d*)?(?:\.((?:\d*[1-9])*)0*)?$/.exec(e))[2]||e[2].length<=t)}function o(e,t){switch(t){case"required":return/(Z)|([+-])([01]\d):([0-5]\d)$/.test(e.toString());case"prohibited":return!/(Z)|([+-])([01]\d):([0-5]\d)$/.test(e.toString());case"optional":return!0}}function s(e){switch(e){case 1:case 0:case 6:case 3:case 18:case 22:case 21:case 20:case 23:case 44:return{};case 4:return{ka:a,wa:function(e,t){return 1>r(e,t)},lc:function(e,t){return 0>r(e,t)},xa:function(e,t){return-1<r(e,t)},mc:function(e,t){return 0<r(e,t)}};case 9:case 8:case 7:case 11:case 12:case 13:case 15:case 14:return{Ba:o};default:return null}}var i={},l={};function c(e){return/^([+-]?(\d*(\.\d*)?([eE][+-]?\d*)?|INF)|NaN)$/.test(e)}function u(e){return/^[_:A-Za-z][-._:A-Za-z0-9]*$/.test(e)}function h(e){return u(e)&&/^[_A-Za-z]([-._A-Za-z0-9])*$/.test(e)}function d(e){return 1===(e=e.split(":")).length?h(e[0]):2===e.length&&(h(e[0])&&h(e[1]))}function p(e){return!/[\u0009\u000A\u000D]/.test(e)}function m(e){return h(e)}const f=new Map([[45,function(){return!0}],[46,function(){return!0}],[1,function(){return!0}],[0,function(e){return/^(0|1|true|false)$/.test(e)}],[6,function(e){return c(e)}],[3,c],[4,function(e){return/^[+-]?\d*(\.\d*)?$/.test(e)}],[18,function(e){return/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.test(e)}],[9,function(e){return/^-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?|(24:00:00(\.0+)?))(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[8,function(e){return/^(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?|(24:00:00(\.0+)?))(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[7,function(e){return/^-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[11,function(e){return/^-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[12,function(e){return/^-?([1-9][0-9]{3,}|0[0-9]{3})(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[13,function(e){return/^--(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[15,function(e){return/^---(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[14,function(e){return/^--(0[1-9]|1[0-2])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(e)}],[22,function(e){return/^([0-9A-Fa-f]{2})*$/.test(e)}],[21,function(e){return new RegExp(/^((([A-Za-z0-9+/] ?){4})*((([A-Za-z0-9+/] ?){3}[A-Za-z0-9+/])|(([A-Za-z0-9+/] ?){2}[AEIMQUYcgkosw048] ?=)|(([A-Za-z0-9+/] ?)[AQgw] ?= ?=)))?$/).test(e)}],[20,function(){return!0}],[44,d],[48,p],[52,function(e){return p(e)&&!/^ | {2,}| $/.test(e)}],[51,function(e){return/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/.test(e)}],[50,function(e){return/^[-._:A-Za-z0-9]+$/.test(e)}],[25,u],[23,d],[24,h],[42,m],[41,m],[26,function(e){return h(e)}],[5,function(e){return/^[+-]?\d+$/.test(e)}],[16,function(e){return/^-?P[0-9]+(Y([0-9]+M)?|M)$/.test(e)}],[17,function(e){return/^-?P([0-9]+D)?(T([0-9]+H)?([0-9]+M)?([0-9]+(\.[0-9]+)?S)?)?$/.test(e)}]]);var g=Object.create(null);function y(e,t){if(!g[t])throw Error("Unknown type");return{type:t,value:e}}[{C:0,name:59},{C:0,name:46,parent:59,K:{whiteSpace:"preserve"}},{C:0,name:19,parent:46},{C:0,name:1,parent:46},{C:0,name:0,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:4,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:6,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:3,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:18,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:9,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:8,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:7,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:11,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:12,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:13,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:15,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:14,parent:46,K:{Ba:"optional",whiteSpace:"collapse"}},{C:0,name:22,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:21,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:20,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:23,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:44,parent:46,K:{whiteSpace:"collapse"}},{C:1,name:10,R:9,K:{whiteSpace:"collapse",Ba:"required"}},{C:1,name:48,R:1,K:{whiteSpace:"replace"}},{C:1,name:52,R:48,K:{whiteSpace:"collapse"}},{C:1,name:51,R:52,K:{whiteSpace:"collapse"}},{C:1,name:50,R:52,K:{whiteSpace:"collapse"}},{C:2,name:49,type:50,K:{minLength:1,whiteSpace:"collapse"}},{C:1,name:25,R:52,K:{whiteSpace:"collapse"}},{C:1,name:24,R:25,K:{whiteSpace:"collapse"}},{C:1,name:42,R:24,K:{whiteSpace:"collapse"}},{C:1,name:41,R:24,K:{whiteSpace:"collapse"}},{C:2,name:43,type:41,K:{minLength:1,whiteSpace:"collapse"}},{C:1,name:26,R:24,K:{whiteSpace:"collapse"}},{C:2,name:40,type:26,K:{minLength:1,whiteSpace:"collapse"}},{C:0,name:5,parent:4,K:{ka:0,whiteSpace:"collapse"}},{C:1,name:27,R:5,K:{ka:0,wa:"0",whiteSpace:"collapse"}},{C:1,name:28,R:27,K:{ka:0,wa:"-1",whiteSpace:"collapse"}},{C:1,name:31,R:5,K:{ka:0,wa:"9223372036854775807",xa:"-9223372036854775808",whiteSpace:"collapse"}},{C:1,name:32,R:31,K:{ka:0,wa:"2147483647",xa:"-2147483648",whiteSpace:"collapse"}},{C:1,name:33,R:32,K:{ka:0,wa:"32767",xa:"-32768",whiteSpace:"collapse"}},{C:1,name:34,R:33,K:{ka:0,wa:"127",xa:"-128",whiteSpace:"collapse"}},{C:1,name:30,R:5,K:{ka:0,xa:"0",whiteSpace:"collapse"}},{C:1,name:36,R:30,K:{ka:0,wa:"18446744073709551615",xa:"0",whiteSpace:"collapse"}},{C:1,name:35,R:36,K:{ka:0,wa:"4294967295",xa:"0",whiteSpace:"collapse"}},{C:1,name:38,R:35,K:{ka:0,wa:"65535",xa:"0",whiteSpace:"collapse"}},{C:1,name:37,R:38,K:{ka:0,wa:"255",xa:"0",whiteSpace:"collapse"}},{C:1,name:29,R:30,K:{ka:0,xa:"1",whiteSpace:"collapse"}},{C:1,name:16,R:18,K:{whiteSpace:"collapse"}},{C:1,name:17,R:18,K:{whiteSpace:"collapse"}},{C:1,name:60,R:59},{C:3,name:39,Ca:[]},{C:1,name:61,R:60},{C:1,name:62,R:60},{C:0,name:53,parent:59},{C:1,name:54,R:53},{C:1,name:58,R:53},{C:1,name:47,R:53},{C:1,name:56,R:53},{C:1,name:57,R:53},{C:1,name:55,R:53},{C:3,name:2,Ca:[4,5,6,3]},{C:3,name:63,Ca:[]}].forEach((e=>{const t=e.name,n=e.K||{};switch(e.C){case 0:e=e.parent?g[e.parent]:null;var r=f.get(t)||null;g[t]={C:0,type:t,Ja:n,parent:e,fb:r,Oa:s(t),Ca:[]};break;case 1:e=g[e.R],r=f.get(t)||null,g[t]={C:1,type:t,Ja:n,parent:e,fb:r,Oa:e.Oa,Ca:[]};break;case 2:g[t]={C:2,type:t,Ja:n,parent:g[e.type],fb:null,Oa:i,Ca:[]};break;case 3:e=e.Ca.map((e=>g[e])),g[t]={C:3,type:t,Ja:n,parent:null,fb:null,Oa:l,Ca:e}}}));var w=y(!0,0),v=y(!1,0),x=(e="A wrong argument type was specified in a function call.")=>Error(`FORG0006: ${e}`),b=class{constructor(e,t){this.done=e,this.value=t}},A=new b(!0);function E(e){return new b(!1,e)}function N(e,t){if(3===t.C)return!!t.Ca.find((t=>N(e,t)));for(;e;){if(e.type===t.type)return!0;if(3===e.C)return!!e.Ca.find((e=>T(e.type,t.type)));e=e.parent}return!1}function T(e,t){return e===t||N(g[e],g[t])}var B=class{constructor(){this.value={next:()=>A}}gb(){return this}filter(){return this}first(){return null}O(){return[]}fa(){return!1}Pa(){return 0}G(){return!0}ua(){return!1}map(){return this}N(e){return e([])}Y(e){return e.empty?e.empty(this):e.default(this)}},I=class{constructor(e,t){this.type=e,this.value=t}};const C={0:"xs:boolean",1:"xs:string",2:"xs:numeric",3:"xs:double",4:"xs:decimal",5:"xs:integer",6:"xs:float",7:"xs:date",8:"xs:time",9:"xs:dateTime",10:"xs:dateTimeStamp",11:"xs:gYearMonth",12:"xs:gYear",13:"xs:gMonthDay",14:"xs:gMonth",15:"xs:gDay",16:"xs:yearMonthDuration",17:"xs:dayTimeDuration",18:"xs:duration",19:"xs:untypedAtomic",20:"xs:anyURI",21:"xs:base64Binary",22:"xs:hexBinary",23:"xs:QName",24:"xs:NCName",25:"xs:Name",26:"xs:ENTITY",27:"xs:nonPositiveInteger",28:"xs:negativeInteger",29:"xs:positiveInteger",30:"xs:nonNegativeInteger",31:"xs:long",32:"xs:int",33:"xs:short",34:"xs:byte",35:"xs:unsignedInt",36:"xs:unsignedLong",37:"xs:unsignedByte",38:"xs:unsignedShort",39:"xs:error",40:"xs:ENTITIES",41:"xs:IDREF",42:"xs:ID",43:"xs:IDREFS",44:"xs:NOTATION",45:"xs:anySimpleType",46:"xs:anyAtomicType",47:"attribute()",48:"xs:normalizedString",49:"xs:NMTOKENS",50:"xs:NMTOKEN",51:"xs:language",52:"xs:token",53:"node()",54:"element()",55:"document-node()",56:"text()",57:"processing-instruction()",58:"comment()",59:"item()",60:"function(*)",61:"map(*)",62:"array(*)",63:"none"},O={"xs:boolean":0,"xs:string":1,"xs:numeric":2,"xs:double":3,"xs:decimal":4,"xs:integer":5,"xs:float":6,"xs:date":7,"xs:time":8,"xs:dateTime":9,"xs:dateTimeStamp":10,"xs:gYearMonth":11,"xs:gYear":12,"xs:gMonthDay":13,"xs:gMonth":14,"xs:gDay":15,"xs:yearMonthDuration":16,"xs:dayTimeDuration":17,"xs:duration":18,"xs:untypedAtomic":19,"xs:anyURI":20,"xs:base64Binary":21,"xs:hexBinary":22,"xs:QName":23,"xs:NCName":24,"xs:Name":25,"xs:ENTITY":26,"xs:nonPositiveInteger":27,"xs:negativeInteger":28,"xs:positiveInteger":29,"xs:nonNegativeInteger":30,"xs:long":31,"xs:int":32,"xs:short":33,"xs:byte":34,"xs:unsignedInt":35,"xs:unsignedLong":36,"xs:unsignedByte":37,"xs:unsignedShort":38,"xs:error":39,"xs:ENTITIES":40,"xs:IDREF":41,"xs:ID":42,"xs:IDREFS":43,"xs:NOTATION":44,"xs:anySimpleType":45,"xs:anyAtomicType":46,"attribute()":47,"xs:normalizedString":48,"xs:NMTOKENS":49,"xs:NMTOKEN":50,"xs:language":51,"xs:token":52,"node()":53,"element()":54,"document-node()":55,"text()":56,"processing-instruction()":57,"comment()":58,"item()":59,"function(*)":60,"map(*)":61,"array(*)":62};function S(e){return 2===e.g?C[e.type]+"*":1===e.g?C[e.type]+"+":0===e.g?C[e.type]+"?":C[e.type]}function F(e){if("none"===e)throw Error('XPST0051: The type "none" could not be found');if(!e.startsWith("xs:")&&0<=e.indexOf(":"))throw Error(`XPST0081: Invalid prefix for input ${e}`);const t=O[e];if(void 0===t)throw Error(`XPST0051: The type "${e}" could not be found`);return t}function D(e){switch(e[e.length-1]){case"*":return{type:F(e.substr(0,e.length-1)),g:2};case"?":return{type:F(e.substr(0,e.length-1)),g:0};case"+":return{type:F(e.substr(0,e.length-1)),g:1};default:return{type:F(e),g:3}}}function k(e){const t=e.value;if(T(e.type,53))return!0;if(T(e.type,0))return t;if(T(e.type,1)||T(e.type,20)||T(e.type,19))return 0!==t.length;if(T(e.type,2))return!isNaN(t)&&0!==t;throw x(`Cannot determine the effective boolean value of a value with the type ${C[e.type]}`)}function R(e,t=0){e.h=t}var M=class{constructor(e){this.v=$,this.h=e;let t=!1;this.value={next:()=>t?A:(t=!0,E(e))},this.o=null}gb(){return this}filter(e){return e(this.h,0,this)?this:this.v.create()}first(){return this.h}O(){return[this.h]}fa(){return null===this.o&&(this.o=k(this.h)),this.o}Pa(){return 1}G(){return!1}ua(){return!0}map(e){return this.v.create(e(this.h,0,this))}N(e){return e([this.h])}Y(e){return e.m?e.m(this):e.default(this)}};const U=new B;function G(e=null,t=null){if(null===e)return U;if(Array.isArray(e))switch(e.length){case 0:return U;case 1:return new M(e[0]);default:return new class{constructor(e){this.o=$,this.h=e;let t=-1;this.value={next:()=>(t++,t>=e.length?A:E(e[t]))}}gb(){return this}filter(e){let t=-1;return this.o.create({next:()=>{for(t++;t<this.h.length&&!e(this.h[t],t,this);)t++;return t>=this.h.length?A:E(this.h[t])}})}first(){return this.h[0]}O(){return this.h}fa(){if(T(this.h[0].type,53))return!0;throw x("Cannot determine the effective boolean value of a sequence with a length higher than one.")}Pa(){return this.h.length}G(){return!1}ua(){return!1}map(e){let t=-1;return this.o.create({next:()=>++t>=this.h.length?A:E(e(this.h[t],t,this))},this.h.length)}N(e){return e(this.h)}Y(e){return e.multiple?e.multiple(this):e.default(this)}}(e)}return e.next?new class{constructor(e,t=null){this.D=$,this.value={next:t=>null!==this.o&&this.h>=this.o?A:void 0!==this.v[this.h]?E(this.v[this.h++]):(t=e.next(t)).done?(this.o=this.h,t):((this.l||2>this.h)&&(this.v[this.h]=t.value),this.h++,t)},this.l=!1,this.v=[],this.h=0,this.o=t}gb(){return this.D.create(this.O())}filter(e){let t=-1;const n=this.value;return this.D.create({next:r=>{for(t++,r=n.next(r);!r.done&&!e(r.value,t,this);)t++,r=n.next(0);return r}})}first(){if(void 0!==this.v[0])return this.v[0];const e=this.value.next(0);return R(this),e.done?null:e.value}O(){if(this.h>this.v.length&&this.o!==this.v.length)throw Error("Implementation error: Sequence Iterator has progressed.");const e=this.value;this.l=!0;let t=e.next(0);for(;!t.done;)t=e.next(0);return this.v}fa(){const e=this.value,t=this.h;R(this);var n=e.next(0);if(n.done)return R(this,t),!1;if(T((n=n.value).type,53))return R(this,t),!0;if(!e.next(0).done)throw x("Cannot determine the effective boolean value of a sequence with a length higher than one.");return R(this,t),k(n)}Pa(e=!1){if(null!==this.o)return this.o;if(e)return-1;e=this.h;const t=this.O().length;return R(this,e),t}G(){return 0===this.o||null===this.first()}ua(){if(null!==this.o)return 1===this.o;var e=this.value;const t=this.h;return R(this),e.next(0).done?(R(this,t),!1):(e=e.next(0),R(this,t),e.done)}map(e){let t=0;const n=this.value;return this.D.create({next:r=>(r=n.next(r)).done?A:E(e(r.value,t++,this))},this.o)}N(e,t){const n=this.value;let r;const a=[];let o=!0;return function(){for(let e=n.next(o?0:t);!e.done;e=n.next(t))o=!1,a.push(e.value);r=e(a).value}(),this.D.create({next:()=>r.next(0)})}Y(e){let t=null;const n=e=>{t=e.value,-1!==(e=e.Pa(!0))&&(this.o=e)};return this.D.create({next:r=>t?t.next(r):this.G()?(n(e.empty?e.empty(this):e.default(this)),t.next(r)):this.ua()?(n(e.m?e.m(this):e.default(this)),t.next(r)):(n(e.multiple?e.multiple(this):e.default(this)),t.next(r))})}}(e,t):new M(e)}var $={create:G,m:e=>new M(e),empty:()=>G(),aa:()=>G(w),V:()=>G(v)};function L(e){const t=[],n=e.value;return()=>{let e=0;return $.create({next:()=>{if(void 0!==t[e])return t[e++];const r=n.next(0);return r.done?r:t[e++]=r}})}}var P=class{constructor(e,t,n){this.namespaceURI=t||null,this.prefix=e||"",this.localName=n}za(){return this.prefix?this.prefix+":"+this.localName:this.localName}};var H=class extends I{constructor({j:e,arity:t,Xa:n=!1,J:r=!1,localName:a,namespaceURI:o,i:s,value:i}){for(super(60,null),this.value=i,this.J=r,r=-1,i=0;i<e.length;i++)4===e[i]&&(r=i);-1<r&&(i=Array(t-(e.length-1)).fill(e[r-1]),e=e.slice(0,r).concat(i)),this.o=e,this.v=t,this.ia=n,this.D=a,this.l=o,this.s=s}Xa(){return this.ia}};function j(e,t){const n=[];return 2!==e&&1!==e||n.push("type-1-or-type-2"),n.push(`type-${e}`),t&&n.push(`name-${t}`),n}function _(e){const t=e.node.nodeType;let n;return 2!==t&&1!==t||(n=e.node.localName),j(t,n)}function X(e){let t,n=e.nodeType;return 4===n&&(n=3),2!==n&&1!==n||(t=e.localName),j(n,t)}var q=class{getAllAttributes(e,t=null){return 1!==e.nodeType?[]:(e=Array.from(e.attributes),null===t?e:e.filter((e=>X(e).includes(t))))}getAttribute(e,t){return 1!==e.nodeType?null:e.getAttribute(t)}getChildNodes(e,t=null){return e=Array.from(e.childNodes),null===t?e:e.filter((e=>X(e).includes(t)))}getData(e){return 2===e.nodeType?e.value:e.data}getFirstChild(e,t=null){for(e=e.firstChild;e;e=e.nextSibling)if(null===t||X(e).includes(t))return e;return null}getLastChild(e,t=null){for(e=e.lastChild;e;e=e.previousSibling)if(null===t||X(e).includes(t))return e;return null}getNextSibling(e,t=null){for(e=e.nextSibling;e;e=e.nextSibling)if(null===t||X(e).includes(t))return e;return null}getParentNode(e,t=null){return(e=2===e.nodeType?e.ownerElement:e.parentNode)&&(null===t||X(e).includes(t))?e:null}getPreviousSibling(e,t=null){for(e=e.previousSibling;e;e=e.previousSibling)if(null===t||X(e).includes(t))return e;return null}};var V=new class{insertBefore(e,t,n){return e.insertBefore(t,n)}removeAttributeNS(e,t,n){return e.removeAttributeNS(t,n)}removeChild(e,t){return e.removeChild(t)}setAttributeNS(e,t,n,r){e.setAttributeNS(t,n,r)}setData(e,t){e.data=t}};class Y{constructor(e){this.h=e}insertBefore(e,t,n){return this.h.insertBefore(e,t,n)}removeAttributeNS(e,t,n){return this.h.removeAttributeNS(e,t,n)}removeChild(e,t){return this.h.removeChild(e,t)}setAttributeNS(e,t,n,r){this.h.setAttributeNS(e,t,n,r)}setData(e,t){this.h.setData(e,t)}}function z(e){return void 0!==e.Ra}function J(e,t,n){let r=null;return t&&(z(t.node)?r={F:t.F,offset:n,parent:t.node}:t.F&&(r=t.F)),{node:e,F:r}}function Q(e,t,n=null){return e.getAllAttributes(t.node,n).map((e=>J(e,t,e.nodeName)))}function K(e,t,n){return z(t=t.node)?(e=t.attributes.find((e=>n===e.name)))?e.value:null:(e=e.h.getAttribute(t,n))?e:null}function W(e,t,n=null){return e.getChildNodes(t.node,n).map(((e,n)=>J(e,t,n)))}function Z(e,t){return e.getData(t.node)}function ee(e,t,n=null){const r=t.node;return z(r)?e=r.childNodes[0]:((n=e.h.getFirstChild(r,n))&&10===n.nodeType&&(n=e.h.getNextSibling(n)),e=n),e?J(e,t,0):null}function te(e,t,n=null){var r=t.node;return z(r)?(e=r.childNodes.length-1,r=r.childNodes[e]):((r=e.h.getLastChild(r,n))&&10===r.nodeType&&(r=e.h.getPreviousSibling(r)),e=e.getChildNodes(t.node,n).length-1),r?J(r,t,e):null}function ne(e,t,n=null){const r=t.node,a=t.F;if(a)"number"==typeof a.offset&&r===a.parent.childNodes[a.offset]||"string"==typeof a.offset&&r===a.parent.attributes.find((e=>a.offset===e.nodeName))?(e=a.parent,t=a.F):(e=e.getParentNode(r,n),t=a);else{if(z(r))return null;e=e.getParentNode(r,n),t=null}return e?{node:e,F:t}:null}function re(e,t,n=null){const r=t.node;let a,o,s;const i=t.F;if(z(r))i&&(s=i.offset+1,a=i.parent.childNodes[s]);else{if(!i){for(a=r;a&&(!(a=e.h.getNextSibling(a,n))||10===a.nodeType););return a?{node:a,F:null}:null}s=i.offset+1,o=ne(e,t,null),a=e.getChildNodes(o.node,n)[s]}return a?J(a,o||ne(e,t,n),s):null}function ae(e,t,n=null){const r=t.node;let a,o;const s=t.F;let i;if(z(r))s&&(i=s.offset-1,a=s.parent.childNodes[i]);else{if(!s){for(a=r;a&&(!(a=e.h.getPreviousSibling(a,n))||10===a.nodeType););return a?{node:a,F:null}:null}i=s.offset-1,o=ne(e,t,null),a=e.getChildNodes(o.node,n)[i]}return a?J(a,o||ne(e,t,n),i):null}var oe=class{constructor(e){this.h=e,this.o=[]}getAllAttributes(e,t=null){return z(e)?e.attributes:this.h.getAllAttributes(e,t)}getChildNodes(e,t=null){return t=z(e)?e.childNodes:this.h.getChildNodes(e,t),9===e.nodeType?t.filter((e=>10!==e.nodeType)):t}getData(e){return z(e)?2===e.nodeType?e.value:e.data:this.h.getData(e)||""}getParentNode(e,t=null){return this.h.getParentNode(e,t)}},se=(e,t,n,r,a)=>a.N((([e])=>r.N((([t])=>{const n=e.value;if(0>=n||n>t.h.length)throw Error("FOAY0001: array position out of bounds.");return t.h[n-1]()})))),ie=class extends H{constructor(e){super({value:(e,t,n,r)=>se(0,0,0,$.m(this),r),localName:"get",namespaceURI:"http://www.w3.org/2005/xpath-functions/array",j:[{type:5,g:3}],arity:1,i:{type:59,g:2}}),this.type=62,this.h=e}};function le(e){switch(e.node.nodeType){case 2:return 47;case 1:return 54;case 3:case 4:return 56;case 7:return 57;case 8:return 58;case 9:return 55;default:return 53}}function ce(e){return{type:le(e),value:e}}function ue(e,t){return e=e.map((e=>e.first())),t(e)}function he(e,t){var n=T(e.type,1)||T(e.type,20)||T(e.type,19),r=T(t.type,1)||T(t.type,20)||T(t.type,19);return n&&r?e.value===t.value:(n=T(e.type,4)||T(e.type,3)||T(e.type,6),r=T(t.type,4)||T(t.type,3)||T(t.type,6),n&&r?!(!isNaN(e.value)||!isNaN(t.value))||e.value===t.value:(n=T(e.type,0)||T(e.type,22)||T(e.type,18)||T(e.type,23)||T(e.type,44),r=T(t.type,0)||T(t.type,22)||T(t.type,18)||T(t.type,23)||T(t.type,44),!(!n||!r)&&e.value===t.value))}var de=(e,t,n,r,a)=>ue([r,a],(([e,t])=>(e=e.h.find((e=>he(e.key,t))))?e.value():$.empty())),pe=class extends H{constructor(e){super({j:[{type:59,g:3}],arity:1,localName:"get",namespaceURI:"http://www.w3.org/2005/xpath-functions/map",value:(e,t,n,r)=>de(0,0,0,$.m(this),r),i:{type:59,g:2}}),this.type=61,this.h=e}};function me(e,t){return e.h()===t.h()&&e.o()===t.o()}var fe=class{Za(){return 0}getHours(){return 0}getMinutes(){return 0}$a(){return 0}h(){return 0}o(){return 0}getSeconds(){return 0}ab(){return 0}na(){return!0}};function ge(e){var t=Math.abs(e.Za()),n=Math.abs(e.getHours());const r=Math.abs(e.getMinutes());return n=(n?`${n}H`:"")+(r?`${r}M`:"")+((e=Math.abs(e.getSeconds()))?`${e}S`:""),(t=""+(t?`${t}D`:""))&&n?`${t}T${n}`:t||(n?`T${n}`:"T0S")}var ye=class extends fe{constructor(e){if(super(),e>Number.MAX_SAFE_INTEGER||e<Number.MIN_SAFE_INTEGER)throw Error("FODT0002: Number of seconds given to construct DayTimeDuration overflows MAX_SAFE_INTEGER or MIN_SAFE_INTEGER");this.ca=e}Za(){return Math.trunc(this.ca/86400)}getHours(){return Math.trunc(this.ca%86400/3600)}getMinutes(){return Math.trunc(this.ca%3600/60)}o(){return this.ca}getSeconds(){const e=this.ca%60;return Object.is(-0,e)?0:e}na(){return!Object.is(-0,this.ca)&&0<=this.ca}toString(){return(this.na()?"P":"-P")+ge(this)}},we=(e,t,n,r,a,o)=>(e=86400*e+3600*t+60*n+r+a,new ye(o||0===e?e:-e)),ve=e=>(e=/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(?:T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.exec(e))?we(e[4]?parseInt(e[4],10):0,e[5]?parseInt(e[5],10):0,e[6]?parseInt(e[6],10):0,e[7]?parseInt(e[7],10):0,e[8]?parseFloat(e[8]):0,!e[1]):null,xe=e=>"Z"===(e=/^(Z)|([+-])([01]\d):([0-5]\d)$/.exec(e))[1]?we(0,0,0,0,0,!0):we(0,e[3]?parseInt(e[3],10):0,e[4]?parseInt(e[4],10):0,0,0,"+"===e[2]);function be(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot multiply xs:dayTimeDuration by NaN");if((e=e.ca*t)>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while multiplying xs:dayTimeDuration");return new ye(e<Number.MIN_SAFE_INTEGER||Object.is(-0,e)?0:e)}function Ae(e){return e?parseInt(e,10):null}function Ee(e){const t=(e+="").startsWith("-");return t&&(e=e.substring(1)),(t?"-":"")+e.padStart(4,"0")}function Ne(e){return(e+"").padStart(2,"0")}function Te(e){return 1===(e+="").split(".")[0].length&&(e=e.padStart(e.length+1,"0")),e}function Be(e){return 0===e.getHours()&&0===e.getMinutes()?"Z":(e.na()?"+":"-")+Ne(Math.abs(e.getHours()))+":"+Ne(Math.abs(e.getMinutes()))}function Ie(e){var t=/^(?:(-?\d{4,}))?(?:--?(\d\d))?(?:-{1,3}(\d\d))?(T)?(?:(\d\d):(\d\d):(\d\d))?(\.\d+)?(Z|(?:[+-]\d\d:\d\d))?$/.exec(e);e=t[1]?parseInt(t[1],10):null;const n=Ae(t[2]),r=Ae(t[3]),a=t[4],o=Ae(t[5]),s=Ae(t[6]),i=Ae(t[7]),l=t[8]?parseFloat(t[8]):0;if(t=t[9]?xe(t[9]):null,e&&(-271821>e||273860<e))throw Error("FODT0001: Datetime year is out of bounds");return a?new Se(e,n,r,o,s,i,l,t,9):null!==o&&null!==s&&null!==i?new Se(1972,12,31,o,s,i,l,t,8):null!==e&&null!==n&&null!==r?new Se(e,n,r,0,0,0,0,t,7):null!==e&&null!==n?new Se(e,n,1,0,0,0,0,t,11):null!==n&&null!==r?new Se(1972,n,r,0,0,0,0,t,13):null!==e?new Se(e,1,1,0,0,0,0,t,12):null!==n?new Se(1972,n,1,0,0,0,0,t,14):new Se(1972,12,r,0,0,0,0,t,15)}function Ce(e,t){switch(t){case 15:return new Se(1972,12,e.o,0,0,0,0,e.X,15);case 14:return new Se(1972,e.h,1,0,0,0,0,e.X,14);case 12:return new Se(e.v,1,1,0,0,0,0,e.X,12);case 13:return new Se(1972,e.h,e.o,0,0,0,0,e.X,13);case 11:return new Se(e.v,e.h,1,0,0,0,0,e.X,11);case 8:return new Se(1972,12,31,e.l,e.s,e.D,e.pa,e.X,8);case 7:return new Se(e.v,e.h,e.o,0,0,0,0,e.X,7);default:return new Se(e.v,e.h,e.o,e.l,e.s,e.D,e.pa,e.X,9)}}function Oe(e,t){return t=e.X||t||xe("Z"),new Date(Date.UTC(e.v,e.h-1,e.o,e.l-t.getHours(),e.s-t.getMinutes(),e.D,1e3*e.pa))}var Se=class{constructor(e,t,n,r,a,o,s,i,l=9){this.v=e,this.h=t,this.o=n+(24===r?1:0),this.l=24===r?0:r,this.s=a,this.D=o,this.pa=s,this.X=i,this.type=l}getDay(){return this.o}getHours(){return this.l}getMinutes(){return this.s}getMonth(){return this.h}getSeconds(){return this.D}getYear(){return this.v}toString(){switch(this.type){case 9:return Ee(this.v)+"-"+Ne(this.h)+"-"+Ne(this.o)+"T"+Ne(this.l)+":"+Ne(this.s)+":"+Te(this.D+this.pa)+(this.X?Be(this.X):"");case 7:return Ee(this.v)+"-"+Ne(this.h)+"-"+Ne(this.o)+(this.X?Be(this.X):"");case 8:return Ne(this.l)+":"+Ne(this.s)+":"+Te(this.D+this.pa)+(this.X?Be(this.X):"");case 15:return"---"+Ne(this.o)+(this.X?Be(this.X):"");case 14:return"--"+Ne(this.h)+(this.X?Be(this.X):"");case 13:return"--"+Ne(this.h)+"-"+Ne(this.o)+(this.X?Be(this.X):"");case 12:return Ee(this.v)+(this.X?Be(this.X):"");case 11:return Ee(this.v)+"-"+Ne(this.h)+(this.X?Be(this.X):"")}throw Error("Unexpected subType")}};function Fe(e,t,n){const r=Oe(e,n).getTime();return r===(n=Oe(t,n).getTime())?e.pa===t.pa?0:e.pa>t.pa?1:-1:r>n?1:-1}function De(e,t,n){return 0===Fe(e,t,n)}function ke(e,t,n){return e=(Oe(e,n).getTime()-Oe(t,n).getTime())/1e3,new ye(e)}function Re(e){throw Error(`Not implemented: adding durations to ${C[e.type]}`)}function Me(e){throw Error(`Not implemented: subtracting durations from ${C[e.type]}`)}function Ue(e,t){if(null===e)return null;switch(typeof e){case"boolean":return e?w:v;case"number":return y(e,3);case"string":return y(e,1);case"object":if("nodeType"in e)return ce({node:e,F:null});if(Array.isArray(e))return new ie(e.map((e=>void 0===e?()=>$.empty():L(e=null===(e=Ue(e))?$.empty():$.m(e)))));if(e instanceof Date){const t=Ie(e.toISOString());return y(t,t.type)}return new pe(Object.keys(e).filter((t=>void 0!==e[t])).map((t=>{var n=Ue(e[t]);return n=null===n?$.empty():$.m(n),{key:y(t,1),value:L(n)}})))}throw Error(`Value ${String(e)} of type "${typeof e}" is not adaptable to an XPath value.`)}function Ge(e,t){if("number"!=typeof e&&("string"!=typeof e||!f.get(t)(e)))throw Error(`Cannot convert JavaScript value '${e}' to the XPath type ${C[t]} since it is not valid.`)}function $e(e,t,n){if(null===t)return null;switch(e){case 0:return t?w:v;case 1:return y(t+"",1);case 3:case 2:return Ge(t,3),y(+t,3);case 4:return Ge(t,e),y(+t,4);case 5:return Ge(t,e),y(0|t,5);case 6:return Ge(t,e),y(+t,6);case 7:case 8:case 9:case 11:case 12:case 13:case 14:case 15:if(!(t instanceof Date))throw Error(`The JavaScript value ${t} with type ${typeof t} is not a valid type to be converted to an XPath ${C[e]}.`);return y(Ce(Ie(t.toISOString()),e),e);case 53:case 47:case 55:case 54:case 56:case 57:case 58:if("object"!=typeof t||!("nodeType"in t))throw Error(`The JavaScript value ${t} with type ${typeof t} is not a valid type to be converted to an XPath ${C[e]}.`);return ce({node:t,F:null});case 59:case 61:return Ue(t);default:throw Error(`Values of the type "${C[e]}" can not be adapted from JavaScript to equivalent XPath values.`)}}function Le(e,t,n){if(0===n.g)return null===(t=$e(n.type,t))?[]:[t];if(2===n.g||1===n.g){if(!Array.isArray(t))throw Error(`The JavaScript value ${t} should be an array if it is to be converted to ${S(n)}.`);return t.map((e=>$e(n.type,e))).filter((e=>null!==e))}const r=$e(n.type,t);if(null===r)throw Error(`The JavaScript value ${t} should be a single entry if it is to be converted to ${S(n)}.`);return[r]}function Pe(e,t,n={type:59,g:0}){return $.create(Le(0,t,n))}var He=2**32;function je(e,t,n,r){return new ze({M:n,Aa:t,sa:r||e.sa,qa:e.qa},e.h,e.o)}function _e(e,t){let n=0;const r=t.value;return{next:a=>(a=r.next(a)).done?A:E(je(e,n++,a.value,t))}}function Xe(e){return e.h.hb||(e.h.hb=!0,e.h.ob=Ie((new Date).toISOString()),e.h.tb=ve("PT0S")),e.h.ob}function qe(e){return e.h.hb||(e.h.hb=!0,e.h.ob=Ie((new Date).toISOString()),e.h.tb=ve("PT0S")),e.h.tb}function Ve(e,t=null){return e=29421*(null!=t?t:e.o.h)%He,{pb:Math.floor(e),Yb:e/He}}function Ye(e,t){return new ze({M:e.M,Aa:e.Aa,sa:e.sa,qa:Object.assign(Object.create(null),e.qa,t)},e.h,e.o)}var ze=class{constructor(e,t={ob:null,tb:null,hb:!1},n=new class{constructor(){this.h=Math.abs(Math.floor(Math.random()*He)%He)}}){this.h=t,this.Aa=e.Aa,this.sa=e.sa,this.M=e.M,this.qa=e.qa||Object.create(null),this.o=n}},Je=class{constructor(e,t,n,r,a,o,s,i,l){this.debug=e,this.Ga=t,this.h=n,this.Ia=r,this.Ma=a,this.o=o,this.v=s,this.ib=i,this.Ua=l}};function Qe(e){let t=0,n=null,r=!0;return $.create({next:a=>{for(;t<e.length;){n||(n=e[t].value,r=!0);const o=n.next(r?0:a);if(r=!1,!o.done)return o;t++,n=null}return A}})}var Ke=(e,t,n)=>Error(`FORG0001: Cannot cast ${e} to ${C[t]}${n?`, ${n}`:""}`),We=e=>Error(`XPDY0002: ${e}`),Ze=e=>Error(`XPTY0004: ${e}`),et=e=>Error(`FOTY0013: Atomization is not supported for ${C[e]}.`),tt=e=>Error(`XPST0081: The prefix ${e} could not be resolved.`);function nt(e,t){if(T(e.type,46)||T(e.type,19)||T(e.type,0)||T(e.type,4)||T(e.type,3)||T(e.type,6)||T(e.type,5)||T(e.type,2)||T(e.type,23)||T(e.type,1))return $.create(e);const n=t.h;if(T(e.type,53)){const t=e.value;if(2===t.node.nodeType||3===t.node.nodeType)return $.create(y(Z(n,t),19));if(8===t.node.nodeType||7===t.node.nodeType)return $.create(y(Z(n,t),1));const r=[];return function e(a){if(8!==t.node.nodeType&&7!==t.node.nodeType){var o=a.nodeType;3===o||4===o?r.push(n.getData(a)):1!==o&&9!==o||n.getChildNodes(a).forEach((t=>{e(t)}))}}(t.node),$.create(y(r.join(""),19))}if(T(e.type,60)&&!T(e.type,62))throw et(e.type);if(T(e.type,62))return Qe(e.h.map((e=>rt(e(),t))));throw Error(`Atomizing ${e.type} is not implemented.`)}function rt(e,t){let n=!1;const r=e.value;let a=null;return $.create({next:()=>{for(;!n;){if(!a){var e=r.next(0);if(e.done){n=!0;break}a=nt(e.value,t).value}if(!(e=a.next(0)).done)return e;a=null}return A}})}function at(e){for(e=g[e];e&&0!==e.C;)e=e.parent;return e?e.type:null}function ot(e,t){const n=(t=g[t]).Ja;if(!n||!n.whiteSpace)return t.parent?ot(e,t.parent.type):e;switch(t.Ja.whiteSpace){case"replace":return e.replace(/[\u0009\u000A\u000D]/g," ");case"collapse":return e.replace(/[\u0009\u000A\u000D]/g," ").replace(/ {2,}/g," ").replace(/^ | $/g,"")}return e}function st(e,t){for(t=g[t];t&&null===t.fb;){if(2===t.C||3===t.C)return!0;t=t.parent}return!t||t.fb(e)}function it(e,t){for(;e;){if(e.Oa&&e.Oa[t])return e.Oa[t];e=e.parent}return()=>!0}function lt(e){return!e||(2===e.g||0===e.g)}function ct(e,t){return e(2)?e=>({u:!0,value:e}):e(0)?e=>({u:!0,value:e?1:0}):e(1)||e(19)?e=>{switch(e){case"NaN":return{u:!0,value:NaN};case"INF":case"+INF":return{u:!0,value:1/0};case"-INF":return{u:!0,value:-1/0};case"0":case"+0":return{u:!0,value:0};case"-0":return{u:!0,value:-0}}const n=parseFloat(e);return isNaN(n)?{u:!1,error:Ke(e,t)}:{u:!0,value:n}}:()=>({u:!1,error:Error(`XPTY0004: Casting not supported from given type to ${t} or any of its derived types.`)})}function ut(e){const t=Math.abs(e.ab());return(t?`${t}Y`:"")+(""+((e=Math.abs(e.$a()))?`${e}M`:""))||"0M"}var ht=class extends fe{constructor(e){if(super(),e>Number.MAX_SAFE_INTEGER||e<Number.MIN_SAFE_INTEGER)throw Error("FODT0002: Number of months given to construct YearMonthDuration overflows MAX_SAFE_INTEGER or MIN_SAFE_INTEGER");this.ea=e}$a(){const e=this.ea%12;return 0===e?0:e}h(){return this.ea}ab(){return Math.trunc(this.ea/12)}na(){return!Object.is(-0,this.ea)&&0<=this.ea}toString(){return(this.na()?"P":"-P")+ut(this)}},dt=e=>{var t=/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(?:T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.exec(e);if(t){if(e=!t[1],(t=12*(t[2]?parseInt(t[2],10):0)+(t[3]?parseInt(t[3],10):0))>Number.MAX_SAFE_INTEGER||!Number.isFinite(t))throw Error("FODT0002: Value overflow while constructing xs:yearMonthDuration");e=new ht(e||0===t?t:-t)}else e=null;return e};function pt(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot multiply xs:yearMonthDuration by NaN");if((e=Math.round(e.ea*t))>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while constructing xs:yearMonthDuration");return new ht(e<Number.MIN_SAFE_INTEGER||0===e?0:e)}var mt=class extends fe{constructor(e,t){super(),this.Va=e,this.Fa=t}Za(){return this.Fa.Za()}getHours(){return this.Fa.getHours()}getMinutes(){return this.Fa.getMinutes()}$a(){return this.Va.$a()}h(){return this.Va.h()}o(){return this.Fa.o()}getSeconds(){return this.Fa.getSeconds()}ab(){return this.Va.ab()}na(){return this.Va.na()&&this.Fa.na()}toString(){const e=this.na()?"P":"-P",t=ut(this.Va),n=ge(this.Fa);return"0M"===t?e+n:"T0S"===n?e+t:e+t+n}};const ft=[3,6,4,5];function gt(e){if(e(1)||e(19))return e=>({u:!0,value:e+""});if(e(20))return e=>({u:!0,value:e});if(e(23))return e=>({u:!0,value:e.prefix?`${e.prefix}:${e.localName}`:e.localName});if(e(44))return e=>({u:!0,value:e.toString()});if(e(2)){if(e(5)||e(4))return e=>({u:!0,value:(e+"").replace("e","E")});if(e(6)||e(3))return e=>isNaN(e)?{u:!0,value:"NaN"}:isFinite(e)?Object.is(e,-0)?{u:!0,value:"-0"}:{u:!0,value:(e+"").replace("e","E").replace("E+","E")}:{u:!0,value:(0>e?"-":"")+"INF"}}return e(9)||e(7)||e(8)||e(15)||e(14)||e(13)||e(12)||e(11)||e(16)||e(17)||e(18)?e=>({u:!0,value:e.toString()}):e(22)?e=>({u:!0,value:e.toUpperCase()}):e=>({u:!0,value:e+""})}const yt=[2,5,17,16];function wt(e,t){const n=t=>T(e,t);if(39===t)return()=>({u:!1,error:Error("FORG0001: Casting to xs:error is always invalid.")});switch(t){case 19:return function(e){const t=gt(e);return e=>(e=t(e)).u?{u:!0,value:y(e.value,19)}:e}(n);case 1:return function(e){const t=gt(e);return e=>(e=t(e)).u?{u:!0,value:y(e.value,1)}:e}(n);case 6:return function(e){const t=ct(e,6);return e=>(e=t(e)).u?{u:!0,value:y(e.value,6)}:e}(n);case 3:return function(e){const t=ct(e,3);return e=>(e=t(e)).u?{u:!0,value:y(e.value,3)}:e}(n);case 4:return function(e){return e(5)?e=>({u:!0,value:y(e,4)}):e(6)||e(3)?e=>isNaN(e)||!isFinite(e)?{u:!1,error:Error(`FOCA0002: Can not cast ${e} to xs:decimal`)}:Math.abs(e)>Number.MAX_VALUE?{u:!1,error:Error(`FOAR0002: Can not cast ${e} to xs:decimal, it is out of bounds for JavaScript numbers`)}:{u:!0,value:y(e,4)}:e(0)?e=>({u:!0,value:y(e?1:0,4)}):e(1)||e(19)?e=>{const t=parseFloat(e);return!isNaN(t)||isFinite(t)?{u:!0,value:y(t,4)}:{u:!1,error:Error(`FORG0001: Can not cast ${e} to xs:decimal`)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:decimal or any of its derived types.")})}(n);case 5:return function(e){return e(0)?e=>({u:!0,value:y(e?1:0,5)}):e(2)?e=>{const t=Math.trunc(e);return!isFinite(t)||isNaN(t)?{u:!1,error:Error(`FOCA0002: can not cast ${e} to xs:integer`)}:Number.isSafeInteger(t)?{u:!0,value:y(t,5)}:{u:!1,error:Error(`FOAR0002: can not cast ${e} to xs:integer, it is out of bounds for JavaScript numbers.`)}}:e(1)||e(19)?e=>{const t=parseInt(e,10);return isNaN(t)?{u:!1,error:Ke(e,5)}:Number.isSafeInteger(t)?{u:!0,value:y(t,5)}:{u:!1,error:Error(`FOCA0003: can not cast ${e} to xs:integer, it is out of bounds for JavaScript numbers.`)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:integer or any of its derived types.")})}(n);case 2:return function(e){var t=wt;return n=>{for(const r of ft){const a=t(e,r)(n);if(a.u)return a}return{u:!1,error:Error(`XPTY0004: Casting not supported from "${n}" given type to xs:numeric or any of its derived types.`)}}}(e);case 18:return function(e){return e(16)?e=>({u:!0,value:y(new mt(e,new ye(e.na()?0:-0)),18)}):e(17)?e=>({u:!0,value:y(e=new mt(new ht(e.na()?0:-0),e),18)}):e(18)?e=>({u:!0,value:y(e,18)}):e(19)||e(1)?e=>({u:!0,value:y(new mt(dt(e),ve(e)),18)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:duration or any of its derived types.")})}(n);case 16:return function(e){return e(18)&&!e(17)?e=>({u:!0,value:y(e.Va,16)}):e(17)?()=>({u:!0,value:y(dt("P0M"),16)}):e(19)||e(1)?e=>{const t=dt(e);return t?{u:!0,value:y(t,16)}:{u:!1,error:Ke(e,16)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:yearMonthDuration or any of its derived types.")})}(n);case 17:return function(e){return e(18)&&!e(16)?e=>({u:!0,value:y(e.Fa,17)}):e(16)?()=>({u:!0,value:y(ve("PT0.0S"),17)}):e(19)||e(1)?e=>{const t=ve(e);return t?{u:!0,value:y(t,17)}:{u:!1,error:Error(`FORG0001: Can not cast ${e} to xs:dayTimeDuration`)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:dayTimeDuration or any of its derived types.")})}(n);case 9:return function(e){return e(7)?e=>({u:!0,value:y(Ce(e,9),9)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),9)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:dateTime or any of its derived types.")})}(n);case 8:return function(e){return e(9)?e=>({u:!0,value:y(Ce(e,8),8)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),8)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:time or any of its derived types.")})}(n);case 7:return function(e){return e(9)?e=>({u:!0,value:y(Ce(e,7),7)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),7)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:date or any of its derived types.")})}(n);case 11:return function(e){return e(7)||e(9)?e=>({u:!0,value:y(Ce(e,11),11)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),11)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gYearMonth or any of its derived types.")})}(n);case 12:return function(e){return e(7)||e(9)?e=>({u:!0,value:y(Ce(e,12),12)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),12)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gYear or any of its derived types.")})}(n);case 13:return function(e){return e(7)||e(9)?e=>({u:!0,value:y(Ce(e,13),13)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),13)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gMonthDay or any of its derived types.")})}(n);case 15:return function(e){return e(7)||e(9)?e=>({u:!0,value:y(Ce(e,15),15)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),15)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gDay or any of its derived types.")})}(n);case 14:return function(e){return e(7)||e(9)?e=>({u:!0,value:y(Ce(e,14),14)}):e(19)||e(1)?e=>({u:!0,value:y(Ie(e),14)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gMonth or any of its derived types.")})}(n);case 0:return function(e){return e(2)?e=>({u:!0,value:0===e||isNaN(e)?v:w}):e(1)||e(19)?e=>{switch(e){case"true":case"1":return{u:!0,value:w};case"false":case"0":return{u:!0,value:v};default:return{u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:boolean or any of its derived types.")}}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:boolean or any of its derived types.")})}(n);case 21:return function(e){return e(22)?e=>{let t="";for(let n=0;n<e.length;n+=2)t+=String.fromCharCode(parseInt(e.substr(n,2),16));return{u:!0,value:y(btoa(t),21)}}:e(1)||e(19)?e=>({u:!0,value:y(e,21)}):()=>({error:Error("XPTY0004: Casting not supported from given type to xs:base64Binary or any of its derived types."),u:!1})}(n);case 22:return function(e){return e(21)?e=>{let t="";for(let n=0,r=(e=atob(e)).length;n<r;n++)t+=Number(e.charCodeAt(n)).toString(16);return{u:!0,value:y(t.toUpperCase(),22)}}:e(1)||e(19)?e=>({u:!0,value:y(e,22)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:hexBinary or any of its derived types.")})}(n);case 20:return function(e){return e(1)||e(19)?e=>({u:!0,value:y(e,20)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:anyURI or any of its derived types.")})}(n);case 23:throw Error("Casting to xs:QName is not implemented.")}return()=>({u:!1,error:Error(`XPTY0004: Casting not supported from ${e} to ${t}.`)})}const vt=Object.create(null);function xt(e,t){if(19===e&&1===t)return e=>({u:!0,value:y(e,1)});if(44===t)return()=>({u:!1,error:Error("XPST0080: Casting to xs:NOTATION is not permitted.")});if(39===t)return()=>({u:!1,error:Error("FORG0001: Casting to xs:error is not permitted.")});if(45===e||45===t)return()=>({u:!1,error:Error("XPST0080: Casting from or to xs:anySimpleType is not permitted.")});if(46===e||46===t)return()=>({u:!1,error:Error("XPST0080: Casting from or to xs:anyAtomicType is not permitted.")});if(T(e,60)&&1===t)return()=>({u:!1,error:Error("FOTY0014: Casting from function item to xs:string is not permitted.")});if(e===t)return e=>({u:!0,value:{type:t,value:e}});const n=yt.includes(e)?e:at(e),r=yt.includes(t)?t:at(t);if(null===r||null===n)return()=>({u:!1,error:Error(`XPST0081: Can not cast: type ${r?C[e]:C[t]} is unknown.`)});const a=[];return 1!==n&&19!==n||a.push((e=>{const n=ot(e,t);return st(n,t)?{u:!0,value:n}:{u:!1,error:Ke(e,t,"pattern validation failed.")}})),n!==r&&(a.push(wt(n,r)),a.push((e=>({u:!0,value:e.value})))),19!==r&&1!==r||a.push((e=>st(e,t)?{u:!0,value:e}:{u:!1,error:Ke(e,t,"pattern validation failed.")})),a.push((e=>function(e,t){let n=g[t];for(;n;){if(n.Ja&&!Object.keys(n.Ja).every((t=>{if("whiteSpace"===t)return!0;const r=it(n,t);return!r||r(e,n.Ja[t])})))return!1;n=n.parent}return!0}(e,t)?{u:!0,value:e}:{u:!1,error:Ke(e,t,"pattern validation failed.")})),a.push((e=>({u:!0,value:{type:t,value:e}}))),e=>{e={u:!0,value:e};for(let t=0,n=a.length;t<n&&(e=a[t](e.value),!1!==e.u);++t);return e}}function bt(e,t){const n=e.type+1e4*t;let r=vt[n];return r||=vt[n]=xt(e.type,t),r.call(void 0,e.value,t)}function At(e,t){if(!0===(e=bt(e,t)).u)return e.value;throw e.error}function Et(e){let t=!1;return{next:()=>t?A:(t=!0,E(e))}}function Nt(e,t){return e===t||!(!e||!t||e.offset!==t.offset||e.parent!==t.parent)&&Nt(e.F,t.F)}function Tt(e,t){return!!(e===t||e.node===t.node&&Nt(e.F,t.F))}function Bt(e,t){const n=[];for(;t;t=ne(e,t,null))n.unshift(t);return n}function It(e,t){const n=[];for(;t;t=e.getParentNode(t,null))n.unshift(t);return n}function Ct(e,t,n,r){if(n.F||r.F||z(n.node)||z(r.node)){if(Tt(n,r))return 0;n=Bt(t,n),r=Bt(t,r);const o=n[0],s=r[0];if(!Tt(o,s))return t=e.findIndex((e=>Tt(e,o))),n=e.findIndex((e=>Tt(e,s))),-1===t&&(t=e.push(o)),-1===n&&(n=e.push(s)),t-n;e=1;for(var a=Math.min(n.length,r.length);e<a&&Tt(n[e],r[e]);++e);return n[e]?r[e]?function(e,t,n){var r=ne(e,t,null);for(let a=0,o=(e=W(e,r,null)).length;a<o;++a){if(r=e[a],Tt(r,t))return-1;if(Tt(r,n))return 1}}(t,n[e],r[e]):1:-1}if((n=n.node)===(a=r.node))return 0;if(r=It(t,n),n=It(t,a),r[0]!==n[0]){const a={node:r[0],F:null},o={node:n[0],F:null};return t=e.findIndex((e=>Tt(e,a))),n=e.findIndex((e=>Tt(e,o))),-1===t&&(t=e.push(a)),-1===n&&(n=e.push(o)),t-n}for(e=1,a=Math.min(r.length,n.length);e<a&&r[e]===n[e];++e);if(r=r[e],a=n[e],!r)return-1;if(!a)return 1;for(let o=0,s=(t=t.getChildNodes(n[e-1],null)).length;o<s;++o){if(e=t[o],e===r)return-1;if(e===a)return 1}}function Ot(e,t,n,r){const a=T(n.type,47),o=T(r.type,47);if(a&&!o){if(Tt(n=ne(t,n.value),r=r.value))return 1}else if(o&&!a){if(Tt(n=n.value,r=ne(t,r.value)))return-1}else if(a&&o){if(Tt(ne(t,r.value),ne(t,n.value)))return n.value.node.localName>r.value.node.localName?1:-1;n=ne(t,n.value),r=ne(t,r.value)}else n=n.value,r=r.value;return Ct(e,t,n,r)}function St(e,t,n){return Ot(e.o,e,t,n)}function Ft(e,t){return kt(t,((t,n)=>Ot(e.o,e,t,n))).filter(((e,t,n)=>0===t||!Tt(e.value,n[t-1].value)))}const Dt=(e,t)=>e<t?-1:0;function kt(e,t=Dt){if(1>=e.length)return e;var n=Math.floor(e.length/2);const r=kt(e.slice(0,n),t);for(e=kt(e.slice(n),t),n=[];r.length&&e.length;)0>t(r[0],e[0])?n.push(r.shift()):n.push(e.shift());return n.concat(r.concat(e))}var Rt=e;function Mt(e,t,n,r,a){if(T(e.type,t.type))return e;if(T(t.type,46)&&T(e.type,53)&&(e=nt(e,n).first()),T(e.type,t.type)||46===t.type)return e;if(T(e.type,19)){if(!(n=At(e,t.type)))throw Error(`XPTY0004 Unable to convert ${a?"return":"argument"} of type ${C[e.type]} to type ${S(t)} while calling ${r}`);return n}if(n=function(e,t){if(T(e.type,2)){if(T(e.type,6))return 3===t?y(e.value,3):null;if(T(e.type,4)){if(6===t)return y(e.value,6);if(3===t)return y(e.value,3)}return null}return T(e.type,20)&&1===t?y(e.value,1):null}(e,t.type),!n)throw Error(`XPTY0004 Unable to cast ${a?"return":"argument"} of type ${C[e.type]} to type ${S(t)} while calling ${r}`);return n}function Ut(e){switch(e){case 2:return"*";case 1:return"+";case 0:return"?";case 3:return""}}var Gt=(e,t,n,r,a)=>0===e.g?t.Y({default:()=>t.map((t=>Mt(t,e,n,r,a))),multiple:()=>{throw Error(`XPTY0004: Multiplicity of ${a?"function return value":"function argument"} of type ${C[e.type]}${Ut(e.g)} for ${r} is incorrect. Expected "?", but got "+".`)}}):1===e.g?t.Y({empty:()=>{throw Error(`XPTY0004: Multiplicity of ${a?"function return value":"function argument"} of type ${C[e.type]}${Ut(e.g)} for ${r} is incorrect. Expected "+", but got "empty-sequence()"`)},default:()=>t.map((t=>Mt(t,e,n,r,a)))}):2===e.g?t.map((t=>Mt(t,e,n,r,a))):t.Y({m:()=>t.map((t=>Mt(t,e,n,r,a))),default:()=>{throw Error(`XPTY0004: Multiplicity of ${a?"function return value":"function argument"} of type ${C[e.type]}${Ut(e.g)} for ${r} is incorrect. Expected exactly one`)}});function $t(e,t){return T(e,5)?y(t,5):T(e,6)?y(t,6):T(e,3)?y(t,3):y(t,4)}const Lt=[{la:"M",ja:1e3},{la:"CM",ja:900},{la:"D",ja:500},{la:"CD",ja:400},{la:"C",ja:100},{la:"XC",ja:90},{la:"L",ja:50},{la:"XL",ja:40},{la:"X",ja:10},{la:"IX",ja:9},{la:"V",ja:5},{la:"IV",ja:4},{la:"I",ja:1}];function Pt(e,t){const n=0>e;if(!(e=Math.abs(e)))return"-";let r=Lt.reduce(((t,n)=>{const r=Math.floor(e/n.ja);return e-=r*n.ja,t+n.la.repeat(r)}),"");return t&&(r=r.toLowerCase()),n&&(r=`-${r}`),r}const Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");function jt(e,t){const n=0>e;if(!(e=Math.abs(e)))return"-";let r,a="";for(;0<e;)r=(e-1)%Ht.length,a=Ht[r]+a,e=(e-r)/Ht.length|0;return t&&(a=a.toLowerCase()),n&&(a=`-${a}`),a}function _t(e,t,n=[]){return Array.from({length:t},((t,n)=>n+e)).filter((e=>!n.includes(e)))}const Xt=_t(1488,27,[1498,1501,1503,1507,1509]),qt=_t(1575,36,[1577,1595,1596,1597,1598,1599,1600,1609]),Vt="أبجدهوزحطيكلمنسعفصقرشتثخذضظغ".split(""),Yt=[[1e3,"غ"],[900,"ظ"],[800,"ض"],[700,"ذ"],[600,"خ"],[500,"ث"],[400,"ت"],[300,"ش"],[200,"ر"],[100,"ق"],[90,"ص"],[80,"ف"],[70,"ع"],[60,"س"],[50,"ن"],[40,"م"],[30,"ل"],[20,"ك"],[10,"ي"],[9,"ط"],[8,"ح"],[7,"ز"],[6,"و"],[5,"ه"],[4,"د"],[3,"ج"],[2,"ب"],[1,"أ"]],zt=[[400,"ת"],[300,"ש"],[200,"ר"],[100,"ק"],[90,"צ"],[80,"פ"],[70,"ע"],[60,"ס"],[50,"נ"],[40,"מ"],[30,"ל"],[20,"כ"],[10,"י"],[9,"ט"],[8,"ח"],[7,"ז"],[6,"ו"],[5,"ה"],[4,"ד"],[3,"ג"],[2,"ב"],[1,"א"]];function Jt(e,t=[]){var n=25;return t.sort(((e,t)=>e-t)),n-=t.length,function(r){const a=0>r;if(!(r=Math.abs(r)))return"-";const o=[];for(;0<r;){let a=e+(r-1)%n;t.forEach((e=>{a>=e&&a++})),o.unshift(String.fromCodePoint(a)),r=Math.floor((r-1)/n)}return r=o.join(""),a&&(r=`-${r}`),r}}const Qt=Jt(945,[962]),Kt=Jt(913,[930]);function Wt(e){return new Intl.NumberFormat([],{numberingSystem:"arab",useGrouping:!1}).format(e)}function Zt(e){return new Intl.NumberFormat([],{numberingSystem:"arabext",useGrouping:!1}).format(e)}const en=new Map([["A",function(e){return jt(e,!1)}],["a",function(e){return jt(e,!0)}],["I",function(e){return Pt(e,!1)}],["i",function(e){return Pt(e,!0)}],["lowerGreek",Qt],["α",Qt],["upperGreek",Kt],["Α",Kt],["arabicAbjadi",function(e){const t=0>e;return(e=Math.abs(e))?(e=Array(Math.floor((e-1)/Vt.length)+1).fill(Vt[(e-1)%Vt.length]).join(String.fromCodePoint(8204)),t&&(e=`-${e}`),e):"-"}],["arabicAbjadNumeral",function(e){const t=0>e;if(!(e=Math.abs(e)))return"-";var n=[],r=Math.floor(e/1e3);if(e-=1e3*r,1===r)n.push(Yt[0][1]);else if(1<r){for(const[e,t]of Yt){var a=e;const o=t;for(;r>=a;)n.push(o),r-=a}n.push(Yt[0][1])}for(const[t,o]of Yt)for(r=t,a=o;e>=r;)e-=r,n.push(a);return n=n.join(""),t&&(n=`-${n}`),n}],["arabicAlifBaTa",function(e){const t=0>e;return(e=Math.abs(e))?(e=Array(Math.floor((e-1)/qt.length)+1).fill(String.fromCodePoint(qt[(e-1)%qt.length])).join(String.fromCodePoint(8204)),t&&(e=`-${e}`),e):"-"}],["hebrewAlefBet",function(e){const t=0>e;if(!(e=Math.abs(e)))return"-";var n=Math.floor((e-1)/Xt.length);const r=String.fromCodePoint(1514);return(n=Array(n).fill(r)).push(String.fromCodePoint(Xt[(e-1)%Xt.length])),e=n.join(""),t&&(e=`-${e}`),e}],["hebrewNumeral",function(e){const t=0>e;if(!(e=Math.abs(e)))return"-";var n=[],r=Math.floor(e/400);e-=400*r;for(var a=0;a<r;a++)n.push("ת");for(const[t,o]of zt)for(r=t,a=o;e>=r;)e-=r,n.push(a);return"יה"===(e=n.slice(-2).join(""))&&n.splice(-2,2,"ט","ו"),"יו"===e&&n.splice(-2,2,"ט","ז"),n=n.join(""),t&&(n=`-${n}`),n}],["arabicIndicNumeral",Wt],["١",Wt],["٢",Wt],["٣",Wt],["٤",Wt],["٥",Wt],["٦",Wt],["٧",Wt],["٨",Wt],["٩",Wt],["persianNumeral",Zt],["۱",Zt],["۲",Zt],["۳",Zt],["۴",Zt],["۵",Zt],["۶",Zt],["۷",Zt],["۸",Zt],["۹",Zt]]);function tn(e,t,n,r,a,o){let s=!1;return $.create({next:()=>{if(s)return A;const t=a.first();if(!t)return s=!0,A;if((T(t.type,6)||T(t.type,3))&&(0===t.value||isNaN(t.value)||1/0===t.value||-1/0===t.value))return s=!0,E(t);var n;if(n=o?o.first().value:0,s=!0,function(e){if(Math.floor(e)===e||isNaN(e))return 0;const t=(e=/\d+(?:\.(\d*))?(?:[Ee](-)?(\d+))*/.exec(`${e}`))[1]?e[1].length:0;return e[3]?e[2]?t+parseInt(e[3],10):0>(e=t-parseInt(e[3],10))?0:e:t}(t.value)<n)return E(t);const r=[5,4,3,6].find((e=>T(t.type,e)));switch(n=function(e,t,n){return t&&0==e*n%1%.5?0==Math.floor(e*n)%2?Math.floor(e*n)/n:Math.ceil(e*n)/n:Math.round(e*n)/n}(At(t,4).value,e,Math.pow(10,n)),r){case 4:return E(y(n,4));case 3:return E(y(n,3));case 6:return E(y(n,6));case 5:return E(y(n,5))}}})}const nn=(e,t,n,r)=>rt(r,t).Y({empty:()=>$.m(y(NaN,3)),m:()=>{const e=bt(r.first(),3);return e.u?$.m(e.value):$.m(y(NaN,3))},multiple:()=>{throw Error("fn:number may only be called with zero or one values")}});const rn=(e,t,n,r=$.empty())=>(t=r.G()?Ve(e):Ve(e,function(e){let t=5381;for(let n=0;n<e.length;++n)t=33*t+e.charCodeAt(n),t%=Number.MAX_SAFE_INTEGER;return t}(At(r.first(),1).value)),function t(n){const r=(t,r,a,o)=>{if(o.G()||o.ua())return o;for(t=o.O(),r=n,a=t.length-1;1<a;a--){const n=t[o=(r=Ve(e,r).pb)%a];t[o]=t[a],t[a]=n}return $.create(t)};return $.m(new pe([{key:y("number",1),value:()=>$.m(y(Ve(e,n).Yb,3))},{key:y("next",1),value:()=>$.m(new H({value:()=>t(Ve(e,n).pb),Xa:!0,localName:"",namespaceURI:"",j:[],arity:0,i:{type:61,g:3}}))},{key:y("permute",1),value:()=>$.m(new H({value:r,Xa:!0,localName:"",namespaceURI:"",j:[{type:59,g:2}],arity:1,i:{type:59,g:2}}))}]))}(t.pb));var an=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"abs",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:(e,t,n,r)=>r.map((e=>$t(e.type,Math.abs(e.value))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"format-integer",j:[{type:5,g:0},{type:1,g:3}],i:{type:1,g:3},callFunction:(e,t,n,r,a)=>(e=r.first(),a=a.first(),r.G()?$.m(y("",1)):(r=en.get(a.value),a=e.value,r?(r=r(a),$.m(y(r,1))):$.m(y(a.toString(),1))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"ceiling",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:(e,t,n,r)=>r.map((e=>$t(e.type,Math.ceil(e.value))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"floor",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:(e,t,n,r)=>r.map((e=>$t(e.type,Math.floor(e.value))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:tn.bind(null,!1)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round",j:[{type:2,g:0},{type:5,g:3}],i:{type:2,g:0},callFunction:tn.bind(null,!1)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round-half-to-even",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:tn.bind(null,!0)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round-half-to-even",j:[{type:2,g:0},{type:5,g:3}],i:{type:2,g:0},callFunction:tn.bind(null,!0)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"number",j:[{type:46,g:0}],i:{type:3,g:3},callFunction:nn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"number",j:[],i:{type:3,g:3},callFunction:(e,t,n)=>{const r=e.M&&Gt({type:46,g:0},$.m(e.M),t,"fn:number",!1);if(!r)throw We("fn:number needs an atomizable context item.");return nn(0,t,0,r)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"random-number-generator",j:[],i:{type:61,g:3},callFunction:rn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"random-number-generator",j:[{type:46,g:0}],i:{type:61,g:3},callFunction:rn}];function on(){throw Error("FOCH0002: No collations are supported")}function sn(e,t,n,r){if(null===t.M)throw We("The function which was called depends on dynamic context, which is absent.");return e(t,n,r,$.m(t.M))}const ln=(e,t,n,r)=>r.Y({empty:()=>$.m(y("",1)),default:()=>r.map((e=>{if(T(e.type,53)){const n=nt(e,t).first();return T(e.type,47)?At(n,1):n}return At(e,1)}))}),cn=(e,t,n,r,a)=>ue([a],(([e])=>rt(r,t).N((t=>(t=t.map((e=>At(e,1).value)).join(e.value),$.m(y(t,1))))))),un=(e,t,n,r)=>r.G()?$.m(y(0,5)):(e=r.first().value,$.m(y(Array.from(e).length,5))),hn=(e,t,n,r,a,o)=>{const s=tn(!1,0,0,0,a,null),i=null!==o?tn(!1,0,0,0,o,null):null;let l=!1,c=null,u=null,h=null;return $.create({next:()=>l?A:c||(c=r.first(),null!==c)?(u||=s.first(),!h&&o&&(h=null,h=i.first()),l=!0,E(y(Array.from(c.value).slice(Math.max(u.value-1,0),o?u.value+h.value-1:void 0).join(""),1))):(l=!0,E(y("",1)))})},dn=(e,t,n,r,a)=>r.G()||0===r.first().value.length?$.empty():(e=r.first().value,a=gn(a=a.first().value),$.create(e.split(a).map((e=>y(e,1))))),pn=(e,t,n,r)=>r.G()?$.m(y("",1)):(e=r.first().value.trim(),$.m(y(e.replace(/\s+/g," "),1))),mn=new Map,fn=new Map;function gn(e){if(fn.has(e))return fn.get(e);let t;try{t=new RegExp(e,"g")}catch(e){throw Error(`FORX0002: ${e}`)}if(t.test(""))throw Error(`FORX0003: the pattern ${e} matches the zero length string`);return fn.set(e,t),t}var yn=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"compare",j:[{type:1,g:0},{type:1,g:0}],i:{type:5,g:0},callFunction:(e,t,n,r,a)=>r.G()||a.G()?$.empty():(e=r.first().value)>(a=a.first().value)?$.m(y(1,5)):e<a?$.m(y(-1,5)):$.m(y(0,5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"compare",j:[{type:1,g:0},{type:1,g:0},{type:1,g:3}],i:{type:5,g:0},callFunction:on},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"concat",j:[{type:46,g:0},{type:46,g:0},4],i:{type:1,g:3},callFunction:(e,t,n,...r)=>(r=r.map((e=>rt(e,t).N((e=>$.m(y(e.map((e=>null===e?"":At(e,1).value)).join(""),1)))))),ue(r,(e=>$.m(y(e.map((e=>e.value)).join(""),1)))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"contains",j:[{type:1,g:0},{type:1,g:0},{type:1,g:0}],i:{type:0,g:3},callFunction:on},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"contains",j:[{type:1,g:0},{type:1,g:0}],i:{type:0,g:3},callFunction:(e,t,n,r,a)=>(e=r.G()?"":r.first().value,0===(a=a.G()?"":a.first().value).length?$.aa():0===e.length?$.V():e.includes(a)?$.aa():$.V())},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"ends-with",j:[{type:1,g:0},{type:1,g:0}],i:{type:0,g:3},callFunction:(e,t,n,r,a)=>0===(e=a.G()?"":a.first().value).length?$.aa():0===(r=r.G()?"":r.first().value).length?$.V():r.endsWith(e)?$.aa():$.V()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"ends-with",j:[{type:1,g:0},{type:1,g:0},{type:1,g:3}],i:{type:0,g:3},callFunction:on},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"normalize-space",j:[{type:1,g:0}],i:{type:1,g:3},callFunction:pn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"normalize-space",j:[],i:{type:1,g:3},callFunction:sn.bind(null,((e,t,n,r)=>pn(e,0,0,ln(0,t,0,r))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"starts-with",j:[{type:1,g:0},{type:1,g:0}],i:{type:0,g:3},callFunction:(e,t,n,r,a)=>0===(e=a.G()?"":a.first().value).length?$.aa():0===(r=r.G()?"":r.first().value).length?$.V():r.startsWith(e)?$.aa():$.V()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"starts-with",j:[{type:1,g:0},{type:1,g:0},{type:1,g:3}],i:{type:0,g:3},callFunction:on},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string",j:[{type:59,g:0}],i:{type:1,g:3},callFunction:ln},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string",j:[],i:{type:1,g:3},callFunction:sn.bind(null,ln)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring-before",j:[{type:1,g:0},{type:1,g:0}],i:{type:1,g:3},callFunction:(e,t,n,r,a)=>(e=r.G()?"":r.first().value,""===(a=a.G()?"":a.first().value)||-1===(a=e.indexOf(a))?$.m(y("",1)):$.m(y(e.substring(0,a),1)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring-after",j:[{type:1,g:0},{type:1,g:0}],i:{type:1,g:3},callFunction:(e,t,n,r,a)=>(e=r.G()?"":r.first().value,""===(a=a.G()?"":a.first().value)?$.m(y(e,1)):-1===(t=e.indexOf(a))?$.m(y("",1)):$.m(y(e.substring(t+a.length),1)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring",j:[{type:1,g:0},{type:3,g:3}],i:{type:1,g:3},callFunction:hn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring",j:[{type:1,g:0},{type:3,g:3},{type:3,g:3}],i:{type:1,g:3},callFunction:hn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"upper-case",j:[{type:1,g:0}],i:{type:1,g:3},callFunction:(e,t,n,r)=>r.G()?$.m(y("",1)):r.map((e=>y(e.value.toUpperCase(),1)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"lower-case",j:[{type:1,g:0}],i:{type:1,g:3},callFunction:(e,t,n,r)=>r.G()?$.m(y("",1)):r.map((e=>y(e.value.toLowerCase(),1)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-join",j:[{type:46,g:2},{type:1,g:3}],i:{type:1,g:3},callFunction:cn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-join",j:[{type:46,g:2}],i:{type:1,g:3},callFunction:(e,t,n,r)=>cn(0,t,0,r,$.m(y("",1)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-length",j:[{type:1,g:0}],i:{type:5,g:3},callFunction:un},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-length",j:[],i:{type:5,g:3},callFunction:sn.bind(null,((e,t,n,r)=>un(e,0,0,ln(0,t,0,r))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"tokenize",j:[{type:1,g:0},{type:1,g:3},{type:1,g:3}],i:{type:1,g:2},callFunction(){throw Error("Not implemented: Using flags in tokenize is not supported")}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"tokenize",j:[{type:1,g:0},{type:1,g:3}],i:{type:1,g:2},callFunction:dn},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"tokenize",j:[{type:1,g:0}],i:{type:1,g:2},callFunction:(e,t,n,r)=>dn(e,0,0,pn(e,0,0,r),$.m(y(" ",1)))},{j:[{type:1,g:0},{type:1,g:3},{type:1,g:3}],callFunction:(e,t,n,r,a,o)=>ue([r,a,o],(([e,t,n])=>{e=Array.from(e?e.value:"");const r=Array.from(t.value),a=Array.from(n.value);return t=e.map((e=>r.includes(e)?(e=r.indexOf(e))<=a.length?a[e]:void 0:e)),$.m(y(t.join(""),1))})),localName:"translate",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:5,g:2}],callFunction:(e,t,n,r)=>r.N((e=>(e=e.map((e=>{if(9===(e=e.value)||10===e||13===e||32<=e&&55295>=e||57344<=e&&65533>=e||65536<=e&&1114111>=e)return String.fromCodePoint(e);throw Error("FOCH0001")})).join(""),$.m(y(e,1))))),localName:"codepoints-to-string",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:1,g:0}],callFunction:(e,t,n,r)=>ue([r],(([e])=>0===(e=e?e.value.split(""):[]).length?$.empty():$.create(e.map((e=>y(e.codePointAt(0),5)))))),localName:"string-to-codepoints",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:2}},{j:[{type:1,g:0}],callFunction:(e,t,n,r)=>ue([r],(([e])=>null===e||0===e.value.length?$.create(y("",1)):$.create(y(encodeURIComponent(e.value).replace(/[!'()*]/g,(e=>"%"+e.charCodeAt(0).toString(16).toUpperCase())),1)))),localName:"encode-for-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:1,g:0}],callFunction:(e,t,n,r)=>ue([r],(([e])=>null===e||0===e.value.length?$.create(y("",1)):$.create(y(e.value.replace(/([\u00A0-\uD7FF\uE000-\uFDCF\uFDF0-\uFFEF "<>{}|\\^`/\n\u007f\u0080-\u009f]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g,(e=>encodeURI(e))),1)))),localName:"iri-to-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:1,g:0},{type:1,g:0}],callFunction:(e,t,n,r,a)=>ue([r,a],(([e,t])=>{if(null===e||null===t)return $.empty();e=e.value;var n=t.value;if(e.length!==n.length)return $.V();for(t=e.split(""),e=n.split(""),n=0;n<t.length;n++)if(t[n].codePointAt(0)!==e[n].codePointAt(0))return $.V();return $.aa()})),localName:"codepoint-equal",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:0}},{j:[{type:1,g:0},{type:1,g:3}],callFunction:(e,t,n,r,a)=>ue([r,a],(([e,t])=>{e=e?e.value:"",t=t.value;let n=mn.get(t);if(!n){try{n=(0,Rt.compile)(t,{language:"xpath"})}catch(e){throw Error(`FORX0002: ${e}`)}mn.set(t,n)}return n(e)?$.aa():$.V()})),localName:"matches",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:1,g:0},{type:1,g:3},{type:1,g:3}],callFunction:(e,t,n,r,a,o)=>ue([r,a,o],(([e,t,n])=>{if(e=e?e.value:"",t=t.value,(n=n.value).includes("$0"))throw Error("Using $0 in fn:replace to replace substrings with full matches is not supported.");return n=n.split(/((?:\$\$)|(?:\\\$)|(?:\\\\))/).map((e=>{switch(e){case"\\$":return"$$";case"\\\\":return"\\";case"$$":throw Error('FORX0004: invalid replacement: "$$"');default:return e}})).join(""),t=gn(t),e=e.replace(t,n),$.m(y(e,1))})),localName:"replace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:1,g:0},{type:1,g:3},{type:1,g:3},{type:1,g:3}],localName:"replace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3},callFunction(){throw Error("Not implemented: Using flags in replace is not supported")}}];function wn(e,t,n,r,a){if(null===n.M)throw We(`The function ${e} depends on dynamic context, which is absent.`);return t(n,r,a,$.m(n.M))}const vn=(e,t,n,r)=>ue([r],(([e])=>{if(null===e)return $.empty();switch((e=e.value).node.nodeType){case 1:case 2:return $.m(y(new P(e.node.prefix,e.node.namespaceURI,e.node.localName),23));case 7:return $.m(y(new P("","",e.node.target),23));default:return $.empty()}})),xn=(e,t,n,r)=>r.Y({default:()=>ln(0,t,0,vn(0,0,0,r)),empty:()=>$.m(y("",1))}),bn=(e,t,n,r)=>rt(r,t),An=(e,t,n,r)=>ue([r],(([e])=>null!==(e=e?e.value:null)&&ee(t.h,e,null)?$.aa():$.V())),En=(e,t,n,r)=>ue([r],(([e])=>{function n(e){let t=0,n=e;for(;null!==n;)(e.node.nodeType!==n.node.nodeType?0:1===n.node.nodeType?n.node.localName===e.node.localName&&n.node.namespaceURI===e.node.namespaceURI:7===n.node.nodeType?n.node.target===e.node.target:1)&&t++,n=ae(r,n,null);return t}if(null===e)return $.empty();const r=t.h;let a="";for(e=e.value;null!==ne(t.h,e,null);e=ne(t.h,e,null))switch(e.node.nodeType){case 1:var o=e;a=`/Q{${o.node.namespaceURI||""}}${o.node.localName}[${n(o)}]${a}`;break;case 2:a=`/@${(o=e).node.namespaceURI?`Q{${o.node.namespaceURI}}`:""}${o.node.localName}${a}`;break;case 3:a=`/text()[${n(e)}]${a}`;break;case 7:a=`/processing-instruction(${(o=e).node.target})[${n(o)}]${a}`;break;case 8:a=`/comment()[${n(e)}]${a}`}return 9===e.node.nodeType?$.create(y(a||"/",1)):$.create(y("Q{http://www.w3.org/2005/xpath-functions}root()"+a,1))})),Nn=(e,t,n,r)=>r.map((e=>y(e.value.node.namespaceURI||"",20))),Tn=(e,t,n,r)=>r.Y({default:()=>r.map((e=>7===e.value.node.nodeType?y(e.value.node.target,1):y(e.value.node.localName||"",1))),empty:()=>$.m(y("",1))});function Bn(e,t,n){if(2===t.node.nodeType)return Tt(t,n);for(;n;){if(Tt(t,n))return!0;if(9===n.node.nodeType)break;n=ne(e,n,null)}return!1}const In=(e,t,n,r)=>r.map((e=>{if(!T(e.type,53))throw Error("XPTY0004 Argument passed to fn:root() should be of the type node()");let n;for(e=e.value;e;)n=e,e=ne(t.h,n,null);return ce(n)}));var Cn=[{j:[{type:53,g:0}],callFunction:xn,localName:"name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[],callFunction:wn.bind(null,"name",xn),localName:"name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:53,g:3}],callFunction:Nn,localName:"namespace-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:20,g:3}},{j:[],callFunction:wn.bind(null,"namespace-uri",Nn),localName:"namespace-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:20,g:3}},{j:[{type:53,g:2}],callFunction:(e,t,n,r)=>r.N((e=>e.length?(e=Ft(t.h,e).reduceRight(((e,n,r,a)=>r===a.length-1?(e.push(n),e):(Bn(t.h,n.value,e[0].value)||e.unshift(n),e)),[]),$.create(e)):$.empty())),localName:"innermost",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:2}},{j:[{type:53,g:2}],callFunction:(e,t,n,r)=>r.N((e=>e.length?(e=Ft(t.h,e).reduce(((e,n,r)=>0===r?(e.push(n),e):(Bn(t.h,e[e.length-1].value,n.value)||e.push(n),e)),[]),$.create(e)):$.empty()),1),localName:"outermost",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:2}},{j:[{type:53,g:0}],callFunction:An,localName:"has-children",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[],callFunction:wn.bind(null,"has-children",An),localName:"has-children",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:53,g:0}],callFunction:En,localName:"path",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:0}},{j:[],callFunction:wn.bind(null,"path",En),localName:"path",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:0}},{j:[{type:53,g:0}],callFunction:vn,localName:"node-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[],callFunction:wn.bind(null,"node-name",vn),localName:"node-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[{type:53,g:0}],callFunction:Tn,localName:"local-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[],callFunction:wn.bind(null,"local-name",Tn),localName:"local-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:53,g:0}],callFunction:In,localName:"root",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:0}},{j:[],callFunction:wn.bind(null,"root",In),localName:"root",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:0}},{j:[],callFunction:wn.bind(null,"data",bn),localName:"data",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}},{j:[{type:59,g:2}],callFunction:bn,localName:"data",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}}];function On(e,t){let n=0;const r=e.length;let a=!1,o=null;return{next:()=>{if(!a){for(;n<r;){o||=t(e[n],n,e);const r=o.next(0);if(o=null,!r.value)return E(!1);n++}return a=!0,E(!0)}return A}}}function Sn(e){return 1===(e=e.node.nodeType)||3===e}function Fn(e,t){if((T(e.type,4)||T(e.type,6))&&(T(t.type,4)||T(t.type,6))){var n=At(e,6),r=At(t,6);return n.value===r.value||isNaN(e.value)&&isNaN(t.value)}return(T(e.type,4)||T(e.type,6)||T(e.type,3))&&(T(t.type,4)||T(t.type,6)||T(t.type,3))?(n=At(e,3),r=At(t,3),n.value===r.value||isNaN(e.value)&&isNaN(t.value)):T(e.type,23)&&T(t.type,23)?e.value.namespaceURI===t.value.namespaceURI&&e.value.localName===t.value.localName:(T(e.type,9)||T(e.type,7)||T(e.type,8)||T(e.type,11)||T(e.type,12)||T(e.type,13)||T(e.type,14)||T(e.type,15))&&(T(t.type,9)||T(t.type,7)||T(t.type,8)||T(t.type,11)||T(t.type,12)||T(t.type,13)||T(t.type,14)||T(t.type,15))?De(e.value,t.value):(T(e.type,16)||T(e.type,17)||T(e.type,18))&&(T(t.type,16)||T(t.type,17)||T(t.type,17))?me(e.value,t.value):e.value===t.value}function Dn(e,t,n){const[r,a]=[t,n].map((t=>({type:1,value:t.reduce(((t,n)=>t+nt(n,e).first().value),"")})));return E(Fn(r,a))}function kn(e,t,n,r){for(;e.value&&T(e.value.type,56);){t.push(e.value);const a=re(r,e.value.value);if(e=n.next(0),a&&3!==a.node.nodeType)break}return e}function Rn(e,t,n,r,a){const o=t.h,s=r.value,i=a.value;let l,c=null,u=null,h=null;const d=[],p=[];return{next:()=>{for(;!l;)if(c||=s.next(0),c=kn(c,d,s,o),u||=i.next(0),u=kn(u,p,i,o),d.length||p.length){var r=Dn(t,d,p);if(d.length=0,p.length=0,!1===r.value)return l=!0,r}else{if(c.done||u.done)return l=!0,E(c.done===u.done);if(h||=Un(e,t,n,c.value,u.value),r=h.next(0),h=null,!1===r.value)return l=!0,r;u=c=null}return A}}}function Mn(e,t,n,r,a){return r=W(t.h,r.value),a=W(t.h,a.value),r=r.filter((e=>Sn(e))),a=a.filter((e=>Sn(e))),r=$.create(r.map((e=>ce(e)))),a=$.create(a.map((e=>ce(e)))),Rn(e,t,n,r,a)}function Un(e,t,n,r,a){if(T(r.type,46)&&T(a.type,46))return Et(Fn(r,a));if(T(r.type,61)&&T(a.type,61))return function(e,t,n,r,a){return r.h.length!==a.h.length?Et(!1):On(r.h,(r=>{const o=a.h.find((e=>Fn(e.key,r.key)));return o?Rn(e,t,n,r.value(),o.value()):Et(!1)}))}(e,t,n,r,a);if(T(r.type,62)&&T(a.type,62))return function(e,t,n,r,a){return r.h.length!==a.h.length?Et(!1):On(r.h,((r,o)=>(o=a.h[o],Rn(e,t,n,r(),o()))))}(e,t,n,r,a);if(T(r.type,53)&&T(a.type,53)){if(T(r.type,55)&&T(a.type,55))return Mn(e,t,n,r,a);if(T(r.type,54)&&T(a.type,54))return function(e,t,n,r,a){const o=Rn(e,t,n,vn(0,0,0,$.m(r)),vn(0,0,0,$.m(a))),s=Mn(e,t,n,r,a);r=Q(t.h,r.value).filter((e=>"http://www.w3.org/2000/xmlns/"!==e.node.namespaceURI)).sort(((e,t)=>e.node.nodeName>t.node.nodeName?1:-1)).map((e=>ce(e))),a=Q(t.h,a.value).filter((e=>"http://www.w3.org/2000/xmlns/"!==e.node.namespaceURI)).sort(((e,t)=>e.node.nodeName>t.node.nodeName?1:-1)).map((e=>ce(e)));const i=Rn(e,t,n,$.create(r),$.create(a));let l=!1;return{next:()=>{if(l)return A;var e=o.next(0);return!e.done&&!1===e.value||!(e=i.next(0)).done&&!1===e.value?(l=!0,e):(e=s.next(0),l=!0,e)}}}(e,t,n,r,a);if(T(r.type,47)&&T(a.type,47)||T(r.type,57)&&T(a.type,57)||T(r.type,58)&&T(a.type,58))return function(e,t,n,r,a){const o=Rn(e,t,n,vn(0,0,0,$.m(r)),vn(0,0,0,$.m(a)));let s=!1;return{next:()=>{if(s)return A;const e=o.next(0);return e.done||!1!==e.value?E(Fn(nt(r,t).first(),nt(a,t).first())):(s=!0,e)}}}(e,t,n,r,a)}return Et(!1)}var Gn=class extends ze{constructor(){super({M:null,Aa:-1,sa:$.empty(),qa:{}})}},$n=(e="Can not execute an updating expression in a non-updating context.")=>Error(`XUST0001: ${e}`),Ln=e=>Error(`XUTY0004: The attribute ${e.name}="${e.value}" follows a node that is not an attribute node.`),Pn=()=>Error("XUTY0005: The target of a insert expression with into must be a single element or document node."),Hn=()=>Error("XUTY0006: The target of a insert expression with before or after must be a single element, text, comment, or processing instruction node."),jn=()=>Error("XUTY0008: The target of a replace expression must be a single element, attribute, text, comment, or processing instruction node."),_n=()=>Error("XUTY0012: The target of a rename expression must be a single element, attribute, or processing instruction node."),Xn=e=>Error(`XUDY0017: The target ${e.outerHTML} is used in more than one replace value of expression.`),qn=e=>Error(`XUDY0021: Applying the updates will result in the XDM instance violating constraint: '${e}'`),Vn=e=>Error(`XUDY0023: The namespace binding ${e} is conflicting.`),Yn=e=>Error(`XUDY0024: The namespace binding ${e} is conflicting.`),zn=()=>Error("XUDY0027: The target for an insert, replace, or rename expression expression should not be empty.");function Jn(e,t,n){return t&&null!==t.M&&e.B?(null===e.nb&&(e.nb=L(e.h(new Gn,n).gb())),e=e.nb()):e=e.h(t,n),e}var Qn=class{constructor(e,t,n={B:!1,W:!1,P:"unsorted",subtree:!1},r=!1,a){this.o=e,this.ia=n.P||"unsorted",this.subtree=!!n.subtree,this.W=!!n.W,this.B=!!n.B,this.Ka=t,this.J=!1,this.nb=null,this.Nb=r,this.type=a}D(){return null}v(e){if(this.Ka.forEach((t=>t.v(e))),!this.Nb&&this.Ka.some((e=>e.J)))throw $n()}},Kn=class{constructor(e,t){this.I=e,this.da=t}},Wn=class{constructor(e){e&&"object"==typeof e&&"nodeType"in e&&("function"==typeof(e=e.ownerDocument||e).createElementNS&&"function"==typeof e.createProcessingInstruction&&"function"==typeof e.createTextNode&&"function"==typeof e.createComment&&(this.h=e)),this.h||(this.h=null)}createAttributeNS(e,t){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createAttributeNS(e,t)}createCDATASection(e){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createCDATASection(e)}createComment(e){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createComment(e)}createDocument(){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.implementation.createDocument(null,null,null)}createElementNS(e,t){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createElementNS(e,t)}createProcessingInstruction(e,t){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createProcessingInstruction(e,t)}createTextNode(e){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createTextNode(e)}};function Zn(e,t,n,r){return Q(r,e,`name-${t}`).some((e=>e.node.localName===t&&e.node.namespaceURI===n))}var er=(e,t,n)=>{t.forEach((t=>{n.insertBefore(e.node,t.node,null)}))},tr=(e,t,n,r)=>{const a=ne(n,e);var o=e.node.nodeType;if(2===o){if(t.some((e=>2!==e.node.nodeType)))throw Error('Constraint "If $target is an attribute node, $replacement must consist of zero or more attribute nodes." failed.');const o=a?a.node:null;r.removeAttributeNS(o,e.node.namespaceURI,e.node.localName),t.forEach((e=>{const t=e.node.localName,s=e.node.namespaceURI;if(Zn(a,t,s,n))throw qn(`An attribute ${s?`Q{${s}}${t}`:t} already exists.`);r.setAttributeNS(o,s,t,Z(n,e))}))}if(1===o||3===o||8===o||7===o){const s=(o=re(n,e))?o.node:null;r.removeChild(a.node,e.node),t.forEach((e=>{r.insertBefore(a.node,e.node,s)}))}},nr=(e,t,n,r)=>{if(rr(e,t),e.filter((e=>-1!==["insertInto","insertAttributes","replaceValue","rename"].indexOf(e.type))).forEach((e=>{switch(e.type){case"insertInto":er(e.target,e.content,r);break;case"insertAttributes":((e,t,n,r)=>{t.forEach((t=>{const a=t.node.localName,o=t.node.namespaceURI;if(Zn(e,a,o,n))throw qn(`An attribute ${o?`Q{${o}}${a}`:a} already exists.`);r.setAttributeNS(e.node,o,a,Z(n,t))}))})(e.target,e.content,t,r);break;case"rename":((e,t,n,r,a)=>{let o;switch(r||=new Wn(e?e.node:null),e.node.nodeType){case 1:const s=n.getAllAttributes(e.node),i=n.getChildNodes(e.node),l=r.createElementNS(t.namespaceURI,t.za());o={node:l,F:null},s.forEach((e=>{a.setAttributeNS(l,e.namespaceURI,e.nodeName,e.value)})),i.forEach((e=>{a.insertBefore(l,e,null)}));break;case 2:(t=r.createAttributeNS(t.namespaceURI,t.za())).value=Z(n,e),o={node:t,F:null};break;case 7:o={node:r.createProcessingInstruction(t.za(),Z(n,e)),F:null}}if(!ne(n,e))throw Error("Not supported: renaming detached nodes.");tr(e,[o],n,a)})(e.target,e.o,t,n,r);break;case"replaceValue":var a=e.target;if(e=e.o,2===a.node.nodeType){const n=ne(t,a);n?r.setAttributeNS(n.node,a.node.namespaceURI,a.node.localName,e):a.node.value=e}else r.setData(a.node,e)}})),e.filter((e=>-1!==["insertBefore","insertAfter","insertIntoAsFirst","insertIntoAsLast"].indexOf(e.type))).forEach((e=>{switch(e.type){case"insertAfter":((e,t,n,r)=>{const a=ne(n,e).node,o=(e=re(n,e))?e.node:null;t.forEach((e=>{r.insertBefore(a,e.node,o)}))})(e.target,e.content,t,r);break;case"insertBefore":((e,t,n,r)=>{const a=ne(n,e).node;t.forEach((t=>{r.insertBefore(a,t.node,e.node)}))})(e.target,e.content,t,r);break;case"insertIntoAsFirst":((e,t,n,r)=>{const a=(n=ee(n,e))?n.node:null;t.forEach((t=>{r.insertBefore(e.node,t.node,a)}))})(e.target,e.content,t,r);break;case"insertIntoAsLast":er(e.target,e.content,r)}})),e.filter((e=>"replaceNode"===e.type)).forEach((e=>{tr(e.target,e.o,t,r)})),e.filter((e=>"replaceElementContent"===e.type)).forEach((e=>{((e,t,n,r)=>{n.getChildNodes(e.node).forEach((t=>r.removeChild(e.node,t))),t&&r.insertBefore(e.node,t.node,null)})(e.target,e.text,t,r)})),e.filter((e=>"delete"===e.type)).forEach((e=>{e=e.target;var n=ne(t,e);(n=n?n.node:null)&&(2===e.node.nodeType?r.removeAttributeNS(n,e.node.namespaceURI,e.node.localName):r.removeChild(n,e.node))})),e.some((e=>"put"===e.type)))throw Error('Not implemented: the execution for pendingUpdate "put" is not yet implemented.')};const rr=(e,t)=>{function n(t,n){const r=new Set;e.filter((e=>e.type===t)).map((e=>e.target)).forEach((e=>{e=e?e.node:null,r.has(e)&&n(e),r.add(e)}))}n("rename",(e=>{throw Error(`XUDY0015: The target ${e.outerHTML} is used in more than one rename expression.`)})),n("replaceNode",(e=>{throw Error(`XUDY0016: The target ${e.outerHTML} is used in more than one replace expression.`)})),n("replaceValue",(e=>{throw Xn(e)})),n("replaceElementContent",(e=>{throw Xn(e)}));const r=new Map,a=e=>new P(e.node.prefix,e.node.namespaceURI,e.node.localName);e.filter((e=>"replaceNode"===e.type&&2===e.target.node.nodeType)).forEach((e=>{var n=ne(t,e.target);n=n?n.node:null;const o=r.get(n);o?o.push(...e.o.map(a)):r.set(n,e.o.map(a))})),e.filter((e=>"rename"===e.type&&2===e.target.node.nodeType)).forEach((e=>{var n=ne(t,e.target);if(n){n=n.node;var a=r.get(n);a?a.push(e.o):r.set(n,[e.o])}})),r.forEach((e=>{const t={};e.forEach((e=>{if(t[e.prefix]||(t[e.prefix]=e.namespaceURI),t[e.prefix]!==e.namespaceURI)throw Yn(e.namespaceURI)}))}))};var ar=(e,...t)=>e.concat(...t.filter(Boolean));function or(e){return e.J?(t,n)=>e.s(t,n):(t,n)=>{const r=e.h(t,n);return{next:()=>E({da:[],I:r.O()})}}}var sr=class extends Qn{constructor(e,t,n,r){super(e,t,n,!0,r),this.J=!0}h(){throw $n()}};function ir(e,t){return t((e=e.next(0)).value.da),$.create(e.value.I)}var lr=class extends sr{constructor(e,t,n,r){super(e,t,n,r),this.J=this.Ka.some((e=>e.J))}h(e,t){return this.A(e,t,this.Ka.map((e=>n=>e.h(n,t))))}s(e,t){let n=[];const r=this.A(e,t,this.Ka.map((e=>e.J?r=>ir(r=e.s(r,t),(e=>n=ar(n,e))):n=>e.h(n,t))));let a=!1;return{next:()=>{if(a)return A;const e=r.O();return a=!0,E(new Kn(e,n))}}}v(e){super.v(e),function(e){e.Ka.some((e=>e.J))&&(e.J=!0)}(this)}};const cr=["external","attribute","nodeName","nodeType","universal"],ur=cr.length;function hr(e,t){for(let n=0;n<ur;++n){if(t.h[n]<e.h[n])return 1;if(t.h[n]>e.h[n])return-1}return 0}var dr=class{constructor(e){if(this.h=cr.map((t=>e[t]||0)),Object.keys(e).some((e=>!cr.includes(e))))throw Error("Invalid specificity kind passed")}add(e){const t=cr.reduce(((t,n,r)=>(t[n]=this.h[r]+e.h[r],t)),Object.create(null));return new dr(t)}};const pr=()=>Ze("Expected base expression of a function call to evaluate to a sequence of single function item");function mr(e,t,n,r){const a=[];for(let o=0;o<t.length;++o){if(null===t[o]){a.push(null);continue}const s=Gt(e[o],t[o],n,r,!1);a.push(s)}return a}function fr(e,t){if(!T(e.type,60))throw Ze("Expected base expression to evaluate to a function item");if(e.v!==t)throw pr();return e}function gr(e,t,n,r,a,o,s){let i=0;return a=a.map((e=>e?null:o[i++](n))),0<=(a=mr(e.o,a,r,e.D)).indexOf(null)?function(e,t){const n=e.value,r=t.map((e=>null===e?null:L(e)));return t=t.reduce(((t,n,r)=>(null===n&&t.push(e.o[r]),t)),[]),t=new H({j:t,arity:t.length,Xa:!0,J:e.J,localName:"boundFunction",namespaceURI:e.l,i:e.s,value:function(e,t,a){const o=Array.from(arguments).slice(3),s=r.map((e=>null===e?o.shift():e()));return n.apply(void 0,[e,t,a].concat(s))}}),$.m(t)}(e,a):(t=t.apply(void 0,[n,r,s,...a]),Gt(e.s,t,r,e.D,!0))}var yr=class extends lr{constructor(e,t,n){super(new dr({external:1}),[e].concat(t.filter((e=>!!e))),{P:"unsorted",W:!1,subtree:!1,B:!1},n),this.ma=t.length,this.S=t.map((e=>null===e)),this.L=null,this.ya=e,this.La=t}s(e,t){if(!this.l||!this.l.J)return super.s(e,t);let n=[];const r=gr(this.l,((e,t,r,...a)=>ir(this.l.value(e,t,r,...a),(e=>{n=ar(n,e)}))),e,t,this.S,this.La.map((r=>()=>r.J?ir(r.s(e,t),(e=>{n=ar(n,e)})):Jn(r,e,t))),this.L);let a=!1;return{next:()=>{if(a)return A;const e=r.O();return a=!0,E({da:n,I:e})}}}A(e,t,[n,...r]){if(this.l)return gr(this.l,((e,t,n,...r)=>this.l.value(e,t,n,...r)),e,t,this.S,r,this.L);const a=n(e);return a.Y({default:()=>{throw pr()},m:()=>a.N((([n])=>{if((n=fr(n,this.ma)).J)throw Error("XUDY0038: The function returned by the PrimaryExpr of a dynamic function invocation can not be an updating function");return gr(n,n.value,e,t,this.S,r,this.L)}))})}v(e){if(this.L=la(e),super.v(e),this.ya.B){if(!(e=Jn(this.ya,null,null)).ua())throw pr();this.l=fr(e.first(),this.ma),this.l.J&&(this.J=!0)}}};const wr=(e,t,n,r,a,o)=>ue([r,a,o],(([e,t,n])=>{if(t=t.value,n=n.value,t>e.h.length||0>=t)throw Error("FOAY0001: subarray start out of bounds.");if(0>n)throw Error("FOAY0002: subarray length out of bounds.");if(t+n>e.h.length+1)throw Error("FOAY0001: subarray start + length out of bounds.");return $.m(new ie(e.h.slice(t-1,n+t-1)))})),vr=(e,t,n,r,a)=>ue([r],(([e])=>a.N((t=>{t=t.map((e=>e.value)).sort(((e,t)=>t-e)).filter(((e,t,n)=>n[t-1]!==e));const n=e.h.concat();for(let r=0,a=t.length;r<a;++r){const a=t[r];if(a>e.h.length||0>=a)throw Error("FOAY0001: subarray position out of bounds.");n.splice(a-1,1)}return $.m(new ie(n))})))),xr=e=>T(e,1)||T(e,20)||T(e,19),br=(e,t,n,r,a)=>0===r.length?0!==a.length:0!==a.length&&Un(e,t,n,r[0],a[0]).next(0).value?br(e,t,n,r.slice(1),a.slice(1)):r[0].value!=r[0].value||(xr(r[0].type)&&0!==a.length&&xr(a[0].type)||0!==a.length)&&r[0].value<a[0].value;function Ar(e){return T(e.type,62)?Qe(e.h.map((e=>e().N((e=>Qe(e.map(Ar))))))):$.m(e)}var Er=[{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"size",j:[{type:62,g:3}],i:{type:5,g:3},callFunction:(e,t,n,r)=>ue([r],(([e])=>$.m(y(e.h.length,5))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"get",j:[{type:62,g:3},{type:5,g:3}],i:{type:59,g:2},callFunction:se},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"put",j:[{type:62,g:3},{type:5,g:3},{type:59,g:2}],i:{type:62,g:3},callFunction:(e,t,n,r,a,o)=>ue([a,r],(([e,t])=>{if(0>=(e=e.value)||e>t.h.length)throw Error("FOAY0001: array position out of bounds.");return(t=t.h.concat()).splice(e-1,1,L(o)),$.m(new ie(t))}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"append",j:[{type:62,g:3},{type:59,g:2}],i:{type:62,g:3},callFunction:(e,t,n,r,a)=>ue([r],(([e])=>$.m(new ie(e.h.concat([L(a)])))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"subarray",j:[{type:62,g:3},{type:5,g:3},{type:5,g:3}],i:{type:62,g:3},callFunction:wr},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"subarray",j:[{type:62,g:3},{type:5,g:3}],i:{type:62,g:3},callFunction(e,t,n,r,a){const o=$.m(y(r.first().value.length-a.first().value+1,5));return wr(0,0,0,r,a,o)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"remove",j:[{type:62,g:3},{type:5,g:2}],i:{type:62,g:3},callFunction:vr},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"insert-before",j:[{type:62,g:3},{type:5,g:3},{type:59,g:2}],i:{type:62,g:3},callFunction:(e,t,n,r,a,o)=>ue([r,a],(([e,t])=>{if((t=t.value)>e.h.length+1||0>=t)throw Error("FOAY0001: subarray position out of bounds.");return(e=e.h.concat()).splice(t-1,0,L(o)),$.m(new ie(e))}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"head",j:[{type:62,g:3}],i:{type:59,g:2},callFunction:(e,t,n,r)=>se(0,0,0,r,$.m(y(1,5)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"tail",j:[{type:62,g:3}],i:{type:59,g:2},callFunction:(e,t,n,r)=>vr(0,0,0,r,$.m(y(1,5)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"reverse",j:[{type:62,g:3}],i:{type:62,g:3},callFunction:(e,t,n,r)=>ue([r],(([e])=>$.m(new ie(e.h.concat().reverse()))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"join",j:[{type:62,g:2}],i:{type:62,g:3},callFunction:(e,t,n,r)=>r.N((e=>(e=e.reduce(((e,t)=>e.concat(t.h)),[]),$.m(new ie(e)))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"for-each",j:[{type:62,g:3},{type:60,g:3}],i:{type:62,g:3},callFunction:(e,t,n,r,a)=>ue([r,a],(([r,a])=>{if(1!==a.v)throw Ze("The callback passed into array:for-each has a wrong arity.");return r=r.h.map((r=>L(a.value.call(void 0,e,t,n,mr(a.o,[r()],t,"array:for-each")[0])))),$.m(new ie(r))}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"filter",j:[{type:62,g:3},{type:60,g:3}],i:{type:62,g:3},callFunction:(e,t,n,r,a)=>ue([r,a],(([r,a])=>{if(1!==a.v)throw Ze("The callback passed into array:filter has a wrong arity.");const o=r.h.map((r=>{r=mr(a.o,[r()],t,"array:filter")[0];return(0,a.value)(e,t,n,r)})),s=[];let i=!1;return $.create({next:()=>{if(i)return A;for(let t=0,n=r.h.length;t<n;++t){var e=o[t].fa();s[t]=e}return e=r.h.filter(((e,t)=>s[t])),i=!0,E(new ie(e))}})}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"fold-left",j:[{type:62,g:3},{type:59,g:2},{type:60,g:3}],i:{type:59,g:2},callFunction:(e,t,n,r,a,o)=>ue([r,o],(([r,o])=>{if(2!==o.v)throw Ze("The callback passed into array:fold-left has a wrong arity.");return r.h.reduce(((r,a)=>(a=mr(o.o,[a()],t,"array:fold-left")[0],o.value.call(void 0,e,t,n,r,a))),a)}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"fold-right",j:[{type:62,g:3},{type:59,g:2},{type:60,g:3}],i:{type:59,g:2},callFunction:(e,t,n,r,a,o)=>ue([r,o],(([r,o])=>{if(2!==o.v)throw Ze("The callback passed into array:fold-right has a wrong arity.");return r.h.reduceRight(((r,a)=>(a=mr(o.o,[a()],t,"array:fold-right")[0],o.value.call(void 0,e,t,n,r,a))),a)}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"for-each-pair",j:[{type:62,g:3},{type:62,g:3},{type:60,g:3}],i:{type:62,g:3},callFunction:(e,t,n,r,a,o)=>ue([r,a,o],(([r,a,o])=>{if(2!==o.v)throw Ze("The callback passed into array:for-each-pair has a wrong arity.");const s=[];for(let i=0,l=Math.min(r.h.length,a.h.length);i<l;++i){const[l,c]=mr(o.o,[r.h[i](),a.h[i]()],t,"array:for-each-pair");s[i]=L(o.value.call(void 0,e,t,n,l,c))}return $.m(new ie(s))}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"sort",j:[{type:62,g:3}],i:{type:62,g:3},callFunction:(e,t,n,r)=>ue([r],(([r])=>(r=r.h.map((e=>e().O())),((e,t,n,r)=>(r.sort(((r,a)=>Rn(e,t,n,$.create(r),$.create(a)).next(0).value?0:br(e,t,n,r,a)?-1:1)),$.m(new ie(r.map((e=>()=>$.create(e)))))))(e,t,n,r))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"flatten",j:[{type:59,g:2}],i:{type:59,g:2},callFunction:(e,t,n,r)=>r.N((e=>Qe(e.map(Ar))))}];function Nr(e,t,n,r,a){return a.G()?a:$.m(At(a.first(),e))}var Tr=[{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"untypedAtomic",j:[{type:46,g:0}],i:{type:19,g:0},callFunction:Nr.bind(null,19)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"error",j:[{type:46,g:0}],i:{type:39,g:0},callFunction:Nr.bind(null,39)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"string",j:[{type:46,g:0}],i:{type:1,g:0},callFunction:Nr.bind(null,1)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"boolean",j:[{type:46,g:0}],i:{type:0,g:0},callFunction:Nr.bind(null,0)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"decimal",j:[{type:46,g:0}],i:{type:4,g:0},callFunction:Nr.bind(null,4)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"float",j:[{type:46,g:0}],i:{type:6,g:0},callFunction:Nr.bind(null,6)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"double",j:[{type:46,g:0}],i:{type:3,g:0},callFunction:Nr.bind(null,3)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"duration",j:[{type:46,g:0}],i:{type:18,g:0},callFunction:Nr.bind(null,18)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTime",j:[{type:46,g:0}],i:{type:9,g:0},callFunction:Nr.bind(null,9)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTimeStamp",j:[{type:46,g:0}],i:{type:10,g:0},callFunction:Nr.bind(null,10)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"time",j:[{type:46,g:0}],i:{type:8,g:0},callFunction:Nr.bind(null,8)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"date",j:[{type:46,g:0}],i:{type:7,g:0},callFunction:Nr.bind(null,7)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gYearMonth",j:[{type:46,g:0}],i:{type:11,g:0},callFunction:Nr.bind(null,11)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gYear",j:[{type:46,g:0}],i:{type:12,g:0},callFunction:Nr.bind(null,12)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gMonthDay",j:[{type:46,g:0}],i:{type:13,g:0},callFunction:Nr.bind(null,13)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gDay",j:[{type:46,g:0}],i:{type:15,g:0},callFunction:Nr.bind(null,15)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gMonth",j:[{type:46,g:0}],i:{type:14,g:0},callFunction:Nr.bind(null,14)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"hexBinary",j:[{type:46,g:0}],i:{type:22,g:0},callFunction:Nr.bind(null,22)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"base64Binary",j:[{type:46,g:0}],i:{type:21,g:0},callFunction:Nr.bind(null,21)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"QName",j:[{type:46,g:0}],i:{type:23,g:0},callFunction:(e,t,n,r)=>{if(r.G())return r;if(T((e=r.first()).type,2))throw Error("XPTY0004: The provided QName is not a string-like value.");if(!st(e=ot(e=At(e,1).value,23),23))throw Error("FORG0001: The provided QName is invalid.");if(!e.includes(":"))return n=n.$(""),$.m(y(new P("",n,e),23));const[a,o]=e.split(":");if(!(n=n.$(a)))throw Error(`FONS0004: The value ${e} can not be cast to a QName. Did you mean to use fn:QName?`);return $.m(y(new P(a,n,o),23))}},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"anyURI",j:[{type:46,g:0}],i:{type:20,g:0},callFunction:Nr.bind(null,20)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"normalizedString",j:[{type:46,g:0}],i:{type:48,g:0},callFunction:Nr.bind(null,48)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"token",j:[{type:46,g:0}],i:{type:52,g:0},callFunction:Nr.bind(null,52)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"language",j:[{type:46,g:0}],i:{type:51,g:0},callFunction:Nr.bind(null,51)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NMTOKEN",j:[{type:46,g:0}],i:{type:50,g:0},callFunction:Nr.bind(null,50)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NMTOKENS",j:[{type:46,g:0}],i:{type:49,g:2},callFunction:Nr.bind(null,49)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"Name",j:[{type:46,g:0}],i:{type:25,g:0},callFunction:Nr.bind(null,25)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NCName",j:[{type:46,g:0}],i:{type:24,g:0},callFunction:Nr.bind(null,24)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"ID",j:[{type:46,g:0}],i:{type:42,g:0},callFunction:Nr.bind(null,42)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"IDREF",j:[{type:46,g:0}],i:{type:41,g:0},callFunction:Nr.bind(null,41)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"IDREFS",j:[{type:46,g:0}],i:{type:43,g:2},callFunction:Nr.bind(null,43)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"ENTITY",j:[{type:46,g:0}],i:{type:26,g:0},callFunction:Nr.bind(null,26)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"ENTITIES",j:[{type:46,g:0}],i:{type:40,g:2},callFunction:Nr.bind(null,40)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"integer",j:[{type:46,g:0}],i:{type:5,g:0},callFunction:Nr.bind(null,5)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"nonPositiveInteger",j:[{type:46,g:0}],i:{type:27,g:0},callFunction:Nr.bind(null,27)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"negativeInteger",j:[{type:46,g:0}],i:{type:28,g:0},callFunction:Nr.bind(null,28)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"long",j:[{type:46,g:0}],i:{type:31,g:0},callFunction:Nr.bind(null,31)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"int",j:[{type:46,g:0}],i:{type:32,g:0},callFunction:Nr.bind(null,32)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"short",j:[{type:46,g:0}],i:{type:33,g:0},callFunction:Nr.bind(null,33)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"byte",j:[{type:46,g:0}],i:{type:34,g:0},callFunction:Nr.bind(null,34)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"nonNegativeInteger",j:[{type:46,g:0}],i:{type:30,g:0},callFunction:Nr.bind(null,30)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedLong",j:[{type:46,g:0}],i:{type:36,g:0},callFunction:Nr.bind(null,36)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedInt",j:[{type:46,g:0}],i:{type:35,g:0},callFunction:Nr.bind(null,35)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedShort",j:[{type:46,g:0}],i:{type:38,g:0},callFunction:Nr.bind(null,38)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedByte",j:[{type:46,g:0}],i:{type:37,g:0},callFunction:Nr.bind(null,37)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"positiveInteger",j:[{type:46,g:0}],i:{type:29,g:0},callFunction:Nr.bind(null,29)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"yearMonthDuration",j:[{type:46,g:0}],i:{type:16,g:0},callFunction:Nr.bind(null,16)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dayTimeDuration",j:[{type:46,g:0}],i:{type:17,g:0},callFunction:Nr.bind(null,17)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTimeStamp",j:[{type:46,g:0}],i:{type:10,g:0},callFunction:Nr.bind(null,10)}];const Br=(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.getYear(),5)),Ir=(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.getMonth(),5)),Cr=(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.getDay(),5)),Or=(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.getHours(),5)),Sr=(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.getMinutes(),5)),Fr=(e,t,n,r)=>(r.G()||(t=(e=$).m,r=r.first().value,r=t.call(e,y(r.D+r.pa,4))),r),Dr=(e,t,n,r)=>r.G()?r:(e=r.first().value.X)?$.m(y(e,17)):$.empty();var kr=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"dateTime",j:[{type:7,g:0},{type:8,g:0}],i:{type:9,g:0},callFunction:(e,t,n,r,a)=>{if(r.G())return r;if(a.G())return a;if(e=r.first().value,a=a.first().value,t=e.X,n=a.X,t||n){if(!t||n)if(!t&&n)t=n;else if(!me(t,n))throw Error("FORG0008: fn:dateTime: got a date and time value with different timezones.")}else t=null;return $.m(y(new Se(e.getYear(),e.getMonth(),e.getDay(),a.getHours(),a.getMinutes(),a.getSeconds(),a.pa,t),9))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"year-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Br},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"month-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Ir},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"day-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Cr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Or},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Sr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-dateTime",j:[{type:9,g:0}],i:{type:4,g:0},callFunction:Fr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-dateTime",j:[{type:9,g:0}],i:{type:17,g:0},callFunction:Dr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"year-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:Br},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"month-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:Ir},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"day-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:Cr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-date",j:[{type:7,g:0}],i:{type:17,g:0},callFunction:Dr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-time",j:[{type:8,g:0}],i:{type:5,g:0},callFunction:Or},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-time",j:[{type:8,g:0}],i:{type:5,g:0},callFunction:Sr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-time",j:[{type:8,g:0}],i:{type:4,g:0},callFunction:Fr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-time",j:[{type:8,g:0}],i:{type:17,g:0},callFunction:Dr}];function Rr(e,t){const n=t.h,r=t.Ia,a=t.Ma;switch(e.node.nodeType){case 1:const s=r.createElementNS(e.node.namespaceURI,e.node.nodeName);for(var o of(n.getAllAttributes(e.node).forEach((e=>a.setAttributeNS(s,e.namespaceURI,e.nodeName,e.value))),W(n,e)))e=Rr(o,t),a.insertBefore(s,e.node,null);return{node:s,F:null};case 2:return(t=r.createAttributeNS(e.node.namespaceURI,e.node.nodeName)).value=Z(n,e),{node:t,F:null};case 4:return{node:r.createCDATASection(Z(n,e)),F:null};case 8:return{node:r.createComment(Z(n,e)),F:null};case 9:o=r.createDocument();for(const r of W(n,e))e=Rr(r,t),a.insertBefore(o,e.node,null);return{node:o,F:null};case 7:return{node:r.createProcessingInstruction(e.node.target,Z(n,e)),F:null};case 3:return{node:r.createTextNode(Z(n,e)),F:null}}}function Mr(e,t){const n=t.Ma;var r=t.Ia;const a=t.h;if(!z(e.node))return Rr(e,t).node;switch(e.node.nodeType){case 2:return(r=r.createAttributeNS(e.node.namespaceURI,e.node.nodeName)).value=Z(a,e),r;case 8:return r.createComment(Z(a,e));case 1:const o=e.node.prefix,s=e.node.localName,i=r.createElementNS(e.node.namespaceURI,o?o+":"+s:s);return W(a,e).forEach((e=>{e=Mr(e,t),n.insertBefore(i,e,null)})),Q(a,e).forEach((e=>{n.setAttributeNS(i,e.node.namespaceURI,e.node.nodeName,Z(a,e))})),i.normalize(),i;case 7:return r.createProcessingInstruction(e.node.target,Z(a,e));case 3:return r.createTextNode(Z(a,e))}}function Ur(e,t,n){var r=e.node;if(!(z(r)||n||e.F))return r;r=t.v;const a=[];return n?Mr(e,t):(e=function(e,t,n){let r=e;for(e=ne(n,r);null!==e;){if(2===r.node.nodeType)t.push(r.node.nodeName);else{const a=W(n,e);t.push(a.findIndex((e=>Tt(e,r))))}r=e,e=ne(n,r)}return r}(e,a,t.h),(n=r.get(e.node))||(n={node:Mr(e,t),F:null},r.set(e.node,n)),function(e,t,n){for(;0<t.length;){const r=t.pop();e="string"==typeof r?Q(n,e).find((e=>e.node.nodeName===r)):W(n,e)[r]}return e.node}(n,a,t.h))}const Gr=(e,t,n,r,a)=>r.N((e=>{let n="";for(let r=0;r<e.length;r++){const a=e[r],o=t.Ua&&T(a.type,53)?t.Ua.serializeToString(Ur(a.value,t,!1)):rt($.m(a),t).map((e=>At(e,1))).first().value;n+=`{type: ${C[a.type]}, value: ${o}}\n`}return void 0!==a&&(n+=a.first().value),t.ib.trace(n),$.create(e)}));var $r=[{j:[{type:59,g:2}],callFunction:Gr,localName:"trace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:1,g:3}],callFunction:Gr,localName:"trace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}}];const Lr=(e,t,n,r,a)=>{throw e=void 0===r||r.G()?new P("err","http://www.w3.org/2005/xqt-errors","FOER0000"):r.first().value,t="",void 0===a||a.G()||(t=`: ${a.first().value}`),Error(`${e.localName}${t}`)};var Pr=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[],i:{type:63,g:3},callFunction:Lr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[{type:23,g:0}],i:{type:63,g:3},callFunction:Lr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[{type:23,g:0},{type:1,g:3}],i:{type:63,g:3},callFunction:Lr},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[{type:23,g:0},{type:1,g:3},{type:59,g:2}],i:{type:63,g:3},callFunction(){throw Error("Not implemented: Using an error object in error is not supported")}}];function Hr(e){return"string"==typeof e?e:(e=(new q).getChildNodes(e).find((e=>8===e.nodeType)))?e.data:"some expression"}var jr=class extends Error{constructor(e,t){super(e),this.position={end:{ha:t.end.ha,line:t.end.line,offset:t.end.offset},start:{ha:t.start.ha,line:t.start.line,offset:t.start.offset}}}};function _r(e,t){if(t instanceof Error)throw t;"string"!=typeof e&&(e=Hr(e));const n=mo(t);e=e.replace(/\r/g,"").split("\n");const r=Math.floor(Math.log10(Math.min(n.end.line+2,e.length)))+1;throw e=e.reduce(((e,t,a)=>{var o=a+1;if(2<n.start.line-o||2<o-n.end.line)return e;if(a=`${Array(r).fill(" ",0,Math.floor(Math.log10(o))+1-r).join("")}${o}: `,e.push(`${a}${t}`),o>=n.start.line&&o<=n.end.line){const r=o<n.end.line?t.length+a.length:n.end.ha-1+a.length;o=o>n.start.line?a.length:n.start.ha-1+a.length,t=" ".repeat(a.length)+Array.from(t.substring(0,o-a.length),(e=>"\t"===e?"\t":" ")).join("")+"^".repeat(r-o),e.push(t)}return e}),[]),t=fo(t).join("\n"),new jr(e.join("\n")+"\n\n"+t,n)}const Xr=Object.create(null);function qr(e,t){const n=new Map;for(let t=0;t<e.length+1;++t)n.set(t,new Map);return function r(a,o){if(0===a)return o;if(0===o)return a;if(n.get(a).has(o))return n.get(a).get(o);var s=0;return e[a-1]!==t[o-1]&&(s=1),s=Math.min(r(a-1,o)+1,r(a,o-1)+1,r(a-1,o-1)+s),n.get(a).set(o,s),s}(e.length,t.length)}function Vr(e){const t=Xr[e]?Xr[e]:Object.keys(Xr).map((t=>({name:t,qb:qr(e,t.slice(t.lastIndexOf(":")+1))}))).sort(((e,t)=>e.qb-t.qb)).slice(0,5).filter((t=>t.qb<e.length/2)).reduce(((e,t)=>e.concat(Xr[t.name])),[]).slice(0,5);return t.length?t.map((e=>`"Q{${e.namespaceURI}}${e.localName} (${e.j.map((e=>4===e?"...":S(e))).join(", ")})"`)).reduce(((e,t,n,r)=>0===n?e+t:e+(n!==r.length-1?", ":" or ")+t),"Did you mean ")+"?":"No similar functions found."}function Yr(e,t,n){var r=Xr[e+":"+t];return r&&(r=r.find((e=>e.j.some((e=>4===e))?e.j.length-1<=n:e.j.length===n)))?{j:r.j,arity:n,callFunction:r.callFunction,J:r.J,localName:t,namespaceURI:e,i:r.i}:null}function zr(e,t,n,r,a){Xr[e+":"+t]||(Xr[e+":"+t]=[]),Xr[e+":"+t].push({j:n,arity:n.length,callFunction:a,J:!1,localName:t,namespaceURI:e,i:r})}var Jr={xml:"http://www.w3.org/XML/1998/namespace",xs:"http://www.w3.org/2001/XMLSchema",fn:"http://www.w3.org/2005/xpath-functions",map:"http://www.w3.org/2005/xpath-functions/map",array:"http://www.w3.org/2005/xpath-functions/array",math:"http://www.w3.org/2005/xpath-functions/math",fontoxpath:"http://fontoxml.com/fontoxpath",local:"http://www.w3.org/2005/xquery-local-functions"},Qr=class{constructor(e,t,n,r){this.Da=[Object.create(null)],this.Ea=Object.create(null),this.s=e,this.ia=Object.keys(t).reduce(((e,n)=>(void 0===t[n]||(e[n]=`Q{}${n}[0]`),e)),Object.create(null)),this.o=Object.create(null),this.h=Object.create(null),this.v=n,this.l=r,this.D=[]}va(e,t,n){return Yr(e,t,n)}cb(e,t){return e?null:(e=this.ia[t],this.o[t]||(this.o[t]={name:t}),e)}Sa(e,t){const n=this.l(e,t);if(n)this.D.push({ac:e,arity:t,Bb:n});else if(""===e.prefix){if(this.v)return{namespaceURI:this.v,localName:e.localName}}else if(t=this.$(e.prefix,!0))return{namespaceURI:t,localName:e.localName};return n}$(e,t=!0){return t?Jr[e]?Jr[e]:(t=this.s(e),this.h[e]||(this.h[e]={namespaceURI:t,prefix:e}),void 0!==t||e?t:null):null}},Kr=(e,t)=>(e=2===e.node.nodeType?`${e.node.nodeName}="${Z(t,e)}"`:e.node.outerHTML,Error(`XQTY0024: The node ${e} follows a node that is not an attribute node or a namespace node.`)),Wr=e=>Error(`XQDY0044: The node name "${e.za()}" is invalid for a computed attribute constructor.`),Zr=()=>Error("XQST0045: Functions and variables may not be declared in one of the reserved namespace URIs."),ea=(e,t)=>Error(`XQST0049: The function or variable "Q{${e}}${t}" is declared more than once.`),ta=()=>Error("XQST0060: Functions declared in a module or as an external function must reside in a namespace."),na=()=>Error("XQST0066: A Prolog may contain at most one default function namespace declaration."),ra=()=>Error("XQST0070: The prefixes xml and xmlns may not be used in a namespace declaration or be bound to another namespaceURI."),aa=e=>Error(`XQDY0074: The value "${e}" of a name expressions cannot be converted to an expanded QName.`),oa=e=>Error(`XPST0081: The prefix "${e}" could not be resolved`);function sa(e,t){return`Q{${e||""}}${t}`}function ia(e,t){for(let n=e.length-1;0<=n;--n)if(t in e[n])return e[n][t]}function la(e){const t=new fa(e.o);for(let n=0;n<e.h+1;++n)t.D=[Object.assign(Object.create(null),t.D[0],e.D[n])],t.Da=[Object.assign(Object.create(null),t.Da[0],e.Da[n])],t.l=Object.assign(Object.create(null),e.l),t.Ea=e.Ea,t.v=e.v;return t}function ca(e){e.s++,e.h++,e.D[e.h]=Object.create(null),e.Da[e.h]=Object.create(null)}function ua(e,t,n,r,a){if(r=sa(t,n)+"~"+r,e.l[r])throw ea(t,n);e.l[r]=a}function ha(e,t,n){e.D[e.h][t]=n}function da(e,t,n){return t=sa(t||"",n),e.Da[e.h][t]=`${t}[${e.s}]`}function pa(e,t,n,r){e.Ea[`${sa(t||"",n)}[${e.s}]`]=r}function ma(e){e.D.length=e.h,e.Da.length=e.h,e.h--}var fa=class{constructor(e){this.o=e,this.s=this.h=0,this.D=[Object.create(null)],this.l=Object.create(null),this.v=null,this.Ea=e&&e.Ea,this.Da=e&&e.Da}va(e,t,n,r=!1){const a=this.l[sa(e,t)+"~"+n];return!a||r&&a.ub?null===this.o?null:this.o.va(e,t,n,r):a}cb(e,t){const n=ia(this.Da,sa(e,t));return n||(null===this.o?null:this.o.cb(e,t))}Sa(e,t){var n=e.prefix;const r=e.localName;return""===n&&this.v?{localName:r,namespaceURI:this.v}:n&&(n=this.$(n,!1))?{localName:r,namespaceURI:n}:null===this.o?null:this.o.Sa(e,t)}$(e,t=!0){const n=ia(this.D,e||"");return void 0===n?null===this.o?void 0:this.o.$(e||"",t):n}};function ga(e,t){"*"===t||Array.isArray(t)||(t=[t]);for(let n=1;n<e.length;++n){if(!Array.isArray(e[n]))continue;const r=e[n];if("*"===t||t.includes(r[0]))return r}return null}function ya(e){return 2>e.length?"":"object"==typeof e[1]?e[2]||"":e[1]||""}function wa(e,t){return Array.isArray(e)?"object"!=typeof(e=e[1])||Array.isArray(e)?null:t in e?e[t]:null:null}function va(e,t){return t.reduce(ga,e)}function xa(e,t){const n=[];for(let r=1;r<e.length;++r){if(!Array.isArray(e[r]))continue;const a=e[r];"*"!==t&&a[0]!==t||n.push(a)}return n}function ba(e){return{localName:ya(e),namespaceURI:wa(e,"URI"),prefix:wa(e,"prefix")}}function Aa(e){const t=ga(e,"typeDeclaration");if(!t||ga(t,"voidSequenceType"))return{type:59,g:2};const n=e=>{switch(e[0]){case"documentTest":return 55;case"elementTest":return 54;case"attributeTest":return 47;case"piTest":return 57;case"commentTest":return 58;case"textTest":return 56;case"anyKindTest":return 53;case"anyItemType":return 59;case"anyFunctionTest":case"functionTest":case"typedFunctionTest":return 60;case"anyMapTest":case"typedMapTest":return 61;case"anyArrayTest":case"typedArrayTest":return 62;case"atomicType":return F([wa(e,"prefix"),ya(e)].join(":"));case"parenthesizedItemType":return n(ga(e,"*"));default:throw Error(`Type declaration "${ga(t,"*")[0]}" is not supported.`)}};e={type:n(ga(t,"*")),g:3};let r=null;const a=ga(t,"occurrenceIndicator");switch(a&&(r=ya(a)),r){case"*":return e.g=2,e;case"?":return e.g=0,e;case"+":return e.g=1,e;case"":case null:return e}}function Ea(e,t,n){if("object"!=typeof e[1]||Array.isArray(e[1])){const r={};r[t]=n,e.splice(1,0,r)}else e[1][t]=n}function Na(e,t,n){return(e<<20)+(t<<12)+(n.charCodeAt(0)<<8)+n.charCodeAt(1)}var Ta={[Na(2,2,"idivOp")]:5,[Na(16,16,"addOp")]:16,[Na(16,16,"subtractOp")]:16,[Na(16,16,"divOp")]:4,[Na(16,2,"multiplyOp")]:16,[Na(16,2,"divOp")]:16,[Na(2,16,"multiplyOp")]:16,[Na(17,17,"addOp")]:17,[Na(17,17,"subtractOp")]:17,[Na(17,17,"divOp")]:4,[Na(17,2,"multiplyOp")]:17,[Na(17,2,"divOp")]:17,[Na(2,17,"multiplyOp")]:17,[Na(9,9,"subtractOp")]:17,[Na(7,7,"subtractOp")]:17,[Na(8,8,"subtractOp")]:17,[Na(9,16,"addOp")]:9,[Na(9,16,"subtractOp")]:9,[Na(9,17,"addOp")]:9,[Na(9,17,"subtractOp")]:9,[Na(7,16,"addOp")]:7,[Na(7,16,"subtractOp")]:7,[Na(7,17,"addOp")]:7,[Na(7,17,"subtractOp")]:7,[Na(8,17,"addOp")]:8,[Na(8,17,"subtractOp")]:8,[Na(9,16,"addOp")]:9,[Na(9,16,"subtractOp")]:9,[Na(9,17,"addOp")]:9,[Na(9,17,"subtractOp")]:9,[Na(7,17,"addOp")]:7,[Na(7,17,"subtractOp")]:7,[Na(7,16,"addOp")]:7,[Na(7,16,"subtractOp")]:7,[Na(8,17,"addOp")]:8,[Na(8,17,"subtractOp")]:8},Ba={[Na(2,2,"addOp")]:(e,t)=>e+t,[Na(2,2,"subtractOp")]:(e,t)=>e-t,[Na(2,2,"multiplyOp")]:(e,t)=>e*t,[Na(2,2,"divOp")]:(e,t)=>e/t,[Na(2,2,"modOp")]:(e,t)=>e%t,[Na(2,2,"idivOp")]:(e,t)=>Math.trunc(e/t),[Na(16,16,"addOp")]:function(e,t){return new ht(e.ea+t.ea)},[Na(16,16,"subtractOp")]:function(e,t){return new ht(e.ea-t.ea)},[Na(16,16,"divOp")]:function(e,t){return e.ea/t.ea},[Na(16,2,"multiplyOp")]:pt,[Na(16,2,"divOp")]:function(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot divide xs:yearMonthDuration by NaN");if((e=Math.round(e.ea/t))>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while dividing xs:yearMonthDuration");return new ht(e<Number.MIN_SAFE_INTEGER||0===e?0:e)},[Na(2,16,"multiplyOp")]:(e,t)=>pt(t,e),[Na(17,17,"addOp")]:function(e,t){return new ye(e.ca+t.ca)},[Na(17,17,"subtractOp")]:function(e,t){return new ye(e.ca-t.ca)},[Na(17,17,"divOp")]:function(e,t){if(0===t.ca)throw Error("FOAR0001: Division by 0");return e.ca/t.ca},[Na(17,2,"multiplyOp")]:be,[Na(17,2,"divOp")]:function(e,t){if(isNaN(t))throw Error("FOCA0005: Cannot divide xs:dayTimeDuration by NaN");if((e=e.ca/t)>Number.MAX_SAFE_INTEGER||!Number.isFinite(e))throw Error("FODT0002: Value overflow while dividing xs:dayTimeDuration");return new ye(e<Number.MIN_SAFE_INTEGER||Object.is(-0,e)?0:e)},[Na(2,17,"multiplyOp")]:(e,t)=>be(t,e),[Na(9,9,"subtractOp")]:ke,[Na(7,7,"subtractOp")]:ke,[Na(8,8,"subtractOp")]:ke,[Na(9,16,"addOp")]:Re,[Na(9,16,"subtractOp")]:Me,[Na(9,17,"addOp")]:Re,[Na(9,17,"subtractOp")]:Me,[Na(7,16,"addOp")]:Re,[Na(7,16,"subtractOp")]:Me,[Na(7,17,"addOp")]:Re,[Na(7,17,"subtractOp")]:Me,[Na(8,17,"addOp")]:Re,[Na(8,17,"subtractOp")]:Me,[Na(9,16,"addOp")]:Re,[Na(9,16,"subtractOp")]:Me,[Na(9,17,"addOp")]:Re,[Na(9,17,"subtractOp")]:Me,[Na(7,17,"addOp")]:Re,[Na(7,17,"subtractOp")]:Me,[Na(7,16,"addOp")]:Re,[Na(7,16,"subtractOp")]:Me,[Na(8,17,"addOp")]:Re,[Na(8,17,"subtractOp")]:Me};function Ia(e,t){return T(e,5)&&T(t,5)?5:T(e,4)&&T(t,4)?4:T(e,6)&&T(t,6)?6:3}const Ca=[2,16,17,9,7,8];function Oa(e,t,n){function r(e,t){return{T:a?a(e):e,U:o?o(t):t}}let a=null,o=null;T(t,19)&&(a=e=>At(e,3),t=3),T(n,19)&&(o=e=>At(e,3),n=3);const s=Ca.filter((e=>T(t,e))),i=Ca.filter((e=>T(n,e)));if(s.includes(2)&&i.includes(2)){const a=Ba[Na(2,2,e)];let o=Ta[Na(2,2,e)];return o||=Ia(t,n),"divOp"===e&&5===o&&(o=4),"idivOp"===e?Sa(r,a)[0]:(e,t)=>{const{T:n,U:s}=r(e,t);return y(a(n.value,s.value),o)}}for(const t of s)for(const n of i){const a=Ba[Na(t,n,e)],o=Ta[Na(t,n,e)];if(a&&void 0!==o)return(e,t)=>{const{T:n,U:s}=r(e,t);return y(a(n.value,s.value),o)}}}function Sa(e,t){return[(n,r)=>{const{T:a,U:o}=e(n,r);if(0===o.value)throw Error("FOAR0001: Divisor of idiv operator cannot be (-)0");if(Number.isNaN(a.value)||Number.isNaN(o.value)||!Number.isFinite(a.value))throw Error("FOAR0002: One of the operands of idiv is NaN or the first operand is (-)INF");return Number.isFinite(a.value)&&!Number.isFinite(o.value)?y(0,5):y(t(a.value,o.value),5)},5]}const Fa=Object.create(null);var Da=class extends Qn{constructor(e,t,n,r,a){super(t.o.add(n.o),[t,n],{B:!1},!1,r),this.A=t,this.L=n,this.l=e,this.s=a}h(e,t){return rt(Jn(this.A,e,t),t).N((n=>0===n.length?$.empty():rt(Jn(this.L,e,t),t).N((e=>{if(0===e.length)return $.empty();if(1<n.length||1<e.length)throw Error('XPTY0004: the operands of the "'+this.l+'" operator should be empty or singleton.');const t=n[0];if(e=e[0],this.s&&this.type)return $.m(this.s(t,e));var r=t.type,a=e.type,o=this.l;const s=`${r}~${a}~${o}`;let i=Fa[s];if(i||=Fa[s]=Oa(o,r,a),!(r=i))throw Error(`XPTY0004: ${this.l} not available for types ${C[t.type]} and ${C[e.type]}`);return $.m(r(t,e))}))))}};function ka(e,t,n){const r=ba(va(e,["forClauseItem","typedVariableBinding","varName"]));(e=va(e,["forClauseItem","forExpr","sequenceExpr"]))&&(e=xa(e,"*").map((e=>n(e,t))),e.includes(void 0)||e.includes(null)||1===(e=Ra(e)).length&&Va(t,r.localName,e[0]))}function Ra(e){return e.filter(((e,t,n)=>n.findIndex((t=>t.type===e.type&&t.g===e.g))===t))}function Ma(e,t,n){const r=xa(e,"*"),a=ga(e,"atomicType");if(!a)return{type:59,g:2};if(F(wa(a,"prefix")+":"+a[2])===t.type)if(1===r.length){if(3===t.g)return n}else if(e=ga(e,"occurrenceIndicator")[1],t.g===function(e){switch(e){case"*":return 2;case"?":return 0;case"+":return 1;default:return 3}}(e))return n}function Ua(e,t){Ga(e,t)}function Ga(e,t){var n=Xa.get(e[0]);if(n)return n(e,t);for(n=1;n<e.length;n++)e[n]&&Ga(e[n],t)}const $a=(e,t)=>{var n=Ga(ga(e,"firstOperand")[1],t);const r=Ga(ga(e,"secondOperand")[1],t);var a=e[0];if(n&&r){if(!(t=function(e,t,n){var r=[2,53,59,46,47];if(r.includes(t)||r.includes(n))return 2;let a=null,o=null;T(t,19)&&(a=e=>At(e,3),t=3),T(n,19)&&(o=e=>At(e,3),n=3);var s=Ca.filter((e=>T(t,e)));if(r=Ca.filter((e=>T(n,e))),s.includes(2)&&r.includes(2)){var i=Ta[Na(2,2,e)];return void 0===i&&(i=Ia(t,n)),"divOp"===e&&5===i&&(i=4),"idivOp"===e?Sa((function(e,t){return{T:a?a(e):e,U:o?o(t):t}}),((e,t)=>Math.trunc(e/t)))[1]:i}for(i of s)for(const t of r)if(s=Ta[Na(i,t,e)],void 0!==s)return s}(a,n.type,r.type)))throw Error(`XPTY0004: ${a} not available for types ${S(n)} and ${S(r)}`);n={type:t,g:n.g},2!==t&&59!==t&&Ea(e,"type",n),e=n}else e={type:2,g:3};return e},La=(e,t)=>{Ga(ga(e,"firstOperand")[1],t),Ga(ga(e,"secondOperand")[1],t);e:{switch(e[0]){case"orOp":case"andOp":Ea(e,"type",t={type:0,g:3}),e=t;break e}e=void 0}return e},Pa=(e,t)=>{Ga(ga(e,"firstOperand")[1],t),Ga(ga(e,"secondOperand")[1],t);e:{switch(e[0]){case"unionOp":case"intersectOp":case"exceptOp":Ea(e,"type",t={type:53,g:2}),e=t;break e}e=void 0}return e},Ha=(e,t)=>(Ga(ga(e,"firstOperand")[1],t),Ga(ga(e,"secondOperand")[1],t),Ea(e,"type",t={type:0,g:3}),t),ja=(e,t)=>{Ga(ga(e,"firstOperand")[1],t),Ga(ga(e,"secondOperand")[1],t),t=wa(va(e,["firstOperand","*"]),"type");const n=wa(va(e,["secondOperand","*"]),"type");return Ea(e,"type",t={type:0,g:lt(t)||lt(n)?0:3}),t},_a=(e,t)=>{Ga(ga(e,"firstOperand")[1],t),Ga(ga(e,"secondOperand")[1],t),t=wa(va(e,["firstOperand","*"]),"type");const n=wa(va(e,["secondOperand","*"]),"type");return Ea(e,"type",t={type:0,g:lt(t)||lt(n)?0:3}),t},Xa=new Map([["unaryMinusOp",(e,t)=>((t=Ga(ga(e,"operand")[1],t))?T(t.type,2)?(Ea(e,"type",t={type:t.type,g:t.g}),e=t):(Ea(e,"type",t={type:3,g:3}),e=t):(Ea(e,"type",t={type:2,g:2}),e=t),e)],["unaryPlusOp",(e,t)=>((t=Ga(ga(e,"operand")[1],t))?T(t.type,2)?(Ea(e,"type",t={type:t.type,g:t.g}),e=t):(Ea(e,"type",t={type:3,g:3}),e=t):(Ea(e,"type",t={type:2,g:2}),e=t),e)],["addOp",$a],["subtractOp",$a],["divOp",$a],["idivOp",$a],["modOp",$a],["multiplyOp",$a],["andOp",La],["orOp",La],["sequenceExpr",(e,t)=>{const n=xa(e,"*"),r=n.map((e=>Ga(e,t)));return function(e,t,n){return t=0===t?{type:53,g:2}:1===t?n[0]:n.includes(void 0)||n.includes(null)||1<(t=Ra(n)).length?{type:59,g:2}:{type:t[0].type,g:2},t&&59!==t.type&&Ea(e,"type",t),t}(e,n.length,r)}],["unionOp",Pa],["intersectOp",Pa],["exceptOp",Pa],["stringConcatenateOp",(e,t)=>(Ga(ga(e,"firstOperand")[1],t),Ga(ga(e,"secondOperand")[1],t),Ea(e,"type",t={type:1,g:3}),t)],["rangeSequenceExpr",(e,t)=>(Ga(ga(e,"startExpr")[1],t),Ga(ga(e,"endExpr")[1],t),Ea(e,"type",t={type:5,g:1}),t)],["equalOp",Ha],["notEqualOp",Ha],["lessThanOrEqualOp",Ha],["lessThanOp",Ha],["greaterThanOrEqualOp",Ha],["greaterThanOp",Ha],["eqOp",ja],["neOp",ja],["ltOp",ja],["leOp",ja],["gtOp",ja],["geOp",ja],["isOp",_a],["nodeBeforeOp",_a],["nodeAfterOp",_a],["pathExpr",(e,t)=>{const n=ga(e,"rootExpr");return n&&n[1]&&Ga(n[1],t),xa(e,"stepExpr").map((e=>Ga(e,t))),function(e,t){var n=xa(e,"stepExpr");if(!n)return{type:59,g:2};for(const e of n){e:{n=e;var r=t;let o=null;if(!n)break e;var a=xa(n,"*");let s="";for(const e of a)switch(e[0]){case"filterExpr":o=wa(va(e,["*"]),"type");break;case"xpathAxis":s=e[1];t:{switch(s){case"attribute":o={type:47,g:2};break t;case"child":case"decendant":case"self":case"descendant-or-self":case"following-sibling":case"following":case"namespace":case"parent":case"ancestor":case"preceding-sibling":case"preceding":case"ancestor-or-self":o={type:53,g:2};break t}o=void 0}break;case"nameTest":if(a=ba(e),null!==a.namespaceURI)break;if("attribute"===s&&!a.prefix)break;void 0!==(a=r.$(a.prefix||""))&&Ea(e,"URI",a);break;case"lookup":o={type:59,g:2}}o&&59!==o.type&&Ea(n,"type",o)}r=wa(e,"type")}return r&&59!==r.type&&Ea(e,"type",r),r}(e,t)}],["contextItemExpr",()=>({type:59,g:2})],["ifThenElseExpr",(e,t)=>{Ga(ga(ga(e,"ifClause"),"*"),t);const n=Ga(ga(ga(e,"thenClause"),"*"),t);return t=Ga(ga(ga(e,"elseClause"),"*"),t),n&&t&&n.type===t.type&&n.g===t.g?(59!==n.type&&Ea(e,"type",n),e=n):e={type:59,g:2},e}],["instanceOfExpr",(e,t)=>(Ga(ga(e,"argExpr"),t),Ga(ga(e,"sequenceType"),t),Ea(e,"type",t={type:0,g:3}),t)],["integerConstantExpr",e=>{const t={type:5,g:3};return Ea(e,"type",t),t}],["doubleConstantExpr",e=>{const t={type:3,g:3};return Ea(e,"type",t),t}],["decimalConstantExpr",e=>{const t={type:4,g:3};return Ea(e,"type",t),t}],["stringConstantExpr",e=>{const t={type:1,g:3};return Ea(e,"type",t),t}],["functionCallExpr",(e,t)=>(xa(ga(e,"arguments"),"*").map((e=>Ga(e,t))),function(e,t){if(!t||!t.ga)return{type:59,g:2};const n=ga(e,"functionName");var r=ba(n);let a=r.localName;var o=r.prefix;let s=r.namespaceURI;if(r=xa(ga(e,"arguments"),"*"),null===s){if(!(o=t.ga.Sa({localName:a,prefix:o},r.length)))return{type:59,g:2};a=o.localName,s=o.namespaceURI,Ea(n,"URI",s),n[2]=a}return(t=t.ga.va(s,a,r.length))&&63!==t.i.type?(59!==t.i.type&&Ea(e,"type",t.i),t.i):{type:59,g:2}}(e,t))],["arrowExpr",(e,t)=>(Ga(ga(e,"argExpr")[1],t),function(e,t){if(!t||!t.ga)return{type:59,g:2};var n=ga(e,"EQName");if(!n)return{type:59,g:2};var r=ba(n);n=r.localName;const a=r.prefix;return r=xa(ga(e,"arguments"),"*"),(n=t.ga.Sa({localName:n,prefix:a},r.length))&&(t=t.ga.va(n.namespaceURI,n.localName,r.length+1))?(59!==t.i.type&&Ea(e,"type",t.i),t.i):{type:59,g:2}}(e,t))],["dynamicFunctionInvocationExpr",(e,t)=>(Ga(va(e,["functionItem","*"]),t),(e=ga(e,"arguments"))&&Ga(e,t),{type:59,g:2})],["namedFunctionRef",(e,t)=>function(e,t){if(!t||!t.ga)return{type:59,g:2};const n=ga(e,"functionName");var r=ba(n);let a=r.localName;var o=r.namespaceURI;const s=r.prefix;if(r=Number(va(e,["integerConstantExpr","value"])[1]),!o){if(!(o=t.ga.Sa({localName:a,prefix:s},r)))return{type:59,g:2};a=o.localName,Ea(n,"URI",o=o.namespaceURI)}return(t=t.ga.va(o,a,r)||null)?(59!==t.i.type&&63!==t.i.type&&Ea(e,"type",t.i),t.i):{type:59,g:2}}(e,t)],["inlineFunctionExpr",(e,t)=>(Ga(ga(e,"functionBody")[1],t),Ea(e,"type",t={type:60,g:3}),t)],["castExpr",e=>{var t=va(e,["singleType","atomicType"]);return 59!==(t={type:F(wa(t,"prefix")+":"+t[2]),g:3}).type&&Ea(e,"type",t),t}],["castableExpr",e=>{const t={type:0,g:3};return Ea(e,"type",t),t}],["simpleMapExpr",(e,t)=>{const n=xa(e,"pathExpr");let r;for(let e=0;e<n.length;e++)r=Ga(n[e],t);return null!=r?(59!==(t={type:r.type,g:2}).type&&Ea(e,"type",t),e=t):e={type:59,g:2},e}],["mapConstructor",(e,t)=>(xa(e,"mapConstructorEntry").map((e=>({key:Ga(va(e,["mapKeyExpr","*"]),t),value:Ga(va(e,["mapValueExpr","*"]),t)}))),function(e){const t={type:61,g:3};return Ea(e,"type",t),t}(e))],["arrayConstructor",(e,t)=>(xa(ga(e,"*"),"arrayElem").map((e=>Ga(e,t))),function(e){const t={type:62,g:3};return Ea(e,"type",t),t}(e))],["unaryLookup",e=>(ga(e,"NCName"),{type:59,g:2})],["typeswitchExpr",(e,t)=>{const n=Ga(ga(e,"argExpr")[1],t),r=xa(e,"typeswitchExprCaseClause").map((e=>Ga(va(e,["resultExpr"])[1],t)));return function(e,t,n,r){if(!t||n.includes(void 0))return{type:59,g:2};var a=xa(e,"typeswitchExprCaseClause");for(let s=0;s<n.length;s++){var o=ga(a[s],"*");switch(o[0]){case"sequenceType":if(o=Ma(o,t,n[s]))return 59!==o.type&&Ea(e,"type",o),o;continue;case"sequenceTypeUnion":for(r=xa(o,"*"),a=0;2>a;a++)if(o=Ma(r[a],t,n[s]))return 59!==o.type&&Ea(e,"type",o),o;default:return{type:59,g:2}}}return 59!==r.type&&Ea(e,"type",r),r}(e,n,r,Ga(va(e,["typeswitchExprDefaultClause","resultExpr"])[1],t))}],["quantifiedExpr",(e,t)=>(xa(e,"*").map((e=>Ga(e,t))),function(e){const t={type:0,g:3};return Ea(e,"type",t),t}(e))],["x:stackTrace",(e,t)=>Ga((e=xa(e,"*"))[0],t)],["queryBody",(e,t)=>Ga(e[1],t)],["flworExpr",(e,t)=>function(e,t){var n=Ga;let r=!1;for(var a=1;a<e.length;a++)switch(e[a][0]){case"letClause":qa(t);var o=e[a],s=t,i=n,l=va(o,["letClauseItem","typedVariableBinding","varName"]);l=ba(l),i=i((o=va(o,["letClauseItem","letExpr"]))[1],s),Va(s,l.localName,i);break;case"forClause":r=!0,qa(t),ka(e[a],t,n);break;case"whereClause":qa(t),n(s=e[a],t),Ea(s,"type",{type:0,g:3});break;case"orderByClause":qa(t);break;case"returnClause":return s=n,Ea(n=va(a=e[a],["*"]),"type",t=s(n,t)),Ea(a,"type",t),(n=t)?(r&&(n={type:n.type,g:2}),59!==n.type&&Ea(e,"type",n),n):{type:59,g:2};default:return(n=n(e[a],t))?(r&&(n={type:n.type,g:2}),59!==n.type&&Ea(e,"type",n),n):{type:59,g:2}}if(!(0<t.h))throw Error("Variable scope out of bound");t.h--,t.o.pop(),t.v.pop()}(e,t)],["varRef",(e,t)=>{const n=ba(ga(e,"name"));var r;e:{for(r=t.h;0<=r;r--){const e=t.o[r][n.localName];if(e){r=e;break e}}r=void 0}return r&&59!==r.type&&Ea(e,"type",r),null===n.namespaceURI&&(void 0!==(t=t.$(n.prefix))&&Ea(e,"URI",t)),r}]]);function qa(e){e.h++,e.o.push({}),e.v.push({})}function Va(e,t,n){if(e.o[e.h][t])throw Error(`Another variable of in the scope ${e.h} with the same name ${t} already exists`);e.o[e.h][t]=n}var Ya=class{constructor(e){this.h=0,this.ga=e,this.o=[{}],this.v=[{}]}$(e){for(let t=this.h;0<=t;t--){const n=this.v[t][e];if(void 0!==n)return n}return this.ga?this.ga.$(e):void 0}},za=class extends Qn{constructor(e,t){super(new dr({external:1}),e,{B:e.every((e=>e.B))},!1,t),this.l=e}h(e,t){return 0===this.l.length?$.m(new ie([])):Jn(this.l[0],e,t).N((e=>$.m(new ie(e.map((e=>L($.m(e))))))))}},Ja=class extends Qn{constructor(e,t){super(new dr({external:1}),e,{B:e.every((e=>e.B))},!1,t),this.l=e}h(e,t){return $.m(new ie(this.l.map((n=>L(Jn(n,e,t))))))}};function Qa(e){if(null===e)throw We("context is absent, it needs to be present to use axes.");if(!T(e.type,53))throw Error("XPTY0020: Axes can only be applied to nodes.");return e.value}var Ka=class extends Qn{constructor(e,t){t=t||{Qa:!1},super(e.o,[e],{P:"reverse-sorted",W:!1,subtree:!1,B:!1}),this.l=e,this.s=!!t.Qa}h(e,t){t=t.h,e=Qa(e.M);var n=this.l.D();return n=n&&(n.startsWith("name-")||"type-1"===n)?"type-1":null,$.create(function(e,t,n){let r=t;return{next:()=>{if(!r)return A;const t=r;return r=ne(e,t,n),E(ce(t))}}}(t,this.s?e:ne(t,e,n),n)).filter((e=>this.l.l(e)))}};const Wa=new Map([["type-1-or-type-2",["name","type-1","type-2"]],["type-1",["name"]],["type-2",["name"]]]);function Za(e,t){if(null===e)return t;if(null===t||e===t)return e;const n=e.startsWith("name-")?"name":e,r=t.startsWith("name-")?"name":t,a=Wa.get(n);return void 0!==a&&a.includes(r)?t:void 0!==(t=Wa.get(r))&&t.includes(n)?e:"empty"}var eo=class extends Qn{constructor(e,t){super(new dr({attribute:1}),[e],{P:"unsorted",subtree:!0,W:!0,B:!1}),this.l=e,this.s=Za(this.l.D(),t)}h(e,t){return t=t.h,1!==(e=Qa(e.M)).node.nodeType?$.empty():(e=Q(t,e,this.s).filter((e=>"http://www.w3.org/2000/xmlns/"!==e.node.namespaceURI)).map((e=>ce(e))).filter((e=>this.l.l(e))),$.create(e))}D(){return"type-1"}},to=class extends Qn{constructor(e,t){super(e.o,[e],{P:"sorted",subtree:!0,W:!0,B:!1}),this.s=e,this.l=Za(t,e.D())}h(e,t){const n=t.h,r=Qa(e.M);if(1!==(e=r.node.nodeType)&&9!==e)return $.empty();let a=null,o=!1;return $.create({next:()=>{for(;!o;){if(!a){if(a=ee(n,r,this.l),!a){o=!0;continue}return E(ce(a))}if(a=re(n,a,this.l))return E(ce(a));o=!0}return A}}).filter((e=>this.s.l(e)))}};function no(e,t,n){const r=t.node.nodeType;if(1!==r&&9!==r)return{next:()=>A};let a=ee(e,t,n);return{next(){if(!a)return A;const t=a;return a=re(e,a,n),E(t)}}}var ro=class extends Qn{constructor(e,t){t=t||{Qa:!1},super(e.o,[e],{B:!1,W:!1,P:"sorted",subtree:!0}),this.l=e,this.s=!!t.Qa,this.A=(e=this.l.D())&&(e.startsWith("name-")||"type-1"===e)||"type-1-or-type-2"===e?"type-1":null}h(e,t){return e=function(e,t,n){const r=[Et(t)];return{next:t=>{if(0<r.length&&0!=(1&t)&&r.shift(),!r.length)return A;for(t=r[0].next(0);t.done;){if(r.shift(),!r.length)return A;t=r[0].next(0)}return r.unshift(no(e,t.value,n)),E(ce(t.value))}}}(t=t.h,e=Qa(e.M),this.A),this.s||e.next(0),$.create(e).filter((e=>this.l.l(e)))}};function ao(e,t,n){var r=e.node.nodeType;if(1!==r&&9!==r)return e;for(r=te(t,e,n);null!==r;){if(1!==r.node.nodeType)return r;r=te(t,e=r,n)}return e}function oo(e,t,n=!1,r){if(n){let n=t,a=!1;return{next:()=>{if(a)return A;if(Tt(n,t))return n=ao(t,e,r),Tt(n,t)?(a=!0,A):E(ce(n));const o=n.node.nodeType,s=9===o||2===o?null:ae(e,n,r);return null!==s?(n=ao(s,e,r),E(ce(n))):(n=9===o?null:ne(e,n,r),Tt(n,t)?(a=!0,A):E(ce(n)))}}}const a=[no(e,t,r)];return{next:()=>{if(!a.length)return A;let t=a[0].next(0);for(;t.done;){if(a.shift(),!a.length)return A;t=a[0].next(0)}return a.unshift(no(e,t.value,r)),E(ce(t.value))}}}var so=class extends Qn{constructor(e){super(e.o,[e],{P:"sorted",W:!0,subtree:!1,B:!1}),this.l=e,this.s=(e=this.l.D())&&(e.startsWith("name-")||"type-1"===e)?"type-1":null}h(e,t){return t=t.h,e=Qa(e.M),$.create(function(e,t,n){const r=[];for(;t&&9!==t.node.nodeType;t=ne(e,t,null)){const a=re(e,t,n);a&&r.push(a)}let a=null;return{next:()=>{for(;a||r.length;){if(!a){a=oo(e,r[0],!1,n);var t=E(ce(r[0]));const o=re(e,r[0],n);return o?r[0]=o:r.shift(),t}if(!(t=a.next(0)).done)return t;a=null}return A}}}(t,e,this.s)).filter((e=>this.l.l(e)))}};var io=class extends Qn{constructor(e,t){super(e.o,[e],{P:"sorted",W:!0,subtree:!1,B:!1}),this.l=e,this.s=Za(this.l.D(),t)}h(e,t){return t=t.h,e=Qa(e.M),$.create(function(e,t,n){return{next:()=>(t=t&&re(e,t,n))?E(ce(t)):A}}(t,e,this.s)).filter((e=>this.l.l(e)))}},lo=class extends Qn{constructor(e,t){super(e.o,[e],{P:"reverse-sorted",W:!0,subtree:!0,B:!1}),this.l=e,this.s=Za(t,this.l.D())}h(e,t){return(e=ne(t=t.h,e=Qa(e.M),this.s))?(e=ce(e),this.l.l(e)?$.m(e):$.empty()):$.empty()}};var co=class extends Qn{constructor(e){super(e.o,[e],{B:!1,W:!0,P:"reverse-sorted",subtree:!1}),this.l=e,this.s=(e=this.l.D())&&(e.startsWith("name-")||"type-1"===e)?"type-1":null}h(e,t){return t=t.h,e=Qa(e.M),$.create(function(e,t,n){const r=[];for(;t&&9!==t.node.nodeType;t=ne(e,t,null)){const a=ae(e,t,n);null!==a&&r.push(a)}let a=null;return{next:()=>{for(;a||r.length;){a||=oo(e,r[0],!0,n);var t=a.next(0);if(t.done){a=null,t=ae(e,r[0],n);const o=E(ce(r[0]));return null===t?r.shift():r[0]=t,o}return t}return A}}}(t,e,this.s)).filter((e=>this.l.l(e)))}};var uo=class extends Qn{constructor(e,t){super(e.o,[e],{B:!1,W:!0,P:"reverse-sorted",subtree:!1}),this.l=e,this.s=Za(this.l.D(),t)}h(e,t){return t=t.h,e=Qa(e.M),$.create(function(e,t,n){return{next:()=>(t=t&&ae(e,t,n))?E(ce(t)):A}}(t,e,this.s)).filter((e=>this.l.l(e)))}},ho=class extends Qn{constructor(e,t){super(e.o,[e],{P:"sorted",subtree:!0,W:!0,B:!1}),this.l=e,this.s=Za(this.l.D(),t)}h(e){return Qa(e.M),this.l.l(e.M)?$.m(e.M):$.empty()}D(){return this.s}},po=class extends lr{constructor(e,t,n,r){super(e.o.add(t.o).add(n.o),[e,t,n],{B:e.B&&t.B&&n.B,W:t.W===n.W&&t.W,P:t.ia===n.ia?t.ia:"unsorted",subtree:t.subtree===n.subtree&&t.subtree},r),this.l=e}A(e,t,n){let r=null;const a=n[0](e);return $.create({next:t=>(r||(r=(a.fa()?n[1](e):n[2](e)).value),r.next(t))})}v(e){if(super.v(e),this.l.J)throw $n()}};function mo(e){return e.h instanceof Error?e.location:mo(e.h)}function fo(e){let t;return t=e.h instanceof jr?["Inner error:",e.h.message]:e.h instanceof Error?[e.h.toString()]:fo(e.h),t.push(` at <${e.o}>:${e.location.start.line}:${e.location.start.ha} - ${e.location.end.line}:${e.location.end.ha}`),t}var go=class{constructor(e,t,n){this.location=e,this.o=t,this.h=n}},yo=class extends lr{constructor(e,t,n){super(n.o,[n],{B:n.B,W:n.W,P:n.ia,subtree:n.subtree}),this.l=t,this.L={end:{ha:e.end.ha,line:e.end.line,offset:e.end.offset},start:{ha:e.start.ha,line:e.start.line,offset:e.start.offset}}}A(e,t,[n]){let r;try{r=n(e)}catch(e){throw new go(this.L,this.l,e)}return $.create({next:e=>{try{return r.value.next(e)}catch(e){throw new go(this.L,this.l,e)}}})}v(e){try{super.v(e)}catch(e){throw new go(this.L,this.l,e)}}};function wo(e,t,n,r){let a=[];const o=e.L(t,n,r,(n=>{if(e.l instanceof xo){return ir(wo(e.l,t,n,r),(e=>a=e))}let o=null;return $.create({next:()=>{for(;;){if(!o){var t=n.next(0);if(t.done)return A;t=e.l.s(t.value,r),o=ir(t,(e=>a=ar(a,e))).value}if(!(t=o.next(0)).done)return t;o=null}}})}));let s=!1;return{next:()=>{if(s)return A;const e=o.O();return s=!0,E(new Kn(e,a))}}}function vo(e,t,n,r){return e.L(t,n,r,(n=>{if(e.l instanceof xo)return vo(e.l,t,n,r);let a=null;return $.create({next:()=>{for(;;){if(!a){var t=n.next(0);if(t.done)return A;a=Jn(e.l,t.value,r).value}if(!(t=a.next(0)).done)return t;a=null}}})}))}var xo=class extends Qn{constructor(e,t,n,r){super(e,t,n,!0),this.l=r,this.J=this.l.J}h(e,t){return this.L(e,Et(e),t,(n=>{if(this.l instanceof xo)return vo(this.l,e,n,t);let r=null;return $.create({next:e=>{for(;;){if(!r){var a=n.next(0);if(a.done)return A;r=Jn(this.l,a.value,t).value}if(!(a=r.next(e)).done)return a;r=null}}})}))}s(e,t){return wo(this,e,Et(e),t)}v(e){super.v(e),this.J=this.l.J;for(const e of this.Ka)if(e!==this.l&&e.J)throw $n()}},bo=class extends xo{constructor(e,t,n,r){super(t.o.add(r.o),[t,r],{B:!1},r),this.S=e.prefix,this.ma=e.namespaceURI,this.Mb=e.localName,this.wb=null,this.A=n,this.La=null,this.ya=t}L(e,t,n,r){let a=null,o=null,s=0;return r({next:()=>{for(;;){if(!a){var e=t.next(0);if(e.done)return A;o=e.value,s=0,a=Jn(this.ya,o,n).value}const r=a.next(0);if(!r.done)return s++,e={[this.wb]:()=>$.m(r.value)},this.La&&(e[this.La]=()=>$.m(new I(5,s))),E(Ye(o,e));a=null}}})}v(e){if(this.S&&(this.ma=e.$(this.S),!this.ma&&this.S))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.S} in a for expression`);if(this.ya.v(e),ca(e),this.wb=da(e,this.ma,this.Mb),this.A){if(this.A.prefix&&(this.A.namespaceURI=e.$(this.A.prefix),!this.A.namespaceURI&&this.A.prefix))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.S} in the positionalVariableBinding in a for expression`);this.La=da(e,this.A.namespaceURI,this.A.localName)}if(this.l.v(e),ma(e),this.ya.J)throw $n();this.l.J&&(this.J=!0)}},Ao=class extends Qn{constructor(e,t,n){super(new dr({external:1}),[n],{B:!1,P:"unsorted"}),this.S=e.map((({name:e})=>e)),this.A=e.map((({type:e})=>e)),this.s=null,this.L=t,this.l=n}h(e,t){const n=new H({j:this.A,arity:this.A.length,Xa:!0,J:this.l.J,localName:"dynamic-function",namespaceURI:"",i:this.L,value:(n,r,a,...o)=>(n=Ye(je(e,-1,null,$.empty()),this.s.reduce(((e,t,n)=>(e[t]=L(o[n]),e)),Object.create(null))),Jn(this.l,n,t))});return $.m(n)}v(e){if(ca(e),this.s=this.S.map((t=>da(e,t.namespaceURI,t.localName))),this.l.v(e),ma(e),this.l.J)throw Error("Not implemented: inline functions can not yet be updating.")}},Eo=class extends xo{constructor(e,t,n){if(super(t.o.add(n.o),[t,n],{B:!1,W:n.W,P:n.ia,subtree:n.subtree},n),e.prefix||e.namespaceURI)throw Error("Not implemented: let expressions with namespace usage.");this.A=e.prefix,this.S=e.namespaceURI,this.La=e.localName,this.ma=t,this.ya=null}L(e,t,n,r){return r({next:()=>{var e=t.next(0);return e.done?A:E(e=Ye(e=e.value,{[this.ya]:L(Jn(this.ma,e,n))}))}})}v(e){if(this.A&&(this.S=e.$(this.A),!this.S&&this.A))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.A} using in a for expression`);if(this.ma.v(e),ca(e),this.ya=da(e,this.S,this.La),this.l.v(e),ma(e),this.J=this.l.J,this.ma.J)throw $n()}},No=class extends Qn{constructor(e,t){let n;switch(super(new dr({}),[],{B:!0,P:"sorted"},!1,t),t.type){case 5:n=y(parseInt(e,10),t.type);break;case 1:n=y(e,t.type);break;case 4:case 3:n=y(parseFloat(e),t.type);break;default:throw new TypeError("Type "+t+" not expected in a literal")}this.l=()=>$.m(n)}h(){return this.l()}},To=class extends Qn{constructor(e,t){super(new dr({external:1}),e.reduce(((e,{key:t,value:n})=>e.concat(t,n)),[]),{B:!1},!1,t),this.l=e}h(e,t){const n=this.l.map((n=>rt(Jn(n.key,e,t),t).Y({default:()=>{throw Error("XPTY0004: A key of a map should be a single atomizable value.")},m:e=>e})));return ue(n,(n=>$.m(new pe(n.map(((n,r)=>({key:n,value:L(Jn(this.l[r].value,e,t))})))))))}},Bo=class extends Qn{constructor(e,t,n){super(new dr({external:1}),[],{B:!0},!1,n),this.s=t,this.A=e,this.l=null}h(){const e=new H({j:this.l.j,J:this.l.J,arity:this.s,localName:this.l.localName,namespaceURI:this.l.namespaceURI,i:this.l.i,value:this.l.callFunction});return $.m(e)}v(e){let t=this.A.namespaceURI,n=this.A.localName;const r=this.A.prefix;if(null===t){const a=e.Sa({localName:n,prefix:r},this.s);if(!a)throw Error(`XPST0017: The function ${r?r+":":""}${n} with arity ${this.s} could not be resolved. ${Vr(n)}`);t=a.namespaceURI,n=a.localName}if(this.l=e.va(t,n,this.s)||null,!this.l)throw e=this.A,Error(`XPST0017: Function ${e.namespaceURI?`Q{${e.namespaceURI}}`:e.prefix?`${e.prefix}:`:""}${e.localName} with arity of ${this.s} not registered. ${Vr(n)}`);super.v(e)}};const Io={5:5,27:5,28:5,31:5,32:5,33:5,34:5,30:5,36:5,35:5,38:5,37:5,29:5,4:4,6:6,3:3};var Co=class extends Qn{constructor(e,t,n){super(t.o,[t],{B:!1},!1,n),this.s=t,this.l=e}h(e,t){return rt(Jn(this.s,e,t),t).N((e=>{if(0===e.length)return $.empty();var t=e[0];if(this.type)return e="+"===this.l?+t.value:-t.value,0===t.type&&(e=Number.NaN),$.m(y(e,this.type.type));if(1<e.length)throw Error("XPTY0004: The operand to a unary operator must be a sequence with a length less than one");return T(t.type,19)?(t=At(t,3).value,$.m(y("+"===this.l?t:-t,3))):T(t.type,2)?"+"===this.l?$.m(t):$.m(y(-1*t.value,Io[t.type])):$.m(y(Number.NaN,3))}))}},Oo=class extends Qn{constructor(e,t){super(e.reduce(((e,t)=>e.add(t.o)),new dr({})),e,{B:e.every((e=>e.B))},!1,t),this.l=e,this.s=e.reduce(((e,t)=>Za(e,t.D())),null)}h(e,t){let n=0,r=null,a=!1,o=null;if(null!==e){const t=e.M;null!==t&&T(t.type,53)&&(o=_(t.value))}return $.create({next:()=>{if(!a){for(;n<this.l.length;){if(!r){const s=this.l[n];if(null!==o&&null!==s.D()&&!o.includes(s.D()))return n++,a=!0,E(v);r=Jn(s,e,t)}if(!1===r.fa())return a=!0,E(v);r=null,n++}return a=!0,E(w)}return A}})}D(){return this.s}},So=class extends Qn{constructor(e,t){let n;for(super(e.reduce(((e,t)=>0<hr(e,t.o)?e:t.o),new dr({})),e,{B:e.every((e=>e.B))},!1,t),t=0;t<e.length&&(void 0===n&&(n=e[t].D()),null!==n);++t)if(n!==e[t].D()){n=null;break}this.s=n,this.l=e}h(e,t){let n=0,r=null,a=!1,o=null;if(null!==e){const t=e.M;null!==t&&T(t.type,53)&&(o=_(t.value))}return $.create({next:()=>{if(!a){for(;n<this.l.length;){if(!r){const a=this.l[n];if(null!==o&&null!==a.D()&&!o.includes(a.D())){n++;continue}r=Jn(a,e,t)}if(!0===r.fa())return a=!0,E(w);r=null,n++}return a=!0,E(v)}return A}})}D(){return this.s}};function Fo(e,t){let n;return $.create({next:r=>{for(;;){if(!n){var a=e.value.next(r);if(a.done)return A;n=nt(a.value,t)}if(!(a=n.value.next(r)).done)return a;n=null}}})}function Do(e,t,n){function r(e,t){return{T:s?s(e):e,U:i?i(t):t}}function a(e){return T(t,e)&&T(n,e)}function o(e){return 0<e.filter((e=>T(t,e))).length&&0<e.filter((e=>T(n,e))).length}let s=null,i=null;if(T(t,19)&&T(n,19)?t=n=1:T(t,19)?(s=e=>At(e,n),t=n):T(n,19)&&(i=e=>At(e,t),n=t),T(t,23)&&T(n,23))return function(e,t){if("eqOp"===e)return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value.namespaceURI===a.value.namespaceURI&&r.value.localName===a.value.localName};if("neOp"===e)return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value.namespaceURI!==a.value.namespaceURI||r.value.localName!==a.value.localName};throw Error('XPTY0004: Only the "eq" and "ne" comparison is defined for xs:QName')}(e,r);if(a(0)||o([1,47,61])||o([2,47,61])||a(20)||a(22)||a(21)||o([1,20])){var l=function(e,t){switch(e){case"eqOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value===a.value};case"neOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value!==a.value};case"ltOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value<a.value};case"leOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value<=a.value};case"gtOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value>a.value};case"geOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value>=a.value}}}(e,r);if(void 0!==l)return l}if(a(16)&&(l=function(e,t){switch(e){case"ltOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value.ea<a.value.ea};case"leOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return me(r.value,a.value)||r.value.ea<a.value.ea};case"gtOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value.ea>a.value.ea};case"geOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return me(r.value,a.value)||r.value.ea>a.value.ea}}}(e,r),void 0!==l)||a(17)&&(l=function(e,t){switch(e){case"eqOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return me(r.value,a.value)};case"ltOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value.ca<a.value.ca};case"leOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return me(r.value,a.value)||r.value.ca<a.value.ca};case"gtOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return r.value.ca>a.value.ca};case"geOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return me(r.value,a.value)||r.value.ca>a.value.ca}}}(e,r),void 0!==l)||a(18)&&(l=function(e,t){switch(e){case"eqOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return me(r.value,a.value)};case"neOp":return(e,n)=>{const{T:r,U:a}=t(e,n);return!me(r.value,a.value)}}}(e,r),void 0!==l))return l;if((a(9)||a(7)||a(8))&&(l=function(e,t){switch(e){case"eqOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return De(a.value,o.value,qe(r))};case"neOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return!De(a.value,o.value,qe(r))};case"ltOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return e=qe(r),0>Fe(a.value,o.value,e)};case"leOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return(e=De(a.value,o.value,qe(r)))||(r=qe(r),e=0>Fe(a.value,o.value,r)),e};case"gtOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return e=qe(r),0<Fe(a.value,o.value,e)};case"geOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return(e=De(a.value,o.value,qe(r)))||(r=qe(r),e=0<Fe(a.value,o.value,r)),e}}}(e,r),void 0!==l))return l;if((a(11)||a(12)||a(13)||a(14)||a(15))&&(l=function(e,t){switch(e){case"eqOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return De(a.value,o.value,qe(r))};case"neOp":return(e,n,r)=>{const{T:a,U:o}=t(e,n);return!De(a.value,o.value,qe(r))}}}(e,r),void 0!==l))return l;throw Error(`XPTY0004: ${e} not available for ${C[t]} and ${C[n]}`)}const ko=Object.create(null);function Ro(e,t,n){const r=`${t}~${n}~${e}`;let a=ko[r];return a||=ko[r]=Do(e,t,n),a}var Mo=class extends Qn{constructor(e,t,n){super(t.o.add(n.o),[t,n],{B:!1}),this.l=t,this.A=n,this.s=e}h(e,t){const n=Jn(this.l,e,t),r=Jn(this.A,e,t),a=Fo(n,t),o=Fo(r,t);return a.Y({empty:()=>$.empty(),m:()=>o.Y({empty:()=>$.empty(),m:()=>{const t=a.first(),n=o.first();return Ro(this.s,t.type,n.type)(t,n,e)?$.aa():$.V()},multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton.")}}),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton.")}})}};const Uo={equalOp:"eqOp",notEqualOp:"neOp",lessThanOrEqualOp:"leOp",lessThanOp:"ltOp",greaterThanOrEqualOp:"geOp",greaterThanOp:"gtOp"};var Go=class extends Qn{constructor(e,t,n){super(t.o.add(n.o),[t,n],{B:!1}),this.l=t,this.A=n,this.s=e}h(e,t){const n=Jn(this.l,e,t),r=Jn(this.A,e,t);return n.Y({empty:()=>$.V(),default:()=>r.Y({empty:()=>$.V(),default:()=>{const a=Fo(n,t),o=Fo(r,t);return function(e,t,n,r){return e=Uo[e],n.N((n=>t.filter((t=>{for(let s=0,i=n.length;s<i;++s){let i,l,c=n[s];var a=t.type,o=c.type;(T(a,19)||T(o,19))&&(T(a,2)?i=3:T(o,2)?l=3:T(a,17)?i=17:T(o,17)?l=17:T(a,16)?i=16:T(o,16)?l=16:T(a,19)?l=o:T(o,19)&&(i=a));const[u,h]=[l,i];if(a=u,o=h,a?t=At(t,a):o&&(c=At(c,o)),Ro(e,t.type,c.type)(t,c,r))return!0}return!1})).Y({default:()=>$.aa(),empty:()=>$.V()})))}(this.s,a,o,e)}})})}};function $o(e,t,n,r){if(!T(n,53)||!T(r,53))throw Error("XPTY0004: Sequences to compare are not nodes");switch(e){case"isOp":return function(e,t){return e!==t||47!==e&&53!==e&&54!==e&&55!==e&&56!==e&&57!==e&&58!==e?()=>!1:(e,t)=>Tt(e.first().value,t.first().value)}(n,r);case"nodeBeforeOp":return t?(e,n)=>0>St(t,e.first(),n.first()):void 0;case"nodeAfterOp":return t?(e,n)=>0<St(t,e.first(),n.first()):void 0;default:throw Error("Unexpected operator")}}var Lo=class extends Qn{constructor(e,t,n){super(t.o.add(n.o),[t,n],{B:!1}),this.l=t,this.A=n,this.s=e}h(e,t){const n=Jn(this.l,e,t),r=Jn(this.A,e,t);return n.Y({empty:()=>$.empty(),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton")},m:()=>r.Y({empty:()=>$.empty(),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton")},m:()=>{const a=n.first(),o=r.first();return $o(this.s,t.h,a.type,o.type)(n,r,e)?$.aa():$.V()}})})}};function Po(e,t,n,r){return n.N((n=>{if(n.some((e=>!T(e.type,53))))throw Error(`XPTY0004: Sequences given to ${e} should only contain nodes.`);return"sorted"===r?$.create(n):"reverse-sorted"===r?$.create(n.reverse()):$.create(Ft(t,n))}))}var Ho=class extends Qn{constructor(e,t,n,r){super(0<hr(t.o,n.o)?t.o:n.o,[t,n],{B:t.B&&n.B},!1,r),this.l=e,this.s=t,this.A=n}h(e,t){const n=Po(this.l,t.h,Jn(this.s,e,t),this.s.ia);e=Po(this.l,t.h,Jn(this.A,e,t),this.A.ia);const r=n.value,a=e.value;let o=null,s=null,i=!1,l=!1;return $.create({next:()=>{if(i)return A;for(;!l;){if(!o){var e=r.next(0);if(e.done)return i=!0,A;o=e.value}if(!s){if((e=a.next(0)).done){l=!0;break}s=e.value}if(Tt(o.value,s.value)){if(e=E(o),s=o=null,"intersectOp"===this.l)return e}else if(0>St(t.h,o,s)){if(e=E(o),o=null,"exceptOp"===this.l)return e}else s=null}return"exceptOp"===this.l?null!==o?(e=E(o),o=null,e):r.next(0):(i=!0,A)}})}},jo=class extends lr{constructor(e,t){super(e.reduce(((e,t)=>e.add(t.o)),new dr({})),e,{P:"unsorted",B:e.every((e=>e.B))},t)}A(e,t,n){return n.length?Qe(n.map((t=>t(e)))):$.empty()}},_o=class extends Qn{constructor(e,t,n){super(new dr({}).add(e.o),[e,t],{B:e.B&&t.B},!1,n),this.l=e,this.s=t}h(e,t){const n=_e(e,Jn(this.l,e,t));let r=null,a=null,o=!1;return $.create({next:e=>{for(;!o;){if(!r&&(r=n.next(e),r.done))return o=!0,A;a||=Jn(this.s,r.value,t);const s=a.value.next(e);if(!s.done)return s;r=a=null}}})}},Xo=class extends Qn{constructor(e,t,n){if(super(e.o,[e],{B:!1}),this.l=F(t.prefix?`${t.prefix}:${t.localName}`:t.localName),46===this.l||45===this.l||44===this.l)throw Error("XPST0080: Casting to xs:anyAtomicType, xs:anySimpleType or xs:NOTATION is not permitted.");if(t.namespaceURI)throw Error("Not implemented: castable as expressions with a namespace URI.");this.A=e,this.s=n}h(e,t){const n=rt(Jn(this.A,e,t),t);return n.Y({empty:()=>this.s?$.aa():$.V(),m:()=>n.map((e=>bt(e,this.l).u?w:v)),multiple:()=>$.V()})}},qo=class extends Qn{constructor(e,t,n){if(super(e.o,[e],{B:!1}),this.l=F(t.prefix?`${t.prefix}:${t.localName}`:t.localName),46===this.l||45===this.l||44===this.l)throw Error("XPST0080: Casting to xs:anyAtomicType, xs:anySimpleType or xs:NOTATION is not permitted.");if(t.namespaceURI)throw Error("Not implemented: casting expressions with a namespace URI.");this.A=e,this.s=n}h(e,t){const n=rt(Jn(this.A,e,t),t);return n.Y({empty:()=>{if(!this.s)throw Error("XPTY0004: Sequence to cast is empty while target type is singleton.");return $.empty()},m:()=>n.map((e=>At(e,this.l))),multiple:()=>{throw Error("XPTY0004: Sequence to cast is not singleton or empty.")}})}};function Vo(e,t){const n=e.value;let r=null,a=!1;return $.create({next:()=>{for(;!a;){if(!r){var e=n.next(0);if(e.done)return a=!0,E(w);r=t(e.value)}if(e=r.fa(),r=null,!1===e)return a=!0,E(v)}return A}})}var Yo=class extends Qn{constructor(e,t,n,r){super(e.o,[e],{B:!1},!1,r),this.A=e,this.s=t,this.l=n}h(e,t){const n=Jn(this.A,e,t);return n.Y({empty:()=>"?"===this.l||"*"===this.l?$.aa():$.V(),multiple:()=>"+"===this.l||"*"===this.l?Vo(n,(n=>{const r=$.m(n);return n=je(e,0,n,r),Jn(this.s,n,t)})):$.V(),m:()=>Vo(n,(n=>{const r=$.m(n);return n=je(e,0,n,r),Jn(this.s,n,t)}))})}};function zo(e,t){return!(null===e||null===t||!T(e.type,53)||!T(t.type,53))&&Tt(e.value,t.value)}function Jo(e){let t=e.next(0);if(t.done)return $.empty();let n=null,r=null;return $.create({next(a){if(t.done)return A;let o;n||(n=t.value.value);do{if(o=n.next(a),o.done){if(t=e.next(0),t.done)return o;n=t.value.value}}while(o.done||zo(o.value,r));return r=o.value,o}})}function Qo(e,t){const n=[];!function(){for(var e=t.next(0);!e.done;){const r=e.value.value;e={current:r.next(0),next:e=>r.next(e)},e.current.done||n.push(e),e=t.next(0)}}();let r=null,a=!1;return $.create({[Symbol.iterator](){return this},next:()=>{let t;a||(a=!0,n.every((e=>T(e.current.value.type,53)))&&n.sort(((t,n)=>St(e,t.current.value,n.current.value))));do{if(!n.length)return A;const r=n.shift();if(t=r.current,r.current=r.next(0),!T(t.value.type,53))return t;if(!r.current.done){let t=0,a=n.length-1,o=0;for(;t<=a;){o=Math.floor((t+a)/2);const s=St(e,r.current.value,n[o].current.value);if(0===s){t=o;break}0<s?t=o+1:a=o-1}n.splice(t,0,r)}}while(zo(t.value,r));return r=t.value,t}})}var Ko=class extends Qn{constructor(e,t){super(e.reduce(((e,t)=>0<hr(e,t.o)?e:t.o),new dr({})),e,{B:e.every((e=>e.B))},!1,t),this.l=e}h(e,t){if(this.l.every((e=>"sorted"===e.ia))){let n=0;return Qo(t.h,{next:()=>n>=this.l.length?A:E(Jn(this.l[n++],e,t))}).map((e=>{if(!T(e.type,53))throw Error("XPTY0004: The sequences to union are not of type node()*");return e}))}return Qe(this.l.map((n=>Jn(n,e,t)))).N((e=>{if(e.some((e=>!T(e.type,53))))throw Error("XPTY0004: The sequences to union are not of type node()*");return e=Ft(t.h,e),$.create(e)}))}};function Wo(e){return e.every((e=>null===e||T(e.type,5)||T(e.type,4)))||null!==e.map((e=>e?at(e.type):null)).reduce(((e,t)=>null===t||t===e?e:null))?e:e.every((e=>null===e||T(e.type,1)||T(e.type,20)))?e.map((e=>e?At(e,1):null)):e.every((e=>null===e||T(e.type,4)||T(e.type,6)))?e.map((e=>e?At(e,6):e)):e.every((e=>null===e||T(e.type,4)||T(e.type,6)||T(e.type,3)))?e.map((e=>e?At(e,3):e)):null}var Zo=class extends xo{constructor(e,t){super(new dr({}),[t,...e.map((e=>e.ba))],{B:!1,W:!1,P:"unsorted",subtree:!1},t),this.A=e}L(e,t,n,r){if(this.A[1])throw Error("More than one order spec is not supported for the order by clause.");const a=[];let o,s,i=!1,l=null;const c=this.A[0];return $.create({next:()=>{if(!i){for(var u=t.next(0);!u.done;)a.push(u.value),u=t.next(0);if(u=a.map((e=>c.ba.h(e,n))).map((e=>rt(e,n))),u.find((e=>!e.G()&&!e.ua())))throw Error("XPTY0004: Order by only accepts empty or singleton sequences");if(o=u.map((e=>e.first())),o=o.map((e=>null===e?e:T(19,e.type)?At(e,1):e)),function(e){return(e=e.find((e=>!!e)))?at(e.type):null}(o)&&(o=Wo(o),!o))throw Error("XPTY0004: Could not cast values");u=o.length,s=o.map(((e,t)=>t));for(let t=0;t<u;t++)if(t+1!==u)for(let n=t;0<=n;n--){const t=n,r=n+1;if(r===u)continue;const a=o[s[t]],i=o[s[r]];if(null!==i||null!==a){if(c.$b){if(null===a)continue;if(null===i&&null!==a){[s[t],s[r]]=[s[r],s[t]];continue}if(isNaN(i.value)&&null!==a&&!isNaN(a.value)){[s[t],s[r]]=[s[r],s[t]];continue}}else{if(null===i)continue;if(null===a&&null!==i){[s[t],s[r]]=[s[r],s[t]];continue}if(isNaN(a.value)&&null!==i&&!isNaN(i.value)){[s[t],s[r]]=[s[r],s[t]];continue}}Ro("gtOp",a.type,i.type)(a,i,e)&&([s[t],s[r]]=[s[r],s[t]])}}let h=c.zb?0:o.length-1;l=r({next:()=>c.zb?h>=o.length?A:E(a[s[h++]]):0>h?A:E(a[s[h--]])}).value,i=!0}return l.next(0)}})}},es=class extends Qn{constructor(e){super(e?e.o:new dr({}),e?[e]:[],{P:"sorted",subtree:!1,W:!1,B:!1}),this.l=e}h(e,t){if(null===e.M)throw We("context is absent, it needs to be present to use paths.");var n=t.h;let r=e.M.value;for(;9!==r.node.nodeType;)if(r=ne(n,r),null===r)throw Error("XPDY0050: the root node of the context node is not a document node.");return n=$.m(ce(r)),this.l?Jn(this.l,je(e,0,n.first(),n),t):n}},ts=class extends Qn{constructor(e){super(new dr({}),[],{P:"sorted"},!1,e)}h(e){if(null===e.M)throw We('context is absent, it needs to be present to use the "." operator');return $.m(e.M)}};var ns=class extends Qn{constructor(e,t){const n=e.every((e=>e.W)),r=e.every((e=>e.subtree));super(e.reduce(((e,t)=>e.add(t.o)),new dr({})),e,{B:!1,W:n,P:t?"sorted":"unsorted",subtree:r}),this.l=e,this.s=t}h(e,t){let n=!0;return this.l.reduce(((r,a,o)=>{const s=null===r?Et(e):_e(e,r);let i;if(r={next:e=>{if((e=s.next(e)).done)return A;if(null!==e.value.M&&!T(e.value.M.type,53)&&0<o)throw Error("XPTY0019: The result of E1 in a path expression E1/E2 should not evaluate to a sequence of nodes.");return E(Jn(a,e.value,t))}},this.s)switch(a.ia){case"reverse-sorted":const e=r;r={next:t=>(t=e.next(t)).done?t:E(t.value.N((e=>$.create(e.reverse()))))};case"sorted":if(a.subtree&&n){i=Jo(r);break}i=Qo(t.h,r);break;case"unsorted":return Jo(r).N((e=>$.create(function(e,t){let n=!1,r=!1;if(t.forEach((e=>{T(e.type,53)?n=!0:r=!0})),r&&n)throw Error("XPTY0018: The path operator should either return nodes or non-nodes. Mixed sequences are not allowed.");return n?Ft(e,t):t}(t.h,e))))}else i=Jo(r);return n=n&&a.W,i}),null)}D(){return this.l[0].D()}},rs=class extends Qn{constructor(e,t){super(e.o.add(t.o),[e,t],{B:e.B&&t.B,W:e.W,P:e.ia,subtree:e.subtree}),this.s=e,this.l=t}h(e,t){const n=Jn(this.s,e,t);if(this.l.B){const r=Jn(this.l,e,t);if(r.G())return r;const a=r.first();if(T(a.type,2)){let e=a.value;if(!Number.isInteger(e))return $.empty();const t=n.value;let r=!1;return $.create({next:()=>{if(!r){for(let n=t.next(0);!n.done;n=t.next(0))if(1==e--)return r=!0,n;r=!0}return A}})}return r.fa()?n:$.empty()}const r=n.value;let a=null,o=0,s=null;return $.create({next:i=>{let l=!1;for(;(!a||!a.done)&&(a||(a=r.next(l?0:i),l=!0),!a.done);){s||=Jn(this.l,je(e,o,a.value,n),t);var c=s.first();c=null!==c&&(T(c.type,2)?c.value===o+1:s.fa()),s=null;const r=a.value;if(a=null,o++,c)return E(r)}return a}})}D(){return this.s.D()}};function as(e,t,n){if(n=[n],T(e.type,62))if("*"===t)n.push(...e.h.map((e=>e())));else{if(!T(t.type,5))throw Error("XPTY0004: The key specifier is not an integer.");{const r=t.value;if(e.h.length<r||0>=r)throw Error("FOAY0001: Array index out of bounds");n.push(e.h[r-1]())}}else{if(!T(e.type,61))throw Error("XPTY0004: The provided context item is not a map or an array.");"*"===t?n.push(...e.h.map((e=>e.value()))):(e=e.h.find((e=>he(e.key,t))))&&n.push(e.value())}return Qe(n)}function os(e,t,n,r,a){return"*"===t?as(e,t,n):(t=L(t=Jn(t,r,a))().N((t=>t.reduce(((t,n)=>as(e,n,t)),new B))),Qe([n,t]))}var ss=class extends Qn{constructor(e,t){super(e.o,[e].concat("*"===t?[]:[t]),{B:e.B,P:e.ia,subtree:e.subtree}),this.l=e,this.s=t}h(e,t){return Jn(this.l,e,t).N((n=>n.reduce(((n,r)=>os(r,this.s,n,e,t)),new B)))}D(){return this.l.D()}},is=class extends Qn{constructor(e,t){super(new dr({external:1}),"*"===e?[]:[e],{B:!1},!1,t),this.l=e}h(e,t){return os(e.M,this.l,new B,e,t)}},ls=class extends Qn{constructor(e,t,n,r){const a=t.map((e=>e.eb));t=t.map((e=>e.name)),super(a.reduce(((e,t)=>e.add(t.o)),n.o),a.concat(n),{B:!1},!1,r),this.s=e,this.A=t,this.L=a,this.S=n,this.l=null}h(e,t){let n=e;const r=this.l.map(((r,a)=>{const o=Jn(this.L[a],n,t).O();return n=Ye(e,{[r]:()=>$.create(o)}),o}));if(r.some((e=>0===e.length)))return"every"===this.s?$.aa():$.V();const a=Array(r.length).fill(0);a[0]=-1;for(var o=!0;o;){o=!1;for(let n=0,i=a.length;n<i;++n){var s=r[n];if(!(++a[n]>s.length-1)){for(o=Object.create(null),s=0;s<a.length;s++){const e=r[s][a[s]];o[this.l[s]]=()=>$.m(e)}if(o=Ye(e,o),(o=Jn(this.S,o,t)).fa()&&"some"===this.s)return $.aa();if(!o.fa()&&"every"===this.s)return $.V();o=!0;break}a[n]=0}}return"every"===this.s?$.aa():$.V()}v(e){this.l=[];for(let n=0,r=this.A.length;n<r;++n){this.L[n].v(e),ca(e);var t=this.A[n];const r=t.prefix?e.$(t.prefix):null;t=da(e,r,t.localName),this.l[n]=t}this.S.v(e);for(let t=0,n=this.A.length;t<n;++t)ma(e)}},cs=class extends Qn{constructor(e){super(e,[],{B:!1})}h(e){return this.l(e.M)?$.aa():$.V()}},us=class extends cs{constructor(e){super(new dr({nodeType:1})),this.s=e}l(e){return!!T(e.type,53)&&(e=e.value.node.nodeType,3===this.s&&4===e||this.s===e)}D(){return`type-${this.s}`}},hs=class extends cs{constructor(e,t={kind:null}){const n=e.prefix,r=e.namespaceURI,a={};"*"!==(e=e.localName)&&(a.nodeName=1),a.nodeType=1,super(new dr(a)),this.s=e,this.L=r,this.A=n,this.S=t.kind}l(e){const t=T(e.type,54),n=T(e.type,47);return!(!t&&!n)&&(e=e.value,!(null!==this.S&&(1===this.S&&!t||2===this.S&&!n))&&(null===this.A&&""!==this.L&&"*"===this.s||("*"===this.A?"*"===this.s||this.s===e.node.localName:("*"===this.s||this.s===e.node.localName)&&(e.node.namespaceURI||null)===((""===this.A?t?this.L:null:this.L)||null))))}D(){return"*"===this.s?null===this.S?"type-1-or-type-2":`type-${this.S}`:`name-${this.s}`}v(e){if(null===this.L&&"*"!==this.A&&(this.L=e.$(this.A||"")||null,!this.L&&this.A))throw Error(`XPST0081: The prefix ${this.A} could not be resolved.`)}},ds=class extends cs{constructor(e){super(new dr({nodeName:1})),this.s=e}l(e){return T(e.type,57)&&e.value.node.target===this.s}D(){return"type-7"}},ps=class extends cs{constructor(e){super(new dr({})),this.s=e}l(e){return T(e.type,F(this.s.prefix?this.s.prefix+":"+this.s.localName:this.s.localName))}},ms=class extends Qn{constructor(e,t,n){super(new dr({}),[],{B:!1,P:"unsorted"}),this.A=n,this.s=t,this.L=e,this.l=null}h(e,t){if(!e.qa[this.l]){if(this.S)return this.S(e,t);throw Error("XQDY0054: The variable "+this.A+" is declared but not in scope.")}return e.qa[this.l]()}v(e){if(null===this.s&&this.L&&(this.s=e.$(this.L)),this.l=e.cb(this.s||"",this.A),!this.l)throw Error("XPST0008, The variable "+this.A+" is not in scope.");(e=e.Ea[this.l])&&(this.S=e)}},fs=class extends xo{constructor(e,t){super(new dr({}),[e,t],{B:!1,W:!1,P:"unsorted",subtree:!1},t),this.A=e}L(e,t,n,r){let a=null,o=null;return r({next:()=>{for(;;){if(!o){var e=t.next(0);if(e.done)return A;a=e.value,o=Jn(this.A,a,n)}e=o.fa();const r=a;if(o=a=null,e)return E(r)}}})}},gs=class{constructor(e){this.type=e}},ys=class extends gs{constructor(e){super("delete"),this.target=e}h(e){return{type:this.type,target:Ur(this.target,e,!1)}}},ws=class extends gs{constructor(e,t,n){super(n),this.target=e,this.content=t}h(e){return{type:this.type,target:Ur(this.target,e,!1),content:this.content.map((t=>Ur(t,e,!0)))}}},vs=class extends ws{constructor(e,t){super(e,t,"insertAfter")}},xs=class extends gs{constructor(e,t){super("insertAttributes"),this.target=e,this.content=t}h(e){return{type:this.type,target:Ur(this.target,e,!1),content:this.content.map((t=>Ur(t,e,!0)))}}},bs=class extends ws{constructor(e,t){super(e,t,"insertBefore")}},As=class extends ws{constructor(e,t){super(e,t,"insertIntoAsFirst")}},Es=class extends ws{constructor(e,t){super(e,t,"insertIntoAsLast")}},Ns=class extends ws{constructor(e,t){super(e,t,"insertInto")}},Ts=class extends gs{constructor(e,t){super("rename"),this.target=e,this.o=t.za?t:new P(t.prefix,t.namespaceURI,t.localName)}h(e){return{type:this.type,target:Ur(this.target,e,!1),newName:{prefix:this.o.prefix,namespaceURI:this.o.namespaceURI,localName:this.o.localName}}}},Bs=class extends gs{constructor(e,t){super("replaceElementContent"),this.target=e,this.text=t}h(e){return{type:this.type,target:Ur(this.target,e,!1),text:this.text?Ur(this.text,e,!0):null}}},Is=class extends gs{constructor(e,t){super("replaceNode"),this.target=e,this.o=t}h(e){return{type:this.type,target:Ur(this.target,e,!1),replacement:this.o.map((t=>Ur(t,e,!0)))}}},Cs=class extends gs{constructor(e,t){super("replaceValue"),this.target=e,this.o=t}h(e){return{type:this.type,target:Ur(this.target,e,!1),"string-value":this.o}}},Os=(e,t)=>new Is(e,t),Ss=class extends sr{constructor(e){super(new dr({}),[e],{B:!1,P:"unsorted"}),this.l=e}s(e,t){const n=or(this.l)(e,t),r=t.h;let a,o;return{next:()=>{if(!a){const e=n.next(0);if(e.value.I.some((e=>!T(e.type,53))))throw Error("XUTY0007: The target of a delete expression must be a sequence of zero or more nodes.");a=e.value.I,o=e.value.da}return a=a.filter((e=>ne(r,e.value))),E({da:ar(a.map((e=>new ys(e.value))),o),I:[]})}}}};function Fs(e,t,n,r,a,o){const s=t.h;return e.reduce((function e(t,n){return T(n.type,62)?(n.h.forEach((n=>n().O().forEach((n=>e(t,n))))),t):(t.push(n),t)}),[]).forEach(((e,i,l)=>{if(T(e.type,47)){if(a)throw o(e.value,s);n.push(e.value.node)}else if(T(e.type,46)||T(e.type,53)&&3===e.value.node.nodeType){const n=T(e.type,46)?At(nt(e,t).first(),1).value:Z(s,e.value);0!==i&&T(l[i-1].type,46)&&T(e.type,46)?(r.push({data:" "+n,Ra:!0,nodeType:3}),a=!0):n&&(r.push({data:""+n,Ra:!0,nodeType:3}),a=!0)}else if(T(e.type,55)){const i=[];W(s,e.value).forEach((e=>i.push(ce(e)))),a=Fs(i,t,n,r,a,o)}else{if(!T(e.type,53)){if(T(e.type,60))throw et(e.type);throw Error(`Atomizing ${e.type} is not implemented.`)}r.push(e.value.node),a=!0}})),a}function Ds(e,t,n){const r=[],a=[];let o=!1;return e.forEach((e=>{o=Fs(e,t,r,a,o,n)})),{attributes:r,Wa:a}}function ks(e,t,n,r,a){const o=[];switch(e){case 4:r.length&&o.push(new xs(t,r)),a.length&&o.push(new As(t,a));break;case 5:r.length&&o.push(new xs(t,r)),a.length&&o.push(new Es(t,a));break;case 3:r.length&&o.push(new xs(t,r)),a.length&&o.push(new Ns(t,a));break;case 2:r.length&&o.push(new xs(n,r)),a.length&&o.push(new bs(t,a));break;case 1:r.length&&o.push(new xs(n,r)),a.length&&o.push(new vs(t,a))}return o}var Rs=class extends sr{constructor(e,t,n){super(new dr({}),[e,n],{B:!1,P:"unsorted"}),this.L=e,this.l=t,this.A=n}s(e,t){const n=or(this.L)(e,t),r=or(this.A)(e,t),a=t.h;let o,s,i,l,c,u;return{next:()=>{if(!o){var e=n.next(0);const r=Ds([e.value.I],t,Ln);o=r.attributes.map((e=>({node:e,F:null}))),s=r.Wa.map((e=>({node:e,F:null}))),i=e.value.da}if(!l){if(0===(e=r.next(0)).value.I.length)throw zn();if(3<=this.l){if(1!==e.value.I.length)throw Pn();if(!T(e.value.I[0].type,54)&&!T(e.value.I[0].type,55))throw Pn()}else{if(1!==e.value.I.length)throw Hn();if(!(T(e.value.I[0].type,54)||T(e.value.I[0].type,56)||T(e.value.I[0].type,58)||T(e.value.I[0].type,57)))throw Hn();if(u=ne(a,e.value.I[0].value,null),null===u)throw Error(`XUDY0029: The target ${e.value.I[0].value.outerHTML} for inserting a node before or after must have a parent.`)}l=e.value.I[0],c=e.value.da}if(o.length){if(3<=this.l){if(!T(l.type,54))throw Error("XUTY0022: An insert expression specifies the insertion of an attribute node into a document node.")}else if(1!==u.node.nodeType)throw Error("XUDY0030: An insert expression specifies the insertion of an attribute node before or after a child of a document node.");o.reduce(((e,t)=>{const n=t.node.prefix||"";var r=t.node.prefix||"";const a=t.node.namespaceURI,o=r?l.value.node.lookupNamespaceURI(r):null;if(o&&o!==a)throw Vn(a);if((r=e[r])&&a!==r)throw Yn(a);return e[n]=t.node.namespaceURI,e}),{})}return E({I:[],da:ar(ks(this.l,l.value,u||null,o,s),i,c)})}}}};const Ms=()=>Ze("Casting not supported from given type to a single xs:string or xs:untypedAtomic or any of its derived types."),Us=/([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]|[\uD800-\uDB7F][\uDC00-\uDFFF])/,Gs=new RegExp(`${Us.source}${new RegExp(`(${Us.source}|[-.0-9·̀-ͯ‿⁀])`).source}*`,"g"),$s=e=>!!(e=e.match(Gs))&&1===e.length;function Ls(e,t){return rt(t,e).Y({m:e=>{if(T((e=e.first()).type,1)||T(e.type,19)){if(!$s(e.value))throw Error(`XQDY0041: The value "${e.value}" of a name expressions cannot be converted to a NCName.`);return $.m(e)}throw Ms()},default:()=>{throw Ms()}}).value}function Ps(e,t,n){return rt(n,t).Y({m:t=>{if(T((t=t.first()).type,23))return $.m(t);if(T(t.type,1)||T(t.type,19)){let n,r;if(1===(t=t.value.split(":")).length?t=t[0]:(n=t[0],r=e.$(n),t=t[1]),!$s(t)||n&&!$s(n))throw aa(n?`${n}:${t}`:t);if(n&&!r)throw aa(`${n}:${t}`);return $.m({type:23,value:new P(n,r,t)})}throw Ms()},default:()=>{throw Ms()}}).value}var Hs=class extends sr{constructor(e,t){super(new dr({}),[e,t],{B:!1,P:"unsorted"}),this.A=e,this.L=t,this.l=void 0}s(e,t){const n=or(this.A)(e,t),r=or(this.L)(e,t);return{next:()=>{const e=n.next(0);var a=e.value.I;if(0===a.length)throw zn();if(1!==a.length)throw _n();if(!T(a[0].type,54)&&!T(a[0].type,47)&&!T(a[0].type,57))throw _n();a=a[0];const o=r.next(0);e:{var s=this.l,i=$.create(o.value.I);switch(a.type){case 54:if(s=Ps(s,t,i).next(0).value.value,(i=a.value.node.lookupNamespaceURI(s.prefix))&&i!==s.namespaceURI)throw Vn(s.namespaceURI);break e;case 47:if((s=Ps(s,t,i).next(0).value.value).namespaceURI&&(i=a.value.node.lookupNamespaceURI(s.prefix))&&i!==s.namespaceURI)throw Vn(s.namespaceURI);break e;case 57:s=Ls(t,i).next(0).value.value,s=new P("",null,s);break e}s=void 0}return E({I:[],da:ar([new Ts(a.value,s)],e.value.da,o.value.da)})}}}v(e){this.l=la(e),super.v(e)}};var js=class extends sr{constructor(e,t,n){super(new dr({}),[t,n],{B:!1,P:"unsorted"}),this.L=e,this.l=t,this.A=n}s(e,t){const n=or(this.l)(e,t);return e=or(this.A)(e,t),this.L?function(e,t,n){let r,a,o,s,i=!1;return{next:()=>{if(i)return A;if(!o){var l=n.next(0);const t=rt($.create(l.value.I),e).map((e=>At(e,1))).O().map((e=>e.value)).join(" ");o=0===t.length?null:{node:e.Ia.createTextNode(t),F:null},s=l.value.da}if(!r){if(0===(l=t.next(0)).value.I.length)throw zn();if(1!==l.value.I.length)throw jn();if(!(T(l.value.I[0].type,54)||T(l.value.I[0].type,47)||T(l.value.I[0].type,56)||T(l.value.I[0].type,58)||T(l.value.I[0].type,57)))throw jn();r=l.value.I[0],a=l.value.da}if(T(r.type,54))return i=!0,E({I:[],da:ar([new Bs(r.value,o)],s,a)});if(T(r.type,47)||T(r.type,56)||T(r.type,58)||T(r.type,57)){if(l=o?Z(e.h,o):"",T(r.type,58)&&(l.includes("--")||l.endsWith("-")))throw Error(`XQDY0072: The content "${l}" for a comment node contains two adjacent hyphens or ends with a hyphen.`);if(T(r.type,57)&&l.includes("?>"))throw Error(`XQDY0026: The content "${l}" for a processing instruction node contains "?>".`);return i=!0,E({I:[],da:ar([new Cs(r.value,l)],s,a)})}}}}(t,n,e):function(e,t,n){let r,a,o;return{next:()=>{if(!r){var s=n.next(0),i=Ds([s.value.I],e,Yn);r={attributes:i.attributes.map((e=>({node:e,F:null}))),Wa:i.Wa.map((e=>({node:e,F:null})))},a=s.value.da}if(0===(i=t.next(0)).value.I.length)throw zn();if(1!==i.value.I.length)throw jn();if(!(T(i.value.I[0].type,54)||T(i.value.I[0].type,47)||T(i.value.I[0].type,56)||T(i.value.I[0].type,58)||T(i.value.I[0].type,57)))throw jn();if(o=ne(e.h,i.value.I[0].value,null),null===o)throw Error(`XUDY0009: The target ${i.value.I[0].value.outerHTML} for replacing a node must have a parent.`);if(s=i.value.I[0],i=i.value.da,T(s.type,47)){if(r.Wa.length)throw Error("XUTY0011: When replacing an attribute the new value must be zero or more attribute nodes.");r.attributes.reduce(((e,t)=>{const n=t.node.prefix||"";t=t.node.namespaceURI;var r=o.node.lookupNamespaceURI(n);if(r&&r!==t)throw Vn(t);if((r=e[n])&&t!==r)throw Yn(t);return e[n]=t,e}),{})}else if(r.attributes.length)throw Error("XUTY0010: When replacing an an element, text, comment, or processing instruction node the new value must be a single node.");return E({I:[],da:ar([Os(s.value,[].concat(r.attributes,r.Wa))],a,i)})}}}(t,n,e)}};function _s(e){switch(e.type){case"delete":return new ys({node:e.target,F:null});case"insertAfter":return new vs({node:e.target,F:null},e.content.map((e=>({node:e,F:null}))));case"insertBefore":return new bs({node:e.target,F:null},e.content.map((e=>({node:e,F:null}))));case"insertInto":return new Ns({node:e.target,F:null},e.content.map((e=>({node:e,F:null}))));case"insertIntoAsFirst":return new As({node:e.target,F:null},e.content.map((e=>({node:e,F:null}))));case"insertIntoAsLast":return new Es({node:e.target,F:null},e.content.map((e=>({node:e,F:null}))));case"insertAttributes":return new xs({node:e.target,F:null},e.content.map((e=>({node:e,F:null}))));case"rename":return new Ts({node:e.target,F:null},e.newName);case"replaceNode":return new Is({node:e.target,F:null},e.replacement.map((e=>({node:e,F:null}))));case"replaceValue":return new Cs({node:e.target,F:null},e["string-value"]);case"replaceElementContent":return new Bs({node:e.target,F:null},e.text?{node:e.text,F:null}:null);default:throw Error(`Unexpected type "${e.type}" when parsing a transferable pending update.`)}}function Xs(e,t,n){if(t.find((t=>Tt(t,e))))return!0;const r=ne(n,e);return!!r&&Xs(r,t,n)}var qs=class extends sr{constructor(e,t,n){super(new dr({}),e.reduce(((e,t)=>(e.push(t.eb),e)),[t,n]),{B:!1,P:"unsorted"}),this.l=e,this.L=t,this.A=n,this.J=null}h(e,t){return ir(e=this.s(e,t),(()=>{}))}s(e,t){const n=t.h,r=t.Ia,a=t.Ma,o=[];let s,i,l;const c=[],u=[];return{next:()=>{if(c.length!==this.l.length)for(var h=c.length;h<this.l.length;h++){const n=this.l[h];var d=o[h];if(d||(o[h]=d=or(n.eb)(e,t)),1!==(d=d.next(0)).value.I.length||!T(d.value.I[0].type,53))throw Error("XUTY0013: The source expression of a copy modify expression must return a single node.");const r=ce(Rr(d.value.I[0].value,t));c.push(r.value),u.push(d.value.da),e=Ye(e,{[n.dc]:()=>$.m(r)})}return l||(s||=or(this.L)(e,t),l=s.next(0).value.da),l.forEach((e=>{if(e.target&&!Xs(e.target,c,n))throw Error(`XUDY0014: The target ${e.target.node.outerHTML} must be a node created by the copy clause.`);if("put"===e.type)throw Error("XUDY0037: The modify expression of a copy modify expression can not contain a fn:put.")})),h=l.map((e=>_s(e=e.h(t)))),nr(h,n,r,a),i||=or(this.A)(e,t),E({I:(h=i.next(0)).value.I,da:ar(h.value.da,...u)})}}}v(e){ca(e),this.l.forEach((t=>t.dc=da(e,t.Gb.namespaceURI,t.Gb.localName))),super.v(e),ma(e),this.J=this.l.some((e=>e.eb.J))||this.A.J}};function Vs(e,t){return{node:{nodeType:2,Ra:!0,nodeName:e.za(),namespaceURI:e.namespaceURI,prefix:e.prefix,localName:e.localName,name:e.za(),value:t},F:null}}var Ys=class extends Qn{constructor(e,t){let n=t.mb||[];n=n.concat(e.Na||[]),super(new dr({}),n,{B:!1,P:"unsorted"}),e.Na?this.s=e.Na:this.name=new P(e.prefix,e.namespaceURI,e.localName),this.l=t,this.A=void 0}h(e,t){let n,r,a,o=!1;return $.create({next:()=>{if(o)return A;if(!r){if(this.s){if(!n){var s=this.s.h(e,t);n=Ps(this.A,t,s)}r=n.next(0).value.value}else r=this.name;if(r){if("xmlns"===r.prefix)throw Wr(r);if(""===r.prefix&&"xmlns"===r.localName)throw Wr(r);if("http://www.w3.org/2000/xmlns/"===r.namespaceURI)throw Wr(r);if("xml"===r.prefix&&"http://www.w3.org/XML/1998/namespace"!==r.namespaceURI)throw Wr(r);if(""!==r.prefix&&"xml"!==r.prefix&&"http://www.w3.org/XML/1998/namespace"===r.namespaceURI)throw Wr(r)}}return this.l.mb?(s=this.l.mb,a||(a=Qe(s.map((n=>rt(n.h(e,t),t).N((e=>$.m(y(e.map((e=>e.value)).join(" "),1))))))).N((e=>$.m(ce(Vs(r,e.map((e=>e.value)).join("")))))).value),a.next(0)):(o=!0,E(ce(Vs(r,this.l.value))))}})}v(e){if(this.A=la(e),this.name&&this.name.prefix&&!this.name.namespaceURI){const t=e.$(this.name.prefix);if(void 0===t&&this.name.prefix)throw tt(this.name.prefix);this.name.namespaceURI=t||null}super.v(e)}},zs=class extends Qn{constructor(e){super(e?e.o:new dr({}),e?[e]:[],{B:!1,P:"unsorted"}),this.l=e}h(e,t){const n={data:"",Ra:!0,nodeType:8},r={node:n,F:null};return this.l?rt(e=Jn(this.l,e,t),t).N((e=>{if(e=e.map((e=>At(e,1).value)).join(" "),-1!==e.indexOf("--\x3e"))throw Error('XQDY0072: The contents of the data of a comment may not include "--\x3e"');return n.data=e,$.m(ce(r))})):$.m(ce(r))}},Js=class extends Qn{constructor(e,t,n,r){super(new dr({}),r.concat(t).concat(e.Na||[]),{B:!1,P:"unsorted"}),e.Na?this.s=e.Na:this.l=new P(e.prefix,e.namespaceURI,e.localName),this.S=n.reduce(((e,t)=>{if(t.prefix in e)throw Error(`XQST0071: The namespace declaration with the prefix ${t.prefix} has already been declared on the constructed element.`);return e[t.prefix||""]=t.uri,e}),{}),this.L=t,this.ma=r,this.A=void 0}h(e,t){let n,r,a,o,s,i=!1,l=!1,c=!1;return $.create({next:()=>{if(c)return A;if(i||(n||=Qe(this.L.map((n=>Jn(n,e,t)))),r=n.O(),i=!0),!l){a||=this.ma.map((n=>Jn(n,e,t)));for(var u=[],h=0;h<a.length;h++){var d=a[h].O();u.push(d)}o=u,l=!0}if(this.s&&(s||(u=this.s.h(e,t),s=Ps(this.A,t,u)),this.l=s.next(0).value.value),"xmlns"===this.l.prefix||"http://www.w3.org/2000/xmlns/"===this.l.namespaceURI||"xml"===this.l.prefix&&"http://www.w3.org/XML/1998/namespace"!==this.l.namespaceURI||this.l.prefix&&"xml"!==this.l.prefix&&"http://www.w3.org/XML/1998/namespace"===this.l.namespaceURI)throw Error(`XQDY0096: The node name "${this.l.za()}" is invalid for a computed element constructor.`);const p={nodeType:1,Ra:!0,attributes:[],childNodes:[],nodeName:this.l.za(),namespaceURI:this.l.namespaceURI,prefix:this.l.prefix,localName:this.l.localName};for(u={node:p,F:null},r.forEach((e=>{p.attributes.push(e.value.node)})),(h=Ds(o,t,Kr)).attributes.forEach((e=>{if(p.attributes.find((t=>t.namespaceURI===e.namespaceURI&&t.localName===e.localName)))throw Error(`XQDY0025: The attribute ${e.name} does not have an unique name in the constructed element.`);p.attributes.push(e)})),h.Wa.forEach((e=>{p.childNodes.push(e)})),h=0;h<p.childNodes.length;h++){if(!z(d=p.childNodes[h])||3!==d.nodeType)continue;const e=p.childNodes[h-1];e&&z(e)&&3===e.nodeType&&(e.data+=d.data,p.childNodes.splice(h,1),h--)}return c=!0,E(ce(u))}})}v(e){if(ca(e),Object.keys(this.S).forEach((t=>ha(e,t,this.S[t]))),this.Ka.forEach((t=>t.v(e))),this.L.reduce(((t,n)=>{if(n.name){if(n=`Q{${null===n.name.namespaceURI?e.$(n.name.prefix):n.name.namespaceURI}}${n.name.localName}`,t.includes(n))throw Error(`XQST0040: The attribute ${n} does not have an unique name in the constructed element.`);t.push(n)}return t}),[]),this.l&&null===this.l.namespaceURI){const t=e.$(this.l.prefix);if(void 0===t&&this.l.prefix)throw tt(this.l.prefix);this.l.namespaceURI=t}this.A=la(e),ma(e)}};function Qs(e){if(/^xml$/i.test(e))throw Error(`XQDY0064: The target of a created PI may not be "${e}"`)}function Ks(e,t){return{node:{data:t,Ra:!0,nodeName:e,nodeType:7,target:e},F:null}}var Ws=class extends Qn{constructor(e,t){const n=e.vb?[e.vb].concat(t):[t];super(n.reduce(((e,t)=>e.add(t.o)),new dr({})),n,{B:!1,P:"unsorted"}),this.l=e,this.s=t}h(e,t){return rt(Jn(this.s,e,t),t).N((n=>{const r=n.map((e=>At(e,1).value)).join(" ");if(-1!==r.indexOf("?>"))throw Error('XQDY0026: The contents of the data of a processing instruction may not include "?>"');if(null!==this.l.Db)return Qs(n=this.l.Db),$.m(ce(Ks(n,r)));n=Jn(this.l.vb,e,t);const a=Ls(t,n);return $.create({next:()=>{var e=a.next(0);return e.done?e:(Qs(e=e.value.value),E(ce(Ks(e,r))))}})}))}},Zs=class extends Qn{constructor(e){super(e?e.o:new dr({}),e?[e]:[],{B:!1,P:"unsorted"}),this.l=e}h(e,t){return this.l?rt(e=Jn(this.l,e,t),t).N((e=>0===e.length?$.empty():(e={node:{data:e.map((e=>At(e,1).value)).join(" "),Ra:!0,nodeType:3},F:null},$.m(ce(e))))):$.empty()}},ei=class extends lr{constructor(e,t,n,r){super(new dr({}),[e,...t.map((e=>e.Xb)),n].concat(...t.map((e=>e.Fb.map((e=>e.Eb))))),{B:!1,W:!1,P:"unsorted",subtree:!1},r),this.L=e,this.l=t.length,this.S=t.map((e=>e.Fb))}A(e,t,n){return n[0](e).N((r=>{for(let a=0;a<this.l;a++)if(this.S[a].some((n=>{switch(n.bc){case"?":if(1<r.length)return!1;break;case"*":break;case"+":if(1>r.length)return!1;break;default:if(1!==r.length)return!1}const a=$.create(r);return r.every(((r,o)=>(r=je(e,o,r,a),Jn(n.Eb,r,t).fa())))})))return n[a+1](e);return n[this.l+1](e)}))}v(e){if(super.v(e),this.L.J)throw $n()}},ti={Z:!1,ra:!1},ni={Z:!0,ra:!1},ri={Z:!0,ra:!0};function ai(e){return e.Z?e.ra?ri:ni:ti}function oi(e,t){switch(e[0]){case"andOp":var n=wa(e,"type");return new Oo(ii("andOp",e,ai(t)),n);case"orOp":return n=wa(e,"type"),new So(ii("orOp",e,ai(t)),n);case"unaryPlusOp":return n=ga(ga(e,"operand"),"*"),e=wa(e,"type"),new Co("+",oi(n,t),e);case"unaryMinusOp":return n=ga(ga(e,"operand"),"*"),e=wa(e,"type"),new Co("-",oi(n,t),e);case"addOp":case"subtractOp":case"multiplyOp":case"divOp":case"idivOp":case"modOp":var r=e[0],a=oi(va(e,["firstOperand","*"]),ai(t));t=oi(va(e,["secondOperand","*"]),ai(t));const o=wa(e,"type"),s=wa(va(e,["firstOperand","*"]),"type"),i=wa(va(e,["secondOperand","*"]),"type");return s&&i&&wa(e,"type")&&(n=Oa(r,s.type,i.type)),new Da(r,a,t,o,n);case"sequenceExpr":return function(e,t){var n=xa(e,"*").map((e=>oi(e,t)));return 1===n.length?n[0]:(n=wa(e,"type"),new jo(xa(e,"*").map((e=>oi(e,t))),n))}(e,t);case"unionOp":return n=wa(e,"type"),new Ko([oi(va(e,["firstOperand","*"]),ai(t)),oi(va(e,["secondOperand","*"]),ai(t))],n);case"exceptOp":case"intersectOp":return n=wa(e,"type"),new Ho(e[0],oi(va(e,["firstOperand","*"]),ai(t)),oi(va(e,["secondOperand","*"]),ai(t)),n);case"stringConcatenateOp":return function(e,t){const n=wa(e,"type");return e=[va(e,["firstOperand","*"]),va(e,["secondOperand","*"])],new yr(new Bo({localName:"concat",namespaceURI:"http://www.w3.org/2005/xpath-functions",prefix:""},e.length,n),e.map((e=>oi(e,ai(t)))),n)}(e,t);case"rangeSequenceExpr":return function(e,t){const n=wa(e,"type");e=[ga(ga(e,"startExpr"),"*"),ga(ga(e,"endExpr"),"*")];const r=new Bo({localName:"to",namespaceURI:"http://fontoxpath/operators",prefix:""},e.length,n);return new yr(r,e.map((e=>oi(e,ai(t)))),n)}(e,t);case"equalOp":case"notEqualOp":case"lessThanOrEqualOp":case"lessThanOp":case"greaterThanOrEqualOp":case"greaterThanOp":return ci("generalCompare",e,t);case"eqOp":case"neOp":case"ltOp":case"leOp":case"gtOp":case"geOp":return ci("valueCompare",e,t);case"isOp":case"nodeBeforeOp":case"nodeAfterOp":return ci("nodeCompare",e,t);case"pathExpr":return function(e,t){const n=wa(e,"type");var r=xa(e,"stepExpr");let a=!1;var o=r.map((e=>{var r=ga(e,"xpathAxis");let o;var s=xa(e,"*");const i=[];let l=null;for(const e of s)switch(e[0]){case"lookup":i.push(["lookup",li(e,t)]);break;case"predicate":case"predicates":for(const n of xa(e,"*"))s=oi(n,ai(t)),l=Za(l,s.D()),i.push(["predicate",s])}if(r)switch(a=!0,e=ga(e,"attributeTest anyElementTest piTest documentTest elementTest commentTest namespaceTest anyKindTest textTest anyFunctionTest typedFunctionTest schemaAttributeTest atomicType anyItemType parenthesizedItemType typedMapTest typedArrayTest nameTest Wildcard".split(" ")),e=si(e),ya(r)){case"ancestor":o=new Ka(e,{Qa:!1});break;case"ancestor-or-self":o=new Ka(e,{Qa:!0});break;case"attribute":o=new eo(e,l);break;case"child":o=new to(e,l);break;case"descendant":o=new ro(e,{Qa:!1});break;case"descendant-or-self":o=new ro(e,{Qa:!0});break;case"parent":o=new lo(e,l);break;case"following-sibling":o=new io(e,l);break;case"preceding-sibling":o=new uo(e,l);break;case"following":o=new so(e);break;case"preceding":o=new co(e);break;case"self":o=new ho(e,l)}else o=oi(r=va(e,["filterExpr","*"]),ai(t));for(const e of i)switch(e[0]){case"lookup":o=new ss(o,e[1]);break;case"predicate":o=new rs(o,e[1])}return o.type=n,o}));return e=ga(e,"rootExpr"),!(r=a||null!==e||1<r.length)&&1===o.length||!e&&1===o.length&&"sorted"===o[0].ia?o[0]:e&&0===o.length?new es(null):(o=new ns(o,r),e?new es(o):o)}(e,t);case"contextItemExpr":return new ts(wa(e,"type"));case"functionCallExpr":return function(e,t){const n=ga(e,"functionName"),r=xa(ga(e,"arguments"),"*");return e=wa(e,"type"),new yr(new Bo(ba(n),r.length,e),r.map((e=>"argumentPlaceholder"===e[0]?null:oi(e,t))),e)}(e,t);case"inlineFunctionExpr":return function(e,t){const n=xa(ga(e,"paramList"),"*"),r=va(e,["functionBody","*"]),a=wa(e,"type");return new Ao(n.map((e=>({name:ba(ga(e,"varName")),type:Aa(e)}))),Aa(e),r?oi(r,t):new jo([],a))}(e,t);case"arrowExpr":return function(e,t){const n=wa(e,"type");var r=va(e,["argExpr","*"]);e=xa(e,"*").slice(1),r=[oi(r,t)];for(let o=0;o<e.length;o++)if("arguments"!==e[o][0]){if("arguments"===e[o+1][0]){var a=xa(e[o+1],"*");r=r.concat(a.map((e=>"argumentPlaceholder"===e[0]?null:oi(e,t))))}a="EQName"===e[o][0]?new Bo(ba(e[o]),r.length,n):oi(e[o],ai(t)),r=[new yr(a,r,n)]}return r[0]}(e,t);case"dynamicFunctionInvocationExpr":return function(e,t){const n=va(e,["functionItem","*"]),r=wa(e,"type");e=ga(e,"arguments");let a=[];return e&&(a=xa(e,"*").map((e=>"argumentPlaceholder"===e[0]?null:oi(e,t)))),new yr(oi(n,t),a,r)}(e,t);case"namedFunctionRef":return t=ga(e,"functionName"),n=wa(e,"type"),e=ya(va(e,["integerConstantExpr","value"])),new Bo(ba(t),parseInt(e,10),n);case"integerConstantExpr":return new No(ya(ga(e,"value")),{type:5,g:3});case"stringConstantExpr":return new No(ya(ga(e,"value")),{type:1,g:3});case"decimalConstantExpr":return new No(ya(ga(e,"value")),{type:4,g:3});case"doubleConstantExpr":return new No(ya(ga(e,"value")),{type:3,g:3});case"varRef":const{prefix:l,namespaceURI:c,localName:u}=ba(ga(e,"name"));return new ms(l,c,u);case"flworExpr":return function(e,t){var n=xa(e,"*");if(e=ga(n[n.length-1],"*"),1<(n=n.slice(0,-1)).length&&!t.Z)throw Error("XPST0003: Use of XQuery FLWOR expressions in XPath is no allowed");return n.reduceRight(((e,n)=>{switch(n[0]){case"forClause":for(var r=(n=xa(n,"*")).length-1;0<=r;--r){var a=n[r],o=va(a,["forExpr","*"]);const s=ga(a,"positionalVariableBinding");e=new bo(ba(va(a,["typedVariableBinding","varName"])),oi(o,ai(t)),s?ba(s):null,e)}return e;case"letClause":for(r=(n=xa(n,"*")).length-1;0<=r;--r)o=va(a=n[r],["letExpr","*"]),e=new Eo(ba(va(a,["typedVariableBinding","varName"])),oi(o,ai(t)),e);return e;case"whereClause":for(r=(n=xa(n,"*")).length-1;0<=r;--r)e=new fs(oi(n[r],t),e);return e;case"windowClause":case"groupByClause":case"countClause":throw Error(`Not implemented: ${n[0]} is not implemented yet.`);case"orderByClause":return function(e,t,n){return e=xa(e,"*"),new Zo(e.filter((e=>"stable"!==e[0])).map((e=>{var n=ga(e,"orderModifier"),r=n?ga(n,"orderingKind"):null;return n=n?ga(n,"emptyOrderingMode"):null,r=!r||"ascending"===ya(r),n=!n||"empty least"===ya(n),{ba:oi(va(e,["orderByExpr","*"]),t),zb:r,$b:n}})),n)}(n,t,e);default:throw Error(`Not implemented: ${n[0]} is not supported in a flwor expression`)}}),oi(e,t))}(e,t);case"quantifiedExpr":return function(e,t){const n=wa(e,"type"),r=ya(ga(e,"quantifier")),a=va(e,["predicateExpr","*"]);return e=xa(e,"quantifiedExprInClause").map((e=>({name:ba(va(e,["typedVariableBinding","varName"])),eb:oi(e=va(e,["sourceExpr","*"]),ai(t))}))),new ls(r,e,oi(a,ai(t)),n)}(e,t);case"ifThenElseExpr":return n=wa(e,"type"),new po(oi(ga(ga(e,"ifClause"),"*"),ai(t)),oi(ga(ga(e,"thenClause"),"*"),t),oi(ga(ga(e,"elseClause"),"*"),t),n);case"instanceOfExpr":return n=oi(va(e,["argExpr","*"]),t),r=va(e,["sequenceType","*"]),a=va(e,["sequenceType","occurrenceIndicator"]),e=wa(e,"type"),new Yo(n,oi(r,ai(t)),a?ya(a):"",e);case"castExpr":return t=oi(ga(ga(e,"argExpr"),"*"),ai(t)),n=ga(e,"singleType"),e=ba(ga(n,"atomicType")),n=null!==ga(n,"optional"),new qo(t,e,n);case"castableExpr":return t=oi(ga(ga(e,"argExpr"),"*"),ai(t)),n=ga(e,"singleType"),e=ba(ga(n,"atomicType")),n=null!==ga(n,"optional"),new Xo(t,e,n);case"simpleMapExpr":return function(e,t){const n=wa(e,"type");return xa(e,"*").reduce(((e,r)=>null===e?oi(r,ai(t)):new _o(e,oi(r,ai(t)),n)),null)}(e,t);case"mapConstructor":return function(e,t){const n=wa(e,"type");return new To(xa(e,"mapConstructorEntry").map((e=>({key:oi(va(e,["mapKeyExpr","*"]),ai(t)),value:oi(va(e,["mapValueExpr","*"]),ai(t))}))),n)}(e,t);case"arrayConstructor":return function(e,t){const n=wa(e,"type"),r=xa(e=ga(e,"*"),"arrayElem").map((e=>oi(ga(e,"*"),ai(t))));switch(e[0]){case"curlyArray":return new za(r,n);case"squareArray":return new Ja(r,n);default:throw Error("Unrecognized arrayType: "+e[0])}}(e,t);case"unaryLookup":return n=wa(e,"type"),new is(li(e,t),n);case"typeswitchExpr":return function(e,t){if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const n=wa(e,"type"),r=oi(ga(ga(e,"argExpr"),"*"),t),a=xa(e,"typeswitchExprCaseClause").map((e=>{const n=0===xa(e,"sequenceTypeUnion").length?[ga(e,"sequenceType")]:xa(ga(e,"sequenceTypeUnion"),"sequenceType");return{Xb:oi(va(e,["resultExpr","*"]),t),Fb:n.map((e=>{const n=ga(e,"occurrenceIndicator");return{bc:n?ya(n):"",Eb:oi(ga(e,"*"),t)}}))}}));return e=oi(va(e,["typeswitchExprDefaultClause","resultExpr","*"]),t),new ei(r,a,e,n)}(e,t);case"elementConstructor":return function(e,t){if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const n=ba(ga(e,"tagName"));var r=ga(e,"attributeList");const a=r?xa(r,"attributeConstructor").map((e=>oi(e,ai(t)))):[];return r=r?xa(r,"namespaceDeclaration").map((e=>{const t=ga(e,"prefix");return{prefix:t?ya(t):"",uri:ya(ga(e,"uri"))}})):[],e=(e=ga(e,"elementContent"))?xa(e,"*").map((e=>oi(e,ai(t)))):[],new Js(n,a,r,e)}(e,t);case"attributeConstructor":return function(e,t){if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const n=ba(ga(e,"attributeName"));var r=ga(e,"attributeValue");return r=r?ya(r):null,e=(e=ga(e,"attributeValueExpr"))?xa(e,"*").map((e=>oi(e,ai(t)))):null,new Ys(n,{value:r,mb:e})}(e,t);case"computedAttributeConstructor":return(n=ga(e,"tagName"))?n=ba(n):(n=ga(e,"tagNameExpr"),n={Na:oi(ga(n,"*"),ai(t))}),e=oi(ga(ga(e,"valueExpr"),"*"),ai(t)),new Ys(n,{mb:[e]});case"computedCommentConstructor":if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");return e=(e=ga(e,"argExpr"))?oi(ga(e,"*"),ai(t)):null,new zs(e);case"computedTextConstructor":if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");return e=(e=ga(e,"argExpr"))?oi(ga(e,"*"),ai(t)):null,new Zs(e);case"computedElementConstructor":return function(e,t){var n=ga(e,"tagName");return n?n=ba(n):(n=ga(e,"tagNameExpr"),n={Na:oi(ga(n,"*"),ai(t))}),e=(e=ga(e,"contentExpr"))?xa(e,"*").map((e=>oi(e,ai(t)))):[],new Js(n,[],[],e)}(e,t);case"computedPIConstructor":if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");return n=ga(e,"piTargetExpr"),r=ga(e,"piTarget"),a=ga(e,"piValueExpr"),e=wa(e,"type"),new Ws({vb:n?oi(ga(n,"*"),ai(t)):null,Db:r?ya(r):null},a?oi(ga(a,"*"),ai(t)):new jo([],e));case"CDataSection":return new No(ya(e),{type:1,g:3});case"deleteExpr":return e=oi(va(e,["targetExpr","*"]),t),new Ss(e);case"insertExpr":switch(n=oi(va(e,["sourceExpr","*"]),t),(a=xa(e,"*")[1])[0]){case"insertAfter":r=1;break;case"insertBefore":r=2;break;case"insertInto":r=(r=ga(a,"*"))?"insertAsFirst"===r[0]?4:5:3}return e=oi(va(e,["targetExpr","*"]),t),new Rs(n,r,e);case"renameExpr":return n=oi(va(e,["targetExpr","*"]),t),e=oi(va(e,["newNameExpr","*"]),t),new Hs(n,e);case"replaceExpr":return n=!!ga(e,"replaceValue"),r=oi(va(e,["targetExpr","*"]),t),e=oi(va(e,["replacementExpr","*"]),t),new js(n,r,e);case"transformExpr":return function(e,t){const n=xa(ga(e,"transformCopies"),"transformCopy").map((e=>{const n=ba(ga(ga(e,"varRef"),"name"));return{eb:oi(ga(ga(e,"copySource"),"*"),t),Gb:new P(n.prefix,n.namespaceURI,n.localName)}})),r=oi(ga(ga(e,"modifyExpr"),"*"),t);return e=oi(ga(ga(e,"returnExpr"),"*"),t),new qs(n,r,e)}(e,t);case"x:stackTrace":for(n=e[1],e=e[2];"x:stackTrace"===e[0];)e=e[2];return new yo(n,e[0],oi(e,t));default:return si(e)}}function si(e){switch(e[0]){case"nameTest":return new hs(ba(e));case"piTest":return(e=ga(e,"piTarget"))?new ds(ya(e)):new us(7);case"commentTest":return new us(8);case"textTest":return new us(3);case"documentTest":return new us(9);case"attributeTest":var t=(e=ga(e,"attributeName"))&&ga(e,"star");return!e||t?new us(2):new hs(ba(ga(e,"QName")),{kind:2});case"elementTest":return t=(e=ga(e,"elementName"))&&ga(e,"star"),!e||t?new us(1):new hs(ba(ga(e,"QName")),{kind:1});case"anyKindTest":return new ps({prefix:"",namespaceURI:null,localName:"node()"});case"anyMapTest":return new ps({prefix:"",namespaceURI:null,localName:"map(*)"});case"anyArrayTest":return new ps({prefix:"",namespaceURI:null,localName:"array(*)"});case"Wildcard":return ga(e,"star")?(t=ga(e,"uri"))?e=new hs({localName:"*",namespaceURI:ya(t),prefix:""}):(t=ga(e,"NCName"),e="star"===ga(e,"*")[0]?new hs({localName:ya(t),namespaceURI:null,prefix:"*"}):new hs({localName:"*",namespaceURI:null,prefix:ya(t)})):e=new hs({localName:"*",namespaceURI:null,prefix:"*"}),e;case"atomicType":return new ps(ba(e));case"anyItemType":return new ps({prefix:"",namespaceURI:null,localName:"item()"});default:throw Error("No selector counterpart for: "+e[0]+".")}}function ii(e,t,n){const r=[];return function t(a){const o=ga(ga(a,"firstOperand"),"*");a=ga(ga(a,"secondOperand"),"*"),o[0]===e?t(o):r.push(oi(o,n)),a[0]===e?t(a):r.push(oi(a,n))}(t),r}function li(e,t){switch((e=ga(e,"*"))[0]){case"NCName":return new No(ya(e),{type:1,g:3});case"star":return"*";default:return oi(e,ai(t))}}function ci(e,t,n){var r=va(t,["firstOperand","*"]);const a=va(t,["secondOperand","*"]);switch(r=oi(r,ai(n)),n=oi(a,ai(n)),e){case"valueCompare":return new Mo(t[0],r,n);case"nodeCompare":return new Lo(t[0],r,n);case"generalCompare":return new Go(t[0],r,n)}}function ui(e,t){return oi(e,t)}const hi=new Map;class di{constructor(e,t,n,r,a,o){this.v=e,this.D=t,this.h=n,this.jb=r,this.o=a,this.l=o}}function pi(e,t,n,r,a,o,s){let i=hi.get(e);i||(i=Object.create(null),hi.set(e,i)),(t=i[e=t+(o?"_DEBUG":"")])||(t=i[e]=[]),t.push(new di(Object.values(n.h),Object.values(n.o),a,Object.keys(r).map((e=>({namespaceURI:r[e],prefix:e}))),s,n.D))}function mi(e){var t=new q;if("http://www.w3.org/2005/XQueryX"!==e.namespaceURI&&"http://www.w3.org/2005/XQueryX"!==e.namespaceURI&&"http://fontoxml.com/fontoxpath"!==e.namespaceURI&&"http://www.w3.org/2007/xquery-update-10"!==e.namespaceURI)throw Ze("The XML structure passed as an XQueryX program was not valid XQueryX");const n=["stackTrace"===e.localName?"x:stackTrace":e.localName],r=t.getAllAttributes(e);r&&0<r.length&&n.push(Array.from(r).reduce(((t,n)=>("start"===n.localName||"end"===n.localName&&"stackTrace"===e.localName?t[n.localName]=JSON.parse(n.value):"type"===n.localName?t[n.localName]=D(n.value):t[n.localName]=n.value,t)),{})),t=t.getChildNodes(e);for(const e of t)switch(e.nodeType){case 1:n.push(mi(e));break;case 3:n.push(e.data)}return n}const fi=Object.create(null);var gi=(e,t)=>{let n=fi[e];n||=fi[e]={Ha:[],Ta:[],oa:null,source:t.source};const r=n.oa||(()=>{});n.Ha=n.Ha.concat(t.Ha),n.Ta=n.Ta.concat(t.Ta),n.oa=e=>{r(e),t.oa&&t.oa(e)}},yi=(e,t)=>{const n=fi[t];if(!n)throw Error(`XQST0051: No modules found with the namespace uri ${t}`);n.Ha.forEach((n=>{n.bb&&ua(e,t,n.localName,n.arity,n)})),n.Ta.forEach((n=>{da(e,t,n.localName),pa(e,t,n.localName,((e,t)=>Jn(n.ba,e,t)))}))},wi=()=>{Object.keys(fi).forEach((e=>{if((e=fi[e]).oa)try{e.oa(e)}catch(t){e.oa=null,_r(e.source,t)}e.oa=null}))};function vi(e){return e.replace(/(\x0D\x0A)|(\x0D(?!\x0A))/g,String.fromCharCode(10))}var xi=t;function bi(e,t){return(n,r)=>t.has(r)?t.get(r):(n=e(n,r),t.set(r,n),n)}function Ai(e,t){return(0,xi.delimited)(t,e,t)}function Ei(e,t){return e.reverse().reduce(((e,t)=>(0,xi.preceded)(t,e)),t)}function Ni(e,t,n,r){return(0,xi.then)((0,xi.then)(e,t,((e,t)=>[e,t])),n,(([e,t],n)=>r(e,t,n)))}function Ti(e,t,n,r,a){return(0,xi.then)((0,xi.then)((0,xi.then)(e,t,((e,t)=>[e,t])),n,(([e,t],n)=>[e,t,n])),r,(([e,t,n],r)=>a(e,t,n,r)))}function Bi(e){return(0,xi.map)(e,(e=>[e]))}function Ii(e,t){return(0,xi.map)((0,xi.or)(e),(()=>t))}function Ci(e){return(t,n)=>(t=e.exec(t.substring(n)))&&0===t.index?(0,xi.okWithValue)(n+t[0].length,t[0]):(0,xi.error)(n,[e.source],!1)}var Oi=(0,xi.or)([(0,xi.token)(" "),(0,xi.token)("\t"),(0,xi.token)("\r"),(0,xi.token)("\n")]),Si=(0,xi.token)("(:"),Fi=(0,xi.token)(":)"),Di=(0,xi.token)("(#"),ki=(0,xi.token)("#)"),Ri=(0,xi.token)("("),Mi=(0,xi.token)(")"),Ui=(0,xi.token)("["),Gi=(0,xi.token)("]"),$i=(0,xi.token)("{"),Li=(0,xi.token)("}"),Pi=(0,xi.token)("{{"),Hi=(0,xi.token)("}}"),ji=(0,xi.token)("'"),_i=(0,xi.token)("''"),Xi=(0,xi.token)('"'),qi=(0,xi.token)('""'),Vi=(0,xi.token)("<![CDATA["),Yi=(0,xi.token)("]]>"),zi=(0,xi.token)("/>"),Ji=(0,xi.token)("</"),Qi=(0,xi.token)("\x3c!--"),Ki=(0,xi.token)("--\x3e"),Wi=(0,xi.token)("<?"),Zi=(0,xi.token)("?>"),el=(0,xi.token)("&#x"),tl=(0,xi.token)("&#"),nl=(0,xi.token)(":*"),rl=(0,xi.token)("*:"),al=(0,xi.token)(":="),ol=(0,xi.token)("&"),sl=(0,xi.token)(":"),il=(0,xi.token)(";"),ll=(0,xi.token)("*"),cl=(0,xi.token)("@"),ul=(0,xi.token)("$"),hl=(0,xi.token)("#"),dl=(0,xi.token)("%"),pl=(0,xi.token)("?"),ml=(0,xi.token)("="),fl=(0,xi.followed)((0,xi.token)("!"),(0,xi.not)((0,xi.peek)(ml),[])),gl=(0,xi.followed)((0,xi.token)("|"),(0,xi.not)((0,xi.peek)((0,xi.token)("|")),[])),yl=(0,xi.token)("||"),wl=(0,xi.token)("!="),vl=(0,xi.token)("<"),xl=(0,xi.token)("<<"),bl=(0,xi.token)("<="),Al=(0,xi.token)(">"),El=(0,xi.token)(">>"),Nl=(0,xi.token)(">="),Tl=(0,xi.token)(","),Bl=(0,xi.token)("."),Il=(0,xi.token)(".."),Cl=(0,xi.token)("+"),Ol=(0,xi.token)("-"),Sl=(0,xi.token)("/"),Fl=(0,xi.token)("//"),Dl=(0,xi.token)("=>"),kl=(0,xi.token)("e"),Rl=(0,xi.token)("E");(0,xi.token)("l"),(0,xi.token)("L"),(0,xi.token)("m"),(0,xi.token)("M");var Ml=(0,xi.token)("Q");(0,xi.token)("x"),(0,xi.token)("X");var Ul=(0,xi.token)("as"),Gl=(0,xi.token)("cast"),$l=(0,xi.token)("castable"),Ll=(0,xi.token)("treat"),Pl=(0,xi.token)("instance"),Hl=(0,xi.token)("of"),jl=(0,xi.token)("node"),_l=(0,xi.token)("nodes"),Xl=(0,xi.token)("delete"),ql=(0,xi.token)("value"),Vl=(0,xi.token)("function"),Yl=(0,xi.token)("map"),zl=(0,xi.token)("element"),Jl=(0,xi.token)("attribute"),Ql=(0,xi.token)("schema-element"),Kl=(0,xi.token)("intersect"),Wl=(0,xi.token)("except"),Zl=(0,xi.token)("union"),ec=(0,xi.token)("to"),tc=(0,xi.token)("is"),nc=(0,xi.token)("or"),rc=(0,xi.token)("and"),ac=(0,xi.token)("div"),oc=(0,xi.token)("idiv"),sc=(0,xi.token)("mod"),ic=(0,xi.token)("eq"),lc=(0,xi.token)("ne"),cc=(0,xi.token)("lt"),uc=(0,xi.token)("le"),hc=(0,xi.token)("gt"),dc=(0,xi.token)("ge"),pc=(0,xi.token)("amp"),mc=(0,xi.token)("quot"),fc=(0,xi.token)("apos"),gc=(0,xi.token)("if"),yc=(0,xi.token)("then"),wc=(0,xi.token)("else"),vc=(0,xi.token)("allowing"),xc=(0,xi.token)("empty"),bc=(0,xi.token)("at"),Ac=(0,xi.token)("in"),Ec=(0,xi.token)("for"),Nc=(0,xi.token)("let"),Tc=(0,xi.token)("where"),Bc=(0,xi.token)("collation"),Ic=(0,xi.token)("group"),Cc=(0,xi.token)("by"),Oc=(0,xi.token)("order"),Sc=(0,xi.token)("stable"),Fc=(0,xi.token)("return"),Dc=(0,xi.token)("array"),kc=(0,xi.token)("document"),Rc=(0,xi.token)("namespace"),Mc=(0,xi.token)("text"),Uc=(0,xi.token)("comment"),Gc=(0,xi.token)("processing-instruction"),$c=(0,xi.token)("lax"),Lc=(0,xi.token)("strict"),Pc=(0,xi.token)("validate"),Hc=(0,xi.token)("type"),jc=(0,xi.token)("declare"),_c=(0,xi.token)("default"),Xc=(0,xi.token)("boundary-space"),qc=(0,xi.token)("strip"),Vc=(0,xi.token)("preserve"),Yc=(0,xi.token)("no-preserve"),zc=(0,xi.token)("inherit"),Jc=(0,xi.token)("no-inherit"),Qc=(0,xi.token)("greatest"),Kc=(0,xi.token)("least"),Wc=(0,xi.token)("copy-namespaces"),Zc=(0,xi.token)("decimal-format"),eu=(0,xi.token)("case"),tu=(0,xi.token)("typeswitch"),nu=(0,xi.token)("some"),ru=(0,xi.token)("every"),au=(0,xi.token)("satisfies"),ou=(0,xi.token)("replace"),su=(0,xi.token)("with"),iu=(0,xi.token)("copy"),lu=(0,xi.token)("modify"),cu=(0,xi.token)("first"),uu=(0,xi.token)("last"),hu=(0,xi.token)("before"),du=(0,xi.token)("after"),pu=(0,xi.token)("into"),mu=(0,xi.token)("insert"),fu=(0,xi.token)("rename"),gu=(0,xi.token)("switch"),yu=(0,xi.token)("variable"),wu=(0,xi.token)("external"),vu=(0,xi.token)("updating"),xu=(0,xi.token)("import"),bu=(0,xi.token)("schema"),Au=(0,xi.token)("module"),Eu=(0,xi.token)("base-uri"),Nu=(0,xi.token)("construction"),Tu=(0,xi.token)("ordering"),Bu=(0,xi.token)("ordered"),Iu=(0,xi.token)("unordered"),Cu=(0,xi.token)("option"),Ou=(0,xi.token)("context"),Su=(0,xi.token)("item"),Fu=(0,xi.token)("xquery"),Du=(0,xi.token)("version"),ku=(0,xi.token)("encoding"),Ru=(0,xi.token)("document-node"),Mu=(0,xi.token)("namespace-node"),Uu=(0,xi.token)("schema-attribute"),Gu=(0,xi.token)("ascending"),$u=(0,xi.token)("descending"),Lu=(0,xi.token)("empty-sequence"),Pu=(0,xi.token)("child::"),Hu=(0,xi.token)("descendant::"),ju=(0,xi.token)("attribute::"),_u=(0,xi.token)("self::"),Xu=(0,xi.token)("descendant-or-self::"),qu=(0,xi.token)("following-sibling::"),Vu=(0,xi.token)("following::"),Yu=(0,xi.token)("parent::"),zu=(0,xi.token)("ancestor::"),Ju=(0,xi.token)("preceding-sibling::"),Qu=(0,xi.token)("preceding::"),Ku=(0,xi.token)("ancestor-or-self::"),Wu=(0,xi.token)("decimal-separator"),Zu=(0,xi.token)("grouping-separator"),eh=(0,xi.token)("infinity"),th=(0,xi.token)("minus-sign"),nh=(0,xi.token)("NaN"),rh=(0,xi.token)("per-mille"),ah=(0,xi.token)("zero-digit"),oh=(0,xi.token)("digit"),sh=(0,xi.token)("pattern-separator"),ih=(0,xi.token)("exponent-separator"),lh=(0,xi.token)("schema-attribute("),ch=(0,xi.token)("document-node("),uh=(0,xi.token)("processing-instruction("),hh=(0,xi.token)("processing-instruction()"),dh=(0,xi.token)("comment()"),ph=(0,xi.token)("text()"),mh=(0,xi.token)("namespace-node()"),fh=(0,xi.token)("node()"),gh=(0,xi.token)("item()"),yh=(0,xi.token)("empty-sequence()"),wh=new Map,vh=new Map,xh=(0,xi.or)([Ci(/[\t\n\r -\uD7FF\uE000\uFFFD]/),Ci(/[\uD800-\uDBFF][\uDC00-\uDFFF]/)]),bh=(0,xi.preceded)((0,xi.peek)((0,xi.not)((0,xi.or)([Si,Fi]),['comment contents cannot contain "(:" or ":)"'])),xh),Ah=(0,xi.map)((0,xi.delimited)(Si,(0,xi.star)((0,xi.or)([bh,function(e,t){return Ah(e,t)}])),Fi,!0),(e=>e.join(""))),Eh=(0,xi.or)([Oi,Ah]),Nh=(0,xi.map)((0,xi.plus)(Oi),(e=>e.join(""))),Th=bi((0,xi.map)((0,xi.star)(Eh),(e=>e.join(""))),wh),Bh=bi((0,xi.map)((0,xi.plus)(Eh),(e=>e.join(""))),vh);const Ih=(0,xi.or)([Ci(/[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]/),(0,xi.then)(Ci(/[\uD800-\uDB7F]/),Ci(/[\uDC00-\uDFFF]/),((e,t)=>e+t))]),Ch=(0,xi.or)([Ih,Ci(/[\-\.0-9\xB7\u0300-\u036F\u203F\u2040]/)]);var Oh=(0,xi.then)(Ih,(0,xi.star)(Ch),((e,t)=>e+t.join(""))),Sh=(0,xi.map)(Oh,(e=>["prefix",e]));const Fh=(0,xi.or)([Ih,sl]),Dh=(0,xi.or)([Ch,sl]);(0,xi.then)(Fh,(0,xi.star)(Dh),((e,t)=>e+t.join("")));const kh=(0,xi.map)(Oh,(e=>[{prefix:"",URI:null},e])),Rh=(0,xi.then)(Oh,(0,xi.preceded)(sl,Oh),((e,t)=>[{prefix:e,URI:null},t]));var Mh=(0,xi.or)([Rh,kh]),Uh=(0,xi.followed)(Ei([Ml,Th,$i],(0,xi.map)((0,xi.star)(Ci(/[^{}]/)),(e=>e.join("").replace(/\s+/g," ").trim()))),Li);const Gh=(0,xi.then)(Uh,Oh,((e,t)=>[e,t]));var $h=(0,xi.or)([(0,xi.map)(Gh,(e=>[{prefix:null,URI:e[0]},e[1]])),Mh]),Lh=(0,xi.or)([(0,xi.map)($h,(e=>["QName",...e])),(0,xi.map)(ll,(()=>["star"]))]),Ph=(0,xi.map)((0,xi.preceded)(ul,$h),(e=>["varRef",["name",...e]])),Hh=(0,xi.peek)((0,xi.or)([Ri,Xi,ji,Eh])),jh=(0,xi.map)((0,xi.or)([Pu,Hu,ju,_u,Xu,qu,Vu]),(e=>e.substring(0,e.length-2))),_h=(0,xi.map)((0,xi.or)([Yu,zu,Ju,Qu,Ku]),(e=>e.substring(0,e.length-2))),Xh=Ni(ol,(0,xi.or)([cc,hc,pc,mc,fc]),il,((e,t,n)=>e+t+n)),qh=(0,xi.or)([Ni(el,Ci(/[0-9a-fA-F]+/),il,((e,t,n)=>e+t+n)),Ni(tl,Ci(/[0-9]+/),il,((e,t,n)=>e+t+n))]),Vh=Ii([qi],'"'),Yh=Ii([_i],"'"),zh=Bi(Ii([dh],"commentTest")),Jh=Bi(Ii([ph],"textTest")),Qh=Bi(Ii([mh],"namespaceTest")),Kh=Bi(Ii([fh],"anyKindTest"));const Wh=Ci(/[0-9]+/),Zh=(0,xi.then)((0,xi.or)([(0,xi.then)(Bl,Wh,((e,t)=>e+t)),(0,xi.then)(Wh,(0,xi.optional)((0,xi.preceded)(Bl,Ci(/[0-9]*/))),((e,t)=>e+(null!==t?"."+t:"")))]),Ni((0,xi.or)([kl,Rl]),(0,xi.optional)((0,xi.or)([Cl,Ol])),Wh,((e,t,n)=>e+(t||"")+n)),((e,t)=>["doubleConstantExpr",["value",e+t]])),ed=(0,xi.or)([(0,xi.map)((0,xi.preceded)(Bl,Wh),(e=>["decimalConstantExpr",["value","."+e]])),(0,xi.then)((0,xi.followed)(Wh,Bl),(0,xi.optional)(Wh),((e,t)=>["decimalConstantExpr",["value",e+"."+(null!==t?t:"")]]))]);var td=(0,xi.map)(Wh,(e=>["integerConstantExpr",["value",e]])),nd=(0,xi.followed)((0,xi.or)([Zh,ed,td]),(0,xi.peek)((0,xi.not)(Ci(/[a-zA-Z]/),["no alphabetical characters after numeric literal"]))),rd=(0,xi.map)((0,xi.followed)(Bl,(0,xi.peek)((0,xi.not)(Bl,["context item should not be followed by another ."]))),(()=>["contextItemExpr"])),ad=(0,xi.or)([Dc,Jl,Uc,Ru,zl,Lu,Vl,gc,Su,Yl,Mu,jl,Gc,Uu,Ql,gu,Mc,tu]),od=Bi(Ii([pl],"argumentPlaceholder")),sd=(0,xi.or)([pl,ll,Cl]),id=(0,xi.preceded)((0,xi.peek)((0,xi.not)(Ci(/[{}<&]/),["elementContentChar cannot be {, }, <, or &"])),xh),ld=(0,xi.map)((0,xi.delimited)(Vi,(0,xi.star)((0,xi.preceded)((0,xi.peek)((0,xi.not)(Yi,['CDataSection content may not contain "]]>"'])),xh)),Yi,!0),(e=>["CDataSection",e.join("")])),cd=(0,xi.preceded)((0,xi.peek)((0,xi.not)(Ci(/["{}<&]/),['quotAttrValueContentChar cannot be ", {, }, <, or &'])),xh),ud=(0,xi.preceded)((0,xi.peek)((0,xi.not)(Ci(/['{}<&]/),["aposAttrValueContentChar cannot be ', {, }, <, or &"])),xh),hd=(0,xi.map)((0,xi.star)((0,xi.or)([(0,xi.preceded)((0,xi.peek)((0,xi.not)(Ol,[])),xh),(0,xi.map)(Ei([Ol,(0,xi.peek)((0,xi.not)(Ol,[]))],xh),(e=>"-"+e))])),(e=>e.join(""))),dd=(0,xi.map)((0,xi.delimited)(Qi,hd,Ki,!0),(e=>["computedCommentConstructor",["argExpr",["stringConstantExpr",["value",e]]]]));const pd=(0,xi.filter)(Oh,(e=>"xml"!==e.toLowerCase()),['A processing instruction target cannot be "xml"']),md=(0,xi.map)((0,xi.star)((0,xi.preceded)((0,xi.peek)((0,xi.not)(Zi,[])),xh)),(e=>e.join("")));var fd=(0,xi.then)((0,xi.preceded)(Wi,(0,xi.cut)(pd)),(0,xi.cut)((0,xi.followed)((0,xi.optional)((0,xi.preceded)(Nh,md)),Zi)),((e,t)=>["computedPIConstructor",["piTarget",e],["piValueExpr",["stringConstantExpr",["value",t]]]])),gd=(0,xi.map)(Fl,(()=>["stepExpr",["xpathAxis","descendant-or-self"],["anyKindTest"]])),yd=(0,xi.or)([$c,Lc]),wd=(0,xi.map)((0,xi.star)((0,xi.followed)(xh,(0,xi.peek)((0,xi.not)(ki,["Pragma contents should not contain '#)'"])))),(e=>e.join(""))),vd=(0,xi.map)((0,xi.followed)((0,xi.or)([ic,lc,cc,uc,hc,dc]),Hh),(e=>e+"Op")),xd=(0,xi.or)([(0,xi.followed)(Ii([tc],"isOp"),Hh),Ii([xl],"nodeBeforeOp"),Ii([El],"nodeAfterOp")]),bd=(0,xi.or)([Ii([ml],"equalOp"),Ii([wl],"notEqualOp"),Ii([bl],"lessThanOrEqualOp"),Ii([vl],"lessThanOp"),Ii([Nl],"greaterThanOrEqualOp"),Ii([Al],"greaterThanOp")]),Ad=(0,xi.map)(vu,(()=>["annotation",["annotationName","updating"]]));const Ed=(0,xi.or)([Vc,Yc]),Nd=(0,xi.or)([zc,Jc]);var Td=(0,xi.or)([Wu,Zu,eh,th,nh,dl,rh,ah,oh,sh,ih]),Bd=(0,xi.map)(Ei([jc,Bh,Xc,Bh],(0,xi.or)([Vc,qc])),(e=>["boundarySpaceDecl",e])),Id=(0,xi.map)(Ei([jc,Bh,Nu,Bh],(0,xi.or)([Vc,qc])),(e=>["constructionDecl",e])),Cd=(0,xi.map)(Ei([jc,Bh,Tu,Bh],(0,xi.or)([Bu,Iu])),(e=>["orderingModeDecl",e])),Od=(0,xi.map)(Ei([jc,Bh,_c,Bh,Oc,Bh,xc,Bh],(0,xi.or)([Qc,Kc])),(e=>["emptyOrderDecl",e])),Sd=(0,xi.then)(Ei([jc,Bh,Wc,Bh],Ed),Ei([Th,Tl,Th],Nd),((e,t)=>["copyNamespacesDecl",["preserveMode",e],["inheritMode",t]]));function Fd(e){switch(e[0]){case"constantExpr":case"varRef":case"contextItemExpr":case"functionCallExpr":case"sequenceExpr":case"elementConstructor":case"computedElementConstructor":case"computedAttributeConstructor":case"computedDocumentConstructor":case"computedTextConstructor":case"computedCommentConstructor":case"computedNamespaceConstructor":case"computedPIConstructor":case"orderedExpr":case"unorderedExpr":case"namedFunctionRef":case"inlineFunctionExpr":case"dynamicFunctionInvocationExpr":case"mapConstructor":case"arrayConstructor":case"stringConstructor":case"unaryLookup":return e}return["sequenceExpr",e]}function Dd(e){if(!(1<=e&&55295>=e||57344<=e&&65533>=e||65536<=e&&1114111>=e))throw Error("XQST0090: The character reference "+e+" ("+e.toString(16)+") does not reference a valid codePoint.")}function kd(e){return e.replace(/(&[^;]+);/g,(e=>{if(/^&#x/.test(e))return Dd(e=parseInt(e.slice(3,-1),16)),String.fromCodePoint(e);if(/^&#/.test(e))return Dd(e=parseInt(e.slice(2,-1),10)),String.fromCodePoint(e);switch(e){case"&lt;":return"<";case"&gt;":return">";case"&amp;":return"&";case"&quot;":return String.fromCharCode(34);case"&apos;":return String.fromCharCode(39)}throw Error('XPST0003: Unknown character reference: "'+e+'"')}))}function Rd(e,t,n){if(!e.length)return[];let r=[e[0]];for(let t=1;t<e.length;++t){const n=r[r.length-1];"string"==typeof n&&"string"==typeof e[t]?r[r.length-1]=n+e[t]:r.push(e[t])}if("string"==typeof r[0]&&0===r.length)return[];if(r=r.reduce(((e,t,a)=>{if("string"!=typeof t)e.push(t);else if(n&&/^\s*$/.test(t)){const n=r[a+1];(n&&"CDataSection"===n[0]||(a=r[a-1])&&"CDataSection"===a[0])&&e.push(kd(t))}else e.push(kd(t));return e}),[]),!r.length)return r;if(1<r.length||t)for(e=0;e<r.length;e++)"string"==typeof r[e]&&(r[e]=["stringConstantExpr",["value",r[e]]]);return r}function Md(e){return e[0].prefix?e[0].prefix+":"+e[1]:e[1]}var Ud=(0,xi.then)($h,(0,xi.optional)(pl),((e,t)=>null!==t?["singleType",["atomicType",...e],["optional"]]:["singleType",["atomicType",...e]])),Gd=(0,xi.map)($h,(e=>["atomicType",...e]));const $d=new Map;function Ld(e){function t(e,t){return t.reduce(((e,t)=>[t[0],["firstOperand",e],["secondOperand",t[1]]]),e)}function n(e,t,n){return(0,xi.then)(e,(0,xi.star)((0,xi.then)(Ai(t,Th),(0,xi.cut)(e),((e,t)=>[e,t]))),n)}function r(e,t,n="firstOperand",r="secondOperand"){return(0,xi.then)(e,(0,xi.optional)((0,xi.then)(Ai(t,Th),(0,xi.cut)(e),((e,t)=>[e,t]))),((e,t)=>null===t?e:[t[0],[n,e],[r,t[1]]]))}function a(t){return e.lb?(e,n)=>{if(!(e=t(e,n)).success)return e;const r=c.has(n)?c.get(n):{offset:n,line:-1,ha:-1},a=c.has(e.offset)?c.get(e.offset):{offset:e.offset,line:-1,ha:-1};return c.set(n,r),c.set(e.offset,a),(0,xi.okWithValue)(e.offset,["x:stackTrace",{start:r,end:a},e.value])}:t}function o(e,t){return J(e,t)}function s(e,t){return Ge(e,t)}function i(e,t){return a((0,xi.or)([Tt,Ft,Pt,Ct,ot,Gt,Dt,$t,kt,Mt,at]))(e,t)}function l(e,t){return n(i,Tl,((e,t)=>0===t.length?e:["sequenceExpr",e,...t.map((e=>e[1]))]))(e,t)}const c=new Map,u=(0,xi.preceded)(Ui,(0,xi.followed)(Ai(l,Th),Gi)),h=(0,xi.map)(e.Ya?(0,xi.or)([Ai((0,xi.star)((0,xi.or)([Xh,qh,Vh,Ci(/[^"&]/)])),Xi),Ai((0,xi.star)((0,xi.or)([Xh,qh,Yh,Ci(/[^'&]/)])),ji)]):(0,xi.or)([Ai((0,xi.star)((0,xi.or)([Vh,Ci(/[^"]/)])),Xi),Ai((0,xi.star)((0,xi.or)([Yh,Ci(/[^']/)])),ji)]),(e=>e.join(""))),d=(0,xi.or)([(0,xi.map)(Ei([zl,Th],(0,xi.delimited)((0,xi.followed)(Ri,Th),(0,xi.then)(Lh,Ei([Th,Tl,Th],$h),((e,t)=>[["elementName",e],["typeName",...t]])),(0,xi.preceded)(Th,Mi))),(([e,t])=>["elementTest",e,t])),(0,xi.map)(Ei([zl,Th],(0,xi.delimited)(Ri,Lh,Mi)),(e=>["elementTest",["elementName",e]])),(0,xi.map)(Ei([zl,Th],(0,xi.delimited)(Ri,Th,Mi)),(()=>["elementTest"]))]),p=(0,xi.or)([(0,xi.map)($h,(e=>["QName",...e])),(0,xi.map)(ll,(()=>["star"]))]),m=(0,xi.or)([(0,xi.map)(Ei([Jl,Th],(0,xi.delimited)((0,xi.followed)(Ri,Th),(0,xi.then)(p,Ei([Th,Tl,Th],$h),((e,t)=>[["attributeName",e],["typeName",...t]])),(0,xi.preceded)(Th,Mi))),(([e,t])=>["attributeTest",e,t])),(0,xi.map)(Ei([Jl,Th],(0,xi.delimited)(Ri,p,Mi)),(e=>["attributeTest",["attributeName",e]])),(0,xi.map)(Ei([Jl,Th],(0,xi.delimited)(Ri,Th,Mi)),(()=>["attributeTest"]))]),f=(0,xi.map)(Ei([Ql,Th,Ri],(0,xi.followed)($h,Mi)),(e=>["schemaElementTest",...e])),g=(0,xi.map)((0,xi.delimited)(lh,Ai($h,Th),Mi),(e=>["schemaAttributeTest",...e])),y=(0,xi.map)((0,xi.preceded)(ch,(0,xi.followed)(Ai((0,xi.optional)((0,xi.or)([d,f])),Th),Mi)),(e=>["documentTest",...e?[e]:[]])),w=(0,xi.or)([(0,xi.map)((0,xi.preceded)(uh,(0,xi.followed)(Ai((0,xi.or)([Oh,h]),Th),Mi)),(e=>["piTest",["piTarget",e]])),Bi(Ii([hh],"piTest"))]),v=(0,xi.or)([y,d,m,f,g,w,zh,Jh,Qh,Kh]),x=(0,xi.or)([(0,xi.map)((0,xi.preceded)(rl,Oh),(e=>["Wildcard",["star"],["NCName",e]])),Bi(Ii([ll],"Wildcard")),(0,xi.map)((0,xi.followed)(Uh,ll),(e=>["Wildcard",["uri",e],["star"]])),(0,xi.map)((0,xi.followed)(Oh,nl),(e=>["Wildcard",["NCName",e],["star"]]))]),b=(0,xi.or)([x,(0,xi.map)($h,(e=>["nameTest",...e]))]),A=(0,xi.or)([v,b]),E=(0,xi.then)((0,xi.optional)(cl),A,((e,t)=>null!==e||"attributeTest"===t[0]||"schemaAttributeTest"===t[0]?["stepExpr",["xpathAxis","attribute"],t]:["stepExpr",["xpathAxis","child"],t])),N=(0,xi.or)([(0,xi.then)(jh,A,((e,t)=>["stepExpr",["xpathAxis",e],t])),E]),T=(0,xi.map)(Il,(()=>["stepExpr",["xpathAxis","parent"],["anyKindTest"]])),B=(0,xi.or)([(0,xi.then)(_h,A,((e,t)=>["stepExpr",["xpathAxis",e],t])),T]),I=(0,xi.map)((0,xi.star)((0,xi.preceded)(Th,u)),(e=>0<e.length?["predicates",...e]:void 0)),C=(0,xi.then)((0,xi.or)([B,N]),I,((e,t)=>void 0===t?e:e.concat([t]))),O=(0,xi.or)([nd,(0,xi.map)(h,(t=>["stringConstantExpr",["value",e.Ya?kd(t):t]]))]),S=(0,xi.or)([(0,xi.delimited)(Ri,Ai(l,Th),Mi),(0,xi.map)((0,xi.delimited)(Ri,Th,Mi),(()=>["sequenceExpr"]))]),F=(0,xi.or)([i,od]),D=(0,xi.map)((0,xi.delimited)(Ri,Ai((0,xi.optional)((0,xi.then)(F,(0,xi.star)((0,xi.preceded)(Ai(Tl,Th),F)),((e,t)=>[e,...t]))),Th),Mi),(e=>null!==e?e:[])),k=(0,xi.preceded)((0,xi.not)(Ni(ad,Th,Ri,(()=>{})),["cannot use reseved keyword for function names"]),(0,xi.then)($h,(0,xi.preceded)(Th,D),((e,t)=>["functionCallExpr",["functionName",...e],null!==t?["arguments",...t]:["arguments"]]))),R=(0,xi.then)($h,(0,xi.preceded)(hl,td),((e,t)=>["namedFunctionRef",["functionName",...e],t])),M=(0,xi.delimited)($i,Ai((0,xi.optional)(l),Th),Li),U=(0,xi.map)(M,(e=>e||["sequenceExpr"])),G=(0,xi.or)([(0,xi.map)(yh,(()=>[["voidSequenceType"]])),(0,xi.then)(o,(0,xi.optional)((0,xi.preceded)(Th,sd)),((e,t)=>[e,...null!==t?[["occurrenceIndicator",t]]:[]]))]),$=(0,xi.then)(Ei([dl,Th],$h),(0,xi.optional)((0,xi.followed)((0,xi.then)(Ei([Ri,Th],O),(0,xi.star)(Ei([Tl,Th],O)),((e,t)=>e.concat(t))),Mi)),((e,t)=>["annotation",["annotationName",...e],...t?["arguments",t]:[]])),L=(0,xi.map)(Ei([Vl,Th,Ri,Th,ll,Th],Mi),(()=>["anyFunctionTest"])),P=(0,xi.then)(Ei([Vl,Th,Ri,Th],(0,xi.optional)(n(G,Tl,((e,t)=>e.concat.apply(e,t.map((e=>e[1]))))))),Ei([Th,Mi,Bh,Ul,Bh],G),((e,t)=>["typedFunctionTest",["paramTypeList",["sequenceType",...e||[]]],["sequenceType",...t]])),H=(0,xi.then)((0,xi.star)($),(0,xi.or)([L,P]),((e,t)=>[t[0],...e,...t.slice(1)])),j=(0,xi.map)(Ei([Yl,Th,Ri,Th,ll,Th],Mi),(()=>["anyMapTest"])),_=(0,xi.then)(Ei([Yl,Th,Ri,Th],Gd),Ei([Th,Tl],(0,xi.followed)(Ai(G,Th),Mi)),((e,t)=>["typedMapTest",e,["sequenceType",...t]])),X=(0,xi.or)([j,_]),q=(0,xi.map)(Ei([Dc,Th,Ri,Th,ll,Th],Mi),(()=>["anyArrayTest"])),V=(0,xi.map)(Ei([Dc,Th,Ri],(0,xi.followed)(Ai(G,Th),Mi)),(e=>["typedArrayTest",["sequenceType",...e]])),Y=(0,xi.or)([q,V]),z=(0,xi.map)((0,xi.delimited)(Ri,Ai(o,Th),Mi),(e=>["parenthesizedItemType",e])),J=(0,xi.or)([v,Bi(Ii([gh],"anyItemType")),H,X,Y,Gd,z]),Q=(0,xi.map)(Ei([Ul,Bh],G),(e=>["typeDeclaration",...e])),K=(0,xi.then)((0,xi.preceded)(ul,$h),(0,xi.optional)((0,xi.preceded)(Bh,Q)),((e,t)=>["param",["varName",...e],...t?[t]:[]])),W=n(K,Tl,((e,t)=>[e,...t.map((e=>e[1]))])),Z=Ti((0,xi.star)($),Ei([Th,Vl,Th,Ri,Th],(0,xi.optional)(W)),Ei([Th,Mi,Th],(0,xi.optional)((0,xi.map)(Ei([Ul,Th],(0,xi.followed)(G,Th)),(e=>["typeDeclaration",...e])))),U,((e,t,n,r)=>["inlineFunctionExpr",...e,["paramList",...t||[]],...n?[n]:[],["functionBody",r]])),ee=(0,xi.or)([R,Z]),te=(0,xi.map)(i,(e=>["mapKeyExpr",e])),ne=(0,xi.map)(i,(e=>["mapValueExpr",e])),re=(0,xi.then)(te,(0,xi.preceded)(Ai(sl,Th),ne),((e,t)=>["mapConstructorEntry",e,t])),ae=(0,xi.preceded)(Yl,(0,xi.delimited)(Ai($i,Th),(0,xi.map)((0,xi.optional)(n(re,Ai(Tl,Th),((e,t)=>[e,...t.map((e=>e[1]))]))),(e=>e?["mapConstructor",...e]:["mapConstructor"])),(0,xi.preceded)(Th,Li))),oe=(0,xi.map)((0,xi.delimited)(Ui,Ai((0,xi.optional)(n(i,Tl,((e,t)=>[e,...t.map((e=>e[1]))].map((e=>["arrayElem",e]))))),Th),Gi),(e=>["squareArray",...null!==e?e:[]])),se=(0,xi.map)((0,xi.preceded)(Dc,(0,xi.preceded)(Th,M)),(e=>["curlyArray",...null!==e?[["arrayElem",e]]:[]])),ie=(0,xi.map)((0,xi.or)([oe,se]),(e=>["arrayConstructor",e])),le=(0,xi.or)([Oh,td,S,ll]),ce=(0,xi.map)((0,xi.preceded)(pl,(0,xi.preceded)(Th,le)),(e=>"*"===e?["unaryLookup",["star"]]:"string"==typeof e?["unaryLookup",["NCName",e]]:["unaryLookup",e])),ue=(0,xi.or)([Xh,qh,Ii([Pi],"{"),Ii([Hi],"}"),(0,xi.map)(M,(e=>e||["sequenceExpr"]))]),he=(0,xi.or)([ld,function(e,t){return we(e,t)},ue,id]),de=(0,xi.or)([(0,xi.map)(cd,(e=>e.replace(/[\x20\x0D\x0A\x09]/g," "))),ue]),pe=(0,xi.or)([(0,xi.map)(ud,(e=>e.replace(/[\x20\x0D\x0A\x09]/g," "))),ue]),me=(0,xi.map)((0,xi.or)([Ai((0,xi.star)((0,xi.or)([Vh,de])),Xi),Ai((0,xi.star)((0,xi.or)([Yh,pe])),ji)]),(e=>Rd(e,!1,!1))),fe=(0,xi.then)(Mh,(0,xi.preceded)(Ai(ml,(0,xi.optional)(Nh)),me),((e,t)=>{if(""===e[0].prefix&&"xmlns"===e[1]){if(t.length&&"string"!=typeof t[0])throw Error("XQST0022: A namespace declaration may not contain enclosed expressions");return["namespaceDeclaration",t.length?["uri",t[0]]:["uri"]]}if("xmlns"===e[0].prefix){if(t.length&&"string"!=typeof t[0])throw Error("XQST0022: The namespace declaration for 'xmlns:"+e[1]+"' may not contain enclosed expressions");return["namespaceDeclaration",["prefix",e[1]],t.length?["uri",t[0]]:["uri"]]}return["attributeConstructor",["attributeName"].concat(e),0===t.length?["attributeValue"]:1===t.length&&"string"==typeof t[0]?["attributeValue",t[0]]:["attributeValueExpr"].concat(t)]})),ge=(0,xi.map)((0,xi.star)((0,xi.preceded)(Nh,(0,xi.optional)(fe))),(e=>e.filter(Boolean))),ye=Ni((0,xi.preceded)(vl,Mh),ge,(0,xi.or)([(0,xi.map)(zi,(()=>null)),(0,xi.then)((0,xi.preceded)(Al,(0,xi.star)(he)),Ei([Th,Ji],(0,xi.followed)(Mh,(0,xi.then)((0,xi.optional)(Nh),Al,(()=>null)))),((e,t)=>[Rd(e,!0,!0),t]))]),((e,t,n)=>{var r=n;if(n&&n.length){r=Md(e);const t=Md(n[1]);if(r!==t)throw Error('XQST0118: The start and the end tag of an element constructor must be equal. "'+r+'" does not match "'+t+'"');r=n[0]}return["elementConstructor",["tagName",...e],...t.length?[["attributeList",...t]]:[],...r&&r.length?[["elementContent",...r]]:[]]})),we=(0,xi.or)([ye,dd,fd]),ve=(0,xi.map)(Ei([kc,Th],M),(e=>["computedDocumentConstructor",...e?[["argExpr",e]]:[]])),xe=(0,xi.map)(M,(e=>e?[["contentExpr",e]]:[])),be=(0,xi.then)(Ei([zl,Th],(0,xi.or)([(0,xi.map)($h,(e=>["tagName",...e])),(0,xi.map)((0,xi.delimited)($i,Ai(l,Th),Li),(e=>["tagNameExpr",e]))])),(0,xi.preceded)(Th,xe),((e,t)=>["computedElementConstructor",e,...t])),Ae=(0,xi.then)((0,xi.preceded)(Jl,(0,xi.or)([(0,xi.map)(Ei([Hh,Th],$h),(e=>["tagName",...e])),(0,xi.map)((0,xi.preceded)(Th,(0,xi.delimited)($i,Ai(l,Th),Li)),(e=>["tagNameExpr",e]))])),(0,xi.preceded)(Th,M),((e,t)=>["computedAttributeConstructor",e,["valueExpr",t||["sequenceExpr"]]])),Ee=(0,xi.map)(M,(e=>e?[["prefixExpr",e]]:[])),Ne=(0,xi.map)(M,(e=>e?[["URIExpr",e]]:[])),Te=(0,xi.then)(Ei([Rc,Th],(0,xi.or)([Sh,Ee])),(0,xi.preceded)(Th,Ne),((e,t)=>["computedNamespaceConstructor",...e,...t])),Be=(0,xi.map)(Ei([Mc,Th],M),(e=>["computedTextConstructor",...e?[["argExpr",e]]:[]])),Ie=(0,xi.map)(Ei([Uc,Th],M),(e=>["computedCommentConstructor",...e?[["argExpr",e]]:[]])),Ce=Ei([Gc,Th],(0,xi.then)((0,xi.or)([(0,xi.map)(Oh,(e=>["piTarget",e])),(0,xi.map)((0,xi.delimited)($i,Ai(l,Th),Li),(e=>["piTargetExpr",e]))]),(0,xi.preceded)(Th,M),((e,t)=>["computedPIConstructor",e,...t?[["piValueExpr",t]]:[]]))),Oe=(0,xi.or)([ve,be,Ae,Te,Be,Ie,Ce]),Se=(0,xi.or)([we,Oe]),Fe=(0,xi.or)([O,Ph,S,rd,k,Se,ee,ae,ie,ce]),De=(0,xi.map)(Ei([pl,Th],le),(e=>"*"===e?["lookup",["star"]]:"string"==typeof e?["lookup",["NCName",e]]:["lookup",e])),ke=(0,xi.then)((0,xi.map)(Fe,(e=>Fd(e))),(0,xi.star)((0,xi.or)([(0,xi.map)((0,xi.preceded)(Th,u),(e=>["predicate",e])),(0,xi.map)((0,xi.preceded)(Th,D),(e=>["argumentList",e])),(0,xi.preceded)(Th,De)])),((e,t)=>{function n(){i&&1===o.length?s.push(["predicate",o[0]]):0!==o.length&&s.push(["predicates",...o]),o.length=0}function r(e){n(),0!==s.length?("sequenceExpr"===a[0][0]&&2<a[0].length&&(a=[["sequenceExpr",...a]]),a=[["filterExpr",...a],...s],s.length=0):e&&(a=[["filterExpr",...a]])}let a=[e];const o=[],s=[];let i=!1;for(const e of t)switch(e[0]){case"predicate":o.push(e[1]);break;case"lookup":i=!0,n(),s.push(e);break;case"argumentList":r(!1),1<a.length&&(a=[["sequenceExpr",["pathExpr",["stepExpr",...a]]]]),a=[["dynamicFunctionInvocationExpr",["functionItem",...a],...e[1].length?[["arguments",...e[1]]]:[]]];break;default:throw Error("unreachable")}return r(!0),a})),Re=(0,xi.or)([(0,xi.map)(ke,(e=>["stepExpr",...e])),C]),Me=(0,xi.followed)(Fe,(0,xi.peek)((0,xi.not)((0,xi.preceded)(Th,(0,xi.or)([u,D,De])),["primary expression not followed by predicate, argumentList, or lookup"]))),Ue=(0,xi.or)([Ni(Re,(0,xi.preceded)(Th,gd),(0,xi.preceded)(Th,s),((e,t,n)=>["pathExpr",e,t,...n])),(0,xi.then)(Re,(0,xi.preceded)(Ai(Sl,Th),s),((e,t)=>["pathExpr",e,...t])),Me,(0,xi.map)(Re,(e=>["pathExpr",e]))]),Ge=(0,xi.or)([Ni(Re,(0,xi.preceded)(Th,gd),(0,xi.preceded)(Th,s),((e,t,n)=>[e,t,...n])),(0,xi.then)(Re,(0,xi.preceded)(Ai(Sl,Th),s),((e,t)=>[e,...t])),(0,xi.map)(Re,(e=>[e]))]),$e=(0,xi.or)([(0,xi.map)(Ei([Sl,Th],Ge),(e=>["pathExpr",["rootExpr"],...e])),(0,xi.then)(gd,(0,xi.preceded)(Th,Ge),((e,t)=>["pathExpr",["rootExpr"],e,...t])),(0,xi.map)((0,xi.followed)(Sl,(0,xi.not)((0,xi.preceded)(Th,e.Ya?Ci(/[*<a-zA-Z]/):Ci(/[*a-zA-Z]/)),["Single rootExpr cannot be by followed by something that can be interpreted as a relative path"])),(()=>["pathExpr",["rootExpr"]]))]),Le=bi((0,xi.or)([Ue,$e]),$d),Pe=(0,xi.preceded)(Pc,(0,xi.then)((0,xi.optional)((0,xi.or)([(0,xi.map)((0,xi.preceded)(Th,yd),(e=>["validationMode",e])),(0,xi.map)(Ei([Th,Hc,Th],$h),(e=>["type",...e]))])),(0,xi.delimited)((0,xi.preceded)(Th,$i),Ai(l,Th),Li),((e,t)=>["validateExpr",...e?[e]:[],["argExpr",t]]))),He=(0,xi.delimited)(Di,(0,xi.then)((0,xi.preceded)(Th,$h),(0,xi.optional)((0,xi.preceded)(Bh,wd)),((e,t)=>t?["pragma",["pragmaName",e],["pragmaContents",t]]:["pragma",["pragmaName",e]])),(0,xi.preceded)(Th,ki)),je=(0,xi.map)((0,xi.followed)((0,xi.plus)(He),(0,xi.preceded)(Th,(0,xi.delimited)($i,Ai((0,xi.optional)(l),Th),Li))),(e=>["extensionExpr",...e])),_e=a(n(Le,fl,((e,t)=>0===t.length?e:["simpleMapExpr","pathExpr"===e[0]?e:["pathExpr",["stepExpr",["filterExpr",Fd(e)]]]].concat(t.map((e=>"pathExpr"===(e=e[1])[0]?e:["pathExpr",["stepExpr",["filterExpr",Fd(e)]]])))))),Xe=(0,xi.or)([Pe,je,_e]),qe=(0,xi.or)([(0,xi.then)((0,xi.or)([Ii([Ol],"unaryMinusOp"),Ii([Cl],"unaryPlusOp")]),(0,xi.preceded)(Th,(function(e,t){return qe(e,t)})),((e,t)=>[e,["operand",t]])),Xe]),Ve=(0,xi.or)([(0,xi.map)($h,(e=>["EQName",...e])),Ph,S]),Ye=(0,xi.then)(qe,(0,xi.star)(Ei([Th,Dl,Th],(0,xi.then)(Ve,(0,xi.preceded)(Th,D),((e,t)=>[e,t])))),((e,t)=>t.reduce(((e,t)=>["arrowExpr",["argExpr",e],t[0],["arguments",...t[1]]]),e))),ze=(0,xi.then)(Ye,(0,xi.optional)(Ei([Th,Gl,Bh,Ul,Hh,Th],Ud)),((e,t)=>null!==t?["castExpr",["argExpr",e],t]:e)),Je=(0,xi.then)(ze,(0,xi.optional)(Ei([Th,$l,Bh,Ul,Hh,Th],Ud)),((e,t)=>null!==t?["castableExpr",["argExpr",e],t]:e)),Qe=(0,xi.then)(Je,(0,xi.optional)(Ei([Th,Ll,Bh,Ul,Hh,Th],G)),((e,t)=>null!==t?["treatExpr",["argExpr",e],["sequenceType",...t]]:e)),Ke=(0,xi.then)(Qe,(0,xi.optional)(Ei([Th,Pl,Bh,Hl,Hh,Th],G)),((e,t)=>null!==t?["instanceOfExpr",["argExpr",e],["sequenceType",...t]]:e)),We=n(Ke,(0,xi.followed)((0,xi.or)([Ii([Kl],"intersectOp"),Ii([Wl],"exceptOp")]),Hh),t),Ze=n(We,(0,xi.or)([Ii([gl],"unionOp"),(0,xi.followed)(Ii([Zl],"unionOp"),Hh)]),t),et=n(Ze,(0,xi.or)([Ii([ll],"multiplyOp"),(0,xi.followed)(Ii([ac],"divOp"),Hh),(0,xi.followed)(Ii([oc],"idivOp"),Hh),(0,xi.followed)(Ii([sc],"modOp"),Hh)]),t),tt=n(et,(0,xi.or)([Ii([Ol],"subtractOp"),Ii([Cl],"addOp")]),t),nt=n(r(tt,(0,xi.followed)(Ii([ec],"rangeSequenceExpr"),Hh),"startExpr","endExpr"),Ii([yl],"stringConcatenateOp"),t),rt=n(r(nt,(0,xi.or)([vd,xd,bd])),(0,xi.followed)(Ii([rc],"andOp"),Hh),t),at=n(rt,(0,xi.followed)(Ii([nc],"orOp"),Hh),t),ot=(0,xi.then)((0,xi.then)(Ei([gc,Th,Ri,Th],l),Ei([Th,Mi,Th,yc,Hh,Th],i),((e,t)=>[e,t])),Ei([Th,wc,Hh,Th],i),((e,t)=>["ifThenElseExpr",["ifClause",e[0]],["thenClause",e[1]],["elseClause",t]])),st=(0,xi.delimited)(vc,Bh,xc),it=(0,xi.map)(Ei([bc,Bh,ul],$h),(e=>["positionalVariableBinding",...e])),lt=function(e,t,n,r,a,o){return(0,xi.then)((0,xi.then)((0,xi.then)((0,xi.then)(e,t,((e,t)=>[e,t])),n,(([e,t],n)=>[e,t,n])),r,(([e,t,n],r)=>[e,t,n,r])),a,(([e,t,n,r],a)=>o(e,t,n,r,a)))}((0,xi.preceded)(ul,(0,xi.cut)($h)),(0,xi.cut)((0,xi.preceded)(Th,(0,xi.optional)(Q))),(0,xi.cut)((0,xi.preceded)(Th,(0,xi.optional)(st))),(0,xi.cut)((0,xi.preceded)(Th,(0,xi.optional)(it))),(0,xi.cut)((0,xi.preceded)(Ai(Ac,Th),i)),((e,t,n,r,a)=>["forClauseItem",["typedVariableBinding",["varName",...e,...t?[t]:[]]],...n?[["allowingEmpty"]]:[],...r?[r]:[],["forExpr",a]])),ct=Ei([Ec,Bh],n(lt,Tl,((e,t)=>["forClause",e,...t.map((e=>e[1]))]))),ut=Ni((0,xi.preceded)(ul,$h),(0,xi.preceded)(Th,(0,xi.optional)(Q)),(0,xi.preceded)(Ai(al,Th),i),((e,t,n)=>["letClauseItem",["typedVariableBinding",["varName",...e],...t?[t]:[]],["letExpr",n]])),ht=(0,xi.map)(Ei([Nc,Th],n(ut,Tl,((e,t)=>[e,...t.map((e=>e[1]))]))),(e=>["letClause",...e])),dt=(0,xi.or)([ct,ht]),pt=(0,xi.map)(Ei([Tc,Hh,Th],i),(e=>["whereClause",e])),mt=(0,xi.map)((0,xi.preceded)(ul,$h),(e=>["varName",...e])),ft=(0,xi.then)((0,xi.preceded)(Th,(0,xi.optional)(Q)),(0,xi.preceded)(Ai(al,Th),i),((e,t)=>["groupVarInitialize",...e?[["typeDeclaration",...e]]:[],["varValue",t]])),gt=Ni(mt,(0,xi.optional)(ft),(0,xi.optional)((0,xi.map)((0,xi.preceded)(Ai(Bc,Th),h),(e=>["collation",e]))),((e,t,n)=>["groupingSpec",e,...t?[t]:[],...n?[n]:[]])),yt=n(gt,Tl,((e,t)=>[e,...t.map((e=>e[1]))])),wt=(0,xi.map)(Ei([Ic,Bh,Cc,Th],yt),(e=>["groupByClause",...e])),vt=Ni((0,xi.optional)((0,xi.or)([Gu,$u])),(0,xi.optional)(Ei([Th,xc,Th],(0,xi.or)([Qc,Kc].map((e=>(0,xi.map)(e,(e=>"empty "+e))))))),(0,xi.preceded)(Th,(0,xi.optional)(Ei([Bc,Th],h))),((e,t,n)=>e||t||n?["orderModifier",...e?[["orderingKind",e]]:[],...t?[["emptyOrderingMode",t]]:[],...n?[["collation",n]]:[]]:null)),xt=(0,xi.then)(i,(0,xi.preceded)(Th,vt),((e,t)=>["orderBySpec",["orderByExpr",e],...t?[t]:[]])),bt=n(xt,Tl,((e,t)=>[e,...t.map((e=>e[1]))])),At=(0,xi.then)((0,xi.or)([(0,xi.map)(Ei([Oc,Bh],Cc),(()=>!1)),(0,xi.map)(Ei([Sc,Bh,Oc,Bh],Cc),(()=>!0))]),(0,xi.preceded)(Th,bt),((e,t)=>["orderByClause",...e?[["stable"]]:[],...t])),Et=(0,xi.or)([dt,pt,wt,At]),Nt=(0,xi.map)(Ei([Fc,Th],i),(e=>["returnClause",e])),Tt=Ni(dt,(0,xi.cut)((0,xi.star)((0,xi.preceded)(Th,Et))),(0,xi.cut)((0,xi.preceded)(Th,Nt)),((e,t,n)=>["flworExpr",e,...t,n])),Bt=n(G,gl,((e,t)=>0===t.length?["sequenceType",...e]:["sequenceTypeUnion",["sequenceType",...e],...t.map((e=>["sequenceType",...e[1]]))])),It=Ni(Ei([eu,Th],(0,xi.optional)((0,xi.preceded)(ul,(0,xi.followed)((0,xi.followed)($h,Bh),Ul)))),(0,xi.preceded)(Th,Bt),Ei([Bh,Fc,Bh],i),((e,t,n)=>["typeswitchExprCaseClause"].concat(e?[["variableBinding",...e]]:[],[t],[["resultExpr",n]]))),Ct=Ti((0,xi.preceded)(tu,Ai((0,xi.delimited)(Ri,Ai(l,Th),Mi),Th)),(0,xi.plus)((0,xi.followed)(It,Th)),Ei([_c,Bh],(0,xi.optional)((0,xi.preceded)(ul,(0,xi.followed)($h,Bh)))),Ei([Fc,Bh],i),((e,t,n,r)=>["typeswitchExpr",["argExpr",e],...t,["typeswitchExprDefaultClause",...n||[],["resultExpr",r]]])),Ot=Ni((0,xi.preceded)(ul,$h),(0,xi.optional)((0,xi.preceded)(Bh,Q)),(0,xi.preceded)(Ai(Ac,Bh),i),((e,t,n)=>["quantifiedExprInClause",["typedVariableBinding",["varName",...e],...t?[t]:[]],["sourceExpr",n]])),St=n(Ot,Tl,((e,t)=>[e,...t.map((e=>e[1]))])),Ft=Ni((0,xi.or)([nu,ru]),(0,xi.preceded)(Bh,St),(0,xi.preceded)(Ai(au,Th),i),((e,t,n)=>["quantifiedExpr",["quantifier",e],...t,["predicateExpr",n]])),Dt=(0,xi.map)(Ei([Xl,Bh,(0,xi.or)([_l,jl]),Bh],i),(e=>["deleteExpr",["targetExpr",e]])),kt=Ni(Ei([ou,Bh],(0,xi.optional)(Ei([ql,Bh,Hl],Bh))),Ei([jl,Bh],i),(0,xi.preceded)(Ai(su,Bh),i),((e,t,n)=>e?["replaceExpr",["replaceValue"],["targetExpr",t],["replacementExpr",n]]:["replaceExpr",["targetExpr",t],["replacementExpr",n]])),Rt=(0,xi.then)(Ph,(0,xi.preceded)(Ai(al,Th),i),((e,t)=>["transformCopy",e,["copySource",t]])),Mt=Ni(Ei([iu,Bh],n(Rt,Tl,((e,t)=>[e,...t.map((e=>e[1]))]))),Ei([Th,lu,Bh],i),(0,xi.preceded)(Ai(Fc,Bh),i),((e,t,n)=>["transformExpr",["transformCopies",...e],["modifyExpr",t],["returnExpr",n]])),Ut=(0,xi.or)([(0,xi.followed)((0,xi.map)((0,xi.optional)((0,xi.followed)(Ei([Ul,Bh],(0,xi.or)([(0,xi.map)(cu,(()=>["insertAsFirst"])),(0,xi.map)(uu,(()=>["insertAsLast"]))])),Bh)),(e=>e?["insertInto",e]:["insertInto"])),pu),(0,xi.map)(du,(()=>["insertAfter"])),(0,xi.map)(hu,(()=>["insertBefore"]))]),Gt=Ni(Ei([mu,Bh,(0,xi.or)([_l,jl]),Bh],i),(0,xi.preceded)(Bh,Ut),(0,xi.preceded)(Bh,i),((e,t,n)=>["insertExpr",["sourceExpr",e],t,["targetExpr",n]])),$t=(0,xi.then)(Ei([fu,Bh,jl,Th],i),Ei([Bh,Ul,Bh],i),((e,t)=>["renameExpr",["targetExpr",e],["newNameExpr",t]])),Lt=(0,xi.then)((0,xi.plus)((0,xi.map)(Ei([eu,Bh],i),(e=>["switchCaseExpr",e]))),Ei([Bh,Fc,Bh],i),((e,t)=>["switchExprCaseClause",...e,["resultExpr",t]])),Pt=Ni(Ei([gu,Th,Ri],l),Ei([Th,Mi,Th],(0,xi.plus)((0,xi.followed)(Lt,Th))),Ei([_c,Bh,Fc,Bh],i),((e,t,n)=>["switchExpr",["argExpr",e],...t,["switchExprDefaultClause",["resultExpr",n]]])),Ht=(0,xi.map)(l,(e=>["queryBody",e])),jt=Ei([jc,Bh,Rc,Bh],(0,xi.cut)((0,xi.then)(Oh,(0,xi.preceded)(Ai(ml,Th),h),((e,t)=>["namespaceDecl",["prefix",e],["uri",t]])))),_t=(0,xi.then)(Ei([yu,Bh,ul,Th],(0,xi.then)($h,(0,xi.optional)((0,xi.preceded)(Th,Q)),((e,t)=>[e,t]))),(0,xi.cut)((0,xi.or)([(0,xi.map)(Ei([Th,al,Th],i),(e=>["varValue",e])),(0,xi.map)(Ei([Bh,wu],(0,xi.optional)(Ei([Th,al,Th],i))),(e=>["external",...e?[["varValue",e]]:[]]))])),(([e,t],n)=>["varDecl",["varName",...e],...null!==t?[t]:[],n])),Xt=Ti(Ei([Vl,Bh,(0,xi.cut)((0,xi.peek)((0,xi.not)((0,xi.followed)(ad,(0,xi.not)(sl,[""])),["Cannot use reserved function name"])))],$h),(0,xi.cut)(Ei([Th,Ri,Th],(0,xi.optional)(W))),(0,xi.cut)(Ei([Th,Mi],(0,xi.optional)(Ei([Bh,Ul,Bh],G)))),(0,xi.cut)((0,xi.preceded)(Th,(0,xi.or)([(0,xi.map)(U,(e=>["functionBody",e])),(0,xi.map)(wu,(()=>["externalDefinition"]))]))),((e,t,n,r)=>["functionDecl",["functionName",...e],["paramList",...t||[]],...n?[["typeDeclaration",...n]]:[],r])),qt=Ei([jc,Bh],(0,xi.then)((0,xi.star)((0,xi.followed)((0,xi.or)([$,Ad]),Bh)),(0,xi.or)([_t,Xt]),((e,t)=>[t[0],...e,...t.slice(1)]))),Vt=(0,xi.then)(Ei([jc,Bh,_c,Bh],(0,xi.or)([zl,Vl])),Ei([Bh,Rc,Bh],h),((e,t)=>["defaultNamespaceDecl",["defaultNamespaceCategory",e],["uri",t]])),Yt=(0,xi.or)([(0,xi.map)((0,xi.followed)(Ei([Rc,Bh],Oh),(0,xi.preceded)(Th,ml)),(e=>["namespacePrefix",e])),(0,xi.map)(Ei([_c,Bh,zl,Bh],Rc),(()=>["defaultElementNamespace"]))]),zt=Ei([xu,Bh,bu],Ni((0,xi.optional)((0,xi.preceded)(Bh,Yt)),(0,xi.preceded)(Th,h),(0,xi.optional)((0,xi.then)(Ei([Bh,bc,Bh],h),(0,xi.star)(Ei([Th,Tl,Th],h)),((e,t)=>[e,...t]))),((e,t,n)=>["schemaImport",...e?[e]:[],["targetNamespace",t],...n?[n]:[]]))),Jt=Ei([xu,Bh,Au],Ni((0,xi.optional)((0,xi.followed)(Ei([Bh,Rc,Bh],Oh),(0,xi.preceded)(Th,ml))),(0,xi.preceded)(Th,h),(0,xi.optional)((0,xi.then)(Ei([Bh,bc,Bh],h),(0,xi.star)(Ei([Th,Tl,Th],h)),((e,t)=>[e,...t]))),((e,t)=>["moduleImport",["namespacePrefix",e],["targetNamespace",t]]))),Qt=(0,xi.or)([zt,Jt]),Kt=(0,xi.map)(Ei([jc,Bh,_c,Bh,Bc,Bh],h),(e=>["defaultCollationDecl",e])),Wt=(0,xi.map)(Ei([jc,Bh,Eu,Bh],h),(e=>["baseUriDecl",e])),Zt=(0,xi.then)(Ei([jc,Bh],(0,xi.or)([(0,xi.map)(Ei([Zc,Bh],$h),(e=>["decimalFormatName",...e])),(0,xi.map)(Ei([_c,Bh],Zc),(()=>null))])),(0,xi.star)((0,xi.then)((0,xi.preceded)(Bh,Td),(0,xi.preceded)(Ai(ml,Bh),h),((e,t)=>["decimalFormatParam",["decimalFormatParamName",e],["decimalFormatParamValue",t]]))),((e,t)=>["decimalFormatDecl",...e?[e]:[],...t])),en=(0,xi.or)([Bd,Kt,Wt,Id,Cd,Od,Sd,Zt]),tn=(0,xi.then)(Ei([jc,Bh,Cu,Bh],$h),(0,xi.preceded)(Bh,h),((e,t)=>["optionDecl",["optionName",e],["optionContents",t]])),nn=(0,xi.then)(Ei([jc,Bh,Ou,Bh,Su],(0,xi.optional)(Ei([Bh,Ul],J))),(0,xi.or)([(0,xi.map)((0,xi.preceded)(Ai(al,Th),i),(e=>["varValue",e])),(0,xi.map)(Ei([Bh,wu],(0,xi.optional)((0,xi.preceded)(Ai(al,Th),i))),(()=>["external"]))]),((e,t)=>["contextItemDecl",...e?[["contextItemType",e]]:[],t])),rn=(0,xi.then)((0,xi.star)((0,xi.followed)((0,xi.or)([Vt,en,jt,Qt]),(0,xi.cut)(Ai(il,Th)))),(0,xi.star)((0,xi.followed)((0,xi.or)([nn,qt,tn]),(0,xi.cut)(Ai(il,Th)))),((e,t)=>0===e.length&&0===t.length?null:["prolog",...e,...t])),an=Ei([Au,Bh,Rc,Bh],(0,xi.then)((0,xi.followed)(Oh,Ai(ml,Th)),(0,xi.followed)(h,Ai(il,Th)),((e,t)=>["moduleDecl",["prefix",e],["uri",t]]))),on=(0,xi.then)(an,(0,xi.preceded)(Th,rn),((e,t)=>["libraryModule",e,...t?[t]:[]])),sn=(0,xi.then)(rn,(0,xi.preceded)(Th,Ht),((e,t)=>["mainModule",...e?[e]:[],t])),ln=(0,xi.map)(Ei([Fu,Th],(0,xi.followed)((0,xi.or)([(0,xi.then)((0,xi.preceded)(ku,Bh),h,(e=>["encoding",e])),(0,xi.then)(Ei([Du,Bh],h),(0,xi.optional)(Ei([Bh,ku,Bh],h)),((e,t)=>[["version",e],...t?[["encoding",t]]:[]]))]),(0,xi.preceded)(Th,il))),(e=>["versionDecl",...e])),cn=(0,xi.then)((0,xi.optional)(Ai(ln,Th)),(0,xi.or)([on,sn]),((e,t)=>["module",...e?[e]:[],t])),un=(0,xi.complete)(Ai(cn,Th));return(e,t)=>{c.clear(),t=un(e,t);let n=1,r=1;for(let t=0;t<e.length+1;t++){if(c.has(t)){var a=c.get(t);a.line=r,a.ha=n}"\r"===(a=e[t])||"\n"===a?(r++,n=1):n++}return t}}const Pd=Ld({lb:!1,Ya:!1}),Hd=Ld({lb:!0,Ya:!1}),jd=Ld({lb:!1,Ya:!0}),_d=Ld({lb:!0,Ya:!0});function Xd(e,t){var n=!!t.Z;if(t=!!t.debug,wh.clear(),vh.clear(),$d.clear(),!0===(n=n?t?_d(e,0):jd(e,0):t?Hd(e,0):Pd(e,0)).success)return n.value;throw t=(e=e.substring(0,n.offset).split("\n"))[e.length-1].length+1,new go({start:{offset:n.offset,line:e.length,ha:t},end:{offset:n.offset+1,line:e.length,ha:t+1}},"",Error(`XPST0003: Failed to parse script. Expected ${[...new Set(n.expected)]}`))}const qd="http://www.w3.org/XML/1998/namespace http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2005/xpath-functions http://www.w3.org/2005/xpath-functions/math http://www.w3.org/2012/xquery http://www.w3.org/2005/xpath-functions/array http://www.w3.org/2005/xpath-functions/map".split(" ");function Vd(e,t,n,r){const a=[],o=[];xa(e,"*").forEach((e=>{switch(e[0]){case"moduleImport":case"namespaceDecl":case"defaultNamespaceDecl":case"functionDecl":case"varDecl":break;default:throw Error("Not implemented: only module imports, namespace declarations, and function declarations are implemented in XQuery modules")}}));const s=new Set;xa(e,"moduleImport").forEach((e=>{const n=ya(ga(e,"namespacePrefix"));if(e=ya(ga(e,"targetNamespace")),s.has(e))throw Error(`XQST0047: The namespace "${e}" is imported more than once.`);s.add(e),ha(t,n,e)})),xa(e,"namespaceDecl").forEach((e=>{const n=ya(ga(e,"prefix"));if(e=ya(ga(e,"uri")),"xml"===n||"xmlns"===n)throw ra();if("http://www.w3.org/XML/1998/namespace"===e||"http://www.w3.org/2000/xmlns/"===e)throw ra();ha(t,n,e)}));let i=null,l=null;for(const t of xa(e,"defaultNamespaceDecl")){const e=ya(ga(t,"defaultNamespaceCategory")),n=ya(ga(t,"uri"));if(!n)throw ta();if("http://www.w3.org/XML/1998/namespace"===n||"http://www.w3.org/2000/xmlns/"===n)throw ra();if("function"===e){if(i)throw na();i=n}else if("element"===e){if(l)throw na();l=n}}i&&(t.v=i),l&&ha(t,"",l),xa(e,"functionDecl").forEach((e=>{!function(e,t,n,r,a){var o=ga(e,"functionName"),s=wa(o,"prefix")||"";let i=wa(o,"URI");const l=ya(o);if(null===i&&(i=""===s?null===t.v?"http://www.w3.org/2005/xpath-functions":t.v:t.$(s),!i&&s))throw oa(s);if(qd.includes(i))throw Zr();if(s=xa(e,"annotation").map((e=>ga(e,"annotationName"))),o=s.every((e=>!wa(e,"URI")&&"private"!==ya(e))),s=s.some((e=>!wa(e,"URI")&&"updating"===ya(e))),!i)throw ta();const c=Aa(e),u=xa(ga(e,"paramList"),"param"),h=u.map((e=>ga(e,"varName"))),d=u.map((e=>Aa(e)));if(e=ga(e,"functionBody")){if(t.va(i,l,d.length))throw ea(i,l);if(!a)return;const u=ui(e[1],{ra:!1,Z:!0}),p=new fa(t),m=h.map((e=>{let n=wa(e,"URI");const r=wa(e,"prefix");return e=ya(e),r&&null===n&&(n=t.$(r||"")),da(p,n,e)}));a=s?{j:d,arity:h.length,callFunction:(e,t,n,...r)=>(e=Ye(je(e,-1,null,$.empty()),m.reduce(((e,t,n)=>(e[t]=L(r[n]),e)),Object.create(null))),u.s(e,t)),ub:!1,J:!0,bb:o,localName:l,namespaceURI:i,i:c}:{j:d,arity:h.length,callFunction:(e,t,n,...r)=>(e=Ye(je(e,-1,null,$.empty()),m.reduce(((e,t,n)=>(e[t]=L(r[n]),e)),Object.create(null))),Jn(u,e,t)),ub:!1,J:!1,bb:o,localName:l,namespaceURI:i,i:c},n.push({ba:u,Cb:p}),r.push({arity:h.length,ba:u,yb:a,localName:l,namespaceURI:i,bb:o})}else{if(s)throw Error("Updating external function declarations are not supported");a={j:d,arity:h.length,callFunction:(e,t,n,...r)=>{const a=n.va(i,l,h.length,!0);if(!a)throw Error(`XPST0017: Function Q{${i}}${l} with arity of ${h.length} not registered. ${Vr(l)}`);if(a.i.type!==c.type||a.j.some(((e,t)=>e.type!==d[t].type)))throw Error("External function declaration types do not match actual function");return a.callFunction(e,t,n,...r)},ub:!0,J:!1,localName:l,namespaceURI:i,bb:o,i:c}}ua(t,i,l,h.length,a)}(e,t,a,o,n)}));const c=[];return xa(e,"varDecl").forEach((e=>{const r=ba(ga(e,"varName"));let o=r.namespaceURI;if(null===o&&(o=t.$(r.prefix),!o&&r.prefix))throw oa(r.prefix);if(qd.includes(o))throw Zr();var s=ga(e,"external");let i,l;if(e=ga(e,"varValue"),null!==s?null!==(s=ga(s,"varValue"))&&(i=ga(s,"*")):null!==e&&(i=ga(e,"*")),c.some((e=>e.namespaceURI===o&&e.localName===r.localName)))throw Error(`XQST0049: The variable ${o?`Q{${o}}`:""}${r.localName} has already been declared.`);if(da(t,o||"",r.localName),n&&(i&&(l=ui(i,{ra:!1,Z:!0})),i&&!function(e,t,n){return(e=e.Ea[sa(t,n)])?e:null}(t,o||"",r.localName))){let e=null;pa(t,o,r.localName,((t,n)=>(e||(e=L(Jn(l,t,n))),e()))),a.push({ba:l,Cb:new fa(t)}),c.push({ba:l,localName:r.localName,namespaceURI:o})}})),o.forEach((e=>{if(!e.yb.J&&e.ba.J)throw $n(`The function Q{${e.namespaceURI}}${e.localName} is updating but the %updating annotation is missing.`)})),{Ha:o.map((e=>e.yb)),Ta:c,source:r,oa:e=>{s.forEach((e=>{yi(t,e)})),a.forEach((({ba:t,Cb:n})=>{s.forEach((e=>{yi(n,e)})),e.Ha.forEach((e=>{n.va(e.namespaceURI,e.localName,e.arity,!0)||e.bb&&ua(n,e.namespaceURI,e.localName,e.arity,e)})),e.Ta.forEach((e=>{n.cb(e.namespaceURI,e.localName)||da(n,e.namespaceURI,e.localName)})),t.v(n)}))}}}function Yd(e,t,n,r,a,o,s){const i=t.Z?"XQuery":"XPath";return n=t.Ga?null:function(e,t,n,r,a,o,s,i){return(e=hi.get(e))&&(t=e[t+(o?"_DEBUG":"")])&&(t=t.find((e=>e.o===s&&e.v.every((e=>n(e.prefix)===e.namespaceURI))&&e.D.every((e=>void 0!==r[e.name]))&&e.jb.every((e=>a[e.prefix]===e.namespaceURI))&&e.l.every((e=>{const t=i(e.ac,e.arity);return t&&t.namespaceURI===e.Bb.namespaceURI&&t.localName===e.Bb.localName})))))?{ba:t.h,ec:!1}:null}(e,i,n,r,a,t.debug,o,s),null!==n?{state:n.ec?1:2,ba:n.ba}:{state:0,Wb:"string"==typeof e?Xd(e,t):mi(e)}}function zd(e,t,n,r,a,o,s){const i=new Qr(n,r,o,s),l=new fa(i);switch(0<Object.keys(a).length&&wi(),Object.keys(a).forEach((e=>{const t=a[e];yi(l,t),ha(l,e,t)})),"string"==typeof e&&(e=vi(e)),(n=Yd(e,t,n,r,a,o,s)).state){case 2:return{ga:l,ba:n.ba};case 1:return n.ba.v(l),pi(e,t.Z?"XQuery":"XPath",i,a,n.ba,t.debug,o),{ga:l,ba:n.ba};case 0:return n=function(e,t,n,r){const a=ga(e,"mainModule");if(!a)throw Error("Can not execute a library module.");const o=ga(a,"prolog");if(o){if(!t.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");wi(),(r=Vd(o,n,!0,r)).oa(r)}return Ga(e,new Ya(n)),oi(e=va(a,["queryBody","*"]),t)}(n.Wb,t,l,e),n.v(l),t.Ga||pi(e,t.Z?"XQuery":"XPath",i,a,n,t.debug,o),{ga:l,ba:n}}}function Jd(e,t,n,r){e=e.first();const a=t.first().h.reduce(((e,t)=>(e[t.key.value]=L(t.value()),e)),Object.create(null));t=a["."]?a["."]():$.empty(),delete a["."];try{const{ba:o,ga:s}=zd(function(e){if(T(e.type,1))return e.value;if(T(e.type,54))return e.value.node;throw Ze(`Unable to convert selector argument of type ${C[e.type]} to either an ${C[1]} or an ${C[54]} representing an XQueryX program while calling 'fontoxpath:evaluate'`)}(e),{ra:!1,Z:!0,debug:r.debug,Ga:r.Ga},(e=>n.$(e)),Object.keys(a).reduce(((e,t)=>(e[t]=t,e)),{}),{},"http://www.w3.org/2005/xpath-functions",((e,t)=>n.Sa(e,t))),i=!t.G(),l=new ze({M:i?t.first():null,Aa:i?0:-1,sa:t,qa:Object.keys(a).reduce(((e,t)=>(e[s.cb(null,t)]=a[t],e)),Object.create(null))});return{fc:o.h(l,r).value,cc:e}}catch(t){_r(e.value,t)}}function Qd(e,t,n){if(1!==t.node.nodeType&&9!==t.node.nodeType)return[];const r=W(e,t).reduce(((t,r)=>{for(const a of Qd(e,r,n))t.push(a);return t}),[]);return n(t)&&r.unshift(t),r}const Kd=(e,t,n,r,a)=>{if(!(e=a.first()))throw We("The context is absent, it needs to be present to use id function.");if(!T(e.type,53))throw Ze("The context item is not a node, it needs to be node to use id function.");const o=t.h,s=r.O().reduce(((e,t)=>(t.value.split(/\s+/).forEach((t=>{e[t]=!0})),e)),Object.create(null));for(t=e.value;9!==t.node.nodeType;)if(null===(t=ne(o,t)))throw Error("FODC0001: the root node of the target node is not a document node.");return t=Qd(o,t,(e=>1===e.node.nodeType&&(!(!(e=K(o,e,"id"))||!s[e])&&(s[e]=!1,!0)))),$.create(t.map((e=>ce(e))))},Wd=(e,t,n,r,a)=>{if(!(e=a.first()))throw We("The context is absent, it needs to be present to use idref function.");if(!T(e.type,53))throw Ze("The context item is not a node, it needs to be node to use idref function.");const o=t.h,s=r.O().reduce(((e,t)=>(e[t.value]=!0,e)),Object.create(null));for(t=e.value;9!==t.node.nodeType;)if(null===(t=ne(o,t)))throw Error("FODC0001: the root node of the context node is not a document node.");return t=Qd(o,t,(e=>1===e.node.nodeType&&(!!(e=K(o,e,"idref"))&&e.split(/\s+/).some((e=>s[e]))))),$.create(t.map((e=>ce(e))))};function Zd(e){switch(typeof e){case"object":return Array.isArray(e)?$.m(new ie(e.map((e=>L(Zd(e)))))):null===e?$.empty():$.m(new pe(Object.keys(e).map((t=>({key:y(t,1),value:L(Zd(e[t]))})))));case"number":return $.m(y(e,3));case"string":return $.m(y(e,1));case"boolean":return e?$.aa():$.V();default:throw Error("Unexpected type in JSON parse")}}const ep=(e,t,n,r,a)=>{const o=$.m(y("duplicates",1)),s=(e=de(0,0,0,a,o)).G()?"use-first":e.first().value;return r.N((e=>$.m(new pe(e.reduce(((e,t)=>(t.h.forEach((t=>{const n=e.findIndex((e=>he(e.key,t.key)));if(0<=n)switch(s){case"reject":throw Error("FOJS0003: Duplicate encountered when merging maps.");case"use-last":return void e.splice(n,1,t);case"combine":return void e.splice(n,1,{key:t.key,value:L($.create(e[n].value().O().concat(t.value().O())))});default:return}e.push(t)})),e)),[])))))};function tp(e,t,n){let r=1;const a=e.value;e=e.Pa(!0);let o=null;const s=Math.max(t-1,0);return-1!==e&&(o=Math.max(0,(null===n?e:Math.max(0,Math.min(e,n+(t-1))))-s)),$.create({next:e=>{for(;r<t;)a.next(e),r++;return null!==n&&r>=t+n?A:(e=a.next(e),r++,e)}},o)}function np(e){return e.map((e=>T(e.type,19)?At(e,3):e))}function rp(e){if((e=np(e)).some((e=>Number.isNaN(e.value))))return[y(NaN,3)];if(!(e=Wo(e)))throw Error("FORG0006: Incompatible types to be converted to a common type");return e}const ap=(e,t,n,r,a,o)=>ue([a,o],(([e,t])=>{if(1/0===e.value)return $.empty();if(-1/0===e.value)return t&&1/0===t.value?$.empty():r;if(t){if(isNaN(t.value))return $.empty();1/0===t.value&&(t=null)}return isNaN(e.value)?$.empty():tp(r,Math.round(e.value),t?Math.round(t.value):null)})),op=(e,t,n,r,a)=>{if(r.G())return a;if(!(e=Wo(e=np(r.O()))))throw Error("FORG0006: Incompatible types to be converted to a common type");if(!e.every((e=>T(e.type,2))))throw Error("FORG0006: items passed to fn:sum are not all numeric.");return t=e.reduce(((e,t)=>e+t.value),0),e.every((e=>T(e.type,5)))?$.m(y(t,5)):e.every((e=>T(e.type,3)))?$.m(y(t,3)):e.every((e=>T(e.type,4)))?$.m(y(t,4)):$.m(y(t,6))};var sp=[].concat(Er,[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"boolean",j:[{type:59,g:2}],i:{type:0,g:3},callFunction:(e,t,n,r)=>r.fa()?$.aa():$.V()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"true",j:[],i:{type:0,g:3},callFunction:()=>$.aa()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"not",j:[{type:59,g:2}],i:{type:0,g:3},callFunction:(e,t,n,r)=>!1===r.fa()?$.aa():$.V()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"false",j:[],i:{type:0,g:3},callFunction:()=>$.V()}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"last",j:[],i:{type:5,g:3},callFunction:e=>{if(null===e.M)throw We("The fn:last() function depends on dynamic context, which is absent.");let t=!1;return $.create({next:()=>{if(t)return A;const n=e.sa.Pa();return t=!0,E(y(n,5))}},1)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"position",j:[],i:{type:5,g:3},callFunction:e=>{if(null===e.M)throw We("The fn:position() function depends on dynamic context, which is absent.");return $.m(y(e.Aa+1,5))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-dateTime",j:[],i:{type:10,g:3},callFunction:e=>$.m(y(Xe(e),10))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-date",j:[],i:{type:7,g:3},callFunction:e=>$.m(y(Ce(Xe(e),7),7))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-time",j:[],i:{type:8,g:3},callFunction:e=>$.m(y(Ce(Xe(e),8),8))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"implicit-timezone",j:[],i:{type:17,g:3},callFunction:e=>$.m(y(qe(e),17))}],Tr,kr,$r,[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"years-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.ab(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"months-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.$a(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"days-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.Za(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.getHours(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.getMinutes(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-duration",j:[{type:18,g:0}],i:{type:4,g:0},callFunction:(e,t,n,r)=>r.G()?r:$.m(y(r.first().value.getSeconds(),4))}],Pr,[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"id",j:[{type:1,g:2},{type:53,g:3}],i:{type:54,g:2},callFunction:Kd},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"id",j:[{type:1,g:2}],i:{type:54,g:2},callFunction:(e,t,n,r)=>Kd(e,t,0,r,$.m(e.M))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"idref",j:[{type:1,g:2},{type:53,g:3}],i:{type:53,g:2},callFunction:Wd},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"idref",j:[{type:1,g:2}],i:{type:53,g:2},callFunction:(e,t,n,r)=>Wd(e,t,0,r,$.m(e.M))}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"parse-json",j:[{type:1,g:3}],i:{type:59,g:0},callFunction:(e,t,n,r)=>{let a;try{a=JSON.parse(r.first().value)}catch(e){throw Error("FOJS0001: parsed JSON string contains illegal JSON.")}return Zd(a)}}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"contains",j:[{type:61,g:3},{type:46,g:3}],i:{type:0,g:3},callFunction:(e,t,n,r,a)=>ue([r,a],(([e,t])=>e.h.some((e=>he(e.key,t)))?$.aa():$.V()))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"entry",j:[{type:46,g:3},{type:59,g:2}],i:{type:61,g:3},callFunction:(e,t,n,r,a)=>r.map((e=>new pe([{key:e,value:L(a)}])))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"for-each",j:[{type:61,g:3},{type:59,g:2}],i:{type:59,g:2},callFunction:(e,t,n,r,a)=>ue([r,a],(([r,a])=>Qe(r.h.map((r=>a.value.call(void 0,e,t,n,$.m(r.key),r.value()))))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"get",j:[{type:61,g:3},{type:46,g:3}],i:{type:59,g:2},callFunction:de},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"keys",j:[{type:61,g:3}],i:{type:46,g:2},callFunction:(e,t,n,r)=>ue([r],(([e])=>$.create(e.h.map((e=>e.key)))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"merge",j:[{type:61,g:2},{type:61,g:3}],i:{type:61,g:3},callFunction:ep},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"merge",j:[{type:61,g:2}],i:{type:61,g:3},callFunction:(e,t,n,r)=>ep(e,0,0,r,$.m(new pe([{key:y("duplicates",1),value:()=>$.m(y("use-first",1))}])))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"put",j:[{type:61,g:3},{type:46,g:3},{type:59,g:2}],i:{type:61,g:3},callFunction:(e,t,n,r,a,o)=>ue([r,a],(([e,t])=>{const n=(e=e.h.concat()).findIndex((e=>he(e.key,t)));return 0<=n?e.splice(n,1,{key:t,value:L(o)}):e.push({key:t,value:L(o)}),$.m(new pe(e))}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"remove",j:[{type:61,g:3},{type:46,g:2}],i:{type:61,g:3},callFunction:(e,t,n,r,a)=>ue([r],(([e])=>{const t=e.h.concat();return a.N((e=>(e.forEach((e=>{const n=t.findIndex((t=>he(t.key,e)));0<=n&&t.splice(n,1)})),$.m(new pe(t)))))}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"size",j:[{type:61,g:3}],i:{type:5,g:3},callFunction:(e,t,n,r)=>r.map((e=>y(e.h.length,5)))}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"pi",j:[],i:{type:3,g:3},callFunction:()=>$.m(y(Math.PI,3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"exp",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.pow(Math.E,e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"exp10",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.pow(10,e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"log",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.log(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"log10",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.log10(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"pow",j:[{type:3,g:0},{type:2,g:3}],i:{type:3,g:0},callFunction:(e,t,n,r,a)=>a.N((([e])=>r.map((t=>1!==Math.abs(t.value)||Number.isFinite(e.value)?y(Math.pow(t.value,e.value),3):y(1,3)))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"sqrt",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.sqrt(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"sin",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.sin(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"cos",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.cos(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"tan",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.tan(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"asin",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.asin(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"acos",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.acos(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"atan",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(Math.atan(e.value),3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"atan2",j:[{type:3,g:0},{type:3,g:3}],i:{type:3,g:0},callFunction:(e,t,n,r,a)=>a.N((([e])=>r.map((t=>y(Math.atan2(t.value,e.value),3)))))}],Cn,an,[{namespaceURI:"http://fontoxpath/operators",localName:"to",j:[{type:5,g:0},{type:5,g:0}],i:{type:5,g:2},callFunction:(e,t,n,r,a)=>{if(e=r.first(),a=a.first(),null===e||null===a)return $.empty();let o=e.value;return a=a.value,o>a?$.empty():$.create({next:()=>E(y(o++,5))},a-o+1)}}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"QName",j:[{type:1,g:0},{type:1,g:3}],i:{type:23,g:3},callFunction:(e,t,n,r,a)=>ue([r,a],(([e,t])=>{if(!st(t=t.value,23))throw Error("FOCA0002: The provided QName is invalid.");if(null===(e=e&&e.value||null)&&t.includes(":"))throw Error("FOCA0002: The URI of a QName may not be empty if a prefix is provided.");if(r.G())return $.m(y(new P("",null,t),23));if(!t.includes(":"))return $.m(y(new P("",e,t),23));const[n,a]=t.split(":");return $.m(y(new P(n,e,a),23))}))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"prefix-from-QName",j:[{type:23,g:0}],i:{type:24,g:0},callFunction:(e,t,n,r)=>ue([r],(([e])=>null===e?$.empty():(e=e.value).prefix?$.m(y(e.prefix,24)):$.empty()))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"local-name-from-QName",j:[{type:23,g:0}],i:{type:24,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(e.value.localName,24)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"namespace-uri-from-QName",j:[{type:23,g:0}],i:{type:20,g:0},callFunction:(e,t,n,r)=>r.map((e=>y(e.value.namespaceURI||"",20)))}],[{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>r.Y({empty:()=>$.aa(),multiple:()=>$.V(),m:()=>$.V()}),localName:"empty",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>r.Y({empty:()=>$.V(),multiple:()=>$.aa(),m:()=>$.aa()}),localName:"exists",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>tp(r,1,1),localName:"head",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:0}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>tp(r,2,null),localName:"tail",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:5,g:3},{type:59,g:2}],callFunction:(e,t,n,r,a,o)=>r.G()?o:o.G()?r:(e=r.O(),0>(a=a.first().value-1)?a=0:a>e.length&&(a=e.length),t=e.slice(a),$.create(e.slice(0,a).concat(o.O(),t))),localName:"insert-before",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:5,g:3}],callFunction:(e,t,n,r,a)=>(e=a.first().value,!(r=r.O()).length||1>e||e>r.length||r.splice(e-1,1),$.create(r)),localName:"remove",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>r.N((e=>$.create(e.reverse()))),localName:"reverse",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:3,g:3}],callFunction:(e,t,n,r,a)=>ap(0,0,0,r,a,$.empty()),localName:"subsequence",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:3,g:3},{type:3,g:3}],callFunction:ap,localName:"subsequence",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>r,localName:"unordered",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:46,g:2}],callFunction:(e,t,n,r)=>{const a=rt(r,t).O();return $.create(a).filter(((e,t)=>a.slice(0,t).every((t=>!Fn(e,t)))))},localName:"distinct-values",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}},{j:[{type:46,g:2},{type:1,g:3}],callFunction(){throw Error("FOCH0002: No collations are supported")},localName:"distinct-values",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}},{j:[{type:46,g:2},{type:46,g:3}],callFunction:(e,t,n,r,a)=>a.N((([n])=>rt(r,t).map(((t,r)=>Ro("eqOp",t.type,n.type)(t,n,e)?y(r+1,5):y(-1,5))).filter((e=>-1!==e.value)))),localName:"index-of",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:2}},{j:[{type:46,g:2},{type:46,g:3},{type:1,g:3}],callFunction(){throw Error("FOCH0002: No collations are supported")},localName:"index-of",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:2}},{j:[{type:59,g:2},{type:59,g:2}],callFunction:(e,t,n,r,a)=>{let o=!1;const s=Rn(e,t,n,r,a);return $.create({next:()=>{if(o)return A;const e=s.next(0);return e.done?e:(o=!0,E(y(e.value,0)))}})},localName:"deep-equal",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:59,g:2},{type:59,g:2},{type:1,g:3}],callFunction(){throw Error("FOCH0002: No collations are supported")},localName:"deep-equal",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>{let a=!1;return $.create({next:()=>{if(a)return A;const e=r.Pa();return a=!0,E(y(e,5))}})},localName:"count",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:3}},{j:[{type:46,g:2}],callFunction:(e,t,n,r)=>{if(r.G())return r;if(!(e=Wo(e=np(r.O()))))throw Error("FORG0006: Incompatible types to be converted to a common type");if(!e.every((e=>T(e.type,2))))throw Error("FORG0006: items passed to fn:avg are not all numeric.");return t=e.reduce(((e,t)=>e+t.value),0)/e.length,e.every((e=>T(e.type,5)||T(e.type,3)))?$.m(y(t,3)):e.every((e=>T(e.type,4)))?$.m(y(t,4)):$.m(y(t,6))},localName:"avg",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2}],callFunction:(e,t,n,r)=>r.G()?r:(e=rp(r.O()),$.m(e.reduce(((e,t)=>e.value<t.value?t:e)))),localName:"max",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2},{type:1,g:3}],callFunction(){throw Error("FOCH0002: No collations are supported")},localName:"max",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2}],callFunction:(e,t,n,r)=>r.G()?r:(e=rp(r.O()),$.m(e.reduce(((e,t)=>e.value>t.value?t:e)))),localName:"min",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2},{type:1,g:3}],callFunction(){throw Error("FOCH0002: No collations are supported")},localName:"min",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2}],callFunction:(e,t,n,r)=>op(e,t,0,r,$.m(y(0,5))),localName:"sum",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:3}},{j:[{type:46,g:2},{type:46,g:0}],callFunction:op,localName:"sum",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>{if(!r.G()&&!r.ua())throw Error("FORG0003: The argument passed to fn:zero-or-one contained more than one item.");return r},localName:"zero-or-one",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:0}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>{if(r.G())throw Error("FORG0004: The argument passed to fn:one-or-more was empty.");return r},localName:"one-or-more",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:1}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>{if(!r.ua())throw Error("FORG0005: The argument passed to fn:exactly-one is empty or contained more than one item.");return r},localName:"exactly-one",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:3}},{j:[{type:59,g:2},{type:60,g:3}],callFunction:(e,t,n,r,a)=>{if(r.G())return r;const o=a.first(),s=o.o;if(1!==s.length)throw Error("XPTY0004: signature of function passed to fn:filter is incompatible.");return r.filter((r=>{if(r=Gt(s[0],$.m(r),t,"fn:filter",!1),!(r=o.value.call(void 0,e,t,n,r)).ua()||!T(r.first().type,0))throw Error("XPTY0004: signature of function passed to fn:filter is incompatible.");return r.first().value}))},localName:"filter",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:60,g:3}],callFunction:(e,t,n,r,a)=>{if(r.G())return r;const o=a.first(),s=o.o;if(1!==s.length)throw Error("XPTY0004: signature of function passed to fn:for-each is incompatible.");const i=r.value;let l;return $.create({next:r=>{for(;;){if(!l){var a=i.next(0);if(a.done)return a;a=Gt(s[0],$.m(a.value),t,"fn:for-each",!1),l=o.value.call(void 0,e,t,n,a).value}if(!(a=l.next(r)).done)return a;l=null}}})},localName:"for-each",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:59,g:2},{type:60,g:3}],callFunction:(e,t,n,r,a,o)=>{if(r.G())return r;const s=o.first(),i=s.o;if(2!==i.length)throw Error("XPTY0004: signature of function passed to fn:fold-left is incompatible.");return r.N((r=>r.reduce(((r,a)=>(r=Gt(i[0],r,t,"fn:fold-left",!1),a=Gt(i[1],$.m(a),t,"fn:fold-left",!1),s.value.call(void 0,e,t,n,r,a))),a)))},localName:"fold-left",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:59,g:2},{type:60,g:3}],callFunction:(e,t,n,r,a,o)=>{if(r.G())return r;const s=o.first(),i=s.o;if(2!==i.length)throw Error("XPTY0004: signature of function passed to fn:fold-right is incompatible.");return r.N((r=>r.reduceRight(((r,a)=>(r=Gt(i[0],r,t,"fn:fold-right",!1),a=Gt(i[1],$.m(a),t,"fn:fold-right",!1),s.value.call(void 0,e,t,n,a,r))),a)))},localName:"fold-right",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2}],callFunction:(e,t,n,r)=>{if(!t.Ua)throw Error("serialize() called but no xmlSerializer set in execution parameters.");if(!(e=r.O()).every((e=>T(e.type,53))))throw Error("Expected argument to fn:serialize to resolve to a sequence of Nodes.");return $.m(y(e.map((e=>t.Ua.serializeToString(Ur(e.value,t,!1)))).join(""),1))},localName:"serialize",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}}],yn,[{j:[{type:59,g:3},{type:61,g:3}],callFunction:(e,t,n,r,a)=>{let o,s;return $.create({next:()=>{o||({fc:o,cc:s}=Jd(r,a,n,t));try{return o.next(0)}catch(e){_r(s.value,e)}}})},localName:"evaluate",namespaceURI:"http://fontoxml.com/fontoxpath",i:{type:59,g:2}},{j:[],callFunction:()=>$.m(y("3.30.0",1)),localName:"version",namespaceURI:"http://fontoxml.com/fontoxpath",i:{type:1,g:3}}],[{j:[{type:23,g:3},{type:5,g:3}],callFunction:(e,t,n,r,a)=>ue([r,a],(([e,t])=>{const r=n.va(e.value.namespaceURI,e.value.localName,t.value);return null===r?$.empty():(e=new H({j:r.j,arity:t.value,localName:e.value.localName,namespaceURI:e.value.namespaceURI,i:r.i,value:r.callFunction}),$.m(e))})),localName:"function-lookup",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{g:0,type:60}},{j:[{type:60,g:3}],callFunction:(e,t,n,r)=>ue([r],(([e])=>e.Xa()?$.empty():$.m(y(new P("",e.l,e.D),23)))),localName:"function-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[{type:60,g:3}],callFunction:(e,t,n,r)=>ue([r],(([e])=>$.m(y(e.v,5)))),localName:"function-arity",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:3}}]);class ip{constructor(e){this.h=e}createAttributeNS(e,t){return this.h.createAttributeNS(e,t)}createCDATASection(e){return this.h.createCDATASection(e)}createComment(e){return this.h.createComment(e)}createDocument(){return this.h.createDocument()}createElementNS(e,t){return this.h.createElementNS(e,t)}createProcessingInstruction(e,t){return this.h.createProcessingInstruction(e,t)}createTextNode(e){return this.h.createTextNode(e)}}var lp=Symbol("IS_XPATH_VALUE_SYMBOL");function cp(e){return e&&"object"==typeof e&&"lookupNamespaceURI"in e?t=>e.lookupNamespaceURI(t||null):()=>null}function up(e){return({prefix:t,localName:n})=>t?null:{namespaceURI:e,localName:n}}function hp(e,t,n,r,a,o){null==r&&(r=r||{});const s=a?{ib:a.logger||{trace:console.log.bind(console)},Ma:a.documentWriter,jb:a.moduleImports,Ab:a.namespaceResolver,Zb:a.functionNameResolver,Ia:a.nodesFactory,Ua:a.xmlSerializer}:{ib:{trace:console.log.bind(console)},jb:{},Ab:null,Ia:null,Ma:null,Ua:null},i=new oe(null===n?new q:n);n=s.jb||Object.create(null);var l=void 0===a.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":a.defaultFunctionNamespaceURI;const c=zd(e,o,s.Ab||cp(t),r,n,l,s.Zb||up(l));e=t?Pe(0,t):$.empty(),t=!s.Ia&&o.Z?new Wn(t):new ip(s.Ia),n=s.Ma?new Y(s.Ma):V,l=s.Ua;const u=Object.keys(r).reduce(((e,t)=>{const n=r[t];return e[`Q{}${t}[0]`]=n&&"object"==typeof n&&lp in n?()=>$.create(n.xb):()=>Pe(0,r[t]),e}),Object.create(null));let h;for(const e of Object.keys(c.ga.Ea))u[e]||(u[e]=()=>(0,c.ga.Ea[e])(h,d));h=new ze({M:e.first(),Aa:0,sa:e,qa:u});const d=new Je(o.debug,o.Ga,i,t,n,a.currentContext,new Map,s.ib,l);return{rb:h,sb:d,ba:c.ba}}function dp(e,t){const n={};let r=0,a=!1,o=null;return{next:()=>{if(a)return A;for(;r<e.h.length;){const a=e.h[r].key.value;if(!o){const i=e.h[r];var s=i.value().Y({default:e=>e,multiple:()=>{throw Error(`Serialization error: The value of an entry in a map is expected to be a single item or an empty sequence. Use arrays when putting multiple values in a map. The value of the key ${i.key.value} holds multiple items`)}}).first();if(null===s){n[a]=null,r++;continue}o=mp(s,t)}s=o.next(0),o=null,n[a]=s.value,r++}return a=!0,E(n)}}}function pp(e,t){const n=[];let r=0,a=!1,o=null;return{next:()=>{if(a)return A;for(;r<e.h.length;){if(!o){var s=e.h[r]().Y({default:e=>e,multiple:()=>{throw Error("Serialization error: The value of an entry in an array is expected to be a single item or an empty sequence. Use nested arrays when putting multiple values in an array.")}}).first();if(null===s){n[r++]=null;continue}o=mp(s,t)}s=o.next(0),o=null,n[r++]=s.value}return a=!0,E(n)}}}function mp(e,t){if(T(e.type,61))return dp(e,t);if(T(e.type,62))return pp(e,t);if(T(e.type,23)){const t=e.value;return{next:()=>E(`Q{${t.namespaceURI||""}}${t.localName}`)}}switch(e.type){case 7:case 8:case 9:case 11:case 12:case 13:case 14:case 15:const n=e.value;return{next:()=>E(Oe(n))};case 47:case 53:case 54:case 55:case 56:case 57:case 58:const r=e.value;return{next:()=>E(Ur(r,t,!1))};default:return{next:()=>E(e.value)}}}sp.forEach((e=>{zr(e.namespaceURI,e.localName,e.j,e.i,e.callFunction)}));var fp={ANY:0,NUMBER:1,STRING:2,BOOLEAN:3,NODES:7,FIRST_NODE:9,STRINGS:10,MAP:11,ARRAY:12,NUMBERS:13,ALL_RESULTS:14,ASYNC_ITERATOR:99};function gp(e,t,n,r){switch(n){case 3:return t.fa();case 2:return(t=rt(t,r).O()).length?t.map((e=>At(e,1).value)).join(" "):"";case 10:return(t=rt(t,r).O()).length?t.map((e=>e.value+"")):[];case 1:return null!==(t=t.first())&&T(t.type,2)?t.value:NaN;case 9:if(null===(t=t.first()))return null;if(!T(t.type,53))throw Error("Expected XPath "+Hr(e)+" to resolve to Node. Got "+C[t.type]);return Ur(t.value,r,!1);case 7:if(!(t=t.O()).every((e=>T(e.type,53))))throw Error("Expected XPath "+Hr(e)+" to resolve to a sequence of Nodes.");return t.map((e=>Ur(e.value,r,!1)));case 11:if(1!==(t=t.O()).length)throw Error("Expected XPath "+Hr(e)+" to resolve to a single map.");if(!T((t=t[0]).type,61))throw Error("Expected XPath "+Hr(e)+" to resolve to a map");return dp(t,r).next(0).value;case 12:if(1!==(t=t.O()).length)throw Error("Expected XPath "+Hr(e)+" to resolve to a single array.");if(!T((t=t[0]).type,62))throw Error("Expected XPath "+Hr(e)+" to resolve to an array");return pp(t,r).next(0).value;case 13:return t.O().map((t=>{if(!T(t.type,2))throw Error("Expected XPath "+Hr(e)+" to resolve to numbers");return t.value}));case 99:const n=t.value;let a=null,o=!1;const s=()=>{for(;!o;){if(!a){var e=n.next(0);if(e.done){o=!0;break}a=mp(e.value,r)}return e=a.next(0),a=null,e}return Promise.resolve({done:!0,value:null})};return"asyncIterator"in Symbol?{[Symbol.asyncIterator](){return this},next:()=>new Promise((e=>e(s()))).catch((t=>{_r(e,t)}))}:{next:()=>new Promise((e=>e(s())))};case 14:return t.O().map((e=>mp(e,r).next(0).value));default:return(t=t.O()).every((e=>T(e.type,53)&&!T(e.type,47)))?(t=t.map((e=>Ur(e.value,r,!1))),1===t.length?t[0]:t):1===t.length?T((t=t[0]).type,62)?pp(t,r).next(0).value:T(t.type,61)?dp(t,r).next(0).value:nt(t,r).first().value:rt($.create(t),r).O().map((e=>e.value))}}fp[fp.ANY]="ANY",fp[fp.NUMBER]="NUMBER",fp[fp.STRING]="STRING",fp[fp.BOOLEAN]="BOOLEAN",fp[fp.NODES]="NODES",fp[fp.FIRST_NODE]="FIRST_NODE",fp[fp.STRINGS]="STRINGS",fp[fp.MAP]="MAP",fp[fp.ARRAY]="ARRAY",fp[fp.NUMBERS]="NUMBERS",fp[fp.ALL_RESULTS]="ALL_RESULTS",fp[fp.ASYNC_ITERATOR]="ASYNC_ITERATOR";let yp=!1,wp=null;var vp={getPerformanceSummary(){const e=wp.getEntriesByType("measure").filter((e=>e.name.startsWith("XPath: ")));return Array.from(e.reduce(((e,t)=>{var n=t.name.substring(7);return e.has(n)?((n=e.get(n)).times+=1,n.totalDuration+=t.duration):e.set(n,{xpath:n,times:1,totalDuration:t.duration,average:0}),e}),new Map).values()).map((e=>(e.average=e.totalDuration/e.times,e))).sort(((e,t)=>t.totalDuration-e.totalDuration))},setPerformanceImplementation(e){wp=e},startProfiling(){if(null===wp)throw Error("Performance API object must be set using `profiler.setPerformanceImplementation` before starting to profile");wp.clearMarks(),wp.clearMeasures(),yp=!0},stopProfiling(){yp=!1}};let xp=0;const bp=(e,t,n,r,a,o)=>{if(a=a||0,!e||"string"!=typeof e&&!("nodeType"in e))throw new TypeError("Failed to execute 'evaluateXPath': xpathExpression must be a string or an element depicting an XQueryX DOM tree.");let s,i;o=o||{};try{const a=hp(e,t,n||null,r||{},o,{ra:"XQueryUpdate3.1"===o.language,Z:"XQuery3.1"===o.language||"XQueryUpdate3.1"===o.language,debug:!!o.debug,Ga:!!o.disableCache});var l=a.rb;s=a.sb,i=a.ba}catch(t){_r(e,t)}if(i.J)throw Error("XUST0001: Updating expressions should be evaluated as updating expressions");if(3===a&&t&&"object"==typeof t&&"nodeType"in t&&(n=i.D(),t=X(t),null!==n&&!t.includes(n)))return!1;try{t=e,yp&&("string"!=typeof t&&(t=Hr(t)),wp.mark(`${t}${0===xp?"":"@"+xp}`),xp++);const n=gp(e,Jn(i,l,s),a,s);return a=e,yp&&("string"!=typeof a&&(a=Hr(a)),xp--,l=`${a}${0===xp?"":"@"+xp}`,wp.measure(`XPath: ${a}`,l),wp.clearMarks(l)),n}catch(t){_r(e,t)}};function Ap(e,t,n,r,a){return bp(e,t,n,r,bp.Jb,a)}function Ep(e,t,n,r){return{pendingUpdateList:e.da.map((e=>e.h(r))),xdmValue:gp(t,$.create(e.I),n,r)}}function Np(e,t,n){return{code:e,ta:t,H:n,isAstAccepted:!0}}function Tp(e){return{isAstAccepted:!1,reason:e}}function Bp(e,t){return e.isAstAccepted?t(e):e}function Ip(e,t){return e.isAstAccepted?t(e):[e,null]}function Cp(e,t,n){return Bp(e,(e=>{switch(e.ta.type){case 0:return e;case 1:return Bp(lm(n,e,"nodes"),(e=>Bp(lm(n,t,"contextItem"),(t=>Np(`(function () {\n\t\t\t\t\t\t\tconst { done, value } = ${e.code}(${t.code}).next();\n\t\t\t\t\t\t\treturn done ? null : value;\n\t\t\t\t\t\t})()`,{type:0},[...e.H,...t.H])))));default:throw Error(`invalid generated code type to convert to value: ${e.ta.type}`)}}))}function Op(e,t,n,r){return e=Cp(e,n,r),t&&0===t.type&&3===t.g?e:Bp(e,(e=>Np(`!!${e.code}`,{type:0},e.H)))}function Sp(e,t,n){return t?e.isAstAccepted&&0!==e.ta.type?Tp("Atomization only implemented for single value"):T(t.type,1)?e:T(t.type,47)?Bp(lm(n,e,"attr"),(e=>Np(`(${e.code} ? domFacade.getData(${e.code}) : null)`,{type:0},e.H))):Tp("Atomization only implemented for string and attribute"):Tp("Can not atomize value if type was not annotated")}function Fp(e,t,n,r){return r=Sp(e=Cp(e,n,r),t,r),lt(t)?Bp(r,(e=>Np(`${e.code} ?? ''`,{type:0},e.H))):r}function Dp(e,t,n){return Bp(lm(n,e,"node"),(e=>1===e.ta.type?e:t&&!T(t.type,53)?Tp("Can not evaluate to node if expression does not result in nodes"):Np(`(function () {\n\t\t\t\tif (${e.code} !== null && !${e.code}.nodeType) {\n\t\t\t\t\tthrow new Error('XPDY0050: The result of the expression was not a node');\n\t\t\t\t}\n\t\t\t\treturn ${e.code};\n\t\t\t})()`,{type:0},e.H)))}function kp(e,t){return Bp(e,(e=>Bp(t,(t=>{if(0!==e.ta.type||0!==t.ta.type)throw Error("can only use emitAnd with value expressions");return Np(`${e.code} && ${t.code}`,{type:0},[...e.H,...t.H])}))))}function Rp(e,t,n,r){return(e=va(e,[t,"*"]))?r.h(e,n,r):[Tp(`${t} expression not found`),null]}Object.assign(bp,{hc:14,ANY_TYPE:0,Ib:12,Jb:99,BOOLEAN_TYPE:3,Lb:9,Ob:11,Qb:7,Rb:13,NUMBER_TYPE:1,Sb:10,STRING_TYPE:2,ic:"XPath3.1",jc:"XQuery3.1",Vb:"XQueryUpdate3.1"}),Object.assign(bp,{ALL_RESULTS_TYPE:14,ANY_TYPE:0,ARRAY_TYPE:12,ASYNC_ITERATOR_TYPE:99,BOOLEAN_TYPE:3,FIRST_NODE_TYPE:9,MAP_TYPE:11,NODES_TYPE:7,NUMBERS_TYPE:13,NUMBER_TYPE:1,STRINGS_TYPE:10,STRING_TYPE:2,XPATH_3_1_LANGUAGE:"XPath3.1",XQUERY_3_1_LANGUAGE:"XQuery3.1",XQUERY_UPDATE_3_1_LANGUAGE:"XQueryUpdate3.1"});const Mp={equalOp:"eqOp",notEqualOp:"neOp",lessThanOrEqualOp:"leOp",lessThanOp:"ltOp",greaterThanOrEqualOp:"geOp",greaterThanOp:"gtOp"},Up={eqOp:"eqOp",neOp:"neOp",leOp:"geOp",ltOp:"gtOp",geOp:"leOp",gtOp:"ltOp"};function Gp(e,t,n,r){const a=wa(va(e,["firstOperand","*"]),"type"),o=wa(va(e,["secondOperand","*"]),"type");if(!a||!o)return Tp("Can not generate code for value compare without both types");var s=[47,1];if(!s.includes(a.type)||!s.includes(o.type))return Tp(`Unsupported types in compare: [${C[a.type]}, ${C[o.type]}]`);if(!(s=new Map([["eqOp","==="],["neOp","!=="]])).has(t))return Tp(t+" not yet implemented");const i=s.get(t);return[t]=Rp(e,"firstOperand",n,r),t=Sp(t=Cp(t,n,r),a,r),Bp(lm(r,t,"first"),(t=>{var[s]=Rp(e,"secondOperand",n,r);return s=Sp(s=Cp(s,n,r),o,r),Bp(lm(r,s,"second"),(e=>{const n=[];return lt(a)&&n.push(`${t.code} === null`),lt(o)&&n.push(`${e.code} === null`),Np(`(${n.length?`${n.join(" || ")} ? null : `:""}${t.code} ${i} ${e.code})`,{type:0},[...t.H,...e.H])}))}))}function $p(e,t,n,r,a,o){var s=wa(va(e,[t,"*"]),"type");const i=wa(va(e,[n,"*"]),"type");if(!s||!i)return Tp("Can not generate code for general compare without both types");var l=[47,1];if(!l.includes(s.type)||!l.includes(i.type))return Tp(`Unsupported types in compare: [${C[s.type]}, ${C[i.type]}]`);if(!(l=new Map([["eqOp","==="],["neOp","!=="]])).has(r))return Tp(r+" not yet implemented");const c=l.get(r);return[t]=Rp(e,t,a,o),s=Sp(t=Cp(t,a,o),s,o),Bp(lm(o,s,"single"),(t=>{const[r]=Rp(e,n,a,o);return Bp(lm(o,r,"multiple"),(e=>{if(1!==e.ta.type)return Tp("can only generate general compare for a single value and a generator");const n=um(o,cm(o,"n")),r=Sp(n,i,o);return Bp(a,(a=>Bp(r,(r=>Np(`(function () {\n\t\t\t\t\t\t\t\t\tfor (const ${n.code} of ${e.code}(${a.code})) {\n\t\t\t\t\t\t\t\t\t\t${r.H.join("\n")}\n\t\t\t\t\t\t\t\t\t\tif (${r.code} ${c} ${t.code}) {\n\t\t\t\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t})()`,{type:0},[...t.H,...n.H,...a.H,...e.H])))))}))}))}function Lp(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}const Pp={"false#0":function(){return Np("false",{type:0},[])},"local-name#0":Vp,"local-name#1":Vp,"name#0":qp,"name#1":qp,"not#1":function(e,t,n){var r=va(e,["arguments","*"]);return e=wa(r,"type"),[r]=n.h(r,t,n),Bp(t=Op(r,e,t,n),(e=>Np(`!${e.code}`,{type:0},e.H)))},"true#0":function(){return Np("true",{type:0},[])}},Hp={"http://fontoxml.com/fontoxpath":["version#0"],"":["root#1","path#1"]};function jp(e,t,n,r){if(e.length!==t.length||t.some((e=>4===e)))return Tp("Not supported: variadic function or mismatch in argument count");if(0===e.length)return Np("",{type:0},[]);const[a,...o]=e,[s,...i]=t;return e=lm(r,function(e,t,n,r){const[a]=r.h(e,n,r);if(e=wa(e,"type"),!t||2===t.g||1===t.g)return Tp("Not supported: sequence arguments with multiple items");if(T(t.type,53))return Dp(t=Cp(a,n,r),e,r);switch(t.type){case 59:return Cp(a,n,r);case 0:return Op(a,e,n,r);case 1:return Fp(a,e,n,r)}return Tp(`Argument types not supported: ${e?C[e.type]:"unknown"} -> ${C[t.type]}`)}(a,s,n,r),"arg"),0===o.length?e:Bp(e,(e=>Bp(jp(o,i,n,r),(t=>Np(`${e.code}, ${t.code}`,{type:0},[...e.H,...t.H])))))}function _p(e,t,n){const{localName:r,namespaceURI:a}=ba(ga(e,"functionName")),o=xa(ga(e,"arguments"),"*");var s=o.length;const i=`${r}#${s}`,l=a===n.D;if(l){const r=Pp[i];if(void 0!==r)return r(e,t,n)}return(e=Hp[l?"":a])&&!e.includes(i)?Tp(`Not supported: built-in function not on allow list: ${i}`):(s=Yr(a,r,s))?s.J?Tp("Not supported: updating functions"):(t=Bp(t=jp(o,s.j,t,n),(e=>Np(`runtimeLib.callFunction(domFacade, ${Lp(a)}, ${Lp(r)}, [${e.code}], options)`,{type:0},e.H))),function(e,t){return Bp(e,(e=>t&&2!==t.g&&1!==t.g&&([0,1].includes(t.type)||T(t.type,53))?e:Tp(`Function return type ${C[t.type]} not supported`)))}(t,s.i)):Tp(`Unknown function / arity: ${i}`)}function Xp(e,t,n,r){if((e=va(e,["arguments","*"]))&&"contextItemExpr"!==e[0]){const r=wa(e,"type");if(!r||!T(r.type,53))return Tp("name function only implemented if arg is a node");[e]=n.h(e,t,n)}else e=function(e,t){return Bp(lm(t,e,"contextItem"),(e=>Np(e.code,{type:0},[...e.H,`if (${e.code} === undefined || ${e.code} === null) {\n\t\t\t\t\tthrow errXPDY0002('The function which was called depends on dynamic context, which is absent.');\n\t\t\t\t}`])))}(t,n);return Bp(lm(n,t=Cp(e,t,n),"arg"),(e=>Np(`(${e.code} ? ${r(e.code)} : '')`,{type:0},e.H)))}function qp(e,t,n){return Xp(e,t,n,(e=>`(((${e}.prefix || '').length !== 0 ? ${e}.prefix + ':' : '')\n\t\t+ (${e}.localName || ${e}.target || ''))`))}function Vp(e,t,n){return Xp(e,t,n,(e=>`(${e}.localName || ${e}.target || '')`))}function Yp(e,t,n,r){const[a,o]=Rp(e,"firstOperand",n,r);var s=wa(va(e,["firstOperand","*"]),"type");s=Op(a,s,n,r);const[i,l]=Rp(e,"secondOperand",n,r);s=Bp(s,(a=>{var o=wa(va(e,["secondOperand","*"]),"type");return Bp(o=Op(i,o,n,r),(e=>Np(`(${a.code} ${t} ${e.code})`,{type:0},[...a.H,...e.H])))}));return[s,"&&"===t?Za(o,l):o===l?o:null]}function zp(e,t,n){return Bp(e,(e=>Bp(t,(t=>Bp(n,(n=>Np(`for (${e.code}) {\n\t\t\t\t\t\t${t.H.join("\n")}\n\t\t\t\t\t\tif (!(${t.code})) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t${n.H.join("\n")}\n\t\t\t\t\t\t${n.code}\n\t\t\t\t\t}`,{type:2},e.H)))))))}function Jp(e,t,n,r,a){const o=t?`, "${t}"`:"";return t=Bp(r,(e=>Bp(a,(t=>Np(`let ${e.code} = domFacade.getFirstChild(${t.code}${o});\n\t\t\t\t\t\t\t${e.code};\n\t\t\t\t\t\t\t${e.code} = domFacade.getNextSibling(${e.code}${o})`,{type:2},[...e.H,...t.H]))))),zp(t,e,n)}function Qp(e,t,n,r,a){const o=Za(t,"type-2"),s=Bp(a,(e=>Np(`(${e.code} && ${e.code}.nodeType === /*ELEMENT_NODE*/ 1 ? domFacade.getAllAttributes(${e.code}${o?`, "${o}"`:""}) : [])`,{type:0},e.H)));return t=Bp(r,(e=>Bp(s,(t=>Np(`const ${e.code} of ${t.code}`,{type:2},[...e.H,...t.H]))))),zp(t,e,n)}function Kp(e,t,n,r,a){const o=t?`, "${t}"`:"";return t=Bp(a,(e=>Np(`domFacade.getParentNode(${e.code}${o})`,{type:0},e.H))),Wp(r,t,e,n)}function Wp(e,t,n,r){const a=kp(e,n);return Bp(e,(e=>Bp(t,(t=>Bp(a,(n=>Bp(r,(r=>Np(`const ${e.code} = ${t.code};\n\t\t\t\t\t\t${n.H.join("\n")}\n\t\t\t\t\t\tif (${n.code}) {\n\t\t\t\t\t\t\t${r.H.join("\n")}\n\t\t\t\t\t\t\t${r.code}\n\t\t\t\t\t\t}`,{type:2},[...e.H,...t.H])))))))))}const Zp={Tb:"textTest",Kb:"elementTest",Pb:"nameTest",Ub:"Wildcard",Hb:"anyKindTest"};var em=Object.values(Zp);function tm(e,t,n,r){!function(e,t){if(null===e.namespaceURI&&"*"!==e.prefix){if(!(t=t.$(e.prefix||"")||null)&&e.prefix)throw Error(`XPST0081: The prefix ${e.prefix} could not be resolved.`);e.namespaceURI=t}}(e,r);const a=e.prefix,o=e.namespaceURI,s=e.localName;return Ip(n,(e=>{var n=Np(t?`${e.code}.nodeType\n\t\t\t\t\t\t&& (${e.code}.nodeType === /*ELEMENT_NODE*/ 1\n\t\t\t\t\t\t|| ${e.code}.nodeType === /*ATTRIBUTE_NODE*/ 2)`:`${e.code}.nodeType\n\t\t\t\t\t\t&& ${e.code}.nodeType === /*ELEMENT_NODE*/ 1`,{type:0},[]);if("*"===a)return"*"===s?[n,t?"type-1-or-type-2":"type-1"]:[kp(n,Np(`${e.code}.localName === ${Lp(s)}`,{type:0},[])),`name-${s}`];n="*"===s?n:kp(n,Np(`${e.code}.localName === ${Lp(s)}`,{type:0},[]));var r=Np(Lp(o),{type:0},[]);return r=""===a&&t?Bp(r,(t=>Np(`${e.code}.nodeType === /*ELEMENT_NODE*/ 1 ? ${t.code} : null`,{type:0},t.H))):r,r=Bp(r,(t=>Np(`(${e.code}.namespaceURI || null) === ((${t.code}) || null)`,{type:0},t.H))),[kp(n,r),`name-${s}`]}))}function nm(e,t,n,r){var a=e[0];switch(a){case Zp.Kb:return function(e,t,n){const r=(e=ga(e,"elementName"))&&ga(e,"star");return null===e||r?[Bp(t,(e=>Np(`${e.code}.nodeType === /*ELEMENT_NODE*/ 1`,{type:0},[]))),"type-1"]:tm(e=ba(ga(e,"QName")),!1,t,n)}(e,n,r);case Zp.Tb:return function(e){return[Bp(e,(e=>Np(`(${e.code}.nodeType === /*TEXT_NODE*/ 3 ||\n\t\t\t\t${e.code}.nodeType === /* CDATA_SECTION_NODE */ 4)`,{type:0},[]))),"type-3"]}(n);case Zp.Pb:return tm(ba(e),t,n,r);case Zp.Ub:return ga(e,"star")?null!==(a=ga(e,"uri"))?e=tm({localName:"*",namespaceURI:ya(a),prefix:""},t,n,r):(a=ga(e,"NCName"),e="star"===ga(e,"*")[0]?tm({localName:ya(a),namespaceURI:null,prefix:"*"},t,n,r):tm({localName:"*",namespaceURI:null,prefix:ya(a)},t,n,r)):e=tm({localName:"*",namespaceURI:null,prefix:"*"},t,n,r),e;case Zp.Hb:return function(e){return[Bp(e,(e=>Np(`!!${e.code}.nodeType`,{type:0},[]))),null]}(n);default:return[Tp(`Test not implemented: '${a}`),null]}}function rm(e,t,n){const[r,a]=n.h(e,t,n);return[Op(r,wa(e,"type"),t,n),a]}function am(e,t,n){e=e?xa(e,"*"):[];const[r,a]=e.reduce((([e,r],a)=>{if(!e)return rm(a,t,n);let o=r;return Ip(e,(e=>{const[s,i]=rm(a,t,n);return o=Za(r,i),[Bp(s,(t=>Np(`${e.code} && ${t.code}`,{type:0},[...e.H,...t.H]))),o]}))}),[null,null]);return[r?Bp(r,(e=>Np(`(function () {\n\t\t\t\t\t\t\t${e.H.join("\n")}\n\t\t\t\t\t\t\treturn ${e.code};\n\t\t\t\t\t\t})()`,{type:0},[]))):null,a]}function om(e,t,n,r){if(0===e.length)return[Bp(n,(e=>Np(`yield ${e.code};`,{type:2},e.H))),null];const[a,...o]=e;if(0<xa(a,"lookup").length)return[Tp("Unsupported: lookups"),null];const s=um(r,cm(r,"contextItem"));e=ga(a,"predicates");const[i,l]=am(e,s,r);if(e=ga(a,"xpathAxis")){var c=ga(a,em);if(!c)return[Tp("Unsupported test in step"),null];var u=ya(e);t="attribute"===u||"self"===u&&t;const[h,d]=nm(c,t,s,r);return c=null===i?h:kp(h,i),u=Za(d,l),[t]=om(o,t,s,r),function(e,t,n,r,a,o){switch(e=ya(e)){case"attribute":return[Qp(t,n,r,a,o),"type-1"];case"child":return[Jp(t,n,r,a,o),null];case"parent":return[Kp(t,n,r,a,o),null];case"self":return[Wp(a,o,t,r),n];default:return[Tp(`Unsupported: the ${e} axis`),null]}}(e,c,u,t,s,n)}if(!(e=va(a,["filterExpr","*"])))return[Tp("Unsupported: unknown step type"),null];const[h,d]=r.h(e,n,r);return[Bp(h,(e=>{const t=0===o.length?Np("",{type:2},[]):Np(`if (${s.code} !== null && !${s.code}.nodeType) {\n\t\t\t\t\t\t\t\t\tthrow new Error('XPTY0019: The result of E1 in a path expression E1/E2 should evaluate to a sequence of nodes.');\n\t\t\t\t\t\t\t\t}`,{type:2},[]),[a]=om(o,!0,s,r),l=null===i?a:Bp(i,(e=>Bp(a,(t=>Np(`if (${e.code}) {\n\t\t\t\t\t\t\t\t\t${t.H.join("\n")}\n\t\t\t\t\t\t\t\t\t${t.code}\n\t\t\t\t\t\t\t\t}`,{type:2},e.H)))));return Bp(l,(r=>{switch(e.ta.type){case 1:return Bp(n,(n=>Np(`for (const ${s.code} of ${e.code}(${n.code})) {\n\t\t\t\t\t\t\t\t\t${r.H.join("\n")}\n\t\t\t\t\t\t\t\t\t${r.code}\n\t\t\t\t\t\t\t\t}`,{type:2},[...s.H,...e.H,...t.H])));case 0:return Np(`const ${s.code} = ${e.code};\n\t\t\t\t\t\t\t${t.code}\n\t\t\t\t\t\t\tif (${s.code} !== null) {\n\t\t\t\t\t\t\t\t${r.H.join("\n")}\n\t\t\t\t\t\t\t\t${r.code}\n\t\t\t\t\t\t\t}`,{type:2},[...s.H,...e.H,...t.H]);default:return Tp("Unsupported generated code type for filterExpr")}}))})),d]}function sm(e,t,n){const r=xa(e,"stepExpr");if(1===r.length){const e=ga(r[0],"xpathAxis");if(e&&"self"===ya(e))return function(e,t,n){return Ip(t,(t=>{if(0<xa(e,"lookup").length)return[Tp("Unsupported: lookups"),null];var r=ga(e,"predicates");const[a,o]=am(r,t,n);if(!(r=ga(e,em)))return[Tp("Unsupported test in step"),null];const[s,i]=nm(r,!0,t,n);r=null===a?s:kp(s,a);const l=Za(i,o);return[Bp(r,(e=>Np(`((${e.code}) ? ${t.code} : null)`,{type:0},[...t.H,...e.H]))),l]}))}(r[0],t,n)}const a=um(n,cm(n,"contextItem"));t=(e=ga(e,"rootExpr"))?lm(n,function(e){return Bp(e,(e=>Np(`(function () {\n\t\t\t\tlet n = ${e.code};\n\t\t\t\twhile (n.nodeType !== /*DOCUMENT_NODE*/9) {\n\t\t\t\t\tn = domFacade.getParentNode(n);\n\t\t\t\t\tif (n === null) {\n\t\t\t\t\t\tthrow new Error('XPDY0050: the root node of the context node is not a document node.');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn n;\n\t\t\t})()`,{type:0},e.H)))}(a),"root"):a;const[o,s]=om(r,!e,t,n);return[Bp(o,(e=>Np(`(function* (${a.code}) {\n\t\t\t${e.H.join("\n")}\n\t\t\t${e.code}\n\t\t})`,{type:1},[]))),s]}function im(e,t,n){const r=e[0];switch(r){case"contextItemExpr":return[t,null];case"pathExpr":return sm(e,t,n);case"andOp":return Yp(e,"&&",t,n);case"orOp":return Yp(e,"||",t,n);case"stringConstantExpr":return[Np(e=Lp(e=ga(e,"value")[1]||""),{type:0},[]),null];case"equalOp":case"notEqualOp":case"lessThanOrEqualOp":case"lessThanOp":case"greaterThanOrEqualOp":case"greaterThanOp":case"eqOp":case"neOp":case"ltOp":case"leOp":case"gtOp":case"geOp":case"isOp":case"nodeBeforeOp":case"nodeAfterOp":e:switch(r){case"eqOp":case"neOp":case"ltOp":case"leOp":case"gtOp":case"geOp":case"isOp":e=Gp(e,r,t,n);break e;case"equalOp":case"notEqualOp":case"lessThanOrEqualOp":case"lessThanOp":case"greaterThanOrEqualOp":case"greaterThanOp":const a=wa(va(e,["firstOperand","*"]),"type"),o=wa(va(e,["secondOperand","*"]),"type");e=a&&o?3===a.g&&3===o.g?Gp(e,Mp[r],t,n):3===a.g?$p(e,"firstOperand","secondOperand",Mp[r],t,n):3===o.g?$p(e,"secondOperand","firstOperand",Up[Mp[r]],t,n):Tp("General comparison for sequences is not implemented"):Tp("types of compare are not known");break e;default:e=Tp(`Unsupported compare type: ${r}`)}return[e,null];case"functionCallExpr":return[_p(e,t,n),null];default:return[Tp(`Unsupported: the base expression '${r}'.`),null]}}function lm(e,t,n){return Bp(t,(t=>{var r=e.o.get(t);return r||(r=Np(r=cm(e,n),t.ta,[...t.H,`const ${r} = ${t.code};`]),e.o.set(t,r),e.o.set(r,r)),r}))}function cm(e,t="v"){const n=e.v.get(t)||0;return e.v.set(t,n+1),`${t}${n}`}function um(e,t){return t=Np(t,{type:0},[]),e.o.set(t,t),t}function hm(e){const t=xa(e,"*");if("pathExpr"===e[0])return!0;for(const e of t)if(hm(e))return!0;return!1}class dm extends Error{constructor(e,t,n){var r=e.stack;r&&(r.includes(e.message)&&(r=r.substr(r.indexOf(e.message)+e.message.length).trim()),(r=r.split("\n")).splice(10),r=r.map((e=>e.startsWith(" ")||e.startsWith("\t")?e:` ${e}`)),r=r.join("\n")),super(`Custom XPath function Q{${n}}${t} raised:\n${e.message}\n${r}`)}}function pm(e,t,n){return 0===t.g?e.G()?null:mp(e.first(),n).next(0).value:2===t.g||1===t.g?e.O().map((e=>{if(T(e.type,47))throw Error("Cannot pass attribute nodes to custom functions");return mp(e,n).next(0).value})):mp(e.first(),n).next(0).value}var mm={callFunction(e,t,n,r,a){const o=Yr(t,n,r.length);if(!o)throw Error("function not found for codegen function call");t=new ze({M:null,Aa:0,sa:$.empty(),qa:{}});const s=new oe(e);return e=new Je(!1,!1,s,null,null,a?a.currentContext:null,null),r=o.callFunction(t,e,null,...r.map(((e,t)=>Pe(0,e,o.j[t])))),pm(r,{type:59,g:0},e)},errXPDY0002:We};const fm={"http://www.w3.org/2005/XQueryX":"xqx","http://www.w3.org/2007/xquery-update-10":"xquf","http://fontoxml.com/fontoxpath":"x"};function gm(e,t,n,r,a){if("string"==typeof n)return 0===n.length?null:t.createTextNode(n);if(!Array.isArray(n))throw new TypeError("JsonML element should be an array or string");var o=function(e,t){switch(e){case"copySource":case"insertAfter":case"insertAsFirst":case"insertAsLast":case"insertBefore":case"insertInto":case"modifyExpr":case"newNameExpr":case"replacementExpr":case"replaceValue":case"returnExpr":case"sourceExpr":case"targetExpr":case"transformCopies":case"transformCopy":return{localName:e,kb:t||"http://www.w3.org/2005/XQueryX"};case"deleteExpr":case"insertExpr":case"renameExpr":case"replaceExpr":case"transformExpr":return{localName:e,kb:"http://www.w3.org/2007/xquery-update-10"};case"x:stackTrace":return{localName:"stackTrace",kb:"http://fontoxml.com/fontoxpath"};default:return{localName:e,kb:"http://www.w3.org/2005/XQueryX"}}}(n[0],r);r=o.localName,o=o.kb;const s=t.createElementNS(o,fm[o]+":"+r),i=n[1];var l=1;if("object"==typeof i&&!Array.isArray(i)){if(null!==i)for(var c of Object.keys(i))null!==(l=i[c])&&("type"===c?void 0!==l&&e.setAttributeNS(s,o,"fontoxpath:"+c,S(l)):("start"!==c&&"end"!==c||"stackTrace"!==r||(l=JSON.stringify(l)),a&&"prefix"===c&&""===l||e.setAttributeNS(s,o,fm[o]+":"+c,l)));l=2}for(let r=l,i=n.length;r<i;++r)c=gm(e,t,n[r],o,a),null!==c&&e.insertBefore(s,c,null);return s}const ym=new Map;function wm(e){var t;e:{if(t=hi.get(e))for(const e of Object.keys(t))if(t[e]&&t[e].length){t=t[e][0].h;break e}t=null}if(t)return t;if(ym.has(e))return ym.get(e);if(null===(t=va(t="string"==typeof e?Xd(e,{Z:!1}):mi(e),["mainModule","queryBody","*"])))throw Error("Library modules do not have a specificity");return t=ui(t,{ra:!1,Z:!1}),ym.set(e,t),t}var vm=new q;return void 0!==n&&(n.compareSpecificity=function(e,t){return hr(wm(e).o,wm(t).o)},n.compileXPathToJavaScript=function(e,t,n){if(n=n||{},t=t||0,"string"==typeof e){e=vi(e);var r={Z:"XQuery3.1"===n.language||"XQueryUpdate3.1"===n.language,debug:!1};try{var a=Xd(e,r)}catch(t){_r(e,t)}}else a=mi(e);if(!(e=ga(a,"mainModule")))return Tp("Unsupported: XQuery Library modules are not supported.");if(ga(e,"prolog"))return Tp("Unsupported: XQuery Prologs are not supported.");if(r=void 0===n.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":n.defaultFunctionNamespaceURI,e=new class{constructor(e,t){this.o=new Map,this.v=new Map,this.$=e,this.D=t,this.h=im}}(n.namespaceResolver||cp(null),r),Ga(a,n=new Ya(new fa(new Qr(e.$,{},r,n.functionNameResolver||up("http://www.w3.org/2005/xpath-functions"))))),n=ga(a,"mainModule"))if(ga(n,"prolog"))e=Tp("Unsupported: XQuery.");else{var o=va(n,["queryBody","*"]);n=um(e,"contextItem"),[r]=e.h(o,n,e);e:switch(o=wa(o,"type"),t){case 9:e=Dp(t=Cp(r,n,e),o,e);break e;case 7:e=function(e,t,n,r){return Bp(e,(e=>{switch(e.ta.type){case 1:return Bp(lm(r,e,"nodes"),(e=>Bp(lm(r,n,"contextItem"),(t=>Np(`Array.from(${e.code}(${t.code}))`,{type:0},[...e.H,...t.H])))));case 0:return Bp(lm(r,Dp(e,t,r),"node"),(e=>Np(`(${e.code} === null ? [] : [${e.code}])`,{type:0},e.H)));default:return Tp("Unsupported code type to evaluate to nodes")}}))}(r,o,n,e);break e;case 3:e=Op(r,o,n,e);break e;case 2:e=Fp(r,o,n,e);break e;default:e=Tp(`Unsupported: the return type '${t}'.`)}e.isAstAccepted&&(e=`\n\t\t${e.H.join("\n")}\n\t\treturn ${e.code};`,t="\n\treturn (contextItem, domFacade, runtimeLib, options) => {\n\t\tconst {\n\t\t\terrXPDY0002,\n\t\t} = runtimeLib;",hm(a)&&(t+='\n\t\tif (!contextItem) {\n\t\t\tthrow errXPDY0002("Context is needed to evaluate the given path expression.");\n\t\t}\n\n\t\tif (!contextItem.nodeType) {\n\t\t\tthrow new Error("Context item must be subtype of node().");\n\t\t}\n\t\t'),e={code:t+(e+"}\n//# sourceURL=generated.js"),isAstAccepted:!0})}else e=Tp("Unsupported: Can not execute a library module.");return e},n.domFacade=vm,n.evaluateXPath=bp,n.evaluateXPathToArray=function(e,t,n,r,a){return bp(e,t,n,r,bp.Ib,a)},n.evaluateXPathToAsyncIterator=Ap,n.evaluateXPathToBoolean=function(e,t,n,r,a){return bp(e,t,n,r,bp.BOOLEAN_TYPE,a)},n.evaluateXPathToFirstNode=function(e,t,n,r,a){return bp(e,t,n,r,bp.Lb,a)},n.evaluateXPathToMap=function(e,t,n,r,a){return bp(e,t,n,r,bp.Ob,a)},n.evaluateXPathToNodes=function(e,t,n,r,a){return bp(e,t,n,r,bp.Qb,a)},n.evaluateXPathToNumber=function(e,t,n,r,a){return bp(e,t,n,r,bp.NUMBER_TYPE,a)},n.evaluateXPathToNumbers=function(e,t,n,r,a){return bp(e,t,n,r,bp.Rb,a)},n.evaluateXPathToString=function(e,t,n,r,a){return bp(e,t,n,r,bp.STRING_TYPE,a)},n.evaluateXPathToStrings=function(e,t,n,r,a){return bp(e,t,n,r,bp.Sb,a)},n.evaluateUpdatingExpression=async function(e,t,n,r,a){let o,s,i;a=a||{},wi();try{const i=hp(e,t,n||null,r||{},a||{},{ra:!0,Z:!0,debug:!!a.debug,Ga:!!a.disableCache});var l=i.rb;o=i.sb,s=i.ba}catch(t){_r(e,t)}if(!s.J){for(l=[],e=Ap(e,t,n,r,Object.assign(Object.assign({},a),{language:"XQueryUpdate3.1"})),t=await e.next();!t.done;t=await e.next())l.push(t.value);return Promise.resolve({pendingUpdateList:[],xdmValue:l})}try{i=s.s(l,o).next(0)}catch(t){_r(e,t)}return Ep(i.value,e,a.returnType,o)},n.evaluateUpdatingExpressionSync=function(e,t,n,r,a){let o,s,i,l;a=a||{},wi();try{const l=hp(e,t,n||null,r||{},a||{},{ra:!0,Z:!0,debug:!!a.debug,Ga:!!a.disableCache});o=l.rb,s=l.sb,i=l.ba}catch(t){_r(e,t)}if(!i.J)return{pendingUpdateList:[],xdmValue:bp(e,t,n,r,a.i,Object.assign(Object.assign({},a),{language:bp.Vb}))};try{l=i.s(o,s).next(0)}catch(t){_r(e,t)}return Ep(l.value,e,a.returnType,s)},n.executeJavaScriptCompiledXPath=(e,t,n,r)=>(n=n||new q,e()(null!=t?t:null,n,mm,r)),n.executePendingUpdateList=function(e,t,n,r){t=new oe(t||new q),r=r?new Y(r):V,n=n?n=new ip(n):null,e=e.map(_s),nr(e,t,n,r)},n.getBucketForSelector=function(e){return wm(e).D()},n.getBucketsForNode=X,n.precompileXPath=function(e){return Promise.resolve(e)},n.registerXQueryModule=function(e,t={debug:!1}){if(Ua(t=Xd(e,{Z:!0,debug:t.debug}),new Ya),!(t=ga(t,"libraryModule")))throw Error("XQuery module must be declared in a library module.");var n=ga(t,"moduleDecl"),r=ga(n,"uri");const a=ya(r);if(r=ya(n=ga(n,"prefix")),ha(n=new fa(new Qr((()=>null),Object.create(null),"http://www.w3.org/2005/xpath-functions",up("http://www.w3.org/2005/xpath-functions"))),r,a),null!==(t=ga(t,"prolog"))){let r;try{r=Vd(t,n,!0,e)}catch(t){_r(e,t)}r.Ha.forEach((({namespaceURI:e})=>{if(a!==e)throw Error("XQST0048: Functions and variables declared in a module must reside in the module target namespace.")})),gi(a,r)}else gi(a,{Ha:[],Ta:[],oa:null,source:e});return a},n.registerCustomXPathFunction=function(e,t,n,r){const{namespaceURI:a,localName:o}=function(e){if("object"==typeof e)return e;if(2!==(e=e.split(":")).length)throw Error("Do not register custom functions in the default function namespace");const[t,n]=e;if(!(e=Jr[t])){if(e=`generated_namespace_uri_${t}`,Jr[t])throw Error("Prefix already registered: Do not register the same prefix twice.");Jr[t]=e}return{localName:n,namespaceURI:e}}(e);if(!a)throw ta();const s=t.map((e=>D(e))),i=D(n);zr(a,o,s,i,(function(e,t,n){var l=Array.from(arguments);l.splice(0,3),l=l.map(((e,n)=>pm(e,s[n],t)));const c={currentContext:t.o,domFacade:t.h.h};let u;try{u=r.apply(void 0,[c,...l])}catch(e){throw new dm(e,o,a)}return u&&"object"==typeof u&&Object.getOwnPropertySymbols(u).includes(lp)?$.create(u.xb):Pe(t.h,u,i)}))},n.parseScript=function(e,t,n,r=V){let a;e=vi(e);try{a=Xd(e,{Z:"XQuery3.1"===t.language||"XQueryUpdate3.1"===t.language,debug:t.debug})}catch(t){_r(e,t)}var o=new Qr(t.namespaceResolver||(()=>null),{},void 0===t.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":t.defaultFunctionNamespaceURI,t.functionNameResolver||(()=>null));o=new fa(o);var s=ga(a,["mainModule","libraryModule"]),i=ga(s,"moduleDecl");if(i){ha(o,ya(ga(i,"prefix")),i=ya(ga(i,"uri")))}return(s=ga(s,"prolog"))&&Vd(s,o,!1,e),!1!==t.annotateAst&&Ua(a,new Ya(o)),o=new q,t=gm(r,n,a,null,!1===t.kc),r.insertBefore(t,n.createComment(e),o.getFirstChild(t)),t},n.profiler=vp,n.createTypedValueFactory=function(e){return(t,n)=>(t=Le(new oe(null===n?new q:n),t,D(e)),{[lp]:!0,xb:t})},n.finalizeModuleRegistration=wi,n.Language={XPATH_3_1_LANGUAGE:"XPath3.1",XQUERY_3_1_LANGUAGE:"XQuery3.1",XQUERY_UPDATE_3_1_LANGUAGE:"XQueryUpdate3.1"},n.ReturnType=fp),n}.call("undefined"==typeof window?void 0:window,Ae,Pe);He.compareSpecificity,He.compileXPathToJavaScript;const je=He.createTypedValueFactory;He.domFacade,He.evaluateUpdatingExpression,He.evaluateUpdatingExpressionSync;const _e=He.evaluateXPath;He.evaluateXPathToArray,He.evaluateXPathToAsyncIterator;const Xe=He.evaluateXPathToBoolean,qe=He.evaluateXPathToFirstNode;He.evaluateXPathToMap;const Ve=He.evaluateXPathToNodes,Ye=He.evaluateXPathToNumber;He.evaluateXPathToNumbers;const ze=He.evaluateXPathToString,Je=He.evaluateXPathToStrings;He.executeJavaScriptCompiledXPath,He.executePendingUpdateList,He.finalizeModuleRegistration,He.getBucketForSelector;const Qe=He.getBucketsForNode;He.Language;const Ke=He.parseScript;He.precompileXPath,He.profiler;const We=He.registerCustomXPathFunction,Ze=He.registerXQueryModule;He.ReturnType;class et{constructor(e){this._onNodeTouched=e}getAllAttributes(e){return Array.from(e.attributes)}getAttribute(e,t){return e.getAttribute(t)}getChildNodes(e,t){const n=Array.from(e.childNodes).filter((e=>!t||Qe(e).includes(t)));return n.forEach((e=>this._onNodeTouched(e))),n}getData(e){return e.nodeType===Node.ATTRIBUTE_NODE?(this._onNodeTouched(e),e.value):(this._onNodeTouched(e.parentNode),e.data)}getFirstChild(e,t){for(const n of e.childNodes)if(!t||Qe(n).includes(t))return this._onNodeTouched(n),n;return null}getLastChild(e,t){const n=e.getChildNodes().filter((e=>!t||Qe(e).includes(t))),r=n[n.length-1];return r||null}getNextSibling(e,t){for(let n=e.nextSibling;n;n=n.nextSibling)if(!t||Qe(n).includes(t))return this._onNodeTouched(n),n;return null}getParentNode(e){return e.parentNode}getPreviousSibling(e,t){for(let{previousSibling:n}=e;n;n=n.previousSibling)if(!t||Qe(n).includes(t))return n;return null}}class tt{static contains(e,t){for(;t;){if(t===e)return!0;t=t.nodeType===Node.DOCUMENT_FRAGMENT_NODE?t.host:t.parentNode}return!1}static getClosest(e,t){for(;t&&!t.matches||!t.matches(e);)if(t.nodeType!==Node.DOCUMENT_FRAGMENT_NODE)if(t.nodeType!==Node.ATTRIBUTE_NODE){if(t.nodeType===Node.TEXT_NODE&&(t=t.parentNode),t.matches("fx-fore"))return null;if(!(t=t.parentNode))return null}else t=t.ownerElement;else t=t.host;return t}static getParentBindingElement(e){return!e.parentNode||e.parentNode.nodeType===Node.DOCUMENT_NODE&&e.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE?null:e.parentNode.closest("[ref]")}static isAbsolutePath(e){return null!=e&&(e.startsWith("/")||e.startsWith("instance("))}static isSelfReference(e){return"."===e||"./text()"===e||"text()"===e||""===e||null===e}static getInstanceId(e){if(!e)return"default";if(e.startsWith("instance()"))return"default";if(e.startsWith("instance(")){const t=e.substring(e.indexOf("(")+1);return t.substring(1,t.indexOf(")")-1)}return null}static resolveInstance(e,t){let n=tt.getInstanceId(t);if(n||(n=tt.getInstanceId(e.getAttribute("ref"))),null!==n)return n;const r=tt.getParentBindingElement(e);return r?this.resolveInstance(r,t):"default"}static getDocPath(e){const t=ze("path()",e),n=tt.shortenPath(t);return n.startsWith("/")?`${n}`:`/${n}`}static getPath(e,t){const n=ze("path()",e),r=tt.shortenPath(n);return r.startsWith("/")?`$${t}${r}`:`$${t}/${r}`}static shortenPath(e){const t=e.replaceAll(/(Q{(.*?)\})/g,""),n=t.substring(1,t.length);return n.substring(n.indexOf("/"),t.length)}static getBasePath(e){return e.split(":")[0]}}function nt(e,t,n,r){const a={};return function(o){if(a[o])return;const s={},i=[],l=[];for(l.push({node:o,processed:!1});l.length>0;){const o=l[l.length-1],{processed:c}=o,{node:u}=o;if(c)l.pop(),i.pop(),s[u]=!1,a[u]=!0,t&&0!==e[u].length||n.push(u);else{if(a[u]){l.pop();continue}if(s[u]){if(r){l.pop();continue}throw i.push(u),window.dispatchEvent(new CustomEvent("compute-exception",{composed:!1,bubbles:!0,detail:{path:i,message:"cyclic graph"}})),new Error(`Cyclic at ${i}`)}s[u]=!0,i.push(u);const t=e[u];for(let e=t.length-1;e>=0;e-=1)l.push({node:t[e],processed:!1});o.processed=!0}}}}function rt(e){this.nodes={},this.outgoingEdges={},this.incomingEdges={},this.circular=e&&!!e.circular}function at(e){const t=(new DOMParser).parseFromString(e,"application/xml"),n=(new DOMParser).parseFromString(['<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">',' <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>',' <xsl:strip-space elements="*"/>',' <xsl:template match="text()">',' <xsl:value-of select="normalize-space(.)"/>'," </xsl:template>",' <xsl:template match="node()|@*">'," <xsl:copy>",' <xsl:apply-templates select="node()|@*"/>'," </xsl:copy>"," </xsl:template>","</xsl:stylesheet>"].join("\n"),"application/xml"),r=new XSLTProcessor;r.importStylesheet(n);const a=r.transformToDocument(t);return(new XMLSerializer).serializeToString(a)}rt.prototype={size(){return Object.keys(this.nodes).length},addNode(e,t){this.hasNode(e)||(this.nodes[e]=2===arguments.length?t:e,this.outgoingEdges[e]=[],this.incomingEdges[e]=[])},removeNode(e){this.hasNode(e)&&(delete this.nodes[e],delete this.outgoingEdges[e],delete this.incomingEdges[e],[this.incomingEdges,this.outgoingEdges].forEach((t=>{Object.keys(t).forEach((n=>{const r=t[n].indexOf(e);r>=0&&t[n].splice(r,1)}),this)})))},hasNode(e){return Object.prototype.hasOwnProperty.call(this.nodes,e)},getNodeData(e){if(this.hasNode(e))return this.nodes[e];throw new Error(`Node does not exist: ${e}`)},setNodeData(e,t){if(!this.hasNode(e))throw new Error(`Node does not exist: ${e}`);this.nodes[e]=t},addDependency(e,t){if(!this.hasNode(e))throw new Error(`Node does not exist: ${e}`);if(!this.hasNode(t))throw new Error(`Node does not exist: ${t}`);return-1===this.outgoingEdges[e].indexOf(t)&&this.outgoingEdges[e].push(t),-1===this.incomingEdges[t].indexOf(e)&&this.incomingEdges[t].push(e),!0},removeDependency(e,t){let n;this.hasNode(e)&&(n=this.outgoingEdges[e].indexOf(t),n>=0&&this.outgoingEdges[e].splice(n,1)),this.hasNode(t)&&(n=this.incomingEdges[t].indexOf(e),n>=0&&this.incomingEdges[t].splice(n,1))},clone(){const e=this,t=new rt;return Object.keys(e.nodes).forEach((n=>{t.nodes[n]=e.nodes[n],t.outgoingEdges[n]=e.outgoingEdges[n].slice(0),t.incomingEdges[n]=e.incomingEdges[n].slice(0)})),t},directDependenciesOf(e){if(this.hasNode(e))return this.outgoingEdges[e].slice(0);throw new Error(`Node does not exist: ${e}`)},directDependantsOf(e){if(this.hasNode(e))return this.incomingEdges[e].slice(0);throw new Error(`Node does not exist: ${e}`)},dependenciesOf(e,t){if(this.hasNode(e)){const n=[];nt(this.outgoingEdges,t,n,this.circular)(e);const r=n.indexOf(e);return r>=0&&n.splice(r,1),n}throw new Error(`Node does not exist: ${e}`)},dependantsOf(e,t){if(this.hasNode(e)){const n=[];nt(this.incomingEdges,t,n,this.circular)(e);const r=n.indexOf(e);return r>=0&&n.splice(r,1),n}throw new Error(`Node does not exist: ${e}`)},entryNodes(){const e=this;return Object.keys(this.nodes).filter((t=>0===e.incomingEdges[t].length))},overallOrder(e){const t=this,n=[],r=Object.keys(this.nodes);if(0===r.length)return n;if(!this.circular){const e=nt(this.outgoingEdges,!1,[],this.circular);r.forEach((t=>{e(t)}))}const a=nt(this.outgoingEdges,e,n,this.circular);return r.filter((e=>0===t.incomingEdges[e].length)).forEach((e=>{a(e)})),this.circular&&r.filter((e=>-1===n.indexOf(e))).forEach((e=>a(e))),n}},rt.prototype.directDependentsOf=rt.prototype.directDependantsOf,rt.prototype.dependentsOf=rt.prototype.dependantsOf;const ot="http://www.w3.org/2002/xforms",st=new Map,it=[];function lt(e,t,n){return st.has(e)?st.get(e).set(t,n):st.set(e,new Map)}const ct=e=>{if(!e)return"http://www.w3.org/1999/xhtml"};function ut(e,t,n=null){t.nodeType===Node.TEXT_NODE&&(t=t.parentNode),t.nodeType===Node.ATTRIBUTE_NODE&&(t=t.ownerElement),t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&(t=t.parentNode.host);const r=("fx-fore"===t.localName?t:t.closest("fx-fore")).querySelectorAll(`[id='${e}']`);if(1===r.length){const e=r[0];return n&&e.localName!==n?null:e}const a=Ve("outermost(ancestor-or-self::fx-fore[1]/(descendant::fx-fore|descendant::*[@id = $id]))[not(self::fx-fore)]",t,null,{id:e},{namespaceResolver:ct});if(0===a.length)return null;if(1===a.length&&Xe("(ancestor::fx-fore | ancestor::fx-repeat)[last()]/self::fx-fore",a[0],null,null,{namespaceResolver:ct})){const e=a[0];return n&&e.localName!==n?null:e}for(const e of Ve("ancestor::fx-repeatitem => reverse()",t,null,null,{namespaceResolver:ct})){const t=a.filter((t=>tt.contains(e,t)));switch(t.length){case 0:break;case 1:{const e=t[0];return n&&e.localName!==n?null:e}default:{const e=t.find((e=>Ve("every $ancestor of ancestor::fx-repeatitem satisfies $ancestor is $ancestor/../child::fx-repeatitem[../@repeat-index]",e,null,{})));return e?n&&e.localName!==n?null:e:null}}}return null}const ht=(new DOMParser).parseFromString("<xml />","text/xml"),dt=new Map;function pt(e,t){const n=function(e,t){return st.has(e)&&st.get(e).get(t)||null}(e,t);if(n)return n;let r=function(e){if(!e.includes("instance"))return[];if(dt.has(e))return dt.get(e);const t=Ke(e,{},ht),n=Je('descendant::xqx:functionCallExpr\n\t\t\t\t[xqx:functionName = "instance"]\n\t\t\t\t/xqx:arguments\n\t\t\t\t/xqx:stringConstantExpr\n\t\t\t\t/xqx:value',t,null,{},{namespaceResolver:e=>"xqx"===e?"http://www.w3.org/2005/XQueryX":void 0});return dt.set(e,n),n}(e);if(0===r.length){const n=t.parentNode&&t.parentNode.nodeType===t.ELEMENT&&t.parentNode.closest("[ref]");if(n){const r=pt(n.getAttribute("ref"),n);return lt(e,t,r),r}r=["default"]}if(1===r.length){let n;if("default"===r[0]){const e=qe("ancestor-or-self::fx-fore[1]",t,null,null,{namespaceResolver:ct});n=e&&e.querySelector("fx-instance")}else n=ut(r[0],t,"fx-instance");if(n&&n.hasAttribute("xpath-default-namespace")){const r=n.getAttribute("xpath-default-namespace"),a=e=>{if(!e)return r};return lt(e,t,a),a}}r.length>1&&console.warn(`More than one instance is used in the query "${e}". The default namespace resolving will be used`);const a=ze("ancestor-or-self::*/@xpath-default-namespace[last()]",t)||"",o=function(e){return""===e?a:ze('ancestor-or-self::*/@*[name() = "xmlns:" || $prefix][last()]',t,null,{prefix:e})};return lt(e,t,o),o}function mt(e,t,n){return(t&&t.ownerDocument||t)===window.document?ct:pt(e,n)}function ft({prefix:e,localName:t},n){switch(t){case"context":case"base64encode":case"boolean-from-string":case"current":case"depends":case"event":case"fore-attr":case"index":case"instance":case"json2xml":case"xml2Json":case"log":case"parse":case"local-date":case"local-dateTime":case"logtree":case"uri":case"uri-fragment":case"uri-host":case"uri-param":case"uri-path":case"uri-relpath":case"uri-port":case"uri-query":case"uri-scheme":case"uri-scheme-specific-part":return{namespaceURI:ot,localName:t};default:return""===e&&it.includes(t)?{namespaceURI:"http://www.w3.org/2005/xquery-local-functions",localName:t}:"fn"===e||""===e?{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:t}:"local"===e?{namespaceURI:"http://www.w3.org/2005/xquery-local-functions",localName:t}:null}}function gt(e){let t=e;for(;t&&!("inScopeVariables"in t);)t=t.parentNode;if(!t)return{};const n={};if(t.inScopeVariables)for(const e of t.inScopeVariables.keys()){const r=t.inScopeVariables.get(e);r&&(r.nodeType?n[e]=r.value:n[e]=r)}return n}function yt(e,t,n,r={},a={}){try{const o=mt(e,t,n),s=gt(n);return _e(e,t,null,{...s,...r},_e.ALL_RESULTS_TYPE,{debug:!0,currentContext:{formElement:n,variables:r},moduleImports:{xf:ot},functionNameResolver:ft,namespaceResolver:o,language:a.language||yt.XPATH_3_1})}catch(t){return n.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,detail:{origin:n,message:`Expression '${e}' failed`,expr:e,level:"Error"}})),!1}}function wt(e,t,n){try{const r=mt(e,t,n),a=gt(n);return qe(e,t,null,a,{defaultFunctionNamespaceURI:ot,moduleImports:{xf:ot},currentContext:{formElement:n},functionNameResolver:ft,namespaceResolver:r})}catch(t){n.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,detail:{origin:n,message:`Expression '${e}' failed`,expr:e,level:"Error"}}))}}function vt(e,t,n){try{const r=mt(e,t,n),a=gt(n);return Ve(e,t,null,a,{currentContext:{formElement:n},functionNameResolver:ft,moduleImports:{xf:ot},namespaceResolver:r})}catch(t){n.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,detail:{origin:n,message:`Expression '${e}' failed`,expr:e,level:"Error"}}))}}function xt(e,t,n){try{const r=mt(e,t,n),a=gt(n);return Xe(e,t,null,a,{currentContext:{formElement:n},functionNameResolver:ft,moduleImports:{xf:ot},namespaceResolver:r})}catch(t){n.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,detail:{origin:n,message:`Expression '${e}' failed`,expr:e,level:"Error"}}))}}function bt(e,t,n,r=null,a=n){try{const a=mt(e,t,n),o=gt(n);return ze(e,t,r,o,{currentContext:{formElement:n},functionNameResolver:ft,moduleImports:{xf:ot},namespaceResolver:a})}catch(t){n.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,detail:{origin:n,message:`Expression '${e}' failed`,expr:e,level:"Error"}}))}}function At(e,t,n,r=null,a=n){try{const a=mt(e,t,n),o=gt(n);return Ye(e,t,r,o,{currentContext:{formElement:n},functionNameResolver:ft,moduleImports:{xf:ot},namespaceResolver:a})}catch(t){n.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,detail:{origin:n,message:`Expression '${e}' failed`,expr:e,level:"Error"}}))}}const Et=(e,t)=>{const n=e.currentContext.formElement;let r=null;if(r=t?ut(t,n):tt.getParentBindingElement(n),r){if("FX-REPEAT"===r.nodeName){const{nodeset:e}=r;for(let t=n;t;t=t.parentNode)if(t.parentNode===r){return e[Array.from(t.parentNode.children).indexOf(t)]}}return r.nodeset}return n.getInScopeContext()};function Nt(e,t){if(t&&t.nodeType===Node.ELEMENT_NODE&&t.children){const n=document.createElement("details");n.setAttribute("data-path",t.nodeName);const r=document.createElement("summary");let a,o=` <${t.nodeName}`;Array.from(t.attributes).forEach((e=>{o+=` ${e.nodeName}="${e.nodeValue}"`})),t.firstChild&&t.firstChild.nodeType===Node.TEXT_NODE&&""!==t.firstChild.data.trim()?(a=t.firstChild.nodeValue,o+=`>${a}</${t.nodeName}>`):o+=">",r.textContent=o,n.appendChild(r),0!==t.childElementCount?n.setAttribute("open","open"):r.setAttribute("style","list-style:none;"),e.appendChild(n),Array.from(t.children).forEach((e=>{Nt(n,e)}))}}We({namespaceURI:ot,localName:"context"},[],"item()?",Et),We({namespaceURI:ot,localName:"context"},["xs:string"],"item()?",Et),We({namespaceURI:ot,localName:"current"},["xs:string"],"item()?",((e,t)=>(e.currentContext.formElement,null))),We({namespaceURI:ot,localName:"element"},["xs:string"],"item()?",((e,t)=>{e.currentContext.formElement;return document.createElement(t)})),We({namespaceURI:ot,localName:"log"},["xs:string?"],"xs:string?",((e,t)=>{const{formElement:n}=e.currentContext,r=ut(t,n,"fx-instance");if(r){if("json"!==r.getAttribute("type")){return at((new XMLSerializer).serializeToString(r.getDefaultContext()))}console.warn("log() does not work for JSON yet")}return null})),We({namespaceURI:ot,localName:"fore-attr"},["xs:string?"],"xs:string?",((e,t)=>{const{formElement:n}=e.currentContext;let r=n;n.nodeType===Node.TEXT_NODE&&(r=n.parentNode);const a=r.closest("fx-fore");return a.hasAttribute(t)?a.getAttribute(t):null})),We({namespaceURI:ot,localName:"parse"},["xs:string?"],"element()?",((e,t)=>{const n=(new DOMParser).parseFromString(t,"application/xml");return console.log("parse",n),n.firstElementChild})),We({namespaceURI:ot,localName:"logtree"},["xs:string?"],"element()?",((e,t)=>{const{formElement:n}=e.currentContext,r=ut(t,n,"fx-instance");if(r){const t=document.createElement("div");t.setAttribute("class","logtree");const n=e.currentContext.formElement,a=n.querySelector(".logtree");a&&a.parentNode.removeChild(a);const o=Nt(t,r.getDefaultContext());o&&n.appendChild(o)}return null}));const Tt=(e,t)=>{const n=qe("ancestor-or-self::fx-fore[1]",e.currentContext.formElement,null,null,{namespaceResolver:ct});let r=null;null===t||"default"===t?r=n.getModel().getDefaultInstance():(r=n.getModel().getInstance(t),r||document.querySelector("fx-fore").dispatchEvent(new CustomEvent("error",{composed:!0,bubbles:!0,detail:{origin:"functions",message:`Instance not found '${localName}'`,level:"Error"}})));const a=r.getDefaultContext();return a||null};We({namespaceURI:ot,localName:"index"},["xs:string?"],"xs:integer?",((e,t)=>{const{formElement:n}=e.currentContext;if(null===t)return 1;const r=ut(t,n,"fx-repeat");return r?r.getAttribute("index"):Number(1)})),We({namespaceURI:ot,localName:"instance"},[],"item()?",(e=>Tt(e,null))),We({namespaceURI:ot,localName:"instance"},["xs:string?"],"item()?",Tt);We({namespaceURI:ot,localName:"json2xml"},["item()?"],"item()?",((e,t)=>{const n=(e,t)=>{const r=typeof e;if("number"===r)t.setAttribute("type","number"),t.textContent=e.toString();else if("boolean"===r)t.setAttribute("type","boolean"),t.textContent=e.toString();else if(null===e){const e=document.createElement("_");e.setAttribute("type","null"),t.appendChild(e)}else"string"===r?t.textContent=e.replace(/[^\u0009\u000A\u000D\u0020-\uD7FF\uE000-\uFFFD]/g,(e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`)):Array.isArray(e)?(t.setAttribute("type","array"),e.forEach((e=>{const r=document.createElement("_");n(e,r),r.textContent=e,t.appendChild(r)}))):"object"===r&&(t.setAttribute("type","object"),Object.entries(e).forEach((([e,r])=>{if(r){const a=document.createElement(e.replace(/[^a-zA-Z0-9_]/g,"_"));n(r,a),t.appendChild(a)}})))},r=document.createElement("json");return Array.isArray(t)?r.setAttribute("type","array"):r.setAttribute("type","object"),n(t,r),console.log("xml",r),r}));function Bt(e,t){const n=t.split(".");return 1==n.length?e[n[0]]:Bt(e[n[0]],n.slice(1).join("."))}function It(e){return e.closest("fx-fore")}function Ct(e,t){const n=tt.getClosest("[ref]",e),r=tt.getClosest("fx-fore",e),a=function(e){return It(e).getModel()}(e);if(null!==n){return r===n.closest("fx-fore")?n.nodeset:a.getDefaultInstance().getDefaultContext()}if(tt.isAbsolutePath(t)){const e=tt.getInstanceId(t);return e?a.getInstance(e).getDefaultContext():a.getDefaultInstance().getDefaultContext()}return a.getDefaultInstance().getDefaultContext()}function Ot(e,t){const n=function(e){return e&&e.nodeType&&e.nodeType===Node.ATTRIBUTE_NODE?e.ownerElement:e.nodeType===Node.ELEMENT_NODE?e:e.parentNode}(e);if("FX-FORE"===n.nodeName){const e=n.getModel().getDefaultInstance()?.getDefaultContext();return e||Ot(n.parentNode,t)}const r=tt.getClosest("[ref]",n.parentNode);if(r&&("FX-GROUP"===r.nodeName||"FX-CONTROL"===r.nodeName))return r.nodeset;const a=n.matches("[iterate]")?n:tt.getClosest("[iterate]",n.parentNode);if(a&&a.currentContext)return a.currentContext;const o=tt.getClosest("fx-repeatitem",n);if(o)return"context"===e.nodeName?wt(e.nodeValue,o.nodeset,It(n)):o.nodeset;const s=n.closest(".fx-repeatitem");if(s){const e=s.parentNode,t=Array.from(e.children).indexOf(s);return tt.getClosest("fx-repeat-attributes",n).nodeset[t]}if(n.hasAttribute("context")){const e=Ct(n.parentNode,t);return wt(n.getAttribute("context"),e,It(n))}if(e.nodeType===Node.ATTRIBUTE_NODE&&"context"===e.nodeName){const r=Ct(e.ownerElement.parentNode,t);return wt(e.ownerElement.getAttribute("context"),r,It(n))}if(e.nodeType===Node.ATTRIBUTE_NODE&&"ref"===e.nodeName){if(e.ownerElement.hasAttribute("context")){const r=Ct(e.ownerElement.parentNode,t);return wt(e.ownerElement.getAttribute("context"),r,It(n))}return Ct(n.parentNode,t)}return Ct(n,t)}We({namespaceURI:ot,localName:"xmltoJson"},["item()?"],"item()?",((e,t)=>{const n=e=>e.nodeType===Node.TEXT_NODE,r=e=>{if((e=>e.nodeType===Node.ELEMENT_NODE)(e)){const t={};if(e.hasAttributes()&&(t.type=e.getAttribute("type")),1===e.childNodes.length&&n(e.firstChild))return e.textContent;for(const n of e.childNodes){const e=n.nodeName,a=r(n);t[e]?(Array.isArray(t[e])||(t[e]=[t[e]]),t[e].push(a)):t[e]=a}return t}if(n(e))return e.textContent},a=(new DOMParser).parseFromString(t,"application/xml").documentElement;return r(a)})),We({namespaceURI:ot,localName:"depends"},["node()*"],"item()?",((e,t)=>t[0])),We({namespaceURI:ot,localName:"event"},["xs:string?"],"item()?",((e,t)=>{if(!t)return null;for(let n=e.currentContext.formElement;n;n=n.parentNode)if(n.currentEvent)return n.currentEvent.detail&&"object"==typeof n.currentEvent.detail&&t in n.currentEvent.detail?n.currentEvent.detail[t]:t.includes(".")?Bt(n.currentEvent,t):n.currentEvent[t]||null;return null})),Ze(`\n module namespace xf="${ot}";\n\n declare %public function xf:boolean-from-string($str as xs:string) as xs:boolean {\n lower-case($str) = "true" or $str = "1"\n };\n`),We({namespaceURI:ot,localName:"base64encode"},["xs:string?"],"xs:string?",((e,t)=>btoa(t))),We({namespaceURI:ot,localName:"local-date"},[],"xs:string?",((e,t)=>(new Date).toLocaleDateString())),We({namespaceURI:ot,localName:"local-dateTime"},[],"xs:string?",((e,t)=>(new Date).toLocaleString())),We({namespaceURI:ot,localName:"uri"},[],"xs:string?",((e,t)=>window.location.href)),We({namespaceURI:ot,localName:"uri-fragment"},[],"xs:string?",((e,t)=>window.location.hash)),We({namespaceURI:ot,localName:"uri-host"},[],"xs:string?",((e,t)=>window.location.host)),We({namespaceURI:ot,localName:"uri-query"},[],"xs:string?",((e,t)=>window.location.search)),We({namespaceURI:ot,localName:"uri-relpath"},[],"xs:string?",((e,t)=>{const n=new URL(window.location.href).pathname;return n.substring(0,n.lastIndexOf("/")+1)})),We({namespaceURI:ot,localName:"uri-path"},[],"xs:string?",((e,t)=>new URL(window.location.href).pathname)),We({namespaceURI:ot,localName:"uri-port"},[],"xs:string?",((e,t)=>window.location.port)),We({namespaceURI:ot,localName:"uri-param"},["xs:string?"],"xs:string?",((e,t)=>{if(!t)return null;const n=window.location.search,r=new URLSearchParams(n).get(t);return r||""})),We({namespaceURI:ot,localName:"uri-scheme"},[],"xs:string?",((e,t)=>new URL(window.location.href).protocol)),We({namespaceURI:ot,localName:"uri-scheme-specific-part"},[],"xs:string?",((e,t)=>{const n=window.location.href;return n.substring(n.indexOf(":")+1,n.length)}));class St{static async loadHtml(e){try{const t=await fetch(e,{method:"GET",mode:"cors",credentials:"same-origin",headers:{"Content-Type":"text/html"}}),n=t.headers.get("content-type").toLowerCase();if(n.startsWith("text/html"))return t.text();St.dispatch(this,"error",{message:`Response has wrong contentType '${n}'. Should be 'text/html'`,level:"Error"})}catch(t){St.dispatch(this,"error",{message:`Html couldn't be loaded from '${e}'`,level:"Error"})}}static async loadForeFromSrc(e,t,n){t||St.dispatch(this,"error",{detail:{message:"No 'src' attribute present"}}),await St.loadHtml(t).then((r=>{const a=(new DOMParser).parseFromString(r,"text/html").querySelector(n);a||St.dispatch(this,"error",{detail:{message:`Fore element not found in '${t}'. Maybe wrapped within 'template' element?`}}),a.setAttribute("from-src",t);const o=e.attributes;return Array.from(o).forEach((e=>{"src"!==e.name&&a.setAttribute(e.name,e.value)})),e.replaceWith(a),a}))}static buildPredicates(e){let t="";return Array.from(e.attributes).forEach((e=>{t+=`[@${e.nodeName}]`})),t}static isWidget(e){if(e?.classList.contains("widget"))return!0;let t=e.parentNode;for(;t&&"FX-CONTROL"!==t.nodeName;){if(t?.classList?.contains("widget"))return!0;t=t.parentNode}return!1}static getDomNodeIndexString(e){const t=[];let n=e;for(;n&&n.parentNode;){const e=n.parentNode;if(e.childNodes&&e.childNodes.length>0){const r=[...e.childNodes].indexOf(n);t.unshift(r)}n=e}return t.join(".")}static getExpression(e){return e.startsWith("{")&&e.endsWith("}")?e.substring(1,e.length-1):e}static getFore(e){return e.nodeType===Node.TEXT_NODE?e.parentNode.closest("fx-fore"):e.closest("fx-fore")}static get ACTION_ELEMENTS(){return["FX-ACTION","FX-DELETE","FX-DISPATCH","FX-HIDE","FX-INSERT","FX-LOAD","FX-MESSAGE","FX-REBUILD","FX-RECALCULATE","FX-REFRESH","FX-RENEW","FX-RELOAD","FX-REPLACE","FX-RESET","FX-RETAIN","FX-RETURN","FX-REVALIDATE","FX-SEND","FX-SETFOCUS","FX-SETINDEX","FX-SETVALUE","FX-SHOW","FX-TOGGLE","FX-UPDATE"]}static createUUID(){const e=[],t="0123456789abcdef";for(let n=0;n<36;n+=1)e[n]=t.substr(Math.floor(16*Math.random()),1);e[14]="4",e[19]=t.substr(3&e[19]|8,1),e[8]=e[13]=e[18]=e[23]="-";return e.join("")}static get XFORMS_NAMESPACE_URI(){return"http://www.w3.org/2002/xforms"}static isActionElement(e){return St.ACTION_ELEMENTS.includes(e)}static get UI_ELEMENTS(){return["FX-ALERT","FX-CONTROL","FX-DIALOG","FX-FILENAME","FX-MEDIATYPE","FX-GROUP","FX-HINT","FX-ITEMS","FX-OUTPUT","FX-RANGE","FX-REPEAT","FX-REPEATITEM","FX-REPEAT-ATTRIBUTES","FX-SWITCH","FX-SECRET","FX-SELECT","FX-SUBMIT","FX-TEXTAREA","FX-TRIGGER","FX-UPLOAD","FX-VAR"]}static get MODEL_ELEMENTS(){return["FX-BIND","FX-FUNCTION","FX-MODEL","FX-INSTANCE","FX-SUBMISSION"]}static isUiElement(e){return St.UI_ELEMENTS.includes(e),St.UI_ELEMENTS.includes(e)}static async refreshChildren(e,t){return new Promise((n=>{const{children:r}=e;r&&Array.from(r).forEach((e=>{"FX-FORE"!==e.nodeName.toUpperCase()?St.isUiElement(e.nodeName)&&"function"==typeof e.refresh?e.refresh(t):"FX-MODEL"!==e.nodeName.toUpperCase()&&St.refreshChildren(e,t):n("done")})),n("done")}))}static copyDom(e){console.time("convert");const t=(new DOMParser).parseFromString("<fx-fore></fx-fore>","text/html");console.log("copyDom new doc",t),console.log("copyDom new body",t.body),console.log("copyDom new body",t.querySelector("fx-fore"));const n=t.querySelector("fx-fore");return this.convertFromSimple(e,n),n.removeAttribute("convert"),console.log("converted",n),console.timeEnd("convert"),n}static convertFromSimple(e,t){const n=e.childNodes;n&&Array.from(n).forEach((e=>{const n=`FX-${e.nodeName.toUpperCase()}`;if(St.MODEL_ELEMENTS.includes(n)||St.UI_ELEMENTS.includes(n)||St.ACTION_ELEMENTS.includes(n)){const r=t.ownerDocument.createElement(n);console.log("conv",e,r),t.appendChild(r),St.copyAttributes(e,r),St.convertFromSimple(e,r)}else{if(e.nodeType===Node.TEXT_NODE){const n=t.ownerDocument.createTextNode(e.textContent);t.appendChild(n)}if(e.nodeType===Node.ELEMENT_NODE){const n=t.ownerDocument.createElement(e.nodeName);t.appendChild(n),St.copyAttributes(e,t),St.convertFromSimple(e,n)}}}))}static copyAttributes(e,t){return Array.from(e.attributes).forEach((e=>{t.setAttribute(e.nodeName,e.nodeValue)}))}static getContentType(e,t){return"application/x-www-form-urlencoded"===t?"application/x-www-form-urlencoded; charset=UTF-8":"xml"===e.type?"application/xml; charset=UTF-8":"json"===e.type?"application/json":(console.warn("content-type unknown ",e.type),null)}static async handleResponse(e){const{status:t}=e;if(t>=400)throw alert(`response status: ${t} - failed to load data for '${this.src}' - stopping.`),new Error(`failed to load data - status: ${t}`);const n=e.headers.get("content-type").toLowerCase();if(n.startsWith("text/html"))return e.text().then((e=>(new DOMParser).parseFromString(e,"text/html")));if(n.startsWith("text/plain")||n.startsWith("text/markdown"))return e.text();if(n.startsWith("application/json"))return e.json();if(n.startsWith("application/xml")){const t=await e.text();return(new DOMParser).parseFromString(t,"application/xml")}return"done"}static fadeInElement(e){let t=()=>(e.getAnimations&&e.getAnimations().map((e=>e.finish())),t=e.animate({opacity:[0,1]},600),t.finished);return t()}static fadeOutElement(e,t){let n=()=>(e.getAnimations&&e.getAnimations().map((e=>e.finish())),n=e.animate({opacity:[1,0]},t),n.finished);return n()}static async dispatch(e,t,n){if(!tt.contains(e?.ownerDocument,e))return;const r=new CustomEvent(t,{composed:!1,bubbles:!0,detail:n});r.listenerPromises=[],e.dispatchEvent(r),r.listenerPromises.length&&await Promise.all(r.listenerPromises)}static formatXml(e){for(var t=(e=e.replace(/(>)(<)(\/*)/g,"$1\n$2$3").replace(/ *(.*) +\n/g,"$1\n").replace(/(<.+>)(.+\n)/g,"$1\n$2")).split("\n"),n=0;n<t.length;n++){var r=t[n];Boolean(r.match(/<.+\/>/)),Boolean(r.match(/<\/.+>/)),Boolean(r.match(/<[^!].*>/))}}static stringifiedComponent(e){return`<${e.localName} ${Array.from(e.attributes).map((e=>`${e.name}="${e.value}"`)).join(" ")}>…</${e.localName}>`}}St.READONLY_DEFAULT=!1,St.REQUIRED_DEFAULT=!1,St.RELEVANT_DEFAULT=!0,St.CONSTRAINT_DEFAULT=!0,St.TYPE_DEFAULT="xs:string";class Ft extends HTMLElement{constructor(){super(),this.model=this.parentNode,this.attachShadow({mode:"open"}),this.originalInstance=null,this.partialInstance=null,this.credentials=""}connectedCallback(){this.hasAttribute("src")&&(this.src=this.getAttribute("src")),this.hasAttribute("id")?this.id=this.getAttribute("id"):this.id="default",this.credentials=this.hasAttribute("credentials")?this.getAttribute("credentials"):"same-origin",["same-origin","include","omit"].includes(this.credentials)||console.error(`fx-submission: the value of credentials is not valid. Expected 'same-origin', 'include' or 'omit' but got '${this.credentials}'`,this),this.hasAttribute("type")?this.type=this.getAttribute("type"):(this.type="xml",this.setAttribute("type",this.type));this.shadowRoot.innerHTML="\n <style>\n \n :host {\n display: none;\n }\n :host * {\n display:none;\n }\n ::slotted(*){\n display:none;\n }\n \n </style>\n \n \n ",this.partialInstance={}}async init(){return await this._initInstance(),console.log(`### <<<<< instance ${this.id} loaded >>>>> `),this.dispatchEvent(new CustomEvent("instance-loaded",{composed:!0,bubbles:!0,detail:{instance:this}})),this}reset(){this.instanceData=this.originalInstance.cloneNode(!0)}evalXPath(e){const t=this.parentElement.parentElement;return wt(e,this.getDefaultContext(),t)}getInstanceData(){return this.instanceData||this.createInstanceData(),this.instanceData}setInstanceData(e){e?this._setInitialData(e):this.createInstanceData()}getDefaultContext(){const e=this.getInstanceData();return"xml"===this.type?e.firstElementChild:e}async _initInstance(){if("#querystring"===this.src){const e=new URLSearchParams(location.search),t=(new DOMParser).parseFromString("<data></data>","application/xml"),n=t.firstElementChild;for(const r of e){const e=t.createElement(r[0]);e.appendChild(t.createTextNode(r[1])),n.appendChild(e)}this._setInitialData(t)}else this.src?await this._loadData():0!==this.childNodes.length&&this._useInlineData()}createInstanceData(){if("xml"===this.type){const e=(new DOMParser).parseFromString("<data></data>","application/xml");this.instanceData=e,this.originalInstance=this.instanceData.cloneNode(!0)}"json"===this.type&&(this.instanceData={},this.originalInstance=[...this.instanceData]),"text"===this.type&&(this.instanceData="",this.originalInstance="")}async _loadData(){const e=`${this.src}`;if(e.startsWith("localStore")){const t=e.substring(e.indexOf(":")+1),n=(new DOMParser).parseFromString("<data></data>","application/xml");if(this.instanceData=n,!t)return void console.warn("no key specified for localStore");const r=localStorage.getItem(t);if(!r)return console.warn(`Data for key ${t} cannot be found`),void this._useInlineData();const a=(new DOMParser).parseFromString(r,"application/xml");return void n.firstElementChild.replaceWith(a.firstElementChild)}const t=St.getContentType(this,"get");try{const n=await fetch(e,{method:"GET",credentials:this.credentials,mode:"cors",headers:{"Content-Type":t}}),r=await async function(e){const{status:t}=e;if(t>=400)throw alert(`response status: ${t} - failed to load data for '${this.src}' - stopping.`),new Error(`failed to load data - status: ${t}`);const n=e.headers.get("content-type").toLowerCase();if(n.startsWith("text/html"))return e.text().then((e=>(new DOMParser).parseFromString(e,"text/html")));if(n.startsWith("text/"))return e.text();if(n.startsWith("application/json"))return e.json();if(n.startsWith("application/xml")||n.startsWith("text/xml")){const t=await e.text();return(new DOMParser).parseFromString(t,"application/xml")}throw new Error(`unable to handle response content type: ${n}`)}(n);this._setInitialData(r)}catch(e){throw new Error(`failed loading data ${e}`)}}_setInitialData(e){this.instanceData=e,e.nodeType?this.originalInstance=this.instanceData.cloneNode(!0):this.originalInstance={...this.instanceData}}_getContentType(){return"xml"===this.type?"application/xml":"json"===this.type?"application/json":(console.warn("content-type unknown ",this.type),null)}_useInlineData(){if("xml"===this.type){const e=(new DOMParser).parseFromString(this.innerHTML,"application/xml");this._setInitialData(e)}else"json"===this.type?this._setInitialData(JSON.parse(this.textContent)):"html"===this.type?this._setInitialData(this.firstElementChild.children):"text"===this.type?this._setInitialData(this.textContent):console.warn("unknow type for data ",this.type)}}customElements.get("fx-instance")||customElements.define("fx-instance",Ft);class Dt{constructor(e,t,n,r,a,o,s,i,l){this.path=e,this.ref=t,this.constraint=o,this.readonly=n,this.relevant=r,this.required=a,this.type=s,this.node=i,this.bind=l,this.changed=!1,this.alerts=[],this.boundControls=[]}get value(){return this.node.nodeType?this.node.nodeType===Node.ATTRIBUTE_NODE?this.node.nodeValue:this.node.textContent:this.node}set value(e){e.nodeType===Node.DOCUMENT_NODE?this.node.replaceWith(e.firstElementChild):e.nodeType===Node.ELEMENT_NODE?this.node.replaceWith(e):this.node.nodeType===Node.ATTRIBUTE_NODE?this.node.nodeValue=e:this.node.textContent=e}addAlert(e){this.alerts.includes(e)||this.alerts.push(e)}cleanAlerts(){this.alerts=[]}}class kt extends HTMLElement{constructor(){super(),this.instances=[],this.modelItems=[],this.defaultContext={},this.changed=[],this.inited=!1,this.modelConstructed=!1,this.attachShadow({mode:"open"}),this.computes=0,this.fore={}}get formElement(){return this.parentElement}connectedCallback(){this.shadowRoot.innerHTML="\n <slot></slot>\n ",this.addEventListener("model-construct-done",(()=>{this.modelConstructed=!0}),{once:!0}),this.skipUpdate=!1,this.fore=this.parentNode}static lazyCreateModelItem(e,t,n){let r,a={};if(null==n)return null;if(a=n.nodeType===n.TEXT_NODE?n.parentNode:n,n.nodeType){const a=tt.resolveInstance(e,t);r=tt.getPath(n,a)}else r=null,a=n;const o=new Dt(r,t,St.READONLY_DEFAULT,St.RELEVANT_DEFAULT,St.REQUIRED_DEFAULT,St.CONSTRAINT_DEFAULT,St.TYPE_DEFAULT,a,this);return e.registerModelItem(o),o}async modelConstruct(){console.log(`### <<<<< dispatching model-construct for '${this.fore.id}' >>>>>`),St.dispatch(this,"model-construct",{model:this});const e=this.querySelectorAll("fx-instance");if(e.length>0){const t=[];e.forEach((e=>{t.push(e.init())})),await Promise.all(t),this.instances=Array.from(e),await St.dispatch(this,"model-construct-done",{model:this}),this.inited=!0,this.updateModel()}else console.log(`### <<<<< dispatching model-construct-done for '${this.fore.id}' >>>>>`),await this.dispatchEvent(new CustomEvent("model-construct-done",{composed:!1,bubbles:!0,detail:{model:this}}));this.inited=!0}registerModelItem(e){this.modelItems.push(e)}updateModel(){this.rebuild(),this.recalculate(),this.revalidate()}rebuild(){console.log(`### <<<<< rebuild() '${this.fore.id}' >>>>>`),this.mainGraph=new rt(!1),this.modelItems=[];const e=this.querySelectorAll("fx-model > fx-bind");0!==e.length?(e.forEach((e=>{e.init(this)})),console.log("mainGraph",this.mainGraph),console.log("rebuild mainGraph calc order",this.mainGraph.overallOrder()),St.dispatch(this,"rebuild-done",{maingraph:this.mainGraph}),console.log("mainGraph",this.mainGraph)):this.skipUpdate=!0}recalculate(){if(this.mainGraph){if(console.log(`### <<<<< recalculate() '${this.fore.id}' >>>>>`),this.computes=0,this.subgraph=new rt(!1),0!==this.changed.length){this.changed.forEach((e=>{if(this.subgraph.addNode(e.path,e.node),this.mainGraph.hasNode(e.path)){const t=this.mainGraph.dependantsOf(e.path,!1).reverse();0!==t.length&&t.forEach((t=>{const n=this.mainGraph.getNodeData(t);if(this.subgraph.addNode(t,n),t.includes(":")){const r=t.substring(0,t.indexOf(":"));this.subgraph.addNode(r,n);0!==this.mainGraph.dependentsOf(e.path,!1).indexOf(t)&&this.subgraph.addDependency(t,e.path)}}))}}));this.subgraph.overallOrder(!1).forEach((e=>{if(this.mainGraph.hasNode(e)){const t=this.mainGraph.getNodeData(e);this.compute(t,e)}}));const e=[...this.changed];this.formElement.toRefresh=e,this.changed=[],St.dispatch(this,"recalculate-done",{graph:this.subgraph,computes:this.computes})}else{this.mainGraph.overallOrder(!1).forEach((e=>{const t=this.mainGraph.getNodeData(e);this.compute(t,e)})),St.dispatch(this,"recalculate-done",{graph:this.mainGraph,computes:this.computes})}console.log("recalculate finished with modelItems ",this.modelItems)}}compute(e,t){const n=this.getModelItem(e);if(n&&t.includes(":")){const e=t.split(":")[1];if(e){const t=n.bind[e];if("calculate"===e){const e=yt(t,n.node,this);n.value=e,n.readonly=!0}else if("constraint"!==e&&"type"!==e&&t){const r=xt(t,n.node,this);n[e]=r}}this.computes+=1}}revalidate(){if(0===this.modelItems.length)return!0;console.log(`### <<<<< revalidate() '${this.fore.id}' >>>>>`);let e=!0;return this.modelItems.forEach((t=>{const{bind:n}=t;if(n){if("function"==typeof n.hasAttribute&&n.hasAttribute("constraint")){const r=n.getAttribute("constraint");if(r&&t.node){const n=xt(r,t.node,this);t.constraint=n,this.formElement.addToRefresh(t),n||(console.log("validation failed on modelitem ",t),e=!1)}}if("function"==typeof n.hasAttribute&&n.hasAttribute("required")){const r=n.getAttribute("required");if(r){const n=xt(r,t.node,this);t.required=n,this.formElement.addToRefresh(t),t.node.textContent||(console.log("node is required but has no value ",tt.getDocPath(t.node)),e=!1)}}}})),console.log("modelItems after revalidate: ",this.modelItems),e}addChanged(e){this.inited&&this.changed.push(e)}getModelItem(e){return this.modelItems.find((t=>t.node===e))}getDefaultContext(){return this.instances[0].getDefaultContext()}getDefaultInstance(){return this.instances.length?this.instances[0]:this.getInstance("default")}getDefaultInstanceData(){return this.instances[0].getInstanceData()}getInstance(e){let t;if("default"===e&&(t=this.instances[0]),!t){t=Array.from(this.instances).find((t=>t.id===e)),this.fore.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE?this.fore.parentNode.host.closest("fx-fore"):this.fore.parentNode.closest("fx-fore")}if(!t){const n=this.fore.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE?this.fore.parentNode.host.closest("fx-fore"):this.fore.parentNode.closest("fx-fore");if(n){console.log("shared instances from parent",this.parentNode.id);t=n.getModel().instances.filter((e=>e.hasAttribute("shared"))).find((t=>t.id===e))}}return t||("default"===e?this.getDefaultInstance():(!t&&this.fore.strict&&St.dispatch(this,"error",{origin:this,message:`Instance '${e}' does not exist`,level:"Error"}),null))}evalBinding(e){return this.instances[0].evalXPath(e)}}kt.dataChanged=!1,customElements.get("fx-model")||customElements.define("fx-model",kt);const Rt=e=>class extends e{static get properties(){return{context:{type:Object},model:{type:Object},modelItem:{type:Object},nodeset:{type:Object},ref:{type:String},inScopeVariables:{type:Map}}}constructor(){super(),this.context=null,this.model=null,this.modelItem={},this.ref=this.hasAttribute("ref")?this.getAttribute("ref"):"",this.inScopeVariables=new Map}getModel(){if(this.model)return this.model;return this.getOwnerForm().querySelector("fx-model")}getOwnerForm(){let e=this;for(;e&&e.parentNode;){if("FX-FORE"===e.nodeName.toUpperCase())return e;e=e.parentNode instanceof DocumentFragment?e.parentNode.host:e.parentNode}return e}evalInContext(){if(!this.getModel())return;let e;if(this.hasAttribute("context")&&(e=Ot(this.getAttributeNode("context")||this,this.context)),this.hasAttribute("ref")&&(e=Ot(this.getAttributeNode("ref")||this,this.ref)),e||0===this.getModel().instances.length||(e=this.getModel().getDefaultInstance().getDefaultContext()),""===this.ref)this.nodeset=e;else if(Array.isArray(e))this.nodeset=yt(this.ref,e[0],this);else{if(!e)return;const{nodeType:t}=e;t&&!tt.isAbsolutePath(this.ref)?this.nodeset=wt(this.ref,e,this):[this.nodeset]=yt(this.ref,e,this)}}evaluateAttributeTemplateExpression(e,t){const n=e.match(/{[^}]*}/g);return n&&n.forEach((n=>{const r=n.substring(1,n.length-1),a=bt(r,Ot(t,r),this),o=e.replaceAll(n,a);e=o})),e}isNotBound(){return!this.hasAttribute("ref")}isBound(){return this.hasAttribute("ref")}getBindingExpr(){if(this.hasAttribute("ref"))return this.getAttribute("ref");const e=tt.getClosest("[ref]",this.parentNode);return e?e.getAttribute("ref"):"instance()"}getInstance(){if(this.ref.startsWith("instance(")){const e=tt.getInstanceId(this.ref);return this.getModel().getInstance(e)}return this.getModel().getInstance("default")}_getParentBindingElement(e){if(e.parentNode.host){const{host:t}=e.parentNode;if(t.hasAttribute("ref"))return t}else if(e.parentNode){if(e.parentNode.hasAttribute("ref"))return this.parentNode;this._getParentBindingElement(this.parentNode)}return null}getModelItem(){const e=this.getModel().getModelItem(this.nodeset);e&&(this.modelItem=e);const t=tt.getClosest("fx-repeatitem",this);let n;if(t){const{index:e}=t;n=Array.isArray(this.nodeset)?this.getModel().getModelItem(this.nodeset[e-1]):this.getModel().getModelItem(this.nodeset)}else n=this.getModel().getModelItem(this.nodeset);return n||kt.lazyCreateModelItem(this.getModel(),this.ref,this.nodeset)}getValue(){if(this.hasAttribute("value")){const e=this.getAttribute("value");try{return bt(e,Ot(this,e),this.getOwnerForm())}catch(e){console.error(e),St.dispatch(this,"error",{message:e})}}return this.textContent?this.textContent:null}getInScopeContext(){return Ot(this.getAttributeNode("ref")||this,this.ref)}setInScopeVariables(e){this.inScopeVariables=e}};class Mt extends(Rt(HTMLElement)){constructor(){super(),this.nodeset=[],this.model={},this.contextNode={},this.inited=!1}connectedCallback(){this.constraint=this.getAttribute("constraint"),this.ref=this.getAttribute("ref"),this.readonly=this.getAttribute("readonly"),this.required=this.getAttribute("required"),this.relevant=this.getAttribute("relevant"),this.type=this.hasAttribute("type")?this.getAttribute("type"):Mt.TYPE_DEFAULT,this.calculate=this.getAttribute("calculate")}init(e){this.model=e,this._getInstanceId(),this.bindType=this.getModel().getInstance(this.instanceId).type,"xml"===this.bindType&&(this._evalInContext(),this._buildBindGraph(),this._createModelItems()),this._processChildren(e)}_buildBindGraph(){"xml"===this.bindType&&this.nodeset.forEach((e=>{const t=tt.resolveInstance(this,this.ref),n=tt.getPath(e,t);this.model.mainGraph.addNode(n,e),this.calculate&&(this.model.mainGraph.addNode(`${n}:calculate`,e),this.model.mainGraph.addDependency(n,`${n}:calculate`));const r=this._getReferencesForProperty(this.calculate,e);if(0!==r.length&&this._addDependencies(r,e,n,"calculate"),!this.calculate){const t=this._getReferencesForProperty(this.readonly,e);0!==t.length?this._addDependencies(t,e,n,"readonly"):this.readonly&&this.model.mainGraph.addNode(`${n}:readonly`,e)}const a=this._getReferencesForProperty(this.required,e);0!==a.length?this._addDependencies(a,e,n,"required"):this.required&&this.model.mainGraph.addNode(`${n}:required`,e);const o=this._getReferencesForProperty(this.relevant,e);0!==o.length?this._addDependencies(o,e,n,"relevant"):this.relevant&&this.model.mainGraph.addNode(`${n}:relevant`,e);const s=this._getReferencesForProperty(this.constraint,e);0!==s.length?this._addDependencies(s,e,n,"constraint"):this.constraint&&(this.model.mainGraph.addNode(`${n}:constraint`,e),this.model.mainGraph.addDependency(n,`${n}:constraint`))}))}_addDependencies(e,t,n,r){const a=`${n}:${r}`;0!==e.length?(this.model.mainGraph.hasNode(a)||this.model.mainGraph.addNode(a,t),e.forEach((e=>{const t=tt.resolveInstance(this,n),r=tt.getPath(e,t);r.endsWith("text()[1]")||(this.model.mainGraph.hasNode(r)||this.model.mainGraph.addNode(r,e),this.model.mainGraph.addDependency(a,r))}))):this.model.mainGraph.addNode(a,t)}_processChildren(e){const t=this.querySelectorAll(":scope > fx-bind");Array.from(t).forEach((t=>{t.init(e)}))}getAlert(){if(this.hasAttribute("alert"))return this.getAttribute("alert");const e=this.querySelector("fx-alert");return e?e.innerHTML:null}_evalInContext(){const e=Ot(this.getAttributeNode("ref")||this,this.ref);if(this.nodeset=[],""===this.ref||null===this.ref)this.nodeset=e;else if(Array.isArray(e))e.forEach((t=>{if(tt.isSelfReference(this.ref))this.nodeset=e;else if(this.ref){vt(this.ref,t,this).forEach((e=>{this.nodeset.push(e)}))}}));else{"xml"===this.getModel().getInstance(this.instanceId).type?this.nodeset=vt(this.ref,e,this):this.nodeset=this.ref}}_createModelItems(){Array.isArray(this.nodeset)?Array.from(this.nodeset).forEach((e=>{this._createModelItem(e)})):this._createModelItem(this.nodeset)}_createModelItem(e){if(tt.isSelfReference(this.ref)){const e=tt.getClosest("fx-bind[ref]",this.parentElement);return void(e?e.required=this.required:console.error("no parent bound element"))}const t=e,n=tt.resolveInstance(this,this.ref),r=tt.getPath(e,n),a=new Dt(r,this.getBindingExpr(),Mt.READONLY_DEFAULT,Mt.RELEVANT_DEFAULT,Mt.REQUIRED_DEFAULT,Mt.CONSTRAINT_DEFAULT,this.type,t,this),o=this.getAlert();o&&a.addAlert(o),this.getModel().registerModelItem(a)}_getReferencesForProperty(e){return e?this.getReferences(e):[]}getReferences(e){const t=new Set,n=new et((e=>t.add(e)));return this.nodeset.forEach((t=>{bt(e,t,this,n)})),Array.from(t.values())}_initBooleanModelItemProperty(e,t){return xt(this[e],t,this)}static shortenPath(e){const t=e.split("/");let n="";for(let e=2;e<t.length;e+=1){const r=t[e];if(-1!==r.indexOf("{}")){n+=`/${r.split("{}")[1]}`}else n+=`/${r}`}return n}_getInstanceId(){const e=this.getBindingExpr();if(e.startsWith("instance("))this.instanceId=tt.getInstanceId(e);else{if(!this.instanceId&&"FX-BIND"===this.parentNode.nodeName){let e=this.parentNode;for(;e&&!this.instanceId;){const t=e.getBindingExpr();if(t.startsWith("instance("))return void(this.instanceId=tt.getInstanceId(t));if("FX-BIND"!==e.parentNode.nodeName){this.instanceId="default";break}e=e.parentNode}}this.instanceId="default"}}}Mt.READONLY_DEFAULT=!1,Mt.REQUIRED_DEFAULT=!1,Mt.RELEVANT_DEFAULT=!0,Mt.CONSTRAINT_DEFAULT=!0,Mt.TYPE_DEFAULT="xs:string",customElements.get("fx-bind")||customElements.define("fx-bind",Mt)
2
2
  /*!
3
3
  * Toastify js 1.11.2
4
4
  * https://github.com/apvarun/toastify-js
5
5
  * @license MIT licensed
6
6
  *
7
7
  * Copyright (C) 2018 Varun A P
8
- */;class Ut{constructor(e){this.defaults={oldestFirst:!0,text:"Toastify is awesome!",node:void 0,duration:3e3,selector:void 0,callback:function(){},destination:void 0,newWindow:!1,close:!1,gravity:"toastify-top",positionLeft:!1,position:"",backgroundColor:"",avatar:"",className:"",stopOnFocus:!0,onClick:function(){},offset:{x:0,y:0},escapeMarkup:!0,style:{background:""}},this.version="1.11.2",this.options={},this.toastElement=null,this._rootElement=document.body,this._init(e)}showToast(){if(this.toastElement=this._buildToast(),"string"==typeof this.options.selector?this._rootElement=document.getElementById(this.options.selector):this.options.selector instanceof HTMLElement||this.options.selector instanceof ShadowRoot?this._rootElement=this.options.selector:this._rootElement=document.body,!this._rootElement)throw"Root element is not defined";return this._rootElement.insertBefore(this.toastElement,this._rootElement.firstChild),this._reposition(),this.options.duration>0&&(this.toastElement.timeOutValue=window.setTimeout((()=>{this._removeElement(this.toastElement)}),this.options.duration)),this}hideToast(){this.toastElement.timeOutValue&&clearTimeout(this.toastElement.timeOutValue),this._removeElement(this.toastElement)}_init(e){this.options=Object.assign(this.defaults,e),this.options.backgroundColor&&console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.'),this.toastElement=null,this.options.gravity="bottom"===e.gravity?"toastify-bottom":"toastify-top",this.options.stopOnFocus=void 0===e.stopOnFocus||e.stopOnFocus,e.backgroundColor&&(this.options.style.background=e.backgroundColor)}_buildToast(){if(!this.options)throw"Toastify is not initialized";let e=document.createElement("div");e.className=`toastify on ${this.options.className}`,e.className+=` toastify-${this.options.position}`,e.className+=` ${this.options.gravity}`;for(const t in this.options.style)e.style[t]=this.options.style[t];if(this.options.node&&this.options.node.nodeType===Node.ELEMENT_NODE)e.appendChild(this.options.node);else if(this.options.escapeMarkup?e.innerText=this.options.text:e.innerHTML=this.options.text,""!==this.options.avatar){let t=document.createElement("img");t.src=this.options.avatar,t.className="toastify-avatar","left"==this.options.position?e.appendChild(t):e.insertAdjacentElement("afterbegin",t)}if(!0===this.options.close){let t=document.createElement("span");t.innerHTML="&#10006;",t.className="toast-close",t.addEventListener("click",(e=>{e.stopPropagation(),this._removeElement(this.toastElement),window.clearTimeout(this.toastElement.timeOutValue)}));const n=window.innerWidth>0?window.innerWidth:screen.width;"left"==this.options.position&&n>360?e.insertAdjacentElement("afterbegin",t):e.appendChild(t)}if(this.options.stopOnFocus&&this.options.duration>0&&(e.addEventListener("mouseover",(t=>{window.clearTimeout(e.timeOutValue)})),e.addEventListener("mouseleave",(()=>{e.timeOutValue=window.setTimeout((()=>{this._removeElement(e)}),this.options.duration)}))),void 0!==this.options.destination&&e.addEventListener("click",(e=>{e.stopPropagation(),!0===this.options.newWindow?window.open(this.options.destination,"_blank"):window.location=this.options.destination})),"function"==typeof this.options.onClick&&void 0===this.options.destination&&e.addEventListener("click",(e=>{e.stopPropagation(),this.options.onClick()})),"object"==typeof this.options.offset){const t=this._getAxisOffsetAValue("x",this.options),n=this._getAxisOffsetAValue("y",this.options),r="left"==this.options.position?t:`-${t}`,a="toastify-top"==this.options.gravity?n:`-${n}`;e.style.transform=`translate(${r},${a})`}return e}_removeElement(e){e.className=e.className.replace(" on",""),window.setTimeout((()=>{this.options.node&&this.options.node.parentNode&&this.options.node.parentNode.removeChild(this.options.node),e.parentNode&&e.parentNode.removeChild(e),this.options.callback.call(e),this._reposition()}),400)}_reposition(){let e,t={top:15,bottom:15},n={top:15,bottom:15},r={top:15,bottom:15},a=this._rootElement.querySelectorAll(".toastify");for(let o=0;o<a.length;o++){e=!0===a[o].classList.contains("toastify-top")?"toastify-top":"toastify-bottom";let s=a[o].offsetHeight;e=e.substr(9,e.length-1);let i=15;(window.innerWidth>0?window.innerWidth:screen.width)<=360?(a[o].style[e]=`${r[e]}px`,r[e]+=s+i):!0===a[o].classList.contains("toastify-left")?(a[o].style[e]=`${t[e]}px`,t[e]+=s+i):(a[o].style[e]=`${n[e]}px`,n[e]+=s+i)}}_getAxisOffsetAValue(e,t){return t.offset[e]?isNaN(t.offset[e])?t.offset[e]:`${t.offset[e]}px`:"0px"}}function Gt(e){return new Ut(e)}class $t extends HTMLElement{static get properties(){return{avatar:{type:String},backgroundColor:{type:String},callback:{type:String},classProp:{type:String},close:{type:Boolean},destination:{type:String},duration:{type:Number},escapeMarkup:{type:Boolean},gravity:{type:String},newWindow:{type:Boolean},oldestFirst:{type:Boolean},position:{type:String},selector:{type:String},stopOnFocus:{type:Boolean},text:{type:String}}}constructor(){super(),this.attachShadow({mode:"open"})}_initVar(e,t){return this.hasAttribute(e)?this.getAttribute(e):t}connectedCallback(){this.avatar=this._initVar("avatar",""),this.backgroundColor=this._initVar("backgroundColor",""),this.callback=this._initVar("callback",{}),this.classProp=this._initVar("data-class",""),this.close="true"===this._initVar("close",!1),this.destination=this._initVar("destination",void 0),this.duration=Number(this._initVar("duration",3e3)),this.escapeMarkup="true"===this._initVar("escapeMarkup","true"),this.gravity=this._initVar("gravity","top"),this.newWindow="true"===this._initVar("newWindow","false"),this.offSet=this._initVar("offSet",{}),this.oldestFirst="true"===this._initVar("oldestFirst","true"),this.position=this._initVar("position","right"),this.stopOnFocus="true"===this._initVar("stopOnFocus","true"),this.text=this._initVar("text","");this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n ${this.renderHTML}\n `,this.addEventListener("jinn-toast",(e=>{this.showToast(e.detail.text)}))}disconnectedCallback(){this.removeEventListener("jinn-toast",this.showToast)}showToast(e){new Gt({avatar:this.avatar,className:this.classProp,close:this.close,destination:this.destination,duration:this.duration,escapeMarkup:this.escapeMarkup,gravity:this.gravity,newWindow:!1,offset:this.offset,oldestFirst:this.oldestFirst,position:this.position,node:this.shadowRoot,stopOnFocus:this.stopOnFocus,text:e}).showToast()}renderHTML(){return"\n <slot></slot>\n "}}customElements.get("jinn-toast")||window.customElements.define("jinn-toast",$t);class Lt extends(Rt(HTMLElement)){static get properties(){return{...super.properties,index:{type:Number},template:{type:Object},focusOnCreate:{type:String},initDone:{type:Boolean},repeatIndex:{type:Number},repeatSize:{type:Number},nodeset:{type:Array}}}constructor(){super(),this.ref="",this.dataTemplate=[],this.focusOnCreate="",this.initDone=!1,this.repeatIndex=1,this.nodeset=[],this.inited=!1,this.host={},this.index=1,this.repeatSize=0,this.attachShadow({mode:"open",delegatesFocus:!0})}get repeatSize(){return this.querySelectorAll(":scope > .fx-repeatitem").length}set repeatSize(e){super.repeatSize=e}setIndex(e){this.index=e;const t=this.querySelector("[data-ref]").querySelectorAll(":scope > *");this.applyIndex(t[this.index-1])}applyIndex(e){this._removeIndexMarker(),e&&e.setAttribute("repeat-index","")}get index(){return this.getAttribute("index")}set index(e){this.setAttribute("index",e)}_getRepeatedItems(){return this.querySelector("[data-ref]").children}async connectedCallback(){this.ref=this.getAttribute("ref"),this.addEventListener("item-changed",(e=>{const{item:t}=e.detail,n=this._getRepeatedItems(),r=Array.from(n).indexOf(t);this.applyIndex(n[r]),this.index=r+1})),document.addEventListener("index-changed",(e=>{if(e.stopPropagation(),!e.target===this)return;const{index:t}=e.detail;this.index=Number(t),this.applyIndex(this.children[t-1])})),this.mutationObserver=new MutationObserver((e=>{if("childList"===e[0].type){const t=e[0].addedNodes[0];if(t){const e=tt.resolveInstance(this,this.ref),n=tt.getPath(t,e);Ot.dispatch(this,"path-mutated",{path:n,index:this.index})}}})),this.getOwnerForm().registerLazyElement(this);this.shadowRoot.innerHTML="\n <style>\n \n :host{\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n \n </style>\n \n <slot></slot>\n \n "}async init(){return new Promise((e=>{this._evalNodeset(),this._initTemplate(),this.setAttribute("index",this.index),this.inited=!0,e("done")}))}_getRef(){return this.getAttribute("ref")}_evalNodeset(){const e=St(this.getAttributeNode("ref")||this,this.ref);this.mutationObserver&&e.nodeName&&this.mutationObserver.observe(e,{childList:!0,subtree:!0});const t=yt(this.ref,e,this);1===t.length&&Array.isArray(t[0])?this.nodeset=t[0]:this.nodeset=t}async refresh(e){this.inited||this.init(),this._evalNodeset();let t=this.querySelectorAll(".fx-repeatitem"),n=t.length,r=1;Array.isArray(this.nodeset)&&(r=this.nodeset.length);const a=r;if(a<n)for(let e=n;e>a;e-=1){const n=t[e-1];n.parentNode.removeChild(n),this.getOwnerForm().unRegisterLazyElement(n),this.getOwnerForm().someInstanceDataStructureChanged=!0}if(a>n)for(let e=n+1;e<=a;e+=1){const t=this._clone();if(!t)return;this.querySelector("[data-ref]").appendChild(t),t.classList.add("fx-repeatitem"),t.setAttribute("index",e),t.addEventListener("click",this._dispatchIndexChange),t.addEventListener("focusin",this._dispatchIndexChange),this.getOwnerForm().someInstanceDataStructureChanged=!0}t=this.querySelectorAll(":scope > .fx-repeatitem"),n=t.length;for(let e=0;e<n;e+=1){const n=t[e];this.getOwnerForm().registerLazyElement(n),n.nodeset!==this.nodeset[e]&&(n.nodeset=this.nodeset[e])}this.getOwnerForm().lazyRefresh&&!e||Ot.refreshChildren(this,e),this.setIndex(this.index)}_dispatchIndexChange(){this.dispatchEvent(new CustomEvent("item-changed",{composed:!1,bubbles:!0,detail:{item:this,index:this.index}}))}_fadeOut(e){e.style.opacity=1,function t(){(e.style.opacity-=.1)<0?e.style.display="none":requestAnimationFrame(t)}()}_fadeIn(e){e&&(e.style.opacity=0,e.style.display=this.display,function t(){let n=parseFloat(e.style.opacity);(n+=.1)>1||(e.style.opacity=n,requestAnimationFrame(t))}())}async _initTemplate(){this.template=this.querySelector("template"),this.template&&this.shadowRoot.appendChild(this.template)}_initVariables(e){const t=new Map(this.inScopeVariables);e.setInScopeVariables(t),function e(n){for(const r of n.children)"setInScopeVariables"in r&&r.setInScopeVariables(t),e(r)}(e)}_clone(){if(this.template=this.shadowRoot.querySelector("template"),this.template)return this.template.content.firstElementChild.cloneNode(!0)}_removeIndexMarker(){const e=this.querySelector("[data-ref]");Array.from(e.children).forEach((e=>{e.removeAttribute("repeat-index")}))}setInScopeVariables(e){this.inScopeVariables=new Map(e)}}customElements.get("fx-repeat-attributes")||window.customElements.define("fx-repeat-attributes",Lt);class Ht extends HTMLElement{static get properties(){return{ignoreExpressions:{type:String},mergePartial:{type:Boolean},lazyRefresh:{type:Boolean},model:{type:Object},ready:{type:Boolean},strict:{type:Boolean},validateOn:{type:String},version:{type:String}}}constructor(){super(),this.version="Version: 2.0.0 - built on February 22, 2024 16:36:43",this.model={},this.inited=!1,this.addEventListener("message",this._displayMessage),this.addEventListener("error",this._logError),this.addEventListener("warn",this._displayWarning),window.addEventListener("compute-exception",(e=>{console.error("circular dependency: ",e)})),this.ready=!1,this.storedTemplateExpressionByNode=new Map,this.outermostHandler=null;this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display: block;\n }\n :host ::slotted(fx-model){\n display:none;\n }\n\n #modalMessage .dialogActions{\n text-align:center;\n }\n .overlay {\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: rgba(0, 0, 0, 0.7);\n transition: all 500ms;\n visibility: hidden;\n opacity: 0;\n z-index:10;\n }\n .overlay.show {\n visibility: visible;\n opacity: 1;\n }\n\n .popup {\n margin: 70px auto;\n background: #fff;\n border-radius: 5px;\n width: 30%;\n position: relative;\n transition: all 5s ease-in-out;\n padding: 20px;\n\n }\n .popup h2 {\n margin-top: 0;\n width:100%;\n background:#eee;\n position:absolute;\n top:0;\n right:0;\n left:0;\n height:40px;\n border-radius: 5px;\n\n }\n .popup .close {\n position: absolute;\n top: 3px;\n right: 10px;\n transition: all 200ms;\n font-size: 30px;\n font-weight: bold;\n text-decoration: none;\n color: #333;\n }\n .popup .close:focus{\n outline:none;\n }\n\n .popup .close:hover {\n color: #06D85F;\n }\n #messageContent{\n margin-top:40px;\n }\n .warning{\n background:orange;\n }\n \n </style>\n \n <noscript>This page uses Web Components and needs JavaScript to be enabled..</noscript>\n\x3c!-- <slot name="errors"></slot> --\x3e\n <jinn-toast id="message" gravity="bottom" position="left"></jinn-toast>\n <jinn-toast id="sticky" gravity="bottom" position="left" duration="-1" close="true" data-class="sticky-message"></jinn-toast>\n <jinn-toast id="error" text="error" duration="-1" data-class="error" close="true" position="right" gravity="top" escape-markup="false"></jinn-toast>\n <jinn-toast id="warn" text="warning" duration="5000" data-class="warning" position="left" gravity="top"></jinn-toast>\n <slot id="default"></slot>\n <slot name="messages"></slot>\n <div id="modalMessage" class="overlay">\n <div class="popup">\n <h2></h2>\n <a class="close" href="#" onclick="event.target.parentNode.parentNode.classList.remove(\'show\')" autofocus>&times;</a>\n <div id="messageContent"></div>\n </div>\n </div>\n <slot name="event"></slot>\n \n ',this.toRefresh=[],this.initialRun=!0,this._scanForNewTemplateExpressionsNextRefresh=!1,this.repeatsFromAttributesCreated=!1,this.validateOn=this.hasAttribute("validate-on")?this.getAttribute("validate-on"):"update",this.mergePartial=!1}connectedCallback(){if(this.style.visibility="hidden",console.time("init"),this.strict=!!this.hasAttribute("strict"),this.ignoreExpressions=this.hasAttribute("ignore-expressions")?this.getAttribute("ignore-expressions"):null,this.lazyRefresh=this.hasAttribute("refresh-on-view"),this.lazyRefresh){const e={root:null,rootMargin:"0px",threshold:.3};this.intersectionObserver=new IntersectionObserver(this.handleIntersect,e)}if(this.src=this.hasAttribute("src")?this.getAttribute("src"):null,this.src)return void this._loadFromSrc();this._injectDevtools();this.shadowRoot.querySelector("slot#default").addEventListener("slotchange",(async e=>{if(console.log(`### <<<<< slotchange on '${this.id}' >>>>>`),this.inited)return;if(this.hasAttribute("convert"))return void this.replaceWith(Ot.copyDom(this));this.ignoreExpressions&&(this.ignoredNodes=Array.from(this.querySelectorAll(this.ignoreExpressions)));let t=e.target.assignedElements().find((e=>"FX-MODEL"===e.nodeName.toUpperCase()));if(!t){const e=document.createElement("fx-model");return this.appendChild(e),void(t=e)}t.inited||(console.info(`%cFore is processing fx-fore#${this.id}`,"background:#64b5f6; color:white; padding:.5rem; display:inline-block; white-space: nowrap; border-radius:0.3rem;width:100%;"),await t.modelConstruct(),this._handleModelConstructDone()),this.model=t,this._createRepeatsFromAttributes(),this.inited=!0})),this.addEventListener("path-mutated",(()=>{this.someInstanceDataStructureChanged=!0})),this.addEventListener("refresh",(()=>{this.refresh(!0)}))}_injectDevtools(){if(this.ownerDocument.querySelector("fx-devtools"))return;const e=window.location.search;if(new URLSearchParams(e).has("inspect")){const e=document.createElement("fx-devtools");document.body.appendChild(e)}}addToRefresh(e){this.toRefresh.find((t=>t.path===e.path))||this.toRefresh.push(e)}scanForNewTemplateExpressionsNextRefresh(){this._scanForNewTemplateExpressionsNextRefresh=!0}async _loadFromSrc(){await Ot.loadForeFromSrc(this,this.src,"fx-fore")}handleIntersect(e,t){e.forEach((e=>{const{target:t}=e;Ot.getFore(t).initialRun||e.isIntersecting&&(t.classList.add("loaded"),"function"==typeof t.refresh?t.refresh(t,!0):Ot.refreshChildren(t,!0))})),e[0].target.getOwnerForm().dispatchEvent(new CustomEvent("refresh-done"))}evaluateToNodes(e,t){return vt(e,t,this)}disconnectedCallback(){}async forceRefresh(){Ot.refreshChildren(this,!0),this._updateTemplateExpressions(),this._scanForNewTemplateExpressionsNextRefresh=!1,this._processTemplateExpressions(),console.log(`### <<<<< refresh-done ${this.id} >>>>>`),Ot.dispatch(this,"refresh-done",{})}async refresh(e){if(this.isRefreshing)return;this.isRefreshing=!0,console.log(`### <<<<< refresh() on '${this.id}' >>>>>`),e||this.initialRun||0===this.toRefresh.length?this.inited&&Ot.refreshChildren(this,!0):(this.toRefresh.forEach((t=>{const n=t.boundControls;n&&n.forEach((t=>{t.refresh(e)}));const{mainGraph:r}=this.getModel();if(r&&r.hasNode(t.path)){const n=this.getModel().mainGraph.dependentsOf(t.path,!1);0!==n.length&&n.forEach((t=>{const n=tt.getBasePath(t);this.getModel().modelItems.find((e=>e.path===n)).boundControls.forEach((t=>{t.refresh(e)}))}))}})),this.toRefresh=[]),(this.initialRun||this._scanForNewTemplateExpressionsNextRefresh)&&(this._updateTemplateExpressions(),this._scanForNewTemplateExpressionsNextRefresh=!1),this._processTemplateExpressions(),this.style.visibility="visible",console.log(`### <<<<< refresh-done ${this.id} >>>>>`),Ot.dispatch(this,"refresh-done",{});const t=Array.from(this.querySelectorAll("fx-fore"));for(const e of t)e.ready&&await e.refresh(!1);this.isRefreshing=!1}_updateTemplateExpressions(){const e=vt("(descendant-or-self::*!(text(), @*))[contains(., '{')][substring-after(., '{') => contains('}')][not(ancestor-or-self::fx-model)]",this,this);this.storedTemplateExpressions||(this.storedTemplateExpressions=[]),Array.from(e).forEach((e=>{if((e.nodeType===Node.ATTRIBUTE_NODE?e.ownerElement:e.parentNode).closest("fx-fore")!==this)return;if(this.storedTemplateExpressionByNode.has(e))return;const t=this._getTemplateExpression(e);t&&this.storedTemplateExpressionByNode.set(e,t)})),this._processTemplateExpressions()}_processTemplateExpressions(){for(const e of Array.from(this.storedTemplateExpressionByNode.keys())){if(e.nodeType===Node.ATTRIBUTE_NODE){if(!tt.contains(this,e.ownerElement)){this.storedTemplateExpressionByNode.delete(e);continue}}else if(!tt.contains(this,e)){this.storedTemplateExpressionByNode.delete(e);continue}this._processTemplateExpression({node:e,expr:this.storedTemplateExpressionByNode.get(e)})}}_processTemplateExpression(e){const{expr:t}=e,{node:n}=e;this.evaluateTemplateExpression(t,n)}evaluateTemplateExpression(e,t){if(t.nodeType===Node.ATTRIBUTE_NODE&&t.ownerElement.closest("[nonrelevant]"))return;if(t.nodeType===Node.TEXT_NODE&&t.parentNode.closest("[nonrelevant]"))return;if(t.nodeType===Node.ELEMENT_NODE&&t.closest("[nonrelevant]"))return;const n=e.replace(/{[^}]*}/g,(e=>{if("{}"===e)return e;const n=e.substring(1,e.length-1),r=St(t,n);if(!r)return console.warn("no inscope context for expr",n),(t.nodeType===Node.TEXT_NODE||t.nodeType===Node.ATTRIBUTE_NODE)&&t.parentNode,e;const a=tt.getInstanceId(n),o=a?this.getModel().getInstance(a):this.getModel().getDefaultInstance();try{return bt(n,r,t,null,o)}catch(t){return console.warn("ignoring unparseable expr",t),e}}));if(t.nodeType===Node.ATTRIBUTE_NODE){const e=t.ownerElement;e.getAttribute(t.nodeName)!==n&&e.setAttribute(t.nodeName,n)}else t.nodeType===Node.TEXT_NODE&&t.textContent!==n&&(t.textContent=n)}_getTemplateExpression(e){if(this.ignoredNodes){e.nodeType===Node.ATTRIBUTE_NODE&&(e=e.ownerElement);const t=this.ignoredNodes.find((t=>t.contains(e)));if(t)return null}return e.nodeType===Node.ATTRIBUTE_NODE?e.value:e.nodeType===Node.TEXT_NODE?e.textContent.trim():null}_handleModelConstructDone(){if(this.hasAttribute("show-confirmation")){const e=this.getAttribute("show-confirmation");e&&"show-confirmation"!==e&&"true"!==e&&""!==e?window.addEventListener("beforeunload",(t=>{if(xt(e,this.getModel().getDefaultContext(),this))return t.returnValue="are you sure";t.preventDefault()})):window.addEventListener("beforeunload",(e=>{if(kt.dataChanged)return e.returnValue="are you sure";e.preventDefault()}))}this._initUI()}async _lazyCreateInstance(){const e=this.querySelector("fx-model"),t=this.parentNode.nodeType!==Node.DOCUMENT_FRAGMENT_NODE?this.parentNode.closest("fx-fore"):null;if(this.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&console.log("fragment",this.parentNode),t){if(0!==t.getModel().instances.filter((e=>e.hasAttribute("shared"))).length)return}try{if(0===e.instances.length){const t=document.createElement("fx-instance");e.appendChild(t);const n=document.implementation.createDocument(null,"data",null);this._generateInstance(this,n.firstElementChild),t.instanceData=n,e.instances.push(t),Ot.dispatch(this,"instance-loaded",{instance:this})}}catch(e){console.warn("lazyCreateInstance created an error attempting to create a document",e.message)}}_generateInstance(e,t){if(e.hasAttribute("ref")&&!Ot.isActionElement(e.nodeName)){const n=e.getAttribute("ref");if(n.includes("/")){n.split("/").forEach((n=>{t=this._generateNode(t,n,e)}))}else t=this._generateNode(t,n,e)}if(e.hasChildNodes()){const n=e.children;for(let e=0;e<n.length;e+=1)this._generateInstance(n[e],t)}return t}_generateNode(e,t,n){const r=e.ownerDocument.createElement(t);return 0===n.children.length&&(r.textContent=n.textContent),e.appendChild(r),e=r}async _initUI(){if(console.log(`### <<<<< _initUI '${this.id}' >>>>>`),!this.initialRun)return;this.classList.add("initialRun"),await this._lazyCreateInstance();const e=new Map;!function t(n){for(const r of n.children)"setInScopeVariables"in r&&r.setInScopeVariables(e),t(r)}(this),await this.refresh(!0),this.classList.add("fx-ready"),document.body.classList.add("fx-ready"),this.ready=!0,this.initialRun=!1,console.log(`### <<<<< ${this.id} ready >>>>>`),Ot.dispatch(this,"ready",{}),console.timeEnd("init")}registerLazyElement(e){this.intersectionObserver&&this.intersectionObserver.observe(e)}unRegisterLazyElement(e){this.intersectionObserver&&this.intersectionObserver.unobserve(e)}getModel(){return this.querySelector("fx-model")}_displayMessage(e){const{level:t}=e.detail,n=e.detail.message;this._showMessage(t,n),e.stopPropagation()}_displayError(e){const t=e.detail.message;this.shadowRoot.querySelector("#error").showToast(t)}_displayWarning(e){const t=e.detail.message,n=tt.shortenPath(bt("path()",e.target,this));this.shadowRoot.querySelector("#warn").showToast(`WARN: ${n}:${t}`)}_logError(e){e.stopPropagation(),e.preventDefault(),console.error("ERROR",e.detail.message),console.error(e.detail.origin),e.detail.expr&&console.error("Failing expression",e.detail.expr),this.strict&&this._displayError(e)}_copyToClipboard(e){console.log("copyToClipboard",e.value),navigator.clipboard.writeText(e.value)}_showMessage(e,t){if("modal"===e)this.shadowRoot.getElementById("messageContent").innerText=t,this.shadowRoot.getElementById("modalMessage").classList.add("show");else if("sticky"===e||"error"===e||"warn"===e)this.shadowRoot.querySelector(`#${e}`).showToast(t);else{this.shadowRoot.querySelector("#message").showToast(t)}}_createRepeatsFromAttributes(){if(this.repeatsFromAttributesCreated)return;const e=this.querySelectorAll("[data-ref]");e&&Array.from(e).forEach((e=>{if(e.closest("fx-control"))return;const t=e.parentNode.closest("table");let n;n=t?t.cloneNode(!0):e.cloneNode(!0);const r=new Lt;r.setAttribute("ref",e.getAttribute("data-ref")),r.appendChild(n),t?(t.parentNode.insertBefore(r,t),t.parentNode.removeChild(t)):(e.parentNode.insertBefore(r,e),e.parentNode.removeChild(e)),e.setAttribute("insertPoint","")})),this.repeatsFromAttributesCreated=!0}}Ht.outermostHandler=null,customElements.get("fx-fore")||customElements.define("fx-fore",Ht);class Pt{static selectRelevant(e,t){return"xml"===t?Pt._relevantXmlNodes(e):(console.warn(`relevance selection not supported for type:${e.type}`),e.nodeset)}static _relevantXmlNodes(e){if("keep"===e.getAttribute("nonrelevant"))return e.nodeset;const t=e.getModel().getModelItem(e.nodeset);if(t&&!t.relevant)return null;const n=e.nodeset.cloneNode(!1);return 0===e.nodeset.children.length&&Pt._isRelevant(e,e.nodeset)?e.nodeset:Pt._filterRelevant(e,e.nodeset,n)}static _filterRelevant(e,t,n){const{childNodes:r}=t;return Array.from(r).forEach((t=>{if(Pt._isRelevant(e,t)){const r=t.cloneNode(!1);n.appendChild(r);const{attributes:a}=t;return a&&Array.from(a).forEach((t=>{"empty"!==e.nonrelevant||Pt._isRelevant(e,t)?Pt._isRelevant(e,t)?r.setAttribute(t.nodeName,t.value):r.removeAttribute(t.nodeName):r.setAttribute(t.nodeName,"")})),Pt._filterRelevant(e,t,r)}return null})),n}static _isRelevant(e,t){const n=e.getModel().getModelItem(t);return(t.nodeType!==Node.ATTRIBUTE_NODE||""!==t.nodeValue)&&(!n||!!n.relevant)}}class jt extends(Rt(HTMLElement)){constructor(){super(),this.attachShadow({mode:"open"}),this.credentials="",this.parameters=new Map}connectedCallback(){this.methods=["get","put","post","delete","head","urlencoded-post"],this.model=this.parentNode,this.hasAttribute("id")||console.warn("id is required"),this.id=this.getAttribute("id"),this.instance=this.hasAttribute("instance")?this.getAttribute("instance"):null,this.into=this.hasAttribute("into")?this.getAttribute("into"):null,this.method=this.hasAttribute("method")?this.getAttribute("method"):"get",this.nonrelevant=this.hasAttribute("nonrelevant")?this.getAttribute("nonrelevant"):"remove",this.replace=this.hasAttribute("replace")?this.getAttribute("replace"):"all",this.serialization=this.hasAttribute("serialization")?this.getAttribute("serialization"):"xml",this.url=this.hasAttribute("url")?this.getAttribute("url"):null,this.targetref=this.hasAttribute("targetref")?this.getAttribute("targetref"):null,this.mediatype=this.hasAttribute("mediatype")?this.getAttribute("mediatype"):"application/xml",this.validate=this.getAttribute("validate")?this.getAttribute("validate"):"true",this.credentials=this.hasAttribute("credentials")?this.getAttribute("credentials"):"same-origin",["same-origin","include","omit"].includes(this.credentials)||console.error(`fx-submission: the value of credentials is not valid. Expected 'same-origin', 'include' or 'omit' but got '${this.credentials}'`,this),this.shadowRoot.innerHTML=this.renderHTML()}renderHTML(){return"\n <slot></slot>\n "}async submit(){await Ot.dispatch(this,"submit",{submission:this}),await this._submit()}async _submit(){console.log("submitting....",this.getAttribute("id")),this.evalInContext();const e=this.getModel();if(e.recalculate(),"true"===this.validate&&"get"!==this.method){if(!e.revalidate())return console.log("validation failed. Submission stopped"),this.getOwnerForm().classList.add("submit-validation-failed"),Ot.dispatch(this,"submit-error",{}),void this.getModel().parentNode.refresh(!0)}await this._serializeAndSend()}_getProperty(e){return this.parameters.has(e)?this.parameters.get(e):this.getAttribute(e)}async _serializeAndSend(){const e=this._getProperty("url"),t=this.evaluateAttributeTemplateExpression(e,this);console.log("resolvedUrl",t);const n=this.getInstance();n||Ot.dispatch(this,"warn",{message:`instance not found ${n.getAttribute("id")}`});const r=n.getAttribute("type");let a;if("none"===this.serialization)a=void 0;else{const e=Pt.selectRelevant(this,r);a=this._serialize(r,e)}if("get"===this.method.toLowerCase()&&(a=void 0),t.startsWith("#echo")){const e=this._parse(a,n);return this._handleResponse(e),console.log("### <<<<< submit-done >>>>>"),Ot.dispatch(this,"submit-done",{}),void this.parameters.clear()}if(t.startsWith("localStore:")){if("get"===this.method||"consume"===this.method){this.replace="instance";const e=t.substring(t.indexOf(":")+1),r=localStorage.getItem(e);if(!r)return Ot.dispatch(this,"submit-error",{message:`Error reading key ${e} from localstorage`}),void this.parameters.clear();const a=this._parse(r,n);this._handleResponse(a),"consume"===this.method&&localStorage.removeItem(e),console.log("### <<<<< submit-done >>>>>"),Ot.dispatch(this,"submit-done",{})}if("post"===this.method){const e=t.substring(t.indexOf(":")+1);localStorage.setItem(e,a),this._handleResponse(n.instanceData),console.log("### <<<<< submit-done >>>>>"),Ot.dispatch(this,"submit-done",{})}if("delete"===this.method){const e=t.substring(t.indexOf(":")+1);localStorage.removeItem(e);const n=(new DOMParser).parseFromString("<data></data>","application/xml");this._handleResponse(n),console.log("### <<<<< submit-done >>>>>"),Ot.dispatch(this,"submit-done",{})}return}const o=this._getHeaders();if(this.methods.includes(this.method.toLowerCase()))try{const e=await fetch(t,{method:this.method,credentials:this.credentials,mode:"cors",headers:o,body:a});if(!e.ok||e.status>400)return void Ot.dispatch(this,"submit-error",{message:`Error while submitting ${this.id}`});const n=e.headers.get("content-type").toLowerCase();if(n.startsWith("text/")){const r=await e.text();this._handleResponse(r,t,n)}else if(n.startsWith("application/json")){const r=await e.json();this._handleResponse(r,t,n)}else if(n.startsWith("application/xml")){const r=await e.text(),a=(new DOMParser).parseFromString(r,"application/xml");this._handleResponse(a,t,n)}else{const r=await e.blob();this._handleResponse(r,t,n)}console.log(`### <<<<< ${this.id} submit-done >>>>>`),Ot.dispatch(this,"submit-done",{})}catch(e){Ot.dispatch(this,"submit-error",{error:e.message})}finally{this.parameters.clear();const e=document.querySelector("[download]");e&&document.body.removeChild(e)}else Ot.dispatch(this,"error",{message:`Unknown method ${this.method}`})}_parse(e,t){let n=null;return e&&"xml"===t.getAttribute("type")&&(n=(new DOMParser).parseFromString(e,"application/xml")),e&&"json"===t.getAttribute("type")&&(n=JSON.parse(e)),e&&"text"===t.getAttribute("type")&&(n=e),n}_serialize(e,t){if("application/x-www-form-urlencoded"===this.serialization){const e=new URLSearchParams;return Array.from(t.children).forEach((t=>{e.append(t.nodeName,t.textContent)})),e}if("xml"===e){return(new XMLSerializer).serializeToString(t)}if("json"===e)return JSON.stringify(t);if("text"===e)return t;throw new Error("unknown instance type ",e)}_getHeaders(){const e=new Headers,t=this.getInstance(),n=Ot.getContentType(t,this.serialization);e.append("Content-Type",n),e.has("Accept")&&e.delete("Accept");const r=this.querySelectorAll("fx-header");return Array.from(r).forEach((t=>{const{name:n}=t,r=t.getValue();e.append(n,r)})),e}_getUrlExpr(){return this.storedTemplateExpressions.find((e=>"url"===e.node.nodeName))}_getTargetInstance(){let e;if(e=this.instance?this.model.getInstance(this.instance):this.model.getInstance("default"),!e)throw new Error(`target instance not found: ${e}`);return e}_handleResponse(e,t,n){const r=this._getTargetInstance();if("instance"===this.replace){if(!r)throw new Error(`target instance not found: ${r}`);if(this.targetref){const[t]=yt(this.targetref,r.instanceData.firstElementChild,this);console.log("theTarget",t);const n=e.firstElementChild,a=t.parentNode;a.replaceChild(n,t),console.log("finally ",a)}else if(this.into){const[t]=yt(this.into,r.instanceData.firstElementChild,this);console.log("theTarget",t),e.nodeType===Node.DOCUMENT_NODE?t.appendChild(e.firstElementChild):t.innerHTML=e}else{const t=e;r.instanceData=t}this.model.inited&&(this.model.updateModel(),this.getOwnerForm().refresh(!0))}if("download"===this.replace){const t=this._getProperty("target"),r=document.createElement("a");r.setAttribute("download",t),r.setAttribute("href",`data:${n},${e}`),document.body.appendChild(r),r.click()}if("all"===this.replace){const n=this._getProperty("target");if(n&&"_blank"===n){const t=window.open("","_blank");t.document.write(`<pre>${e}</pre>`),t.document.close()}else document.open(),document.write(e),document.close(),window.location.href=t}if("target"===this.replace&&n.startsWith("text/html")){const t=this._getProperty("target"),n=document.querySelector(t);n?n.innerHTML=e:Ot.dispatch(this,"submit-error",{message:`targetNode for selector ${t} not found`})}"redirect"===this.replace&&(window.location.href=e)}_handleError(){Ot.dispatch(this,"submit-error",{})}}customElements.get("fx-submission")||customElements.define("fx-submission",jt);class _t extends(Rt(HTMLElement)){constructor(){if(super(),this.style.display="none",this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML="",!this.hasAttribute("name"))throw new Error('required attribute "name" missing');this.name=this.getAttribute("name")}connectedCallback(){this.shadowRoot.innerHTML=""}}customElements.get("fx-header")||customElements.define("fx-header",_t);class Xt extends(Rt(HTMLElement)){constructor(){super(),this.attachShadow({mode:"open"}),this.name="",this.valueQuery="",this.value=null}connectedCallback(){this.name=this.getAttribute("name"),this.valueQuery=this.getAttribute("value")}refresh(){const e=St(this,this.valueQuery),t=yt(this.valueQuery,e,this,this.precedingVariables);[this.value]=t}setInScopeVariables(e){if(e.has(this.name))return console.error(`The variable ${this.name} is declared more than once`),void Ot.dispatch(this,"xforms-binding-error",{});e.set(this.name,this),this.inScopeVariables=new Map(e)}}customElements.get("fx-var")||customElements.define("fx-var",Xt);class qt extends(Rt(HTMLElement)){constructor(){super(),this.value=null,this.display=this.style.display,this.required=!1,this.readonly=!1,this.widget=null,this.visited=!1,this.force=!1}getWidget(){throw new Error("You have to implement the method getWidget!")}async refresh(e){e&&(this.force=!0);const t=this.value;if(!this.isNotBound()&&(this.oldVal=this.nodeset?this.nodeset:null,this.evalInContext(),this.isBound())){if(!this.nodeset){if(this.closest("[create]")){let e,t,n;if(this.ref.includes("/")){t=this.ref.substring(0,this.ref.indexOf("/"));n=wt(t,St(this.parentNode,this.ref),this),n&&n.nodeType===Node.ELEMENT_NODE&&(this.ref.includes("@")?(e=this.ref.substring(this.ref.indexOf("/")+2),n.setAttribute(e,"")):Ot.dispatch(this,"warn",{message:'"create" is not implemented for elements'}))}else{const t=St(this,this.ref);this.ref.includes("@")?(e=this.ref.substring(this.ref.indexOf("@")+1),t.setAttribute(e,"")):Ot.dispatch(this,"warn",{message:'"create" is not implemented for elements'})}}else this.setAttribute("nonrelevant","");return}if(this.modelItem=this.getModelItem(),this.modelItem instanceof Dt){if(this.hasAttribute("as")&&"node"===this.getAttribute("as")?(this.modelItem.node=this.nodeset,this.value=this.modelItem.node):this.value=this.modelItem.value,this.modelItem.boundControls.includes(this)||this.modelItem.boundControls.push(this),await this.updateWidgetValue(),this.handleModelItemProperties(),this.getOwnerForm().initialRun&&Ot.dispatch(this,"init",{}),!this.getOwnerForm().ready)return;null!==this.oldVal&&t!==this.value&&Ot.dispatch(this,"value-changed",{path:this.modelItem.path,value:this.modelItem.value})}}}refreshFromModelItem(e){}async updateWidgetValue(){throw new Error("You have to implement the method updateWidgetValue!")}handleModelItemProperties(){this.handleRequired(),this.handleReadonly(),this.getOwnerForm().ready&&this.handleValid(),this.handleRelevant()}_getForm(){return this.getModel().parentNode}_dispatchEvent(e){this.getOwnerForm().ready&&Ot.dispatch(this,e,{})}handleRequired(){this.widget=this.getWidget();const e=this.isRequired();if(!this.modelItem.required)return this.widget.removeAttribute("required"),this.removeAttribute("required"),void(e!==this.modelItem.required&&this._dispatchEvent("optional"));(this.visited||this.force)&&(""===this.modelItem.value?(this.classList.add("isEmpty"),this._toggleValid(!1)):(this.classList.remove("isEmpty"),this._toggleValid(!0))),this.widget.setAttribute("required",""),this.setAttribute("required",""),e!==this.modelItem.required&&this._dispatchEvent("required")}_updateRequired(){this.modelItem.required?((this.visited||this.force)&&(""===this.modelItem.value?(this.classList.add("isEmpty"),this._toggleValid(!1)):(this.classList.remove("isEmpty"),this._toggleValid(!0))),this.widget.setAttribute("required",""),this.setAttribute("required",""),this._dispatchEvent("required")):(this.widget.removeAttribute("required"),this.removeAttribute("required"),this._dispatchEvent("optional"))}_toggleValid(e){e?(this.removeAttribute("invalid"),this.setAttribute("valid","")):(this.removeAttribute("valid"),this.setAttribute("invalid",""))}handleReadonly(){this.isReadonly()!==this.modelItem.readonly&&(this.modelItem.readonly&&(this.widget.setAttribute("readonly",""),this.setAttribute("readonly",""),this._dispatchEvent("readonly")),this.modelItem.readonly||(this.widget.removeAttribute("readonly"),this.removeAttribute("readonly"),this._dispatchEvent("readwrite")))}handleValid(){if(this.isValid()!==this.modelItem.constraint)if(this.modelItem.constraint)this._dispatchEvent("valid"),this.setAttribute("valid",""),this.removeAttribute("invalid");else{if(this.setAttribute("invalid",""),this.removeAttribute("valid"),0!==this.modelItem.alerts.length){if(!this.querySelector("fx-alert")){const{alerts:e}=this.modelItem;e.forEach((e=>{const t=document.createElement("fx-alert");t.innerHTML=e,this.appendChild(t)}))}}this._dispatchEvent("invalid")}}handleRelevant(){const e=this.modelItem.node;if(this.removeAttribute("relevant"),this.removeAttribute("nonrelevant"),Array.isArray(e)&&0===e.length)return this._dispatchEvent("nonrelevant"),void this.setAttribute("nonrelevant","");this.isEnabled()!==this.modelItem.relevant&&(this.modelItem.relevant?(this._dispatchEvent("relevant"),this.setAttribute("relevant","")):(this._dispatchEvent("nonrelevant"),this.setAttribute("nonrelevant","")))}isRequired(){return this.hasAttribute("required")}isValid(){return!this.hasAttribute("invalid")}isReadonly(){return this.hasAttribute("readonly")}isEnabled(){return!this.hasAttribute("nonrelevant")}_fadeOut(e){e.style.opacity=1,function t(){(e.style.opacity-=.1)<0?e.style.display="none":requestAnimationFrame(t)}()}_fadeIn(e,t){e.style.opacity=0,e.style.display=t||"block",function t(){let n=parseFloat(e.style.opacity);(n+=.1)>1||(e.style.opacity=n,requestAnimationFrame(t))}()}}customElements.get("fx-abstract-control")||window.customElements.define("fx-abstract-control",qt);class Vt extends qt{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.shadowRoot.innerHTML="\n <style>\n \n :host {\n height: auto;\n font-size: 0.8em;\n font-weight: 400;\n color: red;\n }\n \n </style>\n \n <slot></slot>\n \n "}getWidget(){return this}async updateWidgetValue(){this.innerHTML=this.value}}customElements.get("fx-alert")||customElements.define("fx-alert",Vt);class Yt extends qt{constructor(){super(),this.inited=!1,this.attachShadow({mode:"open"})}static get properties(){return{...qt.properties,credentials:{type:String},initial:{type:Boolean},src:{type:String}}}_getValueFromHtmlDom(){return"selectedOptions"===this.valueProp?[...this.widget.selectedOptions].map((e=>e.value)).join(" "):this.widget[this.valueProp]}connectedCallback(){this.initial=this.hasAttribute("initial")?this.getAttribute("initial"):null,this.src=this.hasAttribute("src")?this.getAttribute("src"):null,this.loaded=!1,this.initialNode=null,this.debounceDelay=this.hasAttribute("debounce")?this.getAttribute("debounce"):null,this.updateEvent=this.hasAttribute("update-event")?this.getAttribute("update-event"):"blur",this.label=this.hasAttribute("label")?this.getAttribute("label"):null;this.credentials=this.hasAttribute("credentials")?this.getAttribute("credentials"):"same-origin",["same-origin","include","omit"].includes(this.credentials)||console.error(`fx-submission: the value of credentials is not valid. Expected 'same-origin', 'include' or 'omit' but got '${this.credentials}'`,this),this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:inline-block;\n }\n \n </style>\n ${this.renderHTML(this.ref)}\n `,this.widget=this.getWidget(),this.addEventListener("mousedown",(e=>{Ot.isWidget(e.target)||e.target?.classList.contains("fx-hint")||e.preventDefault(),this.widget.focus()}));const e=this.widget.hasAttribute("multiple")?"selectedOptions":"value";this.valueProp=this.hasAttribute("value-prop")?this.getAttribute("value-prop"):e;let t=this.widget;if(this.hasAttribute("listen-on")){const e=this.getAttribute("listen-on"),n=this.querySelector(e);n&&(t=n)}this.addEventListener("keyup",(()=>{kt.dataChanged=!0})),"enter"===this.updateEvent&&(this.widget.addEventListener("keyup",(e=>{13===e.keyCode&&(e.preventDefault(),this.setValue(this._getValueFromHtmlDom()))})),this.updateEvent="blur"),this.debounceDelay?t.addEventListener(this.updateEvent,function(e,t,n=300){let r;return(...a)=>{clearTimeout(r),r=setTimeout((()=>{t.apply(e,a)}),n)}}(this,(()=>{this.setValue(this._getValueFromHtmlDom())}),this.debounceDelay)):(t.addEventListener(this.updateEvent,(e=>{this.setValue(this._getValueFromHtmlDom())})),t.addEventListener("blur",(e=>{this.setValue(this._getValueFromHtmlDom())}),{once:!0})),this.addEventListener("return",(e=>{const t=e.detail.nodeset;e.stopPropagation(),this._replaceNode(t)})),this.widget.addEventListener("focus",(()=>{})),this.template=this.querySelector("template"),this.boundInitialized=!1,this.static=!!this.widget.hasAttribute("static")}_debounce(e,t=300){let n;return(...r)=>{const a=this;clearTimeout(n),n=setTimeout((()=>{e.apply(a,r)}),t)}}setValue(e){const t=this.getModelItem();if(this.getAttribute("class")?this.classList.add("visited"):this.setAttribute("class","visited"),t?.readonly)return void console.warn("attempt to change readonly node",t);if("node"===this.getAttribute("as")){const e=this.shadowRoot.getElementById("replace"),n=this.getWidget()[this.valueProp];return e.replace(this.nodeset,n),void(t&&n&&n!==t.value&&(t.value=n,kt.dataChanged=!0,e.actionPerformed()))}const n=this.shadowRoot.getElementById("setvalue");n.setValue(t,e),this.modelItem instanceof Dt&&!this.modelItem?.boundControls.includes(this)&&this.modelItem.boundControls.push(this),n.actionPerformed()}_replaceNode(e){e.nodeType===Node.ATTRIBUTE_NODE?this.modelItem.node.nodeValue=e.nodeValue:e.nodeType===Node.ELEMENT_NODE?this.modelItem.node.replaceWith(e.cloneNode(!0)):e.nodeType===Node.TEXT_NODE?this.modelItem.node.nodeValue=e.textContent:Ot.dispatch(this,"warn",{message:"trying to replace a node that is neither an Attribute, Elemment or Text node"})}renderHTML(e){return`\n ${this.label?`${this.label}`:""}\n <slot></slot>\n ${this.hasAttribute("as")&&"node"===this.getAttribute("as")?'<fx-replace id="replace" ref=".">':`<fx-setvalue id="setvalue" ref="${e}"></fx-setvalue>`}\n\n `}getWidget(){if(this.widget)return this.widget;let e=this.querySelector(".widget");if(e||(e=this.querySelector("input"),e&&!e.classList.contains("widget")&&e.classList.add("widget")),!e){const e=document.createElement("input");return e.classList.add("widget"),e.setAttribute("type","text"),this.appendChild(e),e}return e}async updateWidgetValue(){let{widget:e}=this;if(e||(e=this),"checked"!==this.valueProp)if("selectedOptions"!==this.valueProp)if(this.hasAttribute("as")){const t=this.getAttribute("as");if("text"===t){const t=new XMLSerializer,n=Ot.prettifyXml(t.serializeToString(this.nodeset));e.value=n}if("node"===t&&this.nodeset!==e.value){const t=this.nodeset;if(e.value&&t!==this.widget.value)return void(e.value=this.nodeset.cloneNode(!0));e.value=this.nodeset.cloneNode(!0)}}else{if(this.src&&!this.loaded&&this.modelItem.relevant)return this.initial&&(this.initialNode=wt(this.initial,this.nodeset,this)),await this._loadForeFromSrc(),void(this.loaded=!0);e.value!==this.value&&(e.value=this.value)}else{const e=new Set(this.value.split(" "));for(const t of[...this.widget.querySelectorAll("option")])e.has(t.value)?t.selected=!0:t.selected=!1}else"true"===this.value?e.checked=!0:e.checked=!1}async _loadForeFromSrc(){console.info(`%cControl ref="${this.ref}" is loading ${this.src}`,"background:#64b5f6; color:white; padding:0.5rem; display:inline-block; white-space: nowrap; border-radius:0.3rem;width:100%;");try{const e=await fetch(this.src,{method:"GET",credentials:this.credentials,mode:"cors",headers:{"Content-Type":"text/html"}});let t;t=e.headers.get("content-type").toLowerCase().startsWith("text/html")?await e.text().then((e=>(new DOMParser).parseFromString(e,"text/html"))):"done";const n=t.querySelector("fx-fore"),r=document.importNode(n,!0);r.classList.add("widget"),r.addEventListener("model-construct-done",(e=>{const t=r.querySelector("fx-instance");if(this.initial){const e=(new DOMParser).parseFromString("<data></data>","application/xml");this.initialNode=wt(this.initial,this.nodeset,this),e.firstElementChild.appendChild(this.initialNode.cloneNode(!0)),t.instanceData=e}r.model=r.querySelector("fx-model"),r.model.updateModel(),r.refresh(!0)}),{once:!0});const a=this.querySelector("input");this.hasAttribute("shadow")?(a.parentNode.removeChild(a),this.shadowRoot.appendChild(r)):this.loaded||a.replaceWith(r),n||Ot.dispatch("error",{detail:{message:`Fore element not found in '${this.src}'. Maybe wrapped within 'template' element?`}}),Ot.dispatch("loaded",{detail:{fore:n}})}catch(e){Ot.dispatch(this,"error",{origin:this,message:`control couldn't be loaded from src '${this.src}'`,level:"Error"})}}getTemplate(){return this.querySelector("template")}async refresh(e){super.refresh(e);const t=this.getWidget();this._handleBoundWidget(t),this._handleDataAttributeBinding(),Ot.refreshChildren(this,e)}_handleDataAttributeBinding(){const e=this.querySelector("[data-ref]");e&&(this.boundList=e,e.getAttribute("data-ref"),this._handleBoundWidget(e))}_handleBoundWidget(e){if(this.boundInitialized&&this.static)return;const t=e.hasAttribute("ref")?e.getAttribute("ref"):e.getAttribute("data-ref");if(e&&t){const n=yt(t,St(this,t),this),{children:r}=e;if(Array.from(r).forEach((e=>{"template"!==e.nodeName.toLowerCase()&&e.parentNode.removeChild(e)})),Array.isArray(n)&&0===n.length)return;const{template:a}=this;if(a){if("SELECT"===this.widget.nodeName&&this.widget.hasAttribute("selection")&&"open"===this.widget.getAttribute("selection")){const e=this.template.firstElementChild,t=document.createElement("option");this.widget.insertBefore(t,e)}if(0!==n.length){const e=document.createDocumentFragment();Array.from(n).forEach((t=>{const n=this.createEntry();e.appendChild(n),this.updateEntry(n,t)})),this.template.parentNode.appendChild(e)}else{const e=this.createEntry();this.template.parentNode.appendChild(e),this.updateEntry(e,n)}this.boundInitialized=!0}}}updateEntry(e,t){const n=this._getValueAttribute(e);if(!n)return;const r=n.value,a=bt(r.substring(1,r.length-1),t,e);n.value=a,this.value===a&&e.setAttribute("selected","selected");const o=e.textContent;this.evalLabel(o,t,e)}evalLabel(e,t,n){const r=e.substring(1,e.length-1);if(!r)return;const a=bt(r,t,this);n.textContent=a}createEntry(){return this.template.content.firstElementChild.cloneNode(!0)}_getValueAttribute(e){let t;return Array.from(e.attributes).forEach((e=>{-1!==e.value.indexOf("{")&&(t=e)})),t}}customElements.get("fx-control")||window.customElements.define("fx-control",Yt);class zt extends(Rt(HTMLElement)){static get properties(){return{...super.properties}}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.src=this.hasAttribute("src")?this.getAttribute("src"):null;this.shadowRoot.innerHTML="\n <style>\n \n :host {\n display: block;\n }\n \n </style>\n \n <slot></slot>\n \n ",this.getOwnerForm().registerLazyElement(this)}async refresh(e){!e&&this.hasAttribute("refresh-on-view")||this.isBound()&&(this.evalInContext(),this.modelItem=this.getModelItem(),this.modelItem&&!this.modelItem.boundControls.includes(this)&&this.modelItem.boundControls.push(this),this.handleModelItemProperties())}handleModelItemProperties(){this.handleRelevant()}_getForm(){return this.getModel().parentNode}handleRelevant(){if(!this.modelItem)return this.removeAttribute("relevant",""),this.setAttribute("nonrelevant",""),void this.dispatchEvent(new CustomEvent("disabled",{}));this.isEnabled()!==this.modelItem.enabled&&(this.modelItem.relevant?(this.removeAttribute("nonrelevant",""),this.setAttribute("relevant",""),this.dispatchEvent(new CustomEvent("enabled",{}))):(this.removeAttribute("relevant",""),this.setAttribute("nonrelevant",""),this.dispatchEvent(new CustomEvent("disabled",{}))))}isReadonly(){return!!this.hasAttribute("readonly")}isEnabled(){return"none"!==this.style.display}}customElements.get("fx-container")||window.customElements.define("fx-container",zt);class Jt extends zt{static get properties(){return{...super.properties,collapse:{type:Boolean,reflect:!0}}}constructor(){super(),this.collapse=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","group")}render(){return"\n <slot></slot>\n "}handleModelItemProperties(){this.handleRelevant()}initializeChildren(e){Array.from(e.children).forEach((e=>{if(Ot.isUiElement(e.nodeName))e.init(this.model);else if(0!==e.children.length){Array.from(e.children).forEach((e=>{this.initializeChildren(e)}))}})),console.groupEnd()}async refresh(e){super.refresh(e),Ot.refreshChildren(this,e)}}customElements.get("fx-group")||window.customElements.define("fx-group",Jt);class Qt extends qt{static get styles(){return"\n :host {\n display: block;\n height: auto;\n font-size: 0.8em;\n font-weight: 400;\n font-style: italic;\n }\n "}static get properties(){return{...super.properties}}render(){return"\n <slot></slot>\n "}}customElements.get("fx-hint")||customElements.define("fx-hint",Qt);class Kt extends qt{constructor(){super(),this.attachShadow({mode:"open"}),this.valueAttr=this.hasAttribute("value")?this.getAttribute("value"):null,this.readonly=!0}connectedCallback(){this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display: inline-block;\n max-width:100%;\n }\n #widget {\n display: inline-block;\n }\n .label{\n display: inline-block;\n }\n #value{\n max-width:100%;\n }\n \n </style>\n \n <slot name="label"></slot>\n \n <span id="value">\n <slot name="default"></slot>\n </span>\n \n ',this.mediatype=this.hasAttribute("mediatype")?this.getAttribute("mediatype"):null}async refresh(){this.ref&&await super.refresh(),this.valueAttr&&(this.value=this.getValue(),await this.updateWidgetValue())}getValue(){try{const e=St(this,this.valueAttr);return this.hasAttribute("html")?yt(this.valueAttr,e,this)[0]:function(e,t,n,r=null,a=n){try{const a=mt(e,t,n);return Je(e,t,r,{},{currentContext:{formElement:n},functionNameResolver:ft,moduleImports:{xf:ot},namespaceResolver:a})}catch(t){n.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,detail:{origin:n,message:`Expression '${e}' failed`,expr:e,level:"Error"}}))}}(this.valueAttr,e,this)[0]}catch(e){console.error(e),Ot.dispatch(this,"error",{message:e})}return null}getWidget(){return this.shadowRoot.getElementById("value")}handleReadonly(){this.setAttribute("readonly","readonly")}async updateWidgetValue(){const e=this.shadowRoot.getElementById("value");if(e.innerHTML="","html"!==this.mediatype){if("image"===this.mediatype){const t=document.createElement("img");return t.setAttribute("src",this.value),this.innerHTML="",void e.appendChild(t)}e.innerHTML=this.value}else if(this.modelItem.node){this.shadowRoot.querySelector("#default");const{node:t}=this.modelItem;if(t.nodeType)return void e.append(t);const n=(new DOMParser).parseFromString(t,"text/html").body.childNodes;return void Array.from(n).forEach((t=>{e.append(t)}))}}isReadonly(){return!0}}customElements.get("fx-output")||customElements.define("fx-output",Kt);class Wt extends(Rt(HTMLElement)){static get properties(){return{inited:{type:Boolean}}}constructor(){super(),this.inited=!1,this.addEventListener("click",this._dispatchIndexChange),this.addEventListener("focusin",this._dispatchIndexChange),this.attachShadow({mode:"open",delegatesFocus:!0})}_handleFocus(){this.parentNode.setIndex(this.index)}_dispatchIndexChange(){this.parentNode&&this.parentNode.dispatchEvent(new CustomEvent("item-changed",{composed:!1,bubbles:!0,detail:{item:this,index:this.index}}))}connectedCallback(){this.display=this.style.display;this.shadowRoot.innerHTML="\n \n <slot></slot>\n \n ",this.getOwnerForm().registerLazyElement(this),this.ref=`${this.parentNode.ref}`}disconnectedCallback(){this.removeEventListener("click",this._dispatchIndexChange()),this.removeEventListener("focusin",this._handleFocus)}init(){this.inited=!0}refresh(e){this.modelItem=this.getModelItem(),this.modelItem.boundControls.includes(this)||this.modelItem.boundControls.push(this),this.modelItem&&!this.modelItem.relevant?this.setAttribute("nonrelevant",""):this.setAttribute("relevant",""),Ot.refreshChildren(this,e)}}customElements.get("fx-repeatitem")||window.customElements.define("fx-repeatitem",Wt);class Zt extends(Rt(HTMLElement)){static get properties(){return{...super.properties,index:{type:Number},template:{type:Object},focusOnCreate:{type:String},initDone:{type:Boolean},repeatIndex:{type:Number},nodeset:{type:Array}}}constructor(){super(),this.ref="",this.dataTemplate=[],this.focusOnCreate="",this.initDone=!1,this.repeatIndex=1,this.nodeset=[],this.inited=!1,this.index=1,this.repeatSize=0,this.attachShadow({mode:"open",delegatesFocus:!0})}get repeatSize(){return this.querySelectorAll(":scope > fx-repeatitem").length}set repeatSize(e){this.size=e}setIndex(e){this.index=e;const t=this.querySelectorAll(":scope > fx-repeatitem");this.applyIndex(t[this.index-1])}applyIndex(e){this._removeIndexMarker(),e&&e.setAttribute("repeat-index","")}get index(){return this.getAttribute("index")}set index(e){this.setAttribute("index",e)}_getRef(){return this.getAttribute("ref")}connectedCallback(){this.ref=this.getAttribute("ref"),this.addEventListener("item-changed",(e=>{const{item:t}=e.detail,n=Array.from(this.children).indexOf(t);this.applyIndex(this.children[n]),this.index=n+1})),document.addEventListener("index-changed",(e=>{if(e.stopPropagation(),!e.target===this)return;const{index:t}=e.detail;this.index=Number(t),this.applyIndex(this.children[t-1])})),this.mutationObserver=new MutationObserver((e=>{if("childList"===e[0].type){const t=e[0].addedNodes[0];if(t){const e=tt.resolveInstance(this,this.ref),n=tt.getPath(t,e);Ot.dispatch(this,"path-mutated",{path:n,index:this.index})}}})),this.getOwnerForm().registerLazyElement(this);this.shadowRoot.innerHTML='\n <style>\n \n :host{\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n \n </style>\n \n <slot name="header"></slot>\n <slot></slot>\n \n '}init(){this._evalNodeset(),this._initTemplate(),this._initRepeatItems(),this.setAttribute("index",this.index),this.inited=!0}_evalNodeset(){const e=St(this.getAttributeNode("ref")||this,this.ref);this.mutationObserver&&e.nodeName&&this.mutationObserver.observe(e,{childList:!0,subtree:!0});const t=yt(this.ref,e,this);1===t.length&&Array.isArray(t[0])?this.nodeset=t[0]:this.nodeset=t}async refresh(e){this.inited||this.init(),this._evalNodeset();const t=this.querySelectorAll(":scope > fx-repeatitem"),n=t.length;let r=1;Array.isArray(this.nodeset)&&(r=this.nodeset.length);const a=r;if(a<n)for(let e=n;e>a;e-=1){const n=t[e-1];n.parentNode.removeChild(n),this.getOwnerForm().unRegisterLazyElement(n)}if(a>n)for(let e=n+1;e<=a;e+=1){const t=document.createElement("fx-repeatitem"),n=this._clone();t.appendChild(n),this.appendChild(t),this._initVariables(t),t.nodeset=this.nodeset[e-1],t.index=e,this.getOwnerForm().scanForNewTemplateExpressionsNextRefresh()}for(let e=0;e<n;e+=1){const n=t[e];this.getOwnerForm().registerLazyElement(n),n.nodeset!==this.nodeset[e]&&(n.nodeset=this.nodeset[e])}this.getOwnerForm().lazyRefresh&&!e||Ot.refreshChildren(this,e),this.setIndex(this.index)}_fadeOut(e){e.style.opacity=1,function t(){(e.style.opacity-=.1)<0?e.style.display="none":requestAnimationFrame(t)}()}_fadeIn(e){e&&(e.style.opacity=0,e.style.display=this.display,function t(){let n=parseFloat(e.style.opacity);(n+=.1)>1||(e.style.opacity=n,requestAnimationFrame(t))}())}_initTemplate(){this.template=this.querySelector("template"),null===this.template&&this.dispatchEvent(new CustomEvent("no-template-error",{composed:!0,bubbles:!0,detail:{message:`no template found for repeat:${this.id}`}})),this.shadowRoot.appendChild(this.template)}_initRepeatItems(){this.nodeset.forEach(((e,t)=>{const n=document.createElement("fx-repeatitem");n.nodeset=this.nodeset[t],n.index=t+1;const r=this._clone();n.appendChild(r),this.appendChild(n),1===n.index&&this.applyIndex(n),Ot.dispatch(this,"item-created",{nodeset:n.nodeset,pos:t+1}),this._initVariables(n)}))}_initVariables(e){const t=new Map(this.inScopeVariables);e.setInScopeVariables(t),function e(n){for(const r of n.children)"setInScopeVariables"in r&&r.setInScopeVariables(t),e(r)}(e)}_clone(){this.template=this.shadowRoot.querySelector("template");const e=this.template.content.cloneNode(!0);return document.importNode(e,!0)}_removeIndexMarker(){Array.from(this.children).forEach((e=>{e.removeAttribute("repeat-index")}))}setInScopeVariables(e){this.inScopeVariables=new Map(e)}}customElements.get("fx-repeat")||window.customElements.define("fx-repeat",Zt);class en extends zt{constructor(){super(),this.formerCase={},this.selectedCase=null,this.cases=null}connectedCallback(){super.connectedCallback&&super.connectedCallback();this.shadowRoot.innerHTML="\n <style>\n \n :host ::slotted(fx-case.selected-case){\n display: block !important;\n }\n \n </style>\n \n <slot></slot>\n \n ",this.cases=[],this.formerCase=null,this.selectedCase=null}async refresh(e){super.refresh(e),0===this.cases.length&&(this.cases=Array.from(this.querySelectorAll(":scope > fx-case"))),this.isBound()&&this._handleBoundSwitch(),this.selectedCase||(this.selectedCase=this.cases[0],this.toggle(this.selectedCase)),Ot.refreshChildren(this.selectedCase,e)}_dispatchEvents(){this.formerCase&&this.formerCase!==this.selectedCase&&Ot.dispatch(this.formerCase,"deselect",{}),this.selectedCase.classList.contains("selected-case")&&Ot.dispatch(this.selectedCase,"select",{})}_resetVisited(){const e=this.selectedCase.querySelectorAll(".visited");Array.from(e).forEach((e=>{e.classList.remove("visited")}))}_handleBoundSwitch(){Array.from(this.cases).forEach((e=>{e.getAttribute("name")===this.modelItem?.value&&this.toggle(e)}))}toggle(e){this.selectedCase=e,Array.from(this.cases).forEach((e=>{e===this.selectedCase?(e.classList.remove("deselected-case"),e.classList.add("selected-case"),e.inert=!1):(e.classList.remove("selected-case"),e.classList.add("deselected-case"),e.inert=!0,this._resetVisited())})),this.selectedCase!==e&&(this.selectedCase=e),this._dispatchEvents(),this.formerCase=this.selectedCase,this.getOwnerForm().scanForNewTemplateExpressionsNextRefresh()}}customElements.get("fx-switch")||window.customElements.define("fx-switch",en);class tn extends qt{connectedCallback(){this.attachShadow({mode:"open"}),this.ref=this.hasAttribute("ref")?this.getAttribute("ref"):null,this.debounceDelay=this.hasAttribute("debounce")?this.getAttribute("debounce"):null;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n cursor:pointer;\n }\n \n </style>\n ${this.renderHTML()}\n `;const e=this.shadowRoot.querySelector("slot");e.addEventListener("slotchange",(()=>{const t=e.assignedElements({flatten:!0});t[0].setAttribute("tabindex","0"),"BUTTON"!==t[0].nodeName&&t[0].setAttribute("role","button");const n=t[0];this.addEventListener("mousedown",(e=>{console.log("target",e.target.nodeName),e.target.focus()})),this.debounceDelay?this.addEventListener("click",function(e,t,n=300){let r;return(...a)=>{r||t.apply(e,a),clearTimeout(r),r=setTimeout((()=>(r=void 0,null)),n)}}(this,(e=>{this.performActions(e)}),this.debounceDelay)):n.addEventListener("click",(e=>this.performActions(e))),this.widget=n,"BUTTON"!==n.nodeName&&n.addEventListener("keypress",(e=>{"Space"!==e.code&&"Enter"!==e.code||this.performActions(e)}))}))}renderHTML(){return"\n <slot></slot>\n "}getWidget(){return this.widget}async updateWidgetValue(){return null}handleReadonly(){super.handleReadonly(),this.widget.hasAttribute("readonly")?this.widget.setAttribute("disabled","disabled"):this.widget.removeAttribute("disabled")}async performActions(e){const t=this.closest("fx-repeatitem");t&&t.click(),this.querySelectorAll("fx-var").forEach((e=>e.refresh()));for(let t=0;t<this.children.length;t+=1){const n=this.children[t];if("function"==typeof n.execute){if(e&&(e.preventDefault(),e.stopPropagation(),e.type&&n.event&&e.type!==n.event))return;await n.execute(e)}}}async refresh(){super.refresh()}}customElements.get("fx-trigger")||customElements.define("fx-trigger",tn);class nn extends zt{connectedCallback(){this.hasAttribute("label")&&(this.label=this.getAttribute("label")),this.hasAttribute("name")&&(this.name=this.getAttribute("name")),this.hasAttribute("selected")&&(this.selected=this.getAttribute("selected"));const e=`\n ${this.label?`<span>${this.label}</span>`:""}\n <slot></slot>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n visibility: none;\n }\n \n </style>\n ${e}\n `}}customElements.get("fx-case")||window.customElements.define("fx-case",nn);class rn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){const e=this.closest("fx-fore");this.render("\n :host {\n position:absolute;\n display: block;\n width:var(--inspector-handle-width);\n background:var(--inspector-bg);\n top:0;\n right:0;\n bottom:0;\n height: 100%;\n background: var(--inspector-bg);\n color: white;\n /*max-height: 33%;*/\n overflow: scroll;\n transition:width 0.3s ease;\n z-index:100;\n }\n :host([open]){\n width: 30%;\n }\n details{\n margin:1rem;\n }\n .main{\n padding-left:var(--inspector-handle-width);\n color:var(--inspector-color);\n overflow:scroll;\n height:100%;\n }\n pre{\n background:var(--inspector-pre-bg);\n color:var(--inspector-color);\n overflow:scroll;\n padding:0.2rem;\n }\n .handle{\n display:block;\n height:100%;\n width:var(--inspector-handle-width);\n background:var(--inspector-handle-bg);\n opacity:0.7;\n position:absolute;\n left:0;\n color:white;\n cursor:pointer;\n }\n .handle:hover{\n opacity:1;\n }\n .handle::before{\n content: 'Data Inspector';\n white-space: nowrap;\n transform: rotate(-90deg);\n display: inline-block;\n position: absolute;\n left: -85px;\n width: 200px;\n top: 40px;\n }\n summary{\n cursor:pointer;\n }\n "),e.addEventListener("refresh-done",(()=>{this.update()}))}update(){try{const e=this.shadowRoot.querySelectorAll("pre"),t=this.closest("fx-fore");Array.from(e).forEach((e=>{const n=t.getModel().getInstance(e.getAttribute("id"));"xml"===n.getAttribute("type")&&(e.innerText=this.serializeDOM(n.instanceData)),"json"===n.getAttribute("type")&&(e.innerText=JSON.stringify(n.instanceData,void 0,2))}))}catch(e){console.warn("caught problem in inspector",e.message)}}render(e){const t=this.closest("fx-fore"),n=Array.from(t.querySelectorAll("fx-instance"));this.shadowRoot.innerHTML=`\n <style>\n ${e}\n </style>\n <div class="main">\n <slot></slot>\n <span class="handle"></span>\n ${n.map((e=>`\n <details>\n <summary>${e.id}</summary>\n <pre id="${e.id}"></pre>\n </details>\n `))}\n </div>\n `;this.shadowRoot.querySelector(".handle").addEventListener("click",(e=>{this.hasAttribute("open")?this.removeAttribute("open"):this.setAttribute("open","open")}))}serializeDOM(e){if(!e)return void console.warn("no data to serialize");return at((new XMLSerializer).serializeToString(e))}}customElements.get("fx-inspector")||customElements.define("fx-inspector",rn);class an extends HTMLElement{static get properties(){return{id:String}}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.shadowRoot.innerHTML=this.render("\n :host {\n display:none;\n height: 100vh;\n width:100vw;\n position:fixed;\n left:0;\n top:0;\n right:0;\n bottom:0;\n transition:opacity 0.4s linear;\n }\n\n "),this.id=this.getAttribute("id");const e=this.querySelector(".close-dialog");e&&e.addEventListener("click",(()=>{this.classList.remove("show")})),this.setAttribute("role","dialog"),this.setAttribute("aria-modal","false"),this.focus()}render(e){return`\n <style>\n ${e}\n </style>\n <slot></slot>\n `}open(){window.addEventListener("keyup",(e=>{"Escape"===e.key&&this.hide()}),{once:!0}),this.classList.add("show")}async hide(){await Ot.fadeOutElement(this,400),this.classList.remove("show")}}customElements.get("fx-dialog")||customElements.define("fx-dialog",an);class on extends Yt{static get properties(){return{...super.properties,valueAttr:{type:String}}}constructor(){super(),this.valueAttr=this.hasAttribute("value")?this.getAttribute("value"):null}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",(e=>{if(Ot.isWidget(e.target)||(e.preventDefault(),e.stopImmediatePropagation()),"LABEL"===e.target.nodeName){ut(e.target.getAttribute("for"),this).focus()}})),this.addEventListener("mousedown",(e=>{if(this.querySelectorAll("[value]"),"LABEL"===e.target.nodeName){ut(e.target.getAttribute("for"),this).focus()}})),this.addEventListener("click",(e=>{e.preventDefault,e.stopPropagation();const t=this.querySelectorAll("[value]");let n;"LABEL"===e.target.nodeName&&(n=ut(e.target.getAttribute("for"),this),n.checked=!n.checked);let r="";Array.from(t).forEach((e=>{e.checked&&(r+=` ${e.getAttribute("value")}`)})),this.setAttribute("value",r.trim());const a=tt.getClosest("[ref]",this.parentNode);if(!a)return;const o=a.getModelItem(),s=this.shadowRoot.getElementById("setvalue");s.setValue(o,r.trim()),s.actionPerformed()}))}getWidget(){return this}async updateWidgetValue(){const e=tt.getClosest("[ref]",this.parentNode);e&&(this.value=e.value),this.setAttribute("value",this.value)}updateEntry(e,t){const n=Ot.createUUID(),r=e.querySelector("label"),a=Ot.getExpression(r.textContent);if(t.nodeType){const e=bt(a,t,this);r.textContent=e}else{const e=Ot.getExpression(a);r.textContent=t[e]}r.setAttribute("for",n);const o=e.querySelector("[value]"),s=o.value,i=Ot.getExpression(s);let l;l=t.nodeType?bt(i,t,e):t[i];const c=` ${l} `,u=` ${this.getAttribute("value")} `;o.value=l,o.setAttribute("id",n),-1!==u.indexOf(c)&&(o.checked=!0)}}customElements.get("fx-items")||customElements.define("fx-items",on);class sn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.eventName="",this.shortName="",this.shortInfo="",this.shortPath="",this.xpath=""}connectedCallback(){this.eventName=this.getAttribute("event-name"),this.shortName=this.getAttribute("short-name"),this.shortInfo=this.hasAttribute("short-info")?this.getAttribute("short-info"):"",this.xpath=this.getAttribute("xpath");const e=`\n <details class="info send">\n <summary>\n <span class="log-name"><a href="#" title="${("/"+this.xpath.substring(this.xpath.indexOf("/fx-fore"),this.xpath.length)).replaceAll("fx-","")}" data-path="${this.xpath}">${this.shortName}</a></span>\n <span class="short-info">${this.shortInfo}</span>\n <span class="event-name">${this.eventName}</span> \n </summary>\n <slot></slot>\n </details>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n height: auto;\n font-size: 0.8em;\n font-weight: 400;\n\n }\n\n a,a:link,a:visited{\n color:black;\n }\n a{\n position:relative;\n }\n a[alt]:hover::after {\n content:attr(alt);\n position:absolute; \n left:0;\n top:1em;\n border.thin solid;\n padding:0.5em;\n background:white;\n z-index:1;\n min-width:5em;\n border:thin solid;\n white-space:nowrap;\n overflow-wrap:break-word;\n }\n\n .info{\n padding:0 0.5em;\n margin:0.1rem 0;\n background:white;\n position:relative;\n border:1px solid #ddd;\n border-radius:1em; \n box-shadow: 1px 1px 5px 0px rgba(79, 136, 183, 0.8);\n }\n :host(.action) .info{\n border-radius:0;\n border-color:steelblue;\n }\n\n .info label{\n grid-area:left;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .info a{\n grid-area:right;\n justify-self:end;\n }\n .info:hover{\n outline:3px solid lightblue; \n transition:height 0.4s;\n }\n\n summary{\n padding:1em;\n display:flex;\n flex-wrap:wrap;\n padding:0.5em 0;\n cursor:pointer;\n gap:0.25em;\n }\n/*\n .log-name{\n font-size:1.2em;\n }\n .log-name, .short-info{\n width:10em;\n }\n*/\n .event-name{\n width:12em;\n text-align:right;\n }\n .short-info{\n flex:3;\n overflow:hidden;\n white-space:nowrap;\n text-overflow:ellipsis;\n }\n \n </style>\n ${e}\n `}}customElements.get("fx-log-item")||customElements.define("fx-log-item",sn);class ln extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.listenTo=[],this.listeners=[]}connectedCallback(){localStorage.getItem("fx-log-settings")?this.listenTo=JSON.parse(localStorage.getItem("fx-log-settings")):this.listenTo=ln.defaultSettings();this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display:block;\n position:relative;\n width:100%;\n border:thin solid #efefef;\n font-family: Verdana, Sans;\n\n margin:0;\n border:thin solid #ddd;\n }\n .boxes{\n column-width:14rem;\n overflow:auto;\n margin-bottom:5em;\n padding:1em;\n }\n .boxes > span{\n display:inline-block;\n width:14rem;\n }\n \n .buttons{\n position:absolute;\n top:0;\n right:0;\n }\n .buttons button{\n padding:0;\n }\n button{\n float:right;\n }\n button{\n border:none;\n background:transparent;\n width:2.25rem;\n height:2.25rem;\n cursor:pointer;\n }\n button#reset{\n padding:0;\n height:1rem;\n }\n header{\n padding:0.5rem;\n margin:0;\n border-bottom:2px solid #ddd;\n }\n #settings{\n padding:1em;\n }\n \n \n </style>\n \n <section id="settings">\n <header>log settings <button id="reset">reset</button></header>\n <div class="boxes"></div>\n </section>\n \n ';window.document.querySelector("fx-fore")||console.error("fx-fore element not found in this page.");const e=this.shadowRoot.querySelector(".boxes");this.listenTo.forEach((t=>{const n=document.createElement("span");e.append(n);const r=document.createElement("label");r.setAttribute("title",t.description),r.setAttribute("for",t.name),r.innerText=t.name;const a=document.createElement("input");a.setAttribute("type","checkbox"),a.setAttribute("name",t.name),a.setAttribute("id",t.name),t.show&&a.setAttribute("checked",""),n.append(a),n.append(r),a.addEventListener("click",(e=>{if(!e.target.checked){document.querySelector("fx-fore").removeEventListener(t.name,this._log)}const n=this.listenTo.find((e=>e.name===t.name));e.target.checked?n.show=!0:n.show=!1,localStorage.setItem("fx-log-settings",JSON.stringify(this.listenTo))}))}));this.shadowRoot.querySelector("#reset").addEventListener("click",(e=>{localStorage.removeItem("fx-log-settings"),window.location.reload()}))}static defaultSettings(){return[{name:"action-performed",show:!1,description:"fires after an action has been performed"},{name:"click",show:!1,description:""},{name:"deleted",show:!1,description:"fires after a delete action has been executed"},{name:"deselect",show:!1,description:"fires when fx-case is deselected"},{name:"dialog-hidden",show:!1,description:"fires after fx-dialog has been hidden"},{name:"dialog-shown",show:!1,description:"fired when a dialog has been shown"},{name:"error",show:!1,description:"fires after an error occurred"},{name:"execute-action",show:!0,description:"fires when an action executes"},{name:"init",show:!1,description:"fires when a control initializes"},{name:"index-changed",show:!1,description:"fires when the repeat index changes"},{name:"insert",show:!1,description:"fires when an fx-insert is executed"},{name:"instance-loaded",show:!1,description:"fires after an fx-instance has been loaded"},{name:"invalid",show:!1,description:"fires after a control became invalid"},{name:"item-changed",show:!1,description:"fires when a repeat item was changed"},{name:"item-created",show:!1,description:"fires when a repeat item was created"},{name:"loaded",show:!1,description:"fires after a fx-load has loaded"},{name:"model-construct",show:!1,description:"fires when a model gets constructed"},{name:"model-construct-done",show:!1,description:"fires after model initialization"},{name:"nonrelevant",show:!1,description:"fires after an fx-control became nonrelevant"},{name:"optional",show:!1,description:"fires after an fx-control became optional"},{name:"outermost-action-end",show:!1,description:"fires when an outermost action block is finished"},{name:"outermost-action-start",show:!1,description:"fires when an outermost action block is started"},{name:"path-mutated",show:!1,description:"fires when a path in a repeat has been mutated"},{name:"readonly",show:!1,description:"fires after an fx-control became readonly"},{name:"readwrite",show:!1,description:"fires after an fx-control became readwrite"},{name:"ready",show:!1,description:"fires after a fx-fore page has been completely initialized"},{name:"rebuild-done",show:!1,description:"fires after a rebuild has taken place"},{name:"recalculate-done",show:!1,description:"fires after a recalculate has taken place"},{name:"refresh-done",show:!1,description:"fires after a refresh has been done"},{name:"relevant",show:!1,description:"fires after a fx-control has become relevant"},{name:"reload",show:!1,description:"fires when a fx-reload action executes"},{name:"required",show:!1,description:"fires after an fx-control has become required"},{name:"return",show:!1,description:"fires after a fx-return returned"},{name:"select",show:!1,description:"fires when an fx-case has been selected"},{name:"submit",show:!1,description:"fires before a submission takes place"},{name:"submit-done",show:!1,description:"fires after a submission has successfully been executed"},{name:"submit-error",show:!1,description:"fires when a submission returned an error"},{name:"valid",show:!1,description:"fires after a fx-control has become valid"},{name:"value-changed",show:!1,description:"fires after a fx-control has changed its value"}]}_log(e,t){const n=e.target.nodeName;if("FX-ACTION-LOG"===n)return;const r=document.createElement("div");r.classList.add("log-row");const a=this._logDetails(e);if(e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype&&r.classList.add("no-detail"),r.innerHTML=a,this.outermost){if("outermost-action-start"===e.type)return;this.outermostAppender||(this.outermostAppender=document.createElement("ul"),t.append(this.outermostAppender));const n=document.createElement("li");n.append(r),this.outermostAppender.append(n)}else t.append(r);this.parentPath&&"FX-ACTION"!==n&&r.classList.add("nested");const o=e.target;r.addEventListener("click",(e=>{this._highlight(o)}));const s=r.querySelector(".event-target");s&&s.addEventListener("click",(e=>{document.querySelectorAll(".fx-action-log-debug").forEach((e=>{e.classList.remove("fx-action-log-debug")})),o.dispatchEvent(new CustomEvent("log-action",{composed:!1,bubbles:!0,cancelable:!0,detail:{target:o}})),o.classList.add("fx-action-log-debug"),o.setAttribute("data-name",o.nodeName),this._highlight(o)}))}_logDetails(e){const t=e.type,n=tt.getPath(e.target),r=n.substring(n.indexOf("/fx-fore"),n.length),a=`/${r}`,o=r.replaceAll("fx-","");switch(this.parentPath&&!a.startsWith(this.parentPath)&&(this.parentPath=null),t){case"deleted":const{deletedNodes:n}=e.detail,r=new XMLSerializer;let s="";return n.forEach((e=>{s+=r.serializeToString(e)})),`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-info="${e.detail.ref}"\n short-name="${e.target.nodeName.toLowerCase()}">\n <section class="details">\n <header>Details</header>\n <section>\n <span class="key">Deleted Nodes</span>\n <textarea class="value" rows="5">${s.trim()}</textarea>\n </section>\n </section>\n </fx-log-item>\n `;case"outermost-action-start":return"start";case"outermost-action-end":return"";case"execute-action":const i=e.detail.action;return this._renderAction(i,a,o,e);default:return`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-name="${e.target.nodeName.toLowerCase()}">\n \n <section class="details">\n ${this._listEventDetails(e)}\n </section>\n </fx-log-item>\n `}}_renderAction(e,t,n,r){switch(e.nodeName.split("-")[1],e.nodeName){case"FX-ACTION":return this.parentPath=t,`\n <fx-log-item event-name="${r.detail.event}"\n xpath="${t}"\n short-name="ACTION" class="action">\n <section class="details">\n <header>Attributes</header>\n <section>\n ${Array.from(e.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section>\n </section>\n </fx-log-item> \n `;case"FX-MESSAGE":const n=r.detail.action.messageTextContent;return`\n <fx-log-item event-name="${r.detail.event}"\n xpath="${t}"\n short-name="MESSAGE"\n short-info="${n}" class="action">\n <section class="details">\n <span>${n}</span>\n </section>\n </fx-log-item>\n `;case"FX-SEND":const a=document.querySelector(`#${r.detail.action.getAttribute("submission")}`);return`\n <fx-log-item short-name="SEND"\n short-info="${a.id}"\n event-name="${r.detail.event}"\n xpath="${t}" class="action">\n <section class="details">\n <header>Submission</header>\n <section class="attributes">\n ${Array.from(a.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section> \n </section>\n </fx-log-item>\n `;case"FX-SETVALUE":return`\n <fx-log-item short-name="SETVALUE"\n short-info="${tt.getPath(r.target.nodeset)}"\n event-name="${"FX-CONTROL"===r.target.nodeName?r.target.updateEvent:r.detail.event}"\n xpath="${t}" class="action">\n <section class="details">\n <span class="key">value</span>\n <span class="value">${r.detail.value}</span>\n </section>\n </fx-log-item>\n `;default:return`\n <fx-log-item event-name="${r.detail.event}" \n short-name="${r.target.nodeName}"\n xpath="${t}"\n class="action">\n <section class="details">\n </section>\n </fx-log-item>\n `}}_listEventDetails(e){return e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype?"":`${Object.keys(e.detail).map((e=>`<span>${e}</span>`))}`}_listAttributes(e){return""}_highlight(e){const t=e.style.backgroundColor,n=e.style.transition;e.style.transition="background 1s",e.style.backgroundColor="#FFA500",setTimeout((()=>{e.style.backgroundColor=t,setTimeout((()=>{e.style.transition=n}),400)}),400),window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e}}))}}customElements.get("fx-log-settings")||customElements.define("fx-log-settings",ln);class cn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.listenTo=[],this.listeners=[]}connectedCallback(){localStorage.getItem("fx-action-log-filters")?this.listenTo=JSON.parse(localStorage.getItem("fx-action-log-filters")):this.listenTo=ln.defaultSettings(),localStorage.getItem("fx-log-settings")?this.listenTo=JSON.parse(localStorage.getItem("fx-log-settings")):this.listenTo=ln.defaultSettings();this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display:block;\n position:relative;\n width:100%;\n border:thin solid #efefef;\n background:transparent;\n font-family: Verdana, Sans;\n margin:0;\n padding:0.25rem;\n }\n a,a:link,a:visited{\n color:black;\n }\n a{\n position:relative;\n }\n a[alt]:hover::after {\n content:attr(alt);\n position:absolute; \n left:0;\n bottom:-0.5em;\n border:thin solid;\n padding:0.5em;\n background:white;\n z-index:1;\n min-width:5em;\n border:thin solid;\n max-width:90%;\n }\n .details{\n padding:0.25em 0;\n }\n\n .key{\n width:20%;\n display:inline-block;\n min-width:5rem;\n border-bottom:1px solid #ddd;\n background:#efefef;\n vertical-align:top;\n }\n .value{\n display:inline-block;\n width:60%;\n \n }\n \n .buttons{\n position:absolute;\n top:0;\n right:0;\n }\n .buttons button{\n padding:0;\n }\n button{\n float:right;\n }\n button{\n border:none;\n background:transparent;\n width:2.25rem;\n height:2.25rem;\n cursor:pointer;\n }\n button#reset{\n padding:0;\n height:1rem;\n }\n .info{\n padding:0 0.5em;\n margin:0.1rem 0;\n background:white;\n position:relative;\n display:grid;\n grid-template-areas: "left right"\n "bottom .";\n grid-template-columns: 75% 25%;\n }\n .info a{\n grid-area:right;\n justify-self:end;\n }\n .details > section{\n display:flex;\n flex-wrap:wrap;\n padding:0.5em 0;\n }\n fx-log-item{\n }\n header{\n padding:0.5rem;\n margin:0;\n border-bottom:2px solid #ddd;\n }\n \n .info:hover{\n outline:3px solid lightblue; \n transition:height 0.4s;\n }\n\n ol{\n background: #efefef;\n padding: 0.5em 0 0 2em;\n border-left:3px solid red;\n }\n \n .event-name{\n display:inline-block;\n }\n #log{\n margin-bottom:10em;\n margin-right:2em;\n }\n .log-row{\n margin:0;\n padding:0;\n position:relative;\n font-size:0.8em;\n border-left:4px solid transparent;\n padding-left:5px;\n width:calc(100% - 2em);\n margin-bottom:0.25em;\n }\n .log-row summary{\n display:flex;\n flex-wrap:wrap;\n padding:0.5em 0;\n cursor:pointer;\n }\n .log-row summary > span {\n width:calc(90% div 3);\n }\n\n .log-name{\n position:relative;\n }\n .short-info{\n flex:3;\n overflow:hidden;\n white-space:nowrap;\n text-overflow:ellipsis;\n }\n .log-row.no-detail summary{\n position:relative;\n }\n .log-row.no-detail summary{\n list-style:none;\n padding-left:1rem;\n }\n .log-row.no-detail summary::-webkit-details-marker {\n display: none;\n }\n .log-row.nested{\n margin-left:1em;\n }\n .nested .event-name{\n display:none;\n }\n \n .setvalue .value{\n background:lightyellow;\n }\n summary{\n padding:1em;\n border-bottom:2px solid #ddd;\n }\n .outer-details{\n height:100%;\n overflow:auto;\n margin-top:2rem;\n background:rgba(250, 250, 250, 0.9);\n }\n \n .outer-details > header{\n position:absolute;\n top:-1px;\n width:calc(100% - 2rem);\n border-bottom:2px solid #ddd;\n font-size:1rem;\n height:1rem;\n }\n .outer-details > summary{\n font-size:1em;\n }\n ul{\n list-style:none;\n padding:0;\n margin:0.1em 0;\n border-left:3px solid steelblue;\n padding:0.1em 0;\n }\n ul .log-row{\n padding-left:3px;\n width:calc(100% - 1em);\n }\n \n </style>\n \n <section open class="outer-details">\n <header>Log \n <span class="buttons">\n <button id="del"" title="empty log - Ctrl+d">\n <svg viewBox="0 0 24 24" style="width:24px;height:24px;" preserveAspectRatio="xMidYMid meet" focusable="true"><g><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zm2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12zM15.5 4l-1-1h-5l-1 1H5v2h14V4z"></path></g></svg></a>\n </button>\n </span>\n </header>\n <div id="log"></div>\n </section>\n \n ';window.document.querySelector("fx-fore")||console.error("fx-fore element not found in this page.");const e=this.shadowRoot.querySelector("#log");this.listenTo.forEach((t=>{t.show&&document.addEventListener(t.name,(t=>{this._log(t,e)}))})),document.addEventListener("outermost-action-start",(e=>{this.outermost=!0}),{capture:!0}),document.addEventListener("outermost-action-end",(e=>{this.outermost=!1,this.outermostAppender=null}),{capture:!0});this.shadowRoot.querySelector("#del").addEventListener("click",(e=>{this.shadowRoot.querySelector("#log").innerHTML=""})),document.addEventListener("keydown",(e=>{e.ctrlKey&&"d"===e.key&&(this.shadowRoot.querySelector("#log").innerHTML="")}))}_defaultSettings(){this.listenTo=[{name:"action-performed",show:!1,description:"fires after an action has been performed"},{name:"click",show:!1,description:""},{name:"deleted",show:!1,description:"fires after a delete action has been executed"},{name:"deselect",show:!1,description:"fires when fx-case is deselected"},{name:"dialog-hidden",show:!1,description:"fires after fx-dialog has been hidden"},{name:"dialog-shown",show:!1,description:"fired when a dialog has been shown"},{name:"error",show:!1,description:"fires after an error occurred"},{name:"execute-action",show:!0,description:"fires when an action executes"},{name:"init",show:!1,description:"fires when a control initializes"},{name:"index-changed",show:!1,description:"fires when the repeat index changes"},{name:"insert",show:!1,description:"fires when an fx-insert is executed"},{name:"instance-loaded",show:!1,description:"fires after an fx-instance has been loaded"},{name:"invalid",show:!1,description:"fires after a control became invalid"},{name:"item-changed",show:!1,description:"fires when a repeat item was changed"},{name:"item-created",show:!1,description:"fires when a repeat item was created"},{name:"loaded",show:!1,description:"fires after a fx-load has loaded"},{name:"model-construct",show:!1,description:"fires when a model gets constructed"},{name:"model-construct-done",show:!1,description:"fires after model initialization"},{name:"nonrelevant",show:!1,description:"fires after an fx-control became nonrelevant"},{name:"optional",show:!1,description:"fires after an fx-control became optional"},{name:"outermost-action-end",show:!1,description:"fires when an outermost action block is finished"},{name:"outermost-action-start",show:!1,description:"fires when an outermost action block is started"},{name:"path-mutated",show:!1,description:"fires when a path in a repeat has been mutated"},{name:"readonly",show:!1,description:"fires after an fx-control became readonly"},{name:"readwrite",show:!1,description:"fires after an fx-control became readwrite"},{name:"ready",show:!1,description:"fires after a fx-fore page has been completely initialized"},{name:"rebuild-done",show:!1,description:"fires after a rebuild has taken place"},{name:"recalculate-done",show:!1,description:"fires after a recalculate has taken place"},{name:"refresh-done",show:!1,description:"fires after a refresh has been done"},{name:"relevant",show:!1,description:"fires after a fx-control has become relevant"},{name:"reload",show:!1,description:"fires when a fx-reload action executes"},{name:"required",show:!1,description:"fires after an fx-control has become required"},{name:"return",show:!1,description:"fired by embedded Fore controls to return their bound value"},{name:"select",show:!1,description:"fires when an fx-case has been selected"},{name:"submit",show:!1,description:"fires before a submission takes place"},{name:"submit-done",show:!1,description:"fires after a submission has successfully been executed"},{name:"submit-error",show:!1,description:"fires when a submission returned an error"},{name:"valid",show:!1,description:"fires after a fx-control has become valid"},{name:"value-changed",show:!1,description:"fires after a fx-control has changed its value"}]}_log(e,t){const n=e.target.nodeName;if("FX-ACTION-LOG"===n)return;const r=document.createElement("div");r.classList.add("log-row");const a=this._logDetails(e);if(e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype&&r.classList.add("no-detail"),r.innerHTML=a,this.outermost){if("outermost-action-start"===e.type)return;this.outermostAppender||(this.outermostAppender=document.createElement("ul"),t.append(this.outermostAppender));const n=document.createElement("li");n.append(r),this.outermostAppender.append(n)}else t.append(r);this.parentPath&&"FX-ACTION"!==n&&r.classList.add("nested");const o=e.target;r.addEventListener("click",(e=>{this._highlight(o)}));const s=r.querySelector(".event-target");s&&s.addEventListener("click",(e=>{document.querySelectorAll(".fx-action-log-debug").forEach((e=>{e.classList.remove("fx-action-log-debug")})),o.dispatchEvent(new CustomEvent("log-action",{composed:!1,bubbles:!0,cancelable:!0,detail:{target:o}})),o.classList.add("fx-action-log-debug"),o.setAttribute("data-name",o.nodeName),this._highlight(o)}))}_logDetails(e){const t=e.type,n=tt.getDocPath(e.target),r=n.substring(n.indexOf("/fx-fore"),n.length),a=`/${r}`,o=r.replaceAll("fx-","");switch(this.parentPath&&!a.startsWith(this.parentPath)&&(this.parentPath=null),t){case"deleted":const{deletedNodes:n}=e.detail,r=new XMLSerializer;let s="";return n.forEach((e=>{s+=r.serializeToString(e)})),`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-info="${e.detail.ref}"\n short-name="${e.target.nodeName.toLowerCase()}">\n <section class="details">\n <header>Details</header>\n <section>\n <span class="key">Deleted Nodes</span>\n <textarea class="value" rows="5">${s.trim()}</textarea>\n </section>\n </section>\n </fx-log-item>\n `;case"outermost-action-start":return"start";case"outermost-action-end":return"";case"execute-action":const i=e.detail.action;return this._renderAction(i,a,o,e);default:return`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-name="${e.target.nodeName.toLowerCase()}">\n \n <section class="details">\n ${this._listEventDetails(e)}\n </section>\n </fx-log-item>\n `}}_renderAction(e,t,n,r){let a;switch(e.nodeName.split("-")[1],e.nodeName){case"FX-ACTION":return this.parentPath=t,a=r.target.currentEvent?r.target.currentEvent.type:r.detail.event?r.detail.event:"",`\n <fx-log-item event-name="${a}"\n xpath="${t}"\n short-name="ACTION"\n data-path="${r.detail.path}" \n class="action">\n <section class="details">\n <header>Attributes</header>\n <section>\n ${Array.from(e.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section>\n </section>\n </fx-log-item> \n `;case"FX-MESSAGE":const n=r.detail.action.messageTextContent;return`\n <fx-log-item event-name="${r.detail.event}"\n xpath="${t}"\n short-name="MESSAGE"\n short-info="${n}" class="action">\n <section class="details">\n <span>${n}</span>\n </section>\n </fx-log-item>\n `;case"FX-SEND":const o=document.querySelector(`#${r.detail.action.getAttribute("submission")}`),s=r.detail.event?r.detail.event:"";return`\n <fx-log-item short-name="SEND"\n short-info="${o.getAttribute("id")}"\n event-name="${s}"\n xpath="${t}" class="action"\n data-path="${r.detail.path}" >\n <section class="details">\n <header>Submission</header>\n <section class="attributes">\n ${Array.from(o.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section> \n </section>\n </fx-log-item>\n `;case"FX-SETVALUE":return`\n <fx-log-item short-name="SETVALUE"\n short-info="${tt.getPath(r.target.nodeset)}"\n event-name="${"FX-CONTROL"===r.target.nodeName?r.target.updateEvent:r.detail.event?r.detail.event:""}"\n xpath="${t}"\n data-path="${r.detail.path}" class="action">\n <section class="details">\n <span class="key">value</span>\n <span class="value">${r.detail.value}</span>\n </section>\n </fx-log-item>\n `;default:return a=r.target.currentEvent?r.target.currentEvent.type:r.detail.event?r.detail.event:"",`\n <fx-log-item event-name="${a}" \n short-name="${r.target.nodeName}"\n xpath="${t}"\n data-path="${r.detail.path}" \n class="action">\n <section class="details">\n </section>\n </fx-log-item>\n `}}_listEventDetails(e){return e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype?"":`${Object.keys(e.detail).map((e=>`<span>${e}</span>`))}`}_listAttributes(e){return""}_highlight(e){const t=e.style.backgroundColor,n=e.style.transition;e.style.transition="background 1s",e.style.backgroundColor="#FFA500",setTimeout((()=>{e.style.backgroundColor=t,setTimeout((()=>{e.style.transition=n}),400)}),400),window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e}}))}}function un(e,t){e.classList.add(t)}function pn(e,t){e.classList.remove(t)}function hn(e,t){if("object"!=typeof e)throw new Error(`containsOnlyText: Expected argument node of type object, ${typeof e} given.`);let n=!1,r=null;if(t=t||!1)for(let t=0,a=e.childNodes.length;t<a&&(r=e.childNodes[t],n=r.nodeType===Node.TEXT_NODE||r.nodeType===Node.COMMENT_NODE||r.nodeType===Node.CDATA_SECTION_NODE,n);t+=1);else n=e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE||e.nodeType===Node.CDATA_SECTION_NODE;return n}function dn(e,t){const n=document.createElement(e);t=t||{};for(const e of Object.keys(t))n.setAttribute(e,t[e]);return n}function mn(e,t){const n=dn("span",{class:"adi-opt"});return n.innerHTML=`<label><input type="checkbox" data-opt="${e}">${t}</label>`,n}customElements.get("fx-action-log")||customElements.define("fx-action-log",cn);class fn{constructor(e,t){this.sourceNodeByInspectorNodeLookup=new Map,this.uiView=null,this.menuView=null,this.domView=null,this.attrView=null,this.optsView=null,this.activeElement=null,this.vertResizing=!1,this.horizResizing=!1,this.pathScrolling=null,this.elemLookup=!1,this.styleBackup="",this.xPos=0,this.delegatedEvents=[],this.options={align:"right",split:50,minSplit:30,visible:!0,saving:!1,transparent:!0,omitEmptyText:!0,makeVisible:!0,foldText:!0,nodeTypes:[Node.ELEMENT_NODE,Node.TEXT_NODE,Node.COMMENT_NODE,Node.DOCUMENT_NODE]},"#document"===t?(this.instanceId="#document",this.document=window.document,this.isInstanceViewer=!1):(this.instanceId=t.id,t&&"fx-instance"===t.localName||console.error("No instance found!"),this.document=t.getInstanceData(),this.isInstanceViewer=!0,this.options.foldText=!1),this.drawUI(e),this.registerEvents(),this.drawDOM(this.document,this.domView.querySelector(".adi-tree-view"),!0),document.addEventListener("execute-action",(e=>this.processExecuteAction))}getSelected(){if(!this.activeElement)return null;let e=document;return e=this.sourceNodeByInspectorNodeLookup.get(this.activeElement),e}loadOptions(){let e={};e=JSON.parse(window.localStorage.getItem("ADI.options"))||{};for(const t of Object.keys(e))this.options[t]=e[t]}saveOptions(){this.options.saving&&window.localStorage.setItem("ADI.options",JSON.stringify(this.options))}hasRequiredNodes(e){if("object"!=typeof e)throw new Error(`hasRequiredNodes: Expected argument node of type object, ${typeof e} given.`);if(e.hasChildNodes())for(let t=0,n=e.childNodes.length;t<n;t+=1){const n=e.childNodes[t];if(this.options.nodeTypes.includes(n.nodeType))return!0}return!1}newTreeNode(e){if("object"!=typeof e)throw new Error(`newTreeNode: Expected argument node of type object, ${typeof e} given.`);const t=this.hasRequiredNodes(e);let n=!1,r=e.nodeName.startsWith("FX-")?`adi-node ${e.nodeName.toLowerCase()}`:"";e.nodeName.startsWith("FX-")&&(r=`adi-node ${e.nodeName.toLowerCase()}`,r+=Ot.isActionElement(e.nodeName)?" action":"");const a=dn("li",{class:r});if(e===this.uiView)return null;if(t&&a.appendChild(dn("span",{class:"adi-trigger"})),this.options.omitEmptyText&&e.nodeType===Node.TEXT_NODE&&(n=function(e){if("object"!=typeof e)throw new Error(`isEmptyTextNode: Expected argument node of type object, ${typeof e} given.`);return/^\s*$/.test(e.textContent)}(e)),!n){const n=dn("span");this.sourceNodeByInspectorNodeLookup.set(n,e),this.sourceNodeByInspectorNodeLookup.set(e,n);let r=null;if(hn(e))e.nodeType===Node.COMMENT_NODE?(un(n,"adi-comment-node"),"string"==typeof n.innerText&&(n.innerText=`\x3c!-- ${e.textContent} --\x3e`)):(un(n,"adi-text-node"),n.textContent=e.textContent);else if(un(n,"adi-normal-node"),e.nodeType!==Node.DOCUMENT_NODE){const a=Array.from(e.attributes).filter((e=>!!this.isInstanceViewer||"style"!==e.name)).map((e=>`${e.name}="${e.value}"`)).join(" ");n.textContent=`<${e.nodeName.toLowerCase()}${a?` ${a}`:""}>`,t&&(r=dn("span"),un(r,"adi-end-node"),r.textContent=`</${e.nodeName.toLowerCase()}>`)}else n.textContent=e.nodeName.toLowerCase();return a.appendChild(n),e.nodeName.startsWith("FX-")&&(n.classList.add("fore-node"),n.classList.add(e.nodeName.toLowerCase())),r&&(a.appendChild(r),e.nodeName.startsWith("FX-")&&r.classList.add("fore-node")),a}return null}drawDOM(e,t,n){if("object"!=typeof e)throw new Error(`drawDOM: Expected argument root of type object, ${typeof e} given.`);let r=null,a=!0;const o=t.nodeName.startsWith("FX-")?`adi-node ${node.nodeName.toLowerCase()}`:"";n&&-1!==this.options.nodeTypes.indexOf(e.nodeType)&&(t.innerHTML="",r=this.newTreeNode(e),this.hasRequiredNodes(e)&&(r.appendChild(dn("ul",{"data-open":!0,class:o})),un(r.querySelector(".adi-trigger"),"opened")),t.appendChild(r),t=t.querySelector("ul"));for(let n=0,s=e.childNodes.length;n<s;n+=1){const s=e.childNodes[n],i=this.hasRequiredNodes(s);if(-1!==this.options.nodeTypes.indexOf(s.nodeType)&&(r=this.newTreeNode(s),r)){if(i&&(a=!this.options.foldText||!hn(s,!0),"HEAD"===s.nodeName&&(a=!1),"SELECT"===s.nodeName&&(a=!1),"FX-INSTANCE"===s.nodeName&&(a=!1),s.nodeType===Node.DOCUMENT_NODE?r.appendChild(dn("ul",{"data-open":a,class:o})):r.insertBefore(dn("ul",{"data-open":a,class:o}),r.lastChild),un(r.querySelector(".adi-trigger"),a?"opened":"closed")),t.appendChild(r),this.getSelected()===s){const e=r.querySelector("span.adi-normal-node");e?.classList?.add("adi-active-node"),this.activeElement=e,r.scrollIntoView({block:"nearest",behavior:"instant"})}i&&this.drawDOM(s,r.querySelector("ul"),!1)}}}toggleOptions(){-1!==this.optsView.className.indexOf("adi-hidden")?pn(this.optsView,"adi-hidden"):(un(this.optsView,"adi-hidden"),this.attrView.querySelector(".adi-content").innerHTML="",this.refreshUI(),this.drawDOM(document,this.domView.querySelector(".adi-tree-view"),!0),this.options.saving?this.saveOptions():window.localStorage.removeItem("ADI.options"))}drawUI(e){this.uiView=dn("div",{id:"adi-wrapper",class:this.options.transparent?"transparent":""}),this.domView=dn("div",{id:"adi-dom-view"});const t=dn("div",{class:"adi-content",id:"detailsView"}),n=dn("ul",{class:"adi-tree-view"}),r=dn("div",{class:"adi-path-wrap"}),a=dn("span",{class:"adi-path-left"}),o=dn("span",{class:"adi-path-right"});this.menuView=dn("div",{id:"adi-panel"});const s=dn("div",{class:"adi-menu-wrap"}),i=dn("a",{class:"adi-menu-config",title:"Settings"}),l=dn("a",{class:"adi-menu-lookup",title:"Lookup tool"});if(this.optsView=function(){const e=dn("div",{id:"adi-opts-view",class:"adi-hidden"}),t=dn("span",{class:"adi-opt-heading"}),n=dn("span",{class:"adi-opt-heading"}),r=dn("span",{class:"adi-opt-close"});return t.textContent="General options",n.textContent="Observed nodes",e.appendChild(t),e.appendChild(mn("saving","Enable saving of settings")),e.appendChild(mn("makeVisible","Scroll to the active element in DOM View")),e.appendChild(mn("omitEmptyText","Hide empty text nodes")),e.appendChild(mn("foldText","Fold the text nodes")),e.appendChild(mn("transparent","Enable transparent background")),e.appendChild(n),e.appendChild(mn("nodeTypes-3","Text node")),e.appendChild(mn("nodeTypes-8","Comment node")),e.appendChild(r),e}(),t.appendChild(n),this.domView.appendChild(this.menuView),this.domView.appendChild(t),r.appendChild(a),r.appendChild(o),s.appendChild(l),s.appendChild(i),this.menuView.appendChild(r),this.menuView.appendChild(s),this.uiView.appendChild(this.optsView),this.uiView.appendChild(this.domView),!this.isInstanceViewer){this.attrView=dn("div",{id:"adi-attr-view"});const e=dn("div",{class:"adi-content"});this.attrView.appendChild(e),this.uiView.appendChild(this.attrView)}e.appendChild(this.uiView),this.refreshUI(!0)}refreshUI(e){null!==this.uiView&&(e&&this.loadOptions(),e&&(this.optsView.querySelector('[data-opt="transparent"]').checked=this.options.transparent,this.optsView.querySelector('[data-opt="saving"]').checked=this.options.saving,this.optsView.querySelector('[data-opt="omitEmptyText"]').checked=this.options.omitEmptyText,this.optsView.querySelector('[data-opt="makeVisible"]').checked=this.options.makeVisible,this.optsView.querySelector('[data-opt="foldText"]').checked=this.options.foldText,this.optsView.querySelector('[data-opt="nodeTypes-3"]').checked=-1!==this.options.nodeTypes.indexOf(3),this.optsView.querySelector('[data-opt="nodeTypes-8"]').checked=-1!==this.options.nodeTypes.indexOf(8)),this.uiView.className=this.options.transparent?"transparent":"",this.domView.querySelector(".adi-content").style.height=`${this.domView.clientHeight}px`,this.isInstanceViewer||(this.attrView.querySelector(".adi-content").style.height=this.attrView.clientHeight-this.menuView.clientHeight+"px"),un(this.uiView,this.options.align))}toggleVisibilityUI(){null!==this.uiView&&(this.uiView.style.display=this.options.visible?"none":"block",this.options.visible=!this.options.visible,this.saveOptions())}drawAttrs(e){if(this.isInstanceViewer)return;const t=this.attrView.querySelector(".adi-content");t.innerHTML="";const n=document.createElement("header");n.innerText="Attributes",t.appendChild(n),[...e.attributes].forEach((e=>{"style"!==e.name&&t.appendChild(function(e,t){const n=dn("span",{class:"adi-attr"});switch(e.toLowerCase()){case"defaultaction":n.innerHTML=`<label>${e}: <select data-attr="${e}" value="${t}"><option>perform</option><option>cancel</option></label>`;break;case"delay":n.innerHTML=`<label>${e}: <input type="number" data-attr="${e}" value="${t}" readonly="readonly"></label>`;break;default:n.innerHTML=`<label>${e}: <input type="text" data-attr="${e}" value="${t}" readonly="readonly"></label>`}return n}(e.name,e.value))}))}changeAttribute(e){const t=e?e.target:window.event.srcElement,n=t.getAttribute("data-attr"),r=t.value,a=this.getSelected();""===r?a.removeAttribute(n):a.setAttribute(n,r)}changeOption(e){const t=e?e.target:window.event.srcElement,n=t.getAttribute("data-opt"),r=t.checked;if(-1!==n.indexOf("nodeTypes")){const e=parseInt(n.match(/\d+/)[0],10);r?this.options.nodeTypes.push(e):this.options.nodeTypes.splice(this.options.nodeTypes.indexOf(e),1)}else this.options[n]=r}processKey(e){if(272===((e=e||window.event).keyCode||e.which))this.toggleVisibilityUI()}verticalResize(e){if(!this.vertResizing)return;e=e||window.event,document.documentElement.style.cursor="e-resize";const t=this.options.width+this.xPos-e.clientX;t>=this.options.minWidth&&(this.options.width=t,this.xPos=e.clientX,this.refreshUI(),this.saveOptions())}horizontalResize(e){if(!this.horizResizing)return;e=e||window.event,document.documentElement.style.cursor="n-resize";const t=Math.floor(e.clientY/this.uiView.clientHeight*100);t>=this.options.minSplit&&t<=100-this.options.minSplit&&(this.options.split=t,this.refreshUI(),this.saveOptions())}processExecuteAction(e){this.refreshUI()}handleActive(e){let t=e?e.detail?.target||e.target:window.event.srcElement;const n=this.domView.querySelector(".adi-active-node");if(n&&pn(n,"adi-active-node"),!t||t.nodeType===Node.DOCUMENT_NODE)return;if(t&&t.classList&&t.classList.contains("adi-end-node")&&(t=t.parentNode.querySelector(".adi-normal-node")),this.activeElement=t,un(t,"adi-active-node"),this.options.makeVisible){this.domView.querySelector(".adi-content").scrollIntoView({block:"center",behavior:"instant"})}const r=this.getSelected();if(this.drawAttrs(r),r&&"function"==typeof r.getModelItem&&r.getModelItem()?.node){let e=r.modelItem.node;e?.nodeType===Node.ATTRIBUTE_NODE&&(e=e.ownerElement),window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e}}))}}highlightElement(e){let t=e?e.target:window.event.srcElement;t.classList.contains("adi-end-node")&&(t=t.parentNode.querySelector(".adi-normal-node"));const n=this.sourceNodeByInspectorNodeLookup.get(t);n&&n.ownerDocument===window.document&&n&&("mouseover"===e.type?(this.styleBackup=n.getAttribute("style")||"",n.setAttribute("style",`outline: 2px solid blue; ${this.styleBackup}`)):""===this.styleBackup?n.removeAttribute("style"):n.setAttribute("style",this.styleBackup))}handleLookup(e){const t=e?e.detail?.target||e.target:window.event.srcElement;if(!this.document.contains(t))return;if(t.nodeType===Node.DOCUMENT_NODE)return;if(-1!==t.className.indexOf("adi-menu-lookup"))return this.elemLookup?(pn(t,"adi-active"),this.elemLookup=!1,this.removeEvent(document.body,"mouseover",this.handleLookup,!0),this.removeEvent(document.body,"mouseout",this.handleLookup,!0),void this.removeEvent(document.body,"click",this.handleLookup,!0)):(un(t,"adi-active"),this.elemLookup=!0,this.addEventDelegate(document.body,"mouseover",this.handleLookup,!1,"*",!0,"adi-wrapper"),this.addEventDelegate(document.body,"mouseout",this.handleLookup,!1,"*",!0,"adi-wrapper"),void this.addEventDelegate(document.body,"click",this.handleLookup,!1,"*",!0,"adi-wrapper"));if("mouseover"===e.type)return this.styleBackup=t.getAttribute("style")||"",void t.setAttribute("style",`outline: 1px dashed red; ${this.styleBackup}`);if("mouseout"===e.type)return void t.setAttribute("style",this.styleBackup);this.elemLookup=!1,pn(this.menuView.querySelector(".adi-menu-lookup"),"adi-active"),t.setAttribute("style",this.styleBackup),this.removeEvent(document.body,"mouseover",this.handleLookup,!0),this.removeEvent(document.body,"mouseout",this.handleLookup,!0),this.removeEvent(document.body,"click",this.handleLookup,!0),function(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),e.cancelBubble=!0,e.returnValue=!1}(e);const n=this.sourceNodeByInspectorNodeLookup.get(t);if(!n)return;if(n&&n.click(),!n.parentNode)return;let r,a=n.parentNode;for(a.querySelector("ul")&&a.querySelector("ul").setAttribute("data-open","true");a!==this.domView.querySelector(".adi-content");)-1!==a.className.indexOf("adi-node")&&(r=a.querySelector(".adi-trigger"),r&&(pn(r,"closed"),un(r,"opened")),a=a.parentNode,a.setAttribute("data-open","true")),a=a.parentNode;this.options.makeVisible&&n.scrollIntoView({behavior:"instant",block:"nearest",inline:"nearest"}),t.scrollIntoView({behavior:"instant",block:"nearest",inline:"nearest"})}addEventDelegate(e,t,n,r,a,o,s){const i=e=>{const t=e?e.target:window.event.srcElement,r=a.substr(1);let o=!1;if(s){let e=t;for(;e!==document;){if(e.id===s)return;e=e.parentNode}}o=0===a.indexOf("#")?t.id===r:0===a.indexOf(".")?-1!==t.className.indexOf(r):"*"===a||t.nodeName.toLowerCase()===a,o&&n(e)};o&&this.delegatedEvents.push({handle:i,elem:e,fn:n,evt:t}),e.addEventListener(t,i,r)}removeEvent(e,t,n,r){if("object"!=typeof e)throw new Error(`addEvent: Expected argument elem of type object, ${typeof e} given.`);let a=null;if(r)for(let r=0,o=this.delegatedEvents.length;r<o;r+=1)if(a=this.delegatedEvents[r],a.elem===e&&a.evt===t&&a.fn===n){n=a.handle,this.delegatedEvents.splice(r,1);break}}registerEvents(){const e=()=>{if("#document"!==this.instanceId){const e=window.document.querySelector(`#${this.instanceId}`);this.document=e.getInstanceData()}this.drawDOM(this.document,this.domView.querySelector(".adi-tree-view"),!0)};document.addEventListener("instance-loaded",e),document.addEventListener("value-changed",e),document.addEventListener("ready",e),document.addEventListener("mouseup",(()=>{document.documentElement.style.cursor="default",this.vertResizing=!1,this.horizResizing=!1}),!1),document.addEventListener("mousemove",(e=>this.verticalResize(e)),!1),document.addEventListener("mousemove",(e=>this.horizontalResize(e)),!1),window.addEventListener("resize",(e=>this.refreshUI(e)),!1),document.addEventListener("keypress",(e=>this.processKey(e)),!1),document.addEventListener("log-active-element",(e=>this.handleLookup(e)),!1);this.addEventDelegate(this.domView,"click",(e=>{const t=e?e.target:window.event.srcElement,n=t.parentNode.querySelector("ul");"true"===n.getAttribute("data-open")?(pn(t,"opened"),un(t,"closed"),n.setAttribute("data-open","false")):(pn(t,"closed"),un(t,"opened"),n.setAttribute("data-open","true"))}),!1,".adi-trigger"),this.addEventDelegate(this.domView,"click",(e=>this.handleActive(e)),!1,".adi-normal-node"),this.addEventDelegate(this.domView,"click",(e=>this.handleActive(e)),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseover",(e=>{un((e?e.target:window.event.srcElement).parentNode.querySelector(".adi-normal-node"),"hover")}),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseout",(e=>{pn((e?e.target:window.event.srcElement).parentNode.querySelector(".adi-normal-node"),"hover")}),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseover",(e=>this.highlightElement(e)),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseover",(e=>this.highlightElement(e)),!1,".adi-normal-node"),this.addEventDelegate(this.domView,"mouseout",(e=>this.highlightElement(e)),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseout",(e=>this.highlightElement(e)),!1,".adi-normal-node"),this.menuView.querySelector(".adi-menu-lookup").addEventListener("click",(e=>this.handleLookup(e)),!1),document.addEventListener("handle-active",(e=>{if(e.detail.selected===this.getSelected())return;const{selected:t}=e.detail,n=this.sourceNodeByInspectorNodeLookup.get(t);if(this.options.makeVisible){const e=this.domView.querySelector(".adi-content");(n.offsetTop>=e.clientHeight||n.offsetTop<=e.scrollTop)&&(e.scrollTop=n.offsetTop-Math.floor(e.clientHeight/2))}this.drawAttrs(this.getSelected())})),document.addEventListener("execute-action",(e=>this.processExecuteAction(event)),{capture:!0}),this.addEventDelegate(this.optsView,"change",(e=>this.changeOption(e)),!1,"input"),this.addEventDelegate(this.optsView,"click",(e=>this.toggleOptions(e)),!1,".adi-opt-close"),this.menuView.querySelector(".adi-menu-config").addEventListener("click",(e=>this.toggleOptions(e)),!1),this.isInstanceViewer||this.addEventDelegate(this.attrView,"change",this.changeAttribute,!1,"input")}}class gn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.instanceName=null,this.instance=null}connectedCallback(){this.render(),this.instance?this.shadowRoot.querySelector("#focus-button").style="display: none":this.setupFocusButton()}setInstance(e){this.instance=e}disconnectedCallback(){this.adiInstance=null}setupFocusButton(){let e="",t=null;const n=()=>{""===e?t.removeAttribute("style"):t.setAttribute("style",e),t=null},r=r=>{const{target:a}=r;if("mouseover"===r.type)return e=a.getAttribute("style")||"",a.setAttribute("style",`outline: 2px solid blue; ${e}`),void(t=a);t&&n()},a=this.shadowRoot.querySelector("#focus-button");let o=!1;const s=window.document.head.appendChild(document.createElement("style")),i=()=>{o=!1,window.document.body.removeEventListener("click",l),a.classList.remove("selected-btn"),s.innerHTML="",document.body.style.cursor="auto",window.document.body.removeEventListener("mouseover",r),window.document.body.removeEventListener("mouseout",r),t&&n()},l=e=>{i(),e.preventDefault(),e.stopPropagation(),e.target!==a&&window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e.target}}))},c=()=>{o=!0,a.classList.add("selected-btn"),document.body.style.cursor="crosshair",window.document.body.removeEventListener("click",l),s.innerHTML='fx-fore::before { color:blue; content: "Sub fore!" } fx-fore {border: solid 1px blue}',window.document.body.addEventListener("click",l),window.document.body.addEventListener("mouseover",r),window.document.body.addEventListener("mouseout",r)};window.document.addEventListener("keyup",(e=>{o&&"Escape"===e.code?i():!o&&"KeyI"===e.code&&e.ctrlKey&&c()})),a.addEventListener("click",(e=>{o?i():c(),e.preventDefault(),e.stopPropagation()}))}render(){this.shadowRoot.innerHTML="\n <style>\n \n @import '../../resources/fore.css';\n \n :host {\n display:block;\n background:transparent;\n }\n body {\n -webkit-animation: bugfix infinite 1s;\n font-size:1rem;\n }\n \n @-webkit-keyframes bugfix {\n from {\n padding: 0\n }\n to {\n padding: 0\n }\n }\n .adi-content {\n position: relative;\n overflow: auto;\n box-sizing: border-box;\n -moz-box-sizing: border-box;\n height: 100% !important;\n padding:0;\n font-size:0.8em;\n }\n .adi-content header{\n padding:0.5rem;\n // background:rgba(255, 255, 255, 0.2);\n border-bottom:2px solid #ddd;\n border-collapse:collapse;\n }\n .adi-content > * {\n padding:0 0.25em;\n }\n \n #adi-wrapper {\n top: 0;\n font-family: \"Segoe UI\", Arial;\n font-size: 1.1rem;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n position:relative;\n height:calc(100% - 8rem);\n display:flex;\n }\n \n #adi-wrapper.left {\n left: 0\n }\n \n #adi-wrapper.right {\n right: 0\n }\n \n #adi-wrapper.transparent {\n background: rgba(250, 250, 250, 0.9)\n }\n \n #adi-panel {\n position:fixed;\n top:0;\n /*bottom: 0;*/\n right: 0;\n height: 24px;\n background: #d4d4d4;\n border-top: 1px solid #bbc5c9\n }\n \n #adi-panel .adi-path-wrap {\n position:absolute;\n bottom: 0;\n left: 0;\n width: 80%;\n height: 24px;\n padding: 0 13px 0 18px;\n line-height: 24px;\n overflow: hidden;\n box-sizing: border-box;\n -moz-box-sizing: border-box\n }\n \n #adi-panel .adi-path-wrap.adi-overflowing .adi-path-left, \n #adi-panel .adi-path-wrap.adi-overflowing .adi-path-right {\n display: block\n }\n \n #adi-panel .adi-path {\n height: 24px;\n overflow: hidden;\n white-space: nowrap\n }\n \n #adi-panel .adi-path-left, #adi-panel .adi-path-right {\n display: none;\n position: absolute;\n top: 0;\n width: 8px;\n height: 24px;\n background-repeat: no-repeat;\n background-position: center center;\n opacity: .7\n }\n \n #adi-panel .adi-path-left:hover, #adi-panel .adi-path-right:hover {\n opacity: 1\n }\n \n #adi-panel .adi-path-left {\n left: 7px;\n background-image: url('img/left_shift.png')\n }\n \n #adi-panel .adi-path-right {\n position:absolute;\n right: 2px;\n background-image: url('/resources/scripts/dom-inspector/img/right_shift.png')\n }\n \n #adi-panel .adi-menu-wrap {\n bottom: 0;\n right: 24px;\n width: 50px;\n height: 24px\n }\n \n #adi-panel .adi-menu-lookup, #adi-panel .adi-menu-config {\n display: block;\n float: left;\n width: 24px;\n height: 24px;\n border-left: 1px solid #bbc5c9;\n background-position: center center;\n background-repeat: no-repeat;\n opacity: .7;\n border-radius: 0\n }\n \n #adi-panel .adi-menu-lookup:hover, #adi-panel .adi-menu-config:hover {\n background-color: #c5d9d8;\n opacity: 1\n }\n \n #adi-panel .adi-menu-lookup.adi-active, #adi-panel .adi-menu-config.adi-active {\n background-color: #fafafa;\n opacity: 1\n }\n \n #adi-panel .adi-menu-lookup {\n background-image: url('/resources/scripts/dom-inspector/img/lookup.png')\n }\n \n #adi-panel .adi-menu-config {\n background-image: url('/resources/scripts/dom-inspector/img/config.png')\n }\n \n \n \n #adi-vert-split {\n position: fixed;\n top: 0;\n width: 4px;\n height: 100%;\n cursor: e-resize;\n border-width: 0 1px 0 0;\n background: #bbc5c9;\n border-color: #768285;\n border-style: solid;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n \n #adi-vert-split:hover {\n background: #c5d9d8;\n }\n \n \n #adi-dom-view {\n border-right:2px solid #ddd;\n overflow:auto;\n flex-grow:3;\n }\n \n #adi-dom-view ul {\n margin: 0;\n padding: 0;\n list-style: none\n }\n \n #adi-dom-view ul[data-open=true] {\n display: block\n }\n \n #adi-dom-view ul[data-open=false] {\n display: none\n }\n \n #adi-dom-view ul ul {\n margin: 4px 0\n }\n \n #adi-dom-view ul li {\n padding-left: 1em;\n padding-bottom: 0.125em;\n margin: 0;\n padding-top: 0.125em; \n }\n \n \n \n \n \n \n \n #adi-dom-view .adi-normal-node, \n #adi-dom-view .adi-end-node {\n margin-right: 5px;\n padding: 0 6px 0px;\n background: #d2e8ff;\n border-radius: 8px;\n cursor: default;\n font-size:0.8rem;\n }\n #adi-dom-view .adi-text-node:after, #adi-dom-view .adi-comment-node:after {\n content: '\"'\n }\n \n #adi-dom-view .adi-text-node:before, #adi-dom-view .adi-comment-node:before {\n content: '\"'\n }\n \n #adi-dom-view .adi-comment-node {\n color: #999;\n font-style: italic\n }\n \n #adi-dom-view .adi-text-node, #adi-dom-view .adi-comment-node {\n display: block;\n padding: 3px 8px;\n color: #444;\n background: #fff;\n border-radius: 8px\n }\n \n #adi-dom-view .adi-normal-node:hover, \n #adi-dom-view .adi-normal-node.hover, \n #adi-dom-view .adi-end-node:hover, \n #adi-dom-view .adi-end-node.hover {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-normal-node:hover ~ span,\n #adi-dom-view .adi-normal-node.hover ~ span,\n #adi-dom-view .adi-end-node:hover ~ span,\n #adi-dom-view .adi-end-node.hover ~ span {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-normal-node.adi-active-node, \n #adi-dom-view .adi-end-node.adi-active-node {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-normal-node.adi-active-node ~ span,\n #adi-dom-view .adi-end-node.adi-active-node ~ span {\n background: var(--paper-grey-700);\n color:white;\n }\n \n \n \n \n \n \n #adi-dom-view .adi-trigger {\n display: inline-block;\n width: 10px;\n height: 10px;\n margin: 0 5px 0 -13px;\n opacity: .7\n }\n \n #adi-dom-view .adi-trigger.closed {\n // background: url('/resources/scripts/dom-inspector/img/node_closed.png') no-repeat;\n } \n #adi-dom-view .adi-trigger.closed::before {\n content:'\\25B8';\n }\n \n #adi-dom-view .adi-trigger.opened {\n // background: url('/resources/scripts/dom-inspector/img/node_opened.png') no-repeat\n }\n #adi-dom-view .adi-trigger.opened::before{\n content:'\\25BE';\n }\n \n #adi-dom-view .adi-trigger:hover {\n opacity: 1\n }\n \n #adi-opts-view {\n position: relative;\n height: 100%;\n padding: 0 15px;\n background: #fff\n }\n \n #adi-opts-view.adi-hidden {\n display: none\n }\n \n #adi-opts-view .adi-opt-heading, #adi-opts-view .adi-opt {\n display: block;\n padding: 5px 0\n }\n \n #adi-opts-view .adi-opt-heading {\n padding: 20px 0 10px;\n font-size: 1rem;\n }\n \n #adi-opts-view .adi-opt-heading:first-child {\n padding-top: 10px\n }\n \n #adi-opts-view .adi-opt input {\n margin-right: 6px\n }\n \n #adi-opts-view .adi-opt-close {\n position: absolute;\n top: 5px;\n right: 28px;\n width: 16px;\n height: 16px;\n background: url('/resources/scripts/dom-inspector/img/options_close.png') no-repeat;\n opacity: .7;\n }\n \n #adi-opts-view .adi-opt-close:hover {\n opacity: 1;\n }\n \n #adi-attr-view {\n top: 0.5rem;\n border: 1px solid #ddd;\n overflow: auto;\n padding: 0.25em;\n height: calc(90% - 1em);\n min-width: 10rem;\n position: absolute;\n z-index: 10;\n right: 0.5rem;\n background:rgba(255,255,255,0.85);\n }\n #adi-attr-view > .adi-content{\n height:calc(100% - 5em);\n overflow:auto;\n }\n \n #adi-attr-view .adi-attr {\n display: block;\n padding: 0.25em;\n }\n \n #adi-attr-view hr {\n height: 1px;\n border: none\n }\n \n #adi-attr-view input[type=text] {\n width: calc(100% - 0.5em);\n margin-top: 3px;\n padding: 2px;\n }\n \n #adi-horiz-split {\n height: 4px;\n cursor: n-resize;\n border-width: 0 0 1px 0;\n background: #bbc5c9;\n border-color: #768285;\n border-style: solid;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n \n #adi-horiz-split:hover {\n background: #c5d9d8;\n }\n \n #adi-dom-view .fore-node{\n background: var(--paper-blue-700);\n font-size:1.1em;\n color:white;\n }\n #adi-dom-view .adi-normal-node.fore-node:hover {\n background: var(--paper-grey-700);\n color:white;\n }\n #adi-dom-view .adi-end-node.fore-node{\n background: var(--paper-blue-700);\n font-size:1em;\n color:white;\n }\n\n #adi-dom-view .adi-node .adi-active-node.fore-node,\n #adi-dom-view .adi-node.action .adi-active-node.fore-node,\n #adi-dom-view .adi-node.action .adi-active-node.fore-node ~ .adi-end-node\n {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-node.fx-fore{\n background:var(--paper-blue-grey-50); \n }\n #adi-dom-view .adi-node.fx-model{\n background:var(--paper-blue-grey-100); \n padding:0.25em 0;\n } \n \n #adi-dom-view .adi-node.action .fore-node {\n background:var(--paper-blue-grey-100);\n color:black;\n font-family:monospace;\n }\n \n .toggleView{\n /*width:20px;*/\n /*height: 20px;*/\n }\n input, select{\n display: block;\n }\n header{\n background:rgba(255, 255, 255, 0.2);\n }\n\n .selected-btn { color: orange }\n \n </style>\n \n <slot name=\"header\"></slot>\n <button id=\"focus-button\">Focus</button>\n <slot></slot>\n \n ",!this.hasAttribute("instance")||this.getAttribute("instance"),this.adiInstance=new fn(this.shadowRoot,this.hasAttribute("instance")?this.instance:"#document")}verticalResize(e){if(!this.vertResizing)return;e=e||window.event,document.documentElement.style.cursor="e-resize";const t=this.options.width+this.xPos-e.clientX;t>=this.options.minWidth&&(this.options.width=t,this.xPos=e.clientX,this.refreshUI(),this.saveOptions())}}customElements.get("fx-dom-inspector")||customElements.define("fx-dom-inspector",gn);class yn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.instanceElement=null,this.foreSelector=null}connectedCallback(){this.container=this.querySelector(".json-path-picker-container"),this.foreSelector=this.hasAttribute("fore")?this.getAttribute("fore"):"fx-fore",this.render()}render(){const e=this.hasAttribute("instance")?this.getAttribute("instance"):"default";if(!document.querySelector(this.foreSelector))throw new Error(`this '${this.foreSelector}' does not match a fx-fore element`);this.shadowRoot.innerHTML=`\n <style>\n \n @import '../../resources/fore.css';\n \n :host {\n display:block;\n font-size:0.8em;\n background:rgba(250, 250, 250, 0.9);\n }\n .container{\n margin-left:1em;\n }\n .header{\n margin-left:0;\n }\n\n ::slot[name='header']{\n margin-left:-1em;\n }\n /* Syntax highlighting for JSON objects */\n ul.json-dict, ol.json-array {\n list-style-type: none;\n margin: 0 0 0 1px;\n border-left: 1px dotted #ccc;\n padding-left: 2em;\n }\n .json-string {\n // color: #0B7500;\n }\n .json-literal {\n color: #1A01CC;\n font-weight: bold;\n }\n \n /* Toggle button */\n a.json-toggle {\n position: relative;\n color: inherit;\n text-decoration: none;\n }\n a.json-toggle:focus {\n outline: none;\n }\n a.json-toggle:before {\n content: "\\25BC"; /* down arrow */\n position: absolute;\n display: inline-block;\n width: 1em;\n left: -1.2em;\n font-size:0.8em;\n }\n a.json-toggle.collapsed:before {\n content: "\\25B6"; /* left arrow */\n }\n \n /* Collapsable placeholder links */\n a.json-placeholder {\n color: #aaa;\n padding: 0 1em;\n text-decoration: none;\n }\n a.json-placeholder:hover {\n text-decoration: underline;\n }\n \n /* Copy path icon */\n .pick-path {\n color: lightgray;\n cursor: pointer;\n margin-left: 3px;\n }\n \n .pick-path:hover {\n color: darkgray;\n }\n \n \n </style>\n <slot name="header">\n <header class="header">${e}</header>\n </slot>\n <slot></slot>\n \n <div class="container"></div>\n \n `;const t=document.querySelector(`#${e}`);if(!t||"FX-INSTANCE"!==t.nodeName||"json"!==t.getAttribute("type"))throw new Error(`this '${e}' does not match an fx-instance element or is not of type JSON`);const n=this.shadowRoot.querySelector(".container"),r=t.instanceData;let a=this.json2html(r,{outputWithQuotes:!0});this.isCollapsable(r)&&(a="<a href='#' class=\"json-toggle\"></a>".concat(a)),n.innerHTML=a;this.shadowRoot.querySelectorAll(".json-toggle").forEach((e=>{e.addEventListener("click",this._handleToggleEvent.bind(this))}))}disconnectedCallback(){}_isHidden(e){var t=e.offsetWidth,n=e.offsetHeight;return 0===t&&0===n||"none"===window.getComputedStyle(e).display}_handleToggleEvent(e){const t=e.target;t.classList.toggle("collapsed");for(var n=this._siblings(t,"ul.json-dict, ol.json-array",(function(e){e.style.display=""===e.style.display||"block"===e.style.display?"none":"block"})),r=0;r<n.length;r+=1)if(this._isHidden(n[r])){for(var a=n[r].children,o=0,s=0;s<a.length;s+=1)"LI"===a[s].tagName&&(o+=1);var i=o+(o>1?" items":" item");n[r].insertAdjacentHTML("afterend",'<a href class="json-placeholder">'.concat(i,"</a>"))}else this._siblings(n[r],".json-placeholder",(function(e){return e.parentNode.removeChild(e)}));e.stopPropagation(),e.preventDefault()}_siblings(e,t,n){for(var r=[],a=0;a<e.parentNode.children.length;a+=1){var o=e.parentNode.children[a];o!==e&&"string"==typeof t&&o.matches(t)&&r.push(o)}if(n&&"function"==typeof n)for(var s=0;s<r.length;s+=1)n(r[s]);return r}json2html(e,t){let n="";if("string"==typeof e){const t=e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");this.isUrl(t)?n+='<a href="'.concat(t,'" class="json-string">').concat(t,"</a>"):n+='<span class="json-string">"'.concat(t,'"</span>')}else if("number"==typeof e)n+='<span class="json-literal">'.concat(e,"</span>");else if("boolean"==typeof e)n+='<span class="json-literal">'.concat(e,"</span>");else if(null===e)n+='<span class="json-literal">null</span>';else if(e instanceof Array)if(e.length>0){n+='[<ol class="json-array">';for(var r=0;r<e.length;r+=1)n+='<li data-key-type="array" data-key="'.concat(r,'">'),this.isCollapsable(e[r])&&(n+='<a href="#" class="json-toggle"></a>'),n+=this.json2html(e[r],t),r<e.length-1&&(n+=","),n+="</li>";n+="</ol>]"}else n+="[]";else if("object"===this._typeof(e)){let r=Object.keys(e).length;if(r>0){for(var a in n+='{<ul class="json-dict">',e)if(e.hasOwnProperty(a)){n+='<li data-key-type="object" data-key="'.concat(a,'">');const o=t.outputWithQuotes?'<span class="json-string">"'.concat(a,'"</span>'):a;this.isCollapsable(e[a])?n+="<a href='#' class=\"json-toggle\">".concat(o,"</a>"):n+=o,n+=": ".concat(this.json2html(e[a],t)),r-=1,r>0&&(n+=","),n+="</li>"}n+="</ul>}"}else n+="{}"}return n}isUrl(e){return/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#:.?+=&%@!\-/]))?/.test(e)}_typeof(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?this._typeof=function(e){return typeof e}:this._typeof=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},this._typeof(e)}isCollapsable(e){return e instanceof Object&&Object.keys(e).length>0}static get observedAttributes(){return["data"]}attributeChangedCallback(e,t,n){"data"===e&&(this.jsonTextarea.value=n,this.updateTree(n))}updateTree(e){try{this.data=JSON.parse(e),this.treeView.innerHTML="",this.treeView.appendChild(this.createTreeView(this.data,""))}catch(e){console.error(e),alert("Invalid JSON")}}createTreeView(e,t){let n=document.createElement("ul");if(n.classList.add("jp-ul"),Array.isArray(e))e.forEach(((e,r)=>{let a=document.createElement("li");a.classList.add("jp-li");let o=t+"["+r+"]";a.appendChild(this.createItemView(o,e)),n.appendChild(a)}));else if("object"==typeof e&&null!==e)Object.keys(e).forEach((r=>{let a=document.createElement("li");a.classList.add("jp-li");let o=t+"."+r;a.appendChild(this.createItemView(o,e[r])),n.appendChild(a)}));else{let r=document.createElement("li");r.classList.add("jp-li"),r.appendChild(this.createItemView(t,e)),n.appendChild(r)}return n}}customElements.get("fx-json-instance")||customElements.define("fx-json-instance",yn);class wn extends HTMLElement{static get properties(){return{fore:{type:Object,description:"The fx-fore element the devtools are attached to"},instances:{type:Array,description:"Instances of selected Fore element"},selector:{type:String,description:"optional selector to attach to a certain fx-fore element with given id"}}}constructor(){super(),this.attachShadow({mode:"open"}),Object.keys(this.constructor.properties).forEach((e=>{const t=this.constructor.properties[e],n=t.attribute||e,r=this.getAttribute(n)||t.default,a=t.type(r);this[e]=a})),this.isResizing=!1,this.lastY=0,this.defaultHeight="40vh",this.buttonByInstanceId=new Map;const e=e=>{this.fore=e,this.instances=[...this.fore.getModel().instances];const t=this.shadowRoot.querySelector(".instances header");t.textContent="Data ",this.instances.forEach((e=>{const n=document.createElement("button");n.setAttribute("type","button"),n.textContent=e.id,t.appendChild(n),this.buttonByInstanceId.set(e.id,n),n.addEventListener("click",(()=>this.selectInstance(e.id)))})),this.instances.length&&this.selectInstance(this.instances[0].id)},t=document.querySelector("fx-fore");t&&(t.inited?e(t):t.addEventListener("model-construct-done",(()=>e(t)))),window.document.addEventListener("log-active-element",(t=>{const n=t?t.detail?.target||t.target:window.event.srcElement,r=n.nodeType===Node.DOCUMENT_NODE?null:n.closest("fx-fore");r&&e(r);const a=this.instances.find((e=>"xml"===e.type&&e.instanceData.contains(n)));a&&this.selectInstance(a.id)}))}_getInstanceForTarget(e){this.instances.forEach((t=>"xml"===t.type&&t.instanceData.contains(e)||"json"===t.type?t:void 0))}selectInstance(e){const t=this.buttonByInstanceId.get(e);if(!t)return;if(t.classList.contains("selected-btn"))return;const n=this.shadowRoot.querySelector(".selected-btn");n&&n.classList.remove("selected-btn"),t.classList.add("selected-btn");const r=this.shadowRoot.querySelector(".instance-panel");r.innerHTML="",this.instances=[...this.fore.querySelectorAll("fx-instance")];const a=Array.from(this.instances).find((t=>t.id===e)),o=this._renderInstancePanel(a);r.append(o)}connectedCallback(){this.render()}_startResize(e){this.isResizing=!0,this.lastY=e.clientY}_resizePanel(e){if(!this.isResizing)return;const t=e.clientY-this.lastY;this.style.height=this.offsetHeight-t+"px",this.lastHeight=this.style.height,this.lastY=e.clientY}_stopResize(e){e.preventDefault(),e.stopPropagation(),this.isResizing=!1,document.body.style.height="inherit",document.body.style.width="inherit";const t=document.body.scrollHeight+this.offsetHeight;document.body.style.height=`${t}px`}render(){const e=`\n <section class="wrapper">\n <slot></slot>\n <details class="fx-devtools" open>\n <div class="resizer"></div>\n <summary>Fore Glass \n <div>\n <svg preserveAspectRatio="xMidYMid meet" focusable="true" style="width: 24px;height: 24px; margin-bottom:-1px;" width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg">\n <g role="button" id="find-in-page"><path d="M20 19.59V8l-6-6H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c.45 0 .85-.15 1.19-.4l-4.43-4.43c-.8.52-1.74.83-2.76.83-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5c0 1.02-.31 1.96-.83 2.75L20 19.59zM9 13c0 1.66 1.34 3 3 3s3-1.34 3-3-1.34-3-3-3-3 1.34-3 3z"></path></g>\n </svg>\n <button class="optionsBtn" id="optionsTrigger">&#9881;</button> \n </div>\n </summary>\n <section class="panels">\n <section class="log">\n <fx-action-log selector="${this.selector}"></fx-action-log>\n </section>\n <section class="dom">\n <fx-dom-inspector>\n <header slot="header">Document</header>\n </fx-dom-inspector>\n </section>\n <section class="instances">\n <header></header>\n <div class="instance-panel">\n </div>\n </section>\n <section id="options">\n <fx-log-settings></fx-log-settings>\n </section>\n </section>\n </details>\n </section>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n @import '../../resources/fore.css';\n \n :host {\n display:block;\n position:fixed;\n bottom:0;\n left:0;\n width:100vw;\n height:var(--fx-devtools-height);\n font-style:inherit;\n font-family: 'Verdana' , 'Sans';\n font-size:1em;\n max-width:100vw;\n height:3em;\n }\n :host(.open){\n height:40vh;\n }\n \n fx-action-log{\n height:100%;\n }\n fx-dom-inspector{\n max-height:100%;\n height:100%;\n position:relative;\n }\n body {\n }\n details{\n height:100%;\n background:#ebf6ff;\n }\n .dom{\n width:45%;\n border-left:1px solid #999;\n position:relative\n }\n .dom fx-minimap{\n position:absolute;\n right:0;\n top:0;\n width:5rem;\n height:6rem;\n }\n header{\n padding:0.5rem;\n border-bottom:2px solid #ddd;\n font-size:1rem;\n }\n header button{\n margin:0 0.5em;\n border:thin solid #999;\n padding:0 0.5em;\n cursor:pointer;\n }\n header button:hover{\n background:white;\n }\n \n header button.selected-btn{\n background:steelblue;\n color:white;\n }\n .instances{\n width:35%;\n border-left:1px solid #999;\n }\n .instance-panel{\n height:100%;\n overflow:auto;\n }\n .panels{\n display:grid;\n grid-template-columns:20% 50% 30%;\n height:100%;\n width:100%;\n max-height:100%;\n border-top:thin solid #ddd;\n }\n .panels > section {\n min-height:20rem;\n/*\n background:#efefef;\n*/\n position:relative;\n display:inline-block;\n height:100%;\n width:auto;\n }\n #options{\n display:none;\n }\n #options.open{\n position:absolute;\n z-index:10;\n left:0;\n top:3em;\n height:100%;\n display:block;\n padding:0;\n background:rgba(255,255,255,0.95);\n width:100%;\n }\n .optionsBtn{\n font-size:2rem;\n }\n details[open] .optionsBtn{\n display:inline;\n }\n .resizer{\n width:100vw;\n height:6px;\n background:rgba(215,220,235,0.3);\n cursor: ns-resize;\n position:absolute;\n top:0;\n \n }\n summary{\n height:3rem;\n padding:0 1em;\n border-bottom:2px solid #ddd;\n display:flex;\n justify-content:space-between;\n align-items:center;\n color:rgba(0,0,0,0.7);\n background: rgba(235, 255, 255, 0.2);\n box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);\n backdrop-filter: blur(5px);\n -webkit-backdrop-filter: blur(5px);\n border: 1px solid rgba(255, 255, 255, 0.3);\n \n color:white;\n font-weight:300;\n background: rgb(119,119,119);\n background: linear-gradient(90deg, rgba(0,85,159,0.75) 0%, rgba(56,154,252,0.5) 50%, rgba(255,255,255,0.1) 100%);\n\n }\n summary button{\n padding:0;\n border:0;\n background:transparent;\n }\n .wrapper{\n height:100%;\n }\n .vertDevider{\n background:#ddd;\n width:4px;\n height:100%;\n cursor: ew-resize;\n }\n \n </style>\n ${e}\n `,this.resizer=this.shadowRoot.querySelector(".resizer"),this.resizer.addEventListener("mousedown",this._startResize.bind(this)),document.addEventListener("mousemove",this._resizePanel.bind(this)),document.addEventListener("mouseup",this._stopResize.bind(this));const t=this.shadowRoot.querySelector("#optionsTrigger");t.addEventListener("click",(()=>{const e=this.shadowRoot.querySelector("#options");e.classList.toggle("open"),e.classList.contains("open")?t.style.background="lightsteelblue":t.style.background="transparent"}));this.shadowRoot.querySelector(".fx-devtools").addEventListener("click",(e=>{"DIV"===e.target.nodeName&&e.target.classList.contains("resizer")||(e.target.parentNode.open?(this.removeAttribute("open"),this.lastHeight=this.style.height,this.style.height="3em"):(this.setAttribute("open",""),this.style.height=this.lastHeight?this.lastHeight:"40vh"))})),this.classList.add("open")}_handleOpen(e){document.body.style.height=""}_renderInstancePanel(e){if("xml"===e.type){const t=document.createElement("fx-dom-inspector");return t.setInstance(e),t.setAttribute("instance",e.id),t}if("json"===e.type){const t=document.createElement("fx-json-instance");t.setAttribute("instance",e.id);const n=document.createElement("span");return n.setAttribute("slot","header"),t.append(n),t}}}customElements.get("fx-devtools")||customElements.define("fx-devtools",wn);class vn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.src=""}connectedCallback(){this.src=this.getAttribute("src");const e=`\n <fx-fore src="${this.src}">\n </fx-fore>\n <slot id="default"></slot>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n display:block;\n }\n \n </style>\n ${e}\n `;this.shadowRoot.querySelector("#default").addEventListener("slotchange",(async e=>{const t=e.target.assignedElements().filter((e=>"LINK"===e.nodeName.toUpperCase()));if(!t)return;const n=[...document.styleSheets].map((e=>{if(t.find((t=>t.href===e.href)))try{return[...e.cssRules].map((e=>e.cssText)).join("")}catch(t){console.log("Access to stylesheet %s is denied. Ignoring…",e.href)}})).filter(Boolean).join("\n"),r=new CSSStyleSheet;r.replaceSync(n),this.shadowRoot.adoptedStyleSheets=[r]}));const t=this.querySelector("fx-action");if(t){const e=t.cloneNode(!0);this.removeChild(t);this.shadowRoot.querySelector("fx-fore").appendChild(e)}}}async function xn(e){return new Promise((t=>setTimeout((()=>t()),e)))}customElements.get("fore-component")||customElements.define("fore-component",vn);class bn extends(Rt(HTMLElement)){static get properties(){return{...super.properties,defaultAction:{type:String},delay:{type:Number},detail:{type:Object},event:{type:Object},handler:{type:Object},ifExpr:{type:String},needsUpdate:{type:Boolean},observer:{type:Object},phase:{type:String},propagate:{type:String},target:{type:String},whileExpr:{type:String}}}constructor(){super(),this.detail={},this.needsUpdate=!1}connectedCallback(){this.style.display="none",this.propagate=this.hasAttribute("propagate")?this.getAttribute("propagate"):"continue",this.repeatContext=void 0,this.hasAttribute("event")&&(this.event=this.getAttribute("event")),this.hasAttribute("defaultAction")?this.defaultAction=this.getAttribute("defaultAction"):this.defaultAction="perform",this.hasAttribute("phase")?this.phase=this.getAttribute("phase"):this.phase="default",this.ifExpr=this.hasAttribute("if")?this.getAttribute("if"):null,this.whileExpr=this.hasAttribute("while")?this.getAttribute("while"):null,this.delay=this.hasAttribute("delay")?Number(this.getAttribute("delay")):0,this._addUpdateListener()}_addUpdateListener(){if(this.target=this.getAttribute("target"),this.target)if("#window"===this.target)window.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase});else if("#document"===this.target)document.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase});else{if(this.targetElement=ut(this.target,this),!this.targetElement)return;this?.targetElement.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase})}else this.targetElement=this.parentNode,this.targetElement.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase})}async performSafe(){try{return await this.perform(),!0}catch(e){return await Ot.dispatch(this,"error",{origin:this,message:"Action execution failed",expr:tt.getDocPath(this),level:"Error"}),!1}}async execute(e){if(console.log(this,this.event),e&&e.target.nodeType!==Node.DOCUMENT_NODE&&e.target!==window&&e.target.closest("fx-fore")&&e.target.closest("fx-fore")!==this.closest("fx-fore"))return;"stop"===this.propagate&&e.stopPropagation(),"cancel"===this.defaultAction&&e.preventDefault();let t=()=>{};e&&e.listenerPromises&&e.listenerPromises.push(new Promise((e=>{t=e}))),null===Ht.outermostHandler&&(Ht.outermostHandler=this,this.dispatchEvent(new CustomEvent("outermost-action-start",{composed:!0,bubbles:!0,cancelable:!0,detail:{cause:e?.type}}))),e&&(this.currentEvent=e),this.needsUpdate=!1;try{this.evalInContext()}catch(e){console.warn("evaluation failed",e)}if(this.targetElement&&this.targetElement.nodeset&&(this.nodeset=this.targetElement.nodeset),!this.ifExpr||xt(this.ifExpr,St(this),this)){if(this.whileExpr){const e=async()=>{await xn(this.delay||0),tt.contains(this.getOwnerForm(),this)&&xt(this.whileExpr,St(this),this)&&this.performSafe()&&(this.delay?e():await e())};return await e(),void this._finalizePerform(t)}if(this.delay&&(await xn(this.delay),!tt.contains(this.getOwnerForm(),this)))return this.actionPerformed(),void t();await this.performSafe(),this._finalizePerform(t)}else this._finalizePerform(t)}_finalizePerform(e){this.currentEvent=null,this.actionPerformed(),Ht.outermostHandler===this&&(Ht.outermostHandler=null,this.dispatchEvent(new CustomEvent("outermost-action-end",{composed:!0,bubbles:!0,cancelable:!0}))),e()}async perform(){(this.isBound()||"FX-ACTION"===this.nodeName)&&this.evalInContext(),this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}))}actionPerformed(){const e=this.getModel();e&&e.inited&&(Ht.outermostHandler&&!tt.contains(Ht.outermostHandler.ownerDocument,Ht.outermostHandler)&&(Ht.outermostHandler=null),!this.needsUpdate||Ht.outermostHandler!==this&&Ht.outermostHandler?this.needsUpdate&&(Ht.outermostHandler.needsUpdate=!0):(e.recalculate(),e.revalidate(),e.parentNode.refresh(!0),this.dispatchActionPerformed()))}dispatchActionPerformed(){Ot.dispatch(this,"action-performed",{})}}bn.dataChanged=!1,customElements.get("abstract-action")||window.customElements.define("abstract-action",bn);class An extends bn{static get properties(){return{...bn.properties,ref:{type:String},repeat:{type:String},clear:{type:String}}}constructor(){super(),this.repeat=""}connectedCallback(){super.connectedCallback(),this.ref=this.getAttribute("ref"),this.repeat=this.getAttribute("repeat")}async perform(){super.perform(),this._dataFromTemplate(),this.needsUpdate=!0}actionPerformed(){super.actionPerformed(),this._dispatch()}_dataFromTemplate(){const e=this.getInScopeContext(),t=this.getOwnerForm().querySelector(`#${this.repeat}`),n=t.shadowRoot.querySelector("template"),r=e.ownerDocument.createElement(t.ref),a=this._generateInstance(n.content,r);e.appendChild(a)}_dispatch(){const e=ut(this.repeat,this);Ot.dispatch(e,"index-changed",{index:e.nodeset.length})}_clear(e){let t=e.firstChild;const n=e.attributes;for(let e=0;e<n.length;e+=1)n[e].value="";for(;t;)1===t.nodeType&&t.hasAttributes()&&(t.textContent=""),this._clear(t),t=t.nextSibling}_generateInstance(e,t){if(1===e.nodeType&&e.hasAttribute("ref")){const n=e.getAttribute("ref");let r;"."===n||(n.startsWith("@")?t.setAttribute(n.substring(1),""):(r=document.createElement(n),t.appendChild(r),0===e.children.length&&(r.textContent=e.textContent)))}if(e.hasChildNodes()){const n=e.children;for(let e=0;e<n.length;e+=1)this._generateInstance(n[e],t)}return t}getInstanceId(){return this.ref.startsWith("instance(")?"not implemented":"default"}}customElements.get("fx-append")||window.customElements.define("fx-append",An);class En extends bn{static get properties(){return{...super.properties,ref:{type:String}}}async perform(){const e=St(this.getAttributeNode("ref")||this,this.ref);this.nodeset=vt(this.ref,e,this);const t=tt.resolveInstance(this,this.ref),n=this.getModel().getInstance(t),r=Ot.getDomNodeIndexString(this.nodeset),a=this.nodeset;let o;if(this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event,path:r}})),Array.isArray(a)){if(0===a.length)return;o=a[0].parentNode,a.forEach((e=>{this._deleteNode(o,e)}))}else o=a.parentNode,this._deleteNode(o,a);await Ot.dispatch(n,"deleted",{ref:r,deletedNodes:a}),this.needsUpdate=!0}_deleteNode(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return;if(t.nodeType===Node.DOCUMENT_NODE)return;if(t.nodeType===Node.DOCUMENT_FRAGMENT_NODE)return;if(null===t.parentNode)return;this.getModelItem().readonly||e.removeChild(t)}actionPerformed(){this.getModel().rebuild(),super.actionPerformed()}}customElements.get("fx-delete")||window.customElements.define("fx-delete",En);class Nn extends bn{connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.control=this.hasAttribute("control")?this.getAttribute("control"):null}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));const e="#"+this.control;let t=document.querySelector(e);if(!t)return void Ot.dispatch(this,"error",{origin:this,message:`Instance '${this.control}' not found`,level:"Error"});const n=t.closest("fx-repeatitem");n&&(t=n.querySelector(e),this._focus(t));const r=t.closest("fx-repeatitem, .fx-repeatitem");if(r){t=r.parentNode.querySelector("[repeat-index] "+e)}this._focus(t),this.hasAttribute("select")&&this._select(t)}_focus(e){e&&"function"==typeof e.getWidget&&e.getWidget().focus(),e&&e.nodeType===Node.ELEMENT_NODE&&e.click()}_select(e){e&&e.getWidget().select()}}customElements.get("fx-setfocus")||window.customElements.define("fx-setfocus",Nn);class Tn extends bn{static get properties(){return{...super.properties,at:{type:Number},position:{type:Number},origin:{type:Object},keepValues:{type:Boolean}}}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){super.connectedCallback&&super.connectedCallback();this.shadowRoot.innerHTML="\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n <slot></slot>\n ",this.at=Number(this.hasAttribute("at")?this.getAttribute("at"):0),this.position=this.hasAttribute("position")?this.getAttribute("position"):"after",this.origin=this.hasAttribute("origin")?this.getAttribute("origin"):null,this.keepValues=!!this.hasAttribute("keep-values")}_getOriginSequence(e,t){let n;if(this.origin){let t;try{t=wt(this.origin,e,this),Array.isArray(t)&&0===t.length&&(console.warn("invalid origin for this insert action - ignoring...",this),n=null),n=t}catch(e){console.warn("invalid origin for this insert action - ignoring...",this)}}else t&&(n=t,n&&!this.keepValues&&this._clear(n));return n}_cloneOriginSequence(e,t){let n;if(this.origin){let t;try{t=wt(this.origin,e,this),Array.isArray(t)&&0===t.length&&(console.warn("invalid origin for this insert action - ignoring...",this),n=null),n=t.cloneNode(!0)}catch(e){console.warn("invalid origin for this insert action - ignoring...",this)}}else t&&(n=this._cloneTargetSequence(t),n&&!this.keepValues&&this._clear(n));return n}_getInsertIndex(e,t){return 0===t.length?null:this.hasAttribute("at")?At(this.getAttribute("at"),e,this):t.length}async perform(){let e,t;this.hasAttribute("context")&&(e=St(this.getAttributeNode("context"),this.getAttribute("context")),t=vt(this.getAttribute("context"),e,this.getOwnerForm())),this.hasAttribute("ref")&&(e||(e=St(this.getAttributeNode("ref"),this.ref)),t=vt(this.ref,e,this));const n=this._cloneOriginSequence(e,t);if(!n)return;let r,a;if(0===t.length)r=e,e.appendChild(n),a=1;else{if(this.hasAttribute("at")?(a=At(this.getAttribute("at"),e,this),r=t[a-1]):(a=t.length,r=t[t.length-1]),!r){a=1,r=t;a=At("count(preceding::*)",t,this.getOwnerForm())+1}this.position&&"before"===this.position&&r.parentNode.insertBefore(n,r),this.position&&"after"===this.position&&(a+=1,this.hasAttribute("context")&&this.hasAttribute("ref")?e.append(n):this.hasAttribute("context")?(a=1,r.prepend(n)):r.insertAdjacentElement("afterend",n))}const o=tt.resolveInstance(this,this.ref),s=this.getModel().getInstance(o),i=tt.getPath(r.parentNode,o),l=Ot.getDomNodeIndexString(n);return this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event,path:l}})),Ot.dispatch(s,"insert",{"inserted-nodes":n,"insert-location-node":r,position:this.position}),document.dispatchEvent(new CustomEvent("index-changed",{composed:!0,bubbles:!0,detail:{insertedNodes:n,index:a}})),this.needsUpdate=!0,console.log("Changed!",i),[i]}_cloneTargetSequence(e){return Array.isArray(e)&&0!==e.length?e[e.length-1].cloneNode(!0):!Array.isArray(e)&&e?e.cloneNode(!0):null}actionPerformed(e){this.getModel().rebuild(),super.actionPerformed()}_clear(e){const t=e.attributes;for(let e=0;e<t.length;e+=1)t[e].value="";e.textContent&&(e.textContent="");let n=e.firstChild;for(;n;)1===n.nodeType&&n.hasAttributes()&&(n.textContent=""),this._clear(n),n=n.nextSibling}}customElements.get("fx-insert")||window.customElements.define("fx-insert",Tn);class Bn extends bn{constructor(){super(),this.attachShadow({mode:"open"})}static get properties(){return{...bn.properties,modelItem:void 0,messageTextContent:{type:String,get value(){return"here!"}}}}connectedCallback(){super.connectedCallback(),this.event=this.hasAttribute("event")?this.getAttribute("event"):"",this.level=this.hasAttribute("level")?this.getAttribute("level"):"ephemeral",this.message="",this.messageTextContent=this.textContent;this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n ${this.renderHTML()}\n `}renderHTML(){return"\n <slot></slot>\n "}async perform(){super.perform(),this.hasAttribute("value")?this.message=this._getValue():(this.getOwnerForm().evaluateTemplateExpression(this.messageTextContent,this.firstChild),this.message=this.textContent),this.dispatchEvent(new CustomEvent("message",{composed:!1,bubbles:!0,detail:{level:this.level,message:this.message}}))}_getValue(){if(this.hasAttribute("value")){const e=this.getAttribute("value");try{return bt(e,St(this,e),this)}catch(e){console.error(e),Ot.dispatch(this,"error",{message:e})}}return this.textContent?this.textContent:null}}customElements.get("fx-message")||window.customElements.define("fx-message",Bn);class In extends bn{static get properties(){return{...super.properties,ref:{type:String},valueAttr:{type:String}}}constructor(){super(),this.ref="",this.valueAttr=""}connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),!this.hasAttribute("ref"))throw new Error('fx-setvalue must specify a "ref" attribute');this.ref=this.getAttribute("ref"),this.valueAttr=this.getAttribute("value")}async perform(){super.perform();let{value:e}=this;null!==this.valueAttr?[e]=yt(this.valueAttr,this.nodeset,this,this.detail):e=""!==this.textContent?this.textContent:"",e?.nodeType&&e.nodeType===Node.ATTRIBUTE_NODE&&(e=e.nodeValue);const t=this.getModelItem();this.setValue(t,e)}dispatchExecute(){}setValue(e,t){const n=e;if(n&&n.value!==t){const r=Ot.getDomNodeIndexString(e.node),a=this.event,o=this;this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:o,event:a,value:t,path:r}})),t?.nodeType?(t.nodeType===Node.ELEMENT_NODE&&(n.value=t.textContent),t.nodeType===Node.ATTRIBUTE_NODE&&(n.value=t.getValue())):n.value=t,this.getModel().changed.push(e),this.needsUpdate=!0}}}customElements.get("fx-setvalue")||window.customElements.define("fx-setvalue",In);class Cn extends bn{constructor(){super(),this.value="",this.url=null,this.target=null}connectedCallback(){super.connectedCallback(),this.submission=this.getAttribute("submission"),this.url=this.hasAttribute("url")?this.getAttribute("url"):null,this.target=this.hasAttribute("target")?this.getAttribute("target"):null}async perform(){super.perform(),console.log("submitting ",this.submission),this.getOwnerForm().classList.remove("submit-validation-failed");const e=this.getModel().querySelector(`#${this.submission}`);if(null!==e){if(this.url){const t=this.evaluateAttributeTemplateExpression(this.url,this);e.parameters.set("url",t)}if(this.target){const t=this.evaluateAttributeTemplateExpression(this.target,this);e.parameters.set("target",t)}console.log("submission",e),await e.submit()}else this.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,cancelable:!0,detail:{id:this.id,origin:this,message:`<fx-submission id="${this.submission}"> not found`,expr:tt.getDocPath(this),level:"Error"}}))}}customElements.get("fx-send")||window.customElements.define("fx-send",Cn);class Sn extends bn{connectedCallback(){super.connectedCallback(),this.hasAttribute("case")&&(this.case=this.getAttribute("case"))}async perform(){if(super.perform(),this.case){const e=this.getOwnerForm().querySelector(`#${this.case}`);if(!e)return void Ot.dispatch(this,"error",{message:`fx-case id not found: ${this.case}`});e.parentNode.toggle(e)}this.needsUpdate=!0}}customElements.get("fx-toggle")||window.customElements.define("fx-toggle",Sn);class On extends bn{static get properties(){return{...super.properties,name:{type:String},targetid:{type:String},details:{type:String}}}constructor(){super(),this.name=null,this.targetid=null,this.details=null,this.attachShadow({mode:"open"})}connectedCallback(){if(super.connectedCallback(),this.name=this.getAttribute("name"),!this.name)throw new Error("no event specified for dispatch",this);this.targetid=this.hasAttribute("targetid")?this.getAttribute("targetid"):null}async perform(){super.perform();const e=this.querySelectorAll("fx-property"),t={};if(Array.from(e).forEach((e=>{const n=e.getAttribute("name"),r=e.getAttribute("value"),a=e.getAttribute("expr");if(a){if(r)throw new Error('if "expr" is given there must not be a "value" attribute');const[e]=yt(a,this.getInScopeContext(),this);let o=null;if(e.nodeName){o=(new XMLSerializer).serializeToString(e)}t[n]=o||e}r&&(t[n]=r)})),this.targetid){let e=ut(this.targetid,this.parentNode,null);if(e||(e=document.getElementById(this.targetid)),!e)throw new Error(`targetid ${this.targetid} does not exist in document`);e.dispatchEvent(new CustomEvent(this.name,{composed:!0,bubbles:!0,detail:t}))}else document.dispatchEvent(new CustomEvent(this.name,{composed:!0,bubbles:!0,detail:t}))}}customElements.get("fx-dispatch")||window.customElements.define("fx-dispatch",On);class Fn extends bn{async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}})),this.getModel().updateModel()}}customElements.get("fx-update")||window.customElements.define("fx-update",Fn);class Dn extends bn{async perform(){if(this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}})),this.hasAttribute("self")){console.log(`### <<<<< refresh() self ${this} >>>>>`);const e=tt.getClosest("fx-control",this);if(e)return void e.refresh()}if(this.hasAttribute("force"))return console.log(`### <<<<< refresh() force ${this} >>>>>`),void this.getOwnerForm().forceRefresh();if(this.hasAttribute("control")){const e=this.getAttribute("control");console.log(`### <<<<< refresh() control '${e}' >>>>>`);const t=ut(e,this);t&&Ot.isUiElement(t.nodeName)&&"function"==typeof t.refresh&&t.refresh()}else this.getOwnerForm().refresh()}}customElements.get("fx-refresh")||window.customElements.define("fx-refresh",Dn);class kn extends bn{static get properties(){return{...super.properties,with:{type:String},replaceNode:Object}}constructor(){super(),this.with=""}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.with=this.getAttribute("with")}async perform(){super.perform();const e=wt(this.with,this.nodeset,this);e&&this.replace(this.nodeset,e)}actionPerformed(){this.getModel().rebuild(),super.actionPerformed()}replace(e,t){if(e&&t)if(e.nodeName&&t.nodeName){if(e.nodeType===Node.ATTRIBUTE_NODE){const{ownerElement:n}=e;n.setAttribute(t.nodeName,t.textContent),n.removeAttribute(e.nodeName)}else if(e.nodeType===Node.ELEMENT_NODE){const n=t.cloneNode(!0);e.replaceWith(n)}this.needsUpdate=!0}else console.warn("fx-replace: one argument is not a node")}}customElements.get("fx-replace")||window.customElements.define("fx-replace",kn);class Rn extends bn{connectedCallback(){super.connectedCallback&&super.connectedCallback()}async perform(){super.perform();const e=new CustomEvent("return",{composed:!0,bubbles:!0,detail:{nodeset:this.nodeset}});this.getOwnerForm().dispatchEvent(e)}}customElements.get("fx-return")||window.customElements.define("fx-return",Rn);class Mn extends bn{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.src=this.hasAttribute("src")?this.getAttribute("src"):null;this.shadowRoot.innerHTML="\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n <slot></slot>\n "}async perform(){super.perform();const{children:e}=this;if(this.src){this.innerHTML="";const e=document.createElement("script");e.src=this.src,this.appendChild(e)}else{for(const t of e){if("fx-var"===t.localName)continue;const e=t;e.detail=this.detail,await e.execute()}this.dispatchActionPerformed(),this.needsUpdate=!0}}}customElements.get("fx-action")||window.customElements.define("fx-action",Mn);class Un extends Mn{static get properties(){return{...Mn.properties,message:{type:String}}}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.message=this.hasAttribute("message")?this.getAttribute("message"):null}async perform(){window.confirm(this.message)&&super.perform()}}customElements.get("fx-confirm")||window.customElements.define("fx-confirm",Un);class Gn extends Mn{connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.dialog=this.getAttribute("dialog"),this.dialog||Ot.dispatch(this,"error",{message:"dialog does not exist"})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));const e=ut(this.dialog,this);e||console.error("target dialog with given id does not exist",this.dialog),e.open(),Ot.dispatch(e,"dialog-shown",{})}}customElements.get("fx-show")||window.customElements.define("fx-show",Gn);class $n extends bn{static get properties(){return{...super.properties,dialog:{type:String}}}connectedCallback(){super.connectedCallback(),this.dialog=this.getAttribute("dialog"),this.dialog||Ot.dispatch(this,"error",{message:"dialog does not exist"})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));const e=ut(this.dialog,this);e.hide(),Ot.dispatch(e,"dialog-hidden",{})}}customElements.get("fx-hide")||window.customElements.define("fx-hide",$n);class Ln extends bn{connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.addEventListener("reload",(()=>{window.location.reload()}),{once:!0})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}})),Ot.dispatch(this,"reload",{})}}customElements.get("fx-reload")||window.customElements.define("fx-reload",Ln);class Hn extends bn{static get properties(){return{...super.properties,instance:{type:String}}}connectedCallback(){super.connectedCallback(),this.instance=this.getAttribute("instance"),this.instance||Ot.dispatch(this,"error",{message:"instance does not exist"})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));this.getModel().getInstance(this.instance).reset(),this.needsUpdate=!0}}customElements.get("fx-reset")||window.customElements.define("fx-reset",Hn);class Pn extends bn{static get properties(){return{...super.properties,attachTo:{type:String},url:{type:String}}}constructor(){super(),this.attachShadow({mode:"open"}),this.url=""}connectedCallback(){super.connectedCallback(),this.attachTo=this.hasAttribute("attach-to")?this.getAttribute("attach-to"):"_self",this.awaitEvent=this.hasAttribute("await")?this.getAttribute("await"):"",this.url=this.hasAttribute("url")?this.getAttribute("url"):"";this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n ${this.renderHTML()}`}disconnectedCallback(){this.targetElement.removeEventListener(this.event,(e=>this.execute(e)))}renderHTML(){return"\n <slot></slot>\n "}async perform(){await super.perform();const e=this.querySelector("template");if(e){const t=e.content.cloneNode(!0),n=document.importNode(t,!0);if(this.attachTo.startsWith("#")){const e=ut(this.attachTo.substring(1),this);for(;e.firstChild;)e.removeChild(e.firstChild);if(this.awaitEvent){let t;const r=new Promise((e=>{t=e})),a=()=>{t(),e.removeEventListener(this.awaitEvent,a)};return e.appendChild(n),e.addEventListener(this.awaitEvent,a),await r,this.needsUpdate=!0,void Ot.dispatch(this,"loaded",{attachPoint:this.attachTo,content:n})}e.appendChild(n),this.needsUpdate=!0}return void Ot.dispatch(this,"loaded",{})}if(!this.url)return void this.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,cancelable:!0,detail:{origin:this,message:"neither template element nor Url was specified.",level:"Error"}}));const t=this.evaluateAttributeTemplateExpression(this.url,this);"_blank"===this.attachTo&&window.open(this.url),"_self"===this.attachTo&&(window.location.href=this.url);try{const e=await fetch(t,{method:"GET",mode:"cors",credentials:"same-origin",headers:{"Content-Type":"text/html"}}),n=await e.text();this.attachTo||(this.innerHtml=n),this._attachToElement(n),Ot.dispatch(this,"loaded",{url:this.url})}catch(e){throw new Error(`failed loading data ${e}`)}}_attachToElement(e){let t;if(e.nodeType)t=e;else try{t=(new DOMParser).parseFromString(e,"text/html").firstElementChild}catch(e){Ot.dispatch(this,"error",{message:"parsing of content as HTML failed"})}if(this.attachTo.startsWith("_")||this.attachTo.startsWith("#")||Ot.dispatch(this,"error",{message:'valid values for "attach-to" start with "_" or "#"'}),this.attachTo.startsWith("#")){const e=ut(this.attachTo.substring(1),this);if(e.innerHTML="",t.querySelector("fx-fore"))return void e.append(t.querySelector("fx-fore").cloneNode(!0));const n=t.querySelector("body").cloneNode(!0);e.appendChild(n.firstElementChild)}}_evaluateUrlExpression(){const e=this.getAttribute("url");if(!e)throw new Error("url not specified");return e.replace(/{[^}]*}/g,(e=>{if("{}"===e)return e;const t=e.substring(1,e.length-1),n=St(this,t);if(!n)return console.warn("no inscope context for ",this),e;const r=tt.getInstanceId(t),a=r?this.getModel().getInstance(r):this.getModel().getDefaultInstance();try{return bt(t,n,this,null,a)}catch(t){return console.warn("ignoring unparseable url",t),e}}))}}customElements.get("fx-load")||window.customElements.define("fx-load",Pn);class jn extends bn{static get properties(){return{...super.properties,ref:{type:String},valueAttr:{type:String},value:{type:Boolean}}}constructor(){super(),this.ref="",this.valueAttr="",this.value=!1}connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),!this.hasAttribute("ref"))throw new Error('fx-togglealue must specify a "ref" attribute');this.ref=this.getAttribute("ref")}async perform(){super.perform();const e=this.getModelItem();"true"===e.value?e.node.textContent="false":e.node.textContent="true",this.needsUpdate=!0}}customElements.get("fx-toggleboolean")||window.customElements.define("fx-toggleboolean",jn);class _n extends bn{static get properties(){return{...super.properties,action:{type:String},fn:{type:String}}}constructor(){super(),this.action="",this.fn=""}connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),this.hasAttribute("action"))this.action=this.getAttribute("action");else{if(!this.hasAttribute("function"))throw new Error('fx-call must specify an "action" or "function" attribute');this.fn=this.getAttribute("function")}}async perform(){super.perform(),this.action&&await this._callAction(),this.fn&&this._callFunction()}async _callAction(){const e=document.querySelector(`#${this.action}`);e?await e.perform():Ot.dispatch(this,"error",{origin:this,message:`Action '${this.action}' not found`,expr:tt.getDocPath(this),level:"Error"})}_callFunction(){const e=St(this,"instance()");yt(this.fn,e,this)}}customElements.get("fx-call")||window.customElements.define("fx-call",_n);class Xn extends(Rt(HTMLElement)){constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.style.display="none",this.signature=this.hasAttribute("signature")?this.getAttribute("signature"):null,null===this.signature&&console.error("signature is a required attribute"),this.type=this.hasAttribute("type")?this.getAttribute("type"):null,this.shadowRoot.innerHTML="<slot></slot>",this.override=this.hasAttribute("override")?this.getAttribute("override"):"true",this.functionBody=this.innerText;const e=this.getAttribute("type")||"text/xpath",t=this.signature.match(/(?:(?<prefix>[^:]*):)?(?<localName>[^(]+)\((?<params>(?:\(\)|[^)])*)\)(?: as (?<returnType>.*))?/);if(!t)throw new Error(`Function signature ${this.signature} could not be parsed`);const{prefix:n,localName:r,params:a,returnType:o}=t.groups,s="local"!==n&&n?`${n}:${r}`:{namespaceURI:"http://www.w3.org/2005/xquery-local-functions",localName:r};n||it.push(r);const i=a?a.split(",").map((e=>{const t=e.match(/(?<variableName>\$[^\s]+)(?:\sas\s(?<varType>.+))/);if(!t)throw new Error(`Param ${e} could not be parsed`);const{variableName:n,varType:r}=t.groups;return{variableName:n,variableType:r||"item()*"}})):[];switch(e){case"text/javascript":{const e=new Function("_domFacade",...i.map((e=>e.variableName)),"form",this.functionBody);We(s,i.map((e=>e.variableType)),o||"item()*",((...t)=>e.apply(this.getInScopeContext(),[...t,this.getOwnerForm()])));break}case"text/xquf":case"text/xquery":case"text/xpath":{const t=i.map((e=>je(e.variableType))),n="text/xpath"===e?"XPath3.1":"text/xquery"===e?"XQuery3.1":"XQueryUpdate3.1",r=(e,...r)=>yt(this.functionBody,this.getInScopeContext(),this.getOwnerForm(),i.reduce(((e,n,a)=>(e[n.variableName.replace("$","")]=t[a](r[a]),e)),{}),{language:n});We(s,i.map((e=>e.variableType)),o||"item()*",r);break}default:throw new Error(`Unexpected mimetype ${e} for function`)}}}customElements.get("fx-function")||customElements.define("fx-function",Xn);
8
+ */;class Ut{constructor(e){this.defaults={oldestFirst:!0,text:"Toastify is awesome!",node:void 0,duration:3e3,selector:void 0,callback:function(){},destination:void 0,newWindow:!1,close:!1,gravity:"toastify-top",positionLeft:!1,position:"",backgroundColor:"",avatar:"",className:"",stopOnFocus:!0,onClick:function(){},offset:{x:0,y:0},escapeMarkup:!0,style:{background:""}},this.version="1.11.2",this.options={},this.toastElement=null,this._rootElement=document.body,this._init(e)}showToast(){if(this.toastElement=this._buildToast(),"string"==typeof this.options.selector?this._rootElement=document.getElementById(this.options.selector):this.options.selector instanceof HTMLElement||this.options.selector instanceof ShadowRoot?this._rootElement=this.options.selector:this._rootElement=document.body,!this._rootElement)throw"Root element is not defined";return this._rootElement.insertBefore(this.toastElement,this._rootElement.firstChild),this._reposition(),this.options.duration>0&&(this.toastElement.timeOutValue=window.setTimeout((()=>{this._removeElement(this.toastElement)}),this.options.duration)),this}hideToast(){this.toastElement.timeOutValue&&clearTimeout(this.toastElement.timeOutValue),this._removeElement(this.toastElement)}_init(e){this.options=Object.assign(this.defaults,e),this.options.backgroundColor&&console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.'),this.toastElement=null,this.options.gravity="bottom"===e.gravity?"toastify-bottom":"toastify-top",this.options.stopOnFocus=void 0===e.stopOnFocus||e.stopOnFocus,e.backgroundColor&&(this.options.style.background=e.backgroundColor)}_buildToast(){if(!this.options)throw"Toastify is not initialized";let e=document.createElement("div");e.className=`toastify on ${this.options.className}`,e.className+=` toastify-${this.options.position}`,e.className+=` ${this.options.gravity}`;for(const t in this.options.style)e.style[t]=this.options.style[t];if(this.options.node&&this.options.node.nodeType===Node.ELEMENT_NODE)e.appendChild(this.options.node);else if(this.options.escapeMarkup?e.innerText=this.options.text:e.innerHTML=this.options.text,""!==this.options.avatar){let t=document.createElement("img");t.src=this.options.avatar,t.className="toastify-avatar","left"==this.options.position?e.appendChild(t):e.insertAdjacentElement("afterbegin",t)}if(!0===this.options.close){let t=document.createElement("span");t.innerHTML="&#10006;",t.className="toast-close",t.addEventListener("click",(e=>{e.stopPropagation(),this._removeElement(this.toastElement),window.clearTimeout(this.toastElement.timeOutValue)}));const n=window.innerWidth>0?window.innerWidth:screen.width;"left"==this.options.position&&n>360?e.insertAdjacentElement("afterbegin",t):e.appendChild(t)}if(this.options.stopOnFocus&&this.options.duration>0&&(e.addEventListener("mouseover",(t=>{window.clearTimeout(e.timeOutValue)})),e.addEventListener("mouseleave",(()=>{e.timeOutValue=window.setTimeout((()=>{this._removeElement(e)}),this.options.duration)}))),void 0!==this.options.destination&&e.addEventListener("click",(e=>{e.stopPropagation(),!0===this.options.newWindow?window.open(this.options.destination,"_blank"):window.location=this.options.destination})),"function"==typeof this.options.onClick&&void 0===this.options.destination&&e.addEventListener("click",(e=>{e.stopPropagation(),this.options.onClick()})),"object"==typeof this.options.offset){const t=this._getAxisOffsetAValue("x",this.options),n=this._getAxisOffsetAValue("y",this.options),r="left"==this.options.position?t:`-${t}`,a="toastify-top"==this.options.gravity?n:`-${n}`;e.style.transform=`translate(${r},${a})`}return e}_removeElement(e){e.className=e.className.replace(" on",""),window.setTimeout((()=>{this.options.node&&this.options.node.parentNode&&this.options.node.parentNode.removeChild(this.options.node),e.parentNode&&e.parentNode.removeChild(e),this.options.callback.call(e),this._reposition()}),400)}_reposition(){let e,t={top:15,bottom:15},n={top:15,bottom:15},r={top:15,bottom:15},a=this._rootElement.querySelectorAll(".toastify");for(let o=0;o<a.length;o++){e=!0===a[o].classList.contains("toastify-top")?"toastify-top":"toastify-bottom";let s=a[o].offsetHeight;e=e.substr(9,e.length-1);let i=15;(window.innerWidth>0?window.innerWidth:screen.width)<=360?(a[o].style[e]=`${r[e]}px`,r[e]+=s+i):!0===a[o].classList.contains("toastify-left")?(a[o].style[e]=`${t[e]}px`,t[e]+=s+i):(a[o].style[e]=`${n[e]}px`,n[e]+=s+i)}}_getAxisOffsetAValue(e,t){return t.offset[e]?isNaN(t.offset[e])?t.offset[e]:`${t.offset[e]}px`:"0px"}}function Gt(e){return new Ut(e)}class $t extends HTMLElement{static get properties(){return{avatar:{type:String},backgroundColor:{type:String},callback:{type:String},classProp:{type:String},close:{type:Boolean},destination:{type:String},duration:{type:Number},escapeMarkup:{type:Boolean},gravity:{type:String},newWindow:{type:Boolean},oldestFirst:{type:Boolean},position:{type:String},selector:{type:String},stopOnFocus:{type:Boolean},text:{type:String}}}constructor(){super(),this.attachShadow({mode:"open"})}_initVar(e,t){return this.hasAttribute(e)?this.getAttribute(e):t}connectedCallback(){this.avatar=this._initVar("avatar",""),this.backgroundColor=this._initVar("backgroundColor",""),this.callback=this._initVar("callback",{}),this.classProp=this._initVar("data-class",""),this.close="true"===this._initVar("close",!1),this.destination=this._initVar("destination",void 0),this.duration=Number(this._initVar("duration",3e3)),this.escapeMarkup="true"===this._initVar("escapeMarkup","true"),this.gravity=this._initVar("gravity","top"),this.newWindow="true"===this._initVar("newWindow","false"),this.offSet=this._initVar("offSet",{}),this.oldestFirst="true"===this._initVar("oldestFirst","true"),this.position=this._initVar("position","right"),this.stopOnFocus="true"===this._initVar("stopOnFocus","true"),this.text=this._initVar("text","");this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n ${this.renderHTML}\n `,this.addEventListener("jinn-toast",(e=>{this.showToast(e.detail.text)}))}disconnectedCallback(){this.removeEventListener("jinn-toast",this.showToast)}showToast(e){new Gt({avatar:this.avatar,className:this.classProp,close:this.close,destination:this.destination,duration:this.duration,escapeMarkup:this.escapeMarkup,gravity:this.gravity,newWindow:!1,offset:this.offset,oldestFirst:this.oldestFirst,position:this.position,node:this.shadowRoot,stopOnFocus:this.stopOnFocus,text:e}).showToast()}renderHTML(){return"\n <slot></slot>\n "}}customElements.get("jinn-toast")||window.customElements.define("jinn-toast",$t);const Lt=(e,t)=>class extends e{static get properties(){return{...e.properties,dnd:{type:Boolean}}}constructor(){super()}connectedCallback(){this.drop=e=>this._drop(e),this.addEventListener("drop",this.drop),this.dragOver=e=>this._dragOver(e),this.addEventListener("dragover",this.dragOver),this.dragLeave=e=>this._dragLeave(e),this.addEventListener("dragleave",this.dragLeave),this.dragEnd=e=>this._dragEnd(e),this.addEventListener("dragend",this._dragEnd)}disconnectedCallback(){this.removeEventListener("drop",this.drop),this.removeEventListener("dragover",this.dragOver),this.removeEventListener("dragleave",this.dragLeave),this.removeEventListener("dragend",this.dragEnd)}_dragOver(e){if(e.target.classList.contains("no-drop"))return!1;e.stopPropagation();const t=e.target.closest("fx-repeatitem");if(!this.getOwnerForm().draggedItem)return;if(this===this.getOwnerForm().draggedItem)return;const{draggedItem:n}=this.getOwnerForm();this.accepts(n)?this.classList.remove("no-drop"):this.classList.add("no-drop");const r=this.hasAttribute("id")?this:this.closest("[id]"),a=n.hasAttribute("id")?n:n.closest("[id]");r?.id===a?.id&&(t!==this.getOwnerForm().draggedItem&&this.classList.add("drag-over"),e.preventDefault())}_dragLeave(e){this.classList.remove("drag-over"),this.classList.remove("no-drop")}_dragEnd(e){const t=this.getOwnerForm().draggedItem;"copy"===t.getAttribute("drop-action")&&t.remove(),this.classList.remove("drag-over")}_getDataNode(){const e=this.getOwnerForm().draggedItem?.getModelItem()?.node;if(!e)return null;const{draggedItem:t}=this.getOwnerForm(),n=this.hasAttribute("id")?this:this.closest("[id]"),r=t.hasAttribute("id")?t:t.closest("[id]");return n?.id!==r?.id?null:e}accepts(e){if(!this.hasAttribute("accept"))return;const t=this.getAttribute("accept");return e.matches(t)}_drop(e){if(this.classList.remove("drag-over"),e.stopPropagation(),"fx-droptarget"===this.localName){0!==this.children.length&&console.log("we have to do something");let{draggedItem:t}=this.getOwnerForm();if("copy"===t.getAttribute("drop-action")&&(t=t.cloneNode(!0)),!this.accepts(t))return void this.classList.remove("no-drop");if(t===this)return;if("fx-droptarget"===t.localName){if(this.hasAttribute("drop-position"))return this.replaceChildren(t),void e.preventDefault();this.parentNode.lastElementChild===this?(this.parentNode.append(t),e.stopImmediatePropagation()):t===this.previousElementSibling?this.parentNode.insertBefore(t,this.nextElementSibling):this.parentNode.insertBefore(t,this)}else this.appendChild(t);return e.preventDefault(),this.getOwnerForm().getModel().updateModel(),void this.getOwnerForm().refresh(!0)}const t=this._getDataNode();if(t){if("fx-repeat"===this.localName){e.preventDefault();let n=this.nodeset;if(Array.isArray(n)&&!n.length){Ot(this.getAttributeNode("ref")||this,this.ref).append(t)}else n=n[n.length-1],n.after(t)}else if("fx-repeatitem"===this.localName){const e=this.getModelItem().node;e.previousSibling===t?e.after(t):e.before(t)}this.getOwnerForm().getModel().updateModel(),this.getOwnerForm().refresh(!0)}}};class Pt extends(Lt(Rt(HTMLElement))){static get properties(){return{...super.properties,index:{type:Number},template:{type:Object},focusOnCreate:{type:String},initDone:{type:Boolean},repeatIndex:{type:Number},repeatSize:{type:Number},nodeset:{type:Array}}}constructor(){super(),this.ref="",this.dataTemplate=[],this.isDraggable=null,this.focusOnCreate="",this.initDone=!1,this.repeatIndex=1,this.nodeset=[],this.inited=!1,this.host={},this.index=1,this.repeatSize=0,this.attachShadow({mode:"open",delegatesFocus:!0})}get repeatSize(){return this.querySelectorAll(":scope > .fx-repeatitem").length}set repeatSize(e){super.repeatSize=e}setIndex(e){this.index=e;const t=this.querySelector("[data-ref]").querySelectorAll(":scope > *");this.applyIndex(t[this.index-1])}applyIndex(e){this._removeIndexMarker(),e&&e.setAttribute("repeat-index","")}get index(){return parseInt(this.getAttribute("index"),10)}set index(e){this.setAttribute("index",e)}_getRepeatedItems(){return this.querySelector("[data-ref]").children}async connectedCallback(){this.ref=this.getAttribute("ref"),this.addEventListener("item-changed",(e=>{const{item:t}=e.detail,n=this._getRepeatedItems(),r=Array.from(n).indexOf(t);this.applyIndex(n[r]),this.index=r+1})),document.addEventListener("index-changed",(e=>{if(e.stopPropagation(),!e.target===this)return;const{index:t}=e.detail;this.index=Number(t),this.applyIndex(this.children[t-1])})),this.mutationObserver=new MutationObserver((e=>{if("childList"===e[0].type){const t=e[0].addedNodes[0];if(t){const e=tt.resolveInstance(this,this.ref),n=tt.getPath(t,e);St.dispatch(this,"path-mutated",{path:n,index:this.index})}}})),this.getOwnerForm().registerLazyElement(this);this.shadowRoot.innerHTML="\n <style>\n \n :host{\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n \n </style>\n \n <slot></slot>\n \n "}async init(){return new Promise((e=>{this._evalNodeset(),this._initTemplate(),this.setAttribute("index",this.index),this.inited=!0,e("done")}))}_getRef(){return this.getAttribute("ref")}_evalNodeset(){const e=Ot(this.getAttributeNode("ref")||this,this.ref);this.mutationObserver&&e.nodeName&&this.mutationObserver.observe(e,{childList:!0,subtree:!0});const t=yt(this.ref,e,this);1===t.length&&Array.isArray(t[0])?this.nodeset=t[0]:this.nodeset=t}async refresh(e){this.inited||this.init(),this._evalNodeset();let t=this.querySelectorAll(".fx-repeatitem"),n=t.length,r=1;Array.isArray(this.nodeset)&&(r=this.nodeset.length);const a=r;if(a<n)for(let e=n;e>a;e-=1){const n=t[e-1];n.parentNode.removeChild(n),this.getOwnerForm().unRegisterLazyElement(n),this.getOwnerForm().someInstanceDataStructureChanged=!0}if(a>n)for(let e=n+1;e<=a;e+=1){const t=this._clone();if(!t)return;this.querySelector("[data-ref]").appendChild(t),t.classList.add("fx-repeatitem"),t.setAttribute("index",e),t.addEventListener("click",this._dispatchIndexChange),t.addEventListener("focusin",this._dispatchIndexChange),this.getOwnerForm().someInstanceDataStructureChanged=!0}t=this.querySelectorAll(":scope > .fx-repeatitem"),n=t.length;for(let e=0;e<n;e+=1){const n=t[e];this.getOwnerForm().registerLazyElement(n),n.nodeset!==this.nodeset[e]&&(n.nodeset=this.nodeset[e])}this.getOwnerForm().lazyRefresh&&!e||St.refreshChildren(this,e),this.setIndex(this.index)}_dispatchIndexChange(){this.dispatchEvent(new CustomEvent("item-changed",{composed:!1,bubbles:!0,detail:{item:this,index:this.index}}))}_fadeOut(e){e.style.opacity=1,function t(){(e.style.opacity-=.1)<0?e.style.display="none":requestAnimationFrame(t)}()}_fadeIn(e){e&&(e.style.opacity=0,e.style.display=this.display,function t(){let n=parseFloat(e.style.opacity);(n+=.1)>1||(e.style.opacity=n,requestAnimationFrame(t))}())}async _initTemplate(){this.template=this.querySelector("template"),this.template&&this.shadowRoot.appendChild(this.template)}_initVariables(e){const t=new Map(this.inScopeVariables);e.setInScopeVariables(t),function e(n){for(const r of n.children)"setInScopeVariables"in r&&r.setInScopeVariables(t),e(r)}(e)}_clone(){if(this.template=this.shadowRoot.querySelector("template"),this.template)return this.template.content.firstElementChild.cloneNode(!0)}_removeIndexMarker(){const e=this.querySelector("[data-ref]");Array.from(e.children).forEach((e=>{e.removeAttribute("repeat-index")}))}setInScopeVariables(e){this.inScopeVariables=new Map(e)}}customElements.get("fx-repeat-attributes")||window.customElements.define("fx-repeat-attributes",Pt);class Ht extends HTMLElement{static get properties(){return{ignoreExpressions:{type:String},mergePartial:{type:Boolean},lazyRefresh:{type:Boolean},model:{type:Object},ready:{type:Boolean},strict:{type:Boolean},validateOn:{type:String},version:{type:String}}}constructor(){super(),this.version="Version: 2.1.0 - built on May 2, 2024 16:13:13",this.model={},this.inited=!1,this.addEventListener("message",this._displayMessage),this.addEventListener("error",this._logError),this.addEventListener("warn",this._displayWarning),window.addEventListener("compute-exception",(e=>{console.error("circular dependency: ",e)})),this.ready=!1,this.storedTemplateExpressionByNode=new Map,this.outermostHandler=null,this.copiedElements=new WeakSet;this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display: block;\n }\n :host ::slotted(fx-model){\n display:none;\n }\n\n #modalMessage .dialogActions{\n text-align:center;\n }\n .overlay {\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: rgba(0, 0, 0, 0.7);\n transition: all 500ms;\n visibility: hidden;\n opacity: 0;\n z-index:10;\n }\n .overlay.show {\n visibility: visible;\n opacity: 1;\n }\n\n .popup {\n margin: 70px auto;\n background: #fff;\n border-radius: 5px;\n width: 30%;\n position: relative;\n transition: all 5s ease-in-out;\n padding: 20px;\n\n }\n .popup h2 {\n margin-top: 0;\n width:100%;\n background:#eee;\n position:absolute;\n top:0;\n right:0;\n left:0;\n height:40px;\n border-radius: 5px;\n\n }\n .popup .close {\n position: absolute;\n top: 3px;\n right: 10px;\n transition: all 200ms;\n font-size: 30px;\n font-weight: bold;\n text-decoration: none;\n color: #333;\n }\n .popup .close:focus{\n outline:none;\n }\n\n .popup .close:hover {\n color: #06D85F;\n }\n #messageContent{\n margin-top:40px;\n }\n .warning{\n background:orange;\n }\n \n </style>\n \n\x3c!-- <slot name="errors"></slot> --\x3e\n <jinn-toast id="message" gravity="bottom" position="left"></jinn-toast>\n <jinn-toast id="sticky" gravity="bottom" position="left" duration="-1" close="true" data-class="sticky-message"></jinn-toast>\n <jinn-toast id="error" text="error" duration="-1" data-class="error" close="true" position="right" gravity="top" escape-markup="false"></jinn-toast>\n <jinn-toast id="warn" text="warning" duration="5000" data-class="warning" position="left" gravity="top"></jinn-toast>\n <slot id="default"></slot>\n <slot name="messages"></slot>\n <div id="modalMessage" class="overlay">\n <div class="popup">\n <h2></h2>\n <a class="close" href="#" onclick="event.target.parentNode.parentNode.classList.remove(\'show\')" autofocus>&times;</a>\n <div id="messageContent"></div>\n </div>\n </div>\n <slot name="event"></slot>\n \n ',this.toRefresh=[],this.initialRun=!0,this._scanForNewTemplateExpressionsNextRefresh=!1,this.repeatsFromAttributesCreated=!1,this.validateOn=this.hasAttribute("validate-on")?this.getAttribute("validate-on"):"update",this.mergePartial=!1}connectedCallback(){if(this.style.visibility="hidden",console.time("init"),this.strict=!!this.hasAttribute("strict"),this.ignoreExpressions=this.hasAttribute("ignore-expressions")?this.getAttribute("ignore-expressions"):null,this.lazyRefresh=this.hasAttribute("refresh-on-view"),this.lazyRefresh){const e={root:null,rootMargin:"0px",threshold:.3};this.intersectionObserver=new IntersectionObserver(this.handleIntersect,e)}if(this.src=this.hasAttribute("src")?this.getAttribute("src"):null,this.src)return void this._loadFromSrc();this._injectDevtools();this.shadowRoot.querySelector("slot#default").addEventListener("slotchange",(async e=>{if(console.log(`### <<<<< slotchange on '${this.id}' >>>>>`),this.inited)return;if(this.hasAttribute("convert"))return void this.replaceWith(St.copyDom(this));this.ignoreExpressions&&(this.ignoredNodes=Array.from(this.querySelectorAll(this.ignoreExpressions)));let t=e.target.assignedElements().find((e=>"FX-MODEL"===e.nodeName.toUpperCase()));if(!t){const e=document.createElement("fx-model");return this.appendChild(e),void(t=e)}t.inited||(console.info(`%cFore is processing fx-fore#${this.id}`,"background:#64b5f6; color:white; padding:.5rem; display:inline-block; white-space: nowrap; border-radius:0.3rem;width:100%;"),await t.modelConstruct(),this._handleModelConstructDone()),this.model=t,this._createRepeatsFromAttributes(),this.inited=!0})),this.addEventListener("path-mutated",(()=>{this.someInstanceDataStructureChanged=!0})),this.addEventListener("refresh",(()=>{this.refresh(!0)}))}_injectDevtools(){if(this.ownerDocument.querySelector("fx-devtools"))return;const e=window.location.search;if(new URLSearchParams(e).has("inspect")){const e=document.createElement("fx-devtools");document.body.appendChild(e)}}addToRefresh(e){this.toRefresh.find((t=>t.path===e.path))||this.toRefresh.push(e)}scanForNewTemplateExpressionsNextRefresh(){this._scanForNewTemplateExpressionsNextRefresh=!0}async _loadFromSrc(){await St.loadForeFromSrc(this,this.src,"fx-fore")}handleIntersect(e,t){e.forEach((e=>{const{target:t}=e;St.getFore(t).initialRun||e.isIntersecting&&(t.classList.add("loaded"),"function"==typeof t.refresh?t.refresh(t,!0):St.refreshChildren(t,!0))})),e[0].target.getOwnerForm().dispatchEvent(new CustomEvent("refresh-done"))}evaluateToNodes(e,t){return vt(e,t,this)}disconnectedCallback(){this.removeEventListener("dragstart",this.dragstart)}async forceRefresh(){St.refreshChildren(this,!0),this._updateTemplateExpressions(),this._scanForNewTemplateExpressionsNextRefresh=!1,this._processTemplateExpressions(),console.log(`### <<<<< refresh-done ${this.id} >>>>>`),St.dispatch(this,"refresh-done",{})}async refresh(e){if(this.isRefreshing)return;this.isRefreshing=!0,console.log(`### <<<<< refresh() on '${this.id}' >>>>>`),e||this.initialRun||0===this.toRefresh.length?this.inited&&St.refreshChildren(this,!0):(this.toRefresh.forEach((t=>{const n=t.boundControls;n&&n.forEach((t=>{t.refresh(e)}));const{mainGraph:r}=this.getModel();if(r&&r.hasNode(t.path)){const n=this.getModel().mainGraph.dependentsOf(t.path,!1);0!==n.length&&n.forEach((t=>{const n=tt.getBasePath(t);this.getModel().modelItems.find((e=>e.path===n)).boundControls.forEach((t=>{t.refresh(e)}))}))}})),this.toRefresh=[]),(this.initialRun||this._scanForNewTemplateExpressionsNextRefresh)&&(this._updateTemplateExpressions(),this._scanForNewTemplateExpressionsNextRefresh=!1),this._processTemplateExpressions(),this.style.visibility="visible",console.log(`### <<<<< refresh-done ${this.id} >>>>>`),St.dispatch(this,"refresh-done",{});const t=Array.from(this.querySelectorAll("fx-fore"));for(const e of t)e.ready&&await e.refresh(!1);this.isRefreshing=!1}_updateTemplateExpressions(){const e=vt("(descendant-or-self::*!(text(), @*))[contains(., '{')][substring-after(., '{') => contains('}')][not(ancestor-or-self::fx-model)]",this,this);this.storedTemplateExpressions||(this.storedTemplateExpressions=[]),Array.from(e).forEach((e=>{if((e.nodeType===Node.ATTRIBUTE_NODE?e.ownerElement:e.parentNode).closest("fx-fore")!==this)return;if(this.storedTemplateExpressionByNode.has(e))return;const t=this._getTemplateExpression(e);t&&this.storedTemplateExpressionByNode.set(e,t)})),this._processTemplateExpressions()}_processTemplateExpressions(){for(const e of Array.from(this.storedTemplateExpressionByNode.keys())){if(e.nodeType===Node.ATTRIBUTE_NODE){if(!tt.contains(this,e.ownerElement)){this.storedTemplateExpressionByNode.delete(e);continue}}else if(!tt.contains(this,e)){this.storedTemplateExpressionByNode.delete(e);continue}this._processTemplateExpression({node:e,expr:this.storedTemplateExpressionByNode.get(e)})}}_processTemplateExpression(e){const{expr:t}=e,{node:n}=e;this.evaluateTemplateExpression(t,n)}evaluateTemplateExpression(e,t){if(t.nodeType===Node.ATTRIBUTE_NODE&&t.ownerElement.closest("[nonrelevant]"))return;if(t.nodeType===Node.TEXT_NODE&&t.parentNode.closest("[nonrelevant]"))return;if(t.nodeType===Node.ELEMENT_NODE&&t.closest("[nonrelevant]"))return;const n=e.replace(/{[^}]*}/g,(e=>{if("{}"===e)return e;const n=e.substring(1,e.length-1),r=Ot(t,n);if(!r)return console.warn("no inscope context for expr",n),(t.nodeType===Node.TEXT_NODE||t.nodeType===Node.ATTRIBUTE_NODE)&&t.parentNode,e;const a=tt.getInstanceId(n),o=a?this.getModel().getInstance(a):this.getModel().getDefaultInstance();try{return bt(n,r,t,null,o)}catch(t){return console.warn("ignoring unparseable expr",t),e}}));if(t.nodeType===Node.ATTRIBUTE_NODE){const e=t.ownerElement;e.getAttribute(t.nodeName)!==n&&e.setAttribute(t.nodeName,n)}else t.nodeType===Node.TEXT_NODE&&t.textContent!==n&&(t.textContent=n)}_getTemplateExpression(e){if(this.ignoredNodes){e.nodeType===Node.ATTRIBUTE_NODE&&(e=e.ownerElement);const t=this.ignoredNodes.find((t=>t.contains(e)));if(t)return null}return e.nodeType===Node.ATTRIBUTE_NODE?e.value:e.nodeType===Node.TEXT_NODE?e.textContent.trim():null}_handleModelConstructDone(){if(this.hasAttribute("show-confirmation")){const e=this.getAttribute("show-confirmation");e&&"show-confirmation"!==e&&"true"!==e&&""!==e?window.addEventListener("beforeunload",(t=>{if(xt(e,this.getModel().getDefaultContext(),this))return t.returnValue="are you sure";t.preventDefault()})):window.addEventListener("beforeunload",(e=>{if(kt.dataChanged)return e.returnValue="are you sure";e.preventDefault()}))}this._initUI()}async _lazyCreateInstance(){const e=this.querySelector("fx-model"),t=this.parentNode.nodeType!==Node.DOCUMENT_FRAGMENT_NODE?this.parentNode.closest("fx-fore"):null;if(this.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&console.log("fragment",this.parentNode),t){if(0!==t.getModel().instances.filter((e=>e.hasAttribute("shared"))).length)return}try{if(0===e.instances.length){const t=document.createElement("fx-instance");e.appendChild(t);const n=document.implementation.createDocument(null,"data",null);this._generateInstance(this,n.firstElementChild),t.instanceData=n,e.instances.push(t),St.dispatch(this,"instance-loaded",{instance:this})}}catch(e){console.warn("lazyCreateInstance created an error attempting to create a document",e.message)}}_generateInstance(e,t){if(e.hasAttribute("ref")&&!St.isActionElement(e.nodeName)){const n=e.getAttribute("ref");if(n.includes("/")){n.split("/").forEach((n=>{t=this._generateNode(t,n,e)}))}else t=this._generateNode(t,n,e)}if(e.hasChildNodes()){const n=e.children;for(let e=0;e<n.length;e+=1)this._generateInstance(n[e],t)}return t}_generateNode(e,t,n){const r=e.ownerDocument.createElement(t);return 0===n.children.length&&(r.textContent=n.textContent),e.appendChild(r),e=r}async _initUI(){if(console.log(`### <<<<< _initUI '${this.id}' >>>>>`),!this.initialRun)return;this.classList.add("initialRun"),await this._lazyCreateInstance();const e=new Map;!function t(n){for(const r of n.children)"setInScopeVariables"in r&&r.setInScopeVariables(e),t(r)}(this),await this.refresh(!0),this.classList.add("fx-ready"),document.body.classList.add("fx-ready"),this.ready=!0,this.initialRun=!1,console.log(`### <<<<< ${this.id} ready >>>>>`),St.dispatch(this,"ready",{}),console.timeEnd("init"),this.addEventListener("dragstart",this._handleDragStart),this.handleDrop=e=>this._handleDrop(e),this.ownerDocument.body.addEventListener("drop",this.handleDrop),this.ownerDocument.body.addEventListener("dragover",(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move"}))}_handleDragStart(e){const t=e.target.closest('[draggable="true"]');this.originalDraggedItem=t,console.log("DRAG START",this),"copy"===t.getAttribute("drop-action")?(e.dataTransfer.dropEffect="copy",e.dataTransfer.effectAllowed="copy",this.draggedItem=t.cloneNode(!0),this.draggedItem.setAttribute("drop-action","move"),this.copiedElements.add(this.draggedItem)):(e.dataTransfer.dropEffect="move",e.dataTransfer.effectAllowed="move",this.draggedItem=t)}_handleDrop(e){console.log("DROP ON BODY",this),this.draggedItem&&("none"===e.dataTransfer.dropEffect&&this.copiedElements.has(this.originalDraggedItem)&&this.originalDraggedItem.remove(),this.originalDraggedItem=null,this.draggedItem=null,e.stopPropagation())}registerLazyElement(e){this.intersectionObserver&&this.intersectionObserver.observe(e)}unRegisterLazyElement(e){this.intersectionObserver&&this.intersectionObserver.unobserve(e)}getModel(){return this.querySelector("fx-model")}_displayMessage(e){const{level:t}=e.detail,n=e.detail.message;this._showMessage(t,n),e.stopPropagation()}_displayError(e){const t=e.detail.message;this.shadowRoot.querySelector("#error").showToast(t)}_displayWarning(e){const t=e.detail.message,n=tt.shortenPath(bt("path()",e.target,this));this.shadowRoot.querySelector("#warn").showToast(`WARN: ${n}:${t}`)}_logError(e){e.stopPropagation(),e.preventDefault(),console.error("ERROR",e.detail.message),console.error(e.detail.origin),e.detail.expr&&console.error("Failing expression",e.detail.expr),this.strict&&this._displayError(e)}_copyToClipboard(e){console.log("copyToClipboard",e.value),navigator.clipboard.writeText(e.value)}_showMessage(e,t){if("modal"===e)this.shadowRoot.getElementById("messageContent").innerText=t,this.shadowRoot.getElementById("modalMessage").classList.add("show");else if("sticky"===e||"error"===e||"warn"===e)this.shadowRoot.querySelector(`#${e}`).showToast(t);else{this.shadowRoot.querySelector("#message").showToast(t)}}_createRepeatsFromAttributes(){if(this.repeatsFromAttributesCreated)return;const e=this.querySelectorAll("[data-ref]");e&&Array.from(e).forEach((e=>{if(e.closest("fx-control"))return;const t=e.parentNode.closest("table");let n;n=t?t.cloneNode(!0):e.cloneNode(!0);const r=new Pt;r.setAttribute("ref",e.getAttribute("data-ref")),r.appendChild(n),t?(t.parentNode.insertBefore(r,t),t.parentNode.removeChild(t)):(e.parentNode.insertBefore(r,e),e.parentNode.removeChild(e)),e.setAttribute("insertPoint","")})),this.repeatsFromAttributesCreated=!0}}Ht.outermostHandler=null,Ht.draggedItem=null,customElements.get("fx-fore")||customElements.define("fx-fore",Ht);class jt{static handleRelevance(e){const t=e.getModelItem();t&&t.relevant?(e.removeAttribute("nonrelevant"),e.setAttribute("relevant",""),St.dispatch(this,"relevant",{})):(e.removeAttribute("relevant"),e.setAttribute("nonrelevant",""),St.dispatch(this,"nonrelevant",{}))}static selectRelevant(e,t){return"xml"===t?jt._relevantXmlNodes(e):(console.warn(`relevance selection not supported for type:${e.type}`),e.nodeset)}static _relevantXmlNodes(e){if("keep"===e.getAttribute("nonrelevant"))return e.nodeset;const t=e.getModel().getModelItem(e.nodeset);if(t&&!t.relevant)return null;const n=e.nodeset.cloneNode(!1);return 0===e.nodeset.children.length&&jt._isRelevant(e,e.nodeset)?e.nodeset:jt._filterRelevant(e,e.nodeset,n)}static _filterRelevant(e,t,n){const{childNodes:r}=t;return Array.from(r).forEach((t=>{if(jt._isRelevant(e,t)){const r=t.cloneNode(!1);n.appendChild(r);const{attributes:a}=t;return a&&Array.from(a).forEach((t=>{"empty"!==e.nonrelevant||jt._isRelevant(e,t)?jt._isRelevant(e,t)?r.setAttribute(t.nodeName,t.value):r.removeAttribute(t.nodeName):r.setAttribute(t.nodeName,"")})),jt._filterRelevant(e,t,r)}return null})),n}static _isRelevant(e,t){const n=e.getModel().getModelItem(t);return(t.nodeType!==Node.ATTRIBUTE_NODE||""!==t.nodeValue)&&(!n||!!n.relevant)}}class _t extends(Rt(HTMLElement)){constructor(){super(),this.attachShadow({mode:"open"}),this.credentials="",this.parameters=new Map}connectedCallback(){this.methods=["get","put","post","delete","head","urlencoded-post"],this.model=this.parentNode,this.hasAttribute("id")||console.warn("id is required"),this.id=this.getAttribute("id"),this.instance=this.hasAttribute("instance")?this.getAttribute("instance"):null,this.into=this.hasAttribute("into")?this.getAttribute("into"):null,this.method=this.hasAttribute("method")?this.getAttribute("method"):"get",this.nonrelevant=this.hasAttribute("nonrelevant")?this.getAttribute("nonrelevant"):"remove",this.replace=this.hasAttribute("replace")?this.getAttribute("replace"):"all",this.serialization=this.hasAttribute("serialization")?this.getAttribute("serialization"):"xml",this.mediatype=this.hasAttribute("mediatype")?this.getAttribute("mediatype"):"application/xml",this.responseMediatype=this.hasAttribute("response-mediatype")?this.getAttribute("response-mediatype"):this.mediatype,this.url=this.hasAttribute("url")?this.getAttribute("url"):null,this.targetref=this.hasAttribute("targetref")?this.getAttribute("targetref"):null,this.validate=this.getAttribute("validate")?this.getAttribute("validate"):"true",this.credentials=this.hasAttribute("credentials")?this.getAttribute("credentials"):"same-origin",["same-origin","include","omit"].includes(this.credentials)||console.error(`fx-submission: the value of credentials is not valid. Expected 'same-origin', 'include' or 'omit' but got '${this.credentials}'`,this),this.shadowRoot.innerHTML=this.renderHTML()}renderHTML(){return"\n <slot></slot>\n "}async submit(){await St.dispatch(this,"submit",{submission:this}),await this._submit()}async _submit(){console.log("submitting....",this.getAttribute("id")),this.evalInContext();const e=this.getModel();if(e.recalculate(),"true"===this.validate&&"get"!==this.method){if(!e.revalidate())return console.log("validation failed. Submission stopped"),this.getOwnerForm().classList.add("submit-validation-failed"),St.dispatch(this,"submit-error",{}),void this.getModel().parentNode.refresh(!0)}await this._serializeAndSend()}_getProperty(e){return this.parameters.has(e)?this.parameters.get(e):this.getAttribute(e)}async _serializeAndSend(){const e=this._getProperty("url"),t=this.evaluateAttributeTemplateExpression(e,this);console.log("resolvedUrl",t);const n=this.getInstance();n||St.dispatch(this,"warn",{message:`instance not found ${n.getAttribute("id")}`});const r=n.getAttribute("type");let a;if("none"===this.serialization)a=void 0;else{const e=jt.selectRelevant(this,r);a=this._serialize(r,e)}if("get"===this.method.toLowerCase()&&(a=void 0),t.startsWith("#echo")){const e=this._parse(a,n);return this._handleResponse(e),console.log("### <<<<< submit-done >>>>>"),St.dispatch(this,"submit-done",{}),void this.parameters.clear()}if(t.startsWith("localStore:")){if("get"===this.method||"consume"===this.method){this.replace="instance";const e=t.substring(t.indexOf(":")+1),r=localStorage.getItem(e);if(!r)return St.dispatch(this,"submit-error",{message:`Error reading key ${e} from localstorage`}),void this.parameters.clear();const a=this._parse(r,n);this._handleResponse(a),"consume"===this.method&&localStorage.removeItem(e),console.log("### <<<<< submit-done >>>>>"),St.dispatch(this,"submit-done",{})}if("post"===this.method){const e=t.substring(t.indexOf(":")+1);localStorage.setItem(e,a),this._handleResponse(n.instanceData),console.log("### <<<<< submit-done >>>>>"),St.dispatch(this,"submit-done",{})}if("delete"===this.method){const e=t.substring(t.indexOf(":")+1);localStorage.removeItem(e);const n=(new DOMParser).parseFromString("<data></data>","application/xml");this.replace="instance",this._handleResponse(n),console.log("### <<<<< submit-done >>>>>"),St.dispatch(this,"submit-done",{})}return}const o=this._getHeaders();if(this.methods.includes(this.method.toLowerCase()))try{const e=await fetch(t,{method:this.method,credentials:this.credentials,mode:"cors",headers:o,body:a});if(!e.ok||e.status>400)return void St.dispatch(this,"submit-error",{message:`Error while submitting ${this.id}`});const n=e.headers.get("content-type").toLowerCase();if(n.startsWith("text/")){const r=await e.text();this._handleResponse(r,t,n)}else if(n.startsWith("application/json")){const r=await e.json();this._handleResponse(r,t,n)}else if(n.startsWith("application/xml")){const r=await e.text(),a=(new DOMParser).parseFromString(r,"application/xml");this._handleResponse(a,t,n)}else{const r=await e.blob();this._handleResponse(r,t,n)}console.log(`### <<<<< ${this.id} submit-done >>>>>`),St.dispatch(this,"submit-done",{})}catch(e){St.dispatch(this,"submit-error",{error:e.message})}finally{this.parameters.clear();const e=document.querySelector("[download]");e&&document.body.removeChild(e)}else St.dispatch(this,"error",{message:`Unknown method ${this.method}`})}_parse(e,t){let n=null;return e&&"xml"===t.getAttribute("type")&&(n=(new DOMParser).parseFromString(e,"application/xml")),e&&"json"===t.getAttribute("type")&&(n=JSON.parse(e)),e&&"text"===t.getAttribute("type")&&(n=e),n}_serialize(e,t){if("application/x-www-form-urlencoded"===this.serialization){const e=new URLSearchParams;return Array.from(t.children).forEach((t=>{e.append(t.nodeName,t.textContent)})),e}if("xml"===e){return(new XMLSerializer).serializeToString(t)}if("json"===e)return JSON.stringify(t);if("text"===e)return t;throw new Error("unknown instance type ",e)}_getHeaders(){const e=new Headers,t=this.getInstance(),n=St.getContentType(t,this.serialization);e.append("Content-Type",n),e.has("Accept")&&e.delete("Accept");const r=this.querySelectorAll("fx-header");return Array.from(r).forEach((t=>{const{name:n}=t,r=t.getValue();e.append(n,r)})),e}_getUrlExpr(){return this.storedTemplateExpressions.find((e=>"url"===e.node.nodeName))}_getTargetInstance(){let e;if(e=this.instance?this.model.getInstance(this.instance):this.model.getInstance("default"),!e)throw new Error(`target instance not found: ${e}`);return e}_handleResponse(e,t,n){const r=this._getTargetInstance();if("instance"===this.replace){if(!r)throw new Error(`target instance not found: ${r}`);if(this.targetref){const[t]=yt(this.targetref,r.instanceData.firstElementChild,this);console.log("theTarget",t);const n=e.firstElementChild,a=t.parentNode;a.replaceChild(n,t),console.log("finally ",a)}else if(this.into){const[t]=yt(this.into,r.instanceData.firstElementChild,this);console.log("theTarget",t),e.nodeType===Node.DOCUMENT_NODE?t.appendChild(e.firstElementChild):t.innerHTML=e}else{const t=e;r.instanceData=t}this.model.inited&&(this.model.updateModel(),this.getOwnerForm().refresh(!0))}if("download"===this.replace){const t=this._getProperty("target"),r=document.createElement("a");r.setAttribute("download",t),r.setAttribute("href",`data:${n},${e}`),document.body.appendChild(r),r.click()}if("all"===this.replace){const n=this._getProperty("target");if(n&&"_blank"===n){const t=window.open("","_blank");t.document.write(`<pre>${e}</pre>`),t.document.close()}else document.open(),document.write(e),document.close(),window.location.href=t}if("target"===this.replace&&n.startsWith("text/html")){const t=this._getProperty("target"),n=document.querySelector(t);n?n.innerHTML=e:St.dispatch(this,"submit-error",{message:`targetNode for selector ${t} not found`})}"redirect"===this.replace&&(window.location.href=e)}_handleError(){St.dispatch(this,"submit-error",{})}}customElements.get("fx-submission")||customElements.define("fx-submission",_t);class Xt extends(Rt(HTMLElement)){constructor(){if(super(),this.style.display="none",this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML="",!this.hasAttribute("name"))throw new Error('required attribute "name" missing');this.name=this.getAttribute("name")}connectedCallback(){this.shadowRoot.innerHTML=""}}customElements.get("fx-header")||customElements.define("fx-header",Xt);class qt extends(Rt(HTMLElement)){constructor(){super(),this.attachShadow({mode:"open"}),this.name="",this.valueQuery="",this.value=null}connectedCallback(){this.name=this.getAttribute("name"),this.valueQuery=this.getAttribute("value")}refresh(){const e=Ot(this,this.valueQuery),t=yt(this.valueQuery,e,this,this.precedingVariables);[this.value]=t}setInScopeVariables(e){if(e.has(this.name))return console.error(`The variable ${this.name} is declared more than once`),void St.dispatch(this,"xforms-binding-error",{});e.set(this.name,this),this.inScopeVariables=new Map(e)}}customElements.get("fx-var")||customElements.define("fx-var",qt);class Vt extends(Rt(HTMLElement)){constructor(){super(),this.value=null,this.display=this.style.display,this.required=!1,this.readonly=!1,this.widget=null,this.visited=!1,this.force=!1}getWidget(){throw new Error("You have to implement the method getWidget!")}async refresh(e){e&&(this.force=!0);const t=this.value;if(!this.isNotBound()&&(this.oldVal=this.nodeset?this.nodeset:null,this.evalInContext(),this.isBound())){if(!this.nodeset){if(this.closest("[create]")){let e,t,n;if(this.ref.includes("/")){t=this.ref.substring(0,this.ref.indexOf("/"));n=wt(t,Ot(this.parentNode,this.ref),this),n&&n.nodeType===Node.ELEMENT_NODE&&(this.ref.includes("@")?(e=this.ref.substring(this.ref.indexOf("/")+2),n.setAttribute(e,"")):St.dispatch(this,"warn",{message:'"create" is not implemented for elements'}))}else{const t=Ot(this,this.ref);this.ref.includes("@")?(e=this.ref.substring(this.ref.indexOf("@")+1),t.setAttribute(e,"")):St.dispatch(this,"warn",{message:'"create" is not implemented for elements'})}}else this.setAttribute("nonrelevant","");return}if(this.modelItem=this.getModelItem(),this.modelItem instanceof Dt){if(this.hasAttribute("as")&&"node"===this.getAttribute("as")?(this.modelItem.node=this.nodeset,this.value=this.modelItem.node):this.value=this.modelItem.value,this.modelItem.boundControls.includes(this)||this.modelItem.boundControls.push(this),await this.updateWidgetValue(),this.handleModelItemProperties(),this.getOwnerForm().initialRun&&St.dispatch(this,"init",{}),!this.getOwnerForm().ready)return;null!==this.oldVal&&t!==this.value&&St.dispatch(this,"value-changed",{path:this.modelItem.path,value:this.modelItem.value})}}}refreshFromModelItem(e){}async updateWidgetValue(){throw new Error("You have to implement the method updateWidgetValue!")}handleModelItemProperties(){this.handleRequired(),this.handleReadonly(),this.getOwnerForm().ready&&this.handleValid(),this.handleRelevant()}_getForm(){return this.getModel().parentNode}_dispatchEvent(e){this.getOwnerForm().ready&&St.dispatch(this,e,{})}handleRequired(){this.widget=this.getWidget();const e=this.isRequired();if(!this.modelItem.required)return this.widget.removeAttribute("required"),this.removeAttribute("required"),void(e!==this.modelItem.required&&this._dispatchEvent("optional"));(this.visited||this.force)&&(""===this.modelItem.value?(this.classList.add("isEmpty"),this._toggleValid(!1)):(this.classList.remove("isEmpty"),this._toggleValid(!0))),this.widget.setAttribute("required",""),this.setAttribute("required",""),e!==this.modelItem.required&&this._dispatchEvent("required")}_updateRequired(){this.modelItem.required?((this.visited||this.force)&&(""===this.modelItem.value?(this.classList.add("isEmpty"),this._toggleValid(!1)):(this.classList.remove("isEmpty"),this._toggleValid(!0))),this.widget.setAttribute("required",""),this.setAttribute("required",""),this._dispatchEvent("required")):(this.widget.removeAttribute("required"),this.removeAttribute("required"),this._dispatchEvent("optional"))}_toggleValid(e){e?(this.removeAttribute("invalid"),this.setAttribute("valid","")):(this.removeAttribute("valid"),this.setAttribute("invalid",""))}handleReadonly(){this.isReadonly()!==this.modelItem.readonly&&(this.modelItem.readonly&&(this.widget.setAttribute("readonly",""),this.setAttribute("readonly",""),this._dispatchEvent("readonly")),this.modelItem.readonly||(this.widget.removeAttribute("readonly"),this.removeAttribute("readonly"),this._dispatchEvent("readwrite")))}handleValid(){if(this.isValid()!==this.modelItem.constraint)if(this.modelItem.constraint)this._dispatchEvent("valid"),this.setAttribute("valid",""),this.removeAttribute("invalid");else{if(this.setAttribute("invalid",""),this.removeAttribute("valid"),0!==this.modelItem.alerts.length){if(!this.querySelector("fx-alert")){const{alerts:e}=this.modelItem;e.forEach((e=>{const t=document.createElement("fx-alert");t.innerHTML=e,this.appendChild(t)}))}}this._dispatchEvent("invalid")}}handleRelevant(){const e=this.modelItem.node;if(this.removeAttribute("relevant"),this.removeAttribute("nonrelevant"),Array.isArray(e)&&0===e.length)return this._dispatchEvent("nonrelevant"),void this.setAttribute("nonrelevant","");this.isEnabled()!==this.modelItem.relevant&&(this.modelItem.relevant?(this._dispatchEvent("relevant"),this.setAttribute("relevant","")):(this._dispatchEvent("nonrelevant"),this.setAttribute("nonrelevant","")))}isRequired(){return this.hasAttribute("required")}isValid(){return!this.hasAttribute("invalid")}isReadonly(){return this.hasAttribute("readonly")}isEnabled(){return!this.hasAttribute("nonrelevant")}_fadeOut(e){e.style.opacity=1,function t(){(e.style.opacity-=.1)<0?e.style.display="none":requestAnimationFrame(t)}()}_fadeIn(e,t){e.style.opacity=0,e.style.display=t||"block",function t(){let n=parseFloat(e.style.opacity);(n+=.1)>1||(e.style.opacity=n,requestAnimationFrame(t))}()}}customElements.get("fx-abstract-control")||window.customElements.define("fx-abstract-control",Vt);class Yt extends Vt{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.shadowRoot.innerHTML="\n <style>\n \n :host {\n height: auto;\n font-size: 0.8em;\n font-weight: 400;\n color: red;\n }\n \n </style>\n \n <slot></slot>\n \n "}getWidget(){return this}async updateWidgetValue(){this.innerHTML=this.value}}customElements.get("fx-alert")||customElements.define("fx-alert",Yt);class zt extends Vt{constructor(){super(),this.inited=!1,this.attachShadow({mode:"open"})}static get properties(){return{...Vt.properties,credentials:{type:String},initial:{type:Boolean},src:{type:String}}}_getValueFromHtmlDom(){return"selectedOptions"===this.valueProp?[...this.widget.selectedOptions].map((e=>e.value)).join(" "):this.widget[this.valueProp]}connectedCallback(){this.initial=this.hasAttribute("initial")?this.getAttribute("initial"):null,this.src=this.hasAttribute("src")?this.getAttribute("src"):null,this.loaded=!1,this.initialNode=null,this.debounceDelay=this.hasAttribute("debounce")?this.getAttribute("debounce"):null,this.updateEvent=this.hasAttribute("update-event")?this.getAttribute("update-event"):"blur",this.label=this.hasAttribute("label")?this.getAttribute("label"):null;this.credentials=this.hasAttribute("credentials")?this.getAttribute("credentials"):"same-origin",["same-origin","include","omit"].includes(this.credentials)||console.error(`fx-submission: the value of credentials is not valid. Expected 'same-origin', 'include' or 'omit' but got '${this.credentials}'`,this),this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:inline-block;\n }\n \n </style>\n ${this.renderHTML(this.ref)}\n `,this.widget=this.getWidget(),this.addEventListener("mousedown",(e=>{St.isWidget(e.target)||e.target?.classList.contains("fx-hint")||e.preventDefault(),this.widget.focus()}));const e=this.widget.hasAttribute("multiple")?"selectedOptions":"value";this.valueProp=this.hasAttribute("value-prop")?this.getAttribute("value-prop"):e;let t=this.widget;if(this.hasAttribute("listen-on")){const e=this.getAttribute("listen-on"),n=this.querySelector(e);n&&(t=n)}this.addEventListener("keyup",(()=>{kt.dataChanged=!0})),"enter"===this.updateEvent&&(this.widget.addEventListener("keyup",(e=>{13===e.keyCode&&(e.preventDefault(),this.setValue(this._getValueFromHtmlDom()))})),this.updateEvent="blur"),this.debounceDelay?t.addEventListener(this.updateEvent,function(e,t,n=300){let r;return(...a)=>{clearTimeout(r),r=setTimeout((()=>{t.apply(e,a)}),n)}}(this,(()=>{this.setValue(this._getValueFromHtmlDom())}),this.debounceDelay)):(t.addEventListener(this.updateEvent,(e=>{this.setValue(this._getValueFromHtmlDom())})),t.addEventListener("blur",(e=>{this.setValue(this._getValueFromHtmlDom())}),{once:!0})),this.addEventListener("return",(e=>{const t=e.detail.nodeset;e.stopPropagation(),this._replaceNode(t)})),this.widget.addEventListener("focus",(()=>{})),this.template=this.querySelector("template"),this.boundInitialized=!1,this.static=!!this.widget.hasAttribute("static")}_debounce(e,t=300){let n;return(...r)=>{const a=this;clearTimeout(n),n=setTimeout((()=>{e.apply(a,r)}),t)}}setValue(e){const t=this.getModelItem();if(this.getAttribute("class")?this.classList.add("visited"):this.setAttribute("class","visited"),t?.readonly)return void console.warn("attempt to change readonly node",t);if("node"===this.getAttribute("as")){const e=this.shadowRoot.getElementById("replace"),n=this.getWidget()[this.valueProp];return e.replace(this.nodeset,n),void(t&&n&&n!==t.value&&(t.value=n,kt.dataChanged=!0,e.actionPerformed()))}const n=this.shadowRoot.getElementById("setvalue");n.setValue(t,e),this.modelItem instanceof Dt&&!this.modelItem?.boundControls.includes(this)&&this.modelItem.boundControls.push(this),n.actionPerformed()}_replaceNode(e){e.nodeType===Node.ATTRIBUTE_NODE?this.modelItem.node.nodeValue=e.nodeValue:e.nodeType===Node.ELEMENT_NODE?this.modelItem.node.replaceWith(e.cloneNode(!0)):e.nodeType===Node.TEXT_NODE?this.modelItem.node.nodeValue=e.textContent:St.dispatch(this,"warn",{message:"trying to replace a node that is neither an Attribute, Elemment or Text node"})}renderHTML(e){return`\n ${this.label?`${this.label}`:""}\n <slot></slot>\n ${this.hasAttribute("as")&&"node"===this.getAttribute("as")?'<fx-replace id="replace" ref=".">':`<fx-setvalue id="setvalue" ref="${e}"></fx-setvalue>`}\n\n `}getWidget(){if(this.widget)return this.widget;let e=this.querySelector(".widget");if(e||(e=this.querySelector("input"),e&&!e.classList.contains("widget")&&e.classList.add("widget")),!e){const e=document.createElement("input");return e.classList.add("widget"),e.setAttribute("type","text"),this.appendChild(e),e}return e}async updateWidgetValue(){let{widget:e}=this;if(e||(e=this),"checked"!==this.valueProp)if("selectedOptions"!==this.valueProp)if(this.hasAttribute("as")){const t=this.getAttribute("as");if("text"===t){const t=new XMLSerializer,n=St.prettifyXml(t.serializeToString(this.nodeset));e.value=n}if("node"===t&&this.nodeset!==e.value){const t=this.nodeset;if(e.value&&t!==this.widget.value)return void(e.value=this.nodeset.cloneNode(!0));e.value=this.nodeset.cloneNode(!0)}}else{if(this.src&&!this.loaded&&this.modelItem.relevant)return this.initial&&(this.initialNode=wt(this.initial,this.nodeset,this)),await this._loadForeFromSrc(),void(this.loaded=!0);e.value!==this.value&&(e.value=this.value)}else{const e=new Set(this.value.split(" "));for(const t of[...this.widget.querySelectorAll("option")])e.has(t.value)?t.selected=!0:t.selected=!1}else"true"===this.value?e.checked=!0:e.checked=!1}async _loadForeFromSrc(){console.info(`%cControl ref="${this.ref}" is loading ${this.src}`,"background:#64b5f6; color:white; padding:0.5rem; display:inline-block; white-space: nowrap; border-radius:0.3rem;width:100%;");try{const e=await fetch(this.src,{method:"GET",credentials:this.credentials,mode:"cors",headers:{"Content-Type":"text/html"}});let t;t=e.headers.get("content-type").toLowerCase().startsWith("text/html")?await e.text().then((e=>(new DOMParser).parseFromString(e,"text/html"))):"done";const n=t.querySelector("fx-fore"),r=document.importNode(n,!0);r.classList.add("widget"),r.addEventListener("model-construct-done",(e=>{const t=r.querySelector("fx-instance");if(this.initial){const e=(new DOMParser).parseFromString("<data></data>","application/xml");this.initialNode=wt(this.initial,this.nodeset,this),e.firstElementChild.appendChild(this.initialNode.cloneNode(!0)),t.instanceData=e}r.model=r.querySelector("fx-model"),r.model.updateModel(),r.refresh(!0)}),{once:!0});const a=this.querySelector("input");this.hasAttribute("shadow")?(a.parentNode.removeChild(a),this.shadowRoot.appendChild(r)):this.loaded||a.replaceWith(r),n||St.dispatch("error",{detail:{message:`Fore element not found in '${this.src}'. Maybe wrapped within 'template' element?`}}),St.dispatch("loaded",{detail:{fore:n}})}catch(e){St.dispatch(this,"error",{origin:this,message:`control couldn't be loaded from src '${this.src}'`,level:"Error"})}}getTemplate(){return this.querySelector("template")}async refresh(e){super.refresh(e);const t=this.getWidget();this._handleBoundWidget(t),this._handleDataAttributeBinding(),St.refreshChildren(this,e)}_handleDataAttributeBinding(){const e=this.querySelector("[data-ref]");e&&(this.boundList=e,e.getAttribute("data-ref"),this._handleBoundWidget(e))}_handleBoundWidget(e){if(this.boundInitialized&&this.static)return;const t=e.hasAttribute("ref")?e.getAttribute("ref"):e.getAttribute("data-ref");if(e&&t){const n=yt(t,Ot(this,t),this),{children:r}=e;if(Array.from(r).forEach((e=>{"template"!==e.nodeName.toLowerCase()&&e.parentNode.removeChild(e)})),Array.isArray(n)&&0===n.length)return;const{template:a}=this;if(a){if("SELECT"===this.widget.nodeName&&this.widget.hasAttribute("selection")&&"open"===this.widget.getAttribute("selection")){const e=this.template.firstElementChild,t=document.createElement("option");this.widget.insertBefore(t,e)}if(0!==n.length){const e=document.createDocumentFragment();Array.from(n).forEach((t=>{const n=this.createEntry();e.appendChild(n),this.updateEntry(n,t)})),this.template.parentNode.appendChild(e)}else{const e=this.createEntry();this.template.parentNode.appendChild(e),this.updateEntry(e,n)}this.boundInitialized=!0}}}updateEntry(e,t){const n=this._getValueAttribute(e);if(!n)return;const r=n.value,a=bt(r.substring(1,r.length-1),t,e);n.value=a,this.value===a&&e.setAttribute("selected","selected");const o=e.textContent;this.evalLabel(o,t,e)}evalLabel(e,t,n){const r=e.substring(1,e.length-1);if(!r)return;const a=bt(r,t,this);n.textContent=a}createEntry(){return this.template.content.firstElementChild.cloneNode(!0)}_getValueAttribute(e){let t;return Array.from(e.attributes).forEach((e=>{-1!==e.value.indexOf("{")&&(t=e)})),t}}customElements.get("fx-control")||window.customElements.define("fx-control",zt);class Jt extends(Rt(HTMLElement)){static get properties(){return{...super.properties}}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.src=this.hasAttribute("src")?this.getAttribute("src"):null;this.shadowRoot.innerHTML="\n <style>\n \n :host {\n display: block;\n }\n \n </style>\n \n <slot></slot>\n \n ",this.getOwnerForm().registerLazyElement(this)}async refresh(e){!e&&this.hasAttribute("refresh-on-view")||this.isBound()&&(this.evalInContext(),this.modelItem=this.getModelItem(),this.modelItem&&!this.modelItem.boundControls.includes(this)&&this.modelItem.boundControls.push(this),this.handleModelItemProperties())}handleModelItemProperties(){this.handleRelevant()}_getForm(){return this.getModel().parentNode}handleRelevant(){if(!this.modelItem)return this.removeAttribute("relevant",""),this.setAttribute("nonrelevant",""),void this.dispatchEvent(new CustomEvent("disabled",{}));this.isEnabled()!==this.modelItem.enabled&&(this.modelItem.relevant?(this.removeAttribute("nonrelevant",""),this.setAttribute("relevant",""),this.dispatchEvent(new CustomEvent("enabled",{}))):(this.removeAttribute("relevant",""),this.setAttribute("nonrelevant",""),this.dispatchEvent(new CustomEvent("disabled",{}))))}isReadonly(){return!!this.hasAttribute("readonly")}isEnabled(){return"none"!==this.style.display}}customElements.get("fx-container")||window.customElements.define("fx-container",Jt);class Qt extends Jt{static get properties(){return{...super.properties,collapse:{type:Boolean,reflect:!0}}}constructor(){super(),this.collapse=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","group")}render(){return"\n <slot></slot>\n "}handleModelItemProperties(){this.handleRelevant()}initializeChildren(e){Array.from(e.children).forEach((e=>{if(St.isUiElement(e.nodeName))e.init(this.model);else if(0!==e.children.length){Array.from(e.children).forEach((e=>{this.initializeChildren(e)}))}})),console.groupEnd()}async refresh(e){super.refresh(e),St.refreshChildren(this,e)}}customElements.get("fx-group")||window.customElements.define("fx-group",Qt);class Kt extends Vt{static get styles(){return"\n :host {\n display: block;\n height: auto;\n font-size: 0.8em;\n font-weight: 400;\n font-style: italic;\n }\n "}static get properties(){return{...super.properties}}render(){return"\n <slot></slot>\n "}}customElements.get("fx-hint")||customElements.define("fx-hint",Kt);class Wt extends Vt{constructor(){super(),this.attachShadow({mode:"open"}),this.valueAttr=this.hasAttribute("value")?this.getAttribute("value"):null,this.readonly=!0}connectedCallback(){this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display: inline-block;\n max-width:100%;\n }\n #widget {\n display: inline-block;\n }\n .label{\n display: inline-block;\n }\n #value{\n max-width:100%;\n }\n \n </style>\n \n <slot name="label"></slot>\n \n <span id="value">\n <slot name="default"></slot>\n </span>\n \n ',this.mediatype=this.hasAttribute("mediatype")?this.getAttribute("mediatype"):null}async refresh(){this.ref&&await super.refresh(),this.valueAttr&&(this.value=this.getValue(),await this.updateWidgetValue())}getValue(){try{const e=Ot(this,this.valueAttr);return this.hasAttribute("html")?yt(this.valueAttr,e,this)[0]:function(e,t,n,r=null,a=n){try{const a=mt(e,t,n);return Je(e,t,r,{},{currentContext:{formElement:n},functionNameResolver:ft,moduleImports:{xf:ot},namespaceResolver:a})}catch(t){n.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,detail:{origin:n,message:`Expression '${e}' failed`,expr:e,level:"Error"}}))}}(this.valueAttr,e,this)[0]}catch(e){console.error(e),St.dispatch(this,"error",{message:e})}return null}getWidget(){return this.shadowRoot.getElementById("value")}handleReadonly(){this.setAttribute("readonly","readonly")}async updateWidgetValue(){const e=this.shadowRoot.getElementById("value");if(e.innerHTML="","html"!==this.mediatype){if("image"===this.mediatype){const t=document.createElement("img");return t.setAttribute("src",this.value),this.innerHTML="",void e.appendChild(t)}e.innerHTML=this.value}else if(this.modelItem.node){this.shadowRoot.querySelector("#default");const{node:t}=this.modelItem;if(t.nodeType)return void e.append(t);const n=(new DOMParser).parseFromString(t,"text/html").body.childNodes;return void Array.from(n).forEach((t=>{e.append(t)}))}}isReadonly(){return!0}}customElements.get("fx-output")||customElements.define("fx-output",Wt);class Zt extends(Lt(Rt(HTMLElement))){static get properties(){return{inited:{type:Boolean}}}constructor(){super(),this.inited=!1,this.addEventListener("click",this._dispatchIndexChange),this.addEventListener("focusin",this._dispatchIndexChange),this.attachShadow({mode:"open",delegatesFocus:!0}),this.dropTarget=null}connectedCallback(){super.connectedCallback(),this.display=this.style.display;this.shadowRoot.innerHTML="\n \n <slot></slot>\n \n ",this.getOwnerForm().registerLazyElement(this),this.ref=`${this.parentNode.ref}`,this.tabindex=0}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._dispatchIndexChange),this.removeEventListener("focusin",this._handleFocus)}init(){this.inited=!0}_dispatchIndexChange(){this.dispatchEvent(new CustomEvent("item-changed",{composed:!1,bubbles:!0,detail:{item:this,index:this.index}}))}refresh(e){this.modelItem=this.getModelItem(),this.modelItem.boundControls.includes(this)||(this.modelItem.boundControls.push(this),this.modelItem&&!this.modelItem.relevant?(this.removeAttribute("relevant"),this.setAttribute("nonrelevant","")):(this.removeAttribute("nonrelevant"),this.setAttribute("relevant",""))),St.refreshChildren(this,e)}}customElements.get("fx-repeatitem")||window.customElements.define("fx-repeatitem",Zt);class en extends(Lt(Rt(HTMLElement))){static get properties(){return{...super.properties,index:{type:Number},template:{type:Object},focusOnCreate:{type:String},initDone:{type:Boolean},repeatIndex:{type:Number},nodeset:{type:Array}}}constructor(){super(),this.ref="",this.dataTemplate=[],this.isDraggable=null,this.dropTarget=null,this.focusOnCreate="",this.initDone=!1,this.repeatIndex=1,this.nodeset=[],this.inited=!1,this.index=1,this.repeatSize=0,this.attachShadow({mode:"open",delegatesFocus:!0})}get repeatSize(){return this.querySelectorAll(":scope > fx-repeatitem").length}set repeatSize(e){this.size=e}setIndex(e){this.index=e;const t=this.querySelectorAll(":scope > fx-repeatitem");this.applyIndex(t[this.index-1])}applyIndex(e){this._removeIndexMarker(),e&&e.setAttribute("repeat-index","")}get index(){return parseInt(this.getAttribute("index"),10)}set index(e){this.setAttribute("index",e)}_getRef(){return this.getAttribute("ref")}connectedCallback(){super.connectedCallback(),this.ref=this.getAttribute("ref"),this.addEventListener("item-changed",(e=>{const{item:t}=e.detail,n=Array.from(this.children).indexOf(t);this.applyIndex(this.children[n]),this.index=n+1})),document.addEventListener("index-changed",(e=>{if(e.stopPropagation(),!e.target===this)return;const{index:t}=e.detail;this.index=parseInt(t,10),this.applyIndex(this.children[t-1])})),this.mutationObserver=new MutationObserver((e=>{if("childList"===e[0].type){const t=e[0].addedNodes[0];if(t){const e=tt.resolveInstance(this,this.ref),n=tt.getPath(t,e);St.dispatch(this,"path-mutated",{path:n,index:this.index})}}})),this.getOwnerForm().registerLazyElement(this);this.shadowRoot.innerHTML='\n <style>\n \n :host{\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n .fade-out-bottom {\n -webkit-animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n animation: fade-out-bottom 0.7s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;\n }\n \n </style>\n \n <slot name="header"></slot>\n <slot></slot>\n \n '}_createNewRepeatItem(){const e=document.createElement("fx-repeatitem");this.isDraggable&&(e.setAttribute("draggable","true"),e.setAttribute("tabindex",0));const t=this._clone();return e.appendChild(t),e}init(){console.log("##### repeat init ",this.id),this._evalNodeset(),this._initTemplate(),this._initRepeatItems(),this.setAttribute("index",this.index),this.inited=!0}_evalNodeset(){const e=Ot(this.getAttributeNode("ref")||this,this.ref);this.mutationObserver&&e.nodeName&&this.mutationObserver.observe(e,{childList:!0,subtree:!0});const t=yt(this.ref,e,this);1===t.length&&Array.isArray(t[0])?this.nodeset=t[0]:this.nodeset=t}async refresh(e){this.inited||this.init(),this._evalNodeset();const t=this.querySelectorAll(":scope > fx-repeatitem"),n=t.length;let r=1;Array.isArray(this.nodeset)&&(r=this.nodeset.length);const a=r;if(a<n)for(let e=n;e>a;e-=1){const n=t[e-1];n.parentNode.removeChild(n),this.getOwnerForm().unRegisterLazyElement(n)}if(a>n)for(let e=n+1;e<=a;e+=1){const t=this._createNewRepeatItem();this.appendChild(t),this._initVariables(t),t.nodeset=this.nodeset[e-1],t.index=e,this.getOwnerForm().scanForNewTemplateExpressionsNextRefresh()}for(let e=0;e<n;e+=1){const n=t[e];this.getOwnerForm().registerLazyElement(n),n.nodeset!==this.nodeset[e]&&(n.nodeset=this.nodeset[e])}this.getOwnerForm().lazyRefresh&&!e||St.refreshChildren(this,e),this.setIndex(this.index)}_fadeOut(e){e.style.opacity=1,function t(){(e.style.opacity-=.1)<0?e.style.display="none":requestAnimationFrame(t)}()}_fadeIn(e){e&&(e.style.opacity=0,e.style.display=this.display,function t(){let n=parseFloat(e.style.opacity);(n+=.1)>1||(e.style.opacity=n,requestAnimationFrame(t))}())}_initTemplate(){this.template=this.querySelector("template"),this.dropTarget=this.template.getAttribute("drop-target"),this.isDraggable=this.template.hasAttribute("draggable")?this.template.getAttribute("draggable"):null,null===this.template&&this.dispatchEvent(new CustomEvent("no-template-error",{composed:!0,bubbles:!0,detail:{message:`no template found for repeat:${this.id}`}})),this.shadowRoot.appendChild(this.template)}_initRepeatItems(){this.nodeset.forEach(((e,t)=>{const n=this._createNewRepeatItem();n.nodeset=this.nodeset[t],n.index=t+1,this.appendChild(n),1===n.index&&this.applyIndex(n),St.dispatch(this,"item-created",{nodeset:n.nodeset,pos:t+1}),this._initVariables(n)}))}_initVariables(e){const t=new Map(this.inScopeVariables);e.setInScopeVariables(t),function e(n){for(const r of n.children)"setInScopeVariables"in r&&r.setInScopeVariables(t),e(r)}(e)}_clone(){this.template=this.shadowRoot.querySelector("template");const e=this.template.content.cloneNode(!0);return document.importNode(e,!0)}_removeIndexMarker(){Array.from(this.children).forEach((e=>{e.removeAttribute("repeat-index")}))}setInScopeVariables(e){this.inScopeVariables=new Map(e)}}customElements.get("fx-repeat")||window.customElements.define("fx-repeat",en);class tn extends Jt{constructor(){super(),this.formerCase={},this.selectedCase=null,this.cases=null}connectedCallback(){super.connectedCallback&&super.connectedCallback();this.shadowRoot.innerHTML="\n <style>\n \n :host ::slotted(fx-case.selected-case){\n display: block !important;\n }\n \n </style>\n \n <slot></slot>\n \n ",this.cases=[],this.formerCase=null,this.selectedCase=null}async refresh(e){super.refresh(e),0===this.cases.length&&(this.cases=Array.from(this.querySelectorAll(":scope > fx-case"))),this.isBound()&&this._handleBoundSwitch(),this.selectedCase||(this.selectedCase=this.cases[0],this.toggle(this.selectedCase)),St.refreshChildren(this.selectedCase,e)}_dispatchEvents(){this.formerCase&&this.formerCase!==this.selectedCase&&St.dispatch(this.formerCase,"deselect",{}),this.selectedCase.classList.contains("selected-case")&&St.dispatch(this.selectedCase,"select",{})}_resetVisited(){const e=this.selectedCase.querySelectorAll(".visited");Array.from(e).forEach((e=>{e.classList.remove("visited")}))}_handleBoundSwitch(){Array.from(this.cases).forEach((e=>{e.getAttribute("name")===this.modelItem?.value&&this.toggle(e)}))}toggle(e){this.selectedCase=e,Array.from(this.cases).forEach((e=>{e===this.selectedCase?(e.classList.remove("deselected-case"),e.classList.add("selected-case"),e.inert=!1):(e.classList.remove("selected-case"),e.classList.add("deselected-case"),e.inert=!0,this._resetVisited())})),this.selectedCase!==e&&(this.selectedCase=e),this._dispatchEvents(),this.formerCase=this.selectedCase,this.getOwnerForm().scanForNewTemplateExpressionsNextRefresh()}}customElements.get("fx-switch")||window.customElements.define("fx-switch",tn);class nn extends Vt{connectedCallback(){this.attachShadow({mode:"open"}),this.ref=this.hasAttribute("ref")?this.getAttribute("ref"):null,this.debounceDelay=this.hasAttribute("debounce")?this.getAttribute("debounce"):null;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n cursor:pointer;\n }\n \n </style>\n ${this.renderHTML()}\n `;const e=this.shadowRoot.querySelector("slot");e.addEventListener("slotchange",(()=>{const t=e.assignedElements({flatten:!0});t[0].setAttribute("tabindex","0"),"BUTTON"!==t[0].nodeName&&t[0].setAttribute("role","button");const n=t[0];this.addEventListener("mousedown",(e=>{console.log("target",e.target.nodeName),e.target.focus()})),this.debounceDelay?this.addEventListener("click",function(e,t,n=300){let r;return(...a)=>{r||t.apply(e,a),clearTimeout(r),r=setTimeout((()=>(r=void 0,null)),n)}}(this,(e=>{this.performActions(e)}),this.debounceDelay)):n.addEventListener("click",(e=>this.performActions(e))),this.widget=n,"BUTTON"!==n.nodeName&&n.addEventListener("keypress",(e=>{"Space"!==e.code&&"Enter"!==e.code||this.performActions(e)}))}))}renderHTML(){return"\n <slot></slot>\n "}getWidget(){return this.widget}async updateWidgetValue(){return null}handleReadonly(){super.handleReadonly(),this.widget.hasAttribute("readonly")?this.widget.setAttribute("disabled","disabled"):this.widget.removeAttribute("disabled")}async performActions(e){const t=this.closest("fx-repeatitem");t&&t.click(),this.querySelectorAll("fx-var").forEach((e=>e.refresh()));for(let t=0;t<this.children.length;t+=1){const n=this.children[t];if("function"==typeof n.execute){if(e&&(e.preventDefault(),e.stopPropagation(),e.type&&n.event&&e.type!==n.event))return;await n.execute(e)}}}async refresh(){super.refresh()}}customElements.get("fx-trigger")||customElements.define("fx-trigger",nn);class rn extends Jt{connectedCallback(){this.hasAttribute("label")&&(this.label=this.getAttribute("label")),this.hasAttribute("name")&&(this.name=this.getAttribute("name")),this.hasAttribute("selected")&&(this.selected=this.getAttribute("selected"));const e=`\n ${this.label?`<span>${this.label}</span>`:""}\n <slot></slot>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n visibility: none;\n }\n \n </style>\n ${e}\n `}}customElements.get("fx-case")||window.customElements.define("fx-case",rn);class an extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){const e=this.closest("fx-fore");this.render("\n :host {\n position:absolute;\n display: block;\n width:var(--inspector-handle-width);\n background:var(--inspector-bg);\n top:0;\n right:0;\n bottom:0;\n height: 100%;\n background: var(--inspector-bg);\n color: white;\n /*max-height: 33%;*/\n overflow: scroll;\n transition:width 0.3s ease;\n z-index:100;\n }\n :host([open]){\n width: 30%;\n }\n details{\n margin:1rem;\n }\n .main{\n padding-left:var(--inspector-handle-width);\n color:var(--inspector-color);\n overflow:scroll;\n height:100%;\n }\n pre{\n background:var(--inspector-pre-bg);\n color:var(--inspector-color);\n overflow:scroll;\n padding:0.2rem;\n }\n .handle{\n display:block;\n height:100%;\n width:var(--inspector-handle-width);\n background:var(--inspector-handle-bg);\n opacity:0.7;\n position:absolute;\n left:0;\n color:white;\n cursor:pointer;\n }\n .handle:hover{\n opacity:1;\n }\n .handle::before{\n content: 'Data Inspector';\n white-space: nowrap;\n transform: rotate(-90deg);\n display: inline-block;\n position: absolute;\n left: -85px;\n width: 200px;\n top: 40px;\n }\n summary{\n cursor:pointer;\n }\n "),e.addEventListener("refresh-done",(()=>{this.update()}))}update(){try{const e=this.shadowRoot.querySelectorAll("pre"),t=this.closest("fx-fore");Array.from(e).forEach((e=>{const n=t.getModel().getInstance(e.getAttribute("id"));"xml"===n.getAttribute("type")&&(e.innerText=this.serializeDOM(n.instanceData)),"json"===n.getAttribute("type")&&(e.innerText=JSON.stringify(n.instanceData,void 0,2))}))}catch(e){console.warn("caught problem in inspector",e.message)}}render(e){const t=this.closest("fx-fore"),n=Array.from(t.querySelectorAll("fx-instance"));this.shadowRoot.innerHTML=`\n <style>\n ${e}\n </style>\n <div class="main">\n <slot></slot>\n <span class="handle"></span>\n ${n.map((e=>`\n <details>\n <summary>${e.id}</summary>\n <pre id="${e.id}"></pre>\n </details>\n `))}\n </div>\n `;this.shadowRoot.querySelector(".handle").addEventListener("click",(e=>{this.hasAttribute("open")?this.removeAttribute("open"):this.setAttribute("open","open")}))}serializeDOM(e){if(!e)return void console.warn("no data to serialize");return at((new XMLSerializer).serializeToString(e))}}customElements.get("fx-inspector")||customElements.define("fx-inspector",an);class on extends HTMLElement{static get properties(){return{id:String}}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.shadowRoot.innerHTML=this.render("\n :host {\n display:none;\n height: 100vh;\n width:100vw;\n position:fixed;\n left:0;\n top:0;\n right:0;\n bottom:0;\n transition:opacity 0.4s linear;\n }\n\n "),this.id=this.getAttribute("id");const e=this.querySelector(".close-dialog");e&&e.addEventListener("click",(()=>{this.classList.remove("show")})),this.setAttribute("role","dialog"),this.setAttribute("aria-modal","false"),this.focus()}render(e){return`\n <style>\n ${e}\n </style>\n <slot></slot>\n `}open(){window.addEventListener("keyup",(e=>{"Escape"===e.key&&this.hide()}),{once:!0}),this.classList.add("show")}async hide(){await St.fadeOutElement(this,400),this.classList.remove("show")}}customElements.get("fx-dialog")||customElements.define("fx-dialog",on);class sn extends zt{static get properties(){return{...super.properties,valueAttr:{type:String}}}constructor(){super(),this.valueAttr=this.hasAttribute("value")?this.getAttribute("value"):null}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",(e=>{if(St.isWidget(e.target)||(e.preventDefault(),e.stopImmediatePropagation()),"LABEL"===e.target.nodeName){ut(e.target.getAttribute("for"),this).focus()}})),this.addEventListener("mousedown",(e=>{if(this.querySelectorAll("[value]"),"LABEL"===e.target.nodeName){ut(e.target.getAttribute("for"),this).focus()}})),this.addEventListener("click",(e=>{e.preventDefault,e.stopPropagation();const t=this.querySelectorAll("[value]");let n;"LABEL"===e.target.nodeName&&(n=ut(e.target.getAttribute("for"),this),n.checked=!n.checked);let r="";Array.from(t).forEach((e=>{e.checked&&(r+=` ${e.getAttribute("value")}`)})),this.setAttribute("value",r.trim());const a=tt.getClosest("[ref]",this.parentNode);if(!a)return;const o=a.getModelItem(),s=this.shadowRoot.getElementById("setvalue");s.setValue(o,r.trim()),s.actionPerformed()}))}getWidget(){return this}async updateWidgetValue(){const e=tt.getClosest("[ref]",this.parentNode);e&&(this.value=e.value),this.setAttribute("value",this.value)}updateEntry(e,t){const n=St.createUUID(),r=e.querySelector("label"),a=St.getExpression(r.textContent);if(t.nodeType){const e=bt(a,t,this);r.textContent=e}else{const e=St.getExpression(a);r.textContent=t[e]}r.setAttribute("for",n);const o=e.querySelector("[value]"),s=o.value,i=St.getExpression(s);let l;l=t.nodeType?bt(i,t,e):t[i];const c=` ${l} `,u=` ${this.getAttribute("value")} `;o.value=l,o.setAttribute("id",n),-1!==u.indexOf(c)&&(o.checked=!0)}}customElements.get("fx-items")||customElements.define("fx-items",sn);class ln extends(Lt(Rt(HTMLElement))){}customElements.get("fx-droptarget")||window.customElements.define("fx-droptarget",ln);class cn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.eventName="",this.shortName="",this.shortInfo="",this.shortPath="",this.xpath=""}connectedCallback(){this.eventName=this.getAttribute("event-name"),this.shortName=this.getAttribute("short-name"),this.shortInfo=this.hasAttribute("short-info")?this.getAttribute("short-info"):"",this.xpath=this.getAttribute("xpath");const e=`\n <details class="info send">\n <summary>\n <span class="log-name"><a href="#" title="${("/"+this.xpath.substring(this.xpath.indexOf("/fx-fore"),this.xpath.length)).replaceAll("fx-","")}" data-path="${this.xpath}">${this.shortName}</a></span>\n <span class="short-info">${this.shortInfo}</span>\n <span class="event-name">${this.eventName}</span> \n </summary>\n <slot></slot>\n </details>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n height: auto;\n font-size: 0.8em;\n font-weight: 400;\n\n }\n\n a,a:link,a:visited{\n color:black;\n }\n a{\n position:relative;\n }\n a[alt]:hover::after {\n content:attr(alt);\n position:absolute; \n left:0;\n top:1em;\n border.thin solid;\n padding:0.5em;\n background:white;\n z-index:1;\n min-width:5em;\n border:thin solid;\n white-space:nowrap;\n overflow-wrap:break-word;\n }\n\n .info{\n padding:0 0.5em;\n margin:0.1rem 0;\n background:white;\n position:relative;\n border:1px solid #ddd;\n border-radius:1em; \n box-shadow: 1px 1px 5px 0px rgba(79, 136, 183, 0.8);\n }\n :host(.action) .info{\n border-radius:0;\n border-color:steelblue;\n }\n\n .info label{\n grid-area:left;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .info a{\n grid-area:right;\n justify-self:end;\n }\n .info:hover{\n outline:3px solid lightblue; \n transition:height 0.4s;\n }\n\n summary{\n padding:1em;\n display:flex;\n flex-wrap:wrap;\n padding:0.5em 0;\n cursor:pointer;\n gap:0.25em;\n }\n/*\n .log-name{\n font-size:1.2em;\n }\n .log-name, .short-info{\n width:10em;\n }\n*/\n .event-name{\n width:12em;\n text-align:right;\n }\n .short-info{\n flex:3;\n overflow:hidden;\n white-space:nowrap;\n text-overflow:ellipsis;\n }\n \n </style>\n ${e}\n `}}customElements.get("fx-log-item")||customElements.define("fx-log-item",cn);class un extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.listenTo=[],this.listeners=[]}connectedCallback(){localStorage.getItem("fx-log-settings")?this.listenTo=JSON.parse(localStorage.getItem("fx-log-settings")):this.listenTo=un.defaultSettings();this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display:block;\n position:relative;\n width:100%;\n border:thin solid #efefef;\n font-family: Verdana, Sans;\n\n margin:0;\n border:thin solid #ddd;\n }\n .boxes{\n column-width:14rem;\n overflow:auto;\n margin-bottom:5em;\n padding:1em;\n }\n .boxes > span{\n display:inline-block;\n width:14rem;\n }\n \n .buttons{\n position:absolute;\n top:0;\n right:0;\n }\n .buttons button{\n padding:0;\n }\n button{\n float:right;\n }\n button{\n border:none;\n background:transparent;\n width:2.25rem;\n height:2.25rem;\n cursor:pointer;\n }\n button#reset{\n padding:0;\n height:1rem;\n }\n header{\n padding:0.5rem;\n margin:0;\n border-bottom:2px solid #ddd;\n }\n #settings{\n padding:1em;\n }\n \n \n </style>\n \n <section id="settings">\n <header>log settings <button id="reset">reset</button></header>\n <div class="boxes"></div>\n </section>\n \n ';window.document.querySelector("fx-fore")||console.error("fx-fore element not found in this page.");const e=this.shadowRoot.querySelector(".boxes");this.listenTo.forEach((t=>{const n=document.createElement("span");e.append(n);const r=document.createElement("label");r.setAttribute("title",t.description),r.setAttribute("for",t.name),r.innerText=t.name;const a=document.createElement("input");a.setAttribute("type","checkbox"),a.setAttribute("name",t.name),a.setAttribute("id",t.name),t.show&&a.setAttribute("checked",""),n.append(a),n.append(r),a.addEventListener("click",(e=>{if(!e.target.checked){document.querySelector("fx-fore").removeEventListener(t.name,this._log)}const n=this.listenTo.find((e=>e.name===t.name));e.target.checked?n.show=!0:n.show=!1,localStorage.setItem("fx-log-settings",JSON.stringify(this.listenTo))}))}));this.shadowRoot.querySelector("#reset").addEventListener("click",(e=>{localStorage.removeItem("fx-log-settings"),window.location.reload()}))}static defaultSettings(){return[{name:"action-performed",show:!1,description:"fires after an action has been performed"},{name:"click",show:!1,description:""},{name:"deleted",show:!1,description:"fires after a delete action has been executed"},{name:"deselect",show:!1,description:"fires when fx-case is deselected"},{name:"dialog-hidden",show:!1,description:"fires after fx-dialog has been hidden"},{name:"dialog-shown",show:!1,description:"fired when a dialog has been shown"},{name:"error",show:!1,description:"fires after an error occurred"},{name:"execute-action",show:!0,description:"fires when an action executes"},{name:"init",show:!1,description:"fires when a control initializes"},{name:"index-changed",show:!1,description:"fires when the repeat index changes"},{name:"insert",show:!1,description:"fires when an fx-insert is executed"},{name:"instance-loaded",show:!1,description:"fires after an fx-instance has been loaded"},{name:"invalid",show:!1,description:"fires after a control became invalid"},{name:"item-changed",show:!1,description:"fires when a repeat item was changed"},{name:"item-created",show:!1,description:"fires when a repeat item was created"},{name:"loaded",show:!1,description:"fires after a fx-load has loaded"},{name:"model-construct",show:!1,description:"fires when a model gets constructed"},{name:"model-construct-done",show:!1,description:"fires after model initialization"},{name:"nonrelevant",show:!1,description:"fires after an fx-control became nonrelevant"},{name:"optional",show:!1,description:"fires after an fx-control became optional"},{name:"outermost-action-end",show:!1,description:"fires when an outermost action block is finished"},{name:"outermost-action-start",show:!1,description:"fires when an outermost action block is started"},{name:"path-mutated",show:!1,description:"fires when a path in a repeat has been mutated"},{name:"readonly",show:!1,description:"fires after an fx-control became readonly"},{name:"readwrite",show:!1,description:"fires after an fx-control became readwrite"},{name:"ready",show:!1,description:"fires after a fx-fore page has been completely initialized"},{name:"rebuild-done",show:!1,description:"fires after a rebuild has taken place"},{name:"recalculate-done",show:!1,description:"fires after a recalculate has taken place"},{name:"refresh-done",show:!1,description:"fires after a refresh has been done"},{name:"relevant",show:!1,description:"fires after a fx-control has become relevant"},{name:"reload",show:!1,description:"fires when a fx-reload action executes"},{name:"required",show:!1,description:"fires after an fx-control has become required"},{name:"return",show:!1,description:"fires after a fx-return returned"},{name:"select",show:!1,description:"fires when an fx-case has been selected"},{name:"submit",show:!1,description:"fires before a submission takes place"},{name:"submit-done",show:!1,description:"fires after a submission has successfully been executed"},{name:"submit-error",show:!1,description:"fires when a submission returned an error"},{name:"valid",show:!1,description:"fires after a fx-control has become valid"},{name:"value-changed",show:!1,description:"fires after a fx-control has changed its value"}]}_log(e,t){const n=e.target.nodeName;if("FX-ACTION-LOG"===n)return;const r=document.createElement("div");r.classList.add("log-row");const a=this._logDetails(e);if(e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype&&r.classList.add("no-detail"),r.innerHTML=a,this.outermost){if("outermost-action-start"===e.type)return;this.outermostAppender||(this.outermostAppender=document.createElement("ul"),t.append(this.outermostAppender));const n=document.createElement("li");n.append(r),this.outermostAppender.append(n)}else t.append(r);this.parentPath&&"FX-ACTION"!==n&&r.classList.add("nested");const o=e.target;r.addEventListener("click",(e=>{this._highlight(o)}));const s=r.querySelector(".event-target");s&&s.addEventListener("click",(e=>{document.querySelectorAll(".fx-action-log-debug").forEach((e=>{e.classList.remove("fx-action-log-debug")})),o.dispatchEvent(new CustomEvent("log-action",{composed:!1,bubbles:!0,cancelable:!0,detail:{target:o}})),o.classList.add("fx-action-log-debug"),o.setAttribute("data-name",o.nodeName),this._highlight(o)}))}_logDetails(e){const t=e.type,n=tt.getPath(e.target),r=n.substring(n.indexOf("/fx-fore"),n.length),a=`/${r}`,o=r.replaceAll("fx-","");switch(this.parentPath&&!a.startsWith(this.parentPath)&&(this.parentPath=null),t){case"deleted":const{deletedNodes:n}=e.detail,r=new XMLSerializer;let s="";return n.forEach((e=>{s+=r.serializeToString(e)})),`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-info="${e.detail.ref}"\n short-name="${e.target.nodeName.toLowerCase()}">\n <section class="details">\n <header>Details</header>\n <section>\n <span class="key">Deleted Nodes</span>\n <textarea class="value" rows="5">${s.trim()}</textarea>\n </section>\n </section>\n </fx-log-item>\n `;case"outermost-action-start":return"start";case"outermost-action-end":return"";case"execute-action":const i=e.detail.action;return this._renderAction(i,a,o,e);default:return`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-name="${e.target.nodeName.toLowerCase()}">\n \n <section class="details">\n ${this._listEventDetails(e)}\n </section>\n </fx-log-item>\n `}}_renderAction(e,t,n,r){switch(e.nodeName.split("-")[1],e.nodeName){case"FX-ACTION":return this.parentPath=t,`\n <fx-log-item event-name="${r.detail.event}"\n xpath="${t}"\n short-name="ACTION" class="action">\n <section class="details">\n <header>Attributes</header>\n <section>\n ${Array.from(e.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section>\n </section>\n </fx-log-item> \n `;case"FX-MESSAGE":const n=r.detail.action.messageTextContent;return`\n <fx-log-item event-name="${r.detail.event}"\n xpath="${t}"\n short-name="MESSAGE"\n short-info="${n}" class="action">\n <section class="details">\n <span>${n}</span>\n </section>\n </fx-log-item>\n `;case"FX-SEND":const a=document.querySelector(`#${r.detail.action.getAttribute("submission")}`);return`\n <fx-log-item short-name="SEND"\n short-info="${a.id}"\n event-name="${r.detail.event}"\n xpath="${t}" class="action">\n <section class="details">\n <header>Submission</header>\n <section class="attributes">\n ${Array.from(a.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section> \n </section>\n </fx-log-item>\n `;case"FX-SETVALUE":return`\n <fx-log-item short-name="SETVALUE"\n short-info="${tt.getPath(r.target.nodeset)}"\n event-name="${"FX-CONTROL"===r.target.nodeName?r.target.updateEvent:r.detail.event}"\n xpath="${t}" class="action">\n <section class="details">\n <span class="key">value</span>\n <span class="value">${r.detail.value}</span>\n </section>\n </fx-log-item>\n `;default:return`\n <fx-log-item event-name="${r.detail.event}" \n short-name="${r.target.nodeName}"\n xpath="${t}"\n class="action">\n <section class="details">\n </section>\n </fx-log-item>\n `}}_listEventDetails(e){return e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype?"":`${Object.keys(e.detail).map((e=>`<span>${e}</span>`))}`}_listAttributes(e){return""}_highlight(e){const t=e.style.backgroundColor,n=e.style.transition;e.style.transition="background 1s",e.style.backgroundColor="#FFA500",setTimeout((()=>{e.style.backgroundColor=t,setTimeout((()=>{e.style.transition=n}),400)}),400),window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e}}))}}customElements.get("fx-log-settings")||customElements.define("fx-log-settings",un);class hn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.listenTo=[],this.listeners=[]}connectedCallback(){localStorage.getItem("fx-action-log-filters")?this.listenTo=JSON.parse(localStorage.getItem("fx-action-log-filters")):this.listenTo=un.defaultSettings(),localStorage.getItem("fx-log-settings")?this.listenTo=JSON.parse(localStorage.getItem("fx-log-settings")):this.listenTo=un.defaultSettings();this.shadowRoot.innerHTML='\n <style>\n \n :host {\n display:block;\n position:relative;\n width:100%;\n border:thin solid #efefef;\n background:transparent;\n font-family: Verdana, Sans;\n margin:0;\n padding:0.25rem;\n }\n a,a:link,a:visited{\n color:black;\n }\n a{\n position:relative;\n }\n a[alt]:hover::after {\n content:attr(alt);\n position:absolute; \n left:0;\n bottom:-0.5em;\n border:thin solid;\n padding:0.5em;\n background:white;\n z-index:1;\n min-width:5em;\n border:thin solid;\n max-width:90%;\n }\n .details{\n padding:0.25em 0;\n }\n\n .key{\n width:20%;\n display:inline-block;\n min-width:5rem;\n border-bottom:1px solid #ddd;\n background:#efefef;\n vertical-align:top;\n }\n .value{\n display:inline-block;\n width:60%;\n \n }\n \n .buttons{\n position:absolute;\n top:0;\n right:0;\n }\n .buttons button{\n padding:0;\n }\n button{\n float:right;\n }\n button{\n border:none;\n background:transparent;\n width:2.25rem;\n height:2.25rem;\n cursor:pointer;\n }\n button#reset{\n padding:0;\n height:1rem;\n }\n .info{\n padding:0 0.5em;\n margin:0.1rem 0;\n background:white;\n position:relative;\n display:grid;\n grid-template-areas: "left right"\n "bottom .";\n grid-template-columns: 75% 25%;\n }\n .info a{\n grid-area:right;\n justify-self:end;\n }\n .details > section{\n display:flex;\n flex-wrap:wrap;\n padding:0.5em 0;\n }\n fx-log-item{\n }\n header{\n padding:0.5rem;\n margin:0;\n border-bottom:2px solid #ddd;\n }\n \n .info:hover{\n outline:3px solid lightblue; \n transition:height 0.4s;\n }\n\n ol{\n background: #efefef;\n padding: 0.5em 0 0 2em;\n border-left:3px solid red;\n }\n \n .event-name{\n display:inline-block;\n }\n #log{\n margin-bottom:10em;\n margin-right:2em;\n }\n .log-row{\n margin:0;\n padding:0;\n position:relative;\n font-size:0.8em;\n border-left:4px solid transparent;\n padding-left:5px;\n width:calc(100% - 2em);\n margin-bottom:0.25em;\n }\n .log-row summary{\n display:flex;\n flex-wrap:wrap;\n padding:0.5em 0;\n cursor:pointer;\n }\n .log-row summary > span {\n width:calc(90% div 3);\n }\n\n .log-name{\n position:relative;\n }\n .short-info{\n flex:3;\n overflow:hidden;\n white-space:nowrap;\n text-overflow:ellipsis;\n }\n .log-row.no-detail summary{\n position:relative;\n }\n .log-row.no-detail summary{\n list-style:none;\n padding-left:1rem;\n }\n .log-row.no-detail summary::-webkit-details-marker {\n display: none;\n }\n .log-row.nested{\n margin-left:1em;\n }\n .nested .event-name{\n display:none;\n }\n \n .setvalue .value{\n background:lightyellow;\n }\n summary{\n padding:1em;\n border-bottom:2px solid #ddd;\n }\n .outer-details{\n height:100%;\n overflow:auto;\n margin-top:2rem;\n background:rgba(250, 250, 250, 0.9);\n }\n \n .outer-details > header{\n position:absolute;\n top:-1px;\n width:calc(100% - 2rem);\n border-bottom:2px solid #ddd;\n font-size:1rem;\n height:1rem;\n }\n .outer-details > summary{\n font-size:1em;\n }\n ul{\n list-style:none;\n padding:0;\n margin:0.1em 0;\n border-left:3px solid steelblue;\n padding:0.1em 0;\n }\n ul .log-row{\n padding-left:3px;\n width:calc(100% - 1em);\n }\n \n </style>\n \n <section open class="outer-details">\n <header>Log \n <span class="buttons">\n <button id="del"" title="empty log - Ctrl+d">\n <svg viewBox="0 0 24 24" style="width:24px;height:24px;" preserveAspectRatio="xMidYMid meet" focusable="true"><g><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zm2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12zM15.5 4l-1-1h-5l-1 1H5v2h14V4z"></path></g></svg></a>\n </button>\n </span>\n </header>\n <div id="log"></div>\n </section>\n \n ';window.document.querySelector("fx-fore")||console.error("fx-fore element not found in this page.");const e=this.shadowRoot.querySelector("#log");this.listenTo.forEach((t=>{t.show&&document.addEventListener(t.name,(t=>{this._log(t,e)}))})),document.addEventListener("outermost-action-start",(e=>{this.outermost=!0}),{capture:!0}),document.addEventListener("outermost-action-end",(e=>{this.outermost=!1,this.outermostAppender=null}),{capture:!0});this.shadowRoot.querySelector("#del").addEventListener("click",(e=>{this.shadowRoot.querySelector("#log").innerHTML=""})),document.addEventListener("keydown",(e=>{e.ctrlKey&&"d"===e.key&&(this.shadowRoot.querySelector("#log").innerHTML="")}))}_defaultSettings(){this.listenTo=[{name:"action-performed",show:!1,description:"fires after an action has been performed"},{name:"click",show:!1,description:""},{name:"deleted",show:!1,description:"fires after a delete action has been executed"},{name:"deselect",show:!1,description:"fires when fx-case is deselected"},{name:"dialog-hidden",show:!1,description:"fires after fx-dialog has been hidden"},{name:"dialog-shown",show:!1,description:"fired when a dialog has been shown"},{name:"error",show:!1,description:"fires after an error occurred"},{name:"execute-action",show:!0,description:"fires when an action executes"},{name:"init",show:!1,description:"fires when a control initializes"},{name:"index-changed",show:!1,description:"fires when the repeat index changes"},{name:"insert",show:!1,description:"fires when an fx-insert is executed"},{name:"instance-loaded",show:!1,description:"fires after an fx-instance has been loaded"},{name:"invalid",show:!1,description:"fires after a control became invalid"},{name:"item-changed",show:!1,description:"fires when a repeat item was changed"},{name:"item-created",show:!1,description:"fires when a repeat item was created"},{name:"loaded",show:!1,description:"fires after a fx-load has loaded"},{name:"model-construct",show:!1,description:"fires when a model gets constructed"},{name:"model-construct-done",show:!1,description:"fires after model initialization"},{name:"nonrelevant",show:!1,description:"fires after an fx-control became nonrelevant"},{name:"optional",show:!1,description:"fires after an fx-control became optional"},{name:"outermost-action-end",show:!1,description:"fires when an outermost action block is finished"},{name:"outermost-action-start",show:!1,description:"fires when an outermost action block is started"},{name:"path-mutated",show:!1,description:"fires when a path in a repeat has been mutated"},{name:"readonly",show:!1,description:"fires after an fx-control became readonly"},{name:"readwrite",show:!1,description:"fires after an fx-control became readwrite"},{name:"ready",show:!1,description:"fires after a fx-fore page has been completely initialized"},{name:"rebuild-done",show:!1,description:"fires after a rebuild has taken place"},{name:"recalculate-done",show:!1,description:"fires after a recalculate has taken place"},{name:"refresh-done",show:!1,description:"fires after a refresh has been done"},{name:"relevant",show:!1,description:"fires after a fx-control has become relevant"},{name:"reload",show:!1,description:"fires when a fx-reload action executes"},{name:"required",show:!1,description:"fires after an fx-control has become required"},{name:"return",show:!1,description:"fired by embedded Fore controls to return their bound value"},{name:"select",show:!1,description:"fires when an fx-case has been selected"},{name:"submit",show:!1,description:"fires before a submission takes place"},{name:"submit-done",show:!1,description:"fires after a submission has successfully been executed"},{name:"submit-error",show:!1,description:"fires when a submission returned an error"},{name:"valid",show:!1,description:"fires after a fx-control has become valid"},{name:"value-changed",show:!1,description:"fires after a fx-control has changed its value"}]}_log(e,t){const n=e.target.nodeName;if("FX-ACTION-LOG"===n)return;const r=document.createElement("div");r.classList.add("log-row");const a=this._logDetails(e);if(e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype&&r.classList.add("no-detail"),r.innerHTML=a,this.outermost){if("outermost-action-start"===e.type)return;this.outermostAppender||(this.outermostAppender=document.createElement("ul"),t.append(this.outermostAppender));const n=document.createElement("li");n.append(r),this.outermostAppender.append(n)}else t.append(r);this.parentPath&&"FX-ACTION"!==n&&r.classList.add("nested");const o=e.target;r.addEventListener("click",(e=>{this._highlight(o)}));const s=r.querySelector(".event-target");s&&s.addEventListener("click",(e=>{document.querySelectorAll(".fx-action-log-debug").forEach((e=>{e.classList.remove("fx-action-log-debug")})),o.dispatchEvent(new CustomEvent("log-action",{composed:!1,bubbles:!0,cancelable:!0,detail:{target:o}})),o.classList.add("fx-action-log-debug"),o.setAttribute("data-name",o.nodeName),this._highlight(o)}))}_logDetails(e){const t=e.type,n=tt.getDocPath(e.target),r=n.substring(n.indexOf("/fx-fore"),n.length),a=`/${r}`,o=r.replaceAll("fx-","");switch(this.parentPath&&!a.startsWith(this.parentPath)&&(this.parentPath=null),t){case"deleted":const{deletedNodes:n}=e.detail,r=new XMLSerializer;let s="";return n.forEach((e=>{s+=r.serializeToString(e)})),`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-info="${e.detail.ref}"\n short-name="${e.target.nodeName.toLowerCase()}">\n <section class="details">\n <header>Details</header>\n <section>\n <span class="key">Deleted Nodes</span>\n <textarea class="value" rows="5">${s.trim()}</textarea>\n </section>\n </section>\n </fx-log-item>\n `;case"outermost-action-start":return"start";case"outermost-action-end":return"";case"execute-action":const i=e.detail.action;return this._renderAction(i,a,o,e);default:return`\n <fx-log-item event-name="${t}"\n xpath="${a}"\n short-name="${e.target.nodeName.toLowerCase()}">\n \n <section class="details">\n ${this._listEventDetails(e)}\n </section>\n </fx-log-item>\n `}}_renderAction(e,t,n,r){let a;switch(e.nodeName.split("-")[1],e.nodeName){case"FX-ACTION":return this.parentPath=t,a=r.target.currentEvent?r.target.currentEvent.type:r.detail.event?r.detail.event:"",`\n <fx-log-item event-name="${a}"\n xpath="${t}"\n short-name="ACTION"\n data-path="${r.detail.path}" \n class="action">\n <section class="details">\n <header>Attributes</header>\n <section>\n ${Array.from(e.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section>\n </section>\n </fx-log-item> \n `;case"FX-MESSAGE":const n=r.detail.action.messageTextContent;return`\n <fx-log-item event-name="${r.detail.event}"\n xpath="${t}"\n short-name="MESSAGE"\n short-info="${n}" class="action">\n <section class="details">\n <span>${n}</span>\n </section>\n </fx-log-item>\n `;case"FX-SEND":const o=document.querySelector(`#${r.detail.action.getAttribute("submission")}`),s=r.detail.event?r.detail.event:"";return`\n <fx-log-item short-name="SEND"\n short-info="${o.getAttribute("id")}"\n event-name="${s}"\n xpath="${t}" class="action"\n data-path="${r.detail.path}" >\n <section class="details">\n <header>Submission</header>\n <section class="attributes">\n ${Array.from(o.attributes).map((e=>`\n <span class="key">${e.nodeName}</span>\n <span class="value">${e.nodeValue}</span>\n `)).join("")} \n </section> \n </section>\n </fx-log-item>\n `;case"FX-SETVALUE":return`\n <fx-log-item short-name="SETVALUE"\n short-info="${tt.getPath(r.target.nodeset)}"\n event-name="${"FX-CONTROL"===r.target.nodeName?r.target.updateEvent:r.detail.event?r.detail.event:""}"\n xpath="${t}"\n data-path="${r.detail.path}" class="action">\n <section class="details">\n <span class="key">value</span>\n <span class="value">${r.detail.value}</span>\n </section>\n </fx-log-item>\n `;default:return a=r.target.currentEvent?r.target.currentEvent.type:r.detail.event?r.detail.event:"",`\n <fx-log-item event-name="${a}" \n short-name="${r.target.nodeName}"\n xpath="${t}"\n data-path="${r.detail.path}" \n class="action">\n <section class="details">\n </section>\n </fx-log-item>\n `}}_listEventDetails(e){return e.detail&&0===Object.keys(e.detail).length&&Object.getPrototypeOf(e.detail)===Object.prototype?"":`${Object.keys(e.detail).map((e=>`<span>${e}</span>`))}`}_listAttributes(e){return""}_highlight(e){const t=e.style.backgroundColor,n=e.style.transition;e.style.transition="background 1s",e.style.backgroundColor="#FFA500",setTimeout((()=>{e.style.backgroundColor=t,setTimeout((()=>{e.style.transition=n}),400)}),400),window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e}}))}}function dn(e,t){e.classList.add(t)}function pn(e,t){e.classList.remove(t)}function mn(e,t){if("object"!=typeof e)throw new Error(`containsOnlyText: Expected argument node of type object, ${typeof e} given.`);let n=!1,r=null;if(t=t||!1)for(let t=0,a=e.childNodes.length;t<a&&(r=e.childNodes[t],n=r.nodeType===Node.TEXT_NODE||r.nodeType===Node.COMMENT_NODE||r.nodeType===Node.CDATA_SECTION_NODE,n);t+=1);else n=e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE||e.nodeType===Node.CDATA_SECTION_NODE;return n}function fn(e,t){const n=document.createElement(e);t=t||{};for(const e of Object.keys(t))n.setAttribute(e,t[e]);return n}function gn(e,t){const n=fn("span",{class:"adi-opt"});return n.innerHTML=`<label><input type="checkbox" data-opt="${e}">${t}</label>`,n}customElements.get("fx-action-log")||customElements.define("fx-action-log",hn);class yn{constructor(e,t){this.sourceNodeByInspectorNodeLookup=new Map,this.uiView=null,this.menuView=null,this.domView=null,this.attrView=null,this.optsView=null,this.activeElement=null,this.vertResizing=!1,this.horizResizing=!1,this.pathScrolling=null,this.elemLookup=!1,this.styleBackup="",this.xPos=0,this.delegatedEvents=[],this.options={align:"right",split:50,minSplit:30,visible:!0,saving:!1,transparent:!0,omitEmptyText:!0,makeVisible:!0,foldText:!0,nodeTypes:[Node.ELEMENT_NODE,Node.TEXT_NODE,Node.COMMENT_NODE,Node.DOCUMENT_NODE]},"#document"===t?(this.instanceId="#document",this.document=window.document,this.isInstanceViewer=!1):(this.instanceId=t.id,t&&"fx-instance"===t.localName||console.error("No instance found!"),this.document=t.getInstanceData(),this.isInstanceViewer=!0,this.options.foldText=!1),this.drawUI(e),this.registerEvents(),this.drawDOM(this.document,this.domView.querySelector(".adi-tree-view"),!0),document.addEventListener("execute-action",(e=>this.processExecuteAction))}getSelected(){if(!this.activeElement)return null;let e=document;return e=this.sourceNodeByInspectorNodeLookup.get(this.activeElement),e}loadOptions(){let e={};e=JSON.parse(window.localStorage.getItem("ADI.options"))||{};for(const t of Object.keys(e))this.options[t]=e[t]}saveOptions(){this.options.saving&&window.localStorage.setItem("ADI.options",JSON.stringify(this.options))}hasRequiredNodes(e){if("object"!=typeof e)throw new Error(`hasRequiredNodes: Expected argument node of type object, ${typeof e} given.`);if(e.hasChildNodes())for(let t=0,n=e.childNodes.length;t<n;t+=1){const n=e.childNodes[t];if(this.options.nodeTypes.includes(n.nodeType))return!0}return!1}newTreeNode(e){if("object"!=typeof e)throw new Error(`newTreeNode: Expected argument node of type object, ${typeof e} given.`);const t=this.hasRequiredNodes(e);let n=!1,r=e.nodeName.startsWith("FX-")?`adi-node ${e.nodeName.toLowerCase()}`:"";e.nodeName.startsWith("FX-")&&(r=`adi-node ${e.nodeName.toLowerCase()}`,r+=St.isActionElement(e.nodeName)?" action":"");const a=fn("li",{class:r});if(e===this.uiView)return null;if(t&&a.appendChild(fn("span",{class:"adi-trigger"})),this.options.omitEmptyText&&e.nodeType===Node.TEXT_NODE&&(n=function(e){if("object"!=typeof e)throw new Error(`isEmptyTextNode: Expected argument node of type object, ${typeof e} given.`);return/^\s*$/.test(e.textContent)}(e)),!n){const n=fn("span");this.sourceNodeByInspectorNodeLookup.set(n,e),this.sourceNodeByInspectorNodeLookup.set(e,n);let r=null;if(mn(e))e.nodeType===Node.COMMENT_NODE?(dn(n,"adi-comment-node"),"string"==typeof n.innerText&&(n.innerText=`\x3c!-- ${e.textContent} --\x3e`)):(dn(n,"adi-text-node"),n.textContent=e.textContent);else if(dn(n,"adi-normal-node"),e.nodeType!==Node.DOCUMENT_NODE){const a=Array.from(e.attributes).filter((e=>!!this.isInstanceViewer||"style"!==e.name)).map((e=>`${e.name}="${e.value}"`)).join(" ");n.textContent=`<${e.nodeName.toLowerCase()}${a?` ${a}`:""}>`,t&&(r=fn("span"),dn(r,"adi-end-node"),r.textContent=`</${e.nodeName.toLowerCase()}>`)}else n.textContent=e.nodeName.toLowerCase();return a.appendChild(n),e.nodeName.startsWith("FX-")&&(n.classList.add("fore-node"),n.classList.add(e.nodeName.toLowerCase())),r&&(a.appendChild(r),e.nodeName.startsWith("FX-")&&r.classList.add("fore-node")),a}return null}drawDOM(e,t,n){if("object"!=typeof e)throw new Error(`drawDOM: Expected argument root of type object, ${typeof e} given.`);let r=null,a=!0;const o=t.nodeName.startsWith("FX-")?`adi-node ${node.nodeName.toLowerCase()}`:"";n&&-1!==this.options.nodeTypes.indexOf(e.nodeType)&&(t.innerHTML="",r=this.newTreeNode(e),this.hasRequiredNodes(e)&&(r.appendChild(fn("ul",{"data-open":!0,class:o})),dn(r.querySelector(".adi-trigger"),"opened")),t.appendChild(r),t=t.querySelector("ul"));for(let n=0,s=e.childNodes.length;n<s;n+=1){const s=e.childNodes[n],i=this.hasRequiredNodes(s);if(-1!==this.options.nodeTypes.indexOf(s.nodeType)&&(r=this.newTreeNode(s),r)){if(i&&(a=!this.options.foldText||!mn(s,!0),"HEAD"===s.nodeName&&(a=!1),"SELECT"===s.nodeName&&(a=!1),"FX-INSTANCE"===s.nodeName&&(a=!1),s.nodeType===Node.DOCUMENT_NODE?r.appendChild(fn("ul",{"data-open":a,class:o})):r.insertBefore(fn("ul",{"data-open":a,class:o}),r.lastChild),dn(r.querySelector(".adi-trigger"),a?"opened":"closed")),t.appendChild(r),this.getSelected()===s){const e=r.querySelector("span.adi-normal-node");e?.classList?.add("adi-active-node"),this.activeElement=e,r.scrollIntoView({block:"nearest",behavior:"instant"})}i&&this.drawDOM(s,r.querySelector("ul"),!1)}}}toggleOptions(){-1!==this.optsView.className.indexOf("adi-hidden")?pn(this.optsView,"adi-hidden"):(dn(this.optsView,"adi-hidden"),this.attrView.querySelector(".adi-content").innerHTML="",this.refreshUI(),this.drawDOM(document,this.domView.querySelector(".adi-tree-view"),!0),this.options.saving?this.saveOptions():window.localStorage.removeItem("ADI.options"))}drawUI(e){this.uiView=fn("div",{id:"adi-wrapper",class:this.options.transparent?"transparent":""}),this.domView=fn("div",{id:"adi-dom-view"});const t=fn("div",{class:"adi-content",id:"detailsView"}),n=fn("ul",{class:"adi-tree-view"}),r=fn("div",{class:"adi-path-wrap"}),a=fn("span",{class:"adi-path-left"}),o=fn("span",{class:"adi-path-right"});this.menuView=fn("div",{id:"adi-panel"});const s=fn("div",{class:"adi-menu-wrap"}),i=fn("a",{class:"adi-menu-config",title:"Settings"}),l=fn("a",{class:"adi-menu-lookup",title:"Lookup tool"});if(this.optsView=function(){const e=fn("div",{id:"adi-opts-view",class:"adi-hidden"}),t=fn("span",{class:"adi-opt-heading"}),n=fn("span",{class:"adi-opt-heading"}),r=fn("span",{class:"adi-opt-close"});return t.textContent="General options",n.textContent="Observed nodes",e.appendChild(t),e.appendChild(gn("saving","Enable saving of settings")),e.appendChild(gn("makeVisible","Scroll to the active element in DOM View")),e.appendChild(gn("omitEmptyText","Hide empty text nodes")),e.appendChild(gn("foldText","Fold the text nodes")),e.appendChild(gn("transparent","Enable transparent background")),e.appendChild(n),e.appendChild(gn("nodeTypes-3","Text node")),e.appendChild(gn("nodeTypes-8","Comment node")),e.appendChild(r),e}(),t.appendChild(n),this.domView.appendChild(this.menuView),this.domView.appendChild(t),r.appendChild(a),r.appendChild(o),s.appendChild(l),s.appendChild(i),this.menuView.appendChild(r),this.menuView.appendChild(s),this.uiView.appendChild(this.optsView),this.uiView.appendChild(this.domView),!this.isInstanceViewer){this.attrView=fn("div",{id:"adi-attr-view"});const e=fn("div",{class:"adi-content"});this.attrView.appendChild(e),this.uiView.appendChild(this.attrView)}e.appendChild(this.uiView),this.refreshUI(!0)}refreshUI(e){null!==this.uiView&&(e&&this.loadOptions(),e&&(this.optsView.querySelector('[data-opt="transparent"]').checked=this.options.transparent,this.optsView.querySelector('[data-opt="saving"]').checked=this.options.saving,this.optsView.querySelector('[data-opt="omitEmptyText"]').checked=this.options.omitEmptyText,this.optsView.querySelector('[data-opt="makeVisible"]').checked=this.options.makeVisible,this.optsView.querySelector('[data-opt="foldText"]').checked=this.options.foldText,this.optsView.querySelector('[data-opt="nodeTypes-3"]').checked=-1!==this.options.nodeTypes.indexOf(3),this.optsView.querySelector('[data-opt="nodeTypes-8"]').checked=-1!==this.options.nodeTypes.indexOf(8)),this.uiView.className=this.options.transparent?"transparent":"",this.domView.querySelector(".adi-content").style.height=`${this.domView.clientHeight}px`,this.isInstanceViewer||(this.attrView.querySelector(".adi-content").style.height=this.attrView.clientHeight-this.menuView.clientHeight+"px"),dn(this.uiView,this.options.align))}toggleVisibilityUI(){null!==this.uiView&&(this.uiView.style.display=this.options.visible?"none":"block",this.options.visible=!this.options.visible,this.saveOptions())}drawAttrs(e){if(this.isInstanceViewer)return;const t=this.attrView.querySelector(".adi-content");t.innerHTML="";const n=document.createElement("header");n.innerText="Attributes",t.appendChild(n),[...e.attributes].forEach((e=>{"style"!==e.name&&t.appendChild(function(e,t){const n=fn("span",{class:"adi-attr"});switch(e.toLowerCase()){case"defaultaction":n.innerHTML=`<label>${e}: <select data-attr="${e}" value="${t}"><option>perform</option><option>cancel</option></label>`;break;case"delay":n.innerHTML=`<label>${e}: <input type="number" data-attr="${e}" value="${t}" readonly="readonly"></label>`;break;default:n.innerHTML=`<label>${e}: <input type="text" data-attr="${e}" value="${t}" readonly="readonly"></label>`}return n}(e.name,e.value))}))}changeAttribute(e){const t=e?e.target:window.event.srcElement,n=t.getAttribute("data-attr"),r=t.value,a=this.getSelected();""===r?a.removeAttribute(n):a.setAttribute(n,r)}changeOption(e){const t=e?e.target:window.event.srcElement,n=t.getAttribute("data-opt"),r=t.checked;if(-1!==n.indexOf("nodeTypes")){const e=parseInt(n.match(/\d+/)[0],10);r?this.options.nodeTypes.push(e):this.options.nodeTypes.splice(this.options.nodeTypes.indexOf(e),1)}else this.options[n]=r}processKey(e){if(272===((e=e||window.event).keyCode||e.which))this.toggleVisibilityUI()}verticalResize(e){if(!this.vertResizing)return;e=e||window.event,document.documentElement.style.cursor="e-resize";const t=this.options.width+this.xPos-e.clientX;t>=this.options.minWidth&&(this.options.width=t,this.xPos=e.clientX,this.refreshUI(),this.saveOptions())}horizontalResize(e){if(!this.horizResizing)return;e=e||window.event,document.documentElement.style.cursor="n-resize";const t=Math.floor(e.clientY/this.uiView.clientHeight*100);t>=this.options.minSplit&&t<=100-this.options.minSplit&&(this.options.split=t,this.refreshUI(),this.saveOptions())}processExecuteAction(e){this.refreshUI()}handleActive(e){let t=e?e.detail?.target||e.target:window.event.srcElement;const n=this.domView.querySelector(".adi-active-node");if(n&&pn(n,"adi-active-node"),!t||t.nodeType===Node.DOCUMENT_NODE)return;if(t&&t.classList&&t.classList.contains("adi-end-node")&&(t=t.parentNode.querySelector(".adi-normal-node")),this.activeElement=t,dn(t,"adi-active-node"),this.options.makeVisible){this.domView.querySelector(".adi-content").scrollIntoView({block:"center",behavior:"instant"})}const r=this.getSelected();if(this.drawAttrs(r),r&&"function"==typeof r.getModelItem&&r.getModelItem()?.node){let e=r.modelItem.node;e?.nodeType===Node.ATTRIBUTE_NODE&&(e=e.ownerElement),window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e}}))}}highlightElement(e){let t=e?e.target:window.event.srcElement;t.classList.contains("adi-end-node")&&(t=t.parentNode.querySelector(".adi-normal-node"));const n=this.sourceNodeByInspectorNodeLookup.get(t);n&&n.ownerDocument===window.document&&n&&("mouseover"===e.type?(this.styleBackup=n.getAttribute("style")||"",n.setAttribute("style",`outline: 2px solid blue; ${this.styleBackup}`)):""===this.styleBackup?n.removeAttribute("style"):n.setAttribute("style",this.styleBackup))}handleLookup(e){const t=e?e.detail?.target||e.target:window.event.srcElement;if(!this.document.contains(t))return;if(t.nodeType===Node.DOCUMENT_NODE)return;if(-1!==t.className.indexOf("adi-menu-lookup"))return this.elemLookup?(pn(t,"adi-active"),this.elemLookup=!1,this.removeEvent(document.body,"mouseover",this.handleLookup,!0),this.removeEvent(document.body,"mouseout",this.handleLookup,!0),void this.removeEvent(document.body,"click",this.handleLookup,!0)):(dn(t,"adi-active"),this.elemLookup=!0,this.addEventDelegate(document.body,"mouseover",this.handleLookup,!1,"*",!0,"adi-wrapper"),this.addEventDelegate(document.body,"mouseout",this.handleLookup,!1,"*",!0,"adi-wrapper"),void this.addEventDelegate(document.body,"click",this.handleLookup,!1,"*",!0,"adi-wrapper"));if("mouseover"===e.type)return this.styleBackup=t.getAttribute("style")||"",void t.setAttribute("style",`outline: 1px dashed red; ${this.styleBackup}`);if("mouseout"===e.type)return void t.setAttribute("style",this.styleBackup);this.elemLookup=!1,pn(this.menuView.querySelector(".adi-menu-lookup"),"adi-active"),t.setAttribute("style",this.styleBackup),this.removeEvent(document.body,"mouseover",this.handleLookup,!0),this.removeEvent(document.body,"mouseout",this.handleLookup,!0),this.removeEvent(document.body,"click",this.handleLookup,!0),function(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),e.cancelBubble=!0,e.returnValue=!1}(e);const n=this.sourceNodeByInspectorNodeLookup.get(t);if(!n)return;if(n&&n.click(),!n.parentNode)return;let r,a=n.parentNode;for(a.querySelector("ul")&&a.querySelector("ul").setAttribute("data-open","true");a!==this.domView.querySelector(".adi-content");)-1!==a.className.indexOf("adi-node")&&(r=a.querySelector(".adi-trigger"),r&&(pn(r,"closed"),dn(r,"opened")),a=a.parentNode,a.setAttribute("data-open","true")),a=a.parentNode;this.options.makeVisible&&n.scrollIntoView({behavior:"instant",block:"nearest",inline:"nearest"}),t.scrollIntoView({behavior:"instant",block:"nearest",inline:"nearest"})}addEventDelegate(e,t,n,r,a,o,s){const i=e=>{const t=e?e.target:window.event.srcElement,r=a.substr(1);let o=!1;if(s){let e=t;for(;e!==document;){if(e.id===s)return;e=e.parentNode}}o=0===a.indexOf("#")?t.id===r:0===a.indexOf(".")?-1!==t.className.indexOf(r):"*"===a||t.nodeName.toLowerCase()===a,o&&n(e)};o&&this.delegatedEvents.push({handle:i,elem:e,fn:n,evt:t}),e.addEventListener(t,i,r)}removeEvent(e,t,n,r){if("object"!=typeof e)throw new Error(`addEvent: Expected argument elem of type object, ${typeof e} given.`);let a=null;if(r)for(let r=0,o=this.delegatedEvents.length;r<o;r+=1)if(a=this.delegatedEvents[r],a.elem===e&&a.evt===t&&a.fn===n){n=a.handle,this.delegatedEvents.splice(r,1);break}}registerEvents(){const e=()=>{if("#document"!==this.instanceId){const e=window.document.querySelector(`#${this.instanceId}`);this.document=e.getInstanceData()}this.drawDOM(this.document,this.domView.querySelector(".adi-tree-view"),!0)};document.addEventListener("instance-loaded",e),document.addEventListener("value-changed",e),document.addEventListener("ready",e),document.addEventListener("mouseup",(()=>{document.documentElement.style.cursor="default",this.vertResizing=!1,this.horizResizing=!1}),!1),document.addEventListener("mousemove",(e=>this.verticalResize(e)),!1),document.addEventListener("mousemove",(e=>this.horizontalResize(e)),!1),window.addEventListener("resize",(e=>this.refreshUI(e)),!1),document.addEventListener("keypress",(e=>this.processKey(e)),!1),document.addEventListener("log-active-element",(e=>this.handleLookup(e)),!1);this.addEventDelegate(this.domView,"click",(e=>{const t=e?e.target:window.event.srcElement,n=t.parentNode.querySelector("ul");"true"===n.getAttribute("data-open")?(pn(t,"opened"),dn(t,"closed"),n.setAttribute("data-open","false")):(pn(t,"closed"),dn(t,"opened"),n.setAttribute("data-open","true"))}),!1,".adi-trigger"),this.addEventDelegate(this.domView,"click",(e=>this.handleActive(e)),!1,".adi-normal-node"),this.addEventDelegate(this.domView,"click",(e=>this.handleActive(e)),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseover",(e=>{dn((e?e.target:window.event.srcElement).parentNode.querySelector(".adi-normal-node"),"hover")}),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseout",(e=>{pn((e?e.target:window.event.srcElement).parentNode.querySelector(".adi-normal-node"),"hover")}),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseover",(e=>this.highlightElement(e)),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseover",(e=>this.highlightElement(e)),!1,".adi-normal-node"),this.addEventDelegate(this.domView,"mouseout",(e=>this.highlightElement(e)),!1,".adi-end-node"),this.addEventDelegate(this.domView,"mouseout",(e=>this.highlightElement(e)),!1,".adi-normal-node"),this.menuView.querySelector(".adi-menu-lookup").addEventListener("click",(e=>this.handleLookup(e)),!1),document.addEventListener("handle-active",(e=>{if(e.detail.selected===this.getSelected())return;const{selected:t}=e.detail,n=this.sourceNodeByInspectorNodeLookup.get(t);if(this.options.makeVisible){const e=this.domView.querySelector(".adi-content");(n.offsetTop>=e.clientHeight||n.offsetTop<=e.scrollTop)&&(e.scrollTop=n.offsetTop-Math.floor(e.clientHeight/2))}this.drawAttrs(this.getSelected())})),document.addEventListener("execute-action",(e=>this.processExecuteAction(event)),{capture:!0}),this.addEventDelegate(this.optsView,"change",(e=>this.changeOption(e)),!1,"input"),this.addEventDelegate(this.optsView,"click",(e=>this.toggleOptions(e)),!1,".adi-opt-close"),this.menuView.querySelector(".adi-menu-config").addEventListener("click",(e=>this.toggleOptions(e)),!1),this.isInstanceViewer||this.addEventDelegate(this.attrView,"change",this.changeAttribute,!1,"input")}}class wn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.instanceName=null,this.instance=null}connectedCallback(){this.render(),this.instance?this.shadowRoot.querySelector("#focus-button").style="display: none":this.setupFocusButton()}setInstance(e){this.instance=e}disconnectedCallback(){this.adiInstance=null}setupFocusButton(){let e="",t=null;const n=()=>{""===e?t.removeAttribute("style"):t.setAttribute("style",e),t=null},r=r=>{const{target:a}=r;if("mouseover"===r.type)return e=a.getAttribute("style")||"",a.setAttribute("style",`outline: 2px solid blue; ${e}`),void(t=a);t&&n()},a=this.shadowRoot.querySelector("#focus-button");let o=!1;const s=window.document.head.appendChild(document.createElement("style")),i=()=>{o=!1,window.document.body.removeEventListener("click",l),a.classList.remove("selected-btn"),s.innerHTML="",document.body.style.cursor="auto",window.document.body.removeEventListener("mouseover",r),window.document.body.removeEventListener("mouseout",r),t&&n()},l=e=>{i(),e.preventDefault(),e.stopPropagation(),e.target!==a&&window.document.dispatchEvent(new CustomEvent("log-active-element",{detail:{target:e.target}}))},c=()=>{o=!0,a.classList.add("selected-btn"),document.body.style.cursor="crosshair",window.document.body.removeEventListener("click",l),s.innerHTML='fx-fore::before { color:blue; content: "Sub fore!" } fx-fore {border: solid 1px blue}',window.document.body.addEventListener("click",l),window.document.body.addEventListener("mouseover",r),window.document.body.addEventListener("mouseout",r)};window.document.addEventListener("keyup",(e=>{o&&"Escape"===e.code?i():!o&&"KeyI"===e.code&&e.ctrlKey&&c()})),a.addEventListener("click",(e=>{o?i():c(),e.preventDefault(),e.stopPropagation()}))}render(){this.shadowRoot.innerHTML="\n <style>\n \n @import '../../resources/fore.css';\n \n :host {\n display:block;\n background:transparent;\n }\n body {\n -webkit-animation: bugfix infinite 1s;\n font-size:1rem;\n }\n \n @-webkit-keyframes bugfix {\n from {\n padding: 0\n }\n to {\n padding: 0\n }\n }\n .adi-content {\n position: relative;\n overflow: auto;\n box-sizing: border-box;\n -moz-box-sizing: border-box;\n height: 100% !important;\n padding:0;\n font-size:0.8em;\n }\n .adi-content header{\n padding:0.5rem;\n // background:rgba(255, 255, 255, 0.2);\n border-bottom:2px solid #ddd;\n border-collapse:collapse;\n }\n .adi-content > * {\n padding:0 0.25em;\n }\n \n #adi-wrapper {\n top: 0;\n font-family: \"Segoe UI\", Arial;\n font-size: 1.1rem;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n position:relative;\n height:calc(100% - 8rem);\n display:flex;\n }\n \n #adi-wrapper.left {\n left: 0\n }\n \n #adi-wrapper.right {\n right: 0\n }\n \n #adi-wrapper.transparent {\n background: rgba(250, 250, 250, 0.9)\n }\n \n #adi-panel {\n position:fixed;\n top:0;\n /*bottom: 0;*/\n right: 0;\n height: 24px;\n background: #d4d4d4;\n border-top: 1px solid #bbc5c9\n }\n \n #adi-panel .adi-path-wrap {\n position:absolute;\n bottom: 0;\n left: 0;\n width: 80%;\n height: 24px;\n padding: 0 13px 0 18px;\n line-height: 24px;\n overflow: hidden;\n box-sizing: border-box;\n -moz-box-sizing: border-box\n }\n \n #adi-panel .adi-path-wrap.adi-overflowing .adi-path-left, \n #adi-panel .adi-path-wrap.adi-overflowing .adi-path-right {\n display: block\n }\n \n #adi-panel .adi-path {\n height: 24px;\n overflow: hidden;\n white-space: nowrap\n }\n \n #adi-panel .adi-path-left, #adi-panel .adi-path-right {\n display: none;\n position: absolute;\n top: 0;\n width: 8px;\n height: 24px;\n background-repeat: no-repeat;\n background-position: center center;\n opacity: .7\n }\n \n #adi-panel .adi-path-left:hover, #adi-panel .adi-path-right:hover {\n opacity: 1\n }\n \n #adi-panel .adi-path-left {\n left: 7px;\n background-image: url('img/left_shift.png')\n }\n \n #adi-panel .adi-path-right {\n position:absolute;\n right: 2px;\n background-image: url('/resources/scripts/dom-inspector/img/right_shift.png')\n }\n \n #adi-panel .adi-menu-wrap {\n bottom: 0;\n right: 24px;\n width: 50px;\n height: 24px\n }\n \n #adi-panel .adi-menu-lookup, #adi-panel .adi-menu-config {\n display: block;\n float: left;\n width: 24px;\n height: 24px;\n border-left: 1px solid #bbc5c9;\n background-position: center center;\n background-repeat: no-repeat;\n opacity: .7;\n border-radius: 0\n }\n \n #adi-panel .adi-menu-lookup:hover, #adi-panel .adi-menu-config:hover {\n background-color: #c5d9d8;\n opacity: 1\n }\n \n #adi-panel .adi-menu-lookup.adi-active, #adi-panel .adi-menu-config.adi-active {\n background-color: #fafafa;\n opacity: 1\n }\n \n #adi-panel .adi-menu-lookup {\n background-image: url('/resources/scripts/dom-inspector/img/lookup.png')\n }\n \n #adi-panel .adi-menu-config {\n background-image: url('/resources/scripts/dom-inspector/img/config.png')\n }\n \n \n \n #adi-vert-split {\n position: fixed;\n top: 0;\n width: 4px;\n height: 100%;\n cursor: e-resize;\n border-width: 0 1px 0 0;\n background: #bbc5c9;\n border-color: #768285;\n border-style: solid;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n \n #adi-vert-split:hover {\n background: #c5d9d8;\n }\n \n \n #adi-dom-view {\n border-right:2px solid #ddd;\n overflow:auto;\n flex-grow:3;\n }\n \n #adi-dom-view ul {\n margin: 0;\n padding: 0;\n list-style: none\n }\n \n #adi-dom-view ul[data-open=true] {\n display: block\n }\n \n #adi-dom-view ul[data-open=false] {\n display: none\n }\n \n #adi-dom-view ul ul {\n margin: 4px 0\n }\n \n #adi-dom-view ul li {\n padding-left: 1em;\n padding-bottom: 0.125em;\n margin: 0;\n padding-top: 0.125em; \n }\n \n \n \n \n \n \n \n #adi-dom-view .adi-normal-node, \n #adi-dom-view .adi-end-node {\n margin-right: 5px;\n padding: 0 6px 0px;\n background: #d2e8ff;\n border-radius: 8px;\n cursor: default;\n font-size:0.8rem;\n }\n #adi-dom-view .adi-text-node:after, #adi-dom-view .adi-comment-node:after {\n content: '\"'\n }\n \n #adi-dom-view .adi-text-node:before, #adi-dom-view .adi-comment-node:before {\n content: '\"'\n }\n \n #adi-dom-view .adi-comment-node {\n color: #999;\n font-style: italic\n }\n \n #adi-dom-view .adi-text-node, #adi-dom-view .adi-comment-node {\n display: block;\n padding: 3px 8px;\n color: #444;\n background: #fff;\n border-radius: 8px\n }\n \n #adi-dom-view .adi-normal-node:hover, \n #adi-dom-view .adi-normal-node.hover, \n #adi-dom-view .adi-end-node:hover, \n #adi-dom-view .adi-end-node.hover {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-normal-node:hover ~ span,\n #adi-dom-view .adi-normal-node.hover ~ span,\n #adi-dom-view .adi-end-node:hover ~ span,\n #adi-dom-view .adi-end-node.hover ~ span {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-normal-node.adi-active-node, \n #adi-dom-view .adi-end-node.adi-active-node {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-normal-node.adi-active-node ~ span,\n #adi-dom-view .adi-end-node.adi-active-node ~ span {\n background: var(--paper-grey-700);\n color:white;\n }\n \n \n \n \n \n \n #adi-dom-view .adi-trigger {\n display: inline-block;\n width: 10px;\n height: 10px;\n margin: 0 5px 0 -13px;\n opacity: .7\n }\n \n #adi-dom-view .adi-trigger.closed {\n // background: url('/resources/scripts/dom-inspector/img/node_closed.png') no-repeat;\n } \n #adi-dom-view .adi-trigger.closed::before {\n content:'\\25B8';\n }\n \n #adi-dom-view .adi-trigger.opened {\n // background: url('/resources/scripts/dom-inspector/img/node_opened.png') no-repeat\n }\n #adi-dom-view .adi-trigger.opened::before{\n content:'\\25BE';\n }\n \n #adi-dom-view .adi-trigger:hover {\n opacity: 1\n }\n \n #adi-opts-view {\n position: relative;\n height: 100%;\n padding: 0 15px;\n background: #fff\n }\n \n #adi-opts-view.adi-hidden {\n display: none\n }\n \n #adi-opts-view .adi-opt-heading, #adi-opts-view .adi-opt {\n display: block;\n padding: 5px 0\n }\n \n #adi-opts-view .adi-opt-heading {\n padding: 20px 0 10px;\n font-size: 1rem;\n }\n \n #adi-opts-view .adi-opt-heading:first-child {\n padding-top: 10px\n }\n \n #adi-opts-view .adi-opt input {\n margin-right: 6px\n }\n \n #adi-opts-view .adi-opt-close {\n position: absolute;\n top: 5px;\n right: 28px;\n width: 16px;\n height: 16px;\n background: url('/resources/scripts/dom-inspector/img/options_close.png') no-repeat;\n opacity: .7;\n }\n \n #adi-opts-view .adi-opt-close:hover {\n opacity: 1;\n }\n \n #adi-attr-view {\n top: 0.5rem;\n border: 1px solid #ddd;\n overflow: auto;\n padding: 0.25em;\n height: calc(90% - 1em);\n min-width: 10rem;\n position: absolute;\n z-index: 10;\n right: 0.5rem;\n background:rgba(255,255,255,0.85);\n }\n #adi-attr-view > .adi-content{\n height:calc(100% - 5em);\n overflow:auto;\n }\n \n #adi-attr-view .adi-attr {\n display: block;\n padding: 0.25em;\n }\n \n #adi-attr-view hr {\n height: 1px;\n border: none\n }\n \n #adi-attr-view input[type=text] {\n width: calc(100% - 0.5em);\n margin-top: 3px;\n padding: 2px;\n }\n \n #adi-horiz-split {\n height: 4px;\n cursor: n-resize;\n border-width: 0 0 1px 0;\n background: #bbc5c9;\n border-color: #768285;\n border-style: solid;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n \n #adi-horiz-split:hover {\n background: #c5d9d8;\n }\n \n #adi-dom-view .fore-node{\n background: var(--paper-blue-700);\n font-size:1.1em;\n color:white;\n }\n #adi-dom-view .adi-normal-node.fore-node:hover {\n background: var(--paper-grey-700);\n color:white;\n }\n #adi-dom-view .adi-end-node.fore-node{\n background: var(--paper-blue-700);\n font-size:1em;\n color:white;\n }\n\n #adi-dom-view .adi-node .adi-active-node.fore-node,\n #adi-dom-view .adi-node.action .adi-active-node.fore-node,\n #adi-dom-view .adi-node.action .adi-active-node.fore-node ~ .adi-end-node\n {\n background: var(--paper-grey-700);\n color:white;\n }\n \n #adi-dom-view .adi-node.fx-fore{\n background:var(--paper-blue-grey-50); \n }\n #adi-dom-view .adi-node.fx-model{\n background:var(--paper-blue-grey-100); \n padding:0.25em 0;\n } \n \n #adi-dom-view .adi-node.action .fore-node {\n background:var(--paper-blue-grey-100);\n color:black;\n font-family:monospace;\n }\n \n .toggleView{\n /*width:20px;*/\n /*height: 20px;*/\n }\n input, select{\n display: block;\n }\n header{\n background:rgba(255, 255, 255, 0.2);\n }\n\n .selected-btn { color: orange }\n \n </style>\n \n <slot name=\"header\"></slot>\n <button id=\"focus-button\">Focus</button>\n <slot></slot>\n \n ",!this.hasAttribute("instance")||this.getAttribute("instance"),this.adiInstance=new yn(this.shadowRoot,this.hasAttribute("instance")?this.instance:"#document")}verticalResize(e){if(!this.vertResizing)return;e=e||window.event,document.documentElement.style.cursor="e-resize";const t=this.options.width+this.xPos-e.clientX;t>=this.options.minWidth&&(this.options.width=t,this.xPos=e.clientX,this.refreshUI(),this.saveOptions())}}customElements.get("fx-dom-inspector")||customElements.define("fx-dom-inspector",wn);class vn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.instanceElement=null,this.foreSelector=null}connectedCallback(){this.container=this.querySelector(".json-path-picker-container"),this.foreSelector=this.hasAttribute("fore")?this.getAttribute("fore"):"fx-fore",this.render()}render(){const e=this.hasAttribute("instance")?this.getAttribute("instance"):"default";if(!document.querySelector(this.foreSelector))throw new Error(`this '${this.foreSelector}' does not match a fx-fore element`);this.shadowRoot.innerHTML=`\n <style>\n \n @import '../../resources/fore.css';\n \n :host {\n display:block;\n font-size:0.8em;\n background:rgba(250, 250, 250, 0.9);\n }\n .container{\n margin-left:1em;\n }\n .header{\n margin-left:0;\n }\n\n ::slot[name='header']{\n margin-left:-1em;\n }\n /* Syntax highlighting for JSON objects */\n ul.json-dict, ol.json-array {\n list-style-type: none;\n margin: 0 0 0 1px;\n border-left: 1px dotted #ccc;\n padding-left: 2em;\n }\n .json-string {\n // color: #0B7500;\n }\n .json-literal {\n color: #1A01CC;\n font-weight: bold;\n }\n \n /* Toggle button */\n a.json-toggle {\n position: relative;\n color: inherit;\n text-decoration: none;\n }\n a.json-toggle:focus {\n outline: none;\n }\n a.json-toggle:before {\n content: "\\25BC"; /* down arrow */\n position: absolute;\n display: inline-block;\n width: 1em;\n left: -1.2em;\n font-size:0.8em;\n }\n a.json-toggle.collapsed:before {\n content: "\\25B6"; /* left arrow */\n }\n \n /* Collapsable placeholder links */\n a.json-placeholder {\n color: #aaa;\n padding: 0 1em;\n text-decoration: none;\n }\n a.json-placeholder:hover {\n text-decoration: underline;\n }\n \n /* Copy path icon */\n .pick-path {\n color: lightgray;\n cursor: pointer;\n margin-left: 3px;\n }\n \n .pick-path:hover {\n color: darkgray;\n }\n \n \n </style>\n <slot name="header">\n <header class="header">${e}</header>\n </slot>\n <slot></slot>\n \n <div class="container"></div>\n \n `;const t=document.querySelector(`#${e}`);if(!t||"FX-INSTANCE"!==t.nodeName||"json"!==t.getAttribute("type"))throw new Error(`this '${e}' does not match an fx-instance element or is not of type JSON`);const n=this.shadowRoot.querySelector(".container"),r=t.instanceData;let a=this.json2html(r,{outputWithQuotes:!0});this.isCollapsable(r)&&(a="<a href='#' class=\"json-toggle\"></a>".concat(a)),n.innerHTML=a;this.shadowRoot.querySelectorAll(".json-toggle").forEach((e=>{e.addEventListener("click",this._handleToggleEvent.bind(this))}))}disconnectedCallback(){}_isHidden(e){var t=e.offsetWidth,n=e.offsetHeight;return 0===t&&0===n||"none"===window.getComputedStyle(e).display}_handleToggleEvent(e){const t=e.target;t.classList.toggle("collapsed");for(var n=this._siblings(t,"ul.json-dict, ol.json-array",(function(e){e.style.display=""===e.style.display||"block"===e.style.display?"none":"block"})),r=0;r<n.length;r+=1)if(this._isHidden(n[r])){for(var a=n[r].children,o=0,s=0;s<a.length;s+=1)"LI"===a[s].tagName&&(o+=1);var i=o+(o>1?" items":" item");n[r].insertAdjacentHTML("afterend",'<a href class="json-placeholder">'.concat(i,"</a>"))}else this._siblings(n[r],".json-placeholder",(function(e){return e.parentNode.removeChild(e)}));e.stopPropagation(),e.preventDefault()}_siblings(e,t,n){for(var r=[],a=0;a<e.parentNode.children.length;a+=1){var o=e.parentNode.children[a];o!==e&&"string"==typeof t&&o.matches(t)&&r.push(o)}if(n&&"function"==typeof n)for(var s=0;s<r.length;s+=1)n(r[s]);return r}json2html(e,t){let n="";if("string"==typeof e){const t=e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");this.isUrl(t)?n+='<a href="'.concat(t,'" class="json-string">').concat(t,"</a>"):n+='<span class="json-string">"'.concat(t,'"</span>')}else if("number"==typeof e)n+='<span class="json-literal">'.concat(e,"</span>");else if("boolean"==typeof e)n+='<span class="json-literal">'.concat(e,"</span>");else if(null===e)n+='<span class="json-literal">null</span>';else if(e instanceof Array)if(e.length>0){n+='[<ol class="json-array">';for(var r=0;r<e.length;r+=1)n+='<li data-key-type="array" data-key="'.concat(r,'">'),this.isCollapsable(e[r])&&(n+='<a href="#" class="json-toggle"></a>'),n+=this.json2html(e[r],t),r<e.length-1&&(n+=","),n+="</li>";n+="</ol>]"}else n+="[]";else if("object"===this._typeof(e)){let r=Object.keys(e).length;if(r>0){for(var a in n+='{<ul class="json-dict">',e)if(e.hasOwnProperty(a)){n+='<li data-key-type="object" data-key="'.concat(a,'">');const o=t.outputWithQuotes?'<span class="json-string">"'.concat(a,'"</span>'):a;this.isCollapsable(e[a])?n+="<a href='#' class=\"json-toggle\">".concat(o,"</a>"):n+=o,n+=": ".concat(this.json2html(e[a],t)),r-=1,r>0&&(n+=","),n+="</li>"}n+="</ul>}"}else n+="{}"}return n}isUrl(e){return/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#:.?+=&%@!\-/]))?/.test(e)}_typeof(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?this._typeof=function(e){return typeof e}:this._typeof=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},this._typeof(e)}isCollapsable(e){return e instanceof Object&&Object.keys(e).length>0}static get observedAttributes(){return["data"]}attributeChangedCallback(e,t,n){"data"===e&&(this.jsonTextarea.value=n,this.updateTree(n))}updateTree(e){try{this.data=JSON.parse(e),this.treeView.innerHTML="",this.treeView.appendChild(this.createTreeView(this.data,""))}catch(e){console.error(e),alert("Invalid JSON")}}createTreeView(e,t){let n=document.createElement("ul");if(n.classList.add("jp-ul"),Array.isArray(e))e.forEach(((e,r)=>{let a=document.createElement("li");a.classList.add("jp-li");let o=t+"["+r+"]";a.appendChild(this.createItemView(o,e)),n.appendChild(a)}));else if("object"==typeof e&&null!==e)Object.keys(e).forEach((r=>{let a=document.createElement("li");a.classList.add("jp-li");let o=t+"."+r;a.appendChild(this.createItemView(o,e[r])),n.appendChild(a)}));else{let r=document.createElement("li");r.classList.add("jp-li"),r.appendChild(this.createItemView(t,e)),n.appendChild(r)}return n}}customElements.get("fx-json-instance")||customElements.define("fx-json-instance",vn);class xn extends HTMLElement{static get properties(){return{fore:{type:Object,description:"The fx-fore element the devtools are attached to"},instances:{type:Array,description:"Instances of selected Fore element"},selector:{type:String,description:"optional selector to attach to a certain fx-fore element with given id"}}}constructor(){super(),this.attachShadow({mode:"open"}),Object.keys(this.constructor.properties).forEach((e=>{const t=this.constructor.properties[e],n=t.attribute||e,r=this.getAttribute(n)||t.default,a=t.type(r);this[e]=a})),this.isResizing=!1,this.lastY=0,this.defaultHeight="40vh",this.buttonByInstanceId=new Map;const e=e=>{this.fore=e,this.instances=[...this.fore.getModel().instances];const t=this.shadowRoot.querySelector(".instances header");t.textContent="Data ",this.instances.forEach((e=>{const n=document.createElement("button");n.setAttribute("type","button"),n.textContent=e.id,t.appendChild(n),this.buttonByInstanceId.set(e.id,n),n.addEventListener("click",(()=>this.selectInstance(e.id)))})),this.instances.length&&this.selectInstance(this.instances[0].id)},t=document.querySelector("fx-fore");t&&(t.inited?e(t):t.addEventListener("model-construct-done",(()=>e(t)))),window.document.addEventListener("log-active-element",(t=>{const n=t?t.detail?.target||t.target:window.event.srcElement,r=n.nodeType===Node.DOCUMENT_NODE?null:n.closest("fx-fore");r&&e(r);const a=this.instances.find((e=>"xml"===e.type&&e.instanceData.contains(n)));a&&this.selectInstance(a.id)}))}_getInstanceForTarget(e){this.instances.forEach((t=>"xml"===t.type&&t.instanceData.contains(e)||"json"===t.type?t:void 0))}selectInstance(e){const t=this.buttonByInstanceId.get(e);if(!t)return;if(t.classList.contains("selected-btn"))return;const n=this.shadowRoot.querySelector(".selected-btn");n&&n.classList.remove("selected-btn"),t.classList.add("selected-btn");const r=this.shadowRoot.querySelector(".instance-panel");r.innerHTML="",this.instances=[...this.fore.querySelectorAll("fx-instance")];const a=Array.from(this.instances).find((t=>t.id===e)),o=this._renderInstancePanel(a);r.append(o)}connectedCallback(){this.render()}_startResize(e){this.isResizing=!0,this.lastY=e.clientY}_resizePanel(e){if(!this.isResizing)return;const t=e.clientY-this.lastY;this.style.height=this.offsetHeight-t+"px",this.lastHeight=this.style.height,this.lastY=e.clientY}_stopResize(e){e.preventDefault(),e.stopPropagation(),this.isResizing=!1,document.body.style.height="inherit",document.body.style.width="inherit";const t=document.body.scrollHeight+this.offsetHeight;document.body.style.height=`${t}px`}render(){const e=`\n <section class="wrapper">\n <slot></slot>\n <details class="fx-devtools" open>\n <div class="resizer"></div>\n <summary>Fore Glass \n <div>\n <svg preserveAspectRatio="xMidYMid meet" focusable="true" style="width: 24px;height: 24px; margin-bottom:-1px;" width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg">\n <g role="button" id="find-in-page"><path d="M20 19.59V8l-6-6H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c.45 0 .85-.15 1.19-.4l-4.43-4.43c-.8.52-1.74.83-2.76.83-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5c0 1.02-.31 1.96-.83 2.75L20 19.59zM9 13c0 1.66 1.34 3 3 3s3-1.34 3-3-1.34-3-3-3-3 1.34-3 3z"></path></g>\n </svg>\n <button class="optionsBtn" id="optionsTrigger">&#9881;</button> \n </div>\n </summary>\n <section class="panels">\n <section class="log">\n <fx-action-log selector="${this.selector}"></fx-action-log>\n </section>\n <section class="dom">\n <fx-dom-inspector>\n <header slot="header">Document</header>\n </fx-dom-inspector>\n </section>\n <section class="instances">\n <header></header>\n <div class="instance-panel">\n </div>\n </section>\n <section id="options">\n <fx-log-settings></fx-log-settings>\n </section>\n </section>\n </details>\n </section>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n @import '../../resources/fore.css';\n \n :host {\n display:block;\n position:fixed;\n bottom:0;\n left:0;\n width:100vw;\n height:var(--fx-devtools-height);\n font-style:inherit;\n font-family: 'Verdana' , 'Sans';\n font-size:1em;\n max-width:100vw;\n height:3em;\n }\n :host(.open){\n height:40vh;\n }\n \n fx-action-log{\n height:100%;\n }\n fx-dom-inspector{\n max-height:100%;\n height:100%;\n position:relative;\n }\n body {\n }\n details{\n height:100%;\n background:#ebf6ff;\n }\n .dom{\n width:45%;\n border-left:1px solid #999;\n position:relative\n }\n .dom fx-minimap{\n position:absolute;\n right:0;\n top:0;\n width:5rem;\n height:6rem;\n }\n header{\n padding:0.5rem;\n border-bottom:2px solid #ddd;\n font-size:1rem;\n }\n header button{\n margin:0 0.5em;\n border:thin solid #999;\n padding:0 0.5em;\n cursor:pointer;\n }\n header button:hover{\n background:white;\n }\n \n header button.selected-btn{\n background:steelblue;\n color:white;\n }\n .instances{\n width:35%;\n border-left:1px solid #999;\n }\n .instance-panel{\n height:100%;\n overflow:auto;\n }\n .panels{\n display:grid;\n grid-template-columns:20% 50% 30%;\n height:100%;\n width:100%;\n max-height:100%;\n border-top:thin solid #ddd;\n }\n .panels > section {\n min-height:20rem;\n/*\n background:#efefef;\n*/\n position:relative;\n display:inline-block;\n height:100%;\n width:auto;\n }\n #options{\n display:none;\n }\n #options.open{\n position:absolute;\n z-index:10;\n left:0;\n top:3em;\n height:100%;\n display:block;\n padding:0;\n background:rgba(255,255,255,0.95);\n width:100%;\n }\n .optionsBtn{\n font-size:2rem;\n }\n details[open] .optionsBtn{\n display:inline;\n }\n .resizer{\n width:100vw;\n height:6px;\n background:rgba(215,220,235,0.3);\n cursor: ns-resize;\n position:absolute;\n top:0;\n \n }\n summary{\n height:3rem;\n padding:0 1em;\n border-bottom:2px solid #ddd;\n display:flex;\n justify-content:space-between;\n align-items:center;\n color:rgba(0,0,0,0.7);\n background: rgba(235, 255, 255, 0.2);\n box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);\n backdrop-filter: blur(5px);\n -webkit-backdrop-filter: blur(5px);\n border: 1px solid rgba(255, 255, 255, 0.3);\n \n color:white;\n font-weight:300;\n background: rgb(119,119,119);\n background: linear-gradient(90deg, rgba(0,85,159,0.75) 0%, rgba(56,154,252,0.5) 50%, rgba(255,255,255,0.1) 100%);\n\n }\n summary button{\n padding:0;\n border:0;\n background:transparent;\n }\n .wrapper{\n height:100%;\n }\n .vertDevider{\n background:#ddd;\n width:4px;\n height:100%;\n cursor: ew-resize;\n }\n \n </style>\n ${e}\n `,this.resizer=this.shadowRoot.querySelector(".resizer"),this.resizer.addEventListener("mousedown",this._startResize.bind(this)),document.addEventListener("mousemove",this._resizePanel.bind(this)),document.addEventListener("mouseup",this._stopResize.bind(this));const t=this.shadowRoot.querySelector("#optionsTrigger");t.addEventListener("click",(()=>{const e=this.shadowRoot.querySelector("#options");e.classList.toggle("open"),e.classList.contains("open")?t.style.background="lightsteelblue":t.style.background="transparent"}));this.shadowRoot.querySelector(".fx-devtools").addEventListener("click",(e=>{"DIV"===e.target.nodeName&&e.target.classList.contains("resizer")||(e.target.parentNode.open?(this.removeAttribute("open"),this.lastHeight=this.style.height,this.style.height="3em"):(this.setAttribute("open",""),this.style.height=this.lastHeight?this.lastHeight:"40vh"))})),this.classList.add("open")}_handleOpen(e){document.body.style.height=""}_renderInstancePanel(e){if("xml"===e.type){const t=document.createElement("fx-dom-inspector");return t.setInstance(e),t.setAttribute("instance",e.id),t}if("json"===e.type){const t=document.createElement("fx-json-instance");t.setAttribute("instance",e.id);const n=document.createElement("span");return n.setAttribute("slot","header"),t.append(n),t}}}customElements.get("fx-devtools")||customElements.define("fx-devtools",xn);class bn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.src=""}connectedCallback(){this.src=this.getAttribute("src");const e=`\n <fx-fore src="${this.src}">\n </fx-fore>\n <slot id="default"></slot>\n `;this.shadowRoot.innerHTML=`\n <style>\n \n :host {\n display:block;\n }\n \n </style>\n ${e}\n `;this.shadowRoot.querySelector("#default").addEventListener("slotchange",(async e=>{const t=e.target.assignedElements().filter((e=>"LINK"===e.nodeName.toUpperCase()));if(!t)return;const n=[...document.styleSheets].map((e=>{if(t.find((t=>t.href===e.href)))try{return[...e.cssRules].map((e=>e.cssText)).join("")}catch(t){console.log("Access to stylesheet %s is denied. Ignoring…",e.href)}})).filter(Boolean).join("\n"),r=new CSSStyleSheet;r.replaceSync(n),this.shadowRoot.adoptedStyleSheets=[r]}));const t=this.querySelector("fx-action");if(t){const e=t.cloneNode(!0);this.removeChild(t);this.shadowRoot.querySelector("fx-fore").appendChild(e)}}}async function An(e){return new Promise((t=>setTimeout((()=>t()),e)))}customElements.get("fore-component")||customElements.define("fore-component",bn);class En extends(Rt(HTMLElement)){static get properties(){return{...super.properties,defaultAction:{type:String},delay:{type:Number},detail:{type:Object},event:{type:Object},handler:{type:Object},ifExpr:{type:String},iterateExpr:{type:String},needsUpdate:{type:Boolean},observer:{type:Object},phase:{type:String},propagate:{type:String},target:{type:String},whileExpr:{type:String}}}constructor(){super(),this.detail={},this.needsUpdate=!1}disconnectedCallback(){}connectedCallback(){this.style.display="none",this.propagate=this.hasAttribute("propagate")?this.getAttribute("propagate"):"continue",this.repeatContext=void 0,this.hasAttribute("event")&&(this.event=this.getAttribute("event")),this.hasAttribute("defaultAction")?this.defaultAction=this.getAttribute("defaultAction"):this.defaultAction="perform",this.hasAttribute("phase")?this.phase=this.getAttribute("phase"):this.phase="default",this.ifExpr=this.hasAttribute("if")?this.getAttribute("if"):null,this.whileExpr=this.hasAttribute("while")?this.getAttribute("while"):null,this.delay=this.hasAttribute("delay")?Number(this.getAttribute("delay")):0,this.iterateExpr=this.hasAttribute("iterate")?this.getAttribute("iterate"):null,this._addUpdateListener()}_addUpdateListener(){if(this.target=this.getAttribute("target"),this.target)if("#window"===this.target)window.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase});else if("#document"===this.target)document.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase});else{if(this.targetElement=ut(this.target,this),!this.targetElement)return;this?.targetElement.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase})}else this.targetElement=this.parentNode,this.targetElement.addEventListener(this.event,(e=>this.execute(e)),{capture:"capture"===this.phase})}async performSafe(){try{return await this.perform(),!0}catch(e){return await St.dispatch(this,"error",{origin:this,message:"Action execution failed",expr:tt.getDocPath(this),level:"Error"}),!1}}async execute(e){if(console.log(this,this.event),e&&e.target.nodeType!==Node.DOCUMENT_NODE&&e.target!==window&&e.target.closest("fx-fore")&&e.target.closest("fx-fore")!==this.closest("fx-fore"))return;"stop"===this.propagate&&e.stopPropagation(),"cancel"===this.defaultAction&&e.preventDefault();let t=()=>{};e&&e.listenerPromises&&e.listenerPromises.push(new Promise((e=>{t=e}))),null===Ht.outermostHandler&&(Ht.outermostHandler=this,this.dispatchEvent(new CustomEvent("outermost-action-start",{composed:!0,bubbles:!0,cancelable:!0,detail:{cause:e?.type}}))),e&&(this.currentEvent=e),this.needsUpdate=!1;try{this.evalInContext()}catch(e){console.warn("evaluation failed",e)}if(this.targetElement&&this.targetElement.nodeset&&(this.nodeset=this.targetElement.nodeset),this.iterateExpr)return await this.handleIterateExpr(),void this._finalizePerform(t);if(!this.ifExpr||xt(this.ifExpr,Ot(this),this)){if(this.whileExpr)return await this.handleWhileExpr(),void this._finalizePerform(t);if(this.delay&&(await An(this.delay),!tt.contains(this.getOwnerForm(),this)))return this.actionPerformed(),void t();await this.performSafe(),this._finalizePerform(t)}else this._finalizePerform(t)}async handleWhileExpr(){await An(this.delay||0),tt.contains(this.getOwnerForm(),this)&&xt(this.whileExpr,Ot(this),this)&&this.performSafe()&&(this.delay?this.handleWhileExpr():await this.handleWhileExpr())}async handleIterateExpr(){try{const e=yt(this.iterateExpr,Ot(this),this);if(0===e.length)return;if(!tt.contains(this.getOwnerForm(),this))return;for(const t of e)if(this.delay&&await An(this.delay||0),this.currentContext=t,!await this.performSafe())return}finally{this.currentContext=null}}_finalizePerform(e){this.currentEvent=null,this.actionPerformed(),Ht.outermostHandler===this&&(Ht.outermostHandler=null,this.dispatchEvent(new CustomEvent("outermost-action-end",{composed:!0,bubbles:!0,cancelable:!0}))),e()}async perform(){(this.isBound()||"FX-ACTION"===this.nodeName)&&this.evalInContext(),this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}))}actionPerformed(){const e=this.getModel();e&&e.inited&&(Ht.outermostHandler&&!tt.contains(Ht.outermostHandler.ownerDocument,Ht.outermostHandler)&&(Ht.outermostHandler=null),!this.needsUpdate||Ht.outermostHandler!==this&&Ht.outermostHandler?this.needsUpdate&&(Ht.outermostHandler.needsUpdate=!0):(e.recalculate(),e.revalidate(),e.parentNode.refresh(!0),this.dispatchActionPerformed()))}dispatchActionPerformed(){St.dispatch(this,"action-performed",{})}}En.dataChanged=!1,customElements.get("abstract-action")||window.customElements.define("abstract-action",En);class Nn extends En{static get properties(){return{...En.properties,ref:{type:String},repeat:{type:String},clear:{type:String}}}constructor(){super(),this.repeat=""}connectedCallback(){super.connectedCallback(),this.ref=this.getAttribute("ref"),this.repeat=this.getAttribute("repeat")}async perform(){super.perform(),this._dataFromTemplate(),this.needsUpdate=!0}actionPerformed(){super.actionPerformed(),this._dispatch()}_dataFromTemplate(){const e=this.getInScopeContext(),t=this.getOwnerForm().querySelector(`#${this.repeat}`),n=t.shadowRoot.querySelector("template"),r=e.ownerDocument.createElement(t.ref),a=this._generateInstance(n.content,r);e.appendChild(a)}_dispatch(){const e=ut(this.repeat,this);St.dispatch(e,"index-changed",{index:e.nodeset.length})}_clear(e){let t=e.firstChild;const n=e.attributes;for(let e=0;e<n.length;e+=1)n[e].value="";for(;t;)1===t.nodeType&&t.hasAttributes()&&(t.textContent=""),this._clear(t),t=t.nextSibling}_generateInstance(e,t){if(1===e.nodeType&&e.hasAttribute("ref")){const n=e.getAttribute("ref");let r;"."===n||(n.startsWith("@")?t.setAttribute(n.substring(1),""):(r=document.createElement(n),t.appendChild(r),0===e.children.length&&(r.textContent=e.textContent)))}if(e.hasChildNodes()){const n=e.children;for(let e=0;e<n.length;e+=1)this._generateInstance(n[e],t)}return t}getInstanceId(){return this.ref.startsWith("instance(")?"not implemented":"default"}}customElements.get("fx-append")||window.customElements.define("fx-append",Nn);class Tn extends En{static get properties(){return{...super.properties,ref:{type:String}}}async perform(){const e=Ot(this.getAttributeNode("ref")||this,this.ref);this.nodeset=vt(this.ref,e,this);const t=tt.resolveInstance(this,this.ref),n=this.getModel().getInstance(t),r=St.getDomNodeIndexString(this.nodeset),a=this.nodeset;let o;if(this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event,path:r}})),Array.isArray(a)){if(0===a.length)return;o=a[0].parentNode,a.forEach((e=>{this._deleteNode(o,e)}))}else o=a.parentNode,this._deleteNode(o,a);await St.dispatch(n,"deleted",{ref:r,deletedNodes:a}),this.needsUpdate=!0}_deleteNode(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return;if(t.nodeType===Node.DOCUMENT_NODE)return;if(t.nodeType===Node.DOCUMENT_FRAGMENT_NODE)return;if(null===t.parentNode)return;this.getModelItem().readonly||e.removeChild(t)}actionPerformed(){this.getModel().rebuild(),super.actionPerformed()}}customElements.get("fx-delete")||window.customElements.define("fx-delete",Tn);class Bn extends En{connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.control=this.hasAttribute("control")?this.getAttribute("control"):null}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));const e="#"+this.control;let t=document.querySelector(e);if(!t)return void St.dispatch(this,"error",{origin:this,message:`Instance '${this.control}' not found`,level:"Error"});const n=t.closest("fx-repeatitem");n&&(t=n.querySelector(e),this._focus(t));const r=t.closest("fx-repeatitem, .fx-repeatitem");if(r){t=r.parentNode.querySelector("[repeat-index] "+e)}this._focus(t),this.hasAttribute("select")&&this._select(t)}_focus(e){e&&"function"==typeof e.getWidget&&e.getWidget().focus(),e&&e.nodeType===Node.ELEMENT_NODE&&e.click()}_select(e){e&&e.getWidget().select()}}customElements.get("fx-setfocus")||window.customElements.define("fx-setfocus",Bn);class In extends En{static get properties(){return{...super.properties,at:{type:Number},position:{type:Number},origin:{type:Object},keepValues:{type:Boolean}}}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){super.connectedCallback&&super.connectedCallback();this.shadowRoot.innerHTML="\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n <slot></slot>\n ",this.at=Number(this.hasAttribute("at")?this.getAttribute("at"):0),this.position=this.hasAttribute("position")?this.getAttribute("position"):"after",this.origin=this.hasAttribute("origin")?this.getAttribute("origin"):null,this.keepValues=!!this.hasAttribute("keep-values")}_getOriginSequence(e,t){let n;if(this.origin){let t;try{t=wt(this.origin,e,this),Array.isArray(t)&&0===t.length&&(console.warn("invalid origin for this insert action - ignoring...",this),n=null),n=t}catch(e){console.warn("invalid origin for this insert action - ignoring...",this)}}else t&&(n=t,n&&!this.keepValues&&this._clear(n));return n}_cloneOriginSequence(e,t){let n;if(this.origin){let t;try{t=wt(this.origin,e,this),Array.isArray(t)&&0===t.length&&(console.warn("invalid origin for this insert action - ignoring...",this),n=null),n=t.cloneNode(!0)}catch(e){console.warn("invalid origin for this insert action - ignoring...",this)}}else t&&(n=this._cloneTargetSequence(t),n&&!this.keepValues&&this._clear(n));return n}_getInsertIndex(e,t){return 0===t.length?null:this.hasAttribute("at")?At(this.getAttribute("at"),e,this):t.length}async perform(){let e,t,n=[];const r=Ot(this);this.hasAttribute("context")&&([t]=vt(this.getAttribute("context"),r,this.getOwnerForm()),e=r),this.hasAttribute("ref")&&(e||(e=Ot(this.getAttributeNode("ref"),this.ref)),n=vt(this.ref,e,this));const a=this._cloneOriginSequence(e,n);if(!a)return;let o,s;if(0===n.length)t?(o=t,t.appendChild(a),s=1):(o=e,e.appendChild(a),s=1);else{if(this.hasAttribute("at")?(s=At(this.getAttribute("at"),e,this),o=n[s-1]):(s=n.length,o=n[n.length-1]),!o){s=1,o=n;s=At("count(preceding::*)",n,this.getOwnerForm())+1}this.position&&"before"===this.position&&o.parentNode.insertBefore(a,o),this.position&&"after"===this.position&&(s+=1,this.hasAttribute("context")&&this.hasAttribute("ref")?e.append(a):this.hasAttribute("context")?(s=1,o.prepend(a)):o.insertAdjacentElement("afterend",a))}const i=tt.resolveInstance(this,this.ref),l=this.getModel().getInstance(i),c=tt.getPath(o.parentNode,i),u=St.getDomNodeIndexString(a);return this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event,path:u}})),St.dispatch(l,"insert",{"inserted-nodes":a,"insert-location-node":o,position:this.position}),document.dispatchEvent(new CustomEvent("index-changed",{composed:!0,bubbles:!0,detail:{insertedNodes:a,index:s}})),this.needsUpdate=!0,console.log("Changed!",c),[c]}_cloneTargetSequence(e){return Array.isArray(e)&&0!==e.length?e[e.length-1].cloneNode(!0):!Array.isArray(e)&&e?e.cloneNode(!0):null}actionPerformed(e){this.getModel().rebuild(),super.actionPerformed()}_clear(e){const t=e.attributes;for(let e=0;e<t.length;e+=1)t[e].value="";e.textContent&&(e.textContent="");let n=e.firstChild;for(;n;)1===n.nodeType&&n.hasAttributes()&&(n.textContent=""),this._clear(n),n=n.nextSibling}}customElements.get("fx-insert")||window.customElements.define("fx-insert",In);class Cn extends En{constructor(){super(),this.attachShadow({mode:"open"})}static get properties(){return{...En.properties,modelItem:void 0,messageTextContent:{type:String,get value(){return"here!"}}}}connectedCallback(){super.connectedCallback(),this.event=this.hasAttribute("event")?this.getAttribute("event"):"",this.level=this.hasAttribute("level")?this.getAttribute("level"):"ephemeral",this.message="",this.messageTextContent=this.textContent;this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n ${this.renderHTML()}\n `}renderHTML(){return"\n <slot></slot>\n "}async perform(){super.perform(),this.hasAttribute("value")?this.message=this._getValue():(this.getOwnerForm().evaluateTemplateExpression(this.messageTextContent,this.firstChild),this.message=this.textContent),this.dispatchEvent(new CustomEvent("message",{composed:!1,bubbles:!0,detail:{level:this.level,message:this.message}}))}_getValue(){if(this.hasAttribute("value")){const e=this.getAttribute("value");try{return bt(e,Ot(this,e),this)}catch(e){console.error(e),St.dispatch(this,"error",{message:e})}}return this.textContent?this.textContent:null}}customElements.get("fx-message")||window.customElements.define("fx-message",Cn);class On extends En{static get properties(){return{...super.properties,ref:{type:String},valueAttr:{type:String}}}constructor(){super(),this.ref="",this.valueAttr=""}connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),!this.hasAttribute("ref"))throw new Error('fx-setvalue must specify a "ref" attribute');this.ref=this.getAttribute("ref"),this.valueAttr=this.getAttribute("value")}async perform(){super.perform();let{value:e}=this;null!==this.valueAttr?[e]=yt(this.valueAttr,this.nodeset,this,this.detail):e=""!==this.textContent?this.textContent:"",e?.nodeType&&e.nodeType===Node.ATTRIBUTE_NODE&&(e=e.nodeValue);const t=this.getModelItem();this.setValue(t,e)}dispatchExecute(){}setValue(e,t){const n=e;if(n&&n.value!==t){const r=St.getDomNodeIndexString(e.node),a=this.event,o=this;this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:o,event:a,value:t,path:r}})),t?.nodeType?(t.nodeType===Node.ELEMENT_NODE&&(n.value=t.textContent),t.nodeType===Node.ATTRIBUTE_NODE&&(n.value=t.getValue())):n.value=t,this.getModel().changed.push(e),this.needsUpdate=!0}}}customElements.get("fx-setvalue")||window.customElements.define("fx-setvalue",On);class Sn extends En{constructor(){super(),this.value="",this.url=null,this.target=null}connectedCallback(){super.connectedCallback(),this.submission=this.getAttribute("submission"),this.url=this.hasAttribute("url")?this.getAttribute("url"):null,this.target=this.hasAttribute("target")?this.getAttribute("target"):null}async perform(){super.perform(),console.log("submitting ",this.submission),this.getOwnerForm().classList.remove("submit-validation-failed");const e=this.getModel().querySelector(`#${this.submission}`);if(null!==e){if(this.url){const t=this.evaluateAttributeTemplateExpression(this.url,this);e.parameters.set("url",t)}if(this.target){const t=this.evaluateAttributeTemplateExpression(this.target,this);e.parameters.set("target",t)}console.log("submission",e),await e.submit()}else this.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,cancelable:!0,detail:{id:this.id,origin:this,message:`<fx-submission id="${this.submission}"> not found`,expr:tt.getDocPath(this),level:"Error"}}))}}customElements.get("fx-send")||window.customElements.define("fx-send",Sn);class Fn extends En{connectedCallback(){super.connectedCallback(),this.hasAttribute("case")&&(this.case=this.getAttribute("case"))}async perform(){if(super.perform(),this.case){const e=this.getOwnerForm().querySelector(`#${this.case}`);if(!e)return void St.dispatch(this,"error",{message:`fx-case id not found: ${this.case}`});e.parentNode.toggle(e)}this.needsUpdate=!0}}customElements.get("fx-toggle")||window.customElements.define("fx-toggle",Fn);class Dn extends En{static get properties(){return{...super.properties,name:{type:String},targetid:{type:String},details:{type:String}}}constructor(){super(),this.name=null,this.targetid=null,this.details=null,this.attachShadow({mode:"open"})}connectedCallback(){if(super.connectedCallback(),this.name=this.getAttribute("name"),!this.name)throw new Error("no event specified for dispatch",this);this.targetid=this.hasAttribute("targetid")?this.getAttribute("targetid"):null}async perform(){super.perform();const e=this.querySelectorAll("fx-property"),t={};if(Array.from(e).forEach((e=>{const n=e.getAttribute("name"),r=e.getAttribute("value"),a=e.getAttribute("expr");if(a){if(r)throw new Error('if "expr" is given there must not be a "value" attribute');const[e]=yt(a,this.getInScopeContext(),this);let o=null;if(e.nodeName){o=(new XMLSerializer).serializeToString(e)}t[n]=o||e}r&&(t[n]=r)})),this.targetid){let e=ut(this.targetid,this.parentNode,null);if(e||(e=document.getElementById(this.targetid)),!e)throw new Error(`targetid ${this.targetid} does not exist in document`);e.dispatchEvent(new CustomEvent(this.name,{composed:!0,bubbles:!0,detail:t}))}else document.dispatchEvent(new CustomEvent(this.name,{composed:!0,bubbles:!0,detail:t}))}}customElements.get("fx-dispatch")||window.customElements.define("fx-dispatch",Dn);class kn extends En{async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}})),this.getModel().updateModel()}}customElements.get("fx-update")||window.customElements.define("fx-update",kn);class Rn extends En{async perform(){if(this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}})),this.hasAttribute("self")){console.log(`### <<<<< refresh() self ${this} >>>>>`);const e=tt.getClosest("fx-control",this);if(e)return void e.refresh()}if(this.hasAttribute("force"))return console.log(`### <<<<< refresh() force ${this} >>>>>`),void this.getOwnerForm().forceRefresh();if(this.hasAttribute("control")){const e=this.getAttribute("control");console.log(`### <<<<< refresh() control '${e}' >>>>>`);const t=ut(e,this);t&&St.isUiElement(t.nodeName)&&"function"==typeof t.refresh&&t.refresh()}else this.getOwnerForm().refresh()}}customElements.get("fx-refresh")||window.customElements.define("fx-refresh",Rn);class Mn extends En{static get properties(){return{...super.properties,with:{type:String},replaceNode:Object}}constructor(){super(),this.with=""}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.with=this.getAttribute("with")}async perform(){super.perform();const e=wt(this.with,this.nodeset,this);e&&this.replace(this.nodeset,e)}actionPerformed(){this.getModel().rebuild(),super.actionPerformed()}replace(e,t){if(e&&t)if(e.nodeName&&t.nodeName){if(e.nodeType===Node.ATTRIBUTE_NODE){const{ownerElement:n}=e;n.setAttribute(t.nodeName,t.textContent),n.removeAttribute(e.nodeName)}else if(e.nodeType===Node.ELEMENT_NODE){const n=t.cloneNode(!0);e.replaceWith(n)}this.needsUpdate=!0}else console.warn("fx-replace: one argument is not a node")}}customElements.get("fx-replace")||window.customElements.define("fx-replace",Mn);class Un extends En{connectedCallback(){super.connectedCallback&&super.connectedCallback()}async perform(){super.perform();const e=new CustomEvent("return",{composed:!0,bubbles:!0,detail:{nodeset:this.nodeset}});this.getOwnerForm().dispatchEvent(e)}}customElements.get("fx-return")||window.customElements.define("fx-return",Un);class Gn extends En{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.src=this.hasAttribute("src")?this.getAttribute("src"):null;this.shadowRoot.innerHTML="\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n <slot></slot>\n "}async perform(){super.perform();const{children:e}=this;if(this.src){this.innerHTML="";const e=document.createElement("script");e.src=this.src,this.appendChild(e)}else{for(const t of e){if("fx-var"===t.localName)continue;const e=t;e.detail=this.detail,await e.execute()}this.dispatchActionPerformed(),this.needsUpdate=!0}}}customElements.get("fx-action")||window.customElements.define("fx-action",Gn);class $n extends Gn{static get properties(){return{...Gn.properties,message:{type:String}}}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.message=this.hasAttribute("message")?this.getAttribute("message"):null}async perform(){window.confirm(this.message)&&await super.perform()}}customElements.get("fx-confirm")||window.customElements.define("fx-confirm",$n);class Ln extends Gn{connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.dialog=this.getAttribute("dialog"),this.dialog||St.dispatch(this,"error",{message:"dialog does not exist"})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));const e=ut(this.dialog,this);e||console.error("target dialog with given id does not exist",this.dialog),e.open(),St.dispatch(e,"dialog-shown",{})}}customElements.get("fx-show")||window.customElements.define("fx-show",Ln);class Pn extends En{static get properties(){return{...super.properties,dialog:{type:String}}}connectedCallback(){super.connectedCallback(),this.dialog=this.getAttribute("dialog"),this.dialog||St.dispatch(this,"error",{message:"dialog does not exist"})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));const e=ut(this.dialog,this);e.hide(),St.dispatch(e,"dialog-hidden",{})}}customElements.get("fx-hide")||window.customElements.define("fx-hide",Pn);class Hn extends En{connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.addEventListener("reload",(()=>{window.location.reload()}),{once:!0})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}})),St.dispatch(this,"reload",{})}}customElements.get("fx-reload")||window.customElements.define("fx-reload",Hn);class jn extends En{static get properties(){return{...super.properties,instance:{type:String}}}connectedCallback(){super.connectedCallback(),this.instance=this.getAttribute("instance"),this.instance||St.dispatch(this,"error",{message:"instance does not exist"})}async perform(){this.dispatchEvent(new CustomEvent("execute-action",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:this,event:this.event}}));this.getModel().getInstance(this.instance).reset(),this.needsUpdate=!0}}customElements.get("fx-reset")||window.customElements.define("fx-reset",jn);class _n extends En{static get properties(){return{...super.properties,attachTo:{type:String},url:{type:String}}}constructor(){super(),this.attachShadow({mode:"open"}),this.url=""}connectedCallback(){super.connectedCallback(),this.attachTo=this.hasAttribute("attach-to")?this.getAttribute("attach-to"):"_self",this.awaitEvent=this.hasAttribute("await")?this.getAttribute("await"):"",this.url=this.hasAttribute("url")?this.getAttribute("url"):"";this.shadowRoot.innerHTML=`\n <style>\n \n :host{\n display:none;\n }\n \n </style>\n ${this.renderHTML()}`}disconnectedCallback(){this.targetElement.removeEventListener(this.event,(e=>this.execute(e)))}renderHTML(){return"\n <slot></slot>\n "}async perform(){await super.perform();const e=this.querySelector("template");if(e){const t=e.content.cloneNode(!0),n=document.importNode(t,!0);if(this.attachTo.startsWith("#")){const e=ut(this.attachTo.substring(1),this);for(;e.firstChild;)e.removeChild(e.firstChild);if(this.awaitEvent){let t;const r=new Promise((e=>{t=e})),a=()=>{t(),e.removeEventListener(this.awaitEvent,a)};return e.appendChild(n),e.addEventListener(this.awaitEvent,a),await r,this.needsUpdate=!0,void St.dispatch(this,"loaded",{attachPoint:this.attachTo,content:n})}e.appendChild(n),this.needsUpdate=!0}return void St.dispatch(this,"loaded",{})}if(!this.url)return void this.dispatchEvent(new CustomEvent("error",{composed:!1,bubbles:!0,cancelable:!0,detail:{origin:this,message:"neither template element nor Url was specified.",level:"Error"}}));const t=this.evaluateAttributeTemplateExpression(this.url,this);"_blank"===this.attachTo&&window.open(this.url),"_self"===this.attachTo&&(window.location.href=this.url);try{const e=await fetch(t,{method:"GET",mode:"cors",credentials:"same-origin",headers:{"Content-Type":"text/html"}}),n=await e.text();this.attachTo||(this.innerHtml=n),this._attachToElement(n),St.dispatch(this,"loaded",{url:this.url})}catch(e){throw new Error(`failed loading data ${e}`)}}_attachToElement(e){let t;if(e.nodeType)t=e;else try{t=(new DOMParser).parseFromString(e,"text/html").firstElementChild}catch(e){St.dispatch(this,"error",{message:"parsing of content as HTML failed"})}if(this.attachTo.startsWith("_")||this.attachTo.startsWith("#")||St.dispatch(this,"error",{message:'valid values for "attach-to" start with "_" or "#"'}),this.attachTo.startsWith("#")){const e=ut(this.attachTo.substring(1),this);if(e.innerHTML="",t.querySelector("fx-fore"))return void e.append(t.querySelector("fx-fore").cloneNode(!0));const n=t.querySelector("body").cloneNode(!0);e.appendChild(n.firstElementChild)}}_evaluateUrlExpression(){const e=this.getAttribute("url");if(!e)throw new Error("url not specified");return e.replace(/{[^}]*}/g,(e=>{if("{}"===e)return e;const t=e.substring(1,e.length-1),n=Ot(this,t);if(!n)return console.warn("no inscope context for ",this),e;const r=tt.getInstanceId(t),a=r?this.getModel().getInstance(r):this.getModel().getDefaultInstance();try{return bt(t,n,this,null,a)}catch(t){return console.warn("ignoring unparseable url",t),e}}))}}customElements.get("fx-load")||window.customElements.define("fx-load",_n);class Xn extends En{static get properties(){return{...super.properties,ref:{type:String},valueAttr:{type:String},value:{type:Boolean}}}constructor(){super(),this.ref="",this.valueAttr="",this.value=!1}connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),!this.hasAttribute("ref"))throw new Error('fx-togglealue must specify a "ref" attribute');this.ref=this.getAttribute("ref")}async perform(){super.perform();const e=this.getModelItem();"true"===e.value?e.node.textContent="false":e.node.textContent="true",this.needsUpdate=!0}}customElements.get("fx-toggleboolean")||window.customElements.define("fx-toggleboolean",Xn);class qn extends En{static get properties(){return{...super.properties,action:{type:String},fn:{type:String}}}constructor(){super(),this.action="",this.fn=""}connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),this.hasAttribute("action"))this.action=this.getAttribute("action");else{if(!this.hasAttribute("function"))throw new Error('fx-call must specify an "action" or "function" attribute');this.fn=this.getAttribute("function")}}async perform(){super.perform(),this.action&&await this._callAction(),this.fn&&this._callFunction()}async _callAction(){const e=document.querySelector(`#${this.action}`);e?await e.perform():St.dispatch(this,"error",{origin:this,message:`Action '${this.action}' not found`,expr:tt.getDocPath(this),level:"Error"})}_callFunction(){const e=Ot(this,"instance()");yt(this.fn,e,this)}}customElements.get("fx-call")||window.customElements.define("fx-call",qn);class Vn extends En{static get properties(){return{...super.properties,ref:{type:String},attrName:{type:String},attrValue:{type:String}}}constructor(){super(),this.ref="",this.attrName="",this.attrValue=""}connectedCallback(){if(super.connectedCallback&&super.connectedCallback(),!this.hasAttribute("ref"))throw new Error('fx-setvalue must specify a "ref" attribute');this.ref=this.getAttribute("ref"),this.attrName=this.hasAttribute("name")?this.getAttribute("name"):null,this.attrValue=this.hasAttribute("value")?this.getAttribute("value"):"",this.attrName||St.dispatch("this","error",{message:"name or value not specified"})}async perform(){super.perform();const e=this.getModelItem();e.node.nodeType===Node.ELEMENT_NODE?(e.node.setAttribute(this.attrName,this.attrValue),this.needsUpdate=!0):St.dispatch("this","error",{message:"referenced item is not an element"})}}customElements.get("fx-setattribute")||window.customElements.define("fx-setattribute",Vn);class Yn extends Gn{connectedCallback(){super.connectedCallback(),console.log("parentNode",this.parentNode),"FX-MODEL"===this.parentNode.nodeName?this.parentNode.addEventListener("model-construct-done",(e=>{super.perform()})):St.dispatch(this,"error",{message:"parent is not a model"})}}customElements.get("fx-construct-done")||window.customElements.define("fx-construct-done",Yn);class zn extends(Rt(HTMLElement)){constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.style.display="none",this.signature=this.hasAttribute("signature")?this.getAttribute("signature"):null,null===this.signature&&console.error("signature is a required attribute"),this.type=this.hasAttribute("type")?this.getAttribute("type"):null,this.shadowRoot.innerHTML="<slot></slot>",this.override=this.hasAttribute("override")?this.getAttribute("override"):"true",this.functionBody=this.innerText;const e=this.getAttribute("type")||"text/xpath",t=this.signature.match(/(?:(?<prefix>[^:]*):)?(?<localName>[^(]+)\((?<params>(?:\(\)|[^)])*)\)(?: as (?<returnType>.*))?/);if(!t)throw new Error(`Function signature ${this.signature} could not be parsed`);const{prefix:n,localName:r,params:a,returnType:o}=t.groups,s="local"!==n&&n?`${n}:${r}`:{namespaceURI:"http://www.w3.org/2005/xquery-local-functions",localName:r};n||it.push(r);const i=a?a.split(",").map((e=>{const t=e.match(/(?<variableName>\$[^\s]+)(?:\sas\s(?<varType>.+))/);if(!t)throw new Error(`Param ${e} could not be parsed`);const{variableName:n,varType:r}=t.groups;return{variableName:n,variableType:r||"item()*"}})):[];switch(e){case"text/javascript":{const e=new Function("_domFacade",...i.map((e=>e.variableName)),"form",this.functionBody);We(s,i.map((e=>e.variableType)),o||"item()*",((...t)=>e.apply(this.getInScopeContext(),[...t,this.getOwnerForm()])));break}case"text/xquf":case"text/xquery":case"text/xpath":{const t=i.map((e=>je(e.variableType))),n="text/xpath"===e?"XPath3.1":"text/xquery"===e?"XQuery3.1":"XQueryUpdate3.1",r=(e,...r)=>yt(this.functionBody,this.getInScopeContext(),this.getOwnerForm(),i.reduce(((e,n,a)=>(e[n.variableName.replace("$","")]=t[a](r[a]),e)),{}),{language:n});We(s,i.map((e=>e.variableType)),o||"item()*",r);break}default:throw new Error(`Unexpected mimetype ${e} for function`)}}}customElements.get("fx-function")||customElements.define("fx-function",zn);
9
9
  //# sourceMappingURL=fore-dev.js.map