sveld 0.37.1 → 0.37.2

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,7 +0,0 @@
1
- import{ne,l,a,se,p,f,ie,y,B,n,d,C,U,t,r,u,L,m,ae,ce,ue,z,h,pe,X,le,fe,x,de,c,P,me,Q,he,ge,ye,Y,xe,R,Z,K,O,g,Te,Ee,A}from"./chunk-q2023ykg.js";var ct={a:"HTMLAnchorElement",abbr:"HTMLElement",address:"HTMLElement",applet:"HTMLUnknownElement",area:"HTMLAreaElement",article:"HTMLElement",aside:"HTMLElement",audio:"HTMLAudioElement",b:"HTMLElement",base:"HTMLBaseElement",basefont:"HTMLElement",bdi:"HTMLElement",bdo:"HTMLElement",blockquote:"HTMLQuoteElement",body:"HTMLBodyElement",br:"HTMLBRElement",button:"HTMLButtonElement",canvas:"HTMLCanvasElement",caption:"HTMLTableCaptionElement",cite:"HTMLElement",code:"HTMLElement",col:"HTMLTableColElement",colgroup:"HTMLTableColElement",data:"HTMLDataElement",datalist:"HTMLDataListElement",dd:"HTMLElement",del:"HTMLModElement",details:"HTMLDetailsElement",dfn:"HTMLElement",dialog:"HTMLDialogElement",dir:"HTMLDirectoryElement",div:"HTMLDivElement",dl:"HTMLDListElement",dt:"HTMLElement",em:"HTMLElement",embed:"HTMLEmbedElement",fieldset:"HTMLFieldSetElement",figcaption:"HTMLElement",figure:"HTMLElement",font:"HTMLFontElement",footer:"HTMLElement",form:"HTMLFormElement",frame:"HTMLFrameElement",frameset:"HTMLFrameSetElement",h1:"HTMLHeadingElement",h2:"HTMLHeadingElement",h3:"HTMLHeadingElement",h4:"HTMLHeadingElement",h5:"HTMLHeadingElement",h6:"HTMLHeadingElement",head:"HTMLHeadElement",header:"HTMLElement",hgroup:"HTMLElement",hr:"HTMLHRElement",html:"HTMLHtmlElement",i:"HTMLElement",iframe:"HTMLIFrameElement",img:"HTMLImageElement",input:"HTMLInputElement",ins:"HTMLModElement",kbd:"HTMLElement",label:"HTMLLabelElement",legend:"HTMLLegendElement",li:"HTMLLIElement",link:"HTMLLinkElement",main:"HTMLElement",map:"HTMLMapElement",mark:"HTMLElement",marquee:"HTMLMarqueeElement",menu:"HTMLMenuElement",meta:"HTMLMetaElement",meter:"HTMLMeterElement",nav:"HTMLElement",noscript:"HTMLElement",object:"HTMLObjectElement",ol:"HTMLOListElement",optgroup:"HTMLOptGroupElement",option:"HTMLOptionElement",output:"HTMLOutputElement",p:"HTMLParagraphElement",param:"HTMLParamElement",picture:"HTMLPictureElement",pre:"HTMLPreElement",progress:"HTMLProgressElement",q:"HTMLQuoteElement",rp:"HTMLElement",rt:"HTMLElement",ruby:"HTMLElement",s:"HTMLElement",samp:"HTMLElement",script:"HTMLScriptElement",search:"HTMLElement",section:"HTMLElement",select:"HTMLSelectElement",slot:"HTMLSlotElement",small:"HTMLElement",source:"HTMLSourceElement",span:"HTMLSpanElement",strong:"HTMLElement",style:"HTMLStyleElement",sub:"HTMLElement",summary:"HTMLElement",sup:"HTMLElement",table:"HTMLTableElement",tbody:"HTMLTableSectionElement",td:"HTMLTableCellElement",template:"HTMLTemplateElement",textarea:"HTMLTextAreaElement",tfoot:"HTMLTableSectionElement",th:"HTMLTableCellElement",thead:"HTMLTableSectionElement",time:"HTMLTimeElement",title:"HTMLTitleElement",tr:"HTMLTableRowElement",track:"HTMLTrackElement",u:"HTMLElement",ul:"HTMLUListElement",var:"HTMLElement",video:"HTMLVideoElement",wbr:"HTMLElement"};function It(e){return e in ct}function pt(e){if(It(e))return ct[e];return"HTMLElement"}function nt(){return{syntaxMode:"legacy",scriptLanguage:void 0,source:void 0,parsed:void 0,runesOptionOverride:void 0,sourceLineStartOffsetsCache:void 0,sourceLineHint:void 0,parsedJsDocByText:new Map,jsDocBlocksByStart:new Map,rest_props:void 0,extends:void 0,customElementTag:void 0,customElement:void 0,componentComment:void 0,componentCommentSource:void 0,generics:null,scriptGenericsAttribute:void 0,diagnosticRecords:[],componentFilePath:"",props:new Map,moduleExports:new Map,propLocalToPublicName:new Map,reactive_vars:new Set,funcDecls:new Map,vars:new Set,valueImportBindingsByLocalName:new Map,pendingCallDefaultCandidates:[],pendingContextKeyCandidates:[],runesPropsDeclarationMetadataByDeclaratorStart:new Map,typedRunesPropsDeclarations:[],explicitPropTypesByName:new Map,explicitVariableTypesByName:new Map,typeImportBindingsByLocalName:new Map,localTypeDeclarationsByName:new Map,additionalTypeDependencyNodes:[],wholePropsLocals:new Set,restPropLocals:new Set,componentScope:new Map,scopeDeclarations:new Map,activeScopes:[],slots:new Map,snippetPropLocals:new Set,cssParts:[],cssProperties:[],deferredSlotBlockGenerics:[],events:new Map,eventDescriptions:new Map,forwardedEvents:new Map,jsDocEventNames:new Set,jsDocEventSources:new Map,bindings:new Map,contexts:new Map,typedefs:new Map,variableInfoCache:new Map,variableInfoCacheBuilt:!1,sveldIgnoreDirectives:new Map}}var _t=new Set(["Component","SvelteComponent","SvelteSelf"]),Ht=new Set(["RegularElement","SvelteElement"]);function Ve(e){return _t.has(e)}function Oe(e){return Ht.has(e)}function Ft({hasTypeScriptType:e,hasJSDocType:o,inferredType:i,finalType:b}){if(e)return"typescript";if(o)return"jsdoc";if(i!==void 0)return"default";if(b!==void 0)return"inferred";return"unknown"}function $e(e){let o=e.explicitType??e.jsdocType??e.resolvedType??e.typeSeed,i=e.jsdocParams??e.resolvedParams,b=e.jsdocReturnType??e.resolvedReturnType;if(e.isFunctionDeclaration&&o==="() => any"&&b)o=i&&i.length>0?`(${i.map((E)=>`${E.name}${E.optional?"?":""}: ${E.type}`).join(", ")}) => ${b}`:`() => ${b}`;let T=e.jsdocDescription??e.resolvedDescription;if(T===void 0&&o!==void 0)T=e.typedefs?.get(o)?.description;let M=Ft({hasTypeScriptType:e.explicitType!==void 0,hasJSDocType:e.jsdocType!==void 0||e.jsdocParams!==void 0||e.jsdocReturnType!==void 0||e.resolvedType!==void 0,inferredType:e.inferredTypeForSource,finalType:o}),v=e.initializerIsFunction||e.isFunctionDeclaration||e.inferIsFunctionFromTypeSignature===!0&&(!!e.jsdocParams?.length||e.jsdocReturnType!==void 0||!!e.jsdocType?.includes("=>")||!!e.resolvedType?.includes("=>")||!!e.explicitType?.includes("=>"));return{type:o,typeSource:M,description:T,params:i,returnType:b,isFunction:v}}function jt(e){if(!e||typeof e!=="object"||!("type"in e))return;let o=String(e.type),i=Ve(o);if(!i&&!Oe(o))return;let b="name"in e&&typeof e.name==="string"?e.name:void 0;if(!b)return;let T=i?{type:"InlineComponent",name:b}:{type:"Element",name:b};if(b==="svelte:element"&&"tag"in e&&e.tag&&typeof e.tag==="object"){let M=e.tag;if(M.type==="Literal"&&typeof M.value==="string")T.thisValue=M.value}return T}function lt(e,o){let i=jt(o);if(!i)return;if(e.rest_props===void 0){e.rest_props=i;return}if(e.rest_props.type==="InlineComponent"&&i.type==="Element")e.rest_props=i}function Ce(e,o,i){if(!o||e.has(o))return;e.set(o,i)}function Ge(e,o){for(let i=e.activeScopes.length-1;i>=0;i-=1){let b=e.activeScopes[i]?.get(o);if(!b)continue;return b.kind==="prop"?b.publicPropName:void 0}return}function Pe(e,o=new Set){if(!e||typeof e!=="object"||!("type"in e))return o;switch(e.type){case"Identifier":o.add(e.name);break;case"AssignmentPattern":Pe(e.left,o);break;case"ArrayPattern":for(let i of e.elements)Pe(i??void 0,o);break;case"ObjectPattern":for(let i of e.properties)if(i.type==="Property")Pe(i.value,o);else if(i.type==="RestElement")Pe(i.argument,o);break;case"RestElement":Pe(e.argument,o);break}return o}function ot(e,o){if(!o||typeof o!=="object"||!("type"in o))return;if(o.type==="Identifier"){let b=Ge(e,o.name);if(b)e.reactive_vars.add(b);return}let i=Pe(o);for(let b of i){let T=Ge(e,b);if(T)e.reactive_vars.add(T)}}function Ae(e){if(!e||typeof e!=="object"||!("type"in e))return!1;switch(String(e.type)){case"BlockStatement":case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":case"CatchClause":case"EachBlock":case"AwaitBlock":return!0;default:return!1}}function dt(e){if(!e||typeof e!=="object"||!("type"in e))return!1;let o=String(e.type);return o==="FunctionDeclaration"||o==="FunctionExpression"||o==="ArrowFunctionExpression"}function Bt(e,o){let i=e.scopeDeclarations.get(o);if(!i)i=new Map,e.scopeDeclarations.set(o,i);return i}function Vt(e,o,i){let b=[];if(i.id.type==="Identifier")return b.push({kind:"local",name:i.id.name}),b;if(i.id.type!=="ObjectPattern")return b;for(let T of i.id.properties){if(T.type==="RestElement"){if(T.argument.type==="Identifier")b.push({kind:"local",name:T.argument.name});continue}if(T.computed)continue;let M=e.getPropertyName(T.key);if(!M)continue;let v;if(T.value.type==="Identifier")v=T.value.name;else if(T.value.type==="AssignmentPattern"&&T.value.left.type==="Identifier")v=T.value.left.name;if(!v)continue;b.push({kind:"prop",name:v,publicPropName:M})}return b}function rt(e,o,i,b,T){if(!ne(o))return;let M=T?.allowRunesProps??!1,v=T?.forceProp??!1,E=o;for(let N of E.declarations){if(M&&p(f(N.init),"$props")){for(let q of Vt(e,E,N))Ce(q.kind==="prop"?i:b,q.name,q.kind==="prop"?{kind:"prop",publicPropName:q.publicPropName}:{kind:"local"});continue}let j=E.kind==="var"?b:i,G=v?"prop":"local";for(let q of Pe(N.id))Ce(j,q,G==="prop"?{kind:"prop",publicPropName:q}:{kind:"local"})}}function Ot(e,o){if("id"in e&&e.id&&typeof e.id==="object"&&"name"in e.id&&typeof e.id.name==="string")Ce(o,e.id.name,{kind:"local"});for(let i of e.params)for(let b of Pe(i))Ce(o,b,{kind:"local"})}function $t(e,o,i,b){if(!Array.isArray(o))return;for(let T of o){if(!T||typeof T!=="object"||!("type"in T))continue;switch(T.type){case"VariableDeclaration":rt(e,T,i,b);break;case"FunctionDeclaration":if(T.id?.name)Ce(i,T.id.name,{kind:"local"});break;case"ClassDeclaration":if(T.id?.name)Ce(i,T.id.name,{kind:"local"});break}}}function Gt(e,o,i){if(!i||typeof i!=="object")return;let b="content"in i&&i.content&&typeof i.content==="object"&&"body"in i.content&&Array.isArray(i.content.body)?i.content:("body"in i)&&Array.isArray(i.body)?i:void 0;if(!b||!("body"in b)||!Array.isArray(b.body))return;for(let T of b.body){if(!T||typeof T!=="object"||!("type"in T))continue;switch(T.type){case"ImportDeclaration":for(let M of T.specifiers??[])if(M.local?.name)Ce(o.componentScope,M.local.name,{kind:"local"});break;case"VariableDeclaration":rt(e,T,o.componentScope,o.componentScope,{allowRunesProps:!0});break;case"FunctionDeclaration":if(T.id?.name)Ce(o.componentScope,T.id.name,{kind:"local"});break;case"ClassDeclaration":if(T.id?.name)Ce(o.componentScope,T.id.name,{kind:"local"});break;case"ExportNamedDeclaration":if(!T.declaration||typeof T.declaration!=="object"||!("type"in T.declaration))break;if(T.declaration.type==="VariableDeclaration")rt(e,T.declaration,o.componentScope,o.componentScope,{forceProp:!0});else if(T.declaration.type==="FunctionDeclaration"&&T.declaration.id?.name)Ce(o.componentScope,T.declaration.id.name,{kind:"prop",publicPropName:T.declaration.id.name});break}}}function ut(e,o){o.componentScope.clear(),o.scopeDeclarations=new Map,o.activeScopes.length=0,Gt(e,o,o.parsed?.instance)}function mt(e){return{varScopeStack:[e.componentScope]}}function ft(e,o,i,b){if(!Ae(b))return;let T=Bt(o,b),M=i.varScopeStack[i.varScopeStack.length-1]??o.componentScope;switch(String(b.type)){case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":Ot(b,T);break;case"BlockStatement":$t(e,b.body,T,M);break;case"CatchClause":if("param"in b)for(let E of Pe(b.param))Ce(T,E,{kind:"local"});break;case"EachBlock":{let E=b;for(let N of Pe(E.context))Ce(T,N,{kind:"local"});if(typeof E.index==="string")Ce(T,E.index,{kind:"local"});else if(E.index&&"name"in E.index)Ce(T,E.index.name,{kind:"local"});break}case"AwaitBlock":{let E=b;for(let N of Pe(E.value))Ce(T,N,{kind:"local"});for(let N of Pe(E.error))Ce(T,N,{kind:"local"});break}}if(dt(b))i.varScopeStack.push(T);return T}function yt(e,o){if(dt(o))e.varScopeStack.pop()}var Tt=new Set(["$state","$derived","$effect","$props","$bindable","$inspect","$host"]);function Wt(e,o){switch(o?.type){case"MemberExpression":return o.computed||e===o.object;case"MethodDefinition":return!!o.computed;case"MetaProperty":return e===o.meta;case"PropertyDefinition":return o.computed||e===o.value;case"Property":return o.computed||e===o.value;case"ExportSpecifier":case"ImportSpecifier":return e===o.local;case"LabeledStatement":case"BreakStatement":case"ContinueStatement":return!1;default:return!0}}var Jt=Array.from(Tt);function gt(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function Kt(e){if(e.includes("\\u"))return!0;for(let o of Jt){let i=e.indexOf(o);while(i!==-1){if(!gt(e.charCodeAt(i-1))&&!gt(e.charCodeAt(i+o.length)))return!0;i=e.indexOf(o,i+1)}}return!1}function zt(e,o){for(let i=o.length-1;i>=0;i-=1)if(o[i]?.has(e))return!0;return!1}function Xt(e){let o=new Set;if(!e||typeof e!=="object"||!("type"in e))return o;switch(String(e.type)){case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":{let i=e;if(i.id?.name)o.add(i.id.name);for(let b of i.params??[])Pe(b,o);break}case"BlockStatement":Ye(e.body,o);break;case"CatchClause":Pe(e.param,o);break;case"EachBlock":{let i=e;if(Pe(i.context,o),typeof i.index==="string")o.add(i.index);else if(i.index?.name)o.add(i.index.name);break}case"AwaitBlock":{let i=e;Pe(i.value,o),Pe(i.error,o);break}}return o}function Ye(e,o){if(!Array.isArray(e))return;for(let i of e){if(!i||typeof i!=="object"||!("type"in i))continue;switch(String(i.type)){case"ImportDeclaration":for(let b of i.specifiers??[])if(b.local?.name)o.add(b.local.name);break;case"VariableDeclaration":for(let b of i.declarations??[])Pe(b.id,o);break;case"FunctionDeclaration":case"ClassDeclaration":{let b=i.id?.name;if(b)o.add(b);break}case"ExportNamedDeclaration":{let b=i.declaration;if(b&&typeof b==="object"&&"type"in b)Ye([b],o);break}}}}function it(e,o){if(!e||typeof e!=="object")return!1;let i=[...o],b=!1;return C(e,{enter(T,M){if(b){this.skip();return}if(Ae(T))i.push(Xt(T));if(M&&T.type==="Identifier"&&Tt.has(T.name)&&!M.type.startsWith("TS")&&Wt(T,M)&&!zt(T.name,i))b=!0,this.skip()},leave(T){if(Ae(T))i.pop()}}),b}function bt(e){if(!e||typeof e!=="object")return;if("content"in e){let o=e.content,i=o&&typeof o==="object"&&"body"in o?o.body:void 0;if(Array.isArray(i))return i}if("body"in e&&Array.isArray(e.body))return e.body;return}function xt(e){if(e.runesOptionOverride!==void 0)return e.runesOptionOverride?"runes":"legacy";let o=e.parsed;if(!o)return"legacy";if(e.source!==void 0&&!Kt(e.source))return"legacy";let i=new Set;Ye(bt(o.module),i);let b=new Set;return Ye(bt(o.instance),b),it(o.module,[i])||it(o.instance,[i,b])||it(o.fragment,[i,b])?"runes":"legacy"}var Ut=/[A-Za-z_$][\w$]*/g;function qt(e,o,i){let b=new Map,T=o.typeParameters?.params,M=i.typeArguments?.params;if(!T?.length||!M?.length)return b;for(let v=0;v<T.length;v++){let E=T[v]?.name,N=M[v];if(!E||N?.start===void 0||N?.end===void 0)continue;let j=r(e,N.start,N.end)?.trim();if(j)b.set(E,j)}return b}function Yt(e,o){if(o.size===0)return e;return e.replace(Ut,(i)=>o.get(i)??i)}function Ie(e,o,i,b,T=new Set){let M=new Map;if(!i?.type)return M;let v=(E)=>{for(let N of E){if(N?.type!=="TSPropertySignature"||N.computed)continue;if(!N.key)continue;let j=e.getPropertyName(N.key);if(!j)continue;let G=N.typeAnnotation?.start,q=N.typeAnnotation?.end;if(G===void 0||q===void 0)continue;let Se=r(o,G+1,q)?.trim();if(!Se)continue;P(o,N.typeAnnotation?.typeAnnotation),M.set(j,{type:Se,optional:N.optional===!0,source:t(o,N)})}};switch(i.type){case"TSTypeLiteral":v(i.members??[]);break;case"TSInterfaceDeclaration":v(i.body?.body??[]);break;case"TSTypeAliasDeclaration":{let E=Ie(e,o,i.typeAnnotation,b,T);for(let[N,j]of E)M.set(N,j);break}case"TSTypeReference":{let E=fe(i.typeName);if(!E||T.has(E))break;let N=b.get(E);if(!N)break;T.add(E);let j=Ie(e,o,N,b,T);T.delete(E);let G=qt(o,N,i);for(let[q,Se]of j)M.set(q,G.size===0?Se:{...Se,type:Yt(Se.type,G)});break}case"TSIntersectionType":for(let E of i.types??[]){let N=Ie(e,o,E,b,T);for(let[j,G]of N)M.set(j,G)}break;case"TSParenthesizedType":{let E=Ie(e,o,i.typeAnnotation,b,T);for(let[N,j]of E)M.set(N,j);break}}return M}function Qt(e){let o={};for(let[i,b]of Object.entries(e))o[i]={...b.attribute===void 0?{}:{attribute:b.attribute},...b.reflect===void 0?{}:{reflect:b.reflect},...b.type===void 0?{}:{type:b.type}};return o}function ht(e,o,i){if(o.runesPropsDeclarationMetadataByDeclaratorStart.clear(),o.explicitPropTypesByName.clear(),o.explicitVariableTypesByName.clear(),o.typeImportBindingsByLocalName.clear(),o.localTypeDeclarationsByName.clear(),o.additionalTypeDependencyNodes.length=0,o.typedRunesPropsDeclarations.length=0,!o.source)return;let b=i;o.scriptLanguage=e.resolveScriptLanguage(b);let T=b.options?.customElement;o.customElementTag=T?.tag,o.customElement=T?{...T.tag===void 0?{}:{tag:T.tag},...T.shadow==="open"||T.shadow==="none"?{shadow:T.shadow}:{},...T.props?{props:Qt(T.props)}:{},...T.extend===void 0?{}:{extend:!0}}:void 0,o.runesOptionOverride=b.options?.runes,o.scriptGenericsAttribute=e.resolveScriptGenericsAttribute(b);let M=b.instance?.content?.body??[];for(let v of M){if(!v?.type)continue;if(v.type==="ImportDeclaration"&&v.source?.value)for(let E of v.specifiers??[]){let N=E.local?.name;if(!N)continue;if(!(v.importKind==="type"||E.importKind==="type"))continue;let G,q;if(E.type==="ImportSpecifier")G="named",q=E.imported?.type==="Identifier"?E.imported.name:typeof E.imported?.value==="string"?E.imported.value:void 0;else if(E.type==="ImportDefaultSpecifier")G="default";else if(E.type==="ImportNamespaceSpecifier")G="namespace";if(!G)continue;o.typeImportBindingsByLocalName.set(N,{importedName:q,localName:N,source:String(v.source.value),specifierType:G})}if((v.type==="TSInterfaceDeclaration"||v.type==="TSTypeAliasDeclaration")&&v.id?.name&&v.start!==void 0&&v.end!==void 0)o.localTypeDeclarationsByName.set(v.id.name,{code:r(o,v.start,v.end)?.trim()??"",node:v,start:v.start});if(v.type==="TSEnumDeclaration"&&v.id?.name&&v.start!==void 0&&v.end!==void 0)o.localTypeDeclarationsByName.set(v.id.name,{code:me(o,v)??"",node:v,start:v.start});if(v.type==="ExportNamedDeclaration"&&v.declaration?.type==="VariableDeclaration")for(let E of v.declaration.declarations??[]){if(E.id?.type!=="Identifier"||!E.id.name)continue;let N=x(o,E.id.typeAnnotation);if(N)o.explicitPropTypesByName.set(E.id.name,N),P(o,E.id.typeAnnotation?.typeAnnotation)}else if(v.type==="VariableDeclaration")for(let E of v.declarations??[]){if(E.id?.type!=="Identifier"||!E.id.name)continue;let N=x(o,E.id.typeAnnotation);if(N)o.explicitVariableTypesByName.set(E.id.name,N)}}for(let v of M){if(!v||typeof v!=="object"||!("declarations"in v))continue;for(let E of v.declarations??[]){if(!p(f(E.init),"$props"))continue;let N=E.id?.typeAnnotation?void 0:ie(E.init),j=E.id?.typeAnnotation?.typeAnnotation??N,G=E.id?.typeAnnotation?x(o,E.id.typeAnnotation):de(o,N),q=Ie(e,o,j,new Map(Array.from(o.localTypeDeclarationsByName.entries(),([ve,_e])=>[ve,_e.node]))),Se=new Set,Le=new Set;if(c(o,j,Se,Le),ye(o,Se,Le),E.start!==void 0){let ve={canonicalType:G,props:q,referencedImportedTypes:Se,referencedLocalTypes:Le};if(o.runesPropsDeclarationMetadataByDeclaratorStart.set(E.start,ve),G)o.typedRunesPropsDeclarations.push(ve)}}}}function St(e,o,i){for(let b of i.declarations){if(!p(f(b.init),"$props"))continue;if(b.id.type==="Identifier"){o.wholePropsLocals.add(b.id.name),o.restPropLocals.add(b.id.name);let v=X(o,b.start);if(v)for(let[E,N]of v.props)L(e,o,E,{name:E,kind:"let",type:N.type,typeSource:"typescript",isFunction:!1,isFunctionDeclaration:!1,isRequired:!N.optional,constant:!1,reactive:!1,source:N.source});continue}if(b.id.type!=="ObjectPattern")continue;let T=g(o,e,i),M=b.id.properties.filter((v)=>{if(v.type!=="Property"||v.computed)return!1;if(!e.getPropertyName(v.key))return!1;if(v.value.type==="Identifier")return!0;return v.value.type==="AssignmentPattern"&&v.value.left.type==="Identifier"}).length;for(let v of b.id.properties){if(v.type==="RestElement"){if(v.argument.type==="Identifier")o.restPropLocals.add(v.argument.name);continue}let E=e.getPropertyName(v.key);if(!E)continue;let N,j;if(v.value.type==="Identifier")N=v.value.name;else{let S=v.value;N=S.left.name,j=S.right}if(!N)continue;if(e.trackPropLocalName(E,N),E==="children")o.snippetPropLocals.add(N);let G=Te(o,e,v)??(M===1?T:void 0),q=le(o,b.start,E),{init:Se,bindable:Le}=ae(j),ve=Se==null?{isFunction:!1}:m(e,o,Se),{value:_e,type:Re,isFunction:He,defaultValue:Fe}=ve,Je=q?.type===void 0&&G?.type===void 0?ve.resolvedType:void 0;if(ve.pendingCallDefault)o.pendingCallDefaultCandidates.push({propName:E,location:"props",...ve.pendingCallDefault});let{type:je,typeSource:Ke,description:ze,params:Xe,returnType:Ue,isFunction:qe}=$e({explicitType:q?.type,typeSeed:Re,inferredTypeForSource:Re,jsdocType:G?.type,jsdocDescription:G?.description,jsdocParams:G?.params,jsdocReturnType:G?.returnType,resolvedType:Je,resolvedDescription:ve.resolvedDescription,resolvedParams:ve.resolvedParams,resolvedReturnType:ve.resolvedReturnType,initializerIsFunction:He,isFunctionDeclaration:!1,inferIsFunctionFromTypeSignature:!0});if(Le)o.reactive_vars.add(E);d(o,"prop-unknown-type",E,G?.sveldIgnore),L(e,o,E,{name:E,...N===E?{}:{localName:N},kind:"let",description:ze,binding:G?.binding,deprecated:G?.deprecated,tags:G?.tags,...G?.internal?{internal:!0}:{},...Le?{bindable:!0}:{},type:je,typeSource:Ke,value:_e,defaultValue:Fe,params:Xe,returnType:Ue,isFunction:qe,isFunctionDeclaration:!1,isRequired:!Le&&Se==null&&q?.optional!==!0,constant:!1,reactive:Le,source:t(o,v)})}}}function Zt(e){let i=e.indexOf("EventDispatcher");if(i===-1)return;let b=i+15;while(e[b]===" ")b++;if(e[b]!=="<")return;let T=0,M=b;for(;b<e.length;b++)if(e[b]==="<")T++;else if(e[b]===">"){if(T--,T===0)return e.slice(M+1,b)}return}function en(e){let o=[],i=0,b=0;for(let T=0;T<e.length;T++){let M=e[T];if(M==="{"||M==="("||M==="["||M==="<")i++;else if(M==="}"||M===")"||M==="]"||M===">")i=Math.max(i-1,0);else if(i===0&&(M===";"||M===","))o.push(e.slice(b,T)),b=T+1}return o.push(e.slice(b)),o.map((T)=>T.trim()).filter((T)=>T.length>0)}var tn=/^["']|["']$/g,nn=/\?$/,rn=/^\{/,on=/\}$/;function an(e){let o=0;for(let i=0;i<e.length;i++){let b=e[i];if(b==="{"||b==="("||b==="["||b==="<")o++;else if(b==="}"||b===")"||b==="]"||b===">")o=Math.max(o-1,0);else if(o===0&&b===":"){let T=e.slice(0,i).trim().replace(nn,"").replace(tn,""),M=e.slice(i+1).trim();if(!T||!M)return;return{name:T,type:M}}}return}function Et(e,o,i,b,T){if(i){let N=new Map(Array.from(o.localTypeDeclarationsByName.entries(),([G,q])=>[G,q.node])),j=Ie(e,o,i,N);for(let[G,q]of j)h(o,{name:G,detail:q.type,has_argument:!0,source:q.source});return}let M=e.resolveLocalVarJSDoc(b)?.type,v=M?Zt(M):void 0;if(!v)return;let E=v.trim().replace(rn,"").replace(on,"");for(let N of en(E)){let j=an(N);if(!j)continue;h(o,{name:j.name,detail:j.type,has_argument:!0,source:T})}}function Pt(e,o){if(e.syntaxMode!=="runes")return;for(let[i,b]of Array.from(e.events.entries())){if(b.type!=="dispatched")continue;if(o.has(i)||e.forwardedEvents.has(i))continue;let T=`on${i}`,M=e.props.get(T);if(!M)continue;let v=M.type!==void 0||M.params!==void 0||M.returnType!==void 0,E=b.detail===void 0||b.detail==="undefined"||b.detail==="null"?"() => void":`(detail: ${b.detail}) => void`;e.props.set(T,{...M,description:M.description??b.description,type:v?M.type:E,typeSource:v?M.typeSource:"inferred",isFunction:!0}),e.events.delete(i)}}var vt=new Set(["TSAsExpression","TSSatisfiesExpression","TSNonNullExpression","TSTypeAssertion","TSInstantiationExpression"]);function Qe(e){if(!e||typeof e!=="object")return;C(e,{enter(o){if(!vt.has(o.type))return;let i=o.expression;while(i&&vt.has(i.type))i=i.expression;if(i)this.replace(i)}})}function We(e,o,i){at(e,null,null,o,i)}function at(e,o,i,b,T){b(e,o,i);for(let M in e){if(M==="leadingComments")continue;let v=e[M];if(!v||typeof v!=="object")continue;if(Array.isArray(v))for(let E=0;E<v.length;E++){let N=v[E];if(N&&typeof N==="object"&&typeof N.type==="string")at(N,e,M,b,T)}else if(typeof v.type==="string")at(v,e,M,b,T)}if(T)T(e)}function Ze(e,o){let i=o.source?.value;if(typeof i!=="string"||o.importKind==="type")return;for(let b of o.specifiers??[]){if(b.type!=="ImportSpecifier"||b.importKind==="type")continue;let T=b.local?.name;if(!T)continue;let M=b.imported?.name??(typeof b.imported?.value==="string"?b.imported.value:T);e.valueImportBindingsByLocalName.set(T,{localName:T,importedName:M,source:i})}}function st(e,o){if(!o)return;We(o,(i)=>{if(i.type==="ImportDeclaration")Ze(e,i);if(i.type==="FunctionDeclaration"){let b=i;if(b.id?.name)e.funcDecls.set(b.id.name,b)}})}function Dt(e,o,i){let b=o+1;while(b<e.length){if(e[b]==="\\"){b+=2;continue}if(e[b]===i)return b+1;b++}return b}function Mt(e,o){let i=o+1,b=0;while(i<e.length){let T=e[i];if(T==="\\"){i+=2;continue}if(b===0){if(T==="`")return i+1;if(T==="$"&&e[i+1]==="{"){b=1,i+=2;continue}i++;continue}if(T==="{")b++;else if(T==="}")b--;else if(T==='"'||T==="'"){i=Dt(e,i,T);continue}else if(T==="`"){i=Mt(e,i);continue}i++}return i}function sn(e,o){let i=[],b=e.length,T=0;while(T<b){let M=e[T];if(M==='"'||M==="'"){T=Dt(e,T,M);continue}if(M==="`"){T=Mt(e,T);continue}if(M==="/"&&e[T+1]==="/"){let v=T+2;while(v<b&&e[v]!==`
2
- `)v++;T=v;continue}if(M==="/"&&e[T+1]==="*"){let v=T,E=T+2;while(E<b&&!(e[E]==="*"&&e[E+1]==="/"))E++;let N=Math.min(E+2,b),j=e.slice(v,N);i.push({end:N+o,isJsDoc:j.startsWith("/**")&&j.length>4,text:j}),T=N;continue}T++}return i}function Ct(e,o,i){if(!e||typeof e!=="object"||!("type"in e))return;let b=e;if(b.type==="FunctionDeclaration"){if(b.id?.type==="Identifier"&&b.id.name)i.push({name:b.id.name,start:o});return}if(b.type==="VariableDeclaration"){for(let T of b.declarations??[])if(T?.id?.type==="Identifier"&&T.id.name)i.push({name:T.id.name,start:o})}}function cn(e){let o=[];for(let i of e){if(!i||typeof i!=="object"||!("type"in i))continue;let b=i;if(b.start===void 0)continue;if(b.type==="ExportNamedDeclaration"&&b.declaration)Ct(b.declaration,b.start,o);else Ct(b,b.start,o)}return o}function pn(e,o,i){let b;for(let T of e){if(T.end>o)break;if(!T.isJsDoc)continue;if(!Z.test(i.slice(T.end,o)))continue;b=T}return b}function kt(e,o){let i=new Map;if(!e.source)return i;let b=[e.parsed?.module,e.parsed?.instance],T=[],M=[];for(let v of b){let E=v?.content;if(!E?.body||E.start===void 0||E.end===void 0)continue;T.push(...sn(e.source.slice(E.start,E.end),E.start)),M.push(...cn(E.body))}T.sort((v,E)=>v.end-E.end);for(let v of M){let E=pn(T,v.start,e.source);if(!E)continue;let N=K(e,E.text),{type:j,description:G,ignore:q,internal:Se}=O(N);if(q.length>0)d(e,"context-any-type",v.name,q);if(!j)continue;i.set(v.name,{type:o.aliasType(j.type),description:G||j.description,internal:Se||void 0})}return i}function Nt(e){if(e==="var")return"let";if(e==="using"||e==="await using")return"const";return e}var ln=null,Lt=/^@component/,dn=/\r/g,un=/^\{\s*\}$/,mn=new Set(["AssignmentExpression","UpdateExpression","CallExpression","SpreadAttribute","FunctionDeclaration","ImportDeclaration","VariableDeclaration","ExportNamedDeclaration","Comment","SlotElement","RenderTag","OnDirective","BindDirective"]);class s{ctx=nt();static mapToArray(e){return Array.from(e,([o,i])=>i)}static getStaticAttributeValue(e){if(!Array.isArray(e.value))return;return e.value.map((o)=>o.data??o.raw??"").join("").trim()}resolveScriptLanguage(e){let o=[e.instance,e.module].filter((b)=>b!==void 0),i=!1;for(let b of o){let T=b.attributes?.find((v)=>v.name==="lang");if(!T){i=!0;continue}if(s.getStaticAttributeValue(T)?.toLowerCase()==="ts")return"ts"}return i?"js":void 0}resolveScriptGenericsAttribute(e){let o=e.instance?.attributes?.find((v)=>v.name==="generics");if(!o)return;let i=t(this.ctx,o),b=e.instance?.attributes?.find((v)=>v.name==="lang");if((b?s.getStaticAttributeValue(b)?.toLowerCase():void 0)!=="ts"){n(this.ctx,"syntax-skipped","generics",'<script generics="..."> requires lang="ts"; the generics attribute was ignored because the script is not TypeScript.',i);return}let M=s.getStaticAttributeValue(o);if(!M)return;return{value:M,source:i}}resolvePublicPropName(e){return this.ctx.propLocalToPublicName.get(e)??e}trackPropLocalName(e,o=e){this.ctx.propLocalToPublicName.set(o,e)}getPropByLocalOrPublic(e){return this.ctx.props.get(this.resolvePublicPropName(e))}getPropTypeByLocalOrPublic(e){return this.getPropByLocalOrPublic(e)?.type}getExplicitPropType(e){return this.ctx.explicitPropTypesByName.get(e)}getPropertyName(e){if(!e||typeof e!=="object"||!("type"in e))return;if(a(e))return e.name;if(l(e))return e.value==null?void 0:String(e.value);return}isNumericConstant(e){if(!e||typeof e!=="object"||!("type"in e))return!1;if(e.type!=="MemberExpression")return!1;let o=e,i=o.object&&"name"in o.object?o.object.name:void 0,b=o.property&&"name"in o.property?o.property.name:void 0;if(!i||!b)return!1;if(i==="Number")return["POSITIVE_INFINITY","NEGATIVE_INFINITY","MAX_VALUE","MIN_VALUE","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","EPSILON","NaN"].includes(b);if(i==="Math")return["PI","E","LN2","LN10","LOG2E","LOG10E","SQRT2","SQRT1_2"].includes(b);return!1}resolveLocalVarJSDoc(e){for(let i of this.ctx.vars)if(i.declarations.some((T)=>T.id&&typeof T.id==="object"&&("type"in T.id)&&T.id.type==="Identifier"&&("name"in T.id)&&T.id.name===e))return g(this.ctx,this,i);let o=this.ctx.funcDecls.get(e);if(o)return g(this.ctx,this,o);return}addModuleExport(e,o){if(u(e)===void 0)return;if(this.ctx.moduleExports.has(e)){let i=this.ctx.moduleExports.get(e);this.ctx.moduleExports.set(e,{...i,...o})}else this.ctx.moduleExports.set(e,o)}aliasType(e){if(e==="*")return"any";return e.trim()}findVariableTypeAndDescription(e){let o=this.getPropByLocalOrPublic(e);if(o?.type)return{type:o.type,description:o.description,internal:o.internal};if(!this.ctx.variableInfoCacheBuilt)this.ctx.variableInfoCache=kt(this.ctx,this),this.ctx.variableInfoCacheBuilt=!0;let i=this.ctx.variableInfoCache.get(e),b=this.ctx.explicitVariableTypesByName.get(e);if(b)return{type:b,description:i?.description,internal:i?.internal};return i??null}accumulateGeneric(e,o){if(this.ctx.generics)this.ctx.generics=[`${this.ctx.generics[0]}, ${e}`,`${this.ctx.generics[1]}, ${o}`];else this.ctx.generics=[e,o]}cleanup(){this.ctx=nt()}static SCRIPT_BLOCK_REGEX=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi;static TS_DIRECTIVE_REGEX=/\/\/\s*@ts-[^\n\r]*/g;static stripTypeScriptDirectivesFromScripts(e){if(!e.includes("@ts-"))return e;return s.SCRIPT_BLOCK_REGEX.lastIndex=0,e.replace(s.SCRIPT_BLOCK_REGEX,(o,i,b,T)=>{s.TS_DIRECTIVE_REGEX.lastIndex=0;let M=b.replace(s.TS_DIRECTIVE_REGEX,"");return i+M+T})}parseSvelteComponent(e,o){this.cleanup(),this.ctx.componentFilePath=o.filePath;let i=s.stripTypeScriptDirectivesFromScripts(e);this.ctx.source=i;let b=A(i);if(ht(this,this.ctx,b),this.ctx.parsed=b,this.ctx.scriptLanguage==="ts")Qe(this.ctx.parsed.module),Qe(this.ctx.parsed.instance),Qe(this.ctx.parsed.fragment);this.ctx.syntaxMode=xt(this.ctx);let T=this.ctx.parsed.css,M=T?.start!==void 0&&T?.end!==void 0?i.slice(0,T.start)+" ".repeat(T.end-T.start)+i.slice(T.end):i;st(this.ctx,this.ctx.parsed?.module),st(this.ctx,this.ctx.parsed?.instance),Ee(this.ctx,this,M);let v={type:"ComponentRoot",instance:this.ctx.parsed.instance,fragment:this.ctx.parsed.fragment};if(this.ctx.parsed?.module)We(this.ctx.parsed?.module,(S)=>{if(S.type==="ImportDeclaration")Ze(this.ctx,S);if(S.type==="FunctionDeclaration"){let D=S;if(D.id?.name)this.ctx.funcDecls.set(D.id.name,D)}if(S.type==="VariableDeclaration")this.ctx.vars.add(S);if(S.type==="ExportNamedDeclaration"){if(S.declaration==null&&S.specifiers.length===0)return;let D,w=!1;if(S.declaration==null&&S.specifiers[0]?.type==="ExportSpecifier"){let k=S.specifiers[0],I=k.local&&typeof k.local==="object"&&"name"in k.local?k.local.name:void 0,F=k.exported&&typeof k.exported==="object"&&"name"in k.exported?k.exported.name:void 0;if(!I||!F)return;let J;for(let _ of Array.from(this.ctx.vars))if(_.declarations.some((H)=>H.id&&typeof H.id==="object"&&("type"in H.id)&&H.id.type==="Identifier"&&H.id.name===I)){J=_;break}if(!J){let _="source"in S&&S.source&&typeof S.source==="object"&&"value"in S.source?S.source.value:void 0,H=typeof _==="string"?`it re-exports from "${_}"`:this.ctx.valueImportBindingsByLocalName.has(I)?"it re-exports an imported binding":"no matching local declaration was found";n(this.ctx,"export-unresolved",F,`export "${F}" was skipped because ${H}; sveld only resolves exports of a local declaration.`,t(this.ctx,S));return}S.declaration=J,D=F,w=!0}if(S.declaration==null)return;if(!S.declaration||typeof S.declaration!=="object"||!("type"in S.declaration))return;let V=[];if(S.declaration.type==="FunctionDeclaration"){let k=S.declaration;if(!k.id?.name)return;let I=this.ctx.scriptLanguage==="ts"?Q(this.ctx,k):void 0;V.push({prop_name:k.id.name,kind:"function",isFunctionDeclaration:!0,value:void 0,typeSeed:I?.hasAnnotations?void 0:"() => any",explicitType:I?.hasAnnotations?I.signature:void 0,initializerIsFunction:!0,defaultValue:void 0,inferredTypeForSource:void 0,resolvedJSDoc:void 0})}else if(S.declaration.type==="VariableDeclaration"){let k=S.declaration,I=Nt(k.kind),F=w?k.declarations.slice(0,1):k.declarations;for(let J of F){if(!J||typeof J!=="object"||!("id"in J))continue;let{id:_,init:H}=J;if(!_||typeof _!=="object"||!("name"in _))continue;let ee=_.name,re=D??ee,oe=H==null?{isFunction:!1}:m(this,this.ctx,H),{value:be,type:De,isFunction:te,defaultValue:Ne}=oe,Me=oe;if(Me.pendingCallDefault)this.ctx.pendingCallDefaultCandidates.push({propName:ee,location:"moduleExports",...Me.pendingCallDefault});V.push({prop_name:re,kind:I,isFunctionDeclaration:!1,value:be,typeSeed:De,explicitType:this.getExplicitPropType(ee),initializerIsFunction:te,defaultValue:Ne,inferredTypeForSource:De,resolvedJSDoc:Me})}if(V.length===0)return}else return;let W=g(this.ctx,this,S);for(let{prop_name:k,kind:I,isFunctionDeclaration:F,value:J,typeSeed:_,explicitType:H,initializerIsFunction:ee,defaultValue:re,inferredTypeForSource:oe,resolvedJSDoc:be}of V){let{type:De,typeSource:te,description:Ne,params:Me,returnType:we,isFunction:ke}=$e({explicitType:H,typeSeed:_,inferredTypeForSource:oe,jsdocType:W?.type,jsdocDescription:W?.description,jsdocParams:W?.params,jsdocReturnType:W?.returnType,resolvedType:be?.resolvedType,resolvedDescription:be?.resolvedDescription,resolvedParams:be?.resolvedParams,resolvedReturnType:be?.resolvedReturnType,initializerIsFunction:ee,isFunctionDeclaration:F,typedefs:this.ctx.typedefs});this.addModuleExport(k,{name:k,kind:I,description:Ne,deprecated:W?.deprecated,tags:W?.tags,...W?.internal?{internal:!0}:{},type:De,typeSource:te,value:J,defaultValue:re,params:Me,returnType:we,isFunction:ke,isFunctionDeclaration:F,isRequired:!1,constant:I==="const",reactive:!1,source:t(this.ctx,S)})}}});let E,N,j,G=new Set,q=new Set,Se=[];ut(this,this.ctx),this.ctx.activeScopes.push(this.ctx.componentScope);let Le=mt(this.ctx);if(We(v,(S,D,w)=>{let V=ft(this,this.ctx,Le,S);if(V)this.ctx.activeScopes.push(V);let W=S.type;if(!mn.has(W))return;if(S.type==="AssignmentExpression")ot(this.ctx,S.left);if(S.type==="UpdateExpression")ot(this.ctx,S.argument);if(S.type==="CallExpression"){let k=S,I=k.callee&&typeof k.callee==="object"&&"name"in k.callee?k.callee.name:void 0;if(I==="createEventDispatcher"){if(D&&typeof D==="object"&&"id"in D&&D.id&&typeof D.id==="object"&&"name"in D.id)E=D.id.name,N=D;j=k.typeArguments?.params?.[0]}if(I==="$host"){if(D&&typeof D==="object"&&"id"in D&&D.id&&typeof D.id==="object"&&"name"in D.id)G.add(D.id.name)}if(I==="setContext")ce(this.ctx,this,S,D??void 0);if(I)Se.push({name:I,arguments:k.arguments,node:k});if(se(k.callee)&&a(k.callee.property)&&k.callee.property.name==="dispatchEvent"&&(p(k.callee.object,"$host")||a(k.callee.object)&&G.has(k.callee.object.name))){let F=pe(this.ctx,k);if(F)q.add(F)}}if(W==="SpreadAttribute"){let k=S;if(k.expression?.name==="$$restProps"||this.ctx.restPropLocals.has(k.expression?.name??""))lt(this.ctx,D)}if(S.type==="FunctionDeclaration"){let k=S;if(k.id?.name)this.ctx.funcDecls.set(k.id.name,k)}if(S.type==="ImportDeclaration")Ze(this.ctx,S);if(S.type==="VariableDeclaration"){if(this.ctx.vars.add(S),D&&typeof D==="object"&&"type"in D&&D.type==="Program"&&S.declarations.some((k)=>p(f(k.init),"$props")))St(this,this.ctx,S)}if(S.type==="ExportNamedDeclaration"){if(S.declaration==null&&S.specifiers.length===0)return;let k,I=!1;if(S.declaration==null&&S.specifiers[0]?.type==="ExportSpecifier"){let _=S.specifiers[0],H=_.local&&typeof _.local==="object"&&"name"in _.local?_.local.name:void 0,ee=_.exported&&typeof _.exported==="object"&&"name"in _.exported?_.exported.name:void 0;if(!H||!ee)return;let re;for(let oe of Array.from(this.ctx.vars))if(oe.declarations.some((be)=>be.id&&typeof be.id==="object"&&("type"in be.id)&&be.id.type==="Identifier"&&be.id.name===H)){re=oe;break}if(S.declaration=re,k=ee,I=!0,!re){let oe="source"in S&&S.source&&typeof S.source==="object"&&"value"in S.source?S.source.value:void 0,be=typeof oe==="string"?`it re-exports from "${oe}"`:this.ctx.valueImportBindingsByLocalName.has(H)?"it re-exports an imported binding":"no matching local declaration was found";n(this.ctx,"export-unresolved",ee,`export "${ee}" was skipped because ${be}; sveld only resolves exports of a local declaration.`,t(this.ctx,S));return}}if(S.declaration==null)return;if(!S.declaration||typeof S.declaration!=="object"||!("type"in S.declaration))return;let F=[];if(S.declaration.type==="FunctionDeclaration"){let _=S.declaration;if(!_.id?.name)return;k??=_.id.name;let H=this.ctx.scriptLanguage==="ts"?Q(this.ctx,_):void 0;F.push({prop_name:k,kind:"function",isFunctionDeclaration:!0,value:void 0,typeSeed:H?.hasAnnotations?void 0:"() => any",explicitType:H?.hasAnnotations?H.signature:void 0,initializerIsFunction:!0,isRequired:!1,localName:_.id.name,defaultValue:void 0,inferredTypeForSource:void 0,resolvedJSDoc:void 0})}else if(S.declaration.type==="VariableDeclaration"){let _=S.declaration,H=Nt(_.kind),ee=I?_.declarations.slice(0,1):_.declarations;for(let re of ee){if(!re||typeof re!=="object"||!("id"in re))continue;let{id:oe,init:be}=re;if(!oe||typeof oe!=="object"||!("name"in oe))continue;let De=oe.name,te=k??De,Ne=H==="let"&&be==null,Me=be==null?{isFunction:!1}:m(this,this.ctx,be),{value:we,type:ke,isFunction:et,defaultValue:tt}=Me,Be=Me;if(Be.pendingCallDefault)this.ctx.pendingCallDefaultCandidates.push({propName:te,location:"props",...Be.pendingCallDefault});F.push({prop_name:te,kind:H,isFunctionDeclaration:!1,value:we,typeSeed:ke,explicitType:this.getExplicitPropType(De),initializerIsFunction:et,isRequired:Ne,localName:De,defaultValue:tt,inferredTypeForSource:ke,resolvedJSDoc:Be})}if(F.length===0)return}else return;let J=g(this.ctx,this,S);for(let{prop_name:_,kind:H,isFunctionDeclaration:ee,value:re,typeSeed:oe,explicitType:be,initializerIsFunction:De,isRequired:te,localName:Ne,defaultValue:Me,inferredTypeForSource:we,resolvedJSDoc:ke}of F){let{type:et,typeSource:tt,description:Be,params:wt,returnType:Rt,isFunction:At}=$e({explicitType:be,typeSeed:oe,inferredTypeForSource:we,jsdocType:J?.type,jsdocDescription:J?.description,jsdocParams:J?.params,jsdocReturnType:J?.returnType,resolvedType:ke?.resolvedType,resolvedDescription:ke?.resolvedDescription,resolvedParams:ke?.resolvedParams,resolvedReturnType:ke?.resolvedReturnType,initializerIsFunction:De,isFunctionDeclaration:ee,typedefs:this.ctx.typedefs});d(this.ctx,"prop-unknown-type",_,J?.sveldIgnore),L(this,this.ctx,_,{name:_,...Ne!==void 0&&Ne!==_?{localName:Ne}:{},kind:H,description:Be,binding:J?.binding,deprecated:J?.deprecated,tags:J?.tags,...J?.internal?{internal:!0}:{},type:et,typeSource:tt,value:re,defaultValue:Me,params:wt,returnType:Rt,isFunction:At,isFunctionDeclaration:ee,isRequired:te,constant:H==="const",reactive:this.ctx.reactive_vars.has(_),source:t(this.ctx,S)})}}if(W==="Comment"){let I=S?.data?.trim()??"";if(Lt.test(I))this.ctx.componentComment=I.replace(Lt,"").replace(dn,""),this.ctx.componentCommentSource=t(this.ctx,S)}if(W==="SlotElement"){let k=S,I=k.attributes?.find((H)=>H.name==="name")?.value,F=(Array.isArray(I)?I[0]:void 0)?.data,J=(k.attributes||[]).filter((H)=>H.name!=="name").reduce((H,ee)=>{let re={value:void 0,replace:!1},oe=ee.value;if(oe===void 0||oe===!0)return H;let be=Array.isArray(oe)?oe[0]:oe;if(be){let{type:De,expression:te,raw:Ne,start:Me,end:we}=be;if(De==="Text"&&Ne!==void 0)re.value=JSON.stringify(Ne);else if(!Array.isArray(oe)&&De==="ExpressionTag"&&te&&typeof te==="object"&&"type"in te&&te.type==="Identifier"&&"name"in te&&te.name===ee.name)re.value=te.name,re.replace=!0;if(te&&typeof te==="object"&&"type"in te){if(te.type==="Literal"&&"value"in te){let ke=te.value;re.value=typeof ke==="string"?JSON.stringify(ke):String(ke)}else if(te.type==="MemberExpression")re.value=B(this.ctx,this,te);else if(te.type!=="Identifier"){if(Me!==void 0&&we!==void 0){if(te.type==="ObjectExpression"||te.type==="TemplateLiteral")re.value=r(this.ctx,Me+1,we-1)}}}}if(ee.name)H[ee.name]=re;return H},{}),_=k.fragment?.nodes?.map(({start:H,end:ee})=>{if(H===void 0||ee===void 0)return"";return r(this.ctx,H,ee)??""}).join("").trim();R(this.ctx,{slot_name:F,slot_props:J,slot_fallback:_,source:t(this.ctx,S)})}if(W==="RenderTag"){let k=S,I=xe(this.ctx,k.expression);if(I){let F,J=!1;if(I.arguments.length===0)F={};else if(I.arguments.length===1&&typeof I.arguments[0]==="object"&&I.arguments[0]&&"type"in I.arguments[0]&&I.arguments[0].type==="ObjectExpression"){let ee=Y(this.ctx,this,I.arguments[0]);F=ee.slot_props,J=ee.hasUnresolvedSpread}else if(I.arguments.length===1)n(this.ctx,"syntax-skipped",I.publicName,`{@render ${I.publicName}(...)} argument is not a plain object literal; the render call was not mapped to slot metadata.`,t(this.ctx,S));let _=I.publicName==="children"?void 0:I.publicName,H=_===void 0?ln:_;if(F!==void 0)R(this.ctx,{slot_name:_,slot_props:F,slot_props_unresolved_spread:J||void 0,source:t(this.ctx,S)});if(F!==void 0||this.ctx.slots.has(H))this.ctx.snippetPropLocals.add(I.trackingName)}}if(W==="OnDirective"){let k=S;if(k.expression==null&&k.name){if(D!=null&&typeof D==="object"&&"name"in D){let I=typeof D.name==="string"?D.name:void 0,F="type"in D?String(D.type):void 0;if(I&&F){let J=Ve(F)?{type:"InlineComponent",name:I}:{type:"Element",name:I};this.ctx.forwardedEvents.set(k.name,J);let _=this.ctx.events.get(k.name),H=this.ctx.eventDescriptions.get(k.name),ee=_?.deprecated,re=_?.internal;if(!_)this.ctx.events.set(k.name,{type:"forwarded",name:k.name,element:J,description:H,deprecated:ee,...re?{internal:!0}:{},source:t(this.ctx,S)});else if(_.type==="forwarded"&&H&&!_.description)this.ctx.events.set(k.name,{..._,description:H,deprecated:_.deprecated??ee,..._.internal||re?{internal:!0}:{},source:_.source||t(this.ctx,S)})}}}}if(W==="BindDirective"&&D&&typeof D==="object"&&"type"in D&&(Oe(String(D.type))||Ve(String(D.type)))){let k=S;if(k.expression?.name){let I=Ge(this.ctx,k.expression.name);if(I)this.ctx.reactive_vars.add(I)}if(Oe(String(D.type))&&k.name==="this"&&k.expression?.name&&"name"in D&&typeof D.name==="string"){let I=Ge(this.ctx,k.expression.name);if(!I)return;let F=D.name;if(this.ctx.bindings.has(I)){let J=this.ctx.bindings.get(I);if(J&&!J.elements.includes(F))this.ctx.bindings.set(I,{...J,elements:[...J.elements,F]})}else this.ctx.bindings.set(I,{elements:[F]})}}},(S)=>{if(Ae(S))this.ctx.activeScopes.pop(),yt(Le,S)}),E!==void 0){Et(this,this.ctx,j,E,t(this.ctx,N));for(let S of Se)if(S.name===E){let D=S.arguments[0],w=D&&typeof D==="object"&&"value"in D?D.value:void 0,V=S.arguments[1],W=ue(this,V),k=W===void 0&&V&&typeof V==="object"&&"value"in V?V.value:void 0;if(w!=null)h(this.ctx,{name:String(w),detail:W??(k==null?"":z(k)),has_argument:Boolean(V),source:t(this.ctx,S.node)})}}let ve=new Set(q);if(E!==void 0){for(let S of Se)if(S.name===E){let D=S.arguments[0],w=D&&typeof D==="object"&&"value"in D?D.value:void 0;if(w!=null)ve.add(String(w))}}this.ctx.forwardedEvents.forEach((S,D)=>{let w=this.ctx.events.get(D);if(w&&w.type==="dispatched"&&!ve.has(D)){let V=this.ctx.eventDescriptions.get(D),W={type:"forwarded",name:D,element:S,description:V,deprecated:w.deprecated,tags:w.tags,source:w.source};if(w.internal)W.internal=!0;if(w.detail!==void 0&&w.detail!=="undefined")W.detail=w.detail;this.ctx.events.set(D,W)}}),Pt(this.ctx,ve);let _e=this.ctx.syntaxMode==="runes"?new Set(Array.from(this.ctx.snippetPropLocals,(S)=>this.resolvePublicPropName(S))):new Set,Re=s.mapToArray(this.ctx.props).filter((S)=>!_e.has(S.name)).map((S)=>{if(this.ctx.bindings.has(S.name)){let D=this.ctx.bindings.get(S.name)?.elements.sort().map((w)=>pt(w)).join(" | ");return{...S,type:`null | ${D}`,typeSource:"inferred",reactive:S.reactive||this.ctx.reactive_vars.has(S.name)}}return{...S,reactive:S.reactive||this.ctx.reactive_vars.has(S.name)}});this.ctx.activeScopes.length=0;let He=s.mapToArray(this.ctx.slots).map((S)=>{let{slot_props_unresolved_spread:D,...w}=S;if(!S.slot_props)return w;if(typeof S.slot_props==="string")return un.test(S.slot_props)?{...w,slot_props:"Record<string, never>"}:w;let V=S.slot_props,W=[];for(let F of Object.keys(V)){if(V[F].replace&&V[F].value!==void 0)V[F].value=this.getPropTypeByLocalOrPublic(V[F].value);if(V[F].value===void 0)V[F].value="any";W.push(`${F}: ${V[F].value}`)}let k=D?" & Record<string, any>":"",I=W.length===0?D?"Record<string, any>":"Record<string, never>":W.length===1?`{ ${W[0]} }${k}`:`{
3
- ${W.join(`;
4
- `)};
5
- }${k}`;return{...w,slot_props:I}}).sort((S,D)=>{let w=S.name??"",V=D.name??"";if(w<V)return-1;if(w>V)return 1;return 0});if(this.ctx.deferredSlotBlockGenerics.length>0){let S=[...Re.map((D)=>D.type??""),...He.map((D)=>D.slot_props??"")].join(`
6
- `);for(let{name:D,constraint:w}of this.ctx.deferredSlotBlockGenerics){let V=D.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(!new RegExp(`\\b${V}\\b`).test(S))continue;this.accumulateGeneric(D,w)}}if(this.ctx.scriptGenericsAttribute){if(this.ctx.generics)n(this.ctx,"syntax-skipped","generics",'Both the "generics" script attribute and @generics/@template JSDoc tags declare component generics; the script attribute takes precedence and the JSDoc declaration was ignored.',this.ctx.scriptGenericsAttribute.source);this.ctx.generics=ge(this.ctx.scriptGenericsAttribute.value)}let Fe=s.mapToArray(this.ctx.moduleExports),Je=s.mapToArray(this.ctx.events).map((S)=>{switch(S.type){case"forwarded":return{...S,element:S.element.name};case"dispatched":return S;default:return S}}).sort((S,D)=>{let w=S.name.localeCompare(D.name);if(w!==0)return w;let V=S.type.localeCompare(D.type);if(V!==0)return V;if(S.type==="forwarded"&&D.type==="forwarded"){let W=S.element.localeCompare(D.element);if(W!==0)return W}return(S.detail??"").localeCompare(D.detail??"")}),je=s.mapToArray(this.ctx.typedefs),Ke=s.mapToArray(this.ctx.contexts),ze={props:new Map(this.ctx.pendingCallDefaultCandidates.filter((S)=>S.location==="props").map((S)=>[S.propName,S])),moduleExports:new Map(this.ctx.pendingCallDefaultCandidates.filter((S)=>S.location==="moduleExports").map((S)=>[S.propName,S]))};for(let S of Re)if(S.typeSource==="unknown"){let D=ze.props.get(S.name);if(D)S.type="any";let w=D?D.importSource?`Prop "${S.name}" default calls "${D.calleeName}()" imported from "${D.importSource}"; falling back to "any" pending cross-file resolution.`:`Prop "${S.name}" default calls "${D.calleeName}()", but its return type could not be inferred; falling back to "any".`:`Prop "${S.name}" type could not be inferred; falling back to "${S.type??"any"}".`;n(this.ctx,"prop-unknown-type",S.name,w,S.source)}for(let S of Fe)if(S.typeSource==="unknown"&&ze.moduleExports.has(S.name))S.type="any";for(let S of this.ctx.jsDocEventNames){if(ve.has(S))continue;if(this.ctx.forwardedEvents.has(S))continue;if(this.ctx.props.has(`on${S}`))continue;n(this.ctx,"event-no-source",S,`@event "${S}" has no matching dispatch or callback prop.`,this.ctx.jsDocEventSources.get(S))}if(this.ctx.rest_props?.type==="InlineComponent")n(this.ctx,"rest-props-unresolved","$$restProps",`$$restProps is only spread onto component "${this.ctx.rest_props.name}"; sveld cannot infer its rest-prop type. Spread onto a plain element or add an @restProps tag.`);let Xe=je.filter((S)=>S.internal).map((S)=>S.name.split("<")[0]);if(Xe.length>0){let S=Xe.map((w)=>({name:w,regex:new RegExp(`\\b${w}\\b`)})),D=(w,V,W)=>{if(!V)return;for(let{name:k,regex:I}of S){if(!I.test(V))continue;n(this.ctx,"internal-typedef-referenced",w,`"${w}" references "${k}", which is @internal and excluded from output; the generated .d.ts will contain a dangling reference to it.`,W)}};for(let w of Re){if(w.internal)continue;D(w.name,w.type,w.source)}for(let w of Fe){if(w.internal)continue;D(w.name,w.type,w.source)}for(let w of je){if(w.internal)continue;D(w.name,w.ts)}for(let w of Je){if(w.internal||w.type!=="dispatched")continue;D(w.name,w.detail,w.source)}for(let w of He){if(w.internal)continue;D(w.name??"default",w.slot_props,w.source)}for(let w of Ke){if(w.internal)continue;for(let V of w.properties)D(V.name,V.type)}}let Ue={source:U(this.ctx,0,this.ctx.source?.length),syntaxMode:this.ctx.syntaxMode,...this.ctx.scriptLanguage?{scriptLanguage:this.ctx.scriptLanguage}:{},props:Re,moduleExports:Fe,slots:He,events:Je,typedefs:je,generics:this.ctx.generics,rest_props:this.ctx.rest_props,extends:this.ctx.extends,componentComment:this.ctx.componentComment,componentCommentSource:this.ctx.componentCommentSource,contexts:Ke,customElementTag:this.ctx.customElementTag,customElement:this.ctx.customElement,...this.ctx.cssParts.length>0?{cssParts:this.ctx.cssParts.slice()}:{},...this.ctx.cssProperties.length>0?{cssProperties:this.ctx.cssProperties.slice()}:{},diagnostics:this.ctx.diagnosticRecords.slice()},qe=he(this.ctx);if(qe)Ue[y]=qe;return Ue}}
7
- export{s};