@power-plant/schema 0.0.24 → 0.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/codegen.cjs +304 -11
- package/dist/codegen.mjs +300 -11
- package/dist/constants-B7xonHLD.cjs +128 -0
- package/dist/constants-COGt3eeW.mjs +87 -0
- package/dist/constants-COGt3eeW.mjs.map +1 -0
- package/dist/helpers-reqtcaa8.mjs +921 -0
- package/dist/helpers-reqtcaa8.mjs.map +1 -0
- package/dist/helpers-sXsSapgI.cjs +1269 -0
- package/dist/index.cjs +788 -11
- package/dist/index.d.cts.map +1 -1
- package/dist/index.mjs +706 -11
- package/dist/rolldown-runtime-C_NdSu1c.cjs +34 -0
- package/dist/storage/index.cjs +6 -1
- package/dist/storage/index.mjs +3 -1
- package/dist/storage-B8aDmNpv.cjs +934 -0
- package/dist/storage-C3BT2Xh-.mjs +917 -0
- package/dist/storage-C3BT2Xh-.mjs.map +1 -0
- package/dist/valibot.cjs +124 -1
- package/dist/valibot.mjs +119 -1
- package/dist/zod.cjs +150 -1
- package/dist/zod.mjs +143 -1
- package/package.json +6 -12
- package/dist/constants-CjTQhR-l.cjs +0 -1
- package/dist/constants-lk1mMbgx.mjs +0 -2
- package/dist/constants-lk1mMbgx.mjs.map +0 -1
- package/dist/helpers-DFeTcMSU.cjs +0 -1
- package/dist/helpers-Km2QO1Vz.mjs +0 -2
- package/dist/helpers-Km2QO1Vz.mjs.map +0 -1
- package/dist/rolldown-runtime-CMqjfN_6.cjs +0 -1
- package/dist/storage-BzCwRJIM.cjs +0 -1
- package/dist/storage-CwlNwPrn.mjs +0 -2
- package/dist/storage-CwlNwPrn.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,788 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
2
|
-
`)}`)}function we(e){return(0,c.existsSync)(e)}function Te(e,t){return!!(0,c.statSync)(t?(0,l.joinPaths)(t,e):e,{throwIfNoEntry:!1})?.isDirectory()}const Ee=(e,t=(0,f.cwd)(),n={})=>{let r=n?.ignoreCase??!0,i=n?.skipCwd??!1,a=n?.includeNameInResults??!1,o=t;i&&(o=(0,u.resolveParentPath)(t));let s=(0,d.toArray)(e);for(r&&(s=s.map(e=>e.toLowerCase()));;){let e=s.find(e=>(0,c.existsSync)((0,l.joinPaths)(o,e)));if(e)return a||Te((0,l.joinPaths)(o,e))?(0,l.joinPaths)(o,e):o;let t=(0,u.resolveParentPath)(o);if(t===o)return;o=t}};var De=30,Oe=0;function ke(e,t=[],n=[]){let r=e??process.cwd();if(n.some(e=>(0,c.existsSync)((0,p.join)(r,e)))||t.some(e=>(0,c.existsSync)((0,p.join)(r,e))))return r;if(r!==`/`&&Oe++<De)return ke((0,p.join)(r,`..`),t,n)}var Ae=/^[A-Za-z]:\//;function je(e=``){return e&&e.replace(/\\/g,`/`).replace(Ae,e=>e.toUpperCase())}var Me=/^[/\\]{2}/,Ne=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,Pe=/^[A-Za-z]:$/,Fe=function(e){if(!e||e.length===0)return`.`;e=je(e);let t=e?.match(Me),n=Le(e),r=e[e.length-1]===`/`;return e=Ie(e,!n),e.length===0?n?`/`:r?`./`:`.`:(r&&(e+=`/`),Pe.test(e)&&(e+=`/`),t?n?`//${e}`:`//./${e}`:n&&!Le(e)?`/${e}`:e)};function Ie(e,t){let n=``,r=0,i=-1,a=0,o=null;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else if(o===`/`)break;else o=`/`;if(o===`/`){if(i!==s-1&&a!==1)if(a===2){if(n.length<2||r!==2||n[n.length-1]!==`.`||n[n.length-2]!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}else if(n.length>0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/${e.slice(i+1,s)}`:n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}var Le=function(e){return Ne.test(e)},Re=`storm-workspace.json,storm-workspace.yaml,storm-workspace.yml,storm-workspace.js,storm-workspace.ts,.storm-workspace.json,.storm-workspace.yaml,.storm-workspace.yml,.storm-workspace.js,.storm-workspace.ts,lerna.json,nx.json,turbo.json,npm-workspace.json,yarn-workspace.json,pnpm-workspace.json,npm-workspace.yaml,yarn-workspace.yaml,pnpm-workspace.yaml,npm-workspace.yml,yarn-workspace.yml,pnpm-workspace.yml,npm-lock.json,yarn-lock.json,pnpm-lock.json,npm-lock.yaml,yarn-lock.yaml,pnpm-lock.yaml,npm-lock.yml,yarn-lock.yml,pnpm-lock.yml,bun.lockb,bun.lock,bunfig.toml`.split(`,`),ze=[`.storm-workspace`,`.nx`,`.git`,`.github`,`.vscode`,`.verdaccio`];function Be(e){return process.env.STORM_WORKSPACE_ROOT||process.env.NX_WORKSPACE_ROOT_PATH?Fe(process.env.STORM_WORKSPACE_ROOT??process.env.NX_WORKSPACE_ROOT_PATH):Fe(ke(e??process.cwd(),Re,ze))}const Ve=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,He=function(e){return Ve.test(e)};var Ue=[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,78,5,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,199,7,137,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,55,9,266,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,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],We=[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,7,25,39,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,5,57,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,24,43,261,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,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7381,42,31,98,114,8702,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,208,30,2,2,2,1,2,6,3,4,10,1,225,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,4381,3,5773,3,7472,16,621,2467,541,1507,4938,6,8489],Ge=`·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ--ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・`,Ke=`ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ`,qe={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`},Je=`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`,Ye={5:Je,"5module":Je+` export import`,6:Je+` const class extends export import super`},Xe=/^in(stanceof)?$/,Ze=RegExp(`[`+Ke+`]`),Qe=RegExp(`[`+Ke+Ge+`]`);function $e(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 y(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Ze.test(String.fromCharCode(e)):t!==!1&&$e(e,We)}function b(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&&Qe.test(String.fromCharCode(e)):t===!1?!1:$e(e,We)||$e(e,Ue)}var x=function(e,t){t===void 0&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null};function S(e,t){return new x(e,{beforeExpr:!0,binop:t})}var C={beforeExpr:!0},w={startsExpr:!0},et={};function T(e,t){return t===void 0&&(t={}),t.keyword=e,et[e]=new x(e,t)}var E={num:new x(`num`,w),regexp:new x(`regexp`,w),string:new x(`string`,w),name:new x(`name`,w),privateId:new x(`privateId`,w),eof:new x(`eof`),bracketL:new x(`[`,{beforeExpr:!0,startsExpr:!0}),bracketR:new x(`]`),braceL:new x(`{`,{beforeExpr:!0,startsExpr:!0}),braceR:new x(`}`),parenL:new x(`(`,{beforeExpr:!0,startsExpr:!0}),parenR:new x(`)`),comma:new x(`,`,C),semi:new x(`;`,C),colon:new x(`:`,C),dot:new x(`.`),question:new x(`?`,C),questionDot:new x(`?.`),arrow:new x(`=>`,C),template:new x(`template`),invalidTemplate:new x(`invalidTemplate`),ellipsis:new x(`...`,C),backQuote:new x("`",w),dollarBraceL:new x("${",{beforeExpr:!0,startsExpr:!0}),eq:new x(`=`,{beforeExpr:!0,isAssign:!0}),assign:new x(`_=`,{beforeExpr:!0,isAssign:!0}),incDec:new x(`++/--`,{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new x(`!/~`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:S(`||`,1),logicalAND:S(`&&`,2),bitwiseOR:S(`|`,3),bitwiseXOR:S(`^`,4),bitwiseAND:S(`&`,5),equality:S(`==/!=/===/!==`,6),relational:S(`</>/<=/>=`,7),bitShift:S(`<</>>/>>>`,8),plusMin:new x(`+/-`,{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:S(`%`,10),star:S(`*`,10),slash:S(`/`,10),starstar:new x(`**`,{beforeExpr:!0}),coalesce:S(`??`,1),_break:T(`break`),_case:T(`case`,C),_catch:T(`catch`),_continue:T(`continue`),_debugger:T(`debugger`),_default:T(`default`,C),_do:T(`do`,{isLoop:!0,beforeExpr:!0}),_else:T(`else`,C),_finally:T(`finally`),_for:T(`for`,{isLoop:!0}),_function:T(`function`,w),_if:T(`if`),_return:T(`return`,C),_switch:T(`switch`),_throw:T(`throw`,C),_try:T(`try`),_var:T(`var`),_const:T(`const`),_while:T(`while`,{isLoop:!0}),_with:T(`with`),_new:T(`new`,{beforeExpr:!0,startsExpr:!0}),_this:T(`this`,w),_super:T(`super`,w),_class:T(`class`,w),_extends:T(`extends`,C),_export:T(`export`),_import:T(`import`,w),_null:T(`null`,w),_true:T(`true`,w),_false:T(`false`,w),_in:T(`in`,{beforeExpr:!0,binop:7}),_instanceof:T(`instanceof`,{beforeExpr:!0,binop:7}),_typeof:T(`typeof`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:T(`void`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:T(`delete`,{beforeExpr:!0,prefix:!0,startsExpr:!0})},D=/\r\n?|\n|\u2028|\u2029/,tt=new RegExp(D.source,`g`);function O(e){return e===10||e===13||e===8232||e===8233}function nt(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var i=e.charCodeAt(r);if(O(i))return r<n-1&&i===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var rt=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,k=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,it=Object.prototype,at=it.hasOwnProperty,ot=it.toString,st=Object.hasOwn||(function(e,t){return at.call(e,t)}),ct=Array.isArray||(function(e){return ot.call(e)===`[object Array]`}),lt=Object.create(null);function A(e){return lt[e]||(lt[e]=RegExp(`^(?:`+e.replace(/ /g,`|`)+`)$`))}function j(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var ut=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,dt=function(e,t){this.line=e,this.column=t};dt.prototype.offset=function(e){return new dt(this.line,this.column+e)};var ft=function(e,t,n){this.start=t,this.end=n,e.sourceFile!==null&&(this.source=e.sourceFile)};function pt(e,t){for(var n=1,r=0;;){var i=nt(e,r,t);if(i<0)return new dt(n,t-r);++n,r=i}}var mt={ecmaVersion:null,sourceType:`script`,strict:!1,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},ht=!1;function gt(e){var t={};for(var n in mt)t[n]=e&&st(e,n)?e[n]:mt[n];if(t.ecmaVersion===`latest`?t.ecmaVersion=1e8:t.ecmaVersion==null?(!ht&&typeof console==`object`&&console.warn&&(ht=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
3
|
-
|
|
4
|
-
`,n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(D).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=E.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=e.sourceType===`module`,this.strict=this.inModule||e.strict===!0||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&&e.allowHashBang&&this.input.slice(0,2)===`#!`&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType===`commonjs`?N:M),this.regexpState=null,this.privateNameStack=[]},L={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};I.prototype.parse=function(){var e=this,t=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return e.parseTopLevel(t)})},L.inFunction.get=function(){return(this.currentVarScope().flags&N)>0},L.inGenerator.get=function(){return(this.currentVarScope().flags&yt)>0},L.inAsync.get=function(){return(this.currentVarScope().flags&vt)>0},L.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(P|wt))return!1;if(t&N)return(t&vt)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},L.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&M)},L.allowSuper.get=function(){return(this.currentThisScope().flags&St)>0||this.options.allowSuperOutsideMethod},L.allowDirectSuper.get=function(){return(this.currentThisScope().flags&Ct)>0},L.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},L.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(P|wt)||t&N&&!(t&bt))return!0}return!1},L.allowUsing.get=function(){var e=this.currentScope().flags;return!(e&Tt||!this.inModule&&e&M)},L.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&P)>0},I.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var n=this,r=0;r<e.length;r++)n=e[r](n);return n},I.parse=function(e,t){return new this(t,e).parse()},I.parseExpressionAt=function(e,t,n){var r=new this(n,e,t);return r.nextToken(),r.parseExpression()},I.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(I.prototype,L);var R=I.prototype,Nt=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;R.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){k.lastIndex=e,e+=k.exec(this.input)[0].length;var t=Nt.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])===`use strict`){k.lastIndex=e+t[0].length;var n=k.exec(this.input),r=n.index+n[0].length,i=this.input.charAt(r);return i===`;`||i===`}`||D.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||i===`!`&&this.input.charAt(r+1)===`=`)}e+=t[0].length,k.lastIndex=e,e+=k.exec(this.input)[0].length,this.input[e]===`;`&&e++}},R.eat=function(e){return this.type===e?(this.next(),!0):!1},R.isContextual=function(e){return this.type===E.name&&this.value===e&&!this.containsEsc},R.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1},R.catchStackOverflow=function(e){try{return e()}catch(e){if(e instanceof Error&&(/\bstack\b.*\b(exceeded|overflow)\b/i.test(e.message)||/\btoo much recursion\b/i.test(e.message)))this.raise(this.start,`Not enough stack space to parse input`);else throw e}},R.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},R.canInsertSemicolon=function(){return this.type===E.eof||this.type===E.braceR||D.test(this.input.slice(this.lastTokEnd,this.start))},R.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},R.semicolon=function(){!this.eat(E.semi)&&!this.insertSemicolon()&&this.unexpected()},R.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},R.expect=function(e){this.eat(e)||this.unexpected()},R.unexpected=function(e){this.raise(e??this.start,`Unexpected token`)};var Pt=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};R.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`)}},R.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`)},R.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`)},R.isSimpleAssignTarget=function(e){return e.type===`ParenthesizedExpression`?this.isSimpleAssignTarget(e.expression):e.type===`Identifier`||e.type===`MemberExpression`};var z=I.prototype;z.parseTopLevel=function(e){var t=Object.create(null);for(e.body||=[];this.type!==E.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var r=0,i=Object.keys(this.undefinedExports);r<i.length;r+=1){var a=i[r];this.raiseRecoverable(this.undefinedExports[a].start,`Export '`+a+`' is not defined`)}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType===`commonjs`?`script`:this.options.sourceType,this.finishNode(e,`Program`)};var Ft={kind:`loop`},It={kind:`switch`};z.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual(`let`))return!1;k.lastIndex=this.pos;var t=k.exec(this.input),n=this.pos+t[0].length,r=this.fullCharCodeAt(n);if(r===91||r===92)return!0;if(e)return!1;if(r===123)return!0;if(y(r)){var i=n;do n+=r<=65535?1:2;while(b(r=this.fullCharCodeAt(n)));if(r===92)return!0;var a=this.input.slice(i,n);if(!Xe.test(a))return!0}return!1},z.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual(`async`))return!1;k.lastIndex=this.pos;var e=k.exec(this.input),t=this.pos+e[0].length,n;return!D.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)===`function`&&(t+8===this.input.length||!(b(n=this.fullCharCodeAt(t+8))||n===92))},z.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?`await`:`using`))return!1;k.lastIndex=this.pos;var n=k.exec(this.input),r=this.pos+n[0].length;if(D.test(this.input.slice(this.pos,r)))return!1;if(e){var i=r+5,a;if(this.input.slice(r,i)!==`using`||i===this.input.length||b(a=this.fullCharCodeAt(i))||a===92)return!1;k.lastIndex=i;var o=k.exec(this.input);if(r=i+o[0].length,o&&D.test(this.input.slice(i,r)))return!1}var s=this.fullCharCodeAt(r);if(!y(s)&&s!==92)return!1;var c=r;do r+=s<=65535?1:2;while(b(s=this.fullCharCodeAt(r)));if(s===92)return!0;var l=this.input.slice(c,r);if(Xe.test(l))return!1;if(t&&!e&&l===`of`){k.lastIndex=r;var u=k.exec(this.input);if(r+=u[0].length,this.input.charCodeAt(r)!==61||(s=this.input.charCodeAt(r+1))===61||s===62)return!1}return!0},z.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},z.isUsing=function(e){return this.isUsingKeyword(!1,e)},z.parseStatement=function(e,t,n){var r=this.type,i=this.startNode(),a;switch(this.isLet(e)&&(r=E._var,a=`let`),r){case E._break:case E._continue:return this.parseBreakContinueStatement(i,r.keyword);case E._debugger:return this.parseDebuggerStatement(i);case E._do:return this.parseDoStatement(i);case E._for:return this.parseForStatement(i);case E._function:return e&&(this.strict||e!==`if`&&e!==`label`)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!e);case E._class:return e&&this.unexpected(),this.parseClass(i,!0);case E._if:return this.parseIfStatement(i);case E._return:return this.parseReturnStatement(i);case E._switch:return this.parseSwitchStatement(i);case E._throw:return this.parseThrowStatement(i);case E._try:return this.parseTryStatement(i);case E._const:case E._var:return a||=this.value,e&&a!==`var`&&this.unexpected(),this.parseVarStatement(i,a);case E._while:return this.parseWhileStatement(i);case E._with:return this.parseWithStatement(i);case E.braceL:return this.parseBlock(!0,i);case E.semi:return this.parseEmptyStatement(i);case E._export:case E._import:if(this.options.ecmaVersion>10&&r===E._import){k.lastIndex=this.pos;var o=k.exec(this.input),s=this.pos+o[0].length,c=this.input.charCodeAt(s);if(c===40||c===46)return this.parseExpressionStatement(i,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===E._import?this.parseImport(i):this.parseExport(i,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!0,!e);var l=this.isAwaitUsing(!1)?`await using`:this.isUsing(!1)?`using`:null;if(l)return this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),e&&this.raise(this.start,`Using declaration is not allowed in single-statement positions`),l===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.next(),this.parseVar(i,!1,l),this.semicolon(),this.finishNode(i,`VariableDeclaration`);var u=this.value,d=this.parseExpression();return r===E.name&&d.type===`Identifier`&&this.eat(E.colon)?this.parseLabeledStatement(i,u,d,e):this.parseExpressionStatement(i,d)}},z.parseBreakContinueStatement=function(e,t){var n=t===`break`;this.next(),this.eat(E.semi)||this.insertSemicolon()?e.label=null:this.type===E.name?(e.label=this.parseIdent(),this.semicolon()):this.unexpected();for(var r=0;r<this.labels.length;++r){var i=this.labels[r];if((e.label==null||i.name===e.label.name)&&(i.kind!=null&&(n||i.kind===`loop`)||e.label&&n))break}return r===this.labels.length&&this.raise(e.start,`Unsyntactic `+t),this.finishNode(e,n?`BreakStatement`:`ContinueStatement`)},z.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,`DebuggerStatement`)},z.parseDoStatement=function(e){return this.next(),this.labels.push(Ft),e.body=this.parseStatement(`do`),this.labels.pop(),this.expect(E._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(E.semi):this.semicolon(),this.finishNode(e,`DoWhileStatement`)},z.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual(`await`)?this.lastTokStart:-1;if(this.labels.push(Ft),this.enterScope(0),this.expect(E.parenL),this.type===E.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===E._var||this.type===E._const||n){var r=this.startNode(),i=n?`let`:this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,`VariableDeclaration`),this.parseForAfterInit(e,r,t)}var a=this.isContextual(`let`),o=!1,s=this.isUsing(!0)?`using`:this.isAwaitUsing(!0)?`await using`:null;if(s){var c=this.startNode();return this.next(),s===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.parseVar(c,!0,s),this.finishNode(c,`VariableDeclaration`),this.parseForAfterInit(e,c,t)}var l=this.containsEsc,u=new Pt,d=this.start,f=t>-1?this.parseExprSubscripts(u,`await`):this.parseExpression(!0,u);return this.type===E._in||(o=this.options.ecmaVersion>=6&&this.isContextual(`of`))?(t>-1?(this.type===E._in&&this.unexpected(t),e.await=!0):o&&this.options.ecmaVersion>=8&&(f.start===d&&!l&&f.type===`Identifier`&&f.name===`async`?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&o&&this.raise(f.start,`The left-hand side of a for-of loop may not start with 'let'.`),this.toAssignable(f,!1,u),this.checkLValPattern(f),this.parseForIn(e,f)):(this.checkExpressionErrors(u,!0),t>-1&&this.unexpected(t),this.parseFor(e,f))},z.parseForAfterInit=function(e,t,n){return(this.type===E._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))&&t.declarations.length===1?(this.type===E._in?((t.kind===`using`||t.kind===`await using`)&&!t.declarations[0].init&&this.raise(this.start,`Using declaration is not allowed in for-in loops`),this.options.ecmaVersion>=9&&n>-1&&this.unexpected(n)):this.options.ecmaVersion>=9&&(e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))},z.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,Rt|(n?0:zt),!1,t)},z.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(`if`),e.alternate=this.eat(E._else)?this.parseStatement(`if`):null,this.finishNode(e,`IfStatement`)},z.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,`'return' outside of function`),this.next(),this.eat(E.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,`ReturnStatement`)},z.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(E.braceL),this.labels.push(It),this.enterScope(Tt);for(var t,n=!1;this.type!==E.braceR;)if(this.type===E._case||this.type===E._default){var r=this.type===E._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(E.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`)},z.parseThrowStatement=function(e){return this.next(),D.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 Lt=[];z.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type===`Identifier`;return this.enterScope(t?xt:0),this.checkLValPattern(e,t?jt:F),this.expect(E.parenR),e},z.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===E._catch){var t=this.startNode();this.next(),this.eat(E.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(E._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,`Missing catch or finally clause`),this.finishNode(e,`TryStatement`)},z.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,`VariableDeclaration`)},z.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Ft),e.body=this.parseStatement(`while`),this.labels.pop(),this.finishNode(e,`WhileStatement`)},z.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`)},z.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,`EmptyStatement`)},z.parseLabeledStatement=function(e,t,n,r){for(var i=0,a=this.labels;i<a.length;i+=1)a[i].name===t&&this.raise(n.start,`Label '`+t+`' is already declared`);for(var o=this.type.isLoop?`loop`:this.type===E._switch?`switch`:null,s=this.labels.length-1;s>=0;s--){var c=this.labels[s];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`)},z.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,`ExpressionStatement`)},z.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(E.braceL),e&&this.enterScope(0);this.type!==E.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,`BlockStatement`)},z.parseFor=function(e,t){return e.init=t,this.expect(E.semi),e.test=this.type===E.semi?null:this.parseExpression(),this.expect(E.semi),e.update=this.type===E.parenR?null:this.parseExpression(),this.expect(E.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,`ForStatement`)},z.parseForIn=function(e,t){var n=this.type===E._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(E.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,n?`ForInStatement`:`ForOfStatement`)},z.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(E.eq)?i.init=this.parseMaybeAssign(t):!r&&n===`const`&&!(this.type===E._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))?this.unexpected():!r&&(n===`using`||n===`await using`)&&this.options.ecmaVersion>=17&&this.type!==E._in&&!this.isContextual(`of`)?this.raise(this.lastTokEnd,`Missing initializer in `+n+` declaration`):!r&&i.id.type!==`Identifier`&&!(t&&(this.type===E._in||this.isContextual(`of`)))?this.raise(this.lastTokEnd,`Complex binding patterns require an initialization value`):i.init=null,e.declarations.push(this.finishNode(i,`VariableDeclarator`)),!this.eat(E.comma))break}return e},z.parseVarId=function(e,t){e.id=t===`using`||t===`await using`?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t===`var`?kt:F,!1)};var Rt=1,zt=2,Bt=4;z.parseFunction=function(e,t,n,r,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===E.star&&t&zt&&this.unexpected(),e.generator=this.eat(E.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&Rt&&(e.id=t&Bt&&this.type!==E.name?null:this.parseIdent(),e.id&&!(t&zt)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?kt:F:At));var a=this.yieldPos,o=this.awaitPos,s=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Dt(e.async,e.generator)),t&Rt||(e.id=this.type===E.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,i),this.yieldPos=a,this.awaitPos=o,this.awaitIdentPos=s,this.finishNode(e,t&Rt?`FunctionDeclaration`:`FunctionExpression`)},z.parseFunctionParams=function(e){this.expect(E.parenL),e.params=this.parseBindingList(E.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},z.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),i=this.startNode(),a=!1;for(i.body=[],this.expect(E.braceL);this.type!==E.braceR;){var o=this.parseClassElement(e.superClass!==null);o&&(i.body.push(o),o.type===`MethodDefinition`&&o.kind===`constructor`?(a&&this.raiseRecoverable(o.start,`Duplicate constructor in the same class`),a=!0):o.key&&o.key.type===`PrivateIdentifier`&&Vt(r,o)&&this.raiseRecoverable(o.key.start,`Identifier '#`+o.key.name+`' has already been declared`))}return this.strict=n,this.next(),e.body=this.finishNode(i,`ClassBody`),this.exitClassBody(),this.finishNode(e,t?`ClassDeclaration`:`ClassExpression`)},z.parseClassElement=function(e){if(this.eat(E.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r=``,i=!1,a=!1,o=`method`,s=!1;if(this.eatContextual(`static`)){if(t>=13&&this.eat(E.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===E.star?s=!0:r=`static`}if(n.static=s,!r&&t>=8&&this.eatContextual(`async`)&&((this.isClassElementNameStart()||this.type===E.star)&&!this.canInsertSemicolon()?a=!0:r=`async`),!r&&(t>=9||!a)&&this.eat(E.star)&&(i=!0),!r&&!a&&!i){var c=this.value;(this.eatContextual(`get`)||this.eatContextual(`set`))&&(this.isClassElementNameStart()?o=c:r=c)}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===E.parenL||o!==`method`||i||a){var l=!n.static&&Ht(n,`constructor`),u=l&&e;l&&o!==`method`&&this.raise(n.key.start,`Constructor can't have get/set modifier`),n.kind=l?`constructor`:o,this.parseClassMethod(n,i,a,u)}else this.parseClassField(n);return n},z.isClassElementNameStart=function(){return this.type===E.name||this.type===E.privateId||this.type===E.num||this.type===E.string||this.type===E.bracketL||this.type.keyword},z.parseClassElementName=function(e){this.type===E.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)},z.parseClassMethod=function(e,t,n,r){var i=e.key;e.kind===`constructor`?(t&&this.raise(i.start,`Constructor can't be a generator`),n&&this.raise(i.start,`Constructor can't be an async method`)):e.static&&Ht(e,`prototype`)&&this.raise(i.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`)},z.parseClassField=function(e){return Ht(e,`constructor`)?this.raise(e.key.start,`Classes can't have a field named 'constructor'`):e.static&&Ht(e,`prototype`)&&this.raise(e.key.start,`Classes can't have a static field named 'prototype'`),this.eat(E.eq)?(this.enterScope(wt|St),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,`PropertyDefinition`)},z.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(P|St);this.type!==E.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,`StaticBlock`)},z.parseClassId=function(e,t){this.type===E.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,F,!1)):(t===!0&&this.unexpected(),e.id=null)},z.parseClassSuper=function(e){e.superClass=this.eat(E._extends)?this.parseExprSubscripts(null,!1):null},z.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},z.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,i=r===0?null:this.privateNameStack[r-1],a=0;a<n.length;++a){var o=n[a];st(t,o.name)||(i?i.used.push(o):this.raiseRecoverable(o.start,`Private field '#`+o.name+`' must be declared in an enclosing class`))}};function Vt(e,t){var n=t.key.name,r=e[n],i=`true`;return t.type===`MethodDefinition`&&(t.kind===`get`||t.kind===`set`)&&(i=(t.static?`s`:`i`)+t.kind),r===`iget`&&i===`iset`||r===`iset`&&i===`iget`||r===`sget`&&i===`sset`||r===`sset`&&i===`sget`?(e[n]=`true`,!1):r?!0:(e[n]=i,!1)}function Ht(e,t){var n=e.computed,r=e.key;return!n&&(r.type===`Identifier`&&r.name===t||r.type===`Literal`&&r.value===t)}z.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!==E.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ExportAllDeclaration`)},z.parseExport=function(e,t){if(this.next(),this.eat(E.star))return this.parseExportAllDeclaration(e,t);if(this.eat(E._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!==E.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 i=r[n];this.checkUnreserved(i.local),this.checkLocalExport(i.local),i.local.type===`Literal`&&this.raise(i.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`)},z.parseExportDeclaration=function(e){return this.parseStatement(null)},z.parseExportDefaultDeclaration=function(){var e;if(this.type===E._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,Rt|Bt,!1,e)}else if(this.type===E._class){var n=this.startNode();return this.parseClass(n,`nullableID`)}else{var r=this.parseMaybeAssign();return this.semicolon(),r}},z.checkExport=function(e,t,n){e&&(typeof t!=`string`&&(t=t.type===`Identifier`?t.name:t.value),st(e,t)&&this.raiseRecoverable(n,`Duplicate export '`+t+`'`),e[t]=!0)},z.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,i=t.properties;r<i.length;r+=1){var a=i[r];this.checkPatternExport(e,a)}else if(n===`ArrayPattern`)for(var o=0,s=t.elements;o<s.length;o+=1){var c=s[o];c&&this.checkPatternExport(e,c)}else n===`Property`?this.checkPatternExport(e,t.value):n===`AssignmentPattern`?this.checkPatternExport(e,t.left):n===`RestElement`&&this.checkPatternExport(e,t.argument)},z.checkVariableExport=function(e,t){if(e)for(var n=0,r=t;n<r.length;n+=1){var i=r[n];this.checkPatternExport(e,i.id)}},z.shouldParseExportStatement=function(){return this.type.keyword===`var`||this.type.keyword===`const`||this.type.keyword===`class`||this.type.keyword===`function`||this.isLet()||this.isAsyncFunction()},z.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`)},z.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(E.braceL);!this.eat(E.braceR);){if(n)n=!1;else if(this.expect(E.comma),this.afterTrailingComma(E.braceR))break;t.push(this.parseExportSpecifier(e))}return t},z.parseImport=function(e){return this.next(),this.type===E.string?(e.specifiers=Lt,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual(`from`),e.source=this.type===E.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ImportDeclaration`)},z.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,F),this.finishNode(e,`ImportSpecifier`)},z.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,F),this.finishNode(e,`ImportDefaultSpecifier`)},z.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual(`as`),e.local=this.parseIdent(),this.checkLValSimple(e.local,F),this.finishNode(e,`ImportNamespaceSpecifier`)},z.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===E.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(E.comma)))return e;if(this.type===E.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(E.braceL);!this.eat(E.braceR);){if(t)t=!1;else if(this.expect(E.comma),this.afterTrailingComma(E.braceR))break;e.push(this.parseImportSpecifier())}return e},z.parseWithClause=function(){var e=[];if(!this.eat(E._with))return e;this.expect(E.braceL);for(var t={},n=!0;!this.eat(E.braceR);){if(n)n=!1;else if(this.expect(E.comma),this.afterTrailingComma(E.braceR))break;var r=this.parseImportAttribute(),i=r.key.type===`Identifier`?r.key.name:r.key.value;st(t,i)&&this.raiseRecoverable(r.key.start,`Duplicate attribute key '`+i+`'`),t[i]=!0,e.push(r)}return e},z.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===E.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`),this.expect(E.colon),this.type!==E.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,`ImportAttribute`)},z.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===E.string){var e=this.parseLiteral(this.value);return ut.test(e.value)&&this.raise(e.start,`An export name cannot include a lone surrogate.`),e}return this.parseIdent(!0)},z.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)},z.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 B=I.prototype;B.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,i=e.properties;r<i.length;r+=1){var a=i[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},B.toAssignableList=function(e,t){for(var n=e.length,r=0;r<n;r++){var i=e[r];i&&this.toAssignable(i,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},B.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,`SpreadElement`)},B.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==E.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,`RestElement`)},B.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case E.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(E.bracketR,!0,!0),this.finishNode(e,`ArrayPattern`);case E.braceL:return this.parseObj(!0)}return this.parseIdent()},B.parseBindingList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(E.comma),t&&this.type===E.comma)i.push(null);else if(n&&this.afterTrailingComma(e))break;else if(this.type===E.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),i.push(o),this.type===E.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.expect(e);break}else i.push(this.parseAssignableListItem(r));return i},B.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},B.parseBindingListItem=function(e){return e},B.parseMaybeDefault=function(e,t,n){if(n||=this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(E.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,`AssignmentPattern`)},B.checkLValSimple=function(e,t,n){t===void 0&&(t=Ot);var r=t!==Ot;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===F&&e.name===`let`&&this.raiseRecoverable(e.start,`let is disallowed as a lexically bound name`),n&&(st(n,e.name)&&this.raiseRecoverable(e.start,`Argument name clash`),n[e.name]=!0),t!==Mt&&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`)}},B.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=Ot),e.type){case`ObjectPattern`:for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,t,n)}break;case`ArrayPattern`:for(var o=0,s=e.elements;o<s.length;o+=1){var c=s[o];c&&this.checkLValInnerPattern(c,t,n)}break;default:this.checkLValSimple(e,t,n)}},B.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=Ot),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 V=function(e,t,n,r,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=r,this.generator=!!i},H={b_stat:new V(`{`,!1),b_expr:new V(`{`,!0),b_tmpl:new V("${",!1),p_stat:new V(`(`,!1),p_expr:new V(`(`,!0),q_tmpl:new V("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new V(`function`,!1),f_expr:new V(`function`,!0),f_expr_gen:new V(`function`,!0,!1,null,!0),f_gen:new V(`function`,!1,!1,null,!0)},Ut=I.prototype;Ut.initialContext=function(){return[H.b_stat]},Ut.curContext=function(){return this.context[this.context.length-1]},Ut.braceIsBlock=function(e){var t=this.curContext();return t===H.f_expr||t===H.f_stat?!0:e===E.colon&&(t===H.b_stat||t===H.b_expr)?!t.isExpr:e===E._return||e===E.name&&this.exprAllowed?D.test(this.input.slice(this.lastTokEnd,this.start)):e===E._else||e===E.semi||e===E.eof||e===E.parenR||e===E.arrow?!0:e===E.braceL?t===H.b_stat:e===E._var||e===E._const||e===E.name?!1:!this.exprAllowed},Ut.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},Ut.updateContext=function(e){var t,n=this.type;n.keyword&&e===E.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},Ut.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},E.parenR.updateContext=E.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===H.b_stat&&this.curContext().token===`function`&&(e=this.context.pop()),this.exprAllowed=!e.isExpr},E.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?H.b_stat:H.b_expr),this.exprAllowed=!0},E.dollarBraceL.updateContext=function(){this.context.push(H.b_tmpl),this.exprAllowed=!0},E.parenL.updateContext=function(e){var t=e===E._if||e===E._for||e===E._with||e===E._while;this.context.push(t?H.p_stat:H.p_expr),this.exprAllowed=!0},E.incDec.updateContext=function(){},E._function.updateContext=E._class.updateContext=function(e){e.beforeExpr&&e!==E._else&&(e!==E.semi||this.curContext()===H.p_stat)&&!(e===E._return&&D.test(this.input.slice(this.lastTokEnd,this.start)))&&(e!==E.colon&&e!==E.braceL||this.curContext()!==H.b_stat)?this.context.push(H.f_expr):this.context.push(H.f_stat),this.exprAllowed=!1},E.colon.updateContext=function(){this.curContext().token===`function`&&this.context.pop(),this.exprAllowed=!0},E.backQuote.updateContext=function(){this.curContext()===H.q_tmpl?this.context.pop():this.context.push(H.q_tmpl),this.exprAllowed=!1},E.star.updateContext=function(e){if(e===E._function){var t=this.context.length-1;this.context[t]===H.f_expr?this.context[t]=H.f_expr_gen:this.context[t]=H.f_gen}this.exprAllowed=!0},E.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==E.dot&&(this.value===`of`&&!this.exprAllowed||this.value===`yield`&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var U=I.prototype;U.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,i;switch(r.type){case`Identifier`:i=r.name;break;case`Literal`:i=String(r.value);break;default:return}var a=e.kind;if(this.options.ecmaVersion>=6){i===`__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}i=`$`+i;var o=t[i];o?(a===`init`?this.strict&&o.init||o.get||o.set:o.init||o[a])&&this.raiseRecoverable(r.start,`Redefinition of property`):o=t[i]={init:!1,get:!1,set:!1},o[a]=!0}},U.parseExpression=function(e,t){var n=this;return this.catchStackOverflow(function(){var r=n.start,i=n.startLoc,a=n.parseMaybeAssign(e,t);if(n.type===E.comma){var o=n.startNodeAt(r,i);for(o.expressions=[a];n.eat(E.comma);)o.expressions.push(n.parseMaybeAssign(e,t));return n.finishNode(o,`SequenceExpression`)}return a})},U.parseMaybeAssign=function(e,t,n){if(this.isContextual(`yield`)){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,i=-1,a=-1,o=-1;t?(i=t.parenthesizedAssign,a=t.trailingComma,o=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new Pt,r=!0);var s=this.start,c=this.startLoc;(this.type===E.parenL||this.type===E.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e===`await`);var l=this.parseMaybeConditional(e,t);if(n&&(l=n.call(this,l,s,c)),this.type.isAssign){var u=this.startNodeAt(s,c);return u.operator=this.value,this.type===E.eq&&(l=this.toAssignable(l,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),this.type===E.eq?this.checkLValPattern(l):this.checkLValSimple(l),u.left=l,this.next(),u.right=this.parseMaybeAssign(e),o>-1&&(t.doubleProto=o),this.finishNode(u,`AssignmentExpression`)}else r&&this.checkExpressionErrors(t,!0);return i>-1&&(t.parenthesizedAssign=i),a>-1&&(t.trailingComma=a),l},U.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if((i.type!==`ArrowFunctionExpression`||i.start!==n)&&this.eat(E.question)){var a=this.startNodeAt(n,r);return a.test=i,a.consequent=this.parseMaybeAssign(),this.expect(E.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,`ConditionalExpression`)}return i},U.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===n&&i.type===`ArrowFunctionExpression`?i:this.parseExprOp(i,n,r,-1,e)},U.parseExprOp=function(e,t,n,r,i){var a=this.type.binop;if(a!=null&&(!i||this.type!==E._in)&&a>r){var o=this.type===E.logicalOR||this.type===E.logicalAND,s=this.type===E.coalesce;s&&(a=E.logicalAND.binop);var c=this.value;this.next();var l=this.start,u=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,u,a,i),f=this.buildBinary(t,n,e,d,c,o||s);return(o&&this.type===E.coalesce||s&&(this.type===E.logicalOR||this.type===E.logicalAND))&&this.raiseRecoverable(this.start,`Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses`),this.parseExprOp(f,t,n,r,i)}return e},U.buildBinary=function(e,t,n,r,i,a){r.type===`PrivateIdentifier`&&this.raise(r.start,`Private identifier can only be left side of binary expression`);var o=this.startNodeAt(e,t);return o.left=n,o.operator=i,o.right=r,this.finishNode(o,a?`LogicalExpression`:`BinaryExpression`)},U.parseMaybeUnary=function(e,t,n,r){var i=this.start,a=this.startLoc,o;if(this.isContextual(`await`)&&this.canAwait)o=this.parseAwait(r),t=!0;else if(this.type.prefix){var s=this.startNode(),c=this.type===E.incDec;s.operator=this.value,s.prefix=!0,this.next(),s.argument=this.parseMaybeUnary(null,!0,c,r),this.checkExpressionErrors(e,!0),c?this.checkLValSimple(s.argument):this.strict&&s.operator===`delete`&&Wt(s.argument)?this.raiseRecoverable(s.start,`Deleting local variable in strict mode`):s.operator===`delete`&&Gt(s.argument)?this.raiseRecoverable(s.start,`Private fields can not be deleted`):t=!0,o=this.finishNode(s,c?`UpdateExpression`:`UnaryExpression`)}else if(!t&&this.type===E.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),o=this.parsePrivateIdent(),this.type!==E._in&&this.unexpected();else{if(o=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return o;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(i,a);l.operator=this.value,l.prefix=!1,l.argument=o,this.checkLValSimple(o),this.next(),o=this.finishNode(l,`UpdateExpression`)}}if(!n&&this.eat(E.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(i,a,o,this.parseMaybeUnary(null,!1,!1,r),`**`,!1);else return o};function Wt(e){return e.type===`Identifier`||e.type===`ParenthesizedExpression`&&Wt(e.expression)}function Gt(e){return e.type===`MemberExpression`&&e.property.type===`PrivateIdentifier`||e.type===`ChainExpression`&&Gt(e.expression)||e.type===`ParenthesizedExpression`&&Gt(e.expression)}U.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprAtom(e,t);if(i.type===`ArrowFunctionExpression`&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==`)`)return i;var a=this.parseSubscripts(i,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},U.parseSubscripts=function(e,t,n,r,i){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,o=!1;;){var s=this.parseSubscript(e,t,n,r,a,o,i);if(s.optional&&(o=!0),s===e||s.type===`ArrowFunctionExpression`){if(o){var c=this.startNodeAt(t,n);c.expression=s,s=this.finishNode(c,`ChainExpression`)}return s}e=s}},U.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(E.arrow)},U.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)},U.parseSubscript=function(e,t,n,r,i,a,o){var s=this.options.ecmaVersion>=11,c=s&&this.eat(E.questionDot);r&&c&&this.raise(this.lastTokStart,`Optional chaining cannot appear in the callee of new expressions`);var l=this.eat(E.bracketL);if(l||c&&this.type!==E.parenL&&this.type!==E.backQuote||this.eat(E.dot)){var u=this.startNodeAt(t,n);u.object=e,l?(u.property=this.parseExpression(),this.expect(E.bracketR)):this.type===E.privateId&&e.type!==`Super`?u.property=this.parsePrivateIdent():u.property=this.parseIdent(this.options.allowReserved!==`never`),u.computed=!!l,s&&(u.optional=c),e=this.finishNode(u,`MemberExpression`)}else if(!r&&this.eat(E.parenL)){var d=new Pt,f=this.yieldPos,ee=this.awaitPos,p=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var te=this.parseExprList(E.parenR,this.options.ecmaVersion>=8,!1,d);if(i&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,`Cannot use 'await' as identifier inside an async function`),this.yieldPos=f,this.awaitPos=ee,this.awaitIdentPos=p,this.parseSubscriptAsyncArrow(t,n,te,o);this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=ee||this.awaitPos,this.awaitIdentPos=p||this.awaitIdentPos;var m=this.startNodeAt(t,n);m.callee=e,m.arguments=te,s&&(m.optional=c),e=this.finishNode(m,`CallExpression`)}else if(this.type===E.backQuote){(c||a)&&this.raise(this.start,`Optional chaining cannot appear in the tag of tagged template expressions`);var h=this.startNodeAt(t,n);h.tag=e,h.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(h,`TaggedTemplateExpression`)}return e},U.parseExprAtom=function(e,t,n){this.type===E.slash&&this.readRegexp();var r,i=this.potentialArrowAt===this.start;switch(this.type){case E._super:return this.allowSuper||this.raise(this.start,`'super' keyword outside a method`),r=this.startNode(),this.next(),this.type===E.parenL&&!this.allowDirectSuper&&this.raise(r.start,`super() call outside constructor of a subclass`),this.type!==E.dot&&this.type!==E.bracketL&&this.type!==E.parenL&&this.unexpected(),this.finishNode(r,`Super`);case E._this:return r=this.startNode(),this.next(),this.finishNode(r,`ThisExpression`);case E.name:var a=this.start,o=this.startLoc,s=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!s&&c.name===`async`&&!this.canInsertSemicolon()&&this.eat(E._function))return this.overrideContext(H.f_expr),this.parseFunction(this.startNodeAt(a,o),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(E.arrow))return this.parseArrowExpression(this.startNodeAt(a,o),[c],!1,t);if(this.options.ecmaVersion>=8&&c.name===`async`&&this.type===E.name&&!s&&(!this.potentialArrowInForAwait||this.value!==`of`||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(E.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,o),[c],!0,t)}return c;case E.regexp:var l=this.value;return r=this.parseLiteral(l.value),r.regex={pattern:l.pattern,flags:l.flags},r;case E.num:case E.string:return this.parseLiteral(this.value);case E._null:case E._true:case E._false:return r=this.startNode(),r.value=this.type===E._null?null:this.type===E._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,`Literal`);case E.parenL:var u=this.start,d=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(d)&&(e.parenthesizedAssign=u),e.parenthesizedBind<0&&(e.parenthesizedBind=u)),d;case E.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(E.bracketR,!0,!0,e),this.finishNode(r,`ArrayExpression`);case E.braceL:return this.overrideContext(H.b_expr),this.parseObj(!1,e);case E._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case E._class:return this.parseClass(this.startNode(),!1);case E._new:return this.parseNew();case E.backQuote:return this.parseTemplate();case E._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},U.parseExprAtomDefault=function(){this.unexpected()},U.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword import`),this.next(),this.type===E.parenL&&!e)return this.parseDynamicImport(t);if(this.type===E.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()},U.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(E.parenR)?e.options=null:(this.expect(E.comma),this.afterTrailingComma(E.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(E.parenR)||(this.expect(E.comma),this.afterTrailingComma(E.parenR)||this.unexpected())));else if(!this.eat(E.parenR)){var t=this.start;this.eat(E.comma)&&this.eat(E.parenR)?this.raiseRecoverable(t,`Trailing comma is not allowed in import()`):this.unexpected(t)}return this.finishNode(e,`ImportExpression`)},U.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`)},U.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.raw.slice(0,-1).replace(/_/g,``):t.value.toString()),this.next(),this.finishNode(t,`Literal`)},U.parseParenExpression=function(){this.expect(E.parenL);var e=this.parseExpression();return this.expect(E.parenR),e},U.shouldParseArrow=function(e){return!this.canInsertSemicolon()},U.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,i,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var o=this.start,s=this.startLoc,c=[],l=!0,u=!1,d=new Pt,f=this.yieldPos,ee=this.awaitPos,p;for(this.yieldPos=0,this.awaitPos=0;this.type!==E.parenR;)if(l?l=!1:this.expect(E.comma),a&&this.afterTrailingComma(E.parenR,!0)){u=!0;break}else if(this.type===E.ellipsis){p=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===E.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`);break}else c.push(this.parseMaybeAssign(!1,d,this.parseParenItem));var te=this.lastTokEnd,m=this.lastTokEndLoc;if(this.expect(E.parenR),e&&this.shouldParseArrow(c)&&this.eat(E.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=ee,this.parseParenArrowList(n,r,c,t);(!c.length||u)&&this.unexpected(this.lastTokStart),p&&this.unexpected(p),this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=ee||this.awaitPos,c.length>1?(i=this.startNodeAt(o,s),i.expressions=c,this.finishNodeAt(i,`SequenceExpression`,te,m)):i=c[0]}else i=this.parseParenExpression();if(this.options.preserveParens){var h=this.startNodeAt(n,r);return h.expression=i,this.finishNode(h,`ParenthesizedExpression`)}else return i},U.parseParenItem=function(e){return e},U.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var Kt=[];U.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===E.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,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,i,!0,!1),e.callee.type===`Super`&&this.raiseRecoverable(r,`Invalid use of 'super'`),this.eat(E.parenL)?e.arguments=this.parseExprList(E.parenR,this.options.ecmaVersion>=8,!1):e.arguments=Kt,this.finishNode(e,`NewExpression`)},U.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===E.invalidTemplate?(t||this.raiseRecoverable(this.start,`Bad escape sequence in untagged template literal`),n.value={raw:this.value.replace(/\r\n?/g,`
|
|
5
|
-
|
|
6
|
-
`),cooked:this.value},this.next(),n.tail=this.type===E.backQuote,this.finishNode(n,`TemplateElement`)},U.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===E.eof&&this.raise(this.pos,`Unterminated template literal`),this.expect(E.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(E.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,`TemplateLiteral`)},U.isAsyncProp=function(e){return!e.computed&&e.key.type===`Identifier`&&e.key.name===`async`&&(this.type===E.name||this.type===E.num||this.type===E.string||this.type===E.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===E.star)&&!D.test(this.input.slice(this.lastTokEnd,this.start))},U.parseObj=function(e,t){var n=this.startNode(),r=!0,i={};for(n.properties=[],this.next();!this.eat(E.braceR);){if(r)r=!1;else if(this.expect(E.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(E.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,i,t),n.properties.push(a)}return this.finishNode(n,e?`ObjectPattern`:`ObjectExpression`)},U.parseProperty=function(e,t){var n=this.startNode(),r,i,a,o;if(this.options.ecmaVersion>=9&&this.eat(E.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===E.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===E.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,o=this.startLoc),e||(r=this.eat(E.star)));var s=this.containsEsc;return this.parsePropertyName(n),!e&&!s&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(n)?(i=!0,r=this.options.ecmaVersion>=9&&this.eat(E.star),this.parsePropertyName(n)):i=!1,this.parsePropertyValue(n,e,r,i,a,o,t,s),this.finishNode(n,`Property`)},U.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`)},U.parsePropertyValue=function(e,t,n,r,i,a,o,s){(n||r)&&this.type===E.colon&&this.unexpected(),this.eat(E.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind=`init`):this.options.ecmaVersion>=6&&this.type===E.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,r),e.kind=`init`):!t&&!s&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type===`Identifier`&&(e.key.name===`get`||e.key.name===`set`)&&this.type!==E.comma&&this.type!==E.braceR&&this.type!==E.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=i),t?e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key)):this.type===E.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind=`init`,e.shorthand=!0):this.unexpected()},U.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(E.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(E.bracketR),e.key;e.computed=!1}return e.key=this.type===E.num||this.type===E.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`)},U.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},U.parseMethod=function(e,t,n){var r=this.startNode(),i=this.yieldPos,a=this.awaitPos,o=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(Dt(t,r.generator)|St|(n?Ct:0)),this.expect(E.parenL),r.params=this.parseBindingList(E.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(r,`FunctionExpression`)},U.parseArrowExpression=function(e,t,n,r){var i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(Dt(n,!1)|bt),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=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,`ArrowFunctionExpression`)},U.parseFunctionBody=function(e,t,n,r){var i=t&&this.type!==E.braceL,a=this.strict,o=!1;if(i)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var s=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!a||s)&&(o=this.strictDirective(this.end),o&&s&&this.raiseRecoverable(e.start,`Illegal 'use strict' directive in function with non-simple parameter list`));var c=this.labels;this.labels=[],o&&(this.strict=!0),this.checkParams(e,!a&&!o&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,Mt),e.body=this.parseBlock(!1,void 0,o&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=c}this.exitScope()},U.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1)if(n[t].type!==`Identifier`)return!1;return!0},U.checkParams=function(e,t){for(var n=Object.create(null),r=0,i=e.params;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,kt,t?null:n)}},U.parseExprList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(E.comma),t&&this.afterTrailingComma(e))break;var o=void 0;n&&this.type===E.comma?o=null:this.type===E.ellipsis?(o=this.parseSpread(r),r&&this.type===E.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):o=this.parseMaybeAssign(!1,r),i.push(o)}return i},U.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;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&Et)&&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)&&(this.strict?this.reservedWordsStrict:this.reservedWords).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`))},U.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},U.parseIdentNode=function(){var e=this.startNode();return this.type===E.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=E.name):this.unexpected(),e},U.parsePrivateIdent=function(){var e=this.startNode();return this.type===E.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},U.parseYield=function(e){this.yieldPos||=this.start;var t=this.startNode();return this.next(),this.type===E.semi||this.canInsertSemicolon()||this.type!==E.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(E.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,`YieldExpression`)},U.parseAwait=function(e){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=I.prototype;qt.raise=function(e,t){var n=pt(this.input,e);t+=` (`+n.line+`:`+n.column+`)`,this.sourceFile&&(t+=` in `+this.sourceFile);var r=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 dt(this.curLine,this.pos-this.lineStart)};var W=I.prototype,Jt=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};W.enterScope=function(e){this.scopeStack.push(new Jt(e))},W.exitScope=function(){this.scopeStack.pop()},W.treatFunctionsAsVarInScope=function(e){return e.flags&N||!this.inModule&&e.flags&M},W.declareName=function(e,t,n){var r=!1;if(t===F){var i=this.currentScope();r=i.lexical.indexOf(e)>-1||i.functions.indexOf(e)>-1||i.var.indexOf(e)>-1,i.lexical.push(e),this.inModule&&i.flags&M&&delete this.undefinedExports[e]}else if(t===jt)this.currentScope().lexical.push(e);else if(t===At){var a=this.currentScope();r=this.treatFunctionsAsVar?a.lexical.indexOf(e)>-1:a.lexical.indexOf(e)>-1||a.var.indexOf(e)>-1,a.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var s=this.scopeStack[o];if(s.lexical.indexOf(e)>-1&&!(s.flags&xt&&s.lexical[0]===e)||!this.treatFunctionsAsVarInScope(s)&&s.functions.indexOf(e)>-1){r=!0;break}if(s.var.push(e),this.inModule&&s.flags&M&&delete this.undefinedExports[e],s.flags&Et)break}r&&this.raiseRecoverable(n,`Identifier '`+e+`' has already been declared`)},W.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)},W.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},W.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Et|wt|P))return t}},W.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Et|wt|P)&&!(t.flags&bt))return t}};var Yt=function(e,t,n){this.type=``,this.start=t,this.end=0,e.options.locations&&(this.loc=new ft(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},Xt=I.prototype;Xt.startNode=function(){return new Yt(this,this.start,this.startLoc)},Xt.startNodeAt=function(e,t){return new Yt(this,e,t)};function Zt(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}Xt.finishNode=function(e,t){return Zt.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},Xt.finishNodeAt=function(e,t,n,r){return Zt.call(this,e,t,n,r)},Xt.copyNode=function(e){var t=new Yt(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var Qt=`Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz`,$t=`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`,en=$t+` Extended_Pictographic`,tn=en,nn=tn+` EBase EComp EMod EPres ExtPict`,rn=nn,an={9:$t,10:en,11:tn,12:nn,13:rn,14:rn},on={9:``,10:``,11:``,12:``,13:``,14:`Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji`},sn=`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`,cn=`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`,ln=cn+` Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd`,un=ln+` Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho`,dn=un+` Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi`,fn=dn+` Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith`,pn={9:cn,10:ln,11:un,12:dn,13:fn,14:fn+` `+Qt},mn={};function hn(e){var t=mn[e]={binary:A(an[e]+` `+sn),binaryOfStrings:A(on[e]),nonBinary:{General_Category:A(sn),Script:A(pn[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(var gn=0,_n=[9,10,11,12,13,14];gn<_n.length;gn+=1){var vn=_n[gn];hn(vn)}var G=I.prototype,yn=function(e,t){this.parent=e,this.base=t||this};yn.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var n=e;n;n=n.parent)if(t.base===n.base&&t!==n)return!0;return!1},yn.prototype.sibling=function(){return new yn(this.parent,this.base)};var K=function(e){this.parser=e,this.validFlags=`gim`+(e.options.ecmaVersion>=6?`uy`:``)+(e.options.ecmaVersion>=9?`s`:``)+(e.options.ecmaVersion>=13?`d`:``)+(e.options.ecmaVersion>=15?`v`:``),this.unicodeProperties=mn[e.options.ecmaVersion>=14?14:e.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};K.prototype.reset=function(e,t,n){var r=n.indexOf(`v`)!==-1,i=n.indexOf(`u`)!==-1;this.start=e|0,this.source=t+``,this.flags=n,r&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=i&&this.parser.options.ecmaVersion>=9)},K.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,`Invalid regular expression: /`+this.source+`/: `+e)},K.prototype.at=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return-1;var i=n.charCodeAt(e);if(!(t||this.switchU)||i<=55295||i>=57344||e+1>=r)return i;var a=n.charCodeAt(e+1);return a>=56320&&a<=57343?(i<<10)+a-56613888:i},K.prototype.nextIndex=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return r;var i=n.charCodeAt(e),a;return!(t||this.switchU)||i<=55295||i>=57344||e+1>=r||(a=n.charCodeAt(e+1))<56320||a>57343?e+1:e+2},K.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)},K.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},K.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)},K.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e?(this.advance(t),!0):!1},K.prototype.eatChars=function(e,t){t===void 0&&(t=!1);for(var n=this.pos,r=0,i=e;r<i.length;r+=1){var a=i[r],o=this.at(n,t);if(o===-1||o!==a)return!1;n=this.nextIndex(n,t)}return this.pos=n,!0},G.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,r=!1,i=!1,a=0;a<n.length;a++){var o=n.charAt(a);t.indexOf(o)===-1&&this.raise(e.start,`Invalid regular expression flag`),n.indexOf(o,a+1)>-1&&this.raise(e.start,`Duplicate regular expression flag`),o===`u`&&(r=!0),o===`v`&&(i=!0)}this.options.ecmaVersion>=15&&r&&i&&this.raise(e.start,`Invalid regular expression flag`)};function bn(e){for(var t in e)return!0;return!1}G.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&bn(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},G.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`)}},G.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new yn(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`)},G.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},G.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},G.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},G.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1},G.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},G.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var r=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return i!==-1&&i<r&&!t&&e.raise(`numbers out of order in {} quantifier`),!0;e.switchU&&!t&&e.raise(`Incomplete quantifier`),e.pos=n}return!1},G.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)},G.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},G.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 i=0;i<n.length;i++){var a=n.charAt(i);n.indexOf(a,i+1)>-1&&e.raise(`Duplicate regular expression modifiers`)}if(r){var o=this.regexp_eatModifiers(e);!n&&!o&&e.current()===58&&e.raise(`Invalid regular expression modifiers`);for(var s=0;s<o.length;s++){var c=o.charAt(s);(o.indexOf(c,s+1)>-1||n.indexOf(c)>-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},G.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},G.regexp_eatModifiers=function(e){for(var t=``,n=0;(n=e.current())!==-1&&xn(n);)t+=j(n),e.advance();return t};function xn(e){return e===105||e===109||e===115}G.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)},G.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise(`Nothing to repeat`),!1},G.regexp_eatSyntaxCharacter=function(e){var t=e.current();return Sn(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Sn(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}G.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!Sn(n);)e.advance();return e.pos!==t},G.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},G.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,i=n;r<i.length;r+=1)i[r].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}},G.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},G.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue=``,this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=j(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=j(e.lastIntValue);return!0}return!1},G.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),Cn(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Cn(e){return y(e,!0)||e===36||e===95}G.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),wn(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function wn(e){return b(e,!0)||e===36||e===95||e===8204||e===8205}G.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)},G.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},G.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},G.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)},G.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},G.regexp_eatZero=function(e){return e.current()===48&&!Pn(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1},G.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},G.regexp_eatControlLetter=function(e){var t=e.current();return Tn(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Tn(e){return e>=65&&e<=90||e>=97&&e<=122}G.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 i=e.lastIntValue;if(r&&i>=55296&&i<=56319){var a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var o=e.lastIntValue;if(o>=56320&&o<=57343)return e.lastIntValue=(i-55296)*1024+(o-56320)+65536,!0}e.pos=a,e.lastIntValue=i}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&En(e.lastIntValue))return!0;r&&e.raise(`Invalid unicode escape`),e.pos=n}return!1};function En(e){return e>=0&&e<=1114111}G.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},G.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 Dn=0,q=1,J=2;G.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(On(t))return e.lastIntValue=-1,e.advance(),q;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===J&&e.raise(`Invalid property name`),r;e.raise(`Invalid property name`)}return Dn};function On(e){return e===100||e===68||e===115||e===83||e===119||e===87}G.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),q}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return Dn},G.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){st(e.unicodeProperties.nonBinary,t)||e.raise(`Invalid property name`),e.unicodeProperties.nonBinary[t].test(n)||e.raise(`Invalid property value`)},G.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return q;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return J;e.raise(`Invalid property name`)},G.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue=``;kn(t=e.current());)e.lastStringValue+=j(t),e.advance();return e.lastStringValue!==``};function kn(e){return Tn(e)||e===95}G.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue=``;An(t=e.current());)e.lastStringValue+=j(t),e.advance();return e.lastStringValue!==``};function An(e){return kn(e)||Pn(e)}G.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},G.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===J&&e.raise(`Negated character class may contain strings`),!0}return!1},G.regexp_classContents=function(e){return e.current()===93?q:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),q)},G.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`)}}},G.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||Ln(n))&&e.raise(`Invalid class escape`),e.raise(`Invalid escape`)}e.pos=t}var r=e.current();return r===93?!1:(e.lastIntValue=r,e.advance(),!0)},G.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)},G.regexp_classSetExpression=function(e){var t=q,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===J&&(t=J);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==J&&(t=q);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===J&&(t=J)}},G.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},G.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?q:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},G.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===J&&e.raise(`Negated character class may contain strings`),r;e.pos=t}if(e.eat(92)){var i=this.regexp_eatCharacterClassEscape(e);if(i)return i;e.pos=t}return null},G.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},G.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===J&&(t=J);return t},G.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?q:J},G.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()&&jn(n)||Mn(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function jn(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 Mn(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}G.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return Nn(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Nn(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}G.regexp_eatClassControlLetter=function(e){var t=e.current();return Pn(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1},G.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},G.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Pn(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function Pn(e){return e>=48&&e<=57}G.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Fn(n=e.current());)e.lastIntValue=16*e.lastIntValue+In(n),e.advance();return e.pos!==t};function Fn(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function In(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}G.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},G.regexp_eatOctalDigit=function(e){var t=e.current();return Ln(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Ln(e){return e>=48&&e<=55}G.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var i=e.current();if(!Fn(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+In(i),e.advance()}return!0};var Rn=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new ft(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},Y=I.prototype;Y.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 Rn(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},Y.getToken=function(){return this.next(),new Rn(this)},typeof Symbol<`u`&&(Y[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===E.eof,value:t}}}}),Y.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(E.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())},Y.readToken=function(e){return y(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)},Y.fullCharCodeAt=function(e){var t=this.input.charCodeAt(e);if(t<=55295||t>=56320)return t;var n=this.input.charCodeAt(e+1);return n<=56319||n>=57344?t:(t<<10)+n-56613888},Y.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)},Y.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,i=t;(r=nt(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())},Y.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&&!O(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())},Y.skipSpace=function(){loop: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 loop}break;default:if(e>8&&e<14||e>=5760&&rt.test(String.fromCharCode(e)))++this.pos;else break loop}}},Y.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)},Y.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(E.ellipsis)):(++this.pos,this.finishToken(E.dot))},Y.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(E.assign,2):this.finishOp(E.slash,1)},Y.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?E.star:E.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=E.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(E.assign,n+1):this.finishOp(r,n)},Y.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?this.options.ecmaVersion>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(E.assign,3):this.finishOp(e===124?E.logicalOR:E.logicalAND,2):t===61?this.finishOp(E.assign,2):this.finishOp(e===124?E.bitwiseOR:E.bitwiseAND,1)},Y.readToken_caret=function(){return this.input.charCodeAt(this.pos+1)===61?this.finishOp(E.assign,2):this.finishOp(E.bitwiseXOR,1)},Y.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||D.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(E.incDec,2):t===61?this.finishOp(E.assign,2):this.finishOp(E.plusMin,1)},Y.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(E.assign,n+1):this.finishOp(E.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(E.relational,n))},Y.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(E.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(E.arrow)):this.finishOp(e===61?E.eq:E.prefix,1)},Y.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(E.questionDot,2)}if(t===63)return e>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(E.assign,3):this.finishOp(E.coalesce,2)}return this.finishOp(E.question,1)},Y.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),y(t,!0)||t===92))return this.finishToken(E.privateId,this.readWord1());this.raise(this.pos,`Unexpected character '`+j(t)+`'`)},Y.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(E.parenL);case 41:return++this.pos,this.finishToken(E.parenR);case 59:return++this.pos,this.finishToken(E.semi);case 44:return++this.pos,this.finishToken(E.comma);case 91:return++this.pos,this.finishToken(E.bracketL);case 93:return++this.pos,this.finishToken(E.bracketR);case 123:return++this.pos,this.finishToken(E.braceL);case 125:return++this.pos,this.finishToken(E.braceR);case 58:return++this.pos,this.finishToken(E.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(E.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(E.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,`Unexpected character '`+j(e)+`'`)},Y.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},Y.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(D.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 i=this.input.slice(n,this.pos);++this.pos;var a=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(a);var s=this.regexpState||=new K(this);s.reset(n,i,o),this.validateRegExpFlags(s),this.validateRegExpPattern(s);var c=null;try{c=new RegExp(i,o)}catch{}return this.finishToken(E.regexp,{pattern:i,flags:o,value:c})},Y.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,i=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,o=0,s=0,c=0,l=t??1/0;c<l;++c,++this.pos){var u=this.input.charCodeAt(this.pos),d=void 0;if(r&&u===95){i&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed in legacy octal numeric literals`),s===95&&this.raiseRecoverable(this.pos,`Numeric separator must be exactly one underscore`),c===0&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed at the first of digits`),s=u;continue}if(d=u>=97?u-97+10:u>=65?u-65+10:u>=48&&u<=57?u-48:1/0,d>=e)break;s=u,o=o*e+d}return r&&s===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:o};function zn(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,``))}function Bn(e){return typeof BigInt==`function`?BigInt(e.replace(/_/g,``)):null}Y.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return n??this.raise(this.start+2,`Expected number in radix `+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=Bn(this.input.slice(t,this.pos)),++this.pos):y(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(E.num,n)},Y.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 i=Bn(this.input.slice(t,this.pos));return++this.pos,y(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(E.num,i)}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`)),y(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`);var a=zn(this.input.slice(t,this.pos),n);return this.finishToken(E.num,a)},Y.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},Y.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)):(O(r)&&this.raise(this.start,`Unterminated string constant`),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(E.string,t)};var Vn={};Y.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===Vn)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1},Y.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Vn;this.raise(e,t)},Y.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===E.template||this.type===E.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(E.dollarBraceL)):(++this.pos,this.finishToken(E.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(E.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(O(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+=`
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
`;case 114:return`\r`;case 120:return String.fromCharCode(this.readHexChar(2));case 117:return j(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],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=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(i)}return O(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),``):String.fromCharCode(t)}},Y.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,`Bad character escape sequence`),n},Y.readWord1=function(){this.containsEsc=!1;for(var e=``,t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(b(i,r))this.pos+=i<=65535?1:2;else if(i===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 o=this.readCodePoint();(t?y:b)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=j(o),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},Y.readWord=function(){var e=this.readWord1(),t=E.name;return this.keywords.test(e)&&(t=et[e]),this.finishToken(t,e)},I.acorn={Parser:I,version:`8.17.0`,defaultOptions:mt,Position:dt,SourceLocation:ft,getLineInfo:pt,Node:Yt,TokenType:x,tokTypes:E,keywordTypes:et,TokContext:V,tokContexts:H,isIdentifierChar:b,isIdentifierStart:y,Token:Rn,isNewLine:O,lineBreak:D,lineBreakG:tt,nonASCIIwhitespace:rt},String.fromCharCode;const Hn=/\/$|\/\?|\/#/,Un=/^\.?\//;function Wn(e=``,t){return t?Hn.test(e):e.endsWith(`/`)}function Gn(e=``,t){if(!t)return e.endsWith(`/`)?e:e+`/`;if(Wn(e,!0))return e||`/`;let n=e,r=``,i=e.indexOf(`#`);if(i!==-1&&(n=e.slice(0,i),r=e.slice(i),!n))return r;let[a,...o]=n.split(`?`);return a+`/`+(o.length>0?`?${o.join(`?`)}`:``)+r}function Kn(e){return e&&e!==`/`}function qn(e,...t){let n=e||``;for(let e of t.filter(e=>Kn(e)))if(n){let t=e.replace(Un,``);n=Gn(n)+t}else n=e;return n}const Jn=new Set(te.builtinModules);function Yn(e){return e.replace(/\\/g,`/`)}const Xn={}.hasOwnProperty,Zn=/^([A-Z][a-z\d]*)+$/,Qn=new Set([`string`,`function`,`number`,`object`,`Function`,`Object`,`boolean`,`bigint`,`symbol`]),X={};function $n(e,t=`and`){return e.length<3?e.join(` ${t} `):`${e.slice(0,-1).join(`, `)}, ${t} ${e[e.length-1]}`}const er=new Map;let tr;X.ERR_INVALID_ARG_TYPE=Z(`ERR_INVALID_ARG_TYPE`,(e,t,n)=>{h.default.ok(typeof e==`string`,`'name' must be a string`),Array.isArray(t)||(t=[t]);let r=`The `;if(e.endsWith(` argument`))r+=`${e} `;else{let t=e.includes(`.`)?`property`:`argument`;r+=`"${e}" ${t} `}r+=`must be `;let i=[],a=[],o=[];for(let e of t)h.default.ok(typeof e==`string`,`All expected entries have to be of type string`),Qn.has(e)?i.push(e.toLowerCase()):Zn.exec(e)===null?(h.default.ok(e!==`object`,`The value "object" should be written as "Object"`),o.push(e)):a.push(e);if(a.length>0){let e=i.indexOf(`object`);e!==-1&&(i.slice(e,1),a.push(`Object`))}return i.length>0&&(r+=`${i.length>1?`one of type`:`of type`} ${$n(i,`or`)}`,(a.length>0||o.length>0)&&(r+=` or `)),a.length>0&&(r+=`an instance of ${$n(a,`or`)}`,o.length>0&&(r+=` or `)),o.length>0&&(o.length>1?r+=`one of ${$n(o,`or`)}`:(o[0].toLowerCase()!==o[0]&&(r+=`an `),r+=`${o[0]}`)),r+=`. Received ${sr(n)}`,r},TypeError),X.ERR_INVALID_MODULE_SPECIFIER=Z(`ERR_INVALID_MODULE_SPECIFIER`,(e,t,n=void 0)=>`Invalid module "${e}" ${t}${n?` imported from ${n}`:``}`,TypeError),X.ERR_INVALID_PACKAGE_CONFIG=Z(`ERR_INVALID_PACKAGE_CONFIG`,(e,t,n)=>`Invalid package config ${e}${t?` while importing ${t}`:``}${n?`. ${n}`:``}`,Error),X.ERR_INVALID_PACKAGE_TARGET=Z(`ERR_INVALID_PACKAGE_TARGET`,(e,t,n,r=!1,i=void 0)=>{let a=typeof n==`string`&&!r&&n.length>0&&!n.startsWith(`./`);return t===`.`?(h.default.ok(r===!1),`Invalid "exports" main target ${JSON.stringify(n)} defined in the package config ${e}package.json${i?` imported from ${i}`:``}${a?`; targets must start with "./"`:``}`):`Invalid "${r?`imports`:`exports`}" target ${JSON.stringify(n)} defined for '${t}' in the package config ${e}package.json${i?` imported from ${i}`:``}${a?`; targets must start with "./"`:``}`},Error),X.ERR_MODULE_NOT_FOUND=Z(`ERR_MODULE_NOT_FOUND`,(e,t,n=!1)=>`Cannot find ${n?`module`:`package`} '${e}' imported from ${t}`,Error),X.ERR_NETWORK_IMPORT_DISALLOWED=Z(`ERR_NETWORK_IMPORT_DISALLOWED`,`import of '%s' by %s is not supported: %s`,Error),X.ERR_PACKAGE_IMPORT_NOT_DEFINED=Z(`ERR_PACKAGE_IMPORT_NOT_DEFINED`,(e,t,n)=>`Package import specifier "${e}" is not defined${t?` in package ${t}package.json`:``} imported from ${n}`,TypeError),X.ERR_PACKAGE_PATH_NOT_EXPORTED=Z(`ERR_PACKAGE_PATH_NOT_EXPORTED`,(e,t,n=void 0)=>t===`.`?`No "exports" main defined in ${e}package.json${n?` imported from ${n}`:``}`:`Package subpath '${t}' is not defined by "exports" in ${e}package.json${n?` imported from ${n}`:``}`,Error),X.ERR_UNSUPPORTED_DIR_IMPORT=Z(`ERR_UNSUPPORTED_DIR_IMPORT`,`Directory import '%s' is not supported resolving ES modules imported from %s`,Error),X.ERR_UNSUPPORTED_RESOLVE_REQUEST=Z(`ERR_UNSUPPORTED_RESOLVE_REQUEST`,`Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.`,TypeError),X.ERR_UNKNOWN_FILE_EXTENSION=Z(`ERR_UNKNOWN_FILE_EXTENSION`,(e,t)=>`Unknown file extension "${e}" for ${t}`,TypeError),X.ERR_INVALID_ARG_VALUE=Z(`ERR_INVALID_ARG_VALUE`,(e,t,n=`is invalid`)=>{let r=(0,re.inspect)(t);return r.length>128&&(r=`${r.slice(0,128)}...`),`The ${e.includes(`.`)?`property`:`argument`} '${e}' ${n}. Received ${r}`},TypeError);function Z(e,t,n){return er.set(e,t),nr(n,e)}function nr(e,t){return n;function n(...n){let r=Error.stackTraceLimit;rr()&&(Error.stackTraceLimit=0);let i=new e;rr()&&(Error.stackTraceLimit=r);let a=or(t,n,i);return Object.defineProperties(i,{message:{value:a,enumerable:!1,writable:!0,configurable:!0},toString:{value(){return`${this.name} [${t}]: ${this.message}`},enumerable:!1,writable:!0,configurable:!0}}),ar(i),i.code=t,i}}function rr(){try{if(ne.default.startupSnapshot.isBuildingSnapshot())return!1}catch{}let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Xn.call(e,`writable`)&&e.writable!==void 0?e.writable:e.set!==void 0}function ir(e){let t=`__node_internal_`+e.name;return Object.defineProperty(e,"name",{value:t}),e}const ar=ir(function(e){let t=rr();return t&&(tr=Error.stackTraceLimit,Error.stackTraceLimit=1/0),Error.captureStackTrace(e),t&&(Error.stackTraceLimit=tr),e});function or(e,t,n){let r=er.get(e);if(h.default.ok(r!==void 0,"expected `message` to be found"),typeof r==`function`)return h.default.ok(r.length<=t.length,`Code: ${e}; The provided arguments length (${t.length}) does not match the required ones (${r.length}).`),Reflect.apply(r,n,t);let i=/%[dfijoOs]/g,a=0;for(;i.exec(r)!==null;)a++;return h.default.ok(a===t.length,`Code: ${e}; The provided arguments length (${t.length}) does not match the required ones (${a}).`),t.length===0?r:(t.unshift(r),Reflect.apply(re.format,null,t))}function sr(e){if(e==null)return String(e);if(typeof e==`function`&&e.name)return`function ${e.name}`;if(typeof e==`object`)return e.constructor&&e.constructor.name?`an instance of ${e.constructor.name}`:`${(0,re.inspect)(e,{depth:-1})}`;let t=(0,re.inspect)(e,{colors:!1});return t.length>28&&(t=`${t.slice(0,25)}...`),`type ${typeof e} (${t})`}const cr={}.hasOwnProperty,{ERR_INVALID_PACKAGE_CONFIG:lr}=X,ur=new Map;function dr(e,{base:t,specifier:n}){let r=ur.get(e);if(r)return r;let i;try{i=c.default.readFileSync(p.default.toNamespacedPath(e),`utf8`)}catch(e){let t=e;if(t.code!==`ENOENT`)throw t}let a={exists:!1,pjsonPath:e,main:void 0,name:void 0,type:`none`,exports:void 0,imports:void 0};if(i!==void 0){let r;try{r=JSON.parse(i)}catch(r){let i=r,a=new lr(e,(t?`"${n}" from `:``)+(0,m.fileURLToPath)(t||n),i.message);throw a.cause=i,a}a.exists=!0,cr.call(r,`name`)&&typeof r.name==`string`&&(a.name=r.name),cr.call(r,`main`)&&typeof r.main==`string`&&(a.main=r.main),cr.call(r,`exports`)&&(a.exports=r.exports),cr.call(r,`imports`)&&(a.imports=r.imports),cr.call(r,`type`)&&(r.type===`commonjs`||r.type===`module`)&&(a.type=r.type)}return ur.set(e,a),a}function fr(e){let t=new URL(`package.json`,e);for(;!t.pathname.endsWith(`node_modules/package.json`);){let n=dr((0,m.fileURLToPath)(t),{specifier:e});if(n.exists)return n;let r=t;if(t=new URL(`../package.json`,t),t.pathname===r.pathname)break}return{pjsonPath:(0,m.fileURLToPath)(t),exists:!1,type:`none`}}function pr(e){return fr(e).type}const{ERR_UNKNOWN_FILE_EXTENSION:mr}=X,hr={}.hasOwnProperty,gr={__proto__:null,".cjs":`commonjs`,".js":`module`,".json":`json`,".mjs":`module`};function _r(e){return e&&/\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(e)?`module`:e===`application/json`?`json`:null}const vr={__proto__:null,"data:":yr,"file:":xr,"http:":Sr,"https:":Sr,"node:"(){return`builtin`}};function yr(e){let{1:t}=/^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(e.pathname)||[null,null,null];return _r(t)}function br(e){let t=e.pathname,n=t.length;for(;n--;){let e=t.codePointAt(n);if(e===47)return``;if(e===46)return t.codePointAt(n-1)===47?``:t.slice(n)}return``}function xr(e,t,n){let r=br(e);if(r===`.js`){let t=pr(e);return t===`none`?`commonjs`:t}if(r===``){let t=pr(e);return t===`none`||t===`commonjs`?`commonjs`:`module`}let i=gr[r];if(i)return i;if(n)return;let a=(0,m.fileURLToPath)(e);throw new mr(r,a)}function Sr(){}function Cr(e,t){let n=e.protocol;return hr.call(vr,n)&&vr[n](e,t,!0)||null}const wr=Object.freeze([`node`,`import`]),Tr=new Set(wr);function Er(){return Tr}function Dr(e){return Er()}const Or=RegExp.prototype[Symbol.replace],{ERR_INVALID_MODULE_SPECIFIER:kr,ERR_INVALID_PACKAGE_CONFIG:Ar,ERR_INVALID_PACKAGE_TARGET:jr,ERR_MODULE_NOT_FOUND:Mr,ERR_PACKAGE_IMPORT_NOT_DEFINED:Nr,ERR_PACKAGE_PATH_NOT_EXPORTED:Pr,ERR_UNSUPPORTED_DIR_IMPORT:Fr,ERR_UNSUPPORTED_RESOLVE_REQUEST:Ir}=X,Lr={}.hasOwnProperty,Rr=/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i,zr=/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i,Br=/^\.|%|\\/,Vr=/\*/g,Hr=/%2f|%5c/i,Ur=new Set,Wr=/[/\\]{2}/;function Gr(e,t,n,r,i,a,o){if(g.default.noDeprecation)return;let s=(0,m.fileURLToPath)(r),c=Wr.exec(o?e:t)!==null;g.default.emitWarning(`Use of deprecated ${c?`double slash`:`leading or trailing slash matching`} resolving "${e}" for module request "${t}" ${t===n?``:`matched to "${n}" `}in the "${i?`imports`:`exports`}" field module resolution of the package at ${s}${a?` imported from ${(0,m.fileURLToPath)(a)}`:``}.`,`DeprecationWarning`,`DEP0166`)}function Kr(e,t,n,r){if(g.default.noDeprecation||Cr(e,{parentURL:n.href})!==`module`)return;let i=(0,m.fileURLToPath)(e.href),a=(0,m.fileURLToPath)(new URL(`.`,t)),o=(0,m.fileURLToPath)(n);r?p.default.resolve(a,r)!==i&&g.default.emitWarning(`Package ${a} has a "main" field set to "${r}", excluding the full filename and extension to the resolved file at "${i.slice(a.length)}", imported from ${o}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`,`DeprecationWarning`,`DEP0151`):g.default.emitWarning(`No "main" or "exports" field defined in the package.json for ${a} resolving the main entry point "${i.slice(a.length)}", imported from ${o}.\nDefault "index" lookups for the main are deprecated for ES modules.`,`DeprecationWarning`,`DEP0151`)}function qr(e){try{return(0,c.statSync)(e)}catch{}}function Jr(e){let t=(0,c.statSync)(e,{throwIfNoEntry:!1});return(t?t.isFile():void 0)??!1}function Yr(e,t,n){let r;if(t.main!==void 0){if(r=new URL(t.main,e),Jr(r))return r;let i=[`./${t.main}.js`,`./${t.main}.json`,`./${t.main}.node`,`./${t.main}/index.js`,`./${t.main}/index.json`,`./${t.main}/index.node`],a=-1;for(;++a<i.length&&(r=new URL(i[a],e),!Jr(r));)r=void 0;if(r)return Kr(r,e,n,t.main),r}let i=[`./index.js`,`./index.json`,`./index.node`],a=-1;for(;++a<i.length&&(r=new URL(i[a],e),!Jr(r));)r=void 0;if(r)return Kr(r,e,n,t.main),r;throw new Mr((0,m.fileURLToPath)(new URL(`.`,e)),(0,m.fileURLToPath)(n))}function Xr(e,t,n){if(Hr.exec(e.pathname)!==null)throw new kr(e.pathname,`must not include encoded "/" or "\\" characters`,(0,m.fileURLToPath)(t));let r;try{r=(0,m.fileURLToPath)(e)}catch(n){let r=n;throw Object.defineProperty(r,"input",{value:String(e)}),Object.defineProperty(r,"module",{value:String(t)}),r}let i=qr(r.endsWith(`/`)?r.slice(-1):r);if(i&&i.isDirectory()){let n=new Fr(r,(0,m.fileURLToPath)(t));throw n.url=String(e),n}if(!i||!i.isFile()){let n=new Mr(r||e.pathname,t&&(0,m.fileURLToPath)(t),!0);throw n.url=String(e),n}{let t=(0,c.realpathSync)(r),{search:n,hash:i}=e;e=(0,m.pathToFileURL)(t+(r.endsWith(p.default.sep)?`/`:``)),e.search=n,e.hash=i}return e}function Zr(e,t,n){return new Nr(e,t&&(0,m.fileURLToPath)(new URL(`.`,t)),(0,m.fileURLToPath)(n))}function Qr(e,t,n){return new Pr((0,m.fileURLToPath)(new URL(`.`,t)),e,n&&(0,m.fileURLToPath)(n))}function $r(e,t,n,r,i){let a=`request is not a valid match in pattern "${t}" for the "${r?`imports`:`exports`}" resolution of ${(0,m.fileURLToPath)(n)}`;throw new kr(e,a,i&&(0,m.fileURLToPath)(i))}function ei(e,t,n,r,i){return t=typeof t==`object`&&t?JSON.stringify(t,null,``):`${t}`,new jr((0,m.fileURLToPath)(new URL(`.`,n)),e,t,r,i&&(0,m.fileURLToPath)(i))}function ti(e,t,n,r,i,a,o,s,c){if(t!==``&&!a&&e[e.length-1]!==`/`)throw ei(n,e,r,o,i);if(!e.startsWith(`./`)){if(o&&!e.startsWith(`../`)&&!e.startsWith(`/`)){let n=!1;try{new URL(e),n=!0}catch{}if(!n)return ui(a?Or.call(Vr,e,()=>t):e+t,r,c)}throw ei(n,e,r,o,i)}if(Rr.exec(e.slice(2))!==null)if(zr.exec(e.slice(2))===null){if(!s){let s=a?n.replace(`*`,()=>t):n+t;Gr(a?Or.call(Vr,e,()=>t):e,s,n,r,o,i,!0)}}else throw ei(n,e,r,o,i);let l=new URL(e,r),u=l.pathname,d=new URL(`.`,r).pathname;if(!u.startsWith(d))throw ei(n,e,r,o,i);if(t===``)return l;if(Rr.exec(t)!==null){let c=a?n.replace(`*`,()=>t):n+t;zr.exec(t)===null?s||Gr(a?Or.call(Vr,e,()=>t):e,c,n,r,o,i,!1):$r(c,n,r,o,i)}return a?new URL(Or.call(Vr,l.href,()=>t)):new URL(t,l)}function ni(e){let t=Number(e);return`${t}`===e&&t>=0&&t<4294967295}function ri(e,t,n,r,i,a,o,s,c){if(typeof t==`string`)return ti(t,n,r,e,i,a,o,s,c);if(Array.isArray(t)){let l=t;if(l.length===0)return null;let u,d=-1;for(;++d<l.length;){let t=l[d],f;try{f=ri(e,t,n,r,i,a,o,s,c)}catch(e){let t=e;if(u=t,t.code===`ERR_INVALID_PACKAGE_TARGET`)continue;throw e}if(f!==void 0){if(f===null){u=null;continue}return f}}if(u==null)return null;throw u}if(typeof t==`object`&&t){let l=Object.getOwnPropertyNames(t),u=-1;for(;++u<l.length;){let t=l[u];if(ni(t))throw new Ar((0,m.fileURLToPath)(e),i,`"exports" cannot contain numeric property keys.`)}for(u=-1;++u<l.length;){let d=l[u];if(d==="default"||c&&c.has(d)){let l=t[d],u=ri(e,l,n,r,i,a,o,s,c);if(u===void 0)continue;return u}}return null}if(t===null)return null;throw ei(r,t,e,o,i)}function ii(e,t,n){if(typeof e==`string`||Array.isArray(e))return!0;if(typeof e!=`object`||!e)return!1;let r=Object.getOwnPropertyNames(e),i=!1,a=0,o=-1;for(;++o<r.length;){let e=r[o],s=e===``||e[0]!==`.`;if(a++===0)i=s;else if(i!==s)throw new Ar((0,m.fileURLToPath)(t),n,`"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`)}return i}function ai(e,t,n){if(g.default.noDeprecation)return;let r=(0,m.fileURLToPath)(t);Ur.has(r+`|`+e)||(Ur.add(r+`|`+e),g.default.emitWarning(`Use of deprecated trailing slash pattern mapping "${e}" in the "exports" field module resolution of the package at ${r}${n?` imported from ${(0,m.fileURLToPath)(n)}`:``}. Mapping specifiers ending in "/" is no longer supported.`,`DeprecationWarning`,`DEP0155`))}function oi(e,t,n,r,i){let a=n.exports;if(ii(a,e,r)&&(a={".":a}),Lr.call(a,t)&&!t.includes(`*`)&&!t.endsWith(`/`)){let n=a[t],o=ri(e,n,``,t,r,!1,!1,!1,i);if(o==null)throw Qr(t,e,r);return o}let o=``,s=``,c=Object.getOwnPropertyNames(a),l=-1;for(;++l<c.length;){let n=c[l],i=n.indexOf(`*`);if(i!==-1&&t.startsWith(n.slice(0,i))){t.endsWith(`/`)&&ai(t,e,r);let a=n.slice(i+1);t.length>=n.length&&t.endsWith(a)&&si(o,n)===1&&n.lastIndexOf(`*`)===i&&(o=n,s=t.slice(i,t.length-a.length))}}if(o){let n=a[o],c=ri(e,n,s,o,r,!0,!1,t.endsWith(`/`),i);if(c==null)throw Qr(t,e,r);return c}throw Qr(t,e,r)}function si(e,t){let n=e.indexOf(`*`),r=t.indexOf(`*`),i=n===-1?e.length:n+1,a=r===-1?t.length:r+1;return i>a?-1:a>i||n===-1?1:r===-1||e.length>t.length?-1:+(t.length>e.length)}function ci(e,t,n){if(e===`#`||e.startsWith(`#/`)||e.endsWith(`/`))throw new kr(e,`is not a valid internal imports specifier name`,(0,m.fileURLToPath)(t));let r,i=fr(t);if(i.exists){r=(0,m.pathToFileURL)(i.pjsonPath);let a=i.imports;if(a)if(Lr.call(a,e)&&!e.includes(`*`)){let i=ri(r,a[e],``,e,t,!1,!0,!1,n);if(i!=null)return i}else{let i=``,o=``,s=Object.getOwnPropertyNames(a),c=-1;for(;++c<s.length;){let t=s[c],n=t.indexOf(`*`);if(n!==-1&&e.startsWith(t.slice(0,-1))){let r=t.slice(n+1);e.length>=t.length&&e.endsWith(r)&&si(i,t)===1&&t.lastIndexOf(`*`)===n&&(i=t,o=e.slice(n,e.length-r.length))}}if(i){let e=a[i],s=ri(r,e,o,i,t,!0,!0,!1,n);if(s!=null)return s}}}throw Zr(e,r,t)}function li(e,t){let n=e.indexOf(`/`),r=!0,i=!1;e[0]===`@`&&(i=!0,n===-1||e.length===0?r=!1:n=e.indexOf(`/`,n+1));let a=n===-1?e:e.slice(0,n);if(Br.exec(a)!==null&&(r=!1),!r)throw new kr(e,`is not a valid package name`,(0,m.fileURLToPath)(t));return{packageName:a,packageSubpath:`.`+(n===-1?``:e.slice(n)),isScoped:i}}function ui(e,t,n){if(te.builtinModules.includes(e))return new URL(`node:`+e);let{packageName:r,packageSubpath:i,isScoped:a}=li(e,t),o=fr(t);if(o.exists){let e=(0,m.pathToFileURL)(o.pjsonPath);if(o.name===r&&o.exports!==void 0&&o.exports!==null)return oi(e,i,o,t,n)}let s=new URL(`./node_modules/`+r+`/package.json`,t),c=(0,m.fileURLToPath)(s),l;do{let o=qr(c.slice(0,-13));if(!o||!o.isDirectory()){l=c,s=new URL((a?`../../../../node_modules/`:`../../../node_modules/`)+r+`/package.json`,s),c=(0,m.fileURLToPath)(s);continue}let u=dr(c,{base:t,specifier:e});return u.exports!==void 0&&u.exports!==null?oi(s,i,u,t,n):i===`.`?Yr(s,u,t):new URL(i,s)}while(c.length!==l.length);throw new Mr(r,(0,m.fileURLToPath)(t),!1)}function di(e){return!(e[0]!==`.`||e.length!==1&&e[1]!==`/`&&(e[1]!==`.`||e.length!==2&&e[2]!==`/`))}function fi(e){return e===``?!1:e[0]===`/`||di(e)}function pi(e,t,n,r){n===void 0&&(n=Dr());let i=t.protocol,a=i===`data:`||i===`http:`||i===`https:`,o;if(fi(e))try{o=new URL(e,t)}catch(n){let r=new Ir(e,t);throw r.cause=n,r}else if(i===`file:`&&e[0]===`#`)o=ci(e,t,n);else try{o=new URL(e)}catch(r){if(a&&!te.builtinModules.includes(e)){let n=new Ir(e,t);throw n.cause=r,n}o=ui(e,t,n)}return h.default.ok(o!==void 0,`expected to be defined`),o.protocol===`file:`?Xr(o,t):o}function mi(e){return typeof e==`string`&&!e.startsWith(`file://`)?Yn(e):Yn((0,m.fileURLToPath)(e))}function hi(e){return(0,m.pathToFileURL)(mi(e)).toString()}function gi(e){return typeof e!=`string`&&(e=e.toString()),/(?:node|data|http|https|file):/.test(e)?e:Jn.has(e)?`node:`+e:`file://`+encodeURI(Yn(e))}const _i=new Set([`node`,`import`]),vi=[`.mjs`,`.cjs`,`.js`,`.json`],yi=new Set([`ERR_MODULE_NOT_FOUND`,`ERR_UNSUPPORTED_DIR_IMPORT`,`MODULE_NOT_FOUND`,`ERR_PACKAGE_PATH_NOT_EXPORTED`]);function bi(e,t,n){try{return pi(e,t,n)}catch(e){if(!yi.has(e?.code))throw e}}function xi(e,t={}){if(typeof e!=`string`)if(e instanceof URL)e=mi(e);else throw TypeError("input must be a `string` or `URL`");if(/(?:node|data|http|https):/.test(e))return e;if(Jn.has(e))return`node:`+e;if(e.startsWith(`file://`)&&(e=mi(e)),He(e))try{if((0,c.statSync)(e).isFile())return hi(e)}catch(e){if(e?.code!==`ENOENT`)throw e}let n=t.conditions?new Set(t.conditions):_i,r=(Array.isArray(t.url)?t.url:[t.url]).filter(Boolean).map(e=>new URL(gi(e.toString())));r.length===0&&r.push(new URL(hi(process.cwd())));let i=[...r];for(let e of r)e.protocol===`file:`&&i.push(new URL(`./`,e),new URL(qn(e.pathname,`_index.js`),e),new URL(`node_modules`,e));let a;for(let r of i){if(a=bi(e,r,n),a)break;for(let i of[``,`/index`]){for(let o of t.extensions||vi)if(a=bi(qn(e,i)+o,r,n),a)break;if(a)break}if(a)break}if(!a){let t=Error(`Cannot find module ${e} imported from ${i.join(`, `)}`);throw t.code=`ERR_MODULE_NOT_FOUND`,t}return hi(a)}function Si(e,t){return xi(e,t)}function Ci(e,t){return mi(Si(e,t))}function wi(e,t){try{return Promise.resolve(Ci(e,t))}catch(e){return Promise.reject(e)}}const Ti=`.all-contributorsrc,.commitlintrc,.github,.git,.husky,.huskyrc,.lintstagedrc,.log4brains.yml,.npmrc,.nx,.storm-workspace.js,.storm-workspace.json,.storm-workspace.ts,.storm-workspace.yaml,.storm-workspace.yml,.vscode,.whitesource,bun.lock,bun.lockb,lefthook.yaml,lefthook.yml,lerna.json,npm-lock.json,npm-lock.yaml,npm-lock.yml,npm-workspace.json,npm-workspace.yaml,npm-workspace.yml,nx.json,package-lock.json,patches,pnpm-lock.json,pnpm-lock.yaml,pnpm-lock.yml,pnpm-workspace.json,pnpm-workspace.yaml,pnpm-workspace.yml,socket.yaml,storm-workspace.js,storm-workspace.json,storm-workspace.ts,storm-workspace.yaml,storm-workspace.yml,syncpack.config.js,syncpack.json,turbo.json,yarn-lock.json,yarn-lock.yaml,yarn-lock.yml,yarn-workspace.json,yarn-workspace.yaml,yarn-workspace.yml,yarn.lock`.split(`,`);function Ei(e=(0,f.cwd)()){if(process.env.STORM_WORKSPACE_ROOT||process.env.NX_WORKSPACE_ROOT_PATH)return process.env.STORM_WORKSPACE_ROOT||process.env.NX_WORKSPACE_ROOT_PATH;let t=Be(e);if(t)return t;let n=Ee(Ti,e);if(n)return n;for(n=e;n&&!(0,ie.isSystemRoot)(n);)if(n=Ee(`storm-workspace.json`,n,{skipCwd:!0,includeNameInResults:!1}),n)return n;return e}const Di=[`js`,`jsx`,`mjs`,`cjs`,`ts`,`tsx`,`mts`,`cts`,`json`,`jsonc`,`json5`,`node`];function Oi(e=[]){let t=e;t.includes((0,f.cwd)())||t.push((0,f.cwd)());let n=Ei();return t.includes(n)||t.push(n),t=(0,ae.getUnique)(t.filter(Boolean).map(e=>(0,_.correctPath)(e)).reduce((e,t,r,i)=>(e.push(t),(0,oe.isAbsolutePath)(t)||(e.push((0,_.toAbsolutePath)(t,(0,f.cwd)())),e.push((0,_.toAbsolutePath)(t,n)),i.forEach(n=>{e.push((0,_.toAbsolutePath)(t,n))})),e),[])),t}function ki(e=[]){return(0,ae.getUnique)(e.reduce((e,t)=>((0,ee.findFolderName)(t)===`node_modules`&&e.push((0,_.correctPath)(t)),we((0,l.joinPaths)(t,`node_modules`))&&e.push((0,_.correctPath)((0,l.joinPaths)(t,`node_modules`))),e),[]))}async function Ai(e,t={}){let n=Oi(t.paths);(0,oe.isNpmScopedPackage)(e)?n=ki(n):n.push(...ki(n));let r,i;try{r=await wi(e,{url:n,extensions:t.extensions??Di,conditions:t.conditions,fs:t.fs?{statSync:t.fs.statSync,realpathSync:t.fs.realpathSync,readFileSync:t.fs.readFileSync,stat:t.fs.promises?.stat,realpath:t.fs.promises?.realpath,readFile:t.fs.promises?.readFile}:void 0})}catch(e){i=e}if(!r)throw Error(`Unable to resolve module "${e}". The following import paths were tried: \n${n.join(`
|
|
11
|
-
`)}`,{cause:i});return(0,_.correctPath)(r)}async function ji(e,t={}){try{return await Ai(e,t)}catch{return}}const Mi=`https://power-plant.invalid/`;function Ni(e){return!(!(0,i.isSetObject)(e)||!(`schema`in e)||`hash`in e||`variant`in e||`source`in e)}function Pi(e){return Ni(e)?e.schema:e}function Fi(e){return e.endsWith(`#`)?e.slice(0,-1):e}function Ii(e){let t=e.indexOf(`#`);return t>=0?e.slice(0,t):e}function Li(e){return e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}function Ri(e){return e.length===0?``:`/${e.map(e=>Li(e)).join(`/`)}`}function zi(e,t){try{return Fi(new URL(e,t).toString())}catch{return Fi(e)}}function Bi(e,t,n,r,a){if(!(0,i.isSetObject)(e))return;let s=e,c=Ri(t),l=(0,o.isSetString)(s.$id)?zi(s.$id,n):n,u=Ii(l);if(r.set(l,c),r.set(u,c),(0,o.isSetString)(s.$anchor)&&r.set(`${u}#${s.$anchor}`,c),(0,o.isSetString)(s.$dynamicAnchor)){let e=`${u}#${s.$dynamicAnchor}`;r.set(e,c),a.set(e,`#${s.$dynamicAnchor}`)}for(let[e,n]of Object.entries(s)){if(Array.isArray(n)){n.forEach((n,i)=>{Bi(n,[...t,e,String(i)],l,r,a)});continue}Bi(n,[...t,e],l,r,a)}}function Vi(e,t,n,r,a){if(!(0,i.isSetObject)(e))return;let s=e,c=(0,o.isSetString)(s.$id)?zi(s.$id,n):n;if((0,o.isSetString)(s.$ref)){let e=zi(s.$ref,c),t=r.get(e)??r.get(Ii(e));t!==void 0&&(s.$ref=t.length>0?`#${t}`:`#`)}if((0,o.isSetString)(s.$dynamicRef)){let e=zi(s.$dynamicRef,c),t=a.get(e);if(t)s.$dynamicRef=t;else{let t=r.get(e)??r.get(Ii(e));t!==void 0&&(s.$dynamicRef=t.length>0?`#${t}`:`#`)}}for(let[e,n]of Object.entries(s)){if(Array.isArray(n)){n.forEach((n,i)=>{Vi(n,[...t,e,String(i)],c,r,a)});continue}Vi(n,[...t,e],c,r,a)}}function Hi(e){if(!(0,i.isSetObject)(e))return e;let t=(0,se.deepClone)(e),n=(0,o.isSetString)(t.$id)?zi(t.$id,Mi):Mi,r=new Map,a=new Map;return Bi(t,[],n,r,a),Vi(t,[],n,r,a),t}function Ui(e){if(n.$(e))return Q(e);if((0,i.isSetObject)(e)){if(n.Z(e))return Ki(e);let t=e;if(`$schema`in t&&n.$(t.$schema))return Q(t.$schema)}return e}function Wi(e){return Array.isArray(e)?e.map(e=>Ui(e)):e}function Gi(e){return(0,me.toJsonSchema)(e,{target:`draft-2020-12`})}function Q(e){let t=e,n={};for(let[e,r]of Object.entries(t))if(e!==`tsType`&&e!==`markdownType`&&e!==`tags`&&e!==`args`&&e!==`resolve`){if(e===`id`&&(0,o.isSetString)(r)){n.$id=r;continue}if(e===`properties`||e===`patternProperties`||e===`dependentSchemas`||e===`$defs`||e===`definitions`){if(!(0,i.isSetObject)(r)){n[e]=r;continue}n[e]=Object.fromEntries(Object.entries(r).map(([e,t])=>[e,Ui(t)]));continue}if(e===`items`||e===`contains`||e===`if`||e===`then`||e===`else`||e===`not`||e===`propertyNames`||e===`additionalProperties`||e===`unevaluatedProperties`){n[e]=Ui(r);continue}if(e===`oneOf`||e===`anyOf`||e===`allOf`){n[e]=Wi(r);continue}n[e]=r}return n}function Ki(e){let t=e,r=n.$(t.$schema)?Q(t.$schema):{},a={};for(let[e,r]of Object.entries(t)){if(e.startsWith(`$`)||!(0,i.isSetObject)(r))continue;if(n.Z(r)){a[e]=Ki(r);continue}let t=r;if(`$schema`in t&&n.$(t.$schema)){a[e]=Q(t.$schema);continue}n.$(r)&&(a[e]=Q(r))}if(!n.N(r))throw Error(`Failed to convert untyped input to JSON Schema. The base schema must be a valid JSON Schema object.`);let o={...(0,i.isSetObject)(r.properties)?r.properties:{},...a};return{...r,type:r.type??`object`,...Object.keys(o).length>0?{properties:o}:{}}}function $(e,t){let r=Pi(t);if(n.Y(r)||n.K(r))return(0,v.murmurhash)({variant:e,input:r.schema});if((0,o.isSetString)(r)||typeof r==`boolean`)return(0,v.murmurhash)({variant:e,input:r});if((0,i.isSetObject)(r)){if((0,pe.isZod3Type)(r))return(0,v.murmurhash)({variant:e,input:r._def});if((0,ce.isStandardJsonSchema)(r))return(0,v.murmurhash)({variant:e,input:r[`~standard`]});if(n.m(r))return(0,v.murmurhash)({variant:e,input:r});if(n.tt(r))return(0,v.murmurhash)({variant:e,input:Gi(r)});if(n.Z(r))return(0,v.murmurhash)({variant:e,input:Ki(r)});if(n.$(r))return(0,v.murmurhash)({variant:e,input:Q(r)})}throw Error(`Failed to create an input hash for the provided schema definition input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, a Valibot BaseSchema, or a reflected Deepkit Type object.`)}function qi(e){if((0,i.isSetObject)(e)){if((0,pe.isZod3Type)(e))return(0,pe.extractJsonSchema)(e,{target:`draft-2020-12`});if(n.Q(e))return Ki(e);if(n.et(e))return Q(e);if((0,ce.isStandardJsonSchema)(e))return e[`~standard`].jsonSchema.input({target:`draft-2020-12`});if(n.tt(e))return Gi(e);if(n.m(e))return e}}function Ji(e){if((0,i.isSetObject)(e)){if((0,pe.isZod3Type)(e))return`zod3`;if(n.Q(e)||n.et(e))return`untyped`;if((0,ce.isStandardJsonSchema)(e))return`standard-schema`;if(n.m(e))return`json-schema`;if(n.tt(e))return`valibot`}throw Error(`Failed to determine the variant of the provided schema definition input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, a Valibot BaseSchema, a reflected Deepkit Type object, or an Untyped schema.`)}function Yi(e){let t=Pi(e);return n.Y(t)||n.K(t)?t.variant:(0,o.isSetString)(t)||n.p(t)?`file-reference`:Ji(t)}async function Xi(e,t){if(n.Y(e))return e.schema;let r=t??Ji(e),i;if((r===`zod3`||r===`json-schema`||r===`standard-schema`||r===`untyped`||r===`valibot`)&&(i=qi(e)),i)return Hi(i);throw Error(`Failed to extract a valid schema from the provided input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, a Valibot BaseSchema, an untyped schema, or a reflected Deepkit Type object.`)}function Zi(e,t){if(e===`zod3`)return{hash:$(e,t),variant:`zod3`,schema:t};if(e===`untyped`)return{hash:$(e,t),variant:`untyped`,schema:t};if(e===`standard-schema`)return{hash:$(e,t),variant:`standard-schema`,schema:t};if(e===`json-schema`)return{hash:$(e,t),variant:`json-schema`,schema:t};if(e===`valibot`)return{hash:$(e,t),variant:`valibot`,schema:t};throw Error(`Failed to extract source information from the provided input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, an untyped schema, or a reflected Deepkit Type object.`)}async function Qi(e,t={}){let n=(0,s.extractFileReference)(e);if(!n)throw Error(`Failed to extract a file reference from the provided input. The input must be a string or an object with a "file" property that specifies the file path and optional export name.`);let r=n.export??`*`,i=await ji(n.file,{fs:t.fs});try{return(0,he.createGenerator)({path:i||n.file,type:r,expose:`all`,jsDoc:`extended`,markdownDescription:!0,fullDescription:!0,skipTypeCheck:!0,...t}).createSchema(r)}catch(e){throw Error(`Failed to generate a JSON schema for "${n.file}"${i&&i!==n.file?` (resolved: ${i})`:``} using the type "${r}". Error: ${e.message}`)}}async function $i(e,t={}){let i=Pi(e);if(n.Y(i))return i;if(n.K(i))return{...i,source:{hash:$(`json-schema`,i.schema),variant:`json-schema`,schema:i.schema}};let a,o=Yi(i),c=$(o,i);if(o===`file-reference`){let e=(0,s.extractFileReference)(i);if(!e)throw Error(`Failed to extract a valid file reference from the provided input "${JSON.stringify(i)}". Please ensure that the input is correctly formatted as a file reference (e.g. "./schema.ts#MySchema") and that the file exists at the specified path.`);let o=(0,le.findFileExtensionSafe)(e.file);if(o&&!ue.VALID_OBJECT_SOURCE_EXTENSIONS.includes(o))throw Error(`The provided schema file input "${e.file}" has an invalid file extension (.${o}). Please ensure that the file has one of the following extensions: ${(0,fe.list)(ue.VALID_OBJECT_SOURCE_EXTENSIONS,{conjunction:`or`})}.`);let c;t.storage&&(c=r.t(t.storage));let l=await(0,de.loadSafe)(i,{...t,fs:c});l??=await Qi(i,{...t,fs:c});let u=Pi(l);a=n.Y(u)?u.source:n.K(u)?{hash:$(`json-schema`,u.schema),variant:`json-schema`,schema:u.schema}:Zi(Ji(u),u)}else if([`json-schema`,`standard-schema`,`zod3`,`untyped`,`valibot`,`reflection`].includes(o))a=Zi(o,i);else throw Error(`Invalid schema definition input "${o}". The variant must be one of "file-reference", "json-schema", "standard-schema", "zod3", "valibot", "untyped", or "reflection".`);return{variant:o,source:a,schema:await Xi(a.schema,a.variant),hash:c}}async function ea(e,t={}){let r=Pi(e);if(n.Y(r)||n.J(r))return r;let i=await $i(e,t);if(!i?.schema)throw Error(`Failed to extract a valid schema from the provided input. The input must be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a reflected Deepkit Type object.`);return i}exports.JSON_SCHEMA_METADATA_KEYS=t.t,exports.JSON_SCHEMA_PRIMITIVE_TYPES=t.n,exports.JSON_SCHEMA_TYPES=t.r,exports.JsonSchemaTypeNames=t.i,exports.SCHEMA_ARRAY_CONCAT_KEYWORDS=t.a,exports.SCHEMA_RECORD_KEYWORDS=t.o,exports.SCHEMA_SINGLE_KEYWORDS=t.s,exports.addProperty=n.t,exports.applyJsonSchemaMetadata=n.nt,exports.assertSchemasDoNotContradict=Ce,exports.bundleReferences=Hi,exports.createStoragePromises=r.n,exports.extract=ea,exports.extractHash=$,exports.extractJsonSchema=qi,exports.extractResolvedVariant=Ji,exports.extractSchema=Xi,exports.extractSchemaWithSource=$i,exports.extractSource=Zi,exports.extractTSType=Qi,exports.extractVariant=Yi,exports.findSchemaContradictions=Se,exports.getJsonSchema=n.n,exports.getJsonSchemaObject=n.r,exports.getPrimarySchemaType=n.rt,exports.getProperties=n.i,exports.getPropertiesList=n.a,exports.getProperty=n.o,exports.isFileReference=n.p,exports.isJsonSchema=n.m,exports.isJsonSchemaAllOf=n.h,exports.isJsonSchemaAny=n.g,exports.isJsonSchemaAnyOf=n._,exports.isJsonSchemaArray=n.v,exports.isJsonSchemaBigint=n.y,exports.isJsonSchemaBoolean=n.b,exports.isJsonSchemaDate=n.x,exports.isJsonSchemaDecimal=n.S,exports.isJsonSchemaEnum=n.C,exports.isJsonSchemaInteger=n.w,exports.isJsonSchemaKeywords=n.T,exports.isJsonSchemaLiteral=n.E,exports.isJsonSchemaMap=n.D,exports.isJsonSchemaNativeEnum=n.O,exports.isJsonSchemaNever=n.k,exports.isJsonSchemaNull=n.A,exports.isJsonSchemaNullable=n.j,exports.isJsonSchemaNumber=n.M,exports.isJsonSchemaObject=n.N,exports.isJsonSchemaPrimitiveType=n.P,exports.isJsonSchemaPrimitiveUnion=n.F,exports.isJsonSchemaRecord=n.I,exports.isJsonSchemaRef=n.L,exports.isJsonSchemaSet=n.R,exports.isJsonSchemaString=n.z,exports.isJsonSchemaTuple=n.B,exports.isJsonSchemaType=n.V,exports.isJsonSchemaUndefined=n.H,exports.isJsonSchemaUnion=n.U,exports.isJsonSchemaUnknown=n.W,exports.isNullOnlyJsonSchema=n.G,exports.isPropertyOptional=n.s,exports.isSchema=n.K,exports.isSchemaNullable=n.c,exports.isSchemaObject=n.q,exports.isSchemaOf=n.J,exports.isSchemaWithSource=n.Y,exports.isStandardSchema=n.X,exports.isUntypedConfig=n.Z,exports.isUntypedConfigStrict=n.Q,exports.isUntypedSchema=n.$,exports.isUntypedSchemaStrict=n.et,exports.isValibotSchema=n.tt,exports.isValidSchemaConfigFile=n.l,exports.mapStorageToFileSystem=r.t,exports.merge=n.u,exports.mergeMetadata=n.d,exports.normalizeKey=r.r,exports.readSchemaTypes=n.it,exports.traverseSchema=n.f;
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_rolldown_runtime = require('./rolldown-runtime-C_NdSu1c.cjs');
|
|
3
|
+
const require_constants = require('./constants-B7xonHLD.cjs');
|
|
4
|
+
const require_helpers = require('./helpers-sXsSapgI.cjs');
|
|
5
|
+
const require_storage = require('./storage-B8aDmNpv.cjs');
|
|
6
|
+
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
7
|
+
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
8
|
+
let _stryke_type_checks = require("@stryke/type-checks");
|
|
9
|
+
let _stryke_convert_extract_file_reference = require("@stryke/convert/extract-file-reference");
|
|
10
|
+
let _stryke_fs_resolve = require("@stryke/fs/resolve");
|
|
11
|
+
let _stryke_hash = require("@stryke/hash");
|
|
12
|
+
let _stryke_helpers_deep_clone = require("@stryke/helpers/deep-clone");
|
|
13
|
+
let _stryke_json = require("@stryke/json");
|
|
14
|
+
let _stryke_path_find = require("@stryke/path/find");
|
|
15
|
+
let _stryke_resolve_constants = require("@stryke/resolve/constants");
|
|
16
|
+
let _stryke_resolve_load = require("@stryke/resolve/load");
|
|
17
|
+
let _stryke_string_format_list = require("@stryke/string-format/list");
|
|
18
|
+
let _stryke_zod = require("@stryke/zod");
|
|
19
|
+
let _typescript_vfs = require("@typescript/vfs");
|
|
20
|
+
let _valibot_to_json_schema = require("@valibot/to-json-schema");
|
|
21
|
+
let node_path = require("node:path");
|
|
22
|
+
let ts_json_schema_generator_dist_factory_generator_js = require("ts-json-schema-generator/dist/factory/generator.js");
|
|
23
|
+
let typescript = require("typescript");
|
|
24
|
+
typescript = require_rolldown_runtime.__toESM(typescript, 1);
|
|
25
|
+
|
|
26
|
+
//#region src/compatibility.ts
|
|
27
|
+
const METADATA_KEYS = /* @__PURE__ */ new Set([
|
|
28
|
+
...require_constants.JSON_SCHEMA_METADATA_KEYS,
|
|
29
|
+
"default",
|
|
30
|
+
"examples"
|
|
31
|
+
]);
|
|
32
|
+
function isMetadataKey(key) {
|
|
33
|
+
return METADATA_KEYS.has(key);
|
|
34
|
+
}
|
|
35
|
+
function isUnconstrainedSchema(schema) {
|
|
36
|
+
if (!(0, _stryke_type_checks_is_set_object.isSetObject)(schema)) return true;
|
|
37
|
+
if (schema.type === "any") return true;
|
|
38
|
+
return Object.keys(schema).filter((key) => !isMetadataKey(key)).length === 0;
|
|
39
|
+
}
|
|
40
|
+
function resolveSchemaTypes(schema) {
|
|
41
|
+
if (isUnconstrainedSchema(schema)) return "any";
|
|
42
|
+
const schemaType = schema.type;
|
|
43
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(schemaType)) return [schemaType];
|
|
44
|
+
if (Array.isArray(schemaType)) return schemaType.filter(_stryke_type_checks_is_set_string.isSetString);
|
|
45
|
+
const primitiveTypes = require_helpers.readSchemaTypes(schema);
|
|
46
|
+
if (primitiveTypes.length > 0) return primitiveTypes;
|
|
47
|
+
if (require_helpers.isJsonSchemaObject(schema)) return ["object"];
|
|
48
|
+
if (require_helpers.isJsonSchemaArray(schema)) return ["array"];
|
|
49
|
+
return "any";
|
|
50
|
+
}
|
|
51
|
+
function formatPath(path) {
|
|
52
|
+
return path.length > 0 ? path : "schema";
|
|
53
|
+
}
|
|
54
|
+
function valuesEqual(left, right) {
|
|
55
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Finds structural contradictions between two JSON Schema fragments.
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* Metadata-only keywords are ignored. Either schema may be unconstrained
|
|
62
|
+
* (`{}`, `{ type: "any" }`, or missing structural keywords) without
|
|
63
|
+
* producing contradictions.
|
|
64
|
+
*
|
|
65
|
+
* @param base - The base JSON Schema fragment.
|
|
66
|
+
* @param override - The JSON Schema fragment to compare against the base.
|
|
67
|
+
* @param path - Optional dot-separated path used in issue messages.
|
|
68
|
+
* @returns A list of human-readable contradiction descriptions.
|
|
69
|
+
*/
|
|
70
|
+
function findSchemaContradictions(base, override, path = "") {
|
|
71
|
+
const issues = [];
|
|
72
|
+
if (isUnconstrainedSchema(base) || isUnconstrainedSchema(override)) return issues;
|
|
73
|
+
const baseTypes = resolveSchemaTypes(base);
|
|
74
|
+
const overrideTypes = resolveSchemaTypes(override);
|
|
75
|
+
if (baseTypes !== "any" && overrideTypes !== "any") {
|
|
76
|
+
if (baseTypes.filter((type) => overrideTypes.includes(type)).length === 0) {
|
|
77
|
+
issues.push(`${formatPath(path)} has conflicting types: ${baseTypes.join("|")} vs ${overrideTypes.join("|")}`);
|
|
78
|
+
return issues;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const baseConst = base.const;
|
|
82
|
+
const overrideConst = override.const;
|
|
83
|
+
if (baseConst !== void 0 && overrideConst !== void 0 && !valuesEqual(baseConst, overrideConst)) issues.push(`${formatPath(path)} has conflicting const values`);
|
|
84
|
+
const baseEnum = base.enum;
|
|
85
|
+
const overrideEnum = override.enum;
|
|
86
|
+
if (baseEnum?.length && overrideEnum?.length) {
|
|
87
|
+
if (!overrideEnum.some((value) => baseEnum.some((baseValue) => valuesEqual(baseValue, value)))) issues.push(`${formatPath(path)} has enum values that do not overlap`);
|
|
88
|
+
}
|
|
89
|
+
if (require_helpers.isJsonSchemaObject(base) && require_helpers.isJsonSchemaObject(override)) {
|
|
90
|
+
const baseProperties = base.properties ?? {};
|
|
91
|
+
const overrideProperties = override.properties ?? {};
|
|
92
|
+
for (const [key, overrideProperty] of Object.entries(overrideProperties)) {
|
|
93
|
+
const baseProperty = baseProperties[key];
|
|
94
|
+
const propertyPath = path ? `${path}.${key}` : key;
|
|
95
|
+
if (baseProperty && require_helpers.isJsonSchema(baseProperty) && require_helpers.isJsonSchema(overrideProperty)) issues.push(...findSchemaContradictions(baseProperty, overrideProperty, propertyPath));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (require_helpers.isJsonSchemaArray(base) && require_helpers.isJsonSchemaArray(override)) {
|
|
99
|
+
const baseItems = base.items;
|
|
100
|
+
const overrideItems = override.items;
|
|
101
|
+
if (baseItems && overrideItems && require_helpers.isJsonSchema(baseItems) && require_helpers.isJsonSchema(overrideItems)) issues.push(...findSchemaContradictions(baseItems, overrideItems, path ? `${path}[]` : "items"));
|
|
102
|
+
const basePrefix = base.prefixItems;
|
|
103
|
+
const overridePrefix = override.prefixItems;
|
|
104
|
+
if (Array.isArray(basePrefix) && Array.isArray(overridePrefix)) {
|
|
105
|
+
const length = Math.min(basePrefix.length, overridePrefix.length);
|
|
106
|
+
for (let index = 0; index < length; index++) {
|
|
107
|
+
const baseItem = basePrefix[index];
|
|
108
|
+
const overrideItem = overridePrefix[index];
|
|
109
|
+
if (require_helpers.isJsonSchema(baseItem) && require_helpers.isJsonSchema(overrideItem)) issues.push(...findSchemaContradictions(baseItem, overrideItem, path ? `${path}[${index}]` : `[${index}]`));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return issues;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Asserts that two JSON Schema fragments do not structurally contradict each other.
|
|
117
|
+
*
|
|
118
|
+
* @param base - The base JSON Schema fragment.
|
|
119
|
+
* @param override - The JSON Schema fragment to compare against the base.
|
|
120
|
+
* @param label - A label used in the thrown error message.
|
|
121
|
+
* @throws {Error} When one or more structural contradictions are found.
|
|
122
|
+
*/
|
|
123
|
+
function assertSchemasDoNotContradict(base, override, label = "schema") {
|
|
124
|
+
const issues = findSchemaContradictions(base, override);
|
|
125
|
+
if (issues.length > 0) throw new Error(`The ${label} schema contradicts the generator schema:\n${issues.map((issue) => `- ${issue}`).join("\n")}`);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/extract.ts
|
|
130
|
+
const SCHEMA_BUNDLE_BASE_URI = "https://power-plant.invalid/";
|
|
131
|
+
const DEFAULT_TS_COMPILER_OPTIONS = {
|
|
132
|
+
noEmit: true,
|
|
133
|
+
emitDecoratorMetadata: true,
|
|
134
|
+
experimentalDecorators: true,
|
|
135
|
+
target: typescript.default.ScriptTarget.ES2022,
|
|
136
|
+
module: typescript.default.ModuleKind.ESNext,
|
|
137
|
+
strictNullChecks: false,
|
|
138
|
+
skipLibCheck: true,
|
|
139
|
+
skipDefaultLibCheck: true,
|
|
140
|
+
esModuleInterop: true
|
|
141
|
+
};
|
|
142
|
+
function readFileAsString(fs, fileName) {
|
|
143
|
+
if (!fs.readFileSync) return;
|
|
144
|
+
try {
|
|
145
|
+
const content = fs.readFileSync(fileName, "utf8");
|
|
146
|
+
return typeof content === "string" ? content : void 0;
|
|
147
|
+
} catch {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function fileExistsOnFs(fs, fileName) {
|
|
152
|
+
if (fs.existsSync) try {
|
|
153
|
+
return fs.existsSync(fileName);
|
|
154
|
+
} catch {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
if (fs.statSync) try {
|
|
158
|
+
fs.statSync(fileName);
|
|
159
|
+
return true;
|
|
160
|
+
} catch {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
return readFileAsString(fs, fileName) !== void 0;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Prefers `options.fs` for System I/O so virtual storage-backed files resolve
|
|
167
|
+
* through createFSBackedSystem instead of only the real disk.
|
|
168
|
+
*/
|
|
169
|
+
function bindFileSystemToSystem(system, fs) {
|
|
170
|
+
const baseFileExists = system.fileExists.bind(system);
|
|
171
|
+
const baseReadFile = system.readFile.bind(system);
|
|
172
|
+
const baseDirectoryExists = system.directoryExists.bind(system);
|
|
173
|
+
const baseRealpath = system.realpath?.bind(system);
|
|
174
|
+
system.fileExists = (fileName) => fileExistsOnFs(fs, fileName) || baseFileExists(fileName);
|
|
175
|
+
system.readFile = (fileName) => {
|
|
176
|
+
if (fileExistsOnFs(fs, fileName)) {
|
|
177
|
+
const content = readFileAsString(fs, fileName);
|
|
178
|
+
if (content !== void 0) return content;
|
|
179
|
+
}
|
|
180
|
+
return baseReadFile(fileName);
|
|
181
|
+
};
|
|
182
|
+
system.directoryExists = (directory) => {
|
|
183
|
+
try {
|
|
184
|
+
if (fs.statSync) {
|
|
185
|
+
if (fs.statSync(directory)?.isDirectory?.()) return true;
|
|
186
|
+
} else if (fs.existsSync?.(directory)) return true;
|
|
187
|
+
} catch {}
|
|
188
|
+
return baseDirectoryExists(directory);
|
|
189
|
+
};
|
|
190
|
+
if (system.realpath && fs.realpathSync) system.realpath = (path) => {
|
|
191
|
+
try {
|
|
192
|
+
return String(fs.realpathSync(path));
|
|
193
|
+
} catch {
|
|
194
|
+
return baseRealpath?.(path) ?? path;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function resolveCompilerOptions(system, tsconfig, fs) {
|
|
199
|
+
if (!tsconfig) return { ...DEFAULT_TS_COMPILER_OPTIONS };
|
|
200
|
+
const raw = (fs ? readFileAsString(fs, tsconfig) : void 0) ?? typescript.default.sys.readFile(tsconfig);
|
|
201
|
+
if (!raw) return { ...DEFAULT_TS_COMPILER_OPTIONS };
|
|
202
|
+
const parsed = typescript.default.parseConfigFileTextToJson(tsconfig, raw);
|
|
203
|
+
if (!parsed.config) return { ...DEFAULT_TS_COMPILER_OPTIONS };
|
|
204
|
+
const options = {
|
|
205
|
+
...typescript.default.parseJsonConfigFileContent(parsed.config, system, (0, node_path.dirname)(tsconfig), {}, tsconfig).options,
|
|
206
|
+
noEmit: true
|
|
207
|
+
};
|
|
208
|
+
delete options.out;
|
|
209
|
+
delete options.outDir;
|
|
210
|
+
delete options.outFile;
|
|
211
|
+
delete options.declaration;
|
|
212
|
+
delete options.declarationDir;
|
|
213
|
+
delete options.declarationMap;
|
|
214
|
+
return options;
|
|
215
|
+
}
|
|
216
|
+
function createProgramFromFileSystem(rootFile, options) {
|
|
217
|
+
const projectRoot = options.cwd ?? (0, node_path.dirname)(rootFile);
|
|
218
|
+
const createSystem = _typescript_vfs.createFSBackedSystem;
|
|
219
|
+
const createHost = _typescript_vfs.createVirtualCompilerHost;
|
|
220
|
+
const system = createSystem(/* @__PURE__ */ new Map(), projectRoot, typescript.default);
|
|
221
|
+
if (options.fs) bindFileSystemToSystem(system, options.fs);
|
|
222
|
+
const compilerOptions = resolveCompilerOptions(system, options.tsconfig, options.fs);
|
|
223
|
+
const { compilerHost } = createHost(system, compilerOptions, typescript.default);
|
|
224
|
+
return typescript.default.createProgram({
|
|
225
|
+
rootNames: [rootFile],
|
|
226
|
+
options: compilerOptions,
|
|
227
|
+
host: compilerHost
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
function isWrappedSchemaConfig(input) {
|
|
231
|
+
if (!(0, _stryke_type_checks_is_set_object.isSetObject)(input) || !("schema" in input)) return false;
|
|
232
|
+
if ("hash" in input || "variant" in input || "source" in input) return false;
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
function unwrapSchemaConfig(input) {
|
|
236
|
+
if (isWrappedSchemaConfig(input)) return input.schema;
|
|
237
|
+
return input;
|
|
238
|
+
}
|
|
239
|
+
function normalizeUri(uri) {
|
|
240
|
+
return uri.endsWith("#") ? uri.slice(0, -1) : uri;
|
|
241
|
+
}
|
|
242
|
+
function stripUriFragment(uri) {
|
|
243
|
+
const hashIndex = uri.indexOf("#");
|
|
244
|
+
return hashIndex >= 0 ? uri.slice(0, hashIndex) : uri;
|
|
245
|
+
}
|
|
246
|
+
function escapeJsonPointerToken(token) {
|
|
247
|
+
return token.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
248
|
+
}
|
|
249
|
+
function toJsonPointer(path) {
|
|
250
|
+
if (path.length === 0) return "";
|
|
251
|
+
return `/${path.map((segment) => escapeJsonPointerToken(segment)).join("/")}`;
|
|
252
|
+
}
|
|
253
|
+
function resolveUri(reference, baseUri) {
|
|
254
|
+
try {
|
|
255
|
+
return normalizeUri(new URL(reference, baseUri).toString());
|
|
256
|
+
} catch {
|
|
257
|
+
return normalizeUri(reference);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function collectReferenceTargets(value, path, baseUri, uriToPointer, dynamicUriToFragment) {
|
|
261
|
+
if (!(0, _stryke_type_checks_is_set_object.isSetObject)(value)) return;
|
|
262
|
+
const schema = value;
|
|
263
|
+
const pointer = toJsonPointer(path);
|
|
264
|
+
const currentBaseUri = (0, _stryke_type_checks.isSetString)(schema.$id) ? resolveUri(schema.$id, baseUri) : baseUri;
|
|
265
|
+
const currentDocumentUri = stripUriFragment(currentBaseUri);
|
|
266
|
+
uriToPointer.set(currentBaseUri, pointer);
|
|
267
|
+
uriToPointer.set(currentDocumentUri, pointer);
|
|
268
|
+
if ((0, _stryke_type_checks.isSetString)(schema.$anchor)) uriToPointer.set(`${currentDocumentUri}#${schema.$anchor}`, pointer);
|
|
269
|
+
if ((0, _stryke_type_checks.isSetString)(schema.$dynamicAnchor)) {
|
|
270
|
+
const dynamicTarget = `${currentDocumentUri}#${schema.$dynamicAnchor}`;
|
|
271
|
+
uriToPointer.set(dynamicTarget, pointer);
|
|
272
|
+
dynamicUriToFragment.set(dynamicTarget, `#${schema.$dynamicAnchor}`);
|
|
273
|
+
}
|
|
274
|
+
for (const [key, child] of Object.entries(schema)) {
|
|
275
|
+
if (Array.isArray(child)) {
|
|
276
|
+
child.forEach((entry, index) => {
|
|
277
|
+
collectReferenceTargets(entry, [
|
|
278
|
+
...path,
|
|
279
|
+
key,
|
|
280
|
+
String(index)
|
|
281
|
+
], currentBaseUri, uriToPointer, dynamicUriToFragment);
|
|
282
|
+
});
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
collectReferenceTargets(child, [...path, key], currentBaseUri, uriToPointer, dynamicUriToFragment);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
function rewriteReferenceTargets(value, path, baseUri, uriToPointer, dynamicUriToFragment) {
|
|
289
|
+
if (!(0, _stryke_type_checks_is_set_object.isSetObject)(value)) return;
|
|
290
|
+
const schema = value;
|
|
291
|
+
const currentBaseUri = (0, _stryke_type_checks.isSetString)(schema.$id) ? resolveUri(schema.$id, baseUri) : baseUri;
|
|
292
|
+
if ((0, _stryke_type_checks.isSetString)(schema.$ref)) {
|
|
293
|
+
const resolvedRefUri = resolveUri(schema.$ref, currentBaseUri);
|
|
294
|
+
const pointer = uriToPointer.get(resolvedRefUri) ?? uriToPointer.get(stripUriFragment(resolvedRefUri));
|
|
295
|
+
if (pointer !== void 0) schema.$ref = pointer.length > 0 ? `#${pointer}` : "#";
|
|
296
|
+
}
|
|
297
|
+
if ((0, _stryke_type_checks.isSetString)(schema.$dynamicRef)) {
|
|
298
|
+
const resolvedDynamicRefUri = resolveUri(schema.$dynamicRef, currentBaseUri);
|
|
299
|
+
const dynamicFragment = dynamicUriToFragment.get(resolvedDynamicRefUri);
|
|
300
|
+
if (dynamicFragment) schema.$dynamicRef = dynamicFragment;
|
|
301
|
+
else {
|
|
302
|
+
const pointer = uriToPointer.get(resolvedDynamicRefUri) ?? uriToPointer.get(stripUriFragment(resolvedDynamicRefUri));
|
|
303
|
+
if (pointer !== void 0) schema.$dynamicRef = pointer.length > 0 ? `#${pointer}` : "#";
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
for (const [key, child] of Object.entries(schema)) {
|
|
307
|
+
if (Array.isArray(child)) {
|
|
308
|
+
child.forEach((entry, index) => {
|
|
309
|
+
rewriteReferenceTargets(entry, [
|
|
310
|
+
...path,
|
|
311
|
+
key,
|
|
312
|
+
String(index)
|
|
313
|
+
], currentBaseUri, uriToPointer, dynamicUriToFragment);
|
|
314
|
+
});
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
rewriteReferenceTargets(child, [...path, key], currentBaseUri, uriToPointer, dynamicUriToFragment);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Bundles all external references in a JSON Schema into a single schema document by collecting all reference targets and rewriting the references to point to the bundled definitions. This ensures that the resulting schema is self-contained and can be used independently without relying on external documents.
|
|
322
|
+
*
|
|
323
|
+
* @param schema - The JSON Schema to bundle references for.
|
|
324
|
+
* @returns A new JSON Schema with all references bundled and rewritten to point to the bundled definitions.
|
|
325
|
+
*/
|
|
326
|
+
function bundleReferences(schema) {
|
|
327
|
+
if (!(0, _stryke_type_checks_is_set_object.isSetObject)(schema)) return schema;
|
|
328
|
+
const bundledSchema = (0, _stryke_helpers_deep_clone.deepClone)(schema);
|
|
329
|
+
const baseUri = (0, _stryke_type_checks.isSetString)(bundledSchema.$id) ? resolveUri(bundledSchema.$id, SCHEMA_BUNDLE_BASE_URI) : SCHEMA_BUNDLE_BASE_URI;
|
|
330
|
+
const uriToPointer = /* @__PURE__ */ new Map();
|
|
331
|
+
const dynamicUriToFragment = /* @__PURE__ */ new Map();
|
|
332
|
+
collectReferenceTargets(bundledSchema, [], baseUri, uriToPointer, dynamicUriToFragment);
|
|
333
|
+
rewriteReferenceTargets(bundledSchema, [], baseUri, uriToPointer, dynamicUriToFragment);
|
|
334
|
+
return bundledSchema;
|
|
335
|
+
}
|
|
336
|
+
function convertNestedUntypedSchema(value) {
|
|
337
|
+
if (require_helpers.isUntypedSchema(value)) return convertUntypedSchemaToJsonSchema(value);
|
|
338
|
+
if ((0, _stryke_type_checks_is_set_object.isSetObject)(value)) {
|
|
339
|
+
if (require_helpers.isUntypedConfig(value)) return convertUntypedConfigToJsonSchema(value);
|
|
340
|
+
const nested = value;
|
|
341
|
+
if ("$schema" in nested && require_helpers.isUntypedSchema(nested.$schema)) return convertUntypedSchemaToJsonSchema(nested.$schema);
|
|
342
|
+
}
|
|
343
|
+
return value;
|
|
344
|
+
}
|
|
345
|
+
function convertNestedUntypedSchemaArray(value) {
|
|
346
|
+
if (!Array.isArray(value)) return value;
|
|
347
|
+
return value.map((item) => convertNestedUntypedSchema(item));
|
|
348
|
+
}
|
|
349
|
+
function convertValibotSchemaToJsonSchema(schema) {
|
|
350
|
+
return (0, _valibot_to_json_schema.toJsonSchema)(schema, { target: "draft-2020-12" });
|
|
351
|
+
}
|
|
352
|
+
function convertUntypedSchemaToJsonSchema(schema) {
|
|
353
|
+
const source = schema;
|
|
354
|
+
const jsonSchema = {};
|
|
355
|
+
for (const [key, value] of Object.entries(source)) {
|
|
356
|
+
if (key === "tsType" || key === "markdownType" || key === "tags" || key === "args" || key === "resolve") continue;
|
|
357
|
+
if (key === "id" && (0, _stryke_type_checks.isSetString)(value)) {
|
|
358
|
+
jsonSchema.$id = value;
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
if (key === "properties" || key === "patternProperties" || key === "dependentSchemas" || key === "$defs" || key === "definitions") {
|
|
362
|
+
if (!(0, _stryke_type_checks_is_set_object.isSetObject)(value)) {
|
|
363
|
+
jsonSchema[key] = value;
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
jsonSchema[key] = Object.fromEntries(Object.entries(value).map(([propertyKey, propertyValue]) => [propertyKey, convertNestedUntypedSchema(propertyValue)]));
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
if (key === "items" || key === "contains" || key === "if" || key === "then" || key === "else" || key === "not" || key === "propertyNames" || key === "additionalProperties" || key === "unevaluatedProperties") {
|
|
370
|
+
jsonSchema[key] = convertNestedUntypedSchema(value);
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
if (key === "oneOf" || key === "anyOf" || key === "allOf") {
|
|
374
|
+
jsonSchema[key] = convertNestedUntypedSchemaArray(value);
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
jsonSchema[key] = value;
|
|
378
|
+
}
|
|
379
|
+
return jsonSchema;
|
|
380
|
+
}
|
|
381
|
+
function convertUntypedConfigToJsonSchema(input) {
|
|
382
|
+
const inputObject = input;
|
|
383
|
+
const base = require_helpers.isUntypedSchema(inputObject.$schema) ? convertUntypedSchemaToJsonSchema(inputObject.$schema) : {};
|
|
384
|
+
const properties = {};
|
|
385
|
+
for (const [key, value] of Object.entries(inputObject)) {
|
|
386
|
+
if (key.startsWith("$")) continue;
|
|
387
|
+
if (!(0, _stryke_type_checks_is_set_object.isSetObject)(value)) continue;
|
|
388
|
+
if (require_helpers.isUntypedConfig(value)) {
|
|
389
|
+
properties[key] = convertUntypedConfigToJsonSchema(value);
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
const nested = value;
|
|
393
|
+
if ("$schema" in nested && require_helpers.isUntypedSchema(nested.$schema)) {
|
|
394
|
+
properties[key] = convertUntypedSchemaToJsonSchema(nested.$schema);
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
if (require_helpers.isUntypedSchema(value)) properties[key] = convertUntypedSchemaToJsonSchema(value);
|
|
398
|
+
}
|
|
399
|
+
if (!require_helpers.isJsonSchemaObject(base)) throw new Error(`Failed to convert untyped input to JSON Schema. The base schema must be a valid JSON Schema object.`);
|
|
400
|
+
const mergedProperties = {
|
|
401
|
+
...(0, _stryke_type_checks_is_set_object.isSetObject)(base.properties) ? base.properties : {},
|
|
402
|
+
...properties
|
|
403
|
+
};
|
|
404
|
+
return {
|
|
405
|
+
...base,
|
|
406
|
+
type: base.type ?? "object",
|
|
407
|
+
...Object.keys(mergedProperties).length > 0 ? { properties: mergedProperties } : {}
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Creates a hash string for a given schema definition input.
|
|
412
|
+
*/
|
|
413
|
+
function extractHash(variant, input) {
|
|
414
|
+
const unwrappedConfig = unwrapSchemaConfig(input);
|
|
415
|
+
if (require_helpers.isSchemaWithSource(unwrappedConfig) || require_helpers.isSchema(unwrappedConfig)) return (0, _stryke_hash.murmurhash)({
|
|
416
|
+
variant,
|
|
417
|
+
input: unwrappedConfig.schema
|
|
418
|
+
});
|
|
419
|
+
if ((0, _stryke_type_checks.isSetString)(unwrappedConfig)) return (0, _stryke_hash.murmurhash)({
|
|
420
|
+
variant,
|
|
421
|
+
input: unwrappedConfig
|
|
422
|
+
});
|
|
423
|
+
else if (typeof unwrappedConfig === "boolean") return (0, _stryke_hash.murmurhash)({
|
|
424
|
+
variant,
|
|
425
|
+
input: unwrappedConfig
|
|
426
|
+
});
|
|
427
|
+
else if ((0, _stryke_type_checks_is_set_object.isSetObject)(unwrappedConfig)) {
|
|
428
|
+
if ((0, _stryke_zod.isZod3Type)(unwrappedConfig)) return (0, _stryke_hash.murmurhash)({
|
|
429
|
+
variant,
|
|
430
|
+
input: unwrappedConfig._def
|
|
431
|
+
});
|
|
432
|
+
else if ((0, _stryke_json.isStandardJsonSchema)(unwrappedConfig)) return (0, _stryke_hash.murmurhash)({
|
|
433
|
+
variant,
|
|
434
|
+
input: unwrappedConfig["~standard"]
|
|
435
|
+
});
|
|
436
|
+
else if (require_helpers.isJsonSchema(unwrappedConfig)) return (0, _stryke_hash.murmurhash)({
|
|
437
|
+
variant,
|
|
438
|
+
input: unwrappedConfig
|
|
439
|
+
});
|
|
440
|
+
else if (require_helpers.isValibotSchema(unwrappedConfig)) return (0, _stryke_hash.murmurhash)({
|
|
441
|
+
variant,
|
|
442
|
+
input: convertValibotSchemaToJsonSchema(unwrappedConfig)
|
|
443
|
+
});
|
|
444
|
+
else if (require_helpers.isUntypedConfig(unwrappedConfig)) return (0, _stryke_hash.murmurhash)({
|
|
445
|
+
variant,
|
|
446
|
+
input: convertUntypedConfigToJsonSchema(unwrappedConfig)
|
|
447
|
+
});
|
|
448
|
+
else if (require_helpers.isUntypedSchema(unwrappedConfig)) return (0, _stryke_hash.murmurhash)({
|
|
449
|
+
variant,
|
|
450
|
+
input: convertUntypedSchemaToJsonSchema(unwrappedConfig)
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
throw new Error(`Failed to create an input hash for the provided schema definition input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, a Valibot BaseSchema, or a reflected Deepkit Type object.`);
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Extracts a JSON Schema from Zod, Standard Schema, Valibot, untyped, or JSON Schema inputs.
|
|
457
|
+
*
|
|
458
|
+
* @param schema - The schema input to extract a JSON Schema from.
|
|
459
|
+
* @returns The extracted JSON Schema, or `undefined` if the input is not a supported schema type.
|
|
460
|
+
*/
|
|
461
|
+
function extractJsonSchema(schema) {
|
|
462
|
+
if ((0, _stryke_type_checks_is_set_object.isSetObject)(schema)) {
|
|
463
|
+
if ((0, _stryke_zod.isZod3Type)(schema)) return (0, _stryke_zod.extractJsonSchema)(schema, { target: "draft-2020-12" });
|
|
464
|
+
if (require_helpers.isUntypedConfigStrict(schema)) return convertUntypedConfigToJsonSchema(schema);
|
|
465
|
+
if (require_helpers.isUntypedSchemaStrict(schema)) return convertUntypedSchemaToJsonSchema(schema);
|
|
466
|
+
if ((0, _stryke_json.isStandardJsonSchema)(schema)) return schema["~standard"].jsonSchema.input({ target: "draft-2020-12" });
|
|
467
|
+
if (require_helpers.isValibotSchema(schema)) return convertValibotSchemaToJsonSchema(schema);
|
|
468
|
+
if (require_helpers.isJsonSchema(schema)) return schema;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Resolves the concrete source variant for a schema source input.
|
|
473
|
+
*
|
|
474
|
+
* @param input - The schema source input to inspect.
|
|
475
|
+
* @returns The resolved schema source variant.
|
|
476
|
+
* @throws Will throw an error when the input cannot be mapped to a supported source variant.
|
|
477
|
+
*/
|
|
478
|
+
function extractResolvedVariant(input) {
|
|
479
|
+
if ((0, _stryke_type_checks_is_set_object.isSetObject)(input)) {
|
|
480
|
+
if ((0, _stryke_zod.isZod3Type)(input)) return "zod3";
|
|
481
|
+
else if (require_helpers.isUntypedConfigStrict(input) || require_helpers.isUntypedSchemaStrict(input)) return "untyped";
|
|
482
|
+
else if ((0, _stryke_json.isStandardJsonSchema)(input)) return "standard-schema";
|
|
483
|
+
else if (require_helpers.isJsonSchema(input)) return "json-schema";
|
|
484
|
+
else if (require_helpers.isValibotSchema(input)) return "valibot";
|
|
485
|
+
}
|
|
486
|
+
throw new Error(`Failed to determine the variant of the provided schema definition input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, a Valibot BaseSchema, a reflected Deepkit Type object, or an Untyped schema.`);
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Determines the top-level input variant for schema extraction.
|
|
490
|
+
*
|
|
491
|
+
* @param input - The schema input to classify.
|
|
492
|
+
* @returns The resolved schema input variant.
|
|
493
|
+
*/
|
|
494
|
+
function extractVariant(input) {
|
|
495
|
+
const unwrappedConfig = unwrapSchemaConfig(input);
|
|
496
|
+
if (require_helpers.isSchemaWithSource(unwrappedConfig) || require_helpers.isSchema(unwrappedConfig)) return unwrappedConfig.variant;
|
|
497
|
+
if ((0, _stryke_type_checks.isSetString)(unwrappedConfig) || require_helpers.isFileReference(unwrappedConfig)) return "file-reference";
|
|
498
|
+
return extractResolvedVariant(unwrappedConfig);
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Extracts and normalizes a JSON Schema from a concrete schema source input.
|
|
502
|
+
*
|
|
503
|
+
* @param input - The schema source input to extract from.
|
|
504
|
+
* @param variant - Optional source variant override. When omitted, the variant is inferred from the input.
|
|
505
|
+
* @returns A promise that resolves to a bundled JSON Schema.
|
|
506
|
+
* @throws Will throw an error if no valid JSON Schema can be extracted from the input.
|
|
507
|
+
*/
|
|
508
|
+
async function extractSchema(input, variant) {
|
|
509
|
+
if (require_helpers.isSchemaWithSource(input)) return input.schema;
|
|
510
|
+
const resolvedVariant = variant ?? extractResolvedVariant(input);
|
|
511
|
+
let schema;
|
|
512
|
+
if (resolvedVariant === "zod3" || resolvedVariant === "json-schema" || resolvedVariant === "standard-schema" || resolvedVariant === "untyped" || resolvedVariant === "valibot") schema = extractJsonSchema(input);
|
|
513
|
+
if (schema) return bundleReferences(schema);
|
|
514
|
+
throw new Error(`Failed to extract a valid schema from the provided input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, a Valibot BaseSchema, an untyped schema, or a reflected Deepkit Type object.`);
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Builds source metadata for a schema input using a known source variant.
|
|
518
|
+
*
|
|
519
|
+
* @param variant - The schema source variant associated with the input.
|
|
520
|
+
* @param input - The schema source input to wrap.
|
|
521
|
+
* @returns The normalized schema source payload, including the source hash and variant.
|
|
522
|
+
* @throws Will throw an error if the provided variant is unsupported.
|
|
523
|
+
*/
|
|
524
|
+
function extractSource(variant, input) {
|
|
525
|
+
if (variant === "zod3") return {
|
|
526
|
+
hash: extractHash(variant, input),
|
|
527
|
+
variant: "zod3",
|
|
528
|
+
schema: input
|
|
529
|
+
};
|
|
530
|
+
else if (variant === "untyped") return {
|
|
531
|
+
hash: extractHash(variant, input),
|
|
532
|
+
variant: "untyped",
|
|
533
|
+
schema: input
|
|
534
|
+
};
|
|
535
|
+
else if (variant === "standard-schema") return {
|
|
536
|
+
hash: extractHash(variant, input),
|
|
537
|
+
variant: "standard-schema",
|
|
538
|
+
schema: input
|
|
539
|
+
};
|
|
540
|
+
else if (variant === "json-schema") return {
|
|
541
|
+
hash: extractHash(variant, input),
|
|
542
|
+
variant: "json-schema",
|
|
543
|
+
schema: input
|
|
544
|
+
};
|
|
545
|
+
else if (variant === "valibot") return {
|
|
546
|
+
hash: extractHash(variant, input),
|
|
547
|
+
variant: "valibot",
|
|
548
|
+
schema: input
|
|
549
|
+
};
|
|
550
|
+
throw new Error(`Failed to extract source information from the provided input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, an untyped schema, or a reflected Deepkit Type object.`);
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Resolves a type definition to a JSON Schema. This function passes the provided file reference to ts-json-schema-generator, using the referenced export name as the target type when one is provided.
|
|
554
|
+
*
|
|
555
|
+
* @param input - The type definition to compile. This can be either a string or a {@link FileReference} object.
|
|
556
|
+
* @param options - Optional overrides reserved for API compatibility.
|
|
557
|
+
* @returns A promise that resolves to the generated JSON Schema.
|
|
558
|
+
*/
|
|
559
|
+
async function extractTSType(input, options = {}) {
|
|
560
|
+
const fileReference = (0, _stryke_convert_extract_file_reference.extractFileReference)(input);
|
|
561
|
+
if (!fileReference) throw new Error(`Failed to extract a file reference from the provided input. The input must be a string or an object with a "file" property that specifies the file path and optional export name.`);
|
|
562
|
+
const exportName = fileReference.export ?? "*";
|
|
563
|
+
const resolvedPath = await (0, _stryke_fs_resolve.resolveSafe)(fileReference.file, { fs: options.fs });
|
|
564
|
+
const filePath = resolvedPath || fileReference.file;
|
|
565
|
+
try {
|
|
566
|
+
return (0, ts_json_schema_generator_dist_factory_generator_js.createGenerator)({
|
|
567
|
+
path: filePath,
|
|
568
|
+
type: exportName,
|
|
569
|
+
expose: "all",
|
|
570
|
+
jsDoc: "extended",
|
|
571
|
+
markdownDescription: true,
|
|
572
|
+
fullDescription: true,
|
|
573
|
+
skipTypeCheck: true,
|
|
574
|
+
tsProgram: createProgramFromFileSystem(filePath, options),
|
|
575
|
+
...options
|
|
576
|
+
}).createSchema(exportName);
|
|
577
|
+
} catch (error) {
|
|
578
|
+
throw new Error(`Failed to generate a JSON schema for "${fileReference.file}"${resolvedPath && resolvedPath !== fileReference.file ? ` (resolved: ${resolvedPath})` : ""} using the type "${exportName}". Error: ${error.message}`);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Extracts a JSON Schema from a given schema definition input, which can be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a {@link FileReferenceInput} to an exported TypeScript type definition or any of the previous options. If the input is a {@link FileReferenceInput} (e.g. a file path with an export), the source code will be bundled with [esbuild](esbuild.github.io) using [ts-json-schema-generator](https://github.com/vega/ts-json-schema-generator) to obtain the actual schema definition before extraction.
|
|
583
|
+
*
|
|
584
|
+
* @example
|
|
585
|
+
* ```ts
|
|
586
|
+
* Resolve a schema definition from a JSON schema file
|
|
587
|
+
* const schema1 = await extract(context, "./schemas/my-json-schema.json");
|
|
588
|
+
* // Resolve a schema definition from a TypeScript module export
|
|
589
|
+
* const schema2 = await extract(context, "./schemas.ts#MySchema");
|
|
590
|
+
* // Resolve a schema definition from a JSON Schema object
|
|
591
|
+
* const schema3 = await extract(context, schemaObject);
|
|
592
|
+
* // Resolve a schema definition from a Zod schema
|
|
593
|
+
* const schema4 = await extract(context, zodSchema);
|
|
594
|
+
* // Resolve a schema definition from a Valibot schema
|
|
595
|
+
* const schema5 = await extract(context, valibotSchema);
|
|
596
|
+
* // Resolve a schema definition from an untyped schema
|
|
597
|
+
* const schema6 = await extract(context, untypedSchema);
|
|
598
|
+
* ```
|
|
599
|
+
*
|
|
600
|
+
* @see https://zod.dev/
|
|
601
|
+
* @see https://valibot.dev/
|
|
602
|
+
* @see https://standardschema.dev/json-schema#what-schema-libraries-support-this-spec
|
|
603
|
+
* @see https://json-schema.org/
|
|
604
|
+
* @see https://ajv.js.org/json-type-definition.html
|
|
605
|
+
* @see https://github.com/vega/ts-json-schema-generator
|
|
606
|
+
* @see https://github.com/unjs/untyped
|
|
607
|
+
* @see https://www.typescriptlang.org/docs/handbook/2/types-from-types.html
|
|
608
|
+
*
|
|
609
|
+
* @param input - The schema definition input to extract, which can be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a {@link FileReferenceInput} to an exported TypeScript type definition or any of the previous options.
|
|
610
|
+
* @param options - Optional overrides for the configuration used during extraction.
|
|
611
|
+
* @returns A promise that resolves to the extracted and normalized schema as a JSON Schema object.
|
|
612
|
+
* @throws Will throw an error if the input is not a valid schema definition or if the extraction process fails to produce a valid schema.
|
|
613
|
+
*/
|
|
614
|
+
async function extractSchemaWithSource(input, options = {}) {
|
|
615
|
+
const unwrappedConfig = unwrapSchemaConfig(input);
|
|
616
|
+
if (require_helpers.isSchemaWithSource(unwrappedConfig)) return unwrappedConfig;
|
|
617
|
+
if (require_helpers.isSchema(unwrappedConfig)) return {
|
|
618
|
+
...unwrappedConfig,
|
|
619
|
+
source: {
|
|
620
|
+
hash: extractHash("json-schema", unwrappedConfig.schema),
|
|
621
|
+
variant: "json-schema",
|
|
622
|
+
schema: unwrappedConfig.schema
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
let source;
|
|
626
|
+
const variant = extractVariant(unwrappedConfig);
|
|
627
|
+
const hash = extractHash(variant, unwrappedConfig);
|
|
628
|
+
if (variant === "file-reference") {
|
|
629
|
+
const fileReference = (0, _stryke_convert_extract_file_reference.extractFileReference)(unwrappedConfig);
|
|
630
|
+
if (!fileReference) throw new Error(`Failed to extract a valid file reference from the provided input "${JSON.stringify(unwrappedConfig)}". Please ensure that the input is correctly formatted as a file reference (e.g. "./schema.ts#MySchema") and that the file exists at the specified path.`);
|
|
631
|
+
const extension = (0, _stryke_path_find.findFileExtensionSafe)(fileReference.file);
|
|
632
|
+
if (extension && !_stryke_resolve_constants.VALID_OBJECT_SOURCE_EXTENSIONS.includes(extension)) throw new Error(`The provided schema file input "${fileReference.file}" has an invalid file extension (.${extension}). Please ensure that the file has one of the following extensions: ${(0, _stryke_string_format_list.list)(_stryke_resolve_constants.VALID_OBJECT_SOURCE_EXTENSIONS, { conjunction: "or" })}.`);
|
|
633
|
+
let fs;
|
|
634
|
+
if (options.storage) fs = require_storage.mapStorageToFileSystem(options.storage);
|
|
635
|
+
let resolved = await (0, _stryke_resolve_load.loadSafe)(unwrappedConfig, {
|
|
636
|
+
...options,
|
|
637
|
+
fs
|
|
638
|
+
});
|
|
639
|
+
resolved ??= await extractTSType(unwrappedConfig, {
|
|
640
|
+
...options,
|
|
641
|
+
fs
|
|
642
|
+
});
|
|
643
|
+
const resolvedConfig = unwrapSchemaConfig(resolved);
|
|
644
|
+
if (require_helpers.isSchemaWithSource(resolvedConfig)) source = resolvedConfig.source;
|
|
645
|
+
else if (require_helpers.isSchema(resolvedConfig)) source = {
|
|
646
|
+
hash: extractHash("json-schema", resolvedConfig.schema),
|
|
647
|
+
variant: "json-schema",
|
|
648
|
+
schema: resolvedConfig.schema
|
|
649
|
+
};
|
|
650
|
+
else source = extractSource(extractResolvedVariant(resolvedConfig), resolvedConfig);
|
|
651
|
+
} else if ([
|
|
652
|
+
"json-schema",
|
|
653
|
+
"standard-schema",
|
|
654
|
+
"zod3",
|
|
655
|
+
"untyped",
|
|
656
|
+
"valibot",
|
|
657
|
+
"reflection"
|
|
658
|
+
].includes(variant)) source = extractSource(variant, unwrappedConfig);
|
|
659
|
+
else throw new Error(`Invalid schema definition input "${variant}". The variant must be one of "file-reference", "json-schema", "standard-schema", "zod3", "valibot", "untyped", or "reflection".`);
|
|
660
|
+
return {
|
|
661
|
+
variant,
|
|
662
|
+
source,
|
|
663
|
+
schema: await extractSchema(source.schema, source.variant),
|
|
664
|
+
hash
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Extracts a JSON Schema from a given schema definition input, which can be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a {@link FileReferenceInput} to an exported TypeScript type definition or any of the previous options. If the input is a {@link FileReferenceInput} (e.g. a file path with an export), the source code will be bundled with [esbuild](esbuild.github.io) using [ts-json-schema-generator](https://github.com/vega/ts-json-schema-generator) to obtain the actual schema definition before extraction.
|
|
669
|
+
*
|
|
670
|
+
* @example
|
|
671
|
+
* ```ts
|
|
672
|
+
* Resolve a schema definition from a JSON schema file
|
|
673
|
+
* const schema1 = await extract(context, "./schemas/my-json-schema.json");
|
|
674
|
+
* // Resolve a schema definition from a TypeScript module export
|
|
675
|
+
* const schema2 = await extract(context, "./schemas.ts#MySchema");
|
|
676
|
+
* // Resolve a schema definition from a JSON Schema object
|
|
677
|
+
* const schema3 = await extract(context, schemaObject);
|
|
678
|
+
* // Resolve a schema definition from a Zod schema
|
|
679
|
+
* const schema4 = await extract(context, zodSchema);
|
|
680
|
+
* // Resolve a schema definition from a Valibot schema
|
|
681
|
+
* const schema5 = await extract(context, valibotSchema);
|
|
682
|
+
* // Resolve a schema definition from an untyped schema
|
|
683
|
+
* const schema6 = await extract(context, untypedSchema);
|
|
684
|
+
* ```
|
|
685
|
+
*
|
|
686
|
+
* @see https://zod.dev/
|
|
687
|
+
* @see https://valibot.dev/
|
|
688
|
+
* @see https://standardschema.dev/json-schema#what-schema-libraries-support-this-spec
|
|
689
|
+
* @see https://json-schema.org/
|
|
690
|
+
* @see https://ajv.js.org/json-type-definition.html
|
|
691
|
+
* @see https://github.com/vega/ts-json-schema-generator
|
|
692
|
+
* @see https://github.com/unjs/untyped
|
|
693
|
+
* @see https://www.typescriptlang.org/docs/handbook/2/types-from-types.html
|
|
694
|
+
*
|
|
695
|
+
* @param input - The schema definition input to extract, which can be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a {@link FileReferenceInput} to an exported TypeScript type definition or any of the previous options.
|
|
696
|
+
* @param options - Optional overrides for the configuration used during extraction.
|
|
697
|
+
* @returns A promise that resolves to the extracted and normalized schema as a JSON Schema object.
|
|
698
|
+
* @throws Will throw an error if the input is not a valid schema definition or if the extraction process fails to produce a valid schema.
|
|
699
|
+
*/
|
|
700
|
+
async function extract(input, options = {}) {
|
|
701
|
+
const unwrappedConfig = unwrapSchemaConfig(input);
|
|
702
|
+
if (require_helpers.isSchemaWithSource(unwrappedConfig) || require_helpers.isSchemaOf(unwrappedConfig)) return unwrappedConfig;
|
|
703
|
+
const result = await extractSchemaWithSource(input, options);
|
|
704
|
+
if (!result?.schema) throw new Error(`Failed to extract a valid schema from the provided input. The input must be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a reflected Deepkit Type object.`);
|
|
705
|
+
return result;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
//#endregion
|
|
709
|
+
exports.JSON_SCHEMA_METADATA_KEYS = require_constants.JSON_SCHEMA_METADATA_KEYS;
|
|
710
|
+
exports.JSON_SCHEMA_PRIMITIVE_TYPES = require_constants.JSON_SCHEMA_PRIMITIVE_TYPES;
|
|
711
|
+
exports.JSON_SCHEMA_TYPES = require_constants.JSON_SCHEMA_TYPES;
|
|
712
|
+
exports.JsonSchemaTypeNames = require_constants.JsonSchemaTypeNames;
|
|
713
|
+
exports.SCHEMA_ARRAY_CONCAT_KEYWORDS = require_constants.SCHEMA_ARRAY_CONCAT_KEYWORDS;
|
|
714
|
+
exports.SCHEMA_RECORD_KEYWORDS = require_constants.SCHEMA_RECORD_KEYWORDS;
|
|
715
|
+
exports.SCHEMA_SINGLE_KEYWORDS = require_constants.SCHEMA_SINGLE_KEYWORDS;
|
|
716
|
+
exports.addProperty = require_helpers.addProperty;
|
|
717
|
+
exports.applyJsonSchemaMetadata = require_helpers.applyJsonSchemaMetadata;
|
|
718
|
+
exports.assertSchemasDoNotContradict = assertSchemasDoNotContradict;
|
|
719
|
+
exports.bundleReferences = bundleReferences;
|
|
720
|
+
exports.createStoragePromises = require_storage.createStoragePromises;
|
|
721
|
+
exports.extract = extract;
|
|
722
|
+
exports.extractHash = extractHash;
|
|
723
|
+
exports.extractJsonSchema = extractJsonSchema;
|
|
724
|
+
exports.extractResolvedVariant = extractResolvedVariant;
|
|
725
|
+
exports.extractSchema = extractSchema;
|
|
726
|
+
exports.extractSchemaWithSource = extractSchemaWithSource;
|
|
727
|
+
exports.extractSource = extractSource;
|
|
728
|
+
exports.extractTSType = extractTSType;
|
|
729
|
+
exports.extractVariant = extractVariant;
|
|
730
|
+
exports.findSchemaContradictions = findSchemaContradictions;
|
|
731
|
+
exports.getJsonSchema = require_helpers.getJsonSchema;
|
|
732
|
+
exports.getJsonSchemaObject = require_helpers.getJsonSchemaObject;
|
|
733
|
+
exports.getPrimarySchemaType = require_helpers.getPrimarySchemaType;
|
|
734
|
+
exports.getProperties = require_helpers.getProperties;
|
|
735
|
+
exports.getPropertiesList = require_helpers.getPropertiesList;
|
|
736
|
+
exports.getProperty = require_helpers.getProperty;
|
|
737
|
+
exports.isFileReference = require_helpers.isFileReference;
|
|
738
|
+
exports.isJsonSchema = require_helpers.isJsonSchema;
|
|
739
|
+
exports.isJsonSchemaAllOf = require_helpers.isJsonSchemaAllOf;
|
|
740
|
+
exports.isJsonSchemaAny = require_helpers.isJsonSchemaAny;
|
|
741
|
+
exports.isJsonSchemaAnyOf = require_helpers.isJsonSchemaAnyOf;
|
|
742
|
+
exports.isJsonSchemaArray = require_helpers.isJsonSchemaArray;
|
|
743
|
+
exports.isJsonSchemaBigint = require_helpers.isJsonSchemaBigint;
|
|
744
|
+
exports.isJsonSchemaBoolean = require_helpers.isJsonSchemaBoolean;
|
|
745
|
+
exports.isJsonSchemaDate = require_helpers.isJsonSchemaDate;
|
|
746
|
+
exports.isJsonSchemaDecimal = require_helpers.isJsonSchemaDecimal;
|
|
747
|
+
exports.isJsonSchemaEnum = require_helpers.isJsonSchemaEnum;
|
|
748
|
+
exports.isJsonSchemaInteger = require_helpers.isJsonSchemaInteger;
|
|
749
|
+
exports.isJsonSchemaKeywords = require_helpers.isJsonSchemaKeywords;
|
|
750
|
+
exports.isJsonSchemaLiteral = require_helpers.isJsonSchemaLiteral;
|
|
751
|
+
exports.isJsonSchemaMap = require_helpers.isJsonSchemaMap;
|
|
752
|
+
exports.isJsonSchemaNativeEnum = require_helpers.isJsonSchemaNativeEnum;
|
|
753
|
+
exports.isJsonSchemaNever = require_helpers.isJsonSchemaNever;
|
|
754
|
+
exports.isJsonSchemaNull = require_helpers.isJsonSchemaNull;
|
|
755
|
+
exports.isJsonSchemaNullable = require_helpers.isJsonSchemaNullable;
|
|
756
|
+
exports.isJsonSchemaNumber = require_helpers.isJsonSchemaNumber;
|
|
757
|
+
exports.isJsonSchemaObject = require_helpers.isJsonSchemaObject;
|
|
758
|
+
exports.isJsonSchemaPrimitiveType = require_helpers.isJsonSchemaPrimitiveType;
|
|
759
|
+
exports.isJsonSchemaPrimitiveUnion = require_helpers.isJsonSchemaPrimitiveUnion;
|
|
760
|
+
exports.isJsonSchemaRecord = require_helpers.isJsonSchemaRecord;
|
|
761
|
+
exports.isJsonSchemaRef = require_helpers.isJsonSchemaRef;
|
|
762
|
+
exports.isJsonSchemaSet = require_helpers.isJsonSchemaSet;
|
|
763
|
+
exports.isJsonSchemaString = require_helpers.isJsonSchemaString;
|
|
764
|
+
exports.isJsonSchemaTuple = require_helpers.isJsonSchemaTuple;
|
|
765
|
+
exports.isJsonSchemaType = require_helpers.isJsonSchemaType;
|
|
766
|
+
exports.isJsonSchemaUndefined = require_helpers.isJsonSchemaUndefined;
|
|
767
|
+
exports.isJsonSchemaUnion = require_helpers.isJsonSchemaUnion;
|
|
768
|
+
exports.isJsonSchemaUnknown = require_helpers.isJsonSchemaUnknown;
|
|
769
|
+
exports.isNullOnlyJsonSchema = require_helpers.isNullOnlyJsonSchema;
|
|
770
|
+
exports.isPropertyOptional = require_helpers.isPropertyOptional;
|
|
771
|
+
exports.isSchema = require_helpers.isSchema;
|
|
772
|
+
exports.isSchemaNullable = require_helpers.isSchemaNullable;
|
|
773
|
+
exports.isSchemaObject = require_helpers.isSchemaObject;
|
|
774
|
+
exports.isSchemaOf = require_helpers.isSchemaOf;
|
|
775
|
+
exports.isSchemaWithSource = require_helpers.isSchemaWithSource;
|
|
776
|
+
exports.isStandardSchema = require_helpers.isStandardSchema;
|
|
777
|
+
exports.isUntypedConfig = require_helpers.isUntypedConfig;
|
|
778
|
+
exports.isUntypedConfigStrict = require_helpers.isUntypedConfigStrict;
|
|
779
|
+
exports.isUntypedSchema = require_helpers.isUntypedSchema;
|
|
780
|
+
exports.isUntypedSchemaStrict = require_helpers.isUntypedSchemaStrict;
|
|
781
|
+
exports.isValibotSchema = require_helpers.isValibotSchema;
|
|
782
|
+
exports.isValidSchemaConfigFile = require_helpers.isValidSchemaConfigFile;
|
|
783
|
+
exports.mapStorageToFileSystem = require_storage.mapStorageToFileSystem;
|
|
784
|
+
exports.merge = require_helpers.merge;
|
|
785
|
+
exports.mergeMetadata = require_helpers.mergeMetadata;
|
|
786
|
+
exports.normalizeKey = require_storage.normalizeKey;
|
|
787
|
+
exports.readSchemaTypes = require_helpers.readSchemaTypes;
|
|
788
|
+
exports.traverseSchema = require_helpers.traverseSchema;
|