tjs-lang 0.8.7 → 0.9.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 (75) hide show
  1. package/CLAUDE.md +12 -4
  2. package/dist/experiments/ambient/probe.d.ts +52 -0
  3. package/dist/index.js +115 -171
  4. package/dist/index.js.map +4 -4
  5. package/dist/scripts/build-editors.d.ts +19 -0
  6. package/dist/src/css/dimensions.d.ts +23 -0
  7. package/dist/src/css/index.d.ts +85 -0
  8. package/dist/src/css/predicates.d.ts +38 -0
  9. package/dist/src/css/shorthands.d.ts +31 -0
  10. package/dist/src/css/style.d.ts +48 -0
  11. package/dist/src/lang/emitters/js.d.ts +9 -1
  12. package/dist/src/lang/index.d.ts +2 -2
  13. package/dist/src/lang/parser-transforms.d.ts +9 -5
  14. package/dist/src/lang/parser.d.ts +2 -0
  15. package/dist/src/lang/predicate.d.ts +60 -0
  16. package/dist/src/lang/transpiler.d.ts +3 -2
  17. package/dist/src/lang/types.d.ts +16 -0
  18. package/dist/src/schema/index.d.ts +12 -0
  19. package/dist/tjs-browser-from-ts.js +20 -20
  20. package/dist/tjs-browser-from-ts.js.map +3 -3
  21. package/dist/tjs-browser.js +100 -90
  22. package/dist/tjs-browser.js.map +4 -4
  23. package/dist/tjs-css.js +193 -0
  24. package/dist/tjs-css.js.map +7 -0
  25. package/dist/tjs-eval.js +43 -42
  26. package/dist/tjs-eval.js.map +4 -4
  27. package/dist/tjs-from-ts.js +13 -13
  28. package/dist/tjs-from-ts.js.map +2 -2
  29. package/dist/tjs-lang.js +102 -92
  30. package/dist/tjs-lang.js.map +4 -4
  31. package/dist/tjs-runtime.js +10 -0
  32. package/dist/tjs-runtime.js.map +7 -0
  33. package/dist/tjs-schema.js +6 -0
  34. package/dist/tjs-schema.js.map +7 -0
  35. package/dist/tjs-vm.js +55 -54
  36. package/dist/tjs-vm.js.map +4 -4
  37. package/docs/ambient-contracts.md +261 -0
  38. package/editors/ace/ajs-mode.js +214 -233
  39. package/editors/codemirror/ajs-language.js +1570 -233
  40. package/editors/editors-build.test.ts +29 -0
  41. package/editors/monaco/ajs-monarch.js +239 -195
  42. package/llms.txt +4 -0
  43. package/package.json +35 -4
  44. package/src/css/css.test.ts +122 -0
  45. package/src/css/dimensions.test.ts +112 -0
  46. package/src/css/dimensions.ts +146 -0
  47. package/src/css/index.ts +243 -0
  48. package/src/css/perf.bench.test.ts +109 -0
  49. package/src/css/predicates.ts +232 -0
  50. package/src/css/property-aware.test.ts +84 -0
  51. package/src/css/shorthands.test.ts +90 -0
  52. package/src/css/shorthands.ts +113 -0
  53. package/src/css/style.test.ts +125 -0
  54. package/src/css/style.ts +134 -0
  55. package/src/index-tsfree.test.ts +58 -0
  56. package/src/lang/emit-verified-predicate.test.ts +95 -0
  57. package/src/lang/emitters/dts.test.ts +31 -0
  58. package/src/lang/emitters/dts.ts +23 -4
  59. package/src/lang/emitters/js.ts +33 -1
  60. package/src/lang/from-ts.test.ts +1 -1
  61. package/src/lang/generic-verified-predicate.test.ts +39 -0
  62. package/src/lang/index.ts +14 -5
  63. package/src/lang/parser-transforms.ts +109 -14
  64. package/src/lang/parser.ts +9 -2
  65. package/src/lang/predicate-evaluator.test.ts +49 -0
  66. package/src/lang/predicate-report.test.ts +54 -0
  67. package/src/lang/predicate.ts +268 -0
  68. package/src/lang/redos-lint.test.ts +81 -0
  69. package/src/lang/transpiler.ts +13 -0
  70. package/src/lang/type-verified-predicate.test.ts +83 -0
  71. package/src/lang/types.ts +17 -0
  72. package/src/lang/typescript-syntax.test.ts +2 -1
  73. package/src/schema/index.ts +62 -0
  74. package/src/schema/schema.test.ts +66 -0
  75. package/src/use-cases/bootstrap.test.ts +14 -4
@@ -1,67 +1,71 @@
1
- var fa=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ei=fa((Pc,Fo)=>{Fo.exports={name:"tjs-lang",version:"0.8.7",description:"Type-safe JavaScript dialect with runtime validation, sandboxed VM execution, and AI agent orchestration. Transpiles TypeScript to validated JS with fuel-metered execution for untrusted code.",keywords:["typescript","transpiler","runtime-validation","type-safety","sandbox","virtual-machine","wasm-alternative","ai-agents","llm","orchestration","security","fuel-metering","capability-based","json-ast","untrusted-code"],license:"Apache-2.0",main:"./dist/index.js",types:"./dist/src/index.d.ts",typesVersions:{"*":{eval:["./dist/src/lang/eval.d.ts"],lang:["./dist/src/lang/transpiler.d.ts"],"lang/from-ts":["./dist/src/lang/emitters/from-ts.d.ts"],browser:["./dist/src/lang/browser.d.ts"],"browser/from-ts":["./dist/src/lang/browser-from-ts.d.ts"],vm:["./dist/src/vm/index.d.ts"],batteries:["./dist/src/batteries/index.d.ts"]}},exports:{".":{bun:"./src/index.ts",types:"./dist/src/index.d.ts",default:"./dist/index.js"},"./eval":{bun:"./src/lang/eval.ts",types:"./dist/src/lang/eval.d.ts",default:"./dist/tjs-eval.js"},"./lang":{bun:"./src/lang/transpiler.ts",types:"./dist/src/lang/transpiler.d.ts",default:"./dist/tjs-lang.js"},"./lang/from-ts":{bun:"./src/lang/emitters/from-ts.ts",types:"./dist/src/lang/emitters/from-ts.d.ts",default:"./dist/tjs-from-ts.js"},"./browser":{types:"./dist/src/lang/browser.d.ts",default:"./dist/tjs-browser.js"},"./browser/from-ts":{types:"./dist/src/lang/browser-from-ts.d.ts",default:"./dist/tjs-browser-from-ts.js"},"./vm":{bun:"./src/vm/index.ts",types:"./dist/src/vm/index.d.ts",default:"./dist/tjs-vm.js"},"./batteries":{bun:"./src/batteries/index.ts",types:"./dist/src/batteries/index.d.ts",default:"./dist/tjs-batteries.js"},"./linalg":{bun:"./src/linalg/index.tjs",default:"./dist/tjs-linalg.js"},"./src":"./src/index.ts","./editors/monaco":"./editors/monaco/ajs-monarch.js","./editors/codemirror":"./editors/codemirror/ajs-language.js","./editors/ace":"./editors/ace/ajs-mode.js"},bin:{tjs:"./src/cli/tjs.ts",tjsx:"./src/cli/tjsx.ts","tjs-playground":"./src/cli/playground.ts","create-tjs-app":"./src/cli/create-app.ts","ajs-install-vscode":"./bin/install-vscode.sh","ajs-install-cursor":"./bin/install-cursor.sh"},type:"module",files:["dist","src","docs","editors","bin","demo","tjs-lang.svg","CONTEXT.md","CLAUDE.md","llms.txt"],sideEffects:!1,repository:{type:"git",url:"https://github.com/tonioloewald/tjs-lang.git"},devDependencies:{"@codemirror/lang-css":"^6.3.1","@codemirror/lang-html":"^6.4.11","@codemirror/lang-javascript":"^6.2.4","@codemirror/lang-markdown":"^6.5.0","@codemirror/state":"^6.5.3","@codemirror/theme-one-dark":"^6.1.3","@codemirror/view":"^6.39.9","@eslint/js":"^10.0.1","@happy-dom/global-registrator":"^20.1.0","@types/bun":"latest","@types/jsdom":"^21.1.7","acorn-walk":"^8.3.4",chokidar:"^4.0.3",codemirror:"^6.0.2",esbuild:"^0.28.0",eslint:"^10.4.1",firebase:"^10.12.0","firebase-admin":"^13.6.0","firebase-functions":"^7.0.5",globals:"^17.6.0",marked:"^9.1.6",prettier:"^2.8.8",tosijs:"^1.5.6","tosijs-ui":"^1.4.7",typescript:"^5.6.2","typescript-eslint":"^8.61.0",valibot:"^0.36.0",vitest:"^2.0.5"},scripts:{format:"bun eslint src --fix && bun prettier --write .",lint:"eslint src","build:grammars":"bun editors/build-grammars.ts","test:fast":"SKIP_LLM_TESTS=1 SKIP_BENCHMARKS=1 bun test","test:llm":"bun test src/batteries/models.integration.test.ts",bench:"bun bin/benchmarks.ts",make:"rm -rf dist && bun format && bun run build:grammars && tsc -p tsconfig.build.json && bun scripts/build.ts","build:bundles":"bun scripts/build.ts",typecheck:"tsc --noEmit",latest:"rm -rf node_modules && bun install",docs:"node bin/docs.js",dev:"bun run bin/dev.ts","build:demo":"bun scripts/build-demo.ts","build:cli":"bun build src/cli/tjs.ts --compile --outfile=dist/tjs && bun build src/cli/tjsx.ts --compile --outfile=dist/tjsx","functions:build":"cd functions && npm run build","functions:deploy":"cd functions && npm run deploy","functions:serve":"cd functions && npm run serve","deploy:hosting":"bun run build:demo && firebase deploy --only hosting",deploy:"bun run build:demo && bun run functions:deploy && firebase deploy --only hosting",start:"bun run build:demo && bun run dev"},dependencies:{acorn:"^8.15.0","acorn-loose":"^8.5.2","acorn-walk":"^8.3.4","tosijs-schema":"^1.3.0"}}});var pa=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],Yr=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],ha="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65",Xr="\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC",Rn={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},Mn="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",da={5:Mn,"5module":Mn+" export import",6:Mn+" const class extends export import super"},ma=/^in(stanceof)?$/,ga=new RegExp("["+Xr+"]"),ya=new RegExp("["+Xr+ha+"]");function Bn(e,t){for(var n=65536,r=0;r<t.length;r+=2){if(n+=t[r],n>e)return!1;if(n+=t[r+1],n>=e)return!0}return!1}function Ce(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&ga.test(String.fromCharCode(e)):t===!1?!1:Bn(e,Yr)}function Je(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&ya.test(String.fromCharCode(e)):t===!1?!1:Bn(e,Yr)||Bn(e,pa)}var q=function(t,n){n===void 0&&(n={}),this.label=t,this.keyword=n.keyword,this.beforeExpr=!!n.beforeExpr,this.startsExpr=!!n.startsExpr,this.isLoop=!!n.isLoop,this.isAssign=!!n.isAssign,this.prefix=!!n.prefix,this.postfix=!!n.postfix,this.binop=n.binop||null,this.updateContext=null};function be(e,t){return new q(e,{beforeExpr:!0,binop:t})}var xe={beforeExpr:!0},de={startsExpr:!0},Vn={};function L(e,t){return t===void 0&&(t={}),t.keyword=e,Vn[e]=new q(e,t)}var h={num:new q("num",de),regexp:new q("regexp",de),string:new q("string",de),name:new q("name",de),privateId:new q("privateId",de),eof:new q("eof"),bracketL:new q("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new q("]"),braceL:new q("{",{beforeExpr:!0,startsExpr:!0}),braceR:new q("}"),parenL:new q("(",{beforeExpr:!0,startsExpr:!0}),parenR:new q(")"),comma:new q(",",xe),semi:new q(";",xe),colon:new q(":",xe),dot:new q("."),question:new q("?",xe),questionDot:new q("?."),arrow:new q("=>",xe),template:new q("template"),invalidTemplate:new q("invalidTemplate"),ellipsis:new q("...",xe),backQuote:new q("`",de),dollarBraceL:new q("${",{beforeExpr:!0,startsExpr:!0}),eq:new q("=",{beforeExpr:!0,isAssign:!0}),assign:new q("_=",{beforeExpr:!0,isAssign:!0}),incDec:new q("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new q("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:be("||",1),logicalAND:be("&&",2),bitwiseOR:be("|",3),bitwiseXOR:be("^",4),bitwiseAND:be("&",5),equality:be("==/!=/===/!==",6),relational:be("</>/<=/>=",7),bitShift:be("<</>>/>>>",8),plusMin:new q("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:be("%",10),star:be("*",10),slash:be("/",10),starstar:new q("**",{beforeExpr:!0}),coalesce:be("??",1),_break:L("break"),_case:L("case",xe),_catch:L("catch"),_continue:L("continue"),_debugger:L("debugger"),_default:L("default",xe),_do:L("do",{isLoop:!0,beforeExpr:!0}),_else:L("else",xe),_finally:L("finally"),_for:L("for",{isLoop:!0}),_function:L("function",de),_if:L("if"),_return:L("return",xe),_switch:L("switch"),_throw:L("throw",xe),_try:L("try"),_var:L("var"),_const:L("const"),_while:L("while",{isLoop:!0}),_with:L("with"),_new:L("new",{beforeExpr:!0,startsExpr:!0}),_this:L("this",de),_super:L("super",de),_class:L("class",de),_extends:L("extends",xe),_export:L("export"),_import:L("import",de),_null:L("null",de),_true:L("true",de),_false:L("false",de),_in:L("in",{beforeExpr:!0,binop:7}),_instanceof:L("instanceof",{beforeExpr:!0,binop:7}),_typeof:L("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:L("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:L("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},me=/\r\n?|\n|\u2028|\u2029/,ba=new RegExp(me.source,"g");function ct(e){return e===10||e===13||e===8232||e===8233}function es(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var s=e.charCodeAt(r);if(ct(s))return r<n-1&&s===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var ts=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,oe=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,ns=Object.prototype,xa=ns.hasOwnProperty,_a=ns.toString,lt=Object.hasOwn||(function(e,t){return xa.call(e,t)}),Gr=Array.isArray||(function(e){return _a.call(e)==="[object Array]"}),Hr=Object.create(null);function We(e){return Hr[e]||(Hr[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function Be(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var wa=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,vt=function(t,n){this.line=t,this.column=n};vt.prototype.offset=function(t){return new vt(this.line,this.column+t)};var Xt=function(t,n,r){this.start=n,this.end=r,t.sourceFile!==null&&(this.source=t.sourceFile)};function rs(e,t){for(var n=1,r=0;;){var s=es(e,r,t);if(s<0)return new vt(n,t-r);++n,r=s}}var Fn={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},Kr=!1;function Sa(e){var t={};for(var n in Fn)t[n]=e&&lt(e,n)?e[n]:Fn[n];if(t.ecmaVersion==="latest"?t.ecmaVersion=1e8:t.ecmaVersion==null?(!Kr&&typeof console=="object"&&console.warn&&(Kr=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
2
- Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved==null&&(t.allowReserved=t.ecmaVersion<5),(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),Gr(t.onToken)){var r=t.onToken;t.onToken=function(s){return r.push(s)}}return Gr(t.onComment)&&(t.onComment=va(t,t.onComment)),t}function va(e,t){return function(n,r,s,a,i,o){var u={type:n?"Block":"Line",value:r,start:s,end:a};e.locations&&(u.loc=new Xt(this,i,o)),e.ranges&&(u.range=[s,a]),t.push(u)}}var kt=1,ft=2,qn=4,ss=8,Un=16,is=32,en=64,as=128,Ze=256,Et=512,tn=kt|ft|Ze;function Wn(e,t){return ft|(e?qn:0)|(t?ss:0)}var Kt=0,Jn=1,De=2,os=3,us=4,cs=5,ne=function(t,n,r){this.options=t=Sa(t),this.sourceFile=t.sourceFile,this.keywords=We(da[t.ecmaVersion>=6?6:t.sourceType==="module"?"5module":5]);var s="";t.allowReserved!==!0&&(s=Rn[t.ecmaVersion>=6?6:t.ecmaVersion===5?5:3],t.sourceType==="module"&&(s+=" await")),this.reservedWords=We(s);var a=(s?s+" ":"")+Rn.strict;this.reservedWordsStrict=We(a),this.reservedWordsStrictBind=We(a+" "+Rn.strictBind),this.input=String(n),this.containsEsc=!1,r?(this.pos=r,this.lineStart=this.input.lastIndexOf(`
3
- `,r-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(me).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=h.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=t.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&t.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(kt),this.regexpState=null,this.privateNameStack=[]},Ae={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};ne.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};Ae.inFunction.get=function(){return(this.currentVarScope().flags&ft)>0};Ae.inGenerator.get=function(){return(this.currentVarScope().flags&ss)>0};Ae.inAsync.get=function(){return(this.currentVarScope().flags&qn)>0};Ae.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(Ze|Et))return!1;if(n&ft)return(n&qn)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};Ae.allowSuper.get=function(){var e=this.currentThisScope(),t=e.flags;return(t&en)>0||this.options.allowSuperOutsideMethod};Ae.allowDirectSuper.get=function(){return(this.currentThisScope().flags&as)>0};Ae.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};Ae.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(Ze|Et)||n&ft&&!(n&Un))return!0}return!1};Ae.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&Ze)>0};ne.extend=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];for(var r=this,s=0;s<t.length;s++)r=t[s](r);return r};ne.parse=function(t,n){return new this(n,t).parse()};ne.parseExpressionAt=function(t,n,r){var s=new this(r,t,n);return s.nextToken(),s.parseExpression()};ne.tokenizer=function(t,n){return new this(n,t)};Object.defineProperties(ne.prototype,Ae);var pe=ne.prototype,ka=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;pe.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){oe.lastIndex=e,e+=oe.exec(this.input)[0].length;var t=ka.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])==="use strict"){oe.lastIndex=e+t[0].length;var n=oe.exec(this.input),r=n.index+n[0].length,s=this.input.charAt(r);return s===";"||s==="}"||me.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(s)||s==="!"&&this.input.charAt(r+1)==="=")}e+=t[0].length,oe.lastIndex=e,e+=oe.exec(this.input)[0].length,this.input[e]===";"&&e++}};pe.eat=function(e){return this.type===e?(this.next(),!0):!1};pe.isContextual=function(e){return this.type===h.name&&this.value===e&&!this.containsEsc};pe.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1};pe.expectContextual=function(e){this.eatContextual(e)||this.unexpected()};pe.canInsertSemicolon=function(){return this.type===h.eof||this.type===h.braceR||me.test(this.input.slice(this.lastTokEnd,this.start))};pe.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};pe.semicolon=function(){!this.eat(h.semi)&&!this.insertSemicolon()&&this.unexpected()};pe.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0};pe.expect=function(e){this.eat(e)||this.unexpected()};pe.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var nn=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};pe.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?"Assigning to rvalue":"Parenthesized pattern")}};pe.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,r=e.doubleProto;if(!t)return n>=0||r>=0;n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),r>=0&&this.raiseRecoverable(r,"Redefinition of __proto__ property")};pe.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")};pe.isSimpleAssignTarget=function(e){return e.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(e.expression):e.type==="Identifier"||e.type==="MemberExpression"};var j=ne.prototype;j.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==h.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var r=0,s=Object.keys(this.undefinedExports);r<s.length;r+=1){var a=s[r];this.raiseRecoverable(this.undefinedExports[a].start,"Export '"+a+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType,this.finishNode(e,"Program")};var zn={kind:"loop"},Ea={kind:"switch"};j.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;oe.lastIndex=this.pos;var t=oe.exec(this.input),n=this.pos+t[0].length,r=this.input.charCodeAt(n);if(r===91||r===92)return!0;if(e)return!1;if(r===123||r>55295&&r<56320)return!0;if(Ce(r,!0)){for(var s=n+1;Je(r=this.input.charCodeAt(s),!0);)++s;if(r===92||r>55295&&r<56320)return!0;var a=this.input.slice(n,s);if(!ma.test(a))return!0}return!1};j.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;oe.lastIndex=this.pos;var e=oe.exec(this.input),t=this.pos+e[0].length,n;return!me.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)==="function"&&(t+8===this.input.length||!(Je(n=this.input.charCodeAt(t+8))||n>55295&&n<56320))};j.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;oe.lastIndex=this.pos;var n=oe.exec(this.input),r=this.pos+n[0].length;if(me.test(this.input.slice(this.pos,r)))return!1;if(e){var s=r+5,a;if(this.input.slice(r,s)!=="using"||s===this.input.length||Je(a=this.input.charCodeAt(s))||a>55295&&a<56320)return!1;oe.lastIndex=s;var i=oe.exec(this.input);if(i&&me.test(this.input.slice(s,s+i[0].length)))return!1}if(t){var o=r+2,u;if(this.input.slice(r,o)==="of"&&(o===this.input.length||!Je(u=this.input.charCodeAt(o))&&!(u>55295&&u<56320)))return!1}var c=this.input.charCodeAt(r);return Ce(c,!0)||c===92};j.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)};j.isUsing=function(e){return this.isUsingKeyword(!1,e)};j.parseStatement=function(e,t,n){var r=this.type,s=this.startNode(),a;switch(this.isLet(e)&&(r=h._var,a="let"),r){case h._break:case h._continue:return this.parseBreakContinueStatement(s,r.keyword);case h._debugger:return this.parseDebuggerStatement(s);case h._do:return this.parseDoStatement(s);case h._for:return this.parseForStatement(s);case h._function:return e&&(this.strict||e!=="if"&&e!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1,!e);case h._class:return e&&this.unexpected(),this.parseClass(s,!0);case h._if:return this.parseIfStatement(s);case h._return:return this.parseReturnStatement(s);case h._switch:return this.parseSwitchStatement(s);case h._throw:return this.parseThrowStatement(s);case h._try:return this.parseTryStatement(s);case h._const:case h._var:return a=a||this.value,e&&a!=="var"&&this.unexpected(),this.parseVarStatement(s,a);case h._while:return this.parseWhileStatement(s);case h._with:return this.parseWithStatement(s);case h.braceL:return this.parseBlock(!0,s);case h.semi:return this.parseEmptyStatement(s);case h._export:case h._import:if(this.options.ecmaVersion>10&&r===h._import){oe.lastIndex=this.pos;var i=oe.exec(this.input),o=this.pos+i[0].length,u=this.input.charCodeAt(o);if(u===40||u===46)return this.parseExpressionStatement(s,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),r===h._import?this.parseImport(s):this.parseExport(s,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(s,!0,!e);var c=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(c)return t&&this.options.sourceType==="script"&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),c==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(s,!1,c),this.semicolon(),this.finishNode(s,"VariableDeclaration");var l=this.value,p=this.parseExpression();return r===h.name&&p.type==="Identifier"&&this.eat(h.colon)?this.parseLabeledStatement(s,l,p,e):this.parseExpressionStatement(s,p)}};j.parseBreakContinueStatement=function(e,t){var n=t==="break";this.next(),this.eat(h.semi)||this.insertSemicolon()?e.label=null:this.type!==h.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var r=0;r<this.labels.length;++r){var s=this.labels[r];if((e.label==null||s.name===e.label.name)&&(s.kind!=null&&(n||s.kind==="loop")||e.label&&n))break}return r===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,n?"BreakStatement":"ContinueStatement")};j.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")};j.parseDoStatement=function(e){return this.next(),this.labels.push(zn),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(h._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(h.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")};j.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(zn),this.enterScope(0),this.expect(h.parenL),this.type===h.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===h._var||this.type===h._const||n){var r=this.startNode(),s=n?"let":this.value;return this.next(),this.parseVar(r,!0,s),this.finishNode(r,"VariableDeclaration"),this.parseForAfterInit(e,r,t)}var a=this.isContextual("let"),i=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var u=this.startNode();return this.next(),o==="await using"&&this.next(),this.parseVar(u,!0,o),this.finishNode(u,"VariableDeclaration"),this.parseForAfterInit(e,u,t)}var c=this.containsEsc,l=new nn,p=this.start,f=t>-1?this.parseExprSubscripts(l,"await"):this.parseExpression(!0,l);return this.type===h._in||(i=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===h._in&&this.unexpected(t),e.await=!0):i&&this.options.ecmaVersion>=8&&(f.start===p&&!c&&f.type==="Identifier"&&f.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&i&&this.raise(f.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(f,!1,l),this.checkLValPattern(f),this.parseForIn(e,f)):(this.checkExpressionErrors(l,!0),t>-1&&this.unexpected(t),this.parseFor(e,f))};j.parseForAfterInit=function(e,t,n){return(this.type===h._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&t.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===h._in?n>-1&&this.unexpected(n):e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))};j.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,St|(n?0:Dn),!1,t)};j.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(h._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")};j.parseReturnStatement=function(e){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(h.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")};j.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(h.braceL),this.labels.push(Ea),this.enterScope(0);for(var t,n=!1;this.type!==h.braceR;)if(this.type===h._case||this.type===h._default){var r=this.type===h._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),n=!0,t.test=null),this.expect(h.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")};j.parseThrowStatement=function(e){return this.next(),me.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var Ta=[];j.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type==="Identifier";return this.enterScope(t?is:0),this.checkLValPattern(e,t?us:De),this.expect(h.parenR),e};j.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===h._catch){var t=this.startNode();this.next(),this.eat(h.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(h._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")};j.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,"VariableDeclaration")};j.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(zn),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")};j.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement("with"),this.finishNode(e,"WithStatement")};j.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")};j.parseLabeledStatement=function(e,t,n,r){for(var s=0,a=this.labels;s<a.length;s+=1){var i=a[s];i.name===t&&this.raise(n.start,"Label '"+t+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===h._switch?"switch":null,u=this.labels.length-1;u>=0;u--){var c=this.labels[u];if(c.statementStart===e.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?r.indexOf("label")===-1?r+"label":r:"label"),this.labels.pop(),e.label=n,this.finishNode(e,"LabeledStatement")};j.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")};j.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(h.braceL),e&&this.enterScope(0);this.type!==h.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")};j.parseFor=function(e,t){return e.init=t,this.expect(h.semi),e.test=this.type===h.semi?null:this.parseExpression(),this.expect(h.semi),e.update=this.type===h.parenR?null:this.parseExpression(),this.expect(h.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")};j.parseForIn=function(e,t){var n=this.type===h._in;return this.next(),t.type==="VariableDeclaration"&&t.declarations[0].init!=null&&(!n||this.options.ecmaVersion<8||this.strict||t.kind!=="var"||t.declarations[0].id.type!=="Identifier")&&this.raise(t.start,(n?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(h.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,n?"ForInStatement":"ForOfStatement")};j.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var s=this.startNode();if(this.parseVarId(s,n),this.eat(h.eq)?s.init=this.parseMaybeAssign(t):!r&&n==="const"&&!(this.type===h._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!r&&(n==="using"||n==="await using")&&this.options.ecmaVersion>=17&&this.type!==h._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+n+" declaration"):!r&&s.id.type!=="Identifier"&&!(t&&(this.type===h._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):s.init=null,e.declarations.push(this.finishNode(s,"VariableDeclarator")),!this.eat(h.comma))break}return e};j.parseVarId=function(e,t){e.id=t==="using"||t==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t==="var"?Jn:De,!1)};var St=1,Dn=2,ls=4;j.parseFunction=function(e,t,n,r,s){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===h.star&&t&Dn&&this.unexpected(),e.generator=this.eat(h.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&St&&(e.id=t&ls&&this.type!==h.name?null:this.parseIdent(),e.id&&!(t&Dn)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Jn:De:os));var a=this.yieldPos,i=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Wn(e.async,e.generator)),t&St||(e.id=this.type===h.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,s),this.yieldPos=a,this.awaitPos=i,this.awaitIdentPos=o,this.finishNode(e,t&St?"FunctionDeclaration":"FunctionExpression")};j.parseFunctionParams=function(e){this.expect(h.parenL),e.params=this.parseBindingList(h.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};j.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),s=this.startNode(),a=!1;for(s.body=[],this.expect(h.braceL);this.type!==h.braceR;){var i=this.parseClassElement(e.superClass!==null);i&&(s.body.push(i),i.type==="MethodDefinition"&&i.kind==="constructor"?(a&&this.raiseRecoverable(i.start,"Duplicate constructor in the same class"),a=!0):i.key&&i.key.type==="PrivateIdentifier"&&$a(r,i)&&this.raiseRecoverable(i.key.start,"Identifier '#"+i.key.name+"' has already been declared"))}return this.strict=n,this.next(),e.body=this.finishNode(s,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")};j.parseClassElement=function(e){if(this.eat(h.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r="",s=!1,a=!1,i="method",o=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(h.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===h.star?o=!0:r="static"}if(n.static=o,!r&&t>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===h.star)&&!this.canInsertSemicolon()?a=!0:r="async"),!r&&(t>=9||!a)&&this.eat(h.star)&&(s=!0),!r&&!a&&!s){var u=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?i=u:r=u)}if(r?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=r,this.finishNode(n.key,"Identifier")):this.parseClassElementName(n),t<13||this.type===h.parenL||i!=="method"||s||a){var c=!n.static&&Zt(n,"constructor"),l=c&&e;c&&i!=="method"&&this.raise(n.key.start,"Constructor can't have get/set modifier"),n.kind=c?"constructor":i,this.parseClassMethod(n,s,a,l)}else this.parseClassField(n);return n};j.isClassElementNameStart=function(){return this.type===h.name||this.type===h.privateId||this.type===h.num||this.type===h.string||this.type===h.bracketL||this.type.keyword};j.parseClassElementName=function(e){this.type===h.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)};j.parseClassMethod=function(e,t,n,r){var s=e.key;e.kind==="constructor"?(t&&this.raise(s.start,"Constructor can't be a generator"),n&&this.raise(s.start,"Constructor can't be an async method")):e.static&&Zt(e,"prototype")&&this.raise(s.start,"Classes may not have a static property named prototype");var a=e.value=this.parseMethod(t,n,r);return e.kind==="get"&&a.params.length!==0&&this.raiseRecoverable(a.start,"getter should have no params"),e.kind==="set"&&a.params.length!==1&&this.raiseRecoverable(a.start,"setter should have exactly one param"),e.kind==="set"&&a.params[0].type==="RestElement"&&this.raiseRecoverable(a.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")};j.parseClassField=function(e){return Zt(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&Zt(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(h.eq)?(this.enterScope(Et|en),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")};j.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(Ze|en);this.type!==h.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")};j.parseClassId=function(e,t){this.type===h.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,De,!1)):(t===!0&&this.unexpected(),e.id=null)};j.parseClassSuper=function(e){e.superClass=this.eat(h._extends)?this.parseExprSubscripts(null,!1):null};j.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared};j.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,s=r===0?null:this.privateNameStack[r-1],a=0;a<n.length;++a){var i=n[a];lt(t,i.name)||(s?s.used.push(i):this.raiseRecoverable(i.start,"Private field '#"+i.name+"' must be declared in an enclosing class"))}};function $a(e,t){var n=t.key.name,r=e[n],s="true";return t.type==="MethodDefinition"&&(t.kind==="get"||t.kind==="set")&&(s=(t.static?"s":"i")+t.kind),r==="iget"&&s==="iset"||r==="iset"&&s==="iget"||r==="sget"&&s==="sset"||r==="sset"&&s==="sget"?(e[n]="true",!1):r?!0:(e[n]=s,!1)}function Zt(e,t){var n=e.computed,r=e.key;return!n&&(r.type==="Identifier"&&r.name===t||r.type==="Literal"&&r.value===t)}j.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual("from"),this.type!==h.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")};j.parseExport=function(e,t){if(this.next(),this.eat(h.star))return this.parseExportAllDeclaration(e,t);if(this.eat(h._default))return this.checkExport(t,"default",this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type==="VariableDeclaration"?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==h.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,r=e.specifiers;n<r.length;n+=1){var s=r[n];this.checkUnreserved(s.local),this.checkLocalExport(s.local),s.local.type==="Literal"&&this.raise(s.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,"ExportNamedDeclaration")};j.parseExportDeclaration=function(e){return this.parseStatement(null)};j.parseExportDefaultDeclaration=function(){var e;if(this.type===h._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,St|ls,!1,e)}else if(this.type===h._class){var n=this.startNode();return this.parseClass(n,"nullableID")}else{var r=this.parseMaybeAssign();return this.semicolon(),r}};j.checkExport=function(e,t,n){e&&(typeof t!="string"&&(t=t.type==="Identifier"?t.name:t.value),lt(e,t)&&this.raiseRecoverable(n,"Duplicate export '"+t+"'"),e[t]=!0)};j.checkPatternExport=function(e,t){var n=t.type;if(n==="Identifier")this.checkExport(e,t,t.start);else if(n==="ObjectPattern")for(var r=0,s=t.properties;r<s.length;r+=1){var a=s[r];this.checkPatternExport(e,a)}else if(n==="ArrayPattern")for(var i=0,o=t.elements;i<o.length;i+=1){var u=o[i];u&&this.checkPatternExport(e,u)}else n==="Property"?this.checkPatternExport(e,t.value):n==="AssignmentPattern"?this.checkPatternExport(e,t.left):n==="RestElement"&&this.checkPatternExport(e,t.argument)};j.checkVariableExport=function(e,t){if(e)for(var n=0,r=t;n<r.length;n+=1){var s=r[n];this.checkPatternExport(e,s.id)}};j.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};j.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual("as")?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,"ExportSpecifier")};j.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(h.braceL);!this.eat(h.braceR);){if(n)n=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;t.push(this.parseExportSpecifier(e))}return t};j.parseImport=function(e){return this.next(),this.type===h.string?(e.specifiers=Ta,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===h.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")};j.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual("as")?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,De),this.finishNode(e,"ImportSpecifier")};j.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,De),this.finishNode(e,"ImportDefaultSpecifier")};j.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,De),this.finishNode(e,"ImportNamespaceSpecifier")};j.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===h.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(h.comma)))return e;if(this.type===h.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(h.braceL);!this.eat(h.braceR);){if(t)t=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;e.push(this.parseImportSpecifier())}return e};j.parseWithClause=function(){var e=[];if(!this.eat(h._with))return e;this.expect(h.braceL);for(var t={},n=!0;!this.eat(h.braceR);){if(n)n=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;var r=this.parseImportAttribute(),s=r.key.type==="Identifier"?r.key.name:r.key.value;lt(t,s)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+s+"'"),t[s]=!0,e.push(r)}return e};j.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===h.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(h.colon),this.type!==h.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")};j.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===h.string){var e=this.parseLiteral(this.value);return wa.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)};j.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)};j.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type==="ExpressionStatement"&&e.expression.type==="Literal"&&typeof e.expression.value=="string"&&(this.input[e.start]==='"'||this.input[e.start]==="'")};var we=ne.prototype;we.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&e.name==="await"&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];this.toAssignable(a,t),a.type==="RestElement"&&(a.argument.type==="ArrayPattern"||a.argument.type==="ObjectPattern")&&this.raise(a.argument.start,"Unexpected token")}break;case"Property":e.kind!=="init"&&this.raise(e.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(e.value,t);break;case"ArrayExpression":e.type="ArrayPattern",n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,t);break;case"SpreadElement":e.type="RestElement",this.toAssignable(e.argument,t),e.argument.type==="AssignmentPattern"&&this.raise(e.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":e.operator!=="="&&this.raise(e.left.end,"Only '=' operator can be used for specifying default value."),e.type="AssignmentPattern",delete e.operator,this.toAssignable(e.left,t);break;case"ParenthesizedExpression":this.toAssignable(e.expression,t,n);break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!t)break;default:this.raise(e.start,"Assigning to rvalue")}else n&&this.checkPatternErrors(n,!0);return e};we.toAssignableList=function(e,t){for(var n=e.length,r=0;r<n;r++){var s=e[r];s&&this.toAssignable(s,t)}if(n){var a=e[n-1];this.options.ecmaVersion===6&&t&&a&&a.type==="RestElement"&&a.argument.type!=="Identifier"&&this.unexpected(a.argument.start)}return e};we.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")};we.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==h.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")};we.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case h.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(h.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case h.braceL:return this.parseObj(!0)}return this.parseIdent()};we.parseBindingList=function(e,t,n,r){for(var s=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(h.comma),t&&this.type===h.comma)s.push(null);else{if(n&&this.afterTrailingComma(e))break;if(this.type===h.ellipsis){var i=this.parseRestBinding();this.parseBindingListItem(i),s.push(i),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}else s.push(this.parseAssignableListItem(r))}return s};we.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t};we.parseBindingListItem=function(e){return e};we.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(h.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")};we.checkLValSimple=function(e,t,n){t===void 0&&(t=Kt);var r=t!==Kt;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?"Binding ":"Assigning to ")+e.name+" in strict mode"),r&&(t===De&&e.name==="let"&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),n&&(lt(n,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),n[e.name]=!0),t!==cs&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":r&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return r&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(r?"Binding":"Assigning to")+" rvalue")}};we.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=Kt),e.type){case"ObjectPattern":for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];this.checkLValInnerPattern(a,t,n)}break;case"ArrayPattern":for(var i=0,o=e.elements;i<o.length;i+=1){var u=o[i];u&&this.checkLValInnerPattern(u,t,n)}break;default:this.checkLValSimple(e,t,n)}};we.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=Kt),e.type){case"Property":this.checkLValInnerPattern(e.value,t,n);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,n);break;case"RestElement":this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}};var ke=function(t,n,r,s,a){this.token=t,this.isExpr=!!n,this.preserveSpace=!!r,this.override=s,this.generator=!!a},Q={b_stat:new ke("{",!1),b_expr:new ke("{",!0),b_tmpl:new ke("${",!1),p_stat:new ke("(",!1),p_expr:new ke("(",!0),q_tmpl:new ke("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new ke("function",!1),f_expr:new ke("function",!0),f_expr_gen:new ke("function",!0,!1,null,!0),f_gen:new ke("function",!1,!1,null,!0)},pt=ne.prototype;pt.initialContext=function(){return[Q.b_stat]};pt.curContext=function(){return this.context[this.context.length-1]};pt.braceIsBlock=function(e){var t=this.curContext();return t===Q.f_expr||t===Q.f_stat?!0:e===h.colon&&(t===Q.b_stat||t===Q.b_expr)?!t.isExpr:e===h._return||e===h.name&&this.exprAllowed?me.test(this.input.slice(this.lastTokEnd,this.start)):e===h._else||e===h.semi||e===h.eof||e===h.parenR||e===h.arrow?!0:e===h.braceL?t===Q.b_stat:e===h._var||e===h._const||e===h.name?!1:!this.exprAllowed};pt.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token==="function")return t.generator}return!1};pt.updateContext=function(e){var t,n=this.type;n.keyword&&e===h.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr};pt.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)};h.parenR.updateContext=h.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===Q.b_stat&&this.curContext().token==="function"&&(e=this.context.pop()),this.exprAllowed=!e.isExpr};h.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?Q.b_stat:Q.b_expr),this.exprAllowed=!0};h.dollarBraceL.updateContext=function(){this.context.push(Q.b_tmpl),this.exprAllowed=!0};h.parenL.updateContext=function(e){var t=e===h._if||e===h._for||e===h._with||e===h._while;this.context.push(t?Q.p_stat:Q.p_expr),this.exprAllowed=!0};h.incDec.updateContext=function(){};h._function.updateContext=h._class.updateContext=function(e){e.beforeExpr&&e!==h._else&&!(e===h.semi&&this.curContext()!==Q.p_stat)&&!(e===h._return&&me.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===h.colon||e===h.braceL)&&this.curContext()===Q.b_stat)?this.context.push(Q.f_expr):this.context.push(Q.f_stat),this.exprAllowed=!1};h.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};h.backQuote.updateContext=function(){this.curContext()===Q.q_tmpl?this.context.pop():this.context.push(Q.q_tmpl),this.exprAllowed=!1};h.star.updateContext=function(e){if(e===h._function){var t=this.context.length-1;this.context[t]===Q.f_expr?this.context[t]=Q.f_expr_gen:this.context[t]=Q.f_gen}this.exprAllowed=!0};h.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==h.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var R=ne.prototype;R.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&e.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r=e.key,s;switch(r.type){case"Identifier":s=r.name;break;case"Literal":s=String(r.value);break;default:return}var a=e.kind;if(this.options.ecmaVersion>=6){s==="__proto__"&&a==="init"&&(t.proto&&(n?n.doubleProto<0&&(n.doubleProto=r.start):this.raiseRecoverable(r.start,"Redefinition of __proto__ property")),t.proto=!0);return}s="$"+s;var i=t[s];if(i){var o;a==="init"?o=this.strict&&i.init||i.get||i.set:o=i.init||i[a],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else i=t[s]={init:!1,get:!1,set:!1};i[a]=!0}};R.parseExpression=function(e,t){var n=this.start,r=this.startLoc,s=this.parseMaybeAssign(e,t);if(this.type===h.comma){var a=this.startNodeAt(n,r);for(a.expressions=[s];this.eat(h.comma);)a.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(a,"SequenceExpression")}return s};R.parseMaybeAssign=function(e,t,n){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,s=-1,a=-1,i=-1;t?(s=t.parenthesizedAssign,a=t.trailingComma,i=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new nn,r=!0);var o=this.start,u=this.startLoc;(this.type===h.parenL||this.type===h.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e==="await");var c=this.parseMaybeConditional(e,t);if(n&&(c=n.call(this,c,o,u)),this.type.isAssign){var l=this.startNodeAt(o,u);return l.operator=this.value,this.type===h.eq&&(c=this.toAssignable(c,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=c.start&&(t.shorthandAssign=-1),this.type===h.eq?this.checkLValPattern(c):this.checkLValSimple(c),l.left=c,this.next(),l.right=this.parseMaybeAssign(e),i>-1&&(t.doubleProto=i),this.finishNode(l,"AssignmentExpression")}else r&&this.checkExpressionErrors(t,!0);return s>-1&&(t.parenthesizedAssign=s),a>-1&&(t.trailingComma=a),c};R.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,s=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return s;if(this.eat(h.question)){var a=this.startNodeAt(n,r);return a.test=s,a.consequent=this.parseMaybeAssign(),this.expect(h.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,"ConditionalExpression")}return s};R.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,s=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||s.start===n&&s.type==="ArrowFunctionExpression"?s:this.parseExprOp(s,n,r,-1,e)};R.parseExprOp=function(e,t,n,r,s){var a=this.type.binop;if(a!=null&&(!s||this.type!==h._in)&&a>r){var i=this.type===h.logicalOR||this.type===h.logicalAND,o=this.type===h.coalesce;o&&(a=h.logicalAND.binop);var u=this.value;this.next();var c=this.start,l=this.startLoc,p=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,s),c,l,a,s),f=this.buildBinary(t,n,e,p,u,i||o);return(i&&this.type===h.coalesce||o&&(this.type===h.logicalOR||this.type===h.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(f,t,n,r,s)}return e};R.buildBinary=function(e,t,n,r,s,a){r.type==="PrivateIdentifier"&&this.raise(r.start,"Private identifier can only be left side of binary expression");var i=this.startNodeAt(e,t);return i.left=n,i.operator=s,i.right=r,this.finishNode(i,a?"LogicalExpression":"BinaryExpression")};R.parseMaybeUnary=function(e,t,n,r){var s=this.start,a=this.startLoc,i;if(this.isContextual("await")&&this.canAwait)i=this.parseAwait(r),t=!0;else if(this.type.prefix){var o=this.startNode(),u=this.type===h.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,u,r),this.checkExpressionErrors(e,!0),u?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&fs(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&Ln(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):t=!0,i=this.finishNode(o,u?"UpdateExpression":"UnaryExpression")}else if(!t&&this.type===h.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),i=this.parsePrivateIdent(),this.type!==h._in&&this.unexpected();else{if(i=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return i;for(;this.type.postfix&&!this.canInsertSemicolon();){var c=this.startNodeAt(s,a);c.operator=this.value,c.prefix=!1,c.argument=i,this.checkLValSimple(i),this.next(),i=this.finishNode(c,"UpdateExpression")}}if(!n&&this.eat(h.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(s,a,i,this.parseMaybeUnary(null,!1,!1,r),"**",!1);else return i};function fs(e){return e.type==="Identifier"||e.type==="ParenthesizedExpression"&&fs(e.expression)}function Ln(e){return e.type==="MemberExpression"&&e.property.type==="PrivateIdentifier"||e.type==="ChainExpression"&&Ln(e.expression)||e.type==="ParenthesizedExpression"&&Ln(e.expression)}R.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,s=this.parseExprAtom(e,t);if(s.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return s;var a=this.parseSubscripts(s,n,r,!1,t);return e&&a.type==="MemberExpression"&&(e.parenthesizedAssign>=a.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=a.start&&(e.parenthesizedBind=-1),e.trailingComma>=a.start&&(e.trailingComma=-1)),a};R.parseSubscripts=function(e,t,n,r,s){for(var a=this.options.ecmaVersion>=8&&e.type==="Identifier"&&e.name==="async"&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,i=!1;;){var o=this.parseSubscript(e,t,n,r,a,i,s);if(o.optional&&(i=!0),o===e||o.type==="ArrowFunctionExpression"){if(i){var u=this.startNodeAt(t,n);u.expression=o,o=this.finishNode(u,"ChainExpression")}return o}e=o}};R.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(h.arrow)};R.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)};R.parseSubscript=function(e,t,n,r,s,a,i){var o=this.options.ecmaVersion>=11,u=o&&this.eat(h.questionDot);r&&u&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var c=this.eat(h.bracketL);if(c||u&&this.type!==h.parenL&&this.type!==h.backQuote||this.eat(h.dot)){var l=this.startNodeAt(t,n);l.object=e,c?(l.property=this.parseExpression(),this.expect(h.bracketR)):this.type===h.privateId&&e.type!=="Super"?l.property=this.parsePrivateIdent():l.property=this.parseIdent(this.options.allowReserved!=="never"),l.computed=!!c,o&&(l.optional=u),e=this.finishNode(l,"MemberExpression")}else if(!r&&this.eat(h.parenL)){var p=new nn,f=this.yieldPos,d=this.awaitPos,g=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var y=this.parseExprList(h.parenR,this.options.ecmaVersion>=8,!1,p);if(s&&!u&&this.shouldParseAsyncArrow())return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=f,this.awaitPos=d,this.awaitIdentPos=g,this.parseSubscriptAsyncArrow(t,n,y,i);this.checkExpressionErrors(p,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=d||this.awaitPos,this.awaitIdentPos=g||this.awaitIdentPos;var w=this.startNodeAt(t,n);w.callee=e,w.arguments=y,o&&(w.optional=u),e=this.finishNode(w,"CallExpression")}else if(this.type===h.backQuote){(u||a)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var k=this.startNodeAt(t,n);k.tag=e,k.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(k,"TaggedTemplateExpression")}return e};R.parseExprAtom=function(e,t,n){this.type===h.slash&&this.readRegexp();var r,s=this.potentialArrowAt===this.start;switch(this.type){case h._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),r=this.startNode(),this.next(),this.type===h.parenL&&!this.allowDirectSuper&&this.raise(r.start,"super() call outside constructor of a subclass"),this.type!==h.dot&&this.type!==h.bracketL&&this.type!==h.parenL&&this.unexpected(),this.finishNode(r,"Super");case h._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case h.name:var a=this.start,i=this.startLoc,o=this.containsEsc,u=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&u.name==="async"&&!this.canInsertSemicolon()&&this.eat(h._function))return this.overrideContext(Q.f_expr),this.parseFunction(this.startNodeAt(a,i),0,!1,!0,t);if(s&&!this.canInsertSemicolon()){if(this.eat(h.arrow))return this.parseArrowExpression(this.startNodeAt(a,i),[u],!1,t);if(this.options.ecmaVersion>=8&&u.name==="async"&&this.type===h.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return u=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(h.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,i),[u],!0,t)}return u;case h.regexp:var c=this.value;return r=this.parseLiteral(c.value),r.regex={pattern:c.pattern,flags:c.flags},r;case h.num:case h.string:return this.parseLiteral(this.value);case h._null:case h._true:case h._false:return r=this.startNode(),r.value=this.type===h._null?null:this.type===h._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,"Literal");case h.parenL:var l=this.start,p=this.parseParenAndDistinguishExpression(s,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(p)&&(e.parenthesizedAssign=l),e.parenthesizedBind<0&&(e.parenthesizedBind=l)),p;case h.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(h.bracketR,!0,!0,e),this.finishNode(r,"ArrayExpression");case h.braceL:return this.overrideContext(Q.b_expr),this.parseObj(!1,e);case h._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case h._class:return this.parseClass(this.startNode(),!1);case h._new:return this.parseNew();case h.backQuote:return this.parseTemplate();case h._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}};R.parseExprAtomDefault=function(){this.unexpected()};R.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===h.parenL&&!e)return this.parseDynamicImport(t);if(this.type===h.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name="import",t.meta=this.finishNode(n,"Identifier"),this.parseImportMeta(t)}else this.unexpected()};R.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(h.parenR)?e.options=null:(this.expect(h.comma),this.afterTrailingComma(h.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(h.parenR)||(this.expect(h.comma),this.afterTrailingComma(h.parenR)||this.unexpected())));else if(!this.eat(h.parenR)){var t=this.start;this.eat(h.comma)&&this.eat(h.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")};R.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="meta"&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")};R.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value!=null?t.value.toString():t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")};R.parseParenExpression=function(){this.expect(h.parenL);var e=this.parseExpression();return this.expect(h.parenR),e};R.shouldParseArrow=function(e){return!this.canInsertSemicolon()};R.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,s,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var i=this.start,o=this.startLoc,u=[],c=!0,l=!1,p=new nn,f=this.yieldPos,d=this.awaitPos,g;for(this.yieldPos=0,this.awaitPos=0;this.type!==h.parenR;)if(c?c=!1:this.expect(h.comma),a&&this.afterTrailingComma(h.parenR,!0)){l=!0;break}else if(this.type===h.ellipsis){g=this.start,u.push(this.parseParenItem(this.parseRestBinding())),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else u.push(this.parseMaybeAssign(!1,p,this.parseParenItem));var y=this.lastTokEnd,w=this.lastTokEndLoc;if(this.expect(h.parenR),e&&this.shouldParseArrow(u)&&this.eat(h.arrow))return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=d,this.parseParenArrowList(n,r,u,t);(!u.length||l)&&this.unexpected(this.lastTokStart),g&&this.unexpected(g),this.checkExpressionErrors(p,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=d||this.awaitPos,u.length>1?(s=this.startNodeAt(i,o),s.expressions=u,this.finishNodeAt(s,"SequenceExpression",y,w)):s=u[0]}else s=this.parseParenExpression();if(this.options.preserveParens){var k=this.startNodeAt(n,r);return k.expression=s,this.finishNode(k,"ParenthesizedExpression")}else return s};R.parseParenItem=function(e){return e};R.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var Ca=[];R.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===h.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="target"&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),n&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var r=this.start,s=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,s,!0,!1),this.eat(h.parenL)?e.arguments=this.parseExprList(h.parenR,this.options.ecmaVersion>=8,!1):e.arguments=Ca,this.finishNode(e,"NewExpression")};R.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===h.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value.replace(/\r\n?/g,`
1
+ var Sa=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Bi=Sa((tl,ru)=>{ru.exports={name:"tjs-lang",version:"0.9.0",description:"Type-safe JavaScript dialect with runtime validation, sandboxed VM execution, and AI agent orchestration. Transpiles TypeScript to validated JS with fuel-metered execution for untrusted code.",keywords:["typescript","transpiler","runtime-validation","type-safety","sandbox","virtual-machine","wasm-alternative","ai-agents","llm","orchestration","security","fuel-metering","capability-based","json-ast","untrusted-code"],license:"Apache-2.0",main:"./dist/index.js",types:"./dist/src/index.d.ts",typesVersions:{"*":{eval:["./dist/src/lang/eval.d.ts"],lang:["./dist/src/lang/transpiler.d.ts"],"lang/from-ts":["./dist/src/lang/emitters/from-ts.d.ts"],browser:["./dist/src/lang/browser.d.ts"],"browser/from-ts":["./dist/src/lang/browser-from-ts.d.ts"],vm:["./dist/src/vm/index.d.ts"],batteries:["./dist/src/batteries/index.d.ts"],css:["./dist/src/css/index.d.ts"],schema:["./dist/src/schema/index.d.ts"],runtime:["./dist/src/lang/runtime.d.ts"]}},exports:{".":{bun:"./src/index.ts",types:"./dist/src/index.d.ts",default:"./dist/index.js"},"./eval":{bun:"./src/lang/eval.ts",types:"./dist/src/lang/eval.d.ts",default:"./dist/tjs-eval.js"},"./lang":{bun:"./src/lang/transpiler.ts",types:"./dist/src/lang/transpiler.d.ts",default:"./dist/tjs-lang.js"},"./lang/from-ts":{bun:"./src/lang/emitters/from-ts.ts",types:"./dist/src/lang/emitters/from-ts.d.ts",default:"./dist/tjs-from-ts.js"},"./browser":{types:"./dist/src/lang/browser.d.ts",default:"./dist/tjs-browser.js"},"./browser/from-ts":{types:"./dist/src/lang/browser-from-ts.d.ts",default:"./dist/tjs-browser-from-ts.js"},"./vm":{bun:"./src/vm/index.ts",types:"./dist/src/vm/index.d.ts",default:"./dist/tjs-vm.js"},"./batteries":{bun:"./src/batteries/index.ts",types:"./dist/src/batteries/index.d.ts",default:"./dist/tjs-batteries.js"},"./linalg":{bun:"./src/linalg/index.tjs",default:"./dist/tjs-linalg.js"},"./css":{bun:"./src/css/index.ts",types:"./dist/src/css/index.d.ts",default:"./dist/tjs-css.js"},"./schema":{bun:"./src/schema/index.ts",types:"./dist/src/schema/index.d.ts",default:"./dist/tjs-schema.js"},"./runtime":{bun:"./src/lang/runtime.ts",types:"./dist/src/lang/runtime.d.ts",default:"./dist/tjs-runtime.js"},"./bun-plugin":{bun:"./src/bun-plugin/tjs-plugin.ts"},"./src":"./src/index.ts","./editors/monaco":"./editors/monaco/ajs-monarch.js","./editors/codemirror":"./editors/codemirror/ajs-language.js","./editors/ace":"./editors/ace/ajs-mode.js"},bin:{tjs:"./src/cli/tjs.ts",tjsx:"./src/cli/tjsx.ts","tjs-playground":"./src/cli/playground.ts","create-tjs-app":"./src/cli/create-app.ts","ajs-install-vscode":"./bin/install-vscode.sh","ajs-install-cursor":"./bin/install-cursor.sh"},type:"module",files:["dist","src","docs","editors","bin","demo","tjs-lang.svg","CONTEXT.md","CLAUDE.md","llms.txt"],sideEffects:["./src/schema/index.ts","./dist/tjs-schema.js"],repository:{type:"git",url:"https://github.com/tonioloewald/tjs-lang.git"},devDependencies:{"@codemirror/lang-css":"^6.3.1","@codemirror/lang-html":"^6.4.11","@codemirror/lang-javascript":"^6.2.4","@codemirror/lang-markdown":"^6.5.0","@codemirror/state":"^6.5.3","@codemirror/theme-one-dark":"^6.1.3","@codemirror/view":"^6.39.9","@eslint/js":"^10.0.1","@happy-dom/global-registrator":"^20.1.0","@types/bun":"latest","@types/jsdom":"^21.1.7","acorn-walk":"^8.3.4",chokidar:"^4.0.3",codemirror:"^6.0.2",esbuild:"^0.28.0",eslint:"^10.4.1",firebase:"^10.12.0","firebase-admin":"^13.6.0","firebase-functions":"^7.0.5",globals:"^17.6.0",marked:"^9.1.6",prettier:"^2.8.8",tosijs:"^1.5.6","tosijs-ui":"^1.4.7",typescript:"^5.6.2","typescript-eslint":"^8.61.0",valibot:"^0.36.0",vitest:"^2.0.5"},scripts:{format:"bun eslint src --fix && bun prettier --write .",lint:"eslint src","build:grammars":"bun editors/build-grammars.ts","build:editors":"bun scripts/build-editors.ts","test:fast":"SKIP_LLM_TESTS=1 SKIP_BENCHMARKS=1 bun test","test:llm":"bun test src/batteries/models.integration.test.ts",bench:"bun bin/benchmarks.ts",make:"rm -rf dist && bun format && bun run build:grammars && bun run build:editors && tsc -p tsconfig.build.json && bun scripts/build.ts","build:bundles":"bun scripts/build.ts",typecheck:"tsc --noEmit",latest:"rm -rf node_modules && bun install",docs:"node bin/docs.js",dev:"bun run bin/dev.ts","build:demo":"bun scripts/build-demo.ts","build:cli":"bun build src/cli/tjs.ts --compile --outfile=dist/tjs && bun build src/cli/tjsx.ts --compile --outfile=dist/tjsx","functions:build":"cd functions && npm run build","functions:deploy":"cd functions && npm run deploy","functions:serve":"cd functions && npm run serve","deploy:hosting":"bun run build:demo && firebase deploy --only hosting",deploy:"bun run build:demo && bun run functions:deploy && firebase deploy --only hosting",start:"bun run build:demo && bun run dev"},dependencies:{acorn:"^8.15.0","acorn-loose":"^8.5.2","acorn-walk":"^8.3.4","tosijs-schema":"^1.4.0"}}});var va=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],is=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],ka="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65",as="\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC",Fn={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},Ln="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",Ea={5:Ln,"5module":Ln+" export import",6:Ln+" const class extends export import super"},Ta=/^in(stanceof)?$/,$a=new RegExp("["+as+"]"),Ca=new RegExp("["+as+ka+"]");function qn(e,t){for(var n=65536,r=0;r<t.length;r+=2){if(n+=t[r],n>e)return!1;if(n+=t[r+1],n>=e)return!0}return!1}function Ce(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&$a.test(String.fromCharCode(e)):t===!1?!1:qn(e,is)}function Je(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Ca.test(String.fromCharCode(e)):t===!1?!1:qn(e,is)||qn(e,va)}var q=function(t,n){n===void 0&&(n={}),this.label=t,this.keyword=n.keyword,this.beforeExpr=!!n.beforeExpr,this.startsExpr=!!n.startsExpr,this.isLoop=!!n.isLoop,this.isAssign=!!n.isAssign,this.prefix=!!n.prefix,this.postfix=!!n.postfix,this.binop=n.binop||null,this.updateContext=null};function be(e,t){return new q(e,{beforeExpr:!0,binop:t})}var xe={beforeExpr:!0},de={startsExpr:!0},zn={};function L(e,t){return t===void 0&&(t={}),t.keyword=e,zn[e]=new q(e,t)}var h={num:new q("num",de),regexp:new q("regexp",de),string:new q("string",de),name:new q("name",de),privateId:new q("privateId",de),eof:new q("eof"),bracketL:new q("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new q("]"),braceL:new q("{",{beforeExpr:!0,startsExpr:!0}),braceR:new q("}"),parenL:new q("(",{beforeExpr:!0,startsExpr:!0}),parenR:new q(")"),comma:new q(",",xe),semi:new q(";",xe),colon:new q(":",xe),dot:new q("."),question:new q("?",xe),questionDot:new q("?."),arrow:new q("=>",xe),template:new q("template"),invalidTemplate:new q("invalidTemplate"),ellipsis:new q("...",xe),backQuote:new q("`",de),dollarBraceL:new q("${",{beforeExpr:!0,startsExpr:!0}),eq:new q("=",{beforeExpr:!0,isAssign:!0}),assign:new q("_=",{beforeExpr:!0,isAssign:!0}),incDec:new q("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new q("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:be("||",1),logicalAND:be("&&",2),bitwiseOR:be("|",3),bitwiseXOR:be("^",4),bitwiseAND:be("&",5),equality:be("==/!=/===/!==",6),relational:be("</>/<=/>=",7),bitShift:be("<</>>/>>>",8),plusMin:new q("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:be("%",10),star:be("*",10),slash:be("/",10),starstar:new q("**",{beforeExpr:!0}),coalesce:be("??",1),_break:L("break"),_case:L("case",xe),_catch:L("catch"),_continue:L("continue"),_debugger:L("debugger"),_default:L("default",xe),_do:L("do",{isLoop:!0,beforeExpr:!0}),_else:L("else",xe),_finally:L("finally"),_for:L("for",{isLoop:!0}),_function:L("function",de),_if:L("if"),_return:L("return",xe),_switch:L("switch"),_throw:L("throw",xe),_try:L("try"),_var:L("var"),_const:L("const"),_while:L("while",{isLoop:!0}),_with:L("with"),_new:L("new",{beforeExpr:!0,startsExpr:!0}),_this:L("this",de),_super:L("super",de),_class:L("class",de),_extends:L("extends",xe),_export:L("export"),_import:L("import",de),_null:L("null",de),_true:L("true",de),_false:L("false",de),_in:L("in",{beforeExpr:!0,binop:7}),_instanceof:L("instanceof",{beforeExpr:!0,binop:7}),_typeof:L("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:L("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:L("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},me=/\r\n?|\n|\u2028|\u2029/,Aa=new RegExp(me.source,"g");function pt(e){return e===10||e===13||e===8232||e===8233}function os(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var s=e.charCodeAt(r);if(pt(s))return r<n-1&&s===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var us=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,oe=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,cs=Object.prototype,Pa=cs.hasOwnProperty,ja=cs.toString,ht=Object.hasOwn||(function(e,t){return Pa.call(e,t)}),es=Array.isArray||(function(e){return ja.call(e)==="[object Array]"}),ts=Object.create(null);function We(e){return ts[e]||(ts[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function Be(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var Ia=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Tt=function(t,n){this.line=t,this.column=n};Tt.prototype.offset=function(t){return new Tt(this.line,this.column+t)};var nn=function(t,n,r){this.start=n,this.end=r,t.sourceFile!==null&&(this.source=t.sourceFile)};function ls(e,t){for(var n=1,r=0;;){var s=os(e,r,t);if(s<0)return new Tt(n,t-r);++n,r=s}}var Un={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},ns=!1;function Na(e){var t={};for(var n in Un)t[n]=e&&ht(e,n)?e[n]:Un[n];if(t.ecmaVersion==="latest"?t.ecmaVersion=1e8:t.ecmaVersion==null?(!ns&&typeof console=="object"&&console.warn&&(ns=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
2
+ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved==null&&(t.allowReserved=t.ecmaVersion<5),(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),es(t.onToken)){var r=t.onToken;t.onToken=function(s){return r.push(s)}}return es(t.onComment)&&(t.onComment=Ra(t,t.onComment)),t}function Ra(e,t){return function(n,r,s,a,i,o){var u={type:n?"Block":"Line",value:r,start:s,end:a};e.locations&&(u.loc=new nn(this,i,o)),e.ranges&&(u.range=[s,a]),t.push(u)}}var $t=1,dt=2,Gn=4,fs=8,Hn=16,ps=32,rn=64,hs=128,Ye=256,Ct=512,sn=$t|dt|Ye;function Kn(e,t){return dt|(e?Gn:0)|(t?fs:0)}var Yt=0,Zn=1,Fe=2,ds=3,ms=4,gs=5,ne=function(t,n,r){this.options=t=Na(t),this.sourceFile=t.sourceFile,this.keywords=We(Ea[t.ecmaVersion>=6?6:t.sourceType==="module"?"5module":5]);var s="";t.allowReserved!==!0&&(s=Fn[t.ecmaVersion>=6?6:t.ecmaVersion===5?5:3],t.sourceType==="module"&&(s+=" await")),this.reservedWords=We(s);var a=(s?s+" ":"")+Fn.strict;this.reservedWordsStrict=We(a),this.reservedWordsStrictBind=We(a+" "+Fn.strictBind),this.input=String(n),this.containsEsc=!1,r?(this.pos=r,this.lineStart=this.input.lastIndexOf(`
3
+ `,r-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(me).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=h.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=t.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&t.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope($t),this.regexpState=null,this.privateNameStack=[]},Ae={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};ne.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};Ae.inFunction.get=function(){return(this.currentVarScope().flags&dt)>0};Ae.inGenerator.get=function(){return(this.currentVarScope().flags&fs)>0};Ae.inAsync.get=function(){return(this.currentVarScope().flags&Gn)>0};Ae.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(Ye|Ct))return!1;if(n&dt)return(n&Gn)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};Ae.allowSuper.get=function(){var e=this.currentThisScope(),t=e.flags;return(t&rn)>0||this.options.allowSuperOutsideMethod};Ae.allowDirectSuper.get=function(){return(this.currentThisScope().flags&hs)>0};Ae.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};Ae.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(Ye|Ct)||n&dt&&!(n&Hn))return!0}return!1};Ae.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&Ye)>0};ne.extend=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];for(var r=this,s=0;s<t.length;s++)r=t[s](r);return r};ne.parse=function(t,n){return new this(n,t).parse()};ne.parseExpressionAt=function(t,n,r){var s=new this(r,t,n);return s.nextToken(),s.parseExpression()};ne.tokenizer=function(t,n){return new this(n,t)};Object.defineProperties(ne.prototype,Ae);var pe=ne.prototype,Ma=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;pe.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){oe.lastIndex=e,e+=oe.exec(this.input)[0].length;var t=Ma.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])==="use strict"){oe.lastIndex=e+t[0].length;var n=oe.exec(this.input),r=n.index+n[0].length,s=this.input.charAt(r);return s===";"||s==="}"||me.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(s)||s==="!"&&this.input.charAt(r+1)==="=")}e+=t[0].length,oe.lastIndex=e,e+=oe.exec(this.input)[0].length,this.input[e]===";"&&e++}};pe.eat=function(e){return this.type===e?(this.next(),!0):!1};pe.isContextual=function(e){return this.type===h.name&&this.value===e&&!this.containsEsc};pe.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1};pe.expectContextual=function(e){this.eatContextual(e)||this.unexpected()};pe.canInsertSemicolon=function(){return this.type===h.eof||this.type===h.braceR||me.test(this.input.slice(this.lastTokEnd,this.start))};pe.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};pe.semicolon=function(){!this.eat(h.semi)&&!this.insertSemicolon()&&this.unexpected()};pe.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0};pe.expect=function(e){this.eat(e)||this.unexpected()};pe.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var an=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};pe.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?"Assigning to rvalue":"Parenthesized pattern")}};pe.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,r=e.doubleProto;if(!t)return n>=0||r>=0;n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),r>=0&&this.raiseRecoverable(r,"Redefinition of __proto__ property")};pe.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")};pe.isSimpleAssignTarget=function(e){return e.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(e.expression):e.type==="Identifier"||e.type==="MemberExpression"};var I=ne.prototype;I.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==h.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var r=0,s=Object.keys(this.undefinedExports);r<s.length;r+=1){var a=s[r];this.raiseRecoverable(this.undefinedExports[a].start,"Export '"+a+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType,this.finishNode(e,"Program")};var Qn={kind:"loop"},Oa={kind:"switch"};I.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;oe.lastIndex=this.pos;var t=oe.exec(this.input),n=this.pos+t[0].length,r=this.input.charCodeAt(n);if(r===91||r===92)return!0;if(e)return!1;if(r===123||r>55295&&r<56320)return!0;if(Ce(r,!0)){for(var s=n+1;Je(r=this.input.charCodeAt(s),!0);)++s;if(r===92||r>55295&&r<56320)return!0;var a=this.input.slice(n,s);if(!Ta.test(a))return!0}return!1};I.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;oe.lastIndex=this.pos;var e=oe.exec(this.input),t=this.pos+e[0].length,n;return!me.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)==="function"&&(t+8===this.input.length||!(Je(n=this.input.charCodeAt(t+8))||n>55295&&n<56320))};I.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;oe.lastIndex=this.pos;var n=oe.exec(this.input),r=this.pos+n[0].length;if(me.test(this.input.slice(this.pos,r)))return!1;if(e){var s=r+5,a;if(this.input.slice(r,s)!=="using"||s===this.input.length||Je(a=this.input.charCodeAt(s))||a>55295&&a<56320)return!1;oe.lastIndex=s;var i=oe.exec(this.input);if(i&&me.test(this.input.slice(s,s+i[0].length)))return!1}if(t){var o=r+2,u;if(this.input.slice(r,o)==="of"&&(o===this.input.length||!Je(u=this.input.charCodeAt(o))&&!(u>55295&&u<56320)))return!1}var c=this.input.charCodeAt(r);return Ce(c,!0)||c===92};I.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)};I.isUsing=function(e){return this.isUsingKeyword(!1,e)};I.parseStatement=function(e,t,n){var r=this.type,s=this.startNode(),a;switch(this.isLet(e)&&(r=h._var,a="let"),r){case h._break:case h._continue:return this.parseBreakContinueStatement(s,r.keyword);case h._debugger:return this.parseDebuggerStatement(s);case h._do:return this.parseDoStatement(s);case h._for:return this.parseForStatement(s);case h._function:return e&&(this.strict||e!=="if"&&e!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1,!e);case h._class:return e&&this.unexpected(),this.parseClass(s,!0);case h._if:return this.parseIfStatement(s);case h._return:return this.parseReturnStatement(s);case h._switch:return this.parseSwitchStatement(s);case h._throw:return this.parseThrowStatement(s);case h._try:return this.parseTryStatement(s);case h._const:case h._var:return a=a||this.value,e&&a!=="var"&&this.unexpected(),this.parseVarStatement(s,a);case h._while:return this.parseWhileStatement(s);case h._with:return this.parseWithStatement(s);case h.braceL:return this.parseBlock(!0,s);case h.semi:return this.parseEmptyStatement(s);case h._export:case h._import:if(this.options.ecmaVersion>10&&r===h._import){oe.lastIndex=this.pos;var i=oe.exec(this.input),o=this.pos+i[0].length,u=this.input.charCodeAt(o);if(u===40||u===46)return this.parseExpressionStatement(s,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),r===h._import?this.parseImport(s):this.parseExport(s,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(s,!0,!e);var c=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(c)return t&&this.options.sourceType==="script"&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),c==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(s,!1,c),this.semicolon(),this.finishNode(s,"VariableDeclaration");var l=this.value,p=this.parseExpression();return r===h.name&&p.type==="Identifier"&&this.eat(h.colon)?this.parseLabeledStatement(s,l,p,e):this.parseExpressionStatement(s,p)}};I.parseBreakContinueStatement=function(e,t){var n=t==="break";this.next(),this.eat(h.semi)||this.insertSemicolon()?e.label=null:this.type!==h.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var r=0;r<this.labels.length;++r){var s=this.labels[r];if((e.label==null||s.name===e.label.name)&&(s.kind!=null&&(n||s.kind==="loop")||e.label&&n))break}return r===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,n?"BreakStatement":"ContinueStatement")};I.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")};I.parseDoStatement=function(e){return this.next(),this.labels.push(Qn),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(h._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(h.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")};I.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(Qn),this.enterScope(0),this.expect(h.parenL),this.type===h.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===h._var||this.type===h._const||n){var r=this.startNode(),s=n?"let":this.value;return this.next(),this.parseVar(r,!0,s),this.finishNode(r,"VariableDeclaration"),this.parseForAfterInit(e,r,t)}var a=this.isContextual("let"),i=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var u=this.startNode();return this.next(),o==="await using"&&this.next(),this.parseVar(u,!0,o),this.finishNode(u,"VariableDeclaration"),this.parseForAfterInit(e,u,t)}var c=this.containsEsc,l=new an,p=this.start,f=t>-1?this.parseExprSubscripts(l,"await"):this.parseExpression(!0,l);return this.type===h._in||(i=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===h._in&&this.unexpected(t),e.await=!0):i&&this.options.ecmaVersion>=8&&(f.start===p&&!c&&f.type==="Identifier"&&f.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&i&&this.raise(f.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(f,!1,l),this.checkLValPattern(f),this.parseForIn(e,f)):(this.checkExpressionErrors(l,!0),t>-1&&this.unexpected(t),this.parseFor(e,f))};I.parseForAfterInit=function(e,t,n){return(this.type===h._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&t.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===h._in?n>-1&&this.unexpected(n):e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))};I.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,Et|(n?0:Wn),!1,t)};I.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(h._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")};I.parseReturnStatement=function(e){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(h.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")};I.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(h.braceL),this.labels.push(Oa),this.enterScope(0);for(var t,n=!1;this.type!==h.braceR;)if(this.type===h._case||this.type===h._default){var r=this.type===h._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),n=!0,t.test=null),this.expect(h.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")};I.parseThrowStatement=function(e){return this.next(),me.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var Ba=[];I.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type==="Identifier";return this.enterScope(t?ps:0),this.checkLValPattern(e,t?ms:Fe),this.expect(h.parenR),e};I.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===h._catch){var t=this.startNode();this.next(),this.eat(h.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(h._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")};I.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,"VariableDeclaration")};I.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Qn),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")};I.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement("with"),this.finishNode(e,"WithStatement")};I.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")};I.parseLabeledStatement=function(e,t,n,r){for(var s=0,a=this.labels;s<a.length;s+=1){var i=a[s];i.name===t&&this.raise(n.start,"Label '"+t+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===h._switch?"switch":null,u=this.labels.length-1;u>=0;u--){var c=this.labels[u];if(c.statementStart===e.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?r.indexOf("label")===-1?r+"label":r:"label"),this.labels.pop(),e.label=n,this.finishNode(e,"LabeledStatement")};I.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")};I.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(h.braceL),e&&this.enterScope(0);this.type!==h.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")};I.parseFor=function(e,t){return e.init=t,this.expect(h.semi),e.test=this.type===h.semi?null:this.parseExpression(),this.expect(h.semi),e.update=this.type===h.parenR?null:this.parseExpression(),this.expect(h.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")};I.parseForIn=function(e,t){var n=this.type===h._in;return this.next(),t.type==="VariableDeclaration"&&t.declarations[0].init!=null&&(!n||this.options.ecmaVersion<8||this.strict||t.kind!=="var"||t.declarations[0].id.type!=="Identifier")&&this.raise(t.start,(n?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(h.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,n?"ForInStatement":"ForOfStatement")};I.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var s=this.startNode();if(this.parseVarId(s,n),this.eat(h.eq)?s.init=this.parseMaybeAssign(t):!r&&n==="const"&&!(this.type===h._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!r&&(n==="using"||n==="await using")&&this.options.ecmaVersion>=17&&this.type!==h._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+n+" declaration"):!r&&s.id.type!=="Identifier"&&!(t&&(this.type===h._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):s.init=null,e.declarations.push(this.finishNode(s,"VariableDeclarator")),!this.eat(h.comma))break}return e};I.parseVarId=function(e,t){e.id=t==="using"||t==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t==="var"?Zn:Fe,!1)};var Et=1,Wn=2,ys=4;I.parseFunction=function(e,t,n,r,s){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===h.star&&t&Wn&&this.unexpected(),e.generator=this.eat(h.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&Et&&(e.id=t&ys&&this.type!==h.name?null:this.parseIdent(),e.id&&!(t&Wn)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Zn:Fe:ds));var a=this.yieldPos,i=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Kn(e.async,e.generator)),t&Et||(e.id=this.type===h.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,s),this.yieldPos=a,this.awaitPos=i,this.awaitIdentPos=o,this.finishNode(e,t&Et?"FunctionDeclaration":"FunctionExpression")};I.parseFunctionParams=function(e){this.expect(h.parenL),e.params=this.parseBindingList(h.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};I.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),s=this.startNode(),a=!1;for(s.body=[],this.expect(h.braceL);this.type!==h.braceR;){var i=this.parseClassElement(e.superClass!==null);i&&(s.body.push(i),i.type==="MethodDefinition"&&i.kind==="constructor"?(a&&this.raiseRecoverable(i.start,"Duplicate constructor in the same class"),a=!0):i.key&&i.key.type==="PrivateIdentifier"&&Da(r,i)&&this.raiseRecoverable(i.key.start,"Identifier '#"+i.key.name+"' has already been declared"))}return this.strict=n,this.next(),e.body=this.finishNode(s,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")};I.parseClassElement=function(e){if(this.eat(h.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r="",s=!1,a=!1,i="method",o=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(h.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===h.star?o=!0:r="static"}if(n.static=o,!r&&t>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===h.star)&&!this.canInsertSemicolon()?a=!0:r="async"),!r&&(t>=9||!a)&&this.eat(h.star)&&(s=!0),!r&&!a&&!s){var u=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?i=u:r=u)}if(r?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=r,this.finishNode(n.key,"Identifier")):this.parseClassElementName(n),t<13||this.type===h.parenL||i!=="method"||s||a){var c=!n.static&&Xt(n,"constructor"),l=c&&e;c&&i!=="method"&&this.raise(n.key.start,"Constructor can't have get/set modifier"),n.kind=c?"constructor":i,this.parseClassMethod(n,s,a,l)}else this.parseClassField(n);return n};I.isClassElementNameStart=function(){return this.type===h.name||this.type===h.privateId||this.type===h.num||this.type===h.string||this.type===h.bracketL||this.type.keyword};I.parseClassElementName=function(e){this.type===h.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)};I.parseClassMethod=function(e,t,n,r){var s=e.key;e.kind==="constructor"?(t&&this.raise(s.start,"Constructor can't be a generator"),n&&this.raise(s.start,"Constructor can't be an async method")):e.static&&Xt(e,"prototype")&&this.raise(s.start,"Classes may not have a static property named prototype");var a=e.value=this.parseMethod(t,n,r);return e.kind==="get"&&a.params.length!==0&&this.raiseRecoverable(a.start,"getter should have no params"),e.kind==="set"&&a.params.length!==1&&this.raiseRecoverable(a.start,"setter should have exactly one param"),e.kind==="set"&&a.params[0].type==="RestElement"&&this.raiseRecoverable(a.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")};I.parseClassField=function(e){return Xt(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&Xt(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(h.eq)?(this.enterScope(Ct|rn),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")};I.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(Ye|rn);this.type!==h.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")};I.parseClassId=function(e,t){this.type===h.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,Fe,!1)):(t===!0&&this.unexpected(),e.id=null)};I.parseClassSuper=function(e){e.superClass=this.eat(h._extends)?this.parseExprSubscripts(null,!1):null};I.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared};I.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,s=r===0?null:this.privateNameStack[r-1],a=0;a<n.length;++a){var i=n[a];ht(t,i.name)||(s?s.used.push(i):this.raiseRecoverable(i.start,"Private field '#"+i.name+"' must be declared in an enclosing class"))}};function Da(e,t){var n=t.key.name,r=e[n],s="true";return t.type==="MethodDefinition"&&(t.kind==="get"||t.kind==="set")&&(s=(t.static?"s":"i")+t.kind),r==="iget"&&s==="iset"||r==="iset"&&s==="iget"||r==="sget"&&s==="sset"||r==="sset"&&s==="sget"?(e[n]="true",!1):r?!0:(e[n]=s,!1)}function Xt(e,t){var n=e.computed,r=e.key;return!n&&(r.type==="Identifier"&&r.name===t||r.type==="Literal"&&r.value===t)}I.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual("from"),this.type!==h.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")};I.parseExport=function(e,t){if(this.next(),this.eat(h.star))return this.parseExportAllDeclaration(e,t);if(this.eat(h._default))return this.checkExport(t,"default",this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type==="VariableDeclaration"?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==h.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,r=e.specifiers;n<r.length;n+=1){var s=r[n];this.checkUnreserved(s.local),this.checkLocalExport(s.local),s.local.type==="Literal"&&this.raise(s.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,"ExportNamedDeclaration")};I.parseExportDeclaration=function(e){return this.parseStatement(null)};I.parseExportDefaultDeclaration=function(){var e;if(this.type===h._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,Et|ys,!1,e)}else if(this.type===h._class){var n=this.startNode();return this.parseClass(n,"nullableID")}else{var r=this.parseMaybeAssign();return this.semicolon(),r}};I.checkExport=function(e,t,n){e&&(typeof t!="string"&&(t=t.type==="Identifier"?t.name:t.value),ht(e,t)&&this.raiseRecoverable(n,"Duplicate export '"+t+"'"),e[t]=!0)};I.checkPatternExport=function(e,t){var n=t.type;if(n==="Identifier")this.checkExport(e,t,t.start);else if(n==="ObjectPattern")for(var r=0,s=t.properties;r<s.length;r+=1){var a=s[r];this.checkPatternExport(e,a)}else if(n==="ArrayPattern")for(var i=0,o=t.elements;i<o.length;i+=1){var u=o[i];u&&this.checkPatternExport(e,u)}else n==="Property"?this.checkPatternExport(e,t.value):n==="AssignmentPattern"?this.checkPatternExport(e,t.left):n==="RestElement"&&this.checkPatternExport(e,t.argument)};I.checkVariableExport=function(e,t){if(e)for(var n=0,r=t;n<r.length;n+=1){var s=r[n];this.checkPatternExport(e,s.id)}};I.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};I.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual("as")?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,"ExportSpecifier")};I.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(h.braceL);!this.eat(h.braceR);){if(n)n=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;t.push(this.parseExportSpecifier(e))}return t};I.parseImport=function(e){return this.next(),this.type===h.string?(e.specifiers=Ba,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===h.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")};I.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual("as")?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,Fe),this.finishNode(e,"ImportSpecifier")};I.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,Fe),this.finishNode(e,"ImportDefaultSpecifier")};I.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,Fe),this.finishNode(e,"ImportNamespaceSpecifier")};I.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===h.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(h.comma)))return e;if(this.type===h.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(h.braceL);!this.eat(h.braceR);){if(t)t=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;e.push(this.parseImportSpecifier())}return e};I.parseWithClause=function(){var e=[];if(!this.eat(h._with))return e;this.expect(h.braceL);for(var t={},n=!0;!this.eat(h.braceR);){if(n)n=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;var r=this.parseImportAttribute(),s=r.key.type==="Identifier"?r.key.name:r.key.value;ht(t,s)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+s+"'"),t[s]=!0,e.push(r)}return e};I.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===h.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(h.colon),this.type!==h.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")};I.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===h.string){var e=this.parseLiteral(this.value);return Ia.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)};I.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)};I.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type==="ExpressionStatement"&&e.expression.type==="Literal"&&typeof e.expression.value=="string"&&(this.input[e.start]==='"'||this.input[e.start]==="'")};var we=ne.prototype;we.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&e.name==="await"&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];this.toAssignable(a,t),a.type==="RestElement"&&(a.argument.type==="ArrayPattern"||a.argument.type==="ObjectPattern")&&this.raise(a.argument.start,"Unexpected token")}break;case"Property":e.kind!=="init"&&this.raise(e.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(e.value,t);break;case"ArrayExpression":e.type="ArrayPattern",n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,t);break;case"SpreadElement":e.type="RestElement",this.toAssignable(e.argument,t),e.argument.type==="AssignmentPattern"&&this.raise(e.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":e.operator!=="="&&this.raise(e.left.end,"Only '=' operator can be used for specifying default value."),e.type="AssignmentPattern",delete e.operator,this.toAssignable(e.left,t);break;case"ParenthesizedExpression":this.toAssignable(e.expression,t,n);break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!t)break;default:this.raise(e.start,"Assigning to rvalue")}else n&&this.checkPatternErrors(n,!0);return e};we.toAssignableList=function(e,t){for(var n=e.length,r=0;r<n;r++){var s=e[r];s&&this.toAssignable(s,t)}if(n){var a=e[n-1];this.options.ecmaVersion===6&&t&&a&&a.type==="RestElement"&&a.argument.type!=="Identifier"&&this.unexpected(a.argument.start)}return e};we.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")};we.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==h.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")};we.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case h.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(h.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case h.braceL:return this.parseObj(!0)}return this.parseIdent()};we.parseBindingList=function(e,t,n,r){for(var s=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(h.comma),t&&this.type===h.comma)s.push(null);else{if(n&&this.afterTrailingComma(e))break;if(this.type===h.ellipsis){var i=this.parseRestBinding();this.parseBindingListItem(i),s.push(i),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}else s.push(this.parseAssignableListItem(r))}return s};we.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t};we.parseBindingListItem=function(e){return e};we.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(h.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")};we.checkLValSimple=function(e,t,n){t===void 0&&(t=Yt);var r=t!==Yt;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?"Binding ":"Assigning to ")+e.name+" in strict mode"),r&&(t===Fe&&e.name==="let"&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),n&&(ht(n,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),n[e.name]=!0),t!==gs&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":r&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return r&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(r?"Binding":"Assigning to")+" rvalue")}};we.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=Yt),e.type){case"ObjectPattern":for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];this.checkLValInnerPattern(a,t,n)}break;case"ArrayPattern":for(var i=0,o=e.elements;i<o.length;i+=1){var u=o[i];u&&this.checkLValInnerPattern(u,t,n)}break;default:this.checkLValSimple(e,t,n)}};we.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=Yt),e.type){case"Property":this.checkLValInnerPattern(e.value,t,n);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,n);break;case"RestElement":this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}};var ke=function(t,n,r,s,a){this.token=t,this.isExpr=!!n,this.preserveSpace=!!r,this.override=s,this.generator=!!a},Q={b_stat:new ke("{",!1),b_expr:new ke("{",!0),b_tmpl:new ke("${",!1),p_stat:new ke("(",!1),p_expr:new ke("(",!0),q_tmpl:new ke("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new ke("function",!1),f_expr:new ke("function",!0),f_expr_gen:new ke("function",!0,!1,null,!0),f_gen:new ke("function",!1,!1,null,!0)},mt=ne.prototype;mt.initialContext=function(){return[Q.b_stat]};mt.curContext=function(){return this.context[this.context.length-1]};mt.braceIsBlock=function(e){var t=this.curContext();return t===Q.f_expr||t===Q.f_stat?!0:e===h.colon&&(t===Q.b_stat||t===Q.b_expr)?!t.isExpr:e===h._return||e===h.name&&this.exprAllowed?me.test(this.input.slice(this.lastTokEnd,this.start)):e===h._else||e===h.semi||e===h.eof||e===h.parenR||e===h.arrow?!0:e===h.braceL?t===Q.b_stat:e===h._var||e===h._const||e===h.name?!1:!this.exprAllowed};mt.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token==="function")return t.generator}return!1};mt.updateContext=function(e){var t,n=this.type;n.keyword&&e===h.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr};mt.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)};h.parenR.updateContext=h.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===Q.b_stat&&this.curContext().token==="function"&&(e=this.context.pop()),this.exprAllowed=!e.isExpr};h.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?Q.b_stat:Q.b_expr),this.exprAllowed=!0};h.dollarBraceL.updateContext=function(){this.context.push(Q.b_tmpl),this.exprAllowed=!0};h.parenL.updateContext=function(e){var t=e===h._if||e===h._for||e===h._with||e===h._while;this.context.push(t?Q.p_stat:Q.p_expr),this.exprAllowed=!0};h.incDec.updateContext=function(){};h._function.updateContext=h._class.updateContext=function(e){e.beforeExpr&&e!==h._else&&!(e===h.semi&&this.curContext()!==Q.p_stat)&&!(e===h._return&&me.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===h.colon||e===h.braceL)&&this.curContext()===Q.b_stat)?this.context.push(Q.f_expr):this.context.push(Q.f_stat),this.exprAllowed=!1};h.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};h.backQuote.updateContext=function(){this.curContext()===Q.q_tmpl?this.context.pop():this.context.push(Q.q_tmpl),this.exprAllowed=!1};h.star.updateContext=function(e){if(e===h._function){var t=this.context.length-1;this.context[t]===Q.f_expr?this.context[t]=Q.f_expr_gen:this.context[t]=Q.f_gen}this.exprAllowed=!0};h.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==h.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var M=ne.prototype;M.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&e.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r=e.key,s;switch(r.type){case"Identifier":s=r.name;break;case"Literal":s=String(r.value);break;default:return}var a=e.kind;if(this.options.ecmaVersion>=6){s==="__proto__"&&a==="init"&&(t.proto&&(n?n.doubleProto<0&&(n.doubleProto=r.start):this.raiseRecoverable(r.start,"Redefinition of __proto__ property")),t.proto=!0);return}s="$"+s;var i=t[s];if(i){var o;a==="init"?o=this.strict&&i.init||i.get||i.set:o=i.init||i[a],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else i=t[s]={init:!1,get:!1,set:!1};i[a]=!0}};M.parseExpression=function(e,t){var n=this.start,r=this.startLoc,s=this.parseMaybeAssign(e,t);if(this.type===h.comma){var a=this.startNodeAt(n,r);for(a.expressions=[s];this.eat(h.comma);)a.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(a,"SequenceExpression")}return s};M.parseMaybeAssign=function(e,t,n){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,s=-1,a=-1,i=-1;t?(s=t.parenthesizedAssign,a=t.trailingComma,i=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new an,r=!0);var o=this.start,u=this.startLoc;(this.type===h.parenL||this.type===h.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e==="await");var c=this.parseMaybeConditional(e,t);if(n&&(c=n.call(this,c,o,u)),this.type.isAssign){var l=this.startNodeAt(o,u);return l.operator=this.value,this.type===h.eq&&(c=this.toAssignable(c,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=c.start&&(t.shorthandAssign=-1),this.type===h.eq?this.checkLValPattern(c):this.checkLValSimple(c),l.left=c,this.next(),l.right=this.parseMaybeAssign(e),i>-1&&(t.doubleProto=i),this.finishNode(l,"AssignmentExpression")}else r&&this.checkExpressionErrors(t,!0);return s>-1&&(t.parenthesizedAssign=s),a>-1&&(t.trailingComma=a),c};M.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,s=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return s;if(this.eat(h.question)){var a=this.startNodeAt(n,r);return a.test=s,a.consequent=this.parseMaybeAssign(),this.expect(h.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,"ConditionalExpression")}return s};M.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,s=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||s.start===n&&s.type==="ArrowFunctionExpression"?s:this.parseExprOp(s,n,r,-1,e)};M.parseExprOp=function(e,t,n,r,s){var a=this.type.binop;if(a!=null&&(!s||this.type!==h._in)&&a>r){var i=this.type===h.logicalOR||this.type===h.logicalAND,o=this.type===h.coalesce;o&&(a=h.logicalAND.binop);var u=this.value;this.next();var c=this.start,l=this.startLoc,p=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,s),c,l,a,s),f=this.buildBinary(t,n,e,p,u,i||o);return(i&&this.type===h.coalesce||o&&(this.type===h.logicalOR||this.type===h.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(f,t,n,r,s)}return e};M.buildBinary=function(e,t,n,r,s,a){r.type==="PrivateIdentifier"&&this.raise(r.start,"Private identifier can only be left side of binary expression");var i=this.startNodeAt(e,t);return i.left=n,i.operator=s,i.right=r,this.finishNode(i,a?"LogicalExpression":"BinaryExpression")};M.parseMaybeUnary=function(e,t,n,r){var s=this.start,a=this.startLoc,i;if(this.isContextual("await")&&this.canAwait)i=this.parseAwait(r),t=!0;else if(this.type.prefix){var o=this.startNode(),u=this.type===h.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,u,r),this.checkExpressionErrors(e,!0),u?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&bs(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&Jn(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):t=!0,i=this.finishNode(o,u?"UpdateExpression":"UnaryExpression")}else if(!t&&this.type===h.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),i=this.parsePrivateIdent(),this.type!==h._in&&this.unexpected();else{if(i=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return i;for(;this.type.postfix&&!this.canInsertSemicolon();){var c=this.startNodeAt(s,a);c.operator=this.value,c.prefix=!1,c.argument=i,this.checkLValSimple(i),this.next(),i=this.finishNode(c,"UpdateExpression")}}if(!n&&this.eat(h.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(s,a,i,this.parseMaybeUnary(null,!1,!1,r),"**",!1);else return i};function bs(e){return e.type==="Identifier"||e.type==="ParenthesizedExpression"&&bs(e.expression)}function Jn(e){return e.type==="MemberExpression"&&e.property.type==="PrivateIdentifier"||e.type==="ChainExpression"&&Jn(e.expression)||e.type==="ParenthesizedExpression"&&Jn(e.expression)}M.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,s=this.parseExprAtom(e,t);if(s.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return s;var a=this.parseSubscripts(s,n,r,!1,t);return e&&a.type==="MemberExpression"&&(e.parenthesizedAssign>=a.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=a.start&&(e.parenthesizedBind=-1),e.trailingComma>=a.start&&(e.trailingComma=-1)),a};M.parseSubscripts=function(e,t,n,r,s){for(var a=this.options.ecmaVersion>=8&&e.type==="Identifier"&&e.name==="async"&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,i=!1;;){var o=this.parseSubscript(e,t,n,r,a,i,s);if(o.optional&&(i=!0),o===e||o.type==="ArrowFunctionExpression"){if(i){var u=this.startNodeAt(t,n);u.expression=o,o=this.finishNode(u,"ChainExpression")}return o}e=o}};M.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(h.arrow)};M.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)};M.parseSubscript=function(e,t,n,r,s,a,i){var o=this.options.ecmaVersion>=11,u=o&&this.eat(h.questionDot);r&&u&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var c=this.eat(h.bracketL);if(c||u&&this.type!==h.parenL&&this.type!==h.backQuote||this.eat(h.dot)){var l=this.startNodeAt(t,n);l.object=e,c?(l.property=this.parseExpression(),this.expect(h.bracketR)):this.type===h.privateId&&e.type!=="Super"?l.property=this.parsePrivateIdent():l.property=this.parseIdent(this.options.allowReserved!=="never"),l.computed=!!c,o&&(l.optional=u),e=this.finishNode(l,"MemberExpression")}else if(!r&&this.eat(h.parenL)){var p=new an,f=this.yieldPos,d=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var y=this.parseExprList(h.parenR,this.options.ecmaVersion>=8,!1,p);if(s&&!u&&this.shouldParseAsyncArrow())return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=f,this.awaitPos=d,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(t,n,y,i);this.checkExpressionErrors(p,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=d||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var x=this.startNodeAt(t,n);x.callee=e,x.arguments=y,o&&(x.optional=u),e=this.finishNode(x,"CallExpression")}else if(this.type===h.backQuote){(u||a)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var S=this.startNodeAt(t,n);S.tag=e,S.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(S,"TaggedTemplateExpression")}return e};M.parseExprAtom=function(e,t,n){this.type===h.slash&&this.readRegexp();var r,s=this.potentialArrowAt===this.start;switch(this.type){case h._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),r=this.startNode(),this.next(),this.type===h.parenL&&!this.allowDirectSuper&&this.raise(r.start,"super() call outside constructor of a subclass"),this.type!==h.dot&&this.type!==h.bracketL&&this.type!==h.parenL&&this.unexpected(),this.finishNode(r,"Super");case h._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case h.name:var a=this.start,i=this.startLoc,o=this.containsEsc,u=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&u.name==="async"&&!this.canInsertSemicolon()&&this.eat(h._function))return this.overrideContext(Q.f_expr),this.parseFunction(this.startNodeAt(a,i),0,!1,!0,t);if(s&&!this.canInsertSemicolon()){if(this.eat(h.arrow))return this.parseArrowExpression(this.startNodeAt(a,i),[u],!1,t);if(this.options.ecmaVersion>=8&&u.name==="async"&&this.type===h.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return u=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(h.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,i),[u],!0,t)}return u;case h.regexp:var c=this.value;return r=this.parseLiteral(c.value),r.regex={pattern:c.pattern,flags:c.flags},r;case h.num:case h.string:return this.parseLiteral(this.value);case h._null:case h._true:case h._false:return r=this.startNode(),r.value=this.type===h._null?null:this.type===h._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,"Literal");case h.parenL:var l=this.start,p=this.parseParenAndDistinguishExpression(s,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(p)&&(e.parenthesizedAssign=l),e.parenthesizedBind<0&&(e.parenthesizedBind=l)),p;case h.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(h.bracketR,!0,!0,e),this.finishNode(r,"ArrayExpression");case h.braceL:return this.overrideContext(Q.b_expr),this.parseObj(!1,e);case h._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case h._class:return this.parseClass(this.startNode(),!1);case h._new:return this.parseNew();case h.backQuote:return this.parseTemplate();case h._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}};M.parseExprAtomDefault=function(){this.unexpected()};M.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===h.parenL&&!e)return this.parseDynamicImport(t);if(this.type===h.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name="import",t.meta=this.finishNode(n,"Identifier"),this.parseImportMeta(t)}else this.unexpected()};M.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(h.parenR)?e.options=null:(this.expect(h.comma),this.afterTrailingComma(h.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(h.parenR)||(this.expect(h.comma),this.afterTrailingComma(h.parenR)||this.unexpected())));else if(!this.eat(h.parenR)){var t=this.start;this.eat(h.comma)&&this.eat(h.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")};M.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="meta"&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")};M.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value!=null?t.value.toString():t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")};M.parseParenExpression=function(){this.expect(h.parenL);var e=this.parseExpression();return this.expect(h.parenR),e};M.shouldParseArrow=function(e){return!this.canInsertSemicolon()};M.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,s,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var i=this.start,o=this.startLoc,u=[],c=!0,l=!1,p=new an,f=this.yieldPos,d=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==h.parenR;)if(c?c=!1:this.expect(h.comma),a&&this.afterTrailingComma(h.parenR,!0)){l=!0;break}else if(this.type===h.ellipsis){m=this.start,u.push(this.parseParenItem(this.parseRestBinding())),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else u.push(this.parseMaybeAssign(!1,p,this.parseParenItem));var y=this.lastTokEnd,x=this.lastTokEndLoc;if(this.expect(h.parenR),e&&this.shouldParseArrow(u)&&this.eat(h.arrow))return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=d,this.parseParenArrowList(n,r,u,t);(!u.length||l)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(p,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=d||this.awaitPos,u.length>1?(s=this.startNodeAt(i,o),s.expressions=u,this.finishNodeAt(s,"SequenceExpression",y,x)):s=u[0]}else s=this.parseParenExpression();if(this.options.preserveParens){var S=this.startNodeAt(n,r);return S.expression=s,this.finishNode(S,"ParenthesizedExpression")}else return s};M.parseParenItem=function(e){return e};M.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var Fa=[];M.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===h.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="target"&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),n&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var r=this.start,s=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,s,!0,!1),this.eat(h.parenL)?e.arguments=this.parseExprList(h.parenR,this.options.ecmaVersion>=8,!1):e.arguments=Fa,this.finishNode(e,"NewExpression")};M.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===h.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value.replace(/\r\n?/g,`
4
4
  `),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
5
- `),cooked:this.value},this.next(),n.tail=this.type===h.backQuote,this.finishNode(n,"TemplateElement")};R.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.type===h.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(h.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(h.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,"TemplateLiteral")};R.isAsyncProp=function(e){return!e.computed&&e.key.type==="Identifier"&&e.key.name==="async"&&(this.type===h.name||this.type===h.num||this.type===h.string||this.type===h.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===h.star)&&!me.test(this.input.slice(this.lastTokEnd,this.start))};R.parseObj=function(e,t){var n=this.startNode(),r=!0,s={};for(n.properties=[],this.next();!this.eat(h.braceR);){if(r)r=!1;else if(this.expect(h.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(h.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,s,t),n.properties.push(a)}return this.finishNode(n,e?"ObjectPattern":"ObjectExpression")};R.parseProperty=function(e,t){var n=this.startNode(),r,s,a,i;if(this.options.ecmaVersion>=9&&this.eat(h.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(n,"RestElement")):(n.argument=this.parseMaybeAssign(!1,t),this.type===h.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(n,"SpreadElement"));this.options.ecmaVersion>=6&&(n.method=!1,n.shorthand=!1,(e||t)&&(a=this.start,i=this.startLoc),e||(r=this.eat(h.star)));var o=this.containsEsc;return this.parsePropertyName(n),!e&&!o&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(n)?(s=!0,r=this.options.ecmaVersion>=9&&this.eat(h.star),this.parsePropertyName(n)):s=!1,this.parsePropertyValue(n,e,r,s,a,i,t,o),this.finishNode(n,"Property")};R.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind==="get"?0:1;if(e.value.params.length!==n){var r=e.value.start;e.kind==="get"?this.raiseRecoverable(r,"getter should have no params"):this.raiseRecoverable(r,"setter should have exactly one param")}else e.kind==="set"&&e.value.params[0].type==="RestElement"&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")};R.parsePropertyValue=function(e,t,n,r,s,a,i,o){(n||r)&&this.type===h.colon&&this.unexpected(),this.eat(h.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,i),e.kind="init"):this.options.ecmaVersion>=6&&this.type===h.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,r),e.kind="init"):!t&&!o&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type==="Identifier"&&(e.key.name==="get"||e.key.name==="set")&&this.type!==h.comma&&this.type!==h.braceR&&this.type!==h.eq?((n||r)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type==="Identifier"?((n||r)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=s),t?e.value=this.parseMaybeDefault(s,a,this.copyNode(e.key)):this.type===h.eq&&i?(i.shorthandAssign<0&&(i.shorthandAssign=this.start),e.value=this.parseMaybeDefault(s,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected()};R.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(h.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(h.bracketR),e.key;e.computed=!1}return e.key=this.type===h.num||this.type===h.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};R.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)};R.parseMethod=function(e,t,n){var r=this.startNode(),s=this.yieldPos,a=this.awaitPos,i=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Wn(t,r.generator)|en|(n?as:0)),this.expect(h.parenL),r.params=this.parseBindingList(h.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=s,this.awaitPos=a,this.awaitIdentPos=i,this.finishNode(r,"FunctionExpression")};R.parseArrowExpression=function(e,t,n,r){var s=this.yieldPos,a=this.awaitPos,i=this.awaitIdentPos;return this.enterScope(Wn(n,!1)|Un),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=s,this.awaitPos=a,this.awaitIdentPos=i,this.finishNode(e,"ArrowFunctionExpression")};R.parseFunctionBody=function(e,t,n,r){var s=t&&this.type!==h.braceL,a=this.strict,i=!1;if(s)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!a||o)&&(i=this.strictDirective(this.end),i&&o&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var u=this.labels;this.labels=[],i&&(this.strict=!0),this.checkParams(e,!a&&!i&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,cs),e.body=this.parseBlock(!1,void 0,i&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=u}this.exitScope()};R.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1){var r=n[t];if(r.type!=="Identifier")return!1}return!0};R.checkParams=function(e,t){for(var n=Object.create(null),r=0,s=e.params;r<s.length;r+=1){var a=s[r];this.checkLValInnerPattern(a,Jn,t?null:n)}};R.parseExprList=function(e,t,n,r){for(var s=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(h.comma),t&&this.afterTrailingComma(e))break;var i=void 0;n&&this.type===h.comma?i=null:this.type===h.ellipsis?(i=this.parseSpread(r),r&&this.type===h.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):i=this.parseMaybeAssign(!1,r),s.push(i)}return s};R.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;if(this.inGenerator&&r==="yield"&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&r==="await"&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&tn)&&r==="arguments"&&this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(r==="arguments"||r==="await")&&this.raise(t,"Cannot use "+r+" in class static initialization block"),this.keywords.test(r)&&this.raise(t,"Unexpected keyword '"+r+"'"),!(this.options.ecmaVersion<6&&this.input.slice(t,n).indexOf("\\")!==-1)){var s=this.strict?this.reservedWordsStrict:this.reservedWords;s.test(r)&&(!this.inAsync&&r==="await"&&this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+r+"' is reserved"))}};R.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,"Identifier"),e||(this.checkUnreserved(t),t.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t};R.parseIdentNode=function(){var e=this.startNode();return this.type===h.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name==="class"||e.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=h.name):this.unexpected(),e};R.parsePrivateIdent=function(){var e=this.startNode();return this.type===h.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,"Private field '#"+e.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e};R.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===h.semi||this.canInsertSemicolon()||this.type!==h.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(h.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")};R.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,"AwaitExpression")};var Qt=ne.prototype;Qt.raise=function(e,t){var n=rs(this.input,e);t+=" ("+n.line+":"+n.column+")",this.sourceFile&&(t+=" in "+this.sourceFile);var r=new SyntaxError(t);throw r.pos=e,r.loc=n,r.raisedAt=this.pos,r};Qt.raiseRecoverable=Qt.raise;Qt.curPosition=function(){if(this.options.locations)return new vt(this.curLine,this.pos-this.lineStart)};var ze=ne.prototype,Aa=function(t){this.flags=t,this.var=[],this.lexical=[],this.functions=[]};ze.enterScope=function(e){this.scopeStack.push(new Aa(e))};ze.exitScope=function(){this.scopeStack.pop()};ze.treatFunctionsAsVarInScope=function(e){return e.flags&ft||!this.inModule&&e.flags&kt};ze.declareName=function(e,t,n){var r=!1;if(t===De){var s=this.currentScope();r=s.lexical.indexOf(e)>-1||s.functions.indexOf(e)>-1||s.var.indexOf(e)>-1,s.lexical.push(e),this.inModule&&s.flags&kt&&delete this.undefinedExports[e]}else if(t===us){var a=this.currentScope();a.lexical.push(e)}else if(t===os){var i=this.currentScope();this.treatFunctionsAsVar?r=i.lexical.indexOf(e)>-1:r=i.lexical.indexOf(e)>-1||i.var.indexOf(e)>-1,i.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var u=this.scopeStack[o];if(u.lexical.indexOf(e)>-1&&!(u.flags&is&&u.lexical[0]===e)||!this.treatFunctionsAsVarInScope(u)&&u.functions.indexOf(e)>-1){r=!0;break}if(u.var.push(e),this.inModule&&u.flags&kt&&delete this.undefinedExports[e],u.flags&tn)break}r&&this.raiseRecoverable(n,"Identifier '"+e+"' has already been declared")};ze.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)};ze.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};ze.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(tn|Et|Ze))return t}};ze.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(tn|Et|Ze)&&!(t.flags&Un))return t}};var rn=function(t,n,r){this.type="",this.start=n,this.end=0,t.options.locations&&(this.loc=new Xt(t,r)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[n,0])},Tt=ne.prototype;Tt.startNode=function(){return new rn(this,this.start,this.startLoc)};Tt.startNodeAt=function(e,t){return new rn(this,e,t)};function ps(e,t,n,r){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=n),e}Tt.finishNode=function(e,t){return ps.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)};Tt.finishNodeAt=function(e,t,n,r){return ps.call(this,e,t,n,r)};Tt.copyNode=function(e){var t=new rn(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var Pa="Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz",hs="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",ds=hs+" Extended_Pictographic",ms=ds,gs=ms+" EBase EComp EMod EPres ExtPict",ys=gs,ja=ys,Ia={9:hs,10:ds,11:ms,12:gs,13:ys,14:ja},Na="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",Ra={9:"",10:"",11:"",12:"",13:"",14:Na},Zr="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",bs="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",xs=bs+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",_s=xs+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",ws=_s+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Ss=ws+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Ma=Ss+" "+Pa,Oa={9:bs,10:xs,11:_s,12:ws,13:Ss,14:Ma},vs={};function Ba(e){var t=vs[e]={binary:We(Ia[e]+" "+Zr),binaryOfStrings:We(Ra[e]),nonBinary:{General_Category:We(Zr),Script:We(Oa[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(Ht=0,On=[9,10,11,12,13,14];Ht<On.length;Ht+=1)Qr=On[Ht],Ba(Qr);var Qr,Ht,On,P=ne.prototype,Yt=function(t,n){this.parent=t,this.base=n||this};Yt.prototype.separatedFrom=function(t){for(var n=this;n;n=n.parent)for(var r=t;r;r=r.parent)if(n.base===r.base&&n!==r)return!0;return!1};Yt.prototype.sibling=function(){return new Yt(this.parent,this.base)};var Pe=function(t){this.parser=t,this.validFlags="gim"+(t.options.ecmaVersion>=6?"uy":"")+(t.options.ecmaVersion>=9?"s":"")+(t.options.ecmaVersion>=13?"d":"")+(t.options.ecmaVersion>=15?"v":""),this.unicodeProperties=vs[t.options.ecmaVersion>=14?14:t.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};Pe.prototype.reset=function(t,n,r){var s=r.indexOf("v")!==-1,a=r.indexOf("u")!==-1;this.start=t|0,this.source=n+"",this.flags=r,s&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=a&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=a&&this.parser.options.ecmaVersion>=9)};Pe.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)};Pe.prototype.at=function(t,n){n===void 0&&(n=!1);var r=this.source,s=r.length;if(t>=s)return-1;var a=r.charCodeAt(t);if(!(n||this.switchU)||a<=55295||a>=57344||t+1>=s)return a;var i=r.charCodeAt(t+1);return i>=56320&&i<=57343?(a<<10)+i-56613888:a};Pe.prototype.nextIndex=function(t,n){n===void 0&&(n=!1);var r=this.source,s=r.length;if(t>=s)return s;var a=r.charCodeAt(t),i;return!(n||this.switchU)||a<=55295||a>=57344||t+1>=s||(i=r.charCodeAt(t+1))<56320||i>57343?t+1:t+2};Pe.prototype.current=function(t){return t===void 0&&(t=!1),this.at(this.pos,t)};Pe.prototype.lookahead=function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)};Pe.prototype.advance=function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)};Pe.prototype.eat=function(t,n){return n===void 0&&(n=!1),this.current(n)===t?(this.advance(n),!0):!1};Pe.prototype.eatChars=function(t,n){n===void 0&&(n=!1);for(var r=this.pos,s=0,a=t;s<a.length;s+=1){var i=a[s],o=this.at(r,n);if(o===-1||o!==i)return!1;r=this.nextIndex(r,n)}return this.pos=r,!0};P.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,r=!1,s=!1,a=0;a<n.length;a++){var i=n.charAt(a);t.indexOf(i)===-1&&this.raise(e.start,"Invalid regular expression flag"),n.indexOf(i,a+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),i==="u"&&(r=!0),i==="v"&&(s=!0)}this.options.ecmaVersion>=15&&r&&s&&this.raise(e.start,"Invalid regular expression flag")};function Fa(e){for(var t in e)return!0;return!1}P.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&Fa(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))};P.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,n=e.backReferenceNames;t<n.length;t+=1){var r=n[t];e.groupNames[r]||e.raise("Invalid named capture referenced")}};P.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new Yt(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")};P.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););};P.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise("Invalid quantifier"),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1};P.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1};P.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1};P.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)};P.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var r=0,s=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(s=e.lastIntValue),e.eat(125)))return s!==-1&&s<r&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=n}return!1};P.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)};P.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1};P.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),r=e.eat(45);if(n||r){for(var s=0;s<n.length;s++){var a=n.charAt(s);n.indexOf(a,s+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(r){var i=this.regexp_eatModifiers(e);!n&&!i&&e.current()===58&&e.raise("Invalid regular expression modifiers");for(var o=0;o<i.length;o++){var u=i.charAt(o);(i.indexOf(u,o+1)>-1||n.indexOf(u)>-1)&&e.raise("Duplicate regular expression modifiers")}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise("Unterminated group")}}e.pos=t}return!1};P.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1};P.regexp_eatModifiers=function(e){for(var t="",n=0;(n=e.current())!==-1&&Da(n);)t+=Be(n),e.advance();return t};function Da(e){return e===105||e===109||e===115}P.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)};P.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1};P.regexp_eatSyntaxCharacter=function(e){var t=e.current();return ks(t)?(e.lastIntValue=t,e.advance(),!0):!1};function ks(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}P.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!ks(n);)e.advance();return e.pos!==t};P.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1};P.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n)if(t)for(var r=0,s=n;r<s.length;r+=1){var a=s[r];a.separatedFrom(e.branchID)||e.raise("Duplicate capture group name")}else e.raise("Duplicate capture group name");t?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}};P.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1};P.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=Be(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=Be(e.lastIntValue);return!0}return!1};P.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),La(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function La(e){return Ce(e,!0)||e===36||e===95}P.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),Va(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Va(e){return Je(e,!0)||e===36||e===95||e===8204||e===8205}P.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)};P.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1};P.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1};P.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)};P.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1};P.regexp_eatZero=function(e){return e.current()===48&&!sn(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1};P.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1};P.regexp_eatControlLetter=function(e){var t=e.current();return Es(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Es(e){return e>=65&&e<=90||e>=97&&e<=122}P.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var n=e.pos,r=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var s=e.lastIntValue;if(r&&s>=55296&&s<=56319){var a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(i>=56320&&i<=57343)return e.lastIntValue=(s-55296)*1024+(i-56320)+65536,!0}e.pos=a,e.lastIntValue=s}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&qa(e.lastIntValue))return!0;r&&e.raise("Invalid unicode escape"),e.pos=n}return!1};function qa(e){return e>=0&&e<=1114111}P.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1};P.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var Ts=0,Fe=1,_e=2;P.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(Ua(t))return e.lastIntValue=-1,e.advance(),Fe;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=t===80)||t===112)){e.lastIntValue=-1,e.advance();var r;if(e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&r===_e&&e.raise("Invalid property name"),r;e.raise("Invalid property name")}return Ts};function Ua(e){return e===100||e===68||e===115||e===83||e===119||e===87}P.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,r),Fe}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var s=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,s)}return Ts};P.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){lt(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(n)||e.raise("Invalid property value")};P.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return Fe;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return _e;e.raise("Invalid property name")};P.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";$s(t=e.current());)e.lastStringValue+=Be(t),e.advance();return e.lastStringValue!==""};function $s(e){return Es(e)||e===95}P.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";Wa(t=e.current());)e.lastStringValue+=Be(t),e.advance();return e.lastStringValue!==""};function Wa(e){return $s(e)||sn(e)}P.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)};P.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&n===_e&&e.raise("Negated character class may contain strings"),!0}return!1};P.regexp_classContents=function(e){return e.current()===93?Fe:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),Fe)};P.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;e.switchU&&(t===-1||n===-1)&&e.raise("Invalid character class"),t!==-1&&n!==-1&&t>n&&e.raise("Range out of order in character class")}}};P.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(n===99||Ps(n))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var r=e.current();return r!==93?(e.lastIntValue=r,e.advance(),!0):!1};P.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)};P.regexp_classSetExpression=function(e){var t=Fe,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===_e&&(t=_e);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==_e&&(t=Fe);continue}e.raise("Invalid character in character class")}if(r!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(r!==e.pos)return t}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e),!n)return t;n===_e&&(t=_e)}};P.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;return n!==-1&&r!==-1&&n>r&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1};P.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?Fe:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)};P.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return n&&r===_e&&e.raise("Negated character class may contain strings"),r;e.pos=t}if(e.eat(92)){var s=this.regexp_eatCharacterClassEscape(e);if(s)return s;e.pos=t}return null};P.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise("Invalid escape");e.pos=t}return null};P.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===_e&&(t=_e);return t};P.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?Fe:_e};P.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var n=e.current();return n<0||n===e.lookahead()&&Ja(n)||za(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function Ja(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function za(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}P.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return Ga(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Ga(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}P.regexp_eatClassControlLetter=function(e){var t=e.current();return sn(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1};P.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1};P.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;sn(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function sn(e){return e>=48&&e<=57}P.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Cs(n=e.current());)e.lastIntValue=16*e.lastIntValue+As(n),e.advance();return e.pos!==t};function Cs(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function As(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}P.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+n*8+e.lastIntValue:e.lastIntValue=t*8+n}else e.lastIntValue=t;return!0}return!1};P.regexp_eatOctalDigit=function(e){var t=e.current();return Ps(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Ps(e){return e>=48&&e<=55}P.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var s=e.current();if(!Cs(s))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+As(s),e.advance()}return!0};var Gn=function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new Xt(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},D=ne.prototype;D.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new Gn(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};D.getToken=function(){return this.next(),new Gn(this)};typeof Symbol<"u"&&(D[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===h.eof,value:t}}}});D.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(h.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())};D.readToken=function(e){return Ce(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)};D.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var t=this.input.charCodeAt(this.pos+1);return t<=56319||t>=57344?e:(e<<10)+t-56613888};D.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf("*/",this.pos+=2);if(n===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=n+2,this.options.locations)for(var r=void 0,s=t;(r=es(this.input,s,this.pos))>-1;)++this.curLine,s=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())};D.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!ct(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())};D.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(e>8&&e<14||e>=5760&&ts.test(String.fromCharCode(e)))++this.pos;else break e}}};D.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)};D.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(h.ellipsis)):(++this.pos,this.finishToken(h.dot))};D.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(h.assign,2):this.finishOp(h.slash,1)};D.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?h.star:h.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=h.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(h.assign,n+1):this.finishOp(r,n)};D.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);if(t===e){if(this.options.ecmaVersion>=12){var n=this.input.charCodeAt(this.pos+2);if(n===61)return this.finishOp(h.assign,3)}return this.finishOp(e===124?h.logicalOR:h.logicalAND,2)}return t===61?this.finishOp(h.assign,2):this.finishOp(e===124?h.bitwiseOR:h.bitwiseAND,1)};D.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(h.assign,2):this.finishOp(h.bitwiseXOR,1)};D.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||me.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(h.incDec,2):t===61?this.finishOp(h.assign,2):this.finishOp(h.plusMin,1)};D.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(h.assign,n+1):this.finishOp(h.bitShift,n)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(n=2),this.finishOp(h.relational,n))};D.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(h.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(h.arrow)):this.finishOp(e===61?h.eq:h.prefix,1)};D.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(h.questionDot,2)}if(t===63){if(e>=12){var r=this.input.charCodeAt(this.pos+2);if(r===61)return this.finishOp(h.assign,3)}return this.finishOp(h.coalesce,2)}}return this.finishOp(h.question,1)};D.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),Ce(t,!0)||t===92))return this.finishToken(h.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+Be(t)+"'")};D.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(h.parenL);case 41:return++this.pos,this.finishToken(h.parenR);case 59:return++this.pos,this.finishToken(h.semi);case 44:return++this.pos,this.finishToken(h.comma);case 91:return++this.pos,this.finishToken(h.bracketL);case 93:return++this.pos,this.finishToken(h.bracketR);case 123:return++this.pos,this.finishToken(h.braceL);case 125:return++this.pos,this.finishToken(h.braceR);case 58:return++this.pos,this.finishToken(h.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(h.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(h.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+Be(e)+"'")};D.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)};D.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,"Unterminated regular expression");var r=this.input.charAt(this.pos);if(me.test(r)&&this.raise(n,"Unterminated regular expression"),e)e=!1;else{if(r==="[")t=!0;else if(r==="]"&&t)t=!1;else if(r==="/"&&!t)break;e=r==="\\"}++this.pos}var s=this.input.slice(n,this.pos);++this.pos;var a=this.pos,i=this.readWord1();this.containsEsc&&this.unexpected(a);var o=this.regexpState||(this.regexpState=new Pe(this));o.reset(n,s,i),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var u=null;try{u=new RegExp(s,i)}catch{}return this.finishToken(h.regexp,{pattern:s,flags:i,value:u})};D.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,s=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,i=0,o=0,u=0,c=t??1/0;u<c;++u,++this.pos){var l=this.input.charCodeAt(this.pos),p=void 0;if(r&&l===95){s&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),o===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),u===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=l;continue}if(l>=97?p=l-97+10:l>=65?p=l-65+10:l>=48&&l<=57?p=l-48:p=1/0,p>=e)break;o=l,i=i*e+p}return r&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===a||t!=null&&this.pos-a!==t?null:i};function Ha(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function js(e){return typeof BigInt!="function"?null:BigInt(e.replace(/_/g,""))}D.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return n==null&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=js(this.input.slice(t,this.pos)),++this.pos):Ce(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(h.num,n)};D.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,"Invalid number");var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,"Invalid number");var r=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&r===110){var s=js(this.input.slice(t,this.pos));return++this.pos,Ce(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(h.num,s)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),r===46&&!n&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),(r===69||r===101)&&!n&&(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,"Invalid number")),Ce(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var a=Ha(this.input.slice(t,this.pos),n);return this.finishToken(h.num,a)};D.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,"Code point out of bounds")}else t=this.readHexChar(4);return t};D.readString=function(e){for(var t="",n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(ct(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(h.string,t)};var Is={};D.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===Is)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1};D.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Is;this.raise(e,t)};D.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===h.template||this.type===h.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(h.dollarBraceL)):(++this.pos,this.finishToken(h.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(h.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(ct(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`
6
- `;break;default:e+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}};D.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(h.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
5
+ `),cooked:this.value},this.next(),n.tail=this.type===h.backQuote,this.finishNode(n,"TemplateElement")};M.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.type===h.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(h.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(h.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,"TemplateLiteral")};M.isAsyncProp=function(e){return!e.computed&&e.key.type==="Identifier"&&e.key.name==="async"&&(this.type===h.name||this.type===h.num||this.type===h.string||this.type===h.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===h.star)&&!me.test(this.input.slice(this.lastTokEnd,this.start))};M.parseObj=function(e,t){var n=this.startNode(),r=!0,s={};for(n.properties=[],this.next();!this.eat(h.braceR);){if(r)r=!1;else if(this.expect(h.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(h.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,s,t),n.properties.push(a)}return this.finishNode(n,e?"ObjectPattern":"ObjectExpression")};M.parseProperty=function(e,t){var n=this.startNode(),r,s,a,i;if(this.options.ecmaVersion>=9&&this.eat(h.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(n,"RestElement")):(n.argument=this.parseMaybeAssign(!1,t),this.type===h.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(n,"SpreadElement"));this.options.ecmaVersion>=6&&(n.method=!1,n.shorthand=!1,(e||t)&&(a=this.start,i=this.startLoc),e||(r=this.eat(h.star)));var o=this.containsEsc;return this.parsePropertyName(n),!e&&!o&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(n)?(s=!0,r=this.options.ecmaVersion>=9&&this.eat(h.star),this.parsePropertyName(n)):s=!1,this.parsePropertyValue(n,e,r,s,a,i,t,o),this.finishNode(n,"Property")};M.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind==="get"?0:1;if(e.value.params.length!==n){var r=e.value.start;e.kind==="get"?this.raiseRecoverable(r,"getter should have no params"):this.raiseRecoverable(r,"setter should have exactly one param")}else e.kind==="set"&&e.value.params[0].type==="RestElement"&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")};M.parsePropertyValue=function(e,t,n,r,s,a,i,o){(n||r)&&this.type===h.colon&&this.unexpected(),this.eat(h.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,i),e.kind="init"):this.options.ecmaVersion>=6&&this.type===h.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,r),e.kind="init"):!t&&!o&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type==="Identifier"&&(e.key.name==="get"||e.key.name==="set")&&this.type!==h.comma&&this.type!==h.braceR&&this.type!==h.eq?((n||r)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type==="Identifier"?((n||r)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=s),t?e.value=this.parseMaybeDefault(s,a,this.copyNode(e.key)):this.type===h.eq&&i?(i.shorthandAssign<0&&(i.shorthandAssign=this.start),e.value=this.parseMaybeDefault(s,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected()};M.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(h.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(h.bracketR),e.key;e.computed=!1}return e.key=this.type===h.num||this.type===h.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};M.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)};M.parseMethod=function(e,t,n){var r=this.startNode(),s=this.yieldPos,a=this.awaitPos,i=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Kn(t,r.generator)|rn|(n?hs:0)),this.expect(h.parenL),r.params=this.parseBindingList(h.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=s,this.awaitPos=a,this.awaitIdentPos=i,this.finishNode(r,"FunctionExpression")};M.parseArrowExpression=function(e,t,n,r){var s=this.yieldPos,a=this.awaitPos,i=this.awaitIdentPos;return this.enterScope(Kn(n,!1)|Hn),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=s,this.awaitPos=a,this.awaitIdentPos=i,this.finishNode(e,"ArrowFunctionExpression")};M.parseFunctionBody=function(e,t,n,r){var s=t&&this.type!==h.braceL,a=this.strict,i=!1;if(s)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!a||o)&&(i=this.strictDirective(this.end),i&&o&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var u=this.labels;this.labels=[],i&&(this.strict=!0),this.checkParams(e,!a&&!i&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,gs),e.body=this.parseBlock(!1,void 0,i&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=u}this.exitScope()};M.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1){var r=n[t];if(r.type!=="Identifier")return!1}return!0};M.checkParams=function(e,t){for(var n=Object.create(null),r=0,s=e.params;r<s.length;r+=1){var a=s[r];this.checkLValInnerPattern(a,Zn,t?null:n)}};M.parseExprList=function(e,t,n,r){for(var s=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(h.comma),t&&this.afterTrailingComma(e))break;var i=void 0;n&&this.type===h.comma?i=null:this.type===h.ellipsis?(i=this.parseSpread(r),r&&this.type===h.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):i=this.parseMaybeAssign(!1,r),s.push(i)}return s};M.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;if(this.inGenerator&&r==="yield"&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&r==="await"&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&sn)&&r==="arguments"&&this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(r==="arguments"||r==="await")&&this.raise(t,"Cannot use "+r+" in class static initialization block"),this.keywords.test(r)&&this.raise(t,"Unexpected keyword '"+r+"'"),!(this.options.ecmaVersion<6&&this.input.slice(t,n).indexOf("\\")!==-1)){var s=this.strict?this.reservedWordsStrict:this.reservedWords;s.test(r)&&(!this.inAsync&&r==="await"&&this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+r+"' is reserved"))}};M.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,"Identifier"),e||(this.checkUnreserved(t),t.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t};M.parseIdentNode=function(){var e=this.startNode();return this.type===h.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name==="class"||e.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=h.name):this.unexpected(),e};M.parsePrivateIdent=function(){var e=this.startNode();return this.type===h.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,"Private field '#"+e.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e};M.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===h.semi||this.canInsertSemicolon()||this.type!==h.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(h.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")};M.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,"AwaitExpression")};var en=ne.prototype;en.raise=function(e,t){var n=ls(this.input,e);t+=" ("+n.line+":"+n.column+")",this.sourceFile&&(t+=" in "+this.sourceFile);var r=new SyntaxError(t);throw r.pos=e,r.loc=n,r.raisedAt=this.pos,r};en.raiseRecoverable=en.raise;en.curPosition=function(){if(this.options.locations)return new Tt(this.curLine,this.pos-this.lineStart)};var ze=ne.prototype,La=function(t){this.flags=t,this.var=[],this.lexical=[],this.functions=[]};ze.enterScope=function(e){this.scopeStack.push(new La(e))};ze.exitScope=function(){this.scopeStack.pop()};ze.treatFunctionsAsVarInScope=function(e){return e.flags&dt||!this.inModule&&e.flags&$t};ze.declareName=function(e,t,n){var r=!1;if(t===Fe){var s=this.currentScope();r=s.lexical.indexOf(e)>-1||s.functions.indexOf(e)>-1||s.var.indexOf(e)>-1,s.lexical.push(e),this.inModule&&s.flags&$t&&delete this.undefinedExports[e]}else if(t===ms){var a=this.currentScope();a.lexical.push(e)}else if(t===ds){var i=this.currentScope();this.treatFunctionsAsVar?r=i.lexical.indexOf(e)>-1:r=i.lexical.indexOf(e)>-1||i.var.indexOf(e)>-1,i.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var u=this.scopeStack[o];if(u.lexical.indexOf(e)>-1&&!(u.flags&ps&&u.lexical[0]===e)||!this.treatFunctionsAsVarInScope(u)&&u.functions.indexOf(e)>-1){r=!0;break}if(u.var.push(e),this.inModule&&u.flags&$t&&delete this.undefinedExports[e],u.flags&sn)break}r&&this.raiseRecoverable(n,"Identifier '"+e+"' has already been declared")};ze.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)};ze.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};ze.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(sn|Ct|Ye))return t}};ze.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(sn|Ct|Ye)&&!(t.flags&Hn))return t}};var on=function(t,n,r){this.type="",this.start=n,this.end=0,t.options.locations&&(this.loc=new nn(t,r)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[n,0])},At=ne.prototype;At.startNode=function(){return new on(this,this.start,this.startLoc)};At.startNodeAt=function(e,t){return new on(this,e,t)};function xs(e,t,n,r){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=n),e}At.finishNode=function(e,t){return xs.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)};At.finishNodeAt=function(e,t,n,r){return xs.call(this,e,t,n,r)};At.copyNode=function(e){var t=new on(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var Va="Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz",_s="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",ws=_s+" Extended_Pictographic",Ss=ws,vs=Ss+" EBase EComp EMod EPres ExtPict",ks=vs,qa=ks,Ua={9:_s,10:ws,11:Ss,12:vs,13:ks,14:qa},Wa="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",Ja={9:"",10:"",11:"",12:"",13:"",14:Wa},rs="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",Es="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",Ts=Es+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",$s=Ts+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Cs=$s+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",As=Cs+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",za=As+" "+Va,Ga={9:Es,10:Ts,11:$s,12:Cs,13:As,14:za},Ps={};function Ha(e){var t=Ps[e]={binary:We(Ua[e]+" "+rs),binaryOfStrings:We(Ja[e]),nonBinary:{General_Category:We(rs),Script:We(Ga[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(Qt=0,Vn=[9,10,11,12,13,14];Qt<Vn.length;Qt+=1)ss=Vn[Qt],Ha(ss);var ss,Qt,Vn,j=ne.prototype,tn=function(t,n){this.parent=t,this.base=n||this};tn.prototype.separatedFrom=function(t){for(var n=this;n;n=n.parent)for(var r=t;r;r=r.parent)if(n.base===r.base&&n!==r)return!0;return!1};tn.prototype.sibling=function(){return new tn(this.parent,this.base)};var Pe=function(t){this.parser=t,this.validFlags="gim"+(t.options.ecmaVersion>=6?"uy":"")+(t.options.ecmaVersion>=9?"s":"")+(t.options.ecmaVersion>=13?"d":"")+(t.options.ecmaVersion>=15?"v":""),this.unicodeProperties=Ps[t.options.ecmaVersion>=14?14:t.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};Pe.prototype.reset=function(t,n,r){var s=r.indexOf("v")!==-1,a=r.indexOf("u")!==-1;this.start=t|0,this.source=n+"",this.flags=r,s&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=a&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=a&&this.parser.options.ecmaVersion>=9)};Pe.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)};Pe.prototype.at=function(t,n){n===void 0&&(n=!1);var r=this.source,s=r.length;if(t>=s)return-1;var a=r.charCodeAt(t);if(!(n||this.switchU)||a<=55295||a>=57344||t+1>=s)return a;var i=r.charCodeAt(t+1);return i>=56320&&i<=57343?(a<<10)+i-56613888:a};Pe.prototype.nextIndex=function(t,n){n===void 0&&(n=!1);var r=this.source,s=r.length;if(t>=s)return s;var a=r.charCodeAt(t),i;return!(n||this.switchU)||a<=55295||a>=57344||t+1>=s||(i=r.charCodeAt(t+1))<56320||i>57343?t+1:t+2};Pe.prototype.current=function(t){return t===void 0&&(t=!1),this.at(this.pos,t)};Pe.prototype.lookahead=function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)};Pe.prototype.advance=function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)};Pe.prototype.eat=function(t,n){return n===void 0&&(n=!1),this.current(n)===t?(this.advance(n),!0):!1};Pe.prototype.eatChars=function(t,n){n===void 0&&(n=!1);for(var r=this.pos,s=0,a=t;s<a.length;s+=1){var i=a[s],o=this.at(r,n);if(o===-1||o!==i)return!1;r=this.nextIndex(r,n)}return this.pos=r,!0};j.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,r=!1,s=!1,a=0;a<n.length;a++){var i=n.charAt(a);t.indexOf(i)===-1&&this.raise(e.start,"Invalid regular expression flag"),n.indexOf(i,a+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),i==="u"&&(r=!0),i==="v"&&(s=!0)}this.options.ecmaVersion>=15&&r&&s&&this.raise(e.start,"Invalid regular expression flag")};function Ka(e){for(var t in e)return!0;return!1}j.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&Ka(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))};j.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,n=e.backReferenceNames;t<n.length;t+=1){var r=n[t];e.groupNames[r]||e.raise("Invalid named capture referenced")}};j.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new tn(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")};j.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););};j.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise("Invalid quantifier"),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1};j.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1};j.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1};j.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)};j.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var r=0,s=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(s=e.lastIntValue),e.eat(125)))return s!==-1&&s<r&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=n}return!1};j.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)};j.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1};j.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),r=e.eat(45);if(n||r){for(var s=0;s<n.length;s++){var a=n.charAt(s);n.indexOf(a,s+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(r){var i=this.regexp_eatModifiers(e);!n&&!i&&e.current()===58&&e.raise("Invalid regular expression modifiers");for(var o=0;o<i.length;o++){var u=i.charAt(o);(i.indexOf(u,o+1)>-1||n.indexOf(u)>-1)&&e.raise("Duplicate regular expression modifiers")}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise("Unterminated group")}}e.pos=t}return!1};j.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1};j.regexp_eatModifiers=function(e){for(var t="",n=0;(n=e.current())!==-1&&Za(n);)t+=Be(n),e.advance();return t};function Za(e){return e===105||e===109||e===115}j.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)};j.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1};j.regexp_eatSyntaxCharacter=function(e){var t=e.current();return js(t)?(e.lastIntValue=t,e.advance(),!0):!1};function js(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}j.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!js(n);)e.advance();return e.pos!==t};j.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1};j.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n)if(t)for(var r=0,s=n;r<s.length;r+=1){var a=s[r];a.separatedFrom(e.branchID)||e.raise("Duplicate capture group name")}else e.raise("Duplicate capture group name");t?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}};j.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1};j.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=Be(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=Be(e.lastIntValue);return!0}return!1};j.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),Qa(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Qa(e){return Ce(e,!0)||e===36||e===95}j.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),Ya(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Ya(e){return Je(e,!0)||e===36||e===95||e===8204||e===8205}j.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)};j.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1};j.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1};j.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)};j.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1};j.regexp_eatZero=function(e){return e.current()===48&&!un(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1};j.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1};j.regexp_eatControlLetter=function(e){var t=e.current();return Is(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Is(e){return e>=65&&e<=90||e>=97&&e<=122}j.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var n=e.pos,r=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var s=e.lastIntValue;if(r&&s>=55296&&s<=56319){var a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(i>=56320&&i<=57343)return e.lastIntValue=(s-55296)*1024+(i-56320)+65536,!0}e.pos=a,e.lastIntValue=s}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&Xa(e.lastIntValue))return!0;r&&e.raise("Invalid unicode escape"),e.pos=n}return!1};function Xa(e){return e>=0&&e<=1114111}j.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1};j.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var Ns=0,De=1,_e=2;j.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(eo(t))return e.lastIntValue=-1,e.advance(),De;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=t===80)||t===112)){e.lastIntValue=-1,e.advance();var r;if(e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&r===_e&&e.raise("Invalid property name"),r;e.raise("Invalid property name")}return Ns};function eo(e){return e===100||e===68||e===115||e===83||e===119||e===87}j.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,r),De}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var s=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,s)}return Ns};j.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){ht(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(n)||e.raise("Invalid property value")};j.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return De;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return _e;e.raise("Invalid property name")};j.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";Rs(t=e.current());)e.lastStringValue+=Be(t),e.advance();return e.lastStringValue!==""};function Rs(e){return Is(e)||e===95}j.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";to(t=e.current());)e.lastStringValue+=Be(t),e.advance();return e.lastStringValue!==""};function to(e){return Rs(e)||un(e)}j.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)};j.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&n===_e&&e.raise("Negated character class may contain strings"),!0}return!1};j.regexp_classContents=function(e){return e.current()===93?De:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),De)};j.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;e.switchU&&(t===-1||n===-1)&&e.raise("Invalid character class"),t!==-1&&n!==-1&&t>n&&e.raise("Range out of order in character class")}}};j.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(n===99||Bs(n))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var r=e.current();return r!==93?(e.lastIntValue=r,e.advance(),!0):!1};j.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)};j.regexp_classSetExpression=function(e){var t=De,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===_e&&(t=_e);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==_e&&(t=De);continue}e.raise("Invalid character in character class")}if(r!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(r!==e.pos)return t}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e),!n)return t;n===_e&&(t=_e)}};j.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;return n!==-1&&r!==-1&&n>r&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1};j.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?De:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)};j.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return n&&r===_e&&e.raise("Negated character class may contain strings"),r;e.pos=t}if(e.eat(92)){var s=this.regexp_eatCharacterClassEscape(e);if(s)return s;e.pos=t}return null};j.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise("Invalid escape");e.pos=t}return null};j.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===_e&&(t=_e);return t};j.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?De:_e};j.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var n=e.current();return n<0||n===e.lookahead()&&no(n)||ro(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function no(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function ro(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}j.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return so(t)?(e.lastIntValue=t,e.advance(),!0):!1};function so(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}j.regexp_eatClassControlLetter=function(e){var t=e.current();return un(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1};j.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1};j.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;un(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function un(e){return e>=48&&e<=57}j.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Ms(n=e.current());)e.lastIntValue=16*e.lastIntValue+Os(n),e.advance();return e.pos!==t};function Ms(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Os(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}j.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+n*8+e.lastIntValue:e.lastIntValue=t*8+n}else e.lastIntValue=t;return!0}return!1};j.regexp_eatOctalDigit=function(e){var t=e.current();return Bs(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Bs(e){return e>=48&&e<=55}j.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var s=e.current();if(!Ms(s))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+Os(s),e.advance()}return!0};var Yn=function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new nn(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},F=ne.prototype;F.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new Yn(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};F.getToken=function(){return this.next(),new Yn(this)};typeof Symbol<"u"&&(F[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===h.eof,value:t}}}});F.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(h.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())};F.readToken=function(e){return Ce(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)};F.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var t=this.input.charCodeAt(this.pos+1);return t<=56319||t>=57344?e:(e<<10)+t-56613888};F.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf("*/",this.pos+=2);if(n===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=n+2,this.options.locations)for(var r=void 0,s=t;(r=os(this.input,s,this.pos))>-1;)++this.curLine,s=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())};F.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!pt(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())};F.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(e>8&&e<14||e>=5760&&us.test(String.fromCharCode(e)))++this.pos;else break e}}};F.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)};F.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(h.ellipsis)):(++this.pos,this.finishToken(h.dot))};F.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(h.assign,2):this.finishOp(h.slash,1)};F.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?h.star:h.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=h.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(h.assign,n+1):this.finishOp(r,n)};F.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);if(t===e){if(this.options.ecmaVersion>=12){var n=this.input.charCodeAt(this.pos+2);if(n===61)return this.finishOp(h.assign,3)}return this.finishOp(e===124?h.logicalOR:h.logicalAND,2)}return t===61?this.finishOp(h.assign,2):this.finishOp(e===124?h.bitwiseOR:h.bitwiseAND,1)};F.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(h.assign,2):this.finishOp(h.bitwiseXOR,1)};F.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||me.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(h.incDec,2):t===61?this.finishOp(h.assign,2):this.finishOp(h.plusMin,1)};F.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(h.assign,n+1):this.finishOp(h.bitShift,n)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(n=2),this.finishOp(h.relational,n))};F.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(h.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(h.arrow)):this.finishOp(e===61?h.eq:h.prefix,1)};F.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(h.questionDot,2)}if(t===63){if(e>=12){var r=this.input.charCodeAt(this.pos+2);if(r===61)return this.finishOp(h.assign,3)}return this.finishOp(h.coalesce,2)}}return this.finishOp(h.question,1)};F.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),Ce(t,!0)||t===92))return this.finishToken(h.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+Be(t)+"'")};F.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(h.parenL);case 41:return++this.pos,this.finishToken(h.parenR);case 59:return++this.pos,this.finishToken(h.semi);case 44:return++this.pos,this.finishToken(h.comma);case 91:return++this.pos,this.finishToken(h.bracketL);case 93:return++this.pos,this.finishToken(h.bracketR);case 123:return++this.pos,this.finishToken(h.braceL);case 125:return++this.pos,this.finishToken(h.braceR);case 58:return++this.pos,this.finishToken(h.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(h.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(h.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+Be(e)+"'")};F.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)};F.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,"Unterminated regular expression");var r=this.input.charAt(this.pos);if(me.test(r)&&this.raise(n,"Unterminated regular expression"),e)e=!1;else{if(r==="[")t=!0;else if(r==="]"&&t)t=!1;else if(r==="/"&&!t)break;e=r==="\\"}++this.pos}var s=this.input.slice(n,this.pos);++this.pos;var a=this.pos,i=this.readWord1();this.containsEsc&&this.unexpected(a);var o=this.regexpState||(this.regexpState=new Pe(this));o.reset(n,s,i),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var u=null;try{u=new RegExp(s,i)}catch{}return this.finishToken(h.regexp,{pattern:s,flags:i,value:u})};F.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,s=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,i=0,o=0,u=0,c=t??1/0;u<c;++u,++this.pos){var l=this.input.charCodeAt(this.pos),p=void 0;if(r&&l===95){s&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),o===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),u===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=l;continue}if(l>=97?p=l-97+10:l>=65?p=l-65+10:l>=48&&l<=57?p=l-48:p=1/0,p>=e)break;o=l,i=i*e+p}return r&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===a||t!=null&&this.pos-a!==t?null:i};function io(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function Ds(e){return typeof BigInt!="function"?null:BigInt(e.replace(/_/g,""))}F.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return n==null&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=Ds(this.input.slice(t,this.pos)),++this.pos):Ce(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(h.num,n)};F.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,"Invalid number");var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,"Invalid number");var r=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&r===110){var s=Ds(this.input.slice(t,this.pos));return++this.pos,Ce(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(h.num,s)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),r===46&&!n&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),(r===69||r===101)&&!n&&(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,"Invalid number")),Ce(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var a=io(this.input.slice(t,this.pos),n);return this.finishToken(h.num,a)};F.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,"Code point out of bounds")}else t=this.readHexChar(4);return t};F.readString=function(e){for(var t="",n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(pt(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(h.string,t)};var Fs={};F.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===Fs)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1};F.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Fs;this.raise(e,t)};F.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===h.template||this.type===h.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(h.dollarBraceL)):(++this.pos,this.finishToken(h.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(h.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(pt(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`
6
+ `;break;default:e+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}};F.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(h.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
7
7
  `&&++this.pos;case`
8
- `:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};D.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
9
- `;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return Be(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],s=parseInt(r,8);return s>255&&(r=r.slice(0,-1),s=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(s)}return ct(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}};D.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n};D.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var s=this.fullCharCodeAtPos();if(Je(s,r))this.pos+=s<=65535?1:2;else if(s===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var i=this.readCodePoint();(t?Ce:Je)(i,r)||this.invalidStringToken(a,"Invalid Unicode escape"),e+=Be(i),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)};D.readWord=function(){var e=this.readWord1(),t=h.name;return this.keywords.test(e)&&(t=Vn[e]),this.finishToken(t,e)};var Ka="8.15.0";ne.acorn={Parser:ne,version:Ka,defaultOptions:Fn,Position:vt,SourceLocation:Xt,getLineInfo:rs,Node:rn,TokenType:q,tokTypes:h,keywordTypes:Vn,TokContext:ke,tokContexts:Q,isIdentifierChar:Je,isIdentifierStart:Ce,Token:Gn,isNewLine:ct,lineBreak:me,lineBreakG:ba,nonASCIIwhitespace:ts};function je(e,t){return ne.parse(e,t)}function $t(e,t,n){return ne.parseExpressionAt(e,t,n)}var K=class extends Error{line;column;source;filename;constructor(t,n,r,s){let a=`${s||"<source>"}:${n.line}:${n.column}`;super(`${t} at ${a}`),this.name="TranspileError",this.line=n.line,this.column=n.column,this.source=r,this.filename=s}},te=class extends K{constructor(t,n,r,s){super(t,n,r,s),this.name="SyntaxError"}formatWithContext(t=2){if(!this.source)return this.message;let n=this.source.split(`
8
+ `:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};F.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
9
+ `;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return Be(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],s=parseInt(r,8);return s>255&&(r=r.slice(0,-1),s=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(s)}return pt(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}};F.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n};F.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var s=this.fullCharCodeAtPos();if(Je(s,r))this.pos+=s<=65535?1:2;else if(s===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var i=this.readCodePoint();(t?Ce:Je)(i,r)||this.invalidStringToken(a,"Invalid Unicode escape"),e+=Be(i),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)};F.readWord=function(){var e=this.readWord1(),t=h.name;return this.keywords.test(e)&&(t=zn[e]),this.finishToken(t,e)};var ao="8.15.0";ne.acorn={Parser:ne,version:ao,defaultOptions:Un,Position:Tt,SourceLocation:nn,getLineInfo:ls,Node:on,TokenType:q,tokTypes:h,keywordTypes:zn,TokContext:ke,tokContexts:Q,isIdentifierChar:Je,isIdentifierStart:Ce,Token:Yn,isNewLine:pt,lineBreak:me,lineBreakG:Aa,nonASCIIwhitespace:us};function je(e,t){return ne.parse(e,t)}function Pt(e,t,n){return ne.parseExpressionAt(e,t,n)}var K=class extends Error{line;column;source;filename;constructor(t,n,r,s){let a=`${s||"<source>"}:${n.line}:${n.column}`;super(`${t} at ${a}`),this.name="TranspileError",this.line=n.line,this.column=n.column,this.source=r,this.filename=s}},te=class extends K{constructor(t,n,r,s){super(t,n,r,s),this.name="SyntaxError"}formatWithContext(t=2){if(!this.source)return this.message;let n=this.source.split(`
10
10
  `),r=this.line-1,s=Math.max(0,r-t),a=Math.min(n.length-1,r+t),i=[],o=String(a+1).length;for(let u=s;u<=a;u++){let c=String(u+1).padStart(o),l=u===r?">":" ";if(i.push(`${l} ${c} | ${n[u]}`),u===r){let p=" ".repeat(o+4+this.column);i.push(`${p}^ ${this.message.split(" at ")[0]}`)}}return i.join(`
11
- `)}};function Se(e){return{depth:e.depth+1,locals:new Map,parent:e,parameters:e.parameters,atoms:e.atoms,warnings:e.warnings,source:e.source,filename:e.filename,options:e.options,helpers:e.helpers,helperSteps:e.helperSteps,helperTransforming:e.helperTransforming}}function Z(e){return e.loc?{line:e.loc.start.line,column:e.loc.start.column}:{line:1,column:0}}function Za(e,t){let n=e.match(t);if(!n)return null;let r=n.index+n[0].length-1,s=1,a=r+1;for(;a<e.length&&s>0;)e[a]==="{"?s++:e[a]==="}"&&s--,a++;if(s!==0)return null;let i=e.slice(r,a),o=[n[0].slice(0,-1)+i,i];return o.index=n.index,o}function Bs(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\btry\s*\{/);if(r){let a=n+r[0].length-1+1,i=1,o=a;for(;o<e.length&&i>0;){let c=e[o];c==="{"?i++:c==="}"&&i--,o++}if(i!==0){t+=e[n],n++;continue}if(e.slice(o).match(/^\s*(catch|finally)\b/))t+=e.slice(n,o),n=o;else{let c=e.slice(a,o-1);t+=`try {${c}} catch (__try_err) { return new (__tjs?.MonadicError ?? Error)(__try_err?.message || String(__try_err), 'try', undefined, undefined, __tjs?.getStack?.()) }`,n=o}}else t+=e[n],n++}return t}function Fs(e){let t=[],n="",r=0,s=0;for(;r<e.length;){let a=e.slice(r).match(/^\bwasm\s*\{/);if(a){let i=r,o=r+a[0].length,u=1,c=o;for(;c<e.length&&u>0;){let x=e[c];x==="{"?u++:x==="}"&&u--,c++}if(u!==0){n+=e[r],r++;continue}let l=e.slice(o,c-1),p,f=c,d=e.slice(c).match(/^\s*fallback\s*\{/);if(d){let x=c+d[0].length;u=1;let E=x;for(;E<e.length&&u>0;){let $=e[E];$==="{"?u++:$==="}"&&u--,E++}u===0&&(p=e.slice(x,E-1),f=E)}let y=Xa(l).map(x=>{let E=eo(e,i,x);return E?`${x}: ${E}`:x}),w={id:`__tjs_wasm_${s}`,body:l,fallback:p,captures:y,start:i,end:f};t.push(w);let k=p??l,S=y.map(x=>x.split(":")[0].trim()),b=S.length>0?S.join(", "):"",_=S.length>0?`globalThis.${w.id}(${b})`:`globalThis.${w.id}()`,v=`(globalThis.${w.id} ? ${_} : (() => {${k}})())`;n+=v,r=f,s++}else n+=e[r],r++}return{source:n,blocks:t}}function Ds(e){let t=[],n="",r=0;for(;r<e.length;){let s=/^\b(export\s+)?wasm\s+function\s+(\w+)\s*\(/,a=e.slice(r).match(s);if(!a){n+=e[r],r++;continue}let i=!!a[1],o=a[2],u=r,c=r+a[0].length,l=1,p=c;for(;p<e.length&&l>0;)e[p]==="("?l++:e[p]===")"&&l--,p++;if(l!==0){n+=e[r],r++;continue}let f=e.slice(c,p-1);if(f.match(/^\s*!/))throw new te(`Unsafe wasm functions (with \`!\` marker) are reserved for a future phase. Remove the bang from \`wasm function ${o}\` to declare it as a regular (pure) wasm function, or wait until the unsafe variant is implemented.`,Le(e,u));let g,y=p,w=e.slice(p).match(/^\s*:\s*(\w+)/);w&&(g=w[1],y=p+w[0].length);let k=e.slice(y).match(/^\s*\{/);if(!k){n+=e[r],r++;continue}let S=y+k[0].length,b=1,_=S;for(;_<e.length&&b>0;)e[_]==="{"?b++:e[_]==="}"&&b--,_++;if(b!==0){n+=e[r],r++;continue}let v=e.slice(S,_-1),x=Qa(f),E=`__tjs_wasm_${o}`,$={id:E,name:o,returnType:g,body:v,captures:x,start:u,end:_};t.push($);let C=x.map(F=>F.split(":")[0].trim()),M=`${i?"export ":""}function ${o}(${C.join(", ")}) { return globalThis.${E}(${C.join(", ")}) }`;n+=M,r=_}return{source:n,blocks:t}}function Ls(e,t){let{loader:n,importerPath:r}=t;if(!n)return{source:e,blocks:[]};let s=[],a=new Set;function i(c,l){if(!a.has(c.id)){s.push(c),a.add(c.id);for(let[p,f]of l){if(p===c.name||a.has(f.id))continue;new RegExp(`\\b${p}\\s*\\(`).test(c.body)&&i(f,l)}}}let o=/^(\s*)import\s*\{([^}]*?)\}\s*from\s*(['"])([^'"]+)\3\s*;?\s*$/gm;return{source:e.replace(o,(c,l,p,f,d)=>{let g=n.load(d,r);if(!g)return c;let y=new Map;for(let v of g.parseResult.wasmBlocks)v.name&&y.set(v.name,v);if(y.size===0)return c;let w=p.split(",").map(v=>v.trim()).filter(v=>v.length>0),k=[],S=[];for(let v of w){let x=v.match(/^(\w+)(?:\s+as\s+(\w+))?$/);if(!x){S.push(v);continue}let E=x[1],$=x[2]??x[1],C=y.get(E);if(!C){S.push(v);continue}i(C,y);let I=C.captures.map(M=>M.split(":")[0].trim());k.push(`function ${$}(${I.join(", ")}) { return globalThis.${C.id}(${I.join(", ")}) }`)}let b=k.join(`
12
- `);if(S.length===0)return b?`${l}${b}`:`${l}`;let _=`${l}import { ${S.join(", ")} } from '${d}'`;return b?`${_}
13
- ${l}${b}`:_}),blocks:s}}function Qa(e){let t=e.trim();return t?t.split(",").map(n=>n.trim()).filter(n=>n.length>0):[]}function Ya(e){return e.startsWith("f32x4_")||e.startsWith("v128_")}function Xa(e){let t=e.replace(/\/\/[^\n]*/g,"").replace(/\/\*[\s\S]*?\*\//g,""),n=new Set,r=/\.([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,s;for(;(s=r.exec(t))!==null;)n.add(s[1]);let a=/(?<!\.)(\b[a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,i=new Set;for(;(s=a.exec(t))!==null;)i.add(s[1]);for(let f of n){if(!i.has(f))continue;let d=new RegExp(`(?<!\\.)\\b${f}\\b`,"g"),g=new RegExp(`\\.${f}\\b`,"g"),y=t.match(d)?.length||0,w=t.match(g)?.length||0;y<=w&&i.delete(f)}let o=new Set,u=/\b(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;for(;(s=u.exec(t))!==null;)o.add(s[1]);let c=/\bfor\s*\(\s*(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;for(;(s=c.exec(t))!==null;)o.add(s[1]);let l=new Set(["if","else","for","while","do","switch","case","break","continue","return","function","let","const","var","new","this","true","false","null","undefined","typeof","instanceof","in","of","try","catch","finally","throw","async","await","class","extends","super","import","export","default","from","as","static","get","set","yield","console","Math","Array","Object","String","Number","Boolean","Date","JSON","Promise","Map","Set","WeakMap","WeakSet","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","ArrayBuffer","DataView","Error","TypeError","RangeError","length","push","pop","shift","unshift","slice","splice","map","filter","reduce","forEach","find","findIndex","indexOf","includes","globalThis","window","document","Infinity","NaN","isNaN","isFinite","parseInt","parseFloat","encodeURI","decodeURI","eval","wasmBuffer"]),p=[];for(let f of i)!o.has(f)&&!l.has(f)&&!Ya(f)&&p.push(f);return p.sort()}function eo(e,t,n){let r=e.slice(0,t),s=/function\s+\w+\s*\(([^)]*)\)\s*(?:->.*?)?\s*\{[^}]*$/,a=r.match(s);if(!a){let i=/(?:const|let|var)?\s*\w+\s*=\s*(?:async\s*)?\(([^)]*)\)\s*(?:=>|->)?\s*\{[^}]*$/,o=r.match(i);return o?Ns(o[1],n):void 0}return Ns(a[1],n)}function Ns(e,t){let n=e.split(",").map(r=>r.trim());for(let r of n){let s=r.match(new RegExp(`^${t}\\s*:\\s*([A-Za-z][A-Za-z0-9]*)`));if(s)return s[1];let a=r.match(new RegExp(`^${t}\\s*=\\s*(Float32Array|Float64Array|Int32Array|Uint8Array|Int8Array|Int16Array|Uint16Array|Uint32Array)`));if(a)return a[1]}}function At(e){let t=`([\\w][\\w.\\[\\]()]*|null|undefined|true|false|\\d+(?:\\.\\d+)?|'[^']*'|"[^"]*")`,n=new RegExp(t+"\\s+IsNot\\s+"+t,"g");e=e.replace(n,"IsNot($1, $2)");let r=new RegExp(t+"\\s+Is\\s+"+t,"g");return e=e.replace(r,"Is($1, $2)"),e}function Vs(e){let t=/^[\s]*[([`]/,n=/[{([,;:+\-*/%=&|?<>!~^]\s*$|^\s*$/,r=/\b(return|throw|yield|await|case|default|extends|new|typeof|void|delete|in|of|instanceof)\s*$/,s=e.split(`
14
- `),a=[],i=!1;for(let o=0;o<s.length;o++){let u=s[o],c=o>0?s[o-1]:"";if(i){a.push(u),u.includes("*/")&&(i=!1);continue}let l=u.indexOf("/*"),p=u.indexOf("*/");if(l!==-1&&(p===-1||p<l)){i=!0,a.push(u);continue}if(o>0&&t.test(u)){let f=c.replace(/\/\/.*$/,"").replace(/\/\*.*\*\/\s*$/,"");if(!n.test(f)&&!r.test(f)){let d=u.match(/^(\s*)/),g=d?d[1]:"",y=u.slice(g.length);a.push(g+";"+y);continue}}a.push(u)}return a.join(`
15
- `)}function to(e){let t=[],n=0,r="normal",s=[];for(;n<e.length;){let i=e[n],o=e[n+1];switch(r){case"single-string":if(i==="\\"&&n+1<e.length){n+=2;continue}i==="'"&&(r="normal"),n++;continue;case"double-string":if(i==="\\"&&n+1<e.length){n+=2;continue}i==='"'&&(r="normal"),n++;continue;case"template-string":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="$"&&o==="{"){n+=2,s.push(1),r="normal";continue}i==="`"&&(r="normal"),n++;continue;case"line-comment":i===`
16
- `&&(r="normal"),n++;continue;case"block-comment":if(i==="*"&&o==="/"){n+=2,r="normal";continue}n++;continue;case"regex":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="["){for(n++;n<e.length&&e[n]!=="]";)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++;continue}if(i==="/"){for(n++;n<e.length&&/[gimsuy]/.test(e[n]);)n++;r="normal";continue}n++;continue;case"normal":if(s.length>0){if(i==="{")s[s.length-1]++;else if(i==="}"&&(s[s.length-1]--,s[s.length-1]===0)){s.pop(),n++,r="template-string";continue}}if(i==="'"){n++,r="single-string";continue}if(i==='"'){n++,r="double-string";continue}if(i==="`"){n++,r="template-string";continue}if(i==="/"&&o==="/"){n+=2,r="line-comment";continue}if(i==="/"&&o==="*"){n+=2,r="block-comment";continue}if(i==="/"){let u=n-1;for(;u>=0&&/\s/.test(e[u]);)u--;let c=u>=0?e[u]:"";if(!c||/[=(!,;:{[&|?+\-*%<>~^]/.test(c)||u>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,u-10),u+1))){n++,r="regex";continue}}if(i==="t"&&e.slice(n,n+6)==="typeof"&&(n===0||!/[\w$]/.test(e[n-1]))&&/\s/.test(e[n+6]??"")){let u=n+6;for(;u<e.length&&/\s/.test(e[u]);)u++;if(u<e.length&&/[a-zA-Z_$]/.test(e[u])){let c=u;for(;u<e.length&&/[\w$]/.test(e[u]);)u++;for(;u<e.length;)if(e[u]==="."&&/[a-zA-Z_$]/.test(e[u+1]??""))for(u++;u<e.length&&/[\w$]/.test(e[u]);)u++;else if(e[u]==="?"&&e[u+1]==="."&&/[a-zA-Z_$]/.test(e[u+2]??""))for(u+=2;u<e.length&&/[\w$]/.test(e[u]);)u++;else break;t.push({keywordStart:n,operandEnd:u,operand:e.slice(c,u)}),n=u;continue}}break}n++}if(t.length===0)return e;let a=e;for(let i=t.length-1;i>=0;i--){let o=t[i];a=a.slice(0,o.keywordStart)+`TypeOf(${o.operand})`+a.slice(o.operandEnd)}return a}function Pt(e){e=to(e);let t=[],n=0,r="normal",s=[];for(;n<e.length;){let i=e[n],o=e[n+1];switch(r){case"single-string":if(i==="\\"&&n+1<e.length){n+=2;continue}i==="'"&&(r="normal"),n++;continue;case"double-string":if(i==="\\"&&n+1<e.length){n+=2;continue}i==='"'&&(r="normal"),n++;continue;case"template-string":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="$"&&o==="{"){n+=2,s.push(1),r="normal";continue}i==="`"&&(r="normal"),n++;continue;case"line-comment":i===`
17
- `&&(r="normal"),n++;continue;case"block-comment":if(i==="*"&&o==="/"){n+=2,r="normal";continue}n++;continue;case"regex":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="["){for(n++;n<e.length&&e[n]!=="]";)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++;continue}if(i==="/"){for(n++;n<e.length&&/[gimsuy]/.test(e[n]);)n++;r="normal";continue}n++;continue;case"normal":if(s.length>0){if(i==="{")s[s.length-1]++;else if(i==="}"&&(s[s.length-1]--,s[s.length-1]===0)){s.pop(),n++,r="template-string";continue}}if(i==="'"){n++,r="single-string";continue}if(i==='"'){n++,r="double-string";continue}if(i==="`"){n++,r="template-string";continue}if(i==="/"&&o==="/"){n+=2,r="line-comment";continue}if(i==="/"&&o==="*"){n+=2,r="block-comment";continue}if(i==="/"){let u=n-1;for(;u>=0&&/\s/.test(e[u]);)u--;let c=u>=0?e[u]:"";if(!c||/[=(!,;:{[&|?+\-*%<>~^]/.test(c)||u>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,u-10),u+1))){n++,r="regex";continue}}if(i==="="&&o==="="&&e[n+2]!=="="&&e[n-1]!=="!"){t.push({pos:n,op:"=="}),n+=2;continue}if(i==="!"&&o==="="&&e[n+2]!=="="){t.push({pos:n,op:"!="}),n+=2;continue}break}n++}if(t.length===0)return e;let a=e;for(let i=t.length-1;i>=0;i--){let{pos:o,op:u}=t[i],c=u==="=="?"Eq":"NotEq",l=no(a,o),p=ro(a,o+2),f=a.slice(l,o).trim(),d=a.slice(o+2,p).trim();if(f&&d){let g=a.slice(0,l),y=a.slice(p),k=/[a-zA-Z0-9_$]$/.test(g)?" ":"";a=`${g}${k}${c}(${f}, ${d})${y}`}}return a}function no(e,t){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n--;if(n<0)return 0;let r=0,s=!1,a="";for(;n>=0;){let i=e[n],o=n>0?e[n-1]:"";if(s){i===a&&o!=="\\"&&(s=!1),n--;continue}if((i==='"'||i==="'"||i==="`")&&o!=="\\"){s=!0,a=i,n--;continue}if(i===")"||i==="]"||i==="}"){r++,n--;continue}if(i==="("||i==="["){if(r>0){r--,n--;continue}return n+1}if(i==="{"){if(r>0){r--,n--;continue}return n+1}if(r>0){n--;continue}if(i===";")return n+1;if(/[a-z]/.test(i)){let u=n+1,c=n;for(;c>0&&/[a-z]/i.test(e[c-1]);)c--;let l=e.slice(c,u),p=c>0?e[c-1]:"";if(!/[a-zA-Z0-9_$]/.test(p)){if(["return","throw","case","typeof","void","delete","await","yield"].includes(l))return u;if(l==="new")return c}}if(i===">"&&o==="="||i==="="&&o!=="="&&o!=="!"&&o!=="<"&&o!==">"||i==="&"&&o==="&"||i==="|"&&o==="|"||i==="?"||i===":"||i===",")return n+1;n--}return 0}function ro(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)return e.length;let r=0,s=!1,a="";for(;n<e.length;){let i=e[n],o=n+1<e.length?e[n+1]:"";if(s){i===a&&e[n-1]!=="\\"&&(s=!1),n++;continue}if((i==='"'||i==="'"||i==="`")&&e[n-1]!=="\\"){s=!0,a=i,n++;continue}if(i==="("||i==="["||i==="{"){r++,n++;continue}if(i===")"||i==="]"||i==="}"){if(r>0){r--,n++;continue}return n}if(r>0){n++;continue}if(i===";"||i==="&"&&o==="&"||i==="|"&&o==="|"||i==="?"||i===":"||i===","||(i==="="||i==="!")&&o==="="&&e[n+2]!=="=")return n;n++}return e.length}function qs(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bType\s+([A-Z_][a-zA-Z0-9_]*)\s*/);if(r){let s=r[1],a=n+r[0].length,i=s,o=!1,u=e.slice(a).match(/^(['"`])([^]*?)\1\s*/);if(u){let f=a+u[0].length,d=e[f],g=d===void 0||f>=e.length||d!=="="&&d!=="{";if(d==="="||d==="{")i=u[2],o=!0,a=f;else if(g){let y=u[0].trim(),w=u[0].slice(y.length);t+=`const ${s} = Type('${s}', ${y})${w}`,n=f;continue}}let c,l=a,p=e.slice(a).match(/^=\s*/);if(p){a+=p[0].length;let f=e.slice(a).match(/^(\+?\d+(?:\.\d+)?|['"`][^'"`]*['"`]|\{[^}]*\}|\[[^\]]*\]|true|false|null)/);if(f){c=f[0],a+=f[0].length,l=a;let d=e.slice(a).match(/^\s*/);d&&(a+=d[0].length)}}if(e[a]==="{"){let f=a+1,d=1,g=f;for(;g<e.length&&d>0;){let v=e[g];v==="{"?d++:v==="}"&&d--,g++}if(d!==0){t+=e[n],n++;continue}let y=e.slice(f,g-1).trim(),w=g,k=y.match(/description\s*:\s*(['"`])([^]*?)\1/);k&&!o&&(i=k[2]);let S,b=y.match(/example\s*:\s*/);if(b){let v=b.index+b[0].length,x=ai(y,v);x&&(S=x.value.trim())}let _=y.match(/predicate\s*\(([^)]*)\)\s*\{([^]*)\}/);if(_&&S){let v=_[1].trim(),x=_[2].trim(),E=c?`, ${c}`:"";t+=`const ${s} = Type('${i}', (${v}) => { if (!globalThis.__tjs?.validate(${v}, globalThis.__tjs?.infer(${S}))) return false; ${x} }, ${S}${E})`}else if(_){let v=_[1].trim(),x=_[2].trim(),E=c?`, undefined, ${c}`:"";t+=`const ${s} = Type('${i}', (${v}) => { ${x} }${E})`}else if(S){let v=c?`, ${c}`:"";t+=`const ${s} = Type('${i}', undefined, ${S}${v})`}else c?t+=`const ${s} = Type('${i}', ${c})`:t+=`const ${s} = Type('${i}')`;n=w;continue}else if(c){t+=`const ${s} = Type('${i}', ${c})`,n=l;continue}else if(!u){let f=e.slice(a).match(/^(['"`][^]*?['"`]|\+?\d+(?:\.\d+)?|true|false|null|\{[^]*?\}|\[[^]*?\])/);if(f){let d=f[0];t+=`const ${s} = Type('${s}', ${d})`,n=a+f[0].length;continue}}}t+=e[n],n++}return t}function Us(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bFunctionPredicate\s+([A-Z_][a-zA-Z0-9_]*)\s*(?:<([^>]+)>)?\s*/);if(r){let s=r[1],a=r[2],i=n+r[0].length;if(e[i]==="{"){let o=1,u=i+1;for(;u<e.length&&o>0;)e[u]==="{"?o++:e[u]==="}"&&o--,u++;if(o===0){let c=e.slice(i+1,u-1).trim(),l=Za(c,/params\s*:\s*\{/),p=c.match(/returns\s*:\s*(.+?)(?:\n|$)/),f=c.match(/returnContract\s*:\s*['"](\w+)['"]/),d=c.match(/description\s*:\s*(['"])([^]*?)\1/),g=[];l&&g.push(`params: ${l[1]}`),p&&g.push(`returns: ${p[1].trim()}`),f&&g.push(`returnContract: '${f[1]}'`);let y=d?d[2]:s;if(a){let w=a.split(",").map(S=>{let b=S.trim().split("=").map(_=>_.trim());if(b.length===2){let _=b[1]==="any"||b[1]==="undefined"?"null":b[1];return`['${b[0]}', ${_}]`}return`'${b[0]}'`}),k=a.split(",").map(S=>S.trim().split("=")[0].trim());t+=`const ${s} = FunctionPredicate('${y}', [${w.join(", ")}], (${k.join(", ")}) => ({ ${g.join(", ")} }))`}else t+=`const ${s} = FunctionPredicate('${y}', { ${g.join(", ")} })`;n=u;continue}}if(e[i]==="("){let o=1,u=i+1;for(;u<e.length&&o>0;)e[u]==="("?o++:e[u]===")"&&o--,u++;if(o===0){let c=e.slice(i+1,u-1).trim(),l=c.indexOf(",");if(l!==-1){let p=c.slice(0,l).trim(),f=c.slice(l+1).trim();t+=`const ${s} = FunctionPredicate(${f}, ${p})`}else t+=`const ${s} = FunctionPredicate('${s}', ${c})`;n=u;continue}}}t+=e[n],n++}return t}function Ws(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bGeneric\s+([A-Z][a-zA-Z0-9_]*)\s*<([^>]+)>\s*\{/);if(r){let s=r[1],a=r[2],o=n+r[0].length-1+1,u=1,c=o;for(;c<e.length&&u>0;){let S=e[c];S==="{"?u++:S==="}"&&u--,c++}if(u!==0){t+=e[n],n++;continue}let l=e.slice(o,c-1).trim(),p=c,f=a.split(",").map(S=>{let b=S.trim().split("=").map(_=>_.trim());if(b.length===2){let _=b[1]==="any"||b[1]==="undefined"?"null":b[1];return`['${b[0]}', ${_}]`}return`'${b[0]}'`}),d=l,g=d.search(/\bdeclaration\s*\{/);if(g!==-1){let S=d.indexOf("{",g),b=1,_=S+1;for(;_<d.length&&b>0;)d[_]==="{"?b++:d[_]==="}"&&b--,_++;d=d.slice(0,g)+d.slice(_)}let y=d.match(/description\s*:\s*(['"`])([^]*?)\1/),w=d.match(/predicate\s*\(([^)]*)\)\s*\{([^]*)\}/),k=y?y[2]:s;if(w){let S=w[1].trim().split(",").map(E=>E.trim()),b=w[2].trim(),_=S[0]||"x",v=S.slice(1),x=v.map(E=>`check${E}`);v.forEach((E,$)=>{b=b.replace(new RegExp(`\\b${E}\\s*\\(`,"g"),`${x[$]}(`)}),t+=`const ${s} = Generic([${f.join(", ")}], (${_}, ${x.join(", ")}) => { ${b} }, '${k}')`}else t+=`const ${s} = Generic([${f.join(", ")}], () => true, '${k}')`;n=p;continue}t+=e[n],n++}return t}function Js(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bUnion\s+([A-Z][a-zA-Z0-9_]*)\s+(['"`])([^]*?)\2\s*/);if(r){let s=r[1],a=r[3],i=n+r[0].length;if(e[i]==="{"){let o=i+1,u=1,c=o;for(;c<e.length&&u>0;){let d=e[c];d==="{"?u++:d==="}"&&u--,c++}if(u!==0){t+=e[n],n++;continue}let l=e.slice(o,c-1).trim(),p=c,f=Rs(l);t+=`const ${s} = Union('${a}', [${f.join(", ")}])`,n=p;continue}else{let o=e.indexOf(`
18
- `,i);o===-1&&(o=e.length);let u=e.slice(i,o).trim();if(u){let c=Rs(u);t+=`const ${s} = Union('${a}', [${c.join(", ")}])`,n=o;continue}}}t+=e[n],n++}return t}function Rs(e){let t=[],n=e.split("|").map(r=>r.trim());for(let r of n)r&&t.push(r);return t}function zs(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bEnum\s+([A-Z][a-zA-Z0-9_]*)\s+(['"`])([^]*?)\2\s*\{/);if(r){let s=r[1],a=r[3],o=n+r[0].length-1+1,u=1,c=o;for(;c<e.length&&u>0;){let g=e[c];g==="{"?u++:g==="}"&&u--,c++}if(u!==0){t+=e[n],n++;continue}let l=e.slice(o,c-1).trim(),p=c,d=so(l).map(([g,y])=>`${g}: ${y}`).join(", ");t+=`const ${s} = Enum('${a}', { ${d} })`,n=p;continue}t+=e[n],n++}return t}function so(e){let t=[],n=0,r=e.split(/[\n,]/).map(s=>s.trim()).filter(s=>s&&!s.startsWith("//"));for(let s of r){let a=s.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(?:=\s*(.+))?$/);if(a){let i=a[1],o=a[2]?.trim();if(o!==void 0){t.push([i,o]);let u=Number(o);isNaN(u)||(n=u+1)}else t.push([i,String(n)]),n++}}return t}function Gs(e){let t=new Map,n="",r=0;for(;r<e.length;){let s=e.slice(r),a=s.match(/^(\s*)extend\s+([A-Z]\w*)\s*\{/);if(!a){if(r===0||e[r-1]===`
19
- `||e[r-1]===";"||e[r-1]==="}"){let b=s.match(/^(\s*)extend\s+([A-Z]\w*)\s*\{/)}n+=e[r],r++;continue}let i=a[1],o=a[2],u=r+a[0].length-1,c=Ct(e,u),l=e.slice(u+1,c-1).trim(),p=[],f=0,d=e.slice(u+1,c-1);for(;f<d.length;){let b=d.slice(f).match(/^(\s*)(async\s+)?(\w+)\s*\(/);if(!b){f++;continue}let _=b[1],v=!!b[2],x=b[3],E=f+b[0].length-1,$=1,C=E+1;for(;C<d.length&&$>0;)d[C]==="("&&$++,d[C]===")"&&$--,C++;let I=d.slice(E+1,C-1),M=C;for(;M<d.length&&/\s/.test(d[M]);)M++;if(d[M]==="="&&d[M+1]===">"){let ee=Le(e,u+1+f);throw new te(`Arrow functions are not allowed in extend blocks (method '${x}' in extend ${o}). Use regular function syntax instead, as extension methods need 'this' binding.`,ee)}if(d[M]!=="{"){f++;continue}let F=Ct(d,M),N=d.slice(f,F).trim(),U=I.split(",").map(ee=>ee.trim()).filter(ee=>ee.length>0).map(ee=>{let ce=ee.match(/^(\w+)\s*:\s*(.+)$/);return ce?`${ce[1]} = ${ce[2]}`:ee}).join(", "),J=v?"async ":"",X=d.slice(M+1,F-1);p.push({name:x,isAsync:v,fullText:`${x}: ${J}function(${U}) {${X}}`}),f=F}let g=!t.has(o);g&&t.set(o,new Set);let y=t.get(o);for(let S of p)y.add(S.name);let w=p.map(S=>` ${S.fullText}`).join(`,
20
- `),k;g?k=`${i}const __ext_${o} = {
21
- ${w}
11
+ `)}};function Se(e){return{depth:e.depth+1,locals:new Map,parent:e,parameters:e.parameters,atoms:e.atoms,warnings:e.warnings,source:e.source,filename:e.filename,options:e.options,helpers:e.helpers,helperSteps:e.helperSteps,helperTransforming:e.helperTransforming}}function Z(e){return e.loc?{line:e.loc.start.line,column:e.loc.start.column}:{line:1,column:0}}function Ee(e,t,n,r,s){n||(n=$),(function a(i,o,u){var c=u||i.type;n[c](i,o,a),t[c]&&t[c](i,o)})(e,r,s)}function Ls(e,t,n,r,s){var a=[];n||(n=$),(function i(o,u,c){var l=c||o.type,p=o!==a[a.length-1];p&&a.push(o),n[l](o,u,i),t[l]&&t[l](o,u||a,a),p&&a.pop()})(e,r,s)}function Xn(e,t,n){n(e,t)}function Xe(e,t,n){}var $={};$.Program=$.BlockStatement=$.StaticBlock=function(e,t,n){for(var r=0,s=e.body;r<s.length;r+=1){var a=s[r];n(a,t,"Statement")}};$.Statement=Xn;$.EmptyStatement=Xe;$.ExpressionStatement=$.ParenthesizedExpression=$.ChainExpression=function(e,t,n){return n(e.expression,t,"Expression")};$.IfStatement=function(e,t,n){n(e.test,t,"Expression"),n(e.consequent,t,"Statement"),e.alternate&&n(e.alternate,t,"Statement")};$.LabeledStatement=function(e,t,n){return n(e.body,t,"Statement")};$.BreakStatement=$.ContinueStatement=Xe;$.WithStatement=function(e,t,n){n(e.object,t,"Expression"),n(e.body,t,"Statement")};$.SwitchStatement=function(e,t,n){n(e.discriminant,t,"Expression");for(var r=0,s=e.cases;r<s.length;r+=1){var a=s[r];n(a,t)}};$.SwitchCase=function(e,t,n){e.test&&n(e.test,t,"Expression");for(var r=0,s=e.consequent;r<s.length;r+=1){var a=s[r];n(a,t,"Statement")}};$.ReturnStatement=$.YieldExpression=$.AwaitExpression=function(e,t,n){e.argument&&n(e.argument,t,"Expression")};$.ThrowStatement=$.SpreadElement=function(e,t,n){return n(e.argument,t,"Expression")};$.TryStatement=function(e,t,n){n(e.block,t,"Statement"),e.handler&&n(e.handler,t),e.finalizer&&n(e.finalizer,t,"Statement")};$.CatchClause=function(e,t,n){e.param&&n(e.param,t,"Pattern"),n(e.body,t,"Statement")};$.WhileStatement=$.DoWhileStatement=function(e,t,n){n(e.test,t,"Expression"),n(e.body,t,"Statement")};$.ForStatement=function(e,t,n){e.init&&n(e.init,t,"ForInit"),e.test&&n(e.test,t,"Expression"),e.update&&n(e.update,t,"Expression"),n(e.body,t,"Statement")};$.ForInStatement=$.ForOfStatement=function(e,t,n){n(e.left,t,"ForInit"),n(e.right,t,"Expression"),n(e.body,t,"Statement")};$.ForInit=function(e,t,n){e.type==="VariableDeclaration"?n(e,t):n(e,t,"Expression")};$.DebuggerStatement=Xe;$.FunctionDeclaration=function(e,t,n){return n(e,t,"Function")};$.VariableDeclaration=function(e,t,n){for(var r=0,s=e.declarations;r<s.length;r+=1){var a=s[r];n(a,t)}};$.VariableDeclarator=function(e,t,n){n(e.id,t,"Pattern"),e.init&&n(e.init,t,"Expression")};$.Function=function(e,t,n){e.id&&n(e.id,t,"Pattern");for(var r=0,s=e.params;r<s.length;r+=1){var a=s[r];n(a,t,"Pattern")}n(e.body,t,e.expression?"Expression":"Statement")};$.Pattern=function(e,t,n){e.type==="Identifier"?n(e,t,"VariablePattern"):e.type==="MemberExpression"?n(e,t,"MemberPattern"):n(e,t)};$.VariablePattern=Xe;$.MemberPattern=Xn;$.RestElement=function(e,t,n){return n(e.argument,t,"Pattern")};$.ArrayPattern=function(e,t,n){for(var r=0,s=e.elements;r<s.length;r+=1){var a=s[r];a&&n(a,t,"Pattern")}};$.ObjectPattern=function(e,t,n){for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];a.type==="Property"?(a.computed&&n(a.key,t,"Expression"),n(a.value,t,"Pattern")):a.type==="RestElement"&&n(a.argument,t,"Pattern")}};$.Expression=Xn;$.ThisExpression=$.Super=$.MetaProperty=Xe;$.ArrayExpression=function(e,t,n){for(var r=0,s=e.elements;r<s.length;r+=1){var a=s[r];a&&n(a,t,"Expression")}};$.ObjectExpression=function(e,t,n){for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];n(a,t)}};$.FunctionExpression=$.ArrowFunctionExpression=$.FunctionDeclaration;$.SequenceExpression=function(e,t,n){for(var r=0,s=e.expressions;r<s.length;r+=1){var a=s[r];n(a,t,"Expression")}};$.TemplateLiteral=function(e,t,n){for(var r=0,s=e.quasis;r<s.length;r+=1){var a=s[r];n(a,t)}for(var i=0,o=e.expressions;i<o.length;i+=1){var u=o[i];n(u,t,"Expression")}};$.TemplateElement=Xe;$.UnaryExpression=$.UpdateExpression=function(e,t,n){n(e.argument,t,"Expression")};$.BinaryExpression=$.LogicalExpression=function(e,t,n){n(e.left,t,"Expression"),n(e.right,t,"Expression")};$.AssignmentExpression=$.AssignmentPattern=function(e,t,n){n(e.left,t,"Pattern"),n(e.right,t,"Expression")};$.ConditionalExpression=function(e,t,n){n(e.test,t,"Expression"),n(e.consequent,t,"Expression"),n(e.alternate,t,"Expression")};$.NewExpression=$.CallExpression=function(e,t,n){if(n(e.callee,t,"Expression"),e.arguments)for(var r=0,s=e.arguments;r<s.length;r+=1){var a=s[r];n(a,t,"Expression")}};$.MemberExpression=function(e,t,n){n(e.object,t,"Expression"),e.computed&&n(e.property,t,"Expression")};$.ExportNamedDeclaration=$.ExportDefaultDeclaration=function(e,t,n){e.declaration&&n(e.declaration,t,e.type==="ExportNamedDeclaration"||e.declaration.id?"Statement":"Expression"),e.source&&n(e.source,t,"Expression")};$.ExportAllDeclaration=function(e,t,n){e.exported&&n(e.exported,t),n(e.source,t,"Expression")};$.ImportDeclaration=function(e,t,n){for(var r=0,s=e.specifiers;r<s.length;r+=1){var a=s[r];n(a,t)}n(e.source,t,"Expression")};$.ImportExpression=function(e,t,n){n(e.source,t,"Expression")};$.ImportSpecifier=$.ImportDefaultSpecifier=$.ImportNamespaceSpecifier=$.Identifier=$.PrivateIdentifier=$.Literal=Xe;$.TaggedTemplateExpression=function(e,t,n){n(e.tag,t,"Expression"),n(e.quasi,t,"Expression")};$.ClassDeclaration=$.ClassExpression=function(e,t,n){return n(e,t,"Class")};$.Class=function(e,t,n){e.id&&n(e.id,t,"Pattern"),e.superClass&&n(e.superClass,t,"Expression"),n(e.body,t)};$.ClassBody=function(e,t,n){for(var r=0,s=e.body;r<s.length;r+=1){var a=s[r];n(a,t)}};$.MethodDefinition=$.PropertyDefinition=$.Property=function(e,t,n){e.computed&&n(e.key,t,"Expression"),e.value&&n(e.value,t,"Expression")};var oo=new Set(["parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","String","Number","Boolean","Array","Object","Eq","NotEq","Is","IsNot","TypeOf"]),uo=new Set(["Math","JSON","Object","Array","String","Number"]),co=new Set(["Math.random","Date.now"]);function qs(e,t){let n=e[t],r=0;if(n==="*"||n==="+")r=1;else if(n==="{"){let s=e.slice(t).match(/^\{\d+,\}/);s&&(r=s[0].length)}return r===0?0:(e[t+r]==="?"&&r++,r)}function lo(e){let t=[],n=0,r=!1;for(;n<e.length;){let s=e[n];if(s==="\\"){n+=2;continue}if(r){s==="]"&&(r=!1),n++;continue}if(s==="["){r=!0,n++;continue}if(s==="("){t.push({hadUnbounded:!1}),n++;continue}if(s===")"){let i=t.pop()??{hadUnbounded:!1},o=qs(e,n+1);if(o>0){if(i.hadUnbounded)return"an unbounded quantifier is nested inside another (e.g. `(a+)+`)";t.length&&(t[t.length-1].hadUnbounded=!0),n+=1+o;continue}i.hadUnbounded&&t.length&&(t[t.length-1].hadUnbounded=!0),n++;continue}let a=qs(e,n);if(a>0){t.length&&(t[t.length-1].hadUnbounded=!0),n+=a;continue}n++}return null}var fo=new Set(["startsWith","endsWith","includes","indexOf","lastIndexOf","slice","substring","substr","toLowerCase","toUpperCase","trim","trimStart","trimEnd","split","replace","replaceAll","match","matchAll","charAt","charCodeAt","codePointAt","padStart","padEnd","repeat","concat","at","normalize","search","localeCompare","every","some","map","filter","reduce","reduceRight","find","findIndex","findLast","findLastIndex","flat","flatMap","join","keys","entries","values","forEach","test","exec","toFixed","toPrecision","toString","valueOf","hasOwnProperty"]),er=["fetch","XMLHttpRequest","WebSocket","Date","console","setTimeout","setInterval","requestAnimationFrame","queueMicrotask","localStorage","sessionStorage","indexedDB","document","window","globalThis","self","process","require","eval","Function","import","crypto","performance","navigator"];function po(e){let t=new Set(er);for(let[n,r]of Object.entries(e))r?.effects==="io"&&t.add(r.op??n);return t}function et(e,t={}){let n=t.effectful??new Set(er),r;try{r=je(e,{ecmaVersion:"latest",locations:!0})}catch(i){return{safe:!1,predicates:[],diagnostics:[{predicate:"<source>",message:`parse error: ${i.message}`,line:i.loc?.line??0,column:i.loc?.column??0}]}}let s=new Set(t.knownPredicates??[]);for(let i of r.body)i.type==="FunctionDeclaration"&&i.id&&s.add(i.id.name);let a=[];for(let i of r.body){if(i.type!=="FunctionDeclaration"||!i.id)continue;let o=i.id.name,u=(l,p)=>a.push({predicate:o,message:l,line:p?.loc?.start?.line??0,column:p?.loc?.start?.column??0}),c=l=>u("loops are not allowed \u2014 iterate with recursion or array methods (every/some/map/filter/reduce) so work stays fuel-bounded",l);Ee(i,{AwaitExpression(l){u("`await` not allowed \u2014 predicates must be synchronous",l)},NewExpression(l){u("`new` not allowed in a predicate (non-pure construction)",l)},WhileStatement:c,DoWhileStatement:c,ForStatement:c,ForInStatement:c,ForOfStatement:c,Literal(l){if(l.regex&&typeof l.regex.pattern=="string"){let p=lo(l.regex.pattern);p&&u(`regex /${l.regex.pattern}/ risks catastrophic backtracking (ReDoS): ${p}. A single match is not fuel-bounded, so it can't be certified predicate-safe \u2014 simplify the pattern or validate without it.`,l)}},CallExpression(l){let p=l.callee;if(p.type==="Identifier"){let f=p.name;n.has(f)?u(`'${f}' is effectful \u2014 not allowed in a predicate`,p):s.has(f)||oo.has(f)||u(`unknown reference '${f}' \u2014 not a predicate or pure builtin`,p);return}if(p.type==="MemberExpression"&&!p.computed){let f=p.property.name,d=p.object;d.type==="Identifier"&&n.has(d.name)?u(`'${d.name}.${f}' is effectful`,p):d.type==="Identifier"&&uo.has(d.name)?co.has(`${d.name}.${f}`)&&u(`'${d.name}.${f}' is nondeterministic`,p):fo.has(f)||u(`method '.${f}()' is not a known pure method`,p.property);return}u("unsupported call form in a predicate",p)}})}return{safe:a.length===0,predicates:[...s],diagnostics:a}}function fn(e){return e.map(t=>` ${t.predicate} (${t.line}:${t.column}): ${t.message}`).join(`
12
+ `)}var ln=e=>e&&e.type==="Literal"&&typeof e.value=="string";function ho(e,t={}){let n;try{n=je(e,{ecmaVersion:"latest"})}catch{return[]}let r=new Set,s=new Set;Ee(n,{BinaryExpression(u){(u.operator==="=="||u.operator==="===")&&(ln(u.left)&&r.add(u.left.value),ln(u.right)&&r.add(u.right.value))},ArrayExpression(u){for(let c of u.elements)ln(c)&&r.add(c.value)},CallExpression(u){let c=u.callee;if(c.type!=="MemberExpression"||c.computed)return;let l=c.property.name,p=u.arguments[0];ln(p)&&l==="startsWith"&&s.add(p.value)}});let a=null;if(t.validate!==!1){let u=et(e,t);if(u.safe&&u.predicates.length){let c=t.entry??u.predicates[u.predicates.length-1];try{let p=It(e,[c],t)[c];a=f=>{try{return p(f)===!0}catch{return!1}}}catch{a=null}}}let i=[];for(let u of r)(!a||a(u))&&i.push({value:u,kind:"value"});for(let u of s)i.push({value:u,kind:"stub"});let o=i;if(t.prefix){let u=t.prefix;o=i.filter(c=>c.value.startsWith(u)||c.kind==="stub"&&u.startsWith(c.value))}return o.sort((u,c)=>(u.kind===c.kind?0:u.kind==="value"?-1:1)||u.value.localeCompare(c.value)),t.limit?o.slice(0,t.limit):o}var jt=class extends Error{constructor(t){super(`predicate exceeded its fuel budget (${t})`),this.name="PredicateFuelExhausted"}};function Us(e){let t=je(e,{ecmaVersion:"latest"}),n=[],r=a=>n.push([a.body.start+1,"__fuel();"]);Ee(t,{FunctionDeclaration:r,FunctionExpression:r,ArrowFunctionExpression(a){a.body.type==="BlockStatement"?n.push([a.body.start+1,"__fuel();"]):(n.push([a.body.start,"(__fuel(), "]),n.push([a.body.end,")"]))}}),n.sort((a,i)=>i[0]-a[0]);let s=e;for(let[a,i]of n)s=s.slice(0,a)+i+s.slice(a);return s}function It(e,t,n={}){let r=et(e,n);if(!r.safe)throw new Error(`Not predicate-safe:
13
+ ${fn(r.diagnostics)}`);let s=n.fuel??1e6,a=Us(e),i=er.filter(f=>f!=="import"&&f!=="eval"&&f!=="arguments"),o=new Function("__fuel",...i,`"use strict";
14
+ ${a}
15
+ ;return { ${t.join(", ")} };`),u=0,l=o(()=>{if(--u<0)throw new jt(s)},...i.map(()=>{})),p={};for(let f of t){let d=l[f];p[f]=(...m)=>{u=s;try{return d(...m)}catch(y){throw y instanceof RangeError&&/stack/i.test(y.message)?new jt(s):y}}}return p}function tr(e,t,n={}){let r=et(e,n);if(!r.safe)return{safe:!1,diagnostics:r.diagnostics};if(!r.predicates.includes(t))return{safe:!1,diagnostics:[{predicate:t,message:`entry predicate '${t}' not found in the verified cluster`,line:0,column:0}]};let s=n.fuel??1e6;return{safe:!0,code:`(() => {let __f = 0;const __fuel = () => { if (--__f < 0) throw new RangeError('tjs:predicate-fuel'); };${Us(e)}return (...__a) => {__f = ${s};try { return !!${t}(...__a); }catch (e) {if (e instanceof RangeError && /tjs:predicate-fuel|stack/i.test(e.message)) return false;throw e;}};})()`,diagnostics:[]}}function mo(e={}){let{onUnsafe:t,...n}=e,r=new Map,s=new Set;return(a,i)=>{let o=r.get(a);if(o===void 0){try{let u=et(a,n).predicates,c=u[u.length-1];if(!c)throw new Error("$predicate declares no function");o=It(a,[c],n)[c]}catch(u){if(o=null,!s.has(a)){s.add(a);let c=u instanceof Error?u:new Error(String(u));t?t(a,c):console.warn(`[tjs-lang] $predicate not verifiable \u2014 failing closed: ${c.message}`)}}r.set(a,o)}if(o===null)return!1;try{return o(i)===!0}catch{return!1}}}function go(e,t){let n=e.match(t);if(!n)return null;let r=n.index+n[0].length-1,s=1,a=r+1;for(;a<e.length&&s>0;)e[a]==="{"?s++:e[a]==="}"&&s--,a++;if(s!==0)return null;let i=e.slice(r,a),o=[n[0].slice(0,-1)+i,i];return o.index=n.index,o}function nr(e,t,n,r,s,a){let i=`__pred_${e}`,o=`function ${i}(${n}) { ${r} }`,u=tr(o,i,s?{knownPredicates:new Set(s)}:{});return u.safe?(a?.push({name:e,kind:t,verified:!0}),u.code):(a?.push({name:e,kind:t,verified:!1,reason:fn(u.diagnostics).replace(/__pred_/g,"")}),null)}function Hs(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\btry\s*\{/);if(r){let a=n+r[0].length-1+1,i=1,o=a;for(;o<e.length&&i>0;){let c=e[o];c==="{"?i++:c==="}"&&i--,o++}if(i!==0){t+=e[n],n++;continue}if(e.slice(o).match(/^\s*(catch|finally)\b/))t+=e.slice(n,o),n=o;else{let c=e.slice(a,o-1);t+=`try {${c}} catch (__try_err) { return new (__tjs?.MonadicError ?? Error)(__try_err?.message || String(__try_err), 'try', undefined, undefined, __tjs?.getStack?.()) }`,n=o}}else t+=e[n],n++}return t}function Ks(e){let t=[],n="",r=0,s=0;for(;r<e.length;){let a=e.slice(r).match(/^\bwasm\s*\{/);if(a){let i=r,o=r+a[0].length,u=1,c=o;for(;c<e.length&&u>0;){let w=e[c];w==="{"?u++:w==="}"&&u--,c++}if(u!==0){n+=e[r],r++;continue}let l=e.slice(o,c-1),p,f=c,d=e.slice(c).match(/^\s*fallback\s*\{/);if(d){let w=c+d[0].length;u=1;let k=w;for(;k<e.length&&u>0;){let T=e[k];T==="{"?u++:T==="}"&&u--,k++}u===0&&(p=e.slice(w,k-1),f=k)}let y=xo(l).map(w=>{let k=_o(e,i,w);return k?`${w}: ${k}`:w}),x={id:`__tjs_wasm_${s}`,body:l,fallback:p,captures:y,start:i,end:f};t.push(x);let S=p??l,E=y.map(w=>w.split(":")[0].trim()),_=E.length>0?E.join(", "):"",b=E.length>0?`globalThis.${x.id}(${_})`:`globalThis.${x.id}()`,v=`(globalThis.${x.id} ? ${b} : (() => {${S}})())`;n+=v,r=f,s++}else n+=e[r],r++}return{source:n,blocks:t}}function Zs(e){let t=[],n="",r=0;for(;r<e.length;){let s=/^\b(export\s+)?wasm\s+function\s+(\w+)\s*\(/,a=e.slice(r).match(s);if(!a){n+=e[r],r++;continue}let i=!!a[1],o=a[2],u=r,c=r+a[0].length,l=1,p=c;for(;p<e.length&&l>0;)e[p]==="("?l++:e[p]===")"&&l--,p++;if(l!==0){n+=e[r],r++;continue}let f=e.slice(c,p-1);if(f.match(/^\s*!/))throw new te(`Unsafe wasm functions (with \`!\` marker) are reserved for a future phase. Remove the bang from \`wasm function ${o}\` to declare it as a regular (pure) wasm function, or wait until the unsafe variant is implemented.`,Le(e,u));let m,y=p,x=e.slice(p).match(/^\s*:\s*(\w+)/);x&&(m=x[1],y=p+x[0].length);let S=e.slice(y).match(/^\s*\{/);if(!S){n+=e[r],r++;continue}let E=y+S[0].length,_=1,b=E;for(;b<e.length&&_>0;)e[b]==="{"?_++:e[b]==="}"&&_--,b++;if(_!==0){n+=e[r],r++;continue}let v=e.slice(E,b-1),w=yo(f),k=`__tjs_wasm_${o}`,T={id:k,name:o,returnType:m,body:v,captures:w,start:u,end:b};t.push(T);let C=w.map(D=>D.split(":")[0].trim()),P=`${i?"export ":""}function ${o}(${C.join(", ")}) { return globalThis.${k}(${C.join(", ")}) }`;n+=P,r=b}return{source:n,blocks:t}}function Qs(e,t){let{loader:n,importerPath:r}=t;if(!n)return{source:e,blocks:[]};let s=[],a=new Set;function i(c,l){if(!a.has(c.id)){s.push(c),a.add(c.id);for(let[p,f]of l){if(p===c.name||a.has(f.id))continue;new RegExp(`\\b${p}\\s*\\(`).test(c.body)&&i(f,l)}}}let o=/^(\s*)import\s*\{([^}]*?)\}\s*from\s*(['"])([^'"]+)\3\s*;?\s*$/gm;return{source:e.replace(o,(c,l,p,f,d)=>{let m=n.load(d,r);if(!m)return c;let y=new Map;for(let v of m.parseResult.wasmBlocks)v.name&&y.set(v.name,v);if(y.size===0)return c;let x=p.split(",").map(v=>v.trim()).filter(v=>v.length>0),S=[],E=[];for(let v of x){let w=v.match(/^(\w+)(?:\s+as\s+(\w+))?$/);if(!w){E.push(v);continue}let k=w[1],T=w[2]??w[1],C=y.get(k);if(!C){E.push(v);continue}i(C,y);let N=C.captures.map(P=>P.split(":")[0].trim());S.push(`function ${T}(${N.join(", ")}) { return globalThis.${C.id}(${N.join(", ")}) }`)}let _=S.join(`
16
+ `);if(E.length===0)return _?`${l}${_}`:`${l}`;let b=`${l}import { ${E.join(", ")} } from '${d}'`;return _?`${b}
17
+ ${l}${_}`:b}),blocks:s}}function yo(e){let t=e.trim();return t?t.split(",").map(n=>n.trim()).filter(n=>n.length>0):[]}function bo(e){return e.startsWith("f32x4_")||e.startsWith("v128_")}function xo(e){let t=e.replace(/\/\/[^\n]*/g,"").replace(/\/\*[\s\S]*?\*\//g,""),n=new Set,r=/\.([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,s;for(;(s=r.exec(t))!==null;)n.add(s[1]);let a=/(?<!\.)(\b[a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,i=new Set;for(;(s=a.exec(t))!==null;)i.add(s[1]);for(let f of n){if(!i.has(f))continue;let d=new RegExp(`(?<!\\.)\\b${f}\\b`,"g"),m=new RegExp(`\\.${f}\\b`,"g"),y=t.match(d)?.length||0,x=t.match(m)?.length||0;y<=x&&i.delete(f)}let o=new Set,u=/\b(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;for(;(s=u.exec(t))!==null;)o.add(s[1]);let c=/\bfor\s*\(\s*(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;for(;(s=c.exec(t))!==null;)o.add(s[1]);let l=new Set(["if","else","for","while","do","switch","case","break","continue","return","function","let","const","var","new","this","true","false","null","undefined","typeof","instanceof","in","of","try","catch","finally","throw","async","await","class","extends","super","import","export","default","from","as","static","get","set","yield","console","Math","Array","Object","String","Number","Boolean","Date","JSON","Promise","Map","Set","WeakMap","WeakSet","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","ArrayBuffer","DataView","Error","TypeError","RangeError","length","push","pop","shift","unshift","slice","splice","map","filter","reduce","forEach","find","findIndex","indexOf","includes","globalThis","window","document","Infinity","NaN","isNaN","isFinite","parseInt","parseFloat","encodeURI","decodeURI","eval","wasmBuffer"]),p=[];for(let f of i)!o.has(f)&&!l.has(f)&&!bo(f)&&p.push(f);return p.sort()}function _o(e,t,n){let r=e.slice(0,t),s=/function\s+\w+\s*\(([^)]*)\)\s*(?:->.*?)?\s*\{[^}]*$/,a=r.match(s);if(!a){let i=/(?:const|let|var)?\s*\w+\s*=\s*(?:async\s*)?\(([^)]*)\)\s*(?:=>|->)?\s*\{[^}]*$/,o=r.match(i);return o?Ws(o[1],n):void 0}return Ws(a[1],n)}function Ws(e,t){let n=e.split(",").map(r=>r.trim());for(let r of n){let s=r.match(new RegExp(`^${t}\\s*:\\s*([A-Za-z][A-Za-z0-9]*)`));if(s)return s[1];let a=r.match(new RegExp(`^${t}\\s*=\\s*(Float32Array|Float64Array|Int32Array|Uint8Array|Int8Array|Int16Array|Uint16Array|Uint32Array)`));if(a)return a[1]}}function Rt(e){let t=`([\\w][\\w.\\[\\]()]*|null|undefined|true|false|\\d+(?:\\.\\d+)?|'[^']*'|"[^"]*")`,n=new RegExp(t+"\\s+IsNot\\s+"+t,"g");e=e.replace(n,"IsNot($1, $2)");let r=new RegExp(t+"\\s+Is\\s+"+t,"g");return e=e.replace(r,"Is($1, $2)"),e}function Ys(e){let t=/^[\s]*[([`]/,n=/[{([,;:+\-*/%=&|?<>!~^]\s*$|^\s*$/,r=/\b(return|throw|yield|await|case|default|extends|new|typeof|void|delete|in|of|instanceof)\s*$/,s=e.split(`
18
+ `),a=[],i=!1;for(let o=0;o<s.length;o++){let u=s[o],c=o>0?s[o-1]:"";if(i){a.push(u),u.includes("*/")&&(i=!1);continue}let l=u.indexOf("/*"),p=u.indexOf("*/");if(l!==-1&&(p===-1||p<l)){i=!0,a.push(u);continue}if(o>0&&t.test(u)){let f=c.replace(/\/\/.*$/,"").replace(/\/\*.*\*\/\s*$/,"");if(!n.test(f)&&!r.test(f)){let d=u.match(/^(\s*)/),m=d?d[1]:"",y=u.slice(m.length);a.push(m+";"+y);continue}}a.push(u)}return a.join(`
19
+ `)}function wo(e){let t=[],n=0,r="normal",s=[];for(;n<e.length;){let i=e[n],o=e[n+1];switch(r){case"single-string":if(i==="\\"&&n+1<e.length){n+=2;continue}i==="'"&&(r="normal"),n++;continue;case"double-string":if(i==="\\"&&n+1<e.length){n+=2;continue}i==='"'&&(r="normal"),n++;continue;case"template-string":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="$"&&o==="{"){n+=2,s.push(1),r="normal";continue}i==="`"&&(r="normal"),n++;continue;case"line-comment":i===`
20
+ `&&(r="normal"),n++;continue;case"block-comment":if(i==="*"&&o==="/"){n+=2,r="normal";continue}n++;continue;case"regex":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="["){for(n++;n<e.length&&e[n]!=="]";)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++;continue}if(i==="/"){for(n++;n<e.length&&/[gimsuy]/.test(e[n]);)n++;r="normal";continue}n++;continue;case"normal":if(s.length>0){if(i==="{")s[s.length-1]++;else if(i==="}"&&(s[s.length-1]--,s[s.length-1]===0)){s.pop(),n++,r="template-string";continue}}if(i==="'"){n++,r="single-string";continue}if(i==='"'){n++,r="double-string";continue}if(i==="`"){n++,r="template-string";continue}if(i==="/"&&o==="/"){n+=2,r="line-comment";continue}if(i==="/"&&o==="*"){n+=2,r="block-comment";continue}if(i==="/"){let u=n-1;for(;u>=0&&/\s/.test(e[u]);)u--;let c=u>=0?e[u]:"";if(!c||/[=(!,;:{[&|?+\-*%<>~^]/.test(c)||u>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,u-10),u+1))){n++,r="regex";continue}}if(i==="t"&&e.slice(n,n+6)==="typeof"&&(n===0||!/[\w$]/.test(e[n-1]))&&/\s/.test(e[n+6]??"")){let u=n+6;for(;u<e.length&&/\s/.test(e[u]);)u++;if(u<e.length&&/[a-zA-Z_$]/.test(e[u])){let c=u;for(;u<e.length&&/[\w$]/.test(e[u]);)u++;for(;u<e.length;)if(e[u]==="."&&/[a-zA-Z_$]/.test(e[u+1]??""))for(u++;u<e.length&&/[\w$]/.test(e[u]);)u++;else if(e[u]==="?"&&e[u+1]==="."&&/[a-zA-Z_$]/.test(e[u+2]??""))for(u+=2;u<e.length&&/[\w$]/.test(e[u]);)u++;else break;t.push({keywordStart:n,operandEnd:u,operand:e.slice(c,u)}),n=u;continue}}break}n++}if(t.length===0)return e;let a=e;for(let i=t.length-1;i>=0;i--){let o=t[i];a=a.slice(0,o.keywordStart)+`TypeOf(${o.operand})`+a.slice(o.operandEnd)}return a}function Mt(e){e=wo(e);let t=[],n=0,r="normal",s=[];for(;n<e.length;){let i=e[n],o=e[n+1];switch(r){case"single-string":if(i==="\\"&&n+1<e.length){n+=2;continue}i==="'"&&(r="normal"),n++;continue;case"double-string":if(i==="\\"&&n+1<e.length){n+=2;continue}i==='"'&&(r="normal"),n++;continue;case"template-string":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="$"&&o==="{"){n+=2,s.push(1),r="normal";continue}i==="`"&&(r="normal"),n++;continue;case"line-comment":i===`
21
+ `&&(r="normal"),n++;continue;case"block-comment":if(i==="*"&&o==="/"){n+=2,r="normal";continue}n++;continue;case"regex":if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="["){for(n++;n<e.length&&e[n]!=="]";)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++;continue}if(i==="/"){for(n++;n<e.length&&/[gimsuy]/.test(e[n]);)n++;r="normal";continue}n++;continue;case"normal":if(s.length>0){if(i==="{")s[s.length-1]++;else if(i==="}"&&(s[s.length-1]--,s[s.length-1]===0)){s.pop(),n++,r="template-string";continue}}if(i==="'"){n++,r="single-string";continue}if(i==='"'){n++,r="double-string";continue}if(i==="`"){n++,r="template-string";continue}if(i==="/"&&o==="/"){n+=2,r="line-comment";continue}if(i==="/"&&o==="*"){n+=2,r="block-comment";continue}if(i==="/"){let u=n-1;for(;u>=0&&/\s/.test(e[u]);)u--;let c=u>=0?e[u]:"";if(!c||/[=(!,;:{[&|?+\-*%<>~^]/.test(c)||u>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,u-10),u+1))){n++,r="regex";continue}}if(i==="="&&o==="="&&e[n+2]!=="="&&e[n-1]!=="!"){t.push({pos:n,op:"=="}),n+=2;continue}if(i==="!"&&o==="="&&e[n+2]!=="="){t.push({pos:n,op:"!="}),n+=2;continue}break}n++}if(t.length===0)return e;let a=e;for(let i=t.length-1;i>=0;i--){let{pos:o,op:u}=t[i],c=u==="=="?"Eq":"NotEq",l=So(a,o),p=vo(a,o+2),f=a.slice(l,o).trim(),d=a.slice(o+2,p).trim();if(f&&d){let m=a.slice(0,l),y=a.slice(p),S=/[a-zA-Z0-9_$]$/.test(m)?" ":"";a=`${m}${S}${c}(${f}, ${d})${y}`}}return a}function So(e,t){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n--;if(n<0)return 0;let r=0,s=!1,a="";for(;n>=0;){let i=e[n],o=n>0?e[n-1]:"";if(s){i===a&&o!=="\\"&&(s=!1),n--;continue}if((i==='"'||i==="'"||i==="`")&&o!=="\\"){s=!0,a=i,n--;continue}if(i===")"||i==="]"||i==="}"){r++,n--;continue}if(i==="("||i==="["){if(r>0){r--,n--;continue}return n+1}if(i==="{"){if(r>0){r--,n--;continue}return n+1}if(r>0){n--;continue}if(i===";")return n+1;if(/[a-z]/.test(i)){let u=n+1,c=n;for(;c>0&&/[a-z]/i.test(e[c-1]);)c--;let l=e.slice(c,u),p=c>0?e[c-1]:"";if(!/[a-zA-Z0-9_$]/.test(p)){if(["return","throw","case","typeof","void","delete","await","yield"].includes(l))return u;if(l==="new")return c}}if(i===">"&&o==="="||i==="="&&o!=="="&&o!=="!"&&o!=="<"&&o!==">"||i==="&"&&o==="&"||i==="|"&&o==="|"||i==="?"||i===":"||i===",")return n+1;n--}return 0}function vo(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)return e.length;let r=0,s=!1,a="";for(;n<e.length;){let i=e[n],o=n+1<e.length?e[n+1]:"";if(s){i===a&&e[n-1]!=="\\"&&(s=!1),n++;continue}if((i==='"'||i==="'"||i==="`")&&e[n-1]!=="\\"){s=!0,a=i,n++;continue}if(i==="("||i==="["||i==="{"){r++,n++;continue}if(i===")"||i==="]"||i==="}"){if(r>0){r--,n++;continue}return n}if(r>0){n++;continue}if(i===";"||i==="&"&&o==="&"||i==="|"&&o==="|"||i==="?"||i===":"||i===","||(i==="="||i==="!")&&o==="="&&e[n+2]!=="=")return n;n++}return e.length}function Xs(e,t){let n="",r=0;for(;r<e.length;){let s=e.slice(r).match(/^\bType\s+([A-Z_][a-zA-Z0-9_]*)\s*/);if(s){let a=s[1],i=r+s[0].length,o=a,u=!1,c=e.slice(i).match(/^(['"`])([^]*?)\1\s*/);if(c){let d=i+c[0].length,m=e[d],y=m===void 0||d>=e.length||m!=="="&&m!=="{";if(m==="="||m==="{")o=c[2],u=!0,i=d;else if(y){let x=c[0].trim(),S=c[0].slice(x.length);n+=`const ${a} = Type('${a}', ${x})${S}`,r=d;continue}}let l,p=i,f=e.slice(i).match(/^=\s*/);if(f){i+=f[0].length;let d=e.slice(i).match(/^(\+?\d+(?:\.\d+)?|['"`][^'"`]*['"`]|\{[^}]*\}|\[[^\]]*\]|true|false|null)/);if(d){l=d[0],i+=d[0].length,p=i;let m=e.slice(i).match(/^\s*/);m&&(i+=m[0].length)}}if(e[i]==="{"){let d=i+1,m=1,y=d;for(;y<e.length&&m>0;){let w=e[y];w==="{"?m++:w==="}"&&m--,y++}if(m!==0){n+=e[r],r++;continue}let x=e.slice(d,y-1).trim(),S=y,E=x.match(/description\s*:\s*(['"`])([^]*?)\1/);E&&!u&&(o=E[2]);let _,b=x.match(/example\s*:\s*/);if(b){let w=b.index+b[0].length,k=yi(x,w);k&&(_=k.value.trim())}let v=x.match(/predicate\s*\(([^)]*)\)\s*\{([^]*)\}/);if(v&&_){let w=v[1].trim(),k=v[2].trim(),T=l?`, ${l}`:"",C=`globalThis.__tjs?.validate(${w}, globalThis.__tjs?.infer(${_}))`,N=nr(a,"Type",w,k,void 0,t),P=N?`(__g => (${w}) => (${C} ? __g(${w}) : false))(${N})`:`(${w}) => { if (!${C}) return false; ${k} }`;n+=`const ${a} = Type('${o}', ${P}, ${_}${T})`}else if(v){let w=v[1].trim(),k=v[2].trim(),T=l?`, undefined, ${l}`:"",N=nr(a,"Type",w,k,void 0,t)??`(${w}) => { ${k} }`;n+=`const ${a} = Type('${o}', ${N}${T})`}else if(_){let w=l?`, ${l}`:"";n+=`const ${a} = Type('${o}', undefined, ${_}${w})`}else l?n+=`const ${a} = Type('${o}', ${l})`:n+=`const ${a} = Type('${o}')`;r=S;continue}else if(l){n+=`const ${a} = Type('${o}', ${l})`,r=p;continue}else if(!c){let d=e.slice(i).match(/^(['"`][^]*?['"`]|\+?\d+(?:\.\d+)?|true|false|null|\{[^]*?\}|\[[^]*?\])/);if(d){let m=d[0];n+=`const ${a} = Type('${a}', ${m})`,r=i+d[0].length;continue}}}n+=e[r],r++}return n}function ei(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bFunctionPredicate\s+([A-Z_][a-zA-Z0-9_]*)\s*(?:<([^>]+)>)?\s*/);if(r){let s=r[1],a=r[2],i=n+r[0].length;if(e[i]==="{"){let o=1,u=i+1;for(;u<e.length&&o>0;)e[u]==="{"?o++:e[u]==="}"&&o--,u++;if(o===0){let c=e.slice(i+1,u-1).trim(),l=go(c,/params\s*:\s*\{/),p=c.match(/returns\s*:\s*(.+?)(?:\n|$)/),f=c.match(/returnContract\s*:\s*['"](\w+)['"]/),d=c.match(/description\s*:\s*(['"])([^]*?)\1/),m=[];l&&m.push(`params: ${l[1]}`),p&&m.push(`returns: ${p[1].trim()}`),f&&m.push(`returnContract: '${f[1]}'`);let y=d?d[2]:s;if(a){let x=a.split(",").map(E=>{let _=E.trim().split("=").map(b=>b.trim());if(_.length===2){let b=_[1]==="any"||_[1]==="undefined"?"null":_[1];return`['${_[0]}', ${b}]`}return`'${_[0]}'`}),S=a.split(",").map(E=>E.trim().split("=")[0].trim());t+=`const ${s} = FunctionPredicate('${y}', [${x.join(", ")}], (${S.join(", ")}) => ({ ${m.join(", ")} }))`}else t+=`const ${s} = FunctionPredicate('${y}', { ${m.join(", ")} })`;n=u;continue}}if(e[i]==="("){let o=1,u=i+1;for(;u<e.length&&o>0;)e[u]==="("?o++:e[u]===")"&&o--,u++;if(o===0){let c=e.slice(i+1,u-1).trim(),l=c.indexOf(",");if(l!==-1){let p=c.slice(0,l).trim(),f=c.slice(l+1).trim();t+=`const ${s} = FunctionPredicate(${f}, ${p})`}else t+=`const ${s} = FunctionPredicate('${s}', ${c})`;n=u;continue}}}t+=e[n],n++}return t}function ti(e,t){let n="",r=0;for(;r<e.length;){let s=e.slice(r).match(/^\bGeneric\s+([A-Z][a-zA-Z0-9_]*)\s*<([^>]+)>\s*\{/);if(s){let a=s[1],i=s[2],u=r+s[0].length-1+1,c=1,l=u;for(;l<e.length&&c>0;){let _=e[l];_==="{"?c++:_==="}"&&c--,l++}if(c!==0){n+=e[r],r++;continue}let p=e.slice(u,l-1).trim(),f=l,d=i.split(",").map(_=>{let b=_.trim().split("=").map(v=>v.trim());if(b.length===2){let v=b[1]==="any"||b[1]==="undefined"?"null":b[1];return`['${b[0]}', ${v}]`}return`'${b[0]}'`}),m=p,y=m.search(/\bdeclaration\s*\{/);if(y!==-1){let _=m.indexOf("{",y),b=1,v=_+1;for(;v<m.length&&b>0;)m[v]==="{"?b++:m[v]==="}"&&b--,v++;m=m.slice(0,y)+m.slice(v)}let x=m.match(/description\s*:\s*(['"`])([^]*?)\1/),S=m.match(/predicate\s*\(([^)]*)\)\s*\{([^]*)\}/),E=x?x[2]:a;if(S){let _=S[1].trim().split(",").map(P=>P.trim()),b=S[2].trim(),v=_[0]||"x",w=_.slice(1),k=w.map(P=>`check${P}`);w.forEach((P,D)=>{b=b.replace(new RegExp(`\\b${P}\\s*\\(`,"g"),`${k[D]}(`)});let T=[v,...k].join(", "),N=nr(a,"Generic",T,b,k,t)??`(${T}) => { ${b} }`;n+=`const ${a} = Generic([${d.join(", ")}], ${N}, '${E}')`}else n+=`const ${a} = Generic([${d.join(", ")}], () => true, '${E}')`;r=f;continue}n+=e[r],r++}return n}function ni(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bUnion\s+([A-Z][a-zA-Z0-9_]*)\s+(['"`])([^]*?)\2\s*/);if(r){let s=r[1],a=r[3],i=n+r[0].length;if(e[i]==="{"){let o=i+1,u=1,c=o;for(;c<e.length&&u>0;){let d=e[c];d==="{"?u++:d==="}"&&u--,c++}if(u!==0){t+=e[n],n++;continue}let l=e.slice(o,c-1).trim(),p=c,f=Js(l);t+=`const ${s} = Union('${a}', [${f.join(", ")}])`,n=p;continue}else{let o=e.indexOf(`
22
+ `,i);o===-1&&(o=e.length);let u=e.slice(i,o).trim();if(u){let c=Js(u);t+=`const ${s} = Union('${a}', [${c.join(", ")}])`,n=o;continue}}}t+=e[n],n++}return t}function Js(e){let t=[],n=e.split("|").map(r=>r.trim());for(let r of n)r&&t.push(r);return t}function ri(e){let t="",n=0;for(;n<e.length;){let r=e.slice(n).match(/^\bEnum\s+([A-Z][a-zA-Z0-9_]*)\s+(['"`])([^]*?)\2\s*\{/);if(r){let s=r[1],a=r[3],o=n+r[0].length-1+1,u=1,c=o;for(;c<e.length&&u>0;){let m=e[c];m==="{"?u++:m==="}"&&u--,c++}if(u!==0){t+=e[n],n++;continue}let l=e.slice(o,c-1).trim(),p=c,d=ko(l).map(([m,y])=>`${m}: ${y}`).join(", ");t+=`const ${s} = Enum('${a}', { ${d} })`,n=p;continue}t+=e[n],n++}return t}function ko(e){let t=[],n=0,r=e.split(/[\n,]/).map(s=>s.trim()).filter(s=>s&&!s.startsWith("//"));for(let s of r){let a=s.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(?:=\s*(.+))?$/);if(a){let i=a[1],o=a[2]?.trim();if(o!==void 0){t.push([i,o]);let u=Number(o);isNaN(u)||(n=u+1)}else t.push([i,String(n)]),n++}}return t}function si(e){let t=new Map,n="",r=0;for(;r<e.length;){let s=e.slice(r),a=s.match(/^(\s*)extend\s+([A-Z]\w*)\s*\{/);if(!a){if(r===0||e[r-1]===`
23
+ `||e[r-1]===";"||e[r-1]==="}"){let _=s.match(/^(\s*)extend\s+([A-Z]\w*)\s*\{/)}n+=e[r],r++;continue}let i=a[1],o=a[2],u=r+a[0].length-1,c=Nt(e,u),l=e.slice(u+1,c-1).trim(),p=[],f=0,d=e.slice(u+1,c-1);for(;f<d.length;){let _=d.slice(f).match(/^(\s*)(async\s+)?(\w+)\s*\(/);if(!_){f++;continue}let b=_[1],v=!!_[2],w=_[3],k=f+_[0].length-1,T=1,C=k+1;for(;C<d.length&&T>0;)d[C]==="("&&T++,d[C]===")"&&T--,C++;let N=d.slice(k+1,C-1),P=C;for(;P<d.length&&/\s/.test(d[P]);)P++;if(d[P]==="="&&d[P+1]===">"){let ee=Le(e,u+1+f);throw new te(`Arrow functions are not allowed in extend blocks (method '${w}' in extend ${o}). Use regular function syntax instead, as extension methods need 'this' binding.`,ee)}if(d[P]!=="{"){f++;continue}let D=Nt(d,P),R=d.slice(f,D).trim(),U=N.split(",").map(ee=>ee.trim()).filter(ee=>ee.length>0).map(ee=>{let ce=ee.match(/^(\w+)\s*:\s*(.+)$/);return ce?`${ce[1]} = ${ce[2]}`:ee}).join(", "),J=v?"async ":"",X=d.slice(P+1,D-1);p.push({name:w,isAsync:v,fullText:`${w}: ${J}function(${U}) {${X}}`}),f=D}let m=!t.has(o);m&&t.set(o,new Set);let y=t.get(o);for(let E of p)y.add(E.name);let x=p.map(E=>` ${E.fullText}`).join(`,
24
+ `),S;m?S=`${i}const __ext_${o} = {
25
+ ${x}
22
26
  ${i}}
23
- `:k=`${i}Object.assign(__ext_${o}, {
24
- ${w}
27
+ `:S=`${i}Object.assign(__ext_${o}, {
28
+ ${x}
25
29
  ${i}})
26
- `;for(let S of p)k+=`${i}if (__tjs?.registerExtension) { __tjs.registerExtension('${o}', '${S.name}', __ext_${o}.${S.name}) }
27
- `;n+=k,r=c}return r<=e.length&&n.length<e.length,{source:n,extensions:t}}function jt(e,t){if(t.size===0)return e;let n=new Map;for(let[s,a]of t)for(let i of a)n.has(i)||n.set(i,[]),n.get(i).push(s);let r=e;for(let[s,a]of n){if(!a.includes("String"))continue;let i=new RegExp(`('(?:[^'\\\\]|\\\\.)*')\\.(${s})\\((\\))?`,"g");r=r.replace(i,(c,l,p,f)=>f?`__ext_String.${p}.call(${l})`:`__ext_String.${p}.call(${l}, `);let o=new RegExp(`("(?:[^"\\\\]|\\\\.)*")\\.(${s})\\((\\))?`,"g");r=r.replace(o,(c,l,p,f)=>f?`__ext_String.${p}.call(${l})`:`__ext_String.${p}.call(${l}, `);let u=new RegExp("(`(?:[^`\\\\]|\\\\.)*`)\\."+s+"\\((\\))?","g");r=r.replace(u,(c,l,p)=>p?`__ext_String.${s}.call(${l})`:`__ext_String.${s}.call(${l}, `)}for(let[s,a]of n){if(!a.includes("Array"))continue;let i=`].${s}(`,o=0,u;for(;(u=r.indexOf(i,o))!==-1;){let c=1,l=u-1,p=!1;for(;l>=0&&c>0;){let f=r[l];p?f===p&&(l===0||r[l-1]!=="\\")&&(p=!1):(f==="]"&&c++,f==="["&&c--,(f==="'"||f==='"'||f==="`")&&(p=f)),l--}if(c===0){let f=r.slice(l+1,u+1),d=r.slice(0,l+1),g=r.slice(u+i.length);g[0]===")"?r=`${d}__ext_Array.${s}.call(${f})${g.slice(1)}`:r=`${d}__ext_Array.${s}.call(${f}, ${g}`}o=u+1}}for(let[s,a]of n){if(!a.includes("Number"))continue;let i=new RegExp(`(\\d+(?:\\.\\d+)?)\\.(${s})\\((\\))?`,"g");r=r.replace(i,(o,u,c,l)=>l?`__ext_Number.${c}.call(${u})`:`__ext_Number.${c}.call(${u}, `)}return r}function Le(e,t){let n=1,r=0;for(let s=0;s<t&&s<e.length;s++)e[s]===`
28
- `?(n++,r=0):r++;return{line:n,column:r}}function Hs(e,t){let n=t.trim();return/^['"`]/.test(n)?`typeof ${e} === 'string'`:n==="true"||n==="false"?`typeof ${e} === 'boolean'`:n==="null"?`${e} === null`:n==="undefined"?`${e} === undefined`:n.startsWith("[")?`Array.isArray(${e})`:n.startsWith("{")?`(typeof ${e} === 'object' && ${e} !== null && !Array.isArray(${e}))`:/^\+\d+/.test(n)?`(typeof ${e} === 'number' && Number.isInteger(${e}) && ${e} >= 0)`:/^-?\d+\.\d+/.test(n)?`typeof ${e} === 'number'`:/^-?\d+$/.test(n)?`(typeof ${e} === 'number' && Number.isInteger(${e}))`:"true"}function on(e){let t=e.trim();return/^['"`]/.test(t)?"string":t==="true"||t==="false"?"boolean":t==="null"?"null":t==="undefined"?"undefined":t.startsWith("[")?"array":t.startsWith("{")?"object":/^\+\d+/.test(t)?"non-negative-integer":/^-?\d+\.\d+/.test(t)?"number":/^-?\d+$/.test(t)?"integer":"any"}function Hn(e,t){let n=[],r=0,s="",a=!1;for(let o=0;o<e.length;o++){let u=e[o];if(!a&&(u==="'"||u==='"'||u==="`")){a=u,s+=u;continue}if(a){if(s+=u,u==="\\"){o++,o<e.length&&(s+=e[o]);continue}u===a&&(a=!1);continue}if(u==="("||u==="["||u==="{"){r++,s+=u;continue}if(u===")"||u==="]"||u==="}"){r--,s+=u;continue}if(u===","&&r===0){let c=Ms(s.trim(),t);c&&n.push(c),s="";continue}s+=u}let i=s.trim();if(i){let o=Ms(i,t);o&&n.push(o)}return n}function Ms(e,t){let n=e.replace(/^\/\*\s*unsafe\s*\*\/\s*/,"");if(n.startsWith("..."))return null;let r=n.indexOf("=");if(r===-1)return{name:n.trim(),defaultValue:"",required:!0};let s=n.slice(0,r).trim(),a=n.slice(r+1).trim();return{name:s,defaultValue:a,required:t.has(s)}}function Ct(e,t){let n=1,r=t+1,s=!1,a=!1,i=!1;for(;r<e.length&&n>0;){let o=e[r],u=r+1<e.length?e[r+1]:"";if(a){o===`
29
- `&&(a=!1),r++;continue}if(i){if(o==="*"&&u==="/"){i=!1,r+=2;continue}r++;continue}if(s){if(o==="\\"){r+=2;continue}o===s&&(s=!1),r++;continue}if(o==="/"&&u==="/"){a=!0,r+=2;continue}if(o==="/"&&u==="*"){i=!0,r+=2;continue}if(o==="'"||o==='"'||o==="`"){s=o,r++;continue}o==="{"&&n++,o==="}"&&n--,r++}return r}function Ks(e,t){let n=new Set,r=/(?:^|(?<=[\n;{}]))\s*(export\s+)?(async\s+)?function\s+(\w+)\s*\(/gm,s=new Map,a,i=[];for(;(a=r.exec(e))!==null;){let p=!!a[1],f=!!a[2],d=a[3],g=a.index,y=g,k=a[0].indexOf("function");k>=0&&(y=g+k),i.push({name:d,fullMatchStart:g,funcKeywordStart:y,exported:p,isAsync:f})}for(let p of i)s.has(p.name)||s.set(p.name,[]);let o=new Map;for(let p of i)o.set(p.name,(o.get(p.name)||0)+1);let u=new Set;for(let[p,f]of o)f>1&&u.add(p);if(u.size===0)return{source:e,polymorphicNames:n};for(let p of i){if(!u.has(p.name))continue;let f=e.indexOf("(",p.funcKeywordStart);if(f===-1)continue;let d=1,g=f+1;for(;g<e.length&&d>0;)e[g]==="("&&d++,e[g]===")"&&d--,g++;let y=g-1,w=e.slice(f+1,y),k=g;for(;k<e.length&&e[k]!=="{";)k++;if(k>=e.length)continue;let S=Ct(e,k),b=p.fullMatchStart;for(;b>0&&e[b-1]===" ";)b--;let _=s.get(p.name),v=Hn(w,t);if(w.includes("...")){let E=Le(e,p.funcKeywordStart);throw new te(`Rest parameters are not supported in polymorphic function '${p.name}'. Use separate function names instead.`,E)}_.push({index:_.length+1,start:b,end:S,text:e.slice(b,S),exported:p.exported,isAsync:p.isAsync,params:v})}for(let[p,f]of s){if(f.length<2)continue;let d=f.filter(g=>g.isAsync).length;if(d>0&&d<f.length){let g=Le(e,f[0].start);throw new te(`Polymorphic function '${p}': all variants must be either sync or async, not mixed.`,g)}for(let g=0;g<f.length;g++)for(let y=g+1;y<f.length;y++){let w=f[g],k=f[y];if(w.params.length!==k.params.length)continue;let S=!0;for(let b=0;b<w.params.length;b++){let _=w.params[b].defaultValue?on(w.params[b].defaultValue):"any",v=k.params[b].defaultValue?on(k.params[b].defaultValue):"any";if(_!==v){S=!1;break}}if(S){let b=Le(e,k.start);throw new te(`Polymorphic function '${p}': variants ${g+1} and ${y+1} have ambiguous signatures (same parameter types at every position). Overloads must differ by arity or parameter types.`,b)}}}let c=[];for(let[p,f]of s)if(!(f.length<2))for(let d of f)c.push({name:p,variant:d});c.sort((p,f)=>f.variant.start-p.variant.start);let l=e;for(let{name:p,variant:f}of c){let d=f.isAsync?"async ":"",g=f.text.replace(new RegExp(`(?:export\\s+)?${d?d.replace(/\s+$/,"\\s+"):""}function\\s+${p}\\s*\\(`),`${d}function ${p}$$${f.index}(`);l=l.slice(0,f.start)+g+l.slice(f.end)}for(let[p,f]of s){if(f.length<2)continue;n.add(p);let d=f[0].isAsync,g=f.some(_=>_.exported),y=d?"async ":"",w=g?"export ":"",k=[...f].sort((_,v)=>{if(_.params.length!==v.params.length)return 0;let x=0,E=0;for(let $ of _.params){let C=$.defaultValue?on($.defaultValue):"any";C==="non-negative-integer"?x+=3:C==="integer"?x+=2:C!=="any"&&(x+=1)}for(let $ of v.params){let C=$.defaultValue?on($.defaultValue):"any";C==="non-negative-integer"?E+=3:C==="integer"?E+=2:C!=="any"&&(E+=1)}return E-x}),S=[];for(let _ of k){let v=[`__args.length === ${_.params.length}`],x=[];for(let E=0;E<_.params.length;E++){let $=_.params[E];if(x.push(`__args[${E}]`),$.defaultValue){let C=Hs(`__args[${E}]`,$.defaultValue);C!=="true"&&v.push(C)}}S.push(` if (${v.join(" && ")}) return ${p}$${_.index}(${x.join(", ")})`)}let b=`
30
- ${w}${y}function ${p}(...__args) {
31
- ${S.join(`
30
+ `;for(let E of p)S+=`${i}if (__tjs?.registerExtension) { __tjs.registerExtension('${o}', '${E.name}', __ext_${o}.${E.name}) }
31
+ `;n+=S,r=c}return r<=e.length&&n.length<e.length,{source:n,extensions:t}}function Ot(e,t){if(t.size===0)return e;let n=new Map;for(let[s,a]of t)for(let i of a)n.has(i)||n.set(i,[]),n.get(i).push(s);let r=e;for(let[s,a]of n){if(!a.includes("String"))continue;let i=new RegExp(`('(?:[^'\\\\]|\\\\.)*')\\.(${s})\\((\\))?`,"g");r=r.replace(i,(c,l,p,f)=>f?`__ext_String.${p}.call(${l})`:`__ext_String.${p}.call(${l}, `);let o=new RegExp(`("(?:[^"\\\\]|\\\\.)*")\\.(${s})\\((\\))?`,"g");r=r.replace(o,(c,l,p,f)=>f?`__ext_String.${p}.call(${l})`:`__ext_String.${p}.call(${l}, `);let u=new RegExp("(`(?:[^`\\\\]|\\\\.)*`)\\."+s+"\\((\\))?","g");r=r.replace(u,(c,l,p)=>p?`__ext_String.${s}.call(${l})`:`__ext_String.${s}.call(${l}, `)}for(let[s,a]of n){if(!a.includes("Array"))continue;let i=`].${s}(`,o=0,u;for(;(u=r.indexOf(i,o))!==-1;){let c=1,l=u-1,p=!1;for(;l>=0&&c>0;){let f=r[l];p?f===p&&(l===0||r[l-1]!=="\\")&&(p=!1):(f==="]"&&c++,f==="["&&c--,(f==="'"||f==='"'||f==="`")&&(p=f)),l--}if(c===0){let f=r.slice(l+1,u+1),d=r.slice(0,l+1),m=r.slice(u+i.length);m[0]===")"?r=`${d}__ext_Array.${s}.call(${f})${m.slice(1)}`:r=`${d}__ext_Array.${s}.call(${f}, ${m}`}o=u+1}}for(let[s,a]of n){if(!a.includes("Number"))continue;let i=new RegExp(`(\\d+(?:\\.\\d+)?)\\.(${s})\\((\\))?`,"g");r=r.replace(i,(o,u,c,l)=>l?`__ext_Number.${c}.call(${u})`:`__ext_Number.${c}.call(${u}, `)}return r}function Le(e,t){let n=1,r=0;for(let s=0;s<t&&s<e.length;s++)e[s]===`
32
+ `?(n++,r=0):r++;return{line:n,column:r}}function ii(e,t){let n=t.trim();return/^['"`]/.test(n)?`typeof ${e} === 'string'`:n==="true"||n==="false"?`typeof ${e} === 'boolean'`:n==="null"?`${e} === null`:n==="undefined"?`${e} === undefined`:n.startsWith("[")?`Array.isArray(${e})`:n.startsWith("{")?`(typeof ${e} === 'object' && ${e} !== null && !Array.isArray(${e}))`:/^\+\d+/.test(n)?`(typeof ${e} === 'number' && Number.isInteger(${e}) && ${e} >= 0)`:/^-?\d+\.\d+/.test(n)?`typeof ${e} === 'number'`:/^-?\d+$/.test(n)?`(typeof ${e} === 'number' && Number.isInteger(${e}))`:"true"}function pn(e){let t=e.trim();return/^['"`]/.test(t)?"string":t==="true"||t==="false"?"boolean":t==="null"?"null":t==="undefined"?"undefined":t.startsWith("[")?"array":t.startsWith("{")?"object":/^\+\d+/.test(t)?"non-negative-integer":/^-?\d+\.\d+/.test(t)?"number":/^-?\d+$/.test(t)?"integer":"any"}function rr(e,t){let n=[],r=0,s="",a=!1;for(let o=0;o<e.length;o++){let u=e[o];if(!a&&(u==="'"||u==='"'||u==="`")){a=u,s+=u;continue}if(a){if(s+=u,u==="\\"){o++,o<e.length&&(s+=e[o]);continue}u===a&&(a=!1);continue}if(u==="("||u==="["||u==="{"){r++,s+=u;continue}if(u===")"||u==="]"||u==="}"){r--,s+=u;continue}if(u===","&&r===0){let c=zs(s.trim(),t);c&&n.push(c),s="";continue}s+=u}let i=s.trim();if(i){let o=zs(i,t);o&&n.push(o)}return n}function zs(e,t){let n=e.replace(/^\/\*\s*unsafe\s*\*\/\s*/,"");if(n.startsWith("..."))return null;let r=n.indexOf("=");if(r===-1)return{name:n.trim(),defaultValue:"",required:!0};let s=n.slice(0,r).trim(),a=n.slice(r+1).trim();return{name:s,defaultValue:a,required:t.has(s)}}function Nt(e,t){let n=1,r=t+1,s=!1,a=!1,i=!1;for(;r<e.length&&n>0;){let o=e[r],u=r+1<e.length?e[r+1]:"";if(a){o===`
33
+ `&&(a=!1),r++;continue}if(i){if(o==="*"&&u==="/"){i=!1,r+=2;continue}r++;continue}if(s){if(o==="\\"){r+=2;continue}o===s&&(s=!1),r++;continue}if(o==="/"&&u==="/"){a=!0,r+=2;continue}if(o==="/"&&u==="*"){i=!0,r+=2;continue}if(o==="'"||o==='"'||o==="`"){s=o,r++;continue}o==="{"&&n++,o==="}"&&n--,r++}return r}function ai(e,t){let n=new Set,r=/(?:^|(?<=[\n;{}]))\s*(export\s+)?(async\s+)?function\s+(\w+)\s*\(/gm,s=new Map,a,i=[];for(;(a=r.exec(e))!==null;){let p=!!a[1],f=!!a[2],d=a[3],m=a.index,y=m,S=a[0].indexOf("function");S>=0&&(y=m+S),i.push({name:d,fullMatchStart:m,funcKeywordStart:y,exported:p,isAsync:f})}for(let p of i)s.has(p.name)||s.set(p.name,[]);let o=new Map;for(let p of i)o.set(p.name,(o.get(p.name)||0)+1);let u=new Set;for(let[p,f]of o)f>1&&u.add(p);if(u.size===0)return{source:e,polymorphicNames:n};for(let p of i){if(!u.has(p.name))continue;let f=e.indexOf("(",p.funcKeywordStart);if(f===-1)continue;let d=1,m=f+1;for(;m<e.length&&d>0;)e[m]==="("&&d++,e[m]===")"&&d--,m++;let y=m-1,x=e.slice(f+1,y),S=m;for(;S<e.length&&e[S]!=="{";)S++;if(S>=e.length)continue;let E=Nt(e,S),_=p.fullMatchStart;for(;_>0&&e[_-1]===" ";)_--;let b=s.get(p.name),v=rr(x,t);if(x.includes("...")){let k=Le(e,p.funcKeywordStart);throw new te(`Rest parameters are not supported in polymorphic function '${p.name}'. Use separate function names instead.`,k)}b.push({index:b.length+1,start:_,end:E,text:e.slice(_,E),exported:p.exported,isAsync:p.isAsync,params:v})}for(let[p,f]of s){if(f.length<2)continue;let d=f.filter(m=>m.isAsync).length;if(d>0&&d<f.length){let m=Le(e,f[0].start);throw new te(`Polymorphic function '${p}': all variants must be either sync or async, not mixed.`,m)}for(let m=0;m<f.length;m++)for(let y=m+1;y<f.length;y++){let x=f[m],S=f[y];if(x.params.length!==S.params.length)continue;let E=!0;for(let _=0;_<x.params.length;_++){let b=x.params[_].defaultValue?pn(x.params[_].defaultValue):"any",v=S.params[_].defaultValue?pn(S.params[_].defaultValue):"any";if(b!==v){E=!1;break}}if(E){let _=Le(e,S.start);throw new te(`Polymorphic function '${p}': variants ${m+1} and ${y+1} have ambiguous signatures (same parameter types at every position). Overloads must differ by arity or parameter types.`,_)}}}let c=[];for(let[p,f]of s)if(!(f.length<2))for(let d of f)c.push({name:p,variant:d});c.sort((p,f)=>f.variant.start-p.variant.start);let l=e;for(let{name:p,variant:f}of c){let d=f.isAsync?"async ":"",m=f.text.replace(new RegExp(`(?:export\\s+)?${d?d.replace(/\s+$/,"\\s+"):""}function\\s+${p}\\s*\\(`),`${d}function ${p}$$${f.index}(`);l=l.slice(0,f.start)+m+l.slice(f.end)}for(let[p,f]of s){if(f.length<2)continue;n.add(p);let d=f[0].isAsync,m=f.some(b=>b.exported),y=d?"async ":"",x=m?"export ":"",S=[...f].sort((b,v)=>{if(b.params.length!==v.params.length)return 0;let w=0,k=0;for(let T of b.params){let C=T.defaultValue?pn(T.defaultValue):"any";C==="non-negative-integer"?w+=3:C==="integer"?w+=2:C!=="any"&&(w+=1)}for(let T of v.params){let C=T.defaultValue?pn(T.defaultValue):"any";C==="non-negative-integer"?k+=3:C==="integer"?k+=2:C!=="any"&&(k+=1)}return k-w}),E=[];for(let b of S){let v=[`__args.length === ${b.params.length}`],w=[];for(let k=0;k<b.params.length;k++){let T=b.params[k];if(w.push(`__args[${k}]`),T.defaultValue){let C=ii(`__args[${k}]`,T.defaultValue);C!=="true"&&v.push(C)}}E.push(` if (${v.join(" && ")}) return ${p}$${b.index}(${w.join(", ")})`)}let _=`
34
+ ${x}${y}function ${p}(...__args) {
35
+ ${E.join(`
32
36
  `)}
33
37
  return __tjs.typeError('${p}', 'no matching overload', __args)
34
38
  }
35
- `;l+=b}return{source:l,polymorphicNames:n}}function Zs(e){let t=new Set,n=/\b(?:let|const|var|function|class)\s+([A-Z][a-zA-Z0-9_]*)/g;for(let r;r=n.exec(e);)t.add(r[1]);return e.replace(/(?<=^|[;\n{])(\s*)([A-Z][a-zA-Z0-9_]*)\s*=(?!=)/gm,(r,s,a)=>t.has(a)?r:r.replace(a,`const ${a}`))}function Qs(e,t=!1){let n=[],r=[],s="",a=0;for(;a<e.length;){let i=e.slice(a).match(/^\btest\s+/);if(i){let o=a,u=a+i[0].length,c,l=e.slice(u).match(/^(['"`])([^]*?)\1\s*/);if(l&&(c=l[2],u+=l[0].length),e[u]==="{"){let p=u+1,f=1,d=p,g=null,y=!1;for(;d<e.length&&f>0;){let w=e[d];if(y){y=!1,d++;continue}if(w==="\\"&&g){y=!0,d++;continue}if(g){w===g&&(g=null),d++;continue}if(w==="/"&&e[d+1]==="/"){let k=e.indexOf(`
36
- `,d);d=k===-1?e.length:k+1;continue}if(w==="/"&&e[d+1]==="*"){let k=e.indexOf("*/",d+2);d=k===-1?e.length:k+2;continue}if(w==="'"||w==='"'||w==="`"){g=w,d++;continue}w==="{"?f++:w==="}"&&f--,d++}if(f===0){let w=e.slice(p,d-1).trim(),k=d,S=(e.slice(0,o).match(/\n/g)||[]).length+1;if(n.push({description:c,body:w,start:o,end:k,line:S}),!t)try{new Function(w)()}catch(v){let x=c||`test at line ${S}`;r.push(`Test failed: ${x} (line ${S})
37
- ${v.message||v}`)}let _=(e.slice(o,k).match(/\n/g)||[]).length;s+=`
38
- `.repeat(_),a=k;continue}}}s+=e[a],a++}return{source:s,tests:n,errors:r}}function Ys(e,t){let n=new Set,r=/\bclass\s+(\w+)(\s+extends\s+\w+)?\s*\{/g,s,a=[];for(;(s=r.exec(e))!==null;){let o=s[1],u=s[2]?.trim()||"",c=s.index+s[0].length-1,l=Ct(e,c),p=e.slice(c,l);a.push({className:o,extendsClause:u,bodyStart:c,bodyEnd:l,body:p})}let i=e;for(let o=a.length-1;o>=0;o--){let{className:u,extendsClause:c,bodyStart:l,bodyEnd:p,body:f}=a[o],d=/\bconstructor\s*\(/g,g,y=[];for(;(g=d.exec(f))!==null;)y.push(g.index);if(y.length<2)continue;n.add(u);let w=[];for(let v=0;v<y.length;v++){let x=y[v],E=f.indexOf("(",x),$=1,C=E+1;for(;C<f.length&&$>0;)f[C]==="("&&$++,f[C]===")"&&$--,C++;let I=f.slice(E+1,C-1),M=C;for(;M<f.length&&f[M]!=="{";)M++;let F=Ct(f,M),N=f.slice(M+1,F-1);w.push({index:v+1,paramStr:I,bodyText:N,fullStart:x,fullEnd:F})}let k=f;for(let v=w.length-1;v>=1;v--){let x=w[v],E=x.fullStart;for(;E>0&&k[E-1]===" ";)E--;E>0&&k[E-1]===`
39
- `&&E--,k=k.slice(0,E)+k.slice(x.fullEnd)}let S="";for(let v=1;v<w.length;v++){let x=w[v],E=Hn(x.paramStr,t);if(x.paramStr.includes("...")){let C=Le(e,l+x.fullStart);throw new te(`Rest parameters are not supported in polymorphic constructors for '${u}'.`,C)}S+=`
40
- function ${u}$ctor$${x.index}(${x.paramStr}) {`,S+=`
41
- const __obj = Object.create(${u}.prototype)`,S+=`
42
- ;(function() {${x.bodyText}}).call(__obj)`,S+=`
43
- return __obj`,S+=`
39
+ `;l+=_}return{source:l,polymorphicNames:n}}function oi(e){let t=new Set,n=/\b(?:let|const|var|function|class)\s+([A-Z][a-zA-Z0-9_]*)/g;for(let r;r=n.exec(e);)t.add(r[1]);return e.replace(/(?<=^|[;\n{])(\s*)([A-Z][a-zA-Z0-9_]*)\s*=(?!=)/gm,(r,s,a)=>t.has(a)?r:r.replace(a,`const ${a}`))}function ui(e,t=!1){let n=[],r=[],s="",a=0;for(;a<e.length;){let i=e.slice(a).match(/^\btest\s+/);if(i){let o=a,u=a+i[0].length,c,l=e.slice(u).match(/^(['"`])([^]*?)\1\s*/);if(l&&(c=l[2],u+=l[0].length),e[u]==="{"){let p=u+1,f=1,d=p,m=null,y=!1;for(;d<e.length&&f>0;){let x=e[d];if(y){y=!1,d++;continue}if(x==="\\"&&m){y=!0,d++;continue}if(m){x===m&&(m=null),d++;continue}if(x==="/"&&e[d+1]==="/"){let S=e.indexOf(`
40
+ `,d);d=S===-1?e.length:S+1;continue}if(x==="/"&&e[d+1]==="*"){let S=e.indexOf("*/",d+2);d=S===-1?e.length:S+2;continue}if(x==="'"||x==='"'||x==="`"){m=x,d++;continue}x==="{"?f++:x==="}"&&f--,d++}if(f===0){let x=e.slice(p,d-1).trim(),S=d,E=(e.slice(0,o).match(/\n/g)||[]).length+1;if(n.push({description:c,body:x,start:o,end:S,line:E}),!t)try{new Function(x)()}catch(v){let w=c||`test at line ${E}`;r.push(`Test failed: ${w} (line ${E})
41
+ ${v.message||v}`)}let b=(e.slice(o,S).match(/\n/g)||[]).length;s+=`
42
+ `.repeat(b),a=S;continue}}}s+=e[a],a++}return{source:s,tests:n,errors:r}}function ci(e,t){let n=new Set,r=/\bclass\s+(\w+)(\s+extends\s+\w+)?\s*\{/g,s,a=[];for(;(s=r.exec(e))!==null;){let o=s[1],u=s[2]?.trim()||"",c=s.index+s[0].length-1,l=Nt(e,c),p=e.slice(c,l);a.push({className:o,extendsClause:u,bodyStart:c,bodyEnd:l,body:p})}let i=e;for(let o=a.length-1;o>=0;o--){let{className:u,extendsClause:c,bodyStart:l,bodyEnd:p,body:f}=a[o],d=/\bconstructor\s*\(/g,m,y=[];for(;(m=d.exec(f))!==null;)y.push(m.index);if(y.length<2)continue;n.add(u);let x=[];for(let v=0;v<y.length;v++){let w=y[v],k=f.indexOf("(",w),T=1,C=k+1;for(;C<f.length&&T>0;)f[C]==="("&&T++,f[C]===")"&&T--,C++;let N=f.slice(k+1,C-1),P=C;for(;P<f.length&&f[P]!=="{";)P++;let D=Nt(f,P),R=f.slice(P+1,D-1);x.push({index:v+1,paramStr:N,bodyText:R,fullStart:w,fullEnd:D})}let S=f;for(let v=x.length-1;v>=1;v--){let w=x[v],k=w.fullStart;for(;k>0&&S[k-1]===" ";)k--;k>0&&S[k-1]===`
43
+ `&&k--,S=S.slice(0,k)+S.slice(w.fullEnd)}let E="";for(let v=1;v<x.length;v++){let w=x[v],k=rr(w.paramStr,t);if(w.paramStr.includes("...")){let C=Le(e,l+w.fullStart);throw new te(`Rest parameters are not supported in polymorphic constructors for '${u}'.`,C)}E+=`
44
+ function ${u}$ctor$${w.index}(${w.paramStr}) {`,E+=`
45
+ const __obj = Object.create(${u}.prototype)`,E+=`
46
+ ;(function() {${w.bodyText}}).call(__obj)`,E+=`
47
+ return __obj`,E+=`
44
48
  }
45
- `}let b=[];for(let v=0;v<w.length;v++){let x=w[v],E=Hn(x.paramStr,t),$=[`a.length === ${E.length}`];for(let C=0;C<E.length;C++){let I=E[C];if(I.defaultValue){let M=Hs(`a[${C}]`,I.defaultValue);M!=="true"&&$.push(M)}}if(v===0)b.push(` if (${$.join(" && ")}) return Reflect.construct(t, a)`);else{let C=E.map((I,M)=>`a[${M}]`).join(", ");b.push(` if (${$.join(" && ")}) return ${u}$ctor$${x.index}(${C})`)}}S+=`
49
+ `}let _=[];for(let v=0;v<x.length;v++){let w=x[v],k=rr(w.paramStr,t),T=[`a.length === ${k.length}`];for(let C=0;C<k.length;C++){let N=k[C];if(N.defaultValue){let P=ii(`a[${C}]`,N.defaultValue);P!=="true"&&T.push(P)}}if(v===0)_.push(` if (${T.join(" && ")}) return Reflect.construct(t, a)`);else{let C=k.map((N,P)=>`a[${P}]`).join(", ");_.push(` if (${T.join(" && ")}) return ${u}$ctor$${w.index}(${C})`)}}E+=`
46
50
  function ${u}$dispatch(t, a) {
47
- `,S+=b.join(`
51
+ `,E+=_.join(`
48
52
  `)+`
49
- `,S+=` return __tjs.typeError('${u}', 'no matching constructor', a)
50
- `,S+=`}
51
- `,i=i.slice(0,l)+k+i.slice(p);let _=l+k.length;i=i.slice(0,_)+S+i.slice(_)}return{source:i,polyCtorClasses:n}}function Xs(e,t=new Set){let n=/\bclass\s+(\w+)(\s+extends\s+\w+)?\s*\{/g,r="",s=0,a;for(;(a=n.exec(e))!==null;){let i=a[1],o=a[2]||"",u=a.index,c=u+a[0].length-1,l=1,p=c+1;for(;p<e.length&&l>0;){let f=e[p];f==="{"?l++:f==="}"&&l--,p++}if(l===0){let f=p,d=e.slice(c,f);r+=e.slice(s,u),r+=`let ${i} = class ${i}${o} ${d}; `,t.has(i)?r+=`${i} = new Proxy(${i}, { apply(t, _, a) { return ${i}$dispatch(t, a) }, construct(t, a) { return ${i}$dispatch(t, a) } });`:r+=`${i} = new Proxy(${i}, { apply(t, _, a) { return Reflect.construct(t, a) } });`,s=f}}return r+=e.slice(s),r}function ei(e){let t=[{pattern:/\bnew\s+Date\b/,message:"new Date() is not allowed in TjsDate mode. Use Timestamp.now() or Timestamp.from()"},{pattern:/\bDate\.now\b/,message:"Date.now() is not allowed in TjsDate mode. Use Timestamp.now()"},{pattern:/\bDate\.parse\b/,message:"Date.parse() is not allowed in TjsDate mode. Use Timestamp.parse()"},{pattern:/\bDate\.UTC\b/,message:"Date.UTC() is not allowed in TjsDate mode. Use Timestamp.from()"}];for(let{pattern:n,message:r}of t)if(n.test(e))throw new Error(r);return e}function ti(e){let t=new Set,n=/\bconst!\s+(\w+)\b/g,r;for(;(r=n.exec(e))!==null;)t.add(r[1]);if(t.size===0)return e;e=e.replace(/\bconst!\s+/g,"const ");let s=e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"");for(let a of t){if(new RegExp(`\\b${a}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])\\s*(?:=(?!=)|\\+\\+|--|\\+=|-=|\\*=|\\/=|%=|&&=|\\|\\|=|\\?\\?=|<<=|>>=|>>>=|\\^=|&=|\\|=)`,"g").test(s))throw new Error(`Cannot mutate immutable binding '${a}'. const! bindings are read-only at compile time.`);if(new RegExp(`(?:\\+\\+|--)\\s*${a}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])`,"g").test(s))throw new Error(`Cannot mutate immutable binding '${a}'. const! bindings are read-only at compile time.`);if(new RegExp(`\\bdelete\\s+${a}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])`,"g").test(s))throw new Error(`Cannot mutate immutable binding '${a}'. const! bindings are read-only at compile time.`);let c="push|pop|splice|shift|unshift|sort|reverse|fill|copyWithin|set";if(new RegExp(`\\b${a}\\s*\\.\\s*(?:${c})\\s*\\(`,"g").test(s))throw new Error(`Cannot call mutating method on immutable binding '${a}'. const! bindings are read-only at compile time.`)}return e}function ni(e){if(/(?<![a-zA-Z_$])\bvar\s+/.test(e))throw new Error("var is not allowed in TjsNoVar mode. Use const or let instead.");return e}function ri(e){if(/(?<![A-Za-z_$])\beval\s*\(/.test(e))throw new Error("eval() is not allowed in TjsNoeval mode. Use Eval() from TJS runtime for safe evaluation.");if(/\bnew\s+Function\s*\(/.test(e))throw new Error("new Function() is not allowed in TjsNoeval mode. Use SafeFunction() from TJS runtime.");return e}function si(e){if(!e.includes("!."))return e;let t="",n=0,r="normal",s=0;for(;n<e.length;){let a=e[n],i=e[n+1];if(r==="normal"){if(a==="/"&&i==="/"){r="line-comment",t+=a,n++;continue}if(a==="/"&&i==="*"){r="block-comment",t+=a,n++;continue}if(a==="'"){r="string-single",t+=a,n++;continue}if(a==='"'){r="string-double",t+=a,n++;continue}if(a==="`"){r="string-template",s++,t+=a,n++;continue}if(a==="!"&&i==="."&&n+2<e.length&&/[a-zA-Z_$]/.test(e[n+2])){let o=t.length,u=io(t);if(u<o){let c=t.slice(u);t=t.slice(0,u);let l=n+2;for(;l<e.length&&/[\w$]/.test(e[l]);)l++;let p=e.slice(n+2,l);t+=`__tjs.bang(${c},'${p}')`,n=l;continue}}t+=a,n++}else r==="line-comment"?(t+=a,a===`
52
- `&&(r="normal"),n++):r==="block-comment"?(t+=a,a==="*"&&i==="/"?(t+=i,r="normal",n+=2):n++):r==="string-single"?(t+=a,a==="\\"?(t+=i||"",n+=2):(a==="'"&&(r="normal"),n++)):r==="string-double"?(t+=a,a==="\\"?(t+=i||"",n+=2):(a==='"'&&(r="normal"),n++)):r==="string-template"?(t+=a,a==="\\"?(t+=i||"",n+=2):a==="`"?(s--,r=s>0?"string-template":"normal",n++):a==="$"&&i==="{"?(t+=i,n+=2,r="normal"):n++):(t+=a,n++)}return t}function io(e){let t=e.length-1;for(;t>=0&&/\s/.test(e[t]);)t--;if(t<0)return e.length;for(;t>=0;){let n=e[t];if(/[\w$]/.test(n)){for(;t>=0&&/[\w$]/.test(e[t]);)t--;if(t>=0&&e[t]==="."){t>=1&&e[t-1]==="?"?t-=2:t--;continue}return t+1}else if(n===")"){if(t=Os(e,t,"(",")"),t<0)return 0;if(t--,t>=0&&/[\w$]/.test(e[t]))continue;if(t>=0&&e[t]==="."){t>=1&&e[t-1]==="?"?t-=2:t--;continue}return t+1}else if(n==="]"){if(t=Os(e,t,"[","]"),t<0)return 0;if(t--,t>=0&&/[\w$]/.test(e[t]))continue;if(t>=0&&e[t]==="."){t>=1&&e[t-1]==="?"?t-=2:t--;continue}return t+1}else return t+1}return 0}function Os(e,t,n,r){let s=1;for(t--;t>=0&&s>0;)e[t]===r?s++:e[t]===n&&s--,s>0&&t--;return t}function ii(e){let t=new Map;if(!e.includes("let "))return{source:e,annotations:t};let n=[],r=0,s="normal",a=[];for(;r<e.length;){let o=e[r],u=e[r+1];switch(s){case"single-string":if(o==="\\"&&r+1<e.length){r+=2;continue}o==="'"&&(s="normal"),r++;continue;case"double-string":if(o==="\\"&&r+1<e.length){r+=2;continue}o==='"'&&(s="normal"),r++;continue;case"template-string":if(o==="\\"&&r+1<e.length){r+=2;continue}if(o==="$"&&u==="{"){r+=2,a.push(1),s="normal";continue}o==="`"&&(s="normal"),r++;continue;case"line-comment":o===`
53
- `&&(s="normal"),r++;continue;case"block-comment":if(o==="*"&&u==="/"){r+=2,s="normal";continue}r++;continue;case"regex":if(o==="\\"&&r+1<e.length){r+=2;continue}if(o==="["){for(r++;r<e.length&&e[r]!=="]";)e[r]==="\\"&&r+1<e.length?r+=2:r++;r<e.length&&r++;continue}if(o==="/"){for(r++;r<e.length&&/[gimsuy]/.test(e[r]);)r++;s="normal";continue}r++;continue;case"normal":if(a.length>0){if(o==="{")a[a.length-1]++;else if(o==="}"&&(a[a.length-1]--,a[a.length-1]===0)){a.pop(),r++,s="template-string";continue}}if(o==="'"){r++,s="single-string";continue}if(o==='"'){r++,s="double-string";continue}if(o==="`"){r++,s="template-string";continue}if(o==="/"&&u==="/"){r+=2,s="line-comment";continue}if(o==="/"&&u==="*"){r+=2,s="block-comment";continue}if(o==="/"){let c=r-1;for(;c>=0&&/\s/.test(e[c]);)c--;let l=c>=0?e[c]:"";if(!l||/[=(!,;:{[&|?+\-*%<>~^]/.test(l)||c>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,c-10),c+1))){r++,s="regex";continue}}if(o==="l"&&e.slice(r,r+4)==="let "&&(r===0||!/[\w$]/.test(e[r-1]))){let c=r+4;for(;c<e.length&&/\s/.test(e[c]);)c++;if(c<e.length&&/[a-zA-Z_$]/.test(e[c])){let l=c;for(;c<e.length&&/[\w$]/.test(e[c]);)c++;let p=c,f=e.slice(l,p),d=c;for(;d<e.length&&/\s/.test(e[d]);)d++;if(d<e.length&&e[d]===":"&&e[d+1]!==":"){let y=d+1;for(;y<e.length&&/[ \t]/.test(e[y]);)y++;let w=ao(e,y);if(w>y){let k=e.slice(y,w).trim();t.set(f,k),n.push({start:p,end:w,replacement:""}),r=w;continue}}}}break}r++}if(n.length===0)return{source:e,annotations:t};let i=e;for(let o=n.length-1;o>=0;o--){let u=n[o];i=i.slice(0,u.start)+u.replacement+i.slice(u.end)}return{source:i,annotations:t}}function ao(e,t){let n=t,r=0,s=0,a=0,i="normal",o=[];for(;n<e.length;){let u=e[n];if(i==="sq"){if(u==="\\"){n+=2;continue}u==="'"&&(i="normal"),n++;continue}if(i==="dq"){if(u==="\\"){n+=2;continue}u==='"'&&(i="normal"),n++;continue}if(i==="tpl"){if(u==="\\"){n+=2;continue}if(u==="$"&&e[n+1]==="{"){o.push(1),i="normal",n+=2;continue}u==="`"&&(i="normal"),n++;continue}if(o.length>0){if(u==="{")o[o.length-1]++;else if(u==="}"&&(o[o.length-1]--,o[o.length-1]===0)){o.pop(),i="tpl",n++;continue}}if(u==="'"){i="sq",n++;continue}if(u==='"'){i="dq",n++;continue}if(u==="`"){i="tpl",n++;continue}if(u==="("?r++:u===")"?r--:u==="{"?s++:u==="}"?s--:u==="["?a++:u==="]"&&a--,r===0&&s===0&&a===0&&(u==="="||u===","||u===";"||u===`
54
- `))return n;n++}return n}function fn(e,t){let n="",r=0,s,a,i="normal",o=[],u=[{type:"top-level",braceDepth:0}],c=0,l=()=>u[u.length-1]?.type||"top-level",p=()=>{let f=u[u.length-1];return f?.type==="class-body"&&c===f.braceDepth+1};for(;r<e.length;){let f=e[r],d=e[r+1];switch(i){case"single-string":if(n+=f,f==="\\"&&r+1<e.length){n+=d,r+=2;continue}f==="'"&&(i="normal"),r++;continue;case"double-string":if(n+=f,f==="\\"&&r+1<e.length){n+=d,r+=2;continue}f==='"'&&(i="normal"),r++;continue;case"template-string":if(n+=f,f==="\\"&&r+1<e.length){n+=d,r+=2;continue}if(f==="$"&&d==="{"){n+=d,r+=2,o.push(1),i="normal";continue}f==="`"&&(i="normal"),r++;continue;case"line-comment":n+=f,f===`
55
- `&&(i="normal"),r++;continue;case"block-comment":if(n+=f,f==="*"&&d==="/"){n+=d,r+=2,i="normal";continue}r++;continue;case"regex":if(n+=f,f==="\\"&&r+1<e.length){n+=d,r+=2;continue}if(f==="["){for(r++;r<e.length&&e[r]!=="]";)n+=e[r],e[r]==="\\"&&r+1<e.length?(n+=e[r+1],r+=2):r++;r<e.length&&(n+=e[r],r++);continue}if(f==="/"){for(r++;r<e.length&&/[gimsuy]/.test(e[r]);)n+=e[r],r++;i="normal";continue}r++;continue;case"normal":if(o.length>0){if(f==="{")o[o.length-1]++;else if(f==="}"&&(o[o.length-1]--,o[o.length-1]===0)){o.pop(),n+=f,r++,i="template-string";continue}}if(f==="'"){n+=f,r++,i="single-string";continue}if(f==='"'){n+=f,r++,i="double-string";continue}if(f==="`"){n+=f,r++,i="template-string";continue}if(f==="/"&&d==="/"){n+=f+d,r+=2,i="line-comment";continue}if(f==="/"&&d==="*"){n+=f+d,r+=2,i="block-comment";continue}if(f==="/"){let b=n.trimEnd();if(!b[b.length-1]||/[=(!,;:{[&|?+\-*%<>~^]$/.test(b)||/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)\s*$/.test(b)){n+=f,r++,i="regex";continue}}break}if(f==="{"){c++,n+=f,r++;continue}if(f==="}"){c--;let b=u[u.length-1];b&&c===b.braceDepth&&u.pop(),n+=f,r++;continue}let g=e.slice(r).match(/^class\s+\w+(?:\s+extends\s+\w+)?\s*\{/);if(g){let b=g[0].slice(0,-1);n+=b,r+=b.length,u.push({type:"class-body",braceDepth:c});continue}let y=e.slice(r).match(/^function\s+(\w+)\s*\(/);if(y){let b=y[1],_=y[0].length,v=e[r+_],x,E=r+_;(v==="?"||v==="!")&&(x=v,E++,x==="!"?t.unsafeFunctions.add(b):t.safeFunctions.add(b)),n+=`function ${b}(`,r=E;let $=un(e,r,"(",")");if(!$){n+=e[r],r++;continue}let{content:C,endPos:I}=$;r=I;let M=Zn(C,t,!0);n+=M+")";let F=r;for(;F<e.length&&/\s/.test(e[F]);)F++;if(e[F]===":"){let U=e.slice(F,F+2),J;for(U===":?"||U===":!"?(F+=2,J=U===":?"?"safe":"unsafe"):F+=1;F<e.length&&/\s/.test(e[F]);)F++;let X=Kn(e,F);X&&(s===void 0&&(s=X.type,J&&(a=J)),r=X.endPos)}let N=r;for(;N<e.length&&/\s/.test(e[N]);)N++;if(e[N]==="="&&e[N+1]===">")throw new te("Unexpected '=>' after function declaration. Function declarations use `function name(params) { body }`, not arrow syntax. Remove the `=>`.",Le(t.originalSource,N),t.originalSource);continue}let w=e.slice(r).match(/^(constructor|(?:get|set)\s+\w+|async\s+\w+|\w+)\s*\(/),k=(()=>{for(let b=n.length-1;b>=0;b--)if(!/\s/.test(n[b]))return n[b];return`
56
- `})(),S=k!=="="&&k!==","&&k!=="("&&k!=="["&&k!==">";if(w&&p()&&!S){let b=w[1].length;n+=e.slice(r,r+b),r+=b;continue}if(w&&p()&&S){let b=w[1],_=w[0].length,v=r+_;n+=b+"(",r=v;let x=un(e,r,"(",")");if(!x){n+=e[r],r++;continue}let{content:E,endPos:$}=x;r=$;let C=Zn(E,t,!0);n+=C+")";let I=r;for(;I<e.length&&/\s/.test(e[I]);)I++;if(e[I]===":"){let F=e.slice(I,I+2);for(F===":?"||F===":!"?I+=2:I++;I<e.length&&/\s/.test(e[I]);)I++;let N=Kn(e,I);N&&(r=N.endPos)}let M=r;for(;M<e.length&&/\s/.test(e[M]);)M++;if(e[M]==="="&&e[M+1]===">")throw new te("Unexpected '=>' after method declaration. Methods use `name(params) { body }`, not arrow syntax. Remove the `=>`.",Le(t.originalSource,M),t.originalSource);continue}if(e[r]==="("){let b=un(e,r+1,"(",")");if(!b){n+=e[r],r++;continue}let _=b.content,v=b.endPos,x=v;for(;x<e.length&&/\s/.test(e[x]);)x++;let E;if(e[x]===":"){let $=e.slice(x,x+2);for($===":?"||$===":!"?x+=2:x++;x<e.length&&/\s/.test(e[x]);)x++;let C=Kn(e,x);if(C)for(E=C.type,x=C.endPos;x<e.length&&/\s/.test(e[x]);)x++}if(e.slice(x,x+2)==="=>"){let $=null,C=_,I=_.trimStart();I.startsWith("?")&&(I.length===1||/\s/.test(I[1]))?($="?",C=I.slice(1)):I.startsWith("!")&&(I.length===1||/\s/.test(I[1]))&&($="!",C=I.slice(1));let M=Zn(C,t,!1);for(n+=`(${$==="?"?"/* safe */ ":$==="!"?"/* unsafe */ ":""}${M})`,r=v;r<x&&/\s/.test(e[r]);)n+=e[r],r++;E&&(r=x)}else{let $=fn(_,t);n+=`(${$.source})`,r=v}continue}n+=e[r],r++}return{source:n,returnType:s,returnSafety:a}}function un(e,t,n,r){let s=1,a=t,i=!1,o="";for(;a<e.length&&s>0;){let u=e[a];!i&&(u==="'"||u==='"'||u==="`")?(i=!0,o=u):i&&u===o&&e[a-1]!=="\\"?i=!1:i||(u===n?s++:u===r&&s--),a++}return s!==0?null:{content:e.slice(t,a-1),endPos:a}}function ai(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)return null;let r=n,s=e[n];if(s==="{"||s==="["){let i=s==="{"?"}":"]",o=un(e,n+1,s,i);return o?{value:e.slice(r,o.endPos),endPos:o.endPos}:null}if(s==="'"||s==='"'||s==="`"){for(n++;n<e.length;){if(e[n]===s&&e[n-1]!=="\\")return n++,{value:e.slice(r,n),endPos:n};n++}return null}if(/[-+\d]/.test(s)){for(;n<e.length&&/[\d.eE+-]/.test(e[n]);)n++;return{value:e.slice(r,n),endPos:n}}let a=e.slice(n).match(/^(true|false|null|undefined)\b/);return a?{value:a[1],endPos:n+a[1].length}:null}function It(e){return e.replace(/(?<!\|)\|(?!\|)/g," || ")}function Kn(e,t){let n=t,r=0,s=!1,a="",i=!1,o=u=>({type:It(e.slice(t,u).trim()),endPos:u});for(;n<e.length;){let u=e[n];if(!s&&(u==="'"||u==='"'||u==="`")){s=!0,a=u,i=!0,n++;continue}if(s){if(u===a&&e[n-1]!=="\\"){if(s=!1,n++,r===0){let c=n;for(;c<e.length&&/\s/.test(e[c]);)c++;if(e[c]==="{"&&!e.slice(c+1).match(/^\s*(\w+)\s*:/)||e[c]!=="|"&&e[c]!=="&")return o(n)}continue}n++;continue}if(u==="{"||u==="["||u==="("){r++,i=!0,n++;continue}if(u==="}"||u==="]"||u===")"){if(r--,r===0){n++;let c=n;for(;c<e.length&&/\s/.test(e[c]);)c++;if(e[c]==="|"||e[c]==="&")continue;return o(n)}n++;continue}if(r===0&&u==="{"){if(i)return o(n);if(e.slice(n+1).match(/^\s*(\w+)\s*:/)){r++,i=!0,n++;continue}return o(n)}if(r===0&&(u==="|"||u==="&")){for(n++,n<e.length&&e[n]==="|"&&n++;n<e.length&&/\s/.test(e[n]);)n++;continue}if(r===0&&(/\d/.test(u)||u==="-"&&/\d/.test(e[n+1]))){let c=n;for(e[c]==="-"&&c++;c<e.length&&/\d/.test(e[c]);)c++;if(c<e.length&&e[c]==="."&&/\d/.test(e[c+1]))for(c++;c<e.length&&/\d/.test(e[c]);)c++;if(c<e.length&&(e[c]==="e"||e[c]==="E"))for(c++,c<e.length&&(e[c]==="+"||e[c]==="-")&&c++;c<e.length&&/\d/.test(e[c]);)c++;for(i=!0,n=c;n<e.length&&/\s/.test(e[n]);)n++;if(n<e.length&&e[n]==="{")return{type:It(e.slice(t,c).trim()),endPos:c};if(e[n]!=="|"&&e[n]!=="&")return{type:It(e.slice(t,c).trim()),endPos:c};continue}if(r===0&&/[a-zA-Z_]/.test(u)){let c=n;for(;c<e.length&&/\w/.test(e[c]);)c++;for(i=!0,n=c;n<e.length&&/\s/.test(e[n]);)n++;if(n<e.length&&e[n]==="("){r++,n++;continue}if(n<e.length&&e[n]==="{"&&!e.slice(n+1).match(/^\s*(\w+)\s*:/)){let p=c;for(;p>t&&/\s/.test(e[p-1]);)p--;return{type:It(e.slice(t,p).trim()),endPos:c}}if(e[n]!=="|"&&e[n]!=="&")return{type:It(e.slice(t,c).trim()),endPos:c};continue}n++}return i?o(n):null}function pn(e){let t=[],n="",r=0,s=!1,a=!1,i=0;for(;i<e.length;){let o=e[i],u=e[i+1];if(!a&&o==="/"&&u==="/"){s=!0,n+="//",i+=2;continue}if(!s&&o==="/"&&u==="*"){a=!0,n+="/*",i+=2;continue}if(s&&o===`
57
- `){s=!1,n+=o,i++;continue}if(a&&o==="*"&&u==="/"){a=!1,n+="*/",i+=2;continue}if(s||a){n+=o,i++;continue}o==="("||o==="{"||o==="["?(r++,n+=o):o===")"||o==="}"||o==="]"?(r--,n+=o):o===","&&r===0?(t.push(n),n=""):n+=o,i++}return n.trim()&&t.push(n),t}function Zn(e,t,n){let r=fn(e,{originalSource:e,requiredParams:t.requiredParams,unsafeFunctions:t.unsafeFunctions,safeFunctions:t.safeFunctions}).source,s=pn(r),a=!1,i=new Set,o=c=>{if(n&&/^\w+$/.test(c)){if(i.has(c))throw new Error(`Duplicate parameter name '${c}'`);i.add(c)}};return s.map(c=>{let l=c.trim();if(!l)return c;if(n&&l.startsWith("{")&&l.endsWith("}")){let d=l.slice(1,-1);return`{ ${oi(d,t)} }`}if(n&&l.startsWith("[")&&l.endsWith("]")){let d=l.slice(1,-1);return`[ ${oi(d,t)} ]`}if(l.startsWith("...")){let d=ui(l);return d!==-1?l.slice(0,d).trim():c}let p=l.match(/^(\w+)\s*\?\s*:\s*(.+)$/);if(p){let[,d,g]=p;return o(d),a=!0,`${d} = ${g}`}if(!oo(l)){let d=l.match(/^(\w+)\s*=/);return d&&o(d[1]),a=!0,c}let f=ui(l);if(f!==-1){let d=l.slice(0,f).trim(),g=l.slice(f+1).trim();return o(d),a&&n&&/^\w+$/.test(d),n&&/^\w+$/.test(d)&&t.requiredParams.add(d),`${d} = ${g}`}return c}).join(",")}function oi(e,t){return pn(e).map(s=>{let a=s.trim();if(!a)return s;let i=a.match(/^(\w+)\s*:\s*(\{[\s\S]*\})$/);if(i){let[,c,l]=i;t.requiredParams.add(c);let p=cn(l);return`${c} = ${p}`}let o=a.match(/^(\w+)\s*:\s*(\[[\s\S]*\])$/);if(o){let[,c,l]=o;t.requiredParams.add(c);let p=ln(l);return`${c} = ${p}`}let u=a.match(/^(\w+)\s*:\s*([\s\S]+)$/);if(u){let[,c,l]=u;return t.requiredParams.add(c),`${c} = ${l}`}return s}).join(", ")}function cn(e){let t=e.slice(1,-1).trim();return`{ ${pn(t).map(s=>{let a=s.trim();if(!a)return s;let i=a.match(/^(\w+)\s*:\s*(\{[\s\S]*\})$/);if(i){let[,p,f]=i;return`${p}: ${cn(f)}`}let o=a.match(/^(\w+)\s*=\s*(\{[\s\S]*\})$/);if(o){let[,p,f]=o;return`${p}: ${cn(f)}`}let u=a.match(/^(\w+)\s*:\s*(\[[\s\S]*\])$/);if(u){let[,p,f]=u;return`${p}: ${ln(f)}`}let c=a.match(/^(\w+)\s*=\s*(\[[\s\S]*\])$/);if(c){let[,p,f]=c;return`${p}: ${ln(f)}`}let l=a.match(/^(\w+)\s*=\s*([\s\S]+)$/);if(l){let[,p,f]=l;return`${p}: ${f}`}return s}).join(", ")} }`}function ln(e){let t=e.slice(1,-1).trim();return`[ ${pn(t).map(s=>{let a=s.trim();return a?a.startsWith("{")&&a.endsWith("}")?cn(a):a.startsWith("[")&&a.endsWith("]")?ln(a):s:s}).join(", ")} ]`}function oo(e){let t=0,n=!1,r=!1,s=!1,a="";for(let i=0;i<e.length;i++){let o=e[i];if(!s&&(o==="'"||o==='"'||o==="`")){s=!0,a=o;continue}if(s){o===a&&e[i-1]!=="\\"&&(s=!1);continue}o==="("||o==="{"||o==="["?t++:o===")"||o==="}"||o==="]"?t--:t===0&&(o===":"&&(n=!0),o==="="&&e[i+1]!==">"&&(r=!0))}return n&&!r}function ui(e){let t=0,n=!1,r="";for(let s=0;s<e.length;s++){let a=e[s];if(!n&&(a==="'"||a==='"'||a==="`")){n=!0,r=a;continue}if(n){a===r&&e[s-1]!=="\\"&&(n=!1);continue}if(a==="("||a==="{"||a==="[")t++;else if(a===")"||a==="}"||a==="]")t--;else if(t===0&&a===":")return s}return-1}function Qn(e){let t="",n=0;for(;n<e.length;){let r=e[n];if(r==="'"||r==='"'||r==="`"){let s=r;for(t+=r,n++;n<e.length&&e[n]!==s;)e[n]==="\\"&&(t+=e[n++]),n<e.length&&(t+=e[n++]);n<e.length&&(t+=e[n++]);continue}if(r==="/"&&e[n+1]==="*"){let s=e.indexOf("*/",n+2),a=s===-1?e.slice(n):e.slice(n,s+2);t+=a,n+=a.length;continue}if(r==="/"&&e[n+1]==="/"){let s=e.indexOf(`
58
- `,n),a=s===-1?e.length:s;t+=" ".repeat(a-n),n=a;continue}t+=r,n++}return t}function hn(e,t={}){let n=e,r,s=new Set,a=new Set,i=new Set,o=/\/\*\s*tjs\s*<-\s*\S+\s*\*\//.test(e),u=t.dialect==="js"?!0:t.dialect==="tjs"?!1:o||t.vmTarget,c=u?{tjsEquals:!1,tjsClass:!1,tjsDate:!1,tjsNoeval:!1,tjsStandard:!1,tjsSafeEval:!1,tjsNoVar:!1,tjsSafeAssign:!1}:{tjsEquals:!0,tjsClass:!0,tjsDate:!0,tjsNoeval:!0,tjsStandard:!0,tjsSafeEval:!1,tjsNoVar:!0,tjsSafeAssign:!0};u&&(r="none");let l=e.match(/^(\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*)\s*safety\s+(none|inputs|all)\b/);l&&(r=l[2],e=e.replace(/^(\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*)\s*safety\s+(none|inputs|all)\s*/,"$1"));let p=/^(\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*)\s*(TjsStrict|TjsCompat|TjsEquals|TjsClass|TjsDate|TjsNoeval|TjsNoVar|TjsStandard|TjsSafeEval|TjsSafeAssign)\b/,f;for(;f=e.match(p);){let I=f[2];I==="TjsStrict"?(c.tjsEquals=!0,c.tjsClass=!0,c.tjsDate=!0,c.tjsNoeval=!0,c.tjsNoVar=!0,c.tjsStandard=!0,c.tjsSafeAssign=!0):I==="TjsCompat"?(c.tjsEquals=!1,c.tjsClass=!1,c.tjsDate=!1,c.tjsNoeval=!1,c.tjsNoVar=!1,c.tjsStandard=!1,c.tjsSafeEval=!1,c.tjsSafeAssign=!1):I==="TjsEquals"?c.tjsEquals=!0:I==="TjsClass"?c.tjsClass=!0:I==="TjsDate"?c.tjsDate=!0:I==="TjsNoeval"?c.tjsNoeval=!0:I==="TjsNoVar"?c.tjsNoVar=!0:I==="TjsStandard"?c.tjsStandard=!0:I==="TjsSafeEval"?c.tjsSafeEval=!0:I==="TjsSafeAssign"&&(c.tjsSafeAssign=!0),e=e.replace(new RegExp(`^(\\s*(?:\\/\\/[^\\n]*\\n|\\/\\*[\\s\\S]*?\\*\\/\\s*)*)\\s*${I}\\s*`),"$1")}e=Qn(e),c.tjsStandard&&(e=Vs(e)),e=ti(e),e=si(e);let d=ii(e);e=d.source;let g=d.annotations,y=Ds(e);e=y.source,e=At(e),c.tjsEquals&&!t.vmTarget&&(e=Pt(e)),e=qs(e),e=Ws(e),e=Us(e),e=Js(e),e=zs(e),c.tjsSafeAssign&&(e=Zs(e));let w=Ls(e,{loader:t.moduleLoader,importerPath:t.filename});e=w.source;let{source:k,returnType:S,returnSafety:b}=fn(e,{originalSource:n,requiredParams:s,unsafeFunctions:a,safeFunctions:i});e=k;let _=Gs(e);e=_.source,e=Bs(e);let v=Ks(e,s);e=v.source;let x=Fs(e);e=x.source;let E=[...y.blocks,...w.blocks,...x.blocks],$=Qs(e,t.dangerouslySkipTests);e=$.source;let C=Ys(e,s);e=C.source;for(let I of C.polyCtorClasses)a.add(`${I}$dispatch`);return c.tjsClass&&(e=Xs(e,C.polyCtorClasses)),c.tjsDate&&(e=ei(e)),c.tjsNoeval&&(e=ri(e)),c.tjsNoVar&&(e=ni(e)),e=jt(e,_.extensions),{source:e,returnType:S,returnSafety:b,moduleSafety:r,tjsModes:c,originalSource:n,requiredParams:s,unsafeFunctions:a,safeFunctions:i,wasmBlocks:E,tests:$.tests,testErrors:$.errors,polymorphicNames:v.polymorphicNames,extensions:_.extensions,letAnnotations:g}}function Qe(e,t={}){let{filename:n="<source>",colonShorthand:r=!0,vmTarget:s=!1,dialect:a}=t,{source:i,returnType:o,returnSafety:u,moduleSafety:c,originalSource:l,requiredParams:p,unsafeFunctions:f,safeFunctions:d,wasmBlocks:g,tests:y,testErrors:w,letAnnotations:k,tjsModes:S}=r?hn(e,{vmTarget:s,dialect:a,moduleLoader:t.moduleLoader,filename:t.filename}):{source:e,returnType:void 0,returnSafety:void 0,moduleSafety:void 0,originalSource:e,requiredParams:new Set,unsafeFunctions:new Set,safeFunctions:new Set,wasmBlocks:[],tests:[],testErrors:[],letAnnotations:new Map,tjsModes:{tjsEquals:!1,tjsClass:!1,tjsDate:!1,tjsNoeval:!1,tjsStandard:!1,tjsSafeEval:!1,tjsNoVar:!1,tjsSafeAssign:!1}};try{return{ast:je(i,{ecmaVersion:2022,sourceType:"module",locations:!0,allowReturnOutsideFunction:!1}),returnType:o,returnSafety:u,moduleSafety:c,originalSource:l,requiredParams:p,unsafeFunctions:f,safeFunctions:d,wasmBlocks:g,tests:y,testErrors:w,letAnnotations:k,tjsModes:S}}catch(b){let _=b.loc||{line:1,column:0};throw new te(b.message.replace(/\s*\(\d+:\d+\)$/,""),_,l,n)}}function ci(e,t){for(let a of e.body){if(a.type==="ImportDeclaration")throw new te("Imports are not supported. All atoms must be registered with the VM.",a.loc?.start||{line:1,column:0},void 0,t);if(a.type==="ExportNamedDeclaration"||a.type==="ExportDefaultDeclaration")throw new te("Exports are not supported. The function is automatically exported.",a.loc?.start||{line:1,column:0},void 0,t);if(a.type==="ClassDeclaration")throw new te("Classes are not supported. Agent99 uses functional composition.",a.loc?.start||{line:1,column:0},void 0,t)}let n=e.body.filter(a=>a.type==="FunctionDeclaration");if(n.length===0)throw new te("Source must contain a function declaration",{line:1,column:0},void 0,t);let r=n[n.length-1],s=new Map;for(let a=0;a<n.length-1;a++){let i=n[a],o=i.id?.name;if(!o)throw new te("Helper function must have a name",i.loc?.start||{line:1,column:0},void 0,t);if(s.has(o))throw new te(`Duplicate helper function name: ${o}`,i.loc?.start||{line:1,column:0},void 0,t);if(o===r.id?.name)throw new te(`Helper function cannot share a name with the entry function: ${o}`,i.loc?.start||{line:1,column:0},void 0,t);s.set(o,i)}return{entry:r,helpers:s}}function Nt(e,t){let n={params:{}};if(!t.loc)return n;let r=e.substring(0,t.start),s=[...r.matchAll(/(?<=^[ \t]*)\/\*#([\s\S]*?)\*\//gm)];if(s.length>0){let l=s[s.length-1],p=r.substring(l.index+l[0].length);if(/^(?:\s|\/\/[^\n]*)*$/.test(p)){let f=l[1],d=f.split(`
59
- `),g=d.filter(y=>y.trim().length>0).reduce((y,w)=>{let k=w.match(/^(\s*)/)?.[1].length||0;return Math.min(y,k)},1/0);return g>0&&g<1/0&&(f=d.map(y=>y.slice(g)).join(`
60
- `)),n.description=f.trim(),n}}let a=r.match(/\/\*\*[\s\S]*?\*\/\s*$/);if(!a)return n;let i=a[0],o=i.match(/\/\*\*\s*\n?\s*\*?\s*([^@\n][^\n]*)/m);o&&(n.description=o[1].trim());let u=/@param\s+(?:\{[^}]+\}\s+)?(\w+)\s*-?\s*(.*)/g,c;for(;(c=u.exec(i))!==null;)n.params[c[1]]=c[2].trim();return n}function ue(e){switch(e.type){case"Literal":{let t=e.value;if(t===null)return{kind:"null"};if(typeof t=="string")return{kind:"string"};if(typeof t=="number"){let n=e.raw;return n&&n.includes(".")?{kind:"number"}:{kind:"integer"}}return typeof t=="boolean"?{kind:"boolean"}:{kind:"any"}}case"ArrayExpression":{let t=e.elements;if(t.length===0)return{kind:"array",items:{kind:"any"}};let n=t.filter(i=>i!=null).map(i=>ue(i));if(n.length===0)return{kind:"array",items:{kind:"any"}};let r=new Map;for(let i of n){let o=JSON.stringify(i);r.has(o)||r.set(o,i)}let s=[...r.values()];return{kind:"array",items:s.length===1?s[0]:{kind:"union",members:s}}}case"ObjectExpression":{let t=e.properties,n={};for(let r of t)if(r.type==="Property"&&r.key.type==="Identifier"){let s=r.key.name;n[s]=ue(r.value)}return{kind:"object",shape:n}}case"LogicalExpression":{let{operator:t,left:n,right:r}=e;return t==="||"?ue(n):t==="&&"||t==="??"?ue(r):{kind:"any"}}case"BinaryExpression":{let{operator:t,left:n,right:r}=e;if(t==="|"){let s=ue(n),a=ue(r);return a.kind==="null"?{...s,nullable:!0}:s.kind==="null"?{...a,nullable:!0}:{kind:"union",members:[s,a]}}return{kind:"any"}}case"Identifier":return e.name==="undefined"?{kind:"undefined"}:{kind:"any"};case"ArrowFunctionExpression":case"FunctionExpression":{let t=e,n=t.params.map(s=>uo(s)),r={kind:"any"};return t.type==="ArrowFunctionExpression"&&t.body&&t.body.type!=="BlockStatement"&&(r=ue(t.body)),{kind:"function",params:n,returns:r}}case"UnaryExpression":{let t=e.operator,n=e.argument;if(t==="+"&&n.type==="Literal"&&typeof n.value=="number")return{kind:"non-negative-integer"};if(t==="-"&&n.type==="Literal"&&typeof n.value=="number"){let s=n.raw;return s&&s.includes(".")?{kind:"number"}:{kind:"integer"}}return{kind:"any"}}default:return{kind:"any"}}}function uo(e){return e.type==="Identifier"?{name:e.name,type:{kind:"any"}}:e.type==="AssignmentPattern"&&e.left?.type==="Identifier"?{name:e.left.name,type:ue(e.right)}:e.type==="RestElement"&&e.argument?.type==="Identifier"?{name:`...${e.argument.name}`,type:{kind:"array",items:{kind:"any"}}}:{name:"?",type:{kind:"any"}}}function Ge(e,t){if(e.type==="Identifier")return{name:e.name,type:{kind:"any"},required:!0};if(e.type==="AssignmentPattern"){let{left:n,right:r}=e;if(n.type!=="Identifier")throw new K("Only simple parameter names are supported",Z(e));let s=n.name,a=t?.has(s)??!1,i=ue(r),o=Ie(r);return{name:s,type:i,required:a,default:a?null:o,example:o,loc:{start:e.start,end:e.end}}}if(e.type==="ObjectPattern"){let n=e.properties,r={},s={};for(let a of n)if(a.type==="Property"){let i=a.key.type==="Identifier"?a.key.name:String(a.key.value);if(a.value.type==="Identifier")r[i]={kind:"any"},s[i]={name:i,type:{kind:"any"},required:!0};else if(a.value.type==="AssignmentPattern"){let o=Ge(a.value,t),u=t?.has(i)??!1;r[i]=o.type,s[i]={name:i,type:o.type,required:u,default:u?null:o.example,example:o.example}}}return{name:"__destructured__",type:{kind:"object",shape:r,destructuredParams:s},required:!0}}throw new K(`Unsupported parameter pattern: ${e.type}`,Z(e))}function Ie(e){switch(e.type){case"Literal":return e.value;case"ArrayExpression":return e.elements.map(t=>t?Ie(t):null);case"ObjectExpression":{let t={};for(let n of e.properties)n.type==="Property"&&n.key.type==="Identifier"&&(t[n.key.name]=Ie(n.value));return t}case"UnaryExpression":if(e.operator==="-"){let t=Ie(e.argument);return typeof t=="number"?-t:void 0}if(e.operator==="+"){let t=Ie(e.argument);return typeof t=="number"?+t:void 0}return;case"BinaryExpression":{let{operator:t,left:n}=e;return t==="|"?Ie(n):void 0}case"LogicalExpression":{let{operator:t,left:n,right:r}=e;return t==="&&"&&n.type==="Literal"&&n.value===null?null:t==="||"||t==="??"?Ie(n)??Ie(r):void 0}default:return}}function li(e){try{let t=$t(e,0,{ecmaVersion:2022});return ue(t)}catch{return{kind:"any"}}}function Yn(e){switch(e.kind){case"string":return e.nullable?"string | null":"string";case"number":return e.nullable?"number | null":"number";case"integer":return e.nullable?"integer | null":"integer";case"non-negative-integer":return e.nullable?"non-negative integer | null":"non-negative integer";case"boolean":return e.nullable?"boolean | null":"boolean";case"null":return"null";case"any":return"any";case"array":{let t=e.items?Yn(e.items):"any";return e.nullable?`${t}[] | null`:`${t}[]`}case"object":{if(!e.shape||Object.keys(e.shape).length===0)return e.nullable?"object | null":"object";let t=Object.entries(e.shape).map(([n,r])=>`${n}: ${Yn(r)}`).join(", ");return e.nullable?`{ ${t} } | null`:`{ ${t} }`}case"union":return e.members?.map(Yn).join(" | ")||"any";default:return"any"}}function dn(e){switch(e.kind){case"string":return{type:"string"};case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"null":return{};case"undefined":return{};case"any":return{};case"array":return{type:"array",items:e.items?dn(e.items):{}};case"object":if(e.shape){let t={};for(let[n,r]of Object.entries(e.shape))t[n]=dn(r);return{type:"object",properties:t,additionalProperties:!1}}return{type:"object"};case"union":return e.members?{oneOf:e.members.map(dn)}:{};default:return{}}}function co(e){let t={},n=[];for(let[r,s]of Object.entries(e))t[r]=dn(s.type),s.required&&n.push(r);return{type:"object",properties:t,required:n.length>0?n:void 0,additionalProperties:!1}}function Xn(e,t,n,r={},s,a){let i=Nt(t,e),o=new Map;for(let S of e.params){let b=Ge(S,s);if(b.name==="__destructured__"&&b.type.kind==="object"&&b.type.destructuredParams)for(let[_,v]of Object.entries(b.type.destructuredParams))o.set(_,{...v,description:i.params[_]});else b.description=i.params[b.name],o.set(b.name,b)}let u;n&&(u=li(n));let c={depth:0,locals:new Map,parameters:o,atoms:new Set(Object.keys(r.atoms||{})),warnings:[],source:t,filename:r.filename||"<source>",options:r,helpers:a,helperSteps:a?new Map:void 0,helperTransforming:a?new Set:void 0},l=Ee(e.body,c),p=[],f=[],d=[];for(let[S,b]of o.entries())b.required?f.push(S):b.default!==void 0?d.push({name:S,defaultValue:b.default}):f.push(S);f.length>0&&p.push({op:"varsImport",keys:f});for(let{name:S,defaultValue:b}of d)p.push({op:"varsImport",keys:[S]}),p.push({op:"if",condition:{$expr:"binary",op:"==",left:{$expr:"ident",name:S},right:{$expr:"literal",value:null}},then:[{op:"varSet",key:S,value:b}]});p.push(...l);let g=Object.fromEntries(o),y={name:e.id?.name||"anonymous",description:i.description,parameters:g,returns:u},w=co(g),k=c.helperSteps&&c.helperSteps.size>0?Object.fromEntries(c.helperSteps):void 0;return{ast:{op:"seq",steps:p,inputSchema:w,...k&&{helpers:k}},signature:y,warnings:c.warnings}}function Ee(e,t){let n=[];for(let r of e.body){let s=Rt(r,t);s&&(Array.isArray(s)?n.push(...s):n.push(s))}return n}function Rt(e,t){switch(e.type){case"VariableDeclaration":return lo(e,t);case"ExpressionStatement":return fo(e,t);case"IfStatement":return ho(e,t);case"WhileStatement":return mo(e,t);case"ForOfStatement":return go(e,t);case"TryStatement":return yo(e,t);case"ReturnStatement":return bo(e,t);case"ThrowStatement":throw new K("'throw' is not supported in AsyncJS. Use Error('message') to trigger error flow",Z(e),t.source,t.filename);case"BlockStatement":return{op:"scope",steps:Ee(e,Se(t))};case"EmptyStatement":return null;default:throw new K(`Unsupported statement type: ${e.type}`,Z(e),t.source,t.filename)}}function lo(e,t){let n=[],r=e.kind==="const",s=r?"constSet":"varSet";for(let a of e.declarations){if(a.id.type!=="Identifier")throw new K("Only simple variable names are supported",Z(a),t.source,t.filename);let i=a.id.name;if(a.init){let{step:o,resultVar:u}=Ye(a.init,t,i,r);o?n.push(o):u!==i&&n.push({op:s,key:i,value:u});let c=ue(a.init);t.locals.set(i,c)}else{if(r)throw new K("const declarations must be initialized",Z(a),t.source,t.filename);n.push({op:"varSet",key:i,value:null}),t.locals.set(i,{kind:"any",nullable:!0})}}return n}function fo(e,t){let n=e.expression;if(n.type==="AssignmentExpression")return po(n,t);if(n.type==="CallExpression"){let{step:r,resultVar:s}=Ye(n,t);return r||(s?{op:"varSet",key:"_",value:s}:null)}return t.warnings.push({message:"Expression statement has no effect",line:Z(e).line,column:Z(e).column}),null}function po(e,t){if(e.left.type!=="Identifier")throw new K("Only simple variable assignment is supported",Z(e),t.source,t.filename);let n=e.left.name,{step:r,resultVar:s}=Ye(e.right,t,n);return r||{op:"varSet",key:n,value:s}}function ho(e,t){let n=G(e.test,t),r=e.consequent.type==="BlockStatement"?Ee(e.consequent,Se(t)):[Rt(e.consequent,t)].filter(Boolean),s;return e.alternate&&(s=e.alternate.type==="BlockStatement"?Ee(e.alternate,Se(t)):[Rt(e.alternate,t)].filter(Boolean)),{op:"if",condition:n,then:r,...s&&{else:s}}}function mo(e,t){let n=G(e.test,t),r=e.body.type==="BlockStatement"?Ee(e.body,Se(t)):[Rt(e.body,t)].filter(Boolean);return{op:"while",condition:n,body:r}}function go(e,t){let n;if(e.left.type==="VariableDeclaration"){let i=e.left.declarations[0];if(i.id.type!=="Identifier")throw new K("Only simple variable names are supported in for...of",Z(e.left),t.source,t.filename);n=i.id.name}else if(e.left.type==="Identifier")n=e.left.name;else throw new K("Unsupported for...of left-hand side",Z(e.left),t.source,t.filename);let r=ie(e.right,t),s=Se(t);s.locals.set(n,{kind:"any"});let a=e.body.type==="BlockStatement"?Ee(e.body,s):[Rt(e.body,s)].filter(Boolean);return{op:"map",items:r,as:n,steps:a}}function yo(e,t){let n=Ee(e.block,Se(t)),r,s;if(e.handler){let a=Se(t);e.handler.param?.type==="Identifier"&&(s=e.handler.param.name,a.locals.set(s,{kind:"any"})),r=Ee(e.handler.body,a)}return{op:"try",try:n,...r&&{catch:r},...s&&{catchParam:s}}}function bo(e,t){if(!e.argument)return{op:"return",value:{}};let{step:n,resultVar:r}=Ye(e.argument,t,"__returnVal__");return n?[n,{op:"return",value:r}]:{op:"return",value:ie(e.argument,t)}}var pi=new Set(["Math","JSON","Array","Object","String","Number","console","Date","Schema"]),xo=new Set(["parseInt","parseFloat","isNaN","isFinite","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent","Set","Date","filter"]),Mt=new Set(["RegExp","Promise","Map","WeakSet","WeakMap","Symbol","Proxy","Reflect","Function","eval","setTimeout","setInterval","fetch","require","import","process","window","document","global","globalThis"]),_o=new Set(["toUpperCase","toLowerCase","trim","trimStart","trimEnd","charAt","charCodeAt","codePointAt","concat","includes","indexOf","lastIndexOf","startsWith","endsWith","slice","substring","substr","replace","replaceAll","match","search","padStart","padEnd","repeat","normalize","localeCompare","toString","valueOf","at","reverse","sort","fill","copyWithin","flat","flatMap","every","some","forEach","add","remove","has","clear","toArray","union","intersection","diff","format","isBefore","isAfter"]);function wo(e){if(e.callee.type==="Identifier"){let t=e.callee.name;return xo.has(t)||Mt.has(t)}if(e.callee.type==="MemberExpression"){let t=e.callee;if(t.object.type==="Identifier"){let n=t.object.name;if(pi.has(n)||Mt.has(n))return!0}if(t.property.type==="Identifier"){let n=t.property.name;if(_o.has(n))return!0}}return!1}function So(e){if(e.object.type==="Identifier"){let t=e.object.name;return pi.has(t)||Mt.has(t)}return!1}var fi={RegExp:"RegExp is not available. Use string methods or the regexMatch atom.",Promise:"Promise is not needed. All operations are implicitly async.",Map:"Map is not available. Use plain objects instead.",WeakSet:"WeakSet is not available.",WeakMap:"WeakMap is not available.",Symbol:"Symbol is not available.",Proxy:"Proxy is not available.",Reflect:"Reflect is not available.",Function:"Function constructor is not available. Define functions normally.",eval:"eval is not available. Code is compiled, not evaluated.",setTimeout:"setTimeout is not available. Use the delay atom.",setInterval:"setInterval is not available. Use while loops with delay.",fetch:"fetch is not available. Use the httpFetch atom.",require:"require is not available. Atoms must be registered with the VM.",import:"import is not available. Atoms must be registered with the VM.",process:"process is not available. AsyncJS runs in a sandboxed environment.",window:"window is not available. AsyncJS runs in a sandboxed environment.",document:"document is not available. AsyncJS runs in a sandboxed environment.",global:"global is not available. AsyncJS runs in a sandboxed environment.",globalThis:"globalThis is not available. Use builtins directly."};function vo(e){if(e.callee.type==="Identifier"){let t=e.callee.name;if(Mt.has(t))return fi[t]||`${t} is not available in AsyncJS.`}if(e.callee.type==="MemberExpression"){let t=e.callee;if(t.object.type==="Identifier"){let n=t.object.name;if(Mt.has(n))return fi[n]||`${n} is not available in AsyncJS.`}}return null}function hi(e){return{Date:" Use Date() or Date('2024-01-15') instead - no 'new' needed.",Set:" Use Set([items]) instead - no 'new' needed.",Map:" Use plain objects instead of Map.",Array:" Use array literals like [1, 2, 3] instead.",Object:" Use object literals like { key: value } instead.",Error:" Return an error object like { error: 'message' } instead.",RegExp:" Use string methods or the regexMatch atom.",Promise:" Not needed - all operations are implicitly async.",WeakSet:" WeakSet is not available.",WeakMap:" WeakMap is not available."}[e]||" Use factory functions or object literals instead."}function Ye(e,t,n,r){let s=r?"constSet":"varSet";if(e.type==="ChainExpression")return Ye(e.expression,t,n,r);if(e.type==="NewExpression"){let i=e,o="constructor";i.callee.type==="Identifier"&&(o=i.callee.name);let u=hi(o);throw new K(`The 'new' keyword is not supported in AsyncJS.${u}`,Z(e),t.source,t.filename)}if(e.type==="CallExpression"){let i=vo(e);if(i)throw new K(i,Z(e),t.source,t.filename)}if(e.type==="CallExpression"&&wo(e)){let i=G(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}if(e.type==="MemberExpression"&&So(e)){let i=G(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}if(e.type==="CallExpression")return ko(e,t,n,r);if(e.type==="TemplateLiteral")return $o(e,t,n,r);if(e.type==="BinaryExpression"||e.type==="LogicalExpression"||e.type==="UnaryExpression"){let i=G(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}return{step:null,resultVar:ie(e,t)}}function ko(e,t,n,r){let s,a=!1,i;if(e.callee.type==="Identifier")s=e.callee.name;else if(e.callee.type==="MemberExpression"){let u=e.callee;if(u.property.type==="Identifier")s=u.property.name,a=!0,i=ie(u.object,t);else throw new K("Computed method names are not supported",Z(e),t.source,t.filename)}else throw new K("Only named function calls are supported",Z(e),t.source,t.filename);if(a)return To(s,i,e.arguments,t,n,r);if(s==="console"&&e.callee.type,t.helpers?.has(s)){let u=Eo(s,t,e),c=e.arguments.map(l=>ie(l,t));if(c.length!==u.length)throw new K(`Helper '${s}' expects ${u.length} argument(s), got ${c.length}`,Z(e),t.source,t.filename);return{step:{op:"callLocal",name:s,args:c,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}let o=Co(e,t);return{step:{op:s,...o,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}function Eo(e,t,n){let r=t.helpers.get(e),s=[];for(let a of r.params){let i;if(a.type==="Identifier"?i=a:a.type==="AssignmentPattern"&&a.left?.type==="Identifier"&&(i=a.left),!i)throw new K(`Helper '${e}' parameters must be plain identifiers (optionally with an example value); destructuring is not supported`,a.loc?.start??Z(n),t.source,t.filename);s.push(i.name)}if(t.helperSteps.has(e)||t.helperTransforming.has(e))return s;t.helperTransforming.add(e);try{let a={depth:0,locals:new Map,parameters:new Map(s.map(o=>[o,{name:o,type:{kind:"any"},required:!0}])),atoms:t.atoms,warnings:t.warnings,source:t.source,filename:t.filename,options:t.options,helpers:t.helpers,helperSteps:t.helperSteps,helperTransforming:t.helperTransforming},i=Ee(r.body,a);t.helperSteps.set(e,{steps:i,paramNames:s})}finally{t.helperTransforming.delete(e)}return s}function To(e,t,n,r,s,a){switch(e){case"map":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],u=o?.type==="Identifier"?o.name:"item",c=Se(r);c.locals.set(u,{kind:"any"});let l;if(i.body.type==="BlockStatement")l=Ee(i.body,c);else{let{step:p,resultVar:f}=Ye(i.body,c,"result");l=p?[p]:[{op:"varSet",key:"result",value:f}]}return{step:{op:"map",items:t,as:u,steps:l,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"filter":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],u=o?.type==="Identifier"?o.name:"item",c=Se(r);c.locals.set(u,{kind:"any"});let l;if(i.body.type==="BlockStatement")throw new K("filter callback must be an expression, not a block",Z(n[0]),r.source,r.filename);return l=G(i.body,c),{step:{op:"filter",items:t,as:u,condition:l,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"find":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],u=o?.type==="Identifier"?o.name:"item",c=Se(r);c.locals.set(u,{kind:"any"});let l;if(i.body.type==="BlockStatement")throw new K("find callback must be an expression, not a block",Z(n[0]),r.source,r.filename);return l=G(i.body,c),{step:{op:"find",items:t,as:u,condition:l,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"reduce":if(n.length>=2&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],u=i.params[1],c=o?.type==="Identifier"?o.name:"acc",l=u?.type==="Identifier"?u.name:"item",p=Se(r);p.locals.set(c,{kind:"any"}),p.locals.set(l,{kind:"any"});let f;if(i.body.type==="BlockStatement")f=Ee(i.body,p);else{let{step:g,resultVar:y}=Ye(i.body,p,"result");f=g?[g]:[{op:"varSet",key:"result",value:y}]}let d=ie(n[1],r);return{step:{op:"reduce",items:t,as:l,accumulator:c,initial:d,steps:f,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"slice":break;case"push":return{step:{op:"push",list:t,item:ie(n[0],r),...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s};case"join":return{step:{op:"join",list:t,sep:n.length>0?ie(n[0],r):"",...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s};case"split":return{step:{op:"split",str:t,sep:n.length>0?ie(n[0],r):"",...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}return r.warnings.push({message:`Unknown method '${e}' - treating as atom call`,line:0,column:0}),{step:{op:e,receiver:t,args:n.map(i=>ie(i,r)),...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}function $o(e,t,n,r){let s="",a={};for(let i=0;i<e.quasis.length;i++)if(s+=e.quasis[i].value.cooked||e.quasis[i].value.raw,i<e.expressions.length){let o=e.expressions[i],u=`_${i}`;a[u]=ie(o,t),s+=`{{${u}}}`}return{step:{op:"template",tmpl:s,vars:a,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}function G(e,t){switch(e.type){case"Literal":return{$expr:"literal",value:e.value};case"Identifier":return{$expr:"ident",name:e.name};case"MemberExpression":{let n=e,r=G(n.object,t),s=n.optional===!0;if(n.computed){let i=n.property;return i.type==="Literal"?{$expr:"member",object:r,property:String(i.value),computed:!0,...s&&{optional:!0}}:{$expr:"member",object:r,property:G(i,t),computed:!0,...s&&{optional:!0}}}let a=n.property.name;return{$expr:"member",object:r,property:a,...s&&{optional:!0}}}case"ChainExpression":return G(e.expression,t);case"BinaryExpression":{let n=e;return{$expr:"binary",op:n.operator,left:G(n.left,t),right:G(n.right,t)}}case"LogicalExpression":{let n=e;return{$expr:"logical",op:n.operator,left:G(n.left,t),right:G(n.right,t)}}case"UnaryExpression":{let n=e;return{$expr:"unary",op:n.operator,argument:G(n.argument,t)}}case"ConditionalExpression":{let n=e;return{$expr:"conditional",test:G(n.test,t),consequent:G(n.consequent,t),alternate:G(n.alternate,t)}}case"ArrayExpression":return{$expr:"array",elements:e.elements.filter(r=>r!==null).map(r=>G(r,t))};case"ObjectExpression":{let n=e,r=[];for(let s of n.properties)if(s.type==="Property"){let a=s.key.type==="Identifier"?s.key.name:String(s.key.value);r.push({key:a,value:G(s.value,t)})}return{$expr:"object",properties:r}}case"CallExpression":{let n=e;if(n.callee.type==="MemberExpression"){let r=n.callee,s=r.property.type==="Identifier"?r.property.name:String(r.property.value),a=r.optional===!0||n.optional===!0;return{$expr:"methodCall",object:G(r.object,t),method:s,arguments:n.arguments.map(i=>G(i,t)),...a&&{optional:!0}}}if(n.callee.type==="Identifier"){let r=n.callee.name;if(t.helpers?.has(r))throw new K(`Helper '${r}' cannot be called inside an expression. Assign its result to a variable first: const result = ${r}(...); then use result.`,Z(e),t.source,t.filename);return{$expr:"call",callee:r,arguments:n.arguments.map(s=>G(s,t))}}throw new K("Complex function calls in expressions should be lifted to statements",Z(e),t.source,t.filename)}case"NewExpression":{let n=e,r="constructor";n.callee.type==="Identifier"&&(r=n.callee.name);let s=hi(r);throw new K(`The 'new' keyword is not supported in AsyncJS.${s}`,Z(e),t.source,t.filename)}case"TemplateLiteral":throw new K("Template literals inside expressions are not supported. Assign to a variable first: const msg = `hello ${name}`; then use msg",Z(e),t.source,t.filename);default:throw new K(`Unsupported expression type in condition: ${e.type}`,Z(e),t.source,t.filename)}}function ie(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":{let n=e;if(n.optional===!0)return G(e,t);let s=ie(n.object,t);if(s&&typeof s=="object"&&s.$expr){let i=n.computed?String(n.property.value):n.property.name;return{$expr:"member",object:s,property:i,...n.computed&&{computed:!0}}}if(n.computed)return G(e,t);let a=n.property.name;return typeof s=="string"?`${s}.${a}`:s&&s.$kind==="arg"?{$kind:"arg",path:`${s.path}.${a}`}:`${s}.${a}`}case"ChainExpression":return ie(e.expression,t);case"ArrayExpression":return e.elements.map(n=>n?ie(n,t):null);case"ObjectExpression":{let n={};for(let r of e.properties)if(r.type==="Property"){let s=r.key.type==="Identifier"?r.key.name:String(r.key.value);n[s]=ie(r.value,t)}return n}case"TemplateLiteral":return G(e,t);case"CallExpression":return G(e,t);case"BinaryExpression":case"LogicalExpression":case"UnaryExpression":case"ConditionalExpression":return G(e,t);default:return null}}function Co(e,t){if(e.arguments.length===1&&e.arguments[0].type==="ObjectExpression"){let n=e.arguments[0],r={};for(let s of n.properties)if(s.type==="Property"){let a=s.key.type==="Identifier"?s.key.name:String(s.key.value);r[a]=ie(s.value,t)}return r}return{args:e.arguments.map(n=>ie(n,t))}}function Ao(e,t){let n=t;for(;n>0&&e[n-1]!==`
61
- `;)n--;if(e.slice(n,t).includes("//"))return!0;let s=0,a=!1;for(;s<t;)!a&&e.slice(s,s+2)==="/*"?(a=!0,s+=2):a&&e.slice(s,s+2)==="*/"?(a=!1,s+=2):s++;return a}function Po(e){let t=[],n=/\/\*test\s+'([^']*)'\s*\{([\s\S]*?)\}\s*\*\/|\/\*test\s+"([^"]*)"\s*\{([\s\S]*?)\}\s*\*\/|\/\*test\s+`([^`]*)`\s*\{([\s\S]*?)\}\s*\*\/|\/\*test\s*\{([\s\S]*?)\}\s*\*\//g,r;for(;(r=n.exec(e))!==null;){let s=r[1]||r[3]||r[5]||`embedded test ${t.length+1}`,a=(r[2]||r[4]||r[6]||r[7]||"").trim();t.push({description:s,body:a,line:er(e,r.index)})}return t}function tr(e){let t=[],n=[],r=Po(e);t.push(...r);let s=/test\s+'([^']*)'\s*\{|test\s+"([^"]*)"\s*\{|test\s+`([^`]*)`\s*\{|test\s*\(\s*'([^']*)'\s*\)\s*\{|test\s*\(\s*"([^"]*)"\s*\)\s*\{|test\s*\(\s*`([^`]*)`\s*\)\s*\{|test\s*\{/g,a=/mock\s*\{/g,i=e,o,u=[];for(;(o=s.exec(e))!==null;){let f=o.index;if(Ao(e,f))continue;let d=o[1]||o[2]||o[3]||o[4]||o[5]||o[6]||`test ${t.length+1}`,g=o.index+o[0].length,y=di(e,g-1);if(y===-1)continue;let w=e.slice(g,y).trim();t.push({description:d,body:w,line:er(e,f)}),u.push({start:f,end:y+1,desc:d})}let c=[];for(;(o=a.exec(e))!==null;){let f=o.index,d=o.index+o[0].length,g=di(e,d-1);if(g===-1)continue;let y=e.slice(d,g).trim();n.push({body:y,line:er(e,f)}),c.push({start:f,end:g+1})}let l=[...u,...c].sort((f,d)=>d.start-f.start);for(let f of l)i=i.slice(0,f.start)+i.slice(f.end);i=i.replace(/\n\s*\n\s*\n/g,`
53
+ `,E+=` return __tjs.typeError('${u}', 'no matching constructor', a)
54
+ `,E+=`}
55
+ `,i=i.slice(0,l)+S+i.slice(p);let b=l+S.length;i=i.slice(0,b)+E+i.slice(b)}return{source:i,polyCtorClasses:n}}function li(e,t=new Set){let n=/\bclass\s+(\w+)(\s+extends\s+\w+)?\s*\{/g,r="",s=0,a;for(;(a=n.exec(e))!==null;){let i=a[1],o=a[2]||"",u=a.index,c=u+a[0].length-1,l=1,p=c+1;for(;p<e.length&&l>0;){let f=e[p];f==="{"?l++:f==="}"&&l--,p++}if(l===0){let f=p,d=e.slice(c,f);r+=e.slice(s,u),r+=`let ${i} = class ${i}${o} ${d}; `,t.has(i)?r+=`${i} = new Proxy(${i}, { apply(t, _, a) { return ${i}$dispatch(t, a) }, construct(t, a) { return ${i}$dispatch(t, a) } });`:r+=`${i} = new Proxy(${i}, { apply(t, _, a) { return Reflect.construct(t, a) } });`,s=f}}return r+=e.slice(s),r}function fi(e){let t=[{pattern:/\bnew\s+Date\b/,message:"new Date() is not allowed in TjsDate mode. Use Timestamp.now()/Timestamp.from() for wall-clock dates, or performance.now() for a monotonic counter (timing, id generation)"},{pattern:/\bDate\.now\b/,message:"Date.now() is not allowed in TjsDate mode. Use Timestamp.now() for a wall-clock date, or performance.now() for a monotonic counter (timing, id generation)"},{pattern:/\bDate\.parse\b/,message:"Date.parse() is not allowed in TjsDate mode. Use Timestamp.parse()"},{pattern:/\bDate\.UTC\b/,message:"Date.UTC() is not allowed in TjsDate mode. Use Timestamp.from()"}];for(let{pattern:n,message:r}of t)if(n.test(e))throw new Error(r);return e}function pi(e){let t=new Set,n=/\bconst!\s+(\w+)\b/g,r;for(;(r=n.exec(e))!==null;)t.add(r[1]);if(t.size===0)return e;e=e.replace(/\bconst!\s+/g,"const ");let s=e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/[^\n]*/g,"");for(let a of t){if(new RegExp(`\\b${a}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])\\s*(?:=(?!=)|\\+\\+|--|\\+=|-=|\\*=|\\/=|%=|&&=|\\|\\|=|\\?\\?=|<<=|>>=|>>>=|\\^=|&=|\\|=)`,"g").test(s))throw new Error(`Cannot mutate immutable binding '${a}'. const! bindings are read-only at compile time.`);if(new RegExp(`(?:\\+\\+|--)\\s*${a}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])`,"g").test(s))throw new Error(`Cannot mutate immutable binding '${a}'. const! bindings are read-only at compile time.`);if(new RegExp(`\\bdelete\\s+${a}\\s*(?:\\.[\\w]+|\\[[^\\]]+\\])`,"g").test(s))throw new Error(`Cannot mutate immutable binding '${a}'. const! bindings are read-only at compile time.`);let c="push|pop|splice|shift|unshift|sort|reverse|fill|copyWithin|set";if(new RegExp(`\\b${a}\\s*\\.\\s*(?:${c})\\s*\\(`,"g").test(s))throw new Error(`Cannot call mutating method on immutable binding '${a}'. const! bindings are read-only at compile time.`)}return e}function hi(e){if(/(?<![a-zA-Z_$])\bvar\s+/.test(e))throw new Error("var is not allowed in TjsNoVar mode. Use const or let instead.");return e}function di(e){if(/(?<![A-Za-z_$])\beval\s*\(/.test(e))throw new Error("eval() is not allowed in TjsNoeval mode. Use Eval() from TJS runtime for safe evaluation.");if(/\bnew\s+Function\s*\(/.test(e))throw new Error("new Function() is not allowed in TjsNoeval mode. Use SafeFunction() from TJS runtime.");return e}function mi(e){if(!e.includes("!."))return e;let t="",n=0,r="normal",s=0;for(;n<e.length;){let a=e[n],i=e[n+1];if(r==="normal"){if(a==="/"&&i==="/"){r="line-comment",t+=a,n++;continue}if(a==="/"&&i==="*"){r="block-comment",t+=a,n++;continue}if(a==="'"){r="string-single",t+=a,n++;continue}if(a==='"'){r="string-double",t+=a,n++;continue}if(a==="`"){r="string-template",s++,t+=a,n++;continue}if(a==="!"&&i==="."&&n+2<e.length&&/[a-zA-Z_$]/.test(e[n+2])){let o=t.length,u=Eo(t);if(u<o){let c=t.slice(u);t=t.slice(0,u);let l=n+2;for(;l<e.length&&/[\w$]/.test(e[l]);)l++;let p=e.slice(n+2,l);t+=`__tjs.bang(${c},'${p}')`,n=l;continue}}t+=a,n++}else r==="line-comment"?(t+=a,a===`
56
+ `&&(r="normal"),n++):r==="block-comment"?(t+=a,a==="*"&&i==="/"?(t+=i,r="normal",n+=2):n++):r==="string-single"?(t+=a,a==="\\"?(t+=i||"",n+=2):(a==="'"&&(r="normal"),n++)):r==="string-double"?(t+=a,a==="\\"?(t+=i||"",n+=2):(a==='"'&&(r="normal"),n++)):r==="string-template"?(t+=a,a==="\\"?(t+=i||"",n+=2):a==="`"?(s--,r=s>0?"string-template":"normal",n++):a==="$"&&i==="{"?(t+=i,n+=2,r="normal"):n++):(t+=a,n++)}return t}function Eo(e){let t=e.length-1;for(;t>=0&&/\s/.test(e[t]);)t--;if(t<0)return e.length;for(;t>=0;){let n=e[t];if(/[\w$]/.test(n)){for(;t>=0&&/[\w$]/.test(e[t]);)t--;if(t>=0&&e[t]==="."){t>=1&&e[t-1]==="?"?t-=2:t--;continue}return t+1}else if(n===")"){if(t=Gs(e,t,"(",")"),t<0)return 0;if(t--,t>=0&&/[\w$]/.test(e[t]))continue;if(t>=0&&e[t]==="."){t>=1&&e[t-1]==="?"?t-=2:t--;continue}return t+1}else if(n==="]"){if(t=Gs(e,t,"[","]"),t<0)return 0;if(t--,t>=0&&/[\w$]/.test(e[t]))continue;if(t>=0&&e[t]==="."){t>=1&&e[t-1]==="?"?t-=2:t--;continue}return t+1}else return t+1}return 0}function Gs(e,t,n,r){let s=1;for(t--;t>=0&&s>0;)e[t]===r?s++:e[t]===n&&s--,s>0&&t--;return t}function gi(e){let t=new Map;if(!e.includes("let "))return{source:e,annotations:t};let n=[],r=0,s="normal",a=[];for(;r<e.length;){let o=e[r],u=e[r+1];switch(s){case"single-string":if(o==="\\"&&r+1<e.length){r+=2;continue}o==="'"&&(s="normal"),r++;continue;case"double-string":if(o==="\\"&&r+1<e.length){r+=2;continue}o==='"'&&(s="normal"),r++;continue;case"template-string":if(o==="\\"&&r+1<e.length){r+=2;continue}if(o==="$"&&u==="{"){r+=2,a.push(1),s="normal";continue}o==="`"&&(s="normal"),r++;continue;case"line-comment":o===`
57
+ `&&(s="normal"),r++;continue;case"block-comment":if(o==="*"&&u==="/"){r+=2,s="normal";continue}r++;continue;case"regex":if(o==="\\"&&r+1<e.length){r+=2;continue}if(o==="["){for(r++;r<e.length&&e[r]!=="]";)e[r]==="\\"&&r+1<e.length?r+=2:r++;r<e.length&&r++;continue}if(o==="/"){for(r++;r<e.length&&/[gimsuy]/.test(e[r]);)r++;s="normal";continue}r++;continue;case"normal":if(a.length>0){if(o==="{")a[a.length-1]++;else if(o==="}"&&(a[a.length-1]--,a[a.length-1]===0)){a.pop(),r++,s="template-string";continue}}if(o==="'"){r++,s="single-string";continue}if(o==='"'){r++,s="double-string";continue}if(o==="`"){r++,s="template-string";continue}if(o==="/"&&u==="/"){r+=2,s="line-comment";continue}if(o==="/"&&u==="*"){r+=2,s="block-comment";continue}if(o==="/"){let c=r-1;for(;c>=0&&/\s/.test(e[c]);)c--;let l=c>=0?e[c]:"";if(!l||/[=(!,;:{[&|?+\-*%<>~^]/.test(l)||c>=5&&/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)$/.test(e.slice(Math.max(0,c-10),c+1))){r++,s="regex";continue}}if(o==="l"&&e.slice(r,r+4)==="let "&&(r===0||!/[\w$]/.test(e[r-1]))){let c=r+4;for(;c<e.length&&/\s/.test(e[c]);)c++;if(c<e.length&&/[a-zA-Z_$]/.test(e[c])){let l=c;for(;c<e.length&&/[\w$]/.test(e[c]);)c++;let p=c,f=e.slice(l,p),d=c;for(;d<e.length&&/\s/.test(e[d]);)d++;if(d<e.length&&e[d]===":"&&e[d+1]!==":"){let y=d+1;for(;y<e.length&&/[ \t]/.test(e[y]);)y++;let x=To(e,y);if(x>y){let S=e.slice(y,x).trim();t.set(f,S),n.push({start:p,end:x,replacement:""}),r=x;continue}}}}break}r++}if(n.length===0)return{source:e,annotations:t};let i=e;for(let o=n.length-1;o>=0;o--){let u=n[o];i=i.slice(0,u.start)+u.replacement+i.slice(u.end)}return{source:i,annotations:t}}function To(e,t){let n=t,r=0,s=0,a=0,i="normal",o=[];for(;n<e.length;){let u=e[n];if(i==="sq"){if(u==="\\"){n+=2;continue}u==="'"&&(i="normal"),n++;continue}if(i==="dq"){if(u==="\\"){n+=2;continue}u==='"'&&(i="normal"),n++;continue}if(i==="tpl"){if(u==="\\"){n+=2;continue}if(u==="$"&&e[n+1]==="{"){o.push(1),i="normal",n+=2;continue}u==="`"&&(i="normal"),n++;continue}if(o.length>0){if(u==="{")o[o.length-1]++;else if(u==="}"&&(o[o.length-1]--,o[o.length-1]===0)){o.pop(),i="tpl",n++;continue}}if(u==="'"){i="sq",n++;continue}if(u==='"'){i="dq",n++;continue}if(u==="`"){i="tpl",n++;continue}if(u==="("?r++:u===")"?r--:u==="{"?s++:u==="}"?s--:u==="["?a++:u==="]"&&a--,r===0&&s===0&&a===0&&(u==="="||u===","||u===";"||u===`
58
+ `))return n;n++}return n}function gn(e,t){let n="",r=0,s,a,i="normal",o=[],u=[{type:"top-level",braceDepth:0}],c=0,l=()=>u[u.length-1]?.type||"top-level",p=()=>{let f=u[u.length-1];return f?.type==="class-body"&&c===f.braceDepth+1};for(;r<e.length;){let f=e[r],d=e[r+1];switch(i){case"single-string":if(n+=f,f==="\\"&&r+1<e.length){n+=d,r+=2;continue}f==="'"&&(i="normal"),r++;continue;case"double-string":if(n+=f,f==="\\"&&r+1<e.length){n+=d,r+=2;continue}f==='"'&&(i="normal"),r++;continue;case"template-string":if(n+=f,f==="\\"&&r+1<e.length){n+=d,r+=2;continue}if(f==="$"&&d==="{"){n+=d,r+=2,o.push(1),i="normal";continue}f==="`"&&(i="normal"),r++;continue;case"line-comment":n+=f,f===`
59
+ `&&(i="normal"),r++;continue;case"block-comment":if(n+=f,f==="*"&&d==="/"){n+=d,r+=2,i="normal";continue}r++;continue;case"regex":if(n+=f,f==="\\"&&r+1<e.length){n+=d,r+=2;continue}if(f==="["){for(r++;r<e.length&&e[r]!=="]";)n+=e[r],e[r]==="\\"&&r+1<e.length?(n+=e[r+1],r+=2):r++;r<e.length&&(n+=e[r],r++);continue}if(f==="/"){for(r++;r<e.length&&/[gimsuy]/.test(e[r]);)n+=e[r],r++;i="normal";continue}r++;continue;case"normal":if(o.length>0){if(f==="{")o[o.length-1]++;else if(f==="}"&&(o[o.length-1]--,o[o.length-1]===0)){o.pop(),n+=f,r++,i="template-string";continue}}if(f==="'"){n+=f,r++,i="single-string";continue}if(f==='"'){n+=f,r++,i="double-string";continue}if(f==="`"){n+=f,r++,i="template-string";continue}if(f==="/"&&d==="/"){n+=f+d,r+=2,i="line-comment";continue}if(f==="/"&&d==="*"){n+=f+d,r+=2,i="block-comment";continue}if(f==="/"){let _=n.trimEnd();if(!_[_.length-1]||/[=(!,;:{[&|?+\-*%<>~^]$/.test(_)||/\b(return|case|throw|in|of|typeof|instanceof|new|delete|void)\s*$/.test(_)){n+=f,r++,i="regex";continue}}break}if(f==="{"){c++,n+=f,r++;continue}if(f==="}"){c--;let _=u[u.length-1];_&&c===_.braceDepth&&u.pop(),n+=f,r++;continue}let m=e.slice(r).match(/^class\s+\w+(?:\s+extends\s+\w+)?\s*\{/);if(m){let _=m[0].slice(0,-1);n+=_,r+=_.length,u.push({type:"class-body",braceDepth:c});continue}let y=e.slice(r).match(/^function\s+(\w+)\s*\(/);if(y){let _=y[1],b=y[0].length,v=e[r+b],w,k=r+b;(v==="?"||v==="!")&&(w=v,k++,w==="!"?t.unsafeFunctions.add(_):t.safeFunctions.add(_)),n+=`function ${_}(`,r=k;let T=hn(e,r,"(",")");if(!T){n+=e[r],r++;continue}let{content:C,endPos:N}=T;r=N;let P=ir(C,t,!0);n+=P+")";let D=r;for(;D<e.length&&/\s/.test(e[D]);)D++;if(e[D]===":"){let U=e.slice(D,D+2),J;for(U===":?"||U===":!"?(D+=2,J=U===":?"?"safe":"unsafe"):D+=1;D<e.length&&/\s/.test(e[D]);)D++;let X=sr(e,D);X&&(s===void 0&&(s=X.type,J&&(a=J)),r=X.endPos)}let R=r;for(;R<e.length&&/\s/.test(e[R]);)R++;if(e[R]==="="&&e[R+1]===">")throw new te("Unexpected '=>' after function declaration. Function declarations use `function name(params) { body }`, not arrow syntax. Remove the `=>`.",Le(t.originalSource,R),t.originalSource);continue}let x=e.slice(r).match(/^(constructor|(?:get|set)\s+\w+|async\s+\w+|\w+)\s*\(/),S=(()=>{for(let _=n.length-1;_>=0;_--)if(!/\s/.test(n[_]))return n[_];return`
60
+ `})(),E=S!=="="&&S!==","&&S!=="("&&S!=="["&&S!==">";if(x&&p()&&!E){let _=x[1].length;n+=e.slice(r,r+_),r+=_;continue}if(x&&p()&&E){let _=x[1],b=x[0].length,v=r+b;n+=_+"(",r=v;let w=hn(e,r,"(",")");if(!w){n+=e[r],r++;continue}let{content:k,endPos:T}=w;r=T;let C=ir(k,t,!0);n+=C+")";let N=r;for(;N<e.length&&/\s/.test(e[N]);)N++;if(e[N]===":"){let D=e.slice(N,N+2);for(D===":?"||D===":!"?N+=2:N++;N<e.length&&/\s/.test(e[N]);)N++;let R=sr(e,N);R&&(r=R.endPos)}let P=r;for(;P<e.length&&/\s/.test(e[P]);)P++;if(e[P]==="="&&e[P+1]===">")throw new te("Unexpected '=>' after method declaration. Methods use `name(params) { body }`, not arrow syntax. Remove the `=>`.",Le(t.originalSource,P),t.originalSource);continue}if(e[r]==="("){let _=hn(e,r+1,"(",")");if(!_){n+=e[r],r++;continue}let b=_.content,v=_.endPos,w=v;for(;w<e.length&&/\s/.test(e[w]);)w++;let k;if(e[w]===":"){let T=e.slice(w,w+2);for(T===":?"||T===":!"?w+=2:w++;w<e.length&&/\s/.test(e[w]);)w++;let C=sr(e,w);if(C)for(k=C.type,w=C.endPos;w<e.length&&/\s/.test(e[w]);)w++}if(e.slice(w,w+2)==="=>"){let T=null,C=b,N=b.trimStart();N.startsWith("?")&&(N.length===1||/\s/.test(N[1]))?(T="?",C=N.slice(1)):N.startsWith("!")&&(N.length===1||/\s/.test(N[1]))&&(T="!",C=N.slice(1));let P=ir(C,t,!1);for(n+=`(${T==="?"?"/* safe */ ":T==="!"?"/* unsafe */ ":""}${P})`,r=v;r<w&&/\s/.test(e[r]);)n+=e[r],r++;k&&(r=w)}else{let T=gn(b,t);n+=`(${T.source})`,r=v}continue}n+=e[r],r++}return{source:n,returnType:s,returnSafety:a}}function hn(e,t,n,r){let s=1,a=t,i=!1,o="";for(;a<e.length&&s>0;){let u=e[a];!i&&(u==="'"||u==='"'||u==="`")?(i=!0,o=u):i&&u===o&&e[a-1]!=="\\"?i=!1:i||(u===n?s++:u===r&&s--),a++}return s!==0?null:{content:e.slice(t,a-1),endPos:a}}function yi(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)return null;let r=n,s=e[n];if(s==="{"||s==="["){let i=s==="{"?"}":"]",o=hn(e,n+1,s,i);return o?{value:e.slice(r,o.endPos),endPos:o.endPos}:null}if(s==="'"||s==='"'||s==="`"){for(n++;n<e.length;){if(e[n]===s&&e[n-1]!=="\\")return n++,{value:e.slice(r,n),endPos:n};n++}return null}if(/[-+\d]/.test(s)){for(;n<e.length&&/[\d.eE+-]/.test(e[n]);)n++;return{value:e.slice(r,n),endPos:n}}let a=e.slice(n).match(/^(true|false|null|undefined)\b/);return a?{value:a[1],endPos:n+a[1].length}:null}function Bt(e){return e.replace(/(?<!\|)\|(?!\|)/g," || ")}function sr(e,t){let n=t,r=0,s=!1,a="",i=!1,o=u=>({type:Bt(e.slice(t,u).trim()),endPos:u});for(;n<e.length;){let u=e[n];if(!s&&(u==="'"||u==='"'||u==="`")){s=!0,a=u,i=!0,n++;continue}if(s){if(u===a&&e[n-1]!=="\\"){if(s=!1,n++,r===0){let c=n;for(;c<e.length&&/\s/.test(e[c]);)c++;if(e[c]==="{"&&!e.slice(c+1).match(/^\s*(\w+)\s*:/)||e[c]!=="|"&&e[c]!=="&")return o(n)}continue}n++;continue}if(u==="{"||u==="["||u==="("){r++,i=!0,n++;continue}if(u==="}"||u==="]"||u===")"){if(r--,r===0){n++;let c=n;for(;c<e.length&&/\s/.test(e[c]);)c++;if(e[c]==="|"||e[c]==="&")continue;return o(n)}n++;continue}if(r===0&&u==="{"){if(i)return o(n);if(e.slice(n+1).match(/^\s*(\w+)\s*:/)){r++,i=!0,n++;continue}return o(n)}if(r===0&&(u==="|"||u==="&")){for(n++,n<e.length&&e[n]==="|"&&n++;n<e.length&&/\s/.test(e[n]);)n++;continue}if(r===0&&(/\d/.test(u)||u==="-"&&/\d/.test(e[n+1]))){let c=n;for(e[c]==="-"&&c++;c<e.length&&/\d/.test(e[c]);)c++;if(c<e.length&&e[c]==="."&&/\d/.test(e[c+1]))for(c++;c<e.length&&/\d/.test(e[c]);)c++;if(c<e.length&&(e[c]==="e"||e[c]==="E"))for(c++,c<e.length&&(e[c]==="+"||e[c]==="-")&&c++;c<e.length&&/\d/.test(e[c]);)c++;for(i=!0,n=c;n<e.length&&/\s/.test(e[n]);)n++;if(n<e.length&&e[n]==="{")return{type:Bt(e.slice(t,c).trim()),endPos:c};if(e[n]!=="|"&&e[n]!=="&")return{type:Bt(e.slice(t,c).trim()),endPos:c};continue}if(r===0&&/[a-zA-Z_]/.test(u)){let c=n;for(;c<e.length&&/\w/.test(e[c]);)c++;for(i=!0,n=c;n<e.length&&/\s/.test(e[n]);)n++;if(n<e.length&&e[n]==="("){r++,n++;continue}if(n<e.length&&e[n]==="{"&&!e.slice(n+1).match(/^\s*(\w+)\s*:/)){let p=c;for(;p>t&&/\s/.test(e[p-1]);)p--;return{type:Bt(e.slice(t,p).trim()),endPos:c}}if(e[n]!=="|"&&e[n]!=="&")return{type:Bt(e.slice(t,c).trim()),endPos:c};continue}n++}return i?o(n):null}function yn(e){let t=[],n="",r=0,s=!1,a=!1,i=0;for(;i<e.length;){let o=e[i],u=e[i+1];if(!a&&o==="/"&&u==="/"){s=!0,n+="//",i+=2;continue}if(!s&&o==="/"&&u==="*"){a=!0,n+="/*",i+=2;continue}if(s&&o===`
61
+ `){s=!1,n+=o,i++;continue}if(a&&o==="*"&&u==="/"){a=!1,n+="*/",i+=2;continue}if(s||a){n+=o,i++;continue}o==="("||o==="{"||o==="["?(r++,n+=o):o===")"||o==="}"||o==="]"?(r--,n+=o):o===","&&r===0?(t.push(n),n=""):n+=o,i++}return n.trim()&&t.push(n),t}function ir(e,t,n){let r=gn(e,{originalSource:e,requiredParams:t.requiredParams,unsafeFunctions:t.unsafeFunctions,safeFunctions:t.safeFunctions}).source,s=yn(r),a=!1,i=new Set,o=c=>{if(n&&/^\w+$/.test(c)){if(i.has(c))throw new Error(`Duplicate parameter name '${c}'`);i.add(c)}};return s.map(c=>{let l=c.trim();if(!l)return c;if(n&&l.startsWith("{")&&l.endsWith("}")){let d=l.slice(1,-1);return`{ ${bi(d,t)} }`}if(n&&l.startsWith("[")&&l.endsWith("]")){let d=l.slice(1,-1);return`[ ${bi(d,t)} ]`}if(l.startsWith("...")){let d=xi(l);return d!==-1?l.slice(0,d).trim():c}let p=l.match(/^(\w+)\s*\?\s*:\s*(.+)$/);if(p){let[,d,m]=p;return o(d),a=!0,`${d} = ${m}`}if(!$o(l)){let d=l.match(/^(\w+)\s*=/);return d&&o(d[1]),a=!0,c}let f=xi(l);if(f!==-1){let d=l.slice(0,f).trim(),m=l.slice(f+1).trim();return o(d),a&&n&&/^\w+$/.test(d),n&&/^\w+$/.test(d)&&t.requiredParams.add(d),`${d} = ${m}`}return c}).join(",")}function bi(e,t){return yn(e).map(s=>{let a=s.trim();if(!a)return s;let i=a.match(/^(\w+)\s*:\s*(\{[\s\S]*\})$/);if(i){let[,c,l]=i;t.requiredParams.add(c);let p=dn(l);return`${c} = ${p}`}let o=a.match(/^(\w+)\s*:\s*(\[[\s\S]*\])$/);if(o){let[,c,l]=o;t.requiredParams.add(c);let p=mn(l);return`${c} = ${p}`}let u=a.match(/^(\w+)\s*:\s*([\s\S]+)$/);if(u){let[,c,l]=u;return t.requiredParams.add(c),`${c} = ${l}`}return s}).join(", ")}function dn(e){let t=e.slice(1,-1).trim();return`{ ${yn(t).map(s=>{let a=s.trim();if(!a)return s;let i=a.match(/^(\w+)\s*:\s*(\{[\s\S]*\})$/);if(i){let[,p,f]=i;return`${p}: ${dn(f)}`}let o=a.match(/^(\w+)\s*=\s*(\{[\s\S]*\})$/);if(o){let[,p,f]=o;return`${p}: ${dn(f)}`}let u=a.match(/^(\w+)\s*:\s*(\[[\s\S]*\])$/);if(u){let[,p,f]=u;return`${p}: ${mn(f)}`}let c=a.match(/^(\w+)\s*=\s*(\[[\s\S]*\])$/);if(c){let[,p,f]=c;return`${p}: ${mn(f)}`}let l=a.match(/^(\w+)\s*=\s*([\s\S]+)$/);if(l){let[,p,f]=l;return`${p}: ${f}`}return s}).join(", ")} }`}function mn(e){let t=e.slice(1,-1).trim();return`[ ${yn(t).map(s=>{let a=s.trim();return a?a.startsWith("{")&&a.endsWith("}")?dn(a):a.startsWith("[")&&a.endsWith("]")?mn(a):s:s}).join(", ")} ]`}function $o(e){let t=0,n=!1,r=!1,s=!1,a="";for(let i=0;i<e.length;i++){let o=e[i];if(!s&&(o==="'"||o==='"'||o==="`")){s=!0,a=o;continue}if(s){o===a&&e[i-1]!=="\\"&&(s=!1);continue}o==="("||o==="{"||o==="["?t++:o===")"||o==="}"||o==="]"?t--:t===0&&(o===":"&&(n=!0),o==="="&&e[i+1]!==">"&&(r=!0))}return n&&!r}function xi(e){let t=0,n=!1,r="";for(let s=0;s<e.length;s++){let a=e[s];if(!n&&(a==="'"||a==='"'||a==="`")){n=!0,r=a;continue}if(n){a===r&&e[s-1]!=="\\"&&(n=!1);continue}if(a==="("||a==="{"||a==="[")t++;else if(a===")"||a==="}"||a==="]")t--;else if(t===0&&a===":")return s}return-1}function ar(e){let t="",n=0;for(;n<e.length;){let r=e[n];if(r==="'"||r==='"'||r==="`"){let s=r;for(t+=r,n++;n<e.length&&e[n]!==s;)e[n]==="\\"&&(t+=e[n++]),n<e.length&&(t+=e[n++]);n<e.length&&(t+=e[n++]);continue}if(r==="/"&&e[n+1]==="*"){let s=e.indexOf("*/",n+2),a=s===-1?e.slice(n):e.slice(n,s+2);t+=a,n+=a.length;continue}if(r==="/"&&e[n+1]==="/"){let s=e.indexOf(`
62
+ `,n),a=s===-1?e.length:s;t+=" ".repeat(a-n),n=a;continue}t+=r,n++}return t}function bn(e,t={}){let n=e,r,s=new Set,a=new Set,i=new Set,o=/\/\*\s*tjs\s*<-\s*\S+\s*\*\//.test(e),u=t.dialect==="js"?!0:t.dialect==="tjs"?!1:o||t.vmTarget,c=u?{tjsEquals:!1,tjsClass:!1,tjsDate:!1,tjsNoeval:!1,tjsStandard:!1,tjsSafeEval:!1,tjsNoVar:!1,tjsSafeAssign:!1}:{tjsEquals:!0,tjsClass:!0,tjsDate:!0,tjsNoeval:!0,tjsStandard:!0,tjsSafeEval:!1,tjsNoVar:!0,tjsSafeAssign:!0};u&&(r="none");let l=e.match(/^(\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*)\s*safety\s+(none|inputs|all)\b/);l&&(r=l[2],e=e.replace(/^(\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*)\s*safety\s+(none|inputs|all)\s*/,"$1"));let p=/^(\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*)*)\s*(TjsStrict|TjsCompat|TjsEquals|TjsClass|TjsDate|TjsNoeval|TjsNoVar|TjsStandard|TjsSafeEval|TjsSafeAssign)\b/,f;for(;f=e.match(p);){let P=f[2];P==="TjsStrict"?(c.tjsEquals=!0,c.tjsClass=!0,c.tjsDate=!0,c.tjsNoeval=!0,c.tjsNoVar=!0,c.tjsStandard=!0,c.tjsSafeAssign=!0):P==="TjsCompat"?(c.tjsEquals=!1,c.tjsClass=!1,c.tjsDate=!1,c.tjsNoeval=!1,c.tjsNoVar=!1,c.tjsStandard=!1,c.tjsSafeEval=!1,c.tjsSafeAssign=!1):P==="TjsEquals"?c.tjsEquals=!0:P==="TjsClass"?c.tjsClass=!0:P==="TjsDate"?c.tjsDate=!0:P==="TjsNoeval"?c.tjsNoeval=!0:P==="TjsNoVar"?c.tjsNoVar=!0:P==="TjsStandard"?c.tjsStandard=!0:P==="TjsSafeEval"?c.tjsSafeEval=!0:P==="TjsSafeAssign"&&(c.tjsSafeAssign=!0),e=e.replace(new RegExp(`^(\\s*(?:\\/\\/[^\\n]*\\n|\\/\\*[\\s\\S]*?\\*\\/\\s*)*)\\s*${P}\\s*`),"$1")}e=ar(e),c.tjsStandard&&(e=Ys(e)),e=pi(e),e=mi(e);let d=gi(e);e=d.source;let m=d.annotations,y=Zs(e);e=y.source,e=Rt(e),c.tjsEquals&&!t.vmTarget&&(e=Mt(e));let x=[];e=Xs(e,x),e=ti(e,x),e=ei(e),e=ni(e),e=ri(e),c.tjsSafeAssign&&(e=oi(e));let S=Qs(e,{loader:t.moduleLoader,importerPath:t.filename});e=S.source;let{source:E,returnType:_,returnSafety:b}=gn(e,{originalSource:n,requiredParams:s,unsafeFunctions:a,safeFunctions:i});e=E;let v=si(e);e=v.source,e=Hs(e);let w=ai(e,s);e=w.source;let k=Ks(e);e=k.source;let T=[...y.blocks,...S.blocks,...k.blocks],C=ui(e,t.dangerouslySkipTests);e=C.source;let N=ci(e,s);e=N.source;for(let P of N.polyCtorClasses)a.add(`${P}$dispatch`);return c.tjsClass&&(e=li(e,N.polyCtorClasses)),c.tjsDate&&(e=fi(e)),c.tjsNoeval&&(e=di(e)),c.tjsNoVar&&(e=hi(e)),e=Ot(e,v.extensions),{source:e,returnType:_,returnSafety:b,moduleSafety:r,tjsModes:c,originalSource:n,requiredParams:s,unsafeFunctions:a,safeFunctions:i,wasmBlocks:T,tests:C.tests,testErrors:C.errors,polymorphicNames:w.polymorphicNames,extensions:v.extensions,letAnnotations:m,predicates:x}}function tt(e,t={}){let{filename:n="<source>",colonShorthand:r=!0,vmTarget:s=!1,dialect:a}=t,{source:i,returnType:o,returnSafety:u,moduleSafety:c,originalSource:l,requiredParams:p,unsafeFunctions:f,safeFunctions:d,wasmBlocks:m,tests:y,testErrors:x,letAnnotations:S,tjsModes:E}=r?bn(e,{vmTarget:s,dialect:a,moduleLoader:t.moduleLoader,filename:t.filename}):{source:e,returnType:void 0,returnSafety:void 0,moduleSafety:void 0,originalSource:e,requiredParams:new Set,unsafeFunctions:new Set,safeFunctions:new Set,wasmBlocks:[],tests:[],testErrors:[],letAnnotations:new Map,tjsModes:{tjsEquals:!1,tjsClass:!1,tjsDate:!1,tjsNoeval:!1,tjsStandard:!1,tjsSafeEval:!1,tjsNoVar:!1,tjsSafeAssign:!1}};try{return{ast:je(i,{ecmaVersion:2022,sourceType:"module",locations:!0,allowReturnOutsideFunction:!1}),returnType:o,returnSafety:u,moduleSafety:c,originalSource:l,requiredParams:p,unsafeFunctions:f,safeFunctions:d,wasmBlocks:m,tests:y,testErrors:x,letAnnotations:S,tjsModes:E}}catch(_){let b=_.loc||{line:1,column:0};throw new te(_.message.replace(/\s*\(\d+:\d+\)$/,""),b,l,n)}}function _i(e,t){for(let a of e.body){if(a.type==="ImportDeclaration")throw new te("Imports are not supported. All atoms must be registered with the VM.",a.loc?.start||{line:1,column:0},void 0,t);if(a.type==="ExportNamedDeclaration"||a.type==="ExportDefaultDeclaration")throw new te("Exports are not supported. The function is automatically exported.",a.loc?.start||{line:1,column:0},void 0,t);if(a.type==="ClassDeclaration")throw new te("Classes are not supported. Agent99 uses functional composition.",a.loc?.start||{line:1,column:0},void 0,t)}let n=e.body.filter(a=>a.type==="FunctionDeclaration");if(n.length===0)throw new te("Source must contain a function declaration",{line:1,column:0},void 0,t);let r=n[n.length-1],s=new Map;for(let a=0;a<n.length-1;a++){let i=n[a],o=i.id?.name;if(!o)throw new te("Helper function must have a name",i.loc?.start||{line:1,column:0},void 0,t);if(s.has(o))throw new te(`Duplicate helper function name: ${o}`,i.loc?.start||{line:1,column:0},void 0,t);if(o===r.id?.name)throw new te(`Helper function cannot share a name with the entry function: ${o}`,i.loc?.start||{line:1,column:0},void 0,t);s.set(o,i)}return{entry:r,helpers:s}}function Dt(e,t){let n={params:{}};if(!t.loc)return n;let r=e.substring(0,t.start),s=[...r.matchAll(/(?<=^[ \t]*)\/\*#([\s\S]*?)\*\//gm)];if(s.length>0){let l=s[s.length-1],p=r.substring(l.index+l[0].length);if(/^(?:\s|\/\/[^\n]*)*$/.test(p)){let f=l[1],d=f.split(`
63
+ `),m=d.filter(y=>y.trim().length>0).reduce((y,x)=>{let S=x.match(/^(\s*)/)?.[1].length||0;return Math.min(y,S)},1/0);return m>0&&m<1/0&&(f=d.map(y=>y.slice(m)).join(`
64
+ `)),n.description=f.trim(),n}}let a=r.match(/\/\*\*[\s\S]*?\*\/\s*$/);if(!a)return n;let i=a[0],o=i.match(/\/\*\*\s*\n?\s*\*?\s*([^@\n][^\n]*)/m);o&&(n.description=o[1].trim());let u=/@param\s+(?:\{[^}]+\}\s+)?(\w+)\s*-?\s*(.*)/g,c;for(;(c=u.exec(i))!==null;)n.params[c[1]]=c[2].trim();return n}function ue(e){switch(e.type){case"Literal":{let t=e.value;if(t===null)return{kind:"null"};if(typeof t=="string")return{kind:"string"};if(typeof t=="number"){let n=e.raw;return n&&n.includes(".")?{kind:"number"}:{kind:"integer"}}return typeof t=="boolean"?{kind:"boolean"}:{kind:"any"}}case"ArrayExpression":{let t=e.elements;if(t.length===0)return{kind:"array",items:{kind:"any"}};let n=t.filter(i=>i!=null).map(i=>ue(i));if(n.length===0)return{kind:"array",items:{kind:"any"}};let r=new Map;for(let i of n){let o=JSON.stringify(i);r.has(o)||r.set(o,i)}let s=[...r.values()];return{kind:"array",items:s.length===1?s[0]:{kind:"union",members:s}}}case"ObjectExpression":{let t=e.properties,n={};for(let r of t)if(r.type==="Property"&&r.key.type==="Identifier"){let s=r.key.name;n[s]=ue(r.value)}return{kind:"object",shape:n}}case"LogicalExpression":{let{operator:t,left:n,right:r}=e;return t==="||"?ue(n):t==="&&"||t==="??"?ue(r):{kind:"any"}}case"BinaryExpression":{let{operator:t,left:n,right:r}=e;if(t==="|"){let s=ue(n),a=ue(r);return a.kind==="null"?{...s,nullable:!0}:s.kind==="null"?{...a,nullable:!0}:{kind:"union",members:[s,a]}}return{kind:"any"}}case"Identifier":return e.name==="undefined"?{kind:"undefined"}:{kind:"any"};case"ArrowFunctionExpression":case"FunctionExpression":{let t=e,n=t.params.map(s=>Co(s)),r={kind:"any"};return t.type==="ArrowFunctionExpression"&&t.body&&t.body.type!=="BlockStatement"&&(r=ue(t.body)),{kind:"function",params:n,returns:r}}case"UnaryExpression":{let t=e.operator,n=e.argument;if(t==="+"&&n.type==="Literal"&&typeof n.value=="number")return{kind:"non-negative-integer"};if(t==="-"&&n.type==="Literal"&&typeof n.value=="number"){let s=n.raw;return s&&s.includes(".")?{kind:"number"}:{kind:"integer"}}return{kind:"any"}}default:return{kind:"any"}}}function Co(e){return e.type==="Identifier"?{name:e.name,type:{kind:"any"}}:e.type==="AssignmentPattern"&&e.left?.type==="Identifier"?{name:e.left.name,type:ue(e.right)}:e.type==="RestElement"&&e.argument?.type==="Identifier"?{name:`...${e.argument.name}`,type:{kind:"array",items:{kind:"any"}}}:{name:"?",type:{kind:"any"}}}function Ge(e,t){if(e.type==="Identifier")return{name:e.name,type:{kind:"any"},required:!0};if(e.type==="AssignmentPattern"){let{left:n,right:r}=e;if(n.type!=="Identifier")throw new K("Only simple parameter names are supported",Z(e));let s=n.name,a=t?.has(s)??!1,i=ue(r),o=Ie(r);return{name:s,type:i,required:a,default:a?null:o,example:o,loc:{start:e.start,end:e.end}}}if(e.type==="ObjectPattern"){let n=e.properties,r={},s={};for(let a of n)if(a.type==="Property"){let i=a.key.type==="Identifier"?a.key.name:String(a.key.value);if(a.value.type==="Identifier")r[i]={kind:"any"},s[i]={name:i,type:{kind:"any"},required:!0};else if(a.value.type==="AssignmentPattern"){let o=Ge(a.value,t),u=t?.has(i)??!1;r[i]=o.type,s[i]={name:i,type:o.type,required:u,default:u?null:o.example,example:o.example}}}return{name:"__destructured__",type:{kind:"object",shape:r,destructuredParams:s},required:!0}}throw new K(`Unsupported parameter pattern: ${e.type}`,Z(e))}function Ie(e){switch(e.type){case"Literal":return e.value;case"ArrayExpression":return e.elements.map(t=>t?Ie(t):null);case"ObjectExpression":{let t={};for(let n of e.properties)n.type==="Property"&&n.key.type==="Identifier"&&(t[n.key.name]=Ie(n.value));return t}case"UnaryExpression":if(e.operator==="-"){let t=Ie(e.argument);return typeof t=="number"?-t:void 0}if(e.operator==="+"){let t=Ie(e.argument);return typeof t=="number"?+t:void 0}return;case"BinaryExpression":{let{operator:t,left:n}=e;return t==="|"?Ie(n):void 0}case"LogicalExpression":{let{operator:t,left:n,right:r}=e;return t==="&&"&&n.type==="Literal"&&n.value===null?null:t==="||"||t==="??"?Ie(n)??Ie(r):void 0}default:return}}function wi(e){try{let t=Pt(e,0,{ecmaVersion:2022});return ue(t)}catch{return{kind:"any"}}}function or(e){switch(e.kind){case"string":return e.nullable?"string | null":"string";case"number":return e.nullable?"number | null":"number";case"integer":return e.nullable?"integer | null":"integer";case"non-negative-integer":return e.nullable?"non-negative integer | null":"non-negative integer";case"boolean":return e.nullable?"boolean | null":"boolean";case"null":return"null";case"any":return"any";case"array":{let t=e.items?or(e.items):"any";return e.nullable?`${t}[] | null`:`${t}[]`}case"object":{if(!e.shape||Object.keys(e.shape).length===0)return e.nullable?"object | null":"object";let t=Object.entries(e.shape).map(([n,r])=>`${n}: ${or(r)}`).join(", ");return e.nullable?`{ ${t} } | null`:`{ ${t} }`}case"union":return e.members?.map(or).join(" | ")||"any";default:return"any"}}function xn(e){switch(e.kind){case"string":return{type:"string"};case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"null":return{};case"undefined":return{};case"any":return{};case"array":return{type:"array",items:e.items?xn(e.items):{}};case"object":if(e.shape){let t={};for(let[n,r]of Object.entries(e.shape))t[n]=xn(r);return{type:"object",properties:t,additionalProperties:!1}}return{type:"object"};case"union":return e.members?{oneOf:e.members.map(xn)}:{};default:return{}}}function Ao(e){let t={},n=[];for(let[r,s]of Object.entries(e))t[r]=xn(s.type),s.required&&n.push(r);return{type:"object",properties:t,required:n.length>0?n:void 0,additionalProperties:!1}}function ur(e,t,n,r={},s,a){let i=Dt(t,e),o=new Map;for(let E of e.params){let _=Ge(E,s);if(_.name==="__destructured__"&&_.type.kind==="object"&&_.type.destructuredParams)for(let[b,v]of Object.entries(_.type.destructuredParams))o.set(b,{...v,description:i.params[b]});else _.description=i.params[_.name],o.set(_.name,_)}let u;n&&(u=wi(n));let c={depth:0,locals:new Map,parameters:o,atoms:new Set(Object.keys(r.atoms||{})),warnings:[],source:t,filename:r.filename||"<source>",options:r,helpers:a,helperSteps:a?new Map:void 0,helperTransforming:a?new Set:void 0},l=Te(e.body,c),p=[],f=[],d=[];for(let[E,_]of o.entries())_.required?f.push(E):_.default!==void 0?d.push({name:E,defaultValue:_.default}):f.push(E);f.length>0&&p.push({op:"varsImport",keys:f});for(let{name:E,defaultValue:_}of d)p.push({op:"varsImport",keys:[E]}),p.push({op:"if",condition:{$expr:"binary",op:"==",left:{$expr:"ident",name:E},right:{$expr:"literal",value:null}},then:[{op:"varSet",key:E,value:_}]});p.push(...l);let m=Object.fromEntries(o),y={name:e.id?.name||"anonymous",description:i.description,parameters:m,returns:u},x=Ao(m),S=c.helperSteps&&c.helperSteps.size>0?Object.fromEntries(c.helperSteps):void 0;return{ast:{op:"seq",steps:p,inputSchema:x,...S&&{helpers:S}},signature:y,warnings:c.warnings}}function Te(e,t){let n=[];for(let r of e.body){let s=Ft(r,t);s&&(Array.isArray(s)?n.push(...s):n.push(s))}return n}function Ft(e,t){switch(e.type){case"VariableDeclaration":return Po(e,t);case"ExpressionStatement":return jo(e,t);case"IfStatement":return No(e,t);case"WhileStatement":return Ro(e,t);case"ForOfStatement":return Mo(e,t);case"TryStatement":return Oo(e,t);case"ReturnStatement":return Bo(e,t);case"ThrowStatement":throw new K("'throw' is not supported in AsyncJS. Use Error('message') to trigger error flow",Z(e),t.source,t.filename);case"BlockStatement":return{op:"scope",steps:Te(e,Se(t))};case"EmptyStatement":return null;default:throw new K(`Unsupported statement type: ${e.type}`,Z(e),t.source,t.filename)}}function Po(e,t){let n=[],r=e.kind==="const",s=r?"constSet":"varSet";for(let a of e.declarations){if(a.id.type!=="Identifier")throw new K("Only simple variable names are supported",Z(a),t.source,t.filename);let i=a.id.name;if(a.init){let{step:o,resultVar:u}=nt(a.init,t,i,r);o?n.push(o):u!==i&&n.push({op:s,key:i,value:u});let c=ue(a.init);t.locals.set(i,c)}else{if(r)throw new K("const declarations must be initialized",Z(a),t.source,t.filename);n.push({op:"varSet",key:i,value:null}),t.locals.set(i,{kind:"any",nullable:!0})}}return n}function jo(e,t){let n=e.expression;if(n.type==="AssignmentExpression")return Io(n,t);if(n.type==="CallExpression"){let{step:r,resultVar:s}=nt(n,t);return r||(s?{op:"varSet",key:"_",value:s}:null)}return t.warnings.push({message:"Expression statement has no effect",line:Z(e).line,column:Z(e).column}),null}function Io(e,t){if(e.left.type!=="Identifier")throw new K("Only simple variable assignment is supported",Z(e),t.source,t.filename);let n=e.left.name,{step:r,resultVar:s}=nt(e.right,t,n);return r||{op:"varSet",key:n,value:s}}function No(e,t){let n=G(e.test,t),r=e.consequent.type==="BlockStatement"?Te(e.consequent,Se(t)):[Ft(e.consequent,t)].filter(Boolean),s;return e.alternate&&(s=e.alternate.type==="BlockStatement"?Te(e.alternate,Se(t)):[Ft(e.alternate,t)].filter(Boolean)),{op:"if",condition:n,then:r,...s&&{else:s}}}function Ro(e,t){let n=G(e.test,t),r=e.body.type==="BlockStatement"?Te(e.body,Se(t)):[Ft(e.body,t)].filter(Boolean);return{op:"while",condition:n,body:r}}function Mo(e,t){let n;if(e.left.type==="VariableDeclaration"){let i=e.left.declarations[0];if(i.id.type!=="Identifier")throw new K("Only simple variable names are supported in for...of",Z(e.left),t.source,t.filename);n=i.id.name}else if(e.left.type==="Identifier")n=e.left.name;else throw new K("Unsupported for...of left-hand side",Z(e.left),t.source,t.filename);let r=ie(e.right,t),s=Se(t);s.locals.set(n,{kind:"any"});let a=e.body.type==="BlockStatement"?Te(e.body,s):[Ft(e.body,s)].filter(Boolean);return{op:"map",items:r,as:n,steps:a}}function Oo(e,t){let n=Te(e.block,Se(t)),r,s;if(e.handler){let a=Se(t);e.handler.param?.type==="Identifier"&&(s=e.handler.param.name,a.locals.set(s,{kind:"any"})),r=Te(e.handler.body,a)}return{op:"try",try:n,...r&&{catch:r},...s&&{catchParam:s}}}function Bo(e,t){if(!e.argument)return{op:"return",value:{}};let{step:n,resultVar:r}=nt(e.argument,t,"__returnVal__");return n?[n,{op:"return",value:r}]:{op:"return",value:ie(e.argument,t)}}var vi=new Set(["Math","JSON","Array","Object","String","Number","console","Date","Schema"]),Do=new Set(["parseInt","parseFloat","isNaN","isFinite","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent","Set","Date","filter"]),Lt=new Set(["RegExp","Promise","Map","WeakSet","WeakMap","Symbol","Proxy","Reflect","Function","eval","setTimeout","setInterval","fetch","require","import","process","window","document","global","globalThis"]),Fo=new Set(["toUpperCase","toLowerCase","trim","trimStart","trimEnd","charAt","charCodeAt","codePointAt","concat","includes","indexOf","lastIndexOf","startsWith","endsWith","slice","substring","substr","replace","replaceAll","match","search","padStart","padEnd","repeat","normalize","localeCompare","toString","valueOf","at","reverse","sort","fill","copyWithin","flat","flatMap","every","some","forEach","add","remove","has","clear","toArray","union","intersection","diff","format","isBefore","isAfter"]);function Lo(e){if(e.callee.type==="Identifier"){let t=e.callee.name;return Do.has(t)||Lt.has(t)}if(e.callee.type==="MemberExpression"){let t=e.callee;if(t.object.type==="Identifier"){let n=t.object.name;if(vi.has(n)||Lt.has(n))return!0}if(t.property.type==="Identifier"){let n=t.property.name;if(Fo.has(n))return!0}}return!1}function Vo(e){if(e.object.type==="Identifier"){let t=e.object.name;return vi.has(t)||Lt.has(t)}return!1}var Si={RegExp:"RegExp is not available. Use string methods or the regexMatch atom.",Promise:"Promise is not needed. All operations are implicitly async.",Map:"Map is not available. Use plain objects instead.",WeakSet:"WeakSet is not available.",WeakMap:"WeakMap is not available.",Symbol:"Symbol is not available.",Proxy:"Proxy is not available.",Reflect:"Reflect is not available.",Function:"Function constructor is not available. Define functions normally.",eval:"eval is not available. Code is compiled, not evaluated.",setTimeout:"setTimeout is not available. Use the delay atom.",setInterval:"setInterval is not available. Use while loops with delay.",fetch:"fetch is not available. Use the httpFetch atom.",require:"require is not available. Atoms must be registered with the VM.",import:"import is not available. Atoms must be registered with the VM.",process:"process is not available. AsyncJS runs in a sandboxed environment.",window:"window is not available. AsyncJS runs in a sandboxed environment.",document:"document is not available. AsyncJS runs in a sandboxed environment.",global:"global is not available. AsyncJS runs in a sandboxed environment.",globalThis:"globalThis is not available. Use builtins directly."};function qo(e){if(e.callee.type==="Identifier"){let t=e.callee.name;if(Lt.has(t))return Si[t]||`${t} is not available in AsyncJS.`}if(e.callee.type==="MemberExpression"){let t=e.callee;if(t.object.type==="Identifier"){let n=t.object.name;if(Lt.has(n))return Si[n]||`${n} is not available in AsyncJS.`}}return null}function ki(e){return{Date:" Use Date() or Date('2024-01-15') instead - no 'new' needed.",Set:" Use Set([items]) instead - no 'new' needed.",Map:" Use plain objects instead of Map.",Array:" Use array literals like [1, 2, 3] instead.",Object:" Use object literals like { key: value } instead.",Error:" Return an error object like { error: 'message' } instead.",RegExp:" Use string methods or the regexMatch atom.",Promise:" Not needed - all operations are implicitly async.",WeakSet:" WeakSet is not available.",WeakMap:" WeakMap is not available."}[e]||" Use factory functions or object literals instead."}function nt(e,t,n,r){let s=r?"constSet":"varSet";if(e.type==="ChainExpression")return nt(e.expression,t,n,r);if(e.type==="NewExpression"){let i=e,o="constructor";i.callee.type==="Identifier"&&(o=i.callee.name);let u=ki(o);throw new K(`The 'new' keyword is not supported in AsyncJS.${u}`,Z(e),t.source,t.filename)}if(e.type==="CallExpression"){let i=qo(e);if(i)throw new K(i,Z(e),t.source,t.filename)}if(e.type==="CallExpression"&&Lo(e)){let i=G(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}if(e.type==="MemberExpression"&&Vo(e)){let i=G(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}if(e.type==="CallExpression")return Uo(e,t,n,r);if(e.type==="TemplateLiteral")return zo(e,t,n,r);if(e.type==="BinaryExpression"||e.type==="LogicalExpression"||e.type==="UnaryExpression"){let i=G(e,t);return n?{step:{op:s,key:n,value:i},resultVar:n}:{step:null,resultVar:i}}return{step:null,resultVar:ie(e,t)}}function Uo(e,t,n,r){let s,a=!1,i;if(e.callee.type==="Identifier")s=e.callee.name;else if(e.callee.type==="MemberExpression"){let u=e.callee;if(u.property.type==="Identifier")s=u.property.name,a=!0,i=ie(u.object,t);else throw new K("Computed method names are not supported",Z(e),t.source,t.filename)}else throw new K("Only named function calls are supported",Z(e),t.source,t.filename);if(a)return Jo(s,i,e.arguments,t,n,r);if(s==="console"&&e.callee.type,t.helpers?.has(s)){let u=Wo(s,t,e),c=e.arguments.map(l=>ie(l,t));if(c.length!==u.length)throw new K(`Helper '${s}' expects ${u.length} argument(s), got ${c.length}`,Z(e),t.source,t.filename);return{step:{op:"callLocal",name:s,args:c,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}let o=Go(e,t);return{step:{op:s,...o,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}function Wo(e,t,n){let r=t.helpers.get(e),s=[];for(let a of r.params){let i;if(a.type==="Identifier"?i=a:a.type==="AssignmentPattern"&&a.left?.type==="Identifier"&&(i=a.left),!i)throw new K(`Helper '${e}' parameters must be plain identifiers (optionally with an example value); destructuring is not supported`,a.loc?.start??Z(n),t.source,t.filename);s.push(i.name)}if(t.helperSteps.has(e)||t.helperTransforming.has(e))return s;t.helperTransforming.add(e);try{let a={depth:0,locals:new Map,parameters:new Map(s.map(o=>[o,{name:o,type:{kind:"any"},required:!0}])),atoms:t.atoms,warnings:t.warnings,source:t.source,filename:t.filename,options:t.options,helpers:t.helpers,helperSteps:t.helperSteps,helperTransforming:t.helperTransforming},i=Te(r.body,a);t.helperSteps.set(e,{steps:i,paramNames:s})}finally{t.helperTransforming.delete(e)}return s}function Jo(e,t,n,r,s,a){switch(e){case"map":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],u=o?.type==="Identifier"?o.name:"item",c=Se(r);c.locals.set(u,{kind:"any"});let l;if(i.body.type==="BlockStatement")l=Te(i.body,c);else{let{step:p,resultVar:f}=nt(i.body,c,"result");l=p?[p]:[{op:"varSet",key:"result",value:f}]}return{step:{op:"map",items:t,as:u,steps:l,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"filter":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],u=o?.type==="Identifier"?o.name:"item",c=Se(r);c.locals.set(u,{kind:"any"});let l;if(i.body.type==="BlockStatement")throw new K("filter callback must be an expression, not a block",Z(n[0]),r.source,r.filename);return l=G(i.body,c),{step:{op:"filter",items:t,as:u,condition:l,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"find":if(n.length>0&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],u=o?.type==="Identifier"?o.name:"item",c=Se(r);c.locals.set(u,{kind:"any"});let l;if(i.body.type==="BlockStatement")throw new K("find callback must be an expression, not a block",Z(n[0]),r.source,r.filename);return l=G(i.body,c),{step:{op:"find",items:t,as:u,condition:l,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"reduce":if(n.length>=2&&(n[0].type==="ArrowFunctionExpression"||n[0].type==="FunctionExpression")){let i=n[0],o=i.params[0],u=i.params[1],c=o?.type==="Identifier"?o.name:"acc",l=u?.type==="Identifier"?u.name:"item",p=Se(r);p.locals.set(c,{kind:"any"}),p.locals.set(l,{kind:"any"});let f;if(i.body.type==="BlockStatement")f=Te(i.body,p);else{let{step:m,resultVar:y}=nt(i.body,p,"result");f=m?[m]:[{op:"varSet",key:"result",value:y}]}let d=ie(n[1],r);return{step:{op:"reduce",items:t,as:l,accumulator:c,initial:d,steps:f,...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}break;case"slice":break;case"push":return{step:{op:"push",list:t,item:ie(n[0],r),...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s};case"join":return{step:{op:"join",list:t,sep:n.length>0?ie(n[0],r):"",...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s};case"split":return{step:{op:"split",str:t,sep:n.length>0?ie(n[0],r):"",...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}return r.warnings.push({message:`Unknown method '${e}' - treating as atom call`,line:0,column:0}),{step:{op:e,receiver:t,args:n.map(i=>ie(i,r)),...s&&{result:s},...s&&a&&{resultConst:!0}},resultVar:s}}function zo(e,t,n,r){let s="",a={};for(let i=0;i<e.quasis.length;i++)if(s+=e.quasis[i].value.cooked||e.quasis[i].value.raw,i<e.expressions.length){let o=e.expressions[i],u=`_${i}`;a[u]=ie(o,t),s+=`{{${u}}}`}return{step:{op:"template",tmpl:s,vars:a,...n&&{result:n},...n&&r&&{resultConst:!0}},resultVar:n}}function G(e,t){switch(e.type){case"Literal":return{$expr:"literal",value:e.value};case"Identifier":return{$expr:"ident",name:e.name};case"MemberExpression":{let n=e,r=G(n.object,t),s=n.optional===!0;if(n.computed){let i=n.property;return i.type==="Literal"?{$expr:"member",object:r,property:String(i.value),computed:!0,...s&&{optional:!0}}:{$expr:"member",object:r,property:G(i,t),computed:!0,...s&&{optional:!0}}}let a=n.property.name;return{$expr:"member",object:r,property:a,...s&&{optional:!0}}}case"ChainExpression":return G(e.expression,t);case"BinaryExpression":{let n=e;return{$expr:"binary",op:n.operator,left:G(n.left,t),right:G(n.right,t)}}case"LogicalExpression":{let n=e;return{$expr:"logical",op:n.operator,left:G(n.left,t),right:G(n.right,t)}}case"UnaryExpression":{let n=e;return{$expr:"unary",op:n.operator,argument:G(n.argument,t)}}case"ConditionalExpression":{let n=e;return{$expr:"conditional",test:G(n.test,t),consequent:G(n.consequent,t),alternate:G(n.alternate,t)}}case"ArrayExpression":return{$expr:"array",elements:e.elements.filter(r=>r!==null).map(r=>G(r,t))};case"ObjectExpression":{let n=e,r=[];for(let s of n.properties)if(s.type==="Property"){let a=s.key.type==="Identifier"?s.key.name:String(s.key.value);r.push({key:a,value:G(s.value,t)})}return{$expr:"object",properties:r}}case"CallExpression":{let n=e;if(n.callee.type==="MemberExpression"){let r=n.callee,s=r.property.type==="Identifier"?r.property.name:String(r.property.value),a=r.optional===!0||n.optional===!0;return{$expr:"methodCall",object:G(r.object,t),method:s,arguments:n.arguments.map(i=>G(i,t)),...a&&{optional:!0}}}if(n.callee.type==="Identifier"){let r=n.callee.name;if(t.helpers?.has(r))throw new K(`Helper '${r}' cannot be called inside an expression. Assign its result to a variable first: const result = ${r}(...); then use result.`,Z(e),t.source,t.filename);return{$expr:"call",callee:r,arguments:n.arguments.map(s=>G(s,t))}}throw new K("Complex function calls in expressions should be lifted to statements",Z(e),t.source,t.filename)}case"NewExpression":{let n=e,r="constructor";n.callee.type==="Identifier"&&(r=n.callee.name);let s=ki(r);throw new K(`The 'new' keyword is not supported in AsyncJS.${s}`,Z(e),t.source,t.filename)}case"TemplateLiteral":throw new K("Template literals inside expressions are not supported. Assign to a variable first: const msg = `hello ${name}`; then use msg",Z(e),t.source,t.filename);default:throw new K(`Unsupported expression type in condition: ${e.type}`,Z(e),t.source,t.filename)}}function ie(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":{let n=e;if(n.optional===!0)return G(e,t);let s=ie(n.object,t);if(s&&typeof s=="object"&&s.$expr){let i=n.computed?String(n.property.value):n.property.name;return{$expr:"member",object:s,property:i,...n.computed&&{computed:!0}}}if(n.computed)return G(e,t);let a=n.property.name;return typeof s=="string"?`${s}.${a}`:s&&s.$kind==="arg"?{$kind:"arg",path:`${s.path}.${a}`}:`${s}.${a}`}case"ChainExpression":return ie(e.expression,t);case"ArrayExpression":return e.elements.map(n=>n?ie(n,t):null);case"ObjectExpression":{let n={};for(let r of e.properties)if(r.type==="Property"){let s=r.key.type==="Identifier"?r.key.name:String(r.key.value);n[s]=ie(r.value,t)}return n}case"TemplateLiteral":return G(e,t);case"CallExpression":return G(e,t);case"BinaryExpression":case"LogicalExpression":case"UnaryExpression":case"ConditionalExpression":return G(e,t);default:return null}}function Go(e,t){if(e.arguments.length===1&&e.arguments[0].type==="ObjectExpression"){let n=e.arguments[0],r={};for(let s of n.properties)if(s.type==="Property"){let a=s.key.type==="Identifier"?s.key.name:String(s.key.value);r[a]=ie(s.value,t)}return r}return{args:e.arguments.map(n=>ie(n,t))}}function Ho(e,t){let n=t;for(;n>0&&e[n-1]!==`
65
+ `;)n--;if(e.slice(n,t).includes("//"))return!0;let s=0,a=!1;for(;s<t;)!a&&e.slice(s,s+2)==="/*"?(a=!0,s+=2):a&&e.slice(s,s+2)==="*/"?(a=!1,s+=2):s++;return a}function Ko(e){let t=[],n=/\/\*test\s+'([^']*)'\s*\{([\s\S]*?)\}\s*\*\/|\/\*test\s+"([^"]*)"\s*\{([\s\S]*?)\}\s*\*\/|\/\*test\s+`([^`]*)`\s*\{([\s\S]*?)\}\s*\*\/|\/\*test\s*\{([\s\S]*?)\}\s*\*\//g,r;for(;(r=n.exec(e))!==null;){let s=r[1]||r[3]||r[5]||`embedded test ${t.length+1}`,a=(r[2]||r[4]||r[6]||r[7]||"").trim();t.push({description:s,body:a,line:cr(e,r.index)})}return t}function lr(e){let t=[],n=[],r=Ko(e);t.push(...r);let s=/test\s+'([^']*)'\s*\{|test\s+"([^"]*)"\s*\{|test\s+`([^`]*)`\s*\{|test\s*\(\s*'([^']*)'\s*\)\s*\{|test\s*\(\s*"([^"]*)"\s*\)\s*\{|test\s*\(\s*`([^`]*)`\s*\)\s*\{|test\s*\{/g,a=/mock\s*\{/g,i=e,o,u=[];for(;(o=s.exec(e))!==null;){let f=o.index;if(Ho(e,f))continue;let d=o[1]||o[2]||o[3]||o[4]||o[5]||o[6]||`test ${t.length+1}`,m=o.index+o[0].length,y=Ei(e,m-1);if(y===-1)continue;let x=e.slice(m,y).trim();t.push({description:d,body:x,line:cr(e,f)}),u.push({start:f,end:y+1,desc:d})}let c=[];for(;(o=a.exec(e))!==null;){let f=o.index,d=o.index+o[0].length,m=Ei(e,d-1);if(m===-1)continue;let y=e.slice(d,m).trim();n.push({body:y,line:cr(e,f)}),c.push({start:f,end:m+1})}let l=[...u,...c].sort((f,d)=>d.start-f.start);for(let f of l)i=i.slice(0,f.start)+i.slice(f.end);i=i.replace(/\n\s*\n\s*\n/g,`
62
66
 
63
- `).trim();let p=jo(t,n);return{code:i,tests:t,mocks:n,testRunner:p}}function di(e,t){let n=0,r=null,s=!1;for(let a=t;a<e.length;a++){let i=e[a];if(s){s=!1;continue}if(i==="\\"){s=!0;continue}if(!r&&(i==='"'||i==="'"||i==="`")){r=i;continue}if(r===i){r=null;continue}if(!r&&(i==="{"&&n++,i==="}"&&(n--,n===0)))return a}return-1}function er(e,t){return e.slice(0,t).split(`
64
- `).length}function jo(e,t){if(e.length===0)return"// No tests defined";let n=t.map(s=>s.body).join(`
67
+ `).trim();let p=Zo(t,n);return{code:i,tests:t,mocks:n,testRunner:p}}function Ei(e,t){let n=0,r=null,s=!1;for(let a=t;a<e.length;a++){let i=e[a];if(s){s=!1;continue}if(i==="\\"){s=!0;continue}if(!r&&(i==='"'||i==="'"||i==="`")){r=i;continue}if(r===i){r=null;continue}if(!r&&(i==="{"&&n++,i==="}"&&(n--,n===0)))return a}return-1}function cr(e,t){return e.slice(0,t).split(`
68
+ `).length}function Zo(e,t){if(e.length===0)return"// No tests defined";let n=t.map(s=>s.body).join(`
65
69
  `);return`(async () => {
66
70
  const __results = []
67
71
 
@@ -84,13 +88,13 @@ const __failed = __results.filter(r => !r.passed).length
84
88
 
85
89
  // Return summary
86
90
  return { passed: __passed, failed: __failed, results: __results }
87
- })()`.trim()}var mi=`
91
+ })()`.trim()}var Ti=`
88
92
  function assert(condition, message) {
89
93
  if (!condition) {
90
94
  throw new Error(message || 'Assertion failed')
91
95
  }
92
96
  }
93
- `,gi=`
97
+ `,$i=`
94
98
  function expect(actual) {
95
99
  const deepEqual = (a, b) => {
96
100
  if (a === b) return true
@@ -181,43 +185,43 @@ function expect(actual) {
181
185
  }
182
186
  }
183
187
  }
184
- `,Io=mi+`
185
- `+gi;var O=e=>({schema:e,_type:null,validate:(t,n)=>Ne(t,e,n),get optional(){return O({...e,type:Array.isArray(e.type)?[...e.type,"null"]:[e.type,"null"]})},title:t=>O({...e,title:t}),describe:t=>O({...e,description:t}),default:t=>O({...e,default:t}),meta:t=>O({...t,...e,...t}),min:t=>{let n=e.type==="string"?"minLength":e.type==="array"?"minItems":e.type==="object"?"minProperties":"minimum";return O({...e,[n]:t})},max:t=>{let n=e.type==="string"?"maxLength":e.type==="array"?"maxItems":e.type==="object"?"maxProperties":"maximum";return O({...e,[n]:t})},pattern:t=>O({...e,pattern:typeof t=="string"?t:t.source}),get email(){return O({...e,format:"email"})},get uuid(){return O({...e,format:"uuid"})},get ipv4(){return O({...e,format:"ipv4"})},get url(){return O({...e,format:"uri"})},get datetime(){return O({...e,format:"date-time"})},get emoji(){return O({...e,pattern:"^\\p{Extended_Pictographic}+$",format:"emoji"})},get int(){return O({...e,type:"integer"})},step:t=>O({...e,multipleOf:t})}),nr={get email(){return O({type:"string",format:"email"})},get uuid(){return O({type:"string",format:"uuid"})},get ipv4(){return O({type:"string",format:"ipv4"})},get url(){return O({type:"string",format:"uri"})},get datetime(){return O({type:"string",format:"date-time"})},get emoji(){return O({type:"string",pattern:"^\\p{Extended_Pictographic}+$",format:"emoji"})},get null(){return O({type:"null"})},get undefined(){return O({type:"null","x-tjs-undefined":!0})},get any(){return O({})},pattern:e=>O({type:"string",pattern:typeof e=="string"?e:e.source}),union:e=>O({anyOf:e.map(t=>t.schema)}),enum:e=>O({type:typeof e[0],enum:e}),const:e=>O({const:e}),array:e=>O({type:"array",items:e.schema}),tuple:e=>O({type:"array",items:e.map(t=>t.schema),minItems:e.length,maxItems:e.length}),object:e=>{let t={},n=[];for(let r in e)t[r]=e[r].schema,(!Array.isArray(t[r].type)||!t[r].type.includes("null"))&&n.push(r);return O({type:"object",properties:t,required:n,additionalProperties:!1})},record:e=>O({type:"object",additionalProperties:e.schema}),infer:e=>{if(e===null)return O({type:"null"});if(e===void 0)return O({type:"null","x-tjs-undefined":!0});let t=typeof e;if(t==="string")return O({type:"string"});if(t==="number")return O({type:Number.isInteger(e)?"integer":"number"});if(t==="boolean")return O({type:"boolean"});if(Array.isArray(e))return e.length===0?O({type:"array"}):O({type:"array",items:nr.infer(e[0]).schema});if(t==="object"){let n={},r=[];for(let s in e)n[s]=nr.infer(e[s]).schema,r.push(s);return O({type:"object",properties:n,required:r,additionalProperties:!1})}return O({})}},ye=new Proxy(nr,{get(e,t){if(t in e)return e[t];if(t==="string"||t==="number"||t==="boolean"||t==="integer"){let n=O({type:t});return e[t]=n,n}}}),yi={email:e=>/^\S+@\S+\.\S+$/.test(e),uuid:e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e),uri:e=>{try{return new URL(e),!0}catch{return!1}},ipv4:e=>/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(e),"date-time":e=>!isNaN(Date.parse(e)),emoji:e=>new RegExp("\\p{Extended_Pictographic}","u").test(e)};function Ne(e,t,n){let r=t?.schema||t,s=typeof n=="function"?n:n?.onError,a=typeof n=="object"?n?.strict??n?.fullScan??!1:!1,i=[],o=c=>(s&&s(i.join(".")||"root",c),!1),u=(c,l)=>{if(l.anyOf){for(let f of l.anyOf)if(Ne(c,f))return!0;return o("Union mismatch")}if(l.const!==void 0)return c===l.const||o("Const mismatch");if(c===null){let f=l.type==="null"&&!l["x-tjs-undefined"],d=Array.isArray(l.type)&&l.type.includes("null");return f||d||!l.type||o("Expected value, got null")}if(c===void 0){let f=l.type==="null"&&l["x-tjs-undefined"],d=Array.isArray(l.type)&&l.type.includes("null");return f||d||!l.type||o("Expected value, got undefined")}let p=Array.isArray(l.type)?l.type[0]:l.type;if(l.enum&&!l.enum.includes(c))return o("Enum mismatch");if(p==="integer"){if(typeof c!="number"||!Number.isInteger(c))return o("Expected integer")}else if(p==="array"){if(!Array.isArray(c))return o("Expected array")}else if(p==="object"){if(typeof c!="object"||Array.isArray(c))return o("Expected object")}else if(p&&typeof c!==p)return o(`Expected ${p}`);if(typeof c=="number"){if(!Number.isFinite(c))return o("Expected finite number");if(l.minimum!==void 0&&c<l.minimum)return o("Value < min");if(l.maximum!==void 0&&c>l.maximum)return o("Value > max");if(l.multipleOf!==void 0){let f=Math.abs(c%l.multipleOf),d=1e-10;if(f>1e-10&&Math.abs(f-Math.abs(l.multipleOf))>1e-10)return o("Value not step")}}if(typeof c=="string"){if(l.minLength!==void 0&&c.length<l.minLength)return o("Len < min");if(l.maxLength!==void 0&&c.length>l.maxLength)return o("Len > max");if(l.pattern&&!new RegExp(l.pattern,l.format==="emoji"?"u":"").test(c))return o("Pattern mismatch");if(l.format&&yi[l.format]&&!yi[l.format](c))return o("Format invalid")}if(p==="object"){let f=l.minProperties!==void 0,d=a&&l.maxProperties!==void 0;if(f||d){let g=0;for(let y in c)Object.prototype.hasOwnProperty.call(c,y)&&g++;if(f&&g<l.minProperties)return o("Too few props");if(d&&g>l.maxProperties)return o("Too many props")}if(l.required){for(let g of l.required)if(!(g in c))return o(`Missing ${g}`)}if(l.properties){for(let g in l.properties)if(g in c){i.push(g);let y=u(c[g],l.properties[g]);if(i.pop(),!y)return!1}}if(l.additionalProperties){let g=[];for(let k in c)l.properties&&k in l.properties||g.push(k);let y=g.length,w=a||y<=97?1:Math.floor(y/97);for(let k=0;k<y;k+=w){let S=w>1&&k>y-1-w?y-1:k,b=g[S];i.push(b);let _=u(c[b],l.additionalProperties);if(i.pop(),!_)return!1;if(S===y-1)break}}return!0}if(p==="array"&&l.items){let f=c.length;if(l.minItems!==void 0&&f<l.minItems)return o("Array too short");if(l.maxItems!==void 0&&f>l.maxItems)return o("Array too long");if(Array.isArray(l.items)){for(let g=0;g<l.items.length;g++){if(i.push(String(g)),!u(c[g],l.items[g]))return i.pop(),!1;i.pop()}return!0}let d=a||f<=97?1:Math.floor(f/97);for(let g=0;g<f;g+=d){let y=d>1&&g>f-1-d?f-1:g;i.push(String(y));let w=u(c[y],l.items);if(i.pop(),!w)return!1;if(y===f-1)break}return!0}return!0};return u(e,r)}function bi(e,t,n){let r=t?.schema||t,s=typeof n=="function"?n:n?.onError,a=typeof n=="object"?n?.strict??n?.fullScan??!1:!1;if(!(typeof n=="object"&&n?.skipValidation)){let i="",o="";if(!Ne(e,r,{onError:(u,c)=>{i||(i=u,o=c),s&&s(u,c)},fullScan:a}))return Error(`${i}: ${o}`)}return mn(e,r)}function mn(e,t){if(e==null)return e;let n=t.type;if(n==="object"&&t.properties&&typeof e=="object"&&!Array.isArray(e)){let r={};for(let s of Object.keys(t.properties))s in e&&(r[s]=mn(e[s],t.properties[s]));return r}return n==="array"&&Array.isArray(e)&&t.items?Array.isArray(t.items)?e.slice(0,t.items.length).map((r,s)=>mn(r,t.items[s])):e.map(r=>mn(r,t.items)):e}function ht(e){if(e.nullable)return{anyOf:[ht({...e,nullable:!1}),{type:"null"}]};switch(e.kind){case"string":return{type:"string"};case"number":return{type:"number"};case"integer":return{type:"integer"};case"non-negative-integer":return{type:"integer",minimum:0};case"boolean":return{type:"boolean"};case"null":return{type:"null"};case"undefined":return{};case"any":return{};case"array":return e.items?{type:"array",items:ht(e.items)}:{type:"array"};case"object":if(e.shape){let t={},n=[];for(let[r,s]of Object.entries(e.shape))t[r]=ht(s),n.push(r);return{type:"object",properties:t,required:n,additionalProperties:!1}}return{type:"object"};case"union":return e.members?{anyOf:e.members.map(ht)}:{};default:return{}}}function dt(e){if(e===null)return{type:"null"};if(e===void 0)return{};switch(typeof e){case"string":return{type:"string"};case"number":return Number.isInteger(e)?{type:"integer"}:{type:"number"};case"boolean":return{type:"boolean"};case"object":{if(Array.isArray(e))return e.length===0?{type:"array"}:{type:"array",items:dt(e[0])};let t={},n=[];for(let[r,s]of Object.entries(e))t[r]=dt(s),n.push(r);return{type:"object",properties:t,required:n,additionalProperties:!1}}default:return{}}}function rr(e){let t={},n=[];for(let[a,i]of Object.entries(e.params))i?.type?.kind?t[a]=ht(i.type):i?.example!==void 0?t[a]=dt(i.example):t[a]={},i?.required!==!1&&n.push(a),i?.example!==void 0&&(t[a].examples=[i.example]);let r={type:"object",properties:t,required:n},s;return e.returns&&(e.returns.type?.kind?s=ht(e.returns.type):e.returns.example!==void 0&&(s=dt(e.returns.example))),{input:r,output:s}}function Xe(e){return e!==null&&typeof e=="object"&&"__runtimeType"in e&&e.__runtimeType===!0}function xi(e){return e!==null&&typeof e=="object"&&"schema"in e&&typeof e.schema=="object"}function No(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}function se(e,t,n,r){let s,a,i,o=n,u=r;if(typeof e=="string")if(s=e,typeof t=="function")a=t,o!==void 0&&(i=ye.infer(o));else if(t===void 0&&o!==void 0)i=ye.infer(o);else if(xi(t))i=t;else if(No(t))i=t;else if(t!==void 0)o=t,u=o,i=ye.infer(o);else throw new Error("Type(description) requires a predicate, schema, or example");else xi(e),i=e,s=Ro(i);let c;if(i){let p=i?.schema??i;p&&typeof p=="object"&&Array.isArray(p.examples)&&(c=p.examples)}return o===void 0&&c&&c.length>0&&(o=c[0]),{description:s,check:p=>a?a(p):i?Ne(p,i):!1,schema:i,predicate:a,example:o,examples:c,default:u,toJSONSchema(){if(i){let p=i?.schema??i;if(p&&typeof p=="object"&&"type"in p)return p}return o!==void 0?dt(o):{description:s}},strip(p){return i?bi(p,i):p},__runtimeType:!0}}function Ro(e){let t=e?.schema??e;if(t&&typeof t=="object"&&"type"in t){let n=t;switch(n.type){case"string":return n.format?`string (${n.format})`:n.pattern?`string matching ${n.pattern}`:n.minLength!==void 0&&n.maxLength!==void 0?`string (${n.minLength}-${n.maxLength} chars)`:"string";case"number":case"integer":return n.minimum!==void 0&&n.maximum!==void 0?`${n.type} (${n.minimum}-${n.maximum})`:n.minimum!==void 0?`${n.type} >= ${n.minimum}`:n.maximum!==void 0?`${n.type} <= ${n.maximum}`:n.type;case"boolean":return"boolean";case"array":return"array";case"object":return"object";case"null":return"null"}}return"value"}var sr=se("string",e=>typeof e=="string"?!0:`expected string, got ${e===null?"null":typeof e}`),ir=se("number",e=>typeof e=="number"?!0:`expected number, got ${e===null?"null":typeof e}`),ar=se("boolean",e=>typeof e=="boolean"?!0:`expected boolean, got ${e===null?"null":typeof e}`),or=se("integer",e=>typeof e!="number"?`expected integer, got ${e===null?"null":typeof e}`:Number.isInteger(e)?!0:`${e} is not an integer`),ur=se("positive integer",e=>typeof e!="number"?`expected positive integer, got ${e===null?"null":typeof e}`:Number.isInteger(e)?e<=0?`${e} is not positive`:!0:`${e} is not an integer`),cr=se("non-empty string",e=>typeof e!="string"?`expected string, got ${e===null?"null":typeof e}`:e.length===0?"string is empty":!0),lr=se("email address",e=>typeof e!="string"?`expected string, got ${e===null?"null":typeof e}`:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)?!0:`"${e}" is not a valid email`),_i=e=>{try{return new URL(e),!0}catch{return!1}},fr=se("URL",e=>typeof e!="string"?`expected string, got ${e===null?"null":typeof e}`:_i(e)?!0:`"${e}" is not a valid URL`),pr=se("UUID",e=>typeof e!="string"?`expected string, got ${e===null?"null":typeof e}`:/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)?!0:`"${e}" is not a valid UUID`),wi=e=>{let t=new Date(e);return!isNaN(t.getTime())&&e.includes("T")},Si=e=>{if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let t=new Date(e+"T00:00:00Z");return!isNaN(t.getTime())},vi=se("ISO 8601 timestamp",e=>typeof e=="string"&&wi(e)),ki=se("date (YYYY-MM-DD)",e=>typeof e=="string"&&Si(e));function hr(e){return se(`${e.description} or null`,t=>t===null||e.check(t)===!0)}function dr(e){return se(`${e.description} (optional)`,t=>t==null||e.check(t)===!0)}function mr(e,t,...n){if(typeof e=="string"&&Array.isArray(t)){let a=e,i=t,o=new Set(i);return{description:a,check:c=>o.has(c),toJSONSchema:()=>({enum:i}),strip:c=>c,__runtimeType:!0,values:i}}let r=[];Xe(e)&&r.push(e),Xe(t)&&r.push(t),r.push(...n);let s=r.map(a=>a.description).join(" | ");return se(s,a=>r.some(i=>i.check(a)===!0))}function gr(e){return se(`array of ${e.description}`,t=>Array.isArray(t)&&t.every(n=>e.check(n)===!0))}function Mo(e){if(Xe(e))return n=>e.check(n)===!0;if(e&&typeof e=="object"&&"schema"in e)return n=>Ne(n,e);let t=ye.infer(e);return n=>Ne(n,t)}function Ot(e,t,n){let r=[],s=[];for(let i of e)typeof i=="string"?(r.push(i),s.push(void 0)):(r.push(i[0]),s.push(i[1]));let a=(...i)=>{let o=r.map((c,l)=>{let p=l<i.length?i[l]:s[l];return p===void 0?()=>!0:Mo(p)}),u=n;return r.forEach((c,l)=>{let p=l<i.length?i[l]:s[l],f="any";Xe(p)?f=p.description:p!==void 0&&(f=typeof p=="string"?"string":JSON.stringify(p)),u=u.replace(new RegExp(`\\b${c}\\b`,"g"),f)}),se(u,c=>t(c,...o))};return a.params=r,a.description=n,a}var yr=Ot(["T","U"],(e,t,n)=>Array.isArray(e)&&e.length===2&&t(e[0])&&n(e[1]),"Pair<T, U>"),br=Ot(["V"],(e,t)=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.values(e).every(t),"Record<string, V>");function xr(e,t){let n=Object.values(t),r=new Set(n),s=Object.keys(t),a={};for(let[o,u]of Object.entries(t))a[u]=o;return{description:e,check:o=>r.has(o),toJSONSchema:()=>({enum:n}),strip:o=>o,__runtimeType:!0,members:t,names:a,values:n,keys:s}}function Oo(e){if(e===null)return"null";if(e===void 0)return"undefined";switch(typeof e){case"string":return"string";case"boolean":return"boolean";case"number":return Number.isInteger(e)?"integer":"number";case"object":return Array.isArray(e)?"array":"object";default:return null}}function gn(e,t,n){if(Array.isArray(t)&&n){let r=t,s=[],a=[];for(let o of r)Array.isArray(o)?(s.push(o[0]),a.push(o[1])):(s.push(o),a.push(void 0));let i=((...o)=>{let u=s.map((l,p)=>p<o.length?o[p]:a[p]),c=n(...u);return gn(e,c)});return Object.defineProperties(i,{typeParamNames:{value:s,enumerable:!0},description:{value:e,enumerable:!0},__runtimeType:{value:!0,enumerable:!0}}),i}return Bo(e,t)}function Bo(e,t){let n={},r,s="assertReturns";if(typeof t=="function"){let i=t.__tjs;if(i){if(i.params)for(let[o,u]of Object.entries(i.params))n[o]=u?.example??null;i.returns&&(r=i.returns?.example??null),i.safeReturn?s="checkedReturns":i.unsafe?s="assertReturns":s="returns"}}else n=t.params??{},r=t.returns,s=t.returnContract??"assertReturns";return{description:e,params:n,returns:r,returnContract:s,toJSONSchema:()=>({description:e,type:"function"}),strip:i=>i,check:i=>{if(typeof i!="function")return`expected function, got ${i===null?"null":typeof i}`;let o=Object.keys(n).length;if(o>0){let c=i.__tjs;if(c?.params){let l=Object.keys(c.params).length;if(l!==o)return`expected ${o} params, got ${l}`;let p=Object.keys(n),f=Object.keys(c.params);for(let d=0;d<p.length;d++){let g=c.params[f[d]],y=n[p[d]];if(g?.type?.kind&&y!==void 0){let w=Oo(y);if(w&&g.type.kind!==w&&g.type.kind!=="any")return`param '${p[d]}' expected ${w}, got ${g.type.kind}`}}}}return!0},__runtimeType:!0}}var Do=Ei(),Ve=Do.version,Bt=Symbol.for("tjs.equals");function bn(e){let[t=0,n=0,r=0]=e.split(".").map(Number);return{major:t,minor:n,patch:r}}function wr(e,t){let n=bn(e),r=bn(t);return n.major!==r.major?n.major<r.major?-1:1:n.minor!==r.minor?n.minor<r.minor?-1:1:n.patch!==r.patch?n.patch<r.patch?-1:1:0}function Sr(e,t){let n=bn(e),r=bn(t);return n.major===r.major}var He=class e extends Error{path;expected;actual;callStack;reason;constructor(t,n,r,s,a,i){super(t),this.name="MonadicError",this.path=n,this.expected=r,this.actual=s,this.callStack=a,this.reason=i,Error.captureStackTrace&&Error.captureStackTrace(this,e)}};function Lo(e,t,n,r){let s=n===null?"null":typeof n,a=H.callStacks||H.debug?kr():void 0,i=r?`Expected ${t} for '${e}': ${r}`:`Expected ${t} for '${e}', got ${s}`,o=new He(i,e,t,s,a,r);if(H.trackErrors!==!1){let u=H.maxErrors??xn;$i[mt]=o,mt=(mt+1)%u,nt<u&&nt++,_n++}if(H.logTypeErrors&&console.error(`[TJS TypeError] ${o.message}`),H.throwTypeErrors)throw o;return o}function _r(e){return e instanceof Error&&e.name==="MonadicError"&&"path"in e}var vr={debug:!1,safety:"inputs",requireReturnTypes:!1,callStacks:!1,maxStackSize:64,trackErrors:!0,maxErrors:64},H={...vr},Ft=64,Ti=new Array(Ft).fill(""),tt=0,Ue=0,xn=64,$i=new Array(xn).fill(null),mt=0,nt=0,_n=0,bt=0;function Vo(){bt++}function qo(){bt>0&&bt--}function Uo(){return bt>0}function Wo(e){H={...H,...e}}function Jo(){return{...H}}function Ci(e){if((H.callStacks||H.debug)&&e){let t=H.maxStackSize??Ft;Ti[tt]=e,tt=(tt+1)%t,Ue<t&&Ue++}}function yn(){if((H.callStacks||H.debug)&&Ue>0){let e=H.maxStackSize??Ft;tt=(tt-1+e)%e,Ue--}}function kr(){if(Ue===0)return[];let e=H.maxStackSize??Ft,t=[],n=(tt-Ue+e)%e;for(let r=0;r<Ue;r++)t.push(Ti[(n+r)%e]);return t}function Ai(){if(H.trackErrors===!1||nt===0)return[];let e=H.maxErrors??xn,t=[],n=(mt-nt+e)%e;for(let r=0;r<nt;r++)t.push($i[(n+r)%e]);return t}function zo(){let e=Ai();return mt=0,nt=0,_n=0,e}function Go(){return _n}function Ho(){H={...vr},tt=0,Ue=0,mt=0,nt=0,_n=0,bt=0}function gt(e,t){if(e!==null&&typeof e=="object"&&typeof e[Bt]=="function")return e[Bt](t);if(t!==null&&typeof t=="object"&&typeof t[Bt]=="function")return t[Bt](e);if(e!==null&&typeof e=="object"&&typeof e.Equals=="function")return e.Equals(t);if(t!==null&&typeof t=="object"&&typeof t.Equals=="function")return t.Equals(e);if((e instanceof String||e instanceof Number||e instanceof Boolean)&&(e=e.valueOf()),(t instanceof String||t instanceof Number||t instanceof Boolean)&&(t=t.valueOf()),e===t||typeof e=="number"&&typeof t=="number"&&isNaN(e)&&isNaN(t)||e==null&&t==null)return!0;if(e==null||t===null||t===void 0||typeof e!=typeof t||typeof e!="object")return!1;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let s of e)if(!t.has(s))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[s,a]of e)if(!t.has(s)||!gt(a,t.get(s)))return!1;return!0}if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.toString()===t.toString();if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,a)=>gt(s,t[a]));if(Array.isArray(e)!==Array.isArray(t))return!1;let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(s=>gt(e[s],t[s]))}function Pi(e,t){return!gt(e,t)}function ji(e){return e===null?"null":typeof e}function Ii(e){return e instanceof Boolean||e instanceof Number||e instanceof String?!!e.valueOf():!!e}function Er(e,t){return(e instanceof String||e instanceof Number||e instanceof Boolean)&&(e=e.valueOf()),(t instanceof String||t instanceof Number||t instanceof Boolean)&&(t=t.valueOf()),!!(e===t||typeof e=="number"&&typeof t=="number"&&isNaN(e)&&isNaN(t)||e==null&&t==null)}function Ni(e,t){return!Er(e,t)}function qe(e){return e!==null&&typeof e=="object"&&e.$error===!0}function Re(e,t){let n={$error:!0,message:e,...t};if((H.callStacks||H.debug)&&Ue>0){let r=kr(),s=t?.path?[...r,t.path]:r;n.stack=s}return n}function Tr(e,t){if(e.length===0)return Re("Unknown error");if(e.length===1)return e[0];let n=e.map(s=>{if(s.path){let a=s.path.split(".");return a[a.length-1]}return"unknown"}).join(", "),r=`Multiple parameter errors in ${t||"function"}: ${n}`;return Re(r,{path:t,errors:e})}function yt(e){if(e===null)return"null";if(e===void 0)return"undefined";if(Array.isArray(e))return"array";let t=typeof e;if(t!=="object")return t;let n=e.constructor?.name;return n&&n!=="Object"?n:"object"}function Ri(e,t){if(e==null||typeof e!="object"&&typeof e!="function")return!1;let n=e;for(;n!==null;){if(n.constructor?.name===t)return!0;n=Object.getPrototypeOf(n)}return!1}function rt(e,t,n){if(qe(e))return e;if(typeof t=="object"&&t!==null&&"check"in t){let s=t.check(e);if(s===!0)return null;let a=typeof s=="string"?s:void 0,i=a?`Expected ${t.description} for '${n}': ${a}`:`Expected ${t.description} but got ${yt(e)}`;return Re(i,{path:n,expected:t.description,actual:yt(e),reason:a})}let r=yt(e);return t==="any"||t===r||t==="number"&&r==="number"||t==="integer"&&r==="number"&&Number.isInteger(e)||t==="non-negative-integer"&&r==="number"&&Number.isInteger(e)&&e>=0||t==="object"&&r==="object"?null:Re(`Expected ${t} but got ${r}`,{path:n,expected:t,actual:r})}function Mi(e,t,n,r){if(typeof e!="function")return e;let s=e.__tjs;if(!s||!s.params)return e;let a=Object.entries(s.params);for(let i=0;i<t.length;i++){let o=t[i];if(o==="any")continue;let u=a[i];if(!u)continue;let c=u[1]?.type?.kind;if(!(!c||c==="any")&&c!==o)return new He(`Expected (...arg${i}: ${o}, ...) for '${r}', but callback declares arg${i} as ${c}`,`${r}(arg${i})`,o,c)}if(n!=="any"&&s.returns){let i=s.returns.type?.kind??s.returns.kind;if(i&&i!=="any"&&i!==n)return new He(`Expected callback returning ${n} for '${r}', but callback returns ${i}`,`${r}(return)`,n,i)}return e}function $r(e,t,n){for(let[r,s]of Object.entries(t.params)){let a=e[r];if(qe(a))return a;if(s.required&&a===void 0){let o=typeof s.type=="string"?s.type:s.type.description;return Re(`Missing required parameter '${r}'`,{path:n?`${n}.${r}`:r,expected:o,actual:"undefined",loc:s.loc})}if(a===void 0)continue;let i=rt(a,s.type,n?`${n}.${r}`:r);if(i)return s.loc&&(i.loc=s.loc),i}return null}function Cr(e,t){if(e.__tjs=t,e.__tjs.schema=()=>rr(t),!(!t.polymorphic&&(t.safe||t.safeReturn||H.safety!=="none"&&!t.unsafe||t.returns&&H.safety==="all"&&!t.unsafeReturn)))return e;let r=!!t.returns,s=!!t.unsafe,a=!!t.safe,i=!!t.unsafeReturn,o=!!t.safeReturn,u=t.returns?.defaults,c=Object.entries(t.params),l=c.length,p=e.name||t.name||"anonymous",f=function(...d){if(bt>0)return e.apply(this,d);let g=a||!s&&H.safety!=="none",y=r&&(o||!i&&H.safety==="all");if(!g&&!y)return e.apply(this,d);if(d.length>0&&qe(d[0]))return d[0];if(g){let k=d.length===1&&typeof d[0]=="object"&&d[0]!==null&&!Array.isArray(d[0]),S=[];if(k){let b=d[0];for(let _=0;_<l;_++){let[v,x]=c[_],E=b[v];if(qe(E)){S.push(E);continue}if(x.required&&E===void 0){S.push(Re(`Missing required parameter '${v}'`,{path:`${p}.${v}`,expected:typeof x.type=="string"?x.type:x.type?.description||"value",actual:"undefined",loc:x.loc}));continue}if(E!==void 0){let $=rt(E,x.type,`${p}.${v}`);$&&(x.loc&&($.loc=x.loc),S.push($))}}}else for(let b=0;b<l;b++){let[_,v]=c[b],x=d[b];if(qe(x)){S.push(x);continue}if(v.required&&x===void 0){S.push(Re(`Missing required parameter '${_}'`,{path:`${p}.${_}`,expected:typeof v.type=="string"?v.type:v.type?.description||"value",actual:"undefined",loc:v.loc}));continue}if(x!==void 0){let E=rt(x,v.type,`${p}.${_}`);E&&(v.loc&&(E.loc=v.loc),S.push(E))}}if(S.length>0)return Tr(S,p)}let w=H.callStacks||H.debug;w&&Ci(p);try{let k=e.apply(this,d);if(y&&t.returns&&!qe(k)){let S=u&&typeof k=="object"&&k!==null?Object.assign({},u,k):k,b=rt(S,t.returns.type,`${p}()`);if(b)return w&&yn(),b}return w&&yn(),k}catch(k){return w&&yn(),Re(k.message||String(k),{path:p,cause:k})}};return Object.defineProperty(f,"name",{value:e.name}),f.__tjs=t,f.__tjs.schema=()=>rr(t),f}function Oi(e){let t=new Proxy(e,{construct(n,r,s){return Reflect.construct(n,r,s)},apply(n,r,s){return Reflect.construct(n,s)}});Object.defineProperty(t,"name",{value:e.name});for(let n of Object.getOwnPropertyNames(e))n!=="length"&&n!=="name"&&n!=="prototype"&&Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n));return t}function Bi(){let e={...H},t=e.maxStackSize??Ft,n=new Array(t).fill(""),r=0,s=0,a=e.maxErrors??xn,i=new Array(a).fill(null),o=0,u=0,c=0,l=0;function p(N){e={...e,...N}}function f(){return{...e}}function d(N){(e.callStacks||e.debug)&&N&&(n[r]=N,r=(r+1)%t,s<t&&s++)}function g(){(e.callStacks||e.debug)&&s>0&&(r=(r-1+t)%t,s--)}function y(){if(s===0)return[];let N=[],U=(r-s+t)%t;for(let J=0;J<s;J++)N.push(n[(U+J)%t]);return N}function w(){e={...vr},r=0,s=0,o=0,u=0,c=0,l=0}function k(){l++}function S(){l>0&&l--}function b(){return l>0}let _=new Map;function v(N,U,J){_.has(N)||_.set(N,new Map),_.get(N).set(U,J)}function x(N,U){let J=typeof N,X;if(N==null)return;if(J==="string")X="String";else if(J==="number")X="Number";else if(J==="boolean")X="Boolean";else if(Array.isArray(N))X="Array";else if(J==="object")X=N.constructor?.name||"Object";else return;let ee=X;for(;ee;){let ot=_.get(ee);if(ot?.has(U))return ot.get(U);if(J==="object"&&!Array.isArray(N)){if(ee=Object.getPrototypeOf(ee===X?N:Object.getPrototypeOf(N))?.constructor?.name,ee==="Object"||ee===X)break}else break}let ce=_.get("Object");if(ce?.has(U))return ce.get(U)}function E(N,U,J){let X=J===null?"null":typeof J,ee=e.callStacks||e.debug?y():void 0,ce=new He(`Expected ${U} for '${N}', got ${X}`,N,U,X,ee);if(e.trackErrors!==!1&&(i[o]=ce,o=(o+1)%a,u<a&&u++,c++),e.logTypeErrors&&console.error(`[TJS TypeError] ${ce.message}`),e.throwTypeErrors)throw ce;return ce}function $(){if(e.trackErrors===!1||u===0)return[];let N=[],U=(o-u+a)%a;for(let J=0;J<u;J++)N.push(i[(U+J)%a]);return N}function C(){let N=$();return o=0,u=0,c=0,N}function I(){return c}function M(N,U){let J={$error:!0,message:N,...U};if((e.callStacks||e.debug)&&s>0){let X=U?.path?[...y(),U.path]:y();J.stack=X}return J}function F(N,U){return N==null?E(`bang.${U}`,"non-null",N):_r(N)?N:N[U]}return{version:Ve,MonadicError:He,typeError:E,isMonadicError:_r,bang:F,isError:qe,error:M,composeErrors:Tr,typeOf:yt,isNativeType:Ri,checkType:rt,validateArgs:$r,wrap:Cr,checkFnShape:Mi,wrapClass:Oi,compareVersions:wr,versionsCompatible:Sr,createRuntime:Bi,configure:p,getConfig:f,pushStack:d,popStack:g,getStack:y,errors:$,clearErrors:C,getErrorCount:I,resetRuntime:w,enterUnsafe:k,exitUnsafe:S,isUnsafeMode:b,validate:Ne,infer:ye.infer.bind(ye),Type:se,isRuntimeType:Xe,Union:mr,Generic:Ot,Enum:xr,FunctionPredicate:gn,Nullable:hr,Optional:dr,TArray:gr,TString:sr,TNumber:ir,TBoolean:ar,TInteger:or,TPositiveInt:ur,TNonEmptyString:cr,TEmail:lr,TUrl:fr,TUuid:pr,TPair:yr,TRecord:br,Is:gt,IsNot:Pi,Eq:Er,NotEq:Ni,TypeOf:ji,toBool:Ii,tjsEquals:Bt,registerExtension:v,resolveExtension:x}}var et={version:Ve,MonadicError:He,typeError:Lo,isMonadicError:_r,isError:qe,error:Re,composeErrors:Tr,typeOf:yt,isNativeType:Ri,checkType:rt,validateArgs:$r,wrap:Cr,checkFnShape:Mi,wrapClass:Oi,compareVersions:wr,versionsCompatible:Sr,configure:Wo,getConfig:Jo,pushStack:Ci,popStack:yn,getStack:kr,errors:Ai,clearErrors:zo,getErrorCount:Go,resetRuntime:Ho,enterUnsafe:Vo,exitUnsafe:qo,isUnsafeMode:Uo,createRuntime:Bi,validate:Ne,infer:ye.infer.bind(ye),Type:se,isRuntimeType:Xe,Union:mr,Generic:Ot,Enum:xr,FunctionPredicate:gn,Nullable:hr,Optional:dr,TArray:gr,TString:sr,TNumber:ir,TBoolean:ar,TInteger:or,TPositiveInt:ur,TNonEmptyString:cr,TEmail:lr,TUrl:fr,TUuid:pr,Timestamp:vi,LegalDate:ki,TPair:yr,TRecord:br,Is:gt,IsNot:Pi,Eq:Er,NotEq:Ni,TypeOf:ji,toBool:Ii};function Ar(){let e=globalThis;if(e.__tjs){let t=e.__tjs.version;if(typeof t!="string")return e.__tjs=et,et;let n=wr(Ve,t);return n===0||(Sr(Ve,t)?n>0?(console.info(`TJS runtime: upgrading ${t} \u2192 ${Ve}`),e.__tjs=et):console.info(`TJS runtime: keeping ${t} (newer than ${Ve})`):(console.warn(`TJS runtime version conflict: ${t} vs ${Ve} (major version mismatch)`),n>0&&(console.warn(`Upgrading to ${Ve} - check for breaking changes`),e.__tjs=et))),e.__tjs}return e.__tjs=et,et}function Ko(e){return`
188
+ `,Qo=Ti+`
189
+ `+$i;var O=e=>({schema:e,_type:null,validate:(t,n)=>Ne(t,e,n),get optional(){return O({...e,type:Array.isArray(e.type)?[...e.type,"null"]:[e.type,"null"]})},title:t=>O({...e,title:t}),describe:t=>O({...e,description:t}),default:t=>O({...e,default:t}),meta:t=>O({...t,...e,...t}),min:t=>{let n=e.type==="string"?"minLength":e.type==="array"?"minItems":e.type==="object"?"minProperties":"minimum";return O({...e,[n]:t})},max:t=>{let n=e.type==="string"?"maxLength":e.type==="array"?"maxItems":e.type==="object"?"maxProperties":"maximum";return O({...e,[n]:t})},pattern:t=>O({...e,pattern:typeof t=="string"?t:t.source}),get email(){return O({...e,format:"email"})},get uuid(){return O({...e,format:"uuid"})},get ipv4(){return O({...e,format:"ipv4"})},get url(){return O({...e,format:"uri"})},get datetime(){return O({...e,format:"date-time"})},get emoji(){return O({...e,pattern:"^\\p{Extended_Pictographic}+$",format:"emoji"})},get int(){return O({...e,type:"integer"})},step:t=>O({...e,multipleOf:t})}),Ci=null;var fr={get email(){return O({type:"string",format:"email"})},get uuid(){return O({type:"string",format:"uuid"})},get ipv4(){return O({type:"string",format:"ipv4"})},get url(){return O({type:"string",format:"uri"})},get datetime(){return O({type:"string",format:"date-time"})},get emoji(){return O({type:"string",pattern:"^\\p{Extended_Pictographic}+$",format:"emoji"})},get null(){return O({type:"null"})},get undefined(){return O({type:"null","x-tjs-undefined":!0})},get any(){return O({})},pattern:e=>O({type:"string",pattern:typeof e=="string"?e:e.source}),union:e=>O({anyOf:e.map(t=>t.schema)}),enum:e=>O({type:typeof e[0],enum:e}),const:e=>O({const:e}),array:e=>O({type:"array",items:e.schema}),tuple:e=>O({type:"array",items:e.map(t=>t.schema),minItems:e.length,maxItems:e.length}),object:e=>{let t={},n=[];for(let r in e)t[r]=e[r].schema,(!Array.isArray(t[r].type)||!t[r].type.includes("null"))&&n.push(r);return O({type:"object",properties:t,required:n,additionalProperties:!1})},record:e=>O({type:"object",additionalProperties:e.schema}),infer:e=>{if(e===null)return O({type:"null"});if(e===void 0)return O({type:"null","x-tjs-undefined":!0});let t=typeof e;if(t==="string")return O({type:"string"});if(t==="number")return O({type:Number.isInteger(e)?"integer":"number"});if(t==="boolean")return O({type:"boolean"});if(Array.isArray(e))return e.length===0?O({type:"array"}):O({type:"array",items:fr.infer(e[0]).schema});if(t==="object"){let n={},r=[];for(let s in e)n[s]=fr.infer(e[s]).schema,r.push(s);return O({type:"object",properties:n,required:r,additionalProperties:!1})}return O({})}},ye=new Proxy(fr,{get(e,t){if(t in e)return e[t];if(t==="string"||t==="number"||t==="boolean"||t==="integer"){let n=O({type:t});return e[t]=n,n}}}),_n=97,Ai={email:e=>/^\S+@\S+\.\S+$/.test(e),uuid:e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e),uri:e=>{try{return new URL(e),!0}catch{return!1}},ipv4:e=>/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(e),"date-time":e=>!isNaN(Date.parse(e)),emoji:e=>new RegExp("\\p{Extended_Pictographic}","u").test(e)};function Ne(e,t,n){let r=t?.schema||t,s=typeof n=="function"?n:n?.onError,a=typeof n=="object"?n?.strict??n?.fullScan??!1:!1,i=[],o=c=>(s&&s(i.join(".")||"root",c),!1),u=(c,l)=>{if(l.anyOf){for(let f of l.anyOf)if(Ne(c,f))return!0;return o("Union mismatch")}if(l.const!==void 0)return c===l.const||o("Const mismatch");if(c===null){let f=l.type==="null"&&!l["x-tjs-undefined"],d=Array.isArray(l.type)&&l.type.includes("null");return f||d||!l.type||o("Expected value, got null")}if(c===void 0){let f=l.type==="null"&&l["x-tjs-undefined"],d=Array.isArray(l.type)&&l.type.includes("null");return f||d||!l.type||o("Expected value, got undefined")}let p=Array.isArray(l.type)?l.type[0]:l.type;if(l.enum&&!l.enum.includes(c))return o("Enum mismatch");if(p==="integer"){if(typeof c!="number"||!Number.isInteger(c))return o("Expected integer")}else if(p==="array"){if(!Array.isArray(c))return o("Expected array")}else if(p==="object"){if(typeof c!="object"||Array.isArray(c))return o("Expected object")}else if(p&&typeof c!==p)return o(`Expected ${p}`);if(l.$predicate&&Ci&&!Ci(l.$predicate,c))return o("Predicate mismatch");if(typeof c=="number"){if(!Number.isFinite(c))return o("Expected finite number");if(l.minimum!==void 0&&c<l.minimum)return o("Value < min");if(l.maximum!==void 0&&c>l.maximum)return o("Value > max");if(l.multipleOf!==void 0){let f=Math.abs(c%l.multipleOf),d=1e-10;if(f>1e-10&&Math.abs(f-Math.abs(l.multipleOf))>1e-10)return o("Value not step")}}if(typeof c=="string"){if(l.minLength!==void 0&&c.length<l.minLength)return o("Len < min");if(l.maxLength!==void 0&&c.length>l.maxLength)return o("Len > max");if(l.pattern&&!new RegExp(l.pattern,l.format==="emoji"?"u":"").test(c))return o("Pattern mismatch");if(l.format&&Ai[l.format]&&!Ai[l.format](c))return o("Format invalid")}if(p==="object"){let f=l.minProperties!==void 0,d=a&&l.maxProperties!==void 0;if(f||d){let m=0;for(let y in c)Object.prototype.hasOwnProperty.call(c,y)&&m++;if(f&&m<l.minProperties)return o("Too few props");if(d&&m>l.maxProperties)return o("Too many props")}if(l.required){for(let m of l.required)if(!(m in c))return o(`Missing ${m}`)}if(l.properties){for(let m in l.properties)if(m in c){i.push(m);let y=u(c[m],l.properties[m]);if(i.pop(),!y)return!1}}if(l.additionalProperties){let m=[];for(let S in c)l.properties&&S in l.properties||m.push(S);let y=m.length,x=a||y<=_n?1:Math.floor(y/_n);for(let S=0;S<y;S+=x){let E=x>1&&S>y-1-x?y-1:S,_=m[E];i.push(_);let b=u(c[_],l.additionalProperties);if(i.pop(),!b)return!1;if(E===y-1)break}}return!0}if(p==="array"&&l.items){let f=c.length;if(l.minItems!==void 0&&f<l.minItems)return o("Array too short");if(l.maxItems!==void 0&&f>l.maxItems)return o("Array too long");if(Array.isArray(l.items)){for(let m=0;m<l.items.length;m++){if(i.push(String(m)),!u(c[m],l.items[m]))return i.pop(),!1;i.pop()}return!0}let d=a||f<=_n?1:Math.floor(f/_n);for(let m=0;m<f;m+=d){let y=d>1&&m>f-1-d?f-1:m;i.push(String(y));let x=u(c[y],l.items);if(i.pop(),!x)return!1;if(y===f-1)break}return!0}return!0};return u(e,r)}function Pi(e,t,n){let r=t?.schema||t,s=typeof n=="function"?n:n?.onError,a=typeof n=="object"?n?.strict??n?.fullScan??!1:!1;if(!(typeof n=="object"&&n?.skipValidation)){let i="",o="";if(!Ne(e,r,{onError:(u,c)=>{i||(i=u,o=c),s&&s(u,c)},fullScan:a}))return Error(`${i}: ${o}`)}return wn(e,r)}function wn(e,t){if(e==null)return e;let n=t.type;if(n==="object"&&t.properties&&typeof e=="object"&&!Array.isArray(e)){let r={};for(let s of Object.keys(t.properties))s in e&&(r[s]=wn(e[s],t.properties[s]));return r}return n==="array"&&Array.isArray(e)&&t.items?Array.isArray(t.items)?e.slice(0,t.items.length).map((r,s)=>wn(r,t.items[s])):e.map(r=>wn(r,t.items)):e}function gt(e){if(e.nullable)return{anyOf:[gt({...e,nullable:!1}),{type:"null"}]};switch(e.kind){case"string":return{type:"string"};case"number":return{type:"number"};case"integer":return{type:"integer"};case"non-negative-integer":return{type:"integer",minimum:0};case"boolean":return{type:"boolean"};case"null":return{type:"null"};case"undefined":return{};case"any":return{};case"array":return e.items?{type:"array",items:gt(e.items)}:{type:"array"};case"object":if(e.shape){let t={},n=[];for(let[r,s]of Object.entries(e.shape))t[r]=gt(s),n.push(r);return{type:"object",properties:t,required:n,additionalProperties:!1}}return{type:"object"};case"union":return e.members?{anyOf:e.members.map(gt)}:{};default:return{}}}function yt(e){if(e===null)return{type:"null"};if(e===void 0)return{};switch(typeof e){case"string":return{type:"string"};case"number":return Number.isInteger(e)?{type:"integer"}:{type:"number"};case"boolean":return{type:"boolean"};case"object":{if(Array.isArray(e))return e.length===0?{type:"array"}:{type:"array",items:yt(e[0])};let t={},n=[];for(let[r,s]of Object.entries(e))t[r]=yt(s),n.push(r);return{type:"object",properties:t,required:n,additionalProperties:!1}}default:return{}}}function pr(e){let t={},n=[];for(let[a,i]of Object.entries(e.params))i?.type?.kind?t[a]=gt(i.type):i?.example!==void 0?t[a]=yt(i.example):t[a]={},i?.required!==!1&&n.push(a),i?.example!==void 0&&(t[a].examples=[i.example]);let r={type:"object",properties:t,required:n},s;return e.returns&&(e.returns.type?.kind?s=gt(e.returns.type):e.returns.example!==void 0&&(s=yt(e.returns.example))),{input:r,output:s}}function rt(e){return e!==null&&typeof e=="object"&&"__runtimeType"in e&&e.__runtimeType===!0}function ji(e){return e!==null&&typeof e=="object"&&"schema"in e&&typeof e.schema=="object"}function Yo(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}function se(e,t,n,r){let s,a,i,o=n,u=r;if(typeof e=="string")if(s=e,typeof t=="function")a=t,o!==void 0&&(i=ye.infer(o));else if(t===void 0&&o!==void 0)i=ye.infer(o);else if(ji(t))i=t;else if(Yo(t))i=t;else if(t!==void 0)o=t,u=o,i=ye.infer(o);else throw new Error("Type(description) requires a predicate, schema, or example");else ji(e),i=e,s=Xo(i);let c;if(i){let p=i?.schema??i;p&&typeof p=="object"&&Array.isArray(p.examples)&&(c=p.examples)}return o===void 0&&c&&c.length>0&&(o=c[0]),{description:s,check:p=>a?a(p):i?Ne(p,i):!1,schema:i,predicate:a,example:o,examples:c,default:u,toJSONSchema(){if(i){let p=i?.schema??i;if(p&&typeof p=="object"&&"type"in p)return p}return o!==void 0?yt(o):{description:s}},strip(p){return i?Pi(p,i):p},__runtimeType:!0}}function Xo(e){let t=e?.schema??e;if(t&&typeof t=="object"&&"type"in t){let n=t;switch(n.type){case"string":return n.format?`string (${n.format})`:n.pattern?`string matching ${n.pattern}`:n.minLength!==void 0&&n.maxLength!==void 0?`string (${n.minLength}-${n.maxLength} chars)`:"string";case"number":case"integer":return n.minimum!==void 0&&n.maximum!==void 0?`${n.type} (${n.minimum}-${n.maximum})`:n.minimum!==void 0?`${n.type} >= ${n.minimum}`:n.maximum!==void 0?`${n.type} <= ${n.maximum}`:n.type;case"boolean":return"boolean";case"array":return"array";case"object":return"object";case"null":return"null"}}return"value"}var hr=se("string",e=>typeof e=="string"?!0:`expected string, got ${e===null?"null":typeof e}`),dr=se("number",e=>typeof e=="number"?!0:`expected number, got ${e===null?"null":typeof e}`),mr=se("boolean",e=>typeof e=="boolean"?!0:`expected boolean, got ${e===null?"null":typeof e}`),gr=se("integer",e=>typeof e!="number"?`expected integer, got ${e===null?"null":typeof e}`:Number.isInteger(e)?!0:`${e} is not an integer`),yr=se("positive integer",e=>typeof e!="number"?`expected positive integer, got ${e===null?"null":typeof e}`:Number.isInteger(e)?e<=0?`${e} is not positive`:!0:`${e} is not an integer`),br=se("non-empty string",e=>typeof e!="string"?`expected string, got ${e===null?"null":typeof e}`:e.length===0?"string is empty":!0),xr=se("email address",e=>typeof e!="string"?`expected string, got ${e===null?"null":typeof e}`:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)?!0:`"${e}" is not a valid email`),Ii=e=>{try{return new URL(e),!0}catch{return!1}},_r=se("URL",e=>typeof e!="string"?`expected string, got ${e===null?"null":typeof e}`:Ii(e)?!0:`"${e}" is not a valid URL`),wr=se("UUID",e=>typeof e!="string"?`expected string, got ${e===null?"null":typeof e}`:/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)?!0:`"${e}" is not a valid UUID`),Ni=e=>{let t=new Date(e);return!isNaN(t.getTime())&&e.includes("T")},Ri=e=>{if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let t=new Date(e+"T00:00:00Z");return!isNaN(t.getTime())},Mi=se("ISO 8601 timestamp",e=>typeof e=="string"&&Ni(e)),Oi=se("date (YYYY-MM-DD)",e=>typeof e=="string"&&Ri(e));function Sr(e){return se(`${e.description} or null`,t=>t===null||e.check(t)===!0)}function vr(e){return se(`${e.description} (optional)`,t=>t==null||e.check(t)===!0)}function kr(e,t,...n){if(typeof e=="string"&&Array.isArray(t)){let a=e,i=t,o=new Set(i);return{description:a,check:c=>o.has(c),toJSONSchema:()=>({enum:i}),strip:c=>c,__runtimeType:!0,values:i}}let r=[];rt(e)&&r.push(e),rt(t)&&r.push(t),r.push(...n);let s=r.map(a=>a.description).join(" | ");return se(s,a=>r.some(i=>i.check(a)===!0))}function Er(e){return se(`array of ${e.description}`,t=>Array.isArray(t)&&t.every(n=>e.check(n)===!0))}function eu(e){if(rt(e))return n=>e.check(n)===!0;if(e&&typeof e=="object"&&"schema"in e)return n=>Ne(n,e);let t=ye.infer(e);return n=>Ne(n,t)}function Vt(e,t,n){let r=[],s=[];for(let i of e)typeof i=="string"?(r.push(i),s.push(void 0)):(r.push(i[0]),s.push(i[1]));let a=(...i)=>{let o=r.map((c,l)=>{let p=l<i.length?i[l]:s[l];return p===void 0?()=>!0:eu(p)}),u=n;return r.forEach((c,l)=>{let p=l<i.length?i[l]:s[l],f="any";rt(p)?f=p.description:p!==void 0&&(f=typeof p=="string"?"string":JSON.stringify(p)),u=u.replace(new RegExp(`\\b${c}\\b`,"g"),f)}),se(u,c=>t(c,...o))};return a.params=r,a.description=n,a}var Tr=Vt(["T","U"],(e,t,n)=>Array.isArray(e)&&e.length===2&&t(e[0])&&n(e[1]),"Pair<T, U>"),$r=Vt(["V"],(e,t)=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.values(e).every(t),"Record<string, V>");function Cr(e,t){let n=Object.values(t),r=new Set(n),s=Object.keys(t),a={};for(let[o,u]of Object.entries(t))a[u]=o;return{description:e,check:o=>r.has(o),toJSONSchema:()=>({enum:n}),strip:o=>o,__runtimeType:!0,members:t,names:a,values:n,keys:s}}function tu(e){if(e===null)return"null";if(e===void 0)return"undefined";switch(typeof e){case"string":return"string";case"boolean":return"boolean";case"number":return Number.isInteger(e)?"integer":"number";case"object":return Array.isArray(e)?"array":"object";default:return null}}function Sn(e,t,n){if(Array.isArray(t)&&n){let r=t,s=[],a=[];for(let o of r)Array.isArray(o)?(s.push(o[0]),a.push(o[1])):(s.push(o),a.push(void 0));let i=((...o)=>{let u=s.map((l,p)=>p<o.length?o[p]:a[p]),c=n(...u);return Sn(e,c)});return Object.defineProperties(i,{typeParamNames:{value:s,enumerable:!0},description:{value:e,enumerable:!0},__runtimeType:{value:!0,enumerable:!0}}),i}return nu(e,t)}function nu(e,t){let n={},r,s="assertReturns";if(typeof t=="function"){let i=t.__tjs;if(i){if(i.params)for(let[o,u]of Object.entries(i.params))n[o]=u?.example??null;i.returns&&(r=i.returns?.example??null),i.safeReturn?s="checkedReturns":i.unsafe?s="assertReturns":s="returns"}}else n=t.params??{},r=t.returns,s=t.returnContract??"assertReturns";return{description:e,params:n,returns:r,returnContract:s,toJSONSchema:()=>({description:e,type:"function"}),strip:i=>i,check:i=>{if(typeof i!="function")return`expected function, got ${i===null?"null":typeof i}`;let o=Object.keys(n).length;if(o>0){let c=i.__tjs;if(c?.params){let l=Object.keys(c.params).length;if(l!==o)return`expected ${o} params, got ${l}`;let p=Object.keys(n),f=Object.keys(c.params);for(let d=0;d<p.length;d++){let m=c.params[f[d]],y=n[p[d]];if(m?.type?.kind&&y!==void 0){let x=tu(y);if(x&&m.type.kind!==x&&m.type.kind!=="any")return`param '${p[d]}' expected ${x}, got ${m.type.kind}`}}}}return!0},__runtimeType:!0}}var su=Bi(),Ve=su.version,qt=Symbol.for("tjs.equals");function kn(e){let[t=0,n=0,r=0]=e.split(".").map(Number);return{major:t,minor:n,patch:r}}function Pr(e,t){let n=kn(e),r=kn(t);return n.major!==r.major?n.major<r.major?-1:1:n.minor!==r.minor?n.minor<r.minor?-1:1:n.patch!==r.patch?n.patch<r.patch?-1:1:0}function jr(e,t){let n=kn(e),r=kn(t);return n.major===r.major}var He=class e extends Error{path;expected;actual;callStack;reason;constructor(t,n,r,s,a,i){super(t),this.name="MonadicError",this.path=n,this.expected=r,this.actual=s,this.callStack=a,this.reason=i,Error.captureStackTrace&&Error.captureStackTrace(this,e)}};function iu(e,t,n,r){let s=n===null?"null":typeof n,a=H.callStacks||H.debug?Nr():void 0,i=r?`Expected ${t} for '${e}': ${r}`:`Expected ${t} for '${e}', got ${s}`,o=new He(i,e,t,s,a,r);if(H.trackErrors!==!1){let u=H.maxErrors??En;Fi[bt]=o,bt=(bt+1)%u,at<u&&at++,Tn++}if(H.logTypeErrors&&console.error(`[TJS TypeError] ${o.message}`),H.throwTypeErrors)throw o;return o}function Ar(e){return e instanceof Error&&e.name==="MonadicError"&&"path"in e}var Ir={debug:!1,safety:"inputs",requireReturnTypes:!1,callStacks:!1,maxStackSize:64,trackErrors:!0,maxErrors:64},H={...Ir},Ut=64,Di=new Array(Ut).fill(""),it=0,Ue=0,En=64,Fi=new Array(En).fill(null),bt=0,at=0,Tn=0,wt=0;function au(){wt++}function ou(){wt>0&&wt--}function uu(){return wt>0}function cu(e){H={...H,...e}}function lu(){return{...H}}function Li(e){if((H.callStacks||H.debug)&&e){let t=H.maxStackSize??Ut;Di[it]=e,it=(it+1)%t,Ue<t&&Ue++}}function vn(){if((H.callStacks||H.debug)&&Ue>0){let e=H.maxStackSize??Ut;it=(it-1+e)%e,Ue--}}function Nr(){if(Ue===0)return[];let e=H.maxStackSize??Ut,t=[],n=(it-Ue+e)%e;for(let r=0;r<Ue;r++)t.push(Di[(n+r)%e]);return t}function Vi(){if(H.trackErrors===!1||at===0)return[];let e=H.maxErrors??En,t=[],n=(bt-at+e)%e;for(let r=0;r<at;r++)t.push(Fi[(n+r)%e]);return t}function fu(){let e=Vi();return bt=0,at=0,Tn=0,e}function pu(){return Tn}function hu(){H={...Ir},it=0,Ue=0,bt=0,at=0,Tn=0,wt=0}function xt(e,t){if(e!==null&&typeof e=="object"&&typeof e[qt]=="function")return e[qt](t);if(t!==null&&typeof t=="object"&&typeof t[qt]=="function")return t[qt](e);if(e!==null&&typeof e=="object"&&typeof e.Equals=="function")return e.Equals(t);if(t!==null&&typeof t=="object"&&typeof t.Equals=="function")return t.Equals(e);if((e instanceof String||e instanceof Number||e instanceof Boolean)&&(e=e.valueOf()),(t instanceof String||t instanceof Number||t instanceof Boolean)&&(t=t.valueOf()),e===t||typeof e=="number"&&typeof t=="number"&&isNaN(e)&&isNaN(t)||e==null&&t==null)return!0;if(e==null||t===null||t===void 0||typeof e!=typeof t||typeof e!="object")return!1;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let s of e)if(!t.has(s))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[s,a]of e)if(!t.has(s)||!xt(a,t.get(s)))return!1;return!0}if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.toString()===t.toString();if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,a)=>xt(s,t[a]));if(Array.isArray(e)!==Array.isArray(t))return!1;let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(s=>xt(e[s],t[s]))}function qi(e,t){return!xt(e,t)}function Ui(e){return e===null?"null":typeof e}function Wi(e){return e instanceof Boolean||e instanceof Number||e instanceof String?!!e.valueOf():!!e}function Rr(e,t){return(e instanceof String||e instanceof Number||e instanceof Boolean)&&(e=e.valueOf()),(t instanceof String||t instanceof Number||t instanceof Boolean)&&(t=t.valueOf()),!!(e===t||typeof e=="number"&&typeof t=="number"&&isNaN(e)&&isNaN(t)||e==null&&t==null)}function Ji(e,t){return!Rr(e,t)}function qe(e){return e!==null&&typeof e=="object"&&e.$error===!0}function Re(e,t){let n={$error:!0,message:e,...t};if((H.callStacks||H.debug)&&Ue>0){let r=Nr(),s=t?.path?[...r,t.path]:r;n.stack=s}return n}function Mr(e,t){if(e.length===0)return Re("Unknown error");if(e.length===1)return e[0];let n=e.map(s=>{if(s.path){let a=s.path.split(".");return a[a.length-1]}return"unknown"}).join(", "),r=`Multiple parameter errors in ${t||"function"}: ${n}`;return Re(r,{path:t,errors:e})}function _t(e){if(e===null)return"null";if(e===void 0)return"undefined";if(Array.isArray(e))return"array";let t=typeof e;if(t!=="object")return t;let n=e.constructor?.name;return n&&n!=="Object"?n:"object"}function zi(e,t){if(e==null||typeof e!="object"&&typeof e!="function")return!1;let n=e;for(;n!==null;){if(n.constructor?.name===t)return!0;n=Object.getPrototypeOf(n)}return!1}function ot(e,t,n){if(qe(e))return e;if(typeof t=="object"&&t!==null&&"check"in t){let s=t.check(e);if(s===!0)return null;let a=typeof s=="string"?s:void 0,i=a?`Expected ${t.description} for '${n}': ${a}`:`Expected ${t.description} but got ${_t(e)}`;return Re(i,{path:n,expected:t.description,actual:_t(e),reason:a})}let r=_t(e);return t==="any"||t===r||t==="number"&&r==="number"||t==="integer"&&r==="number"&&Number.isInteger(e)||t==="non-negative-integer"&&r==="number"&&Number.isInteger(e)&&e>=0||t==="object"&&r==="object"?null:Re(`Expected ${t} but got ${r}`,{path:n,expected:t,actual:r})}function Gi(e,t,n,r){if(typeof e!="function")return e;let s=e.__tjs;if(!s||!s.params)return e;let a=Object.entries(s.params);for(let i=0;i<t.length;i++){let o=t[i];if(o==="any")continue;let u=a[i];if(!u)continue;let c=u[1]?.type?.kind;if(!(!c||c==="any")&&c!==o)return new He(`Expected (...arg${i}: ${o}, ...) for '${r}', but callback declares arg${i} as ${c}`,`${r}(arg${i})`,o,c)}if(n!=="any"&&s.returns){let i=s.returns.type?.kind??s.returns.kind;if(i&&i!=="any"&&i!==n)return new He(`Expected callback returning ${n} for '${r}', but callback returns ${i}`,`${r}(return)`,n,i)}return e}function Or(e,t,n){for(let[r,s]of Object.entries(t.params)){let a=e[r];if(qe(a))return a;if(s.required&&a===void 0){let o=typeof s.type=="string"?s.type:s.type.description;return Re(`Missing required parameter '${r}'`,{path:n?`${n}.${r}`:r,expected:o,actual:"undefined",loc:s.loc})}if(a===void 0)continue;let i=ot(a,s.type,n?`${n}.${r}`:r);if(i)return s.loc&&(i.loc=s.loc),i}return null}function Br(e,t){if(e.__tjs=t,e.__tjs.schema=()=>pr(t),!(!t.polymorphic&&(t.safe||t.safeReturn||H.safety!=="none"&&!t.unsafe||t.returns&&H.safety==="all"&&!t.unsafeReturn)))return e;let r=!!t.returns,s=!!t.unsafe,a=!!t.safe,i=!!t.unsafeReturn,o=!!t.safeReturn,u=t.returns?.defaults,c=Object.entries(t.params),l=c.length,p=e.name||t.name||"anonymous",f=function(...d){if(wt>0)return e.apply(this,d);let m=a||!s&&H.safety!=="none",y=r&&(o||!i&&H.safety==="all");if(!m&&!y)return e.apply(this,d);if(d.length>0&&qe(d[0]))return d[0];if(m){let S=d.length===1&&typeof d[0]=="object"&&d[0]!==null&&!Array.isArray(d[0]),E=[];if(S){let _=d[0];for(let b=0;b<l;b++){let[v,w]=c[b],k=_[v];if(qe(k)){E.push(k);continue}if(w.required&&k===void 0){E.push(Re(`Missing required parameter '${v}'`,{path:`${p}.${v}`,expected:typeof w.type=="string"?w.type:w.type?.description||"value",actual:"undefined",loc:w.loc}));continue}if(k!==void 0){let T=ot(k,w.type,`${p}.${v}`);T&&(w.loc&&(T.loc=w.loc),E.push(T))}}}else for(let _=0;_<l;_++){let[b,v]=c[_],w=d[_];if(qe(w)){E.push(w);continue}if(v.required&&w===void 0){E.push(Re(`Missing required parameter '${b}'`,{path:`${p}.${b}`,expected:typeof v.type=="string"?v.type:v.type?.description||"value",actual:"undefined",loc:v.loc}));continue}if(w!==void 0){let k=ot(w,v.type,`${p}.${b}`);k&&(v.loc&&(k.loc=v.loc),E.push(k))}}if(E.length>0)return Mr(E,p)}let x=H.callStacks||H.debug;x&&Li(p);try{let S=e.apply(this,d);if(y&&t.returns&&!qe(S)){let E=u&&typeof S=="object"&&S!==null?Object.assign({},u,S):S,_=ot(E,t.returns.type,`${p}()`);if(_)return x&&vn(),_}return x&&vn(),S}catch(S){return x&&vn(),Re(S.message||String(S),{path:p,cause:S})}};return Object.defineProperty(f,"name",{value:e.name}),f.__tjs=t,f.__tjs.schema=()=>pr(t),f}function Hi(e){let t=new Proxy(e,{construct(n,r,s){return Reflect.construct(n,r,s)},apply(n,r,s){return Reflect.construct(n,s)}});Object.defineProperty(t,"name",{value:e.name});for(let n of Object.getOwnPropertyNames(e))n!=="length"&&n!=="name"&&n!=="prototype"&&Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n));return t}function Ki(){let e={...H},t=e.maxStackSize??Ut,n=new Array(t).fill(""),r=0,s=0,a=e.maxErrors??En,i=new Array(a).fill(null),o=0,u=0,c=0,l=0;function p(R){e={...e,...R}}function f(){return{...e}}function d(R){(e.callStacks||e.debug)&&R&&(n[r]=R,r=(r+1)%t,s<t&&s++)}function m(){(e.callStacks||e.debug)&&s>0&&(r=(r-1+t)%t,s--)}function y(){if(s===0)return[];let R=[],U=(r-s+t)%t;for(let J=0;J<s;J++)R.push(n[(U+J)%t]);return R}function x(){e={...Ir},r=0,s=0,o=0,u=0,c=0,l=0}function S(){l++}function E(){l>0&&l--}function _(){return l>0}let b=new Map;function v(R,U,J){b.has(R)||b.set(R,new Map),b.get(R).set(U,J)}function w(R,U){let J=typeof R,X;if(R==null)return;if(J==="string")X="String";else if(J==="number")X="Number";else if(J==="boolean")X="Boolean";else if(Array.isArray(R))X="Array";else if(J==="object")X=R.constructor?.name||"Object";else return;let ee=X;for(;ee;){let lt=b.get(ee);if(lt?.has(U))return lt.get(U);if(J==="object"&&!Array.isArray(R)){if(ee=Object.getPrototypeOf(ee===X?R:Object.getPrototypeOf(R))?.constructor?.name,ee==="Object"||ee===X)break}else break}let ce=b.get("Object");if(ce?.has(U))return ce.get(U)}function k(R,U,J){let X=J===null?"null":typeof J,ee=e.callStacks||e.debug?y():void 0,ce=new He(`Expected ${U} for '${R}', got ${X}`,R,U,X,ee);if(e.trackErrors!==!1&&(i[o]=ce,o=(o+1)%a,u<a&&u++,c++),e.logTypeErrors&&console.error(`[TJS TypeError] ${ce.message}`),e.throwTypeErrors)throw ce;return ce}function T(){if(e.trackErrors===!1||u===0)return[];let R=[],U=(o-u+a)%a;for(let J=0;J<u;J++)R.push(i[(U+J)%a]);return R}function C(){let R=T();return o=0,u=0,c=0,R}function N(){return c}function P(R,U){let J={$error:!0,message:R,...U};if((e.callStacks||e.debug)&&s>0){let X=U?.path?[...y(),U.path]:y();J.stack=X}return J}function D(R,U){return R==null?k(`bang.${U}`,"non-null",R):Ar(R)?R:R[U]}return{version:Ve,MonadicError:He,typeError:k,isMonadicError:Ar,bang:D,isError:qe,error:P,composeErrors:Mr,typeOf:_t,isNativeType:zi,checkType:ot,validateArgs:Or,wrap:Br,checkFnShape:Gi,wrapClass:Hi,compareVersions:Pr,versionsCompatible:jr,createRuntime:Ki,configure:p,getConfig:f,pushStack:d,popStack:m,getStack:y,errors:T,clearErrors:C,getErrorCount:N,resetRuntime:x,enterUnsafe:S,exitUnsafe:E,isUnsafeMode:_,validate:Ne,infer:ye.infer.bind(ye),Type:se,isRuntimeType:rt,Union:kr,Generic:Vt,Enum:Cr,FunctionPredicate:Sn,Nullable:Sr,Optional:vr,TArray:Er,TString:hr,TNumber:dr,TBoolean:mr,TInteger:gr,TPositiveInt:yr,TNonEmptyString:br,TEmail:xr,TUrl:_r,TUuid:wr,TPair:Tr,TRecord:$r,Is:xt,IsNot:qi,Eq:Rr,NotEq:Ji,TypeOf:Ui,toBool:Wi,tjsEquals:qt,registerExtension:v,resolveExtension:w}}var st={version:Ve,MonadicError:He,typeError:iu,isMonadicError:Ar,isError:qe,error:Re,composeErrors:Mr,typeOf:_t,isNativeType:zi,checkType:ot,validateArgs:Or,wrap:Br,checkFnShape:Gi,wrapClass:Hi,compareVersions:Pr,versionsCompatible:jr,configure:cu,getConfig:lu,pushStack:Li,popStack:vn,getStack:Nr,errors:Vi,clearErrors:fu,getErrorCount:pu,resetRuntime:hu,enterUnsafe:au,exitUnsafe:ou,isUnsafeMode:uu,createRuntime:Ki,validate:Ne,infer:ye.infer.bind(ye),Type:se,isRuntimeType:rt,Union:kr,Generic:Vt,Enum:Cr,FunctionPredicate:Sn,Nullable:Sr,Optional:vr,TArray:Er,TString:hr,TNumber:dr,TBoolean:mr,TInteger:gr,TPositiveInt:yr,TNonEmptyString:br,TEmail:xr,TUrl:_r,TUuid:wr,Timestamp:Mi,LegalDate:Oi,TPair:Tr,TRecord:$r,Is:xt,IsNot:qi,Eq:Rr,NotEq:Ji,TypeOf:Ui,toBool:Wi};function Dr(){let e=globalThis;if(e.__tjs){let t=e.__tjs.version;if(typeof t!="string")return e.__tjs=st,st;let n=Pr(Ve,t);return n===0||(jr(Ve,t)?n>0?(console.info(`TJS runtime: upgrading ${t} \u2192 ${Ve}`),e.__tjs=st):console.info(`TJS runtime: keeping ${t} (newer than ${Ve})`):(console.warn(`TJS runtime version conflict: ${t} vs ${Ve} (major version mismatch)`),n>0&&(console.warn(`Upgrading to ${Ve} - check for breaking changes`),e.__tjs=st))),e.__tjs}return e.__tjs=st,st}function du(e){return`
186
190
  // TJS runtime wrapper (skips unsafe functions)
187
191
  if (typeof ${e}.__tjs === 'object' && !${e}.__tjs.unsafe && typeof globalThis.__tjs?.wrap === 'function') {
188
192
  ${e} = globalThis.__tjs.wrap(${e}, ${e}.__tjs)
189
193
  }
190
- `.trim()}function Zo(e,t,n=1e-9){if(e===t)return!0;if(typeof e=="number"&&typeof t=="number"&&(!Number.isInteger(e)||!Number.isInteger(t))){let r=Math.abs(e-t),s=Math.max(Math.abs(e),Math.abs(t),1);return r/s<n}return!1}function jr(e,t){if(e===t||typeof e=="number"&&typeof t=="number"&&Number.isNaN(e)&&Number.isNaN(t)||Zo(e,t))return!0;if(e===null||t===null||e===void 0||t===void 0)return e===t;if(typeof e!=typeof t||typeof e!="object")return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,a)=>jr(s,t[a]));if(Array.isArray(e)!==Array.isArray(t))return!1;let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(s=>jr(e[s],t[s]))}function Ir(e,t,n=""){if(t===null)return e===null?{matches:!0}:{matches:!1,error:`Expected null at '${n}', got ${st(e)}`};if(t===void 0)return e===void 0?{matches:!0}:{matches:!1,error:`Expected undefined at '${n}', got ${st(e)}`};if(typeof t=="number")return typeof e=="number"?{matches:!0}:{matches:!1,error:`Expected number at '${n}', got ${st(e)}`};if(typeof t=="string")return typeof e=="string"?{matches:!0}:{matches:!1,error:`Expected string at '${n}', got ${st(e)}`};if(typeof t=="boolean")return typeof e=="boolean"?{matches:!0}:{matches:!1,error:`Expected boolean at '${n}', got ${st(e)}`};if(Array.isArray(t)){if(!Array.isArray(e))return{matches:!1,error:`Expected array at '${n}', got ${st(e)}`};if(t.length===0)return{matches:!0};let r=t[0];for(let s=0;s<e.length;s++){let a=Ir(e[s],r,`${n}[${s}]`);if(!a.matches)return a}return{matches:!0}}if(typeof t=="object"&&t!==null){if(typeof e!="object"||e===null||Array.isArray(e))return{matches:!1,error:`Expected object at '${n}', got ${st(e)}`};for(let r of Object.keys(t)){let s=n?`${n}.${r}`:r;if(!(r in e))return{matches:!1,error:`Missing property '${s}'`};let a=Ir(e[r],t[r],s);if(!a.matches)return a}return{matches:!0}}return e===t?{matches:!0}:{matches:!1,error:`Type mismatch at '${n}'`}}function st(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}function Dt(e,t=0){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.length===0?"[]":e.length<=3?`[${e.map(n=>Dt(n,t)).join(", ")}]`:`[${e.slice(0,3).map(n=>Dt(n,t)).join(", ")}, ...]`;if(typeof e=="object"){let n=Object.entries(e);if(n.length===0)return"{}";let r=u=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(u)?u:JSON.stringify(u);if(n.length<=2)return`{${n.map(([c,l])=>`${r(c)}: ${Dt(l,t)}`).join(", ")}}`;let s=" ".repeat(t+1),a=" ".repeat(t),i=n.slice(0,8).map(([u,c])=>`${s}${r(u)}: ${Dt(c,t+1)}`).join(`,
194
+ `.trim()}function mu(e,t,n=1e-9){if(e===t)return!0;if(typeof e=="number"&&typeof t=="number"&&(!Number.isInteger(e)||!Number.isInteger(t))){let r=Math.abs(e-t),s=Math.max(Math.abs(e),Math.abs(t),1);return r/s<n}return!1}function Lr(e,t){if(e===t||typeof e=="number"&&typeof t=="number"&&Number.isNaN(e)&&Number.isNaN(t)||mu(e,t))return!0;if(e===null||t===null||e===void 0||t===void 0)return e===t;if(typeof e!=typeof t||typeof e!="object")return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((s,a)=>Lr(s,t[a]));if(Array.isArray(e)!==Array.isArray(t))return!1;let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(s=>Lr(e[s],t[s]))}function Vr(e,t,n=""){if(t===null)return e===null?{matches:!0}:{matches:!1,error:`Expected null at '${n}', got ${ut(e)}`};if(t===void 0)return e===void 0?{matches:!0}:{matches:!1,error:`Expected undefined at '${n}', got ${ut(e)}`};if(typeof t=="number")return typeof e=="number"?{matches:!0}:{matches:!1,error:`Expected number at '${n}', got ${ut(e)}`};if(typeof t=="string")return typeof e=="string"?{matches:!0}:{matches:!1,error:`Expected string at '${n}', got ${ut(e)}`};if(typeof t=="boolean")return typeof e=="boolean"?{matches:!0}:{matches:!1,error:`Expected boolean at '${n}', got ${ut(e)}`};if(Array.isArray(t)){if(!Array.isArray(e))return{matches:!1,error:`Expected array at '${n}', got ${ut(e)}`};if(t.length===0)return{matches:!0};let r=t[0];for(let s=0;s<e.length;s++){let a=Vr(e[s],r,`${n}[${s}]`);if(!a.matches)return a}return{matches:!0}}if(typeof t=="object"&&t!==null){if(typeof e!="object"||e===null||Array.isArray(e))return{matches:!1,error:`Expected object at '${n}', got ${ut(e)}`};for(let r of Object.keys(t)){let s=n?`${n}.${r}`:r;if(!(r in e))return{matches:!1,error:`Missing property '${s}'`};let a=Vr(e[r],t[r],s);if(!a.matches)return a}return{matches:!0}}return e===t?{matches:!0}:{matches:!1,error:`Type mismatch at '${n}'`}}function ut(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}function Wt(e,t=0){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.length===0?"[]":e.length<=3?`[${e.map(n=>Wt(n,t)).join(", ")}]`:`[${e.slice(0,3).map(n=>Wt(n,t)).join(", ")}, ...]`;if(typeof e=="object"){let n=Object.entries(e);if(n.length===0)return"{}";let r=u=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(u)?u:JSON.stringify(u);if(n.length<=2)return`{${n.map(([c,l])=>`${r(c)}: ${Wt(l,t)}`).join(", ")}}`;let s=" ".repeat(t+1),a=" ".repeat(t),i=n.slice(0,8).map(([u,c])=>`${s}${r(u)}: ${Wt(c,t+1)}`).join(`,
191
195
  `),o=n.length>8?`,
192
196
  ${s}...`:"";return`{
193
197
  ${i}${o}
194
- ${a}}`}return String(e)}function Qo(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,n=>{let r=n.split(`
198
+ ${a}}`}return String(e)}function gu(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,n=>{let r=n.split(`
195
199
  `).length-1;return`
196
- `.repeat(r)});return t=t.replace(/\/\/[^\n]*/g,""),t}function Di(e){let t=e.replace(/^import\s+.*?from\s+['"][^'"]+['"];?\s*$/gm,"");return t=t.replace(/^import\s+['"][^'"]+['"];?\s*$/gm,""),t=t.replace(/^export\s+default\s+/gm,""),t=t.replace(/^export\s+/gm,""),t=t.replace(/^(\s*)((?:const|let|var)\s+\w+\s*=\s*)?await\s+.+$/gm,"$1/* top-level await removed for test execution */"),t}function Yo(e){if(Object.keys(e).length===0)return"";let t=[];for(let[n,r]of Object.entries(e)){let s=Di(r);t.push(`// Resolved import: ${n}`),t.push(s)}return t.join(`
197
- `)}function Fi(e){let t={},n=e.trim();if(!n.startsWith("{")||!n.includes("="))try{return{pattern:new Function(`return ${e}`)(),defaults:t}}catch{return null}let r="",s=0,a=0;for(;a<n.length;){let i=n[a];if(i==="{"||i==="["||i==="(")s++,r+=i,a++;else if(i==="}"||i==="]"||i===")")s--,r+=i,a++;else if(i==="'"||i==='"'||i==="`"){let o=i;for(r+=i,a++;a<n.length&&n[a]!==o;)n[a]==="\\"&&(r+=n[a++]),r+=n[a++];a<n.length&&(r+=n[a++])}else if(s===1&&i==="="){let c=(r.slice(r.lastIndexOf("{")+1).split(",").pop()||"").match(/\s*(\w+)\s*$/);if(c){let l=a+1;for(;l<n.length&&/\s/.test(n[l]);)l++;let p="",f=0;for(;l<n.length;){let d=n[l];if(d==="{"||d==="["||d==="(")f++;else if(d==="}"||d==="]"||d===")"){if(f===0)break;f--}else if(d===","&&f===0)break;p+=d,l++}try{t[c[1]]=new Function(`return ${p.trim()}`)()}catch{}r+=":",a++;continue}r+=i,a++}else r+=i,a++}try{return{pattern:new Function(`return ${r}`)(),defaults:t}}catch{return null}}function Li(e){let t=[],n=Qo(e),r=/(async\s+)?function\s+(\w+)\s*\(([^)]*)\)\s*(:[?!]?)\s*/g,s;for(;(s=r.exec(n))!==null;){let o=!!s[1],u=s[2],c=s[3],l=s[4],p=n.slice(0,s.index).split(`
198
- `).length;if(l===":!")continue;let f=n.slice(s.index+s[0].length),d=wn(f);if(!d)continue;let g=Pr(c);if(!(c.trim()&&g.length===0))try{let y=Fi(d);if(!y)continue;let w=g.map(k=>new Function(`return ${k}`)());t.push({funcName:u,args:w,expected:y.pattern,defaults:Object.keys(y.defaults).length>0?y.defaults:void 0,line:p,isAsync:o})}catch{}}let a=/class\s+(\w+)(?:\s+extends\s+\w+)?\s*\{/g,i;for(;(i=a.exec(n))!==null;){let o=i[1],u=i.index+i[0].length,c=1,l=u;for(let b=u;b<n.length;b++)if(n[b]==="{")c++;else if(n[b]==="}"&&(c--,c===0)){l=b;break}let p=n.slice(u,l),d=/constructor\s*\(([^)]*)\)/.exec(p);if(!d)continue;let g=d[1],y=Pr(g);if(g.trim()&&y.length===0)continue;let w;try{w=y.map(b=>new Function(`return ${b}`)())}catch{continue}let k=/(async\s+)?(\w+)\s*\(([^)]*)\)\s*(:[?!]?)\s*/g,S;for(;(S=k.exec(p))!==null;){let b=S[2];if(b==="constructor")continue;let _=!!S[1],v=S[3];if(S[4]===":!")continue;let E=u+S.index,$=n.slice(0,E).split(`
199
- `).length,C=p.slice(S.index+S[0].length),I=wn(C);if(!I)continue;let M=Pr(v);if(!(v.trim()&&M.length===0))try{let F=Fi(I);if(!F)continue;let N=M.map(U=>new Function(`return ${U}`)());t.push({funcName:b,args:N,expected:F.pattern,defaults:Object.keys(F.defaults).length>0?F.defaults:void 0,line:$,isAsync:_,className:o,constructorArgs:w})}catch{}}}return t}function Vi(e,t,n,r,s={},a=new Map){let i=[];if(e.length===0&&n.length===0)return i;let o=r.match(/^import\s+.*?from\s+['"]([^'"]+)['"];?\s*$/gm)||[],u=o.length>0&&o.some(_=>{let v=_.match(/from\s+['"]([^'"]+)['"]/);return v&&!(v[1]in s)}),c=Di(r),l=Yo(s),p=t.map(_=>_.body).join(`
200
- `),f="const { Is, IsNot, Eq, NotEq, TypeOf } = globalThis.__tjs ?? {};",d=e.map((_,v)=>{let x=a.size>0?jt(_.body,a):_.body;return`
201
- // Test ${v}: ${_.description}
200
+ `.repeat(r)});return t=t.replace(/\/\/[^\n]*/g,""),t}function Qi(e){let t=e.replace(/^import\s+.*?from\s+['"][^'"]+['"];?\s*$/gm,"");return t=t.replace(/^import\s+['"][^'"]+['"];?\s*$/gm,""),t=t.replace(/^export\s+default\s+/gm,""),t=t.replace(/^export\s+/gm,""),t=t.replace(/^(\s*)((?:const|let|var)\s+\w+\s*=\s*)?await\s+.+$/gm,"$1/* top-level await removed for test execution */"),t}function yu(e){if(Object.keys(e).length===0)return"";let t=[];for(let[n,r]of Object.entries(e)){let s=Qi(r);t.push(`// Resolved import: ${n}`),t.push(s)}return t.join(`
201
+ `)}function Zi(e){let t={},n=e.trim();if(!n.startsWith("{")||!n.includes("="))try{return{pattern:new Function(`return ${e}`)(),defaults:t}}catch{return null}let r="",s=0,a=0;for(;a<n.length;){let i=n[a];if(i==="{"||i==="["||i==="(")s++,r+=i,a++;else if(i==="}"||i==="]"||i===")")s--,r+=i,a++;else if(i==="'"||i==='"'||i==="`"){let o=i;for(r+=i,a++;a<n.length&&n[a]!==o;)n[a]==="\\"&&(r+=n[a++]),r+=n[a++];a<n.length&&(r+=n[a++])}else if(s===1&&i==="="){let c=(r.slice(r.lastIndexOf("{")+1).split(",").pop()||"").match(/\s*(\w+)\s*$/);if(c){let l=a+1;for(;l<n.length&&/\s/.test(n[l]);)l++;let p="",f=0;for(;l<n.length;){let d=n[l];if(d==="{"||d==="["||d==="(")f++;else if(d==="}"||d==="]"||d===")"){if(f===0)break;f--}else if(d===","&&f===0)break;p+=d,l++}try{t[c[1]]=new Function(`return ${p.trim()}`)()}catch{}r+=":",a++;continue}r+=i,a++}else r+=i,a++}try{return{pattern:new Function(`return ${r}`)(),defaults:t}}catch{return null}}function Yi(e){let t=[],n=gu(e),r=/(async\s+)?function\s+(\w+)\s*\(([^)]*)\)\s*(:[?!]?)\s*/g,s;for(;(s=r.exec(n))!==null;){let o=!!s[1],u=s[2],c=s[3],l=s[4],p=n.slice(0,s.index).split(`
202
+ `).length;if(l===":!")continue;let f=n.slice(s.index+s[0].length),d=$n(f);if(!d)continue;let m=Fr(c);if(!(c.trim()&&m.length===0))try{let y=Zi(d);if(!y)continue;let x=m.map(S=>new Function(`return ${S}`)());t.push({funcName:u,args:x,expected:y.pattern,defaults:Object.keys(y.defaults).length>0?y.defaults:void 0,line:p,isAsync:o})}catch{}}let a=/class\s+(\w+)(?:\s+extends\s+\w+)?\s*\{/g,i;for(;(i=a.exec(n))!==null;){let o=i[1],u=i.index+i[0].length,c=1,l=u;for(let _=u;_<n.length;_++)if(n[_]==="{")c++;else if(n[_]==="}"&&(c--,c===0)){l=_;break}let p=n.slice(u,l),d=/constructor\s*\(([^)]*)\)/.exec(p);if(!d)continue;let m=d[1],y=Fr(m);if(m.trim()&&y.length===0)continue;let x;try{x=y.map(_=>new Function(`return ${_}`)())}catch{continue}let S=/(async\s+)?(\w+)\s*\(([^)]*)\)\s*(:[?!]?)\s*/g,E;for(;(E=S.exec(p))!==null;){let _=E[2];if(_==="constructor")continue;let b=!!E[1],v=E[3];if(E[4]===":!")continue;let k=u+E.index,T=n.slice(0,k).split(`
203
+ `).length,C=p.slice(E.index+E[0].length),N=$n(C);if(!N)continue;let P=Fr(v);if(!(v.trim()&&P.length===0))try{let D=Zi(N);if(!D)continue;let R=P.map(U=>new Function(`return ${U}`)());t.push({funcName:_,args:R,expected:D.pattern,defaults:Object.keys(D.defaults).length>0?D.defaults:void 0,line:T,isAsync:b,className:o,constructorArgs:x})}catch{}}}return t}function Xi(e,t,n,r,s={},a=new Map){let i=[];if(e.length===0&&n.length===0)return i;let o=r.match(/^import\s+.*?from\s+['"]([^'"]+)['"];?\s*$/gm)||[],u=o.length>0&&o.some(b=>{let v=b.match(/from\s+['"]([^'"]+)['"]/);return v&&!(v[1]in s)}),c=Qi(r),l=yu(s),p=t.map(b=>b.body).join(`
204
+ `),f="const { Is, IsNot, Eq, NotEq, TypeOf } = globalThis.__tjs ?? {};",d=e.map((b,v)=>{let w=a.size>0?Ot(b.body,a):b.body;return`
205
+ // Test ${v}: ${b.description}
202
206
  try {
203
207
  ${f}
204
- ${x}
208
+ ${w}
205
209
  __testResults.push({ idx: ${v}, passed: true });
206
210
  } catch (e) {
207
211
  __testResults.push({ idx: ${v}, passed: false, isRef: e instanceof ReferenceError, error: e.message || String(e) });
208
212
  }
209
213
  `}).join(`
210
- `),g=n.filter(_=>!_.isAsync),y=n.filter(_=>_.isAsync),w=g.map((_,v)=>{let x=_.className?`${_.className}.${_.funcName}`:_.funcName,E=_.className?`new ${_.className}(${(_.constructorArgs||[]).map($=>JSON.stringify($)).join(", ")}).${_.funcName}(${_.args.map($=>JSON.stringify($)).join(", ")})`:`${_.funcName}(${_.args.map($=>JSON.stringify($)).join(", ")})`;return`
211
- // Signature test ${v}: ${x}
214
+ `),m=n.filter(b=>!b.isAsync),y=n.filter(b=>b.isAsync),x=m.map((b,v)=>{let w=b.className?`${b.className}.${b.funcName}`:b.funcName,k=b.className?`new ${b.className}(${(b.constructorArgs||[]).map(T=>JSON.stringify(T)).join(", ")}).${b.funcName}(${b.args.map(T=>JSON.stringify(T)).join(", ")})`:`${b.funcName}(${b.args.map(T=>JSON.stringify(T)).join(", ")})`;return`
215
+ // Signature test ${v}: ${w}
212
216
  try {
213
- let __actual = ${E};
214
- const __expected = ${JSON.stringify(_.expected)};${_.defaults?`
215
- const __defaults = ${JSON.stringify(_.defaults)};
217
+ let __actual = ${k};
218
+ const __expected = ${JSON.stringify(b.expected)};${b.defaults?`
219
+ const __defaults = ${JSON.stringify(b.defaults)};
216
220
  if (typeof __actual === 'object' && __actual !== null) __actual = Object.assign({}, __defaults, __actual);`:""}
217
221
  if (__deepEqual(__actual, __expected)) {
218
222
  __sigTestResults.push({ idx: ${v}, passed: true });
219
223
  } else {
220
- __sigTestResults.push({ idx: ${v}, passed: false, error: 'Expected ' + __format(__expected) + ' at \\'${x}\\', got ' + __format(__actual) });
224
+ __sigTestResults.push({ idx: ${v}, passed: false, error: 'Expected ' + __format(__expected) + ' at \\'${w}\\', got ' + __format(__actual) });
221
225
  }
222
226
  } catch (e) {
223
227
  // The function threw on its example inputs \u2014 the example couldn't be
@@ -226,7 +230,7 @@ ${a}}`}return String(e)}function Qo(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,n=>{l
226
230
  __sigTestResults.push({ idx: ${v}, passed: false, threw: true, error: e.message || String(e) });
227
231
  }
228
232
  `}).join(`
229
- `);Ar();let b=`
233
+ `);Dr();let _=`
230
234
 
231
235
  const __saved_tjs = globalThis.__tjs;
232
236
 
@@ -304,14 +308,14 @@ ${a}}`}return String(e)}function Qo(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,n=>{l
304
308
  ${d}
305
309
 
306
310
  // Run signature tests
307
- ${w}
311
+ ${x}
308
312
 
309
313
  } finally {
310
314
  globalThis.__tjs = __saved_tjs;
311
315
  }
312
316
  return { testResults: __testResults, sigTestResults: __sigTestResults };
313
- `;try{let _=new Function("__deepEqual","__format","__typeMatches",b),{testResults:v,sigTestResults:x}=_(jr,Dt,Ir);for(let E of v){let $=e[E.idx],C=!E.passed&&(E.isRef||u&&E.error&&/is not defined$/.test(E.error));i.push({description:$.description,passed:E.passed,inconclusive:C||void 0,error:E.error,line:$.line})}for(let E of x){let $=g[E.idx],C=!E.passed&&(E.threw||u&&E.error&&/is not defined$/.test(E.error)),I=$.className?`${$.className}.${$.funcName}`:$.funcName;i.push({description:`${I} signature example`,passed:E.passed,inconclusive:C||void 0,error:E.error,isSignatureTest:!0,line:$.line})}}catch(_){let v=`Module could not be executed for testing: ${_.message}`;for(let x of e)i.push({description:x.description,passed:!1,inconclusive:!0,error:v});for(let x of g){let E=x.className?`${x.className}.${x.funcName}`:x.funcName;i.push({description:`${E} signature example`,passed:!1,inconclusive:!0,error:v,isSignatureTest:!0})}}for(let _ of y){let v=_.className?`${_.className}.${_.funcName}`:_.funcName;i.push({description:`${v} signature example`,passed:!0,isSignatureTest:!0,line:_.line})}return i}function wn(e){let t="",n=0,r=!1;for(let a=0;a<e.length;a++){let i=e[a];if(i==="{"||i==="["||i==="("){if(i==="{"&&n===0&&r)break;n++,t+=i,r=!0}else i==="}"||i==="]"||i===")"?(n--,t+=i):/\s/.test(i)?t+=i:(t+=i,r=!0)}return t.trim()||null}function Pr(e){if(!e.trim())return[];let t=[],n=Xo(e);for(let r of n){let s=r.trim(),a=s.match(/^\.\.\.(\w+)\s*[:=]\s*(\[.+\])$/);if(a){try{let o=new Function(`return ${a[2]}`)();if(Array.isArray(o))for(let u of o)t.push(JSON.stringify(u))}catch{}continue}if(s.startsWith("..."))continue;let i=s.match(/(?:\(\s*[?!]\s*)?(\w+)\s*[:=]\s*(.+?)(?:\))?$/);if(i)t.push(i[2].trim());else return[]}return t}function Xo(e){let t=[],n="",r=0;for(let s of e){if(s==="("||s==="["||s==="{")r++;else if(s===")"||s==="]"||s==="}")r--;else if(s===","&&r===0){t.push(n.trim()),n="";continue}n+=s}return n.trim()&&t.push(n.trim()),t}var Te={i32:127,i64:126,f32:125,f64:124,v128:123,funcref:112,externref:111,void:64},Lt={custom:0,type:1,import:2,function:3,table:4,memory:5,global:6,export:7,start:8,element:9,code:10,data:11},m={unreachable:0,nop:1,block:2,loop:3,if:4,else:5,end:11,br:12,br_if:13,br_table:14,return:15,call:16,call_indirect:17,drop:26,select:27,local_get:32,local_set:33,local_tee:34,global_get:35,global_set:36,i32_load:40,i64_load:41,f32_load:42,f64_load:43,i32_load8_s:44,i32_load8_u:45,i32_load16_s:46,i32_load16_u:47,i32_store:54,i64_store:55,f32_store:56,f64_store:57,i32_store8:58,i32_store16:59,memory_size:63,memory_grow:64,i32_const:65,i64_const:66,f32_const:67,f64_const:68,i32_eqz:69,i32_eq:70,i32_ne:71,i32_lt_s:72,i32_lt_u:73,i32_gt_s:74,i32_gt_u:75,i32_le_s:76,i32_le_u:77,i32_ge_s:78,i32_ge_u:79,i64_eqz:80,i64_eq:81,i64_ne:82,i64_lt_s:83,i64_lt_u:84,i64_gt_s:85,i64_gt_u:86,i64_le_s:87,i64_le_u:88,i64_ge_s:89,i64_ge_u:90,f32_eq:91,f32_ne:92,f32_lt:93,f32_gt:94,f32_le:95,f32_ge:96,f64_eq:97,f64_ne:98,f64_lt:99,f64_gt:100,f64_le:101,f64_ge:102,i32_clz:103,i32_ctz:104,i32_popcnt:105,i32_add:106,i32_sub:107,i32_mul:108,i32_div_s:109,i32_div_u:110,i32_rem_s:111,i32_rem_u:112,i32_and:113,i32_or:114,i32_xor:115,i32_shl:116,i32_shr_s:117,i32_shr_u:118,i32_rotl:119,i32_rotr:120,i64_add:124,i64_sub:125,i64_mul:126,i64_div_s:127,f32_abs:139,f32_neg:140,f32_ceil:141,f32_floor:142,f32_trunc:143,f32_nearest:144,f32_sqrt:145,f32_add:146,f32_sub:147,f32_mul:148,f32_div:149,f32_min:150,f32_max:151,f32_copysign:152,f64_abs:153,f64_neg:154,f64_ceil:155,f64_floor:156,f64_trunc:157,f64_nearest:158,f64_sqrt:159,f64_add:160,f64_sub:161,f64_mul:162,f64_div:163,f64_min:164,f64_max:165,f64_copysign:166,i32_wrap_i64:167,i32_trunc_f32_s:168,i32_trunc_f32_u:169,i32_trunc_f64_s:170,i32_trunc_f64_u:171,i64_extend_i32_s:172,i64_extend_i32_u:173,f32_convert_i32_s:178,f32_convert_i32_u:179,f32_convert_i64_s:180,f32_demote_f64:182,f64_convert_i32_s:183,f64_convert_i32_u:184,f64_convert_i64_s:185,f64_promote_f32:187,i32_reinterpret_f32:188,f32_reinterpret_i32:190,f64_reinterpret_i64:191,i32_extend8_s:192,i32_extend16_s:193},eu=Object.fromEntries(Object.entries(m).map(([e,t])=>[t,e.replace(/_/g,".")])),qt=253,ae={v128_load:0,v128_store:11,v128_const:12,f32x4_splat:19,f32x4_extract_lane:31,f32x4_replace_lane:32,f32x4_neg:225,f32x4_sqrt:227,f32x4_add:228,f32x4_sub:229,f32x4_mul:230,f32x4_div:231},tu=Object.fromEntries(Object.entries(ae).map(([e,t])=>[t,e.replace(/_/g,".")]));function Nr(e){return[qt,...B(e)]}function qi(e,t,n){return[qt,...B(e),...B(t),...B(n)]}function B(e){let t=[];do{let n=e&127;e>>>=7,e!==0&&(n|=128),t.push(n)}while(e!==0);return t}function Ut(e){let t=[],n=!0;for(;n;){let r=e&127;e>>=7,e===0&&(r&64)===0||e===-1&&(r&64)!==0?n=!1:r|=128,t.push(r)}return t}function Rr(e){let t=new ArrayBuffer(4);return new Float32Array(t)[0]=e,[...new Uint8Array(t)]}function ge(e){let t=new ArrayBuffer(8);return new Float64Array(t)[0]=e,[...new Uint8Array(t)]}function Mr(e){let t=new TextEncoder().encode(e);return[...B(t.length),...t]}function Vt(e,t){return[e,...B(t.length),...t]}function Ke(e,t){let n=0,r=0,s=t;for(;s<e.length;){let a=e[s];if(n|=(a&127)<<r,s++,(a&128)===0)break;r+=7}return[n,s-t]}function nu(e,t){let n=new ArrayBuffer(8),r=new Uint8Array(n);for(let s=0;s<8;s++)r[s]=e[t+s];return new Float64Array(n)[0]}function ru(e,t,n){let r=[],s=1,a=()=>" ".repeat(s),i=t.map((c,l)=>`(param $${c.name} ${c.type})`).join(" "),o=n.map((c,l)=>`(local $L${t.length+l} ${c})`).join(" ");r.push(`(func (export "compute") ${i} (result f64)`),o&&r.push(` ${o}`);let u=0;for(;u<e.length;){let c=e[u],l=eu[c]||`unknown(0x${c.toString(16)})`;if(u++,c===m.local_get||c===m.local_set||c===m.local_tee){let[p,f]=Ke(e,u);u+=f;let d=p<t.length?`$${t[p].name}`:`$L${p}`;r.push(`${a()}${l} ${d}`)}else if(c===m.br||c===m.br_if){let[p,f]=Ke(e,u);u+=f,r.push(`${a()}${l} ${p}`)}else if(c===m.i32_const){let[p,f]=Ke(e,u);u+=f,r.push(`${a()}i32.const ${p}`)}else if(c===m.f32_const){let p=new ArrayBuffer(4),f=new Uint8Array(p);for(let g=0;g<4;g++)f[g]=e[u+g];let d=new Float32Array(p)[0];u+=4,r.push(`${a()}f32.const ${d}`)}else if(c===m.f64_const){let p=nu(e,u);u+=8,r.push(`${a()}f64.const ${p}`)}else if(c===m.block||c===m.loop){let p=e[u];u++,r.push(`${a()}${l}${p===Te.void?"":` (result ${p===Te.f64?"f64":"i32"})`}`),s++}else if(c===m.if){let p=e[u];u++,r.push(`${a()}if${p===Te.void?"":` (result ${p===Te.f64?"f64":"i32"})`}`),s++}else if(c===m.else)s--,r.push(`${a()}else`),s++;else if(c===m.end)s=Math.max(1,s-1),r.push(`${a()}end`);else if(c===m.f64_load||c===m.f64_store||c===m.f32_load||c===m.f32_store||c===m.i32_load||c===m.i32_store){let[p,f]=Ke(e,u);u+=f;let[d,g]=Ke(e,u);u+=g,r.push(`${a()}${l}${d?` offset=${d}`:""}`)}else if(c===qt){let[p,f]=Ke(e,u);u+=f;let d=tu[p]||`simd.unknown(0x${p.toString(16)})`;if(p===ae.v128_load||p===ae.v128_store){let[g,y]=Ke(e,u);u+=y;let[w,k]=Ke(e,u);u+=k,r.push(`${a()}${d}${w?` offset=${w}`:""}`)}else if(p===ae.v128_const){let g=e.slice(u,u+16);u+=16,r.push(`${a()}v128.const ${g.map(y=>"0x"+y.toString(16).padStart(2,"0")).join(" ")}`)}else if(p===ae.f32x4_extract_lane||p===ae.f32x4_replace_lane){let g=e[u];u++,r.push(`${a()}${d} ${g}`)}else r.push(`${a()}${d}`)}else r.push(`${a()}${l}`)}return r.push(")"),r.join(`
314
- `)}var vn={Int8Array:{elementType:"i32",bytesPerElement:1,loadOp:m.i32_load8_s,storeOp:m.i32_store8},Uint8Array:{elementType:"i32",bytesPerElement:1,loadOp:m.i32_load8_u,storeOp:m.i32_store8},Uint8ClampedArray:{elementType:"i32",bytesPerElement:1,loadOp:m.i32_load8_u,storeOp:m.i32_store8},Int16Array:{elementType:"i32",bytesPerElement:2,loadOp:m.i32_load16_s,storeOp:m.i32_store16},Uint16Array:{elementType:"i32",bytesPerElement:2,loadOp:m.i32_load16_u,storeOp:m.i32_store16},Int32Array:{elementType:"i32",bytesPerElement:4,loadOp:m.i32_load,storeOp:m.i32_store},Uint32Array:{elementType:"i32",bytesPerElement:4,loadOp:m.i32_load,storeOp:m.i32_store},Float32Array:{elementType:"f32",bytesPerElement:4,loadOp:m.f32_load,storeOp:m.f32_store},Float64Array:{elementType:"f64",bytesPerElement:8,loadOp:m.f64_load,storeOp:m.f64_store}};function su(e,t=new Map){let n={params:e,locals:new Map,nextLocalIndex:e.length,localTypes:[],warnings:[],errors:[],loopDepth:0,needsMathImports:new Set,needsMemory:!1,hasReturn:!1,wat:[],watIndent:1,moduleFunctions:t};return e.forEach((r,s)=>{n.locals.set(r.name,{index:s,type:r.type})}),n}function Sn(e,t,n){if(e.locals.has(t))return e.errors.push(`Duplicate local declaration: ${t}`),e.locals.get(t).index;let r=e.nextLocalIndex++;return e.locals.set(t,{index:r,type:n}),e.localTypes.push(n),r}function it(e,t){return e.locals.get(t)}function xt(e,t){switch(e.type){case"ExpressionStatement":{let n=e.expression;return[...z(n,t),m.drop]}case"ReturnStatement":{let n=e;if(t.hasReturn=!0,!n.argument)return[m.return];let r=z(n.argument,t),s=Y(n.argument,t);return s==="i32"?r.push(m.f64_convert_i32_s):s==="f32"&&r.push(m.f64_promote_f32),r.push(m.return),r}case"VariableDeclaration":{let n=e,r=[];for(let s of n.declarations){if(s.id.type!=="Identifier"){t.errors.push("Destructuring not supported in WASM blocks");continue}let a=s.id.name,i="f64";s.init&&(i=Y(s.init,t));let o=Sn(t,a,i);s.init&&(r.push(...z(s.init,t)),r.push(m.local_set,...B(o)))}return r}case"ForStatement":return iu(e,t);case"IfStatement":return au(e,t);case"BlockStatement":{let n=e,r=[];for(let s of n.body)r.push(...xt(s,t));return r}default:return t.errors.push(`Unsupported statement type: ${e.type}`),[]}}function iu(e,t){let n=[];return e.init&&(e.init.type==="VariableDeclaration"?n.push(...xt(e.init,t)):n.push(...z(e.init,t))),n.push(m.block,Te.void),n.push(m.loop,Te.void),e.test&&(n.push(...z(e.test,t)),n.push(m.i32_eqz),n.push(m.br_if,1)),t.loopDepth++,e.body&&n.push(...xt(e.body,t)),t.loopDepth--,e.update&&(n.push(...z(e.update,t)),n.push(m.drop)),n.push(m.br,0),n.push(m.end),n.push(m.end),n}function au(e,t){let n=[];return n.push(...z(e.test,t)),n.push(m.if,Te.void),n.push(...xt(e.consequent,t)),e.alternate&&(n.push(m.else),n.push(...xt(e.alternate,t))),n.push(m.end),n}function Y(e,t){switch(e.type){case"Literal":{let n=e;return typeof n.value=="number"?n.raw&&(n.raw.includes(".")||n.raw.includes("e"))?"f64":Number.isInteger(n.value)&&n.value>=-2147483648&&n.value<=2147483647?"i32":"f64":"f64"}case"Identifier":return it(t,e.name)?.type??"f64";case"BinaryExpression":case"AssignmentExpression":{let n=e;if(["<",">","<=",">=","==","!=","===","!=="].includes(n.operator)||["|","&","^","<<",">>",">>>"].includes(n.operator))return"i32";let r=Y(n.left,t),s=Y(n.right,t);return r==="v128"||s==="v128"?"v128":r==="f64"||s==="f64"?"f64":r==="f32"||s==="f32"?"f32":"i32"}case"UnaryExpression":{let n=e;return n.operator==="!"?"i32":Y(n.argument,t)}case"MemberExpression":{let n=e;if(n.object.type==="Identifier"&&it(t,n.object.name)){let s=t.params.find(a=>a.name===n.object.name);if(s?.arrayType){let a=vn[s.arrayType];if(a)return a.elementType}}return"f64"}case"CallExpression":{let n=e;if(n.callee.type==="MemberExpression"){let r=n.callee;if(r.object.type==="Identifier"&&r.object.name==="Math")return"f64"}if(n.callee.type==="Identifier"){let r=n.callee.name;if(r==="f32x4_extract_lane")return"f32";if(r.startsWith("f32x4_")||r==="v128_load")return"v128";let s=t.moduleFunctions.get(r);if(s)return s.hasReturn?"f64":"i32"}return"f64"}default:return"f64"}}function z(e,t){switch(e.type){case"Literal":{let n=e;if(typeof n.value=="number"){let r=Y(e,t);return r==="i32"?[m.i32_const,...Ut(n.value|0)]:r==="f32"?[m.f32_const,...Rr(n.value)]:[m.f64_const,...ge(n.value)]}return t.errors.push(`Unsupported literal type: ${typeof n.value}`),[m.f64_const,...ge(0)]}case"Identifier":{let n=e.name,r=it(t,n);return r?[m.local_get,...B(r.index)]:(t.errors.push(`Unknown identifier: ${n}`),[m.f64_const,...ge(0)])}case"BinaryExpression":return ou(e,t);case"UnaryExpression":return uu(e,t);case"AssignmentExpression":return cu(e,t);case"UpdateExpression":return lu(e,t);case"MemberExpression":return fu(e,t);case"CallExpression":return hu(e,t);case"SequenceExpression":{let n=e,r=[];for(let s=0;s<n.expressions.length;s++)r.push(...z(n.expressions[s],t)),s<n.expressions.length-1&&r.push(m.drop);return r}default:return t.errors.push(`Unsupported expression type: ${e.type}`),[m.f64_const,...ge(0)]}}function ou(e,t){let n=z(e.left,t),r=z(e.right,t),s=Y(e,t),a=Y(e.left,t),i=Y(e.right,t),o=["<",">","<=",">=","==","===","!=","!=="].includes(e.operator),u;a==="f64"||i==="f64"?u="f64":a==="f32"||i==="f32"?u="f32":u="i32",!o&&s==="f64"&&(u="f64");let c=n,l=r;u==="f64"?(a==="i32"?c=[...n,m.f64_convert_i32_s]:a==="f32"&&(c=[...n,m.f64_promote_f32]),i==="i32"?l=[...r,m.f64_convert_i32_s]:i==="f32"&&(l=[...r,m.f64_promote_f32])):u==="f32"&&(a==="i32"&&(c=[...n,m.f32_convert_i32_s]),i==="i32"&&(l=[...r,m.f32_convert_i32_s]));let f={"+":{i32:m.i32_add,f32:m.f32_add,f64:m.f64_add},"-":{i32:m.i32_sub,f32:m.f32_sub,f64:m.f64_sub},"*":{i32:m.i32_mul,f32:m.f32_mul,f64:m.f64_mul},"/":{i32:m.i32_div_s,f32:m.f32_div,f64:m.f64_div},"%":{i32:m.i32_rem_s},"<":{i32:m.i32_lt_s,f32:m.f32_lt,f64:m.f64_lt},">":{i32:m.i32_gt_s,f32:m.f32_gt,f64:m.f64_gt},"<=":{i32:m.i32_le_s,f32:m.f32_le,f64:m.f64_le},">=":{i32:m.i32_ge_s,f32:m.f32_ge,f64:m.f64_ge},"==":{i32:m.i32_eq,f32:m.f32_eq,f64:m.f64_eq},"===":{i32:m.i32_eq,f32:m.f32_eq,f64:m.f64_eq},"!=":{i32:m.i32_ne,f32:m.f32_ne,f64:m.f64_ne},"!==":{i32:m.i32_ne,f32:m.f32_ne,f64:m.f64_ne},"|":{i32:m.i32_or},"&":{i32:m.i32_and},"^":{i32:m.i32_xor},"<<":{i32:m.i32_shl},">>":{i32:m.i32_shr_s},">>>":{i32:m.i32_shr_u}}[e.operator];if(!f)return t.errors.push(`Unsupported operator: ${e.operator}`),[m.f64_const,...ge(0)];let d=f[u]??f.f64??f.i32;return d===void 0?(t.errors.push(`Operator ${e.operator} not supported for type ${u}`),[m.f64_const,...ge(0)]):[...c,...l,d]}function uu(e,t){let n=z(e.argument,t),r=Y(e.argument,t);switch(e.operator){case"-":return r==="i32"?[m.i32_const,0,...n,m.i32_sub]:r==="f32"?[...n,m.f32_neg]:[...n,m.f64_neg];case"!":return[...n,m.i32_eqz];case"~":return[...n,m.i32_const,...Ut(-1),m.i32_xor];default:return t.errors.push(`Unsupported unary operator: ${e.operator}`),n}}function cu(e,t){if(e.left.type==="MemberExpression")return pu(e.left,e.right,e.operator,t);if(e.left.type!=="Identifier")return t.errors.push("Assignment target must be identifier or array element"),[];let n=e.left.name,r=it(t,n);if(!r)return t.errors.push(`Unknown variable: ${n}`),[];let s=[];if(e.operator==="="){s.push(...z(e.right,t));let a=Y(e.right,t);r.type==="f64"&&a==="i32"?s.push(m.f64_convert_i32_s):r.type==="f64"&&a==="f32"?s.push(m.f64_promote_f32):r.type==="i32"&&a==="f64"?s.push(m.i32_trunc_f64_s):r.type==="i32"&&a==="f32"?s.push(m.i32_trunc_f32_s):r.type==="f32"&&a==="i32"?s.push(m.f32_convert_i32_s):r.type==="f32"&&a==="f64"&&s.push(m.f32_demote_f64)}else{let a=Y(e.right,t),i=r.type;a==="f64"||r.type==="f64"?i="f64":(a==="f32"||r.type==="f32")&&(i="f32"),s.push(m.local_get,...B(r.index)),i==="f64"&&r.type==="i32"?s.push(m.f64_convert_i32_s):i==="f64"&&r.type==="f32"?s.push(m.f64_promote_f32):i==="f32"&&r.type==="i32"&&s.push(m.f32_convert_i32_s),s.push(...z(e.right,t)),i==="f64"&&a==="i32"?s.push(m.f64_convert_i32_s):i==="f64"&&a==="f32"?s.push(m.f64_promote_f32):i==="f32"&&a==="i32"&&s.push(m.f32_convert_i32_s);let o=e.operator.slice(0,-1),c={"+":{i32:m.i32_add,f32:m.f32_add,f64:m.f64_add},"-":{i32:m.i32_sub,f32:m.f32_sub,f64:m.f64_sub},"*":{i32:m.i32_mul,f32:m.f32_mul,f64:m.f64_mul},"/":{i32:m.i32_div_s,f32:m.f32_div,f64:m.f64_div}}[o]?.[i];if(!c)return t.errors.push(`Unsupported compound assignment: ${e.operator}`),[];s.push(c),r.type==="i32"&&i==="f64"?s.push(m.i32_trunc_f64_s):r.type==="i32"&&i==="f32"?s.push(m.i32_trunc_f32_s):r.type==="f32"&&i==="f64"&&s.push(m.f32_demote_f64)}return s.push(m.local_tee,...B(r.index)),s}function lu(e,t){if(e.argument.type!=="Identifier")return t.errors.push("Update expression argument must be identifier"),[];let n=e.argument.name,r=it(t,n);if(!r)return t.errors.push(`Unknown variable: ${n}`),[];let s=[],a=r.type==="i32";return e.prefix?(s.push(m.local_get,...B(r.index)),a?(s.push(m.i32_const,1),s.push(e.operator==="++"?m.i32_add:m.i32_sub)):(s.push(m.f64_const,...ge(1)),s.push(e.operator==="++"?m.f64_add:m.f64_sub)),s.push(m.local_tee,...B(r.index))):(s.push(m.local_get,...B(r.index)),s.push(m.local_get,...B(r.index)),a?(s.push(m.i32_const,1),s.push(e.operator==="++"?m.i32_add:m.i32_sub)):(s.push(m.f64_const,...ge(1)),s.push(e.operator==="++"?m.f64_add:m.f64_sub)),s.push(m.local_set,...B(r.index))),s}function fu(e,t){if(e.object.type!=="Identifier")return t.errors.push("Array access requires identifier"),[];let n=e.object.name,r=t.params.find(c=>c.name===n);if(!r?.isArray||!r.arrayType)return t.errors.push(`${n} is not a typed array parameter`),[];let s=vn[r.arrayType];if(!s)return t.errors.push(`Unknown array type: ${r.arrayType}`),[];t.needsMemory=!0;let a=[],i=it(t,n);if(!i)return t.errors.push(`Unknown array: ${n}`),[];if(a.push(m.local_get,...B(i.index)),!e.computed||!e.property)return t.errors.push("Array access requires computed index"),[];let o=z(e.property,t),u=Y(e.property,t);return a.push(...o),u==="f64"&&a.push(m.i32_trunc_f64_s),s.bytesPerElement>1&&(a.push(m.i32_const,...Ut(s.bytesPerElement)),a.push(m.i32_mul)),a.push(m.i32_add),a.push(s.loadOp,0,0),a}function pu(e,t,n,r){if(e.object.type!=="Identifier")return r.errors.push("Array store requires identifier"),[];let s=e.object.name,a=r.params.find(g=>g.name===s);if(!a?.isArray||!a.arrayType)return r.errors.push(`${s} is not a typed array parameter`),[];let i=vn[a.arrayType];if(!i)return r.errors.push(`Unknown array type: ${a.arrayType}`),[];r.needsMemory=!0;let o=[],u=it(r,s);if(!u)return[];if(!e.computed||!e.property)return r.errors.push("Array store requires computed index"),[];let c=z(e.property,r),l=Y(e.property,r),p=()=>{let g=[];return g.push(m.local_get,...B(u.index)),g.push(...c),l==="f64"&&g.push(m.i32_trunc_f64_s),i.bytesPerElement>1&&(g.push(m.i32_const,...Ut(i.bytesPerElement)),g.push(m.i32_mul)),g.push(m.i32_add),g};if(n==="=")o.push(...z(t,r));else{let g=Sn(r,`__addr_${r.nextLocalIndex}`,"i32");o.push(...p()),o.push(m.local_tee,...B(g)),o.push(i.loadOp,0,0),o.push(...z(t,r));let y=Y(t,r);i.elementType==="f32"&&y==="f64"?o.push(m.f32_demote_f64):i.elementType==="f64"&&y==="f32"?o.push(m.f64_promote_f32):i.elementType==="f32"&&y==="i32"?o.push(m.f32_convert_i32_s):i.elementType==="f64"&&y==="i32"?o.push(m.f64_convert_i32_s):i.elementType==="i32"&&y==="f64"?o.push(m.i32_trunc_f64_s):i.elementType==="i32"&&y==="f32"&&o.push(m.i32_trunc_f32_s);let w=n.slice(0,-1),k={"+":i.elementType==="i32"?m.i32_add:i.elementType==="f32"?m.f32_add:m.f64_add,"-":i.elementType==="i32"?m.i32_sub:i.elementType==="f32"?m.f32_sub:m.f64_sub,"*":i.elementType==="i32"?m.i32_mul:i.elementType==="f32"?m.f32_mul:m.f64_mul};o.push(k[w]??m.f64_add);let S=Sn(r,`__val_${r.nextLocalIndex}`,i.elementType);return o.push(m.local_set,...B(S)),o.push(m.local_get,...B(g)),o.push(m.local_get,...B(S)),o.push(i.storeOp,0,0),o.push(m.local_get,...B(S)),o}let f=Y(t,r);i.elementType==="f32"&&f==="f64"?o.push(m.f32_demote_f64):i.elementType==="f64"&&f==="f32"?o.push(m.f64_promote_f32):i.elementType==="i32"&&f==="f64"&&o.push(m.i32_trunc_f64_s);let d=Sn(r,`__tmp_${r.nextLocalIndex}`,i.elementType);return o.push(m.local_set,...B(d)),o.push(m.local_get,...B(u.index)),o.push(...c),l==="f64"&&o.push(m.i32_trunc_f64_s),i.bytesPerElement>1&&(o.push(m.i32_const,...Ut(i.bytesPerElement)),o.push(m.i32_mul)),o.push(m.i32_add),o.push(m.local_get,...B(d)),o.push(i.storeOp,0,0),o.push(m.local_get,...B(d)),o}function hu(e,t){if(e.callee.type==="MemberExpression"){let n=e.callee;if(n.object.type==="Identifier"&&n.object.name==="Math"&&n.property.type==="Identifier"){let r=n.property.name;return yu(r,e.arguments,t)}}if(e.callee.type==="Identifier"){let n=e.callee.name;if(n.startsWith("f32x4_")||n.startsWith("v128_"))return gu(n,e.arguments,t);let r=t.moduleFunctions.get(n);if(r)return du(r,n,e.arguments,t)}return t.errors.push(`Unsupported function call: ${e.callee.type}`),[m.f64_const,...ge(0)]}function du(e,t,n,r){if(n.length!==e.params.length)return r.errors.push(`wasm function ${t} expects ${e.params.length} arguments, got ${n.length}`),[m.f64_const,...ge(0)];let s=[];for(let a=0;a<n.length;a++){let i=n[a],o=e.params[a].type,u=Y(i,r);if(s.push(...z(i,r)),u!==o){let c=mu(u,o);c===void 0?r.errors.push(`wasm function ${t} param ${a} expects ${o}, got ${u} (no conversion available)`):c!==null&&s.push(c)}}return s.push(m.call,...B(e.index)),e.hasReturn||s.push(m.i32_const,0),s}function mu(e,t){if(e===t)return null;if(!(e==="v128"||t==="v128")&&!(e==="i64"||t==="i64"))switch(`${e}->${t}`){case"f64->i32":return m.i32_trunc_f64_s;case"f32->i32":return m.i32_trunc_f32_s;case"i32->f64":return m.f64_convert_i32_s;case"i32->f32":return m.f32_convert_i32_s;case"f32->f64":return m.f64_promote_f32;case"f64->f32":return m.f32_demote_f64;default:return}}function gu(e,t,n){n.needsMemory=!0;let r=[];switch(e){case"v128_load":case"f32x4_load":{r.push(...z(t[0],n)),Y(t[0],n)==="f64"&&r.push(m.i32_trunc_f64_s),r.push(...z(t[1],n));let a=Y(t[1],n);return a==="f64"?r.push(m.i32_trunc_f64_s):a==="f32"&&r.push(m.i32_trunc_f32_s),r.push(m.i32_add),r.push(...qi(ae.v128_load,2,0)),r}case"v128_store":case"f32x4_store":{r.push(...z(t[0],n)),Y(t[0],n)==="f64"&&r.push(m.i32_trunc_f64_s),r.push(...z(t[1],n));let a=Y(t[1],n);return a==="f64"?r.push(m.i32_trunc_f64_s):a==="f32"&&r.push(m.i32_trunc_f32_s),r.push(m.i32_add),r.push(...z(t[2],n)),r.push(...qi(ae.v128_store,2,0)),r.push(m.i32_const,0),r}case"f32x4_splat":{r.push(...z(t[0],n));let s=Y(t[0],n);return s==="i32"?r.push(m.f32_convert_i32_s):s==="f64"&&r.push(m.f32_demote_f64),r.push(...Nr(ae.f32x4_splat)),r}case"f32x4_extract_lane":{r.push(...z(t[0],n));let s=t[1].value;return!Number.isInteger(s)||s<0||s>3?(n.errors.push(`f32x4_extract_lane: lane must be 0-3, got ${s}`),[m.f32_const,...Rr(0)]):(r.push(qt,...B(ae.f32x4_extract_lane),s),r)}case"f32x4_replace_lane":{r.push(...z(t[0],n));let s=t[1].value;if(!Number.isInteger(s)||s<0||s>3)return n.errors.push(`f32x4_replace_lane: lane must be 0-3, got ${s}`),[m.f32_const,...Rr(0)];r.push(...z(t[2],n));let a=Y(t[2],n);return a==="i32"?r.push(m.f32_convert_i32_s):a==="f64"&&r.push(m.f32_demote_f64),r.push(qt,...B(ae.f32x4_replace_lane),s),r}case"f32x4_add":case"f32x4_sub":case"f32x4_mul":case"f32x4_div":{r.push(...z(t[0],n)),r.push(...z(t[1],n));let s={f32x4_add:ae.f32x4_add,f32x4_sub:ae.f32x4_sub,f32x4_mul:ae.f32x4_mul,f32x4_div:ae.f32x4_div};return r.push(...Nr(s[e])),r}case"f32x4_neg":case"f32x4_sqrt":{r.push(...z(t[0],n));let s={f32x4_neg:ae.f32x4_neg,f32x4_sqrt:ae.f32x4_sqrt};return r.push(...Nr(s[e])),r}default:return n.errors.push(`Unknown SIMD intrinsic: ${e}`),[m.f64_const,...ge(0)]}}function yu(e,t,n){let r=[];for(let o of t){r.push(...z(o,n));let u=Y(o,n);u==="i32"?r.push(m.f64_convert_i32_s):u==="f32"&&r.push(m.f64_promote_f32)}let a={abs:m.f64_abs,ceil:m.f64_ceil,floor:m.f64_floor,trunc:m.f64_trunc,sqrt:m.f64_sqrt,min:m.f64_min,max:m.f64_max}[e];return a!==void 0?(r.push(a),r):["sin","cos","tan","asin","acos","atan","atan2","exp","log","pow"].includes(e)?(n.needsMathImports.add(e),n.errors.push(`Math.${e} requires JS import (not yet implemented)`),[m.f64_const,...ge(0)]):(n.errors.push(`Unknown Math method: ${e}`),[m.f64_const,...ge(0)])}function Ui(e){let t=e.split(":").map(a=>a.trim()),n=t[0];if(t.length===1)return{name:n,type:"f64"};let r=t[1];return vn[r]?{name:n,type:"i32",isArray:!0,arrayType:r}:{name:n,type:{i32:"i32",i64:"i64",f32:"f32",f64:"f64",number:"f64",int:"i32"}[r]??"f64"}}function bu(e,t){let n=e.map(s=>Te[s.type]),r=t?[1,Te.f64]:[0];return[96,...B(e.length),...n,...r]}function xu(e,t){let n=[];if(t.length>0){let a=t[0],i=1;for(let o=1;o<t.length;o++)t[o]===a?i++:(n.push([...B(i),Te[a]]),a=t[o],i=1);n.push([...B(i),Te[a]])}let s=[...[...B(n.length),...n.flat()],...e,m.end];return[...B(s.length),...s]}function _u(){return Vt(Lt.import,[1,...Mr("env"),...Mr("memory"),2,0,1])}function wu(e,t){if(e.length!==t.length)throw new Error("functions and exportNames length mismatch");let n=[0,97,115,109,1,0,0,0],r=e.map(f=>bu(f.params,f.hasReturn)),s=Vt(Lt.type,[...B(r.length),...r.flat()]),i=e.some(f=>f.needsMemory)?_u():[],o=Vt(Lt.function,[...B(e.length),...e.map((f,d)=>B(d)).flat()]),u=Vt(Lt.export,[...B(e.length),...t.map((f,d)=>[...Mr(f),0,...B(d)]).flat()]),c=e.map(f=>xu(f.bodyCode,f.localTypes)),l=Vt(Lt.code,[...B(c.length),...c.flat()]),p=[...n,...s];return i.length>0&&p.push(...i),p.push(...o,...u,...l),p}function Su(e,t=new Map){try{let n=e.captures.map(Ui),r;try{let u=`function __wasm__(${n.map(c=>c.name).join(", ")}) { ${e.body} }`;r=je(u,{ecmaVersion:2022})}catch(u){return{success:!1,warnings:[],error:`Parse error: ${u.message}`}}let a=r.body[0].body.body,i=su(n,t),o=[];for(let u of a)o.push(...xt(u,i));return i.errors.length>0?{success:!1,warnings:i.warnings,error:i.errors.join("; ")}:{success:!0,fn:{params:n,bodyCode:o,localTypes:i.localTypes,needsMemory:i.needsMemory,hasReturn:i.hasReturn},wat:ru(o,n,i.localTypes),warnings:i.warnings}}catch(n){return{success:!1,warnings:[],error:n.message}}}function Wi(e){let t=new Map,n=[];for(let u=0;u<e.length;u++){let c=e[u],l=c.captures.map(Ui),p=c.returnType!==void 0;n.push({params:l,hasReturn:p}),c.name&&t.set(c.name,{index:u,params:l,hasReturn:p})}let r=[],s=[],a=[],i=[];for(let u=0;u<e.length;u++){let c=e[u],l=Su(c,t);if(i.push(...l.warnings),!l.success||!l.fn){r.push({id:c.id,success:!1,error:l.error}),s.push(vu(n[u])),a.push({id:c.id,exportName:`compute_${u}`,captures:c.captures,needsMemory:!1,wat:`(failed: ${l.error??"unknown error"})`});continue}s.push(l.fn),a.push({id:c.id,exportName:`compute_${u}`,captures:c.captures,needsMemory:l.fn.needsMemory,wat:l.wat??""}),r.push({id:c.id,success:!0,exportIndex:u})}if(s.length===0)return{bytes:new Uint8Array,results:r,exports:[],needsMemory:!1,warnings:i};let o=wu(s,a.map(u=>u.exportName));return{bytes:new Uint8Array(o),results:r,exports:a,needsMemory:a.some(u=>u.needsMemory),warnings:i}}function vu(e){let t=e.hasReturn?[m.f64_const,...ge(0)]:[];return{params:e.params,bodyCode:t,localTypes:[],needsMemory:!1,hasReturn:e.hasReturn}}function Ji(e){let t=Wi(e),n=new Map(t.exports.map(l=>[l.id,l])),r=t.results.map(l=>{if(!l.success)return{id:l.id,success:!1,error:l.error};let p=n.get(l.id);return{id:l.id,success:!0,byteLength:t.bytes.length,_exportName:p.exportName}});if(t.exports.length===0)return{code:"",results:r};let s=t.exports.map(l=>{let p=l.wat.split(`
317
+ `;try{let b=new Function("__deepEqual","__format","__typeMatches",_),{testResults:v,sigTestResults:w}=b(Lr,Wt,Vr);for(let k of v){let T=e[k.idx],C=!k.passed&&(k.isRef||u&&k.error&&/is not defined$/.test(k.error));i.push({description:T.description,passed:k.passed,inconclusive:C||void 0,error:k.error,line:T.line})}for(let k of w){let T=m[k.idx],C=!k.passed&&(k.threw||u&&k.error&&/is not defined$/.test(k.error)),N=T.className?`${T.className}.${T.funcName}`:T.funcName;i.push({description:`${N} signature example`,passed:k.passed,inconclusive:C||void 0,error:k.error,isSignatureTest:!0,line:T.line})}}catch(b){let v=`Module could not be executed for testing: ${b.message}`;for(let w of e)i.push({description:w.description,passed:!1,inconclusive:!0,error:v});for(let w of m){let k=w.className?`${w.className}.${w.funcName}`:w.funcName;i.push({description:`${k} signature example`,passed:!1,inconclusive:!0,error:v,isSignatureTest:!0})}}for(let b of y){let v=b.className?`${b.className}.${b.funcName}`:b.funcName;i.push({description:`${v} signature example`,passed:!0,isSignatureTest:!0,line:b.line})}return i}function $n(e){let t="",n=0,r=!1;for(let a=0;a<e.length;a++){let i=e[a];if(i==="{"||i==="["||i==="("){if(i==="{"&&n===0&&r)break;n++,t+=i,r=!0}else i==="}"||i==="]"||i===")"?(n--,t+=i):/\s/.test(i)?t+=i:(t+=i,r=!0)}return t.trim()||null}function Fr(e){if(!e.trim())return[];let t=[],n=bu(e);for(let r of n){let s=r.trim(),a=s.match(/^\.\.\.(\w+)\s*[:=]\s*(\[.+\])$/);if(a){try{let o=new Function(`return ${a[2]}`)();if(Array.isArray(o))for(let u of o)t.push(JSON.stringify(u))}catch{}continue}if(s.startsWith("..."))continue;let i=s.match(/(?:\(\s*[?!]\s*)?(\w+)\s*[:=]\s*(.+?)(?:\))?$/);if(i)t.push(i[2].trim());else return[]}return t}function bu(e){let t=[],n="",r=0;for(let s of e){if(s==="("||s==="["||s==="{")r++;else if(s===")"||s==="]"||s==="}")r--;else if(s===","&&r===0){t.push(n.trim()),n="";continue}n+=s}return n.trim()&&t.push(n.trim()),t}var $e={i32:127,i64:126,f32:125,f64:124,v128:123,funcref:112,externref:111,void:64},Jt={custom:0,type:1,import:2,function:3,table:4,memory:5,global:6,export:7,start:8,element:9,code:10,data:11},g={unreachable:0,nop:1,block:2,loop:3,if:4,else:5,end:11,br:12,br_if:13,br_table:14,return:15,call:16,call_indirect:17,drop:26,select:27,local_get:32,local_set:33,local_tee:34,global_get:35,global_set:36,i32_load:40,i64_load:41,f32_load:42,f64_load:43,i32_load8_s:44,i32_load8_u:45,i32_load16_s:46,i32_load16_u:47,i32_store:54,i64_store:55,f32_store:56,f64_store:57,i32_store8:58,i32_store16:59,memory_size:63,memory_grow:64,i32_const:65,i64_const:66,f32_const:67,f64_const:68,i32_eqz:69,i32_eq:70,i32_ne:71,i32_lt_s:72,i32_lt_u:73,i32_gt_s:74,i32_gt_u:75,i32_le_s:76,i32_le_u:77,i32_ge_s:78,i32_ge_u:79,i64_eqz:80,i64_eq:81,i64_ne:82,i64_lt_s:83,i64_lt_u:84,i64_gt_s:85,i64_gt_u:86,i64_le_s:87,i64_le_u:88,i64_ge_s:89,i64_ge_u:90,f32_eq:91,f32_ne:92,f32_lt:93,f32_gt:94,f32_le:95,f32_ge:96,f64_eq:97,f64_ne:98,f64_lt:99,f64_gt:100,f64_le:101,f64_ge:102,i32_clz:103,i32_ctz:104,i32_popcnt:105,i32_add:106,i32_sub:107,i32_mul:108,i32_div_s:109,i32_div_u:110,i32_rem_s:111,i32_rem_u:112,i32_and:113,i32_or:114,i32_xor:115,i32_shl:116,i32_shr_s:117,i32_shr_u:118,i32_rotl:119,i32_rotr:120,i64_add:124,i64_sub:125,i64_mul:126,i64_div_s:127,f32_abs:139,f32_neg:140,f32_ceil:141,f32_floor:142,f32_trunc:143,f32_nearest:144,f32_sqrt:145,f32_add:146,f32_sub:147,f32_mul:148,f32_div:149,f32_min:150,f32_max:151,f32_copysign:152,f64_abs:153,f64_neg:154,f64_ceil:155,f64_floor:156,f64_trunc:157,f64_nearest:158,f64_sqrt:159,f64_add:160,f64_sub:161,f64_mul:162,f64_div:163,f64_min:164,f64_max:165,f64_copysign:166,i32_wrap_i64:167,i32_trunc_f32_s:168,i32_trunc_f32_u:169,i32_trunc_f64_s:170,i32_trunc_f64_u:171,i64_extend_i32_s:172,i64_extend_i32_u:173,f32_convert_i32_s:178,f32_convert_i32_u:179,f32_convert_i64_s:180,f32_demote_f64:182,f64_convert_i32_s:183,f64_convert_i32_u:184,f64_convert_i64_s:185,f64_promote_f32:187,i32_reinterpret_f32:188,f32_reinterpret_i32:190,f64_reinterpret_i64:191,i32_extend8_s:192,i32_extend16_s:193},xu=Object.fromEntries(Object.entries(g).map(([e,t])=>[t,e.replace(/_/g,".")])),Gt=253,ae={v128_load:0,v128_store:11,v128_const:12,f32x4_splat:19,f32x4_extract_lane:31,f32x4_replace_lane:32,f32x4_neg:225,f32x4_sqrt:227,f32x4_add:228,f32x4_sub:229,f32x4_mul:230,f32x4_div:231},_u=Object.fromEntries(Object.entries(ae).map(([e,t])=>[t,e.replace(/_/g,".")]));function qr(e){return[Gt,...B(e)]}function ea(e,t,n){return[Gt,...B(e),...B(t),...B(n)]}function B(e){let t=[];do{let n=e&127;e>>>=7,e!==0&&(n|=128),t.push(n)}while(e!==0);return t}function Ht(e){let t=[],n=!0;for(;n;){let r=e&127;e>>=7,e===0&&(r&64)===0||e===-1&&(r&64)!==0?n=!1:r|=128,t.push(r)}return t}function Ur(e){let t=new ArrayBuffer(4);return new Float32Array(t)[0]=e,[...new Uint8Array(t)]}function ge(e){let t=new ArrayBuffer(8);return new Float64Array(t)[0]=e,[...new Uint8Array(t)]}function Wr(e){let t=new TextEncoder().encode(e);return[...B(t.length),...t]}function zt(e,t){return[e,...B(t.length),...t]}function Ke(e,t){let n=0,r=0,s=t;for(;s<e.length;){let a=e[s];if(n|=(a&127)<<r,s++,(a&128)===0)break;r+=7}return[n,s-t]}function wu(e,t){let n=new ArrayBuffer(8),r=new Uint8Array(n);for(let s=0;s<8;s++)r[s]=e[t+s];return new Float64Array(n)[0]}function Su(e,t,n){let r=[],s=1,a=()=>" ".repeat(s),i=t.map((c,l)=>`(param $${c.name} ${c.type})`).join(" "),o=n.map((c,l)=>`(local $L${t.length+l} ${c})`).join(" ");r.push(`(func (export "compute") ${i} (result f64)`),o&&r.push(` ${o}`);let u=0;for(;u<e.length;){let c=e[u],l=xu[c]||`unknown(0x${c.toString(16)})`;if(u++,c===g.local_get||c===g.local_set||c===g.local_tee){let[p,f]=Ke(e,u);u+=f;let d=p<t.length?`$${t[p].name}`:`$L${p}`;r.push(`${a()}${l} ${d}`)}else if(c===g.br||c===g.br_if){let[p,f]=Ke(e,u);u+=f,r.push(`${a()}${l} ${p}`)}else if(c===g.i32_const){let[p,f]=Ke(e,u);u+=f,r.push(`${a()}i32.const ${p}`)}else if(c===g.f32_const){let p=new ArrayBuffer(4),f=new Uint8Array(p);for(let m=0;m<4;m++)f[m]=e[u+m];let d=new Float32Array(p)[0];u+=4,r.push(`${a()}f32.const ${d}`)}else if(c===g.f64_const){let p=wu(e,u);u+=8,r.push(`${a()}f64.const ${p}`)}else if(c===g.block||c===g.loop){let p=e[u];u++,r.push(`${a()}${l}${p===$e.void?"":` (result ${p===$e.f64?"f64":"i32"})`}`),s++}else if(c===g.if){let p=e[u];u++,r.push(`${a()}if${p===$e.void?"":` (result ${p===$e.f64?"f64":"i32"})`}`),s++}else if(c===g.else)s--,r.push(`${a()}else`),s++;else if(c===g.end)s=Math.max(1,s-1),r.push(`${a()}end`);else if(c===g.f64_load||c===g.f64_store||c===g.f32_load||c===g.f32_store||c===g.i32_load||c===g.i32_store){let[p,f]=Ke(e,u);u+=f;let[d,m]=Ke(e,u);u+=m,r.push(`${a()}${l}${d?` offset=${d}`:""}`)}else if(c===Gt){let[p,f]=Ke(e,u);u+=f;let d=_u[p]||`simd.unknown(0x${p.toString(16)})`;if(p===ae.v128_load||p===ae.v128_store){let[m,y]=Ke(e,u);u+=y;let[x,S]=Ke(e,u);u+=S,r.push(`${a()}${d}${x?` offset=${x}`:""}`)}else if(p===ae.v128_const){let m=e.slice(u,u+16);u+=16,r.push(`${a()}v128.const ${m.map(y=>"0x"+y.toString(16).padStart(2,"0")).join(" ")}`)}else if(p===ae.f32x4_extract_lane||p===ae.f32x4_replace_lane){let m=e[u];u++,r.push(`${a()}${d} ${m}`)}else r.push(`${a()}${d}`)}else r.push(`${a()}${l}`)}return r.push(")"),r.join(`
318
+ `)}var An={Int8Array:{elementType:"i32",bytesPerElement:1,loadOp:g.i32_load8_s,storeOp:g.i32_store8},Uint8Array:{elementType:"i32",bytesPerElement:1,loadOp:g.i32_load8_u,storeOp:g.i32_store8},Uint8ClampedArray:{elementType:"i32",bytesPerElement:1,loadOp:g.i32_load8_u,storeOp:g.i32_store8},Int16Array:{elementType:"i32",bytesPerElement:2,loadOp:g.i32_load16_s,storeOp:g.i32_store16},Uint16Array:{elementType:"i32",bytesPerElement:2,loadOp:g.i32_load16_u,storeOp:g.i32_store16},Int32Array:{elementType:"i32",bytesPerElement:4,loadOp:g.i32_load,storeOp:g.i32_store},Uint32Array:{elementType:"i32",bytesPerElement:4,loadOp:g.i32_load,storeOp:g.i32_store},Float32Array:{elementType:"f32",bytesPerElement:4,loadOp:g.f32_load,storeOp:g.f32_store},Float64Array:{elementType:"f64",bytesPerElement:8,loadOp:g.f64_load,storeOp:g.f64_store}};function vu(e,t=new Map){let n={params:e,locals:new Map,nextLocalIndex:e.length,localTypes:[],warnings:[],errors:[],loopDepth:0,needsMathImports:new Set,needsMemory:!1,hasReturn:!1,wat:[],watIndent:1,moduleFunctions:t};return e.forEach((r,s)=>{n.locals.set(r.name,{index:s,type:r.type})}),n}function Cn(e,t,n){if(e.locals.has(t))return e.errors.push(`Duplicate local declaration: ${t}`),e.locals.get(t).index;let r=e.nextLocalIndex++;return e.locals.set(t,{index:r,type:n}),e.localTypes.push(n),r}function ct(e,t){return e.locals.get(t)}function St(e,t){switch(e.type){case"ExpressionStatement":{let n=e.expression;return[...z(n,t),g.drop]}case"ReturnStatement":{let n=e;if(t.hasReturn=!0,!n.argument)return[g.return];let r=z(n.argument,t),s=Y(n.argument,t);return s==="i32"?r.push(g.f64_convert_i32_s):s==="f32"&&r.push(g.f64_promote_f32),r.push(g.return),r}case"VariableDeclaration":{let n=e,r=[];for(let s of n.declarations){if(s.id.type!=="Identifier"){t.errors.push("Destructuring not supported in WASM blocks");continue}let a=s.id.name,i="f64";s.init&&(i=Y(s.init,t));let o=Cn(t,a,i);s.init&&(r.push(...z(s.init,t)),r.push(g.local_set,...B(o)))}return r}case"ForStatement":return ku(e,t);case"IfStatement":return Eu(e,t);case"BlockStatement":{let n=e,r=[];for(let s of n.body)r.push(...St(s,t));return r}default:return t.errors.push(`Unsupported statement type: ${e.type}`),[]}}function ku(e,t){let n=[];return e.init&&(e.init.type==="VariableDeclaration"?n.push(...St(e.init,t)):n.push(...z(e.init,t))),n.push(g.block,$e.void),n.push(g.loop,$e.void),e.test&&(n.push(...z(e.test,t)),n.push(g.i32_eqz),n.push(g.br_if,1)),t.loopDepth++,e.body&&n.push(...St(e.body,t)),t.loopDepth--,e.update&&(n.push(...z(e.update,t)),n.push(g.drop)),n.push(g.br,0),n.push(g.end),n.push(g.end),n}function Eu(e,t){let n=[];return n.push(...z(e.test,t)),n.push(g.if,$e.void),n.push(...St(e.consequent,t)),e.alternate&&(n.push(g.else),n.push(...St(e.alternate,t))),n.push(g.end),n}function Y(e,t){switch(e.type){case"Literal":{let n=e;return typeof n.value=="number"?n.raw&&(n.raw.includes(".")||n.raw.includes("e"))?"f64":Number.isInteger(n.value)&&n.value>=-2147483648&&n.value<=2147483647?"i32":"f64":"f64"}case"Identifier":return ct(t,e.name)?.type??"f64";case"BinaryExpression":case"AssignmentExpression":{let n=e;if(["<",">","<=",">=","==","!=","===","!=="].includes(n.operator)||["|","&","^","<<",">>",">>>"].includes(n.operator))return"i32";let r=Y(n.left,t),s=Y(n.right,t);return r==="v128"||s==="v128"?"v128":r==="f64"||s==="f64"?"f64":r==="f32"||s==="f32"?"f32":"i32"}case"UnaryExpression":{let n=e;return n.operator==="!"?"i32":Y(n.argument,t)}case"MemberExpression":{let n=e;if(n.object.type==="Identifier"&&ct(t,n.object.name)){let s=t.params.find(a=>a.name===n.object.name);if(s?.arrayType){let a=An[s.arrayType];if(a)return a.elementType}}return"f64"}case"CallExpression":{let n=e;if(n.callee.type==="MemberExpression"){let r=n.callee;if(r.object.type==="Identifier"&&r.object.name==="Math")return"f64"}if(n.callee.type==="Identifier"){let r=n.callee.name;if(r==="f32x4_extract_lane")return"f32";if(r.startsWith("f32x4_")||r==="v128_load")return"v128";let s=t.moduleFunctions.get(r);if(s)return s.hasReturn?"f64":"i32"}return"f64"}default:return"f64"}}function z(e,t){switch(e.type){case"Literal":{let n=e;if(typeof n.value=="number"){let r=Y(e,t);return r==="i32"?[g.i32_const,...Ht(n.value|0)]:r==="f32"?[g.f32_const,...Ur(n.value)]:[g.f64_const,...ge(n.value)]}return t.errors.push(`Unsupported literal type: ${typeof n.value}`),[g.f64_const,...ge(0)]}case"Identifier":{let n=e.name,r=ct(t,n);return r?[g.local_get,...B(r.index)]:(t.errors.push(`Unknown identifier: ${n}`),[g.f64_const,...ge(0)])}case"BinaryExpression":return Tu(e,t);case"UnaryExpression":return $u(e,t);case"AssignmentExpression":return Cu(e,t);case"UpdateExpression":return Au(e,t);case"MemberExpression":return Pu(e,t);case"CallExpression":return Iu(e,t);case"SequenceExpression":{let n=e,r=[];for(let s=0;s<n.expressions.length;s++)r.push(...z(n.expressions[s],t)),s<n.expressions.length-1&&r.push(g.drop);return r}default:return t.errors.push(`Unsupported expression type: ${e.type}`),[g.f64_const,...ge(0)]}}function Tu(e,t){let n=z(e.left,t),r=z(e.right,t),s=Y(e,t),a=Y(e.left,t),i=Y(e.right,t),o=["<",">","<=",">=","==","===","!=","!=="].includes(e.operator),u;a==="f64"||i==="f64"?u="f64":a==="f32"||i==="f32"?u="f32":u="i32",!o&&s==="f64"&&(u="f64");let c=n,l=r;u==="f64"?(a==="i32"?c=[...n,g.f64_convert_i32_s]:a==="f32"&&(c=[...n,g.f64_promote_f32]),i==="i32"?l=[...r,g.f64_convert_i32_s]:i==="f32"&&(l=[...r,g.f64_promote_f32])):u==="f32"&&(a==="i32"&&(c=[...n,g.f32_convert_i32_s]),i==="i32"&&(l=[...r,g.f32_convert_i32_s]));let f={"+":{i32:g.i32_add,f32:g.f32_add,f64:g.f64_add},"-":{i32:g.i32_sub,f32:g.f32_sub,f64:g.f64_sub},"*":{i32:g.i32_mul,f32:g.f32_mul,f64:g.f64_mul},"/":{i32:g.i32_div_s,f32:g.f32_div,f64:g.f64_div},"%":{i32:g.i32_rem_s},"<":{i32:g.i32_lt_s,f32:g.f32_lt,f64:g.f64_lt},">":{i32:g.i32_gt_s,f32:g.f32_gt,f64:g.f64_gt},"<=":{i32:g.i32_le_s,f32:g.f32_le,f64:g.f64_le},">=":{i32:g.i32_ge_s,f32:g.f32_ge,f64:g.f64_ge},"==":{i32:g.i32_eq,f32:g.f32_eq,f64:g.f64_eq},"===":{i32:g.i32_eq,f32:g.f32_eq,f64:g.f64_eq},"!=":{i32:g.i32_ne,f32:g.f32_ne,f64:g.f64_ne},"!==":{i32:g.i32_ne,f32:g.f32_ne,f64:g.f64_ne},"|":{i32:g.i32_or},"&":{i32:g.i32_and},"^":{i32:g.i32_xor},"<<":{i32:g.i32_shl},">>":{i32:g.i32_shr_s},">>>":{i32:g.i32_shr_u}}[e.operator];if(!f)return t.errors.push(`Unsupported operator: ${e.operator}`),[g.f64_const,...ge(0)];let d=f[u]??f.f64??f.i32;return d===void 0?(t.errors.push(`Operator ${e.operator} not supported for type ${u}`),[g.f64_const,...ge(0)]):[...c,...l,d]}function $u(e,t){let n=z(e.argument,t),r=Y(e.argument,t);switch(e.operator){case"-":return r==="i32"?[g.i32_const,0,...n,g.i32_sub]:r==="f32"?[...n,g.f32_neg]:[...n,g.f64_neg];case"!":return[...n,g.i32_eqz];case"~":return[...n,g.i32_const,...Ht(-1),g.i32_xor];default:return t.errors.push(`Unsupported unary operator: ${e.operator}`),n}}function Cu(e,t){if(e.left.type==="MemberExpression")return ju(e.left,e.right,e.operator,t);if(e.left.type!=="Identifier")return t.errors.push("Assignment target must be identifier or array element"),[];let n=e.left.name,r=ct(t,n);if(!r)return t.errors.push(`Unknown variable: ${n}`),[];let s=[];if(e.operator==="="){s.push(...z(e.right,t));let a=Y(e.right,t);r.type==="f64"&&a==="i32"?s.push(g.f64_convert_i32_s):r.type==="f64"&&a==="f32"?s.push(g.f64_promote_f32):r.type==="i32"&&a==="f64"?s.push(g.i32_trunc_f64_s):r.type==="i32"&&a==="f32"?s.push(g.i32_trunc_f32_s):r.type==="f32"&&a==="i32"?s.push(g.f32_convert_i32_s):r.type==="f32"&&a==="f64"&&s.push(g.f32_demote_f64)}else{let a=Y(e.right,t),i=r.type;a==="f64"||r.type==="f64"?i="f64":(a==="f32"||r.type==="f32")&&(i="f32"),s.push(g.local_get,...B(r.index)),i==="f64"&&r.type==="i32"?s.push(g.f64_convert_i32_s):i==="f64"&&r.type==="f32"?s.push(g.f64_promote_f32):i==="f32"&&r.type==="i32"&&s.push(g.f32_convert_i32_s),s.push(...z(e.right,t)),i==="f64"&&a==="i32"?s.push(g.f64_convert_i32_s):i==="f64"&&a==="f32"?s.push(g.f64_promote_f32):i==="f32"&&a==="i32"&&s.push(g.f32_convert_i32_s);let o=e.operator.slice(0,-1),c={"+":{i32:g.i32_add,f32:g.f32_add,f64:g.f64_add},"-":{i32:g.i32_sub,f32:g.f32_sub,f64:g.f64_sub},"*":{i32:g.i32_mul,f32:g.f32_mul,f64:g.f64_mul},"/":{i32:g.i32_div_s,f32:g.f32_div,f64:g.f64_div}}[o]?.[i];if(!c)return t.errors.push(`Unsupported compound assignment: ${e.operator}`),[];s.push(c),r.type==="i32"&&i==="f64"?s.push(g.i32_trunc_f64_s):r.type==="i32"&&i==="f32"?s.push(g.i32_trunc_f32_s):r.type==="f32"&&i==="f64"&&s.push(g.f32_demote_f64)}return s.push(g.local_tee,...B(r.index)),s}function Au(e,t){if(e.argument.type!=="Identifier")return t.errors.push("Update expression argument must be identifier"),[];let n=e.argument.name,r=ct(t,n);if(!r)return t.errors.push(`Unknown variable: ${n}`),[];let s=[],a=r.type==="i32";return e.prefix?(s.push(g.local_get,...B(r.index)),a?(s.push(g.i32_const,1),s.push(e.operator==="++"?g.i32_add:g.i32_sub)):(s.push(g.f64_const,...ge(1)),s.push(e.operator==="++"?g.f64_add:g.f64_sub)),s.push(g.local_tee,...B(r.index))):(s.push(g.local_get,...B(r.index)),s.push(g.local_get,...B(r.index)),a?(s.push(g.i32_const,1),s.push(e.operator==="++"?g.i32_add:g.i32_sub)):(s.push(g.f64_const,...ge(1)),s.push(e.operator==="++"?g.f64_add:g.f64_sub)),s.push(g.local_set,...B(r.index))),s}function Pu(e,t){if(e.object.type!=="Identifier")return t.errors.push("Array access requires identifier"),[];let n=e.object.name,r=t.params.find(c=>c.name===n);if(!r?.isArray||!r.arrayType)return t.errors.push(`${n} is not a typed array parameter`),[];let s=An[r.arrayType];if(!s)return t.errors.push(`Unknown array type: ${r.arrayType}`),[];t.needsMemory=!0;let a=[],i=ct(t,n);if(!i)return t.errors.push(`Unknown array: ${n}`),[];if(a.push(g.local_get,...B(i.index)),!e.computed||!e.property)return t.errors.push("Array access requires computed index"),[];let o=z(e.property,t),u=Y(e.property,t);return a.push(...o),u==="f64"&&a.push(g.i32_trunc_f64_s),s.bytesPerElement>1&&(a.push(g.i32_const,...Ht(s.bytesPerElement)),a.push(g.i32_mul)),a.push(g.i32_add),a.push(s.loadOp,0,0),a}function ju(e,t,n,r){if(e.object.type!=="Identifier")return r.errors.push("Array store requires identifier"),[];let s=e.object.name,a=r.params.find(m=>m.name===s);if(!a?.isArray||!a.arrayType)return r.errors.push(`${s} is not a typed array parameter`),[];let i=An[a.arrayType];if(!i)return r.errors.push(`Unknown array type: ${a.arrayType}`),[];r.needsMemory=!0;let o=[],u=ct(r,s);if(!u)return[];if(!e.computed||!e.property)return r.errors.push("Array store requires computed index"),[];let c=z(e.property,r),l=Y(e.property,r),p=()=>{let m=[];return m.push(g.local_get,...B(u.index)),m.push(...c),l==="f64"&&m.push(g.i32_trunc_f64_s),i.bytesPerElement>1&&(m.push(g.i32_const,...Ht(i.bytesPerElement)),m.push(g.i32_mul)),m.push(g.i32_add),m};if(n==="=")o.push(...z(t,r));else{let m=Cn(r,`__addr_${r.nextLocalIndex}`,"i32");o.push(...p()),o.push(g.local_tee,...B(m)),o.push(i.loadOp,0,0),o.push(...z(t,r));let y=Y(t,r);i.elementType==="f32"&&y==="f64"?o.push(g.f32_demote_f64):i.elementType==="f64"&&y==="f32"?o.push(g.f64_promote_f32):i.elementType==="f32"&&y==="i32"?o.push(g.f32_convert_i32_s):i.elementType==="f64"&&y==="i32"?o.push(g.f64_convert_i32_s):i.elementType==="i32"&&y==="f64"?o.push(g.i32_trunc_f64_s):i.elementType==="i32"&&y==="f32"&&o.push(g.i32_trunc_f32_s);let x=n.slice(0,-1),S={"+":i.elementType==="i32"?g.i32_add:i.elementType==="f32"?g.f32_add:g.f64_add,"-":i.elementType==="i32"?g.i32_sub:i.elementType==="f32"?g.f32_sub:g.f64_sub,"*":i.elementType==="i32"?g.i32_mul:i.elementType==="f32"?g.f32_mul:g.f64_mul};o.push(S[x]??g.f64_add);let E=Cn(r,`__val_${r.nextLocalIndex}`,i.elementType);return o.push(g.local_set,...B(E)),o.push(g.local_get,...B(m)),o.push(g.local_get,...B(E)),o.push(i.storeOp,0,0),o.push(g.local_get,...B(E)),o}let f=Y(t,r);i.elementType==="f32"&&f==="f64"?o.push(g.f32_demote_f64):i.elementType==="f64"&&f==="f32"?o.push(g.f64_promote_f32):i.elementType==="i32"&&f==="f64"&&o.push(g.i32_trunc_f64_s);let d=Cn(r,`__tmp_${r.nextLocalIndex}`,i.elementType);return o.push(g.local_set,...B(d)),o.push(g.local_get,...B(u.index)),o.push(...c),l==="f64"&&o.push(g.i32_trunc_f64_s),i.bytesPerElement>1&&(o.push(g.i32_const,...Ht(i.bytesPerElement)),o.push(g.i32_mul)),o.push(g.i32_add),o.push(g.local_get,...B(d)),o.push(i.storeOp,0,0),o.push(g.local_get,...B(d)),o}function Iu(e,t){if(e.callee.type==="MemberExpression"){let n=e.callee;if(n.object.type==="Identifier"&&n.object.name==="Math"&&n.property.type==="Identifier"){let r=n.property.name;return Ou(r,e.arguments,t)}}if(e.callee.type==="Identifier"){let n=e.callee.name;if(n.startsWith("f32x4_")||n.startsWith("v128_"))return Mu(n,e.arguments,t);let r=t.moduleFunctions.get(n);if(r)return Nu(r,n,e.arguments,t)}return t.errors.push(`Unsupported function call: ${e.callee.type}`),[g.f64_const,...ge(0)]}function Nu(e,t,n,r){if(n.length!==e.params.length)return r.errors.push(`wasm function ${t} expects ${e.params.length} arguments, got ${n.length}`),[g.f64_const,...ge(0)];let s=[];for(let a=0;a<n.length;a++){let i=n[a],o=e.params[a].type,u=Y(i,r);if(s.push(...z(i,r)),u!==o){let c=Ru(u,o);c===void 0?r.errors.push(`wasm function ${t} param ${a} expects ${o}, got ${u} (no conversion available)`):c!==null&&s.push(c)}}return s.push(g.call,...B(e.index)),e.hasReturn||s.push(g.i32_const,0),s}function Ru(e,t){if(e===t)return null;if(!(e==="v128"||t==="v128")&&!(e==="i64"||t==="i64"))switch(`${e}->${t}`){case"f64->i32":return g.i32_trunc_f64_s;case"f32->i32":return g.i32_trunc_f32_s;case"i32->f64":return g.f64_convert_i32_s;case"i32->f32":return g.f32_convert_i32_s;case"f32->f64":return g.f64_promote_f32;case"f64->f32":return g.f32_demote_f64;default:return}}function Mu(e,t,n){n.needsMemory=!0;let r=[];switch(e){case"v128_load":case"f32x4_load":{r.push(...z(t[0],n)),Y(t[0],n)==="f64"&&r.push(g.i32_trunc_f64_s),r.push(...z(t[1],n));let a=Y(t[1],n);return a==="f64"?r.push(g.i32_trunc_f64_s):a==="f32"&&r.push(g.i32_trunc_f32_s),r.push(g.i32_add),r.push(...ea(ae.v128_load,2,0)),r}case"v128_store":case"f32x4_store":{r.push(...z(t[0],n)),Y(t[0],n)==="f64"&&r.push(g.i32_trunc_f64_s),r.push(...z(t[1],n));let a=Y(t[1],n);return a==="f64"?r.push(g.i32_trunc_f64_s):a==="f32"&&r.push(g.i32_trunc_f32_s),r.push(g.i32_add),r.push(...z(t[2],n)),r.push(...ea(ae.v128_store,2,0)),r.push(g.i32_const,0),r}case"f32x4_splat":{r.push(...z(t[0],n));let s=Y(t[0],n);return s==="i32"?r.push(g.f32_convert_i32_s):s==="f64"&&r.push(g.f32_demote_f64),r.push(...qr(ae.f32x4_splat)),r}case"f32x4_extract_lane":{r.push(...z(t[0],n));let s=t[1].value;return!Number.isInteger(s)||s<0||s>3?(n.errors.push(`f32x4_extract_lane: lane must be 0-3, got ${s}`),[g.f32_const,...Ur(0)]):(r.push(Gt,...B(ae.f32x4_extract_lane),s),r)}case"f32x4_replace_lane":{r.push(...z(t[0],n));let s=t[1].value;if(!Number.isInteger(s)||s<0||s>3)return n.errors.push(`f32x4_replace_lane: lane must be 0-3, got ${s}`),[g.f32_const,...Ur(0)];r.push(...z(t[2],n));let a=Y(t[2],n);return a==="i32"?r.push(g.f32_convert_i32_s):a==="f64"&&r.push(g.f32_demote_f64),r.push(Gt,...B(ae.f32x4_replace_lane),s),r}case"f32x4_add":case"f32x4_sub":case"f32x4_mul":case"f32x4_div":{r.push(...z(t[0],n)),r.push(...z(t[1],n));let s={f32x4_add:ae.f32x4_add,f32x4_sub:ae.f32x4_sub,f32x4_mul:ae.f32x4_mul,f32x4_div:ae.f32x4_div};return r.push(...qr(s[e])),r}case"f32x4_neg":case"f32x4_sqrt":{r.push(...z(t[0],n));let s={f32x4_neg:ae.f32x4_neg,f32x4_sqrt:ae.f32x4_sqrt};return r.push(...qr(s[e])),r}default:return n.errors.push(`Unknown SIMD intrinsic: ${e}`),[g.f64_const,...ge(0)]}}function Ou(e,t,n){let r=[];for(let o of t){r.push(...z(o,n));let u=Y(o,n);u==="i32"?r.push(g.f64_convert_i32_s):u==="f32"&&r.push(g.f64_promote_f32)}let a={abs:g.f64_abs,ceil:g.f64_ceil,floor:g.f64_floor,trunc:g.f64_trunc,sqrt:g.f64_sqrt,min:g.f64_min,max:g.f64_max}[e];return a!==void 0?(r.push(a),r):["sin","cos","tan","asin","acos","atan","atan2","exp","log","pow"].includes(e)?(n.needsMathImports.add(e),n.errors.push(`Math.${e} requires JS import (not yet implemented)`),[g.f64_const,...ge(0)]):(n.errors.push(`Unknown Math method: ${e}`),[g.f64_const,...ge(0)])}function ta(e){let t=e.split(":").map(a=>a.trim()),n=t[0];if(t.length===1)return{name:n,type:"f64"};let r=t[1];return An[r]?{name:n,type:"i32",isArray:!0,arrayType:r}:{name:n,type:{i32:"i32",i64:"i64",f32:"f32",f64:"f64",number:"f64",int:"i32"}[r]??"f64"}}function Bu(e,t){let n=e.map(s=>$e[s.type]),r=t?[1,$e.f64]:[0];return[96,...B(e.length),...n,...r]}function Du(e,t){let n=[];if(t.length>0){let a=t[0],i=1;for(let o=1;o<t.length;o++)t[o]===a?i++:(n.push([...B(i),$e[a]]),a=t[o],i=1);n.push([...B(i),$e[a]])}let s=[...[...B(n.length),...n.flat()],...e,g.end];return[...B(s.length),...s]}function Fu(){return zt(Jt.import,[1,...Wr("env"),...Wr("memory"),2,0,1])}function Lu(e,t){if(e.length!==t.length)throw new Error("functions and exportNames length mismatch");let n=[0,97,115,109,1,0,0,0],r=e.map(f=>Bu(f.params,f.hasReturn)),s=zt(Jt.type,[...B(r.length),...r.flat()]),i=e.some(f=>f.needsMemory)?Fu():[],o=zt(Jt.function,[...B(e.length),...e.map((f,d)=>B(d)).flat()]),u=zt(Jt.export,[...B(e.length),...t.map((f,d)=>[...Wr(f),0,...B(d)]).flat()]),c=e.map(f=>Du(f.bodyCode,f.localTypes)),l=zt(Jt.code,[...B(c.length),...c.flat()]),p=[...n,...s];return i.length>0&&p.push(...i),p.push(...o,...u,...l),p}function Vu(e,t=new Map){try{let n=e.captures.map(ta),r;try{let u=`function __wasm__(${n.map(c=>c.name).join(", ")}) { ${e.body} }`;r=je(u,{ecmaVersion:2022})}catch(u){return{success:!1,warnings:[],error:`Parse error: ${u.message}`}}let a=r.body[0].body.body,i=vu(n,t),o=[];for(let u of a)o.push(...St(u,i));return i.errors.length>0?{success:!1,warnings:i.warnings,error:i.errors.join("; ")}:{success:!0,fn:{params:n,bodyCode:o,localTypes:i.localTypes,needsMemory:i.needsMemory,hasReturn:i.hasReturn},wat:Su(o,n,i.localTypes),warnings:i.warnings}}catch(n){return{success:!1,warnings:[],error:n.message}}}function na(e){let t=new Map,n=[];for(let u=0;u<e.length;u++){let c=e[u],l=c.captures.map(ta),p=c.returnType!==void 0;n.push({params:l,hasReturn:p}),c.name&&t.set(c.name,{index:u,params:l,hasReturn:p})}let r=[],s=[],a=[],i=[];for(let u=0;u<e.length;u++){let c=e[u],l=Vu(c,t);if(i.push(...l.warnings),!l.success||!l.fn){r.push({id:c.id,success:!1,error:l.error}),s.push(qu(n[u])),a.push({id:c.id,exportName:`compute_${u}`,captures:c.captures,needsMemory:!1,wat:`(failed: ${l.error??"unknown error"})`});continue}s.push(l.fn),a.push({id:c.id,exportName:`compute_${u}`,captures:c.captures,needsMemory:l.fn.needsMemory,wat:l.wat??""}),r.push({id:c.id,success:!0,exportIndex:u})}if(s.length===0)return{bytes:new Uint8Array,results:r,exports:[],needsMemory:!1,warnings:i};let o=Lu(s,a.map(u=>u.exportName));return{bytes:new Uint8Array(o),results:r,exports:a,needsMemory:a.some(u=>u.needsMemory),warnings:i}}function qu(e){let t=e.hasReturn?[g.f64_const,...ge(0)]:[];return{params:e.params,bodyCode:t,localTypes:[],needsMemory:!1,hasReturn:e.hasReturn}}function ra(e){let t=na(e),n=new Map(t.exports.map(l=>[l.id,l])),r=t.results.map(l=>{if(!l.success)return{id:l.id,success:!1,error:l.error};let p=n.get(l.id);return{id:l.id,success:!0,byteLength:t.bytes.length,_exportName:p.exportName}});if(t.exports.length===0)return{code:"",results:r};let s=t.exports.map(l=>{let p=l.wat.split(`
315
319
  `).map(f=>` * ${f}`);return`/**
316
320
  * WASM: ${l.id} (export: ${l.exportName})
317
321
  ${p.join(`
@@ -346,25 +350,31 @@ for(const{id,n,c,m}of __wasmExports){
346
350
  const ab=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);off=(off+15)&~15;ab.set(mv.slice(off,off+ab.length));off+=ab.length}}
347
351
  return r};
348
352
  }})();
349
- `.trim(),c=r.map(({_exportName:l,...p})=>p);return{code:u,results:c}}function Br(e,t){let n=[];function r(a){n.push({start:a.start,end:a.end,newText:`__tjs.toBool(${he(a,t)})`})}function s(a){if(!(!a||typeof a!="object"||!("type"in a))){switch(a.type){case"IfStatement":case"WhileStatement":case"DoWhileStatement":{let i=a;r(i.test),i.consequent&&s(i.consequent),i.alternate&&s(i.alternate),i.body&&s(i.body);return}case"ForStatement":{let i=a;i.init&&s(i.init),i.test&&r(i.test),i.update&&s(i.update),i.body&&s(i.body);return}case"ConditionalExpression":{let i=a;n.push({start:i.start,end:i.end,newText:`__tjs.toBool(${he(i.test,t)})?(${he(i.consequent,t)}):(${he(i.alternate,t)})`});return}case"LogicalExpression":{let i=a;if(i.operator==="&&"||i.operator==="||"){n.push({start:i.start,end:i.end,newText:he(a,t)});return}break}case"UnaryExpression":{let i=a;if(i.operator==="!"){n.push({start:i.start,end:i.end,newText:`!__tjs.toBool(${he(i.argument,t)})`});return}break}case"CallExpression":{let i=a;if(i.callee&&i.callee.type==="Identifier"&&i.callee.name==="Boolean"&&i.arguments.length===1&&i.arguments[0].type!=="SpreadElement"){n.push({start:i.start,end:i.end,newText:`__tjs.toBool(${he(i.arguments[0],t)})`});return}break}}ku(a,s)}}return s(e),Eu(n)}function he(e,t){if(!e)return"";switch(e.type){case"LogicalExpression":{let n=e,r=he(n.left,t),s=he(n.right,t);return n.operator==="&&"?`((__tjs__t)=>__tjs.toBool(__tjs__t)?(${s}):__tjs__t)(${r})`:n.operator==="||"?`((__tjs__t)=>__tjs.toBool(__tjs__t)?__tjs__t:(${s}))(${r})`:`(${r})??(${s})`}case"ConditionalExpression":{let n=e;return`__tjs.toBool(${he(n.test,t)})?(${he(n.consequent,t)}):(${he(n.alternate,t)})`}case"UnaryExpression":{let n=e;return n.operator==="!"?`!__tjs.toBool(${he(n.argument,t)})`:Or(e,t)}case"CallExpression":{let n=e;return n.callee&&n.callee.type==="Identifier"&&n.callee.name==="Boolean"&&n.arguments.length===1&&n.arguments[0].type!=="SpreadElement"?`__tjs.toBool(${he(n.arguments[0],t)})`:Or(e,t)}}return Or(e,t)}function Or(e,t){let n=e.start,r=e.end;if(typeof n!="number"||typeof r!="number")return"";let s=zi(e);if(s.length===0)return t.slice(n,r);s.sort((o,u)=>o.start-u.start);let a="",i=n;for(let o of s)o.start<i||(o.start>i&&(a+=t.slice(i,o.start)),a+=he(o,t),i=o.end);return i<r&&(a+=t.slice(i,r)),a}function ku(e,t){for(let n of zi(e))t(n)}function zi(e){let t=[];for(let n in e){if(n==="type"||n==="start"||n==="end"||n==="loc")continue;let r=e[n];if(Array.isArray(r))for(let s of r)s&&typeof s=="object"&&typeof s.type=="string"&&t.push(s);else r&&typeof r=="object"&&typeof r.type=="string"&&t.push(r)}return t}function Eu(e){let t=[...e].sort((s,a)=>s.start-a.start||a.end-s.end),n=[],r=-1;for(let s of t)s.start>=r&&(n.push(s),r=s.end);return n}function Fr(e){let t;try{t=je(`function __wrap__(){${e}}`,{ecmaVersion:2022,sourceType:"module",locations:!1})}catch{return e}let n=`function __wrap__(){${e}}`,r=Br(t,n);if(r.length===0)return e;r.sort((o,u)=>u.start-o.start);let s=n;for(let o of r)s=s.slice(0,o.start)+o.newText+s.slice(o.end);return s.slice("function __wrap__(){".length,s.length-"}".length)}function Tu(e,t,n){if(!e||!t)return!1;let r=new RegExp(`function\\s+${t}\\s*\\([^)]*?\\b${n}\\s*([=:])`,"s"),s=e.match(r);return s?s[1]===":":!1}function $u(e,t,n,r,s){let a=[],i=Nt(t,e),o={},u=!1,c,l;if(e.params.length===1&&(e.params[0].type==="ObjectPattern"||e.params[0].type==="AssignmentPattern"&&e.params[0].left.type==="ObjectPattern")){u=!0;let d=e.params[0],g=d.type==="ObjectPattern"?d:d.left,y=Ge(g,n);if(y.type.kind==="object"&&y.type.destructuredParams){c={},l=new Set;for(let[w,k]of Object.entries(y.type.destructuredParams))o[w]={...k,description:i.params[w]},c[w]=k.type,k.required&&l.add(w)}}else for(let d of e.params)if(d.type==="Identifier"){let g=Ge(d,n);o[d.name]={...g,required:n.has(d.name),description:i.params[d.name]}}else if(d.type==="AssignmentPattern"&&d.left.type==="Identifier"){let g=Ge(d,n),y=Tu(s||"",e.id?.name||"",d.left.name);o[d.left.name]={...g,required:y,default:y?null:g.example??g.default,description:i.params[d.left.name]}}else if(d.type==="ObjectPattern"){let g=Ge(d,n);if(g.type.kind==="object"&&g.type.destructuredParams)for(let[y,w]of Object.entries(g.type.destructuredParams))o[y]={...w,description:i.params[y]}}else if(d.type==="RestElement"&&d.argument?.type==="Identifier"){let g=d.argument.name,y=t.match(new RegExp(`\\.\\.\\.${g}\\s*:\\s*([^)]+?)\\s*\\)`));if(y)try{let w=$t(y[1].trim(),0,{ecmaVersion:2022}),k=ue(w);o[g]={name:g,type:k,required:!1,description:i.params[g]}}catch{o[g]={name:g,type:{kind:"array"},required:!1,description:i.params[g]}}else o[g]={name:g,type:{kind:"array"},required:!1,description:i.params[g]}}let p;if(r)try{let d=r.includes("=")?Hi(r):r,g=$t(d,0,{ecmaVersion:2022});p=ue(g)}catch{p={kind:"any"},a.push(`Could not parse return type: ${r}`)}return{types:{name:e.id?.name||"anonymous",params:o,returns:p,description:i.description,isDestructuredParam:u,destructuredShape:c,destructuredRequired:l},warnings:a}}function Cu(e,t,n){let r=[],s=n?`${n}:`:"",a=n?`${n}:${e}`:e;if(t.isDestructuredParam&&t.destructuredShape){let o=t.destructuredShape,u=t.destructuredRequired||new Set,c=Object.keys(o);if(c.length===0)return null;for(let l of c)r.push(`if (${l} instanceof Error) return ${l};`);for(let[l,p]of Object.entries(o)){let f=u.has(l),d=`${s}${e}.${l}`,g=kn(l,p);if(g){let y=p.kind;f?r.push(`if (${g}) return __tjs.typeError('${d}', '${y}', ${l});`):r.push(`if (${l} !== undefined && ${g}) return __tjs.typeError('${d}', '${y}', ${l});`)}}return r.length===0?null:(r.unshift(`__tjs.pushStack('${a}');`),{preamble:r.join(`
350
- `),suffix:"__tjs.popStack();"})}let i=Object.entries(t.params);if(i.length===0)return null;for(let[o]of i)r.push(`if (${o} instanceof Error) return ${o};`);for(let[o,u]of i){let c=`${s}${e}.${o}`;u.type.kind==="array"&&r.push(`if (Array.isArray(${o})) { for (const __i of ${o}) { if (__i instanceof Error && __i.path !== undefined) return __i } }`);let l=kn(o,u.type);if(l){let p=u.type.kind==="union"?u.type.members.map(f=>f.kind).join(" | "):u.type.kind;u.required?r.push(`if (${l}) return __tjs.typeError('${c}', '${p}', ${o});`):r.push(`if (${o} !== undefined && ${l}) return __tjs.typeError('${c}', '${p}', ${o});`)}if(u.type.kind==="function"){let p=Mu(o,u.type,c);p&&(r.push(p),r.push(`if (${o} instanceof Error) return ${o};`))}}return r.length===0?null:(r.unshift(`__tjs.pushStack('${a}');`),{preamble:r.join(`
351
- `),suffix:"__tjs.popStack();"})}function Hi(e){let t="",n=0;for(let r=0;r<e.length;r++){let s=e[r];if(s==="{"||s==="["||s==="(")n++,t+=s;else if(s==="}"||s==="]"||s===")")n--,t+=s;else if(s==="'"||s==='"'||s==="`"){for(t+=s,r++;r<e.length&&e[r]!==s;)e[r]==="\\"&&(t+=e[r++]),t+=e[r++];r<e.length&&(t+=e[r])}else n===1&&s==="="&&e[r-1]!=="!"&&e[r+1]!=="="?t+=":":t+=s}return t}function Au(e,t){let r=new RegExp(`function\\s+${t}\\s*\\([^)]*\\)\\s*(:[?!]?)\\s*`,"g").exec(e);if(!r)return null;let s=e.slice(r.index+r[0].length);return wn(s)}function Pu(e,t){let r=new RegExp(`function\\s+${t}\\s*\\([^)]*\\)\\s*:([?!]?)`,"g").exec(e);if(!r)return;let s=r[1];if(s==="?")return"safe";if(s==="!")return"unsafe"}function ju(e){let t=e.match(/^\/\*\s*tjs\s*<-\s*([^*]+?)\s*\*\//);return t?t[1].trim():void 0}function Iu(e,t){let n=new RegExp(`\\/\\*\\s*line\\s+(\\d+)\\s*\\*\\/\\s*(?:async\\s+)?function\\s+${t}\\s*\\(`,"m"),r=e.match(n);return r?parseInt(r[1],10):void 0}function En(e,t={}){let{filename:n="<source>",runTests:r=!0,debug:s=!1,resolvedImports:a={}}=t,i=[];e=Qn(e);let u=ju(e)||n,{code:c,tests:l,mocks:p,testRunner:f}=tr(e),{ast:d,originalSource:g,requiredParams:y,unsafeFunctions:w}=Qe(c,{filename:n,colonShorthand:!0,dialect:t.dialect,moduleLoader:t.moduleLoader}),k=Nu(d),S=hn(c,{dialect:t.dialect,moduleLoader:t.moduleLoader,filename:n});for(let A of l)A.body=At(A.body),S.tjsModes.tjsEquals&&(A.body=Pt(A.body)),S.tjsModes.tjsStandard&&(A.body=Fr(A.body));for(let A of p)A.body=At(A.body),S.tjsModes.tjsEquals&&(A.body=Pt(A.body)),S.tjsModes.tjsStandard&&(A.body=Fr(A.body));let b={},_=[],v=[];for(let A of k){let W=A.id?.name||"anonymous",V=Au(c,W),ve;if(V&&V.includes("="))try{let re=V.matchAll(/(\w+)\s*=\s*/g),le=Hi(V),Oe=new Function(`return ${le}`)(),fe={};for(let Nn of re){let wt=Nn[1];wt in Oe&&(fe[wt]=Oe[wt])}Object.keys(fe).length>0&&(ve=fe)}catch{}let{types:Me,warnings:sa}=$u(A,g,y,V,c);i.push(...sa),b[W]=Me;for(let re of A.params)if(re.type==="AssignmentPattern"&&re.left.type==="Identifier"&&re.right.type==="Identifier"){let le=re.left.name,Oe=re.right.name,fe=b[Oe];if(fe&&Me.params[le]){let Nn=Object.entries(fe.params).map(([ca,la])=>({name:ca,type:la.type})),wt=fe.returns??{kind:"any"};Me.params[le].type={kind:"function",params:Nn,returns:wt}}}for(let re of A.params)if(re.type==="AssignmentPattern"){let le=re.left?.name||re.left?.value,Oe=le?Me.params[le]:null;if(Oe?.required&&Oe.default===null)v.push({start:re.left.end,end:re.right.end});else{let fe=re.right;fe.type==="BinaryExpression"&&fe.operator==="|"&&v.push({start:fe.left.end,end:fe.end})}}let Jr=S.moduleSafety==="none"||w.has(W),ia=S.safeFunctions.has(W),aa=Pu(c,W),oa=Iu(e,W),ut={file:u,line:oa??A.loc?.start.line??0,column:A.loc?.start.column??0},ua={unsafe:Jr,safe:ia,returnSafety:aa},zr=S.polymorphicNames.has(W),In;if(zr){let re=[];for(let Oe of k){let fe=Oe.id?.name||"";fe.startsWith(W+"$")&&re.push(fe)}let le={polymorphic:!0,variants:re};ut&&(le.source=`${ut.file}:${ut.line}`),In=`${W}.__tjs = ${JSON.stringify(le,null,2)}`}else In=Ru(W,Me,ua,{debug:s,source:ut,returnDefaults:ve});if(_.push({position:A.end,text:`
352
- ${In}`}),!Jr&&!zr){let re=`${ut.file}:${ut.line}`,le=Cu(W,Me,re);le&&A.body&&A.body.start!==void 0&&(_.push({position:A.body.start+1,text:`
353
+ `.trim(),c=r.map(({_exportName:l,...p})=>p);return{code:u,results:c}}function zr(e,t){let n=[];function r(a){n.push({start:a.start,end:a.end,newText:`__tjs.toBool(${he(a,t)})`})}function s(a){if(!(!a||typeof a!="object"||!("type"in a))){switch(a.type){case"IfStatement":case"WhileStatement":case"DoWhileStatement":{let i=a;r(i.test),i.consequent&&s(i.consequent),i.alternate&&s(i.alternate),i.body&&s(i.body);return}case"ForStatement":{let i=a;i.init&&s(i.init),i.test&&r(i.test),i.update&&s(i.update),i.body&&s(i.body);return}case"ConditionalExpression":{let i=a;n.push({start:i.start,end:i.end,newText:`__tjs.toBool(${he(i.test,t)})?(${he(i.consequent,t)}):(${he(i.alternate,t)})`});return}case"LogicalExpression":{let i=a;if(i.operator==="&&"||i.operator==="||"){n.push({start:i.start,end:i.end,newText:he(a,t)});return}break}case"UnaryExpression":{let i=a;if(i.operator==="!"){n.push({start:i.start,end:i.end,newText:`!__tjs.toBool(${he(i.argument,t)})`});return}break}case"CallExpression":{let i=a;if(i.callee&&i.callee.type==="Identifier"&&i.callee.name==="Boolean"&&i.arguments.length===1&&i.arguments[0].type!=="SpreadElement"){n.push({start:i.start,end:i.end,newText:`__tjs.toBool(${he(i.arguments[0],t)})`});return}break}}Uu(a,s)}}return s(e),Wu(n)}function he(e,t){if(!e)return"";switch(e.type){case"LogicalExpression":{let n=e,r=he(n.left,t),s=he(n.right,t);return n.operator==="&&"?`((__tjs__t)=>__tjs.toBool(__tjs__t)?(${s}):__tjs__t)(${r})`:n.operator==="||"?`((__tjs__t)=>__tjs.toBool(__tjs__t)?__tjs__t:(${s}))(${r})`:`(${r})??(${s})`}case"ConditionalExpression":{let n=e;return`__tjs.toBool(${he(n.test,t)})?(${he(n.consequent,t)}):(${he(n.alternate,t)})`}case"UnaryExpression":{let n=e;return n.operator==="!"?`!__tjs.toBool(${he(n.argument,t)})`:Jr(e,t)}case"CallExpression":{let n=e;return n.callee&&n.callee.type==="Identifier"&&n.callee.name==="Boolean"&&n.arguments.length===1&&n.arguments[0].type!=="SpreadElement"?`__tjs.toBool(${he(n.arguments[0],t)})`:Jr(e,t)}}return Jr(e,t)}function Jr(e,t){let n=e.start,r=e.end;if(typeof n!="number"||typeof r!="number")return"";let s=sa(e);if(s.length===0)return t.slice(n,r);s.sort((o,u)=>o.start-u.start);let a="",i=n;for(let o of s)o.start<i||(o.start>i&&(a+=t.slice(i,o.start)),a+=he(o,t),i=o.end);return i<r&&(a+=t.slice(i,r)),a}function Uu(e,t){for(let n of sa(e))t(n)}function sa(e){let t=[];for(let n in e){if(n==="type"||n==="start"||n==="end"||n==="loc")continue;let r=e[n];if(Array.isArray(r))for(let s of r)s&&typeof s=="object"&&typeof s.type=="string"&&t.push(s);else r&&typeof r=="object"&&typeof r.type=="string"&&t.push(r)}return t}function Wu(e){let t=[...e].sort((s,a)=>s.start-a.start||a.end-s.end),n=[],r=-1;for(let s of t)s.start>=r&&(n.push(s),r=s.end);return n}function Gr(e){let t;try{t=je(`function __wrap__(){${e}}`,{ecmaVersion:2022,sourceType:"module",locations:!1})}catch{return e}let n=`function __wrap__(){${e}}`,r=zr(t,n);if(r.length===0)return e;r.sort((o,u)=>u.start-o.start);let s=n;for(let o of r)s=s.slice(0,o.start)+o.newText+s.slice(o.end);return s.slice("function __wrap__(){".length,s.length-"}".length)}function Ju(e,t,n){if(!e||!t)return!1;let r=new RegExp(`function\\s+${t}\\s*\\([^)]*?\\b${n}\\s*([=:])`,"s"),s=e.match(r);return s?s[1]===":":!1}function zu(e,t,n,r,s){let a=[],i=Dt(t,e),o={},u=!1,c,l;if(e.params.length===1&&(e.params[0].type==="ObjectPattern"||e.params[0].type==="AssignmentPattern"&&e.params[0].left.type==="ObjectPattern")){u=!0;let d=e.params[0],m=d.type==="ObjectPattern"?d:d.left,y=Ge(m,n);if(y.type.kind==="object"&&y.type.destructuredParams){c={},l=new Set;for(let[x,S]of Object.entries(y.type.destructuredParams))o[x]={...S,description:i.params[x]},c[x]=S.type,S.required&&l.add(x)}}else for(let d of e.params)if(d.type==="Identifier"){let m=Ge(d,n);o[d.name]={...m,required:n.has(d.name),description:i.params[d.name]}}else if(d.type==="AssignmentPattern"&&d.left.type==="Identifier"){let m=Ge(d,n),y=Ju(s||"",e.id?.name||"",d.left.name);o[d.left.name]={...m,required:y,default:y?null:m.example??m.default,description:i.params[d.left.name]}}else if(d.type==="ObjectPattern"){let m=Ge(d,n);if(m.type.kind==="object"&&m.type.destructuredParams)for(let[y,x]of Object.entries(m.type.destructuredParams))o[y]={...x,description:i.params[y]}}else if(d.type==="RestElement"&&d.argument?.type==="Identifier"){let m=d.argument.name,y=t.match(new RegExp(`\\.\\.\\.${m}\\s*:\\s*([^)]+?)\\s*\\)`));if(y)try{let x=Pt(y[1].trim(),0,{ecmaVersion:2022}),S=ue(x);o[m]={name:m,type:S,required:!1,description:i.params[m]}}catch{o[m]={name:m,type:{kind:"array"},required:!1,description:i.params[m]}}else o[m]={name:m,type:{kind:"array"},required:!1,description:i.params[m]}}let p;if(r)try{let d=r.includes("=")?aa(r):r,m=Pt(d,0,{ecmaVersion:2022});p=ue(m)}catch{p={kind:"any"},a.push(`Could not parse return type: ${r}`)}return{types:{name:e.id?.name||"anonymous",params:o,returns:p,description:i.description,isDestructuredParam:u,destructuredShape:c,destructuredRequired:l},warnings:a}}function Gu(e,t,n){let r=[],s=n?`${n}:`:"",a=n?`${n}:${e}`:e;if(t.isDestructuredParam&&t.destructuredShape){let o=t.destructuredShape,u=t.destructuredRequired||new Set,c=Object.keys(o);if(c.length===0)return null;for(let l of c)r.push(`if (${l} instanceof Error) return ${l};`);for(let[l,p]of Object.entries(o)){let f=u.has(l),d=`${s}${e}.${l}`,m=Pn(l,p);if(m){let y=p.kind;f?r.push(`if (${m}) return __tjs.typeError('${d}', '${y}', ${l});`):r.push(`if (${l} !== undefined && ${m}) return __tjs.typeError('${d}', '${y}', ${l});`)}}return r.length===0?null:(r.unshift(`__tjs.pushStack('${a}');`),{preamble:r.join(`
354
+ `),suffix:"__tjs.popStack();"})}let i=Object.entries(t.params);if(i.length===0)return null;for(let[o]of i)r.push(`if (${o} instanceof Error) return ${o};`);for(let[o,u]of i){let c=`${s}${e}.${o}`;u.type.kind==="array"&&r.push(`if (Array.isArray(${o})) { for (const __i of ${o}) { if (__i instanceof Error && __i.path !== undefined) return __i } }`);let l=Pn(o,u.type);if(l){let p=u.type.kind==="union"?u.type.members.map(f=>f.kind).join(" | "):u.type.kind;u.required?r.push(`if (${l}) return __tjs.typeError('${c}', '${p}', ${o});`):r.push(`if (${o} !== undefined && ${l}) return __tjs.typeError('${c}', '${p}', ${o});`)}if(u.type.kind==="function"){let p=ec(o,u.type,c);p&&(r.push(p),r.push(`if (${o} instanceof Error) return ${o};`))}}return r.length===0?null:(r.unshift(`__tjs.pushStack('${a}');`),{preamble:r.join(`
355
+ `),suffix:"__tjs.popStack();"})}function aa(e){let t="",n=0;for(let r=0;r<e.length;r++){let s=e[r];if(s==="{"||s==="["||s==="(")n++,t+=s;else if(s==="}"||s==="]"||s===")")n--,t+=s;else if(s==="'"||s==='"'||s==="`"){for(t+=s,r++;r<e.length&&e[r]!==s;)e[r]==="\\"&&(t+=e[r++]),t+=e[r++];r<e.length&&(t+=e[r])}else n===1&&s==="="&&e[r-1]!=="!"&&e[r+1]!=="="?t+=":":t+=s}return t}function Hu(e,t){let r=new RegExp(`function\\s+${t}\\s*\\([^)]*\\)\\s*(:[?!]?)\\s*`,"g").exec(e);if(!r)return null;let s=e.slice(r.index+r[0].length);return $n(s)}function Ku(e,t){let r=new RegExp(`function\\s+${t}\\s*\\([^)]*\\)\\s*:([?!]?)`,"g").exec(e);if(!r)return;let s=r[1];if(s==="?")return"safe";if(s==="!")return"unsafe"}function Zu(e){let t=e.match(/^\/\*\s*tjs\s*<-\s*([^*]+?)\s*\*\//);return t?t[1].trim():void 0}function Qu(e,t){let n=new RegExp(`\\/\\*\\s*line\\s+(\\d+)\\s*\\*\\/\\s*(?:async\\s+)?function\\s+${t}\\s*\\(`,"m"),r=e.match(n);return r?parseInt(r[1],10):void 0}function jn(e,t={}){let{filename:n="<source>",runTests:r=!0,debug:s=!1,resolvedImports:a={}}=t,i=[];e=ar(e);let u=Zu(e)||n,{code:c,tests:l,mocks:p,testRunner:f}=lr(e),{ast:d,originalSource:m,requiredParams:y,unsafeFunctions:x}=tt(c,{filename:n,colonShorthand:!0,dialect:t.dialect,moduleLoader:t.moduleLoader}),S=Yu(d),E=bn(c,{dialect:t.dialect,moduleLoader:t.moduleLoader,filename:n});for(let A of E.predicates)A.verified||i.push(`${A.kind} '${A.name}': predicate is not verifiable, compiled as a plain function (not fuel-bounded, not safe on untrusted data)${A.reason?` \u2014 ${A.reason.replace(/\s+/g," ").trim()}`:""}`);let _=E.predicates.length?E.predicates:void 0;for(let A of l)A.body=Rt(A.body),E.tjsModes.tjsEquals&&(A.body=Mt(A.body)),E.tjsModes.tjsStandard&&(A.body=Gr(A.body));for(let A of p)A.body=Rt(A.body),E.tjsModes.tjsEquals&&(A.body=Mt(A.body)),E.tjsModes.tjsStandard&&(A.body=Gr(A.body));let b={},v=[],w=[];for(let A of S){let W=A.id?.name||"anonymous",V=Hu(c,W),ve;if(V&&V.includes("="))try{let re=V.matchAll(/(\w+)\s*=\s*/g),le=aa(V),Oe=new Function(`return ${le}`)(),fe={};for(let Dn of re){let kt=Dn[1];kt in Oe&&(fe[kt]=Oe[kt])}Object.keys(fe).length>0&&(ve=fe)}catch{}let{types:Me,warnings:ma}=zu(A,m,y,V,c);i.push(...ma),b[W]=Me;for(let re of A.params)if(re.type==="AssignmentPattern"&&re.left.type==="Identifier"&&re.right.type==="Identifier"){let le=re.left.name,Oe=re.right.name,fe=b[Oe];if(fe&&Me.params[le]){let Dn=Object.entries(fe.params).map(([_a,wa])=>({name:_a,type:wa.type})),kt=fe.returns??{kind:"any"};Me.params[le].type={kind:"function",params:Dn,returns:kt}}}for(let re of A.params)if(re.type==="AssignmentPattern"){let le=re.left?.name||re.left?.value,Oe=le?Me.params[le]:null;if(Oe?.required&&Oe.default===null)w.push({start:re.left.end,end:re.right.end});else{let fe=re.right;fe.type==="BinaryExpression"&&fe.operator==="|"&&w.push({start:fe.left.end,end:fe.end})}}let Yr=E.moduleSafety==="none"||x.has(W),ga=E.safeFunctions.has(W),ya=Ku(c,W),ba=Qu(e,W),ft={file:u,line:ba??A.loc?.start.line??0,column:A.loc?.start.column??0},xa={unsafe:Yr,safe:ga,returnSafety:ya},Xr=E.polymorphicNames.has(W),Bn;if(Xr){let re=[];for(let Oe of S){let fe=Oe.id?.name||"";fe.startsWith(W+"$")&&re.push(fe)}let le={polymorphic:!0,variants:re};ft&&(le.source=`${ft.file}:${ft.line}`),Bn=`${W}.__tjs = ${JSON.stringify(le,null,2)}`}else Bn=Xu(W,Me,xa,{debug:s,source:ft,returnDefaults:ve});if(v.push({position:A.end,text:`
356
+ ${Bn}`}),!Yr&&!Xr){let re=`${ft.file}:${ft.line}`,le=Gu(W,Me,re);le&&A.body&&A.body.start!==void 0&&(v.push({position:A.body.start+1,text:`
353
357
  ${le.preamble}
354
- `}),le.suffix&&_.push({position:A.body.end-1,text:`
358
+ `}),le.suffix&&v.push({position:A.body.end-1,text:`
355
359
  ${le.suffix}
356
- `}))}}if(S.tjsModes.tjsStandard){let A=Br(d,S.source);for(let W of A)v.push({start:W.start,end:W.end}),_.push({position:W.start,text:W.newText})}v.sort((A,W)=>W.start-A.start);let x=S.source;for(let{start:A,end:W}of v)x=x.slice(0,A)+x.slice(W);for(let A of _){let W=0;for(let V of v)V.start<A.position&&(W+=V.end-V.start);A.position-=W}_.sort((A,W)=>W.position-A.position);for(let{position:A,text:W}of _)x=x.slice(0,A)+W+x.slice(A);let E=x.includes("__tjs.typeError("),$=x.includes("__tjs.pushStack("),C=x.includes("Is("),I=x.includes("IsNot("),M=x.includes("Eq("),F=x.includes("NotEq("),N=x.includes("TypeOf("),U=/\bType\(/.test(x),J=/\bGeneric\(/.test(x),X=/\bFunctionPredicate\(/.test(x),ee=/\bEnum\(/.test(x),ce=/\bUnion\(/.test(x),ot=x.includes("__tjs.bang("),Gt=x.includes("__tjs.toBool("),jn=x.includes("__tjs.checkFnShape("),Ur=S.tjsModes.tjsSafeEval;if(E||$||C||I||M||F||N||U||J||X||ee||ce||ot||Gt||jn||Ur){let A=[];E&&A.push("class MonadicError extends Error{constructor(m,p,e,a,c,r){super(m);this.name='MonadicError';this.path=p;this.expected=e;this.actual=a;this.callStack=c;this.reason=r}}",`function typeError(p,e,v,r){const a=v===null?'null':typeof v;const m=r?'Expected '+e+" for '"+p+"': "+r:'Expected '+e+" for '"+p+"', got "+a;const err=new MonadicError(m,p,e,a,undefined,r);const c=globalThis.__tjs?.getConfig?.();if(c?.logTypeErrors)console.error('[TJS TypeError] '+err.message);if(c?.throwTypeErrors)throw err;return err}`,"function isMonadicError(v){return v instanceof Error&&v.name==='MonadicError'&&'path' in v}"),$&&A.push("const __stack=[];function pushStack(n){__stack.push(n)}function popStack(){__stack.pop()}function getStack(){return[...__stack]}"),M&&A.push("function Eq(a,b){if(a instanceof String||a instanceof Number||a instanceof Boolean)a=a.valueOf();if(b instanceof String||b instanceof Number||b instanceof Boolean)b=b.valueOf();if(a===b)return true;if(typeof a==='number'&&typeof b==='number'&&isNaN(a)&&isNaN(b))return true;if((a===null||a===undefined)&&(b===null||b===undefined))return true;return false}"),F&&A.push("function NotEq(a,b){return!Eq(a,b)}"),N&&A.push("function TypeOf(v){return v===null?'null':typeof v}"),C&&A.push("const tjsEquals=Symbol.for('tjs.equals');function Is(a,b){if(a!=null&&typeof a==='object'&&typeof a[tjsEquals]==='function')return a[tjsEquals](b);if(b!=null&&typeof b==='object'&&typeof b[tjsEquals]==='function')return b[tjsEquals](a);if(a!=null&&typeof a==='object'&&typeof a.Equals==='function')return a.Equals(b);if(b!=null&&typeof b==='object'&&typeof b.Equals==='function')return b.Equals(a);if(a instanceof String||a instanceof Number||a instanceof Boolean)a=a.valueOf();if(b instanceof String||b instanceof Number||b instanceof Boolean)b=b.valueOf();if(a===b)return true;if(typeof a==='number'&&typeof b==='number'&&isNaN(a)&&isNaN(b))return true;if((a==null)&&(b==null))return true;if(a==null||b==null)return false;if(typeof a!==typeof b)return false;if(typeof a!=='object')return false;if(a instanceof Set&&b instanceof Set){if(a.size!==b.size)return false;for(const v of a)if(!b.has(v))return false;return true}if(a instanceof Map&&b instanceof Map){if(a.size!==b.size)return false;for(const[k,v]of a)if(!b.has(k)||!Is(v,b.get(k)))return false;return true}if(a instanceof Date&&b instanceof Date)return a.getTime()===b.getTime();if(a instanceof RegExp&&b instanceof RegExp)return a.toString()===b.toString();if(Array.isArray(a)&&Array.isArray(b)){if(a.length!==b.length)return false;return a.every((v,i)=>Is(v,b[i]))}if(Array.isArray(a)!==Array.isArray(b))return false;const ka=Object.keys(a),kb=Object.keys(b);if(ka.length!==kb.length)return false;return ka.every(k=>Is(a[k],b[k]))}"),I&&A.push("function IsNot(a,b){return!Is(a,b)}"),U&&A.push("function Type(d,p,e){const t={description:d,__runtimeType:true};if(typeof p==='function'){t.check=p;t.default=e??null}else{const ex=e??p;t.default=ex;t.check=v=>{if(ex===null)return true;return typeof v===typeof ex}}return t}"),J&&A.push("function Generic(tp,pred,d){const f=(...args)=>{const t={description:d||'generic',__runtimeType:true,check:v=>pred(v,...args)};return t};f.__runtimeType=true;f.description=d;return f}"),X&&A.push("function FunctionPredicate(n,s,b){if(Array.isArray(s)&&b){const f=(...a)=>FunctionPredicate(n,b(...a));f.typeParamNames=s.map(p=>Array.isArray(p)?p[0]:p);f.description=n;f.__runtimeType=true;return f}const spec=typeof s==='function'?{}:s||{};return{description:n,params:spec.params||{},returns:spec.returns,returnContract:spec.returnContract||'assertReturns',check:v=>typeof v==='function',__runtimeType:true}}"),ee&&A.push("function Enum(d,m){const vals=typeof m==='object'?Object.values(m):[];return{description:d,check:v=>vals.includes(v),values:vals,__runtimeType:true}}"),ce&&A.push("function Union(d,...v){const vals=v.flat();return{description:d,check:x=>vals.includes(x),values:vals,__runtimeType:true}}"),Gt&&A.push("function toBool(v){if(v instanceof Boolean||v instanceof Number||v instanceof String)return Boolean(v.valueOf());return Boolean(v)}"),jn&&(E||A.push("class MonadicError extends Error{constructor(m,p,e,a,c,r){super(m);this.name='MonadicError';this.path=p;this.expected=e;this.actual=a;this.callStack=c;this.reason=r}}",`function typeError(p,e,v,r){const a=v===null?'null':typeof v;const m=r?'Expected '+e+" for '"+p+"': "+r:'Expected '+e+" for '"+p+"', got "+a;const err=new MonadicError(m,p,e,a,undefined,r);const c=globalThis.__tjs?.getConfig?.();if(c?.logTypeErrors)console.error('[TJS TypeError] '+err.message);if(c?.throwTypeErrors)throw err;return err}`,"function isMonadicError(v){return v instanceof Error&&v.name==='MonadicError'&&'path' in v}"),A.push(`function checkFnShape(fn,expectedParams,expectedReturn,path){if(typeof fn!=='function')return fn;const meta=fn.__tjs;if(!meta||!meta.params)return fn;const entries=Object.entries(meta.params);for(let i=0;i<expectedParams.length;i++){const e=expectedParams[i];if(e==='any')continue;const a=entries[i];if(!a)continue;const ak=a[1]&&a[1].type&&a[1].type.kind;if(!ak||ak==='any')continue;if(ak!==e)return new MonadicError("Expected (...arg"+i+": "+e+", ...) for '"+path+"', but callback declares arg"+i+" as "+ak,path+"(arg"+i+")",e,ak)}if(expectedReturn!=='any'&&meta.returns){const ar=(meta.returns.type&&meta.returns.type.kind)||meta.returns.kind;if(ar&&ar!=='any'&&ar!==expectedReturn)return new MonadicError("Expected callback returning "+expectedReturn+" for '"+path+"', but callback returns "+ar,path+"(return)",expectedReturn,ar)}return fn}`)),ot&&(E||A.push("class MonadicError extends Error{constructor(m,p,e,a,c,r){super(m);this.name='MonadicError';this.path=p;this.expected=e;this.actual=a;this.callStack=c;this.reason=r}}",`function typeError(p,e,v,r){const a=v===null?'null':typeof v;const m=r?'Expected '+e+" for '"+p+"': "+r:'Expected '+e+" for '"+p+"', got "+a;const err=new MonadicError(m,p,e,a,undefined,r);const c=globalThis.__tjs?.getConfig?.();if(c?.logTypeErrors)console.error('[TJS TypeError] '+err.message);if(c?.throwTypeErrors)throw err;return err}`,"function isMonadicError(v){return v instanceof Error&&v.name==='MonadicError'&&'path' in v}"),A.push("function bang(o,p){if(o===null||o===undefined)return typeError('bang.'+p,'non-null',o);if(isMonadicError(o))return o;return o[p]}"));let W=A.length>0?A.join(`;
360
+ `}))}}if(E.tjsModes.tjsStandard){let A=zr(d,E.source);for(let W of A)w.push({start:W.start,end:W.end}),v.push({position:W.start,text:W.newText})}w.sort((A,W)=>W.start-A.start);let k=E.source;for(let{start:A,end:W}of w)k=k.slice(0,A)+k.slice(W);for(let A of v){let W=0;for(let V of w)V.start<A.position&&(W+=V.end-V.start);A.position-=W}v.sort((A,W)=>W.position-A.position);for(let{position:A,text:W}of v)k=k.slice(0,A)+W+k.slice(A);let T=k.includes("__tjs.typeError("),C=k.includes("__tjs.pushStack("),N=k.includes("Is("),P=k.includes("IsNot("),D=k.includes("Eq("),R=k.includes("NotEq("),U=k.includes("TypeOf("),J=/\bType\(/.test(k),X=/\bGeneric\(/.test(k),ee=/\bFunctionPredicate\(/.test(k),ce=/\bEnum\(/.test(k),lt=/\bUnion\(/.test(k),Zt=k.includes("__tjs.bang("),Mn=k.includes("__tjs.toBool("),On=k.includes("__tjs.checkFnShape("),Zr=E.tjsModes.tjsSafeEval;if(T||C||N||P||D||R||U||J||X||ee||ce||lt||Zt||Mn||On||Zr){let A=[];T&&A.push("class MonadicError extends Error{constructor(m,p,e,a,c,r){super(m);this.name='MonadicError';this.path=p;this.expected=e;this.actual=a;this.callStack=c;this.reason=r}}",`function typeError(p,e,v,r){const a=v===null?'null':typeof v;const m=r?'Expected '+e+" for '"+p+"': "+r:'Expected '+e+" for '"+p+"', got "+a;const err=new MonadicError(m,p,e,a,undefined,r);const c=globalThis.__tjs?.getConfig?.();if(c?.logTypeErrors)console.error('[TJS TypeError] '+err.message);if(c?.throwTypeErrors)throw err;return err}`,"function isMonadicError(v){return v instanceof Error&&v.name==='MonadicError'&&'path' in v}"),C&&A.push("const __stack=[];function pushStack(n){__stack.push(n)}function popStack(){__stack.pop()}function getStack(){return[...__stack]}"),D&&A.push("function Eq(a,b){if(a instanceof String||a instanceof Number||a instanceof Boolean)a=a.valueOf();if(b instanceof String||b instanceof Number||b instanceof Boolean)b=b.valueOf();if(a===b)return true;if(typeof a==='number'&&typeof b==='number'&&isNaN(a)&&isNaN(b))return true;if((a===null||a===undefined)&&(b===null||b===undefined))return true;return false}"),R&&A.push("function NotEq(a,b){return!Eq(a,b)}"),U&&A.push("function TypeOf(v){return v===null?'null':typeof v}"),N&&A.push("const tjsEquals=Symbol.for('tjs.equals');function Is(a,b){if(a!=null&&typeof a==='object'&&typeof a[tjsEquals]==='function')return a[tjsEquals](b);if(b!=null&&typeof b==='object'&&typeof b[tjsEquals]==='function')return b[tjsEquals](a);if(a!=null&&typeof a==='object'&&typeof a.Equals==='function')return a.Equals(b);if(b!=null&&typeof b==='object'&&typeof b.Equals==='function')return b.Equals(a);if(a instanceof String||a instanceof Number||a instanceof Boolean)a=a.valueOf();if(b instanceof String||b instanceof Number||b instanceof Boolean)b=b.valueOf();if(a===b)return true;if(typeof a==='number'&&typeof b==='number'&&isNaN(a)&&isNaN(b))return true;if((a==null)&&(b==null))return true;if(a==null||b==null)return false;if(typeof a!==typeof b)return false;if(typeof a!=='object')return false;if(a instanceof Set&&b instanceof Set){if(a.size!==b.size)return false;for(const v of a)if(!b.has(v))return false;return true}if(a instanceof Map&&b instanceof Map){if(a.size!==b.size)return false;for(const[k,v]of a)if(!b.has(k)||!Is(v,b.get(k)))return false;return true}if(a instanceof Date&&b instanceof Date)return a.getTime()===b.getTime();if(a instanceof RegExp&&b instanceof RegExp)return a.toString()===b.toString();if(Array.isArray(a)&&Array.isArray(b)){if(a.length!==b.length)return false;return a.every((v,i)=>Is(v,b[i]))}if(Array.isArray(a)!==Array.isArray(b))return false;const ka=Object.keys(a),kb=Object.keys(b);if(ka.length!==kb.length)return false;return ka.every(k=>Is(a[k],b[k]))}"),P&&A.push("function IsNot(a,b){return!Is(a,b)}"),J&&A.push("function Type(d,p,e){const t={description:d,__runtimeType:true};if(typeof p==='function'){t.check=p;t.default=e??null}else{const ex=e??p;t.default=ex;t.check=v=>{if(ex===null)return true;return typeof v===typeof ex}}return t}"),X&&A.push("function Generic(tp,pred,d){const f=(...args)=>{const t={description:d||'generic',__runtimeType:true,check:v=>pred(v,...args)};return t};f.__runtimeType=true;f.description=d;return f}"),ee&&A.push("function FunctionPredicate(n,s,b){if(Array.isArray(s)&&b){const f=(...a)=>FunctionPredicate(n,b(...a));f.typeParamNames=s.map(p=>Array.isArray(p)?p[0]:p);f.description=n;f.__runtimeType=true;return f}const spec=typeof s==='function'?{}:s||{};return{description:n,params:spec.params||{},returns:spec.returns,returnContract:spec.returnContract||'assertReturns',check:v=>typeof v==='function',__runtimeType:true}}"),ce&&A.push("function Enum(d,m){const vals=typeof m==='object'?Object.values(m):[];return{description:d,check:v=>vals.includes(v),values:vals,__runtimeType:true}}"),lt&&A.push("function Union(d,...v){const vals=v.flat();return{description:d,check:x=>vals.includes(x),values:vals,__runtimeType:true}}"),Mn&&A.push("function toBool(v){if(v instanceof Boolean||v instanceof Number||v instanceof String)return Boolean(v.valueOf());return Boolean(v)}"),On&&(T||A.push("class MonadicError extends Error{constructor(m,p,e,a,c,r){super(m);this.name='MonadicError';this.path=p;this.expected=e;this.actual=a;this.callStack=c;this.reason=r}}",`function typeError(p,e,v,r){const a=v===null?'null':typeof v;const m=r?'Expected '+e+" for '"+p+"': "+r:'Expected '+e+" for '"+p+"', got "+a;const err=new MonadicError(m,p,e,a,undefined,r);const c=globalThis.__tjs?.getConfig?.();if(c?.logTypeErrors)console.error('[TJS TypeError] '+err.message);if(c?.throwTypeErrors)throw err;return err}`,"function isMonadicError(v){return v instanceof Error&&v.name==='MonadicError'&&'path' in v}"),A.push(`function checkFnShape(fn,expectedParams,expectedReturn,path){if(typeof fn!=='function')return fn;const meta=fn.__tjs;if(!meta||!meta.params)return fn;const entries=Object.entries(meta.params);for(let i=0;i<expectedParams.length;i++){const e=expectedParams[i];if(e==='any')continue;const a=entries[i];if(!a)continue;const ak=a[1]&&a[1].type&&a[1].type.kind;if(!ak||ak==='any')continue;if(ak!==e)return new MonadicError("Expected (...arg"+i+": "+e+", ...) for '"+path+"', but callback declares arg"+i+" as "+ak,path+"(arg"+i+")",e,ak)}if(expectedReturn!=='any'&&meta.returns){const ar=(meta.returns.type&&meta.returns.type.kind)||meta.returns.kind;if(ar&&ar!=='any'&&ar!==expectedReturn)return new MonadicError("Expected callback returning "+expectedReturn+" for '"+path+"', but callback returns "+ar,path+"(return)",expectedReturn,ar)}return fn}`)),Zt&&(T||A.push("class MonadicError extends Error{constructor(m,p,e,a,c,r){super(m);this.name='MonadicError';this.path=p;this.expected=e;this.actual=a;this.callStack=c;this.reason=r}}",`function typeError(p,e,v,r){const a=v===null?'null':typeof v;const m=r?'Expected '+e+" for '"+p+"': "+r:'Expected '+e+" for '"+p+"', got "+a;const err=new MonadicError(m,p,e,a,undefined,r);const c=globalThis.__tjs?.getConfig?.();if(c?.logTypeErrors)console.error('[TJS TypeError] '+err.message);if(c?.throwTypeErrors)throw err;return err}`,"function isMonadicError(v){return v instanceof Error&&v.name==='MonadicError'&&'path' in v}"),A.push("function bang(o,p){if(o===null||o===undefined)return typeError('bang.'+p,'non-null',o);if(isMonadicError(o))return o;return o[p]}"));let W=A.length>0?A.join(`;
357
361
  `)+`;
358
- `:"",V=[];E&&V.push("typeError","isMonadicError"),$&&V.push("pushStack","popStack","getStack"),M&&V.push("Eq"),F&&V.push("NotEq"),N&&V.push("TypeOf"),C&&V.push("Is","tjsEquals"),I&&V.push("IsNot"),U&&V.push("Type"),J&&V.push("Generic"),X&&V.push("FunctionPredicate"),ee&&V.push("Enum"),ce&&V.push("Union"),Gt&&V.push("toBool"),jn&&(V.push("checkFnShape"),E||V.push("typeError","isMonadicError")),ot&&(V.push("bang"),E||V.push("typeError","isMonadicError"));let ve=V.length>0?`{${V.join(",")}}`:"undefined";x=W+`const __tjs = globalThis.__tjs?.createRuntime?.() ?? ${ve};
359
- `+x}Ur&&(x=`import { Eval, SafeFunction } from 'tjs-lang';
360
- `+x);let _t;if(r){let A=Li(e);_t=Vi(l,p,A,x,a,S.extensions);let W=_t.filter(V=>!V.passed&&!V.inconclusive);if(W.length>0&&r===!0){let V=W.map(ve=>{if(ve.isSignatureTest)return` Function signature example is inconsistent:
362
+ `:"",V=[];T&&V.push("typeError","isMonadicError"),C&&V.push("pushStack","popStack","getStack"),D&&V.push("Eq"),R&&V.push("NotEq"),U&&V.push("TypeOf"),N&&V.push("Is","tjsEquals"),P&&V.push("IsNot"),J&&V.push("Type"),X&&V.push("Generic"),ee&&V.push("FunctionPredicate"),ce&&V.push("Enum"),lt&&V.push("Union"),Mn&&V.push("toBool"),On&&(V.push("checkFnShape"),T||V.push("typeError","isMonadicError")),Zt&&(V.push("bang"),T||V.push("typeError","isMonadicError"));let ve=V.length>0?`{${V.join(",")}}`:"undefined";k=W+`const __tjs = globalThis.__tjs?.createRuntime?.() ?? ${ve};
363
+ `+k}Zr&&(k=`import { Eval, SafeFunction } from 'tjs-lang';
364
+ `+k);let vt;if(r){let A=Yi(e);vt=Xi(l,p,A,k,a,E.extensions);let W=vt.filter(V=>!V.passed&&!V.inconclusive);if(W.length>0&&r===!0){let V=W.map(ve=>{if(ve.isSignatureTest)return` Function signature example is inconsistent:
361
365
  ${ve.error}`;let Me=ve.line?` (line ${ve.line})`:"";return` Test '${ve.description}'${Me} failed:
362
366
  ${ve.error}`});throw new Error(`Transpile-time test failures:
363
367
  ${V.join(`
364
- `)}`)}}if(r==="only")return{code:"",types:b,metadata:b,testResults:_t,testCount:_t?.length};let Wr;if(S.wasmBlocks.length>0){let A=Ji(S.wasmBlocks);A.code&&(x=A.code+`
365
- `+x),Wr=A.results}return{code:x,types:b,metadata:b,warnings:i.length>0?i:void 0,testRunner:l.length>0?f:void 0,testCount:l.length>0?l.length:void 0,testResults:_t,wasmCompiled:Wr}}function Nu(e){let t=[];for(let n of e.body)n.type==="FunctionDeclaration"?t.push(n):(n.type==="ExportNamedDeclaration"&&n.declaration?.type==="FunctionDeclaration"||n.type==="ExportDefaultDeclaration"&&n.declaration?.type==="FunctionDeclaration")&&t.push(n.declaration);return t}function Wt(e){let t={kind:e.kind};return e.nullable&&(t.nullable=!0),e.items&&(t.items=Wt(e.items)),e.shape&&(t.shape=Object.fromEntries(Object.entries(e.shape).map(([n,r])=>[n,Wt(r)]))),e.members&&(t.members=e.members.map(Wt)),t}function Ru(e,t,n={},r={}){let s={};for(let[i,o]of Object.entries(t.params))s[i]={type:Wt(o.type),required:o.required},o.default!==void 0&&(s[i].default=o.default),o.description&&(s[i].description=o.description);let a={params:s};if(t.returns&&(a.returns={type:Wt(t.returns)},r.returnDefaults&&(a.returns.defaults=r.returnDefaults),n.returnSafety==="safe"?a.safeReturn=!0:n.returnSafety==="unsafe"&&(a.unsafeReturn=!0)),t.description&&(a.description=t.description),n.unsafe&&(a.unsafe=!0),n.safe&&(a.safe=!0),r.source){let{file:i,line:o}=r.source;a.source=`${i}:${o}`}return`${e}.__tjs = ${JSON.stringify(a,null,2)}`}function kn(e,t){let n;switch(t.kind){case"string":n=`typeof ${e} !== 'string'`;break;case"number":n=`typeof ${e} !== 'number'`;break;case"integer":n=`(typeof ${e} !== 'number' || !Number.isInteger(${e}))`;break;case"non-negative-integer":n=`(typeof ${e} !== 'number' || !Number.isInteger(${e}) || ${e} < 0)`;break;case"boolean":n=`typeof ${e} !== 'boolean'`;break;case"null":return`${e} !== null`;case"undefined":return`${e} !== undefined`;case"array":{let r=t.items&&t.items.kind!=="any"?kn("__a",t.items):null;r?n=`(!Array.isArray(${e}) || ${e}.some(__a => ${r}))`:n=`!Array.isArray(${e})`;break}case"object":n=`(typeof ${e} !== 'object' || ${e} === null || Array.isArray(${e}))`;break;case"function":n=`typeof ${e} !== 'function'`;break;case"union":{let r=t.members.map(s=>kn(e,s)).filter(s=>s!==null);if(r.length===0)return null;n=`(${r.join(" && ")})`;break}case"any":return null;default:return null}return n&&t.nullable&&(n=`(${e} !== null && ${n})`),n}var Gi=new Set(["string","number","integer","non-negative-integer","boolean","function","any","undefined","null","object"]);function Mu(e,t,n){let r=t.params??[],s=t.returns??{kind:"any"},a=r.map(c=>c.type?.kind),i=a.every(c=>c&&Gi.has(c))&&Gi.has(s.kind),o=a.some(c=>c!=="any")||s.kind!=="any";if(!i||!o)return null;let u=JSON.stringify(a);return`if (typeof ${e} === 'function') ${e} = __tjs.checkFnShape(${e}, ${u}, '${s.kind}', '${n}');`}function $n(e,t={}){let{ast:n,returnType:r,originalSource:s,requiredParams:a}=Qe(e,{filename:t.filename,colonShorthand:!0,vmTarget:!0}),{entry:i,helpers:o}=ci(n,t.filename),{ast:u,signature:c,warnings:l}=Xn(i,s,r,t,a,o.size>0?o:void 0);return{ast:u,signature:c,warnings:l}}function Ou(e,...t){if(typeof e=="string")return $n(e).ast;let n=e.reduce((r,s,a)=>r+s+(t[a]!==void 0?String(t[a]):""),"");return $n(n).ast}function Bu(e,t,n){let{ast:r,signature:s}=$n(e),a=async i=>(await t.run(r,i,n)).result;return a.signature=s,a.ast=r,a}function Tn(e){switch(e.kind){case"string":return{type:"string"};case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"null":return{type:"null"};case"array":return{type:"array",items:e.items?Tn(e.items):{}};case"object":return e.shape?{type:"object",properties:Object.fromEntries(Object.entries(e.shape).map(([t,n])=>[t,Tn(n)]))}:{type:"object"};case"union":return e.members?{anyOf:e.members.map(Tn)}:{};default:return{}}}function Fu(e){return Object.entries(e).map(([t,n])=>{let r=n.signature,s={},a=[];for(let[i,o]of Object.entries(r.parameters))s[i]=Tn(o.type),o.description&&(s[i].description=o.description),o.required&&a.push(i);return{type:"function",function:{name:t,description:r.description,parameters:{type:"object",properties:s,required:a}}}})}function Du(e,t,...n){if(typeof e=="string")return En(e,t);let r=t!==void 0?[t,...n]:n,s=e.reduce((a,i,o)=>a+i+(r[o]!==void 0?String(r[o]):""),"");return En(s)}var Lu=/\.[mc]?js$/i,Vu=/\.[mc]?ts$/i,qu=/\.tjs$/i;function Ki(e){return qu.test(e)?"tjs":Lu.test(e)?"js":Vu.test(e)?"ts":"tjs"}function Uu(e){return Ki(e)==="js"?"js":"tjs"}function $e(e,t,n,r,s){n||(n=T),(function a(i,o,u){var c=u||i.type;n[c](i,o,a),t[c]&&t[c](i,o)})(e,r,s)}function Zi(e,t,n,r,s){var a=[];n||(n=T),(function i(o,u,c){var l=c||o.type,p=o!==a[a.length-1];p&&a.push(o),n[l](o,u,i),t[l]&&t[l](o,u||a,a),p&&a.pop()})(e,r,s)}function Dr(e,t,n){n(e,t)}function at(e,t,n){}var T={};T.Program=T.BlockStatement=T.StaticBlock=function(e,t,n){for(var r=0,s=e.body;r<s.length;r+=1){var a=s[r];n(a,t,"Statement")}};T.Statement=Dr;T.EmptyStatement=at;T.ExpressionStatement=T.ParenthesizedExpression=T.ChainExpression=function(e,t,n){return n(e.expression,t,"Expression")};T.IfStatement=function(e,t,n){n(e.test,t,"Expression"),n(e.consequent,t,"Statement"),e.alternate&&n(e.alternate,t,"Statement")};T.LabeledStatement=function(e,t,n){return n(e.body,t,"Statement")};T.BreakStatement=T.ContinueStatement=at;T.WithStatement=function(e,t,n){n(e.object,t,"Expression"),n(e.body,t,"Statement")};T.SwitchStatement=function(e,t,n){n(e.discriminant,t,"Expression");for(var r=0,s=e.cases;r<s.length;r+=1){var a=s[r];n(a,t)}};T.SwitchCase=function(e,t,n){e.test&&n(e.test,t,"Expression");for(var r=0,s=e.consequent;r<s.length;r+=1){var a=s[r];n(a,t,"Statement")}};T.ReturnStatement=T.YieldExpression=T.AwaitExpression=function(e,t,n){e.argument&&n(e.argument,t,"Expression")};T.ThrowStatement=T.SpreadElement=function(e,t,n){return n(e.argument,t,"Expression")};T.TryStatement=function(e,t,n){n(e.block,t,"Statement"),e.handler&&n(e.handler,t),e.finalizer&&n(e.finalizer,t,"Statement")};T.CatchClause=function(e,t,n){e.param&&n(e.param,t,"Pattern"),n(e.body,t,"Statement")};T.WhileStatement=T.DoWhileStatement=function(e,t,n){n(e.test,t,"Expression"),n(e.body,t,"Statement")};T.ForStatement=function(e,t,n){e.init&&n(e.init,t,"ForInit"),e.test&&n(e.test,t,"Expression"),e.update&&n(e.update,t,"Expression"),n(e.body,t,"Statement")};T.ForInStatement=T.ForOfStatement=function(e,t,n){n(e.left,t,"ForInit"),n(e.right,t,"Expression"),n(e.body,t,"Statement")};T.ForInit=function(e,t,n){e.type==="VariableDeclaration"?n(e,t):n(e,t,"Expression")};T.DebuggerStatement=at;T.FunctionDeclaration=function(e,t,n){return n(e,t,"Function")};T.VariableDeclaration=function(e,t,n){for(var r=0,s=e.declarations;r<s.length;r+=1){var a=s[r];n(a,t)}};T.VariableDeclarator=function(e,t,n){n(e.id,t,"Pattern"),e.init&&n(e.init,t,"Expression")};T.Function=function(e,t,n){e.id&&n(e.id,t,"Pattern");for(var r=0,s=e.params;r<s.length;r+=1){var a=s[r];n(a,t,"Pattern")}n(e.body,t,e.expression?"Expression":"Statement")};T.Pattern=function(e,t,n){e.type==="Identifier"?n(e,t,"VariablePattern"):e.type==="MemberExpression"?n(e,t,"MemberPattern"):n(e,t)};T.VariablePattern=at;T.MemberPattern=Dr;T.RestElement=function(e,t,n){return n(e.argument,t,"Pattern")};T.ArrayPattern=function(e,t,n){for(var r=0,s=e.elements;r<s.length;r+=1){var a=s[r];a&&n(a,t,"Pattern")}};T.ObjectPattern=function(e,t,n){for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];a.type==="Property"?(a.computed&&n(a.key,t,"Expression"),n(a.value,t,"Pattern")):a.type==="RestElement"&&n(a.argument,t,"Pattern")}};T.Expression=Dr;T.ThisExpression=T.Super=T.MetaProperty=at;T.ArrayExpression=function(e,t,n){for(var r=0,s=e.elements;r<s.length;r+=1){var a=s[r];a&&n(a,t,"Expression")}};T.ObjectExpression=function(e,t,n){for(var r=0,s=e.properties;r<s.length;r+=1){var a=s[r];n(a,t)}};T.FunctionExpression=T.ArrowFunctionExpression=T.FunctionDeclaration;T.SequenceExpression=function(e,t,n){for(var r=0,s=e.expressions;r<s.length;r+=1){var a=s[r];n(a,t,"Expression")}};T.TemplateLiteral=function(e,t,n){for(var r=0,s=e.quasis;r<s.length;r+=1){var a=s[r];n(a,t)}for(var i=0,o=e.expressions;i<o.length;i+=1){var u=o[i];n(u,t,"Expression")}};T.TemplateElement=at;T.UnaryExpression=T.UpdateExpression=function(e,t,n){n(e.argument,t,"Expression")};T.BinaryExpression=T.LogicalExpression=function(e,t,n){n(e.left,t,"Expression"),n(e.right,t,"Expression")};T.AssignmentExpression=T.AssignmentPattern=function(e,t,n){n(e.left,t,"Pattern"),n(e.right,t,"Expression")};T.ConditionalExpression=function(e,t,n){n(e.test,t,"Expression"),n(e.consequent,t,"Expression"),n(e.alternate,t,"Expression")};T.NewExpression=T.CallExpression=function(e,t,n){if(n(e.callee,t,"Expression"),e.arguments)for(var r=0,s=e.arguments;r<s.length;r+=1){var a=s[r];n(a,t,"Expression")}};T.MemberExpression=function(e,t,n){n(e.object,t,"Expression"),e.computed&&n(e.property,t,"Expression")};T.ExportNamedDeclaration=T.ExportDefaultDeclaration=function(e,t,n){e.declaration&&n(e.declaration,t,e.type==="ExportNamedDeclaration"||e.declaration.id?"Statement":"Expression"),e.source&&n(e.source,t,"Expression")};T.ExportAllDeclaration=function(e,t,n){e.exported&&n(e.exported,t),n(e.source,t,"Expression")};T.ImportDeclaration=function(e,t,n){for(var r=0,s=e.specifiers;r<s.length;r+=1){var a=s[r];n(a,t)}n(e.source,t,"Expression")};T.ImportExpression=function(e,t,n){n(e.source,t,"Expression")};T.ImportSpecifier=T.ImportDefaultSpecifier=T.ImportNamespaceSpecifier=T.Identifier=T.PrivateIdentifier=T.Literal=at;T.TaggedTemplateExpression=function(e,t,n){n(e.tag,t,"Expression"),n(e.quasi,t,"Expression")};T.ClassDeclaration=T.ClassExpression=function(e,t,n){return n(e,t,"Class")};T.Class=function(e,t,n){e.id&&n(e.id,t,"Pattern"),e.superClass&&n(e.superClass,t,"Expression"),n(e.body,t)};T.ClassBody=function(e,t,n){for(var r=0,s=e.body;r<s.length;r+=1){var a=s[r];n(a,t)}};T.MethodDefinition=T.PropertyDefinition=T.Property=function(e,t,n){e.computed&&n(e.key,t,"Expression"),e.value&&n(e.value,t,"Expression")};var Wu=new Set(["parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","String","Number","Boolean","Array","Object"]),Ju=new Set(["Math","JSON","Object","Array","String","Number"]),zu=new Set(["Math.random","Date.now"]),Gu=new Set(["startsWith","endsWith","includes","indexOf","lastIndexOf","slice","substring","substr","toLowerCase","toUpperCase","trim","trimStart","trimEnd","split","replace","replaceAll","match","matchAll","charAt","charCodeAt","codePointAt","padStart","padEnd","repeat","concat","at","normalize","search","localeCompare","every","some","map","filter","reduce","reduceRight","find","findIndex","findLast","findLastIndex","flat","flatMap","join","keys","entries","values","forEach","test","exec","toFixed","toPrecision","toString","valueOf","hasOwnProperty"]),Lr=["fetch","XMLHttpRequest","WebSocket","Date","console","setTimeout","setInterval","requestAnimationFrame","queueMicrotask","localStorage","sessionStorage","indexedDB","document","window","globalThis","self","process","require","eval","Function","import","crypto","performance","navigator"];function Hu(e){let t=new Set(Lr);for(let[n,r]of Object.entries(e))r?.effects==="io"&&t.add(r.op??n);return t}function zt(e,t={}){let n=t.effectful??new Set(Lr),r;try{r=je(e,{ecmaVersion:"latest",locations:!0})}catch(i){return{safe:!1,predicates:[],diagnostics:[{predicate:"<source>",message:`parse error: ${i.message}`,line:i.loc?.line??0,column:i.loc?.column??0}]}}let s=new Set(t.knownPredicates??[]);for(let i of r.body)i.type==="FunctionDeclaration"&&i.id&&s.add(i.id.name);let a=[];for(let i of r.body){if(i.type!=="FunctionDeclaration"||!i.id)continue;let o=i.id.name,u=(l,p)=>a.push({predicate:o,message:l,line:p?.loc?.start?.line??0,column:p?.loc?.start?.column??0}),c=l=>u("loops are not allowed \u2014 iterate with recursion or array methods (every/some/map/filter/reduce) so work stays fuel-bounded",l);$e(i,{AwaitExpression(l){u("`await` not allowed \u2014 predicates must be synchronous",l)},NewExpression(l){u("`new` not allowed in a predicate (non-pure construction)",l)},WhileStatement:c,DoWhileStatement:c,ForStatement:c,ForInStatement:c,ForOfStatement:c,CallExpression(l){let p=l.callee;if(p.type==="Identifier"){let f=p.name;n.has(f)?u(`'${f}' is effectful \u2014 not allowed in a predicate`,p):s.has(f)||Wu.has(f)||u(`unknown reference '${f}' \u2014 not a predicate or pure builtin`,p);return}if(p.type==="MemberExpression"&&!p.computed){let f=p.property.name,d=p.object;d.type==="Identifier"&&n.has(d.name)?u(`'${d.name}.${f}' is effectful`,p):d.type==="Identifier"&&Ju.has(d.name)?zu.has(`${d.name}.${f}`)&&u(`'${d.name}.${f}' is nondeterministic`,p):Gu.has(f)||u(`method '.${f}()' is not a known pure method`,p.property);return}u("unsupported call form in a predicate",p)}})}return{safe:a.length===0,predicates:[...s],diagnostics:a}}function Yi(e){return e.map(t=>` ${t.predicate} (${t.line}:${t.column}): ${t.message}`).join(`
366
- `)}var Cn=e=>e&&e.type==="Literal"&&typeof e.value=="string";function Ku(e,t={}){let n;try{n=je(e,{ecmaVersion:"latest"})}catch{return[]}let r=new Set,s=new Set;$e(n,{BinaryExpression(u){(u.operator==="=="||u.operator==="===")&&(Cn(u.left)&&r.add(u.left.value),Cn(u.right)&&r.add(u.right.value))},ArrayExpression(u){for(let c of u.elements)Cn(c)&&r.add(c.value)},CallExpression(u){let c=u.callee;if(c.type!=="MemberExpression"||c.computed)return;let l=c.property.name,p=u.arguments[0];Cn(p)&&l==="startsWith"&&s.add(p.value)}});let a=null;if(t.validate!==!1){let u=zt(e,t);if(u.safe&&u.predicates.length){let c=t.entry??u.predicates[u.predicates.length-1];try{let p=An(e,[c],t)[c];a=f=>{try{return p(f)===!0}catch{return!1}}}catch{a=null}}}let i=[];for(let u of r)(!a||a(u))&&i.push({value:u,kind:"value"});for(let u of s)i.push({value:u,kind:"stub"});let o=i;if(t.prefix){let u=t.prefix;o=i.filter(c=>c.value.startsWith(u)||c.kind==="stub"&&u.startsWith(c.value))}return o.sort((u,c)=>(u.kind===c.kind?0:u.kind==="value"?-1:1)||u.value.localeCompare(c.value)),t.limit?o.slice(0,t.limit):o}var Jt=class extends Error{constructor(t){super(`predicate exceeded its fuel budget (${t})`),this.name="PredicateFuelExhausted"}};function Zu(e){let t=je(e,{ecmaVersion:"latest"}),n=[],r=a=>n.push([a.body.start+1,"__fuel();"]);$e(t,{FunctionDeclaration:r,FunctionExpression:r,ArrowFunctionExpression(a){a.body.type==="BlockStatement"?n.push([a.body.start+1,"__fuel();"]):(n.push([a.body.start,"(__fuel(), "]),n.push([a.body.end,")"]))}}),n.sort((a,i)=>i[0]-a[0]);let s=e;for(let[a,i]of n)s=s.slice(0,a)+i+s.slice(a);return s}function An(e,t,n={}){let r=zt(e,n);if(!r.safe)throw new Error(`Not predicate-safe:
367
- ${Yi(r.diagnostics)}`);let s=n.fuel??1e6,a=Zu(e),i=Lr.filter(f=>f!=="import"&&f!=="eval"&&f!=="arguments"),o=new Function("__fuel",...i,`"use strict";
368
- ${a}
369
- ;return { ${t.join(", ")} };`),u=0,l=o(()=>{if(--u<0)throw new Jt(s)},...i.map(()=>{})),p={};for(let f of t){let d=l[f];p[f]=(...g)=>{u=s;try{return d(...g)}catch(y){throw y instanceof RangeError&&/stack/i.test(y.message)?new Jt(s):y}}}return p}var Xi=e=>e===null?"null":Array.isArray(e)?"array":typeof e;function Qu(e,t){return t==="integer"?typeof e=="number"&&Number.isInteger(e):Xi(e)===t}function ea(e,t={}){let{ignorePredicates:n,...r}=t,s=new Map,a=o=>{if(o.$predicate&&!n&&!s.has(o.$predicate)){let u=o.$predicate,c=zt(u,r).predicates,l=c[c.length-1];if(!l)throw new Error("$predicate must declare at least one function");let p=An(u,[l],r);s.set(u,p[l])}if(o.properties)for(let u of Object.values(o.properties))a(u);o.items&&a(o.items)};a(e);let i=(o,u,c,l)=>{if(o.type&&!Qu(u,o.type)){l.push({path:c||"/",message:`expected ${o.type}, got ${Xi(u)}`});return}if(o.type==="object"&&o.properties&&u&&typeof u=="object"){let p=u;for(let f of o.required??[])f in p||l.push({path:`${c}/${f}`,message:`missing required '${f}'`});for(let[f,d]of Object.entries(o.properties))f in p&&i(d,p[f],`${c}/${f}`,l)}o.type==="array"&&o.items&&Array.isArray(u)&&u.forEach((p,f)=>i(o.items,p,`${c}/${f}`,l)),o.$predicate&&!n&&(s.get(o.$predicate)(u)||l.push({path:c||"/",message:`failed predicate at ${c||"/"}`}))};return o=>{let u=[];return i(e,o,"",u),{valid:u.length===0,errors:u}}}function Yu(e,t,n){return ea(e,n)(t)}function ta(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}function Pn(e){return ye.infer(e)}function Vr(e){return Pn(e)}Vr.type=ta;Vr.infer=Pn;var Xu=new Proxy(Vr,{get(e,t){return t==="type"?ta:t==="infer"?Pn:ye[t]},apply(e,t,n){return Pn(n[0])}});var ec={unusedVariables:!0,undefinedVariables:!0,unreachableCode:!0,noExplicitNew:!0};function tc(e,t={}){let n={...ec,...t},r=[],s,a=new Map,i;try{let l=Qe(e,{filename:n.filename,colonShorthand:!0});s=l.ast,a=l.letAnnotations,i=l.tjsModes.tjsSafeAssign}catch(l){return{diagnostics:[{severity:"error",message:l.message,line:l.loc?.line,column:l.loc?.column,rule:"parse-error"}],valid:!1}}let o=n.safeAssign!==void 0?n.safeAssign:i,u=n.strict?"error":"warning",c=[na()];if(Zi(s,{FunctionDeclaration(l,p,f){let d=na();c.push(d);for(let g of l.params)nc(d,g,"parameter");l.id&&(c[c.length-2]||c[0]).declarations.set(l.id.name,{node:l.id,kind:"function",used:!1})},VariableDeclaration(l){let p=c[c.length-1];for(let f of l.declarations)f.id.type==="Identifier"&&p.declarations.set(f.id.name,{node:f.id,kind:l.kind,used:!1})}}),$e(s,{Identifier(l){for(let p=c.length-1;p>=0;p--){let f=c[p].declarations.get(l.name);if(f){f.used=!0;break}}}}),n.unusedVariables)for(let l of c)for(let[p,f]of l.declarations)p.startsWith("_")||!f.used&&f.kind!=="function"&&r.push({severity:"warning",message:`'${p}' is declared but never used`,line:f.node.loc?.start?.line,column:f.node.loc?.start?.column,rule:"no-unused-vars"});if(n.unreachableCode&&$e(s,{BlockStatement(l){let p=!1;for(let f of l.body){if(p){r.push({severity:"warning",message:"Unreachable code after return statement",line:f.loc?.start?.line,column:f.loc?.start?.column,rule:"no-unreachable"});break}f.type==="ReturnStatement"&&(p=!0)}}}),o){let l=new Set;$e(s,{VariableDeclaration(p){if(p.kind==="let")for(let f of p.declarations){if(f.id.type!=="Identifier")continue;let d=f.id.name,g=a.has(d),y=f.init;(g||y&&!qr(y))&&l.add(d)}}}),$e(s,{VariableDeclaration(p){if(p.kind==="let")for(let f of p.declarations){if(f.id.type!=="Identifier")continue;let d=f.id.name;a.has(d)||(f.init?qr(f.init)&&r.push({severity:u,message:`'let ${d}' is initialized to ${ra(f.init)} with no type annotation. Annotate (let ${d}: <example>) to record the intended type.`,line:f.loc?.start?.line,column:f.loc?.start?.column,rule:"safe-assign-let-needs-type"}):r.push({severity:u,message:`'let ${d}' has no initializer or type annotation. Add an initializer (let ${d} = ...) or annotate (let ${d}: <example>).`,line:f.loc?.start?.line,column:f.loc?.start?.column,rule:"safe-assign-let-needs-type"}))}}}),$e(s,{AssignmentExpression(p){if(p.operator!=="="||p.left.type!=="Identifier")return;let f=p.left.name;l.has(f)&&qr(p.right)&&r.push({severity:u,message:`Cannot assign ${ra(p.right)} to typed let '${f}'.`,line:p.loc?.start?.line,column:p.loc?.start?.column,rule:"safe-assign-no-nullish"})}})}return n.noExplicitNew&&$e(s,{NewExpression(l){let p="class";l.callee.type==="Identifier"?p=l.callee.name:l.callee.type==="MemberExpression"&&l.callee.property.type==="Identifier"&&(p=l.callee.property.name),r.push({severity:"warning",message:`Unnecessary 'new' keyword. In TJS, classes are callable without 'new': ${p}(...) instead of new ${p}(...)`,line:l.loc?.start?.line,column:l.loc?.start?.column,rule:"no-explicit-new"})}}),{diagnostics:r,valid:r.filter(l=>l.severity==="error").length===0}}function na(){return{declarations:new Map}}function qr(e){return e?e.type==="Identifier"&&e.name==="undefined"||e.type==="Literal"&&e.value===null||e.type==="UnaryExpression"&&e.operator==="void":!1}function ra(e){return e.type==="Identifier"?"undefined":e.type==="Literal"&&e.value===null?"null":e.type==="UnaryExpression"&&e.operator==="void"?"void <expr> (undefined)":"a nullish value"}function nc(e,t,n){t.type==="Identifier"?e.declarations.set(t.name,{node:t,kind:n,used:!1}):t.type==="AssignmentPattern"&&t.left.type==="Identifier"&&e.declarations.set(t.left.name,{node:t.left,kind:n,used:!1})}export{Jt as PredicateFuelExhausted,Xu as Schema,Ve as TJS_VERSION,Ou as ajs,mi as assertFunction,rt as checkType,An as compilePredicate,ea as compilePredicateSchema,Bu as createAgent,Uu as dialectForFilename,Hu as effectfulFromAtoms,Ko as emitRuntimeWrapper,Re as error,gi as expectFunction,Ie as extractLiteralValue,Nt as extractTDoc,tr as extractTests,Yi as formatPredicateDiagnostics,Fu as getToolDefinitions,ue as inferTypeFromValue,Ar as installRuntime,qe as isError,tc as lint,Qe as parse,Ge as parseParameter,li as parseReturnType,hn as preprocess,et as runtime,Ki as sourceKindForFilename,Ku as suggest,Io as testUtils,Du as tjs,Xn as transformFunction,$n as transpile,En as transpileToJS,yt as typeOf,Yn as typeToString,$r as validateArgs,Yu as validatePredicateSchema,zt as verifyPredicate,Cr as wrap};
368
+ `)}`)}}if(r==="only")return{code:"",types:b,metadata:b,testResults:vt,testCount:vt?.length,predicates:_};let Qr;if(E.wasmBlocks.length>0){let A=ra(E.wasmBlocks);A.code&&(k=A.code+`
369
+ `+k),Qr=A.results}return{code:k,types:b,metadata:b,warnings:i.length>0?i:void 0,predicates:_,testRunner:l.length>0?f:void 0,testCount:l.length>0?l.length:void 0,testResults:vt,wasmCompiled:Qr}}function Yu(e){let t=[];for(let n of e.body)n.type==="FunctionDeclaration"?t.push(n):(n.type==="ExportNamedDeclaration"&&n.declaration?.type==="FunctionDeclaration"||n.type==="ExportDefaultDeclaration"&&n.declaration?.type==="FunctionDeclaration")&&t.push(n.declaration);return t}function Kt(e){let t={kind:e.kind};return e.nullable&&(t.nullable=!0),e.items&&(t.items=Kt(e.items)),e.shape&&(t.shape=Object.fromEntries(Object.entries(e.shape).map(([n,r])=>[n,Kt(r)]))),e.members&&(t.members=e.members.map(Kt)),t}function Xu(e,t,n={},r={}){let s={};for(let[i,o]of Object.entries(t.params))s[i]={type:Kt(o.type),required:o.required},o.default!==void 0&&(s[i].default=o.default),o.description&&(s[i].description=o.description);let a={params:s};if(t.returns&&(a.returns={type:Kt(t.returns)},r.returnDefaults&&(a.returns.defaults=r.returnDefaults),n.returnSafety==="safe"?a.safeReturn=!0:n.returnSafety==="unsafe"&&(a.unsafeReturn=!0)),t.description&&(a.description=t.description),n.unsafe&&(a.unsafe=!0),n.safe&&(a.safe=!0),r.source){let{file:i,line:o}=r.source;a.source=`${i}:${o}`}return`${e}.__tjs = ${JSON.stringify(a,null,2)}`}function Pn(e,t){let n;switch(t.kind){case"string":n=`typeof ${e} !== 'string'`;break;case"number":n=`typeof ${e} !== 'number'`;break;case"integer":n=`(typeof ${e} !== 'number' || !Number.isInteger(${e}))`;break;case"non-negative-integer":n=`(typeof ${e} !== 'number' || !Number.isInteger(${e}) || ${e} < 0)`;break;case"boolean":n=`typeof ${e} !== 'boolean'`;break;case"null":return`${e} !== null`;case"undefined":return`${e} !== undefined`;case"array":{let r=t.items&&t.items.kind!=="any"?Pn("__a",t.items):null;r?n=`(!Array.isArray(${e}) || ${e}.some(__a => ${r}))`:n=`!Array.isArray(${e})`;break}case"object":n=`(typeof ${e} !== 'object' || ${e} === null || Array.isArray(${e}))`;break;case"function":n=`typeof ${e} !== 'function'`;break;case"union":{let r=t.members.map(s=>Pn(e,s)).filter(s=>s!==null);if(r.length===0)return null;n=`(${r.join(" && ")})`;break}case"any":return null;default:return null}return n&&t.nullable&&(n=`(${e} !== null && ${n})`),n}var ia=new Set(["string","number","integer","non-negative-integer","boolean","function","any","undefined","null","object"]);function ec(e,t,n){let r=t.params??[],s=t.returns??{kind:"any"},a=r.map(c=>c.type?.kind),i=a.every(c=>c&&ia.has(c))&&ia.has(s.kind),o=a.some(c=>c!=="any")||s.kind!=="any";if(!i||!o)return null;let u=JSON.stringify(a);return`if (typeof ${e} === 'function') ${e} = __tjs.checkFnShape(${e}, ${u}, '${s.kind}', '${n}');`}function Nn(e,t={}){let{ast:n,returnType:r,originalSource:s,requiredParams:a}=tt(e,{filename:t.filename,colonShorthand:!0,vmTarget:!0}),{entry:i,helpers:o}=_i(n,t.filename),{ast:u,signature:c,warnings:l}=ur(i,s,r,t,a,o.size>0?o:void 0);return{ast:u,signature:c,warnings:l}}function tc(e,...t){if(typeof e=="string")return Nn(e).ast;let n=e.reduce((r,s,a)=>r+s+(t[a]!==void 0?String(t[a]):""),"");return Nn(n).ast}function nc(e,t,n){let{ast:r,signature:s}=Nn(e),a=async i=>(await t.run(r,i,n)).result;return a.signature=s,a.ast=r,a}function In(e){switch(e.kind){case"string":return{type:"string"};case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"null":return{type:"null"};case"array":return{type:"array",items:e.items?In(e.items):{}};case"object":return e.shape?{type:"object",properties:Object.fromEntries(Object.entries(e.shape).map(([t,n])=>[t,In(n)]))}:{type:"object"};case"union":return e.members?{anyOf:e.members.map(In)}:{};default:return{}}}function rc(e){return Object.entries(e).map(([t,n])=>{let r=n.signature,s={},a=[];for(let[i,o]of Object.entries(r.parameters))s[i]=In(o.type),o.description&&(s[i].description=o.description),o.required&&a.push(i);return{type:"function",function:{name:t,description:r.description,parameters:{type:"object",properties:s,required:a}}}})}function sc(e,t,...n){if(typeof e=="string")return jn(e,t);let r=t!==void 0?[t,...n]:n,s=e.reduce((a,i,o)=>a+i+(r[o]!==void 0?String(r[o]):""),"");return jn(s)}var ic=/\.[mc]?js$/i,ac=/\.[mc]?ts$/i,oc=/\.tjs$/i;function oa(e){return oc.test(e)?"tjs":ic.test(e)?"js":ac.test(e)?"ts":"tjs"}function uc(e){return oa(e)==="js"?"js":"tjs"}var ua=e=>e===null?"null":Array.isArray(e)?"array":typeof e;function cc(e,t){return t==="integer"?typeof e=="number"&&Number.isInteger(e):ua(e)===t}function ca(e,t={}){let{ignorePredicates:n,...r}=t,s=new Map,a=o=>{if(o.$predicate&&!n&&!s.has(o.$predicate)){let u=o.$predicate,c=et(u,r).predicates,l=c[c.length-1];if(!l)throw new Error("$predicate must declare at least one function");let p=It(u,[l],r);s.set(u,p[l])}if(o.properties)for(let u of Object.values(o.properties))a(u);o.items&&a(o.items)};a(e);let i=(o,u,c,l)=>{if(o.type&&!cc(u,o.type)){l.push({path:c||"/",message:`expected ${o.type}, got ${ua(u)}`});return}if(o.type==="object"&&o.properties&&u&&typeof u=="object"){let p=u;for(let f of o.required??[])f in p||l.push({path:`${c}/${f}`,message:`missing required '${f}'`});for(let[f,d]of Object.entries(o.properties))f in p&&i(d,p[f],`${c}/${f}`,l)}o.type==="array"&&o.items&&Array.isArray(u)&&u.forEach((p,f)=>i(o.items,p,`${c}/${f}`,l)),o.$predicate&&!n&&(s.get(o.$predicate)(u)||l.push({path:c||"/",message:`failed predicate at ${c||"/"}`}))};return o=>{let u=[];return i(e,o,"",u),{valid:u.length===0,errors:u}}}function lc(e,t,n){return ca(e,n)(t)}function Ze(e){let t;switch(e.kind){case"string":t="string";break;case"number":case"integer":case"non-negative-integer":t="number";break;case"boolean":t="boolean";break;case"null":return"null";case"undefined":return"undefined";case"any":t="any";break;case"array":if(e.items){let n=Ze(e.items);t=n.includes("|")?`(${n})[]`:`${n}[]`}else t="any[]";break;case"object":e.shape&&Object.keys(e.shape).length>0?t=`{ ${Object.entries(e.shape).map(([r,s])=>`${r}: ${Ze(s)}`).join("; ")} }`:t="Record<string, any>";break;case"union":if(e.members&&e.members.length>0)return e.members.map(Ze).join(" | ");t="any";break;case"function":{let n=e.params??[],r=e.returns?Ze(e.returns):"any";t=`(${n.map(a=>`${a.name}: ${Ze(a.type)}`).join(", ")}) => ${r}`;break}default:t="any"}return e.nullable?`${t} | null`:t}function fc(e,t,n,r){let s=Object.entries(t.params),a=new Array(s.length),i=!1;for(let l=s.length-1;l>=0;l--){let p=s[l][1],f=!p.required&&p.default!==void 0;a[l]=f&&!i,a[l]||(i=!0)}let o=s.map(([l,p],f)=>{let d=Ze(p.type);return a[f]?`${l}?: ${d}`:`${l}: ${d}`}).join(", "),u=t.returns?Ze(t.returns):"any";return`${n?r?"export default function":"export declare function":"declare function"} ${e}(${o}): ${u};`}function pc(e){let t=new Map,n,r=/^[ \t]*export\s+(default\s+)?function\s+(\w+)/gm;for(;(n=r.exec(e))!==null;)t.set(n[2],{exported:!0,isDefault:!!n[1]});let s=/^[ \t]*export\s+(default\s+)?class\s+(\w+)/gm;for(;(n=s.exec(e))!==null;)t.set(n[2],{exported:!0,isDefault:!!n[1]});let a=/^[ \t]*export\s+(default\s+)?(?:const|let|var)\s+(\w+)/gm;for(;(n=a.exec(e))!==null;)t.set(n[2],{exported:!0,isDefault:!!n[1]});let i=/^[ \t]*export\s+Type\s+(\w+)/gm;for(;(n=i.exec(e))!==null;)t.set(n[1],{exported:!0,isDefault:!1});let o=/^[ \t]*export\s+Generic\s+(\w+)/gm;for(;(n=o.exec(e))!==null;)t.set(n[1],{exported:!0,isDefault:!1});let u=/^[ \t]*export\s+FunctionPredicate\s+(\w+)/gm;for(;(n=u.exec(e))!==null;)t.set(n[1],{exported:!0,isDefault:!1});let c=/^[ \t]*export\s*\{([^}]+)\}/gm;for(;(n=c.exec(e))!==null;){let l=n[1].split(",").map(p=>p.trim().split(/\s+as\s+/));for(let p of l){let f=p.length>1?p[1]:p[0];f&&/^\w+$/.test(f)&&t.set(f,{exported:!0,isDefault:!1})}}return t}function hc(e){let t=new Map,n=/^[ \t]*(?:export\s+)?FunctionPredicate\s+(\w+)\s*(?:<([^>]+)>)?\s*\{/gm,r;for(;(r=n.exec(e))!==null;){let s=r[1],a=r[2],i=r.index+r[0].length-1,o=1,u=i+1;for(;u<e.length&&o>0;)e[u]==="{"?o++:e[u]==="}"&&o--,u++;let c=e.slice(i+1,u-1),l;a&&(l=a.split(",").map(y=>y.trim()));let p=[],f=c.match(/params\s*:\s*\{([^}]*)\}/);if(f){let y=f[1],x=fa(y);for(let S of x){let E=S.match(/^(\w+)\s*:\s*(.+)$/);E&&p.push({name:E[1],example:E[2].trim()})}}let d,m=c.match(/returns\s*:\s*(.+?)(?:\n|$)/);m&&(d=m[1].trim()),t.set(s,{params:p,returns:d,typeParams:l})}return t}function dc(e){let t=new Map,n=/^[ \t]*(?:export\s+(?:default\s+)?)?class\s+(\w+)(?:\s+extends\s+\w+)?\s*\{/gm,r;for(;(r=n.exec(e))!==null;){let s=r[1],a=r.index+r[0].length-1,i=1,o=a+1;for(;o<e.length&&i>0;)e[o]==="{"?i++:e[o]==="}"&&i--,o++;let u=e.slice(a+1,o-1),c=u.indexOf("constructor"),l="";if(c!==-1){let f=u.indexOf("(",c);if(f!==-1){let d=1,m=f+1;for(;m<u.length&&d>0;)u[m]==="("?d++:u[m]===")"&&d--,m++;l=u.slice(f+1,m-1).trim()}}let p=[];{let f=0,d=0;for(;f<u.length;){let m=u[f];if(m==="{"){d++,f++;continue}if(m==="}"){d--,f++;continue}if(d===0){let y=u.slice(f).match(/^(\w+)\s*\(/);if(y){let x=y[1];if(x==="constructor"||x==="get"||x==="set"){f+=x.length;continue}else{let S=f+y[0].length-1,E=1,_=S+1;for(;_<u.length&&E>0;)u[_]==="("?E++:u[_]===")"&&E--,_++;let b=u.slice(S+1,_-1).trim(),v=u.slice(_).match(/^\s*->\s*(.+?)\s*\{/),w=v?v[1].trim():null;p.push({name:x,params:b,returnType:w}),f=_;continue}}}f++}}t.set(s,{name:s,constructorParams:l,methods:p})}return t}function fa(e){let t=[],n=0,r="";for(let s of e)s==="{"||s==="["||s==="("?n++:(s==="}"||s==="]"||s===")")&&n--,s===","&&n===0?(t.push(r.trim()),r=""):r+=s;return r.trim()&&t.push(r.trim()),t}function la(e){return e.trim()?fa(e).map(t=>{let n=t.match(/^(\w+)\s*:\s*(.+)$/);if(n){let s=n[1],a=Qe(n[2].trim());return`${s}: ${a}`}let r=t.match(/^(\w+)\s*=\s*(.+)$/);if(r){let s=r[1],a=Qe(r[2].trim());return`${s}?: ${a}`}return t.startsWith("{")?"options: any":`${t}: any`}).join(", "):""}function mc(e){let t=new Map,n,r=/^[ \t]*(?:export\s+)?Type\s+(\w+)\s*=\s*(.+)$/gm;for(;(n=r.exec(e))!==null;)t.set(n[1],n[2].trim());let s=/^[ \t]*(?:export\s+)?Type\s+(\w+)\s+([^{=].*)$/gm;for(;(n=s.exec(e))!==null;)t.has(n[1])||t.set(n[1],n[2].trim());let a=/^[ \t]*(?:export\s+)?Type\s+(\w+)\s*\{[^}]*example\s*:\s*(.+?)(?:\n|\s*[,}])/gm;for(;(n=a.exec(e))!==null;)t.set(n[1],n[2].trim());let i=/^[ \t]*(?:export\s+)?Type\s+(\w+)\s*\{[^}]*\/\/\s*TS:\s*(.+?)(?:\n|\s*\})/gm;for(;(n=i.exec(e))!==null;)t.has(n[1])||t.set(n[1],`__ts__:${n[2].trim()}`);let o=/^[ \t]*(?:export\s+)?Type\s+(\w+)\s*\{\s*\}/gm;for(;(n=o.exec(e))!==null;)t.has(n[1])||t.set(n[1],"");return t}function gc(e){let t=new Map,n=/^[ \t]*(?:export\s+)?Generic\s+(\w+)\s*<([^>]+)>\s*\{/gm,r;for(;(r=n.exec(e))!==null;){let s=r[1],a=r[2].split(",").map(f=>f.trim().split(/\s*=/)[0].trim()),i=r.index+r[0].length-1,o=1,u=i+1;for(;u<e.length&&o>0;)e[u]==="{"?o++:e[u]==="}"&&o--,u++;let c=e.slice(i+1,u-1),l,p=c.match(/\bdeclaration\s*\{/);if(p&&p.index!==void 0){let f=p.index+p[0].length-1,d=1,m=f+1;for(;m<c.length&&d>0;)c[m]==="{"?d++:c[m]==="}"&&d--,m++;l=c.slice(f+1,m-1).trim()}t.set(s,{typeParams:a,declaration:l})}return t}function yc(e){let t=[],n=/^[ \t]*export\s+(?:default\s+)?(const|let|var)\s+(\w+)\s*(?::\s*\w+\s*)?=\s*(.+)/gm,r;for(;(r=n.exec(e))!==null;){let s=r[3].trim();s.endsWith(";")&&(s=s.slice(0,-1).trim()),t.push({name:r[2],value:s,kind:r[1]})}return t}function bc(e){return/^['"]/.test(e)||e.startsWith("`")?"string":e==="true"||e==="false"?"boolean":/^[+-]?\d+(\.\d+)?$/.test(e)?"number":e.startsWith("Symbol(")||e.startsWith("Symbol.")?"symbol":e.startsWith("[")?"any[]":e.startsWith("new WeakMap")?"WeakMap<any, any>":e.startsWith("new Map")?"Map<any, any>":e.startsWith("new Set")?"Set<any>":e.startsWith("new ")?"any":e.startsWith("{")?"Record<string, any>":e==="null"?"null":e==="undefined"?"undefined":"any"}function xc(e,t,n={}){let r=[],s=pc(t),a=mc(t),i=dc(t),o=gc(t),u=s.size>0,c=new Set;for(let[f,d]of Object.entries(e.types)){if(f.includes("$"))continue;let m=s.get(f),y=u?!!m?.exported:!0,x=m?.isDefault??!1;y&&(d.description&&r.push(`/** ${d.description} */`),r.push(fc(f,d,!0,x)),c.add(f))}for(let[f,d]of i){if(c.has(f))continue;let m=s.get(f);if(!(u?!!m?.exported:!0))continue;let x=d.constructorParams?la(d.constructorParams):"";if(r.push(`export declare function ${f}(${x}): any;`),x||d.methods.length>0){r.push(`export declare class ${f} {`),d.constructorParams&&r.push(` constructor(${x});`);for(let S of d.methods){let E=S.params?la(S.params):"";r.push(` ${S.name}(${E}): any;`)}r.push("}")}c.add(f)}for(let[f,d]of a){if(c.has(f))continue;let m=s.get(f);if(!u||m?.exported){if(d.startsWith("__ts__:")){let x=d.slice(7);r.push(`export type ${f} = ${x};`)}else if(d==="")r.push(`export type ${f} = any;`);else{let x=Qe(d);r.push(`export declare const ${f}: { check(value: any): boolean; default: ${x}; (value: any): boolean; };`)}c.add(f)}}for(let[f,d]of o){if(c.has(f))continue;let m=s.get(f);if(!(u?!!m?.exported:!0))continue;let x=d.typeParams.length>0?`<${d.typeParams.join(", ")}>`:"";if(d.declaration){let S=d.declaration.trim(),E=S.match(/^\/\/\s*TS:\s*(.+)$/s);if(E)r.push(`export type ${f}${x} = ${E[1].trim()};`);else{let _=S.split(`
370
+ `).map(b=>b.trim()).filter(b=>b.length>0).map(b=>` ${b}`).join(`
371
+ `);r.push(`export interface ${f}${x} {
372
+ ${_}
373
+ }`)}}else r.push(`export declare function ${f}(...args: any[]): { check(value: any): boolean; (value: any): boolean; };`);c.add(f)}let l=hc(t);for(let[f,d]of l){if(c.has(f))continue;let m=s.get(f);if(!(u?!!m?.exported:!0))continue;let x=new Set(d.typeParams?.map(b=>b.split("=")[0].trim())??[]),S=d.typeParams?`<${d.typeParams.join(", ")}>`:"",E=d.params.map((b,v)=>{let w=v===d.params.length-1;if(b.example.startsWith("[")&&b.example.endsWith("]")&&w){let T=b.example.slice(1,-1).trim(),C=!T||T==="null"?"any":x.has(T)?T:Qe(T);return`...${b.name}: ${C}[]`}if(b.example.startsWith("[")&&b.example.endsWith("]")){let T=b.example.slice(1,-1).trim(),C=!T||T==="null"?"any":x.has(T)?T:Qe(T);return`${b.name}: ${C}[]`}let k=b.example==="null"?"any":x.has(b.example)?b.example:Qe(b.example);return`${b.name}: ${k}`}).join(", "),_=d.returns!==void 0?d.returns==="null"?"any":x.has(d.returns)?d.returns:Qe(d.returns):"void";r.push(`export type ${f}${S} = (${E}) => ${_};`),c.add(f)}let p=yc(t);for(let f of p){if(c.has(f.name))continue;let d=s.get(f.name);if(!(u?!!d?.exported:!0))continue;let y=bc(f.value);r.push(`export declare const ${f.name}: ${y};`),c.add(f.name)}if(n.moduleName){let f=r.map(d=>` ${d}`).join(`
374
+ `);return`declare module '${n.moduleName}' {
375
+ ${f}
376
+ }
377
+ `}return r.join(`
378
+ `)+`
379
+ `}function Qe(e){let t=e.trim();if(_c(t)){let n=wc(t).map(r=>Qe(r.trim()));return[...new Set(n)].join(" | ")}return/^['"]/.test(t)?"string":t==="true"||t==="false"?"boolean":t==="null"?"null":t==="undefined"?"undefined":/^[+-]?\d+\.\d+$/.test(t)||/^[+-]?\d+$/.test(t)?"number":t.startsWith("[")?"any[]":t.startsWith("{")?"Record<string, any>":"any"}function _c(e){let t=0,n=null;for(let r of e){if(n){r===n&&(n=null);continue}if(r==="'"||r==='"'||r==="`"){n=r;continue}if(r==="{"||r==="["||r==="(")t++;else if(r==="}"||r==="]"||r===")")t--;else if(r==="|"&&t===0)return!0}return!1}function wc(e){let t=[],n=0,r=null,s="";for(let a of e){if(r){s+=a,a===r&&(r=null);continue}if(a==="'"||a==='"'||a==="`"){r=a,s+=a;continue}a==="{"||a==="["||a==="("?n++:(a==="}"||a==="]"||a===")")&&n--,a==="|"&&n===0?(t.push(s),s=""):s+=a}return s&&t.push(s),t}function pa(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}function Rn(e){return ye.infer(e)}function Hr(e){return Rn(e)}Hr.type=pa;Hr.infer=Rn;var Sc=new Proxy(Hr,{get(e,t){return t==="type"?pa:t==="infer"?Rn:ye[t]},apply(e,t,n){return Rn(n[0])}});var vc={unusedVariables:!0,undefinedVariables:!0,unreachableCode:!0,noExplicitNew:!0};function kc(e,t={}){let n={...vc,...t},r=[],s,a=new Map,i;try{let l=tt(e,{filename:n.filename,colonShorthand:!0});s=l.ast,a=l.letAnnotations,i=l.tjsModes.tjsSafeAssign}catch(l){return{diagnostics:[{severity:"error",message:l.message,line:l.loc?.line,column:l.loc?.column,rule:"parse-error"}],valid:!1}}let o=n.safeAssign!==void 0?n.safeAssign:i,u=n.strict?"error":"warning",c=[ha()];if(Ls(s,{FunctionDeclaration(l,p,f){let d=ha();c.push(d);for(let m of l.params)Ec(d,m,"parameter");l.id&&(c[c.length-2]||c[0]).declarations.set(l.id.name,{node:l.id,kind:"function",used:!1})},VariableDeclaration(l){let p=c[c.length-1];for(let f of l.declarations)f.id.type==="Identifier"&&p.declarations.set(f.id.name,{node:f.id,kind:l.kind,used:!1})}}),Ee(s,{Identifier(l){for(let p=c.length-1;p>=0;p--){let f=c[p].declarations.get(l.name);if(f){f.used=!0;break}}}}),n.unusedVariables)for(let l of c)for(let[p,f]of l.declarations)p.startsWith("_")||!f.used&&f.kind!=="function"&&r.push({severity:"warning",message:`'${p}' is declared but never used`,line:f.node.loc?.start?.line,column:f.node.loc?.start?.column,rule:"no-unused-vars"});if(n.unreachableCode&&Ee(s,{BlockStatement(l){let p=!1;for(let f of l.body){if(p){r.push({severity:"warning",message:"Unreachable code after return statement",line:f.loc?.start?.line,column:f.loc?.start?.column,rule:"no-unreachable"});break}f.type==="ReturnStatement"&&(p=!0)}}}),o){let l=new Set;Ee(s,{VariableDeclaration(p){if(p.kind==="let")for(let f of p.declarations){if(f.id.type!=="Identifier")continue;let d=f.id.name,m=a.has(d),y=f.init;(m||y&&!Kr(y))&&l.add(d)}}}),Ee(s,{VariableDeclaration(p){if(p.kind==="let")for(let f of p.declarations){if(f.id.type!=="Identifier")continue;let d=f.id.name;a.has(d)||(f.init?Kr(f.init)&&r.push({severity:u,message:`'let ${d}' is initialized to ${da(f.init)} with no type annotation. Annotate (let ${d}: <example>) to record the intended type.`,line:f.loc?.start?.line,column:f.loc?.start?.column,rule:"safe-assign-let-needs-type"}):r.push({severity:u,message:`'let ${d}' has no initializer or type annotation. Add an initializer (let ${d} = ...) or annotate (let ${d}: <example>).`,line:f.loc?.start?.line,column:f.loc?.start?.column,rule:"safe-assign-let-needs-type"}))}}}),Ee(s,{AssignmentExpression(p){if(p.operator!=="="||p.left.type!=="Identifier")return;let f=p.left.name;l.has(f)&&Kr(p.right)&&r.push({severity:u,message:`Cannot assign ${da(p.right)} to typed let '${f}'.`,line:p.loc?.start?.line,column:p.loc?.start?.column,rule:"safe-assign-no-nullish"})}})}return n.noExplicitNew&&Ee(s,{NewExpression(l){let p="class";l.callee.type==="Identifier"?p=l.callee.name:l.callee.type==="MemberExpression"&&l.callee.property.type==="Identifier"&&(p=l.callee.property.name),r.push({severity:"warning",message:`Unnecessary 'new' keyword. In TJS, classes are callable without 'new': ${p}(...) instead of new ${p}(...)`,line:l.loc?.start?.line,column:l.loc?.start?.column,rule:"no-explicit-new"})}}),{diagnostics:r,valid:r.filter(l=>l.severity==="error").length===0}}function ha(){return{declarations:new Map}}function Kr(e){return e?e.type==="Identifier"&&e.name==="undefined"||e.type==="Literal"&&e.value===null||e.type==="UnaryExpression"&&e.operator==="void":!1}function da(e){return e.type==="Identifier"?"undefined":e.type==="Literal"&&e.value===null?"null":e.type==="UnaryExpression"&&e.operator==="void"?"void <expr> (undefined)":"a nullish value"}function Ec(e,t,n){t.type==="Identifier"?e.declarations.set(t.name,{node:t,kind:n,used:!1}):t.type==="AssignmentPattern"&&t.left.type==="Identifier"&&e.declarations.set(t.left.name,{node:t.left,kind:n,used:!1})}export{jt as PredicateFuelExhausted,Sc as Schema,Ve as TJS_VERSION,tc as ajs,Ti as assertFunction,ot as checkType,It as compilePredicate,ca as compilePredicateSchema,nc as createAgent,mo as createPredicateEvaluator,uc as dialectForFilename,po as effectfulFromAtoms,du as emitRuntimeWrapper,tr as emitVerifiedPredicate,Re as error,$i as expectFunction,Ie as extractLiteralValue,Dt as extractTDoc,lr as extractTests,fn as formatPredicateDiagnostics,xc as generateDTS,rc as getToolDefinitions,ue as inferTypeFromValue,Dr as installRuntime,qe as isError,kc as lint,tt as parse,Ge as parseParameter,wi as parseReturnType,bn as preprocess,st as runtime,oa as sourceKindForFilename,ho as suggest,Qo as testUtils,sc as tjs,ur as transformFunction,Nn as transpile,jn as transpileToJS,Ze as typeDescriptorToTS,_t as typeOf,or as typeToString,Or as validateArgs,lc as validatePredicateSchema,et as verifyPredicate,Br as wrap};
370
380
  //# sourceMappingURL=tjs-browser.js.map