sveld 0.39.0 → 0.40.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.
@@ -1,4 +1,4 @@
1
- import{n,V}from"./chunk-bbv5bs84.js";import{readdirSync as P,readFileSync as T,statSync as _}from"node:fs";import{createRequire as x}from"node:module";import c from"node:path";var k=/[^A-Za-z0-9_-]/g,R=/[^A-Za-z0-9_$]/g,I=/^[0-9]/,C=2,g=7,f=`TypeScript ${g} or later, which provides \`typescript/async\` (\`typescript/unstable/async\` in 7.0)`,w=["typescript/async","typescript/unstable/async"];function A(e){if(!e)return!1;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>=g}async function b(e){let t;try{let i=x(c.join(e,"package.json")).resolve("typescript/package.json");t=JSON.parse(T(i,"utf8")).version}catch{return{installed:!1}}if(!A(t))return{installed:!0,version:t};for(let s of w)try{let i=await import(s);return{installed:!0,version:t,module:i}}catch{}return{installed:!0,version:t}}class d{api=null;usesFileSystemLayer=!1;tsconfigPath;overlay=new Map;constructor(e){this.tsconfigPath=e}static async create(e=process.cwd(),{importTs:t=b}={}){let s=await t(e);if(!s.installed)return{ok:!1,reason:"not-installed",message:`requires the \`typescript\` package to be installed (${f}); none was found`};if(!s.module)return{ok:!1,reason:"unsupported-version",message:`requires ${f}; found \`typescript@${s.version??"unknown"}\` installed, which does not expose that module`};let i=V(e,["tsconfig.json"]);if(!i)return{ok:!1,reason:"no-tsconfig",message:`could not locate a tsconfig.json starting from "${e}"`};let r=new d(i);return r.usesFileSystemLayer=typeof s.module.API.prototype?.createSnapshot==="function",r.api=r.usesFileSystemLayer?new s.module.API({cwd:e}):new s.module.API({cwd:e,fs:r.createFileSystem()}),{ok:!0,resolver:r}}async checkExamples(e){let t=new Map,s=[];for(let r of e)for(let a of r.sources){let o=this.exampleFileName(r.filePath,r.moduleName,a.id);this.overlay.set(o,N(a)),s.push({filePath:r.filePath,source:a,file:o})}if(s.length===0)return t;let i=this.usesFileSystemLayer?await this.api.createSnapshot({openProjects:[this.tsconfigPath],fileSystem:{kind:"layer",files:Object.fromEntries(this.overlay)}}):await this.api.updateSnapshot({openProject:this.tsconfigPath,fileChanges:{created:s.map((r)=>r.file)}});try{let r=await i.getDefaultProjectForFile(s[0].file);if(!r)return t;await Promise.all(s.map(async({filePath:a,source:o,file:p})=>{let[y,h]=await Promise.all([r.program.getSyntacticDiagnostics(p),r.program.getSemanticDiagnostics(p)]),u=[...y,...h];if(u.length===0)return;let S=this.overlay.get(p)??"",E=u.map((l)=>j(l,S)).sort((l,v)=>l.line-v.line).map((l)=>`Line ${l.line}: ${l.text}`).join(`
1
+ import{n,V}from"./chunk-w75v318p.js";import{readdirSync as P,readFileSync as T,statSync as _}from"node:fs";import{createRequire as x}from"node:module";import c from"node:path";var k=/[^A-Za-z0-9_-]/g,R=/[^A-Za-z0-9_$]/g,I=/^[0-9]/,C=2,g=7,f=`TypeScript ${g} or later, which provides \`typescript/async\` (\`typescript/unstable/async\` in 7.0)`,w=["typescript/async","typescript/unstable/async"];function A(e){if(!e)return!1;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>=g}async function b(e){let t;try{let i=x(c.join(e,"package.json")).resolve("typescript/package.json");t=JSON.parse(T(i,"utf8")).version}catch{return{installed:!1}}if(!A(t))return{installed:!0,version:t};for(let s of w)try{let i=await import(s);return{installed:!0,version:t,module:i}}catch{}return{installed:!0,version:t}}class d{api=null;usesFileSystemLayer=!1;tsconfigPath;overlay=new Map;constructor(e){this.tsconfigPath=e}static async create(e=process.cwd(),{importTs:t=b}={}){let s=await t(e);if(!s.installed)return{ok:!1,reason:"not-installed",message:`requires the \`typescript\` package to be installed (${f}); none was found`};if(!s.module)return{ok:!1,reason:"unsupported-version",message:`requires ${f}; found \`typescript@${s.version??"unknown"}\` installed, which does not expose that module`};let i=V(e,["tsconfig.json"]);if(!i)return{ok:!1,reason:"no-tsconfig",message:`could not locate a tsconfig.json starting from "${e}"`};let r=new d(i);return r.usesFileSystemLayer=typeof s.module.API.prototype?.createSnapshot==="function",r.api=r.usesFileSystemLayer?new s.module.API({cwd:e}):new s.module.API({cwd:e,fs:r.createFileSystem()}),{ok:!0,resolver:r}}async checkExamples(e){let t=new Map,s=[];for(let r of e)for(let a of r.sources){let o=this.exampleFileName(r.filePath,r.moduleName,a.id);this.overlay.set(o,N(a)),s.push({filePath:r.filePath,source:a,file:o})}if(s.length===0)return t;let i=this.usesFileSystemLayer?await this.api.createSnapshot({openProjects:[this.tsconfigPath],fileSystem:{kind:"layer",files:Object.fromEntries(this.overlay)}}):await this.api.updateSnapshot({openProject:this.tsconfigPath,fileChanges:{created:s.map((r)=>r.file)}});try{let r=await i.getDefaultProjectForFile(s[0].file);if(!r)return t;await Promise.all(s.map(async({filePath:a,source:o,file:p})=>{let[y,h]=await Promise.all([r.program.getSyntacticDiagnostics(p),r.program.getSemanticDiagnostics(p)]),u=[...y,...h];if(u.length===0)return;let S=this.overlay.get(p)??"",E=u.map((l)=>j(l,S)).sort((l,v)=>l.line-v.line).map((l)=>`Line ${l.line}: ${l.text}`).join(`
2
2
  `),m=t.get(a)??[];m.push({id:o.id,name:o.name,message:E}),t.set(a,m)}))}finally{await i.dispose?.()}return t}async dispose(){this.overlay.clear(),await this.api?.close?.()}createFileSystem(){return{readFile:(e)=>this.overlay.get(n(e)),fileExists:(e)=>this.overlay.has(n(e))?!0:void 0,getAccessibleEntries:(e)=>{let t=n(e),s=Array.from(this.overlay.keys()).filter((a)=>n(c.dirname(a))===t);if(s.length===0)return;let i=[],r=[];try{for(let a of P(e)){let o=c.join(e,a);try{(_(o).isDirectory()?r:i).push(a)}catch{}}}catch{}for(let a of s){let o=c.basename(a);if(!i.includes(o))i.push(o)}return{files:i,directories:r}}}}exampleFileName(e,t,s){let i=c.dirname(c.resolve(e)),r=s.replace(k,"_");return n(c.join(i,`__sveld_example_${t}_${r}.ts`))}}function F(e){let t=e.replace(R,"_");if(t===""||I.test(t))return`_${t}`;return t}function N(e){return`const ${F(e.name)} = null as unknown as (${e.type});
3
3
  ${e.code}
4
4
  `}function j(e,t){let s=e.pos??0,i=t.slice(0,s).split(`
@@ -1,7 +1,7 @@
1
1
  var x=Symbol("sveld.parsedComponentTypeScriptMetadata"),I=Symbol("sveld.parsedComponentPropIgnores");function fo(Z){return Z[I]}function mo(Z){return Z[x]}var Bs=Array(2048).fill(void 0);function $c(){Bs.fill(void 0)}function go(Z,ee,Le,Ot){let Bt=Ot&2047,jt=Bs[Bt];if(jt!==void 0&&jt.length===Le-ee&&Z.startsWith(jt,ee))return jt;let Gt=Z.slice(ee,Le);return Bs[Bt]=Gt,Gt}var oi="",Dn=[0],Vn=0,ri=0,jn;function te(Z){$c(),oi=Z,Dn=[0],Vn=0,ri=0,jn=void 0}function js(Z){while(Vn<=Z){let ee=oi.indexOf(`
2
2
  `,Vn);if(ee===-1){Vn=Number.POSITIVE_INFINITY;return}Vn=ee+1,Dn.push(Vn)}}function yo(Z){let ee=[0],Le=Z.indexOf(`
3
3
  `);while(Le!==-1)ee.push(Le+1),Le=Z.indexOf(`
4
- `,Le+1);return ee}function qi(Z,ee,Le){let Ot=0,Bt=Z.length-1;if(ee>=Z[Le])Ot=Le;else Bt=Le-1;if(Ot<Bt&&ee<Z[Ot+1])Bt=Ot;while(Ot<Bt){let jt=Ot+Bt+1>>>1;if(Z[jt]<=ee)Ot=jt;else Bt=jt-1}return Ot}function y(Z){return js(Z),ri=qi(Dn,Z,ri),{line:ri+1,column:Z-Dn[ri],character:Z}}var Fs=/\r\n?|\n|\u2028|\u2029/g,Nc=/[\r\u2028\u2029]/;function xo(Z){if(jn===void 0){jn=Nc.test(oi)?[]:null,Fs.lastIndex=0;while(jn!==null&&Fs.exec(oi)!==null)jn.push(Fs.lastIndex)}if(jn===null)return js(Z),qi(Dn,Z,ri);let ee=0,Le=jn.length;while(ee<Le){let Ot=ee+Le>>>1;if(jn[Ot]<=Z)ee=Ot+1;else Le=Ot}return ee}function A(Z){let{line:ee,column:Le}=y(Z);return{line:ee,column:Le}}function vo(Z){while(Dn.length<=Z+1&&Vn!==Number.POSITIVE_INFINITY)js(Vn);if(Z>=Dn.length)return;let ee=Z+1<Dn.length?Dn[Z+1]-1:oi.length;return oi.slice(Dn[Z],ee)}function Ee(Z){let ee,Le=0;return(Ot)=>(ee??=yo(Z),Le=qi(ee,Ot,Le),{line:Le+1,column:Ot-ee[Le]})}function Ln(Z){return typeof Z==="object"&&Z!==null&&typeof Xn(Z).type==="string"}function Xn(Z){return Z}function W(Z,ee){let Le=Xn(Z);for(let Ot in Le){let Bt=Le[Ot];if(Array.isArray(Bt)){for(let jt=0;jt<Bt.length;jt++)if(Ln(Bt[jt]))Bt[jt]=ee(Bt[jt])}else if(Ln(Bt))Le[Ot]=ee(Bt)}}function ne(Z,...ee){if(!ee.some((Le)=>Le===Z.type))throw Error(`expected ${ee.join(" or ")}, got ${Z.type}`)}function ve(Z){let ee=[];return Jn(Z,ee),ee}function Jn(Z,ee){switch(Z.type){case"Identifier":ee.push(Z);return;case"ObjectPattern":for(let Le of Z.properties)Jn(Le.type==="RestElement"?Le.argument:Le.value,ee);return;case"ArrayPattern":for(let Le of Z.elements)if(Le!==null)Jn(Le,ee);return;case"RestElement":Jn(Z.argument,ee);return;case"AssignmentPattern":Jn(Z.left,ee);return;case"TSParameterProperty":Jn(Z.parameter,ee);return;case"TSAsExpression":case"TSNonNullExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":Jn(Z.expression,ee)}}function H(Z,ee){if(Z.type!=="Identifier")return!1;if(ee===null)return!0;switch(ee.type){case"MemberExpression":return ee.computed||Z===ee.object;case"MethodDefinition":return ee.computed;case"Property":case"PropertyDefinition":return ee.computed||Z===ee.value;case"ExportSpecifier":case"ImportSpecifier":return Z===ee.local;case"MetaProperty":case"ImportAttribute":case"ExportAllDeclaration":case"LabeledStatement":case"BreakStatement":case"ContinueStatement":return!1;case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":case"TSNonNullExpression":case"TSInstantiationExpression":case"TSExportAssignment":return Z===ee.expression;case"TSEnumMember":return Z===ee.initializer;case"TSParameterProperty":case"TSEnumDeclaration":case"TSImportEqualsDeclaration":return!0;default:return!ee.type.startsWith("TS")}}var Yn={Root:["module","instance","fragment","css"],Script:["attributes","content"],Fragment:["nodes"],Text:[],Comment:[],ExpressionTag:["expression"],HtmlTag:["expression"],ConstTag:["declaration"],DeclarationTag:["declaration"],DebugTag:["identifiers"],RenderTag:["expression"],AttachTag:["expression"],Attribute:["value"],SpreadAttribute:["expression"],AnimateDirective:["expression"],BindDirective:["expression"],ClassDirective:["expression"],LetDirective:["expression"],OnDirective:["expression"],StyleDirective:["value"],TransitionDirective:["expression"],UseDirective:["expression"],Component:["attributes","fragment"],TitleElement:["attributes","fragment"],SlotElement:["attributes","fragment"],RegularElement:["attributes","fragment"],SvelteBody:["attributes","fragment"],SvelteBoundary:["attributes","fragment"],SvelteComponent:["expression","attributes","fragment"],SvelteDocument:["attributes","fragment"],SvelteElement:["tag","attributes","fragment"],SvelteFragment:["attributes","fragment"],SvelteHead:["attributes","fragment"],SvelteOptions:["attributes","fragment"],SvelteSelf:["attributes","fragment"],SvelteWindow:["attributes","fragment"],IfBlock:["test","consequent","alternate"],EachBlock:["expression","context","key","body","fallback"],AwaitBlock:["expression","pending","value","then","error","catch"],KeyBlock:["expression","fragment"],SnippetBlock:["expression","parameters","body"],StyleSheet:["attributes","children"],Rule:["prelude","block"],Atrule:["block"],SelectorList:["children"],ComplexSelector:["children"],RelativeSelector:["combinator","selectors"],Combinator:[],TypeSelector:[],IdSelector:[],ClassSelector:[],AttributeSelector:[],PseudoElementSelector:["args"],PseudoClassSelector:["args"],Percentage:[],Nth:[],NestingSelector:[],Block:["children"],Declaration:[],Program:["body"],ExpressionStatement:["expression"],BlockStatement:["body"],StaticBlock:["body"],EmptyStatement:[],DebuggerStatement:[],WithStatement:["object","body"],ReturnStatement:["argument"],LabeledStatement:["label","body"],BreakStatement:["label"],ContinueStatement:["label"],IfStatement:["test","consequent","alternate"],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],CatchClause:["param","body"],WhileStatement:["test","body"],DoWhileStatement:["body","test"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","typeParameters","params","returnType","body"],FunctionExpression:["id","typeParameters","params","returnType","body"],ArrowFunctionExpression:["typeParameters","params","returnType","body"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],ClassDeclaration:["decorators","id","typeParameters","superClass","superTypeParameters","implements","body"],ClassExpression:["decorators","id","typeParameters","superClass","superTypeParameters","implements","body"],ClassBody:["body"],MethodDefinition:["decorators","key","typeParameters","value"],PropertyDefinition:["decorators","key","typeAnnotation","value"],Property:["decorators","key","value"],ThisExpression:[],Super:[],Literal:[],Identifier:["decorators","typeAnnotation"],PrivateIdentifier:[],ArrayExpression:["elements"],ObjectExpression:["properties"],UnaryExpression:["argument"],UpdateExpression:["argument"],BinaryExpression:["left","right"],LogicalExpression:["left","right"],AssignmentExpression:["left","right"],MemberExpression:["object","property"],ConditionalExpression:["test","consequent","alternate"],CallExpression:["callee","typeArguments","arguments"],NewExpression:["callee","typeArguments","arguments"],SequenceExpression:["expressions"],TemplateLiteral:["quasis","expressions"],TaggedTemplateExpression:["tag","typeArguments","quasi"],TemplateElement:[],SpreadElement:["argument"],RestElement:["decorators","argument","typeAnnotation"],YieldExpression:["argument"],AwaitExpression:["argument"],ImportExpression:["source","options","arguments"],ChainExpression:["expression"],ParenthesizedExpression:["expression"],MetaProperty:["meta","property"],ObjectPattern:["decorators","properties","typeAnnotation"],ArrayPattern:["decorators","elements","typeAnnotation"],AssignmentPattern:["decorators","left","right"],ImportDeclaration:["specifiers","source","attributes"],ImportSpecifier:["imported","local"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportAttribute:["key","value"],ExportNamedDeclaration:["declaration","specifiers","source","attributes"],ExportSpecifier:["local","exported"],ExportDefaultDeclaration:["declaration"],ExportAllDeclaration:["exported","source","attributes"],Decorator:["expression"],TSTypeAnnotation:["typeAnnotation"],TSTypeParameterDeclaration:["params"],TSTypeParameterInstantiation:["params"],TSTypeParameter:["constraint","default"],TSAnyKeyword:[],TSBigIntKeyword:[],TSBooleanKeyword:[],TSNeverKeyword:[],TSNullKeyword:[],TSNumberKeyword:[],TSObjectKeyword:[],TSStringKeyword:[],TSSymbolKeyword:[],TSUndefinedKeyword:[],TSUnknownKeyword:[],TSVoidKeyword:[],TSThisType:[],TSArrayType:["elementType"],TSTupleType:["elementTypes"],TSNamedTupleMember:["label","elementType"],TSOptionalType:["typeAnnotation"],TSRestType:["typeAnnotation"],TSUnionType:["types"],TSIntersectionType:["types"],TSConditionalType:["checkType","extendsType","trueType","falseType"],TSInferType:["typeParameter"],TSParenthesizedType:["typeAnnotation"],TSTypeOperator:["typeAnnotation"],TSIndexedAccessType:["objectType","indexType"],TSMappedType:["typeParameter","nameType","typeAnnotation"],TSLiteralType:["literal"],TSTypeReference:["typeName","typeArguments"],TSQualifiedName:["left","right"],TSTypeQuery:["exprName","typeArguments"],TSImportType:["argument","qualifier","typeArguments"],TSTypeLiteral:["members"],TSPropertySignature:["key","typeAnnotation"],TSMethodSignature:["key","typeParameters","parameters","typeAnnotation"],TSCallSignatureDeclaration:["typeParameters","parameters","typeAnnotation"],TSConstructSignatureDeclaration:["typeParameters","parameters","typeAnnotation"],TSFunctionType:["typeParameters","parameters","typeAnnotation"],TSConstructorType:["typeParameters","parameters","typeAnnotation"],TSIndexSignature:["decorators","parameters","typeAnnotation"],TSTypePredicate:["parameterName","typeAnnotation"],TSInterfaceDeclaration:["id","typeParameters","extends","body"],TSInterfaceBody:["body"],TSExpressionWithTypeArguments:["expression","typeParameters"],TSTypeAliasDeclaration:["id","typeParameters","typeAnnotation"],TSEnumDeclaration:["id","members"],TSEnumMember:["id","initializer"],TSModuleDeclaration:["id","body"],TSModuleBlock:["body"],TSImportEqualsDeclaration:["id","moduleReference"],TSExternalModuleReference:["expression"],TSExportAssignment:["expression"],TSNamespaceExportDeclaration:["id"],TSDeclareFunction:["id","typeParameters","params","returnType"],TSDeclareMethod:["typeParameters","params","returnType"],TSParameterProperty:["parameter"],TSAsExpression:["expression","typeAnnotation"],TSSatisfiesExpression:["expression","typeAnnotation"],TSTypeAssertion:["typeAnnotation","expression"],TSNonNullExpression:["expression"],TSInstantiationExpression:["expression","typeArguments"]};var rn=[],ai={...Yn,FunctionDeclaration:["id","params","body"],FunctionExpression:["id","params","body"],ArrowFunctionExpression:["params","body"],ClassDeclaration:["decorators","id","superClass","body"],ClassExpression:["decorators","id","superClass","body"],MethodDefinition:["decorators","key","value"],PropertyDefinition:["decorators","key","value"],Identifier:["decorators"],CallExpression:["callee","arguments"],NewExpression:["callee","arguments"],TaggedTemplateExpression:["tag","quasi"],RestElement:["decorators","argument"],ObjectPattern:["decorators","properties"],ArrayPattern:["decorators","elements"],TSTypeAnnotation:rn,TSTypeParameterDeclaration:rn,TSTypeParameterInstantiation:rn,TSTypeParameter:rn,TSArrayType:rn,TSTupleType:rn,TSNamedTupleMember:rn,TSOptionalType:rn,TSRestType:rn,TSUnionType:rn,TSIntersectionType:rn,TSConditionalType:rn,TSInferType:rn,TSParenthesizedType:rn,TSTypeOperator:rn,TSIndexedAccessType:rn,TSMappedType:rn,TSLiteralType:rn,TSTypeReference:rn,TSTypeQuery:rn,TSImportType:rn,TSTypeLiteral:rn,TSPropertySignature:rn,TSMethodSignature:rn,TSCallSignatureDeclaration:rn,TSConstructSignatureDeclaration:rn,TSFunctionType:rn,TSConstructorType:rn,TSIndexSignature:rn,TSTypePredicate:rn,TSInterfaceDeclaration:rn,TSInterfaceBody:rn,TSExpressionWithTypeArguments:rn,TSTypeAliasDeclaration:rn,TSNamespaceExportDeclaration:rn,TSDeclareFunction:["id"],TSDeclareMethod:rn,TSAsExpression:["expression"],TSSatisfiesExpression:["expression"],TSTypeAssertion:["expression"],TSInstantiationExpression:["expression"]},Dc=Object.assign(Object.create(null),Yn),Rc=Object.assign(Object.create(null),ai),Eo=[],E=Symbol("sveast.walk.stop"),p=Symbol("sveast.walk.skip");function o(Z,ee,Le){zi(Z,null,null,null,ee,Ic(Le))}function Ic(Z){if(Z===void 0||Z===Yn)return Lc;if(Z===ai)return Mc;return(ee)=>Oc(Z,ee.type)}function Oc(Z,ee){return Object.hasOwn(Z,ee)?Z[ee]:void 0}var bm=Object.freeze([]);function zi(Z,ee,Le,Ot,Bt,jt){let Gt=jt(Z);if(Gt===void 0)throw Error(`unknown node type: ${Z.type}`);let Lt=Bt.enter?.(Z,ee,Le,Ot);if(Lt===E)return!0;if(Lt!==p){if(Lt!==Z&&Ln(Lt))return Fc(Lt,ee,Le,Ot,Bt,jt);let Vt=Xn(Z);for(let Wt=0;Wt<Gt.length;Wt++){let Ut=Gt[Wt],Ht=Vt[Ut];if(Array.isArray(Ht))for(let qt=0;qt<Ht.length;qt++){let zt=Ht[qt];if(Ln(zt)&&zi(zt,Z,Ut,qt,Bt,jt))return!0}else if(Ln(Ht)&&zi(Ht,Z,Ut,null,Bt,jt))return!0}}return Bt.leave?.(Z,ee,Le,Ot)===E}function Lc(Z){let ee=Z.type;if(ee==="Identifier")return Z.typeAnnotation===void 0&&Z.decorators===void 0?Eo:Yn.Identifier;if(ee==="Literal")return Yn.Literal;if(ee==="Text")return Yn.Text;return Dc[ee]}function Mc(Z){let ee=Z.type;if(ee==="Identifier")return Z.decorators===void 0?Eo:ai.Identifier;if(ee==="Literal")return ai.Literal;if(ee==="Text")return ai.Text;return Rc[ee]}function Fc(Z,ee,Le,Ot,Bt,jt){if(ee===null||Le===null)throw Error("walk can't replace the node it was called with");let Gt=Xn(ee),Lt=Gt[Le];if(Ot===null)Gt[Le]=Z;else if(Array.isArray(Lt))Lt[Ot]=Z;return zi(Z,ee,Le,Ot,Bt,jt)}function r(Z){return typeof Z==="object"&&Z!==null}function S(Z){return r(Z)&&Z.type==="Literal"}function t(Z){return r(Z)&&Z.type==="Identifier"&&typeof Z.name==="string"}function b(Z){return r(Z)&&Z.type==="MemberExpression"}function c(Z){return r(Z)&&Z.type==="ObjectExpression"&&Array.isArray(Z.properties)}function Bc(Z){return r(Z)&&Z.type==="CallExpression"}function f(Z,ee){return Bc(Z)&&t(Z.callee)&&Z.callee.name===ee}function C(Z){return Z?.type==="TSAsExpression"||Z?.type==="TSSatisfiesExpression"?C(Z.expression):Z}function Oe(Z){return Z?.type==="TSAsExpression"||Z?.type==="TSSatisfiesExpression"?Z.typeAnnotation:void 0}function jc(Z){return r(Z)&&Z.type==="NewExpression"}function Se(Z,ee){return jc(Z)&&t(Z.callee)&&Z.callee.name===ee}function T(Z){if(!r(Z))return null;if(Z.type==="Literal")return Z.value==null?null:String(Z.value);if(Z.type==="TemplateLiteral"){let ee=Z.quasis;if(ee?.length===1)return ee[0]?.value?.cooked??null}return null}function l(Z){if(t(Z))return Z.name;if(S(Z))return Z.value==null?void 0:String(Z.value);return}var Vc=new Set(["Component","SvelteComponent","SvelteSelf"]),Gc=new Set(["RegularElement","SvelteElement"]);function L(Z){return Vc.has(Z)}function D(Z){return Gc.has(Z)}function Xi(Z,ee,Le=0,Ot=Z.length,Bt=0){let jt=Bt;for(let Gt=Le;Gt<Ot;Gt++){let Lt=Z.charCodeAt(Gt);if(Lt===34||Lt===39||Lt===96){Gt=Wc(Z,Gt,Ot);continue}if(Lt===123||Lt===40||Lt===91||Lt===60)jt++;else if(Lt===125||Lt===41||Lt===93||Lt===62&&Z.charCodeAt(Gt-1)!==61){if(jt>0)jt--}if(ee?.(Gt,jt)===!0)break}return jt}function Wc(Z,ee,Le){let Ot=Z.charCodeAt(ee);for(let Bt=ee+1;Bt<Le;Bt++){let jt=Z.charCodeAt(Bt);if(jt===92)Bt++;else if(jt===Ot)return Bt}return Le-1}function i(Z,ee){let Le=[],Ot=0;return Xi(Z,(Bt,jt)=>{if(jt===0&&ee.includes(Z[Bt]))Le.push(Z.slice(Ot,Bt)),Ot=Bt+1;return!1}),Le.push(Z.slice(Ot)),Le}function Vs(Z,ee,Le=0){let Ot=-1;return Xi(Z,(Bt,jt)=>{if(ee(Bt,jt))Ot=Bt;return Ot!==-1},Le),Ot}function U(Z,ee){return Vs(Z,(Le,Ot)=>Ot===0&&ee.includes(Z[Le]))}function k(Z){return Vs(Z,(ee,Le)=>Le===0&&Z[ee]==="="&&Z[ee+1]===">")}function w(Z,ee){return Vs(Z,(Le,Ot)=>Ot===0,ee)}function Gs(Z){let ee=Z.trim();return ee.startsWith("[")&&w(ee,0)===ee.length-1}function re(Z){if(!Z)return;let ee=k(Z);if(ee===-1)return;return Z.slice(ee+2).trim()||void 0}var Uc=new Set(["null","undefined"]);function ie(Z){if(!Z)return!1;let ee=i(Z,"|").map((Ot)=>Ot.trim()).filter((Ot)=>Ot&&!Uc.has(Ot));if(ee.length!==1)return!1;let[Le]=ee;while(Le.startsWith("(")&&w(Le,0)===Le.length-1)Le=Le.slice(1,-1).trim();return(Le.startsWith("(")||Le.startsWith("<"))&&k(Le)!==-1}function Kc(Z){let ee="";for(let Le=0;Le<Z.length;Le++){let Ot=Z[Le];if(Ot==="*"&&Z[Le+1]==="*"){if(Le++,Z[Le+1]==="/")ee+="(?:.*/)?",Le++;else ee+=".*";continue}if(Ot==="*"){ee+="[^/]*";continue}if(Ot==="?"){ee+="[^/]";continue}ee+=".+^$()[]{}|\\".includes(Ot)?`\\${Ot}`:Ot}return ee}function So(Z,ee){return new RegExp(`^${Kc(Z)}$`).test(ee)}var Ws={"prop-unknown-type":{severity:"warning",label:"Props without inferred types"},"context-any-type":{severity:"warning",label:"Context values typed as `any`"},"slot-missing-type":{severity:"warning",label:"@slot/@snippet tags missing a {Type} annotation"},"slot-not-rendered":{severity:"warning",label:"@slot/@snippet tags for slots the component doesn't render"},"event-no-source":{severity:"warning",label:"@event tags with no dispatch or callback"},"dispatch-escapes":{severity:"warning",label:"Dispatchers passed to functions sveld can't follow"},"example-compile-error":{severity:"error",label:"@example blocks that failed to compile"},"example-syntax-error":{severity:"error",label:"@example blocks that failed to parse"},"syntax-skipped":{severity:"error",label:"Component syntax sveld skipped"},"type-syntax-error":{severity:"error",label:"JSDoc types that aren't valid TypeScript"},"rest-props-unresolved":{severity:"warning",label:"$$restProps spread only onto components"},"context-duplicate-key":{severity:"warning",label:"Duplicate setContext keys"},"context-key-unresolved":{severity:"warning",label:"setContext keys sveld couldn't resolve"},"context-value-unresolved":{severity:"warning",label:"setContext values sveld couldn't describe"},"spread-unresolved":{severity:"warning",label:"Unresolved spreads widened to Record<string, any>"},"export-unresolved":{severity:"warning",label:"Unresolved named export specifiers"},"module-export-conflict":{severity:"warning",label:"Module-script exports colliding with generated names"},"extend-props-target-missing":{severity:"error",label:"@extends/@extendProps targets that couldn't be verified"},"extend-props-duplicate":{severity:"warning",label:"Duplicate @extends/@extendProps tags"},"extend-props-override":{severity:"warning",label:"Own props overriding an @extends target's prop"},"jsdoc-unknown-tag":{severity:"warning",label:"Unknown JSDoc tags"},"typedef-duplicate":{severity:"warning",label:"Duplicate @typedef/@callback names"},"property-duplicate":{severity:"warning",label:"Duplicate @property names"},"generics-conflict":{severity:"warning",label:"Duplicate @generics/@template names"},"event-description-ambiguous":{severity:"warning",label:"Text after an @event read as the next tag's description"},"jsdoc-tag-dropped":{severity:"warning",label:"Passthrough JSDoc tags that couldn't attach"},"internal-typedef-referenced":{severity:"error",label:"Public types referencing an @internal typedef"},"cross-file-unresolved":{severity:"warning",label:"Imports a standalone parse couldn't read"},"export-ambiguous":{severity:"warning",label:"Ambiguous `export *` names left out of the entry exports"}};function a(Z){return{...Z,code:z[Z.kind],severity:Ws[Z.kind].severity}}function Co(Z,ee){if(ee)return Z;return Z.filter((Le)=>Le.kind!=="jsdoc-unknown-tag")}function bo(Z,ee){if(!ee)return[];return Z.filter((Le)=>!Le.ignored&&(ee!=="errors"||Le.severity==="error"))}function Hc(Z,ee){if(ee.code!==void 0&&ee.code!==Z.code)return!1;if(ee.name!==void 0&&ee.name!==Z.name)return!1;if(ee.component!==void 0&&!So(ee.component,Z.component))return!1;return!0}function wo(Z,ee){if(!ee||ee.length===0)return Z;return Z.map((Le)=>Le.ignored||ee.some((Ot)=>Hc(Le,Ot))?{...Le,ignored:!0}:Le)}var To=Object.keys(Ws),z=Object.fromEntries(To.map((Z)=>[Z,`sveld/${Z}`]));function ko(Z){let ee=new Set,Le=[];for(let Ot of Z){let Bt=`${Ot.component}:${Ot.kind}:${Ot.name}`;if(ee.has(Bt))continue;ee.add(Bt),Le.push(Ot)}return Le}function Ao(Z){let ee=Z.filter((Vt)=>!Vt.ignored),Le=Z.length-ee.length,Ot=Le>0?` (${Le} ignored)`:"";if(ee.length===0)return`sveld: no diagnostics${Ot}.`;let Bt=[],jt=(Vt,Wt)=>`${Vt} ${Wt}${Vt===1?"":"s"}`,Gt=ee.filter((Vt)=>Vt.severity==="error").length,Lt=`${jt(Gt,"error")}, ${jt(ee.length-Gt,"warning")}`;Bt.push(`sveld: ${jt(ee.length,"diagnostic")} (${Lt})${Ot}.`);for(let Vt of To){let Wt=ee.filter((Ht)=>Ht.kind===Vt);if(Wt.length===0)continue;Bt.push(""),Bt.push(`${Ws[Vt].label} (${Wt.length}):`);let Ut=new Map;for(let Ht of Wt){let qt=Ut.get(Ht.component)??[];qt.push(Ht),Ut.set(Ht.component,qt)}for(let[Ht,qt]of Ut){Bt.push(` ${Ht}`);for(let zt of qt){let Xt=zt.source?` (${Ht}:${zt.source.start.line}:${zt.source.start.column})`:"";Bt.push(` - ${zt.message}${Xt} [${zt.code}]`)}}}return Bt.join(`
4
+ `,Le+1);return ee}function qi(Z,ee,Le){let Ot=0,Bt=Z.length-1;if(ee>=Z[Le])Ot=Le;else Bt=Le-1;if(Ot<Bt&&ee<Z[Ot+1])Bt=Ot;while(Ot<Bt){let jt=Ot+Bt+1>>>1;if(Z[jt]<=ee)Ot=jt;else Bt=jt-1}return Ot}function y(Z){return js(Z),ri=qi(Dn,Z,ri),{line:ri+1,column:Z-Dn[ri],character:Z}}var Fs=/\r\n?|\n|\u2028|\u2029/g,Nc=/[\r\u2028\u2029]/;function xo(Z){if(jn===void 0){jn=Nc.test(oi)?[]:null,Fs.lastIndex=0;while(jn!==null&&Fs.exec(oi)!==null)jn.push(Fs.lastIndex)}if(jn===null)return js(Z),qi(Dn,Z,ri);let ee=0,Le=jn.length;while(ee<Le){let Ot=ee+Le>>>1;if(jn[Ot]<=Z)ee=Ot+1;else Le=Ot}return ee}function A(Z){let{line:ee,column:Le}=y(Z);return{line:ee,column:Le}}function vo(Z){while(Dn.length<=Z+1&&Vn!==Number.POSITIVE_INFINITY)js(Vn);if(Z>=Dn.length)return;let ee=Z+1<Dn.length?Dn[Z+1]-1:oi.length;return oi.slice(Dn[Z],ee)}function Ee(Z){let ee,Le=0;return(Ot)=>(ee??=yo(Z),Le=qi(ee,Ot,Le),{line:Le+1,column:Ot-ee[Le]})}function Ln(Z){return typeof Z==="object"&&Z!==null&&typeof Xn(Z).type==="string"}function Xn(Z){return Z}function W(Z,ee){let Le=Xn(Z);for(let Ot in Le){let Bt=Le[Ot];if(Array.isArray(Bt)){for(let jt=0;jt<Bt.length;jt++)if(Ln(Bt[jt]))Bt[jt]=ee(Bt[jt])}else if(Ln(Bt))Le[Ot]=ee(Bt)}}function ne(Z,...ee){if(!ee.some((Le)=>Le===Z.type))throw Error(`expected ${ee.join(" or ")}, got ${Z.type}`)}function ve(Z){let ee=[];return Jn(Z,ee),ee}function Jn(Z,ee){switch(Z.type){case"Identifier":ee.push(Z);return;case"ObjectPattern":for(let Le of Z.properties)Jn(Le.type==="RestElement"?Le.argument:Le.value,ee);return;case"ArrayPattern":for(let Le of Z.elements)if(Le!==null)Jn(Le,ee);return;case"RestElement":Jn(Z.argument,ee);return;case"AssignmentPattern":Jn(Z.left,ee);return;case"TSParameterProperty":Jn(Z.parameter,ee);return;case"TSAsExpression":case"TSNonNullExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":Jn(Z.expression,ee)}}function H(Z,ee){if(Z.type!=="Identifier")return!1;if(ee===null)return!0;switch(ee.type){case"MemberExpression":return ee.computed||Z===ee.object;case"MethodDefinition":return ee.computed;case"Property":case"PropertyDefinition":return ee.computed||Z===ee.value;case"ExportSpecifier":case"ImportSpecifier":return Z===ee.local;case"MetaProperty":case"ImportAttribute":case"ExportAllDeclaration":case"LabeledStatement":case"BreakStatement":case"ContinueStatement":return!1;case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":case"TSNonNullExpression":case"TSInstantiationExpression":case"TSExportAssignment":return Z===ee.expression;case"TSEnumMember":return Z===ee.initializer;case"TSParameterProperty":case"TSEnumDeclaration":case"TSImportEqualsDeclaration":return!0;default:return!ee.type.startsWith("TS")}}var Yn={Root:["module","instance","fragment","css"],Script:["attributes","content"],Fragment:["nodes"],Text:[],Comment:[],ExpressionTag:["expression"],HtmlTag:["expression"],ConstTag:["declaration"],DeclarationTag:["declaration"],DebugTag:["identifiers"],RenderTag:["expression"],AttachTag:["expression"],Attribute:["value"],SpreadAttribute:["expression"],AnimateDirective:["expression"],BindDirective:["expression"],ClassDirective:["expression"],LetDirective:["expression"],OnDirective:["expression"],StyleDirective:["value"],TransitionDirective:["expression"],UseDirective:["expression"],Component:["attributes","fragment"],TitleElement:["attributes","fragment"],SlotElement:["attributes","fragment"],RegularElement:["attributes","fragment"],SvelteBody:["attributes","fragment"],SvelteBoundary:["attributes","fragment"],SvelteComponent:["expression","attributes","fragment"],SvelteDocument:["attributes","fragment"],SvelteElement:["tag","attributes","fragment"],SvelteFragment:["attributes","fragment"],SvelteHead:["attributes","fragment"],SvelteOptions:["attributes","fragment"],SvelteSelf:["attributes","fragment"],SvelteWindow:["attributes","fragment"],IfBlock:["test","consequent","alternate"],EachBlock:["expression","context","key","body","fallback"],AwaitBlock:["expression","pending","value","then","error","catch"],KeyBlock:["expression","fragment"],SnippetBlock:["expression","parameters","body"],StyleSheet:["attributes","children"],Rule:["prelude","block"],Atrule:["block"],SelectorList:["children"],ComplexSelector:["children"],RelativeSelector:["combinator","selectors"],Combinator:[],TypeSelector:[],IdSelector:[],ClassSelector:[],AttributeSelector:[],PseudoElementSelector:["args"],PseudoClassSelector:["args"],Percentage:[],Nth:[],NestingSelector:[],Block:["children"],Declaration:[],Program:["body"],ExpressionStatement:["expression"],BlockStatement:["body"],StaticBlock:["body"],EmptyStatement:[],DebuggerStatement:[],WithStatement:["object","body"],ReturnStatement:["argument"],LabeledStatement:["label","body"],BreakStatement:["label"],ContinueStatement:["label"],IfStatement:["test","consequent","alternate"],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],CatchClause:["param","body"],WhileStatement:["test","body"],DoWhileStatement:["body","test"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","typeParameters","params","returnType","body"],FunctionExpression:["id","typeParameters","params","returnType","body"],ArrowFunctionExpression:["typeParameters","params","returnType","body"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],ClassDeclaration:["decorators","id","typeParameters","superClass","superTypeParameters","implements","body"],ClassExpression:["decorators","id","typeParameters","superClass","superTypeParameters","implements","body"],ClassBody:["body"],MethodDefinition:["decorators","key","typeParameters","value"],PropertyDefinition:["decorators","key","typeAnnotation","value"],Property:["decorators","key","value"],ThisExpression:[],Super:[],Literal:[],Identifier:["decorators","typeAnnotation"],PrivateIdentifier:[],ArrayExpression:["elements"],ObjectExpression:["properties"],UnaryExpression:["argument"],UpdateExpression:["argument"],BinaryExpression:["left","right"],LogicalExpression:["left","right"],AssignmentExpression:["left","right"],MemberExpression:["object","property"],ConditionalExpression:["test","consequent","alternate"],CallExpression:["callee","typeArguments","arguments"],NewExpression:["callee","typeArguments","arguments"],SequenceExpression:["expressions"],TemplateLiteral:["quasis","expressions"],TaggedTemplateExpression:["tag","typeArguments","quasi"],TemplateElement:[],SpreadElement:["argument"],RestElement:["decorators","argument","typeAnnotation"],YieldExpression:["argument"],AwaitExpression:["argument"],ImportExpression:["source","options","arguments"],ChainExpression:["expression"],ParenthesizedExpression:["expression"],MetaProperty:["meta","property"],ObjectPattern:["decorators","properties","typeAnnotation"],ArrayPattern:["decorators","elements","typeAnnotation"],AssignmentPattern:["decorators","left","right"],ImportDeclaration:["specifiers","source","attributes"],ImportSpecifier:["imported","local"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportAttribute:["key","value"],ExportNamedDeclaration:["declaration","specifiers","source","attributes"],ExportSpecifier:["local","exported"],ExportDefaultDeclaration:["declaration"],ExportAllDeclaration:["exported","source","attributes"],Decorator:["expression"],TSTypeAnnotation:["typeAnnotation"],TSTypeParameterDeclaration:["params"],TSTypeParameterInstantiation:["params"],TSTypeParameter:["constraint","default"],TSAnyKeyword:[],TSBigIntKeyword:[],TSBooleanKeyword:[],TSNeverKeyword:[],TSNullKeyword:[],TSNumberKeyword:[],TSObjectKeyword:[],TSStringKeyword:[],TSSymbolKeyword:[],TSUndefinedKeyword:[],TSUnknownKeyword:[],TSVoidKeyword:[],TSThisType:[],TSArrayType:["elementType"],TSTupleType:["elementTypes"],TSNamedTupleMember:["label","elementType"],TSOptionalType:["typeAnnotation"],TSRestType:["typeAnnotation"],TSUnionType:["types"],TSIntersectionType:["types"],TSConditionalType:["checkType","extendsType","trueType","falseType"],TSInferType:["typeParameter"],TSParenthesizedType:["typeAnnotation"],TSTypeOperator:["typeAnnotation"],TSIndexedAccessType:["objectType","indexType"],TSMappedType:["typeParameter","nameType","typeAnnotation"],TSLiteralType:["literal"],TSTypeReference:["typeName","typeArguments"],TSQualifiedName:["left","right"],TSTypeQuery:["exprName","typeArguments"],TSImportType:["argument","qualifier","typeArguments"],TSTypeLiteral:["members"],TSPropertySignature:["key","typeAnnotation"],TSMethodSignature:["key","typeParameters","parameters","typeAnnotation"],TSCallSignatureDeclaration:["typeParameters","parameters","typeAnnotation"],TSConstructSignatureDeclaration:["typeParameters","parameters","typeAnnotation"],TSFunctionType:["typeParameters","parameters","typeAnnotation"],TSConstructorType:["typeParameters","parameters","typeAnnotation"],TSIndexSignature:["decorators","parameters","typeAnnotation"],TSTypePredicate:["parameterName","typeAnnotation"],TSInterfaceDeclaration:["id","typeParameters","extends","body"],TSInterfaceBody:["body"],TSExpressionWithTypeArguments:["expression","typeParameters"],TSTypeAliasDeclaration:["id","typeParameters","typeAnnotation"],TSEnumDeclaration:["id","members"],TSEnumMember:["id","initializer"],TSModuleDeclaration:["id","body"],TSModuleBlock:["body"],TSImportEqualsDeclaration:["id","moduleReference"],TSExternalModuleReference:["expression"],TSExportAssignment:["expression"],TSNamespaceExportDeclaration:["id"],TSDeclareFunction:["id","typeParameters","params","returnType"],TSDeclareMethod:["typeParameters","params","returnType"],TSParameterProperty:["parameter"],TSAsExpression:["expression","typeAnnotation"],TSSatisfiesExpression:["expression","typeAnnotation"],TSTypeAssertion:["typeAnnotation","expression"],TSNonNullExpression:["expression"],TSInstantiationExpression:["expression","typeArguments"]};var rn=[],ai={...Yn,FunctionDeclaration:["id","params","body"],FunctionExpression:["id","params","body"],ArrowFunctionExpression:["params","body"],ClassDeclaration:["decorators","id","superClass","body"],ClassExpression:["decorators","id","superClass","body"],MethodDefinition:["decorators","key","value"],PropertyDefinition:["decorators","key","value"],Identifier:["decorators"],CallExpression:["callee","arguments"],NewExpression:["callee","arguments"],TaggedTemplateExpression:["tag","quasi"],RestElement:["decorators","argument"],ObjectPattern:["decorators","properties"],ArrayPattern:["decorators","elements"],TSTypeAnnotation:rn,TSTypeParameterDeclaration:rn,TSTypeParameterInstantiation:rn,TSTypeParameter:rn,TSArrayType:rn,TSTupleType:rn,TSNamedTupleMember:rn,TSOptionalType:rn,TSRestType:rn,TSUnionType:rn,TSIntersectionType:rn,TSConditionalType:rn,TSInferType:rn,TSParenthesizedType:rn,TSTypeOperator:rn,TSIndexedAccessType:rn,TSMappedType:rn,TSLiteralType:rn,TSTypeReference:rn,TSTypeQuery:rn,TSImportType:rn,TSTypeLiteral:rn,TSPropertySignature:rn,TSMethodSignature:rn,TSCallSignatureDeclaration:rn,TSConstructSignatureDeclaration:rn,TSFunctionType:rn,TSConstructorType:rn,TSIndexSignature:rn,TSTypePredicate:rn,TSInterfaceDeclaration:rn,TSInterfaceBody:rn,TSExpressionWithTypeArguments:rn,TSTypeAliasDeclaration:rn,TSNamespaceExportDeclaration:rn,TSDeclareFunction:["id"],TSDeclareMethod:rn,TSAsExpression:["expression"],TSSatisfiesExpression:["expression"],TSTypeAssertion:["expression"],TSInstantiationExpression:["expression"]},Dc=Object.assign(Object.create(null),Yn),Rc=Object.assign(Object.create(null),ai),Eo=[],E=Symbol("sveast.walk.stop"),p=Symbol("sveast.walk.skip");function o(Z,ee,Le){zi(Z,null,null,null,ee,Ic(Le))}function Ic(Z){if(Z===void 0||Z===Yn)return Lc;if(Z===ai)return Mc;return(ee)=>Oc(Z,ee.type)}function Oc(Z,ee){return Object.hasOwn(Z,ee)?Z[ee]:void 0}var bm=Object.freeze([]);function zi(Z,ee,Le,Ot,Bt,jt){let Gt=jt(Z);if(Gt===void 0)throw Error(`unknown node type: ${Z.type}`);let Lt=Bt.enter?.(Z,ee,Le,Ot);if(Lt===E)return!0;if(Lt!==p){if(Lt!==Z&&Ln(Lt))return Fc(Lt,ee,Le,Ot,Bt,jt);let Vt=Xn(Z);for(let Wt=0;Wt<Gt.length;Wt++){let Ut=Gt[Wt],Ht=Vt[Ut];if(Array.isArray(Ht))for(let qt=0;qt<Ht.length;qt++){let zt=Ht[qt];if(Ln(zt)&&zi(zt,Z,Ut,qt,Bt,jt))return!0}else if(Ln(Ht)&&zi(Ht,Z,Ut,null,Bt,jt))return!0}}return Bt.leave?.(Z,ee,Le,Ot)===E}function Lc(Z){let ee=Z.type;if(ee==="Identifier")return Z.typeAnnotation===void 0&&Z.decorators===void 0?Eo:Yn.Identifier;if(ee==="Literal")return Yn.Literal;if(ee==="Text")return Yn.Text;return Dc[ee]}function Mc(Z){let ee=Z.type;if(ee==="Identifier")return Z.decorators===void 0?Eo:ai.Identifier;if(ee==="Literal")return ai.Literal;if(ee==="Text")return ai.Text;return Rc[ee]}function Fc(Z,ee,Le,Ot,Bt,jt){if(ee===null||Le===null)throw Error("walk can't replace the node it was called with");let Gt=Xn(ee),Lt=Gt[Le];if(Ot===null)Gt[Le]=Z;else if(Array.isArray(Lt))Lt[Ot]=Z;return zi(Z,ee,Le,Ot,Bt,jt)}function r(Z){return typeof Z==="object"&&Z!==null}function S(Z){return r(Z)&&Z.type==="Literal"}function t(Z){return r(Z)&&Z.type==="Identifier"&&typeof Z.name==="string"}function b(Z){return r(Z)&&Z.type==="MemberExpression"}function c(Z){return r(Z)&&Z.type==="ObjectExpression"&&Array.isArray(Z.properties)}function Bc(Z){return r(Z)&&Z.type==="CallExpression"}function f(Z,ee){return Bc(Z)&&t(Z.callee)&&Z.callee.name===ee}function C(Z){return Z?.type==="TSAsExpression"||Z?.type==="TSSatisfiesExpression"?C(Z.expression):Z}function Oe(Z){return Z?.type==="TSAsExpression"||Z?.type==="TSSatisfiesExpression"?Z.typeAnnotation:void 0}function jc(Z){return r(Z)&&Z.type==="NewExpression"}function Se(Z,ee){return jc(Z)&&t(Z.callee)&&Z.callee.name===ee}function T(Z){if(!r(Z))return null;if(Z.type==="Literal")return Z.value==null?null:String(Z.value);if(Z.type==="TemplateLiteral"){let ee=Z.quasis;if(ee?.length===1)return ee[0]?.value?.cooked??null}return null}function l(Z){if(t(Z))return Z.name;if(S(Z))return Z.value==null?void 0:String(Z.value);return}var Vc=new Set(["Component","SvelteComponent","SvelteSelf"]),Gc=new Set(["RegularElement","SvelteElement"]);function L(Z){return Vc.has(Z)}function D(Z){return Gc.has(Z)}function Xi(Z,ee,Le=0,Ot=Z.length,Bt=0){let jt=Bt;for(let Gt=Le;Gt<Ot;Gt++){let Lt=Z.charCodeAt(Gt);if(Lt===34||Lt===39||Lt===96){Gt=Wc(Z,Gt,Ot);continue}if(Lt===123||Lt===40||Lt===91||Lt===60)jt++;else if(Lt===125||Lt===41||Lt===93||Lt===62&&Z.charCodeAt(Gt-1)!==61){if(jt>0)jt--}if(ee?.(Gt,jt)===!0)break}return jt}function Wc(Z,ee,Le){let Ot=Z.charCodeAt(ee);for(let Bt=ee+1;Bt<Le;Bt++){let jt=Z.charCodeAt(Bt);if(jt===92)Bt++;else if(jt===Ot)return Bt}return Le-1}function i(Z,ee){let Le=[],Ot=0;return Xi(Z,(Bt,jt)=>{if(jt===0&&ee.includes(Z[Bt]))Le.push(Z.slice(Ot,Bt)),Ot=Bt+1;return!1}),Le.push(Z.slice(Ot)),Le}function Vs(Z,ee,Le=0){let Ot=-1;return Xi(Z,(Bt,jt)=>{if(ee(Bt,jt))Ot=Bt;return Ot!==-1},Le),Ot}function U(Z,ee){return Vs(Z,(Le,Ot)=>Ot===0&&ee.includes(Z[Le]))}function k(Z){return Vs(Z,(ee,Le)=>Le===0&&Z[ee]==="="&&Z[ee+1]===">")}function w(Z,ee){return Vs(Z,(Le,Ot)=>Ot===0,ee)}function Gs(Z){let ee=Z.trim();return ee.startsWith("[")&&w(ee,0)===ee.length-1}function re(Z){if(!Z)return;let ee=k(Z);if(ee===-1)return;return Z.slice(ee+2).trim()||void 0}var Uc=new Set(["null","undefined"]);function ie(Z){if(!Z)return!1;let ee=i(Z,"|").map((Ot)=>Ot.trim()).filter((Ot)=>Ot&&!Uc.has(Ot));if(ee.length!==1)return!1;let[Le]=ee;while(Le.startsWith("(")&&w(Le,0)===Le.length-1)Le=Le.slice(1,-1).trim();return(Le.startsWith("(")||Le.startsWith("<"))&&k(Le)!==-1}function Kc(Z){let ee="";for(let Le=0;Le<Z.length;Le++){let Ot=Z[Le];if(Ot==="*"&&Z[Le+1]==="*"){if(Le++,Z[Le+1]==="/")ee+="(?:.*/)?",Le++;else ee+=".*";continue}if(Ot==="*"){ee+="[^/]*";continue}if(Ot==="?"){ee+="[^/]";continue}ee+=".+^$()[]{}|\\".includes(Ot)?`\\${Ot}`:Ot}return ee}function So(Z,ee){return new RegExp(`^${Kc(Z)}$`).test(ee)}var Ws={"prop-unknown-type":{severity:"warning",label:"Props without inferred types"},"context-any-type":{severity:"warning",label:"Context values typed as `any`"},"bind-this-type-mismatch":{severity:"warning",label:"bind:this props declared with an element type they're never bound to"},"slot-missing-type":{severity:"warning",label:"@slot/@snippet tags missing a {Type} annotation"},"slot-not-rendered":{severity:"warning",label:"@slot/@snippet tags for slots the component doesn't render"},"event-no-source":{severity:"warning",label:"@event tags with no dispatch or callback"},"dispatch-escapes":{severity:"warning",label:"Dispatchers passed to functions sveld can't follow"},"example-compile-error":{severity:"error",label:"@example blocks that failed to compile"},"example-syntax-error":{severity:"error",label:"@example blocks that failed to parse"},"syntax-skipped":{severity:"error",label:"Component syntax sveld skipped"},"type-syntax-error":{severity:"error",label:"JSDoc types that aren't valid TypeScript"},"rest-props-unresolved":{severity:"warning",label:"$$restProps spread only onto components"},"context-duplicate-key":{severity:"warning",label:"Duplicate setContext keys"},"context-key-unresolved":{severity:"warning",label:"setContext keys sveld couldn't resolve"},"context-value-unresolved":{severity:"warning",label:"setContext values sveld couldn't describe"},"spread-unresolved":{severity:"warning",label:"Unresolved spreads widened to Record<string, any>"},"export-unresolved":{severity:"warning",label:"Unresolved named export specifiers"},"module-export-conflict":{severity:"warning",label:"Module-script exports colliding with generated names"},"extend-props-target-missing":{severity:"error",label:"@extends/@extendProps targets that couldn't be verified"},"extend-props-duplicate":{severity:"warning",label:"Duplicate @extends/@extendProps tags"},"extend-props-override":{severity:"warning",label:"Own props overriding an @extends target's prop"},"jsdoc-unknown-tag":{severity:"warning",label:"Unknown JSDoc tags"},"typedef-duplicate":{severity:"warning",label:"Duplicate @typedef/@callback names"},"property-duplicate":{severity:"warning",label:"Duplicate @property names"},"generics-conflict":{severity:"warning",label:"Duplicate @generics/@template names"},"event-description-ambiguous":{severity:"warning",label:"Text after an @event read as the next tag's description"},"jsdoc-tag-dropped":{severity:"warning",label:"Passthrough JSDoc tags that couldn't attach"},"internal-typedef-referenced":{severity:"error",label:"Public types referencing an @internal typedef"},"cross-file-unresolved":{severity:"warning",label:"Imports a standalone parse couldn't read"},"export-ambiguous":{severity:"warning",label:"Ambiguous `export *` names left out of the entry exports"}};function a(Z){return{...Z,code:z[Z.kind],severity:Ws[Z.kind].severity}}function Co(Z,ee){if(ee)return Z;return Z.filter((Le)=>Le.kind!=="jsdoc-unknown-tag")}function bo(Z,ee){if(!ee)return[];return Z.filter((Le)=>!Le.ignored&&(ee!=="errors"||Le.severity==="error"))}function Hc(Z,ee){if(ee.code!==void 0&&ee.code!==Z.code)return!1;if(ee.name!==void 0&&ee.name!==Z.name)return!1;if(ee.component!==void 0&&!So(ee.component,Z.component))return!1;return!0}function wo(Z,ee){if(!ee||ee.length===0)return Z;return Z.map((Le)=>Le.ignored||ee.some((Ot)=>Hc(Le,Ot))?{...Le,ignored:!0}:Le)}var To=Object.keys(Ws),z=Object.fromEntries(To.map((Z)=>[Z,`sveld/${Z}`]));function ko(Z){let ee=new Set,Le=[];for(let Ot of Z){let Bt=`${Ot.component}:${Ot.kind}:${Ot.name}`;if(ee.has(Bt))continue;ee.add(Bt),Le.push(Ot)}return Le}function Ao(Z){let ee=Z.filter((Vt)=>!Vt.ignored),Le=Z.length-ee.length,Ot=Le>0?` (${Le} ignored)`:"";if(ee.length===0)return`sveld: no diagnostics${Ot}.`;let Bt=[],jt=(Vt,Wt)=>`${Vt} ${Wt}${Vt===1?"":"s"}`,Gt=ee.filter((Vt)=>Vt.severity==="error").length,Lt=`${jt(Gt,"error")}, ${jt(ee.length-Gt,"warning")}`;Bt.push(`sveld: ${jt(ee.length,"diagnostic")} (${Lt})${Ot}.`);for(let Vt of To){let Wt=ee.filter((Ht)=>Ht.kind===Vt);if(Wt.length===0)continue;Bt.push(""),Bt.push(`${Ws[Vt].label} (${Wt.length}):`);let Ut=new Map;for(let Ht of Wt){let qt=Ut.get(Ht.component)??[];qt.push(Ht),Ut.set(Ht.component,qt)}for(let[Ht,qt]of Ut){Bt.push(` ${Ht}`);for(let zt of qt){let Xt=zt.source?` (${Ht}:${zt.source.start.line}:${zt.source.start.column})`:"";Bt.push(` - ${zt.message}${Xt} [${zt.code}]`)}}}return Bt.join(`
5
5
  `)}function Po(Z){return Z.replaceAll("%","%25").replaceAll("\r","%0D").replaceAll(`
6
6
  `,"%0A")}function qc(Z){return Po(Z).replaceAll(":","%3A").replaceAll(",","%2C")}function zc(Z){let Le=[["file",Z.file],["line",Z.line],["col",Z.column],["endLine",Z.endLine],["endColumn",Z.endColumn],["title",Z.title]].filter((Ot)=>Ot[1]!==void 0).map(([Ot,Bt])=>`${Ot}=${qc(String(Bt))}`).join(",");return`::${Z.severity} ${Le}::${Po(Z.message)}`}function _o(Z,ee){let Le=Z.filter((Bt)=>!Bt.ignored);return[...Le.filter((Bt)=>Bt.severity==="error"),...Le.filter((Bt)=>Bt.severity!=="error")].map(({source:Bt,...jt})=>{let Gt=Bt!==void 0&&Bt.start.line===Bt.end.line;return zc({severity:jt.severity,title:jt.code,message:jt.message,file:ee(jt.component),line:Bt?.start.line,column:Gt?Bt.start.column+1:void 0,endLine:Bt?.end.line,endColumn:Gt?Bt.end.column+1:void 0})}).join(`
7
7
  `)}var Me=1;function $o(Z){return`${JSON.stringify({kind:"diagnostics",schemaVersion:Me,diagnostics:Z},null,2)}
@@ -22,7 +22,7 @@ ${" ".repeat(Bt+2+aa(jt.slice(0,ee)).length)}^`}).join(`
22
22
  `,Le);while(Bt!==-1){if(Ot+=Z.slice(Le,Bt+1),Le=Bt+1,Z.startsWith(ee,Le))Le+=ee.length;Bt=Z.indexOf(`
23
23
  `,Le)}return Ot+Z.slice(Le)}function Kl(Z,ee,Le){let Ot=0,Bt=ee.length;while(Ot<Bt){let jt=Ot+Bt>>>1;if(ee[jt].start<Le)Ot=jt+1;else Bt=jt}if(Ot>=ee.length)return;if(dn=ee.slice(Ot).map(({type:jt,value:Gt,start:Lt,end:Vt})=>({type:jt,value:Gt,start:Lt,end:Vt})),fn=0,cr(Z,void 0,!1),fn<dn.length&&(dn[fn].start>=Z.end||Z.type==="Program")){Z.trailingComments??=[];while(fn<dn.length)Z.trailingComments.push(dn[fn++])}}var Hl=new Map([["BlockStatement","body"],["Program","body"],["ArrayExpression","elements"],["ObjectExpression","properties"]]);function pa(Z,ee){for(let Le=Z;Le<ee;Le++){let Ot=ui.charCodeAt(Le);if(Ot!==44&&Ot!==41&&Ot!==32&&Ot!==9)return!0}return!1}function cr(Z,ee,Le){while(fn<dn.length&&dn[fn].start<Z.start)Z.leadingComments??=[],Z.leadingComments.push(dn[fn++]);if(fn>=dn.length)return;let Ot=dn[fn].start;if(Ot<Z.end||!pa(Z.end,Ot)){let Bt=Xn(Z),jt=Hl.get(Z.type),Gt=jt===void 0?void 0:Bt[jt],Lt=Array.isArray(Gt)&&Gt.length===0;for(let Vt in Bt){if(fn>=dn.length)return;if(Vt==="type")continue;let Wt=Bt[Vt];if(Array.isArray(Wt)){let Ut=Vt===jt;for(let Ht=0;Ht<Wt.length;Ht++){let qt=Wt[Ht];if(Ln(qt))cr(qt,Z,Ut?Ht===Wt.length-1:Lt)}}else if(Ln(Wt))cr(Wt,Z,Lt)}if(fn>=dn.length)return}if(ee!==void 0&&Z.end===ee.end)return;if(Le)while(fn<dn.length){if(ee&&dn[fn].start>=ee.end)break;Z.trailingComments??=[],Z.trailingComments.push(dn[fn++])}else if(Z.end<=dn[fn].start&&!pa(Z.end,dn[fn].start))Z.trailingComments=[dn[fn++]]}var de=new Set("arguments await break case catch class const continue debugger default delete do else enum eval export extends false finally for function if implements import in instanceof interface let new null package private protected public return static super switch this throw true try typeof var void while with yield".split(" ")),us=!1,Ai=1,ql=2,zl=32,Xl=256,Jl=Ai|ql|Xl,Yl=2,Ql=3,Zl=4,eu=/\r\n?|\n|\u2028|\u2029/,ca=new Map;function cs(Z){if(!(Z instanceof RegExp))return Z;let ee=ca.get(Z);if(!ee){let Le=new Set(Z.source.slice(4,-2).split("|"));ee={test:(Ot)=>Le.has(Ot)},ca.set(Z,ee)}return ee}var lr=wi((Z)=>class extends Z{declareName(ee,Le,Ot){let Bt=!1;if(Le===Yl){let jt=this.currentScope();if(Bt=En(jt.lexical,ee)||En(jt.functions,ee)||En(jt.var,ee),jt.lexical.push(ee),this.inModule&&jt.flags&Ai)delete this.undefinedExports[ee]}else if(Le===Zl)this.currentScope().lexical.push(ee);else if(Le===Ql){let jt=this.currentScope();Bt=this.treatFunctionsAsVar?En(jt.lexical,ee):En(jt.lexical,ee)||En(jt.var,ee),jt.functions.push(ee)}else for(let jt=this.scopeStack.length-1;jt>=0;--jt){let Gt=this.scopeStack[jt];if(En(Gt.lexical,ee)&&!(Gt.flags&zl&&Gt.lexical[0]===ee)||!this.treatFunctionsAsVarInScope(Gt)&&En(Gt.functions,ee)){Bt=!0;break}if(Gt.var.push(ee),this.inModule&&Gt.flags&Ai)delete this.undefinedExports[ee];if(Gt.flags&Jl)break}if(Bt)this.raiseRecoverable(Ot,`Identifier '${ee}' has already been declared`)}}),ur=wi((Z)=>{let{keywordTypes:ee,tokTypes:Le}=Z.acorn,Ot=new Map("break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this const class extends export import super".split(" ").map((jt)=>[jt,ee[jt]])),Bt;return class extends Z{constructor(jt,Gt,Lt){super(jt,Gt,Lt);this.keywords=cs(this.keywords),this.reservedWords=cs(this.reservedWords),this.reservedWordsStrict=cs(this.reservedWordsStrict),this.reservedWordsStrictBind=cs(this.reservedWordsStrictBind),Bt??=this.context[0]}reset(jt,Gt,Lt){if(super.reset?.(jt,Gt,Lt),this.input=jt,this.containsEsc=!1,this.pos=Gt,Lt)this.lineStart=Gt-Lt.column,this.curLine=Lt.line;else this.lineStart=jt.lastIndexOf(`
24
24
  `,Gt-1)+1,this.curLine=this.options.locations?jt.slice(0,this.lineStart).split(eu).length:1;this.type=Le.eof,this.value=null,this.start=this.end=Gt,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=Gt;let Vt=this.context;if(Vt.length!==1||Vt[0]!==Bt)this.context=this.initialContext();if(this.exprAllowed=!0,this.strict=!0,this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels.length>0)this.labels=[];for(let Ht in this.undefinedExports){this.undefinedExports=Object.create(null);break}let Wt=this.scopeStack,Ut=Wt[0];if(Wt.length!==1||Ut.flags!==Ai||Ut.var.length>0||Ut.lexical.length>0||Ut.functions.length>0||Ut.tsTypes!==void 0||Ut.tsExportOnly!==void 0||Ut.tsEnums!==void 0)this.scopeStack=[],this.enterScope(Ai);if(this.regexpState=null,this.privateNameStack.length>0)this.privateNameStack=[];this.inTemplateElement=!1}parseParenAndDistinguishExpression(jt,Gt){let Lt=super.parseParenAndDistinguishExpression(jt,Gt);if(Lt.type==="ParenthesizedExpression")us=!0;return Lt}checkUnreserved(jt){if(de.has(jt.name))super.checkUnreserved(jt)}canInsertSemicolon(){let jt=this.type;return jt===Le.eof||jt===Le.braceR||Ti(this.input,this.lastTokEnd,this.start)}checkLocalExport(){}skipSpace(){let jt=this.input,Gt=this.options.locations,Lt=this.pos,Vt=jt.charCodeAt(Lt);for(;;)if(Vt===32||Vt===9)Vt=jt.charCodeAt(++Lt);else if(Vt===10){if(Vt=jt.charCodeAt(++Lt),Gt)this.curLine++,this.lineStart=Lt}else break;if(this.pos=Lt,Vt===47||Vt<33||Vt>=128)super.skipSpace()}readWord1(){let jt=this.input,Gt=this.pos,Lt=Gt,Vt=jt.charCodeAt(Lt),Wt=0;while(Vt>=97&&Vt<=122||Vt>=65&&Vt<=90||Vt>=48&&Vt<=57||Vt===95||Vt===36)Wt=Math.imul(Wt,31)+Vt|0,Vt=jt.charCodeAt(++Lt);if(Vt>=128||Vt===92)return super.readWord1();return this.containsEsc=!1,this.pos=Lt,go(jt,Gt,Lt,Wt)}readWord(){let jt=this.readWord1();return this.finishToken(Ot.get(jt)??Le.name,jt)}}}),ua=os(lr,ur),tu=/ \(\d+:\d+\)$/;function Pi(Z){return Z}function ha(Z){return Z instanceof SyntaxError&&"pos"in Z&&typeof Z.pos==="number"}function hr(Z,ee,Le,Ot,Bt,jt=Z.root.comments.length){let Gt=Z.root.comments;jl(ee,Gt);let Lt={onComment:Z.comments?Wl:Gl,sourceType:"module",ecmaVersion:16,locations:Z.loc,preserveParens:Ot};if(Z.lfOnly)Lt.startLocation=y(Le);let Vt=Z.isTypeScript?Z.typescript:ua;if(!Vt)ce();let Wt;try{Wt=Bt(Vt,Lt)}catch(Ut){if(!ha(Ut))throw Ut;Bl(Ut.pos,Ut.message.replace(tu,""))}if(Gt.length>jt)Kl(Pi(Wt),Gt,Le);return Wt}function fe(Z,ee,Le=0){return Pi(hr(Z,ee,0,!1,(Ot,Bt)=>{if(Le>0&&Bt.locations)Bt.startLocation=y(Le);let jt=new Ot(Bt,ee,Le).parse();return jt.start=0,jt},0))}function nu(Z,ee){if(!ee)return{line:1,column:0};let{column:Le}=y(Z);return{line:xo(Z-Le)+1,column:Le}}var iu={count:0},pr,su=(Z)=>Z.parseExpression();function ru(Z,ee,Le,Ot,Bt){let jt=pr;if(pr=void 0,jt?.ParserClass===Z&&jt.onComment===ee.onComment&&jt.locations===ee.locations&&jt.parser.reset)jt.parser.reset(Le,Ot,ee.startLocation);else jt={ParserClass:Z,onComment:ee.onComment,locations:ee.locations,parser:new Z(ee,Le,Ot)};let Gt=jt.parser;Gt.nextToken();let Lt=Bt(Gt);return Gt.input="",pr=jt,Lt}function da(Z,ee,Le,Ot){return iu.count+=1,us=!1,hr(Z,ee,Le,!0,(Bt,jt)=>(jt.startLocation??=nu(Le,jt.locations),ru(Bt,jt,ee,Le,Ot)))}function M(Z,ee,Le,Ot=!1){let Bt=Pi(da(Z,ee,Le,su)),jt=Math.max(Bt.end,Vl());return{node:us&&!Ot?dr(Bt):Bt,end:jt}}function Dt(Z,ee,Le){let Ot=Z.root.comments.length,Bt=!0,jt=da(Z,ee,Le,(Lt)=>{let Vt={shorthandAssign:-1,trailingComma:-1,parenthesizedAssign:-1,parenthesizedBind:-1,doubleProto:-1},Wt=Lt.parseMaybeConditional(void 0,Vt);if(Lt.type!==ua.acorn.tokTypes.eof)return Bt=!1,Wt;let Ut=Lt.toAssignable(Wt,!1,Vt);return Lt.checkLValPattern(Ut),Ut});if(!Bt){Z.root.comments.length=Ot;return}let Gt=Pi(jt);return us?dr(Gt):Gt}function Nt(Z,ee,Le){return Pi(hr(Z,ee,Le,!1,(Ot,Bt)=>{let jt=new Ot(Bt,ee,Le);try{return jt.nextToken(),jt.parseStatement(null,!0,Object.create(null))}catch(Gt){if(ha(Gt)&&Gt.pos===ee.length)d(ee.length);throw Gt}}))}function dr(Z){let ee=Z;while(ee.type==="ParenthesizedExpression")ee=ee.expression;return W(ee,dr),ee}var F=os(lr,pe,ur);function fa(Z,ee,Le){return te(Z),fe({isTypeScript:ee.typescript??!1,typescript:Le,loc:ee.loc??!1,comments:ee.comments??!0,root:{comments:[]}},Z)}function me(Z,ee={}){return fa(Z,ee,F)}function he(Z,ee){let Le=u(Z.name,ee.name);if(Le!==0)return Le;let Ot=u(Z.type,ee.type);if(Ot!==0)return Ot;if(Z.type==="forwarded"&&ee.type==="forwarded"){let Bt=u(Z.element,ee.element);if(Bt!==0)return Bt}return u(Z.detail??"",ee.detail??"")}function ou(Z,ee){let Le=Z.length+1,Ot=ee.length+1,Bt=Array.from({length:Le},()=>Array(Ot).fill(0));for(let jt=0;jt<Le;jt++)Bt[jt][0]=jt;for(let jt=0;jt<Ot;jt++)Bt[0][jt]=jt;for(let jt=1;jt<Le;jt++)for(let Gt=1;Gt<Ot;Gt++){let Lt=Z[jt-1]===ee[Gt-1]?0:1;if(Bt[jt][Gt]=Math.min(Bt[jt-1][Gt]+1,Bt[jt][Gt-1]+1,Bt[jt-1][Gt-1]+Lt),jt>1&&Gt>1&&Z[jt-1]===ee[Gt-2]&&Z[jt-2]===ee[Gt-1])Bt[jt][Gt]=Math.min(Bt[jt][Gt],Bt[jt-2][Gt-2]+1)}return Bt[Le-1][Ot-1]}function _(Z,ee,Le=3){let Ot,Bt=Number.POSITIVE_INFINITY;for(let jt of ee){let Gt=ou(Z,jt);if(Gt<Bt)Ot=jt,Bt=Gt}return Bt<=Le?Ot:void 0}import{readFile as cu}from"node:fs/promises";import gr from"node:path";import ma,{sep as fr}from"node:path";var Pn=/\.svelte$/,hi=[".ts",".mts",".cts",".tsx",".js",".mjs",".cjs",".jsx",".d.ts"],ga=/\.(?:svelte|[mc]?ts|[mc]?js|tsx|jsx)$/;function di(Z){if(!Z.endsWith(".svelte"))return!1;let ee=Z.length-7;if(ee===0)return!1;let Le=Z.charCodeAt(ee-1);return Le!==47&&(fr==="/"||Le!==92)}function n(Z){return fr==="/"?Z:Z.split(fr).join("/")}function ya(Z,ee){return n(ma.join(ee,ma.normalize(Z)))}function _i(Z){return`${JSON.stringify(Z,null,2)}
25
- `}var xa="sveld",hs="0.39.0";var _t={name:xa,version:hs,license:"Apache-2.0",description:"Generate TypeScript definitions and component documentation for your Svelte components.",type:"module",main:"./dist/index.js",types:"./dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",default:"./dist/index.js"},"./browser":{types:"./dist/browser.d.ts",import:"./dist/browser.js",default:"./dist/browser.js"},"./schema/component-api.schema.json":"./schema/component-api.schema.json"},scripts:{test:"bun test --parallel","test:update":"SVELD_UPDATE_FIXTURES=1 bun test tests/fixtures.test.ts","test:fixtures-types":"bun check --project tsconfig.fixtures.json","test:types-matrix":"bun scripts/typecheck-option-matrix.ts","test:svelte-versions":"bun scripts/typecheck-svelte-versions.ts","test:e2e":"bun tests/test-e2e.ts","test:inferred-types":"bun scripts/check-inferred-types.ts",format:"biome format --write .",lint:"biome check --error-on-warnings .","lint:fix":"biome check --write --unsafe .","lint:fix:changed":"biome check --write --unsafe --changed --no-errors-on-unmatched",knip:"knip-bun",build:"bun scripts/build.ts",bench:"bun scripts/bench.ts","bench:cache":"bun scripts/bench.ts --cache","bench:ostia":"ostia bench scripts/bench-ostia.ts",typecheck:"bun check && bun check --project tsconfig.excluded.json"},devDependencies:{"@biomejs/biome":"2.6.3","@types/bun":"^1.4.4","@types/jest":"^30.0.0","@typescript/typescript6":"^6.0.2",ajv:"^8.20.0",knip:"^6.43.0",ostia:"^0.2.11",sveast:"^0.9.6",svelte:"^5.57.2",typescript:"^7.0.2"},bin:{sveld:"dist/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 $i="5.57.2";var ds=1;function Wn(Z){return Z.some((ee)=>ee.internal)?Z.filter((ee)=>!ee.internal):Z}function pu(Z){return{...Z,props:Wn(Z.props),moduleExports:Wn(Z.moduleExports),slots:Wn(Z.slots),events:Wn(Z.events),typedefs:Wn(Z.typedefs),...Z.contexts?{contexts:Wn(Z.contexts).map((ee)=>({...ee,properties:Wn(ee.properties)}))}:{}}}function g(Z,ee={}){let Le=Array.from(Z.values(),(jt)=>{let{diagnostics:Gt,...Lt}=jt;return pu(Lt)}).sort((jt,Gt)=>u(jt.moduleName,Gt.moduleName)),Ot={schemaVersion:ds,generator:{name:xa,version:hs,svelteVersion:$i},total:Le.length,components:Le},Bt=ee.entryExports?Wn(ee.entryExports):void 0;if(Bt&&Bt.length>0)Ot.totalExports=Bt.length,Ot.exports=Bt;return Ot}var lu=/[:=]/,yr="COMPONENT_API.json",fs={none:0,patch:1,minor:2,major:3};function uu(Z,ee){return fs[ee]>fs[Z]?ee:Z}function hu(Z){return Z.reduce((ee,Le)=>uu(ee,Le.bump),"none")}function wa(Z,ee){return fs[Z]>=fs[ee]}function va(Z){return new Set(i(Z,"|").map((ee)=>ee.trim()).filter((ee)=>ee.length>0))}function Ea(Z){let ee=k(Z);if(ee===-1)return;let Le=Z.slice(0,ee).trim(),Ot=Z.slice(ee+2).trim();if(!Le.startsWith("(")||!Le.endsWith(")"))return;let Bt=Le.slice(1,-1).trim();return{params:Bt.length===0?[]:i(Bt,",").map((Gt)=>Gt.trim()),returnType:Ot}}function du(Z){return(Z.split(lu,1)[0]??"").trimEnd().endsWith("?")}function fu(Z,ee){if(Z.returnType!==ee.returnType)return"major";if(ee.params.length<Z.params.length)return"major";for(let Ot=0;Ot<Z.params.length;Ot++)if(Z.params[Ot]!==ee.params[Ot])return"major";if(ee.params.length===Z.params.length)return"none";return ee.params.slice(Z.params.length).every(du)?"minor":"major"}function Ni(Z,ee){if(Z===ee)return"none";if(Z===void 0||ee===void 0)return"major";let Le=Ea(Z),Ot=Ea(ee);if(Le&&Ot)return fu(Le,Ot);let Bt=va(Z),jt=va(ee),Gt=[...jt].some((Vt)=>!Bt.has(Vt));if(![...Bt].some((Vt)=>!jt.has(Vt)))return Gt?"minor":"none";return"major"}function Sa(Z){return Z.bindable===!0||Z.binding==="writable"}function fi(Z,ee,Le){let Ot=new Map(Z.map((Vt)=>[Le(Vt),Vt])),Bt=new Map(ee.map((Vt)=>[Le(Vt),Vt])),jt=[...Bt].filter(([Vt])=>!Ot.has(Vt)),Gt=[...Ot.keys()].filter((Vt)=>!Bt.has(Vt)),Lt=[];for(let[Vt,Wt]of Ot){let Ut=Bt.get(Vt);if(Ut)Lt.push([Vt,Wt,Ut])}return{added:jt,removed:Gt,common:Lt}}function xr(Z,ee,Le,Ot){return(Bt,jt,Gt)=>Z.push({component:ee,kind:Le,name:Bt,bump:jt,message:`${Ot} "${Bt}" ${Gt}`})}function Ca(Z,ee,Le,Ot){let Bt=[],jt=xr(Bt,Z,ee,ee==="prop"?"prop":"export"),{added:Gt,removed:Lt,common:Vt}=fi(Le,Ot,(Wt)=>Wt.name);for(let[Wt,Ut]of Gt)jt(Wt,Ut.isRequired?"major":"minor",`added${Ut.isRequired?" (required)":""}`);for(let Wt of Lt)jt(Wt,"major","removed");for(let[Wt,Ut,Ht]of Vt){if(Ut.isRequired!==Ht.isRequired)jt(Wt,Ht.isRequired?"major":"minor",`became ${Ht.isRequired?"required":"optional"}`);let qt=Ni(Ut.type,Ht.type);if(qt!=="none")jt(Wt,qt,`type changed from \`${Ut.type??"unknown"}\` to \`${Ht.type??"unknown"}\``);let zt=Sa(Ht);if(Sa(Ut)!==zt)jt(Wt,zt?"minor":"major",zt?"gained a writable binding":"lost its writable binding");if(Ut.value!==Ht.value&&qt==="none")jt(Wt,"patch",`default changed from \`${Ut.value??"none"}\` to \`${Ht.value??"none"}\``);let Xt=Ht.deprecated!==void 0;if(Ut.deprecated!==void 0!==Xt)jt(Wt,Xt?"minor":"patch",Xt?"marked as deprecated":"no longer deprecated");if(Ut.constant!==Ht.constant)jt(Wt,"minor",Ht.constant?"became constant":"became mutable");if(Ut.reactive!==Ht.reactive)jt(Wt,"minor",Ht.reactive?"became reactive":"stopped being reactive")}return Bt}function mu(Z,ee,Le){let Ot=[],Bt=xr(Ot,Z,"event","event"),{added:jt,removed:Gt,common:Lt}=fi(ee,Le,(Vt)=>Vt.name);for(let[Vt]of jt)Bt(Vt,"minor","added");for(let Vt of Gt)Bt(Vt,"major","removed");for(let[Vt,Wt,Ut]of Lt){if(Wt.type!==Ut.type){Bt(Vt,"major",`changed from ${Wt.type} to ${Ut.type}`);continue}let Ht=Wt.type==="dispatched"?Wt.detail:void 0,qt=Ut.type==="dispatched"?Ut.detail:void 0,zt=Ni(Ht,qt);if(zt!=="none")Bt(Vt,zt,`detail changed from \`${Ht??"unknown"}\` to \`${qt??"unknown"}\``)}return Ot}function gu(Z,ee,Le){let Ot=[],Bt=xr(Ot,Z,"slot","slot"),{added:jt,removed:Gt,common:Lt}=fi(ee,Le,(Vt)=>Vt.name??"default");for(let[Vt]of jt)Bt(Vt,"minor","added");for(let Vt of Gt)Bt(Vt,"major","removed");for(let[Vt,Wt,Ut]of Lt){let Ht=Ni(Wt.slot_props,Ut.slot_props);if(Ht!=="none")Bt(Vt,Ht,`props changed from \`${Wt.slot_props??"none"}\` to \`${Ut.slot_props??"none"}\``)}return Ot}function ba(Z){return Z.type===void 0?"an object of properties":`\`${Z.type}\``}function yu(Z,ee=[],Le=[]){let Ot=[],{added:Bt,removed:jt,common:Gt}=fi(ee,Le,(Lt)=>Lt.key);for(let[Lt]of Bt)Ot.push({component:Z,kind:"context",name:Lt,bump:"minor",message:`context "${Lt}" added`});for(let Lt of jt)Ot.push({component:Z,kind:"context",name:Lt,bump:"major",message:`context "${Lt}" removed`});for(let[Lt,Vt,Wt]of Gt){let Ut=(qt,zt,Xt)=>Ot.push({component:Z,kind:"context",name:Lt,...Xt===void 0?{}:{property:Xt},bump:qt,message:`context "${Lt}" ${Xt===void 0?"":`property "${Xt}" `}${zt}`});if(Vt.typeName!==Wt.typeName)Ut("major",`type name changed from \`${Vt.typeName}\` to \`${Wt.typeName}\``);if(Boolean(Vt.hasUnresolvedSpread)!==Boolean(Wt.hasUnresolvedSpread))Ut("major",`${Wt.hasUnresolvedSpread?"gained":"lost"} an unresolved spread`);if(Vt.type!==void 0||Wt.type!==void 0){if(Vt.type!==Wt.type){let qt=Vt.type!==void 0&&Wt.type!==void 0?Ni(Vt.type,Wt.type):"major";Ut(qt,`type changed from ${ba(Vt)} to ${ba(Wt)}`)}continue}let Ht=fi(Vt.properties,Wt.properties,(qt)=>qt.name);for(let[qt]of Ht.added)Ut("minor","added",qt);for(let qt of Ht.removed)Ut("major","removed",qt);for(let[qt,zt,Xt]of Ht.common){if(zt.optional!==Xt.optional)Ut(Xt.optional?"major":"minor",`became ${Xt.optional?"optional":"required"}`,qt);let Yt=Ni(zt.type,Xt.type);if(Yt!=="none")Ut(Yt,`type changed from \`${zt.type}\` to \`${Xt.type}\``,qt)}}return Ot}var xu=new Set(["description","source","componentCommentSource","tags"]);function ms(Z){if(Array.isArray(Z))return Z.map(ms);if(r(Z)){let ee={};for(let[Le,Ot]of Object.entries(Z)){if(xu.has(Le))continue;ee[Le]=ms(Ot)}return ee}return Z}var vu=["generics","rest_props","extends","typedefs"];function Eu(Z,ee,Le){let Ot=[];for(let Bt of vu){let jt=JSON.stringify(ms(ee[Bt])),Gt=JSON.stringify(ms(Le[Bt]));if(jt!==Gt)Ot.push({component:Z,kind:"shape",name:Bt,bump:"major",message:`"${Bt}" changed (breaking)`})}return Ot}function Su(Z,ee){let Le=ee.moduleName;return[...Ca(Le,"prop",Z.props,ee.props),...Ca(Le,"moduleExport",Z.moduleExports,ee.moduleExports),...mu(Le,Z.events,ee.events),...gu(Le,Z.slots,ee.slots),...yu(Le,Z.contexts,ee.contexts),...Eu(Le,Z,ee)]}function Rt(Z,ee){let Le=[],{added:Ot,removed:Bt,common:jt}=fi(Z.components,ee.components,(Gt)=>Gt.moduleName);for(let[Gt]of Ot)Le.push({component:Gt,kind:"component",bump:"minor",message:`component "${Gt}" added`});for(let Gt of Bt)Le.push({component:Gt,kind:"component",bump:"major",message:`component "${Gt}" removed`});for(let[,Gt,Lt]of jt)Le.push(...Su(Gt,Lt));return Le}async function Cu(Z){let ee;try{ee=await cu(gr.resolve(Z),"utf-8")}catch(Le){if(Le.code==="ENOENT")return null;throw Le}try{return JSON.parse(ee)}catch{throw Error(`sveld: could not parse "${Z}" as JSON. Is it a sveld COMPONENT_API.json snapshot?`)}}function Ta(Z){if(typeof Z.check==="string")return Z.check;return Z.jsonOptions?.outFile??yr}function ka(Z,ee){if(!Z.json||Z.stdout||Z.jsonOptions?.outDir)return!1;return gr.resolve(Z.jsonOptions?.outFile??yr)===gr.resolve(ee)}async function _e(Z,ee,Le={}){let Ot=await Cu(ee);if(Ot===null)return{snapshotExists:!1,snapshotFile:ee,changes:[],bump:"none"};if(Ot.schemaVersion!==ds)return{snapshotExists:!0,snapshotFile:ee,changes:[{component:"*",kind:"schema",bump:"none",message:`snapshot schemaVersion ${Ot.schemaVersion} differs from ${ds}; regenerate the snapshot`}],bump:"none"};let Bt=g(Z,{entryExports:Le.entryExports}),jt=Rt(Ot,Bt);return{snapshotExists:!0,snapshotFile:ee,changes:jt,bump:hu(jt)}}var bu={major:"BREAKING",minor:"additive",patch:"patch",none:"no change"};function ge(Z){if(!Z.snapshotExists){let Bt=Z.snapshotFile===yr?"`sveld --json`":`\`sveld --json\` with \`jsonOptions.outFile: "${Z.snapshotFile}"\``;return`sveld --check: no snapshot found at "${Z.snapshotFile}". Generate it with ${Bt} and commit it.`}if(Z.changes.length===0)return`sveld --check: no API changes detected against "${Z.snapshotFile}".`;let ee=Z.changes.length,Le=[`sveld --check: ${ee} API change${ee===1?"":"s"} detected against "${Z.snapshotFile}".`,`Suggested semver bump: ${Z.bump}.`],Ot=new Map;for(let Bt of Z.changes){let jt=Ot.get(Bt.component)??[];jt.push(Bt),Ot.set(Bt.component,jt)}for(let[Bt,jt]of Ot){Le.push("",` ${Bt}`);for(let Gt of jt){let Lt=Gt.kind==="schema"?"schema":bu[Gt.bump];Le.push(` [${Lt}] ${Gt.message}`)}}return Le.join(`
25
+ `}var xa="sveld",hs="0.40.0";var _t={name:xa,version:hs,license:"Apache-2.0",description:"Generate TypeScript definitions and component documentation for your Svelte components.",type:"module",main:"./dist/index.js",types:"./dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",default:"./dist/index.js"},"./browser":{types:"./dist/browser.d.ts",import:"./dist/browser.js",default:"./dist/browser.js"},"./schema/component-api.schema.json":"./schema/component-api.schema.json"},scripts:{test:"bun test --parallel","test:changed":"bivium run --suite unit","test:update":"SVELD_UPDATE_FIXTURES=1 bun test tests/fixtures.test.ts","test:fixtures-types":"bun check --project tsconfig.fixtures.json","test:types-matrix":"bun scripts/typecheck-option-matrix.ts","test:svelte-versions":"bun scripts/typecheck-svelte-versions.ts","test:e2e":"bun tests/test-e2e.ts","test:inferred-types":"bun scripts/check-inferred-types.ts",format:"biome format --write .",lint:"biome check --error-on-warnings .","lint:fix":"biome check --write --unsafe .","lint:fix:changed":"biome check --write --unsafe --changed --no-errors-on-unmatched",knip:"knip-bun",build:"bun scripts/build.ts",bench:"bun scripts/bench.ts","bench:cache":"bun scripts/bench.ts --cache","bench:ostia":"ostia bench scripts/bench-ostia.ts",typecheck:"bun check && bun check --project tsconfig.excluded.json"},devDependencies:{"@biomejs/biome":"2.6.3","@types/bun":"^1.4.4","@types/jest":"^30.0.0","@typescript/typescript6":"^6.0.2",ajv:"^8.20.0",bivium:"^0.3.1",knip:"^6.43.0",ostia:"^0.2.11",sveast:"^0.9.6",svelte:"^5.57.2",typescript:"^7.0.2"},bin:{sveld:"dist/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 $i="5.57.2";var ds=1;function Wn(Z){return Z.some((ee)=>ee.internal)?Z.filter((ee)=>!ee.internal):Z}function pu(Z){return{...Z,props:Wn(Z.props),moduleExports:Wn(Z.moduleExports),slots:Wn(Z.slots),events:Wn(Z.events),typedefs:Wn(Z.typedefs),...Z.contexts?{contexts:Wn(Z.contexts).map((ee)=>({...ee,properties:Wn(ee.properties)}))}:{}}}function g(Z,ee={}){let Le=Array.from(Z.values(),(jt)=>{let{diagnostics:Gt,...Lt}=jt;return pu(Lt)}).sort((jt,Gt)=>u(jt.moduleName,Gt.moduleName)),Ot={schemaVersion:ds,generator:{name:xa,version:hs,svelteVersion:$i},total:Le.length,components:Le},Bt=ee.entryExports?Wn(ee.entryExports):void 0;if(Bt&&Bt.length>0)Ot.totalExports=Bt.length,Ot.exports=Bt;return Ot}var lu=/[:=]/,yr="COMPONENT_API.json",fs={none:0,patch:1,minor:2,major:3};function uu(Z,ee){return fs[ee]>fs[Z]?ee:Z}function hu(Z){return Z.reduce((ee,Le)=>uu(ee,Le.bump),"none")}function wa(Z,ee){return fs[Z]>=fs[ee]}function va(Z){return new Set(i(Z,"|").map((ee)=>ee.trim()).filter((ee)=>ee.length>0))}function Ea(Z){let ee=k(Z);if(ee===-1)return;let Le=Z.slice(0,ee).trim(),Ot=Z.slice(ee+2).trim();if(!Le.startsWith("(")||!Le.endsWith(")"))return;let Bt=Le.slice(1,-1).trim();return{params:Bt.length===0?[]:i(Bt,",").map((Gt)=>Gt.trim()),returnType:Ot}}function du(Z){return(Z.split(lu,1)[0]??"").trimEnd().endsWith("?")}function fu(Z,ee){if(Z.returnType!==ee.returnType)return"major";if(ee.params.length<Z.params.length)return"major";for(let Ot=0;Ot<Z.params.length;Ot++)if(Z.params[Ot]!==ee.params[Ot])return"major";if(ee.params.length===Z.params.length)return"none";return ee.params.slice(Z.params.length).every(du)?"minor":"major"}function Ni(Z,ee){if(Z===ee)return"none";if(Z===void 0||ee===void 0)return"major";let Le=Ea(Z),Ot=Ea(ee);if(Le&&Ot)return fu(Le,Ot);let Bt=va(Z),jt=va(ee),Gt=[...jt].some((Vt)=>!Bt.has(Vt));if(![...Bt].some((Vt)=>!jt.has(Vt)))return Gt?"minor":"none";return"major"}function Sa(Z){return Z.bindable===!0||Z.binding==="writable"}function fi(Z,ee,Le){let Ot=new Map(Z.map((Vt)=>[Le(Vt),Vt])),Bt=new Map(ee.map((Vt)=>[Le(Vt),Vt])),jt=[...Bt].filter(([Vt])=>!Ot.has(Vt)),Gt=[...Ot.keys()].filter((Vt)=>!Bt.has(Vt)),Lt=[];for(let[Vt,Wt]of Ot){let Ut=Bt.get(Vt);if(Ut)Lt.push([Vt,Wt,Ut])}return{added:jt,removed:Gt,common:Lt}}function xr(Z,ee,Le,Ot){return(Bt,jt,Gt)=>Z.push({component:ee,kind:Le,name:Bt,bump:jt,message:`${Ot} "${Bt}" ${Gt}`})}function Ca(Z,ee,Le,Ot){let Bt=[],jt=xr(Bt,Z,ee,ee==="prop"?"prop":"export"),{added:Gt,removed:Lt,common:Vt}=fi(Le,Ot,(Wt)=>Wt.name);for(let[Wt,Ut]of Gt)jt(Wt,Ut.isRequired?"major":"minor",`added${Ut.isRequired?" (required)":""}`);for(let Wt of Lt)jt(Wt,"major","removed");for(let[Wt,Ut,Ht]of Vt){if(Ut.isRequired!==Ht.isRequired)jt(Wt,Ht.isRequired?"major":"minor",`became ${Ht.isRequired?"required":"optional"}`);let qt=Ni(Ut.type,Ht.type);if(qt!=="none")jt(Wt,qt,`type changed from \`${Ut.type??"unknown"}\` to \`${Ht.type??"unknown"}\``);let zt=Sa(Ht);if(Sa(Ut)!==zt)jt(Wt,zt?"minor":"major",zt?"gained a writable binding":"lost its writable binding");if(Ut.value!==Ht.value&&qt==="none")jt(Wt,"patch",`default changed from \`${Ut.value??"none"}\` to \`${Ht.value??"none"}\``);let Xt=Ht.deprecated!==void 0;if(Ut.deprecated!==void 0!==Xt)jt(Wt,Xt?"minor":"patch",Xt?"marked as deprecated":"no longer deprecated");if(Ut.constant!==Ht.constant)jt(Wt,"minor",Ht.constant?"became constant":"became mutable");if(Ut.reactive!==Ht.reactive)jt(Wt,"minor",Ht.reactive?"became reactive":"stopped being reactive")}return Bt}function mu(Z,ee,Le){let Ot=[],Bt=xr(Ot,Z,"event","event"),{added:jt,removed:Gt,common:Lt}=fi(ee,Le,(Vt)=>Vt.name);for(let[Vt]of jt)Bt(Vt,"minor","added");for(let Vt of Gt)Bt(Vt,"major","removed");for(let[Vt,Wt,Ut]of Lt){if(Wt.type!==Ut.type){Bt(Vt,"major",`changed from ${Wt.type} to ${Ut.type}`);continue}let Ht=Wt.type==="dispatched"?Wt.detail:void 0,qt=Ut.type==="dispatched"?Ut.detail:void 0,zt=Ni(Ht,qt);if(zt!=="none")Bt(Vt,zt,`detail changed from \`${Ht??"unknown"}\` to \`${qt??"unknown"}\``)}return Ot}function gu(Z,ee,Le){let Ot=[],Bt=xr(Ot,Z,"slot","slot"),{added:jt,removed:Gt,common:Lt}=fi(ee,Le,(Vt)=>Vt.name??"default");for(let[Vt]of jt)Bt(Vt,"minor","added");for(let Vt of Gt)Bt(Vt,"major","removed");for(let[Vt,Wt,Ut]of Lt){let Ht=Ni(Wt.slot_props,Ut.slot_props);if(Ht!=="none")Bt(Vt,Ht,`props changed from \`${Wt.slot_props??"none"}\` to \`${Ut.slot_props??"none"}\``)}return Ot}function ba(Z){return Z.type===void 0?"an object of properties":`\`${Z.type}\``}function yu(Z,ee=[],Le=[]){let Ot=[],{added:Bt,removed:jt,common:Gt}=fi(ee,Le,(Lt)=>Lt.key);for(let[Lt]of Bt)Ot.push({component:Z,kind:"context",name:Lt,bump:"minor",message:`context "${Lt}" added`});for(let Lt of jt)Ot.push({component:Z,kind:"context",name:Lt,bump:"major",message:`context "${Lt}" removed`});for(let[Lt,Vt,Wt]of Gt){let Ut=(qt,zt,Xt)=>Ot.push({component:Z,kind:"context",name:Lt,...Xt===void 0?{}:{property:Xt},bump:qt,message:`context "${Lt}" ${Xt===void 0?"":`property "${Xt}" `}${zt}`});if(Vt.typeName!==Wt.typeName)Ut("major",`type name changed from \`${Vt.typeName}\` to \`${Wt.typeName}\``);if(Boolean(Vt.hasUnresolvedSpread)!==Boolean(Wt.hasUnresolvedSpread))Ut("major",`${Wt.hasUnresolvedSpread?"gained":"lost"} an unresolved spread`);if(Vt.type!==void 0||Wt.type!==void 0){if(Vt.type!==Wt.type){let qt=Vt.type!==void 0&&Wt.type!==void 0?Ni(Vt.type,Wt.type):"major";Ut(qt,`type changed from ${ba(Vt)} to ${ba(Wt)}`)}continue}let Ht=fi(Vt.properties,Wt.properties,(qt)=>qt.name);for(let[qt]of Ht.added)Ut("minor","added",qt);for(let qt of Ht.removed)Ut("major","removed",qt);for(let[qt,zt,Xt]of Ht.common){if(zt.optional!==Xt.optional)Ut(Xt.optional?"major":"minor",`became ${Xt.optional?"optional":"required"}`,qt);let Yt=Ni(zt.type,Xt.type);if(Yt!=="none")Ut(Yt,`type changed from \`${zt.type}\` to \`${Xt.type}\``,qt)}}return Ot}var xu=new Set(["description","source","componentCommentSource","tags"]);function ms(Z){if(Array.isArray(Z))return Z.map(ms);if(r(Z)){let ee={};for(let[Le,Ot]of Object.entries(Z)){if(xu.has(Le))continue;ee[Le]=ms(Ot)}return ee}return Z}var vu=["generics","rest_props","extends","typedefs"];function Eu(Z,ee,Le){let Ot=[];for(let Bt of vu){let jt=JSON.stringify(ms(ee[Bt])),Gt=JSON.stringify(ms(Le[Bt]));if(jt!==Gt)Ot.push({component:Z,kind:"shape",name:Bt,bump:"major",message:`"${Bt}" changed (breaking)`})}return Ot}function Su(Z,ee){let Le=ee.moduleName;return[...Ca(Le,"prop",Z.props,ee.props),...Ca(Le,"moduleExport",Z.moduleExports,ee.moduleExports),...mu(Le,Z.events,ee.events),...gu(Le,Z.slots,ee.slots),...yu(Le,Z.contexts,ee.contexts),...Eu(Le,Z,ee)]}function Rt(Z,ee){let Le=[],{added:Ot,removed:Bt,common:jt}=fi(Z.components,ee.components,(Gt)=>Gt.moduleName);for(let[Gt]of Ot)Le.push({component:Gt,kind:"component",bump:"minor",message:`component "${Gt}" added`});for(let Gt of Bt)Le.push({component:Gt,kind:"component",bump:"major",message:`component "${Gt}" removed`});for(let[,Gt,Lt]of jt)Le.push(...Su(Gt,Lt));return Le}async function Cu(Z){let ee;try{ee=await cu(gr.resolve(Z),"utf-8")}catch(Le){if(Le.code==="ENOENT")return null;throw Le}try{return JSON.parse(ee)}catch{throw Error(`sveld: could not parse "${Z}" as JSON. Is it a sveld COMPONENT_API.json snapshot?`)}}function Ta(Z){if(typeof Z.check==="string")return Z.check;return Z.jsonOptions?.outFile??yr}function ka(Z,ee){if(!Z.json||Z.stdout||Z.jsonOptions?.outDir)return!1;return gr.resolve(Z.jsonOptions?.outFile??yr)===gr.resolve(ee)}async function _e(Z,ee,Le={}){let Ot=await Cu(ee);if(Ot===null)return{snapshotExists:!1,snapshotFile:ee,changes:[],bump:"none"};if(Ot.schemaVersion!==ds)return{snapshotExists:!0,snapshotFile:ee,changes:[{component:"*",kind:"schema",bump:"none",message:`snapshot schemaVersion ${Ot.schemaVersion} differs from ${ds}; regenerate the snapshot`}],bump:"none"};let Bt=g(Z,{entryExports:Le.entryExports}),jt=Rt(Ot,Bt);return{snapshotExists:!0,snapshotFile:ee,changes:jt,bump:hu(jt)}}var bu={major:"BREAKING",minor:"additive",patch:"patch",none:"no change"};function ge(Z){if(!Z.snapshotExists){let Bt=Z.snapshotFile===yr?"`sveld --json`":`\`sveld --json\` with \`jsonOptions.outFile: "${Z.snapshotFile}"\``;return`sveld --check: no snapshot found at "${Z.snapshotFile}". Generate it with ${Bt} and commit it.`}if(Z.changes.length===0)return`sveld --check: no API changes detected against "${Z.snapshotFile}".`;let ee=Z.changes.length,Le=[`sveld --check: ${ee} API change${ee===1?"":"s"} detected against "${Z.snapshotFile}".`,`Suggested semver bump: ${Z.bump}.`],Ot=new Map;for(let Bt of Z.changes){let jt=Ot.get(Bt.component)??[];jt.push(Bt),Ot.set(Bt.component,jt)}for(let[Bt,jt]of Ot){Le.push("",` ${Bt}`);for(let Gt of jt){let Lt=Gt.kind==="schema"?"schema":bu[Gt.bump];Le.push(` [${Lt}] ${Gt.message}`)}}return Le.join(`
26
26
  `)}var $t=1;function ye(Z){let ee={kind:"check-report",schemaVersion:$t,...Z};return _i(ee)}import{existsSync as _a}from"node:fs";import{join as wu,resolve as Tu}from"node:path";import{pathToFileURL as ku}from"node:url";var Au=["sveld.config.js","sveld.config.mjs","sveld.config.ts"];function Mt(Z){return Z}function Pu(Z=process.cwd()){for(let ee of Au){let Le=wu(Z,ee);if(_a(Le))return Le}return null}async function $a(Z){let ee;try{ee=await import(`${ku(Z).href}?t=${Date.now()}`)}catch(Ot){let Bt=Ot instanceof Error?Ot.message:String(Ot);throw Error(`sveld: failed to load config file "${Z}".
27
27
  ${Bt}`)}let Le=ee.default;if(!r(Le)||Array.isArray(Le))throw Error(`sveld: config file "${Z}" must export a configuration object as its default export. Did you forget \`export default defineConfig({ ... })\`?`);return Le}async function _u(Z=process.cwd()){let ee=Pu(Z);return ee===null?{}:$a(ee)}async function B(Z,ee,Le){if(typeof Z==="string"){let Ot=Tu(ee,Z);if(!_a(Ot))throw Error(`sveld: config file "${Z}" does not exist.`);return $a(Ot)}return Z??Le?_u(ee):{}}function R(...Z){let ee={};for(let Le of Z){if(!Le)continue;for(let[Ot,Bt]of Object.entries(Le)){let jt=ee[Ot];ee[Ot]=r(jt)&&!Array.isArray(jt)&&r(Bt)&&!Array.isArray(Bt)?{...jt,...Bt}:Bt}}return ee}var Aa=["entry","glob","quiet","documentExports","types","typesOptions","json","jsonOptions","markdown","markdownOptions","failFast","watch","config","cache","checkExamples","reportDiagnostics","strict","check","checkLevel","stdout","format","diagnostics"],$u={typesOptions:["outDir","preamble","format","transform","indexTypes"],jsonOptions:["outFile","outDir","source"],markdownOptions:["outFile","outDir","onAppend"],diagnostics:["ignore"]};function Pa(Z,ee,Le){let Ot=Z===null?ee:`${Z}.${ee}`,Bt=_(ee,Le),jt=Bt===void 0?void 0:Z===null?Bt:`${Z}.${Bt}`;console.warn(`sveld: unknown option "${Ot}".${jt?` Did you mean "${jt}"?`:""}`)}function j(Z){for(let ee of Object.keys(Z))if(!Aa.includes(ee))Pa(null,ee,Aa);for(let[ee,Le]of Object.entries($u)){let Ot=Z[ee];if(!r(Ot))continue;for(let Bt of Object.keys(Ot))if(!Le.includes(Bt))Pa(ee,Bt,Le)}}import{dirname as bc}from"node:path";import{lstatSync as Pf}from"node:fs";import{readFile as _f}from"node:fs/promises";import{resolve as zp}from"node:path";import{dirname as Gh}from"node:path";var Nu=" ",Du=120,Ru=/\binterface\s+[A-Za-z_$][\w$]*(\s*<[^{};]*>)?\s*$/,Iu=200,Ia=/\s/,Ou=/\s{2}|[^\S ]/,Lu=/["'`{}/]/g,Mu=/["'`{};/]/g,Oa=9,vr=10,Fu=13,Di=32,ys=34,Bu=38,xs=39,ju=40,Vu=41,gs=42,Na=46,Sr=47,La=59,Gu=62,Wu=91,Cr=92,Uu=93,vs=96,br=123,Ku=124,wr=125;function Hu(Z){return Ru.test(zu(Z,Iu))}var Da=[""];function qu(Z){let ee=Da[Z];if(ee===void 0)ee=Nu.repeat(Z),Da[Z]=ee;return ee}function zu(Z,ee){let Le="";for(let Ot=Z.length-1;Ot>=0&&Le.length<ee;Ot--)Le=Z[Ot]+Le;return Le.length>ee?Le.slice(-ee):Le}function Xu(Z){if(Z.length===0)return!1;let ee=Z[Z.length-1];return ee.charCodeAt(ee.length-1)===vr}function Ju(Z){while(Z.length>0){let ee=Z[Z.length-1],Le=ee.length;while(Le>0){let Ot=ee.charCodeAt(Le-1);if(Ot!==Di&&Ot!==Oa)break;Le--}if(Le===ee.length)return;if(Le===0){Z.pop();continue}Z[Z.length-1]=ee.slice(0,Le);return}}function Yu(Z){while(Z.length>0){let ee=Z[Z.length-1];if(!Ia.test(ee[ee.length-1]))return;let Le=ee.trimEnd();if(Le.length===ee.length)return;if(Le.length===0){Z.pop();continue}Z[Z.length-1]=Le;return}}function Qu(Z){if(Z.includes("{"))return!1;let ee=0,Le=0;for(let Ot=0;Ot<Z.length;Ot++){let Bt=Z.charCodeAt(Ot);if(ee!==0){if(Bt===ee&&Z.charCodeAt(Ot-1)!==Cr)ee=0;continue}if(Bt===ys||Bt===xs||Bt===vs){ee=Bt;continue}if(Bt===La&&++Le>=2)return!0}return!1}function Zu(Z){if(!Ou.test(Z))return Z.trimEnd();let ee="",Le=null,Ot=!1;for(let Bt=0;Bt<Z.length;Bt++){let jt=Z[Bt],Gt=Z[Bt-1];if(Le){if(ee+=jt,Le==="double"&&jt==='"'&&Gt!=="\\"||Le==="single"&&jt==="'"&&Gt!=="\\"||Le==="template"&&jt==="`"&&Gt!=="\\")Le=null;Ot=!1;continue}if(jt==='"'||jt==="'"||jt==="`"){Le=jt==='"'?"double":jt==="'"?"single":"template",ee+=jt,Ot=!1;continue}if(Ia.test(jt)){if(!Ot&&ee.length>0)ee+=" ",Ot=!0;continue}ee+=jt,Ot=!1}return ee.trimEnd()}function Ma(Z,ee){let Le=Z[ee],Ot=Z.indexOf(Le,ee+1);while(Ot!==-1&&Z.charCodeAt(Ot-1)===Cr)Ot=Z.indexOf(Le,Ot+1);return Ot}function Fa(Z,ee){let Le=Z.indexOf("*/",ee+1);return Le===-1?-1:Le+1}function eh(Z){let ee=new Map,Le=[],Ot=Lu,Bt=0;while(Bt<Z.length){if(Ot.lastIndex=Bt,!Ot.test(Z))break;Bt=Ot.lastIndex-1;let jt=Z.charCodeAt(Bt);if(jt===Sr){if(Z.charCodeAt(Bt+1)===gs){let Gt=Fa(Z,Bt);if(Gt===-1)break;Bt=Gt}}else if(jt===ys||jt===xs||jt===vs){let Gt=Ma(Z,Bt);if(Gt===-1)break;Bt=Gt}else if(jt===br)Le.push(Bt);else if(jt===wr&&Le.length>0)ee.set(Le.pop(),Bt);Bt++}return ee}function th(Z,ee,Le){for(let Ot=ee;Ot<Le;Ot++)if(!Er(Z.charCodeAt(Ot)))return!1;return!0}function Er(Z){if(Z<=Di)return Z===Di||Z>=Oa&&Z<=Fu;if(Z<160)return!1;return Z===160||Z===5760||Z>=8192&&Z<=8202||Z===8232||Z===8233||Z===8239||Z===8287||Z===12288||Z===65279}function Ba(Z,ee,Le,Ot){let Bt=[],jt=Mu,Gt=ee,Lt=ee;while(Lt<Le){if(jt.lastIndex=Lt,!jt.test(Z))break;if(Lt=jt.lastIndex-1,Lt>=Le)break;let Vt=Z.charCodeAt(Lt);if(Vt===Sr){if(Z.charCodeAt(Lt+1)===gs){let Wt=Fa(Z,Lt);if(Wt===-1)break;Lt=Wt}Lt++;continue}if(Vt===ys||Vt===xs||Vt===vs){let Wt=Ma(Z,Lt);if(Wt===-1)break;Lt=Wt+1;continue}if(Vt===br){let Wt=Ot.get(Lt);if(Wt===void 0||Wt>=Le){Lt++;continue}if(Gt<Lt)Bt.push(Z.slice(Gt,Lt));let Ut=Lt+1;if(th(Z,Ut,Wt)){Bt.push("{}"),Lt=Wt+1,Gt=Lt;continue}let Ht=Z.slice(Ut,Wt),qt=Z.charCodeAt(Ut)===vr;if(!qt&&!Ht.includes("/*")&&!Qu(Ht)&&!Hu(Bt)){let zt=Ba(Z,Ut,Wt,Ot),Xt=zt.trim();if(!Xt.includes(`
28
28
  `)){let Yt=Xt.endsWith(";")?Xt.slice(0,-1):Xt,Jt=`{ ${Zu(Yt)} }`;if(Jt.length<=Du){Bt.push(Jt),Lt=Wt+1,Gt=Lt;continue}}if(Bt.push("{"),zt.charCodeAt(0)!==La)Bt.push(`
@@ -135,8 +135,8 @@ export { ${Gt.name} as ${JSON.stringify(Bt.name)} };`;return`
135
135
 
136
136
  `);return ja([Ac,_c].filter(Boolean).join(`
137
137
 
138
- `))}var Wh=[...hi,".svelte"];function Uh(Z){let ee=Z.trim();if(ee.length<2)return;let Le=ee[0],Ot=ee[ee.length-1];if((Le==='"'||Le==="'"||Le==="`")&&Le===Ot)return ee.slice(1,-1);return}function ip(Z){let ee=[],Le=Z.moduleExports.filter((Bt)=>Bt.kind==="re-export");if(Le.length===0)return ee;let Ot=new Set([gi(Z.moduleName),Oi(Z.moduleName)]);for(let Bt of Le){if(!Ot.has(Bt.name))continue;ee.push(a({component:Z.filePath,kind:"module-export-conflict",name:Bt.name,message:`Re-export "${Bt.name}" has the same name as the generated "${Bt.name}" type; the .d.ts won't type-check if "${Bt.reExport?.from}" exports a type by that name.`,source:Bt.source}))}return ee}function sp(Z,ee,Le){let Ot=new Map(Array.from(Z.values()).map((Bt)=>[ee(Bt.filePath),Bt]));return(Bt)=>{let jt=Bt.extends;if(!jt)return[];let Gt=Uh(jt.import);if(Gt===void 0||!Gt.startsWith(".")&&!Gt.startsWith("/"))return[];let Lt=ee(Bt.filePath),Vt=Le.resolve(Gt,Gh(Lt),Wh);if(Vt===null)return[a({component:Bt.filePath,kind:"extend-props-target-missing",name:jt.interface,message:`@extends/@extendProps target "${Gt}" was not found on disk.`})];let Wt=Ot.get(Vt);if(!Wt)return[];let Ut=gi(Wt.moduleName);if(_r(jt.interface)!==Ut)return[a({component:Bt.filePath,kind:"extend-props-target-missing",name:jt.interface,message:`@extends/@extendProps names "${jt.interface}", but "${Gt}" generates "${Ut}".`})];let Ht=[];for(let qt of Bt.props){let zt=Wt.props.find((Xt)=>Xt.name===qt.name);if(zt&&zt.type!==qt.type){let Xt=a({component:Bt.filePath,kind:"extend-props-override",name:qt.name,message:`Own prop "${qt.name}" (${qt.type}) overrides "${Ut}"'s "${qt.name}" (${zt.type}).`,source:qt.source}),Jt=fo(Bt)?.[qt.name]?.some((tn)=>tn===""||tn===Xt.code);Ht.push(Jt?{...Xt,ignored:!0}:Xt)}}return Ht}}import{lstatSync as ud,readFileSync as hd,realpathSync as dd,statSync as fd}from"node:fs";import{dirname as md,isAbsolute as gd,join as Cp,parse as yd,relative as Gr,resolve as Mi}from"node:path";function Q(Z){return Z}function $n(Z){if(Z==="")return Z;return Z==="."||Z===".."||Z.startsWith("./")||Z.startsWith("../")?Z:`./${Z}`}import{readFileSync as Ep}from"node:fs";import{dirname as jr,join as cd,relative as yp,resolve as xp}from"node:path";import{readFileSync as ed,statSync as td}from"node:fs";import{basename as Br,dirname as Cs,isAbsolute as nd,join as id,resolve as sd}from"node:path";import{existsSync as ap,readdirSync as Kh}from"node:fs";import{dirname as rp,join as pp,resolve as Hh}from"node:path";function V(Z,ee){for(let Le=Hh(Z);;Le=rp(Le)){for(let Ot of ee){let Bt=pp(Le,Ot);if(ap(Bt))return Bt}if(rp(Le)===Le)return null}}function op(Z){return Z.normalize("NFC").toLowerCase()}class Rr{listings=new Map;clear(){this.listings.clear()}entries(Z){return this.read(Z)?.entries??null}entry(Z,ee){let Le=this.read(Z);if(Le===null)return;if(Le.byName===void 0){Le.byName=new Map;for(let Ot of Le.entries)Le.byName.set(Ot.name,Ot)}return Le.byName.get(ee)}has(Z,ee){let Le=this.read(Z);if(Le===null)return!1;if(Le.names.has(ee))return!0;if(Le.folded===void 0){Le.folded=new Map;for(let Bt of Le.names)Le.folded.set(op(Bt),Bt)}let Ot=Le.folded.get(op(ee));return Ot!==void 0&&Ot!==ee&&ap(pp(Z,ee))}read(Z){let ee=this.listings.get(Z);if(ee!==void 0)return ee;try{let Le=Kh(Z,{withFileTypes:!0}),Ot=new Set;for(let Bt of Le)Ot.add(Bt.name);ee={entries:Le,names:Ot}}catch{ee=null}return this.listings.set(Z,ee),ee}}var Ir=!1;function q(Z){Ir=Z}function Fn(Z){if(!Ir)console.error(Z)}function cp(Z){if(!Ir)console.error(Z)}function xe(Z){if(Z instanceof e)return Z.start?`${Z.reason} (${Z.start.line}:${Z.start.column})`:Z.reason;return Z instanceof Error?Z.message:String(Z)}var Li=null,Or=null;function Un(){if(Li)return Promise.resolve(Li);if(!Or)Or=import("./chunk-rwc4gb17.js").then((Z)=>(Li=Z,Z));return Or}function Nn(){if(!Li)throw Error("sveld: internal error, parser stack read before loadParserStack() resolved.");return Li}import{existsSync as Lr,readFileSync as qh}from"node:fs";import{dirname as fp,isAbsolute as mp,relative as zh,resolve as Mr}from"node:path";function lp(Z){if(!r(Z))return{};let ee={};if(typeof Z.svelte==="string")ee.svelte=Z.svelte;if(typeof Z.name==="string")ee.name=Z.name;if(typeof Z.description==="string")ee.description=Z.description;return ee}function up(Z){if(!r(Z))return{};let ee={};if(typeof Z.extends==="string")ee.extends=Z.extends;if(r(Z.compilerOptions)){let Le={};if(typeof Z.compilerOptions.baseUrl==="string")Le.baseUrl=Z.compilerOptions.baseUrl;if(r(Z.compilerOptions.paths)){let Ot={};for(let[Bt,jt]of Object.entries(Z.compilerOptions.paths))if(Array.isArray(jt)&&jt.every((Gt)=>typeof Gt==="string"))Ot[Bt]=jt;if(Object.keys(Ot).length>0)Le.paths=Ot}if(Object.keys(Le).length>0)ee.compilerOptions=Le}return ee}var Xh=["tsconfig.json","jsconfig.json"],hp=new Map,Jh=/\/\*[\s\S]*?\*\/|\/\/.*/g,Yh=[".svelte",...hi];class G extends Error{specifier;fromFile;searched;constructor(Z,ee,Le){super(`cannot resolve "${Z}" from ${ee||"."} (${Le})`);this.name="UnresolvedModuleError",this.specifier=Z,this.fromFile=ee,this.searched=Le}}function Qh(Z){if(Lr(Z))return!0;return Yh.some((ee)=>Lr(Z+ee))}function dp(Z){let ee=Z.indexOf("*");return ee===-1?Z.length:ee}function gp(Z,ee){if(ee.has(Z))return ee.get(Z)??null;try{let Le=qh(Z,"utf-8"),Ot;try{Ot=JSON.parse(Le)}catch{let jt=Le.replace(Jh,"");Ot=JSON.parse(jt)}let Bt=up(Ot);if(Bt.extends){let jt=mp(Bt.extends)?Bt.extends:Mr(fp(Z),Bt.extends),Gt=jt.endsWith(".json")?jt:`${jt}.json`;if(Lr(Gt)){let Lt=gp(Gt,ee);if(Lt)Bt.compilerOptions={...Lt.compilerOptions,...Bt.compilerOptions,paths:{...Lt.compilerOptions?.paths,...Bt.compilerOptions?.paths}}}}return ee.set(Z,Bt),Bt}catch{return ee.set(Z,null),null}}function Zh(Z){let ee=hp.get(Z);if(!ee){let Le=Z.split("*").map(N).join("(.*)");ee=new RegExp(`^${Le}$`),hp.set(Z,ee)}return ee}class Fr{configs=new Map;lookup(Z,ee){if(Z.startsWith(".")||mp(Z))return{resolved:Z,unresolved:!1,searched:""};let Le=V(ee,Xh),Ot=Le?gp(Le,this.configs)?.compilerOptions:void 0,Bt=Ot?.paths;if(!Le||!Ot||!Bt)return{resolved:Z,unresolved:!0,searched:"no tsconfig/jsconfig paths found"};let jt=Mr(fp(Le),Ot.baseUrl??"."),Gt=Object.entries(Bt).sort(([Lt],[Vt])=>dp(Vt)-dp(Lt));for(let[Lt,Vt]of Gt){let Wt=Z.match(Zh(Lt));if(!Wt)continue;let Ut;for(let Ht of Vt){let qt=Ht;for(let Xt=1;Xt<Wt.length;Xt++)qt=qt.replace("*",Wt[Xt]);let zt=Mr(jt,qt);if(Ut??=zt,Qh(zt))return{resolved:zt,unresolved:!1,searched:Le}}return{resolved:Ut??Z,unresolved:!1,searched:Le}}return{resolved:Z,unresolved:!0,searched:`tsconfig paths (${Le})`}}absolute(Z,ee){return this.lookup(Z,ee).resolved}relative(Z,ee){let Le=this.absolute(Z,ee);if(Le===Z)return Z;return $n(n(zh(ee,Le)))}}var rd=/\.[mc]?jsx?$/,od={".js":[".ts",".tsx",".d.ts"],".jsx":[".tsx",".d.ts"],".mjs":[".mts",".d.mts"],".cjs":[".cts",".d.cts"]};function ad(Z){return Z==="."||Z===".."||Z.startsWith("./")||Z.startsWith("../")||nd(Z)}class Kn{aliases=new Fr;listings=new Rr;modules=new Map;programs=new Map;listDirectory(Z){return this.listings.entries(Z)}exists(Z){return this.listings.has(Cs(Z),Br(Z))}resolve(Z,ee,Le=hi){let Ot=this.aliases.absolute(Z,ee);if(Ot===Z&&!ad(Z))return null;let Bt=sd(ee,Ot),jt=Cs(Bt),Gt=Br(Bt),Lt=this.listings.has(jt,Gt),Vt;if(Lt){let Wt=this.listings.entry(jt,Gt);if(Vt=Wt&&!Wt.isSymbolicLink()?Wt:td(Bt,{throwIfNoEntry:!1}),Vt?.isFile())return Bt}for(let Wt of Le)if(this.listings.has(jt,Gt+Wt))return Bt+Wt;if(!Lt)return this.typeScriptCounterpart(Bt)??null;if(Vt?.isDirectory()){for(let Wt of Le)if(this.listings.has(Bt,`index${Wt}`))return id(Bt,`index${Wt}`)}return null}parse(Z){let ee=this.modules.get(Z);if(ee===void 0)ee=pd(Z),this.modules.set(Z,ee);return ee}parseJavaScript(Z,ee){let Le=this.programs.get(Z);if(Le?.source===ee)return Le.ast;let Ot;try{Ot=me(ee)}catch(Bt){throw Error(xe(Bt))}return this.programs.set(Z,{source:ee,ast:Ot}),Ot}invalidate(...Z){this.listings.clear();for(let ee of Z)this.modules.delete(ee),this.programs.delete(ee)}typeScriptCounterpart(Z){let ee=rd.exec(Z)?.[0];if(ee===void 0)return;let Le=Z.slice(0,-ee.length),Ot=Cs(Le),Bt=Br(Le);for(let jt of od[ee]??[])if(this.listings.has(Ot,Bt+jt))return Le+jt;return}}function pd(Z){let ee;try{ee=ed(Z,"utf-8")}catch{return null}try{let Le=Z.endsWith(".svelte")?Nn().parseSvelteScripts(ee).module?.content.body??[]:Nn().parseModule(ee,{typescript:!0}).body;return{source:{text:ee,filePath:Z,dir:Cs(Z)},body:Le}}catch(Le){return cp(`Warning: sveld couldn't parse ${Z} to read its exports (${xe(Le)}); skipping it.`),null}}function vp(Z){return Z.type==="Identifier"?Z.name:Z.value}function ld(Z,ee,Le,Ot){let Bt=Z.resolve(ee,Le);if(!Bt)return null;let jt=jr(Bt);if(Ot.has(Bt))return{dir:jt,exports:{}};Ot.add(Bt);try{return{dir:jt,exports:Vr(Z,Ep(Bt,"utf-8"),jt,Ot,Bt)}}catch{return{dir:jt,exports:{}}}finally{Ot.delete(Bt)}}function Sp(Z,ee,Le=new Kn,Ot=new Set,Bt=ee){return Vr(Le,Z,ee,Ot,Bt)}function Vr(Z,ee,Le,Ot,Bt){let jt=Z.parseJavaScript(Bt,ee),Gt={};for(let Lt of jt.body)if(Lt.type==="ExportDefaultDeclaration"){if(Lt.declaration.type!=="Identifier")continue;let Vt=Lt.declaration.name;if(Vt in Gt)Gt[Vt].default=!0;else Gt[Vt]={source:$n(""),default:!0}}else if(Lt.type==="ExportAllDeclaration"){let Vt=Lt.source.value,Wt=Z.resolve(Vt,Le);if(!Wt){let zt=Z.aliases.lookup(Vt,Le);throw new G(Vt,Bt,zt.unresolved?zt.searched:"no matching file or index found")}if(Ot.has(Wt))continue;Ot.add(Wt);let Ut=Ep(Wt,"utf-8"),Ht=Vr(Z,Ut,jr(Wt),Ot,Wt);Ot.delete(Wt);let qt=Object.entries(Ht);if(qt.length===0&&!Pn.test(Vt)){let zt=$n(n(Vt));Gt[`*:${Vt}`]={source:zt,default:!1,star:!0}}for(let[zt,Xt]of qt){let Yt=$n(n(Xt.source.startsWith(".")?`./${yp(Le,xp(jr(Wt),Xt.source))}`:`./${cd(Vt,Xt.source)}`));Gt[zt]={...Xt,source:Yt}}}else if(Lt.type==="ExportNamedDeclaration"){let Vt=Lt.source?.value,Wt=Vt!==void 0&&Pn.test(Vt);if(Wt){let qt=Z.aliases.lookup(Vt,Le);if(qt.unresolved)throw new G(Vt,Bt,qt.searched)}let Ht=Vt!==void 0&&!Wt?ld(Z,Vt,Le,Ot):void 0;if(Ht===null){console.warn(`sveld: could not resolve re-exported module "${Vt}" from barrel "${Le||"."}"; skipping.`);continue}for(let qt of Lt.specifiers){let zt=vp(qt.exported),Xt=vp(qt.local),Yt=zt||Xt,Jt=Ht?.exports[Xt],tn=Jt?$n(n(`./${yp(Le,xp(Ht.dir,Jt.source))}`)):$n(Z.aliases.relative(Vt??"",Le)),sn=Jt?Jt.default:Xt==="default";if(Yt in Gt){if(Gt[Yt].mixed=!0,!Gt[Yt].source)Gt[Yt].source=tn}else Gt[Yt]={source:tn,default:sn}}}else if(Lt.type==="ImportDeclaration"){let Vt=Lt.specifiers[0];if(!Vt)continue;let Wt=Vt.local.name,Ut=$n(Z.aliases.relative(Lt.source.value,Le));if(Wt in Gt){if(!Gt[Wt].source)Gt[Wt].source=Ut}else Gt[Wt]={source:Ut,default:Wt==="default"}}return Gt}var xd=/-/g,vd=/[^A-Za-z0-9_$]/g,Ed=/^[0-9]/;function Sd(Z,ee){let Le=Z.replace(vd,""),Ot=Ed.test(Le)?`_${Le}`:Le;if(Ot!==Z&&!ee?.has(Z))ee?.add(Z),console.warn(`Warning: "${Z}" is not a valid identifier; using "${Ot}" instead.`);return Ot}function bp(Z,ee){return Sd(yd(Z).name.replace(xd,""),ee)}function wp(Z,ee,Le=[],Ot=new Set,Bt){let jt;try{jt=Bt??dd(ee)}catch{return Le}if(Ot.has(jt))return Le;Ot.add(jt);let Gt=Z.listDirectory(ee);if(Gt===null)return Le;for(let Lt of Gt){if(Lt.name.startsWith("."))continue;let Vt=Cp(ee,Lt.name),Wt=Lt.isSymbolicLink(),Ut=Wt?fd(Vt,{throwIfNoEntry:!1}):Lt;if(!Ut)continue;if(Ut.isDirectory())wp(Z,Vt,Le,Ot,Wt?void 0:Cp(jt,Lt.name));else if(Ut.isFile()&&Lt.name.endsWith(".svelte"))Le.push(Vt)}return Le}function Cd(Z,ee){return wp(Z,ee).map((Le)=>({moduleName:bp(Le),source:$n(n(`./${Gr(ee,Le)}`))})).sort((Le,Ot)=>u(Le.source,Ot.source))}function bd(Z){return!di(Z)}function wd(Z,ee){let Le=Z.endsWith("/")?Z:`${Z}/`;return ee.startsWith(Le)}function bs(Z,ee){return{seenPaths:new Set(Z.map(([,Le])=>ee(Le.source))),seenModuleNamePaths:new Map(Z.map(([Le,Ot])=>[Le,ee(Ot.source)])),warnedModuleNames:new Set}}function Wr(Z,ee,Le,Ot,Bt,jt){for(let{moduleName:Gt,source:Lt}of Cd(Z,ee)){let Vt=Bt(Lt),Wt=Le[Gt];if(Wt&&bd(Wt.source)&&wd(Wt.source,Lt)){jt.seenPaths.delete(Bt(Wt.source)),Wt.source=Lt,jt.seenPaths.add(Vt),jt.seenModuleNamePaths.set(Gt,Vt);continue}if(jt.seenPaths.has(Vt))continue;jt.seenPaths.add(Vt);let Ut=jt.seenModuleNamePaths.get(Gt);if(Ut===void 0)jt.seenModuleNamePaths.set(Gt,Vt);else if(Ut!==Vt&&!jt.warnedModuleNames.has(Gt))jt.warnedModuleNames.add(Gt),console.warn(`Warning: multiple components named "${Gt}" found (${n(Gr(ee,Ut))} and ${n(Gr(ee,Vt))}). Both are included in TypeScript definitions, but only one can be the named export.`);Ot.push([Gt,{source:Lt,default:!1}])}}function Ur(Z,ee,Le,Ot){let Bt=ud(Z).isFile(),jt=Bt?md(Z):Z,Gt=Mi(jt),Lt=new Map,Vt=(Ht)=>{let qt=Lt.get(Ht);if(qt===void 0)qt=gd(Ht)?Mi(Ht):Mi(Gt,Ht),Lt.set(Ht,qt);return qt},Wt={};if(Bt){let Ht=hd(Z,"utf-8");try{Wt=Sp(Ht,Gt,Ot,new Set([Mi(Z)]),Mi(Z))}catch(qt){if(!Le)throw qt;let zt=qt instanceof Error?qt.message:String(qt);console.warn(`Warning: Failed to parse component exports from ${Z}: ${zt}`)}}let Ut=Object.entries(Wt);if(ee){let Ht=bs(Ut,Vt);if(Wr(Ot,Gt,Wt,Ut,Vt,Ht),!Bt)Wt=Object.fromEntries(Ut.map(([qt,zt])=>[qt,{...zt,default:!0}]))}return{exports:Wt,allComponentEntries:Ut,rootDir:Gt,resolveComponentFilePath:Vt}}function Tp(Z,ee,Le,Ot){if(Le!==1||Z!=="default")return Z;return bp(ee,Ot)}import{dirname as of}from"node:path";import{resolve as Td}from"node:path";var kd=/\r?\n/,Ad=/^\s*\*+/;function ws(Z){return{graph:Z,cache:new Map,computing:new Set}}function gn(Z){return Z?.type==="Identifier"?Z.name:void 0}function Pd(Z){let ee=Z.trimEnd();for(;;){let Le=ee.lastIndexOf(`
139
- `)+1;if(ee.slice(Le).trimStart().startsWith("//")){ee=ee.slice(0,Le).trimEnd();continue}let Ot=ee.endsWith("*/")?ee.lastIndexOf("/*",ee.length-3):-1;if(Ot!==-1&&ee[Ot+2]!=="*"){ee=ee.slice(0,Ot).trimEnd();continue}return ee}}function _d(Z,ee){let Le=Pd(Z.slice(0,ee));if(!Le.endsWith("*/"))return;let Ot=Le.length-2,Bt=Le.lastIndexOf("/**",Ot);if(Bt===-1)return;return Le.slice(Bt,Ot+2)}function $d(Z){let ee=[];for(let Le of Z.slice(3,-2).split(kd)){let Ot=Le.replace(Ad,"").trim();if(Ot.startsWith("@"))break;if(Ot)ee.push(Ot)}return ee.join(" ")||void 0}function ti(Z,ee){if(!ee)return;return Z.text.slice(ee.start,ee.end)}function Nd(Z,ee){return"typeAnnotation"in ee?ti(Z,ee.typeAnnotation?.typeAnnotation):void 0}function Ap(Z,ee){return ti(Z,ee.returnType?.typeAnnotation)}function Kr(Z,ee,Le){return`(${ee.params.map((Bt)=>ti(Z,Bt)??"").join(", ")}) => ${Ap(Z,ee)??Le??"any"}`}function Pp(Z){if(Z.type==="Literal"){let ee=Z.value;if(typeof ee==="string")return"string";if(typeof ee==="number")return"number";if(typeof ee==="boolean")return"boolean"}if(Z.type==="TemplateLiteral")return"string";if(Z.type==="UnaryExpression"&&(Z.operator==="-"||Z.operator==="+"))return Z.argument.type==="Literal"&&typeof Z.argument.value==="number"?"number":void 0;if(Z.type==="CallExpression"&&Z.callee.type==="Identifier")return Dd[Z.callee.name];return}var Dd={String:"string",Number:"number",Boolean:"boolean"};function _p(Z){if(Z.type==="Literal"){let ee=Z.value;return typeof ee==="string"||typeof ee==="number"||typeof ee==="boolean"?ee:void 0}if(Z.type==="UnaryExpression"&&Z.operator==="-"){let ee=Z.argument;return ee.type==="Literal"&&typeof ee.value==="number"?-ee.value:void 0}return Z.type==="TemplateLiteral"?T(Z)??void 0:void 0}function Rd(Z,ee){let Le=ti(Z,ee),Ot=_p(ee);if(Le===void 0||Ot===void 0)return;return{raw:Le,value:Ot,type:typeof Ot}}function Id(Z,ee){if(Z.type!=="CallExpression"&&Z.type!=="NewExpression")return;let Le=Z.callee;if(!(gn(Le)==="Symbol"||Le.type==="MemberExpression"&&!Le.computed&&gn(Le.object)==="Symbol"&&gn(Le.property)==="for"))return;let[Bt]=Z.arguments;return(Bt?.type==="Literal"&&typeof Bt.value!=="string"?null:T(Bt))||ee}var Od=new Set(["any","bigint","boolean","false","never","null","number","object","readonly","string","symbol","true","undefined","unknown","void"]),Ld=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,Md=/(?<![\w$.])[A-Za-z_$][\w$]*(?![\w$]|\s*\??:)/g;function Fd(Z,ee){let Le=ee?Nn().extractJsDocType(ee):void 0,Ot=Z?{type:Z,source:"typescript"}:Le?{type:Le,source:"jsdoc"}:void 0;if(!Ot||Ot.type.includes("`"))return;return(Ot.type.replace(Ld,'""').match(Md)??[]).every((jt)=>Od.has(jt))?Ot:void 0}function $p(Z){if(Z.async||Z.generator||Z.type==="TSDeclareFunction")return;let ee=Z.body,Le=ee.type==="BlockStatement"?Y(ee):[ee];if(Le.length===0)return;let Ot;for(let Bt of Le){if(!Bt)return;let jt=Pp(Bt);if(!jt)return;if(Ot===void 0)Ot=jt;else if(Ot!==jt)return}return Ot}function Bd(Z){if(Z.type==="TemplateLiteral")return;let ee=_p(Z);return typeof ee==="boolean"?void 0:ee}function jd(Z){let ee=Z.members;if(ee.length===0)return;let Le=[],Ot=0;for(let Bt of ee){if(!Bt.initializer){Le.push(String(Ot)),Ot+=1;continue}let jt=Bd(Bt.initializer);if(jt===void 0)return;Le.push(typeof jt==="string"?JSON.stringify(jt):String(jt)),Ot=typeof jt==="number"?jt+1:Ot}return Le.join(" | ")}function Hr(Z,ee,Le,Ot){let Bt=_d(Z.text,Le),jt=Bt?$d(Bt):void 0,Gt=Bt?Nn().extractJsDocReturnType(Bt):void 0,{deprecated:Lt,tags:Vt,internal:Wt}=Bt?Nn().extractJsDocDeprecatedAndTags(Bt):{deprecated:void 0,tags:void 0,internal:!1},Ut={description:jt,deprecated:Lt,tags:Vt,...Wt?{internal:!0}:{},declFile:Z.filePath},Ht=(zt,Xt,Yt=!1)=>zt?[{name:zt,...Xt,...Ut,isTypeOnly:Yt}]:[],qt=(zt,Xt)=>Ap(Z,zt)??Gt??re(Xt)??$p(zt);if(ee.type==="VariableDeclaration"){let zt=ee.kind==="let"||ee.kind==="var"?ee.kind:"const";return ee.declarations.flatMap((Xt)=>{let Yt=Xt.id,Jt=gn(Yt);if(!Jt)return[];let tn=Nd(Z,Yt),sn=tn,ln,cn,un,On,zn,Bn,yn=Xt.init;if(yn)if(yn.type==="ArrowFunctionExpression"||yn.type==="FunctionExpression"){if(Bn=yn,cn=qt(yn,sn),!sn)sn=Kr(Z,yn,cn)}else{if(ln=ti(Z,yn),!sn)sn=Pp(yn);let Zt=C(yn);if(un=T(Zt)??Id(Zt,Jt),zt==="const")On=Rd(Z,Zt),zn=Fd(tn,Bt)}return Ht(Jt,{kind:zt,type:sn,value:ln,returnType:cn,literalValue:un,primitiveLiteral:On,declaredType:zn,functionNode:Bn})})}if(ee.type==="FunctionDeclaration"||ee.type==="TSDeclareFunction"){let zt=qt(ee);return Ht(gn(ee.id)??Ot,{kind:"function",type:Kr(Z,ee,zt),returnType:zt,...ee.type==="FunctionDeclaration"?{functionNode:ee}:{}})}if(ee.type==="ClassDeclaration"){let zt=gn(ee.id);return Ht(zt??Ot,{kind:"class",...zt?{type:zt}:{}})}if(ee.type==="TSTypeAliasDeclaration")return Ht(gn(ee.id),{kind:"type",type:ti(Z,ee.typeAnnotation)},!0);if(ee.type==="TSInterfaceDeclaration")return Ht(gn(ee.id),{kind:"interface",type:ti(Z,ee.body)},!0);if(ee.type==="TSEnumDeclaration"){let zt=gn(ee.id);return Ht(zt,{kind:"enum",type:jd(ee)??zt})}return[]}function Vd(Z,ee,Le){let Ot=ee.declaration;if(Ot.type==="FunctionDeclaration"||Ot.type==="TSDeclareFunction"||Ot.type==="ClassDeclaration"){let[Gt]=Hr(Z,Ot,ee.start,"default");return Gt?{...Gt,name:"default"}:void 0}if(Ot.type==="FunctionExpression"||Ot.type==="ArrowFunctionExpression")return{name:"default",kind:"function",type:Kr(Z,Ot,$p(Ot)),functionNode:Ot,declFile:Z.filePath,isTypeOnly:!1};let Bt=gn(Ot),jt=Bt?Le(Bt):null;return jt?{...jt,name:"default"}:void 0}function Gd(Z,ee){for(let Le of Z){if(Le.type!=="ImportDeclaration")continue;let Ot=Le.source.value;for(let Bt of Le.specifiers){if(Bt.local.name!==ee)continue;let jt=Le.importKind==="type"||Bt.type==="ImportSpecifier"&&Bt.importKind==="type";if(Bt.type==="ImportDefaultSpecifier")return{specifier:Ot,importedName:"default",isTypeOnly:jt};if(Bt.type==="ImportNamespaceSpecifier")return{specifier:Ot,importedName:"*",isTypeOnly:jt};if(Bt.type==="ImportSpecifier"){let Gt=gn(Bt.imported)??ee;return{specifier:Ot,importedName:Gt,isTypeOnly:jt}}}}return null}function kp(Z,ee,Le){return{name:Z,kind:"const",declFile:ee,namespaceFile:ee,isTypeOnly:Le}}function Ts(Z,ee){let Le=ee.cache.get(Z);if(Le)return Le;if(ee.computing.has(Z))return[];ee.computing.add(Z);let Ot=ee.graph.parse(Z);if(!Ot)return ee.computing.delete(Z),ee.cache.set(Z,[]),[];let{source:Bt,body:jt}=Ot,Gt=[],Lt=new Map;for(let qt of jt){let zt=qt.type==="ExportNamedDeclaration"?qt.declaration:qt;if(!zt)continue;for(let Xt of Hr(Bt,zt,zt.start))Lt.set(Xt.name,Xt)}let Vt=(qt,zt)=>({name:qt,kind:"const",declFile:Td(Bt.dir,zt),isTypeOnly:!1}),Wt=(qt)=>{let zt=Lt.get(qt);if(zt)return zt;let Xt=Gd(jt,qt);if(!Xt)return null;if(Xt.specifier.endsWith(".svelte"))return Vt(qt,Xt.specifier);let Yt=ee.graph.resolve(Xt.specifier,Bt.dir);if(!Yt)return null;if(Xt.importedName==="*")return kp(qt,Yt,Xt.isTypeOnly);return ni(Yt,Xt.importedName,ee)??null},Ut=new Map;for(let qt of jt){if(qt.type==="ExportAllDeclaration"){let Jt=qt.source.value;if(Jt.endsWith(".svelte"))continue;let tn=ee.graph.resolve(Jt,Bt.dir);if(!tn)continue;let sn=qt.exportKind==="type",ln=gn(qt.exported);if(ln){Gt.push(kp(ln,tn,sn));continue}for(let cn of Ts(tn,ee)){let un=Ut.get(cn.name)??[];un.push(sn?{...cn,isTypeOnly:!0}:cn),Ut.set(cn.name,un)}continue}if(qt.type==="ExportDefaultDeclaration"){let Jt=Vd(Bt,qt,Wt);if(Jt)Gt.push(Jt);continue}if(qt.type!=="ExportNamedDeclaration")continue;let zt=qt.declaration;if(zt){Gt.push(...Hr(Bt,zt,qt.start));continue}let Xt=qt.source?.value;if(Xt?.endsWith(".svelte")){for(let Jt of qt.specifiers){let tn=gn(Jt.exported);if(tn)Gt.push(Vt(tn,Xt))}continue}let Yt=qt.exportKind==="type";for(let Jt of qt.specifiers){let tn=gn(Jt.exported),sn=gn(Jt.local);if(!tn||!sn)continue;let ln=Yt||Jt.exportKind==="type",cn=null;if(Xt){let un=ee.graph.resolve(Xt,Bt.dir);if(un)cn=ni(un,sn,ee)??null}else cn=Wt(sn);if(cn)Gt.push({...cn,name:tn,isTypeOnly:cn.isTypeOnly||ln});else if(sn!=="default")Gt.push({name:tn,kind:ln?"type":"const",declFile:Z,isTypeOnly:ln})}}let Ht=new Set(Gt.map((qt)=>qt.name));for(let[qt,zt]of Ut){if(Ht.has(qt)||qt==="default")continue;if(zt.every((Xt)=>Xt.declFile===zt[0].declFile))Gt.push(...zt);else ee.onAmbiguousStarExport?.(Z,qt,zt)}return ee.computing.delete(Z),ee.cache.set(Z,Gt),Gt}function ni(Z,ee,Le){return Ts(Z,Le).findLast((Ot)=>Ot.name===ee)}function yi(Z,{importedName:ee,members:Le=[]},Ot){let Bt=ni(Z,ee,Ot);for(let jt of Le){if(Bt?.namespaceFile===void 0)return;Bt=ni(Bt.namespaceFile,jt,Ot)}return Bt}function Hn(Z,ee,Le){if(Z[ee]===void 0)delete Z[ee];Z[ee]=Le}function ks(Z,ee){return(ee.location==="props"?Z.props:Z.moduleExports).find((Ot)=>Ot.name===ee.propName)}function As(Z,ee){if(ee.location!=="props")return;Z.diagnostics=(Z.diagnostics??[]).filter((Le)=>!(Le.kind==="prop-unknown-type"&&Le.name===ee.propName))}var Wd=/\.[^./\\]+$/;function Ud(Z,ee){if(Z.endsWith(".d.ts"))return null;let Le=Z.replace(Wd,".d.ts");return ee.exists(Le)?Le:null}function Kd(Z,ee,Le){return ee.map((Ot)=>{if(!Ot.importSource||!Ot.importedName)return{candidate:Ot};let Bt=Le.graph.resolve(Ot.importSource,Z);if(!Bt)return{candidate:Ot,failureReason:"module-not-found"};let jt=ni(Bt,Ot.importedName,Le);if(!jt)return{candidate:Ot,failureReason:"export-not-found"};if(jt.returnType)return{candidate:Ot,type:jt.returnType};let Gt=Ud(Bt,Le.graph);if(Gt){let Lt=ni(Gt,Ot.importedName,Le);if(Lt?.returnType)return{candidate:Ot,type:Lt.returnType}}return{candidate:Ot,failureReason:"return-type-unresolved"}})}function Hd(Z,ee){switch(ee){case"module-not-found":return`Prop "${Z.propName}" default calls "${Z.calleeName}()", but "${Z.importSource}" could not be resolved; falling back to "any".`;case"export-not-found":return`Prop "${Z.propName}" default calls "${Z.calleeName}()", but "${Z.importedName}" is not exported from "${Z.importSource}"; falling back to "any".`;case"return-type-unresolved":return`Prop "${Z.propName}" default calls "${Z.calleeName}()" imported from "${Z.importSource}", but its return type could not be resolved; falling back to "any".`}}function qd(Z,ee){for(let{candidate:Le,type:Ot,failureReason:Bt}of ee){let jt=ks(Z,Le);if(jt?.typeSource!=="unknown")continue;if(Ot){Hn(jt,"type",Ot),Hn(jt,"typeSource","typescript"),As(Z,Le);continue}if(Le.location==="props"&&Bt){let Gt=Z.diagnostics?.find((Lt)=>Lt.kind==="prop-unknown-type"&&Lt.name===Le.propName);if(Gt)Gt.message=Hd(Le,Bt)}}}var Np={collect:(Z)=>Z.pendingCallDefaultCandidates?.filter((ee)=>ee.importSource!==void 0)??[],resolve:Kd,apply:qd};function zd(Z,ee,Le){return ee.map((Ot)=>{let Bt=Le.graph.resolve(Ot.importSource,Z);if(!Bt)return{candidate:Ot};let jt=yi(Bt,Ot,Le);if(!jt?.primitiveLiteral)return{candidate:Ot};return{candidate:Ot,literal:jt.primitiveLiteral,declaredType:jt.declaredType}})}function Xd(Z,ee){for(let{candidate:Le,literal:Ot,declaredType:Bt}of ee){if(!Ot)continue;let jt=ks(Z,Le);if(!jt)continue;if(Hn(jt,"value",Ot.raw),Hn(jt,"defaultValue",{raw:Ot.raw,kind:"literal",value:Ot.value}),jt.typeSource!=="unknown")continue;Hn(jt,"type",Bt?.type??Ot.type),Hn(jt,"typeSource",Bt?.source??"default"),As(Z,Le)}}var Dp={collect:(Z)=>Z.pendingConstDefaultCandidates??[],resolve:zd,apply:Xd};function Jd(Z,ee,Le){return ee.map((Ot)=>{let Bt=Le.graph.resolve(Ot.importSource,Z);if(!Bt)return{candidate:Ot};let jt=yi(Bt,Ot,Le);if(jt?.kind!=="const"||jt.literalValue===void 0)return{candidate:Ot};return{candidate:Ot,key:jt.literalValue}})}function Yd(Z,ee){for(let{candidate:Le,key:Ot}of ee){if(!Ot){let Lt=oe(Le);pi(Z,[a({component:Z.filePath,kind:"context-key-unresolved",name:Lt,message:`setContext key \`${Lt}\` from "${Le.importSource}" isn't an \`export const\` string or Symbol() sveld can read; the context is skipped.`,...Le.source?{source:Le.source}:{}})]);continue}let Bt=[...Z.contexts??[]],jt=Bt.findIndex((Lt)=>Lt.key===Ot);if(jt!==-1){let Lt=Bt[jt],Vt=Rp(Lt.source,Le.source),Wt=Vt?Lt.source:Le.source;if(pi(Z,[a({component:Z.filePath,kind:"context-duplicate-key",name:Ot,message:`setContext("${Ot}", ...) was called more than once; only the first call's shape is used.`,...Wt?{source:Wt}:{}})]),!Vt)continue;Bt.splice(jt,1)}let Gt=Bt.findIndex((Lt)=>Rp(Lt.source,Le.source));Bt.splice(Gt===-1?Bt.length:Gt,0,{key:Ot,typeName:J(Ot),...Le.type===void 0?{}:{type:Le.type},description:Le.description,properties:Le.properties,...Le.hasUnresolvedSpread?{hasUnresolvedSpread:!0}:{},...Le.internal?{internal:!0}:{},source:Le.source}),Z.contexts=Bt}}function Rp(Z,ee){if(!Z||!ee)return!1;let{line:Le,column:Ot}=Z.start;return Le>ee.start.line||Le===ee.start.line&&Ot>ee.start.column}var Ip={collect:(Z)=>Z.pendingContextKeyCandidates??[],resolve:Jd,apply:Yd};function Qd(Z,ee,Le){return ee.map((Ot)=>{let Bt=Le.graph.resolve(Ot.importSource,Z);if(!Bt)return{candidate:Ot,failureReason:"module-not-found"};let jt=yi(Bt,Ot,Le)?.functionNode;if(!jt)return{candidate:Ot,failureReason:"not-a-function"};let Gt=Zd(jt,Ot);if(!Gt)return{candidate:Ot,failureReason:"parameter-not-found"};return nf(jt,Gt,Ot)})}function Op(Z){return Z?.type==="AssignmentPattern"?Z.left:Z}function Zd(Z,ee){let Le=Op(Z.params[ee.argumentIndex]);if(ee.property===void 0)return Le?.type==="Identifier"?{name:Le.name}:void 0;if(!ee.property)return;if(Le?.type==="Identifier")return{object:Le.name,property:ee.property};if(Le?.type!=="ObjectPattern")return;for(let Ot of Le.properties){if(Ot.type!=="Property"||Ot.computed)continue;if(Ot.key.type!=="Identifier"||Ot.key.name!==ee.property)continue;let Bt=Op(Ot.value);return Bt?.type==="Identifier"?{name:Bt.name}:void 0}return}function qr(Z){if(!Z)return null;if(Z.type==="ConditionalExpression"){let Le=qr(Z.consequent),Ot=qr(Z.alternate);return Le&&Ot?[...Le,...Ot]:null}let ee=T(Z);return ee?[ee]:null}var ef={variableType:()=>{return}};function tf(Z){if(!Z)return"null";let{deriveLiteralDetailType:ee,literalDetailToTypeText:Le}=Nn();if(Z.type==="Literal")return Le(Z.value);return ee(ef,Z)??"any"}function Lp(Z,ee){if("name"in ee)return Z.type==="Identifier"&&Z.name===ee.name;if(Z.type!=="MemberExpression"||Z.computed)return!1;return Z.object.type==="Identifier"&&Z.object.name===ee.object&&Z.property.type==="Identifier"&&Z.property.name===ee.property}function nf(Z,ee,Le){let Ot=new Map,Bt="name"in ee?ee.name:ee.object,jt;if(o(Z.body,{enter(Lt,Vt,Wt){if(Lt.type==="CallExpression"){if(!Lp(Lt.callee,ee))return;let Ht=Lt.arguments,qt=qr(Ht[0]);if(!qt)return jt="dynamic-event-name",E;for(let zt of qt){let Xt=Ot.get(zt)??new Set;Xt.add(tf(Ht[1])),Ot.set(zt,Xt)}return}let Ut=Vt?.type==="CallExpression"&&Wt==="callee";if(Lt.type==="MemberExpression"&&Lp(Lt,ee)&&!Ut)return jt="passed-on",E;if(Lt.type!=="Identifier"||Lt.name!==Bt)return;if(Ut)return;if(!("name"in ee)&&Vt?.type==="MemberExpression"&&Wt==="object")return;if(!H(Lt,Vt))return;return jt="passed-on",E}}),jt)return{candidate:Le,failureReason:jt};let Gt=Array.from(Ot,([Lt,Vt])=>{let Wt=Array.from(Vt);return{name:Lt,detail:Wt.includes("any")?"any":Wt.join(" | ")}});return{candidate:Le,events:Gt}}function sf(Z,ee){let Le=Z.members?`"${Z.calleeText}"`:Z.importedName==="default"?"the default export":`"${Z.importedName}"`;switch(ee){case"module-not-found":return`"${Z.importSource}" isn't a local module sveld can read`;case"not-a-function":return`${Le} isn't a function declared in "${Z.importSource}"`;case"parameter-not-found":return`no parameter of ${Le} receives it`;case"dynamic-event-name":return"an event name isn't a string literal";case"passed-on":return`${Le} passes it on`}}function rf(Z,ee,{deferredEventNoSourceDiagnostics:Le=[],untypedJsDocEventNames:Ot=[]}){let Bt=new Map,jt=[...Z.diagnostics??[]],Gt=!0;for(let{candidate:zt,events:Xt,failureReason:Yt}of ee){if(Yt){Gt=!1,jt.push(a({component:Z.filePath,kind:"dispatch-escapes",name:zt.dispatcherName,message:`\`${zt.dispatcherName}\` is passed to \`${zt.calleeText}\`, but sveld couldn't read the events it dispatches: ${sf(zt,Yt)}. Document them with @event tags.`,...zt.source?{source:zt.source}:{},...zt.ignored?{ignored:!0}:{}}));continue}for(let Jt of Xt??[]){if(Bt.has(Jt.name))continue;Bt.set(Jt.name,{type:"dispatched",name:Jt.name,detail:Jt.detail,...zt.source?{source:zt.source}:{}})}}if(Gt){for(let zt of Le)if(!Bt.has(zt.name))jt.push(zt)}if(Z.diagnostics=jt,Bt.size===0)return;let Lt=new Map,Vt=new Set;for(let zt of Z.events)if(zt.type==="dispatched")Vt.add(zt.name);else if(!Lt.has(zt.name))Lt.set(zt.name,zt);let Wt=new Set(Ot),Ut=new Map,Ht=[];for(let zt of Bt.values()){if(Vt.has(zt.name)){if(Wt.has(zt.name)&&zt.detail!==void 0)Ut.set(zt.name,zt.detail);continue}let Xt=Lt.get(zt.name);if(!Xt){Ht.push(zt);continue}let Yt=zt.source??Xt.source;Ht.push({type:"dispatched",name:zt.name,detail:Xt.detail??zt.detail,...Xt.description?{description:Xt.description}:{},...Xt.deprecated===void 0?{}:{deprecated:Xt.deprecated},...Xt.tags?{tags:Xt.tags}:{},...Xt.internal?{internal:!0}:{},...Yt?{source:Yt}:{}})}if(Ht.length===0&&Ut.size===0)return;let qt=new Set(Ht.map((zt)=>zt.name));Z.events=[...Z.events.filter((zt)=>zt.type==="dispatched"||!qt.has(zt.name)).map((zt)=>{let Xt=zt.type==="dispatched"?Ut.get(zt.name):void 0;return Xt===void 0?zt:{...zt,detail:Xt}}),...Ht].sort(he)}var Mp={collect:(Z)=>Z.pendingDispatchEscapeCandidates??[],resolve:Qd,apply:rf};function Ps(Z){return(ee)=>{let Le=Z.collect(ee);if(Le.length===0)return;return(Ot,Bt,jt)=>Z.apply(Ot,Z.resolve(Bt,Le,jt),ee)}}var af=[Ps(Np),Ps(Dp),Ps(Ip),Ps(Mp)];async function Fp(Z,ee,Le,Ot){let Bt=[];for(let Gt of Z){let Lt=Le(Gt);if(Lt===void 0)continue;let Vt=af.flatMap((Wt)=>Wt(Lt)??[]);if(Vt.length>0)Bt.push({component:Gt,passes:Vt})}let jt=new Map;if(Bt.length===0)return jt;await Un();for(let{component:Gt,passes:Lt}of Bt){let Vt=ws(Ot),Wt=of(ee(Gt.filePath));for(let Ut of Lt)Ut(Gt,Wt,Vt);jt.set(Gt.filePath,Array.from(Vt.cache.keys()))}return jt}var pf=/^```([\w-]*)\r?\n([\s\S]*?)\r?\n?```$/,cf=new Set(["","js","jsx","ts","tsx","javascript","typescript"]),lf=new Set(["svelte","html"]);function uf(Z){let ee=Z.trim();if(ee==="")return null;let Le=ee.match(pf);if(Le){let Ot=Le[1].toLowerCase(),Bt=Le[2].trim();if(Bt==="")return null;if(cf.has(Ot))return{kind:"compile",code:Bt};if(lf.has(Ot))return{kind:"syntax",code:Bt};return null}if(ee.startsWith("<"))return null;return{kind:"compile",code:ee}}function Bp(Z){if(!Z.isFunction)return"any";return`(${(Z.params??[]).map((Le)=>`${Le.name}${Le.optional?"?":""}: any`).join(", ")}) => any`}function _s(Z,ee,Le,Ot,Bt){let jt=(Z??[]).filter((Lt)=>Lt.name==="example"),Gt=jt.length>1;return jt.flatMap((Lt,Vt)=>{let Wt=uf(Lt.body);if(Wt===null)return[];return[{id:Gt?`${ee}#${Vt}`:ee,name:Gt?`${Le} (example ${Vt+1})`:Le,type:Ot,code:Wt.code,kind:Wt.kind,...Bt?{source:Bt}:{}}]})}function hf(Z){let ee=[];for(let Le of Z.props)ee.push(..._s(Le.tags,`prop:${Le.name}`,Le.name,Bp(Le),Le.source));for(let Le of Z.moduleExports)ee.push(..._s(Le.tags,`export:${Le.name}`,Le.name,Bp(Le),Le.source));for(let Le of Z.slots){let Ot=Le.name??"default";ee.push(..._s(Le.tags,`slot:${Ot}`,Ot,"any",Le.source))}for(let Le of Z.events)ee.push(..._s(Le.tags,`event:${Le.name}`,Le.name,"any",Le.source));return ee}function jp(Z,ee){return Z.flatMap(({component:Le,sources:Ot})=>{let Bt=Ot.filter((jt)=>jt.kind===ee);return Bt.length===0?[]:[{component:Le,sources:Bt}]})}async function df(Z){let{formatParseError:ee,parseSvelte:Le}=await Un(),Ot=new Map;for(let{component:Bt,sources:jt}of Z){let Gt=[];for(let Lt of jt)try{Le(Lt.code)}catch(Vt){Gt.push(a({component:Bt.filePath,kind:"example-syntax-error",name:Lt.name,message:ee(Vt),...Lt.source?{source:Lt.source}:{}}))}Ot.set(Bt,Gt)}return Ot}async function ff(Z,ee,Le){let Ot=await ee.checkExamples(Z.map(({component:jt,sources:Gt})=>({moduleName:jt.moduleName,filePath:Le(jt.filePath),sources:Gt}))),Bt=new Map;for(let{component:jt,sources:Gt}of Z){let Lt=Ot.get(Le(jt.filePath));if(!Lt||Lt.length===0)continue;let Vt=new Map(Gt.map((Wt)=>[Wt.id,Wt.source]));Bt.set(jt,Lt.map((Wt)=>{let Ut=Vt.get(Wt.id);return a({component:jt.filePath,kind:"example-compile-error",name:Wt.name,message:Wt.message,...Ut?{source:Ut}:{}})}))}return Bt}async function Vp(Z,ee,Le,Ot){let Bt=Array.from(Z,(Wt)=>({component:Wt,sources:hf(Wt)})),jt=ee===!0?jp(Bt,"compile"):[],Gt=jp(Bt,"syntax"),Lt=new Map,Vt=(Wt)=>{for(let[Ut,Ht]of Wt)Lt.set(Ut,[...Lt.get(Ut)??[],...Ht])};if(Gt.length>0)Vt(await df(Gt));if(jt.length>0){let{TypeResolver:Wt}=await import("./chunk-2n2nej6f.js"),Ut=await Wt.create(Le);if(!Ut.ok)throw Error(`sveld: \`checkExamples\` ${Ut.message}.`);let Ht=Ut.resolver;try{Vt(await ff(jt,Ht,Ot))}finally{await Ht.dispose()}}return Lt}import{hash as mf}from"node:crypto";import{mkdirSync as gf,readFileSync as yf,renameSync as xf,writeFileSync as Gp}from"node:fs";import{dirname as Wp,isAbsolute as vf,join as Ef,resolve as zr}from"node:path";var Up=11,Sf=Ef("node_modules",".cache","sveld","parse-cache.json"),Cf="672481c0ad3d35ba";function Kp(){return`${hs}+${Cf}+svelte@${$i}`}function bf(Z){let ee=V(Z,["package.json"]);return ee===null?zr(Z):Wp(ee)}function Hp(Z,ee){let Le=bf(Z);if(typeof ee==="string")return vf(ee)?ee:zr(Le,ee);return zr(Le,Sf)}function $s(Z){return mf("sha256",Z,"hex")}function Xr(){return{formatVersion:Up,toolchainVersion:Kp(),entries:{}}}function wf(Z){try{let ee=JSON.parse(yf(Z,"utf-8"));if(ee.formatVersion!==Up||ee.toolchainVersion!==Kp())return Xr();return ee}catch{return Xr()}}class Jr{cacheFilePath;file;next=new Map;dirty=!1;savedEntryCount;constructor(Z){this.cacheFilePath=Z,this.file=wf(Z),this.savedEntryCount=Object.keys(this.file.entries).length}has(Z,ee){return this.lookup(Z,ee)!==void 0}lookup(Z,ee){let Le=this.next.get(Z);if(Le?.hash===ee)return Le;let Ot=this.file.entries[Z];return Ot?.hash===ee?Ot:void 0}get(Z,ee){let Le=this.lookup(Z,ee);if(Le===void 0)return null;this.next.set(Z,Le);let{component:Ot,typeScriptMetadata:Bt,propIgnores:jt,pending:Gt}=structuredClone({component:Le.component,typeScriptMetadata:Le.typeScriptMetadata,propIgnores:Le.propIgnores,pending:Le.pending});if(Bt!==void 0)Ot[x]=Bt;if(jt!==void 0)Ot[I]=jt;return Gt===void 0?{component:Ot}:{component:Ot,pending:Gt}}set(Z,ee,{component:Le,pending:Ot}){this.dirty=!0,this.next.set(Z,{hash:ee,...structuredClone({component:Le,typeScriptMetadata:Le[x],propIgnores:Le[I],pending:Ot})})}getGeneratedText(Z,ee){let Le=this.next.get(Z);if(Le?.generatedText===void 0||Le.generatedText.key!==ee)return;return Le.generatedText.text}setGeneratedText(Z,ee,Le){let Ot=this.next.get(Z);if(Ot===void 0)return;if(Ot.generatedText?.key===ee&&Ot.generatedText.text===Le)return;Ot.generatedText={key:ee,text:Le},this.dirty=!0}save(){if(!this.dirty&&this.next.size===this.savedEntryCount)return;this.dirty=!1,this.savedEntryCount=this.next.size,gf(Wp(this.cacheFilePath),{recursive:!0});let Z={...Xr(),entries:Object.fromEntries(this.next)},ee=JSON.stringify(Z),Le=`${this.cacheFilePath}.${process.pid}.tmp`;try{Gp(Le,ee),xf(Le,this.cacheFilePath)}catch{try{Gp(this.cacheFilePath,ee)}catch{}}}}import{dirname as Tf,relative as kf,resolve as Af}from"node:path";async function qp(Z,ee={}){await Un();let Le=Af(Z),Ot=Tf(Le),Bt=(Lt)=>n(`./${kf(Ot,Lt)}`),jt=Ts(Le,{...ws(ee.graph??new Kn),onAmbiguousStarExport:(Lt,Vt,Wt)=>{if(Lt!==Le||!ee.diagnostics)return;if(Wt.every((zt)=>zt.declFile.endsWith(".svelte")))return;let Ut=Array.from(new Set(Wt.map((zt)=>Bt(zt.declFile)))),Ht=Ut.map((zt)=>`"${zt}"`),qt=`${Ht.slice(0,-1).join(", ")} and ${Ht[Ht.length-1]}`;ee.diagnostics.push(a({component:Bt(Le),kind:"export-ambiguous",name:Vt,message:`"${Vt}" is exported by ${qt} through \`export *\`, so the barrel doesn't export it and the docs leave it out; export it explicitly from the barrel (e.g. \`export { ${Vt} } from "${Ut[0]}"\`).`}))}}),Gt=new Map;for(let Lt of jt){if(Lt.name==="default"||Lt.declFile.endsWith(".svelte"))continue;let{declFile:Vt,returnType:Wt,literalValue:Ut,primitiveLiteral:Ht,declaredType:qt,functionNode:zt,namespaceFile:Xt,...Yt}=Lt,Jt=Bt(Vt);if(Xt!==void 0)Yt.type=`typeof import(${JSON.stringify(Bt(Xt))})`;Gt.set(Lt.name,{...Yt,source:Jt})}return Array.from(Gt.values()).sort((Lt,Vt)=>u(Lt.name,Vt.name))}async function $f(Z){let ee=await Promise.all(Array.from(Z,async(Le)=>{try{return[Le,await _f(Le,"utf-8")]}catch(Ot){return console.warn(`Warning: Failed to read file ${Le}:`,Ot),[Le,null]}}));return new Map(ee)}function Xp(Z){if(Z.length===0)return;console.error(`sveld: failed to parse ${Z.length} component(s):`);for(let{filePath:ee,message:Le}of Z)console.error(` - ${ee}: ${Le}`)}class Fi{input;glob;options;graph=new Kn;collected;entryFile=null;globMergeState;cache;entryExports=[];entryDiagnostics=[];records=new Map;parseErrors=new Map;canonicalEntries=new Map;warnedModuleNames=new Set;constructor(Z,ee,Le={}){this.input=Z,this.glob=ee,this.options=Le}get documentExports(){return this.options.documentExports===!0}async build(){return this.graph=new Kn,this.collected=Ur(this.input,this.glob,this.documentExports,this.graph),this.globMergeState=bs(this.collected.allComponentEntries,this.collected.resolveComponentFilePath),this.entryFile=Pf(this.input).isFile()?zp(this.input):null,this.cache=this.options.cache===!1?void 0:new Jr(Hp(this.collected.rootDir,this.options.cache??!0)),await this.readEntryExports(),this.records.clear(),this.parseErrors.clear(),this.indexEntries(),await this.process(this.componentPaths()),Xp(Array.from(this.parseErrors.values())),this.assemble()}async update(Z){let ee=Z.map((Wt)=>zp(Wt));if(this.graph.invalidate(...ee),ee.length===0)return{result:this.assemble(),reparsed:[]};let Le=this.entryFile!==null&&ee.includes(this.entryFile)?await this.recollect():[];if(this.glob){let{rootDir:Wt,exports:Ut,allComponentEntries:Ht,resolveComponentFilePath:qt}=this.collected;Wr(this.graph,Wt,Ut,Ht,qt,this.globMergeState)}this.indexEntries();let Ot=this.componentPaths();for(let Wt of this.records.keys())if(!Ot.has(Wt))this.records.delete(Wt);for(let Wt of this.parseErrors.keys())if(!Ot.has(Wt))this.parseErrors.delete(Wt);let Bt=Array.from(this.records).flatMap(([Wt,{crossFileReads:Ut}])=>Ut?.some((Ht)=>ee.includes(Ht))?[Wt]:[]),jt=new Set([...ee.filter((Wt)=>Pn.test(Wt)),...Le,...Bt]),Gt=new Set(Array.from(Ot).filter((Wt)=>jt.has(Wt))),Lt=await this.process(Gt),Vt=this.assemble();return Xp(Vt.errors),{result:Vt,reparsed:Lt}}async recollect(){let Z=this.collected,ee=Ur(this.input,this.glob,this.documentExports,this.graph),Le=[];for(let[Ot,Bt]of Object.entries(ee.exports)){let jt=ee.resolveComponentFilePath(Bt.source),Gt=Object.hasOwn(Z.exports,Ot)?Z.exports[Ot]:void 0;if(Gt===void 0||Z.resolveComponentFilePath(Gt.source)!==jt)Le.push(jt)}return this.collected=ee,this.globMergeState=bs(ee.allComponentEntries,ee.resolveComponentFilePath),await this.readEntryExports(),Le}async readEntryExports(){this.entryDiagnostics=[],this.entryExports=this.documentExports&&this.entryFile!==null?await qp(this.entryFile,{diagnostics:this.entryDiagnostics,graph:this.graph}):[]}componentPaths(){let{exports:Z,allComponentEntries:ee,resolveComponentFilePath:Le}=this.collected,Ot=new Set;for(let[,Bt]of[...Object.entries(Z),...ee])if(di(Bt.source))Ot.add(Le(Bt.source));return Ot}indexEntries(){let{exports:Z,allComponentEntries:ee,resolveComponentFilePath:Le}=this.collected;this.canonicalEntries=new Map;for(let Ot of[Object.entries(Z),ee])for(let Bt of Ot){if(!di(Bt[1].source))continue;this.canonicalEntries.set(Le(Bt[1].source),this.entryIdentity(Ot,Bt))}}entryIdentity(Z,[ee,{source:Le}]){return{moduleName:Tp(ee,Le,Z.length,this.warnedModuleNames),filePath:n(Le)}}canonicalEntry(Z){let ee=this.canonicalEntries.get(Z);if(ee===void 0)throw Error(`sveld: no entry lists ${Z}.`);return ee}async process(Z){let ee=new Map,Le=await this.parse(Z,ee);this.cache?.save();let Ot=await this.settle(Le);for(let Bt of Z)this.records.delete(Bt),this.parseErrors.delete(Bt);for(let[Bt,jt]of Ot)this.records.set(Bt,jt);for(let[Bt,jt]of ee)this.parseErrors.set(Bt,jt);return Array.from(Ot.keys())}async parse(Z,ee){let Le=await $f(Z),Ot=this.cache,Bt=new Map,jt=new Set;if(Ot)for(let[Lt,Vt]of Le){if(Vt===null)continue;let Wt=$s(Vt);if(Bt.set(Lt,Wt),!Ot.has(Lt,Wt))jt.add(Lt)}if(Z.size>0&&(!Ot||jt.size>0))await Un();let Gt=new Map;for(let Lt of Z){let Vt=Le.get(Lt);if(Vt===null||Vt===void 0)continue;let Wt=this.parseOne(Lt,Vt,Bt.get(Lt),ee);if(Wt)Gt.set(Lt,Wt)}return Gt}parseOne(Z,ee,Le,Ot){let Bt=Le===void 0?null:this.cache?.get(Z,Le);if(Bt)return Bt;let{moduleName:jt,filePath:Gt}=this.canonicalEntry(Z),Lt;try{Lt=new(Nn()).ComponentParser().parse(ee,{moduleName:jt,filePath:Gt})}catch(Vt){if(this.options.failFast)throw Vt;Ot.set(Z,{filePath:Gt,moduleName:jt,message:Vt instanceof Error?Vt.message:String(Vt),stack:Vt instanceof Error?Vt.stack:void 0});return}if(Le!==void 0)this.cache?.set(Z,Le,Lt);return Lt}async settle(Z){let{rootDir:ee,resolveComponentFilePath:Le}=this.collected,Ot=new Map,Bt=new Map;for(let[Vt,{component:Wt,pending:Ut}]of Z){let Ht={...this.canonicalEntry(Vt),...Wt};Ot.set(Vt,Ht),Bt.set(Ht,Ut)}let{checkExamples:jt}=this.options;if(jt){let Vt=await Vp(Ot.values(),jt,ee,Le);for(let[Wt,Ut]of Vt)pi(Wt,Ut)}let Gt=await Fp(Ot.values(),Le,(Vt)=>Bt.get(Vt),this.graph),Lt=new Map;for(let[Vt,Wt]of Ot){let{moduleName:Ut,filePath:Ht,...qt}=Wt,zt=Gt.get(Ht);Lt.set(Vt,zt===void 0?{component:qt}:{component:qt,crossFileReads:zt})}return Lt}assemble(){let{exports:Z,allComponentEntries:ee,resolveComponentFilePath:Le}=this.collected,Ot=this.cache,Bt=(Ht,qt)=>{let{source:zt}=qt[1];if(!di(zt))return;let Xt=this.records.get(Le(zt));if(Xt===void 0)return;return{component:{...this.entryIdentity(Ht,qt),...Xt.component},record:Xt}},jt=new Map,Gt=Ot?new Map:void 0,Lt=Ot?new Map:void 0;for(let Ht of ee){let qt=Bt(ee,Ht);if(qt===void 0)continue;let{filePath:zt}=qt.component;jt.set(zt,qt.component),(qt.record.crossFileReads===void 0?Gt:Lt)?.set(zt,Le(Ht[1].source))}let Vt=sp(jt,Le,this.graph);for(let Ht of jt.values())pi(Ht,[...Vt(Ht),...ip(Ht)]);let Wt=new Map,Ut=Object.entries(Z);for(let Ht of Ut){let qt=Bt(Ut,Ht);if(qt===void 0)continue;let zt=jt.get(qt.component.filePath);if(zt)qt.component.diagnostics=zt.diagnostics;Wt.set(qt.component.moduleName,qt.component)}return{exports:Z,entryExports:this.entryExports,components:Wt,allComponentsForTypes:jt,errors:Array.from(this.parseErrors.values()),diagnostics:wo(ko([...Array.from(jt.values()).flatMap((Ht)=>Ht.diagnostics??[]),...this.entryDiagnostics]),this.options.diagnostics?.ignore),cache:Ot,resolvedPathByFilePath:Gt,crossFileResolvedPathByFilePath:Lt}}}function Bi(Z){return{failFast:Z?.failFast,documentExports:Z?.documentExports===!0,cache:Z?.cache,checkExamples:Z?.checkExamples==="syntax"?"syntax":Z?.checkExamples===!0,diagnostics:Z?.diagnostics}}async function ji(Z,ee,Le={}){return new Fi(Z,ee,Le).build()}import{existsSync as Yr,readFileSync as Nf}from"node:fs";import{isAbsolute as Df,join as Yp}from"node:path";var Vi='sveld: could not resolve a Svelte entry point. Set package.json#svelte, or pass the "entry" option.';function Jp(Z){return Df(Z)?Z:Yp(process.cwd(),Z)}function Re(Z){if(Z){let Bt=Jp(Z);if(Yr(Bt))return{entry:Q(Z)};return{entry:null,configured:!0,message:`Invalid entry point: ${Bt}. Pass a valid --entry (or "entry" option), or unset it and set the "svelte" field in your package.json instead.`}}let ee=Yp(process.cwd(),"package.json");if(!Yr(ee))return{entry:null,configured:!1,message:'Could not locate a package.json file. Specify an entry point with --entry (or the "entry" option).'};let Le;try{Le=lp(JSON.parse(Nf(ee,"utf-8")))}catch(Bt){throw console.error("Error reading package.json:",Bt),Bt}let Ot=Le.svelte?.trim();if(!Ot)return{entry:null,configured:!1,message:'Could not determine an entry point. Set the "svelte" field in your package.json, or pass --entry (or the "entry" option).'};if(!Yr(Jp(Ot)))return{entry:null,configured:!0,message:`The "svelte" field in package.json points to "${Ot}", which does not exist.`};return{entry:Q(Ot)}}function Ns(Z){let ee=Re(Z);if(ee.entry===null)console.error(ee.message);return ee.entry}async function Qp(Z,ee,Le={}){let Ot=new Fi(Z,ee,{...Le,failFast:!1}),Bt=await Ot.build();return{get result(){return Promise.resolve(Bt)},async update(jt){let Gt=await Ot.update(jt);return Bt=Gt.result,Gt}}}import Zr from"node:path";function Zp(Z){let ee=new Map,Le=[];for(let[Ot,Bt]of Object.entries(Z)){if(Bt.star){Le.push(`export * from "${Bt.source}";`);continue}let jt=ee.get(Bt.source)??[];jt.push({id:Ot,exportee:Bt}),ee.set(Bt.source,jt)}for(let[Ot,Bt]of ee){let jt=Pn.test(Ot),Gt=Bt.some(({id:qt,exportee:zt})=>qt!=="default"&&zt.default),Lt=Bt.some(({exportee:qt})=>!qt.default),Vt=jt&&Gt&&Lt,Wt=[],Ut=[],Ht=[];for(let{id:qt,exportee:zt}of Bt){if(qt==="default"){Ut.push(`export { default } from "${Ot}";`);continue}if(zt.default)if(zt.mixed)Ut.push(`export { default as ${qt} } from "${Ot}";`),Ut.push(`export { default } from "${Ot}";`);else Ht.push(`default as ${qt}`);else if(jt&&!Vt)Ht.push(`default as ${qt}`);else Wt.push(qt)}if(Ht.length>0&&Wt.length>0)Le.push(`export { ${[...Ht,...Wt].join(", ")} } from "${Ot}";`);else{if(Wt.length>0)Le.push(`export { ${Wt.join(", ")} } from "${Ot}";`);if(Ht.length>0)Le.push(`export { ${Ht.join(", ")} } from "${Ot}";`)}Le.push(...Ut)}return Le.join(`
138
+ `))}var Wh=[...hi,".svelte"];function Uh(Z){let ee=Z.trim();if(ee.length<2)return;let Le=ee[0],Ot=ee[ee.length-1];if((Le==='"'||Le==="'"||Le==="`")&&Le===Ot)return ee.slice(1,-1);return}function ip(Z){let ee=[],Le=Z.moduleExports.filter((Bt)=>Bt.kind==="re-export");if(Le.length===0)return ee;let Ot=new Set([gi(Z.moduleName),Oi(Z.moduleName)]);for(let Bt of Le){if(!Ot.has(Bt.name))continue;ee.push(a({component:Z.filePath,kind:"module-export-conflict",name:Bt.name,message:`Re-export "${Bt.name}" has the same name as the generated "${Bt.name}" type; the .d.ts won't type-check if "${Bt.reExport?.from}" exports a type by that name.`,source:Bt.source}))}return ee}function sp(Z,ee,Le){let Ot=new Map(Array.from(Z.values()).map((Bt)=>[ee(Bt.filePath),Bt]));return(Bt)=>{let jt=Bt.extends;if(!jt)return[];let Gt=Uh(jt.import);if(Gt===void 0||!Gt.startsWith(".")&&!Gt.startsWith("/"))return[];let Lt=ee(Bt.filePath),Vt=Le.resolve(Gt,Gh(Lt),Wh);if(Vt===null)return[a({component:Bt.filePath,kind:"extend-props-target-missing",name:jt.interface,message:`@extends/@extendProps target "${Gt}" was not found on disk.`})];let Wt=Ot.get(Vt);if(!Wt)return[];let Ut=gi(Wt.moduleName);if(_r(jt.interface)!==Ut)return[a({component:Bt.filePath,kind:"extend-props-target-missing",name:jt.interface,message:`@extends/@extendProps names "${jt.interface}", but "${Gt}" generates "${Ut}".`})];let Ht=[];for(let qt of Bt.props){let zt=Wt.props.find((Xt)=>Xt.name===qt.name);if(zt&&zt.type!==qt.type){let Xt=a({component:Bt.filePath,kind:"extend-props-override",name:qt.name,message:`Own prop "${qt.name}" (${qt.type}) overrides "${Ut}"'s "${qt.name}" (${zt.type}).`,source:qt.source}),Jt=fo(Bt)?.[qt.name]?.some((tn)=>tn===""||tn===Xt.code);Ht.push(Jt?{...Xt,ignored:!0}:Xt)}}return Ht}}import{lstatSync as ud,readFileSync as hd,realpathSync as dd,statSync as fd}from"node:fs";import{dirname as md,isAbsolute as gd,join as Cp,parse as yd,relative as Gr,resolve as Mi}from"node:path";function Q(Z){return Z}function $n(Z){if(Z==="")return Z;return Z==="."||Z===".."||Z.startsWith("./")||Z.startsWith("../")?Z:`./${Z}`}import{readFileSync as Ep}from"node:fs";import{dirname as jr,join as cd,relative as yp,resolve as xp}from"node:path";import{readFileSync as ed,statSync as td}from"node:fs";import{basename as Br,dirname as Cs,isAbsolute as nd,join as id,resolve as sd}from"node:path";import{existsSync as ap,readdirSync as Kh}from"node:fs";import{dirname as rp,join as pp,resolve as Hh}from"node:path";function V(Z,ee){for(let Le=Hh(Z);;Le=rp(Le)){for(let Ot of ee){let Bt=pp(Le,Ot);if(ap(Bt))return Bt}if(rp(Le)===Le)return null}}function op(Z){return Z.normalize("NFC").toLowerCase()}class Rr{listings=new Map;clear(){this.listings.clear()}entries(Z){return this.read(Z)?.entries??null}entry(Z,ee){let Le=this.read(Z);if(Le===null)return;if(Le.byName===void 0){Le.byName=new Map;for(let Ot of Le.entries)Le.byName.set(Ot.name,Ot)}return Le.byName.get(ee)}has(Z,ee){let Le=this.read(Z);if(Le===null)return!1;if(Le.names.has(ee))return!0;if(Le.folded===void 0){Le.folded=new Map;for(let Bt of Le.names)Le.folded.set(op(Bt),Bt)}let Ot=Le.folded.get(op(ee));return Ot!==void 0&&Ot!==ee&&ap(pp(Z,ee))}read(Z){let ee=this.listings.get(Z);if(ee!==void 0)return ee;try{let Le=Kh(Z,{withFileTypes:!0}),Ot=new Set;for(let Bt of Le)Ot.add(Bt.name);ee={entries:Le,names:Ot}}catch{ee=null}return this.listings.set(Z,ee),ee}}var Ir=!1;function q(Z){Ir=Z}function Fn(Z){if(!Ir)console.error(Z)}function cp(Z){if(!Ir)console.error(Z)}function xe(Z){if(Z instanceof e)return Z.start?`${Z.reason} (${Z.start.line}:${Z.start.column})`:Z.reason;return Z instanceof Error?Z.message:String(Z)}var Li=null,Or=null;function Un(){if(Li)return Promise.resolve(Li);if(!Or)Or=import("./chunk-wfd8yb7b.js").then((Z)=>(Li=Z,Z));return Or}function Nn(){if(!Li)throw Error("sveld: internal error, parser stack read before loadParserStack() resolved.");return Li}import{existsSync as Lr,readFileSync as qh}from"node:fs";import{dirname as fp,isAbsolute as mp,relative as zh,resolve as Mr}from"node:path";function lp(Z){if(!r(Z))return{};let ee={};if(typeof Z.svelte==="string")ee.svelte=Z.svelte;if(typeof Z.name==="string")ee.name=Z.name;if(typeof Z.description==="string")ee.description=Z.description;return ee}function up(Z){if(!r(Z))return{};let ee={};if(typeof Z.extends==="string")ee.extends=Z.extends;if(r(Z.compilerOptions)){let Le={};if(typeof Z.compilerOptions.baseUrl==="string")Le.baseUrl=Z.compilerOptions.baseUrl;if(r(Z.compilerOptions.paths)){let Ot={};for(let[Bt,jt]of Object.entries(Z.compilerOptions.paths))if(Array.isArray(jt)&&jt.every((Gt)=>typeof Gt==="string"))Ot[Bt]=jt;if(Object.keys(Ot).length>0)Le.paths=Ot}if(Object.keys(Le).length>0)ee.compilerOptions=Le}return ee}var Xh=["tsconfig.json","jsconfig.json"],hp=new Map,Jh=/\/\*[\s\S]*?\*\/|\/\/.*/g,Yh=[".svelte",...hi];class G extends Error{specifier;fromFile;searched;constructor(Z,ee,Le){super(`cannot resolve "${Z}" from ${ee||"."} (${Le})`);this.name="UnresolvedModuleError",this.specifier=Z,this.fromFile=ee,this.searched=Le}}function Qh(Z){if(Lr(Z))return!0;return Yh.some((ee)=>Lr(Z+ee))}function dp(Z){let ee=Z.indexOf("*");return ee===-1?Z.length:ee}function gp(Z,ee){if(ee.has(Z))return ee.get(Z)??null;try{let Le=qh(Z,"utf-8"),Ot;try{Ot=JSON.parse(Le)}catch{let jt=Le.replace(Jh,"");Ot=JSON.parse(jt)}let Bt=up(Ot);if(Bt.extends){let jt=mp(Bt.extends)?Bt.extends:Mr(fp(Z),Bt.extends),Gt=jt.endsWith(".json")?jt:`${jt}.json`;if(Lr(Gt)){let Lt=gp(Gt,ee);if(Lt)Bt.compilerOptions={...Lt.compilerOptions,...Bt.compilerOptions,paths:{...Lt.compilerOptions?.paths,...Bt.compilerOptions?.paths}}}}return ee.set(Z,Bt),Bt}catch{return ee.set(Z,null),null}}function Zh(Z){let ee=hp.get(Z);if(!ee){let Le=Z.split("*").map(N).join("(.*)");ee=new RegExp(`^${Le}$`),hp.set(Z,ee)}return ee}class Fr{configs=new Map;lookup(Z,ee){if(Z.startsWith(".")||mp(Z))return{resolved:Z,unresolved:!1,searched:""};let Le=V(ee,Xh),Ot=Le?gp(Le,this.configs)?.compilerOptions:void 0,Bt=Ot?.paths;if(!Le||!Ot||!Bt)return{resolved:Z,unresolved:!0,searched:"no tsconfig/jsconfig paths found"};let jt=Mr(fp(Le),Ot.baseUrl??"."),Gt=Object.entries(Bt).sort(([Lt],[Vt])=>dp(Vt)-dp(Lt));for(let[Lt,Vt]of Gt){let Wt=Z.match(Zh(Lt));if(!Wt)continue;let Ut;for(let Ht of Vt){let qt=Ht;for(let Xt=1;Xt<Wt.length;Xt++)qt=qt.replace("*",Wt[Xt]);let zt=Mr(jt,qt);if(Ut??=zt,Qh(zt))return{resolved:zt,unresolved:!1,searched:Le}}return{resolved:Ut??Z,unresolved:!1,searched:Le}}return{resolved:Z,unresolved:!0,searched:`tsconfig paths (${Le})`}}absolute(Z,ee){return this.lookup(Z,ee).resolved}relative(Z,ee){let Le=this.absolute(Z,ee);if(Le===Z)return Z;return $n(n(zh(ee,Le)))}}var rd=/\.[mc]?jsx?$/,od={".js":[".ts",".tsx",".d.ts"],".jsx":[".tsx",".d.ts"],".mjs":[".mts",".d.mts"],".cjs":[".cts",".d.cts"]};function ad(Z){return Z==="."||Z===".."||Z.startsWith("./")||Z.startsWith("../")||nd(Z)}class Kn{aliases=new Fr;listings=new Rr;modules=new Map;programs=new Map;listDirectory(Z){return this.listings.entries(Z)}exists(Z){return this.listings.has(Cs(Z),Br(Z))}resolve(Z,ee,Le=hi){let Ot=this.aliases.absolute(Z,ee);if(Ot===Z&&!ad(Z))return null;let Bt=sd(ee,Ot),jt=Cs(Bt),Gt=Br(Bt),Lt=this.listings.has(jt,Gt),Vt;if(Lt){let Wt=this.listings.entry(jt,Gt);if(Vt=Wt&&!Wt.isSymbolicLink()?Wt:td(Bt,{throwIfNoEntry:!1}),Vt?.isFile())return Bt}for(let Wt of Le)if(this.listings.has(jt,Gt+Wt))return Bt+Wt;if(!Lt)return this.typeScriptCounterpart(Bt)??null;if(Vt?.isDirectory()){for(let Wt of Le)if(this.listings.has(Bt,`index${Wt}`))return id(Bt,`index${Wt}`)}return null}parse(Z){let ee=this.modules.get(Z);if(ee===void 0)ee=pd(Z),this.modules.set(Z,ee);return ee}parseJavaScript(Z,ee){let Le=this.programs.get(Z);if(Le?.source===ee)return Le.ast;let Ot;try{Ot=me(ee)}catch(Bt){throw Error(xe(Bt))}return this.programs.set(Z,{source:ee,ast:Ot}),Ot}invalidate(...Z){this.listings.clear();for(let ee of Z)this.modules.delete(ee),this.programs.delete(ee)}typeScriptCounterpart(Z){let ee=rd.exec(Z)?.[0];if(ee===void 0)return;let Le=Z.slice(0,-ee.length),Ot=Cs(Le),Bt=Br(Le);for(let jt of od[ee]??[])if(this.listings.has(Ot,Bt+jt))return Le+jt;return}}function pd(Z){let ee;try{ee=ed(Z,"utf-8")}catch{return null}try{let Le=Z.endsWith(".svelte")?Nn().parseSvelteScripts(ee).module?.content.body??[]:Nn().parseModule(ee,{typescript:!0}).body;return{source:{text:ee,filePath:Z,dir:Cs(Z)},body:Le}}catch(Le){return cp(`Warning: sveld couldn't parse ${Z} to read its exports (${xe(Le)}); skipping it.`),null}}function vp(Z){return Z.type==="Identifier"?Z.name:Z.value}function ld(Z,ee,Le,Ot){let Bt=Z.resolve(ee,Le);if(!Bt)return null;let jt=jr(Bt);if(Ot.has(Bt))return{dir:jt,exports:{}};Ot.add(Bt);try{return{dir:jt,exports:Vr(Z,Ep(Bt,"utf-8"),jt,Ot,Bt)}}catch{return{dir:jt,exports:{}}}finally{Ot.delete(Bt)}}function Sp(Z,ee,Le=new Kn,Ot=new Set,Bt=ee){return Vr(Le,Z,ee,Ot,Bt)}function Vr(Z,ee,Le,Ot,Bt){let jt=Z.parseJavaScript(Bt,ee),Gt={};for(let Lt of jt.body)if(Lt.type==="ExportDefaultDeclaration"){if(Lt.declaration.type!=="Identifier")continue;let Vt=Lt.declaration.name;if(Vt in Gt)Gt[Vt].default=!0;else Gt[Vt]={source:$n(""),default:!0}}else if(Lt.type==="ExportAllDeclaration"){let Vt=Lt.source.value,Wt=Z.resolve(Vt,Le);if(!Wt){let zt=Z.aliases.lookup(Vt,Le);throw new G(Vt,Bt,zt.unresolved?zt.searched:"no matching file or index found")}if(Ot.has(Wt))continue;Ot.add(Wt);let Ut=Ep(Wt,"utf-8"),Ht=Vr(Z,Ut,jr(Wt),Ot,Wt);Ot.delete(Wt);let qt=Object.entries(Ht);if(qt.length===0&&!Pn.test(Vt)){let zt=$n(n(Vt));Gt[`*:${Vt}`]={source:zt,default:!1,star:!0}}for(let[zt,Xt]of qt){let Yt=$n(n(Xt.source.startsWith(".")?`./${yp(Le,xp(jr(Wt),Xt.source))}`:`./${cd(Vt,Xt.source)}`));Gt[zt]={...Xt,source:Yt}}}else if(Lt.type==="ExportNamedDeclaration"){let Vt=Lt.source?.value,Wt=Vt!==void 0&&Pn.test(Vt);if(Wt){let qt=Z.aliases.lookup(Vt,Le);if(qt.unresolved)throw new G(Vt,Bt,qt.searched)}let Ht=Vt!==void 0&&!Wt?ld(Z,Vt,Le,Ot):void 0;if(Ht===null){console.warn(`sveld: could not resolve re-exported module "${Vt}" from barrel "${Le||"."}"; skipping.`);continue}for(let qt of Lt.specifiers){let zt=vp(qt.exported),Xt=vp(qt.local),Yt=zt||Xt,Jt=Ht?.exports[Xt],tn=Jt?$n(n(`./${yp(Le,xp(Ht.dir,Jt.source))}`)):$n(Z.aliases.relative(Vt??"",Le)),sn=Jt?Jt.default:Xt==="default";if(Yt in Gt){if(Gt[Yt].mixed=!0,!Gt[Yt].source)Gt[Yt].source=tn}else Gt[Yt]={source:tn,default:sn}}}else if(Lt.type==="ImportDeclaration"){let Vt=Lt.specifiers[0];if(!Vt)continue;let Wt=Vt.local.name,Ut=$n(Z.aliases.relative(Lt.source.value,Le));if(Wt in Gt){if(!Gt[Wt].source)Gt[Wt].source=Ut}else Gt[Wt]={source:Ut,default:Wt==="default"}}return Gt}var xd=/-/g,vd=/[^A-Za-z0-9_$]/g,Ed=/^[0-9]/;function Sd(Z,ee){let Le=Z.replace(vd,""),Ot=Ed.test(Le)?`_${Le}`:Le;if(Ot!==Z&&!ee?.has(Z))ee?.add(Z),console.warn(`Warning: "${Z}" is not a valid identifier; using "${Ot}" instead.`);return Ot}function bp(Z,ee){return Sd(yd(Z).name.replace(xd,""),ee)}function wp(Z,ee,Le=[],Ot=new Set,Bt){let jt;try{jt=Bt??dd(ee)}catch{return Le}if(Ot.has(jt))return Le;Ot.add(jt);let Gt=Z.listDirectory(ee);if(Gt===null)return Le;for(let Lt of Gt){if(Lt.name.startsWith("."))continue;let Vt=Cp(ee,Lt.name),Wt=Lt.isSymbolicLink(),Ut=Wt?fd(Vt,{throwIfNoEntry:!1}):Lt;if(!Ut)continue;if(Ut.isDirectory())wp(Z,Vt,Le,Ot,Wt?void 0:Cp(jt,Lt.name));else if(Ut.isFile()&&Lt.name.endsWith(".svelte"))Le.push(Vt)}return Le}function Cd(Z,ee){return wp(Z,ee).map((Le)=>({moduleName:bp(Le),source:$n(n(`./${Gr(ee,Le)}`))})).sort((Le,Ot)=>u(Le.source,Ot.source))}function bd(Z){return!di(Z)}function wd(Z,ee){let Le=Z.endsWith("/")?Z:`${Z}/`;return ee.startsWith(Le)}function bs(Z,ee){return{seenPaths:new Set(Z.map(([,Le])=>ee(Le.source))),seenModuleNamePaths:new Map(Z.map(([Le,Ot])=>[Le,ee(Ot.source)])),warnedModuleNames:new Set}}function Wr(Z,ee,Le,Ot,Bt,jt){for(let{moduleName:Gt,source:Lt}of Cd(Z,ee)){let Vt=Bt(Lt),Wt=Le[Gt];if(Wt&&bd(Wt.source)&&wd(Wt.source,Lt)){jt.seenPaths.delete(Bt(Wt.source)),Wt.source=Lt,jt.seenPaths.add(Vt),jt.seenModuleNamePaths.set(Gt,Vt);continue}if(jt.seenPaths.has(Vt))continue;jt.seenPaths.add(Vt);let Ut=jt.seenModuleNamePaths.get(Gt);if(Ut===void 0)jt.seenModuleNamePaths.set(Gt,Vt);else if(Ut!==Vt&&!jt.warnedModuleNames.has(Gt))jt.warnedModuleNames.add(Gt),console.warn(`Warning: multiple components named "${Gt}" found (${n(Gr(ee,Ut))} and ${n(Gr(ee,Vt))}). Both are included in TypeScript definitions, but only one can be the named export.`);Ot.push([Gt,{source:Lt,default:!1}])}}function Ur(Z,ee,Le,Ot){let Bt=ud(Z).isFile(),jt=Bt?md(Z):Z,Gt=Mi(jt),Lt=new Map,Vt=(Ht)=>{let qt=Lt.get(Ht);if(qt===void 0)qt=gd(Ht)?Mi(Ht):Mi(Gt,Ht),Lt.set(Ht,qt);return qt},Wt={};if(Bt){let Ht=hd(Z,"utf-8");try{Wt=Sp(Ht,Gt,Ot,new Set([Mi(Z)]),Mi(Z))}catch(qt){if(!Le)throw qt;let zt=qt instanceof Error?qt.message:String(qt);console.warn(`Warning: Failed to parse component exports from ${Z}: ${zt}`)}}let Ut=Object.entries(Wt);if(ee){let Ht=bs(Ut,Vt);if(Wr(Ot,Gt,Wt,Ut,Vt,Ht),!Bt)Wt=Object.fromEntries(Ut.map(([qt,zt])=>[qt,{...zt,default:!0}]))}return{exports:Wt,allComponentEntries:Ut,rootDir:Gt,resolveComponentFilePath:Vt}}function Tp(Z,ee,Le,Ot){if(Le!==1||Z!=="default")return Z;return bp(ee,Ot)}import{dirname as of}from"node:path";import{resolve as Td}from"node:path";var kd=/\r?\n/,Ad=/^\s*\*+/;function ws(Z){return{graph:Z,cache:new Map,computing:new Set}}function gn(Z){return Z?.type==="Identifier"?Z.name:void 0}function Pd(Z){let ee=Z.trimEnd();for(;;){let Le=ee.lastIndexOf(`
139
+ `)+1;if(ee.slice(Le).trimStart().startsWith("//")){ee=ee.slice(0,Le).trimEnd();continue}let Ot=ee.endsWith("*/")?ee.lastIndexOf("/*",ee.length-3):-1;if(Ot!==-1&&ee[Ot+2]!=="*"){ee=ee.slice(0,Ot).trimEnd();continue}return ee}}function _d(Z,ee){let Le=Pd(Z.slice(0,ee));if(!Le.endsWith("*/"))return;let Ot=Le.length-2,Bt=Le.lastIndexOf("/**",Ot);if(Bt===-1)return;return Le.slice(Bt,Ot+2)}function $d(Z){let ee=[];for(let Le of Z.slice(3,-2).split(kd)){let Ot=Le.replace(Ad,"").trim();if(Ot.startsWith("@"))break;if(Ot)ee.push(Ot)}return ee.join(" ")||void 0}function ti(Z,ee){if(!ee)return;return Z.text.slice(ee.start,ee.end)}function Nd(Z,ee){return"typeAnnotation"in ee?ti(Z,ee.typeAnnotation?.typeAnnotation):void 0}function Ap(Z,ee){return ti(Z,ee.returnType?.typeAnnotation)}function Kr(Z,ee,Le){return`(${ee.params.map((Bt)=>ti(Z,Bt)??"").join(", ")}) => ${Ap(Z,ee)??Le??"any"}`}function Pp(Z){if(Z.type==="Literal"){let ee=Z.value;if(typeof ee==="string")return"string";if(typeof ee==="number")return"number";if(typeof ee==="boolean")return"boolean"}if(Z.type==="TemplateLiteral")return"string";if(Z.type==="UnaryExpression"&&(Z.operator==="-"||Z.operator==="+"))return Z.argument.type==="Literal"&&typeof Z.argument.value==="number"?"number":void 0;if(Z.type==="CallExpression"&&Z.callee.type==="Identifier")return Dd[Z.callee.name];return}var Dd={String:"string",Number:"number",Boolean:"boolean"};function _p(Z){if(Z.type==="Literal"){let ee=Z.value;return typeof ee==="string"||typeof ee==="number"||typeof ee==="boolean"?ee:void 0}if(Z.type==="UnaryExpression"&&Z.operator==="-"){let ee=Z.argument;return ee.type==="Literal"&&typeof ee.value==="number"?-ee.value:void 0}return Z.type==="TemplateLiteral"?T(Z)??void 0:void 0}function Rd(Z,ee){let Le=ti(Z,ee),Ot=_p(ee);if(Le===void 0||Ot===void 0)return;return{raw:Le,value:Ot,type:typeof Ot}}function Id(Z,ee){if(Z.type!=="CallExpression"&&Z.type!=="NewExpression")return;let Le=Z.callee;if(!(gn(Le)==="Symbol"||Le.type==="MemberExpression"&&!Le.computed&&gn(Le.object)==="Symbol"&&gn(Le.property)==="for"))return;let[Bt]=Z.arguments;return(Bt?.type==="Literal"&&typeof Bt.value!=="string"?null:T(Bt))||ee}var Od=new Set(["any","bigint","boolean","false","never","null","number","object","readonly","string","symbol","true","undefined","unknown","void"]),Ld=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,Md=/(?<![\w$.])[A-Za-z_$][\w$]*(?![\w$]|\s*\??:)/g;function Fd(Z,ee){let Le=ee?Nn().extractJsDocType(ee):void 0,Ot=Z?{type:Z,source:"typescript"}:Le?{type:Le,source:"jsdoc"}:void 0;if(!Ot||Ot.type.includes("`"))return;return(Ot.type.replace(Ld,'""').match(Md)??[]).every((jt)=>Od.has(jt))?Ot:void 0}function $p(Z){if(Z.async||Z.generator||Z.type==="TSDeclareFunction")return;let ee=Z.body,Le=ee.type==="BlockStatement"?Y(ee):[ee];if(Le.length===0)return;let Ot;for(let Bt of Le){if(!Bt)return;let jt=Pp(Bt);if(!jt)return;if(Ot===void 0)Ot=jt;else if(Ot!==jt)return}return Ot}function Bd(Z){if(Z.type==="TemplateLiteral")return;let ee=_p(Z);return typeof ee==="boolean"?void 0:ee}function jd(Z){let ee=Z.members;if(ee.length===0)return;let Le=[],Ot=0;for(let Bt of ee){if(!Bt.initializer){Le.push(String(Ot)),Ot+=1;continue}let jt=Bd(Bt.initializer);if(jt===void 0)return;Le.push(typeof jt==="string"?JSON.stringify(jt):String(jt)),Ot=typeof jt==="number"?jt+1:Ot}return Le.join(" | ")}function Hr(Z,ee,Le,Ot){let Bt=_d(Z.text,Le),jt=Bt?$d(Bt):void 0,Gt=Bt?Nn().extractJsDocReturnType(Bt):void 0,{deprecated:Lt,tags:Vt,internal:Wt}=Bt?Nn().extractJsDocDeprecatedAndTags(Bt):{deprecated:void 0,tags:void 0,internal:!1},Ut={description:jt,deprecated:Lt,tags:Vt,...Wt?{internal:!0}:{},declFile:Z.filePath},Ht=(zt,Xt,Yt=!1)=>zt?[{name:zt,...Xt,...Ut,isTypeOnly:Yt}]:[],qt=(zt,Xt)=>Ap(Z,zt)??Gt??re(Xt)??$p(zt);if(ee.type==="VariableDeclaration"){let zt=ee.kind==="let"||ee.kind==="var"?ee.kind:"const";return ee.declarations.flatMap((Xt)=>{let Yt=Xt.id,Jt=gn(Yt);if(!Jt)return[];let tn=Nd(Z,Yt),sn=tn,ln,cn,un,On,zn,Bn,yn=Xt.init;if(yn)if(yn.type==="ArrowFunctionExpression"||yn.type==="FunctionExpression"){if(Bn=yn,cn=qt(yn,sn),!sn)sn=Kr(Z,yn,cn)}else{if(ln=ti(Z,yn),!sn)sn=Pp(yn);let Zt=C(yn);if(un=T(Zt)??Id(Zt,Jt),zt==="const")On=Rd(Z,Zt),zn=Fd(tn,Bt)}return Ht(Jt,{kind:zt,type:sn,value:ln,returnType:cn,literalValue:un,primitiveLiteral:On,declaredType:zn,functionNode:Bn})})}if(ee.type==="FunctionDeclaration"||ee.type==="TSDeclareFunction"){let zt=qt(ee);return Ht(gn(ee.id)??Ot,{kind:"function",type:Kr(Z,ee,zt),returnType:zt,...ee.type==="FunctionDeclaration"?{functionNode:ee}:{}})}if(ee.type==="ClassDeclaration"){let zt=gn(ee.id);return Ht(zt??Ot,{kind:"class",...zt?{type:zt}:{}})}if(ee.type==="TSTypeAliasDeclaration")return Ht(gn(ee.id),{kind:"type",type:ti(Z,ee.typeAnnotation)},!0);if(ee.type==="TSInterfaceDeclaration")return Ht(gn(ee.id),{kind:"interface",type:ti(Z,ee.body)},!0);if(ee.type==="TSEnumDeclaration"){let zt=gn(ee.id);return Ht(zt,{kind:"enum",type:jd(ee)??zt})}return[]}function Vd(Z,ee,Le){let Ot=ee.declaration;if(Ot.type==="FunctionDeclaration"||Ot.type==="TSDeclareFunction"||Ot.type==="ClassDeclaration"){let[Gt]=Hr(Z,Ot,ee.start,"default");return Gt?{...Gt,name:"default"}:void 0}if(Ot.type==="FunctionExpression"||Ot.type==="ArrowFunctionExpression")return{name:"default",kind:"function",type:Kr(Z,Ot,$p(Ot)),functionNode:Ot,declFile:Z.filePath,isTypeOnly:!1};let Bt=gn(Ot),jt=Bt?Le(Bt):null;return jt?{...jt,name:"default"}:void 0}function Gd(Z,ee){for(let Le of Z){if(Le.type!=="ImportDeclaration")continue;let Ot=Le.source.value;for(let Bt of Le.specifiers){if(Bt.local.name!==ee)continue;let jt=Le.importKind==="type"||Bt.type==="ImportSpecifier"&&Bt.importKind==="type";if(Bt.type==="ImportDefaultSpecifier")return{specifier:Ot,importedName:"default",isTypeOnly:jt};if(Bt.type==="ImportNamespaceSpecifier")return{specifier:Ot,importedName:"*",isTypeOnly:jt};if(Bt.type==="ImportSpecifier"){let Gt=gn(Bt.imported)??ee;return{specifier:Ot,importedName:Gt,isTypeOnly:jt}}}}return null}function kp(Z,ee,Le){return{name:Z,kind:"const",declFile:ee,namespaceFile:ee,isTypeOnly:Le}}function Ts(Z,ee){let Le=ee.cache.get(Z);if(Le)return Le;if(ee.computing.has(Z))return[];ee.computing.add(Z);let Ot=ee.graph.parse(Z);if(!Ot)return ee.computing.delete(Z),ee.cache.set(Z,[]),[];let{source:Bt,body:jt}=Ot,Gt=[],Lt=new Map;for(let qt of jt){let zt=qt.type==="ExportNamedDeclaration"?qt.declaration:qt;if(!zt)continue;for(let Xt of Hr(Bt,zt,zt.start))Lt.set(Xt.name,Xt)}let Vt=(qt,zt)=>({name:qt,kind:"const",declFile:Td(Bt.dir,zt),isTypeOnly:!1}),Wt=(qt)=>{let zt=Lt.get(qt);if(zt)return zt;let Xt=Gd(jt,qt);if(!Xt)return null;if(Xt.specifier.endsWith(".svelte"))return Vt(qt,Xt.specifier);let Yt=ee.graph.resolve(Xt.specifier,Bt.dir);if(!Yt)return null;if(Xt.importedName==="*")return kp(qt,Yt,Xt.isTypeOnly);return ni(Yt,Xt.importedName,ee)??null},Ut=new Map;for(let qt of jt){if(qt.type==="ExportAllDeclaration"){let Jt=qt.source.value;if(Jt.endsWith(".svelte"))continue;let tn=ee.graph.resolve(Jt,Bt.dir);if(!tn)continue;let sn=qt.exportKind==="type",ln=gn(qt.exported);if(ln){Gt.push(kp(ln,tn,sn));continue}for(let cn of Ts(tn,ee)){let un=Ut.get(cn.name)??[];un.push(sn?{...cn,isTypeOnly:!0}:cn),Ut.set(cn.name,un)}continue}if(qt.type==="ExportDefaultDeclaration"){let Jt=Vd(Bt,qt,Wt);if(Jt)Gt.push(Jt);continue}if(qt.type!=="ExportNamedDeclaration")continue;let zt=qt.declaration;if(zt){Gt.push(...Hr(Bt,zt,qt.start));continue}let Xt=qt.source?.value;if(Xt?.endsWith(".svelte")){for(let Jt of qt.specifiers){let tn=gn(Jt.exported);if(tn)Gt.push(Vt(tn,Xt))}continue}let Yt=qt.exportKind==="type";for(let Jt of qt.specifiers){let tn=gn(Jt.exported),sn=gn(Jt.local);if(!tn||!sn)continue;let ln=Yt||Jt.exportKind==="type",cn=null;if(Xt){let un=ee.graph.resolve(Xt,Bt.dir);if(un)cn=ni(un,sn,ee)??null}else cn=Wt(sn);if(cn)Gt.push({...cn,name:tn,isTypeOnly:cn.isTypeOnly||ln});else if(sn!=="default")Gt.push({name:tn,kind:ln?"type":"const",declFile:Z,isTypeOnly:ln})}}let Ht=new Set(Gt.map((qt)=>qt.name));for(let[qt,zt]of Ut){if(Ht.has(qt)||qt==="default")continue;if(zt.every((Xt)=>Xt.declFile===zt[0].declFile))Gt.push(...zt);else ee.onAmbiguousStarExport?.(Z,qt,zt)}return ee.computing.delete(Z),ee.cache.set(Z,Gt),Gt}function ni(Z,ee,Le){return Ts(Z,Le).findLast((Ot)=>Ot.name===ee)}function yi(Z,{importedName:ee,members:Le=[]},Ot){let Bt=ni(Z,ee,Ot);for(let jt of Le){if(Bt?.namespaceFile===void 0)return;Bt=ni(Bt.namespaceFile,jt,Ot)}return Bt}function Hn(Z,ee,Le){if(Z[ee]===void 0)delete Z[ee];Z[ee]=Le}function ks(Z,ee){return(ee.location==="props"?Z.props:Z.moduleExports).find((Ot)=>Ot.name===ee.propName)}function As(Z,ee){if(ee.location!=="props")return;Z.diagnostics=(Z.diagnostics??[]).filter((Le)=>!(Le.kind==="prop-unknown-type"&&Le.name===ee.propName))}var Wd=/\.[^./\\]+$/;function Ud(Z,ee){if(Z.endsWith(".d.ts"))return null;let Le=Z.replace(Wd,".d.ts");return ee.exists(Le)?Le:null}function Kd(Z,ee,Le){return ee.map((Ot)=>{if(!Ot.importSource||!Ot.importedName)return{candidate:Ot};let Bt=Le.graph.resolve(Ot.importSource,Z);if(!Bt)return{candidate:Ot,failureReason:"module-not-found"};let jt=ni(Bt,Ot.importedName,Le);if(!jt)return{candidate:Ot,failureReason:"export-not-found"};if(jt.returnType)return{candidate:Ot,type:jt.returnType};let Gt=Ud(Bt,Le.graph);if(Gt){let Lt=ni(Gt,Ot.importedName,Le);if(Lt?.returnType)return{candidate:Ot,type:Lt.returnType}}return{candidate:Ot,failureReason:"return-type-unresolved"}})}function Hd(Z,ee){switch(ee){case"module-not-found":return`Prop "${Z.propName}" default calls "${Z.calleeName}()", but "${Z.importSource}" could not be resolved; falling back to "any".`;case"export-not-found":return`Prop "${Z.propName}" default calls "${Z.calleeName}()", but "${Z.importedName}" is not exported from "${Z.importSource}"; falling back to "any".`;case"return-type-unresolved":return`Prop "${Z.propName}" default calls "${Z.calleeName}()" imported from "${Z.importSource}", but its return type could not be resolved; falling back to "any".`}}function qd(Z,ee){for(let{candidate:Le,type:Ot,failureReason:Bt}of ee){let jt=ks(Z,Le);if(jt?.typeSource!=="unknown")continue;if(Ot){Hn(jt,"type",Ot),Hn(jt,"typeSource","typescript"),As(Z,Le);continue}if(Le.location==="props"&&Bt){let Gt=Z.diagnostics?.find((Lt)=>Lt.kind==="prop-unknown-type"&&Lt.name===Le.propName);if(Gt)Gt.message=Hd(Le,Bt)}}}var Np={collect:(Z)=>Z.pendingCallDefaultCandidates?.filter((ee)=>ee.importSource!==void 0)??[],resolve:Kd,apply:qd};function zd(Z,ee,Le){return ee.map((Ot)=>{let Bt=Le.graph.resolve(Ot.importSource,Z);if(!Bt)return{candidate:Ot};let jt=yi(Bt,Ot,Le);if(!jt?.primitiveLiteral)return{candidate:Ot};return{candidate:Ot,literal:jt.primitiveLiteral,declaredType:jt.declaredType}})}function Xd(Z,ee){for(let{candidate:Le,literal:Ot,declaredType:Bt}of ee){if(!Ot)continue;let jt=ks(Z,Le);if(!jt)continue;if(Hn(jt,"value",Ot.raw),Hn(jt,"defaultValue",{raw:Ot.raw,kind:"literal",value:Ot.value}),jt.typeSource!=="unknown")continue;Hn(jt,"type",Bt?.type??Ot.type),Hn(jt,"typeSource",Bt?.source??"default"),As(Z,Le)}}var Dp={collect:(Z)=>Z.pendingConstDefaultCandidates??[],resolve:zd,apply:Xd};function Jd(Z,ee,Le){return ee.map((Ot)=>{let Bt=Le.graph.resolve(Ot.importSource,Z);if(!Bt)return{candidate:Ot};let jt=yi(Bt,Ot,Le);if(jt?.kind!=="const"||jt.literalValue===void 0)return{candidate:Ot};return{candidate:Ot,key:jt.literalValue}})}function Yd(Z,ee){for(let{candidate:Le,key:Ot}of ee){if(!Ot){let Lt=oe(Le);pi(Z,[a({component:Z.filePath,kind:"context-key-unresolved",name:Lt,message:`setContext key \`${Lt}\` from "${Le.importSource}" isn't an \`export const\` string or Symbol() sveld can read; the context is skipped.`,...Le.source?{source:Le.source}:{}})]);continue}let Bt=[...Z.contexts??[]],jt=Bt.findIndex((Lt)=>Lt.key===Ot);if(jt!==-1){let Lt=Bt[jt],Vt=Rp(Lt.source,Le.source),Wt=Vt?Lt.source:Le.source;if(pi(Z,[a({component:Z.filePath,kind:"context-duplicate-key",name:Ot,message:`setContext("${Ot}", ...) was called more than once; only the first call's shape is used.`,...Wt?{source:Wt}:{}})]),!Vt)continue;Bt.splice(jt,1)}let Gt=Bt.findIndex((Lt)=>Rp(Lt.source,Le.source));Bt.splice(Gt===-1?Bt.length:Gt,0,{key:Ot,typeName:J(Ot),...Le.type===void 0?{}:{type:Le.type},description:Le.description,properties:Le.properties,...Le.hasUnresolvedSpread?{hasUnresolvedSpread:!0}:{},...Le.internal?{internal:!0}:{},source:Le.source}),Z.contexts=Bt}}function Rp(Z,ee){if(!Z||!ee)return!1;let{line:Le,column:Ot}=Z.start;return Le>ee.start.line||Le===ee.start.line&&Ot>ee.start.column}var Ip={collect:(Z)=>Z.pendingContextKeyCandidates??[],resolve:Jd,apply:Yd};function Qd(Z,ee,Le){return ee.map((Ot)=>{let Bt=Le.graph.resolve(Ot.importSource,Z);if(!Bt)return{candidate:Ot,failureReason:"module-not-found"};let jt=yi(Bt,Ot,Le)?.functionNode;if(!jt)return{candidate:Ot,failureReason:"not-a-function"};let Gt=Zd(jt,Ot);if(!Gt)return{candidate:Ot,failureReason:"parameter-not-found"};return nf(jt,Gt,Ot)})}function Op(Z){return Z?.type==="AssignmentPattern"?Z.left:Z}function Zd(Z,ee){let Le=Op(Z.params[ee.argumentIndex]);if(ee.property===void 0)return Le?.type==="Identifier"?{name:Le.name}:void 0;if(!ee.property)return;if(Le?.type==="Identifier")return{object:Le.name,property:ee.property};if(Le?.type!=="ObjectPattern")return;for(let Ot of Le.properties){if(Ot.type!=="Property"||Ot.computed)continue;if(Ot.key.type!=="Identifier"||Ot.key.name!==ee.property)continue;let Bt=Op(Ot.value);return Bt?.type==="Identifier"?{name:Bt.name}:void 0}return}function qr(Z){if(!Z)return null;if(Z.type==="ConditionalExpression"){let Le=qr(Z.consequent),Ot=qr(Z.alternate);return Le&&Ot?[...Le,...Ot]:null}let ee=T(Z);return ee?[ee]:null}var ef={variableType:()=>{return}};function tf(Z){if(!Z)return"null";let{deriveLiteralDetailType:ee,literalDetailToTypeText:Le}=Nn();if(Z.type==="Literal")return Le(Z.value);return ee(ef,Z)??"any"}function Lp(Z,ee){if("name"in ee)return Z.type==="Identifier"&&Z.name===ee.name;if(Z.type!=="MemberExpression"||Z.computed)return!1;return Z.object.type==="Identifier"&&Z.object.name===ee.object&&Z.property.type==="Identifier"&&Z.property.name===ee.property}function nf(Z,ee,Le){let Ot=new Map,Bt="name"in ee?ee.name:ee.object,jt;if(o(Z.body,{enter(Lt,Vt,Wt){if(Lt.type==="CallExpression"){if(!Lp(Lt.callee,ee))return;let Ht=Lt.arguments,qt=qr(Ht[0]);if(!qt)return jt="dynamic-event-name",E;for(let zt of qt){let Xt=Ot.get(zt)??new Set;Xt.add(tf(Ht[1])),Ot.set(zt,Xt)}return}let Ut=Vt?.type==="CallExpression"&&Wt==="callee";if(Lt.type==="MemberExpression"&&Lp(Lt,ee)&&!Ut)return jt="passed-on",E;if(Lt.type!=="Identifier"||Lt.name!==Bt)return;if(Ut)return;if(!("name"in ee)&&Vt?.type==="MemberExpression"&&Wt==="object")return;if(!H(Lt,Vt))return;return jt="passed-on",E}}),jt)return{candidate:Le,failureReason:jt};let Gt=Array.from(Ot,([Lt,Vt])=>{let Wt=Array.from(Vt);return{name:Lt,detail:Wt.includes("any")?"any":Wt.join(" | ")}});return{candidate:Le,events:Gt}}function sf(Z,ee){let Le=Z.members?`"${Z.calleeText}"`:Z.importedName==="default"?"the default export":`"${Z.importedName}"`;switch(ee){case"module-not-found":return`"${Z.importSource}" isn't a local module sveld can read`;case"not-a-function":return`${Le} isn't a function declared in "${Z.importSource}"`;case"parameter-not-found":return`no parameter of ${Le} receives it`;case"dynamic-event-name":return"an event name isn't a string literal";case"passed-on":return`${Le} passes it on`}}function rf(Z,ee,{deferredEventNoSourceDiagnostics:Le=[],untypedJsDocEventNames:Ot=[]}){let Bt=new Map,jt=[...Z.diagnostics??[]],Gt=!0;for(let{candidate:zt,events:Xt,failureReason:Yt}of ee){if(Yt){Gt=!1,jt.push(a({component:Z.filePath,kind:"dispatch-escapes",name:zt.dispatcherName,message:`\`${zt.dispatcherName}\` is passed to \`${zt.calleeText}\`, but sveld couldn't read the events it dispatches: ${sf(zt,Yt)}. Document them with @event tags.`,...zt.source?{source:zt.source}:{},...zt.ignored?{ignored:!0}:{}}));continue}for(let Jt of Xt??[]){if(Bt.has(Jt.name))continue;Bt.set(Jt.name,{type:"dispatched",name:Jt.name,detail:Jt.detail,...zt.source?{source:zt.source}:{}})}}if(Gt){for(let zt of Le)if(!Bt.has(zt.name))jt.push(zt)}if(Z.diagnostics=jt,Bt.size===0)return;let Lt=new Map,Vt=new Set;for(let zt of Z.events)if(zt.type==="dispatched")Vt.add(zt.name);else if(!Lt.has(zt.name))Lt.set(zt.name,zt);let Wt=new Set(Ot),Ut=new Map,Ht=[];for(let zt of Bt.values()){if(Vt.has(zt.name)){if(Wt.has(zt.name)&&zt.detail!==void 0)Ut.set(zt.name,zt.detail);continue}let Xt=Lt.get(zt.name);if(!Xt){Ht.push(zt);continue}let Yt=zt.source??Xt.source;Ht.push({type:"dispatched",name:zt.name,detail:Xt.detail??zt.detail,...Xt.description?{description:Xt.description}:{},...Xt.deprecated===void 0?{}:{deprecated:Xt.deprecated},...Xt.tags?{tags:Xt.tags}:{},...Xt.internal?{internal:!0}:{},...Yt?{source:Yt}:{}})}if(Ht.length===0&&Ut.size===0)return;let qt=new Set(Ht.map((zt)=>zt.name));Z.events=[...Z.events.filter((zt)=>zt.type==="dispatched"||!qt.has(zt.name)).map((zt)=>{let Xt=zt.type==="dispatched"?Ut.get(zt.name):void 0;return Xt===void 0?zt:{...zt,detail:Xt}}),...Ht].sort(he)}var Mp={collect:(Z)=>Z.pendingDispatchEscapeCandidates??[],resolve:Qd,apply:rf};function Ps(Z){return(ee)=>{let Le=Z.collect(ee);if(Le.length===0)return;return(Ot,Bt,jt)=>Z.apply(Ot,Z.resolve(Bt,Le,jt),ee)}}var af=[Ps(Np),Ps(Dp),Ps(Ip),Ps(Mp)];async function Fp(Z,ee,Le,Ot){let Bt=[];for(let Gt of Z){let Lt=Le(Gt);if(Lt===void 0)continue;let Vt=af.flatMap((Wt)=>Wt(Lt)??[]);if(Vt.length>0)Bt.push({component:Gt,passes:Vt})}let jt=new Map;if(Bt.length===0)return jt;await Un();for(let{component:Gt,passes:Lt}of Bt){let Vt=ws(Ot),Wt=of(ee(Gt.filePath));for(let Ut of Lt)Ut(Gt,Wt,Vt);jt.set(Gt.filePath,Array.from(Vt.cache.keys()))}return jt}var pf=/^```([\w-]*)\r?\n([\s\S]*?)\r?\n?```$/,cf=new Set(["","js","jsx","ts","tsx","javascript","typescript"]),lf=new Set(["svelte","html"]);function uf(Z){let ee=Z.trim();if(ee==="")return null;let Le=ee.match(pf);if(Le){let Ot=Le[1].toLowerCase(),Bt=Le[2].trim();if(Bt==="")return null;if(cf.has(Ot))return{kind:"compile",code:Bt};if(lf.has(Ot))return{kind:"syntax",code:Bt};return null}if(ee.startsWith("<"))return null;return{kind:"compile",code:ee}}function Bp(Z){if(!Z.isFunction)return"any";return`(${(Z.params??[]).map((Le)=>`${Le.name}${Le.optional?"?":""}: any`).join(", ")}) => any`}function _s(Z,ee,Le,Ot,Bt){let jt=(Z??[]).filter((Lt)=>Lt.name==="example"),Gt=jt.length>1;return jt.flatMap((Lt,Vt)=>{let Wt=uf(Lt.body);if(Wt===null)return[];return[{id:Gt?`${ee}#${Vt}`:ee,name:Gt?`${Le} (example ${Vt+1})`:Le,type:Ot,code:Wt.code,kind:Wt.kind,...Bt?{source:Bt}:{}}]})}function hf(Z){let ee=[];for(let Le of Z.props)ee.push(..._s(Le.tags,`prop:${Le.name}`,Le.name,Bp(Le),Le.source));for(let Le of Z.moduleExports)ee.push(..._s(Le.tags,`export:${Le.name}`,Le.name,Bp(Le),Le.source));for(let Le of Z.slots){let Ot=Le.name??"default";ee.push(..._s(Le.tags,`slot:${Ot}`,Ot,"any",Le.source))}for(let Le of Z.events)ee.push(..._s(Le.tags,`event:${Le.name}`,Le.name,"any",Le.source));return ee}function jp(Z,ee){return Z.flatMap(({component:Le,sources:Ot})=>{let Bt=Ot.filter((jt)=>jt.kind===ee);return Bt.length===0?[]:[{component:Le,sources:Bt}]})}async function df(Z){let{formatParseError:ee,parseSvelte:Le}=await Un(),Ot=new Map;for(let{component:Bt,sources:jt}of Z){let Gt=[];for(let Lt of jt)try{Le(Lt.code)}catch(Vt){Gt.push(a({component:Bt.filePath,kind:"example-syntax-error",name:Lt.name,message:ee(Vt),...Lt.source?{source:Lt.source}:{}}))}Ot.set(Bt,Gt)}return Ot}async function ff(Z,ee,Le){let Ot=await ee.checkExamples(Z.map(({component:jt,sources:Gt})=>({moduleName:jt.moduleName,filePath:Le(jt.filePath),sources:Gt}))),Bt=new Map;for(let{component:jt,sources:Gt}of Z){let Lt=Ot.get(Le(jt.filePath));if(!Lt||Lt.length===0)continue;let Vt=new Map(Gt.map((Wt)=>[Wt.id,Wt.source]));Bt.set(jt,Lt.map((Wt)=>{let Ut=Vt.get(Wt.id);return a({component:jt.filePath,kind:"example-compile-error",name:Wt.name,message:Wt.message,...Ut?{source:Ut}:{}})}))}return Bt}async function Vp(Z,ee,Le,Ot){let Bt=Array.from(Z,(Wt)=>({component:Wt,sources:hf(Wt)})),jt=ee===!0?jp(Bt,"compile"):[],Gt=jp(Bt,"syntax"),Lt=new Map,Vt=(Wt)=>{for(let[Ut,Ht]of Wt)Lt.set(Ut,[...Lt.get(Ut)??[],...Ht])};if(Gt.length>0)Vt(await df(Gt));if(jt.length>0){let{TypeResolver:Wt}=await import("./chunk-2p18x9at.js"),Ut=await Wt.create(Le);if(!Ut.ok)throw Error(`sveld: \`checkExamples\` ${Ut.message}.`);let Ht=Ut.resolver;try{Vt(await ff(jt,Ht,Ot))}finally{await Ht.dispose()}}return Lt}import{hash as mf}from"node:crypto";import{mkdirSync as gf,readFileSync as yf,renameSync as xf,writeFileSync as Gp}from"node:fs";import{dirname as Wp,isAbsolute as vf,join as Ef,resolve as zr}from"node:path";var Up=11,Sf=Ef("node_modules",".cache","sveld","parse-cache.json"),Cf="8ee3dad1e544f7b0";function Kp(){return`${hs}+${Cf}+svelte@${$i}`}function bf(Z){let ee=V(Z,["package.json"]);return ee===null?zr(Z):Wp(ee)}function Hp(Z,ee){let Le=bf(Z);if(typeof ee==="string")return vf(ee)?ee:zr(Le,ee);return zr(Le,Sf)}function $s(Z){return mf("sha256",Z,"hex")}function Xr(){return{formatVersion:Up,toolchainVersion:Kp(),entries:{}}}function wf(Z){try{let ee=JSON.parse(yf(Z,"utf-8"));if(ee.formatVersion!==Up||ee.toolchainVersion!==Kp())return Xr();return ee}catch{return Xr()}}class Jr{cacheFilePath;file;next=new Map;dirty=!1;savedEntryCount;constructor(Z){this.cacheFilePath=Z,this.file=wf(Z),this.savedEntryCount=Object.keys(this.file.entries).length}has(Z,ee){return this.lookup(Z,ee)!==void 0}lookup(Z,ee){let Le=this.next.get(Z);if(Le?.hash===ee)return Le;let Ot=this.file.entries[Z];return Ot?.hash===ee?Ot:void 0}get(Z,ee){let Le=this.lookup(Z,ee);if(Le===void 0)return null;this.next.set(Z,Le);let{component:Ot,typeScriptMetadata:Bt,propIgnores:jt,pending:Gt}=structuredClone({component:Le.component,typeScriptMetadata:Le.typeScriptMetadata,propIgnores:Le.propIgnores,pending:Le.pending});if(Bt!==void 0)Ot[x]=Bt;if(jt!==void 0)Ot[I]=jt;return Gt===void 0?{component:Ot}:{component:Ot,pending:Gt}}set(Z,ee,{component:Le,pending:Ot}){this.dirty=!0,this.next.set(Z,{hash:ee,...structuredClone({component:Le,typeScriptMetadata:Le[x],propIgnores:Le[I],pending:Ot})})}getGeneratedText(Z,ee){let Le=this.next.get(Z);if(Le?.generatedText===void 0||Le.generatedText.key!==ee)return;return Le.generatedText.text}setGeneratedText(Z,ee,Le){let Ot=this.next.get(Z);if(Ot===void 0)return;if(Ot.generatedText?.key===ee&&Ot.generatedText.text===Le)return;Ot.generatedText={key:ee,text:Le},this.dirty=!0}save(){if(!this.dirty&&this.next.size===this.savedEntryCount)return;this.dirty=!1,this.savedEntryCount=this.next.size,gf(Wp(this.cacheFilePath),{recursive:!0});let Z={...Xr(),entries:Object.fromEntries(this.next)},ee=JSON.stringify(Z),Le=`${this.cacheFilePath}.${process.pid}.tmp`;try{Gp(Le,ee),xf(Le,this.cacheFilePath)}catch{try{Gp(this.cacheFilePath,ee)}catch{}}}}import{dirname as Tf,relative as kf,resolve as Af}from"node:path";async function qp(Z,ee={}){await Un();let Le=Af(Z),Ot=Tf(Le),Bt=(Lt)=>n(`./${kf(Ot,Lt)}`),jt=Ts(Le,{...ws(ee.graph??new Kn),onAmbiguousStarExport:(Lt,Vt,Wt)=>{if(Lt!==Le||!ee.diagnostics)return;if(Wt.every((zt)=>zt.declFile.endsWith(".svelte")))return;let Ut=Array.from(new Set(Wt.map((zt)=>Bt(zt.declFile)))),Ht=Ut.map((zt)=>`"${zt}"`),qt=`${Ht.slice(0,-1).join(", ")} and ${Ht[Ht.length-1]}`;ee.diagnostics.push(a({component:Bt(Le),kind:"export-ambiguous",name:Vt,message:`"${Vt}" is exported by ${qt} through \`export *\`, so the barrel doesn't export it and the docs leave it out; export it explicitly from the barrel (e.g. \`export { ${Vt} } from "${Ut[0]}"\`).`}))}}),Gt=new Map;for(let Lt of jt){if(Lt.name==="default"||Lt.declFile.endsWith(".svelte"))continue;let{declFile:Vt,returnType:Wt,literalValue:Ut,primitiveLiteral:Ht,declaredType:qt,functionNode:zt,namespaceFile:Xt,...Yt}=Lt,Jt=Bt(Vt);if(Xt!==void 0)Yt.type=`typeof import(${JSON.stringify(Bt(Xt))})`;Gt.set(Lt.name,{...Yt,source:Jt})}return Array.from(Gt.values()).sort((Lt,Vt)=>u(Lt.name,Vt.name))}async function $f(Z){let ee=await Promise.all(Array.from(Z,async(Le)=>{try{return[Le,await _f(Le,"utf-8")]}catch(Ot){return console.warn(`Warning: Failed to read file ${Le}:`,Ot),[Le,null]}}));return new Map(ee)}function Xp(Z){if(Z.length===0)return;console.error(`sveld: failed to parse ${Z.length} component(s):`);for(let{filePath:ee,message:Le}of Z)console.error(` - ${ee}: ${Le}`)}class Fi{input;glob;options;graph=new Kn;collected;entryFile=null;globMergeState;cache;entryExports=[];entryDiagnostics=[];records=new Map;parseErrors=new Map;canonicalEntries=new Map;warnedModuleNames=new Set;constructor(Z,ee,Le={}){this.input=Z,this.glob=ee,this.options=Le}get documentExports(){return this.options.documentExports===!0}async build(){return this.graph=new Kn,this.collected=Ur(this.input,this.glob,this.documentExports,this.graph),this.globMergeState=bs(this.collected.allComponentEntries,this.collected.resolveComponentFilePath),this.entryFile=Pf(this.input).isFile()?zp(this.input):null,this.cache=this.options.cache===!1?void 0:new Jr(Hp(this.collected.rootDir,this.options.cache??!0)),await this.readEntryExports(),this.records.clear(),this.parseErrors.clear(),this.indexEntries(),await this.process(this.componentPaths()),Xp(Array.from(this.parseErrors.values())),this.assemble()}async update(Z){let ee=Z.map((Wt)=>zp(Wt));if(this.graph.invalidate(...ee),ee.length===0)return{result:this.assemble(),reparsed:[]};let Le=this.entryFile!==null&&ee.includes(this.entryFile)?await this.recollect():[];if(this.glob){let{rootDir:Wt,exports:Ut,allComponentEntries:Ht,resolveComponentFilePath:qt}=this.collected;Wr(this.graph,Wt,Ut,Ht,qt,this.globMergeState)}this.indexEntries();let Ot=this.componentPaths();for(let Wt of this.records.keys())if(!Ot.has(Wt))this.records.delete(Wt);for(let Wt of this.parseErrors.keys())if(!Ot.has(Wt))this.parseErrors.delete(Wt);let Bt=Array.from(this.records).flatMap(([Wt,{crossFileReads:Ut}])=>Ut?.some((Ht)=>ee.includes(Ht))?[Wt]:[]),jt=new Set([...ee.filter((Wt)=>Pn.test(Wt)),...Le,...Bt]),Gt=new Set(Array.from(Ot).filter((Wt)=>jt.has(Wt))),Lt=await this.process(Gt),Vt=this.assemble();return Xp(Vt.errors),{result:Vt,reparsed:Lt}}async recollect(){let Z=this.collected,ee=Ur(this.input,this.glob,this.documentExports,this.graph),Le=[];for(let[Ot,Bt]of Object.entries(ee.exports)){let jt=ee.resolveComponentFilePath(Bt.source),Gt=Object.hasOwn(Z.exports,Ot)?Z.exports[Ot]:void 0;if(Gt===void 0||Z.resolveComponentFilePath(Gt.source)!==jt)Le.push(jt)}return this.collected=ee,this.globMergeState=bs(ee.allComponentEntries,ee.resolveComponentFilePath),await this.readEntryExports(),Le}async readEntryExports(){this.entryDiagnostics=[],this.entryExports=this.documentExports&&this.entryFile!==null?await qp(this.entryFile,{diagnostics:this.entryDiagnostics,graph:this.graph}):[]}componentPaths(){let{exports:Z,allComponentEntries:ee,resolveComponentFilePath:Le}=this.collected,Ot=new Set;for(let[,Bt]of[...Object.entries(Z),...ee])if(di(Bt.source))Ot.add(Le(Bt.source));return Ot}indexEntries(){let{exports:Z,allComponentEntries:ee,resolveComponentFilePath:Le}=this.collected;this.canonicalEntries=new Map;for(let Ot of[Object.entries(Z),ee])for(let Bt of Ot){if(!di(Bt[1].source))continue;this.canonicalEntries.set(Le(Bt[1].source),this.entryIdentity(Ot,Bt))}}entryIdentity(Z,[ee,{source:Le}]){return{moduleName:Tp(ee,Le,Z.length,this.warnedModuleNames),filePath:n(Le)}}canonicalEntry(Z){let ee=this.canonicalEntries.get(Z);if(ee===void 0)throw Error(`sveld: no entry lists ${Z}.`);return ee}async process(Z){let ee=new Map,Le=await this.parse(Z,ee);this.cache?.save();let Ot=await this.settle(Le);for(let Bt of Z)this.records.delete(Bt),this.parseErrors.delete(Bt);for(let[Bt,jt]of Ot)this.records.set(Bt,jt);for(let[Bt,jt]of ee)this.parseErrors.set(Bt,jt);return Array.from(Ot.keys())}async parse(Z,ee){let Le=await $f(Z),Ot=this.cache,Bt=new Map,jt=new Set;if(Ot)for(let[Lt,Vt]of Le){if(Vt===null)continue;let Wt=$s(Vt);if(Bt.set(Lt,Wt),!Ot.has(Lt,Wt))jt.add(Lt)}if(Z.size>0&&(!Ot||jt.size>0))await Un();let Gt=new Map;for(let Lt of Z){let Vt=Le.get(Lt);if(Vt===null||Vt===void 0)continue;let Wt=this.parseOne(Lt,Vt,Bt.get(Lt),ee);if(Wt)Gt.set(Lt,Wt)}return Gt}parseOne(Z,ee,Le,Ot){let Bt=Le===void 0?null:this.cache?.get(Z,Le);if(Bt)return Bt;let{moduleName:jt,filePath:Gt}=this.canonicalEntry(Z),Lt;try{Lt=new(Nn()).ComponentParser().parse(ee,{moduleName:jt,filePath:Gt})}catch(Vt){if(this.options.failFast)throw Vt;Ot.set(Z,{filePath:Gt,moduleName:jt,message:Vt instanceof Error?Vt.message:String(Vt),stack:Vt instanceof Error?Vt.stack:void 0});return}if(Le!==void 0)this.cache?.set(Z,Le,Lt);return Lt}async settle(Z){let{rootDir:ee,resolveComponentFilePath:Le}=this.collected,Ot=new Map,Bt=new Map;for(let[Vt,{component:Wt,pending:Ut}]of Z){let Ht={...this.canonicalEntry(Vt),...Wt};Ot.set(Vt,Ht),Bt.set(Ht,Ut)}let{checkExamples:jt}=this.options;if(jt){let Vt=await Vp(Ot.values(),jt,ee,Le);for(let[Wt,Ut]of Vt)pi(Wt,Ut)}let Gt=await Fp(Ot.values(),Le,(Vt)=>Bt.get(Vt),this.graph),Lt=new Map;for(let[Vt,Wt]of Ot){let{moduleName:Ut,filePath:Ht,...qt}=Wt,zt=Gt.get(Ht);Lt.set(Vt,zt===void 0?{component:qt}:{component:qt,crossFileReads:zt})}return Lt}assemble(){let{exports:Z,allComponentEntries:ee,resolveComponentFilePath:Le}=this.collected,Ot=this.cache,Bt=(Ht,qt)=>{let{source:zt}=qt[1];if(!di(zt))return;let Xt=this.records.get(Le(zt));if(Xt===void 0)return;return{component:{...this.entryIdentity(Ht,qt),...Xt.component},record:Xt}},jt=new Map,Gt=Ot?new Map:void 0,Lt=Ot?new Map:void 0;for(let Ht of ee){let qt=Bt(ee,Ht);if(qt===void 0)continue;let{filePath:zt}=qt.component;jt.set(zt,qt.component),(qt.record.crossFileReads===void 0?Gt:Lt)?.set(zt,Le(Ht[1].source))}let Vt=sp(jt,Le,this.graph);for(let Ht of jt.values())pi(Ht,[...Vt(Ht),...ip(Ht)]);let Wt=new Map,Ut=Object.entries(Z);for(let Ht of Ut){let qt=Bt(Ut,Ht);if(qt===void 0)continue;let zt=jt.get(qt.component.filePath);if(zt)qt.component.diagnostics=zt.diagnostics;Wt.set(qt.component.moduleName,qt.component)}return{exports:Z,entryExports:this.entryExports,components:Wt,allComponentsForTypes:jt,errors:Array.from(this.parseErrors.values()),diagnostics:wo(ko([...Array.from(jt.values()).flatMap((Ht)=>Ht.diagnostics??[]),...this.entryDiagnostics]),this.options.diagnostics?.ignore),cache:Ot,resolvedPathByFilePath:Gt,crossFileResolvedPathByFilePath:Lt}}}function Bi(Z){return{failFast:Z?.failFast,documentExports:Z?.documentExports===!0,cache:Z?.cache,checkExamples:Z?.checkExamples==="syntax"?"syntax":Z?.checkExamples===!0,diagnostics:Z?.diagnostics}}async function ji(Z,ee,Le={}){return new Fi(Z,ee,Le).build()}import{existsSync as Yr,readFileSync as Nf}from"node:fs";import{isAbsolute as Df,join as Yp}from"node:path";var Vi='sveld: could not resolve a Svelte entry point. Set package.json#svelte, or pass the "entry" option.';function Jp(Z){return Df(Z)?Z:Yp(process.cwd(),Z)}function Re(Z){if(Z){let Bt=Jp(Z);if(Yr(Bt))return{entry:Q(Z)};return{entry:null,configured:!0,message:`Invalid entry point: ${Bt}. Pass a valid --entry (or "entry" option), or unset it and set the "svelte" field in your package.json instead.`}}let ee=Yp(process.cwd(),"package.json");if(!Yr(ee))return{entry:null,configured:!1,message:'Could not locate a package.json file. Specify an entry point with --entry (or the "entry" option).'};let Le;try{Le=lp(JSON.parse(Nf(ee,"utf-8")))}catch(Bt){throw console.error("Error reading package.json:",Bt),Bt}let Ot=Le.svelte?.trim();if(!Ot)return{entry:null,configured:!1,message:'Could not determine an entry point. Set the "svelte" field in your package.json, or pass --entry (or the "entry" option).'};if(!Yr(Jp(Ot)))return{entry:null,configured:!0,message:`The "svelte" field in package.json points to "${Ot}", which does not exist.`};return{entry:Q(Ot)}}function Ns(Z){let ee=Re(Z);if(ee.entry===null)console.error(ee.message);return ee.entry}async function Qp(Z,ee,Le={}){let Ot=new Fi(Z,ee,{...Le,failFast:!1}),Bt=await Ot.build();return{get result(){return Promise.resolve(Bt)},async update(jt){let Gt=await Ot.update(jt);return Bt=Gt.result,Gt}}}import Zr from"node:path";function Zp(Z){let ee=new Map,Le=[];for(let[Ot,Bt]of Object.entries(Z)){if(Bt.star){Le.push(`export * from "${Bt.source}";`);continue}let jt=ee.get(Bt.source)??[];jt.push({id:Ot,exportee:Bt}),ee.set(Bt.source,jt)}for(let[Ot,Bt]of ee){let jt=Pn.test(Ot),Gt=Bt.some(({id:qt,exportee:zt})=>qt!=="default"&&zt.default),Lt=Bt.some(({exportee:qt})=>!qt.default),Vt=jt&&Gt&&Lt,Wt=[],Ut=[],Ht=[];for(let{id:qt,exportee:zt}of Bt){if(qt==="default"){Ut.push(`export { default } from "${Ot}";`);continue}if(zt.default)if(zt.mixed)Ut.push(`export { default as ${qt} } from "${Ot}";`),Ut.push(`export { default } from "${Ot}";`);else Ht.push(`default as ${qt}`);else if(jt&&!Vt)Ht.push(`default as ${qt}`);else Wt.push(qt)}if(Ht.length>0&&Wt.length>0)Le.push(`export { ${[...Ht,...Wt].join(", ")} } from "${Ot}";`);else{if(Wt.length>0)Le.push(`export { ${Wt.join(", ")} } from "${Ot}";`);if(Ht.length>0)Le.push(`export { ${Ht.join(", ")} } from "${Ot}";`)}Le.push(...Ut)}return Le.join(`
140
140
  `)}function ec(Z){return Z.filter((ee)=>ee.names.length>0).map((ee)=>`export type { ${ee.names.join(", ")} } from "${ee.source}";`).join(`
141
141
  `)}function tc(Z){return Z.replace(Pn,"")}function Qr(Z){return Z.replace(Pn,".svelte.d.ts")}import{mkdir as Rf,readFile as If,writeFile as Of}from"node:fs/promises";import{parse as Lf}from"node:path";class In{ensuredDirs=new Set;async write(Z,ee){try{if(await If(Z,"utf-8")===ee)return!1}catch{}let Le=Lf(Z).dir;if(!this.ensuredDirs.has(Le))await Rf(Le,{recursive:!0}),this.ensuredDirs.add(Le);return await Of(Z,ee),!0}}function Mf(Z){return r(Z)&&!Array.isArray(Z)&&"start"in Z&&"end"in Z}function eo(Z){if(Array.isArray(Z))return Z.map((ee)=>eo(ee));if(r(Z)){let ee={};for(let[Le,Ot]of Object.entries(Z)){if((Le==="source"||Le==="componentCommentSource")&&Mf(Ot))continue;ee[Le]=eo(Ot)}return ee}return Z}function Ff(Z,ee,Le){if(!ee)return`${Z.moduleName}.api.json`;if(!Le.has(Z.moduleName))Le.add(Z.moduleName),console.warn(`Warning: multiple components named "${Z.moduleName}" found. Their JSON files are keyed by source path instead of name to avoid overwriting each other.`);return`${tc(Z.filePath)}.api.json`}async function Bf(Z,ee,Le){let Ot=Ds(Z,{inputDir:ee.inputDir,source:ee.source}).components,Bt=new Map;for(let Lt of Ot)Bt.set(Lt.moduleName,(Bt.get(Lt.moduleName)??0)+1);let jt=new Set,Gt=new In;await Promise.all(Ot.map(async(Lt)=>{let Vt=(Bt.get(Lt.moduleName)??0)>1,Wt=Ff(Lt,Vt,jt),Ut=Zr.resolve(Zr.join(Le,Wt)),Ht=await Gt.write(Ut,_i(Lt));Fn(`${Ht?"created":"unchanged"} "${Ut}".`)}))}function Ds(Z,ee){let Le=g(Z,{entryExports:ee.entryExports}),Ot={...Le,components:Le.components.map((Bt)=>({...Bt,filePath:ya(Bt.filePath,ee.inputDir)}))};return ee.source===!1?eo(Ot):Ot}function to(Z,ee){return _i(Ds(Z,ee))}async function no(Z,ee){if(ee.outDir){await Bf(Z,ee,ee.outDir);return}let Le=await new In().write(Zr.resolve(ee.outFile),to(Z,ee));Fn(`${Le?"created":"unchanged"} "${ee.outFile}".`)}import{join as Sc,resolve as co}from"node:path";var nc=/`/g,ic=/\s+/g,qn="--",sc=`| Prop name | Required | Kind | Reactive | Binding | Type | Default value | Description |
142
142
  | :- | :- | :- | :- | :- | :- | :- | :- |
@@ -1 +1 @@
1
- import{me,xe}from"./chunk-bbv5bs84.js";import{Bt,Z,jt,Lt,Ot,Le,Vt,ee}from"./chunk-yqr2sj7d.js";export{ee as ComponentParser,Lt as deriveLiteralDetailType,jt as extractJsDocDeprecatedAndTags,Bt as extractJsDocReturnType,Z as extractJsDocType,xe as formatParseError,Ot as literalDetailToTypeText,me as parseModule,Le as parseSvelte,Vt as parseSvelteScripts};
1
+ import{me,xe}from"./chunk-w75v318p.js";import{Bt,Z,jt,Lt,Ot,Le,Vt,ee}from"./chunk-xkx28fv0.js";export{ee as ComponentParser,Lt as deriveLiteralDetailType,jt as extractJsDocDeprecatedAndTags,Bt as extractJsDocReturnType,Z as extractJsDocType,xe as formatParseError,Ot as literalDetailToTypeText,me as parseModule,Le as parseSvelte,Vt as parseSvelteScripts};