@dtsx/dtsx 0.11.57 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +1 -1
- package/dist/{chunk-s9937pks.js → chunk-07c41ffx.js} +7 -7
- package/dist/{chunk-qhbdh4gy.js → chunk-0mj07j66.js} +3 -3
- package/dist/chunk-0zwa1tag.js +31 -0
- package/dist/chunk-16rpzfwq.js +10 -0
- package/dist/chunk-253e6nb4.js +3 -0
- package/dist/chunk-27hrxxsh.js +9 -0
- package/dist/{chunk-1b003vaa.js → chunk-27rxm6hh.js} +6 -6
- package/dist/chunk-30ffarqm.js +4 -0
- package/dist/{chunk-kqyqbrcv.js → chunk-37jcvx0v.js} +3 -3
- package/dist/chunk-44a6zpxs.js +3 -0
- package/dist/{chunk-xvp60m78.js → chunk-4ce9a877.js} +2 -2
- package/dist/{chunk-587w6ktw.js → chunk-4th0w19y.js} +3 -3
- package/dist/{chunk-mew3f4wh.js → chunk-50r5qs7t.js} +2 -2
- package/dist/chunk-5fgakmq9.js +3 -0
- package/dist/chunk-5tcpge5e.js +56 -0
- package/dist/{chunk-wmzg12wb.js → chunk-5vk2x8ee.js} +2 -2
- package/dist/{chunk-ered54kd.js → chunk-7116bytq.js} +8 -8
- package/dist/{chunk-hqytpz18.js → chunk-78ft65vf.js} +2 -2
- package/dist/{chunk-p023fhce.js → chunk-795w1bb2.js} +3 -3
- package/dist/chunk-7vjbc4z7.js +6 -0
- package/dist/chunk-85r70e8z.js +3 -0
- package/dist/chunk-8t9qp0mq.js +5 -0
- package/dist/chunk-9axwjcna.js +21 -0
- package/dist/{chunk-s3mxfatw.js → chunk-9wgk5qp1.js} +2 -2
- package/dist/{chunk-b1wmavr8.js → chunk-am4b9zt0.js} +3 -3
- package/dist/chunk-b5wcbnb8.js +9 -0
- package/dist/{chunk-ss3na6s0.js → chunk-bd048mjd.js} +2 -2
- package/dist/chunk-be7f8t6b.js +3 -0
- package/dist/chunk-bwb12r8r.js +3 -0
- package/dist/chunk-cb5dj4qy.js +3 -0
- package/dist/chunk-chj3hn6f.js +3 -0
- package/dist/chunk-cnb2rfmv.js +21 -0
- package/dist/{chunk-jb43rwce.js → chunk-cs6538bw.js} +2 -2
- package/dist/chunk-d99qykzn.js +6 -0
- package/dist/{chunk-31t6c3q1.js → chunk-e12f4mpd.js} +21 -21
- package/dist/chunk-e21ap86b.js +3 -0
- package/dist/{chunk-vs6ay4t3.js → chunk-ezhvnzja.js} +2 -2
- package/dist/chunk-fnd5bvfd.js +3 -0
- package/dist/chunk-fwqdc8fd.js +3 -0
- package/dist/{chunk-yd8rwwzf.js → chunk-gkfchhnr.js} +2 -2
- package/dist/chunk-h9gwg4kt.js +9 -0
- package/dist/chunk-hd2bq1j5.js +6 -0
- package/dist/{chunk-14zb70ca.js → chunk-hpdmtzhk.js} +3 -3
- package/dist/{chunk-v6fwy63g.js → chunk-j2bapmng.js} +2 -2
- package/dist/{chunk-aa3k6rcj.js → chunk-j41nnny5.js} +2 -2
- package/dist/{chunk-c094c8jt.js → chunk-j60x598n.js} +3 -3
- package/dist/{chunk-8z4tvwyd.js → chunk-javyer70.js} +2 -2
- package/dist/chunk-ke1h5m7f.js +5 -0
- package/dist/chunk-kp395d2p.js +44 -0
- package/dist/{chunk-naweq349.js → chunk-mzw42cv7.js} +2 -2
- package/dist/chunk-n2fm08w5.js +2 -0
- package/dist/chunk-n73yp5s4.js +6 -0
- package/dist/{chunk-zf6qpv30.js → chunk-ne7q6jf2.js} +2 -2
- package/dist/{chunk-srbye4cm.js → chunk-ngb87w7x.js} +7 -7
- package/dist/{chunk-6yvk3q1e.js → chunk-nnayqrp5.js} +2 -2
- package/dist/chunk-p15wwraa.js +3 -0
- package/dist/{chunk-q8dtn1qf.js → chunk-pb7p64tn.js} +2 -2
- package/dist/chunk-peg2exva.js +3 -0
- package/dist/chunk-pjrnfmwm.js +3 -0
- package/dist/{chunk-fnncnk59.js → chunk-pkmjprad.js} +4 -4
- package/dist/{chunk-k2axmtyh.js → chunk-pq6j9bkd.js} +5 -5
- package/dist/chunk-r1t34d75.js +3 -0
- package/dist/chunk-r48h4anw.js +3 -0
- package/dist/chunk-r6bagvr6.js +18 -0
- package/dist/chunk-rnm8937h.js +3 -0
- package/dist/chunk-rv597vq5.js +3 -0
- package/dist/chunk-s7d3d1wx.js +3 -0
- package/dist/{chunk-hnjv8zsq.js → chunk-sqhmhd08.js} +2 -2
- package/dist/{chunk-6bsft59m.js → chunk-t5x9cy8y.js} +5 -5
- package/dist/chunk-t9w6e58q.js +22 -0
- package/dist/chunk-v0gpmwh9.js +8 -0
- package/dist/{chunk-8j311f4n.js → chunk-ves5kf6r.js} +4 -4
- package/dist/{chunk-4rchw3mn.js → chunk-veys7ggd.js} +4 -4
- package/dist/chunk-vjmwxye4.js +3 -0
- package/dist/chunk-war78wdt.js +22 -0
- package/dist/chunk-wfkkp4tx.js +29 -0
- package/dist/{chunk-qg691xj0.js → chunk-x4pxkg7c.js} +4 -4
- package/dist/chunk-xrtfb38p.js +14 -0
- package/dist/chunk-xz57d151.js +3 -0
- package/dist/chunk-y7bcjjqd.js +3 -0
- package/dist/{chunk-5af6meh8.js → chunk-yfgm2ccr.js} +2 -2
- package/dist/{chunk-ysgfcqvf.js → chunk-yje9ebc0.js} +4 -4
- package/dist/chunk-yjkhep5n.js +3 -0
- package/dist/{chunk-ppybvpk4.js → chunk-ykxeeekb.js} +3 -3
- package/dist/{chunk-5egg62em.js → chunk-ypbjr2b6.js} +3 -3
- package/dist/src/augmentation-graph.js +1 -1
- package/dist/src/binding-patterns.js +1 -1
- package/dist/src/branded-types.js +1 -1
- package/dist/src/bundle-linker.d.ts +4 -2
- package/dist/src/bundle-linker.js +1 -1
- package/dist/src/bundler.js +1 -1
- package/dist/src/cache.js +1 -1
- package/dist/src/call-signatures.d.ts +2 -0
- package/dist/src/call-signatures.js +1 -1
- package/dist/src/circular.js +1 -1
- package/dist/src/compat.js +1 -1
- package/dist/src/computed-keys.js +1 -1
- package/dist/src/concurrency.js +1 -1
- package/dist/src/config.js +1 -1
- package/dist/src/dangling-refs.js +1 -1
- package/dist/src/declaration-project.d.ts +4 -2
- package/dist/src/declaration-project.js +1 -1
- package/dist/src/declaration-publication.d.ts +1 -1
- package/dist/src/declaration-publication.js +1 -1
- package/dist/src/declaration-references.js +1 -1
- package/dist/src/diff.js +1 -1
- package/dist/src/docs.js +1 -1
- package/dist/src/enum-declarations.js +1 -1
- package/dist/src/errors.js +1 -1
- package/dist/src/extractor/directives.js +1 -1
- package/dist/src/extractor/extract.js +1 -1
- package/dist/src/extractor/hash.js +1 -1
- package/dist/src/extractor/scanner.d.ts +2 -0
- package/dist/src/extractor/scanner.js +1 -1
- package/dist/src/extractor.js +1 -1
- package/dist/src/formats.js +1 -1
- package/dist/src/formatter.js +1 -1
- package/dist/src/function-properties.js +1 -1
- package/dist/src/generator.js +1 -1
- package/dist/src/global-types.js +1 -1
- package/dist/src/import-sorter.d.ts +6 -6
- package/dist/src/import-sorter.js +1 -1
- package/dist/src/incremental.js +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/inferred-imports.d.ts +5 -1
- package/dist/src/inferred-imports.js +1 -1
- package/dist/src/initializer-type-spans.js +1 -1
- package/dist/src/json-config.js +1 -1
- package/dist/src/lexical.d.ts +3 -0
- package/dist/src/lexical.js +1 -1
- package/dist/src/logger.js +1 -1
- package/dist/src/lsp.js +1 -1
- package/dist/src/memory.js +1 -1
- package/dist/src/merger.js +1 -1
- package/dist/src/module-graph.d.ts +9 -3
- package/dist/src/module-graph.js +1 -1
- package/dist/src/module-references.d.ts +2 -0
- package/dist/src/module-references.js +1 -1
- package/dist/src/native-checker.js +1 -1
- package/dist/src/native-engine.d.ts +24 -0
- package/dist/src/native-engine.js +1 -1
- package/dist/src/native-extractor.js +1 -1
- package/dist/src/native-generation.js +1 -1
- package/dist/src/native-project.js +1 -1
- package/dist/src/numeric-literals.js +1 -1
- package/dist/src/optimizer.js +1 -1
- package/dist/src/output-normalizer.d.ts +5 -5
- package/dist/src/output-normalizer.js +1 -1
- package/dist/src/parallel-processor.js +1 -1
- package/dist/src/parameters.js +1 -1
- package/dist/src/parser.js +1 -1
- package/dist/src/plugins/bun.js +1 -1
- package/dist/src/plugins/esbuild.js +1 -1
- package/dist/src/plugins/index.js +1 -1
- package/dist/src/plugins/tsdown.js +1 -1
- package/dist/src/plugins/tsup.js +1 -1
- package/dist/src/plugins/vite.js +1 -1
- package/dist/src/plugins/webpack.js +1 -1
- package/dist/src/plugins.d.ts +2 -0
- package/dist/src/plugins.js +1 -1
- package/dist/src/process-source.js +1 -1
- package/dist/src/processor/cache.js +1 -1
- package/dist/src/processor/comments.js +1 -1
- package/dist/src/processor/declarations.js +1 -1
- package/dist/src/processor/import-usage.js +1 -1
- package/dist/src/processor/imports.d.ts +3 -1
- package/dist/src/processor/imports.js +1 -1
- package/dist/src/processor/index.js +1 -1
- package/dist/src/processor/type-inference.d.ts +27 -7
- package/dist/src/processor/type-inference.js +1 -1
- package/dist/src/processor.js +1 -1
- package/dist/src/profiling.js +1 -1
- package/dist/src/return-type-scope.js +1 -1
- package/dist/src/security.js +1 -1
- package/dist/src/source-cache.js +1 -1
- package/dist/src/sourcemap.js +1 -1
- package/dist/src/stx.js +1 -1
- package/dist/src/syntax-validator.js +1 -1
- package/dist/src/tracking.js +1 -1
- package/dist/src/transformers.js +1 -1
- package/dist/src/tree-shaker.js +1 -1
- package/dist/src/tsconfig.js +1 -1
- package/dist/src/type-mappings.js +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/src/value-inference.js +1 -1
- package/dist/src/vue.js +1 -1
- package/dist/src/watcher.js +1 -1
- package/dist/src/worker-thread.js +1 -1
- package/dist/src/worker.js +1 -1
- package/dist/src/workspace.js +1 -1
- package/native/darwin-arm64/libzig-dtsx.dylib +0 -0
- package/native/darwin-x64/libzig-dtsx.dylib +0 -0
- package/native/freebsd-x64/libzig-dtsx.so +0 -0
- package/native/linux-arm64/libzig-dtsx.so +0 -0
- package/native/linux-x64/libzig-dtsx.so +0 -0
- package/native/windows-x64/zig-dtsx.dll +0 -0
- package/package.json +1 -1
- package/dist/chunk-3phg2e1n.js +0 -3
- package/dist/chunk-4tk9w4ms.js +0 -2
- package/dist/chunk-59q0p96t.js +0 -3
- package/dist/chunk-5ncggctz.js +0 -3
- package/dist/chunk-5t69y2qj.js +0 -18
- package/dist/chunk-5zcampnz.js +0 -3
- package/dist/chunk-6m4fpfzj.js +0 -31
- package/dist/chunk-6mg1pbfj.js +0 -19
- package/dist/chunk-6rxhkcx0.js +0 -3
- package/dist/chunk-6vhzmpy0.js +0 -8
- package/dist/chunk-7061vwkq.js +0 -4
- package/dist/chunk-72txgcxc.js +0 -3
- package/dist/chunk-93jzvstf.js +0 -3
- package/dist/chunk-9hz32qxh.js +0 -3
- package/dist/chunk-a018gbxq.js +0 -6
- package/dist/chunk-abe0mchv.js +0 -6
- package/dist/chunk-ctpxwa1v.js +0 -3
- package/dist/chunk-dc6thsdb.js +0 -3
- package/dist/chunk-f27fd50q.js +0 -3
- package/dist/chunk-fcx6r0m1.js +0 -22
- package/dist/chunk-fpbcgcwd.js +0 -6
- package/dist/chunk-fxx9zbtq.js +0 -3
- package/dist/chunk-g2s10ehd.js +0 -8
- package/dist/chunk-gzjccs8y.js +0 -27
- package/dist/chunk-h3m1vfa2.js +0 -5
- package/dist/chunk-jhjj15ey.js +0 -38
- package/dist/chunk-mzpbqdd2.js +0 -10
- package/dist/chunk-n8044s0h.js +0 -3
- package/dist/chunk-qhsgmwcm.js +0 -3
- package/dist/chunk-qxkvzznc.js +0 -3
- package/dist/chunk-r7qq9579.js +0 -7
- package/dist/chunk-rb602c8k.js +0 -21
- package/dist/chunk-rcmdt2gs.js +0 -3
- package/dist/chunk-rzjj16rb.js +0 -9
- package/dist/chunk-s28gyv8z.js +0 -3
- package/dist/chunk-s5rja20d.js +0 -3
- package/dist/chunk-szxyqpfq.js +0 -3
- package/dist/chunk-try1hmvs.js +0 -3
- package/dist/chunk-vdt9x6h8.js +0 -29
- package/dist/chunk-vej5fnnp.js +0 -3
- package/dist/chunk-w482p1x8.js +0 -14
- package/dist/chunk-y18th8yp.js +0 -3
- package/dist/chunk-ynpxjf6d.js +0 -4
- package/dist/chunk-ywzc3ym6.js +0 -40
- package/dist/chunk-z03w2v8h.js +0 -3
- package/dist/chunk-zddtg858.js +0 -3
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{a,i,u,c,Te,Je}from"./chunk-ke1h5m7f.js";import{n,f,m,qe,C}from"./chunk-b5wcbnb8.js";import{vr}from"./chunk-javyer70.js";import{fr}from"./chunk-p15wwraa.js";import{$r}from"./chunk-xz57d151.js";import{Q,wr}from"./chunk-30ffarqm.js";import{gt,Sr}from"./chunk-be7f8t6b.js";import{b,v,z}from"./chunk-cs6538bw.js";import{D}from"./chunk-pjrnfmwm.js";import{ze,Ae,He}from"./chunk-gkfchhnr.js";import{r,O,Ue,B,sn,Se,xr,on,Z,oe,ae,ee,cn,P}from"./chunk-kp395d2p.js";import{dr}from"./chunk-27hrxxsh.js";import{w}from"./chunk-cb5dj4qy.js";import{A}from"./chunk-wfkkp4tx.js";import{qt,pr}from"./chunk-peg2exva.js";function ar(F,J,ne,he,be=""){let pe=new Map,h={start:0,end:F.length,header:0,name:"",children:[],results:new Map},ce=n(F),ye=[],x=[],Le=[],st=new Map;for(let fe=0;fe<ce.length;fe++){let Oe=ce[fe];if(Oe.kind!=="punctuation")continue;let Fe=F.slice(Oe.start,Oe.end);if(Fe==="(")Le.push(fe);else if(Fe===")"){let e=Le.pop();if(e!==void 0)st.set(fe,e)}else if(Fe==="{")x.push(fe);else if(Fe==="}"){let e=x.pop();if(e===void 0)continue;let Ve=ce[e].start,G=e-1,X=G>=0?F.slice(ce[G].start,ce[G].end):"";if(X===")"){let we=st.get(G);if(we!==void 0&&we>0&&["if","for","while","switch","catch","with"].includes(F.slice(ce[we-1].start,ce[we-1].end)))Ve=ce[we-1].start}else if(["else","try","finally","do"].includes(X))Ve=ce[G].start;ye.push({open:ce[e].start,close:Oe.start,header:Ve})}}let ie=0,Ne=(fe,Oe=new Set)=>{let Fe=new Set(Oe),e=n(F.slice(fe.start,fe.end)),Ve=0;for(let _e=0;_e+1<e.length;_e++){let Ye=F.slice(fe.start+e[_e].start,fe.start+e[_e].end);if(Ye==="{")Ve++;else if(Ye==="}")Ve--;else if(!Ve&&["type","interface"].includes(Ye))Fe.add(F.slice(fe.start+e[_e+1].start,fe.start+e[_e+1].end))}let G="",X=fe.start,we=[...fe.results].map(([_e,Ye])=>({type:_e,name:Ye}));for(let _e of fe.children.sort((Ye,ft)=>Ye.header-ft.header)){let Ye=Ne(_e,Fe);G+=F.slice(X,_e.header)+`
|
|
3
|
+
declare namespace ${_e.name} {
|
|
4
|
+
${Ye.text}
|
|
5
|
+
}
|
|
6
|
+
`,X=_e.end+1;for(let ft of Ye.exports)we.push({type:`${_e.name}.${ft.name}`,name:ft.name})}G+=`${F.slice(X,fe.end)}
|
|
7
|
+
;
|
|
8
|
+
${we.map((_e)=>`export type ${_e.name} = ${_e.type};`).join(`
|
|
9
|
+
`)}`;let ue=U(G,J,!1);for(let _e of we)Fe.add(_e.name);let Ce=be?Cn(be).map((_e,Ye)=>[_e,`${nt}_capture_${Ye}`]):[],ot=ue.map((_e)=>be&&["type","interface"].includes(_e.kind)?bi(_e,be,Ce,Fe):(_e.kind==="variable"?A(_e,!1):_e.text).replace(/^export\s+/,"").replace(/^declare\s+/,"")).join(`
|
|
10
|
+
`);return{declarations:ue,text:ot,exports:we}},nt;return{resolve(fe,Oe){nt??=ne();let Fe=h;for(let Ve of ye.filter((G)=>G.open<Oe&&Oe<G.close).sort((G,X)=>G.open-X.open)){let G=Fe.children.find((X)=>X.start===Ve.open+1);if(!G)G={start:Ve.open+1,end:Ve.close,header:Ve.header,name:`${nt}_scope_${ie++}`,children:[],results:new Map},Fe.children.push(G);Fe=G}let e=Fe.results.get(fe);if(!e)e=`${nt}_result_${pe.size}`,Fe.results.set(fe,e),pe.set(e,fe);return`${nt}.${e}`},finish(fe){if(!nt)return fe;let Oe=Ne(h),Fe=Oe.declarations,e=new Set(pe.keys());if(Fe.every((G)=>e.has(G.name))){let G=new Map(pe),X=n(fe),we="",ue=0;for(let Ce=0;Ce+2<X.length;Ce++){if(fe.slice(X[Ce].start,X[Ce].end)!==nt||fe.slice(X[Ce+1].start,X[Ce+1].end)!==".")continue;let ot=G.get(fe.slice(X[Ce+2].start,X[Ce+2].end));if(!ot)continue;we+=fe.slice(ue,X[Ce].start)+`(${ot})`,ue=X[Ce+2].end,Ce+=2}return we+fe.slice(ue)}if(be){let G=Cn(be).join(", "),X=n(fe),we="",ue=0;for(let Ce=0;Ce+2<X.length;Ce++){if(fe.slice(X[Ce].start,X[Ce].end)!==nt||fe.slice(X[Ce+1].start,X[Ce+1].end)!=="."||!e.has(fe.slice(X[Ce+2].start,X[Ce+2].end)))continue;we+=`${fe.slice(ue,X[Ce+2].end)}<${G}>`,ue=X[Ce+2].end,Ce+=2}fe=we+fe.slice(ue)}let Ve=Oe.text;return he({kind:"module",name:nt,text:`declare namespace ${nt} {
|
|
11
|
+
${Ve}
|
|
12
|
+
}`,moduleForm:"namespace",isExported:!1}),fe}}}function Cn(F){let J=n(F),ne=[],he=0,be=0,pe=!1;for(let h of J){let ce=F.slice(h.start,h.end);if(ce==="<"){if(he++,he===1)pe=!0}else if(ce===">"&&F[h.start-1]!=="=")he--;else if(["(","[","{"].includes(ce))be++;else if([")","]","}"].includes(ce))be--;else if(ce===","&&he===1&&!be)pe=!0;else if(pe&&h.kind==="word"&&!["const","in","out"].includes(ce))ne.push(ce),pe=!1}return ne}function bi(F,J,ne,he){let be=new Set(Cn(F.generics||"")),pe=(Ne,nt,fe)=>{let Oe=n(Ne),Fe=[{sawExtends:!1,condDepth:0}],e="",Ve=0;for(let G=0;G<Oe.length;G++){let X=Oe[G],we=Ne.slice(X.start,X.end),ue=Fe[Fe.length-1];if(X.kind!=="word"){if(we==="("||we==="["||we==="{"||we==="<")Fe.push({sawExtends:!1,condDepth:0});else if((we===")"||we==="]"||we==="}"||we===">"&&Ne[X.start-1]!=="=")&&Fe.length>1)Fe.pop();else if(we==="?"&&ue.sawExtends)ue.sawExtends=!1,ue.condDepth++;else if(we===":"&&ue.condDepth>0)ue.condDepth--;else if(we===";"&&ue.condDepth===0)ue.sawExtends=!1;continue}if(we==="extends"){ue.sawExtends=!0;continue}let Ce=Oe[G+1]&&Ne.slice(Oe[G+1].start,Oe[G+1].end),ot=Oe[G+2]&&Ne.slice(Oe[G+2].start,Oe[G+2].end),_e=Oe[G-1]&&Ne.slice(Oe[G-1].start,Oe[G-1].end);if(Ce===":"&&ue.condDepth===0||Ce==="?"&&ot===":")continue;let Ye=!fe.has(we)&&_e!=="."&&ne.find(([ft])=>ft===we)?.[1];if(Ye)e+=Ne.slice(Ve,X.start)+Ye,Ve=X.end;else if(nt&&he.has(we)&&!fe.has(we)){let ft=ne.map(([,bt])=>bt).join(", ");if(e+=`${Ne.slice(Ve,X.end)}<${ft}${Ce==="<"?", ":">"}`,Ce==="<")Fe.push({sawExtends:!1,condDepth:0}),Ve=Oe[++G].end;else Ve=X.end}}return e+Ne.slice(Ve)},h=n(F.text),ce=h.findIndex((Ne)=>["type","interface"].includes(F.text.slice(Ne.start,Ne.end))),ye=h[ce+1],x=F.generics||"",Le=x?F.text.indexOf(x,ye.end)+x.length:ye.end,st=pe(ki(J),!1,new Set),ie=x?`, ${pe(x.slice(1,-1),!0,be)}`:"";return`${F.text.slice(0,ye.end)}<${st}${ie}>${pe(F.text.slice(Le),!0,be)}`.replace(/^export\s+/,"").replace(/^declare\s+/,"")}function ki(F){let J=F.slice(1,-1),ne=n(J),he=0,be=0,pe=!1,h="";for(let ce=0;ce<ne.length;ce++){let ye=ne[ce],x=J.slice(ye.start,ye.end);if(["(","[","{","<"].includes(x))he++;else if([")","]","}"].includes(x)||x===">"&&J[ye.start-1]!=="=")he--;else if(!he&&x==="const")h+=J.slice(be,ye.start),be=ye.end;else if(!he&&x==="="&&J.slice(ne[ce+1]?.start,ne[ce+1]?.end)!==">")h+=J.slice(be,ye.start),pe=!0;else if(!he&&x===","&&pe)be=ye.start,pe=!1}return h+(pe?"":J.slice(be))}var Ze=32,Xe=9,Pe=10,Ke=13,Y=47,Ie=42,$e=39,ve=34,Ge=96,lt=92,te=123,le=125,ge=40,xe=41,Ee=91,Be=93,Me=60,Re=62,ke=59,dt=58,We=61,pt=44,Jn=new WeakMap;function cr(F){return Jn.get(F)}var Ct=46,zt=63,jn=35,Gn=64,wi=36;function it(F){return F===Ze||F===Xe||F===Pe||F===Ke}function bn(F){if(F.length<2||F[0]!=="`"||F.at(-1)!=="`")return!1;for(let J=1;J<F.length-1;J++){let ne=F[J];if(ne==="\\"){J++;continue}if(ne==="`"||ne==="$"&&F[J+1]==="{")return!1}return!0}function yi(F){let J=F.trim();if(J==="true"||J==="false")return!0;if(b(J)||v(J)||bn(J))return!0;let ne=J[0];if(ne!=="'"&&ne!=='"'||J.length<2||J.at(-1)!==ne)return!1;for(let he=1;he<J.length-1;he++){let be=J[he];if(be==="\\"){he++;continue}if(be===ne)return!1}return!0}function Un(F){let J=!0;for(let ne=0;ne<F.length;ne++){let he=F.charCodeAt(ne);if(he===Ct){if(J)return!1;J=!0}else if(J){if(!a(he))return!1;J=!1}else if(!i(he))return!1}return F.length>0&&!J}function ht(F,J,ne){let he=J+1;while(he<F.length){let be=F.charCodeAt(he);if(be===lt){he+=2;continue}if(he++,be===ne)break}return he}function xi(F){if(F==="any"||F==="object"||F==="unknown")return!0;if(F.startsWith("Record<")||F.startsWith("Array<"))return!0;return F.charCodeAt(0)===te&&F.includes("[")&&F.includes("]:")}var An=["public","protected","private","readonly","override"];function rc(F,J,ne=!0,he=!1){return he?V(F,J,ne):U(F,J,ne)}function V(F,J,ne=!0){return kn(F,J,ne,!0)}function U(F,J,ne=!0,he){return kn(F,J,ne,!1,!1,he)}function Kt(F,J,ne=!0){return kn(F,J,ne,!0,!0)}function kn(F,J,ne,he,be=!1,pe){let h=F,ce=ne,ye=he,x=h.length,Le=Je(h),st=Q(h),ie=[],Ne=new Map,nt=new Map;function fe(t,o){let s=o.kind==="interface"||o.kind==="type";if(s){let d=nt.get(t);if(d)d.push(o);else nt.set(t,[o])}let l=Ne.get(t);if(!s||!l||l.kind!=="variable"&&l.kind!=="function")Ne.set(t,o)}let Oe=new Map,Fe=new Set,e=0,Ve,G=0,X=[],we=[],ue=[],Ce=[],ot;function _e(t,o=!1){let s=`__dtsx_constructor_field_${Ce.length}__`;if(ot===void 0)ot=h.includes("__dtsx_constructor_field_")?new Set(f(h).filter((l)=>l.kind==="word").map((l)=>h.slice(l.start,l.end)).filter((l)=>l.startsWith("__dtsx_constructor_field_"))):new Set;while(ot.has(s))s+="_";return Ce.push({marker:s,initializer:t,classes:X.map((l)=>l.name),namespaces:[...ue],binding:o}),s}function Ye(t){let o=/^this\.([\w$]+)$/.exec(t);if(o){let k=X.at(-1);return k?.fields.get(`${k.isStatic?"static:":""}${o[1]}`)}let s=/^([\w$]+)\s*\(/.exec(t);if(!s||!t.endsWith(")"))return;let l=n(t),d=0;for(let k=1;k<l.length;k++){let T=t.slice(l[k].start,l[k].end);if(T==="(")d++;else if(T===")"&&--d===0&&k!==l.length-1)return}let p=[...ie,...Ne.values()].filter((k)=>k.kind==="function"&&k.name===s[1]);if(p.length!==1||p[0].generics||fr(h,s[1])!==1)return;return p[0].returnType}function ft(t){let o=t.trim();while(o.length>=2&&o.charCodeAt(0)===40&&o.charCodeAt(o.length-1)===41){let s=0,l=!0;for(let d=0;d<o.length-1;d++){let p=o.charCodeAt(d);if(p===39||p===34||p===96){d++;while(d<o.length-1){if(o.charCodeAt(d)===92){d+=2;continue}if(o.charCodeAt(d)===p)break;d++}continue}if(p===40)s++;else if(p===41){if(s--,s===0){l=!1;break}}}if(!l)break;o=o.slice(1,-1).trim()}return o}function bt(t){let o=ft(t),s=Ye(o);if(s)return s;if(!o.startsWith("class"))return;let l=n(o);if(l[0]?.kind!=="word"||o.slice(l[0].start,l[0].end)!=="class")return;let d;do d=`__dtsx_class_${G++}`;while(h.includes(d));let p=l[1],k=p?o.slice(p.start,p.end):"",T=p?.kind==="word"&&!["extends","implements"].includes(k),g=T?k:`${d}_value`,I=T?`export ${o}`:`export class ${g} ${o.slice(5)}`,R=U(I,J,ce),_=R.find((S)=>S.kind==="class");if(!_)throw Error("Cannot extract the class expression declaration");if(n(I.slice(_.end??I.length)).some((S)=>I.slice((_.end??0)+S.start,(_.end??0)+S.end)!==";"))return;let y=R.map((S)=>S.text.replace(/^export\s+/,"").replace(/^declare\s+/,"")).join(`
|
|
13
|
+
`);return fe(d,{kind:"module",name:d,text:`declare namespace ${d} {
|
|
14
|
+
${y}
|
|
15
|
+
}`,moduleForm:"namespace",isExported:!1,start:e,end:e}),`typeof ${d}.${g}`}function _t(t,o){let s=/^this\.(#?[\w$]+)$/.exec(t);if(s)return X.at(-1)?.fields.get(`${o?"static:":""}${s[1]}`);return bt(t)}function wn(t){let o=Oe.get(t.name);if(o)o.push(t);else Oe.set(t.name,[t]);fe(t.name,t)}if(e<x&&h.charCodeAt(e)===65279)e++;function je(t,o){if(t<o){let s=h.charCodeAt(t),l=h.charCodeAt(o-1);if(s!==Ze&&s!==Xe&&s!==Pe&&s!==Ke&&l!==Ze&&l!==Xe&&l!==Pe&&l!==Ke)return h.slice(t,o)}while(t<o&&it(h.charCodeAt(t)))t++;while(o>t&&it(h.charCodeAt(o-1)))o--;return h.slice(t,o)}let yn=/[\r\n]/g;function St(t){return yn.lastIndex=t,yn.exec(h)?.index??x}let Rt=-1,Pt=!1;function M(){if(e>=x)return;let t=h.charCodeAt(e);if(t!==Ze&&t!==Xe&&t!==Pe&&t!==Ke&&t!==Y)return;let o=e,s=!1;while(e<x){let l=h.charCodeAt(e);if(l===Ze||l===Xe||l===Pe||l===Ke){e++;continue}if(l===Y&&e+1<x){let d=h.charCodeAt(e+1);if(d===Y){s=!0,e=St(e+2);continue}if(d===Ie){s=!0;let p=h.indexOf("*/",e+2);e=p===-1?x:p+2;continue}}break}Pt=o===Rt?Pt||s:s,Rt=e}function Xn(t){if(t.indexOf("//")===-1&&t.indexOf("/*")===-1)return t;let o=0,s=0;while(s<t.length){let l=t.charCodeAt(s);if(l===$e||l===ve||l===Ge){s=ht(t,s,l),o=s;continue}if(l===lt){s+=2,o=Math.min(s,t.length);continue}if(l===Y&&t.charCodeAt(s+1)===Y){while(s<t.length&&t.charCodeAt(s)!==Pe&&t.charCodeAt(s)!==Ke)s++;continue}if(l===Y&&t.charCodeAt(s+1)===Ie){let d=t.indexOf("*/",s+2);s=d===-1?t.length:d+2;continue}if(s++,l>32)o=s}return o<t.length?t.slice(0,o).trimEnd():t}function Yn(t){let o=t.length,s=0,l=o;for(let d=0;d<o;d++){let p=t.charCodeAt(d);if(s){if(p===lt){d++;continue}if(p===s)s=0;continue}if(p===$e||p===ve||p===Ge){s=p;continue}if(p===Y&&d+1<o){let k=t.charCodeAt(d+1);if(k===Y){l=d;while(l>0&&(t.charCodeAt(l-1)===Ze||t.charCodeAt(l-1)===Xe))l--;return t.slice(0,l)}if(k===Ie){let T=t.indexOf("*/",d+2);if(T!==-1){t=`${t.slice(0,d)} ${t.slice(T+2)}`,d--;continue}}}}l=o;while(l>0&&(t.charCodeAt(l-1)===Ze||t.charCodeAt(l-1)===Xe||t.charCodeAt(l-1)===Ke))l--;return l<o?t.slice(0,l):t}function mt(t){e++;let o=t===$e?"'":'"';while(e<x){let s=h.indexOf(o,e);if(s===-1){e=x;return}let l=0,d=s-1;while(d>=0&&h.charCodeAt(d)===lt)l++,d--;if(l%2===0){e=s+1;return}e=s+1}}function Nt(){e++;let t=[];while(e<x){let o=h.charCodeAt(e);if(t.length===0){if(o===lt){e+=2;continue}if(o===Ge){e++;return}if(o===wi&&e+1<x&&h.charCodeAt(e+1)===te){e+=2,t.push(0);continue}e++;continue}if(o===$e||o===ve){mt(o);continue}if(o===Ge){Nt();continue}if(o===Y&&e+1<x){let s=h.charCodeAt(e+1);if(s===Y){e=St(e+2);continue}if(s===Ie){let l=h.indexOf("*/",e+2);e=l===-1?x:l+2;continue}if(xn()){$n();continue}e++;continue}if(o===te){t[t.length-1]++,e++;continue}if(o===le){let s=t[t.length-1];if(s===0){t.pop(),e++;continue}t[t.length-1]=s-1,e++;continue}e++}}let tn=!1;function rt(){tn=!1;let t=h.charCodeAt(e);if(t===$e||t===ve)return mt(t),!0;if(t===Ge)return Nt(),!0;if(t===Y&&e+1<x){let o=h.charCodeAt(e+1);if(o===Y)return e=St(e+2),Pt=!0,Rt=e,!0;if(o===Ie){let s=h.indexOf("*/",e+2);return tn=St(e+2)<(s===-1?x:s),e=s===-1?x:s+2,Pt=!0,Rt=e,!0}if(xn())return $n(),!0}return!1}function xn(){return u(h,e)}function $n(){e=c(h,e)}function Qe(){let t=e;while(e<x&&i(h.charCodeAt(e)))e++;return h.slice(t,e)}function W(t){if(e+t.length>x)return!1;for(let o=0;o<t.length;o++)if(h.charCodeAt(e+o)!==t.charCodeAt(o))return!1;if(e+t.length<x&&i(h.charCodeAt(e+t.length)))return!1;return!0}function Ht(t){let o=e+t;while(o<x){let s=h.charCodeAt(o);if(s===Ze||s===Xe||s===Pe||s===Ke){o++;continue}return s!==Ct&&s!==We}return!1}function vn(){if(!tn)return!1;let t=e;M();let o=e>=x||nn()||h.charCodeAt(e)===le;return e=t,o}function nn(){if(e>=x)return!1;switch(h.charCodeAt(e)){case 101:return W("export")||W("enum");case 105:return W("import")||W("interface");case 102:return W("function");case 99:return W("class")||W("const");case 116:return W("type");case 108:return W("let");case 118:return W("var");case 100:return W("declare")||W("default");case 109:return W("module");case 110:return W("namespace");case 97:return W("abstract")||W("async");default:return!1}}function Tt(){let t=h.charCodeAt(e);if(t!==Pe&&t!==Ke)return!1;let o=e;if(e++,t===Ke&&e<x&&h.charCodeAt(e)===Pe)e++;while(e<x){let l=h.charCodeAt(e);if(l===Ze||l===Xe||l===Ke||l===Pe){e++;continue}if(l===Y&&e+1<x){let d=h.charCodeAt(e+1);if(d===Y){e=St(e+2);continue}if(d===Ie){let p=h.indexOf("*/",e+2);e=p===-1?x:p+2;continue}}break}let s=e>=x||nn()||h.charCodeAt(e)===le;return e=o,s}function ei(t){let o=t-1;while(o>=0){let g=h.charCodeAt(o);if(g===Ze||g===Xe||g===Ke||g===Pe){o--;continue}break}if(o<0)return!0;let s=h[o];if("+-*/%=<>&|^!~?:,.([{".includes(s))return!0;let l=o;while(l>0&&h.charCodeAt(l-1)!==Pe)l--;let d=h.slice(l,o+1),p=d.lastIndexOf("<");if(p!==-1&&/^<[A-Za-z]/.test(d.slice(p))&&!d.slice(p).includes(">"))return!0;let k=o;while(k>=0&&/[a-z]/i.test(h[k]))k--;let T=h.slice(k+1,o+1);return["as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","return","yield","void"].includes(T)}let Vt=new Set(["as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","return","yield","void"]);function ti(t,o){let s=h.charCodeAt(e);if(s!==Pe&&s!==Ke&&!(s===Y&&(h[e+1]==="/"||h[e+1]==="*")))return!1;let l=e,d=!1;while(l<x){let y=h.charCodeAt(l);if(y===Pe||y===Ke)d=!0,l++;else if(y===Ze||y===Xe)l++;else if(y===Y&&h.charCodeAt(l+1)===Y){let S=h.indexOf(`
|
|
16
|
+
`,l+2);l=S===-1?x:S}else if(y===Y&&h.charCodeAt(l+1)===Ie){let S=h.indexOf("*/",l+2),E=S===-1?x:S+2;if(!d&&(h.indexOf(`
|
|
17
|
+
`,l+2)!==-1&&h.indexOf(`
|
|
18
|
+
`,l+2)<E))d=!0;l=E}else break}if(!d)return!1;if(l<x){let y=h[l];if(".?:)]},+-*/%<>=&|^`([".includes(y))return!1;if(y==="a"&&h.startsWith("as",l)&&(l+2>=x||!i(h.charCodeAt(l+2))))return!1;if(y==="s"&&h.startsWith("satisfies",l)&&(l+9>=x||!i(h.charCodeAt(l+9))))return!1;if(y==="i"&&(h.startsWith("instanceof",l)&&(l+10>=x||!i(h.charCodeAt(l+10)))||h.startsWith("in",l)&&(l+2>=x||!i(h.charCodeAt(l+2)))))return!1}let p=e;while(p>t&&h.charCodeAt(p-1)<=32)p--;if(p===t)return!1;let k=h.charCodeAt(p-1),T=Math.max(t,h.lastIndexOf(`
|
|
19
|
+
`,p-1)+1);if(!(k===Y||h.indexOf("//",T)!==-1&&h.indexOf("//",T)<p)){if(o!==void 0&&p===o)return!0;if(k===$e||k===ve||k===Ge||k===le||k===Be||k===xe||k>=48&&k<=57)return!0;if(i(k)){let y=p-1;while(y>t&&i(h.charCodeAt(y-1)))y--;return!Vt.has(h.slice(y,p))}if(k===33){let y=p-1;while(y>t&&(h.charCodeAt(y-1)<=32||h.charCodeAt(y-1)===33))y--;if(y===t)return!1;let S=h.charCodeAt(y-1);if(S===xe||S===Be||S===le||S===$e||S===ve||S===Ge||S>=48&&S<=57)return!0;if(i(S)){let E=y-1;while(E>t&&i(h.charCodeAt(E-1)))E--;return!Vt.has(h.slice(E,y))}return!1}if(k===Re&&p-2>=t&&h.charCodeAt(p-2)===Y)return!0;if(k!==Re&&"+-*/%=<&|^~?:,.([{".includes(h[p-1]))return!1}let I=h.slice(t,e),R=n(I),_=R[R.length-1];if(!_)return!1;let N=I.slice(_.start,_.end);if(t+_.end!==o&&_.kind==="punctuation"){if(N==="!"){let y=R.length-1,S=!1;while(y>0){y--;let E=R[y],L=I.slice(E.start,E.end);if(E.kind==="punctuation"&&L==="!")continue;if(E.kind==="word")S=!Vt.has(L);else if(E.kind==="quoted"||E.kind==="literal")S=!0;else S=L===")"||L==="]"||L==="}";break}if(!S)return!1}else if("+-*/%=<>&|^~?:,.([{".includes(N))return!1}if(_.kind==="word"&&Vt.has(N))return!1;return!0}function Dn(){let t=h.charCodeAt(e);if(t!==Pe&&t!==Ke)return!1;if(ei(e))return!1;let o=e;e++;while(e<x){let d=h.charCodeAt(e);if(d===Ze||d===Xe||d===Ke||d===Pe){e++;continue}if(d===Y&&e+1<x){let p=h.charCodeAt(e+1);if(p===Y){e=St(e+2);continue}if(p===Ie){let k=h.indexOf("*/",e+2);e=k===-1?x:k+2;continue}}break}let s=e<x?h[e]:"",l=s==="|"||s==="&"||s==="["||s==="."||s==="?"||s===":"||s===">"||s===")"||s===","||W("extends");return e=o,!l}function Lt(){let t=h.charCodeAt(e);if(t!==Pe&&t!==Ke)return!1;let o=e;if(e++,t===Ke&&e<x&&h.charCodeAt(e)===Pe)e++;while(e<x){let l=h.charCodeAt(e);if(l===Ze||l===Xe||l===Ke||l===Pe){e++;continue}if(l===Y&&e+1<x&&h.charCodeAt(e+1)===Y){e=St(e+2);continue}break}if(e>=x)return e=o,!0;let s=h.charCodeAt(e);if(s===124||s===38||s===Ct||s===zt||s===dt)return e=o,!1;if(W("extends")||W("keyof")||W("typeof")||W("infer")||W("is")||W("as")||W("in"))return e=o,!1;return e=o,!0}let ni=/[{}'"`\/]/g,ii=/[()'"`\/]/g,si=/[[\]'"`\/]/g,ri=/[<>'"`\/]/g;function et(t,o){let s=1;e++;let l=t===te?ni:t===ge?ii:t===Ee?si:ri;l.lastIndex=e;let d;while((d=l.exec(h))!==null){let p=d.index,k=h.charCodeAt(p);if(k===$e||k===ve){e=p,mt(k),l.lastIndex=e;continue}if(k===Ge){e=p,Nt(),l.lastIndex=e;continue}if(k===Y){if(e=p,rt()){l.lastIndex=e;continue}l.lastIndex=p+1;continue}if(k===t)s++;else if(k===o){if(o===Re&&p>0&&h.charCodeAt(p-1)===We){l.lastIndex=p+1;continue}if(s--,s===0)return e=p+1,e}l.lastIndex=p+1}return e=x,e}function ut(){return e>0&&h.charCodeAt(e-1)===We}function rn(){return e+1<x&&h.charCodeAt(e+1)===Re}let ct=/[<{};'"`\/\n\r()[\]]/g;function tt(t=!1,o=!0){let s=0,l=0,d=0,p=0,k=o&&h.charCodeAt(e)===te;ct.lastIndex=e;let T;while((T=ct.exec(h))!==null){let g=T.index,I=h.charCodeAt(g);if(I===$e||I===ve){e=g,mt(I),ct.lastIndex=e;continue}if(I===Ge){e=g,Nt(),ct.lastIndex=e;continue}if(I===Y){if(g>0&&h.charCodeAt(g-1)===Me){ct.lastIndex=g+1;continue}if(e=g,rt()){if(s===0&&l===0&&d===0&&p===0&&vn())return;ct.lastIndex=e;continue}ct.lastIndex=g+1;continue}if(I===Me){let R=Le(g)?.delta??null;if(R!==null)p=Math.max(0,p+R);ct.lastIndex=g+1;continue}if(I===ge){l++,ct.lastIndex=g+1;continue}if(I===xe){if(l>0)l--;ct.lastIndex=g+1;continue}if(I===Ee){d++,ct.lastIndex=g+1;continue}if(I===Be){if(d>0)d--;ct.lastIndex=g+1;continue}if(I===te){s++,ct.lastIndex=g+1;continue}if(I===le){let R=s>0;if(!R&&t&&l===0&&d===0&&p===0){e=g;return}if(R)s--;if((!R||k)&&s===0&&l===0&&d===0&&p===0){e=g+1;return}if(R&&s===0&&l===0&&d===0&&p===0){e=g+1;let _=e;M();let N=nn();if(e=_,N)return}ct.lastIndex=g+1;continue}if(I===ke&&s===0&&l===0&&d===0&&p===0){e=g+1;return}if((I===Pe||I===Ke)&&s===0&&l===0&&d===0&&p===0){if(e=g,Tt())return}ct.lastIndex=g+1}e=x}function oi(){e++;while(e<x&&(h.charCodeAt(e)===Ze||h.charCodeAt(e)===Xe))e++;let t=h.indexOf(`
|
|
20
|
+
`,e),o=t===-1?x:t,s=h.indexOf(";",e);if(s!==-1&&s<o){let l=s-1;while(l>=e&&(h.charCodeAt(l)===Ze||h.charCodeAt(l)===Xe))l--;let d=h.charCodeAt(e),p=h.charCodeAt(l);if(d===te&&p===le||d===Ee&&p===Be||d===$e&&p===$e||d===ve&&p===ve||d===Ge&&p===Ge){e=s+1;return}}tt()}function an(){let t=e+5,o=!1;while(t<x){let s=h.charCodeAt(t);if(s===Ze||s===Xe)o=!0,t++;else if(s===Y&&h.charCodeAt(t+1)===Ie){let l=h.indexOf("*/",t+2);if(l===-1)return!1;let d=h.slice(t+2,l);if(d.includes(`
|
|
21
|
+
`)||d.includes("\r"))return!1;o=!0,t=l+2}else break}return o&&t<x&&a(h.charCodeAt(t))}function Sn(){let t=e+5,o=!1;while(t<x){let d=h.charCodeAt(t);if(d===Ze||d===Xe)o=!0,t++;else if(d===Y&&h.charCodeAt(t+1)===Ie){let p=h.indexOf("*/",t+2);if(p===-1)return!1;let k=h.slice(t+2,p);if(k.includes(`
|
|
22
|
+
`)||k.includes("\r"))return!1;o=!0,t=p+2}else break}if(!o||!h.startsWith("using",t))return!1;if(t+5<x&&i(h.charCodeAt(t+5)))return!1;let s=e;e=t;let l=an();return e=s,l}function ln(){let t=e;M();let o=W("with")?4:W("assert")?6:0;if(o>0){if(e+=o,M(),e<x&&h.charCodeAt(e)===te){et(te,le);return}}e=t}function In(){et(te,le);while(e<x&&it(h.charCodeAt(e)))e++;if(W("from")){e+=4;while(e<x&&it(h.charCodeAt(e)))e++;if(e<x){let t=h.charCodeAt(e);if(t===$e||t===ve)mt(t),ln()}}while(e<x&&(h.charCodeAt(e)===Ze||h.charCodeAt(e)===Xe))e++;if(e<x&&h.charCodeAt(e)===ke)e++}function On(){e++;while(e<x&&it(h.charCodeAt(e)))e++;if(W("as")){e+=2;while(e<x&&it(h.charCodeAt(e)))e++;if(e<x&&(h.charCodeAt(e)===$e||h.charCodeAt(e)===ve))mt(h.charCodeAt(e));else Qe();while(e<x&&it(h.charCodeAt(e)))e++}if(W("from")){e+=4;while(e<x&&it(h.charCodeAt(e)))e++;if(e<x){let t=h.charCodeAt(e);if(t===$e||t===ve)mt(t),ln()}}while(e<x&&(h.charCodeAt(e)===Ze||h.charCodeAt(e)===Xe))e++;if(e<x&&h.charCodeAt(e)===ke)e++}function jt(t){let o=t.indexOf("from ");if(o===-1)return;let s=o+5;while(s<t.length&&(t.charCodeAt(s)===32||t.charCodeAt(s)===9))s++;if(s>=t.length)return;let l=t.charCodeAt(s);if(l!==39&&l!==34)return;let d=t.indexOf(t[s],s+1);if(d===-1)return;return t.slice(s+1,d)}function _n(t){if(!t.startsWith("///"))return!1;let o=t.slice(3).trimStart();return o.startsWith("<reference ")||o.startsWith("<reference\t")||o.startsWith("<amd-")}function at(t){if(!ce||t===0)return;if(t===Rt&&!Pt)return;let o=t-1;while(o>=0&&it(h.charCodeAt(o)))o--;if(o<0)return;if(!(o>=1&&h.charCodeAt(o)===Y&&h.charCodeAt(o-1)===Ie)){let d=o;while(d>0&&h.charCodeAt(d-1)!==Pe)d--;while(d<=o&&(h.charCodeAt(d)===Ze||h.charCodeAt(d)===Xe||h.charCodeAt(d)===Ke))d++;if(d+1>o||h.charCodeAt(d)!==Y||h.charCodeAt(d+1)!==Y)return}let s=[],l=!1;while(o>=0){if(o>=1&&h.charCodeAt(o)===Y&&h.charCodeAt(o-1)===Ie){let k=h.lastIndexOf("/*",o-2);if(k>=0){s.push(h.slice(k,o+1)),l=!0,o=k-1;while(o>=0&&it(h.charCodeAt(o)))o--;continue}break}let d=o;while(d>0&&h.charCodeAt(d-1)!==Pe)d--;let p=je(d,o+1);if(p.startsWith("//")){if(l||_n(p))break;let k=[p];o=d-1;while(o>=0&&(h.charCodeAt(o)===Pe||h.charCodeAt(o)===Ke))o--;while(o>=0){let T=o;while(T>0&&h.charCodeAt(T-1)!==Pe)T--;let g=je(T,o+1);if(g.startsWith("//")){if(_n(g))break;k.push(g),o=T-1;while(o>=0&&(h.charCodeAt(o)===Pe||h.charCodeAt(o)===Ke))o--}else if(g===""){o=T-1;while(o>=0&&(h.charCodeAt(o)===Pe||h.charCodeAt(o)===Ke))o--}else break}k.reverse(),s.push(k.join(`
|
|
23
|
+
`));continue}break}if(s.length===0)return;return s.reverse(),s}function ci(t){let o=e;if(e+=6,M(),e>=x||!a(h.charCodeAt(e)))return e=o,null;let s=Qe();if(!s)return e=o,null;if(M(),e>=x||h.charCodeAt(e)!==We)return e=o,null;if(e++,M(),W("require")&&Bt("require")===ge)return e=o,null;let l=e;if(!Qe())return e=o,null;while(!0){let T=e;if(M(),e<x&&h.charCodeAt(e)===Ct)e++,M(),Qe();else{e=T;break}}let p=je(l,e);while(e<x&&(h.charCodeAt(e)===Ze||h.charCodeAt(e)===Xe))e++;if(e<x&&h.charCodeAt(e)===ke)e++;let k=at(t);return{kind:"type",name:s,text:`import ${s} = ${p};`,isExported:!1,leadingComments:k,start:t,end:e}}function ai(t){let o=t,s=!1,l=0,d;while(e<x){let N=h.charCodeAt(e);if(N===Y&&(h.charCodeAt(e+1)===Y||h.charCodeAt(e+1)===Ie)){M();continue}if(N===ke){e++;break}if(N===te)l++;else if(N===le&&l>0)l--;if(N===$e||N===ve){if(mt(N),l>0)continue;s=!0;let y=e;if(M(),h.charCodeAt(e)===xe){let S=e+1;d=qe(h.slice(o,S)),e=d?S:y}else e=y,ln();while(e<x&&(h.charCodeAt(e)===Ze||h.charCodeAt(e)===Xe))e++;if(e<x&&h.charCodeAt(e)===ke)e++;break}if(N===Pe&&s)break;e++}let p=je(o,e),k=C(p).find((N)=>N.category==="static-import"),T=n(p),g=d?.isTypeOnly??k?.isTypeOnly??!1,I=T[1]?.kind==="quoted",R=d?.source??k?.specifier??"",_=at(o);return{kind:"import",name:"",text:p,isExported:!1,isTypeOnly:g,isSideEffect:I,source:R,leadingComments:_,start:o,end:e}}function Gt(){let t=e;return et(te,le),h.slice(t,e)}function Tn(t){let o=t.indexOf("(");if(o===-1)return t;let s=t.slice(o);if(s.indexOf("=")===-1)return t;let l=!1;for(let g=0;g<s.length;g++)if(s.charCodeAt(g)===61){let R=g>0?s.charCodeAt(g-1):0,_=g+1<s.length?s.charCodeAt(g+1):0;if(R!==61&&R!==33&&R!==60&&R!==62&&_!==61&&_!==62){l=!0;break}}if(!l)return t;let d=0,p=-1;for(let g=o;g<t.length;g++){let I=t.charCodeAt(g);if(I===40)d++;else if(I===41){if(d--,d===0){p=g;break}}}if(p===-1)return t;let k=t.slice(o,p+1),T=It(k);return t.slice(0,o)+T+t.slice(p+1)}function En(t){if(t.length<2)return t;if(t.indexOf("/")===-1&&t.indexOf(";")===-1&&t.indexOf("=")===-1&&t.indexOf("\r")===-1&&t.indexOf(`
|
|
24
|
+
|
|
25
|
+
`)===-1){let _=!1,N=t.indexOf(`
|
|
26
|
+
`);if(N!==-1){let y=N+1,S=0;while(y<t.length&&(t.charCodeAt(y)===Ze||t.charCodeAt(y)===Xe))S++,y++;if(y<t.length&&t.charCodeAt(y)!==Pe&&t.charCodeAt(y)!==le&&t.charCodeAt(y)!==Be&&S>2)_=!0;if(!_&&(t.indexOf(`
|
|
27
|
+
`)!==-1||t.indexOf(`
|
|
28
|
+
`)!==-1))_=!0}if(!_)return t}let o=t.indexOf("//")!==-1||t.indexOf("/*")!==-1,s=t.split(`
|
|
29
|
+
`),l=[],d=[],p=[],k=!1,T=0,g=1/0;for(let _=0;_<s.length;_++){let N=s[_];if(o){let y=N,S=!1,E=0;while(E<N.length&&(N.charCodeAt(E)===Ze||N.charCodeAt(E)===Xe))E++;if(k){let se=y.indexOf("*/");if(se===-1)continue;k=!1,y=y.slice(se+2),S=!0,E=T}while(!0){let se=y.trimStart();if(se.startsWith("/*")){let K=se.indexOf("*/",2);if(K===-1){k=!0,T=E,y="";break}y=se.slice(K+2),S=!0;continue}break}let L=y.trim();if(L.length===0)continue;let H=L.charCodeAt(0);if(H===Y&&L.charCodeAt(1)===Y)continue;if(!S&&H===Ie)continue;let q=Yn(y);if(q.charCodeAt(q.length-1)===ke)q=q.slice(0,-1);q=Tn(q);let j=q.trim();if(!j)continue;let de=0;if(S)de=E,q=E>0?`${" ".repeat(E)}${j}`:j;else while(de<q.length&&it(q.charCodeAt(de)))de++;if(l.push(q),d.push(j),j!=="{"&&j!=="}"){if(de<g)g=de}p.push(de)}else{let y=N.length;while(y>0&&(N.charCodeAt(y-1)===Ze||N.charCodeAt(y-1)===Xe||N.charCodeAt(y-1)===Ke))y--;if(y===0)continue;let S=y<N.length?N.slice(0,y):N;if(S.charCodeAt(S.length-1)===ke)S=S.slice(0,-1);S=Tn(S);let E=S.trim();if(!E)continue;l.push(S),d.push(E);let L=0;while(L<S.length&&it(S.charCodeAt(L)))L++;if(E!=="{"&&E!=="}"){if(L<g)g=L}p.push(L)}}if(l.length===0)return"{}";if(g===1/0||g<=2)return l.join(`
|
|
30
|
+
`);let I=g-2,R=Array(l.length);for(let _=0;_<l.length;_++){let N=d[_];if(N==="{"){R[_]=N;continue}let y=p[_];if(y>g)R[_]=l[_];else if(y===g&&(N.charCodeAt(0)===le||N.charCodeAt(0)===Be||N.charCodeAt(0)===xe))R[_]=l[_];else{let S=Math.max(0,y-I);R[_]=" ".repeat(S)+N}}return R.join(`
|
|
31
|
+
`)}function kt(){if(e>=x||h.charCodeAt(e)!==Me)return"";let t=e;et(Me,Re);let o=h.slice(t,e);if(o.includes(`
|
|
32
|
+
`)){let s="",l=!1;for(let d=0;d<o.length;){let p=o.charCodeAt(d);if(p===$e||p===ve||p===Ge){let k=ht(o,d,p);s+=o.slice(d,k),l=!1,d=k;continue}if(p===Y&&o.charCodeAt(d+1)===Y){let k=o.indexOf(`
|
|
33
|
+
`,d+2);d=k===-1?o.length:k;continue}if(p===Y&&o.charCodeAt(d+1)===Ie){let k=o.indexOf("*/",d+2);d=k===-1?o.length:k+2;continue}if(p===32||p===9||p===10||p===13){if(!l&&s.length>0&&s.charCodeAt(s.length-1)!==Me)s+=" ",l=!0;d++}else{if(p===Re&&l&&s.length>0&&s.charCodeAt(s.length-1)===32)s=s.slice(0,-1);s+=o[d],l=!1,d++}}return s}return o}function yt(){if(e>=x||h.charCodeAt(e)!==ge)return"()";let t=e;return et(ge,xe),h.slice(t,e)}function Ut(t){if(t.indexOf("/")===-1)return t;let o="",s=!1,l=0;for(let d=0;d<t.length;d++){let p=t.charCodeAt(d);if(s){if(o+=t[d],p===lt&&d+1<t.length){o+=t[++d];continue}if(p===l)s=!1;continue}if(p===$e||p===ve||p===Ge){s=!0,l=p,o+=t[d];continue}if(p===Y&&d+1<t.length){let k=t.charCodeAt(d+1);if(k===Ie){let T=t.indexOf("*/",d+2);d=T===-1?t.length:T+1,o+=" ";continue}if(k===Y){let T=t.indexOf(`
|
|
34
|
+
`,d+2);d=T===-1?t.length:T-1;continue}if(u(t,d)){let T=c(t,d);o+=t.slice(d,T),d=T-1;continue}}o+=t[d]}return o.trim()}function Bn(t,o){let s=o-1;while(s>=0&&t.charCodeAt(s)<=32)s--;if(s<0)return-1;let l=t.charCodeAt(s);if(!i(l)&&l!==Be&&l!==xe)return-1;let d=1,p=0,k=0,T=0;for(let g=o+1;g<t.length;g++){let I=t.charCodeAt(g);if(I===$e||I===ve||I===Ge){g=ht(t,g,I)-1;continue}if(I===ge)p++;else if(I===xe){if(p===0)return-1;p--}else if(I===Ee)k++;else if(I===Be){if(k===0)return-1;k--}else if(I===te)T++;else if(I===le){if(T===0)return-1;T--}else if(p===0&&k===0&&T===0){if(I===ke)return-1;if(I===We&&t.charCodeAt(g+1)!==Re)return-1;if(I===Me)d++;else if(I===Re&&t.charCodeAt(g-1)!==We){if(d--,d===0){let R=g+1;while(R<t.length&&t.charCodeAt(R)<=32)R++;if(R<t.length&&(t.charCodeAt(R)===ge||t.charCodeAt(R)===Ge))return g;return-1}}}}return-1}function It(t){let o=t.slice(1,-1).trim();if(!o)return"()";if(t.indexOf(`
|
|
35
|
+
`)===-1&&o.indexOf(":")!==-1&&o.indexOf("{")===-1&&o.indexOf("[")===-1&&o.indexOf("=")===-1&&o.indexOf("@")===-1&&o.indexOf("...")===-1){let y=!1,S=!0,E=0;for(let L=0;L<o.length;L++){let H=o.charCodeAt(L);if(H===ge||H===Me||H===te)E++;else if(H===xe||H===le)E--;else if(H===Re&&(L===0||o.charCodeAt(L-1)!==We))E--;else if(E===0){if(H===dt)y=!0;else if(H===pt){if(!y){S=!1;break}y=!1}}}if(S&&y){let L=!1;for(let H=0;H<An.length;H++){let q=An[H],j=o.indexOf(q);if(j!==-1){let de=j+q.length;if((j===0||!i(o.charCodeAt(j-1)))&&(de>=o.length||!i(o.charCodeAt(de)))){L=!0;break}}}if(!L)return t}}let s=[],l=0,d=0,p=0,k=!1,T=!1,g=0;for(let y=0;y<=o.length;y++){if(y===o.length){s.push(Ut(o.slice(l).trim()));break}let S=o.charCodeAt(y);if(T){if(S===lt){y++;continue}if(S===g)T=!1;continue}if(S===Y&&y+1<o.length){let E=o.charCodeAt(y+1);if(E===Ie){y+=2;while(y+1<o.length&&!(o.charCodeAt(y)===Ie&&o.charCodeAt(y+1)===Y))y++;y++;continue}if(E===Y){while(y<o.length&&o.charCodeAt(y)!==10)y++;continue}if(u(o,y)){y=c(o,y)-1;continue}}if(S===$e||S===ve||S===Ge){T=!0,g=S;continue}if(S===ge||S===te||S===Ee)d++;else if(S===xe||S===le||S===Be){if(d>0)d--}else if(S===Me){if(!k)p++;else if(d===0){let E=Bn(o,y);if(E!==-1)y=E}}else if(S===Re&&!(y>0&&o.charCodeAt(y-1)===We)){if(!k&&p>0)p--}else if(S===We&&d===0&&p===0&&!k&&o.charCodeAt(y+1)!==Re&&o.charCodeAt(y+1)!==We)k=!0;else if(S===pt&&d===0&&p===0)s.push(Ut(o.slice(l,y).trim())),l=y+1,k=!1}let I=[];for(let y of s){if(!y)continue;let S=y.trim();if(S.startsWith("//")||S.startsWith("/*"))continue;let E=y;{let L=!1,H=0,q=0,j=0;for(let de=0;de<E.length-1;de++){let se=E.charCodeAt(de);if(se===Pe){j=de+1;continue}if(L){if(se===lt){de++;continue}if(se===H)L=!1;continue}if(se===$e||se===ve||se===Ge){L=!0,H=se;continue}if(se===te||se===Ee||se===ge||se===Me){q++;continue}if(se===le||se===Be||se===xe||se===Re){if(q>0)q--;continue}if(se===Y&&u(E,de)){de=c(E,de)-1;continue}if(se===Y&&E.charCodeAt(de+1)===Y){if(q===0){E=E.slice(0,de).trimEnd();break}let K=E.indexOf(`
|
|
36
|
+
`,de);if(K===-1){E=E.slice(0,j).trimEnd();break}let re=E.slice(0,j),me=E.slice(K+1);E=`${re}${me}`,de=j-1}}}if(!E.trim())continue;I.push(Mn(E))}let R=!1,_=!1;for(let y=0;y<I.length;y++){let S=I[y];if(!S||S.startsWith("..."))continue;let E=0,L=S.charCodeAt(0);if(L===te||L===Ee){let H=L===te?le:Be,q=1;E=1;while(E<S.length&&q>0){let j=S.charCodeAt(E);if(j===$e||j===ve||j===Ge){E=ht(S,E,j);continue}if(j===L)q++;else if(j===H)q--;E++}}else{while(E<S.length&&i(S.charCodeAt(E)))E++;if(E===4&&S.startsWith("this"))continue}while(E<S.length&&S.charCodeAt(E)<=32)E++;if(E<S.length&&S.charCodeAt(E)===zt)R=!0;else if(R){_=!0;break}}let N=`(${I.join(", ")})`;return _?ze(N):N}function li(t){if(!t.startsWith("{")&&!t.startsWith("["))return t;let o="",s=0,l=0,d=!1,p=0;while(s<t.length){let k=t.charCodeAt(s);if(d){if(k===lt&&s+1<t.length){o+=t[s]+t[s+1],s+=2;continue}if(k===p)d=!1;o+=t[s],s++;continue}if(k===Y&&s+1<t.length){let T=t.charCodeAt(s+1);if(T===Ie){let g=s;s+=2;while(s+1<t.length&&!(t.charCodeAt(s)===Ie&&t.charCodeAt(s+1)===Y))s++;s=Math.min(s+2,t.length),o+=t.slice(g,s);continue}if(T===Y){let g=s;while(s<t.length&&t.charCodeAt(s)!==10)s++;o+=t.slice(g,s);continue}}if(k===$e||k===ve||k===Ge){d=!0,p=k,o+=t[s],s++;continue}if(k===te||k===Ee||k===ge)l++;else if(k===le||k===Be||k===xe)l--;if(l>=1&&k===We&&(s+1>=t.length||t.charCodeAt(s+1)!==We&&t.charCodeAt(s+1)!==Re)){while(o.length>0&&(o[o.length-1]===" "||o[o.length-1]==="\t"||o[o.length-1]===`
|
|
37
|
+
`))o=o.slice(0,-1);s++;let T=0;while(s<t.length){let g=t.charCodeAt(s);if(g===Y){if(t.charCodeAt(s+1)===Y){let I=t.indexOf(`
|
|
38
|
+
`,s+2);s=I===-1?t.length:I+1;continue}if(t.charCodeAt(s+1)===Ie){let I=t.indexOf("*/",s+2);s=I===-1?t.length:I+2;continue}if(u(t,s)){s=c(t,s);continue}}if(g===$e||g===ve||g===Ge){let I=g;s++;while(s<t.length){if(t.charCodeAt(s)===lt){s+=2;continue}if(t.charCodeAt(s)===I){s++;break}s++}continue}if(g===te||g===Ee||g===ge)T++;else if(g===le||g===Be||g===xe){if(T===0)break;T--}else if(g===pt&&T===0)break;s++}continue}o+=t[s],s++}return o}function vi(t,o){let s=o+1,l=1;while(s<t.length&&l>0){let d=t.charCodeAt(s);if(d===$e||d===ve||d===Ge){s=ht(t,s,d);continue}if(d===ge)l++;else if(d===xe)l--;s++}return s}function Qt(t,o,s,l){let d=o+1,p=1;while(d<t.length&&p>0){let k=t.charCodeAt(d);if(k===$e||k===ve||k===Ge){d=ht(t,d,k);continue}if(k===s)p++;else if(k===l&&!(l===Re&&d>0&&t.charCodeAt(d-1)===We))p--;d++}return d}function Wn(t){let o=t;while(o.startsWith("@")){let s=1;while(s<o.length&&it(o.charCodeAt(s)))s++;if(s<o.length&&o.charCodeAt(s)===ge)s=Qt(o,s,ge,xe);else while(s<o.length&&i(o.charCodeAt(s)))s++;while(s<o.length){let l=s;while(s<o.length&&it(o.charCodeAt(s)))s++;if(s<o.length&&o.charCodeAt(s)===Ct&&(s+1>=o.length||o.charCodeAt(s+1)!==Ct)){s++;while(s<o.length&&it(o.charCodeAt(s)))s++;while(s<o.length&&i(o.charCodeAt(s)))s++}else if(s<o.length&&o.charCodeAt(s)===Me)s=Qt(o,s,Me,Re);else if(s<o.length&&o.charCodeAt(s)===Ee)s=Qt(o,s,Ee,Be);else if(s<o.length&&o.charCodeAt(s)===ge)s=Qt(o,s,ge,xe);else{s=l;break}}o=o.slice(s).trim()}return o}function Mn(t){let o=t.trim();if(o.startsWith("@"))o=Wn(o);let s=o.startsWith("...");if(s)o=o.slice(3).trim();let l=!0;while(l){l=!1;for(let S of An)if(o.startsWith(S)&&o.length>S.length&&!i(o.charCodeAt(S.length))){let E=o.slice(S.length).trim();if(E.charCodeAt(0)===dt||E.charCodeAt(0)===zt&&E.length>1&&E.charCodeAt(1)===dt)break;o=E,l=!0;break}}let d=-1,p=-1,k=0,T=!1,g=0;for(let S=0;S<o.length;S++){let E=o.charCodeAt(S);if(T){if(E===lt){S++;continue}if(E===g)T=!1;continue}if(E===Y&&S+1<o.length){let L=o.charCodeAt(S+1);if(L===Ie){S+=2;while(S+1<o.length&&!(o.charCodeAt(S)===Ie&&o.charCodeAt(S+1)===Y))S++;S++;continue}if(L===Y){while(S<o.length&&o.charCodeAt(S)!==10)S++;continue}if(u(o,S)){S=c(o,S)-1;continue}}if(E===$e||E===ve||E===Ge){T=!0,g=E;continue}if(E===ge||E===te||E===Ee||E===Me)k++;else if(E===xe||E===le||E===Be||E===Re&&!(S>0&&o.charCodeAt(S-1)===We))k--;else if(k===0){if(E===dt&&d===-1)d=S;else if(E===We&&p===-1&&(S===0||o.charCodeAt(S-1)!==We)&&(S+1>=o.length||o.charCodeAt(S+1)!==We&&o.charCodeAt(S+1)!==Re))p=S}}let I,R,_=p!==-1;if(d!==-1&&(p===-1||d<p))if(I=o.slice(0,d).trim(),p!==-1)R=o.slice(d+1,p).trim();else R=o.slice(d+1).trim();else if(p!==-1){I=o.slice(0,p).trim();let S=s?null:Ae(I,o.slice(p+1));if(S)return He(S,Ot);R=Ot(o.slice(p+1).trim())}else I=o,R="unknown";if(I=li(I),(I.startsWith("{")||I.startsWith("["))&&I.includes(`
|
|
39
|
+
`)){let S=I.replace(/\s*\n\s*/g," ").replace(/\s+/g," ");if(S.length<=40)I=S;else I=I.split(`
|
|
40
|
+
`).map((L)=>{let H=L.trim();if(!H)return"";if(H==="{"||H==="}"||H==="["||H==="]"||H.startsWith("}")||H.startsWith("]"))return H;return` ${H}`}).join(`
|
|
41
|
+
`)}let N=I.endsWith("?")||_;if(I.endsWith("?"))I=I.slice(0,-1).trim();let y=N&&!s?"?":"";if(s)return`...${I}: ${R}`;return`${I}${y}: ${R}`}function Ot(t){let o=t.trim();if(!o)return"unknown";if(oe(o)!==null&&!ae(o))return r(o,!0,!1,0);let s=Ye(o);if(s)return s;if(o==="true"||o==="false")return"boolean";if(b(o))return"number";if(v(o))return"bigint";if((o.startsWith("'")||o.startsWith('"'))&&ht(o,0,o.charCodeAt(0))===o.length||bn(o))return"string";if(o.startsWith("[")&&o.endsWith("]")&&Rn(o,0,91,93)===o.length-1)return"unknown[]";if(o.startsWith("{")&&o.endsWith("}")&&Rn(o,0,123,125)===o.length-1)return"Record<string, unknown>";if(o.startsWith("/")&&sn(o))return"RegExp";if(o.startsWith("new "))return Se(o);if(ae(o))return ee(o,!1,0,!1);return Z(o)??"unknown"}function Rn(t,o,s,l){let d=0;for(let p=o;p<t.length;p++){let k=t.charCodeAt(p);if(k===$e||k===ve||k===Ge){p=ht(t,p,k)-1;continue}if(k===Y&&t.charCodeAt(p+1)===Y){let T=t.indexOf(`
|
|
42
|
+
`,p+2);if(T===-1)break;p=T;continue}if(k===Y&&t.charCodeAt(p+1)===Ie){let T=t.indexOf("*/",p+2);if(T===-1)break;p=T+1;continue}if(k===Y&&s!==Me&&u(t,p)){p=c(t,p)-1;continue}if(k===s)d++;else if(k===l){if(d--,d===0)return p}}return-1}function fn(t){let o=t.trim(),s=oe(o);if(s!==null)o=s;if(o==="true"||o==="false")return o;if(b(o)||v(o))return z(o);if(bn(o))return o;let l=fi(o);if(l!==null)return l;return Z(o)??"unknown"}function fi(t){if(t==="")return null;if(t.charCodeAt(0)===$e||t.charCodeAt(0)===ve){if(ht(t,0,t.charCodeAt(0))===t.length)return t}let o=di(t,"+");if(o.length>1){let s=!1,l=!0,d=[];for(let p of o){let k=p.trim(),T=k.charCodeAt(0);if((T===$e||T===ve)&&ht(k,0,T)===k.length)s=!0,d.push(ui(k));else l=!1}if(l)return hi(d.join(""));if(s)return"string";return null}if(/^[\d\s()+*/%.\-]+$/.test(t)&&/\d/.test(t)&&/[+*/%\-\s]/.test(t))return"number";return null}function di(t,o){let s=[],l=0,d="",p=0;while(p<t.length){let k=t.charCodeAt(p);if(k===$e||k===ve||k===Ge){let T=ht(t,p,k);d+=t.slice(p,T),p=T;continue}if(k===Y&&(t.charCodeAt(p+1)===Y||t.charCodeAt(p+1)===42)){if(t.charCodeAt(p+1)===Y){let I=t.indexOf(`
|
|
43
|
+
`,p+2),R=I===-1?t.length:I;d+=t.slice(p,R),p=R;continue}let T=t.indexOf("*/",p+2),g=T===-1?t.length:T+2;d+=t.slice(p,g),p=g;continue}if(k===ge||k===Ee||k===te)l++;else if(k===xe||k===Be||k===le)l--;if(t[p]===o&&l===0){s.push(d),d="",p++;continue}d+=t[p],p++}return s.push(d),s}function ui(t){return t.slice(1,-1).replace(/\\(.)/g,(s,l)=>{if(l==="n")return`
|
|
44
|
+
`;if(l==="t")return"\t";if(l==="r")return"\r";if(l==="0")return"\x00";return l})}function hi(t){return`'${t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function Jt(t){if(oe(t)!==null)return null;if(!t.includes("as"))return null;let o=0,s=-1;for(let d=0;d<t.length;d++){let p=t.charCodeAt(d);if(p===$e||p===ve||p===Ge){d=ht(t,d,p)-1;continue}if(p===Y&&t.charCodeAt(d+1)===Y){while(d<t.length&&t.charCodeAt(d)!==Pe)d++;continue}if(p===Y&&t.charCodeAt(d+1)===Ie){let k=t.indexOf("*/",d+2);d=k===-1?t.length:k+1;continue}if(p===Y){let k=d-1;while(k>=0&&t.charCodeAt(k)<=32)k--;if(k<0||"([{:;,=!?&|+*-~>".includes(t[k])){let T=!1;for(d++;d<t.length;d++){let g=t.charCodeAt(d);if(g===lt)d++;else if(g===91)T=!0;else if(g===93)T=!1;else if(g===Y&&!T)break}continue}}if(p===123||p===91||p===40)o++;else if(p===125||p===93||p===41)o--;else if(o===0){if(s===-1){let k=t.charCodeAt(d+1);if(p===61&&k===62)return null;if(p===63&&k!==46)return null;if(p===58||p===44||p===124||p===38||p===94)return null;if((p===61||p===33)&&k===61)return null}if(p<=32&&d+4<=t.length&&t.charCodeAt(d+1)===97&&t.charCodeAt(d+2)===115&&t.charCodeAt(d+3)<=32)s=d}}if(s===-1)return null;let l=t.slice(s+4).trim();if(l.endsWith(";"))l=l.slice(0,-1).trim();return l&&l!=="const"&&cn(l)?l:null}function Ft(){if(M(),e<x&&h.charCodeAt(e)===dt){let l=function(){let d=je(t,s),p=(k)=>{let T=d.length-k.length;return T>=0&&d.endsWith(k)&&(T===0||!i(d.charCodeAt(T-1)))};return d.length===0||d.endsWith("=>")||d.endsWith("|")||d.endsWith("&")||d.endsWith("?")||d.endsWith(":")||p("is")||p("extends")||p("keyof")||p("readonly")};e++,M();let t=e,o=0,s=t;while(e<x){let d=e;if(rt()){if(h.charCodeAt(d)!==Y)s=e;continue}let p=h.charCodeAt(e);if(p===ge||p===Ee||p===Me)o++;else if(p===xe||p===Be||p===Re&&!ut())o--;else if(p===te)if(o>0)o++;else if(l())o++;else break;else if(p===le){if(o===0)break;o--}else if(o===0&&p===ke)break;if(o===0&&Lt()&&!l())break;if(!it(p))s=e+1;e++}return je(t,e)}return""}function xt(t,o,s,l){e+=8,M();let d=e<x&&h.charCodeAt(e)===Ie;if(d)e++,M();let p=Qe();if(!p&&!l)return null;M();let k=kt();M();let T=yt();M();let g=Ft(),I=g.length>0;if(!g)if(s&&d)g="AsyncGenerator<unknown, void, unknown>";else if(d)g="Generator<unknown, void, unknown>";else if(s)g="Promise<void>";else g="void";M();let R=!1;if(e<x&&h.charCodeAt(e)===te){R=!0;let H=e+1;if(et(te,le),!I&&d){let q=h.slice(H,e-1),j=ar(q,J??"stdin.ts",()=>{let de;do de=`__dtsx_return_${G++}`;while(h.includes(de));return de},(de)=>fe(de.name,{...de,start:e,end:e}),k);g=j.finish(Ue(q,s,T,bt,j.resolve))}else if(!I){let q=h.slice(H,e-1),j=ar(q,J??"stdin.ts",()=>{let de;do de=`__dtsx_return_${G++}`;while(h.includes(de));return de},(de)=>fe(de.name,{...de,start:e,end:e}),k);g=j.finish(O(q,s,T,bt,j.resolve))}}else if(e<x&&h.charCodeAt(e)===ke)e++;let _=It(T),S=`${o?l?"export default function ":"export declare function ":"declare function "}${p||(l?"":"default")}${k}${_}: ${g};`,E=at(t),L={kind:"function",name:p||"default",text:S,isExported:o,isDefault:l,isAsync:s,isGenerator:d,returnType:g,generics:k||void 0,leadingComments:E,start:t,end:e};if(R)Fe.add(L);return L}let dn,pi=0;function Pn(){dn??=new Set(n(h).filter((t)=>t.kind==="word").map((t)=>h.slice(t.start,t.end)));for(;;){let t=`__dtsx_binding_${pi++}`;if(dn.has(t))continue;return dn.add(t),t}}function wt(t,o,s){e+=o.length,M();let l=[];do{if(M(),e>=x)break;let d=h.charCodeAt(e),p,k=e;if(d===te||d===Ee)et(d,d===te?le:Be),p=h.slice(k,e);let T=p?Pn():Qe();if(!T)return tt(),l;M();let g,I,R,_=!1;if(e<x&&h.charCodeAt(e)===dt){e++,M();let H=e,q=0;while(e<x){if(rt()){if(q===0&&vn())break;continue}let j=h.charCodeAt(e);if(j===ge||j===te||j===Ee||j===Me)q++;else if(j===xe||j===le||j===Be||j===Re&&!ut())q--;else if(q===0&&(j===ke||j===pt))break;else if(q===0&&j===We&&!rn())break;if(q===0&&(Tt()||Dn()))break;e++}g=je(H,e)}if(e<x&&h.charCodeAt(e)===We)if(ye&&g&&(!ce||!xi(g)))oi();else{e++,M();let H=e;R=H;let q=0,j=0,de;if(h.charCodeAt(e)===ge||h.charCodeAt(e)===Me||W("function")||W("async")){Ve??=D(h);let K=Ve(e,H);if(K?.parameters)e=K.end}while(e<x){if(q===0&&j===0&&ti(H,de))break;if(rt())continue;let K=h.charCodeAt(e);if(K===ge||K===te||K===Ee)q++;else if(K===xe||K===le||K===Be)q--;else if(K===Me){Ve??=D(h);let re=q===0&&j===0?Ve(e,H,de):void 0;if(re?.parameters||re?.completeOperand||re&&J!==void 0&&!/\.[jt]sx$/.test(J)){e=re.end,de=re.completeOperand?re.end:void 0;continue}let me=j>0||h[e+1]!=="/"&&Te(h,e)?Le(e):null;if(me){if(j=Math.max(0,j+me.delta),e=me.end+1,j===0)de=e;continue}else if(j===0){if(re){e=re.end,de=re.completeOperand?re.end:void 0;continue}}}else if(q===0&&j===0&&(K===ke||K===pt))break;e++}I=Xn(je(H,e));let se=oe(I);if(se!==null||I==="const"){if(_=!0,!g){let re=fn(se??I);g=re!=="unknown"?re:void 0}}else if(!g){let K=P(I)??Jt(I)??bt(I);if(K)g=K}}let N=l.length===0?at(t):void 0,y=p?"const":o,S=p?!1:s,E=`${S?"export ":""}declare ${y} ${T}: ${g||"unknown"};`,L={kind:"variable",name:T,text:E,isExported:S,typeAnnotation:g,value:I,initializerStart:R,modifiers:_?[y,"const assertion"]:[y],leadingComments:p?void 0:N,start:t,end:e};if(p)l.push(...vr({pattern:p,patternOffset:k,root:L,kind:o,exported:s,comments:N,allocateName:Pn}));else l.push(L);if(h.charCodeAt(e)===pt){e++;continue}if(h.charCodeAt(e)===ke)e++;break}while(e<x);return l}function Zt(t,o,s=!1){e+=9,M();let l=Qe();M();let d=kt();M();let p="";if(W("extends")){e+=7,M();let _=e,N=0;while(e<x){if(rt())continue;let y=h.charCodeAt(e);if(y===Me)N++;else if(y===Re&&!ut())N--;else if(y===te&&N===0)break;e++}p=je(_,e)}M();let k=e<x&&h.charCodeAt(e)===te?Gt():"{}",T=En(k),I=`${s?"export default interface ":`${o?"export ":""}declare interface `}${l}${d}${p?` extends ${p}`:""} ${T}`,R=at(t);return{kind:"interface",name:l,text:I,isExported:o,extends:p||void 0,generics:d||void 0,leadingComments:R,start:t,end:e}}function un(t,o){e+=4,M();let s=Qe();M();let l=kt();if(M(),e<x&&h.charCodeAt(e)===We)e++;M();let d=e,p=0;while(e<x){if(rt())continue;let I=h.charCodeAt(e);if(I===ge||I===te||I===Ee||I===Me)p++;else if(I===xe||I===le||I===Be||I===Re&&!ut())p--;else if(p===0&&I===ke)break;if(p===0&&(I===Pe||I===Ke)&&(Tt()||Dn()))break;e++}let k=je(d,e);if(e<x&&h.charCodeAt(e)===ke)e++;let T=`${o?"export ":""}type ${s}${l} = ${k}`,g=at(t);return{kind:"type",name:s,text:T,isExported:o,generics:l||void 0,leadingComments:g,start:t,end:e}}function Et(t,o,s){e+=4,M();let l=Qe();M();let d=e;if(e<x&&h.charCodeAt(e)===te)et(te,le);let p=je(t,e),k=at(t);return{kind:"enum",name:l,text:p,isExported:o,modifiers:s?["const"]:void 0,leadingComments:k,start:t,end:e}}function $t(t,o,s,l=!1){e+=5,M();let d=W("extends")||W("implements")?"":Qe();if(!d){d="AnonymousClass";let N=1;while(h.includes(d))d=`AnonymousClass_${N++}`}M();let p=kt();M();let k="";if(W("extends")){e+=7,M();let N=e,y=W("class"),S=0,E=0,L=0,H=0;while(e<x){if(rt())continue;let j=h.charCodeAt(e);if(j===Me)S++;else if(j===Re&&!ut()&&S>0)S--;else if(j===ge)E++;else if(j===xe&&E>0)E--;else if(j===Ee)L++;else if(j===Be&&L>0)L--;else if(j===te)if(S===0&&E===0&&L===0&&H===0)if(y)y=!1,H++;else break;else H++;else if(j===le&&H>0)H--;else if(S===0&&E===0&&L===0&&H===0&&!y&&W("implements"))break;e++}k=je(N,e);let q=ft(k);if(q.startsWith("class")&&(q.length===5||!i(q.charCodeAt(5)))){let j=bt(q);if(j?.startsWith("typeof "))k=j.slice(7)}}let T;if(W("implements")){e+=10,M();let N=e,y=0,S=0,E=0,L=0;while(e<x){if(rt())continue;let q=h.charCodeAt(e);if(q===Me)y++;else if(q===Re&&!ut()&&y>0)y--;else if(q===ge)S++;else if(q===xe&&S>0)S--;else if(q===Ee)E++;else if(q===Be&&E>0)E--;else if(q===te){if(y===0&&S===0&&E===0&&L===0)break;L++}else if(q===le&&L>0)L--;e++}let H=je(N,e);if(H)T=H.split(",").map((q)=>q.trim())}M();let g=Nn(d),R=`${o?l?"export default ":"export declare ":"declare "}${s?"abstract ":""}class ${d}${p}${k?` extends ${k}`:""}${T&&T.length>0?` implements ${T.join(", ")}`:""} ${g}`,_=at(t);return{kind:"class",name:d,text:R,isExported:o,isDefault:l,extends:k||void 0,implements:T,generics:p||void 0,modifiers:s?["abstract"]:void 0,leadingComments:_,start:t,end:e}}let hn;function Nn(t){if(e>=x||h.charCodeAt(e)!==te)return"{}";e++;let o={name:t,fields:new Map,pending:[],isStatic:!1};X.push(o);let s=[],l=new Set,d=new Map,p=[],k=0,T;while(e<x){if(M(),e>=x)break;if(h.charCodeAt(e)===le){e++;break}if(h.charCodeAt(e)===ke){e++;continue}if(hn=at(e),en(),e>=x||h.charCodeAt(e)===le){if(e<x)e++;break}if(W("static")&&Bt("static")===te){e+=6,M(),et(te,le);continue}let g=!1,I=!1,R=!1,_=!1,N=!1,y=!1,S=!1,E=!1,L=!0;while(L){M();let K=e,re=Qe();if(e=K,re){let me=Bt(re);if(me===ge||me===Me||me===zt||me===33||me===dt||me===We||me===ke||me===le)break}if(W("private")){g=!0,e+=7;continue}if(W("protected")){I=!0,e+=9;continue}if(W("public")){e+=6;continue}if(W("static")){R=!0,e+=6;continue}if(W("abstract")){_=!0,e+=8;continue}if(W("readonly")){N=!0,e+=8;continue}if(W("override")){y=!0,e+=8;continue}if(W("accessor")){S=!0,e+=8;continue}if(W("async")){let De=e+5,At=!1;while(De<x){let vt=h.charCodeAt(De);if(vt===Pe||vt===Ke){At=!0;break}if(vt===Ze||vt===Xe)De++;else if(vt===Y&&h.charCodeAt(De+1)===Y){At=!0;break}else if(vt===Y&&h.charCodeAt(De+1)===Ie){let Dt=h.indexOf("*/",De+2),Mt=h.slice(De,Dt===-1?x:Dt);if(Mt.includes(`
|
|
45
|
+
`)||Mt.includes("\r")){At=!0;break}De=Dt===-1?x:Dt+2}else break}if(At)break;E=!0,e+=5;continue}if(W("declare")){e+=7;continue}break}if(M(),e>=x||h.charCodeAt(e)===le)break;let H=e;if(o.isStatic=R,(W("get")||W("set"))&&pn(Bt(h.slice(e,e+3))))e+=3,M();if(h.charCodeAt(e)===Ie)e++,M();let q=Xt();e=H;let j=q.startsWith("#");if(j)g=!0;if(g&&q&&q!=="constructor"){let K=j?R?" static #private_static;":" #private;":` private ${R?"static ":""}${S?"accessor ":""}${q};`,me=q[0]==="'"||q[0]==='"'?m(q)??q:q,De=j?`${R?"static":"instance"}#`:`${R?"static:":"instance:"}${me}`;if(!l.has(De))l.add(De),s.push(K)}let de=g?[]:s,se=" ";if(I)se+="protected ";if(R)se+="static ";if(_)se+="abstract ";if(N)se+="readonly ";if(S)se+="accessor ";if(W("constructor")){e+=11,M();let K=yt();M(),Ci(K,s);let re=!1;if(e<x&&h.charCodeAt(e)===te)re=!0,et(te,le);else if(e<x&&h.charCodeAt(e)===ke)e++;if(re&&k>0)continue;if(!re)k++;let me=It(K);s.push(g?" private constructor();":` ${I?"protected ":""}constructor${me};`)}else if(W("get"))if(e+=3,M(),e<x&&pn(h.charCodeAt(e))){let K=Xt();if(K.startsWith("#")){if(M(),e<x&&h.charCodeAt(e)===ge)yt();if(M(),Ft(),M(),e<x&&h.charCodeAt(e)===te)et(te,le);else if(e<x&&h.charCodeAt(e)===ke)e++;continue}M();let re=yt(),me=re.length>2&&re.slice(1,-1).trim().length>0?It(re):"()";M();let De=Ft(),At;if(M(),e<x&&h.charCodeAt(e)===te){let Dt=e+1;if(et(te,le),!De&&!ye)At=h.slice(Dt,e-1),De=O(At,!1,re,(Mt)=>_t(Mt,R))}else if(e<x&&h.charCodeAt(e)===ke)e++;let vt=de.length;if(!g)d.set(R?`static:${K}`:K,s.length);if(de.push(`${se}get ${K}${me}: ${At?B(De):De||"unknown"};`),At)o.pending.push(()=>{let Dt=O(At,!1,re,(Mt)=>_t(Mt,R));de[vt]=`${se}get ${K}${me}: ${B(Dt)};`})}else{if(!g)T??=new Set;Fn("get",se,R,N,E,de,g?void 0:T)}else if(W("set"))if(e+=3,M(),e<x&&pn(h.charCodeAt(e))){let K=Xt();if(K.startsWith("#")){if(M(),e<x&&h.charCodeAt(e)===ge)yt();if(M(),e<x&&h.charCodeAt(e)===te)et(te,le);else if(e<x&&h.charCodeAt(e)===ke)e++;continue}M();let re=yt();if(M(),e<x&&h.charCodeAt(e)===te)et(te,le);else if(e<x&&h.charCodeAt(e)===ke)e++;let me=It(re);if(!g&&re.length>=2){let De=re.slice(1,-1).trim();if(De&&/^[A-Za-z_$][\w$]*$/.test(De))p.push({key:R?`static:${K}`:K,memberIndex:s.length,modPrefix:se,memberName:K,paramName:De})}de.push(`${se}set ${K}${me};`)}else{if(!g)T??=new Set;Fn("set",se,R,N,E,de,g?void 0:T)}else{let K=h.charCodeAt(e)===Ie;if(K)e++,M();let re=Xt();if(!re){Ln();continue}if(!g)T??=new Set;zn(re,se,R,N,K,_,E,de,g?void 0:T)}}for(let g of o.pending)g();for(let g of p){let I=d.get(g.key);if(I===void 0)continue;let R=s[I],_=gi(R);if(_&&_!=="unknown")s[g.memberIndex]=`${g.modPrefix}set ${g.memberName}(${g.paramName}: ${_});`}return X.pop(),s.length===0?"{}":`{
|
|
46
|
+
${s.join(`
|
|
47
|
+
`)}
|
|
48
|
+
}`}function gi(t){let o=0,s=0;while(o<t.length){let T=t.charCodeAt(o);if(T===$e||T===ve){o++;while(o<t.length&&t.charCodeAt(o)!==T){if(t.charCodeAt(o)===92)o++;o++}}else if(T===Ee)s++;else if(T===Be&&s>0)s--;else if(T===ge&&s===0)break;o++}if(o>=t.length)return"";let l=0,d=-1;for(;o<t.length;o++){let T=t.charCodeAt(o);if(T===$e||T===ve){o++;while(o<t.length&&t.charCodeAt(o)!==T){if(t.charCodeAt(o)===92)o++;o++}continue}if(T===ge)l++;else if(T===xe&&--l===0){d=o;break}}if(d===-1)return"";let p=d+1;while(p<t.length&&it(t.charCodeAt(p)))p++;if(t.charCodeAt(p)!==dt)return"";let k=t.endsWith(";")?t.length-1:t.length;return t.slice(p+1,k).trim()}function pn(t){return a(t)||t>=48&&t<=57||t===Ee||t===jn||t===$e||t===ve}function Xt(){if(e>=x)return"";let t=h.charCodeAt(e);if(t===Ee){let o=e;return et(Ee,Be),h.slice(o,e)}if(t===jn)return e++,`#${Qe()}`;if(t===$e||t===ve){let o=e;return mt(t),h.slice(o,e)}if(t>=48&&t<=57){let o=e;while(e<x){let s=h.charCodeAt(e);if(s>=48&&s<=57||s>=65&&s<=70||s>=97&&s<=102||s===46||s===95||s===120||s===88||s===111||s===79||s===98||s===66||s===110)e++;else break}return h.slice(o,e)}return Qe()}function Bt(t){let o=e;e+=t.length,M();let s=e<x?h.charCodeAt(e):0;return e=o,s}function Ln(){let t=0;while(e<x){if(rt())continue;let o=h.charCodeAt(e);if(o===te||o===ge)t++;else if(o===le||o===xe){if(t===0)return;t--}else if(o===ke&&t===0){e++;return}if(t===0&&Lt())return;e++}}function Fn(t,o,s,l,d,p,k){zn(t,o,s,l,!1,!1,d,p,k)}function zn(t,o,s,l,d,p,k,T,g){let I=hn;hn=void 0;let R=e;if(M(),e>=x)return;let _=h.charCodeAt(e),N=!1;if(_===zt)N=!0,e++,R=e,M();if(e<x&&h.charCodeAt(e)===33)e++,R=e,M();let y=e<x?h.charCodeAt(e):0,S=h.slice(R,e),E=S.includes(`
|
|
49
|
+
`)||S.includes("\r");if(y===ge||y===Me){let L=y===Me?kt():"";M();let H=yt();M();let q=Ft(),j,de=q.length>0;if(!q)if(k&&d)q="AsyncGenerator<unknown, void, unknown>";else if(d)q="Generator<unknown, void, unknown>";else if(k)q="Promise<void>";else q="void";if(M(),e<x&&h.charCodeAt(e)===te){let me=e+1;if(et(te,le),g?.has(s?`static:${t}`:t))return;if(!de&&d)j=h.slice(me,e-1),q=Ue(j,k,H,(De)=>_t(De,s));else if(!de)j=h.slice(me,e-1),q=O(j,k,H,(De)=>_t(De,s))}else{if(e<x&&h.charCodeAt(e)===ke)e++;if(!p&&g)g.add(s?`static:${t}`:t)}let se=It(H),K=N?"?":"",re=T.length;if(T.push(`${o}${t}${K}${L}${se}: ${j?B(q):q};`),j)X.at(-1)?.pending.push(()=>{let me=d?Ue(j,k,H,(De)=>_t(De,s)):O(j,k,H,(De)=>_t(De,s));T[re]=`${o}${t}${K}${L}${se}: ${B(me)};`})}else if(y===dt||y===We||y===ke||y===le||y===Pe||y===Ke||E){let L="";if(y===dt){e++,M();let se=e,K=0;while(e<x){if(rt())continue;let re=h.charCodeAt(e);if(re===ge||re===te||re===Ee||re===Me)K++;else if(re===xe||re===le||re===Be||re===Re&&!ut()){if(K===0)break;K--}else if(K===0&&(re===ke||re===pt))break;else if(K===0&&re===We&&!rn())break;if(K===0&&Lt())break;e++}L=je(se,e)}let H="";if(e<x&&h.charCodeAt(e)===We)if(ye&&L){e++;let se=0;while(e<x){if(rt())continue;let K=h.charCodeAt(e);if(K===ge||K===te||K===Ee)se++;else if(K===xe||K===le||K===Be){if(se===0&&K===le)break;se--}else if(se===0&&K===ke)break;if(se===0&&Lt())break;e++}}else{e++,M();let se=e,K=0;while(e<x){if(rt())continue;let re=h.charCodeAt(e);if(re===ge||re===te||re===Ee)K++;else if(re===xe||re===le||re===Be){if(K===0&&re===le)break;K--}else if(K===0&&re===ke)break;if(K===0&&Lt())break;e++}H=je(se,e)}if(e<x&&h.charCodeAt(e)===ke)e++;let q=L.length>0;if(!L)if(H){let se=P(H)??Jt(H);if(se)L=se;else if(H.startsWith("new "))L=_e(H);else{let K=oe(H),re=K!==null,me=K??H;if(re&&me.length>=2&&(me[0]==="{"||me[0]==="["))L=B(r(H,!0,!1,0));else{let De=l&&(s||yi(me));if(L=re||De?fn(me):Ot(me),(re||De)&&L==="unknown")L=Ot(me);if(L==="unknown"&&Un(me)&&!me.includes("."))L=_e(me,!0)}}}else L="unknown";let j=N?"?":"";X.at(-1)?.fields.set(`${s?"static:":""}${t}`,N?`(${L}) | undefined`:L);let de=ce&&!q&&H?on(I,H,L):"";T.push(`${de}${o}${t}${j}: ${L};`)}else Ln()}function mi(t){let o=0;for(let s=0;s<t.length;s++){let l=t.charCodeAt(s);if(l===ge||l===te||l===Ee||l===Me)o++;else if(l===xe||l===le||l===Be||l===Re&&t.charCodeAt(s-1)!==We)o--;else if(l===We&&o===0&&t.charCodeAt(s+1)!==Re&&t.charCodeAt(s+1)!==We)return!0}return!1}function Ci(t,o){let s=t.slice(1,-1).trim();if(!s)return;let l=[],d=0,p=0,k=0,T=!1,g=!1,I=0,R=[];for(let _=0;_<=s.length;_++){if(_===s.length){R.push(s.slice(d)),l.push(Ut(s.slice(d).trim()));break}let N=s.charCodeAt(_);if(g){if(N===lt){_++;continue}if(N===I)g=!1;continue}if(N===Y&&_+1<s.length){let y=s.charCodeAt(_+1);if(y===Ie){_+=2;while(_+1<s.length&&!(s.charCodeAt(_)===Ie&&s.charCodeAt(_+1)===Y))_++;_++;continue}if(y===Y){while(_<s.length&&s.charCodeAt(_)!==10)_++;continue}}if(N===$e||N===ve||N===Ge){g=!0,I=N;continue}if(N===ge||N===te||N===Ee)p++;else if(N===xe||N===le||N===Be){if(p>0)p--}else if(N===Me){if(!T)k++;else if(p===0){let y=Bn(s,_);if(y!==-1)_=y}}else if(N===Re&&!(_>0&&s.charCodeAt(_-1)===We)){if(!T&&k>0)k--}else if(N===We&&p===0&&k===0&&!T&&s.charCodeAt(_+1)!==Re&&s.charCodeAt(_+1)!==We)T=!0;else if(N===pt&&p===0&&k===0)R.push(s.slice(d,_)),l.push(Ut(s.slice(d,_).trim())),d=_+1,T=!1}for(let[_,N]of l.entries()){let y=N.startsWith("@")?Wn(N):N,S=!1,E=!1,L=!1,H=!1,q=!1;while(y.length>0){let me=0;if(y.startsWith("public")&&y.length>6&&!i(y.charCodeAt(6)))me=6;else if(y.startsWith("protected")&&y.length>9&&!i(y.charCodeAt(9)))me=9;else if(y.startsWith("private")&&y.length>7&&!i(y.charCodeAt(7)))me=7;else if(y.startsWith("readonly")&&y.length>8&&!i(y.charCodeAt(8)))me=8;else if(y.startsWith("override")&&y.length>8&&!i(y.charCodeAt(8)))me=8;else break;let De=y.slice(me).trimStart();if(!De||De[0]===":"||De[0]==="="||De[0]===","||De[0]==="?")break;if(me===6)S=!0;else if(me===9)E=!0;else if(me===7)L=!0;else if(y[0]==="r")H=!0;else q=!0;y=De}if(!S&&!E&&!L&&!H&&!q)continue;let j=[];if(L)j.push("private");if(S)j.push("public");if(E)j.push("protected");if(H)j.push("readonly");let de=j.length>0?`${j.join(" ")} `:"",se=Mn(y),K=y.search(/[?:=]/);if(K!==-1&&y.charCodeAt(K)!==63&&mi(y))se=se.replace(/^([\w$]+)\?:/,"$1:");let re="";if(ce&&!L&&K!==-1&&y.charCodeAt(K)===We){let me=y.slice(K+1);re=on(xr(R[_]),me,Ot(me))}o.push(L?` private ${se.split(/[?:]/,1)[0]};`:`${re} ${de}${se};`)}}function gn(t=" ",o="",s=!1){if(e>=x||h.charCodeAt(e)!==te)return"{}";e++;let l=ue.at(-1)?.path,d={path:l?`${l}.${o}`:o,bindings:new Map,exports:new Set,annotatedValues:new Set,ambient:s||ue.at(-1)?.ambient===!0};we.push(d),ue.push(d);let p=[],k=new Map;while(e<x){if(M(),e>=x)break;if(h.charCodeAt(e)===le){e++;break}if(h.charCodeAt(e)===ke){e++;continue}let T=!1;if(W("export"))T=!0,e+=6,M();let g=!1;if(W("declare"))g=!0,e+=7,M();let I=T?"export ":"";if(W("function")||W("async")&&Ai("async","function")){let R=!1;if(W("async"))R=!0,e+=5,M();e+=8,M();let _=e<x&&h.charCodeAt(e)===Ie;if(_)e++,M();let N=Qe();M();let y=kt();M();let S=yt();M();let E=Ft(),L=E.length>0;if(!L)if(R&&_)E="AsyncGenerator<unknown, void, unknown>";else if(_)E="Generator<unknown, void, unknown>";else E=R?"Promise<void>":"void";if(M(),e<x&&h.charCodeAt(e)===te){let q=e+1;if(et(te,le),!L&&_)E=Ue(h.slice(q,e-1),R,S,bt)}else if(e<x&&h.charCodeAt(e)===ke)e++;let H=It(S);p.push(`${t}${I}function ${N}${y}${H}: ${E};`)}else if(W("const")||W("let")||W("var")||W("using")&&an()||W("await")&&Sn()){let R="const";if(W("await"))e+=5,M(),e+=5;else if(W("using"))e+=5;else R=W("const")?"const":W("let")?"let":"var",e+=R.length;if(M(),R==="const"&&W("enum")){e+=4,M();let _=Qe();M();let N=e<x&&h.charCodeAt(e)===te?Gt():"{}",y=N;if(!d.ambient&&!g&&N.length>2){let S=gt(N,_,k);y=S.body;for(let[E,L]of S.members)if(typeof L==="string"||typeof L==="number")k.set(`${_}.${E}`,L)}p.push(`${t}${I}const enum ${_} ${y}`);continue}while(e<x){M();let _=Qe();if(d.bindings.set(_,"value"),T||d.ambient)d.exports.add(_);if(!_){tt(!0);break}M();let N="";if(e<x&&h.charCodeAt(e)===dt){e++,M();let E=e,L=0;while(e<x){if(rt())continue;let H=h.charCodeAt(e);if(H===ge||H===te||H===Ee||H===Me)L++;else if(H===le&&L===0)break;else if(H===xe||H===le||H===Be||H===Re&&!ut())L--;else if(L===0&&(H===ke||H===pt))break;else if(L===0&&H===We&&!rn())break;if(L===0&&Tt())break;e++}N=je(E,e)}if(N)d.annotatedValues.add(_);let y="";if(e<x&&h.charCodeAt(e)===We){e++,M();let E=e,L=0;while(e<x){if(rt())continue;let H=h.charCodeAt(e);if(H===ge||H===te||H===Ee||H===Me)L++;else if(H===le&&L===0)break;else if(H===xe||H===le||H===Be||H===Re&&!ut())L--;else if(L===0&&(H===ke||H===pt))break;if(L===0&&Tt())break;e++}y=je(E,e)}let S=e<x&&h.charCodeAt(e)===pt;if(S)e++;else if(e<x&&h.charCodeAt(e)===ke)e++;if(!N&&y){let E=P(y)??Jt(y);if(E)N=E;else if(R==="const"){if(N=fn(y),N==="unknown")N=Ot(y)}else N=Ot(y)}if(!N)N="unknown";if(p.push(`${t}${I}${R} ${_}: ${N};`),!S)break}}else if(W("interface")){e+=9,M();let R=Qe();M();let _=kt();M();let N="";if(W("extends")){e+=7,M();let S=e,E=0;while(e<x){if(rt())continue;let L=h.charCodeAt(e);if(L===Me)E++;else if(L===Re&&!ut())E--;else if(L===te&&E===0)break;e++}N=je(S,e)}let y=En(Gt());p.push(`${t}${I}interface ${R}${_}${N?` extends ${N}`:""} ${y}`)}else if(W("type")){let R=e;if(e+=4,M(),T&&e<x&&(h.charCodeAt(e)===te||h.charCodeAt(e)===Ie)){tt(!0);let y=je(R,e);if(y.charCodeAt(y.length-1)===ke)y=y.slice(0,-1);if(y)p.push(`${t}export ${y};`);continue}let _=Qe();M();let N=kt();if(M(),e<x&&h.charCodeAt(e)===We){e++,M();let y=e,S=0;while(e<x){if(rt())continue;let L=h.charCodeAt(e);if(L===ge||L===te||L===Ee||L===Me)S++;else if(L===le&&S===0)break;else if(L===xe||L===le||L===Be||L===Re&&!ut())S--;else if(S===0&&L===ke)break;if(S===0&&Tt())break;e++}let E=je(y,e);if(e<x&&h.charCodeAt(e)===ke)e++;p.push(`${t}${I}type ${_}${N} = ${E}`)}}else if(W("abstract")||W("class")){let R=!1;if(W("abstract"))R=!0,e+=8,M();if(W("class")){e+=5,M();let _=Qe();M();let N=kt();M();let y=e,S=0,E=0,L=0,H=0;while(e<x){if(rt())continue;let se=h.charCodeAt(e);if(se===Me)S++;else if(se===Re&&!ut()&&S>0)S--;else if(se===ge)E++;else if(se===xe&&E>0)E--;else if(se===Ee)L++;else if(se===Be&&L>0)L--;else if(se===te){if(S===0&&E===0&&L===0&&H===0)break;H++}else if(se===le&&H>0)H--;e++}let q=je(y,e),j=q?` ${q}`:"";if(d.bindings.set(_,"class"),T||d.ambient)d.exports.add(_);let de=Nn(_);p.push(`${t}${I}${R?"abstract ":""}class ${_}${N}${j} ${de}`)}else tt(!0)}else if(W("enum")){e+=4,M();let R=Qe();M();let _=Gt(),N=_;if(!d.ambient&&!g&&_.length>2){let y=gt(_,R,k);N=y.body;for(let[S,E]of y.members)if(typeof E==="string"||typeof E==="number")k.set(`${R}.${S}`,E)}p.push(`${t}${I}enum ${R} ${N}`)}else if(W("namespace")||W("module")){let R=W("namespace")?"namespace":"module";e+=R.length,M();let _=e,N=Qe(),y=e;while(!0){let L=e;if(M(),e<x&&h.charCodeAt(e)===Ct){if(e++,M(),Qe()){y=e;continue}}e=L;break}let S=N?h.slice(_,y):N;if(!d.bindings.has(N))d.bindings.set(N,"namespace");if(T||d.ambient)d.exports.add(N);M();let E=gn(t,S,g);p.push(`${t}${I}${R} ${S} ${E}`)}else if(T&&W("default")){e+=7,M();let R=e;tt(!0);let _=je(R,e);if(_.charCodeAt(_.length-1)===ke)_=_.slice(0,-1);if(_)p.push(`${t}export default ${_};`)}else if(!T&&W("import")){let R=e;tt(!0);let _=je(R,e);if(_.charCodeAt(_.length-1)===ke)_=_.slice(0,-1);if(_)p.push(`${t}${_};`)}else if(T&&e<x&&(h.charCodeAt(e)===te||h.charCodeAt(e)===Ie||h.charCodeAt(e)===We)){let R=e;tt(!0);let _=je(R,e);if(_.charCodeAt(_.length-1)===ke)_=_.slice(0,-1);if(_)p.push(`${t}export ${_};`)}else if(!T&&(h.charCodeAt(e)===$e||h.charCodeAt(e)===ve||h.charCodeAt(e)===Ge))tt(!0);else tt(!0)}if(ue.pop(),p.length===0)return"{}";return`{
|
|
50
|
+
${p.join(`
|
|
51
|
+
`)}
|
|
52
|
+
}`}function Ai(t,o){let s=e+t.length;while(s<x&&it(h.charCodeAt(s)))s++;for(let l=0;l<o.length;l++)if(s+l>=x||h.charCodeAt(s+l)!==o.charCodeAt(l))return!1;return s+o.length>=x||!i(h.charCodeAt(s+o.length))}function Wt(t,o,s){e+=s.length,M();let l="",d=h.charCodeAt(e);if(d===$e||d===ve){let _=e;mt(d),l=h.slice(_,e)}else{l=Qe();while(e<x&&h.charCodeAt(e)===Ct)e++,l+=`.${Qe()}`}M();let p=l.startsWith("'")||l.startsWith('"'),k=e<x&&h.charCodeAt(e)===te,T=p&&!k,g;if(k){let _=n(h.slice(t,e)),N=_.findIndex((S)=>S.kind==="word"&&["namespace","module"].includes(h.slice(t+S.start,t+S.end))),y=_.slice(0,N).some((S)=>S.kind==="word"&&h.slice(t+S.start,t+S.end)==="declare");g=gn(" ",l,y)}else if(T){if(e<x&&h.charCodeAt(e)===ke)e++;g=";"}else g="{}";let I=T?`${o?"export ":""}declare ${s} ${l};`:`${o?"export ":""}declare ${s} ${l} ${g}`,R=at(t);return{kind:"module",name:l,text:I,isExported:o,moduleForm:p?"quoted":s==="namespace"?"namespace":"identifier",source:p?l.slice(1,-1):void 0,leadingComments:R,start:t,end:e}}function mn(t,o){tt(!1,!1);let s=je(o,e);if(s.charCodeAt(s.length-1)===ke)s=s.slice(0,-1).trimEnd();if(!s)return;let l=a(s.charCodeAt(0));for(let R=1;l&&R<s.length;R++)l=i(s.charCodeAt(R));let d=at(t);if(l){ie.push({kind:"export",name:"default",text:`export default ${s};`,isExported:!0,isTypeOnly:!1,leadingComments:d,start:t,end:e});return}let p="__dtsx_default_export__",k=1;while(h.includes(p))p=`__dtsx_default_export_${k++}__`;let g=(P(s)??Jt(s))||bt(s)||r(s,!1),I=g==="unknown"&&Un(s)?`typeof ${s}`:g;ie.push({kind:"variable",name:p,text:`declare const ${p}: ${I};`,isExported:!1,typeAnnotation:I,modifiers:["const"],start:t,end:e}),ie.push({kind:"export",name:"default",text:`export default ${p};`,isExported:!0,isTypeOnly:!1,leadingComments:d,start:t,end:e})}function Hn(){if(h.charCodeAt(e)===te)return et(te,le),!0;let t=W("if"),o=W("do"),s=W("try"),l=W("for");if(!t&&!o&&!s&&!l&&!W("while")&&!W("switch")&&!W("with"))return!1;if(Qe(),M(),l&&W("await"))e+=5,M();if(!o&&!s&&h.charCodeAt(e)===ge)et(ge,xe);if(Yt(),M(),t&&W("else"))e+=4,Yt();else if(o&&W("while")){if(e+=5,M(),h.charCodeAt(e)===ge)et(ge,xe);if(M(),h.charCodeAt(e)===ke)e++}else if(s){if(W("catch")){if(e+=5,M(),h.charCodeAt(e)===ge)et(ge,xe);Yt(),M()}if(W("finally"))e+=7,Yt()}return!0}function Yt(){if(M(),!Hn())tt()}function en(){while(e<x&&h.charCodeAt(e)===Gn){if(e++,M(),e<x&&h.charCodeAt(e)===ge)et(ge,xe);else Qe();while(e<x){let t=e;if(M(),e>=x)break;let o=h.charCodeAt(e);if(o===Ct)e++,M(),Qe();else if(o===Ee&&!h.slice(t,e).includes(`
|
|
53
|
+
`))et(Ee,Be);else if(o===Me)et(Me,Re);else if(o===ge)et(ge,xe);else{e=t;break}}M()}}while(e<x){if(M(),e>=x)break;if(Hn())continue;let t=e,o=h.charCodeAt(e);if(o===105&&W("import")){let s=Bt("import");if(s===ge||s===Ct){tt();continue}let l=ci(t);if(l)Ne.set(l.name,l);else ie.push(ai(t))}else if(o===101&&W("export")){e+=6,M(),en();let s=h.charCodeAt(e);if(s===100&&W("default")){e+=7,M(),en();let l=e,d=h.charCodeAt(e);if(d===102&&W("function")){let p=xt(t,!0,!1,!0);if(p)ie.push(p)}else if(d===97&&W("async")&&Bt("async")!==ke){e+=5;let p=e;if(M(),!(h.slice(p,e).includes(`
|
|
54
|
+
`)||h.slice(p,e).includes("\r"))&&W("function")){let T=xt(t,!0,!0,!0);if(T)ie.push(T)}else e=l,mn(t,l)}else if(d===99&&W("class")){let p=$t(t,!0,!1,!0);ie.push(p)}else if(d===105&&W("interface")){let p=Zt(t,!0,!0);ie.push(p)}else if(d===97&&W("abstract")){e+=8;let p=e;if(M(),!(h.slice(p,e).includes(`
|
|
55
|
+
`)||h.slice(p,e).includes("\r"))&&W("class")){let T=$t(t,!0,!0,!0);ie.push(T)}else e=l,mn(t,l)}else mn(t,l)}else if(s===116&&W("type")){let l=e;if(e+=4,M(),e<x&&h.charCodeAt(e)===te){In();let d=je(t,e),p=at(t);ie.push({kind:"export",name:"",text:d,isExported:!0,isTypeOnly:!0,source:jt(d),leadingComments:p,start:t,end:e})}else if(e<x&&h.charCodeAt(e)===Ie){On();let d=je(t,e);ie.push({kind:"export",name:"",text:d,isExported:!0,isTypeOnly:!0,source:jt(d),start:t,end:e})}else{e=l;let d=un(t,!0);ie.push(d)}}else if(s===105&&W("interface")){let l=Zt(t,!0);ie.push(l)}else if(s===102&&W("function")){let l=xt(t,!0,!1,!1);if(l)ie.push(l)}else if(s===97&&W("async"))if(e+=5,M(),W("function")){let l=xt(t,!0,!0,!1);if(l)ie.push(l)}else tt();else if(s===99)if(W("class")){let l=$t(t,!0,!1);ie.push(l)}else if(W("const")){let l=e;if(e+=5,M(),W("enum")){e=l+5,M();let d=Et(t,!0,!0);ie.push(d)}else{e=l;let d=wt(t,"const",!0);for(let p=0;p<d.length;p++)ie.push(d[p])}}else tt();else if(s===97&&W("abstract")){if(e+=8,M(),W("class")){let l=$t(t,!0,!0);ie.push(l)}}else if(s===108&&W("let")){let l=wt(t,"let",!0);for(let d=0;d<l.length;d++)ie.push(l[d])}else if(s===118&&W("var")){let l=wt(t,"var",!0);for(let d=0;d<l.length;d++)ie.push(l[d])}else if(s===101&&W("enum")){let l=Et(t,!0,!1);ie.push(l)}else if(s===100&&W("declare"))e+=7,M(),Vn(t,!0);else if(s===110&&W("namespace")&&Ht(9)){let l=Wt(t,!0,"namespace");ie.push(l)}else if(s===109&&W("module")&&Ht(6)){let l=Wt(t,!0,"module");ie.push(l)}else if(s===te){In();let l=je(t,e),d=l.includes("export type"),p=at(t);ie.push({kind:"export",name:"",text:l,isExported:!0,isTypeOnly:d,source:jt(l),leadingComments:p,start:t,end:e})}else if(s===Ie){On();let l=je(t,e),d=at(t);ie.push({kind:"export",name:"",text:l,isExported:!0,isTypeOnly:!1,source:jt(l),leadingComments:d,start:t,end:e})}else{tt();let l=je(t,e);if(l)ie.push({kind:"export",name:"",text:l,isExported:!0,start:t,end:e})}}else if(o===100&&W("declare"))e+=7,M(),Vn(t,!1);else if(o===105&&W("interface")){let s=Zt(t,!1);fe(s.name,s)}else if(o===116&&W("type")){let s=un(t,!1);fe(s.name,s),ie.push(s)}else if(o===102&&W("function")){let s=xt(t,!1,!1,!1);if(s)wn(s);else tt()}else if(o===97)if(W("async")){let s=e;if(e+=5,M(),W("function")){let l=xt(t,!1,!0,!1);if(l)wn(l);else e=s,tt()}else e=s,tt()}else if(W("abstract"))if(e+=8,M(),W("class")){let s=$t(t,!1,!0);fe(s.name,s),ie.push(s)}else tt();else if(W("await")&&Sn()){e+=5,M();let s=wt(t,"const",!1);for(let l=0;l<s.length;l++)fe(s[l].name,s[l])}else{let s=e;if(tt(),e===s)e++}else if(o===99)if(W("class")){let s=$t(t,!1,!1);fe(s.name,s),ie.push(s)}else if(W("const")){let s=e;if(e+=5,M(),W("enum")){e=s+5,M();let l=Et(t,!1,!0);fe(l.name,l),ie.push(l)}else{e=s;let l=wt(t,"const",!1);for(let d=0;d<l.length;d++)fe(l[d].name,l[d])}}else{let s=e;if(tt(),e===s)e++}else if(o===101&&W("enum")){let s=Et(t,!1,!1);fe(s.name,s),ie.push(s)}else if(o===108&&W("let")||o===118&&W("var")){let s=W("let")?"let":"var",l=wt(t,s,!1);for(let d=0;d<l.length;d++)fe(l[d].name,l[d])}else if(o===117&&W("using")&&an()){let s=wt(t,"const",!1);for(let l=0;l<s.length;l++)fe(s[l].name,s[l])}else if(o===109&&W("module")&&Ht(6)){let s=Wt(t,!1,"module");ie.push(s)}else if(o===110&&W("namespace")&&Ht(9)){let s=Wt(t,!1,"namespace");ie.push(s)}else{let s=h.charCodeAt(e);if(s===ke)e++;else if(s===$e||s===ve){if(mt(s),e<x&&h.charCodeAt(e)===ke)e++}else if(s===Ge){if(Nt(),e<x&&h.charCodeAt(e)===ke)e++}else if(s===Gn)en();else{let l=e;if(tt(),e===l)e++}}}if(Ce.length){let t=new Set([...ie,...Ne.values()]),o=new Set([...t].filter((g)=>g.kind==="class").map((g)=>g.name)),s=new Set([...t].filter((g)=>g.kind==="variable"&&!!g.typeAnnotation).map((g)=>g.name)),l=new Set,d=new Map;for(let g of we)for(let[I,R]of g.bindings){let _=g.path?`${g.path}.${I}`:I;if(g.exports.has(I)&&(R!=="namespace"||!d.has(_)))d.set(_,R);if(g.exports.has(I)&&g.annotatedValues.has(I))l.add(_)}let p=new Set;for(let g of t)if(g.kind==="import"){for(let I of w(g.text))if(I==="Set"||I==="Map")p.add(I)}else if(g.kind!=="type"&&g.kind!=="interface"&&g.kind!=="export"){if(g.name==="Set"||g.name==="Map")p.add(g.name)}let k=new Map;for(let g of Ce){if(g.binding){let I=s.has(g.initializer);for(let R=g.namespaces.length-1;R>=0;R--){let _=g.namespaces[R],N=_.path?`${_.path}.${g.initializer}`:g.initializer;if(_.bindings.has(g.initializer)||d.has(N)){I=_.bindings.has(g.initializer)?_.annotatedValues.has(g.initializer):l.has(N);break}}k.set(g.marker,I?`typeof ${g.initializer}`:"unknown");continue}k.set(g.marker,Se(g.initializer,(I)=>{if(g.classes.includes(I))return!0;for(let R=g.namespaces.length-1;R>=0;R--){let _=g.namespaces[R],N=_.path?`${_.path}.${I}`:I,y=I.split(".")[0],S=_.bindings.get(y);if(S){if(I===y&&S!=="namespace")return S==="class";return d.get(N)==="class"}let E=_.path?`${_.path}.${y}`:y;if(d.has(E))return d.get(N)==="class"}return d.has(I)?d.get(I)==="class":o.has(I)},(I)=>{if(p.has(I)||g.classes.includes(I))return!0;for(let R=g.namespaces.length-1;R>=0;R--)if(g.namespaces[R].bindings.has(I))return!0;return!1}))}let T=(g)=>{if(!g.includes("__dtsx_constructor_field_"))return g;let I="",R=0;for(let _ of n(g)){if(_.kind!=="word")continue;let N=k.get(g.slice(_.start,_.end));if(!N)continue;I+=g.slice(R,_.start)+N,R=_.end}return I+g.slice(R)};for(let g of t){g.text=T(g.text);for(let I of["typeAnnotation","inferredType","returnType"])if(g[I])g[I]=T(g[I])}}if(Fe.size>0){qn(ie);for(let t of Oe.values())qn(t)}if(dr(h,ie,Ne,Oe),Sr(ie,Ne),$r(ie,Ne),ye)qt([...ie,...Ne.values()]);else pr(h,ie,Ne,pe);if(be){let t=new Set(ie);for(let o of[...Ne.values(),...[...Oe.values()].flat(),...[...nt.values()].flat()])if(!t.has(o))ie.push(o),t.add(o);return ie.sort((o,s)=>(o.start??0)-(s.start??0))}if(Ne.size>0)$i(ie,Ne,Oe,nt,st);return Jn.set(ie,st),ie;function qn(t){let o=new Map;for(let l of t)if(l.kind==="function")o.set(l.name,(o.get(l.name)||0)+1);let s=new Set;for(let[l,d]of o)if(d>1)s.add(l);if(s.size>0){let l=new Set;for(let d of s)for(let p=t.length-1;p>=0;p--)if(t[p].kind==="function"&&t[p].name===d&&Fe.has(t[p])){l.add(p);break}if(l.size>0){let d=[...l].sort((p,k)=>k-p);for(let p of d)t.splice(p,1)}}}function Vn(t,o){if(W("function")){let s=xt(t,o,!1,!1);if(s)ie.push(s)}else if(W("async")){if(e+=5,M(),W("function")){let s=xt(t,o,!0,!1);if(s)ie.push(s)}}else if(W("class")){let s=$t(t,o,!1);ie.push(s)}else if(W("abstract")){if(e+=8,M(),W("class")){let s=$t(t,o,!0);ie.push(s)}}else if(W("interface")){let s=Zt(t,o);ie.push(s)}else if(W("type")){let s=un(t,o);ie.push(s)}else if(W("enum")){let s=Et(t,o,!1);ie.push(s)}else if(W("const")){let s=e;if(e+=5,M(),W("enum")){e=s+5,M();let l=Et(t,o,!0);ie.push(l)}else{e=s;let l=wt(t,"const",o);for(let d=0;d<l.length;d++)if(o||!st)ie.push(l[d]);else fe(l[d].name,l[d])}}else if(W("let")||W("var")){let s=W("let")?"let":"var",l=wt(t,s,o);for(let d=0;d<l.length;d++)if(o||!st)ie.push(l[d]);else fe(l[d].name,l[d])}else if(W("module")){let s=Wt(t,o,"module");ie.push(s)}else if(W("namespace")){let s=Wt(t,o,"namespace");ie.push(s)}else if(W("global")){e+=6,M();let l=`declare global ${e<x&&h.charCodeAt(e)===te?gn(" ","",!0):"{}"}`,d=at(t);ie.push({kind:"module",name:"global",text:l,isExported:!1,moduleForm:"global",leadingComments:d,start:t,end:e})}else tt()}}function Kn(F,J){let ne=0,he=F.length;while(ne<J.length){let be=J.indexOf(F,ne);if(be===-1)return!1;let pe=be>0?J.charCodeAt(be-1):32,h=be+he<J.length?J.charCodeAt(be+he):32,ce=!(pe>=65&&pe<=90||pe>=97&&pe<=122||pe>=48&&pe<=57||pe===95||pe===36),ye=!(h>=65&&h<=90||h>=97&&h<=122||h>=48&&h<=57||h===95||h===36);if(ce&&ye)return!0;ne=be+1}return!1}class Zn{names;lengths=new Uint8Array(65);asciiFirstUnits=new Uint8Array(128);nonAsciiFirstUnits=null;smallNames=null;smallIsValue=null;size;hasValueDecl;hasNonFunction;constructor(F){this.names=F;let J=!1,ne=!1,he=F.size>=1&&F.size<=8,be=he?[]:null,pe=he?[]:null;for(let[h,ce]of F){if(!h)continue;let ye=ce.kind==="function"||ce.kind==="variable";if(ye)J=!0;if(ce.kind!=="function")ne=!0;if(be&&pe)be.push(h),pe.push(ye);this.lengths[Math.min(h.length,64)]=1;let x=h.charCodeAt(0);if(x<128)this.asciiFirstUnits[x]=1;else{if(!this.nonAsciiFirstUnits)this.nonAsciiFirstUnits=new Set;this.nonAsciiFirstUnits.add(x)}}this.smallNames=be,this.smallIsValue=pe,this.size=F.size,this.hasValueDecl=J,this.hasNonFunction=ne}scan(F,J,ne,he){if(this.size===0)return!1;if(!this.hasValueDecl&&!he&&J.size===this.size)return!1;let be=!1;if(this.smallNames&&this.smallIsValue){for(let ce=0;ce<this.smallNames.length;ce++){let ye=this.smallNames[ce];if(!this.smallIsValue[ce]){if(J.has(ye))continue;if(Kn(ye,F))J.add(ye)}else{if(!he&&ne.has(ye))continue;if(Kn(ye,F))J.add(ye),be=!0}}return be}let pe=0,h=F.length;while(pe<h){let ce=F.charCodeAt(pe);if(ce>=65&&ce<=90||ce>=97&&ce<=122||ce===95||ce===36||ce>127){let ye=pe;pe++;while(pe<h){let Le=F.charCodeAt(pe);if(Le>=65&&Le<=90||Le>=97&&Le<=122||Le>=48&&Le<=57||Le===95||Le===36||Le>127)pe++;else break}if((ce<128?this.asciiFirstUnits[ce]===1:this.nonAsciiFirstUnits?.has(ce)===!0)&&this.lengths[Math.min(pe-ye,64)]===1){let Le=F.substring(ye,pe),st=this.names.get(Le);if(st!==void 0){if(J.add(Le),st.kind==="function"||st.kind==="variable")be=!0;else if(!this.hasValueDecl&&!he&&J.size===this.size)return!1}}}else pe++}return be}}function Qn(F,J){let ne=0;while(ne<F.length){let he=F.charCodeAt(ne);if(he===$e||he===ve||he===Ge){let Le=he;ne++;while(ne<F.length)if(F.charCodeAt(ne)===lt)ne+=2;else if(F.charCodeAt(ne++)===Le)break;continue}if(he===Y&&F.charCodeAt(ne+1)===Y){ne+=2;while(ne<F.length&&F.charCodeAt(ne)!==Pe&&F.charCodeAt(ne)!==Ke)ne++;continue}if(he===Y&&F.charCodeAt(ne+1)===Ie){let Le=F.indexOf("*/",ne+2);ne=Le===-1?F.length:Le+2;continue}if(!a(he)){ne++;continue}let be=ne++;while(ne<F.length&&i(F.charCodeAt(ne)))ne++;let pe=be-1,h=ne;while(pe>=0&&it(F.charCodeAt(pe)))pe--;while(h<F.length&&it(F.charCodeAt(h)))h++;let ce=pe>=0?F.charCodeAt(pe):0,ye=h<F.length?F.charCodeAt(h):0,x=be>=3&&F.slice(be-3,be)==="...";if(ye===dt||ce===Ct&&!x)continue;if(ye===ge&&(ce===te||ce===pt))continue;J.add(F.slice(be,ne))}}function $i(F,J,ne,he,be){let pe=new Map;if(be){let G=0;for(let X of F)if(X.kind==="class"&&!X.isExported){if(pe.set(X.name,X),!J.has(X.name))J.set(X.name,X)}else if(!X.isExported&&(X.kind==="type"||X.kind==="interface")&&["variable","function"].includes(J.get(X.name)?.kind??""));else F[G++]=X;F.length=G}let h=new Set(F),ce=new Set,ye=new Set,x=new Set;for(let G of F)if(ye.add(G.name),G.kind!=="type"&&G.kind!=="interface")x.add(G.name);let Le=new Map;for(let[G,X]of he){let we=J.get(G);if(we?.kind==="variable"||we?.kind==="function")Le.set(G,X[0])}let st=new Map;for(let[G,X]of J)if(!(X.kind==="function"||X.kind==="variable"?x.has(G):ye.has(G))||pe.has(G)||Le.has(G))st.set(G,X);if(st.size===0&&Le.size===0)return;let ie=new Zn(st),Ne=Le.size>0,nt=new Set,fe=new Set,Oe=new Set,Fe=new Set,e=(G)=>{if(ie.scan(G.text,Oe,Fe,Ne))wr(G,Fe,Ne?{candidates:Le,references:nt}:void 0)},Ve=new Set;for(let G=0;G<F.length;G++){if(!ie.hasValueDecl&&!Ne&&Oe.size===ie.size)break;let X=F[G];if(X.kind!=="import"){if(e(X),ie.hasNonFunction&&typeof X.value==="string")Qn(X.value,Ve)}}for(;;){let G=[];for(let[ue,Ce]of st){if(ce.has(ue))continue;if((Ce.kind==="function"||Ce.kind==="variable"?Fe:Oe).has(ue)||Ce.kind!=="function"&&Ve.has(ue)){let _e=pe.get(ue);if(_e){for(let Ye of[_e,Ce])if(!h.has(Ye))G.push(Ye),h.add(Ye);ye.add(ue)}else if(!(Ce.kind==="function"||Ce.kind==="variable"?x:ye).has(ue)){let Ye=Ce.kind==="function"?ne.get(ue):void 0;if(Ye)for(let ft of Ye)G.push(ft);else G.push(Ce);if(ye.add(ue),Ce.kind==="function"||Ce.kind==="variable")x.add(ue)}ce.add(ue)}}for(let[ue,Ce]of he){if(!Le.has(ue)||fe.has(ue)||!nt.has(ue))continue;for(let ot of Ce)if(!h.has(ot))G.push(ot),h.add(ot);fe.add(ue)}if(G.length===0)break;G.sort((ue,Ce)=>(ue.start??1/0)-(Ce.start??1/0));let X=[],we=0;for(let ue=0;ue<F.length;ue++){let Ce=F[ue].start??1/0;while(we<G.length&&(G[we].start??1/0)<=Ce)X.push(G[we++]);X.push(F[ue])}while(we<G.length)X.push(G[we++]);F.length=0;for(let ue=0;ue<X.length;ue++)F.push(X[ue]);for(let ue of G)if(ue.kind!=="import"){if(e(ue),ie.hasNonFunction&&typeof ue.value==="string")Qn(ue.value,Ve)}}}
|
|
56
|
+
export{ar,cr,rc,V,U,Kt};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{g}from"./chunk-j2bapmng.js";import{existsSync as u,mkdirSync as H,readFileSync as l,renameSync as b,rmdirSync as D,rmSync as C,statSync as p,writeFileSync as S}from"fs";import{join as d,relative as h,resolve as y}from"path";var f=30,m=".dtsx-cache",v="manifest.json";function fi(t){try{C(d(t,v),{force:!0});try{D(t)}catch{}}catch{}}class nt{cacheDir;manifestPath;manifest=null;configHash;constructor(t,n){this.cacheDir=y(t.cwd,t.cacheDir??m),this.manifestPath=d(this.cacheDir,v),this.configHash=this.hashConfig(t,n)}hashConfig(t,n){let s={resolutionContext:n,keepComments:t.keepComments,importOrder:t.importOrder,outputStructure:t.outputStructure,moduleSpecifierMode:t.moduleSpecifierMode??"preserve",root:y(t.cwd,t.root),exclude:t.exclude??[],isolatedDeclarations:t.isolatedDeclarations,declarationMap:t.declarationMap,indentStyle:t.indentStyle,indentSize:t.indentSize,prettier:t.prettier,typeMappings:t.typeMappings?{includeDefaults:t.typeMappings.includeDefaults,presets:t.typeMappings.presets,cacheKey:t.typeMappings.cacheKey,rules:t.typeMappings.rules.map((e)=>({pattern:typeof e.pattern==="string"?{kind:"string",value:e.pattern}:{kind:"regex",source:e.pattern.source,flags:e.pattern.flags},replacement:e.replacement,global:e.global,priority:e.priority,hasCondition:Boolean(e.condition)}))}:void 0,lineEnding:t.lineEnding,normalizeOutput:t.normalizeOutput,declarationOrder:t.declarationOrder,plugins:t.plugins?.map((e)=>({name:e.name,version:e.version,cacheKey:e.cacheKey}))};return String(g(JSON.stringify(s)))}hashString(t){return String(g(t))}load(){try{if(!u(this.manifestPath))return!1;let t=l(this.manifestPath,"utf-8"),n=JSON.parse(t);if(n.version!==f)return!1;if(n.configHash!==this.configHash)return!1;if(!n.entries||typeof n.entries!=="object"||Array.isArray(n.entries))return!1;return this.manifest=n,!0}catch{return!1}}save(){if(!this.manifest)this.manifest={version:f,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};if(this.manifest.updatedAt=Date.now(),!u(this.cacheDir))H(this.cacheDir,{recursive:!0});let t=`${this.manifestPath}.${process.pid}.tmp`;try{S(t,JSON.stringify(this.manifest,null,2)),b(t,this.manifestPath)}finally{if(u(t))C(t,{force:!0})}}needsRegeneration(t,n){return this.getCachedIfValid(t,n)===null}getCached(t,n){return this.getCachedIfValid(t,n)}getCachedIfValid(t,n){if(!this.manifest)return null;let s=h(n,t),e=this.manifest.entries[s];if(!e)return null;if(typeof e.dtsContent!=="string"||typeof e.dtsHash!=="string"||e.configHash!==this.configHash||this.hashString(e.dtsContent)!==e.dtsHash)return null;try{let i=p(t),{mtimeMs:r,ctimeMs:a}=i;if(i.size!==e.sourceSize)return null;if(r!==e.sourceMtime||a!==e.sourceCtime){let o=l(t,"utf-8");if(this.hashString(o)!==e.sourceHash)return null;e.sourceMtime=r,e.sourceCtime=a}return e.dtsContent}catch{return null}}update(t,n,s,e){if(!this.manifest)this.manifest={version:f,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};let i=h(e,t),r,a,o;try{let c=p(t);r=c.mtimeMs,a=c.ctimeMs,o=c.size}catch{r=Date.now(),a=r,o=Buffer.byteLength(n)}this.manifest.entries[i]={sourcePath:i,sourceHash:this.hashString(n),sourceMtime:r,sourceCtime:a,sourceSize:o,dtsContent:s,dtsHash:this.hashString(s),generatedAt:Date.now(),configHash:this.configHash}}remove(t,n){if(!this.manifest)return;let s=h(n,t);delete this.manifest.entries[s]}clear(){this.manifest=null,fi(this.cacheDir)}getStats(){if(!this.manifest)return{entries:0,size:0};let t=Object.keys(this.manifest.entries).length,n=0;for(let s of Object.values(this.manifest.entries))n+=s.dtsContent.length;return{entries:t,size:n}}prune(t,n){if(!this.manifest)return 0;let s=0,e=new Set(Array.from(t).map((i)=>h(n,i)));for(let i of Object.keys(this.manifest.entries))if(!e.has(i))delete this.manifest.entries[i],s++;return s}}function $t(t){let n=d(t,".gitignore");try{let s="";if(u(n))s=l(n,"utf-8");if(!s.split(/\r?\n/).some((i)=>i.trim()===m||i.trim()===`${m}/`)){let i=s.trimEnd(),r=`${i}${i?`
|
|
3
3
|
|
|
4
4
|
`:""}# dtsx cache
|
|
5
5
|
${m}/
|
|
6
6
|
`;S(n,r)}}catch{}}
|
|
7
|
-
export{
|
|
7
|
+
export{fi,nt,$t};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function p(r,t){let e=r.trim();if(e==="string")return{type:"string"};if(e==="number")return{type:"number"};if(e==="boolean")return{type:"boolean"};if(e==="null")return{type:"null"};if(e==="undefined")return{type:"null"};if(e==="any"||e==="unknown")return{};if(e==="never")return{not:{}};if(e==="void")return{type:"null"};if(e==="bigint")return{type:"integer"};if(e==="symbol")return{type:"string",description:"Symbol type"};if(e==="object")return{type:"object"};if(e.startsWith("'")||e.startsWith('"'))return{const:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{const:Number.parseFloat(e)};if(e==="true")return{const:!0};if(e==="false")return{const:!1};let n=e.match(/^(.+)\[\]$/)||e.match(/^Array<(.+)>$/i);if(n)return{type:"array",items:p(n[1],t)};let i=e.match(/^\[(.+)\]$/);if(i){let f=l(i[1],",").map((d)=>p(d.trim(),t));return{type:"array",items:f,minItems:f.length,maxItems:f.length}}if(e.includes("|")){let f=l(e,"|");if(f.length>1){let d=f.filter((a)=>a.trim()!=="null"&&a.trim()!=="undefined");if(f.some((a)=>a.trim()==="null"||a.trim()==="undefined")&&d.length===1){let a=p(d[0],t);if(a.type&&typeof a.type==="string")return{...a,type:[a.type,"null"]};return{oneOf:[a,{type:"null"}]}}return{oneOf:f.map((a)=>p(a.trim(),t))}}}if(e.includes("&")){let f=l(e,"&");if(f.length>1)return{allOf:f.map((d)=>p(d.trim(),t))}}let s=e.match(/^Record<(.+),\s*(.+)>$/i);if(s)return{type:"object",additionalProperties:p(s[2],t)};let o=e.match(/^Promise<(.+)>$/i);if(o)return p(o[1],t);let u=e.match(/^Partial<(.+)>$/i);if(u)return{...p(u[1],t),required:[]};let h=e.match(/^Required<(.+)>$/i);if(h)return p(h[1],t);let c=e.match(/^Readonly<(.+)>$/i);if(c)return p(c[1],t);let y=e.match(/^Pick<(.+),\s*(.+)>$/i);if(y)return p(y[1],t);let b=e.match(/^Omit<(.+),\s*(.+)>$/i);if(b)return p(b[1],t);if(e==="Date")return{type:"string",format:"date-time"};if(/^[A-Z]\w*$/.test(e))return{$ref:`#/$defs/${e}`};return{type:"object"}}function
|
|
2
|
+
function p(r,t){let e=r.trim();if(e==="string")return{type:"string"};if(e==="number")return{type:"number"};if(e==="boolean")return{type:"boolean"};if(e==="null")return{type:"null"};if(e==="undefined")return{type:"null"};if(e==="any"||e==="unknown")return{};if(e==="never")return{not:{}};if(e==="void")return{type:"null"};if(e==="bigint")return{type:"integer"};if(e==="symbol")return{type:"string",description:"Symbol type"};if(e==="object")return{type:"object"};if(e.startsWith("'")||e.startsWith('"'))return{const:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{const:Number.parseFloat(e)};if(e==="true")return{const:!0};if(e==="false")return{const:!1};let n=e.match(/^(.+)\[\]$/)||e.match(/^Array<(.+)>$/i);if(n)return{type:"array",items:p(n[1],t)};let i=e.match(/^\[(.+)\]$/);if(i){let f=l(i[1],",").map((d)=>p(d.trim(),t));return{type:"array",items:f,minItems:f.length,maxItems:f.length}}if(e.includes("|")){let f=l(e,"|");if(f.length>1){let d=f.filter((a)=>a.trim()!=="null"&&a.trim()!=="undefined");if(f.some((a)=>a.trim()==="null"||a.trim()==="undefined")&&d.length===1){let a=p(d[0],t);if(a.type&&typeof a.type==="string")return{...a,type:[a.type,"null"]};return{oneOf:[a,{type:"null"}]}}return{oneOf:f.map((a)=>p(a.trim(),t))}}}if(e.includes("&")){let f=l(e,"&");if(f.length>1)return{allOf:f.map((d)=>p(d.trim(),t))}}let s=e.match(/^Record<(.+),\s*(.+)>$/i);if(s)return{type:"object",additionalProperties:p(s[2],t)};let o=e.match(/^Promise<(.+)>$/i);if(o)return p(o[1],t);let u=e.match(/^Partial<(.+)>$/i);if(u)return{...p(u[1],t),required:[]};let h=e.match(/^Required<(.+)>$/i);if(h)return p(h[1],t);let c=e.match(/^Readonly<(.+)>$/i);if(c)return p(c[1],t);let y=e.match(/^Pick<(.+),\s*(.+)>$/i);if(y)return p(y[1],t);let b=e.match(/^Omit<(.+),\s*(.+)>$/i);if(b)return p(b[1],t);if(e==="Date")return{type:"string",format:"date-time"};if(/^[A-Z]\w*$/.test(e))return{$ref:`#/$defs/${e}`};return{type:"object"}}function Bi(r,t={}){let e=t.indent??2,n=t.jsonSchemaDraft??"2020-12",i={"2020-12":"https://json-schema.org/draft/2020-12/schema","2019-09":"https://json-schema.org/draft/2019-09/schema","draft-07":"http://json-schema.org/draft-07/schema#"}[n],s=new Map,o={$schema:t.includeSchema!==!1?i:void 0,$defs:{}};for(let u of r)if(u.kind==="interface"||u.kind==="type"){let h=N(u,s,t);if(o.$defs)o.$defs[u.name]=h}if(o.$defs&&Object.keys(o.$defs).length===1){let[u,h]=Object.entries(o.$defs)[0];return JSON.stringify({$schema:o.$schema,title:u,...h},null,e)}return JSON.stringify(o,null,e)}function N(r,t,e){let n={type:"object"};if(e.includeDescriptions&&r.leadingComments?.length){let i=v(r.leadingComments);if(i)n.description=i}if(r.members&&r.members.length>0){n.properties={},n.required=[];for(let i of r.members)if(i.name&&i.typeAnnotation){let s=p(i.typeAnnotation,t);if(e.includeDescriptions&&i.leadingComments?.length){let u=v(i.leadingComments);if(u)s.description=u}if(n.properties[i.name]=s,!(i.modifiers?.includes("?")||i.text?.includes("?:")||e.allOptional))n.required.push(i.name)}if(n.required.length===0)delete n.required}else if(r.typeAnnotation)return p(r.typeAnnotation,t);return n}function _i(r,t={}){let e=["import { z } from 'zod'",""];for(let n of r)if(n.kind==="interface"||n.kind==="type"){let i=t.exportName||`${n.name}Schema`,s=x(n,t);if(e.push(`export const ${i} = ${s}`),e.push(""),t.useInfer!==!1)e.push(`export type ${n.name} = z.infer<typeof ${i}>`),e.push("")}return e.join(`
|
|
3
3
|
`)}function x(r,t){if(r.members&&r.members.length>0)return`z.object({
|
|
4
4
|
${r.members.filter((n)=>n.name&&n.typeAnnotation).map((n)=>{let i=m(n.typeAnnotation);if(n.modifiers?.includes("?")||n.text?.includes("?:")||t.allOptional)i=`${i}.optional()`;if(t.includeDescriptions&&n.leadingComments?.length){let o=v(n.leadingComments);if(o)i=`${i}.describe(${JSON.stringify(o)})`}return` ${n.name}: ${i}`}).join(`,
|
|
5
5
|
`)}
|
|
6
|
-
})`;if(r.typeAnnotation)return m(r.typeAnnotation);return"z.unknown()"}function m(r){let t=r.trim();if(t==="string")return"z.string()";if(t==="number")return"z.number()";if(t==="boolean")return"z.boolean()";if(t==="null")return"z.null()";if(t==="undefined")return"z.undefined()";if(t==="any")return"z.any()";if(t==="unknown")return"z.unknown()";if(t==="never")return"z.never()";if(t==="void")return"z.void()";if(t==="bigint")return"z.bigint()";if(t==="symbol")return"z.symbol()";if(t==="Date")return"z.date()";if(t.startsWith("'")||t.startsWith('"'))return`z.literal(${t})`;if(/^-?\d+(\.\d+)?$/.test(t))return`z.literal(${t})`;if(t==="true"||t==="false")return`z.literal(${t})`;let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`z.array(${m(e[1])})`;let n=t.match(/^\[(.+)\]$/);if(n)return`z.tuple([${l(n[1],",").map((b)=>m(b.trim())).join(", ")}])`;if(t.includes("|")){let y=l(t,"|");if(y.length>1){let b=y.filter((a)=>a.trim()!=="null"&&a.trim()!=="undefined"),f=y.some((a)=>a.trim()==="null"),d=y.some((a)=>a.trim()==="undefined");if((f||d)&&b.length===1){let a=m(b[0]);if(f)a=`${a}.nullable()`;if(d)a=`${a}.optional()`;return a}return`z.union([${y.map((a)=>m(a.trim())).join(", ")}])`}}if(t.includes("&")){let y=l(t,"&");if(y.length>1)return y.map((f)=>m(f.trim())).reduce((f,d)=>`${f}.and(${d})`)}let i=t.match(/^Record<(.+),\s*(.+)>$/i);if(i)return`z.record(${m(i[1])}, ${m(i[2])})`;let s=t.match(/^Promise<(.+)>$/i);if(s)return`z.promise(${m(s[1])})`;let o=t.match(/^Map<(.+),\s*(.+)>$/i);if(o)return`z.map(${m(o[1])}, ${m(o[2])})`;let u=t.match(/^Set<(.+)>$/i);if(u)return`z.set(${m(u[1])})`;let h=t.match(/^Partial<(.+)>$/i);if(h)return`${m(h[1])}.partial()`;let c=t.match(/^Required<(.+)>$/i);if(c)return`${m(c[1])}.required()`;if(/^[A-Z]\w*$/.test(t))return`${t}Schema`;return"z.unknown()"}function
|
|
6
|
+
})`;if(r.typeAnnotation)return m(r.typeAnnotation);return"z.unknown()"}function m(r){let t=r.trim();if(t==="string")return"z.string()";if(t==="number")return"z.number()";if(t==="boolean")return"z.boolean()";if(t==="null")return"z.null()";if(t==="undefined")return"z.undefined()";if(t==="any")return"z.any()";if(t==="unknown")return"z.unknown()";if(t==="never")return"z.never()";if(t==="void")return"z.void()";if(t==="bigint")return"z.bigint()";if(t==="symbol")return"z.symbol()";if(t==="Date")return"z.date()";if(t.startsWith("'")||t.startsWith('"'))return`z.literal(${t})`;if(/^-?\d+(\.\d+)?$/.test(t))return`z.literal(${t})`;if(t==="true"||t==="false")return`z.literal(${t})`;let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`z.array(${m(e[1])})`;let n=t.match(/^\[(.+)\]$/);if(n)return`z.tuple([${l(n[1],",").map((b)=>m(b.trim())).join(", ")}])`;if(t.includes("|")){let y=l(t,"|");if(y.length>1){let b=y.filter((a)=>a.trim()!=="null"&&a.trim()!=="undefined"),f=y.some((a)=>a.trim()==="null"),d=y.some((a)=>a.trim()==="undefined");if((f||d)&&b.length===1){let a=m(b[0]);if(f)a=`${a}.nullable()`;if(d)a=`${a}.optional()`;return a}return`z.union([${y.map((a)=>m(a.trim())).join(", ")}])`}}if(t.includes("&")){let y=l(t,"&");if(y.length>1)return y.map((f)=>m(f.trim())).reduce((f,d)=>`${f}.and(${d})`)}let i=t.match(/^Record<(.+),\s*(.+)>$/i);if(i)return`z.record(${m(i[1])}, ${m(i[2])})`;let s=t.match(/^Promise<(.+)>$/i);if(s)return`z.promise(${m(s[1])})`;let o=t.match(/^Map<(.+),\s*(.+)>$/i);if(o)return`z.map(${m(o[1])}, ${m(o[2])})`;let u=t.match(/^Set<(.+)>$/i);if(u)return`z.set(${m(u[1])})`;let h=t.match(/^Partial<(.+)>$/i);if(h)return`${m(h[1])}.partial()`;let c=t.match(/^Required<(.+)>$/i);if(c)return`${m(c[1])}.required()`;if(/^[A-Z]\w*$/.test(t))return`${t}Schema`;return"z.unknown()"}function ji(r,t={}){let e=["import * as v from 'valibot'",""];for(let n of r)if(n.kind==="interface"||n.kind==="type"){let i=t.exportName||`${n.name}Schema`,s=j(n,t);if(e.push(`export const ${i} = ${s}`),e.push(""),t.useInfer!==!1)e.push(`export type ${n.name} = v.InferOutput<typeof ${i}>`),e.push("")}return e.join(`
|
|
7
7
|
`)}function j(r,t){if(r.members&&r.members.length>0)return`v.object({
|
|
8
8
|
${r.members.filter((n)=>n.name&&n.typeAnnotation).map((n)=>{let i=g(n.typeAnnotation);if(n.modifiers?.includes("?")||n.text?.includes("?:")||t.allOptional)i=`v.optional(${i})`;return` ${n.name}: ${i}`}).join(`,
|
|
9
9
|
`)}
|
|
10
|
-
})`;if(r.typeAnnotation)return g(r.typeAnnotation);return"v.unknown()"}function g(r){let t=r.trim();if(t==="string")return"v.string()";if(t==="number")return"v.number()";if(t==="boolean")return"v.boolean()";if(t==="null")return"v.null_()";if(t==="undefined")return"v.undefined_()";if(t==="any")return"v.any()";if(t==="unknown")return"v.unknown()";if(t==="never")return"v.never()";if(t==="void")return"v.void_()";if(t==="bigint")return"v.bigint()";if(t==="symbol")return"v.symbol()";if(t==="Date")return"v.date()";if(t.startsWith("'")||t.startsWith('"'))return`v.literal(${t})`;if(/^-?\d+(\.\d+)?$/.test(t))return`v.literal(${t})`;if(t==="true"||t==="false")return`v.literal(${t})`;let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`v.array(${g(e[1])})`;let n=t.match(/^\[(.+)\]$/);if(n)return`v.tuple([${l(n[1],",").map((o)=>g(o.trim())).join(", ")}])`;if(t.includes("|")){let s=l(t,"|");if(s.length>1){let o=s.filter((c)=>c.trim()!=="null"&&c.trim()!=="undefined"),u=s.some((c)=>c.trim()==="null"),h=s.some((c)=>c.trim()==="undefined");if((u||h)&&o.length===1){let c=g(o[0]);if(u)c=`v.nullable(${c})`;if(h)c=`v.optional(${c})`;return c}return`v.union([${s.map((c)=>g(c.trim())).join(", ")}])`}}if(t.includes("&")){let s=l(t,"&");if(s.length>1)return`v.intersect([${s.map((o)=>g(o.trim())).join(", ")}])`}let i=t.match(/^Record<(.+),\s*(.+)>$/i);if(i)return`v.record(${g(i[1])}, ${g(i[2])})`;if(/^[A-Z]\w*$/.test(t))return`${t}Schema`;return"v.unknown()"}function
|
|
10
|
+
})`;if(r.typeAnnotation)return g(r.typeAnnotation);return"v.unknown()"}function g(r){let t=r.trim();if(t==="string")return"v.string()";if(t==="number")return"v.number()";if(t==="boolean")return"v.boolean()";if(t==="null")return"v.null_()";if(t==="undefined")return"v.undefined_()";if(t==="any")return"v.any()";if(t==="unknown")return"v.unknown()";if(t==="never")return"v.never()";if(t==="void")return"v.void_()";if(t==="bigint")return"v.bigint()";if(t==="symbol")return"v.symbol()";if(t==="Date")return"v.date()";if(t.startsWith("'")||t.startsWith('"'))return`v.literal(${t})`;if(/^-?\d+(\.\d+)?$/.test(t))return`v.literal(${t})`;if(t==="true"||t==="false")return`v.literal(${t})`;let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`v.array(${g(e[1])})`;let n=t.match(/^\[(.+)\]$/);if(n)return`v.tuple([${l(n[1],",").map((o)=>g(o.trim())).join(", ")}])`;if(t.includes("|")){let s=l(t,"|");if(s.length>1){let o=s.filter((c)=>c.trim()!=="null"&&c.trim()!=="undefined"),u=s.some((c)=>c.trim()==="null"),h=s.some((c)=>c.trim()==="undefined");if((u||h)&&o.length===1){let c=g(o[0]);if(u)c=`v.nullable(${c})`;if(h)c=`v.optional(${c})`;return c}return`v.union([${s.map((c)=>g(c.trim())).join(", ")}])`}}if(t.includes("&")){let s=l(t,"&");if(s.length>1)return`v.intersect([${s.map((o)=>g(o.trim())).join(", ")}])`}let i=t.match(/^Record<(.+),\s*(.+)>$/i);if(i)return`v.record(${g(i[1])}, ${g(i[2])})`;if(/^[A-Z]\w*$/.test(t))return`${t}Schema`;return"v.unknown()"}function Gi(r,t={}){let e=["import * as t from 'io-ts'",""];for(let n of r)if(n.kind==="interface"||n.kind==="type"){let i=t.exportName||`${n.name}Codec`,s=A(n,t);if(e.push(`export const ${i} = ${s}`),e.push(""),t.useInfer!==!1)e.push(`export type ${n.name} = t.TypeOf<typeof ${i}>`),e.push("")}return e.join(`
|
|
11
11
|
`)}function A(r,t){if(r.members&&r.members.length>0){let e=[],n=[];for(let i of r.members){if(!i.name||!i.typeAnnotation)continue;let s=O(i.typeAnnotation),o=i.modifiers?.includes("?")||i.text?.includes("?:")||t.allOptional,u=` ${i.name}: ${s}`;if(o)n.push(u);else e.push(u)}if(n.length>0)return`t.intersection([
|
|
12
12
|
t.type({
|
|
13
13
|
${e.join(`,
|
|
@@ -20,15 +20,15 @@ ${n.join(`,
|
|
|
20
20
|
])`;return`t.type({
|
|
21
21
|
${e.join(`,
|
|
22
22
|
`)}
|
|
23
|
-
})`}if(r.typeAnnotation)return O(r.typeAnnotation);return"t.unknown"}function O(r){let t=r.trim();if(t==="string")return"t.string";if(t==="number")return"t.number";if(t==="boolean")return"t.boolean";if(t==="null")return"t.null";if(t==="undefined")return"t.undefined";if(t==="any")return"t.unknown";if(t==="unknown")return"t.unknown";if(t==="never")return"t.never";if(t==="void")return"t.void";if(t.startsWith("'")||t.startsWith('"'))return`t.literal(${t})`;if(/^-?\d+(\.\d+)?$/.test(t))return`t.literal(${t})`;if(t==="true"||t==="false")return`t.literal(${t})`;let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`t.array(${O(e[1])})`;let n=t.match(/^\[(.+)\]$/);if(n)return`t.tuple([${l(n[1],",").map((o)=>O(o.trim())).join(", ")}])`;if(t.includes("|")){let s=l(t,"|");if(s.length>1)return`t.union([${s.map((o)=>O(o.trim())).join(", ")}])`}if(t.includes("&")){let s=l(t,"&");if(s.length>1)return`t.intersection([${s.map((o)=>O(o.trim())).join(", ")}])`}let i=t.match(/^Record<(.+),\s*(.+)>$/i);if(i)return`t.record(${O(i[1])}, ${O(i[2])})`;if(/^[A-Z]\w*$/.test(t))return`${t}Codec`;return"t.unknown"}function
|
|
23
|
+
})`}if(r.typeAnnotation)return O(r.typeAnnotation);return"t.unknown"}function O(r){let t=r.trim();if(t==="string")return"t.string";if(t==="number")return"t.number";if(t==="boolean")return"t.boolean";if(t==="null")return"t.null";if(t==="undefined")return"t.undefined";if(t==="any")return"t.unknown";if(t==="unknown")return"t.unknown";if(t==="never")return"t.never";if(t==="void")return"t.void";if(t.startsWith("'")||t.startsWith('"'))return`t.literal(${t})`;if(/^-?\d+(\.\d+)?$/.test(t))return`t.literal(${t})`;if(t==="true"||t==="false")return`t.literal(${t})`;let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`t.array(${O(e[1])})`;let n=t.match(/^\[(.+)\]$/);if(n)return`t.tuple([${l(n[1],",").map((o)=>O(o.trim())).join(", ")}])`;if(t.includes("|")){let s=l(t,"|");if(s.length>1)return`t.union([${s.map((o)=>O(o.trim())).join(", ")}])`}if(t.includes("&")){let s=l(t,"&");if(s.length>1)return`t.intersection([${s.map((o)=>O(o.trim())).join(", ")}])`}let i=t.match(/^Record<(.+),\s*(.+)>$/i);if(i)return`t.record(${O(i[1])}, ${O(i[2])})`;if(/^[A-Z]\w*$/.test(t))return`${t}Codec`;return"t.unknown"}function Vi(r,t={}){let e=["import * as yup from 'yup'",""];for(let n of r)if(n.kind==="interface"||n.kind==="type"){let i=t.exportName||`${n.name}Schema`,s=z(n,t);if(e.push(`export const ${i} = ${s}`),e.push(""),t.useInfer!==!1)e.push(`export type ${n.name} = yup.InferType<typeof ${i}>`),e.push("")}return e.join(`
|
|
24
24
|
`)}function z(r,t){if(r.members&&r.members.length>0)return`yup.object({
|
|
25
25
|
${r.members.filter((n)=>n.name&&n.typeAnnotation).map((n)=>{let i=T(n.typeAnnotation);if(!(n.modifiers?.includes("?")||n.text?.includes("?:")||t.allOptional))i=`${i}.required()`;return` ${n.name}: ${i}`}).join(`,
|
|
26
26
|
`)}
|
|
27
|
-
})`;if(r.typeAnnotation)return T(r.typeAnnotation);return"yup.mixed()"}function T(r){let t=r.trim();if(t==="string")return"yup.string()";if(t==="number")return"yup.number()";if(t==="boolean")return"yup.boolean()";if(t==="Date")return"yup.date()";if(t==="any"||t==="unknown")return"yup.mixed()";let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`yup.array().of(${T(e[1])})`;if(t.includes("|")){let n=l(t,"|");if(n.length>1){let i=n.filter((o)=>o.trim()!=="null"&&o.trim()!=="undefined");if(n.some((o)=>o.trim()==="null"||o.trim()==="undefined")&&i.length===1)return`${T(i[0])}.nullable()`}}if(/^[A-Z]\w*$/.test(t))return`${t}Schema`;return"yup.mixed()"}function
|
|
27
|
+
})`;if(r.typeAnnotation)return T(r.typeAnnotation);return"yup.mixed()"}function T(r){let t=r.trim();if(t==="string")return"yup.string()";if(t==="number")return"yup.number()";if(t==="boolean")return"yup.boolean()";if(t==="Date")return"yup.date()";if(t==="any"||t==="unknown")return"yup.mixed()";let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`yup.array().of(${T(e[1])})`;if(t.includes("|")){let n=l(t,"|");if(n.length>1){let i=n.filter((o)=>o.trim()!=="null"&&o.trim()!=="undefined");if(n.some((o)=>o.trim()==="null"||o.trim()==="undefined")&&i.length===1)return`${T(i[0])}.nullable()`}}if(/^[A-Z]\w*$/.test(t))return`${t}Schema`;return"yup.mixed()"}function Ui(r,t={}){let e=["import { type } from 'arktype'",""];for(let n of r)if(n.kind==="interface"||n.kind==="type"){let i=t.exportName||n.name,s=w(n,t);if(e.push(`export const ${i} = ${s}`),e.push(""),t.useInfer!==!1)e.push(`export type ${n.name}Type = typeof ${i}.infer`),e.push("")}return e.join(`
|
|
28
28
|
`)}function w(r,t){if(r.members&&r.members.length>0)return`type({
|
|
29
29
|
${r.members.filter((n)=>n.name&&n.typeAnnotation).map((n)=>{let i=S(n.typeAnnotation);return` ${n.modifiers?.includes("?")||n.text?.includes("?:")||t.allOptional?`'${n.name}?'`:`${n.name}`}: ${i}`}).join(`,
|
|
30
30
|
`)}
|
|
31
|
-
})`;if(r.typeAnnotation)return`type(${S(r.typeAnnotation)})`;return"type('unknown')"}function S(r){let t=r.trim();if(t==="string")return"'string'";if(t==="number")return"'number'";if(t==="boolean")return"'boolean'";if(t==="null")return"'null'";if(t==="undefined")return"'undefined'";if(t==="bigint")return"'bigint'";if(t==="symbol")return"'symbol'";if(t==="Date")return"'Date'";if(t==="any"||t==="unknown")return"'unknown'";let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`${S(e[1])}.array()`;if(t.includes("|")){let n=l(t,"|");if(n.length>1)return`'${n.map((i)=>i.trim()).join(" | ")}'`}if(t.startsWith("'")||t.startsWith('"'))return`'${t}'`;return`'${t}'`}function l(r,t){let e=[],n="",i=0;for(let s=0;s<r.length;s++){let o=r[s];if(o==="<"||o==="("||o==="["||o==="{")i++,n+=o;else if(o===">"||o===")"||o==="]"||o==="}")i--,n+=o;else if(i===0&&r.slice(s,s+t.length)===t)e.push(n.trim()),n="",s+=t.length-1;else n+=o}if(n.trim())e.push(n.trim());return e}function v(r){for(let t of r){let e=t.replace(/^\/\*\*|\*\/$/g,"").replace(/^\s*\*\s?/gm,"").replace(/@\w.*/g,"").trim();if(e)return e}return null}function
|
|
31
|
+
})`;if(r.typeAnnotation)return`type(${S(r.typeAnnotation)})`;return"type('unknown')"}function S(r){let t=r.trim();if(t==="string")return"'string'";if(t==="number")return"'number'";if(t==="boolean")return"'boolean'";if(t==="null")return"'null'";if(t==="undefined")return"'undefined'";if(t==="bigint")return"'bigint'";if(t==="symbol")return"'symbol'";if(t==="Date")return"'Date'";if(t==="any"||t==="unknown")return"'unknown'";let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`${S(e[1])}.array()`;if(t.includes("|")){let n=l(t,"|");if(n.length>1)return`'${n.map((i)=>i.trim()).join(" | ")}'`}if(t.startsWith("'")||t.startsWith('"'))return`'${t}'`;return`'${t}'`}function l(r,t){let e=[],n="",i=0;for(let s=0;s<r.length;s++){let o=r[s];if(o==="<"||o==="("||o==="["||o==="{")i++,n+=o;else if(o===">"||o===")"||o==="]"||o==="}")i--,n+=o;else if(i===0&&r.slice(s,s+t.length)===t)e.push(n.trim()),n="",s+=t.length-1;else n+=o}if(n.trim())e.push(n.trim());return e}function v(r){for(let t of r){let e=t.replace(/^\/\*\*|\*\/$/g,"").replace(/^\s*\*\s?/gm,"").replace(/@\w.*/g,"").trim();if(e)return e}return null}function fa(r,t){switch(t.format){case"json-schema":return Bi(r,t);case"zod":return _i(r,t);case"valibot":return ji(r,t);case"io-ts":return Gi(r,t);case"yup":return Vi(r,t);case"arktype":return Ui(r,t);case"dts":default:return r.map((e)=>e.text).join(`
|
|
32
32
|
|
|
33
|
-
`)}}function
|
|
34
|
-
export{
|
|
33
|
+
`)}}function da(r){switch(r){case"json-schema":return".schema.json";case"zod":case"valibot":case"io-ts":case"yup":case"arktype":return".schema.ts";case"dts":default:return".d.ts"}}
|
|
34
|
+
export{Bi,_i,ji,Gi,Vi,Ui,fa,da};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{
|
|
2
|
+
import{M}from"./chunk-e12f4mpd.js";import{fe}from"./chunk-xrtfb38p.js";import{ue,Oe}from"./chunk-253e6nb4.js";import{Nn}from"./chunk-y7bcjjqd.js";import{spawn as j}from"child_process";var N=new Set(["cwd","root","outdir","entrypoints","include","exclude","autoIncludeReExports","outputStructure","tsconfigPath","moduleSpecifierMode","keepComments","isolatedDeclarations","clean","lineEnding"]);function x(l,f,d,n,u){let s=u.signal;s?.throwIfAborted();let c=u.timeoutMs??30000;if(!Number.isSafeInteger(c)||c<=0||c>2147483647)throw RangeError("Native project timeoutMs must be an integer between 1 and 2147483647");return new Promise((g,r)=>{let o=j(l,f,{cwd:n,stdio:["pipe","pipe","pipe"],windowsHide:!0}),i=[],a=[],e,h,v=!1,p=(t)=>{e??=t,o.kill()},m=()=>p(s?.reason instanceof Error?s.reason:Error("Native declaration project aborted",{cause:s?.reason})),b=setTimeout(()=>p(Error(`Native declaration project exceeded ${c}ms`)),c),E=(t,w)=>{if(v)return;if(v=!0,clearTimeout(b),s?.removeEventListener("abort",m),t)r(t);else g(w)};if(o.once("error",(t)=>E(t)),o.stdout.on("data",(t)=>i.push(Buffer.from(t))),o.stderr.on("data",(t)=>a.push(Buffer.from(t))),o.stdout.once("error",p),o.stderr.once("error",p),o.stdin.once("error",(t)=>{h??=t}),o.once("close",(t,w)=>{if(t!==0&&!e)e=Error(`Native declaration project failed (${w??t}): ${Buffer.concat(a).toString("utf8")}`);E(e??h,Buffer.concat(i).toString("utf8"))}),s?.addEventListener("abort",m,{once:!0}),s?.aborted)m();o.stdin.end(Buffer.from(d,"utf8"))})}async function Rs(l,f={},d={}){if(!l||l.includes("\x00"))throw Error("A native zig-dtsx executable is required");for(let i of Object.keys(f))if(!N.has(i))throw Error(`Native declaration project does not support option: ${i}`);d.signal?.throwIfAborted();let n={...M,...f};if(await ue(n),n.isolatedDeclarations===void 0)n.isolatedDeclarations=await fe(n);let u=await Nn(n),s=["--batch"];if(!n.keepComments)s.push("--no-comments");if(n.isolatedDeclarations)s.push("--isolated-declarations");let c=JSON.stringify({protocol:"zig-dtsx-project",version:1,files:u.files.map((i)=>({source:i.source,context:i.context}))}),g=await x(l,s,c,n.cwd,d),r;try{r=JSON.parse(g)}catch(i){throw Error("Native executable did not return a valid zig-dtsx project protocol response",{cause:i})}if(!r||typeof r!=="object"||!("protocol"in r)||r.protocol!=="zig-dtsx-project"||!("version"in r)||r.version!==1||!("files"in r)||!Array.isArray(r.files)||r.files.length!==u.files.length)throw Error("Native executable returned an unsupported or incomplete project response");let o=new Map;for(let[i,a]of u.files.entries()){let e=r.files[i];if(!e||typeof e!=="object"||!("sourceFile"in e)||e.sourceFile!==a.sourceFile||!("outputFile"in e)||e.outputFile!==a.outputFile||!("sourceHash"in e)||e.sourceHash!==a.context.sourceHash||!("content"in e)||typeof e.content!=="string")throw Error(`Native executable returned a mismatched project result for ${a.sourceFile}`);o.set(a.outputFile,{content:e.content,lineEnding:n.lineEnding})}return d.signal?.throwIfAborted(),await Oe(n,o),Object.freeze({filesGenerated:o.size,outputFiles:Object.freeze([...o.keys()])})}
|
|
3
|
+
export{Rs};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{In}from"./chunk-nnayqrp5.js";var g=new Set(["This","True","False","Null","Undefined","Void","Never","Any","Unknown","Object","Infinity","NaN"]);function f(e,o={strings:!0}){let c="",n=0;while(n<e.length){let t=e.slice(n,n+2);if(t==="//"){let s=e.indexOf(`
|
|
3
3
|
`,n),a=s===-1?e.length:s;c+=" ".repeat(a-n),n=a;continue}if(t==="/*"){let s=e.indexOf("*/",n+2),a=s===-1?e.length:s+2;for(let r=n;r<a;r++)c+=e[r]===`
|
|
4
4
|
`?`
|
|
5
5
|
`:" ";n=a;continue}let i=e[n];if(o.strings&&(i==='"'||i==="'"||i==="`")){let s=i;c+=" ",n++;while(n<e.length){if(e[n]==="\\"){c+=" ",n+=2;continue}if(e[n]===s){c+=" ",n++;break}c+=e[n]===`
|
|
6
6
|
`?`
|
|
7
|
-
`:" ",n++}continue}c+=i,n++}return c}function m(e){let o=new Set,c=[/\b(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:type|interface|class|enum|namespace|module)\s+([A-Za-z_$][\w$]*)/g,/\b(?:export\s+)?(?:declare\s+)?(?:async\s+)?function\s*\*?\s*([A-Za-z_$][\w$]*)/g,/\b(?:export\s+)?declare\s+(?:const|let|var)\s+([A-Za-z_$][\w$]*)/g];for(let n of c)for(let t of e.matchAll(n))o.add(t[1]);return o}function d(e){let o=new Set;for(let c of e.matchAll(/\bimport\s+(?:type\s+)?([\s\S]*?)\s+from\s*['"`]/g)){let n=c[1],t=/\*\s*as\s+([A-Za-z_$][\w$]*)/.exec(n);if(t)o.add(t[1]);let i=n.split("{")[0].replace(/\*\s*as\s+[A-Za-z_$][\w$]*/,"");for(let a of i.split(",")){let r=a.trim();if(/^[A-Za-z_$][\w$]*$/.test(r))o.add(r)}let s=/\{([\s\S]*?)\}/.exec(n);if(s)for(let a of s[1].split(",")){let r=a.trim().replace(/^type\s+/,"");if(!r)continue;let l=/\bas\s+([A-Za-z_$][\w$]*)$/.exec(r);o.add(l?l[1]:r.split(/\s+/)[0])}}for(let c of e.matchAll(/\bimport\s*\(\s*['"`][^'"`]*['"`]\s*\)\s*\.\s*([A-Za-z_$][\w$]*)/g))o.add(c[1]);return o}function p(e){let o=new Set,c=(t)=>{for(let i of t.split(",")){let s=i.trim().split(/\s+|=/)[0]?.trim();if(s&&/^[A-Za-z_$][\w$]*$/.test(s))o.add(s)}},n=/\b(?:type|interface|class|function)\s+[A-Za-z_$][\w$]*\s*<([^<>]*(?:<[^<>]*>[^<>]*)*)>/g;for(let t of e.matchAll(n))c(t[1]);for(let t of e.matchAll(/(?:\b[A-Za-z_$][\w$]*)?\s*<([^<>()]*)>\s*\(/g))c(t[1]);for(let t of e.matchAll(/\binfer\s+([A-Za-z_$][\w$]*)/g))o.add(t[1]);for(let t of e.matchAll(/\[\s*([A-Za-z_$][\w$]*)\s+in\b/g))o.add(t[1]);return o}function h(e){let o=new Map,c=(t)=>{let i=1;for(let s=0;s<t&&s<e.length;s++)if(e.charCodeAt(s)===10)i++;return i},n=(t,i,s)=>{for(let a of t.matchAll(/\b([A-Z][\w$]*)\b/g)){let r=a[1];if(o.has(r))continue;let l=t.slice(a.index+r.length);if(/^\s*\??:/.test(l))continue;o.set(r,{line:c(i),context:s.trim().slice(0,120)})}};for(let t of e.matchAll(/\btype\s+[A-Za-z_$][\w$]*\s*(?:<[^=]*?>)?\s*=([^;]*)/g))n(t[1],t.index+t[0].indexOf("="),t[0]);for(let t of e.matchAll(/\b(?:extends|implements)\s+([^{;]*)/g))n(t[1],t.index,t[0]);for(let t of e.matchAll(/:\s*([^;,){}\n=]+)/g))n(t[1],t.index,t[0]);for(let t of e.matchAll(/<([^<>()]*)>/g))n(t[1],t.index,t[0]);return o}function
|
|
8
|
-
export{
|
|
7
|
+
`:" ",n++}continue}c+=i,n++}return c}function m(e){let o=new Set,c=[/\b(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:type|interface|class|enum|namespace|module)\s+([A-Za-z_$][\w$]*)/g,/\b(?:export\s+)?(?:declare\s+)?(?:async\s+)?function\s*\*?\s*([A-Za-z_$][\w$]*)/g,/\b(?:export\s+)?declare\s+(?:const|let|var)\s+([A-Za-z_$][\w$]*)/g];for(let n of c)for(let t of e.matchAll(n))o.add(t[1]);return o}function d(e){let o=new Set;for(let c of e.matchAll(/\bimport\s+(?:type\s+)?([\s\S]*?)\s+from\s*['"`]/g)){let n=c[1],t=/\*\s*as\s+([A-Za-z_$][\w$]*)/.exec(n);if(t)o.add(t[1]);let i=n.split("{")[0].replace(/\*\s*as\s+[A-Za-z_$][\w$]*/,"");for(let a of i.split(",")){let r=a.trim();if(/^[A-Za-z_$][\w$]*$/.test(r))o.add(r)}let s=/\{([\s\S]*?)\}/.exec(n);if(s)for(let a of s[1].split(",")){let r=a.trim().replace(/^type\s+/,"");if(!r)continue;let l=/\bas\s+([A-Za-z_$][\w$]*)$/.exec(r);o.add(l?l[1]:r.split(/\s+/)[0])}}for(let c of e.matchAll(/\bimport\s*\(\s*['"`][^'"`]*['"`]\s*\)\s*\.\s*([A-Za-z_$][\w$]*)/g))o.add(c[1]);return o}function p(e){let o=new Set,c=(t)=>{for(let i of t.split(",")){let s=i.trim().split(/\s+|=/)[0]?.trim();if(s&&/^[A-Za-z_$][\w$]*$/.test(s))o.add(s)}},n=/\b(?:type|interface|class|function)\s+[A-Za-z_$][\w$]*\s*<([^<>]*(?:<[^<>]*>[^<>]*)*)>/g;for(let t of e.matchAll(n))c(t[1]);for(let t of e.matchAll(/(?:\b[A-Za-z_$][\w$]*)?\s*<([^<>()]*)>\s*\(/g))c(t[1]);for(let t of e.matchAll(/\binfer\s+([A-Za-z_$][\w$]*)/g))o.add(t[1]);for(let t of e.matchAll(/\[\s*([A-Za-z_$][\w$]*)\s+in\b/g))o.add(t[1]);return o}function h(e){let o=new Map,c=(t)=>{let i=1;for(let s=0;s<t&&s<e.length;s++)if(e.charCodeAt(s)===10)i++;return i},n=(t,i,s)=>{for(let a of t.matchAll(/\b([A-Z][\w$]*)\b/g)){let r=a[1];if(o.has(r))continue;let l=t.slice(a.index+r.length);if(/^\s*\??:/.test(l))continue;o.set(r,{line:c(i),context:s.trim().slice(0,120)})}};for(let t of e.matchAll(/\btype\s+[A-Za-z_$][\w$]*\s*(?:<[^=]*?>)?\s*=([^;]*)/g))n(t[1],t.index+t[0].indexOf("="),t[0]);for(let t of e.matchAll(/\b(?:extends|implements)\s+([^{;]*)/g))n(t[1],t.index,t[0]);for(let t of e.matchAll(/:\s*([^;,){}\n=]+)/g))n(t[1],t.index,t[0]);for(let t of e.matchAll(/<([^<>()]*)>/g))n(t[1],t.index,t[0]);return o}function Mn(e){let o=f(e),c=f(e,{strings:!1}),n=new Set([...m(o),...d(c),...p(o),...In,...g]),t=[];for(let[i,s]of h(o)){if(n.has(i))continue;if(new RegExp(`[\\w$]\\s*\\.\\s*${i}\\b`).test(o))continue;t.push({name:i,line:s.line,context:s.context})}return t.sort((i,s)=>i.line-s.line||i.name.localeCompare(s.name))}
|
|
8
|
+
export{Mn};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{e,H}from"./chunk-bd048mjd.js";import{Ge}from"./chunk-4ce9a877.js";import{l}from"./chunk-0zwa1tag.js";import{existsSync as u,readFileSync as w}from"fs";import{dirname as W,join as d,resolve as v}from"path";async function ai(n){let i=[],s=new Set;async function t(c,a){let o=v(c);if(s.has(o))return;if(s.add(o),!u(o)){e.warn(`tsconfig not found: ${o}`);return}try{let f=w(o,"utf-8"),r=JSON.parse(Ge(f)),g=W(o),p=P(g,a),m=[];if(r.references)for(let y of r.references){let h=v(g,y.path),C=u(d(h,"tsconfig.json"))?d(h,"tsconfig.json"):h;await t(C,p);let G=P(W(C),p);m.push(G)}let j="./src";if(r.compilerOptions?.rootDir)j=r.compilerOptions.rootDir;else if(r.include&&r.include.length>0){if(r.include[0].startsWith("src/"))j="./src"}let k="./dist";if(r.compilerOptions?.outDir)k=r.compilerOptions.outDir;else if(r.compilerOptions?.declarationDir)k=r.compilerOptions.declarationDir;i.push({name:p,root:g,tsconfigPath:o,references:m,config:{root:j,outdir:k}})}catch(f){let r=f instanceof Error?f.message:String(f);e.warn(`Failed to parse ${o}: ${r}`)}}return await t(n),i}function P(n,i){let s=d(n,"package.json");if(u(s))try{let c=w(s,"utf-8"),a=JSON.parse(c);if(a.name)return a.name}catch{}let t=n.split("/").pop()||"unknown";return i?`${i}/${t}`:t}function ci(n){let i=new Map(n.map((o)=>[o.name,o])),s=[],t=new Set,c=new Set;function a(o){if(t.has(o))return;if(c.has(o)){e.warn(`Circular dependency detected involving: ${o}`);return}c.add(o);let f=i.get(o);if(f){for(let r of f.references)a(r);s.push(f)}c.delete(o),t.add(o)}for(let o of n)a(o.name);return s}async function $n(n){let i=Date.now(),s=ci(n.projects);e.info(`Generating declarations for ${s.length} projects...`);let t=[],c=!0;for(let r of s){e.info(`
|
|
3
|
+
[${r.name}] Generating...`);try{let g={...n.sharedConfig,...r.config,cwd:r.root,tsconfigPath:r.tsconfigPath},p=await l(g),m=p.filesFailed===0;if(!m)c=!1;t.push({name:r.name,stats:p,success:m}),e.info(`[${r.name}] Generated ${p.filesGenerated} files`)}catch(g){c=!1;let p=g instanceof Error?g.message:String(g);t.push({name:r.name,stats:{generationMode:r.config?.isolatedDeclarations||n.sharedConfig?.isolatedDeclarations?"isolated":"semantic",filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},success:!1,error:p}),e.error(`[${r.name}] Failed: ${p}`)}}let a=Date.now()-i,o=t.filter((r)=>r.success).length,f=t.length-o;if(e.info(`
|
|
4
|
+
--- Workspace Generation Summary ---`),e.info(`Projects processed: ${t.length}`),e.info(`Successful: ${o}`),f>0)e.info(`Failed: ${f}`);return e.info(`Total duration: ${a}ms`),e.info(`------------------------------------
|
|
5
|
+
`),{success:c,projects:t,durationMs:a}}async function Xs(n,i){if(i?.logLevel)H(i.logLevel);let s=d(n,"tsconfig.json");if(!u(s))throw Error(`Root tsconfig.json not found at: ${s}`);e.info("Discovering workspace projects...");let t=await ai(s);if(t.length===0)return e.warn("No projects found in workspace"),{success:!0,projects:[],durationMs:0};return e.info(`Found ${t.length} projects`),$n({root:n,projects:t,sharedConfig:i})}async function li(n){let i=d(n,"package.json");if(!u(i))return[];try{let s=w(i,"utf-8"),t=JSON.parse(s),c=[];if(Array.isArray(t.workspaces))c=t.workspaces;else if(t.workspaces?.packages)c=t.workspaces.packages;return c}catch{return[]}}async function ui(n,i){let{Glob:s}=await Promise.resolve(globalThis.Bun),t=[];for(let c of i){let a=new s(c);for await(let o of a.scan({cwd:n,absolute:!0,onlyFiles:!1})){let f=d(o,"package.json");if(u(f))t.push(o)}}return t}async function Qs(n,i){if(i?.logLevel)H(i.logLevel);let s=await li(n);if(s.length===0)return e.warn("No workspace patterns found in package.json"),{success:!0,projects:[],durationMs:0};e.info(`Found workspace patterns: ${s.join(", ")}`);let t=await ui(n,s);if(t.length===0)return e.warn("No projects found matching workspace patterns"),{success:!0,projects:[],durationMs:0};e.info(`Found ${t.length} workspace packages`);let c=t.map((a)=>{let o=d(a,"tsconfig.json");return{name:P(a),root:a,tsconfigPath:u(o)?o:"",references:[]}});return $n({root:n,projects:c,sharedConfig:i})}
|
|
6
|
+
export{ai,ci,$n,Xs,li,ui,Qs};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{l}from"./chunk-0zwa1tag.js";function Pe(a={}){let{onBuildStart:d=!1,onBuildEnd:u=!0,onGenerated:f,onError:i,...c}=a,o,r,e=async()=>{let t={...c};if(!t.outdir&&o)t.outdir=o;if(!t.entrypoints&&r)t.entrypoints=r;try{let n=await l(t);f?.(n)}catch(n){let s=n instanceof Error?n:Error(String(n));if(i?.(s),!i)console.error("[dtsx] Generation failed:",s.message)}};return{name:"dtsx",esbuildOptions(t){if(t.outdir&&typeof t.outdir==="string")o=t.outdir;if(t.entryPoints){if(Array.isArray(t.entryPoints))r=t.entryPoints;else if(typeof t.entryPoints==="object")r=Object.values(t.entryPoints)}},async buildStart(){if(d)await e()},async buildEnd(t){if(u)await e()}}}var Ha=Pe,Dr=Pe,Ka=Pe;
|
|
3
|
+
export{Pe,Ha,Dr,Ka};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{a,i}from"./chunk-ke1h5m7f.js";import{A}from"./chunk-wfkkp4tx.js";import{w}from"./chunk-cb5dj4qy.js";function Fe(y){let r=new Set,u=[];for(let o of y)if(o.kind==="import")for(let d of w(o.text))r.add(d);else if(o.kind!=="unknown"){if(u.push(o.text),o.kind==="variable"){if(o.typeAnnotation&&!o.text)u.push(o.typeAnnotation);else if(!o.typeAnnotation&&o.value)u.push(A(o,!1))}}let n=u.join(`
|
|
3
|
+
`),p=new Set;if(r.size>0){let o=new Uint8Array(128),d=!1,m=Number.POSITIVE_INFINITY,g=0;for(let e of r){if(e.length===0)continue;let t=e.charCodeAt(0);if(t<128)o[t]=1;else d=!0;if(e.length<m)m=e.length;if(e.length>g)g=e.length}let c=!1,f=0,l=[];for(let e=0;e<n.length;){let t=n.charCodeAt(e);if(c){if(t===92){e+=2;continue}if(t===96){c=!1,e++;continue}if(t===36&&n.charCodeAt(e+1)===123){l.push(f),f++,c=!1,e+=2;continue}e++;continue}if(t===47){let s=n.charCodeAt(e+1);if(s===47){let h=n.indexOf(`
|
|
4
|
+
`,e+2);e=h===-1?n.length:h+1;continue}if(s===42){let h=n.indexOf("*/",e+2);e=h===-1?n.length:h+2;continue}}if(t===39||t===34){e++;while(e<n.length){let s=n.charCodeAt(e);if(s===92){e+=2;continue}if(e++,s===t||s===10)break}continue}if(t===96){c=!0,e++;continue}if(t===123){f++,e++;continue}if(t===125){if(f--,l.length>0&&f===l[l.length-1])l.pop(),c=!0;e++;continue}if(!a(t)){e++;continue}let x=e++;while(e<n.length&&i(n.charCodeAt(e)))e++;let I=e-x;if(I>=m&&I<=g&&(t<128?o[t]===1:d)){let s=n.slice(x,e);if(r.has(s)){if(p.add(s),p.size>=r.size)break}}}}return{usedItems:p,referenceText:n}}
|
|
5
|
+
export{Fe};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
function N(n){return n.endsWith(".vue")}function qo(n){let i={script:null,scriptSetup:null},e=/<script\b((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/script>/gi,s;while((s=e.exec(n))!==null){let t=s[1]||"",r=/lang\s*=\s*["']([^"']+)["']/i.exec(t)?.[1]?.toLowerCase()??"js",l={content:s[2]??"",attrs:t,setup:/\bsetup\b/.test(t),lang:r};if(l.setup)i.scriptSetup=l;else i.script=l}return i}function g(n,i){let e=n[i];i++;while(i<n.length){let s=n[i];if(s==="\\"){i+=2;continue}if(s===e)return i+1;i++}return i}function m(n,i){i++;let e=0;while(i<n.length){let s=n[i];if(s==="\\"){i+=2;continue}if(s==="`"&&e===0)return i+1;if(s==="$"&&n[i+1]==="{"){e++,i+=2;continue}if(s==="}"){if(e>0)e--;i++;continue}i++}return i}function b(n,i){if(n[i+1]==="/"){let e=n.indexOf(`
|
|
3
|
+
`,i+2);return e===-1?n.length:e+1}if(n[i+1]==="*"){let e=n.indexOf("*/",i+2);return e===-1?n.length:e+2}return i+1}function It(n,i){let e=n[i];if(e==='"'||e==="'")return g(n,i);if(e==="`")return m(n,i);if(e==="/"&&(n[i+1]==="/"||n[i+1]==="*"))return b(n,i);return i}function Nt(n){let i=n.split(""),e=0;while(e<n.length){let s=It(n,e);if(s>e){for(let t=e;t<s;t++)if(i[t]!==`
|
|
4
|
+
`&&i[t]!=="\r")i[t]=" ";e=s;continue}e++}return i.join("")}function d(n,i,e,s){let t=0,r=i;while(r<n.length){let l=n[r];if(l==='"'||l==="'"){r=g(n,r);continue}if(l==="`"){r=m(n,r);continue}if(l==="/"&&(n[r+1]==="/"||n[r+1]==="*")){r=b(n,r);continue}if(l===e)t++;else if(l===s){if(t--,t===0)return r}r++}return-1}function W(n,i){let e=0,s=i;while(s<n.length){let t=n[s];if(t==='"'||t==="'"){s=g(n,s);continue}if(t==="`"){s=m(n,s);continue}if(t==="/"&&(n[s+1]==="/"||n[s+1]==="*")){s=b(n,s);continue}if(t==="="&&n[s+1]===">"){s+=2;continue}if(t==="<")e++;else if(t===">"){if(e--,e===0)return s}s++}return-1}function S(n,i=","){let e=[],s=0,t="",r=0;while(r<n.length){let l=n[r];if(l==='"'||l==="'"){let u=g(n,r);t+=n.slice(r,u),r=u;continue}if(l==="`"){let u=m(n,r);t+=n.slice(r,u),r=u;continue}if(l==="/"&&(n[r+1]==="/"||n[r+1]==="*")){r=b(n,r);continue}if(l==="{"||l==="["||l==="("||l==="<")s++;else if(l==="}"||l==="]"||l===")"||l===">"&&n[r-1]!=="="){if(s>0)s--}if(l===i&&s===0){e.push(t),t="",r++;continue}t+=l,r++}if(t.trim()!=="")e.push(t);return e}function O(n){let i=n.trim();if(!i.startsWith("{"))return[];let e=d(i,0,"{","}");if(e===-1)return[];let s=i.slice(1,e),t=[];for(let r of S(s)){let l=-1,u=0;for(let a=0;a<r.length;a++){let c=r[a];if(c==='"'||c==="'"){a=g(r,a)-1;continue}if(c==="`"){a=m(r,a)-1;continue}if(c==="{"||c==="["||c==="("||c==="<")u++;else if(c==="}"||c==="]"||c===")"||c===">")u--;else if(c===":"&&u===0){l=a;break}}if(l!==-1){t.push({key:E(r.slice(0,l).trim()),value:r.slice(l+1).trim(),isMethod:!1});continue}let o=/^([A-Za-z_$][\w$]*|['"][^'"]+['"])\s*\(/.exec(r.trim());if(o){t.push({key:E(o[1]),value:r.trim(),isMethod:!0});continue}let f=r.trim();if(f)t.push({key:E(f),value:"",isMethod:!1})}return t}function E(n){if(n.startsWith("'")&&n.endsWith("'")||n.startsWith('"')&&n.endsWith('"'))return n.slice(1,-1);return n}function k(n){return/^[A-Za-z_$][\w$]*$/.test(n)?n:JSON.stringify(n)}function _e(n,i){let e=new RegExp(`\\b${i}\\b`,"g"),s;while((s=e.exec(n))!==null){let t=s.index+s[0].length;while(t<n.length&&/\s/.test(n[t]))t++;let r=null;if(n[t]==="<"){let o=W(n,t);if(o===-1)return null;r=n.slice(t+1,o).trim(),t=o+1;while(t<n.length&&/\s/.test(n[t]))t++}if(n[t]!=="(")continue;let l=d(n,t,"(",")");if(l===-1)return null;let u=S(n.slice(t+1,l));return{generic:r,arg:u.length>0?u[0].trim():null}}return null}function P(n,i){let e=R(n,i);if(!e)return null;return e.kind==="interface"?n.slice(e.bodyStart,e.end):n.slice(e.bodyStart,e.end).trim()}function R(n,i){let s=new RegExp(`\\binterface\\s+${i}\\b[^{]*\\{`,"m").exec(n);if(s){let l=s.index+s[0].length-1,u=d(n,l,"{","}");if(u!==-1)return{kind:"interface",start:s.index,end:u+1,bodyStart:l}}let r=new RegExp(`\\btype\\s+${i}\\b[^=]*=`,"m").exec(n);if(r){let l=r.index+r[0].length,u=0,o=l;while(l<n.length){let f=n[l];if(f==='"'||f==="'"){l=g(n,l);continue}if(f==="`"){l=m(n,l);continue}if(f==="{"||f==="["||f==="("||f==="<")u++;else if(f==="}"||f==="]"||f===")"||f===">")u--;else if((f===";"||f===`
|
|
5
|
+
`)&&u===0)break;l++}return{kind:"type",start:r.index,end:l,bodyStart:o}}return null}var M={String:"string",Number:"number",Boolean:"boolean",Array:"unknown[]",Object:"Record<string, unknown>",Function:"(...args: any[]) => any",Symbol:"symbol",Promise:"Promise<unknown>",Date:"Date",BigInt:"bigint"};function x(n){let i=n.search(/\bas\s+PropType\s*</);if(i===-1)return null;let e=n.indexOf("<",i),s=W(n,e);if(s===-1)return null;if(n.slice(s+1).trim()!=="")return null;return n.slice(e+1,s).trim()}function T(n){let i=n.trim(),e=x(i);if(e!==null)return{type:e,optional:!0};if(i==="null")return{type:"unknown",optional:!0};if(i.startsWith("[")){let s=d(i,0,"[","]");if(s!==-1){let t=S(i.slice(1,s)).map((r)=>T(r).type).filter((r)=>r!=="unknown");return{type:t.length>0?[...new Set(t)].join(" | "):"unknown",optional:!0}}}if(i.startsWith("{")){let s=O(i),t=s.find((o)=>o.key==="type"),r=s.find((o)=>o.key==="required"),l=t?T(t.value).type:"unknown",u=!(r&&r.value.trim()==="true");return{type:l,optional:u}}if(M[i])return{type:M[i],optional:!0};if(/^[A-Za-z_$][\w$.]*$/.test(i))return{type:i,optional:!0};return{type:"unknown",optional:!0}}function st(n){let i=n.trim();if(i.startsWith("{")){let e=O(i);if(e.length===0)return"{}";return`{ ${e.map((t)=>{if(t.isMethod||t.value==="")return`${k(t.key)}?: unknown`;let r=T(t.value);return`${k(t.key)}${r.optional?"?":""}: ${r.type}`}).join(", ")} }`}if(i.startsWith("[")){let e=d(i,0,"[","]");if(e===-1)return null;let s=S(i.slice(1,e)).map((t)=>E(t.trim())).filter((t)=>t!=="");if(s.length===0)return"{}";return`{ ${s.map((t)=>`${k(t)}?: unknown`).join(", ")} }`}return null}function V(n){let i=n.trim();if(!i.startsWith("["))return null;let e=d(i,0,"[","]");if(e===-1)return null;let s=S(i.slice(1,e)).map((t)=>t.trim());if(s.length===0)return"{}";if(!s.every((t)=>t.startsWith("'")&&t.endsWith("'")||t.startsWith('"')&&t.endsWith('"')))return"string[]";return`[${s.map((t)=>JSON.stringify(E(t))).join(", ")}]`}function A(n){let i=n.trim();if(!i.startsWith("{"))return null;let e=O(i);if(e.length===0)return"{}";return`{ ${e.map((t)=>`${JSON.stringify(t.key)}: (...args: any[]) => void`).join(", ")} }`}function L(n){return V(n)??A(n)}function D(n){let i=[],e=0,s="",t=0;while(t<n.length){let r=n[t];if(r==='"'||r==="'"){let l=g(n,t);s+=n.slice(t,l),t=l;continue}if(r==="`"){let l=m(n,t);s+=n.slice(t,l),t=l;continue}if(r==="/"&&(n[t+1]==="/"||n[t+1]==="*")){let l=b(n,t);s+=n.slice(t,l),t=l;continue}if(r==="="&&n[t+1]===">"){s+="=>",t+=2;continue}if(r==="{"||r==="["||r==="("||r==="<")e++;else if(r==="}"||r==="]"||r===")"||r===">"&&n[t-1]!=="="){if(e>0)e--}if((r===";"||r===","||r===`
|
|
6
|
+
`)&&e===0){if(s.trim()!=="")i.push(s.trim());s="",t++;continue}s+=r,t++}if(s.trim()!=="")i.push(s.trim());return i}function I(n){let i=n.trim();if(!i.startsWith("{"))return null;let e=d(i,0,"{","}");if(e===-1||i.slice(e+1).trim()!=="")return null;let s=D(i.slice(1,e));if(s.length===0)return"{}";let t=[];for(let r of s){let l=/^\(\s*\w+\s*:\s*/.exec(r);if(!l)return null;let u=l[0].length,o=r[u];if(o!=="'"&&o!=='"'&&o!=="`")return null;let f=g(r,u),a=r.slice(u+1,f-1),c=d(r,r.indexOf("(",0),"(",")");if(c===-1)return null;let h=r.slice(u,c),w=S(h).slice(1),p=r.slice(c+1).trim();if(p.startsWith(":"))p=p.slice(1).trim();if(p==="")p="void";t.push(`${JSON.stringify(a)}: (${w.map((v)=>v.trim()).join(", ")}) => ${p}`)}return`{ ${t.join(", ")} }`}function Wt(n){let i=n;for(let e of["defineProps","defineEmits","defineExpose","defineSlots","defineOptions"])i=z(i,e);return i}function z(n,i){let e=new RegExp(`\\b${i}\\b`,"g"),s=[],t=n,r;while((r=e.exec(n))!==null){let l=n.lastIndexOf(`
|
|
7
|
+
`,r.index)+1,u=n.slice(l,r.index),o=/^\s*(?:(?:const|let|var)\s+[A-Za-z_$][\w$]*\s*(?::[^=]+)?=\s*)?(withDefaults\s*\(\s*)?$/.exec(u);if(!o)continue;let f=r.index+r[0].length;while(f<n.length&&/\s/.test(n[f]))f++;if(n[f]==="<"){let h=W(n,f);if(h===-1)continue;f=h+1;while(f<n.length&&/\s/.test(n[f]))f++}if(n[f]!=="(")continue;let a=d(n,f,"(",")");if(a===-1)continue;if(o[1]){let h=l+u.length-o[1].length,w=n.indexOf("(",h);if(w!==-1){let p=d(n,w,"(",")");if(p!==-1)a=p}}let c=a+1;while(c<n.length&&n[c]!==`
|
|
8
|
+
`&&/\s|;/.test(n[c]))c++;if(n[c]===`
|
|
9
|
+
`)c++;s.push([l,c])}for(let l=s.length-1;l>=0;l--)t=t.slice(0,s[l][0])+t.slice(s[l][1]);return t}function Lt(n){let i=Z(n);if(i!==-1){let e=/^export\s+default\b/.exec(n.slice(i))?.[0];if(!e)return{options:null,script:n,passthrough:!1};let s=i+e.length;while(s<n.length&&/\s/.test(n[s]))s++;let t=-1,r=-1,l=-1;if(n[s]==="{")t=s,r=d(n,s,"{","}"),l=r;else if(n.startsWith("defineComponent",s)){let f=n.indexOf("(",s);if(f!==-1){let a=f+1;while(a<n.length&&/\s/.test(n[a]))a++;if(n[a]==="{")t=a,r=d(n,a,"{","}"),l=d(n,f,"(",")")}}if(t===-1||r===-1||l===-1)return{options:null,script:n,passthrough:!0};let u=l+1;if(n[u]===";")u++;let o=(n.slice(0,i)+n.slice(u)).trim();return{options:n.slice(t,r+1),script:o,passthrough:!1}}return{options:null,script:n,passthrough:!1}}function Z(n){let i=0,e=0;while(e<n.length){let s=n[e];if(s==='"'||s==="'"){e=g(n,e);continue}if(s==="`"){e=m(n,e);continue}if(s==="/"&&(n[e+1]==="/"||n[e+1]==="*")){e=b(n,e);continue}if(s==="{"||s==="["||s==="(")i++;else if(s==="}"||s==="]"||s===")")i=Math.max(0,i-1);else if(i===0&&n.startsWith("export",e)){let t=e===0?"":n[e-1],r=n[e+6]??"";if(!/[\w$]/.test(t)&&!/[\w$]/.test(r)){if(/^export\s+default\b/.exec(n.slice(e)))return e}}e++}return-1}function ot(n,i){let e=O(n).find((s)=>s.key===i);return e&&e.value!==""?e.value:null}function at(n,i){let e=q(n),s=n;for(let t=e.length-1;t>=0;t--){let r=e[t],l=s.slice(0,r.start)+s.slice(r.end);if(B(l,r.name))continue;if(new RegExp(`\\btypeof\\s+${r.name}\\b`).test(i))continue;s=l}return s}function B(n,i){let e=0;while(e<n.length){let s=n[e];if(s==='"'||s==="'"){e=g(n,e);continue}if(s==="`"){e=m(n,e);continue}if(s==="/"&&(n[e+1]==="/"||n[e+1]==="*")){e=b(n,e);continue}if(/[A-Za-z_$]/.test(s)){let t=e+1;while(t<n.length&&/[\w$]/.test(n[t]))t++;if(n.slice(e,t)===i)return!0;e=t;continue}e++}return!1}function q(n){let i=[],e=J(n),s=/^[ \t]*(const|let|var|(?:async[ \t]+)?function)[ \t]+([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=?/gm,t;while((t=s.exec(n))!==null){let r=n.lastIndexOf(`
|
|
10
|
+
`,t.index)+1;if(!e.has(r))continue;if(/\bexport\b/.test(n.slice(r,t.index)))continue;let l=t[1],u=t[2],o=t.index+t[0].length,f=-1;if(l.endsWith("function")){let a=n.indexOf("(",o);if(a===-1)continue;let c=d(n,a,"(",")");if(c===-1)continue;o=c+1;while(o<n.length&&/\s/.test(n[o]))o++;if(n[o]===":")while(o<n.length&&n[o]!=="{"&&n[o]!==`
|
|
11
|
+
`)o++;while(o<n.length&&/\s/.test(n[o])&&n[o]!==`
|
|
12
|
+
`)o++;if(n[o]!=="{")continue;let h=d(n,o,"{","}");if(h===-1)continue;f=h+1}else{let a=0;while(o<n.length){let c=n[o];if(c==='"'||c==="'"){o=g(n,o);continue}if(c==="`"){o=m(n,o);continue}if(c==="/"&&(n[o+1]==="/"||n[o+1]==="*")){o=b(n,o);continue}if(c==="{"||c==="["||c==="(")a++;else if(c==="}"||c==="]"||c===")")a--;else if(c===";"&&a===0){f=o+1;break}else if(c===`
|
|
13
|
+
`&&a===0){f=o;break}o++}if(f===-1)f=n.length}if(n[f]===`
|
|
14
|
+
`)f++;i.push({name:u,start:t.index,end:f})}return i}function J(n){let i=new Set([0]),e=0,s=0;while(s<n.length){let t=n[s];if(t==='"'||t==="'"){s=g(n,s);continue}if(t==="`"){s=m(n,s);continue}if(t==="/"&&(n[s+1]==="/"||n[s+1]==="*")){s=b(n,s);continue}if(t==="{"||t==="["||t==="(")e++;else if(t==="}"||t==="]"||t===")")e=Math.max(0,e-1);if(t===`
|
|
15
|
+
`&&e===0)i.add(s+1);s++}return i}function ct(n,i,e){let s=n.indexOf(e);if(s===-1)return n;let t=n.lastIndexOf(`
|
|
16
|
+
`,s)+1;if(/\bexport\b/.test(n.slice(t,s)))return n;let r=n.slice(0,s)+n.slice(s+e.length);if(new RegExp(`\\b${i}\\b`).test(r))return n;return r}function Ft(n){let i="",e=0,s=()=>{for(let r=i.length-1;r>=0;r--)if(!/\s/.test(i[r]))return i[r];return""},t=(r)=>{for(let l=r;l<n.length;l++)if(!/\s/.test(n[l]))return n[l];return""};while(e<n.length){let r=n[e];if(r==='"'||r==="'"){let l=g(n,e);i+=n.slice(e,l),e=l;continue}if(r==="`"){let l=m(n,e);i+=n.slice(e,l),e=l;continue}if(r==="/"&&n[e+1]==="*"){let l=b(n,e);i+=n.slice(e,l).replace(/\s*\n\s*/g," "),e=l;continue}if(r==="/"&&n[e+1]==="/"){let l=e+2;while(l<n.length&&n[l]!==`
|
|
17
|
+
`)l++;let u=n.slice(e+2,l).trim();if(u!==""&&!u.includes("*/"))i+=`/* ${u} */`;e=l;continue}if(r===`
|
|
18
|
+
`){let l=s(),u=t(e+1);if(l===""||u===""){e++;continue}let o=F(i);if(!o&&("{;,(<:=[".includes(l)||"}),]>;|&".includes(u))){if(!i.endsWith(" ")&&!i.endsWith(";"))i+=" "}else if(o){if(!i.endsWith(" "))i+=" "}else{if(i.endsWith(" "))i=i.slice(0,-1);i+="; "}e++;while(e<n.length&&(n[e]===" "||n[e]==="\t"))e++;continue}i+=r,e++}return i}function F(n){let i=n.length-1;while(i>=0&&/\s/.test(n[i]))i--;if(i<1||n[i]!=="/"||n[i-1]!=="*")return!1;let e=n.lastIndexOf("/*",i);if(e===-1)return!1;for(let s=e-1;s>=0;s--){let t=n[s];if(/\s/.test(t))continue;return"{;,(<:".includes(t)}return!0}function lt(n,i){let e=[n,i].filter((s)=>s!==null);for(let s of e){let t=_e(s,"defineProps");if(!t)continue;if(t.generic){let r=t.generic;if(r.startsWith("{"))return{type:r};if(/^[A-Za-z_$][\w$]*$/.test(r)){for(let l of e){let u=R(l,r);if(!u)continue;let o=P(l,r);if(o===null)continue;return{type:o,inlinedLocal:{name:r,declText:l.slice(u.start,u.end)}}}return{type:r}}return{type:r}}if(t.arg){let r=st(t.arg);if(r!==null)return{type:r}}}return null}function Bt(n,i){let e=[n,i].filter((s)=>s!==null);for(let s of e){let t=_e(s,"defineEmits");if(!t)continue;if(t.generic)return I(t.generic)??t.generic;if(t.arg){let r=L(t.arg);if(r!==null)return r}}return null}function _t(n,i){let e=[n,i].filter((s)=>s!==null);for(let s of e){let t=_e(s,"defineExpose");if(!t||!t.arg||!t.arg.startsWith("{"))continue;let r=O(t.arg);if(r.length===0)return null;return`{ ${r.map((u)=>{if(u.value===""&&/^[A-Za-z_$][\w$]*$/.test(u.key))return`${k(u.key)}: typeof ${u.key}`;let o=u.isMethod||/=>|^\s*function\b/.test(u.value);return`${k(u.key)}: ${o?"(...args: any[]) => any":"unknown"}`}).join(", ")} }`}return null}function j(n){let i=qo(n),e="",s=null,t=null;if(i.script){let y=Lt(i.script.content);if(y.passthrough)return i.scriptSetup?`${i.script.content}
|
|
19
|
+
${i.scriptSetup.content}`:i.script.content;if(e=y.script,y.options){let _=ot(y.options,"props");if(_)s=st(_);let C=ot(y.options,"emits");if(C)t=L(C)}}let r=i.scriptSetup?.content??null,l=r!==null?Wt(r):null,u=lt(r,r!==null?null:e),o=u?.type??s??"{}",f=Bt(r,null)??t,a=_t(r,null),c=u?.inlinedLocal;if(c){if(e=ct(e,c.name,c.declText),l!==null)l=ct(l,c.name,c.declText)}let h=[o,a??"{}"];if(f)h.push("{}","{}","{}","{}","{}",f);let w=Ft(`DefineComponent<${h.join(", ")}>`),p=[],v=at(e,w);if(v.trim()!=="")p.push(v);if(l&&l.trim()!==""){let y=at(l,w);if(y.trim()!=="")p.push(y)}return p.push("import type { DefineComponent } from 'vue'"),p.push(`type __DtsxComponentType = ${w}`),p.push("const __dtsx_component__: __DtsxComponentType = null as unknown as __DtsxComponentType"),p.push("export default __dtsx_component__"),p.join(`
|
|
20
|
+
`)}
|
|
21
|
+
export{N,qo,It,Nt,d,_e,st,Wt,Lt,ot,at,ct,Ft,lt,Bt,_t,j};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{
|
|
2
|
+
import{l}from"./chunk-0zwa1tag.js";function De(s={}){let{onStart:a=!1,onEnd:d=!0,onGenerated:u,onError:i,...n}=s,e=async()=>{try{let r=await l(n);u?.(r)}catch(r){let t=r instanceof Error?r:Error(String(r));if(i?.(t),!i)console.error("[dtsx] Generation failed:",t.message)}};return{name:"dtsx",setup(r){let t=r.initialOptions;if(!n.entrypoints&&t.entryPoints)if(Array.isArray(t.entryPoints))n.entrypoints=t.entryPoints;else n.entrypoints=Object.values(t.entryPoints);if(!n.outdir){if(t.outdir)n.outdir=t.outdir;else if(t.outfile){let o=t.outfile.lastIndexOf("/");if(o!==-1)n.outdir=t.outfile.substring(0,o)}}if(a)r.onStart(async()=>{await e()});if(d)r.onEnd(async(o)=>{if(o.errors.length===0)await e()})}}}var qa=De,Rr=De,Ja=De;
|
|
3
|
+
export{De,qa,Rr,Ja};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{e}from"./chunk-
|
|
2
|
+
import{e}from"./chunk-bd048mjd.js";import{existsSync as h}from"fs";import{cpus as u}from"os";import{resolve as l}from"path";import{fileURLToPath as k}from"url";import{Worker as c}from"worker_threads";var __dirname="/home/runner/work/dtsx/dtsx/packages/dtsx/src",a;function f(){if(a!==void 0)return a;a=null;for(let t of["./worker-thread.js","./worker-thread.ts","./src/worker-thread.js","./src/worker-thread.ts"]){let r=new URL(t,import.meta.url);try{if(h(k(r))){a=r;break}}catch{}}return a}class Yn{workers=[];taskQueue=[];config;stats={totalTasks:0,completedTasks:0,failedTasks:0,averageDuration:0,activeWorkers:0,idleWorkers:0};isShuttingDown=!1;idleCheckInterval=null;constructor(t={}){let r=t.maxWorkers??Math.max(1,u().length-1);this.config={maxWorkers:r,taskTimeout:t.taskTimeout??30000,recycleAfter:t.recycleAfter??100,idleTimeout:t.idleTimeout??1e4,initialWorkers:t.initialWorkers??Math.min(2,r)}}async init(){let t=Math.min(this.config.initialWorkers,this.config.maxWorkers);for(let r=0;r<t;r++)this.createWorker();if(this.config.idleTimeout>0){if(this.idleCheckInterval=setInterval(()=>{this.checkIdleWorkers()},5000),this.idleCheckInterval&&typeof this.idleCheckInterval==="object"&&"unref"in this.idleCheckInterval)this.idleCheckInterval.unref()}}createWorker(){let t=`
|
|
3
3
|
const { parentPort } = require('worker_threads');
|
|
4
4
|
const bun = typeof Bun !== 'undefined' ? Bun : null;
|
|
5
5
|
const fs = bun ? null : require('node:fs');
|
|
@@ -173,5 +173,5 @@ catch (error) {
|
|
|
173
173
|
const result = await processTask(task);
|
|
174
174
|
parentPort.postMessage(result);
|
|
175
175
|
});
|
|
176
|
-
`,r=f(),o=r?new c(k(r)):new c(t,{eval:!0}),s={worker:o,busy:!1,taskCount:0,lastActive:Date.now(),currentTask:null};return o.on("message",(i)=>{this.handleWorkerResult(s,i)}),o.on("error",(i)=>{e.error("Worker error:",i),this.handleWorkerError(s,i)}),o.on("exit",(i)=>{if(i!==0&&!this.isShuttingDown)e.error(`Worker exited with code ${i}`),this.removeWorker(s)}),this.workers.push(s),this.updateStats(),s}handleWorkerResult(t,r){if(t.busy=!1,t.taskCount++,t.lastActive=Date.now(),t.currentTask&&t.currentTask.id===r.id){clearTimeout(t.currentTask.timeout);let{resolve:s}=t.currentTask;t.currentTask=null,s(r)}if(r.success)this.stats.completedTasks++;else this.stats.failedTasks++;let o=this.stats.averageDuration*(this.stats.completedTasks+this.stats.failedTasks-1)+r.duration;if(this.stats.averageDuration=o/(this.stats.completedTasks+this.stats.failedTasks),this.updateStats(),t.taskCount>=this.config.recycleAfter)this.recycleWorker(t);this.processQueue()}handleWorkerError(t,r){if(t.busy=!1,t.currentTask){clearTimeout(t.currentTask.timeout);let{reject:o}=t.currentTask;t.currentTask=null,o(r)}this.stats.failedTasks++,this.updateStats(),this.recycleWorker(t),this.processQueue()}removeWorker(t){let r=this.workers.indexOf(t);if(r!==-1)this.workers.splice(r,1),t.worker.terminate();this.updateStats()}recycleWorker(t){if(this.removeWorker(t),!this.isShuttingDown&&this.workers.length<this.config.maxWorkers)this.createWorker()}checkIdleWorkers(){let t=Date.now(),r=1;for(let o=this.workers.length-1;o>=0;o--){let s=this.workers[o];if(!s.busy&&t-s.lastActive>this.config.idleTimeout&&this.workers.length>1)this.removeWorker(s)}}processQueue(){while(this.taskQueue.length>0){let t;for(let n=0;n<this.workers.length;n++)if(!this.workers[n].busy){t=this.workers[n];break}if(!t&&this.workers.length<this.config.maxWorkers)t=this.createWorker();if(!t)return;let{task:r,resolve:o,reject:s}=this.taskQueue.shift();t.busy=!0,t.lastActive=Date.now();let i=setTimeout(()=>{if(t.currentTask?.id===r.id)t.currentTask=null;s(Error(`Task ${r.id} timed out`)),this.recycleWorker(t)},this.config.taskTimeout);t.currentTask={id:r.id,resolve:o,reject:s,timeout:i},t.worker.postMessage(r),this.updateStats()}}async submit(t){return this.stats.totalTasks++,new Promise((r,o)=>{this.taskQueue.push({task:t,resolve:r,reject:o}),this.processQueue()})}async processFiles(t,r={}){let o=t.map((s,i)=>({id:`task-${i}-${Date.now()}`,type:"process",filePath:s.path,sourceCode:s.content,config:r}));return Promise.all(o.map((s)=>this.submit(s)))}updateStats(){let t=0;for(let r=0;r<this.workers.length;r++)if(this.workers[r].busy)t++;this.stats.activeWorkers=t,this.stats.idleWorkers=this.workers.length-t}getStats(){return{...this.stats}}async shutdown(){if(this.isShuttingDown=!0,this.idleCheckInterval)clearInterval(this.idleCheckInterval);while(this.taskQueue.length>0||this.workers.some((t)=>t.busy))await new Promise((t)=>setTimeout(t,100));await Promise.all(this.workers.map((t)=>t.worker.terminate())),this.workers=[]}}function
|
|
177
|
-
export{
|
|
176
|
+
`,r=f(),o=r?new c(k(r)):new c(t,{eval:!0}),s={worker:o,busy:!1,taskCount:0,lastActive:Date.now(),currentTask:null};return o.on("message",(i)=>{this.handleWorkerResult(s,i)}),o.on("error",(i)=>{e.error("Worker error:",i),this.handleWorkerError(s,i)}),o.on("exit",(i)=>{if(i!==0&&!this.isShuttingDown)e.error(`Worker exited with code ${i}`),this.removeWorker(s)}),this.workers.push(s),this.updateStats(),s}handleWorkerResult(t,r){if(t.busy=!1,t.taskCount++,t.lastActive=Date.now(),t.currentTask&&t.currentTask.id===r.id){clearTimeout(t.currentTask.timeout);let{resolve:s}=t.currentTask;t.currentTask=null,s(r)}if(r.success)this.stats.completedTasks++;else this.stats.failedTasks++;let o=this.stats.averageDuration*(this.stats.completedTasks+this.stats.failedTasks-1)+r.duration;if(this.stats.averageDuration=o/(this.stats.completedTasks+this.stats.failedTasks),this.updateStats(),t.taskCount>=this.config.recycleAfter)this.recycleWorker(t);this.processQueue()}handleWorkerError(t,r){if(t.busy=!1,t.currentTask){clearTimeout(t.currentTask.timeout);let{reject:o}=t.currentTask;t.currentTask=null,o(r)}this.stats.failedTasks++,this.updateStats(),this.recycleWorker(t),this.processQueue()}removeWorker(t){let r=this.workers.indexOf(t);if(r!==-1)this.workers.splice(r,1),t.worker.terminate();this.updateStats()}recycleWorker(t){if(this.removeWorker(t),!this.isShuttingDown&&this.workers.length<this.config.maxWorkers)this.createWorker()}checkIdleWorkers(){let t=Date.now(),r=1;for(let o=this.workers.length-1;o>=0;o--){let s=this.workers[o];if(!s.busy&&t-s.lastActive>this.config.idleTimeout&&this.workers.length>1)this.removeWorker(s)}}processQueue(){while(this.taskQueue.length>0){let t;for(let n=0;n<this.workers.length;n++)if(!this.workers[n].busy){t=this.workers[n];break}if(!t&&this.workers.length<this.config.maxWorkers)t=this.createWorker();if(!t)return;let{task:r,resolve:o,reject:s}=this.taskQueue.shift();t.busy=!0,t.lastActive=Date.now();let i=setTimeout(()=>{if(t.currentTask?.id===r.id)t.currentTask=null;s(Error(`Task ${r.id} timed out`)),this.recycleWorker(t)},this.config.taskTimeout);t.currentTask={id:r.id,resolve:o,reject:s,timeout:i},t.worker.postMessage(r),this.updateStats()}}async submit(t){return this.stats.totalTasks++,new Promise((r,o)=>{this.taskQueue.push({task:t,resolve:r,reject:o}),this.processQueue()})}async processFiles(t,r={}){let o=t.map((s,i)=>({id:`task-${i}-${Date.now()}`,type:"process",filePath:s.path,sourceCode:s.content,config:r}));return Promise.all(o.map((s)=>this.submit(s)))}updateStats(){let t=0;for(let r=0;r<this.workers.length;r++)if(this.workers[r].busy)t++;this.stats.activeWorkers=t,this.stats.idleWorkers=this.workers.length-t}getStats(){return{...this.stats}}async shutdown(){if(this.isShuttingDown=!0,this.idleCheckInterval)clearInterval(this.idleCheckInterval);while(this.taskQueue.length>0||this.workers.some((t)=>t.busy))await new Promise((t)=>setTimeout(t,100));await Promise.all(this.workers.map((t)=>t.worker.terminate())),this.workers=[]}}function Yi(t={}){return new Yn(t)}async function ya(t,r={},o={}){let s=Yi(o);await s.init();try{return await s.processFiles(t,r)}finally{await s.shutdown()}}function ba(t,r){let o=[];for(let s=0;s<t.length;s+=r)o.push(t.slice(s,s+r));return o}function wa(t,r=u().length){if(t<=r)return 1;let s=r*3;return Math.max(1,Math.ceil(t/s))}
|
|
177
|
+
export{Yn,Yi,ya,ba,wa};
|