@stacksjs/stx-vscode 0.2.904 → 0.2.907

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@stacksjs/stx-typescript-plugin",
3
- "version": "0.2.904",
3
+ "version": "0.2.907",
4
4
  "private": true,
5
5
  "main": "index.js"
6
6
  }
@@ -1,4 +1,4 @@
1
- var gn=Object.create;var{getPrototypeOf:hn,defineProperty:nt,getOwnPropertyNames:xn}=Object;var rt=Object.prototype.hasOwnProperty;function bn(e){return this[e]}var yn,Sn,Q=(e,n,r)=>{var t=e!=null&&typeof e==="object";if(t){var s=n?yn??=new WeakMap:Sn??=new WeakMap,i=s.get(e);if(i)return i}r=e!=null?gn(hn(e)):{};let o=n||!e||!e.__esModule||!rt.call(e,"default")?nt(r,"default",{value:e,enumerable:!0}):r;if(e&&typeof e==="object"||typeof e==="function"){for(let a of xn(e))if(!rt.call(o,a))nt(o,a,{get:bn.bind(e,a),enumerable:!0})}if(t)s.set(e,o);return o};var cn=require("node:crypto"),Z=require("node:fs"),ln=require("node:os"),H=Q(require("node:path"));var Be=/<(\/?)([a-zA-Z][a-zA-Z0-9-]*)\b/y,vn=new Map(["textarea","title","xmp","iframe","noembed","noframes"].map((e)=>[e,new RegExp(`</${e}\\s*>`,"ig")]));function En(e){let n=[],r=0;while(r<e.length){let t=e.indexOf("<",r);if(t===-1)break;if(e.startsWith("<!--",t)){let b=e.indexOf("-->",t+4);if(b===-1)break;r=b+3;continue}Be.lastIndex=t;let s=Be.exec(e);if(!s){r=t+1;continue}let i=Be.lastIndex,o=i,a=null;for(;o<e.length;o++){let b=e[o];if(a){if(b===a)a=null}else if(b==='"'||b==="'")a=b;else if(b===">")break}if(o===e.length)break;let c=s[1]==="/",l=e[o-1]==="/";n.push({start:t,end:o+1,name:s[2],attributes:e.slice(i,l?o-1:o),closing:c,selfClosing:l}),r=o+1;let p=s[2].toLowerCase();if(!c&&p==="plaintext")break;let x=vn.get(p);if(!c&&(p==="script"||p==="style"||x)){let b=x??(p==="script"?wn:$n);b.lastIndex=r;let _=b.exec(e);if(!_)break;r=_.index}}return n}var wn=/<\/script\s*>/ig;var $n=/<\/style\s*>/ig;function ue(e){let n=En(e),r=[];for(let t=0;t<n.length;t++){let s=n[t],i=n[t+1];if(s.name.toLowerCase()!=="script"||s.closing||i?.name.toLowerCase()!=="script"||!i.closing)continue;r.push({start:s.start,end:i.end,bodyStart:s.end,bodyEnd:i.start,attrs:s.attributes})}return r}function pe(e){let n=new Map;for(let r of e.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g))n.set(r[1].toLowerCase(),r[2]??r[3]??r[4]??!0);return n}function ye(e){let n=e.get("type");return typeof n!=="string"||!n.trim()||/^(?:module|(?:text|application)\/(?:javascript|typescript|ecmascript))$/i.test(n.trim())}var ze=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser","debounce","throttle","retry","sleep","wait","delay","waitUntil","waitWhile","lazy","clamp","rand","readableSize","useActiveElement","useIntervalFn","useObjectUrl"];var tt=Q(require("node:path"),1);function _n(e,n){let r=e[n],t=n+1;while(t<e.length){if(e[t]==="\\"){t+=2;continue}if(e[t]===r)return t+1;t++}return e.length}function kn(e,n){let r=n+1;while(r<e.length){if(e[r]==="\\"){r+=2;continue}if(e[r]==="`")return r+1;if(e[r]==="$"&&e[r+1]==="{"){if(r=st(e,r+2),r<e.length)r++;continue}r++}return e.length}function st(e,n){let r=1,t=n,s="{",i="";while(t<e.length){let o=e[t];if(o==="\\"){t+=2;continue}if(o==='"'||o==="'"){t=_n(e,t),s=se,i="";continue}if(o==="`"){t=kn(e,t),s=se,i="";continue}if(o==="/"&&e[t+1]==="/"){while(t<e.length&&e[t]!==`
1
+ var gn=Object.create;var{getPrototypeOf:hn,defineProperty:nt,getOwnPropertyNames:xn}=Object;var rt=Object.prototype.hasOwnProperty;function bn(e){return this[e]}var yn,Sn,Q=(e,n,r)=>{var t=e!=null&&typeof e==="object";if(t){var s=n?yn??=new WeakMap:Sn??=new WeakMap,i=s.get(e);if(i)return i}r=e!=null?gn(hn(e)):{};let o=n||!e||!e.__esModule||!rt.call(e,"default")?nt(r,"default",{value:e,enumerable:!0}):r;if(e&&typeof e==="object"||typeof e==="function"){for(let a of xn(e))if(!rt.call(o,a))nt(o,a,{get:bn.bind(e,a),enumerable:!0})}if(t)s.set(e,o);return o};var cn=require("node:crypto"),Z=require("node:fs"),ln=require("node:os"),H=Q(require("node:path"));var Be=/<(\/?)([a-zA-Z][a-zA-Z0-9-]*)\b/y,vn=new Map(["textarea","title","xmp","iframe","noembed","noframes"].map((e)=>[e,new RegExp(`</${e}\\s*>`,"ig")]));function En(e){let n=[],r=0;while(r<e.length){let t=e.indexOf("<",r);if(t===-1)break;if(e.startsWith("<!--",t)){let x=e.indexOf("-->",t+4);if(x===-1)break;r=x+3;continue}Be.lastIndex=t;let s=Be.exec(e);if(!s){r=t+1;continue}let i=Be.lastIndex,o=i,a=null;for(;o<e.length;o++){let x=e[o];if(a){if(x===a)a=null}else if(x==='"'||x==="'")a=x;else if(x===">")break}if(o===e.length)break;let c=s[1]==="/",l=e[o-1]==="/";n.push({start:t,end:o+1,name:s[2],attributes:e.slice(i,l?o-1:o),closing:c,selfClosing:l}),r=o+1;let p=s[2].toLowerCase();if(!c&&p==="plaintext")break;let h=vn.get(p);if(!c&&(p==="script"||p==="style"||h)){let x=h??(p==="script"?wn:$n);x.lastIndex=r;let _=x.exec(e);if(!_)break;r=_.index}}return n}var wn=/<\/script\s*>/ig;var $n=/<\/style\s*>/ig;function ue(e){let n=En(e),r=[];for(let t=0;t<n.length;t++){let s=n[t],i=n[t+1];if(s.name.toLowerCase()!=="script"||s.closing||i?.name.toLowerCase()!=="script"||!i.closing)continue;r.push({start:s.start,end:i.end,bodyStart:s.end,bodyEnd:i.start,attrs:s.attributes})}return r}function pe(e){let n=new Map;for(let r of e.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g))n.set(r[1].toLowerCase(),r[2]??r[3]??r[4]??!0);return n}function ye(e){let n=e.get("type");return typeof n!=="string"||!n.trim()||/^(?:module|(?:text|application)\/(?:javascript|typescript|ecmascript))$/i.test(n.trim())}var ze=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser","debounce","throttle","retry","sleep","wait","delay","waitUntil","waitWhile","lazy","clamp","rand","readableSize","useActiveElement","useIntervalFn","useObjectUrl"];var tt=Q(require("node:path"),1);function _n(e,n){let r=e[n],t=n+1;while(t<e.length){if(e[t]==="\\"){t+=2;continue}if(e[t]===r)return t+1;t++}return e.length}function kn(e,n){let r=n+1;while(r<e.length){if(e[r]==="\\"){r+=2;continue}if(e[r]==="`")return r+1;if(e[r]==="$"&&e[r+1]==="{"){if(r=st(e,r+2),r<e.length)r++;continue}r++}return e.length}function st(e,n){let r=1,t=n,s="{",i="";while(t<e.length){let o=e[t];if(o==="\\"){t+=2;continue}if(o==='"'||o==="'"){t=_n(e,t),s=se,i="";continue}if(o==="`"){t=kn(e,t),s=se,i="";continue}if(o==="/"&&e[t+1]==="/"){while(t<e.length&&e[t]!==`
2
2
  `)t++;continue}if(o==="/"&&e[t+1]==="*"){t+=2;while(t<e.length&&e.slice(t,t+2)!=="*/")t++;t+=2;continue}if(o==="/"&&it(s,i)){let a=ot(e,t);if(a!==-1){t=a,s=se,i="";continue}}if(o==="{")r++;else if(o==="}"){if(r--,r===0)return t}if(/[\w$]/.test(o))i=/[\w$]/.test(s)?i+o:o,s=o;else if(!/\s/.test(o))s=o,i="";t++}return e.length}var Cn=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function it(e,n){if(n)return Cn.has(n);return!(e===")"||e==="]"||e===se)}var se="\x00";function ot(e,n){let r=n+1,t=!1;while(r<e.length){let s=e[r];if(s===`
3
3
  `)return-1;if(s==="\\"){r+=2;continue}if(s==="[")t=!0;else if(s==="]")t=!1;else if(s==="/"&&!t){r++;while(r<e.length&&/[a-z]/i.test(e[r]))r++;return r}r++}return-1}function j(e){return Ve(e,!1)}function at(e){return Ve(e,!0)}function Ve(e,n){let r="",t=0,s="",i="";while(t<e.length){let o=e.slice(t,t+2);if(o==="//"){while(t<e.length&&e[t]!==`
4
4
  `)r+=" ",t++;continue}if(o==="/*"){while(t<e.length&&e.slice(t,t+2)!=="*/")r+=e[t]===`
@@ -7,7 +7,7 @@ var gn=Object.create;var{getPrototypeOf:hn,defineProperty:nt,getOwnPropertyNames
7
7
  `?`
8
8
  `:" ",t++}r+=n?"$":" ",t++,s=se,i="";continue}if(a==="/"&&it(s,i)){let c=ot(e,t);if(c!==-1){r+=`/${" ".repeat(c-t-2)}/`,t=c,s=se,i="";continue}}if(a==="`"){r+=n?"(":" ",t++;while(t<e.length&&e[t]!=="`"){if(e[t]==="\\"){r+=" ",t+=2;continue}if(e[t]==="$"&&e[t+1]==="{"){let c=t+2,l=st(e,c);if(r+=n?" {":" ",r+=Ve(e.slice(c,l),n),l<e.length)r+=n?"}":" ";t=l+1;continue}r+=e[t]===`
9
9
  `?`
10
- `:" ",t++}r+=n?")":" ",t++,s=se,i="";continue}if(r+=a,t++,/[\w$]/.test(a))i=/[\w$]/.test(s)?i+a:a,s=a;else if(!/\s/.test(a))s=a,i=""}return r}function U(e){let n=new Uint16Array(e.length),r=0,t=!0;for(let s=0;s<e.length;s++){let i=e[s];if(i===")"||i==="]"||i==="}")if(r===0)t=!1;else r--;if(n[s]=r,i==="("||i==="["||i==="{")r++}return{depths:n,balanced:t&&r===0}}class Se{cache=new Map;maxSize;options;sizes;bytes=0;constructor(e=100,n){this.maxSize=e,this.options=n??null,this.sizes=n?new Map:null}get byteSize(){return this.bytes}setMaxBytes(e){if(!this.options)return;this.options={...this.options,maxBytes:e};while(this.bytes>e&&this.cache.size>0){let n=this.cache.keys().next().value;if(n===void 0)break;this.delete(n)}}get(e){if(!this.cache.has(e))return;let n=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,n),n}set(e,n){if(this.cache.has(e))this.delete(e);let r=this.options?this.options.sizeOf(n):0;if(this.options&&r>this.options.maxBytes)return;while(this.cache.size>0&&(this.cache.size>=this.maxSize||this.options!==null&&this.bytes+r>this.options.maxBytes)){let t=this.cache.keys().next().value;if(t===void 0)break;this.delete(t)}if(this.cache.set(e,n),this.sizes)this.sizes.set(e,r),this.bytes+=r}has(e){return this.cache.has(e)}delete(e){if(this.sizes){let n=this.sizes.get(e);if(n!==void 0)this.bytes-=n,this.sizes.delete(e)}return this.cache.delete(e)}clear(){this.cache.clear(),this.sizes?.clear(),this.bytes=0}get size(){return this.cache.size}keys(){return this.cache.keys()}values(){return this.cache.values()}}class ct{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator(e){let n=Array.from(new Set(e)),r=n.sort().join(","),t=this.pool.find((a)=>a.context.join(",")===r);if(t)return t.func;let s=this.fnCache,i=this.fnCacheMaxSize,o=(...a)=>(c)=>{try{let l=`${r}:${c}`,p=s.get(l);if(!p){if(s.size>=i){let x=s.keys().next().value;if(x)s.delete(x)}p=Function(...n,`
10
+ `:" ",t++}r+=n?")":" ",t++,s=se,i="";continue}if(r+=a,t++,/[\w$]/.test(a))i=/[\w$]/.test(s)?i+a:a,s=a;else if(!/\s/.test(a))s=a,i=""}return r}function U(e){let n=new Uint16Array(e.length),r=0,t=!0;for(let s=0;s<e.length;s++){let i=e[s];if(i===")"||i==="]"||i==="}")if(r===0)t=!1;else r--;if(n[s]=r,i==="("||i==="["||i==="{")r++}return{depths:n,balanced:t&&r===0}}class Se{cache=new Map;maxSize;options;sizes;bytes=0;constructor(e=100,n){this.maxSize=e,this.options=n??null,this.sizes=n?new Map:null}get byteSize(){return this.bytes}setMaxBytes(e){if(!this.options)return;this.options={...this.options,maxBytes:e};while(this.bytes>e&&this.cache.size>0){let n=this.cache.keys().next().value;if(n===void 0)break;this.delete(n)}}get(e){if(!this.cache.has(e))return;let n=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,n),n}set(e,n){if(this.cache.has(e))this.delete(e);let r=this.options?this.options.sizeOf(n):0;if(this.options&&r>this.options.maxBytes)return;while(this.cache.size>0&&(this.cache.size>=this.maxSize||this.options!==null&&this.bytes+r>this.options.maxBytes)){let t=this.cache.keys().next().value;if(t===void 0)break;this.delete(t)}if(this.cache.set(e,n),this.sizes)this.sizes.set(e,r),this.bytes+=r}has(e){return this.cache.has(e)}delete(e){if(this.sizes){let n=this.sizes.get(e);if(n!==void 0)this.bytes-=n,this.sizes.delete(e)}return this.cache.delete(e)}clear(){this.cache.clear(),this.sizes?.clear(),this.bytes=0}get size(){return this.cache.size}keys(){return this.cache.keys()}values(){return this.cache.values()}}class ct{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator(e){let n=Array.from(new Set(e)),r=n.sort().join(","),t=this.pool.find((a)=>a.context.join(",")===r);if(t)return t.func;let s=this.fnCache,i=this.fnCacheMaxSize,o=(...a)=>(c)=>{try{let l=`${r}:${c}`,p=s.get(l);if(!p){if(s.size>=i){let h=s.keys().next().value;if(h)s.delete(h)}p=Function(...n,`
11
11
  'use strict';
12
12
  try {
13
13
  return ${c};
@@ -18,7 +18,7 @@ catch (e) {
18
18
  }
19
19
  throw e;
20
20
  }
21
- `),s.set(l,p)}return p(...a)}catch{return}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:o,context:n.slice()});return o}clear(){this.pool.length=0,this.fnCache.clear()}}var Jr=new ct;class lt{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(e){this.enabled=e}isEnabled(){return this.enabled}setBudget(e,n){this.budgets.set(e,{warnThreshold:0.8,action:"warn",...n})}setBudgets(e){for(let[n,r]of Object.entries(e))this.setBudget(n,r)}removeBudget(e){this.budgets.delete(e)}getBudgets(){let e={};for(let[n,r]of this.budgets.entries())e[n]=r;return e}onViolation(e){this.violationHandlers.push(e)}offViolation(e){let n=this.violationHandlers.indexOf(e);if(n!==-1)this.violationHandlers.splice(n,1)}time(e,n){if(!this.enabled)return n();let r=performance.now(),t=n(),s=performance.now()-r;return this.recordTime(e,s),this.checkBudget(e,s),t}async timeAsync(e,n){if(!this.enabled)return n();let r=performance.now(),t=await n(),s=performance.now()-r;return this.recordTime(e,s),this.checkBudget(e,s),t}checkBudget(e,n){let r=this.budgets.get(e);if(!r)return;let t=n/r.maxTime*100,s=r.warnThreshold!==void 0?n>=r.maxTime*r.warnThreshold&&n<r.maxTime:!1,i=n>=r.maxTime;if(!s&&!i)return;let o={label:e,actualTime:n,budgetTime:r.maxTime,exceedancePercent:t,timestamp:new Date,isWarning:s};this.violations.push(o);while(this.violations.length>this.maxViolations)this.violations.shift();for(let c of this.violationHandlers)try{c(o)}catch{}let a=s?`[Performance Warning] "${e}" took ${n.toFixed(2)}ms (${t.toFixed(1)}% of ${r.maxTime}ms budget)`:`[Performance Budget Exceeded] "${e}" took ${n.toFixed(2)}ms (exceeded ${r.maxTime}ms budget by ${(t-100).toFixed(1)}%)`;switch(r.action){case"log":console.log(a);break;case"warn":console.warn(a);break;case"error":console.error(a);break;case"throw":if(i)throw Error(a);else console.warn(a);break}}recordTime(e,n){let r=this.metrics.get(e);if(r)r.count++,r.totalTime+=n,r.maxTime=Math.max(r.maxTime,n),r.minTime=Math.min(r.minTime,n);else this.metrics.set(e,{count:1,totalTime:n,maxTime:n,minTime:n})}getStats(e){if(e){let r=this.metrics.get(e);if(!r)return{};let t=this.budgets.get(e);return{count:r.count,avgTime:r.totalTime/r.count,totalTime:r.totalTime,maxTime:r.maxTime,minTime:r.minTime,budget:t?.maxTime,budgetUtilization:t?r.totalTime/r.count/t.maxTime*100:void 0}}let n={};for(let[r,t]of this.metrics.entries()){let s=this.budgets.get(r);n[r]={count:t.count,avgTime:t.totalTime/t.count,totalTime:t.totalTime,maxTime:t.maxTime,minTime:t.minTime,budget:s?.maxTime,budgetUtilization:s?t.totalTime/t.count/s.maxTime*100:void 0}}return n}getViolations(e){if(e)return this.violations.filter((n)=>n.label===e);return[...this.violations]}getViolationStats(){let e={},n=0,r=0;for(let t of this.violations)if(e[t.label]=(e[t.label]||0)+1,t.isWarning)n++;else r++;return{total:this.violations.length,byLabel:e,warnings:n,errors:r}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var We=null;function Tn(){if(!We)We=new lt;return We}var qr=new Proxy({},{get(e,n){return Tn()[n]}});var ut=new Se(32,{maxBytes:2097152,sizeOf:(e)=>e.code.length*4}),ie=/^[A-Za-z_$][\w$]*$/,Rn=new Set(["if","for","while","switch","with"]),pt=["(","[","{"],dt=[")","]","}"],An=new Set(["const","let","var","return","if","for","while","do","switch","try","throw","export"]);function On(e){let n=j(e),r=[];for(let t of n.matchAll(/[A-Za-z_$][\w$]*|=>|\.\.\.|[^\s]/g)){let s=t.index??0;r.push({text:t[0],start:s,end:s+t[0].length})}return{code:n,tokens:r}}function Pn(e){let n=ut.get(e);if(n)return n;let{code:r,tokens:t}=On(e),s=new Map,i=[];for(let d=0;d<t.length;d++){let f=t[d].text;if(["(","[","{"].includes(f))i.push(d);else if([")","]","}"].includes(f)){let w=i.at(-1);if(w!==void 0&&["()","[]","{}"].includes(t[w].text+f))i.pop(),s.set(w,d),s.set(d,w)}}function o(d,f){let w=[],h=d;for(let u=d;u<f;u++){if(["(","[","{"].includes(t[u].text)&&(s.get(u)??f)<f){u=s.get(u);continue}if(t[u].text===",")w.push([h,u]),h=u+1}return w.push([h,f]),w}let a=[];function c(d,f,w,h=!1,u){if(t[d]?.text==="...")d++;if(d>=f)return;let m=t[d].text;if(ie.test(m)){if(w.add(m),w===x)a.push({name:m,token:d,functionScoped:h,declarationToken:u});return}if(m!=="{"&&m!=="[")return;let E=s.get(d);if(E===void 0||E>=f)return;for(let[A,v]of o(d+1,E)){let O=A;if(m==="{")for(let M=A;M<v;M++){if(t[M].text===":"){O=M+1;break}if(t[M].text==="=")break;if(["(","[","{"].includes(t[M].text)&&s.has(M))M=s.get(M)}c(O,v,w,h,u)}}function l(d,f){let w=new Set;for(let[h,u]of o(d,f))c(h,u,w);return w}function p(d){let f=d;for(;f<t.length;f++){let w=t[f].text;if(["(","[","{"].includes(w)&&s.has(f)){f=s.get(f);continue}if([",",";",")","]","}"].includes(w))break}return t[Math.max(d,f-1)]?.end??r.length}let x=new Set,b=[];for(let d=0;d<t.length;d++)if(t[d].text==="=>"){let f=d-1,w=f,h;if(t[f]?.text===")"&&s.has(f))w=s.get(f),h=l(w+1,f);else if(t[f]&&ie.test(t[f].text))h=new Set([t[f].text]);else continue;let u=d+1,m=t[u]?.text==="{"&&s.has(u)?t[s.get(u)].end:p(u);b.push({start:t[w].start,end:m,bodyStart:t[u]?.start??m,functionBody:!0,names:h})}else if(t[d].text==="("&&s.has(d)){let f=t[d-1]?.text;if(!f||Rn.has(f)||!ie.test(f)&&f!=="*"&&f!=="]")continue;let w=s.get(d),h=w+1;if(t[h]?.text===":"){h++;while(h<t.length&&!["{","=>",";","="].includes(t[h].text))h++}if(t[h]?.text!=="{"||!s.has(h))continue;b.push({start:t[d].start,end:t[s.get(h)].end,bodyStart:t[h].start,functionBody:f!=="catch",names:l(d+1,w)})}function _(d){let f=d;for(;f<t.length;f++){let w=t[f].text;if(pt.includes(w)&&s.has(f)){f=s.get(f);continue}if(w===";"||dt.includes(w))break;let h=t[f-1];if(f>d&&An.has(w)&&h.text!==".")break;if(f>d&&/[\n\r]/.test(r.slice(h.end,t[f].start))&&(/^[\w$]+$/.test(h.text)||dt.includes(h.text)||['"',"'","`"].includes(h.text))&&ie.test(w)&&!["in","of","instanceof"].includes(w))break}return f}let R=[];for(let d=0;d<t.length;d++){if(t[d].text!=="for")continue;let f=t[d+1]?.text==="await"?d+2:d+1;if(t[f]?.text!=="("||!s.has(f))continue;let w=s.get(f),h=w+1,u=t[h]?.text==="{"&&s.has(h)?s.get(h):_(h),m=t[u]?.text===";"||t[u]?.text==="}"?t[u].end:t[Math.max(h,u-1)]?.end??r.length;R.push({headStart:f,headEnd:w,start:t[f].start,end:m})}for(let d=0;d<t.length;d++){let f=t[d].text,w=t[d-1]?.text;if(w==="."||t[d+1]?.text===":")continue;if(w==="as"||w==="<")continue;if(f==="const"||f==="let"||f==="var"){let h=_(d+1),u=d+1,m=!1,E=!1,A=0;for(let v=d+1;v<=h;v++){let O=t[v]?.text;if(v<h&&pt.includes(O)&&s.has(v)&&s.get(v)<h){v=s.get(v);continue}if(v<h&&O===":"&&!E)m=!0;else if(v<h&&O==="="&&A===0)m=!1,E=!0;else if(v<h&&m&&O==="<")A++;else if(v<h&&m&&O===">"&&A>0)A--;else if(v===h||O===","&&A===0)c(u,v,x,f==="var",d),u=v+1,m=!1,E=!1}}else if(f==="function"||f==="class"){let h=d+1;if(t[h]?.text==="*")h++;if(t[h]&&ie.test(t[h].text)&&t[h].text!=="extends")x.add(t[h].text),a.push({name:t[h].text,token:h,declarationToken:d})}else if(f==="import"){let h=d+1;if(t[h]?.text==="*"&&t[h+1]?.text==="as")h+=2;let u=t[h]?.text;if(u&&ie.test(u)&&u!=="type"&&t[h+1]?.text!=="("&&t[h+1]?.text!==".")x.add(u),a.push({name:u,token:h,file:!0});let m=t[h]?.text==="{"?h:t[h+1]?.text===","&&t[h+2]?.text==="{"?h+2:-1;if(m!==-1&&s.has(m)){let E=s.get(m);for(let[A,v]of o(m+1,E)){let O=v-1;while(O>=A&&!ie.test(t[O].text))O--;if(O>=A&&t[O].text!=="type")a.push({name:t[O].text,token:O,file:!0})}}}}let C={code:r,scopes:b,loops:R,declarations:x,sites:a,tokens:t,pairs:s};return ut.set(e,C),C}function Ce(e){let n=Pn(e),r=at(e),{depths:t}=U(r),s=[];for(let i of n.sites){if(i.file||i.declarationToken===void 0)continue;let o=n.tokens[i.declarationToken];if(t[o.start]!==0)continue;let a=r.slice(0,o.start),c=[...a.matchAll(/[A-Za-z_$][\w$]*|\d+(?:[.]\d+)?|[^\s]/g)],l=c.pop();if(l?.[0]==="declare")continue;if(o.text==="function"||o.text==="class"){while(l&&["async","export","default","abstract"].includes(l[0]))l=c.pop();if(l&&![";","}"].includes(l[0])){let p=a.slice(l.index+l[0].length);if(!/[\r\n]/.test(p)||!/^(?:[\w$]+|[)\]])$/.test(l[0])||["return","throw","yield","await","new"].includes(l[0]))continue}}s.push({name:i.name,start:o.start})}return s}function ft(e){return[...new Set(Ce(e).map((n)=>n.name))].sort()}function mt(e){let n=e.indexOf(" as ");if(n!==-1){let i=e.slice(0,n).trim(),o=e.slice(n+4).trim();return i&&o?{arrayExpr:i,itemVar:o}:null}let r=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(e);if(!r)return null;let t=r[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),s=r[2].trim();return t&&s?{arrayExpr:s,itemVar:t}:null}var de=["batch","cachedQuery","clearServerData","computed","configureFetch","defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","defineStore","derived","effect","flushKeptState","forgetKeptState","goBack","goForward","inject","invalidateRoute","isDerived","isSignal","keptState","memo","navigate","nextTick","onBeforeMount","onBeforeUnmount","onDestroy","onMount","onMounted","onUnmounted","peek","provide","reactive","ref","refDebounced","refresh","registerStoresClient","setKeptScope","setRouteParams","sharedRequest","state","untrack","useAsync","useBroadcastStream","useClickOutside","useColorMode","useCookie","useCounter","useDark","useDebounce","useDebounceFn","useDebouncedValue","useDocumentVisibility","useEventListener","useFetch","useFocus","useHead","useId","useInterval","useLocalStorage","useMediaQuery","useModel","useMutation","useNativeDesktop","useOptimistic","usePreferredContrast","usePreferredDark","usePreferredLight","usePreferredReducedMotion","useQuery","useReactiveProp","useRef","useRoute","useRouteParam","useRouteParams","useScrollLock","useSearchParams","useSeoMeta","useSessionStorage","useSlots","useStore","useThrottle","useThrottleFn","useTimeout","useTimeoutFn","useToggle","useWebSocket","watch","watchEffect","watchMultiple","withDefaults"];var Mn=["defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","withDefaults"];var ss=de.filter((e)=>!Mn.includes(e));var In=["x-text","x-html","x-model","x-show","x-if","x-for","x-cloak","x-ref","x-data","x-bind","x-class","x-style","x-tooltip","x-tooltip-position"],Nn=["x-init","x-transition","x-effect","x-on"],is=[...In,...Nn];var Oe=Q(require("node:fs"),1),fe=Q(require("node:path"),1);function gt(e,n,r,t){let s=0;for(let i=n;i<e.length;i++)if(e[i]===r)s++;else if(e[i]===t&&!(t===">"&&e[i-1]==="=")){if(--s===0)return i}return-1}function Dn(e){let n=j(e),r=0,t=0,s=[];for(let i=0;i<n.length;i++)if("([{".includes(n[i]))r++;else if(")]}".includes(n[i]))r--;else if(n[i]===","&&r===0)s.push(e.slice(t,i).trim()),t=i+1;return s.push(e.slice(t).trim()),s}function Te(e,n,r=!1){let t=j(e),s=new RegExp(`\\b(?:${n.map((o)=>o.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g"),i=r?U(t).depths:void 0;for(let o of t.matchAll(s)){if(i&&i[o.index]!==0)continue;let a=o.index+o[0].length,c="";if(t[a]==="<"){let p=gt(t,a,"<",">");if(p<0)continue;c=e.slice(a+1,p),a=p+1;while(/\s/.test(t[a]||"")&&a<t.length)a++}if(t[a]!=="(")continue;let l=gt(t,a,"(",")");if(l>=0)return{type:c,args:Dn(e.slice(a+1,l)),start:o.index,end:l+1}}return null}var Re=`
21
+ `),s.set(l,p)}return p(...a)}catch{return}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:o,context:n.slice()});return o}clear(){this.pool.length=0,this.fnCache.clear()}}var Jr=new ct;class lt{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(e){this.enabled=e}isEnabled(){return this.enabled}setBudget(e,n){this.budgets.set(e,{warnThreshold:0.8,action:"warn",...n})}setBudgets(e){for(let[n,r]of Object.entries(e))this.setBudget(n,r)}removeBudget(e){this.budgets.delete(e)}getBudgets(){let e={};for(let[n,r]of this.budgets.entries())e[n]=r;return e}onViolation(e){this.violationHandlers.push(e)}offViolation(e){let n=this.violationHandlers.indexOf(e);if(n!==-1)this.violationHandlers.splice(n,1)}time(e,n){if(!this.enabled)return n();let r=performance.now(),t=n(),s=performance.now()-r;return this.recordTime(e,s),this.checkBudget(e,s),t}async timeAsync(e,n){if(!this.enabled)return n();let r=performance.now(),t=await n(),s=performance.now()-r;return this.recordTime(e,s),this.checkBudget(e,s),t}checkBudget(e,n){let r=this.budgets.get(e);if(!r)return;let t=n/r.maxTime*100,s=r.warnThreshold!==void 0?n>=r.maxTime*r.warnThreshold&&n<r.maxTime:!1,i=n>=r.maxTime;if(!s&&!i)return;let o={label:e,actualTime:n,budgetTime:r.maxTime,exceedancePercent:t,timestamp:new Date,isWarning:s};this.violations.push(o);while(this.violations.length>this.maxViolations)this.violations.shift();for(let c of this.violationHandlers)try{c(o)}catch{}let a=s?`[Performance Warning] "${e}" took ${n.toFixed(2)}ms (${t.toFixed(1)}% of ${r.maxTime}ms budget)`:`[Performance Budget Exceeded] "${e}" took ${n.toFixed(2)}ms (exceeded ${r.maxTime}ms budget by ${(t-100).toFixed(1)}%)`;switch(r.action){case"log":console.log(a);break;case"warn":console.warn(a);break;case"error":console.error(a);break;case"throw":if(i)throw Error(a);else console.warn(a);break}}recordTime(e,n){let r=this.metrics.get(e);if(r)r.count++,r.totalTime+=n,r.maxTime=Math.max(r.maxTime,n),r.minTime=Math.min(r.minTime,n);else this.metrics.set(e,{count:1,totalTime:n,maxTime:n,minTime:n})}getStats(e){if(e){let r=this.metrics.get(e);if(!r)return{};let t=this.budgets.get(e);return{count:r.count,avgTime:r.totalTime/r.count,totalTime:r.totalTime,maxTime:r.maxTime,minTime:r.minTime,budget:t?.maxTime,budgetUtilization:t?r.totalTime/r.count/t.maxTime*100:void 0}}let n={};for(let[r,t]of this.metrics.entries()){let s=this.budgets.get(r);n[r]={count:t.count,avgTime:t.totalTime/t.count,totalTime:t.totalTime,maxTime:t.maxTime,minTime:t.minTime,budget:s?.maxTime,budgetUtilization:s?t.totalTime/t.count/s.maxTime*100:void 0}}return n}getViolations(e){if(e)return this.violations.filter((n)=>n.label===e);return[...this.violations]}getViolationStats(){let e={},n=0,r=0;for(let t of this.violations)if(e[t.label]=(e[t.label]||0)+1,t.isWarning)n++;else r++;return{total:this.violations.length,byLabel:e,warnings:n,errors:r}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var We=null;function Tn(){if(!We)We=new lt;return We}var qr=new Proxy({},{get(e,n){return Tn()[n]}});var ut=new Se(32,{maxBytes:2097152,sizeOf:(e)=>e.code.length*4}),ie=/^[A-Za-z_$][\w$]*$/,Rn=new Set(["if","for","while","switch","with"]),pt=["(","[","{"],dt=[")","]","}"],An=new Set(["const","let","var","return","if","for","while","do","switch","try","throw","export"]);function On(e){let n=j(e),r=[];for(let t of n.matchAll(/[A-Za-z_$][\w$]*|=>|\.\.\.|[^\s]/g)){let s=t.index??0;r.push({text:t[0],start:s,end:s+t[0].length})}return{code:n,tokens:r}}function Pn(e){let n=ut.get(e);if(n)return n;let{code:r,tokens:t}=On(e),s=new Map,i=[];for(let d=0;d<t.length;d++){let f=t[d].text;if(["(","[","{"].includes(f))i.push(d);else if([")","]","}"].includes(f)){let w=i.at(-1);if(w!==void 0&&["()","[]","{}"].includes(t[w].text+f))i.pop(),s.set(w,d),s.set(d,w)}}function o(d,f){let w=[],b=d;for(let u=d;u<f;u++){if(["(","[","{"].includes(t[u].text)&&(s.get(u)??f)<f){u=s.get(u);continue}if(t[u].text===",")w.push([b,u]),b=u+1}return w.push([b,f]),w}let a=[];function c(d,f,w,b=!1,u){if(t[d]?.text==="...")d++;if(d>=f)return;let m=t[d].text;if(ie.test(m)){if(w.add(m),w===h)a.push({name:m,token:d,functionScoped:b,declarationToken:u});return}if(m!=="{"&&m!=="[")return;let E=s.get(d);if(E===void 0||E>=f)return;for(let[A,v]of o(d+1,E)){let O=A;if(m==="{")for(let M=A;M<v;M++){if(t[M].text===":"){O=M+1;break}if(t[M].text==="=")break;if(["(","[","{"].includes(t[M].text)&&s.has(M))M=s.get(M)}c(O,v,w,b,u)}}function l(d,f){let w=new Set;for(let[b,u]of o(d,f))c(b,u,w);return w}function p(d){let f=d;for(;f<t.length;f++){let w=t[f].text;if(["(","[","{"].includes(w)&&s.has(f)){f=s.get(f);continue}if([",",";",")","]","}"].includes(w))break}return t[Math.max(d,f-1)]?.end??r.length}let h=new Set,x=[];for(let d=0;d<t.length;d++)if(t[d].text==="=>"){let f=d-1,w=f,b;if(t[f]?.text===")"&&s.has(f))w=s.get(f),b=l(w+1,f);else if(t[f]&&ie.test(t[f].text))b=new Set([t[f].text]);else continue;let u=d+1,m=t[u]?.text==="{"&&s.has(u)?t[s.get(u)].end:p(u);x.push({start:t[w].start,end:m,bodyStart:t[u]?.start??m,functionBody:!0,names:b})}else if(t[d].text==="("&&s.has(d)){let f=t[d-1]?.text;if(!f||Rn.has(f)||!ie.test(f)&&f!=="*"&&f!=="]")continue;let w=s.get(d),b=w+1;if(t[b]?.text===":"){b++;while(b<t.length&&!["{","=>",";","="].includes(t[b].text))b++}if(t[b]?.text!=="{"||!s.has(b))continue;x.push({start:t[d].start,end:t[s.get(b)].end,bodyStart:t[b].start,functionBody:f!=="catch",names:l(d+1,w)})}function _(d){let f=d;for(;f<t.length;f++){let w=t[f].text;if(pt.includes(w)&&s.has(f)){f=s.get(f);continue}if(w===";"||dt.includes(w))break;let b=t[f-1];if(f>d&&An.has(w)&&b.text!==".")break;if(f>d&&/[\n\r]/.test(r.slice(b.end,t[f].start))&&(/^[\w$]+$/.test(b.text)||dt.includes(b.text)||['"',"'","`"].includes(b.text))&&ie.test(w)&&!["in","of","instanceof"].includes(w))break}return f}let R=[];for(let d=0;d<t.length;d++){if(t[d].text!=="for")continue;let f=t[d+1]?.text==="await"?d+2:d+1;if(t[f]?.text!=="("||!s.has(f))continue;let w=s.get(f),b=w+1,u=t[b]?.text==="{"&&s.has(b)?s.get(b):_(b),m=t[u]?.text===";"||t[u]?.text==="}"?t[u].end:t[Math.max(b,u-1)]?.end??r.length;R.push({headStart:f,headEnd:w,start:t[f].start,end:m})}for(let d=0;d<t.length;d++){let f=t[d].text,w=t[d-1]?.text;if(w==="."||t[d+1]?.text===":")continue;if(w==="as"||w==="<")continue;if(f==="const"||f==="let"||f==="var"){let b=_(d+1),u=d+1,m=!1,E=!1,A=0;for(let v=d+1;v<=b;v++){let O=t[v]?.text;if(v<b&&pt.includes(O)&&s.has(v)&&s.get(v)<b){v=s.get(v);continue}if(v<b&&O===":"&&!E)m=!0;else if(v<b&&O==="="&&A===0)m=!1,E=!0;else if(v<b&&m&&O==="<")A++;else if(v<b&&m&&O===">"&&A>0)A--;else if(v===b||O===","&&A===0)c(u,v,h,f==="var",d),u=v+1,m=!1,E=!1}}else if(f==="function"||f==="class"){let b=d+1;if(t[b]?.text==="*")b++;if(t[b]&&ie.test(t[b].text)&&t[b].text!=="extends")h.add(t[b].text),a.push({name:t[b].text,token:b,declarationToken:d})}else if(f==="import"){let b=d+1;if(t[b]?.text==="*"&&t[b+1]?.text==="as")b+=2;let u=t[b]?.text;if(u&&ie.test(u)&&u!=="type"&&t[b+1]?.text!=="("&&t[b+1]?.text!==".")h.add(u),a.push({name:u,token:b,file:!0});let m=t[b]?.text==="{"?b:t[b+1]?.text===","&&t[b+2]?.text==="{"?b+2:-1;if(m!==-1&&s.has(m)){let E=s.get(m);for(let[A,v]of o(m+1,E)){let O=v-1;while(O>=A&&!ie.test(t[O].text))O--;if(O>=A&&t[O].text!=="type")a.push({name:t[O].text,token:O,file:!0})}}}}let C={code:r,scopes:x,loops:R,declarations:h,sites:a,tokens:t,pairs:s};return ut.set(e,C),C}function Ce(e){let n=Pn(e),r=at(e),{depths:t}=U(r),s=[...r.matchAll(/[A-Za-z_$][\w$]*|\d+(?:[.]\d+)?|[^\s]/g)],i=[];for(let o of n.sites){if(o.file||o.declarationToken===void 0)continue;let a=n.tokens[o.declarationToken];if(t[a.start]!==0)continue;let c=0,l=s.length;while(c<l){let x=c+l>>>1;if(s[x].index<a.start)c=x+1;else l=x}let p=c-1,h=s[p--];if(h?.[0]==="declare")continue;if(a.text==="function"||a.text==="class"){while(h&&["async","export","default","abstract"].includes(h[0]))h=s[p--];if(h&&![";","}"].includes(h[0])){let x=r.slice(h.index+h[0].length,a.start);if(!/[\r\n]/.test(x)||!/^(?:[\w$]+|[)\]])$/.test(h[0])||["return","throw","yield","await","new"].includes(h[0]))continue}}i.push({name:o.name,start:a.start})}return i}function ft(e){return[...new Set(Ce(e).map((n)=>n.name))].sort()}function mt(e){let n=e.indexOf(" as ");if(n!==-1){let i=e.slice(0,n).trim(),o=e.slice(n+4).trim();return i&&o?{arrayExpr:i,itemVar:o}:null}let r=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(e);if(!r)return null;let t=r[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),s=r[2].trim();return t&&s?{arrayExpr:s,itemVar:t}:null}var de=["batch","cachedQuery","clearServerData","computed","configureFetch","defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","defineStore","derived","effect","flushKeptState","forgetKeptState","goBack","goForward","inject","invalidateRoute","isDerived","isSignal","keptState","memo","navigate","nextTick","onBeforeMount","onBeforeUnmount","onDestroy","onMount","onMounted","onUnmounted","peek","provide","reactive","ref","refDebounced","refresh","registerStoresClient","setKeptScope","setRouteParams","sharedRequest","state","untrack","useAsync","useBroadcastStream","useClickOutside","useColorMode","useCookie","useCounter","useDark","useDebounce","useDebounceFn","useDebouncedValue","useDocumentVisibility","useEventListener","useFetch","useFocus","useHead","useId","useInterval","useLocalStorage","useMediaQuery","useModel","useMutation","useNativeDesktop","useOptimistic","usePreferredContrast","usePreferredDark","usePreferredLight","usePreferredReducedMotion","useQuery","useReactiveProp","useRef","useRoute","useRouteParam","useRouteParams","useScrollLock","useSearchParams","useSeoMeta","useSessionStorage","useSlots","useStore","useThrottle","useThrottleFn","useTimeout","useTimeoutFn","useToggle","useWebSocket","watch","watchEffect","watchMultiple","withDefaults"];var Mn=["defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","withDefaults"];var ss=de.filter((e)=>!Mn.includes(e));var In=["x-text","x-html","x-model","x-show","x-if","x-for","x-cloak","x-ref","x-data","x-bind","x-class","x-style","x-tooltip","x-tooltip-position"],Nn=["x-init","x-transition","x-effect","x-on"],is=[...In,...Nn];var Oe=Q(require("node:fs"),1),fe=Q(require("node:path"),1);function gt(e,n,r,t){let s=0;for(let i=n;i<e.length;i++)if(e[i]===r)s++;else if(e[i]===t&&!(t===">"&&e[i-1]==="=")){if(--s===0)return i}return-1}function Dn(e){let n=j(e),r=0,t=0,s=[];for(let i=0;i<n.length;i++)if("([{".includes(n[i]))r++;else if(")]}".includes(n[i]))r--;else if(n[i]===","&&r===0)s.push(e.slice(t,i).trim()),t=i+1;return s.push(e.slice(t).trim()),s}function Te(e,n,r=!1){let t=j(e),s=new RegExp(`\\b(?:${n.map((o)=>o.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g"),i=r?U(t).depths:void 0;for(let o of t.matchAll(s)){if(i&&i[o.index]!==0)continue;let a=o.index+o[0].length,c="";if(t[a]==="<"){let p=gt(t,a,"<",">");if(p<0)continue;c=e.slice(a+1,p),a=p+1;while(/\s/.test(t[a]||"")&&a<t.length)a++}if(t[a]!=="(")continue;let l=gt(t,a,"(",")");if(l>=0)return{type:c,args:Dn(e.slice(a+1,l)),start:o.index,end:l+1}}return null}var Re=`
22
22
  type __StxCtor<T> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends ArrayConstructor ? unknown[] : T extends ObjectConstructor ? object : T extends readonly unknown[] ? __StxCtor<T[number]> : T extends abstract new (...args: any[]) => infer V ? V : unknown;
23
23
  type __StxWiden<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
24
24
  type __StxOption<T> = T extends { type: infer C } ? __StxCtor<C> : T extends { default: infer D } ? D extends (...args: any[]) => infer V ? V : __StxWiden<D> : __StxCtor<T>;
@@ -26,33 +26,33 @@ type __StxRequired<O> = { [K in keyof O]-?: O[K] extends { required: true } ? K
26
26
  type __StxDefaulted<O> = { [K in keyof O]-?: O[K] extends { default: unknown } ? K : never }[keyof O];
27
27
  type __StxOptions<O> = { [K in Exclude<__StxRequired<O>, __StxDefaulted<O>>]: __StxOption<O[K]> } & { [K in Exclude<keyof O, Exclude<__StxRequired<O>, __StxDefaulted<O>>>]?: __StxOption<O[K]> };
28
28
  type __StxDefaults<P, K> = Omit<P, Extract<keyof P, K>> & Partial<Pick<P, Extract<keyof P, K>>>;
29
- `;function Ae(e,n){let r=[],t={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},s=j(e),i=e.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(b,_,R,C,d)=>{if(s.slice(d,d+6)!=="import")return b;if(C.endsWith(".stx"))return"";let f=`${n}Import${r.length}`;if(r.push(`import * as ${f} from ${JSON.stringify(C)};`),_.startsWith("*"))return`import ${_.replace(/^\*\s+as\s+/,"")} = ${f};`;if(!_.startsWith("{"))return`import ${_} = ${f}.default;`;return _.slice(1,-1).split(",").map((w)=>{let[h,u=h]=w.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(!h)return"";if(/^(?:stx|@stacksjs\/stx)(?:\/|$)/.test(C)&&h in t)t[h].push(u);return`import ${u} = ${f}.${h};`}).join(`
30
- `)}),o=Te(e,t.defineProps),a=Te(e,t.defineEmits),c=Te(e,t.withDefaults);if(!o&&!a)return{declarations:"",props:null,events:null};let l=[],p=null,x=null;if(o){l.push(`const __options = (${o.args[0]||"{}"}) as const;`),l.push(`const __defaults = (${c?.args[1]||"{}"});`);let b=o.type||"__StxOptions<typeof __options>";l.push(`export type __StxProps = __StxDefaults<${b}, keyof typeof __defaults | __StxDefaulted<typeof __options>>;`),p=`${n}.__StxProps`}if(a)l.push(`const __events = (${a.args[0]||"[]"}) as const;`),l.push(`export type __StxEvents = ${a.type||"Record<(typeof __events)[number], any[]>"};`),x=`${n}.__StxEvents`;return{declarations:`${r.join(`
29
+ `;function Ae(e,n){let r=[],t={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},s=j(e),i=e.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(x,_,R,C,d)=>{if(s.slice(d,d+6)!=="import")return x;if(C.endsWith(".stx"))return"";let f=`${n}Import${r.length}`;if(r.push(`import * as ${f} from ${JSON.stringify(C)};`),_.startsWith("*"))return`import ${_.replace(/^\*\s+as\s+/,"")} = ${f};`;if(!_.startsWith("{"))return`import ${_} = ${f}.default;`;return _.slice(1,-1).split(",").map((w)=>{let[b,u=b]=w.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(!b)return"";if(/^(?:stx|@stacksjs\/stx)(?:\/|$)/.test(C)&&b in t)t[b].push(u);return`import ${u} = ${f}.${b};`}).join(`
30
+ `)}),o=Te(e,t.defineProps),a=Te(e,t.defineEmits),c=Te(e,t.withDefaults);if(!o&&!a)return{declarations:"",props:null,events:null};let l=[],p=null,h=null;if(o){l.push(`const __options = (${o.args[0]||"{}"}) as const;`),l.push(`const __defaults = (${c?.args[1]||"{}"});`);let x=o.type||"__StxOptions<typeof __options>";l.push(`export type __StxProps = __StxDefaults<${x}, keyof typeof __defaults | __StxDefaulted<typeof __options>>;`),p=`${n}.__StxProps`}if(a)l.push(`const __events = (${a.args[0]||"[]"}) as const;`),l.push(`export type __StxEvents = ${a.type||"Record<(typeof __events)[number], any[]>"};`),h=`${n}.__StxEvents`;return{declarations:`${r.join(`
31
31
  `)}
32
32
  namespace ${n} {
33
33
  ${i}
34
34
  ${l.join(`
35
35
  `)}
36
- }`,props:p,events:x}}var oe=Q(require("node:fs"),1),D=Q(require("node:path"),1);function xt(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var ht=new Map;function bt(e,n=!0){let r=ht.get(e);if(n&&r)return r;let t=new Map,s=[D.default.join(e,"src"),D.default.join(e,"dist"),e];function i(o,a){if(a>6)return;let c;try{c=oe.default.readdirSync(o,{withFileTypes:!0})}catch{return}for(let l of c){let p=D.default.join(o,l.name);if(l.isDirectory()){if(l.name==="node_modules"||l.name.startsWith("."))continue;i(p,a+1)}else if(l.isFile()&&l.name.endsWith(".stx")){let x=l.name.slice(0,-4);if(!t.has(x))t.set(x,p);let b=x.toLowerCase();if(!t.has(b))t.set(b,p);let _=xt(x);if(!t.has(_))t.set(_,p)}}}for(let o of s)if(i(o,0),t.size>0)break;if(n)ht.set(e,t);return t}function yt(e,n){if(e.startsWith(".")||e.startsWith("/"))return null;let r=n;while(!0){let t=D.default.join(r,"node_modules",e);try{if(oe.default.statSync(t).isDirectory())return t}catch{}let s=D.default.dirname(r);if(s===r)return null;r=s}}function St(e,n,r={}){return[D.default.resolve(D.default.dirname(n),`${e}.stx`),D.default.resolve(D.default.dirname(n),e),D.default.resolve(r.componentsDir||"components",`${e}.stx`),D.default.resolve(r.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function vt(e){let n=e.endsWith(".stx")?e.slice(0,-4):e,r=n.split("-").map((s)=>s.charAt(0).toUpperCase()+s.slice(1)).join(""),t=xt(n);return[n,r,t]}function Ln(e,n){let[r,t,s]=vt(e);for(let i of[r,r.toLowerCase(),t,s]){let o=n?.__importedComponents?.get(i);if(o!==void 0)return o}}function jn(e,n){let r=n?D.default.resolve(n):void 0,t=D.default.dirname(D.default.resolve(e));for(;;){if(oe.default.existsSync(D.default.join(t,"package.json")))return r&&t===r?void 0:t;let s=D.default.dirname(t);if(s===t)return;t=s}}var Fn=["src/ui","src/components","components","dist"];function Bn(e,n){let r=D.default.resolve(e);if(!n&&!r.split(D.default.sep).includes("node_modules"))return[];let t=jn(r,n);if(!t)return[];let s=[];try{let a=JSON.parse(oe.default.readFileSync(D.default.join(t,"package.json"),"utf8")).stx?.components;if(Array.isArray(a))s=a.filter((c)=>typeof c==="string")}catch{}let i=s.length?s:Fn;return[D.default.dirname(D.default.resolve(e)),...i.map((o)=>D.default.resolve(t,o))]}function*zn(e,n,r={},t){let s=vt(e);if(s[0].startsWith("./")||s[0].startsWith("../")){yield D.default.resolve(D.default.dirname(n),`${s[0]}.stx`);return}let i=[...new Set(s.map((c)=>`${c}.stx`))],o=r.projectRoot||process.cwd(),a=[...Bn(n,r.projectRoot),...t?.__originalFilePath?[D.default.join(D.default.dirname(t.__originalFilePath),"components")]:[],...r.componentsDir?[r.componentsDir]:[],D.default.join(D.default.dirname(n),"components"),D.default.resolve(o,"src/components"),D.default.resolve(o,"components"),D.default.resolve("/home/runner/work/stx/stx/packages/stx/src","components")];for(let c of new Set(a)){for(let l of i)yield D.default.join(c,l);try{for(let l of oe.default.readdirSync(c,{withFileTypes:!0}))if(l.isDirectory())for(let p of i)yield D.default.join(c,l.name,p)}catch{}}}function Et(e,n,r={},t){let s=Ln(e,t);if(s!==void 0)return s;for(let i of zn(e,n,r,t))try{if(oe.default.statSync(i,{throwIfNoEntry:!1})?.isFile())return i}catch{}return null}var wt=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","component","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);function $t(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...wt].some((n)=>n.toLowerCase()===e.toLowerCase());return wt.has(e)||/[A-Z]/.test(e)}function*Vn(e){let n=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,r;while(r=n.exec(e)){let t=n.lastIndex,s=[];while(t<e.length){while(/\s/.test(e[t]||""))t++;if(e[t]===">"||e.slice(t,t+2)==="/>"){t+=e[t]===">"?1:2;break}let i=/^[^\s=/>]+/.exec(e.slice(t))?.[0];if(!i){t++;continue}let o=t;t+=i.length;while(/\s/.test(e[t]||""))t++;if(e[t]!=="="){s.push({name:i,value:!0,offset:o,braced:!1});continue}t++;while(/\s/.test(e[t]||""))t++;let a=e[t],c=a==="{",l=a==='"'||a==="'";if(l||c)t++;let p=t;if(c){let x=j(e.slice(t)),b=1,_=0;for(;_<x.length;_++){if(x[_]==="{")b++;if(x[_]==="}"&&--b===0)break}t+=_}else if(l)while(t<e.length&&e[t]!==a)t++;else while(t<e.length&&!/[\s/>]/.test(e[t]))t++;if(s.push({name:i,value:e.slice(p,t),offset:p,braced:c}),l||c)t++}n.lastIndex=t,yield{name:r[1],offset:r.index,attributes:s}}}function _t(e,n,r){let t=[],s=[Re,"type __StxAssignedValue<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? T extends () => infer V ? V : T : T;","type __StxProp<P, K> = K extends keyof P ? P[K] : unknown;",'type __StxStaticProp<P, K> = __StxProp<P, K> extends infer T ? boolean extends T ? T | "true" | "false" : T : never;','type __StxEvent<E, K> = K extends keyof E ? E[K] extends readonly unknown[] ? number extends E[K]["length"] ? E[K][0] : Exclude<E[K]["length"], 0 | 1> extends never ? E[K][0] : E[K] : E[K] : any;'],i=new Map,o=new Map,a=new Map,c=r.scriptCode(e,r.filePath),l=j(c);for(let R of c.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(l.slice(R.index,R.index+6)!=="import")continue;let C=R[2],d=fe.default.isAbsolute(C)||C.startsWith(".")?fe.default.resolve(fe.default.dirname(r.filePath),C):yt(C,fe.default.dirname(r.filePath));if(!d)continue;let f=d.endsWith(".stx")?d:Oe.default.existsSync(`${d}.stx`)?`${d}.stx`:void 0,w=f?null:bt(d,!1),h=R[1].startsWith("{")?R[1].slice(1,-1).split(","):[R[1]];for(let u of h){let[m,E=m]=u.trim().split(/\s+as\s+/),A=f||w?.get(m)||w?.get(m.toLowerCase());if(A)a.set(E,A),a.set(E.toLowerCase(),A),a.set(E.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),A)}}for(let R of n.matchAll(/@import\s*\(([^)]+)\)/g))for(let C of R[1].matchAll(/['"]([^'"]+)['"]/g)){let d=St(C[1],r.filePath,r).find((f)=>Oe.default.statSync(f,{throwIfNoEntry:!1})?.isFile());if(d)a.set(fe.default.basename(C[1]).replace(/\.stx$/,""),d)}let p={__importedComponents:a},x=new Map,b=(R,C,d)=>{let f=e.slice(0,R);return{code:C,offset:R,attribute:d,anchor:!0,kind:"directive",line:f.split(`
36
+ }`,props:p,events:h}}var oe=Q(require("node:fs"),1),D=Q(require("node:path"),1);function xt(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var ht=new Map;function bt(e,n=!0){let r=ht.get(e);if(n&&r)return r;let t=new Map,s=[D.default.join(e,"src"),D.default.join(e,"dist"),e];function i(o,a){if(a>6)return;let c;try{c=oe.default.readdirSync(o,{withFileTypes:!0})}catch{return}for(let l of c){let p=D.default.join(o,l.name);if(l.isDirectory()){if(l.name==="node_modules"||l.name.startsWith("."))continue;i(p,a+1)}else if(l.isFile()&&l.name.endsWith(".stx")){let h=l.name.slice(0,-4);if(!t.has(h))t.set(h,p);let x=h.toLowerCase();if(!t.has(x))t.set(x,p);let _=xt(h);if(!t.has(_))t.set(_,p)}}}for(let o of s)if(i(o,0),t.size>0)break;if(n)ht.set(e,t);return t}function yt(e,n){if(e.startsWith(".")||e.startsWith("/"))return null;let r=n;while(!0){let t=D.default.join(r,"node_modules",e);try{if(oe.default.statSync(t).isDirectory())return t}catch{}let s=D.default.dirname(r);if(s===r)return null;r=s}}function St(e,n,r={}){return[D.default.resolve(D.default.dirname(n),`${e}.stx`),D.default.resolve(D.default.dirname(n),e),D.default.resolve(r.componentsDir||"components",`${e}.stx`),D.default.resolve(r.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function vt(e){let n=e.endsWith(".stx")?e.slice(0,-4):e,r=n.split("-").map((s)=>s.charAt(0).toUpperCase()+s.slice(1)).join(""),t=xt(n);return[n,r,t]}function Ln(e,n){let[r,t,s]=vt(e);for(let i of[r,r.toLowerCase(),t,s]){let o=n?.__importedComponents?.get(i);if(o!==void 0)return o}}function jn(e,n){let r=n?D.default.resolve(n):void 0,t=D.default.dirname(D.default.resolve(e));for(;;){if(oe.default.existsSync(D.default.join(t,"package.json")))return r&&t===r?void 0:t;let s=D.default.dirname(t);if(s===t)return;t=s}}var Fn=["src/ui","src/components","components","dist"];function Bn(e,n){let r=D.default.resolve(e);if(!n&&!r.split(D.default.sep).includes("node_modules"))return[];let t=jn(r,n);if(!t)return[];let s=[];try{let a=JSON.parse(oe.default.readFileSync(D.default.join(t,"package.json"),"utf8")).stx?.components;if(Array.isArray(a))s=a.filter((c)=>typeof c==="string")}catch{}let i=s.length?s:Fn;return[D.default.dirname(D.default.resolve(e)),...i.map((o)=>D.default.resolve(t,o))]}function*zn(e,n,r={},t){let s=vt(e);if(s[0].startsWith("./")||s[0].startsWith("../")){yield D.default.resolve(D.default.dirname(n),`${s[0]}.stx`);return}let i=[...new Set(s.map((c)=>`${c}.stx`))],o=r.projectRoot||process.cwd(),a=[...Bn(n,r.projectRoot),...t?.__originalFilePath?[D.default.join(D.default.dirname(t.__originalFilePath),"components")]:[],...r.componentsDir?[r.componentsDir]:[],D.default.join(D.default.dirname(n),"components"),D.default.resolve(o,"src/components"),D.default.resolve(o,"components"),D.default.resolve("/home/runner/work/stx/stx/packages/stx/src","components")];for(let c of new Set(a)){for(let l of i)yield D.default.join(c,l);try{for(let l of oe.default.readdirSync(c,{withFileTypes:!0}))if(l.isDirectory())for(let p of i)yield D.default.join(c,l.name,p)}catch{}}}function Et(e,n,r={},t){let s=Ln(e,t);if(s!==void 0)return s;for(let i of zn(e,n,r,t))try{if(oe.default.statSync(i,{throwIfNoEntry:!1})?.isFile())return i}catch{}return null}var wt=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","component","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);function $t(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...wt].some((n)=>n.toLowerCase()===e.toLowerCase());return wt.has(e)||/[A-Z]/.test(e)}function*Vn(e){let n=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,r;while(r=n.exec(e)){let t=n.lastIndex,s=[];while(t<e.length){while(/\s/.test(e[t]||""))t++;if(e[t]===">"||e.slice(t,t+2)==="/>"){t+=e[t]===">"?1:2;break}let i=/^[^\s=/>]+/.exec(e.slice(t))?.[0];if(!i){t++;continue}let o=t;t+=i.length;while(/\s/.test(e[t]||""))t++;if(e[t]!=="="){s.push({name:i,value:!0,offset:o,braced:!1});continue}t++;while(/\s/.test(e[t]||""))t++;let a=e[t],c=a==="{",l=a==='"'||a==="'";if(l||c)t++;let p=t;if(c){let h=j(e.slice(t)),x=1,_=0;for(;_<h.length;_++){if(h[_]==="{")x++;if(h[_]==="}"&&--x===0)break}t+=_}else if(l)while(t<e.length&&e[t]!==a)t++;else while(t<e.length&&!/[\s/>]/.test(e[t]))t++;if(s.push({name:i,value:e.slice(p,t),offset:p,braced:c}),l||c)t++}n.lastIndex=t,yield{name:r[1],offset:r.index,attributes:s}}}function _t(e,n,r){let t=[],s=[Re,"type __StxAssignedValue<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? T extends () => infer V ? V : T : T;","type __StxProp<P, K> = K extends keyof P ? P[K] : unknown;",'type __StxStaticProp<P, K> = __StxProp<P, K> extends infer T ? boolean extends T ? T | "true" | "false" : T : never;','type __StxEvent<E, K> = K extends keyof E ? E[K] extends readonly unknown[] ? number extends E[K]["length"] ? E[K][0] : Exclude<E[K]["length"], 0 | 1> extends never ? E[K][0] : E[K] : E[K] : any;'],i=new Map,o=new Map,a=new Map,c=r.scriptCode(e,r.filePath),l=j(c);for(let R of c.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(l.slice(R.index,R.index+6)!=="import")continue;let C=R[2],d=fe.default.isAbsolute(C)||C.startsWith(".")?fe.default.resolve(fe.default.dirname(r.filePath),C):yt(C,fe.default.dirname(r.filePath));if(!d)continue;let f=d.endsWith(".stx")?d:Oe.default.existsSync(`${d}.stx`)?`${d}.stx`:void 0,w=f?null:bt(d,!1),b=R[1].startsWith("{")?R[1].slice(1,-1).split(","):[R[1]];for(let u of b){let[m,E=m]=u.trim().split(/\s+as\s+/),A=f||w?.get(m)||w?.get(m.toLowerCase());if(A)a.set(E,A),a.set(E.toLowerCase(),A),a.set(E.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),A)}}for(let R of n.matchAll(/@import\s*\(([^)]+)\)/g))for(let C of R[1].matchAll(/['"]([^'"]+)['"]/g)){let d=St(C[1],r.filePath,r).find((f)=>Oe.default.statSync(f,{throwIfNoEntry:!1})?.isFile());if(d)a.set(fe.default.basename(C[1]).replace(/\.stx$/,""),d)}let p={__importedComponents:a},h=new Map,x=(R,C,d)=>{let f=e.slice(0,R);return{code:C,offset:R,attribute:d,anchor:!0,kind:"directive",line:f.split(`
37
37
  `).length,column:R-f.lastIndexOf(`
38
- `)}},_=(R,C,d)=>t.push({expression:R,statement:{text:C+R.code+d,prefixLength:C.length}});for(let R of Vn(n)){if($t(R.name)||R.name==="component")continue;let C=Et(R.name,r.filePath,r,p);if(!C)continue;let d=x.get(C);if(!d){let w;try{w=r.readComponent?r.readComponent(C):Oe.default.readFileSync(C,"utf8")}catch{continue}if(w===void 0)continue;o.set(C,w),d=Ae(r.scriptCode(w,C),`__StxComponent${x.size}`),x.set(C,d),s.push(d.declarations)}let f=[];for(let w of R.attributes){let{name:h,offset:u}=w,m=w.value===!0?"true":w.value;if(h.startsWith("@")||h.startsWith("v-on:")){if(d.events&&w.value!==!0)i.set(u,`__StxEvent<${d.events}, ${JSON.stringify(h.replace(/^@|^v-on:/,"").split(".")[0])}>`);continue}let E=/^v-model(?::([\w-]+))?(?:\.[\w-]+)*$/.exec(h);if(h.startsWith("v-")&&!h.startsWith("v-bind:")&&!E)continue;if(/^(?:x-|:)(?:if|for|show|key|else)(?:$|[.:-])/.test(h))continue;let A=(E?E[1]||"modelValue":h.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(I,P)=>P.toUpperCase());if(f.push(A),!d.props)continue;let v=h.startsWith(":")||h.startsWith("v-bind:")||!!E||w.braced,O=v?m:w.value!==!0?JSON.stringify(m):"true",M=!v&&w.value!==!0&&(m==="true"||m==="false");_(b(u,O,h),";void ((",`) satisfies ${M?"__StxStaticProp":"__StxProp"}<${d.props}, ${JSON.stringify(A)}>);`)}if(d.props){let w=[...new Set(f)].map((u)=>`${JSON.stringify(u)}: undefined as any`).join(", "),h=b(R.offset,`<${R.name}>`);t.push({expression:h,statement:{text:`;void ({ ${w} } satisfies ${d.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:x.size?s.join(`
38
+ `)}},_=(R,C,d)=>t.push({expression:R,statement:{text:C+R.code+d,prefixLength:C.length}});for(let R of Vn(n)){if($t(R.name)||R.name==="component")continue;let C=Et(R.name,r.filePath,r,p);if(!C)continue;let d=h.get(C);if(!d){let w;try{w=r.readComponent?r.readComponent(C):Oe.default.readFileSync(C,"utf8")}catch{continue}if(w===void 0)continue;o.set(C,w),d=Ae(r.scriptCode(w,C),`__StxComponent${h.size}`),h.set(C,d),s.push(d.declarations)}let f=[];for(let w of R.attributes){let{name:b,offset:u}=w,m=w.value===!0?"true":w.value;if(b.startsWith("@")||b.startsWith("v-on:")){if(d.events&&w.value!==!0)i.set(u,`__StxEvent<${d.events}, ${JSON.stringify(b.replace(/^@|^v-on:/,"").split(".")[0])}>`);continue}let E=/^v-model(?::([\w-]+))?(?:\.[\w-]+)*$/.exec(b);if(b.startsWith("v-")&&!b.startsWith("v-bind:")&&!E)continue;if(/^(?:x-|:)(?:if|for|show|key|else)(?:$|[.:-])/.test(b))continue;let A=(E?E[1]||"modelValue":b.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(I,P)=>P.toUpperCase());if(f.push(A),!d.props)continue;let v=b.startsWith(":")||b.startsWith("v-bind:")||!!E||w.braced,O=v?m:w.value!==!0?JSON.stringify(m):"true",M=!v&&w.value!==!0&&(m==="true"||m==="false");_(x(u,O,b),";void ((",`) satisfies ${M?"__StxStaticProp":"__StxProp"}<${d.props}, ${JSON.stringify(A)}>);`)}if(d.props){let w=[...new Set(f)].map((u)=>`${JSON.stringify(u)}: undefined as any`).join(", "),b=x(R.offset,`<${R.name}>`);t.push({expression:b,statement:{text:`;void ({ ${w} } satisfies ${d.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:h.size?s.join(`
39
39
  `):"",checks:t,events:i,dependencies:o}}var Xe=Q(require("node:fs"),1),J=Q(require("node:path"),1);var Pe=["module","exports","require","props","$props","$bool","$num","defineProps","withDefaults","defineClientPayload","useServerData","useRuntimeConfig","useServerRuntimeConfig","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","setResponseStatus","setResponseHeader","notFound","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","useMediaQuery","useScrollLock","usePreferredDark","usePreferredLight","usePreferredReducedMotion","usePreferredContrast","window","document","console","confirm","alert","fetch","params"];function Wn(){let{NODE_ENV:e}=process.env;return e==="production"}function He(){let{STX_DEBUG:e}=process.env;return!Wn()||e==="true"}var Hn={showRelativePaths:!1,enableAutoRecovery:He(),logRecoveryWarnings:!0},vs={...Hn};class Ke{errors=[];maxErrors;enableFileLogging;logFilePath;logFormat;maxFileSize;maxLogFiles;minLevel;writeQueue=Promise.resolve();constructor(e={}){this.maxErrors=e.maxErrors??1000,this.enableFileLogging=e.enableFileLogging??!1,this.logFilePath=e.logFilePath??".stx/errors.log",this.logFormat=e.logFormat??"json",this.maxFileSize=e.maxFileSize??10485760,this.maxLogFiles=e.maxLogFiles??5,this.minLevel=e.minLevel??"all"}configure(e){if(e.maxErrors!==void 0)this.maxErrors=e.maxErrors;if(e.enableFileLogging!==void 0)this.enableFileLogging=e.enableFileLogging;if(e.logFilePath!==void 0)this.logFilePath=e.logFilePath;if(e.logFormat!==void 0)this.logFormat=e.logFormat;if(e.maxFileSize!==void 0)this.maxFileSize=e.maxFileSize;if(e.maxLogFiles!==void 0)this.maxLogFiles=e.maxLogFiles;if(e.minLevel!==void 0)this.minLevel=e.minLevel}log(e,n,r="error"){let t={timestamp:new Date,error:e,context:n,level:r};if(this.errors.push(t),this.errors.length>this.maxErrors)this.errors=this.errors.slice(-this.maxErrors);if(this.enableFileLogging&&this.shouldLog(r))this.writeToFile(t)}shouldLog(e){if(this.minLevel==="all")return!0;if(this.minLevel==="warning")return e==="error"||e==="warning";if(this.minLevel==="error")return e==="error";return!0}formatEntry(e){if(this.logFormat==="json")return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level||"error",type:e.error.constructor.name,message:e.error.message,stack:e.error.stack,context:e.context});let n=[`[${e.timestamp.toISOString()}] [${(e.level||"error").toUpperCase()}] ${e.error.constructor.name}: ${e.error.message}`];if(e.error.stack)n.push(` Stack: ${e.error.stack.split(`
40
40
  `).slice(1).join(`
41
41
  `)}`);if(e.context)n.push(` Context: ${JSON.stringify(e.context)}`);return n.join(`
42
42
  `)}writeToFile(e){this.writeQueue=this.writeQueue.then(async()=>{try{let n=await import("node:fs"),r=await import("node:path"),t=r.dirname(this.logFilePath);if(!n.existsSync(t))n.mkdirSync(t,{recursive:!0});await this.rotateIfNeeded(n);let s=`${this.formatEntry(e)}
43
43
  `;n.appendFileSync(this.logFilePath,s,"utf-8")}catch(n){if(process.env.STX_DEBUG==="true")console.error("Failed to write to error log:",n)}})}async rotateIfNeeded(e){try{if(!e.existsSync(this.logFilePath))return;if(e.statSync(this.logFilePath).size<this.maxFileSize)return;for(let r=this.maxLogFiles-1;r>=1;r--){let t=`${this.logFilePath}.${r}`,s=`${this.logFilePath}.${r+1}`;if(e.existsSync(t))if(r>=this.maxLogFiles-1)e.unlinkSync(t);else e.renameSync(t,s)}if(this.maxLogFiles<=1)e.writeFileSync(this.logFilePath,"");else e.renameSync(this.logFilePath,`${this.logFilePath}.1`)}catch(n){if(process.env.STX_DEBUG==="true")console.error("Failed to rotate error logs:",n)}}getRecentErrors(e=10){return this.errors.slice(-e)}getErrorsByType(e){return this.errors.filter((n)=>n.error.constructor.name===e)}getErrorsByLevel(e){return this.errors.filter((n)=>n.level===e)}clear(){this.errors.length=0}async clearLogFile(){try{let e=await import("node:fs");if(e.existsSync(this.logFilePath))e.writeFileSync(this.logFilePath,"","utf-8")}catch(e){if(process.env.STX_DEBUG==="true")console.error("Failed to clear error log:",e)}}getStats(){let e={},n={error:0,warning:0,info:0};for(let r of this.errors){let t=r.error.constructor.name;e[t]=(e[t]||0)+1;let s=r.level||"error";n[s]=(n[s]||0)+1}return{total:this.errors.length,byType:e,byLevel:n}}async exportToFile(e,n="json"){let r=await import("node:fs"),t=await import("node:path"),s=t.dirname(e);if(!r.existsSync(s))r.mkdirSync(s,{recursive:!0});if(n==="json"){let i=this.errors.map((o)=>({timestamp:o.timestamp.toISOString(),level:o.level||"error",type:o.error.constructor.name,message:o.error.message,stack:o.error.stack,context:o.context}));r.writeFileSync(e,JSON.stringify(i,null,2),"utf-8")}else{let i=this.errors.map((o)=>this.formatEntry(o));r.writeFileSync(e,i.join(`
44
44
 
45
- `),"utf-8")}}async flush(){await this.writeQueue}}var Jn=new Ke;var Xn={maxSanitizeDepth:10,allowBracketNotation:!1},fi={...Xn};var Zn="__stx_safe_ctors",Ct=["Bun","Deno","Buffer","fetch","atob","btoa","console","Response","Request","Headers","WebAssembly","structuredClone","queueMicrotask","crypto","performance","navigator","Worker","WebSocket","BroadcastChannel","EventSource","XMLHttpRequest","localStorage","sessionStorage"],Yn=[...Ct,"Function","setTimeout","setInterval","setImmediate","process","require","exports","module","window","document","global","globalThis","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry"],mi=Yn.map(()=>{return}),gi=Object.freeze(Object.assign(Object.create(null),{keys:Object.keys,values:Object.values,entries:Object.entries,fromEntries:Object.fromEntries,assign:Object.assign,hasOwn:Object.hasOwn,is:Object.is}));var hi=new Set([...Ct,"eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this",Zn]);var Tt=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],xi=(()=>{let e={Date,URL,URLSearchParams},n=Intl;for(let r of Tt)if(typeof n[r]==="function")e[`Intl_${r}`]=n[r];return Object.freeze(Object.assign(Object.create(null),e))})();var bi=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${Tt.join(",")}}() are allowed`;var yi=Symbol("stx.sanitizeCache");var Si=`stx-compile-probe:${globalThis.crypto.randomUUID()}`;var vi=new Se(2000,{maxBytes:2097152,sizeOf:(e)=>e.sourceBytes});function ve(e,n,r,t){if(e[n]!==r)return-1;let s=0,i=null;for(let o=n;o<e.length;o++){let a=e[o];if(i){if(a==="\\"){o++;continue}if(a===i)i=null;continue}if(a==="'"||a==='"'||a==="`"){i=a;continue}if(a===r)s++;else if(a===t){if(t===">"&&e[o-1]==="=")continue;if(s--,s===0)return o+1}}return-1}var At=require("node:module");var eo=new Set(At.builtinModules);function Ue(e){return e.replace(/<!--[\s\S]*?-->|\{\{--[\s\S]*?--\}\}/g,(n)=>n.replace(/[^\n]/g," "))}function Ge(e){for(let n of ue(Ue(e))){let r=pe(n.attrs);if(!r.has("component")&&!r.has("stx:component"))continue;return{code:e.slice(n.bodyStart,n.bodyEnd),start:n.bodyStart,open:n.start}}}function Ot(e,n){let r=Ge(e);if(!r)return{};let t=r.code.trim();if(!t)return{};try{let s=JSON.parse(t);if(!s||typeof s!=="object"||Array.isArray(s))throw Error("expected a JSON object");return s}catch(s){throw Error(`${n}: <script component> must contain JSON metadata (${s.message})`)}}function Je(e,n){let r=j(e),t=new Set(Ce(e).map((c)=>c.start)),s=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/g,i=[],o=n?void 0:new Bun.Transpiler({loader:"ts"}),a;while(a=s.exec(r)){if(!t.has(a.index+a[0].indexOf("function")))continue;let c=s.lastIndex;while(/\s/.test(r[c]||""))c++;let l=c;if(r[c]==="<")c=ve(r,c,"<",">");if(c<0)continue;let p=e.slice(l,c).trim();while(/\s/.test(r[c]||""))c++;if(r[c]!=="(")continue;let x=c,b=ve(r,c,"(",")");if(b<0)continue;for(c=b;c<e.length;c++){let _=r[c];if(_!=="{"&&_!==";")continue;let R=e.slice(a.index,c).trim();if(n){if(!n(R,_,a[1]))continue}else{let d;try{d=o.transformSync(R+(_==="{"?"{}":";"))}catch{continue}if(_==="{"&&!d.includes(`function ${a[1]}(`))continue;if(_===";"&&d.trim())continue}let C=_==="{"?ve(r,c,"{","}"):c+1;if(C<0)break;i.push({name:a[1],header:R,generic:p,parameterOffset:x+1,parameters:e.slice(x+1,b-1),returns:e.slice(b,c).trim().replace(/^:\s*/,""),async:/\basync\s+function/.test(a[0]),..._==="{"?{source:e.slice(a.index,C)}:{}}),s.lastIndex=C;break}}return i}function Me(e,n){if(e[n]!=="(")return null;let r=0,t="";for(let s=n;s<e.length;s++){let i=e[s];if(t!==""){if(i==="\\")s++;else if(i===t)t="";continue}if(i==="'"||i==='"'||i==="`"){t=i;continue}if(i==="(")r++;else if(i===")"){if(r--,r===0)return{expression:e.slice(n+1,s),end:s+1}}}return null}function Pt(e){let n=/^([\s\S]+?)\s+as\s+(?:([A-Za-z_$][\w$]*)\s*=>\s*)?([A-Za-z_$][\w$]*)$/.exec(e.trim());return n?{iterable:n[1],key:n[2],value:n[3]}:void 0}function qe(e){if(!e||typeof e!=="object")return"unknown";switch(e.type){case"boolean":return"boolean";case"number":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return"string"}}var nr=new Set(Pe);function Ie(e){let n=he(e),r=n.find((x)=>x.name==="InheritedContext");if(!r)return;let t=/^(?:interface\s+InheritedContext|type\s+InheritedContext\s*=)\s*\{/.test(j(r.text).trim()),s=j(e),i=U(s).depths,o=[...s.matchAll(/\b(?:interface|type)\s+InheritedContext\b/g)].find((x)=>i[x.index]===0)?.index??0,a=r.text.slice(r.text.indexOf("{")+1,r.text.lastIndexOf("}")),c=j(a),l=U(c).depths,p=[...c.matchAll(/(?:^|[;,\n])\s*(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:/g)].filter((x)=>l[x.index]===0).map((x)=>x[1]);return{keys:t?p:[],types:n.map((x)=>x.text).join(`
45
+ `),"utf-8")}}async flush(){await this.writeQueue}}var Jn=new Ke;var Xn={maxSanitizeDepth:10,allowBracketNotation:!1},fi={...Xn};var Zn="__stx_safe_ctors",Ct=["Bun","Deno","Buffer","fetch","atob","btoa","console","Response","Request","Headers","WebAssembly","structuredClone","queueMicrotask","crypto","performance","navigator","Worker","WebSocket","BroadcastChannel","EventSource","XMLHttpRequest","localStorage","sessionStorage"],Yn=[...Ct,"Function","setTimeout","setInterval","setImmediate","process","require","exports","module","window","document","global","globalThis","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry"],mi=Yn.map(()=>{return}),gi=Object.freeze(Object.assign(Object.create(null),{keys:Object.keys,values:Object.values,entries:Object.entries,fromEntries:Object.fromEntries,assign:Object.assign,hasOwn:Object.hasOwn,is:Object.is}));var hi=new Set([...Ct,"eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this",Zn]);var Tt=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],xi=(()=>{let e={Date,URL,URLSearchParams},n=Intl;for(let r of Tt)if(typeof n[r]==="function")e[`Intl_${r}`]=n[r];return Object.freeze(Object.assign(Object.create(null),e))})();var bi=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${Tt.join(",")}}() are allowed`;var yi=Symbol("stx.sanitizeCache");var Si=`stx-compile-probe:${globalThis.crypto.randomUUID()}`;var vi=new Se(2000,{maxBytes:2097152,sizeOf:(e)=>e.sourceBytes});function ve(e,n,r,t){if(e[n]!==r)return-1;let s=0,i=null;for(let o=n;o<e.length;o++){let a=e[o];if(i){if(a==="\\"){o++;continue}if(a===i)i=null;continue}if(a==="'"||a==='"'||a==="`"){i=a;continue}if(a===r)s++;else if(a===t){if(t===">"&&e[o-1]==="=")continue;if(s--,s===0)return o+1}}return-1}var At=require("node:module");var eo=new Set(At.builtinModules);function Ue(e){return e.replace(/<!--[\s\S]*?-->|\{\{--[\s\S]*?--\}\}/g,(n)=>n.replace(/[^\n]/g," "))}function Ge(e){for(let n of ue(Ue(e))){let r=pe(n.attrs);if(!r.has("component")&&!r.has("stx:component"))continue;return{code:e.slice(n.bodyStart,n.bodyEnd),start:n.bodyStart,open:n.start}}}function Ot(e,n){let r=Ge(e);if(!r)return{};let t=r.code.trim();if(!t)return{};try{let s=JSON.parse(t);if(!s||typeof s!=="object"||Array.isArray(s))throw Error("expected a JSON object");return s}catch(s){throw Error(`${n}: <script component> must contain JSON metadata (${s.message})`)}}function Je(e,n){let r=j(e),t=new Set(Ce(e).map((c)=>c.start)),s=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/g,i=[],o=n?void 0:new Bun.Transpiler({loader:"ts"}),a;while(a=s.exec(r)){if(!t.has(a.index+a[0].indexOf("function")))continue;let c=s.lastIndex;while(/\s/.test(r[c]||""))c++;let l=c;if(r[c]==="<")c=ve(r,c,"<",">");if(c<0)continue;let p=e.slice(l,c).trim();while(/\s/.test(r[c]||""))c++;if(r[c]!=="(")continue;let h=c,x=ve(r,c,"(",")");if(x<0)continue;for(c=x;c<e.length;c++){let _=r[c];if(_!=="{"&&_!==";")continue;let R=e.slice(a.index,c).trim();if(n){if(!n(R,_,a[1]))continue}else{let d;try{d=o.transformSync(R+(_==="{"?"{}":";"))}catch{continue}if(_==="{"&&!d.includes(`function ${a[1]}(`))continue;if(_===";"&&d.trim())continue}let C=_==="{"?ve(r,c,"{","}"):c+1;if(C<0)break;i.push({name:a[1],header:R,generic:p,parameterOffset:h+1,parameters:e.slice(h+1,x-1),returns:e.slice(x,c).trim().replace(/^:\s*/,""),async:/\basync\s+function/.test(a[0]),..._==="{"?{source:e.slice(a.index,C)}:{}}),s.lastIndex=C;break}}return i}function Me(e,n){if(e[n]!=="(")return null;let r=0,t="";for(let s=n;s<e.length;s++){let i=e[s];if(t!==""){if(i==="\\")s++;else if(i===t)t="";continue}if(i==="'"||i==='"'||i==="`"){t=i;continue}if(i==="(")r++;else if(i===")"){if(r--,r===0)return{expression:e.slice(n+1,s),end:s+1}}}return null}function Pt(e){let n=/^([\s\S]+?)\s+as\s+(?:([A-Za-z_$][\w$]*)\s*=>\s*)?([A-Za-z_$][\w$]*)$/.exec(e.trim());return n?{iterable:n[1],key:n[2],value:n[3]}:void 0}function qe(e){if(!e||typeof e!=="object")return"unknown";switch(e.type){case"boolean":return"boolean";case"number":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return"string"}}var nr=new Set(Pe);function Ie(e){let n=he(e),r=n.find((h)=>h.name==="InheritedContext");if(!r)return;let t=/^(?:interface\s+InheritedContext|type\s+InheritedContext\s*=)\s*\{/.test(j(r.text).trim()),s=j(e),i=U(s).depths,o=[...s.matchAll(/\b(?:interface|type)\s+InheritedContext\b/g)].find((h)=>i[h.index]===0)?.index??0,a=r.text.slice(r.text.indexOf("{")+1,r.text.lastIndexOf("}")),c=j(a),l=U(c).depths,p=[...c.matchAll(/(?:^|[;,\n])\s*(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:/g)].filter((h)=>l[h.index]===0).map((h)=>h[1]);return{keys:t?p:[],types:n.map((h)=>h.text).join(`
46
46
  `),offset:Math.max(0,o),...!t?{unsupported:"InheritedContext requires a local non-generic object interface or object type alias with named properties"}:{}}}function rr(e){let n=[],r=j(e);for(let t of e.matchAll(/\bimport\s+(type\s+)?([\w$*{}\s,]+?)\s+from\s*(['"])([^'"]+)\3/g)){if(t[1]||r.slice(t.index,t.index+6)!=="import")continue;let s=t[2].trim(),i=["stx","@stacksjs/stx"].includes(t[4]);if(/^[A-Za-z_$][\w$]*$/.test(s)){n.push(s);continue}if(!s.startsWith("{")||!s.endsWith("}"))continue;for(let o of s.slice(1,-1).split(",")){if(/^\s*type\s+/.test(o))continue;let[a,c=a]=o.trim().split(/\s+as\s+/);if(c&&!(i&&nr.has(a)))n.push(c)}}return n}function Mt(e){let n=Ie(e);if(!n||n.unsupported)return"";let r=new Set(ae(e));return n.keys.filter((t)=>!r.has(t)).map((t)=>`declare const ${t}: InheritedContext[${JSON.stringify(t)}];`).join(`
47
- `)}function It(e,n){let r=[Re],t=[],s=new Map,i=J.default.resolve(n.filePath),o=i.split(J.default.sep).lastIndexOf("views"),a=o>=0?i.split(J.default.sep).slice(0,o).join(J.default.sep):J.default.dirname(i),c=J.default.resolve(n.partialsDir||J.default.join(a,"partials")),l=J.default.resolve(n.layoutsDir||J.default.join(a,"views/layouts"));if([c,l].some((d)=>i===d||i.startsWith(d+J.default.sep)))return{declarations:"",checks:t,dependencies:s};let p=(d)=>n.readTemplate?.(d)??(Xe.default.existsSync(d)?Xe.default.readFileSync(d,"utf8"):void 0),x=0,b=!1,_=[];function R(d,f){let w=e.slice(0,d).split(`
48
- `).length,h=d-e.lastIndexOf(`
47
+ `)}function It(e,n){let r=[Re],t=[],s=new Map,i=J.default.resolve(n.filePath),o=i.split(J.default.sep).lastIndexOf("views"),a=o>=0?i.split(J.default.sep).slice(0,o).join(J.default.sep):J.default.dirname(i),c=J.default.resolve(n.partialsDir||J.default.join(a,"partials")),l=J.default.resolve(n.layoutsDir||J.default.join(a,"views/layouts"));if([c,l].some((d)=>i===d||i.startsWith(d+J.default.sep)))return{declarations:"",checks:t,dependencies:s};let p=(d)=>n.readTemplate?.(d)??(Xe.default.existsSync(d)?Xe.default.readFileSync(d,"utf8"):void 0),h=0,x=!1,_=[];function R(d,f){let w=e.slice(0,d).split(`
48
+ `).length,b=d-e.lastIndexOf(`
49
49
  `,d-1),u={code:e.slice(d,e.indexOf(`
50
50
  `,d)<0?e.length:e.indexOf(`
51
- `,d)),line:w,column:h,kind:"directive",offset:d,anchor:!0};t.push({expression:u,statement:{text:`;${f}`,prefixLength:1}})}function C(d,f,w,h,u,m){let E=`__StxInherited${x++}`;while((e+d+[...s.values()].join("")).includes(E))E+="_";let A=me(d).filter((L)=>L.kind==="server").map((L)=>L.code).join(`
52
- `),v=`${E}ParentValue`,O=`${E}ParentType`;r.push(`type ${O} = ${w};`);let M=Ze(De(A,J.default.dirname(f)),E);r.push(...M.imports);let I=Ie(A);if(I&&u!==void 0){b=!0;let L=M.imports.length?M.aliases.join(`
51
+ `,d)),line:w,column:b,kind:"directive",offset:d,anchor:!0};t.push({expression:u,statement:{text:`;${f}`,prefixLength:1}})}function C(d,f,w,b,u,m){let E=`__StxInherited${h++}`;while((e+d+[...s.values()].join("")).includes(E))E+="_";let A=me(d).filter((L)=>L.kind==="server").map((L)=>L.code).join(`
52
+ `),v=`${E}ParentValue`,O=`${E}ParentType`;r.push(`type ${O} = ${w};`);let M=Ze(De(A,J.default.dirname(f)),E);r.push(...M.imports);let I=Ie(A);if(I&&u!==void 0){x=!0;let L=M.imports.length?M.aliases.join(`
53
53
  `):"",W=Ae(`${L}
54
54
  ${I.types}
55
- const __contract = defineProps<InheritedContext>();`,`${E}Contract`);r.push(W.declarations),r.push(`declare const ${E}Input: ${O};`),R(u,I.unsupported?`({})[${JSON.stringify(I.unsupported)}];`:`${E}Input satisfies ${W.props};`)}let P=[...new Set([...ae(A),...rr(A)])],B=[...new Set([...h,...I?.keys||[]])].filter((L)=>!P.includes(L)),K=I?`${O} & ${E}Contract.__StxProps`:O,q=Ne(M.body).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,""),G=[],ee=ge(d),re=/@(include|extends|layout)\s*\(/g,X;while(X=re.exec(ee)){let L=Me(ee,re.lastIndex-1);if(!L)continue;re.lastIndex=L.end;let W=/^\s*(['"])(.*?)\1\s*(?:,\s*([\s\S]*))?$/.exec(L.expression);if(!W){_.push({offset:u??X.index,message:`Inherited context cannot be checked across dynamic @${X[1]}`});continue}let Y=W[2],F=X[1];if(F!=="include"&&W[3])_.push({offset:u??X.index,message:`Inherited context cannot be checked for unsupported @${F} data arguments`});let ke=F==="include"?c:l,xe=J.default.resolve(Y.startsWith(".")?J.default.dirname(f):ke,Y.endsWith(".stx")?Y:Y+".stx");if(p(xe)===void 0){_.push({offset:u??X.index,message:`Inherited context target cannot be resolved: ${Y}`});continue}G.push({name:`edge${G.length}`,target:xe,kind:F,args:F==="include"?W[3]||"{}":"{}",offset:u??X.index})}let le=`{ ...${v}${P.length?", "+P.join(", "):""} }`;r.push(`namespace ${E} {
55
+ const __contract = defineProps<InheritedContext>();`,`${E}Contract`);r.push(W.declarations),r.push(`declare const ${E}Input: ${O};`),R(u,I.unsupported?`({})[${JSON.stringify(I.unsupported)}];`:`${E}Input satisfies ${W.props};`)}let P=[...new Set([...ae(A),...rr(A)])],B=[...new Set([...b,...I?.keys||[]])].filter((L)=>!P.includes(L)),K=I?`${O} & ${E}Contract.__StxProps`:O,q=Ne(M.body).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,""),G=[],ee=ge(d),re=/@(include|extends|layout)\s*\(/g,X;while(X=re.exec(ee)){let L=Me(ee,re.lastIndex-1);if(!L)continue;re.lastIndex=L.end;let W=/^\s*(['"])(.*?)\1\s*(?:,\s*([\s\S]*))?$/.exec(L.expression);if(!W){_.push({offset:u??X.index,message:`Inherited context cannot be checked across dynamic @${X[1]}`});continue}let Y=W[2],F=X[1];if(F!=="include"&&W[3])_.push({offset:u??X.index,message:`Inherited context cannot be checked for unsupported @${F} data arguments`});let ke=F==="include"?c:l,xe=J.default.resolve(Y.startsWith(".")?J.default.dirname(f):ke,Y.endsWith(".stx")?Y:Y+".stx");if(p(xe)===void 0){_.push({offset:u??X.index,message:`Inherited context target cannot be resolved: ${Y}`});continue}G.push({name:`edge${G.length}`,target:xe,kind:F,args:F==="include"?W[3]||"{}":"{}",offset:u??X.index})}let le=`{ ...${v}${P.length?", "+P.join(", "):""} }`;r.push(`namespace ${E} {
56
56
  ${M.aliases.join(`
57
57
  `)}
58
58
  export async function read(${v}: ${u===void 0?"{}":K}) {
@@ -60,47 +60,47 @@ ${B.length?`const { ${B.join(", ")} } = ${v};`:""}
60
60
  ${q}
61
61
  return { context: ${le}${G.map((L)=>`, ${L.name}: { ...${le}, ...(${L.args}) }`).join("")} };
62
62
  }
63
- }`);for(let L of G){if(m.includes(L.target)||m.length>=32){_.push({offset:L.offset,message:"Inherited context cannot be checked across a cyclic or overly deep template graph"});continue}let W=p(L.target);s.set(L.target,W),C(W,L.target,`Awaited<ReturnType<typeof ${E}.read>>[${JSON.stringify(L.name)}]`,[...new Set([...h,...P])],L.offset,[...m,L.target])}return E}if(C(e,i,"{}",[],void 0,[i]),b||n.contractsKnown)for(let d of _)R(d.offset,`({})[${JSON.stringify(d.message)}];`);return{declarations:b?r.join(`
63
+ }`);for(let L of G){if(m.includes(L.target)||m.length>=32){_.push({offset:L.offset,message:"Inherited context cannot be checked across a cyclic or overly deep template graph"});continue}let W=p(L.target);s.set(L.target,W),C(W,L.target,`Awaited<ReturnType<typeof ${E}.read>>[${JSON.stringify(L.name)}]`,[...new Set([...b,...P])],L.offset,[...m,L.target])}return E}if(C(e,i,"{}",[],void 0,[i]),x||n.contractsKnown)for(let d of _)R(d.offset,`({})[${JSON.stringify(d.message)}];`);return{declarations:x?r.join(`
64
64
  `):"",checks:t,dependencies:s}}function Nt(e,n){let r=Ue(e),t=Ge(e);if(!t)return;let s;try{s=Ot(e,"component")}catch(u){let m=t.open,E=u instanceof Error?u.message:"Invalid component metadata";return{declarations:"",checks:[{text:`({})[${JSON.stringify(E)}];`,line:e.slice(0,m).split(`
65
65
  `).length,column:m-e.lastIndexOf(`
66
66
  `,m-1),origin:"component"}],project:(A)=>({code:A,columns:new Map})}}let i=ue(r).filter((u)=>{let m=pe(u.attrs);return ye(m)&&m.has("client")&&!m.has("server")&&!m.has("component")&&!m.has("stx:component")&&!m.has("src")}),o=i.map((u)=>e.slice(u.bodyStart,u.bodyEnd)).join(`
67
- `),a=Je(o,n),c=he(o).some((u)=>u.name==="ComponentState")||Le(o).includes("ComponentState"),l=Object.entries(s.properties||s.props||{}).map(([u,m])=>`${JSON.stringify(u)}: ${qe(m)}`).join("; "),p=[...new Set(a.map((u)=>u.name))],x=[`interface __StxMetadataProperties { ${l} }`,"type __StxNativeProperties = Omit<__StxMetadataProperties, keyof HTMLElement> & Pick<HTMLElement, Extract<keyof __StxMetadataProperties, keyof HTMLElement>>;","type __StxAny<T> = 0 extends (1 & T) ? true : false;","type __StxAnyFields<T> = { [K in keyof T]-?: __StxAny<T[K]> extends true ? K : never }[keyof T];","type __StxSpecific<T> = __StxAny<T> extends true ? false : T extends object ? string extends keyof T ? false : number extends keyof T ? false : symbol extends keyof T ? false : __StxAnyFields<T> extends never ? true : false : false;",c?"type __StxState = __StxSpecific<ComponentState> extends true ? ComponentState : {};":"type __StxState = {};",c?'declare function __stxSpecificState(value: __StxSpecific<ComponentState> extends true ? true : "ComponentState requires named explicit fields without any or index signatures"): void;':"",c?"declare const __stxStateProperties: Pick<ComponentState, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;":"",c?'declare function __stxStateMethods(value: Extract<keyof ComponentState, __StxMethodNames | "emit" | "requestUpdate" | "updateComplete" | "renderRoot"> extends never ? true : "ComponentState cannot redeclare component methods"): void;':"",`type __StxMethodNames = ${p.map((u)=>JSON.stringify(u)).join(" | ")||"never"};`,"type __StxInstanceProperties = Omit<HTMLElement, __StxMethodNames | keyof __StxNativeProperties> & __StxNativeProperties;",'type __StxPrivateKeys<T> = Exclude<keyof T, keyof HTMLElement | keyof __StxNativeProperties | __StxMethodNames | "emit" | "updateComplete" | "requestUpdate" | "renderRoot">;',c?'declare function __stxOptionalPrivate(value: { [K in __StxPrivateKeys<ComponentState>]-?: {} extends Pick<ComponentState, K> ? never : K }[__StxPrivateKeys<ComponentState>] extends never ? true : "Private ComponentState fields must be optional until initialized"): void;':"","type __StxRefinedProperties = { [K in keyof __StxNativeProperties]: K extends keyof __StxState ? __StxAny<__StxState[K]> extends true ? __StxNativeProperties[K] : __StxState[K] extends __StxNativeProperties[K] ? __StxState[K] : __StxNativeProperties[K] : __StxNativeProperties[K] };","type __StxNativeComponent = Omit<HTMLElement, keyof __StxNativeProperties | __StxMethodNames> & __StxRefinedProperties & Partial<Pick<__StxState, __StxPrivateKeys<__StxState>>> & {","readonly updateComplete: Promise<void>; requestUpdate(): Promise<void>; readonly renderRoot: HTMLElement | ShadowRoot;","emit<T = unknown>(name: string, detail?: T, options?: CustomEventInit<T>): boolean;",...p.map((u)=>`${JSON.stringify(u)}: typeof ${u};`),"}"].filter(Boolean).join(`
68
- `),b=-1;for(let u of i){let m=u.bodyStart,E=e.slice(m,u.bodyEnd),A=j(E),v=U(A).depths,O=[...A.matchAll(/\b(?:interface|type)\s+ComponentState\b/g)].find((M)=>v[M.index]===0)??(Le(E).includes("ComponentState")?/\bComponentState\b/.exec(A):void 0);if(O){b=m+O.index;break}}let _=c&&b>=0?[{origin:"client",text:"__stxSpecificState(true); __stxStateMethods(true); __stxOptionalPrivate(true); __stxStateProperties satisfies Pick<__StxInstanceProperties, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;",line:e.slice(0,b).split(`
69
- `).length,column:b-e.lastIndexOf(`
70
- `,b-1)}]:[],{start:R,code:C}=t,d=j(C),f=U(d).depths,w=new Map,h=!1;for(let u of C.matchAll(/"(?:\\.|[^"\\])*"\s*:/g)){let m=JSON.parse(u[0].slice(0,u[0].lastIndexOf(":")).trim());if(f[u.index]===1&&["properties","props"].includes(m)){h=!0;continue}if(h&&f[u.index]===1)h=!1;if(h&&f[u.index]===2&&!w.has(m))w.set(m,R+u.index)}for(let[u,m]of Object.entries(s.properties||s.props||{})){let E=w.get(u)??R,A=e.slice(0,E).split(`
67
+ `),a=Je(o,n),c=he(o).some((u)=>u.name==="ComponentState")||Le(o).includes("ComponentState"),l=Object.entries(s.properties||s.props||{}).map(([u,m])=>`${JSON.stringify(u)}: ${qe(m)}`).join("; "),p=[...new Set(a.map((u)=>u.name))],h=[`interface __StxMetadataProperties { ${l} }`,"type __StxNativeProperties = Omit<__StxMetadataProperties, keyof HTMLElement> & Pick<HTMLElement, Extract<keyof __StxMetadataProperties, keyof HTMLElement>>;","type __StxAny<T> = 0 extends (1 & T) ? true : false;","type __StxAnyFields<T> = { [K in keyof T]-?: __StxAny<T[K]> extends true ? K : never }[keyof T];","type __StxSpecific<T> = __StxAny<T> extends true ? false : T extends object ? string extends keyof T ? false : number extends keyof T ? false : symbol extends keyof T ? false : __StxAnyFields<T> extends never ? true : false : false;",c?"type __StxState = __StxSpecific<ComponentState> extends true ? ComponentState : {};":"type __StxState = {};",c?'declare function __stxSpecificState(value: __StxSpecific<ComponentState> extends true ? true : "ComponentState requires named explicit fields without any or index signatures"): void;':"",c?"declare const __stxStateProperties: Pick<ComponentState, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;":"",c?'declare function __stxStateMethods(value: Extract<keyof ComponentState, __StxMethodNames | "emit" | "requestUpdate" | "updateComplete" | "renderRoot"> extends never ? true : "ComponentState cannot redeclare component methods"): void;':"",`type __StxMethodNames = ${p.map((u)=>JSON.stringify(u)).join(" | ")||"never"};`,"type __StxInstanceProperties = Omit<HTMLElement, __StxMethodNames | keyof __StxNativeProperties> & __StxNativeProperties;",'type __StxPrivateKeys<T> = Exclude<keyof T, keyof HTMLElement | keyof __StxNativeProperties | __StxMethodNames | "emit" | "updateComplete" | "requestUpdate" | "renderRoot">;',c?'declare function __stxOptionalPrivate(value: { [K in __StxPrivateKeys<ComponentState>]-?: {} extends Pick<ComponentState, K> ? never : K }[__StxPrivateKeys<ComponentState>] extends never ? true : "Private ComponentState fields must be optional until initialized"): void;':"","type __StxRefinedProperties = { [K in keyof __StxNativeProperties]: K extends keyof __StxState ? __StxAny<__StxState[K]> extends true ? __StxNativeProperties[K] : __StxState[K] extends __StxNativeProperties[K] ? __StxState[K] : __StxNativeProperties[K] : __StxNativeProperties[K] };","type __StxNativeComponent = Omit<HTMLElement, keyof __StxNativeProperties | __StxMethodNames> & __StxRefinedProperties & Partial<Pick<__StxState, __StxPrivateKeys<__StxState>>> & {","readonly updateComplete: Promise<void>; requestUpdate(): Promise<void>; readonly renderRoot: HTMLElement | ShadowRoot;","emit<T = unknown>(name: string, detail?: T, options?: CustomEventInit<T>): boolean;",...p.map((u)=>`${JSON.stringify(u)}: typeof ${u};`),"}"].filter(Boolean).join(`
68
+ `),x=-1;for(let u of i){let m=u.bodyStart,E=e.slice(m,u.bodyEnd),A=j(E),v=U(A).depths,O=[...A.matchAll(/\b(?:interface|type)\s+ComponentState\b/g)].find((M)=>v[M.index]===0)??(Le(E).includes("ComponentState")?/\bComponentState\b/.exec(A):void 0);if(O){x=m+O.index;break}}let _=c&&x>=0?[{origin:"client",text:"__stxSpecificState(true); __stxStateMethods(true); __stxOptionalPrivate(true); __stxStateProperties satisfies Pick<__StxInstanceProperties, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;",line:e.slice(0,x).split(`
69
+ `).length,column:x-e.lastIndexOf(`
70
+ `,x-1)}]:[],{start:R,code:C}=t,d=j(C),f=U(d).depths,w=new Map,b=!1;for(let u of C.matchAll(/"(?:\\.|[^"\\])*"\s*:/g)){let m=JSON.parse(u[0].slice(0,u[0].lastIndexOf(":")).trim());if(f[u.index]===1&&["properties","props"].includes(m)){b=!0;continue}if(b&&f[u.index]===1)b=!1;if(b&&f[u.index]===2&&!w.has(m))w.set(m,R+u.index)}for(let[u,m]of Object.entries(s.properties||s.props||{})){let E=w.get(u)??R,A=e.slice(0,E).split(`
71
71
  `).length,v=E-e.lastIndexOf(`
72
- `,E-1);if(!m||typeof m!=="object"||!["string","number","boolean","object","array"].includes(m.type))_.push({text:`({})[${JSON.stringify(`Property ${u} must declare string, number, boolean, object or array`)}];`,line:A,column:v,origin:"component"});if(m&&m.default!==void 0)_.push({text:`const __stxDefault${_.length}: ${qe(m)} = ${JSON.stringify(m.default)};`,line:A,column:v,origin:"component"})}return{declarations:x,checks:_,project(u){let m=new Map,E=[],A=0;for(let v of Je(u,n)){if(/^\s*this\s*:/.test(v.parameters))continue;let O=v.parameterOffset,M=`this: __StxNativeComponent${v.parameters.trim()?", ":""}`;E.push(u.slice(A,O),M);let I=u.slice(0,O).split(`
72
+ `,E-1);if(!m||typeof m!=="object"||!["string","number","boolean","object","array"].includes(m.type))_.push({text:`({})[${JSON.stringify(`Property ${u} must declare string, number, boolean, object or array`)}];`,line:A,column:v,origin:"component"});if(m&&m.default!==void 0)_.push({text:`const __stxDefault${_.length}: ${qe(m)} = ${JSON.stringify(m.default)};`,line:A,column:v,origin:"component"})}return{declarations:h,checks:_,project(u){let m=new Map,E=[],A=0;for(let v of Je(u,n)){if(/^\s*this\s*:/.test(v.parameters))continue;let O=v.parameterOffset,M=`this: __StxNativeComponent${v.parameters.trim()?", ":""}`;E.push(u.slice(A,O),M);let I=u.slice(0,O).split(`
73
73
  `).length,P=O-u.lastIndexOf(`
74
74
  `,O-1),B=m.get(I)||[],K=B.at(-1),q=P+(K?K.generatedEnd-K.sourceEnd:0);B.push({sourceStart:P,sourceEnd:P,generatedStart:q,generatedEnd:q+M.length}),m.set(I,B),A=O}return E.push(u.slice(A)),{code:E.join(""),columns:m}}}}function Dt(e){let n=[],r=[],t=/@foreach\s*\(|@endforeach\b/g,s;while(s=t.exec(e)){if(s[0].startsWith("@endforeach")){let c=r.pop();if(c)c.end=s.index,n.push(c);continue}let i=Me(e,t.lastIndex-1);if(!i)continue;let o=Pt(i.expression),a=i.end;if(o)r.push({start:a,end:e.length,iterable:o.iterable,binding:o.key?`${o.value}, ${o.key}`:o.value});t.lastIndex=a}return n.sort((i,o)=>i.start-o.start)}function Lt(e){if(!e.includes("#")&&!e.includes("v-slot:")&&!e.includes("data-stx-slot-binding"))return[];let n=[],r=[],t=/<!--[\s\S]*?-->|<script\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/script\s*>|<style\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/style\s*>|<\/?[a-z][\w:-]*\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;for(let s of e.matchAll(t)){let i=s[0];if(/^<\/template\s*>$/i.test(i)){let o=r.pop();if(o)o.end=s.index}else if(/^<template\b/i.test(i)&&!/\/\s*>$/.test(i)){let a=[...i.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((p)=>/^(?:#[\w-]+|v-slot:[\w-]+|data-stx-slot-binding)$/i.test(p[1])),c=(a?.[2]??a?.[3])?.trim();if(c&&a?.[1]==="data-stx-slot-binding")try{c=decodeURIComponent(c)}catch{c=void 0}let l=c?{start:s.index+i.length,end:e.length,binding:c}:void 0;if(r.push(l),l)n.push(l)}}return n}function sr(e){let n=(r)=>r.replace(/[^\n]/g," ");return e.replace(/<!--[\s\S]*?-->/g,n).replace(/\{\{--[\s\S]*?--\}\}/g,n)}function me(e){let n=[],r=sr(e);for(let t of ue(r)){let s=t.attrs.trim(),i=pe(s),{bodyStart:o,bodyEnd:a}=t,c=e.slice(o,a);if(i.has("src")||i.has("component")||i.has("stx:component"))continue;if(!ye(i))continue;let l=i.has("server")?"server":i.has("client")?"client":"plain",p=Ee(e,o);n.push({kind:l,code:c,startLine:p,startColumn:we(e,o),offset:o,attrs:s})}return n}function Ee(e,n){let r=1;for(let t=0;t<n&&t<e.length;t++)if(e.charCodeAt(t)===10)r++;return r}function we(e,n){let r=e.lastIndexOf(`
75
75
  `,n-1)+1;return n-r+1}function ge(e){let n=e.split(""),r=(s,i)=>{for(let o=s;o<i&&o<n.length;o++)if(n[o]!==`
76
- `)n[o]=" "},t=[/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi,/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi,/<!--[\s\S]*?-->/g,/\{\{--[\s\S]*?--\}\}/g,/@verbatim\b[\s\S]*?@endverbatim\b/g];for(let s of t){s.lastIndex=0;let i;while((i=s.exec(e))!==null)r(i.index,i.index+i[0].length)}return n.join("")}function Wt(e){let n=0,r="";for(let t=0;t<e.length;t++){let s=e[t];if(r){if(s==="\\"){t++;continue}if(s===r)r="";continue}if(s==='"'||s==="'"||s==="`"){r=s;continue}if(s==="("||s==="["||s==="{"){n++;continue}if(s===")"||s==="]"||s==="}"){n--;continue}if(s==="|"&&n===0){if(e[t+1]==="|"){t++;continue}if(e[t-1]==="|")continue;return e.slice(0,t)}}return e}var Ht=new Set([":for","x-for","v-for"]),je=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,et="__stx_interpolated",jt="__StxElement",Kt="__StxTemplateValue",ir=`type ${Kt}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function Ft(e){return e.replace(/\{\{[\s\S]*?\}\}/g,et).replace(/\{!![\s\S]*?!!\}/g,et)}function or(e,n,r){let t=0;for(let s=n;s<e.length;s++){let i=e[s];if(i==="{"){t++;continue}if(i!=="}"&&i!=="!")continue;if(e.startsWith(r,s)&&t===0)return s;if(i==="}"&&t>0)t--}return-1}function ar(e,n,r="0"){let t=`__stxScript${r}`;while((e+n).includes(t))t+="_";let s=new Map,i=[],o=[],a=j(e),c=$e(e),l=[],p=0;for(let C=0;C<a.length;C++){let d=a.startsWith("{{",C);if(!d&&!a.startsWith("{!!",C))continue;let f=d?2:3,w=d?"}}":"!!}",h=or(a,C+f,w);if(h<0)continue;let u=C,m=e.slice(u,h+w.length),E=m.slice(f,-w.length);C=h+w.length-1;let A=o.length,v=ce(c,u),O=ce(c,u+(d?2:3));o.push({code:Wt(E),...O});let M=`${t}_${A}`,I=m.split(`
76
+ `)n[o]=" "},t=[/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi,/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi,/<!--[\s\S]*?-->/g,/\{\{--[\s\S]*?--\}\}/g,/@verbatim\b[\s\S]*?@endverbatim\b/g];for(let s of t){s.lastIndex=0;let i;while((i=s.exec(e))!==null)r(i.index,i.index+i[0].length)}return n.join("")}function Wt(e){let n=0,r="";for(let t=0;t<e.length;t++){let s=e[t];if(r){if(s==="\\"){t++;continue}if(s===r)r="";continue}if(s==='"'||s==="'"||s==="`"){r=s;continue}if(s==="("||s==="["||s==="{"){n++;continue}if(s===")"||s==="]"||s==="}"){n--;continue}if(s==="|"&&n===0){if(e[t+1]==="|"){t++;continue}if(e[t-1]==="|")continue;return e.slice(0,t)}}return e}var Ht=new Set([":for","x-for","v-for"]),je=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,et="__stx_interpolated",jt="__StxElement",Kt="__StxTemplateValue",ir=`type ${Kt}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function Ft(e){return e.replace(/\{\{[\s\S]*?\}\}/g,et).replace(/\{!![\s\S]*?!!\}/g,et)}function or(e,n,r){let t=0;for(let s=n;s<e.length;s++){let i=e[s];if(i==="{"){t++;continue}if(i!=="}"&&i!=="!")continue;if(e.startsWith(r,s)&&t===0)return s;if(i==="}"&&t>0)t--}return-1}function ar(e,n,r="0"){let t=`__stxScript${r}`;while((e+n).includes(t))t+="_";let s=new Map,i=[],o=[],a=j(e),c=$e(e),l=[],p=0;for(let C=0;C<a.length;C++){let d=a.startsWith("{{",C);if(!d&&!a.startsWith("{!!",C))continue;let f=d?2:3,w=d?"}}":"!!}",b=or(a,C+f,w);if(b<0)continue;let u=C,m=e.slice(u,b+w.length),E=m.slice(f,-w.length);C=b+w.length-1;let A=o.length,v=ce(c,u),O=ce(c,u+(d?2:3));o.push({code:Wt(E),...O});let M=`${t}_${A}`,I=m.split(`
77
77
  `),P=I[0].length;I[0]=M+" ".repeat(Math.max(0,P-M.length));for(let G=1;G<I.length;G++)I[G]=I[G].replace(/[^\r]/g," ");let B=s.get(v.line)??[],K=B.at(-1),q=v.column+(K?K.generatedEnd-K.sourceEnd:0);B.push({sourceStart:v.column,sourceEnd:v.column+P,generatedStart:q,generatedEnd:q+I[0].length}),s.set(v.line,B),l.push(e.slice(p,u),I.join(`
78
- `)),p=u+m.length}l.push(e.slice(p));let x=l.join("");if(!o.length)return{code:x,columns:s,declarations:i};let{imports:b,aliases:_,body:R}=Ze(n,t);for(let C of b)i.push({text:C});i.push({text:`namespace ${t}Scope {
78
+ `)),p=u+m.length}l.push(e.slice(p));let h=l.join("");if(!o.length)return{code:h,columns:s,declarations:i};let{imports:x,aliases:_,body:R}=Ze(n,t);for(let C of x)i.push({text:C});i.push({text:`namespace ${t}Scope {
79
79
  ${_.join(`
80
80
  `)}
81
81
  export async function read() {
82
82
  ${Ne(R).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,"")}
83
83
  return {`});for(let[C,d]of o.entries())i.push({text:`value${C}: (`}),i.push({text:d.code,origin:{line:d.line,column:d.column}}),i.push({text:"),"});i.push({text:`}
84
84
  }
85
- }`});for(let C=0;C<o.length;C++)i.push({text:`declare var ${t}_${C}: Awaited<ReturnType<typeof ${t}Scope.read>>['value${C}']`});return{code:x,columns:s,declarations:i}}function Ze(e,n){let r=[],{imports:t,body:s}=mr(e),i=[],o=0;for(let a of t.split(/\n(?=import\b)/)){if(!a.trim())continue;let c=/^import\s+(?:type\s+)?([\s\S]+?)\s+from\s*(['"][^'"]+['"])/.exec(a);if(!c){r.push(a);continue}let l=`${n}Module${o++}`;r.push(`import * as ${l} from ${c[2]}`);let p=c[1],x=/\{([\s\S]*?)\}/.exec(p);for(let C of x?.[1].split(",")??[]){let[d,f=d]=C.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(d==="default")i.push(`const ${f} = ${l}.default; type ${f} = import(${c[2]}).default`);else if(d)i.push(`import ${f} = ${l}.${d}`)}let b=p.replace(/\{[\s\S]*?\}/,""),_=/\*\s+as\s+(\w+)/.exec(b);if(_)i.push(`import ${_[1]} = ${l}`);let R=/^\s*([\w$]+)/.exec(b)?.[1];if(R)i.push(`const ${R} = ${l}.default; type ${R} = import(${c[2]}).default`)}return{imports:r,aliases:i,body:s}}function Ye(e,n){let r=0;for(let t of e){if(n<t.generatedStart)break;if(n<t.generatedEnd)return t.sourceStart+Math.min(n-t.generatedStart,t.sourceEnd-t.sourceStart);r=t.sourceEnd-t.generatedEnd}return n+r}function Qe(e,n){let r=0;for(let t of e){if(n<t.sourceStart)break;if(n<t.sourceEnd)return t.generatedStart+Math.min(n-t.sourceStart,t.generatedEnd-t.generatedStart);r=t.generatedEnd-t.sourceEnd}return n+r}var cr=["foreach","endforeach","forelse","endforelse","for","endfor","while","endwhile","empty","if","elseif","else","endif","unless","endunless","isset","endisset","switch","case","default","endswitch","auth","endauth","guest","endguest","env","endenv","once","endonce","break","continue"],lr=new RegExp(String.raw`^[ \t]*@(?:${cr.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function Ne(e){return e.replace(lr,(n)=>n.replace(/[^\n]/g," "))}var Bt=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function ur(e){let n=ge(e),r=[],t=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,s;while((s=t.exec(n))!==null){if(s[1]||s[3])continue;let a=s[2]??s[4]??"",c=s[2]!==void 0?2:3,l=Wt(a);if(!l.trim())continue;let p=s.index+c+(l.length-l.trimStart().length);r.push({code:l.trim(),line:Ee(n,p),column:we(n,p),offset:p,kind:"interpolation"})}let i=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((s=i.exec(n))!==null){let o=s.index+s[0].length-1,a=0,c=o;for(;c<n.length;c++){let b=n[c];if(b==="(")a++;else if(b===")"){if(a--,a===0)break}}if(a!==0)continue;let l=n.slice(o+1,c),p=l.trim();if(i.lastIndex=c+1,!p)continue;let x=o+1+(l.length-l.trimStart().length);r.push({code:p,line:Ee(n,x),column:we(n,x),offset:s.index,kind:"condition"})}je.lastIndex=0;while((s=je.exec(n))!==null){let o=s[1],a=s[3]??"",c=o.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(Bt.has(c)||Bt.has(o))continue;if(!a.trim())continue;let l=s.index+s[0].indexOf(s[2],s[0].indexOf(o)+o.length)+1;if(Ht.has(c)){let x=a.match(/\s+(?:in|of)\s+/);if(!x||x.index===void 0)continue;let b=a.slice(x.index+x[0].length),_=x.index+x[0].length+(b.length-b.trimStart().length);r.push({code:Ft(b.trim()),line:Ee(n,l+_),column:we(n,l+_),offset:l+_,kind:"directive",attribute:c});continue}let p=a.length-a.trimStart().length;r.push({code:Ft(a.trim()),line:Ee(n,l+p),column:we(n,l+p),offset:l+p,kind:"directive",attribute:c})}return r.sort((o,a)=>o.line-a.line||o.column-a.column),r}var pr=2000;function dr(e,n){let r=0,t=Math.min(e.length,n+pr);for(let s=n;s<t;s++){let i=e[s];if(i==="(")r++;else if(i===")"){if(r--,r===0)return e.slice(n+1,s)}}return null}function fr(e){let n=new Map,r=(a,c)=>{let l=a.split(/[,[\]{}()\s]+/).filter(Boolean);for(let p of l){let x=p.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(x))continue;let b=l.length===1?c:void 0,_=n.get(x);if(!_)n.set(x,{name:x,iterable:b});else if(_.iterable!==b)_.iterable=void 0}},t=/^\$?[A-Z_$][\w$]*$/i,s=(a)=>{let c=a.trim();return t.test(c)?c:void 0};for(let a of e.matchAll(/@for(?:each|else)\s*\(/g)){let c=dr(e,a.index+a[0].length-1);if(c===null)continue;let l=mt(c);if(!l)continue;r(l.itemVar.replace(/=>/g," "),s(l.arrayExpr))}for(let a of e.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))r(a[1],a[2]==="of"?s(a[3]):void 0);for(let a of e.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))r(a[1]);let i=ge(e);je.lastIndex=0;let o;while((o=je.exec(i))!==null){let a=o[1].replace(/\..*$/,"");if(!Ht.has(a))continue;let c=o[3].match(/\s+(?:in|of)\s+/);if(!c||c.index===void 0)continue;r(o[3].slice(0,c.index),s(o[3].slice(c.index+c[0].length)))}for(let a of e.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let c of a[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))r(c[1]);return[...n.values()].sort((a,c)=>a.name.localeCompare(c.name))}function ae(e){return ft(e)}var zt=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"];function Ut(e){return new Set([...e.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((n)=>n[1]))}function mr(e){let n=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,r=[],t=e.replace(n,(s)=>(r.push(s.trim()),s.split(`
85
+ }`});for(let C=0;C<o.length;C++)i.push({text:`declare var ${t}_${C}: Awaited<ReturnType<typeof ${t}Scope.read>>['value${C}']`});return{code:h,columns:s,declarations:i}}function Ze(e,n){let r=[],{imports:t,body:s}=mr(e),i=[],o=0;for(let a of t.split(/\n(?=import\b)/)){if(!a.trim())continue;let c=/^import\s+(?:type\s+)?([\s\S]+?)\s+from\s*(['"][^'"]+['"])/.exec(a);if(!c){r.push(a);continue}let l=`${n}Module${o++}`;r.push(`import * as ${l} from ${c[2]}`);let p=c[1],h=/\{([\s\S]*?)\}/.exec(p);for(let C of h?.[1].split(",")??[]){let[d,f=d]=C.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(d==="default")i.push(`const ${f} = ${l}.default; type ${f} = import(${c[2]}).default`);else if(d)i.push(`import ${f} = ${l}.${d}`)}let x=p.replace(/\{[\s\S]*?\}/,""),_=/\*\s+as\s+(\w+)/.exec(x);if(_)i.push(`import ${_[1]} = ${l}`);let R=/^\s*([\w$]+)/.exec(x)?.[1];if(R)i.push(`const ${R} = ${l}.default; type ${R} = import(${c[2]}).default`)}return{imports:r,aliases:i,body:s}}function Ye(e,n){let r=0;for(let t of e){if(n<t.generatedStart)break;if(n<t.generatedEnd)return t.sourceStart+Math.min(n-t.generatedStart,t.sourceEnd-t.sourceStart);r=t.sourceEnd-t.generatedEnd}return n+r}function Qe(e,n){let r=0;for(let t of e){if(n<t.sourceStart)break;if(n<t.sourceEnd)return t.generatedStart+Math.min(n-t.sourceStart,t.generatedEnd-t.generatedStart);r=t.generatedEnd-t.sourceEnd}return n+r}var cr=["foreach","endforeach","forelse","endforelse","for","endfor","while","endwhile","empty","if","elseif","else","endif","unless","endunless","isset","endisset","switch","case","default","endswitch","auth","endauth","guest","endguest","env","endenv","once","endonce","break","continue"],lr=new RegExp(String.raw`^[ \t]*@(?:${cr.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function Ne(e){return e.replace(lr,(n)=>n.replace(/[^\n]/g," "))}var Bt=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function ur(e){let n=ge(e),r=[],t=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,s;while((s=t.exec(n))!==null){if(s[1]||s[3])continue;let a=s[2]??s[4]??"",c=s[2]!==void 0?2:3,l=Wt(a);if(!l.trim())continue;let p=s.index+c+(l.length-l.trimStart().length);r.push({code:l.trim(),line:Ee(n,p),column:we(n,p),offset:p,kind:"interpolation"})}let i=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((s=i.exec(n))!==null){let o=s.index+s[0].length-1,a=0,c=o;for(;c<n.length;c++){let x=n[c];if(x==="(")a++;else if(x===")"){if(a--,a===0)break}}if(a!==0)continue;let l=n.slice(o+1,c),p=l.trim();if(i.lastIndex=c+1,!p)continue;let h=o+1+(l.length-l.trimStart().length);r.push({code:p,line:Ee(n,h),column:we(n,h),offset:s.index,kind:"condition"})}je.lastIndex=0;while((s=je.exec(n))!==null){let o=s[1],a=s[3]??"",c=o.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(Bt.has(c)||Bt.has(o))continue;if(!a.trim())continue;let l=s.index+s[0].indexOf(s[2],s[0].indexOf(o)+o.length)+1;if(Ht.has(c)){let h=a.match(/\s+(?:in|of)\s+/);if(!h||h.index===void 0)continue;let x=a.slice(h.index+h[0].length),_=h.index+h[0].length+(x.length-x.trimStart().length);r.push({code:Ft(x.trim()),line:Ee(n,l+_),column:we(n,l+_),offset:l+_,kind:"directive",attribute:c});continue}let p=a.length-a.trimStart().length;r.push({code:Ft(a.trim()),line:Ee(n,l+p),column:we(n,l+p),offset:l+p,kind:"directive",attribute:c})}return r.sort((o,a)=>o.line-a.line||o.column-a.column),r}var pr=2000;function dr(e,n){let r=0,t=Math.min(e.length,n+pr);for(let s=n;s<t;s++){let i=e[s];if(i==="(")r++;else if(i===")"){if(r--,r===0)return e.slice(n+1,s)}}return null}function fr(e){let n=new Map,r=(a,c)=>{let l=a.split(/[,[\]{}()\s]+/).filter(Boolean);for(let p of l){let h=p.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(h))continue;let x=l.length===1?c:void 0,_=n.get(h);if(!_)n.set(h,{name:h,iterable:x});else if(_.iterable!==x)_.iterable=void 0}},t=/^\$?[A-Z_$][\w$]*$/i,s=(a)=>{let c=a.trim();return t.test(c)?c:void 0};for(let a of e.matchAll(/@for(?:each|else)\s*\(/g)){let c=dr(e,a.index+a[0].length-1);if(c===null)continue;let l=mt(c);if(!l)continue;r(l.itemVar.replace(/=>/g," "),s(l.arrayExpr))}for(let a of e.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))r(a[1],a[2]==="of"?s(a[3]):void 0);for(let a of e.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))r(a[1]);let i=ge(e);je.lastIndex=0;let o;while((o=je.exec(i))!==null){let a=o[1].replace(/\..*$/,"");if(!Ht.has(a))continue;let c=o[3].match(/\s+(?:in|of)\s+/);if(!c||c.index===void 0)continue;r(o[3].slice(0,c.index),s(o[3].slice(c.index+c[0].length)))}for(let a of e.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let c of a[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))r(c[1]);return[...n.values()].sort((a,c)=>a.name.localeCompare(c.name))}function ae(e){return ft(e)}var zt=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"];function Ut(e){return new Set([...e.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((n)=>n[1]))}function mr(e){let n=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,r=[],t=e.replace(n,(s)=>(r.push(s.trim()),s.split(`
86
86
  `).map(()=>"").join(`
87
87
  `)));return{imports:r.join(`
88
- `),body:t}}function he(e){let n=j(e),r=Array(n.length),t=0;for(let a=0;a<n.length;a++){let c=n[a];if(c==="}"||c===")"||c==="]")t=Math.max(0,t-1);if(r[a]=t,c==="{"||c==="("||c==="[")t++}let s=[],i=/^[ \t]*(?:export[ \t]+)?(interface|type)[ \t]+([A-Za-z_$][\w$]*)/gm,o;while((o=i.exec(n))!==null){if(r[o.index]!==0)continue;let a=o[1],c=o[2],l;if(a==="interface"){let p=n.indexOf("{",o.index);if(p===-1)continue;let x=0;l=-1;for(let b=p;b<n.length;b++)if(n[b]==="{")x++;else if(n[b]==="}"&&--x===0){l=b+1;break}if(l===-1)continue}else{let p=0;l=n.length;for(let x=n.indexOf("=",o.index)+1;x<n.length;x++){let b=n[x];if(b==="{"||b==="["||b==="("||b==="<")p++;else if(b==="}"||b==="]"||b===")"||b===">")p--;else if(p<=0&&(b===";"||b===`
89
- `&&!/[=|&,<([{]\s*$/.test(n.slice(Math.max(0,x-40),x)))){l=b===";"?x+1:x;break}}}s.push({name:c,text:e.slice(o.index,l).replace(/^[ \t]*export[ \t]+/,"")}),i.lastIndex=l}return s}function gr(e){let n=j(e),r=[],t=/^[ \t]*(?:export[ \t]+)?(?:const|let|var)[ \t]+/gm,s,i=0,o=0;while((s=t.exec(n))!==null){for(;o<s.index;o++){let l=n[o];if(l==="{"||l==="("||l==="[")i++;else if(l==="}"||l===")"||l==="]")i=Math.max(0,i-1)}if(i!==0)continue;let a=0,c=n.length;for(let l=s.index+s[0].length;l<n.length;l++){let p=n[l];if(p==="{"||p==="("||p==="[")a++;else if(p==="}"||p===")"||p==="]")a--;else if(a<=0&&(p===";"||p===`
88
+ `),body:t}}function he(e){let n=j(e),r=Array(n.length),t=0;for(let a=0;a<n.length;a++){let c=n[a];if(c==="}"||c===")"||c==="]")t=Math.max(0,t-1);if(r[a]=t,c==="{"||c==="("||c==="[")t++}let s=[],i=/^[ \t]*(?:export[ \t]+)?(interface|type)[ \t]+([A-Za-z_$][\w$]*)/gm,o;while((o=i.exec(n))!==null){if(r[o.index]!==0)continue;let a=o[1],c=o[2],l;if(a==="interface"){let p=n.indexOf("{",o.index);if(p===-1)continue;let h=0;l=-1;for(let x=p;x<n.length;x++)if(n[x]==="{")h++;else if(n[x]==="}"&&--h===0){l=x+1;break}if(l===-1)continue}else{let p=0;l=n.length;for(let h=n.indexOf("=",o.index)+1;h<n.length;h++){let x=n[h];if(x==="{"||x==="["||x==="("||x==="<")p++;else if(x==="}"||x==="]"||x===")"||x===">")p--;else if(p<=0&&(x===";"||x===`
89
+ `&&!/[=|&,<([{]\s*$/.test(n.slice(Math.max(0,h-40),h)))){l=x===";"?h+1:h;break}}}s.push({name:c,text:e.slice(o.index,l).replace(/^[ \t]*export[ \t]+/,"")}),i.lastIndex=l}return s}function gr(e){let n=j(e),r=[],t=/^[ \t]*(?:export[ \t]+)?(?:const|let|var)[ \t]+/gm,s,i=0,o=0;while((s=t.exec(n))!==null){for(;o<s.index;o++){let l=n[o];if(l==="{"||l==="("||l==="[")i++;else if(l==="}"||l===")"||l==="]")i=Math.max(0,i-1)}if(i!==0)continue;let a=0,c=n.length;for(let l=s.index+s[0].length;l<n.length;l++){let p=n[l];if(p==="{"||p==="("||p==="[")a++;else if(p==="}"||p===")"||p==="]")a--;else if(a<=0&&(p===";"||p===`
90
90
  `)){c=p===";"?l+1:l;break}}if(/\bdefineProps\s*(?:<|\()/.test(n.slice(s.index,c)))r.push(e.slice(s.index,c).replace(/^[ \t]*export[ \t]+/,"").trim())}return r}function hr(e){let n=e.filter((s)=>s.kind==="server").map((s)=>s.code).join(`
91
91
  `);if(/\bdefineProps\s*(?:<|\()/.test(j(n)))return n;let r=xr(n),t=e.filter((s)=>s.kind!=="server").flatMap((s)=>{let i=gr(s.code);if(!i.length)return[];return[...he(s.code).filter((o)=>!r.has(o.name)).map((o)=>o.text),...i]});return[n,...t].filter(Boolean).join(`
92
- `)}function xr(e){return new Set(he(e).map((n)=>n.name))}var Vt=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","$native","props","slot"];function Gt(e){let n=new Set,r=new Set;for(let t of e){let s=t.kind==="server"?n:r;for(let i of ae(t.code))s.add(i)}return[...n].filter((t)=>r.has(t)).sort()}var br=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function yr(e){let n=new Map,r=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let t of e){let s=j(t),{depths:i,balanced:o}=U(s);if(!o)continue;let a=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let c of s.matchAll(a)){let l=c.index??0;if(i[l+c[1].length]!==0)continue;let p=c[2],x=l+c[0].length-c[3].length,b=t.slice(x,l+c[0].length).trim().replace(/;$/,"").trim(),_=c[3],R=r.test(_)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(_)&&!/[,+\-*/%&|?:=]$/.test(b)&&U(_).balanced;n.set(p,n.has(p)||!R?null:b)}}return new Map([...n].filter((t)=>t[1]!==null))}function Jt(e,n,r=0,t=new Set){if(n.size===0||r>=5)return e;let s=j(e),i="",o=0;for(let a of s.matchAll(/[A-Za-z_$][\w$]*/g)){let c=a.index??0,l=a[0],p=n.get(l);if(!p||t.has(l))continue;let x=s.slice(0,c).trimEnd(),b=s.slice(c+l.length).trimStart();if(x.endsWith(".")||/^:(?!:)/.test(b)&&/[{,]$/.test(x))continue;if(c>0&&/[\w$]/.test(s[c-1]))continue;i+=`${e.slice(o,c)}(${Jt(p,n,r+1,new Set([...t,l]))})`,o=c+l.length}return i+e.slice(o)}function Sr(e,n){let r=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,t=[],s;while((s=r.exec(e))!==null){if(s.index>n)break;let i=s[1];if(s.index===n){if(i==="elseif"){let a=t[t.length-1];if(a?.current)a.seen.push(a.current);if(a)a.current=null}break}if(i==="endif"||i==="endunless"){t.pop();continue}let o="";if(s[2]==="("){let a=0,c=s.index+s[0].length-1,l=c+1;for(;c<e.length;c++){let p=e[c];if(p==="(")a++;else if(p===")"){if(a--,a===0)break}}o=e.slice(l,c).trim(),r.lastIndex=c+1}if(i==="if")t.push({seen:[],current:o});else if(i==="unless")t.push({seen:[],current:`!(${o})`});else if(i==="elseif"||i==="else"){let a=t[t.length-1];if(!a)continue;if(a.current)a.seen.push(a.current);a.current=i==="elseif"?o:null}}return t.flatMap((i)=>[...i.seen.map((o)=>`!(${o})`),...i.current?[i.current]:[]]).filter(Boolean)}function vr(e){let n=e.code.trim();if(!n)return null;if(e.attribute?.startsWith("@")){if(br.test(n))return null;let t=";(($event: any): void => { ";return{text:`${t}${n} });`,prefixLength:t.length}}let r=";void ((";return{text:`${r}${n}));`,prefixLength:r.length}}var Er=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function De(e,n){return qt(e,n).code}function qt(e,n){let r=new Map;if(!n)return{code:e,columns:r};let t=$e(e),s=[],i=0;for(let o of e.matchAll(Er)){let a=o.index,[c,l,p,x]=o,b=tt.default.resolve(n,x).replace(/\\/g,"/"),_=`${l}${p}${b}${p}`;if(s.push(e.slice(i,a),_),i=a+c.length,c.includes(`
92
+ `)}function xr(e){return new Set(he(e).map((n)=>n.name))}var Vt=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","$native","props","slot"];function Gt(e){let n=new Set,r=new Set;for(let t of e){let s=t.kind==="server"?n:r;for(let i of ae(t.code))s.add(i)}return[...n].filter((t)=>r.has(t)).sort()}var br=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function yr(e){let n=new Map,r=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let t of e){let s=j(t),{depths:i,balanced:o}=U(s);if(!o)continue;let a=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let c of s.matchAll(a)){let l=c.index??0;if(i[l+c[1].length]!==0)continue;let p=c[2],h=l+c[0].length-c[3].length,x=t.slice(h,l+c[0].length).trim().replace(/;$/,"").trim(),_=c[3],R=r.test(_)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(_)&&!/[,+\-*/%&|?:=]$/.test(x)&&U(_).balanced;n.set(p,n.has(p)||!R?null:x)}}return new Map([...n].filter((t)=>t[1]!==null))}function Jt(e,n,r=0,t=new Set){if(n.size===0||r>=5)return e;let s=j(e),i="",o=0;for(let a of s.matchAll(/[A-Za-z_$][\w$]*/g)){let c=a.index??0,l=a[0],p=n.get(l);if(!p||t.has(l))continue;let h=s.slice(0,c).trimEnd(),x=s.slice(c+l.length).trimStart();if(h.endsWith(".")||/^:(?!:)/.test(x)&&/[{,]$/.test(h))continue;if(c>0&&/[\w$]/.test(s[c-1]))continue;i+=`${e.slice(o,c)}(${Jt(p,n,r+1,new Set([...t,l]))})`,o=c+l.length}return i+e.slice(o)}function Sr(e,n){let r=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,t=[],s;while((s=r.exec(e))!==null){if(s.index>n)break;let i=s[1];if(s.index===n){if(i==="elseif"){let a=t[t.length-1];if(a?.current)a.seen.push(a.current);if(a)a.current=null}break}if(i==="endif"||i==="endunless"){t.pop();continue}let o="";if(s[2]==="("){let a=0,c=s.index+s[0].length-1,l=c+1;for(;c<e.length;c++){let p=e[c];if(p==="(")a++;else if(p===")"){if(a--,a===0)break}}o=e.slice(l,c).trim(),r.lastIndex=c+1}if(i==="if")t.push({seen:[],current:o});else if(i==="unless")t.push({seen:[],current:`!(${o})`});else if(i==="elseif"||i==="else"){let a=t[t.length-1];if(!a)continue;if(a.current)a.seen.push(a.current);a.current=i==="elseif"?o:null}}return t.flatMap((i)=>[...i.seen.map((o)=>`!(${o})`),...i.current?[i.current]:[]]).filter(Boolean)}function vr(e){let n=e.code.trim();if(!n)return null;if(e.attribute?.startsWith("@")){if(br.test(n))return null;let t=";(($event: any): void => { ";return{text:`${t}${n} });`,prefixLength:t.length}}let r=";void ((";return{text:`${r}${n}));`,prefixLength:r.length}}var Er=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function De(e,n){return qt(e,n).code}function qt(e,n){let r=new Map;if(!n)return{code:e,columns:r};let t=$e(e),s=[],i=0;for(let o of e.matchAll(Er)){let a=o.index,[c,l,p,h]=o,x=tt.default.resolve(n,h).replace(/\\/g,"/"),_=`${l}${p}${x}${p}`;if(s.push(e.slice(i,a),_),i=a+c.length,c.includes(`
93
93
  `))continue;let R=ce(t,a),C=r.get(R.line)??[],d=C.at(-1),f=R.column+(d?d.generatedEnd-d.sourceEnd:0);C.push({sourceStart:R.column,sourceEnd:R.column+c.length,generatedStart:f,generatedEnd:f+_.length}),r.set(R.line,C)}return s.push(e.slice(i)),{code:s.join(""),columns:r}}function wr(e,n,r){let t=Ye(e.importColumns?.get(n)??[],r);return Ye(e.scriptColumns?.get(n)??[],Ye(e.componentColumns?.get(n)??[],t))}function Xt(e,n,r){let t=Qe(e.scriptColumns?.get(n)??[],r);return Qe(e.importColumns?.get(n)??[],Qe(e.componentColumns?.get(n)??[],t))}function $r(e){return" ".repeat(Math.max(0,(e.startColumn??1)-1))}function Le(e){let n=new Set,r=j(e);for(let t of r.matchAll(/\bimport\s+(?:type\s+)?([\w$*{}\s,]+?)\s+from\b/g)){let s=t[1],i=/\{([^}]*)\}/.exec(s);for(let l of i?.[1].split(",")??[]){let p=l.trim().replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim();if(p&&/^[A-Z_$][\w$]*$/i.test(p))n.add(p)}let o=s.replace(/\{[^}]*\}/,""),a=/\*\s*as\s+([A-Z_$][\w$]*)/i.exec(o);if(a)n.add(a[1]);let c=/^\s*([A-Z_$][\w$]*)/i.exec(o);if(c&&c[1]!=="type")n.add(c[1])}return[...n].sort()}function Zt(e,n={}){let r=me(e),t=n.scriptKinds?r.filter((u)=>n.scriptKinds.includes(u.kind)):r,s=Nt(e,n.componentMethodValidator),i=n.filePath&&n.templateExpressions!==!1?It(e,{filePath:n.filePath,partialsDir:n.partialsDir,layoutsDir:n.layoutsDir,contractsKnown:n.inheritedContractsKnown,readTemplate:n.readComponent}):void 0,o=new Map,a=e.split(`
94
- `),c=Array.from({length:a.length},()=>""),l=new Map,p=new Map,x=new Map,b=[],_=hr(r),R=n.filePath&&n.templateExpressions!==!1?_t(e,ge(e),{filePath:n.filePath,componentsDir:n.componentsDir,projectRoot:n.projectRoot,readComponent:n.readComponent,scriptCode:(u,m)=>me(u).map((E)=>De(E.code,tt.default.dirname(m))).join(`
95
- `)}):void 0,C=new Set,d=[];for(let[u,m]of t.entries()){let E=ar($r(m)+m.code,_,String(u));for(let[I,P]of E.columns)p.set(m.startLine+I-1,P);for(let I of E.declarations)b.push({text:De(I.text,n.originDir??""),origin:I.origin?{...I.origin,line:I.origin.line+m.startLine-1}:void 0});let A=m.kind==="client"&&s?s.project(E.code):void 0;for(let[I,P]of A?.columns??[])o.set(m.startLine+I-1,P);let v=Ne(A?.code??E.code),O=qt(v,n.originDir??"");for(let[I,P]of O.columns)x.set(m.startLine+I-1,P);let M=O.code.split(`
94
+ `),c=Array.from({length:a.length},()=>""),l=new Map,p=new Map,h=new Map,x=[],_=hr(r),R=n.filePath&&n.templateExpressions!==!1?_t(e,ge(e),{filePath:n.filePath,componentsDir:n.componentsDir,projectRoot:n.projectRoot,readComponent:n.readComponent,scriptCode:(u,m)=>me(u).map((E)=>De(E.code,tt.default.dirname(m))).join(`
95
+ `)}):void 0,C=new Set,d=[];for(let[u,m]of t.entries()){let E=ar($r(m)+m.code,_,String(u));for(let[I,P]of E.columns)p.set(m.startLine+I-1,P);for(let I of E.declarations)x.push({text:De(I.text,n.originDir??""),origin:I.origin?{...I.origin,line:I.origin.line+m.startLine-1}:void 0});let A=m.kind==="client"&&s?s.project(E.code):void 0;for(let[I,P]of A?.columns??[])o.set(m.startLine+I-1,P);let v=Ne(A?.code??E.code),O=qt(v,n.originDir??"");for(let[I,P]of O.columns)h.set(m.startLine+I-1,P);let M=O.code.split(`
96
96
  `);M.forEach((I,P)=>{let B=m.startLine-1+P;if(B<c.length)c[B]=I,C.add(B)}),d.push(m.startLine-1+M.length-1)}for(let u of d){let m=c[u]?.trim()===""?u:u+1;if(m<c.length&&c[m].trim()===""&&(m===u||!C.has(m)))c[m]=";"}let f=(u,m)=>{for(let[E,A]of u.split(`
97
97
  `).entries())if(c.push(A),m)l.set(c.length,E===0?m:{...m,line:m.line+E,column:1,prefixLength:0})},w=Mt(t.filter((u)=>u.kind==="server").map((u)=>u.code).join(`
98
98
  `));if(w)f(w);for(let u of t.filter((m)=>m.kind==="server")){let m=Ie(u.code);if(!m?.unsupported)continue;let E=u.code.slice(0,m.offset),A=u.startLine+E.split(`
99
99
  `).length-1,v=m.offset-u.code.lastIndexOf(`
100
- `,m.offset-1)+(A===u.startLine?(u.startColumn??1)-1:0);f(`;({})[${JSON.stringify(m.unsupported)}];`,{line:A,column:v,anchor:!0})}if(i?.declarations)f(i.declarations);for(let u of b)f(u.text,u.origin);if(s){if(f(s.declarations),n.nativeChecks!==!1)for(let u of s.checks)f(u.text,{line:u.line,column:u.column,diagnosticOrigin:u.origin,anchor:!0})}if(n.globals!==!1){f("");let u=new Set([...t.flatMap((v)=>ae(v.code)),...t.flatMap((v)=>Le(v.code))]),m=(v)=>{if(!u.has(v)&&!n.declaredGlobals?.includes(v))f(`declare var ${v}: any`)};if(n.runtimeGlobals!==!1){if(!u.has("window"))f("declare var window: any");for(let v of de)m(v)}let E=[...new Set([...zt,...ze,...Vt])].filter((v)=>!n.declaredGlobals?.includes(v)&&(n.runtimeGlobals!==!1||!de.includes(v)));if(n.contextScope==="global"){f("declare global {");for(let v of E)f(` var ${v}: any`);f("}")}else{for(let v of zt)m(v);for(let v of ze)m(v);for(let v of Vt)m(v)}f(`declare var ${et}: any`);let A=new Set(t.flatMap((v)=>ae(v.code)));f(`type ${jt}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let v of s?[]:fr(e)){if(A.has(v.name))continue;let O=v.iterable&&A.has(v.iterable)?`${jt}<typeof ${v.iterable}>`:"any";f(`declare var ${v.name}: ${O}`)}}if(n.templateExpressions!==!1){if(R?.declarations)for(let m of R.declarations.split(`
101
- `))f(m);let u=ur(e).map((m)=>{let E=R?.events.get(m.offset??-1);if(E){m.anchor=!0;let A=m.code.trim(),v=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(A),O=v?`void ((${v[2]}) satisfies __StxAssignedValue<typeof ${v[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(A)?`${A} satisfies (($event: ${E}) => unknown)`:A,M=`;(($event: ${E}): void => { `;return{expression:m,statement:{text:`${M}${O} });`,prefixLength:M.length}}}return{expression:m,statement:vr(m)}}).filter((m)=>m.statement!==null);if(u.push(...R?.checks||[],...i?.checks||[]),u.length>0){let m=ge(e),E=Lt(m),A=s?Dt(m):[];if(s)f("type __StxNativeValue<T> = T extends readonly (infer E)[] ? E : T extends object ? T[keyof T] : never; declare function __stxEach<T>(items: T, callback: (item: __StxNativeValue<T>, key: string) => void): void;");let v=yr(t.map((P)=>P.code)),M=[...new Set(t.flatMap((P)=>ae(P.code)))].filter((P)=>/^[A-Z_$][\w$]*$/i.test(P)),I=0;if(s)f("function __stxNativeTemplate(this: __StxNativeComponent) {");if(M.length>0){f(ir);for(let P of M)f(`function __StxRead_${P}() { return ${P} }`),f(`type __StxT_${P} = ${Kt}<ReturnType<typeof __StxRead_${P}>>`);f(`;((${M.map((P)=>`${P}: __StxT_${P}`).join(", ")}) => {`),I=1}for(let{expression:P,statement:B}of u){let K=" ".repeat(I),q=P.offset===void 0?[]:E.filter((F)=>P.offset>=F.start&&P.offset<F.end),G=P.offset===void 0?[]:A.filter((F)=>P.offset>=F.start&&P.offset<F.end),ee=G.map((F)=>`;__stxEach(${F.iterable}, (${F.binding}) => { `).join(""),re=" });".repeat(G.length),X=ee+q.map((F)=>`;((${F.binding.replace(/[\r\n]/g," ")}: any) => { `).join(""),le=" });".repeat(q.length)+re,L=P.offset===void 0?[]:Sr(m,P.offset),W=L.length>0?`${L.map((F)=>`if (${Jt(F,v)}) `).join("")}{ `:"",Y=L.length>0?" }":"";f(K+X+W+B.text+Y+le,{line:P.line,column:P.column,expression:P,prefixLength:B.prefixLength+K.length+X.length+W.length,guardPrefixLength:K.length+X.length+W.length})}if(I>0)f("});");if(s)f("}")}}let h=!1;if(n.reference&&c[0]!==void 0&&c[0].trim()==="")c[0]=`/// <reference path=${JSON.stringify(n.reference.replace(/\\/g,"/"))} />`,h=!0;return f("export {}"),{text:c.join(`
102
- `),lineMap:l,sourceLineCount:a.length,componentDependencies:new Map([...R?.dependencies??[],...i?.dependencies??[]]),referenced:h,scriptColumns:p,importColumns:x,componentColumns:o}}function $e(e){let n=[0];for(let r=0;r<e.length;r++)if(e.charCodeAt(r)===10)n.push(r+1);return n}function ce(e,n){let r=0,t=e.length-1;while(r<t){let s=Math.ceil((r+t)/2);if(e[s]<=n)r=s;else t=s-1}return{line:r+1,column:n-e[r]+1}}function Fe(e,n,r){let t=Math.min(Math.max(n,1),e.length)-1,s=t+1<e.length?e[t+1]-1:Number.MAX_SAFE_INTEGER;return Math.min(e[t]+Math.max(r,1)-1,s)}function Yt(e,n){if(!e.expression)return!1;return e.inGuard===!0||n===2774}function Qt(e,n,r){let t=e.lineMap.get(n);if(!t)return n<=e.sourceLineCount?{line:n,column:wr(e,n,r)}:null;let s=t.anchor||t.expression?.anchor||t.diagnosticOrigin==="component"?0:Math.max(0,r-1-(t.prefixLength??0));return{line:t.line,column:t.column+s,expression:t.expression,diagnosticOrigin:t.diagnosticOrigin,inGuard:r<=(t.guardPrefixLength??0)}}var _r=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),tn=Pe.filter((e)=>!_r.has(e)).sort(),nn=[...de].sort(),kr=[...new Set([...tn,...nn])].sort(),Cr=new Set(tn),Tr=new Set(nn),Rr=new Set(kr),en=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Ar(e,n){if(n==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function rn(e,n){let r=[];for(let t of n){if(t.offset===void 0)continue;let s=t.kind==="server"?Cr:Tr;en.lastIndex=0;for(let i of t.code.matchAll(en)){let o=i.index+i[0].indexOf("{")+1;for(let a of i[1].matchAll(/[^,]+/g)){let c=a[0];if(/^\s*type\s/.test(c))continue;let l=/^\s*([A-Za-z_$][\w$]*)/.exec(c);if(!l)continue;let p=l[1];if(!Rr.has(p)||s.has(p))continue;let x=t.offset+o+a.index+l[0].length-p.length,b=e.slice(0,x),_=b.split(`
103
- `).length;r.push({line:_,column:x-(b.lastIndexOf(`
104
- `)+1)+1,offset:x,length:p.length,name:p,kind:t.kind,message:Ar(p,t.kind)})}}}return r}var ne=Q(require("node:path"),1),Or="@stacksjs/stx-typescript-plugin";function Pr(e,n){let r=ne.default.resolve(e);for(;;){let t=ne.default.join(r,"tsconfig.json");if(n(t))return t;let s=ne.default.dirname(r);if(s===r)return;r=s}}function sn(e,n,r){let t=Pr(e,r);if(!t)return;let s=new Set,i=(o)=>{if(s.has(o))return;s.add(o);let a=n(o);if(!a)return;let c=a.compilerOptions?.plugins;if(Array.isArray(c)){let p=c.find((b)=>b?.name===Or),x=Array.isArray(p?.libs)?p.libs.filter((b)=>typeof b==="string"):[];return p?{configPath:o,libs:x.map((b)=>ne.default.resolve(ne.default.dirname(o),b))}:null}let l=typeof a.extends==="string"?[a.extends]:Array.isArray(a.extends)?a.extends:[];for(let p of[...l].reverse()){if(typeof p!=="string"||!p.startsWith("."))continue;let x=ne.default.resolve(ne.default.dirname(o),p.endsWith(".json")?p:`${p}.json`),b=i(x);if(b!==void 0)return b}return};return i(t)??void 0}var on=Symbol.for("@stacksjs/stx-typescript-plugin"),Mr=new Set([2300,2451,2403]);function _e(e){return e.endsWith(".stx")}function an(e){return _e(e)||e.endsWith(".md")}function Ir(e){if(!e)return;return Z.existsSync(H.default.join(e,"stx-module.d.ts"))&&Z.existsSync(H.default.join(e,"stx.d.ts"))?H.default.join(e,"stx-module.d.ts"):void 0}function Nr(e,n=Z.existsSync){let r=e;for(;;){let t=H.default.join(r,"node_modules","@stacksjs","stx","stx-module.d.ts");if(n(t))return t;let s=H.default.dirname(r);if(s===r)return;r=s}}function Dr(e,n=H.default.join(ln.tmpdir(),"stx-typescript-plugin")){let r=e.map((s)=>`/// <reference path=${JSON.stringify(s.replace(/\\/g,"/"))} />`).join(`
100
+ `,m.offset-1)+(A===u.startLine?(u.startColumn??1)-1:0);f(`;({})[${JSON.stringify(m.unsupported)}];`,{line:A,column:v,anchor:!0})}if(i?.declarations)f(i.declarations);for(let u of x)f(u.text,u.origin);if(s){if(f(s.declarations),n.nativeChecks!==!1)for(let u of s.checks)f(u.text,{line:u.line,column:u.column,diagnosticOrigin:u.origin,anchor:!0})}if(n.globals!==!1){f("");let u=new Set([...t.flatMap((v)=>ae(v.code)),...t.flatMap((v)=>Le(v.code))]),m=(v)=>{if(!u.has(v)&&!n.declaredGlobals?.includes(v))f(`declare var ${v}: any`)};if(n.runtimeGlobals!==!1){if(!u.has("window"))f("declare var window: any");for(let v of de)m(v)}let E=[...new Set([...zt,...ze,...Vt])].filter((v)=>!n.declaredGlobals?.includes(v)&&(n.runtimeGlobals!==!1||!de.includes(v)));if(n.contextScope==="global"){f("declare global {");for(let v of E)f(` var ${v}: any`);f("}")}else{for(let v of zt)m(v);for(let v of ze)m(v);for(let v of Vt)m(v)}f(`declare var ${et}: any`);let A=new Set(t.flatMap((v)=>ae(v.code)));f(`type ${jt}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let v of s?[]:fr(e)){if(A.has(v.name))continue;let O=v.iterable&&A.has(v.iterable)?`${jt}<typeof ${v.iterable}>`:"any";f(`declare var ${v.name}: ${O}`)}}if(n.templateExpressions!==!1){if(R?.declarations)for(let m of R.declarations.split(`
101
+ `))f(m);let u=ur(e).map((m)=>{let E=R?.events.get(m.offset??-1);if(E){m.anchor=!0;let A=m.code.trim(),v=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(A),O=v?`void ((${v[2]}) satisfies __StxAssignedValue<typeof ${v[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(A)?`${A} satisfies (($event: ${E}) => unknown)`:A,M=`;(($event: ${E}): void => { `;return{expression:m,statement:{text:`${M}${O} });`,prefixLength:M.length}}}return{expression:m,statement:vr(m)}}).filter((m)=>m.statement!==null);if(u.push(...R?.checks||[],...i?.checks||[]),u.length>0){let m=ge(e),E=Lt(m),A=s?Dt(m):[];if(s)f("type __StxNativeValue<T> = T extends readonly (infer E)[] ? E : T extends object ? T[keyof T] : never; declare function __stxEach<T>(items: T, callback: (item: __StxNativeValue<T>, key: string) => void): void;");let v=yr(t.map((P)=>P.code)),M=[...new Set(t.flatMap((P)=>ae(P.code)))].filter((P)=>/^[A-Z_$][\w$]*$/i.test(P)),I=0;if(s)f("function __stxNativeTemplate(this: __StxNativeComponent) {");if(M.length>0){f(ir);for(let P of M)f(`function __StxRead_${P}() { return ${P} }`),f(`type __StxT_${P} = ${Kt}<ReturnType<typeof __StxRead_${P}>>`);f(`;((${M.map((P)=>`${P}: __StxT_${P}`).join(", ")}) => {`),I=1}for(let{expression:P,statement:B}of u){let K=" ".repeat(I),q=P.offset===void 0?[]:E.filter((F)=>P.offset>=F.start&&P.offset<F.end),G=P.offset===void 0?[]:A.filter((F)=>P.offset>=F.start&&P.offset<F.end),ee=G.map((F)=>`;__stxEach(${F.iterable}, (${F.binding}) => { `).join(""),re=" });".repeat(G.length),X=ee+q.map((F)=>`;((${F.binding.replace(/[\r\n]/g," ")}: any) => { `).join(""),le=" });".repeat(q.length)+re,L=P.offset===void 0?[]:Sr(m,P.offset),W=L.length>0?`${L.map((F)=>`if (${Jt(F,v)}) `).join("")}{ `:"",Y=L.length>0?" }":"";f(K+X+W+B.text+Y+le,{line:P.line,column:P.column,expression:P,prefixLength:B.prefixLength+K.length+X.length+W.length,guardPrefixLength:K.length+X.length+W.length})}if(I>0)f("});");if(s)f("}")}}let b=!1;if(n.reference&&c[0]!==void 0&&c[0].trim()==="")c[0]=`/// <reference path=${JSON.stringify(n.reference.replace(/\\/g,"/"))} />`,b=!0;return f("export {}"),{text:c.join(`
102
+ `),lineMap:l,sourceLineCount:a.length,componentDependencies:new Map([...R?.dependencies??[],...i?.dependencies??[]]),referenced:b,scriptColumns:p,importColumns:h,componentColumns:o}}function $e(e){let n=[0];for(let r=0;r<e.length;r++)if(e.charCodeAt(r)===10)n.push(r+1);return n}function ce(e,n){let r=0,t=e.length-1;while(r<t){let s=Math.ceil((r+t)/2);if(e[s]<=n)r=s;else t=s-1}return{line:r+1,column:n-e[r]+1}}function Fe(e,n,r){let t=Math.min(Math.max(n,1),e.length)-1,s=t+1<e.length?e[t+1]-1:Number.MAX_SAFE_INTEGER;return Math.min(e[t]+Math.max(r,1)-1,s)}function Yt(e,n){if(!e.expression)return!1;return e.inGuard===!0||n===2774}function Qt(e,n,r){let t=e.lineMap.get(n);if(!t)return n<=e.sourceLineCount?{line:n,column:wr(e,n,r)}:null;let s=t.anchor||t.expression?.anchor||t.diagnosticOrigin==="component"?0:Math.max(0,r-1-(t.prefixLength??0));return{line:t.line,column:t.column+s,expression:t.expression,diagnosticOrigin:t.diagnosticOrigin,inGuard:r<=(t.guardPrefixLength??0)}}var _r=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),tn=Pe.filter((e)=>!_r.has(e)).sort(),nn=[...de].sort(),kr=[...new Set([...tn,...nn])].sort(),Cr=new Set(tn),Tr=new Set(nn),Rr=new Set(kr),en=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Ar(e,n){if(n==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function rn(e,n){let r=[];for(let t of n){if(t.offset===void 0)continue;let s=t.kind==="server"?Cr:Tr;en.lastIndex=0;for(let i of t.code.matchAll(en)){let o=i.index+i[0].indexOf("{")+1;for(let a of i[1].matchAll(/[^,]+/g)){let c=a[0];if(/^\s*type\s/.test(c))continue;let l=/^\s*([A-Za-z_$][\w$]*)/.exec(c);if(!l)continue;let p=l[1];if(!Rr.has(p)||s.has(p))continue;let h=t.offset+o+a.index+l[0].length-p.length,x=e.slice(0,h),_=x.split(`
103
+ `).length;r.push({line:_,column:h-(x.lastIndexOf(`
104
+ `)+1)+1,offset:h,length:p.length,name:p,kind:t.kind,message:Ar(p,t.kind)})}}}return r}var ne=Q(require("node:path"),1),Or="@stacksjs/stx-typescript-plugin";function Pr(e,n){let r=ne.default.resolve(e);for(;;){let t=ne.default.join(r,"tsconfig.json");if(n(t))return t;let s=ne.default.dirname(r);if(s===r)return;r=s}}function sn(e,n,r){let t=Pr(e,r);if(!t)return;let s=new Set,i=(o)=>{if(s.has(o))return;s.add(o);let a=n(o);if(!a)return;let c=a.compilerOptions?.plugins;if(Array.isArray(c)){let p=c.find((x)=>x?.name===Or),h=Array.isArray(p?.libs)?p.libs.filter((x)=>typeof x==="string"):[];return p?{configPath:o,libs:h.map((x)=>ne.default.resolve(ne.default.dirname(o),x))}:null}let l=typeof a.extends==="string"?[a.extends]:Array.isArray(a.extends)?a.extends:[];for(let p of[...l].reverse()){if(typeof p!=="string"||!p.startsWith("."))continue;let h=ne.default.resolve(ne.default.dirname(o),p.endsWith(".json")?p:`${p}.json`),x=i(h);if(x!==void 0)return x}return};return i(t)??void 0}var on=Symbol.for("@stacksjs/stx-typescript-plugin"),Mr=new Set([2300,2451,2403]);function _e(e){return e.endsWith(".stx")}function an(e){return _e(e)||e.endsWith(".md")}function Ir(e){if(!e)return;return Z.existsSync(H.default.join(e,"stx-module.d.ts"))&&Z.existsSync(H.default.join(e,"stx.d.ts"))?H.default.join(e,"stx-module.d.ts"):void 0}function Nr(e,n=Z.existsSync){let r=e;for(;;){let t=H.default.join(r,"node_modules","@stacksjs","stx","stx-module.d.ts");if(n(t))return t;let s=H.default.dirname(r);if(s===r)return;r=s}}function Dr(e,n=H.default.join(ln.tmpdir(),"stx-typescript-plugin")){let r=e.map((s)=>`/// <reference path=${JSON.stringify(s.replace(/\\/g,"/"))} />`).join(`
105
105
  `)+`
106
- `,t=H.default.join(n,`${cn.createHash("sha1").update(r).digest("hex").slice(0,16)}.d.ts`);if(!Z.existsSync(t))Z.mkdirSync(n,{recursive:!0}),Z.writeFileSync(t,r);return t}function Lr(e){let n=new Set,r=new Set;function t(s){if(r.has(s)||!Z.existsSync(s))return;r.add(s);let i=Z.readFileSync(s,"utf8");for(let o of Ut(i))n.add(o);for(let o of i.matchAll(/<reference\s+path=["']([^"']+)["']/g))t(H.default.resolve(H.default.dirname(s),o[1]))}if(e)t(e);return[...n]}function jr(e,n,r,t){let s=(a)=>Zt(n,{templateExpressions:_e(e),componentMethodValidator:(c,l,p)=>{let x=t.typescript.transpileModule(c+(l==="{"?"{}":";"),{reportDiagnostics:!0,compilerOptions:{target:t.typescript.ScriptTarget.ESNext}});if(x.diagnostics?.some((b)=>b.category===t.typescript.DiagnosticCategory.Error))return!1;return l==="{"?x.outputText.includes(`function ${p}(`):!x.outputText.trim()},originDir:H.default.dirname(e),filePath:e,readComponent:t.readComponent,componentsDir:t.componentsDir,projectRoot:t.projectRoot,reference:a,declaredGlobals:Lr(a),runtimeGlobals:!a,contextScope:"global"}),i=s(t.declarations);if(t.declarations&&!i.referenced)i=s(void 0);let o=me(n);return{version:r,source:n,virtual:i,blocks:o,sourceStarts:$e(n),virtualStarts:$e(i.text),collisions:new Set(Gt(o))}}function Fr(e,n){let r=e.findConfigFile(n,e.sys.fileExists);if(!r)return;let t=e.readConfigFile(r,e.sys.readFile);if(t.error)return;let s=e.parseJsonConfigFileContent(t.config,e.sys,H.default.dirname(r),void 0,r),i={};if(s.options.types)i.types=s.options.types;let o=s.options.paths;if(o){let a=s.options.baseUrl??s.options.pathsBasePath??H.default.dirname(r);i.paths={};for(let[c,l]of Object.entries(o))i.paths[c]=l.map((p)=>H.default.isAbsolute(p)?p:H.default.resolve(a,p))}return i}function Br(e,n={}){let r=e.typescript,t={},s=new Set,i=new WeakSet;return{create(o){let a=(g)=>{o.project.projectService.logger.info(`[stx-plugin] ${g}`)};if(o.languageService[on])return i.add(o.project),a("already applied to this project by another registration of the plugin; leaving it as it is"),o.languageService;a("TypeScript stx plugin initialized");let{languageService:c,languageServiceHost:l}=o,p=(g)=>{let S=c[g];return typeof S==="function"?S.bind(c):()=>{return}},x=l.getScriptSnapshot?.bind(l),b=l.getScriptVersion?.bind(l),_=Ir(n.declarationsDir);if(!_)a("the bundled stx declarations were not found; apps without their own fall back to `any`");let R=(g)=>r.sys?.fileExists(g)??Z.existsSync(g),C=(g)=>{let S=r.readConfigFile?.(g,(y)=>r.sys.readFile(y));return S&&!S.error?S.config:void 0},d=new Map,f=(g)=>{let S=H.default.dirname(g);if(!d.has(S)){let y=Nr(S,R)??_,T=[];try{T=(sn(S,C,R)?.libs??[]).filter(R)}catch(k){a(`could not read the stx entry of the project's tsconfig: ${String(k)}`)}d.set(S,y&&T.length>0?Dr([y,...T]):y)}return d.get(S)},w=new Map,h=(g)=>{let S=x?.(g);return S?S.getText(0,S.getLength()):r.sys?.readFile(g)},u=()=>t.enabled!==!1;s.add(()=>{w.clear(),o.project.refreshDiagnostics?.()});let m=(g)=>{if(!an(g)||!x)return;let S=`${b?.(g)||"0"}:${l.getProjectVersion?.()||""}`,y=w.get(g);if(y&&y.version===S&&[...y.virtual.componentDependencies||[]].every(([k,N])=>h(k)===N))return y;let T=x(g);if(!T)return;try{let k=o.project.getCurrentDirectory?.(),N=k?H.default.resolve(k,typeof o.config?.componentsDir==="string"?o.config.componentsDir:"components"):void 0,z=jr(g,T.getText(0,T.getLength()),S,{typescript:r,declarations:f(g),readComponent:h,componentsDir:N,projectRoot:k});return w.set(g,z),z}catch(k){a(`failed to build virtual document for ${g}: ${String(k)}`);return}},E=(g)=>_e(g)?m(g):void 0,A=(g,S)=>{let y=ce(g.virtualStarts,S);return Qt(g.virtual,y.line,y.column)},v=(g,S)=>{let y=A(g,S);if(!y)return;return Fe(g.sourceStarts,y.line,y.column)},O=(g,S)=>{let y=ce(g.sourceStarts,S);return Fe(g.virtualStarts,y.line,Xt(g.virtual,y.line,y.column))},M=(g,S)=>{let y=v(g,S.start);if(y===void 0)return;let T=v(g,S.start+S.length);return{start:y,length:T!==void 0&&T>=y?T-y:S.length}},I=(g,S)=>g.blocks.some((y)=>y.offset!==void 0&&S>=y.offset&&S<=y.offset+y.code.length),P=(g)=>{let S=E(g.fileName);if(!S)return g;let y=M(S,g.textSpan);if(!y)return;let T=g.contextSpan?M(S,g.contextSpan):void 0;return{...g,textSpan:y,contextSpan:T}},B=(g)=>g?.map(P).filter((S)=>S!==void 0),K=(g)=>g?.filter((S)=>{let y=E(S.fileName);if(!y)return!0;let{line:T}=ce(y.virtualStarts,S.textSpan.start);return T<=y.virtual.sourceLineCount&&!y.virtual.lineMap.has(T)});if(x)l.getScriptSnapshot=(g)=>{let S=m(g);if(S)return r.ScriptSnapshot.fromString(S.virtual.text);return x(g)};let q=l.getCompilationSettings?.bind(l),G=r.server?.ProjectKind!==void 0&&o.project.projectKind===r.server.ProjectKind.Inferred;if(q&&G){let g=null,S;l.getCompilationSettings=()=>{let y=q();if(g===null)try{g=Fr(r,o.project.getCurrentDirectory())}catch(T){a(`could not read the project's tsconfig: ${String(T)}`),g=void 0}if(!g)return y;if(S?.from!==y)S={from:y,options:{...y,...g.paths&&!y.paths?{paths:g.paths}:{},...g.types&&!y.types?{types:g.types}:{}}};return S.options}}let ee=(g,S)=>{let y=m(g);if(!y)return S;if(_e(g)&&!u())return[];let T=[];for(let k of S){let N=typeof k.messageText==="string"?k.messageText:k.messageText.messageText;if(Mr.has(k.code)){let te=N.match(/'([^']+)'/)?.[1];if(te&&y.collisions.has(te))continue}if(k.start===void 0){T.push(k);continue}let z=A(y,k.start);if(!z||Yt(z,k.code))continue;let V=Fe(y.sourceStarts,z.line,z.column),be=v(y,k.start+(k.length??0));T.push({...k,start:V,length:be!==void 0&&be>V?be-V:k.length??0})}return T},re=p("getSemanticDiagnostics");c.getSemanticDiagnostics=(g)=>{let S=ee(g,re(g)),y=E(g);if(!y||!u())return S;let T=c.getProgram?.()?.getSourceFile(g);for(let k of rn(y.source,y.blocks))S.push({file:T,start:k.offset,length:k.length,messageText:k.message,category:r.DiagnosticCategory?.Error??1,code:0,source:"stx"});return S};let X=p("getSyntacticDiagnostics");c.getSyntacticDiagnostics=(g)=>ee(g,X(g));let le=p("getSuggestionDiagnostics");c.getSuggestionDiagnostics=(g)=>ee(g,le(g));let L=p("getQuickInfoAtPosition");c.getQuickInfoAtPosition=(g,S,...y)=>{let T=E(g);if(!T)return L(g,S,...y);if(!u())return;let k=L(g,O(T,S),...y);if(!k)return k;let N=M(T,k.textSpan);return N?{...k,textSpan:N}:void 0};let W=p("getCompletionsAtPosition");c.getCompletionsAtPosition=(g,S,y,...T)=>{let k=E(g);if(!k)return W(g,S,y,...T);if(!u()||!I(k,S))return;let N=W(g,O(k,S),{...y,includeCompletionsForModuleExports:!1},...T);if(!N)return N;let z=(V)=>V&&M(k,V);return{...N,optionalReplacementSpan:z(N.optionalReplacementSpan),entries:N.entries.filter((V)=>!V.name.startsWith("__stx")&&!V.name.startsWith("__Stx")).map((V)=>V.replacementSpan?{...V,replacementSpan:z(V.replacementSpan)}:V)}};let Y=p("getCompletionEntryDetails");c.getCompletionEntryDetails=(g,S,...y)=>{let T=E(g);if(!T)return Y(g,S,...y);let k=Y(g,O(T,S),...y);return k?{...k,codeActions:void 0}:k};let F=p("getSignatureHelpItems");c.getSignatureHelpItems=(g,S,...y)=>{let T=E(g);if(!T)return F(g,S,...y);if(!u()||!I(T,S))return;let k=F(g,O(T,S),...y),N=k&&M(T,k.applicableSpan);return k&&N?{...k,applicableSpan:N}:void 0};let ke=p("getDefinitionAndBoundSpan");c.getDefinitionAndBoundSpan=(g,S)=>{let y=E(g);if(!y)return xe(ke(g,S));if(!u())return;let T=ke(g,O(y,S)),k=T&&M(y,T.textSpan);return T&&k?{...xe(T),textSpan:k}:void 0};let xe=(g)=>g&&{...g,definitions:K(g.definitions)};for(let g of["getDefinitionAtPosition","getTypeDefinitionAtPosition","getImplementationAtPosition"]){let S=p(g);c[g]=(y,T,...k)=>{let N=E(y);if(N&&!u())return;return K(S(y,N?O(N,T):T,...k))}}for(let g of["getReferencesAtPosition"]){let S=p(g);c[g]=(y,T,...k)=>{let N=E(y);if(N&&!u())return;return B(S(y,N?O(N,T):T,...k))}}let pn=p("findReferences");c.findReferences=(g,S)=>{let y=E(g);if(y&&!u())return;return pn(g,y?O(y,S):S)?.map((T)=>{let k=P(T.definition);return k?{definition:k,references:B(T.references)}:void 0}).filter((T)=>T!==void 0)};let dn=p("getDocumentHighlights");c.getDocumentHighlights=(g,S,y)=>{let T=E(g);if(T&&(!u()||!I(T,S)))return;return dn(g,T?O(T,S):S,y)?.map((k)=>{let N=E(k.fileName);if(!N)return k;return{...k,highlightSpans:k.highlightSpans.map((z)=>{let V=M(N,z.textSpan);return V?{...z,textSpan:V,contextSpan:z.contextSpan&&M(N,z.contextSpan)}:void 0}).filter((z)=>z!==void 0)}})};let fn=p("getNavigationTree");c.getNavigationTree=(g)=>{let S=fn(g),y=E(g);if(!y)return S;let T=(N)=>{let z=N.spans.map((te)=>M(y,te)).filter((te)=>te!==void 0);if(z.length===0)return;let V=N.nameSpan&&M(y,N.nameSpan),be=N.childItems?.map(T).filter((te)=>te!==void 0);return{...N,spans:z,nameSpan:V,childItems:be}},k={...S,spans:[{start:0,length:y.source.length}]};return u()?{...k,childItems:S.childItems?.map(T).filter((N)=>N!==void 0)}:{...k,childItems:[]}};let mn={getEncodedSemanticClassifications:()=>{return},getEncodedSyntacticClassifications:()=>{return},getSemanticClassifications:()=>[],getSyntacticClassifications:()=>[],getFormattingEditsForDocument:()=>[],getFormattingEditsForRange:()=>[],getFormattingEditsAfterKeystroke:()=>[],getNavigationBarItems:()=>[],getOutliningSpans:()=>[],getBraceMatchingAtPosition:()=>[],getTodoComments:()=>[],getDocCommentTemplateAtPosition:()=>{return},getJsxClosingTagAtPosition:()=>{return},getLinkedEditingRangeAtPosition:()=>{return},getSpanOfEnclosingComment:()=>{return},getCodeFixesAtPosition:()=>[],getApplicableRefactors:()=>[],getEditsForRefactor:()=>{return},getRenameInfo:()=>({canRename:!1,localizedErrorMessage:"Rename is not supported in .stx files."}),findRenameLocations:()=>{return},provideInlayHints:()=>[],prepareCallHierarchy:()=>{return},provideCallHierarchyIncomingCalls:()=>[],provideCallHierarchyOutgoingCalls:()=>[],getFileReferences:()=>[]};for(let[g,S]of Object.entries(mn)){let y=c[g];if(typeof y!=="function")continue;let T=y.bind(c);c[g]=(k,...N)=>typeof k==="string"&&_e(k)?S():T(k,...N)}return c[on]=!0,a("Language service proxy created"),c},getExternalFiles(o){if(i.has(o))return[];return o.getFileNames().filter(an)},onConfigurationChanged(o){t={...t,...o};for(let a of s)a()}}}var un=Br;module.exports=un;
106
+ `,t=H.default.join(n,`${cn.createHash("sha1").update(r).digest("hex").slice(0,16)}.d.ts`);if(!Z.existsSync(t))Z.mkdirSync(n,{recursive:!0}),Z.writeFileSync(t,r);return t}function Lr(e){let n=new Set,r=new Set;function t(s){if(r.has(s)||!Z.existsSync(s))return;r.add(s);let i=Z.readFileSync(s,"utf8");for(let o of Ut(i))n.add(o);for(let o of i.matchAll(/<reference\s+path=["']([^"']+)["']/g))t(H.default.resolve(H.default.dirname(s),o[1]))}if(e)t(e);return[...n]}function jr(e,n,r,t){let s=(a)=>Zt(n,{templateExpressions:_e(e),componentMethodValidator:(c,l,p)=>{let h=t.typescript.transpileModule(c+(l==="{"?"{}":";"),{reportDiagnostics:!0,compilerOptions:{target:t.typescript.ScriptTarget.ESNext}});if(h.diagnostics?.some((x)=>x.category===t.typescript.DiagnosticCategory.Error))return!1;return l==="{"?h.outputText.includes(`function ${p}(`):!h.outputText.trim()},originDir:H.default.dirname(e),filePath:e,readComponent:t.readComponent,componentsDir:t.componentsDir,projectRoot:t.projectRoot,reference:a,declaredGlobals:Lr(a),runtimeGlobals:!a,contextScope:"global"}),i=s(t.declarations);if(t.declarations&&!i.referenced)i=s(void 0);let o=me(n);return{version:r,source:n,virtual:i,blocks:o,sourceStarts:$e(n),virtualStarts:$e(i.text),collisions:new Set(Gt(o))}}function Fr(e,n){let r=e.findConfigFile(n,e.sys.fileExists);if(!r)return;let t=e.readConfigFile(r,e.sys.readFile);if(t.error)return;let s=e.parseJsonConfigFileContent(t.config,e.sys,H.default.dirname(r),void 0,r),i={};if(s.options.types)i.types=s.options.types;let o=s.options.paths;if(o){let a=s.options.baseUrl??s.options.pathsBasePath??H.default.dirname(r);i.paths={};for(let[c,l]of Object.entries(o))i.paths[c]=l.map((p)=>H.default.isAbsolute(p)?p:H.default.resolve(a,p))}return i}function Br(e,n={}){let r=e.typescript,t={},s=new Set,i=new WeakSet;return{create(o){let a=(g)=>{o.project.projectService.logger.info(`[stx-plugin] ${g}`)};if(o.languageService[on])return i.add(o.project),a("already applied to this project by another registration of the plugin; leaving it as it is"),o.languageService;a("TypeScript stx plugin initialized");let{languageService:c,languageServiceHost:l}=o,p=(g)=>{let S=c[g];return typeof S==="function"?S.bind(c):()=>{return}},h=l.getScriptSnapshot?.bind(l),x=l.getScriptVersion?.bind(l),_=Ir(n.declarationsDir);if(!_)a("the bundled stx declarations were not found; apps without their own fall back to `any`");let R=(g)=>r.sys?.fileExists(g)??Z.existsSync(g),C=(g)=>{let S=r.readConfigFile?.(g,(y)=>r.sys.readFile(y));return S&&!S.error?S.config:void 0},d=new Map,f=(g)=>{let S=H.default.dirname(g);if(!d.has(S)){let y=Nr(S,R)??_,T=[];try{T=(sn(S,C,R)?.libs??[]).filter(R)}catch(k){a(`could not read the stx entry of the project's tsconfig: ${String(k)}`)}d.set(S,y&&T.length>0?Dr([y,...T]):y)}return d.get(S)},w=new Map,b=(g)=>{let S=h?.(g);return S?S.getText(0,S.getLength()):r.sys?.readFile(g)},u=()=>t.enabled!==!1;s.add(()=>{w.clear(),o.project.refreshDiagnostics?.()});let m=(g)=>{if(!an(g)||!h)return;let S=`${x?.(g)||"0"}:${l.getProjectVersion?.()||""}`,y=w.get(g);if(y&&y.version===S&&[...y.virtual.componentDependencies||[]].every(([k,N])=>b(k)===N))return y;let T=h(g);if(!T)return;try{let k=o.project.getCurrentDirectory?.(),N=k?H.default.resolve(k,typeof o.config?.componentsDir==="string"?o.config.componentsDir:"components"):void 0,z=jr(g,T.getText(0,T.getLength()),S,{typescript:r,declarations:f(g),readComponent:b,componentsDir:N,projectRoot:k});return w.set(g,z),z}catch(k){a(`failed to build virtual document for ${g}: ${String(k)}`);return}},E=(g)=>_e(g)?m(g):void 0,A=(g,S)=>{let y=ce(g.virtualStarts,S);return Qt(g.virtual,y.line,y.column)},v=(g,S)=>{let y=A(g,S);if(!y)return;return Fe(g.sourceStarts,y.line,y.column)},O=(g,S)=>{let y=ce(g.sourceStarts,S);return Fe(g.virtualStarts,y.line,Xt(g.virtual,y.line,y.column))},M=(g,S)=>{let y=v(g,S.start);if(y===void 0)return;let T=v(g,S.start+S.length);return{start:y,length:T!==void 0&&T>=y?T-y:S.length}},I=(g,S)=>g.blocks.some((y)=>y.offset!==void 0&&S>=y.offset&&S<=y.offset+y.code.length),P=(g)=>{let S=E(g.fileName);if(!S)return g;let y=M(S,g.textSpan);if(!y)return;let T=g.contextSpan?M(S,g.contextSpan):void 0;return{...g,textSpan:y,contextSpan:T}},B=(g)=>g?.map(P).filter((S)=>S!==void 0),K=(g)=>g?.filter((S)=>{let y=E(S.fileName);if(!y)return!0;let{line:T}=ce(y.virtualStarts,S.textSpan.start);return T<=y.virtual.sourceLineCount&&!y.virtual.lineMap.has(T)});if(h)l.getScriptSnapshot=(g)=>{let S=m(g);if(S)return r.ScriptSnapshot.fromString(S.virtual.text);return h(g)};let q=l.getCompilationSettings?.bind(l),G=r.server?.ProjectKind!==void 0&&o.project.projectKind===r.server.ProjectKind.Inferred;if(q&&G){let g=null,S;l.getCompilationSettings=()=>{let y=q();if(g===null)try{g=Fr(r,o.project.getCurrentDirectory())}catch(T){a(`could not read the project's tsconfig: ${String(T)}`),g=void 0}if(!g)return y;if(S?.from!==y)S={from:y,options:{...y,...g.paths&&!y.paths?{paths:g.paths}:{},...g.types&&!y.types?{types:g.types}:{}}};return S.options}}let ee=(g,S)=>{let y=m(g);if(!y)return S;if(_e(g)&&!u())return[];let T=[];for(let k of S){let N=typeof k.messageText==="string"?k.messageText:k.messageText.messageText;if(Mr.has(k.code)){let te=N.match(/'([^']+)'/)?.[1];if(te&&y.collisions.has(te))continue}if(k.start===void 0){T.push(k);continue}let z=A(y,k.start);if(!z||Yt(z,k.code))continue;let V=Fe(y.sourceStarts,z.line,z.column),be=v(y,k.start+(k.length??0));T.push({...k,start:V,length:be!==void 0&&be>V?be-V:k.length??0})}return T},re=p("getSemanticDiagnostics");c.getSemanticDiagnostics=(g)=>{let S=ee(g,re(g)),y=E(g);if(!y||!u())return S;let T=c.getProgram?.()?.getSourceFile(g);for(let k of rn(y.source,y.blocks))S.push({file:T,start:k.offset,length:k.length,messageText:k.message,category:r.DiagnosticCategory?.Error??1,code:0,source:"stx"});return S};let X=p("getSyntacticDiagnostics");c.getSyntacticDiagnostics=(g)=>ee(g,X(g));let le=p("getSuggestionDiagnostics");c.getSuggestionDiagnostics=(g)=>ee(g,le(g));let L=p("getQuickInfoAtPosition");c.getQuickInfoAtPosition=(g,S,...y)=>{let T=E(g);if(!T)return L(g,S,...y);if(!u())return;let k=L(g,O(T,S),...y);if(!k)return k;let N=M(T,k.textSpan);return N?{...k,textSpan:N}:void 0};let W=p("getCompletionsAtPosition");c.getCompletionsAtPosition=(g,S,y,...T)=>{let k=E(g);if(!k)return W(g,S,y,...T);if(!u()||!I(k,S))return;let N=W(g,O(k,S),{...y,includeCompletionsForModuleExports:!1},...T);if(!N)return N;let z=(V)=>V&&M(k,V);return{...N,optionalReplacementSpan:z(N.optionalReplacementSpan),entries:N.entries.filter((V)=>!V.name.startsWith("__stx")&&!V.name.startsWith("__Stx")).map((V)=>V.replacementSpan?{...V,replacementSpan:z(V.replacementSpan)}:V)}};let Y=p("getCompletionEntryDetails");c.getCompletionEntryDetails=(g,S,...y)=>{let T=E(g);if(!T)return Y(g,S,...y);let k=Y(g,O(T,S),...y);return k?{...k,codeActions:void 0}:k};let F=p("getSignatureHelpItems");c.getSignatureHelpItems=(g,S,...y)=>{let T=E(g);if(!T)return F(g,S,...y);if(!u()||!I(T,S))return;let k=F(g,O(T,S),...y),N=k&&M(T,k.applicableSpan);return k&&N?{...k,applicableSpan:N}:void 0};let ke=p("getDefinitionAndBoundSpan");c.getDefinitionAndBoundSpan=(g,S)=>{let y=E(g);if(!y)return xe(ke(g,S));if(!u())return;let T=ke(g,O(y,S)),k=T&&M(y,T.textSpan);return T&&k?{...xe(T),textSpan:k}:void 0};let xe=(g)=>g&&{...g,definitions:K(g.definitions)};for(let g of["getDefinitionAtPosition","getTypeDefinitionAtPosition","getImplementationAtPosition"]){let S=p(g);c[g]=(y,T,...k)=>{let N=E(y);if(N&&!u())return;return K(S(y,N?O(N,T):T,...k))}}for(let g of["getReferencesAtPosition"]){let S=p(g);c[g]=(y,T,...k)=>{let N=E(y);if(N&&!u())return;return B(S(y,N?O(N,T):T,...k))}}let pn=p("findReferences");c.findReferences=(g,S)=>{let y=E(g);if(y&&!u())return;return pn(g,y?O(y,S):S)?.map((T)=>{let k=P(T.definition);return k?{definition:k,references:B(T.references)}:void 0}).filter((T)=>T!==void 0)};let dn=p("getDocumentHighlights");c.getDocumentHighlights=(g,S,y)=>{let T=E(g);if(T&&(!u()||!I(T,S)))return;return dn(g,T?O(T,S):S,y)?.map((k)=>{let N=E(k.fileName);if(!N)return k;return{...k,highlightSpans:k.highlightSpans.map((z)=>{let V=M(N,z.textSpan);return V?{...z,textSpan:V,contextSpan:z.contextSpan&&M(N,z.contextSpan)}:void 0}).filter((z)=>z!==void 0)}})};let fn=p("getNavigationTree");c.getNavigationTree=(g)=>{let S=fn(g),y=E(g);if(!y)return S;let T=(N)=>{let z=N.spans.map((te)=>M(y,te)).filter((te)=>te!==void 0);if(z.length===0)return;let V=N.nameSpan&&M(y,N.nameSpan),be=N.childItems?.map(T).filter((te)=>te!==void 0);return{...N,spans:z,nameSpan:V,childItems:be}},k={...S,spans:[{start:0,length:y.source.length}]};return u()?{...k,childItems:S.childItems?.map(T).filter((N)=>N!==void 0)}:{...k,childItems:[]}};let mn={getEncodedSemanticClassifications:()=>{return},getEncodedSyntacticClassifications:()=>{return},getSemanticClassifications:()=>[],getSyntacticClassifications:()=>[],getFormattingEditsForDocument:()=>[],getFormattingEditsForRange:()=>[],getFormattingEditsAfterKeystroke:()=>[],getNavigationBarItems:()=>[],getOutliningSpans:()=>[],getBraceMatchingAtPosition:()=>[],getTodoComments:()=>[],getDocCommentTemplateAtPosition:()=>{return},getJsxClosingTagAtPosition:()=>{return},getLinkedEditingRangeAtPosition:()=>{return},getSpanOfEnclosingComment:()=>{return},getCodeFixesAtPosition:()=>[],getApplicableRefactors:()=>[],getEditsForRefactor:()=>{return},getRenameInfo:()=>({canRename:!1,localizedErrorMessage:"Rename is not supported in .stx files."}),findRenameLocations:()=>{return},provideInlayHints:()=>[],prepareCallHierarchy:()=>{return},provideCallHierarchyIncomingCalls:()=>[],provideCallHierarchyOutgoingCalls:()=>[],getFileReferences:()=>[]};for(let[g,S]of Object.entries(mn)){let y=c[g];if(typeof y!=="function")continue;let T=y.bind(c);c[g]=(k,...N)=>typeof k==="string"&&_e(k)?S():T(k,...N)}return c[on]=!0,a("Language service proxy created"),c},getExternalFiles(o){if(i.has(o))return[];return o.getFileNames().filter(an)},onConfigurationChanged(o){t={...t,...o};for(let a of s)a()}}}var un=Br;module.exports=un;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx-vscode",
3
3
  "type": "module",
4
- "version": "0.2.904",
4
+ "version": "0.2.907",
5
5
  "description": "stx language support for VS Code extensions to embed: the hovers, completions, diagnostics, grammar, snippets, language configuration and TypeScript server plugin behind the stx extension.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",