sveld 0.36.2 → 0.36.4

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.
@@ -0,0 +1,230 @@
1
+ import{D as p0,E as U0,F as O1,X as x0,da as z1,u as i,x as K1}from"./chunk-4ggahk6z.js";import{na as G1}from"./chunk-tjthqdyw.js";import{pa as f,qa as S,ra as N0,sa as u}from"./chunk-jvqe4bt1.js";import{wa as t0}from"./chunk-0q7qnmx3.js";var Sj="sveld",k0="0.36.4";var _j={name:Sj,version:k0,license:"Apache-2.0",description:"Generate TypeScript definitions and component documentation for your Svelte components.",type:"module",main:"./lib/index.js",types:"./lib/index.d.ts",exports:{".":{types:"./lib/index.d.ts",import:"./lib/index.js",default:"./lib/index.js"},"./browser":{types:"./lib/browser.d.ts",import:"./lib/browser.js",default:"./lib/browser.js"}},scripts:{test:"bun test --parallel","test:fixtures-types":"tsc --project tsconfig.fixtures.json","test:e2e":"bun tests/test-e2e.ts",format:"biome format --write .",lint:"biome lint .","lint:fix":"biome check --write --unsafe .",build:"bun scripts/build.ts",bench:"bun scripts/bench.ts","bench:cache":"bun scripts/bench.ts --cache",typecheck:"tsc --noEmit"},devDependencies:{"@biomejs/biome":"2.5.8","@types/bun":"^1.3.14","@types/jest":"^30.0.0","@typescript/typescript6":"^6.0.2",acorn:"^8.18.0","comment-parser":"^1.4.7",culls:"^0.2.0","estree-walker":"^3.0.3",svelte:"^5.56.8",typescript:"^7.0.2"},bin:{sveld:"cli.js"},files:["lib","cli.js"],repository:{type:"git",url:"git+https://github.com/carbon-design-system/sveld.git"},homepage:"https://github.com/carbon-design-system/sveld",bugs:"https://github.com/carbon-design-system/sveld/issues",keywords:["svelte","svelte component","documentation","docgen","typescript","definitions","JSDocs","vite","vite-plugin"],maintainers:["Eric Liu (https://github.com/metonym)"]};var e="5.56.8";var O0=1,Fj=new WeakMap;function C(j,$={}){let Z=Fj.get(j),Q=Z?.get($.entryExports);if(Q)return Q;let Y=Array.from(j,([,z])=>{let{diagnostics:J,...H}=z;return H}).sort((z,J)=>z.moduleName.localeCompare(J.moduleName)),K={schemaVersion:O0,generator:{name:Sj,version:k0,svelteVersion:e},total:Y.length,components:Y};if($.entryExports&&$.entryExports.length>0)K.totalExports=$.entryExports.length,K.exports=$.entryExports;if(!Z)Z=new Map,Fj.set(j,Z);return Z.set($.entryExports,K),K}import{readFile as U2}from"node:fs/promises";import H2 from"node:path";var Nj={none:0,patch:1,minor:2,major:3};function V2(j,$){return Nj[$]>Nj[j]?$:j}function q2(j){return j.reduce(($,Z)=>V2($,Z.bump),"none")}function xj(j){let $=[],Z=0,Q="",Y=null;for(let K=0;K<j.length;K++){let z=j[K];if(Y){if(Q+=z,z==="\\")K++,Q+=j[K]??"";else if(z===Y)Y=null;continue}if(z==='"'||z==="'"||z==="`"){Y=z,Q+=z;continue}if(z==="<"||z==="("||z==="{"||z==="[")Z++;if(z===">"||z===")"||z==="}"||z==="]")Z--;if(z==="|"&&Z===0){$.push(Q.trim()),Q="";continue}Q+=z}return $.push(Q.trim()),new Set($.filter((K)=>K.length>0))}function d0(j,$){if(j===$)return"none";if(j===void 0||$===void 0)return"major";let Z=xj(j),Q=xj($),Y=[...Q].some((z)=>!Z.has(z)),K=[...Z].some((z)=>!Q.has(z));if(!Y&&!K)return"none";if(Y&&!K)return"minor";if(K&&!Y)return"major";return"major"}function yj(j,$,Z,Q){let Y=$==="prop"?"prop":"export",K=[],z=new Map(Z.map((H)=>[H.name,H])),J=new Map(Q.map((H)=>[H.name,H]));for(let[H,U]of J){if(z.has(H))continue;K.push({component:j,kind:$,name:H,bump:U.isRequired?"major":"minor",message:`${Y} "${H}" added${U.isRequired?" (required)":""}`})}for(let[H]of z){if(J.has(H))continue;K.push({component:j,kind:$,name:H,bump:"major",message:`${Y} "${H}" removed`})}for(let[H,U]of z){let V=J.get(H);if(!V)continue;if(U.isRequired!==V.isRequired)K.push({component:j,kind:$,name:H,bump:V.isRequired?"major":"minor",message:`${Y} "${H}" became ${V.isRequired?"required":"optional"}`});let G=d0(U.type,V.type);if(G!=="none")K.push({component:j,kind:$,name:H,bump:G,message:`${Y} "${H}" type changed from \`${U.type??"unknown"}\` to \`${V.type??"unknown"}\``})}return K}function G2(j,$,Z){let Q=[],Y=new Map($.map((z)=>[z.name,z])),K=new Map(Z.map((z)=>[z.name,z]));for(let[z]of K){if(Y.has(z))continue;Q.push({component:j,kind:"event",name:z,bump:"minor",message:`event "${z}" added`})}for(let[z]of Y){if(K.has(z))continue;Q.push({component:j,kind:"event",name:z,bump:"major",message:`event "${z}" removed`})}for(let[z,J]of Y){let H=K.get(z);if(!H)continue;if(J.type!==H.type){Q.push({component:j,kind:"event",name:z,bump:"major",message:`event "${z}" changed from ${J.type} to ${H.type}`});continue}let U=J.type==="dispatched"?J.detail:void 0,V=H.type==="dispatched"?H.detail:void 0,G=d0(U,V);if(G!=="none")Q.push({component:j,kind:"event",name:z,bump:G,message:`event "${z}" detail changed from \`${U??"unknown"}\` to \`${V??"unknown"}\``})}return Q}function gj(j){return j.name??"default"}function W2(j,$,Z){let Q=[],Y=new Map($.map((z)=>[gj(z),z])),K=new Map(Z.map((z)=>[gj(z),z]));for(let[z]of K){if(Y.has(z))continue;Q.push({component:j,kind:"slot",name:z,bump:"minor",message:`slot "${z}" added`})}for(let[z]of Y){if(K.has(z))continue;Q.push({component:j,kind:"slot",name:z,bump:"major",message:`slot "${z}" removed`})}for(let[z,J]of Y){let H=K.get(z);if(!H)continue;let U=d0(J.slot_props,H.slot_props);if(U!=="none")Q.push({component:j,kind:"slot",name:z,bump:U,message:`slot "${z}" props changed from \`${J.slot_props??"none"}\` to \`${H.slot_props??"none"}\``})}return Q}var X2=new Set(["description","source","componentCommentSource","tags"]);function B0(j){if(Array.isArray(j))return j.map(B0);if(j!==null&&typeof j==="object"){let $={};for(let[Z,Q]of Object.entries(j)){if(X2.has(Z))continue;$[Z]=B0(Q)}return $}return j}var k2=["generics","rest_props","extends","contexts","typedefs"];function O2(j,$,Z){let Q=[];for(let Y of k2){let K=JSON.stringify(B0($[Y])),z=JSON.stringify(B0(Z[Y]));if(K!==z)Q.push({component:j,kind:"shape",name:Y,bump:"major",message:`"${Y}" changed (breaking)`})}return Q}function B2(j,$){let Z=$.moduleName;return[...yj(Z,"prop",j.props,$.props),...yj(Z,"moduleExport",j.moduleExports,$.moduleExports),...G2(Z,j.events,$.events),...W2(Z,j.slots,$.slots),...O2(Z,j,$)]}function L2(j,$){let Z=[],Q=new Map(j.components.map((K)=>[K.moduleName,K])),Y=new Map($.components.map((K)=>[K.moduleName,K]));for(let[K]of Y){if(Q.has(K))continue;Z.push({component:K,kind:"component",bump:"minor",message:`component "${K}" added`})}for(let[K]of Q){if(Y.has(K))continue;Z.push({component:K,kind:"component",bump:"major",message:`component "${K}" removed`})}for(let[K,z]of Q){let J=Y.get(K);if(!J)continue;Z.push(...B2(z,J))}return Z}async function I2(j){let $;try{$=await U2(H2.resolve(j),"utf-8")}catch(Z){if(Z.code==="ENOENT")return null;throw Z}try{return JSON.parse($)}catch{throw Error(`sveld: could not parse "${j}" as JSON. Is it a sveld COMPONENT_API.json snapshot?`)}}function Cj(j){if(typeof j.check==="string")return j.check;return j.jsonOptions?.outFile??"COMPONENT_API.json"}async function Ej(j,$,Z={}){let Q=await I2($);if(Q===null)return{snapshotExists:!1,snapshotFile:$,changes:[],bump:"none"};if(Q.schemaVersion!==O0)return{snapshotExists:!0,snapshotFile:$,changes:[{component:"*",kind:"shape",bump:"none",message:`snapshot schemaVersion ${Q.schemaVersion} does not match the current schemaVersion ${O0}; skipping diff`}],bump:"none"};let Y=C(j,{entryExports:Z.entryExports}),K=L2(Q,Y);return{snapshotExists:!0,snapshotFile:$,changes:K,bump:q2(K)}}var R2={major:"BREAKING",minor:"additive",patch:"patch",none:"no change"};function Pj(j){if(!j.snapshotExists)return`sveld --check: no snapshot found at "${j.snapshotFile}". Run \`sveld --json\` and commit the output first.`;if(j.changes.length===0)return`sveld --check: no API changes detected against "${j.snapshotFile}".`;let $=[],Z=j.changes.length;$.push(`sveld --check: ${Z} API change${Z===1?"":"s"} detected against "${j.snapshotFile}".`),$.push(`Suggested semver bump: ${j.bump}.`);let Q=new Map;for(let Y of j.changes){let K=Q.get(Y.component)??[];K.push(Y),Q.set(Y.component,K)}for(let[Y,K]of Q){$.push(""),$.push(` ${Y}`);for(let z of K)$.push(` [${R2[z.bump]}] ${z.message}`)}return $.join(`
2
+ `)}function vj(j){let $={kind:"check-report",...j};return u($)}import{existsSync as M2}from"node:fs";import{join as b2}from"node:path";import{pathToFileURL as D2}from"node:url";var A2=["sveld.config.js","sveld.config.mjs","sveld.config.ts"];function g4(j){return j}function T2(j=process.cwd()){for(let $ of A2){let Z=b2(j,$);if(M2(Z))return Z}return null}async function w2(j){let $;try{$=await import(`${D2(j).href}?t=${Date.now()}`)}catch(Q){let Y=Q instanceof Error?Q.message:String(Q);throw Error(`sveld: failed to load config file "${j}".
3
+ ${Y}`)}let Z=$.default;if(!i(Z)||Array.isArray(Z))throw Error(`sveld: config file "${j}" must export a configuration object as its default export. Did you forget \`export default defineConfig({ ... })\`?`);return Z}async function fj(j=process.cwd()){let $=T2(j);if($===null)return{};return w2($)}function hj(...j){return Object.assign({},...j.filter(Boolean))}var l0=new Map;function j0(j){l0.set(j.name,j)}function i0(j){return l0.get(j)}function E4(){return Array.from(l0.values())}import{dirname as j2}from"node:path";import{lstatSync as B1,readdirSync as I5,readFileSync as R5,realpathSync as M5,statSync as b5}from"node:fs";import{readFile as D5}from"node:fs/promises";import{dirname as A5,isAbsolute as T5,join as w5,parse as w0,relative as $j,resolve as J0}from"node:path";function $0(j){return j}function m(j){if(j==="")return j;return j.startsWith(".")?j:`./${j}`}import{dirname as S2,resolve as _2}from"node:path";var F2=/^(['"])(.*)\1$/;function N2(j,$){let Z=j.extends?.import;if(Z===void 0)return null;let Q=Z.replace(F2,"$2");if(!f.test(Q))return null;return _2(S2($),Q)}function Z0(j,$){let Z=new Map;for(let Q of j.values()){let Y=$(Q.filePath),K=N2(Q,Y);if(K===null)continue;let z=Z.get(K);if(z===void 0)z=new Set,Z.set(K,z);z.add(Y)}return Z}function L0(j,$){let Z=new Set,Q=[];for(let Y of j)if(!Z.has(Y))Z.add(Y),Q.push(Y);while(Q.length>0){let Y=Q.shift(),K=$.get(Y);if(K===void 0)continue;for(let z of K)if(!Z.has(z))Z.add(z),Q.push(z)}return Z}var x2={"prop-unknown-type":"Props without inferred types","context-any-type":"Context values typed as `any`","event-no-source":"@event tags with no dispatch or callback","example-compile-error":"@example blocks that failed to compile","syntax-skipped":"Component syntax sveld skipped"},y2=["prop-unknown-type","context-any-type","event-no-source","example-compile-error","syntax-skipped"];function I0(j){let $=new Set,Z=[];for(let Q of j){let Y=`${Q.component}:${Q.kind}:${Q.name}`;if($.has(Y))continue;$.add(Y),Z.push(Q)}return Z}function uj(j){if(j.length===0)return"sveld: all types resolved.";let $=[],Z=j.length;$.push(`sveld: ${Z} unresolved type${Z===1?"":"s"} found.`);for(let Q of y2){let Y=j.filter((z)=>z.kind===Q);if(Y.length===0)continue;$.push(""),$.push(`${x2[Q]} (${Y.length}):`);let K=new Map;for(let z of Y){let J=K.get(z.component)??[];J.push(z),K.set(z.component,J)}for(let[z,J]of K){$.push(` ${z}`);for(let H of J){let U=H.source?` (${z}:${H.source.start.line}:${H.source.start.column})`:"";$.push(` - ${H.message}${U}`)}}}return $.join(`
4
+ `)}function mj(j){return u({kind:"diagnostics",diagnostics:j})}var g2=/^```([\w-]*)\r?\n([\s\S]*?)\r?\n?```$/,C2=new Set(["","js","jsx","ts","tsx","javascript","typescript"]);function E2(j){let $=j.trim();if($==="")return null;let Z=$.match(g2);if(Z){let Q=Z[1].toLowerCase();if(!C2.has(Q))return null;let Y=Z[2].trim();return Y===""?null:Y}if($.startsWith("<"))return null;return $}function cj(j){if(!j.isFunction)return"any";return`(${(j.params??[]).map((Z)=>`${Z.name}${Z.optional?"?":""}: any`).join(", ")}) => any`}function R0(j,$,Z,Q,Y){let K=(j??[]).filter((J)=>J.name==="example"),z=[];return K.forEach((J,H)=>{let U=E2(J.body);if(U===null)return;let V=K.length>1;z.push({id:V?`${$}#${H}`:$,name:V?`${Z} (example ${H+1})`:Z,type:Q,code:U,...Y?{source:Y}:{}})}),z}function dj(j){return j.name??"default"}function lj(j){let $=[];for(let Z of j.props)$.push(...R0(Z.tags,`prop:${Z.name}`,Z.name,cj(Z),Z.source));for(let Z of j.moduleExports)$.push(...R0(Z.tags,`export:${Z.name}`,Z.name,cj(Z),Z.source));for(let Z of j.slots)$.push(...R0(Z.tags,`slot:${dj(Z)}`,dj(Z),"any",Z.source));for(let Z of j.events)$.push(...R0(Z.tags,`event:${Z.name}`,Z.name,"any",Z.source));return $}import{createHash as P2}from"node:crypto";import{mkdirSync as v2,readFileSync as f2,writeFileSync as h2}from"node:fs";import{dirname as u2,isAbsolute as m2,join as c2,resolve as ij}from"node:path";var s0=2,d2=c2("node_modules",".cache","sveld","parse-cache.json");function r0(){return`${k0}+svelte@${e}`}function sj(j,$){if(typeof $==="string")return m2($)?$:ij(j,$);return ij(j,d2)}function rj(j){return P2("sha256").update(j).digest("hex")}function pj(){return{formatVersion:s0,toolchainVersion:r0(),entries:{}}}function l2(j){try{let $=f2(j,"utf-8"),Z=JSON.parse($);if(Z.formatVersion!==s0||Z.toolchainVersion!==r0())return pj();return Z}catch{return pj()}}class a0{cacheFilePath;file;next=new Map;blocked=new Set;constructor(j){this.cacheFilePath=j,this.file=l2(j)}has(j,$){if(this.blocked.has(j))return!1;let Z=this.file.entries[j];return Z!==void 0&&Z.hash===$}get(j,$){if(this.blocked.has(j))return null;let Z=this.file.entries[j];if(Z===void 0||Z.hash!==$)return null;if(this.next.set(j,Z),Z.typeScriptMetadata!==void 0)Z.parsed[p0]=Z.typeScriptMetadata;return Z.parsed}set(j,$,Z){this.next.set(j,{hash:$,parsed:Z,typeScriptMetadata:Z[p0]})}invalidate(j){this.blocked.add(j)}getGeneratedText(j,$){let Z=this.next.get(j);if(Z?.generatedText===void 0||Z.generatedText.format!==$)return;return Z.generatedText.text}setGeneratedText(j,$,Z){let Q=this.next.get(j);if(Q===void 0)return;Q.generatedText={format:$,text:Z}}save(){v2(u2(this.cacheFilePath),{recursive:!0});let j={formatVersion:s0,toolchainVersion:r0(),entries:Object.fromEntries(this.next)};h2(this.cacheFilePath,JSON.stringify(j))}}import{existsSync as A0,lstatSync as j1,readFileSync as o2}from"node:fs";import{dirname as J1,join as e2,relative as j5,resolve as U1}from"node:path";var a=null,n0=null;function p(){if(a)return Promise.resolve(a);if(!n0)n0=Promise.all([import("./chunk-jehp1k7m.js"),import("./chunk-9ep3ybg5.js")]).then(([j,$])=>{return a={ComponentParser:j.default,parseSvelte:$.parse},a});return n0}function M0(){if(!a)throw Error("sveld: internal error, parser stack read before loadParserStack() resolved.");return a}import{existsSync as oj,readFileSync as i2}from"node:fs";import{dirname as o0,isAbsolute as p2,join as s2,relative as r2,resolve as D0}from"node:path";function aj(j){if(!i(j))return{};let $=j.svelte;return typeof $==="string"?{svelte:$}:{}}function nj(j){if(!i(j))return{};let $={};if(typeof j.extends==="string")$.extends=j.extends;if(i(j.compilerOptions)){let Z={};if(typeof j.compilerOptions.baseUrl==="string")Z.baseUrl=j.compilerOptions.baseUrl;if(i(j.compilerOptions.paths)){let Q={};for(let[Y,K]of Object.entries(j.compilerOptions.paths))if(Array.isArray(K)&&K.every((z)=>typeof z==="string"))Q[Y]=K;if(Object.keys(Q).length>0)Z.paths=Q}if(Object.keys(Z).length>0)$.compilerOptions=Z}return $}var b0=new Map,tj=new Map,a2=/\/\*[\s\S]*?\*\/|\/\/.*/g,n2=/[.+?^${}()|[\]\\]/g;function t2(j){let $=j,Z=D0($,"/");while($!==Z){for(let Q of["tsconfig.json","jsconfig.json"]){let Y=s2($,Q);if(oj(Y))return Y}$=o0($)}return null}function ej(j){if(b0.has(j))return b0.get(j)??null;try{let $=i2(j,"utf-8"),Z;try{Z=JSON.parse($)}catch{let Y=$.replace(a2,"");Z=JSON.parse(Y)}let Q=nj(Z);if(Q.extends){let Y=p2(Q.extends)?Q.extends:D0(o0(j),Q.extends),K=Y.endsWith(".json")?Y:`${Y}.json`;if(oj(K)){let z=ej(K);if(z)Q.compilerOptions={...z.compilerOptions,...Q.compilerOptions,paths:{...z.compilerOptions?.paths,...Q.compilerOptions?.paths}}}}return b0.set(j,Q),Q}catch{return b0.set(j,null),null}}function Q0(j,$){if(j.startsWith(".")||j.startsWith("/"))return j;let Z=t2($);if(!Z)return j;let Q=ej(Z);if(!Q?.compilerOptions?.paths)return j;let{baseUrl:Y=".",paths:K}=Q.compilerOptions,z=o0(Z),J=D0(z,Y);for(let[H,U]of Object.entries(K)){let V=tj.get(H);if(!V){let W=H.split("*").map((X)=>X.replace(n2,"\\$&")).join("(.*)");V=new RegExp(`^${W}$`),tj.set(H,V)}let G=j.match(V);if(G){let W=U[0];if(!W)continue;let X=W;for(let q=1;q<G.length;q++)X=X.replace("*",G[q]);return D0(J,X)}}return j}function Y0(j,$){if(j.startsWith(".")||j.startsWith("/"))return j;let Z=Q0(j,$);if(Z===j)return j;let Q=r2($,Z);return Q=S(Q),Q.startsWith(".")?Q:`./${Q}`}var $1=[".ts",".mts",".cts",".tsx",".js",".mjs",".cjs",".jsx",".d.ts"],$5=/\r?\n/,Z5=/^\s*\*+/;function L(j){return j&&typeof j==="object"?j:void 0}function t(j){return Array.isArray(j)?j:[]}function h(j){return K1(j)?j.name:void 0}function z0(j,$){let Z=Q0(j,$),Q=U1($,Z);if(A0(Q)&&j1(Q).isFile())return Q;for(let Y of $1){let K=Q+Y;if(A0(K))return K}if(A0(Q)&&j1(Q).isDirectory())for(let Y of $1){let K=e2(Q,`index${Y}`);if(A0(K))return K}return null}function Q5(j,$){let Z=j.slice(0,$).trimEnd();if(!Z.endsWith("*/"))return;let Q=Z.length-2,Y=Z.lastIndexOf("/**",Q);if(Y===-1)return;let K=[];for(let z of Z.slice(Y+3,Q).split($5)){let J=z.replace(Z5,"").trim();if(J.startsWith("@"))break;if(J)K.push(J)}return K.join(" ")||void 0}function Y5(j,$){let Z=j.slice(0,$).trimEnd();if(!Z.endsWith("*/"))return;let Q=Z.length-2,Y=Z.lastIndexOf("/**",Q);if(Y===-1)return;return Z.slice(Y,Q+2)}function n(j,$){if(!$)return;return j.text.slice($.start,$.end)}function K5(j,$){let Z=L($?.typeAnnotation);if(Z?.type!=="TSTypeAnnotation")return;return n(j,L(Z.typeAnnotation))}function e0(j,$){let Z=L($.returnType);return Z?.type==="TSTypeAnnotation"?n(j,L(Z.typeAnnotation)):void 0}function Z1(j,$){let Z=t($.params).map((Y)=>n(j,Y)??"").join(", "),Q=e0(j,$);return`(${Z})${Q?` => ${Q}`:""}`}function H1(j){if(j.type==="Literal"){let $=j.value;if(typeof $==="string")return"string";if(typeof $==="number")return"number";if(typeof $==="boolean")return"boolean"}if(j.type==="TemplateLiteral")return"string";return}function z5(j){if(!j)return;let $=j.lastIndexOf("=>");if($===-1)return;return j.slice($+2).trim()||void 0}function Q1(j){if(j.async||j.generator)return;let $=L(j.body);if(!$)return;let Z=[];if($.type==="BlockStatement"){if(K0($,Z),Z.length===0)return}else Z.push($);let Q;for(let Y of Z){if(!Y)return;let K=H1(Y);if(!K)return;if(Q===void 0)Q=K;else if(Q!==K)return}return Q}function K0(j,$){for(let Z of t(j.body)){if(Z.type==="FunctionDeclaration"||Z.type==="FunctionExpression"||Z.type==="ArrowFunctionExpression")continue;if(Z.type==="ReturnStatement"){$.push(L(Z.argument)??null);continue}if(Z.type==="BlockStatement"){K0(Z,$);continue}let Q=L(Z.consequent);if(Q?.type==="BlockStatement")K0(Q,$);else if(Q?.type==="ReturnStatement")$.push(L(Q.argument)??null);let Y=L(Z.alternate);if(Y?.type==="BlockStatement")K0(Y,$);else if(Y?.type==="ReturnStatement")$.push(L(Y.argument)??null);let K=L(Z.body);if(K?.type==="BlockStatement")K0(K,$)}}function Y1(j,$,Z){let Q=j.filePath,Y=Q5(j.text,Z),K=Y5(j.text,Z),z=K?z1(K):void 0;if($.type==="VariableDeclaration"){let J=$.kind??"const",H=[];for(let U of t($.declarations)){let V=L(U.id),G=h(V);if(!G)continue;let W=K5(j,V),X,B,q=L(U.init);if(q){if(q.type==="ArrowFunctionExpression"||q.type==="FunctionExpression"){if(!W)W=Z1(j,q);B=e0(j,q)??z??z5(W)??Q1(q)}else if(X=n(j,q),!W)W=H1(q)}H.push({name:G,kind:J,type:W,value:X,returnType:B,description:Y,declFile:Q,isTypeOnly:!1})}return H}if($.type==="FunctionDeclaration"||$.type==="TSDeclareFunction"){let J=h(L($.id));if(!J)return[];return[{name:J,kind:"function",type:Z1(j,$),returnType:e0(j,$)??z??Q1($),description:Y,declFile:Q,isTypeOnly:!1}]}if($.type==="ClassDeclaration"){let J=h(L($.id));if(!J)return[];return[{name:J,kind:"class",type:J,description:Y,declFile:Q,isTypeOnly:!1}]}if($.type==="TSTypeAliasDeclaration"){let J=h(L($.id));if(!J)return[];return[{name:J,kind:"type",type:n(j,L($.typeAnnotation)),description:Y,declFile:Q,isTypeOnly:!0}]}if($.type==="TSInterfaceDeclaration"){let J=h(L($.id));if(!J)return[];return[{name:J,kind:"interface",type:n(j,L($.body)),description:Y,declFile:Q,isTypeOnly:!0}]}if($.type==="TSEnumDeclaration"){let J=h(L($.id));if(!J)return[];return[{name:J,kind:"enum",type:J,description:Y,declFile:Q,isTypeOnly:!1}]}return[]}function J5(j){let $;try{$=o2(j,"utf-8")}catch{return null}let Z=`<script lang="ts">
5
+ ${$}
6
+ </script>`;try{let Q=M0().parseSvelte(Z,{modern:!0}),Y=t(Q.instance?.content?.body);return{source:{text:Z,filePath:j,dir:J1(j)},body:Y}}catch(Q){let Y=Q instanceof Error?Q.message:String(Q);return console.warn(`Warning: Failed to parse entry export module ${j}: ${Y}`),null}}function U5(j,$){for(let Z of j){if(Z.type!=="ImportDeclaration")continue;let Q=L(Z.source)?.value;if(typeof Q!=="string")continue;for(let Y of t(Z.specifiers)){if(Y.type!=="ImportSpecifier")continue;if(h(L(Y.local))===$){let K=h(L(Y.imported))??$;return{specifier:Q,importedName:K}}}}return null}function s(j,$){let Z=$.cache.get(j);if(Z)return Z;if($.computing.has(j))return[];$.computing.add(j);let Q=J5(j);if(!Q)return $.computing.delete(j),$.cache.set(j,[]),[];let{source:Y,body:K}=Q,z=[],J=new Map;for(let U of K){let V=U.type==="ExportNamedDeclaration"?L(U.declaration):U;if(!V)continue;for(let G of Y1(Y,V,V.start))J.set(G.name,G)}let H=(U)=>{let V=J.get(U);if(V)return V;let G=U5(K,U);if(!G||G.specifier.endsWith(".svelte"))return null;let W=z0(G.specifier,Y.dir);if(!W)return null;return s(W,$).find((X)=>X.name===G.importedName)??null};for(let U of K){if(U.type==="ExportAllDeclaration"){let B=L(U.source)?.value;if(typeof B!=="string"||B.endsWith(".svelte"))continue;let q=z0(B,Y.dir);if(!q)continue;let O=U.exportKind==="type";for(let b of s(q,$))z.push(O?{...b,isTypeOnly:!0}:b);continue}if(U.type!=="ExportNamedDeclaration")continue;let V=L(U.declaration);if(V){z.push(...Y1(Y,V,U.start));continue}let G=L(U.source)?.value,W=typeof G==="string"?G:void 0;if(W?.endsWith(".svelte"))continue;let X=U.exportKind==="type";for(let B of t(U.specifiers)){if(B.type!=="ExportSpecifier")continue;let q=h(L(B.exported)),O=h(L(B.local));if(!q||!O||O==="default"||q==="default")continue;let b=X||B.exportKind==="type",k=null;if(W){let D=z0(W,Y.dir);if(D)k=s(D,$).find((R)=>R.name===O)??null}else k=H(O);if(k?.declFile.endsWith(".svelte"))continue;if(k)z.push({...k,name:q,isTypeOnly:k.isTypeOnly||b});else z.push({name:q,kind:b?"type":"const",declFile:j,isTypeOnly:b})}}return $.computing.delete(j),$.cache.set(j,z),z}async function T0(j){await p();let $=U1(j),Z=J1($),Q=s($,{cache:new Map,computing:new Set}),Y=new Map;for(let K of Q){let{declFile:z,returnType:J,...H}=K,U=S(`./${j5(Z,z)}`);Y.set(K.name,{...H,source:U})}return Array.from(Y.values()).sort((K,z)=>K.name.localeCompare(z.name))}import{lstatSync as H5,readdirSync as V5,readFileSync as q5}from"node:fs";import{dirname as G5,join as V1,resolve as W5}from"node:path";var q1=new Map;function X5(j){return G1(j,{ecmaVersion:"latest",sourceType:"module"})}function jj(j,$,Z=new Set){let Q=q1.get(j);if(!Q)Q=X5(j),q1.set(j,Q);let Y={};for(let K of Q.body)if(K.type==="ExportDefaultDeclaration"){let z=K.declaration.name;if(z in Y)Y[z].default=!0;else Y[z]={source:m(""),default:!0}}else if(K.type==="ExportAllDeclaration"){if(!K.source)continue;let z=Q0(K.source.value,$),J=W5($,z);if(!H5(J).isFile()){let V=V5(J);for(let G of V)if(G.includes("index")){J=V1(J,G);break}}if(Z.has(J))continue;Z.add(J);let H=q5(J,"utf-8"),U=jj(H,G5(J),Z);Z.delete(J);for(let[V,G]of Object.entries(U)){let W=m(S(`./${V1(K.source.value,G.source)}`));Y[V]={...G,source:W}}}else if(K.type==="ExportNamedDeclaration")for(let z of K.specifiers){let J=z.exported.name,H=z.local.name,U=J||H;if(U in Y){if(K.type==="ExportNamedDeclaration")Y[U].mixed=!0;if(!Y[U].source)Y[U].source=m(Y0(K.source?.value??"",$))}else Y[U]={source:m(Y0(K.source?.value??"",$)),default:H==="default"}}else if(K.type==="ImportDeclaration"){let z=K.specifiers[0].local.name;if(z in Y){if(!Y[z].source)Y[z].source=m(Y0(K.source?.value??"",$))}else Y[z]={source:m(Y0(K.source?.value??"",$)),default:z==="default"}}return Y}import{existsSync as k5}from"node:fs";import{dirname as O5}from"node:path";function W1(){return{cache:new Map,computing:new Set}}var B5=/\.[^./\\]+$/;function L5(j){if(j.endsWith(".d.ts"))return null;let $=j.replace(B5,".d.ts");return k5($)?$:null}function X1(j,$,Z){let Q=O5(j);return $.map((Y)=>{if(!Y.importSource||!Y.importedName)return{candidate:Y};let K=z0(Y.importSource,Q);if(!K)return{candidate:Y,failureReason:"module-not-found"};let z=s(K,Z).find((H)=>H.name===Y.importedName);if(!z)return{candidate:Y,failureReason:"export-not-found"};if(z.returnType)return{candidate:Y,type:z.returnType};let J=L5(K);if(J){let H=s(J,Z).find((U)=>U.name===Y.importedName);if(H?.returnType)return{candidate:Y,type:H.returnType}}return{candidate:Y,failureReason:"return-type-unresolved"}})}function k1(j,$){switch($){case"module-not-found":return`Prop "${j.propName}" default calls "${j.calleeName}()", but "${j.importSource}" could not be resolved; falling back to "any".`;case"export-not-found":return`Prop "${j.propName}" default calls "${j.calleeName}()", but "${j.importedName}" is not exported from "${j.importSource}"; falling back to "any".`;case"return-type-unresolved":return`Prop "${j.propName}" default calls "${j.calleeName}()" imported from "${j.importSource}", but its return type could not be resolved; falling back to "any".`}}function H0(j){return{failFast:j?.failFast,resolveTypes:j?.resolveTypes===!0,documentExports:j?.documentExports===!0,cache:j?.cache,checkExamples:j?.checkExamples===!0,dryRun:j?.dryRun===!0}}var S5=/-/g;function L1(j,$=[],Z=new Set){let Q;try{let Y=M5(j);if(Z.has(Y))return $;Z.add(Y),Q=I5(j,{withFileTypes:!0})}catch{return $}for(let Y of Q){if(Y.name.startsWith("."))continue;let K=w5(j,Y.name),z=Y.isSymbolicLink()?b5(K,{throwIfNoEntry:!1}):Y;if(!z)continue;if(z.isDirectory())L1(K,$,Z);else if(z.isFile()&&Y.name.endsWith(".svelte"))$.push(K)}return $}function _5(j){return L1(j).map(($)=>{let Z=w0($).name.replace(S5,""),Q=m(S(`./${$j(j,$)}`));return{moduleName:Z,source:Q}}).sort(($,Z)=>$.source.localeCompare(Z.source))}function F5(j){return w0(j).ext!==".svelte"}function N5(j,$){let Z=j.endsWith("/")?j:`${j}/`;return $.startsWith(Z)}function Zj(j,$){return{seenPaths:new Set(j.map(([,Z])=>$(Z.source))),seenModuleNamePaths:new Map(j.map(([Z,Q])=>[Z,$(Q.source)])),warnedModuleNames:new Set}}function Qj(j,$,Z,Q,Y){for(let{moduleName:K,source:z}of _5(j)){let J=Q(z),H=$[K];if(H&&F5(H.source)&&N5(H.source,z)){Y.seenPaths.delete(Q(H.source)),H.source=z,Y.seenPaths.add(J),Y.seenModuleNamePaths.set(K,J);continue}if(Y.seenPaths.has(J))continue;Y.seenPaths.add(J);let U=Y.seenModuleNamePaths.get(K);if(U===void 0)Y.seenModuleNamePaths.set(K,J);else if(U!==J&&!Y.warnedModuleNames.has(K))Y.warnedModuleNames.add(K),console.warn(`Warning: multiple components named "${K}" found (${S($j(j,U))} and ${S($j(j,J))}). Both are included in TypeScript definitions, but only one can be the named export.`);Z.push([K,{source:z,default:!1}])}}function Yj(j,$,Z=!1){let Q=B1(j).isFile(),Y=Q?A5(j):j,K=J0(Y),z=(U)=>T5(U)?J0(U):J0(K,U),J={};if(Q){let U=R5(j,"utf-8");try{J=jj(U,K,new Set([J0(j)]))}catch(V){if(!Z)throw V;let G=V instanceof Error?V.message:String(V);console.warn(`Warning: Failed to parse component exports from ${j}: ${G}`)}}let H=Object.entries(J);if($){let U=Zj(H,z);Qj(K,J,H,z,U)}return{exports:J,allComponentEntries:H,rootDir:K,resolveComponentFilePath:z}}async function S0(j){let $=await Promise.all(Array.from(j).map(async(Z)=>{try{let Q=await D5(Z,"utf-8");return{path:Z,content:Q}}catch(Q){return console.warn(`Warning: Failed to read file ${Z}:`,Q),{path:Z,content:null}}}));return new Map($.map(({path:Z,content:Q})=>[Z,Q]))}function d([j,$],Z,Q,Y,K={}){let z=$.source,{ext:J,name:H}=w0(z),U=j;if(Z.length===1&&j==="default")U=H;if(J===".svelte"){let V=Y(z),G=Q.get(V);if(G===null||G===void 0)return null;let W=S(z),X=K.memo?.get(V),B=K.hashes?.get(V),q=X===void 0?B===void 0?null:K.cache?.get(V,B):null,O;if(X!==void 0)O=X;else if(q)O=q;else{let b=new(M0()).ComponentParser;try{O=b.parseSvelteComponent(G,{moduleName:U,filePath:W})}catch(k){if(K.failFast)throw k;let D=k instanceof Error?k.message:String(k),R=k instanceof Error?k.stack:void 0;return K.onParseError?.({filePath:W,moduleName:U,message:D,stack:R}),null}if(B!==void 0)K.cache?.set(V,B,O);K.memo?.set(V,O)}return{moduleName:U,filePath:W,...O}}return null}function Kj(j,$){let Z=new Set;for(let Q of j)for(let[,Y]of Q)if(w0(Y.source).ext===".svelte")Z.add($(Y.source));return Z}function _0(j){if(j.length===0)return;console.error(`sveld: failed to parse ${j.length} component(s):`);for(let{filePath:$,message:Z}of j)console.error(` - ${$}: ${Z}`)}async function V0(j,$,Z={}){let Q=Z.documentExports===!0,{exports:Y,allComponentEntries:K,rootDir:z,resolveComponentFilePath:J}=Yj(j,$,Q),H=Q&&B1(j).isFile()?await T0(J0(j)):[],U=Object.entries(Y),V=Kj([U,K],J),G=await S0(V),W=new Map,X=new Map,B=Z.cache===!1?void 0:new a0(sj(z,Z.cache??!0)),q=B?new Map:void 0,O=new Set,b=new Map;if(B)for(let M of V){let I=G.get(M);if(I===null||I===void 0)continue;let T=rj(I);if(b.set(M,T),!B.has(M,T))O.add(M)}if(V.size>0&&(!B||O.size>0))await p();let k=new Map,D=new Map,R={failFast:Z.failFast===!0,onParseError:(M)=>k.set(M.filePath,M),cache:B,hashes:b,memo:D};for(let M of U){let I=d(M,U,G,J,R);if(I)W.set(I.moduleName,I)}for(let M of K){let I=d(M,K,G,J,R);if(I)X.set(I.filePath,I),q?.set(I.filePath,J(M[1].source))}if(B&&O.size>0){let M=Z0(X,J),I=L0(O,M);for(let T of I){if(O.has(T))continue;B.invalidate(T),D.delete(T)}for(let T of U){let g=J(T[1].source);if(!I.has(g)||O.has(g))continue;let v=d(T,U,G,J,R);if(v)W.set(v.moduleName,v)}for(let T of K){let g=J(T[1].source);if(!I.has(g)||O.has(g))continue;let v=d(T,K,G,J,R);if(v)X.set(v.filePath,v),q?.set(v.filePath,g)}}let A=Array.from(k.values());if(_0(A),!Z.dryRun)B?.save();let x=Z.resolveTypes?g5(W):[],y=Z.checkExamples?E5(X):[];if(x.length>0||y.length>0){let{TypeResolver:M}=await import("./chunk-fk94b2eb.js"),I=await M.create(z);try{if(x.length>0)await C5(x,I,J);if(y.length>0)await P5(y,I,J)}finally{await I?.dispose()}}let w=x5(X);if(w.length>0){await p();let M=W1();for(let{component:I,candidates:T}of w){let g=X1(J(I.filePath),T,M);y5(I,g)}}let _=I0(Array.from(X.values()).flatMap((M)=>M.diagnostics??[]));return{exports:Y,entryExports:H,components:W,allComponentsForTypes:X,errors:A,diagnostics:_,cache:B,resolvedPathByFilePath:q}}function x5(j){let $=[];for(let Z of j.values()){let Q=U0(Z)?.pendingCallDefaultCandidates?.filter((Y)=>Y.importSource!==void 0);if(!Q||Q.length===0)continue;$.push({component:Z,candidates:Q})}return $}function y5(j,$){for(let{candidate:Z,type:Q,failureReason:Y}of $){let z=(Z.location==="props"?j.props:j.moduleExports).find((J)=>J.name===Z.propName);if(z?.typeSource!=="unknown")continue;if(Q){if(z.type=Q,z.typeSource="typescript",Z.location==="props")j.diagnostics=(j.diagnostics??[]).filter((J)=>!(J.kind==="prop-unknown-type"&&J.name===Z.propName));continue}if(Z.location==="props"&&Y){let J=j.diagnostics?.find((H)=>H.kind==="prop-unknown-type"&&H.name===Z.propName);if(J)J.message=k1(Z,Y)}}}function g5(j){let $=[];for(let Z of j.values()){let Q=U0(Z);if(!Q?.canonicalPropsType||Z.props.length>0)continue;$.push({component:Z,metadata:Q})}return $}async function C5(j,$,Z){if(!$)return;let Q=await $.expandAll(j.map(({component:Y,metadata:K})=>({moduleName:Y.moduleName,metadata:K,filePath:Z(Y.filePath)})));for(let{component:Y}of j){let K=Q.get(Z(Y.filePath));if(K)O1(Y,K)}}function E5(j){let $=[];for(let Z of j.values()){let Q=lj(Z);if(Q.length===0)continue;$.push({component:Z,sources:Q})}return $}async function P5(j,$,Z){if(!$)return;let Q=await $.checkExamples(j.map(({component:Y,sources:K})=>({moduleName:Y.moduleName,filePath:Z(Y.filePath),sources:K})));for(let{component:Y,sources:K}of j){let z=Q.get(Z(Y.filePath));if(!z||z.length===0)continue;let J=new Map(K.map((U)=>[U.id,U.source])),H=Y.diagnostics??[];for(let U of z){let V=J.get(U.id);H.push({component:Y.filePath,kind:"example-compile-error",name:U.name,message:U.message,...V?{source:V}:{}})}Y.diagnostics=H}}import{existsSync as I1,readFileSync as v5}from"node:fs";import{join as R1}from"node:path";function F0(j){if(j){let Z=R1(process.cwd(),j);if(I1(Z))return $0(j);return console.error(`Invalid entry point: ${Z}. Pass a valid --entry (or "entry" option), or unset it and`),console.error('set the "svelte" field in your package.json instead.'),null}let $=R1(process.cwd(),"package.json");if(!I1($))return console.error("Could not locate a package.json file."),console.error(`Specify an entry point with --entry (or the "entry" option) instead.
7
+ `),null;try{let Z=aj(JSON.parse(v5($,"utf-8")));if(Z.svelte?.trim())return $0(Z.svelte);return console.error(`Could not determine an entry point.
8
+ `),console.error(`Specify an entry point to your Svelte code in the "svelte" field of your package.json, or pass --entry (or the "entry" option).
9
+ `),null}catch(Z){throw console.error("Error reading package.json:",Z),Z}}import{lstatSync as f5}from"node:fs";import{resolve as M1}from"node:path";async function b1(j,$,Z=!1){let{exports:Q,allComponentEntries:Y,rootDir:K,resolveComponentFilePath:z}=Yj(j,$,Z),J=Z&&f5(j).isFile()?await T0(M1(j)):[],H=Object.entries(Q),U=Zj(Y,z),V=new Map,G=new Map;await p();let W=new Map,X={onParseError:(k)=>W.set(k.filePath,k)},B=()=>({exports:Q,entryExports:J,components:V,allComponentsForTypes:G,errors:Array.from(W.values()),diagnostics:I0(Array.from(G.values()).flatMap((k)=>k.diagnostics??[]))});{let k=Kj([H,Y],z),D=await S0(k);for(let R of H){let A=d(R,H,D,z,X);if(A)V.set(A.moduleName,A)}for(let R of Y){let A=d(R,Y,D,z,X);if(A)G.set(A.filePath,A)}_0(B().errors)}let q=Z0(G,z),O=(k,D,R,A,x)=>{let y=new Set;for(let w of R){let _=z(w[1].source);if(!A.has(_))continue;let M=d(w,R,x,z,X);if(M)k.set(D(M),M),y.add(_);else for(let[I,T]of k)if(z(T.filePath)===_)k.delete(I)}return y};return{get result(){return B()},update:async(k)=>{let D=k.filter((w)=>f.test(w)).map((w)=>M1(w));if(D.length===0)return{result:B(),reparsed:[]};if($)Qj(K,Q,Y,z,U);let R=L0(D,q);for(let[w,_]of W)if(R.has(z(_.filePath)))W.delete(w);let A=await S0(R),x=new Set;for(let w of O(V,(_)=>_.moduleName,H,R,A))x.add(w);for(let w of O(G,(_)=>_.filePath,Y,R,A))x.add(w);q=Z0(G,z);let y=B();return _0(y.errors),{result:y,reparsed:Array.from(x)}}}}import n5 from"node:path";var D1=!1;function A1(j){D1=j}function c(j){if(!D1)console.error(j)}import{mkdir as h5,readFile as u5,writeFile as m5}from"node:fs/promises";import{parse as c5}from"node:path";class F{dryRun;constructor(j){this.dryRun=j?.dryRun===!0}async write(j,$){if(this.dryRun)return console.log(`would write "${S(j)}"`),!0;try{if(await u5(j,"utf-8")===$)return!1}catch{}return await h5(c5(j).dir,{recursive:!0}),await m5(j,$),!0}}var d5=new Set(["string","number","boolean"]);function l5(j){return j.map(($)=>({kind:"field",name:$.name,...$.type?{type:{text:$.type}}:{},...$.value===void 0?{}:{default:$.value},...$.description?{description:$.description}:{},...$.deprecated===void 0?{}:{deprecated:$.deprecated}}))}function i5(j){let $=new Map;for(let Q of j){if(!Q.type||!d5.has(Q.type.trim()))continue;let Y=Q.name.toLowerCase(),K=$.get(Y);if(K)K.push(Q);else $.set(Y,[Q])}let Z=[];for(let[Q,Y]of $){if(Y.length!==1)continue;let K=Y[0];Z.push({name:Q,fieldName:K.name,type:{text:K.type},...K.value===void 0?{}:{default:K.value},...K.description?{description:K.description}:{}})}return Z}function p5(j){return j.filter(($)=>$.type==="dispatched").map(($)=>({name:$.name,type:{text:`CustomEvent<${$.detail??"unknown"}>`},...$.description?{description:$.description}:{},...$.deprecated===void 0?{}:{deprecated:$.deprecated}}))}function s5(j){return j.map(($)=>({name:$.default?"":$.name??"",...$.description?{description:$.description}:{},...$.deprecated===void 0?{}:{deprecated:$.deprecated}}))}function r5(j){let $={kind:"class",name:j.moduleName,...j.componentComment?{description:j.componentComment}:{},members:l5(j.props),attributes:i5(j.props),events:p5(j.events),slots:s5(j.slots)};if(j.customElementTag)$.tagName=j.customElementTag,$.customElement=!0;return $}function a5(j,$){let Z=[{kind:"js",name:j.moduleName,declaration:{name:j.moduleName,module:$}}];if(j.customElementTag)Z.push({kind:"custom-element-definition",name:j.customElementTag,declaration:{name:j.moduleName,module:$}});return Z}function T1(j,$={}){let Z=C(j),Q=$.resolveModulePath??((K)=>K.filePath);return{schemaVersion:"1.0.0",modules:Z.components.map((K)=>{let z=Q(K);return{kind:"javascript-module",path:z,declarations:[r5(K)],exports:a5(K,z)}})}}function zj(j,$){let Z=T1(j,{resolveModulePath:(Q)=>N0(Q.filePath,$.inputDir)});return u(Z)}async function Jj(j,$){let Z=zj(j,$),Q=n5.join(process.cwd(),$.outFile);if(await new F({dryRun:$.dryRun}).write(Q,Z),!$.dryRun)c(`created "${$.outFile}".`)}import Uj from"node:path";function w1(j){let $=new Map;for(let[Q,Y]of Object.entries(j)){let K=$.get(Y.source)||[];K.push({id:Q,exportee:Y}),$.set(Y.source,K)}let Z=[];for(let[Q,Y]of $){let K=f.test(Q),z=Y.some(({id:W,exportee:X})=>W!=="default"&&X.default),J=Y.some(({exportee:W})=>!W.default),H=K&&z&&J,U=[],V=[],G=[];for(let{id:W,exportee:X}of Y){if(W==="default"){V.push(`export { default } from "${Q}";`);continue}if(X.default)if(X.mixed)V.push(`export { default as ${W} } from "${Q}";`),V.push(`export { default } from "${Q}";`);else G.push(`default as ${W}`);else if(K&&!H)G.push(`default as ${W}`);else U.push(W)}if(G.length>0&&U.length>0)Z.push(`export { ${[...G,...U].join(", ")} } from "${Q}";`);else{if(U.length>0)Z.push(`export { ${U.join(", ")} } from "${Q}";`);if(G.length>0)Z.push(`export { ${G.join(", ")} } from "${Q}";`)}Z.push(...V)}return Z.join(`
10
+ `)}function S1(j){return j.replace(f,"")}function _1(j){return j.replace(f,".svelte.d.ts")}function Hj(j,$){return j.map((Z)=>({...Z,filePath:N0(Z.filePath,$)}))}function t5(j,$,Z){if(!$)return`${j.moduleName}.api.json`;if(!Z.has(j.moduleName))Z.add(j.moduleName),console.warn(`Warning: multiple components named "${j.moduleName}" found. Their JSON files are keyed by source path instead of name to avoid overwriting each other.`);return`${S1(j.filePath)}.api.json`}async function o5(j,$){let Z=C(j),Q=Hj(Z.components,$.inputDir),Y=new Map;for(let z of Q)Y.set(z.moduleName,(Y.get(z.moduleName)??0)+1);let K=new Set;await Promise.all(Q.map(async(z)=>{let J=(Y.get(z.moduleName)??0)>1,H=t5(z,J,K),U=Uj.resolve(Uj.join($.outDir||"",H)),G=await new F({dryRun:$.dryRun}).write(U,u(z));if(!$.dryRun)c(`${G?"created":"unchanged"} "${U}".`)}))}function Vj(j,$){let Z=C(j,{entryExports:$.entryExports}),Q={...Z,components:Hj(Z.components,$.inputDir)};return u(Q)}function F1(j,$){let Z=C(j,{entryExports:$.entryExports});return`${Hj(Z.components,$.inputDir).map((Y)=>JSON.stringify(Y)).join(`
11
+ `)}
12
+ `}async function e5(j,$){let Z=Vj(j,$),Q=Uj.join(process.cwd(),$.outFile);if(await new F({dryRun:$.dryRun}).write(Q,Z),!$.dryRun)c(`created "${$.outFile}".`)}async function qj(j,$){if($.outDir)await o5(j,$);else await e5(j,$)}import{join as e3}from"node:path";var x1=/^[}\])>]/,j3=new Set(["{","(","["]),$3=new Set(["}",")","]"]);var Z3=/\binterface\s+[A-Za-z_$][\w$]*(\s*<[^{};]*>)?\s*$/,y1=/[ \t]+$/,Q3=/\s+$/,Y3=/[{([]$/,K3=/\s/;function z3(j){return Z3.test(j.slice(-200))}var J3=200;function U3(j,$){let Z="";for(let Q=j.length-1;Q>=0&&Z.length<$;Q--)Z=j[Q]+Z;return Z.length>$?Z.slice(-$):Z}function N1(j,$){while(j.length>0&&$.test(j[j.length-1]))j.pop()}function H3(j){let $="",Z=null,Q=!1;for(let Y=0;Y<j.length;Y++){let K=j[Y],z=j[Y-1];if(Z){if($+=K,Z==="double"&&K==='"'&&z!=="\\"||Z==="single"&&K==="'"&&z!=="\\"||Z==="template"&&K==="`"&&z!=="\\")Z=null;Q=!1;continue}if(K==='"'||K==="'"||K==="`"){Z=K==='"'?"double":K==="'"?"single":"template",$+=K,Q=!1;continue}if(K3.test(K)){if(!Q&&$.length>0)$+=" ",Q=!0;continue}$+=K,Q=!1}return $.trimEnd()}function V3(j,$){let Z=0,Q="normal";for(let Y=$;Y<j.length;Y++){let K=j[Y],z=j[Y-1];if(Q==="blockComment"){if(z==="*"&&K==="/")Q="normal";continue}if(Q==="double"||Q==="single"){if(K===(Q==="double"?'"':"'")&&z!=="\\")Q="normal";continue}if(Q==="template"){if(K==="`"&&z!=="\\")Q="normal";continue}if(K==="/"&&j[Y+1]==="*")Q="blockComment";else if(K==='"')Q="double";else if(K==="'")Q="single";else if(K==="`")Q="template";else if(K==="{")Z++;else if(K==="}"){if(Z--,Z===0)return Y}}return-1}function g1(j){let $=[],Z="normal";for(let Q=0;Q<j.length;Q++){let Y=j[Q],K=j[Q-1];if(Z==="blockComment"){if($.push(Y),K==="*"&&Y==="/")Z="normal";continue}if(Z==="double"||Z==="single"){if($.push(Y),Y===(Z==="double"?'"':"'")&&K!=="\\")Z="normal";continue}if(Z==="template"){if($.push(Y),Y==="`"&&K!=="\\")Z="normal";continue}if(Y==="/"&&j[Q+1]==="*"){Z="blockComment",$.push(Y);continue}if(Y==='"'){Z="double",$.push(Y);continue}if(Y==="'"){Z="single",$.push(Y);continue}if(Y==="`"){Z="template",$.push(Y);continue}if(Y==="{"){let z=V3(j,Q);if(z===-1){$.push(Y);continue}let J=j.slice(Q+1,z);if(J.trim()===""){$.push("{}"),Q=z;continue}if(!J.includes("/*")&&j[Q+1]!==`
13
+ `&&!z3(U3($,J3))){let H=g1(J).trim();if(!H.includes(`
14
+ `)){let U=H.endsWith(";")?H.slice(0,-1):H,V=`{ ${H3(U)} }`;if(V.length<=120){$.push(V),Q=z;continue}}}if($.push(Y),j[Q+1]!==`
15
+ `)$.push(`
16
+ `);continue}if(Y==="}"){if(N1($,y1),$[$.length-1]!==`
17
+ `)$.push(`
18
+ `);$.push(Y);continue}if(Y===";"){if(N1($,Q3),$.push(";"),j[Q+1]!==`
19
+ `)$.push(`
20
+ `);continue}$.push(Y)}return $.join("")}function q3(j){let $="",Z=null;for(let Q=0;Q<j.length;Q++){let Y=j[Q],K=j[Q-1];if(Z){if($+=Y,Z==="double"&&Y==='"'&&K!=="\\"||Z==="single"&&Y==="'"&&K!=="\\"||Z==="template"&&Y==="`"&&K!=="\\")Z=null;continue}if(Y==='"'||Y==="'"||Y==="`"){Z=Y==='"'?"double":Y==="'"?"single":"template",$+=Y;continue}if(Y===" "&&$.endsWith(" "))continue;$+=Y}return $}function G3(j){let $=j.split(`
21
+ `),Z=[],Q=0,Y=!1,K=0;for(let z of $){let J=z.trim();if(J===""){Z.push("");continue}if(Y){if(Z.push(`${" ".repeat(K)} ${J}`),J.includes("*/"))Y=!1;continue}if(J.startsWith("/**")&&!J.includes("*/")){Z.push(" ".repeat(Q)+J),Y=!0,K=Q;continue}let H=q3(J),U=x1.test(H),V=Math.max(0,Q-(U?1:0));if(Z.push(" ".repeat(V)+H),H.startsWith("/**")&&H.includes("*/"))continue;let G=null;for(let W=0;W<H.length;W++){let X=H[W],B=H[W-1];if(G){if(G==="double"&&X==='"'&&B!=="\\"||G==="single"&&X==="'"&&B!=="\\"||G==="template"&&X==="`"&&B!=="\\")G=null;continue}if(X==='"')G="double";else if(X==="'")G="single";else if(X==="`")G="template";else if(j3.has(X))Q++;else if($3.has(X))Q=Math.max(0,Q-1);else if(X==="<")Q++;else if(X===">"&&B!=="=")Q=Math.max(0,Q-1)}}return Z.join(`
22
+ `)}function W3(j){let $=j.split(`
23
+ `).map((Q)=>Q.replace(y1,"")),Z=[];for(let Q of $){let Y=Q==="",K=Z.length>0&&Z[Z.length-1]==="",z=Z.length>0&&Y3.test(Z[Z.length-1]);if(Y){if(Z.length===0||K||z)continue;Z.push(Q);continue}if(x1.test(Q)&&K)Z.pop();Z.push(Q)}while(Z.length>0&&Z[Z.length-1]==="")Z.pop();return Z.join(`
24
+ `)}function C1(j){let $=g1(j),Z=G3($);return`${W3(Z)}
25
+ `}var l="any",E="",X3="Record<string, any>",Wj="Record<string, never>",k3=/(-|\s+|:)/,O3=/("|')/,B3=/CustomEvent/,L3=/^[A-Z]/,I3=/\n/,E1=/=>/,R3=/(?:^|\n)@default\b/,Xj=/\n/g,M3=/\s+/g,b3=/(^|[^.\w])Snippet(?:\s*<|\b)/,D3=/import\s+type\s+[^;]*\bSnippet\b[^;]*from\s+"svelte";/,A3=/[.*+?^${}()|[\]\\]/g,T3=/^const\s+/;function kj(j){return j.replace(T3,"")}function w3(j){if(!j)return;return j.replace(Xj,`
26
+ * `)}function y0(j){if(!j)return"";return`/** ${j} */`}function g0(j){if(!j)return"";return`/**
27
+ * ${j.replace(Xj,`
28
+ * `)}
29
+ */`}function P1(j){if(j===void 0)return;return j===!0?"@deprecated":`@deprecated ${j}`}function S3(j){let $=P1(j);if($===void 0)return;return`* ${$.replace(Xj,`
30
+ * `)}
31
+ `}function _3(j,$){if(!$)return[`@${j}`];if(!$.includes(`
32
+ `))return[`@${j} ${$}`];return[`@${j}`,...$.split(`
33
+ `)]}function v1(j){let $=[];for(let{name:Z,body:Q}of j??[])$.push(..._3(Z,Q));return $}function q0(j,$,Z){let Q=P1(Z),Y=v1($),K=Y.length>0;if(!j&&!K&&!Q)return"";if(!K&&!Q)return j?.includes(`
34
+ `)?g0(j):y0(j);let z=[];if(j)z.push(...j.split(`
35
+ `));if(z.push(...Y),Q)z.push(...Q.split(`
36
+ `));return`/**
37
+ * ${z.join(`
38
+ * `)}
39
+ */`}function F3(j){let $=v1(j);if($.length===0)return"";return $.map((Z)=>`* ${Z}
40
+ `).join("")}function C0(j){if(j===void 0)return l;return`${j}
41
+ `}function E0(j){if(j.typedefs.length===0)return E;return j.typedefs.map(($)=>{return`${$.description?`${g0($.description)}
42
+ `:""}export ${$.ts}`}).join(`
43
+
44
+ `)}function f1(j,$){let Z=$.replace(A3,"\\$&");return new RegExp(`\\b${Z}\\b`).test(j)}function N3(j){if(j===null)return[];return j[0].split(",").map(($,Z)=>({name:$.trim(),constraint:(x0(j[1]??"")[Z]??$).trim()}))}function x3(j,$){let Z=N3(j).filter(({name:Q})=>f1($,Q));if(Z.length===0)return{declSuffix:E,refSuffix:E};return{declSuffix:`<${Z.map(({constraint:Q})=>kj(Q)).join(", ")}>`,refSuffix:`<${Z.map(({name:Q})=>Q).join(", ")}>`}}function h1(j){if(!j.contexts||j.contexts.length===0)return E;let $=j.generics===null?[]:j.generics[0].split(",").map((Z,Q)=>({name:Z.trim(),constraint:(x0(j.generics?.[1]??"")[Q]??Z).trim()}));return j.contexts.map((Z)=>{let Q=Z.properties.map((J)=>{let H=J.description?`${y0(J.description)}
45
+ `:"",U=J.optional?"?":"";return`${H}${J.name}${U}: ${J.type};`}).join(`
46
+ `),Y=Z.description?`${g0(Z.description)}
47
+ `:"",K=$.filter(({name:J})=>Z.properties.some((H)=>f1(H.type,J))).map(({constraint:J})=>J),z=K.length>0?`<${K.map(kj).join(", ")}>`:"";if(Z.properties.length===0)return`${Y}export type ${Z.typeName} = Record<string, never>;`;return`${Y}export type ${Z.typeName}${z} = {
48
+ ${Q}
49
+ };`}).join(`
50
+
51
+ `)}function G0(j){if(k3.test(j))return O3.test(j)?j:`"${j}"`;return j}function u1(j,$){if(!j)return;return`* ${$||j}
52
+ `}function Oj(j,$,Z){return[u1(w3(j)),S3($),F3(Z)].filter(Boolean).join("")}function Bj(j){return j.length>0?`/**
53
+ ${j}*/`:E}function y3(j){let $=new Set([...j.props.filter((q)=>!q.isFunctionDeclaration&&q.kind!=="const").map((q)=>q.name),...Array.from(j.canonicalPropNames??[])]),Z=j.props.filter((q)=>!q.isFunctionDeclaration&&q.kind!=="const").map((q)=>{let O=q.value;if(typeof q.value==="string")O=q.value.replace(M3," ");if(q.value===void 0)O="undefined";let k=R3.test(q.description??"")||q.isFunction&&q.value===void 0,D=[Oj(q.description,q.deprecated,q.tags),u1(q.constant,"@constant"),k?null:`* @default ${O}
54
+ `].filter(Boolean).join(""),R=q.constant&&!q.isFunction?q.value:q.type;return`
55
+ ${Bj(D)}
56
+ ${q.name}${q.isRequired?"":"?"}: ${R};`}),Q=j.canonicalPropsType?Z.filter((q,O)=>{let b=j.props.filter((k)=>!k.isFunctionDeclaration&&k.kind!=="const")[O];return b?!(j.canonicalPropNames?.has(b.name)??!1):!0}):Z,Y=(j.slots||[]).filter((q)=>!q.default&&q.name!=null&&!$.has(q.name)).map((q)=>{let O=q.name,b=G0(O),k=q0(q.description,q.tags,q.deprecated),D=k?`${k}
57
+ `:"",A=q.slot_props&&q.slot_props!=="Record<string, never>"?`(this: void, ...args: [${q.slot_props}]) => void`:"(this: void) => void";return`
58
+ ${D}${b}?: ${A};`}),K=(j.slots||[]).find((q)=>q.default||q.name===null),z=K&&!$.has("children")?(()=>{let q=q0(K.description,K.tags,K.deprecated),O=q?`${q}
59
+ `:"",k=K.slot_props&&K.slot_props!=="Record<string, never>"?`(this: void, ...args: [${K.slot_props}]) => void`:"(this: void) => void";return`
60
+ ${O}children?: ${k};`})():"",J=j.events?f3({events:j.events},$):[],H=[...Y,z,...J].filter(Boolean),U=[...Q,...H].join(`
61
+ `),V=`${j.moduleName}Props`,G=E,W=j.generics?`<${x0(j.generics[1]).map((q)=>kj(q.trim())).join(", ")}>`:"",X=j.generics?`<${j.generics[0]}>`:"",B=j.canonicalPropsType?`
62
+ type $Props${W} = ${j.canonicalPropsType}${U.trim()===""?"":` & {${U}
63
+ }`};
64
+ `:`
65
+ type $Props${W} = {
66
+ ${U}
67
+ };
68
+ `;if(j.rest_props?.type==="Element"){let q;if(j.rest_props.name==="svelte:element")if(j.rest_props.thisValue)q=`SvelteHTMLElements["${j.rest_props.thisValue}"]`;else q="HTMLAttributes<HTMLElement>";else q=j.rest_props.name.split("|").map((k)=>{return`SvelteHTMLElements["${k.trim()}"]`}).join(" & ");let O="[key: `data-${string}`]: unknown;",b=j.rest_props.description?j.rest_props.description.includes(`
69
+ `)?`${g0(j.rest_props.description)}
70
+ `:`${y0(j.rest_props.description)}
71
+ `:"";if(j.extends===void 0)G=`
72
+ ${b}${q?`type $RestProps = ${q};
73
+ `:""}
74
+ ${j.canonicalPropsType?`type $Props${W} = (${j.canonicalPropsType}) & {${U}
75
+
76
+ ${O}
77
+ };`:`type $Props${W} = {
78
+ ${U}
79
+
80
+ ${O}
81
+ };`}
82
+
83
+ export type ${V}${W} = Omit<$RestProps, keyof $Props${X}> & $Props${X};
84
+ `;else G=`
85
+ ${b}${q?`type $RestProps = ${q};
86
+ `:""}
87
+ ${j.canonicalPropsType?`type $Props${W} = (${j.canonicalPropsType}) & {${U}
88
+
89
+ ${O}
90
+ };`:`type $Props${W} = {
91
+ ${U}
92
+
93
+ ${O}
94
+ };`}
95
+
96
+ export type ${V}${W} = Omit<$RestProps, keyof ($Props${X} & ${j.extends.interface})> & $Props${X} & ${j.extends.interface};
97
+ `}else if(U.trim()===""&&j.extends===void 0&&!j.canonicalPropsType)G=`
98
+ export type ${V}${W} = ${Wj};
99
+ `;else if(j.canonicalPropsType)G=`
100
+ ${B}
101
+ export type ${V}${W} = ${j.extends===void 0?"":`${j.extends.interface} & `}$Props${X};
102
+ `;else G=`
103
+ export type ${V}${W} = ${j.extends===void 0?"":`${j.extends.interface} & `} {
104
+ ${U}
105
+ };
106
+ `;return{props_name:V,prop_def:G}}function g3(j){if(j.slots.length===0)return Wj;let $=j.slots.map(({name:Z,slot_props:Q,...Y})=>{let K=Y.default||Z===null?"default":G0(Z??""),z=q0(Y.description,Y.tags,Y.deprecated);return`${z?`${z}
107
+ `:""}${G0(K)}: ${C0(Q)};`}).join(`
108
+ `);return j.slots.length===1?`{${$}}`:`{
109
+ ${$}
110
+ }`}var C3=()=>"WindowEventMap",E3=new Set(["click","dblclick","mousedown","mouseup","mousemove","mouseover","mouseout","mouseenter","mouseleave","contextmenu","wheel","keydown","keyup","keypress","submit","change","input","focus","blur","focusin","focusout","reset","select","touchstart","touchend","touchmove","touchcancel","drag","dragstart","dragend","dragover","dragenter","dragleave","drop","pointerdown","pointerup","pointermove","pointerover","pointerout","pointerenter","pointerleave","pointercancel","gotpointercapture","lostpointercapture","play","pause","ended","volumechange","timeupdate","loadeddata","loadedmetadata","canplay","canplaythrough","seeking","seeked","playing","waiting","stalled","suspend","abort","error","emptied","ratechange","durationchange","loadstart","progress","loadend","animationstart","animationend","animationiteration","animationcancel","transitionstart","transitionend","transitionrun","transitioncancel","scroll","resize","load","unload","beforeunload","cut","copy","paste","compositionstart","compositionupdate","compositionend"]);function Gj(j=l){if(B3.test(j))return j;return`CustomEvent<${j}>`}function P3(j){return E3.has(j)}function m1(j){switch(j.type){case"dispatched":return Gj(j.detail);case"forwarded":{let $=j.element,Q=!($&&L3.test($))||P3(j.name),Y=j.detail!==void 0&&j.detail!=="undefined"&&!(j.detail==="null"&&Q),K=j.detail==="null"&&!Q;if(Y||K)return Gj(j.detail);else if(Q)return`${C3()}["${j.name}"]`;else return Gj()}default:return j}}function v3(j){if(j.events.length===0)return X3;let $=j.events.map((Z)=>{let Q="",Y=q0(Z.description,Z.tags,Z.deprecated);if(Y)Q=`${Y}
111
+ `;return`${Q}${G0(Z.name)}: ${m1(Z)};
112
+ `}).join("");return j.events.length===1?`{${$}}`:`{
113
+ ${$}}`}function f3(j,$){return j.events.map((Z)=>{let Q=`on${Z.name}`;if($.has(Q))return;let Y="",K=q0(Z.description,Z.tags,Z.deprecated);if(K)Y=`${K}
114
+ `;return`
115
+ ${Y}${G0(Q)}?: (event: ${m1(Z)}) => void;`}).filter((Z)=>Z!==void 0)}function h3(j){let $=j.type==="() => any";if(j.type&&E1.test(j.type)&&!$)return j.type;else if(j.params&&j.params.length>0){let Q=j.params.map((K)=>{let z=K.optional?"?":"";return`${K.name}${z}: ${K.type}`}).join(", "),Y=j.returnType||l;return`(${Q}) => ${Y}`}else if(j.returnType)return`() => ${j.returnType}`;else return j.type||l}function c1(j){return j.props.filter(($)=>$.isFunctionDeclaration||$.kind==="const").map(($)=>{let Z=Oj($.description,$.deprecated,$.tags),Q=h3($);return`
116
+ ${Bj(Z)}
117
+ ${$.name}: ${Q};`}).join(`
118
+ `)}function u3(j){let $=`${j.moduleName}Exports`,Z=c1({props:j.props});if(Z.trim()==="")return{exports_name:$,exports_ref:$,exports_def:`export type ${$} = ${Wj};`};let{declSuffix:Q,refSuffix:Y}=x3(j.generics,Z);return{exports_name:$,exports_ref:`${$}${Y}`,exports_def:`export type ${$}${Q} = {${Z}
119
+ };`}}function m3(j){let $=j.props.filter((Z)=>Z.bindable===!0||Z.binding==="writable").map((Z)=>`"${Z.name}"`);return $.length===0?E:$.join(" | ")}function c3(j){let $=j.moduleName==="default"?"$$Component":j.moduleName,Z=j.bindings===E?'""':j.bindings;return`declare const ${$}: Component<
120
+ ${j.propsRef},
121
+ ${j.exportsRef},
122
+ ${Z}
123
+ >;
124
+ export default ${$};`}function d3(j){let $=j.moduleName==="default"?"$$Component":j.moduleName,Z=`${$}Component`,Q=j.bindings===E?'""':j.bindings;return`interface ${Z} {
125
+ new ${j.generic}(
126
+ options: ComponentConstructorOptions<${j.propsRef}>
127
+ ): SvelteComponent<${j.propsRef}> & ${j.exportsRef};
128
+ ${j.generic}(
129
+ this: void,
130
+ internals: ComponentInternals,
131
+ props: ${j.propsRef}
132
+ ): {
133
+ $on?(type: string, callback: (e: any) => void): () => void;
134
+ $set?(props: Partial<${j.propsRef}>): void;
135
+ } & ${j.exportsRef};
136
+ element?: typeof HTMLElement;
137
+ z_$$bindings?: ${Q};
138
+ }
139
+ declare const ${$}: ${Z};
140
+ export default ${$};`}function l3(j){if(j.extends===void 0)return"";return`import type { ${j.extends.interface} } from ${j.extends.import};`}function i3(j){if(!j.componentComment)return"";if(!I3.test(j.componentComment))return y0(j.componentComment.trim());return`/*${j.componentComment.split(`
141
+ `).map(($)=>`* ${$}`).join(`
142
+ `)}
143
+ */`}function p3(j){return j.moduleExports.map(($)=>{let Z=Oj($.description,$.deprecated,$.tags),Q,Y=$.type&&E1.test($.type),K=$.type==="() => any";if($.kind==="const"&&!Y)Q=`export declare const ${$.name}: ${$.type||l};
144
+ `;else if($.params&&$.params.length>0){let J=$.params.map((U)=>{let V=U.optional?"?":"";return`${U.name}${V}: ${U.type}`}).join(", "),H=$.returnType||l;Q=`export declare function ${$.name}(${J}): ${H};`}else if($.returnType)Q=`export declare function ${$.name}(): ${$.returnType};`;else if(Y&&$.type&&!K){let[z,J,...H]=$.type.split("=>"),U=H.map((V)=>` => ${V.trim()}`).join("");Q=`export declare function ${$.name}${z.trimEnd()}: ${J.trim()}${U};`}else if(Y&&$.type){let[z,J,...H]=$.type.split("=>"),U=H.map((V)=>` => ${V.trim()}`).join("");Q=`export declare function ${$.name}${z.trimEnd()}: ${J.trim()}${U};`}else if($.kind==="const")Q=`export declare const ${$.name}: ${$.type||l};
145
+ `;else Q=`export type ${$.name} = ${$.type||l};`;return`
146
+ ${Bj(Z)}
147
+ ${Q}`}).join(`
148
+ `)}var s3=120;function r3(j){let Z=`export default class ${j.moduleName==="default"?"":j.moduleName}${j.generic} extends SvelteComponentTyped<`,Q=[j.genericProps,j.events,j.slots];if(j.accessors.trim()===""&&Q.every((Y)=>!Y.includes(`
149
+ `))){let Y=`${Z}${Q.join(", ")}> {}`;if(Y.length<=s3)return Y}return`${Z}
150
+ ${j.genericProps},
151
+ ${j.events},
152
+ ${j.slots}
153
+ > {
154
+ ${j.accessors}
155
+ }`}function Lj(j,$){let Z=U0(j),{moduleName:Q,typedefs:Y,generics:K,props:z,moduleExports:J,slots:H,events:U,rest_props:V,extends:G,componentComment:W,contexts:X,syntaxMode:B}=j,q=$?.format==="component",O=K!==null,{props_name:b,prop_def:k}=y3({moduleName:Q,props:z,rest_props:V,extends:G,generics:K,slots:H,canonicalPropNames:new Set(Z?.canonicalPropNames??[]),canonicalPropsType:Z?.canonicalPropsType,events:q&&B==="legacy"?U:void 0}),D=K?`<${K[1]}>`:"",R=K?`${b}<${K[0]}>`:b,A=p3({moduleExports:J}),x=E0({typedefs:Y}),y=h1({contexts:X,generics:K}),w=(Z?.typeImportStatements??[]).join(`
156
+ `),_=(Z?.localTypeDeclarations??[]).join(`
157
+
158
+ `),{exports_ref:M,exports_def:I}=q?u3({props:z,moduleName:Q,generics:K}):{exports_ref:E,exports_def:E},T=q?m3({props:z}):E,g=!D3.test(w)&&b3.test(`${k}
159
+ ${A}
160
+ ${x}
161
+ ${y}
162
+ ${_}
163
+ ${I}`),v=V?.type==="Element"&&(V.name!=="svelte:element"||V.name==="svelte:element"&&V.thisValue),Z2=V?.type==="Element"&&V.name==="svelte:element"&&!V.thisValue,Q2=[q?O?`import type { SvelteComponent, ComponentConstructorOptions, ComponentInternals${g?", Snippet":""} } from "svelte";`:`import type { Component${g?", Snippet":""} } from "svelte";`:`import { SvelteComponentTyped${g?", type Snippet":""} } from "svelte";`,v?'import type { SvelteHTMLElements } from "svelte/elements";':"",Z2?'import type { HTMLAttributes } from "svelte/elements";':"",w,l3({extends:G})].filter(Boolean).join(`
164
+ `),Y2=q?O?d3({moduleName:Q,generic:D,propsRef:R,exportsRef:M,bindings:T}):c3({moduleName:Q,propsRef:R,exportsRef:M,bindings:T}):r3({moduleName:Q,generic:D,genericProps:R,events:v3({events:U}),slots:g3({slots:H}),accessors:c1({props:z})}),K2=[A,x,_,y,k,I,[i3({componentComment:W}),Y2].filter(Boolean).join(`
165
+ `)].map((z2)=>z2.trim()).filter(Boolean).join(`
166
+
167
+ `);return C1([Q2,K2].filter(Boolean).join(`
168
+
169
+ `))}var Ij=/`/g,P0=/\s+/g,P="--",d1=`| Prop name | Required | Kind | Reactive | Binding | Type | Default value | Description |
170
+ | :- | :- | :- | :- | :- | :- | :- | :- |
171
+ `,l1=`| Slot name | Default | Props | Fallback | Description |
172
+ | :- | :- | :- | :- | :- |
173
+ `,i1=`| Event name | Type | Detail | Description |
174
+ | :- | :- | :- | :- |
175
+ `,p1=`| Name | Kind | Type | Description |
176
+ | :- | :- | :- | :- |
177
+ `,v0=/\|/g,a3=/</g,n3=/>/g,o=/\n/g;function r(j){if(j===void 0)return P;return`<code>${j.replace(v0,"&#124;")}</code>`}function W0(j){return j.replace(a3,"&lt;").replace(n3,"&gt;")}function s1(j){if(j===void 0)return P;return`<code>${j.replace(Ij,"\\`").replace(v0,"&#124;")}</code>`}function f0(j,$){if($===void 0)return j;let Z=typeof $==="string"&&$.trim().length>0?`: ${W0($).replace(o," ").replace(v0,"&#124;")}`:"";return`<s>${j}</s><br />**Deprecated**${Z}`}function h0(j){if(j===void 0||j.trim().length===0)return P;return W0(j).replace(o,"<br />")}function r1(j){if(j===void 0||j==="{}")return P;return r(C0(j).replace(o," "))}function a1(j){if(j===void 0)return P;return r(W0(j).replace(o,"<br />"))}function n1(j,$){let Z=[];if(j!==void 0&&j.trim().length>0)Z.push(W0(j));for(let{name:Q,body:Y}of $??[]){let K=Y?.trim();Z.push(K?`@${Q} ${W0(K)}`:`@${Q}`)}if(Z.length===0)return P;return Z.join(`
178
+ `).replace(v0,"&#124;").replace(o,"<br />")}function t1(j){if(j===void 0)return P;return r(j.replace(o," "))}function o1(j,$,Z){if(j.append("h1","Component Index"),j.append("h2","Components").tableOfContents(),j.append("divider"),Z&&Z.length>0)t3(j,Z);let Q=C($);for(let Y of Q.components)o3(j,Y)}function t3(j,$){j.append("h2","Exports"),j.append("raw",p1);for(let Z of $){let Q=(Z.type??Z.value)?.replace(P0," ").trim();j.append("raw",`| ${Z.name} | ${`<code>${Z.kind}</code>`} | ${r(Q)} | ${h0(Z.description)} |
179
+ `)}j.append("raw",`
180
+ `),j.append("divider")}function Rj(j,$,Z,Q){if($.length>0)Z(),j.append("raw",`
181
+ `);else j.append("p",Q??"None.")}function o3(j,$){if(j.append("h2",`\`${$.moduleName}\``),$.generics)j.append("p",`**Type parameters:** ${r(`<${$.generics[1]}>`)}`);if($.typedefs.length>0)j.append("h3","Types").append("raw",`\`\`\`ts
182
+ ${E0({typedefs:$.typedefs})}
183
+ \`\`\`
184
+
185
+ `);j.append("h3","Props"),Rj(j,$.props,()=>{j.append("raw",d1);let Z=[...$.props].sort((Q)=>{if(Q.reactive)return-1;if(Q.constant)return 1;return 0});for(let Q of Z)j.append("raw",`| ${f0(Q.name,Q.deprecated)} | ${Q.isRequired?"Yes":"No"} | ${`<code>${Q.kind}</code>`} | ${Q.reactive?"Yes":"No"} | ${Q.binding??"--"} | ${r(Q.type)} | ${s1(Q.value)} | ${h0(Q.description)} |
186
+ `)}),j.append("h3","Slots"),Rj(j,$.slots,()=>{j.append("raw",l1);for(let Z of $.slots)j.append("raw",`| ${f0(Z.default?P:Z.name??P,Z.deprecated)} | ${Z.default?"Yes":"No"} | ${r1(Z.slot_props)} | ${a1(Z.fallback)} | ${n1(Z.description,Z.tags)} |
187
+ `)}),j.append("h3","Events"),Rj(j,$.events,()=>{j.append("raw",i1);for(let Z of $.events)j.append("raw",`| ${f0(Z.name,Z.deprecated)} | ${Z.type} | ${Z.type==="dispatched"?t1(Z.detail):P} | ${h0(Z.description)} |
188
+ `)})}class Mj{sourceParts=[];hasToC=!1;toc=[];get source(){return this.sourceParts.join("")}appendLineBreaks(){return this.sourceParts.push(`
189
+
190
+ `),this}append(j,$){switch(j){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":{let Z=Number(j.slice(-1));if(this.sourceParts.push(`${"#".repeat(Z)} ${$}`),this.hasToC&&j==="h2")this.toc.push({indent:0,raw:$??""});break}case"quote":this.sourceParts.push(`> ${$}`);break;case"p":this.sourceParts.push($??"");break;case"divider":this.sourceParts.push("---");break;case"raw":this.sourceParts.push($??"");break}if(j!=="raw")this.appendLineBreaks();return this}tableOfContents(){return this.sourceParts.push("<!-- __TOC__ -->"),this.hasToC=!0,this.appendLineBreaks(),this}end(){return this.sourceParts.join("").replace("<!-- __TOC__ -->",this.toc.map(({indent:$,raw:Z})=>{return`${" ".repeat($)}- [${Z}](#${Z.toLowerCase().replace(Ij,"").replace(P0,"-")})`}).join(`
191
+ `))}}class u0 extends F{onAppend;markdownBase;constructor(j){super();this.onAppend=j.onAppend,this.markdownBase=new Mj}get source(){return this.markdownBase.source}get hasToC(){return this.markdownBase.hasToC}get toc(){return this.markdownBase.toc}appendLineBreaks(){return this.markdownBase.appendLineBreaks(),this}append(j,$){return this.markdownBase.append(j,$),this.onAppend?.call(this,j,this),this}tableOfContents(){return this.markdownBase.tableOfContents(),this}end(){return this.markdownBase.end()}}function bj(j,$){let Z=new u0({onAppend:(Q,Y)=>{$.onAppend?.call(null,Q,Y,j)}});return o1(Z,j,$.entryExports),Z.end()}async function Dj(j,$){let Z=$?.write!==!1,Q=bj(j,$);if(Z){let Y=e3(process.cwd(),$.outFile);if(await new F({dryRun:$.dryRun}).write(Y,Q),!$.dryRun)c(`created "${$.outFile}".`)}return Q}import{join as e1}from"node:path";async function Aj(j,$){let Z=e1(process.cwd(),$.outDir,"index.d.ts"),Q=new F({dryRun:$.dryRun}),Y=$.preamble+w1($.exports),K=C(j),z=$.format??"class",J=K.components.map(async(H)=>{let U=_1(e1($.outDir,H.filePath)),V=$.resolvedPathByFilePath?.get(H.filePath),G=V?$.cache?.getGeneratedText(V,z):void 0;if(G===void 0){if(G=Lj(H,{format:$.format}),V)$.cache?.setGeneratedText(V,z,G)}await Q.write(U,G)});if(await Promise.all([...J,Q.write(Z,`${Y}
192
+ `)]),!$.dryRun)c("created TypeScript definitions.")}j0({name:"json",componentSet:"exported",write:qj});j0({name:"markdown",componentSet:"exported",write:Dj});j0({name:"types",componentSet:"all",write:Aj});j0({name:"custom-elements",componentSet:"exported",write:Jj});var j4=50;function $4(j){let $=j?.watch===!0,Z,Q,Y=null,K,z=new Set,J=async()=>{if(Y==null||Q==null||z.size===0)return;let U=Array.from(z);z.clear();try{let{result:V}=await Y.update(U);await X0(V,j||{},Q)}catch(V){console.error("sveld: failed to regenerate types in watch mode:",V)}},H=(U)=>{if(!$||Y==null||!f.test(U))return;z.add(U),clearTimeout(K),K=setTimeout(J,j4)};return{name:"vite-plugin-sveld",apply:$?void 0:"build",enforce:"post",async buildStart(){if(Q=F0(j?.entry),$&&Q!=null)Y=await b1(Q,j?.glob===!0,j?.documentExports===!0),await X0(Y.result,j||{},Q)},async generateBundle(){if($)return;if(Q!=null)Z=await V0(Q,j?.glob===!0,H0(j))},async writeBundle(){if($)return;if(Q!=null)await X0(Z,j||{},Q),Z.cache?.save()},handleHotUpdate(U){H(U.file)},watchChange(U){H(U)}}}function m0(j,$,Z){let Q=i0(j);if(!Q)throw Error(`sveld: built-in writer "${j}" is not registered.`);return Q.write($,Z)}async function X0(j,$,Z){let Q=j2(Z),Y=$?.dryRun===!0;if($?.types!==!1)await m0("types",j.allComponentsForTypes,{outDir:"types",preamble:"",...$?.typesOptions,exports:j.exports,inputDir:Q,dryRun:Y,cache:j.cache,resolvedPathByFilePath:j.resolvedPathByFilePath});if($?.json)await m0("json",j.components,{outFile:"COMPONENT_API.json",...$?.jsonOptions,input:Z,inputDir:Q,entryExports:j.entryExports,dryRun:Y});if($?.markdown)await m0("markdown",j.components,{outFile:"COMPONENT_INDEX.md",...$?.markdownOptions,entryExports:j.entryExports,dryRun:Y});if($?.customElements)await m0("custom-elements",j.components,{outFile:"custom-elements.json",...$?.customElementsOptions,inputDir:Q,dryRun:Y});let K=Object.entries($?.additionalWriters??{}).map(([z,J])=>{let H=i0(z);if(!H){console.warn(`sveld: no writer registered with name "${z}"; skipping.`);return}let U=H.componentSet==="all"?j.allComponentsForTypes:j.components;return H.write(U,J)});await Promise.all(K)}async function $2(j,$,Z){let Q=j2(Z);if($?.json){let Y={...$?.jsonOptions,inputDir:Q,entryExports:j.entryExports},K=$.stdout==="ndjson"?F1(j.components,Y):Vj(j.components,Y);process.stdout.write(K);return}if($?.markdown){let Y=bj(j.components,{...$?.markdownOptions,entryExports:j.entryExports});process.stdout.write(Y);return}if($?.customElements){let Y=zj(j.components,{...$?.customElementsOptions,inputDir:Q});process.stdout.write(Y)}}import{existsSync as Z4}from"node:fs";import{join as Q4}from"node:path";var Tj="src/index.js",N={SUCCESS:0,USAGE_ERROR:1,GENERATION_FAILURE:2,BREAKING_CHANGE:3,DIAGNOSTICS:4},Y4=`Usage: sveld [options]
193
+
194
+ Generate TypeScript definitions and component documentation for a Svelte
195
+ library. With no flags, only TypeScript definitions are generated for the
196
+ entry resolved from package.json#svelte.
197
+
198
+ --entry, --cache, --check, and --types-format accept their value as
199
+ --flag=value or as a separate --flag value argument.
200
+
201
+ Options:
202
+ --entry=<path> Entry point to uncompiled Svelte source (default: package.json "svelte" field)
203
+ --glob Analyze all *.svelte files instead of the entry barrel
204
+ --types Generate TypeScript definitions (default: true)
205
+ --json Generate component documentation in JSON format
206
+ --markdown Generate component documentation in Markdown format
207
+ --custom-elements Generate a Custom Elements Manifest (custom-elements.json)
208
+ --fail-fast Abort the run when a single component fails to parse
209
+ --dry-run Resolve, parse, and print "would write" lines for each output file instead of writing anything (including the parse cache)
210
+ --quiet Suppress progress logs (errors, the diagnostics summary, and the --check report are unaffected)
211
+ --stdout[=json|ndjson] Print the document from exactly one of --json, --markdown, or --custom-elements to stdout and write nothing to disk (rejects --types and --check); --stdout=ndjson prints one JSON object per component per line and requires --json
212
+ --cache[=<path>] Persist parsed output and skip re-parsing unchanged files (on by default, default path: node_modules/.cache/sveld/parse-cache.json; pass --cache=false to disable)
213
+ --resolve-types Expand opaque imported $props() types into JSON (alias: --resolveTypes, deprecated)
214
+ --check-examples Compile-check @example blocks against the TypeScript program (alias: --checkExamples, deprecated)
215
+ --report-diagnostics Print unresolved-type diagnostics to stderr
216
+ --strict Exit with code 1 when diagnostics exist (implies --report-diagnostics)
217
+ --types-format=<format> ".d.ts" output format: "class" (default) or "component" (Svelte 5 Component<...>)
218
+ --check[=<path>] Diff the parsed API against a committed snapshot; exit 1 on a breaking change (default path: COMPONENT_API.json)
219
+ --format=<text|json> Output format for the --check report and the diagnostics summary (default: text)
220
+ --help Print this help message and exit
221
+ --version Print the installed sveld version and exit
222
+
223
+ Exit codes:
224
+ 0 success
225
+ 1 usage or configuration error
226
+ 2 generation failure
227
+ 3 breaking API change detected by --check
228
+ 4 diagnostics present under --strict
229
+ `,wj={resolveTypes:"resolve-types",checkExamples:"check-examples"},K4=["help","version","glob","types","json","markdown","quiet","stdout","custom-elements","strict","report-diagnostics","resolve-types","check-examples","fail-fast","entry","cache","check","types-format","format"],z4=[...K4,...Object.keys(wj)],J4=new Set(["glob","types","json","markdown","quiet","custom-elements","strict","report-diagnostics","resolve-types","check-examples","fail-fast"]),U4=new Set(["entry","cache","check","types-format"]),H4=new Set(["entry","types-format"]),V4=3;function q4(j,$){let Z=j.length+1,Q=$.length+1,Y=Array.from({length:Z},()=>Array(Q).fill(0));for(let K=0;K<Z;K++)Y[K][0]=K;for(let K=0;K<Q;K++)Y[0][K]=K;for(let K=1;K<Z;K++)for(let z=1;z<Q;z++){let J=j[K-1]===$[z-1]?0:1;Y[K][z]=Math.min(Y[K-1][z]+1,Y[K][z-1]+1,Y[K-1][z-1]+J)}return Y[Z-1][Q-1]}function G4(j){let $,Z=Number.POSITIVE_INFINITY;for(let Q of z4){let Y=q4(j,Q);if(Y<Z)$=Q,Z=Y}if($===void 0||Z>V4)return;return wj[$]??$}function W4(j,$){let Z=j.indexOf("="),Q=Z===-1?j.slice(2):j.slice(2,Z),Y=wj[Q]??Q,K=Z===-1?!0:j.slice(Z+1),z=!1;if(Z===-1&&U4.has(Y)){if($!==void 0&&!$.startsWith("--"))K=$,z=!0;else if(H4.has(Y))return{result:{kind:"usage-error",message:`sveld: --${Y} requires a value (pass --${Y}=<value> or --${Y} <value>).`},consumedNext:!1,flag:Y}}return{result:X4(Y,K,j,Q),consumedNext:z,flag:Y}}function X4(j,$,Z,Q){switch(j){case"help":return{kind:"help"};case"version":return{kind:"version"};case"glob":case"types":case"json":case"markdown":case"quiet":return{kind:"option",option:{[j]:$===!0||$==="true"}};case"stdout":if($===!0||$==="true")return{kind:"option",option:{stdout:!0}};if($==="false")return{kind:"option",option:{stdout:!1}};return{kind:"option",option:{stdout:$}};case"custom-elements":return{kind:"option",option:{customElements:$===!0||$==="true"}};case"strict":return{kind:"option",option:{strict:$===!0||$==="true"}};case"report-diagnostics":return{kind:"option",option:{reportDiagnostics:$===!0||$==="true"}};case"resolve-types":return{kind:"option",option:{resolveTypes:$===!0||$==="true"}};case"check-examples":return{kind:"option",option:{checkExamples:$===!0||$==="true"}};case"fail-fast":return{kind:"option",option:{failFast:$===!0||$==="true"}};case"dry-run":return{kind:"option",option:{dryRun:$===!0||$==="true"}};case"entry":return typeof $==="string"?{kind:"option",option:{entry:$}}:{kind:"option",option:{}};case"cache":if($==="false")return{kind:"option",option:{cache:!1}};return{kind:"option",option:{cache:typeof $==="string"?$:!0}};case"check":if($==="false")return{kind:"option",option:{check:!1}};return{kind:"option",option:{check:typeof $==="string"?$:!0}};case"types-format":return typeof $==="string"?{kind:"option",option:{typesOptions:{format:$}}}:{kind:"option",option:{}};case"format":return typeof $==="string"?{kind:"option",option:{format:$}}:{kind:"option",option:{}};default:return{kind:"unknown",arg:Z,suggestion:G4(Q)}}}function k4(j){let $={},Z=!1;for(let Q=0;Q<j.length;Q++){let Y=j[Q];if(!Y.startsWith("--"))return{kind:"unknown",arg:Y,positionalHint:Z?!0:void 0};let{result:K,consumedNext:z,flag:J}=W4(Y,j[Q+1]);if(K.kind!=="option")return K;if(Object.assign($,K.option),Z=J4.has(J),z)Q++}return{kind:"options",options:$}}async function T$(j){let $=k4(j.argv.slice(2));if($.kind==="help"){console.log(Y4);return}if($.kind==="version"){console.log(_j.version);return}if($.kind==="usage-error"){console.error($.message),j.exitCode=N.USAGE_ERROR;return}if($.kind==="unknown"){let W=`Unknown flag: ${$.arg}`;if($.suggestion)W+=` Did you mean --${$.suggestion}?`;if($.positionalHint)W+=" (values are passed as --flag=value or --flag value)";console.error(W),console.error("Run sveld --help for a list of available flags."),j.exitCode=N.USAGE_ERROR;return}let Z=$.options,Q=await fj(),Y=hj(Q,Z);if(Q.typesOptions||Z.typesOptions)Y.typesOptions={...Q.typesOptions,...Z.typesOptions};if(Y.stdout){if(Y.stdout!==!0&&Y.stdout!=="json"&&Y.stdout!=="ndjson"){console.error(`sveld: --stdout must be "json" or "ndjson"; got "${Y.stdout}".`),j.exitCode=N.USAGE_ERROR;return}if([Y.json,Y.markdown,Y.customElements].filter(Boolean).length!==1){console.error("sveld: --stdout requires exactly one of --json, --markdown, or --custom-elements."),j.exitCode=N.USAGE_ERROR;return}if(Y.stdout==="ndjson"&&!Y.json){console.error("sveld: --stdout=ndjson is only valid with --json."),j.exitCode=N.USAGE_ERROR;return}if(Y.types===!0){console.error("sveld: --stdout cannot be combined with --types; type definitions span multiple files."),j.exitCode=N.USAGE_ERROR;return}if(Y.check){console.error("sveld: --stdout cannot be combined with --check; both write their document to stdout."),j.exitCode=N.USAGE_ERROR;return}}if(Y.format!==void 0&&Y.format!=="text"&&Y.format!=="json"){console.error(`sveld: --format must be "text" or "json"; got "${Y.format}".`),j.exitCode=N.USAGE_ERROR;return}A1(Y.quiet===!0);let K=F0(Y.entry),z;if(K!==null)z=K;else if(Z4(Q4(j.cwd(),Tj)))console.error(`sveld: could not resolve an entry point; falling back to "${Tj}". Set package.json#svelte (or pass --entry) to avoid relying on this fallback.`),z=$0(S(Tj));else{j.exitCode=N.USAGE_ERROR;return}let J,H;try{if(J=await V0(z,Y.glob===!0,H0(Y)),Y.check)H=await Ej(J.components,Cj(Y),{entryExports:J.entryExports});if(Y.stdout)await $2(J,Y,z);else if(await X0(J,Y,z),!Y.dryRun)J.cache?.save()}catch(W){console.error(W instanceof Error?W.message:String(W)),j.exitCode=N.GENERATION_FAILURE;return}let{diagnostics:U}=J;if((Y.reportDiagnostics||Y.strict)&&U.length>0)if(Y.format==="json")j.stderr.write(mj(U));else console.error(uj(U));if(H)if(Y.format==="json")j.stdout.write(vj(H));else console.log(Pj(H));let G;if(H?.bump==="major")G=N.BREAKING_CHANGE;if(Y.strict&&U.length>0)G=G===void 0?N.DIAGNOSTICS:Math.min(G,N.DIAGNOSTICS);if(G!==void 0)j.exitCode=G}
230
+ export{C as a,L2 as b,Cj as c,Ej as d,Pj as e,vj as f,uj as g,F0 as h,g4 as i,fj as j,hj as k,H0 as l,V0 as m,j0 as n,i0 as o,E4 as p,$4 as q,X0 as r,T$ as s};
@@ -0,0 +1 @@
1
+ import{ia as a,ja as b}from"./chunk-mab8x3d6.js";import"./chunk-tjthqdyw.js";import"./chunk-0q7qnmx3.js";export{b as parseModernAndLegacy,a as parse};
@@ -0,0 +1,6 @@
1
+ import{qa as O}from"./chunk-jvqe4bt1.js";import{wa as P}from"./chunk-0q7qnmx3.js";import{existsSync as N,readdirSync as b,statSync as I}from"node:fs";import B from"node:path";var E="__sveld_resolved_props__",_="__SveldResolvedProps__",h=/ \| undefined$/,x=/[^A-Za-z0-9_-]/g,f=/[^A-Za-z0-9_$]/g,g=/^[0-9]/,y=2;class T{api;symbolFlags;typeFlags;tsconfigPath;overlay=new Map;constructor(J,K,Q,$){this.api=J,this.symbolFlags=K,this.typeFlags=Q,this.tsconfigPath=$}static async create(J=process.cwd()){let K=n(J);if(!K)return console.warn("Warning: `resolveTypes` could not locate a tsconfig.json. Skipping semantic resolution."),null;let Q;try{Q=await import("./chunk-02g49ekt.js")}catch(q){return console.warn("Warning: `resolveTypes` requires the `typescript` package to be installed. Skipping semantic resolution.",q),null}let $=new T(null,Q.SymbolFlags,Q.TypeFlags,K),Z=new Q.API({cwd:J,fs:$.createFileSystem()});return $.api=Z,$}async expandAll(J){let K=new Map;if(J.length===0)return K;let Q=new Map;for(let Z of J){if(!Z.metadata.canonicalPropsType)continue;if(Z.metadata.referencesComponentGenerics)continue;let q=this.virtualFileName(Z.filePath,Z.moduleName);this.overlay.set(q,m(Z.metadata)),Q.set(q,Z)}if(Q.size===0)return K;let $=await this.api.updateSnapshot({openProject:this.tsconfigPath,fileChanges:{created:Array.from(Q.keys())}});try{let[Z]=Q.keys(),q=await $.getDefaultProjectForFile(Z);if(!q)return K;let W=q.checker,D=await Promise.all(Array.from(Q,async([H,C])=>{let Y=this.overlay.get(H);if(!Y)return null;let U=p(Y),M=await W.getTypeAtPosition(H,U);if(!M)return null;let X=new Map,w=await W.getPropertiesOfType(M);for(let V of w){if(!V.name||V.name.startsWith("__"))continue;X.set(V.name,{name:V.name,symbols:[V],forceOptional:!1})}if((M.flags&this.typeFlags.Union)!==0){let V=await M.getTypes(),F=await Promise.all(V.map((v)=>W.getPropertiesOfType(v)));for(let v of F)for(let k of v){if(!k.name||k.name.startsWith("__")||X.has(k.name))continue;let R=X.get(k.name);if(R)R.symbols.push(k);else X.set(k.name,{name:k.name,symbols:[k],forceOptional:!0})}}return{filePath:C.filePath,groups:Array.from(X.values())}})),j=[],A=[];D.forEach((H,C)=>{if(!H)return;H.groups.forEach((Y,U)=>{for(let M of Y.symbols)j.push(M),A.push({fileIndex:C,groupIndex:U})})});let S=j.length>0?await W.getTypeOfSymbol(j):[],G=await Promise.all(S.map((H)=>H?W.typeToString(H):Promise.resolve("any"))),L=new Map;j.forEach((H,C)=>{let{fileIndex:Y,groupIndex:U}=A[C],M=(H.flags&this.symbolFlags.Optional)!==0,X=G[C];if(M)X=X.replace(h,"");let w=L.get(Y)??new Map,z=w.get(U)??[];z.push(X),w.set(U,z),L.set(Y,w)}),D.forEach((H,C)=>{if(!H)return;let Y=L.get(C),U=H.groups.map((M,X)=>{let w=Y?.get(X)??[],z=!(M.forceOptional||M.symbols.some((V)=>(V.flags&this.symbolFlags.Optional)!==0));return{name:M.name,type:Array.from(new Set(w)).join(" | "),isRequired:z}});U.sort((M,X)=>M.name.localeCompare(X.name)),K.set(H.filePath,U)})}finally{await $.dispose?.()}return K}async checkExamples(J){let K=new Map;if(J.length===0)return K;let Q=[];for(let Z of J)for(let q of Z.sources){let W=this.exampleFileName(Z.filePath,Z.moduleName,q.id);this.overlay.set(W,u(q)),Q.push({filePath:Z.filePath,source:q,file:W})}if(Q.length===0)return K;let $=await this.api.updateSnapshot({openProject:this.tsconfigPath,fileChanges:{created:Q.map((Z)=>Z.file)}});try{let[Z]=Q,q=await $.getDefaultProjectForFile(Z.file);if(!q)return K;await Promise.all(Q.map(async({filePath:W,source:D,file:j})=>{let[A,S]=await Promise.all([q.program.getSyntacticDiagnostics(j),q.program.getSemanticDiagnostics(j)]),G=[...A,...S];if(G.length===0)return;let L=this.overlay.get(j)??"",H=G.map((Y)=>c(Y,L)).sort((Y,U)=>Y.line-U.line).map((Y)=>`Line ${Y.line}: ${Y.text}`).join(`
2
+ `),C=K.get(W)??[];C.push({id:D.id,name:D.name,message:H}),K.set(W,C)}))}finally{await $.dispose?.()}return K}async dispose(){this.overlay.clear(),await this.api?.close?.()}createFileSystem(){return{readFile:(J)=>this.overlay.get(O(J)),fileExists:(J)=>this.overlay.has(O(J))?!0:void 0,getAccessibleEntries:(J)=>{let K=O(J),Q=Array.from(this.overlay.keys()).filter((q)=>O(B.dirname(q))===K);if(Q.length===0)return;let $=[],Z=[];try{for(let q of b(J)){let W=B.join(J,q);try{(I(W).isDirectory()?Z:$).push(q)}catch{}}}catch{}for(let q of Q){let W=B.basename(q);if(!$.includes(W))$.push(W)}return{files:$,directories:Z}}}}virtualFileName(J,K){let Q=B.dirname(B.resolve(J));return O(B.join(Q,`__sveld_resolved_${K}.ts`))}exampleFileName(J,K,Q){let $=B.dirname(B.resolve(J)),Z=Q.replace(x,"_");return O(B.join($,`__sveld_example_${K}_${Z}.ts`))}}function m(J){return[...J.typeImportStatements,...J.localTypeDeclarations,`type ${_} = ${J.canonicalPropsType};`,`declare const ${E}: ${_};`].join(`
3
+ `)}function d(J){let K=J.replace(f,"_");if(K===""||g.test(K))return`_${K}`;return K}function u(J){return`const ${d(J.name)} = null as unknown as (${J.type});
4
+ ${J.code}
5
+ `}function c(J,K){let Q=J.pos??0,$=K.slice(0,Q).split(`
6
+ `).length;return{line:Math.max(1,$-y+1),text:String(J.text??"").trim()}}function p(J){let K=J.lastIndexOf("declare const");return J.indexOf(E,K)+2}function n(J){let K=B.resolve(J);while(!0){let Q=B.join(K,"tsconfig.json");if(N(Q))return Q;let $=B.dirname(K);if($===K)return null;K=$}}export{T as TypeResolver};
@@ -0,0 +1 @@
1
+ import{t as d}from"./chunk-6magvxxe.js";import{D as a,E as b,F as c}from"./chunk-4ggahk6z.js";import"./chunk-mab8x3d6.js";import"./chunk-tjthqdyw.js";import"./chunk-0q7qnmx3.js";export{b as getParsedComponentTypeScriptMetadata,d as default,c as applyResolvedProps,a as PARSED_COMPONENT_TYPE_SCRIPT_METADATA};
@@ -0,0 +1,3 @@
1
+ import j,{sep as k}from"node:path";var C=/\.svelte$/;function A(b){return k==="/"?b:b.split(k).join("/")}function E(b,q){return A(j.join(q,j.normalize(b)))}function F(b){return`${JSON.stringify(b,null,2)}
2
+ `}
3
+ export{C as pa,A as qa,E as ra,F as sa};