/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@marko/language-tools@2.5.58/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(t,e)=>{for(var r in e)__defProp(t,r,{get:e[r],enumerable:!0})},__copyProps=(t,e,r,s)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let a of __getOwnPropNames(e))__hasOwnProp.call(t,a)||a===r||__defProp(t,a,{get:()=>e[a],enumerable:!(s=__getOwnPropDesc(e,a))||s.enumerable});return t},__toESM=(t,e,r)=>(r=null!=t?__create(__getProtoOf(t)):{},__copyProps(!e&&t&&t.__esModule?r:__defProp(r,"default",{value:t,enumerable:!0}),t)),__toCommonJS=t=>__copyProps(__defProp({},"__esModule",{value:!0}),t),index_exports={};__export(index_exports,{NodeType:()=>NodeType,Processors:()=>processors_exports,Project:()=>project_exports,ScriptLang:()=>ScriptLang,UNFINISHED:()=>UNFINISHED,extractHTML:()=>extractHTML,extractScript:()=>extractScript,extractStyle:()=>extractStyle,getExt:()=>getExt,getLines:()=>import_htmljs_parser2.getLines,getLocation:()=>import_htmljs_parser2.getLocation,getPosition:()=>import_htmljs_parser2.getPosition,isControlFlowTag:()=>isControlFlowTag,isDefinitionFile:()=>isDefinitionFile,parse:()=>parse}),module.exports=__toCommonJS(index_exports);var import_htmljs_parser=require("htmljs-parser");function getNodeAtOffset(t,e){const r=childAtOffset(t,e.body);return r?visitChildNode(t,r):childAtOffset(t,e.static)||e}function visitChildNode(t,e){switch(e.type){case 1:case 16:return visitTag(t,e);default:return e}}function visitTag(t,e){const{body:r}=e;if(r&&t>e.open.end){const s=childAtOffset(t,r);return s?visitChildNode(t,s):e}const{attrs:s}=e;if(s&&t>s[0].start){const r=childAtOffset(t,s);return r?visitAttrNode(t,r):e}const{var:a}=e;if(a&&t>a.start&&t<=a.end)return a;const{args:n}=e;if(n&&t>n.start&&t<=n.end)return n;const{params:i}=e;if(i&&t>i.start&&t<=i.end)return i;const{typeParams:o}=e;if(o&&t>o.start&&t<=o.end)return o;const{typeArgs:c}=e;if(c&&t>c.start&&t<=c.end)return c;const{name:p}=e;return p&&t<=p.end?p:e}function visitAttrNode(t,e){if(10===e.type){const{value:r}=e;if(r&&t>r.start)return r;const{name:s}=e;if(t>s.start&&t<=s.end)return s}return e}function childAtOffset(t,e){let r=e.length-1;if(-1===r)return;let s=0;for(;s<r;){const a=1+s+r>>>1;e[a].start<t?s=a:r=a-1}const a=e[s];return t>a.start&&t<=a.end?a:void 0}var import_htmljs_parser2=require("htmljs-parser"),styleBlockReg=/((?:\.[^\s\\/:*?"<>|({]+)*)\s*\{/y,UNFINISHED=Number.MAX_SAFE_INTEGER,NodeType=(t=>(t[t.Program=0]="Program",t[t.Tag=1]="Tag",t[t.OpenTagName=2]="OpenTagName",t[t.ShorthandId=3]="ShorthandId",t[t.ShorthandClassName=4]="ShorthandClassName",t[t.TagTypeArgs=5]="TagTypeArgs",t[t.TagTypeParams=6]="TagTypeParams",t[t.TagVar=7]="TagVar",t[t.TagArgs=8]="TagArgs",t[t.TagParams=9]="TagParams",t[t.AttrNamed=10]="AttrNamed",t[t.AttrName=11]="AttrName",t[t.AttrArgs=12]="AttrArgs",t[t.AttrValue=13]="AttrValue",t[t.AttrMethod=14]="AttrMethod",t[t.AttrSpread=15]="AttrSpread",t[t.AttrTag=16]="AttrTag",t[t.Text=17]="Text",t[t.CDATA=18]="CDATA",t[t.Doctype=19]="Doctype",t[t.Declaration=20]="Declaration",t[t.Comment=21]="Comment",t[t.Placeholder=22]="Placeholder",t[t.Scriptlet=23]="Scriptlet",t[t.Import=24]="Import",t[t.Export=25]="Export",t[t.Class=26]="Class",t[t.Style=27]="Style",t[t.Static=28]="Static",t))(NodeType||{});function parse(t,e="index.marko"){const r=new Builder(t),s=(0,import_htmljs_parser.createParser)(r);s.parse(t);const a=r.end();return{read:s.read,locationAt:s.locationAt,positionAt:s.positionAt,nodeAt:t=>getNodeAtOffset(t,a),filename:e,program:a,code:t}}var Builder=class{#t;#e;#r;#s;#a;#n;#i;constructor(t){this.#t=t,this.#e=this.#s={type:0,comments:void 0,parent:void 0,static:[],body:[],start:0,end:t.length}}end(){return this.#e.comments=this.#i,this.#e}onText(t){pushBody(this.#s,{type:17,parent:this.#s,start:t.start,end:t.end})}onCDATA(t){pushBody(this.#s,{type:18,parent:this.#s,value:t.value,start:t.start,end:t.end})}onDoctype(t){pushBody(this.#s,{type:19,parent:this.#s,value:t.value,start:t.start,end:t.end})}onDeclaration(t){pushBody(this.#s,{type:20,parent:this.#s,value:t.value,start:t.start,end:t.end})}onComment(t){const e={type:21,parent:this.#s,value:t.value,start:t.start,end:t.end};this.#i?this.#i.push(e):this.#i=[e]}onPlaceholder(t){pushBody(this.#s,{type:22,parent:this.#s,comments:this.#i,value:t.value,escape:t.escape,start:t.start,end:t.end}),this.#i=void 0}onScriptlet(t){pushBody(this.#s,{type:23,parent:this.#s,comments:this.#i,value:t.value,block:t.block,start:t.start,end:t.end}),this.#i=void 0}onOpenTagStart(t){this.#r=t}onOpenTagName(t){let e,r=!0,s=t.start,a=1,n=import_htmljs_parser.TagType.html;if(this.#r&&(r=!1,s=this.#r.start,this.#r=void 0),!t.expressions.length)switch(e=this.#t.slice(t.start,t.end)||"div"){case"style":{styleBlockReg.lastIndex=t.end;const e=styleBlockReg.exec(this.#t);if(e){const[{length:r},s]=e;return this.#e.static.push(this.#a={type:27,parent:this.#e,comments:this.#i,ext:s||void 0,value:{start:t.end+r,end:UNFINISHED},start:t.start,end:UNFINISHED}),this.#i=void 0,import_htmljs_parser.TagType.statement}n=import_htmljs_parser.TagType.text;break}case"class":return this.#e.static.push(this.#a={type:26,parent:this.#e,comments:this.#i,start:t.start,end:UNFINISHED}),this.#i=void 0,import_htmljs_parser.TagType.statement;case"export":return this.#e.static.push(this.#a={type:25,parent:this.#e,comments:this.#i,start:t.start,end:UNFINISHED}),this.#i=void 0,import_htmljs_parser.TagType.statement;case"import":return this.#e.static.push(this.#a={type:24,parent:this.#e,comments:this.#i,start:t.start,end:UNFINISHED}),this.#i=void 0,import_htmljs_parser.TagType.statement;case"server":case"client":case"static":return this.#e.static.push(this.#a={type:28,parent:this.#e,comments:this.#i,start:t.start,end:UNFINISHED}),this.#i=void 0,import_htmljs_parser.TagType.statement;case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"input":case"link":case"meta":case"param":case"source":case"track":case"wbr":case"const":case"debug":case"id":case"let":case"lifecycle":case"log":case"return":n=import_htmljs_parser.TagType.void;break;case"html-comment":case"html-script":case"html-style":case"script":case"textarea":n=import_htmljs_parser.TagType.text;break;default:"@"===e[0]&&(a=16)}const i=this.#s,o=UNFINISHED,c={type:2,parent:void 0,quasis:t.quasis,expressions:t.expressions,start:t.start,end:t.end},p=this.#s=c.parent={type:a,parent:i,comments:this.#i,owner:void 0,concise:r,selfClosed:!1,hasAttrTags:!1,open:{start:s,end:o},nameText:e,name:c,var:void 0,args:void 0,params:void 0,shorthandId:void 0,shorthandClassNames:void 0,typeArgs:void 0,typeParams:void 0,attrs:void 0,bodyType:n,body:void 0,close:void 0,start:s,end:o};if(this.#i=void 0,16===p.type){let t=i,e=p.nameText.slice(1);for(;1===t.type&&isControlFlowTag(t);)t.hasAttrTags=!0,t=t.parent;switch(t.type){case 16:p.owner=t.owner,t.hasAttrTags=!0,e=`${t.nameText}:${e}`;break;case 1:p.owner=t,t.hasAttrTags=!0,e=`${t.nameText||"*"}:${e}`}p.nameText=e}return pushBody(i,p),this.#r=void 0,n}onTagShorthandId(t){const e=this.#s;e.shorthandId={type:3,parent:e,quasis:t.quasis,expressions:t.expressions,start:t.start,end:t.end}}onTagShorthandClass(t){const e=this.#s,r={type:4,parent:e,quasis:t.quasis,expressions:t.expressions,start:t.start,end:t.end};e.shorthandClassNames?e.shorthandClassNames.push(r):e.shorthandClassNames=[r]}onTagTypeArgs(t){const e=this.#s;e.typeArgs={type:5,parent:e,value:t.value,start:t.start,end:t.end}}onTagTypeParams(t){const e=this.#s;e.typeParams={type:6,parent:e,value:t.value,start:t.start,end:t.end}}onTagVar(t){const e=this.#s;e.var={type:7,parent:e,value:t.value,start:t.start,end:t.end}}onTagParams(t){const e=this.#s;e.params={type:9,parent:e,value:t.value,start:t.start,end:t.end}}onTagArgs(t){const e=this.#s;e.args={type:8,parent:e,value:t.value,start:t.start,end:t.end}}onAttrName(t){const e=this.#s,r={type:11,parent:void 0,start:t.start,end:t.end};pushAttr(e,this.#n=r.parent={type:10,parent:e,name:r,value:void 0,args:void 0,start:t.start,end:t.end})}onAttrArgs(t){const e=this.#n;e.args={type:12,parent:e,value:t.value,start:t.start,end:t.end},e.end=t.end}onAttrValue(t){const e=this.#n;e.value={type:13,parent:e,value:t.value,bound:t.bound,start:t.start,end:t.end},e.end=t.end}onAttrMethod(t){const e=this.#n;e.value={type:14,parent:e,typeParams:t.typeParams,params:t.params,body:t.body,start:t.start,end:t.end},e.end=t.end}onAttrSpread(t){const e=this.#s;pushAttr(e,{type:15,parent:e,value:t.value,start:t.start,end:t.end})}onOpenTagEnd(t){if(this.#a)27===this.#a.type&&(this.#a.value.end=t.end-1),this.#a.end=t.end,this.#a=void 0;else{this.#n=void 0;const e=this.#s;e.open.end=t.end,(t.selfClosed||e.bodyType===import_htmljs_parser.TagType.void)&&(this.#s=e.parent,e.end=t.end,e.selfClosed=t.selfClosed)}}onCloseTagStart(t){this.#s.close={start:t.start,end:UNFINISHED}}onCloseTagEnd(t){const e=this.#s;hasCloseTag(e)&&(e.close.end=t.end),e.end=t.end,this.#s=e.parent}};function pushBody(t,e){t.body?t.body.push(e):t.body=[e]}function pushAttr(t,e){t.attrs?t.attrs.push(e):t.attrs=[e]}function hasCloseTag(t){return void 0!==t.close}function isControlFlowTag(t){switch(t.nameText){case"if":case"else":case"else-if":case"for":case"while":return!0;default:return!1}}var emptyView={offsetAt(t){},rangeAt(t,e){}},Extractor=class{#o;#c="";#p=[];constructor(t){this.#o=t}write(t){return this.#c+=t,this}copy(t){return t&&("string"==typeof t?this.#c+=t:(this.#p.push({generatedStart:this.#c.length,sourceStart:t.start,length:Math.min(this.#o.code.length,t.end)-t.start}),this.#c+=this.#o.read(t))),this}end(){return new Extracted(this.#o,this.#c,this.#p)}},Extracted=class{constructor(t,e,r){this.parsed=t,this.#c=e,0===r.length?this.#d=this.#h=emptyView:(this.#d=new GeneratedToSourceView(r),this.#h=new SourceToGeneratedView([...r].sort(sortBySourceThenGenerated)))}#c;#h;#d;#l;get#u(){return this.#l||(this.#l=(0,import_htmljs_parser2.getLines)(this.#c))}sourceOffsetAt(t){return this.#d.offsetAt(t)}sourcePositionAt(t){const e=this.sourceOffsetAt(t);if(void 0!==e)return this.parsed.positionAt(e)}sourceRangeAt(t,e){return this.#d.rangeAt(t,e)}sourceLocationAt(t,e){const r=this.sourceRangeAt(t,e);if(r)return this.parsed.locationAt(r)}generatedOffsetAt(t){return this.#h.offsetAt(t)}generatedPositionAt(t){const e=this.generatedOffsetAt(t);if(void 0!==e)return(0,import_htmljs_parser2.getPosition)(this.#u,e)}generatedRangeAt(t,e){return this.#h.rangeAt(t,e)}generatedLocationAt(t,e){const r=this.generatedRangeAt(t,e);if(r)return(0,import_htmljs_parser2.getLocation)(this.#u,r.start,r.end)}toString(){return this.#c}},TokenView=class{#p;#m;constructor(t){this.#p=t,this.#m=t.length-1}offsetAt(t){let e=0,r=this.#m;for(;e<r;){const s=1+e+r>>>1;this.inStart(this.#p[s])<=t?e=s:r=s-1}const s=this.#p[e],a=t-this.inStart(s);if(a>=0&&a<=s.length)return this.outStart(s)+a}rangeAt(t,e){let r=0,s=this.#m;for(;r<s;){const e=r+s>>1,a=this.#p[e];this.inStart(a)+a.length>t?s=e:r=e+1}const a=this.#p[s],n=this.inStart(a);if(n>=e)return;for(s=this.#m;r<s;){const t=1+r+s>>>1,a=this.#p[t];this.inStart(a)+a.length<=e?r=t:s=t-1}const i=this.#p[r],o=this.inStart(i);if(o+i.length<t)return;const c=t-n,p=e-o;return{start:this.outStart(a)+Math.max(0,c),end:this.outStart(i)+Math.min(i.length,p)}}},GeneratedToSourceView=class extends TokenView{inStart(t){return t.generatedStart}outStart(t){return t.sourceStart}},SourceToGeneratedView=class extends TokenView{inStart(t){return t.sourceStart}outStart(t){return t.generatedStart}};function sortBySourceThenGenerated(t,e){const r=t.sourceStart-e.sourceStart;return 0===r?e.generatedStart-t.generatedStart:r}var builtinTagsRegex=/^(?:a(?:(?:bbr|cronym|ddress|pplet|r(?:ea|ticle)|side|udio))?|b(?:(?:ase(?:font)?|d[io]|gsound|ig|l(?:ink|ockquote)|ody|r|utton))?|c(?:a(?:nvas|ption)|enter|ite|o(?:de|l(?:group)?|mmand|ntent))|d(?:ata(?:list)?|d|e(?:l|tails)|fn|i(?:alog|r|v)|l|t)|e(?:lement|m(?:bed)?)|f(?:i(?:eldset|g(?:caption|ure))|o(?:nt|oter|rm)|rame(?:set)?)|h(?:1|2|3|4|5|6|ead(?:er)?|group|r|tml)|i(?:(?:frame|m(?:age|g)|n(?:put|s)|sindex))?|k(?:bd|eygen)|l(?:abel|egend|i(?:(?:nk|sting))?)|m(?:a(?:in|p|r(?:k|quee)|th)|e(?:nu(?:item)?|t(?:a|er))|ulticol)|n(?:av|extid|o(?:br|embed|frames|script))|o(?:bject|l|pt(?:group|ion)|utput)|p(?:(?:aram|icture|laintext|r(?:e|ogress)))?|q|r(?:bc?|p|tc?|uby)|s(?:(?:amp|cript|e(?:ction|lect)|hadow|lot|mall|ource|pa(?:cer|n)|t(?:r(?:ike|ong)|yle)|u(?:b|mmary|p)|vg))?|t(?:able|body|d|e(?:mplate|xtarea)|foot|h(?:ead)?|i(?:me|tle)|r(?:ack)?|t)|ul?|v(?:ar|ideo)|wbr|xmp)$/;function isHTMLTag(t){return builtinTagsRegex.test(t)}function getAttributeValueType(t){if(void 0!==t&&"="===t[0]){switch(t=t.substring(1).trim()){case"NaN":case"Infinity":case"-Infinity":return 1;case"null":case"false":case"undefined":return;case"true":return 0}return/^"(?:[^"\\]|\\.)*"$/.test(t)||/^'(?:[^'\\]|\\.)*'$/.test(t)||/^`(?:[^`\\$]|\\.|\$(?!\{))*`$/.test(t)?2:/^-?0[oO]?[0-7](?:_?[0-7]+)*n?$/.test(t)||/^-?0[xX][0-9a-fA-F](?:_?[0-9a-fA-F]+)*n?$/.test(t)||/^-?0[bB][01](?:_?[01]+)*n?$/.test(t)||/^-?\d(?:_?\d+)*(?:[.eE]\d(?:_?\d+)*|n?|\.?)$/.test(t)?1:3}}function extractHTML(t){return new HTMLExtractor(t).end()}var HTMLExtractor=class{#g;#f;#y;#T;constructor(t){this.#g=new Extractor(t),this.#f=t.read.bind(t),this.#y={},this.#T=0,t.program.body.forEach((t=>this.#v(t)))}end(){return{extracted:this.#g.end(),nodeDetails:this.#y}}#v(t){var e;let r=!1,s=!1,a=!1;switch(t.type){case 16:null==(e=t.body)||e.forEach((t=>{this.#v(t)&&(r=!0)}));break;case 1:{if("script"===t.nameText||"style"===t.nameText)break;const e=""+this.#T++;({isDynamic:a,hasDynamicAttrs:s,hasDynamicBody:r}=this.#w(t,e)),this.#y[e]={hasDynamicAttrs:s,hasDynamicBody:r};break}case 17:this.#g.copy(t);break;case 22:a="!"===this.#f({start:t.start+1,end:t.start+2}),this.#g.write("placeholder")}return a||r}#w(t,e){const r=!t.nameText||!isHTMLTag(t.nameText);let s=!1,a=!1;return r?this.#x(t):({hasDynamicAttrs:s,hasDynamicBody:a}=this.#A(t,e)),{isDynamic:r,hasDynamicAttrs:s,hasDynamicBody:a}}#A(t,e){var r,s;let a=!1,n=!1;return this.#g.write("<"),this.#g.copy(isEmptyRange(t.name)?t.nameText:t.name),this.#g.write(` data-marko-node-id="${e}"`),null==(r=t.attrs)||r.forEach((t=>{10===t.type?this.#_(t):15===t.type&&(a=!0)})),this.#g.write(">"),isVoidTag(t.nameText)||(null==(s=t.body)||s.forEach((t=>{this.#v(t)&&(n=!0)})),this.#g.write(`</${t.nameText}>`)),{hasDynamicAttrs:a,hasDynamicBody:n}}#x(t){t.body&&(this.#g.write("<div>"),t.body.forEach((t=>this.#v(t))),this.#g.write("</div>"))}#_(t){this.#g.write(" ");const e=this.#f(t.name);if(/:(?:scoped|(?:no-update(?:-if)?))$/.test(e)?this.#g.copy({start:t.name.start,end:t.name.start+e.lastIndexOf(":")}):this.#g.copy(t.name),void 0===t.value||t.name.start===t.name.end||14===t.value.type)return;const r=this.#f(t.value),s=getAttributeValueType(r);if(void 0!==s)switch(s){case 0:break;case 1:this.#g.write('="'),this.#g.copy({start:t.value.start+r.search(/[^=\s]/g),end:t.value.end}),this.#g.write('"');break;case 2:this.#g.write('="'),this.#g.copy({start:t.value.start+r.search(/[^=\s]/g)+1,end:t.value.end-1}),this.#g.write('"');break;case 3:this.#g.write('="dynamic"')}}};function isVoidTag(t){switch(t){case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"input":case"link":case"meta":case"param":case"source":case"track":case"wbr":return!0;default:return!1}}function isEmptyRange(t){return t.start===t.end}var import_relative_import_path=require("relative-import-path"),import_compiler=require("@marko/compiler"),VISITOR_KEYS=import_compiler.types.VISITOR_KEYS,ATTR_UNNAMED="value",Scopes=new WeakMap,BoundAttrValueRange=new WeakMap;function crawlProgramScope(t,e){var r;const{program:s}=t,a=[],n=[],i=new Map,o={parent:void 0,hoists:!1,bindings:{}};o.bindings.input={type:1,name:"input",node:s,scope:o,hoisted:!1},function r(s,a){var o;for(const p of s)switch(p.type){case 1:case 16:if(p.var){a.bindings??={};const r=e.tagVar(p.var);if(r){c(a,r);for(const e of getVarIdentifiers(t,r,"",ATTR_UNNAMED)){const{name:t,objectPath:r,sourceName:s}=e,i=a.bindings[t]={type:0,name:t,node:p,scope:a,hoisted:!1,mutated:!1,objectPath:r,sourceName:s};n.push(i)}}}if(p.body){const t={parent:a,hoists:!1,bindings:{}};if(p.params){t.bindings??={};const r=e.tagParams(p.params);if(r)for(const e of r){c(t,e);for(const r of getIdentifiers(e))t.bindings[r]={type:1,name:r,node:p,scope:t,hoisted:!1}}}const s=e.scriptBody(p);if(s){const t=i.get(a);t?t.push(...s):i.set(a,[...s])}else r(p.body,t);Scopes.set(p.body,t)}if(p.attrs)for(const t of p.attrs)switch(t.type){case 15:c(a,e.attrSpread(t));break;case 10:switch(null==(o=t.value)?void 0:o.type){case 13:{let r=e.attrValue(t.value);if(r)if(t.value.bound){let e;if("TSAsExpression"!==r.type&&"TSSatisfiesExpression"!==r.type||(e={start:r.expression.end+1,end:r.end},r=r.expression),"Identifier"===r.type){const s=resolveWritableVar(a,r.name);s&&(s.mutated=!0),BoundAttrValueRange.set(t.value,{types:e,value:{start:r.start,end:r.end},member:void 0})}else"MemberExpression"===r.type&&BoundAttrValueRange.set(t.value,{types:e,value:{start:r.start,end:r.property.start-1},member:{start:r.property.start,end:r.property.end,computed:r.computed}})}else c(a,r);break}case 14:c(a,e.attrMethod(t.value))}}}}(s.body,o),Scopes.set(s.body,o);for(const t of n){const{scope:e,name:s}=t;let a=e.parent;for(;a;){const e=null==(r=a.bindings)?void 0:r[s];if(e){2===e.type&&(t.hoisted=!0,e.bindings.push(t));break}if(a===o){t.hoisted=!0,o.bindings[s]={type:2,scope:o,bindings:[t],hoisted:!1};break}a=a.parent}if(t.hoisted)for(e.hoists=!0,a=e.parent;a&&!a.hoists&&a!==o;)a.hoists=!0,a=a.parent}for(const[t,e]of i){const r=new Set,s=[];for(const n of e)trackMutations(n,t,a,r,s);flushMutations(t,a,r,s)}if(a.length)return a.sort(byStart);function c(t,e){e&&traverse(e,(e=>{switch(e.type){case"FunctionDeclaration":case"FunctionExpression":case"ObjectMethod":case"ArrowFunctionExpression":case"ClassMethod":case"ClassPrivateMethod":{const r=i.get(t);return r?r.push(e):i.set(t,[e]),!0}}}))}}function getProgramBindings(t){const{bindings:e}=Scopes.get(t.body);let r,s;for(const t in e)switch(e[t].type){case 2:r?r.push(t):r=[t];break;case 0:s?s.push(t):s=[t]}if(r||s)return{all:s?r?[...s,...r]:s:r,vars:s,hoists:r}}function getMutatedVars(t){const{bindings:e}=Scopes.get(t.parent.body);let r;for(const s in e){const a=e[s];0==a.type&&a.node===t&&a.mutated&&(r?r.push(a):r=[a])}return r}function getHoistSources(t){let e;if(t){const{bindings:r}=Scopes.get(t);for(const t in r)r[t].hoisted&&(e?e.push(t):e=[t])}return e}function isMutatedVar(t,e){var r;let s=Scopes.get(t.body);for(;s;){const t=null==(r=s.bindings)?void 0:r[e];if(0===(null==t?void 0:t.type)&&t.mutated)return!0;s=s.parent}return!1}function hasHoists(t){return!!t.body&&Scopes.get(t.body).hoists}function getBoundAttrRange(t){return BoundAttrValueRange.get(t)}function resolveWritableVar(t,e){var r;let s=t;do{const t=null==(r=s.bindings)?void 0:r[e];if(0===(null==t?void 0:t.type)&&void 0!==t.sourceName)return t}while(s=s.parent)}function*getIdentifiers(t){switch(t.type){case"Identifier":yield t.name;break;case"ObjectPattern":for(const e of t.properties)"RestElement"===e.type?yield*getIdentifiers(e.argument):yield*getIdentifiers(e.value);break;case"ArrayPattern":for(const e of t.elements)e&&("RestElement"===e.type?yield*getIdentifiers(e.argument):yield*getIdentifiers(e));break;case"AssignmentPattern":yield*getIdentifiers(t.left)}}function*getVarIdentifiers(t,e,r,s){switch(e.type){case"Identifier":yield{name:e.name,objectPath:r,sourceName:s};break;case"ObjectPattern":for(const a of e.properties)if("RestElement"===a.type)yield*getVarIdentifiers(t,a.argument,r,s);else{let e,s;"Identifier"===a.key.type?(e=a.key.name,s=`.${e}`):(e=t.read(a.key),s=`[${e}]`),yield*getVarIdentifiers(t,a.value,r+s,e)}break;case"ArrayPattern":{let s=-1;for(const a of e.elements)s++,a&&("RestElement"===a.type?yield*getVarIdentifiers(t,a.argument,r):yield*getVarIdentifiers(t,a,r+`[${s}]`));break}case"AssignmentPattern":yield*getVarIdentifiers(t,e.left,r,s)}}function trackMutations(t,e,r,s,a){if(!t)return;let n=s,i=a;switch(t.type){case"BlockStatement":i===a&&(n=new Set(n),i=[]);break;case"ForStatement":case"ForInStatement":case"ForOfStatement":n=new Set(n),i=[];break;case"ArrowFunctionExpression":case"ObjectMethod":case"ClassMethod":case"ClassPrivateMethod":n=new Set(n),i=[];for(const r of t.params)trackShadows(r,e,n);break;case"FunctionExpression":n=new Set(n),i=[],t.id&&trackShadows(t.id,e,n);for(const r of t.params)trackShadows(r,e,n);break;case"FunctionDeclaration":trackShadows(t.id,e,s),n=new Set(n),i=[];for(const r of t.params)trackShadows(r,e,n);break;case"ClassExpression":n=new Set(n),i=[],t.id&&trackShadows(t.id,e,n);break;case"ClassDeclaration":t.id&&trackShadows(t.id,e,s),n=new Set(n),i=[];break;case"CatchClause":n=new Set(n),i=[],t.param&&trackShadows(t.param,e,n);break;case"VariableDeclaration":for(const r of t.declarations)trackShadows(r.id,e,n);break;case"UpdateExpression":"Identifier"===t.argument.type&&a.push(t.argument);break;case"AssignmentExpression":"Identifier"===t.left.type&&a.push(t.left)}for(const s of VISITOR_KEYS[t.type]){const a=t[s];if(Array.isArray(a))for(const t of a)trackMutations(t,e,r,n,i);else trackMutations(a,e,r,n,i)}i!==a&&i.length&&flushMutations(e,r,n,i)}function flushMutations(t,e,r,s){for(const{name:a,start:n}of s){if(null==n||r.has(a))continue;const s=resolveWritableVar(t,a);s&&(s.mutated=!0,e.push({start:n,binding:s}))}}function trackShadows(t,e,r){for(const s of getIdentifiers(t))resolveWritableVar(e,s)&&r.add(s)}function traverse(t,e){if(t&&!e(t))for(const r of VISITOR_KEYS[t.type]){const s=t[r];if(Array.isArray(s))for(const t of s)traverse(t,e);else traverse(s,e)}}function byStart(t,e){return t.start-e.start}var import_fs=__toESM(require("fs")),import_path=__toESM(require("path"));function getComponentFilename(t){const e=import_path.default.dirname(t);let r=import_path.default.basename(t,".marko");r.endsWith(".d")&&(r=r.slice(0,-2));const s="index"===r,a=`(${r.replace(/[.*+?^$[\]()|\\:!{}]/g,"\\$&")}\\.${s?"|":""})`,n=new RegExp(`^${a}component(-browser)?\\.\\w+$`);for(const t of tryReaddirSync(e))if(n.test(t))return import_path.default.join(e,t)}function tryReaddirSync(t){try{return import_fs.default.readdirSync(t)}catch{return[]}}var RuntimeAPI={tags:"tags",class:"class"};function getRuntimeAPI(t,e,r){const s=detectAPIFromTranslator(t);return{interop:!s,api:s||detectAPIFromFileName(r.filename,e)||detectAPIFromProgram(r,r.program)||("tags"===e.exclusiveTagDiscoveryDirs?RuntimeAPI.tags:RuntimeAPI.class)}}function detectAPIFromTranslator(t){if("tags"===(null==t?void 0:t.preferAPI))return RuntimeAPI.tags}function detectAPIFromFileName(t,e){var r;const s=getTagsDir(t);if(s&&!(null==(r=e.manualTagsDirs)?void 0:r.has(s)))return RuntimeAPI.tags}function getTagsDir(t){var e;const r=null==(e=/\/|\\/.exec(t))?void 0:e[0];if(r){let e=t.length-1;for(;e>0;){const s=t.lastIndexOf(r,e);switch(e-s){case 4:if(t.startsWith("tags",s+1))return t.slice(0,s+5);break;case 10:if(t.startsWith("components",s+1))return!1}e=s-1}}return!1}function detectAPIFromProgram(t,e){if(e.comments)switch(t.read(e.comments[0].value).trim()){case"use tags":return RuntimeAPI.tags;case"use class":return RuntimeAPI.class}if(e.static)for(const t of e.static)switch(t.type){case 26:case 27:return RuntimeAPI.class}return detectAPIFromBody(t,e.body)}function detectAPIFromBody(t,e){if(e)for(const r of e){const e=detectAPIFromChild(t,r);if(e)return e}}function detectAPIFromChild(t,e){switch(e.type){case 23:return RuntimeAPI.class;case 1:case 16:return detectAPIFromTag(t,e)}}function detectAPIFromTag(t,e){var r;if(e.var)return RuntimeAPI.tags;switch(e.nameText){case"await-reorderer":case"include-html":case"include-text":case"init-components":case"macro":case"module-code":case"while":return RuntimeAPI.class;case"const":case"debug":case"define":case"id":case"let":case"lifecycle":case"log":case"return":case"try":return RuntimeAPI.tags}if(e.attrs)for(const s of e.attrs)if(15!==s.type){if(13===(null==(r=s.value)?void 0:r.type)&&s.value.bound)return RuntimeAPI.tags;if(s.args)return RuntimeAPI.class;if(/:/.test(t.read(s.name)))return RuntimeAPI.class}return detectAPIFromBody(t,e.body)}function isTextOnlyScript(t){if("script"!==t.nameText||t.args||t.attrs||!t.body)return!1;for(const e of t.body)if(17!==e.type)return!1;return!0}var MaybeInputTypedefReg=/@typedef\b[\s\S]*\bInput\b/;function getJSDocInputType(t,e){var r,s,a,n;if(!MaybeInputTypedefReg.test(t))return;const i=e.createSourceFile("_.js",t,e.ScriptTarget.Latest,!1,e.ScriptKind.JS),o=null==(s=null==(r=i.endOfFileToken.jsDoc)?void 0:r[0])?void 0:s.tags;if(!o||!hasInputTypeDef(e,i,o))return;let c;for(const t of o)if(isTemplateTag(e,t)){let e=null==(a=t.constraint)?void 0:a.type.getText(i);for(const r of t.typeParameters){const t={name:""+r.name.escapedText,constraint:e,default:null==(n=r.default)?void 0:n.getText(i)};e=void 0,c?c.push(t):c=[t]}}return{typeParameters:c}}function hasInputTypeDef(t,e,r){var s;for(const a of r)if(isTypeDefTag(t,a)&&"Input"===(null==(s=a.fullName)?void 0:s.getText(e)))return!0;return!1}function isTypeDefTag(t,e){return e.kind===t.SyntaxKind.JSDocTypedefTag}function isTemplateTag(t,e){return e.kind===t.SyntaxKind.JSDocTemplateTag}var RuntimeOverloads=new Map,commentsReg=/\/\*(?:[^*]|\*[^/])*\*\//gm,replaceTokensReg=/\babstract\s+(\w+)|Marko\.(TemplateInput(?:<[^>]+>)?|Component)|\b(Return)\b/gm,overrideBlockReg=/\/\*[*\s]*@marko-overload-start[*\s]*\*\/([\s\S]+)\/\*[*\s]*@marko-overload-end[*\s]*\*\//g;function getRuntimeOverrides(t,e,r,s,a){let n=RuntimeOverloads.get(e);if(!n){const t=overrideBlockReg.exec(e);if(RuntimeOverloads.set(e,n=[]),t){let e,[,r]=t,s=0;for(r=r.replace(commentsReg,"");e=replaceTokensReg.exec(r);){const[,t,a,i]=e,o=r.slice(s,e.index);s=replaceTokensReg.lastIndex,t?n.push(o+t,0):i?n.push(o,2):n.push(o,"Component"===a?3:1)}n.push(r.slice(s))}}let i="";const o=`Marko.TemplateInput<Input${s}>`,c=t===RuntimeAPI.tags?"never":`Component${s}`;for(const t of n)switch(t){case 0:i+=r;break;case 1:i+=o;break;case 2:i+=a;break;case 3:i+=c;break;default:i+=t}return i}var import_babel=require("@marko/compiler/internal/babel"),plugins=["exportDefaultFrom","importAssertions","typescript"],ScriptParser=class{#o;#S=new Map;constructor(t){this.#o=t}tagName(t){return this.#b(t)}tagShorthandId(t){return this.#b(t)}tagShorthandClassName(t){return this.#b(t)}tagVar(t){const e=t.value.start-1,r=this.#S.get(e)??this.#E(e,`(${this.#o.read(t.value)})=>0`);if(r)return r.params[0]}tagParams(t){const e=t.start,r=this.#S.get(e)??this.#E(e,`(${this.#o.read(t.value)})=>0`);if(r)return r.params}tagTypeParams(t){const e=t.value.start-1,r=this.#S.get(e)??this.#E(e,`<${this.#o.read(t.value)}>()=>0`);if(r)return r.typeParameters}tagArgs(t){const e=t.value.start-2,r=this.#S.get(e)??this.#E(e,`_(${this.#o.read(t.value)})`);if(r)return r.arguments}tagTypeArgs(t){const e=t.value.start-2,r=this.#S.get(e)??this.#E(e,`_<${this.#o.read(t.value)}>()`);if(r)return r.typeParameters}attrValue(t){const e=t.value.start;return(this.#S.get(e)??this.#E(e,this.#o.read(t.value)))||void 0}attrSpread(t){const e=t.value.start;return(this.#S.get(e)??this.#E(e,this.#o.read(t.value)))||void 0}attrMethod(t){const e=t.params.start-2,r=this.#S.get(e)??this.#E(e,`{_${this.#o.read({start:t.params.start,end:t.body.end})}}`);if(r)return r.properties[0]}attrArgs(t){const e=t.value.start;return(this.#S.get(e)??this.#E(e,this.#o.read(t.value)))||void 0}placeholder(t){const e=t.value.start;return(this.#S.get(e)??this.#E(e,this.#o.read(t.value)))||void 0}scriptBody(t){if(!isTextOnlyScript(t))return;const e=t.body[0].start,r=this.#S.get(e)??this.#N(e,this.#o.read({start:e,end:t.body[t.body.length-1].end}));return r||void 0}scriptlet(t){const e=t.value.start,r=this.#S.get(e)??this.#N(e,this.#o.read(t.value));if(r)return r}import(t){const e=this.#S.get(t.start)??this.#N(t.start,this.#o.read(t));if(e)return e[0]}export(t){const e=this.#S.get(t.start)??this.#N(t.start,this.#o.read(t));if(e)return e[0]}class(t){return(this.#S.get(t.start)??this.#E(t.start,this.#o.read(t)))||void 0}static(t){const e=t.start+7,r=this.#S.get(e)??this.#N(e,this.#o.read({start:e,end:t.end}));if(r)return r}#b(t){const{expressions:e}=t;if(!e.length)return;const r=[];for(const t of e){const e=t.value.start,s=this.#S.get(e)??this.#E(e,this.#o.read(t.value));if(!s)return;r.push(s)}return r.length?r:void 0}#N(t,e){try{const r=this.#o.positionAt(t),s=(0,import_babel.parse)(e,{plugins:plugins,startIndex:t,startLine:r.line+1,startColumn:r.character,strictMode:!0,errorRecovery:!0,sourceType:"module",allowUndeclaredExports:!0,allowSuperOutsideMethod:!0,allowAwaitOutsideFunction:!0,allowReturnOutsideFunction:!0,sourceFilename:this.#o.filename}).program.body;if(s.length)return this.#S.set(t,s),s}catch{}this.#S.set(t,!1)}#E(t,e){try{const r=this.#o.positionAt(t),s=(0,import_babel.parseExpression)(e,{plugins:plugins,startIndex:t,startLine:r.line+1,startColumn:r.character,strictMode:!0,errorRecovery:!0,sourceType:"module",allowUndeclaredExports:!0,allowSuperOutsideMethod:!0,allowAwaitOutsideFunction:!0,allowReturnOutsideFunction:!0,sourceFilename:this.#o.filename});return this.#S.set(t,s),s}catch{this.#S.set(t,!1)}}},SEP_EMPTY="",SEP_SPACE=" ",SEP_COMMA_SPACE=", ",SEP_COMMA_NEW_LINE=",\n",VAR_LOCAL_PREFIX="__marko_internal_",VAR_SHARED_PREFIX="Marko._.",ATTR_UNNAMED2="value",REG_EXT=/(?<=[/\\][^/\\]+)\.[^.]+$/,REG_BLOCK=/\s*{/y,REG_NEW_LINE=/^|(\r?\n)/g,REG_ATTR_ARG_LITERAL=/(?<=\s*)(["'])((?:[^"'\\]|\\.|(?!\1))*)\1\s*([,)])/my,REG_TAG_IMPORT=/(?<=(['"]))<([^'">]+)>(?=\1)/,REG_INPUT_TYPE=/\s*(interface|type)\s+Input\b/y,REG_OBJECT_PROPERTY=/^[_$a-z][_$a-z0-9]*$/i,REG_COMMENT_PRAGMA=/\/\/(?:\s*@ts-|\/\s*<)/y,REG_TAG_NAME_IDENTIFIER=/^[A-Z][a-zA-Z0-9_$]+$/,IF_TAG_ALTERNATES=new WeakMap,TAG_ID=new WeakMap,RENDER_VAR=new WeakMap,TEMPLATE_VAR=new WeakMap,WROTE_COMMENT=new WeakSet,START_OF_FILE={start:0,end:0},ScriptLang=(t=>(t.js="js",t.ts="ts",t))(ScriptLang||{});function extractScript(t){return new ScriptExtractor(t).end()}var ScriptExtractor=class{#t;#C;#I;#$;#o;#g;#R;#f;#k;#P;#M;#D;#L;#O=1;#F=[0];constructor(t){const{parsed:e,lookup:r,scriptLang:s}=t,{api:a,interop:n}=getRuntimeAPI(t.translator,t.lookup,e);this.#t=e.code,this.#C=e.filename,this.#I=a,this.#$=n,this.#P=s,this.#o=e,this.#k=r,this.#M=t.ts,this.#D=t.runtimeTypesCode,this.#g=new Extractor(e),this.#R=new ScriptParser(e),this.#f=e.read.bind(e),this.#L=crawlProgramScope(this.#o,this.#R),this.#j(e.program)}end(){return this.#g.end()}#j(t){this.#V(t);const e=this.#I===RuntimeAPI.class?getComponentFilename(this.#C):void 0,r=this.#B(t);let s;for(const e of t.static)switch(e.type){case 26:this.#W(e),s={start:e.start+5,end:e.end};break;case 25:this.#W(e),this.#g.copy(e).write("\n");break;case 24:{const t=REG_TAG_IMPORT.exec(this.#f(e));if(this.#W(e),t){const[,,r]=t,s=resolveTagImport(this.#C,this.#k.getTag(r));if(s){const[{length:r}]=t,a=e.start+t.index;this.#g.copy({start:e.start,end:a}).write(s).copy({start:a+r,end:e.end}).write("\n");break}}this.#g.copy(e).write("\n");break}case 28:{let t=e.start+7,r=e.end;this.#W(e),this.#G(REG_BLOCK,t)&&(t=REG_BLOCK.lastIndex,r--),this.#g.copy({start:t,end:r}).write("\n");break}}let a="",n="",i="";const o=!s&&void 0!==e;if(r){if(r.typeParameters){let t=SEP_EMPTY;a=n="<";for(const e of r.typeParameters)a+=t+e.name+(e.constraint?` extends ${e.constraint}`:"")+(e.default?` = ${e.default}`:""),n+=t+e.name,t=SEP_COMMA_SPACE;if(a+=">",n+=">","js"===this.#P)for(const t of r.typeParameters)i+=`\n* @template ${t.constraint?`{${removeNewLines(t.constraint)}} `:""}${t.default?`[${t.name} = ${removeNewLines(t.default)}]`:t.name}`}}else"ts"===this.#P?this.#g.write(o?"export type Input = Component['input'];\n":"export interface Input {}\n"):this.#g.write("/** @typedef {Record<string, unknown>} Input */\n");if(this.#I===RuntimeAPI.class)if(o){const t=`"${stripExt((0,import_relative_import_path.relativeImportPath)(this.#C,e))}"`;"ts"===this.#P?n?this.#g.write(`import type Component from ${t};\nexport type { Component };\n`):this.#g.write(`export interface Component extends ${varShared("ResolveComponent")}<typeof import(${t})> {}\n`):n?this.#g.write(`/** @import Component from ${t} */\n`):this.#g.write(`/** @typedef {${varShared("ResolveComponent")}<typeof import(${t})>} Component */\n`)}else{const t=s||" {}";"ts"===this.#P?this.#g.write(`abstract class Component${a} extends Marko.Component<Input${n}>`).copy(t).write("\nexport { type Component }\n"):(this.#g.write(`/**${i}\n    * @extends {Marko.Component<Input${n}>}\n    * @abstract\n    */\n`),this.#g.write("export class Component extends Marko.Component").copy(t).write("\n"))}const c=!!getReturnTag(t),p=c?varLocal("template"):"";c||this.#g.write("("),"ts"===this.#P?this.#g.write(`function ${p}${a}(this: void) {\n`):this.#g.write(`/**${i}\n* @this {void}\n*/\nfunction ${p}() {\n`),this.#g.write(`  const input = ${this.#H(`Input${n}`)};${this.#I===RuntimeAPI.class?`\n  const component = ${this.#H(`Component${n}`)};\n  const state = ${varShared("state")}(component);\n  const out = ${this.#H("Marko.Out")};`:""}\n  const $signal = ${this.#H("AbortSignal")};\n  const $global = ${varShared("getGlobal")}(\n    // @ts-expect-error We expect the compiler to error because we are checking if the MarkoRun.Context is defined.\n    (${varShared("error")}, ${this.#H("MarkoRun.Context")})\n  );\n`);const d=this.#U(t),h=getProgramBindings(t);if(h)for(const t of h.all)this.#g.write(`const ${t} = ${varShared("hoist")}(() => ${varLocal(`hoist__${t}`)});\n`);if(null==d?void 0:d.content){if(this.#J(d.content),h){if(h.vars)for(const t of h.vars)this.#g.write(`var ${varLocal(`hoist__${t}`)} = ${t};\n`);h.hoists&&this.#g.write(`var {${h.hoists.map((t=>`${t}: ${varLocal(`hoist__${t}`)}`)).join(SEP_COMMA_SPACE)}} = ${this.#q(t.body)};\n`)}this.#K()}this.#g.write(`${varShared("noop")}({ ${h?h.all.join(SEP_COMMA_SPACE)+SEP_COMMA_SPACE:""}${this.#I===RuntimeAPI.class?"component, state, out, ":""}input, $global, $signal });\n`),c?this.#g.write(`return ${varLocal("return")};\n}\n`):this.#g.write("return;\n})();\n");const l=varShared("Template"),u=varLocal("input"),m=`${u} extends unknown`,g=varLocal("apply"),f=c?`typeof ${p+n} extends () => infer Return ? Return : never`:"void",y=`(input: Marko.Directives & Input${n} & ${varShared("Relate")}<${u}, Marko.Directives & Input${n}>) => (${varShared("ReturnWithScope")}<${u}, ${f}>)`,T=`${l}<{${this.#D?getRuntimeOverrides(this.#I,this.#D,a,n,f):""}\n  ${this.#$?`api: "${this.#I}",`:""}\n  _${a?`<${g} = 1>(): ${g} extends 0\n    ? ${a}() => <${m}>${y}\n    : () => <${m}, ${a.slice(1,-1)}>${y};`:`(): () => <${m}>${y};`}\n}>`;this.#g.copy(START_OF_FILE),"ts"===this.#P?this.#g.write(`export default new (\n  class Template extends ${T} {}\n);\n`):this.#g.write(`export default new (\n  /**\n   * @extends {${removeNewLines(T)}}\n   */\n  class Template extends ${l} {}\n);\n`),this.#W(t)}#V(t){const e=t.static.length?t.static[0].comments:t.body.length?t.body[0].comments:t.comments;if(e)for(const t of e)this.#G(REG_COMMENT_PRAGMA,t.start)&&(WROTE_COMMENT.add(t),this.#g.copy(t).write("\n"))}#W(t){if(t.comments)for(const e of t.comments)if(!WROTE_COMMENT.has(e))if("/"===this.#t.charAt(e.start+1))this.#g.write("//").copy(e.value).write("\n");else if("!"===this.#t.charAt(e.start+1)){this.#g.write("/*");let t=e.value.start;for(const{index:r}of this.#f(e.value).matchAll(/\*\//g))this.#g.copy({start:t,end:t=e.value.start+r+1}).write("\\");this.#g.copy({start:t,end:e.value.end}),this.#g.write("*/")}else this.#g.write("/*").copy(e.value).write("*/")}#Y(t,e){const r=this.#X(e);t||r?(this.#g.write("return new (class MarkoReturn<Return = void> {\n"),r&&this.#g.write(`readonly [${varShared("scope")}] = ${r};\n`),this.#g.write("declare return: Return;\nconstructor(_?: Return) {}\n})(\n"),this.#g.copy(t),this.#g.write(");\n")):this.#g.write(`return ${varShared("voidReturn")};\n`)}#J(t,e=!1){var r,s;const a=t.length-1;let n,i=0;for(this.#F.push(0);i<=a;){const a=t[i++];switch(a.type){case 1:switch(a.nameText){case"return":n=a;break;case"if":{const t=IF_TAG_ALTERNATES.get(a);let s=!1;if(!e){if(s=hasHoists(a),!s&&t)for(const{node:e}of t)if(s=hasHoists(e))break;s&&this.#g.write(`const ${this.#z(a,!0)} = (() => {\n`)}this.#W(a),this.#g.write("if (").copy(this.#Z(null==(r=a.args)?void 0:r.value)||this.#Q(a,ATTR_UNNAMED2)||"undefined").write(") {\n");const n=this.#U(a);if(null==n?void 0:n.content){this.#J(n.content,!0);const t=this.#X(a.body);t&&this.#g.write(`return {\nscope: ${t}\n};\n`),this.#K()}let i=!0;if(t)for(const{node:e,condition:r}of t){this.#W(e),r?this.#g.write("\n} else if (\n").copy(r).write("\n) {\n"):"else"===e.nameText?(i=!1,this.#g.write("\n} else {\n")):this.#g.write("\n} else if (undefined) {\n");const t=this.#U(e);if(null==t?void 0:t.content){this.#J(t.content,!0);const r=this.#X(e.body);r&&this.#g.write(`return {\nscope: ${r}\n};\n`),this.#K()}}i&&s?this.#g.write("\n} else {\nreturn undefined;\n}\n"):this.#g.write("\n}\n"),s&&this.#g.write("\n})();\n");break}case"for":{hasHoists(a)&&this.#g.write(`const ${this.#z(a,!0)} = `),this.#g.write(`${varShared(getForTagRuntime(this.#o,a))}({\n`),this.#tt(a),this.#et(a),this.#g.write("\n}"+SEP_COMMA_NEW_LINE).copy(a.typeParams).write("(\n"),this.#W(a),a.params&&this.#rt(a.params.value),this.#g.write("\n) => {\n");const t=this.#U(a);(null==t?void 0:t.content)&&this.#J(t.content),this.#Y(void 0,(null==t?void 0:t.content)&&a.body),(null==t?void 0:t.content)&&this.#K(),this.#g.write("\n});\n");break}case"while":{this.#W(a),this.#g.write("while (\n").copy(this.#Z(null==(s=a.args)?void 0:s.value)||"undefined").write("\n) {\n");const t=this.#U(a);(null==t?void 0:t.content)&&(this.#J(t.content),this.#K()),this.#g.write("\n}\n");break}default:this.#w(a)}break;case 22:this.#st(a);break;case 23:this.#at(a)}}return n&&(this.#g.write(`var ${varLocal("return")} = ${varShared("returnTag")}(`),this.#nt(n),this.#g.write(");\n")),void 0!==n}#w(t){const e=t.nameText,r=e?this.#k.getTag(e):void 0,s=resolveTagImport(this.#C,r),a=!s&&(null==r?void 0:r.html),n=hasHoists(t),i=t.var&&!a&&getMutatedVars(t);let o,c,p=!1;if(!r||s){const r=e&&REG_TAG_NAME_IDENTIFIER.test(e),a=null==s?void 0:s.endsWith(".marko");r||a||!s?(c=this.#it(t,!0),this.#g.write(`const ${c} = (\n`),r?s?this.#g.write(`${varShared("fallbackTemplate")}(${e},${a?`import("${s}")`:varShared("any")})`):this.#g.copy(t.name):a?(p=!0,this.#g.write(`${varShared("resolveTemplate")}(import("${s}"))`)):this.#ot(t),this.#g.write("\n);\n")):c=varShared("missingTag");const n=this.#ct(t);n&&(this.#pt(n,c),this.#g.write(";\n"))}if((n||t.var)&&(o=this.#z(t,!0),t.var&&(this.#F[this.#F.length-1]++,this.#g.write("{const "),a?this.#g.copy(t.var.value).write(` = ${varShared("el")}(${JSON.stringify(r.name)});\n`):(this.#rt(t.var.value),this.#g.write(` = ${varShared("returned")}(() => ${o});\n`))),!n&&a||this.#g.write(`const ${o} = `)),a?this.#g.write(`${varShared("renderNativeTag")}("`).copy(isEmptyRange2(t.name)?e:t.name).write('")'):c?(this.#g.write(`${varShared(p?"renderTemplate":"renderDynamicTag")}(${c}`),this.#tt(t),this.#g.write(")")):this.#g.write(varShared("missingTag")),t.typeArgs?this.#g.write("<0>()").copy(t.typeArgs).write("()("):this.#g.write("()()("),this.#nt(t),this.#g.write(");\n"),i)for(const t of i)this.#g.write(`const ${varLocal(`change__${t.name}`)} = ${varShared("change")}(${JSON.stringify(t.name)+(t.sourceName&&t.sourceName!==t.name?`, ${JSON.stringify(t.sourceName)}`:"")}, ${o}.return${t.objectPath||""});\n`)}#K(){const t=this.#F.pop();t&&this.#g.write("}".repeat(t))}#ot(t){const e=this.#dt(t);e?this.#g.copy(e):this.#g.write(`${varShared("interpolated")}\``).copy(t.name).write("`")}#tt(t){this.#g.write("/*").copy(this.#dt(t)||t.name).write("*/")}#st(t){this.#W(t),this.#g.write("(").copy(t.value).write(");\n")}#at(t){this.#W(t),this.#g.copy(t.value).write(";\n")}#et(t){var e,r,s,a,n,i;let o=!1;if(t.shorthandId&&(o=!0,this.#g.write(`id: ${varShared("interpolated")}\``).copy({start:t.shorthandId.start+1,end:t.shorthandId.end}).write("`"+SEP_COMMA_NEW_LINE)),t.shorthandClassNames){let e=SEP_EMPTY;o=!0,this.#g.write(`class: ${varShared("interpolated")}\``);for(const r of t.shorthandClassNames)this.#g.write(e).copy({start:r.start+1,end:r.end}),e=SEP_SPACE;this.#g.write("`"+SEP_COMMA_NEW_LINE)}let c=Math.max(t.name.end,(null==(e=t.shorthandId)?void 0:e.end)??-1,(null==(s=null==(r=t.shorthandClassNames)?void 0:r[t.shorthandClassNames.length-1])?void 0:s.end)??-1,(null==(a=t.var)?void 0:a.end)??-1,(null==(n=t.args)?void 0:n.end)??-1,(null==(i=t.params)?void 0:i.end)??-1);if(t.attrs){o=!0;for(const e of t.attrs){switch(this.#ht(c,e.start),c=e.end,e.type){case 15:this.#g.write("...(\n"),this.#rt(e.value),this.#g.write("\n)");break;case 10:{const r=isEmptyRange2(e.name),s=e.value,a=s&&13!==s.type?void 0:this.#lt(e),n=r?e.name:void 0;let i=r?ATTR_UNNAMED2:e.name;if(a&&(i={start:e.name.start,end:a.start-1}),s)switch(s.type){case 14:this.#g.write('"').copy(n).copy(i).write('"').copy(s.typeParams),this.#rt(s.params),this.#rt(s.body);break;case 13:{const e=s.bound&&getBoundAttrRange(s);if(this.#g.write('"').copy(n).copy(i).write('": (\n'),e)if(e.member)if(e.member.computed)this.#g.copy(e.value).copy({start:e.value.end,end:e.value.end+1}).copy(e.member).copy({start:e.member.end,end:e.member.end+1}).copy(e.types).write(`\n)${SEP_COMMA_NEW_LINE}"`).copy(n).copy(i).write('Change": (\n'),a?this.#g.copy(e.value).write("[`${\n").copy(e.member).write("\n}Change`] && ((\n// @ts-ignore\n_\n)=>{\n").copy(e.value).write("[`${\n").copy(e.member).write("\n}Change`](").copy(a).write("(_));\n})"):this.#g.copy(e.value).write("[`${\n").copy(e.member).write("\n}Change`]"),this.#g.write(")");else{const t={start:e.value.start,end:e.member.end};this.#g.copy(t).copy(e.types).write(`\n)${SEP_COMMA_NEW_LINE}"`).copy(n).copy(i).write('Change": (\n'),a?this.#g.copy(t).write("Change && ((\n// @ts-ignore\n_\n)=>{\n").copy(t).write("Change(").copy(a).write("(_));\n})"):this.#g.copy(t).write("Change"),this.#g.write(")")}else{const r=this.#f(e.value);this.#g.copy(e.value).write(" ").copy(e.types).write(`\n)${SEP_COMMA_NEW_LINE}"`).copy(n).copy(i).write(`Change"(\n// @ts-ignore\n_${r}\n) {\n${isMutatedVar(t.parent,r)?varLocal(`change__${r}.`):""}`).copy(e.value).write("= ").copy(a).write(`(_${r});\n}`)}else this.#rt(s.value),this.#g.write("\n)");break}}else if(e.args)if(this.#g.write('"').copy(i).write('": '),this.#I===RuntimeAPI.class&&"string"!=typeof i&&this.#f(i).startsWith("on")){const t=this.#ut(REG_ATTR_ARG_LITERAL,e.args.value.start);if(t){const r=","===t[3],s=t[2],a=t.index;if(REG_OBJECT_PROPERTY.test(t[2])){const t=a+1;this.#g.write("component.").copy({start:t,end:t+s.length})}else this.#g.write("component[").copy({start:a,end:a+s.length+2}).write("]");r&&this.#g.write(".bind(component, ").copy({start:a+t[0].length,end:e.args.value.end}).write(")")}else this.#g.write(`${varShared("bind")}(component, \n`).copy(e.args.value).write("\n)")}else this.#g.copy(e.args);else this.#g.write('"').copy(n).copy(i).write('": '+(a?'""':"true"));break}}this.#g.write(SEP_COMMA_NEW_LINE)}}return this.#ht(c,t.open.end-(t.concise?";"===this.#t[t.open.end]?1:0:t.selfClosed?2:1)),o}#mt({staticAttrTags:t,dynamicAttrTagParents:e},r){let s=!1;e&&(t?(this.#g.write(`...${varShared("mergeAttrTags")}({\n`),s=!0):e.length>1?(this.#g.write(`...${varShared("mergeAttrTags")}(\n`),s=!0):this.#g.write("...")),t&&(this.#gt(t),e&&this.#g.write(`}${SEP_COMMA_NEW_LINE}`)),e&&(this.#ft(e,r),s&&this.#g.write(`)${SEP_COMMA_NEW_LINE}`))}#gt(t){for(const e in t){const r=t[e],s=r.length>1,[a]=r,n=this.#yt(a);if(this.#g.write(`["${n}"`),this.#tt(a),this.#g.write("]: "),s){const t=this.#it(a.owner);t?this.#g.write(`${varShared("attrTagFor")}(${t},${this.#Tt(a)})(`):this.#g.write(`${varShared("attrTag")}(`),this.#g.write(`"${n}",`);for(const t of r)this.#g.write(`{["${n}"`),this.#tt(t),this.#g.write("]: "),this.#nt(t),this.#g.write(`}${SEP_COMMA_NEW_LINE}`);this.#g.write(`)${SEP_COMMA_NEW_LINE}`)}else for(const t of r)this.#nt(t),this.#g.write(SEP_COMMA_NEW_LINE)}}#ft(t,e){var r,s,a;for(const n of t){switch(n.nameText){case"if":{const t=IF_TAG_ALTERNATES.get(n);this.#W(n),this.#g.write("((\n").copy(this.#Z(null==(r=n.args)?void 0:r.value)||this.#Q(n,ATTR_UNNAMED2)||"undefined").write("\n) ? "),this.#vt(n);let e=!0;if(t)for(const{node:r,condition:s}of t)this.#W(r),s?this.#g.write(": (\n").copy(s).write("\n) ? "):"else"===r.nameText?(e=!1,this.#g.write(": ")):this.#g.write(": undefined ? "),this.#vt(r);e&&this.#g.write(" : {}"),this.#g.write(")");break}case"for":this.#g.write(`${varShared(getForAttrTagRuntime(this.#o,n))}({\n`),this.#tt(n),this.#et(n),this.#g.write("\n}, \n"),this.#W(n),this.#g.copy(n.typeParams).write("(\n").copy(null==(s=n.params)?void 0:s.value).write("\n) => ("),this.#vt(n,e),this.#g.write(")"),e&&this.#g.write(`,${e}`),this.#g.write(")");break;case"while":this.#W(n),this.#g.write("((\n").copy(this.#Z(null==(a=n.args)?void 0:a.value)||"undefined").write("\n) ? "),this.#vt(n),this.#g.write(" : {})")}this.#g.write(SEP_COMMA_NEW_LINE)}}#nt(t){t.params||this.#W(t);const e=this.#U(t);let r=!1,s=!0;t.args&&(this.#I===RuntimeAPI.tags||this.#dt(t))?(r=!0,this.#g.copy(t.args.value),e||t.attrs||t.shorthandId||t.shorthandClassNames?this.#g.write(",\n{\n"):s=!1):(this.#g.write("{\n"),t.args&&(r=!0,this.#g.write("[").copy({start:t.args.start,end:t.args.start+1}).write('"value"').copy({start:t.args.end-1,end:t.args.end}).write(`]: ${varShared("tuple")}(`).copy(t.args.value).write(")").write(",\n"))),this.#et(t)&&(r=!0);let a=!1;if(isTextOnlyScript(t)?(this.#g.write(`async ${this.#I===RuntimeAPI.tags?"value":`[${varShared("never")}]`}(){`),this.#rt({start:t.body[0].start,end:t.body[t.body.length-1].end}),this.#g.write(`}${SEP_COMMA_NEW_LINE}`)):e?(r=!0,this.#mt(e,this.#wt(t)),a=void 0!==e.content):t.close&&(a=!0),t.params||a){if(this.#g.write("["),this.#$){const e=this.#it(16===t.type?t.owner:t);e?this.#g.write(`${varShared("contentFor")}(${e})`):this.#g.write(varShared("content"))}else this.#g.write('"content"');this.#tt(t),this.#g.write("]: "),t.params?(this.#g.write("("),this.#W(t),this.#g.copy(t.typeParams).write("(\n"),this.#rt(t.params.value),this.#g.write("\n) => {\n")):this.#g.write("(() => {\n");let r=!1;(null==e?void 0:e.content)&&(r=this.#J(e.content)),t.params||this.#g.write("return () => {\n"),this.#Y(r?varLocal("return"):void 0,t.body),(null==e?void 0:e.content)&&this.#K(),t.params?this.#g.write("})"):this.#g.write("}\n})()"),this.#g.write(SEP_COMMA_NEW_LINE)}16===t.type&&this.#g.write("[/*").copy(t.name).write(`*/Symbol.iterator]: ${varShared("any")}${SEP_COMMA_NEW_LINE}`),r||this.#tt(t),s&&this.#g.write("\n}")}#H(t){return"ts"===this.#P?`${varShared("any")} as ${t}`:`/** @type {${t}} */(${varShared("any")})`}#rt(t){const e=this.#L;if(!e)return this.#g.copy(t);const r=e.length;let s=t.start,a=0;for(;;){let n=r;for(;a<n;){const t=a+n>>>1;e[t].start>=s?n=t:a=t+1}const i=n!==r&&e[n];if(!i||i.start>=t.end)return void this.#g.copy({start:s,end:t.end});this.#g.copy({start:s,end:i.start}),this.#g.write(`${varLocal(`change__${i.binding.name}`)}.`),s=i.start,a=n+1}}#ht(t,e){const r=this.#t,s=Math.min(e,r.length);let a=t,n=t;for(;n<s;){if(!isWhitespaceCode(r.charCodeAt(n)))return a=n+1,void(n>a&&this.#g.copy({start:a,end:n}));n++}n>a&&this.#g.copy({start:a,end:n})}#U(t){var e;const{body:r}=t;if(!r)return;const s=r.length-1;let a,n,i,o=0;for(;o<=s;){const t=r[o++];switch(t.type){case 16:{const e=t.nameText;if(n){const r=n[e];r?r.push(t):n[e]=[t]}else n={[e]:[t]};break}case 1:{let n=!1;switch(t.nameText){case"for":case"while":n||=t.hasAttrTags;break;case"if":{let a;n||=t.hasAttrTags;t:for(;o<=s;){const t=r[o++];switch(t.type){case 17:if(this.#xt(t))continue t;break;case 1:switch(t.nameText){case"else-if":{const r={condition:this.#Z(null==(e=t.args)?void 0:e.value)||this.#Q(t,ATTR_UNNAMED2),node:t};n||=t.hasAttrTags,a?a.push(r):a=[r];continue t}case"else":{const e={condition:this.#Q(t,"if"),node:t};if(n||=t.hasAttrTags,a?a.push(e):a=[e],e.condition)continue t;break t}}}o--;break}IF_TAG_ALTERNATES.set(t,a)}}n?i?i.push(t):i=[t]:a?a.push(t):a=[t];break}case 17:this.#xt(t)||(a?a.push(t):a=[t]);break;default:a?a.push(t):a=[t]}}return a||n||i?{content:a,staticAttrTags:n,dynamicAttrTagParents:i}:void 0}#vt(t,e){const r=this.#U(t);r?(r.content&&(this.#g.write("(() => {\n"),this.#J(r.content),this.#g.write("return ")),this.#g.write("{\n"),this.#mt(r,e),this.#g.write("}"),r.content&&(this.#K(),this.#g.write(";\n})()"))):this.#g.write("{}")}#Q(t,e){if(t.attrs)for(const r of t.attrs)if(isValueAttribute(r)&&(this.#f(r.name)||ATTR_UNNAMED2)===e)return r.value.value}#Z(t){if(!t)return;const{start:e}=t;let r=t.end-1;for(;r>=e;){if(!isWhitespaceCode(this.#t.charCodeAt(r))){if(","===this.#t.charAt(r))return{start:e,end:r};break}r--}return t}#xt(t){let e=t.start;for(;e<t.end;){if(!isWhitespaceCode(this.#t.charCodeAt(e)))return!1;e++}return!0}#B(t){return"ts"===this.#P?this.#At(t):this.#M&&this.#_t(t)}#At(t){var e;for(const r of t.static)if(25===r.type&&this.#G(REG_INPUT_TYPE,r.start+7)){const t=this.#R.export(r),s=null==t?void 0:t.declaration;return{typeParameters:null==(e=null==s?void 0:s.typeParameters)?void 0:e.params.map((t=>({name:t.name,constraint:t.constraint?this.#f(t.constraint):void 0,default:t.default?this.#f(t.default):void 0})))}}}#_t(t){return this.#St(t.static)||this.#St(t.body)||this.#bt(t)}#St(t){for(const e of t){this.#f(e);const t=this.#bt(e);if(t)return t}}#bt(t){const e=t.comments;if(e)for(const t of e)if("*"===this.#t.charAt(t.start+1)){const e=getJSDocInputType(this.#f(t),this.#M);if(e)return WROTE_COMMENT.add(t),this.#g.write("/*").copy(t.value).write("*/"),e}}#dt(t){if(1===t.name.expressions.length&&isEmptyRange2(t.name.quasis[0])&&isEmptyRange2(t.name.quasis[1]))return t.name.expressions[0].value}#z(t,e=!1){let r=RENDER_VAR.get(t);return!r&&e&&RENDER_VAR.set(t,r=varLocal("rendered_"+this.#Et(t))),r}#it(t,e=!1){let r=TEMPLATE_VAR.get(t);return!r&&e&&TEMPLATE_VAR.set(t,r=varLocal("tag_"+this.#Et(t))),r}#Et(t){let e=TAG_ID.get(t);return void 0===e&&(e=this.#O++,TAG_ID.set(t,e)),e}#X(t){const e=getHoistSources(t),r=this.#q(t);return e?`{ ${r?`...${r}, `:""}${e.join(SEP_COMMA_SPACE)} }`:r}#q(t){let e;if(t)for(const r of t)if(1===r.type){const t=this.#z(r);!t||r.var&&!hasHoists(r)||(e?e.push(t):e=[t])}if(e)return 1===e.length?`${varShared("readScope")}(${e[0]})`:`${varShared("readScopes")}({ ${e.join(SEP_COMMA_SPACE)} })`}#lt(t){const e=t.name.start,r=t.name.end;for(let t=r-1;t-- >e;)if(":"===this.#t.charAt(t))return{start:t+1,end:r}}#yt(t){var e;const{nameText:r}=t;return(null==(e=this.#k.getTag(r))?void 0:e.targetProperty)||r.slice(r.lastIndexOf(":")+1)}#Tt(t){let e=`"${this.#yt(t)}"`,r=t.parent;for(;r;){if(16===r.type)e=`"${this.#yt(r)}",${e}`;else if(!isControlFlowTag(r))break;r=r.parent}return e}#wt(t){if(16===t.type){if(!t.owner)return;const e=this.#it(t.owner);if(!e)return;return`${varShared("inputForAttr")}(${e},${this.#Tt(t)})`}const e=this.#it(t);if(e)return`${varShared("input")}(${e})`}#pt(t,e,r){this.#g.write(`${varShared(r?"nestedAttrTagNames":"attrTagNames")}(${e},input=>{\n`);for(const e in t){const{tags:r,nested:s}=t[e];for(const t of r)this.#g.write('input["').copy(t.name).write('"];\n');s&&this.#pt(s,`input["@${e}"]`,!0)}this.#g.write("});")}#ct(t,e){if(!t.hasAttrTags||!t.body)return e;const r=e||{};for(const e of t.body)switch(e.type){case 16:{const t=this.#yt(e),s=r[t];s?(s.tags.push(e),s.nested=this.#ct(e,s.nested)):r[t]={tags:[e],nested:this.#ct(e)};break}case 1:isControlFlowTag(e)&&this.#ct(e,r)}return r}#G(t,e){return t.lastIndex=e,t.test(this.#t)}#ut(t,e){return t.lastIndex=e,t.exec(this.#t)}};function getForTagType(t,e){if(e.attrs)for(const r of e.attrs){if(15===r.type)return 0;switch(t.read(r.name)){case"of":return 1;case"in":return 2;case"to":return 3;case"until":return 4}}return 0}function getForTagRuntime(t,e){switch(getForTagType(t,e)){case 1:return"forOfTag";case 2:return"forInTag";case 3:return"forToTag";case 4:return"forUntilTag";default:return"forTag"}}function getForAttrTagRuntime(t,e){switch(getForTagType(t,e)){case 1:return"forOfAttrTag";case 2:return"forInAttrTag";case 3:return"forToAttrTag";case 4:return"forUntilAttrTag";default:return"forAttrTag"}}function varLocal(t){return VAR_LOCAL_PREFIX+t}function varShared(t){return VAR_SHARED_PREFIX+t}function getReturnTag(t){if(t.body)for(const e of t.body)if(1===e.type&&"return"===e.nameText)return e}function isValueAttribute(t){var e;return 10===t.type&&13===(null==(e=t.value)?void 0:e.type)}function resolveTagImport(t,e){const r=resolveTagFile(e);if(r)return t?(0,import_relative_import_path.relativeImportPath)(t,r):r}function resolveTagFile(t){return t&&(t.types||t.template||t.renderer)}function isWhitespaceCode(t){return t<=32}function stripExt(t){return t.replace(REG_EXT,"")}function removeNewLines(t){return t.replace(REG_NEW_LINE," ")}function isEmptyRange2(t){return t.start===t.end}function extractStyle(t){const{parsed:e,lookup:r}=t,s=new Map,{read:a,program:n,code:i}=e;let o=0;for(const t of n.static)27===t.type&&d(t.ext||".css").copy(t.value);for(const t of n.body)p(t);const c=new Map;for(const[t,e]of s)c.set(t,e.end());return c;function p(t){var e,s;switch(t.type){case 16:if(t.body)for(const e of t.body)p(e);break;case 1:if(t.body)if("style"===t.nameText){const e=t.shorthandClassNames?a(t.shorthandClassNames.at(-1)):".css";for(const r of t.body)switch(r.type){case 17:d(e).copy(r);break;case 22:d(e).write(`var(--_${o++})`)}}else for(const e of t.body)p(e);if(t.attrs)for(const n of t.attrs)if(10===n.type&&13===(null==(e=n.value)?void 0:e.type)&&/^['"]$/.test(i[n.value.value.start])){const e=a(n.name);("#style"===e||"style"===e&&t.nameText&&"style"===e&&(null==(s=r.getTag(t.nameText))?void 0:s.html))&&d("css").write(":root{").copy({start:n.value.value.start+1,end:n.value.value.end-1}).write("}")}}}function d(t){let r=s.get(t);return r||s.set(t,r=new Extractor(e)),r}}var processors_exports={};function getExt(t){const e=t.lastIndexOf(".");if(-1!==e)return t.slice(e)}__export(processors_exports,{create:()=>create,extensions:()=>extensions,has:()=>has});var import_path3=__toESM(require("path")),project_exports={};__export(project_exports,{clearCaches:()=>clearCaches,getCache:()=>getCache,getCompiler:()=>getCompiler,getConfig:()=>getConfig,getScriptLang:()=>getScriptLang,getTagLookup:()=>getTagLookup,getTypeLibs:()=>getTypeLibs,setDefaultCompilerMeta:()=>setDefaultCompilerMeta,setDefaultTypePaths:()=>setDefaultTypePaths});var defaultMeta,import_strip_json_comments=require("@luxass/strip-json-comments"),import_module=require("module"),import_path2=__toESM(require("path")),defaultTypeLibs={},ignoreErrors=t=>{},metaByDir=new Map,metaByTranslator=new Map;function getCompiler(t){return getMeta(t).compiler}function getCache(t){return getMeta(t).config.cache}function getConfig(t){return getMeta(t).config}function getTagLookup(t){return getTagLookupForProject(getMeta(t),t)}function getTypeLibs(t,e,r){var s;const a=getConfig(t);let n=a.cache.get(getTypeLibs);if(n)return n;const i={moduleResolution:e.ModuleResolutionKind.Bundler},o=import_path2.default.join(t,".marko-run/routes.d.ts"),c=import_path2.default.join(t,"_.d.ts"),p=defaultTypeLibs.internalTypesFile||(null==(s=e.resolveTypeReferenceDirective("@marko/language-tools/marko.internal.d.ts",c,i,r).resolvedTypeReferenceDirective)?void 0:s.resolvedFileName),{resolvedTypeReferenceDirective:d}=e.resolveTypeReferenceDirective(a.translator.runtimeTypes||"marko",c,i,r),{resolvedTypeReferenceDirective:h}=e.resolveTypeReferenceDirective("@marko/run",c,i,r),l=(null==d?void 0:d.resolvedFileName)||defaultTypeLibs.markoTypesFile,u=null==h?void 0:h.resolvedFileName;if(!p||!l)throw new Error("Could not resolve marko type files.");return a.cache.set(getTypeLibs,n={internalTypesFile:p,markoTypesFile:l,markoTypesCode:r.readFile(l)||"",markoRunTypesFile:u,markoRunGeneratedTypesFile:r.fileExists(o)?o:void 0}),n}function getScriptLang(t,e,r,s){if(t.endsWith(".d.marko"))return"ts";const a=import_path2.default.dirname(t),n=getConfig(a),i=n.cache.get(getScriptLang);let o=null==i?void 0:i.get(a);if(!o){const t=r.findConfigFile(a,s.fileExists.bind(s),"marko.json");if(t)try{const e=s.readFile(t);if(e){const t=tryParseJSONWithComments(e);if(t){const e=t["script-lang"]||t.scriptLang;void 0!==e&&(o="ts"===e?"ts":"js")}}}catch{}void 0===o&&(o=/[/\\]node_modules[/\\]/.test(a)?"js":e),i?i.set(a,o):n.cache.set(getScriptLang,new Map([[a,o]]))}return o}function clearCaches(){defaultMeta&&clearCacheForMeta(defaultMeta);for(const t of metaByTranslator.values())clearCacheForMeta(t)}function setDefaultTypePaths(t){Object.assign(defaultTypeLibs,t)}function setDefaultCompilerMeta(t,e){const{translator:r}=e;if("object"!=typeof r)throw new Error("Translator must be fully resolved and loaded.");defaultMeta={compiler:t,config:{...e,cache:new Map,translator:r}},t.configure(defaultMeta.config)}function getMeta(t){if(!t){if(!defaultMeta)throw new Error("@marko/compiler must be installed or compiler registered.");return defaultMeta}if(defaultMeta)try{return loadMeta(t)}catch{return metaByDir.set(t,defaultMeta),defaultMeta}return loadMeta(t)}function loadMeta(t){let e=metaByDir.get(t);if(!e){const r=(0,import_module.createRequire)(import_path2.default.join(t,"_.js")),s=(()=>{try{return r.resolve("@marko/compiler/config")}catch{return(0,import_module.createRequire)(r.resolve("marko/package.json")).resolve("@marko/compiler/config")}})(),a=interopDefault(r(s)),n=r.resolve(a.translator);if(e=metaByTranslator.get(n),!e){const t=r(import_path2.default.dirname(s));e={compiler:t,config:{...a,cache:new Map,translator:r(n)}},t.configure(e.config),metaByTranslator.set(n,e)}metaByDir.set(t,e)}return e}function getTagLookupForProject(t,e){const r=t.config.cache.get(getTagLookupForProject);let s=null==r?void 0:r.get(e);if(void 0===s){try{s=t.compiler.taglib.buildLookup(e,t.config.translator,ignoreErrors)}catch{t!==defaultMeta&&(s=getTagLookupForProject(getMeta(),e))}r?r.set(e,s):t.config.cache.set(getTagLookupForProject,new Map([[e,s]]))}return s}function clearCacheForMeta(t){t.config.cache.clear(),t.compiler.taglib.clearCaches()}function tryParseJSONWithComments(t){try{return JSON.parse((0,import_strip_json_comments.strip)(t))}catch{return}}function interopDefault(t){return t.default||t}var isRemapExtensionReg=/\.ts$/,skipRemapExtensionsReg=/\.(?:[cm]?jsx?|json|marko|css|less|sass|scss|styl|stylus|pcss|postcss|sss|a?png|jpe?g|jfif|pipeg|pjp|gif|svg|ico|web[pm]|avif|mp4|ogg|mp3|wav|flac|aac|opus|woff2?|eot|[ot]tf|webmanifest|pdf|txt)$/,marko_default={extension:".marko",create({ts:t,host:e,configFile:r}){const s=e.getCurrentDirectory?e.getCurrentDirectory():t.sys.getCurrentDirectory(),a=r&&/tsconfig/g.test(r)?"ts":"js",n=getTypeLibs(s,t,e),i=[n.internalTypesFile,n.markoTypesFile],o=(t,r)=>e.fileExists(import_path3.default.join(r,"..",`${t}.ts`))&&`${t}.js`,c={output:"source",stripTypes:!0,sourceMaps:!0,babelConfig:{babelrc:!1,configFile:!1,browserslistConfigFile:!1,plugins:[{visitor:{"ImportDeclaration|ExportNamedDeclaration"(t){var e;const{node:r}=t,s=null==(e=r.source)?void 0:e.value,a="importKind"in r?r.importKind:void 0;if(!("."!==(null==s?void 0:s[0])||a&&"value"!==a||skipRemapExtensionsReg.test(s))){const e=t.hub.file.opts.filename,a=isRemapExtensionReg.test(s)?`${s.slice(0,-2)}js`:o(s,e)||o(`${s}/index`,e);a&&(r.source.value=a)}}}}],caller:{name:"@marko/type-check",supportsStaticESM:!0,supportsDynamicImport:!0,supportsTopLevelAwait:!0,supportsExportNamespaceFrom:!0}}};return n.markoRunTypesFile&&i.push(n.markoRunTypesFile),n.markoRunGeneratedTypesFile&&i.push(n.markoRunGeneratedTypesFile),{getRootNames:()=>i,getScriptExtension:r=>"ts"===getScriptLang(r,a,t,e)?t.Extension.Ts:t.Extension.Js,getScriptKind:r=>"ts"===getScriptLang(r,a,t,e)?t.ScriptKind.TS:t.ScriptKind.JS,extract(r,s){const i=import_path3.default.dirname(r),o=parse(s,r);return extractScript({ts:t,parsed:o,translator:getConfig(i).translator,lookup:getTagLookup(i),scriptLang:getScriptLang(r,a,t,e),runtimeTypesCode:n.markoTypesCode})},print({extracted:{parsed:t}}){const{code:e,map:r}=getCompiler(import_path3.default.dirname(t.filename)).compileSync(t.code,t.filename,c);return{code:e,map:r}},printTypes({printer:e,typeChecker:r,sourceFile:s,formatSettings:a}){var n,i,o;let c="";const m=a.newLineCharacter,g=a.convertTabsToSpaces?" ".repeat(a.indentSize):"\t";let f,y,T,v;for(const e of s.statements)t.isExportAssignment(e)?(f=e,y=t.isIdentifier(e.expression)?e.expression.escapedText:void 0):t.isClassDeclaration(e)&&"Component"===(null==(n=e.name)?void 0:n.escapedText)?T=e:t.isFunctionDeclaration(e)&&"___marko_internal_template"===(null==(i=e.name)?void 0:i.escapedText)&&(v=e);for(const r of s.statements){if(r===f||r===T||r===v||l(r)||p(r)||h(r)||d(r)||y&&u(r,y))continue;const a=e.printNode(t.EmitHint.Unspecified,r,s);/^(?:import|export) /.test(a)||(c+="static "),c+=a+m}if(null==T?void 0:T.members.length){c+=`class {${m}`;for(const r of T.members)t.isPropertyDeclaration(r)?c+=`${g}declare ${e.printNode(t.EmitHint.Unspecified,r,s)+m}`:t.isMethodDeclaration(r)||t.isGetAccessorDeclaration(r)||t.isSetAccessorDeclaration(r)?c+=`${g+e.printNode(t.EmitHint.Unspecified,r,s).replace(/;\s*$/,"")} { return ${castType("any")}; }${m}`:t.isIndexSignatureDeclaration(r)&&(c+=g+e.printNode(t.EmitHint.Unspecified,r,s)+m);c+=`}${m}`}if(v){const t=null==(o=r.getSignatureFromDeclaration(v))?void 0:o.getReturnType();if(t){const e=t.getProperties(),s=1===e.length&&"value"===e[0].name&&r.getPropertyOfType(t,"value")||void 0;c+="<return ",c+=s?`= ${castType(r.typeToString(r.getTypeOfSymbol(s)))}`:`...${castType(r.typeToString(t))}`,c+=`/>${m}`}}return{code:c}}};function p(e){var r,s;return t.isImportDeclaration(e)&&"Component"===(null==(s=null==(r=e.importClause)?void 0:r.name)?void 0:s.escapedText)}function d(e){return t.isTypeAliasDeclaration(e)&&"Input"===e.name.escapedText&&t.isIndexedAccessTypeNode(e.type)&&t.isTypeReferenceNode(e.type.objectType)&&t.isIdentifier(e.type.objectType.typeName)&&"Component"===e.type.objectType.typeName.escapedText&&t.isLiteralTypeNode(e.type.indexType)&&t.isStringLiteral(e.type.indexType.literal)&&"input"===e.type.indexType.literal.text}function h(e){return t.isTypeAliasDeclaration(e)&&"Input"===e.name.escapedText&&t.isTypeLiteralNode(e.type)&&!e.typeParameters&&0===e.type.members.length||t.isInterfaceDeclaration(e)&&"Input"===e.name.escapedText&&!e.heritageClauses&&!e.typeParameters&&0===e.members.length}function l(e){return t.isExportDeclaration(e)?e.exportClause&&t.isNamedExports(e.exportClause)&&1===e.exportClause.elements.length&&t.isIdentifier(e.exportClause.elements[0].name)&&"Component"===e.exportClause.elements[0].name.escapedText:!!t.isTypeAliasDeclaration(e)&&"Component"===e.name.text}function u(e,r){if(t.isVariableStatement(e))for(const s of e.declarationList.declarations)if(t.isIdentifier(s.name)&&s.name.escapedText===r)return!0}}};function castType(t){return"any"===t?"1 as any":`(1 as any as ${t})`}var extensions=[marko_default.extension];function create(t){return{[marko_default.extension]:marko_default.create(t)}}function has(t){const e=getExt(t);return!(!e||!extensions.includes(e))}function isDefinitionFile(t){return/\.d\.[^.]+$/.test(t)}
//# sourceMappingURL=/sm/bfda1d4ed86726ef21dc472b3c3045c95ed32b8db9eb90d361874375bc1d6352.map