jtlt 0.12.0 → 0.13.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.
Files changed (57) hide show
  1. package/CHANGES.md +5 -0
  2. package/README.md +9 -5
  3. package/demo/calltemplate-params-demo.js +19 -15
  4. package/demo/codemirror.esm.js +140 -70
  5. package/demo/codemirror.js +9 -5
  6. package/demo/index.js +2 -1
  7. package/demo/vendor/fontoxpath/dist/fontoxpath.esm.js +508 -499
  8. package/demo/vendor/jamilih/dist/jml.mjs +516 -225
  9. package/demo/vendor/jsonpath-plus/dist/index-browser-esm.js +11 -5
  10. package/dist/AbstractJoiningTransformer.d.ts +12 -20
  11. package/dist/AbstractJoiningTransformer.d.ts.map +1 -1
  12. package/dist/DOMJoiningTransformer.d.ts +502 -19
  13. package/dist/DOMJoiningTransformer.d.ts.map +1 -1
  14. package/dist/JSONJoiningTransformer.d.ts +41 -25
  15. package/dist/JSONJoiningTransformer.d.ts.map +1 -1
  16. package/dist/JSONPathTransformer.d.ts +20 -20
  17. package/dist/JSONPathTransformer.d.ts.map +1 -1
  18. package/dist/JSONPathTransformerContext.d.ts +103 -80
  19. package/dist/JSONPathTransformerContext.d.ts.map +1 -1
  20. package/dist/StringJoiningTransformer.d.ts +42 -28
  21. package/dist/StringJoiningTransformer.d.ts.map +1 -1
  22. package/dist/XPathTransformer.d.ts +11 -11
  23. package/dist/XPathTransformer.d.ts.map +1 -1
  24. package/dist/XPathTransformerContext.d.ts +47 -45
  25. package/dist/XPathTransformerContext.d.ts.map +1 -1
  26. package/dist/XSLTStyleJSONPathResolver.d.ts +1 -1
  27. package/dist/XSLTStyleJSONPathResolver.d.ts.map +1 -1
  28. package/dist/index-browser.d.ts +2 -2
  29. package/dist/index-browser.d.ts.map +1 -1
  30. package/dist/index-node.d.ts +2 -2
  31. package/dist/index-node.d.ts.map +1 -1
  32. package/dist/index.d.ts +126 -167
  33. package/dist/index.d.ts.map +1 -1
  34. package/docs/API.expanded.md +6 -4
  35. package/docs/API.md +1 -1
  36. package/docs/TO-DO.md +4 -2
  37. package/eslint.config.js +17 -1
  38. package/package.json +23 -22
  39. package/pnpm-workspace.yaml +32 -4
  40. package/rollup.config.js +42 -0
  41. package/src/AbstractJoiningTransformer.js +8 -1
  42. package/src/DOMJoiningTransformer.js +56 -27
  43. package/src/JSONJoiningTransformer.js +64 -44
  44. package/src/JSONPathTransformer.js +86 -85
  45. package/src/JSONPathTransformerContext.js +95 -48
  46. package/src/StringJoiningTransformer.js +48 -23
  47. package/src/XPathTransformer.js +18 -14
  48. package/src/XPathTransformerContext.js +173 -123
  49. package/src/index-browser.js +1 -0
  50. package/src/index-node.js +2 -0
  51. package/src/index.js +125 -68
  52. package/test.html +17 -0
  53. package/test.js +45 -0
  54. package/tsconfig-prod.json +1 -0
  55. package/tsconfig.json +3 -2
  56. package/dist/types.d.ts +0 -204
  57. package/dist/types.d.ts.map +0 -1
@@ -1,22 +1,22 @@
1
1
  import * as xspattern from 'xspattern';
2
2
  import * as prsc from 'prsc';
3
3
  const fontoxpath = (function (xspattern, prsc) {
4
- const VERSION='3.33.2';
4
+ const VERSION='3.34.0';
5
5
  const fontoxpathGlobal = {};
6
- function aa(a,b){if(!("0"!==a&&"-0"!==a||"0"!==b&&"-0"!==b))return 0;var c=/(?:\+|(-))?(\d+)?(?:\.(\d+))?/;a=c.exec(a+"");var d=c.exec(b+""),e=!a[1];const f=!d[1];b=(a[2]||"").replace(/^0*/,"");c=(d[2]||"").replace(/^0*/,"");a=a[3]||"";d=d[3]||"";if(e&&!f)return 1;if(!e&&f)return-1;e=e&&f;if(b.length>c.length)return e?1:-1;if(b.length<c.length)return e?-1:1;if(b>c)return e?1:-1;if(b<c)return e?-1:1;b=Math.max(a.length,d.length);c=a.padEnd(b,"0");b=d.padEnd(b,"0");return c>b?e?1:-1:c<b?e?-1:1:0};function ba(a,b){a=a.toString();if(-1<a.indexOf(".")&&0===b)return!1;a=/^[-+]?0*([1-9]\d*)?(?:\.((?:\d*[1-9])*)0*)?$/.exec(a);return a[2]?a[2].length<=b:!0}function da(){return function(a,b){return 1>aa(a,b)}}function fa(){return function(a,b){return 0>aa(a,b)}}function ha(){return function(a,b){return-1<aa(a,b)}}function ia(){return function(a,b){return 0<aa(a,b)}}
7
- function ja(a,b){switch(b){case "required":return/(Z)|([+-])([01]\d):([0-5]\d)$/.test(a.toString());case "prohibited":return!/(Z)|([+-])([01]\d):([0-5]\d)$/.test(a.toString());case "optional":return!0}}function ka(a){switch(a){case 1:case 0:case 6:case 3:return{};case 4:return{ka:ba,wa:da(),nc:fa(),xa:ha(),oc:ia()};case 18:return{};case 9:case 8:case 7:case 11:case 12:case 13:case 15:case 14:return{Ba:ja};case 22:case 21:case 20:case 23:case 44:return{};default:return null}}var la={},ma={};function na(a){return/^([+-]?(\d*(\.\d*)?([eE][+-]?\d*)?|INF)|NaN)$/.test(a)}function oa(a){return/^[_:A-Za-z][-._:A-Za-z0-9]*$/.test(a)}function pa(a){return oa(a)&&/^[_A-Za-z]([-._A-Za-z0-9])*$/.test(a)}function qa(a){a=a.split(":");return 1===a.length?pa(a[0]):2!==a.length?!1:pa(a[0])&&pa(a[1])}function ra(a){return!/[\u0009\u000A\u000D]/.test(a)}function sa(a){return pa(a)}
6
+ function aa(a,b){if(!("0"!==a&&"-0"!==a||"0"!==b&&"-0"!==b))return 0;var c=/(?:\+|(-))?(\d+)?(?:\.(\d+))?/;a=c.exec(a+"");var d=c.exec(b+""),e=!a[1];const f=!d[1];b=(a[2]||"").replace(/^0*/,"");c=(d[2]||"").replace(/^0*/,"");a=a[3]||"";d=d[3]||"";if(e&&!f)return 1;if(!e&&f)return-1;e=e&&f;if(b.length>c.length)return e?1:-1;if(b.length<c.length)return e?-1:1;if(b>c)return e?1:-1;if(b<c)return e?-1:1;b=Math.max(a.length,d.length);c=a.padEnd(b,"0");b=d.padEnd(b,"0");return c>b?e?1:-1:c<b?e?-1:1:0};function ba(a,b){a=a.toString();if(-1<a.indexOf(".")&&0===b)return!1;a=/^[-+]?0*([1-9]\d*)?(?:\.((?:\d*[1-9])*)0*)?$/.exec(a);return a[2]?a[2].length<=b:!0}function ca(){return function(a,b){return 1>aa(a,b)}}function fa(){return function(a,b){return 0>aa(a,b)}}function ha(){return function(a,b){return-1<aa(a,b)}}function ia(){return function(a,b){return 0<aa(a,b)}}
7
+ function ja(a,b){switch(b){case "required":return/(Z)|([+-])([01]\d):([0-5]\d)$/.test(a.toString());case "prohibited":return!/(Z)|([+-])([01]\d):([0-5]\d)$/.test(a.toString());case "optional":return!0}}function ka(a){switch(a){case 1:case 0:case 6:case 3:return{};case 4:return{ja:ba,va:ca(),pc:fa(),wa:ha(),qc:ia()};case 18:return{};case 9:case 8:case 7:case 11:case 12:case 13:case 15:case 14:return{Ca:ja};case 22:case 21:case 20:case 23:case 44:return{};default:return null}}var la={},ma={};function na(a){return/^([+-]?(\d*(\.\d*)?([eE][+-]?\d*)?|INF)|NaN)$/.test(a)}function oa(a){return/^[_:A-Za-z][-._:A-Za-z0-9]*$/.test(a)}function pa(a){return oa(a)&&/^[_A-Za-z]([-._A-Za-z0-9])*$/.test(a)}function qa(a){a=a.split(":");return 1===a.length?pa(a[0]):2!==a.length?!1:pa(a[0])&&pa(a[1])}function ra(a){return!/[\u0009\u000A\u000D]/.test(a)}function sa(a){return pa(a)}
8
8
  const ta=new Map([[45,function(){return!0}],[46,function(){return!0}],[1,function(){return!0}],[0,function(a){return/^(0|1|true|false)$/.test(a)}],[6,function(a){return na(a)}],[3,na],[4,function(a){return/^[+-]?\d*(\.\d*)?$/.test(a)}],[18,function(a){return/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.test(a)}],[9,function(a){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(a)}],
9
9
  [8,function(a){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(a)}],[7,function(a){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(a)}],[11,function(a){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(a)}],[12,function(a){return/^-?([1-9][0-9]{3,}|0[0-9]{3})(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(a)}],
10
10
  [13,function(a){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(a)}],[15,function(a){return/^---(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(a)}],[14,function(a){return/^--(0[1-9]|1[0-2])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$/.test(a)}],[22,function(a){return/^([0-9A-Fa-f]{2})*$/.test(a)}],[21,function(a){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(a)}],
11
11
  [20,function(){return!0}],[44,qa],[48,ra],[52,function(a){return ra(a)&&!/^ | {2,}| $/.test(a)}],[51,function(a){return/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/.test(a)}],[50,function(a){return/^[-._:A-Za-z0-9]+$/.test(a)}],[25,oa],[23,qa],[24,pa],[42,sa],[41,sa],[26,function(a){return pa(a)}],[5,function(a){return/^[+-]?\d+$/.test(a)}],[16,function(a){return/^-?P[0-9]+(Y([0-9]+M)?|M)$/.test(a)}],[17,function(a){return/^-?P([0-9]+D)?(T([0-9]+H)?([0-9]+M)?([0-9]+(\.[0-9]+)?S)?)?$/.test(a)}]]);var ua=Object.create(null);
12
- [{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,
13
- 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"}},
14
- {C:0,name:23,parent:46,K:{whiteSpace:"collapse"}},{C:0,name:44,parent:46,K:{whiteSpace:"collapse"}},{C:1,name:10,S:9,K:{whiteSpace:"collapse",Ba:"required"}},{C:1,name:48,S:1,K:{whiteSpace:"replace"}},{C:1,name:52,S:48,K:{whiteSpace:"collapse"}},{C:1,name:51,S:52,K:{whiteSpace:"collapse"}},{C:1,name:50,S:52,K:{whiteSpace:"collapse"}},{C:2,name:49,type:50,K:{minLength:1,whiteSpace:"collapse"}},{C:1,name:25,S:52,K:{whiteSpace:"collapse"}},{C:1,name:24,S:25,K:{whiteSpace:"collapse"}},{C:1,name:42,S:24,
15
- K:{whiteSpace:"collapse"}},{C:1,name:41,S:24,K:{whiteSpace:"collapse"}},{C:2,name:43,type:41,K:{minLength:1,whiteSpace:"collapse"}},{C:1,name:26,S: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,S:5,K:{ka:0,wa:"0",whiteSpace:"collapse"}},{C:1,name:28,S:27,K:{ka:0,wa:"-1",whiteSpace:"collapse"}},{C:1,name:31,S:5,K:{ka:0,wa:"9223372036854775807",xa:"-9223372036854775808",whiteSpace:"collapse"}},
16
- {C:1,name:32,S:31,K:{ka:0,wa:"2147483647",xa:"-2147483648",whiteSpace:"collapse"}},{C:1,name:33,S:32,K:{ka:0,wa:"32767",xa:"-32768",whiteSpace:"collapse"}},{C:1,name:34,S:33,K:{ka:0,wa:"127",xa:"-128",whiteSpace:"collapse"}},{C:1,name:30,S:5,K:{ka:0,xa:"0",whiteSpace:"collapse"}},{C:1,name:36,S:30,K:{ka:0,wa:"18446744073709551615",xa:"0",whiteSpace:"collapse"}},{C:1,name:35,S:36,K:{ka:0,wa:"4294967295",xa:"0",whiteSpace:"collapse"}},{C:1,name:38,S:35,K:{ka:0,wa:"65535",xa:"0",whiteSpace:"collapse"}},
17
- {C:1,name:37,S:38,K:{ka:0,wa:"255",xa:"0",whiteSpace:"collapse"}},{C:1,name:29,S:30,K:{ka:0,xa:"1",whiteSpace:"collapse"}},{C:1,name:16,S:18,K:{whiteSpace:"collapse"}},{C:1,name:17,S:18,K:{whiteSpace:"collapse"}},{C:1,name:60,S:59},{C:3,name:39,Ca:[]},{C:1,name:61,S:60},{C:1,name:62,S:60},{C:0,name:53,parent:59},{C:1,name:54,S:53},{C:1,name:58,S:53},{C:1,name:47,S:53},{C:1,name:56,S:53},{C:1,name:57,S:53},{C:1,name:55,S:53},{C:3,name:2,Ca:[4,5,6,3]},{C:3,name:63,Ca:[]}].forEach(a=>{const b=a.name,
18
- c=a.K||{};switch(a.C){case 0:a=a.parent?ua[a.parent]:null;var d=ta.get(b)||null;ua[b]={C:0,type:b,Ka:c,parent:a,gb:d,Oa:ka(b),Ca:[]};break;case 1:a=ua[a.S];d=ta.get(b)||null;ua[b]={C:1,type:b,Ka:c,parent:a,gb:d,Oa:a.Oa,Ca:[]};break;case 2:ua[b]={C:2,type:b,Ka:c,parent:ua[a.type],gb:null,Oa:la,Ca:[]};break;case 3:a=a.Ca.map(e=>ua[e]),ua[b]={C:3,type:b,Ka:c,parent:null,gb:null,Oa:ma,Ca:a}}});function g(a,b){if(!ua[b])throw Error("Unknown type");return{type:b,value:a}}var va=g(!0,0),wa=g(!1,0);var xa=(a="A wrong argument type was specified in a function call.")=>Error(`FORG0006: ${a}`);var ya=class{constructor(a,b){this.done=a;this.value=b}},p=new ya(!0);function q(a){return new ya(!1,a)};function za(a,b){if(3===b.C)return!!b.Ca.find(c=>za(a,c));for(;a;){if(a.type===b.type)return!0;if(3===a.C)return!!a.Ca.find(c=>v(c.type,b.type));a=a.parent}return!1}function v(a,b){return a===b?!0:za(ua[a],ua[b])};var Aa=class{constructor(a){this.o=w;this.h=a;let b=-1;this.value={next:()=>{b++;return b>=a.length?p:q(a[b])}}}hb(){return this}filter(a){let b=-1;return this.o.create({next:()=>{for(b++;b<this.h.length&&!a(this.h[b],b,this);)b++;return b>=this.h.length?p:q(this.h[b])}})}first(){return this.h[0]}O(){return this.h}fa(){if(v(this.h[0].type,53))return!0;throw xa("Cannot determine the effective boolean value of a sequence with a length higher than one.");}Pa(){return this.h.length}F(){return!1}oa(){return!1}map(a){let b=
19
- -1;return this.o.create({next:()=>++b>=this.h.length?p:q(a(this.h[b],b,this))},this.h.length)}N(a){return a(this.h)}X(a){return a.multiple?a.multiple(this):a.default(this)}};var Ba=class{constructor(){this.value={next:()=>p}}hb(){return this}filter(){return this}first(){return null}O(){return[]}fa(){return!1}Pa(){return 0}F(){return!0}oa(){return!1}map(){return this}N(a){return a([])}X(a){return a.empty?a.empty(this):a.default(this)}};var Ca=class{constructor(a,b){this.type=a;this.value=b}};
12
+ [{C:0,name:59},{C:0,name:46,parent:59,J:{whiteSpace:"preserve"}},{C:0,name:19,parent:46},{C:0,name:1,parent:46},{C:0,name:0,parent:46,J:{whiteSpace:"collapse"}},{C:0,name:4,parent:46,J:{whiteSpace:"collapse"}},{C:0,name:6,parent:46,J:{whiteSpace:"collapse"}},{C:0,name:3,parent:46,J:{whiteSpace:"collapse"}},{C:0,name:18,parent:46,J:{whiteSpace:"collapse"}},{C:0,name:9,parent:46,J:{Ca:"optional",whiteSpace:"collapse"}},{C:0,name:8,parent:46,J:{Ca:"optional",whiteSpace:"collapse"}},{C:0,name:7,parent:46,
13
+ J:{Ca:"optional",whiteSpace:"collapse"}},{C:0,name:11,parent:46,J:{Ca:"optional",whiteSpace:"collapse"}},{C:0,name:12,parent:46,J:{Ca:"optional",whiteSpace:"collapse"}},{C:0,name:13,parent:46,J:{Ca:"optional",whiteSpace:"collapse"}},{C:0,name:15,parent:46,J:{Ca:"optional",whiteSpace:"collapse"}},{C:0,name:14,parent:46,J:{Ca:"optional",whiteSpace:"collapse"}},{C:0,name:22,parent:46,J:{whiteSpace:"collapse"}},{C:0,name:21,parent:46,J:{whiteSpace:"collapse"}},{C:0,name:20,parent:46,J:{whiteSpace:"collapse"}},
14
+ {C:0,name:23,parent:46,J:{whiteSpace:"collapse"}},{C:0,name:44,parent:46,J:{whiteSpace:"collapse"}},{C:1,name:10,R:9,J:{whiteSpace:"collapse",Ca:"required"}},{C:1,name:48,R:1,J:{whiteSpace:"replace"}},{C:1,name:52,R:48,J:{whiteSpace:"collapse"}},{C:1,name:51,R:52,J:{whiteSpace:"collapse"}},{C:1,name:50,R:52,J:{whiteSpace:"collapse"}},{C:2,name:49,type:50,J:{minLength:1,whiteSpace:"collapse"}},{C:1,name:25,R:52,J:{whiteSpace:"collapse"}},{C:1,name:24,R:25,J:{whiteSpace:"collapse"}},{C:1,name:42,R:24,
15
+ J:{whiteSpace:"collapse"}},{C:1,name:41,R:24,J:{whiteSpace:"collapse"}},{C:2,name:43,type:41,J:{minLength:1,whiteSpace:"collapse"}},{C:1,name:26,R:24,J:{whiteSpace:"collapse"}},{C:2,name:40,type:26,J:{minLength:1,whiteSpace:"collapse"}},{C:0,name:5,parent:4,J:{ja:0,whiteSpace:"collapse"}},{C:1,name:27,R:5,J:{ja:0,va:"0",whiteSpace:"collapse"}},{C:1,name:28,R:27,J:{ja:0,va:"-1",whiteSpace:"collapse"}},{C:1,name:31,R:5,J:{ja:0,va:"9223372036854775807",wa:"-9223372036854775808",whiteSpace:"collapse"}},
16
+ {C:1,name:32,R:31,J:{ja:0,va:"2147483647",wa:"-2147483648",whiteSpace:"collapse"}},{C:1,name:33,R:32,J:{ja:0,va:"32767",wa:"-32768",whiteSpace:"collapse"}},{C:1,name:34,R:33,J:{ja:0,va:"127",wa:"-128",whiteSpace:"collapse"}},{C:1,name:30,R:5,J:{ja:0,wa:"0",whiteSpace:"collapse"}},{C:1,name:36,R:30,J:{ja:0,va:"18446744073709551615",wa:"0",whiteSpace:"collapse"}},{C:1,name:35,R:36,J:{ja:0,va:"4294967295",wa:"0",whiteSpace:"collapse"}},{C:1,name:38,R:35,J:{ja:0,va:"65535",wa:"0",whiteSpace:"collapse"}},
17
+ {C:1,name:37,R:38,J:{ja:0,va:"255",wa:"0",whiteSpace:"collapse"}},{C:1,name:29,R:30,J:{ja:0,wa:"1",whiteSpace:"collapse"}},{C:1,name:16,R:18,J:{whiteSpace:"collapse"}},{C:1,name:17,R:18,J:{whiteSpace:"collapse"}},{C:1,name:60,R:59},{C:3,name:39,Da:[]},{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,Da:[4,5,6,3]},{C:3,name:63,Da:[]}].forEach(a=>{const b=a.name,
18
+ c=a.J||{};switch(a.C){case 0:a=a.parent?ua[a.parent]:null;var d=ta.get(b)||null;ua[b]={C:0,type:b,La:c,parent:a,gb:d,Qa:ka(b),Da:[]};break;case 1:a=ua[a.R];d=ta.get(b)||null;ua[b]={C:1,type:b,La:c,parent:a,gb:d,Qa:a.Qa,Da:[]};break;case 2:ua[b]={C:2,type:b,La:c,parent:ua[a.type],gb:null,Qa:la,Da:[]};break;case 3:a=a.Da.map(e=>ua[e]),ua[b]={C:3,type:b,La:c,parent:null,gb:null,Qa:ma,Da:a}}});function g(a,b){if(!ua[b])throw Error("Unknown type");return{type:b,value:a}}var va=g(!0,0),wa=g(!1,0);var xa=(a="A wrong argument type was specified in a function call.")=>Error(`FORG0006: ${a}`);var ya=class{constructor(a,b){this.done=a;this.value=b}},p=new ya(!0);function q(a){return new ya(!1,a)};function za(a,b){if(3===b.C)return!!b.Da.find(c=>za(a,c));for(;a;){if(a.type===b.type)return!0;if(3===a.C)return!!a.Da.find(c=>v(c.type,b.type));a=a.parent}return!1}function v(a,b){return a===b?!0:za(ua[a],ua[b])};var Aa=class{constructor(a){this.o=w;this.h=a;let b=-1;this.value={next:()=>{b++;return b>=a.length?p:q(a[b])}}}hb(){return this}filter(a){let b=-1;return this.o.create({next:()=>{for(b++;b<this.h.length&&!a(this.h[b],b,this);)b++;return b>=this.h.length?p:q(this.h[b])}})}first(){return this.h[0]}N(){return this.h}ea(){if(v(this.h[0].type,53))return!0;throw xa("Cannot determine the effective boolean value of a sequence with a length higher than one.");}Ra(){return this.h.length}isEmpty(){return!1}oa(){return!1}map(a){let b=
19
+ -1;return this.o.create({next:()=>++b>=this.h.length?p:q(a(this.h[b],b,this))},this.h.length)}M(a){return a(this.h)}X(a){return a.multiple?a.multiple(this):a.default(this)}};var Ba=class{constructor(){this.value={next:()=>p}}hb(){return this}filter(){return this}first(){return null}N(){return[]}ea(){return!1}Ra(){return 0}isEmpty(){return!0}oa(){return!1}map(){return this}M(a){return a([])}X(a){return a.empty?a.empty(this):a.default(this)}};var Ca=class{constructor(a,b){this.type=a;this.value=b}};
20
20
  const Da={[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",
21
21
  [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",
22
22
  [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"},Ea={"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,
@@ -24,144 +24,147 @@ const Da={[0]:"xs:boolean",[1]:"xs:string",[2]:"xs:numeric",[3]:"xs:double",[4]:
24
24
  "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 Ha(a){return 2===a.g?Da[a.type]+"*":1===a.g?Da[a.type]+"+":0===a.g?Da[a.type]+"?":Da[a.type]}
25
25
  function Ia(a){if("none"===a)throw Error('XPST0051: The type "none" could not be found');if(!a.startsWith("xs:")&&0<=a.indexOf(":"))throw Error(`XPST0081: Invalid prefix for input ${a}`);const b=Ea[a];if(void 0===b)throw Error(`XPST0051: The type "${a}" could not be found`);return b}
26
26
  function Ja(a){switch(a[a.length-1]){case "*":return{type:Ia(a.substr(0,a.length-1)),g:2};case "?":return{type:Ia(a.substr(0,a.length-1)),g:0};case "+":return{type:Ia(a.substr(0,a.length-1)),g:1};default:return{type:Ia(a),g:3}}}function Ka(a){switch(a){case "*":return 2;case "?":return 0;case "+":return 1;default:return 3}};function La(a){const b=a.value;if(v(a.type,53))return!0;if(v(a.type,0))return b;if(v(a.type,1)||v(a.type,20)||v(a.type,19))return 0!==b.length;if(v(a.type,2))return!isNaN(b)&&0!==b;throw xa(`Cannot determine the effective boolean value of a value with the type ${Da[a.type]}`);};function Ma(a,b=0){a.h=b}
27
- var Na=class{constructor(a,b=null){this.D=w;this.value={next:c=>{if(null!==this.o&&this.h>=this.o)return p;if(void 0!==this.v[this.h])return q(this.v[this.h++]);c=a.next(c);if(c.done)return this.o=this.h,c;if(this.l||2>this.h)this.v[this.h]=c.value;this.h++;return c}};this.l=!1;this.v=[];this.h=0;this.o=b}hb(){return this.D.create(this.O())}filter(a){let b=-1;const c=this.value;return this.D.create({next:d=>{b++;for(d=c.next(d);!d.done&&!a(d.value,b,this);)b++,d=c.next(0);return d}})}first(){if(void 0!==
28
- this.v[0])return this.v[0];const a=this.value.next(0);Ma(this);return a.done?null:a.value}O(){if(this.h>this.v.length&&this.o!==this.v.length)throw Error("Implementation error: Sequence Iterator has progressed.");const a=this.value;this.l=!0;let b=a.next(0);for(;!b.done;)b=a.next(0);return this.v}fa(){const a=this.value,b=this.h;Ma(this);var c=a.next(0);if(c.done)return Ma(this,b),!1;c=c.value;if(v(c.type,53))return Ma(this,b),!0;if(!a.next(0).done)throw xa("Cannot determine the effective boolean value of a sequence with a length higher than one.");
29
- Ma(this,b);return La(c)}Pa(a=!1){if(null!==this.o)return this.o;if(a)return-1;a=this.h;const b=this.O().length;Ma(this,a);return b}F(){return 0===this.o?!0:null===this.first()}oa(){if(null!==this.o)return 1===this.o;var a=this.value;const b=this.h;Ma(this);if(a.next(0).done)return Ma(this,b),!1;a=a.next(0);Ma(this,b);return a.done}map(a){let b=0;const c=this.value;return this.D.create({next:d=>{d=c.next(d);return d.done?p:q(a(d.value,b++,this))}},this.o)}N(a,b){const c=this.value;let d;const e=[];
30
- let f=!0;(function(){for(let h=c.next(f?0:b);!h.done;h=c.next(b))f=!1,e.push(h.value);d=a(e).value})();return this.D.create({next:()=>d.next(0)})}X(a){let b=null;const c=d=>{b=d.value;d=d.Pa(!0);-1!==d&&(this.o=d)};return this.D.create({next:d=>{if(b)return b.next(d);if(this.F())return c(a.empty?a.empty(this):a.default(this)),b.next(d);if(this.oa())return c(a.m?a.m(this):a.default(this)),b.next(d);c(a.multiple?a.multiple(this):a.default(this));return b.next(d)}})}};var Oa=class{constructor(a){this.v=w;this.h=a;let b=!1;this.value={next:()=>{if(b)return p;b=!0;return q(a)}};this.o=null}hb(){return this}filter(a){return a(this.h,0,this)?this:this.v.create()}first(){return this.h}O(){return[this.h]}fa(){null===this.o&&(this.o=La(this.h));return this.o}Pa(){return 1}F(){return!1}oa(){return!0}map(a){return this.v.create(a(this.h,0,this))}N(a){return a([this.h])}X(a){return a.m?a.m(this):a.default(this)}};const Pa=new Ba;function Qa(a=null,b=null){if(null===a)return Pa;if(Array.isArray(a))switch(a.length){case 0:return Pa;case 1:return new Oa(a[0]);default:return new Aa(a)}return a.next?new Na(a,b):new Oa(a)}var w={create:Qa,m:a=>new Oa(a),empty:()=>Qa(),aa:()=>Qa(va),T:()=>Qa(wa)};function Ra(a){const b=[],c=a.value;return()=>{let d=0;return w.create({next:()=>{if(void 0!==b[d])return b[d++];const e=c.next(0);return e.done?e:b[d++]=e}})}};var Sa=class{constructor(a,b,c){this.namespaceURI=b||null;this.prefix=a||"";this.localName=c}za(){return this.prefix?this.prefix+":"+this.localName:this.localName}};function Ta(a,b){const c=a.value,d=b.map(e=>null===e?null:Ra(e));b=b.reduce((e,f,h)=>{null===f&&e.push(a.o[h]);return e},[]);b=new Va({j:b,arity:b.length,Ya:!0,I:a.I,localName:"boundFunction",namespaceURI:a.l,i:a.s,value:function(e,f,h){const k=Array.from(arguments).slice(3),l=d.map(n=>null===n?k.shift():n());return c.apply(void 0,[e,f,h].concat(l))}});return w.m(b)}
31
- var Va=class extends Ca{constructor({j:a,arity:b,Ya:c=!1,I:d=!1,localName:e,namespaceURI:f,i:h,value:k}){super(60,null);this.value=k;this.I=d;d=-1;for(k=0;k<a.length;k++)4===a[k]&&(d=k);-1<d&&(k=Array(b-(a.length-1)).fill(a[d-1]),a=a.slice(0,d).concat(k));this.o=a;this.v=b;this.ia=c;this.D=e;this.l=f;this.s=h}Ya(){return this.ia}};function Wa(a,b){const c=[];2!==a&&1!==a||c.push("type-1-or-type-2");c.push(`type-${a}`);b&&c.push(`name-${b}`);return c}function Xa(a){const b=a.node.nodeType;let c;if(2===b||1===b)c=a.node.localName;return Wa(b,c)}function Ya(a){let b=a.nodeType;4===b&&(b=3);let c;if(2===b||1===b)c=a.localName;return Wa(b,c)};var Za=class{getAllAttributes(a,b=null){if(1!==a.nodeType)return[];a=Array.from(a.attributes);return null===b?a:a.filter(c=>Ya(c).includes(b))}getAttribute(a,b){return 1!==a.nodeType?null:a.getAttribute(b)}getChildNodes(a,b=null){a=Array.from(a.childNodes);return null===b?a:a.filter(c=>Ya(c).includes(b))}getData(a){return 2===a.nodeType?a.value:a.data}getFirstChild(a,b=null){for(a=a.firstChild;a;a=a.nextSibling)if(null===b||Ya(a).includes(b))return a;return null}getLastChild(a,b=null){for(a=a.lastChild;a;a=
32
- a.previousSibling)if(null===b||Ya(a).includes(b))return a;return null}getNextSibling(a,b=null){for(a=a.nextSibling;a;a=a.nextSibling)if(null===b||Ya(a).includes(b))return a;return null}getParentNode(a,b=null){return(a=2===a.nodeType?a.ownerElement:a.parentNode)?null===b||Ya(a).includes(b)?a:null:null}getPreviousSibling(a,b=null){for(a=a.previousSibling;a;a=a.previousSibling)if(null===b||Ya(a).includes(b))return a;return null}};class $a{insertBefore(a,b,c){return a.insertBefore(b,c)}removeAttributeNS(a,b,c){return a.removeAttributeNS(b,c)}removeChild(a,b){return a.removeChild(b)}setAttributeNS(a,b,c,d){a.setAttributeNS(b,c,d)}setData(a,b){a.data=b}}var ab=new $a;class bb{constructor(a){this.h=a}insertBefore(a,b,c){return this.h.insertBefore(a,b,c)}removeAttributeNS(a,b,c){return this.h.removeAttributeNS(a,b,c)}removeChild(a,b){return this.h.removeChild(a,b)}setAttributeNS(a,b,c,d){this.h.setAttributeNS(a,b,c,d)}setData(a,b){this.h.setData(a,b)}};function cb(a){return void 0!==a.Ra};function db(a,b,c){let d=null;b&&(cb(b.node)?d={G:b.G,offset:c,parent:b.node}:b.G&&(d=b.G));return{node:a,G:d}}function eb(a,b,c=null){return a.getAllAttributes(b.node,c).map(d=>db(d,b,d.nodeName))}function fb(a,b,c){b=b.node;return cb(b)?(a=b.attributes.find(d=>c===d.name))?a.value:null:(a=a.h.getAttribute(b,c))?a:null}function gb(a,b,c=null){return a.getChildNodes(b.node,c).map((d,e)=>db(d,b,e))}function hb(a,b){return a.getData(b.node)}
33
- function ib(a,b,c=null){const d=b.node;cb(d)?a=d.childNodes[0]:((c=a.h.getFirstChild(d,c))&&10===c.nodeType&&(c=a.h.getNextSibling(c)),a=c);return a?db(a,b,0):null}function kb(a,b,c=null){var d=b.node;cb(d)?(a=d.childNodes.length-1,d=d.childNodes[a]):((d=a.h.getLastChild(d,c))&&10===d.nodeType&&(d=a.h.getPreviousSibling(d)),a=a.getChildNodes(b.node,c).length-1);return d?db(d,b,a):null}
34
- function x(a,b,c=null){const d=b.node,e=b.G;if(e)"number"===typeof e.offset&&d===e.parent.childNodes[e.offset]||"string"===typeof e.offset&&d===e.parent.attributes.find(f=>e.offset===f.nodeName)?(a=e.parent,b=e.G):(a=a.getParentNode(d,c),b=e);else{if(cb(d))return null;a=a.getParentNode(d,c);b=null}return a?{node:a,G:b}:null}
35
- function lb(a,b,c=null){const d=b.node;let e,f,h;const k=b.G;if(cb(d))k&&(h=k.offset+1,e=k.parent.childNodes[h]);else if(k)h=k.offset+1,f=x(a,b,null),e=a.getChildNodes(f.node,c)[h];else{for(e=d;e&&(!(e=a.h.getNextSibling(e,c))||10===e.nodeType););return e?{node:e,G:null}:null}return e?db(e,f||x(a,b,c),h):null}
36
- function mb(a,b,c=null){const d=b.node;let e,f;const h=b.G;let k;if(cb(d))h&&(k=h.offset-1,e=h.parent.childNodes[k]);else if(h)k=h.offset-1,f=x(a,b,null),e=a.getChildNodes(f.node,c)[k];else{for(e=d;e&&(!(e=a.h.getPreviousSibling(e,c))||10===e.nodeType););return e?{node:e,G:null}:null}return e?db(e,f||x(a,b,c),k):null}
37
- var nb=class{constructor(a){this.h=a;this.o=[]}getAllAttributes(a,b=null){return cb(a)?a.attributes:this.h.getAllAttributes(a,b)}getChildNodes(a,b=null){b=cb(a)?a.childNodes:this.h.getChildNodes(a,b);return 9===a.nodeType?b.filter(c=>10!==c.nodeType):b}getData(a){return cb(a)?2===a.nodeType?a.value:a.data:this.h.getData(a)||""}getParentNode(a,b=null){return this.h.getParentNode(a,b)}};var ob=(a,b,c,d,e)=>e.N(([f])=>d.N(([h])=>{const k=f.value;if(0>=k||k>h.h.length)throw Error("FOAY0001: array position out of bounds.");return h.h[k-1]()}));var pb=class extends Va{constructor(a){super({value:(b,c,d,e)=>ob(b,c,d,w.m(this),e),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=a}};function qb(a){switch(a.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 rb(a){return{type:qb(a),value:a}};function A(a,b){a=a.map(c=>c.first());return b(a)};function sb(a,b){var c=v(a.type,1)||v(a.type,20)||v(a.type,19),d=v(b.type,1)||v(b.type,20)||v(b.type,19);if(c&&d)return a.value===b.value;c=v(a.type,4)||v(a.type,3)||v(a.type,6);d=v(b.type,4)||v(b.type,3)||v(b.type,6);if(c&&d)return isNaN(a.value)&&isNaN(b.value)?!0:a.value===b.value;c=v(a.type,0)||v(a.type,22)||v(a.type,18)||v(a.type,23)||v(a.type,44);d=v(b.type,0)||v(b.type,22)||v(b.type,18)||v(b.type,23)||v(b.type,44);return c&&d?a.value===b.value:!1};var tb=(a,b,c,d,e)=>A([d,e],([f,h])=>(f=f.h.find(k=>sb(k.key,h)))?f.value():w.empty());var ub=class extends Va{constructor(a){super({j:[{type:59,g:3}],arity:1,localName:"get",namespaceURI:"http://www.w3.org/2005/xpath-functions/map",value:(b,c,d,e)=>tb(b,c,d,w.m(this),e),i:{type:59,g:2}});this.type=61;this.h=a}};function vb(a,b){return a.h()===b.h()&&a.o()===b.o()}var wb=class{$a(){return 0}getHours(){return 0}getMinutes(){return 0}ab(){return 0}h(){return 0}o(){return 0}getSeconds(){return 0}bb(){return 0}na(){return!0}};function xb(a){var b=Math.abs(a.$a()),c=Math.abs(a.getHours());const d=Math.abs(a.getMinutes());a=Math.abs(a.getSeconds());b=`${b?`${b}D`:""}`;c=(c?`${c}H`:"")+(d?`${d}M`:"")+(a?`${a}S`:"");return b&&c?`${b}T${c}`:b?b:c?`T${c}`:"T0S"}
38
- var yb=class extends wb{constructor(a){super();if(a>Number.MAX_SAFE_INTEGER||a<Number.MIN_SAFE_INTEGER)throw Error("FODT0002: Number of seconds given to construct DayTimeDuration overflows MAX_SAFE_INTEGER or MIN_SAFE_INTEGER");this.ca=a}$a(){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 a=this.ca%60;return Object.is(-0,a)?0:a}na(){return Object.is(-0,this.ca)?!1:0<=this.ca}toString(){return(this.na()?
39
- "P":"-P")+xb(this)}},zb=(a,b,c,d,e,f)=>{a=86400*a+3600*b+60*c+d+e;return new yb(f||0===a?a:-a)},Ab=a=>(a=/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(?:T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.exec(a))?zb(a[4]?parseInt(a[4],10):0,a[5]?parseInt(a[5],10):0,a[6]?parseInt(a[6],10):0,a[7]?parseInt(a[7],10):0,a[8]?parseFloat(a[8]):0,!a[1]):null,Bb=a=>{a=/^(Z)|([+-])([01]\d):([0-5]\d)$/.exec(a);return"Z"===a[1]?zb(0,0,0,0,0,!0):zb(0,a[3]?parseInt(a[3],10):0,a[4]?parseInt(a[4],10):0,0,0,"+"===a[2])};
40
- function Cb(a,b){if(isNaN(b))throw Error("FOCA0005: Cannot multiply xs:dayTimeDuration by NaN");a=a.ca*b;if(a>Number.MAX_SAFE_INTEGER||!Number.isFinite(a))throw Error("FODT0002: Value overflow while multiplying xs:dayTimeDuration");return new yb(a<Number.MIN_SAFE_INTEGER||Object.is(-0,a)?0:a)};function Db(a){return a?parseInt(a,10):null}function Eb(a){a+="";const b=a.startsWith("-");b&&(a=a.substring(1));return(b?"-":"")+a.padStart(4,"0")}function Fb(a){return(a+"").padStart(2,"0")}function Hb(a){a+="";1===a.split(".")[0].length&&(a=a.padStart(a.length+1,"0"));return a}function Ib(a){return 0===a.getHours()&&0===a.getMinutes()?"Z":(a.na()?"+":"-")+Fb(Math.abs(a.getHours()))+":"+Fb(Math.abs(a.getMinutes()))}
41
- function Jb(a){var b=/^(?:(-?\d{4,}))?(?:--?(\d\d))?(?:-{1,3}(\d\d))?(T)?(?:(\d\d):(\d\d):(\d\d))?(\.\d+)?(Z|(?:[+-]\d\d:\d\d))?$/.exec(a);a=b[1]?parseInt(b[1],10):null;const c=Db(b[2]),d=Db(b[3]),e=b[4],f=Db(b[5]),h=Db(b[6]),k=Db(b[7]),l=b[8]?parseFloat(b[8]):0;b=b[9]?Bb(b[9]):null;if(a&&(-271821>a||273860<a))throw Error("FODT0001: Datetime year is out of bounds");return e?new Kb(a,c,d,f,h,k,l,b,9):null!==f&&null!==h&&null!==k?new Kb(1972,12,31,f,h,k,l,b,8):null!==a&&null!==c&&null!==d?new Kb(a,
42
- c,d,0,0,0,0,b,7):null!==a&&null!==c?new Kb(a,c,1,0,0,0,0,b,11):null!==c&&null!==d?new Kb(1972,c,d,0,0,0,0,b,13):null!==a?new Kb(a,1,1,0,0,0,0,b,12):null!==c?new Kb(1972,c,1,0,0,0,0,b,14):new Kb(1972,12,d,0,0,0,0,b,15)}
43
- function Lb(a,b){switch(b){case 15:return new Kb(1972,12,a.o,0,0,0,0,a.Y,15);case 14:return new Kb(1972,a.h,1,0,0,0,0,a.Y,14);case 12:return new Kb(a.v,1,1,0,0,0,0,a.Y,12);case 13:return new Kb(1972,a.h,a.o,0,0,0,0,a.Y,13);case 11:return new Kb(a.v,a.h,1,0,0,0,0,a.Y,11);case 8:return new Kb(1972,12,31,a.l,a.s,a.D,a.qa,a.Y,8);case 7:return new Kb(a.v,a.h,a.o,0,0,0,0,a.Y,7);default:return new Kb(a.v,a.h,a.o,a.l,a.s,a.D,a.qa,a.Y,9)}}
44
- function Mb(a,b){b=a.Y||b||Bb("Z");return new Date(Date.UTC(a.v,a.h-1,a.o,a.l-b.getHours(),a.s-b.getMinutes(),a.D,1E3*a.qa))}
45
- var Kb=class{constructor(a,b,c,d,e,f,h,k,l=9){this.v=a;this.h=b;this.o=c+(24===d?1:0);this.l=24===d?0:d;this.s=e;this.D=f;this.qa=h;this.Y=k;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 Eb(this.v)+"-"+Fb(this.h)+"-"+Fb(this.o)+"T"+Fb(this.l)+":"+Fb(this.s)+":"+Hb(this.D+this.qa)+(this.Y?Ib(this.Y):"");case 7:return Eb(this.v)+"-"+Fb(this.h)+
46
- "-"+Fb(this.o)+(this.Y?Ib(this.Y):"");case 8:return Fb(this.l)+":"+Fb(this.s)+":"+Hb(this.D+this.qa)+(this.Y?Ib(this.Y):"");case 15:return"---"+Fb(this.o)+(this.Y?Ib(this.Y):"");case 14:return"--"+Fb(this.h)+(this.Y?Ib(this.Y):"");case 13:return"--"+Fb(this.h)+"-"+Fb(this.o)+(this.Y?Ib(this.Y):"");case 12:return Eb(this.v)+(this.Y?Ib(this.Y):"");case 11:return Eb(this.v)+"-"+Fb(this.h)+(this.Y?Ib(this.Y):"")}throw Error("Unexpected subType");}};
47
- function Nb(a,b,c){const d=Mb(a,c).getTime();c=Mb(b,c).getTime();return d===c?a.qa===b.qa?0:a.qa>b.qa?1:-1:d>c?1:-1}function Ob(a,b,c){return 0===Nb(a,b,c)}function Pb(a,b,c){a=(Mb(a,c).getTime()-Mb(b,c).getTime())/1E3;return new yb(a)}function Qb(a){throw Error(`Not implemented: adding durations to ${Da[a.type]}`);}function Rb(a){throw Error(`Not implemented: subtracting durations from ${Da[a.type]}`);};function Sb(a,b){if(null===a)return null;switch(typeof a){case "boolean":return a?va:wa;case "number":return g(a,3);case "string":return g(a,1);case "object":if("nodeType"in a)return rb({node:a,G:null});if(Array.isArray(a))return new pb(a.map(c=>{if(void 0===c)return()=>w.empty();c=Sb(c,b);c=null===c?w.empty():w.m(c);return Ra(c)}));if(a instanceof Date){const c=Jb(a.toISOString());return g(c,c.type)}return new ub(Object.keys(a).filter(c=>void 0!==a[c]).map(c=>{var d=Sb(a[c],b);d=null===d?w.empty():
48
- w.m(d);return{key:g(c,1),value:Ra(d)}}))}throw Error(`Value ${String(a)} of type "${typeof a}" is not adaptable to an XPath value.`);}function Tb(a,b){if("number"!==typeof a&&("string"!==typeof a||!ta.get(b)(a)))throw Error(`Cannot convert JavaScript value '${a}' to the XPath type ${Da[b]} since it is not valid.`);}
49
- function Ub(a,b,c){if(null===b)return null;switch(a){case 0:return b?va:wa;case 1:return g(b+"",1);case 3:case 2:return Tb(b,3),g(+b,3);case 4:return Tb(b,a),g(+b,4);case 5:return Tb(b,a),g(b|0,5);case 6:return Tb(b,a),g(+b,6);case 7:case 8:case 9:case 11:case 12:case 13:case 14:case 15:if(!(b instanceof Date))throw Error(`The JavaScript value ${b} with type ${typeof b} is not a valid type to be converted to an XPath ${Da[a]}.`);return g(Lb(Jb(b.toISOString()),a),a);case 53:case 47:case 55:case 54:case 56:case 57:case 58:if("object"!==
50
- typeof b||!("nodeType"in b))throw Error(`The JavaScript value ${b} with type ${typeof b} is not a valid type to be converted to an XPath ${Da[a]}.`);return rb({node:b,G:null});case 59:return Sb(b,c);case 61:return Sb(b,c);default:throw Error(`Values of the type "${Da[a]}" can not be adapted from JavaScript to equivalent XPath values.`);}}
51
- function Vb(a,b,c){if(0===c.g)return b=Ub(c.type,b,a),null===b?[]:[b];if(2===c.g||1===c.g){if(!Array.isArray(b))throw Error(`The JavaScript value ${b} should be an array if it is to be converted to ${Ha(c)}.`);return b.map(e=>Ub(c.type,e,a)).filter(e=>null!==e)}const d=Ub(c.type,b,a);if(null===d)throw Error(`The JavaScript value ${b} should be a single entry if it is to be converted to ${Ha(c)}.`);return[d]}function Wb(a,b,c={type:59,g:0}){return w.create(Vb(a,b,c))};var ac=class{constructor(){this.h=Math.abs(Math.floor(Math.random()*$b)%$b)}},$b=2**32;function bc(a,b,c,d){return new cc({M:c,Aa:b,ta:d||a.ta,ra:a.ra},a.h,a.o)}function dc(a,b){let c=0;const d=b.value;return{next:e=>{e=d.next(e);return e.done?p:q(bc(a,c++,e.value,b))}}}function ec(a){a.h.ib||(a.h.ib=!0,a.h.qb=Jb((new Date).toISOString()),a.h.vb=Ab("PT0S"));return a.h.qb}function fc(a){a.h.ib||(a.h.ib=!0,a.h.qb=Jb((new Date).toISOString()),a.h.vb=Ab("PT0S"));return a.h.vb}function gc(a,b=null){a=29421*(null!==b&&void 0!==b?b:a.o.h)%$b;return{rb:Math.floor(a),$b:a/$b}}
52
- function hc(a,b){return new cc({M:a.M,Aa:a.Aa,ta:a.ta,ra:Object.assign(Object.create(null),a.ra,b)},a.h,a.o)}var cc=class{constructor(a,b={qb:null,vb:null,ib:!1},c=new ac){this.h=b;this.Aa=a.Aa;this.ta=a.ta;this.M=a.M;this.ra=a.ra||Object.create(null);this.o=c}};var ic=class{constructor(a,b,c,d,e,f,h,k,l){this.debug=a;this.Ha=b;this.h=c;this.Ja=d;this.Ma=e;this.o=f;this.v=h;this.jb=k;this.Ua=l}};function jc(a){let b=0,c=null,d=!0;return w.create({next:e=>{for(;b<a.length;){c||(c=a[b].value,d=!0);const f=c.next(d?0:e);d=!1;if(f.done)b++,c=null;else return f}return p}})};var kc=(a,b,c)=>Error(`FORG0001: Cannot cast ${a} to ${Da[b]}${c?`, ${c}`:""}`),lc=a=>Error(`XPDY0002: ${a}`),mc=a=>Error(`XPTY0004: ${a}`),nc=a=>Error(`FOTY0013: Atomization is not supported for ${Da[a]}.`),oc=a=>Error(`XPST0081: The prefix ${a} could not be resolved.`);function pc(a,b){if(v(a.type,46)||v(a.type,19)||v(a.type,0)||v(a.type,4)||v(a.type,3)||v(a.type,6)||v(a.type,5)||v(a.type,2)||v(a.type,23)||v(a.type,1))return w.create(a);const c=b.h;if(v(a.type,53)){const d=a.value;if(2===d.node.nodeType||3===d.node.nodeType)return w.create(g(hb(c,d),19));if(8===d.node.nodeType||7===d.node.nodeType)return w.create(g(hb(c,d),1));const e=[];(function k(h){if(8!==d.node.nodeType&&7!==d.node.nodeType){var l=h.nodeType;3===l||4===l?e.push(c.getData(h)):1!==l&&9!==l&&
53
- 11!==l||c.getChildNodes(h).forEach(n=>{k(n)})}})(d.node);return w.create(g(e.join(""),19))}if(v(a.type,60)&&!v(a.type,62))throw nc(a.type);if(v(a.type,62))return jc(a.h.map(d=>qc(d(),b)));throw Error(`Atomizing ${a.type} is not implemented.`);}function qc(a,b){let c=!1;const d=a.value;let e=null;return w.create({next:()=>{for(;!c;){if(!e){var f=d.next(0);if(f.done){c=!0;break}e=pc(f.value,b).value}f=e.next(0);if(f.done)e=null;else return f}return p}})};function rc(a){for(a=ua[a];a&&0!==a.C;)a=a.parent;return a?a.type:null}function sc(a,b){b=ua[b];const c=b.Ka;if(!c||!c.whiteSpace)return b.parent?sc(a,b.parent.type):a;switch(b.Ka.whiteSpace){case "replace":return a.replace(/[\u0009\u000A\u000D]/g," ");case "collapse":return a.replace(/[\u0009\u000A\u000D]/g," ").replace(/ {2,}/g," ").replace(/^ | $/g,"")}return a}function tc(a,b){for(b=ua[b];b&&null===b.gb;){if(2===b.C||3===b.C)return!0;b=b.parent}return b?b.gb(a):!0}
54
- function uc(a,b){for(;a;){if(a.Oa&&a.Oa[b])return a.Oa[b];a=a.parent}return()=>!0}function vc(a,b){let c=ua[b];for(;c;){if(c.Ka&&!Object.keys(c.Ka).every(d=>{if("whiteSpace"===d)return!0;const e=uc(c,d);return e?e(a,c.Ka[d]):!0}))return!1;c=c.parent}return!0}function wc(a){return a?2===a.g||0===a.g:!0};function xc(a){return a(1)||a(19)?b=>({u:!0,value:g(b,20)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:anyURI or any of its derived types.")})};function yc(a){return a(22)?b=>{let c="";for(let d=0;d<b.length;d+=2)c+=String.fromCharCode(parseInt(b.substr(d,2),16));return{u:!0,value:g(btoa(c),21)}}:a(1)||a(19)?b=>({u:!0,value:g(b,21)}):()=>({error:Error("XPTY0004: Casting not supported from given type to xs:base64Binary or any of its derived types."),u:!1})};function zc(a){return a(2)?b=>({u:!0,value:0===b||isNaN(b)?wa:va}):a(1)||a(19)?b=>{switch(b){case "true":case "1":return{u:!0,value:va};case "false":case "0":return{u:!0,value:wa};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.")})};function Dc(a){return a(9)?b=>({u:!0,value:g(Lb(b,7),7)}):a(19)||a(1)?b=>({u:!0,value:g(Jb(b),7)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:date or any of its derived types.")})};function Ec(a){return a(7)?b=>({u:!0,value:g(Lb(b,9),9)}):a(19)||a(1)?b=>({u:!0,value:g(Jb(b),9)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:dateTime or any of its derived types.")})};function Fc(a){return a(18)&&!a(16)?b=>({u:!0,value:g(b.Ga,17)}):a(16)?()=>({u:!0,value:g(Ab("PT0.0S"),17)}):a(19)||a(1)?b=>{const c=Ab(b);return c?{u:!0,value:g(c,17)}:{u:!1,error:Error(`FORG0001: Can not cast ${b} to xs:dayTimeDuration`)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:dayTimeDuration or any of its derived types.")})};function Gc(a){return a(5)?b=>({u:!0,value:g(b,4)}):a(6)||a(3)?b=>isNaN(b)||!isFinite(b)?{u:!1,error:Error(`FOCA0002: Can not cast ${b} to xs:decimal`)}:Math.abs(b)>Number.MAX_VALUE?{u:!1,error:Error(`FOAR0002: Can not cast ${b} to xs:decimal, it is out of bounds for JavaScript numbers`)}:{u:!0,value:g(b,4)}:a(0)?b=>({u:!0,value:g(b?1:0,4)}):a(1)||a(19)?b=>{const c=parseFloat(b);return!isNaN(c)||isFinite(c)?{u:!0,value:g(c,4)}:{u:!1,error:Error(`FORG0001: Can not cast ${b} to xs:decimal`)}}:()=>({u:!1,
55
- error:Error("XPTY0004: Casting not supported from given type to xs:decimal or any of its derived types.")})};function Hc(a,b){return a(2)?c=>({u:!0,value:c}):a(0)?c=>({u:!0,value:c?1:0}):a(1)||a(19)?c=>{switch(c){case "NaN":return{u:!0,value:NaN};case "INF":case "+INF":return{u:!0,value:Infinity};case "-INF":return{u:!0,value:-Infinity};case "0":case "+0":return{u:!0,value:0};case "-0":return{u:!0,value:-0}}const d=parseFloat(c);return isNaN(d)?{u:!1,error:kc(c,b)}:{u:!0,value:d}}:()=>({u:!1,error:Error(`XPTY0004: Casting not supported from given type to ${b} or any of its derived types.`)})};function Ic(a){const b=Hc(a,3);return c=>{c=b(c);return c.u?{u:!0,value:g(c.value,3)}:c}};function Jc(a){const b=Math.abs(a.bb());a=Math.abs(a.ab());return`${b?`${b}Y`:""}`+`${a?`${a}M`:""}`||"0M"}
56
- var Kc=class extends wb{constructor(a){super();if(a>Number.MAX_SAFE_INTEGER||a<Number.MIN_SAFE_INTEGER)throw Error("FODT0002: Number of months given to construct YearMonthDuration overflows MAX_SAFE_INTEGER or MIN_SAFE_INTEGER");this.ea=a}ab(){const a=this.ea%12;return 0===a?0:a}h(){return this.ea}bb(){return Math.trunc(this.ea/12)}na(){return Object.is(-0,this.ea)?!1:0<=this.ea}toString(){return(this.na()?"P":"-P")+Jc(this)}},Lc=a=>{var b=/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(?:T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.exec(a);
57
- if(b){a=!b[1];b=12*(b[2]?parseInt(b[2],10):0)+(b[3]?parseInt(b[3],10):0);if(b>Number.MAX_SAFE_INTEGER||!Number.isFinite(b))throw Error("FODT0002: Value overflow while constructing xs:yearMonthDuration");a=new Kc(a||0===b?b:-b)}else a=null;return a};
58
- function Mc(a,b){if(isNaN(b))throw Error("FOCA0005: Cannot multiply xs:yearMonthDuration by NaN");a=Math.round(a.ea*b);if(a>Number.MAX_SAFE_INTEGER||!Number.isFinite(a))throw Error("FODT0002: Value overflow while constructing xs:yearMonthDuration");return new Kc(a<Number.MIN_SAFE_INTEGER||0===a?0:a)};var Nc=class extends wb{constructor(a,b){super();this.Va=a;this.Ga=b}$a(){return this.Ga.$a()}getHours(){return this.Ga.getHours()}getMinutes(){return this.Ga.getMinutes()}ab(){return this.Va.ab()}h(){return this.Va.h()}o(){return this.Ga.o()}getSeconds(){return this.Ga.getSeconds()}bb(){return this.Va.bb()}na(){return this.Va.na()&&this.Ga.na()}toString(){const a=this.na()?"P":"-P",b=Jc(this.Va),c=xb(this.Ga);return"0M"===b?a+c:"T0S"===c?a+b:a+b+c}};function Oc(a){return a(16)?b=>({u:!0,value:g(new Nc(b,new yb(b.na()?0:-0)),18)}):a(17)?b=>{b=new Nc(new Kc(b.na()?0:-0),b);return{u:!0,value:g(b,18)}}:a(18)?b=>({u:!0,value:g(b,18)}):a(19)||a(1)?b=>{var c;return c=new Nc(Lc(b),Ab(b)),{u:!0,value:g(c,18)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:duration or any of its derived types.")})};function Pc(a){const b=Hc(a,6);return c=>{c=b(c);return c.u?{u:!0,value:g(c.value,6)}:c}};function Qc(a){return a(7)||a(9)?b=>({u:!0,value:g(Lb(b,15),15)}):a(19)||a(1)?b=>({u:!0,value:g(Jb(b),15)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gDay or any of its derived types.")})};function Rc(a){return a(7)||a(9)?b=>({u:!0,value:g(Lb(b,14),14)}):a(19)||a(1)?b=>({u:!0,value:g(Jb(b),14)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gMonth or any of its derived types.")})};function Sc(a){return a(7)||a(9)?b=>({u:!0,value:g(Lb(b,13),13)}):a(19)||a(1)?b=>({u:!0,value:g(Jb(b),13)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gMonthDay or any of its derived types.")})};function Tc(a){return a(7)||a(9)?b=>({u:!0,value:g(Lb(b,12),12)}):a(19)||a(1)?b=>({u:!0,value:g(Jb(b),12)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gYear or any of its derived types.")})};function Uc(a){return a(7)||a(9)?b=>({u:!0,value:g(Lb(b,11),11)}):a(19)||a(1)?b=>({u:!0,value:g(Jb(b),11)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gYearMonth or any of its derived types.")})};function Vc(a){return a(21)?b=>{b=atob(b);let c="";for(let d=0,e=b.length;d<e;d++)c+=Number(b.charCodeAt(d)).toString(16);return{u:!0,value:g(c.toUpperCase(),22)}}:a(1)||a(19)?b=>({u:!0,value:g(b,22)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:hexBinary or any of its derived types.")})};function Wc(a){return a(0)?b=>({u:!0,value:g(b?1:0,5)}):a(2)?b=>{const c=Math.trunc(b);return!isFinite(c)||isNaN(c)?{u:!1,error:Error(`FOCA0002: can not cast ${b} to xs:integer`)}:Number.isSafeInteger(c)?{u:!0,value:g(c,5)}:{u:!1,error:Error(`FOAR0002: can not cast ${b} to xs:integer, it is out of bounds for JavaScript numbers.`)}}:a(1)||a(19)?b=>{const c=parseInt(b,10);return isNaN(c)?{u:!1,error:kc(b,5)}:Number.isSafeInteger(c)?{u:!0,value:g(c,5)}:{u:!1,error:Error(`FOCA0003: can not cast ${b} to xs:integer, it is out of bounds for JavaScript numbers.`)}}:
59
- ()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:integer or any of its derived types.")})};const Xc=[3,6,4,5];function Yc(a){var b=Zc;return c=>{for(const d of Xc){const e=b(a,d)(c);if(e.u)return e}return{u:!1,error:Error(`XPTY0004: Casting not supported from "${c}" given type to xs:numeric or any of its derived types.`)}}};function $c(a){if(a(1)||a(19))return b=>({u:!0,value:b+""});if(a(20))return b=>({u:!0,value:b});if(a(23))return b=>({u:!0,value:b.prefix?`${b.prefix}:${b.localName}`:b.localName});if(a(44))return b=>({u:!0,value:b.toString()});if(a(2)){if(a(5)||a(4))return b=>({u:!0,value:(b+"").replace("e","E")});if(a(6)||a(3))return b=>isNaN(b)?{u:!0,value:"NaN"}:isFinite(b)?Object.is(b,-0)?{u:!0,value:"-0"}:{u:!0,value:(b+"").replace("e","E").replace("E+","E")}:{u:!0,value:`${0>b?"-":""}INF`}}return a(9)||a(7)||
60
- a(8)||a(15)||a(14)||a(13)||a(12)||a(11)?b=>({u:!0,value:b.toString()}):a(16)?b=>({u:!0,value:b.toString()}):a(17)?b=>({u:!0,value:b.toString()}):a(18)?b=>({u:!0,value:b.toString()}):a(22)?b=>({u:!0,value:b.toUpperCase()}):b=>({u:!0,value:b+""})};function ad(a){const b=$c(a);return c=>{c=b(c);return c.u?{u:!0,value:g(c.value,1)}:c}};function bd(a){return a(9)?b=>({u:!0,value:g(Lb(b,8),8)}):a(19)||a(1)?b=>({u:!0,value:g(Jb(b),8)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:time or any of its derived types.")})};function cd(a){const b=$c(a);return c=>{c=b(c);return c.u?{u:!0,value:g(c.value,19)}:c}};function dd(a){return a(18)&&!a(17)?b=>({u:!0,value:g(b.Va,16)}):a(17)?()=>({u:!0,value:g(Lc("P0M"),16)}):a(19)||a(1)?b=>{const c=Lc(b);return c?{u:!0,value:g(c,16)}:{u:!1,error:kc(b,16)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:yearMonthDuration or any of its derived types.")})};const ed=[2,5,17,16];
61
- function Zc(a,b){const c=d=>v(a,d);if(39===b)return()=>({u:!1,error:Error("FORG0001: Casting to xs:error is always invalid.")});switch(b){case 19:return cd(c);case 1:return ad(c);case 6:return Pc(c);case 3:return Ic(c);case 4:return Gc(c);case 5:return Wc(c);case 2:return Yc(a);case 18:return Oc(c);case 16:return dd(c);case 17:return Fc(c);case 9:return Ec(c);case 8:return bd(c);case 7:return Dc(c);case 11:return Uc(c);case 12:return Tc(c);case 13:return Sc(c);case 15:return Qc(c);case 14:return Rc(c);
62
- case 0:return zc(c);case 21:return yc(c);case 22:return Vc(c);case 20:return xc(c);case 23:throw Error("Casting to xs:QName is not implemented.");}return()=>({u:!1,error:Error(`XPTY0004: Casting not supported from ${a} to ${b}.`)})}const gd=Object.create(null);
63
- function hd(a,b){if(19===a&&1===b)return f=>({u:!0,value:g(f,1)});if(44===b)return()=>({u:!1,error:Error("XPST0080: Casting to xs:NOTATION is not permitted.")});if(39===b)return()=>({u:!1,error:Error("FORG0001: Casting to xs:error is not permitted.")});if(45===a||45===b)return()=>({u:!1,error:Error("XPST0080: Casting from or to xs:anySimpleType is not permitted.")});if(46===a||46===b)return()=>({u:!1,error:Error("XPST0080: Casting from or to xs:anyAtomicType is not permitted.")});if(v(a,60)&&1===
64
- b)return()=>({u:!1,error:Error("FOTY0014: Casting from function item to xs:string is not permitted.")});if(a===b)return f=>({u:!0,value:{type:b,value:f}});const c=ed.includes(a)?a:rc(a),d=ed.includes(b)?b:rc(b);if(null===d||null===c)return()=>({u:!1,error:Error(`XPST0081: Can not cast: type ${d?Da[a]:Da[b]} is unknown.`)});const e=[];1!==c&&19!==c||e.push(f=>{const h=sc(f,b);return tc(h,b)?{u:!0,value:h}:{u:!1,error:kc(f,b,"pattern validation failed.")}});c!==d&&(e.push(Zc(c,d)),e.push(f=>({u:!0,
65
- value:f.value})));19!==d&&1!==d||e.push(f=>tc(f,b)?{u:!0,value:f}:{u:!1,error:kc(f,b,"pattern validation failed.")});e.push(f=>vc(f,b)?{u:!0,value:f}:{u:!1,error:kc(f,b,"pattern validation failed.")});e.push(f=>({u:!0,value:{type:b,value:f}}));return f=>{f={u:!0,value:f};for(let h=0,k=e.length;h<k&&(f=e[h](f.value),!1!==f.u);++h);return f}}function id(a,b){const c=a.type+1E4*b;let d=gd[c];d||=gd[c]=hd(a.type,b);return d.call(void 0,a.value,b)};function jd(a,b){a=id(a,b);if(!0===a.u)return a.value;throw a.error;};function kd(a){let b=!1;return{next:()=>{if(b)return p;b=!0;return q(a)}}};function ld(a,b){return a===b?!0:a&&b&&a.offset===b.offset&&a.parent===b.parent?ld(a.G,b.G):!1}function md(a,b){return a===b||a.node===b.node&&ld(a.G,b.G)?!0:!1};function nd(a,b,c){var d=x(a,b,null);a=gb(a,d,null);for(let e=0,f=a.length;e<f;++e){d=a[e];if(md(d,b))return-1;if(md(d,c))return 1}}function od(a,b){const c=[];for(;b;b=x(a,b,null))c.unshift(b);return c}function pd(a,b){const c=[];for(;b;b=a.getParentNode(b,null))c.unshift(b);return c}
66
- function qd(a,b,c,d){if(c.G||d.G||cb(c.node)||cb(d.node)){if(md(c,d))return 0;c=od(b,c);d=od(b,d);const f=c[0],h=d[0];if(!md(f,h))return b=a.findIndex(k=>md(k,f)),c=a.findIndex(k=>md(k,h)),-1===b&&(b=a.push(f)),-1===c&&(c=a.push(h)),b-c;a=1;for(var e=Math.min(c.length,d.length);a<e&&md(c[a],d[a]);++a);return c[a]?d[a]?nd(b,c[a],d[a]):1:-1}c=c.node;e=d.node;if(c===e)return 0;d=pd(b,c);c=pd(b,e);if(d[0]!==c[0]){const f={node:d[0],G:null},h={node:c[0],G:null};b=a.findIndex(k=>md(k,f));c=a.findIndex(k=>
67
- md(k,h));-1===b&&(b=a.push(f));-1===c&&(c=a.push(h));return b-c}a=1;for(e=Math.min(d.length,c.length);a<e&&d[a]===c[a];++a);d=d[a];e=c[a];if(!d)return-1;if(!e)return 1;b=b.getChildNodes(c[a-1],null);for(let f=0,h=b.length;f<h;++f){a=b[f];if(a===d)return-1;if(a===e)return 1}}
68
- function rd(a,b,c,d){const e=v(c.type,47),f=v(d.type,47);if(e&&!f){if(c=x(b,c.value),d=d.value,md(c,d))return 1}else if(f&&!e){if(c=c.value,d=x(b,d.value),md(c,d))return-1}else if(e&&f){if(md(x(b,d.value),x(b,c.value)))return c.value.node.localName>d.value.node.localName?1:-1;c=x(b,c.value);d=x(b,d.value)}else c=c.value,d=d.value;return qd(a,b,c,d)}function sd(a,b,c){return rd(a.o,a,b,c)}function td(a,b){return ud(b,(c,d)=>rd(a.o,a,c,d)).filter((c,d,e)=>0===d?!0:!md(c.value,e[d-1].value))}
69
- const vd=(a,b)=>a<b?-1:0;function ud(a,b=vd){if(1>=a.length)return a;var c=Math.floor(a.length/2);const d=ud(a.slice(0,c),b);a=ud(a.slice(c),b);for(c=[];d.length&&a.length;)0>b(d[0],a[0])?c.push(d.shift()):c.push(a.shift());return c.concat(d.concat(a))};function wd(a,b){if(v(a.type,2)){if(v(a.type,6))return 3===b?g(a.value,3):null;if(v(a.type,4)){if(6===b)return g(a.value,6);if(3===b)return g(a.value,3)}return null}return v(a.type,20)&&1===b?g(a.value,1):null};function xd(a,b,c,d,e){if(v(a.type,b.type))return a;v(b.type,46)&&v(a.type,53)&&(a=pc(a,c).first());if(v(a.type,b.type)||46===b.type)return a;if(v(a.type,19)){c=jd(a,b.type);if(!c)throw Error(`XPTY0004 Unable to convert ${e?"return":"argument"} of type ${Da[a.type]} to type ${Ha(b)} while calling ${d}`);return c}c=wd(a,b.type);if(!c)throw Error(`XPTY0004 Unable to cast ${e?"return":"argument"} of type ${Da[a.type]} to type ${Ha(b)} while calling ${d}`);return c}
70
- function yd(a){switch(a){case 2:return"*";case 1:return"+";case 0:return"?";case 3:return""}}
71
- var zd=(a,b,c,d,e)=>0===a.g?b.X({default:()=>b.map(f=>xd(f,a,c,d,e)),multiple:()=>{throw Error(`XPTY0004: Multiplicity of ${e?"function return value":"function argument"} of type ${Da[a.type]}${yd(a.g)} for ${d} is incorrect. Expected "?", but got "+".`);}}):1===a.g?b.X({empty:()=>{throw Error(`XPTY0004: Multiplicity of ${e?"function return value":"function argument"} of type ${Da[a.type]}${yd(a.g)} for ${d} is incorrect. Expected "+", but got "empty-sequence()"`);},default:()=>b.map(f=>xd(f,a,c,
72
- d,e))}):2===a.g?b.map(f=>xd(f,a,c,d,e)):b.X({m:()=>b.map(f=>xd(f,a,c,d,e)),default:()=>{throw Error(`XPTY0004: Multiplicity of ${e?"function return value":"function argument"} of type ${Da[a.type]}${yd(a.g)} for ${d} is incorrect. Expected exactly one`);}});function Ad(a,b,c){return(d,e,f)=>{if(null===d.M)throw lc(`The function ${a} depends on dynamic context, which is absent.`);const h=zd({type:b,g:3},w.m(d.M),e,a,!1);return c(d,e,f,h)}};var Bd=xspattern;function Cd(a,b){return v(a,5)?g(b,5):v(a,6)?g(b,6):v(a,3)?g(b,3):g(b,4)}const Dd=[{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 Ed(a,b){const c=0>a;a=Math.abs(a);if(!a)return"-";let d=Dd.reduce((e,f)=>{const h=Math.floor(a/f.ja);a-=h*f.ja;return e+f.la.repeat(h)},"");b&&(d=d.toLowerCase());c&&(d=`-${d}`);return d}const Fd="ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
73
- function Gd(a,b){const c=0>a;a=Math.abs(a);if(!a)return"-";let d="",e;for(;0<a;)e=(a-1)%Fd.length,d=Fd[e]+d,a=(a-e)/Fd.length|0;b&&(d=d.toLowerCase());c&&(d=`-${d}`);return d}function Hd(a,b,c=[]){return Array.from({length:b},(d,e)=>e+a).filter(d=>!c.includes(d))}
74
- const Id=Hd(1488,27,[1498,1501,1503,1507,1509]),Jd=Hd(1575,36,[1577,1595,1596,1597,1598,1599,1600,1609]),Kd="\u0623\u0628\u062c\u062f\u0647\u0648\u0632\u062d\u0637\u064a\u0643\u0644\u0645\u0646\u0633\u0639\u0641\u0635\u0642\u0631\u0634\u062a\u062b\u062e\u0630\u0636\u0638\u063a".split(""),Ld=[[1E3,"\u063a"],[900,"\u0638"],[800,"\u0636"],[700,"\u0630"],[600,"\u062e"],[500,"\u062b"],[400,"\u062a"],[300,"\u0634"],[200,"\u0631"],[100,"\u0642"],[90,"\u0635"],[80,"\u0641"],[70,"\u0639"],[60,"\u0633"],[50,
75
- "\u0646"],[40,"\u0645"],[30,"\u0644"],[20,"\u0643"],[10,"\u064a"],[9,"\u0637"],[8,"\u062d"],[7,"\u0632"],[6,"\u0648"],[5,"\u0647"],[4,"\u062f"],[3,"\u062c"],[2,"\u0628"],[1,"\u0623"]],Md=[[400,"\u05ea"],[300,"\u05e9"],[200,"\u05e8"],[100,"\u05e7"],[90,"\u05e6"],[80,"\u05e4"],[70,"\u05e2"],[60,"\u05e1"],[50,"\u05e0"],[40,"\u05de"],[30,"\u05dc"],[20,"\u05db"],[10,"\u05d9"],[9,"\u05d8"],[8,"\u05d7"],[7,"\u05d6"],[6,"\u05d5"],[5,"\u05d4"],[4,"\u05d3"],[3,"\u05d2"],[2,"\u05d1"],[1,"\u05d0"]];
76
- function Nd(a,b=[]){var c=25;b.sort((d,e)=>d-e);c-=b.length;return function(d){const e=0>d;d=Math.abs(d);if(!d)return"-";const f=[];for(;0<d;){let h=a+(d-1)%c;b.forEach(k=>{h>=k&&h++});f.unshift(String.fromCodePoint(h));d=Math.floor((d-1)/c)}d=f.join("");e&&(d=`-${d}`);return d}}const Od=Nd(945,[962]),Pd=Nd(913,[930]);function Qd(a){return(new Intl.NumberFormat([],{numberingSystem:"arab",useGrouping:!1})).format(a)}
77
- function Rd(a){return(new Intl.NumberFormat([],{numberingSystem:"arabext",useGrouping:!1})).format(a)}
78
- const Sd=new Map([["A",function(a){return Gd(a,!1)}],["a",function(a){return Gd(a,!0)}],["I",function(a){return Ed(a,!1)}],["i",function(a){return Ed(a,!0)}],["lowerGreek",Od],["\u03b1",Od],["upperGreek",Pd],["\u0391",Pd],["arabicAbjadi",function(a){const b=0>a;a=Math.abs(a);if(!a)return"-";a=Array(Math.floor((a-1)/Kd.length)+1).fill(Kd[(a-1)%Kd.length]).join(String.fromCodePoint(8204));b&&(a=`-${a}`);return a}],["arabicAbjadNumeral",function(a){const b=0>a;a=Math.abs(a);if(!a)return"-";var c=[],
79
- d=Math.floor(a/1E3);a-=1E3*d;if(1===d)c.push(Ld[0][1]);else if(1<d){for(const [f,h]of Ld){var e=f;const k=h;for(;d>=e;)c.push(k),d-=e}c.push(Ld[0][1])}for(const [f,h]of Ld)for(d=f,e=h;a>=d;)a-=d,c.push(e);c=c.join("");b&&(c=`-${c}`);return c}],["arabicAlifBaTa",function(a){const b=0>a;a=Math.abs(a);if(!a)return"-";a=Array(Math.floor((a-1)/Jd.length)+1).fill(String.fromCodePoint(Jd[(a-1)%Jd.length])).join(String.fromCodePoint(8204));b&&(a=`-${a}`);return a}],["hebrewAlefBet",function(a){const b=0>
80
- a;a=Math.abs(a);if(!a)return"-";var c=Math.floor((a-1)/Id.length);const d=String.fromCodePoint(1514);c=Array(c).fill(d);c.push(String.fromCodePoint(Id[(a-1)%Id.length]));a=c.join("");b&&(a=`-${a}`);return a}],["hebrewNumeral",function(a){const b=0>a;a=Math.abs(a);if(!a)return"-";var c=[],d=Math.floor(a/400);a-=400*d;for(var e=0;e<d;e++)c.push("\u05ea");for(const [f,h]of Md)for(d=f,e=h;a>=d;)a-=d,c.push(e);a=c.slice(-2).join("");"\u05d9\u05d4"===a&&c.splice(-2,2,"\u05d8","\u05d5");"\u05d9\u05d5"===
81
- a&&c.splice(-2,2,"\u05d8","\u05d6");c=c.join("");b&&(c=`-${c}`);return c}],["arabicIndicNumeral",Qd],["\u0661",Qd],["\u0662",Qd],["\u0663",Qd],["\u0664",Qd],["\u0665",Qd],["\u0666",Qd],["\u0667",Qd],["\u0668",Qd],["\u0669",Qd],["persianNumeral",Rd],["\u06f1",Rd],["\u06f2",Rd],["\u06f3",Rd],["\u06f4",Rd],["\u06f5",Rd],["\u06f6",Rd],["\u06f7",Rd],["\u06f8",Rd],["\u06f9",Rd]]);
82
- function Td(a){if(Math.floor(a)===a||isNaN(a))return 0;a=/\d+(?:\.(\d*))?(?:[Ee](-)?(\d+))*/.exec(`${a}`);const b=a[1]?a[1].length:0;if(a[3]){if(a[2])return b+parseInt(a[3],10);a=b-parseInt(a[3],10);return 0>a?0:a}return b}function Ud(a,b,c){return b&&0===a*c%1%.5?0===Math.floor(a*c)%2?Math.floor(a*c)/c:Math.ceil(a*c)/c:Math.round(a*c)/c}
83
- function Vd(a,b,c,d,e,f){let h=!1;return w.create({next:()=>{if(h)return p;const k=e.first();if(!k)return h=!0,p;if((v(k.type,6)||v(k.type,3))&&(0===k.value||isNaN(k.value)||Infinity===k.value||-Infinity===k.value))return h=!0,q(k);var l;f?l=f.first().value:l=0;h=!0;if(Td(k.value)<l)return q(k);const n=[5,4,3,6].find(u=>v(k.type,u)),t=jd(k,4);l=Ud(t.value,a,Math.pow(10,l));switch(n){case 4:return q(g(l,4));case 3:return q(g(l,3));case 6:return q(g(l,6));case 5:return q(g(l,5))}}})}
84
- const Wd=(a,b,c,d)=>qc(d,b).X({empty:()=>w.m(g(NaN,3)),m:()=>{const e=id(d.first(),3);return e.u?w.m(e.value):w.m(g(NaN,3))},multiple:()=>{throw Error("fn:number may only be called with zero or one values");}});function Xd(a){let b=5381;for(let c=0;c<a.length;++c)b=33*b+a.charCodeAt(c),b%=Number.MAX_SAFE_INTEGER;return b}
85
- const Yd=(a,b,c,d=w.empty())=>{function e(f){const h=(k,l,n,t)=>{if(t.F()||t.oa())return t;k=t.O();l=f;for(n=k.length-1;1<n;n--){l=gc(a,l).rb;t=l%n;const u=k[t];k[t]=k[n];k[n]=u}return w.create(k)};return w.m(new ub([{key:g("number",1),value:()=>w.m(g(gc(a,f).$b,3))},{key:g("next",1),value:()=>w.m(new Va({value:()=>e(gc(a,f).rb),Ya:!0,localName:"",namespaceURI:"",j:[],arity:0,i:{type:61,g:3}}))},{key:g("permute",1),value:()=>w.m(new Va({value:h,Ya:!0,localName:"",namespaceURI:"",j:[{type:59,g:2}],
86
- arity:1,i:{type:59,g:2}}))}]))}b=d.F()?gc(a):gc(a,Xd(jd(d.first(),1).value));return e(b.rb)};
87
- var Zd=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"abs",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:(a,b,c,d)=>d.map(e=>Cd(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:(a,b,c,d,e)=>{a=d.first();e=e.first();if(d.F())return w.m(g("",1));d=Sd.get(e.value);e=a.value;return d?(d=d(e),w.m(g(d,1))):w.m(g(e.toString(),1))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
88
- localName:"ceiling",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:(a,b,c,d)=>d.map(e=>Cd(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:(a,b,c,d)=>d.map(e=>Cd(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:Vd.bind(null,!1)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round",j:[{type:2,
89
- g:0},{type:5,g:3}],i:{type:2,g:0},callFunction:Vd.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:Vd.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:Vd.bind(null,!0)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"number",j:[{type:46,g:0}],i:{type:3,g:3},callFunction:Wd},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
90
- localName:"number",j:[],i:{type:3,g:3},callFunction:(a,b,c)=>{const d=a.M&&zd({type:46,g:0},w.m(a.M),b,"fn:number",!1);if(!d)throw lc("fn:number needs an atomizable context item.");return Wd(a,b,c,d)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"random-number-generator",j:[],i:{type:61,g:3},callFunction:Yd},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"random-number-generator",j:[{type:46,g:0}],i:{type:61,g:3},callFunction:Yd}];function $d(){throw Error("FOCH0002: No collations are supported");}
91
- const ae=(a,b,c,d)=>d.X({empty:()=>w.m(g("",1)),default:()=>d.map(e=>{if(v(e.type,53)){const f=pc(e,b).first();return v(e.type,47)?jd(f,1):f}return jd(e,1)})}),be=(a,b,c,d,e)=>A([e],([f])=>qc(d,b).N(h=>{h=h.map(k=>jd(k,1).value).join(f.value);return w.m(g(h,1))})),ce=(a,b,c,d)=>{if(d.F())return w.m(g(0,5));a=d.first().value;return w.m(g(Array.from(a).length,5))},ee=(a,b,c,d,e,f)=>{const h=Vd(!1,a,b,c,e,null),k=null!==f?Vd(!1,a,b,c,f,null):null;let l=!1,n=null,t=null,u=null;return w.create({next:()=>
92
- {if(l)return p;if(!n&&(n=d.first(),null===n))return l=!0,q(g("",1));t||=h.first();!u&&f&&(u=null,u=k.first());l=!0;return q(g(Array.from(n.value).slice(Math.max(t.value-1,0),f?t.value+u.value-1:void 0).join(""),1))}})},ge=(a,b,c,d,e)=>{if(d.F()||0===d.first().value.length)return w.empty();a=d.first().value;e=e.first().value;e=fe(e);e.lastIndex=0;b=[];c=e.exec(a);for(d=0;c;)b.push(a.slice(d,c.index)),d=e.lastIndex,c=e.exec(a);b.push(a.slice(d));return w.create(b.map(f=>g(f,1)))},he=(a,b,c,d)=>{if(d.F())return w.m(g("",
93
- 1));a=d.first().value.trim();return w.m(g(a.replace(/\s+/g," "),1))},ie=new Map,je=new Map;function fe(a){if(je.has(a))return je.get(a);let b;try{b=new RegExp(a,"g")}catch(c){throw Error(`FORX0002: ${c}`);}if(b.test(""))throw Error(`FORX0003: the pattern ${a} matches the zero length string`);je.set(a,b);return b}
94
- var ke=[{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:(a,b,c,d,e)=>{if(d.F()||e.F())return w.empty();a=d.first().value;e=e.first().value;return a>e?w.m(g(1,5)):a<e?w.m(g(-1,5)):w.m(g(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:$d},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"concat",
95
- j:[{type:46,g:0},{type:46,g:0},4],i:{type:1,g:3},callFunction:(a,b,c,...d)=>{d=d.map(e=>qc(e,b).N(f=>w.m(g(f.map(h=>null===h?"":jd(h,1).value).join(""),1))));return A(d,e=>w.m(g(e.map(f=>f.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:$d},{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:(a,b,
96
- c,d,e)=>{a=d.F()?"":d.first().value;e=e.F()?"":e.first().value;return 0===e.length?w.aa():0===a.length?w.T():a.includes(e)?w.aa():w.T()}},{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:(a,b,c,d,e)=>{a=e.F()?"":e.first().value;if(0===a.length)return w.aa();d=d.F()?"":d.first().value;return 0===d.length?w.T():d.endsWith(a)?w.aa():w.T()}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"ends-with",
97
- j:[{type:1,g:0},{type:1,g:0},{type:1,g:3}],i:{type:0,g:3},callFunction:$d},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"normalize-space",j:[{type:1,g:0}],i:{type:1,g:3},callFunction:he},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"normalize-space",j:[],i:{type:1,g:3},callFunction:Ad("normalize-space",1,(a,b,c,d)=>he(a,b,c,ae(a,b,c,d)))},{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},
98
- callFunction:(a,b,c,d,e)=>{a=e.F()?"":e.first().value;if(0===a.length)return w.aa();d=d.F()?"":d.first().value;return 0===d.length?w.T():d.startsWith(a)?w.aa():w.T()}},{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:$d},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string",j:[{type:59,g:0}],i:{type:1,g:3},callFunction:ae},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
99
- localName:"string",j:[],i:{type:1,g:3},callFunction:Ad("string",59,ae)},{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:(a,b,c,d,e)=>{a=d.F()?"":d.first().value;e=e.F()?"":e.first().value;if(""===e)return w.m(g("",1));e=a.indexOf(e);return-1===e?w.m(g("",1)):w.m(g(a.substring(0,e),1))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring-after",j:[{type:1,g:0},{type:1,g:0}],i:{type:1,
100
- g:3},callFunction:(a,b,c,d,e)=>{a=d.F()?"":d.first().value;e=e.F()?"":e.first().value;if(""===e)return w.m(g(a,1));b=a.indexOf(e);return-1===b?w.m(g("",1)):w.m(g(a.substring(b+e.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:ee},{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:ee},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
101
- localName:"upper-case",j:[{type:1,g:0}],i:{type:1,g:3},callFunction:(a,b,c,d)=>d.F()?w.m(g("",1)):d.map(e=>g(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:(a,b,c,d)=>d.F()?w.m(g("",1)):d.map(e=>g(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:be},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
102
- localName:"string-join",j:[{type:46,g:2}],i:{type:1,g:3},callFunction(a,b,c,d){return be(a,b,c,d,w.m(g("",1)))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-length",j:[{type:1,g:0}],i:{type:5,g:3},callFunction:ce},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-length",j:[],i:{type:5,g:3},callFunction:Ad("string-length",46,(a,b,c,d)=>ce(a,b,c,ae(a,b,c,d)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"tokenize",j:[{type:1,
103
- 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:ge},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"tokenize",j:[{type:1,g:0}],i:{type:1,g:2},callFunction(a,b,c,d){return ge(a,b,c,he(a,b,c,d),w.m(g(" ",1)))}},{j:[{type:1,g:0},{type:1,g:3},{type:1,g:3}],callFunction:(a,
104
- b,c,d,e,f)=>A([d,e,f],([h,k,l])=>{h=Array.from(h?h.value:"");const n=Array.from(k.value),t=Array.from(l.value);k=h.map(u=>{if(n.includes(u)){if(u=n.indexOf(u),u<=t.length)return t[u]}else return u});return w.m(g(k.join(""),1))}),localName:"translate",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:5,g:2}],callFunction:(a,b,c,d)=>d.N(e=>{e=e.map(f=>{f=f.value;if(9===f||10===f||13===f||32<=f&&55295>=f||57344<=f&&65533>=f||65536<=f&&1114111>=f)return String.fromCodePoint(f);
105
- throw Error("FOCH0001");}).join("");return w.m(g(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:(a,b,c,d)=>A([d],([e])=>{e=e?e.value.split(""):[];return 0===e.length?w.empty():w.create(e.map(f=>g(f.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:(a,b,c,d)=>A([d],([e])=>null===e||0===e.value.length?
106
- w.create(g("",1)):w.create(g(encodeURIComponent(e.value).replace(/[!'()*]/g,f=>"%"+f.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:(a,b,c,d)=>A([d],([e])=>null===e||0===e.value.length?w.create(g("",1)):w.create(g(e.value.replace(/([\u00A0-\uD7FF\uE000-\uFDCF\uFDF0-\uFFEF "<>{}|\\^`/\n\u007f\u0080-\u009f]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g,f=>encodeURI(f)),1))),localName:"iri-to-uri",
107
- namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:1,g:0},{type:1,g:0}],callFunction:(a,b,c,d,e)=>A([d,e],([f,h])=>{if(null===f||null===h)return w.empty();f=f.value;var k=h.value;if(f.length!==k.length)return w.T();h=f.split("");f=k.split("");for(k=0;k<h.length;k++)if(h[k].codePointAt(0)!==f[k].codePointAt(0))return w.T();return w.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:(a,
108
- b,c,d,e)=>A([d,e],([f,h])=>{f=f?f.value:"";h=h.value;let k=ie.get(h);if(!k){try{k=(0,Bd.compile)(h,{language:"xpath"})}catch(l){throw Error(`FORX0002: ${l}`);}ie.set(h,k)}return k(f)?w.aa():w.T()}),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:(a,b,c,d,e,f)=>A([d,e,f],([h,k,l])=>{h=h?h.value:"";k=k.value;l=l.value;if(l.includes("$0"))throw Error("Using $0 in fn:replace to replace substrings with full matches is not supported.");
109
- l=l.split(/((?:\$\$)|(?:\\\$)|(?:\\\\))/).map(n=>{switch(n){case "\\$":return"$$";case "\\\\":return"\\";case "$$":throw Error('FORX0004: invalid replacement: "$$"');default:return n}}).join("");k=fe(k);h=h.replace(k,l);return w.m(g(h,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");
110
- }}];const le=new WeakMap;let me=0;const ne=(a,b,c,d)=>A([d],([e])=>{if(null===e)return w.empty();e=e.value;switch(e.node.nodeType){case 1:case 2:return w.m(g(new Sa(e.node.prefix,e.node.namespaceURI,e.node.localName),23));case 7:return w.m(g(new Sa("","",e.node.target),23));default:return w.empty()}}),oe=(a,b,c,d)=>d.X({default:()=>ae(a,b,c,ne(a,b,c,d)),empty:()=>w.m(g("",1))}),pe=(a,b,c,d)=>qc(d,b),qe=(a,b,c,d)=>{if(d.F())return w.m(g("",1));if(!v(d.first().type,53))throw Error("XPTY0004: The context item must be a node.");c=d.first().value;
111
- a=w;b=a.m;c=c.node;le.has(c)||le.set(c,`id${++me}`);c=le.get(c);return b.call(a,g(c,1))},re=(a,b,c,d)=>A([d],([e])=>{e=e?e.value:null;return null!==e&&ib(b.h,e,null)?w.aa():w.T()});function se(a,b){a=a.toLowerCase();b=b.toLowerCase();return a===b?!0:5>a.length||!a.startsWith(b)?!1:se(a.replace(/-[a-z0-9]+$/,""),b)}
112
- const te=(a,b,c,d,e)=>{b=b.h;if(d.F())d="";else if(v(d.first().type,1))d=d.first().value;else throw Error("XPTY0004: The first argument of lang must be a string.");if(e)e=e.first().value;else{if(!a||!a.M)throw lc("The function lang depends on dynamic context if a node is not passed as the second argument.");if(!v(a.M.type,53))throw Error("XPTY0004: The context item must be a node.");e=a.M.value}a:{for(a=d;e;)if(1!==e.node.nodeType)e=x(b,e);else if(1===e.node.nodeType){if(d=fb(b,e,"xml:lang")){b=se(d,
113
- a)?w.aa():w.T();break a}e=x(b,e)}b=w.T()}return b},ue=(a,b,c,d)=>A([d],([e])=>{function f(n){let t=0,u=n;for(;null!==u;)(n.node.nodeType!==u.node.nodeType?0:1===u.node.nodeType?u.node.localName===n.node.localName&&u.node.namespaceURI===n.node.namespaceURI:7===u.node.nodeType?u.node.target===n.node.target:1)&&t++,u=mb(h,u,null);return t}if(null===e)return w.empty();const h=b.h;let k="";for(e=e.value;null!==x(b.h,e,null);e=x(b.h,e,null))switch(e.node.nodeType){case 1:var l=e;k=`/Q{${l.node.namespaceURI||
114
- ""}}${l.node.localName}[${f(l)}]${k}`;break;case 2:l=e;k=`/@${l.node.namespaceURI?`Q{${l.node.namespaceURI}}`:""}${l.node.localName}${k}`;break;case 3:k=`/text()[${f(e)}]${k}`;break;case 7:l=e;k=`/processing-instruction(${l.node.target})[${f(l)}]${k}`;break;case 8:k=`/comment()[${f(e)}]${k}`}return 9===e.node.nodeType?w.create(g(k||"/",1)):w.create(g("Q{http://www.w3.org/2005/xpath-functions}root()"+k,1))}),ve=(a,b,c,d)=>d.map(e=>g(e.value.node.namespaceURI||"",20)),we=(a,b,c,d)=>d.X({default:()=>
115
- d.map(e=>7===e.value.node.nodeType?g(e.value.node.target,1):g(e.value.node.localName||"",1)),empty:()=>w.m(g("",1))});function xe(a,b,c){if(2===b.node.nodeType)return md(b,c);for(;c;){if(md(b,c))return!0;if(9===c.node.nodeType)break;c=x(a,c,null)}return!1}const ye=(a,b,c,d)=>d.map(e=>{if(!v(e.type,53))throw Error("XPTY0004 Argument passed to fn:root() should be of the type node()");let f;for(e=e.value;e;)f=e,e=x(b.h,f,null);return rb(f)});
116
- var ze=[{j:[{type:53,g:0}],callFunction:oe,localName:"name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[],callFunction:Ad("name",53,oe),localName:"name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:53,g:3}],callFunction:ve,localName:"namespace-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:20,g:3}},{j:[],callFunction:Ad("namespace-uri",53,ve),localName:"namespace-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",
117
- i:{type:20,g:3}},{j:[{type:53,g:2}],callFunction:(a,b,c,d)=>d.N(e=>{if(!e.length)return w.empty();e=td(b.h,e).reduceRight((f,h,k,l)=>{if(k===l.length-1)return f.push(h),f;if(xe(b.h,h.value,f[0].value))return f;f.unshift(h);return f},[]);return w.create(e)}),localName:"innermost",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:2}},{j:[{type:53,g:2}],callFunction:(a,b,c,d)=>d.N(e=>{if(!e.length)return w.empty();e=td(b.h,e).reduce((f,h,k)=>{if(0===k)return f.push(h),f;if(xe(b.h,f[f.length-
118
- 1].value,h.value))return f;f.push(h);return f},[]);return w.create(e)},1),localName:"outermost",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:2}},{j:[{type:53,g:0}],callFunction:re,localName:"has-children",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[],callFunction:Ad("has-children",53,re),localName:"has-children",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:53,g:0}],callFunction:ue,localName:"path",namespaceURI:"http://www.w3.org/2005/xpath-functions",
119
- i:{type:1,g:0}},{j:[],callFunction:Ad("path",53,ue),localName:"path",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:0}},{j:[{type:53,g:0}],callFunction:ne,localName:"node-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[],callFunction:Ad("node-name",53,ne),localName:"node-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[{type:53,g:0}],callFunction:we,localName:"local-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",
120
- i:{type:1,g:3}},{j:[],callFunction:Ad("local-name",53,we),localName:"local-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:53,g:0}],callFunction:ye,localName:"root",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:0}},{j:[],callFunction:Ad("root",53,ye),localName:"root",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:0}},{j:[],callFunction:Ad("data",59,pe),localName:"data",namespaceURI:"http://www.w3.org/2005/xpath-functions",
121
- i:{type:46,g:2}},{j:[{type:59,g:2}],callFunction:pe,localName:"data",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}},{j:[{type:1,g:0}],callFunction:te,localName:"lang",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:1,g:0},{type:53,g:3}],callFunction:te,localName:"lang",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[],callFunction:Ad("generate-id",53,qe),localName:"generate-id",namespaceURI:"http://www.w3.org/2005/xpath-functions",
122
- i:{type:1,g:3}},{j:[{type:53,g:0}],callFunction:qe,localName:"generate-id",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}}];function Ae(a,b){let c=0;const d=a.length;let e=!1,f=null;return{next:()=>{if(!e){for(;c<d;){f||=b(a[c],c,a);const h=f.next(0);f=null;if(h.value)c++;else return q(!1)}e=!0;return q(!0)}return p}}}function Be(a){a=a.node.nodeType;return 1===a||3===a}
123
- function Ce(a,b){if((v(a.type,4)||v(a.type,6))&&(v(b.type,4)||v(b.type,6))){var c=jd(a,6),d=jd(b,6);return c.value===d.value||isNaN(a.value)&&isNaN(b.value)}return(v(a.type,4)||v(a.type,6)||v(a.type,3))&&(v(b.type,4)||v(b.type,6)||v(b.type,3))?(c=jd(a,3),d=jd(b,3),c.value===d.value||isNaN(a.value)&&isNaN(b.value)):v(a.type,23)&&v(b.type,23)?a.value.namespaceURI===b.value.namespaceURI&&a.value.localName===b.value.localName:(v(a.type,9)||v(a.type,7)||v(a.type,8)||v(a.type,11)||v(a.type,12)||v(a.type,
124
- 13)||v(a.type,14)||v(a.type,15))&&(v(b.type,9)||v(b.type,7)||v(b.type,8)||v(b.type,11)||v(b.type,12)||v(b.type,13)||v(b.type,14)||v(b.type,15))?Ob(a.value,b.value):(v(a.type,16)||v(a.type,17)||v(a.type,18))&&(v(b.type,16)||v(b.type,17)||v(b.type,17))?vb(a.value,b.value):a.value===b.value}function De(a,b,c){const [d,e]=[b,c].map(f=>({type:1,value:f.reduce((h,k)=>h+=pc(k,a).first().value,"")}));return q(Ce(d,e))}
125
- function Ee(a,b,c,d){for(;a.value&&v(a.value.type,56);){b.push(a.value);const e=lb(d,a.value.value);a=c.next(0);if(e&&3!==e.node.nodeType)break}return a}
126
- function Fe(a,b,c,d,e){const f=b.h,h=d.value,k=e.value;let l=null,n=null,t=null,u;const z=[],y=[];return{next:()=>{for(;!u;)if(l||=h.next(0),l=Ee(l,z,h,f),n||=k.next(0),n=Ee(n,y,k,f),z.length||y.length){var G=De(b,z,y);z.length=0;y.length=0;if(!1===G.value)return u=!0,G}else{if(l.done||n.done)return u=!0,q(l.done===n.done);t||=Ge(a,b,c,l.value,n.value);G=t.next(0);t=null;if(!1===G.value)return u=!0,G;n=l=null}return p}}}
127
- function He(a,b,c,d,e){return d.h.length!==e.h.length?kd(!1):Ae(d.h,f=>{const h=e.h.find(k=>Ce(k.key,f.key));return h?Fe(a,b,c,f.value(),h.value()):kd(!1)})}function Ie(a,b,c,d,e){return d.h.length!==e.h.length?kd(!1):Ae(d.h,(f,h)=>{h=e.h[h];return Fe(a,b,c,f(),h())})}function Je(a,b,c,d,e){d=gb(b.h,d.value);e=gb(b.h,e.value);d=d.filter(f=>Be(f));e=e.filter(f=>Be(f));d=w.create(d.map(f=>rb(f)));e=w.create(e.map(f=>rb(f)));return Fe(a,b,c,d,e)}
128
- function Ke(a,b,c,d,e){const f=Fe(a,b,c,ne(a,b,c,w.m(d)),ne(a,b,c,w.m(e))),h=Je(a,b,c,d,e);d=eb(b.h,d.value).filter(n=>"http://www.w3.org/2000/xmlns/"!==n.node.namespaceURI).sort((n,t)=>n.node.nodeName>t.node.nodeName?1:-1).map(n=>rb(n));e=eb(b.h,e.value).filter(n=>"http://www.w3.org/2000/xmlns/"!==n.node.namespaceURI).sort((n,t)=>n.node.nodeName>t.node.nodeName?1:-1).map(n=>rb(n));const k=Fe(a,b,c,w.create(d),w.create(e));let l=!1;return{next:()=>{if(l)return p;var n=f.next(0);if(!n.done&&!1===n.value)return l=
129
- !0,n;n=k.next(0);if(!n.done&&!1===n.value)return l=!0,n;n=h.next(0);l=!0;return n}}}function Le(a,b,c,d,e){const f=Fe(a,b,c,ne(a,b,c,w.m(d)),ne(a,b,c,w.m(e)));let h=!1;return{next:()=>{if(h)return p;const k=f.next(0);return k.done||!1!==k.value?q(Ce(pc(d,b).first(),pc(e,b).first())):(h=!0,k)}}}
130
- function Ge(a,b,c,d,e){if(v(d.type,46)&&v(e.type,46))return kd(Ce(d,e));if(v(d.type,61)&&v(e.type,61))return He(a,b,c,d,e);if(v(d.type,62)&&v(e.type,62))return Ie(a,b,c,d,e);if(v(d.type,53)&&v(e.type,53)){if(v(d.type,55)&&v(e.type,55))return Je(a,b,c,d,e);if(v(d.type,54)&&v(e.type,54))return Ke(a,b,c,d,e);if(v(d.type,47)&&v(e.type,47)||v(d.type,57)&&v(e.type,57)||v(d.type,58)&&v(e.type,58))return Le(a,b,c,d,e)}return kd(!1)};var Me=class extends cc{constructor(){super({M:null,Aa:-1,ta:w.empty(),ra:{}})}};var Ne=(a="Can not execute an updating expression in a non-updating context.")=>Error(`XUST0001: ${a}`),Oe=a=>Error(`XUTY0004: The attribute ${a.name}="${a.value}" follows a node that is not an attribute node.`),Pe=()=>Error("XUTY0005: The target of a insert expression with into must be a single element or document node."),Qe=()=>Error("XUTY0006: The target of a insert expression with before or after must be a single element, text, comment, or processing instruction node."),Re=()=>Error("XUTY0008: The target of a replace expression must be a single element, attribute, text, comment, or processing instruction node."),
131
- Se=()=>Error("XUTY0012: The target of a rename expression must be a single element, attribute, or processing instruction node."),Te=a=>Error(`XUDY0017: The target ${a.outerHTML} is used in more than one replace value of expression.`),Ue=a=>Error(`XUDY0021: Applying the updates will result in the XDM instance violating constraint: '${a}'`),Ve=a=>Error(`XUDY0023: The namespace binding ${a} is conflicting.`),We=a=>Error(`XUDY0024: The namespace binding ${a} is conflicting.`),Xe=()=>Error("XUDY0027: The target for an insert, replace, or rename expression expression should not be empty.");function C(a,b,c){b&&null!==b.M?a.B?(null===a.ob&&(a.ob=Ra(a.h(new Me,c).hb())),a=a.ob()):a=a.h(b,c):a=a.h(b,c);return a}var D=class{constructor(a,b,c={B:!1,W:!1,R:"unsorted",subtree:!1},d=!1,e){this.o=a;this.ia=c.R||"unsorted";this.subtree=!!c.subtree;this.W=!!c.W;this.B=!!c.B;this.Fa=b;this.I=!1;this.ob=null;this.Qb=d;this.type=e}D(){return null}v(a){this.Fa.forEach(b=>b.v(a));if(!this.Qb&&this.Fa.some(b=>b.I))throw Ne();}};var Ye=class{constructor(a,b){this.J=a;this.da=b}};var Ze=class{constructor(a){a&&"object"===typeof a&&"nodeType"in a&&(a=a.ownerDocument||a,"function"===typeof a.createElementNS&&"function"===typeof a.createProcessingInstruction&&"function"===typeof a.createTextNode&&"function"===typeof a.createComment&&(this.h=a));this.h||(this.h=null)}createAttributeNS(a,b){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createAttributeNS(a,b)}createCDATASection(a){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");
27
+ var Na=class{constructor(a,b=null){this.D=w;this.value={next:c=>{if(null!==this.o&&this.h>=this.o)return p;if(void 0!==this.v[this.h])return q(this.v[this.h++]);c=a.next(c);if(c.done)return this.o=this.h,c;if(this.l||2>this.h)this.v[this.h]=c.value;this.h++;return c}};this.l=!1;this.v=[];this.h=0;this.o=b}hb(){return this.D.create(this.N())}filter(a){let b=-1;const c=this.value;return this.D.create({next:d=>{b++;for(d=c.next(d);!d.done&&!a(d.value,b,this);)b++,d=c.next(0);return d}})}first(){if(void 0!==
28
+ this.v[0])return this.v[0];const a=this.value.next(0);Ma(this);return a.done?null:a.value}N(){if(this.h>this.v.length&&this.o!==this.v.length)throw Error("Implementation error: Sequence Iterator has progressed.");const a=this.value;this.l=!0;let b=a.next(0);for(;!b.done;)b=a.next(0);return this.v}ea(){const a=this.value,b=this.h;Ma(this);var c=a.next(0);if(c.done)return Ma(this,b),!1;c=c.value;if(v(c.type,53))return Ma(this,b),!0;if(!a.next(0).done)throw xa("Cannot determine the effective boolean value of a sequence with a length higher than one.");
29
+ Ma(this,b);return La(c)}Ra(a=!1){if(null!==this.o)return this.o;if(a)return-1;a=this.h;const b=this.N().length;Ma(this,a);return b}isEmpty(){return 0===this.o?!0:null===this.first()}oa(){if(null!==this.o)return 1===this.o;var a=this.value;const b=this.h;Ma(this);if(a.next(0).done)return Ma(this,b),!1;a=a.next(0);Ma(this,b);return a.done}map(a){let b=0;const c=this.value;return this.D.create({next:d=>{d=c.next(d);return d.done?p:q(a(d.value,b++,this))}},this.o)}M(a,b){const c=this.value;let d;const e=
30
+ [];let f=!0;(function(){for(let h=c.next(f?0:b);!h.done;h=c.next(b))f=!1,e.push(h.value);d=a(e).value})();return this.D.create({next:()=>d.next(0)})}X(a){let b=null;const c=d=>{b=d.value;d=d.Ra(!0);-1!==d&&(this.o=d)};return this.D.create({next:d=>{if(b)return b.next(d);if(this.isEmpty())return c(a.empty?a.empty(this):a.default(this)),b.next(d);if(this.oa())return c(a.m?a.m(this):a.default(this)),b.next(d);c(a.multiple?a.multiple(this):a.default(this));return b.next(d)}})}};var Oa=class{constructor(a){this.v=w;this.h=a;let b=!1;this.value={next:()=>{if(b)return p;b=!0;return q(a)}};this.o=null}hb(){return this}filter(a){return a(this.h,0,this)?this:this.v.create()}first(){return this.h}N(){return[this.h]}ea(){null===this.o&&(this.o=La(this.h));return this.o}Ra(){return 1}isEmpty(){return!1}oa(){return!0}map(a){return this.v.create(a(this.h,0,this))}M(a){return a([this.h])}X(a){return a.m?a.m(this):a.default(this)}};const Pa=new Ba;function Qa(a=null,b=null){if(null===a)return Pa;if(Array.isArray(a))switch(a.length){case 0:return Pa;case 1:return new Oa(a[0]);default:return new Aa(a)}return a.next?new Na(a,b):new Oa(a)}var w={create:Qa,m:a=>new Oa(a),empty:()=>Qa(),$:()=>Qa(va),S:()=>Qa(wa)};function Ra(a){const b=[],c=a.value;return()=>{let d=0;return w.create({next:()=>{if(void 0!==b[d])return b[d++];const e=c.next(0);return e.done?e:b[d++]=e}})}};var Sa=class{constructor(a,b,c){this.namespaceURI=b||null;this.prefix=a||"";this.localName=c}Aa(){return this.prefix?this.prefix+":"+this.localName:this.localName}};function Ta(a,b){const c=a.value,d=b.map(e=>null===e?null:Ra(e));b=b.reduce((e,f,h)=>{null===f&&e.push(a.o[h]);return e},[]);b=new Va({j:b,arity:b.length,bb:!0,H:a.H,localName:"boundFunction",namespaceURI:a.l,i:a.s,value:function(e,f,h){const k=Array.from(arguments).slice(3),l=d.map(n=>null===n?k.shift():n());return c.apply(void 0,[e,f,h].concat(l))}});return w.m(b)}
31
+ var Va=class extends Ca{constructor({j:a,arity:b,bb:c=!1,H:d=!1,localName:e,namespaceURI:f,i:h,value:k}){super(60,null);this.value=k;this.H=d;d=-1;for(k=0;k<a.length;k++)4===a[k]&&(d=k);-1<d&&(k=Array(b-(a.length-1)).fill(a[d-1]),a=a.slice(0,d).concat(k));this.o=a;this.v=b;this.ha=c;this.D=e;this.l=f;this.s=h}bb(){return this.ha}};function Wa(a,b){const c=[];2!==a&&1!==a||c.push("type-1-or-type-2");c.push(`type-${a}`);b&&c.push(`name-${b}`);return c}function Xa(a){const b=a.node.nodeType;let c;if(2===b||1===b)c=a.node.localName;return Wa(b,c)}function Ya(a){let b=a.nodeType;4===b&&(b=3);let c;if(2===b||1===b)c=a.localName;return Wa(b,c)};var Za=class{getAllAttributes(a,b=null){if(1!==a.nodeType)return[];a=Array.from(a.attributes);return null===b?a:a.filter(c=>Ya(c).includes(b))}getAttribute(a,b){return 1!==a.nodeType?null:a.getAttribute(b)}getChildNodes(a,b=null){a=Array.from(a.childNodes);return null===b?a:a.filter(c=>Ya(c).includes(b))}getData(a){return 2===a.nodeType?a.value:a.data}getFirstChild(a,b=null){for(a=a.firstChild;a;a=a.nextSibling)if(null===b||Ya(a).includes(b))return a;return null}getLastChild(a,b=null){for(a=a.lastChild;a;a=
32
+ a.previousSibling)if(null===b||Ya(a).includes(b))return a;return null}getNextSibling(a,b=null){for(a=a.nextSibling;a;a=a.nextSibling)if(null===b||Ya(a).includes(b))return a;return null}getParentNode(a,b=null){return(a=2===a.nodeType?a.ownerElement:a.parentNode)?null===b||Ya(a).includes(b)?a:null:null}getPreviousSibling(a,b=null){for(a=a.previousSibling;a;a=a.previousSibling)if(null===b||Ya(a).includes(b))return a;return null}};class $a{insertBefore(a,b,c){return a.insertBefore(b,c)}removeAttributeNS(a,b,c){return a.removeAttributeNS(b,c)}removeChild(a,b){return a.removeChild(b)}setAttributeNS(a,b,c,d){a.setAttributeNS(b,c,d)}setData(a,b){a.data=b}}var ab=new $a;class bb{constructor(a){this.h=a}insertBefore(a,b,c){return this.h.insertBefore(a,b,c)}removeAttributeNS(a,b,c){return this.h.removeAttributeNS(a,b,c)}removeChild(a,b){return this.h.removeChild(a,b)}setAttributeNS(a,b,c,d){this.h.setAttributeNS(a,b,c,d)}setData(a,b){this.h.setData(a,b)}};function cb(a){return void 0!==a.Ta};function db(a,b,c){let d=null;b&&(cb(b.node)?d={F:b.F,offset:c,parent:b.node}:b.F&&(d=b.F));return{node:a,F:d}}function eb(a,b,c=null){return a.getAllAttributes(b.node,c).map(d=>db(d,b,d.nodeName))}function fb(a,b,c){b=b.node;return cb(b)?(a=b.attributes.find(d=>c===d.name))?a.value:null:(a=a.h.getAttribute(b,c))?a:null}function gb(a,b,c=null){return a.getChildNodes(b.node,c).map((d,e)=>db(d,b,e))}function hb(a,b){return a.getData(b.node)}
33
+ function ib(a,b,c=null){const d=b.node;cb(d)?a=d.childNodes[0]:((c=a.h.getFirstChild(d,c))&&10===c.nodeType&&(c=a.h.getNextSibling(c)),a=c);return a?db(a,b,0):null}function lb(a,b,c=null){var d=b.node;cb(d)?(a=d.childNodes.length-1,d=d.childNodes[a]):((d=a.h.getLastChild(d,c))&&10===d.nodeType&&(d=a.h.getPreviousSibling(d)),a=a.getChildNodes(b.node,c).length-1);return d?db(d,b,a):null}
34
+ function x(a,b,c=null){const d=b.node,e=b.F;if(e)"number"===typeof e.offset&&d===e.parent.childNodes[e.offset]||"string"===typeof e.offset&&d===e.parent.attributes.find(f=>e.offset===f.nodeName)?(a=e.parent,b=e.F):(a=a.getParentNode(d,c),b=e);else{if(cb(d))return null;a=a.getParentNode(d,c);b=null}return a?{node:a,F:b}:null}
35
+ function mb(a,b,c=null){const d=b.node;let e,f,h;const k=b.F;if(cb(d))k&&(h=k.offset+1,e=k.parent.childNodes[h]);else if(k)h=k.offset+1,f=x(a,b,null),e=a.getChildNodes(f.node,c)[h];else{for(e=d;e&&(!(e=a.h.getNextSibling(e,c))||10===e.nodeType););return e?{node:e,F:null}:null}return e?db(e,f||x(a,b,c),h):null}
36
+ function nb(a,b,c=null){const d=b.node;let e,f;const h=b.F;let k;if(cb(d))h&&(k=h.offset-1,e=h.parent.childNodes[k]);else if(h)k=h.offset-1,f=x(a,b,null),e=a.getChildNodes(f.node,c)[k];else{for(e=d;e&&(!(e=a.h.getPreviousSibling(e,c))||10===e.nodeType););return e?{node:e,F:null}:null}return e?db(e,f||x(a,b,c),k):null}
37
+ var ob=class{constructor(a){this.h=a;this.o=[]}getAllAttributes(a,b=null){return cb(a)?a.attributes:this.h.getAllAttributes(a,b)}getChildNodes(a,b=null){b=cb(a)?a.childNodes:this.h.getChildNodes(a,b);return 9===a.nodeType?b.filter(c=>10!==c.nodeType):b}getData(a){return cb(a)?2===a.nodeType?a.value:a.data:this.h.getData(a)||""}getParentNode(a,b=null){return this.h.getParentNode(a,b)}};var pb=(a,b,c,d,e)=>e.M(([f])=>d.M(([h])=>{const k=f.value;if(0>=k||k>h.members.length)throw Error("FOAY0001: array position out of bounds.");return h.members[k-1]()}));var qb=class extends Va{constructor(a){super({value:(b,c,d,e)=>pb(b,c,d,w.m(this),e),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.members=a}};function rb(a){switch(a.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 sb(a){return{type:rb(a),value:a}};function tb(a,b){a=a.map(c=>c.first());return b(a)};function ub(a,b){var c=v(a.type,1)||v(a.type,20)||v(a.type,19),d=v(b.type,1)||v(b.type,20)||v(b.type,19);if(c&&d)return a.value===b.value;c=v(a.type,4)||v(a.type,3)||v(a.type,6);d=v(b.type,4)||v(b.type,3)||v(b.type,6);if(c&&d)return isNaN(a.value)&&isNaN(b.value)?!0:a.value===b.value;c=v(a.type,0)||v(a.type,22)||v(a.type,18)||v(a.type,23)||v(a.type,44);d=v(b.type,0)||v(b.type,22)||v(b.type,18)||v(b.type,23)||v(b.type,44);return c&&d?a.value===b.value:!1};var vb=(a,b,c,d,e)=>tb([d,e],([f,h])=>(f=f.h.find(k=>ub(k.key,h)))?f.value():w.empty());var wb=class extends Va{constructor(a){super({j:[{type:59,g:3}],arity:1,localName:"get",namespaceURI:"http://www.w3.org/2005/xpath-functions/map",value:(b,c,d,e)=>vb(b,c,d,w.m(this),e),i:{type:59,g:2}});this.type=61;this.h=a}};var xb=class{equals(a){return this.o()===a.o()&&this.v()===a.v()}Za(){return 0}getHours(){return 0}getMinutes(){return 0}$a(){return 0}o(){return 0}v(){return 0}getSeconds(){return 0}ab(){return 0}na(){return!0}h(){return this}};function yb(a){var b=Math.abs(a.Za()),c=Math.abs(a.getHours());const d=Math.abs(a.getMinutes());a=Math.abs(a.getSeconds());b=`${b?`${b}D`:""}`;c=(c?`${c}H`:"")+(d?`${d}M`:"")+(a?`${a}S`:"");return b&&c?`${b}T${c}`:b?b:c?`T${c}`:"T0S"}
38
+ var zb=class extends xb{constructor(a){super();if(a>Number.MAX_SAFE_INTEGER||a<Number.MIN_SAFE_INTEGER)throw Error("FODT0002: Number of seconds given to construct DayTimeDuration overflows MAX_SAFE_INTEGER or MIN_SAFE_INTEGER");this.ba=a}Za(){return Math.trunc(this.ba/86400)}getHours(){return Math.trunc(this.ba%86400/3600)}getMinutes(){return Math.trunc(this.ba%3600/60)}v(){return this.ba}getSeconds(){const a=this.ba%60;return Object.is(-0,a)?0:a}na(){return Object.is(-0,this.ba)?!1:0<=this.ba}h(){return new this.constructor(-this.ba)}toString(){return(this.na()?
39
+ "P":"-P")+yb(this)}},Ab=(a,b,c,d,e,f)=>{a=86400*a+3600*b+60*c+d+e;return new zb(f||0===a?a:-a)},Bb=a=>(a=/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(?:T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.exec(a))?Ab(a[4]?parseInt(a[4],10):0,a[5]?parseInt(a[5],10):0,a[6]?parseInt(a[6],10):0,a[7]?parseInt(a[7],10):0,a[8]?parseFloat(a[8]):0,!a[1]):null,Cb=a=>{a=/^(Z)|([+-])([01]\d):([0-5]\d)$/.exec(a);return"Z"===a[1]?Ab(0,0,0,0,0,!0):Ab(0,a[3]?parseInt(a[3],10):0,a[4]?parseInt(a[4],10):0,0,0,"+"===a[2])};
40
+ function Db(a,b){if(isNaN(b))throw Error("FOCA0005: Cannot multiply xs:dayTimeDuration by NaN");a=a.ba*b;if(a>Number.MAX_SAFE_INTEGER||!Number.isFinite(a))throw Error("FODT0002: Value overflow while multiplying xs:dayTimeDuration");return new zb(a<Number.MIN_SAFE_INTEGER||Object.is(-0,a)?0:a)};function Eb(a){return a?parseInt(a,10):null}function Fb(a){a+="";const b=a.startsWith("-");b&&(a=a.substring(1));return(b?"-":"")+a.padStart(4,"0")}function Gb(a){return(a+"").padStart(2,"0")}function Ib(a){a+="";1===a.split(".")[0].length&&(a=a.padStart(a.length+1,"0"));return a}function Jb(a){return 0===a.getHours()&&0===a.getMinutes()?"Z":(a.na()?"+":"-")+Gb(Math.abs(a.getHours()))+":"+Gb(Math.abs(a.getMinutes()))}
41
+ function Kb(a){var b=/^(?:(-?\d{4,}))?(?:--?(\d\d))?(?:-{1,3}(\d\d))?(T)?(?:(\d\d):(\d\d):(\d\d))?(\.\d+)?(Z|(?:[+-]\d\d:\d\d))?$/.exec(a);a=b[1]?parseInt(b[1],10):null;const c=Eb(b[2]),d=Eb(b[3]),e=b[4],f=Eb(b[5]),h=Eb(b[6]),k=Eb(b[7]),l=b[8]?parseFloat(b[8]):0;b=b[9]?Cb(b[9]):null;if(a&&(-271821>a||273860<a))throw Error("FODT0001: Datetime year is out of bounds");return e?new Lb(a,c,d,f,h,k,l,b,9):null!==f&&null!==h&&null!==k?new Lb(1972,12,31,f,h,k,l,b,8):null!==a&&null!==c&&null!==d?new Lb(a,
42
+ c,d,0,0,0,0,b,7):null!==a&&null!==c?new Lb(a,c,1,0,0,0,0,b,11):null!==c&&null!==d?new Lb(1972,c,d,0,0,0,0,b,13):null!==a?new Lb(a,1,1,0,0,0,0,b,12):null!==c?new Lb(1972,c,1,0,0,0,0,b,14):new Lb(1972,12,d,0,0,0,0,b,15)}
43
+ function Mb(a,b){switch(b){case 15:return new Lb(1972,12,a.o,0,0,0,0,a.W,15);case 14:return new Lb(1972,a.h,1,0,0,0,0,a.W,14);case 12:return new Lb(a.v,1,1,0,0,0,0,a.W,12);case 13:return new Lb(1972,a.h,a.o,0,0,0,0,a.W,13);case 11:return new Lb(a.v,a.h,1,0,0,0,0,a.W,11);case 8:return new Lb(1972,12,31,a.l,a.s,a.D,a.ma,a.W,8);case 7:return new Lb(a.v,a.h,a.o,0,0,0,0,a.W,7);default:return new Lb(a.v,a.h,a.o,a.l,a.s,a.D,a.ma,a.W,9)}}
44
+ function Nb(a,b){b=a.W||b||Cb("Z");return new Date(Date.UTC(a.v,a.h-1,a.o,a.l-b.getHours(),a.s-b.getMinutes(),a.D,1E3*a.ma))}
45
+ var Lb=class{constructor(a,b,c,d,e,f,h,k,l=9){this.v=a;this.h=b;this.o=c+(24===d?1:0);this.l=24===d?0:d;this.s=e;this.D=f;this.ma=h;this.W=k;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 Fb(this.v)+"-"+Gb(this.h)+"-"+Gb(this.o)+"T"+Gb(this.l)+":"+Gb(this.s)+":"+Ib(this.D+this.ma)+(this.W?Jb(this.W):"");case 7:return Fb(this.v)+"-"+Gb(this.h)+
46
+ "-"+Gb(this.o)+(this.W?Jb(this.W):"");case 8:return Gb(this.l)+":"+Gb(this.s)+":"+Ib(this.D+this.ma)+(this.W?Jb(this.W):"");case 15:return"---"+Gb(this.o)+(this.W?Jb(this.W):"");case 14:return"--"+Gb(this.h)+(this.W?Jb(this.W):"");case 13:return"--"+Gb(this.h)+"-"+Gb(this.o)+(this.W?Jb(this.W):"");case 12:return Fb(this.v)+(this.W?Jb(this.W):"");case 11:return Fb(this.v)+"-"+Gb(this.h)+(this.W?Jb(this.W):"")}throw Error("Unexpected subType");}};
47
+ function Ob(a,b,c){const d=Nb(a,c).getTime();c=Nb(b,c).getTime();return d===c?a.ma===b.ma?0:a.ma>b.ma?1:-1:d>c?1:-1}function Pb(a,b,c){return 0===Ob(a,b,c)}function Qb(a,b,c){a=(Nb(a,c).getTime()-Nb(b,c).getTime())/1E3;return new zb(a)}
48
+ function Rb(a,b){function c(y,F){return 2===F?0===y%4&&0!==y%100||0===y%400?29:28:[4,6,9,11].includes(F)?30:31}const d=a.W;let e=a.getYear(),f=a.getMonth(),h=a.getDay(),k=a.getHours(),l=a.getMinutes(),n=a.getSeconds();const t=a.ma;e+=b.ab();for(f+=b.$a();12<f;)f-=12,e+=1;for(;1>f;)f+=12,--e;var u=c(a.getYear(),a.getMonth());u=a.getDay()===u;const z=c(e,f);u&&(h=z);h+=b.Za();k+=b.getHours();l+=b.getMinutes();n+=b.getSeconds();60<=n?(l+=Math.floor(n/60),n%=60):0>n&&(l-=Math.ceil(Math.abs(n)/60),n=(n%
49
+ 60+60)%60);60<=l?(k+=Math.floor(l/60),l%=60):0>l&&(k-=Math.ceil(Math.abs(l)/60),l=(l%60+60)%60);24<=k?(h+=Math.floor(k/24),k%=24):0>k&&(h-=Math.ceil(Math.abs(k)/24),k=(k%24+24)%24);for(;h>c(e,f);)h-=c(e,f),f+=1;for(;1>h;)--f,h+=c(e,f);for(;12<f;)f-=12,e+=1;for(;1>f;)f+=12,--e;return new Lb(e,f,h,k,l,n,t,d,a.type)}function Sb(a,b){return Rb(a,b)}function Tb(a,b){return Rb(a,b.h())};function Ub(a,b){if(null===a)return null;switch(typeof a){case "boolean":return a?va:wa;case "number":return g(a,3);case "string":return g(a,1);case "object":if("nodeType"in a)return sb({node:a,F:null});if(Array.isArray(a))return new qb(a.map(c=>{if(void 0===c)return()=>w.empty();c=Ub(c,b);c=null===c?w.empty():w.m(c);return Ra(c)}));if(a instanceof Date){const c=Kb(a.toISOString());return g(c,c.type)}return new wb(Object.keys(a).filter(c=>void 0!==a[c]).map(c=>{var d=Ub(a[c],b);d=null===d?w.empty():
50
+ w.m(d);return{key:g(c,1),value:Ra(d)}}))}throw Error(`Value ${String(a)} of type "${typeof a}" is not adaptable to an XPath value.`);}function Vb(a,b){if("number"!==typeof a&&("string"!==typeof a||!ta.get(b)(a)))throw Error(`Cannot convert JavaScript value '${a}' to the XPath type ${Da[b]} since it is not valid.`);}
51
+ function Wb(a,b,c){if(null===b)return null;switch(a){case 0:return b?va:wa;case 1:return g(b+"",1);case 3:case 2:return Vb(b,3),g(+b,3);case 4:return Vb(b,a),g(+b,4);case 5:return Vb(b,a),g(b|0,5);case 6:return Vb(b,a),g(+b,6);case 7:case 8:case 9:case 11:case 12:case 13:case 14:case 15:if(!(b instanceof Date))throw Error(`The JavaScript value ${b} with type ${typeof b} is not a valid type to be converted to an XPath ${Da[a]}.`);return g(Mb(Kb(b.toISOString()),a),a);case 53:case 47:case 55:case 54:case 56:case 57:case 58:if("object"!==
52
+ typeof b||!("nodeType"in b))throw Error(`The JavaScript value ${b} with type ${typeof b} is not a valid type to be converted to an XPath ${Da[a]}.`);return sb({node:b,F:null});case 59:return Ub(b,c);case 61:return Ub(b,c);default:throw Error(`Values of the type "${Da[a]}" can not be adapted from JavaScript to equivalent XPath values.`);}}
53
+ function Xb(a,b,c){if(0===c.g)return b=Wb(c.type,b,a),null===b?[]:[b];if(2===c.g||1===c.g){if(!Array.isArray(b))throw Error(`The JavaScript value ${b} should be an array if it is to be converted to ${Ha(c)}.`);return b.map(e=>Wb(c.type,e,a)).filter(e=>null!==e)}const d=Wb(c.type,b,a);if(null===d)throw Error(`The JavaScript value ${b} should be a single entry if it is to be converted to ${Ha(c)}.`);return[d]}function Yb(a,b,c={type:59,g:0}){return w.create(Xb(a,b,c))};var bc=class{constructor(){this.h=Math.abs(Math.floor(Math.random()*ac)%ac)}},ac=2**32;function cc(a,b,c,d){return new dc({L:c,Ba:b,sa:d||a.sa,qa:a.qa},a.h,a.o)}function ec(a,b){let c=0;const d=b.value;return{next:e=>{e=d.next(e);return e.done?p:q(cc(a,c++,e.value,b))}}}function fc(a){a.h.ib||(a.h.ib=!0,a.h.qb=Kb((new Date).toISOString()),a.h.vb=Bb("PT0S"));return a.h.qb}function gc(a){a.h.ib||(a.h.ib=!0,a.h.qb=Kb((new Date).toISOString()),a.h.vb=Bb("PT0S"));return a.h.vb}function hc(a,b=null){a=29421*(null!==b&&void 0!==b?b:a.o.h)%ac;return{rb:Math.floor(a),bc:a/ac}}
54
+ function ic(a,b){return new dc({L:a.L,Ba:a.Ba,sa:a.sa,qa:Object.assign(Object.create(null),a.qa,b)},a.h,a.o)}var dc=class{constructor(a,b={qb:null,vb:null,ib:!1},c=new bc){this.h=b;this.Ba=a.Ba;this.sa=a.sa;this.L=a.L;this.qa=a.qa||Object.create(null);this.o=c}};var jc=class{constructor(a,b,c,d,e,f,h,k,l){this.debug=a;this.Ha=b;this.h=c;this.Ja=d;this.Oa=e;this.o=f;this.v=h;this.jb=k;this.Wa=l}};function kc(a){let b=0,c=null,d=!0;return w.create({next:e=>{for(;b<a.length;){c||(c=a[b].value,d=!0);const f=c.next(d?0:e);d=!1;if(f.done)b++,c=null;else return f}return p}})};var lc=(a,b,c)=>Error(`FORG0001: Cannot cast ${a} to ${Da[b]}${c?`, ${c}`:""}`),mc=a=>Error(`XPDY0002: ${a}`),nc=a=>Error(`XPTY0004: ${a}`),oc=a=>Error(`FOTY0013: Atomization is not supported for ${Da[a]}.`),pc=a=>Error(`XPST0081: The prefix ${a} could not be resolved.`);function qc(a,b){if(v(a.type,46)||v(a.type,19)||v(a.type,0)||v(a.type,4)||v(a.type,3)||v(a.type,6)||v(a.type,5)||v(a.type,2)||v(a.type,23)||v(a.type,1))return w.create(a);const c=b.h;if(v(a.type,53)){const d=a.value;if(2===d.node.nodeType||3===d.node.nodeType)return w.create(g(hb(c,d),19));if(8===d.node.nodeType||7===d.node.nodeType)return w.create(g(hb(c,d),1));const e=[];(function k(h){if(8!==d.node.nodeType&&7!==d.node.nodeType){var l=h.nodeType;3===l||4===l?e.push(c.getData(h)):1!==l&&9!==l&&
55
+ 11!==l||c.getChildNodes(h).forEach(n=>{k(n)})}})(d.node);return w.create(g(e.join(""),19))}if(v(a.type,60)&&!v(a.type,62))throw oc(a.type);if(v(a.type,62))return kc(a.members.map(d=>rc(d(),b)));throw Error(`Atomizing ${a.type} is not implemented.`);}function rc(a,b){let c=!1;const d=a.value;let e=null;return w.create({next:()=>{for(;!c;){if(!e){var f=d.next(0);if(f.done){c=!0;break}e=qc(f.value,b).value}f=e.next(0);if(f.done)e=null;else return f}return p}})};function sc(a){for(a=ua[a];a&&0!==a.C;)a=a.parent;return a?a.type:null}function tc(a,b){b=ua[b];const c=b.La;if(!c||!c.whiteSpace)return b.parent?tc(a,b.parent.type):a;switch(b.La.whiteSpace){case "replace":return a.replace(/[\u0009\u000A\u000D]/g," ");case "collapse":return a.replace(/[\u0009\u000A\u000D]/g," ").replace(/ {2,}/g," ").replace(/^ | $/g,"")}return a}function uc(a,b){for(b=ua[b];b&&null===b.gb;){if(2===b.C||3===b.C)return!0;b=b.parent}return b?b.gb(a):!0}
56
+ function vc(a,b){for(;a;){if(a.Qa&&a.Qa[b])return a.Qa[b];a=a.parent}return()=>!0}function wc(a,b){let c=ua[b];for(;c;){if(c.La&&!Object.keys(c.La).every(d=>{if("whiteSpace"===d)return!0;const e=vc(c,d);return e?e(a,c.La[d]):!0}))return!1;c=c.parent}return!0}function xc(a){return a?2===a.g||0===a.g:!0};function yc(a){return a(1)||a(19)?b=>({u:!0,value:g(b,20)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:anyURI or any of its derived types.")})};function zc(a){return a(22)?b=>{let c="";for(let d=0;d<b.length;d+=2)c+=String.fromCharCode(parseInt(b.substr(d,2),16));return{u:!0,value:g(btoa(c),21)}}:a(1)||a(19)?b=>({u:!0,value:g(b,21)}):()=>({error:Error("XPTY0004: Casting not supported from given type to xs:base64Binary or any of its derived types."),u:!1})};function Ac(a){return a(2)?b=>({u:!0,value:0===b||isNaN(b)?wa:va}):a(1)||a(19)?b=>{switch(b){case "true":case "1":return{u:!0,value:va};case "false":case "0":return{u:!0,value:wa};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.")})};function Ec(a){return a(9)?b=>({u:!0,value:g(Mb(b,7),7)}):a(19)||a(1)?b=>({u:!0,value:g(Kb(b),7)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:date or any of its derived types.")})};function Fc(a){return a(7)?b=>({u:!0,value:g(Mb(b,9),9)}):a(19)||a(1)?b=>({u:!0,value:g(Kb(b),9)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:dateTime or any of its derived types.")})};function Gc(a){return a(18)&&!a(16)?b=>({u:!0,value:g(b.za,17)}):a(16)?()=>({u:!0,value:g(Bb("PT0.0S"),17)}):a(19)||a(1)?b=>{const c=Bb(b);return c?{u:!0,value:g(c,17)}:{u:!1,error:Error(`FORG0001: Can not cast ${b} to xs:dayTimeDuration`)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:dayTimeDuration or any of its derived types.")})};function Hc(a){return a(5)?b=>({u:!0,value:g(b,4)}):a(6)||a(3)?b=>isNaN(b)||!isFinite(b)?{u:!1,error:Error(`FOCA0002: Can not cast ${b} to xs:decimal`)}:Math.abs(b)>Number.MAX_VALUE?{u:!1,error:Error(`FOAR0002: Can not cast ${b} to xs:decimal, it is out of bounds for JavaScript numbers`)}:{u:!0,value:g(b,4)}:a(0)?b=>({u:!0,value:g(b?1:0,4)}):a(1)||a(19)?b=>{const c=parseFloat(b);return!isNaN(c)||isFinite(c)?{u:!0,value:g(c,4)}:{u:!1,error:Error(`FORG0001: Can not cast ${b} to xs:decimal`)}}:()=>({u:!1,
57
+ error:Error("XPTY0004: Casting not supported from given type to xs:decimal or any of its derived types.")})};function Ic(a,b){return a(2)?c=>({u:!0,value:c}):a(0)?c=>({u:!0,value:c?1:0}):a(1)||a(19)?c=>{switch(c){case "NaN":return{u:!0,value:NaN};case "INF":case "+INF":return{u:!0,value:Infinity};case "-INF":return{u:!0,value:-Infinity};case "0":case "+0":return{u:!0,value:0};case "-0":return{u:!0,value:-0}}const d=parseFloat(c);return isNaN(d)?{u:!1,error:lc(c,b)}:{u:!0,value:d}}:()=>({u:!1,error:Error(`XPTY0004: Casting not supported from given type to ${b} or any of its derived types.`)})};function Jc(a){const b=Ic(a,3);return c=>{c=b(c);return c.u?{u:!0,value:g(c.value,3)}:c}};function Kc(a){const b=Math.abs(a.ab());a=Math.abs(a.$a());return`${b?`${b}Y`:""}`+`${a?`${a}M`:""}`||"0M"}
58
+ var Lc=class extends xb{constructor(a){super();if(a>Number.MAX_SAFE_INTEGER||a<Number.MIN_SAFE_INTEGER)throw Error("FODT0002: Number of months given to construct YearMonthDuration overflows MAX_SAFE_INTEGER or MIN_SAFE_INTEGER");this.da=a}$a(){const a=this.da%12;return 0===a?0:a}o(){return this.da}ab(){return Math.trunc(this.da/12)}na(){return Object.is(-0,this.da)?!1:0<=this.da}h(){return new this.constructor(-this.da)}toString(){return(this.na()?"P":"-P")+Kc(this)}},Mc=a=>{var b=/^(-)?P(\d+Y)?(\d+M)?(\d+D)?(?:T(\d+H)?(\d+M)?(\d+(\.\d*)?S)?)?$/.exec(a);
59
+ if(b){a=!b[1];b=12*(b[2]?parseInt(b[2],10):0)+(b[3]?parseInt(b[3],10):0);if(b>Number.MAX_SAFE_INTEGER||!Number.isFinite(b))throw Error("FODT0002: Value overflow while constructing xs:yearMonthDuration");a=new Lc(a||0===b?b:-b)}else a=null;return a};
60
+ function Nc(a,b){if(isNaN(b))throw Error("FOCA0005: Cannot multiply xs:yearMonthDuration by NaN");a=Math.round(a.da*b);if(a>Number.MAX_SAFE_INTEGER||!Number.isFinite(a))throw Error("FODT0002: Value overflow while constructing xs:yearMonthDuration");return new Lc(a<Number.MIN_SAFE_INTEGER||0===a?0:a)};var Oc=class extends xb{constructor(a,b){super();this.Na=a;this.za=b}Za(){return this.za.Za()}getHours(){return this.za.getHours()}getMinutes(){return this.za.getMinutes()}$a(){return this.Na.$a()}o(){return this.Na.o()}v(){return this.za.v()}getSeconds(){return this.za.getSeconds()}ab(){return this.Na.ab()}na(){return this.Na.na()&&this.za.na()}h(){return new this.constructor(this.Na.h(),this.za.h())}toString(){const a=this.na()?"P":"-P",b=Kc(this.Na),c=yb(this.za);return"0M"===b?a+c:"T0S"===c?a+
61
+ b:a+b+c}};function Pc(a){return a(16)?b=>({u:!0,value:g(new Oc(b,new zb(b.na()?0:-0)),18)}):a(17)?b=>{b=new Oc(new Lc(b.na()?0:-0),b);return{u:!0,value:g(b,18)}}:a(18)?b=>({u:!0,value:g(b,18)}):a(19)||a(1)?b=>{var c;return c=new Oc(Mc(b),Bb(b)),{u:!0,value:g(c,18)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:duration or any of its derived types.")})};function Qc(a){const b=Ic(a,6);return c=>{c=b(c);return c.u?{u:!0,value:g(c.value,6)}:c}};function Rc(a){return a(7)||a(9)?b=>({u:!0,value:g(Mb(b,15),15)}):a(19)||a(1)?b=>({u:!0,value:g(Kb(b),15)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gDay or any of its derived types.")})};function Sc(a){return a(7)||a(9)?b=>({u:!0,value:g(Mb(b,14),14)}):a(19)||a(1)?b=>({u:!0,value:g(Kb(b),14)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gMonth or any of its derived types.")})};function Tc(a){return a(7)||a(9)?b=>({u:!0,value:g(Mb(b,13),13)}):a(19)||a(1)?b=>({u:!0,value:g(Kb(b),13)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gMonthDay or any of its derived types.")})};function Uc(a){return a(7)||a(9)?b=>({u:!0,value:g(Mb(b,12),12)}):a(19)||a(1)?b=>({u:!0,value:g(Kb(b),12)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gYear or any of its derived types.")})};function Vc(a){return a(7)||a(9)?b=>({u:!0,value:g(Mb(b,11),11)}):a(19)||a(1)?b=>({u:!0,value:g(Kb(b),11)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:gYearMonth or any of its derived types.")})};function Wc(a){return a(21)?b=>{b=atob(b);let c="";for(let d=0,e=b.length;d<e;d++)c+=Number(b.charCodeAt(d)).toString(16);return{u:!0,value:g(c.toUpperCase(),22)}}:a(1)||a(19)?b=>({u:!0,value:g(b,22)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:hexBinary or any of its derived types.")})};function Xc(a){return a(0)?b=>({u:!0,value:g(b?1:0,5)}):a(2)?b=>{const c=Math.trunc(b);return!isFinite(c)||isNaN(c)?{u:!1,error:Error(`FOCA0002: can not cast ${b} to xs:integer`)}:Number.isSafeInteger(c)?{u:!0,value:g(c,5)}:{u:!1,error:Error(`FOAR0002: can not cast ${b} to xs:integer, it is out of bounds for JavaScript numbers.`)}}:a(1)||a(19)?b=>{const c=parseInt(b,10);return isNaN(c)?{u:!1,error:lc(b,5)}:Number.isSafeInteger(c)?{u:!0,value:g(c,5)}:{u:!1,error:Error(`FOCA0003: can not cast ${b} to xs:integer, it is out of bounds for JavaScript numbers.`)}}:
62
+ ()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:integer or any of its derived types.")})};const Yc=[3,6,4,5];function Zc(a){var b=$c;return c=>{for(const d of Yc){const e=b(a,d)(c);if(e.u)return e}return{u:!1,error:Error(`XPTY0004: Casting not supported from "${c}" given type to xs:numeric or any of its derived types.`)}}};function ad(a){if(a(1)||a(19))return b=>({u:!0,value:b+""});if(a(20))return b=>({u:!0,value:b});if(a(23))return b=>({u:!0,value:b.prefix?`${b.prefix}:${b.localName}`:b.localName});if(a(44))return b=>({u:!0,value:b.toString()});if(a(2)){if(a(5)||a(4))return b=>({u:!0,value:(b+"").replace("e","E")});if(a(6)||a(3))return b=>isNaN(b)?{u:!0,value:"NaN"}:isFinite(b)?Object.is(b,-0)?{u:!0,value:"-0"}:{u:!0,value:(b+"").replace("e","E").replace("E+","E")}:{u:!0,value:`${0>b?"-":""}INF`}}return a(9)||a(7)||
63
+ a(8)||a(15)||a(14)||a(13)||a(12)||a(11)?b=>({u:!0,value:b.toString()}):a(16)?b=>({u:!0,value:b.toString()}):a(17)?b=>({u:!0,value:b.toString()}):a(18)?b=>({u:!0,value:b.toString()}):a(22)?b=>({u:!0,value:b.toUpperCase()}):b=>({u:!0,value:b+""})};function bd(a){const b=ad(a);return c=>{c=b(c);return c.u?{u:!0,value:g(c.value,1)}:c}};function cd(a){return a(9)?b=>({u:!0,value:g(Mb(b,8),8)}):a(19)||a(1)?b=>({u:!0,value:g(Kb(b),8)}):()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:time or any of its derived types.")})};function dd(a){const b=ad(a);return c=>{c=b(c);return c.u?{u:!0,value:g(c.value,19)}:c}};function ed(a){return a(18)&&!a(17)?b=>({u:!0,value:g(b.Na,16)}):a(17)?()=>({u:!0,value:g(Mc("P0M"),16)}):a(19)||a(1)?b=>{const c=Mc(b);return c?{u:!0,value:g(c,16)}:{u:!1,error:lc(b,16)}}:()=>({u:!1,error:Error("XPTY0004: Casting not supported from given type to xs:yearMonthDuration or any of its derived types.")})};const fd=[2,5,17,16];
64
+ function $c(a,b){const c=d=>v(a,d);if(39===b)return()=>({u:!1,error:Error("FORG0001: Casting to xs:error is always invalid.")});switch(b){case 19:return dd(c);case 1:return bd(c);case 6:return Qc(c);case 3:return Jc(c);case 4:return Hc(c);case 5:return Xc(c);case 2:return Zc(a);case 18:return Pc(c);case 16:return ed(c);case 17:return Gc(c);case 9:return Fc(c);case 8:return cd(c);case 7:return Ec(c);case 11:return Vc(c);case 12:return Uc(c);case 13:return Tc(c);case 15:return Rc(c);case 14:return Sc(c);
65
+ case 0:return Ac(c);case 21:return zc(c);case 22:return Wc(c);case 20:return yc(c);case 23:throw Error("Casting to xs:QName is not implemented.");}return()=>({u:!1,error:Error(`XPTY0004: Casting not supported from ${a} to ${b}.`)})}const gd=Object.create(null);
66
+ function id(a,b){if(19===a&&1===b)return f=>({u:!0,value:g(f,1)});if(44===b)return()=>({u:!1,error:Error("XPST0080: Casting to xs:NOTATION is not permitted.")});if(39===b)return()=>({u:!1,error:Error("FORG0001: Casting to xs:error is not permitted.")});if(45===a||45===b)return()=>({u:!1,error:Error("XPST0080: Casting from or to xs:anySimpleType is not permitted.")});if(46===a||46===b)return()=>({u:!1,error:Error("XPST0080: Casting from or to xs:anyAtomicType is not permitted.")});if(v(a,60)&&1===
67
+ b)return()=>({u:!1,error:Error("FOTY0014: Casting from function item to xs:string is not permitted.")});if(a===b)return f=>({u:!0,value:{type:b,value:f}});const c=fd.includes(a)?a:sc(a),d=fd.includes(b)?b:sc(b);if(null===d||null===c)return()=>({u:!1,error:Error(`XPST0081: Can not cast: type ${d?Da[a]:Da[b]} is unknown.`)});const e=[];1!==c&&19!==c||e.push(f=>{const h=tc(f,b);return uc(h,b)?{u:!0,value:h}:{u:!1,error:lc(f,b,"pattern validation failed.")}});c!==d&&(e.push($c(c,d)),e.push(f=>({u:!0,
68
+ value:f.value})));19!==d&&1!==d||e.push(f=>uc(f,b)?{u:!0,value:f}:{u:!1,error:lc(f,b,"pattern validation failed.")});e.push(f=>wc(f,b)?{u:!0,value:f}:{u:!1,error:lc(f,b,"pattern validation failed.")});e.push(f=>({u:!0,value:{type:b,value:f}}));return f=>{f={u:!0,value:f};for(let h=0,k=e.length;h<k&&(f=e[h](f.value),!1!==f.u);++h);return f}}function jd(a,b){const c=a.type+1E4*b;let d=gd[c];d||=gd[c]=id(a.type,b);return d.call(void 0,a.value,b)};function kd(a,b){a=jd(a,b);if(!0===a.u)return a.value;throw a.error;};function ld(a){let b=!1;return{next:()=>{if(b)return p;b=!0;return q(a)}}};function md(a,b){return a===b?!0:a&&b&&a.offset===b.offset&&a.parent===b.parent?md(a.F,b.F):!1}function nd(a,b){return a===b||a.node===b.node&&md(a.F,b.F)?!0:!1};function od(a,b,c){var d=x(a,b,null);a=gb(a,d,null);for(let e=0,f=a.length;e<f;++e){d=a[e];if(nd(d,b))return-1;if(nd(d,c))return 1}}function pd(a,b){const c=[];for(;b;b=x(a,b,null))c.unshift(b);return c}function qd(a,b){const c=[];for(;b;b=a.getParentNode(b,null))c.unshift(b);return c}
69
+ function rd(a,b,c,d){if(c.F||d.F||cb(c.node)||cb(d.node)){if(nd(c,d))return 0;c=pd(b,c);d=pd(b,d);const f=c[0],h=d[0];if(!nd(f,h))return b=a.findIndex(k=>nd(k,f)),c=a.findIndex(k=>nd(k,h)),-1===b&&(b=a.push(f)),-1===c&&(c=a.push(h)),b-c;a=1;for(var e=Math.min(c.length,d.length);a<e&&nd(c[a],d[a]);++a);return c[a]?d[a]?od(b,c[a],d[a]):1:-1}c=c.node;e=d.node;if(c===e)return 0;d=qd(b,c);c=qd(b,e);if(d[0]!==c[0]){const f={node:d[0],F:null},h={node:c[0],F:null};b=a.findIndex(k=>nd(k,f));c=a.findIndex(k=>
70
+ nd(k,h));-1===b&&(b=a.push(f));-1===c&&(c=a.push(h));return b-c}a=1;for(e=Math.min(d.length,c.length);a<e&&d[a]===c[a];++a);d=d[a];e=c[a];if(!d)return-1;if(!e)return 1;b=b.getChildNodes(c[a-1],null);for(let f=0,h=b.length;f<h;++f){a=b[f];if(a===d)return-1;if(a===e)return 1}}
71
+ function sd(a,b,c,d){const e=v(c.type,47),f=v(d.type,47);if(e&&!f){if(c=x(b,c.value),d=d.value,nd(c,d))return 1}else if(f&&!e){if(c=c.value,d=x(b,d.value),nd(c,d))return-1}else if(e&&f){if(nd(x(b,d.value),x(b,c.value)))return c.value.node.localName>d.value.node.localName?1:-1;c=x(b,c.value);d=x(b,d.value)}else c=c.value,d=d.value;return rd(a,b,c,d)}function td(a,b,c){return sd(a.o,a,b,c)}function ud(a,b){return vd(b,(c,d)=>sd(a.o,a,c,d)).filter((c,d,e)=>0===d?!0:!nd(c.value,e[d-1].value))}
72
+ const wd=(a,b)=>a<b?-1:0;function vd(a,b=wd){if(1>=a.length)return a;var c=Math.floor(a.length/2);const d=vd(a.slice(0,c),b);a=vd(a.slice(c),b);for(c=[];d.length&&a.length;)0>b(d[0],a[0])?c.push(d.shift()):c.push(a.shift());return c.concat(d.concat(a))};function xd(a,b){if(v(a.type,2)){if(v(a.type,6))return 3===b?g(a.value,3):null;if(v(a.type,4)){if(6===b)return g(a.value,6);if(3===b)return g(a.value,3)}return null}return v(a.type,20)&&1===b?g(a.value,1):null};function yd(a,b,c,d,e){if(v(a.type,b.type))return a;v(b.type,46)&&v(a.type,53)&&(a=qc(a,c).first());if(v(a.type,b.type)||46===b.type)return a;if(v(a.type,19)){c=kd(a,b.type);if(!c)throw Error(`XPTY0004 Unable to convert ${e?"return":"argument"} of type ${Da[a.type]} to type ${Ha(b)} while calling ${d}`);return c}c=xd(a,b.type);if(!c)throw Error(`XPTY0004 Unable to cast ${e?"return":"argument"} of type ${Da[a.type]} to type ${Ha(b)} while calling ${d}`);return c}
73
+ function zd(a){switch(a){case 2:return"*";case 1:return"+";case 0:return"?";case 3:return""}}
74
+ var Ad=(a,b,c,d,e)=>0===a.g?b.X({default:()=>b.map(f=>yd(f,a,c,d,e)),multiple:()=>{throw Error(`XPTY0004: Multiplicity of ${e?"function return value":"function argument"} of type ${Da[a.type]}${zd(a.g)} for ${d} is incorrect. Expected "?", but got "+".`);}}):1===a.g?b.X({empty:()=>{throw Error(`XPTY0004: Multiplicity of ${e?"function return value":"function argument"} of type ${Da[a.type]}${zd(a.g)} for ${d} is incorrect. Expected "+", but got "empty-sequence()"`);},default:()=>b.map(f=>yd(f,a,c,
75
+ d,e))}):2===a.g?b.map(f=>yd(f,a,c,d,e)):b.X({m:()=>b.map(f=>yd(f,a,c,d,e)),default:()=>{throw Error(`XPTY0004: Multiplicity of ${e?"function return value":"function argument"} of type ${Da[a.type]}${zd(a.g)} for ${d} is incorrect. Expected exactly one`);}});function Bd(a,b,c){return(d,e,f)=>{if(null===d.L)throw mc(`The function ${a} depends on dynamic context, which is absent.`);const h=Ad({type:b,g:3},w.m(d.L),e,a,!1);return c(d,e,f,h)}};var Cd=xspattern;function Dd(a,b){return v(a,5)?g(b,5):v(a,6)?g(b,6):v(a,3)?g(b,3):g(b,4)}const Ed=[{ka:"M",ia:1E3},{ka:"CM",ia:900},{ka:"D",ia:500},{ka:"CD",ia:400},{ka:"C",ia:100},{ka:"XC",ia:90},{ka:"L",ia:50},{ka:"XL",ia:40},{ka:"X",ia:10},{ka:"IX",ia:9},{ka:"V",ia:5},{ka:"IV",ia:4},{ka:"I",ia:1}];function Fd(a,b){const c=0>a;a=Math.abs(a);if(!a)return"-";let d=Ed.reduce((e,f)=>{const h=Math.floor(a/f.ia);a-=h*f.ia;return e+f.ka.repeat(h)},"");b&&(d=d.toLowerCase());c&&(d=`-${d}`);return d}const Gd="ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
76
+ function Hd(a,b){const c=0>a;a=Math.abs(a);if(!a)return"-";let d="",e;for(;0<a;)e=(a-1)%Gd.length,d=Gd[e]+d,a=(a-e)/Gd.length|0;b&&(d=d.toLowerCase());c&&(d=`-${d}`);return d}function Id(a,b,c=[]){return Array.from({length:b},(d,e)=>e+a).filter(d=>!c.includes(d))}
77
+ const Jd=Id(1488,27,[1498,1501,1503,1507,1509]),Kd=Id(1575,36,[1577,1595,1596,1597,1598,1599,1600,1609]),Ld="\u0623\u0628\u062c\u062f\u0647\u0648\u0632\u062d\u0637\u064a\u0643\u0644\u0645\u0646\u0633\u0639\u0641\u0635\u0642\u0631\u0634\u062a\u062b\u062e\u0630\u0636\u0638\u063a".split(""),Md=[[1E3,"\u063a"],[900,"\u0638"],[800,"\u0636"],[700,"\u0630"],[600,"\u062e"],[500,"\u062b"],[400,"\u062a"],[300,"\u0634"],[200,"\u0631"],[100,"\u0642"],[90,"\u0635"],[80,"\u0641"],[70,"\u0639"],[60,"\u0633"],[50,
78
+ "\u0646"],[40,"\u0645"],[30,"\u0644"],[20,"\u0643"],[10,"\u064a"],[9,"\u0637"],[8,"\u062d"],[7,"\u0632"],[6,"\u0648"],[5,"\u0647"],[4,"\u062f"],[3,"\u062c"],[2,"\u0628"],[1,"\u0623"]],Nd=[[400,"\u05ea"],[300,"\u05e9"],[200,"\u05e8"],[100,"\u05e7"],[90,"\u05e6"],[80,"\u05e4"],[70,"\u05e2"],[60,"\u05e1"],[50,"\u05e0"],[40,"\u05de"],[30,"\u05dc"],[20,"\u05db"],[10,"\u05d9"],[9,"\u05d8"],[8,"\u05d7"],[7,"\u05d6"],[6,"\u05d5"],[5,"\u05d4"],[4,"\u05d3"],[3,"\u05d2"],[2,"\u05d1"],[1,"\u05d0"]];
79
+ function Od(a,b=[]){var c=25;b.sort((d,e)=>d-e);c-=b.length;return function(d){const e=0>d;d=Math.abs(d);if(!d)return"-";const f=[];for(;0<d;){let h=a+(d-1)%c;b.forEach(k=>{h>=k&&h++});f.unshift(String.fromCodePoint(h));d=Math.floor((d-1)/c)}d=f.join("");e&&(d=`-${d}`);return d}}const Pd=Od(945,[962]),Qd=Od(913,[930]);function Rd(a){return(new Intl.NumberFormat([],{numberingSystem:"arab",useGrouping:!1})).format(a)}
80
+ function Sd(a){return(new Intl.NumberFormat([],{numberingSystem:"arabext",useGrouping:!1})).format(a)}
81
+ const Td=new Map([["A",function(a){return Hd(a,!1)}],["a",function(a){return Hd(a,!0)}],["I",function(a){return Fd(a,!1)}],["i",function(a){return Fd(a,!0)}],["lowerGreek",Pd],["\u03b1",Pd],["upperGreek",Qd],["\u0391",Qd],["arabicAbjadi",function(a){const b=0>a;a=Math.abs(a);if(!a)return"-";a=Array(Math.floor((a-1)/Ld.length)+1).fill(Ld[(a-1)%Ld.length]).join(String.fromCodePoint(8204));b&&(a=`-${a}`);return a}],["arabicAbjadNumeral",function(a){const b=0>a;a=Math.abs(a);if(!a)return"-";var c=[],
82
+ d=Math.floor(a/1E3);a-=1E3*d;if(1===d)c.push(Md[0][1]);else if(1<d){for(const [f,h]of Md){var e=f;const k=h;for(;d>=e;)c.push(k),d-=e}c.push(Md[0][1])}for(const [f,h]of Md)for(d=f,e=h;a>=d;)a-=d,c.push(e);c=c.join("");b&&(c=`-${c}`);return c}],["arabicAlifBaTa",function(a){const b=0>a;a=Math.abs(a);if(!a)return"-";a=Array(Math.floor((a-1)/Kd.length)+1).fill(String.fromCodePoint(Kd[(a-1)%Kd.length])).join(String.fromCodePoint(8204));b&&(a=`-${a}`);return a}],["hebrewAlefBet",function(a){const b=0>
83
+ a;a=Math.abs(a);if(!a)return"-";var c=Math.floor((a-1)/Jd.length);const d=String.fromCodePoint(1514);c=Array(c).fill(d);c.push(String.fromCodePoint(Jd[(a-1)%Jd.length]));a=c.join("");b&&(a=`-${a}`);return a}],["hebrewNumeral",function(a){const b=0>a;a=Math.abs(a);if(!a)return"-";var c=[],d=Math.floor(a/400);a-=400*d;for(var e=0;e<d;e++)c.push("\u05ea");for(const [f,h]of Nd)for(d=f,e=h;a>=d;)a-=d,c.push(e);a=c.slice(-2).join("");"\u05d9\u05d4"===a&&c.splice(-2,2,"\u05d8","\u05d5");"\u05d9\u05d5"===
84
+ a&&c.splice(-2,2,"\u05d8","\u05d6");c=c.join("");b&&(c=`-${c}`);return c}],["arabicIndicNumeral",Rd],["\u0661",Rd],["\u0662",Rd],["\u0663",Rd],["\u0664",Rd],["\u0665",Rd],["\u0666",Rd],["\u0667",Rd],["\u0668",Rd],["\u0669",Rd],["persianNumeral",Sd],["\u06f1",Sd],["\u06f2",Sd],["\u06f3",Sd],["\u06f4",Sd],["\u06f5",Sd],["\u06f6",Sd],["\u06f7",Sd],["\u06f8",Sd],["\u06f9",Sd]]);
85
+ function Ud(a){if(Math.floor(a)===a||isNaN(a))return 0;a=/\d+(?:\.(\d*))?(?:[Ee](-)?(\d+))*/.exec(`${a}`);const b=a[1]?a[1].length:0;if(a[3]){if(a[2])return b+parseInt(a[3],10);a=b-parseInt(a[3],10);return 0>a?0:a}return b}function Vd(a,b,c){return b&&0===a*c%1%.5?0===Math.floor(a*c)%2?Math.floor(a*c)/c:Math.ceil(a*c)/c:Math.round(a*c)/c}
86
+ function Wd(a,b,c,d,e,f){let h=!1;return w.create({next:()=>{if(h)return p;const k=e.first();if(!k)return h=!0,p;if((v(k.type,6)||v(k.type,3))&&(0===k.value||isNaN(k.value)||Infinity===k.value||-Infinity===k.value))return h=!0,q(k);var l;f?l=f.first().value:l=0;h=!0;if(Ud(k.value)<l)return q(k);const n=[5,4,3,6].find(u=>v(k.type,u)),t=kd(k,4);l=Vd(t.value,a,Math.pow(10,l));switch(n){case 4:return q(g(l,4));case 3:return q(g(l,3));case 6:return q(g(l,6));case 5:return q(g(l,5))}}})}
87
+ const Xd=(a,b,c,d)=>rc(d,b).X({empty:()=>w.m(g(NaN,3)),m:()=>{const e=jd(d.first(),3);return e.u?w.m(e.value):w.m(g(NaN,3))},multiple:()=>{throw Error("fn:number may only be called with zero or one values");}});function Yd(a){let b=5381;for(let c=0;c<a.length;++c)b=33*b+a.charCodeAt(c),b%=Number.MAX_SAFE_INTEGER;return b}
88
+ const Zd=(a,b,c,d=w.empty())=>{function e(f){const h=(k,l,n,t)=>{if(t.isEmpty()||t.oa())return t;k=t.N();l=f;for(n=k.length-1;1<n;n--){l=hc(a,l).rb;t=l%n;const u=k[t];k[t]=k[n];k[n]=u}return w.create(k)};return w.m(new wb([{key:g("number",1),value:()=>w.m(g(hc(a,f).bc,3))},{key:g("next",1),value:()=>w.m(new Va({value:()=>e(hc(a,f).rb),bb:!0,localName:"",namespaceURI:"",j:[],arity:0,i:{type:61,g:3}}))},{key:g("permute",1),value:()=>w.m(new Va({value:h,bb:!0,localName:"",namespaceURI:"",j:[{type:59,
89
+ g:2}],arity:1,i:{type:59,g:2}}))}]))}b=d.isEmpty()?hc(a):hc(a,Yd(kd(d.first(),1).value));return e(b.rb)};
90
+ var $d=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"abs",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:(a,b,c,d)=>d.map(e=>Dd(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:(a,b,c,d,e)=>{a=d.first();e=e.first();if(d.isEmpty())return w.m(g("",1));d=Td.get(e.value);e=a.value;return d?(d=d(e),w.m(g(d,1))):w.m(g(e.toString(),1))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
91
+ localName:"ceiling",j:[{type:2,g:0}],i:{type:2,g:0},callFunction:(a,b,c,d)=>d.map(e=>Dd(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:(a,b,c,d)=>d.map(e=>Dd(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:Wd.bind(null,!1)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"round",j:[{type:2,
92
+ g:0},{type:5,g:3}],i:{type:2,g:0},callFunction:Wd.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:Wd.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:Wd.bind(null,!0)},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"number",j:[{type:46,g:0}],i:{type:3,g:3},callFunction:Xd},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
93
+ localName:"number",j:[],i:{type:3,g:3},callFunction:(a,b,c)=>{const d=a.L&&Ad({type:46,g:0},w.m(a.L),b,"fn:number",!1);if(!d)throw mc("fn:number needs an atomizable context item.");return Xd(a,b,c,d)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"random-number-generator",j:[],i:{type:61,g:3},callFunction:Zd},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"random-number-generator",j:[{type:46,g:0}],i:{type:61,g:3},callFunction:Zd}];function ae(){throw Error("FOCH0002: No collations are supported");}
94
+ const be=(a,b,c,d)=>d.X({empty:()=>w.m(g("",1)),default:()=>d.map(e=>{if(v(e.type,53)){const f=qc(e,b).first();return v(e.type,47)?kd(f,1):f}return kd(e,1)})}),de=(a,b,c,d,e)=>tb([e],([f])=>rc(d,b).M(h=>{h=h.map(k=>kd(k,1).value).join(f.value);return w.m(g(h,1))})),ee=(a,b,c,d)=>{if(d.isEmpty())return w.m(g(0,5));a=d.first().value;return w.m(g(Array.from(a).length,5))},fe=(a,b,c,d,e,f)=>{const h=Wd(!1,a,b,c,e,null),k=null!==f?Wd(!1,a,b,c,f,null):null;let l=!1,n=null,t=null,u=null;return w.create({next:()=>
95
+ {if(l)return p;if(!n&&(n=d.first(),null===n))return l=!0,q(g("",1));t||=h.first();!u&&f&&(u=null,u=k.first());l=!0;return q(g(Array.from(n.value).slice(Math.max(t.value-1,0),f?t.value+u.value-1:void 0).join(""),1))}})},he=(a,b,c,d,e)=>{if(d.isEmpty()||0===d.first().value.length)return w.empty();a=d.first().value;e=e.first().value;e=ge(e);e.lastIndex=0;b=[];c=e.exec(a);for(d=0;c;)b.push(a.slice(d,c.index)),d=e.lastIndex,c=e.exec(a);b.push(a.slice(d));return w.create(b.map(f=>g(f,1)))},ie=(a,b,c,d)=>
96
+ {if(d.isEmpty())return w.m(g("",1));a=d.first().value.trim();return w.m(g(a.replace(/\s+/g," "),1))},je=new Map,ke=new Map;function ge(a){if(ke.has(a))return ke.get(a);let b;try{b=new RegExp(a,"g")}catch(c){throw Error(`FORX0002: ${c}`);}if(b.test(""))throw Error(`FORX0003: the pattern ${a} matches the zero length string`);ke.set(a,b);return b}
97
+ var le=[{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:(a,b,c,d,e)=>{if(d.isEmpty()||e.isEmpty())return w.empty();a=d.first().value;e=e.first().value;return a>e?w.m(g(1,5)):a<e?w.m(g(-1,5)):w.m(g(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:ae},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"concat",
98
+ j:[{type:46,g:0},{type:46,g:0},4],i:{type:1,g:3},callFunction:(a,b,c,...d)=>{d=d.map(e=>rc(e,b).M(f=>w.m(g(f.map(h=>null===h?"":kd(h,1).value).join(""),1))));return tb(d,e=>w.m(g(e.map(f=>f.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:ae},{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:(a,
99
+ b,c,d,e)=>{a=d.isEmpty()?"":d.first().value;e=e.isEmpty()?"":e.first().value;return 0===e.length?w.$():0===a.length?w.S():a.includes(e)?w.$():w.S()}},{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:(a,b,c,d,e)=>{a=e.isEmpty()?"":e.first().value;if(0===a.length)return w.$();d=d.isEmpty()?"":d.first().value;return 0===d.length?w.S():d.endsWith(a)?w.$():w.S()}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
100
+ localName:"ends-with",j:[{type:1,g:0},{type:1,g:0},{type:1,g:3}],i:{type:0,g:3},callFunction:ae},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"normalize-space",j:[{type:1,g:0}],i:{type:1,g:3},callFunction:ie},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"normalize-space",j:[],i:{type:1,g:3},callFunction:Bd("normalize-space",1,(a,b,c,d)=>ie(a,b,c,be(a,b,c,d)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"starts-with",j:[{type:1,g:0},{type:1,
101
+ g:0}],i:{type:0,g:3},callFunction:(a,b,c,d,e)=>{a=e.isEmpty()?"":e.first().value;if(0===a.length)return w.$();d=d.isEmpty()?"":d.first().value;return 0===d.length?w.S():d.startsWith(a)?w.$():w.S()}},{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:ae},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string",j:[{type:59,g:0}],i:{type:1,g:3},callFunction:be},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
102
+ localName:"string",j:[],i:{type:1,g:3},callFunction:Bd("string",59,be)},{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:(a,b,c,d,e)=>{a=d.isEmpty()?"":d.first().value;e=e.isEmpty()?"":e.first().value;if(""===e)return w.m(g("",1));e=a.indexOf(e);return-1===e?w.m(g("",1)):w.m(g(a.substring(0,e),1))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"substring-after",j:[{type:1,g:0},{type:1,
103
+ g:0}],i:{type:1,g:3},callFunction:(a,b,c,d,e)=>{a=d.isEmpty()?"":d.first().value;e=e.isEmpty()?"":e.first().value;if(""===e)return w.m(g(a,1));b=a.indexOf(e);return-1===b?w.m(g("",1)):w.m(g(a.substring(b+e.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:fe},{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:fe},
104
+ {namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"upper-case",j:[{type:1,g:0}],i:{type:1,g:3},callFunction:(a,b,c,d)=>d.isEmpty()?w.m(g("",1)):d.map(e=>g(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:(a,b,c,d)=>d.isEmpty()?w.m(g("",1)):d.map(e=>g(e.value.toLowerCase(),1))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-join",j:[{type:46,g:2},{type:1,g:3}],
105
+ i:{type:1,g:3},callFunction:de},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-join",j:[{type:46,g:2}],i:{type:1,g:3},callFunction(a,b,c,d){return de(a,b,c,d,w.m(g("",1)))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-length",j:[{type:1,g:0}],i:{type:5,g:3},callFunction:ee},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"string-length",j:[],i:{type:5,g:3},callFunction:Bd("string-length",46,(a,b,c,d)=>ee(a,b,c,be(a,b,c,d)))},
106
+ {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:he},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"tokenize",j:[{type:1,g:0}],i:{type:1,g:2},callFunction(a,b,c,d){return he(a,
107
+ b,c,ie(a,b,c,d),w.m(g(" ",1)))}},{j:[{type:1,g:0},{type:1,g:3},{type:1,g:3}],callFunction:(a,b,c,d,e,f)=>tb([d,e,f],([h,k,l])=>{h=Array.from(h?h.value:"");const n=Array.from(k.value),t=Array.from(l.value);k=h.map(u=>{if(n.includes(u)){if(u=n.indexOf(u),u<=t.length)return t[u]}else return u});return w.m(g(k.join(""),1))}),localName:"translate",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:5,g:2}],callFunction:(a,b,c,d)=>d.M(e=>{e=e.map(f=>{f=f.value;if(9===f||10===
108
+ f||13===f||32<=f&&55295>=f||57344<=f&&65533>=f||65536<=f&&1114111>=f)return String.fromCodePoint(f);throw Error("FOCH0001");}).join("");return w.m(g(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:(a,b,c,d)=>tb([d],([e])=>{e=e?e.value.split(""):[];return 0===e.length?w.empty():w.create(e.map(f=>g(f.codePointAt(0),5)))}),localName:"string-to-codepoints",namespaceURI:"http://www.w3.org/2005/xpath-functions",
109
+ i:{type:5,g:2}},{j:[{type:1,g:0}],callFunction:(a,b,c,d)=>tb([d],([e])=>null===e||0===e.value.length?w.create(g("",1)):w.create(g(encodeURIComponent(e.value).replace(/[!'()*]/g,f=>"%"+f.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:(a,b,c,d)=>tb([d],([e])=>null===e||0===e.value.length?w.create(g("",1)):w.create(g(e.value.replace(/([\u00A0-\uD7FF\uE000-\uFDCF\uFDF0-\uFFEF "<>{}|\\^`/\n\u007f\u0080-\u009f]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g,
110
+ f=>encodeURI(f)),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:(a,b,c,d,e)=>tb([d,e],([f,h])=>{if(null===f||null===h)return w.empty();f=f.value;var k=h.value;if(f.length!==k.length)return w.S();h=f.split("");f=k.split("");for(k=0;k<h.length;k++)if(h[k].codePointAt(0)!==f[k].codePointAt(0))return w.S();return w.$()}),localName:"codepoint-equal",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,
111
+ g:0}},{j:[{type:1,g:0},{type:1,g:3}],callFunction:(a,b,c,d,e)=>tb([d,e],([f,h])=>{f=f?f.value:"";h=h.value;let k=je.get(h);if(!k){try{k=(0,Cd.compile)(h,{language:"xpath"})}catch(l){throw Error(`FORX0002: ${l}`);}je.set(h,k)}return k(f)?w.$():w.S()}),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:(a,b,c,d,e,f)=>tb([d,e,f],([h,k,l])=>{h=h?h.value:"";k=k.value;l=l.value;if(l.includes("$0"))throw Error("Using $0 in fn:replace to replace substrings with full matches is not supported.");
112
+ l=l.split(/((?:\$\$)|(?:\\\$)|(?:\\\\))/).map(n=>{switch(n){case "\\$":return"$$";case "\\\\":return"\\";case "$$":throw Error('FORX0004: invalid replacement: "$$"');default:return n}}).join("");k=ge(k);h=h.replace(k,l);return w.m(g(h,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");
113
+ }}];const me=new WeakMap;let ne=0;const oe=(a,b,c,d)=>tb([d],([e])=>{if(null===e)return w.empty();e=e.value;switch(e.node.nodeType){case 1:case 2:return w.m(g(new Sa(e.node.prefix,e.node.namespaceURI,e.node.localName),23));case 7:return w.m(g(new Sa("","",e.node.target),23));default:return w.empty()}}),pe=(a,b,c,d)=>d.X({default:()=>be(a,b,c,oe(a,b,c,d)),empty:()=>w.m(g("",1))}),qe=(a,b,c,d)=>rc(d,b),re=(a,b,c,d)=>{if(d.isEmpty())return w.m(g("",1));if(!v(d.first().type,53))throw Error("XPTY0004: The context item must be a node.");
114
+ c=d.first().value;a=w;b=a.m;c=c.node;me.has(c)||me.set(c,`id${++ne}`);c=me.get(c);return b.call(a,g(c,1))},se=(a,b,c,d)=>tb([d],([e])=>{e=e?e.value:null;return null!==e&&ib(b.h,e,null)?w.$():w.S()});function te(a,b){a=a.toLowerCase();b=b.toLowerCase();return a===b?!0:5>a.length||!a.startsWith(b)?!1:te(a.replace(/-[a-z0-9]+$/,""),b)}
115
+ const ue=(a,b,c,d,e)=>{b=b.h;if(d.isEmpty())d="";else if(v(d.first().type,1))d=d.first().value;else throw Error("XPTY0004: The first argument of lang must be a string.");if(e)e=e.first().value;else{if(!a||!a.L)throw mc("The function lang depends on dynamic context if a node is not passed as the second argument.");if(!v(a.L.type,53))throw Error("XPTY0004: The context item must be a node.");e=a.L.value}a:{for(a=d;e;)if(1!==e.node.nodeType)e=x(b,e);else if(1===e.node.nodeType){if(d=fb(b,e,"xml:lang")){b=
116
+ te(d,a)?w.$():w.S();break a}e=x(b,e)}b=w.S()}return b},ve=(a,b,c,d)=>tb([d],([e])=>{function f(n){let t=0,u=n;for(;null!==u;)(n.node.nodeType!==u.node.nodeType?0:1===u.node.nodeType?u.node.localName===n.node.localName&&u.node.namespaceURI===n.node.namespaceURI:7===u.node.nodeType?u.node.target===n.node.target:1)&&t++,u=nb(h,u,null);return t}if(null===e)return w.empty();const h=b.h;let k="";for(e=e.value;null!==x(b.h,e,null);e=x(b.h,e,null))switch(e.node.nodeType){case 1:var l=e;k=`/Q{${l.node.namespaceURI||
117
+ ""}}${l.node.localName}[${f(l)}]${k}`;break;case 2:l=e;k=`/@${l.node.namespaceURI?`Q{${l.node.namespaceURI}}`:""}${l.node.localName}${k}`;break;case 3:k=`/text()[${f(e)}]${k}`;break;case 7:l=e;k=`/processing-instruction(${l.node.target})[${f(l)}]${k}`;break;case 8:k=`/comment()[${f(e)}]${k}`}return 9===e.node.nodeType?w.create(g(k||"/",1)):w.create(g("Q{http://www.w3.org/2005/xpath-functions}root()"+k,1))}),we=(a,b,c,d)=>d.map(e=>g(e.value.node.namespaceURI||"",20)),xe=(a,b,c,d)=>d.X({default:()=>
118
+ d.map(e=>7===e.value.node.nodeType?g(e.value.node.target,1):g(e.value.node.localName||"",1)),empty:()=>w.m(g("",1))});function ye(a,b,c){if(2===b.node.nodeType)return nd(b,c);for(;c;){if(nd(b,c))return!0;if(9===c.node.nodeType)break;c=x(a,c,null)}return!1}const ze=(a,b,c,d)=>d.map(e=>{if(!v(e.type,53))throw Error("XPTY0004 Argument passed to fn:root() should be of the type node()");let f;for(e=e.value;e;)f=e,e=x(b.h,f,null);return sb(f)});
119
+ var Ae=[{j:[{type:53,g:0}],callFunction:pe,localName:"name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[],callFunction:Bd("name",53,pe),localName:"name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:53,g:3}],callFunction:we,localName:"namespace-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:20,g:3}},{j:[],callFunction:Bd("namespace-uri",53,we),localName:"namespace-uri",namespaceURI:"http://www.w3.org/2005/xpath-functions",
120
+ i:{type:20,g:3}},{j:[{type:53,g:2}],callFunction:(a,b,c,d)=>d.M(e=>{if(!e.length)return w.empty();e=ud(b.h,e).reduceRight((f,h,k,l)=>{if(k===l.length-1)return f.push(h),f;if(ye(b.h,h.value,f[0].value))return f;f.unshift(h);return f},[]);return w.create(e)}),localName:"innermost",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:2}},{j:[{type:53,g:2}],callFunction:(a,b,c,d)=>d.M(e=>{if(!e.length)return w.empty();e=ud(b.h,e).reduce((f,h,k)=>{if(0===k)return f.push(h),f;if(ye(b.h,f[f.length-
121
+ 1].value,h.value))return f;f.push(h);return f},[]);return w.create(e)},1),localName:"outermost",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:2}},{j:[{type:53,g:0}],callFunction:se,localName:"has-children",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[],callFunction:Bd("has-children",53,se),localName:"has-children",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:53,g:0}],callFunction:ve,localName:"path",namespaceURI:"http://www.w3.org/2005/xpath-functions",
122
+ i:{type:1,g:0}},{j:[],callFunction:Bd("path",53,ve),localName:"path",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:0}},{j:[{type:53,g:0}],callFunction:oe,localName:"node-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[],callFunction:Bd("node-name",53,oe),localName:"node-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:23,g:0}},{j:[{type:53,g:0}],callFunction:xe,localName:"local-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",
123
+ i:{type:1,g:3}},{j:[],callFunction:Bd("local-name",53,xe),localName:"local-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}},{j:[{type:53,g:0}],callFunction:ze,localName:"root",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:0}},{j:[],callFunction:Bd("root",53,ze),localName:"root",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:53,g:0}},{j:[],callFunction:Bd("data",59,qe),localName:"data",namespaceURI:"http://www.w3.org/2005/xpath-functions",
124
+ i:{type:46,g:2}},{j:[{type:59,g:2}],callFunction:qe,localName:"data",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}},{j:[{type:1,g:0}],callFunction:ue,localName:"lang",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:1,g:0},{type:53,g:3}],callFunction:ue,localName:"lang",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[],callFunction:Bd("generate-id",53,re),localName:"generate-id",namespaceURI:"http://www.w3.org/2005/xpath-functions",
125
+ i:{type:1,g:3}},{j:[{type:53,g:0}],callFunction:re,localName:"generate-id",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}}];function Be(a,b){let c=0;const d=a.length;let e=!1,f=null;return{next:()=>{if(!e){for(;c<d;){f||=b(a[c],c,a);const h=f.next(0);f=null;if(h.value)c++;else return q(!1)}e=!0;return q(!0)}return p}}}function Ce(a){a=a.node.nodeType;return 1===a||3===a}
126
+ function De(a,b){if((v(a.type,4)||v(a.type,6))&&(v(b.type,4)||v(b.type,6))){var c=kd(a,6),d=kd(b,6);return c.value===d.value||isNaN(a.value)&&isNaN(b.value)}return(v(a.type,4)||v(a.type,6)||v(a.type,3))&&(v(b.type,4)||v(b.type,6)||v(b.type,3))?(c=kd(a,3),d=kd(b,3),c.value===d.value||isNaN(a.value)&&isNaN(b.value)):v(a.type,23)&&v(b.type,23)?a.value.namespaceURI===b.value.namespaceURI&&a.value.localName===b.value.localName:(v(a.type,9)||v(a.type,7)||v(a.type,8)||v(a.type,11)||v(a.type,12)||v(a.type,
127
+ 13)||v(a.type,14)||v(a.type,15))&&(v(b.type,9)||v(b.type,7)||v(b.type,8)||v(b.type,11)||v(b.type,12)||v(b.type,13)||v(b.type,14)||v(b.type,15))?Pb(a.value,b.value):(v(a.type,16)||v(a.type,17)||v(a.type,18))&&(v(b.type,16)||v(b.type,17)||v(b.type,17))?a.value.equals(b.value):a.value===b.value}function Ee(a,b,c){const [d,e]=[b,c].map(f=>({type:1,value:f.reduce((h,k)=>h+=qc(k,a).first().value,"")}));return q(De(d,e))}
128
+ function Fe(a,b,c,d){for(;a.value&&v(a.value.type,56);){b.push(a.value);const e=mb(d,a.value.value);a=c.next(0);if(e&&3!==e.node.nodeType)break}return a}
129
+ function Ge(a,b,c,d,e){const f=b.h,h=d.value,k=e.value;let l=null,n=null,t=null,u;const z=[],y=[];return{next:()=>{for(;!u;)if(l||=h.next(0),l=Fe(l,z,h,f),n||=k.next(0),n=Fe(n,y,k,f),z.length||y.length){var F=Ee(b,z,y);z.length=0;y.length=0;if(!1===F.value)return u=!0,F}else{if(l.done||n.done)return u=!0,q(l.done===n.done);t||=He(a,b,c,l.value,n.value);F=t.next(0);t=null;if(!1===F.value)return u=!0,F;n=l=null}return p}}}
130
+ function Ie(a,b,c,d,e){return d.h.length!==e.h.length?ld(!1):Be(d.h,f=>{const h=e.h.find(k=>De(k.key,f.key));return h?Ge(a,b,c,f.value(),h.value()):ld(!1)})}function Je(a,b,c,d,e){return d.members.length!==e.members.length?ld(!1):Be(d.members,(f,h)=>{h=e.members[h];return Ge(a,b,c,f(),h())})}function Ke(a,b,c,d,e){d=gb(b.h,d.value);e=gb(b.h,e.value);d=d.filter(f=>Ce(f));e=e.filter(f=>Ce(f));d=w.create(d.map(f=>sb(f)));e=w.create(e.map(f=>sb(f)));return Ge(a,b,c,d,e)}
131
+ function Le(a,b,c,d,e){const f=Ge(a,b,c,oe(a,b,c,w.m(d)),oe(a,b,c,w.m(e))),h=Ke(a,b,c,d,e);d=eb(b.h,d.value).filter(n=>"http://www.w3.org/2000/xmlns/"!==n.node.namespaceURI).sort((n,t)=>n.node.nodeName>t.node.nodeName?1:-1).map(n=>sb(n));e=eb(b.h,e.value).filter(n=>"http://www.w3.org/2000/xmlns/"!==n.node.namespaceURI).sort((n,t)=>n.node.nodeName>t.node.nodeName?1:-1).map(n=>sb(n));const k=Ge(a,b,c,w.create(d),w.create(e));let l=!1;return{next:()=>{if(l)return p;var n=f.next(0);if(!n.done&&!1===n.value)return l=
132
+ !0,n;n=k.next(0);if(!n.done&&!1===n.value)return l=!0,n;n=h.next(0);l=!0;return n}}}function Me(a,b,c,d,e){const f=Ge(a,b,c,oe(a,b,c,w.m(d)),oe(a,b,c,w.m(e)));let h=!1;return{next:()=>{if(h)return p;const k=f.next(0);return k.done||!1!==k.value?q(De(qc(d,b).first(),qc(e,b).first())):(h=!0,k)}}}
133
+ function He(a,b,c,d,e){if(v(d.type,46)&&v(e.type,46))return ld(De(d,e));if(v(d.type,61)&&v(e.type,61))return Ie(a,b,c,d,e);if(v(d.type,62)&&v(e.type,62))return Je(a,b,c,d,e);if(v(d.type,53)&&v(e.type,53)){if(v(d.type,55)&&v(e.type,55))return Ke(a,b,c,d,e);if(v(d.type,54)&&v(e.type,54))return Le(a,b,c,d,e);if(v(d.type,47)&&v(e.type,47)||v(d.type,57)&&v(e.type,57)||v(d.type,58)&&v(e.type,58))return Me(a,b,c,d,e)}return ld(!1)};var Ne=class extends dc{constructor(){super({L:null,Ba:-1,sa:w.empty(),qa:{}})}};var Oe=(a="Can not execute an updating expression in a non-updating context.")=>Error(`XUST0001: ${a}`),Pe=a=>Error(`XUTY0004: The attribute ${a.name}="${a.value}" follows a node that is not an attribute node.`),Qe=()=>Error("XUTY0005: The target of a insert expression with into must be a single element or document node."),Re=()=>Error("XUTY0006: The target of a insert expression with before or after must be a single element, text, comment, or processing instruction node."),Se=()=>Error("XUTY0008: The target of a replace expression must be a single element, attribute, text, comment, or processing instruction node."),
134
+ Te=()=>Error("XUTY0012: The target of a rename expression must be a single element, attribute, or processing instruction node."),Ue=a=>Error(`XUDY0017: The target ${a.outerHTML} is used in more than one replace value of expression.`),Ve=a=>Error(`XUDY0021: Applying the updates will result in the XDM instance violating constraint: '${a}'`),We=a=>Error(`XUDY0023: The namespace binding ${a} is conflicting.`),Xe=a=>Error(`XUDY0024: The namespace binding ${a} is conflicting.`),Ye=()=>Error("XUDY0027: The target for an insert, replace, or rename expression expression should not be empty.");function A(a,b,c){b&&null!==b.L?a.B?(null===a.ob&&(a.ob=Ra(a.h(new Ne,c).hb())),a=a.ob()):a=a.h(b,c):a=a.h(b,c);return a}var C=class{constructor(a,b,c={B:!1,V:!1,P:"unsorted",subtree:!1},d=!1,e){this.o=a;this.ha=c.P||"unsorted";this.subtree=!!c.subtree;this.V=!!c.V;this.B=!!c.B;this.Ga=b;this.H=!1;this.ob=null;this.Sb=d;this.type=e}D(){return null}v(a){this.Ga.forEach(b=>b.v(a));if(!this.Sb&&this.Ga.some(b=>b.H))throw Oe();}};var Ze=class{constructor(a,b){this.I=a;this.ca=b}};var $e=class{constructor(a){a&&"object"===typeof a&&"nodeType"in a&&(a=a.ownerDocument||a,"function"===typeof a.createElementNS&&"function"===typeof a.createProcessingInstruction&&"function"===typeof a.createTextNode&&"function"===typeof a.createComment&&(this.h=a));this.h||(this.h=null)}createAttributeNS(a,b){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createAttributeNS(a,b)}createCDATASection(a){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");
132
135
  return this.h.createCDATASection(a)}createComment(a){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createComment(a)}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(a,b){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createElementNS(a,
133
- b)}createProcessingInstruction(a,b){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createProcessingInstruction(a,b)}createTextNode(a){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createTextNode(a)}};function $e(a,b,c,d){return eb(d,a,`name-${b}`).some(e=>e.node.localName===b&&e.node.namespaceURI===c)}
134
- var af=(a,b,c,d)=>{const e=x(c,a).node,f=(a=lb(c,a))?a.node:null;b.forEach(h=>{d.insertBefore(e,h.node,f)})},bf=(a,b,c,d)=>{const e=x(c,a).node;b.forEach(f=>{d.insertBefore(e,f.node,a.node)})},cf=(a,b,c,d)=>{const e=(c=ib(c,a))?c.node:null;b.forEach(f=>{d.insertBefore(a.node,f.node,e)})},df=(a,b,c)=>{b.forEach(d=>{c.insertBefore(a.node,d.node,null)})},ef=(a,b,c,d)=>{b.forEach(e=>{const f=e.node.localName,h=e.node.namespaceURI;if($e(a,f,h,c))throw Ue(`An attribute ${h?`Q{${h}}${f}`:f} already exists.`);
135
- d.setAttributeNS(a.node,h,f,hb(c,e))})},gf=(a,b,c,d,e)=>{d||=new Ze(a?a.node:null);let f;switch(a.node.nodeType){case 1:const h=c.getAllAttributes(a.node),k=c.getChildNodes(a.node),l=d.createElementNS(b.namespaceURI,b.za());f={node:l,G:null};h.forEach(n=>{e.setAttributeNS(l,n.namespaceURI,n.nodeName,n.value)});k.forEach(n=>{e.insertBefore(l,n,null)});break;case 2:b=d.createAttributeNS(b.namespaceURI,b.za());b.value=hb(c,a);f={node:b,G:null};break;case 7:f={node:d.createProcessingInstruction(b.za(),
136
- hb(c,a)),G:null}}if(!x(c,a))throw Error("Not supported: renaming detached nodes.");ff(a,[f],c,e)},hf=(a,b,c,d)=>{c.getChildNodes(a.node).forEach(e=>d.removeChild(a.node,e));b&&d.insertBefore(a.node,b.node,null)},ff=(a,b,c,d)=>{const e=x(c,a);var f=a.node.nodeType;if(2===f){if(b.some(k=>2!==k.node.nodeType))throw Error('Constraint "If $target is an attribute node, $replacement must consist of zero or more attribute nodes." failed.');const h=e?e.node:null;d.removeAttributeNS(h,a.node.namespaceURI,a.node.localName);
137
- b.forEach(k=>{const l=k.node.localName,n=k.node.namespaceURI;if($e(e,l,n,c))throw Ue(`An attribute ${n?`Q{${n}}${l}`:l} already exists.`);d.setAttributeNS(h,n,l,hb(c,k))})}if(1===f||3===f||8===f||7===f){const h=(f=lb(c,a))?f.node:null;d.removeChild(e.node,a.node);b.forEach(k=>{d.insertBefore(e.node,k.node,h)})}};var kf=(a,b,c,d)=>{jf(a,b);a.filter(e=>-1!==["insertInto","insertAttributes","replaceValue","rename"].indexOf(e.type)).forEach(e=>{switch(e.type){case "insertInto":df(e.target,e.content,d);break;case "insertAttributes":ef(e.target,e.content,b,d);break;case "rename":gf(e.target,e.o,b,c,d);break;case "replaceValue":var f=e.target;e=e.o;if(2===f.node.nodeType){const h=x(b,f);h?d.setAttributeNS(h.node,f.node.namespaceURI,f.node.localName,e):f.node.value=e}else d.setData(f.node,e)}});a.filter(e=>-1!==
138
- ["insertBefore","insertAfter","insertIntoAsFirst","insertIntoAsLast"].indexOf(e.type)).forEach(e=>{switch(e.type){case "insertAfter":af(e.target,e.content,b,d);break;case "insertBefore":bf(e.target,e.content,b,d);break;case "insertIntoAsFirst":cf(e.target,e.content,b,d);break;case "insertIntoAsLast":df(e.target,e.content,d)}});a.filter(e=>"replaceNode"===e.type).forEach(e=>{ff(e.target,e.o,b,d)});a.filter(e=>"replaceElementContent"===e.type).forEach(e=>{hf(e.target,e.text,b,d)});a.filter(e=>"delete"===
136
+ b)}createProcessingInstruction(a,b){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createProcessingInstruction(a,b)}createTextNode(a){if(!this.h)throw Error("Please pass a node factory if an XQuery script uses node constructors");return this.h.createTextNode(a)}};function af(a,b,c,d){return eb(d,a,`name-${b}`).some(e=>e.node.localName===b&&e.node.namespaceURI===c)}
137
+ var bf=(a,b,c,d)=>{const e=x(c,a).node,f=(a=mb(c,a))?a.node:null;b.forEach(h=>{d.insertBefore(e,h.node,f)})},cf=(a,b,c,d)=>{const e=x(c,a).node;b.forEach(f=>{d.insertBefore(e,f.node,a.node)})},df=(a,b,c,d)=>{const e=(c=ib(c,a))?c.node:null;b.forEach(f=>{d.insertBefore(a.node,f.node,e)})},ef=(a,b,c)=>{b.forEach(d=>{c.insertBefore(a.node,d.node,null)})},ff=(a,b,c,d)=>{b.forEach(e=>{const f=e.node.localName,h=e.node.namespaceURI;if(af(a,f,h,c))throw Ve(`An attribute ${h?`Q{${h}}${f}`:f} already exists.`);
138
+ d.setAttributeNS(a.node,h,f,hb(c,e))})},hf=(a,b,c,d,e)=>{d||=new $e(a?a.node:null);let f;switch(a.node.nodeType){case 1:const h=c.getAllAttributes(a.node),k=c.getChildNodes(a.node),l=d.createElementNS(b.namespaceURI,b.Aa());f={node:l,F:null};h.forEach(n=>{e.setAttributeNS(l,n.namespaceURI,n.nodeName,n.value)});k.forEach(n=>{e.insertBefore(l,n,null)});break;case 2:b=d.createAttributeNS(b.namespaceURI,b.Aa());b.value=hb(c,a);f={node:b,F:null};break;case 7:f={node:d.createProcessingInstruction(b.Aa(),
139
+ hb(c,a)),F:null}}if(!x(c,a))throw Error("Not supported: renaming detached nodes.");gf(a,[f],c,e)},jf=(a,b,c,d)=>{c.getChildNodes(a.node).forEach(e=>d.removeChild(a.node,e));b&&d.insertBefore(a.node,b.node,null)},gf=(a,b,c,d)=>{const e=x(c,a);var f=a.node.nodeType;if(2===f){if(b.some(k=>2!==k.node.nodeType))throw Error('Constraint "If $target is an attribute node, $replacement must consist of zero or more attribute nodes." failed.');const h=e?e.node:null;d.removeAttributeNS(h,a.node.namespaceURI,a.node.localName);
140
+ b.forEach(k=>{const l=k.node.localName,n=k.node.namespaceURI;if(af(e,l,n,c))throw Ve(`An attribute ${n?`Q{${n}}${l}`:l} already exists.`);d.setAttributeNS(h,n,l,hb(c,k))})}if(1===f||3===f||8===f||7===f){const h=(f=mb(c,a))?f.node:null;d.removeChild(e.node,a.node);b.forEach(k=>{d.insertBefore(e.node,k.node,h)})}};var lf=(a,b,c,d)=>{kf(a,b);a.filter(e=>-1!==["insertInto","insertAttributes","replaceValue","rename"].indexOf(e.type)).forEach(e=>{switch(e.type){case "insertInto":ef(e.target,e.content,d);break;case "insertAttributes":ff(e.target,e.content,b,d);break;case "rename":hf(e.target,e.o,b,c,d);break;case "replaceValue":var f=e.target;e=e.o;if(2===f.node.nodeType){const h=x(b,f);h?d.setAttributeNS(h.node,f.node.namespaceURI,f.node.localName,e):f.node.value=e}else d.setData(f.node,e)}});a.filter(e=>-1!==
141
+ ["insertBefore","insertAfter","insertIntoAsFirst","insertIntoAsLast"].indexOf(e.type)).forEach(e=>{switch(e.type){case "insertAfter":bf(e.target,e.content,b,d);break;case "insertBefore":cf(e.target,e.content,b,d);break;case "insertIntoAsFirst":df(e.target,e.content,b,d);break;case "insertIntoAsLast":ef(e.target,e.content,d)}});a.filter(e=>"replaceNode"===e.type).forEach(e=>{gf(e.target,e.o,b,d)});a.filter(e=>"replaceElementContent"===e.type).forEach(e=>{jf(e.target,e.text,b,d)});a.filter(e=>"delete"===
139
142
  e.type).forEach(e=>{e=e.target;var f=x(b,e);(f=f?f.node:null)&&(2===e.node.nodeType?d.removeAttributeNS(f,e.node.namespaceURI,e.node.localName):d.removeChild(f,e.node))});if(a.some(e=>"put"===e.type))throw Error('Not implemented: the execution for pendingUpdate "put" is not yet implemented.');};
140
- const jf=(a,b)=>{function c(f,h){const k=new Set;a.filter(l=>l.type===f).map(l=>l.target).forEach(l=>{l=l?l.node:null;k.has(l)&&h(l);k.add(l)})}c("rename",f=>{throw Error(`XUDY0015: The target ${f.outerHTML} is used in more than one rename expression.`);});c("replaceNode",f=>{throw Error(`XUDY0016: The target ${f.outerHTML} is used in more than one replace expression.`);});c("replaceValue",f=>{throw Te(f);});c("replaceElementContent",f=>{throw Te(f);});const d=new Map,e=f=>new Sa(f.node.prefix,f.node.namespaceURI,
141
- f.node.localName);a.filter(f=>"replaceNode"===f.type&&2===f.target.node.nodeType).forEach(f=>{var h=x(b,f.target);h=h?h.node:null;const k=d.get(h);k?k.push(...f.o.map(e)):d.set(h,f.o.map(e))});a.filter(f=>"rename"===f.type&&2===f.target.node.nodeType).forEach(f=>{var h=x(b,f.target);if(h){h=h.node;var k=d.get(h);k?k.push(f.o):d.set(h,[f.o])}});d.forEach(f=>{const h={};f.forEach(k=>{h[k.prefix]||(h[k.prefix]=k.namespaceURI);if(h[k.prefix]!==k.namespaceURI)throw We(k.namespaceURI);})})};
142
- var lf=(a,...b)=>a.concat(...b.filter(Boolean));function mf(a){return a.I?(b,c)=>a.s(b,c):(b,c)=>{const d=a.h(b,c);return{next:()=>{const e=d.O();return q({da:[],J:e})}}}}var nf=class extends D{constructor(a,b,c,d){super(a,b,c,!0,d);this.I=!0}h(){throw Ne();}};function of(a,b){a=a.next(0);b(a.value.da);return w.create(a.value.J)}function pf(a){a.Fa.some(b=>b.I)&&(a.I=!0)}var qf=class extends nf{constructor(a,b,c,d){super(a,b,c,d);this.I=this.Fa.some(e=>e.I)}h(a,b){return this.A(a,b,this.Fa.map(c=>d=>c.h(d,b)))}s(a,b){let c=[];const d=this.A(a,b,this.Fa.map(f=>f.I?h=>{h=f.s(h,b);return of(h,k=>c=lf(c,k))}:h=>f.h(h,b)));let e=!1;return{next:()=>{if(e)return p;const f=d.O();e=!0;return q(new Ye(f,c))}}}v(a){super.v(a);pf(this)}};const rf=["external","attribute","nodeName","nodeType","universal"],sf=rf.length;function tf(a,b){for(let c=0;c<sf;++c){if(b.h[c]<a.h[c])return 1;if(b.h[c]>a.h[c])return-1}return 0}var uf=class{constructor(a){this.h=rf.map(b=>a[b]||0);if(Object.keys(a).some(b=>!rf.includes(b)))throw Error("Invalid specificity kind passed");}add(a){const b=rf.reduce((c,d,e)=>{c[d]=this.h[e]+a.h[e];return c},Object.create(null));return new uf(b)}};const vf=()=>mc("Expected base expression of a function call to evaluate to a sequence of single function item");function wf(a,b,c,d){const e=[];for(let f=0;f<b.length;++f){if(null===b[f]){e.push(null);continue}const h=zd(a[f],b[f],c,d,!1);e.push(h)}return e}function Cf(a,b){if(!v(a.type,60))throw mc("Expected base expression to evaluate to a function item");if(a.v!==b)throw vf();return a}
143
- function Df(a,b,c,d,e,f,h){let k=0;e=e.map(l=>l?null:f[k++](c));e=wf(a.o,e,d,a.D);if(0<=e.indexOf(null))return Ta(a,e);b=b.apply(void 0,[c,d,h,...e]);return zd(a.s,b,d,a.D,!0)}
144
- var Ff=class extends qf{constructor(a,b,c){super(new uf({external:1}),[a].concat(b.filter(d=>!!d)),{R:"unsorted",W:!1,subtree:!1,B:!1},c);this.ma=b.length;this.P=b.map(d=>null===d);this.L=null;this.ya=a;this.La=b}s(a,b){if(!this.l||!this.l.I)return super.s(a,b);let c=[];const d=Df(this.l,(f,h,k,...l)=>of(this.l.value(f,h,k,...l),n=>{c=lf(c,n)}),a,b,this.P,this.La.map(f=>()=>f.I?of(f.s(a,b),h=>{c=lf(c,h)}):C(f,a,b)),this.L);let e=!1;return{next:()=>{if(e)return p;const f=d.O();e=!0;return q({da:c,
145
- J:f})}}}A(a,b,[c,...d]){if(this.l)return Df(this.l,(f,h,k,...l)=>this.l.value(f,h,k,...l),a,b,this.P,d,this.L);const e=c(a);return e.X({default:()=>{throw vf();},m:()=>e.N(([f])=>{f=Cf(f,this.ma);if(f.I)throw Error("XUDY0038: The function returned by the PrimaryExpr of a dynamic function invocation can not be an updating function");return Df(f,f.value,a,b,this.P,d,this.L)})})}v(a){this.L=Ef(a);super.v(a);if(this.ya.B){a=C(this.ya,null,null);if(!a.oa())throw vf();this.l=Cf(a.first(),this.ma);this.l.I&&
146
- (this.I=!0)}}};const Gf=(a,b,c,d,e,f)=>A([d,e,f],([h,k,l])=>{k=k.value;l=l.value;if(k>h.h.length||0>=k)throw Error("FOAY0001: subarray start out of bounds.");if(0>l)throw Error("FOAY0002: subarray length out of bounds.");if(k+l>h.h.length+1)throw Error("FOAY0001: subarray start + length out of bounds.");return w.m(new pb(h.h.slice(k-1,l+k-1)))}),Hf=(a,b,c,d,e)=>A([d],([f])=>e.N(h=>{h=h.map(l=>l.value).sort((l,n)=>n-l).filter((l,n,t)=>t[n-1]!==l);const k=f.h.concat();for(let l=0,n=h.length;l<n;++l){const t=h[l];
147
- if(t>f.h.length||0>=t)throw Error("FOAY0001: subarray position out of bounds.");k.splice(t-1,1)}return w.m(new pb(k))})),If=a=>v(a,1)||v(a,20)||v(a,19),Jf=(a,b,c,d,e)=>0===d.length?0!==e.length:0!==e.length&&Ge(a,b,c,d[0],e[0]).next(0).value?Jf(a,b,c,d.slice(1),e.slice(1)):d[0].value!==d[0].value?!0:If(d[0].type)&&0!==e.length&&If(e[0].type)?d[0].value<e[0].value:0===e.length?!1:d[0].value<e[0].value,Kf=(a,b,c,d)=>{d.sort((e,f)=>Fe(a,b,c,w.create(e),w.create(f)).next(0).value?0:Jf(a,b,c,e,f)?-1:1);
148
- return w.m(new pb(d.map(e=>()=>w.create(e))))};function Lf(a){return v(a.type,62)?jc(a.h.map(b=>b().N(c=>jc(c.map(Lf))))):w.m(a)}
149
- var Mf=[{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"size",j:[{type:62,g:3}],i:{type:5,g:3},callFunction:(a,b,c,d)=>A([d],([e])=>w.m(g(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:ob},{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:(a,b,c,d,e,f)=>A([e,d],([h,k])=>
150
- {h=h.value;if(0>=h||h>k.h.length)throw Error("FOAY0001: array position out of bounds.");k=k.h.concat();k.splice(h-1,1,Ra(f));return w.m(new pb(k))})},{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:(a,b,c,d,e)=>A([d],([f])=>w.m(new pb(f.h.concat([Ra(e)]))))},{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:Gf},
151
- {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(a,b,c,d,e){const f=w.m(g(d.first().value.length-e.first().value+1,5));return Gf(a,b,c,d,e,f)}},{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:Hf},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"insert-before",j:[{type:62,g:3},{type:5,g:3},{type:59,
152
- g:2}],i:{type:62,g:3},callFunction:(a,b,c,d,e,f)=>A([d,e],([h,k])=>{k=k.value;if(k>h.h.length+1||0>=k)throw Error("FOAY0001: subarray position out of bounds.");h=h.h.concat();h.splice(k-1,0,Ra(f));return w.m(new pb(h))})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"head",j:[{type:62,g:3}],i:{type:59,g:2},callFunction(a,b,c,d){return ob(a,b,c,d,w.m(g(1,5)))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"tail",j:[{type:62,g:3}],i:{type:59,g:2},
153
- callFunction(a,b,c,d){return Hf(a,b,c,d,w.m(g(1,5)))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"reverse",j:[{type:62,g:3}],i:{type:62,g:3},callFunction:(a,b,c,d)=>A([d],([e])=>w.m(new pb(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:(a,b,c,d)=>d.N(e=>{e=e.reduce((f,h)=>f.concat(h.h),[]);return w.m(new pb(e))})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",
154
- localName:"for-each",j:[{type:62,g:3},{type:60,g:3}],i:{type:62,g:3},callFunction:(a,b,c,d,e)=>A([d,e],([f,h])=>{if(1!==h.v)throw mc("The callback passed into array:for-each has a wrong arity.");f=f.h.map(k=>Ra(h.value.call(void 0,a,b,c,wf(h.o,[k()],b,"array:for-each")[0])));return w.m(new pb(f))})},{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:(a,b,c,d,e)=>A([d,e],([f,h])=>{if(1!==h.v)throw mc("The callback passed into array:filter has a wrong arity.");
155
- const k=f.h.map(t=>{t=wf(h.o,[t()],b,"array:filter")[0];const u=h.value;return u(a,b,c,t)}),l=[];let n=!1;return w.create({next:()=>{if(n)return p;for(let u=0,z=f.h.length;u<z;++u){var t=k[u].fa();l[u]=t}t=f.h.filter((u,z)=>l[z]);n=!0;return q(new pb(t))}})})},{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:(a,b,c,d,e,f)=>A([d,f],([h,k])=>{if(2!==k.v)throw mc("The callback passed into array:fold-left has a wrong arity.");
156
- return h.h.reduce((l,n)=>{n=wf(k.o,[n()],b,"array:fold-left")[0];return k.value.call(void 0,a,b,c,l,n)},e)})},{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:(a,b,c,d,e,f)=>A([d,f],([h,k])=>{if(2!==k.v)throw mc("The callback passed into array:fold-right has a wrong arity.");return h.h.reduceRight((l,n)=>{n=wf(k.o,[n()],b,"array:fold-right")[0];return k.value.call(void 0,a,b,c,l,n)},e)})},
157
- {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:(a,b,c,d,e,f)=>A([d,e,f],([h,k,l])=>{if(2!==l.v)throw mc("The callback passed into array:for-each-pair has a wrong arity.");const n=[];for(let t=0,u=Math.min(h.h.length,k.h.length);t<u;++t){const [z,y]=wf(l.o,[h.h[t](),k.h[t]()],b,"array:for-each-pair");n[t]=Ra(l.value.call(void 0,a,b,c,z,y))}return w.m(new pb(n))})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",
158
- localName:"sort",j:[{type:62,g:3}],i:{type:62,g:3},callFunction:(a,b,c,d)=>A([d],([e])=>{e=e.h.map(f=>f().O());return Kf(a,b,c,e)})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"flatten",j:[{type:59,g:2}],i:{type:59,g:2},callFunction:(a,b,c,d)=>d.N(e=>jc(e.map(Lf)))}];function E(a,b,c,d,e){return e.F()?e:w.m(jd(e.first(),a))}
159
- var Nf=[{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"untypedAtomic",j:[{type:46,g:0}],i:{type:19,g:0},callFunction:E.bind(null,19)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"error",j:[{type:46,g:0}],i:{type:39,g:0},callFunction:E.bind(null,39)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"string",j:[{type:46,g:0}],i:{type:1,g:0},callFunction:E.bind(null,1)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"boolean",j:[{type:46,g:0}],i:{type:0,
143
+ const kf=(a,b)=>{function c(f,h){const k=new Set;a.filter(l=>l.type===f).map(l=>l.target).forEach(l=>{l=l?l.node:null;k.has(l)&&h(l);k.add(l)})}c("rename",f=>{throw Error(`XUDY0015: The target ${f.outerHTML} is used in more than one rename expression.`);});c("replaceNode",f=>{throw Error(`XUDY0016: The target ${f.outerHTML} is used in more than one replace expression.`);});c("replaceValue",f=>{throw Ue(f);});c("replaceElementContent",f=>{throw Ue(f);});const d=new Map,e=f=>new Sa(f.node.prefix,f.node.namespaceURI,
144
+ f.node.localName);a.filter(f=>"replaceNode"===f.type&&2===f.target.node.nodeType).forEach(f=>{var h=x(b,f.target);h=h?h.node:null;const k=d.get(h);k?k.push(...f.o.map(e)):d.set(h,f.o.map(e))});a.filter(f=>"rename"===f.type&&2===f.target.node.nodeType).forEach(f=>{var h=x(b,f.target);if(h){h=h.node;var k=d.get(h);k?k.push(f.o):d.set(h,[f.o])}});d.forEach(f=>{const h={};f.forEach(k=>{h[k.prefix]||(h[k.prefix]=k.namespaceURI);if(h[k.prefix]!==k.namespaceURI)throw Xe(k.namespaceURI);})})};
145
+ var mf=(a,...b)=>a.concat(...b.filter(Boolean));function nf(a){return a.H?(b,c)=>a.s(b,c):(b,c)=>{const d=a.h(b,c);return{next:()=>{const e=d.N();return q({ca:[],I:e})}}}}var of=class extends C{constructor(a,b,c,d){super(a,b,c,!0,d);this.H=!0}h(){throw Oe();}};function pf(a,b){a=a.next(0);b(a.value.ca);return w.create(a.value.I)}function qf(a){a.Ga.some(b=>b.H)&&(a.H=!0)}var rf=class extends of{constructor(a,b,c,d){super(a,b,c,d);this.H=this.Ga.some(e=>e.H)}h(a,b){return this.A(a,b,this.Ga.map(c=>d=>c.h(d,b)))}s(a,b){let c=[];const d=this.A(a,b,this.Ga.map(f=>f.H?h=>{h=f.s(h,b);return pf(h,k=>c=mf(c,k))}:h=>f.h(h,b)));let e=!1;return{next:()=>{if(e)return p;const f=d.N();e=!0;return q(new Ze(f,c))}}}v(a){super.v(a);qf(this)}};const sf=["external","attribute","nodeName","nodeType","universal"],tf=sf.length;function uf(a,b){for(let c=0;c<tf;++c){if(b.h[c]<a.h[c])return 1;if(b.h[c]>a.h[c])return-1}return 0}var D=class{constructor(a){this.h=sf.map(b=>a[b]||0);if(Object.keys(a).some(b=>!sf.includes(b)))throw Error("Invalid specificity kind passed");}add(a){const b=sf.reduce((c,d,e)=>{c[d]=this.h[e]+a.h[e];return c},Object.create(null));return new D(b)}};const vf=()=>nc("Expected base expression of a function call to evaluate to a sequence of single function item");function wf(a,b,c,d){const e=[];for(let f=0;f<b.length;++f){if(null===b[f]){e.push(null);continue}const h=Ad(a[f],b[f],c,d,!1);e.push(h)}return e}function xf(a,b){if(!v(a.type,60))throw nc("Expected base expression to evaluate to a function item");if(a.v!==b)throw vf();return a}
146
+ function Ef(a,b,c,d,e,f,h){let k=0;e=e.map(l=>l?null:f[k++](c));e=wf(a.o,e,d,a.D);if(0<=e.indexOf(null))return Ta(a,e);b=b.apply(void 0,[c,d,h,...e]);return Ad(a.s,b,d,a.D,!0)}
147
+ var Gf=class extends rf{constructor(a,b,c){super(new D({external:1}),[a].concat(b.filter(d=>!!d)),{P:"unsorted",V:!1,subtree:!1,B:!1},c);this.la=b.length;this.O=b.map(d=>null===d);this.K=null;this.ya=a;this.Ma=b}s(a,b){if(!this.l||!this.l.H)return super.s(a,b);let c=[];const d=Ef(this.l,(f,h,k,...l)=>pf(this.l.value(f,h,k,...l),n=>{c=mf(c,n)}),a,b,this.O,this.Ma.map(f=>()=>f.H?pf(f.s(a,b),h=>{c=mf(c,h)}):A(f,a,b)),this.K);let e=!1;return{next:()=>{if(e)return p;const f=d.N();e=!0;return q({ca:c,I:f})}}}A(a,
148
+ b,[c,...d]){if(this.l)return Ef(this.l,(f,h,k,...l)=>this.l.value(f,h,k,...l),a,b,this.O,d,this.K);const e=c(a);return e.X({default:()=>{throw vf();},m:()=>e.M(([f])=>{f=xf(f,this.la);if(f.H)throw Error("XUDY0038: The function returned by the PrimaryExpr of a dynamic function invocation can not be an updating function");return Ef(f,f.value,a,b,this.O,d,this.K)})})}v(a){this.K=Ff(a);super.v(a);if(this.ya.B){a=A(this.ya,null,null);if(!a.oa())throw vf();this.l=xf(a.first(),this.la);this.l.H&&(this.H=
149
+ !0)}}};const Hf=(a,b,c,d,e,f)=>tb([d,e,f],([h,k,l])=>{k=k.value;l=l.value;if(k>h.members.length||0>=k)throw Error("FOAY0001: subarray start out of bounds.");if(0>l)throw Error("FOAY0002: subarray length out of bounds.");if(k+l>h.members.length+1)throw Error("FOAY0001: subarray start + length out of bounds.");return w.m(new qb(h.members.slice(k-1,l+k-1)))}),If=(a,b,c,d,e)=>tb([d],([f])=>e.M(h=>{h=h.map(l=>l.value).sort((l,n)=>n-l).filter((l,n,t)=>t[n-1]!==l);const k=f.members.concat();for(let l=0,n=h.length;l<
150
+ n;++l){const t=h[l];if(t>f.members.length||0>=t)throw Error("FOAY0001: subarray position out of bounds.");k.splice(t-1,1)}return w.m(new qb(k))})),Jf=a=>v(a,1)||v(a,20)||v(a,19),Kf=(a,b,c,d,e)=>0===d.length?0!==e.length:0!==e.length&&He(a,b,c,d[0],e[0]).next(0).value?Kf(a,b,c,d.slice(1),e.slice(1)):d[0].value!==d[0].value?!0:Jf(d[0].type)&&0!==e.length&&Jf(e[0].type)?d[0].value<e[0].value:0===e.length?!1:d[0].value<e[0].value,Lf=(a,b,c,d)=>{d.sort((e,f)=>Ge(a,b,c,w.create(e),w.create(f)).next(0).value?
151
+ 0:Kf(a,b,c,e,f)?-1:1);return w.m(new qb(d.map(e=>()=>w.create(e))))};function Mf(a){return v(a.type,62)?kc(a.members.map(b=>b().M(c=>kc(c.map(Mf))))):w.m(a)}
152
+ var Nf=[{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"size",j:[{type:62,g:3}],i:{type:5,g:3},callFunction:(a,b,c,d)=>tb([d],([e])=>w.m(g(e.members.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:pb},{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:(a,b,c,d,e,f)=>tb([e,d],
153
+ ([h,k])=>{h=h.value;if(0>=h||h>k.members.length)throw Error("FOAY0001: array position out of bounds.");k=k.members.concat();k.splice(h-1,1,Ra(f));return w.m(new qb(k))})},{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:(a,b,c,d,e)=>tb([d],([f])=>w.m(new qb(f.members.concat([Ra(e)]))))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"subarray",j:[{type:62,g:3},{type:5,g:3},{type:5,g:3}],
154
+ i:{type:62,g:3},callFunction:Hf},{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(a,b,c,d,e){const f=w.m(g(d.first().value.length-e.first().value+1,5));return Hf(a,b,c,d,e,f)}},{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:If},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"insert-before",
155
+ j:[{type:62,g:3},{type:5,g:3},{type:59,g:2}],i:{type:62,g:3},callFunction:(a,b,c,d,e,f)=>tb([d,e],([h,k])=>{k=k.value;if(k>h.members.length+1||0>=k)throw Error("FOAY0001: subarray position out of bounds.");h=h.members.concat();h.splice(k-1,0,Ra(f));return w.m(new qb(h))})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"head",j:[{type:62,g:3}],i:{type:59,g:2},callFunction(a,b,c,d){return pb(a,b,c,d,w.m(g(1,5)))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",
156
+ localName:"tail",j:[{type:62,g:3}],i:{type:59,g:2},callFunction(a,b,c,d){return If(a,b,c,d,w.m(g(1,5)))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"reverse",j:[{type:62,g:3}],i:{type:62,g:3},callFunction:(a,b,c,d)=>tb([d],([e])=>w.m(new qb(e.members.concat().reverse())))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"join",j:[{type:62,g:2}],i:{type:62,g:3},callFunction:(a,b,c,d)=>d.M(e=>{e=e.reduce((f,h)=>f.concat(h.members),[]);return w.m(new qb(e))})},
157
+ {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:(a,b,c,d,e)=>tb([d,e],([f,h])=>{if(1!==h.v)throw nc("The callback passed into array:for-each has a wrong arity.");f=f.members.map(k=>Ra(h.value.call(void 0,a,b,c,wf(h.o,[k()],b,"array:for-each")[0])));return w.m(new qb(f))})},{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:(a,
158
+ b,c,d,e)=>tb([d,e],([f,h])=>{if(1!==h.v)throw nc("The callback passed into array:filter has a wrong arity.");const k=f.members.map(t=>{t=wf(h.o,[t()],b,"array:filter")[0];const u=h.value;return u(a,b,c,t)}),l=[];let n=!1;return w.create({next:()=>{if(n)return p;for(let u=0,z=f.members.length;u<z;++u){var t=k[u].ea();l[u]=t}t=f.members.filter((u,z)=>l[z]);n=!0;return q(new qb(t))}})})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"fold-left",j:[{type:62,g:3},{type:59,g:2},
159
+ {type:60,g:3}],i:{type:59,g:2},callFunction:(a,b,c,d,e,f)=>tb([d,f],([h,k])=>{if(2!==k.v)throw nc("The callback passed into array:fold-left has a wrong arity.");return h.members.reduce((l,n)=>{n=wf(k.o,[n()],b,"array:fold-left")[0];return k.value.call(void 0,a,b,c,l,n)},e)})},{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:(a,b,c,d,e,f)=>tb([d,f],([h,k])=>{if(2!==k.v)throw nc("The callback passed into array:fold-right has a wrong arity.");
160
+ return h.members.reduceRight((l,n)=>{n=wf(k.o,[n()],b,"array:fold-right")[0];return k.value.call(void 0,a,b,c,l,n)},e)})},{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:(a,b,c,d,e,f)=>tb([d,e,f],([h,k,l])=>{if(2!==l.v)throw nc("The callback passed into array:for-each-pair has a wrong arity.");const n=[];for(let t=0,u=Math.min(h.members.length,k.members.length);t<u;++t){const [z,y]=wf(l.o,
161
+ [h.members[t](),k.members[t]()],b,"array:for-each-pair");n[t]=Ra(l.value.call(void 0,a,b,c,z,y))}return w.m(new qb(n))})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"sort",j:[{type:62,g:3}],i:{type:62,g:3},callFunction:(a,b,c,d)=>tb([d],([e])=>{e=e.members.map(f=>f().N());return Lf(a,b,c,e)})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/array",localName:"flatten",j:[{type:59,g:2}],i:{type:59,g:2},callFunction:(a,b,c,d)=>d.M(e=>kc(e.map(Mf)))}];function E(a,b,c,d,e){return e.isEmpty()?e:w.m(kd(e.first(),a))}
162
+ var Of=[{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"untypedAtomic",j:[{type:46,g:0}],i:{type:19,g:0},callFunction:E.bind(null,19)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"error",j:[{type:46,g:0}],i:{type:39,g:0},callFunction:E.bind(null,39)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"string",j:[{type:46,g:0}],i:{type:1,g:0},callFunction:E.bind(null,1)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"boolean",j:[{type:46,g:0}],i:{type:0,
160
163
  g:0},callFunction:E.bind(null,0)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"decimal",j:[{type:46,g:0}],i:{type:4,g:0},callFunction:E.bind(null,4)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"float",j:[{type:46,g:0}],i:{type:6,g:0},callFunction:E.bind(null,6)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"double",j:[{type:46,g:0}],i:{type:3,g:0},callFunction:E.bind(null,3)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"duration",j:[{type:46,
161
164
  g:0}],i:{type:18,g:0},callFunction:E.bind(null,18)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTime",j:[{type:46,g:0}],i:{type:9,g:0},callFunction:E.bind(null,9)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTimeStamp",j:[{type:46,g:0}],i:{type:10,g:0},callFunction:E.bind(null,10)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"time",j:[{type:46,g:0}],i:{type:8,g:0},callFunction:E.bind(null,8)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"date",
162
165
  j:[{type:46,g:0}],i:{type:7,g:0},callFunction:E.bind(null,7)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gYearMonth",j:[{type:46,g:0}],i:{type:11,g:0},callFunction:E.bind(null,11)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gYear",j:[{type:46,g:0}],i:{type:12,g:0},callFunction:E.bind(null,12)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gMonthDay",j:[{type:46,g:0}],i:{type:13,g:0},callFunction:E.bind(null,13)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",
163
166
  localName:"gDay",j:[{type:46,g:0}],i:{type:15,g:0},callFunction:E.bind(null,15)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"gMonth",j:[{type:46,g:0}],i:{type:14,g:0},callFunction:E.bind(null,14)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"hexBinary",j:[{type:46,g:0}],i:{type:22,g:0},callFunction:E.bind(null,22)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"base64Binary",j:[{type:46,g:0}],i:{type:21,g:0},callFunction:E.bind(null,21)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",
164
- localName:"QName",j:[{type:46,g:0}],i:{type:23,g:0},callFunction:(a,b,c,d)=>{if(d.F())return d;a=d.first();if(v(a.type,2))throw Error("XPTY0004: The provided QName is not a string-like value.");a=jd(a,1).value;a=sc(a,23);if(!tc(a,23))throw Error("FORG0001: The provided QName is invalid.");if(!a.includes(":"))return c=c.$(""),w.m(g(new Sa("",c,a),23));const [e,f]=a.split(":");c=c.$(e);if(!c)throw Error(`FONS0004: The value ${a} can not be cast to a QName. Did you mean to use fn:QName?`);return w.m(g(new Sa(e,
167
+ localName:"QName",j:[{type:46,g:0}],i:{type:23,g:0},callFunction:(a,b,c,d)=>{if(d.isEmpty())return d;a=d.first();if(v(a.type,2))throw Error("XPTY0004: The provided QName is not a string-like value.");a=kd(a,1).value;a=tc(a,23);if(!uc(a,23))throw Error("FORG0001: The provided QName is invalid.");if(!a.includes(":"))return c=c.Z(""),w.m(g(new Sa("",c,a),23));const [e,f]=a.split(":");c=c.Z(e);if(!c)throw Error(`FONS0004: The value ${a} can not be cast to a QName. Did you mean to use fn:QName?`);return w.m(g(new Sa(e,
165
168
  c,f),23))}},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"anyURI",j:[{type:46,g:0}],i:{type:20,g:0},callFunction:E.bind(null,20)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"normalizedString",j:[{type:46,g:0}],i:{type:48,g:0},callFunction:E.bind(null,48)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"token",j:[{type:46,g:0}],i:{type:52,g:0},callFunction:E.bind(null,52)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"language",j:[{type:46,g:0}],
166
169
  i:{type:51,g:0},callFunction:E.bind(null,51)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NMTOKEN",j:[{type:46,g:0}],i:{type:50,g:0},callFunction:E.bind(null,50)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NMTOKENS",j:[{type:46,g:0}],i:{type:49,g:2},callFunction:E.bind(null,49)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"Name",j:[{type:46,g:0}],i:{type:25,g:0},callFunction:E.bind(null,25)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"NCName",
167
170
  j:[{type:46,g:0}],i:{type:24,g:0},callFunction:E.bind(null,24)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"ID",j:[{type:46,g:0}],i:{type:42,g:0},callFunction:E.bind(null,42)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"IDREF",j:[{type:46,g:0}],i:{type:41,g:0},callFunction:E.bind(null,41)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"IDREFS",j:[{type:46,g:0}],i:{type:43,g:2},callFunction:E.bind(null,43)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",
@@ -169,368 +172,373 @@ localName:"ENTITY",j:[{type:46,g:0}],i:{type:26,g:0},callFunction:E.bind(null,26
169
172
  localName:"negativeInteger",j:[{type:46,g:0}],i:{type:28,g:0},callFunction:E.bind(null,28)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"long",j:[{type:46,g:0}],i:{type:31,g:0},callFunction:E.bind(null,31)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"int",j:[{type:46,g:0}],i:{type:32,g:0},callFunction:E.bind(null,32)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"short",j:[{type:46,g:0}],i:{type:33,g:0},callFunction:E.bind(null,33)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",
170
173
  localName:"byte",j:[{type:46,g:0}],i:{type:34,g:0},callFunction:E.bind(null,34)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"nonNegativeInteger",j:[{type:46,g:0}],i:{type:30,g:0},callFunction:E.bind(null,30)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedLong",j:[{type:46,g:0}],i:{type:36,g:0},callFunction:E.bind(null,36)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedInt",j:[{type:46,g:0}],i:{type:35,g:0},callFunction:E.bind(null,35)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",
171
174
  localName:"unsignedShort",j:[{type:46,g:0}],i:{type:38,g:0},callFunction:E.bind(null,38)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"unsignedByte",j:[{type:46,g:0}],i:{type:37,g:0},callFunction:E.bind(null,37)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"positiveInteger",j:[{type:46,g:0}],i:{type:29,g:0},callFunction:E.bind(null,29)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"yearMonthDuration",j:[{type:46,g:0}],i:{type:16,g:0},callFunction:E.bind(null,
172
- 16)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dayTimeDuration",j:[{type:46,g:0}],i:{type:17,g:0},callFunction:E.bind(null,17)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTimeStamp",j:[{type:46,g:0}],i:{type:10,g:0},callFunction:E.bind(null,10)}];const Of=(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.getYear(),5)),Pf=(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.getMonth(),5)),Qf=(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.getDay(),5)),Rf=(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.getHours(),5)),Sf=(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.getMinutes(),5)),Tf=(a,b,c,d)=>{d.F()||(a=w,b=a.m,d=d.first().value,d=b.call(a,g(d.D+d.qa,4)));return d},Uf=(a,b,c,d)=>d.F()?d:(a=d.first().value.Y)?w.m(g(a,17)):w.empty();
173
- var Vf=[{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:(a,b,c,d,e)=>{if(d.F())return d;if(e.F())return e;a=d.first().value;e=e.first().value;b=a.Y;c=e.Y;if(b||c){if(!b||c)if(!b&&c)b=c;else if(!vb(b,c))throw Error("FORG0008: fn:dateTime: got a date and time value with different timezones.");}else b=null;return w.m(g(new Kb(a.getYear(),a.getMonth(),a.getDay(),e.getHours(),e.getMinutes(),e.getSeconds(),e.qa,b),9))}},
174
- {namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"year-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Of},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"month-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Pf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"day-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Qf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-dateTime",j:[{type:9,
175
- g:0}],i:{type:5,g:0},callFunction:Rf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Sf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-dateTime",j:[{type:9,g:0}],i:{type:4,g:0},callFunction:Tf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-dateTime",j:[{type:9,g:0}],i:{type:17,g:0},callFunction:Uf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
176
- localName:"year-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:Of},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"month-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:Pf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"day-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:Qf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-date",j:[{type:7,g:0}],i:{type:17,g:0},callFunction:Uf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
177
- localName:"hours-from-time",j:[{type:8,g:0}],i:{type:5,g:0},callFunction:Rf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-time",j:[{type:8,g:0}],i:{type:5,g:0},callFunction:Sf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-time",j:[{type:8,g:0}],i:{type:4,g:0},callFunction:Tf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-time",j:[{type:8,g:0}],i:{type:17,g:0},callFunction:Uf}];function Wf(a,b){const c=b.h,d=b.Ja,e=b.Ma;switch(a.node.nodeType){case 1:const h=d.createElementNS(a.node.namespaceURI,a.node.nodeName);c.getAllAttributes(a.node).forEach(k=>e.setAttributeNS(h,k.namespaceURI,k.nodeName,k.value));for(var f of gb(c,a))a=Wf(f,b),e.insertBefore(h,a.node,null);return{node:h,G:null};case 2:return b=d.createAttributeNS(a.node.namespaceURI,a.node.nodeName),b.value=hb(c,a),{node:b,G:null};case 4:return{node:d.createCDATASection(hb(c,a)),G:null};case 8:return{node:d.createComment(hb(c,
178
- a)),G:null};case 9:f=d.createDocument();for(const k of gb(c,a))a=Wf(k,b),e.insertBefore(f,a.node,null);return{node:f,G:null};case 7:return{node:d.createProcessingInstruction(a.node.target,hb(c,a)),G:null};case 3:return{node:d.createTextNode(hb(c,a)),G:null}}};function Xf(a,b){const c=b.Ma;var d=b.Ja;const e=b.h;if(cb(a.node))switch(a.node.nodeType){case 2:return d=d.createAttributeNS(a.node.namespaceURI,a.node.nodeName),d.value=hb(e,a),d;case 8:return d.createComment(hb(e,a));case 1:const f=a.node.prefix,h=a.node.localName,k=d.createElementNS(a.node.namespaceURI,f?f+":"+h:h);gb(e,a).forEach(l=>{l=Xf(l,b);c.insertBefore(k,l,null)});eb(e,a).forEach(l=>{c.setAttributeNS(k,l.node.namespaceURI,l.node.nodeName,hb(e,l))});k.normalize();return k;case 7:return d.createProcessingInstruction(a.node.target,
179
- hb(e,a));case 3:return d.createTextNode(hb(e,a))}else return Wf(a,b).node}function Yf(a,b,c){let d=a;for(a=x(c,d);null!==a;){if(2===d.node.nodeType)b.push(d.node.nodeName);else{const e=gb(c,a);b.push(e.findIndex(f=>md(f,d)))}d=a;a=x(c,d)}return d}function Zf(a,b,c){for(;0<b.length;){const d=b.pop();"string"===typeof d?a=eb(c,a).find(e=>e.node.nodeName===d):a=gb(c,a)[d]}return a.node}
180
- function $f(a,b,c){var d=a.node;if(!(cb(d)||c||a.G))return d;d=b.v;const e=[];if(c)return Xf(a,b);a=Yf(a,e,b.h);c=d.get(a.node);c||(c={node:Xf(a,b),G:null},d.set(a.node,c));return Zf(c,e,b.h)};const ag=(a,b,c,d,e)=>d.N(f=>{var h;let k="";for(let l=0;l<f.length;l++){const n=f[l],t=b.Ua&&v(n.type,53)?b.Ua.serializeToString($f(n.value,b,!1)):null===(h=qc(w.m(n),b).map(u=>jd(u,1)).first())||void 0===h?void 0:h.value;t&&(k+=`{type: ${Da[n.type]}, value: ${t}}\n`)}void 0!==e&&(k+=e.first().value);b.jb.trace(k);return w.create(f)});
181
- var bg=[{j:[{type:59,g:2}],callFunction:ag,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:ag,localName:"trace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}}];const cg=(a,b,c,d,e)=>{a=void 0===d||d.F()?new Sa("err","http://www.w3.org/2005/xqt-errors","FOER0000"):d.first().value;b="";void 0===e||e.F()||(b=`: ${e.first().value}`);throw Error(`${a.localName}${b}`);};
182
- var dg=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[],i:{type:63,g:3},callFunction:cg},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[{type:23,g:0}],i:{type:63,g:3},callFunction:cg},{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:cg},{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,
183
- g:3},callFunction(){throw Error("Not implemented: Using an error object in error is not supported");}}];function eg(a){return"string"===typeof a?a:(a=(new Za).getChildNodes(a).find(b=>8===b.nodeType))?a.data:"some expression"};var fg=class extends Error{constructor(a,b){super(a);this.position={end:{ha:b.end.ha,line:b.end.line,offset:b.end.offset},start:{ha:b.start.ha,line:b.start.line,offset:b.start.offset}}}};function gg(a,b){if(b instanceof Error)throw b;"string"!==typeof a&&(a=eg(a));const c=hg(b);a=a.replace(/\r/g,"").split("\n");const d=Math.floor(Math.log10(Math.min(c.end.line+2,a.length)))+1;a=a.reduce((e,f,h)=>{var k=h+1;if(2<c.start.line-k||2<k-c.end.line)return e;h=`${Array(d).fill(" ",0,Math.floor(Math.log10(k))+1-d).join("")}${k}: `;e.push(`${h}${f}`);if(k>=c.start.line&&k<=c.end.line){const l=k<c.end.line?f.length+h.length:c.end.ha-1+h.length;k=k>c.start.line?h.length:c.start.ha-1+h.length;
184
- f=" ".repeat(h.length)+Array.from(f.substring(0,k-h.length),n=>"\t"===n?"\t":" ").join("")+"^".repeat(l-k);e.push(f)}return e},[]);b=ig(b).join("\n");throw new fg(a.join("\n")+"\n\n"+b,c);};const jg=Object.create(null);function kg(a,b){const c=new Map;for(let d=0;d<a.length+1;++d)c.set(d,new Map);return function h(e,f){if(0===e)return f;if(0===f)return e;if(c.get(e).has(f))return c.get(e).get(f);var k=0;a[e-1]!==b[f-1]&&(k=1);k=Math.min(h(e-1,f)+1,h(e,f-1)+1,h(e-1,f-1)+k);c.get(e).set(f,k);return k}(a.length,b.length)}
185
- function lg(a){const b=jg[a]?jg[a]:Object.keys(jg).map(c=>({name:c,sb:kg(a,c.slice(c.lastIndexOf(":")+1))})).sort((c,d)=>c.sb-d.sb).slice(0,5).filter(c=>c.sb<a.length/2).reduce((c,d)=>c.concat(jg[d.name]),[]).slice(0,5);return b.length?b.map(c=>`"Q{${c.namespaceURI}}${c.localName} (${c.j.map(d=>4===d?"...":Ha(d)).join(", ")})"`).reduce((c,d,e,f)=>0===e?c+d:c+((e!==f.length-1?", ":" or ")+d),"Did you mean ")+"?":"No similar functions found."}
186
- function mg(a,b,c){var d=jg[a+":"+b];return d?(d=d.find(e=>e.j.some(f=>4===f)?e.j.length-1<=c:e.j.length===c))?{j:d.j,arity:c,callFunction:d.callFunction,I:d.I,localName:b,namespaceURI:a,i:d.i}:null:null}function ng(a,b,c,d,e){jg[a+":"+b]||(jg[a+":"+b]=[]);jg[a+":"+b].push({j:c,arity:c.length,callFunction:e,I:!1,localName:b,namespaceURI:a,i:d})};var og={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"};var pg=class{constructor(a,b,c,d){this.Da=[Object.create(null)];this.Ea=Object.create(null);this.s=a;this.ia=Object.keys(b).reduce((e,f)=>{if(void 0===b[f])return e;e[f]=`Q{}${f}[0]`;return e},Object.create(null));this.o=Object.create(null);this.h=Object.create(null);this.v=c;this.l=d;this.D=[]}va(a,b,c){return mg(a,b,c)}eb(a,b){if(a)return null;a=this.ia[b];this.o[b]||(this.o[b]={name:b});return a}Sa(a,b){const c=this.l(a,b);if(c)this.D.push({dc:a,arity:b,Db:c});else if(""===a.prefix){if(this.v)return{namespaceURI:this.v,
187
- localName:a.localName}}else if(b=this.$(a.prefix,!0))return{namespaceURI:b,localName:a.localName};return c}$(a,b=!0){if(!b)return null;if(og[a])return og[a];b=this.s(a);this.h[a]||(this.h[a]={namespaceURI:b,prefix:a});return void 0!==b||a?b:null}};var qg=(a,b)=>{a=2===a.node.nodeType?`${a.node.nodeName}="${hb(b,a)}"`:a.node.outerHTML;return Error(`XQTY0024: The node ${a} follows a node that is not an attribute node or a namespace node.`)},rg=a=>Error(`XQDY0044: The node name "${a.za()}" is invalid for a computed attribute constructor.`),sg=()=>Error("XQST0045: Functions and variables may not be declared in one of the reserved namespace URIs."),tg=(a,b)=>Error(`XQST0049: The function or variable "Q{${a}}${b}" is declared more than once.`),ug=
188
- ()=>Error("XQST0060: Functions declared in a module or as an external function must reside in a namespace."),vg=()=>Error("XQST0066: A Prolog may contain at most one default function namespace declaration."),wg=()=>Error("XQST0070: The prefixes xml and xmlns may not be used in a namespace declaration or be bound to another namespaceURI."),xg=a=>Error(`XQDY0074: The value "${a}" of a name expressions cannot be converted to an expanded QName.`),yg=a=>Error(`XPST0081: The prefix "${a}" could not be resolved`);function zg(a,b){return`Q{${a||""}}${b}`}function Ag(a,b){for(let c=a.length-1;0<=c;--c)if(b in a[c])return a[c][b]}function Ef(a){const b=new Bg(a.o);for(let c=0;c<a.h+1;++c)b.D=[Object.assign(Object.create(null),b.D[0],a.D[c])],b.Da=[Object.assign(Object.create(null),b.Da[0],a.Da[c])],b.l=Object.assign(Object.create(null),a.l),b.Ea=a.Ea,b.v=a.v;return b}function Cg(a){a.s++;a.h++;a.D[a.h]=Object.create(null);a.Da[a.h]=Object.create(null)}function Dg(a,b,c){return(a=a.Ea[zg(b,c)])?a:null}
189
- function Eg(a,b,c,d,e){d=zg(b,c)+"~"+d;if(a.l[d])throw tg(b,c);a.l[d]=e}function Fg(a,b,c){a.D[a.h][b]=c}function Gg(a,b,c){b=zg(b||"",c);return a.Da[a.h][b]=`${b}[${a.s}]`}function Hg(a,b,c,d){a.Ea[`${zg(b||"",c)}[${a.s}]`]=d}function Ig(a){a.D.length=a.h;a.Da.length=a.h;a.h--}
190
- var Bg=class{constructor(a){this.o=a;this.s=this.h=0;this.D=[Object.create(null)];this.l=Object.create(null);this.v=null;this.Ea=a&&a.Ea;this.Da=a&&a.Da}va(a,b,c,d=!1){const e=this.l[zg(a,b)+"~"+c];return!e||d&&e.wb?null===this.o?null:this.o.va(a,b,c,d):e}eb(a,b){const c=Ag(this.Da,zg(a,b));return c?c:null===this.o?null:this.o.eb(a,b)}Sa(a,b){var c=a.prefix;const d=a.localName;return""===c&&this.v?{localName:d,namespaceURI:this.v}:c&&(c=this.$(c,!1))?{localName:d,namespaceURI:c}:null===this.o?null:
191
- this.o.Sa(a,b)}$(a,b=!0){const c=Ag(this.D,a||"");return void 0===c?null===this.o?void 0:this.o.$(a||"",b):c}};function F(a,b){"*"===b||Array.isArray(b)||(b=[b]);for(let c=1;c<a.length;++c){if(!Array.isArray(a[c]))continue;const d=a[c];if("*"===b||b.includes(d[0]))return d}return null}function H(a){return 2>a.length?"":"object"===typeof a[1]?a[2]||"":a[1]||""}function I(a,b){if(!Array.isArray(a))return null;a=a[1];return"object"!==typeof a||Array.isArray(a)?null:b in a?a[b]:null}function J(a,b){return b.reduce(F,a)}
192
- function K(a,b){const c=[];for(let d=1;d<a.length;++d){if(!Array.isArray(a[d]))continue;const e=a[d];"*"!==b&&e[0]!==b||c.push(e)}return c}function Jg(a){return{localName:H(a),namespaceURI:I(a,"URI"),prefix:I(a,"prefix")}}
193
- function Kg(a){const b=F(a,"typeDeclaration");if(!b||F(b,"voidSequenceType"))return{type:59,g:2};const c=f=>{switch(f[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;
194
- case "atomicType":return Ia([I(f,"prefix"),H(f)].join(":"));case "parenthesizedItemType":return c(F(f,"*"));default:throw Error(`Type declaration "${F(b,"*")[0]}" is not supported.`);}};a={type:c(F(b,"*")),g:3};let d=null;const e=F(b,"occurrenceIndicator");e&&(d=H(e));switch(d){case "*":return a.g=2,a;case "?":return a.g=0,a;case "+":return a.g=1,a;case "":case null:return a}}function L(a,b,c){if("object"!==typeof a[1]||Array.isArray(a[1])){const d={};d[b]=c;a.splice(1,0,d)}else a[1][b]=c};function Lg(a){const b={type:62,g:3};L(a,"type",b);return b};function Mg(a,b){if(!b||!b.ga)return{type:59,g:2};var c=F(a,"EQName");if(!c)return{type:59,g:2};var d=Jg(c);c=d.localName;const e=d.prefix;d=K(F(a,"arguments"),"*");c=b.ga.Sa({localName:c,prefix:e},d.length);if(!c)return{type:59,g:2};b=b.ga.va(c.namespaceURI,c.localName,d.length+1);if(!b)return{type:59,g:2};59!==b.i.type&&L(a,"type",b.i);return b.i};function M(a,b,c){return(a<<20)+(b<<12)+(c.charCodeAt(0)<<8)+c.charCodeAt(1)}
195
- var Ng={[M(2,2,"idivOp")]:5,[M(16,16,"addOp")]:16,[M(16,16,"subtractOp")]:16,[M(16,16,"divOp")]:4,[M(16,2,"multiplyOp")]:16,[M(16,2,"divOp")]:16,[M(2,16,"multiplyOp")]:16,[M(17,17,"addOp")]:17,[M(17,17,"subtractOp")]:17,[M(17,17,"divOp")]:4,[M(17,2,"multiplyOp")]:17,[M(17,2,"divOp")]:17,[M(2,17,"multiplyOp")]:17,[M(9,9,"subtractOp")]:17,[M(7,7,"subtractOp")]:17,[M(8,8,"subtractOp")]:17,[M(9,16,"addOp")]:9,[M(9,16,"subtractOp")]:9,[M(9,17,"addOp")]:9,[M(9,17,"subtractOp")]:9,[M(7,16,"addOp")]:7,[M(7,
196
- 16,"subtractOp")]:7,[M(7,17,"addOp")]:7,[M(7,17,"subtractOp")]:7,[M(8,17,"addOp")]:8,[M(8,17,"subtractOp")]:8,[M(9,16,"addOp")]:9,[M(9,16,"subtractOp")]:9,[M(9,17,"addOp")]:9,[M(9,17,"subtractOp")]:9,[M(7,17,"addOp")]:7,[M(7,17,"subtractOp")]:7,[M(7,16,"addOp")]:7,[M(7,16,"subtractOp")]:7,[M(8,17,"addOp")]:8,[M(8,17,"subtractOp")]:8},Og={[M(2,2,"addOp")]:(a,b)=>a+b,[M(2,2,"subtractOp")]:(a,b)=>a-b,[M(2,2,"multiplyOp")]:(a,b)=>a*b,[M(2,2,"divOp")]:(a,b)=>a/b,[M(2,2,"modOp")]:(a,b)=>a%b,[M(2,2,"idivOp")]:(a,
197
- b)=>Math.trunc(a/b),[M(16,16,"addOp")]:function(a,b){return new Kc(a.ea+b.ea)},[M(16,16,"subtractOp")]:function(a,b){return new Kc(a.ea-b.ea)},[M(16,16,"divOp")]:function(a,b){return a.ea/b.ea},[M(16,2,"multiplyOp")]:Mc,[M(16,2,"divOp")]:function(a,b){if(isNaN(b))throw Error("FOCA0005: Cannot divide xs:yearMonthDuration by NaN");a=Math.round(a.ea/b);if(a>Number.MAX_SAFE_INTEGER||!Number.isFinite(a))throw Error("FODT0002: Value overflow while dividing xs:yearMonthDuration");return new Kc(a<Number.MIN_SAFE_INTEGER||
198
- 0===a?0:a)},[M(2,16,"multiplyOp")]:(a,b)=>Mc(b,a),[M(17,17,"addOp")]:function(a,b){return new yb(a.ca+b.ca)},[M(17,17,"subtractOp")]:function(a,b){return new yb(a.ca-b.ca)},[M(17,17,"divOp")]:function(a,b){if(0===b.ca)throw Error("FOAR0001: Division by 0");return a.ca/b.ca},[M(17,2,"multiplyOp")]:Cb,[M(17,2,"divOp")]:function(a,b){if(isNaN(b))throw Error("FOCA0005: Cannot divide xs:dayTimeDuration by NaN");a=a.ca/b;if(a>Number.MAX_SAFE_INTEGER||!Number.isFinite(a))throw Error("FODT0002: Value overflow while dividing xs:dayTimeDuration");
199
- return new yb(a<Number.MIN_SAFE_INTEGER||Object.is(-0,a)?0:a)},[M(2,17,"multiplyOp")]:(a,b)=>Cb(b,a),[M(9,9,"subtractOp")]:Pb,[M(7,7,"subtractOp")]:Pb,[M(8,8,"subtractOp")]:Pb,[M(9,16,"addOp")]:Qb,[M(9,16,"subtractOp")]:Rb,[M(9,17,"addOp")]:Qb,[M(9,17,"subtractOp")]:Rb,[M(7,16,"addOp")]:Qb,[M(7,16,"subtractOp")]:Rb,[M(7,17,"addOp")]:Qb,[M(7,17,"subtractOp")]:Rb,[M(8,17,"addOp")]:Qb,[M(8,17,"subtractOp")]:Rb,[M(9,16,"addOp")]:Qb,[M(9,16,"subtractOp")]:Rb,[M(9,17,"addOp")]:Qb,[M(9,17,"subtractOp")]:Rb,
200
- [M(7,17,"addOp")]:Qb,[M(7,17,"subtractOp")]:Rb,[M(7,16,"addOp")]:Qb,[M(7,16,"subtractOp")]:Rb,[M(8,17,"addOp")]:Qb,[M(8,17,"subtractOp")]:Rb};function Pg(a,b){return v(a,5)&&v(b,5)?5:v(a,4)&&v(b,4)?4:v(a,6)&&v(b,6)?6:3}const Qg=[2,16,17,9,7,8];
201
- function Rg(a,b,c){function d(l,n){return{U:e?e(l):l,V:f?f(n):n}}let e=null,f=null;v(b,19)&&(e=l=>jd(l,3),b=3);v(c,19)&&(f=l=>jd(l,3),c=3);const h=Qg.filter(l=>v(b,l)),k=Qg.filter(l=>v(c,l));if(h.includes(2)&&k.includes(2)){const l=Og[M(2,2,a)];let n=Ng[M(2,2,a)];n||=Pg(b,c);"divOp"===a&&5===n&&(n=4);return"idivOp"===a?Sg(d,l)[0]:(t,u)=>{const {U:z,V:y}=d(t,u);return g(l(z.value,y.value),n)}}for(const l of h)for(const n of k){const t=Og[M(l,n,a)],u=Ng[M(l,n,a)];if(t&&void 0!==u)return(z,y)=>{const {U:G,
202
- V:N}=d(z,y);return g(t(G.value,N.value),u)}}}
203
- function Tg(a,b,c){function d(n,t){return{U:f?f(n):n,V:h?h(t):t}}var e=[2,53,59,46,47];if(e.includes(b)||e.includes(c))return 2;let f=null,h=null;v(b,19)&&(f=n=>jd(n,3),b=3);v(c,19)&&(h=n=>jd(n,3),c=3);var k=Qg.filter(n=>v(b,n));e=Qg.filter(n=>v(c,n));if(k.includes(2)&&e.includes(2)){var l=Ng[M(2,2,a)];void 0===l&&(l=Pg(b,c));"divOp"===a&&5===l&&(l=4);return"idivOp"===a?Sg(d,(n,t)=>Math.trunc(n/t))[1]:l}for(l of k)for(const n of e)if(k=Ng[M(l,n,a)],void 0!==k)return k}
204
- function Sg(a,b){return[(c,d)=>{const {U:e,V:f}=a(c,d);if(0===f.value)throw Error("FOAR0001: Divisor of idiv operator cannot be (-)0");if(Number.isNaN(e.value)||Number.isNaN(f.value)||!Number.isFinite(e.value))throw Error("FOAR0002: One of the operands of idiv is NaN or the first operand is (-)INF");return Number.isFinite(e.value)&&!Number.isFinite(f.value)?g(0,5):g(b(e.value,f.value),5)},5]}const Ug=Object.create(null);
205
- var Vg=class extends D{constructor(a,b,c,d,e){super(b.o.add(c.o),[b,c],{B:!1},!1,d);this.A=b;this.L=c;this.l=a;this.s=e}h(a,b){return qc(C(this.A,a,b),b).N(c=>0===c.length?w.empty():qc(C(this.L,a,b),b).N(d=>{if(0===d.length)return w.empty();if(1<c.length||1<d.length)throw Error('XPTY0004: the operands of the "'+this.l+'" operator should be empty or singleton.');const e=c[0];d=d[0];if(this.s&&this.type)return w.m(this.s(e,d));var f=e.type;var h=d.type,k=this.l;const l=`${f}~${h}~${k}`;let n=Ug[l];
206
- n||=Ug[l]=Rg(k,f,h);f=n;if(!f)throw Error(`XPTY0004: ${this.l} not available for types ${Da[e.type]} and ${Da[d.type]}`);return w.m(f(e,d))}))}};function Wg(a,b){var c=O;let d=!1;for(var e=1;e<a.length;e++)switch(a[e][0]){case "letClause":Xg(b);var f=a[e],h=b,k=c,l=J(f,["letClauseItem","typedVariableBinding","varName"]);l=Jg(l);f=J(f,["letClauseItem","letExpr"]);k=k(f[1],h);Yg(h,l.localName,k);break;case "forClause":d=!0;Xg(b);Zg(a[e],b,c);break;case "whereClause":Xg(b);h=a[e];c(h,b);L(h,"type",{type:0,g:3});break;case "orderByClause":Xg(b);break;case "returnClause":e=a[e];h=c;c=J(e,["*"]);b=h(c,b);L(c,"type",b);L(e,"type",b);c=b;if(!c)return{type:59,
175
+ 16)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dayTimeDuration",j:[{type:46,g:0}],i:{type:17,g:0},callFunction:E.bind(null,17)},{namespaceURI:"http://www.w3.org/2001/XMLSchema",localName:"dateTimeStamp",j:[{type:46,g:0}],i:{type:10,g:0},callFunction:E.bind(null,10)}];const Pf=(a,b,c,d)=>d.isEmpty()?d:w.m(g(d.first().value.getYear(),5)),Qf=(a,b,c,d)=>d.isEmpty()?d:w.m(g(d.first().value.getMonth(),5)),Rf=(a,b,c,d)=>d.isEmpty()?d:w.m(g(d.first().value.getDay(),5)),Sf=(a,b,c,d)=>d.isEmpty()?d:w.m(g(d.first().value.getHours(),5)),Tf=(a,b,c,d)=>d.isEmpty()?d:w.m(g(d.first().value.getMinutes(),5)),Uf=(a,b,c,d)=>{d.isEmpty()||(a=w,b=a.m,d=d.first().value,d=b.call(a,g(d.D+d.ma,4)));return d},Vf=(a,b,c,d)=>d.isEmpty()?d:(a=d.first().value.W)?w.m(g(a,17)):w.empty();
176
+ var Wf=[{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:(a,b,c,d,e)=>{if(d.isEmpty())return d;if(e.isEmpty())return e;a=d.first().value;e=e.first().value;b=a.W;c=e.W;if(b||c){if(!b||c)if(!b&&c)b=c;else if(!b.equals(c))throw Error("FORG0008: fn:dateTime: got a date and time value with different timezones.");}else b=null;e=new Lb(a.getYear(),a.getMonth(),a.getDay(),e.getHours(),e.getMinutes(),e.getSeconds(),e.ma,b);
177
+ return w.m(g(e,9))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"year-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Pf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"month-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Qf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"day-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Rf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-dateTime",
178
+ j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Sf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-dateTime",j:[{type:9,g:0}],i:{type:5,g:0},callFunction:Tf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-dateTime",j:[{type:9,g:0}],i:{type:4,g:0},callFunction:Uf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-dateTime",j:[{type:9,g:0}],i:{type:17,g:0},callFunction:Vf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
179
+ localName:"year-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:Pf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"month-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:Qf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"day-from-date",j:[{type:7,g:0}],i:{type:5,g:0},callFunction:Rf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-date",j:[{type:7,g:0}],i:{type:17,g:0},callFunction:Vf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
180
+ localName:"hours-from-time",j:[{type:8,g:0}],i:{type:5,g:0},callFunction:Sf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"minutes-from-time",j:[{type:8,g:0}],i:{type:5,g:0},callFunction:Tf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-time",j:[{type:8,g:0}],i:{type:4,g:0},callFunction:Uf},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"timezone-from-time",j:[{type:8,g:0}],i:{type:17,g:0},callFunction:Vf}];function Xf(a,b){const c=b.h,d=b.Ja,e=b.Oa;switch(a.node.nodeType){case 1:const h=d.createElementNS(a.node.namespaceURI,a.node.nodeName);c.getAllAttributes(a.node).forEach(k=>e.setAttributeNS(h,k.namespaceURI,k.nodeName,k.value));for(var f of gb(c,a))a=Xf(f,b),e.insertBefore(h,a.node,null);return{node:h,F:null};case 2:return b=d.createAttributeNS(a.node.namespaceURI,a.node.nodeName),b.value=hb(c,a),{node:b,F:null};case 4:return{node:d.createCDATASection(hb(c,a)),F:null};case 8:return{node:d.createComment(hb(c,
181
+ a)),F:null};case 9:f=d.createDocument();for(const k of gb(c,a))a=Xf(k,b),e.insertBefore(f,a.node,null);return{node:f,F:null};case 7:return{node:d.createProcessingInstruction(a.node.target,hb(c,a)),F:null};case 3:return{node:d.createTextNode(hb(c,a)),F:null}}};function Yf(a,b){const c=b.Oa;var d=b.Ja;const e=b.h;if(cb(a.node))switch(a.node.nodeType){case 2:return d=d.createAttributeNS(a.node.namespaceURI,a.node.nodeName),d.value=hb(e,a),d;case 8:return d.createComment(hb(e,a));case 1:const f=a.node.prefix,h=a.node.localName,k=d.createElementNS(a.node.namespaceURI,f?f+":"+h:h);gb(e,a).forEach(l=>{l=Yf(l,b);c.insertBefore(k,l,null)});eb(e,a).forEach(l=>{c.setAttributeNS(k,l.node.namespaceURI,l.node.nodeName,hb(e,l))});k.normalize();return k;case 7:return d.createProcessingInstruction(a.node.target,
182
+ hb(e,a));case 3:return d.createTextNode(hb(e,a))}else return Xf(a,b).node}function Zf(a,b,c){let d=a;for(a=x(c,d);null!==a;){if(2===d.node.nodeType)b.push(d.node.nodeName);else{const e=gb(c,a);b.push(e.findIndex(f=>nd(f,d)))}d=a;a=x(c,d)}return d}function $f(a,b,c){for(;0<b.length;){const d=b.pop();"string"===typeof d?a=eb(c,a).find(e=>e.node.nodeName===d):a=gb(c,a)[d]}return a.node}
183
+ function ag(a,b,c){var d=a.node;if(!(cb(d)||c||a.F))return d;d=b.v;const e=[];if(c)return Yf(a,b);a=Zf(a,e,b.h);c=d.get(a.node);c||(c={node:Yf(a,b),F:null},d.set(a.node,c));return $f(c,e,b.h)};const bg=(a,b,c,d,e)=>d.M(f=>{var h;let k="";for(let l=0;l<f.length;l++){const n=f[l],t=b.Wa&&v(n.type,53)?b.Wa.serializeToString(ag(n.value,b,!1)):null===(h=rc(w.m(n),b).map(u=>kd(u,1)).first())||void 0===h?void 0:h.value;t&&(k+=`{type: ${Da[n.type]}, value: ${t}}\n`)}void 0!==e&&(k+=e.first().value);b.jb.trace(k);return w.create(f)});
184
+ var cg=[{j:[{type:59,g:2}],callFunction:bg,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:bg,localName:"trace",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}}];const dg=(a,b,c,d,e)=>{a=void 0===d||d.isEmpty()?new Sa("err","http://www.w3.org/2005/xqt-errors","FOER0000"):d.first().value;b="";void 0===e||e.isEmpty()||(b=`: ${e.first().value}`);throw Error(`${a.localName}${b}`);};
185
+ var eg=[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[],i:{type:63,g:3},callFunction:dg},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"error",j:[{type:23,g:0}],i:{type:63,g:3},callFunction:dg},{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:dg},{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,
186
+ g:3},callFunction(){throw Error("Not implemented: Using an error object in error is not supported");}}];function fg(a){return"string"===typeof a?a:(a=(new Za).getChildNodes(a).find(b=>8===b.nodeType))?a.data:"some expression"};var gg=class extends Error{constructor(a,b){super(a);this.position={end:{ga:b.end.ga,line:b.end.line,offset:b.end.offset},start:{ga:b.start.ga,line:b.start.line,offset:b.start.offset}}}};function hg(a,b){if(b instanceof Error)throw b;"string"!==typeof a&&(a=fg(a));const c=ig(b);a=a.replace(/\r/g,"").split("\n");const d=Math.floor(Math.log10(Math.min(c.end.line+2,a.length)))+1;a=a.reduce((e,f,h)=>{var k=h+1;if(2<c.start.line-k||2<k-c.end.line)return e;h=`${Array(d).fill(" ",0,Math.floor(Math.log10(k))+1-d).join("")}${k}: `;e.push(`${h}${f}`);if(k>=c.start.line&&k<=c.end.line){const l=k<c.end.line?f.length+h.length:c.end.ga-1+h.length;k=k>c.start.line?h.length:c.start.ga-1+h.length;
187
+ f=" ".repeat(h.length)+Array.from(f.substring(0,k-h.length),n=>"\t"===n?"\t":" ").join("")+"^".repeat(l-k);e.push(f)}return e},[]);b=jg(b).join("\n");throw new gg(a.join("\n")+"\n\n"+b,c);};const kg=Object.create(null);function lg(a,b){const c=new Map;for(let d=0;d<a.length+1;++d)c.set(d,new Map);return function h(e,f){if(0===e)return f;if(0===f)return e;if(c.get(e).has(f))return c.get(e).get(f);var k=0;a[e-1]!==b[f-1]&&(k=1);k=Math.min(h(e-1,f)+1,h(e,f-1)+1,h(e-1,f-1)+k);c.get(e).set(f,k);return k}(a.length,b.length)}
188
+ function mg(a){const b=kg[a]?kg[a]:Object.keys(kg).map(c=>({name:c,sb:lg(a,c.slice(c.lastIndexOf(":")+1))})).sort((c,d)=>c.sb-d.sb).slice(0,5).filter(c=>c.sb<a.length/2).reduce((c,d)=>c.concat(kg[d.name]),[]).slice(0,5);return b.length?b.map(c=>`"Q{${c.namespaceURI}}${c.localName} (${c.j.map(d=>4===d?"...":Ha(d)).join(", ")})"`).reduce((c,d,e,f)=>0===e?c+d:c+((e!==f.length-1?", ":" or ")+d),"Did you mean ")+"?":"No similar functions found."}
189
+ function ng(a,b,c){var d=kg[a+":"+b];return d?(d=d.find(e=>e.j.some(f=>4===f)?e.j.length-1<=c:e.j.length===c))?{j:d.j,arity:c,callFunction:d.callFunction,H:d.H,localName:b,namespaceURI:a,i:d.i}:null:null}function og(a,b,c,d,e){kg[a+":"+b]||(kg[a+":"+b]=[]);kg[a+":"+b].push({j:c,arity:c.length,callFunction:e,H:!1,localName:b,namespaceURI:a,i:d})};var pg={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"};var qg=class{constructor(a,b,c,d){this.Ea=[Object.create(null)];this.Fa=Object.create(null);this.s=a;this.ha=Object.keys(b).reduce((e,f)=>{if(void 0===b[f])return e;e[f]=`Q{}${f}[0]`;return e},Object.create(null));this.o=Object.create(null);this.h=Object.create(null);this.v=c;this.l=d;this.D=[]}ua(a,b,c){return ng(a,b,c)}eb(a,b){if(a)return null;a=this.ha[b];this.o[b]||(this.o[b]={name:b});return a}Ua(a,b){const c=this.l(a,b);if(c)this.D.push({fc:a,arity:b,Eb:c});else if(""===a.prefix){if(this.v)return{namespaceURI:this.v,
190
+ localName:a.localName}}else if(b=this.Z(a.prefix,!0))return{namespaceURI:b,localName:a.localName};return c}Z(a,b=!0){if(!b)return null;if(pg[a])return pg[a];b=this.s(a);this.h[a]||(this.h[a]={namespaceURI:b,prefix:a});return void 0!==b||a?b:null}};var rg=(a,b)=>{a=2===a.node.nodeType?`${a.node.nodeName}="${hb(b,a)}"`:a.node.outerHTML;return Error(`XQTY0024: The node ${a} follows a node that is not an attribute node or a namespace node.`)},sg=a=>Error(`XQDY0044: The node name "${a.Aa()}" is invalid for a computed attribute constructor.`),tg=()=>Error("XQST0045: Functions and variables may not be declared in one of the reserved namespace URIs."),ug=(a,b)=>Error(`XQST0049: The function or variable "Q{${a}}${b}" is declared more than once.`),vg=
191
+ ()=>Error("XQST0060: Functions declared in a module or as an external function must reside in a namespace."),wg=()=>Error("XQST0066: A Prolog may contain at most one default function namespace declaration."),xg=()=>Error("XQST0070: The prefixes xml and xmlns may not be used in a namespace declaration or be bound to another namespaceURI."),yg=a=>Error(`XQDY0074: The value "${a}" of a name expressions cannot be converted to an expanded QName.`),zg=a=>Error(`XPST0081: The prefix "${a}" could not be resolved`);function Ag(a,b){return`Q{${a||""}}${b}`}function Bg(a,b){for(let c=a.length-1;0<=c;--c)if(b in a[c])return a[c][b]}function Ff(a){const b=new Cg(a.o);for(let c=0;c<a.h+1;++c)b.D=[Object.assign(Object.create(null),b.D[0],a.D[c])],b.Ea=[Object.assign(Object.create(null),b.Ea[0],a.Ea[c])],b.l=Object.assign(Object.create(null),a.l),b.Fa=a.Fa,b.v=a.v;return b}function Dg(a){a.s++;a.h++;a.D[a.h]=Object.create(null);a.Ea[a.h]=Object.create(null)}function Eg(a,b,c){return(a=a.Fa[Ag(b,c)])?a:null}
192
+ function Fg(a,b,c,d,e){d=Ag(b,c)+"~"+d;if(a.l[d])throw ug(b,c);a.l[d]=e}function Gg(a,b,c){a.D[a.h][b]=c}function Hg(a,b,c){b=Ag(b||"",c);return a.Ea[a.h][b]=`${b}[${a.s}]`}function Ig(a,b,c,d){a.Fa[`${Ag(b||"",c)}[${a.s}]`]=d}function Jg(a){a.D.length=a.h;a.Ea.length=a.h;a.h--}
193
+ var Cg=class{constructor(a){this.o=a;this.s=this.h=0;this.D=[Object.create(null)];this.l=Object.create(null);this.v=null;this.Fa=a&&a.Fa;this.Ea=a&&a.Ea}ua(a,b,c,d=!1){const e=this.l[Ag(a,b)+"~"+c];return!e||d&&e.wb?null===this.o?null:this.o.ua(a,b,c,d):e}eb(a,b){const c=Bg(this.Ea,Ag(a,b));return c?c:null===this.o?null:this.o.eb(a,b)}Ua(a,b){var c=a.prefix;const d=a.localName;return""===c&&this.v?{localName:d,namespaceURI:this.v}:c&&(c=this.Z(c,!1))?{localName:d,namespaceURI:c}:null===this.o?null:
194
+ this.o.Ua(a,b)}Z(a,b=!0){const c=Bg(this.D,a||"");return void 0===c?null===this.o?void 0:this.o.Z(a||"",b):c}};function G(a,b){"*"===b||Array.isArray(b)||(b=[b]);for(let c=1;c<a.length;++c){if(!Array.isArray(a[c]))continue;const d=a[c];if("*"===b||b.includes(d[0]))return d}return null}function H(a){return 2>a.length?"":"object"===typeof a[1]?a[2]||"":a[1]||""}function I(a,b){if(!Array.isArray(a))return null;a=a[1];return"object"!==typeof a||Array.isArray(a)?null:b in a?a[b]:null}function J(a,b){return b.reduce(G,a)}
195
+ function K(a,b){const c=[];for(let d=1;d<a.length;++d){if(!Array.isArray(a[d]))continue;const e=a[d];"*"!==b&&e[0]!==b||c.push(e)}return c}function Kg(a){return{localName:H(a),namespaceURI:I(a,"URI"),prefix:I(a,"prefix")}}
196
+ function Lg(a){const b=G(a,"typeDeclaration");if(!b||G(b,"voidSequenceType"))return{type:59,g:2};const c=f=>{switch(f[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;
197
+ case "atomicType":return Ia([I(f,"prefix"),H(f)].join(":"));case "parenthesizedItemType":return c(G(f,"*"));default:throw Error(`Type declaration "${G(b,"*")[0]}" is not supported.`);}};a={type:c(G(b,"*")),g:3};let d=null;const e=G(b,"occurrenceIndicator");e&&(d=H(e));switch(d){case "*":return a.g=2,a;case "?":return a.g=0,a;case "+":return a.g=1,a;case "":case null:return a}}function L(a,b,c){if("object"!==typeof a[1]||Array.isArray(a[1])){const d={};d[b]=c;a.splice(1,0,d)}else a[1][b]=c};function Mg(a){const b={type:62,g:3};L(a,"type",b);return b};function Ng(a,b){if(!b||!b.fa)return{type:59,g:2};var c=G(a,"EQName");if(!c)return{type:59,g:2};var d=Kg(c);c=d.localName;const e=d.prefix;d=K(G(a,"arguments"),"*");c=b.fa.Ua({localName:c,prefix:e},d.length);if(!c)return{type:59,g:2};b=b.fa.ua(c.namespaceURI,c.localName,d.length+1);if(!b)return{type:59,g:2};59!==b.i.type&&L(a,"type",b.i);return b.i};function M(a,b,c){return(a<<20)+(b<<12)+(c.charCodeAt(0)<<8)+c.charCodeAt(1)}
198
+ var Og={[M(2,2,"idivOp")]:5,[M(16,16,"addOp")]:16,[M(16,16,"subtractOp")]:16,[M(16,16,"divOp")]:4,[M(16,2,"multiplyOp")]:16,[M(16,2,"divOp")]:16,[M(2,16,"multiplyOp")]:16,[M(17,17,"addOp")]:17,[M(17,17,"subtractOp")]:17,[M(17,17,"divOp")]:4,[M(17,2,"multiplyOp")]:17,[M(17,2,"divOp")]:17,[M(2,17,"multiplyOp")]:17,[M(9,9,"subtractOp")]:17,[M(7,7,"subtractOp")]:17,[M(8,8,"subtractOp")]:17,[M(9,16,"addOp")]:9,[M(9,16,"subtractOp")]:9,[M(9,17,"addOp")]:9,[M(9,17,"subtractOp")]:9,[M(7,16,"addOp")]:7,[M(7,
199
+ 16,"subtractOp")]:7,[M(7,17,"addOp")]:7,[M(7,17,"subtractOp")]:7,[M(8,17,"addOp")]:8,[M(8,17,"subtractOp")]:8,[M(9,16,"addOp")]:9,[M(9,16,"subtractOp")]:9,[M(9,17,"addOp")]:9,[M(9,17,"subtractOp")]:9,[M(7,17,"addOp")]:7,[M(7,17,"subtractOp")]:7,[M(7,16,"addOp")]:7,[M(7,16,"subtractOp")]:7,[M(8,17,"addOp")]:8,[M(8,17,"subtractOp")]:8},Pg={[M(2,2,"addOp")]:(a,b)=>a+b,[M(2,2,"subtractOp")]:(a,b)=>a-b,[M(2,2,"multiplyOp")]:(a,b)=>a*b,[M(2,2,"divOp")]:(a,b)=>a/b,[M(2,2,"modOp")]:(a,b)=>a%b,[M(2,2,"idivOp")]:(a,
200
+ b)=>Math.trunc(a/b),[M(16,16,"addOp")]:function(a,b){return new Lc(a.da+b.da)},[M(16,16,"subtractOp")]:function(a,b){return new Lc(a.da-b.da)},[M(16,16,"divOp")]:function(a,b){return a.da/b.da},[M(16,2,"multiplyOp")]:Nc,[M(16,2,"divOp")]:function(a,b){if(isNaN(b))throw Error("FOCA0005: Cannot divide xs:yearMonthDuration by NaN");a=Math.round(a.da/b);if(a>Number.MAX_SAFE_INTEGER||!Number.isFinite(a))throw Error("FODT0002: Value overflow while dividing xs:yearMonthDuration");return new Lc(a<Number.MIN_SAFE_INTEGER||
201
+ 0===a?0:a)},[M(2,16,"multiplyOp")]:(a,b)=>Nc(b,a),[M(17,17,"addOp")]:function(a,b){return new zb(a.ba+b.ba)},[M(17,17,"subtractOp")]:function(a,b){return new zb(a.ba-b.ba)},[M(17,17,"divOp")]:function(a,b){if(0===b.ba)throw Error("FOAR0001: Division by 0");return a.ba/b.ba},[M(17,2,"multiplyOp")]:Db,[M(17,2,"divOp")]:function(a,b){if(isNaN(b))throw Error("FOCA0005: Cannot divide xs:dayTimeDuration by NaN");a=a.ba/b;if(a>Number.MAX_SAFE_INTEGER||!Number.isFinite(a))throw Error("FODT0002: Value overflow while dividing xs:dayTimeDuration");
202
+ return new zb(a<Number.MIN_SAFE_INTEGER||Object.is(-0,a)?0:a)},[M(2,17,"multiplyOp")]:(a,b)=>Db(b,a),[M(9,9,"subtractOp")]:Qb,[M(7,7,"subtractOp")]:Qb,[M(8,8,"subtractOp")]:Qb,[M(9,16,"addOp")]:Sb,[M(9,16,"subtractOp")]:Tb,[M(9,17,"addOp")]:Sb,[M(9,17,"subtractOp")]:Tb,[M(7,16,"addOp")]:Sb,[M(7,16,"subtractOp")]:Tb,[M(7,17,"addOp")]:Sb,[M(7,17,"subtractOp")]:Tb,[M(8,17,"addOp")]:Sb,[M(8,17,"subtractOp")]:Tb,[M(9,16,"addOp")]:Sb,[M(9,16,"subtractOp")]:Tb,[M(9,17,"addOp")]:Sb,[M(9,17,"subtractOp")]:Tb,
203
+ [M(7,17,"addOp")]:Sb,[M(7,17,"subtractOp")]:Tb,[M(7,16,"addOp")]:Sb,[M(7,16,"subtractOp")]:Tb,[M(8,17,"addOp")]:Sb,[M(8,17,"subtractOp")]:Tb};function Qg(a,b){return v(a,5)&&v(b,5)?5:v(a,4)&&v(b,4)?4:v(a,6)&&v(b,6)?6:3}const Rg=[2,16,17,9,7,8];
204
+ function Sg(a,b,c){function d(l,n){return{T:e?e(l):l,U:f?f(n):n}}let e=null,f=null;v(b,19)&&(e=l=>kd(l,3),b=3);v(c,19)&&(f=l=>kd(l,3),c=3);const h=Rg.filter(l=>v(b,l)),k=Rg.filter(l=>v(c,l));if(h.includes(2)&&k.includes(2)){const l=Pg[M(2,2,a)];let n=Og[M(2,2,a)];n||=Qg(b,c);"divOp"===a&&5===n&&(n=4);return"idivOp"===a?Tg(d,l)[0]:(t,u)=>{const {T:z,U:y}=d(t,u);return g(l(z.value,y.value),n)}}for(const l of h)for(const n of k){const t=Pg[M(l,n,a)],u=Og[M(l,n,a)];if(t&&void 0!==u)return(z,y)=>{const {T:F,
205
+ U:N}=d(z,y);return g(t(F.value,N.value),u)}}}
206
+ function Ug(a,b,c){function d(n,t){return{T:f?f(n):n,U:h?h(t):t}}var e=[2,53,59,46,47];if(e.includes(b)||e.includes(c))return 2;let f=null,h=null;v(b,19)&&(f=n=>kd(n,3),b=3);v(c,19)&&(h=n=>kd(n,3),c=3);var k=Rg.filter(n=>v(b,n));e=Rg.filter(n=>v(c,n));if(k.includes(2)&&e.includes(2)){var l=Og[M(2,2,a)];void 0===l&&(l=Qg(b,c));"divOp"===a&&5===l&&(l=4);return"idivOp"===a?Tg(d,(n,t)=>Math.trunc(n/t))[1]:l}for(l of k)for(const n of e)if(k=Og[M(l,n,a)],void 0!==k)return k}
207
+ function Tg(a,b){return[(c,d)=>{const {T:e,U:f}=a(c,d);if(0===f.value)throw Error("FOAR0001: Divisor of idiv operator cannot be (-)0");if(Number.isNaN(e.value)||Number.isNaN(f.value)||!Number.isFinite(e.value))throw Error("FOAR0002: One of the operands of idiv is NaN or the first operand is (-)INF");return Number.isFinite(e.value)&&!Number.isFinite(f.value)?g(0,5):g(b(e.value,f.value),5)},5]}const Vg=Object.create(null);
208
+ var Wg=class extends C{constructor(a,b,c,d,e){super(b.o.add(c.o),[b,c],{B:!1},!1,d);this.A=b;this.K=c;this.l=a;this.s=e}h(a,b){return rc(A(this.A,a,b),b).M(c=>0===c.length?w.empty():rc(A(this.K,a,b),b).M(d=>{if(0===d.length)return w.empty();if(1<c.length||1<d.length)throw Error('XPTY0004: the operands of the "'+this.l+'" operator should be empty or singleton.');const e=c[0];d=d[0];if(this.s&&this.type)return w.m(this.s(e,d));var f=e.type;var h=d.type,k=this.l;const l=`${f}~${h}~${k}`;let n=Vg[l];
209
+ n||=Vg[l]=Sg(k,f,h);f=n;if(!f)throw Error(`XPTY0004: ${this.l} not available for types ${Da[e.type]} and ${Da[d.type]}`);return w.m(f(e,d))}))}};function Xg(a,b){var c=O;let d=!1;for(var e=1;e<a.length;e++)switch(a[e][0]){case "letClause":Yg(b);var f=a[e],h=b,k=c,l=J(f,["letClauseItem","typedVariableBinding","varName"]);l=Kg(l);f=J(f,["letClauseItem","letExpr"]);k=k(f[1],h);Zg(h,l.localName,k);break;case "forClause":d=!0;Yg(b);$g(a[e],b,c);break;case "whereClause":Yg(b);h=a[e];c(h,b);L(h,"type",{type:0,g:3});break;case "orderByClause":Yg(b);break;case "returnClause":e=a[e];h=c;c=J(e,["*"]);b=h(c,b);L(c,"type",b);L(e,"type",b);c=b;if(!c)return{type:59,
207
210
  g:2};d&&(c={type:c.type,g:2});59!==c.type&&L(a,"type",c);return c;default:c=c(a[e],b);if(!c)return{type:59,g:2};d&&(c={type:c.type,g:2});59!==c.type&&L(a,"type",c);return c}if(0<b.h)b.h--,b.o.pop(),b.v.pop();else throw Error("Variable scope out of bound");}
208
- function Zg(a,b,c){const d=Jg(J(a,["forClauseItem","typedVariableBinding","varName"]));if(a=J(a,["forClauseItem","forExpr","sequenceExpr"]))a=K(a,"*").map(e=>c(e,b)),a.includes(void 0)||a.includes(null)||(a=$g(a),1===a.length&&Yg(b,d.localName,a[0]))}function $g(a){return a.filter((b,c,d)=>d.findIndex(e=>e.type===b.type&&e.g===b.g)===c)};function ah(a,b){if(!b||!b.ga)return{type:59,g:2};const c=F(a,"functionName");var d=Jg(c);let e=d.localName;var f=d.prefix;let h=d.namespaceURI;d=K(F(a,"arguments"),"*");if(null===h){f=b.ga.Sa({localName:e,prefix:f},d.length);if(!f)return{type:59,g:2};e=f.localName;h=f.namespaceURI;L(c,"URI",h);c[2]=e}b=b.ga.va(h,e,d.length);if(!b||63===b.i.type)return{type:59,g:2};59!==b.i.type&&L(a,"type",b.i);return b.i};function bh(a){const b={type:61,g:3};L(a,"type",b);return b};function ch(a,b){if(!b||!b.ga)return{type:59,g:2};const c=F(a,"functionName");var d=Jg(c);let e=d.localName;var f=d.namespaceURI;const h=d.prefix;d=Number(J(a,["integerConstantExpr","value"])[1]);if(!f){f=b.ga.Sa({localName:e,prefix:h},d);if(!f)return{type:59,g:2};e=f.localName;f=f.namespaceURI;L(c,"URI",f)}b=b.ga.va(f,e,d)||null;if(!b)return{type:59,g:2};59!==b.i.type&&63!==b.i.type&&L(a,"type",b.i);return b.i};function dh(a,b){var c=K(a,"stepExpr");if(!c)return{type:59,g:2};for(const f of c){a:{c=f;var d=b;let h=null;if(!c)break a;var e=K(c,"*");let k="";for(const l of e)switch(l[0]){case "filterExpr":h=I(J(l,["*"]),"type");break;case "xpathAxis":k=l[1];b:{switch(k){case "attribute":h={type:47,g:2};break b;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":h=
209
- {type:53,g:2};break b}h=void 0}break;case "nameTest":e=Jg(l);if(null!==e.namespaceURI)break;if("attribute"===k&&!e.prefix)break;e=d.$(e.prefix||"");void 0!==e&&L(l,"URI",e);break;case "lookup":h={type:59,g:2}}h&&59!==h.type&&L(c,"type",h)}d=I(f,"type")}d&&59!==d.type&&L(a,"type",d);return d};function eh(a){const b={type:0,g:3};L(a,"type",b);return b};function fh(a,b,c){0===b?b={type:53,g:2}:1===b?b=c[0]:c.includes(void 0)||c.includes(null)?b={type:59,g:2}:(b=$g(c),b=1<b.length?{type:59,g:2}:{type:b[0].type,g:2});b&&59!==b.type&&L(a,"type",b);return b};function gh(a,b,c,d){if(!b||c.includes(void 0))return{type:59,g:2};var e=K(a,"typeswitchExprCaseClause");for(let h=0;h<c.length;h++){var f=F(e[h],"*");switch(f[0]){case "sequenceType":if(f=hh(f,b,c[h]))return 59!==f.type&&L(a,"type",f),f;continue;case "sequenceTypeUnion":for(d=K(f,"*"),e=0;2>e;e++)if(f=hh(d[e],b,c[h]))return 59!==f.type&&L(a,"type",f),f;default:return{type:59,g:2}}}59!==d.type&&L(a,"type",d);return d}
210
- function hh(a,b,c){const d=K(a,"*"),e=F(a,"atomicType");if(!e)return{type:59,g:2};if(Ia(I(e,"prefix")+":"+e[2])===b.type)if(1===d.length){if(3===b.g)return c}else if(a=F(a,"occurrenceIndicator")[1],b.g===Ka(a))return c};function ih(a,b){O(a,b)}function O(a,b){var c=jh.get(a[0]);if(c)return c(a,b);for(c=1;c<a.length;c++)a[c]&&O(a[c],b)}
211
- const kh=(a,b)=>{var c=O(F(a,"firstOperand")[1],b);const d=O(F(a,"secondOperand")[1],b);var e=a[0];if(c&&d)if(b=Tg(e,c.type,d.type))c={type:b,g:c.g},2!==b&&59!==b&&L(a,"type",c),a=c;else throw Error(`XPTY0004: ${e} not available for types ${Ha(c)} and ${Ha(d)}`);else a={type:2,g:3};return a},lh=(a,b)=>{O(F(a,"firstOperand")[1],b);O(F(a,"secondOperand")[1],b);a:{switch(a[0]){case "orOp":b={type:0,g:3};L(a,"type",b);a=b;break a;case "andOp":b={type:0,g:3};L(a,"type",b);a=b;break a}a=void 0}return a},
212
- mh=(a,b)=>{O(F(a,"firstOperand")[1],b);O(F(a,"secondOperand")[1],b);a:{switch(a[0]){case "unionOp":b={type:53,g:2};L(a,"type",b);a=b;break a;case "intersectOp":b={type:53,g:2};L(a,"type",b);a=b;break a;case "exceptOp":b={type:53,g:2};L(a,"type",b);a=b;break a}a=void 0}return a},nh=(a,b)=>{O(F(a,"firstOperand")[1],b);O(F(a,"secondOperand")[1],b);b={type:0,g:3};L(a,"type",b);return b},oh=(a,b)=>{O(F(a,"firstOperand")[1],b);O(F(a,"secondOperand")[1],b);b=I(J(a,["firstOperand","*"]),"type");const c=I(J(a,
213
- ["secondOperand","*"]),"type");b={type:0,g:wc(b)||wc(c)?0:3};L(a,"type",b);return b},ph=(a,b)=>{O(F(a,"firstOperand")[1],b);O(F(a,"secondOperand")[1],b);b=I(J(a,["firstOperand","*"]),"type");const c=I(J(a,["secondOperand","*"]),"type");b={type:0,g:wc(b)||wc(c)?0:3};L(a,"type",b);return b},jh=new Map([["unaryMinusOp",(a,b)=>{b=O(F(a,"operand")[1],b);b?v(b.type,2)?(b={type:b.type,g:b.g},L(a,"type",b),a=b):(b={type:3,g:3},L(a,"type",b),a=b):(b={type:2,g:2},L(a,"type",b),a=b);return a}],["unaryPlusOp",
214
- (a,b)=>{b=O(F(a,"operand")[1],b);b?v(b.type,2)?(b={type:b.type,g:b.g},L(a,"type",b),a=b):(b={type:3,g:3},L(a,"type",b),a=b):(b={type:2,g:2},L(a,"type",b),a=b);return a}],["addOp",kh],["subtractOp",kh],["divOp",kh],["idivOp",kh],["modOp",kh],["multiplyOp",kh],["andOp",lh],["orOp",lh],["sequenceExpr",(a,b)=>{const c=K(a,"*"),d=c.map(e=>O(e,b));return fh(a,c.length,d)}],["unionOp",mh],["intersectOp",mh],["exceptOp",mh],["stringConcatenateOp",(a,b)=>{O(F(a,"firstOperand")[1],b);O(F(a,"secondOperand")[1],
215
- b);b={type:1,g:3};L(a,"type",b);return b}],["rangeSequenceExpr",(a,b)=>{O(F(a,"startExpr")[1],b);O(F(a,"endExpr")[1],b);b={type:5,g:1};L(a,"type",b);return b}],["equalOp",nh],["notEqualOp",nh],["lessThanOrEqualOp",nh],["lessThanOp",nh],["greaterThanOrEqualOp",nh],["greaterThanOp",nh],["eqOp",oh],["neOp",oh],["ltOp",oh],["leOp",oh],["gtOp",oh],["geOp",oh],["isOp",ph],["nodeBeforeOp",ph],["nodeAfterOp",ph],["pathExpr",(a,b)=>{const c=F(a,"rootExpr");c&&c[1]&&O(c[1],b);K(a,"stepExpr").map(d=>O(d,b));
216
- return dh(a,b)}],["contextItemExpr",()=>({type:59,g:2})],["ifThenElseExpr",(a,b)=>{var c=F(a,"ifClause")||F(K(a,"x:stackTrace")[0],"ifClause");const d=F(a,"thenClause")||F(K(a,"x:stackTrace")[1],"thenClause"),e=F(a,"elseClause")||F(K(a,"x:stackTrace")[2],"elseClause");O(F(c,"*"),b);c=O(F(d,"*"),b);b=O(F(e,"*"),b);c&&b?c.type===b.type&&c.g===b.g?(59!==c.type&&L(a,"type",c),a=c):a={type:59,g:2}:a={type:59,g:2};return a}],["instanceOfExpr",(a,b)=>{O(F(a,"argExpr"),b);O(F(a,"sequenceType"),b);b={type:0,
217
- g:3};L(a,"type",b);return b}],["integerConstantExpr",a=>{const b={type:5,g:3};L(a,"type",b);return b}],["doubleConstantExpr",a=>{const b={type:3,g:3};L(a,"type",b);return b}],["decimalConstantExpr",a=>{const b={type:4,g:3};L(a,"type",b);return b}],["stringConstantExpr",a=>{const b={type:1,g:3};L(a,"type",b);return b}],["functionCallExpr",(a,b)=>{const c=F(a,"arguments");K(c,"*").map(d=>O(d,b));return ah(a,b)}],["arrowExpr",(a,b)=>{O(F(a,"argExpr")[1],b);return Mg(a,b)}],["dynamicFunctionInvocationExpr",
218
- (a,b)=>{O(J(a,["functionItem","*"]),b);(a=F(a,"arguments"))&&O(a,b);return{type:59,g:2}}],["namedFunctionRef",(a,b)=>ch(a,b)],["inlineFunctionExpr",(a,b)=>{O(F(a,"functionBody")[1],b);b={type:60,g:3};L(a,"type",b);return b}],["castExpr",a=>{var b=J(a,["singleType","atomicType"]);b={type:Ia(I(b,"prefix")+":"+b[2]),g:3};59!==b.type&&L(a,"type",b);return b}],["castableExpr",a=>{const b={type:0,g:3};L(a,"type",b);return b}],["simpleMapExpr",(a,b)=>{const c=K(a,"pathExpr");let d;for(let e=0;e<c.length;e++)d=
219
- O(c[e],b);void 0!==d&&null!==d?((b={type:d.type,g:2},59!==b.type)&&L(a,"type",b),a=b):a={type:59,g:2};return a}],["mapConstructor",(a,b)=>{K(a,"mapConstructorEntry").map(c=>({key:O(J(c,["mapKeyExpr","*"]),b),value:O(J(c,["mapValueExpr","*"]),b)}));return bh(a)}],["arrayConstructor",(a,b)=>{K(F(a,"*"),"arrayElem").map(c=>O(c,b));return Lg(a)}],["unaryLookup",a=>{F(a,"NCName");return{type:59,g:2}}],["typeswitchExpr",(a,b)=>{const c=O(F(a,"argExpr")[1],b),d=K(a,"typeswitchExprCaseClause").map(f=>O(J(f,
220
- ["resultExpr"])[1],b)),e=O(J(a,["typeswitchExprDefaultClause","resultExpr"])[1],b);return gh(a,c,d,e)}],["quantifiedExpr",(a,b)=>{K(a,"*").map(c=>O(c,b));return eh(a)}],["x:stackTrace",(a,b)=>{a=K(a,"*");return O(a[0],b)}],["queryBody",(a,b)=>O(a[1],b)],["flworExpr",(a,b)=>Wg(a,b)],["varRef",(a,b)=>{const c=Jg(F(a,"name"));var d;a:{for(d=b.h;0<=d;d--){const e=b.o[d][c.localName];if(e){d=e;break a}}d=void 0}d&&59!==d.type&&L(a,"type",d);null===c.namespaceURI&&(b=b.$(c.prefix),void 0!==b&&L(a,"URI",
221
- b));return d}]]);function Xg(a){a.h++;a.o.push({});a.v.push({})}function Yg(a,b,c){if(a.o[a.h][b])throw Error(`Another variable of in the scope ${a.h} with the same name ${b} already exists`);a.o[a.h][b]=c}var qh=class{constructor(a){this.h=0;this.ga=a;this.o=[{}];this.v=[{}]}$(a){for(let b=this.h;0<=b;b--){const c=this.v[b][a];if(void 0!==c)return c}return this.ga?this.ga.$(a):void 0}};var rh=class extends D{constructor(a,b){super(new uf({external:1}),a,{B:a.every(c=>c.B)},!1,b);this.l=a}h(a,b){return 0===this.l.length?w.m(new pb([])):C(this.l[0],a,b).N(c=>w.m(new pb(c.map(d=>Ra(w.m(d))))))}};var sh=class extends D{constructor(a,b){super(new uf({external:1}),a,{B:a.every(c=>c.B)},!1,b);this.l=a}h(a,b){return w.m(new pb(this.l.map(c=>Ra(C(c,a,b)))))}};function th(a){if(null===a)throw lc("context is absent, it needs to be present to use axes.");if(!v(a.type,53))throw Error("XPTY0020: Axes can only be applied to nodes.");return a.value};function uh(a,b,c){let d=b;return{next:()=>{if(!d)return p;const e=d;d=x(a,e,c);return q(rb(e))}}}var vh=class extends D{constructor(a,b){b=b||{Qa:!1};super(a.o,[a],{R:"reverse-sorted",W:!1,subtree:!1,B:!1});this.l=a;this.s=!!b.Qa}h(a,b){b=b.h;a=th(a.M);var c=this.l.D();c=c&&(c.startsWith("name-")||"type-1"===c)?"type-1":null;return w.create(uh(b,this.s?a:x(b,a,c),c)).filter(d=>this.l.l(d))}};const wh=new Map([["type-1-or-type-2",["name","type-1","type-2"]],["type-1",["name"]],["type-2",["name"]]]);function xh(a,b){if(null===a)return b;if(null===b||a===b)return a;const c=a.startsWith("name-")?"name":a,d=b.startsWith("name-")?"name":b,e=wh.get(c);if(void 0!==e&&e.includes(d))return b;b=wh.get(d);return void 0!==b&&b.includes(c)?a:"empty"};var yh=class extends D{constructor(a,b){super(new uf({attribute:1}),[a],{R:"unsorted",subtree:!0,W:!0,B:!1});this.l=a;this.s=xh(this.l.D(),b)}h(a,b){b=b.h;a=th(a.M);if(1!==a.node.nodeType)return w.empty();a=eb(b,a,this.s).filter(c=>"http://www.w3.org/2000/xmlns/"!==c.node.namespaceURI).map(c=>rb(c)).filter(c=>this.l.l(c));return w.create(a)}D(){return"type-1"}};var zh=class extends D{constructor(a,b){super(a.o,[a],{R:"sorted",subtree:!0,W:!0,B:!1});this.s=a;this.l=xh(b,a.D())}h(a,b){const c=b.h,d=th(a.M);a=d.node.nodeType;if(1!==a&&9!==a)return w.empty();let e=null,f=!1;return w.create({next:()=>{for(;!f;){if(!e){e=ib(c,d,this.l);if(!e){f=!0;continue}return q(rb(e))}if(e=lb(c,e,this.l))return q(rb(e));f=!0}return p}}).filter(h=>this.s.l(h))}};function Ah(a,b,c){const d=b.node.nodeType;if(1!==d&&9!==d)return{next:()=>p};let e=ib(a,b,c);return{next(){if(!e)return p;const f=e;e=lb(a,e,c);return q(f)}}};function Bh(a,b,c){const d=[kd(b)];return{next:e=>{0<d.length&&0!==(e&1)&&d.shift();if(!d.length)return p;for(e=d[0].next(0);e.done;){d.shift();if(!d.length)return p;e=d[0].next(0)}d.unshift(Ah(a,e.value,c));return q(rb(e.value))}}}
222
- var Ch=class extends D{constructor(a,b){b=b||{Qa:!1};super(a.o,[a],{B:!1,W:!1,R:"sorted",subtree:!0});this.l=a;this.s=!!b.Qa;this.A=(a=this.l.D())&&(a.startsWith("name-")||"type-1"===a)||"type-1-or-type-2"===a?"type-1":null}h(a,b){b=b.h;a=th(a.M);a=Bh(b,a,this.A);this.s||a.next(0);return w.create(a).filter(c=>this.l.l(c))}};function Dh(a,b,c){var d=a.node.nodeType;if(1!==d&&9!==d)return a;for(d=kb(b,a,c);null!==d;){if(1!==d.node.nodeType)return d;a=d;d=kb(b,a,c)}return a}
223
- function Eh(a,b,c=!1,d){if(c){let f=b,h=!1;return{next:()=>{if(h)return p;if(md(f,b))return f=Dh(b,a,d),md(f,b)?(h=!0,p):q(rb(f));const k=f.node.nodeType,l=9===k||2===k?null:mb(a,f,d);if(null!==l)return f=Dh(l,a,d),q(rb(f));f=9===k?null:x(a,f,d);return md(f,b)?(h=!0,p):q(rb(f))}}}const e=[Ah(a,b,d)];return{next:()=>{if(!e.length)return p;let f=e[0].next(0);for(;f.done;){e.shift();if(!e.length)return p;f=e[0].next(0)}e.unshift(Ah(a,f.value,d));return q(rb(f.value))}}};function Fh(a,b,c){const d=[];for(;b&&9!==b.node.nodeType;b=x(a,b,null)){const f=lb(a,b,c);f&&d.push(f)}let e=null;return{next:()=>{for(;e||d.length;){if(!e){e=Eh(a,d[0],!1,c);var f=q(rb(d[0]));const h=lb(a,d[0],c);h?d[0]=h:d.shift();return f}f=e.next(0);if(f.done)e=null;else return f}return p}}}
224
- var Gh=class extends D{constructor(a){super(a.o,[a],{R:"sorted",W:!0,subtree:!1,B:!1});this.l=a;this.s=(a=this.l.D())&&(a.startsWith("name-")||"type-1"===a)?"type-1":null}h(a,b){b=b.h;a=th(a.M);return w.create(Fh(b,a,this.s)).filter(c=>this.l.l(c))}};function Hh(a,b,c){return{next:()=>(b=b&&lb(a,b,c))?q(rb(b)):p}}var Ih=class extends D{constructor(a,b){super(a.o,[a],{R:"sorted",W:!0,subtree:!1,B:!1});this.l=a;this.s=xh(this.l.D(),b)}h(a,b){b=b.h;a=th(a.M);return w.create(Hh(b,a,this.s)).filter(c=>this.l.l(c))}};var Jh=class extends D{constructor(a,b){super(a.o,[a],{R:"reverse-sorted",W:!0,subtree:!0,B:!1});this.l=a;this.s=xh(b,this.l.D())}h(a,b){b=b.h;a=th(a.M);a=x(b,a,this.s);if(!a)return w.empty();a=rb(a);return this.l.l(a)?w.m(a):w.empty()}};function Kh(a,b,c){const d=[];for(;b&&9!==b.node.nodeType;b=x(a,b,null)){const f=mb(a,b,c);null!==f&&d.push(f)}let e=null;return{next:()=>{for(;e||d.length;){e||=Eh(a,d[0],!0,c);var f=e.next(0);if(f.done){e=null;f=mb(a,d[0],c);const h=q(rb(d[0]));null===f?d.shift():d[0]=f;return h}return f}return p}}}
225
- var Lh=class extends D{constructor(a){super(a.o,[a],{B:!1,W:!0,R:"reverse-sorted",subtree:!1});this.l=a;this.s=(a=this.l.D())&&(a.startsWith("name-")||"type-1"===a)?"type-1":null}h(a,b){b=b.h;a=th(a.M);return w.create(Kh(b,a,this.s)).filter(c=>this.l.l(c))}};function Mh(a,b,c){return{next:()=>(b=b&&mb(a,b,c))?q(rb(b)):p}}var Nh=class extends D{constructor(a,b){super(a.o,[a],{B:!1,W:!0,R:"reverse-sorted",subtree:!1});this.l=a;this.s=xh(this.l.D(),b)}h(a,b){b=b.h;a=th(a.M);return w.create(Mh(b,a,this.s)).filter(c=>this.l.l(c))}};var Oh=class extends D{constructor(a,b){super(a.o,[a],{R:"sorted",subtree:!0,W:!0,B:!1});this.l=a;this.s=xh(this.l.D(),b)}h(a){th(a.M);return this.l.l(a.M)?w.m(a.M):w.empty()}D(){return this.s}};var Ph=class extends qf{constructor(a,b,c,d){super(a.o.add(b.o).add(c.o),[a,b,c],{B:a.B&&b.B&&c.B,W:b.W===c.W&&b.W,R:b.ia===c.ia?b.ia:"unsorted",subtree:b.subtree===c.subtree&&b.subtree},d);this.l=a}A(a,b,c){let d=null;const e=c[0](a);return w.create({next:f=>{d||(d=(e.fa()?c[1](a):c[2](a)).value);return d.next(f)}})}v(a){super.v(a);if(this.l.I)throw Ne();}};function hg(a){return a.h instanceof Error?a.location:hg(a.h)}function ig(a){let b;b=a.h instanceof fg?["Inner error:",a.h.message]:a.h instanceof Error?[a.h.toString()]:ig(a.h);b.push(` at <${a.o}${a.Wa?` (${a.Wa})`:""}>:${a.location.start.line}:${a.location.start.ha} - ${a.location.end.line}:${a.location.end.ha}`);return b}var Qh=class{constructor(a,b,c,d){this.location=a;this.o=b;this.Wa=c;this.h=d}};var Rh=class extends qf{constructor(a,b,c,d){super(c.o,[c],{B:c.B,W:c.W,R:c.ia,subtree:c.subtree});this.L=b;this.P={end:{ha:a.end.ha,line:a.end.line,offset:a.end.offset},start:{ha:a.start.ha,line:a.start.line,offset:a.start.offset}};this.l=d}A(a,b,[c]){let d;try{d=c(a)}catch(e){throw new Qh(this.P,this.L,this.l,e);}return w.create({next:e=>{try{return d.value.next(e)}catch(f){throw new Qh(this.P,this.L,this.l,f);}}})}v(a){try{super.v(a)}catch(b){throw new Qh(this.P,this.L,this.l,b);}}D(){return this.Fa[0].D()}};function Sh(a,b,c,d){let e=[];const f=a.L(b,c,d,k=>{if(a.l instanceof Th){const n=Sh(a.l,b,k,d);return of(n,t=>e=t)}let l=null;return w.create({next:()=>{for(;;){if(!l){var n=k.next(0);if(n.done)return p;n=a.l.s(n.value,d);l=of(n,t=>e=lf(e,t)).value}n=l.next(0);if(n.done)l=null;else return n}}})});let h=!1;return{next:()=>{if(h)return p;const k=f.O();h=!0;return q(new Ye(k,e))}}}
226
- function Uh(a,b,c,d){return a.L(b,c,d,e=>{if(a.l instanceof Th)return Uh(a.l,b,e,d);let f=null;return w.create({next:()=>{for(;;){if(!f){var h=e.next(0);if(h.done)return p;f=C(a.l,h.value,d).value}h=f.next(0);if(h.done)f=null;else return h}}})})}
227
- var Th=class extends D{constructor(a,b,c,d){super(a,b,c,!0);this.l=d;this.I=this.l.I}h(a,b){return this.L(a,kd(a),b,c=>{if(this.l instanceof Th)return Uh(this.l,a,c,b);let d=null;return w.create({next:e=>{for(;;){if(!d){var f=c.next(0);if(f.done)return p;d=C(this.l,f.value,b).value}f=d.next(e);if(f.done)d=null;else return f}}})})}s(a,b){return Sh(this,a,kd(a),b)}v(a){super.v(a);this.I=this.l.I;for(const b of this.Fa)if(b!==this.l&&b.I)throw Ne();}};var Vh=class extends Th{constructor(a,b,c,d){super(b.o.add(d.o),[b,d],{B:!1},d);this.P=a.prefix;this.ma=a.namespaceURI;this.Pb=a.localName;this.yb=null;this.A=c;this.La=null;this.ya=b}L(a,b,c,d){let e=null,f=null,h=0;return d({next:()=>{for(;;){if(!e){var k=b.next(0);if(k.done)return p;f=k.value;h=0;e=C(this.ya,f,c).value}const l=e.next(0);if(l.done)e=null;else return h++,k={[this.yb]:()=>w.m(l.value)},this.La&&(k[this.La]=()=>w.m(new Ca(5,h))),q(hc(f,k))}}})}v(a){if(this.P&&(this.ma=a.$(this.P),
228
- !this.ma&&this.P))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.P} in a for expression`);this.ya.v(a);Cg(a);this.yb=Gg(a,this.ma,this.Pb);if(this.A){if(this.A.prefix&&(this.A.namespaceURI=a.$(this.A.prefix),!this.A.namespaceURI&&this.A.prefix))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.P} in the positionalVariableBinding in a for expression`);this.La=Gg(a,this.A.namespaceURI,this.A.localName)}this.l.v(a);Ig(a);if(this.ya.I)throw Ne();this.l.I&&(this.I=
229
- !0)}};var Wh=class extends D{constructor(a,b,c){super(new uf({external:1}),[c],{B:!1,R:"unsorted"});this.P=a.map(({name:d})=>d);this.A=a.map(({type:d})=>d);this.s=null;this.L=b;this.l=c}h(a,b){const c=new Va({j:this.A,arity:this.A.length,Ya:!0,I:this.l.I,localName:"dynamic-function",namespaceURI:"",i:this.L,value:(d,e,f,...h)=>{d=hc(bc(a,-1,null,w.empty()),this.s.reduce((k,l,n)=>{k[l]=Ra(h[n]);return k},Object.create(null)));return C(this.l,d,b)}});return w.m(c)}v(a){Cg(a);this.s=this.P.map(b=>Gg(a,b.namespaceURI,
230
- b.localName));this.l.v(a);Ig(a);if(this.l.I)throw Error("Not implemented: inline functions can not yet be updating.");}};var Xh=class extends Th{constructor(a,b,c){super(b.o.add(c.o),[b,c],{B:!1,W:c.W,R:c.ia,subtree:c.subtree},c);if(a.prefix||a.namespaceURI)throw Error("Not implemented: let expressions with namespace usage.");this.A=a.prefix;this.P=a.namespaceURI;this.La=a.localName;this.ma=b;this.ya=null}L(a,b,c,d){return d({next:()=>{var e=b.next(0);if(e.done)return p;e=e.value;e=hc(e,{[this.ya]:Ra(C(this.ma,e,c))});return q(e)}})}v(a){if(this.A&&(this.P=a.$(this.A),!this.P&&this.A))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.A} using in a for expression`);
231
- this.ma.v(a);Cg(a);this.ya=Gg(a,this.P,this.La);this.l.v(a);Ig(a);this.I=this.l.I;if(this.ma.I)throw Ne();}};var Yh=class extends D{constructor(a,b){super(new uf({}),[],{B:!0,R:"sorted"},!1,b);let c;switch(b.type){case 5:c=g(parseInt(a,10),b.type);break;case 1:c=g(a,b.type);break;case 4:case 3:c=g(parseFloat(a),b.type);break;default:throw new TypeError("Type "+b+" not expected in a literal");}this.l=()=>w.m(c)}h(){return this.l()}};var Zh=class extends D{constructor(a,b){super(new uf({external:1}),a.reduce((c,{key:d,value:e})=>c.concat(d,e),[]),{B:!1},!1,b);this.l=a}h(a,b){const c=this.l.map(d=>qc(C(d.key,a,b),b).X({default:()=>{throw Error("XPTY0004: A key of a map should be a single atomizable value.");},m:e=>e}));return A(c,d=>w.m(new ub(d.map((e,f)=>({key:e,value:Ra(C(this.l[f].value,a,b))})))))}};var $h=class extends D{constructor(a,b,c){super(new uf({external:1}),[],{B:!0},!1,c);this.s=b;this.A=a;this.l=null}h(){const a=new Va({j:this.l.j,I:this.l.I,arity:this.s,localName:this.l.localName,namespaceURI:this.l.namespaceURI,i:this.l.i,value:this.l.callFunction});return w.m(a)}v(a){let b=this.A.namespaceURI,c=this.A.localName;const d=this.A.prefix;if(null===b){const e=a.Sa({localName:c,prefix:d},this.s);if(!e)throw Error(`XPST0017: The function ${d?d+":":""}${c} with arity ${this.s} could not be resolved. ${lg(c)}`);
232
- b=e.namespaceURI;c=e.localName}this.l=a.va(b,c,this.s)||null;if(!this.l)throw a=this.A,Error(`XPST0017: Function ${`${a.namespaceURI?`Q{${a.namespaceURI}}`:a.prefix?`${a.prefix}:`:""}${a.localName}`} with arity of ${this.s} not registered. ${lg(c)}`);super.v(a)}};const ai={[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};
233
- var bi=class extends D{constructor(a,b,c){super(b.o,[b],{B:!1},!1,c);this.s=b;this.l=a}h(a,b){return qc(C(this.s,a,b),b).N(c=>{if(0===c.length)return w.empty();var d=c[0];if(this.type)return c="+"===this.l?+d.value:-d.value,0===d.type&&(c=Number.NaN),w.m(g(c,this.type.type));if(1<c.length)throw Error("XPTY0004: The operand to a unary operator must be a sequence with a length less than one");return v(d.type,19)?(d=jd(d,3).value,w.m(g("+"===this.l?d:-d,3))):v(d.type,2)?"+"===this.l?w.m(d):w.m(g(-1*
234
- d.value,ai[d.type])):w.m(g(Number.NaN,3))})}};var ci=class extends D{constructor(a,b){super(a.reduce((c,d)=>c.add(d.o),new uf({})),a,{B:a.every(c=>c.B)},!1,b);this.l=a;this.s=a.reduce((c,d)=>xh(c,d.D()),null)}h(a,b){let c=0,d=null,e=!1,f=null;if(null!==a){const h=a.M;null!==h&&v(h.type,53)&&(f=Xa(h.value))}return w.create({next:()=>{if(!e){for(;c<this.l.length;){if(!d){const h=this.l[c];if(null!==f&&null!==h.D()&&!f.includes(h.D()))return c++,e=!0,q(wa);d=C(h,a,b)}if(!1===d.fa())return e=!0,q(wa);d=null;c++}e=!0;return q(va)}return p}})}D(){return this.s}};var di=class extends D{constructor(a,b){super(a.reduce((d,e)=>0<tf(d,e.o)?d:e.o,new uf({})),a,{B:a.every(d=>d.B)},!1,b);let c;for(b=0;b<a.length;++b){void 0===c&&(c=a[b].D());if(null===c)break;if(c!==a[b].D()){c=null;break}}this.s=c;this.l=a}h(a,b){let c=0,d=null,e=!1,f=null;if(null!==a){const h=a.M;null!==h&&v(h.type,53)&&(f=Xa(h.value))}return w.create({next:()=>{if(!e){for(;c<this.l.length;){if(!d){const h=this.l[c];if(null!==f&&null!==h.D()&&!f.includes(h.D())){c++;continue}d=C(h,a,b)}if(!0===
235
- d.fa())return e=!0,q(va);d=null;c++}e=!0;return q(wa)}return p}})}D(){return this.s}};function ei(a,b){let c;return w.create({next:d=>{for(;;){if(!c){var e=a.value.next(d);if(e.done)return p;c=pc(e.value,b)}e=c.value.next(d);if(e.done)c=null;else return e}}})};function fi(a,b){if("eqOp"===a)return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value.namespaceURI===f.value.namespaceURI&&e.value.localName===f.value.localName};if("neOp"===a)return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value.namespaceURI!==f.value.namespaceURI||e.value.localName!==f.value.localName};throw Error('XPTY0004: Only the "eq" and "ne" comparison is defined for xs:QName');}
236
- function gi(a,b){switch(a){case "eqOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value===f.value};case "neOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value!==f.value};case "ltOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value<f.value};case "leOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value<=f.value};case "gtOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value>f.value};case "geOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value>=f.value}}}
237
- function hi(a,b){switch(a){case "ltOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value.ea<f.value.ea};case "leOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return vb(e.value,f.value)||e.value.ea<f.value.ea};case "gtOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value.ea>f.value.ea};case "geOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return vb(e.value,f.value)||e.value.ea>f.value.ea}}}
238
- function ii(a,b){switch(a){case "eqOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return vb(e.value,f.value)};case "ltOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value.ca<f.value.ca};case "leOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return vb(e.value,f.value)||e.value.ca<f.value.ca};case "gtOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return e.value.ca>f.value.ca};case "geOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return vb(e.value,f.value)||e.value.ca>f.value.ca}}}
239
- function ji(a,b){switch(a){case "eqOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return vb(e.value,f.value)};case "neOp":return(c,d)=>{const {U:e,V:f}=b(c,d);return!vb(e.value,f.value)}}}
240
- function ki(a,b){switch(a){case "eqOp":return(c,d,e)=>{const {U:f,V:h}=b(c,d);return Ob(f.value,h.value,fc(e))};case "neOp":return(c,d,e)=>{const {U:f,V:h}=b(c,d);return!Ob(f.value,h.value,fc(e))};case "ltOp":return(c,d,e)=>{const {U:f,V:h}=b(c,d);c=fc(e);return 0>Nb(f.value,h.value,c)};case "leOp":return(c,d,e)=>{const {U:f,V:h}=b(c,d);(c=Ob(f.value,h.value,fc(e)))||(e=fc(e),c=0>Nb(f.value,h.value,e));return c};case "gtOp":return(c,d,e)=>{const {U:f,V:h}=b(c,d);c=fc(e);return 0<Nb(f.value,h.value,
241
- c)};case "geOp":return(c,d,e)=>{const {U:f,V:h}=b(c,d);(c=Ob(f.value,h.value,fc(e)))||(e=fc(e),c=0<Nb(f.value,h.value,e));return c}}}function li(a,b){switch(a){case "eqOp":return(c,d,e)=>{const {U:f,V:h}=b(c,d);return Ob(f.value,h.value,fc(e))};case "neOp":return(c,d,e)=>{const {U:f,V:h}=b(c,d);return!Ob(f.value,h.value,fc(e))}}}
242
- function mi(a,b,c){function d(n,t){return{U:h?h(n):n,V:k?k(t):t}}function e(n){return v(b,n)&&v(c,n)}function f(n){return 0<n.filter(t=>v(b,t)).length&&0<n.filter(t=>v(c,t)).length}let h=null,k=null;v(b,19)&&v(c,19)?b=c=1:v(b,19)?(h=n=>jd(n,c),b=c):v(c,19)&&(k=n=>jd(n,b),c=b);if(v(b,23)&&v(c,23))return fi(a,d);if(e(0)||f([1,47,61])||f([2,47,61])||e(20)||e(22)||e(21)||f([1,20])){var l=gi(a,d);if(void 0!==l)return l}if(e(16)&&(l=hi(a,d),void 0!==l)||e(17)&&(l=ii(a,d),void 0!==l)||e(18)&&(l=ji(a,d),
243
- void 0!==l))return l;if(e(9)||e(7)||e(8))if(l=ki(a,d),void 0!==l)return l;if(e(11)||e(12)||e(13)||e(14)||e(15))if(l=li(a,d),void 0!==l)return l;throw Error(`XPTY0004: ${a} not available for ${Da[b]} and ${Da[c]}`);}const ni=Object.create(null);function oi(a,b,c){const d=`${b}~${c}~${a}`;let e=ni[d];e||=ni[d]=mi(a,b,c);return e}
244
- var pi=class extends D{constructor(a,b,c){super(b.o.add(c.o),[b,c],{B:!1});this.l=b;this.A=c;this.s=a}h(a,b){const c=C(this.l,a,b),d=C(this.A,a,b),e=ei(c,b),f=ei(d,b);return e.X({empty:()=>w.empty(),m:()=>f.X({empty:()=>w.empty(),m:()=>{const h=e.first(),k=f.first();return oi(this.s,h.type,k.type)(h,k,a)?w.aa():w.T()},multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton.");}}),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton.");}})}};const qi={equalOp:"eqOp",notEqualOp:"neOp",lessThanOrEqualOp:"leOp",lessThanOp:"ltOp",greaterThanOrEqualOp:"geOp",greaterThanOp:"gtOp"};
245
- function ri(a,b,c,d){a=qi[a];return c.N(e=>b.filter(f=>{for(let l=0,n=e.length;l<n;++l){let t=e[l],u=void 0,z=void 0;var h=f.type,k=t.type;if(v(h,19)||v(k,19))v(h,2)?u=3:v(k,2)?z=3:v(h,17)?u=17:v(k,17)?z=17:v(h,16)?u=16:v(k,16)?z=16:v(h,19)?z=k:v(k,19)&&(u=h);const [y,G]=[z,u];h=y;k=G;h?f=jd(f,h):k&&(t=jd(t,k));if(oi(a,f.type,t.type)(f,t,d))return!0}return!1}).X({default:()=>w.aa(),empty:()=>w.T()}))}
246
- var si=class extends D{constructor(a,b,c){super(b.o.add(c.o),[b,c],{B:!1});this.l=b;this.A=c;this.s=a}h(a,b){const c=C(this.l,a,b),d=C(this.A,a,b);return c.X({empty:()=>w.T(),default:()=>d.X({empty:()=>w.T(),default:()=>{const e=ei(c,b),f=ei(d,b);return ri(this.s,e,f,a)}})})}};function ti(a,b,c,d){if(!v(c,53)||!v(d,53))throw Error("XPTY0004: Sequences to compare are not nodes");switch(a){case "isOp":return ui(c,d);case "nodeBeforeOp":return b?(e,f)=>0>sd(b,e.first(),f.first()):void 0;case "nodeAfterOp":return b?(e,f)=>0<sd(b,e.first(),f.first()):void 0;default:throw Error("Unexpected operator");}}function ui(a,b){return a!==b||47!==a&&53!==a&&54!==a&&55!==a&&56!==a&&57!==a&&58!==a?()=>!1:(c,d)=>md(c.first().value,d.first().value)}
247
- var vi=class extends D{constructor(a,b,c){super(b.o.add(c.o),[b,c],{B:!1});this.l=b;this.A=c;this.s=a}h(a,b){const c=C(this.l,a,b),d=C(this.A,a,b);return c.X({empty:()=>w.empty(),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton");},m:()=>d.X({empty:()=>w.empty(),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton");},m:()=>{const e=c.first(),f=d.first();return ti(this.s,b.h,e.type,f.type)(c,d,a)?w.aa():w.T()}})})}};function wi(a,b,c,d){return c.N(e=>{if(e.some(f=>!v(f.type,53)))throw Error(`XPTY0004: Sequences given to ${a} should only contain nodes.`);return"sorted"===d?w.create(e):"reverse-sorted"===d?w.create(e.reverse()):w.create(td(b,e))})}
248
- var xi=class extends D{constructor(a,b,c,d){super(0<tf(b.o,c.o)?b.o:c.o,[b,c],{B:b.B&&c.B},!1,d);this.l=a;this.s=b;this.A=c}h(a,b){const c=wi(this.l,b.h,C(this.s,a,b),this.s.ia);a=wi(this.l,b.h,C(this.A,a,b),this.A.ia);const d=c.value,e=a.value;let f=null,h=null,k=!1,l=!1;return w.create({next:()=>{if(k)return p;for(;!l;){if(!f){var n=d.next(0);if(n.done)return k=!0,p;f=n.value}if(!h){n=e.next(0);if(n.done){l=!0;break}h=n.value}if(md(f.value,h.value)){if(n=q(f),h=f=null,"intersectOp"===this.l)return n}else if(0>
249
- sd(b.h,f,h)){if(n=q(f),f=null,"exceptOp"===this.l)return n}else h=null}if("exceptOp"===this.l)return null!==f?(n=q(f),f=null,n):d.next(0);k=!0;return p}})}};var yi=class extends qf{constructor(a,b){super(a.reduce((c,d)=>c.add(d.o),new uf({})),a,{R:"unsorted",B:a.every(c=>c.B)},b)}A(a,b,c){return c.length?jc(c.map(d=>d(a))):w.empty()}};var zi=class extends D{constructor(a,b,c){super((new uf({})).add(a.o),[a,b],{B:a.B&&b.B},!1,c);this.l=a;this.s=b}h(a,b){const c=C(this.l,a,b),d=dc(a,c);let e=null,f=null,h=!1;return w.create({next:k=>{for(;!h;){if(!e&&(e=d.next(k),e.done))return h=!0,p;f||=C(this.s,e.value,b);const l=f.value.next(k);if(l.done)e=f=null;else return l}}})}};var Ai=class extends D{constructor(a,b,c){super(a.o,[a],{B:!1});this.l=Ia(b.prefix?`${b.prefix}:${b.localName}`:b.localName);if(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(b.namespaceURI)throw Error("Not implemented: castable as expressions with a namespace URI.");this.A=a;this.s=c}h(a,b){const c=qc(C(this.A,a,b),b);return c.X({empty:()=>this.s?w.aa():w.T(),m:()=>c.map(d=>id(d,this.l).u?va:wa),multiple:()=>
250
- w.T()})}};var Bi=class extends D{constructor(a,b,c){super(a.o,[a],{B:!1});this.l=Ia(b.prefix?`${b.prefix}:${b.localName}`:b.localName);if(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(b.namespaceURI)throw Error("Not implemented: casting expressions with a namespace URI.");this.A=a;this.s=c}h(a,b){const c=qc(C(this.A,a,b),b);return c.X({empty:()=>{if(!this.s)throw Error("XPTY0004: Sequence to cast is empty while target type is singleton.");
251
- return w.empty()},m:()=>c.map(d=>jd(d,this.l)),multiple:()=>{throw Error("XPTY0004: Sequence to cast is not singleton or empty.");}})}};function Ci(a,b){const c=a.value;let d=null,e=!1;return w.create({next:()=>{for(;!e;){if(!d){var f=c.next(0);if(f.done)return e=!0,q(va);d=b(f.value)}f=d.fa();d=null;if(!1===f)return e=!0,q(wa)}return p}})};var Di=class extends D{constructor(a,b,c,d){super(a.o,[a],{B:!1},!1,d);this.A=a;this.s=b;this.l=c}h(a,b){const c=C(this.A,a,b);return c.X({empty:()=>"?"===this.l||"*"===this.l?w.aa():w.T(),multiple:()=>"+"===this.l||"*"===this.l?Ci(c,d=>{const e=w.m(d);d=bc(a,0,d,e);return C(this.s,d,b)}):w.T(),m:()=>Ci(c,d=>{const e=w.m(d);d=bc(a,0,d,e);return C(this.s,d,b)})})}};function Ei(a,b){return null!==a&&null!==b&&v(a.type,53)&&v(b.type,53)?md(a.value,b.value):!1}function Fi(a){let b=a.next(0);if(b.done)return w.empty();let c=null,d=null;return w.create({next(e){if(b.done)return p;c||(c=b.value.value);let f;do if(f=c.next(e),f.done){b=a.next(0);if(b.done)return f;c=b.value.value}while(f.done||Ei(f.value,d));d=f.value;return f}})}
252
- function Gi(a,b){const c=[];(function(){for(var f=b.next(0);!f.done;){const h=f.value.value;f={current:h.next(0),next:k=>h.next(k)};f.current.done||c.push(f);f=b.next(0)}})();let d=null,e=!1;return w.create({[Symbol.iterator](){return this},next:()=>{e||(e=!0,c.every(h=>v(h.current.value.type,53))&&c.sort((h,k)=>sd(a,h.current.value,k.current.value)));let f;do{if(!c.length)return p;const h=c.shift();f=h.current;h.current=h.next(0);if(!v(f.value.type,53))return f;if(!h.current.done){let k=0,l=c.length-
253
- 1,n=0;for(;k<=l;){n=Math.floor((k+l)/2);const t=sd(a,h.current.value,c[n].current.value);if(0===t){k=n;break}0<t?k=n+1:l=n-1}c.splice(k,0,h)}}while(Ei(f.value,d));d=f.value;return f}})};var Hi=class extends D{constructor(a,b){super(a.reduce((c,d)=>0<tf(c,d.o)?c:d.o,new uf({})),a,{B:a.every(c=>c.B)},!1,b);this.l=a}h(a,b){if(this.l.every(c=>"sorted"===c.ia)){let c=0;return Gi(b.h,{next:()=>c>=this.l.length?p:q(C(this.l[c++],a,b))}).map(d=>{if(!v(d.type,53))throw Error("XPTY0004: The sequences to union are not of type node()*");return d})}return jc(this.l.map(c=>C(c,a,b))).N(c=>{if(c.some(d=>!v(d.type,53)))throw Error("XPTY0004: The sequences to union are not of type node()*");c=td(b.h,
254
- c);return w.create(c)})}};function Ii(a){return a.every(b=>null===b||v(b.type,5)||v(b.type,4))||null!==a.map(b=>b?rc(b.type):null).reduce((b,c)=>null===c?b:c===b?b:null)?a:a.every(b=>null===b||v(b.type,1)||v(b.type,20))?a.map(b=>b?jd(b,1):null):a.every(b=>null===b||v(b.type,4)||v(b.type,6))?a.map(b=>b?jd(b,6):b):a.every(b=>null===b||v(b.type,4)||v(b.type,6)||v(b.type,3))?a.map(b=>b?jd(b,3):b):null};function Ji(a){return(a=a.find(b=>!!b))?rc(a.type):null}
255
- var Ki=class extends Th{constructor(a,b){super(new uf({}),[b,...a.map(c=>c.ba)],{B:!1,W:!1,R:"unsorted",subtree:!1},b);this.A=a}L(a,b,c,d){if(this.A[1])throw Error("More than one order spec is not supported for the order by clause.");const e=[];let f=!1,h,k,l=null;const n=this.A[0];return w.create({next:()=>{if(!f){for(var t=b.next(0);!t.done;)e.push(t.value),t=b.next(0);t=e.map(z=>n.ba.h(z,c)).map(z=>qc(z,c));if(t.find(z=>!z.F()&&!z.oa()))throw Error("XPTY0004: Order by only accepts empty or singleton sequences");h=
256
- t.map(z=>z.first());h=h.map(z=>null===z?z:v(19,z.type)?jd(z,1):z);if(Ji(h)&&(h=Ii(h),!h))throw Error("XPTY0004: Could not cast values");t=h.length;k=h.map((z,y)=>y);for(let z=0;z<t;z++)if(z+1!==t)for(let y=z;0<=y;y--){const G=y,N=y+1;if(N===t)continue;const U=h[k[G]],ca=h[k[N]];if(null!==ca||null!==U){if(n.cc){if(null===U)continue;if(null===ca&&null!==U){[k[G],k[N]]=[k[N],k[G]];continue}if(isNaN(ca.value)&&null!==U&&!isNaN(U.value)){[k[G],k[N]]=[k[N],k[G]];continue}}else{if(null===ca)continue;if(null===
257
- U&&null!==ca){[k[G],k[N]]=[k[N],k[G]];continue}if(isNaN(U.value)&&null!==ca&&!isNaN(ca.value)){[k[G],k[N]]=[k[N],k[G]];continue}}oi("gtOp",U.type,ca.type)(U,ca,a)&&([k[G],k[N]]=[k[N],k[G]])}}let u=n.Bb?0:h.length-1;l=d({next:()=>n.Bb?u>=h.length?p:q(e[k[u++]]):0>u?p:q(e[k[u--]])}).value;f=!0}return l.next(0)}})}};var Li=class extends D{constructor(a){super(a?a.o:new uf({}),a?[a]:[],{R:"sorted",subtree:!1,W:!1,B:!1});this.l=a}h(a,b){if(null===a.M)throw lc("context is absent, it needs to be present to use paths.");var c=b.h;let d=a.M.value;for(;9!==d.node.nodeType;)if(d=x(c,d),null===d)throw Error("XPDY0050: the root node of the context node is not a document node.");c=w.m(rb(d));return this.l?C(this.l,bc(a,0,c.first(),c),b):c}};var Mi=class extends D{constructor(a){super(new uf({}),[],{R:"sorted"},!1,a)}h(a){if(null===a.M)throw lc('context is absent, it needs to be present to use the "." operator');return w.m(a.M)}};function Ni(a,b){let c=!1,d=!1;b.forEach(e=>{v(e.type,53)?c=!0:d=!0});if(d&&c)throw Error("XPTY0018: The path operator should either return nodes or non-nodes. Mixed sequences are not allowed.");return c?td(a,b):b}
258
- var Oi=class extends D{constructor(a,b){const c=a.every(e=>e.W),d=a.every(e=>e.subtree);super(a.reduce((e,f)=>e.add(f.o),new uf({})),a,{B:!1,W:c,R:b?"sorted":"unsorted",subtree:d});this.l=a;this.s=b}h(a,b){let c=!0;return this.l.reduce((d,e,f)=>{const h=null===d?kd(a):dc(a,d);d={next:l=>{l=h.next(l);if(l.done)return p;if(null!==l.value.M&&!v(l.value.M.type,53)&&0<f)throw Error("XPTY0019: The result of E1 in a path expression E1/E2 should not evaluate to a sequence of nodes.");return q(C(e,l.value,
259
- b))}};let k;if(this.s)switch(e.ia){case "reverse-sorted":const l=d;d={next:n=>{n=l.next(n);return n.done?n:q(n.value.N(t=>w.create(t.reverse())))}};case "sorted":if(e.subtree&&c){k=Fi(d);break}k=Gi(b.h,d);break;case "unsorted":return Fi(d).N(n=>w.create(Ni(b.h,n)))}else k=Fi(d);c=c&&e.W;return k},null)}D(){return this.l[0].D()}};var Pi=class extends D{constructor(a,b){super(a.o.add(b.o),[a,b],{B:a.B&&b.B,W:a.W,R:a.ia,subtree:a.subtree});this.s=a;this.l=b}h(a,b){const c=C(this.s,a,b);if(this.l.B){const k=C(this.l,a,b);if(k.F())return k;const l=k.first();if(v(l.type,2)){let n=l.value;if(!Number.isInteger(n))return w.empty();const t=c.value;let u=!1;return w.create({next:()=>{if(!u){for(let z=t.next(0);!z.done;z=t.next(0))if(1===n--)return u=!0,z;u=!0}return p}})}return k.fa()?c:w.empty()}const d=c.value;let e=null,f=0,h=null;
260
- return w.create({next:k=>{let l=!1;for(;!e||!e.done;){e||(e=d.next(l?0:k),l=!0);if(e.done)break;h||=C(this.l,bc(a,f,e.value,c),b);var n=h.first();n=null===n?!1:v(n.type,2)?n.value===f+1:h.fa();h=null;const t=e.value;e=null;f++;if(n)return q(t)}return e}})}D(){return this.s.D()}};function Qi(a,b,c){c=[c];if(v(a.type,62))if("*"===b)c.push(...a.h.map(d=>d()));else if(v(b.type,5)){const d=b.value;if(a.h.length<d||0>=d)throw Error("FOAY0001: Array index out of bounds");c.push(a.h[d-1]())}else throw Error("XPTY0004: The key specifier is not an integer.");else if(v(a.type,61))"*"===b?c.push(...a.h.map(d=>d.value())):(a=a.h.find(d=>sb(d.key,b)))&&c.push(a.value());else throw Error("XPTY0004: The provided context item is not a map or an array.");return jc(c)}
261
- function Ri(a,b,c,d,e){if("*"===b)return Qi(a,b,c);b=C(b,d,e);b=Ra(b)().N(f=>f.reduce((h,k)=>Qi(a,k,h),new Ba));return jc([c,b])};var Si=class extends D{constructor(a,b){super(a.o,[a].concat("*"===b?[]:[b]),{B:a.B,R:a.ia,subtree:a.subtree});this.l=a;this.s=b}h(a,b){return C(this.l,a,b).N(c=>c.reduce((d,e)=>Ri(e,this.s,d,a,b),new Ba))}D(){return this.l.D()}};var Ti=class extends D{constructor(a,b){super(new uf({external:1}),"*"===a?[]:[a],{B:!1},!1,b);this.l=a}h(a,b){return Ri(a.M,this.l,new Ba,a,b)}};var Ui=class extends D{constructor(a,b,c,d){const e=b.map(f=>f.fb);b=b.map(f=>f.name);super(e.reduce((f,h)=>f.add(h.o),c.o),e.concat(c),{B:!1},!1,d);this.s=a;this.A=b;this.L=e;this.P=c;this.l=null}h(a,b){let c=a;const d=this.l.map((k,l)=>{const n=C(this.L[l],c,b).O();c=hc(a,{[k]:()=>w.create(n)});return n});if(d.some(k=>0===k.length))return"every"===this.s?w.aa():w.T();const e=Array(d.length).fill(0);e[0]=-1;for(var f=!0;f;){f=!1;for(let k=0,l=e.length;k<l;++k){var h=d[k];if(++e[k]>h.length-1)e[k]=
262
- 0;else{f=Object.create(null);for(h=0;h<e.length;h++){const n=d[h][e[h]];f[this.l[h]]=()=>w.m(n)}f=hc(a,f);f=C(this.P,f,b);if(f.fa()&&"some"===this.s)return w.aa();if(!f.fa()&&"every"===this.s)return w.T();f=!0;break}}}return"every"===this.s?w.aa():w.T()}v(a){this.l=[];for(let c=0,d=this.A.length;c<d;++c){this.L[c].v(a);Cg(a);var b=this.A[c];const e=b.prefix?a.$(b.prefix):null;b=Gg(a,e,b.localName);this.l[c]=b}this.P.v(a);for(let c=0,d=this.A.length;c<d;++c)Ig(a)}};var Vi=class extends D{constructor(a){super(a,[],{B:!1})}h(a){return this.l(a.M)?w.aa():w.T()}};var Wi=class extends Vi{constructor(a){super(new uf({nodeType:1}));this.s=a}l(a){if(!v(a.type,53))return!1;a=a.value.node.nodeType;return 3===this.s&&4===a?!0:this.s===a}D(){return`type-${this.s}`}};var Xi=class extends Vi{constructor(a,b={kind:null}){const c=a.prefix,d=a.namespaceURI;a=a.localName;const e={};"*"!==a&&(e.nodeName=1);e.nodeType=1;super(new uf(e));this.s=a;this.L=d;this.A=c;this.P=b.kind}l(a){const b=v(a.type,54),c=v(a.type,47);if(!b&&!c)return!1;a=a.value;return null!==this.P&&(1===this.P&&!b||2===this.P&&!c)?!1:null===this.A&&""!==this.L&&"*"===this.s?!0:"*"===this.A?"*"===this.s?!0:this.s===a.node.localName:"*"!==this.s&&this.s!==a.node.localName?!1:(a.node.namespaceURI||null)===
263
- ((""===this.A?b?this.L:null:this.L)||null)}D(){return"*"===this.s?null===this.P?"type-1-or-type-2":`type-${this.P}`:`name-${this.s}`}v(a){if(null===this.L&&"*"!==this.A&&(this.L=a.$(this.A||"")||null,!this.L&&this.A))throw Error(`XPST0081: The prefix ${this.A} could not be resolved.`);}};var Yi=class extends Vi{constructor(a){super(new uf({nodeName:1}));this.s=a}l(a){return v(a.type,57)&&a.value.node.target===this.s}D(){return"type-7"}};var Zi=class extends Vi{constructor(a){super(new uf({}));this.s=a}l(a){return v(a.type,Ia(this.s.prefix?this.s.prefix+":"+this.s.localName:this.s.localName))}};var $i=class extends D{constructor(a,b,c){super(new uf({}),[],{B:!1,R:"unsorted"});this.A=c;this.s=b;this.L=a;this.l=null}h(a,b){if(!a.ra[this.l]){if(this.P)return this.P(a,b);throw Error("XQDY0054: The variable "+this.A+" is declared but not in scope.");}return a.ra[this.l]()}v(a){null===this.s&&this.L&&(this.s=a.$(this.L));this.l=a.eb(this.s||"",this.A);if(!this.l)throw Error("XPST0008, The variable "+this.A+" is not in scope.");if(a=a.Ea[this.l])this.P=a}};var aj=class extends Th{constructor(a,b){super(new uf({}),[a,b],{B:!1,W:!1,R:"unsorted",subtree:!1},b);this.A=a}L(a,b,c,d){let e=null,f=null;return d({next:()=>{for(;;){if(!f){var h=b.next(0);if(h.done)return p;e=h.value;f=C(this.A,e,c)}h=f.fa();const k=e;f=e=null;if(h)return q(k)}}})}};var bj=class{constructor(a){this.type=a}};var cj=class extends bj{constructor(a){super("delete");this.target=a}h(a){return{type:this.type,target:$f(this.target,a,!1)}}};var dj=class extends bj{constructor(a,b,c){super(c);this.target=a;this.content=b}h(a){return{type:this.type,target:$f(this.target,a,!1),content:this.content.map(b=>$f(b,a,!0))}}};var ej=class extends dj{constructor(a,b){super(a,b,"insertAfter")}};var fj=class extends bj{constructor(a,b){super("insertAttributes");this.target=a;this.content=b}h(a){return{type:this.type,target:$f(this.target,a,!1),content:this.content.map(b=>$f(b,a,!0))}}};var gj=class extends dj{constructor(a,b){super(a,b,"insertBefore")}};var hj=class extends dj{constructor(a,b){super(a,b,"insertIntoAsFirst")}};var ij=class extends dj{constructor(a,b){super(a,b,"insertIntoAsLast")}};var jj=class extends dj{constructor(a,b){super(a,b,"insertInto")}};var kj=class extends bj{constructor(a,b){super("rename");this.target=a;this.o=b.za?b:new Sa(b.prefix,b.namespaceURI,b.localName)}h(a){return{type:this.type,target:$f(this.target,a,!1),newName:{prefix:this.o.prefix,namespaceURI:this.o.namespaceURI,localName:this.o.localName}}}};var lj=class extends bj{constructor(a,b){super("replaceElementContent");this.target=a;this.text=b}h(a){return{type:this.type,target:$f(this.target,a,!1),text:this.text?$f(this.text,a,!0):null}}};var mj=class extends bj{constructor(a,b){super("replaceNode");this.target=a;this.o=b}h(a){return{type:this.type,target:$f(this.target,a,!1),replacement:this.o.map(b=>$f(b,a,!0))}}};var nj=class extends bj{constructor(a,b){super("replaceValue");this.target=a;this.o=b}h(a){return{type:this.type,target:$f(this.target,a,!1),["string-value"]:this.o}}};var oj=(a,b)=>new mj(a,b);var pj=class extends nf{constructor(a){super(new uf({}),[a],{B:!1,R:"unsorted"});this.l=a}s(a,b){const c=mf(this.l)(a,b),d=b.h;let e,f;return{next:()=>{if(!e){const h=c.next(0);if(h.value.J.some(k=>!v(k.type,53)))throw Error("XUTY0007: The target of a delete expression must be a sequence of zero or more nodes.");e=h.value.J;f=h.value.da}e=e.filter(h=>x(d,h.value));return q({da:lf(e.map(h=>new cj(h.value)),f),J:[]})}}}};function qj(a,b,c,d,e,f){const h=b.h;a.reduce(function t(l,n){if(v(n.type,62))return n.h.forEach(u=>u().O().forEach(z=>t(l,z))),l;l.push(n);return l},[]).forEach((l,n,t)=>{if(v(l.type,47)){if(e)throw f(l.value,h);c.push(l.value.node)}else if(v(l.type,46)||v(l.type,53)&&3===l.value.node.nodeType){const u=v(l.type,46)?jd(pc(l,b).first(),1).value:hb(h,l.value);0!==n&&v(t[n-1].type,46)&&v(l.type,46)?(d.push({data:" "+u,Ra:!0,nodeType:3}),e=!0):u&&(d.push({data:""+u,Ra:!0,nodeType:3}),e=!0)}else if(v(l.type,
264
- 55)){const u=[];gb(h,l.value).forEach(z=>u.push(rb(z)));e=qj(u,b,c,d,e,f)}else if(v(l.type,53))d.push(l.value.node),e=!0;else{if(v(l.type,60))throw nc(l.type);throw Error(`Atomizing ${l.type} is not implemented.`);}});return e}function rj(a,b,c){const d=[],e=[];let f=!1;a.forEach(h=>{f=qj(h,b,d,e,f,c)});return{attributes:d,Xa:e}};function sj(a,b,c,d,e){const f=[];switch(a){case 4:d.length&&f.push(new fj(b,d));e.length&&f.push(new hj(b,e));break;case 5:d.length&&f.push(new fj(b,d));e.length&&f.push(new ij(b,e));break;case 3:d.length&&f.push(new fj(b,d));e.length&&f.push(new jj(b,e));break;case 2:d.length&&f.push(new fj(c,d));e.length&&f.push(new gj(b,e));break;case 1:d.length&&f.push(new fj(c,d)),e.length&&f.push(new ej(b,e))}return f}
265
- var tj=class extends nf{constructor(a,b,c){super(new uf({}),[a,c],{B:!1,R:"unsorted"});this.L=a;this.l=b;this.A=c}s(a,b){const c=mf(this.L)(a,b),d=mf(this.A)(a,b),e=b.h;let f,h,k,l,n,t;return{next:()=>{if(!f){var u=c.next(0);const z=rj([u.value.J],b,Oe);f=z.attributes.map(y=>({node:y,G:null}));h=z.Xa.map(y=>({node:y,G:null}));k=u.value.da}if(!l){u=d.next(0);if(0===u.value.J.length)throw Xe();if(3<=this.l){if(1!==u.value.J.length)throw Pe();if(!v(u.value.J[0].type,54)&&!v(u.value.J[0].type,55))throw Pe();
266
- }else{if(1!==u.value.J.length)throw Qe();if(!(v(u.value.J[0].type,54)||v(u.value.J[0].type,56)||v(u.value.J[0].type,58)||v(u.value.J[0].type,57)))throw Qe();t=x(e,u.value.J[0].value,null);if(null===t)throw Error(`XUDY0029: The target ${u.value.J[0].value.outerHTML} for inserting a node before or after must have a parent.`);}l=u.value.J[0];n=u.value.da}if(f.length){if(3<=this.l){if(!v(l.type,54))throw Error("XUTY0022: An insert expression specifies the insertion of an attribute node into a document node.");
267
- }else if(1!==t.node.nodeType)throw Error("XUDY0030: An insert expression specifies the insertion of an attribute node before or after a child of a document node.");f.reduce((z,y)=>{const G=y.node.prefix||"";var N=y.node.prefix||"";const U=y.node.namespaceURI,ca=N?l.value.node.lookupNamespaceURI(N):null;if(ca&&ca!==U)throw Ve(U);if((N=z[N])&&U!==N)throw We(U);z[G]=y.node.namespaceURI;return z},{})}return q({J:[],da:lf(sj(this.l,l.value,t?t:null,f,h),k,n)})}}}};const uj=()=>mc("Casting not supported from given type to a single xs:string or xs:untypedAtomic or any of its derived types."),vj=/([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])/,wj=new RegExp(`${vj.source}${(new RegExp(`(${vj.source}|[-.0-9\xB7\u0300-\u036F\u203F\u2040])`)).source}*`,"g"),xj=a=>(a=a.match(wj))?1===a.length:!1;
268
- function yj(a,b){return qc(b,a).X({m:c=>{c=c.first();if(v(c.type,1)||v(c.type,19)){if(!xj(c.value))throw Error(`XQDY0041: The value "${c.value}" of a name expressions cannot be converted to a NCName.`);return w.m(c)}throw uj();},default:()=>{throw uj();}}).value}
269
- function zj(a,b,c){return qc(c,b).X({m:d=>{d=d.first();if(v(d.type,23))return w.m(d);if(v(d.type,1)||v(d.type,19)){let e,f;d=d.value.split(":");1===d.length?d=d[0]:(e=d[0],f=a.$(e),d=d[1]);if(!xj(d)||e&&!xj(e))throw xg(e?`${e}:${d}`:d);if(e&&!f)throw xg(`${e}:${d}`);return w.m({type:23,value:new Sa(e,f,d)})}throw uj();},default:()=>{throw uj();}}).value};var Aj=class extends nf{constructor(a,b){super(new uf({}),[a,b],{B:!1,R:"unsorted"});this.A=a;this.L=b;this.l=void 0}s(a,b){const c=mf(this.A)(a,b),d=mf(this.L)(a,b);return{next:()=>{const e=c.next(0);var f=e.value.J;if(0===f.length)throw Xe();if(1!==f.length)throw Se();if(!v(f[0].type,54)&&!v(f[0].type,47)&&!v(f[0].type,57))throw Se();f=f[0];const h=d.next(0);a:{var k=this.l;var l=w.create(h.value.J);switch(f.type){case 54:k=zj(k,b,l).next(0).value.value;if((l=f.value.node.lookupNamespaceURI(k.prefix))&&
270
- l!==k.namespaceURI)throw Ve(k.namespaceURI);break a;case 47:k=zj(k,b,l).next(0).value.value;if(k.namespaceURI&&(l=f.value.node.lookupNamespaceURI(k.prefix))&&l!==k.namespaceURI)throw Ve(k.namespaceURI);break a;case 57:k=yj(b,l).next(0).value.value;k=new Sa("",null,k);break a}k=void 0}return q({J:[],da:lf([new kj(f.value,k)],e.value.da,h.value.da)})}}}v(a){this.l=Ef(a);super.v(a)}};function Bj(a,b,c){let d,e,f;return{next:()=>{if(!d){var h=c.next(0),k=rj([h.value.J],a,We);d={attributes:k.attributes.map(l=>({node:l,G:null})),Xa:k.Xa.map(l=>({node:l,G:null}))};e=h.value.da}k=b.next(0);if(0===k.value.J.length)throw Xe();if(1!==k.value.J.length)throw Re();if(!(v(k.value.J[0].type,54)||v(k.value.J[0].type,47)||v(k.value.J[0].type,56)||v(k.value.J[0].type,58)||v(k.value.J[0].type,57)))throw Re();f=x(a.h,k.value.J[0].value,null);if(null===f)throw Error(`XUDY0009: The target ${k.value.J[0].value.outerHTML} for replacing a node must have a parent.`);
271
- h=k.value.J[0];k=k.value.da;if(v(h.type,47)){if(d.Xa.length)throw Error("XUTY0011: When replacing an attribute the new value must be zero or more attribute nodes.");d.attributes.reduce((l,n)=>{const t=n.node.prefix||"";n=n.node.namespaceURI;var u=f.node.lookupNamespaceURI(t);if(u&&u!==n)throw Ve(n);if((u=l[t])&&n!==u)throw We(n);l[t]=n;return l},{})}else if(d.attributes.length)throw Error("XUTY0010: When replacing an an element, text, comment, or processing instruction node the new value must be a single node.");
272
- return q({J:[],da:lf([oj(h.value,[].concat(d.attributes,d.Xa))],e,k)})}}}
273
- function Cj(a,b,c){let d,e,f,h,k=!1;return{next:()=>{if(k)return p;if(!f){var l=c.next(0);const n=qc(w.create(l.value.J),a).map(t=>jd(t,1)).O().map(t=>t.value).join(" ");f=0===n.length?null:{node:a.Ja.createTextNode(n),G:null};h=l.value.da}if(!d){l=b.next(0);if(0===l.value.J.length)throw Xe();if(1!==l.value.J.length)throw Re();if(!(v(l.value.J[0].type,54)||v(l.value.J[0].type,47)||v(l.value.J[0].type,56)||v(l.value.J[0].type,58)||v(l.value.J[0].type,57)))throw Re();d=l.value.J[0];e=l.value.da}if(v(d.type,
274
- 54))return k=!0,q({J:[],da:lf([new lj(d.value,f)],h,e)});if(v(d.type,47)||v(d.type,56)||v(d.type,58)||v(d.type,57)){l=f?hb(a.h,f):"";if(v(d.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(v(d.type,57)&&l.includes("?>"))throw Error(`XQDY0026: The content "${l}" for a processing instruction node contains "?>".`);k=!0;return q({J:[],da:lf([new nj(d.value,l)],h,e)})}}}}
275
- var Qj=class extends nf{constructor(a,b,c){super(new uf({}),[b,c],{B:!1,R:"unsorted"});this.L=a;this.l=b;this.A=c}s(a,b){const c=mf(this.l)(a,b);a=mf(this.A)(a,b);return this.L?Cj(b,c,a):Bj(b,c,a)}};function Rj(a){switch(a.type){case "delete":return new cj({node:a.target,G:null});case "insertAfter":return new ej({node:a.target,G:null},a.content.map(b=>({node:b,G:null})));case "insertBefore":return new gj({node:a.target,G:null},a.content.map(b=>({node:b,G:null})));case "insertInto":return new jj({node:a.target,G:null},a.content.map(b=>({node:b,G:null})));case "insertIntoAsFirst":return new hj({node:a.target,G:null},a.content.map(b=>({node:b,G:null})));case "insertIntoAsLast":return new ij({node:a.target,
276
- G:null},a.content.map(b=>({node:b,G:null})));case "insertAttributes":return new fj({node:a.target,G:null},a.content.map(b=>({node:b,G:null})));case "rename":return new kj({node:a.target,G:null},a.newName);case "replaceNode":return new mj({node:a.target,G:null},a.replacement.map(b=>({node:b,G:null})));case "replaceValue":return new nj({node:a.target,G:null},a["string-value"]);case "replaceElementContent":return new lj({node:a.target,G:null},a.text?{node:a.text,G:null}:null);default:throw Error(`Unexpected type "${a.type}" when parsing a transferable pending update.`);
277
- }};function Sj(a,b,c){if(b.find(e=>md(e,a)))return!0;const d=x(c,a);return d?Sj(d,b,c):!1}
278
- var Tj=class extends nf{constructor(a,b,c){super(new uf({}),a.reduce((d,e)=>{d.push(e.fb);return d},[b,c]),{B:!1,R:"unsorted"});this.l=a;this.L=b;this.A=c;this.I=null}h(a,b){a=this.s(a,b);return of(a,()=>{})}s(a,b){const c=b.h,d=b.Ja,e=b.Ma,f=[];let h,k,l;const n=[],t=[];return{next:()=>{if(n.length!==this.l.length)for(var u=n.length;u<this.l.length;u++){const y=this.l[u];var z=f[u];z||(f[u]=z=mf(y.fb)(a,b));z=z.next(0);if(1!==z.value.J.length||!v(z.value.J[0].type,53))throw Error("XUTY0013: The source expression of a copy modify expression must return a single node.");
279
- const G=rb(Wf(z.value.J[0].value,b));n.push(G.value);t.push(z.value.da);a=hc(a,{[y.fc]:()=>w.m(G)})}l||(h||=mf(this.L)(a,b),l=h.next(0).value.da);l.forEach(y=>{if(y.target&&!Sj(y.target,n,c))throw Error(`XUDY0014: The target ${y.target.node.outerHTML} must be a node created by the copy clause.`);if("put"===y.type)throw Error("XUDY0037: The modify expression of a copy modify expression can not contain a fn:put.");});u=l.map(y=>{y=y.h(b);return Rj(y)});kf(u,c,d,e);k||=mf(this.A)(a,b);u=k.next(0);return q({J:u.value.J,
280
- da:lf(u.value.da,...t)})}}}v(a){Cg(a);this.l.forEach(b=>b.fc=Gg(a,b.Jb.namespaceURI,b.Jb.localName));super.v(a);Ig(a);this.I=this.l.some(b=>b.fb.I)||this.A.I}};function Uj(a,b){return{node:{nodeType:2,Ra:!0,nodeName:a.za(),namespaceURI:a.namespaceURI,prefix:a.prefix,localName:a.localName,name:a.za(),value:b},G:null}}
281
- var Vj=class extends D{constructor(a,b){let c=b.nb||[];c=c.concat(a.Na||[]);super(new uf({}),c,{B:!1,R:"unsorted"});a.Na?this.s=a.Na:this.name=new Sa(a.prefix,a.namespaceURI,a.localName);this.l=b;this.A=void 0}h(a,b){let c,d,e,f=!1;return w.create({next:()=>{if(f)return p;if(!d){if(this.s){if(!c){var h=this.s.h(a,b);c=zj(this.A,b,h)}d=c.next(0).value.value}else d=this.name;if(d){if("xmlns"===d.prefix)throw rg(d);if(""===d.prefix&&"xmlns"===d.localName)throw rg(d);if("http://www.w3.org/2000/xmlns/"===
282
- d.namespaceURI)throw rg(d);if("xml"===d.prefix&&"http://www.w3.org/XML/1998/namespace"!==d.namespaceURI)throw rg(d);if(""!==d.prefix&&"xml"!==d.prefix&&"http://www.w3.org/XML/1998/namespace"===d.namespaceURI)throw rg(d);}}if(this.l.nb)return h=this.l.nb,e||(e=jc(h.map(k=>qc(k.h(a,b),b).N(l=>w.m(g(l.map(n=>n.value).join(" "),1))))).N(k=>w.m(rb(Uj(d,k.map(l=>l.value).join(""))))).value),e.next(0);f=!0;return q(rb(Uj(d,this.l.value)))}})}v(a){this.A=Ef(a);if(this.name&&this.name.prefix&&!this.name.namespaceURI){const b=
283
- a.$(this.name.prefix);if(void 0===b&&this.name.prefix)throw oc(this.name.prefix);this.name.namespaceURI=b||null}super.v(a)}};var Wj=class extends D{constructor(a){super(a?a.o:new uf({}),a?[a]:[],{B:!1,R:"unsorted"});this.l=a}h(a,b){const c={data:"",Ra:!0,nodeType:8},d={node:c,G:null};if(!this.l)return w.m(rb(d));a=C(this.l,a,b);return qc(a,b).N(e=>{e=e.map(f=>jd(f,1).value).join(" ");if(-1!==e.indexOf("--\x3e"))throw Error('XQDY0072: The contents of the data of a comment may not include "--\x3e"');c.data=e;return w.m(rb(d))})}};var Xj=class extends D{constructor(a,b,c,d){super(new uf({}),d.concat(b).concat(a.Na||[]),{B:!1,R:"unsorted"});a.Na?this.s=a.Na:this.l=new Sa(a.prefix,a.namespaceURI,a.localName);this.P=c.reduce((e,f)=>{if(f.prefix in e)throw Error(`XQST0071: The namespace declaration with the prefix ${f.prefix} has already been declared on the constructed element.`);e[f.prefix||""]=f.uri;return e},{});this.L=b;this.ma=d;this.A=void 0}h(a,b){let c=!1,d,e,f=!1,h,k,l,n=!1;return w.create({next:()=>{if(n)return p;c||
284
- (d||=jc(this.L.map(G=>C(G,a,b))),e=d.O(),c=!0);if(!f){h||=this.ma.map(G=>C(G,a,b));var t=[];for(var u=0;u<h.length;u++){var z=h[u].O();t.push(z)}k=t;f=!0}this.s&&(l||(t=this.s.h(a,b),l=zj(this.A,b,t)),this.l=l.next(0).value.value);if("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.`);
285
- const y={nodeType:1,Ra:!0,attributes:[],childNodes:[],nodeName:this.l.za(),namespaceURI:this.l.namespaceURI,prefix:this.l.prefix,localName:this.l.localName};t={node:y,G:null};e.forEach(G=>{y.attributes.push(G.value.node)});u=rj(k,b,qg);u.attributes.forEach(G=>{if(y.attributes.find(N=>N.namespaceURI===G.namespaceURI&&N.localName===G.localName))throw Error(`XQDY0025: The attribute ${G.name} does not have an unique name in the constructed element.`);y.attributes.push(G)});u.Xa.forEach(G=>{y.childNodes.push(G)});
286
- for(u=0;u<y.childNodes.length;u++){z=y.childNodes[u];if(!cb(z)||3!==z.nodeType)continue;const G=y.childNodes[u-1];G&&cb(G)&&3===G.nodeType&&(G.data+=z.data,y.childNodes.splice(u,1),u--)}n=!0;return q(rb(t))}})}v(a){Cg(a);Object.keys(this.P).forEach(b=>Fg(a,b,this.P[b]));this.Fa.forEach(b=>b.v(a));this.L.reduce((b,c)=>{if(c.name){c=`Q{${null===c.name.namespaceURI?a.$(c.name.prefix):c.name.namespaceURI}}${c.name.localName}`;if(b.includes(c))throw Error(`XQST0040: The attribute ${c} does not have an unique name in the constructed element.`);
287
- b.push(c)}return b},[]);if(this.l&&null===this.l.namespaceURI){const b=a.$(this.l.prefix);if(void 0===b&&this.l.prefix)throw oc(this.l.prefix);this.l.namespaceURI=b}this.A=Ef(a);Ig(a)}};function Yj(a){if(/^xml$/i.test(a))throw Error(`XQDY0064: The target of a created PI may not be "${a}"`);}function Zj(a,b){return{node:{data:b,Ra:!0,nodeName:a,nodeType:7,target:a},G:null}}
288
- var ak=class extends D{constructor(a,b){const c=a.xb?[a.xb].concat(b):[b];super(c.reduce((d,e)=>d.add(e.o),new uf({})),c,{B:!1,R:"unsorted"});this.l=a;this.s=b}h(a,b){const c=C(this.s,a,b);return qc(c,b).N(d=>{const e=d.map(h=>jd(h,1).value).join(" ");if(-1!==e.indexOf("?>"))throw Error('XQDY0026: The contents of the data of a processing instruction may not include "?>"');if(null!==this.l.Fb)return d=this.l.Fb,Yj(d),w.m(rb(Zj(d,e)));d=C(this.l.xb,a,b);const f=yj(b,d);return w.create({next:()=>{var h=
289
- f.next(0);if(h.done)return h;h=h.value.value;Yj(h);return q(rb(Zj(h,e)))}})})}};var bk=class extends D{constructor(a){super(a?a.o:new uf({}),a?[a]:[],{B:!1,R:"unsorted"});this.l=a}h(a,b){if(!this.l)return w.empty();a=C(this.l,a,b);return qc(a,b).N(c=>{if(0===c.length)return w.empty();c={node:{data:c.map(d=>jd(d,1).value).join(" "),Ra:!0,nodeType:3},G:null};return w.m(rb(c))})}};var ck=class extends qf{constructor(a,b,c,d){super(new uf({}),[a,...b.map(e=>e.pb),c].concat(...b.map(e=>e.Ib.map(f=>f.Hb))),{B:!1,W:!1,R:"unsorted",subtree:!1},d);this.L=a;this.l=b.length;this.P=b.map(e=>e.Ib)}A(a,b,c){return c[0](a).N(d=>{for(let e=0;e<this.l;e++)if(this.P[e].some(f=>{switch(f.ec){case "?":if(1<d.length)return!1;break;case "*":break;case "+":if(1>d.length)return!1;break;default:if(1!==d.length)return!1}const h=w.create(d);return d.every((k,l)=>{k=bc(a,l,k,h);return C(f.Hb,k,b).fa()})}))return c[e+
290
- 1](a);return c[this.l+1](a)})}v(a){super.v(a);if(this.L.I)throw Ne();}};var dk=class extends qf{constructor(a,b,c,d){super(new uf({}),[a,c,...b.map(e=>e.pb)].concat(...b.map(e=>e.Gb.map(f=>f))),{B:!1,W:!1,R:"unsorted",subtree:!1},d);this.L=a;this.l=b.length;this.P=b.map(e=>e.Gb)}A(a,b,c){const d=ei(c[0](a),b),[,e,...f]=c;return d.X({multiple:()=>{throw Error("XPTY0004: The operand for a switch expression should result in zero or one item");},default:()=>{const h=d.first(),k=!h;for(let n=0;n<this.l;n++){var l=this.P[n].map(t=>C(t,a,b));for(const t of l)if(l=ei(t,b),l.F()){if(k)return f[n](a)}else{if(!l.oa())throw Error("XPTY0004: The operand for a switch case should result in zero or one item");
291
- if(!k&&(l=l.first(),Ge(a,b,null,h,l).next(0).value))return f[n](a)}}return e(a)}})}v(a){super.v(a);if(this.L.I)throw Ne();}};var ek={Z:!1,sa:!1},fk={Z:!0,sa:!1},gk={Z:!0,sa:!0};function P(a){return a.Z?a.sa?gk:fk:ek}
292
- function Q(a,b){switch(a[0]){case "andOp":var c=I(a,"type");return new ci(hk("andOp",a,P(b)),c);case "orOp":return c=I(a,"type"),new di(hk("orOp",a,P(b)),c);case "unaryPlusOp":return c=F(F(a,"operand"),"*"),a=I(a,"type"),new bi("+",Q(c,b),a);case "unaryMinusOp":return c=F(F(a,"operand"),"*"),a=I(a,"type"),new bi("-",Q(c,b),a);case "addOp":case "subtractOp":case "multiplyOp":case "divOp":case "idivOp":case "modOp":var d=a[0],e=Q(J(a,["firstOperand","*"]),P(b));b=Q(J(a,["secondOperand","*"]),P(b));
293
- const f=I(a,"type"),h=I(J(a,["firstOperand","*"]),"type"),k=I(J(a,["secondOperand","*"]),"type");h&&k&&I(a,"type")&&(c=Rg(d,h.type,k.type));return new Vg(d,e,b,f,c);case "sequenceExpr":return ik(a,b);case "unionOp":return c=I(a,"type"),new Hi([Q(J(a,["firstOperand","*"]),P(b)),Q(J(a,["secondOperand","*"]),P(b))],c);case "exceptOp":case "intersectOp":return c=I(a,"type"),new xi(a[0],Q(J(a,["firstOperand","*"]),P(b)),Q(J(a,["secondOperand","*"]),P(b)),c);case "stringConcatenateOp":return jk(a,b);case "rangeSequenceExpr":return kk(a,
294
- b);case "equalOp":case "notEqualOp":case "lessThanOrEqualOp":case "lessThanOp":case "greaterThanOrEqualOp":case "greaterThanOp":return lk("generalCompare",a,b);case "eqOp":case "neOp":case "ltOp":case "leOp":case "gtOp":case "geOp":return lk("valueCompare",a,b);case "isOp":case "nodeBeforeOp":case "nodeAfterOp":return lk("nodeCompare",a,b);case "pathExpr":return mk(a,b);case "contextItemExpr":return new Mi(I(a,"type"));case "functionCallExpr":return nk(a,b);case "inlineFunctionExpr":return ok(a,b);
295
- case "arrowExpr":return pk(a,b);case "dynamicFunctionInvocationExpr":return qk(a,b);case "namedFunctionRef":return b=F(a,"functionName"),c=I(a,"type"),a=H(J(a,["integerConstantExpr","value"])),new $h(Jg(b),parseInt(a,10),c);case "integerConstantExpr":return new Yh(H(F(a,"value")),{type:5,g:3});case "stringConstantExpr":return new Yh(H(F(a,"value")),{type:1,g:3});case "decimalConstantExpr":return new Yh(H(F(a,"value")),{type:4,g:3});case "doubleConstantExpr":return new Yh(H(F(a,"value")),{type:3,g:3});
296
- case "varRef":const {prefix:l,namespaceURI:n,localName:t}=Jg(F(a,"name"));return new $i(l,n,t);case "flworExpr":return rk(a,b);case "quantifiedExpr":return sk(a,b);case "ifThenElseExpr":return c=I(a,"type"),d=F(a,"ifClause")||K(a,"x:stackTrace")[0],e=F(a,"thenClause")||K(a,"x:stackTrace")[1],a=F(a,"elseClause")||K(a,"x:stackTrace")[2],new Ph(Q(d,P(b)),Q(e,b),Q(a,b),c);case "instanceOfExpr":return c=Q(J(a,["argExpr","*"]),b),d=J(a,["sequenceType","*"]),e=J(a,["sequenceType","occurrenceIndicator"]),
297
- a=I(a,"type"),new Di(c,Q(d,P(b)),e?H(e):"",a);case "castExpr":return b=Q(F(F(a,"argExpr"),"*"),P(b)),c=F(a,"singleType"),a=Jg(F(c,"atomicType")),c=null!==F(c,"optional"),new Bi(b,a,c);case "castableExpr":return b=Q(F(F(a,"argExpr"),"*"),P(b)),c=F(a,"singleType"),a=Jg(F(c,"atomicType")),c=null!==F(c,"optional"),new Ai(b,a,c);case "simpleMapExpr":return tk(a,b);case "mapConstructor":return uk(a,b);case "arrayConstructor":return vk(a,b);case "unaryLookup":return c=I(a,"type"),new Ti(wk(a,b),c);case "typeswitchExpr":return xk(a,
298
- b);case "switchExpr":return yk(a,b);case "elementConstructor":return zk(a,b);case "attributeConstructor":return Ak(a,b);case "computedAttributeConstructor":return(c=F(a,"tagName"))?c=Jg(c):(c=F(a,"tagNameExpr"),c={Na:Q(F(c,"*"),P(b))}),b=Q(F(F(a,"valueExpr"),"*"),P(b)),new Vj(c,{nb:[b]});case "computedCommentConstructor":if(!b.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");b=(a=F(a,"argExpr"))?Q(F(a,"*"),P(b)):null;return new Wj(b);case "computedTextConstructor":if(!b.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");
299
- b=(a=F(a,"argExpr"))?Q(F(a,"*"),P(b)):null;return new bk(b);case "computedElementConstructor":return Bk(a,b);case "computedPIConstructor":if(!b.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");c=F(a,"piTargetExpr");d=F(a,"piTarget");e=F(a,"piValueExpr");a=I(a,"type");return new ak({xb:c?Q(F(c,"*"),P(b)):null,Fb:d?H(d):null},e?Q(F(e,"*"),P(b)):new yi([],a));case "CDataSection":return new Yh(H(a),{type:1,g:3});case "deleteExpr":return b=Q(J(a,["targetExpr","*"]),
300
- b),new pj(b);case "insertExpr":c=Q(J(a,["sourceExpr","*"]),b);e=K(a,"*")[1];switch(e[0]){case "insertAfter":d=1;break;case "insertBefore":d=2;break;case "insertInto":d=(d=F(e,"*"))?"insertAsFirst"===d[0]?4:5:3}b=Q(J(a,["targetExpr","*"]),b);return new tj(c,d,b);case "renameExpr":return c=Q(J(a,["targetExpr","*"]),b),b=Q(J(a,["newNameExpr","*"]),b),new Aj(c,b);case "replaceExpr":return c=!!F(a,"replaceValue"),d=Q(J(a,["targetExpr","*"]),b),b=Q(J(a,["replacementExpr","*"]),b),new Qj(c,d,b);case "transformExpr":return Ck(a,
301
- b);case "x:stackTrace":c=a;for(a=c[2];"x:stackTrace"===a[0];)c=a,a=a[2];c=c[1];return new Rh(c,a[0],Q(a,b),c.Wa);case "ifClause":case "thenClause":case "elseClause":return Q(F(a,"*"),b);default:return Dk(a)}}
302
- function Dk(a){switch(a[0]){case "nameTest":return new Xi(Jg(a));case "piTest":return(a=F(a,"piTarget"))?new Yi(H(a)):new Wi(7);case "commentTest":return new Wi(8);case "textTest":return new Wi(3);case "documentTest":return new Wi(9);case "attributeTest":var b=(a=F(a,"attributeName"))&&F(a,"star");return!a||b?new Wi(2):new Xi(Jg(F(a,"QName")),{kind:2});case "elementTest":return b=(a=F(a,"elementName"))&&F(a,"star"),!a||b?new Wi(1):new Xi(Jg(F(a,"QName")),{kind:1});case "anyKindTest":return new Zi({prefix:"",
303
- namespaceURI:null,localName:"node()"});case "anyMapTest":return new Zi({prefix:"",namespaceURI:null,localName:"map(*)"});case "anyArrayTest":return new Zi({prefix:"",namespaceURI:null,localName:"array(*)"});case "Wildcard":return F(a,"star")?(b=F(a,"uri"))?a=new Xi({localName:"*",namespaceURI:H(b),prefix:""}):(b=F(a,"NCName"),a="star"===F(a,"*")[0]?new Xi({localName:H(b),namespaceURI:null,prefix:"*"}):new Xi({localName:"*",namespaceURI:null,prefix:H(b)})):a=new Xi({localName:"*",namespaceURI:null,
304
- prefix:"*"}),a;case "atomicType":return new Zi(Jg(a));case "anyItemType":return new Zi({prefix:"",namespaceURI:null,localName:"item()"});default:throw Error("No selector counterpart for: "+a[0]+".");}}function vk(a,b){const c=I(a,"type");a=F(a,"*");const d=K(a,"arrayElem").map(e=>Q(F(e,"*"),P(b)));switch(a[0]){case "curlyArray":return new rh(d,c);case "squareArray":return new sh(d,c);default:throw Error("Unrecognized arrayType: "+a[0]);}}
305
- function uk(a,b){const c=I(a,"type");return new Zh(K(a,"mapConstructorEntry").map(d=>({key:Q(J(d,["mapKeyExpr","*"]),P(b)),value:Q(J(d,["mapValueExpr","*"]),P(b))})),c)}function hk(a,b,c){function d(f){const h=F(F(f,"firstOperand"),"*");f=F(F(f,"secondOperand"),"*");h[0]===a?d(h):e.push(Q(h,c));f[0]===a?d(f):e.push(Q(f,c))}const e=[];d(b);return e}function wk(a,b){a=F(a,"*");switch(a[0]){case "NCName":return new Yh(H(a),{type:1,g:3});case "star":return"*";default:return Q(a,P(b))}}
306
- function lk(a,b,c){var d=J(b,["firstOperand","*"]);const e=J(b,["secondOperand","*"]);d=Q(d,P(c));c=Q(e,P(c));switch(a){case "valueCompare":return new pi(b[0],d,c);case "nodeCompare":return new vi(b[0],d,c);case "generalCompare":return new si(b[0],d,c)}}
307
- function Ek(a,b,c){a=K(a,"*");return new Ki(a.filter(d=>"stable"!==d[0]).map(d=>{var e=F(d,"orderModifier"),f=e?F(e,"orderingKind"):null;e=e?F(e,"emptyOrderingMode"):null;f=f?"ascending"===H(f):!0;e=e?"empty least"===H(e):!0;return{ba:Q(J(d,["orderByExpr","*"]),b),Bb:f,cc:e}}),c)}
308
- function rk(a,b){var c=K(a,"*");a=F(c[c.length-1],"*");c=c.slice(0,-1);if(1<c.length&&!b.Z)throw Error("XPST0003: Use of XQuery FLWOR expressions in XPath is no allowed");return c.reduceRight((d,e)=>{switch(e[0]){case "forClause":e=K(e,"*");for(var f=e.length-1;0<=f;--f){var h=e[f],k=J(h,["forExpr","*"]);const l=F(h,"positionalVariableBinding");d=new Vh(Jg(J(h,["typedVariableBinding","varName"])),Q(k,P(b)),l?Jg(l):null,d)}return d;case "letClause":e=K(e,"*");for(f=e.length-1;0<=f;--f)h=e[f],k=J(h,
309
- ["letExpr","*"]),d=new Xh(Jg(J(h,["typedVariableBinding","varName"])),Q(k,P(b)),d);return d;case "whereClause":e=K(e,"*");for(f=e.length-1;0<=f;--f)d=new aj(Q(e[f],b),d);return d;case "windowClause":throw Error(`Not implemented: ${e[0]} is not implemented yet.`);case "groupByClause":throw Error(`Not implemented: ${e[0]} is not implemented yet.`);case "orderByClause":return Ek(e,b,d);case "countClause":throw Error(`Not implemented: ${e[0]} is not implemented yet.`);default:throw Error(`Not implemented: ${e[0]} is not supported in a flwor expression`);
310
- }},Q(a,b))}function nk(a,b){const c=F(a,"functionName"),d=K(F(a,"arguments"),"*");a=I(a,"type");return new Ff(new $h(Jg(c),d.length,a),d.map(e=>"argumentPlaceholder"===e[0]?null:Q(e,b)),a)}
311
- function pk(a,b){const c=I(a,"type");var d=J(a,["argExpr","*"]);a=K(a,"*").slice(1);d=[Q(d,b)];for(let f=0;f<a.length;f++)if("arguments"!==a[f][0]){if("arguments"===a[f+1][0]){var e=K(a[f+1],"*");d=d.concat(e.map(h=>"argumentPlaceholder"===h[0]?null:Q(h,b)))}e="EQName"===a[f][0]?new $h(Jg(a[f]),d.length,c):Q(a[f],P(b));d=[new Ff(e,d,c)]}return d[0]}
312
- function qk(a,b){const c=J(a,["functionItem","*"]),d=I(a,"type");a=F(a,"arguments");let e=[];a&&(e=K(a,"*").map(f=>"argumentPlaceholder"===f[0]?null:Q(f,b)));return new Ff(Q(c,b),e,d)}function ok(a,b){const c=K(F(a,"paramList"),"*"),d=J(a,["functionBody","*"]),e=I(a,"type");return new Wh(c.map(f=>({name:Jg(F(f,"varName")),type:Kg(f)})),Kg(a),d?Q(d,b):new yi([],e))}
313
- function mk(a,b){const c=I(a,"type");var d=K(a,"stepExpr");let e=!1;var f=d.map(h=>{var k=F(h,"xpathAxis");let l;var n=K(h,"*");const t=[];let u=null,z=!1;for(const y of n)switch(y[0]){case "lookup":t.push(["lookup",wk(y,b)]);break;case "predicate":case "predicates":for(const G of K(y,"*")){n=Q(G,P(b));if(!z){const N=n.D();null===N?z=!0:u=xh(u,N)}t.push(["predicate",n])}}if(k)switch(e=!0,h=F(h,"attributeTest anyElementTest piTest documentTest elementTest commentTest namespaceTest anyKindTest textTest anyFunctionTest typedFunctionTest schemaAttributeTest atomicType anyItemType parenthesizedItemType typedMapTest typedArrayTest nameTest Wildcard".split(" ")),
314
- h=Dk(h),H(k)){case "ancestor":l=new vh(h,{Qa:!1});break;case "ancestor-or-self":l=new vh(h,{Qa:!0});break;case "attribute":l=new yh(h,u);break;case "child":l=new zh(h,u);break;case "descendant":l=new Ch(h,{Qa:!1});break;case "descendant-or-self":l=new Ch(h,{Qa:!0});break;case "parent":l=new Jh(h,u);break;case "following-sibling":l=new Ih(h,u);break;case "preceding-sibling":l=new Nh(h,u);break;case "following":l=new Gh(h);break;case "preceding":l=new Lh(h);break;case "self":l=new Oh(h,u)}else k=J(h,
315
- ["filterExpr","*"]),l=Q(k,P(b));for(const y of t)switch(y[0]){case "lookup":l=new Si(l,y[1]);break;case "predicate":l=new Pi(l,y[1])}l.type=c;return l});a=F(a,"rootExpr");d=e||null!==a||1<d.length;if(!d&&1===f.length||!a&&1===f.length&&"sorted"===f[0].ia)return f[0];if(a&&0===f.length)return new Li(null);f=new Oi(f,d);return a?new Li(f):f}
316
- function sk(a,b){const c=I(a,"type"),d=H(F(a,"quantifier")),e=J(a,["predicateExpr","*"]);a=K(a,"quantifiedExprInClause").map(f=>{const h=Jg(J(f,["typedVariableBinding","varName"]));f=J(f,["sourceExpr","*"]);return{name:h,fb:Q(f,P(b))}});return new Ui(d,a,Q(e,P(b)),c)}function ik(a,b){var c=K(a,"*").map(d=>Q(d,b));if(1===c.length)return c[0];c=I(a,"type");return new yi(K(a,"*").map(d=>Q(d,b)),c)}
317
- function tk(a,b){const c=I(a,"type");return K(a,"*").reduce((d,e)=>null===d?Q(e,P(b)):new zi(d,Q(e,P(b)),c),null)}function jk(a,b){const c=I(a,"type");a=[J(a,["firstOperand","*"]),J(a,["secondOperand","*"])];return new Ff(new $h({localName:"concat",namespaceURI:"http://www.w3.org/2005/xpath-functions",prefix:""},a.length,c),a.map(d=>Q(d,P(b))),c)}
318
- function kk(a,b){const c=I(a,"type");a=[F(F(a,"startExpr"),"*"),F(F(a,"endExpr"),"*")];const d=new $h({localName:"to",namespaceURI:"http://fontoxpath/operators",prefix:""},a.length,c);return new Ff(d,a.map(e=>Q(e,P(b))),c)}
319
- function zk(a,b){if(!b.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const c=Jg(F(a,"tagName"));var d=F(a,"attributeList");const e=d?K(d,"attributeConstructor").map(f=>Q(f,P(b))):[];d=d?K(d,"namespaceDeclaration").map(f=>{const h=F(f,"prefix");return{prefix:h?H(h):"",uri:H(F(f,"uri"))}}):[];a=(a=F(a,"elementContent"))?K(a,"*").map(f=>Q(f,P(b))):[];return new Xj(c,e,d,a)}
320
- function Ak(a,b){if(!b.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const c=Jg(F(a,"attributeName"));var d=F(a,"attributeValue");d=d?H(d):null;a=(a=F(a,"attributeValueExpr"))?K(a,"*").map(e=>Q(e,P(b))):null;return new Vj(c,{value:d,nb:a})}function Bk(a,b){var c=F(a,"tagName");c?c=Jg(c):(c=F(a,"tagNameExpr"),c={Na:Q(F(c,"*"),P(b))});a=(a=F(a,"contentExpr"))?K(a,"*").map(d=>Q(d,P(b))):[];return new Xj(c,[],[],a)}
321
- function Ck(a,b){const c=K(F(a,"transformCopies"),"transformCopy").map(e=>{const f=Jg(F(F(e,"varRef"),"name"));return{fb:Q(F(F(e,"copySource"),"*"),b),Jb:new Sa(f.prefix,f.namespaceURI,f.localName)}}),d=Q(F(F(a,"modifyExpr"),"*"),b);a=Q(F(F(a,"returnExpr"),"*"),b);return new Tj(c,d,a)}
322
- function xk(a,b){if(!b.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const c=I(a,"type"),d=Q(F(F(a,"argExpr"),"*"),b),e=K(a,"typeswitchExprCaseClause").map(f=>{const h=0===K(f,"sequenceTypeUnion").length?[F(f,"sequenceType")]:K(F(f,"sequenceTypeUnion"),"sequenceType");return{pb:Q(J(f,["resultExpr","*"]),b),Ib:h.map(k=>{const l=F(k,"occurrenceIndicator");return{ec:l?H(l):"",Hb:Q(F(k,"*"),b)}})}});a=Q(J(a,["typeswitchExprDefaultClause","resultExpr","*"]),b);
323
- return new ck(d,e,a,c)}function yk(a,b){if(!b.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const c=I(a,"type"),d=Q(F(F(a,"argExpr"),"*"),b),e=K(a,"switchExprCaseClause").map(f=>{const h=K(f,"switchCaseExpr");return{pb:Q(J(f,["resultExpr","*"]),b),Gb:h.map(k=>Q(F(k,"*"),b))}});a=Q(J(a,["switchExprDefaultClause","resultExpr","*"]),b);return new dk(d,e,a,c)}function Fk(a,b){return Q(a,b)};const Gk=new Map;class Hk{constructor(a,b,c,d,e,f){this.v=a;this.D=b;this.h=c;this.kb=d;this.o=e;this.l=f}}function Ik(a,b,c,d,e,f,h,k){a=Gk.get(a);if(!a)return null;b=a[b+(f?"_DEBUG":"")];return b?(b=b.find(l=>l.o===h&&l.v.every(n=>c(n.prefix)===n.namespaceURI)&&l.D.every(n=>void 0!==d[n.name])&&l.kb.every(n=>e[n.prefix]===n.namespaceURI)&&l.l.every(n=>{const t=k(n.dc,n.arity);return t&&t.namespaceURI===n.Db.namespaceURI&&t.localName===n.Db.localName})))?{ba:b.h,hc:!1}:null:null}
324
- function Jk(a,b,c,d,e,f,h){let k=Gk.get(a);k||(k=Object.create(null),Gk.set(a,k));a=b+(f?"_DEBUG":"");(b=k[a])||(b=k[a]=[]);b.push(new Hk(Object.values(c.h),Object.values(c.o),e,Object.keys(d).map(l=>({namespaceURI:d[l],prefix:l})),h,c.D))};function Kk(a){var b=new Za;if("http://www.w3.org/2005/XQueryX"!==a.namespaceURI&&"http://www.w3.org/2005/XQueryX"!==a.namespaceURI&&"http://fontoxml.com/fontoxpath"!==a.namespaceURI&&"http://www.w3.org/2007/xquery-update-10"!==a.namespaceURI)throw mc("The XML structure passed as an XQueryX program was not valid XQueryX");const c=["stackTrace"===a.localName?"x:stackTrace":a.localName],d=b.getAllAttributes(a);d&&0<d.length&&c.push(Array.from(d).reduce((e,f)=>{"comment"!==f.localName&&"start"!==f.localName&&
325
- "end"!==f.localName||"stackTrace"!==a.localName?"type"===f.localName?e[f.localName]=Ja(f.value):e[f.localName]=f.value:e[f.localName]=JSON.parse(f.value);return e},{}));b=b.getChildNodes(a);for(const e of b)switch(e.nodeType){case 1:c.push(Kk(e));break;case 3:c.push(e.data)}return c};const Lk=Object.create(null);
326
- var Mk=(a,b)=>{let c=Lk[a];c||=Lk[a]={Ia:[],Ta:[],pa:null,source:b.source};const d=c.pa||(()=>{});c.Ia=c.Ia.concat(b.Ia);c.Ta=c.Ta.concat(b.Ta);c.pa=e=>{d(e);b.pa&&b.pa(e)}},Nk=(a,b)=>{const c=Lk[b];if(!c)throw Error(`XQST0051: No modules found with the namespace uri ${b}`);c.Ia.forEach(d=>{d.cb&&Eg(a,b,d.localName,d.arity,d)});c.Ta.forEach(d=>{Gg(a,b,d.localName);Hg(a,b,d.localName,(e,f)=>C(d.ba,e,f))})},Ok=()=>{Object.keys(Lk).forEach(a=>{a=Lk[a];if(a.pa)try{a.pa(a)}catch(b){a.pa=null,gg(a.source,
327
- b)}a.pa=null})};function Pk(a){return a.replace(/(\x0D\x0A)|(\x0D(?!\x0A))/g,String.fromCharCode(10))};var R=prsc;function Qk(a,b){return(c,d)=>{if(b.has(d))return b.get(d);c=a(c,d);b.set(d,c);return c}}function S(a,b){return(0,R.delimited)(b,a,b)}function T(a,b){return a.reverse().reduce((c,d)=>(0,R.preceded)(d,c),b)}function Rk(a,b,c,d){return(0,R.then)((0,R.then)(a,b,(e,f)=>[e,f]),c,([e,f],h)=>d(e,f,h))}function Sk(a,b,c,d,e){return(0,R.then)((0,R.then)((0,R.then)(a,b,(f,h)=>[f,h]),c,([f,h],k)=>[f,h,k]),d,([f,h,k],l)=>e(f,h,k,l))}
328
- function Tk(a,b,c,d,e,f){return(0,R.then)((0,R.then)((0,R.then)((0,R.then)(a,b,(h,k)=>[h,k]),c,([h,k],l)=>[h,k,l]),d,([h,k,l],n)=>[h,k,l,n]),e,([h,k,l,n],t)=>f(h,k,l,n,t))}function Uk(a){return(0,R.map)(a,b=>[b])}function Vk(a,b){return(0,R.map)((0,R.or)(a),()=>b)}function Wk(a){return(b,c)=>(b=a.exec(b.substring(c)))&&0===b.index?(0,R.okWithValue)(c+b[0].length,b[0]):(0,R.error)(c,[a.source],!1)};var Xk=(0,R.or)([(0,R.token)(" "),(0,R.token)("\t"),(0,R.token)("\r"),(0,R.token)("\n")]),Yk=(0,R.token)("(:"),Zk=(0,R.token)(":)"),$k=(0,R.token)("(#"),al=(0,R.token)("#)"),bl=(0,R.token)("("),cl=(0,R.token)(")"),dl=(0,R.token)("["),el=(0,R.token)("]"),fl=(0,R.token)("{"),gl=(0,R.token)("}"),hl=(0,R.token)("{{"),il=(0,R.token)("}}"),jl=(0,R.token)("'"),kl=(0,R.token)("''"),ll=(0,R.token)('"'),ml=(0,R.token)('""'),nl=(0,R.token)("<![CDATA["),ol=(0,R.token)("]]\x3e"),pl=(0,R.token)("/>"),ql=(0,R.token)("</"),
329
- rl=(0,R.token)("\x3c!--"),sl=(0,R.token)("--\x3e"),tl=(0,R.token)("<?"),ul=(0,R.token)("?>"),vl=(0,R.token)("&#x"),wl=(0,R.token)("&#"),xl=(0,R.token)(":*"),yl=(0,R.token)("*:"),zl=(0,R.token)(":="),Al=(0,R.token)("&"),Bl=(0,R.token)(":"),Cl=(0,R.token)(";"),Dl=(0,R.token)("*"),El=(0,R.token)("@"),Fl=(0,R.token)("$"),Gl=(0,R.token)("#"),Hl=(0,R.token)("%"),Il=(0,R.token)("?"),Jl=(0,R.token)("="),Kl=(0,R.followed)((0,R.token)("!"),(0,R.not)((0,R.peek)(Jl),[])),Ll=(0,R.followed)((0,R.token)("|"),(0,R.not)((0,R.peek)((0,R.token)("|")),
330
- [])),Ml=(0,R.token)("||"),Nl=(0,R.token)("!="),Ol=(0,R.token)("<"),Pl=(0,R.token)("<<"),Ql=(0,R.token)("<="),Rl=(0,R.token)(">"),Sl=(0,R.token)(">>"),Tl=(0,R.token)(">="),Ul=(0,R.token)(","),Vl=(0,R.token)("."),Wl=(0,R.token)(".."),Xl=(0,R.token)("+"),Yl=(0,R.token)("-"),Zl=(0,R.token)("/"),$l=(0,R.token)("//"),am=(0,R.token)("=>"),bm=(0,R.token)("e"),cm=(0,R.token)("E");(0,R.token)("l");(0,R.token)("L");(0,R.token)("m");(0,R.token)("M");var dm=(0,R.token)("Q");(0,R.token)("x");(0,R.token)("X");
331
- var em=(0,R.token)("as"),fm=(0,R.token)("cast"),gm=(0,R.token)("castable"),hm=(0,R.token)("treat"),im=(0,R.token)("instance"),jm=(0,R.token)("of"),km=(0,R.token)("node"),lm=(0,R.token)("nodes"),mm=(0,R.token)("delete"),nm=(0,R.token)("value"),om=(0,R.token)("function"),pm=(0,R.token)("map"),qm=(0,R.token)("element"),rm=(0,R.token)("attribute"),sm=(0,R.token)("schema-element"),tm=(0,R.token)("intersect"),um=(0,R.token)("except"),vm=(0,R.token)("union"),wm=(0,R.token)("to"),xm=(0,R.token)("is"),ym=
332
- (0,R.token)("or"),zm=(0,R.token)("and"),Am=(0,R.token)("div"),Bm=(0,R.token)("idiv"),Cm=(0,R.token)("mod"),Dm=(0,R.token)("eq"),Em=(0,R.token)("ne"),Fm=(0,R.token)("lt"),Gm=(0,R.token)("le"),Hm=(0,R.token)("gt"),Im=(0,R.token)("ge"),Jm=(0,R.token)("amp"),Km=(0,R.token)("quot"),Lm=(0,R.token)("apos"),Mm=(0,R.token)("if"),Nm=(0,R.token)("then"),Om=(0,R.token)("else"),Pm=(0,R.token)("allowing"),Qm=(0,R.token)("empty"),Rm=(0,R.token)("at"),Sm=(0,R.token)("in"),Tm=(0,R.token)("for"),Um=(0,R.token)("let"),
333
- Vm=(0,R.token)("where"),Wm=(0,R.token)("collation"),Xm=(0,R.token)("group"),Ym=(0,R.token)("by"),Zm=(0,R.token)("order"),$m=(0,R.token)("stable"),an=(0,R.token)("return"),bn=(0,R.token)("array"),cn=(0,R.token)("document"),dn=(0,R.token)("namespace"),en=(0,R.token)("text"),fn=(0,R.token)("comment"),gn=(0,R.token)("processing-instruction"),hn=(0,R.token)("lax"),jn=(0,R.token)("strict"),kn=(0,R.token)("validate"),ln=(0,R.token)("type"),mn=(0,R.token)("declare"),nn=(0,R.token)("default"),on=(0,R.token)("boundary-space"),
334
- pn=(0,R.token)("strip"),qn=(0,R.token)("preserve"),rn=(0,R.token)("no-preserve"),sn=(0,R.token)("inherit"),tn=(0,R.token)("no-inherit"),un=(0,R.token)("greatest"),vn=(0,R.token)("least"),wn=(0,R.token)("copy-namespaces"),xn=(0,R.token)("decimal-format"),yn=(0,R.token)("case"),zn=(0,R.token)("typeswitch"),An=(0,R.token)("some"),Bn=(0,R.token)("every"),Cn=(0,R.token)("satisfies"),Dn=(0,R.token)("replace"),En=(0,R.token)("with"),Fn=(0,R.token)("copy"),Gn=(0,R.token)("modify"),Hn=(0,R.token)("first"),
335
- In=(0,R.token)("last"),Jn=(0,R.token)("before"),Kn=(0,R.token)("after"),Ln=(0,R.token)("into"),Mn=(0,R.token)("insert"),Nn=(0,R.token)("rename"),On=(0,R.token)("switch"),Pn=(0,R.token)("variable"),Qn=(0,R.token)("external"),Rn=(0,R.token)("updating"),Sn=(0,R.token)("import"),Tn=(0,R.token)("schema"),Un=(0,R.token)("module"),Vn=(0,R.token)("base-uri"),Wn=(0,R.token)("construction"),Xn=(0,R.token)("ordering"),Yn=(0,R.token)("ordered"),Zn=(0,R.token)("unordered"),$n=(0,R.token)("option"),ao=(0,R.token)("context"),
336
- bo=(0,R.token)("item"),co=(0,R.token)("xquery"),eo=(0,R.token)("version"),fo=(0,R.token)("encoding"),go=(0,R.token)("document-node"),ho=(0,R.token)("namespace-node"),io=(0,R.token)("schema-attribute"),jo=(0,R.token)("ascending"),ko=(0,R.token)("descending"),lo=(0,R.token)("empty-sequence"),mo=(0,R.token)("child::"),no=(0,R.token)("descendant::"),oo=(0,R.token)("attribute::"),po=(0,R.token)("self::"),qo=(0,R.token)("descendant-or-self::"),ro=(0,R.token)("following-sibling::"),so=(0,R.token)("following::"),
337
- to=(0,R.token)("parent::"),uo=(0,R.token)("ancestor::"),vo=(0,R.token)("preceding-sibling::"),wo=(0,R.token)("preceding::"),xo=(0,R.token)("ancestor-or-self::"),yo=(0,R.token)("decimal-separator"),zo=(0,R.token)("grouping-separator"),Ao=(0,R.token)("infinity"),Bo=(0,R.token)("minus-sign"),Co=(0,R.token)("NaN"),Do=(0,R.token)("per-mille"),Eo=(0,R.token)("zero-digit"),Fo=(0,R.token)("digit"),Go=(0,R.token)("pattern-separator"),Ho=(0,R.token)("exponent-separator"),Io=(0,R.token)("schema-attribute("),
338
- Jo=(0,R.token)("document-node("),Ko=(0,R.token)("processing-instruction("),Lo=(0,R.token)("processing-instruction()"),Mo=(0,R.token)("comment()"),No=(0,R.token)("text()"),Oo=(0,R.token)("namespace-node()"),Po=(0,R.token)("node()"),Qo=(0,R.token)("item()"),Ro=(0,R.token)("empty-sequence()");(0,R.token)("`");var So=(0,R.token)("``["),To=(0,R.token)("]``"),Uo=(0,R.token)("`{"),Vo=(0,R.token)("}`");var Wo=new Map,Xo=new Map,Yo=(0,R.or)([Wk(/[\t\n\r -\uD7FF\uE000\uFFFD]/),Wk(/[\uD800-\uDBFF][\uDC00-\uDFFF]/)]),Zo=(0,R.preceded)((0,R.peek)((0,R.not)((0,R.or)([Yk,Zk]),['comment contents cannot contain "(:" or ":)"'])),Yo),$o=(0,R.map)((0,R.delimited)(Yk,(0,R.star)((0,R.or)([Zo,function(a,b){return $o(a,b)}])),Zk,!0),a=>a.join("")),ap=(0,R.or)([Xk,$o]),bp=(0,R.map)((0,R.plus)(Xk),a=>a.join("")),V=Qk((0,R.map)((0,R.star)(ap),a=>a.join("")),Wo),X=Qk((0,R.map)((0,R.plus)(ap),a=>a.join("")),Xo);const cp=(0,R.or)([Wk(/[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,R.then)(Wk(/[\uD800-\uDB7F]/),Wk(/[\uDC00-\uDFFF]/),(a,b)=>a+b)]),dp=(0,R.or)([cp,Wk(/[\-\.0-9\xB7\u0300-\u036F\u203F\u2040]/)]);var ep=(0,R.then)(cp,(0,R.star)(dp),(a,b)=>a+b.join("")),fp=(0,R.map)(ep,a=>["prefix",a]);const gp=(0,R.or)([cp,Bl]),hp=(0,R.or)([dp,Bl]);(0,R.then)(gp,(0,R.star)(hp),(a,b)=>a+b.join(""));
339
- const ip=(0,R.map)(ep,a=>[{prefix:"",URI:null},a]),jp=(0,R.then)(ep,(0,R.preceded)(Bl,ep),(a,b)=>[{prefix:a,URI:null},b]);var kp=(0,R.or)([jp,ip]),lp=(0,R.followed)(T([dm,V,fl],(0,R.map)((0,R.star)(Wk(/[^{}]/)),a=>a.join("").replace(/\s+/g," ").trim())),gl);const mp=(0,R.then)(lp,ep,(a,b)=>[a,b]);var np=(0,R.or)([(0,R.map)(mp,a=>[{prefix:null,URI:a[0]},a[1]]),kp]),op=(0,R.or)([(0,R.map)(np,a=>["QName",...a]),(0,R.map)(Dl,()=>["star"])]),pp=(0,R.map)((0,R.preceded)(Fl,np),a=>["varRef",["name",...a]]);var qp=(0,R.peek)((0,R.or)([bl,ll,jl,ap])),rp=(0,R.map)((0,R.or)([mo,no,oo,po,qo,ro,so]),a=>a.substring(0,a.length-2)),sp=(0,R.map)((0,R.or)([to,uo,vo,wo,xo]),a=>a.substring(0,a.length-2)),tp=Rk(Al,(0,R.or)([Fm,Hm,Jm,Km,Lm]),Cl,(a,b,c)=>a+b+c),up=(0,R.or)([Rk(vl,Wk(/[0-9a-fA-F]+/),Cl,(a,b,c)=>a+b+c),Rk(wl,Wk(/[0-9]+/),Cl,(a,b,c)=>a+b+c)]),vp=Vk([ml],'"'),wp=Vk([kl],"'"),xp=Uk(Vk([Mo],"commentTest")),yp=Uk(Vk([No],"textTest")),zp=Uk(Vk([Oo],"namespaceTest")),Ap=Uk(Vk([Po],"anyKindTest"));
340
- const Bp=Wk(/[0-9]+/),Cp=(0,R.then)((0,R.or)([(0,R.then)(Vl,Bp,(a,b)=>a+b),(0,R.then)(Bp,(0,R.optional)((0,R.preceded)(Vl,Wk(/[0-9]*/))),(a,b)=>a+(null!==b?"."+b:""))]),Rk((0,R.or)([bm,cm]),(0,R.optional)((0,R.or)([Xl,Yl])),Bp,(a,b,c)=>a+(b?b:"")+c),(a,b)=>["doubleConstantExpr",["value",a+b]]),Dp=(0,R.or)([(0,R.map)((0,R.preceded)(Vl,Bp),a=>["decimalConstantExpr",["value","."+a]]),(0,R.then)((0,R.followed)(Bp,Vl),(0,R.optional)(Bp),(a,b)=>["decimalConstantExpr",["value",a+"."+(null!==b?b:"")]])]);
341
- var Ep=(0,R.map)(Bp,a=>["integerConstantExpr",["value",a]]),Fp=(0,R.followed)((0,R.or)([Cp,Dp,Ep]),(0,R.peek)((0,R.not)(Wk(/[a-zA-Z]/),["no alphabetical characters after numeric literal"]))),Gp=(0,R.map)((0,R.followed)(Vl,(0,R.peek)((0,R.not)(Vl,["context item should not be followed by another ."]))),()=>["contextItemExpr"]),Hp=(0,R.or)([bn,rm,fn,go,qm,lo,om,Mm,bo,pm,ho,km,gn,io,sm,On,en,zn]),Ip=Uk(Vk([Il],"argumentPlaceholder")),Jp=(0,R.or)([Il,Dl,Xl]),Kp=(0,R.preceded)((0,R.peek)((0,R.not)(Wk(/[{}<&]/),
342
- ["elementContentChar cannot be {, }, <, or &"])),Yo),Lp=(0,R.map)((0,R.delimited)(nl,(0,R.star)((0,R.preceded)((0,R.peek)((0,R.not)(ol,['CDataSection content may not contain "]]\x3e"'])),Yo)),ol,!0),a=>["CDataSection",a.join("")]),Mp=(0,R.preceded)((0,R.peek)((0,R.not)(Wk(/["{}<&]/),['quotAttrValueContentChar cannot be ", {, }, <, or &'])),Yo),Np=(0,R.preceded)((0,R.peek)((0,R.not)(Wk(/['{}<&]/),["aposAttrValueContentChar cannot be ', {, }, <, or &"])),Yo),Op=(0,R.map)((0,R.star)((0,R.or)([(0,R.preceded)((0,R.peek)((0,R.not)(Yl,
343
- [])),Yo),(0,R.map)(T([Yl,(0,R.peek)((0,R.not)(Yl,[]))],Yo),a=>"-"+a)])),a=>a.join("")),Pp=(0,R.map)((0,R.delimited)(rl,Op,sl,!0),a=>["computedCommentConstructor",["argExpr",["stringConstantExpr",["value",a]]]]);const Qp=(0,R.filter)(ep,a=>"xml"!==a.toLowerCase(),['A processing instruction target cannot be "xml"']),Rp=(0,R.map)((0,R.star)((0,R.preceded)((0,R.peek)((0,R.not)(ul,[])),Yo)),a=>a.join(""));
344
- var Sp=(0,R.then)((0,R.preceded)(tl,(0,R.cut)(Qp)),(0,R.cut)((0,R.followed)((0,R.optional)((0,R.preceded)(bp,Rp)),ul)),(a,b)=>["computedPIConstructor",["piTarget",a],["piValueExpr",["stringConstantExpr",["value",b]]]]),Tp=(0,R.map)($l,()=>["stepExpr",["xpathAxis","descendant-or-self"],["anyKindTest"]]),Up=(0,R.or)([hn,jn]),Vp=(0,R.map)((0,R.star)((0,R.followed)(Yo,(0,R.peek)((0,R.not)(al,["Pragma contents should not contain '#)'"])))),a=>a.join("")),Wp=(0,R.map)((0,R.followed)((0,R.or)([Dm,Em,Fm,
345
- Gm,Hm,Im]),qp),a=>a+"Op"),Xp=(0,R.or)([(0,R.followed)(Vk([xm],"isOp"),qp),Vk([Pl],"nodeBeforeOp"),Vk([Sl],"nodeAfterOp")]),Yp=(0,R.or)([Vk([Jl],"equalOp"),Vk([Nl],"notEqualOp"),Vk([Ql],"lessThanOrEqualOp"),Vk([Ol],"lessThanOp"),Vk([Tl],"greaterThanOrEqualOp"),Vk([Rl],"greaterThanOp")]),Zp=(0,R.map)(Rn,()=>["annotation",["annotationName","updating"]]);const $p=(0,R.or)([qn,rn]),aq=(0,R.or)([sn,tn]);
346
- var bq=(0,R.or)([yo,zo,Ao,Bo,Co,Hl,Do,Eo,Fo,Go,Ho]),cq=(0,R.map)(T([mn,X,on,X],(0,R.or)([qn,pn])),a=>["boundarySpaceDecl",a]),dq=(0,R.map)(T([mn,X,Wn,X],(0,R.or)([qn,pn])),a=>["constructionDecl",a]),eq=(0,R.map)(T([mn,X,Xn,X],(0,R.or)([Yn,Zn])),a=>["orderingModeDecl",a]),fq=(0,R.map)(T([mn,X,nn,X,Zm,X,Qm,X],(0,R.or)([un,vn])),a=>["emptyOrderDecl",a]),gq=(0,R.then)(T([mn,X,wn,X],$p),T([V,Ul,V],aq),(a,b)=>["copyNamespacesDecl",["preserveMode",a],["inheritMode",b]]);function hq(a){switch(a[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 a}return["sequenceExpr",
347
- a]}function iq(a){if(!(1<=a&&55295>=a||57344<=a&&65533>=a||65536<=a&&1114111>=a))throw Error("XQST0090: The character reference "+a+" ("+a.toString(16)+") does not reference a valid codePoint.");}
348
- function jq(a){return a.replace(/(&[^;]+);/g,b=>{if(/^&#x/.test(b))return b=parseInt(b.slice(3,-1),16),iq(b),String.fromCodePoint(b);if(/^&#/.test(b))return b=parseInt(b.slice(2,-1),10),iq(b),String.fromCodePoint(b);switch(b){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: "'+b+'"');})}
349
- function kq(a,b,c){if(!a.length)return[];let d=[a[0]];for(let e=1;e<a.length;++e){const f=d[d.length-1];"string"===typeof f&&"string"===typeof a[e]?d[d.length-1]=f+a[e]:d.push(a[e])}if("string"===typeof d[0]&&0===d.length)return[];d=d.reduce((e,f,h)=>{if("string"!==typeof f)e.push(f);else if(c&&/^\s*$/.test(f)){const k=d[h+1];k&&"CDataSection"===k[0]?e.push(jq(f)):(h=d[h-1])&&"CDataSection"===h[0]&&e.push(jq(f))}else e.push(jq(f));return e},[]);if(!d.length)return d;if(1<d.length||b)for(a=0;a<d.length;a++)"string"===
350
- typeof d[a]&&(d[a]=["stringConstantExpr",["value",d[a]]]);return d}function lq(a){return a[0].prefix?a[0].prefix+":"+a[1]:a[1]};var mq=(0,R.then)(np,(0,R.optional)(Il),(a,b)=>null!==b?["singleType",["atomicType",...a],["optional"]]:["singleType",["atomicType",...a]]),nq=(0,R.map)(np,a=>["atomicType",...a]);const oq=new Map;
351
- function pq(a){function b(m,r){return r.reduce((B,W)=>[W[0],["firstOperand",B],["secondOperand",W[1]]],m)}function c(m,r,B){return(0,R.then)(m,(0,R.star)((0,R.then)(S(r,V),(0,R.cut)(m),(W,ea)=>[W,ea])),B)}function d(m,r,B="firstOperand",W="secondOperand"){return(0,R.then)(m,(0,R.optional)((0,R.then)(S(r,V),(0,R.cut)(m),(ea,Fa)=>[ea,Fa])),(ea,Fa)=>null===Fa?ea:[Fa[0],[B,ea],[W,Fa[1]]])}function e(m){return a.mb?(r,B)=>{r=m(r,B);if(!r.success)return r;const W=n.has(B)?n.get(B):{offset:B,line:-1,ha:-1},
352
- ea=n.has(r.offset)?n.get(r.offset):{offset:r.offset,line:-1,ha:-1};n.set(B,W);n.set(r.offset,ea);B=r.value.Wa;return(0,R.okWithValue)(r.offset,["x:stackTrace",Object.assign({start:W,end:ea},B?{Wa:B}:{}),r.value])}:m}function f(m,r){return Dj(m,r)}function h(m,r){return xf(m,r)}function k(m,r){return e((0,R.or)([Dr,Er,Fr,Gr,Hr,Ir,Jr,Kr,Lr,Mr,Nr]))(m,r)}function l(m,r){return c(k,Ul,(B,W)=>0===W.length?B:["sequenceExpr",B,...W.map(ea=>ea[1])])(m,r)}const n=new Map,t=(0,R.preceded)(dl,(0,R.followed)(S(l,
353
- V),el)),u=(0,R.map)(a.Za?(0,R.or)([S((0,R.star)((0,R.or)([tp,up,vp,Wk(/[^"&]/)])),ll),S((0,R.star)((0,R.or)([tp,up,wp,Wk(/[^'&]/)])),jl)]):(0,R.or)([S((0,R.star)((0,R.or)([vp,Wk(/[^"]/)])),ll),S((0,R.star)((0,R.or)([wp,Wk(/[^']/)])),jl)]),m=>m.join("")),z=(0,R.or)([(0,R.map)(T([qm,V],(0,R.delimited)((0,R.followed)(bl,V),(0,R.then)(op,T([V,Ul,V],np),(m,r)=>[["elementName",m],["typeName",...r]]),(0,R.preceded)(V,cl))),([m,r])=>["elementTest",m,r]),(0,R.map)(T([qm,V],(0,R.delimited)(bl,op,cl)),m=>["elementTest",
354
- ["elementName",m]]),(0,R.map)(T([qm,V],(0,R.delimited)(bl,V,cl)),()=>["elementTest"])]),y=(0,R.or)([(0,R.map)(np,m=>["QName",...m]),(0,R.map)(Dl,()=>["star"])]),G=(0,R.or)([(0,R.map)(T([rm,V],(0,R.delimited)((0,R.followed)(bl,V),(0,R.then)(y,T([V,Ul,V],np),(m,r)=>[["attributeName",m],["typeName",...r]]),(0,R.preceded)(V,cl))),([m,r])=>["attributeTest",m,r]),(0,R.map)(T([rm,V],(0,R.delimited)(bl,y,cl)),m=>["attributeTest",["attributeName",m]]),(0,R.map)(T([rm,V],(0,R.delimited)(bl,V,cl)),()=>["attributeTest"])]),
355
- N=(0,R.map)(T([sm,V,bl],(0,R.followed)(np,cl)),m=>["schemaElementTest",...m]),U=(0,R.map)((0,R.delimited)(Io,S(np,V),cl),m=>["schemaAttributeTest",...m]),ca=(0,R.map)((0,R.preceded)(Jo,(0,R.followed)(S((0,R.optional)((0,R.or)([z,N])),V),cl)),m=>["documentTest",...(m?[m]:[])]),Ga=(0,R.or)([(0,R.map)((0,R.preceded)(Ko,(0,R.followed)(S((0,R.or)([ep,u]),V),cl)),m=>["piTest",["piTarget",m]]),Uk(Vk([Lo],"piTest"))]),Gb=(0,R.or)([ca,z,G,N,U,Ga,xp,yp,zp,Ap]),Xb=(0,R.or)([(0,R.map)((0,R.preceded)(yl,ep),m=>
356
- ["Wildcard",["star"],["NCName",m]]),Uk(Vk([Dl],"Wildcard")),(0,R.map)((0,R.followed)(lp,Dl),m=>["Wildcard",["uri",m],["star"]]),(0,R.map)((0,R.followed)(ep,xl),m=>["Wildcard",["NCName",m],["star"]])]),fd=(0,R.or)([Xb,(0,R.map)(np,m=>["nameTest",...m])]),Yb=(0,R.or)([Gb,fd]),Or=(0,R.then)((0,R.optional)(El),Yb,(m,r)=>null!==m||"attributeTest"===r[0]||"schemaAttributeTest"===r[0]?["stepExpr",["xpathAxis","attribute"],r]:["stepExpr",["xpathAxis","child"],r]),Pr=(0,R.or)([(0,R.then)(rp,Yb,(m,r)=>["stepExpr",
357
- ["xpathAxis",m],r]),Or]),Qr=(0,R.map)(Wl,()=>["stepExpr",["xpathAxis","parent"],["anyKindTest"]]),Rr=(0,R.or)([(0,R.then)(sp,Yb,(m,r)=>["stepExpr",["xpathAxis",m],r]),Qr]),Sr=(0,R.map)((0,R.star)((0,R.preceded)(V,t)),m=>0<m.length?["predicates",...m]:void 0),Tr=(0,R.then)((0,R.or)([Rr,Pr]),Sr,(m,r)=>void 0===r?m:m.concat([r])),yf=(0,R.or)([Fp,(0,R.map)(u,m=>["stringConstantExpr",["value",a.Za?jq(m):m]])]),zf=(0,R.or)([(0,R.delimited)(bl,S(l,V),cl),(0,R.map)((0,R.delimited)(bl,V,cl),()=>["sequenceExpr"])]),
358
- Ej=(0,R.or)([k,Ip]),de=(0,R.map)((0,R.delimited)(bl,S((0,R.optional)((0,R.then)(Ej,(0,R.star)((0,R.preceded)(S(Ul,V),Ej)),(m,r)=>[m,...r])),V),cl),m=>null!==m?m:[]),Ur=(0,R.preceded)((0,R.not)(Rk(Hp,V,bl,()=>{}),["cannot use reserved keyword for function names"]),e((0,R.then)(np,(0,R.preceded)(V,de),(m,r)=>{r=["functionCallExpr",["functionName",...m],null!==r?["arguments",...r]:["arguments"]];const B=m[0].prefix,W=m[0].URI;m=m[1];r.Wa=B?`${B}:${m}`:W?`Q{${W}}${m}`:m;return r}))),Vr=(0,R.then)(np,
359
- (0,R.preceded)(Gl,Ep),(m,r)=>["namedFunctionRef",["functionName",...m],r]),Ua=(0,R.delimited)(fl,S((0,R.optional)(l),V),gl),Fj=(0,R.map)(Ua,m=>m?m:["sequenceExpr"]),jb=(0,R.or)([(0,R.map)(Ro,()=>[["voidSequenceType"]]),(0,R.then)(f,(0,R.optional)((0,R.preceded)(V,Jp)),(m,r)=>[m,...(null!==r?[["occurrenceIndicator",r]]:[])])]),Af=(0,R.then)(T([Hl,V],np),(0,R.optional)((0,R.followed)((0,R.then)(T([bl,V],yf),(0,R.star)(T([Ul,V],yf)),(m,r)=>m.concat(r)),cl)),(m,r)=>["annotation",["annotationName",...m],
360
- ...(r?["arguments",r]:[])]),Wr=(0,R.map)(T([om,V,bl,V,Dl,V],cl),()=>["anyFunctionTest"]),Xr=(0,R.then)(T([om,V,bl,V],(0,R.optional)(c(jb,Ul,(m,r)=>m.concat.apply(m,r.map(B=>B[1]))))),T([V,cl,X,em,X],jb),(m,r)=>["typedFunctionTest",["paramTypeList",["sequenceType",...(m?m:[])]],["sequenceType",...r]]),Yr=(0,R.then)((0,R.star)(Af),(0,R.or)([Wr,Xr]),(m,r)=>[r[0],...m,...r.slice(1)]),Zr=(0,R.map)(T([pm,V,bl,V,Dl,V],cl),()=>["anyMapTest"]),$r=(0,R.then)(T([pm,V,bl,V],nq),T([V,Ul],(0,R.followed)(S(jb,V),
361
- cl)),(m,r)=>["typedMapTest",m,["sequenceType",...r]]),as=(0,R.or)([Zr,$r]),bs=(0,R.map)(T([bn,V,bl,V,Dl,V],cl),()=>["anyArrayTest"]),cs=(0,R.map)(T([bn,V,bl],(0,R.followed)(S(jb,V),cl)),m=>["typedArrayTest",["sequenceType",...m]]),ds=(0,R.or)([bs,cs]),es=(0,R.map)((0,R.delimited)(bl,S(f,V),cl),m=>["parenthesizedItemType",m]),Dj=(0,R.or)([Gb,Uk(Vk([Qo],"anyItemType")),Yr,as,ds,nq,es]),Ac=(0,R.map)(T([em,X],jb),m=>["typeDeclaration",...m]),fs=(0,R.then)((0,R.preceded)(Fl,np),(0,R.optional)((0,R.preceded)(X,
362
- Ac)),(m,r)=>["param",["varName",...m],...(r?[r]:[])]),Gj=c(fs,Ul,(m,r)=>[m,...r.map(B=>B[1])]),gs=Sk((0,R.star)(Af),T([V,om,V,bl,V],(0,R.optional)(Gj)),T([V,cl,V],(0,R.optional)((0,R.map)(T([em,V],(0,R.followed)(jb,V)),m=>["typeDeclaration",...m]))),Fj,(m,r,B,W)=>["inlineFunctionExpr",...m,["paramList",...(r?r:[])],...(B?[B]:[]),["functionBody",W]]),hs=(0,R.or)([Vr,gs]),is=(0,R.map)(k,m=>["mapKeyExpr",m]),js=(0,R.map)(k,m=>["mapValueExpr",m]),ks=(0,R.then)(is,(0,R.preceded)(S(Bl,V),js),(m,r)=>["mapConstructorEntry",
363
- m,r]),ls=(0,R.preceded)(pm,(0,R.delimited)(S(fl,V),(0,R.map)((0,R.optional)(c(ks,S(Ul,V),(m,r)=>[m,...r.map(B=>B[1])])),m=>m?["mapConstructor",...m]:["mapConstructor"]),(0,R.preceded)(V,gl))),ms=(0,R.map)((0,R.delimited)(dl,S((0,R.optional)(c(k,Ul,(m,r)=>[m,...r.map(B=>B[1])].map(B=>["arrayElem",B]))),V),el),m=>["squareArray",...(null!==m?m:[])]),ns=(0,R.map)((0,R.preceded)(bn,(0,R.preceded)(V,Ua)),m=>["curlyArray",...(null!==m?[["arrayElem",m]]:[])]),os=(0,R.map)((0,R.or)([ms,ns]),m=>["arrayConstructor",
364
- m]),Hj=(0,R.map)((0,R.star)((0,R.preceded)((0,R.peek)((0,R.not)((0,R.or)([Uo,Vo,To]),["String constructors can not contain interpolation characters"])),Yo)),m=>["stringConstructorChars",m.join("")]),ps=(0,R.map)((0,R.delimited)(Uo,l,Vo,!0),m=>["stringConstructorInterpolation",m]),qs=(0,R.then)(Hj,(0,R.star)((0,R.then)(ps,Hj,(m,r)=>[m,r])),(m,r)=>{m=[m];for(const [B,W]of r)m.push(B,W);return m}),rs=(0,R.map)((0,R.delimited)(So,qs,To,!0),m=>["stringConstructor",...m]),Ij=(0,R.or)([ep,Ep,zf,Dl]),ss=
365
- (0,R.map)((0,R.preceded)(Il,(0,R.preceded)(V,Ij)),m=>"*"===m?["unaryLookup",["star"]]:"string"===typeof m?["unaryLookup",["NCName",m]]:["unaryLookup",m]),Bf=(0,R.or)([tp,up,Vk([hl],"{"),Vk([il],"}"),(0,R.map)(Ua,m=>m||["sequenceExpr"])]),ts=(0,R.or)([Lp,function(m,r){return Jj(m,r)},Bf,Kp]),us=(0,R.or)([(0,R.map)(Mp,m=>m.replace(/[\x20\x0D\x0A\x09]/g," ")),Bf]),vs=(0,R.or)([(0,R.map)(Np,m=>m.replace(/[\x20\x0D\x0A\x09]/g," ")),Bf]),ws=(0,R.map)((0,R.or)([S((0,R.star)((0,R.or)([vp,us])),ll),S((0,R.star)((0,R.or)([wp,
366
- vs])),jl)]),m=>kq(m,!1,!1)),xs=(0,R.then)(kp,(0,R.preceded)(S(Jl,(0,R.optional)(bp)),ws),(m,r)=>{if(""===m[0].prefix&&"xmlns"===m[1]){if(r.length&&"string"!==typeof r[0])throw Error("XQST0022: A namespace declaration may not contain enclosed expressions");return["namespaceDeclaration",r.length?["uri",r[0]]:["uri"]]}if("xmlns"===m[0].prefix){if(r.length&&"string"!==typeof r[0])throw Error("XQST0022: The namespace declaration for 'xmlns:"+m[1]+"' may not contain enclosed expressions");return["namespaceDeclaration",
367
- ["prefix",m[1]],r.length?["uri",r[0]]:["uri"]]}return["attributeConstructor",["attributeName"].concat(m),0===r.length?["attributeValue"]:1===r.length&&"string"===typeof r[0]?["attributeValue",r[0]]:["attributeValueExpr"].concat(r)]}),ys=(0,R.map)((0,R.star)((0,R.preceded)(bp,(0,R.optional)(xs))),m=>m.filter(Boolean)),zs=Rk((0,R.preceded)(Ol,kp),ys,(0,R.or)([(0,R.map)(pl,()=>null),(0,R.then)((0,R.preceded)(Rl,(0,R.star)(ts)),T([V,ql],(0,R.followed)(kp,(0,R.then)((0,R.optional)(bp),Rl,()=>null))),(m,
368
- r)=>[kq(m,!0,!0),r])]),(m,r,B)=>{var W=B;if(B&&B.length){W=lq(m);const ea=lq(B[1]);if(W!==ea)throw Error('XQST0118: The start and the end tag of an element constructor must be equal. "'+W+'" does not match "'+ea+'"');W=B[0]}return["elementConstructor",["tagName",...m],...(r.length?[["attributeList",...r]]:[]),...(W&&W.length?[["elementContent",...W]]:[])]}),Jj=(0,R.or)([zs,Pp,Sp]),As=(0,R.map)(T([cn,V],Ua),m=>["computedDocumentConstructor",...(m?[["argExpr",m]]:[])]),Bs=(0,R.map)(Ua,m=>m?[["contentExpr",
369
- m]]:[]),Cs=(0,R.then)(T([qm,V],(0,R.or)([(0,R.map)(np,m=>["tagName",...m]),(0,R.map)((0,R.delimited)(fl,S(l,V),gl),m=>["tagNameExpr",m])])),(0,R.preceded)(V,Bs),(m,r)=>["computedElementConstructor",m,...r]),Ds=(0,R.then)((0,R.preceded)(rm,(0,R.or)([(0,R.map)(T([qp,V],np),m=>["tagName",...m]),(0,R.map)((0,R.preceded)(V,(0,R.delimited)(fl,S(l,V),gl)),m=>["tagNameExpr",m])])),(0,R.preceded)(V,Ua),(m,r)=>["computedAttributeConstructor",m,["valueExpr",r?r:["sequenceExpr"]]]),Es=(0,R.map)(Ua,m=>m?[["prefixExpr",
370
- m]]:[]),Fs=(0,R.map)(Ua,m=>m?[["URIExpr",m]]:[]),Gs=(0,R.then)(T([dn,V],(0,R.or)([fp,Es])),(0,R.preceded)(V,Fs),(m,r)=>["computedNamespaceConstructor",...m,...r]),Hs=(0,R.map)(T([en,V],Ua),m=>["computedTextConstructor",...(m?[["argExpr",m]]:[])]),Is=(0,R.map)(T([fn,V],Ua),m=>["computedCommentConstructor",...(m?[["argExpr",m]]:[])]),Js=T([gn,V],(0,R.then)((0,R.or)([(0,R.map)(ep,m=>["piTarget",m]),(0,R.map)((0,R.delimited)(fl,S(l,V),gl),m=>["piTargetExpr",m])]),(0,R.preceded)(V,Ua),(m,r)=>["computedPIConstructor",
371
- m,...(r?[["piValueExpr",r]]:[])])),Ks=(0,R.or)([As,Cs,Ds,Gs,Hs,Is,Js]),Ls=(0,R.or)([Jj,Ks]),Kj=(0,R.or)([yf,pp,zf,Gp,Ur,Ls,hs,ls,os,rs,ss]),Lj=(0,R.map)(T([Il,V],Ij),m=>"*"===m?["lookup",["star"]]:"string"===typeof m?["lookup",["NCName",m]]:["lookup",m]),Ms=(0,R.then)((0,R.map)(Kj,m=>hq(m)),(0,R.star)((0,R.or)([(0,R.map)((0,R.preceded)(V,t),m=>["predicate",m]),(0,R.map)((0,R.preceded)(V,de),m=>["argumentList",m]),(0,R.preceded)(V,Lj)])),(m,r)=>{function B(){Mj&&1===Fa.length?Bc.push(["predicate",
372
- Fa[0]]):0!==Fa.length&&Bc.push(["predicates",...Fa]);Fa.length=0}function W(Zb){B();0!==Bc.length?("sequenceExpr"===ea[0][0]&&2<ea[0].length&&(ea=[["sequenceExpr",...ea]]),ea=[["filterExpr",...ea],...Bc],Bc.length=0):Zb&&(ea=[["filterExpr",...ea]])}let ea=[m];const Fa=[],Bc=[];let Mj=!1;for(const Zb of r)switch(Zb[0]){case "predicate":Fa.push(Zb[1]);break;case "lookup":Mj=!0;B();Bc.push(Zb);break;case "argumentList":W(!1);1<ea.length&&(ea=[["sequenceExpr",["pathExpr",["stepExpr",...ea]]]]);ea=[["dynamicFunctionInvocationExpr",
373
- ["functionItem",...ea],...(Zb[1].length?[["arguments",...Zb[1]]]:[])]];break;default:throw Error("unreachable");}W(!0);return ea}),Cc=(0,R.or)([(0,R.map)(Ms,m=>["stepExpr",...m]),Tr]),Ns=(0,R.followed)(Kj,(0,R.peek)((0,R.not)((0,R.preceded)(V,(0,R.or)([t,de,Lj])),["primary expression not followed by predicate, argumentList, or lookup"]))),Os=(0,R.or)([Rk(Cc,(0,R.preceded)(V,Tp),(0,R.preceded)(V,h),(m,r,B)=>["pathExpr",m,r,...B]),(0,R.then)(Cc,(0,R.preceded)(S(Zl,V),h),(m,r)=>["pathExpr",m,...r]),
374
- Ns,(0,R.map)(Cc,m=>["pathExpr",m])]),xf=(0,R.or)([Rk(Cc,(0,R.preceded)(V,Tp),(0,R.preceded)(V,h),(m,r,B)=>[m,r,...B]),(0,R.then)(Cc,(0,R.preceded)(S(Zl,V),h),(m,r)=>[m,...r]),(0,R.map)(Cc,m=>[m])]),Ps=(0,R.or)([(0,R.map)(T([Zl,V],xf),m=>["pathExpr",["rootExpr"],...m]),(0,R.then)(Tp,(0,R.preceded)(V,xf),(m,r)=>["pathExpr",["rootExpr"],m,...r]),(0,R.map)((0,R.followed)(Zl,(0,R.not)((0,R.preceded)(V,a.Za?Wk(/[*<a-zA-Z]/):Wk(/[*a-zA-Z]/)),["Single rootExpr cannot be by followed by something that can be interpreted as a relative path"])),
375
- ()=>["pathExpr",["rootExpr"]])]),Qs=Qk((0,R.or)([Os,Ps]),oq),Rs=(0,R.preceded)(kn,(0,R.then)((0,R.optional)((0,R.or)([(0,R.map)((0,R.preceded)(V,Up),m=>["validationMode",m]),(0,R.map)(T([V,ln,V],np),m=>["type",...m])])),(0,R.delimited)((0,R.preceded)(V,fl),S(l,V),gl),(m,r)=>["validateExpr",...(m?[m]:[]),["argExpr",r]])),Ss=(0,R.delimited)($k,(0,R.then)((0,R.preceded)(V,np),(0,R.optional)((0,R.preceded)(X,Vp)),(m,r)=>r?["pragma",["pragmaName",m],["pragmaContents",r]]:["pragma",["pragmaName",m]]),(0,R.preceded)(V,
376
- al)),Ts=(0,R.map)((0,R.followed)((0,R.plus)(Ss),(0,R.preceded)(V,(0,R.delimited)(fl,S((0,R.optional)(l),V),gl))),m=>["extensionExpr",...m]),Us=e(c(Qs,Kl,(m,r)=>0===r.length?m:["simpleMapExpr","pathExpr"===m[0]?m:["pathExpr",["stepExpr",["filterExpr",hq(m)]]]].concat(r.map(B=>{B=B[1];return"pathExpr"===B[0]?B:["pathExpr",["stepExpr",["filterExpr",hq(B)]]]})))),Vs=(0,R.or)([Rs,Ts,Us]),Nj=(0,R.or)([(0,R.then)((0,R.or)([Vk([Yl],"unaryMinusOp"),Vk([Xl],"unaryPlusOp")]),(0,R.preceded)(V,function(m,r){return Nj(m,
377
- r)}),(m,r)=>[m,["operand",r]]),Vs]),Ws=(0,R.or)([(0,R.map)(np,m=>["EQName",...m]),pp,zf]),Xs=(0,R.then)(Nj,(0,R.star)(T([V,am,V],(0,R.then)(Ws,(0,R.preceded)(V,de),(m,r)=>[m,r]))),(m,r)=>r.reduce((B,W)=>["arrowExpr",["argExpr",B],W[0],["arguments",...W[1]]],m)),Ys=(0,R.then)(Xs,(0,R.optional)(T([V,fm,X,em,qp,V],mq)),(m,r)=>null!==r?["castExpr",["argExpr",m],r]:m),Zs=(0,R.then)(Ys,(0,R.optional)(T([V,gm,X,em,qp,V],mq)),(m,r)=>null!==r?["castableExpr",["argExpr",m],r]:m),$s=(0,R.then)(Zs,(0,R.optional)(T([V,
378
- hm,X,em,qp,V],jb)),(m,r)=>null!==r?["treatExpr",["argExpr",m],["sequenceType",...r]]:m),at=(0,R.then)($s,(0,R.optional)(T([V,im,X,jm,qp,V],jb)),(m,r)=>null!==r?["instanceOfExpr",["argExpr",m],["sequenceType",...r]]:m),bt=c(at,(0,R.followed)((0,R.or)([Vk([tm],"intersectOp"),Vk([um],"exceptOp")]),qp),b),ct=c(bt,(0,R.or)([Vk([Ll],"unionOp"),(0,R.followed)(Vk([vm],"unionOp"),qp)]),b),dt=c(ct,(0,R.or)([Vk([Dl],"multiplyOp"),(0,R.followed)(Vk([Am],"divOp"),qp),(0,R.followed)(Vk([Bm],"idivOp"),qp),(0,R.followed)(Vk([Cm],
379
- "modOp"),qp)]),b),et=c(dt,(0,R.or)([Vk([Yl],"subtractOp"),Vk([Xl],"addOp")]),b),ft=d(et,(0,R.followed)(Vk([wm],"rangeSequenceExpr"),qp),"startExpr","endExpr"),gt=c(ft,Vk([Ml],"stringConcatenateOp"),b),ht=d(gt,(0,R.or)([Wp,Xp,Yp])),it=c(ht,(0,R.followed)(Vk([zm],"andOp"),qp),b),Nr=c(it,(0,R.followed)(Vk([ym],"orOp"),qp),b),jt=e((0,R.map)(l,m=>["ifClause",m])),kt=e((0,R.map)(k,m=>["thenClause",m])),lt=e((0,R.map)(k,m=>["elseClause",m])),Hr=(0,R.then)((0,R.then)(T([Mm,V,bl,V],jt),T([V,cl,V,Nm,qp,V],
380
- kt),(m,r)=>[m,r]),T([V,Om,qp,V],lt),(m,r)=>["ifThenElseExpr",m[0],m[1],r]),mt=(0,R.delimited)(Pm,X,Qm),nt=(0,R.map)(T([Rm,X,Fl],np),m=>["positionalVariableBinding",...m]),ot=Tk((0,R.preceded)(Fl,(0,R.cut)(np)),(0,R.cut)((0,R.preceded)(V,(0,R.optional)(Ac))),(0,R.cut)((0,R.preceded)(V,(0,R.optional)(mt))),(0,R.cut)((0,R.preceded)(V,(0,R.optional)(nt))),(0,R.cut)((0,R.preceded)(S(Sm,V),k)),(m,r,B,W,ea)=>["forClauseItem",["typedVariableBinding",["varName",...m,...(r?[r]:[])]],...(B?[["allowingEmpty"]]:
381
- []),...(W?[W]:[]),["forExpr",ea]]),pt=T([Tm,X],c(ot,Ul,(m,r)=>["forClause",m,...r.map(B=>B[1])])),qt=Rk((0,R.preceded)(Fl,np),(0,R.preceded)(V,(0,R.optional)(Ac)),(0,R.preceded)(S(zl,V),k),(m,r,B)=>["letClauseItem",["typedVariableBinding",["varName",...m],...(r?[r]:[])],["letExpr",B]]),rt=(0,R.map)(T([Um,V],c(qt,Ul,(m,r)=>[m,...r.map(B=>B[1])])),m=>["letClause",...m]),Oj=(0,R.or)([pt,rt]),st=(0,R.map)(T([Vm,qp,V],k),m=>["whereClause",m]),tt=(0,R.map)((0,R.preceded)(Fl,np),m=>["varName",...m]),ut=
382
- (0,R.then)((0,R.preceded)(V,(0,R.optional)(Ac)),(0,R.preceded)(S(zl,V),k),(m,r)=>["groupVarInitialize",...(m?[["typeDeclaration",...m]]:[]),["varValue",r]]),vt=Rk(tt,(0,R.optional)(ut),(0,R.optional)((0,R.map)((0,R.preceded)(S(Wm,V),u),m=>["collation",m])),(m,r,B)=>["groupingSpec",m,...(r?[r]:[]),...(B?[B]:[])]),wt=c(vt,Ul,(m,r)=>[m,...r.map(B=>B[1])]),xt=(0,R.map)(T([Xm,X,Ym,V],wt),m=>["groupByClause",...m]),yt=Rk((0,R.optional)((0,R.or)([jo,ko])),(0,R.optional)(T([V,Qm,V],(0,R.or)([un,vn].map(m=>
383
- (0,R.map)(m,r=>"empty "+r))))),(0,R.preceded)(V,(0,R.optional)(T([Wm,V],u))),(m,r,B)=>m||r||B?["orderModifier",...(m?[["orderingKind",m]]:[]),...(r?[["emptyOrderingMode",r]]:[]),...(B?[["collation",B]]:[])]:null),zt=(0,R.then)(k,(0,R.preceded)(V,yt),(m,r)=>["orderBySpec",["orderByExpr",m],...(r?[r]:[])]),At=c(zt,Ul,(m,r)=>[m,...r.map(B=>B[1])]),Bt=(0,R.then)((0,R.or)([(0,R.map)(T([Zm,X],Ym),()=>!1),(0,R.map)(T([$m,X,Zm,X],Ym),()=>!0)]),(0,R.preceded)(V,At),(m,r)=>["orderByClause",...(m?[["stable"]]:
384
- []),...r]),Ct=(0,R.or)([Oj,st,xt,Bt]),Dt=(0,R.map)(T([an,V],k),m=>["returnClause",m]),Dr=Rk(Oj,(0,R.cut)((0,R.star)((0,R.preceded)(V,Ct))),(0,R.cut)((0,R.preceded)(V,Dt)),(m,r,B)=>["flworExpr",m,...r,B]),Et=c(jb,Ll,(m,r)=>0===r.length?["sequenceType",...m]:["sequenceTypeUnion",["sequenceType",...m],...r.map(B=>["sequenceType",...B[1]])]),Ft=Rk(T([yn,V],(0,R.optional)((0,R.preceded)(Fl,(0,R.followed)((0,R.followed)(np,X),em)))),(0,R.preceded)(V,Et),T([X,an,X],k),(m,r,B)=>["typeswitchExprCaseClause"].concat(m?
385
- [["variableBinding",...m]]:[],[r],[["resultExpr",B]])),Gr=Sk((0,R.preceded)(zn,S((0,R.delimited)(bl,S(l,V),cl),V)),(0,R.plus)((0,R.followed)(Ft,V)),T([nn,X],(0,R.optional)((0,R.preceded)(Fl,(0,R.followed)(np,X)))),T([an,X],k),(m,r,B,W)=>["typeswitchExpr",["argExpr",m],...r,["typeswitchExprDefaultClause",...(B||[]),["resultExpr",W]]]),Gt=Rk((0,R.preceded)(Fl,np),(0,R.optional)((0,R.preceded)(X,Ac)),(0,R.preceded)(S(Sm,X),k),(m,r,B)=>["quantifiedExprInClause",["typedVariableBinding",["varName",...m],
386
- ...(r?[r]:[])],["sourceExpr",B]]),Ht=c(Gt,Ul,(m,r)=>[m,...r.map(B=>B[1])]),Er=Rk((0,R.or)([An,Bn]),(0,R.preceded)(X,Ht),(0,R.preceded)(S(Cn,V),k),(m,r,B)=>["quantifiedExpr",["quantifier",m],...r,["predicateExpr",B]]),Jr=(0,R.map)(T([mm,X,(0,R.or)([lm,km]),X],k),m=>["deleteExpr",["targetExpr",m]]),Lr=Rk(T([Dn,X],(0,R.optional)(T([nm,X,jm],X))),T([km,X],k),(0,R.preceded)(S(En,X),k),(m,r,B)=>m?["replaceExpr",["replaceValue"],["targetExpr",r],["replacementExpr",B]]:["replaceExpr",["targetExpr",r],["replacementExpr",
387
- B]]),It=(0,R.then)(pp,(0,R.preceded)(S(zl,V),k),(m,r)=>["transformCopy",m,["copySource",r]]),Mr=Rk(T([Fn,X],c(It,Ul,(m,r)=>[m,...r.map(B=>B[1])])),T([V,Gn,X],k),(0,R.preceded)(S(an,X),k),(m,r,B)=>["transformExpr",["transformCopies",...m],["modifyExpr",r],["returnExpr",B]]),Jt=(0,R.or)([(0,R.followed)((0,R.map)((0,R.optional)((0,R.followed)(T([em,X],(0,R.or)([(0,R.map)(Hn,()=>["insertAsFirst"]),(0,R.map)(In,()=>["insertAsLast"])])),X)),m=>m?["insertInto",m]:["insertInto"]),Ln),(0,R.map)(Kn,()=>["insertAfter"]),
388
- (0,R.map)(Jn,()=>["insertBefore"])]),Ir=Rk(T([Mn,X,(0,R.or)([lm,km]),X],k),(0,R.preceded)(X,Jt),(0,R.preceded)(X,k),(m,r,B)=>["insertExpr",["sourceExpr",m],r,["targetExpr",B]]),Kr=(0,R.then)(T([Nn,X,km,V],k),T([X,em,X],k),(m,r)=>["renameExpr",["targetExpr",m],["newNameExpr",r]]),Kt=(0,R.then)((0,R.plus)((0,R.then)((0,R.map)(T([yn,X],(0,R.cut)(k)),m=>["switchCaseExpr",m]),(0,R.cut)(X),m=>m)),(0,R.cut)(T([an,X],(0,R.cut)(k))),(m,r)=>["switchExprCaseClause",...m,["resultExpr",r]]),Fr=Rk(T([On,V,bl],
389
- (0,R.cut)(l)),(0,R.cut)(T([V,cl,(0,R.cut)(V)],(0,R.plus)((0,R.followed)(Kt,V)))),(0,R.cut)(T([nn,X,an,X],k)),(m,r,B)=>["switchExpr",["argExpr",m],...r,["switchExprDefaultClause",["resultExpr",B]]]),Lt=(0,R.map)(l,m=>["queryBody",m]),Mt=T([mn,X,dn,X],(0,R.cut)((0,R.then)(ep,(0,R.preceded)(S(Jl,V),u),(m,r)=>["namespaceDecl",["prefix",m],["uri",r]]))),Nt=(0,R.then)(T([Pn,X,Fl,V],(0,R.then)(np,(0,R.optional)((0,R.preceded)(V,Ac)),(m,r)=>[m,r])),(0,R.cut)((0,R.or)([(0,R.map)(T([V,zl,V],k),m=>["varValue",
390
- m]),(0,R.map)(T([X,Qn],(0,R.optional)(T([V,zl,V],k))),m=>["external",...(m?[["varValue",m]]:[])])])),([m,r],B)=>["varDecl",["varName",...m],...(null!==r?[r]:[]),B]),Ot=Sk(T([om,X,(0,R.cut)((0,R.peek)((0,R.not)((0,R.followed)(Hp,(0,R.not)(Bl,[""])),["Cannot use reserved function name"])))],np),(0,R.cut)(T([V,bl,V],(0,R.optional)(Gj))),(0,R.cut)(T([V,cl],(0,R.optional)(T([X,em,X],jb)))),(0,R.cut)((0,R.preceded)(V,(0,R.or)([(0,R.map)(Fj,m=>["functionBody",m]),(0,R.map)(Qn,()=>["externalDefinition"])]))),
391
- (m,r,B,W)=>["functionDecl",["functionName",...m],["paramList",...(r||[])],...(B?[["typeDeclaration",...B]]:[]),W]),Pt=T([mn,X],(0,R.then)((0,R.star)((0,R.followed)((0,R.or)([Af,Zp]),X)),(0,R.or)([Nt,Ot]),(m,r)=>[r[0],...m,...r.slice(1)])),Qt=(0,R.then)(T([mn,X,nn,X],(0,R.or)([qm,om])),T([X,dn,X],u),(m,r)=>["defaultNamespaceDecl",["defaultNamespaceCategory",m],["uri",r]]),Rt=(0,R.or)([(0,R.map)((0,R.followed)(T([dn,X],ep),(0,R.preceded)(V,Jl)),m=>["namespacePrefix",m]),(0,R.map)(T([nn,X,qm,X],dn),
392
- ()=>["defaultElementNamespace"])]),St=T([Sn,X,Tn],Rk((0,R.optional)((0,R.preceded)(X,Rt)),(0,R.preceded)(V,u),(0,R.optional)((0,R.then)(T([X,Rm,X],u),(0,R.star)(T([V,Ul,V],u)),(m,r)=>[m,...r])),(m,r,B)=>["schemaImport",...(m?[m]:[]),["targetNamespace",r],...(B?[B]:[])])),Tt=T([Sn,X,Un],Rk((0,R.optional)((0,R.followed)(T([X,dn,X],ep),(0,R.preceded)(V,Jl))),(0,R.preceded)(V,u),(0,R.optional)((0,R.then)(T([X,Rm,X],u),(0,R.star)(T([V,Ul,V],u)),(m,r)=>[m,...r])),(m,r)=>["moduleImport",["namespacePrefix",
393
- m],["targetNamespace",r]])),Ut=(0,R.or)([St,Tt]),Vt=(0,R.map)(T([mn,X,nn,X,Wm,X],u),m=>["defaultCollationDecl",m]),Wt=(0,R.map)(T([mn,X,Vn,X],u),m=>["baseUriDecl",m]),Xt=(0,R.then)(T([mn,X],(0,R.or)([(0,R.map)(T([xn,X],np),m=>["decimalFormatName",...m]),(0,R.map)(T([nn,X],xn),()=>null)])),(0,R.star)((0,R.then)((0,R.preceded)(X,bq),(0,R.preceded)(S(Jl,X),u),(m,r)=>["decimalFormatParam",["decimalFormatParamName",m],["decimalFormatParamValue",r]])),(m,r)=>["decimalFormatDecl",...(m?[m]:[]),...r]),Yt=
394
- (0,R.or)([cq,Vt,Wt,dq,eq,fq,gq,Xt]),Zt=(0,R.then)(T([mn,X,$n,X],np),(0,R.preceded)(X,u),(m,r)=>["optionDecl",["optionName",m],["optionContents",r]]),$t=(0,R.then)(T([mn,X,ao,X,bo],(0,R.optional)(T([X,em],Dj))),(0,R.or)([(0,R.map)((0,R.preceded)(S(zl,V),k),m=>["varValue",m]),(0,R.map)(T([X,Qn],(0,R.optional)((0,R.preceded)(S(zl,V),k))),()=>["external"])]),(m,r)=>["contextItemDecl",...(m?[["contextItemType",m]]:[]),r]),Pj=(0,R.then)((0,R.star)((0,R.followed)((0,R.or)([Qt,Yt,Mt,Ut]),(0,R.cut)(S(Cl,V)))),
395
- (0,R.star)((0,R.followed)((0,R.or)([$t,Pt,Zt]),(0,R.cut)(S(Cl,V)))),(m,r)=>0===m.length&&0===r.length?null:["prolog",...m,...r]),au=T([Un,X,dn,X],(0,R.then)((0,R.followed)(ep,S(Jl,V)),(0,R.followed)(u,S(Cl,V)),(m,r)=>["moduleDecl",["prefix",m],["uri",r]])),bu=(0,R.then)(au,(0,R.preceded)(V,Pj),(m,r)=>["libraryModule",m,...(r?[r]:[])]),cu=(0,R.then)(Pj,(0,R.preceded)(V,Lt),(m,r)=>["mainModule",...(m?[m]:[]),r]),du=(0,R.map)(T([co,V],(0,R.followed)((0,R.or)([(0,R.then)((0,R.preceded)(fo,X),u,m=>["encoding",
396
- m]),(0,R.then)(T([eo,X],u),(0,R.optional)(T([X,fo,X],u)),(m,r)=>[["version",m],...(r?[["encoding",r]]:[])])]),(0,R.preceded)(V,Cl))),m=>["versionDecl",...m]),eu=(0,R.then)((0,R.optional)(S(du,V)),(0,R.or)([bu,cu]),(m,r)=>["module",...(m?[m]:[]),r]),fu=(0,R.complete)(S(eu,V));return(m,r)=>{n.clear();r=fu(m,r);let B=1,W=1;for(let ea=0;ea<m.length+1;ea++){if(n.has(ea)){const Fa=n.get(ea);Fa.line=W;Fa.ha=B}"\n"===m[ea]?(W++,B=1):B++}return r}}
397
- const qq=pq({mb:!1,Za:!1}),rq=pq({mb:!0,Za:!1}),sq=pq({mb:!1,Za:!0}),tq=pq({mb:!0,Za:!0});function uq(a,b){var c=!!b.Z;b=!!b.debug;Wo.clear();Xo.clear();oq.clear();c=c?b?tq(a,0):sq(a,0):b?rq(a,0):qq(a,0);if(!0===c.success)return c.value;a=a.substring(0,c.offset).split("\n");b=a[a.length-1].length+1;throw new Qh({start:{offset:c.offset,line:a.length,ha:b},end:{offset:c.offset+1,line:a.length,ha:b+1}},"","",Error(`XPST0003: Failed to parse script. Expected ${[...(new Set(c.expected))]}`));};const vq="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(" ");
398
- function wq(a,b,c,d,e){var f=F(a,"functionName"),h=I(f,"prefix")||"";let k=I(f,"URI");const l=H(f);if(null===k&&(k=""===h?null===b.v?"http://www.w3.org/2005/xpath-functions":b.v:b.$(h),!k&&h))throw yg(h);if(vq.includes(k))throw sg();h=K(a,"annotation").map(y=>F(y,"annotationName"));f=h.every(y=>!I(y,"URI")&&"private"!==H(y));h=h.some(y=>!I(y,"URI")&&"updating"===H(y));if(!k)throw ug();const n=Kg(a),t=K(F(a,"paramList"),"param"),u=t.map(y=>F(y,"varName")),z=t.map(y=>Kg(y));if(a=F(a,"functionBody")){if(b.va(k,
399
- l,z.length))throw tg(k,l);if(!e)return;const y=Fk(a[1],{sa:!1,Z:!0}),G=new Bg(b),N=u.map(U=>{let ca=I(U,"URI");const Ga=I(U,"prefix");U=H(U);Ga&&null===ca&&(ca=b.$(Ga||""));return Gg(G,ca,U)});e=h?{j:z,arity:u.length,callFunction:(U,ca,Ga,...Gb)=>{U=hc(bc(U,-1,null,w.empty()),N.reduce((Xb,fd,Yb)=>{Xb[fd]=Ra(Gb[Yb]);return Xb},Object.create(null)));return y.s(U,ca)},wb:!1,I:!0,cb:f,localName:l,namespaceURI:k,i:n}:{j:z,arity:u.length,callFunction:(U,ca,Ga,...Gb)=>{U=hc(bc(U,-1,null,w.empty()),N.reduce((Xb,
400
- fd,Yb)=>{Xb[fd]=Ra(Gb[Yb]);return Xb},Object.create(null)));return C(y,U,ca)},wb:!1,I:!1,cb:f,localName:l,namespaceURI:k,i:n};c.push({ba:y,Eb:G});d.push({arity:u.length,ba:y,Ab:e,localName:l,namespaceURI:k,cb:f})}else{if(h)throw Error("Updating external function declarations are not supported");e={j:z,arity:u.length,callFunction:(y,G,N,...U)=>{const ca=N.va(k,l,u.length,!0);if(!ca)throw Error(`XPST0017: Function Q{${k}}${l} with arity of ${u.length} not registered. ${lg(l)}`);if(ca.i.type!==n.type||
401
- ca.j.some((Ga,Gb)=>Ga.type!==z[Gb].type))throw Error("External function declaration types do not match actual function");return ca.callFunction(y,G,N,...U)},wb:!0,I:!1,localName:l,namespaceURI:k,cb:f,i:n}}Eg(b,k,l,u.length,e)}
402
- function xq(a,b,c,d){const e=[],f=[];K(a,"*").forEach(t=>{switch(t[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 h=new Set;K(a,"moduleImport").forEach(t=>{const u=H(F(t,"namespacePrefix"));t=H(F(t,"targetNamespace"));if(h.has(t))throw Error(`XQST0047: The namespace "${t}" is imported more than once.`);
403
- h.add(t);Fg(b,u,t)});K(a,"namespaceDecl").forEach(t=>{const u=H(F(t,"prefix"));t=H(F(t,"uri"));if("xml"===u||"xmlns"===u)throw wg();if("http://www.w3.org/XML/1998/namespace"===t||"http://www.w3.org/2000/xmlns/"===t)throw wg();Fg(b,u,t)});let k=null,l=null;for(const t of K(a,"defaultNamespaceDecl")){const u=H(F(t,"defaultNamespaceCategory")),z=H(F(t,"uri"));if(!z)throw ug();if("http://www.w3.org/XML/1998/namespace"===z||"http://www.w3.org/2000/xmlns/"===z)throw wg();if("function"===u){if(k)throw vg();
404
- k=z}else if("element"===u){if(l)throw vg();l=z}}k&&(b.v=k);l&&Fg(b,"",l);K(a,"functionDecl").forEach(t=>{wq(t,b,e,f,c)});const n=[];K(a,"varDecl").forEach(t=>{const u=Jg(F(t,"varName"));let z=u.namespaceURI;if(null===z&&(z=b.$(u.prefix),!z&&u.prefix))throw yg(u.prefix);if(vq.includes(z))throw sg();var y=F(t,"external");t=F(t,"varValue");let G,N;null!==y?(y=F(y,"varValue"),null!==y&&(G=F(y,"*"))):null!==t&&(G=F(t,"*"));if(n.some(U=>U.namespaceURI===z&&U.localName===u.localName))throw Error(`XQST0049: The variable ${z?
405
- `Q{${z}}`:""}${u.localName} has already been declared.`);Gg(b,z||"",u.localName);if(c&&(G&&(N=Fk(G,{sa:!1,Z:!0})),G&&!Dg(b,z||"",u.localName))){let U=null;Hg(b,z,u.localName,(ca,Ga)=>{if(U)return U();U=Ra(C(N,ca,Ga));return U()});e.push({ba:N,Eb:new Bg(b)});n.push({ba:N,localName:u.localName,namespaceURI:z})}});f.forEach(t=>{if(!t.Ab.I&&t.ba.I)throw Ne(`The function Q{${t.namespaceURI}}${t.localName} is updating but the %updating annotation is missing.`);});return{Ia:f.map(t=>t.Ab),Ta:n,source:d,
406
- pa:t=>{h.forEach(u=>{Nk(b,u)});e.forEach(({ba:u,Eb:z})=>{h.forEach(y=>{Nk(z,y)});t.Ia.forEach(y=>{z.va(y.namespaceURI,y.localName,y.arity,!0)||y.cb&&Eg(z,y.namespaceURI,y.localName,y.arity,y)});t.Ta.forEach(y=>{z.eb(y.namespaceURI,y.localName)||Gg(z,y.namespaceURI,y.localName)});u.v(z)})}}};function yq(a,b,c,d,e,f,h){const k=b.Z?"XQuery":"XPath";c=b.Ha?null:Ik(a,k,c,d,e,b.debug,f,h);return null!==c?{state:c.hc?1:2,ba:c.ba}:{state:0,Zb:"string"===typeof a?uq(a,b):Kk(a)}}function zq(a,b,c,d){const e=F(a,"mainModule");if(!e)throw Error("Can not execute a library module.");const f=F(e,"prolog");if(f){if(!b.Z)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");Ok();d=xq(f,c,!0,d);d.pa(d)}O(a,new qh(c));a=J(e,["queryBody","*"]);return Q(a,b)}
407
- function Aq(a,b,c,d,e,f,h){const k=new pg(c,d,f,h),l=new Bg(k);0<Object.keys(e).length&&Ok();Object.keys(e).forEach(n=>{const t=e[n];Nk(l,t);Fg(l,n,t)});"string"===typeof a&&(a=Pk(a));c=yq(a,b,c,d,e,f,h);switch(c.state){case 2:return{ga:l,ba:c.ba};case 1:return c.ba.v(l),Jk(a,b.Z?"XQuery":"XPath",k,e,c.ba,b.debug,f),{ga:l,ba:c.ba};case 0:return c=zq(c.Zb,b,l,a),c.v(l),b.Ha||Jk(a,b.Z?"XQuery":"XPath",k,e,c,b.debug,f),{ga:l,ba:c}}};function Bq(a){if(v(a.type,1))return a.value;if(v(a.type,54))return a.value.node;throw mc(`Unable to convert selector argument of type ${Da[a.type]} to either an ${Da[1]} or an ${Da[54]} representing an XQueryX program while calling 'fontoxpath:evaluate'`);}
408
- function Cq(a,b,c,d){a=a.first();const e=b.first().h.reduce((f,h)=>{f[h.key.value]=Ra(h.value());return f},Object.create(null));b=e["."]?e["."]():w.empty();delete e["."];a=Bq(a);try{const {ba:f,ga:h}=Aq(a,{sa:!1,Z:!0,debug:d.debug,Ha:d.Ha},n=>c.$(n),Object.keys(e).reduce((n,t)=>{n[t]=t;return n},{}),{},"http://www.w3.org/2005/xpath-functions",(n,t)=>c.Sa(n,t)),k=!b.F(),l=new cc({M:k?b.first():null,Aa:k?0:-1,ta:b,ra:Object.keys(e).reduce((n,t)=>{n[h.eb(null,t)]=e[t];return n},Object.create(null))});
409
- return{ic:f.h(l,d).value,ac:a}}catch(f){gg(a,f)}};function Dq(a,b,c){if(1!==b.node.nodeType&&9!==b.node.nodeType)return[];const d=gb(a,b).reduce((e,f)=>{for(const h of Dq(a,f,c))e.push(h);return e},[]);c(b)&&d.unshift(b);return d}
410
- const Eq=(a,b,c,d,e)=>{a=e.first();if(!a)throw lc("The context is absent, it needs to be present to use id function.");if(!v(a.type,53))throw mc("The context item is not a node, it needs to be node to use id function.");const f=b.h,h=d.O().reduce((k,l)=>{l.value.split(/\s+/).forEach(n=>{k[n]=!0});return k},Object.create(null));for(b=a.value;9!==b.node.nodeType;)if(b=x(f,b),null===b)throw Error("FODC0001: the root node of the target node is not a document node.");b=Dq(f,b,k=>{if(1!==k.node.nodeType)return!1;
411
- k=fb(f,k,"id");if(!k||!h[k])return!1;h[k]=!1;return!0});return w.create(b.map(k=>rb(k)))},Fq=(a,b,c,d,e)=>{a=e.first();if(!a)throw lc("The context is absent, it needs to be present to use idref function.");if(!v(a.type,53))throw mc("The context item is not a node, it needs to be node to use idref function.");const f=b.h,h=d.O().reduce((k,l)=>{k[l.value]=!0;return k},Object.create(null));for(b=a.value;9!==b.node.nodeType;)if(b=x(f,b),null===b)throw Error("FODC0001: the root node of the context node is not a document node.");
412
- b=Dq(f,b,k=>1!==k.node.nodeType?!1:(k=fb(f,k,"idref"))?k.split(/\s+/).some(l=>h[l]):!1);return w.create(b.map(k=>rb(k)))};function Gq(a){switch(typeof a){case "object":return Array.isArray(a)?w.m(new pb(a.map(b=>Ra(Gq(b))))):null===a?w.empty():w.m(new ub(Object.keys(a).map(b=>({key:g(b,1),value:Ra(Gq(a[b]))}))));case "number":return w.m(g(a,3));case "string":return w.m(g(a,1));case "boolean":return a?w.aa():w.T();default:throw Error("Unexpected type in JSON parse");}};const Hq=(a,b,c,d,e)=>{const f=w.m(g("duplicates",1));a=tb(a,b,c,e,f);const h=a.F()?"use-first":a.first().value;return d.N(k=>w.m(new ub(k.reduce((l,n)=>{n.h.forEach(t=>{const u=l.findIndex(z=>sb(z.key,t.key));if(0<=u)switch(h){case "reject":throw Error("FOJS0003: Duplicate encountered when merging maps.");case "use-last":l.splice(u,1,t);return;case "combine":l.splice(u,1,{key:t.key,value:Ra(w.create(l[u].value().O().concat(t.value().O())))});return;default:return}l.push(t)});return l},[]))))};function Iq(a,b,c){let d=1;const e=a.value;a=a.Pa(!0);let f=null;const h=Math.max(b-1,0);-1!==a&&(f=Math.max(0,(null===c?a:Math.max(0,Math.min(a,c+(b-1))))-h));return w.create({next:k=>{for(;d<b;)e.next(k),d++;if(null!==c&&d>=b+c)return p;k=e.next(k);d++;return k}},f)}function Jq(a){return a.map(b=>v(b.type,19)?jd(b,3):b)}function Kq(a){a=Jq(a);if(a.some(b=>Number.isNaN(b.value)))return[g(NaN,3)];a=Ii(a);if(!a)throw Error("FORG0006: Incompatible types to be converted to a common type");return a}
413
- const Lq=(a,b,c,d,e,f)=>A([e,f],([h,k])=>{if(Infinity===h.value)return w.empty();if(-Infinity===h.value)return k&&Infinity===k.value?w.empty():d;if(k){if(isNaN(k.value))return w.empty();Infinity===k.value&&(k=null)}return isNaN(h.value)?w.empty():Iq(d,Math.round(h.value),k?Math.round(k.value):null)}),Mq=(a,b,c,d,e)=>{if(d.F())return e;a=Jq(d.O());a=Ii(a);if(!a)throw Error("FORG0006: Incompatible types to be converted to a common type");if(!a.every(f=>v(f.type,2)))throw Error("FORG0006: items passed to fn:sum are not all numeric.");
414
- b=a.reduce((f,h)=>f+h.value,0);return a.every(f=>v(f.type,5))?w.m(g(b,5)):a.every(f=>v(f.type,3))?w.m(g(b,3)):a.every(f=>v(f.type,4))?w.m(g(b,4)):w.m(g(b,6))};var Nq=[].concat(Mf,[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"boolean",j:[{type:59,g:2}],i:{type:0,g:3},callFunction:(a,b,c,d)=>d.fa()?w.aa():w.T()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"true",j:[],i:{type:0,g:3},callFunction:()=>w.aa()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"not",j:[{type:59,g:2}],i:{type:0,g:3},callFunction:(a,b,c,d)=>!1===d.fa()?w.aa():w.T()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"false",
415
- j:[],i:{type:0,g:3},callFunction:()=>w.T()}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"last",j:[],i:{type:5,g:3},callFunction:a=>{if(null===a.M)throw lc("The fn:last() function depends on dynamic context, which is absent.");let b=!1;return w.create({next:()=>{if(b)return p;const c=a.ta.Pa();b=!0;return q(g(c,5))}},1)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"position",j:[],i:{type:5,g:3},callFunction:a=>{if(null===a.M)throw lc("The fn:position() function depends on dynamic context, which is absent.");
416
- return w.m(g(a.Aa+1,5))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-dateTime",j:[],i:{type:10,g:3},callFunction:a=>w.m(g(ec(a),10))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-date",j:[],i:{type:7,g:3},callFunction:a=>w.m(g(Lb(ec(a),7),7))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-time",j:[],i:{type:8,g:3},callFunction:a=>w.m(g(Lb(ec(a),8),8))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"implicit-timezone",
417
- j:[],i:{type:17,g:3},callFunction:a=>w.m(g(fc(a),17))}],Nf,Vf,bg,[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"years-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.bb(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"months-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.ab(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"days-from-duration",
418
- j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.$a(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"hours-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(a,b,c,d)=>d.F()?d:w.m(g(d.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:(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.getMinutes(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
419
- localName:"seconds-from-duration",j:[{type:18,g:0}],i:{type:4,g:0},callFunction:(a,b,c,d)=>d.F()?d:w.m(g(d.first().value.getSeconds(),4))}],dg,[{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:Eq},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"id",j:[{type:1,g:2}],i:{type:54,g:2},callFunction(a,b,c,d){return Eq(a,b,c,d,w.m(a.M))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"idref",
420
- j:[{type:1,g:2},{type:53,g:3}],i:{type:53,g:2},callFunction:Fq},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"idref",j:[{type:1,g:2}],i:{type:53,g:2},callFunction(a,b,c,d){return Fq(a,b,c,d,w.m(a.M))}}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"parse-json",j:[{type:1,g:3}],i:{type:59,g:0},callFunction:(a,b,c,d)=>{let e;try{e=JSON.parse(d.first().value)}catch(f){throw Error("FOJS0001: parsed JSON string contains illegal JSON.");}return Gq(e)}}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",
421
- localName:"contains",j:[{type:61,g:3},{type:46,g:3}],i:{type:0,g:3},callFunction:(a,b,c,d,e)=>A([d,e],([f,h])=>f.h.some(k=>sb(k.key,h))?w.aa():w.T())},{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:(a,b,c,d,e)=>d.map(f=>new ub([{key:f,value:Ra(e)}]))},{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:(a,b,c,d,e)=>A([d,
422
- e],([f,h])=>jc(f.h.map(k=>h.value.call(void 0,a,b,c,w.m(k.key),k.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:tb},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"keys",j:[{type:61,g:3}],i:{type:46,g:2},callFunction:(a,b,c,d)=>A([d],([e])=>w.create(e.h.map(f=>f.key)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"merge",j:[{type:61,g:2},{type:61,g:3}],
423
- i:{type:61,g:3},callFunction:Hq},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"merge",j:[{type:61,g:2}],i:{type:61,g:3},callFunction(a,b,c,d){return Hq(a,b,c,d,w.m(new ub([{key:g("duplicates",1),value:()=>w.m(g("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:(a,b,c,d,e,f)=>A([d,e],([h,k])=>{h=h.h.concat();const l=h.findIndex(n=>sb(n.key,k));0<=l?h.splice(l,
424
- 1,{key:k,value:Ra(f)}):h.push({key:k,value:Ra(f)});return w.m(new ub(h))})},{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:(a,b,c,d,e)=>A([d],([f])=>{const h=f.h.concat();return e.N(k=>{k.forEach(l=>{const n=h.findIndex(t=>sb(t.key,l));0<=n&&h.splice(n,1)});return w.m(new ub(h))})})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"size",j:[{type:61,g:3}],i:{type:5,g:3},callFunction:(a,
425
- b,c,d)=>d.map(e=>g(e.h.length,5))}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"pi",j:[],i:{type:3,g:3},callFunction:()=>w.m(g(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:(a,b,c,d)=>d.map(e=>g(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:(a,b,c,d)=>d.map(e=>g(Math.pow(10,e.value),
426
- 3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"log",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(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:(a,b,c,d)=>d.map(e=>g(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:(a,b,c,d,e)=>e.N(([f])=>d.map(h=>
427
- 1!==Math.abs(h.value)||Number.isFinite(f.value)?g(Math.pow(h.value,f.value),3):g(1,3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"sqrt",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(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:(a,b,c,d)=>d.map(e=>g(Math.sin(e.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"cos",j:[{type:3,
428
- g:0}],i:{type:3,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(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:(a,b,c,d)=>d.map(e=>g(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:(a,b,c,d)=>d.map(e=>g(Math.asin(e.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"acos",j:[{type:3,
429
- g:0}],i:{type:3,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(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:(a,b,c,d)=>d.map(e=>g(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:(a,b,c,d,e)=>e.N(([f])=>d.map(h=>g(Math.atan2(h.value,f.value),3)))}],ze,Zd,[{namespaceURI:"http://fontoxpath/operators",
430
- localName:"to",j:[{type:5,g:0},{type:5,g:0}],i:{type:5,g:2},callFunction:(a,b,c,d,e)=>{a=d.first();e=e.first();if(null===a||null===e)return w.empty();let f=a.value;e=e.value;return f>e?w.empty():w.create({next:()=>q(g(f++,5))},e-f+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:(a,b,c,d,e)=>A([d,e],([f,h])=>{h=h.value;if(!tc(h,23))throw Error("FOCA0002: The provided QName is invalid.");f=f?f.value||null:null;
431
- if(null===f&&h.includes(":"))throw Error("FOCA0002: The URI of a QName may not be empty if a prefix is provided.");if(d.F())return w.m(g(new Sa("",null,h),23));if(!h.includes(":"))return w.m(g(new Sa("",f,h),23));const [k,l]=h.split(":");return w.m(g(new Sa(k,f,l),23))})},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"prefix-from-QName",j:[{type:23,g:0}],i:{type:24,g:0},callFunction:(a,b,c,d)=>A([d],([e])=>{if(null===e)return w.empty();e=e.value;return e.prefix?w.m(g(e.prefix,24)):
432
- w.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:(a,b,c,d)=>d.map(e=>g(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:(a,b,c,d)=>d.map(e=>g(e.value.namespaceURI||"",20))}],[{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>d.X({empty:()=>w.aa(),multiple:()=>w.T(),m:()=>w.T()}),localName:"empty",
433
- namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>d.X({empty:()=>w.T(),multiple:()=>w.aa(),m:()=>w.aa()}),localName:"exists",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>Iq(d,1,1),localName:"head",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:0}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>Iq(d,2,null),localName:"tail",namespaceURI:"http://www.w3.org/2005/xpath-functions",
434
- i:{type:59,g:2}},{j:[{type:59,g:2},{type:5,g:3},{type:59,g:2}],callFunction:(a,b,c,d,e,f)=>{if(d.F())return f;if(f.F())return d;a=d.O();e=e.first().value-1;0>e?e=0:e>a.length&&(e=a.length);b=a.slice(e);return w.create(a.slice(0,e).concat(f.O(),b))},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:(a,b,c,d,e)=>{a=e.first().value;d=d.O();if(!d.length||1>a||a>d.length)return w.create(d);d.splice(a-1,1);return w.create(d)},
435
- localName:"remove",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>d.N(e=>w.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:(a,b,c,d,e)=>Lq(a,b,c,d,e,w.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:Lq,localName:"subsequence",
436
- namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>d,localName:"unordered",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:46,g:2}],callFunction:(a,b,c,d)=>{const e=qc(d,b).O();return w.create(e).filter((f,h)=>e.slice(0,h).every(k=>!Ce(f,k)))},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");
437
- },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:(a,b,c,d,e)=>e.N(([f])=>qc(d,b).map((h,k)=>oi("eqOp",h.type,f.type)(h,f,a)?g(k+1,5):g(-1,5)).filter(h=>-1!==h.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",
438
- i:{type:5,g:2}},{j:[{type:59,g:2},{type:59,g:2}],callFunction:(a,b,c,d,e)=>{let f=!1;const h=Fe(a,b,c,d,e);return w.create({next:()=>{if(f)return p;const k=h.next(0);if(k.done)return k;f=!0;return q(g(k.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",
439
- i:{type:0,g:3}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>{let e=!1;return w.create({next:()=>{if(e)return p;const f=d.Pa();e=!0;return q(g(f,5))}})},localName:"count",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:3}},{j:[{type:46,g:2}],callFunction:(a,b,c,d)=>{if(d.F())return d;a=Jq(d.O());a=Ii(a);if(!a)throw Error("FORG0006: Incompatible types to be converted to a common type");if(!a.every(e=>v(e.type,2)))throw Error("FORG0006: items passed to fn:avg are not all numeric.");
440
- b=a.reduce((e,f)=>e+f.value,0)/a.length;return a.every(e=>v(e.type,5)||v(e.type,3))?w.m(g(b,3)):a.every(e=>v(e.type,4))?w.m(g(b,4)):w.m(g(b,6))},localName:"avg",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2}],callFunction:(a,b,c,d)=>{if(d.F())return d;a=Kq(d.O());return w.m(a.reduce((e,f)=>e.value<f.value?f: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");
441
- },localName:"max",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2}],callFunction:(a,b,c,d)=>{if(d.F())return d;a=Kq(d.O());return w.m(a.reduce((e,f)=>e.value>f.value?f: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,
442
- g:2}],callFunction:(a,b,c,d)=>Mq(a,b,c,d,w.m(g(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:Mq,localName:"sum",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>{if(!d.F()&&!d.oa())throw Error("FORG0003: The argument passed to fn:zero-or-one contained more than one item.");return d},localName:"zero-or-one",namespaceURI:"http://www.w3.org/2005/xpath-functions",
443
- i:{type:59,g:0}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>{if(d.F())throw Error("FORG0004: The argument passed to fn:one-or-more was empty.");return d},localName:"one-or-more",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:1}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>{if(!d.oa())throw Error("FORG0005: The argument passed to fn:exactly-one is empty or contained more than one item.");return d},localName:"exactly-one",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,
444
- g:3}},{j:[{type:59,g:2},{type:60,g:3}],callFunction:(a,b,c,d,e)=>{if(d.F())return d;const f=e.first(),h=f.o;if(1!==h.length)throw Error("XPTY0004: signature of function passed to fn:filter is incompatible.");return d.filter(k=>{k=zd(h[0],w.m(k),b,"fn:filter",!1);k=f.value.call(void 0,a,b,c,k);if(!k.oa()||!v(k.first().type,0))throw Error("XPTY0004: signature of function passed to fn:filter is incompatible.");return k.first().value})},localName:"filter",namespaceURI:"http://www.w3.org/2005/xpath-functions",
445
- i:{type:59,g:2}},{j:[{type:59,g:2},{type:60,g:3}],callFunction:(a,b,c,d,e)=>{if(d.F())return d;const f=e.first(),h=f.o;if(1!==h.length)throw Error("XPTY0004: signature of function passed to fn:for-each is incompatible.");const k=d.value;let l;return w.create({next:n=>{for(;;){if(!l){var t=k.next(0);if(t.done)return t;t=zd(h[0],w.m(t.value),b,"fn:for-each",!1);l=f.value.call(void 0,a,b,c,t).value}t=l.next(n);if(!t.done)return t;l=null}}})},localName:"for-each",namespaceURI:"http://www.w3.org/2005/xpath-functions",
446
- i:{type:59,g:2}},{j:[{type:59,g:2},{type:59,g:2},{type:60,g:3}],callFunction:(a,b,c,d,e,f)=>{if(d.F())return d;const h=f.first(),k=h.o;if(2!==k.length)throw Error("XPTY0004: signature of function passed to fn:fold-left is incompatible.");return d.N(l=>l.reduce((n,t)=>{n=zd(k[0],n,b,"fn:fold-left",!1);t=zd(k[1],w.m(t),b,"fn:fold-left",!1);return h.value.call(void 0,a,b,c,n,t)},e))},localName:"fold-left",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2},{type:59,
447
- g:2},{type:60,g:3}],callFunction:(a,b,c,d,e,f)=>{if(d.F())return d;const h=f.first(),k=h.o;if(2!==k.length)throw Error("XPTY0004: signature of function passed to fn:fold-right is incompatible.");return d.N(l=>l.reduceRight((n,t)=>{n=zd(k[0],n,b,"fn:fold-right",!1);t=zd(k[1],w.m(t),b,"fn:fold-right",!1);return h.value.call(void 0,a,b,c,t,n)},e))},localName:"fold-right",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>{if(!b.Ua)throw Error("serialize() called but no xmlSerializer set in execution parameters.");
448
- a=d.O();if(!a.every(e=>v(e.type,53)))throw Error("Expected argument to fn:serialize to resolve to a sequence of Nodes.");return w.m(g(a.map(e=>b.Ua.serializeToString($f(e.value,b,!1))).join(""),1))},localName:"serialize",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}}],ke,[{j:[{type:59,g:3},{type:61,g:3}],callFunction:(a,b,c,d,e)=>{let f,h;return w.create({next:()=>{f||({ic:f,ac:h}=Cq(d,e,c,b));try{return f.next(0)}catch(k){gg(h,k)}}})},localName:"evaluate",namespaceURI:"http://fontoxml.com/fontoxpath",
449
- i:{type:59,g:2}},{j:[],callFunction:()=>w.m(g("undefined"===typeof VERSION?"devbuild":VERSION,1)),localName:"version",namespaceURI:"http://fontoxml.com/fontoxpath",i:{type:1,g:3}}],[{j:[{type:23,g:3},{type:5,g:3}],callFunction:(a,b,c,d,e)=>A([d,e],([f,h])=>{const k=c.va(f.value.namespaceURI,f.value.localName,h.value);if(null===k)return w.empty();f=new Va({j:k.j,arity:h.value,localName:f.value.localName,namespaceURI:f.value.namespaceURI,i:k.i,value:k.callFunction});return w.m(f)}),localName:"function-lookup",
450
- namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{g:0,type:60}},{j:[{type:60,g:3}],callFunction:(a,b,c,d)=>A([d],([e])=>e.Ya()?w.empty():w.m(g(new Sa("",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:(a,b,c,d)=>A([d],([e])=>w.m(g(e.v,5))),localName:"function-arity",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:3}}]);class Oq{constructor(a){this.h=a}createAttributeNS(a,b){return this.h.createAttributeNS(a,b)}createCDATASection(a){return this.h.createCDATASection(a)}createComment(a){return this.h.createComment(a)}createDocument(){return this.h.createDocument()}createElementNS(a,b){return this.h.createElementNS(a,b)}createProcessingInstruction(a,b){return this.h.createProcessingInstruction(a,b)}createTextNode(a){return this.h.createTextNode(a)}};var Pq=Symbol("IS_XPATH_VALUE_SYMBOL");function Qq(a){return(b,c)=>{b=Vb(new nb(null===c?new Za:c),b,Ja(a));return{[Pq]:!0,zb:b}}};Nq.forEach(a=>{ng(a.namespaceURI,a.localName,a.j,a.i,a.callFunction)});function Rq(a){return a&&"object"===typeof a&&"lookupNamespaceURI"in a?b=>a.lookupNamespaceURI(b||null):()=>null}function Sq(a){return({prefix:b,localName:c})=>b?null:{namespaceURI:a,localName:c}}
451
- function Tq(a,b,c,d,e,f){if(null===d||void 0===d)d=d||{};const h=e?{jb:e.logger||{trace:console.log.bind(console)},Ma:e.documentWriter,kb:e.moduleImports,Cb:e.namespaceResolver,bc:e.functionNameResolver,Ja:e.nodesFactory,Ua:e.xmlSerializer}:{jb:{trace:console.log.bind(console)},kb:{},Cb:null,Ja:null,Ma:null,Ua:null},k=new nb(null===c?new Za:c);c=h.kb||Object.create(null);var l=void 0===e.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":e.defaultFunctionNamespaceURI;const n=Aq(a,
452
- f,h.Cb||Rq(b),d,c,l,h.bc||Sq(l));a=b?Wb(k,b):w.empty();b=!h.Ja&&f.Z?new Ze(b):new Oq(h.Ja);c=h.Ma?new bb(h.Ma):ab;l=h.Ua;const t=Object.keys(d).reduce((y,G)=>{const N=d[G];y[`Q{}${G}[0]`]=N&&"object"===typeof N&&Pq in N?()=>w.create(N.zb):()=>Wb(k,d[G]);return y},Object.create(null));let u;for(const y of Object.keys(n.ga.Ea))t[y]||(t[y]=()=>(0,n.ga.Ea[y])(u,z));u=new cc({M:a.first(),Aa:0,ta:a,ra:t});const z=new ic(f.debug,f.Ha,k,b,c,e.currentContext,new Map,h.jb,l);return{tb:u,ub:z,ba:n.ba}};function Uq(a,b){const c={};let d=0,e=!1,f=null;return{next:()=>{if(e)return p;for(;d<a.h.length;){const k=a.h[d].key.value;if(!f){const l=a.h[d];var h=l.value().X({default:n=>n,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 ${l.key.value} holds multiple items`);}}).first();if(null===h){c[k]=null;d++;continue}f=Vq(h,b)}h=f.next(0);f=null;c[k]=
453
- h.value;d++}e=!0;return q(c)}}}function Wq(a,b){const c=[];let d=0,e=!1,f=null;return{next:()=>{if(e)return p;for(;d<a.h.length;){if(!f){var h=a.h[d]().X({default:k=>k,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===h){c[d++]=null;continue}f=Vq(h,b)}h=f.next(0);f=null;c[d++]=h.value}e=!0;return q(c)}}}
454
- function Vq(a,b){if(v(a.type,61))return Uq(a,b);if(v(a.type,62))return Wq(a,b);if(v(a.type,23)){const c=a.value;return{next:()=>q(`Q{${c.namespaceURI||""}}${c.localName}`)}}switch(a.type){case 7:case 8:case 9:case 11:case 12:case 13:case 14:case 15:const c=a.value;return{next:()=>q(Mb(c))};case 47:case 53:case 54:case 55:case 56:case 57:case 58:const d=a.value;return{next:()=>q($f(d,b,!1))};default:return{next:()=>q(a.value)}}};var Xq={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};Xq[Xq.ANY]="ANY";Xq[Xq.NUMBER]="NUMBER";Xq[Xq.STRING]="STRING";Xq[Xq.BOOLEAN]="BOOLEAN";Xq[Xq.NODES]="NODES";Xq[Xq.FIRST_NODE]="FIRST_NODE";Xq[Xq.STRINGS]="STRINGS";Xq[Xq.MAP]="MAP";Xq[Xq.ARRAY]="ARRAY";Xq[Xq.NUMBERS]="NUMBERS";Xq[Xq.ALL_RESULTS]="ALL_RESULTS";Xq[Xq.ASYNC_ITERATOR]="ASYNC_ITERATOR";
455
- function Yq(a,b,c,d){switch(c){case 3:return b.fa();case 2:return b=qc(b,d).O(),b.length?b.map(l=>jd(l,1).value).join(" "):"";case 10:return b=qc(b,d).O(),b.length?b.map(l=>l.value+""):[];case 1:return b=b.first(),null!==b&&v(b.type,2)?b.value:NaN;case 9:b=b.first();if(null===b)return null;if(!v(b.type,53))throw Error("Expected XPath "+eg(a)+" to resolve to Node. Got "+Da[b.type]);return $f(b.value,d,!1);case 7:b=b.O();if(!b.every(l=>v(l.type,53)))throw Error("Expected XPath "+eg(a)+" to resolve to a sequence of Nodes.");
456
- return b.map(l=>$f(l.value,d,!1));case 11:b=b.O();if(1!==b.length)throw Error("Expected XPath "+eg(a)+" to resolve to a single map.");b=b[0];if(!v(b.type,61))throw Error("Expected XPath "+eg(a)+" to resolve to a map");return Uq(b,d).next(0).value;case 12:b=b.O();if(1!==b.length)throw Error("Expected XPath "+eg(a)+" to resolve to a single array.");b=b[0];if(!v(b.type,62))throw Error("Expected XPath "+eg(a)+" to resolve to an array");return Wq(b,d).next(0).value;case 13:return b.O().map(l=>{if(!v(l.type,
457
- 2))throw Error("Expected XPath "+eg(a)+" to resolve to numbers");return l.value});case 99:const e=b.value;let f=null,h=!1;const k=()=>{for(;!h;){if(!f){var l=e.next(0);if(l.done){h=!0;break}f=Vq(l.value,d)}l=f.next(0);f=null;return l}return Promise.resolve({done:!0,value:null})};return"asyncIterator"in Symbol?{[Symbol.asyncIterator](){return this},next:()=>(new Promise(l=>l(k()))).catch(l=>{gg(a,l)})}:{next:()=>new Promise(l=>l(k()))};case 14:return b.O().map(l=>Vq(l,d).next(0).value);default:return b=
458
- b.O(),b.every(l=>v(l.type,53)&&!v(l.type,47))?(b=b.map(l=>$f(l.value,d,!1)),1===b.length?b[0]:b):1===b.length?(b=b[0],v(b.type,62)?Wq(b,d).next(0).value:v(b.type,61)?Uq(b,d).next(0).value:pc(b,d).first().value):qc(w.create(b),d).O().map(l=>l.value)}};let Zq=!1,$q=null;
459
- var ar={getPerformanceSummary(){const a=$q.getEntriesByType("measure").filter(b=>b.name.startsWith("XPath: "));return Array.from(a.reduce((b,c)=>{var d=c.name.substring(7);b.has(d)?(d=b.get(d),d.times+=1,d.totalDuration+=c.duration):b.set(d,{xpath:d,times:1,totalDuration:c.duration,average:0});return b},new Map).values()).map(b=>{b.average=b.totalDuration/b.times;return b}).sort((b,c)=>c.totalDuration-b.totalDuration)},setPerformanceImplementation(a){$q=a},startProfiling(){if(null===$q)throw Error("Performance API object must be set using `profiler.setPerformanceImplementation` before starting to profile");
460
- $q.clearMarks();$q.clearMeasures();Zq=!0},stopProfiling(){Zq=!1}};let br=0;var cr={XPATH_3_1_LANGUAGE:"XPath3.1",XQUERY_3_1_LANGUAGE:"XQuery3.1",XQUERY_UPDATE_3_1_LANGUAGE:"XQueryUpdate3.1"};const dr=(a,b,c,d,e,f)=>{e=e||0;if(!a||"string"!==typeof a&&!("nodeType"in a))throw new TypeError("Failed to execute 'evaluateXPath': xpathExpression must be a string or an element depicting an XQueryX DOM tree.");f=f||{};let h,k;try{const n=Tq(a,b,c||null,d||{},f,{sa:"XQueryUpdate3.1"===f.language,Z:"XQuery3.1"===f.language||"XQueryUpdate3.1"===f.language,debug:!!f.debug,Ha:!!f.disableCache});var l=n.tb;h=n.ub;k=n.ba}catch(n){gg(a,n)}if(k.I)throw Error("XUST0001: Updating expressions should be evaluated as updating expressions");
461
- if(3===e&&b&&"object"===typeof b&&"nodeType"in b&&(c=k.D(),b=Ya(b),null!==c&&!b.includes(c)))return!1;try{b=a;Zq&&("string"!==typeof b&&(b=eg(b)),$q.mark(`${b}${0===br?"":"@"+br}`),br++);const n=C(k,l,h),t=Yq(a,n,e,h);e=a;Zq&&("string"!==typeof e&&(e=eg(e)),br--,l=`${e}${0===br?"":"@"+br}`,$q.measure(`XPath: ${e}`,l),$q.clearMarks(l));return t}catch(n){gg(a,n)}};
462
- Object.assign(dr,{jc:14,ANY_TYPE:0,Lb:12,Mb:99,BOOLEAN_TYPE:3,Ob:9,Rb:11,Tb:7,Ub:13,NUMBER_TYPE:1,Vb:10,STRING_TYPE:2,kc:"XPath3.1",lc:"XQuery3.1",Yb:"XQueryUpdate3.1"});Object.assign(dr,{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"});function er(a,b,c,d,e){return dr(a,b,c,d,dr.Mb,e)};function fr(a,b,c,d){return{pendingUpdateList:a.da.map(e=>e.h(d)),xdmValue:Yq(b,w.create(a.J),c,d)}};async function gr(a,b,c,d,e){e=e||{};Ok();let f,h;try{const n=Tq(a,b,c||null,d||{},e||{},{sa:!0,Z:!0,debug:!!e.debug,Ha:!!e.disableCache});var k=n.tb;f=n.ub;h=n.ba}catch(n){gg(a,n)}if(!h.I){k=[];a=er(a,b,c,d,Object.assign(Object.assign({},e),{language:"XQueryUpdate3.1"}));for(b=await a.next();!b.done;b=await a.next())k.push(b.value);return Promise.resolve({pendingUpdateList:[],xdmValue:k})}let l;try{l=h.s(k,f).next(0)}catch(n){gg(a,n)}return fr(l.value,a,e.returnType,f)};function hr(a,b,c,d,e){e=e||{};Ok();let f,h,k;try{const n=Tq(a,b,c||null,d||{},e||{},{sa:!0,Z:!0,debug:!!e.debug,Ha:!!e.disableCache});f=n.tb;h=n.ub;k=n.ba}catch(n){gg(a,n)}if(!k.I)return{pendingUpdateList:[],xdmValue:dr(a,b,c,d,e.i,Object.assign(Object.assign({},e),{language:dr.Yb}))};let l;try{l=k.s(f,h).next(0)}catch(n){gg(a,n)}return fr(l.value,a,e.returnType,h)};function ir(a,b,c,d,e){return dr(a,b,c,d,dr.Lb,e)};function jr(a,b,c,d,e){return dr(a,b,c,d,dr.BOOLEAN_TYPE,e)};function kr(a,b,c,d,e){return dr(a,b,c,d,dr.Ob,e)};function lr(a,b,c,d,e){return dr(a,b,c,d,dr.Rb,e)};function mr(a,b,c,d,e){return dr(a,b,c,d,dr.Tb,e)};function nr(a,b,c,d,e){return dr(a,b,c,d,dr.NUMBER_TYPE,e)};function or(a,b,c,d,e){return dr(a,b,c,d,dr.Ub,e)};function pr(a,b,c,d,e){return dr(a,b,c,d,dr.STRING_TYPE,e)};function qr(a,b,c,d,e){return dr(a,b,c,d,dr.Vb,e)};function rr(a,b,c,d){b=new nb(b?b:new Za);d=d?new bb(d):ab;c=c?c=new Oq(c):null;a=a.map(Rj);kf(a,b,c,d)};function Y(a,b,c){return{code:a,ua:b,H:c,isAstAccepted:!0}}function sr(a){return{isAstAccepted:!1,reason:a}};function Z(a,b){return a.isAstAccepted?b(a):a}function tr(a,b){return a.isAstAccepted?b(a):[a,null]}function ur(a,b,c){return Z(a,d=>{switch(d.ua.type){case 0:return d;case 1:return Z(vr(c,d,"nodes"),e=>Z(vr(c,b,"contextItem"),f=>Y(`(function () {
211
+ function $g(a,b,c){const d=Kg(J(a,["forClauseItem","typedVariableBinding","varName"]));if(a=J(a,["forClauseItem","forExpr","sequenceExpr"]))a=K(a,"*").map(e=>c(e,b)),a.includes(void 0)||a.includes(null)||(a=ah(a),1===a.length&&Zg(b,d.localName,a[0]))}function ah(a){return a.filter((b,c,d)=>d.findIndex(e=>e.type===b.type&&e.g===b.g)===c)};function bh(a,b){if(!b||!b.fa)return{type:59,g:2};const c=G(a,"functionName");var d=Kg(c);let e=d.localName;var f=d.prefix;let h=d.namespaceURI;d=K(G(a,"arguments"),"*");if(null===h){f=b.fa.Ua({localName:e,prefix:f},d.length);if(!f)return{type:59,g:2};e=f.localName;h=f.namespaceURI;L(c,"URI",h);c[2]=e}b=b.fa.ua(h,e,d.length);if(!b||63===b.i.type)return{type:59,g:2};59!==b.i.type&&L(a,"type",b.i);return b.i};function ch(a){const b={type:61,g:3};L(a,"type",b);return b};function dh(a,b){if(!b||!b.fa)return{type:59,g:2};const c=G(a,"functionName");var d=Kg(c);let e=d.localName;var f=d.namespaceURI;const h=d.prefix;d=Number(J(a,["integerConstantExpr","value"])[1]);if(!f){f=b.fa.Ua({localName:e,prefix:h},d);if(!f)return{type:59,g:2};e=f.localName;f=f.namespaceURI;L(c,"URI",f)}b=b.fa.ua(f,e,d)||null;if(!b)return{type:59,g:2};59!==b.i.type&&63!==b.i.type&&L(a,"type",b.i);return b.i};function eh(a,b){var c=K(a,"stepExpr");if(!c)return{type:59,g:2};for(const f of c){a:{c=f;var d=b;let h=null;if(!c)break a;var e=K(c,"*");let k="";for(const l of e)switch(l[0]){case "filterExpr":h=I(J(l,["*"]),"type");break;case "xpathAxis":k=l[1];b:{switch(k){case "attribute":h={type:47,g:2};break b;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":h=
212
+ {type:53,g:2};break b}h=void 0}break;case "nameTest":e=Kg(l);if(null!==e.namespaceURI)break;if("attribute"===k&&!e.prefix)break;e=d.Z(e.prefix||"");void 0!==e&&L(l,"URI",e);break;case "lookup":h={type:59,g:2}}h&&59!==h.type&&L(c,"type",h)}d=I(f,"type")}d&&59!==d.type&&L(a,"type",d);return d};function fh(a){const b={type:0,g:3};L(a,"type",b);return b};function gh(a,b,c){0===b?b={type:53,g:2}:1===b?b=c[0]:c.includes(void 0)||c.includes(null)?b={type:59,g:2}:(b=ah(c),b=1<b.length?{type:59,g:2}:{type:b[0].type,g:2});b&&59!==b.type&&L(a,"type",b);return b};function hh(a,b,c,d){if(!b||c.includes(void 0))return{type:59,g:2};var e=K(a,"typeswitchExprCaseClause");for(let h=0;h<c.length;h++){var f=G(e[h],"*");switch(f[0]){case "sequenceType":if(f=ih(f,b,c[h]))return 59!==f.type&&L(a,"type",f),f;continue;case "sequenceTypeUnion":for(d=K(f,"*"),e=0;2>e;e++)if(f=ih(d[e],b,c[h]))return 59!==f.type&&L(a,"type",f),f;default:return{type:59,g:2}}}59!==d.type&&L(a,"type",d);return d}
213
+ function ih(a,b,c){const d=K(a,"*"),e=G(a,"atomicType");if(!e)return{type:59,g:2};if(Ia(I(e,"prefix")+":"+e[2])===b.type)if(1===d.length){if(3===b.g)return c}else if(a=G(a,"occurrenceIndicator")[1],b.g===Ka(a))return c};function jh(a,b){O(a,b)}function O(a,b){var c=kh.get(a[0]);if(c)return c(a,b);for(c=1;c<a.length;c++)a[c]&&O(a[c],b)}
214
+ const lh=(a,b)=>{var c=O(G(a,"firstOperand")[1],b);const d=O(G(a,"secondOperand")[1],b);var e=a[0];if(c&&d)if(b=Ug(e,c.type,d.type))c={type:b,g:c.g},2!==b&&59!==b&&L(a,"type",c),a=c;else throw Error(`XPTY0004: ${e} not available for types ${Ha(c)} and ${Ha(d)}`);else a={type:2,g:3};return a},mh=(a,b)=>{O(G(a,"firstOperand")[1],b);O(G(a,"secondOperand")[1],b);a:{switch(a[0]){case "orOp":b={type:0,g:3};L(a,"type",b);a=b;break a;case "andOp":b={type:0,g:3};L(a,"type",b);a=b;break a}a=void 0}return a},
215
+ nh=(a,b)=>{O(G(a,"firstOperand")[1],b);O(G(a,"secondOperand")[1],b);a:{switch(a[0]){case "unionOp":b={type:53,g:2};L(a,"type",b);a=b;break a;case "intersectOp":b={type:53,g:2};L(a,"type",b);a=b;break a;case "exceptOp":b={type:53,g:2};L(a,"type",b);a=b;break a}a=void 0}return a},oh=(a,b)=>{O(G(a,"firstOperand")[1],b);O(G(a,"secondOperand")[1],b);b={type:0,g:3};L(a,"type",b);return b},ph=(a,b)=>{O(G(a,"firstOperand")[1],b);O(G(a,"secondOperand")[1],b);b=I(J(a,["firstOperand","*"]),"type");const c=I(J(a,
216
+ ["secondOperand","*"]),"type");b={type:0,g:xc(b)||xc(c)?0:3};L(a,"type",b);return b},qh=(a,b)=>{O(G(a,"firstOperand")[1],b);O(G(a,"secondOperand")[1],b);b=I(J(a,["firstOperand","*"]),"type");const c=I(J(a,["secondOperand","*"]),"type");b={type:0,g:xc(b)||xc(c)?0:3};L(a,"type",b);return b},kh=new Map([["unaryMinusOp",(a,b)=>{b=O(G(a,"operand")[1],b);b?v(b.type,2)?(b={type:b.type,g:b.g},L(a,"type",b),a=b):(b={type:3,g:3},L(a,"type",b),a=b):(b={type:2,g:2},L(a,"type",b),a=b);return a}],["unaryPlusOp",
217
+ (a,b)=>{b=O(G(a,"operand")[1],b);b?v(b.type,2)?(b={type:b.type,g:b.g},L(a,"type",b),a=b):(b={type:3,g:3},L(a,"type",b),a=b):(b={type:2,g:2},L(a,"type",b),a=b);return a}],["addOp",lh],["subtractOp",lh],["divOp",lh],["idivOp",lh],["modOp",lh],["multiplyOp",lh],["andOp",mh],["orOp",mh],["sequenceExpr",(a,b)=>{const c=K(a,"*"),d=c.map(e=>O(e,b));return gh(a,c.length,d)}],["unionOp",nh],["intersectOp",nh],["exceptOp",nh],["stringConcatenateOp",(a,b)=>{O(G(a,"firstOperand")[1],b);O(G(a,"secondOperand")[1],
218
+ b);b={type:1,g:3};L(a,"type",b);return b}],["rangeSequenceExpr",(a,b)=>{O(G(a,"startExpr")[1],b);O(G(a,"endExpr")[1],b);b={type:5,g:1};L(a,"type",b);return b}],["equalOp",oh],["notEqualOp",oh],["lessThanOrEqualOp",oh],["lessThanOp",oh],["greaterThanOrEqualOp",oh],["greaterThanOp",oh],["eqOp",ph],["neOp",ph],["ltOp",ph],["leOp",ph],["gtOp",ph],["geOp",ph],["isOp",qh],["nodeBeforeOp",qh],["nodeAfterOp",qh],["pathExpr",(a,b)=>{const c=G(a,"rootExpr");c&&c[1]&&O(c[1],b);K(a,"stepExpr").map(d=>O(d,b));
219
+ return eh(a,b)}],["contextItemExpr",()=>({type:59,g:2})],["ifThenElseExpr",(a,b)=>{var c=G(a,"ifClause")||G(K(a,"x:stackTrace")[0],"ifClause");const d=G(a,"thenClause")||G(K(a,"x:stackTrace")[1],"thenClause"),e=G(a,"elseClause")||G(K(a,"x:stackTrace")[2],"elseClause");O(G(c,"*"),b);c=O(G(d,"*"),b);b=O(G(e,"*"),b);c&&b?c.type===b.type&&c.g===b.g?(59!==c.type&&L(a,"type",c),a=c):a={type:59,g:2}:a={type:59,g:2};return a}],["instanceOfExpr",(a,b)=>{O(G(a,"argExpr"),b);O(G(a,"sequenceType"),b);b={type:0,
220
+ g:3};L(a,"type",b);return b}],["integerConstantExpr",a=>{const b={type:5,g:3};L(a,"type",b);return b}],["doubleConstantExpr",a=>{const b={type:3,g:3};L(a,"type",b);return b}],["decimalConstantExpr",a=>{const b={type:4,g:3};L(a,"type",b);return b}],["stringConstantExpr",a=>{const b={type:1,g:3};L(a,"type",b);return b}],["functionCallExpr",(a,b)=>{const c=G(a,"arguments");K(c,"*").map(d=>O(d,b));return bh(a,b)}],["arrowExpr",(a,b)=>{O(G(a,"argExpr")[1],b);return Ng(a,b)}],["dynamicFunctionInvocationExpr",
221
+ (a,b)=>{O(J(a,["functionItem","*"]),b);(a=G(a,"arguments"))&&O(a,b);return{type:59,g:2}}],["namedFunctionRef",(a,b)=>dh(a,b)],["inlineFunctionExpr",(a,b)=>{O(G(a,"functionBody")[1],b);b={type:60,g:3};L(a,"type",b);return b}],["castExpr",a=>{var b=J(a,["singleType","atomicType"]);b=I(b,"prefix")+":"+b[2];b={type:Ia(b),g:3};59!==b.type&&L(a,"type",b);return b}],["castableExpr",a=>{const b={type:0,g:3};L(a,"type",b);return b}],["simpleMapExpr",(a,b)=>{const c=K(a,"pathExpr");let d;for(let e=0;e<c.length;e++)d=
222
+ O(c[e],b);void 0!==d&&null!==d?((b={type:d.type,g:2},59!==b.type)&&L(a,"type",b),a=b):a={type:59,g:2};return a}],["mapConstructor",(a,b)=>{K(a,"mapConstructorEntry").map(c=>({key:O(J(c,["mapKeyExpr","*"]),b),value:O(J(c,["mapValueExpr","*"]),b)}));return ch(a)}],["arrayConstructor",(a,b)=>{K(G(a,"*"),"arrayElem").map(c=>O(c,b));return Mg(a)}],["unaryLookup",a=>{G(a,"NCName");return{type:59,g:2}}],["typeswitchExpr",(a,b)=>{const c=O(G(a,"argExpr")[1],b),d=K(a,"typeswitchExprCaseClause").map(f=>O(J(f,
223
+ ["resultExpr"])[1],b)),e=O(J(a,["typeswitchExprDefaultClause","resultExpr"])[1],b);return hh(a,c,d,e)}],["quantifiedExpr",(a,b)=>{K(a,"*").map(c=>O(c,b));return fh(a)}],["x:stackTrace",(a,b)=>{a=K(a,"*");return O(a[0],b)}],["queryBody",(a,b)=>O(a[1],b)],["flworExpr",(a,b)=>Xg(a,b)],["varRef",(a,b)=>{const c=Kg(G(a,"name"));var d;a:{for(d=b.h;0<=d;d--){const e=b.o[d][c.localName];if(e){d=e;break a}}d=void 0}d&&59!==d.type&&L(a,"type",d);null===c.namespaceURI&&(b=b.Z(c.prefix),void 0!==b&&L(a,"URI",
224
+ b));return d}]]);function Yg(a){a.h++;a.o.push({});a.v.push({})}function Zg(a,b,c){if(a.o[a.h][b])throw Error(`Another variable of in the scope ${a.h} with the same name ${b} already exists`);a.o[a.h][b]=c}var rh=class{constructor(a){this.h=0;this.fa=a;this.o=[{}];this.v=[{}]}Z(a){for(let b=this.h;0<=b;b--){const c=this.v[b][a];if(void 0!==c)return c}return this.fa?this.fa.Z(a):void 0}};var sh=class extends rf{constructor(a,b){super(a.reduce((c,d)=>0<uf(c,d.o)?c:d.o,new D({})),a,{B:a.every(c=>c.B)},b)}A(a,b,c){for(const d of c)if(b=d(a),!b.isEmpty())return b;return w.empty()}};const th=new Map([["type-1-or-type-2",["name","type-1","type-2"]],["type-1",["name"]],["type-2",["name"]]]),uh=new Map([["name","type-1-or-type-2"],["type-1","type-1-or-type-2"],["type-2","type-1-or-type-2"]]);function vh(a,b){if(null===a)return b;if(null===b||a===b)return a;const c=a.startsWith("name-")?"name":a,d=b.startsWith("name-")?"name":b,e=th.get(c);if(void 0!==e&&e.includes(d))return b;b=th.get(d);return void 0!==b&&b.includes(c)?a:"empty"}
225
+ function wh(a,b){if(null===a||null===b)return null;if("empty"===a)return b;if("empty"===b||a===b)return a;a=a.startsWith("name-")?"name":a;var c=b.startsWith("name-")?"name":b;b=uh.get(a);if(void 0!==b&&b===c)return b;c=uh.get(c);return void 0!==c&&c===a?c:b===c?b:null};var xh=class extends C{constructor(a){super(a,[],{B:!1})}h(a,b){return this.l(a,a.L,b)?w.$():w.S()}};var yh=class extends xh{constructor(a){super(a.reduce((c,d)=>0<uf(c,d.o)?c:d.o,new D({})));let b;for(let c=0;c<a.length;++c){const d=a[c].D();void 0===b&&(b=d);if(null===b)break;b=wh(b,d)}this.A=b;this.s=a}l(a,b,c){return this.s.some(d=>d.l(a,b,c))}D(){return this.A}v(a){this.s.forEach(b=>b.v(a))}};var zh=class extends C{constructor(a,b){super(new D({external:1}),a,{B:a.every(c=>c.B)},!1,b);this.l=a}h(a,b){return 0===this.l.length?w.m(new qb([])):A(this.l[0],a,b).M(c=>w.m(new qb(c.map(d=>Ra(w.m(d))))))}};var Ah=class extends C{constructor(a,b){super(new D({external:1}),a,{B:a.every(c=>c.B)},!1,b);this.l=a}h(a,b){return w.m(new qb(this.l.map(c=>Ra(A(c,a,b)))))}};function Bh(a){if(null===a)throw mc("context is absent, it needs to be present to use axes.");if(!v(a.type,53))throw Error("XPTY0020: Axes can only be applied to nodes.");return a.value};function Ch(a,b,c){let d=b;return{next:()=>{if(!d)return p;const e=d;d=x(a,e,c);return q(sb(e))}}}var Dh=class extends C{constructor(a,b){b=b||{Sa:!1};super(a.o,[a],{P:"reverse-sorted",V:!1,subtree:!1,B:!1});this.l=a;this.s=!!b.Sa}h(a,b){const c=b.h,d=Bh(a.L);var e=this.l.D();e=e&&(e.startsWith("name-")||"type-1"===e)?"type-1":null;return w.create(Ch(c,this.s?d:x(c,d,e),e)).filter(f=>this.l.l(a,f,b))}};var Eh=class extends C{constructor(a,b){super(new D({attribute:1}),[a],{P:"unsorted",subtree:!0,V:!0,B:!1});this.l=a;this.s=vh(this.l.D(),b)}h(a,b){var c=b.h;const d=Bh(a.L);if(1!==d.node.nodeType)return w.empty();c=eb(c,d,this.s).filter(e=>"http://www.w3.org/2000/xmlns/"!==e.node.namespaceURI).map(e=>sb(e)).filter(e=>this.l.l(a,e,b));return w.create(c)}D(){return"type-1"}};var Fh=class extends C{constructor(a,b){super(a.o,[a],{P:"sorted",subtree:!0,V:!0,B:!1});this.s=a;this.l=vh(b,a.D())}h(a,b){const c=b.h,d=Bh(a.L),e=d.node.nodeType;if(1!==e&&9!==e)return w.empty();let f=null,h=!1;return w.create({next:()=>{for(;!h;){if(!f){f=ib(c,d,this.l);if(!f){h=!0;continue}return q(sb(f))}if(f=mb(c,f,this.l))return q(sb(f));h=!0}return p}}).filter(k=>this.s.l(a,k,b))}};function Gh(a,b,c){const d=b.node.nodeType;if(1!==d&&9!==d)return{next:()=>p};let e=ib(a,b,c);return{next(){if(!e)return p;const f=e;e=mb(a,e,c);return q(f)}}};function Hh(a,b,c){const d=[ld(b)];return{next:e=>{0<d.length&&0!==(e&1)&&d.shift();if(!d.length)return p;for(e=d[0].next(0);e.done;){d.shift();if(!d.length)return p;e=d[0].next(0)}d.unshift(Gh(a,e.value,c));return q(sb(e.value))}}}
226
+ var Ih=class extends C{constructor(a,b){b=b||{Sa:!1};super(a.o,[a],{B:!1,V:!1,P:"sorted",subtree:!0});this.l=a;this.s=!!b.Sa;this.A=(a=this.l.D())&&(a.startsWith("name-")||"type-1"===a)||"type-1-or-type-2"===a?"type-1":null}h(a,b){var c=b.h;const d=Bh(a.L);c=Hh(c,d,this.A);this.s||c.next(0);return w.create(c).filter(e=>this.l.l(a,e,b))}};function Jh(a,b,c){var d=a.node.nodeType;if(1!==d&&9!==d)return a;for(d=lb(b,a,c);null!==d;){if(1!==d.node.nodeType)return d;a=d;d=lb(b,a,c)}return a}
227
+ function Kh(a,b,c=!1,d){if(c){let f=b,h=!1;return{next:()=>{if(h)return p;if(nd(f,b))return f=Jh(b,a,d),nd(f,b)?(h=!0,p):q(sb(f));const k=f.node.nodeType,l=9===k||2===k?null:nb(a,f,d);if(null!==l)return f=Jh(l,a,d),q(sb(f));f=9===k?null:x(a,f,d);return nd(f,b)?(h=!0,p):q(sb(f))}}}const e=[Gh(a,b,d)];return{next:()=>{if(!e.length)return p;let f=e[0].next(0);for(;f.done;){e.shift();if(!e.length)return p;f=e[0].next(0)}e.unshift(Gh(a,f.value,d));return q(sb(f.value))}}};function Lh(a,b,c){const d=[];for(;b&&9!==b.node.nodeType;b=x(a,b,null)){const f=mb(a,b,c);f&&d.push(f)}let e=null;return{next:()=>{for(;e||d.length;){if(!e){e=Kh(a,d[0],!1,c);var f=q(sb(d[0]));const h=mb(a,d[0],c);h?d[0]=h:d.shift();return f}f=e.next(0);if(f.done)e=null;else return f}return p}}}
228
+ var Mh=class extends C{constructor(a){super(a.o,[a],{P:"sorted",V:!0,subtree:!1,B:!1});this.l=a;this.s=(a=this.l.D())&&(a.startsWith("name-")||"type-1"===a)?"type-1":null}h(a,b){const c=b.h,d=Bh(a.L);return w.create(Lh(c,d,this.s)).filter(e=>this.l.l(a,e,b))}};function Nh(a,b,c){return{next:()=>(b=b&&mb(a,b,c))?q(sb(b)):p}}var Oh=class extends C{constructor(a,b){super(a.o,[a],{P:"sorted",V:!0,subtree:!1,B:!1});this.l=a;this.s=vh(this.l.D(),b)}h(a,b){const c=b.h,d=Bh(a.L);return w.create(Nh(c,d,this.s)).filter(e=>this.l.l(a,e,b))}};var Ph=class extends C{constructor(a,b){super(a.o,[a],{P:"reverse-sorted",V:!0,subtree:!0,B:!1});this.l=a;this.s=vh(b,this.l.D())}h(a,b){var c=b.h;const d=Bh(a.L);c=x(c,d,this.s);if(!c)return w.empty();c=sb(c);return this.l.l(a,c,b)?w.m(c):w.empty()}};function Qh(a,b,c){const d=[];for(;b&&9!==b.node.nodeType;b=x(a,b,null)){const f=nb(a,b,c);null!==f&&d.push(f)}let e=null;return{next:()=>{for(;e||d.length;){e||=Kh(a,d[0],!0,c);var f=e.next(0);if(f.done){e=null;f=nb(a,d[0],c);const h=q(sb(d[0]));null===f?d.shift():d[0]=f;return h}return f}return p}}}
229
+ var Rh=class extends C{constructor(a){super(a.o,[a],{B:!1,V:!0,P:"reverse-sorted",subtree:!1});this.l=a;this.s=(a=this.l.D())&&(a.startsWith("name-")||"type-1"===a)?"type-1":null}h(a,b){const c=b.h,d=Bh(a.L);return w.create(Qh(c,d,this.s)).filter(e=>this.l.l(a,e,b))}};function Sh(a,b,c){return{next:()=>(b=b&&nb(a,b,c))?q(sb(b)):p}}var Th=class extends C{constructor(a,b){super(a.o,[a],{B:!1,V:!0,P:"reverse-sorted",subtree:!1});this.l=a;this.s=vh(this.l.D(),b)}h(a,b){const c=b.h,d=Bh(a.L);return w.create(Sh(c,d,this.s)).filter(e=>this.l.l(a,e,b))}};var Uh=class extends C{constructor(a,b){super(a.o,[a],{P:"sorted",subtree:!0,V:!0,B:!1});this.l=a;this.s=vh(this.l.D(),b)}h(a,b){Bh(a.L);return this.l.l(a,a.L,b)?w.m(a.L):w.empty()}D(){return this.s}};var Vh=class extends rf{constructor(a,b,c,d){super(a.o.add(b.o).add(c.o),[a,b,c],{B:a.B&&b.B&&c.B,V:b.V===c.V&&b.V,P:b.ha===c.ha?b.ha:"unsorted",subtree:b.subtree===c.subtree&&b.subtree},d);this.l=a}A(a,b,c){let d=null;const e=c[0](a);return w.create({next:f=>{d||(d=(e.ea()?c[1](a):c[2](a)).value);return d.next(f)}})}v(a){super.v(a);if(this.l.H)throw Oe();}};function ig(a){return a.h instanceof Error?a.location:ig(a.h)}function jg(a){let b;b=a.h instanceof gg?["Inner error:",a.h.message]:a.h instanceof Error?[a.h.toString()]:jg(a.h);b.push(` at <${a.o}${a.Xa?` (${a.Xa})`:""}>:${a.location.start.line}:${a.location.start.ga} - ${a.location.end.line}:${a.location.end.ga}`);return b}var Wh=class{constructor(a,b,c,d){this.location=a;this.o=b;this.Xa=c;this.h=d}};var Xh=class extends rf{constructor(a,b,c,d){super(c.o,[c],{B:c.B,V:c.V,P:c.ha,subtree:c.subtree});this.K=b;this.O={end:{ga:a.end.ga,line:a.end.line,offset:a.end.offset},start:{ga:a.start.ga,line:a.start.line,offset:a.start.offset}};this.l=d}A(a,b,[c]){let d;try{d=c(a)}catch(e){throw new Wh(this.O,this.K,this.l,e);}return w.create({next:e=>{try{return d.value.next(e)}catch(f){throw new Wh(this.O,this.K,this.l,f);}}})}v(a){try{super.v(a)}catch(b){throw new Wh(this.O,this.K,this.l,b);}}D(){return this.Ga[0].D()}};function Yh(a,b,c,d){let e=[];const f=a.K(b,c,d,k=>{if(a.l instanceof Zh){const n=Yh(a.l,b,k,d);return pf(n,t=>e=t)}let l=null;return w.create({next:()=>{for(;;){if(!l){var n=k.next(0);if(n.done)return p;n=a.l.s(n.value,d);l=pf(n,t=>e=mf(e,t)).value}n=l.next(0);if(n.done)l=null;else return n}}})});let h=!1;return{next:()=>{if(h)return p;const k=f.N();h=!0;return q(new Ze(k,e))}}}
230
+ function $h(a,b,c,d){return a.K(b,c,d,e=>{if(a.l instanceof Zh)return $h(a.l,b,e,d);let f=null;return w.create({next:()=>{for(;;){if(!f){var h=e.next(0);if(h.done)return p;f=A(a.l,h.value,d).value}h=f.next(0);if(h.done)f=null;else return h}}})})}
231
+ var Zh=class extends C{constructor(a,b,c,d){super(a,b,c,!0);this.l=d;this.H=this.l.H}h(a,b){return this.K(a,ld(a),b,c=>{if(this.l instanceof Zh)return $h(this.l,a,c,b);let d=null;return w.create({next:e=>{for(;;){if(!d){var f=c.next(0);if(f.done)return p;d=A(this.l,f.value,b).value}f=d.next(e);if(f.done)d=null;else return f}}})})}s(a,b){return Yh(this,a,ld(a),b)}v(a){super.v(a);this.H=this.l.H;for(const b of this.Ga)if(b!==this.l&&b.H)throw Oe();}};var ai=class extends Zh{constructor(a,b,c,d){super(b.o.add(d.o),[b,d],{B:!1},d);this.O=a.prefix;this.la=a.namespaceURI;this.Rb=a.localName;this.yb=null;this.A=c;this.Ma=null;this.ya=b}K(a,b,c,d){let e=null,f=null,h=0;return d({next:()=>{for(;;){if(!e){var k=b.next(0);if(k.done)return p;f=k.value;h=0;e=A(this.ya,f,c).value}const l=e.next(0);if(l.done)e=null;else return h++,k={[this.yb]:()=>w.m(l.value)},this.Ma&&(k[this.Ma]=()=>w.m(new Ca(5,h))),q(ic(f,k))}}})}v(a){if(this.O&&(this.la=a.Z(this.O),
232
+ !this.la&&this.O))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.O} in a for expression`);this.ya.v(a);Dg(a);this.yb=Hg(a,this.la,this.Rb);if(this.A){if(this.A.prefix&&(this.A.namespaceURI=a.Z(this.A.prefix),!this.A.namespaceURI&&this.A.prefix))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.O} in the positionalVariableBinding in a for expression`);this.Ma=Hg(a,this.A.namespaceURI,this.A.localName)}this.l.v(a);Jg(a);if(this.ya.H)throw Oe();this.l.H&&(this.H=
233
+ !0)}};var bi=class extends C{constructor(a,b,c){super(new D({external:1}),[c],{B:!1,P:"unsorted"});this.O=a.map(({name:d})=>d);this.A=a.map(({type:d})=>d);this.s=null;this.K=b;this.l=c}h(a,b){const c=new Va({j:this.A,arity:this.A.length,bb:!0,H:this.l.H,localName:"dynamic-function",namespaceURI:"",i:this.K,value:(d,e,f,...h)=>{d=ic(cc(a,-1,null,w.empty()),this.s.reduce((k,l,n)=>{k[l]=Ra(h[n]);return k},Object.create(null)));return A(this.l,d,b)}});return w.m(c)}v(a){Dg(a);this.s=this.O.map(b=>Hg(a,b.namespaceURI,
234
+ b.localName));this.l.v(a);Jg(a);if(this.l.H)throw Error("Not implemented: inline functions can not yet be updating.");}};var ci=class extends Zh{constructor(a,b,c){super(b.o.add(c.o),[b,c],{B:!1,V:c.V,P:c.ha,subtree:c.subtree},c);if(a.prefix||a.namespaceURI)throw Error("Not implemented: let expressions with namespace usage.");this.A=a.prefix;this.O=a.namespaceURI;this.Ma=a.localName;this.la=b;this.ya=null}K(a,b,c,d){return d({next:()=>{var e=b.next(0);if(e.done)return p;e=e.value;e=ic(e,{[this.ya]:Ra(A(this.la,e,c))});return q(e)}})}v(a){if(this.A&&(this.O=a.Z(this.A),!this.O&&this.A))throw Error(`XPST0081: Could not resolve namespace for prefix ${this.A} using in a for expression`);
235
+ this.la.v(a);Dg(a);this.ya=Hg(a,this.O,this.Ma);this.l.v(a);Jg(a);this.H=this.l.H;if(this.la.H)throw Oe();}};var di=class extends C{constructor(a,b){super(new D({}),[],{B:!0,P:"sorted"},!1,b);let c;switch(b.type){case 5:c=g(parseInt(a,10),b.type);break;case 1:c=g(a,b.type);break;case 4:case 3:c=g(parseFloat(a),b.type);break;default:throw new TypeError("Type "+b+" not expected in a literal");}this.l=()=>w.m(c)}h(){return this.l()}};var ei=class extends C{constructor(a,b){super(new D({external:1}),a.reduce((c,{key:d,value:e})=>c.concat(d,e),[]),{B:!1},!1,b);this.l=a}h(a,b){const c=this.l.map(d=>rc(A(d.key,a,b),b).X({default:()=>{throw Error("XPTY0004: A key of a map should be a single atomizable value.");},m:e=>e}));return tb(c,d=>w.m(new wb(d.map((e,f)=>({key:e,value:Ra(A(this.l[f].value,a,b))})))))}};var fi=class extends C{constructor(a,b,c){super(new D({external:1}),[],{B:!0},!1,c);this.s=b;this.A=a;this.l=null}h(){const a=new Va({j:this.l.j,H:this.l.H,arity:this.s,localName:this.l.localName,namespaceURI:this.l.namespaceURI,i:this.l.i,value:this.l.callFunction});return w.m(a)}v(a){let b=this.A.namespaceURI,c=this.A.localName;const d=this.A.prefix;if(null===b){const e=a.Ua({localName:c,prefix:d},this.s);if(!e)throw Error(`XPST0017: The function ${d?d+":":""}${c} with arity ${this.s} could not be resolved. ${mg(c)}`);
236
+ b=e.namespaceURI;c=e.localName}this.l=a.ua(b,c,this.s)||null;if(!this.l)throw a=this.A,Error(`XPST0017: Function ${`${a.namespaceURI?`Q{${a.namespaceURI}}`:a.prefix?`${a.prefix}:`:""}${a.localName}`} with arity of ${this.s} not registered. ${mg(c)}`);super.v(a)}};const gi={[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};
237
+ var hi=class extends C{constructor(a,b,c){super(b.o,[b],{B:!1},!1,c);this.s=b;this.l=a}h(a,b){return rc(A(this.s,a,b),b).M(c=>{if(0===c.length)return w.empty();var d=c[0];if(this.type)return c="+"===this.l?+d.value:-d.value,0===d.type&&(c=Number.NaN),w.m(g(c,this.type.type));if(1<c.length)throw Error("XPTY0004: The operand to a unary operator must be a sequence with a length less than one");return v(d.type,19)?(d=kd(d,3).value,w.m(g("+"===this.l?d:-d,3))):v(d.type,2)?"+"===this.l?w.m(d):w.m(g(-1*
238
+ d.value,gi[d.type])):w.m(g(Number.NaN,3))})}};var ii=class extends C{constructor(a,b){super(a.reduce((c,d)=>c.add(d.o),new D({})),a,{B:a.every(c=>c.B)},!1,b);this.l=a;this.s=a.reduce((c,d)=>vh(c,d.D()),null)}h(a,b){let c=0,d=null,e=!1,f=null;if(null!==a){const h=a.L;null!==h&&v(h.type,53)&&(f=Xa(h.value))}return w.create({next:()=>{if(!e){for(;c<this.l.length;){if(!d){const h=this.l[c];if(null!==f&&null!==h.D()&&!f.includes(h.D()))return c++,e=!0,q(wa);d=A(h,a,b)}if(!1===d.ea())return e=!0,q(wa);d=null;c++}e=!0;return q(va)}return p}})}D(){return this.s}};var ji=class extends C{constructor(a,b){super(a.reduce((d,e)=>0<uf(d,e.o)?d:e.o,new D({})),a,{B:a.every(d=>d.B)},!1,b);let c;for(b=0;b<a.length;++b){const d=a[b].D();void 0===c&&(c=d);if(null===c)break;c=wh(c,d)}this.s=c;this.l=a}h(a,b){let c=0,d=null,e=!1,f=null;if(null!==a){const h=a.L;null!==h&&v(h.type,53)&&(f=Xa(h.value))}return w.create({next:()=>{if(!e){for(;c<this.l.length;){if(!d){const h=this.l[c];if(null!==f&&null!==h.D()&&!f.includes(h.D())){c++;continue}d=A(h,a,b)}if(!0===d.ea())return e=
239
+ !0,q(va);d=null;c++}e=!0;return q(wa)}return p}})}D(){return this.s}};function ki(a,b){let c;return w.create({next:d=>{for(;;){if(!c){var e=a.value.next(d);if(e.done)return p;c=qc(e.value,b)}e=c.value.next(d);if(e.done)c=null;else return e}}})};function li(a,b){if("eqOp"===a)return(c,d)=>{const {T:e,U:f}=b(c,d);return e.value.namespaceURI===f.value.namespaceURI&&e.value.localName===f.value.localName};if("neOp"===a)return(c,d)=>{const {T:e,U:f}=b(c,d);return e.value.namespaceURI!==f.value.namespaceURI||e.value.localName!==f.value.localName};throw Error('XPTY0004: Only the "eq" and "ne" comparison is defined for xs:QName');}
240
+ function mi(a,b){switch(a){case "eqOp":return(c,d)=>{const {T:e,U:f}=b(c,d);return e.value===f.value};case "neOp":return(c,d)=>{const {T:e,U:f}=b(c,d);return e.value!==f.value};case "ltOp":return(c,d)=>{const {T:e,U:f}=b(c,d);return e.value<f.value};case "leOp":return(c,d)=>{const {T:e,U:f}=b(c,d);return e.value<=f.value};case "gtOp":return(c,d)=>{const {T:e,U:f}=b(c,d);return e.value>f.value};case "geOp":return(c,d)=>{const {T:e,U:f}=b(c,d);return e.value>=f.value}}}
241
+ function ni(a,b){switch(a){case "ltOp":return(c,d)=>{const {T:e,U:f}=b(c,d);return e.value.da<f.value.da};case "leOp":return(c,d)=>{const {T:e,U:f}=b(c,d);return e.value.equals(f.value)||e.value.da<f.value.da};case "gtOp":return(c,d)=>{const {T:e,U:f}=b(c,d);return e.value.da>f.value.da};case "geOp":return(c,d)=>{const {T:e,U:f}=b(c,d);return e.value.equals(f.value)||e.value.da>f.value.da}}}
242
+ function oi(a,b){switch(a){case "eqOp":return(c,d)=>{const {T:e,U:f}=b(c,d);return e.value.equals(f.value)};case "ltOp":return(c,d)=>{const {T:e,U:f}=b(c,d);return e.value.ba<f.value.ba};case "leOp":return(c,d)=>{const {T:e,U:f}=b(c,d);return e.value.equals(f.value)||e.value.ba<f.value.ba};case "gtOp":return(c,d)=>{const {T:e,U:f}=b(c,d);return e.value.ba>f.value.ba};case "geOp":return(c,d)=>{const {T:e,U:f}=b(c,d);return e.value.equals(f.value)||e.value.ba>f.value.ba}}}
243
+ function pi(a,b){switch(a){case "eqOp":return(c,d)=>{const {T:e,U:f}=b(c,d);return e.value.equals(f.value)};case "neOp":return(c,d)=>{const {T:e,U:f}=b(c,d);return!e.value.equals(f.value)}}}
244
+ function qi(a,b){switch(a){case "eqOp":return(c,d,e)=>{const {T:f,U:h}=b(c,d);return Pb(f.value,h.value,gc(e))};case "neOp":return(c,d,e)=>{const {T:f,U:h}=b(c,d);return!Pb(f.value,h.value,gc(e))};case "ltOp":return(c,d,e)=>{const {T:f,U:h}=b(c,d);c=gc(e);return 0>Ob(f.value,h.value,c)};case "leOp":return(c,d,e)=>{const {T:f,U:h}=b(c,d);(c=Pb(f.value,h.value,gc(e)))||(e=gc(e),c=0>Ob(f.value,h.value,e));return c};case "gtOp":return(c,d,e)=>{const {T:f,U:h}=b(c,d);c=gc(e);return 0<Ob(f.value,h.value,
245
+ c)};case "geOp":return(c,d,e)=>{const {T:f,U:h}=b(c,d);(c=Pb(f.value,h.value,gc(e)))||(e=gc(e),c=0<Ob(f.value,h.value,e));return c}}}function ri(a,b){switch(a){case "eqOp":return(c,d,e)=>{const {T:f,U:h}=b(c,d);return Pb(f.value,h.value,gc(e))};case "neOp":return(c,d,e)=>{const {T:f,U:h}=b(c,d);return!Pb(f.value,h.value,gc(e))}}}
246
+ function si(a,b,c){function d(n,t){return{T:h?h(n):n,U:k?k(t):t}}function e(n){return v(b,n)&&v(c,n)}function f(n){return 0<n.filter(t=>v(b,t)).length&&0<n.filter(t=>v(c,t)).length}let h=null,k=null;v(b,19)&&v(c,19)?b=c=1:v(b,19)?(h=n=>kd(n,c),b=c):v(c,19)&&(k=n=>kd(n,b),c=b);if(v(b,23)&&v(c,23))return li(a,d);if(e(0)||f([1,47,61])||f([2,47,61])||e(20)||e(22)||e(21)||f([1,20])){var l=mi(a,d);if(void 0!==l)return l}if(e(16)&&(l=ni(a,d),void 0!==l)||e(17)&&(l=oi(a,d),void 0!==l)||e(18)&&(l=pi(a,d),
247
+ void 0!==l))return l;if(e(9)||e(7)||e(8))if(l=qi(a,d),void 0!==l)return l;if(e(11)||e(12)||e(13)||e(14)||e(15))if(l=ri(a,d),void 0!==l)return l;throw Error(`XPTY0004: ${a} not available for ${Da[b]} and ${Da[c]}`);}const ti=Object.create(null);function ui(a,b,c){const d=`${b}~${c}~${a}`;let e=ti[d];e||=ti[d]=si(a,b,c);return e}
248
+ var vi=class extends C{constructor(a,b,c){super(b.o.add(c.o),[b,c],{B:!1});this.l=b;this.A=c;this.s=a}h(a,b){const c=A(this.l,a,b),d=A(this.A,a,b),e=ki(c,b),f=ki(d,b);return e.X({empty:()=>w.empty(),m:()=>f.X({empty:()=>w.empty(),m:()=>{const h=e.first(),k=f.first();return ui(this.s,h.type,k.type)(h,k,a)?w.$():w.S()},multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton.");}}),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton.");}})}};const wi={equalOp:"eqOp",notEqualOp:"neOp",lessThanOrEqualOp:"leOp",lessThanOp:"ltOp",greaterThanOrEqualOp:"geOp",greaterThanOp:"gtOp"};
249
+ function xi(a,b,c,d){a=wi[a];return c.M(e=>b.filter(f=>{for(let l=0,n=e.length;l<n;++l){let t=e[l],u=void 0,z=void 0;var h=f.type,k=t.type;if(v(h,19)||v(k,19))v(h,2)?u=3:v(k,2)?z=3:v(h,17)?u=17:v(k,17)?z=17:v(h,16)?u=16:v(k,16)?z=16:v(h,19)?z=k:v(k,19)&&(u=h);const [y,F]=[z,u];h=y;k=F;h?f=kd(f,h):k&&(t=kd(t,k));if(ui(a,f.type,t.type)(f,t,d))return!0}return!1}).X({default:()=>w.$(),empty:()=>w.S()}))}
250
+ var yi=class extends C{constructor(a,b,c){super(b.o.add(c.o),[b,c],{B:!1});this.l=b;this.A=c;this.s=a}h(a,b){const c=A(this.l,a,b),d=A(this.A,a,b);return c.X({empty:()=>w.S(),default:()=>d.X({empty:()=>w.S(),default:()=>{const e=ki(c,b),f=ki(d,b);return xi(this.s,e,f,a)}})})}};function zi(a,b,c,d){if(!v(c,53)||!v(d,53))throw Error("XPTY0004: Sequences to compare are not nodes");switch(a){case "isOp":return Ai(c,d);case "nodeBeforeOp":return b?(e,f)=>0>td(b,e.first(),f.first()):void 0;case "nodeAfterOp":return b?(e,f)=>0<td(b,e.first(),f.first()):void 0;default:throw Error("Unexpected operator");}}function Ai(a,b){return a!==b||47!==a&&53!==a&&54!==a&&55!==a&&56!==a&&57!==a&&58!==a?()=>!1:(c,d)=>nd(c.first().value,d.first().value)}
251
+ var Bi=class extends C{constructor(a,b,c){super(b.o.add(c.o),[b,c],{B:!1});this.l=b;this.A=c;this.s=a}h(a,b){const c=A(this.l,a,b),d=A(this.A,a,b);return c.X({empty:()=>w.empty(),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton");},m:()=>d.X({empty:()=>w.empty(),multiple:()=>{throw Error("XPTY0004: Sequences to compare are not singleton");},m:()=>{const e=c.first(),f=d.first();return zi(this.s,b.h,e.type,f.type)(c,d,a)?w.$():w.S()}})})}};function Ci(a,b,c,d){return c.M(e=>{if(e.some(f=>!v(f.type,53)))throw Error(`XPTY0004: Sequences given to ${a} should only contain nodes.`);return"sorted"===d?w.create(e):"reverse-sorted"===d?w.create(e.reverse()):w.create(ud(b,e))})}
252
+ var Di=class extends C{constructor(a,b,c,d){super(0<uf(b.o,c.o)?b.o:c.o,[b,c],{B:b.B&&c.B},!1,d);this.l=a;this.s=b;this.A=c}h(a,b){const c=Ci(this.l,b.h,A(this.s,a,b),this.s.ha);a=Ci(this.l,b.h,A(this.A,a,b),this.A.ha);const d=c.value,e=a.value;let f=null,h=null,k=!1,l=!1;return w.create({next:()=>{if(k)return p;for(;!l;){if(!f){var n=d.next(0);if(n.done)return k=!0,p;f=n.value}if(!h){n=e.next(0);if(n.done){l=!0;break}h=n.value}if(nd(f.value,h.value)){if(n=q(f),h=f=null,"intersectOp"===this.l)return n}else if(0>
253
+ td(b.h,f,h)){if(n=q(f),f=null,"exceptOp"===this.l)return n}else h=null}if("exceptOp"===this.l)return null!==f?(n=q(f),f=null,n):d.next(0);k=!0;return p}})}};var Ei=class extends rf{constructor(a,b){super(a.reduce((c,d)=>c.add(d.o),new D({})),a,{P:"unsorted",B:a.every(c=>c.B)},b)}A(a,b,c){return c.length?kc(c.map(d=>d(a))):w.empty()}};var Fi=class extends C{constructor(a,b,c){super((new D({})).add(a.o),[a,b],{B:a.B&&b.B},!1,c);this.l=a;this.s=b}h(a,b){const c=A(this.l,a,b),d=ec(a,c);let e=null,f=null,h=!1;return w.create({next:k=>{for(;!h;){if(!e&&(e=d.next(k),e.done))return h=!0,p;f||=A(this.s,e.value,b);const l=f.value.next(k);if(l.done)e=f=null;else return l}}})}};var Gi=class extends C{constructor(a,b,c){super(a.o,[a],{B:!1});this.l=Ia(b.prefix?`${b.prefix}:${b.localName}`:b.localName);if(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(b.namespaceURI)throw Error("Not implemented: castable as expressions with a namespace URI.");this.A=a;this.s=c}h(a,b){const c=rc(A(this.A,a,b),b);return c.X({empty:()=>this.s?w.$():w.S(),m:()=>c.map(d=>jd(d,this.l).u?va:wa),multiple:()=>
254
+ w.S()})}};var Hi=class extends C{constructor(a,b,c){super(a.o,[a],{B:!1});this.l=Ia(b.prefix?`${b.prefix}:${b.localName}`:b.localName);if(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(b.namespaceURI)throw Error("Not implemented: casting expressions with a namespace URI.");this.A=a;this.s=c}h(a,b){const c=rc(A(this.A,a,b),b);return c.X({empty:()=>{if(!this.s)throw Error("XPTY0004: Sequence to cast is empty while target type is singleton.");
255
+ return w.empty()},m:()=>c.map(d=>kd(d,this.l)),multiple:()=>{throw Error("XPTY0004: Sequence to cast is not singleton or empty.");}})}};function Ii(a,b){const c=a.value;let d=null,e=!1;return w.create({next:()=>{for(;!e;){if(!d){var f=c.next(0);if(f.done)return e=!0,q(va);d=b(f.value)}f=d.ea();d=null;if(!1===f)return e=!0,q(wa)}return p}})};var Ji=class extends C{constructor(a,b,c,d){super(a.o,[a,b],{B:!1},!1,d);this.A=a;this.s=b;this.l=c}h(a,b){const c=A(this.A,a,b);return c.X({empty:()=>"?"===this.l||"*"===this.l?w.$():w.S(),multiple:()=>"+"===this.l||"*"===this.l?Ii(c,d=>{const e=w.m(d);d=cc(a,0,d,e);return A(this.s,d,b)}):w.S(),m:()=>Ii(c,d=>{const e=w.m(d);d=cc(a,0,d,e);return A(this.s,d,b)})})}};function Ki(a,b){return null!==a&&null!==b&&v(a.type,53)&&v(b.type,53)?nd(a.value,b.value):!1}function Li(a){let b=a.next(0);if(b.done)return w.empty();let c=null,d=null;return w.create({next(e){if(b.done)return p;c||(c=b.value.value);let f;do if(f=c.next(e),f.done){b=a.next(0);if(b.done)return f;c=b.value.value}while(f.done||Ki(f.value,d));d=f.value;return f}})}
256
+ function Mi(a,b){const c=[];(function(){for(var f=b.next(0);!f.done;){const h=f.value.value;f={current:h.next(0),next:k=>h.next(k)};f.current.done||c.push(f);f=b.next(0)}})();let d=null,e=!1;return w.create({[Symbol.iterator](){return this},next:()=>{e||(e=!0,c.every(h=>v(h.current.value.type,53))&&c.sort((h,k)=>td(a,h.current.value,k.current.value)));let f;do{if(!c.length)return p;const h=c.shift();f=h.current;h.current=h.next(0);if(!v(f.value.type,53))return f;if(!h.current.done){let k=0,l=c.length-
257
+ 1,n=0;for(;k<=l;){n=Math.floor((k+l)/2);const t=td(a,h.current.value,c[n].current.value);if(0===t){k=n;break}0<t?k=n+1:l=n-1}c.splice(k,0,h)}}while(Ki(f.value,d));d=f.value;return f}})};var Ni=class extends C{constructor(a,b){super(a.reduce((c,d)=>0<uf(c,d.o)?c:d.o,new D({})),a,{B:a.every(c=>c.B)},!1,b);this.l=a}h(a,b){if(this.l.every(c=>"sorted"===c.ha)){let c=0;return Mi(b.h,{next:()=>c>=this.l.length?p:q(A(this.l[c++],a,b))}).map(d=>{if(!v(d.type,53))throw Error("XPTY0004: The sequences to union are not of type node()*");return d})}return kc(this.l.map(c=>A(c,a,b))).M(c=>{if(c.some(d=>!v(d.type,53)))throw Error("XPTY0004: The sequences to union are not of type node()*");c=ud(b.h,
258
+ c);return w.create(c)})}};function Oi(a){return a.every(b=>null===b||v(b.type,5)||v(b.type,4))||null!==a.map(b=>b?sc(b.type):null).reduce((b,c)=>null===c?b:c===b?b:null)?a:a.every(b=>null===b||v(b.type,1)||v(b.type,20))?a.map(b=>b?kd(b,1):null):a.every(b=>null===b||v(b.type,4)||v(b.type,6))?a.map(b=>b?kd(b,6):b):a.every(b=>null===b||v(b.type,4)||v(b.type,6)||v(b.type,3))?a.map(b=>b?kd(b,3):b):null};function Pi(a){return(a=a.find(b=>!!b))?sc(a.type):null}
259
+ var Qi=class extends Zh{constructor(a,b){super(new D({}),[b,...a.map(c=>c.aa)],{B:!1,V:!1,P:"unsorted",subtree:!1},b);this.A=a}K(a,b,c,d){if(this.A[1])throw Error("More than one order spec is not supported for the order by clause.");const e=[];let f=!1,h,k,l=null;const n=this.A[0];return w.create({next:()=>{if(!f){for(var t=b.next(0);!t.done;)e.push(t.value),t=b.next(0);t=e.map(z=>n.aa.h(z,c)).map(z=>rc(z,c));if(t.find(z=>!z.isEmpty()&&!z.oa()))throw Error("XPTY0004: Order by only accepts empty or singleton sequences");h=
260
+ t.map(z=>z.first());h=h.map(z=>null===z?z:v(19,z.type)?kd(z,1):z);if(Pi(h)&&(h=Oi(h),!h))throw Error("XPTY0004: Could not cast values");t=h.length;k=h.map((z,y)=>y);for(let z=0;z<t;z++)if(z+1!==t)for(let y=z;0<=y;y--){const F=y,N=y+1;if(N===t)continue;const U=h[k[F]],da=h[k[N]];if(null!==da||null!==U){if(n.ec){if(null===U)continue;if(null===da&&null!==U){[k[F],k[N]]=[k[N],k[F]];continue}if(isNaN(da.value)&&null!==U&&!isNaN(U.value)){[k[F],k[N]]=[k[N],k[F]];continue}}else{if(null===da)continue;if(null===
261
+ U&&null!==da){[k[F],k[N]]=[k[N],k[F]];continue}if(isNaN(U.value)&&null!==da&&!isNaN(da.value)){[k[F],k[N]]=[k[N],k[F]];continue}}ui("gtOp",U.type,da.type)(U,da,a)&&([k[F],k[N]]=[k[N],k[F]])}}let u=n.Cb?0:h.length-1;l=d({next:()=>n.Cb?u>=h.length?p:q(e[k[u++]]):0>u?p:q(e[k[u--]])}).value;f=!0}return l.next(0)}})}};var Ri=class extends C{constructor(a){super(a?a.o:new D({}),a?[a]:[],{P:"sorted",subtree:!1,V:!1,B:!1});this.l=a}h(a,b){if(null===a.L)throw mc("context is absent, it needs to be present to use paths.");var c=b.h;let d=a.L.value;for(;9!==d.node.nodeType;)if(d=x(c,d),null===d)throw Error("XPDY0050: the root node of the context node is not a document node.");c=w.m(sb(d));return this.l?A(this.l,cc(a,0,c.first(),c),b):c}};var Si=class extends C{constructor(a){super(new D({}),[],{P:"sorted"},!1,a)}h(a){if(null===a.L)throw mc('context is absent, it needs to be present to use the "." operator');return w.m(a.L)}};function Ti(a,b){let c=!1,d=!1;b.forEach(e=>{v(e.type,53)?c=!0:d=!0});if(d&&c)throw Error("XPTY0018: The path operator should either return nodes or non-nodes. Mixed sequences are not allowed.");return c?ud(a,b):b}
262
+ var Ui=class extends C{constructor(a,b){const c=a.every(e=>e.V),d=a.every(e=>e.subtree);super(a.reduce((e,f)=>e.add(f.o),new D({})),a,{B:!1,V:c,P:b?"sorted":"unsorted",subtree:d});this.l=a;this.s=b}h(a,b){let c=!0;return this.l.reduce((d,e,f)=>{const h=null===d?ld(a):ec(a,d);d={next:l=>{l=h.next(l);if(l.done)return p;if(null!==l.value.L&&!v(l.value.L.type,53)&&0<f)throw Error("XPTY0019: The result of E1 in a path expression E1/E2 should not evaluate to a sequence of nodes.");return q(A(e,l.value,
263
+ b))}};let k;if(this.s)switch(e.ha){case "reverse-sorted":const l=d;d={next:n=>{n=l.next(n);return n.done?n:q(n.value.M(t=>w.create(t.reverse())))}};case "sorted":if(e.subtree&&c){k=Li(d);break}k=Mi(b.h,d);break;case "unsorted":return Li(d).M(n=>w.create(Ti(b.h,n)))}else k=Li(d);c=c&&e.V;return k},null)}D(){return this.l[0].D()}};var Vi=class extends C{constructor(a,b){super(a.o.add(b.o),[a,b],{B:a.B&&b.B,V:a.V,P:a.ha,subtree:a.subtree});this.s=a;this.l=b}h(a,b){const c=A(this.s,a,b);if(this.l.B){const k=A(this.l,a,b);if(k.isEmpty())return k;const l=k.first();if(v(l.type,2)){let n=l.value;if(!Number.isInteger(n))return w.empty();const t=c.value;let u=!1;return w.create({next:()=>{if(!u){for(let z=t.next(0);!z.done;z=t.next(0))if(1===n--)return u=!0,z;u=!0}return p}})}return k.ea()?c:w.empty()}const d=c.value;let e=null,f=
264
+ 0,h=null;return w.create({next:k=>{let l=!1;for(;!e||!e.done;){e||(e=d.next(l?0:k),l=!0);if(e.done)break;h||=A(this.l,cc(a,f,e.value,c),b);var n=h.first();n=null===n?!1:v(n.type,2)?n.value===f+1:h.ea();h=null;const t=e.value;e=null;f++;if(n)return q(t)}return e}})}D(){return this.s.D()}};function Wi(a,b,c){c=[c];if(v(a.type,62))if("*"===b)c.push(...a.members.map(d=>d()));else if(v(b.type,5)){const d=b.value;if(a.members.length<d||0>=d)throw Error("FOAY0001: Array index out of bounds");c.push(a.members[d-1]())}else throw Error("XPTY0004: The key specifier is not an integer.");else if(v(a.type,61))"*"===b?c.push(...a.h.map(d=>d.value())):(a=a.h.find(d=>ub(d.key,b)))&&c.push(a.value());else throw Error("XPTY0004: The provided context item is not a map or an array.");return kc(c)}
265
+ function Xi(a,b,c,d,e){if("*"===b)return Wi(a,b,c);b=A(b,d,e);b=Ra(b)().M(f=>f.reduce((h,k)=>Wi(a,k,h),new Ba));return kc([c,b])};var Yi=class extends C{constructor(a,b){super(a.o,[a].concat("*"===b?[]:[b]),{B:a.B,P:a.ha,subtree:a.subtree});this.l=a;this.s=b}h(a,b){return A(this.l,a,b).M(c=>c.reduce((d,e)=>Xi(e,this.s,d,a,b),new Ba))}D(){return this.l.D()}};var Zi=class extends C{constructor(a,b){super(new D({external:1}),"*"===a?[]:[a],{B:!1},!1,b);this.l=a}h(a,b){return Xi(a.L,this.l,new Ba,a,b)}};var $i=class extends C{constructor(a,b,c,d){const e=b.map(f=>f.fb);b=b.map(f=>f.name);super(e.reduce((f,h)=>f.add(h.o),c.o),e.concat(c),{B:!1},!1,d);this.s=a;this.A=b;this.K=e;this.O=c;this.l=null}h(a,b){let c=a;const d=this.l.map((k,l)=>{const n=A(this.K[l],c,b).N();c=ic(a,{[k]:()=>w.create(n)});return n});if(d.some(k=>0===k.length))return"every"===this.s?w.$():w.S();const e=Array(d.length).fill(0);e[0]=-1;for(var f=!0;f;){f=!1;for(let k=0,l=e.length;k<l;++k){var h=d[k];if(++e[k]>h.length-1)e[k]=
266
+ 0;else{f=Object.create(null);for(h=0;h<e.length;h++){const n=d[h][e[h]];f[this.l[h]]=()=>w.m(n)}f=ic(a,f);f=A(this.O,f,b);if(f.ea()&&"some"===this.s)return w.$();if(!f.ea()&&"every"===this.s)return w.S();f=!0;break}}}return"every"===this.s?w.$():w.S()}v(a){this.l=[];for(let c=0,d=this.A.length;c<d;++c){this.K[c].v(a);Dg(a);var b=this.A[c];const e=b.prefix?a.Z(b.prefix):null;b=Hg(a,e,b.localName);this.l[c]=b}this.O.v(a);for(let c=0,d=this.A.length;c<d;++c)Jg(a)}};var aj=class extends xh{constructor(a){super(new D({nodeType:1}));this.s=a}l(a,b){if(!v(b.type,53))return!1;a=b.value.node.nodeType;return 3===this.s&&4===a?!0:this.s===a}D(){return`type-${this.s}`}};var bj=class extends xh{constructor(a,b={kind:null}){const c=a.prefix,d=a.namespaceURI;a=a.localName;const e={};"*"!==a&&(e.nodeName=1);e.nodeType=1;super(new D(e));this.s=a;this.K=d;this.A=c;this.O=b.kind}l(a,b){a=v(b.type,54);const c=v(b.type,47);if(!a&&!c)return!1;b=b.value;return null!==this.O&&(1===this.O&&!a||2===this.O&&!c)?!1:null===this.A&&""!==this.K&&"*"===this.s?!0:"*"===this.A?"*"===this.s?!0:this.s===b.node.localName:"*"!==this.s&&this.s!==b.node.localName?!1:(b.node.namespaceURI||null)===
267
+ ((""===this.A?a?this.K:null:this.K)||null)}D(){return"*"===this.s?null===this.O?"type-1-or-type-2":`type-${this.O}`:`name-${this.s}`}v(a){if(null===this.K&&"*"!==this.A&&(this.K=a.Z(this.A||"")||null,!this.K&&this.A))throw Error(`XPST0081: The prefix ${this.A} could not be resolved.`);}};var cj=class extends xh{constructor(a){super(new D({nodeName:1}));this.s=a}l(a,b){return v(b.type,57)&&b.value.node.target===this.s}D(){return"type-7"}};var dj=class extends xh{constructor(a){super(new D({}));this.s=a}l(a,b){return v(b.type,Ia(this.s.prefix?this.s.prefix+":"+this.s.localName:this.s.localName))}};var ej=class extends C{constructor(a,b,c){super(new D({}),[],{B:!1,P:"unsorted"});this.A=c;this.s=b;this.K=a;this.l=null}h(a,b){if(!a.qa[this.l]){if(this.O)return this.O(a,b);throw Error("XQDY0054: The variable "+this.A+" is declared but not in scope.");}return a.qa[this.l]()}v(a){null===this.s&&this.K&&(this.s=a.Z(this.K));this.l=a.eb(this.s||"",this.A);if(!this.l)throw Error("XPST0008, The variable "+this.A+" is not in scope.");if(a=a.Fa[this.l])this.O=a}};var fj=class extends Zh{constructor(a,b){super(new D({}),[a,b],{B:!1,V:!1,P:"unsorted",subtree:!1},b);this.A=a}K(a,b,c,d){let e=null,f=null;return d({next:()=>{for(;;){if(!f){var h=b.next(0);if(h.done)return p;e=h.value;f=A(this.A,e,c)}h=f.ea();const k=e;f=e=null;if(h)return q(k)}}})}};var gj=class{constructor(a){this.type=a}};var hj=class extends gj{constructor(a){super("delete");this.target=a}h(a){return{type:this.type,target:ag(this.target,a,!1)}}};var ij=class extends gj{constructor(a,b,c){super(c);this.target=a;this.content=b}h(a){return{type:this.type,target:ag(this.target,a,!1),content:this.content.map(b=>ag(b,a,!0))}}};var jj=class extends ij{constructor(a,b){super(a,b,"insertAfter")}};var kj=class extends gj{constructor(a,b){super("insertAttributes");this.target=a;this.content=b}h(a){return{type:this.type,target:ag(this.target,a,!1),content:this.content.map(b=>ag(b,a,!0))}}};var lj=class extends ij{constructor(a,b){super(a,b,"insertBefore")}};var mj=class extends ij{constructor(a,b){super(a,b,"insertIntoAsFirst")}};var nj=class extends ij{constructor(a,b){super(a,b,"insertIntoAsLast")}};var oj=class extends ij{constructor(a,b){super(a,b,"insertInto")}};var pj=class extends gj{constructor(a,b){super("rename");this.target=a;this.o=b.Aa?b:new Sa(b.prefix,b.namespaceURI,b.localName)}h(a){return{type:this.type,target:ag(this.target,a,!1),newName:{prefix:this.o.prefix,namespaceURI:this.o.namespaceURI,localName:this.o.localName}}}};var qj=class extends gj{constructor(a,b){super("replaceElementContent");this.target=a;this.text=b}h(a){return{type:this.type,target:ag(this.target,a,!1),text:this.text?ag(this.text,a,!0):null}}};var rj=class extends gj{constructor(a,b){super("replaceNode");this.target=a;this.o=b}h(a){return{type:this.type,target:ag(this.target,a,!1),replacement:this.o.map(b=>ag(b,a,!0))}}};var sj=class extends gj{constructor(a,b){super("replaceValue");this.target=a;this.o=b}h(a){return{type:this.type,target:ag(this.target,a,!1),["string-value"]:this.o}}};var tj=(a,b)=>new rj(a,b);var uj=class extends of{constructor(a){super(new D({}),[a],{B:!1,P:"unsorted"});this.l=a}s(a,b){const c=nf(this.l)(a,b),d=b.h;let e,f;return{next:()=>{if(!e){const h=c.next(0);if(h.value.I.some(k=>!v(k.type,53)))throw Error("XUTY0007: The target of a delete expression must be a sequence of zero or more nodes.");e=h.value.I;f=h.value.ca}e=e.filter(h=>x(d,h.value));return q({ca:mf(e.map(h=>new hj(h.value)),f),I:[]})}}}};function vj(a,b,c,d,e,f){const h=b.h;a.reduce(function t(l,n){if(v(n.type,62))return n.members.forEach(u=>u().N().forEach(z=>t(l,z))),l;l.push(n);return l},[]).forEach((l,n,t)=>{if(v(l.type,47)){if(e)throw f(l.value,h);c.push(l.value.node)}else if(v(l.type,46)||v(l.type,53)&&3===l.value.node.nodeType){const u=v(l.type,46)?kd(qc(l,b).first(),1).value:hb(h,l.value);0!==n&&v(t[n-1].type,46)&&v(l.type,46)?(d.push({data:" "+u,Ta:!0,nodeType:3}),e=!0):u&&(d.push({data:""+u,Ta:!0,nodeType:3}),e=!0)}else if(v(l.type,
268
+ 55)){const u=[];gb(h,l.value).forEach(z=>u.push(sb(z)));e=vj(u,b,c,d,e,f)}else if(v(l.type,53))d.push(l.value.node),e=!0;else{if(v(l.type,60))throw oc(l.type);throw Error(`Atomizing ${l.type} is not implemented.`);}});return e}function wj(a,b,c){const d=[],e=[];let f=!1;a.forEach(h=>{f=vj(h,b,d,e,f,c)});return{attributes:d,Ya:e}};function xj(a,b,c,d,e){const f=[];switch(a){case 4:d.length&&f.push(new kj(b,d));e.length&&f.push(new mj(b,e));break;case 5:d.length&&f.push(new kj(b,d));e.length&&f.push(new nj(b,e));break;case 3:d.length&&f.push(new kj(b,d));e.length&&f.push(new oj(b,e));break;case 2:d.length&&f.push(new kj(c,d));e.length&&f.push(new lj(b,e));break;case 1:d.length&&f.push(new kj(c,d)),e.length&&f.push(new jj(b,e))}return f}
269
+ var yj=class extends of{constructor(a,b,c){super(new D({}),[a,c],{B:!1,P:"unsorted"});this.K=a;this.l=b;this.A=c}s(a,b){const c=nf(this.K)(a,b),d=nf(this.A)(a,b),e=b.h;let f,h,k,l,n,t;return{next:()=>{if(!f){var u=c.next(0);const z=wj([u.value.I],b,Pe);f=z.attributes.map(y=>({node:y,F:null}));h=z.Ya.map(y=>({node:y,F:null}));k=u.value.ca}if(!l){u=d.next(0);if(0===u.value.I.length)throw Ye();if(3<=this.l){if(1!==u.value.I.length)throw Qe();if(!v(u.value.I[0].type,54)&&!v(u.value.I[0].type,55))throw Qe();
270
+ }else{if(1!==u.value.I.length)throw Re();if(!(v(u.value.I[0].type,54)||v(u.value.I[0].type,56)||v(u.value.I[0].type,58)||v(u.value.I[0].type,57)))throw Re();t=x(e,u.value.I[0].value,null);if(null===t)throw Error(`XUDY0029: The target ${u.value.I[0].value.outerHTML} for inserting a node before or after must have a parent.`);}l=u.value.I[0];n=u.value.ca}if(f.length){if(3<=this.l){if(!v(l.type,54))throw Error("XUTY0022: An insert expression specifies the insertion of an attribute node into a document node.");
271
+ }else if(1!==t.node.nodeType)throw Error("XUDY0030: An insert expression specifies the insertion of an attribute node before or after a child of a document node.");f.reduce((z,y)=>{const F=y.node.prefix||"";var N=y.node.prefix||"";const U=y.node.namespaceURI,da=N?l.value.node.lookupNamespaceURI(N):null;if(da&&da!==U)throw We(U);if((N=z[N])&&U!==N)throw Xe(U);z[F]=y.node.namespaceURI;return z},{})}return q({I:[],ca:mf(xj(this.l,l.value,t?t:null,f,h),k,n)})}}}};const zj=()=>nc("Casting not supported from given type to a single xs:string or xs:untypedAtomic or any of its derived types."),Aj=/([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])/,Bj=new RegExp(`${Aj.source}${(new RegExp(`(${Aj.source}|[-.0-9\xB7\u0300-\u036F\u203F\u2040])`)).source}*`,"g"),Cj=a=>(a=a.match(Bj))?1===a.length:!1;
272
+ function Dj(a,b){return rc(b,a).X({m:c=>{c=c.first();if(v(c.type,1)||v(c.type,19)){if(!Cj(c.value))throw Error(`XQDY0041: The value "${c.value}" of a name expressions cannot be converted to a NCName.`);return w.m(c)}throw zj();},default:()=>{throw zj();}}).value}
273
+ function Ej(a,b,c){return rc(c,b).X({m:d=>{d=d.first();if(v(d.type,23))return w.m(d);if(v(d.type,1)||v(d.type,19)){let e,f;d=d.value.split(":");1===d.length?d=d[0]:(e=d[0],f=a.Z(e),d=d[1]);if(!Cj(d)||e&&!Cj(e))throw yg(e?`${e}:${d}`:d);if(e&&!f)throw yg(`${e}:${d}`);return w.m({type:23,value:new Sa(e,f,d)})}throw zj();},default:()=>{throw zj();}}).value};var Fj=class extends of{constructor(a,b){super(new D({}),[a,b],{B:!1,P:"unsorted"});this.A=a;this.K=b;this.l=void 0}s(a,b){const c=nf(this.A)(a,b),d=nf(this.K)(a,b);return{next:()=>{const e=c.next(0);var f=e.value.I;if(0===f.length)throw Ye();if(1!==f.length)throw Te();if(!v(f[0].type,54)&&!v(f[0].type,47)&&!v(f[0].type,57))throw Te();f=f[0];const h=d.next(0);a:{var k=this.l;var l=w.create(h.value.I);switch(f.type){case 54:k=Ej(k,b,l).next(0).value.value;if((l=f.value.node.lookupNamespaceURI(k.prefix))&&
274
+ l!==k.namespaceURI)throw We(k.namespaceURI);break a;case 47:k=Ej(k,b,l).next(0).value.value;if(k.namespaceURI&&(l=f.value.node.lookupNamespaceURI(k.prefix))&&l!==k.namespaceURI)throw We(k.namespaceURI);break a;case 57:k=Dj(b,l).next(0).value.value;k=new Sa("",null,k);break a}k=void 0}return q({I:[],ca:mf([new pj(f.value,k)],e.value.ca,h.value.ca)})}}}v(a){this.l=Ff(a);super.v(a)}};function Gj(a,b,c){let d,e,f;return{next:()=>{if(!d){var h=c.next(0),k=wj([h.value.I],a,Xe);d={attributes:k.attributes.map(l=>({node:l,F:null})),Ya:k.Ya.map(l=>({node:l,F:null}))};e=h.value.ca}k=b.next(0);if(0===k.value.I.length)throw Ye();if(1!==k.value.I.length)throw Se();if(!(v(k.value.I[0].type,54)||v(k.value.I[0].type,47)||v(k.value.I[0].type,56)||v(k.value.I[0].type,58)||v(k.value.I[0].type,57)))throw Se();f=x(a.h,k.value.I[0].value,null);if(null===f)throw Error(`XUDY0009: The target ${k.value.I[0].value.outerHTML} for replacing a node must have a parent.`);
275
+ h=k.value.I[0];k=k.value.ca;if(v(h.type,47)){if(d.Ya.length)throw Error("XUTY0011: When replacing an attribute the new value must be zero or more attribute nodes.");d.attributes.reduce((l,n)=>{const t=n.node.prefix||"";n=n.node.namespaceURI;var u=f.node.lookupNamespaceURI(t);if(u&&u!==n)throw We(n);if((u=l[t])&&n!==u)throw Xe(n);l[t]=n;return l},{})}else if(d.attributes.length)throw Error("XUTY0010: When replacing an an element, text, comment, or processing instruction node the new value must be a single node.");
276
+ return q({I:[],ca:mf([tj(h.value,[].concat(d.attributes,d.Ya))],e,k)})}}}
277
+ function Vj(a,b,c){let d,e,f,h,k=!1;return{next:()=>{if(k)return p;if(!f){var l=c.next(0);const n=rc(w.create(l.value.I),a).map(t=>kd(t,1)).N().map(t=>t.value).join(" ");f=0===n.length?null:{node:a.Ja.createTextNode(n),F:null};h=l.value.ca}if(!d){l=b.next(0);if(0===l.value.I.length)throw Ye();if(1!==l.value.I.length)throw Se();if(!(v(l.value.I[0].type,54)||v(l.value.I[0].type,47)||v(l.value.I[0].type,56)||v(l.value.I[0].type,58)||v(l.value.I[0].type,57)))throw Se();d=l.value.I[0];e=l.value.ca}if(v(d.type,
278
+ 54))return k=!0,q({I:[],ca:mf([new qj(d.value,f)],h,e)});if(v(d.type,47)||v(d.type,56)||v(d.type,58)||v(d.type,57)){l=f?hb(a.h,f):"";if(v(d.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(v(d.type,57)&&l.includes("?>"))throw Error(`XQDY0026: The content "${l}" for a processing instruction node contains "?>".`);k=!0;return q({I:[],ca:mf([new sj(d.value,l)],h,e)})}}}}
279
+ var Wj=class extends of{constructor(a,b,c){super(new D({}),[b,c],{B:!1,P:"unsorted"});this.K=a;this.l=b;this.A=c}s(a,b){const c=nf(this.l)(a,b);a=nf(this.A)(a,b);return this.K?Vj(b,c,a):Gj(b,c,a)}};function Xj(a){switch(a.type){case "delete":return new hj({node:a.target,F:null});case "insertAfter":return new jj({node:a.target,F:null},a.content.map(b=>({node:b,F:null})));case "insertBefore":return new lj({node:a.target,F:null},a.content.map(b=>({node:b,F:null})));case "insertInto":return new oj({node:a.target,F:null},a.content.map(b=>({node:b,F:null})));case "insertIntoAsFirst":return new mj({node:a.target,F:null},a.content.map(b=>({node:b,F:null})));case "insertIntoAsLast":return new nj({node:a.target,
280
+ F:null},a.content.map(b=>({node:b,F:null})));case "insertAttributes":return new kj({node:a.target,F:null},a.content.map(b=>({node:b,F:null})));case "rename":return new pj({node:a.target,F:null},a.newName);case "replaceNode":return new rj({node:a.target,F:null},a.replacement.map(b=>({node:b,F:null})));case "replaceValue":return new sj({node:a.target,F:null},a["string-value"]);case "replaceElementContent":return new qj({node:a.target,F:null},a.text?{node:a.text,F:null}:null);default:throw Error(`Unexpected type "${a.type}" when parsing a transferable pending update.`);
281
+ }};function Yj(a,b,c){if(b.find(e=>nd(e,a)))return!0;const d=x(c,a);return d?Yj(d,b,c):!1}
282
+ var Zj=class extends of{constructor(a,b,c){super(new D({}),a.reduce((d,e)=>{d.push(e.fb);return d},[b,c]),{B:!1,P:"unsorted"});this.l=a;this.K=b;this.A=c;this.H=null}h(a,b){a=this.s(a,b);return pf(a,()=>{})}s(a,b){const c=b.h,d=b.Ja,e=b.Oa,f=[];let h,k,l;const n=[],t=[];return{next:()=>{if(n.length!==this.l.length)for(var u=n.length;u<this.l.length;u++){const y=this.l[u];var z=f[u];z||(f[u]=z=nf(y.fb)(a,b));z=z.next(0);if(1!==z.value.I.length||!v(z.value.I[0].type,53))throw Error("XUTY0013: The source expression of a copy modify expression must return a single node.");
283
+ const F=sb(Xf(z.value.I[0].value,b));n.push(F.value);t.push(z.value.ca);a=ic(a,{[y.ic]:()=>w.m(F)})}l||(h||=nf(this.K)(a,b),l=h.next(0).value.ca);l.forEach(y=>{if(y.target&&!Yj(y.target,n,c))throw Error(`XUDY0014: The target ${y.target.node.outerHTML} must be a node created by the copy clause.`);if("put"===y.type)throw Error("XUDY0037: The modify expression of a copy modify expression can not contain a fn:put.");});u=l.map(y=>{y=y.h(b);return Xj(y)});lf(u,c,d,e);k||=nf(this.A)(a,b);u=k.next(0);return q({I:u.value.I,
284
+ ca:mf(u.value.ca,...t)})}}}v(a){Dg(a);this.l.forEach(b=>b.ic=Hg(a,b.Lb.namespaceURI,b.Lb.localName));super.v(a);Jg(a);this.H=this.l.some(b=>b.fb.H)||this.A.H}};function ak(a,b){return{node:{nodeType:2,Ta:!0,nodeName:a.Aa(),namespaceURI:a.namespaceURI,prefix:a.prefix,localName:a.localName,name:a.Aa(),value:b},F:null}}
285
+ var bk=class extends C{constructor(a,b){let c=b.nb||[];c=c.concat(a.Pa||[]);super(new D({}),c,{B:!1,P:"unsorted"});a.Pa?this.s=a.Pa:this.name=new Sa(a.prefix,a.namespaceURI,a.localName);this.l=b;this.A=void 0}h(a,b){let c,d,e,f=!1;return w.create({next:()=>{if(f)return p;if(!d){if(this.s){if(!c){var h=this.s.h(a,b);c=Ej(this.A,b,h)}d=c.next(0).value.value}else d=this.name;if(d){if("xmlns"===d.prefix)throw sg(d);if(""===d.prefix&&"xmlns"===d.localName)throw sg(d);if("http://www.w3.org/2000/xmlns/"===
286
+ d.namespaceURI)throw sg(d);if("xml"===d.prefix&&"http://www.w3.org/XML/1998/namespace"!==d.namespaceURI)throw sg(d);if(""!==d.prefix&&"xml"!==d.prefix&&"http://www.w3.org/XML/1998/namespace"===d.namespaceURI)throw sg(d);}}if(this.l.nb)return h=this.l.nb,e||(e=kc(h.map(k=>rc(k.h(a,b),b).M(l=>w.m(g(l.map(n=>n.value).join(" "),1))))).M(k=>w.m(sb(ak(d,k.map(l=>l.value).join(""))))).value),e.next(0);f=!0;return q(sb(ak(d,this.l.value)))}})}v(a){this.A=Ff(a);if(this.name&&this.name.prefix&&!this.name.namespaceURI){const b=
287
+ a.Z(this.name.prefix);if(void 0===b&&this.name.prefix)throw pc(this.name.prefix);this.name.namespaceURI=b||null}super.v(a)}};var ck=class extends C{constructor(a){super(a?a.o:new D({}),a?[a]:[],{B:!1,P:"unsorted"});this.l=a}h(a,b){const c={data:"",Ta:!0,nodeType:8},d={node:c,F:null};if(!this.l)return w.m(sb(d));a=A(this.l,a,b);return rc(a,b).M(e=>{e=e.map(f=>kd(f,1).value).join(" ");if(-1!==e.indexOf("--\x3e"))throw Error('XQDY0072: The contents of the data of a comment may not include "--\x3e"');c.data=e;return w.m(sb(d))})}};var dk=class extends C{constructor(a,b,c,d){super(new D({}),d.concat(b).concat(a.Pa||[]),{B:!1,P:"unsorted"});a.Pa?this.s=a.Pa:this.l=new Sa(a.prefix,a.namespaceURI,a.localName);this.O=c.reduce((e,f)=>{if(f.prefix in e)throw Error(`XQST0071: The namespace declaration with the prefix ${f.prefix} has already been declared on the constructed element.`);e[f.prefix||""]=f.uri;return e},{});this.K=b;this.la=d;this.A=void 0}h(a,b){let c=!1,d,e,f=!1,h,k,l,n=!1;return w.create({next:()=>{if(n)return p;c||
288
+ (d||=kc(this.K.map(F=>A(F,a,b))),e=d.N(),c=!0);if(!f){h||=this.la.map(F=>A(F,a,b));var t=[];for(var u=0;u<h.length;u++){var z=h[u].N();t.push(z)}k=t;f=!0}this.s&&(l||(t=this.s.h(a,b),l=Ej(this.A,b,t)),this.l=l.next(0).value.value);if("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.Aa()}" is invalid for a computed element constructor.`);
289
+ const y={nodeType:1,Ta:!0,attributes:[],childNodes:[],nodeName:this.l.Aa(),namespaceURI:this.l.namespaceURI,prefix:this.l.prefix,localName:this.l.localName};t={node:y,F:null};e.forEach(F=>{y.attributes.push(F.value.node)});u=wj(k,b,rg);u.attributes.forEach(F=>{if(y.attributes.find(N=>N.namespaceURI===F.namespaceURI&&N.localName===F.localName))throw Error(`XQDY0025: The attribute ${F.name} does not have an unique name in the constructed element.`);y.attributes.push(F)});u.Ya.forEach(F=>{y.childNodes.push(F)});
290
+ for(u=0;u<y.childNodes.length;u++){z=y.childNodes[u];if(!cb(z)||3!==z.nodeType)continue;const F=y.childNodes[u-1];F&&cb(F)&&3===F.nodeType&&(F.data+=z.data,y.childNodes.splice(u,1),u--)}n=!0;return q(sb(t))}})}v(a){Dg(a);Object.keys(this.O).forEach(b=>Gg(a,b,this.O[b]));this.Ga.forEach(b=>b.v(a));this.K.reduce((b,c)=>{if(c.name){c=`Q{${null===c.name.namespaceURI?a.Z(c.name.prefix):c.name.namespaceURI}}${c.name.localName}`;if(b.includes(c))throw Error(`XQST0040: The attribute ${c} does not have an unique name in the constructed element.`);
291
+ b.push(c)}return b},[]);if(this.l&&null===this.l.namespaceURI){const b=a.Z(this.l.prefix);if(void 0===b&&this.l.prefix)throw pc(this.l.prefix);this.l.namespaceURI=b}this.A=Ff(a);Jg(a)}};function ek(a){if(/^xml$/i.test(a))throw Error(`XQDY0064: The target of a created PI may not be "${a}"`);}function fk(a,b){return{node:{data:b,Ta:!0,nodeName:a,nodeType:7,target:a},F:null}}
292
+ var gk=class extends C{constructor(a,b){const c=a.xb?[a.xb].concat(b):[b];super(c.reduce((d,e)=>d.add(e.o),new D({})),c,{B:!1,P:"unsorted"});this.l=a;this.s=b}h(a,b){const c=A(this.s,a,b);return rc(c,b).M(d=>{const e=d.map(h=>kd(h,1).value).join(" ");if(-1!==e.indexOf("?>"))throw Error('XQDY0026: The contents of the data of a processing instruction may not include "?>"');if(null!==this.l.Gb)return d=this.l.Gb,ek(d),w.m(sb(fk(d,e)));d=A(this.l.xb,a,b);const f=Dj(b,d);return w.create({next:()=>{var h=
293
+ f.next(0);if(h.done)return h;h=h.value.value;ek(h);return q(sb(fk(h,e)))}})})}};var hk=class extends C{constructor(a){super(a?a.o:new D({}),a?[a]:[],{B:!1,P:"unsorted"});this.l=a}h(a,b){if(!this.l)return w.empty();a=A(this.l,a,b);return rc(a,b).M(c=>{if(0===c.length)return w.empty();c={node:{data:c.map(d=>kd(d,1).value).join(" "),Ta:!0,nodeType:3},F:null};return w.m(sb(c))})}};var ik=class extends rf{constructor(a,b,c,d){super(new D({}),[a,...b.map(e=>e.pb),c].concat(...b.map(e=>e.Kb.map(f=>f.Jb))),{B:!1,V:!1,P:"unsorted",subtree:!1},d);this.K=a;this.l=b.length;this.O=b.map(e=>e.Kb)}A(a,b,c){return c[0](a).M(d=>{for(let e=0;e<this.l;e++)if(this.O[e].some(f=>{switch(f.hc){case "?":if(1<d.length)return!1;break;case "*":break;case "+":if(1>d.length)return!1;break;default:if(1!==d.length)return!1}const h=w.create(d);return d.every((k,l)=>{k=cc(a,l,k,h);return A(f.Jb,k,b).ea()})}))return c[e+
294
+ 1](a);return c[this.l+1](a)})}v(a){super.v(a);if(this.K.H)throw Oe();}};var jk=class extends rf{constructor(a,b,c,d){super(new D({}),[a,c,...b.map(e=>e.pb)].concat(...b.map(e=>e.Hb.map(f=>f))),{B:!1,V:!1,P:"unsorted",subtree:!1},d);this.K=a;this.l=b.length;this.O=b.map(e=>e.Hb)}A(a,b,c){const d=ki(c[0](a),b),[,e,...f]=c;return d.X({multiple:()=>{throw Error("XPTY0004: The operand for a switch expression should result in zero or one item");},default:()=>{const h=d.first(),k=!h;for(let n=0;n<this.l;n++){var l=this.O[n].map(t=>A(t,a,b));for(const t of l)if(l=ki(t,b),l.isEmpty()){if(k)return f[n](a)}else{if(!l.oa())throw Error("XPTY0004: The operand for a switch case should result in zero or one item");
295
+ if(!k&&(l=l.first(),He(a,b,null,h,l).next(0).value))return f[n](a)}}return e(a)}})}v(a){super.v(a);if(this.K.H)throw Oe();}};var kk={Y:!1,ra:!1},lk={Y:!0,ra:!1},mk={Y:!0,ra:!0};function P(a){return a.Y?a.ra?mk:lk:kk}
296
+ function Q(a,b){switch(a[0]){case "andOp":var c=I(a,"type");return new ii(nk("andOp",a,P(b)),c);case "orOp":return c=I(a,"type"),new ji(nk("orOp",a,P(b)),c);case "unaryPlusOp":return c=G(G(a,"operand"),"*"),a=I(a,"type"),new hi("+",Q(c,b),a);case "unaryMinusOp":return c=G(G(a,"operand"),"*"),a=I(a,"type"),new hi("-",Q(c,b),a);case "addOp":case "subtractOp":case "multiplyOp":case "divOp":case "idivOp":case "modOp":var d=a[0],e=Q(J(a,["firstOperand","*"]),P(b));b=Q(J(a,["secondOperand","*"]),P(b));
297
+ const f=I(a,"type"),h=I(J(a,["firstOperand","*"]),"type"),k=I(J(a,["secondOperand","*"]),"type");h&&k&&I(a,"type")&&(c=Sg(d,h.type,k.type));return new Wg(d,e,b,f,c);case "sequenceExpr":return ok(a,b);case "unionOp":return c=I(a,"type"),new Ni([Q(J(a,["firstOperand","*"]),P(b)),Q(J(a,["secondOperand","*"]),P(b))],c);case "otherwiseOp":return c=I(a,"type"),new sh([Q(J(a,["firstOperand","*"]),P(b)),Q(J(a,["secondOperand","*"]),P(b))],c);case "exceptOp":case "intersectOp":return c=I(a,"type"),new Di(a[0],
298
+ Q(J(a,["firstOperand","*"]),P(b)),Q(J(a,["secondOperand","*"]),P(b)),c);case "stringConcatenateOp":return pk(a,b);case "rangeSequenceExpr":return qk(a,b);case "equalOp":case "notEqualOp":case "lessThanOrEqualOp":case "lessThanOp":case "greaterThanOrEqualOp":case "greaterThanOp":return rk("generalCompare",a,b);case "eqOp":case "neOp":case "ltOp":case "leOp":case "gtOp":case "geOp":return rk("valueCompare",a,b);case "isOp":case "nodeBeforeOp":case "nodeAfterOp":return rk("nodeCompare",a,b);case "pathExpr":return sk(a,
299
+ b);case "contextItemExpr":return b=I(a,"type"),new Si(b);case "functionCallExpr":return tk(a,b);case "inlineFunctionExpr":return uk(a,b);case "arrowExpr":return vk(a,b);case "dynamicFunctionInvocationExpr":return wk(a,b);case "namedFunctionRef":return b=G(a,"functionName"),c=I(a,"type"),a=H(J(a,["integerConstantExpr","value"])),new fi(Kg(b),parseInt(a,10),c);case "integerConstantExpr":return new di(H(G(a,"value")),{type:5,g:3});case "stringConstantExpr":return new di(H(G(a,"value")),{type:1,g:3});
300
+ case "decimalConstantExpr":return new di(H(G(a,"value")),{type:4,g:3});case "doubleConstantExpr":return new di(H(G(a,"value")),{type:3,g:3});case "varRef":const {prefix:l,namespaceURI:n,localName:t}=Kg(G(a,"name"));return new ej(l,n,t);case "flworExpr":return xk(a,b);case "quantifiedExpr":return yk(a,b);case "ifThenElseExpr":return c=I(a,"type"),d=G(a,"ifClause")||K(a,"x:stackTrace")[0],e=G(a,"thenClause")||K(a,"x:stackTrace")[1],a=G(a,"elseClause")||K(a,"x:stackTrace")[2],new Vh(Q(d,P(b)),Q(e,b),
301
+ Q(a,b),c);case "instanceOfExpr":return c=Q(J(a,["argExpr","*"]),b),d=J(a,["sequenceType","*"]),e=J(a,["sequenceType","occurrenceIndicator"]),a=I(a,"type"),new Ji(c,Q(d,P(b)),e?H(e):"",a);case "castExpr":return b=Q(G(G(a,"argExpr"),"*"),P(b)),c=G(a,"singleType"),a=Kg(G(c,"atomicType")),c=null!==G(c,"optional"),new Hi(b,a,c);case "castableExpr":return b=Q(G(G(a,"argExpr"),"*"),P(b)),c=G(a,"singleType"),a=Kg(G(c,"atomicType")),c=null!==G(c,"optional"),new Gi(b,a,c);case "simpleMapExpr":return zk(a,b);
302
+ case "mapConstructor":return Ak(a,b);case "arrayConstructor":return Bk(a,b);case "unaryLookup":return c=I(a,"type"),new Zi(Ck(a,b),c);case "typeswitchExpr":return Dk(a,b);case "switchExpr":return Ek(a,b);case "elementConstructor":return Fk(a,b);case "attributeConstructor":return Gk(a,b);case "computedAttributeConstructor":return(c=G(a,"tagName"))?c=Kg(c):(c=G(a,"tagNameExpr"),c={Pa:Q(G(c,"*"),P(b))}),b=Q(G(G(a,"valueExpr"),"*"),P(b)),new bk(c,{nb:[b]});case "computedCommentConstructor":if(!b.Y)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");
303
+ b=(a=G(a,"argExpr"))?Q(G(a,"*"),P(b)):null;return new ck(b);case "computedTextConstructor":if(!b.Y)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");b=(a=G(a,"argExpr"))?Q(G(a,"*"),P(b)):null;return new hk(b);case "computedElementConstructor":return Hk(a,b);case "computedPIConstructor":if(!b.Y)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");c=G(a,"piTargetExpr");d=G(a,"piTarget");e=G(a,"piValueExpr");a=I(a,"type");return new gk({xb:c?
304
+ Q(G(c,"*"),P(b)):null,Gb:d?H(d):null},e?Q(G(e,"*"),P(b)):new Ei([],a));case "CDataSection":return new di(H(a),{type:1,g:3});case "deleteExpr":return b=Q(J(a,["targetExpr","*"]),b),new uj(b);case "insertExpr":c=Q(J(a,["sourceExpr","*"]),b);e=K(a,"*")[1];switch(e[0]){case "insertAfter":d=1;break;case "insertBefore":d=2;break;case "insertInto":d=(d=G(e,"*"))?"insertAsFirst"===d[0]?4:5:3}b=Q(J(a,["targetExpr","*"]),b);return new yj(c,d,b);case "renameExpr":return c=Q(J(a,["targetExpr","*"]),b),b=Q(J(a,
305
+ ["newNameExpr","*"]),b),new Fj(c,b);case "replaceExpr":return c=!!G(a,"replaceValue"),d=Q(J(a,["targetExpr","*"]),b),b=Q(J(a,["replacementExpr","*"]),b),new Wj(c,d,b);case "transformExpr":return Ik(a,b);case "x:stackTrace":c=a;for(a=c[2];"x:stackTrace"===a[0];)c=a,a=a[2];c=c[1];return new Xh(c,a[0],Q(a,b),c.Xa);case "ifClause":case "thenClause":case "elseClause":return Q(G(a,"*"),b);default:return Jk(a,b)}}
306
+ function Jk(a,b){switch(a[0]){case "nameTest":return new bj(Kg(a));case "piTest":return(a=G(a,"piTarget"))?new cj(H(a)):new aj(7);case "commentTest":return new aj(8);case "textTest":return new aj(3);case "documentTest":return new aj(9);case "attributeTest":return b=(a=G(a,"attributeName"))&&G(a,"star"),!a||b?new aj(2):new bj(Kg(G(a,"QName")),{kind:2});case "elementTest":return b=(a=G(a,"elementName"))&&G(a,"star"),!a||b?new aj(1):new bj(Kg(G(a,"QName")),{kind:1});case "anyKindTest":return new dj({prefix:"",
307
+ namespaceURI:null,localName:"node()"});case "anyMapTest":return new dj({prefix:"",namespaceURI:null,localName:"map(*)"});case "anyArrayTest":return new dj({prefix:"",namespaceURI:null,localName:"array(*)"});case "Wildcard":return G(a,"star")?(b=G(a,"uri"))?a=new bj({localName:"*",namespaceURI:H(b),prefix:""}):(b=G(a,"NCName"),a="star"===G(a,"*")[0]?new bj({localName:H(b),namespaceURI:null,prefix:"*"}):new bj({localName:"*",namespaceURI:null,prefix:H(b)})):a=new bj({localName:"*",namespaceURI:null,
308
+ prefix:"*"}),a;case "atomicType":return a=Kg(a),new dj(a);case "anyItemType":return new dj({prefix:"",namespaceURI:null,localName:"item()"});case "unionNodeTest":return Kk(a,b);default:throw Error("No selector counterpart for: "+a[0]+".");}}function Bk(a,b){const c=I(a,"type");a=G(a,"*");const d=K(a,"arrayElem").map(e=>Q(G(e,"*"),P(b)));switch(a[0]){case "curlyArray":return new zh(d,c);case "squareArray":return new Ah(d,c);default:throw Error("Unrecognized arrayType: "+a[0]);}}
309
+ function Ak(a,b){const c=I(a,"type");return new ei(K(a,"mapConstructorEntry").map(d=>({key:Q(J(d,["mapKeyExpr","*"]),P(b)),value:Q(J(d,["mapValueExpr","*"]),P(b))})),c)}function nk(a,b,c){function d(f){const h=G(G(f,"firstOperand"),"*");f=G(G(f,"secondOperand"),"*");h[0]===a?d(h):e.push(Q(h,c));f[0]===a?d(f):e.push(Q(f,c))}const e=[];d(b);return e}function Ck(a,b){a=G(a,"*");switch(a[0]){case "NCName":return new di(H(a),{type:1,g:3});case "star":return"*";default:return Q(a,P(b))}}
310
+ function rk(a,b,c){var d=J(b,["firstOperand","*"]);const e=J(b,["secondOperand","*"]);d=Q(d,P(c));c=Q(e,P(c));switch(a){case "valueCompare":return new vi(b[0],d,c);case "nodeCompare":return new Bi(b[0],d,c);case "generalCompare":return new yi(b[0],d,c)}}
311
+ function Lk(a,b,c){a=K(a,"*");return new Qi(a.filter(d=>"stable"!==d[0]).map(d=>{var e=G(d,"orderModifier"),f=e?G(e,"orderingKind"):null;e=e?G(e,"emptyOrderingMode"):null;f=f?"ascending"===H(f):!0;e=e?"empty least"===H(e):!0;return{aa:Q(J(d,["orderByExpr","*"]),b),Cb:f,ec:e}}),c)}
312
+ function xk(a,b){var c=K(a,"*");a=G(c[c.length-1],"*");c=c.slice(0,-1);if(1<c.length&&!b.Y)throw Error("XPST0003: Use of XQuery FLWOR expressions in XPath is no allowed");return c.reduceRight((d,e)=>{switch(e[0]){case "forClause":e=K(e,"*");for(var f=e.length-1;0<=f;--f){var h=e[f],k=J(h,["forExpr","*"]);const l=G(h,"positionalVariableBinding");d=new ai(Kg(J(h,["typedVariableBinding","varName"])),Q(k,P(b)),l?Kg(l):null,d)}return d;case "letClause":e=K(e,"*");for(f=e.length-1;0<=f;--f)h=e[f],k=J(h,
313
+ ["letExpr","*"]),d=new ci(Kg(J(h,["typedVariableBinding","varName"])),Q(k,P(b)),d);return d;case "whereClause":e=K(e,"*");for(f=e.length-1;0<=f;--f)d=new fj(Q(e[f],b),d);return d;case "windowClause":throw Error(`Not implemented: ${e[0]} is not implemented yet.`);case "groupByClause":throw Error(`Not implemented: ${e[0]} is not implemented yet.`);case "orderByClause":return Lk(e,b,d);case "countClause":throw Error(`Not implemented: ${e[0]} is not implemented yet.`);default:throw Error(`Not implemented: ${e[0]} is not supported in a flwor expression`);
314
+ }},Q(a,b))}function tk(a,b){const c=G(a,"functionName"),d=K(G(a,"arguments"),"*");a=I(a,"type");return new Gf(new fi(Kg(c),d.length,a),d.map(e=>"argumentPlaceholder"===e[0]?null:Q(e,b)),a)}
315
+ function vk(a,b){const c=I(a,"type");var d=J(a,["argExpr","*"]);a=K(a,"*").slice(1);d=[Q(d,b)];for(let f=0;f<a.length;f++)if("arguments"!==a[f][0]){if("arguments"===a[f+1][0]){var e=K(a[f+1],"*");d=d.concat(e.map(h=>"argumentPlaceholder"===h[0]?null:Q(h,b)))}e="EQName"===a[f][0]?new fi(Kg(a[f]),d.length,c):Q(a[f],P(b));d=[new Gf(e,d,c)]}return d[0]}
316
+ function wk(a,b){const c=J(a,["functionItem","*"]),d=I(a,"type");a=G(a,"arguments");let e=[];a&&(e=K(a,"*").map(f=>"argumentPlaceholder"===f[0]?null:Q(f,b)));return new Gf(Q(c,b),e,d)}function uk(a,b){const c=K(G(a,"paramList"),"*"),d=J(a,["functionBody","*"]),e=I(a,"type");return new bi(c.map(f=>({name:Kg(G(f,"varName")),type:Lg(f)})),Lg(a),d?Q(d,b):new Ei([],e))}function Kk(a,b){a=K(a,"*").map(c=>Jk(c,b));return 1===a.length?a[1]:new yh(a)}
317
+ function sk(a,b){const c=I(a,"type");var d=K(a,"stepExpr");let e=!1;var f=d.map(h=>{var k=G(h,"xpathAxis");let l;var n=K(h,"*");const t=[];let u=null,z=!1;for(const y of n)switch(y[0]){case "lookup":t.push(["lookup",Ck(y,b)]);break;case "predicate":case "predicates":for(const F of K(y,"*")){n=Q(F,P(b));if(!z){const N=n.D();null===N?z=!0:u=vh(u,N)}t.push(["predicate",n])}}if(k)switch(e=!0,h=G(h,"attributeTest anyElementTest piTest documentTest elementTest commentTest namespaceTest anyKindTest textTest anyFunctionTest typedFunctionTest schemaAttributeTest atomicType anyItemType parenthesizedItemType typedMapTest typedArrayTest nameTest Wildcard unionNodeTest".split(" ")),
318
+ h=Jk(h,P(b)),H(k)){case "ancestor":l=new Dh(h,{Sa:!1});break;case "ancestor-or-self":l=new Dh(h,{Sa:!0});break;case "attribute":l=new Eh(h,u);break;case "child":l=new Fh(h,u);break;case "descendant":l=new Ih(h,{Sa:!1});break;case "descendant-or-self":l=new Ih(h,{Sa:!0});break;case "parent":l=new Ph(h,u);break;case "following-sibling":l=new Oh(h,u);break;case "preceding-sibling":l=new Th(h,u);break;case "following":l=new Mh(h);break;case "preceding":l=new Rh(h);break;case "self":l=new Uh(h,u)}else k=
319
+ J(h,["filterExpr","*"]),l=Q(k,P(b));for(const y of t)switch(y[0]){case "lookup":l=new Yi(l,y[1]);break;case "predicate":l=new Vi(l,y[1])}l.type=c;return l});a=G(a,"rootExpr");d=e||null!==a||1<d.length;if(!d&&1===f.length||!a&&1===f.length&&"sorted"===f[0].ha)return f[0];if(a&&0===f.length)return new Ri(null);f=new Ui(f,d);return a?new Ri(f):f}
320
+ function yk(a,b){const c=I(a,"type"),d=H(G(a,"quantifier")),e=J(a,["predicateExpr","*"]);a=K(a,"quantifiedExprInClause").map(f=>{const h=Kg(J(f,["typedVariableBinding","varName"]));f=J(f,["sourceExpr","*"]);return{name:h,fb:Q(f,P(b))}});return new $i(d,a,Q(e,P(b)),c)}function ok(a,b){var c=K(a,"*").map(d=>Q(d,b));if(1===c.length)return c[0];c=I(a,"type");return new Ei(K(a,"*").map(d=>Q(d,b)),c)}
321
+ function zk(a,b){const c=I(a,"type");return K(a,"*").reduce((d,e)=>null===d?Q(e,P(b)):new Fi(d,Q(e,P(b)),c),null)}function pk(a,b){const c=I(a,"type");a=[J(a,["firstOperand","*"]),J(a,["secondOperand","*"])];return new Gf(new fi({localName:"concat",namespaceURI:"http://www.w3.org/2005/xpath-functions",prefix:""},a.length,c),a.map(d=>Q(d,P(b))),c)}
322
+ function qk(a,b){const c=I(a,"type");a=[G(G(a,"startExpr"),"*"),G(G(a,"endExpr"),"*")];const d=new fi({localName:"to",namespaceURI:"http://fontoxpath/operators",prefix:""},a.length,c);return new Gf(d,a.map(e=>Q(e,P(b))),c)}
323
+ function Fk(a,b){if(!b.Y)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const c=Kg(G(a,"tagName"));var d=G(a,"attributeList");const e=d?K(d,"attributeConstructor").map(f=>Q(f,P(b))):[];d=d?K(d,"namespaceDeclaration").map(f=>{const h=G(f,"prefix");return{prefix:h?H(h):"",uri:H(G(f,"uri"))}}):[];a=(a=G(a,"elementContent"))?K(a,"*").map(f=>Q(f,P(b))):[];return new dk(c,e,d,a)}
324
+ function Gk(a,b){if(!b.Y)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const c=Kg(G(a,"attributeName"));var d=G(a,"attributeValue");d=d?H(d):null;a=(a=G(a,"attributeValueExpr"))?K(a,"*").map(e=>Q(e,P(b))):null;return new bk(c,{value:d,nb:a})}function Hk(a,b){var c=G(a,"tagName");c?c=Kg(c):(c=G(a,"tagNameExpr"),c={Pa:Q(G(c,"*"),P(b))});a=(a=G(a,"contentExpr"))?K(a,"*").map(d=>Q(d,P(b))):[];return new dk(c,[],[],a)}
325
+ function Ik(a,b){const c=K(G(a,"transformCopies"),"transformCopy").map(e=>{const f=Kg(G(G(e,"varRef"),"name"));return{fb:Q(G(G(e,"copySource"),"*"),b),Lb:new Sa(f.prefix,f.namespaceURI,f.localName)}}),d=Q(G(G(a,"modifyExpr"),"*"),b);a=Q(G(G(a,"returnExpr"),"*"),b);return new Zj(c,d,a)}
326
+ function Dk(a,b){if(!b.Y)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const c=I(a,"type"),d=Q(G(G(a,"argExpr"),"*"),b),e=K(a,"typeswitchExprCaseClause").map(f=>{const h=0===K(f,"sequenceTypeUnion").length?[G(f,"sequenceType")]:K(G(f,"sequenceTypeUnion"),"sequenceType");return{pb:Q(J(f,["resultExpr","*"]),b),Kb:h.map(k=>{const l=G(k,"occurrenceIndicator");return{hc:l?H(l):"",Jb:Q(G(k,"*"),b)}})}});a=Q(J(a,["typeswitchExprDefaultClause","resultExpr","*"]),b);
327
+ return new ik(d,e,a,c)}function Ek(a,b){if(!b.Y)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");const c=I(a,"type"),d=Q(G(G(a,"argExpr"),"*"),b),e=K(a,"switchExprCaseClause").map(f=>{const h=K(f,"switchCaseExpr");return{pb:Q(J(f,["resultExpr","*"]),b),Hb:h.map(k=>Q(G(k,"*"),b))}});a=Q(J(a,["switchExprDefaultClause","resultExpr","*"]),b);return new jk(d,e,a,c)}function Mk(a,b){return Q(a,b)};const Nk=new Map;class Ok{constructor(a,b,c,d,e,f){this.v=a;this.D=b;this.h=c;this.kb=d;this.o=e;this.l=f}}function Pk(a,b,c,d,e,f,h,k){a=Nk.get(a);if(!a)return null;b=a[b+(f?"_DEBUG":"")];return b?(b=b.find(l=>l.o===h&&l.v.every(n=>c(n.prefix)===n.namespaceURI)&&l.D.every(n=>void 0!==d[n.name])&&l.kb.every(n=>e[n.prefix]===n.namespaceURI)&&l.l.every(n=>{const t=k(n.fc,n.arity);return t&&t.namespaceURI===n.Eb.namespaceURI&&t.localName===n.Eb.localName})))?{aa:b.h,jc:!1}:null:null}
328
+ function Qk(a,b,c,d,e,f,h){let k=Nk.get(a);k||(k=Object.create(null),Nk.set(a,k));a=b+(f?"_DEBUG":"");(b=k[a])||(b=k[a]=[]);b.push(new Ok(Object.values(c.h),Object.values(c.o),e,Object.keys(d).map(l=>({namespaceURI:d[l],prefix:l})),h,c.D))};function Rk(a){var b=new Za;if("http://www.w3.org/2005/XQueryX"!==a.namespaceURI&&"http://www.w3.org/2005/XQueryX"!==a.namespaceURI&&"http://fontoxml.com/fontoxpath"!==a.namespaceURI&&"http://www.w3.org/2007/xquery-update-10"!==a.namespaceURI)throw nc("The XML structure passed as an XQueryX program was not valid XQueryX");const c=["stackTrace"===a.localName?"x:stackTrace":a.localName],d=b.getAllAttributes(a);d&&0<d.length&&c.push(Array.from(d).reduce((e,f)=>{"comment"!==f.localName&&"start"!==f.localName&&
329
+ "end"!==f.localName||"stackTrace"!==a.localName?"type"===f.localName?e[f.localName]=Ja(f.value):e[f.localName]=f.value:e[f.localName]=JSON.parse(f.value);return e},{}));b=b.getChildNodes(a);for(const e of b)switch(e.nodeType){case 1:c.push(Rk(e));break;case 3:c.push(e.data)}return c};const Sk=Object.create(null);
330
+ var Tk=(a,b)=>{let c=Sk[a];c||=Sk[a]={Ia:[],Va:[],pa:null,source:b.source};const d=c.pa||(()=>{});c.Ia=c.Ia.concat(b.Ia);c.Va=c.Va.concat(b.Va);c.pa=e=>{d(e);b.pa&&b.pa(e)}},Uk=(a,b)=>{const c=Sk[b];if(!c)throw Error(`XQST0051: No modules found with the namespace uri ${b}`);c.Ia.forEach(d=>{d.cb&&Fg(a,b,d.localName,d.arity,d)});c.Va.forEach(d=>{Hg(a,b,d.localName);Ig(a,b,d.localName,(e,f)=>A(d.aa,e,f))})},Vk=()=>{Object.keys(Sk).forEach(a=>{a=Sk[a];if(a.pa)try{a.pa(a)}catch(b){a.pa=null,hg(a.source,
331
+ b)}a.pa=null})};function Wk(a){return a.replace(/(\x0D\x0A)|(\x0D(?!\x0A))/g,String.fromCharCode(10))};var R=prsc;function Xk(a,b){return(c,d)=>{if(b.has(d))return b.get(d);c=a(c,d);b.set(d,c);return c}}function S(a,b){return(0,R.delimited)(b,a,b)}function T(a,b){return a.reverse().reduce((c,d)=>(0,R.preceded)(d,c),b)}function Yk(a,b,c,d){return(0,R.then)((0,R.then)(a,b,(e,f)=>[e,f]),c,([e,f],h)=>d(e,f,h))}function Zk(a,b,c,d,e){return(0,R.then)((0,R.then)((0,R.then)(a,b,(f,h)=>[f,h]),c,([f,h],k)=>[f,h,k]),d,([f,h,k],l)=>e(f,h,k,l))}
332
+ function $k(a,b,c,d,e,f){return(0,R.then)((0,R.then)((0,R.then)((0,R.then)(a,b,(h,k)=>[h,k]),c,([h,k],l)=>[h,k,l]),d,([h,k,l],n)=>[h,k,l,n]),e,([h,k,l,n],t)=>f(h,k,l,n,t))}function al(a){return(0,R.map)(a,b=>[b])}function bl(a,b){return(0,R.map)((0,R.or)(a),()=>b)}function cl(a){return(b,c)=>(b=a.exec(b.substring(c)))&&0===b.index?(0,R.okWithValue)(c+b[0].length,b[0]):(0,R.error)(c,[a.source],!1)};var dl=(0,R.or)([(0,R.token)(" "),(0,R.token)("\t"),(0,R.token)("\r"),(0,R.token)("\n")]),el=(0,R.token)("(:"),fl=(0,R.token)(":)"),gl=(0,R.token)("(#"),hl=(0,R.token)("#)"),il=(0,R.token)("("),jl=(0,R.token)(")"),kl=(0,R.token)("["),ll=(0,R.token)("]"),ml=(0,R.token)("{"),nl=(0,R.token)("}"),ol=(0,R.token)("{{"),pl=(0,R.token)("}}"),ql=(0,R.token)("'"),rl=(0,R.token)("''"),sl=(0,R.token)('"'),tl=(0,R.token)('""'),ul=(0,R.token)("<![CDATA["),vl=(0,R.token)("]]\x3e"),wl=(0,R.token)("/>"),xl=(0,R.token)("</"),
333
+ yl=(0,R.token)("\x3c!--"),zl=(0,R.token)("--\x3e"),Al=(0,R.token)("<?"),Bl=(0,R.token)("?>"),Cl=(0,R.token)("&#x"),Dl=(0,R.token)("&#"),El=(0,R.token)(":*"),Fl=(0,R.token)("*:"),Gl=(0,R.token)(":="),Hl=(0,R.token)("&"),Il=(0,R.token)(":"),Jl=(0,R.token)(";"),Kl=(0,R.token)("*"),Ll=(0,R.token)("@"),Ml=(0,R.token)("$"),Nl=(0,R.token)("#"),Ol=(0,R.token)("%"),Pl=(0,R.token)("?"),Ql=(0,R.token)("="),Rl=(0,R.followed)((0,R.token)("!"),(0,R.not)((0,R.peek)(Ql),[])),Sl=(0,R.followed)((0,R.token)("|"),(0,R.not)((0,R.peek)((0,R.token)("|")),
334
+ [])),Tl=(0,R.token)("||"),Ul=(0,R.token)("!="),Vl=(0,R.token)("<"),Wl=(0,R.token)("<<"),Xl=(0,R.token)("<="),Yl=(0,R.token)(">"),Zl=(0,R.token)(">>"),$l=(0,R.token)(">="),am=(0,R.token)(","),bm=(0,R.token)("."),cm=(0,R.token)(".."),dm=(0,R.token)("+"),em=(0,R.token)("-"),fm=(0,R.token)("/"),gm=(0,R.token)("//"),hm=(0,R.token)("=>"),im=(0,R.token)("e"),jm=(0,R.token)("E");(0,R.token)("l");(0,R.token)("L");(0,R.token)("m");(0,R.token)("M");var km=(0,R.token)("Q");(0,R.token)("x");(0,R.token)("X");
335
+ var lm=(0,R.token)("as"),mm=(0,R.token)("cast"),nm=(0,R.token)("castable"),om=(0,R.token)("treat"),pm=(0,R.token)("instance"),qm=(0,R.token)("of"),rm=(0,R.token)("node"),sm=(0,R.token)("nodes"),tm=(0,R.token)("delete"),um=(0,R.token)("value"),vm=(0,R.token)("function"),wm=(0,R.token)("map"),xm=(0,R.token)("element"),ym=(0,R.token)("attribute"),zm=(0,R.token)("schema-element"),Am=(0,R.token)("intersect"),Bm=(0,R.token)("except"),Cm=(0,R.token)("union"),Dm=(0,R.token)("otherwise"),Em=(0,R.token)("to"),
336
+ Fm=(0,R.token)("is"),Gm=(0,R.token)("or"),Hm=(0,R.token)("and"),Im=(0,R.token)("div"),Jm=(0,R.token)("idiv"),Km=(0,R.token)("mod"),Lm=(0,R.token)("eq"),Mm=(0,R.token)("ne"),Nm=(0,R.token)("lt"),Om=(0,R.token)("le"),Pm=(0,R.token)("gt"),Qm=(0,R.token)("ge"),Rm=(0,R.token)("amp"),Sm=(0,R.token)("quot"),Tm=(0,R.token)("apos"),Um=(0,R.token)("if"),Vm=(0,R.token)("then"),Wm=(0,R.token)("else"),Xm=(0,R.token)("allowing"),Ym=(0,R.token)("empty"),Zm=(0,R.token)("at"),$m=(0,R.token)("in"),an=(0,R.token)("for"),
337
+ bn=(0,R.token)("let"),cn=(0,R.token)("where"),dn=(0,R.token)("collation"),en=(0,R.token)("group"),fn=(0,R.token)("by"),gn=(0,R.token)("order"),hn=(0,R.token)("stable"),jn=(0,R.token)("return"),kn=(0,R.token)("array"),ln=(0,R.token)("document"),mn=(0,R.token)("namespace"),nn=(0,R.token)("text"),on=(0,R.token)("comment"),pn=(0,R.token)("processing-instruction"),qn=(0,R.token)("lax"),rn=(0,R.token)("strict"),sn=(0,R.token)("validate"),tn=(0,R.token)("type"),un=(0,R.token)("declare"),vn=(0,R.token)("default"),
338
+ wn=(0,R.token)("boundary-space"),xn=(0,R.token)("strip"),yn=(0,R.token)("preserve"),zn=(0,R.token)("no-preserve"),An=(0,R.token)("inherit"),Bn=(0,R.token)("no-inherit"),Cn=(0,R.token)("greatest"),Dn=(0,R.token)("least"),En=(0,R.token)("copy-namespaces"),Fn=(0,R.token)("decimal-format"),Gn=(0,R.token)("case"),Hn=(0,R.token)("typeswitch"),In=(0,R.token)("some"),Jn=(0,R.token)("every"),Kn=(0,R.token)("satisfies"),Ln=(0,R.token)("replace"),Mn=(0,R.token)("with"),Nn=(0,R.token)("copy"),On=(0,R.token)("modify"),
339
+ Pn=(0,R.token)("first"),Qn=(0,R.token)("last"),Rn=(0,R.token)("before"),Sn=(0,R.token)("after"),Tn=(0,R.token)("into"),Un=(0,R.token)("insert"),Vn=(0,R.token)("rename"),Wn=(0,R.token)("switch"),Xn=(0,R.token)("variable"),Yn=(0,R.token)("external"),Zn=(0,R.token)("updating"),$n=(0,R.token)("import"),ao=(0,R.token)("schema"),bo=(0,R.token)("module"),co=(0,R.token)("base-uri"),eo=(0,R.token)("construction"),fo=(0,R.token)("ordering"),go=(0,R.token)("ordered"),ho=(0,R.token)("unordered"),io=(0,R.token)("option"),
340
+ jo=(0,R.token)("context"),ko=(0,R.token)("item"),lo=(0,R.token)("xquery"),mo=(0,R.token)("version"),no=(0,R.token)("encoding"),oo=(0,R.token)("document-node"),po=(0,R.token)("namespace-node"),qo=(0,R.token)("schema-attribute"),ro=(0,R.token)("ascending"),so=(0,R.token)("descending"),to=(0,R.token)("empty-sequence"),uo=(0,R.token)("child::"),vo=(0,R.token)("descendant::"),wo=(0,R.token)("attribute::"),xo=(0,R.token)("self::"),yo=(0,R.token)("descendant-or-self::"),zo=(0,R.token)("following-sibling::"),
341
+ Ao=(0,R.token)("following::"),Bo=(0,R.token)("parent::"),Co=(0,R.token)("ancestor::"),Do=(0,R.token)("preceding-sibling::"),Eo=(0,R.token)("preceding::"),Fo=(0,R.token)("ancestor-or-self::"),Go=(0,R.token)("decimal-separator"),Ho=(0,R.token)("grouping-separator"),Io=(0,R.token)("infinity"),Jo=(0,R.token)("minus-sign"),Ko=(0,R.token)("NaN"),Lo=(0,R.token)("per-mille"),Mo=(0,R.token)("zero-digit"),No=(0,R.token)("digit"),Oo=(0,R.token)("pattern-separator"),Po=(0,R.token)("exponent-separator"),Qo=(0,R.token)("schema-attribute("),
342
+ Ro=(0,R.token)("document-node("),So=(0,R.token)("processing-instruction("),To=(0,R.token)("processing-instruction()"),Uo=(0,R.token)("comment()"),Vo=(0,R.token)("text()"),Wo=(0,R.token)("namespace-node()"),Xo=(0,R.token)("node()"),Yo=(0,R.token)("item()"),Zo=(0,R.token)("empty-sequence()");(0,R.token)("`");var $o=(0,R.token)("``["),ap=(0,R.token)("]``"),bp=(0,R.token)("`{"),cp=(0,R.token)("}`");var dp=new Map,ep=new Map,fp=(0,R.or)([cl(/[\t\n\r -\uD7FF\uE000\uFFFD]/),cl(/[\uD800-\uDBFF][\uDC00-\uDFFF]/)]),gp=(0,R.preceded)((0,R.peek)((0,R.not)((0,R.or)([el,fl]),['comment contents cannot contain "(:" or ":)"'])),fp),hp=(0,R.map)((0,R.delimited)(el,(0,R.star)((0,R.or)([gp,function(a,b){return hp(a,b)}])),fl,!0),a=>a.join("")),ip=(0,R.or)([dl,hp]),jp=(0,R.map)((0,R.plus)(dl),a=>a.join("")),V=Xk((0,R.map)((0,R.star)(ip),a=>a.join("")),dp),W=Xk((0,R.map)((0,R.plus)(ip),a=>a.join("")),ep);const kp=(0,R.or)([cl(/[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,R.then)(cl(/[\uD800-\uDB7F]/),cl(/[\uDC00-\uDFFF]/),(a,b)=>a+b)]),lp=(0,R.or)([kp,cl(/[\-\.0-9\xB7\u0300-\u036F\u203F\u2040]/)]);var mp=(0,R.then)(kp,(0,R.star)(lp),(a,b)=>a+b.join("")),np=(0,R.map)(mp,a=>["prefix",a]);const op=(0,R.or)([kp,Il]),pp=(0,R.or)([lp,Il]);(0,R.then)(op,(0,R.star)(pp),(a,b)=>a+b.join(""));
343
+ const qp=(0,R.map)(mp,a=>[{prefix:"",URI:null},a]),rp=(0,R.then)(mp,(0,R.preceded)(Il,mp),(a,b)=>[{prefix:a,URI:null},b]);var sp=(0,R.or)([rp,qp]),tp=(0,R.followed)(T([km,V,ml],(0,R.map)((0,R.star)(cl(/[^{}]/)),a=>a.join("").replace(/\s+/g," ").trim())),nl);const up=(0,R.then)(tp,mp,(a,b)=>[a,b]);var vp=(0,R.or)([(0,R.map)(up,a=>[{prefix:null,URI:a[0]},a[1]]),sp]),wp=(0,R.or)([(0,R.map)(vp,a=>["QName",...a]),(0,R.map)(Kl,()=>["star"])]),xp=(0,R.map)((0,R.preceded)(Ml,vp),a=>["varRef",["name",...a]]);var yp=(0,R.peek)((0,R.or)([il,sl,ql,ip])),zp=(0,R.map)((0,R.or)([uo,vo,wo,xo,yo,zo,Ao]),a=>a.substring(0,a.length-2)),Ap=(0,R.map)((0,R.or)([Bo,Co,Do,Eo,Fo]),a=>a.substring(0,a.length-2)),Bp=Yk(Hl,(0,R.or)([Nm,Pm,Rm,Sm,Tm]),Jl,(a,b,c)=>a+b+c),Cp=(0,R.or)([Yk(Cl,cl(/[0-9a-fA-F]+/),Jl,(a,b,c)=>a+b+c),Yk(Dl,cl(/[0-9]+/),Jl,(a,b,c)=>a+b+c)]),Dp=bl([tl],'"'),Ep=bl([rl],"'"),Fp=al(bl([Uo],"commentTest")),Gp=al(bl([Vo],"textTest")),Hp=al(bl([Wo],"namespaceTest")),Ip=al(bl([Xo],"anyKindTest"));
344
+ const Jp=cl(/[0-9]+/),Kp=(0,R.then)((0,R.or)([(0,R.then)(bm,Jp,(a,b)=>a+b),(0,R.then)(Jp,(0,R.optional)((0,R.preceded)(bm,cl(/[0-9]*/))),(a,b)=>a+(null!==b?"."+b:""))]),Yk((0,R.or)([im,jm]),(0,R.optional)((0,R.or)([dm,em])),Jp,(a,b,c)=>a+(b?b:"")+c),(a,b)=>["doubleConstantExpr",["value",a+b]]),Lp=(0,R.or)([(0,R.map)((0,R.preceded)(bm,Jp),a=>["decimalConstantExpr",["value","."+a]]),(0,R.then)((0,R.followed)(Jp,bm),(0,R.optional)(Jp),(a,b)=>["decimalConstantExpr",["value",a+"."+(null!==b?b:"")]])]);
345
+ var Mp=(0,R.map)(Jp,a=>["integerConstantExpr",["value",a]]),Np=(0,R.followed)((0,R.or)([Kp,Lp,Mp]),(0,R.peek)((0,R.not)(cl(/[a-zA-Z]/),["no alphabetical characters after numeric literal"]))),Op=(0,R.map)((0,R.followed)(bm,(0,R.peek)((0,R.not)(bm,["context item should not be followed by another ."]))),()=>["contextItemExpr"]),Pp=(0,R.or)([kn,ym,on,oo,xm,to,vm,Um,ko,wm,po,rm,pn,qo,zm,Wn,nn,Hn]),Qp=al(bl([Pl],"argumentPlaceholder")),Rp=(0,R.or)([Pl,Kl,dm]),Sp=(0,R.preceded)((0,R.peek)((0,R.not)(cl(/[{}<&]/),
346
+ ["elementContentChar cannot be {, }, <, or &"])),fp),Tp=(0,R.map)((0,R.delimited)(ul,(0,R.star)((0,R.preceded)((0,R.peek)((0,R.not)(vl,['CDataSection content may not contain "]]\x3e"'])),fp)),vl,!0),a=>["CDataSection",a.join("")]),Up=(0,R.preceded)((0,R.peek)((0,R.not)(cl(/["{}<&]/),['quotAttrValueContentChar cannot be ", {, }, <, or &'])),fp),Vp=(0,R.preceded)((0,R.peek)((0,R.not)(cl(/['{}<&]/),["aposAttrValueContentChar cannot be ', {, }, <, or &"])),fp),Wp=(0,R.map)((0,R.star)((0,R.or)([(0,R.preceded)((0,R.peek)((0,R.not)(em,
347
+ [])),fp),(0,R.map)(T([em,(0,R.peek)((0,R.not)(em,[]))],fp),a=>"-"+a)])),a=>a.join("")),Xp=(0,R.map)((0,R.delimited)(yl,Wp,zl,!0),a=>["computedCommentConstructor",["argExpr",["stringConstantExpr",["value",a]]]]);const Yp=(0,R.filter)(mp,a=>"xml"!==a.toLowerCase(),['A processing instruction target cannot be "xml"']),Zp=(0,R.map)((0,R.star)((0,R.preceded)((0,R.peek)((0,R.not)(Bl,[])),fp)),a=>a.join(""));
348
+ var $p=(0,R.then)((0,R.preceded)(Al,(0,R.cut)(Yp)),(0,R.cut)((0,R.followed)((0,R.optional)((0,R.preceded)(jp,Zp)),Bl)),(a,b)=>["computedPIConstructor",["piTarget",a],["piValueExpr",["stringConstantExpr",["value",b]]]]),aq=(0,R.map)(gm,()=>["stepExpr",["xpathAxis","descendant-or-self"],["anyKindTest"]]),bq=(0,R.or)([qn,rn]),cq=(0,R.map)((0,R.star)((0,R.followed)(fp,(0,R.peek)((0,R.not)(hl,["Pragma contents should not contain '#)'"])))),a=>a.join("")),dq=(0,R.map)((0,R.followed)((0,R.or)([Lm,Mm,Nm,
349
+ Om,Pm,Qm]),yp),a=>a+"Op"),eq=(0,R.or)([(0,R.followed)(bl([Fm],"isOp"),yp),bl([Wl],"nodeBeforeOp"),bl([Zl],"nodeAfterOp")]),fq=(0,R.or)([bl([Ql],"equalOp"),bl([Ul],"notEqualOp"),bl([Xl],"lessThanOrEqualOp"),bl([Vl],"lessThanOp"),bl([$l],"greaterThanOrEqualOp"),bl([Yl],"greaterThanOp")]),gq=(0,R.map)(Zn,()=>["annotation",["annotationName","updating"]]);const hq=(0,R.or)([yn,zn]),iq=(0,R.or)([An,Bn]);
350
+ var jq=(0,R.or)([Go,Ho,Io,Jo,Ko,Ol,Lo,Mo,No,Oo,Po]),kq=(0,R.map)(T([un,W,wn,W],(0,R.or)([yn,xn])),a=>["boundarySpaceDecl",a]),lq=(0,R.map)(T([un,W,eo,W],(0,R.or)([yn,xn])),a=>["constructionDecl",a]),mq=(0,R.map)(T([un,W,fo,W],(0,R.or)([go,ho])),a=>["orderingModeDecl",a]),nq=(0,R.map)(T([un,W,vn,W,gn,W,Ym,W],(0,R.or)([Cn,Dn])),a=>["emptyOrderDecl",a]),oq=(0,R.then)(T([un,W,En,W],hq),T([V,am,V],iq),(a,b)=>["copyNamespacesDecl",["preserveMode",a],["inheritMode",b]]);function pq(a){switch(a[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 a}return["sequenceExpr",
351
+ a]}function qq(a){if(!(1<=a&&55295>=a||57344<=a&&65533>=a||65536<=a&&1114111>=a))throw Error("XQST0090: The character reference "+a+" ("+a.toString(16)+") does not reference a valid codePoint.");}
352
+ function rq(a){return a.replace(/(&[^;]+);/g,b=>{if(/^&#x/.test(b))return b=parseInt(b.slice(3,-1),16),qq(b),String.fromCodePoint(b);if(/^&#/.test(b))return b=parseInt(b.slice(2,-1),10),qq(b),String.fromCodePoint(b);switch(b){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: "'+b+'"');})}
353
+ function sq(a,b,c){if(!a.length)return[];let d=[a[0]];for(let e=1;e<a.length;++e){const f=d[d.length-1];"string"===typeof f&&"string"===typeof a[e]?d[d.length-1]=f+a[e]:d.push(a[e])}if("string"===typeof d[0]&&0===d.length)return[];d=d.reduce((e,f,h)=>{if("string"!==typeof f)e.push(f);else if(c&&/^\s*$/.test(f)){const k=d[h+1];k&&"CDataSection"===k[0]?e.push(rq(f)):(h=d[h-1])&&"CDataSection"===h[0]&&e.push(rq(f))}else e.push(rq(f));return e},[]);if(!d.length)return d;if(1<d.length||b)for(a=0;a<d.length;a++)"string"===
354
+ typeof d[a]&&(d[a]=["stringConstantExpr",["value",d[a]]]);return d}function tq(a){return a[0].prefix?a[0].prefix+":"+a[1]:a[1]};var uq=(0,R.then)(vp,(0,R.optional)(Pl),(a,b)=>null!==b?["singleType",["atomicType",...a],["optional"]]:["singleType",["atomicType",...a]]),vq=(0,R.map)(vp,a=>["atomicType",...a]);const wq=new Map;
355
+ function xq(a){function b(m,r){return r.reduce((B,X)=>[X[0],["firstOperand",B],["secondOperand",X[1]]],m)}function c(m,r,B){return(0,R.then)(m,(0,R.star)((0,R.then)(S(r,V),(0,R.cut)(m),(X,ea)=>[X,ea])),B)}function d(m,r,B="firstOperand",X="secondOperand"){return(0,R.then)(m,(0,R.optional)((0,R.then)(S(r,V),(0,R.cut)(m),(ea,Fa)=>[ea,Fa])),(ea,Fa)=>null===Fa?ea:[Fa[0],[B,ea],[X,Fa[1]]])}function e(m){return a.Ka?(r,B)=>{r=m(r,B);if(!r.success)return r;const X=n.has(B)?n.get(B):{offset:B,line:-1,ga:-1},
356
+ ea=n.has(r.offset)?n.get(r.offset):{offset:r.offset,line:-1,ga:-1};n.set(B,X);n.set(r.offset,ea);B=r.value.Xa;return(0,R.okWithValue)(r.offset,["x:stackTrace",Object.assign({start:X,end:ea},B?{Xa:B}:{}),r.value])}:m}function f(m,r){return Hj(m,r)}function h(m,r){return yf(m,r)}function k(m,r){return e((0,R.or)([Lr,Mr,Nr,Or,Pr,Qr,Rr,Sr,Tr,Ur,Vr]))(m,r)}function l(m,r){return c(k,am,(B,X)=>0===X.length?B:["sequenceExpr",B,...X.map(ea=>ea[1])])(m,r)}const n=new Map,t=(0,R.preceded)(kl,(0,R.followed)(S(l,
357
+ V),ll)),u=(0,R.map)(a.xa?(0,R.or)([S((0,R.star)((0,R.or)([Bp,Cp,Dp,cl(/[^"&]/)])),sl),S((0,R.star)((0,R.or)([Bp,Cp,Ep,cl(/[^'&]/)])),ql)]):(0,R.or)([S((0,R.star)((0,R.or)([Dp,cl(/[^"]/)])),sl),S((0,R.star)((0,R.or)([Ep,cl(/[^']/)])),ql)]),m=>m.join("")),z=(0,R.or)([(0,R.map)(T([xm,V],(0,R.delimited)((0,R.followed)(il,V),(0,R.then)(wp,T([V,am,V],vp),(m,r)=>[["elementName",m],["typeName",...r]]),(0,R.preceded)(V,jl))),([m,r])=>["elementTest",m,r]),(0,R.map)(T([xm,V],(0,R.delimited)(il,wp,jl)),m=>["elementTest",
358
+ ["elementName",m]]),(0,R.map)(T([xm,V],(0,R.delimited)(il,V,jl)),()=>["elementTest"])]),y=(0,R.or)([(0,R.map)(vp,m=>["QName",...m]),(0,R.map)(Kl,()=>["star"])]),F=(0,R.or)([(0,R.map)(T([ym,V],(0,R.delimited)((0,R.followed)(il,V),(0,R.then)(y,T([V,am,V],vp),(m,r)=>[["attributeName",m],["typeName",...r]]),(0,R.preceded)(V,jl))),([m,r])=>["attributeTest",m,r]),(0,R.map)(T([ym,V],(0,R.delimited)(il,y,jl)),m=>["attributeTest",["attributeName",m]]),(0,R.map)(T([ym,V],(0,R.delimited)(il,V,jl)),()=>["attributeTest"])]),
359
+ N=(0,R.map)(T([zm,V,il],(0,R.followed)(vp,jl)),m=>["schemaElementTest",...m]),U=(0,R.map)((0,R.delimited)(Qo,S(vp,V),jl),m=>["schemaAttributeTest",...m]),da=(0,R.map)((0,R.preceded)(Ro,(0,R.followed)(S((0,R.optional)((0,R.or)([z,N])),V),jl)),m=>["documentTest",...(m?[m]:[])]),Ga=(0,R.or)([(0,R.map)((0,R.preceded)(So,(0,R.followed)(S((0,R.or)([mp,u]),V),jl)),m=>["piTest",["piTarget",m]]),al(bl([To],"piTest"))]),Hb=(0,R.or)([da,z,F,N,U,Ga,Fp,Gp,Hp,Ip]),Zb=(0,R.or)([(0,R.map)((0,R.preceded)(Fl,mp),m=>
360
+ ["Wildcard",["star"],["NCName",m]]),al(bl([Kl],"Wildcard")),(0,R.map)((0,R.followed)(tp,Kl),m=>["Wildcard",["uri",m],["star"]]),(0,R.map)((0,R.followed)(mp,El),m=>["Wildcard",["NCName",m],["star"]])]),hd=(0,R.or)([Zb,(0,R.map)(vp,m=>["nameTest",...m])]),jb=(0,R.or)([Hb,hd]),Wr=(0,R.map)((0,R.delimited)((0,R.followed)(il,V),(0,R.then)(jb,(0,R.star)((0,R.preceded)(S(Sl,V),jb)),(m,r)=>[m].concat(r)),(0,R.followed)(V,jl),!0),m=>["unionNodeTest",...m]),zf=4===a.version?(0,R.or)([Wr,jb]):jb,Xr=4===a.version?
361
+ (0,R.or)([(0,R.map)((0,R.preceded)(Ll,zf),m=>["stepExpr",["xpathAxis","attribute"],m]),(0,R.map)(jb,m=>["stepExpr",["xpathAxis","child"],m])]):(0,R.then)((0,R.optional)(Ll),jb,(m,r)=>null!==m||"attributeTest"===r[0]||"schemaAttributeTest"===r[0]?["stepExpr",["xpathAxis","attribute"],r]:["stepExpr",["xpathAxis","child"],r]),Yr=(0,R.or)([(0,R.then)(zp,zf,(m,r)=>["stepExpr",["xpathAxis",m],r]),Xr]),Zr=(0,R.map)(cm,()=>["stepExpr",["xpathAxis","parent"],["anyKindTest"]]),$r=(0,R.or)([(0,R.then)(Ap,zf,
362
+ (m,r)=>["stepExpr",["xpathAxis",m],r]),Zr]),as=(0,R.map)((0,R.star)((0,R.preceded)(V,t)),m=>0<m.length?["predicates",...m]:void 0),bs=(0,R.then)((0,R.or)([$r,Yr]),as,(m,r)=>void 0===r?m:m.concat([r])),Af=(0,R.or)([Np,(0,R.map)(u,m=>["stringConstantExpr",["value",a.xa?rq(m):m]])]),Bf=(0,R.or)([(0,R.delimited)(il,S(l,V),jl),(0,R.map)((0,R.delimited)(il,V,jl),()=>["sequenceExpr"])]),Ij=(0,R.or)([k,Qp]),ce=(0,R.map)((0,R.delimited)(il,S((0,R.optional)((0,R.then)(Ij,(0,R.star)((0,R.preceded)(S(am,V),Ij)),
363
+ (m,r)=>[m,...r])),V),jl),m=>null!==m?m:[]),cs=(0,R.preceded)((0,R.not)(Yk(Pp,V,il,()=>{}),["cannot use reserved keyword for function names"]),e((0,R.then)(vp,(0,R.preceded)(V,ce),(m,r)=>{r=["functionCallExpr",["functionName",...m],null!==r?["arguments",...r]:["arguments"]];const B=m[0].prefix,X=m[0].URI;m=m[1];r.Xa=B?`${B}:${m}`:X?`Q{${X}}${m}`:m;return r}))),ds=(0,R.then)(vp,(0,R.preceded)(Nl,Mp),(m,r)=>["namedFunctionRef",["functionName",...m],r]),Ua=(0,R.delimited)(ml,S((0,R.optional)(l),V),nl),
364
+ Jj=(0,R.map)(Ua,m=>m?m:["sequenceExpr"]),kb=(0,R.or)([(0,R.map)(Zo,()=>[["voidSequenceType"]]),(0,R.then)(f,(0,R.optional)((0,R.preceded)(V,Rp)),(m,r)=>[m,...(null!==r?[["occurrenceIndicator",r]]:[])])]),Cf=(0,R.then)(T([Ol,V],vp),(0,R.optional)((0,R.followed)((0,R.then)(T([il,V],Af),(0,R.star)(T([am,V],Af)),(m,r)=>m.concat(r)),jl)),(m,r)=>["annotation",["annotationName",...m],...(r?["arguments",r]:[])]),es=(0,R.map)(T([vm,V,il,V,Kl,V],jl),()=>["anyFunctionTest"]),fs=(0,R.then)(T([vm,V,il,V],(0,R.optional)(c(kb,
365
+ am,(m,r)=>m.concat.apply(m,r.map(B=>B[1]))))),T([V,jl,W,lm,W],kb),(m,r)=>["typedFunctionTest",["paramTypeList",["sequenceType",...(m?m:[])]],["sequenceType",...r]]),gs=(0,R.then)((0,R.star)(Cf),(0,R.or)([es,fs]),(m,r)=>[r[0],...m,...r.slice(1)]),hs=(0,R.map)(T([wm,V,il,V,Kl,V],jl),()=>["anyMapTest"]),is=(0,R.then)(T([wm,V,il,V],vq),T([V,am],(0,R.followed)(S(kb,V),jl)),(m,r)=>["typedMapTest",m,["sequenceType",...r]]),js=(0,R.or)([hs,is]),ks=(0,R.map)(T([kn,V,il,V,Kl,V],jl),()=>["anyArrayTest"]),ls=
366
+ (0,R.map)(T([kn,V,il],(0,R.followed)(S(kb,V),jl)),m=>["typedArrayTest",["sequenceType",...m]]),ms=(0,R.or)([ks,ls]),ns=(0,R.map)((0,R.delimited)(il,S(f,V),jl),m=>["parenthesizedItemType",m]),Hj=(0,R.or)([Hb,al(bl([Yo],"anyItemType")),gs,js,ms,vq,ns]),Bc=(0,R.map)(T([lm,W],kb),m=>["typeDeclaration",...m]),os=(0,R.then)((0,R.preceded)(Ml,vp),(0,R.optional)((0,R.preceded)(W,Bc)),(m,r)=>["param",["varName",...m],...(r?[r]:[])]),Kj=c(os,am,(m,r)=>[m,...r.map(B=>B[1])]),ps=Zk((0,R.star)(Cf),T([V,vm,V,il,
367
+ V],(0,R.optional)(Kj)),T([V,jl,V],(0,R.optional)((0,R.map)(T([lm,V],(0,R.followed)(kb,V)),m=>["typeDeclaration",...m]))),Jj,(m,r,B,X)=>["inlineFunctionExpr",...m,["paramList",...(r?r:[])],...(B?[B]:[]),["functionBody",X]]),qs=(0,R.or)([ds,ps]),rs=(0,R.map)(k,m=>["mapKeyExpr",m]),ss=(0,R.map)(k,m=>["mapValueExpr",m]),ts=(0,R.then)(rs,(0,R.preceded)(S(Il,V),ss),(m,r)=>["mapConstructorEntry",m,r]),us=(0,R.preceded)(wm,(0,R.delimited)(S(ml,V),(0,R.map)((0,R.optional)(c(ts,S(am,V),(m,r)=>[m,...r.map(B=>
368
+ B[1])])),m=>m?["mapConstructor",...m]:["mapConstructor"]),(0,R.preceded)(V,nl))),vs=(0,R.map)((0,R.delimited)(kl,S((0,R.optional)(c(k,am,(m,r)=>[m,...r.map(B=>B[1])].map(B=>["arrayElem",B]))),V),ll),m=>["squareArray",...(null!==m?m:[])]),ws=(0,R.map)((0,R.preceded)(kn,(0,R.preceded)(V,Ua)),m=>["curlyArray",...(null!==m?[["arrayElem",m]]:[])]),xs=(0,R.map)((0,R.or)([vs,ws]),m=>["arrayConstructor",m]),Lj=(0,R.map)((0,R.star)((0,R.preceded)((0,R.peek)((0,R.not)((0,R.or)([bp,cp,ap]),["String constructors can not contain interpolation characters"])),
369
+ fp)),m=>["stringConstructorChars",m.join("")]),ys=(0,R.map)((0,R.delimited)(bp,l,cp,!0),m=>["stringConstructorInterpolation",m]),zs=(0,R.then)(Lj,(0,R.star)((0,R.then)(ys,Lj,(m,r)=>[m,r])),(m,r)=>{m=[m];for(const [B,X]of r)m.push(B,X);return m}),As=(0,R.map)((0,R.delimited)($o,zs,ap,!0),m=>["stringConstructor",...m]),Mj=(0,R.or)([mp,Mp,Bf,Kl]),Bs=(0,R.map)((0,R.preceded)(Pl,(0,R.preceded)(V,Mj)),m=>"*"===m?["unaryLookup",["star"]]:"string"===typeof m?["unaryLookup",["NCName",m]]:["unaryLookup",m]),
370
+ Df=(0,R.or)([Bp,Cp,bl([ol],"{"),bl([pl],"}"),(0,R.map)(Ua,m=>m||["sequenceExpr"])]),Cs=(0,R.or)([Tp,function(m,r){return Nj(m,r)},Df,Sp]),Ds=(0,R.or)([(0,R.map)(Up,m=>m.replace(/[\x20\x0D\x0A\x09]/g," ")),Df]),Es=(0,R.or)([(0,R.map)(Vp,m=>m.replace(/[\x20\x0D\x0A\x09]/g," ")),Df]),Fs=(0,R.map)((0,R.or)([S((0,R.star)((0,R.or)([Dp,Ds])),sl),S((0,R.star)((0,R.or)([Ep,Es])),ql)]),m=>sq(m,!1,!1)),Gs=(0,R.then)(sp,(0,R.preceded)(S(Ql,(0,R.optional)(jp)),Fs),(m,r)=>{if(""===m[0].prefix&&"xmlns"===m[1]){if(r.length&&
371
+ "string"!==typeof r[0])throw Error("XQST0022: A namespace declaration may not contain enclosed expressions");return["namespaceDeclaration",r.length?["uri",r[0]]:["uri"]]}if("xmlns"===m[0].prefix){if(r.length&&"string"!==typeof r[0])throw Error("XQST0022: The namespace declaration for 'xmlns:"+m[1]+"' may not contain enclosed expressions");return["namespaceDeclaration",["prefix",m[1]],r.length?["uri",r[0]]:["uri"]]}return["attributeConstructor",["attributeName"].concat(m),0===r.length?["attributeValue"]:
372
+ 1===r.length&&"string"===typeof r[0]?["attributeValue",r[0]]:["attributeValueExpr"].concat(r)]}),Hs=(0,R.map)((0,R.star)((0,R.preceded)(jp,(0,R.optional)(Gs))),m=>m.filter(Boolean)),Is=Yk((0,R.preceded)(Vl,sp),Hs,(0,R.or)([(0,R.map)(wl,()=>null),(0,R.then)((0,R.preceded)(Yl,(0,R.star)(Cs)),T([V,xl],(0,R.followed)(sp,(0,R.then)((0,R.optional)(jp),Yl,()=>null))),(m,r)=>[sq(m,!0,!0),r])]),(m,r,B)=>{var X=B;if(B&&B.length){X=tq(m);const ea=tq(B[1]);if(X!==ea)throw Error('XQST0118: The start and the end tag of an element constructor must be equal. "'+
373
+ X+'" does not match "'+ea+'"');X=B[0]}return["elementConstructor",["tagName",...m],...(r.length?[["attributeList",...r]]:[]),...(X&&X.length?[["elementContent",...X]]:[])]}),Nj=(0,R.or)([Is,Xp,$p]),Js=(0,R.map)(T([ln,V],Ua),m=>["computedDocumentConstructor",...(m?[["argExpr",m]]:[])]),Ks=(0,R.map)(Ua,m=>m?[["contentExpr",m]]:[]),Ls=(0,R.then)(T([xm,V],(0,R.or)([(0,R.map)(vp,m=>["tagName",...m]),(0,R.map)((0,R.delimited)(ml,S(l,V),nl),m=>["tagNameExpr",m])])),(0,R.preceded)(V,Ks),(m,r)=>["computedElementConstructor",
374
+ m,...r]),Ms=(0,R.then)((0,R.preceded)(ym,(0,R.or)([(0,R.map)(T([yp,V],vp),m=>["tagName",...m]),(0,R.map)((0,R.preceded)(V,(0,R.delimited)(ml,S(l,V),nl)),m=>["tagNameExpr",m])])),(0,R.preceded)(V,Ua),(m,r)=>["computedAttributeConstructor",m,["valueExpr",r?r:["sequenceExpr"]]]),Ns=(0,R.map)(Ua,m=>m?[["prefixExpr",m]]:[]),Os=(0,R.map)(Ua,m=>m?[["URIExpr",m]]:[]),Ps=(0,R.then)(T([mn,V],(0,R.or)([np,Ns])),(0,R.preceded)(V,Os),(m,r)=>["computedNamespaceConstructor",...m,...r]),Qs=(0,R.map)(T([nn,V],Ua),
375
+ m=>["computedTextConstructor",...(m?[["argExpr",m]]:[])]),Rs=(0,R.map)(T([on,V],Ua),m=>["computedCommentConstructor",...(m?[["argExpr",m]]:[])]),Ss=T([pn,V],(0,R.then)((0,R.or)([(0,R.map)(mp,m=>["piTarget",m]),(0,R.map)((0,R.delimited)(ml,S(l,V),nl),m=>["piTargetExpr",m])]),(0,R.preceded)(V,Ua),(m,r)=>["computedPIConstructor",m,...(r?[["piValueExpr",r]]:[])])),Ts=(0,R.or)([Js,Ls,Ms,Ps,Qs,Rs,Ss]),Us=(0,R.or)([Nj,Ts]),Oj=(0,R.or)([Af,xp,Bf,Op,cs,Us,qs,us,xs,As,Bs]),Pj=(0,R.map)(T([Pl,V],Mj),m=>"*"===
376
+ m?["lookup",["star"]]:"string"===typeof m?["lookup",["NCName",m]]:["lookup",m]),Vs=(0,R.then)((0,R.map)(Oj,m=>pq(m)),(0,R.star)((0,R.or)([(0,R.map)((0,R.preceded)(V,t),m=>["predicate",m]),(0,R.map)((0,R.preceded)(V,ce),m=>["argumentList",m]),(0,R.preceded)(V,Pj)])),(m,r)=>{function B(){Qj&&1===Fa.length?Cc.push(["predicate",Fa[0]]):0!==Fa.length&&Cc.push(["predicates",...Fa]);Fa.length=0}function X($b){B();0!==Cc.length?("sequenceExpr"===ea[0][0]&&2<ea[0].length&&(ea=[["sequenceExpr",...ea]]),ea=
377
+ [["filterExpr",...ea],...Cc],Cc.length=0):$b&&(ea=[["filterExpr",...ea]])}let ea=[m];const Fa=[],Cc=[];let Qj=!1;for(const $b of r)switch($b[0]){case "predicate":Fa.push($b[1]);break;case "lookup":Qj=!0;B();Cc.push($b);break;case "argumentList":X(!1);1<ea.length&&(ea=[["sequenceExpr",["pathExpr",["stepExpr",...ea]]]]);ea=[["dynamicFunctionInvocationExpr",["functionItem",...ea],...($b[1].length?[["arguments",...$b[1]]]:[])]];break;default:throw Error("unreachable");}X(!0);return ea}),Dc=(0,R.or)([(0,R.map)(Vs,
378
+ m=>["stepExpr",...m]),bs]),Ws=(0,R.followed)(Oj,(0,R.peek)((0,R.not)((0,R.preceded)(V,(0,R.or)([t,ce,Pj])),["primary expression not followed by predicate, argumentList, or lookup"]))),Xs=(0,R.or)([Yk(Dc,(0,R.preceded)(V,aq),(0,R.preceded)(V,h),(m,r,B)=>["pathExpr",m,r,...B]),(0,R.then)(Dc,(0,R.preceded)(S(fm,V),h),(m,r)=>["pathExpr",m,...r]),Ws,(0,R.map)(Dc,m=>["pathExpr",m])]),yf=(0,R.or)([Yk(Dc,(0,R.preceded)(V,aq),(0,R.preceded)(V,h),(m,r,B)=>[m,r,...B]),(0,R.then)(Dc,(0,R.preceded)(S(fm,V),h),
379
+ (m,r)=>[m,...r]),(0,R.map)(Dc,m=>[m])]),Ys=(0,R.or)([(0,R.map)(T([fm,V],yf),m=>["pathExpr",["rootExpr"],...m]),(0,R.then)(aq,(0,R.preceded)(V,yf),(m,r)=>["pathExpr",["rootExpr"],m,...r]),(0,R.map)((0,R.followed)(fm,(0,R.not)((0,R.preceded)(V,a.xa?cl(/[*<a-zA-Z]/):cl(/[*a-zA-Z]/)),["Single rootExpr cannot be by followed by something that can be interpreted as a relative path"])),()=>["pathExpr",["rootExpr"]])]),Zs=Xk((0,R.or)([Xs,Ys]),wq),$s=(0,R.preceded)(sn,(0,R.then)((0,R.optional)((0,R.or)([(0,R.map)((0,R.preceded)(V,
380
+ bq),m=>["validationMode",m]),(0,R.map)(T([V,tn,V],vp),m=>["type",...m])])),(0,R.delimited)((0,R.preceded)(V,ml),S(l,V),nl),(m,r)=>["validateExpr",...(m?[m]:[]),["argExpr",r]])),at=(0,R.delimited)(gl,(0,R.then)((0,R.preceded)(V,vp),(0,R.optional)((0,R.preceded)(W,cq)),(m,r)=>r?["pragma",["pragmaName",m],["pragmaContents",r]]:["pragma",["pragmaName",m]]),(0,R.preceded)(V,hl)),bt=(0,R.map)((0,R.followed)((0,R.plus)(at),(0,R.preceded)(V,(0,R.delimited)(ml,S((0,R.optional)(l),V),nl))),m=>["extensionExpr",
381
+ ...m]),ct=e(c(Zs,Rl,(m,r)=>0===r.length?m:["simpleMapExpr","pathExpr"===m[0]?m:["pathExpr",["stepExpr",["filterExpr",pq(m)]]]].concat(r.map(B=>{B=B[1];return"pathExpr"===B[0]?B:["pathExpr",["stepExpr",["filterExpr",pq(B)]]]})))),dt=(0,R.or)([$s,bt,ct]),Rj=(0,R.or)([(0,R.then)((0,R.or)([bl([em],"unaryMinusOp"),bl([dm],"unaryPlusOp")]),(0,R.preceded)(V,function(m,r){return Rj(m,r)}),(m,r)=>[m,["operand",r]]),dt]),et=(0,R.or)([(0,R.map)(vp,m=>["EQName",...m]),xp,Bf]),ft=(0,R.then)(Rj,(0,R.star)(T([V,
382
+ hm,V],(0,R.then)(et,(0,R.preceded)(V,ce),(m,r)=>[m,r]))),(m,r)=>r.reduce((B,X)=>["arrowExpr",["argExpr",B],X[0],["arguments",...X[1]]],m)),gt=(0,R.then)(ft,(0,R.optional)(T([V,mm,W,lm,yp,V],uq)),(m,r)=>null!==r?["castExpr",["argExpr",m],r]:m),ht=(0,R.then)(gt,(0,R.optional)(T([V,nm,W,lm,yp,V],uq)),(m,r)=>null!==r?["castableExpr",["argExpr",m],r]:m),it=(0,R.then)(ht,(0,R.optional)(T([V,om,W,lm,yp,V],kb)),(m,r)=>null!==r?["treatExpr",["argExpr",m],["sequenceType",...r]]:m),jt=(0,R.then)(it,(0,R.optional)(T([V,
383
+ pm,W,qm,yp,V],kb)),(m,r)=>null!==r?["instanceOfExpr",["argExpr",m],["sequenceType",...r]]:m),kt=c(jt,(0,R.followed)((0,R.or)([bl([Am],"intersectOp"),bl([Bm],"exceptOp")]),yp),b),Sj=c(kt,(0,R.or)([bl([Sl],"unionOp"),(0,R.followed)(bl([Cm],"unionOp"),yp)]),b),lt=c(Sj,(0,R.followed)(bl([Dm],"otherwiseOp"),(0,R.cut)(yp)),b),mt=c(4<=a.version?lt:Sj,(0,R.or)([bl([Kl],"multiplyOp"),(0,R.followed)(bl([Im],"divOp"),yp),(0,R.followed)(bl([Jm],"idivOp"),yp),(0,R.followed)(bl([Km],"modOp"),yp)]),b),nt=c(mt,(0,R.or)([bl([em],
384
+ "subtractOp"),bl([dm],"addOp")]),b),ot=d(nt,(0,R.followed)(bl([Em],"rangeSequenceExpr"),yp),"startExpr","endExpr"),pt=c(ot,bl([Tl],"stringConcatenateOp"),b),qt=d(pt,(0,R.or)([dq,eq,fq])),rt=c(qt,(0,R.followed)(bl([Hm],"andOp"),yp),b),Vr=c(rt,(0,R.followed)(bl([Gm],"orOp"),yp),b),st=e((0,R.map)(l,m=>["ifClause",m])),tt=e((0,R.map)(k,m=>["thenClause",m])),ut=e((0,R.map)(k,m=>["elseClause",m])),Pr=(0,R.then)((0,R.then)(T([Um,V,il,V],st),T([V,jl,V,Vm,yp,V],tt),(m,r)=>[m,r]),T([V,Wm,yp,V],ut),(m,r)=>["ifThenElseExpr",
385
+ m[0],m[1],r]),vt=(0,R.delimited)(Xm,W,Ym),wt=(0,R.map)(T([Zm,W,Ml],vp),m=>["positionalVariableBinding",...m]),xt=$k((0,R.preceded)(Ml,(0,R.cut)(vp)),(0,R.cut)((0,R.preceded)(V,(0,R.optional)(Bc))),(0,R.cut)((0,R.preceded)(V,(0,R.optional)(vt))),(0,R.cut)((0,R.preceded)(V,(0,R.optional)(wt))),(0,R.cut)((0,R.preceded)(S($m,V),k)),(m,r,B,X,ea)=>["forClauseItem",["typedVariableBinding",["varName",...m,...(r?[r]:[])]],...(B?[["allowingEmpty"]]:[]),...(X?[X]:[]),["forExpr",ea]]),yt=T([an,W],c(xt,am,(m,
386
+ r)=>["forClause",m,...r.map(B=>B[1])])),zt=Yk((0,R.preceded)(Ml,vp),(0,R.preceded)(V,(0,R.optional)(Bc)),(0,R.preceded)(S(Gl,V),k),(m,r,B)=>["letClauseItem",["typedVariableBinding",["varName",...m],...(r?[r]:[])],["letExpr",B]]),At=(0,R.map)(T([bn,V],c(zt,am,(m,r)=>[m,...r.map(B=>B[1])])),m=>["letClause",...m]),Tj=(0,R.or)([yt,At]),Bt=(0,R.map)(T([cn,yp,V],k),m=>["whereClause",m]),Ct=(0,R.map)((0,R.preceded)(Ml,vp),m=>["varName",...m]),Dt=(0,R.then)((0,R.preceded)(V,(0,R.optional)(Bc)),(0,R.preceded)(S(Gl,
387
+ V),k),(m,r)=>["groupVarInitialize",...(m?[["typeDeclaration",...m]]:[]),["varValue",r]]),Et=Yk(Ct,(0,R.optional)(Dt),(0,R.optional)((0,R.map)((0,R.preceded)(S(dn,V),u),m=>["collation",m])),(m,r,B)=>["groupingSpec",m,...(r?[r]:[]),...(B?[B]:[])]),Ft=c(Et,am,(m,r)=>[m,...r.map(B=>B[1])]),Gt=(0,R.map)(T([en,W,fn,V],Ft),m=>["groupByClause",...m]),Ht=Yk((0,R.optional)((0,R.or)([ro,so])),(0,R.optional)(T([V,Ym,V],(0,R.or)([Cn,Dn].map(m=>(0,R.map)(m,r=>"empty "+r))))),(0,R.preceded)(V,(0,R.optional)(T([dn,
388
+ V],u))),(m,r,B)=>m||r||B?["orderModifier",...(m?[["orderingKind",m]]:[]),...(r?[["emptyOrderingMode",r]]:[]),...(B?[["collation",B]]:[])]:null),It=(0,R.then)(k,(0,R.preceded)(V,Ht),(m,r)=>["orderBySpec",["orderByExpr",m],...(r?[r]:[])]),Jt=c(It,am,(m,r)=>[m,...r.map(B=>B[1])]),Kt=(0,R.then)((0,R.or)([(0,R.map)(T([gn,W],fn),()=>!1),(0,R.map)(T([hn,W,gn,W],fn),()=>!0)]),(0,R.preceded)(V,Jt),(m,r)=>["orderByClause",...(m?[["stable"]]:[]),...r]),Lt=(0,R.or)([Tj,Bt,Gt,Kt]),Mt=(0,R.map)(T([jn,V],k),m=>
389
+ ["returnClause",m]),Lr=Yk(Tj,(0,R.cut)((0,R.star)((0,R.preceded)(V,Lt))),(0,R.cut)((0,R.preceded)(V,Mt)),(m,r,B)=>["flworExpr",m,...r,B]),Nt=c(kb,Sl,(m,r)=>0===r.length?["sequenceType",...m]:["sequenceTypeUnion",["sequenceType",...m],...r.map(B=>["sequenceType",...B[1]])]),Ot=Yk(T([Gn,V],(0,R.optional)((0,R.preceded)(Ml,(0,R.followed)((0,R.followed)(vp,W),lm)))),(0,R.preceded)(V,Nt),T([W,jn,W],k),(m,r,B)=>["typeswitchExprCaseClause"].concat(m?[["variableBinding",...m]]:[],[r],[["resultExpr",B]])),
390
+ Or=Zk((0,R.preceded)(Hn,S((0,R.delimited)(il,S(l,V),jl),V)),(0,R.plus)((0,R.followed)(Ot,V)),T([vn,W],(0,R.optional)((0,R.preceded)(Ml,(0,R.followed)(vp,W)))),T([jn,W],k),(m,r,B,X)=>["typeswitchExpr",["argExpr",m],...r,["typeswitchExprDefaultClause",...(B||[]),["resultExpr",X]]]),Pt=Yk((0,R.preceded)(Ml,vp),(0,R.optional)((0,R.preceded)(W,Bc)),(0,R.preceded)(S($m,W),k),(m,r,B)=>["quantifiedExprInClause",["typedVariableBinding",["varName",...m],...(r?[r]:[])],["sourceExpr",B]]),Qt=c(Pt,am,(m,r)=>[m,
391
+ ...r.map(B=>B[1])]),Mr=Yk((0,R.or)([In,Jn]),(0,R.preceded)(W,Qt),(0,R.preceded)(S(Kn,V),k),(m,r,B)=>["quantifiedExpr",["quantifier",m],...r,["predicateExpr",B]]),Rr=(0,R.map)(T([tm,W,(0,R.or)([sm,rm]),W],k),m=>["deleteExpr",["targetExpr",m]]),Tr=Yk(T([Ln,W],(0,R.optional)(T([um,W,qm],W))),T([rm,W],k),(0,R.preceded)(S(Mn,W),k),(m,r,B)=>m?["replaceExpr",["replaceValue"],["targetExpr",r],["replacementExpr",B]]:["replaceExpr",["targetExpr",r],["replacementExpr",B]]),Rt=(0,R.then)(xp,(0,R.preceded)(S(Gl,
392
+ V),k),(m,r)=>["transformCopy",m,["copySource",r]]),Ur=Yk(T([Nn,W],c(Rt,am,(m,r)=>[m,...r.map(B=>B[1])])),T([V,On,W],k),(0,R.preceded)(S(jn,W),k),(m,r,B)=>["transformExpr",["transformCopies",...m],["modifyExpr",r],["returnExpr",B]]),St=(0,R.or)([(0,R.followed)((0,R.map)((0,R.optional)((0,R.followed)(T([lm,W],(0,R.or)([(0,R.map)(Pn,()=>["insertAsFirst"]),(0,R.map)(Qn,()=>["insertAsLast"])])),W)),m=>m?["insertInto",m]:["insertInto"]),Tn),(0,R.map)(Sn,()=>["insertAfter"]),(0,R.map)(Rn,()=>["insertBefore"])]),
393
+ Qr=Yk(T([Un,W,(0,R.or)([sm,rm]),W],k),(0,R.preceded)(W,St),(0,R.preceded)(W,k),(m,r,B)=>["insertExpr",["sourceExpr",m],r,["targetExpr",B]]),Sr=(0,R.then)(T([Vn,W,rm,V],k),T([W,lm,W],k),(m,r)=>["renameExpr",["targetExpr",m],["newNameExpr",r]]),Tt=(0,R.then)((0,R.plus)((0,R.then)((0,R.map)(T([Gn,W],(0,R.cut)(k)),m=>["switchCaseExpr",m]),(0,R.cut)(W),m=>m)),(0,R.cut)(T([jn,W],(0,R.cut)(k))),(m,r)=>["switchExprCaseClause",...m,["resultExpr",r]]),Nr=Yk(T([Wn,V,il],(0,R.cut)(l)),(0,R.cut)(T([V,jl,(0,R.cut)(V)],
394
+ (0,R.plus)((0,R.followed)(Tt,V)))),(0,R.cut)(T([vn,W,jn,W],k)),(m,r,B)=>["switchExpr",["argExpr",m],...r,["switchExprDefaultClause",["resultExpr",B]]]),Ut=(0,R.map)(l,m=>["queryBody",m]),Vt=T([un,W,mn,W],(0,R.cut)((0,R.then)(mp,(0,R.preceded)(S(Ql,V),u),(m,r)=>["namespaceDecl",["prefix",m],["uri",r]]))),Wt=(0,R.then)(T([Xn,W,Ml,V],(0,R.then)(vp,(0,R.optional)((0,R.preceded)(V,Bc)),(m,r)=>[m,r])),(0,R.cut)((0,R.or)([(0,R.map)(T([V,Gl,V],k),m=>["varValue",m]),(0,R.map)(T([W,Yn],(0,R.optional)(T([V,
395
+ Gl,V],k))),m=>["external",...(m?[["varValue",m]]:[])])])),([m,r],B)=>["varDecl",["varName",...m],...(null!==r?[r]:[]),B]),Xt=Zk(T([vm,W,(0,R.cut)((0,R.peek)((0,R.not)((0,R.followed)(Pp,(0,R.not)(Il,[""])),["Cannot use reserved function name"])))],vp),(0,R.cut)(T([V,il,V],(0,R.optional)(Kj))),(0,R.cut)(T([V,jl],(0,R.optional)(T([W,lm,W],kb)))),(0,R.cut)((0,R.preceded)(V,(0,R.or)([(0,R.map)(Jj,m=>["functionBody",m]),(0,R.map)(Yn,()=>["externalDefinition"])]))),(m,r,B,X)=>["functionDecl",["functionName",
396
+ ...m],["paramList",...(r||[])],...(B?[["typeDeclaration",...B]]:[]),X]),Yt=T([un,W],(0,R.then)((0,R.star)((0,R.followed)((0,R.or)([Cf,gq]),W)),(0,R.or)([Wt,Xt]),(m,r)=>[r[0],...m,...r.slice(1)])),Zt=(0,R.then)(T([un,W,vn,W],(0,R.or)([xm,vm])),T([W,mn,W],u),(m,r)=>["defaultNamespaceDecl",["defaultNamespaceCategory",m],["uri",r]]),$t=(0,R.or)([(0,R.map)((0,R.followed)(T([mn,W],mp),(0,R.preceded)(V,Ql)),m=>["namespacePrefix",m]),(0,R.map)(T([vn,W,xm,W],mn),()=>["defaultElementNamespace"])]),au=T([$n,
397
+ W,ao],Yk((0,R.optional)((0,R.preceded)(W,$t)),(0,R.preceded)(V,u),(0,R.optional)((0,R.then)(T([W,Zm,W],u),(0,R.star)(T([V,am,V],u)),(m,r)=>[m,...r])),(m,r,B)=>["schemaImport",...(m?[m]:[]),["targetNamespace",r],...(B?[B]:[])])),bu=T([$n,W,bo],Yk((0,R.optional)((0,R.followed)(T([W,mn,W],mp),(0,R.preceded)(V,Ql))),(0,R.preceded)(V,u),(0,R.optional)((0,R.then)(T([W,Zm,W],u),(0,R.star)(T([V,am,V],u)),(m,r)=>[m,...r])),(m,r)=>["moduleImport",["namespacePrefix",m],["targetNamespace",r]])),cu=(0,R.or)([au,
398
+ bu]),du=(0,R.map)(T([un,W,vn,W,dn,W],u),m=>["defaultCollationDecl",m]),eu=(0,R.map)(T([un,W,co,W],u),m=>["baseUriDecl",m]),fu=(0,R.then)(T([un,W],(0,R.or)([(0,R.map)(T([Fn,W],vp),m=>["decimalFormatName",...m]),(0,R.map)(T([vn,W],Fn),()=>null)])),(0,R.star)((0,R.then)((0,R.preceded)(W,jq),(0,R.preceded)(S(Ql,W),u),(m,r)=>["decimalFormatParam",["decimalFormatParamName",m],["decimalFormatParamValue",r]])),(m,r)=>["decimalFormatDecl",...(m?[m]:[]),...r]),gu=(0,R.or)([kq,du,eu,lq,mq,nq,oq,fu]),hu=(0,R.then)(T([un,
399
+ W,io,W],vp),(0,R.preceded)(W,u),(m,r)=>["optionDecl",["optionName",m],["optionContents",r]]),iu=(0,R.then)(T([un,W,jo,W,ko],(0,R.optional)(T([W,lm],Hj))),(0,R.or)([(0,R.map)((0,R.preceded)(S(Gl,V),k),m=>["varValue",m]),(0,R.map)(T([W,Yn],(0,R.optional)((0,R.preceded)(S(Gl,V),k))),()=>["external"])]),(m,r)=>["contextItemDecl",...(m?[["contextItemType",m]]:[]),r]),Uj=(0,R.then)((0,R.star)((0,R.followed)((0,R.or)([Zt,gu,Vt,cu]),(0,R.cut)(S(Jl,V)))),(0,R.star)((0,R.followed)((0,R.or)([iu,Yt,hu]),(0,R.cut)(S(Jl,
400
+ V)))),(m,r)=>0===m.length&&0===r.length?null:["prolog",...m,...r]),ju=T([bo,W,mn,W],(0,R.then)((0,R.followed)(mp,S(Ql,V)),(0,R.followed)(u,S(Jl,V)),(m,r)=>["moduleDecl",["prefix",m],["uri",r]])),ku=(0,R.then)(ju,(0,R.preceded)(V,Uj),(m,r)=>["libraryModule",m,...(r?[r]:[])]),lu=(0,R.then)(Uj,(0,R.preceded)(V,Ut),(m,r)=>["mainModule",...(m?[m]:[]),r]),mu=(0,R.map)(T([lo,V],(0,R.followed)((0,R.or)([(0,R.then)((0,R.preceded)(no,W),u,m=>["encoding",m]),(0,R.then)(T([mo,W],u),(0,R.optional)(T([W,no,W],
401
+ u)),(m,r)=>[["version",m],...(r?[["encoding",r]]:[])])]),(0,R.preceded)(V,Jl))),m=>["versionDecl",...m]),nu=(0,R.then)((0,R.optional)(S(mu,V)),(0,R.or)([ku,lu]),(m,r)=>["module",...(m?[m]:[]),r]),ou=(0,R.complete)(S(nu,V));return(m,r)=>{n.clear();r=ou(m,r);let B=1,X=1;for(let ea=0;ea<m.length+1;ea++){if(n.has(ea)){const Fa=n.get(ea);Fa.line=X;Fa.ga=B}"\n"===m[ea]?(X++,B=1):B++}return r}}
402
+ const yq=xq({Ka:!1,xa:!1,version:3.1}),zq=xq({Ka:!0,xa:!1,version:3.1}),Aq=xq({Ka:!1,xa:!0,version:3.1}),Bq=xq({Ka:!0,xa:!0,version:3.1}),Cq=xq({Ka:!1,xa:!1,version:4}),Dq=xq({Ka:!0,xa:!1,version:4}),Eq=xq({Ka:!1,xa:!0,version:4}),Fq=xq({Ka:!0,xa:!0,version:4});var Gq={Ab:{debug:Dq,mb:Cq},Ib:{debug:zq,mb:yq}},Hq={Ab:{debug:Fq,mb:Eq},Ib:{debug:Bq,mb:Aq}};function Iq(a,b){var c=!!b.Y;var d=!!b.debug;b=b.version;dp.clear();ep.clear();wq.clear();c=c?Hq:Gq;c=4===b?c.Ab:c.Ib;d=(d?c.debug:c.mb)(a,0);if(!0===d.success)return d.value;a=a.substring(0,d.offset).split("\n");c=a[a.length-1].length+1;throw new Wh({start:{offset:d.offset,line:a.length,ga:c},end:{offset:d.offset+1,line:a.length,ga:c+1}},"","",Error(`XPST0003: Failed to parse script. Expected ${[...(new Set(d.expected))]}`));};const Jq="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(" ");
403
+ function Kq(a,b,c,d,e){var f=G(a,"functionName"),h=I(f,"prefix")||"";let k=I(f,"URI");const l=H(f);if(null===k&&(k=""===h?null===b.v?"http://www.w3.org/2005/xpath-functions":b.v:b.Z(h),!k&&h))throw zg(h);if(Jq.includes(k))throw tg();h=K(a,"annotation").map(y=>G(y,"annotationName"));f=h.every(y=>!I(y,"URI")&&"private"!==H(y));h=h.some(y=>!I(y,"URI")&&"updating"===H(y));if(!k)throw vg();const n=Lg(a),t=K(G(a,"paramList"),"param"),u=t.map(y=>G(y,"varName")),z=t.map(y=>Lg(y));if(a=G(a,"functionBody")){if(b.ua(k,
404
+ l,z.length))throw ug(k,l);if(!e)return;const y=Mk(a[1],{ra:!1,Y:!0}),F=new Cg(b),N=u.map(U=>{let da=I(U,"URI");const Ga=I(U,"prefix");U=H(U);Ga&&null===da&&(da=b.Z(Ga||""));return Hg(F,da,U)});e=h?{j:z,arity:u.length,callFunction:(U,da,Ga,...Hb)=>{U=ic(cc(U,-1,null,w.empty()),N.reduce((Zb,hd,jb)=>{Zb[hd]=Ra(Hb[jb]);return Zb},Object.create(null)));return y.s(U,da)},wb:!1,H:!0,cb:f,localName:l,namespaceURI:k,i:n}:{j:z,arity:u.length,callFunction:(U,da,Ga,...Hb)=>{U=ic(cc(U,-1,null,w.empty()),N.reduce((Zb,
405
+ hd,jb)=>{Zb[hd]=Ra(Hb[jb]);return Zb},Object.create(null)));return A(y,U,da)},wb:!1,H:!1,cb:f,localName:l,namespaceURI:k,i:n};c.push({aa:y,Fb:F});d.push({arity:u.length,aa:y,Bb:e,localName:l,namespaceURI:k,cb:f})}else{if(h)throw Error("Updating external function declarations are not supported");e={j:z,arity:u.length,callFunction:(y,F,N,...U)=>{const da=N.ua(k,l,u.length,!0);if(!da)throw Error(`XPST0017: Function Q{${k}}${l} with arity of ${u.length} not registered. ${mg(l)}`);if(da.i.type!==n.type||
406
+ da.j.some((Ga,Hb)=>Ga.type!==z[Hb].type))throw Error("External function declaration types do not match actual function");return da.callFunction(y,F,N,...U)},wb:!0,H:!1,localName:l,namespaceURI:k,cb:f,i:n}}Fg(b,k,l,u.length,e)}
407
+ function Lq(a,b,c,d){const e=[],f=[];K(a,"*").forEach(t=>{switch(t[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 h=new Set;K(a,"moduleImport").forEach(t=>{const u=H(G(t,"namespacePrefix"));t=H(G(t,"targetNamespace"));if(h.has(t))throw Error(`XQST0047: The namespace "${t}" is imported more than once.`);
408
+ h.add(t);Gg(b,u,t)});K(a,"namespaceDecl").forEach(t=>{const u=H(G(t,"prefix"));t=H(G(t,"uri"));if("xml"===u||"xmlns"===u)throw xg();if("http://www.w3.org/XML/1998/namespace"===t||"http://www.w3.org/2000/xmlns/"===t)throw xg();Gg(b,u,t)});let k=null,l=null;for(const t of K(a,"defaultNamespaceDecl")){const u=H(G(t,"defaultNamespaceCategory")),z=H(G(t,"uri"));if(!z)throw vg();if("http://www.w3.org/XML/1998/namespace"===z||"http://www.w3.org/2000/xmlns/"===z)throw xg();if("function"===u){if(k)throw wg();
409
+ k=z}else if("element"===u){if(l)throw wg();l=z}}k&&(b.v=k);l&&Gg(b,"",l);K(a,"functionDecl").forEach(t=>{Kq(t,b,e,f,c)});const n=[];K(a,"varDecl").forEach(t=>{const u=Kg(G(t,"varName"));let z=u.namespaceURI;if(null===z&&(z=b.Z(u.prefix),!z&&u.prefix))throw zg(u.prefix);if(Jq.includes(z))throw tg();var y=G(t,"external");t=G(t,"varValue");let F,N;null!==y?(y=G(y,"varValue"),null!==y&&(F=G(y,"*"))):null!==t&&(F=G(t,"*"));if(n.some(U=>U.namespaceURI===z&&U.localName===u.localName))throw Error(`XQST0049: The variable ${z?
410
+ `Q{${z}}`:""}${u.localName} has already been declared.`);Hg(b,z||"",u.localName);if(c&&(F&&(N=Mk(F,{ra:!1,Y:!0})),F&&!Eg(b,z||"",u.localName))){let U=null;Ig(b,z,u.localName,(da,Ga)=>{if(U)return U();U=Ra(A(N,da,Ga));return U()});e.push({aa:N,Fb:new Cg(b)});n.push({aa:N,localName:u.localName,namespaceURI:z})}});f.forEach(t=>{if(!t.Bb.H&&t.aa.H)throw Oe(`The function Q{${t.namespaceURI}}${t.localName} is updating but the %updating annotation is missing.`);});return{Ia:f.map(t=>t.Bb),Va:n,source:d,
411
+ pa:t=>{h.forEach(u=>{Uk(b,u)});e.forEach(({aa:u,Fb:z})=>{h.forEach(y=>{Uk(z,y)});t.Ia.forEach(y=>{z.ua(y.namespaceURI,y.localName,y.arity,!0)||y.cb&&Fg(z,y.namespaceURI,y.localName,y.arity,y)});t.Va.forEach(y=>{z.eb(y.namespaceURI,y.localName)||Hg(z,y.namespaceURI,y.localName)});u.v(z)})}}};function Mq(a,b,c,d,e,f,h){const k=b.Y?"XQuery":"XPath";c=b.Ha?null:Pk(a,k,c,d,e,b.debug,f,h);return null!==c?{state:c.jc?1:2,aa:c.aa}:{state:0,ac:"string"===typeof a?Iq(a,b):Rk(a)}}function Nq(a,b,c,d){const e=G(a,"mainModule");if(!e)throw Error("Can not execute a library module.");const f=G(e,"prolog");if(f){if(!b.Y)throw Error("XPST0003: Use of XQuery functionality is not allowed in XPath context");Vk();d=Lq(f,c,!0,d);d.pa(d)}O(a,new rh(c));a=J(e,["queryBody","*"]);return Q(a,b)}
412
+ function Oq(a,b,c,d,e,f,h){const k=new qg(c,d,f,h),l=new Cg(k);0<Object.keys(e).length&&Vk();Object.keys(e).forEach(n=>{const t=e[n];Uk(l,t);Gg(l,n,t)});"string"===typeof a&&(a=Wk(a));c=Mq(a,b,c,d,e,f,h);switch(c.state){case 2:return{fa:l,aa:c.aa};case 1:return c.aa.v(l),Qk(a,b.Y?"XQuery":"XPath",k,e,c.aa,b.debug,f),{fa:l,aa:c.aa};case 0:return c=Nq(c.ac,b,l,a),c.v(l),b.Ha||Qk(a,b.Y?"XQuery":"XPath",k,e,c,b.debug,f),{fa:l,aa:c}}};function Pq(a){if(v(a.type,1))return a.value;if(v(a.type,54))return a.value.node;throw nc(`Unable to convert selector argument of type ${Da[a.type]} to either an ${Da[1]} or an ${Da[54]} representing an XQueryX program while calling 'fontoxpath:evaluate'`);}
413
+ function Qq(a,b,c,d){a=a.first();const e=b.first().h.reduce((f,h)=>{f[h.key.value]=Ra(h.value());return f},Object.create(null));b=e["."]?e["."]():w.empty();delete e["."];a=Pq(a);try{const {aa:f,fa:h}=Oq(a,{ra:!1,Y:!0,debug:d.debug,Ha:d.Ha,version:3.1},n=>c.Z(n),Object.keys(e).reduce((n,t)=>{n[t]=t;return n},{}),{},"http://www.w3.org/2005/xpath-functions",(n,t)=>c.Ua(n,t)),k=!b.isEmpty(),l=new dc({L:k?b.first():null,Ba:k?0:-1,sa:b,qa:Object.keys(e).reduce((n,t)=>{n[h.eb(null,t)]=e[t];return n},Object.create(null))});
414
+ return{kc:f.h(l,d).value,cc:a}}catch(f){hg(a,f)}};function Rq(a,b,c){if(1!==b.node.nodeType&&9!==b.node.nodeType)return[];const d=gb(a,b).reduce((e,f)=>{for(const h of Rq(a,f,c))e.push(h);return e},[]);c(b)&&d.unshift(b);return d}
415
+ const Sq=(a,b,c,d,e)=>{a=e.first();if(!a)throw mc("The context is absent, it needs to be present to use id function.");if(!v(a.type,53))throw nc("The context item is not a node, it needs to be node to use id function.");const f=b.h,h=d.N().reduce((k,l)=>{l.value.split(/\s+/).forEach(n=>{k[n]=!0});return k},Object.create(null));for(b=a.value;9!==b.node.nodeType;)if(b=x(f,b),null===b)throw Error("FODC0001: the root node of the target node is not a document node.");b=Rq(f,b,k=>{if(1!==k.node.nodeType)return!1;
416
+ k=fb(f,k,"id");if(!k||!h[k])return!1;h[k]=!1;return!0});return w.create(b.map(k=>sb(k)))},Tq=(a,b,c,d,e)=>{a=e.first();if(!a)throw mc("The context is absent, it needs to be present to use idref function.");if(!v(a.type,53))throw nc("The context item is not a node, it needs to be node to use idref function.");const f=b.h,h=d.N().reduce((k,l)=>{k[l.value]=!0;return k},Object.create(null));for(b=a.value;9!==b.node.nodeType;)if(b=x(f,b),null===b)throw Error("FODC0001: the root node of the context node is not a document node.");
417
+ b=Rq(f,b,k=>1!==k.node.nodeType?!1:(k=fb(f,k,"idref"))?k.split(/\s+/).some(l=>h[l]):!1);return w.create(b.map(k=>sb(k)))};function Uq(a){switch(typeof a){case "object":return Array.isArray(a)?w.m(new qb(a.map(b=>Ra(Uq(b))))):null===a?w.empty():w.m(new wb(Object.keys(a).map(b=>({key:g(b,1),value:Ra(Uq(a[b]))}))));case "number":return w.m(g(a,3));case "string":return w.m(g(a,1));case "boolean":return a?w.$():w.S();default:throw Error("Unexpected type in JSON parse");}};const Vq=(a,b,c,d,e)=>{const f=w.m(g("duplicates",1));a=vb(a,b,c,e,f);const h=a.isEmpty()?"use-first":a.first().value;return d.M(k=>w.m(new wb(k.reduce((l,n)=>{n.h.forEach(t=>{const u=l.findIndex(z=>ub(z.key,t.key));if(0<=u)switch(h){case "reject":throw Error("FOJS0003: Duplicate encountered when merging maps.");case "use-last":l.splice(u,1,t);return;case "combine":l.splice(u,1,{key:t.key,value:Ra(w.create(l[u].value().N().concat(t.value().N())))});return;default:return}l.push(t)});return l},[]))))};function Wq(a,b,c){let d=1;const e=a.value;a=a.Ra(!0);let f=null;const h=Math.max(b-1,0);-1!==a&&(f=Math.max(0,(null===c?a:Math.max(0,Math.min(a,c+(b-1))))-h));return w.create({next:k=>{for(;d<b;)e.next(k),d++;if(null!==c&&d>=b+c)return p;k=e.next(k);d++;return k}},f)}function Xq(a){return a.map(b=>v(b.type,19)?kd(b,3):b)}function Yq(a){a=Xq(a);if(a.some(b=>Number.isNaN(b.value)))return[g(NaN,3)];a=Oi(a);if(!a)throw Error("FORG0006: Incompatible types to be converted to a common type");return a}
418
+ const Zq=(a,b,c,d,e,f)=>tb([e,f],([h,k])=>{if(Infinity===h.value)return w.empty();if(-Infinity===h.value)return k&&Infinity===k.value?w.empty():d;if(k){if(isNaN(k.value))return w.empty();Infinity===k.value&&(k=null)}return isNaN(h.value)?w.empty():Wq(d,Math.round(h.value),k?Math.round(k.value):null)}),$q=(a,b,c,d,e)=>{if(d.isEmpty())return e;a=Xq(d.N());a=Oi(a);if(!a)throw Error("FORG0006: Incompatible types to be converted to a common type");if(!a.every(f=>v(f.type,2)))throw Error("FORG0006: items passed to fn:sum are not all numeric.");
419
+ b=a.reduce((f,h)=>f+h.value,0);return a.every(f=>v(f.type,5))?w.m(g(b,5)):a.every(f=>v(f.type,3))?w.m(g(b,3)):a.every(f=>v(f.type,4))?w.m(g(b,4)):w.m(g(b,6))};var ar=[].concat(Nf,[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"boolean",j:[{type:59,g:2}],i:{type:0,g:3},callFunction:(a,b,c,d)=>d.ea()?w.$():w.S()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"true",j:[],i:{type:0,g:3},callFunction:()=>w.$()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"not",j:[{type:59,g:2}],i:{type:0,g:3},callFunction:(a,b,c,d)=>!1===d.ea()?w.$():w.S()},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"false",
420
+ j:[],i:{type:0,g:3},callFunction:()=>w.S()}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"last",j:[],i:{type:5,g:3},callFunction:a=>{if(null===a.L)throw mc("The fn:last() function depends on dynamic context, which is absent.");let b=!1;return w.create({next:()=>{if(b)return p;const c=a.sa.Ra();b=!0;return q(g(c,5))}},1)}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"position",j:[],i:{type:5,g:3},callFunction:a=>{if(null===a.L)throw mc("The fn:position() function depends on dynamic context, which is absent.");
421
+ return w.m(g(a.Ba+1,5))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-dateTime",j:[],i:{type:10,g:3},callFunction:a=>w.m(g(fc(a),10))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-date",j:[],i:{type:7,g:3},callFunction:a=>w.m(g(Mb(fc(a),7),7))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"current-time",j:[],i:{type:8,g:3},callFunction:a=>w.m(g(Mb(fc(a),8),8))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"implicit-timezone",
422
+ j:[],i:{type:17,g:3},callFunction:a=>w.m(g(gc(a),17))}],Of,Wf,cg,[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"years-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(a,b,c,d)=>d.isEmpty()?d:w.m(g(d.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:(a,b,c,d)=>d.isEmpty()?d:w.m(g(d.first().value.$a(),5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
423
+ localName:"days-from-duration",j:[{type:18,g:0}],i:{type:5,g:0},callFunction:(a,b,c,d)=>d.isEmpty()?d:w.m(g(d.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:(a,b,c,d)=>d.isEmpty()?d:w.m(g(d.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:(a,b,c,d)=>d.isEmpty()?d:w.m(g(d.first().value.getMinutes(),
424
+ 5))},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"seconds-from-duration",j:[{type:18,g:0}],i:{type:4,g:0},callFunction:(a,b,c,d)=>d.isEmpty()?d:w.m(g(d.first().value.getSeconds(),4))}],eg,[{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:Sq},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"id",j:[{type:1,g:2}],i:{type:54,g:2},callFunction(a,b,c,d){return Sq(a,b,c,d,w.m(a.L))}},{namespaceURI:"http://www.w3.org/2005/xpath-functions",
425
+ localName:"idref",j:[{type:1,g:2},{type:53,g:3}],i:{type:53,g:2},callFunction:Tq},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"idref",j:[{type:1,g:2}],i:{type:53,g:2},callFunction(a,b,c,d){return Tq(a,b,c,d,w.m(a.L))}}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"parse-json",j:[{type:1,g:3}],i:{type:59,g:0},callFunction:(a,b,c,d)=>{let e;try{e=JSON.parse(d.first().value)}catch(f){throw Error("FOJS0001: parsed JSON string contains illegal JSON.");}return Uq(e)}}],
426
+ [{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:(a,b,c,d,e)=>tb([d,e],([f,h])=>f.h.some(k=>ub(k.key,h))?w.$():w.S())},{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:(a,b,c,d,e)=>d.map(f=>new wb([{key:f,value:Ra(e)}]))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"for-each",j:[{type:61,g:3},{type:59,
427
+ g:2}],i:{type:59,g:2},callFunction:(a,b,c,d,e)=>tb([d,e],([f,h])=>kc(f.h.map(k=>h.value.call(void 0,a,b,c,w.m(k.key),k.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:vb},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"keys",j:[{type:61,g:3}],i:{type:46,g:2},callFunction:(a,b,c,d)=>tb([d],([e])=>w.create(e.h.map(f=>f.key)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",
428
+ localName:"merge",j:[{type:61,g:2},{type:61,g:3}],i:{type:61,g:3},callFunction:Vq},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"merge",j:[{type:61,g:2}],i:{type:61,g:3},callFunction(a,b,c,d){return Vq(a,b,c,d,w.m(new wb([{key:g("duplicates",1),value:()=>w.m(g("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:(a,b,c,d,e,f)=>tb([d,e],([h,k])=>{h=h.h.concat();
429
+ const l=h.findIndex(n=>ub(n.key,k));0<=l?h.splice(l,1,{key:k,value:Ra(f)}):h.push({key:k,value:Ra(f)});return w.m(new wb(h))})},{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:(a,b,c,d,e)=>tb([d],([f])=>{const h=f.h.concat();return e.M(k=>{k.forEach(l=>{const n=h.findIndex(t=>ub(t.key,l));0<=n&&h.splice(n,1)});return w.m(new wb(h))})})},{namespaceURI:"http://www.w3.org/2005/xpath-functions/map",localName:"size",
430
+ j:[{type:61,g:3}],i:{type:5,g:3},callFunction:(a,b,c,d)=>d.map(e=>g(e.h.length,5))}],[{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"pi",j:[],i:{type:3,g:3},callFunction:()=>w.m(g(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:(a,b,c,d)=>d.map(e=>g(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:(a,
431
+ b,c,d)=>d.map(e=>g(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:(a,b,c,d)=>d.map(e=>g(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:(a,b,c,d)=>d.map(e=>g(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},
432
+ callFunction:(a,b,c,d,e)=>e.M(([f])=>d.map(h=>1!==Math.abs(h.value)||Number.isFinite(f.value)?g(Math.pow(h.value,f.value),3):g(1,3)))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"sqrt",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(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:(a,b,c,d)=>d.map(e=>g(Math.sin(e.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",
433
+ localName:"cos",j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(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:(a,b,c,d)=>d.map(e=>g(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:(a,b,c,d)=>d.map(e=>g(Math.asin(e.value),3))},{namespaceURI:"http://www.w3.org/2005/xpath-functions/math",localName:"acos",
434
+ j:[{type:3,g:0}],i:{type:3,g:0},callFunction:(a,b,c,d)=>d.map(e=>g(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:(a,b,c,d)=>d.map(e=>g(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:(a,b,c,d,e)=>e.M(([f])=>d.map(h=>g(Math.atan2(h.value,f.value),3)))}],Ae,$d,[{namespaceURI:"http://fontoxpath/operators",
435
+ localName:"to",j:[{type:5,g:0},{type:5,g:0}],i:{type:5,g:2},callFunction:(a,b,c,d,e)=>{a=d.first();e=e.first();if(null===a||null===e)return w.empty();let f=a.value;e=e.value;return f>e?w.empty():w.create({next:()=>q(g(f++,5))},e-f+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:(a,b,c,d,e)=>tb([d,e],([f,h])=>{h=h.value;if(!uc(h,23))throw Error("FOCA0002: The provided QName is invalid.");f=f?f.value||null:null;
436
+ if(null===f&&h.includes(":"))throw Error("FOCA0002: The URI of a QName may not be empty if a prefix is provided.");if(d.isEmpty())return w.m(g(new Sa("",null,h),23));if(!h.includes(":"))return w.m(g(new Sa("",f,h),23));const [k,l]=h.split(":");return w.m(g(new Sa(k,f,l),23))})},{namespaceURI:"http://www.w3.org/2005/xpath-functions",localName:"prefix-from-QName",j:[{type:23,g:0}],i:{type:24,g:0},callFunction:(a,b,c,d)=>tb([d],([e])=>{if(null===e)return w.empty();e=e.value;return e.prefix?w.m(g(e.prefix,
437
+ 24)):w.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:(a,b,c,d)=>d.map(e=>g(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:(a,b,c,d)=>d.map(e=>g(e.value.namespaceURI||"",20))}],[{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>d.X({empty:()=>w.$(),multiple:()=>w.S(),m:()=>w.S()}),localName:"empty",
438
+ namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>d.X({empty:()=>w.S(),multiple:()=>w.$(),m:()=>w.$()}),localName:"exists",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>Wq(d,1,1),localName:"head",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:0}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>Wq(d,2,null),localName:"tail",namespaceURI:"http://www.w3.org/2005/xpath-functions",
439
+ i:{type:59,g:2}},{j:[{type:59,g:2},{type:5,g:3},{type:59,g:2}],callFunction:(a,b,c,d,e,f)=>{if(d.isEmpty())return f;if(f.isEmpty())return d;a=d.N();e=e.first().value-1;0>e?e=0:e>a.length&&(e=a.length);b=a.slice(e);return w.create(a.slice(0,e).concat(f.N(),b))},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:(a,b,c,d,e)=>{a=e.first().value;d=d.N();if(!d.length||1>a||a>d.length)return w.create(d);d.splice(a-
440
+ 1,1);return w.create(d)},localName:"remove",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>d.M(e=>w.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:(a,b,c,d,e)=>Zq(a,b,c,d,e,w.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}],
441
+ callFunction:Zq,localName:"subsequence",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>d,localName:"unordered",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:46,g:2}],callFunction:(a,b,c,d)=>{const e=rc(d,b).N();return w.create(e).filter((f,h)=>e.slice(0,h).every(k=>!De(f,k)))},localName:"distinct-values",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:2}},{j:[{type:46,g:2},{type:1,
442
+ 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:(a,b,c,d,e)=>e.M(([f])=>rc(d,b).map((h,k)=>ui("eqOp",h.type,f.type)(h,f,a)?g(k+1,5):g(-1,5)).filter(h=>-1!==h.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");
443
+ },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:(a,b,c,d,e)=>{let f=!1;const h=Ge(a,b,c,d,e);return w.create({next:()=>{if(f)return p;const k=h.next(0);if(k.done)return k;f=!0;return q(g(k.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");
444
+ },localName:"deep-equal",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:0,g:3}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>{let e=!1;return w.create({next:()=>{if(e)return p;const f=d.Ra();e=!0;return q(g(f,5))}})},localName:"count",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:3}},{j:[{type:46,g:2}],callFunction:(a,b,c,d)=>{if(d.isEmpty())return d;a=Xq(d.N());a=Oi(a);if(!a)throw Error("FORG0006: Incompatible types to be converted to a common type");if(!a.every(e=>
445
+ v(e.type,2)))throw Error("FORG0006: items passed to fn:avg are not all numeric.");b=a.reduce((e,f)=>e+f.value,0)/a.length;return a.every(e=>v(e.type,5)||v(e.type,3))?w.m(g(b,3)):a.every(e=>v(e.type,4))?w.m(g(b,4)):w.m(g(b,6))},localName:"avg",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2}],callFunction:(a,b,c,d)=>{if(d.isEmpty())return d;a=Yq(d.N());return w.m(a.reduce((e,f)=>e.value<f.value?f:e))},localName:"max",namespaceURI:"http://www.w3.org/2005/xpath-functions",
446
+ 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:(a,b,c,d)=>{if(d.isEmpty())return d;a=Yq(d.N());return w.m(a.reduce((e,f)=>e.value>f.value?f: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");
447
+ },localName:"min",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:46,g:2}],callFunction:(a,b,c,d)=>$q(a,b,c,d,w.m(g(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:$q,localName:"sum",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:46,g:0}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>{if(!d.isEmpty()&&!d.oa())throw Error("FORG0003: The argument passed to fn:zero-or-one contained more than one item.");
448
+ return d},localName:"zero-or-one",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:0}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>{if(d.isEmpty())throw Error("FORG0004: The argument passed to fn:one-or-more was empty.");return d},localName:"one-or-more",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:1}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>{if(!d.oa())throw Error("FORG0005: The argument passed to fn:exactly-one is empty or contained more than one item.");
449
+ return d},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:(a,b,c,d,e)=>{if(d.isEmpty())return d;const f=e.first(),h=f.o;if(1!==h.length)throw Error("XPTY0004: signature of function passed to fn:filter is incompatible.");return d.filter(k=>{k=Ad(h[0],w.m(k),b,"fn:filter",!1);k=f.value.call(void 0,a,b,c,k);if(!k.oa()||!v(k.first().type,0))throw Error("XPTY0004: signature of function passed to fn:filter is incompatible.");
450
+ return k.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:(a,b,c,d,e)=>{if(d.isEmpty())return d;const f=e.first(),h=f.o;if(1!==h.length)throw Error("XPTY0004: signature of function passed to fn:for-each is incompatible.");const k=d.value;let l;return w.create({next:n=>{for(;;){if(!l){var t=k.next(0);if(t.done)return t;t=Ad(h[0],w.m(t.value),b,"fn:for-each",!1);l=f.value.call(void 0,a,b,c,t).value}t=
451
+ l.next(n);if(!t.done)return t;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:(a,b,c,d,e,f)=>{if(d.isEmpty())return d;const h=f.first(),k=h.o;if(2!==k.length)throw Error("XPTY0004: signature of function passed to fn:fold-left is incompatible.");return d.M(l=>l.reduce((n,t)=>{n=Ad(k[0],n,b,"fn:fold-left",!1);t=Ad(k[1],w.m(t),b,"fn:fold-left",!1);return h.value.call(void 0,a,b,c,n,t)},
452
+ e))},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:(a,b,c,d,e,f)=>{if(d.isEmpty())return d;const h=f.first(),k=h.o;if(2!==k.length)throw Error("XPTY0004: signature of function passed to fn:fold-right is incompatible.");return d.M(l=>l.reduceRight((n,t)=>{n=Ad(k[0],n,b,"fn:fold-right",!1);t=Ad(k[1],w.m(t),b,"fn:fold-right",!1);return h.value.call(void 0,a,b,c,t,n)},e))},localName:"fold-right",
453
+ namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:59,g:2}},{j:[{type:59,g:2}],callFunction:(a,b,c,d)=>{if(!b.Wa)throw Error("serialize() called but no xmlSerializer set in execution parameters.");a=d.N();if(!a.every(e=>v(e.type,53)))throw Error("Expected argument to fn:serialize to resolve to a sequence of Nodes.");return w.m(g(a.map(e=>b.Wa.serializeToString(ag(e.value,b,!1))).join(""),1))},localName:"serialize",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:1,g:3}}],le,
454
+ [{j:[{type:59,g:3},{type:61,g:3}],callFunction:(a,b,c,d,e)=>{let f,h;return w.create({next:()=>{f||({kc:f,cc:h}=Qq(d,e,c,b));try{return f.next(0)}catch(k){hg(h,k)}}})},localName:"evaluate",namespaceURI:"http://fontoxml.com/fontoxpath",i:{type:59,g:2}},{j:[],callFunction:()=>w.m(g("undefined"===typeof VERSION?"devbuild":VERSION,1)),localName:"version",namespaceURI:"http://fontoxml.com/fontoxpath",i:{type:1,g:3}}],[{j:[{type:23,g:3},{type:5,g:3}],callFunction:(a,b,c,d,e)=>tb([d,e],([f,h])=>{const k=
455
+ c.ua(f.value.namespaceURI,f.value.localName,h.value);if(null===k)return w.empty();f=new Va({j:k.j,arity:h.value,localName:f.value.localName,namespaceURI:f.value.namespaceURI,i:k.i,value:k.callFunction});return w.m(f)}),localName:"function-lookup",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{g:0,type:60}},{j:[{type:60,g:3}],callFunction:(a,b,c,d)=>tb([d],([e])=>e.bb()?w.empty():w.m(g(new Sa("",e.l,e.D),23))),localName:"function-name",namespaceURI:"http://www.w3.org/2005/xpath-functions",
456
+ i:{type:23,g:0}},{j:[{type:60,g:3}],callFunction:(a,b,c,d)=>tb([d],([e])=>w.m(g(e.v,5))),localName:"function-arity",namespaceURI:"http://www.w3.org/2005/xpath-functions",i:{type:5,g:3}}]);class br{constructor(a){this.h=a}createAttributeNS(a,b){return this.h.createAttributeNS(a,b)}createCDATASection(a){return this.h.createCDATASection(a)}createComment(a){return this.h.createComment(a)}createDocument(){return this.h.createDocument()}createElementNS(a,b){return this.h.createElementNS(a,b)}createProcessingInstruction(a,b){return this.h.createProcessingInstruction(a,b)}createTextNode(a){return this.h.createTextNode(a)}};var cr=Symbol("IS_XPATH_VALUE_SYMBOL");function dr(a){return(b,c)=>{b=Xb(new ob(null===c?new Za:c),b,Ja(a));return{[cr]:!0,zb:b}}};ar.forEach(a=>{og(a.namespaceURI,a.localName,a.j,a.i,a.callFunction)});function er(a){return a&&"object"===typeof a&&"lookupNamespaceURI"in a?b=>a.lookupNamespaceURI(b||null):()=>null}function fr(a){return({prefix:b,localName:c})=>b?null:{namespaceURI:a,localName:c}}
457
+ function gr(a,b,c,d,e,f){if(null===d||void 0===d)d=d||{};const h=e?{jb:e.logger||{trace:console.log.bind(console)},Oa:e.documentWriter,kb:e.moduleImports,Db:e.namespaceResolver,dc:e.functionNameResolver,Ja:e.nodesFactory,Wa:e.xmlSerializer}:{jb:{trace:console.log.bind(console)},kb:{},Db:null,Ja:null,Oa:null,Wa:null},k=new ob(null===c?new Za:c);c=h.kb||Object.create(null);var l=void 0===e.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":e.defaultFunctionNamespaceURI;const n=Oq(a,
458
+ f,h.Db||er(b),d,c,l,h.dc||fr(l));a=b?Yb(k,b):w.empty();b=!h.Ja&&f.Y?new $e(b):new br(h.Ja);c=h.Oa?new bb(h.Oa):ab;l=h.Wa;const t=Object.keys(d).reduce((y,F)=>{const N=d[F];y[`Q{}${F}[0]`]=N&&"object"===typeof N&&cr in N?()=>w.create(N.zb):()=>Yb(k,d[F]);return y},Object.create(null));let u;for(const y of Object.keys(n.fa.Fa))t[y]||(t[y]=()=>(0,n.fa.Fa[y])(u,z));u=new dc({L:a.first(),Ba:0,sa:a,qa:t});const z=new jc(f.debug,f.Ha,k,b,c,e.currentContext,new Map,h.jb,l);return{tb:u,ub:z,aa:n.aa}};function hr(a,b){const c={};let d=0,e=!1,f=null;return{next:()=>{if(e)return p;for(;d<a.h.length;){const k=a.h[d].key.value;if(!f){const l=a.h[d];var h=l.value().X({default:n=>n,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 ${l.key.value} holds multiple items`);}}).first();if(null===h){c[k]=null;d++;continue}f=ir(h,b)}h=f.next(0);f=null;c[k]=
459
+ h.value;d++}e=!0;return q(c)}}}function jr(a,b){const c=[];let d=0,e=!1,f=null;return{next:()=>{if(e)return p;for(;d<a.members.length;){if(!f){var h=a.members[d]().X({default:k=>k,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===h){c[d++]=null;continue}f=ir(h,b)}h=f.next(0);f=null;c[d++]=h.value}e=!0;return q(c)}}}
460
+ function ir(a,b){if(v(a.type,61))return hr(a,b);if(v(a.type,62))return jr(a,b);if(v(a.type,23)){const c=a.value;return{next:()=>q(`Q{${c.namespaceURI||""}}${c.localName}`)}}switch(a.type){case 7:case 8:case 9:case 11:case 12:case 13:case 14:case 15:const c=a.value;return{next:()=>q(Nb(c))};case 47:case 53:case 54:case 55:case 56:case 57:case 58:const d=a.value;return{next:()=>q(ag(d,b,!1))};default:return{next:()=>q(a.value)}}};var kr={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};kr[kr.ANY]="ANY";kr[kr.NUMBER]="NUMBER";kr[kr.STRING]="STRING";kr[kr.BOOLEAN]="BOOLEAN";kr[kr.NODES]="NODES";kr[kr.FIRST_NODE]="FIRST_NODE";kr[kr.STRINGS]="STRINGS";kr[kr.MAP]="MAP";kr[kr.ARRAY]="ARRAY";kr[kr.NUMBERS]="NUMBERS";kr[kr.ALL_RESULTS]="ALL_RESULTS";kr[kr.ASYNC_ITERATOR]="ASYNC_ITERATOR";
461
+ function lr(a,b,c,d){switch(c){case 3:return b.ea();case 2:return b=rc(b,d).N(),b.length?b.map(l=>kd(l,1).value).join(" "):"";case 10:return b=rc(b,d).N(),b.length?b.map(l=>l.value+""):[];case 1:return b=b.first(),null!==b&&v(b.type,2)?b.value:NaN;case 9:b=b.first();if(null===b)return null;if(!v(b.type,53))throw Error("Expected XPath "+fg(a)+" to resolve to Node. Got "+Da[b.type]);return ag(b.value,d,!1);case 7:b=b.N();if(!b.every(l=>v(l.type,53)))throw Error("Expected XPath "+fg(a)+" to resolve to a sequence of Nodes.");
462
+ return b.map(l=>ag(l.value,d,!1));case 11:b=b.N();if(1!==b.length)throw Error("Expected XPath "+fg(a)+" to resolve to a single map.");b=b[0];if(!v(b.type,61))throw Error("Expected XPath "+fg(a)+" to resolve to a map");return hr(b,d).next(0).value;case 12:b=b.N();if(1!==b.length)throw Error("Expected XPath "+fg(a)+" to resolve to a single array.");b=b[0];if(!v(b.type,62))throw Error("Expected XPath "+fg(a)+" to resolve to an array");return jr(b,d).next(0).value;case 13:return b.N().map(l=>{if(!v(l.type,
463
+ 2))throw Error("Expected XPath "+fg(a)+" to resolve to numbers");return l.value});case 99:const e=b.value;let f=null,h=!1;const k=()=>{for(;!h;){if(!f){var l=e.next(0);if(l.done){h=!0;break}f=ir(l.value,d)}l=f.next(0);f=null;return l}return Promise.resolve({done:!0,value:null})};return"asyncIterator"in Symbol?{[Symbol.asyncIterator](){return this},next:()=>(new Promise(l=>l(k()))).catch(l=>{hg(a,l)})}:{next:()=>new Promise(l=>l(k()))};case 14:return b.N().map(l=>ir(l,d).next(0).value);default:return b=
464
+ b.N(),b.every(l=>v(l.type,53)&&!v(l.type,47))?(b=b.map(l=>ag(l.value,d,!1)),1===b.length?b[0]:b):1===b.length?(b=b[0],v(b.type,62)?jr(b,d).next(0).value:v(b.type,61)?hr(b,d).next(0).value:qc(b,d).first().value):rc(w.create(b),d).N().map(l=>l.value)}};let mr=!1,nr=null;
465
+ var or={getPerformanceSummary(){const a=nr.getEntriesByType("measure").filter(b=>b.name.startsWith("XPath: "));return Array.from(a.reduce((b,c)=>{var d=c.name.substring(7);b.has(d)?(d=b.get(d),d.times+=1,d.totalDuration+=c.duration):b.set(d,{xpath:d,times:1,totalDuration:c.duration,average:0});return b},new Map).values()).map(b=>{b.average=b.totalDuration/b.times;return b}).sort((b,c)=>c.totalDuration-b.totalDuration)},setPerformanceImplementation(a){nr=a},startProfiling(){if(null===nr)throw Error("Performance API object must be set using `profiler.setPerformanceImplementation` before starting to profile");
466
+ nr.clearMarks();nr.clearMeasures();mr=!0},stopProfiling(){mr=!1}};let pr=0;var qr={XPATH_3_1_LANGUAGE:"XPath3.1",XQUERY_3_1_LANGUAGE:"XQuery3.1",XQUERY_UPDATE_3_1_LANGUAGE:"XQueryUpdate3.1",XPATH_4_0_LANGUAGE:"XPath4.0",XQUERY_4_0_LANGUAGE:"XQuery4.0",XQUERY_UPDATE_4_0_LANGUAGE:"XQueryUpdate4.0"};const rr=(a,b,c,d,e,f)=>{e=e||0;if(!a||"string"!==typeof a&&!("nodeType"in a))throw new TypeError("Failed to execute 'evaluateXPath': xpathExpression must be a string or an element depicting an XQueryX DOM tree.");f=f||{};let h,k;try{const n=gr(a,b,c||null,d||{},f,{ra:"XQueryUpdate3.1"===f.language,Y:"XQuery3.1"===f.language||"XQueryUpdate3.1"===f.language,debug:!!f.debug,Ha:!!f.disableCache,version:"XPath4.0"===f.language||"XQuery4.0"===f.language||"XQueryUpdate4.0"===f.language?4:3.1});var l=n.tb;
467
+ h=n.ub;k=n.aa}catch(n){hg(a,n)}if(k.H)throw Error("XUST0001: Updating expressions should be evaluated as updating expressions");if(3===e&&b&&"object"===typeof b&&"nodeType"in b&&(c=k.D(),b=Ya(b),null!==c&&!b.includes(c)))return!1;try{b=a;mr&&("string"!==typeof b&&(b=fg(b)),nr.mark(`${b}${0===pr?"":"@"+pr}`),pr++);const n=A(k,l,h),t=lr(a,n,e,h);e=a;mr&&("string"!==typeof e&&(e=fg(e)),pr--,l=`${e}${0===pr?"":"@"+pr}`,nr.measure(`XPath: ${e}`,l),nr.clearMarks(l));return t}catch(n){hg(a,n)}};
468
+ Object.assign(rr,{lc:14,ANY_TYPE:0,Nb:12,Ob:99,BOOLEAN_TYPE:3,Qb:9,Tb:11,Vb:7,Wb:13,NUMBER_TYPE:1,Xb:10,STRING_TYPE:2,mc:"XPath3.1",nc:"XQuery3.1",$b:"XQueryUpdate3.1"});
469
+ Object.assign(rr,{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",XPATH_4_0_LANGUAGE:"XPath4.0",XQUERY_4_0_LANGUAGE:"XQuery4.0"});function sr(a,b,c,d,e){return rr(a,b,c,d,rr.Ob,e)};function tr(a,b,c,d){return{pendingUpdateList:a.ca.map(e=>e.h(d)),xdmValue:lr(b,w.create(a.I),c,d)}};async function ur(a,b,c,d,e){e=e||{};Vk();let f,h;try{const n=gr(a,b,c||null,d||{},e||{},{ra:!0,Y:!0,debug:!!e.debug,Ha:!!e.disableCache,version:"XQueryUpdate4.0"===e.language?4:3.1});var k=n.tb;f=n.ub;h=n.aa}catch(n){hg(a,n)}if(!h.H){k=[];a=sr(a,b,c,d,Object.assign(Object.assign({},e),{language:"XQueryUpdate3.1"}));for(b=await a.next();!b.done;b=await a.next())k.push(b.value);return Promise.resolve({pendingUpdateList:[],xdmValue:k})}let l;try{l=h.s(k,f).next(0)}catch(n){hg(a,n)}return tr(l.value,
470
+ a,e.returnType,f)};function vr(a,b,c,d,e){e=e||{};Vk();let f,h,k;try{const n=gr(a,b,c||null,d||{},e||{},{ra:!0,Y:!0,debug:!!e.debug,Ha:!!e.disableCache,version:"XQueryUpdate4.0"===e.language?4:3.1});f=n.tb;h=n.ub;k=n.aa}catch(n){hg(a,n)}if(!k.H)return{pendingUpdateList:[],xdmValue:rr(a,b,c,d,e.i,Object.assign(Object.assign({},e),{language:rr.$b}))};let l;try{l=k.s(f,h).next(0)}catch(n){hg(a,n)}return tr(l.value,a,e.returnType,h)};function wr(a,b,c,d,e){return rr(a,b,c,d,rr.Nb,e)};function xr(a,b,c,d,e){return rr(a,b,c,d,rr.BOOLEAN_TYPE,e)};function yr(a,b,c,d,e){return rr(a,b,c,d,rr.Qb,e)};function zr(a,b,c,d,e){return rr(a,b,c,d,rr.Tb,e)};function Ar(a,b,c,d,e){return rr(a,b,c,d,rr.Vb,e)};function Br(a,b,c,d,e){return rr(a,b,c,d,rr.NUMBER_TYPE,e)};function Cr(a,b,c,d,e){return rr(a,b,c,d,rr.Wb,e)};function Dr(a,b,c,d,e){return rr(a,b,c,d,rr.STRING_TYPE,e)};function Er(a,b,c,d,e){return rr(a,b,c,d,rr.Xb,e)};function Fr(a,b,c,d){b=new ob(b?b:new Za);d=d?new bb(d):ab;c=c?c=new br(c):null;a=a.map(Xj);lf(a,b,c,d)};function Y(a,b,c){return{code:a,ta:b,G:c,isAstAccepted:!0}}function Gr(a){return{isAstAccepted:!1,reason:a}};function Z(a,b){return a.isAstAccepted?b(a):a}function Hr(a,b){return a.isAstAccepted?b(a):[a,null]}function Ir(a,b,c){return Z(a,d=>{switch(d.ta.type){case 0:return d;case 1:return Z(Jr(c,d,"nodes"),e=>Z(Jr(c,b,"contextItem"),f=>Y(`(function () {
463
471
  const { done, value } = ${e.code}(${f.code}).next();
464
472
  return done ? null : value;
465
- })()`,{type:0},[...e.H,...f.H])));default:throw Error(`invalid generated code type to convert to value: ${d.ua.type}`);}})}function wr(a,b,c,d){a=ur(a,c,d);return b&&0===b.type&&3===b.g?a:Z(a,e=>Y(`!!${e.code}`,{type:0},e.H))}
466
- function xr(a,b,c){return b?a.isAstAccepted&&0!==a.ua.type?sr("Atomization only implemented for single value"):v(b.type,1)?a:v(b.type,47)?Z(vr(c,a,"attr"),d=>Y(`(${d.code} ? domFacade.getData(${d.code}) : null)`,{type:0},d.H)):sr("Atomization only implemented for string and attribute"):sr("Can not atomize value if type was not annotated")}function yr(a,b,c,d){a=ur(a,c,d);d=xr(a,b,d);return wc(b)?Z(d,e=>Y(`${e.code} ?? ''`,{type:0},e.H)):d}
467
- function zr(a,b,c){return Z(vr(c,a,"node"),d=>1===d.ua.type?d:b&&!v(b.type,53)?sr("Can not evaluate to node if expression does not result in nodes"):Y(`(function () {
473
+ })()`,{type:0},[...e.G,...f.G])));default:throw Error(`invalid generated code type to convert to value: ${d.ta.type}`);}})}function Kr(a,b,c,d){a=Ir(a,c,d);return b&&0===b.type&&3===b.g?a:Z(a,e=>Y(`!!${e.code}`,{type:0},e.G))}
474
+ function pu(a,b,c){return b?a.isAstAccepted&&0!==a.ta.type?Gr("Atomization only implemented for single value"):v(b.type,1)?a:v(b.type,47)?Z(Jr(c,a,"attr"),d=>Y(`(${d.code} ? domFacade.getData(${d.code}) : null)`,{type:0},d.G)):Gr("Atomization only implemented for string and attribute"):Gr("Can not atomize value if type was not annotated")}function qu(a,b,c,d){a=Ir(a,c,d);d=pu(a,b,d);return xc(b)?Z(d,e=>Y(`${e.code} ?? ''`,{type:0},e.G)):d}
475
+ function ru(a,b,c){return Z(Jr(c,a,"node"),d=>1===d.ta.type?d:b&&!v(b.type,53)?Gr("Can not evaluate to node if expression does not result in nodes"):Y(`(function () {
468
476
  if (${d.code} !== null && !${d.code}.nodeType) {
469
477
  throw new Error('XPDY0050: The result of the expression was not a node');
470
478
  }
471
479
  return ${d.code};
472
- })()`,{type:0},d.H))}function Ar(a,b,c,d){return Z(a,e=>{switch(e.ua.type){case 1:return Z(vr(d,e,"nodes"),f=>Z(vr(d,c,"contextItem"),h=>Y(`Array.from(${f.code}(${h.code}))`,{type:0},[...f.H,...h.H])));case 0:return Z(vr(d,zr(e,b,d),"node"),f=>Y(`(${f.code} === null ? [] : [${f.code}])`,{type:0},f.H));default:return sr("Unsupported code type to evaluate to nodes")}})}
473
- function Br(a,b){return Z(a,c=>Z(b,d=>{if(0!==c.ua.type||0!==d.ua.type)throw Error("can only use emitAnd with value expressions");return Y(`${c.code} && ${d.code}`,{type:0},[...c.H,...d.H])}))};function Cr(a,b,c,d){return(a=J(a,[b,"*"]))?d.h(a,c,d):[sr(`${b} expression not found`),null]};const gu={equalOp:"eqOp",notEqualOp:"neOp",lessThanOrEqualOp:"leOp",lessThanOp:"ltOp",greaterThanOrEqualOp:"geOp",greaterThanOp:"gtOp"},hu={eqOp:"eqOp",neOp:"neOp",leOp:"geOp",ltOp:"gtOp",geOp:"leOp",gtOp:"ltOp"};
474
- function iu(a,b,c,d){const e=I(J(a,["firstOperand","*"]),"type"),f=I(J(a,["secondOperand","*"]),"type");if(!e||!f)return sr("Can not generate code for value compare without both types");var h=[47,1];if(!h.includes(e.type)||!h.includes(f.type))return sr(`Unsupported types in compare: [${Da[e.type]}, ${Da[f.type]}]`);h=new Map([["eqOp","==="],["neOp","!=="]]);if(!h.has(b))return sr(b+" not yet implemented");const k=h.get(b);[b]=Cr(a,"firstOperand",c,d);b=ur(b,c,d);b=xr(b,e,d);return Z(vr(d,b,"first"),
475
- l=>{var [n]=Cr(a,"secondOperand",c,d);n=ur(n,c,d);n=xr(n,f,d);return Z(vr(d,n,"second"),t=>{const u=[];wc(e)&&u.push(`${l.code} === null`);wc(f)&&u.push(`${t.code} === null`);return Y(`(${u.length?`${u.join(" || ")} ? null : `:""}${l.code} ${k} ${t.code})`,{type:0},[...l.H,...t.H])})})}
476
- function ju(a,b,c,d,e,f){var h=I(J(a,[b,"*"]),"type");const k=I(J(a,[c,"*"]),"type");if(!h||!k)return sr("Can not generate code for general compare without both types");var l=[47,1];if(!l.includes(h.type)||!l.includes(k.type))return sr(`Unsupported types in compare: [${Da[h.type]}, ${Da[k.type]}]`);l=new Map([["eqOp","==="],["neOp","!=="]]);if(!l.has(d))return sr(d+" not yet implemented");const n=l.get(d);[b]=Cr(a,b,e,f);b=ur(b,e,f);h=xr(b,h,f);return Z(vr(f,h,"single"),t=>{const [u]=Cr(a,c,e,f);
477
- return Z(vr(f,u,"multiple"),z=>{if(1!==z.ua.type)return sr("can only generate general compare for a single value and a generator");const y=ku(f,lu(f,"n")),G=xr(y,k,f);return Z(e,N=>Z(G,U=>Y(`(function () {
480
+ })()`,{type:0},d.G))}function su(a,b,c,d){return Z(a,e=>{switch(e.ta.type){case 1:return Z(Jr(d,e,"nodes"),f=>Z(Jr(d,c,"contextItem"),h=>Y(`Array.from(${f.code}(${h.code}))`,{type:0},[...f.G,...h.G])));case 0:return Z(Jr(d,ru(e,b,d),"node"),f=>Y(`(${f.code} === null ? [] : [${f.code}])`,{type:0},f.G));default:return Gr("Unsupported code type to evaluate to nodes")}})}
481
+ function tu(a,b){return Z(a,c=>Z(b,d=>{if(0!==c.ta.type||0!==d.ta.type)throw Error("can only use emitAnd with value expressions");return Y(`${c.code} && ${d.code}`,{type:0},[...c.G,...d.G])}))};function uu(a,b,c,d){return(a=J(a,[b,"*"]))?d.h(a,c,d):[Gr(`${b} expression not found`),null]};const vu={equalOp:"eqOp",notEqualOp:"neOp",lessThanOrEqualOp:"leOp",lessThanOp:"ltOp",greaterThanOrEqualOp:"geOp",greaterThanOp:"gtOp"},wu={eqOp:"eqOp",neOp:"neOp",leOp:"geOp",ltOp:"gtOp",geOp:"leOp",gtOp:"ltOp"};
482
+ function xu(a,b,c,d){const e=I(J(a,["firstOperand","*"]),"type"),f=I(J(a,["secondOperand","*"]),"type");if(!e||!f)return Gr("Can not generate code for value compare without both types");var h=[47,1];if(!h.includes(e.type)||!h.includes(f.type))return Gr(`Unsupported types in compare: [${Da[e.type]}, ${Da[f.type]}]`);h=new Map([["eqOp","==="],["neOp","!=="]]);if(!h.has(b))return Gr(b+" not yet implemented");const k=h.get(b);[b]=uu(a,"firstOperand",c,d);b=Ir(b,c,d);b=pu(b,e,d);return Z(Jr(d,b,"first"),
483
+ l=>{var [n]=uu(a,"secondOperand",c,d);n=Ir(n,c,d);n=pu(n,f,d);return Z(Jr(d,n,"second"),t=>{const u=[];xc(e)&&u.push(`${l.code} === null`);xc(f)&&u.push(`${t.code} === null`);return Y(`(${u.length?`${u.join(" || ")} ? null : `:""}${l.code} ${k} ${t.code})`,{type:0},[...l.G,...t.G])})})}
484
+ function yu(a,b,c,d,e,f){var h=I(J(a,[b,"*"]),"type");const k=I(J(a,[c,"*"]),"type");if(!h||!k)return Gr("Can not generate code for general compare without both types");var l=[47,1];if(!l.includes(h.type)||!l.includes(k.type))return Gr(`Unsupported types in compare: [${Da[h.type]}, ${Da[k.type]}]`);l=new Map([["eqOp","==="],["neOp","!=="]]);if(!l.has(d))return Gr(d+" not yet implemented");const n=l.get(d);[b]=uu(a,b,e,f);b=Ir(b,e,f);h=pu(b,h,f);return Z(Jr(f,h,"single"),t=>{const [u]=uu(a,c,e,f);
485
+ return Z(Jr(f,u,"multiple"),z=>{if(1!==z.ta.type)return Gr("can only generate general compare for a single value and a generator");const y=zu(f,Au(f,"n")),F=pu(y,k,f);return Z(e,N=>Z(F,U=>Y(`(function () {
478
486
  for (const ${y.code} of ${z.code}(${N.code})) {
479
- ${U.H.join("\n")}
487
+ ${U.G.join("\n")}
480
488
  if (${U.code} ${n} ${t.code}) {
481
489
  return true;
482
490
  }
483
491
  }
484
492
  return false;
485
- })()`,{type:0},[...t.H,...y.H,...N.H,...z.H])))})})};function mu(a){return JSON.stringify(a).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};const su={"false#0":nu,"local-name#0":ou,"local-name#1":ou,"name#0":pu,"name#1":pu,"not#1":qu,"true#0":ru},tu={["http://fontoxml.com/fontoxpath"]:["version#0"],[""]:["root#1","path#1"]};
486
- function uu(a,b,c,d){const [e]=d.h(a,c,d);a=I(a,"type");if(b?2===b.g||1===b.g:1)return sr("Not supported: sequence arguments with multiple items");if(v(b.type,53))return b=ur(e,c,d),zr(b,a,d);switch(b.type){case 59:return ur(e,c,d);case 0:return wr(e,a,c,d);case 1:return yr(e,a,c,d)}return sr(`Argument types not supported: ${a?Da[a.type]:"unknown"} -> ${Da[b.type]}`)}
487
- function vu(a,b,c,d){if(a.length!==b.length||b.some(l=>4===l))return sr("Not supported: variadic function or mismatch in argument count");if(0===a.length)return Y("",{type:0},[]);const [e,...f]=a,[h,...k]=b;a=vr(d,uu(e,h,c,d),"arg");return 0===f.length?a:Z(a,l=>{const n=vu(f,k,c,d);return Z(n,t=>Y(`${l.code}, ${t.code}`,{type:0},[...l.H,...t.H]))})}
488
- function wu(a,b){return Z(a,c=>(b?2===b.g||1===b.g:1)||![0,1].includes(b.type)&&!v(b.type,53)?sr(`Function return type ${Da[b.type]} not supported`):c)}
489
- function xu(a,b,c){const {localName:d,namespaceURI:e}=Jg(F(a,"functionName")),f=K(F(a,"arguments"),"*");var h=f.length;const k=`${d}#${h}`,l=e===c.D;if(l){const n=su[k];if(void 0!==n)return n(a,b,c)}if((a=tu[l?"":e])&&!a.includes(k))return sr(`Not supported: built-in function not on allow list: ${k}`);h=mg(e,d,h);if(!h)return sr(`Unknown function / arity: ${k}`);if(h.I)return sr("Not supported: updating functions");b=vu(f,h.j,b,c);b=Z(b,n=>Y(`runtimeLib.callFunction(domFacade, ${mu(e)}, ${mu(d)}, [${n.code}], options)`,
490
- {type:0},n.H));return wu(b,h.i)}function yu(a,b){return Z(vr(b,a,"contextItem"),c=>Y(c.code,{type:0},[...c.H,`if (${c.code} === undefined || ${c.code} === null) {
493
+ })()`,{type:0},[...t.G,...y.G,...N.G,...z.G])))})})};function Bu(a){return JSON.stringify(a).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};const Hu={"false#0":Cu,"local-name#0":Du,"local-name#1":Du,"name#0":Eu,"name#1":Eu,"not#1":Fu,"true#0":Gu},Iu={["http://fontoxml.com/fontoxpath"]:["version#0"],[""]:["root#1","path#1"]};
494
+ function Ju(a,b,c,d){const [e]=d.h(a,c,d);a=I(a,"type");if(b?2===b.g||1===b.g:1)return Gr("Not supported: sequence arguments with multiple items");if(v(b.type,53))return b=Ir(e,c,d),ru(b,a,d);switch(b.type){case 59:return Ir(e,c,d);case 0:return Kr(e,a,c,d);case 1:return qu(e,a,c,d)}return Gr(`Argument types not supported: ${a?Da[a.type]:"unknown"} -> ${Da[b.type]}`)}
495
+ function Ku(a,b,c,d){if(a.length!==b.length||b.some(l=>4===l))return Gr("Not supported: variadic function or mismatch in argument count");if(0===a.length)return Y("",{type:0},[]);const [e,...f]=a,[h,...k]=b;a=Jr(d,Ju(e,h,c,d),"arg");return 0===f.length?a:Z(a,l=>{const n=Ku(f,k,c,d);return Z(n,t=>Y(`${l.code}, ${t.code}`,{type:0},[...l.G,...t.G]))})}
496
+ function Lu(a,b){return Z(a,c=>(b?2===b.g||1===b.g:1)||![0,1].includes(b.type)&&!v(b.type,53)?Gr(`Function return type ${Da[b.type]} not supported`):c)}
497
+ function Mu(a,b,c){const {localName:d,namespaceURI:e}=Kg(G(a,"functionName")),f=K(G(a,"arguments"),"*");var h=f.length;const k=`${d}#${h}`,l=e===c.D;if(l){const n=Hu[k];if(void 0!==n)return n(a,b,c)}if((a=Iu[l?"":e])&&!a.includes(k))return Gr(`Not supported: built-in function not on allow list: ${k}`);h=ng(e,d,h);if(!h)return Gr(`Unknown function / arity: ${k}`);if(h.H)return Gr("Not supported: updating functions");b=Ku(f,h.j,b,c);b=Z(b,n=>Y(`runtimeLib.callFunction(domFacade, ${Bu(e)}, ${Bu(d)}, [${n.code}], options)`,
498
+ {type:0},n.G));return Lu(b,h.i)}function Nu(a,b){return Z(Jr(b,a,"contextItem"),c=>Y(c.code,{type:0},[...c.G,`if (${c.code} === undefined || ${c.code} === null) {
491
499
  throw errXPDY0002('The function which was called depends on dynamic context, which is absent.');
492
- }`]))}function zu(a,b,c,d){if((a=J(a,["arguments","*"]))&&"contextItemExpr"!==a[0]){const e=I(a,"type");if(!e||!v(e.type,53))return sr("name function only implemented if arg is a node");[a]=c.h(a,b,c)}else a=yu(b,c);b=ur(a,b,c);return Z(vr(c,b,"arg"),e=>Y(`(${e.code} ? ${d(e.code)} : '')`,{type:0},e.H))}function pu(a,b,c){return zu(a,b,c,d=>`(((${d}.prefix || '').length !== 0 ? ${d}.prefix + ':' : '')
493
- + (${d}.localName || ${d}.target || ''))`)}function ou(a,b,c){return zu(a,b,c,d=>`(${d}.localName || ${d}.target || '')`)}function qu(a,b,c){var d=J(a,["arguments","*"]);a=I(d,"type");[d]=c.h(d,b,c);b=wr(d,a,b,c);return Z(b,e=>Y(`!${e.code}`,{type:0},e.H))}function nu(){return Y("false",{type:0},[])}function ru(){return Y("true",{type:0},[])};function Au(a,b,c,d){const [e,f]=Cr(a,"firstOperand",c,d);var h=I(J(a,["firstOperand","*"]),"type");h=wr(e,h,c,d);const [k,l]=Cr(a,"secondOperand",c,d);h=Z(h,t=>{var u=I(J(a,["secondOperand","*"]),"type");u=wr(k,u,c,d);return Z(u,z=>Y(`(${t.code} ${b} ${z.code})`,{type:0},[...t.H,...z.H]))});const n="&&"===b?xh(f,l):f===l?f:null;return[h,n]};function Bu(a,b,c){return Z(a,d=>Z(b,e=>Z(c,f=>Y(`for (${d.code}) {
494
- ${e.H.join("\n")}
500
+ }`]))}function Ou(a,b,c,d){if((a=J(a,["arguments","*"]))&&"contextItemExpr"!==a[0]){const e=I(a,"type");if(!e||!v(e.type,53))return Gr("name function only implemented if arg is a node");[a]=c.h(a,b,c)}else a=Nu(b,c);b=Ir(a,b,c);return Z(Jr(c,b,"arg"),e=>Y(`(${e.code} ? ${d(e.code)} : '')`,{type:0},e.G))}function Eu(a,b,c){return Ou(a,b,c,d=>`(((${d}.prefix || '').length !== 0 ? ${d}.prefix + ':' : '')
501
+ + (${d}.localName || ${d}.target || ''))`)}function Du(a,b,c){return Ou(a,b,c,d=>`(${d}.localName || ${d}.target || '')`)}function Fu(a,b,c){var d=J(a,["arguments","*"]);a=I(d,"type");[d]=c.h(d,b,c);b=Kr(d,a,b,c);return Z(b,e=>Y(`!${e.code}`,{type:0},e.G))}function Cu(){return Y("false",{type:0},[])}function Gu(){return Y("true",{type:0},[])};function Pu(a,b,c,d){const [e,f]=uu(a,"firstOperand",c,d);var h=I(J(a,["firstOperand","*"]),"type");h=Kr(e,h,c,d);const [k,l]=uu(a,"secondOperand",c,d);h=Z(h,t=>{var u=I(J(a,["secondOperand","*"]),"type");u=Kr(k,u,c,d);return Z(u,z=>Y(`(${t.code} ${b} ${z.code})`,{type:0},[...t.G,...z.G]))});const n="&&"===b?vh(f,l):f===l?f:null;return[h,n]};function Qu(a,b,c){return Z(a,d=>Z(b,e=>Z(c,f=>Y(`for (${d.code}) {
502
+ ${e.G.join("\n")}
495
503
  if (!(${e.code})) {
496
504
  continue;
497
505
  }
498
- ${f.H.join("\n")}
506
+ ${f.G.join("\n")}
499
507
  ${f.code}
500
- }`,{type:2},d.H))))}function Cu(a,b,c,d,e){const f=b?`, "${b}"`:"";b=Z(d,h=>Z(e,k=>Y(`let ${h.code} = domFacade.getFirstChild(${k.code}${f});
508
+ }`,{type:2},d.G))))}function Ru(a,b,c,d,e){const f=b?`, "${b}"`:"";b=Z(d,h=>Z(e,k=>Y(`let ${h.code} = domFacade.getFirstChild(${k.code}${f});
501
509
  ${h.code};
502
- ${h.code} = domFacade.getNextSibling(${h.code}${f})`,{type:2},[...h.H,...k.H])));return Bu(b,a,c)}function Du(a,b,c,d,e){const f=xh(b,"type-2"),h=Z(e,k=>Y(`(${k.code} && ${k.code}.nodeType === /*ELEMENT_NODE*/ ${1} ? domFacade.getAllAttributes(${k.code}${f?`, "${f}"`:""}) : [])`,{type:0},k.H));b=Z(d,k=>Z(h,l=>Y(`const ${k.code} of ${l.code}`,{type:2},[...k.H,...l.H])));return Bu(b,a,c)}
503
- function Eu(a,b,c,d,e){const f=b?`, "${b}"`:"";b=Z(e,h=>Y(`domFacade.getParentNode(${h.code}${f})`,{type:0},h.H));return Fu(d,b,a,c)}function Fu(a,b,c,d){const e=Br(a,c);return Z(a,f=>Z(b,h=>Z(e,k=>Z(d,l=>Y(`const ${f.code} = ${h.code};
504
- ${k.H.join("\n")}
510
+ ${h.code} = domFacade.getNextSibling(${h.code}${f})`,{type:2},[...h.G,...k.G])));return Qu(b,a,c)}function Su(a,b,c,d,e){const f=vh(b,"type-2"),h=Z(e,k=>Y(`(${k.code} && ${k.code}.nodeType === /*ELEMENT_NODE*/ ${1} ? domFacade.getAllAttributes(${k.code}${f?`, "${f}"`:""}) : [])`,{type:0},k.G));b=Z(d,k=>Z(h,l=>Y(`const ${k.code} of ${l.code}`,{type:2},[...k.G,...l.G])));return Qu(b,a,c)}
511
+ function Tu(a,b,c,d,e){const f=b?`, "${b}"`:"";b=Z(e,h=>Y(`domFacade.getParentNode(${h.code}${f})`,{type:0},h.G));return Uu(d,b,a,c)}function Uu(a,b,c,d){const e=tu(a,c);return Z(a,f=>Z(b,h=>Z(e,k=>Z(d,l=>Y(`const ${f.code} = ${h.code};
512
+ ${k.G.join("\n")}
505
513
  if (${k.code}) {
506
- ${l.H.join("\n")}
514
+ ${l.G.join("\n")}
507
515
  ${l.code}
508
- }`,{type:2},[...f.H,...h.H])))))}function Gu(a,b,c,d,e,f){a=H(a);switch(a){case "attribute":return[Du(b,c,d,e,f),"type-1"];case "child":return[Cu(b,c,d,e,f),null];case "parent":return[Eu(b,c,d,e,f),null];case "self":return[Fu(e,f,b,d),c];default:return[sr(`Unsupported: the ${a} axis`),null]}};const Hu={Wb:"textTest",Nb:"elementTest",Sb:"nameTest",Xb:"Wildcard",Kb:"anyKindTest"};var Iu=Object.values(Hu);function Ju(a){return[Z(a,b=>Y(`(${b.code}.nodeType === /*TEXT_NODE*/ ${3} ||
509
- ${b.code}.nodeType === /* CDATA_SECTION_NODE */ ${4})`,{type:0},[])),"type-3"]}function Ku(a,b){if(null===a.namespaceURI&&"*"!==a.prefix){b=b.$(a.prefix||"")||null;if(!b&&a.prefix)throw Error(`XPST0081: The prefix ${a.prefix} could not be resolved.`);a.namespaceURI=b}}function Lu(a,b,c,d){Ku(a,d);const e=a.prefix,f=a.namespaceURI,h=a.localName;return tr(c,k=>{var l=b?Y(`${k.code}.nodeType
516
+ }`,{type:2},[...f.G,...h.G])))))}function Vu(a,b,c,d,e,f){a=H(a);switch(a){case "attribute":return[Su(b,c,d,e,f),"type-1"];case "child":return[Ru(b,c,d,e,f),null];case "parent":return[Tu(b,c,d,e,f),null];case "self":return[Uu(e,f,b,d),c];default:return[Gr(`Unsupported: the ${a} axis`),null]}};const Wu={Yb:"textTest",Pb:"elementTest",Ub:"nameTest",Zb:"Wildcard",Mb:"anyKindTest"};var Xu=Object.values(Wu);function Yu(a){return[Z(a,b=>Y(`(${b.code}.nodeType === /*TEXT_NODE*/ ${3} ||
517
+ ${b.code}.nodeType === /* CDATA_SECTION_NODE */ ${4})`,{type:0},[])),"type-3"]}function Zu(a,b){if(null===a.namespaceURI&&"*"!==a.prefix){b=b.Z(a.prefix||"")||null;if(!b&&a.prefix)throw Error(`XPST0081: The prefix ${a.prefix} could not be resolved.`);a.namespaceURI=b}}function $u(a,b,c,d){Zu(a,d);const e=a.prefix,f=a.namespaceURI,h=a.localName;return Hr(c,k=>{var l=b?Y(`${k.code}.nodeType
510
518
  && (${k.code}.nodeType === /*ELEMENT_NODE*/ ${1}
511
519
  || ${k.code}.nodeType === /*ATTRIBUTE_NODE*/ ${2})`,{type:0},[]):Y(`${k.code}.nodeType
512
- && ${k.code}.nodeType === /*ELEMENT_NODE*/ ${1}`,{type:0},[]);if("*"===e)return"*"===h?[l,b?"type-1-or-type-2":"type-1"]:[Br(l,Y(`${k.code}.localName === ${mu(h)}`,{type:0},[])),`name-${h}`];l="*"===h?l:Br(l,Y(`${k.code}.localName === ${mu(h)}`,{type:0},[]));var n=Y(mu(f),{type:0},[]);n=""===e&&b?Z(n,t=>Y(`${k.code}.nodeType === /*ELEMENT_NODE*/ ${1} ? ${t.code} : null`,{type:0},t.H)):n;n=Z(n,t=>Y(`(${k.code}.namespaceURI || null) === ((${t.code}) || null)`,{type:0},t.H));return[Br(l,n),`name-${h}`]})}
513
- function Mu(a,b,c){const d=(a=F(a,"elementName"))&&F(a,"star");if(null===a||d)return[Z(b,e=>Y(`${e.code}.nodeType === /*ELEMENT_NODE*/ ${1}`,{type:0},[])),"type-1"];a=Jg(F(a,"QName"));return Lu(a,!1,b,c)}function Nu(a){return[Z(a,b=>Y(`!!${b.code}.nodeType`,{type:0},[])),null]}
514
- function Ou(a,b,c,d){var e=a[0];switch(e){case Hu.Nb:return Mu(a,c,d);case Hu.Wb:return Ju(c);case Hu.Sb:return Lu(Jg(a),b,c,d);case Hu.Xb:return F(a,"star")?(e=F(a,"uri"),null!==e?a=Lu({localName:"*",namespaceURI:H(e),prefix:""},b,c,d):(e=F(a,"NCName"),a="star"===F(a,"*")[0]?Lu({localName:H(e),namespaceURI:null,prefix:"*"},b,c,d):Lu({localName:"*",namespaceURI:null,prefix:H(e)},b,c,d))):a=Lu({localName:"*",namespaceURI:null,prefix:"*"},b,c,d),a;case Hu.Kb:return Nu(c);default:return[sr(`Test not implemented: '${e}`),
515
- null]}};function Pu(a,b,c){const [d,e]=c.h(a,b,c);return[wr(d,I(a,"type"),b,c),e]}function Qu(a,b,c){a=a?K(a,"*"):[];const [d,e]=a.reduce(([f,h],k)=>{if(!f)return Pu(k,b,c);let l=h;return tr(f,n=>{const [t,u]=Pu(k,b,c);l=xh(h,u);return[Z(t,z=>Y(`${n.code} && ${z.code}`,{type:0},[...n.H,...z.H])),l]})},[null,null]);return[d?Z(d,f=>Y(`(function () {
516
- ${f.H.join("\n")}
520
+ && ${k.code}.nodeType === /*ELEMENT_NODE*/ ${1}`,{type:0},[]);if("*"===e)return"*"===h?[l,b?"type-1-or-type-2":"type-1"]:[tu(l,Y(`${k.code}.localName === ${Bu(h)}`,{type:0},[])),`name-${h}`];l="*"===h?l:tu(l,Y(`${k.code}.localName === ${Bu(h)}`,{type:0},[]));var n=Y(Bu(f),{type:0},[]);n=""===e&&b?Z(n,t=>Y(`${k.code}.nodeType === /*ELEMENT_NODE*/ ${1} ? ${t.code} : null`,{type:0},t.G)):n;n=Z(n,t=>Y(`(${k.code}.namespaceURI || null) === ((${t.code}) || null)`,{type:0},t.G));return[tu(l,n),`name-${h}`]})}
521
+ function av(a,b,c){const d=(a=G(a,"elementName"))&&G(a,"star");if(null===a||d)return[Z(b,e=>Y(`${e.code}.nodeType === /*ELEMENT_NODE*/ ${1}`,{type:0},[])),"type-1"];a=Kg(G(a,"QName"));return $u(a,!1,b,c)}function bv(a){return[Z(a,b=>Y(`!!${b.code}.nodeType`,{type:0},[])),null]}
522
+ function cv(a,b,c,d){var e=a[0];switch(e){case Wu.Pb:return av(a,c,d);case Wu.Yb:return Yu(c);case Wu.Ub:return $u(Kg(a),b,c,d);case Wu.Zb:return G(a,"star")?(e=G(a,"uri"),null!==e?a=$u({localName:"*",namespaceURI:H(e),prefix:""},b,c,d):(e=G(a,"NCName"),a="star"===G(a,"*")[0]?$u({localName:H(e),namespaceURI:null,prefix:"*"},b,c,d):$u({localName:"*",namespaceURI:null,prefix:H(e)},b,c,d))):a=$u({localName:"*",namespaceURI:null,prefix:"*"},b,c,d),a;case Wu.Mb:return bv(c);default:return[Gr(`Test not implemented: '${e}`),
523
+ null]}};function dv(a,b,c){const [d,e]=c.h(a,b,c);a=I(a,"type");return[Kr(d,a,b,c),e]}function ev(a,b,c){a=a?K(a,"*"):[];const [d,e]=a.reduce(([f,h],k)=>{if(!f)return dv(k,b,c);let l=h;return Hr(f,n=>{const [t,u]=dv(k,b,c);l=vh(h,u);return[Z(t,z=>Y(`${n.code} && ${z.code}`,{type:0},[...n.G,...z.G])),l]})},[null,null]);return[d?Z(d,f=>Y(`(function () {
524
+ ${f.G.join("\n")}
517
525
  return ${f.code};
518
526
  })()`,{type:0},[])):null,e]}
519
- function Ru(a,b,c,d){if(0===a.length)return[Z(c,y=>Y(`yield ${y.code};`,{type:2},y.H)),null];const [e,...f]=a;if(0<K(e,"lookup").length)return[sr("Unsupported: lookups"),null];const h=ku(d,lu(d,"contextItem"));a=F(e,"predicates");const [k,l]=Qu(a,h,d);if(a=F(e,"xpathAxis")){var n=F(e,Iu);if(!n)return[sr("Unsupported test in step"),null];var t=H(a);b="attribute"===t||"self"===t&&b;const [y,G]=Ou(n,b,h,d);n=null===k?y:Br(y,k);t=xh(G,l);[b]=Ru(f,b,h,d);return Gu(a,n,t,b,h,c)}a=J(e,["filterExpr","*"]);
520
- if(!a)return[sr("Unsupported: unknown step type"),null];const [u,z]=d.h(a,c,d);return[Z(u,y=>{const G=0===f.length?Y("",{type:2},[]):Y(`if (${h.code} !== null && !${h.code}.nodeType) {
527
+ function fv(a,b,c,d){if(0===a.length)return[Z(c,y=>Y(`yield ${y.code};`,{type:2},y.G)),null];const [e,...f]=a;if(0<K(e,"lookup").length)return[Gr("Unsupported: lookups"),null];const h=zu(d,Au(d,"contextItem"));a=G(e,"predicates");const [k,l]=ev(a,h,d);if(a=G(e,"xpathAxis")){var n=G(e,Xu);if(!n)return[Gr("Unsupported test in step"),null];var t=H(a);b="attribute"===t||"self"===t&&b;const [y,F]=cv(n,b,h,d);n=null===k?y:tu(y,k);t=vh(F,l);[b]=fv(f,b,h,d);return Vu(a,n,t,b,h,c)}a=J(e,["filterExpr","*"]);
528
+ if(!a)return[Gr("Unsupported: unknown step type"),null];const [u,z]=d.h(a,c,d);return[Z(u,y=>{const F=0===f.length?Y("",{type:2},[]):Y(`if (${h.code} !== null && !${h.code}.nodeType) {
521
529
  throw new Error('XPTY0019: The result of E1 in a path expression E1/E2 should evaluate to a sequence of nodes.');
522
- }`,{type:2},[]),[N]=Ru(f,!0,h,d),U=null===k?N:Z(k,ca=>Z(N,Ga=>Y(`if (${ca.code}) {
523
- ${Ga.H.join("\n")}
530
+ }`,{type:2},[]),[N]=fv(f,!0,h,d),U=null===k?N:Z(k,da=>Z(N,Ga=>Y(`if (${da.code}) {
531
+ ${Ga.G.join("\n")}
524
532
  ${Ga.code}
525
- }`,{type:2},ca.H)));return Z(U,ca=>{switch(y.ua.type){case 1:return Z(c,Ga=>Y(`for (const ${h.code} of ${y.code}(${Ga.code})) {
526
- ${ca.H.join("\n")}
527
- ${ca.code}
528
- }`,{type:2},[...h.H,...y.H,...G.H]));case 0:return Y(`const ${h.code} = ${y.code};
529
- ${G.code}
533
+ }`,{type:2},da.G)));return Z(U,da=>{switch(y.ta.type){case 1:return Z(c,Ga=>Y(`for (const ${h.code} of ${y.code}(${Ga.code})) {
534
+ ${da.G.join("\n")}
535
+ ${da.code}
536
+ }`,{type:2},[...h.G,...y.G,...F.G]));case 0:return Y(`const ${h.code} = ${y.code};
537
+ ${F.code}
530
538
  if (${h.code} !== null) {
531
- ${ca.H.join("\n")}
532
- ${ca.code}
533
- }`,{type:2},[...h.H,...y.H,...G.H]);default:return sr("Unsupported generated code type for filterExpr")}})}),z]}function Su(a){return Z(a,b=>Y(`(function () {
539
+ ${da.G.join("\n")}
540
+ ${da.code}
541
+ }`,{type:2},[...h.G,...y.G,...F.G]);default:return Gr("Unsupported generated code type for filterExpr")}})}),z]}function gv(a){return Z(a,b=>Y(`(function () {
534
542
  let n = ${b.code};
535
543
  while (n.nodeType !== /*DOCUMENT_NODE*/${9}) {
536
544
  n = domFacade.getParentNode(n);
@@ -539,30 +547,31 @@ if(!a)return[sr("Unsupported: unknown step type"),null];const [u,z]=d.h(a,c,d);r
539
547
  }
540
548
  }
541
549
  return n;
542
- })()`,{type:0},b.H))}function Tu(a,b,c){return tr(b,d=>{if(0<K(a,"lookup").length)return[sr("Unsupported: lookups"),null];var e=F(a,"predicates");const [f,h]=Qu(e,d,c);e=F(a,Iu);if(!e)return[sr("Unsupported test in step"),null];const [k,l]=Ou(e,!0,d,c);e=null===f?k:Br(k,f);const n=xh(l,h);return[Z(e,t=>Y(`((${t.code}) ? ${d.code} : null)`,{type:0},[...d.H,...t.H])),n]})}
543
- function Uu(a,b,c){const d=K(a,"stepExpr");if(1===d.length){const k=F(d[0],"xpathAxis");if(k&&"self"===H(k))return Tu(d[0],b,c)}const e=ku(c,lu(c,"contextItem"));b=(a=F(a,"rootExpr"))?vr(c,Su(e),"root"):e;const [f,h]=Ru(d,!a,b,c);return[Z(f,k=>Y(`(function* (${e.code}) {
544
- ${k.H.join("\n")}
550
+ })()`,{type:0},b.G))}function hv(a,b,c){return Hr(b,d=>{if(0<K(a,"lookup").length)return[Gr("Unsupported: lookups"),null];var e=G(a,"predicates");const [f,h]=ev(e,d,c);e=G(a,Xu);if(!e)return[Gr("Unsupported test in step"),null];const [k,l]=cv(e,!0,d,c);e=null===f?k:tu(k,f);const n=vh(l,h);return[Z(e,t=>Y(`((${t.code}) ? ${d.code} : null)`,{type:0},[...d.G,...t.G])),n]})}
551
+ function iv(a,b,c){const d=K(a,"stepExpr");if(1===d.length){const k=G(d[0],"xpathAxis");if(k&&"self"===H(k))return hv(d[0],b,c)}const e=zu(c,Au(c,"contextItem"));b=(a=G(a,"rootExpr"))?Jr(c,gv(e),"root"):e;const [f,h]=fv(d,!a,b,c);return[Z(f,k=>Y(`(function* (${e.code}) {
552
+ ${k.G.join("\n")}
545
553
  ${k.code}
546
- })`,{type:1},[])),h]};function Vu(a,b,c){const d=a[0];switch(d){case "contextItemExpr":return[b,null];case "pathExpr":return Uu(a,b,c);case "andOp":return Au(a,"&&",b,c);case "orOp":return Au(a,"||",b,c);case "stringConstantExpr":return a=F(a,"value")[1]||"",a=mu(a),[Y(a,{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":a:switch(d){case "eqOp":case "neOp":case "ltOp":case "leOp":case "gtOp":case "geOp":case "isOp":a=
547
- iu(a,d,b,c);break a;case "equalOp":case "notEqualOp":case "lessThanOrEqualOp":case "lessThanOp":case "greaterThanOrEqualOp":case "greaterThanOp":const e=I(J(a,["firstOperand","*"]),"type"),f=I(J(a,["secondOperand","*"]),"type");a=e&&f?3===e.g&&3===f.g?iu(a,gu[d],b,c):3===e.g?ju(a,"firstOperand","secondOperand",gu[d],b,c):3===f.g?ju(a,"secondOperand","firstOperand",hu[gu[d]],b,c):sr("General comparison for sequences is not implemented"):sr("types of compare are not known");break a;default:a=sr(`Unsupported compare type: ${d}`)}return[a,
548
- null];case "functionCallExpr":return[xu(a,b,c),null];default:return[sr(`Unsupported: the base expression '${d}'.`),null]}};function vr(a,b,c){return Z(b,d=>{var e=a.o.get(d);e||(e=lu(a,c),e=Y(e,d.ua,[...d.H,`const ${e} = ${d.code};`]),a.o.set(d,e),a.o.set(e,e));return e})}function lu(a,b="v"){const c=a.v.get(b)||0;a.v.set(b,c+1);return`${b}${c}`}function ku(a,b){b=Y(b,{type:0},[]);a.o.set(b,b);return b}var Wu=class{constructor(a,b){this.o=new Map;this.v=new Map;this.$=a;this.D=b;this.h=Vu}};function Xu(a){const b=K(a,"*");if("pathExpr"===a[0])return!0;for(const c of b)if(Xu(c))return!0;return!1};function Yu(a,b,c){c=c||{};b=b||0;if("string"===typeof a){a=Pk(a);var d={Z:"XQuery3.1"===c.language||"XQueryUpdate3.1"===c.language,debug:!1};try{var e=uq(a,d)}catch(h){gg(a,h)}}else e=Kk(a);a=F(e,"mainModule");if(!a)return sr("Unsupported: XQuery Library modules are not supported.");if(F(a,"prolog"))return sr("Unsupported: XQuery Prologs are not supported.");d=void 0===c.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":c.defaultFunctionNamespaceURI;a=new Wu(c.namespaceResolver||
549
- Rq(null),d);c=new qh(new Bg(new pg(a.$,{},d,c.functionNameResolver||Sq("http://www.w3.org/2005/xpath-functions"))));O(e,c);if(c=F(e,"mainModule"))if(F(c,"prolog"))a=sr("Unsupported: XQuery.");else{var f=J(c,["queryBody","*"]);c=ku(a,"contextItem");[d]=a.h(f,c,a);b:switch(f=I(f,"type"),b){case 9:b=ur(d,c,a);a=zr(b,f,a);break b;case 7:a=Ar(d,f,c,a);break b;case 3:a=wr(d,f,c,a);break b;case 2:a=yr(d,f,c,a);break b;default:a=sr(`Unsupported: the return type '${b}'.`)}a.isAstAccepted&&(a=`
550
- ${a.H.join("\n")}
551
- return ${a.code};`,b="\n\treturn (contextItem, domFacade, runtimeLib, options) => {\n\t\tconst {\n\t\t\terrXPDY0002,\n\t\t} = runtimeLib;",Xu(e)&&(b+='\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'),a={code:b+(a+"}\n//# sourceURL=generated.js"),isAstAccepted:!0})}else a=sr("Unsupported: Can not execute a library module.");
552
- return a};class Zu extends Error{constructor(a,b,c){var d=a.stack;d&&(d.includes(a.message)&&(d=d.substr(d.indexOf(a.message)+a.message.length).trim()),d=d.split("\n"),d.splice(10),d=d.map(e=>e.startsWith(" ")||e.startsWith("\t")?e:` ${e}`),d=d.join("\n"));super(`Custom XPath function Q{${c}}${b} raised:\n${a.message}\n${d}`)}}
553
- function $u(a,b,c){return 0===b.g?a.F()?null:Vq(a.first(),c).next(0).value:2===b.g||1===b.g?a.O().map(d=>{if(v(d.type,47))throw Error("Cannot pass attribute nodes to custom functions");return Vq(d,c).next(0).value}):Vq(a.first(),c).next(0).value}
554
- function av(a){if("object"===typeof a)return a;a=a.split(":");if(2!==a.length)throw Error("Do not register custom functions in the default function namespace");const [b,c]=a;a=og[b];if(!a){a=`generated_namespace_uri_${b}`;if(og[b])throw Error("Prefix already registered: Do not register the same prefix twice.");og[b]=a}return{localName:c,namespaceURI:a}}
555
- function bv(a,b,c,d){const {namespaceURI:e,localName:f}=av(a);if(!e)throw ug();const h=b.map(l=>Ja(l)),k=Ja(c);ng(e,f,h,k,function(l,n,t){var u=Array.from(arguments);u.splice(0,3);u=u.map((G,N)=>$u(G,h[N],n));const z={currentContext:n.o,domFacade:n.h.h};let y;try{y=d.apply(void 0,[z,...u])}catch(G){throw new Zu(G,f,e);}return y&&"object"===typeof y&&Object.getOwnPropertySymbols(y).includes(Pq)?w.create(y.zb):Wb(n.h,y,k)})};var cv={callFunction(a,b,c,d,e){const f=mg(b,c,d.length);if(!f)throw Error("function not found for codegen function call");b=new cc({M:null,Aa:0,ta:w.empty(),ra:{}});const h=new nb(a);a=new ic(!1,!1,h,null,null,e?e.currentContext:null,null);d=f.callFunction(b,a,null,...d.map((k,l)=>Wb(h,k,f.j[l])));return $u(d,{type:59,g:0},a)},errXPDY0002:lc};var dv=(a,b,c,d)=>{c=c?c:new Za;return a()(null!==b&&void 0!==b?b:null,c,cv,d)};const ev={["http://www.w3.org/2005/XQueryX"]:"xqx",["http://www.w3.org/2007/xquery-update-10"]:"xquf",["http://fontoxml.com/fontoxpath"]:"x"};
556
- function fv(a,b){switch(a){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:a,lb:b||"http://www.w3.org/2005/XQueryX"};case "deleteExpr":case "insertExpr":case "renameExpr":case "replaceExpr":case "transformExpr":return{localName:a,lb:"http://www.w3.org/2007/xquery-update-10"};
554
+ })`,{type:1},[])),h]};function jv(a,b,c){const d=a[0];switch(d){case "contextItemExpr":return[b,null];case "pathExpr":return iv(a,b,c);case "andOp":return Pu(a,"&&",b,c);case "orOp":return Pu(a,"||",b,c);case "stringConstantExpr":return a=G(a,"value")[1]||"",a=Bu(a),[Y(a,{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":a:switch(d){case "eqOp":case "neOp":case "ltOp":case "leOp":case "gtOp":case "geOp":case "isOp":a=
555
+ xu(a,d,b,c);break a;case "equalOp":case "notEqualOp":case "lessThanOrEqualOp":case "lessThanOp":case "greaterThanOrEqualOp":case "greaterThanOp":const e=I(J(a,["firstOperand","*"]),"type"),f=I(J(a,["secondOperand","*"]),"type");a=e&&f?3===e.g&&3===f.g?xu(a,vu[d],b,c):3===e.g?yu(a,"firstOperand","secondOperand",vu[d],b,c):3===f.g?yu(a,"secondOperand","firstOperand",wu[vu[d]],b,c):Gr("General comparison for sequences is not implemented"):Gr("types of compare are not known");break a;default:a=Gr(`Unsupported compare type: ${d}`)}return[a,
556
+ null];case "functionCallExpr":return[Mu(a,b,c),null];default:return[Gr(`Unsupported: the base expression '${d}'.`),null]}};function Jr(a,b,c){return Z(b,d=>{var e=a.o.get(d);e||(e=Au(a,c),e=Y(e,d.ta,[...d.G,`const ${e} = ${d.code};`]),a.o.set(d,e),a.o.set(e,e));return e})}function Au(a,b="v"){const c=a.v.get(b)||0;a.v.set(b,c+1);return`${b}${c}`}function zu(a,b){b=Y(b,{type:0},[]);a.o.set(b,b);return b}var kv=class{constructor(a,b){this.o=new Map;this.v=new Map;this.Z=a;this.D=b;this.h=jv}};function lv(a){const b=K(a,"*");if("pathExpr"===a[0])return!0;for(const c of b)if(lv(c))return!0;return!1};function mv(a,b,c){c=c||{};b=b||0;if("string"===typeof a){a=Wk(a);var d={Y:"XQuery3.1"===c.language||"XQueryUpdate3.1"===c.language,debug:!1,version:"XPath4.0"===c.language||"XQuery4.0"===c.language||"XQueryUpdate4.0"===c.language?4:3.1};try{var e=Iq(a,d)}catch(h){hg(a,h)}}else e=Rk(a);a=G(e,"mainModule");if(!a)return Gr("Unsupported: XQuery Library modules are not supported.");if(G(a,"prolog"))return Gr("Unsupported: XQuery Prologs are not supported.");d=void 0===c.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":
557
+ c.defaultFunctionNamespaceURI;a=new kv(c.namespaceResolver||er(null),d);c=new rh(new Cg(new qg(a.Z,{},d,c.functionNameResolver||fr("http://www.w3.org/2005/xpath-functions"))));O(e,c);if(c=G(e,"mainModule"))if(G(c,"prolog"))a=Gr("Unsupported: XQuery.");else{var f=J(c,["queryBody","*"]);c=zu(a,"contextItem");[d]=a.h(f,c,a);f=I(f,"type");b:switch(b){case 9:b=Ir(d,c,a);a=ru(b,f,a);break b;case 7:a=su(d,f,c,a);break b;case 3:a=Kr(d,f,c,a);break b;case 2:a=qu(d,f,c,a);break b;default:a=Gr(`Unsupported: the return type '${b}'.`)}a.isAstAccepted&&
558
+ (a=`
559
+ ${a.G.join("\n")}
560
+ return ${a.code};`,b="\n\treturn (contextItem, domFacade, runtimeLib, options) => {\n\t\tconst {\n\t\t\terrXPDY0002,\n\t\t} = runtimeLib;",lv(e)&&(b+='\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'),a={code:b+(a+"}\n//# sourceURL=generated.js"),isAstAccepted:!0})}else a=Gr("Unsupported: Can not execute a library module.");
561
+ return a};class nv extends Error{constructor(a,b,c){var d=a.stack;d&&(d.includes(a.message)&&(d=d.substr(d.indexOf(a.message)+a.message.length).trim()),d=d.split("\n"),d.splice(10),d=d.map(e=>e.startsWith(" ")||e.startsWith("\t")?e:` ${e}`),d=d.join("\n"));super(`Custom XPath function Q{${c}}${b} raised:\n${a.message}\n${d}`)}}
562
+ function ov(a,b,c){return 0===b.g?a.isEmpty()?null:ir(a.first(),c).next(0).value:2===b.g||1===b.g?a.N().map(d=>{if(v(d.type,47))throw Error("Cannot pass attribute nodes to custom functions");return ir(d,c).next(0).value}):ir(a.first(),c).next(0).value}
563
+ function pv(a){if("object"===typeof a)return a;a=a.split(":");if(2!==a.length)throw Error("Do not register custom functions in the default function namespace");const [b,c]=a;a=pg[b];if(!a){a=`generated_namespace_uri_${b}`;if(pg[b])throw Error("Prefix already registered: Do not register the same prefix twice.");pg[b]=a}return{localName:c,namespaceURI:a}}
564
+ function qv(a,b,c,d){const {namespaceURI:e,localName:f}=pv(a);if(!e)throw vg();const h=b.map(l=>Ja(l)),k=Ja(c);og(e,f,h,k,function(l,n,t){var u=Array.from(arguments);u.splice(0,3);u=u.map((F,N)=>ov(F,h[N],n));const z={currentContext:n.o,domFacade:n.h.h};let y;try{y=d.apply(void 0,[z,...u])}catch(F){throw new nv(F,f,e);}return y&&"object"===typeof y&&Object.getOwnPropertySymbols(y).includes(cr)?w.create(y.zb):Yb(n.h,y,k)})};var rv={callFunction(a,b,c,d,e){const f=ng(b,c,d.length);if(!f)throw Error("function not found for codegen function call");b=new dc({L:null,Ba:0,sa:w.empty(),qa:{}});const h=new ob(a);a=new jc(!1,!1,h,null,null,e?e.currentContext:null,null);d=f.callFunction(b,a,null,...d.map((k,l)=>Yb(h,k,f.j[l])));return ov(d,{type:59,g:0},a)},errXPDY0002:mc};var sv=(a,b,c,d)=>{c=c?c:new Za;return a()(null!==b&&void 0!==b?b:null,c,rv,d)};const tv={["http://www.w3.org/2005/XQueryX"]:"xqx",["http://www.w3.org/2007/xquery-update-10"]:"xquf",["http://fontoxml.com/fontoxpath"]:"x"};
565
+ function uv(a,b){switch(a){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:a,lb:b||"http://www.w3.org/2005/XQueryX"};case "deleteExpr":case "insertExpr":case "renameExpr":case "replaceExpr":case "transformExpr":return{localName:a,lb:"http://www.w3.org/2007/xquery-update-10"};
557
566
  case "x:stackTrace":return{localName:"stackTrace",lb:"http://fontoxml.com/fontoxpath"};default:return{localName:a,lb:"http://www.w3.org/2005/XQueryX"}}}
558
- function gv(a,b,c,d,e){if("string"===typeof c)return 0===c.length?null:b.createTextNode(c);if(!Array.isArray(c))throw new TypeError("JsonML element should be an array or string");var f=fv(c[0],d);d=f.localName;f=f.lb;const h=b.createElementNS(f,ev[f]+":"+d),k=c[1];var l=1;if("object"===typeof k&&!Array.isArray(k)){if(null!==k)for(var n of Object.keys(k))l=k[n],null!==l&&("type"===n?void 0!==l&&a.setAttributeNS(h,f,"fontoxpath:"+n,Ha(l)):("start"!==n&&"end"!==n&&"comment"!==n||"stackTrace"!==d||(l=
559
- JSON.stringify(l)),e&&"prefix"===n&&""===l||a.setAttributeNS(h,f,ev[f]+":"+n,l)));l=2}for(let t=l,u=c.length;t<u;++t)n=gv(a,b,c[t],f,e),null!==n&&a.insertBefore(h,n,null);return h}
560
- function hv(a,b,c,d=ab){a=Pk(a);let e;try{e=uq(a,{Z:"XQuery3.1"===b.language||"XQueryUpdate3.1"===b.language,debug:b.debug})}catch(l){gg(a,l)}var f=new pg(b.namespaceResolver||(()=>null),{},void 0===b.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":b.defaultFunctionNamespaceURI,b.functionNameResolver||(()=>null));f=new Bg(f);var h=F(e,["mainModule","libraryModule"]),k=F(h,"moduleDecl");if(k){const l=H(F(k,"prefix"));k=H(F(k,"uri"));Fg(f,l,k)}(h=F(h,"prolog"))&&xq(h,f,!1,a);!1!==
561
- b.annotateAst&&ih(e,new qh(f));f=new Za;b=gv(d,c,e,null,!1===b.mc);d.insertBefore(b,c.createComment(a),f.getFirstChild(b));return b};function iv(a){return Promise.resolve(a)};function jv(a,b={debug:!1}){try{var c=uq(a,{Z:!0,debug:b.debug})}catch(f){gg(a,f)}ih(c,new qh);b=F(c,"libraryModule");if(!b)throw Error("XQuery module must be declared in a library module.");c=F(b,"moduleDecl");var d=F(c,"uri");const e=H(d);c=F(c,"prefix");d=H(c);c=new Bg(new pg(()=>null,Object.create(null),"http://www.w3.org/2005/xpath-functions",Sq("http://www.w3.org/2005/xpath-functions")));Fg(c,d,e);b=F(b,"prolog");if(null!==b){let f;try{f=xq(b,c,!0,a)}catch(h){gg(a,h)}f.Ia.forEach(({namespaceURI:h})=>
562
- {if(e!==h)throw Error("XQST0048: Functions and variables declared in a module must reside in the module target namespace.");});Mk(e,f)}else Mk(e,{Ia:[],Ta:[],pa:null,source:a});return e};const kv=new Map;function lv(a){var b;a:{if(b=Gk.get(a))for(const c of Object.keys(b))if(b[c]&&b[c].length){b=b[c][0].h;break a}b=null}if(b)return b;if(kv.has(a))return kv.get(a);b="string"===typeof a?uq(a,{Z:!1}):Kk(a);b=J(b,["mainModule","queryBody","*"]);if(null===b)throw Error("Library modules do not have a specificity");b=Fk(b,{sa:!1,Z:!1});kv.set(a,b);return b}function mv(a){return lv(a).D()}function nv(a,b){return tf(lv(a).o,lv(b).o)}var ov=new Za;
563
- "undefined"!==typeof fontoxpathGlobal&&(fontoxpathGlobal.compareSpecificity=nv,fontoxpathGlobal.compileXPathToJavaScript=Yu,fontoxpathGlobal.domFacade=ov,fontoxpathGlobal.evaluateXPath=dr,fontoxpathGlobal.evaluateXPathToArray=ir,fontoxpathGlobal.evaluateXPathToAsyncIterator=er,fontoxpathGlobal.evaluateXPathToBoolean=jr,fontoxpathGlobal.evaluateXPathToFirstNode=kr,fontoxpathGlobal.evaluateXPathToMap=lr,fontoxpathGlobal.evaluateXPathToNodes=mr,fontoxpathGlobal.evaluateXPathToNumber=nr,fontoxpathGlobal.evaluateXPathToNumbers=
564
- or,fontoxpathGlobal.evaluateXPathToString=pr,fontoxpathGlobal.evaluateXPathToStrings=qr,fontoxpathGlobal.evaluateUpdatingExpression=gr,fontoxpathGlobal.evaluateUpdatingExpressionSync=hr,fontoxpathGlobal.executeJavaScriptCompiledXPath=dv,fontoxpathGlobal.executePendingUpdateList=rr,fontoxpathGlobal.getBucketForSelector=mv,fontoxpathGlobal.getBucketsForNode=Ya,fontoxpathGlobal.precompileXPath=iv,fontoxpathGlobal.registerXQueryModule=jv,fontoxpathGlobal.registerCustomXPathFunction=bv,fontoxpathGlobal.parseScript=
565
- hv,fontoxpathGlobal.profiler=ar,fontoxpathGlobal.createTypedValueFactory=Qq,fontoxpathGlobal.finalizeModuleRegistration=Ok,fontoxpathGlobal.Language=cr,fontoxpathGlobal.ReturnType=Xq);
567
+ function vv(a,b,c,d,e){if("string"===typeof c)return 0===c.length?null:b.createTextNode(c);if(!Array.isArray(c))throw new TypeError("JsonML element should be an array or string");var f=uv(c[0],d);d=f.localName;f=f.lb;const h=b.createElementNS(f,tv[f]+":"+d),k=c[1];var l=1;if("object"===typeof k&&!Array.isArray(k)){if(null!==k)for(var n of Object.keys(k))l=k[n],null!==l&&("type"===n?void 0!==l&&a.setAttributeNS(h,f,"fontoxpath:"+n,Ha(l)):("start"!==n&&"end"!==n&&"comment"!==n||"stackTrace"!==d||(l=
568
+ JSON.stringify(l)),e&&"prefix"===n&&""===l||a.setAttributeNS(h,f,tv[f]+":"+n,l)));l=2}for(let t=l,u=c.length;t<u;++t)n=vv(a,b,c[t],f,e),null!==n&&a.insertBefore(h,n,null);return h}
569
+ function wv(a,b,c,d=ab){a=Wk(a);let e;try{e=Iq(a,{Y:"XQuery3.1"===b.language||"XQueryUpdate3.1"===b.language||"XQuery4.0"===b.language||"XQueryUpdate4.0"===b.language,version:"XPath4.0"===b.language||"XQuery4.0"===b.language||"XQueryUpdate4.0"===b.language?4:3.1,debug:b.debug})}catch(l){hg(a,l)}var f=new qg(b.namespaceResolver||(()=>null),{},void 0===b.defaultFunctionNamespaceURI?"http://www.w3.org/2005/xpath-functions":b.defaultFunctionNamespaceURI,b.functionNameResolver||(()=>null));f=new Cg(f);
570
+ var h=G(e,["mainModule","libraryModule"]),k=G(h,"moduleDecl");if(k){const l=H(G(k,"prefix"));k=H(G(k,"uri"));Gg(f,l,k)}(h=G(h,"prolog"))&&Lq(h,f,!1,a);!1!==b.annotateAst&&jh(e,new rh(f));f=new Za;b=vv(d,c,e,null,!1===b.oc);d.insertBefore(b,c.createComment(a),f.getFirstChild(b));return b};function xv(a){return Promise.resolve(a)};function yv(a,b={debug:!1,language:"XQuery3.1"}){try{var c=Iq(a,{Y:!0,debug:b.debug,version:"XQuery4.0"===b.language||"XQueryUpdate4.0"===b.language?4:3.1})}catch(f){hg(a,f)}jh(c,new rh);b=G(c,"libraryModule");if(!b)throw Error("XQuery module must be declared in a library module.");c=G(b,"moduleDecl");var d=G(c,"uri");const e=H(d);c=G(c,"prefix");d=H(c);c=new Cg(new qg(()=>null,Object.create(null),"http://www.w3.org/2005/xpath-functions",fr("http://www.w3.org/2005/xpath-functions")));Gg(c,d,e);b=
571
+ G(b,"prolog");if(null!==b){let f;try{f=Lq(b,c,!0,a)}catch(h){hg(a,h)}f.Ia.forEach(({namespaceURI:h})=>{if(e!==h)throw Error("XQST0048: Functions and variables declared in a module must reside in the module target namespace.");});Tk(e,f)}else Tk(e,{Ia:[],Va:[],pa:null,source:a});return e};const zv=new Map;function Av(a){var b;a:{if(b=Nk.get(a))for(const c of Object.keys(b))if(b[c]&&b[c].length){b=b[c][0].h;break a}b=null}if(b)return b;if(zv.has(a))return zv.get(a);b="string"===typeof a?Iq(a,{Y:!1,version:4}):Rk(a);b=J(b,["mainModule","queryBody","*"]);if(null===b)throw Error("Library modules do not have a specificity");b=Mk(b,{ra:!1,Y:!1});zv.set(a,b);return b}function Bv(a){return Av(a).D()}function Cv(a,b){return uf(Av(a).o,Av(b).o)}var Dv=new Za;
572
+ "undefined"!==typeof fontoxpathGlobal&&(fontoxpathGlobal.compareSpecificity=Cv,fontoxpathGlobal.compileXPathToJavaScript=mv,fontoxpathGlobal.domFacade=Dv,fontoxpathGlobal.evaluateXPath=rr,fontoxpathGlobal.evaluateXPathToArray=wr,fontoxpathGlobal.evaluateXPathToAsyncIterator=sr,fontoxpathGlobal.evaluateXPathToBoolean=xr,fontoxpathGlobal.evaluateXPathToFirstNode=yr,fontoxpathGlobal.evaluateXPathToMap=zr,fontoxpathGlobal.evaluateXPathToNodes=Ar,fontoxpathGlobal.evaluateXPathToNumber=Br,fontoxpathGlobal.evaluateXPathToNumbers=
573
+ Cr,fontoxpathGlobal.evaluateXPathToString=Dr,fontoxpathGlobal.evaluateXPathToStrings=Er,fontoxpathGlobal.evaluateUpdatingExpression=ur,fontoxpathGlobal.evaluateUpdatingExpressionSync=vr,fontoxpathGlobal.executeJavaScriptCompiledXPath=sv,fontoxpathGlobal.executePendingUpdateList=Fr,fontoxpathGlobal.getBucketForSelector=Bv,fontoxpathGlobal.getBucketsForNode=Ya,fontoxpathGlobal.precompileXPath=xv,fontoxpathGlobal.registerXQueryModule=yv,fontoxpathGlobal.registerCustomXPathFunction=qv,fontoxpathGlobal.parseScript=
574
+ wv,fontoxpathGlobal.profiler=or,fontoxpathGlobal.createTypedValueFactory=dr,fontoxpathGlobal.finalizeModuleRegistration=Vk,fontoxpathGlobal.Language=qr,fontoxpathGlobal.ReturnType=kr);
566
575
  return fontoxpathGlobal;
567
576
  }
568
577