@stacksjs/stx 0.2.889 → 0.2.890
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.
- package/dist/{chunk-1n33yrar.js → chunk-062qfv99.js} +2 -2
- package/dist/{chunk-2a5g80mq.js → chunk-0jdz31q1.js} +3 -3
- package/dist/{chunk-mhxg6j6s.js → chunk-0jkj8thz.js} +1 -1
- package/dist/chunk-0q0nbq50.js +2 -0
- package/dist/{chunk-kj43fbzm.js → chunk-0wp23n1d.js} +1 -1
- package/dist/{chunk-cz1sdes5.js → chunk-115bb91s.js} +2 -2
- package/dist/{chunk-w82nk19t.js → chunk-12cjs6vs.js} +1 -1
- package/dist/chunk-1a7a8cjs.js +2 -0
- package/dist/{chunk-700m927w.js → chunk-1bft48gk.js} +2 -2
- package/dist/{chunk-6pz5gq6v.js → chunk-1jtsr42q.js} +20 -20
- package/dist/chunk-1ph2yhfn.js +3 -0
- package/dist/{chunk-f3cyghnb.js → chunk-1t15z230.js} +4 -4
- package/dist/{chunk-7212fwzz.js → chunk-1w0bqqh5.js} +2 -2
- package/dist/{chunk-s0mf56y1.js → chunk-2xnbdqy4.js} +4 -4
- package/dist/{chunk-2gn2nc2j.js → chunk-35j7gaj5.js} +1 -1
- package/dist/chunk-3b3mkgpj.js +3 -0
- package/dist/{chunk-snv80b1b.js → chunk-3bsz7zj3.js} +2 -2
- package/dist/chunk-3yvmaphj.js +2 -0
- package/dist/{chunk-njpva3zq.js → chunk-40k0r6z9.js} +1 -1
- package/dist/{chunk-eyx92t9n.js → chunk-41z7f41b.js} +2 -2
- package/dist/chunk-44teqn0b.js +2 -0
- package/dist/{chunk-b15c4g3e.js → chunk-49xwf7dk.js} +6 -6
- package/dist/chunk-4d85str1.js +2 -0
- package/dist/{chunk-7hpca9c7.js → chunk-4eescf3s.js} +4 -4
- package/dist/chunk-4xbtxeak.js +2 -0
- package/dist/{chunk-0ncafcs2.js → chunk-67j2m620.js} +3 -3
- package/dist/{chunk-5ssv10ep.js → chunk-690518hw.js} +1 -1
- package/dist/chunk-6s3jwysv.js +2 -0
- package/dist/{chunk-mt8edb75.js → chunk-6svc4kb8.js} +57 -57
- package/dist/{chunk-5kqezrjt.js → chunk-80ky40mm.js} +1 -1
- package/dist/chunk-850tye3c.js +2 -0
- package/dist/{chunk-eceeqy74.js → chunk-8ccgty8s.js} +2 -2
- package/dist/{chunk-1gyxxfdf.js → chunk-8f8qgjjr.js} +1 -1
- package/dist/{chunk-87g5xmmr.js → chunk-9344rq4r.js} +14 -14
- package/dist/chunk-94j4p584.js +2 -0
- package/dist/{chunk-446tb2th.js → chunk-97snfzsy.js} +49 -49
- package/dist/chunk-9a9cec4x.js +2 -0
- package/dist/{chunk-pctf14yw.js → chunk-9rjgq8k4.js} +1 -1
- package/dist/{chunk-q9tc9rdv.js → chunk-a0aqs5a8.js} +2 -2
- package/dist/{chunk-cgfjrgfw.js → chunk-a3zrwky3.js} +11 -11
- package/dist/{chunk-6gtecbe7.js → chunk-a7bqrjm5.js} +2 -2
- package/dist/{chunk-vc432a0w.js → chunk-adsqckg4.js} +9 -9
- package/dist/{chunk-51720m79.js → chunk-aj5tsksz.js} +9 -9
- package/dist/chunk-amb7e0fp.js +2 -0
- package/dist/chunk-arr79m90.js +2 -0
- package/dist/{chunk-9d91h636.js → chunk-b0hj8eg2.js} +2 -2
- package/dist/chunk-bm0mzk3b.js +2 -0
- package/dist/{chunk-ymqm898x.js → chunk-bvqgq18r.js} +2 -2
- package/dist/{chunk-m95sygv4.js → chunk-c25q87ys.js} +1 -1
- package/dist/{chunk-mgh5rst1.js → chunk-cphc60zw.js} +2 -2
- package/dist/{chunk-ranjkpc8.js → chunk-e16ef18k.js} +1 -1
- package/dist/chunk-e28czxw3.js +2 -0
- package/dist/{chunk-g6ap4085.js → chunk-e8szp5wa.js} +1 -1
- package/dist/chunk-eq86wzhr.js +1314 -0
- package/dist/chunk-essd43ad.js +2 -0
- package/dist/chunk-fsk3rk2x.js +2 -0
- package/dist/{chunk-s93yh7ed.js → chunk-g3vce7ka.js} +2 -2
- package/dist/{chunk-zwwhpxp7.js → chunk-g5nfqzfh.js} +2 -2
- package/dist/chunk-gfea8a9y.js +2 -0
- package/dist/chunk-hda7t8g6.js +2 -0
- package/dist/{chunk-dymck524.js → chunk-hyyh7qxw.js} +5 -5
- package/dist/chunk-j6fs31va.js +2 -0
- package/dist/chunk-j9kejcrx.js +2 -0
- package/dist/chunk-j9vfv53x.js +20 -0
- package/dist/chunk-jhbz5w30.js +2 -0
- package/dist/chunk-jvnsz2x9.js +2 -0
- package/dist/{chunk-bwx6w87c.js → chunk-k8bk685s.js} +1 -1
- package/dist/chunk-kexqmwx8.js +2 -0
- package/dist/{chunk-bqtj62ys.js → chunk-kg7vby72.js} +7 -7
- package/dist/{chunk-mjp1z9kz.js → chunk-khm56bfm.js} +1 -1
- package/dist/chunk-kpjq135z.js +2 -0
- package/dist/chunk-kqsm7gf1.js +2 -0
- package/dist/{chunk-mctzpw0w.js → chunk-kr2400c3.js} +4 -4
- package/dist/{chunk-b6bf0t02.js → chunk-mhrnjaka.js} +4 -4
- package/dist/chunk-mtfymhy1.js +2 -0
- package/dist/{chunk-eqffvse2.js → chunk-n6q1d66k.js} +1 -1
- package/dist/{chunk-3hsv6ejp.js → chunk-neg6ckjg.js} +7 -7
- package/dist/{chunk-hm9d40yf.js → chunk-nhv81gp2.js} +2 -2
- package/dist/{chunk-kbbbpae2.js → chunk-nq60tjkz.js} +2 -2
- package/dist/{chunk-kx09v9ya.js → chunk-nzpb263k.js} +9 -9
- package/dist/{chunk-6kyqejnq.js → chunk-p0bjbtdx.js} +20 -20
- package/dist/{chunk-967ydrq4.js → chunk-p3hbsrk9.js} +2 -2
- package/dist/chunk-p82fzxdg.js +2 -0
- package/dist/{chunk-pz554g43.js → chunk-pvm48tse.js} +3 -3
- package/dist/{chunk-zek9t5za.js → chunk-pwpge9bj.js} +2 -2
- package/dist/{chunk-58qzyyyv.js → chunk-qnf7w4xw.js} +1 -1
- package/dist/chunk-qsv84cwm.js +2 -0
- package/dist/chunk-r7m60q1m.js +2 -0
- package/dist/chunk-r98pye4h.js +2 -0
- package/dist/{chunk-6pdy7ajr.js → chunk-rd663v1m.js} +1 -1
- package/dist/{chunk-55tc5w32.js → chunk-sh7a0g09.js} +2 -2
- package/dist/chunk-sztr4d5g.js +2 -0
- package/dist/{chunk-95sd8h5g.js → chunk-t3zmfh8w.js} +3 -3
- package/dist/chunk-t4gcsbna.js +2 -0
- package/dist/chunk-tspqdt8e.js +2 -0
- package/dist/{chunk-sjjw6y49.js → chunk-v1mwwben.js} +4 -4
- package/dist/chunk-v6gkjg5f.js +3 -0
- package/dist/{chunk-48rwqchc.js → chunk-v90nz5xm.js} +9 -9
- package/dist/chunk-vfcbz0an.js +3 -0
- package/dist/{chunk-hgf7bc50.js → chunk-vkfw9k1n.js} +6 -6
- package/dist/{chunk-4kmg6g5n.js → chunk-vxbvrbqs.js} +9 -9
- package/dist/chunk-wedwczed.js +2 -0
- package/dist/chunk-wg6fmren.js +4 -0
- package/dist/{chunk-mw7hacm3.js → chunk-whcrca58.js} +21 -21
- package/dist/chunk-wmvvrsn0.js +2 -0
- package/dist/chunk-wnrh62by.js +2 -0
- package/dist/{chunk-nkyff7v6.js → chunk-wy6vjz1e.js} +17 -17
- package/dist/{chunk-brzjass3.js → chunk-xc5esqcb.js} +2 -2
- package/dist/{chunk-nbdscgvj.js → chunk-xeyq6d0t.js} +6 -6
- package/dist/{chunk-3dqfjpz4.js → chunk-xmg6bmh6.js} +29 -29
- package/dist/chunk-xwrjre34.js +2 -0
- package/dist/{chunk-p8shtje2.js → chunk-yesh4dfe.js} +45 -45
- package/dist/chunk-ymc1wgb3.js +2 -0
- package/dist/{chunk-6c1vm6bs.js → chunk-zkwkhesc.js} +2 -2
- package/dist/{chunk-me4yq8c2.js → chunk-zpqjsnz9.js} +2 -2
- package/dist/{chunk-hpzje67q.js → chunk-zwqkbk2m.js} +2 -2
- package/dist/chunk-zxjdfgdx.js +3 -0
- package/dist/cli.js +28 -28
- package/dist/component-contract.d.ts +1 -0
- package/dist/component-contract.js +6 -4
- package/dist/component-library.js +207 -58
- package/dist/composition-api.d.ts +7 -1
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/emits-declaration.d.ts +9 -0
- package/dist/emits-declaration.js +64 -0
- package/dist/props-declaration.d.ts +2 -0
- package/dist/props-declaration.js +25 -0
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +28 -28
- package/package.json +5 -5
- package/dist/chunk-0g9cceht.js +0 -2
- package/dist/chunk-0rpj5t80.js +0 -2
- package/dist/chunk-2ba4zfa0.js +0 -2
- package/dist/chunk-2wkpksg1.js +0 -2
- package/dist/chunk-3yjyjq0m.js +0 -2
- package/dist/chunk-444haxxa.js +0 -2
- package/dist/chunk-4rvfeee5.js +0 -2
- package/dist/chunk-5aa83bpm.js +0 -2
- package/dist/chunk-67rppc5v.js +0 -2
- package/dist/chunk-77c89d23.js +0 -2
- package/dist/chunk-79vbkez0.js +0 -2
- package/dist/chunk-8354mzpd.js +0 -2
- package/dist/chunk-8ygf6jnt.js +0 -2
- package/dist/chunk-94mpe1ny.js +0 -3
- package/dist/chunk-9n5h4sqc.js +0 -3
- package/dist/chunk-9ztn7w4y.js +0 -2
- package/dist/chunk-ankap9pc.js +0 -2
- package/dist/chunk-asnd03sr.js +0 -2
- package/dist/chunk-b0b5yr97.js +0 -2
- package/dist/chunk-b0e7dgv8.js +0 -3
- package/dist/chunk-b7jj45bz.js +0 -2
- package/dist/chunk-dzqfv801.js +0 -3
- package/dist/chunk-ery4tty7.js +0 -20
- package/dist/chunk-evwrxsxd.js +0 -3
- package/dist/chunk-fdqdz018.js +0 -2
- package/dist/chunk-gz9pknbw.js +0 -1204
- package/dist/chunk-hjb4c8g2.js +0 -2
- package/dist/chunk-jhbj9ja2.js +0 -2
- package/dist/chunk-k9abxnpa.js +0 -2
- package/dist/chunk-mvavjydq.js +0 -2
- package/dist/chunk-qqng9545.js +0 -2
- package/dist/chunk-rjm515e2.js +0 -2
- package/dist/chunk-rye4b2x3.js +0 -2
- package/dist/chunk-ryj8139z.js +0 -2
- package/dist/chunk-s9b809n2.js +0 -2
- package/dist/chunk-sb67wg5x.js +0 -2
- package/dist/chunk-sqwx2g02.js +0 -2
- package/dist/chunk-tpyekw0q.js +0 -2
- package/dist/chunk-v2627s75.js +0 -2
- package/dist/chunk-v98n53nk.js +0 -2
- package/dist/chunk-w34vvhm7.js +0 -2
- package/dist/chunk-wbmx0rge.js +0 -2
- package/dist/chunk-yjwa7ktk.js +0 -2
- package/dist/chunk-z47p2gx8.js +0 -2
- package/dist/chunk-z6kw6sct.js +0 -4
- package/dist/chunk-zhywjwdr.js +0 -2
package/dist/chunk-gz9pknbw.js
DELETED
|
@@ -1,1204 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Ye,On,uo,Ki,z}from"./chunk-eyx92t9n.js";import{In}from"./chunk-s93yh7ed.js";import{Jr,_,Bl,wt,ta,Fl}from"./chunk-mgh5rst1.js";import{D}from"./chunk-vk2jy6mn.js";import{T,R}from"./chunk-2a5g80mq.js";import{Gr,bo,Xr,Dl,De}from"./chunk-9n5h4sqc.js";import{po,d,m,Fr,p,ee,K,Mn,k,Dn,ho,Me,Qe,yo}from"./chunk-3dqfjpz4.js";import{b}from"./chunk-94mpe1ny.js";import{te}from"./chunk-q9tc9rdv.js";import{t,E}from"./chunk-3hsv6ejp.js";import{c}from"./chunk-hxws025y.js";import St from"path";import cn from"process";import{AsyncLocalStorage as Ya}from"async_hooks";var Qr=new Ya;function Tn(e){return e.__stx_server_data??={pending:new Map,values:new Map}}function ei(e,n){return Qr.run(Tn(e),n)}async function ti(e,n){let r=Qr.getStore();if(!r)throw Error("useServerData must run inside a <script server> render");if(typeof e!=="string"||!e.trim())throw TypeError("useServerData requires a non-empty string key");let i=r.pending.get(e);if(i)return i;let a=Promise.resolve().then(n).then((l)=>{let u=JSON.stringify(l,(x,v)=>{if(v===void 0||typeof v==="function"||typeof v==="symbol"||typeof v==="bigint"||typeof v==="number"&&!Number.isFinite(v))throw TypeError(`useServerData(${JSON.stringify(e)}) requires JSON-serializable data`);if(v&&typeof v==="object"&&!Array.isArray(v)&&Object.getPrototypeOf(v)!==Object.prototype&&Object.getPrototypeOf(v)!==null)throw TypeError(`useServerData(${JSON.stringify(e)}) requires JSON-serializable data`);return v}),f=JSON.parse(u);return r.values.set(e,f),f}).catch((l)=>{throw r.pending.delete(e),l});return r.pending.set(e,a),a}function jr(e){let n=e.__stx_server_data;if(!n?.values.size)return"";return`<script data-stx-scoped data-stx-server-data type="application/json">${JSON.stringify(Object.fromEntries(n.values)).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}</script>`}function X(e,n=!1){let r=t(e),i=[],a=new Set,l=0,u=0,f=r.length,x=()=>{if(l!==0)return;let v=r.slice(u).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*(?:[!:;,\n]|=(?!=)|$)/);if(v){if(n&&v[1]==="const")return;let L=v[2];if(!a.has(L))i.push(L),a.add(L);return}let I=r.slice(u).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(I){if(n&&r.slice(u).startsWith("const"))return;I[1].split(",").forEach((L)=>{let V=L.trim();if(!V)return;let U=V.indexOf(":"),Z=(U>=0?V.slice(U+1).trim():V).split(/[\s=]/)[0];if(Z&&!a.has(Z))i.push(Z),a.add(Z)});return}let j=r.slice(u).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(j){if(n&&r.slice(u).startsWith("const"))return;j[1].split(",").forEach((L)=>{let V=L.trim().replace(/^\.\.\./,"");if(!V)return;let U=V.split(/[\s=]/)[0];if(U&&!a.has(U))i.push(U),a.add(U)});return}if(n)return;let W=r.slice(u).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(W){let L=W[1];if(!a.has(L))i.push(L),a.add(L);return}let M=r.slice(u).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(M){let L=M[1];if(!a.has(L))i.push(L),a.add(L)}};while(u<f){if(r[u]==="{"){l++,u++;continue}if(r[u]==="}"){l--,u++;continue}if(l===0&&/[a-z]/i.test(r[u])&&(u===0||/\s|[;{}()]/.test(r[u-1])))x();u++}return i.join(", ")}function Gs(e){return`{ enumerable: true, configurable: true, get() { return ${e} }, set(__stxValue_${e}) { ${e} = __stxValue_${e} } }`}function Qa(e,n=X(e).split(",").map((r)=>r.trim()).filter(Boolean)){let r=new Set(X(e,!0).split(",").map((i)=>i.trim()));return n.map((i)=>r.has(i)?`get ${i}() { return ${i} }, set ${i}(__stxValue_${i}) { ${i} = __stxValue_${i} }`:i).join(", ")}function Xs(e,n){let r=`{ ${Qa(e,n)} }`;return X(e).split(",").some((i)=>i.trim()==="__stxLiveBindings")?`Object.defineProperties(${r}, Object.getOwnPropertyDescriptors(__stxLiveBindings))`:r}import Qt from"fs";import ze from"path";function J(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var ni=new Map;function Pr(e,n=!0){let r=ni.get(e);if(n&&r)return r;let i=new Map,a=[ze.join(e,"src"),ze.join(e,"dist"),e];function l(u,f){if(f>6)return;let x;try{x=Qt.readdirSync(u,{withFileTypes:!0})}catch{return}for(let v of x){let I=ze.join(u,v.name);if(v.isDirectory()){if(v.name==="node_modules"||v.name.startsWith("."))continue;l(I,f+1)}else if(v.isFile()&&v.name.endsWith(".stx")){let j=v.name.slice(0,-4);if(!i.has(j))i.set(j,I);let W=j.toLowerCase();if(!i.has(W))i.set(W,I);let M=J(j);if(!i.has(M))i.set(M,I)}}}for(let u of a)if(l(u,0),i.size>0)break;if(n)ni.set(e,i);return i}function Js(e,n){if(e.startsWith(".")||e.startsWith("/"))return null;let r=n;while(!0){let i=ze.join(r,"node_modules",e);try{if(Qt.statSync(i).isDirectory())return i}catch{}let a=ze.dirname(r);if(a===r)return null;r=a}}function Ys(e,n,r={}){return[ze.resolve(ze.dirname(n),`${e}.stx`),ze.resolve(ze.dirname(n),e),ze.resolve(r.componentsDir||"components",`${e}.stx`),ze.resolve(r.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function si(e){let n=e.endsWith(".stx")?e.slice(0,-4):e,r=n.split("-").map((a)=>a.charAt(0).toUpperCase()+a.slice(1)).join(""),i=J(n);return[n,r,i]}function Ti(e,n){let[r,i,a]=si(e);for(let l of[r,r.toLowerCase(),i,a]){let u=n?.__importedComponents?.get(l);if(u!==void 0)return u}}function $i(e,n){let r=n?ze.resolve(n):void 0,i=ze.dirname(ze.resolve(e));for(;;){if(Qt.existsSync(ze.join(i,"package.json")))return r&&i===r?void 0:i;let a=ze.dirname(i);if(a===i)return;i=a}}var ec=["src/ui","src/components","components","dist"];function ts(e,n){let r=ze.resolve(e);if(!n&&!r.split(ze.sep).includes("node_modules"))return[];let i=$i(r,n);if(!i)return[];let a=[];try{let f=JSON.parse(Qt.readFileSync(ze.join(i,"package.json"),"utf8")).stx?.components;if(Array.isArray(f))a=f.filter((x)=>typeof x==="string")}catch{}let l=a.length?a:ec;return[ze.dirname(ze.resolve(e)),...l.map((u)=>ze.resolve(i,u))]}function*Ri(e,n,r={},i){let a=si(e);if(a[0].startsWith("./")||a[0].startsWith("../")){yield ze.resolve(ze.dirname(n),`${a[0]}.stx`);return}let l=[...new Set(a.map((x)=>`${x}.stx`))],u=r.projectRoot||process.cwd(),f=[...ts(n,r.projectRoot),...i?.__originalFilePath?[ze.join(ze.dirname(i.__originalFilePath),"components")]:[],...r.componentsDir?[r.componentsDir]:[],ze.join(ze.dirname(n),"components"),ze.resolve(u,"src/components"),ze.resolve(u,"components"),...import.meta.dir?[ze.resolve(import.meta.dir,"components")]:[]];for(let x of new Set(f)){for(let v of l)yield ze.join(x,v);try{for(let v of Qt.readdirSync(x,{withFileTypes:!0}))if(v.isDirectory())for(let I of l)yield ze.join(x,v.name,I)}catch{}}}function ri(e,n,r={},i){let a=Ti(e,i);if(a!==void 0)return a;for(let l of Ri(e,n,r,i))try{if(Qt.statSync(l,{throwIfNoEntry:!1})?.isFile())return l}catch{}return null}function Zs(e,n=[],r={}){let i=new Set([...e].map((v)=>v.replace(/[-_]/g,"").toLowerCase()));if(!i.has("src")&&!i.has("source")||!i.has("alt")&&!i.has("decorative"))return!1;let a=new Map(Object.entries(r).map(([v,I])=>[v.replace(/[-_]/g,"").toLowerCase(),I])),l=a.get("alt"),u=a.get("decorative"),f=typeof l==="string"&&!!l.trim(),x=typeof u==="string"?!["false","0","off","no"].includes(u.trim().toLowerCase()):Boolean(u);if(!f&&!x)return!1;if(["defaultsource","provider","format","densities","quality","preload","modifiers","preset"].some((v)=>i.has(v)))return!1;if([...n].some((v)=>!["load","error"].includes(v.replace(/^@/,"").split(".")[0].toLowerCase())))return!1;if(i.has("resizemode")&&(i.has("fit")||i.has("objectfit")))return!1;if(i.has("src")&&i.has("source"))return!1;return["fit","objectfit","resizemode","position","objectposition","rounded","aspectratio","zoomonhover","sources","webpsrc","webpsrcset"].some((v)=>i.has(v))}import ks from"fs";import ge from"path";import Nt from"path";import bn from"fs";var tc=new Set(["touchstart","touchmove","wheel","mousewheel"]);function zs(e,n){if(n.passive)return!0;if(n.prevent||n.nonpassive)return!1;return tc.has(e.toLowerCase())}var ii=new Set(["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","wheel","keydown","keyup","keypress","submit","reset","change","input","focus","blur","focusin","focusout","select","invalid","touchstart","touchend","touchmove","touchcancel","drag","dragstart","dragend","dragenter","dragleave","dragover","drop","scroll","resize","load","error","abort","animationstart","animationend","animationiteration","transitionstart","transitionend","transitionrun","transitioncancel","mounted","unmounted"]),oi={enter:"Enter",tab:"Tab",delete:"Delete",backspace:"Backspace",esc:"Escape",escape:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown"},nc=new Set(["ctrl","alt","shift","meta"]),li={left:0,middle:1,right:2};function ai(e){let n={prevent:!1,stop:!1,once:!1,capture:!1,self:!1,passive:!1,nonpassive:!1,keys:[],systemKeys:[],mouse:null,debounce:null,throttle:null};for(let r of e){let i=r.toLowerCase();if(i==="prevent")n.prevent=!0;else if(i==="stop")n.stop=!0;else if(i==="once")n.once=!0;else if(i==="capture")n.capture=!0;else if(i==="self")n.self=!0;else if(i==="passive")n.passive=!0;else if(i==="nonpassive")n.nonpassive=!0;else if(nc.has(i))n.systemKeys.push(i);else if(i in li)n.mouse=i;else if(i in oi||/^[a-z]$/.test(i))n.keys.push(oi[i]||i.toUpperCase());else if(i.startsWith("debounce")){let a=i.match(/debounce(?:\.(\d+))?/);n.debounce=a?.[1]?Number.parseInt(a[1],10):300}else if(i.startsWith("throttle")){let a=i.match(/throttle(?:\.(\d+))?/);n.throttle=a?.[1]?Number.parseInt(a[1],10):300}}return n}function ui(e,n=""){let r=[],i=0,a=/<([a-z][a-z0-9-]*)\s+([^>]*@[a-z][^>]*)>/gi,l;while((l=a.exec(e))!==null){let[u,f,x]=l,v=l.index,I=v+u.length,j=`__stx_evt_${n}${i++}`,W=[],M=/@([a-z][a-z0-9.]*)\s*=\s*"([^"]*)"/gi,L;while((L=M.exec(x))!==null){let[,U,q]=L,Z=U.split("."),G=Z[0];if(!ii.has(G))continue;W.push({attribute:`@${U}`,event:G,handler:q,modifiers:ai(Z.slice(1)),elementId:j})}let V=/@([a-z][a-z0-9.]*)\s*=\s*'([^']*)'/gi;while((L=V.exec(x))!==null){let[,U,q]=L,Z=U.split("."),G=Z[0];if(!ii.has(G))continue;W.push({attribute:`@${U}`,event:G,handler:q,modifiers:ai(Z.slice(1)),elementId:j})}if(W.length>0)r.push({originalTag:u,elementId:j,events:W,startIndex:v,endIndex:I})}return r}function sc(e){let n=[],{modifiers:r}=e;if(r.self)n.push("if ($event.target !== $el) return");for(let i of r.systemKeys)n.push(`if (!$event.${i}Key) return`);if(r.keys.length>0){let i=r.keys.map((a)=>`$event.key === '${a}'`).join(" || ");n.push(`if (!(${i})) return`)}if(r.mouse!==null){let i=li[r.mouse];n.push(`if ($event.button !== ${i}) return`)}if(r.prevent)n.push("$event.preventDefault()");if(r.stop)n.push("$event.stopPropagation()");return n.join("; ")}function rc(e,n){let r=e;if(n.debounce!==null)r=`__stx_debounce(() => { ${r} }, ${n.debounce})`;else if(n.throttle!==null)r=`__stx_throttle(() => { ${r} }, ${n.throttle})`;return r}function Bs(e){let n=e.trim();if(!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(n))return e;return`if (typeof ${n} === 'function' && !${n}._isSignal) ${n}($event);`}function ic(e){let{modifiers:n}=e,r=e.elementId.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),i=sc(e),a=rc(Bs(e.handler),n),l=[];if(n.once)l.push("once: true");if(n.capture)l.push("capture: true");if(zs(e.event,n))l.push("passive: true");let u=l.length>0?`, { ${l.join(", ")} }`:"",f=a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");if(e.event==="mounted")return`
|
|
3
|
-
(function() {
|
|
4
|
-
var $el = document.getElementById('${r}');
|
|
5
|
-
if (!$el) return;
|
|
6
|
-
// Run mounted handler immediately (DOM is ready)
|
|
7
|
-
var scope = $el.closest('[data-stx-scope]');
|
|
8
|
-
if (scope && scope.__stx_execute) {
|
|
9
|
-
scope.__stx_execute('${f}', null, $el);
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
__stx_runHandler('${f}', null, $el);
|
|
13
|
-
}
|
|
14
|
-
})();`;if(e.event==="unmounted")return`
|
|
15
|
-
(function() {
|
|
16
|
-
var $el = document.getElementById('${r}');
|
|
17
|
-
if (!$el) return;
|
|
18
|
-
// Set up MutationObserver to detect removal
|
|
19
|
-
var observer = new MutationObserver(function(mutations) {
|
|
20
|
-
for (var m of mutations) {
|
|
21
|
-
for (var node of m.removedNodes) {
|
|
22
|
-
if (node === $el || (node.contains && node.contains($el))) {
|
|
23
|
-
observer.disconnect();
|
|
24
|
-
var scope = $el.closest('[data-stx-scope]');
|
|
25
|
-
if (scope && scope.__stx_execute) {
|
|
26
|
-
scope.__stx_execute('${f}', null, $el);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
__stx_runHandler('${f}', null, $el);
|
|
30
|
-
}
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
observer.observe(document.body, { childList: true, subtree: true });
|
|
37
|
-
// Store observer for cleanup
|
|
38
|
-
$el.__stx_unmount_observer = observer;
|
|
39
|
-
})();`;return`
|
|
40
|
-
(function() {
|
|
41
|
-
var $el = document.getElementById('${r}');
|
|
42
|
-
if (!$el) return;
|
|
43
|
-
// eslint-disable-next-line pickier/no-unused-vars
|
|
44
|
-
$el.addEventListener('${e.event}', function($event) {
|
|
45
|
-
${i?i+";":""}
|
|
46
|
-
// Find the closest reactive scope and execute within its context
|
|
47
|
-
var scope = $el.closest('[data-stx-scope]');
|
|
48
|
-
if (scope && scope.__stx_execute) {
|
|
49
|
-
scope.__stx_execute('${f}', $event, $el);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
// Fallback for non-reactive context (entity-safe; decoded + run in memory)
|
|
53
|
-
__stx_runHandler('${f}', $event, $el);
|
|
54
|
-
}
|
|
55
|
-
}${u});
|
|
56
|
-
})();`}function Ai(e){if(e.length===0)return"";return`
|
|
57
|
-
<script data-stx-events>
|
|
58
|
-
(function() {
|
|
59
|
-
'use strict';
|
|
60
|
-
|
|
61
|
-
// Utility functions
|
|
62
|
-
function __stx_debounce(fn, delay) {
|
|
63
|
-
var timeout;
|
|
64
|
-
return function() {
|
|
65
|
-
var args = arguments;
|
|
66
|
-
var ctx = this;
|
|
67
|
-
clearTimeout(timeout);
|
|
68
|
-
timeout = setTimeout(function() { fn.apply(ctx, args); }, delay);
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function __stx_throttle(fn, delay) {
|
|
73
|
-
var last = 0;
|
|
74
|
-
return function() {
|
|
75
|
-
var now = Date.now();
|
|
76
|
-
if (now - last >= delay) {
|
|
77
|
-
last = now;
|
|
78
|
-
fn.apply(this, arguments);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Non-reactive fallback runner. The handler is embedded HTML-entity-encoded
|
|
84
|
-
// so the surrounding script element can never contain raw markup, including
|
|
85
|
-
// its own closing tag; we decode it to JS only in memory here, then run it
|
|
86
|
-
// with $event/$el in scope.
|
|
87
|
-
//
|
|
88
|
-
// This comment must not spell that closing tag out. It used to, as an
|
|
89
|
-
// example, and a browser ends the script element at the FIRST one it sees \u2014
|
|
90
|
-
// so everything below this line, __stx_runHandler included, was emitted as
|
|
91
|
-
// page text and no listener was ever bound. The comment about escaping was
|
|
92
|
-
// the thing that needed escaping.
|
|
93
|
-
function __stx_runHandler(h, $event, $el) {
|
|
94
|
-
var code = h
|
|
95
|
-
.replace(/</g, '<')
|
|
96
|
-
.replace(/>/g, '>')
|
|
97
|
-
.replace(/"/g, '"')
|
|
98
|
-
.replace(/'/g, "'")
|
|
99
|
-
.replace(/'/g, "'")
|
|
100
|
-
.replace(/&/g, '&');
|
|
101
|
-
try {
|
|
102
|
-
// eslint-disable-next-line no-new-func
|
|
103
|
-
(new Function('$event', '$el', code)).call($el, $event, $el);
|
|
104
|
-
}
|
|
105
|
-
catch (e) {
|
|
106
|
-
if (typeof console !== 'undefined') console.error('[stx] event handler error:', e);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Event listeners
|
|
111
|
-
${e.map(ic).join(`
|
|
112
|
-
`)}
|
|
113
|
-
})();
|
|
114
|
-
</script>`}function oc(e,n=""){let r=ui(e,n);if(r.length===0)return{template:e,bindings:[]};let i=e,a=[];for(let l=r.length-1;l>=0;l--){let u=r[l],f=u.originalTag;if(!f.includes(" id="))f=f.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${u.elementId}"`);else{let x=f.match(/id=["']([^"']+)["']/);if(x)for(let v of u.events)v.elementId=x[1]}for(let x of u.events){let v=x.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),I=new RegExp(`\\s*${v}\\s*=\\s*"[^"]*"`,"g"),j=new RegExp(`\\s*${v}\\s*=\\s*'[^']*'`,"g");f=f.replace(I,""),f=f.replace(j,"")}i=i.slice(0,u.startIndex)+f+i.slice(u.endIndex),a.push(...u.events)}return{template:i,bindings:a}}function ci(e){let n=e.$uid;return typeof n==="string"&&n?`${n}_`:""}function tl(e,n,r){if(Fl(e))return e;if(n.__stx_sfc_mode){if(/x-data\s*=\s*["']/.test(e))return e;let{template:f,bindings:x}=oc(e,ci(n)),v=n.__stx_event_bindings||[];return n.__stx_event_bindings=[...v,...x],f}let i=ui(e,ci(n));if(i.length===0)return e;let a=e;for(let f=i.length-1;f>=0;f--){let x=i[f],v=x.originalTag;if(!v.includes(" id="))v=v.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${x.elementId}"`);else{let I=v.match(/id=["']([^"']+)["']/);if(I)for(let j of x.events)j.elementId=I[1]}for(let I of x.events){let j=I.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),W=new RegExp(`\\s*${j}\\s*=\\s*"[^"]*"`,"g"),M=new RegExp(`\\s*${j}\\s*=\\s*'[^']*'`,"g");v=v.replace(W,""),v=v.replace(M,"")}a=a.slice(0,x.startIndex)+v+a.slice(x.endIndex)}let l=Ai(i.flatMap((f)=>f.events)),u=c(a);if(u!==-1)a=a.slice(0,u)+l+`
|
|
115
|
-
`+a.slice(u);else a+=l;return a}function pi(e,n){let r=new Set;for(let i of e.split(",")){let a=i.trim().replace(/^\.\.\./,"").trim();if(!a)continue;if(n){let l=a.lastIndexOf(":");if(l!==-1)a=a.slice(l+1).trim()}if(a=a.split("=")[0].trim(),/^[A-Za-z_$][\w$]*$/.test(a))r.add(a)}return r}function zt(e,n){let r=t(e),{depths:i,balanced:a}=E(r),l=(f)=>!a||i[f]===0,u=new RegExp(`(?:^|[^\\w$.])((?:const|let|var|function|class)\\s+${n}\\b)`,"g");for(let f of r.matchAll(u)){let x=(f.index??0)+f[0].length-f[1].length;if(l(x))return!0}for(let f of r.matchAll(/(?:const|let|var)\s*\{([^}]*)\}/g))if(l(f.index??0)&&pi(f[1],!0).has(n))return!0;for(let f of r.matchAll(/(?:const|let|var)\s*\[([^\]]*)\]/g))if(l(f.index??0)&&pi(f[1],!1).has(n))return!0;return!1}var Ve="0.2.889";var fi=Symbol.for(`stx.lazy-module-promises.${Ve}`);function cc(){let e=globalThis;return e[fi]??=new Map,e[fi]}function o(e,n){let r=cc(),i=`${import.meta.url}\x00${e}`,a=r.get(i);if(a)return a;let l=n();return r.set(i,l),l.catch(()=>{if(r.get(i)===l)r.delete(i)}),l}var lc=/<\/(script)/gi;function me(e){if(!e||e.indexOf("</")===-1)return e;return e.replace(lc,"<\\/$1")}import di from"fs";var gi=[];function S(e){let n=new T(e);return gi.push(n),n}function nl(){for(let e of gi)e.clear()}function C(e,...n){return`${n.map((r)=>String(r??"")).join("\x00")}\x00${e.length}\x00${Bun.hash(e)}`}function Ir(e){let n=[];for(let r of new Set(e))try{n.push({path:r,mtimeMs:di.statSync(r).mtimeMs})}catch{}return n}function Qs(e){for(let n of e)try{if(di.statSync(n.path).mtimeMs!==n.mtimeMs)return!1}catch{return!1}return!0}var Pe=["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 uc=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;function pc(e){if(e.startsWith(".")||e.startsWith("/"))return null;if(e.startsWith("@")){let r=e.match(/^(@[^/]+\/[^/]+)(\/.*)?$/);if(!r)return null;return{pkg:r[1],subpath:r[2]||""}}let n=e.match(/^([^/]+)(\/.*)?$/);if(!n)return null;return{pkg:n[1],subpath:n[2]||""}}function fc(e,n){let r=n;while(!0){let i=Nt.join(r,"node_modules",e,"package.json");if(bn.existsSync(i))return Nt.dirname(i);let a=Nt.dirname(r);if(a===r)return null;r=a}}function dc(e,n){if(!e||typeof e!=="object")return null;let r=(a)=>{if(typeof a==="string")return a;if(a&&typeof a==="object"){if(typeof a.import==="string")return a.import;if(typeof a.default==="string")return a.default;if(typeof a.import==="object")return r(a.import);if(typeof a.default==="object")return r(a.default)}return null};if(Object.prototype.hasOwnProperty.call(e,n))return r(e[n]);let i=null;for(let a of Object.keys(e)){let l=a.indexOf("*");if(l===-1)continue;let u=a.slice(0,l),f=a.slice(l+1);if(!n.startsWith(u)||!n.endsWith(f))continue;if(n.length<u.length+f.length)continue;if(!i||u.length>i.prefix.length)i={pattern:a,prefix:u,suffix:f}}if(i){let a=n.slice(i.prefix.length,n.length-i.suffix.length),l=r(e[i.pattern]);if(l)return l.replace("*",a)}return null}function gc(e,n){let r=pc(e);if(!r||!r.subpath)return null;let i=fc(r.pkg,n);if(!i)return null;let a;try{a=JSON.parse(bn.readFileSync(Nt.join(i,"package.json"),"utf8"))}catch{return null}let l=`.${r.subpath}`,u=dc(a.exports,l);if(!u)return null;let f=Nt.resolve(i,u);return bn.existsSync(f)?f:null}function Fi(e,n){let r=n.filePath?Nt.dirname(n.filePath):n.projectRoot||process.cwd(),i=n.projectRoot||process.cwd(),a=new Set,l=[],u=[];return{code:e.replace(uc,(x,v)=>{let I;try{if(v.startsWith("./")||v.startsWith("../")||v.startsWith("/")){if(I=v.startsWith("/")?v:Nt.resolve(r,v),!bn.existsSync(I))throw Error(`file not found: ${I}`)}else{let j=null;try{j=Bun.resolveSync(v,i)}catch{j=gc(v,i)}if(!j)throw Error(`could not resolve ${v} (Bun.resolveSync + exports fallback both failed)`);I=j}}catch(j){return console.warn(`[stx:vendor-css] could not resolve ${JSON.stringify(v)} (from ${n.filePath||"<unknown>"}): ${j?.message||j}`),u.push(v),""}if(a.has(I))return"";a.add(I);try{let j=bn.readFileSync(I,"utf8");l.push({source:v,resolvedPath:I,contents:j})}catch(j){console.warn(`[stx:vendor-css] could not read ${I}: ${j?.message||j}`),u.push(v)}return""}),styles:l,unresolved:u}}function mc(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function zi(e){if(e.length===0)return"";return`${e.map((n)=>`<style data-stx-vendor="${mc(n.source)}" data-stx-layer="vendor">
|
|
116
|
-
@layer vendor {
|
|
117
|
-
${n.contents}
|
|
118
|
-
}
|
|
119
|
-
</style>`).join(`
|
|
120
|
-
`)}
|
|
121
|
-
`}var Dg=_,mi=S(256);function Kt(e){let n=C(e),r=mi.get(n);if(!r)r=hc(e),mi.set(n,r);return{code:r.code,imports:[...r.imports],models:[...r.models]}}function hc(e){let n=t(e),r=new Set;for(let f of e.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let x of f[1].split(",")){let v=x.trim().split(/\s+as\s+/).pop()?.replace(/^type\s+/,"").trim();if(v)r.add(v)}let i=bo(n),a=Pe.filter((f)=>{if(r.has(f)||i.has(f))return!1;return Lg(n,f,!0)}),l=yi(n).filter((f)=>!r.has(f)&&!i.has(f));if(a.length===0&&l.length===0)return{code:e,imports:a,models:l};return{code:`${[a.length>0?`import { ${a.join(", ")} } from '@stacksjs/browser'`:"",l.length>0?"import '@stacksjs/browser'":"",l.length>0?`const { ${l.join(", ")} } = window.StacksBrowser || {}`:""].filter(Boolean).join(`
|
|
122
|
-
`)}
|
|
123
|
-
${e}`,imports:a,models:l}}var xc=new Set(["Promise","Object","Array","Map","Set","Date","Error","JSON","Math","Number","String","RegExp","Symbol","WeakMap","WeakSet","Proxy","Reflect","Intl","URL","URLSearchParams","FormData","Headers","Request","Response","AbortController","EventTarget","Element","Document","Node","Window","Console","Storage","Navigator","Blob","File","FileReader","HTMLElement","SVGElement","Event","CustomEvent","DOMParser","XMLSerializer","WebSocket","Worker","SharedWorker","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","Notification","Bun","Buffer","Process","Modal","Intl"]);function yi(e,n=Gr(e)){let r=new Set,i=bo(e),a=/(?<![\w$.])([A-Z][a-zA-Z0-9]*)\s*\.\s*(all|find|first|get|where|orderBy|orderByDesc|limit|select|pluck|create|update|delete)\s*\(/g;for(let l of n.code.matchAll(a)){let u=l[1];if(xc.has(u)||i.has(u)||u.length<3)continue;if(n.shadows(u,l.index??0))continue;r.add(u)}return Array.from(r)}function bc(e){return bo(e)}var hi=S(128);function vl(e){let n=C(e),r=hi.get(n);if(!r)r=yc(e),hi.set(n,r);return{code:r.code,stxImports:[...r.stxImports],browserImports:[...r.browserImports]}}function yc(e){let n=new Set,r=new Set,i=e;i=i.replace(/^[ \t]*import\s+type\s+\{[^}]*\}\s+from\s+['"][^'"]+['"][ \t]*;?[ \t]*$/gm,"// [type import stripped]");let a=new Set,l=/^[ \t]*import\s+(?:type\s+)?{\s*([^}]+)\s*}\s+from\s+['"](@stacksjs\/browser|@stacksjs\/stx|stx)['"][ \t]*;?[ \t]*$/gm,u;while((u=l.exec(e))!==null){let M=u[1],L=u[2];if(u[0].includes("import type"))continue;let V=[];for(let q of M.split(",")){let Z=q.trim();if(!Z||Z.startsWith("type "))continue;let G=Z.match(/^([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/);if(!G)continue;let H=G[1],ne=G[2]||H;if(a.add(H),a.add(ne),L==="stx"||L==="@stacksjs/stx")n.add(H);else r.add(H);if(ne!==H)V.push(`${ne} = ${H}`)}let U=V.length>0?`var ${V.join(", ")}; /* [auto-import processed] */`:"// [auto-import processed]";i=i.replace(u[0],U)}let f=bc(i),x=Gr(i);for(let M of Dg){if(a.has(M)||f.has(M))continue;if(Ws(x,M,!0))n.add(M)}let v=t(i),I=Gr(v),j=new Set;for(let M of i.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let L of M[1].split(",")){let V=L.trim().replace(/^type\s+/,"").split(/\s+as\s+/);for(let U of V){let q=U.trim();if(q)j.add(q)}}for(let M of Pe){if(a.has(M)||f.has(M)||j.has(M))continue;if(Ws(I,M))r.add(M)}let W=yi(v,I);for(let M of W)if(!a.has(M)&&!f.has(M))r.add(M);return{code:i,stxImports:Array.from(n),browserImports:Array.from(r)}}function Lg(e,n,r=!1){return Ws(Gr(e),n,r)}function Ws(e,n,r=!1){let i=e.code,a=new RegExp(`\\b${n.replace(/[$]/g,"\\$")}\\b`,"g");for(let l of i.matchAll(a)){let u=l.index??0;if(e.shadows(n,u))continue;let f=u+n.length,x=u-1;while(x>=0&&/\s/.test(i[x]))x--;if(i[x]==="."&&i.slice(Math.max(0,x-2),x+1)!=="...")continue;let v=f;while(v<i.length&&/\s/.test(i[v]))v++;if(i[v]===":"&&i[v+1]!==":"&&(i[x]==="{"||i[x]===","))continue;if(r&&!/^\s*(?:<[^>]*>)?\s*\(/.test(i.slice(f)))continue;if(_c(i,f))continue;return!0}return!1}function _c(e,n){let r=n;while(r<e.length&&(e[r]===" "||e[r]==="\t"))r++;if(e[r]!=="(")return!1;let i=0;for(;r<e.length;r++){let a=e[r];if(a==="(")i++;else if(a===")"){if(i--,i===0)break}}if(i!==0)return!1;r++;while(r<e.length&&(e[r]===" "||e[r]==="\t"))r++;return e[r]==="{"}function xl(e,n){let r=[];if(e.length>0)r.push(` var { ${e.join(", ")} } = window.stx || window;`);if(n.length>0)r.push(` var { ${n.join(", ")} } = window.StacksBrowser || {};`);if(r.length>0)return` // STX: auto-imported from stx and @stacksjs/browser
|
|
124
|
-
${r.join(`
|
|
125
|
-
`)}
|
|
126
|
-
${wc(e,n)}`;return""}function Ty(e,n=[]){let{browserImports:r}=vl(e),i=new Set(n);return xl([],r.filter((a)=>!i.has(a)))}function wc(e,n){let r=[...e.map((i)=>`['${i}', typeof ${i}, 'stx']`),...n.map((i)=>`['${i}', typeof ${i}, '@stacksjs/browser']`)];if(r.length===0)return"";return` // STX: report auto-imports the client runtime did not provide
|
|
127
|
-
[${r.join(", ")}].forEach(function (e) {
|
|
128
|
-
if (e[1] !== 'undefined') return;
|
|
129
|
-
console.error(
|
|
130
|
-
'[stx] "' + e[0] + '" is used in this client script and auto-imported from ' + e[2] + ', '
|
|
131
|
-
+ 'but the client runtime does not provide it. Either it is not exported to the browser, '
|
|
132
|
-
+ 'or it should be imported from a relative path so the bundler includes it.'
|
|
133
|
-
);
|
|
134
|
-
});
|
|
135
|
-
`}function qe(e){let n=e.__stxClientPayload;if(n&&typeof n==="object"){let i={};for(let a in n){let l=n[a];if(typeof l==="function")continue;i[a]=l}return i.__stxDeclaredPayload=!0,i}let r={};for(let i in e){if(i.startsWith("__")||i.startsWith("$"))continue;let a=e[i];if(typeof a==="function")continue;r[i]=a}return r}var vc=/token|secret|passw|apikey|api_key|privatekey|private_key|credential|webhook|bearer|jwt|signature/i,xi=new Set;function Sc(e,n){let r=vc.test(e),i=n.length>32768;if(!r&&!i)return;if(xi.has(e))return;if(xi.add(e),r)console.warn(`[stx] server\u2192client bridge is publishing "${e}" into the page body. If it holds a credential, rename it with a "__" prefix (never bridged) and pass only what the template needs. See stacksjs/stx#1831.`);if(i)console.warn(`[stx] server\u2192client bridge is publishing ${(n.length/1024).toFixed(1)}KB under "${e}". Every byte ships in the HTML on each request; prefix the binding with "__" and project just the fields the client reads.`)}function $n(e,n){if(!n)return"";let r=De(e,new Set(Object.keys(n))),i=n.__stxDeclaredPayload===!0,a=[],l=Object.entries(n).sort(([u],[f])=>u<f?-1:u>f?1:0);for(let[u,f]of l){if(!/^[A-Za-z_$][\w$]*$/.test(u))continue;if(u.startsWith("__")||u.startsWith("$"))continue;if(!i&&!r.has(u))continue;if(zt(e,u)){if(i)console.warn(`[stx] defineClientPayload declares "${u}", but this client block also declares "${u}" at the top level, so the server value is not published (emitting it would be a duplicate binding). Rename the local, or drop "${u}" from defineClientPayload.`);continue}let x;try{x=JSON.stringify(f)}catch{continue}if(x===void 0)continue;Sc(u,x),a.push(` var ${u} = ${x.replace(/</g,"\\u003c")};`)}if(a.length===0)return"";return` // stx: server -> client data bridge (seeded from server scope)
|
|
136
|
-
${a.join(`
|
|
137
|
-
`)}
|
|
138
|
-
`}var $c={left:0,middle:1,right:2};function Ec(e){let n=[];if(e.self)n.push("if ($event.target !== $el) return");for(let r of e.systemKeys)n.push(`if (!$event.${r}Key) return`);if(e.keys.length>0){let r=e.keys.map((i)=>`$event.key === '${i}'`).join(" || ");n.push(`if (!(${r})) return`)}if(e.mouse!==null){let r=$c[e.mouse];n.push(`if ($event.button !== ${r}) return`)}if(e.prevent)n.push("$event.preventDefault()");if(e.stop)n.push("$event.stopPropagation()");return n.join("; ")}function kc(e,n){let{elementId:r,event:i,modifiers:a}=e,l=Bs(e.handler),u=Ec(a),f=[];if(a.once)f.push("once: true");if(a.capture)f.push("capture: true");if(zs(i,a))f.push("passive: true");let x=f.length>0?`, { ${f.join(", ")} }`:"",v="";if(u)v+=`${u}; `;let I=l.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),j=`var $emit = function(name, detail) {
|
|
139
|
-
$el.dispatchEvent(new CustomEvent(name, { detail: detail, bubbles: true, cancelable: true }))
|
|
140
|
-
};`;function W(M){if(/\$emit\s*\(/.test(M))return`${j}
|
|
141
|
-
${M}`;return`var scope = $el.closest('[data-stx-scope]');
|
|
142
|
-
if (scope && scope.__stx_execute) {
|
|
143
|
-
scope.__stx_execute('${I}', $event, $el);
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
${M}
|
|
147
|
-
}`}if(a.debounce!==null)return` ;(function() {
|
|
148
|
-
// eslint-disable-next-line pickier/no-unused-vars
|
|
149
|
-
var $el = document.getElementById('${r}')
|
|
150
|
-
if (!$el) return
|
|
151
|
-
var __timer
|
|
152
|
-
$el.addEventListener('${i}', function($event) {
|
|
153
|
-
${u?u+"; ":""}clearTimeout(__timer)
|
|
154
|
-
__timer = setTimeout(function() { ${W(l)} }, ${a.debounce})
|
|
155
|
-
}${x})
|
|
156
|
-
})()`;if(a.throttle!==null)return` ;(function() {
|
|
157
|
-
// eslint-disable-next-line pickier/no-unused-vars
|
|
158
|
-
var $el = document.getElementById('${r}')
|
|
159
|
-
if (!$el) return
|
|
160
|
-
var __last = 0
|
|
161
|
-
$el.addEventListener('${i}', function($event) {
|
|
162
|
-
${u?u+"; ":""}var __now = Date.now()
|
|
163
|
-
if (__now - __last >= ${a.throttle}) {
|
|
164
|
-
__last = __now
|
|
165
|
-
${W(l)}
|
|
166
|
-
}
|
|
167
|
-
}${x})
|
|
168
|
-
})()`;if(/\$emit\s*\(/.test(l))return` var $el = document.getElementById('${r}')
|
|
169
|
-
if ($el) $el.addEventListener('${i}', function($event) {
|
|
170
|
-
${v}${j}
|
|
171
|
-
${l}
|
|
172
|
-
}${x})`;return` var $el = document.getElementById('${r}')
|
|
173
|
-
if ($el) $el.addEventListener('${i}', function($event) {
|
|
174
|
-
${v}var scope = $el.closest('[data-stx-scope]');
|
|
175
|
-
if (scope && scope.__stx_execute) {
|
|
176
|
-
scope.__stx_execute('${I}', $event, $el);
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
${l}
|
|
180
|
-
}
|
|
181
|
-
}${x})`}function Cc(e){if(e.length===0)return"";return`
|
|
182
|
-
// STX: auto-generated event bindings
|
|
183
|
-
${e.map((r,i)=>kc(r,i)).join(`
|
|
184
|
-
`)}`}function bi(e){let n=[],r=new Set,i=e.replace(/^\s*import\s+.*$/gm,""),a=0,l=i.length,u=0;while(u<l){let f=i[u];if(f==="'"||f==='"'||f==="`"){let x=f;if(u++,x==="`"){let v=0;while(u<l){if(i[u]==="\\"){u+=2;continue}if(i[u]==="`"&&v===0){u++;break}if(i[u]==="$"&&i[u+1]==="{"){v++,u+=2;continue}if(i[u]==="}"&&v>0){v--,u++;continue}u++}}else while(u<l){if(i[u]==="\\"){u+=2;continue}if(i[u]===x){u++;break}u++}continue}if(f==="/"&&i[u+1]==="/"){while(u<l&&i[u]!==`
|
|
185
|
-
`)u++;continue}if(f==="/"&&i[u+1]==="*"){u+=2;while(u<l-1&&!(i[u]==="*"&&i[u+1]==="/"))u++;u+=2;continue}if(f==="{"){a++,u++;continue}if(f==="}"){a--,u++;continue}if(a===0){let x=i.slice(u),v=x.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(v){let W=v[1];if(!W.startsWith("_")&&!r.has(W))n.push(W),r.add(W);u+=v[0].length;continue}let I=x.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(I){I[1].split(",").forEach((W)=>{let M=W.trim(),L=M.indexOf(":"),V=L>=0?M.slice(L+1).trim().split(/[\s=]/)[0]:M.split(/[\s=]/)[0];if(V&&!V.startsWith("_")&&!r.has(V))n.push(V),r.add(V)}),u+=I[0].length;continue}let j=x.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(j){let W=j[1];if(!W.startsWith("_")&&!r.has(W))n.push(W),r.add(W);u+=j[0].length;continue}}u++}return n}var Rc=new Set(["if","else","true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","switch","case","break","continue","for","while","do","try","catch","finally","const","let","var","function","class","import","export","default","async","await","yield","with","debugger","console","window","document","Math","JSON","Date","Array","Object","String","Number","Boolean","Symbol","Map","Set","Promise","Error","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","setTimeout","setInterval","clearTimeout","clearInterval","fetch","alert","confirm","prompt","event"]);function Ac(e){let n=new Set,r=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function i(W){let M;while((M=r.exec(W))!==null){let L=M[0];if(!Rc.has(L))n.add(L)}}let a=/\{\{([\s\S]*?)\}\}/g,l;while((l=a.exec(e))!==null)i(l[1]);let u=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((l=u.exec(e))!==null)i(l[1]);let f=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((l=f.exec(e))!==null)i(l[1]);let x=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((l=x.exec(e))!==null)i(l[1]);let v=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((l=v.exec(e))!==null)i(l[1]);let I=/@model\s*=\s*["']([^"']*)["']/gi;while((l=I.exec(e))!==null)i(l[1]);let j=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((l=j.exec(e))!==null)i(l[1]);return n}async function Ke(e,n={}){let r=e,i="",a=!1,l=[],u=Fi(r,{filePath:n.filePath,projectRoot:n.projectRoot});r=u.code;let f=zi(u.styles),x=Kt(r);r=x.code,l=[...x.imports,...x.models];let{hasUserImports:v,bundleClientScript:I}=await o("stx/client-script-bundler",()=>import("./chunk-rjm515e2.js"));if(v(r))r=await I(r,n.filePath||"",{projectRoot:n.projectRoot,minify:n.production}),a=!0;if(n.autoImports!==!1){let G=vl(r);r=G.code,i=xl(G.stxImports,G.browserImports.filter((H)=>!l.includes(H)))}if(i=`${$n(r,n.serverData)}${i}`,r=D(r),!a&&Ge(n.attrs||""))r=Xe(r);let j=Cc(n.eventBindings||[]),W=(n.attrs||"").trim(),M=/\btype\s*=\s*["']module["']/i.test(W),L=n.instanceId?` data-stx-instance="${n.instanceId}"`:"";if(M){let G=W.replace(/\btype\s*=\s*["']module["']/i,"").trim(),H=`type="module" data-stx-scoped${L}${G?` ${G}`:""}`;return`${f}<script ${H}>
|
|
186
|
-
${me(`${i}${r}
|
|
187
|
-
${j}`)}
|
|
188
|
-
</script>`}let V=ta(e),U=/function __stx_setup_/.test(r),q=/\bstx\.mount\s*\(|\bstx\.mountEl\s*\(/.test(e);function Z(G){let H=G.length>0?`
|
|
189
|
-
return ${Xs(r,G)};`:"",ne=JSON.stringify(`[stx] client block failed${n.filePath?` (${n.filePath})`:""}; this block will not hydrate`);return`${f}<script data-stx-scoped data-stx-run="always"${L}>
|
|
190
|
-
window.stx.mount(function() {
|
|
191
|
-
'use strict';
|
|
192
|
-
try {
|
|
193
|
-
${me(`${i}${r}
|
|
194
|
-
${j}${H}`)}
|
|
195
|
-
} catch (error) {
|
|
196
|
-
console.error(${ne}, error);
|
|
197
|
-
return {};
|
|
198
|
-
}
|
|
199
|
-
})</script>`}if(!q&&!U){if(V)return Z(bi(e));if(n.templateContent){let G=bi(e);if(G.length>0){let H=Ac(n.templateContent);if(G.some((ce)=>H.has(ce)))return Z(G)}}}return`${f}<script data-stx-scoped data-stx-run="always"${L}>
|
|
200
|
-
;(function() {
|
|
201
|
-
'use strict';
|
|
202
|
-
try {
|
|
203
|
-
${me(`${i}${r}
|
|
204
|
-
${j}`)}
|
|
205
|
-
} catch (error) {
|
|
206
|
-
console.error(${JSON.stringify(`[stx] client block failed${n.filePath?` (${n.filePath})`:""}; this block will not hydrate`)}, error);
|
|
207
|
-
}
|
|
208
|
-
})()</script>`}import{createHash as Nc}from"crypto";var Fs=/\s*/y,Vs=/\x00STX_HTML_COMMENT_\d+\x00/y;function Ht(e){let n=0;while(n<e.length){if(Fs.lastIndex=n,Fs.exec(e),n=Fs.lastIndex,e.startsWith("<!--",n)){let r=e.indexOf("-->",n+4);if(r===-1)return n;n=r+3;continue}if(Vs.lastIndex=n,Vs.test(e)){n=Vs.lastIndex;continue}return n}return n}var Us=/<(\/?)([a-zA-Z][a-zA-Z0-9-]*)\b/y,Tc=new Map(["textarea","title","xmp","iframe","noembed","noframes"].map((e)=>[e,new RegExp(`</${e}\\s*>`,"ig")]));function Ie(e){let n=[],r=0;while(r<e.length){let i=e.indexOf("<",r);if(i===-1)break;if(e.startsWith("<!--",i)){let W=e.indexOf("-->",i+4);if(W===-1)break;r=W+3;continue}Us.lastIndex=i;let a=Us.exec(e);if(!a){r=i+1;continue}let l=Us.lastIndex,u=l,f=null;for(;u<e.length;u++){let W=e[u];if(f){if(W===f)f=null}else if(W==='"'||W==="'")f=W;else if(W===">")break}if(u===e.length)break;let x=a[1]==="/",v=e[u-1]==="/";n.push({start:i,end:u+1,name:a[2],attributes:e.slice(l,v?u-1:u),closing:x,selfClosing:v}),r=u+1;let I=a[2].toLowerCase();if(!x&&I==="plaintext")break;let j=Tc.get(I);if(!x&&(I==="script"||I==="style"||j)){let W=j??(I==="script"?rs:is);W.lastIndex=r;let M=W.exec(e);if(!M)break;r=M.index}}return n}var ns=/<script\b[^>]*>/iy,rs=/<\/script\s*>/ig,ss=/<style\b[^>]*>/iy,is=/<\/style\s*>/ig;function _i(e,n,r,i){r.lastIndex=n;let a=r.exec(e);if(!a||a.index!==n)return-1;i.lastIndex=r.lastIndex;let l=i.exec(e);if(!l)return-1;return l.index+l[0].length}function Q(e,n){return _i(e,n,ns,rs)}function kn(e,n){return _i(e,n,ss,is)}function We(e,n){if(!e.startsWith("<!--",n))return-1;let r=e.indexOf("-->",n+4);if(r===-1)return-1;return r+3}function wi(e,n){if(e.startsWith("<!--",n)){let a=We(e,n);return a===-1?e.length:a}if(ns.lastIndex=n,ns.exec(e)?.index===n){rs.lastIndex=ns.lastIndex;let a=rs.exec(e);return a?a.index+a[0].length:e.length}if(ss.lastIndex=n,ss.exec(e)?.index===n){is.lastIndex=ss.lastIndex;let a=is.exec(e);return a?a.index+a[0].length:e.length}return-1}function w(e,n){let r=[],i=0,a=e.length,l=!1,u=null;while(i<a){let f=e[i];if(l){if(u){if(f===u)u=null}else if(f==='"'||f==="'")u=f;else if(f===">")l=!1;i++;continue}if(f!=="<"){let j=e.indexOf("<",i+1);if(j===-1)break;i=j;continue}let x=n(e,i);if(x>i){r.push({start:i,end:x,token:e.slice(i,x)}),i=x;continue}let v=wi(e,i);if(v>i){i=v;continue}let I=e.charCodeAt(i+1);if(I>=65&&I<=90||I>=97&&I<=122)l=!0;i++}return r}function vi(e){let n=0,r=0,i=0,a=!1,l=null;while(i<e.length){if(a){let j=e[i];if(l){if(j===l)l=null}else if(j==='"'||j==="'")l=j;else if(j===">")a=!1;i++;continue}let u=e.indexOf("<",i),f=u===-1?e.length:u;while(i<f){let j=e[i++];if(j==="{")n++;else if(j==="}")r++;if(n>=2&&r>=2)return!0}if(u===-1)break;let x=wi(e,u);if(x>u){i=x;continue}let v=e.charCodeAt(u+1),I=v===47?e.charCodeAt(u+2):v;if(I>=65&&I<=90||I>=97&&I<=122)a=!0;i=u+1}return!1}function rl(e,n){while(e.size>=n){let r=e.keys().next();if(r.done)return;e.delete(r.value)}}var Ic=1024,Pc=16777216,en=new Map,Hs=0;function Oc(e,n){en.set(e,n),Hs+=e.length+n.output.length;for(let[r,i]of en){if(Hs<=Pc)break;en.delete(r),Hs-=r.length+i.output.length}}function Se(e,n,r,i){let a=i!==void 0&&e.length>=Ic,l=a?`${i}\x00${e}`:"";if(a){let I=en.get(l);if(I)return en.delete(l),en.set(l,I),{output:I.output,tokens:I.tokens.slice()}}let u=w(e,n);if(u.length===0)return{output:e,tokens:[]};let f=u.map((I)=>I.token),x="",v=0;for(let I=0;I<u.length;I++){let j=u[I];x+=e.slice(v,j.start),x+=r(j.token,I),v=j.end}if(x+=e.slice(v),a)return Oc(l,{output:x,tokens:f}),{output:x,tokens:f.slice()};return{output:x,tokens:f}}var jc=1024,Mc=16777216,tn=new Map,Ks=0;function Dc(e,n){tn.set(e,n),Ks+=e.length+n.output.length;for(let[r,i]of tn){if(Ks<=Mc)break;tn.delete(r),Ks-=r.length+i.output.length}}function qs(e,n,r){return{output:n,scripts:r,restore:(i)=>i===n?e:Or(i,r)}}function re(e){let n=e.length>=jc;if(n){let a=tn.get(e);if(a)return tn.delete(e),tn.set(e,a),qs(e,a.output,a.scripts.slice())}let{output:r,tokens:i}=Se(e,Q,(a,l)=>`\x00STX_SCRIPT_${l}\x00`);if(n)return Dc(e,{output:r,scripts:i}),qs(e,r,i.slice());return qs(e,r,i)}function Or(e,n){if(n.length===0)return e;return e.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(r,i)=>n[+i]??"")}function se(e){let n=Ie(e),r=[];for(let i=0;i<n.length;i++){let a=n[i],l=n[i+1];if(a.name.toLowerCase()!=="script"||a.closing||l?.name.toLowerCase()!=="script"||!l.closing)continue;r.push({start:a.start,end:l.end,bodyStart:a.end,bodyEnd:l.start,attrs:a.attributes})}return r}var os="__stx_component_client_factories";function as(e){let n=e[os];return n instanceof Map?n:null}function hl(e){e[os]=new Map}function er(e,n){let r=as(e);if(!r)return null;let i=Nc("sha256").update(n).digest("hex").slice(0,16),a=r.get(i);if(a)a.instances++;else r.set(i,{body:n,instances:1});return i}function yl(e,n){let r=as(n);if(!r?.size)return e;let i=new Map;for(let[I,j]of r)if(j.instances===1)i.set(I,j.body);let a=[];if(i.size>0){let I=[...i.keys()].map((M)=>JSON.stringify(M).replace(/[$()*+.?[\\\]^{|}]/g,"\\$&")).join("|"),j=new RegExp(`window\\.__stxComponentFactories\\[(${I})\\]\\(("[^"]+")\\);`,"g"),W=j.exec(e);while(W!==null){let M=i.get(JSON.parse(W[1]));if(M!==void 0)a.push({start:W.index,end:W.index+W[0].length,replacement:me(`(${M})(${W[2]});`)});W=j.exec(e)}}let l=[...r].filter(([,I])=>I.instances>1);if(l.length===0)return Si(e,a);let u=l.map(([I,j])=>` try { factories[${JSON.stringify(I)}] = factories[${JSON.stringify(I)}] || ${j.body}; }
|
|
209
|
-
catch (e) { console.error('[stx] component factory ' + ${JSON.stringify(I)} + ' failed to register; instances of it will not hydrate.', e); }`).join(`
|
|
210
|
-
`),f=`<script data-stx-scoped data-stx-run="always" data-stx-component-factories>
|
|
211
|
-
(function() {
|
|
212
|
-
const factories = window.__stxComponentFactories = window.__stxComponentFactories || {};
|
|
213
|
-
${me(u)}
|
|
214
|
-
})();
|
|
215
|
-
</script>`,x,v=/<(?:template\b|script\b(?=[^>]*\bdata-stx-scoped\b))/iy;return w(e,(I,j)=>{if(x===void 0){if(v.lastIndex=j,v.test(I))x=j}return-1}),a.push({start:x??0,end:x??0,replacement:`${f}
|
|
216
|
-
`}),Si(e,a)}function Si(e,n){if(n.length===0)return e;n.sort((l,u)=>l.start-u.start||l.end-u.end);let r=Array(n.length*2+1),i=0,a=0;for(let l of n)r[a++]=e.slice(i,l.start),r[a++]=l.replacement,i=l.end;return r[a]=e.slice(i),r.join("")}function Ei(e){let n=as(e),r=new Map;if(n)for(let[i,a]of n)r.set(i,a.instances);return r}function ki(e,n){let r=as(e);if(!r)return[];let i=[];for(let[a,l]of r){let u=l.instances-(n.get(a)??0);if(u>0)i.push({body:l.body,count:u})}return i}function Ci(e,n){for(let{body:r,count:i}of n)for(let a=0;a<i;a++)er(e,r)}function Ae(e,n,r=2){let i=0,a=null;for(let l=n+r;l<e.length;l++){let u=e[l];if(a){if(u==="\\"){l++;continue}if(u===a)a=null;continue}if(u==='"'||u==="'"||u==="`"){a=u;continue}if(u==="{"){i++;continue}if(u==="}"){if(i>0){i--;continue}let f=0;while(e[l+f]==="}")f++;if(f>=r)return l}}return-1}import fo from"fs";var qi=0,tr=new Map;function Cl(){qi=0,tr.clear()}function cs(e,n){let r=qi++,i=`<!--__STX_${e.toUpperCase()}_${r}__-->`;return tr.set(i,{type:e,expression:n}),i}function El(){let e={};for(let[n,r]of tr)e[n]={type:r.type,expression:r.expression};return e}function Tl(e,n){let r=e;for(let[i,a]of n)r=r.split(i).join(a);return r}function Vi(e){return e.includes("<!--__STX_")}var Lc=/@(?=[a-zA-Z_]\w*\s*\(|end[a-zA-Z]*\b|else(?:if)?\b|empty\b|case\b|default\b|break\b|continue\b|fallback\b)/g;function zc(e){return Array.from({length:e},()=>"{").join("⁠")}function Zi(e){return e.replace(/\{{2,}/g,(n)=>zc(n.length)).replace(/\{(?=!)/g,"{⁠").replace(Lc,"@")}function Mr(e,n,r=!1){let{openTag:i,tail:a}=r?Bc(e,n):Wc(e).at(n);return Vc(a,i,r)}function Bc(e,n){let r="",i=0;for(let u=0;u<n;u++){if(!e.startsWith("{{",u))continue;let f=Ae(e,u);if(f<0||f+2>n)break;r+=e.slice(i,u)+"x",u=f+1,i=f+2}r+=e.slice(i,n);let a=-1,l=null;for(let u=0;u<r.length;u++){let f=r[u];if(l){if(f===l)l=null;continue}if(f==='"'||f==="'"){l=f;continue}if(f===">"){a=-1;continue}if(f==="<")a=u}return{openTag:a,tail:a>=0?r.slice(a+1):r}}var ls=null;function Wc(e){if(ls&&ls.source===e)return ls.scanner;let n=Fc(e);return ls={source:e,scanner:n},n}function Fc(e){let n=0,r=-1,i=null,a=-1,l=(f,x)=>{let v=e[f];if(x.quote){if(v===x.quote)x.quote=null;return}if(x.openTag>=0){if(v==='"'||v==="'"){x.quote=v;return}if(v===">"){x.openTag=-1;return}}if(v==="<")x.openTag=f},u=(f,x)=>{if(x.openTag>=0||!e.startsWith("<!--",f))return-1;let v=e.indexOf("-->",f+4);return v<0?e.length:v+3};return{at(f){if(f<n)n=0,r=-1,i=null,a=-1;let x={openTag:r,quote:i},v=!1;while(n<f){if(a<0&&e.startsWith("{{",n)){let V=Ae(e,n);if(V<0)a=n;else if(V+2<=f){n=V+2;continue}else break}let L=u(n,x);if(L>=0){if(L>f){v=!0;break}n=L;continue}l(n,x),n++}if(r=x.openTag,i=x.quote,v)return{openTag:-1,tail:""};let I=a>=0?a:n,j={openTag:r,quote:i};for(let L=n;L<f;L++){let V=u(L,j);if(V>=0){if(V>f)return{openTag:-1,tail:""};L=V-1;continue}l(L,j)}if(j.openTag<0)return{openTag:-1,tail:""};let W="",M=j.openTag+1;for(let L=M;L<Math.min(f,I);L++){if(!e.startsWith("{{",L))continue;let V=Ae(e,L);W+=e.slice(M,L)+"x",L=V+1,M=V+2}return W+=e.slice(M,f),{openTag:j.openTag,tail:W}}}}function Vc(e,n,r){if(n<0&&!r)return null;if(n>=0&&/^\s*[!/?]/.test(e))return/^\s*\/?\s*$/.test(e)?{kind:"tag-name"}:null;if(n>=0&&/^\s*$/.test(e))return{kind:"tag-name"};let i=0;if(n>=0)while(i<e.length&&!/\s/.test(e[i]))i++;while(i<e.length){while(/\s/.test(e[i]??"")&&i<e.length)i++;let a=i;while(i<e.length&&!/[\s=/>]/.test(e[i]))i++;let l=e.slice(a,i);if(!l)break;while(i<e.length&&/\s/.test(e[i]))i++;if(e[i]!=="=")continue;i++;while(i<e.length&&/\s/.test(e[i]))i++;let u=e[i];if(u==='"'||u==="'"){let f=++i,x=e.indexOf(u,i);if(x===-1)return{kind:"attribute",name:l,quote:u,valuePrefix:e.slice(f)};i=x+1}else{let f=i;while(i<e.length&&!/\s/.test(e[i]))i++;if(i===e.length)return{kind:"attribute",name:l,quote:null,valuePrefix:e.slice(f)}}}return{kind:"tag"}}class he extends Error{attribute;near;constructor(e,n){super(`Unsafe interpolation in ${e}: ${n}`);this.name="UnsafeInterpolationContextError",this.attribute=e}locate(e,n){if(this.near===void 0)this.near=e.slice(Math.max(0,n-160),n).replace(/\s+/g," ").trim(),this.message+=` (after: ${JSON.stringify(this.near)})`;return this}}var Ji="unsafe:";var Uc=/^(?:javascript|vbscript|livescript|mocha|view-source):/,Hc=/^data:(?:text\/html|text\/xml|application\/xhtml\+xml|application\/xml|image\/svg\+xml)/,Kc=/^data:(?:text\/html|application\/xhtml\+xml)/,qc=new RegExp("[\\u0000-\\u0020\\u00A0\\u1680\\u2000-\\u200F\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]+","g");function Zc(e){return e.replace(qc,"").toLowerCase()}function nr(e){let n=e.toLowerCase();if(new RegExp("^(?:href|xlink:href|action|formaction|ping|cite|manifest|data|to)$").test(n))return"navigable";if(new RegExp("^(?:src|srcset|poster|background)$").test(n))return"fetched";return null}function us(e,n="navigable"){let r=Zc(e);if(Uc.test(r))return!0;return n==="navigable"?Hc.test(r):Kc.test(r)}function Nr(e,n="navigable"){return us(e,n)?"unsafe:"+e:e}function Jc(e){let n=e.match(/(?:^|[\s"'`/])([A-Za-z][\w:-]*)\s*=\s*(["'])([^"']*)$/);if(!n)return null;if(n[3].trim()!=="")return null;return nr(n[1])}function Xi(e,n,r=256){if(n<=r)return e.slice(0,n);let i=e.slice(n-r,n),a=i.search(/[\s"'`/]/);return a===-1?"":i.slice(a)}function Gi(e,n,r=n){let i=Jc(e);return i&&us(n,i)?"unsafe:"+r:r}function Vt(e){let n=e.indexOf(" as ");if(n!==-1){let l=e.slice(0,n).trim(),u=e.slice(n+4).trim();return l&&u?{arrayExpr:l,itemVar:u}:null}let r=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(e);if(!r)return null;let i=r[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),a=r[2].trim();return i&&a?{arrayExpr:a,itemVar:i}:null}function ps(e){let n=[],r=0,i="",a=0;for(let l=0;l<e.length;l++){let u=e[l];if(i){if(u==="\\")l++;else if(u===i)i="";continue}if(u==="'"||u==='"'||u==="`")i=u;else if(u==="("||u==="["||u==="{")r++;else if(u===")"||u==="]"||u==="}")r--;else if(u===","&&r===0)n.push(e.slice(a,l)),a=l+1}return n.push(e.slice(a)),n}function Yi(e,n){let r=0;for(let i=0;i<e.length;i++){let a=e[i];if(a==="("||a==="["||a==="{")r++;else if(a===")"||a==="]"||a==="}")r--;else if(a===n&&r===0)return i}return-1}function Qi(e){let n=0;for(let r=0;r<e.length;r++){let i=e[r];if(i==="("||i==="["||i==="{")n++;else if((i===")"||i==="]"||i==="}")&&--n===0)return r}return-1}function Lt(e,n){let r=e.trim().replace(/^\.\.\./,"").trim(),i=Yi(r,"=");if(i!==-1&&r[i+1]!==">")r=r.slice(0,i).trim();if(!r)return;if(r.startsWith("{")&&r.endsWith("}")){for(let a of ps(r.slice(1,-1))){let l=a.trim();if(!l)continue;if(l.startsWith("...")){Lt(l,n);continue}let u=Yi(l,":");Lt(u===-1?l:l.slice(u+1),n)}return}if(r.startsWith("[")&&r.endsWith("]")){for(let a of ps(r.slice(1,-1)))Lt(a,n);return}if(/^[A-Z_$][\w$]*$/i.test(r))n.push(r)}function oe(e){let n=e.trim(),r=[],i=0;for(let l=0;l<n.length;l++){let u=n[l];if(u==="("||u==="["||u==="{")i++;else if(u===")"||u==="]"||u==="}")i--;else if(i===0&&/\s/.test(u)){if(!/^\s+(?:in|of)\s/.exec(n.slice(l)))continue;let x=n.slice(0,l).trim();if(x.startsWith("(")&&Qi(x)===x.length-1)x=x.slice(1,-1);for(let v of ps(x))Lt(v,r);if(r.length>0)return r;break}}let a=/^[\s\S]+?\s+as\s+([\s\S]+)$/.exec(n);if(a){let l=a[1].trim();if(l.startsWith("(")&&Qi(l)===l.length-1)l=l.slice(1,-1);let u=/^([\w$]+)\s*=>\s*([\s\S]+)$/.exec(l);if(u)Lt(u[2],r),Lt(u[1],r);else for(let f of ps(l))Lt(f,r)}return r}function F(e,n){let r=n instanceof Set?n:new Set(n);if(r.size===0)return!1;let u=e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g," ").replace(/`(?:[^`\\$]|\\.|\$(?!\{))*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:(?!:))/g,"$1$2");for(let f of u.match(/[a-zA-Z_$][\w$]*/g)||[])if(r.has(f))return!0;return!1}var fs="__stx_client_loop_names";function gt(e){let n=e?.[fs];return Array.isArray(n)?n:[]}function ds(e){if(!e.includes("#")&&!e.includes("v-slot:")&&!e.includes("data-stx-slot-binding"))return[];let n=[],r=[],i=/<!--[\s\S]*?-->|<script\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/script\s*>|<style\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/style\s*>|<\/?[a-z][\w:-]*\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;for(let a of e.matchAll(i)){let l=a[0];if(/^<\/template\s*>$/i.test(l)){let u=r.pop();if(u)u.end=a.index}else if(/^<template\b/i.test(l)&&!/\/\s*>$/.test(l)){let f=[...l.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((I)=>/^(?:#[\w-]+|v-slot:[\w-]+|data-stx-slot-binding)$/i.test(I[1])),x=(f?.[2]??f?.[3])?.trim();if(x&&f?.[1]==="data-stx-slot-binding")try{x=decodeURIComponent(x)}catch{x=void 0}let v=x?{start:a.index+l.length,end:e.length,binding:x}:void 0;if(r.push(v),v)n.push(v)}}return n}var wn={},go=new Map;function Xc(e){let n=go.get(e);if(!n){let r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=new RegExp(`:${r}(?!\\w)`,"g"),go.set(e,n)}return n.lastIndex=0,n}var lo={uppercase:(e,n)=>e!==void 0&&e!==null?String(e).toUpperCase():"",lowercase:(e,n)=>e!==void 0&&e!==null?String(e).toLowerCase():"",capitalize:(e,n)=>{if(e===void 0||e===null)return"";let r=String(e);return r.charAt(0).toUpperCase()+r.slice(1)},number:(e,n,r=0)=>{if(e===void 0||e===null)return"";try{let i=Number(e);return Number.isNaN(i)?"":i.toFixed(Number.parseInt(String(r),10))}catch{return""}},fmt:(e,n,r="en-US")=>{if(e===void 0||e===null)return"";try{let i=Number(e);if(Number.isNaN(i))return String(e);return i.toLocaleString(r)}catch{return String(e)}},join:(e,n,r=",")=>{if(!Array.isArray(e))return"";return e.join(String(r))},escape:(e,n)=>{if(e===void 0||e===null)return"";return Y(String(e))},translate:(e,n,r={})=>{if(!n||!n.__translations)return e;let i=n.__translations,a=n.__i18nConfig?.fallbackToKey??!0,l=String(e).split("."),u=i;for(let x of l){if(u===void 0||u===null)break;u=u[x]}if(u===void 0||u===null)return a?e:"";let f=String(u);return Object.entries(r).forEach(([x,v])=>{f=f.replace(Xc(x),()=>String(v))}),f},t:(e,n,r={})=>lo.translate(e,n,r),truncate:(e,n,r=50,i="...")=>{if(e===void 0||e===null)return"";let a=String(e);if(a.length<=r)return a;if(r<=i.length)return i.substring(0,r);return a.substring(0,r-i.length)+i},date:(e,n,r="short",i="en-US")=>{if(e===void 0||e===null)return"";try{let a=e instanceof Date?e:new Date(e);if(Number.isNaN(a.getTime()))return String(e);let l={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(r==="iso")return a.toISOString();return new Intl.DateTimeFormat(i,l[r]||l.short).format(a)}catch{return String(e)}},currency:(e,n,r="USD",i="en-US")=>{if(e===void 0||e===null)return"";try{let a=Number(e);if(Number.isNaN(a))return String(e);return new Intl.NumberFormat(i,{style:"currency",currency:r}).format(a)}catch{return String(e)}},pluralize:(e,n,r,i)=>{let a=Number(e);if(Number.isNaN(a))return r;let l=i||`${r}s`;return a===1?r:l},first:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return e.length===0?"":e[0];return String(e).charAt(0)},last:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return e.length===0?"":e[e.length-1];let r=String(e);return r.charAt(r.length-1)},length:(e,n)=>{if(e===void 0||e===null)return 0;if(Array.isArray(e)||typeof e==="string")return e.length;if(e instanceof Map||e instanceof Set)return e.size;if(typeof e==="object")return Object.keys(e).length;return 0},json:(e,n,r=!1)=>{if(e===void 0)return"undefined";if(e===null)return"null";try{return r?JSON.stringify(e,null,2):JSON.stringify(e)}catch{return String(e)}},default:(e,n,r="")=>e===void 0||e===null||e===""?r:e,reverse:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return[...e].reverse();return String(e).split("").reverse().join("")},slice:(e,n,r=0,i)=>{if(e===void 0||e===null)return"";if(Array.isArray(e)||typeof e==="string")return e.slice(r,i);return e},replace:(e,n,r,i="")=>{if(e===void 0||e===null)return"";let a=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String(e).replace(new RegExp(a,"g"),()=>i)},stripTags:(e,n)=>{if(e===void 0||e===null)return"";return String(e).replace(/<[^>]*>/g,"")},urlencode:(e,n)=>{if(e===void 0||e===null)return"";return encodeURIComponent(String(e))},abs:(e,n)=>{let r=Number(e);return Number.isNaN(r)?0:Math.abs(r)},round:(e,n,r=0)=>{let i=Number(e);if(Number.isNaN(i))return 0;let a=10**r;return Math.round(i*a)/a}};function qg(e,n){if(e in lo)console.warn(`Filter "${e}" already exists as a built-in filter. Custom filter will take precedence.`);wn[e]=n}function Ry(e){for(let[n,r]of Object.entries(e))qg(n,r)}function Kg(){return{...lo,...wn}}function Ay(){for(let e of Object.keys(wn))delete wn[e]}function So(e){let n=e.next();while(!n.done)n=e.next();return n.value}function*$o(e,n,r,i){let a="{".repeat(r);if(!e.includes(a))return e;let l="",u=0,f=0,x=i===Number.POSITIVE_INFINITY?0:performance.now();for(;;){let v=e.indexOf(a,u);if(v===-1)break;let I=Ae(e,v,r);if(I===-1)break;if(l+=e.slice(u,v)+n(e.slice(v,I+r),e.slice(v+r,I),v),u=I+r,++f>=64){f=0;let j=performance.now();if(j-x>=i)x=j,yield}}return u===0?e:l+e.slice(u)}function An(e,n,r=2){return So($o(e,n,r,Number.POSITIVE_INFINITY))}function Gc(e,n,r){let i=r[0];if(i!=="'"&&i!=='"'&&i!=="`")return!1;let a=Mr(e,n);if(!a||a.kind!=="attribute"||a.quote===i)return!1;if(!/^(?::|@|x-|v-)/.test(a.name))return!1;let l=0;for(let u=0;u<a.valuePrefix.length;u++)if(a.valuePrefix[u]==="\\")u++;else if(a.valuePrefix[u]===i)l++;return l%2===1}function g(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Y(e){return Zi(g(e))}function Yc(e){return e.replace(/ /g," ").replace(/\t/g,"	").replace(/\n/g," ").replace(/\r/g," ").replace(/\f/g,"").replace(/=/g,"=").replace(/`/g,"`")}function Qc(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\\([\dA-Fa-f]{1,6})\s?/g,(n,r)=>String.fromCodePoint(Number.parseInt(r,16))).replace(/\\([^\r\n])/g,"$1").replace(/[\u0000-\u0020]+/g,"").toLowerCase()}function el(e,n){let r=Qc(e);if(/@import|expression\(|behavior:|-moz-binding|(?:image-set|cross-fade)\(/.test(r))throw new he(n,"network-capable or executable CSS is not allowed in an escaped interpolation");let i=/url\(([^)]*)\)/g,a;while((a=i.exec(r))!==null){let l=a[1].replace(/^["']|["']$/g,""),u=l.startsWith("/")&&!l.startsWith("//")||l.startsWith("./")||l.startsWith("../")||l.startsWith("#"),f=/^data:image\/(?:avif|bmp|gif|jpeg|jpg|png|webp);base64,[a-z\d+/=]+$/i.test(l);if(!u&&!f)throw new he(n,"CSS URLs must be local paths or base64 raster images")}}function ae(e,n,r,i=!1,a=0){try{return $l(e,n,r,i,a)}catch(l){if(l instanceof he)l.locate(e,n);throw l}}function $l(e,n,r,i,a){let l=Mr(e,n,i),u=Y(r);if(!l)return u;if(l.kind==="tag-name"){if(!/^[A-Za-z][A-Za-z0-9:-]*$/.test(r))throw new he("tag name","dynamic tag names may contain only letters, digits, colons, and hyphens");return r}if(l.kind==="tag"){let v=e.slice(n+a).trimStart(),I=r.trim();if(!v.startsWith("=")&&(I===""||I.split(/\s+/).every((j)=>/^(?!on)[A-Za-z_:][\w:.-]*$/.test(j))))return I;throw new he("tag structure","only standalone boolean attributes may be interpolated into tag structure")}let f=l.name.toLowerCase();if(/^on[a-z]/.test(f))throw new he(l.name,"native event-handler attributes execute JavaScript; use an @event binding instead");if(f==="srcdoc")u=Y(u);if(f==="style")el(r,l.name);if(l.quote===null)u=Yc(u);let x=nr(f);if(x&&l.valuePrefix.trim()===""&&us(r,x))return Ji+u;return Gi(Xi(e,n),r,u)}function Pn(e,n){let r=` ${e}="`;return ae(r,r.length,n,!0)}function Eo(e){return e.flatMap((n)=>{let r=n.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i);return!r||/\bserver\b|\bsrc\s*=/.test(r[1])?[]:[r[2]]})}function Oe(e,n){let{scripts:r}=re(e);for(let i of Eo(r)){if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect|useModel)\s*(?:<[^>]*>)?\s*\(/.test(i)||kl.test(i))return!0;if(Jr(i,n))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test(e))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test(e))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test(e))return!0;return!1}function Gg(e){let n=[],r=/<([a-zA-Z][\w-]*)\b[^>]*?\s(?::for|x-for|@for)\s*=\s*(["'])([\s\S]*?)\2[^>]*>/g;for(let i=r.exec(e);i;i=r.exec(e)){let a=i[1].toLowerCase(),l=new Set(oe(i[3]));if(l.size===0)continue;let u=i.index+i[0].length;if(i[0].endsWith("/>")){n.push({start:i.index,end:u,names:l});continue}let f=new RegExp(`<(/?)${a}\\b[^>]*?(/?)>`,"gi");f.lastIndex=u;let x=1,v=e.length;for(let I=f.exec(e);I;I=f.exec(e)){if(I[2]==="/")continue;if(x+=I[1]==="/"?-1:1,x===0){v=I.index+I[0].length;break}}n.push({start:i.index,end:v,names:l})}return n}function mo(e,n,r){let i=t(r);for(let a of e){if(n<a.start||n>=a.end)continue;for(let l of a.names)if(new RegExp(`(?<![.#\\w$])${l.replace(/\$/g,"\\$")}(?![\\w$])`).test(i))return!0}return!1}function xo(e,n){let r=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","URL","URLSearchParams","Intl","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console","new","typeof","instanceof","in","void"],i=e.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),a="",l=!1,u=0;for(let v=0;v<i.length;v++){let I=i[v];if(!l&&I==="`"){l=!0,u=0;continue}if(l){if(I==="`"&&u===0){l=!1;continue}if(I==="$"&&i[v+1]==="{"){u++,v++,a+=" ";continue}if(I==="}"&&u>0){u--;continue}if(u>0){a+=I;continue}continue}a+=I}i=a;let f=/(?<![a-zA-Z0-9_$])([a-zA-Z_$][a-zA-Z0-9_$]*)/g,x;while((x=f.exec(i))!==null){let v=x[1];if(!i.substring(0,x.index).trimEnd().endsWith(".")){if(!r.includes(v)&&!(v in n))return!1}}return!0}function Rl(e,n){let r=t(e);for(let i of r.matchAll(/(?<![.\w$])([A-Z_$][\w$]*)\s*\(/gi))if(typeof n[i[1]]==="function")return!0;return!1}function Al(e,n){let r=n.__stx_serverDeclared;if(!r||r.size===0)return!1;let i=t(e);for(let a of r)if(new RegExp(`(?<![.#\\w$])${a}(?![\\w$])`).test(i))return!0;return!1}var _o=new Set;function wo(e){return/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(e.trim())}function Il(e,n,r){let i=r[0];if(i!=="'"&&i!=='"'&&i!=="`")return!1;let a=0;for(let l=e.lastIndexOf(`
|
|
217
|
-
`,n-1)+1;l<n;l++)if(e[l]==="\\")l++;else if(e[l]===i)a++;return a%2===1}function vo(e,n){let r=`${n??"<unknown>"}\x00${e}`;if(process.env.STX_DEBUG||!_o.has(r))_o.add(r),console.warn(`[stx] {{ ${e} }} in a <script> in ${n??"<unknown>"} has no server value, so it was emitted as undefined. A mustache left in JavaScript is a SyntaxError that takes the whole script down, so give the value a default in <script server>.`);return"undefined"}function Ui(e,n,r){let i=e;return i=i.replace(/\{!!([\s\S]*?)!!\}/g,(a,l)=>{try{let u=N(l,n);if(u===void 0)return wo(l)?vo(l.trim(),r):a;return u===null?"":String(u)}catch{return a}}),i=An(i,(a,l,u)=>{let f=l.trim();if(Il(i,u,l))return a;if(/^__[A-Z_]+__$/.test(f))return a;try{let x=N(l,n);if(x===void 0)return wo(f)?vo(f,r):a;return JSON.stringify(x).replace(/</g,"\\u003c").replace(/@/g,"\\u0040").replace(/\{{2,}/g,(v)=>"\\u007b".repeat(v.length)).replace(/\{(?=!)/g,"\\u007b")}catch{return a}}),i}function Xg(e,n){if(!e.includes("{"))return e;let r=e;return r=r.replace(/\{!!([\s\S]*?)!!\}/g,(i,a)=>{try{let l=N(a,n);if(l===void 0)return i;return l===null?"":String(l)}catch{return i}}),r=An(r,(i,a,l)=>{let u=a.trim();if(/^__[A-Z_]+__$/.test(u))return i;try{let f=N(a,n);if(f===void 0)return i;if(f===null)return"";let x=String(f);return ae(r,l,x,!0,i.length)}catch(f){if(f instanceof he)throw f;return i}}),r}function Py(e,n,r={}){let{output:i,scripts:a}=re(e),l=a.map((u)=>{let f=u.match(/^<script\b((?:[^>\"']|\"[^\"]*\"|'[^']*')*)>/i),x=u.search(/<\/script\s*>$/i);if(!f||x===-1)return u;let v=f[1],I=u.slice(f[0].length,x);if(/\bdata-raw\b/.test(v))return u;if(r.skipServer&&/\bserver\b/.test(v))return u;let W=`<script${Xg(v,n)}>`;if(/\bsrc\s*=/.test(v)||/\btype\s*=\s*["']application\/json["']/.test(v))return W+I+u.slice(x);return W+Ui(I,n)+u.slice(x)});return Or(i,l)}function*ko(e,n,r,i){let a=e,l=(V,U)=>{let q=kn(V,U);if(q===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(V.slice(U,q))?-1:q},u=(V,U,q,Z)=>{let G=q.length,{output:H,tokens:ne}=Se(V,U,(ce,de)=>Z(G+de));return q.push(...ne),H},f=[];a=u(a,l,f,(V)=>`<!--__STX_STYLE_${V}__-->`);let x=[];a=u(a,Q,x,(V)=>`<!--__STX_SCRIPT_EXPR_${V}__-->`);let v=n?.__stx_signals_gate===!0||Oe(e),I=new Set([...Array.isArray(n?.__stx_client_signal_names)?n.__stx_client_signal_names:[],...Hi(Eo(x))]),j=new Set(Array.isArray(n?.__stx_preserved_client_expressions)?n.__stx_preserved_client_expressions:[]);a=An(a,(V,U,q)=>{if(F(U,I))return V;try{let Z=N(U,n,!1,(G)=>sr(G,V,r,e));return Z!==void 0&&Z!==null?String(Z):""}catch(Z){let G=Z instanceof Error?Z.message:String(Z);return y("Expression",`Error evaluating: {{{ ${U.trim()}}}}: ${G}`,r,e,q,V)}},3),a=a.replace(/\{!!([\s\S]*?)!!\}/g,(V,U,q)=>{if(F(U,I))return V;try{let Z=N(U,n,!1,(G)=>sr(G,V,r,e));if(Z===void 0&&n.__stx_buildMode==="compile")return cs("raw",U.trim());return Z!==void 0&&Z!==null?String(Z):""}catch(Z){if(n.__stx_buildMode==="compile")return cs("raw",U.trim());let G=Z instanceof Error?Z.message:String(Z);return y("Expression",`Error evaluating: {!! ${U.trim()} !!}: ${G}`,r,e,q,V)}}),a=u(a,Q,x,(V)=>`<!--__STX_SCRIPT_EXPR_${V}__-->`),a=u(a,l,f,(V)=>`<!--__STX_STYLE_${V}__-->`);let W=v?Gg(a):[],M=ds(a).map((V)=>({...V,names:new Set(oe(`${V.binding} in __slot`))})),L=new Set(gt(n));if(a=yield*$o(a,(V,U,q)=>{let Z=U.trim();if(Gc(a,q,U))return V;if(mo(M,q,Z))return V;if(F(Z,L))return V;if(W.length>0&&mo(W,q,Z))return V;if(j.has(Z))return V;let G=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],H=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,ce=Z.match(H)?.[1],de=ce&&((ce in n)||G.includes(ce)),fe=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,Ce=Z.match(fe),Re=Ce&&!G.includes(Ce[1])&&!(Ce[1]in n);if(/^__[A-Z_]+__$/.test(Z))return"";if(F(Z,I))return V;if(n.__stx_native_screen===!0&&Rl(Z,n))return V;let we;try{let xe=N(U,n,!1,(tt)=>{we=tt});if(v&&!xo(Z,n))return V;if(we)sr(we,V,r,e);if(n.__stx_buildMode==="compile"&&!v&&(xe===void 0||Al(Z,n)))return cs("expr",Z);if(xe===void 0||xe===null)return"";let He=String(xe);return ae(a,q,He,!1,V.length)}catch(xe){if(xe instanceof he)throw xe;if(v&&!xo(Z,n))return V;if(Re)return V;let He=xe instanceof Error?xe.message:String(xe);return y("Expression",`Error evaluating: {{ ${Z} }}: ${He}`,r,e,q,V)}},2,i),x.length>0)a=a.replace(/<!--__STX_SCRIPT_EXPR_(\d+)__-->/g,(V,U)=>x[Number(U)]??V);if(f.length>0)a=a.replace(/<!--__STX_STYLE_(\d+)__-->/g,(V,U)=>f[Number(U)]??V);return a}function P(e,n,r){return So(ko(e,n,r,Number.POSITIVE_INFINITY))}var Pl=100;async function Wi(e,n,r,i=Pl){let a=ko(e,n,r,i),l=a.next();while(!l.done)await R(),l=a.next();return l.value}function Jg(e,n,r){if(!n.trim())return e;let i=e,a=n.trim();while(a.length>0){let l=a.match(/^(\w+)/);if(!l)break;let u=l[1];a=a.substring(u.length).trim();let f=wn[u]||lo[u];if(!f)throw Error(`Filter not found: ${u}. Available filters: ${Object.keys(Kg()).join(", ")}`);let x=[];if(a.startsWith(":")){let v=a.match(/^:([^|\s]+)/);if(v){let I=v[1].trim();try{let j=Number(I);x=[Number.isNaN(j)?I:j]}catch{x=[I]}a=a.substring(v[0].length).trim()}}else if(a.startsWith("(")){let v=1,I=1;while(v>0&&I<a.length){if(a[I]==="(")v++;if(a[I]===")")v--;I++}if(v===0){let j=a.substring(1,I-1).trim();if(j)try{if(j.startsWith("{")&&j.endsWith("}"))x=[N(`(${j})`,r,!0)];else{let W=[],M="",L=null,V=0,U=0,q=0,Z=!1;for(let G=0;G<j.length;G++){let H=j[G];if(Z){M+=H,Z=!1;continue}if(H==="\\"){M+=H,Z=!0;continue}if(L){if(M+=H,H===L)L=null;continue}if(H==='"'||H==="'"||H==="`"){L=H,M+=H;continue}if(H==="(")V++;else if(H===")")V--;else if(H==="[")U++;else if(H==="]")U--;else if(H==="{")q++;else if(H==="}")q--;if(H===","&&V===0&&U===0&&q===0){W.push(M),M="";continue}M+=H}if(M)W.push(M);x=W.map((G)=>{let H=G.trim();return N(H,r,!0)})}}catch{x=[j]}a=a.substring(I).trim()}}try{i=f(i,r,...x)}catch(v){let I=v instanceof Error?v.message:String(v);throw Error(`Error applying filter '${u}': ${I}`)}if(a.startsWith("|"))a=a.substring(1).trim();else break}return i}function Ol(e){let n=!1,r="",i=0,a=0,l=0,u=!1;for(let f=0;f<e.length;f++){let x=e[f],v=e[f+1];if(n&&u){u=!1;continue}if(n&&x==="\\"){u=!0;continue}if(u=!1,(x==='"'||x==="'"||x==="`")&&!u){if(!n)n=!0,r=x;else if(x===r)n=!1,r="";continue}if(n&&r==="`"&&x==="$"&&v==="{"){let I=1;f+=2;while(f<e.length&&I>0){if(e[f]==="{")I++;else if(e[f]==="}")I--;if(I>0)f++}continue}if(n)continue;if(x==="(")i++;else if(x===")")i--;else if(x==="[")a++;else if(x==="]")a--;else if(x==="{")l++;else if(x==="}")l--;if(x==="|"&&i===0&&a===0&&l===0){if(v==="|"){f++;continue}if(v==="="){f++;continue}return f}}return-1}var yn=new Set,jl=1000;function Iy(){yn.clear()}function sr(e,n,r,i){if(!te())return;let a=`${r}\x00${e.expression}`;if(yn.has(a))return;if(yn.size>=jl)yn.clear();yn.add(a);let l=r,u=i;try{if(r&&fo.existsSync(r))u=fo.readFileSync(r,"utf8")}catch{}let f=u.indexOf(n);if(f>=0)l=`${r}:${u.slice(0,f).split(`
|
|
218
|
-
`).length}`;console.warn(`${l}: stx warning: ${n} rendered as an empty string. The safe evaluator rejected \`${e.expression}\` (${e.rule}). Compute the value in <script server> and interpolate the variable instead.`)}function N(e,n,r=!1,i){try{let a=e.trim(),l=Ol(a);if(l>0){let f=a.substring(0,l).trim(),x=a.substring(l+1).trim(),v=N(f,n,!0,i);return Jg(v,x,n)}let u=po(a);if(u!==null){i?.({expression:a,rule:u});return}try{let f=Object.keys(n),x=Object.values(n);return p(a,f)(...x)}catch{return d(a,n)}}catch(a){if(a instanceof ReferenceError){let l=/(\b\w+)\s+is not defined/.exec(a.message);if(l){let u=l[1],f=Ml(u,Object.keys(n));if(f&&f!==u)a.message=`${a.message} \u2014 did you mean '${f}'?`}}if(!r)console.error(`Error evaluating expression: ${e}`,a);throw a}}function Ml(e,n){let r=null;for(let a of n){if(a===e)continue;let l=Nl(e,a);if(r===null||l<r.dist)r={key:a,dist:l}}if(!r)return null;let i=Math.max(e.length,r.key.length);if(r.dist<=2||r.dist/i<=0.35)return r.key;return null}function Nl(e,n){if(e===n)return 0;if(e.length===0)return n.length;if(n.length===0)return e.length;let[r,i]=e.length<n.length?[e,n]:[n,e],a=Array(r.length+1),l=Array(r.length+1);for(let u=0;u<=r.length;u++)a[u]=u;for(let u=1;u<=i.length;u++){l[0]=u;for(let f=1;f<=r.length;f++){let x=r[f-1]===i[u-1]?0:1;l[f]=Math.min(l[f-1]+1,a[f]+1,a[f-1]+x)}for(let f=0;f<=r.length;f++)a[f]=l[f]}return a[r.length]}function Oy(e){if(!e)return"";return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/&/g,"&")}import Ll from"process";function A(e="STX_PUBLIC_"){let n={},r={};for(let[i,a]of Object.entries(Ll.env)){if(!i.startsWith(e)||a===void 0)continue;n[`import.meta.env.${i}`]=JSON.stringify(a),r[i]=a}return n["import.meta.env"]=JSON.stringify(r),n}function Co(e,n=""){let r=`${e}${n}`,i=0;for(let a=0;a<r.length;a++){let l=r.charCodeAt(a);i=(i<<5)-i+l,i=i&i}return`stx-${Math.abs(i).toString(36)}`}function Ro(e,n,r={}){let{prefix:i="",preserveHost:a=!0,scopeKeyframes:l=!0,scopeCustomProperties:u=!1}=r;if(!e.trim())return"";let f=rr(e),x=[],v=new Map;if(l)for(let I of f){let j=I.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(j){let W=j[1],M=`${n}_${W}`;v.set(W,M)}}for(let I of f){let j=Ao(I,n,i,a,v,u);x.push(j)}return x.join(`
|
|
219
|
-
|
|
220
|
-
`)}function rr(e){let n=[],r=e.replace(/\/\*[\s\S]*?\*\//g,""),i=0,a="",l=!1,u="";for(let f=0;f<r.length;f++){let x=r[f];if(x==="@"&&i===0)l=!0;if(x==="{")i++;else if(x==="}"){if(i--,i===0){if(l){u+=x;let v=u.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(v){let[,I,j,W]=v;if(I==="keyframes")n.push({selector:`@keyframes ${j.trim()}`,declarations:W.trim()});else if(I==="media"||I==="supports"||I==="container"){let M=rr(W);n.push({selector:`@${I} ${j.trim()}`,declarations:M.map((L)=>`${L.selector} { ${L.declarations} }`).join(`
|
|
221
|
-
`)})}else n.push({selector:`@${I} ${j.trim()}`,declarations:W.trim()})}u="",l=!1}else if(a.trim()){a+=x;let v=a.match(/([^{]+)\{([^}]*)\}/);if(v)n.push({selector:v[1].trim(),declarations:v[2].trim()});a=""}continue}}if(l)u+=x;else a+=x}return n}function Ao(e,n,r,i,a,l){let{selector:u,declarations:f}=e;if(u.startsWith("@")){if(u.startsWith("@keyframes")){let I=u.replace("@keyframes ","").trim();return`@keyframes ${a.get(I)||I} { ${f} }`}if(u.startsWith("@media")||u.startsWith("@supports")||u.startsWith("@container")){let j=rr(`x { ${f} }`.replace(/x \{ /,"").replace(/ \}$/,"")).map((W)=>Ao(W,n,r,i,a,l)).join(`
|
|
222
|
-
`);return`${u} {
|
|
223
|
-
${j}
|
|
224
|
-
}`}return`${u} { ${f} }`}let x=zl(u,n,r,i),v=f;for(let[I,j]of a)v=v.replace(new RegExp(`\\b${I}\\b`,"g"),j);if(l)v=v.replace(/--([a-z-]+)/gi,`--${n}-$1`);return`${x} { ${v} }`}function zl(e,n,r,i){let a=e.split(",").map((u)=>u.trim()),l=[];for(let u of a){if(u.startsWith(":host")){if(i)l.push(u);else{let v=u.replace(/:host(\([^)]*\))?/,`.${n}$1`);l.push(v)}continue}if(u.includes("::slotted")){l.push(u);continue}if(u===":root"){l.push(`:root .${n}`);continue}let f=r?`${r} .${n}`:`.${n}`;l.push(`${f} ${u}`);let x=Wl(u,n);if(x)l.push(r?`${r} ${x}`:x)}return l.join(", ")}function Wl(e,n){let r=0,i=e.length;for(let x=0;x<e.length;x++){let v=e[x];if(v==="["||v==="(")r++;else if(v==="]"||v===")")r--;else if(r===0&&(v===" "||v===">"||v==="+"||v==="~")){i=x;break}}let a=e.slice(0,i),l=e.slice(i);if(!a)return"";let u=a.length,f=0;for(let x=0;x<a.length;x++){let v=a[x];if(v==="["||v==="(")f++;else if(v==="]"||v===")")f--;else if(r===0&&f===0&&v===":"){u=x;break}}return`${a.slice(0,u)}.${n}${a.slice(u)}${l}`}var Po=String.raw`(?<![\w-])scoped(?![\w-])`,ir=/<style\s+([^>]*)>/gi,To=/<style\s+([^>]*)>([\s\S]*?)<\/style>/gi,Oo=new RegExp(Po,"i"),Vl=new RegExp(Po,"gi"),or=/<style\b[^>]*\bdata-stx-scoped(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?[^>]*>[\s\S]*?<\/style>\s*/gi;function Ul(e){ir.lastIndex=0;let n=ir.exec(e);while(n!==null){if(Oo.test(n[1]))return!0;n=ir.exec(e)}return!1}function Li(e){let n=new Set,r=[];or.lastIndex=0;let i=or.exec(e);while(i!==null){let a=i[0].trim();if(n.has(a))r.push({start:i.index,end:i.index+i[0].length});else n.add(a);i=or.exec(e)}return r}function Cn(e){let n=Li(e);if(n.length===0)return e;let r=Array(n.length+1),i=0;for(let a=0;a<n.length;a++){let l=n[a];r[a]=e.slice(i,l.start),i=l.end}return r[n.length]=e.slice(i),r.join("")}function so(e,n){if(!Ul(e))return{html:e,hasScoped:!1};let r=Co(n),i=`data-v-${r}`,a=e,l=!1;if(To.lastIndex=0,a=a.replace(To,(u,f,x)=>{if(!Oo.test(f))return u;l=!0;let v=Hl(x,i),I=f.replace(Vl,"").trim(),j=I?` ${I}`:"";return`<style data-stx-scoped="${r}"${j}>${v}</style>`}),!l)return{html:e,hasScoped:!1};return a=ql(a,i),{html:a,hasScoped:!0}}function Hl(e,n){return Ro(e,"__SCOPE_PLACEHOLDER__",{preserveHost:!1}).replace(/\.(__SCOPE_PLACEHOLDER__) /g,`[${n}] `).replace(/\.(__SCOPE_PLACEHOLDER__)/g,`[${n}]`)}var Kl=(e)=>`\x00stx-scope-mask-${e}\x00`,Io=/\u0000stx-scope-mask-(\d+)\u0000/g;function ql(e,n){let r=Se(e,(a,l)=>{let u=Q(a,l);return u>l?u:kn(a,l)},(a,l)=>Kl(l)),i=Zl(r.output,n);return Io.lastIndex=0,i.replace(Io,(a,l)=>r.tokens[Number(l)])}function Zl(e,n){let r=new Set(["script","style","template","html","head","body","meta","link","title","base","!doctype","!DOCTYPE"]);return e.replace(/<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(i,a,l)=>{if(r.has(a.toLowerCase()))return i;if(i.includes(n))return i;if(a.toLowerCase()==="style"||a.toLowerCase()==="script")return i;if(l)return i.replace(`<${a}${l}`,`<${a} ${n}${l}`);if(i.endsWith("/>"))return`<${a} ${n} />`;return`<${a} ${n}>`})}var vn=/<\/?template\b[^>]*>/gi,Jl=/(?:^|\s)(?:id\s*=|(?:x-|[@:])(?:for|if|else(?:-if)?)(?=\s|=|$)|#[\w-]+(?:\s*=|\s|$)|v-slot(?::[\w-]+)?(?=\s|=|$)|slot\s*=)/i;function Xl(e){let n=e.replace(/^<template\b/i,"").replace(/>$/,"");return Jl.test(n)}function B(e){vn.lastIndex=0;let n;while((n=vn.exec(e))!==null){if(n[0].startsWith("</")||Xl(n[0]))continue;let r=n.index,i=vn.lastIndex,a=1,l;while((l=vn.exec(e))!==null)if(l[0].startsWith("</")){if(a--,a===0){let u=l.index;return{start:r,openEnd:i,closeStart:u,end:vn.lastIndex,content:e.slice(i,u)}}}else a++;return null}return null}var Gl=0,Yl=0;function gs(e,n){let r=/(?:^|\s)([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g;for(let i of e.matchAll(r))if(i[1].toLowerCase()===n.toLowerCase())return i[2]??i[3]??i[4]??null;return null}function Mo(e){let n=[],r=/<([a-z][a-z0-9-]*)\b((?:"[^"]*"|'[^']*'|[^>"'])*)>/iy;return w(e,(i,a)=>{r.lastIndex=a;let l=r.exec(i);if(!l||!gs(l[2],"x-data"))return-1;return n.push({fullMatch:l[0],tagName:l[1],attributes:l[2],startIndex:a,endIndex:r.lastIndex}),r.lastIndex}),n}function Ql(e){let n=[];for(let{fullMatch:r,tagName:i,attributes:a,startIndex:l}of Mo(e)){let u=gs(a,"x-data");if(!u)continue;let f=`__stx_scope_${Gl++}`,x=gs(a,"x-init"),v=eu(e,i,l+r.length),I=e.slice(l,v.endIndex),j=tu(I);n.push({id:f,selector:`[data-stx-scope="${f}"]`,stateExpr:u,initExpr:x,bindings:[],refs:j})}return n}function eu(e,n,r){let i=1,a=r,l=new RegExp(`<${n}(?:\\s|>)`,"gi"),u=new RegExp(`</${n}>`,"gi"),f=new RegExp(`<${n}[^>]*/\\s*>`,"gi");while(i>0&&a<e.length){l.lastIndex=a,u.lastIndex=a,f.lastIndex=a;let x=l.exec(e),v=u.exec(e),I=f.exec(e);if(I&&I.index<(x?.index??1/0)){a=I.index+I[0].length;continue}if(!v)return{endIndex:e.length};if(x&&x.index<v.index)i++,a=x.index+x[0].length;else{if(i--,i===0)return{endIndex:v.index+v[0].length};a=v.index+v[0].length}}return{endIndex:e.length}}function tu(e){let n=new Map,r=e.replace(/x-data\s*=\s*"[^"]*"/gi,'x-data="__stripped__"').replace(/x-data\s*=\s*'[^']*'/gi,"x-data='__stripped__'"),i=/<[a-z][a-z0-9-]*\s+([^>]*x-ref\s*=\s*["']([^"']*)["'][^>]*)>/gi,a;while((a=i.exec(r))!==null){let[,l,u]=a,f=nu(l);n.set(u,f)}return n}function nu(e){let n=e.match(/\bid\s*=\s*["']([^"']*)["']/);if(n)return n[1];return`__stx_el_${Yl++}`}function su(){return`
|
|
225
|
-
// STX Reactive Runtime - x-cloak and transition CSS
|
|
226
|
-
(function() {
|
|
227
|
-
var style = document.createElement('style');
|
|
228
|
-
style.textContent = [
|
|
229
|
-
'[x-cloak] { display: none !important; }',
|
|
230
|
-
// Default transition classes
|
|
231
|
-
'.stx-enter { opacity: 0; transform: scale(0.95); }',
|
|
232
|
-
'.stx-enter-start { opacity: 0; transform: scale(0.95); }',
|
|
233
|
-
'.stx-enter-active { transition: opacity 150ms ease-out, transform 150ms ease-out; }',
|
|
234
|
-
'.stx-enter-to { opacity: 1; transform: scale(1); }',
|
|
235
|
-
'.stx-leave { opacity: 1; transform: scale(1); }',
|
|
236
|
-
'.stx-leave-start { opacity: 1; transform: scale(1); }',
|
|
237
|
-
'.stx-leave-active { transition: opacity 100ms ease-in, transform 100ms ease-in; }',
|
|
238
|
-
'.stx-leave-to { opacity: 0; transform: scale(0.95); }'
|
|
239
|
-
].join('\\n');
|
|
240
|
-
document.head.appendChild(style);
|
|
241
|
-
})();
|
|
242
|
-
|
|
243
|
-
// STX Reactive Runtime
|
|
244
|
-
/* eslint-disable pickier/no-unused-vars, no-console, prefer-const */
|
|
245
|
-
window.__stx_reactive = (function() {
|
|
246
|
-
'use strict';
|
|
247
|
-
|
|
248
|
-
// Deep reactive proxy that triggers onChange for any mutation
|
|
249
|
-
function reactive(obj, onChange) {
|
|
250
|
-
if (!obj || typeof obj !== 'object') return obj;
|
|
251
|
-
return new Proxy(obj, {
|
|
252
|
-
get(target, prop) {
|
|
253
|
-
const value = target[prop];
|
|
254
|
-
if (value && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Promise)) {
|
|
255
|
-
return reactive(value, onChange);
|
|
256
|
-
}
|
|
257
|
-
return value;
|
|
258
|
-
},
|
|
259
|
-
set(target, prop, value) {
|
|
260
|
-
target[prop] = value;
|
|
261
|
-
onChange(prop, value);
|
|
262
|
-
return true;
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// Initialize an x-data scope: parse state, run init(), register into window.stx._scopes,
|
|
268
|
-
// then let the signals runtime handle all directive processing (x-for, x-text, :bind, etc.)
|
|
269
|
-
function initScope(scopeEl, initialState, bindings, refs, initExpr, deferInit) {
|
|
270
|
-
// Parse initial state (may contain methods including async init())
|
|
271
|
-
var state;
|
|
272
|
-
try {
|
|
273
|
-
state = new Function('return (' + initialState + ')')();
|
|
274
|
-
} catch (e) {
|
|
275
|
-
console.error('[stx-reactive] Invalid x-data:', initialState, e);
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// Build $refs object
|
|
280
|
-
var $refs = {};
|
|
281
|
-
for (var name in refs) {
|
|
282
|
-
if (Object.prototype.hasOwnProperty.call(refs, name)) {
|
|
283
|
-
(function(refName, refId) {
|
|
284
|
-
Object.defineProperty($refs, refName, {
|
|
285
|
-
get: function() { return document.getElementById(refId); }
|
|
286
|
-
});
|
|
287
|
-
})(name, refs[name]);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// Extract init method from state if present (Alpine.js convention)
|
|
292
|
-
var initMethod = state.init;
|
|
293
|
-
if (typeof initMethod === 'function') {
|
|
294
|
-
delete state.init;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// Make state reactive \u2014 mutations trigger re-render via signals
|
|
298
|
-
var scopeId = scopeEl.getAttribute('data-stx-scope');
|
|
299
|
-
var stx = window.stx;
|
|
300
|
-
|
|
301
|
-
// Create signals for each state property so the signals runtime can track dependencies
|
|
302
|
-
var signalState = {};
|
|
303
|
-
var rawState = {};
|
|
304
|
-
var derivedState = {};
|
|
305
|
-
var accessors = {};
|
|
306
|
-
// A getter must NOT be read here. Reading one calls it, and the old loop did
|
|
307
|
-
// exactly that: the returned value is not a function, so it was wrapped as a
|
|
308
|
-
// plain state() -- a snapshot of the answer at construction time, frozen
|
|
309
|
-
// forever while plain properties beside it updated (#2053). A getter is a
|
|
310
|
-
// derived value, so it is registered as one below, once ctxProxy exists for
|
|
311
|
-
// it to read through.
|
|
312
|
-
var ownDescriptors = Object.getOwnPropertyDescriptors ? Object.getOwnPropertyDescriptors(state) : {};
|
|
313
|
-
for (var key in state) {
|
|
314
|
-
if (Object.prototype.hasOwnProperty.call(state, key)) {
|
|
315
|
-
var descriptor = ownDescriptors[key];
|
|
316
|
-
if (descriptor && typeof descriptor.get === 'function') {
|
|
317
|
-
accessors[key] = descriptor;
|
|
318
|
-
continue;
|
|
319
|
-
}
|
|
320
|
-
if (typeof state[key] === 'function') {
|
|
321
|
-
// Methods \u2014 bind to a proxy so 'this.prop = val' triggers signal updates
|
|
322
|
-
signalState[key] = state[key];
|
|
323
|
-
} else {
|
|
324
|
-
// Data properties \u2014 wrap in signals for reactivity
|
|
325
|
-
signalState[key] = stx.state(state[key]);
|
|
326
|
-
rawState[key] = true;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// Create a proxy context that auto-unwraps signals and writes back through them.
|
|
332
|
-
// Methods get 'this' bound to this proxy so this.foo = bar triggers reactivity.
|
|
333
|
-
var ctx = {};
|
|
334
|
-
var ctxProxy = new Proxy(ctx, {
|
|
335
|
-
get: function(target, prop) {
|
|
336
|
-
if (prop === '$refs') return $refs;
|
|
337
|
-
if (prop === '$el') return scopeEl;
|
|
338
|
-
if (prop === '$nextTick') return function(fn) { requestAnimationFrame(fn); };
|
|
339
|
-
if (prop === Symbol.unscopables) return undefined;
|
|
340
|
-
if (!(prop in signalState)) {
|
|
341
|
-
var owner = stx._scopeForBinding(scopeEl, prop);
|
|
342
|
-
return owner ? owner[prop] : undefined;
|
|
343
|
-
}
|
|
344
|
-
var s = signalState[prop];
|
|
345
|
-
if (!s) return undefined;
|
|
346
|
-
if (rawState[prop] && s && typeof s === 'function' && typeof s.value !== 'undefined') {
|
|
347
|
-
return s.value; // unwrap signal
|
|
348
|
-
}
|
|
349
|
-
if (typeof s === 'function' && !rawState[prop]) {
|
|
350
|
-
return s.bind(ctxProxy); // bind methods to proxy
|
|
351
|
-
}
|
|
352
|
-
return s;
|
|
353
|
-
},
|
|
354
|
-
set: function(target, prop, value) {
|
|
355
|
-
var accessor = derivedState[prop];
|
|
356
|
-
if (accessor) {
|
|
357
|
-
// A getter/setter pair writes through its setter. A getter alone has
|
|
358
|
-
// nowhere to put the value: a derived has no .value setter, so the
|
|
359
|
-
// assignment would be a silent no-op, which is the same class of
|
|
360
|
-
// failure as the stale read this replaces.
|
|
361
|
-
if (typeof accessor.set === 'function') {
|
|
362
|
-
accessor.set.call(ctxProxy, value);
|
|
363
|
-
return true;
|
|
364
|
-
}
|
|
365
|
-
console.warn('[stx-reactive] cannot assign to ' + String(prop) + ': it is a getter in x-data, so its value comes from what it reads. Give it a setter, or make it a plain property.');
|
|
366
|
-
return true;
|
|
367
|
-
}
|
|
368
|
-
var s = signalState[prop];
|
|
369
|
-
if (rawState[prop] && s && typeof s === 'function') {
|
|
370
|
-
s.value = value; // write through signal \u2014 triggers effects
|
|
371
|
-
} else {
|
|
372
|
-
signalState[prop] = value;
|
|
373
|
-
}
|
|
374
|
-
return true;
|
|
375
|
-
},
|
|
376
|
-
has: function(target, prop) {
|
|
377
|
-
return prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick' || !!stx._scopeForBinding(scopeEl, prop);
|
|
378
|
-
},
|
|
379
|
-
ownKeys: function() {
|
|
380
|
-
return Object.keys(signalState).concat(['$refs', '$el', '$nextTick']);
|
|
381
|
-
},
|
|
382
|
-
getOwnPropertyDescriptor: function(target, prop) {
|
|
383
|
-
if (prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick') {
|
|
384
|
-
return { configurable: true, enumerable: true, writable: true, value: ctxProxy[prop] };
|
|
385
|
-
}
|
|
386
|
-
return undefined;
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
// Now that ctxProxy exists, a getter becomes a derived that reads through it,
|
|
391
|
-
// so it tracks whatever it touches and recomputes when that changes. derived()
|
|
392
|
-
// is lazy, so nothing is evaluated until a binding actually reads it.
|
|
393
|
-
//
|
|
394
|
-
// Marked rawState as well: that is what makes the proxy unwrap it and what
|
|
395
|
-
// exposes the signal itself to the runtime below, which is where dependency
|
|
396
|
-
// tracking comes from. A getter needs both, exactly like a data property.
|
|
397
|
-
for (var accessorKey in accessors) {
|
|
398
|
-
if (Object.prototype.hasOwnProperty.call(accessors, accessorKey)) {
|
|
399
|
-
(function(name, descriptor) {
|
|
400
|
-
signalState[name] = stx.derived(function() {
|
|
401
|
-
return descriptor.get.call(ctxProxy);
|
|
402
|
-
});
|
|
403
|
-
rawState[name] = true;
|
|
404
|
-
derivedState[name] = descriptor;
|
|
405
|
-
})(accessorKey, accessors[accessorKey]);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
// Build scope vars for the signals runtime \u2014 it reads these for expression evaluation.
|
|
410
|
-
// We need to provide getter/setter descriptors so signals track properly.
|
|
411
|
-
var scopeVars = {};
|
|
412
|
-
for (var k in signalState) {
|
|
413
|
-
if (Object.prototype.hasOwnProperty.call(signalState, k)) {
|
|
414
|
-
if (rawState[k]) {
|
|
415
|
-
// Data: expose the signal directly so expressions trigger dependency tracking
|
|
416
|
-
scopeVars[k] = signalState[k];
|
|
417
|
-
} else {
|
|
418
|
-
// Method: bind to ctxProxy so 'this' works
|
|
419
|
-
scopeVars[k] = (typeof signalState[k] === 'function') ? signalState[k].bind(ctxProxy) : signalState[k];
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
scopeVars.$refs = $refs;
|
|
424
|
-
scopeVars.$el = scopeEl;
|
|
425
|
-
scopeVars.$nextTick = function(fn) { requestAnimationFrame(fn); };
|
|
426
|
-
|
|
427
|
-
// Register scope \u2014 merge with any existing vars from partial signal scripts
|
|
428
|
-
if (!stx._scopes) stx._scopes = {};
|
|
429
|
-
var registered = stx._scopes[scopeId] = Object.assign(stx._scopes[scopeId] || {}, scopeVars);
|
|
430
|
-
registered.__el = scopeEl;
|
|
431
|
-
|
|
432
|
-
// Store on element for findElementScope
|
|
433
|
-
scopeEl.__stx_scope = scopeVars;
|
|
434
|
-
|
|
435
|
-
// Run init() if present (supports async)
|
|
436
|
-
function runInit() {
|
|
437
|
-
var maybePromise;
|
|
438
|
-
if (initMethod) {
|
|
439
|
-
maybePromise = initMethod.call(ctxProxy);
|
|
440
|
-
}
|
|
441
|
-
if (initExpr) {
|
|
442
|
-
try {
|
|
443
|
-
var fn = new Function('with(this){' + initExpr + ';}');
|
|
444
|
-
var result = fn.call(ctxProxy);
|
|
445
|
-
if (result && typeof result.then === 'function') maybePromise = result;
|
|
446
|
-
} catch (e) {
|
|
447
|
-
console.warn('[stx-reactive] init expression error:', e);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
// If init is async, signal updates will trigger effects automatically
|
|
451
|
-
// when init() resolves and sets this.prop = value (writes through signal)
|
|
452
|
-
if (maybePromise && typeof maybePromise.then === 'function') {
|
|
453
|
-
maybePromise.catch(function(e) {
|
|
454
|
-
console.error('[stx-reactive] async init() error:', e);
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
// A component's helper setup follows its markup. Its own mount queue
|
|
460
|
-
// starts the initializer after all component factories have registered.
|
|
461
|
-
// Standalone x-data retains synchronous initialization.
|
|
462
|
-
if (deferInit) {
|
|
463
|
-
registered.__mountCallbacks = registered.__mountCallbacks || [];
|
|
464
|
-
registered.__mountCallbacks.push(runInit);
|
|
465
|
-
} else {
|
|
466
|
-
runInit();
|
|
467
|
-
}
|
|
468
|
-
var destroyExpr = scopeEl.getAttribute('data-stx-xdestroy') || scopeEl.getAttribute('x-destroy');
|
|
469
|
-
if (destroyExpr) {
|
|
470
|
-
registered.__destroyCallbacks = registered.__destroyCallbacks || [];
|
|
471
|
-
var teardown = function() { scopeEl.__stx_execute(destroyExpr); };
|
|
472
|
-
registered.__destroyCallbacks.push(teardown);
|
|
473
|
-
registered.__destroyHooks = registered.__destroyHooks || [];
|
|
474
|
-
registered.__destroyHooks.push(teardown);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
// Expose for debugging
|
|
478
|
-
scopeEl.__stx_state = ctxProxy;
|
|
479
|
-
scopeEl.__stx_execute = function(stmt, $event, $el) {
|
|
480
|
-
try {
|
|
481
|
-
// Run the statement with the reactive proxy as the lexical scope.
|
|
482
|
-
// Wrapping in a with-block on the proxy makes bare reads/writes go
|
|
483
|
-
// through it (so foo = bar triggers signal.set()) instead of treating
|
|
484
|
-
// each state key as a local function parameter \u2014 bare assignments
|
|
485
|
-
// would otherwise just rebind the local and never reach the signal.
|
|
486
|
-
var fn = new Function('$event', '$el', 'with(this){' + stmt + ';}');
|
|
487
|
-
fn.call(ctxProxy, $event, $el);
|
|
488
|
-
} catch (e) {
|
|
489
|
-
console.warn('[stx-reactive] execute error:', e);
|
|
490
|
-
}
|
|
491
|
-
};
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
return { initScope: initScope, reactive: reactive };
|
|
495
|
-
})();
|
|
496
|
-
`}function jo(e,n){let r=e.replace(/\{!!([\s\S]*?)!!\}/g,(f,x)=>{try{let v=N(x,n,!0);if(v===void 0)return f;return String(v)}catch{return f}}),i="",a=0,l=null;while(a<r.length){let f=r[a];if(l&&f==="\\"){i+=f+(r[a+1]??""),a+=2;continue}if(f==="{"&&r[a+1]==="{"){let x=r.indexOf("}}",a+2);if(x!==-1){let v=r.slice(a,x+2);i+=u(r.slice(a+2,x),v,l),a=x+2;continue}}if(l){if(f===l)l=null}else if(f==="'"||f==='"'||f==="`")l=f;i+=f,a++}return i;function u(f,x,v){let I;try{I=N(f,n,!0)}catch{return x}if(I===void 0)return x;if(v){let j=String(I).replace(/\\/g,"\\\\").replace(new RegExp(v==="`"?"`":v,"g"),`\\${v}`).replace(/\r/g,"\\r").replace(/\n/g,"\\n");return v==="`"?j.replace(/\$\{/g,"\\${"):j}if(typeof I==="string"){let j=I.trim();if(j.startsWith("{")&&j.endsWith("}")||j.startsWith("[")&&j.endsWith("]"))try{return JSON.parse(j),j}catch{}}return JSON.stringify(I)}}function ru(e,n,r){if(e.length===0)return"";let i=e.map((a)=>{let l=JSON.stringify(Object.fromEntries(a.refs)),u=jo(a.stateExpr,n),f=a.initExpr?jo(a.initExpr,n):null,x=JSON.stringify(u),v=f?JSON.stringify(f):"null";return`
|
|
497
|
-
(function() {
|
|
498
|
-
var scopeEl = document.querySelector('${a.selector}');
|
|
499
|
-
if (!scopeEl) return;
|
|
500
|
-
var refs = ${l};
|
|
501
|
-
window.__stx_reactive.initScope(scopeEl, ${x}, [], refs, ${v}${r?", true":""});
|
|
502
|
-
})();`}).join(`
|
|
503
|
-
`);return`
|
|
504
|
-
<script data-stx-scoped data-stx-reactive data-stx-run="always">
|
|
505
|
-
${su()}
|
|
506
|
-
${i}
|
|
507
|
-
</script>`}function pl(e,n,r,i=!1){if(!ar(e))return e;let a=Ql(e);if(a.length===0)return e;let l=iu(e,a),u=ru(a,n,i),f=c(l);if(f!==-1)l=l.slice(0,f)+u+`
|
|
508
|
-
`+l.slice(f);else l+=u;return l}function iu(e,n){let r=[],i=0;for(let[l,u]of Mo(e).entries()){let f=n[l];if(!f)break;r.push(e.slice(i,u.startIndex));let x=gs(u.attributes,"data-stx-scope");if(x)f.id=x,f.selector=`[data-stx-scope="${f.id}"]`,r.push(u.fullMatch);else r.push(`<${u.tagName} data-stx-scope="${f.id}"${u.attributes}>`);i=u.endIndex}r.push(e.slice(i));let a=r.join("");return a=a.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),a=a.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),a=a.replace(/\s*x-init\s*=\s*"([^"]*)"/g,' data-stx-xinit="$1"'),a=a.replace(/\s*x-init\s*=\s*'([^']*)'/g," data-stx-xinit='$1'"),a=a.replace(/\s*x-destroy\s*=\s*"([^"]*)"/g,' data-stx-xdestroy="$1"'),a=a.replace(/\s*x-destroy\s*=\s*'([^']*)'/g," data-stx-xdestroy='$1'"),a}function ar(e){return/x-data\s*=\s*["']/.test(e)}function io(e,n){let r=e,i=/@json\s*\(/g,a;while((a=i.exec(r))!==null){let l=a.index,u=l+a[0].length-1,f=1,x=u+1,v=null,I=!1;while(x<r.length&&f>0){let G=r[x];if(I){I=!1,x++;continue}if(G==="\\"&&v){I=!0,x++;continue}if(v){if(G===v)v=null;x++;continue}if(G==='"'||G==="'"||G==="`"){v=G,x++;continue}if(G==="(")f++;else if(G===")"){if(f--,f===0)break}x++}if(f!==0)break;let j=r.substring(u+1,x).trim(),W=r.substring(l,x+1),M=-1,L=0,V=null,U=!1;for(let G=0;G<j.length;G++){let H=j[G];if(U){U=!1;continue}if(H==="\\"&&V){U=!0;continue}if(V){if(H===V)V=null;continue}if(H==='"'||H==="'"||H==="`"){V=H;continue}if(H==="("||H==="["||H==="{")L++;else if(H===")"||H==="]"||H==="}")L--;if(H===","&&L===0){M=G;break}}let q=M>=0?j.substring(0,M).trim():j,Z=M>=0?j.substring(M+1).trim():void 0;try{let G=q.trim(),H;if(m(G))H=p(G,Object.keys(n))(...Object.values(n));else H=void 0;let ne;if(Z==="true")ne=JSON.stringify(H,null,2);else ne=JSON.stringify(H);let ce=ne.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");r=r.substring(0,l)+ce+r.substring(x+1),i.lastIndex=l+ce.length}catch(G){K.log(G instanceof Error?G:Error(String(G)),{directive:"@json"},"error"),i.lastIndex=l+W.length}}return r}function ao(e){return e.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function fl(e){let n=e,r=/@memo\s*\(/g,i,a=[];while((i=r.exec(n))!==null){let l=i.index,u=l+i[0].length,f=1,x=u;while(x<n.length&&f>0){if(n[x]==="(")f++;else if(n[x]===")")f--;x++}if(f!==0)continue;let v=n.slice(u,x-1).trim(),I=x,j=n.slice(I),W=j.indexOf("@endmemo");if(W===-1)continue;let M=j.slice(0,W),L=I+W+8,V=Ht(M),U=M.slice(V),q=M.match(/(\s*)$/),Z=q?q[0].length:0,G=U.slice(0,U.length-Z),H=G.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),ne;if(H){let[ce,de,fe="",Ce]=H,Re=`<${de}${fe} data-stx-memo="${v}"${Ce}>`;ne=M.slice(0,V)+Re+G.slice(ce.length)+M.slice(V+G.length)}else ne=`${M.slice(0,V)}<div data-stx-memo="${v}">${G}</div>${M.slice(V+G.length)}`;a.push({start:l,end:L,replacement:ne}),r.lastIndex=L}for(let l=a.length-1;l>=0;l--){let u=a[l];n=n.slice(0,u.start)+u.replacement+n.slice(u.end)}return n.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function ji(e){let n=e.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return n=n.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),n}function zo(e,n){let r=/<\/?([a-zA-Z][\w-]*)\b(?:"[^"]*"|'[^']*'|[^'">])*>/y,i=w(e,(f,x)=>{r.lastIndex=x;let v=r.exec(f);if(!v||/^(?:script|style)$/i.test(v[1]))return-1;return r.lastIndex}),a=[],l=0,u=[];for(let{start:f,end:x,token:v}of i){let I=/^<\/?([\w-]+)/.exec(v)[1].toLowerCase();if(v.startsWith("</")){while(a.length&&a.pop()!==I);continue}if(!a.length&&!/\sdata-stx-slot-owner\s*=/.test(v))u.push(e.slice(l,f),v.replace(/\s*\/?>$/,(j)=>` data-stx-slot-owner="${n}"${j}`)),l=x;if(!cr.has(I)&&!/\/>$/.test(v))a.push(I)}return u.push(e.slice(l)),u.join("")}function Bo(e,n){if(!/\bref\s*=/.test(e))return e;let r=/<\/?([a-zA-Z][\w-]*)\b(?:"[^"]*"|'[^']*'|[^'">])*>/y,i=w(e,(x,v)=>{r.lastIndex=v;let I=r.exec(x);if(!I||/^(?:script|style)$/i.test(I[1]))return-1;return r.lastIndex}),a=[],l=0,u=0,f=[];for(let{start:x,end:v,token:I}of i){let j=/^<\/?([\w-]+)/.exec(I)[1].toLowerCase();if(I.startsWith("</")){let V;while(V=a.pop()){if(V.scoped)l--;if(V.name===j)break}continue}let W=/\sdata-stx-scope\s*=/.test(I),M=/\sdata-stx-ref-caller\s*=\s*(["'])(.*?)\1/.exec(I),L=a.find((V)=>V.scoped)?.scopeId;if(M&&L&&M[2]===L)f.push(e.slice(u,x),I.replace(M[0],` data-stx-ref-caller="${n}"`)),u=v;else if(!l&&!W&&/\s(?:ref|@ref|:ref|x-ref|data-stx-ref)\s*=/.test(I)&&!/\sdata-stx-ref-caller\s*=/.test(I))f.push(e.slice(u,x),I.replace(/\s*\/?>$/,(V)=>` data-stx-ref-caller="${n}"${V}`)),u=v;if(!cr.has(j)&&!/\/>$/.test(I)){let V=/\sdata-stx-scope\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(I);if(a.push({name:j,scoped:W,scopeId:V?.[1]??V?.[2]}),W)l++}}return f.push(e.slice(u)),f.join("")}var cr=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Wo=/(?:^|\s)x-no-cloak(?:=|\s|\/|>|$)/,Do=/<\/?\s*([a-z][\w-]*)/iy,ou=/\s/;function au(e,n){let r=n-1;while(r>=0&&ou.test(e[r]))r--;return r>=0&&e[r]==="/"}function cu(e,n){let r=!1,i=!1;for(let a=n;a<e.length;a++){let l=e[a];if(r){if(l==="'")r=!1}else if(i){if(l==='"')i=!1}else if(l==="'")r=!0;else if(l==='"')i=!0;else if(l===">")return a}return-1}function lu(e,n){if(e.indexOf("{",n)===-1||e.indexOf("}",n)===-1)return!1;let r=0,i=n,a=!1,l=!1,u=!1;while(i<e.length){let f=e.indexOf("<",i),x=f===-1?e.length:f;if(x>i){if(r===0)while(i<x){let j=e.indexOf(l?"}":"{",i);if(j===-1||j>=x){if(l)u=!1;else a=!1;break}if(j>i)if(l)u=!1;else a=!1;if(l){if(u)return!0;u=!0}else if(a)l=!0,u=!1;else a=!0;i=j+1}i=x;continue}if(e.startsWith("<!--",i)){let j=e.indexOf("-->",i);i=j===-1?e.length:j+3;continue}let v=cu(e,i);if(v===-1)break;Do.lastIndex=i;let I=Do.exec(e)?.[1]?.toLowerCase()??"";if(e[i+1]==="/"){if(r===0)break;r--}else if(!au(e,v)&&!cr.has(I))r++;i=v+1}return!1}var No=S(256);function gl(e){if(e.length<1024)return Lo(e);let n=C(e),r=No.get(n);if(r!==void 0)return r;let i=Lo(e);return No.set(n,i),i}function Lo(e){if(e.length>=32768&&!vi(e))return e;let r=new RegExp(`<(${"div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i"})\\b`,"gi"),i="",a=0,l;while((l=r.exec(e))!==null){let u=l.index,f=u+l[0].length,x=!1,v=!1,I=-1;while(f<e.length){let W=e[f];if(x){if(W==="'")x=!1}else if(v){if(W==='"')v=!1}else if(W==="'")x=!0;else if(W==='"')v=!0;else if(W===">"){I=f;break}f++}if(I===-1)continue;let j=e.slice(u,I+1);if(Wo.test(j))continue;if(j.includes("x-cloak"))continue;if(lu(e,I+1))i+=e.slice(a,I)+" x-cloak>",a=I+1}return i+=e.slice(a),i}var uu=/(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/,pu=/<\/script>/gi,fu=/<\/style>/gi;function ml(e){let n=/<[a-z][\w-]*/gi,r="",i=0,a;while((a=n.exec(e))!==null){let l=a.index,u=a[0].slice(1).toLowerCase();if(u==="script"||u==="style"){let L=u==="script"?pu:fu;L.lastIndex=l;let V=L.exec(e);if(V!==null)n.lastIndex=V.index+V[0].length;continue}let f=l+a[0].length,x=!1,v=!1,I=-1;while(f<e.length){let L=e[f];if(x){if(L==="'")x=!1}else if(v){if(L==='"')v=!1}else if(L==="'")x=!0;else if(L==='"')v=!0;else if(L===">"){I=f;break}f++}if(I===-1)continue;let j=e.slice(l+a[0].length,I);if(Wo.test(j))continue;if(/(?:^|\s)x-cloak(?:=|\s|\/|>|$)/.test(j))continue;if(!uu.test(j))continue;let W=e[I-1]==="/",M=W?I-1:I;r+=`${e.slice(i,M)} x-cloak${W?" ":""}`,i=M}return r+=e.slice(i),r}function O(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 vt(e){let n=e.get("type");return typeof n!=="string"||!n.trim()||/^(?:module|(?:text|application)\/(?:javascript|typescript|ecmascript))$/i.test(n.trim())}import fa from"path";import ur from"fs";import Sn from"path";function Fo(e,n,r,i){let a=0;for(let l=n;l<e.length;l++)if(e[l]===r)a++;else if(e[l]===i&&!(i===">"&&e[l-1]==="=")){if(--a===0)return l}return-1}function du(e){let n=t(e),r=0,i=0,a=[];for(let l=0;l<n.length;l++)if("([{".includes(n[l]))r++;else if(")]}".includes(n[l]))r--;else if(n[l]===","&&r===0)a.push(e.slice(i,l).trim()),i=l+1;return a.push(e.slice(i).trim()),a}function lr(e,n){let r=t(e),i=new RegExp(`\\b(?:${n.map((a)=>a.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g");for(let a of r.matchAll(i)){let l=a.index+a[0].length,u="";if(r[l]==="<"){let x=Fo(r,l,"<",">");if(x<0)continue;u=e.slice(l+1,x),l=x+1;while(/\s/.test(r[l]||"")&&l<r.length)l++}if(r[l]!=="(")continue;let f=Fo(r,l,"(",")");if(f>=0)return{type:u,args:du(e.slice(l+1,f))}}return null}var ms=`
|
|
509
|
-
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;
|
|
510
|
-
type __StxWiden<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
|
|
511
|
-
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>;
|
|
512
|
-
type __StxRequired<O> = { [K in keyof O]-?: O[K] extends { required: true } ? K : never }[keyof O];
|
|
513
|
-
type __StxDefaulted<O> = { [K in keyof O]-?: O[K] extends { default: unknown } ? K : never }[keyof O];
|
|
514
|
-
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]> };
|
|
515
|
-
type __StxDefaults<P, K> = Omit<P, Extract<keyof P, K>> & Partial<Pick<P, Extract<keyof P, K>>>;
|
|
516
|
-
`;function hs(e,n){let r=[],i={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},a=t(e),l=e.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(W,M,L,V,U)=>{if(a.slice(U,U+6)!=="import")return W;if(V.endsWith(".stx"))return"";let q=`${n}Import${r.length}`;if(r.push(`import * as ${q} from ${JSON.stringify(V)};`),M.startsWith("*"))return`import ${M.replace(/^\*\s+as\s+/,"")} = ${q};`;if(!M.startsWith("{"))return`import ${M} = ${q}.default;`;return M.slice(1,-1).split(",").map((Z)=>{let[G,H=G]=Z.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(!G)return"";if(/^(?:stx|@stacksjs\/stx)(?:\/|$)/.test(V)&&G in i)i[G].push(H);return`import ${H} = ${q}.${G};`}).join(`
|
|
517
|
-
`)}),u=lr(e,i.defineProps),f=lr(e,i.defineEmits),x=lr(e,i.withDefaults);if(!u&&!f)return{declarations:"",props:null,events:null};let v=[],I=null,j=null;if(u){v.push(`const __options = (${u.args[0]||"{}"}) as const;`),v.push(`const __defaults = (${x?.args[1]||"{}"});`);let W=u.type||"__StxOptions<typeof __options>";v.push(`export type __StxProps = __StxDefaults<${W}, keyof typeof __defaults | __StxDefaulted<typeof __options>>;`),I=`${n}.__StxProps`}if(f)v.push(`const __events = (${f.args[0]||"[]"}) as const;`),v.push(`export type __StxEvents = ${f.type||"Record<(typeof __events)[number], any[]>"};`),j=`${n}.__StxEvents`;return{declarations:`${r.join(`
|
|
518
|
-
`)}
|
|
519
|
-
namespace ${n} {
|
|
520
|
-
${l}
|
|
521
|
-
${v.join(`
|
|
522
|
-
`)}
|
|
523
|
-
}`,props:I,events:j}}var Dr=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 Lr(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...Dr].some((n)=>n.toLowerCase()===e.toLowerCase());return Dr.has(e)||/[A-Z]/.test(e)}function*gu(e){let n=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,r;while(r=n.exec(e)){let i=n.lastIndex,a=[];while(i<e.length){while(/\s/.test(e[i]||""))i++;if(e[i]===">"||e.slice(i,i+2)==="/>"){i+=e[i]===">"?1:2;break}let l=/^[^\s=/>]+/.exec(e.slice(i))?.[0];if(!l){i++;continue}let u=i;i+=l.length;while(/\s/.test(e[i]||""))i++;if(e[i]!=="="){a.push({name:l,value:!0,offset:u,braced:!1});continue}i++;while(/\s/.test(e[i]||""))i++;let f=e[i],x=f==="{",v=f==='"'||f==="'";if(v||x)i++;let I=i;if(x){let j=t(e.slice(i)),W=1,M=0;for(;M<j.length;M++){if(j[M]==="{")W++;if(j[M]==="}"&&--W===0)break}i+=M}else if(v)while(i<e.length&&e[i]!==f)i++;else while(i<e.length&&!/[\s/>]/.test(e[i]))i++;if(a.push({name:l,value:e.slice(I,i),offset:I,braced:x}),v||x)i++}n.lastIndex=i,yield{name:r[1],offset:r.index,attributes:a}}}function Vo(e,n,r){let i=[],a=[ms,"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;'],l=new Map,u=new Map,f=new Map,x=r.scriptCode(e,r.filePath),v=t(x);for(let L of x.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(v.slice(L.index,L.index+6)!=="import")continue;let V=L[2],U=Sn.isAbsolute(V)||V.startsWith(".")?Sn.resolve(Sn.dirname(r.filePath),V):Js(V,Sn.dirname(r.filePath));if(!U)continue;let q=U.endsWith(".stx")?U:ur.existsSync(`${U}.stx`)?`${U}.stx`:void 0,Z=q?null:Pr(U,!1),G=L[1].startsWith("{")?L[1].slice(1,-1).split(","):[L[1]];for(let H of G){let[ne,ce=ne]=H.trim().split(/\s+as\s+/),de=q||Z?.get(ne)||Z?.get(ne.toLowerCase());if(de)f.set(ce,de),f.set(ce.toLowerCase(),de),f.set(ce.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),de)}}for(let L of n.matchAll(/@import\s*\(([^)]+)\)/g))for(let V of L[1].matchAll(/['"]([^'"]+)['"]/g)){let U=Ys(V[1],r.filePath,r).find((q)=>ur.statSync(q,{throwIfNoEntry:!1})?.isFile());if(U)f.set(Sn.basename(V[1]).replace(/\.stx$/,""),U)}let I={__importedComponents:f},j=new Map,W=(L,V,U)=>{let q=e.slice(0,L);return{code:V,offset:L,attribute:U,anchor:!0,kind:"directive",line:q.split(`
|
|
524
|
-
`).length,column:L-q.lastIndexOf(`
|
|
525
|
-
`)}},M=(L,V,U)=>i.push({expression:L,statement:{text:V+L.code+U,prefixLength:V.length}});for(let L of gu(n)){if(Lr(L.name)||L.name==="component")continue;let V=ri(L.name,r.filePath,r,I);if(!V)continue;let U=j.get(V);if(!U){let Z;try{Z=r.readComponent?r.readComponent(V):ur.readFileSync(V,"utf8")}catch{continue}if(Z===void 0)continue;u.set(V,Z),U=hs(r.scriptCode(Z,V),`__StxComponent${j.size}`),j.set(V,U),a.push(U.declarations)}let q=[];for(let Z of L.attributes){let{name:G,offset:H}=Z,ne=Z.value===!0?"true":Z.value;if(G.startsWith("@")||G.startsWith("v-on:")){if(U.events&&Z.value!==!0)l.set(H,`__StxEvent<${U.events}, ${JSON.stringify(G.replace(/^@|^v-on:/,"").split(".")[0])}>`);continue}let ce=/^v-model(?::([\w-]+))?(?:\.[\w-]+)*$/.exec(G);if(G.startsWith("v-")&&!G.startsWith("v-bind:")&&!ce)continue;if(/^(?:x-|:)(?:if|for|show|key|else)(?:$|[.:-])/.test(G))continue;let de=(ce?ce[1]||"modelValue":G.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(we,xe)=>xe.toUpperCase());if(q.push(de),!U.props)continue;let fe=G.startsWith(":")||G.startsWith("v-bind:")||!!ce||Z.braced,Ce=fe?ne:Z.value!==!0?JSON.stringify(ne):"true",Re=!fe&&Z.value!==!0&&(ne==="true"||ne==="false");M(W(H,Ce,G),";void ((",`) satisfies ${Re?"__StxStaticProp":"__StxProp"}<${U.props}, ${JSON.stringify(de)}>);`)}if(U.props){let Z=[...new Set(q)].map((H)=>`${JSON.stringify(H)}: undefined as any`).join(", "),G=W(L.offset,`<${L.name}>`);i.push({expression:G,statement:{text:`;void ({ ${Z} } satisfies ${U.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:j.size?a.join(`
|
|
526
|
-
`):"",checks:i,events:l,dependencies:u}}import ea from"fs";import dt from"path";var mt=["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"];import{mkdir as Ho,readFile as bu,readdir as yu,realpath as _u,stat as Ko,writeFile as wu}from"fs/promises";import st from"path";import{builtinModules as vu}from"module";function mu(e){let n=new Mn(e,"javascript").tokenize(),r=e;for(let i of n.reverse())if(i.type==="COMMENT")r=r.slice(0,i.start)+i.value.replace(/[^\r\n]/g," ")+r.slice(i.end);return r}function Tt(e,n,r,i){if(e[n]!==r)return-1;let a=0,l=null;for(let u=n;u<e.length;u++){let f=e[u];if(l){if(f==="\\"){u++;continue}if(f===l)l=null;continue}if(f==="'"||f==='"'||f==="`"){l=f;continue}if(f===r)a++;else if(f===i){if(i===">"&&e[u-1]==="=")continue;if(a--,a===0)return u+1}}return-1}function nn(e,n,r){let i=r?"([{<":"([{",a=r?")]}>":")]}",l=[],u=0,f=null,x="";for(let v=0;v<e.length;v++){let I=e[v];if(f){if(x+=I,I==="\\"){x+=e[++v]??"";continue}if(I===f)f=null;continue}if(I==="'"||I==='"'||I==="`"){f=I,x+=I;continue}if(i.includes(I))u++;else if(a.includes(I)&&!(r&&I===">"&&e[v-1]==="="))u--;if(u===0&&n.includes(I)){l.push(x),x="";continue}x+=I}return l.push(x),l.map((v)=>v.trim()).filter(Boolean)}function hu(e){let n=0,r=null;for(let i=0;i<e.length;i++){let a=e[i];if(r){if(a==="\\"){i++;continue}if(a===r)r=null;continue}if(a==="'"||a==='"'||a==="`"){r=a;continue}if("([{".includes(a))n++;else if(")]}".includes(a))n--;if(n!==0||a!=="=")continue;let l=e[i-1];if(e[i+1]==="="||l==="="||l==="!"||l==="<"||l===">")continue;return i}return-1}function Uo(e){switch(e.trim()){case"String":return"string";case"Number":return"number";case"Boolean":return"boolean";case"Array":return"unknown[]";case"Object":return"Record<string, unknown>";default:return}}function sn(e){let n=mu(e);for(let r of new Set(Xr(n).map((i)=>i.start))){let i=xu(n,r);if(i)return{...i,text:e.slice(r,r+i.text.length)}}return null}function xu(e,n){let r=Object.create(null),i=Object.create(null),a=[],l=Object.create(null),u=Object.create(null),f=n+(/^(?:const|let|var)\s+/.exec(e.slice(n))?.[0].length??0),x=()=>{while(f<e.length&&/\s/.test(e[f]))f++},v;if(e[f]==="{"){let q=Tt(e,f,"{","}");if(q===-1)return null;v=e.slice(f,q),f=q}else{let q=/^[A-Za-z_$][\w$]*/.exec(e.slice(f));if(!q)return null;v=q[0],f+=q[0].length}if(x(),e[f]!=="=")return null;f++,x();let I=/^withDefaults\s*\(\s*/.exec(e.slice(f)),j=Boolean(I);if(I)f+=I[0].length;let W=/^defineProps\b/.exec(e.slice(f));if(!W)return null;f+=W[0].length;let M="";if(x(),e[f]==="<"){let q=Tt(e,f,"<",">");if(q===-1)return null;M=e.slice(f+1,q-1).trim(),f=q}if(x(),e[f]!=="(")return null;let L=Tt(e,f,"(",")");if(L===-1)return null;let V=e.slice(f+1,L-1).trim();if(f=L,j){if(x(),e[f]===",")f++,x();if(e[f]==="{"){let q=Tt(e,f,"{","}");if(q===-1)return null;for(let[Z,G]of xs(e.slice(f,q)))i[Z]=G;f=q}if(x(),e[f]===",")f++,x();if(e[f]===")")f++}if(e[f]===";")f++;let U=/^[A-Za-z_$][\w$]*$/.test(M)?M:void 0;if(M.startsWith("{"))for(let q of nn(M.replace(/^\{/,"").replace(/\}$/,""),",;",!0)){let Z=/^(?:readonly\s+)?([A-Za-z_$][\w$]*)\s*\??\s*:\s*([\s\S]+)$/.exec(q);if(Z)r[Z[1]]=Z[2].trim()}if(V.startsWith("{"))for(let[q,Z]of xs(V)){if(a.push(q),!Z.startsWith("{")){let G=Uo(Z);if(G)r[q]=G;continue}for(let[G,H]of xs(Z))if(G==="default")i[q]=H;else if(G==="type"){let ne=Uo(H);if(ne)r[q]=ne}}else if(V.startsWith("["))for(let q of nn(V.slice(1,-1),",",!1))a.push(q.replace(/^['"`]/,"").replace(/['"`]$/,""));if(v.startsWith("{")){a.length=0;for(let q of nn(v.replace(/^\{/,"").replace(/\}$/,""),",",!1)){let Z=hu(q),G=Z===-1?q:q.slice(0,Z),H=G.split(":")[0].trim().replace(/^\.\.\./,"");if(!H)continue;a.push(H),l[H]=G.trim();let ne=G.split(":").at(-1).trim();if(/^[A-Za-z_$][\w$]*$/.test(ne))u[H]=ne;if(Z!==-1)i[H]=q.slice(Z+1).trim()}}else if(a.length===0)a.push(...Object.keys(r));return{text:e.slice(n,f),propNames:a,propBindings:l,localBindings:u,defaults:i,declared:r,typeName:U,identifier:v.startsWith("{")?void 0:v}}function xs(e){let n=e.trim().replace(/^\{/,"").replace(/\}$/,""),r=[],i=0;while(i<n.length){let a=/\s*([A-Za-z_$][\w$]*)\s*:/y;a.lastIndex=i;let l=a.exec(n);if(!l)break;i=a.lastIndex;let u=0,f="",x=i;while(i<n.length){let I=n[i];if(f){if(I==="\\")i++;else if(I===f)f=""}else if(I==="'"||I==='"'||I==="`")f=I;else if(I==="{"||I==="["||I==="(")u++;else if(I==="}"||I==="]"||I===")")u--;else if(I===","&&u===0)break;i++}let v=n.slice(x,i).trim();if(v)r.push([l[1],v]);i++}return r}function pr(e){let n=/^(?:(?:0|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?$/,r=/^(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[bB][01](?:_?[01])*|0[oO][0-7](?:_?[0-7])*)$/;if(!n.test(e)&&!r.test(e))throw Error("Invalid prop number");return Number(e.replaceAll("_",""))}function bs(e){let n=new Mn(e,"javascript").tokenize().filter((a)=>!["COMMENT","WHITESPACE","EOF"].includes(a.type)),r=0;function i(a){if(a>64)throw Error("Prop literal too deep");let l=n[r++];if(!l)throw Error("Missing prop literal");if(l.type==="STRING"||l.type==="TEMPLATE_STRING"){let I=Dn(l.value);if(I===null)throw Error("Dynamic prop string");return I}if(l.type==="NUMBER")return pr(l.value);if(l.value==="-"||l.value==="+"){let I=n[r++];if(I?.type!=="NUMBER")throw Error("Dynamic prop number");return(l.value==="-"?-1:1)*pr(I.value)}if(l.value==="true")return!0;if(l.value==="false")return!1;if(l.value==="null")return null;if(l.value==="undefined")return;if(l.value!=="["&&l.value!=="{")throw Error("Dynamic prop default");let u=l.value==="[",f=u?"]":"}",x=[],v=[];while(n[r]?.value!==f){if(u)v.push(i(a+1));else{let I=n[r++];if(!I||!["STRING","IDENTIFIER","NUMBER"].includes(I.type))throw Error("Dynamic prop key");let j=I.type==="STRING"?Dn(I.value):I.type==="NUMBER"?String(pr(I.value)):I.value;if(j===null||n[r++]?.value!==":")throw Error("Dynamic prop key");x.push([j,i(a+1)])}if(n[r]?.value!==",")break;r++}if(n[r++]?.value!==f)throw Error("Unclosed prop literal");return u?v:Object.fromEntries(x)}try{let a=i(0);return r===n.length?a:void 0}catch{return}}function Go(e){if(e==="connectedCallback")return`method "${e}" is reserved; define "onConnect" instead, which the element calls once it is connected, rendered and bound`;if(e==="disconnectedCallback")return`method "${e}" is reserved; define "onDisconnect" instead, which the element calls as it leaves the DOM, before it releases its own listeners`;return`method "${e}" is reserved`}var Yo=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]),Su=new Set(vu);function $u(e){return e.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((n)=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}function dr(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Eu(e){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test(e)&&!e.startsWith("xml")&&!/[A-Z]/.test(e)}function ku(e){if(e===!0)return"open";if(e==="open"||e==="closed")return e;return!1}async function Cu(e){let n=[];async function r(i){let a=await yu(i,{withFileTypes:!0});a.sort((l,u)=>l.name.localeCompare(u.name));for(let l of a){let u=st.join(i,l.name);if(l.isDirectory()){if(!l.name.startsWith(".")&&l.name!=="node_modules")await r(u)}else if(l.isFile()&&l.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(l.name))n.push(u)}}return await r(e),n}function rn(e){return e.replace(/<!--[\s\S]*?-->|\{\{--[\s\S]*?--\}\}/g,(n)=>n.replace(/[^\n]/g," "))}function gr(e){for(let n of se(rn(e))){let r=O(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 mr(e,n){let r=gr(e);if(!r)return{};let i=r.code.trim();if(!i)return{};try{let a=JSON.parse(i);if(!a||typeof a!=="object"||Array.isArray(a))throw Error("expected a JSON object");return a}catch(a){throw Error(`${n}: <script component> must contain JSON metadata (${a.message})`)}}function ys(e,n){let r=t(e),i=new Set(Xr(e).map((x)=>x.start)),a=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/g,l=[],u=n?void 0:new Bun.Transpiler({loader:"ts"}),f;while(f=a.exec(r)){if(!i.has(f.index+f[0].indexOf("function")))continue;let x=a.lastIndex;while(/\s/.test(r[x]||""))x++;let v=x;if(r[x]==="<")x=Tt(r,x,"<",">");if(x<0)continue;let I=e.slice(v,x).trim();while(/\s/.test(r[x]||""))x++;if(r[x]!=="(")continue;let j=x,W=Tt(r,x,"(",")");if(W<0)continue;for(x=W;x<e.length;x++){let M=r[x];if(M!=="{"&&M!==";")continue;let L=e.slice(f.index,x).trim();if(n){if(!n(L,M,f[1]))continue}else{let U;try{U=u.transformSync(L+(M==="{"?"{}":";"))}catch{continue}if(M==="{"&&!U.includes(`function ${f[1]}(`))continue;if(M===";"&&U.trim())continue}let V=M==="{"?Tt(r,x,"{","}"):x+1;if(V<0)break;l.push({name:f[1],header:L,generic:I,parameterOffset:j+1,parameters:e.slice(j+1,W-1),returns:e.slice(W,x).trim().replace(/^:\s*/,""),async:/\basync\s+function/.test(f[0]),...M==="{"?{source:e.slice(f.index,V)}:{}}),a.lastIndex=V;break}}return l}function Ru(e){let n=nn(e.parameters,",",!0).flatMap((r,i)=>{let a=t(r),l=0,u=-1;for(let V=0;V<a.length;V++){let U=a[V];if("([{<".includes(U))l++;else if(")]}>".includes(U)&&!(U===">"&&a[V-1]==="="))l--;if(U==="="&&l===0&&a[V+1]!==">"){u=V;break}}let f=(u<0?r:r.slice(0,u)).trim(),x=nn(f,":",!0),v=x.shift().trim();if(v==="this")return[];let I=/^[A-Za-z_$]|^\.\.\./.test(v)?v:`argument${i}`,j=u<0?"":r.slice(u+1).trim(),W=j==="true"||j==="false"?"boolean":/^-?\d+(?:\.\d+)?$/.test(j)?"number":/^['"`]/.test(j)?"string":I.startsWith("...")?"unknown[]":"unknown",M=x.join(":").trim()||W,L=u>=0&&!I.endsWith("?")&&!I.startsWith("...")?"?":"";return[`${I}${L}: ${M}`]}).join(", ");return`${e.name}${e.generic}(${n}): ${e.returns||(e.async?"Promise<unknown>":"unknown")}`}function Au(e,n){let r={},i={},a=[],l=[],u=se(rn(e)).map((I)=>({code:e.slice(I.bodyStart,I.bodyEnd),attributes:O(I.attrs)})).filter(({attributes:I})=>!["src","server","component","stx:component"].some((j)=>I.has(j))&&vt(I));for(let I of u){let{code:j,attributes:W}=I;try{new Bun.Transpiler({loader:"ts"}).transformSync(j)}catch(H){throw Error(`${n}: failed to transpile <script client> (${H.message})`)}let M=W.has("client")?null:sn(j),L=W.has("client")?ys(j):[],V=new Set(L.filter((H)=>!H.source).map((H)=>H.name));for(let H of L){if(Yo.has(H.name))throw Error(`${n}: client ${Go(H.name)}`);if(H.source)r[H.name]=new Bun.Transpiler({loader:"ts"}).transformSync(H.source).trim().replace(/^(?:export\s+)?(async\s+)?function\s+/,"$1");if(!H.source||!V.has(H.name))(i[H.name]??=[]).push(Ru(H))}for(let H of j.matchAll(/^\s*import\s+(?:type\s+)?([\s\S]*?)\s+from\s*(['"])([^'"]+)\2\s*;?/gm))l.push({binding:H[1].trim(),module:H[3]});let U=t(j),q=E(U).depths,Z=/(?:export\s+)?(interface|type)\s+[A-Za-z_$][\w$]*/g,G;while(G=Z.exec(U)){if(q[G.index]!==0)continue;let H=Z.lastIndex,ne=0;for(;H<U.length;H++){let we=U[H];if(we==="{"){let xe=Tt(U,H,"{","}");if(xe<0)break;if(H=xe-1,G[1]==="interface"&&ne===0){H++;break}continue}if("([<".includes(we))ne++;else if(")]>".includes(we)&&!(we===">"&&U[H-1]==="="))ne--;if(G[1]==="type"&&ne===0&&(we===";"||we===`
|
|
527
|
-
`)){if(we===`
|
|
528
|
-
`&&/^[\s]*[|&]/.test(U.slice(H+1)))continue;try{new Bun.Transpiler({loader:"ts"}).transformSync(j.slice(G.index,H));break}catch{}}}let ce=j.slice(G.index,H),de=G.index,fe=/(?:interface|type)\s+([A-Za-z_$][\w$]*)/.exec(G[0])?.[1],Ce=u.map((we)=>{let xe=we===I?j.slice(0,de)+j.slice(H):we.code;return t(xe.replace(sn(we.code)?.text??"\x00",""))}).join(`
|
|
529
|
-
`);if(!(M?.typeName===fe&&!/^export\s/.test(ce)&&fe&&!new RegExp(`\\b${fe}\\b`).test(Ce)))a.push(ce.replace(/^export\s+/,"").trim());Z.lastIndex=H+1}}let f=Object.values(i).flat().join(`
|
|
530
|
-
`)+`
|
|
531
|
-
`+a.join(`
|
|
532
|
-
`),x=l.filter((I)=>(I.binding.match(/[A-Za-z_$][\w$]*/g)||[]).filter((j)=>!["type","as"].includes(j)).some((j)=>new RegExp(`\\b${j}\\b`).test(f)));for(let I of x)if(I.module.startsWith(".")||st.isAbsolute(I.module))throw Error(`${n}: public method types import ${JSON.stringify(I.module)} outside the generated package; declare these types in the component or import them from a published dependency`);let v=[...new Set(x.map((I)=>`import type ${I.binding.replace(/\btype\s+/g,"")} from ${JSON.stringify(I.module)}`))];return{methods:r,declarations:i,types:[...v,...a].join(`
|
|
533
|
-
|
|
534
|
-
`)}}function Tu(e){let n=e.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(n?n[1]:e).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function qo(e){return[...e.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((n)=>n[1].replace(/\r\n?/g,`
|
|
535
|
-
`).replaceAll("\x00","\uFFFD").trim()).filter(Boolean).join(`
|
|
536
|
-
|
|
537
|
-
`)}function Iu(e){if(!e)return null;let n=e.replace(/\s*\|\s*(?:undefined|null)\b/g,"").trim();if(/^string$/.test(n))return"string";if(/^number$/.test(n))return"number";if(/^boolean$/.test(n))return"boolean";if(/^(?:'[^']*'|"[^"]*")(?:\s*\|\s*(?:'[^']*'|"[^"]*"))*$/.test(n))return"string";return"object"}function Pu(e){if(e===void 0)return"object";if(e==="true"||e==="false")return"boolean";if(/^-?\d+(?:\.\d+)?$/.test(e))return"number";if(/^['"`]/.test(e))return"string";return"object"}function jn(e,n){if(e[n]!=="(")return null;let r=0,i="";for(let a=n;a<e.length;a++){let l=e[a];if(i!==""){if(l==="\\")a++;else if(l===i)i="";continue}if(l==="'"||l==='"'||l==="`"){i=l;continue}if(l==="(")r++;else if(l===")"){if(r--,r===0)return{expression:e.slice(n+1,a),end:a+1}}}return null}function hr(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 Ou(e){let n=[],r=0,i=e.replace(/\{\{--[\s\S]*?--\}\}/g,""),a=/@(if|elseif|else|endif|foreach|endforeach)\s*/g,l,u=(f)=>{if(f==="")return;let x=0,v=/\{!!\s*([\s\S]*?)\s*!!\}|\{\{\s*([\s\S]*?)\s*\}\}/g,I;while(I=v.exec(f)){if(I.index>x)n.push(`out += ${JSON.stringify(f.slice(x,I.index))};`);n.push(I[1]!==void 0?`out += __raw(${I[1]});`:`out += __escape(${I[2]});`),x=I.index+I[0].length}if(x<f.length)n.push(`out += ${JSON.stringify(f.slice(x))};`)};while(l=a.exec(i)){u(i.slice(r,l.index)),r=l.index+l[0].length;let x=l[1]==="if"||l[1]==="elseif"||l[1]==="foreach"?jn(i,r):null;if(x)r=x.end,a.lastIndex=x.end;let v=x?.expression;switch(l[1]){case"if":n.push(`if (${v}) {`);break;case"elseif":n.push(`} else if (${v}) {`);break;case"else":n.push("} else {");break;case"endif":case"endforeach":n.push("}");break;case"foreach":{let I=hr(v||"");if(!I){n.push(`out += ${JSON.stringify(l[0]+(x?`(${v})`:""))};`);break}let{iterable:j,key:W,value:M}=I;n.push(W?`for (const [${W}, ${M}] of __entries(${j})) {`:`for (const ${M} of __values(${j})) {`);break}}}return u(i.slice(r)),n.join(`
|
|
538
|
-
`)}function Qo(e){let n=t(e),r=E(n).depths,i=[],a=[];for(let u of n.matchAll(/\bimport\b/g)){let f=u.index;if(r[f]!==0)continue;let x=new Mn(e.slice(f)).tokenize().filter((L)=>!["COMMENT","WHITESPACE"].includes(L.type));if(x[1]?.value==="("||x[1]?.value===".")continue;let v=x[1]?.type==="STRING"?1:-1,I=0;for(let L=1;v===-1&&L<x.length;L++){let V=x[L];if(V.value===";"||V.type==="EOF")break;if(V.value==="{")I++;else if(V.value==="}")I--;else if(I===0&&V.value==="from"&&x[L+1]?.type==="STRING")v=L+1}if(v===-1)continue;let j=x[v],W=v;if(x[W+1]?.value==="with"&&x[W+2]?.value==="{"){W+=2;let L=1;while(L&&x[W+1]?.type!=="EOF")if(W++,x[W]?.value==="{")L++;else if(x[W]?.value==="}")L--}if(x[W+1]?.value===";")W++;let M=f+x[W].end;if(a.push({start:f,end:M}),j.value.slice(1,-1)!=="stx")i.push(e.slice(f,M))}let l=e;for(let u of a.reverse())l=l.slice(0,u.start)+l.slice(u.end);return{imports:i,body:l}}function ju(e){let r=se(rn(e)).find((W)=>{let M=O(W.attrs);return vt(M)&&!["component","stx:component","client","server","src"].some((L)=>M.has(L))});if(!r)return{imports:[],body:"",propNames:[],propBindings:{},defaults:{},declared:{}};let i=e.slice(r.bodyStart,r.bodyEnd),a=[],l=[],u=Object.create(null),f=Object.create(null),x=Object.create(null),v=Qo(i);a.push(...v.imports),i=v.body;let I=sn(i);if(I)l.push(...I.propNames),Object.assign(u,I.propBindings),Object.assign(f,I.defaults),Object.assign(x,I.declared),i=i.replace(I.text,I.identifier?`const ${I.identifier} = this._props();`:"");let j={};for(let W of i.matchAll(/(?:export\s+)?interface\s+([A-Za-z_$][\w$]*)\s*\{([\s\S]*?)\n\}/g)){let M=[];for(let L of W[2].matchAll(/^\s*(?:\/\*\*[\s\S]*?\*\/\s*)?([A-Za-z_$][\w$]*)\??\s*:\s*([^\n;]+)/gm))x[L[1]]=L[2].trim(),M.push(L[1]);j[W[1]]=M}if(I&&I.propNames.length===0&&I.typeName){for(let W of j[I.typeName]??[])if(!l.includes(W))l.push(W)}return i=i.replace(/(?:export\s+)?interface\s+[A-Za-z_$][\w$]*\s*\{[\s\S]*?\n\}/g,""),{imports:a,body:i.trim(),propNames:l,propBindings:u,defaults:f,declared:x}}function Mu(e){let n=new Set;return{template:e.replace(/\s@([a-z][\w:-]*)(\.[\w.-]+)?\s*=\s*(["'])([A-Za-z_$][\w$]*)\3/gi,(i,a,l,u,f)=>{let x=a.toLowerCase();n.add(x);let v=(l||"").split(".").filter(Boolean).join(" ");return` data-stx-on-${x}="${f}"${v?` data-stx-mod-${x}="${v}"`:""}`}),eventTypes:[...n].sort()}}function Du(e){let n=[];return{template:e.replace(/\s:([a-z][\w:-]*)\s*=\s*(["'])([\w$.]+)\2/gi,(i,a,l,u)=>{let f=n.length;return n.push({id:f,name:a,expression:u}),` data-stx-bind-${f}=""`}),bindings:n}}function Nu(e){let n=new Set;for(let r of e.matchAll(/<slot\b([^>]*)>/gi))n.add(r[1].match(/\bname\s*=\s*["']([^"']+)["']/i)?.[1]||"");return[...n].map((r)=>({name:r}))}function Lu(e){return[...new Set([...e.matchAll(/(--[a-z0-9_-]+)\s*:/gi)].map((n)=>n[1]))].sort().map((n)=>({name:n}))}function Zo(e,n){if(!n||!new Set(["string","number","boolean","object","array"]).has(n.type))throw Error(`Property "${e}" must declare one of: string, number, boolean, object, array`);return{...n,reflect:n.reflect??n.attribute!==!1}}async function zu(e,n,r){let i=st.isAbsolute(n.file)?n.file:st.resolve(e,n.file),a=await bu(i,"utf8"),l=mr(a,i),u=st.basename(i,".stx"),f=n.name||l.name||$u(u),x=`${dr(r.prefix||"stx")}-${dr(u)}`,v=n.tag||l.tag||x;if(!f||!/^[A-Za-z_$][\w$]*$/.test(f))throw Error(`${i}: invalid component class name "${f}"`);if(!Eu(v))throw Error(`${i}: invalid custom-element tag "${v}"; tags must be lowercase and contain a hyphen`);let I=n.properties||l.properties||l.props||{},j=Object.fromEntries(Object.entries(I).map(([G,H])=>[G,Zo(G,H)])),W=Mu(Tu(a)),M=Du(W.template),L=ju(a);for(let G of se(rn(a))){let H=O(G.attrs);if(!H.has("client")||["server","component","stx:component","src"].some((ne)=>H.has(ne))||!vt(H))continue;L.imports.push(...Qo(a.slice(G.bodyStart,G.bodyEnd)).imports)}L.imports=[...new Set(L.imports)];let V=Ou(M.template);for(let G of L.propNames){if(j[G])continue;let H=L.defaults[G];j[G]=Zo(G,{type:Iu(L.declared[G])??Pu(H),...H===void 0?{}:{default:bs(H)}})}let U=l.methods||{},q=n.methods||{},Z=Au(a,i);return{file:st.relative(e,i),sourcePath:i,name:f,tag:v,description:n.description||l.description||"",template:M.template,styles:qo(a),shadowMode:ku(n.shadowDOM??l.shadowDOM??r.shadowDOM),progressive:n.progressive??l.progressive??r.progressive??!0,properties:j,events:n.events||l.events||{},methods:{...U,...q,...Z.methods},methodDeclarations:Z.declarations,declarationTypes:Z.types,eventTypes:W.eventTypes,bindings:M.bindings,slots:Nu(M.template),cssProperties:Lu(qo(a)),scope:L,render:V}}function Bu(){let e=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),n=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}");return`const HTMLElementBase = globalThis.HTMLElement || class {};
|
|
539
|
-
|
|
540
|
-
const escapeHTML = (value) => String(value ?? '')
|
|
541
|
-
.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>')
|
|
542
|
-
.replaceAll('"', '"').replaceAll("'", ''');
|
|
543
|
-
|
|
544
|
-
const valueAt = (host, path) => {
|
|
545
|
-
const parts = path.trim().split('.');
|
|
546
|
-
if (parts[0] === 'this') parts.shift();
|
|
547
|
-
if (!parts.length) return host;
|
|
548
|
-
const first = parts.shift();
|
|
549
|
-
// Render bindings read declared props, including attributes whose names
|
|
550
|
-
// also belong to the native DOM API. The public element keeps that API.
|
|
551
|
-
let value = host._values && Object.prototype.hasOwnProperty.call(host._values, first)
|
|
552
|
-
? host._values[first]
|
|
553
|
-
: host[first];
|
|
554
|
-
for (const part of parts) value = value?.[part];
|
|
555
|
-
return typeof value === 'function' ? value.call(host) : value;
|
|
556
|
-
};
|
|
557
|
-
|
|
558
|
-
const deserialize = (value, type, fallback) => {
|
|
559
|
-
if (value === null) return type === 'boolean' ? false : fallback;
|
|
560
|
-
if (type === 'boolean') return value !== 'false' && value !== '0';
|
|
561
|
-
if (type === 'number') return Number(value);
|
|
562
|
-
if (type === 'object' || type === 'array') {
|
|
563
|
-
try { return JSON.parse(value); }
|
|
564
|
-
catch { return fallback; }
|
|
565
|
-
}
|
|
566
|
-
return value;
|
|
567
|
-
};
|
|
568
|
-
|
|
569
|
-
const serialize = (value, type) => {
|
|
570
|
-
if (value == null || value === false) return null;
|
|
571
|
-
if (type === 'boolean') return '';
|
|
572
|
-
if (type === 'object' || type === 'array') return JSON.stringify(value);
|
|
573
|
-
return String(value);
|
|
574
|
-
};
|
|
575
|
-
|
|
576
|
-
const cloneDefault = (value, type) => {
|
|
577
|
-
if (value == null || (type !== 'object' && type !== 'array')) return value;
|
|
578
|
-
if (typeof structuredClone === 'function') return structuredClone(value);
|
|
579
|
-
return JSON.parse(JSON.stringify(value));
|
|
580
|
-
};
|
|
581
|
-
|
|
582
|
-
const defaultFor = property => cloneDefault(
|
|
583
|
-
property.default ?? ({ string: '', number: 0, boolean: false, object: {}, array: [] })[property.type],
|
|
584
|
-
property.type,
|
|
585
|
-
);
|
|
586
|
-
|
|
587
|
-
export class StxElement extends HTMLElementBase {
|
|
588
|
-
static definition = {};
|
|
589
|
-
static get observedAttributes() { return this.definition.observedAttributes || []; }
|
|
590
|
-
|
|
591
|
-
constructor() {
|
|
592
|
-
super();
|
|
593
|
-
this._values = Object.create(null);
|
|
594
|
-
this._reflecting = false;
|
|
595
|
-
this._connected = false;
|
|
596
|
-
this._hasConnected = false;
|
|
597
|
-
this._initializing = false;
|
|
598
|
-
this._updatePending = false;
|
|
599
|
-
this._listeners = new Map();
|
|
600
|
-
const definition = this.constructor.definition;
|
|
601
|
-
for (const [name, property] of Object.entries(definition.properties || {})) {
|
|
602
|
-
this._values[name] = defaultFor(property);
|
|
603
|
-
}
|
|
604
|
-
if (definition.shadowMode && this.attachShadow && !this.shadowRoot) {
|
|
605
|
-
this._closedRoot = this.attachShadow({ mode: definition.shadowMode });
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
get updateComplete() { return this._updateComplete || Promise.resolve(); }
|
|
610
|
-
get renderRoot() { return this._closedRoot || this.shadowRoot || this; }
|
|
611
|
-
|
|
612
|
-
connectedCallback() {
|
|
613
|
-
if (this._connected) return;
|
|
614
|
-
this._connected = true;
|
|
615
|
-
this._initializing = true;
|
|
616
|
-
const definition = this.constructor.definition;
|
|
617
|
-
for (const [name, property] of Object.entries(definition.properties || {})) {
|
|
618
|
-
const attribute = property.attribute === false ? null : (property.attribute || name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase()));
|
|
619
|
-
if (attribute && this.hasAttribute?.(attribute)) this._values[name] = deserialize(this.getAttribute(attribute), property.type, defaultFor(property));
|
|
620
|
-
}
|
|
621
|
-
// Properties assigned before customElements.define() become own properties.
|
|
622
|
-
// Upgrade them after attributes so imperative state wins, matching the
|
|
623
|
-
// platform's property-first custom-element initialization convention.
|
|
624
|
-
for (const name of Object.keys(definition.properties || {})) this._upgradeProperty(name);
|
|
625
|
-
this._initializing = false;
|
|
626
|
-
const root = this.renderRoot;
|
|
627
|
-
const hasMarkup = [...(root.childNodes || [])].some(node => node.nodeType !== 3 || node.textContent.trim());
|
|
628
|
-
const firstConnection = !this._hasConnected;
|
|
629
|
-
if (!(firstConnection && definition.progressive && hasMarkup)) this._render();
|
|
630
|
-
else this._upgradeDeclarativeEvents();
|
|
631
|
-
this._bindEvents();
|
|
632
|
-
if (firstConnection) {
|
|
633
|
-
this._hasConnected = true;
|
|
634
|
-
this.setAttribute?.('hydrated', '');
|
|
635
|
-
this.dispatchEvent?.(new CustomEvent('stx:hydrated', { bubbles: true, composed: true }));
|
|
636
|
-
}
|
|
637
|
-
// Called last, so a component that acquires something sees its own rendered
|
|
638
|
-
// markup and its events already bound. Reported rather than rethrown: a
|
|
639
|
-
// component that fails to set up must not take the element down with it.
|
|
640
|
-
try { this.onConnect?.(); }
|
|
641
|
-
catch (error) { console.error('[stx] onConnect failed', error); }
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
disconnectedCallback() {
|
|
645
|
-
this._connected = false;
|
|
646
|
-
// Called before the framework releases anything, so the element is still
|
|
647
|
-
// intact for a component that needs to read it on the way out, and inside
|
|
648
|
-
// try/finally so a throwing hook cannot leak the framework's own listeners.
|
|
649
|
-
try { this.onDisconnect?.(); }
|
|
650
|
-
catch (error) { console.error('[stx] onDisconnect failed', error); }
|
|
651
|
-
finally {
|
|
652
|
-
for (const [event, listener] of this._listeners) this.renderRoot.removeEventListener(event, listener);
|
|
653
|
-
this._listeners.clear();
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
attributeChangedCallback(attribute, oldValue, newValue) {
|
|
658
|
-
if (oldValue === newValue || this._reflecting) return;
|
|
659
|
-
const definition = this.constructor.definition;
|
|
660
|
-
const name = definition.attributeToProperty?.[attribute];
|
|
661
|
-
if (!name) return;
|
|
662
|
-
const property = definition.properties[name];
|
|
663
|
-
const value = deserialize(newValue, property.type, defaultFor(property));
|
|
664
|
-
if (!Object.is(this._values[name], value)) {
|
|
665
|
-
this._values[name] = value;
|
|
666
|
-
this.requestUpdate();
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
/**
|
|
671
|
-
* The props a compiled render reads.
|
|
672
|
-
*
|
|
673
|
-
* Its own method rather than _values directly, so a component that sets a
|
|
674
|
-
* property before upgrade still sees it, and so the generated code has one
|
|
675
|
-
* name to depend on rather than a private field's shape.
|
|
676
|
-
*/
|
|
677
|
-
_props() {
|
|
678
|
-
return this._values;
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
requestUpdate() {
|
|
682
|
-
if (!this._connected || this._initializing || this._updatePending) return this.updateComplete;
|
|
683
|
-
this._updatePending = true;
|
|
684
|
-
this._updateComplete = new Promise((resolve) => {
|
|
685
|
-
queueMicrotask(() => {
|
|
686
|
-
this._updatePending = false;
|
|
687
|
-
if (this._connected) this._render();
|
|
688
|
-
resolve();
|
|
689
|
-
});
|
|
690
|
-
});
|
|
691
|
-
return this._updateComplete;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
emit(name, detail, options = {}) {
|
|
695
|
-
return this.dispatchEvent(new CustomEvent(name, {
|
|
696
|
-
detail, bubbles: true, composed: true, ...options,
|
|
697
|
-
}));
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
_upgradeProperty(name) {
|
|
701
|
-
if (!Object.prototype.hasOwnProperty.call(this, name)) return;
|
|
702
|
-
const value = this[name];
|
|
703
|
-
delete this[name];
|
|
704
|
-
this[name] = value;
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
_upgradeDeclarativeEvents() {
|
|
708
|
-
for (const element of this.renderRoot.querySelectorAll?.('*') || []) {
|
|
709
|
-
const names = element.getAttributeNames?.() || [...(element.attributes || [])].filter(Boolean).map(attribute => attribute.name);
|
|
710
|
-
for (const attributeName of names) {
|
|
711
|
-
if (!attributeName?.startsWith('@')) continue;
|
|
712
|
-
const [event, ...modifiers] = attributeName.slice(1).split('.');
|
|
713
|
-
element.setAttribute('data-stx-on-' + event, element.getAttribute(attributeName));
|
|
714
|
-
if (modifiers.length) element.setAttribute('data-stx-mod-' + event, modifiers.join(' '));
|
|
715
|
-
element.removeAttribute(attributeName);
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
_bindEvents() {
|
|
721
|
-
for (const event of this.constructor.definition.eventTypes || []) {
|
|
722
|
-
if (this._listeners.has(event)) continue;
|
|
723
|
-
const listener = ($event) => {
|
|
724
|
-
const selector = '[data-stx-on-' + event + ']';
|
|
725
|
-
const target = $event.target?.closest?.(selector);
|
|
726
|
-
if (!target || !this.renderRoot.contains(target)) return;
|
|
727
|
-
const modifiers = (target.getAttribute('data-stx-mod-' + event) || '').split(' ');
|
|
728
|
-
if (modifiers.includes('prevent')) $event.preventDefault();
|
|
729
|
-
if (modifiers.includes('stop')) $event.stopPropagation();
|
|
730
|
-
const method = target.getAttribute('data-stx-on-' + event);
|
|
731
|
-
if (typeof this[method] === 'function') this[method]($event);
|
|
732
|
-
};
|
|
733
|
-
this.renderRoot.addEventListener(event, listener);
|
|
734
|
-
this._listeners.set(event, listener);
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
_render() {
|
|
739
|
-
const definition = this.constructor.definition;
|
|
740
|
-
const root = this.renderRoot;
|
|
741
|
-
const active = root.activeElement || (root.contains?.(globalThis.document?.activeElement) ? globalThis.document.activeElement : null);
|
|
742
|
-
const focusAttribute = active?.getAttribute?.('data-key') ? 'data-key' : active?.id ? 'id' : 'name';
|
|
743
|
-
const focusKey = active?.getAttribute?.(focusAttribute);
|
|
744
|
-
const focusValue = focusAttribute === 'name' && active?.type === 'radio' ? active.value : null;
|
|
745
|
-
const selectionStart = active?.selectionStart, selectionEnd = active?.selectionEnd;
|
|
746
|
-
const selection = Number.isInteger(selectionStart) && Number.isInteger(selectionEnd)
|
|
747
|
-
? [selectionStart, selectionEnd, active.selectionDirection] : null;
|
|
748
|
-
// A compiled component renders itself: the control flow and the derived
|
|
749
|
-
// values were turned into JavaScript at build time, so there is nothing to
|
|
750
|
-
// interpret here and nothing that needs an eval the page's CSP forbids.
|
|
751
|
-
// The string template remains for components that carry no logic.
|
|
752
|
-
let html = typeof this.render === 'function'
|
|
753
|
-
? this.render(RENDER_HELPERS)
|
|
754
|
-
: definition.template
|
|
755
|
-
.replace(new RegExp(${e}, 'g'), (_match, expression) => String(valueAt(this, expression) ?? ''))
|
|
756
|
-
.replace(new RegExp(${n}, 'g'), (_match, expression) => escapeHTML(valueAt(this, expression)));
|
|
757
|
-
if (definition.shadowMode && definition.styles) html = '<style>' + definition.styles + '</style>' + html;
|
|
758
|
-
root.innerHTML = html;
|
|
759
|
-
this._applyBindings();
|
|
760
|
-
this._bindEvents();
|
|
761
|
-
if (focusKey) {
|
|
762
|
-
const escaped = globalThis.CSS?.escape ? globalThis.CSS.escape(focusKey) : focusKey.replace(/["\\\\]/g, '\\$&');
|
|
763
|
-
const selector = '[' + focusAttribute + '="' + escaped + '"]';
|
|
764
|
-
// Name-only radio groups share a name, but their chosen member must stay focused.
|
|
765
|
-
const next = focusValue === null ? root.querySelector(selector)
|
|
766
|
-
: [...root.querySelectorAll(selector)].find(element => element.type === 'radio' && element.value === focusValue);
|
|
767
|
-
next?.focus?.();
|
|
768
|
-
// Several input types expose this method but reject text selection. A
|
|
769
|
-
// rerender can also change a text input into one of those types.
|
|
770
|
-
if (selection && Number.isInteger(next?.selectionStart) && Number.isInteger(next?.selectionEnd) && typeof next?.setSelectionRange === 'function')
|
|
771
|
-
next.setSelectionRange(selection[0], selection[1], selection[2] || 'none');
|
|
772
|
-
}
|
|
773
|
-
this.dispatchEvent?.(new CustomEvent('stx:updated', { bubbles: false }));
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
_applyBindings() {
|
|
777
|
-
for (const binding of this.constructor.definition.bindings || []) {
|
|
778
|
-
const element = this.renderRoot.querySelector('[data-stx-bind-' + binding.id + ']');
|
|
779
|
-
if (!element) continue;
|
|
780
|
-
const value = valueAt(this, binding.expression);
|
|
781
|
-
if (binding.name === 'class') element.className = value || '';
|
|
782
|
-
else if (binding.name === 'style' && typeof value === 'object') {
|
|
783
|
-
Object.assign(element.style, value);
|
|
784
|
-
}
|
|
785
|
-
else if (typeof value === 'boolean') {
|
|
786
|
-
element.toggleAttribute(binding.name, value);
|
|
787
|
-
if (binding.name in element) element[binding.name] = value;
|
|
788
|
-
}
|
|
789
|
-
else if (value == null || value === false) element.removeAttribute(binding.name);
|
|
790
|
-
else element.setAttribute(binding.name, String(value));
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
/**
|
|
796
|
-
* What a compiled render is handed.
|
|
797
|
-
*
|
|
798
|
-
* Passed in rather than closed over so the generated code names no globals, and
|
|
799
|
-
* a component module stays readable on its own: __escape is visibly a
|
|
800
|
-
* parameter, not something the bundler happened to leave in scope.
|
|
801
|
-
*/
|
|
802
|
-
const RENDER_HELPERS = {
|
|
803
|
-
escape: escapeHTML,
|
|
804
|
-
// The raw form is the author declaring the value is markup. Null becomes an
|
|
805
|
-
// empty string rather than the word "null", which is the only sensible
|
|
806
|
-
// reading of a missing fragment.
|
|
807
|
-
raw: (value) => String(value ?? ''),
|
|
808
|
-
// A loop over something absent runs zero times. Throwing here would fail a
|
|
809
|
-
// whole page over one empty list, which is never what the author meant.
|
|
810
|
-
values: (value) => value == null ? [] : (value[Symbol.iterator] ? value : Object.values(value)),
|
|
811
|
-
entries: (value) => value == null ? [] : (Array.isArray(value) ? value.entries() : Object.entries(value)),
|
|
812
|
-
};
|
|
813
|
-
|
|
814
|
-
export function defineComponent(Component, definition) {
|
|
815
|
-
const properties = definition.properties || {};
|
|
816
|
-
const attributeToProperty = {};
|
|
817
|
-
const observedAttributes = [];
|
|
818
|
-
for (const [name, property] of Object.entries(properties)) {
|
|
819
|
-
const attribute = property.attribute === false ? null : (property.attribute || name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase()));
|
|
820
|
-
if (attribute) {
|
|
821
|
-
attributeToProperty[attribute] = name;
|
|
822
|
-
observedAttributes.push(attribute);
|
|
823
|
-
}
|
|
824
|
-
// A style prop is an attribute value, not a replacement for the browser's
|
|
825
|
-
// CSSStyleDeclaration. Native event handler accessors must survive too.
|
|
826
|
-
if (name in HTMLElementBase.prototype) {
|
|
827
|
-
if (!attribute) throw new TypeError('STX prop "' + name + '" overlaps the native DOM API and needs an attribute binding');
|
|
828
|
-
continue;
|
|
829
|
-
}
|
|
830
|
-
Object.defineProperty(Component.prototype, name, {
|
|
831
|
-
configurable: true,
|
|
832
|
-
enumerable: true,
|
|
833
|
-
get() { return this._values[name]; },
|
|
834
|
-
set(value) {
|
|
835
|
-
const oldValue = this._values[name];
|
|
836
|
-
if (Object.is(oldValue, value)) return;
|
|
837
|
-
this._values[name] = value;
|
|
838
|
-
if (property.reflect && attribute && !this._reflecting) {
|
|
839
|
-
const serialized = serialize(value, property.type);
|
|
840
|
-
this._reflecting = true;
|
|
841
|
-
if (serialized === null) this.removeAttribute(attribute);
|
|
842
|
-
else this.setAttribute(attribute, serialized);
|
|
843
|
-
this._reflecting = false;
|
|
844
|
-
}
|
|
845
|
-
this.requestUpdate();
|
|
846
|
-
this.dispatchEvent?.(new CustomEvent(name + '-changed', {
|
|
847
|
-
detail: { value, oldValue }, bubbles: true, composed: true,
|
|
848
|
-
}));
|
|
849
|
-
},
|
|
850
|
-
});
|
|
851
|
-
}
|
|
852
|
-
Component.definition = { ...definition, attributeToProperty, observedAttributes };
|
|
853
|
-
const registry = globalThis.customElements || globalThis.window?.customElements;
|
|
854
|
-
if (registry && !registry.get(definition.tag)) {
|
|
855
|
-
registry.define(definition.tag, Component);
|
|
856
|
-
}
|
|
857
|
-
return Component;
|
|
858
|
-
}
|
|
859
|
-
`}function fr(e,n="./runtime.js"){let r=JSON.stringify({tag:e.tag,template:e.template,styles:e.styles,shadowMode:e.shadowMode,progressive:e.progressive,properties:e.properties,eventTypes:e.eventTypes,bindings:e.bindings},null,2),i=Object.entries(e.methods).map(([x,v])=>{if(Yo.has(x))throw Error(`${e.sourcePath}: ${Go(x)}`);if(/^(?:async\s+)?[A-Za-z_$][\w$]*\s*\(/.test(v.trim()))return` ${v.trim()}`;return` ${x}($event) {
|
|
860
|
-
${v}
|
|
861
|
-
}`}).join(`
|
|
862
|
-
|
|
863
|
-
`),a=e.scope,l=[...new Set([...Object.keys(e.properties),...a.propNames])].map((x)=>{let v=a.propBindings[x]||x;return a.defaults[x]===void 0?v:`${v} = ${a.defaults[x]}`}).join(", "),u=(x)=>x.split(`
|
|
864
|
-
`).map((v)=>v.trim()===""?v:` ${v}`).join(`
|
|
865
|
-
`),f="";if(e.render.trim()!==""||a.body!==""||l!==""){let x=[l?`const { ${l} } = this._props();`:"",a.body,"let out = '';",e.render,"return out;"].filter(Boolean).join(`
|
|
866
|
-
`),v;try{let I=new Bun.Transpiler({loader:"ts"}).transformSync(`export function __render(__helpers) {
|
|
867
|
-
${x}
|
|
868
|
-
}`),j=I.indexOf("{"),W=I.lastIndexOf("}");v=I.slice(j+1,W).trim()}catch(I){throw Error(`${e.sourcePath}: failed to compile render (${I.message})`)}f=`
|
|
869
|
-
render(__helpers) {
|
|
870
|
-
const { escape: __escape, raw: __raw, values: __values, entries: __entries } = __helpers;
|
|
871
|
-
${u(v.trim())}
|
|
872
|
-
}
|
|
873
|
-
`}return`import { StxElement, defineComponent } from ${n==="./runtime.js"?"'./runtime.js'":JSON.stringify(n)};
|
|
874
|
-
${a.imports.length?`${a.imports.join(`
|
|
875
|
-
`)}
|
|
876
|
-
`:""}
|
|
877
|
-
/** ${e.description||`${e.name} web component generated from ${e.file}.`} */
|
|
878
|
-
export class ${e.name} extends StxElement {
|
|
879
|
-
${i}${f}
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
defineComponent(${e.name}, ${r});
|
|
883
|
-
export default ${e.name};
|
|
884
|
-
`}function on(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"}}function Wu(e){let n=Object.entries(e.properties).map(([a,l])=>` ${a}${l.required?"":"?"}: ${on(l)}`).join(`
|
|
885
|
-
`),r=Object.entries(e.events).map(([a,l])=>` ${JSON.stringify(a)}: CustomEvent<${l.detailType||"unknown"}>`).join(`
|
|
886
|
-
`),i=Object.keys(e.methods).flatMap((a)=>e.methodDeclarations[a]||[`${a}($event?: Event): unknown`]).map((a)=>` ${a}`).join(`
|
|
887
|
-
`);return`${e.declarationTypes?`${e.declarationTypes}
|
|
888
|
-
|
|
889
|
-
`:""}export interface ${e.name}Props {
|
|
890
|
-
${n}
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
export interface ${e.name}EventMap {
|
|
894
|
-
${r}
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
export interface ${e.name} extends Required<Pick<${e.name}Props, Exclude<keyof ${e.name}Props, keyof HTMLElement>>> {}
|
|
898
|
-
|
|
899
|
-
export declare class ${e.name} extends HTMLElement {
|
|
900
|
-
${i}
|
|
901
|
-
readonly updateComplete: Promise<void>
|
|
902
|
-
requestUpdate(): Promise<void>
|
|
903
|
-
emit<T = unknown>(name: string, detail?: T, options?: CustomEventInit<T>): boolean
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
declare global {
|
|
907
|
-
interface HTMLElementTagNameMap {
|
|
908
|
-
${JSON.stringify(e.tag)}: ${e.name}
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
export default ${e.name}
|
|
913
|
-
`}function Fu(e){return`declare global {
|
|
914
|
-
namespace JSX {
|
|
915
|
-
interface IntrinsicElements {
|
|
916
|
-
${e.map((r)=>{let i=Object.entries(r.properties).map(([l,u])=>` ${JSON.stringify(l)}?: ${on(u)}`).join(`
|
|
917
|
-
`),a=Object.keys(r.events).map((l)=>` ${`on${l.split(/[-:]/).map((f)=>f.charAt(0).toUpperCase()+f.slice(1)).join("")}`}?: (event: CustomEvent<${r.events[l].detailType||"unknown"}>) => void`).join(`
|
|
918
|
-
`);return` ${JSON.stringify(r.tag)}: {
|
|
919
|
-
${i}
|
|
920
|
-
${a}
|
|
921
|
-
children?: unknown
|
|
922
|
-
slot?: string
|
|
923
|
-
class?: string
|
|
924
|
-
className?: string
|
|
925
|
-
}`}).join(`
|
|
926
|
-
`)}
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
export {}
|
|
932
|
-
`}function Vu(e){return{schemaVersion:"1.0.0",modules:e.map((n)=>({kind:"javascript-module",path:`./${n.tag}.js`,declarations:[{kind:"class",name:n.name,description:n.description||void 0,customElement:!0,tagName:n.tag,members:Object.entries(n.properties).map(([r,i])=>({kind:"field",name:r,description:i.description,type:{text:on(i)},default:i.default===void 0?void 0:JSON.stringify(i.default),attribute:i.attribute===!1?void 0:i.attribute||dr(r),reflects:i.reflect})),events:Object.entries(n.events).map(([r,i])=>({name:r,description:i.description,type:{text:`CustomEvent<${i.detailType||"unknown"}>`}})),slots:n.slots,cssProperties:n.cssProperties}],exports:[{kind:"js",name:n.name,declaration:{name:n.name,module:`./${n.tag}.js`}}]}))}}function Jo(e){if(!e.styles)return"";let n=e.styles.replace(/:host\b/g,":scope");if(/\@scope\s*\(/.test(n))return n;return`@scope (${e.tag}) {
|
|
933
|
-
${n}
|
|
934
|
-
}`}function Xo(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;,])\s*/g,"$1").replace(/;}/g,"}").trim()}function Uu(e){let n=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),r=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}"),i=JSON.stringify('<slot(?:\\s+name=["\\\']([^"\\\']+)["\\\'])?\\s*\\/?>(?:<\\/slot>)?'),a=Object.fromEntries(e.map((u)=>[u.tag,{template:u.template,styles:u.styles,shadowMode:u.shadowMode,properties:u.properties}])),l=e.map((u)=>`export const render${u.name} = (props = {}, slots = {}) => renderComponent('${u.tag}', props, slots);`).join(`
|
|
935
|
-
`);return`const definitions = ${JSON.stringify(a,null,2)};
|
|
936
|
-
const escapeHTML = (value) => String(value ?? '')
|
|
937
|
-
.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>')
|
|
938
|
-
.replaceAll('"', '"').replaceAll("'", ''');
|
|
939
|
-
const valueAt = (values, path) => path.trim().split('.').reduce((value, part) => value?.[part], values);
|
|
940
|
-
|
|
941
|
-
export function renderComponent(tag, props = {}, slots = {}) {
|
|
942
|
-
const definition = definitions[tag];
|
|
943
|
-
if (!definition) throw new Error('Unknown STX component: ' + tag);
|
|
944
|
-
const values = Object.fromEntries(Object.entries(definition.properties).map(([name, property]) => [name, property.default]));
|
|
945
|
-
Object.assign(values, props);
|
|
946
|
-
let template = definition.template
|
|
947
|
-
.replace(new RegExp(${n}, 'g'), (_match, expression) => String(valueAt(values, expression) ?? ''))
|
|
948
|
-
.replace(new RegExp(${r}, 'g'), (_match, expression) => escapeHTML(valueAt(values, expression)))
|
|
949
|
-
.replace(new RegExp(${i}, 'gi'), (_match, name) => String(slots[name || 'default'] ?? ''));
|
|
950
|
-
const attributes = Object.entries(definition.properties).flatMap(([name, property]) => {
|
|
951
|
-
if (property.attribute === false || !(name in props)) return [];
|
|
952
|
-
const attribute = property.attribute || name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase());
|
|
953
|
-
const value = props[name];
|
|
954
|
-
if (value == null || value === false) return [];
|
|
955
|
-
if (value === true) return [attribute];
|
|
956
|
-
const serialized = typeof value === 'object' ? JSON.stringify(value) : value;
|
|
957
|
-
return [attribute + '=\\"' + escapeHTML(serialized) + '\\"'];
|
|
958
|
-
}).join(' ');
|
|
959
|
-
if (definition.shadowMode) {
|
|
960
|
-
template = '<template shadowrootmode="' + definition.shadowMode + '">' +
|
|
961
|
-
(definition.styles ? '<style>' + definition.styles + '</style>' : '') + template + '</template>' +
|
|
962
|
-
String(slots.default ?? '');
|
|
963
|
-
}
|
|
964
|
-
return '<' + tag + (attributes ? ' ' + attributes : '') + '>' + template + '</' + tag + '>';
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
${l}
|
|
968
|
-
`}async function sl(e){let n=st.resolve(e.inputDir),r=st.resolve(e.outputDir);if(!(await Ko(n).catch(()=>null))?.isDirectory())throw Error(`Component-library input directory does not exist: ${n}`);let a=e.components?.length?e.components:(await Cu(n)).map((U)=>({file:U}));if(!a.length)throw Error(`No .stx components found in ${n}`);let l=await Promise.all(a.map((U)=>zu(n,U,e)));l.sort((U,q)=>U.tag.localeCompare(q.tag));let u=l.filter((U,q)=>l.findIndex((Z)=>Z.tag===U.tag)!==q);if(u.length)throw Error(`Duplicate custom-element tag: ${u[0].tag}`);let f=l.filter((U,q)=>l.findIndex((Z)=>Z.name===U.name)!==q);if(f.length)throw Error(`Duplicate component class name: ${f[0].name}`);await Ho(r,{recursive:!0});let x=[],v=async(U,q)=>{let Z=st.join(r,U);if(await Ho(st.dirname(Z),{recursive:!0}),await wu(Z,typeof q==="string"&&!q.endsWith(`
|
|
969
|
-
`)?`${q}
|
|
970
|
-
`:q),!x.includes(Z))x.push(Z);return Z};await v("runtime.js",Bu());for(let U of l){if(await v(`${U.tag}.js`,fr(U)),e.declarations!==!1)await v(`${U.tag}.d.ts`,Wu(U));if(e.css!==!1&&U.styles){let q=U.shadowMode?U.styles:Jo(U);await v(`${U.tag}.css`,e.minify?Xo(q):q)}}let I=new Bun.Transpiler({loader:"ts"});if(l.some((U)=>U.scope.imports.length||I.scanImports(fr(U)).some((q)=>q.kind==="dynamic-import"))){let U=l.map((ne)=>st.join(r,`${ne.tag}.js`)),q=new Map(await Promise.all(U.map(async(ne,ce)=>[await _u(ne),l[ce]])));for(let[ne,ce]of U.entries())q.set(ce,l[ne]);let Z=new Map(l.map((ne)=>[st.join(st.dirname(ne.sourcePath),`.stx-library-${ne.tag}.ts`),ne])),G=st.join(r,"runtime.js"),H=await Bun.build({entrypoints:U,outdir:r,root:r,target:"browser",format:"esm",splitting:!0,naming:{entry:"[name].js",chunk:"chunks/[name]-[hash].js"},minify:!1,loader:{".js":"ts"},plugins:[{name:"stx-element-runtime",setup(ne){ne.onResolve({filter:/.*/},(ce)=>{if(ce.path==="bun"||ce.path.startsWith("bun:")||ce.path.startsWith("node:")||Su.has(ce.path))throw Error(`Server-only import ${JSON.stringify(ce.path)} is not available in a browser component (${ce.importer})`);let de=q.get(ce.path);if(!ce.importer&&de)return{path:st.join(st.dirname(de.sourcePath),`.stx-library-${de.tag}.ts`)};if(ce.path===G&&Z.has(ce.importer))return{path:"./runtime.js",external:!0}}),ne.onLoad({filter:/\.ts$/},(ce)=>{let de=Z.get(ce.path);if(de)return{contents:fr(de,G),loader:"ts"}})}}]}).catch((ne)=>{let ce=(ne instanceof AggregateError?ne.errors:[ne]).map(String).join(`
|
|
971
|
-
`);throw Error(`Failed to bundle browser component imports
|
|
972
|
-
${ce}`)});if(!H.success)throw Error(`Failed to bundle component imports
|
|
973
|
-
${H.logs.map(String).join(`
|
|
974
|
-
`)}`);for(let ne of H.outputs)await v(st.relative(r,ne.path),new Uint8Array(await ne.arrayBuffer()))}let j=l.map((U)=>`export { ${U.name}, default as ${U.name}Element } from './${U.tag}.js';`).join(`
|
|
975
|
-
`);if(await v("index.js",j),await v("ssr.js",Uu(l)),e.declarations!==!1)await v("index.d.ts",l.map((U)=>`export * from './${U.tag}.js'`).join(`
|
|
976
|
-
`)),await v("custom-elements.d.ts",Fu(l)),await v("ssr.d.ts",`${l.map((U)=>`export declare const render${U.name}: (props?: ${U.name}Props, slots?: Record<string, string>) => string`).join(`
|
|
977
|
-
`)}
|
|
978
|
-
export declare function renderComponent(tag: string, props?: Record<string, unknown>, slots?: Record<string, string>): string
|
|
979
|
-
${l.map((U)=>`import type { ${U.name}Props } from './${U.tag}.js'`).join(`
|
|
980
|
-
`)}`);let W;if(e.manifest!==!1)W=await v("custom-elements.json",JSON.stringify(Vu(l),null,2));let M;if(e.css!==!1){let U=l.filter((q)=>!q.shadowMode&&q.styles).map(Jo).join(`
|
|
981
|
-
|
|
982
|
-
`);if(U)M=await v("bundle.css",e.minify?Xo(U):U)}let L;if(e.bundle!==!1){L=st.join(r,"bundle.js");let U;try{U=await Bun.build({entrypoints:[st.join(r,"index.js")],outdir:r,naming:"bundle.js",target:"browser",format:"esm",minify:e.minify??!0,sourcemap:e.sourcemap||"none"})}catch(q){let Z=q instanceof AggregateError?q.errors:[q],G=Z.map((H)=>String(H).trim()).filter(Boolean).join(`
|
|
983
|
-
`);throw AggregateError(Z,`Failed to bundle component library${G?`
|
|
984
|
-
${G}`:""}`)}if(!U.success){let q=U.logs.map((Z)=>String(Z).trim()).filter(Boolean).join(`
|
|
985
|
-
`);throw AggregateError(U.logs,`Failed to bundle component library${q?`
|
|
986
|
-
${q}`:""}`)}if(x.push(L),e.sourcemap==="external")x.push(`${L}.map`)}let V=await Promise.all(x.map(async(U)=>(await Ko(U)).size));return{components:l.map((U)=>({name:U.name,tag:U.tag,source:U.sourcePath,module:st.join(r,`${U.tag}.js`),styles:U.styles,shadowMode:U.shadowMode})),files:x,manifest:W,bundle:L,cssBundle:M,totalBytes:V.reduce((U,q)=>U+q,0)}}var Hu=new Set(mt);function Ut(e){let n=Bt(e),r=n.find((j)=>j.name==="InheritedContext");if(!r)return;let i=/^(?:interface\s+InheritedContext|type\s+InheritedContext\s*=)\s*\{/.test(t(r.text).trim()),a=t(e),l=E(a).depths,u=[...a.matchAll(/\b(?:interface|type)\s+InheritedContext\b/g)].find((j)=>l[j.index]===0)?.index??0,f=r.text.slice(r.text.indexOf("{")+1,r.text.lastIndexOf("}")),x=t(f),v=E(x).depths,I=[...x.matchAll(/(?:^|[;,\n])\s*(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:/g)].filter((j)=>v[j.index]===0).map((j)=>j[1]);return{keys:i?I:[],types:n.map((j)=>j.text).join(`
|
|
987
|
-
`),offset:Math.max(0,u),...!i?{unsupported:"InheritedContext requires a local non-generic object interface or object type alias with named properties"}:{}}}function Ku(e){let n=[],r=t(e);for(let i of e.matchAll(/\bimport\s+(type\s+)?([\w$*{}\s,]+?)\s+from\s*(['"])([^'"]+)\3/g)){if(i[1]||r.slice(i.index,i.index+6)!=="import")continue;let a=i[2].trim(),l=["stx","@stacksjs/stx"].includes(i[4]);if(/^[A-Za-z_$][\w$]*$/.test(a)){n.push(a);continue}if(!a.startsWith("{")||!a.endsWith("}"))continue;for(let u of a.slice(1,-1).split(",")){if(/^\s*type\s+/.test(u))continue;let[f,x=f]=u.trim().split(/\s+as\s+/);if(x&&!(l&&Hu.has(f)))n.push(x)}}return n}function eo(e){let n=Ut(e);if(!n||n.unsupported)return"";let r=new Set(ye(e));return n.keys.filter((i)=>!r.has(i)).map((i)=>`declare const ${i}: InheritedContext[${JSON.stringify(i)}];`).join(`
|
|
988
|
-
`)}function na(e,n){let r=[ms],i=[],a=new Map,l=dt.resolve(n.filePath),u=l.split(dt.sep).lastIndexOf("views"),f=u>=0?l.split(dt.sep).slice(0,u).join(dt.sep):dt.dirname(l),x=dt.resolve(n.partialsDir||dt.join(f,"partials")),v=dt.resolve(n.layoutsDir||dt.join(f,"views/layouts"));if([x,v].some((U)=>l===U||l.startsWith(U+dt.sep)))return{declarations:"",checks:i,dependencies:a};let I=(U)=>n.readTemplate?.(U)??(ea.existsSync(U)?ea.readFileSync(U,"utf8"):void 0),j=0,W=!1,M=[];function L(U,q){let Z=e.slice(0,U).split(`
|
|
989
|
-
`).length,G=U-e.lastIndexOf(`
|
|
990
|
-
`,U-1),H={code:e.slice(U,e.indexOf(`
|
|
991
|
-
`,U)<0?e.length:e.indexOf(`
|
|
992
|
-
`,U)),line:Z,column:G,kind:"directive",offset:U,anchor:!0};i.push({expression:H,statement:{text:`;${q}`,prefixLength:1}})}function V(U,q,Z,G,H,ne){let ce=`__StxInherited${j++}`;while((e+U+[...a.values()].join("")).includes(ce))ce+="_";let de=ke(U).filter((je)=>je.kind==="server").map((je)=>je.code).join(`
|
|
993
|
-
`),fe=`${ce}ParentValue`,Ce=`${ce}ParentType`;r.push(`type ${Ce} = ${Z};`);let Re=xr(_s(de,dt.dirname(q)),ce);r.push(...Re.imports);let we=Ut(de);if(we&&H!==void 0){W=!0;let je=Re.imports.length?Re.aliases.join(`
|
|
994
|
-
`):"",Te=hs(`${je}
|
|
995
|
-
${we.types}
|
|
996
|
-
const __contract = defineProps<InheritedContext>();`,`${ce}Contract`);r.push(Te.declarations),r.push(`declare const ${ce}Input: ${Ce};`),L(H,we.unsupported?`({})[${JSON.stringify(we.unsupported)}];`:`${ce}Input satisfies ${Te.props};`)}let xe=[...new Set([...ye(de),...Ku(de)])],He=[...new Set([...G,...we?.keys||[]])].filter((je)=>!xe.includes(je)),tt=we?`${Ce} & ${ce}Contract.__StxProps`:Ce,ct=_n(Re.body).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,""),nt=[],ht=an(U),ut=/@(include|extends|layout)\s*\(/g,rt;while(rt=ut.exec(ht)){let je=jn(ht,ut.lastIndex-1);if(!je)continue;ut.lastIndex=je.end;let Te=/^\s*(['"])(.*?)\1\s*(?:,\s*([\s\S]*))?$/.exec(je.expression);if(!Te){M.push({offset:H??rt.index,message:`Inherited context cannot be checked across dynamic @${rt[1]}`});continue}let pt=Te[2],et=rt[1];if(et!=="include"&&Te[3])M.push({offset:H??rt.index,message:`Inherited context cannot be checked for unsupported @${et} data arguments`});let ln=et==="include"?x:v,It=dt.resolve(pt.startsWith(".")?dt.dirname(q):ln,pt.endsWith(".stx")?pt:pt+".stx");if(I(It)===void 0){M.push({offset:H??rt.index,message:`Inherited context target cannot be resolved: ${pt}`});continue}nt.push({name:`edge${nt.length}`,target:It,kind:et,args:et==="include"?Te[3]||"{}":"{}",offset:H??rt.index})}let jt=`{ ...${fe}${xe.length?", "+xe.join(", "):""} }`;r.push(`namespace ${ce} {
|
|
997
|
-
${Re.aliases.join(`
|
|
998
|
-
`)}
|
|
999
|
-
export async function read(${fe}: ${H===void 0?"{}":tt}) {
|
|
1000
|
-
${He.length?`const { ${He.join(", ")} } = ${fe};`:""}
|
|
1001
|
-
${ct}
|
|
1002
|
-
return { context: ${jt}${nt.map((je)=>`, ${je.name}: { ...${jt}, ...(${je.args}) }`).join("")} };
|
|
1003
|
-
}
|
|
1004
|
-
}`);for(let je of nt){if(ne.includes(je.target)||ne.length>=32){M.push({offset:je.offset,message:"Inherited context cannot be checked across a cyclic or overly deep template graph"});continue}let Te=I(je.target);a.set(je.target,Te),V(Te,je.target,`Awaited<ReturnType<typeof ${ce}.read>>[${JSON.stringify(je.name)}]`,[...new Set([...G,...xe])],je.offset,[...ne,je.target])}return ce}if(V(e,l,"{}",[],void 0,[l]),W||n.contractsKnown)for(let U of M)L(U.offset,`({})[${JSON.stringify(U.message)}];`);return{declarations:W?r.join(`
|
|
1005
|
-
`):"",checks:i,dependencies:a}}function to(e,n){let r=rn(e),i=gr(e);if(!i)return;let a;try{a=mr(e,"component")}catch(H){let ne=i.open,ce=H instanceof Error?H.message:"Invalid component metadata";return{declarations:"",checks:[{text:`({})[${JSON.stringify(ce)}];`,line:e.slice(0,ne).split(`
|
|
1006
|
-
`).length,column:ne-e.lastIndexOf(`
|
|
1007
|
-
`,ne-1),origin:"component"}],project:(de)=>({code:de,columns:new Map})}}let l=se(r).filter((H)=>{let ne=O(H.attrs);return vt(ne)&&ne.has("client")&&!ne.has("server")&&!ne.has("component")&&!ne.has("stx:component")&&!ne.has("src")}),u=l.map((H)=>e.slice(H.bodyStart,H.bodyEnd)).join(`
|
|
1008
|
-
`),f=ys(u,n),x=Bt(u).some((H)=>H.name==="ComponentState")||ws(u).includes("ComponentState"),v=Object.entries(a.properties||a.props||{}).map(([H,ne])=>`${JSON.stringify(H)}: ${on(ne)}`).join("; "),I=[...new Set(f.map((H)=>H.name))],j=[`interface __StxMetadataProperties { ${v} }`,"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;",x?"type __StxState = __StxSpecific<ComponentState> extends true ? ComponentState : {};":"type __StxState = {};",x?'declare function __stxSpecificState(value: __StxSpecific<ComponentState> extends true ? true : "ComponentState requires named explicit fields without any or index signatures"): void;':"",x?"declare const __stxStateProperties: Pick<ComponentState, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;":"",x?'declare function __stxStateMethods(value: Extract<keyof ComponentState, __StxMethodNames | "emit" | "requestUpdate" | "updateComplete" | "renderRoot"> extends never ? true : "ComponentState cannot redeclare component methods"): void;':"",`type __StxMethodNames = ${I.map((H)=>JSON.stringify(H)).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">;',x?'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;",...I.map((H)=>`${JSON.stringify(H)}: typeof ${H};`),"}"].filter(Boolean).join(`
|
|
1009
|
-
`),W=-1;for(let H of l){let ne=H.bodyStart,ce=e.slice(ne,H.bodyEnd),de=t(ce),fe=E(de).depths,Ce=[...de.matchAll(/\b(?:interface|type)\s+ComponentState\b/g)].find((Re)=>fe[Re.index]===0)??(ws(ce).includes("ComponentState")?/\bComponentState\b/.exec(de):void 0);if(Ce){W=ne+Ce.index;break}}let M=x&&W>=0?[{origin:"client",text:"__stxSpecificState(true); __stxStateMethods(true); __stxOptionalPrivate(true); __stxStateProperties satisfies Pick<__StxInstanceProperties, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;",line:e.slice(0,W).split(`
|
|
1010
|
-
`).length,column:W-e.lastIndexOf(`
|
|
1011
|
-
`,W-1)}]:[],{start:L,code:V}=i,U=t(V),q=E(U).depths,Z=new Map,G=!1;for(let H of V.matchAll(/"(?:\\.|[^"\\])*"\s*:/g)){let ne=JSON.parse(H[0].slice(0,H[0].lastIndexOf(":")).trim());if(q[H.index]===1&&["properties","props"].includes(ne)){G=!0;continue}if(G&&q[H.index]===1)G=!1;if(G&&q[H.index]===2&&!Z.has(ne))Z.set(ne,L+H.index)}for(let[H,ne]of Object.entries(a.properties||a.props||{})){let ce=Z.get(H)??L,de=e.slice(0,ce).split(`
|
|
1012
|
-
`).length,fe=ce-e.lastIndexOf(`
|
|
1013
|
-
`,ce-1);if(!ne||typeof ne!=="object"||!["string","number","boolean","object","array"].includes(ne.type))M.push({text:`({})[${JSON.stringify(`Property ${H} must declare string, number, boolean, object or array`)}];`,line:de,column:fe,origin:"component"});if(ne&&ne.default!==void 0)M.push({text:`const __stxDefault${M.length}: ${on(ne)} = ${JSON.stringify(ne.default)};`,line:de,column:fe,origin:"component"})}return{declarations:j,checks:M,project(H){let ne=new Map,ce=[],de=0;for(let fe of ys(H,n)){if(/^\s*this\s*:/.test(fe.parameters))continue;let Ce=fe.parameterOffset,Re=`this: __StxNativeComponent${fe.parameters.trim()?", ":""}`;ce.push(H.slice(de,Ce),Re);let we=H.slice(0,Ce).split(`
|
|
1014
|
-
`).length,xe=Ce-H.lastIndexOf(`
|
|
1015
|
-
`,Ce-1),He=ne.get(we)||[],tt=He.at(-1),ct=xe+(tt?tt.generatedEnd-tt.sourceEnd:0);He.push({sourceStart:xe,sourceEnd:xe,generatedStart:ct,generatedEnd:ct+Re.length}),ne.set(we,He),de=Ce}return ce.push(H.slice(de)),{code:ce.join(""),columns:ne}}}}function sa(e){let n=[],r=[],i=/@foreach\s*\(|@endforeach\b/g,a;while(a=i.exec(e)){if(a[0].startsWith("@endforeach")){let x=r.pop();if(x)x.end=a.index,n.push(x);continue}let l=jn(e,i.lastIndex-1);if(!l)continue;let u=hr(l.expression),f=l.end;if(u)r.push({start:f,end:e.length,iterable:u.iterable,binding:u.key?`${u.value}, ${u.key}`:u.value});i.lastIndex=f}return n.sort((l,u)=>l.start-u.start)}function qu(e){let n=(r)=>r.replace(/[^\n]/g," ");return e.replace(/<!--[\s\S]*?-->/g,n).replace(/\{\{--[\s\S]*?--\}\}/g,n)}function ke(e){let n=[],r=qu(e);for(let i of se(r)){let a=i.attrs.trim(),l=O(a),{bodyStart:u,bodyEnd:f}=i,x=e.slice(u,f);if(l.has("src")||l.has("component")||l.has("stx:component"))continue;if(!vt(l))continue;let v=l.has("server")?"server":l.has("client")?"client":"plain",I=Nn(e,u);n.push({kind:v,code:x,startLine:I,startColumn:Ln(e,u),offset:u,attrs:a})}return n}function Nn(e,n){let r=1;for(let i=0;i<n&&i<e.length;i++)if(e.charCodeAt(i)===10)r++;return r}function Ln(e,n){let r=e.lastIndexOf(`
|
|
1016
|
-
`,n-1)+1;return n-r+1}function an(e){let n=e.split(""),r=(a,l)=>{for(let u=a;u<l&&u<n.length;u++)if(n[u]!==`
|
|
1017
|
-
`)n[u]=" "},i=[/<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 a of i){a.lastIndex=0;let l;while((l=a.exec(e))!==null)r(l.index,l.index+l[0].length)}return n.join("")}function da(e){let n=0,r="";for(let i=0;i<e.length;i++){let a=e[i];if(r){if(a==="\\"){i++;continue}if(a===r)r="";continue}if(a==='"'||a==="'"||a==="`"){r=a;continue}if(a==="("||a==="["||a==="{"){n++;continue}if(a===")"||a==="]"||a==="}"){n--;continue}if(a==="|"&&n===0){if(e[i+1]==="|"){i++;continue}if(e[i-1]==="|")continue;return e.slice(0,i)}}return e}var ga=new Set([":for","x-for","v-for"]),vs=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,yr="__stx_interpolated",ra="__StxElement",ma="__StxTemplateValue",Zu=`type ${ma}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function ia(e){return e.replace(/\{\{[\s\S]*?\}\}/g,yr).replace(/\{!![\s\S]*?!!\}/g,yr)}function Ju(e,n,r){let i=0;for(let a=n;a<e.length;a++){let l=e[a];if(l==="{"){i++;continue}if(l!=="}"&&l!=="!")continue;if(e.startsWith(r,a)&&i===0)return a;if(l==="}"&&i>0)i--}return-1}function Pi(e,n,r="0"){let i=`__stxScript${r}`;while((e+n).includes(i))i+="_";let a=new Map,l=[],u=[],f=t(e),x=va(e),v=[],I=0;for(let V=0;V<f.length;V++){let U=f.startsWith("{{",V);if(!U&&!f.startsWith("{!!",V))continue;let q=U?2:3,Z=U?"}}":"!!}",G=Ju(f,V+q,Z);if(G<0)continue;let H=V,ne=e.slice(H,G+Z.length),ce=ne.slice(q,-Z.length);V=G+Z.length-1;let de=u.length,fe=wr(x,H),Ce=wr(x,H+(U?2:3));u.push({code:da(ce),...Ce});let Re=`${i}_${de}`,we=ne.split(`
|
|
1018
|
-
`),xe=we[0].length;we[0]=Re+" ".repeat(Math.max(0,xe-Re.length));for(let nt=1;nt<we.length;nt++)we[nt]=we[nt].replace(/[^\r]/g," ");let He=a.get(fe.line)??[],tt=He.at(-1),ct=fe.column+(tt?tt.generatedEnd-tt.sourceEnd:0);He.push({sourceStart:fe.column,sourceEnd:fe.column+xe,generatedStart:ct,generatedEnd:ct+we[0].length}),a.set(fe.line,He),v.push(e.slice(I,H),we.join(`
|
|
1019
|
-
`)),I=H+ne.length}v.push(e.slice(I));let j=v.join("");if(!u.length)return{code:j,columns:a,declarations:l};let{imports:W,aliases:M,body:L}=xr(n,i);for(let V of W)l.push({text:V});l.push({text:`namespace ${i}Scope {
|
|
1020
|
-
${M.join(`
|
|
1021
|
-
`)}
|
|
1022
|
-
export async function read() {
|
|
1023
|
-
${_n(L).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,"")}
|
|
1024
|
-
return {`});for(let[V,U]of u.entries())l.push({text:`value${V}: (`}),l.push({text:U.code,origin:{line:U.line,column:U.column}}),l.push({text:"),"});l.push({text:`}
|
|
1025
|
-
}
|
|
1026
|
-
}`});for(let V=0;V<u.length;V++)l.push({text:`declare var ${i}_${V}: Awaited<ReturnType<typeof ${i}Scope.read>>['value${V}']`});return{code:j,columns:a,declarations:l}}function xr(e,n){let r=[],{imports:i,body:a}=xa(e),l=[],u=0;for(let f of i.split(/\n(?=import\b)/)){if(!f.trim())continue;let x=/^import\s+(?:type\s+)?([\s\S]+?)\s+from\s*(['"][^'"]+['"])/.exec(f);if(!x){r.push(f);continue}let v=`${n}Module${u++}`;r.push(`import * as ${v} from ${x[2]}`);let I=x[1],j=/\{([\s\S]*?)\}/.exec(I);for(let V of j?.[1].split(",")??[]){let[U,q=U]=V.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(U==="default")l.push(`const ${q} = ${v}.default; type ${q} = import(${x[2]}).default`);else if(U)l.push(`import ${q} = ${v}.${U}`)}let W=I.replace(/\{[\s\S]*?\}/,""),M=/\*\s+as\s+(\w+)/.exec(W);if(M)l.push(`import ${M[1]} = ${v}`);let L=/^\s*([\w$]+)/.exec(W)?.[1];if(L)l.push(`const ${L} = ${v}.default; type ${L} = import(${x[2]}).default`)}return{imports:r,aliases:l,body:a}}function br(e,n){let r=0;for(let i of e){if(n<i.generatedStart)break;if(n<i.generatedEnd)return i.sourceStart+Math.min(n-i.generatedStart,i.sourceEnd-i.sourceStart);r=i.sourceEnd-i.generatedEnd}return n+r}var Xu=["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"],Gu=new RegExp(String.raw`^[ \t]*@(?:${Xu.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function _n(e){return e.replace(Gu,(n)=>n.replace(/[^\n]/g," "))}var oa=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function no(e){let n=an(e),r=[],i=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,a;while((a=i.exec(n))!==null){if(a[1]||a[3])continue;let f=a[2]??a[4]??"",x=a[2]!==void 0?2:3,v=da(f);if(!v.trim())continue;let I=a.index+x+(v.length-v.trimStart().length);r.push({code:v.trim(),line:Nn(n,I),column:Ln(n,I),offset:I,kind:"interpolation"})}let l=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((a=l.exec(n))!==null){let u=a.index+a[0].length-1,f=0,x=u;for(;x<n.length;x++){let W=n[x];if(W==="(")f++;else if(W===")"){if(f--,f===0)break}}if(f!==0)continue;let v=n.slice(u+1,x),I=v.trim();if(l.lastIndex=x+1,!I)continue;let j=u+1+(v.length-v.trimStart().length);r.push({code:I,line:Nn(n,j),column:Ln(n,j),offset:a.index,kind:"condition"})}vs.lastIndex=0;while((a=vs.exec(n))!==null){let u=a[1],f=a[3]??"",x=u.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(oa.has(x)||oa.has(u))continue;if(!f.trim())continue;let v=a.index+a[0].indexOf(a[2],a[0].indexOf(u)+u.length)+1;if(ga.has(x)){let j=f.match(/\s+(?:in|of)\s+/);if(!j||j.index===void 0)continue;let W=f.slice(j.index+j[0].length),M=j.index+j[0].length+(W.length-W.trimStart().length);r.push({code:ia(W.trim()),line:Nn(n,v+M),column:Ln(n,v+M),offset:v+M,kind:"directive",attribute:x});continue}let I=f.length-f.trimStart().length;r.push({code:ia(f.trim()),line:Nn(n,v+I),column:Ln(n,v+I),offset:v+I,kind:"directive",attribute:x})}return r.sort((u,f)=>u.line-f.line||u.column-f.column),r}var Yu=2000;function Qu(e,n){let r=0,i=Math.min(e.length,n+Yu);for(let a=n;a<i;a++){let l=e[a];if(l==="(")r++;else if(l===")"){if(r--,r===0)return e.slice(n+1,a)}}return null}function ep(e){let n=new Map,r=(f,x)=>{let v=f.split(/[,[\]{}()\s]+/).filter(Boolean);for(let I of v){let j=I.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(j))continue;let W=v.length===1?x:void 0,M=n.get(j);if(!M)n.set(j,{name:j,iterable:W});else if(M.iterable!==W)M.iterable=void 0}},i=/^\$?[A-Z_$][\w$]*$/i,a=(f)=>{let x=f.trim();return i.test(x)?x:void 0};for(let f of e.matchAll(/@for(?:each|else)\s*\(/g)){let x=Qu(e,f.index+f[0].length-1);if(x===null)continue;let v=Vt(x);if(!v)continue;r(v.itemVar.replace(/=>/g," "),a(v.arrayExpr))}for(let f of e.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))r(f[1],f[2]==="of"?a(f[3]):void 0);for(let f of e.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))r(f[1]);let l=an(e);vs.lastIndex=0;let u;while((u=vs.exec(l))!==null){let f=u[1].replace(/\..*$/,"");if(!ga.has(f))continue;let x=u[3].match(/\s+(?:in|of)\s+/);if(!x||x.index===void 0)continue;r(u[3].slice(0,x.index),a(u[3].slice(x.index+x[0].length)))}for(let f of e.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let x of f[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))r(x[1]);return[...n.values()].sort((f,x)=>f.name.localeCompare(x.name))}function ye(e){return Dl(e)}var _r=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"],tp={$bool:"declare function $bool(value: unknown, fallback?: boolean): boolean",$num:"declare function $num(value: unknown, fallback?: number): number",$uid:"declare var $uid: string",$native:"declare var $native: boolean"};function ol(e=new Set){return[..._r.filter((n)=>!e.has(n)).map((n)=>`declare var ${n}: any`),...Object.entries(tp).filter(([n])=>!e.has(n)).map(([,n])=>n)].join(`
|
|
1027
|
-
`)}function il(e){return new Set([...e.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((n)=>n[1]))}function ha(e){let n=/\bdefineClientPayload\s*\(\s*\{([\s\S]*?)\}\s*\)/g,r,i=!1,a=new Set,l=t(e);while((r=n.exec(l))!==null){i=!0;for(let u of np(r[1])){let f=u.split(":")[0].trim();if(/^[A-Za-z_$][\w$]*$/.test(f))a.add(f)}}return i?[...a]:null}function np(e){let n=[],r=0,i="";for(let a of e){if(a===","&&r===0){n.push(i),i="";continue}if(a==="("||a==="["||a==="{")r++;else if(a===")"||a==="]"||a==="}")r--;i+=a}return n.push(i),n.filter((a)=>a.trim().length>0)}function xa(e){let n=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,r=[],i=e.replace(n,(a)=>(r.push(a.trim()),a.split(`
|
|
1028
|
-
`).map(()=>"").join(`
|
|
1029
|
-
`)));return{imports:r.join(`
|
|
1030
|
-
`),body:i}}function Bt(e){let n=t(e),r=Array(n.length),i=0;for(let f=0;f<n.length;f++){let x=n[f];if(x==="}"||x===")"||x==="]")i=Math.max(0,i-1);if(r[f]=i,x==="{"||x==="("||x==="[")i++}let a=[],l=/^[ \t]*(?:export[ \t]+)?(interface|type)[ \t]+([A-Za-z_$][\w$]*)/gm,u;while((u=l.exec(n))!==null){if(r[u.index]!==0)continue;let f=u[1],x=u[2],v;if(f==="interface"){let I=n.indexOf("{",u.index);if(I===-1)continue;let j=0;v=-1;for(let W=I;W<n.length;W++)if(n[W]==="{")j++;else if(n[W]==="}"&&--j===0){v=W+1;break}if(v===-1)continue}else{let I=0;v=n.length;for(let j=n.indexOf("=",u.index)+1;j<n.length;j++){let W=n[j];if(W==="{"||W==="["||W==="("||W==="<")I++;else if(W==="}"||W==="]"||W===")"||W===">")I--;else if(I<=0&&(W===";"||W===`
|
|
1031
|
-
`&&!/[=|&,<([{]\s*$/.test(n.slice(Math.max(0,j-40),j)))){v=W===";"?j+1:j;break}}}a.push({name:x,text:e.slice(u.index,v).replace(/^[ \t]*export[ \t]+/,"")}),l.lastIndex=v}return a}function sp(e){let n=t(e),r=[],i=/^[ \t]*(?:export[ \t]+)?(?:const|let|var)[ \t]+/gm,a,l=0,u=0;while((a=i.exec(n))!==null){for(;u<a.index;u++){let v=n[u];if(v==="{"||v==="("||v==="[")l++;else if(v==="}"||v===")"||v==="]")l=Math.max(0,l-1)}if(l!==0)continue;let f=0,x=n.length;for(let v=a.index+a[0].length;v<n.length;v++){let I=n[v];if(I==="{"||I==="("||I==="[")f++;else if(I==="}"||I===")"||I==="]")f--;else if(f<=0&&(I===";"||I===`
|
|
1032
|
-
`)){x=I===";"?v+1:v;break}}if(/\bdefineProps\s*(?:<|\()/.test(n.slice(a.index,x)))r.push(e.slice(a.index,x).replace(/^[ \t]*export[ \t]+/,"").trim())}return r}function Ii(e){let n=e.filter((a)=>a.kind==="server").map((a)=>a.code).join(`
|
|
1033
|
-
`);if(/\bdefineProps\s*(?:<|\()/.test(t(n)))return n;let r=ba(n),i=e.filter((a)=>a.kind!=="server").flatMap((a)=>{let l=sp(a.code);if(!l.length)return[];return[...Bt(a.code).filter((u)=>!r.has(u.name)).map((u)=>u.text),...l]});return[n,...i].filter(Boolean).join(`
|
|
1034
|
-
`)}function ba(e){return new Set(Bt(e).map((n)=>n.name))}function al(e,n=""){let r=ha(e),i=ba(n),a=Bt(e).filter((v)=>!i.has(v.name)).map((v)=>v.text);if(!r){let v=ye(e).filter((I)=>!zt(n,I));if(v.length===0&&a.length===0)return"";return["",`// ${op}`,...a,...v.map((I)=>`declare var ${I}: any`)].join(`
|
|
1035
|
-
`)}if(r.length===0)return a.length>0?["",`// ${ca}`,...a].join(`
|
|
1036
|
-
`):"";let{imports:l,body:u}=xa(e),f=u.replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class)\b)/gm,""),x=["",`// ${ca}`];if(l)x.push(l);return x.push(...a),x.push(`async function ${la}() {`,f,` return { ${r.join(", ")} }`,"}",`type ${ua} = Awaited<ReturnType<typeof ${la}>>`,...r.map((v)=>`declare var ${v}: ${ua}[${JSON.stringify(v)}]`)),x.join(`
|
|
1037
|
-
`)}function Oi(e){let n=t(e),r=n.split(""),i=[],a=0,l=0;for(let f=0;f<r.length;f++){let x=r[f];if(x===`
|
|
1038
|
-
`)l=f+1;if(x==="{"||x==="("||x==="["){if(a===0&&x!=="("&&rp.test(n.slice(l,f))){let v=ya(n,f);if(v!==-1)i.push(..._a(n.slice(f,v+1)))}a++;continue}if(x==="}"||x===")"||x==="]"){a=Math.max(0,a-1);continue}if(a>0&&x!==`
|
|
1039
|
-
`)r[f]=" "}let u=ye(r.join(""));return i.length===0?u:[...new Set([...u,...i])].sort()}var rp=/^\s*(?:export\s+)?(?:const|let|var)\s*$/;function ya(e,n){let r=0;for(let i=n;i<e.length;i++){let a=e[i];if(a==="{"||a==="("||a==="[")r++;else if(a==="}"||a===")"||a==="]")r--;if(r===0)return i}return-1}function ip(e){let n=[],r=0,i=0;for(let a=0;a<e.length;a++){let l=e[a];if(l==="{"||l==="("||l==="[")r++;else if(l==="}"||l===")"||l==="]")r--;else if(l===","&&r===0)n.push(e.slice(i,a)),i=a+1}return n.push(e.slice(i)),n}function aa(e){let n=0;for(let r=0;r<e.length;r++){let i=e[r];if(i==="{"||i==="("||i==="[")n++;else if(i==="}"||i===")"||i==="]")n--;else if(n===0&&(i===":"||i==="="))return{index:r,char:i}}return null}function _a(e){let n=[],r=(a)=>{let l=a.trim().replace(/^\.\.\./,"").trim();if(l.startsWith("{")||l.startsWith("[")){let f=ya(l,0);if(f!==-1)n.push(..._a(l.slice(0,f+1)));return}let u=aa(l);if(u)l=l.slice(0,u.index).trim();if(/^[A-Z_$][\w$]*$/i.test(l))n.push(l)},i=e.slice(1,-1);for(let a of ip(i)){if(!a.trim())continue;if(e[0]==="["){r(a);continue}let l=aa(a);r(l?.char===":"?a.slice(l.index+1):a)}return n}function cl(e,n){if(ha(e)!==null)return[];let r=Oi(e),i=De(n,new Set(r)),a=new Set(_);return r.filter((l)=>{if(a.has(l))return!1;if(zt(n,l))return!1;return i.has(l)})}var ca="stx: types for the declared client payload (#1868)",op="stx: untyped bridge names \u2014 declare a defineClientPayload to check these (#1868)",la="__stxServerScope",ua="__StxClientPayload";var pa=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","$native","props","slot"];var ap=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function cp(e){let n=new Map,r=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let i of e){let a=t(i),{depths:l,balanced:u}=E(a);if(!u)continue;let f=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let x of a.matchAll(f)){let v=x.index??0;if(l[v+x[1].length]!==0)continue;let I=x[2],j=v+x[0].length-x[3].length,W=i.slice(j,v+x[0].length).trim().replace(/;$/,"").trim(),M=x[3],L=r.test(M)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(M)&&!/[,+\-*/%&|?:=]$/.test(W)&&E(M).balanced;n.set(I,n.has(I)||!L?null:W)}}return new Map([...n].filter((i)=>i[1]!==null))}function wa(e,n,r=0,i=new Set){if(n.size===0||r>=5)return e;let a=t(e),l="",u=0;for(let f of a.matchAll(/[A-Za-z_$][\w$]*/g)){let x=f.index??0,v=f[0],I=n.get(v);if(!I||i.has(v))continue;let j=a.slice(0,x).trimEnd(),W=a.slice(x+v.length).trimStart();if(j.endsWith(".")||/^:(?!:)/.test(W)&&/[{,]$/.test(j))continue;if(x>0&&/[\w$]/.test(a[x-1]))continue;l+=`${e.slice(u,x)}(${wa(I,n,r+1,new Set([...i,v]))})`,u=x+v.length}return l+e.slice(u)}function lp(e,n){let r=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,i=[],a;while((a=r.exec(e))!==null){if(a.index>n)break;let l=a[1];if(a.index===n){if(l==="elseif"){let f=i[i.length-1];if(f?.current)f.seen.push(f.current);if(f)f.current=null}break}if(l==="endif"||l==="endunless"){i.pop();continue}let u="";if(a[2]==="("){let f=0,x=a.index+a[0].length-1,v=x+1;for(;x<e.length;x++){let I=e[x];if(I==="(")f++;else if(I===")"){if(f--,f===0)break}}u=e.slice(v,x).trim(),r.lastIndex=x+1}if(l==="if")i.push({seen:[],current:u});else if(l==="unless")i.push({seen:[],current:`!(${u})`});else if(l==="elseif"||l==="else"){let f=i[i.length-1];if(!f)continue;if(f.current)f.seen.push(f.current);f.current=l==="elseif"?u:null}}return i.flatMap((l)=>[...l.seen.map((u)=>`!(${u})`),...l.current?[l.current]:[]]).filter(Boolean)}function up(e){let n=e.code.trim();if(!n)return null;if(e.attribute?.startsWith("@")){if(ap.test(n))return null;let i=";(($event: any): void => { ";return{text:`${i}${n} });`,prefixLength:i.length}}let r=";void ((";return{text:`${r}${n}));`,prefixLength:r.length}}var pp=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function _s(e,n){return ro(e,n).code}function ro(e,n){let r=new Map;if(!n)return{code:e,columns:r};let i=va(e),a=[],l=0;for(let u of e.matchAll(pp)){let f=u.index,[x,v,I,j]=u,W=fa.resolve(n,j).replace(/\\/g,"/"),M=`${v}${I}${W}${I}`;if(a.push(e.slice(l,f),M),l=f+x.length,x.includes(`
|
|
1040
|
-
`))continue;let L=wr(i,f),V=r.get(L.line)??[],U=V.at(-1),q=L.column+(U?U.generatedEnd-U.sourceEnd:0);V.push({sourceStart:L.column,sourceEnd:L.column+x.length,generatedStart:q,generatedEnd:q+M.length}),r.set(L.line,V)}return a.push(e.slice(l)),{code:a.join(""),columns:r}}function fp(e,n,r){let i=br(e.importColumns?.get(n)??[],r);return br(e.scriptColumns?.get(n)??[],br(e.componentColumns?.get(n)??[],i))}function Ni(e){return" ".repeat(Math.max(0,(e.startColumn??1)-1))}function ws(e){let n=new Set,r=t(e);for(let i of r.matchAll(/\bimport\s+(?:type\s+)?([\w$*{}\s,]+?)\s+from\b/g)){let a=i[1],l=/\{([^}]*)\}/.exec(a);for(let v of l?.[1].split(",")??[]){let I=v.trim().replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim();if(I&&/^[A-Z_$][\w$]*$/i.test(I))n.add(I)}let u=a.replace(/\{[^}]*\}/,""),f=/\*\s*as\s+([A-Z_$][\w$]*)/i.exec(u);if(f)n.add(f[1]);let x=/^\s*([A-Z_$][\w$]*)/i.exec(u);if(x&&x[1]!=="type")n.add(x[1])}return[...n].sort()}function Mi(e,n={}){let r=ke(e),i=n.scriptKinds?r.filter((H)=>n.scriptKinds.includes(H.kind)):r,a=to(e,n.componentMethodValidator),l=n.filePath&&n.templateExpressions!==!1?na(e,{filePath:n.filePath,partialsDir:n.partialsDir,layoutsDir:n.layoutsDir,contractsKnown:n.inheritedContractsKnown,readTemplate:n.readComponent}):void 0,u=new Map,f=e.split(`
|
|
1041
|
-
`),x=Array.from({length:f.length},()=>""),v=new Map,I=new Map,j=new Map,W=[],M=Ii(r),L=n.filePath&&n.templateExpressions!==!1?Vo(e,an(e),{filePath:n.filePath,componentsDir:n.componentsDir,projectRoot:n.projectRoot,readComponent:n.readComponent,scriptCode:(H,ne)=>ke(H).map((ce)=>_s(ce.code,fa.dirname(ne))).join(`
|
|
1042
|
-
`)}):void 0,V=new Set,U=[];for(let[H,ne]of i.entries()){let ce=Pi(Ni(ne)+ne.code,M,String(H));for(let[we,xe]of ce.columns)I.set(ne.startLine+we-1,xe);for(let we of ce.declarations)W.push({text:_s(we.text,n.originDir??""),origin:we.origin?{...we.origin,line:we.origin.line+ne.startLine-1}:void 0});let de=ne.kind==="client"&&a?a.project(ce.code):void 0;for(let[we,xe]of de?.columns??[])u.set(ne.startLine+we-1,xe);let fe=_n(de?.code??ce.code),Ce=ro(fe,n.originDir??"");for(let[we,xe]of Ce.columns)j.set(ne.startLine+we-1,xe);let Re=Ce.code.split(`
|
|
1043
|
-
`);Re.forEach((we,xe)=>{let He=ne.startLine-1+xe;if(He<x.length)x[He]=we,V.add(He)}),U.push(ne.startLine-1+Re.length-1)}for(let H of U){let ne=x[H]?.trim()===""?H:H+1;if(ne<x.length&&x[ne].trim()===""&&(ne===H||!V.has(ne)))x[ne]=";"}let q=(H,ne)=>{for(let[ce,de]of H.split(`
|
|
1044
|
-
`).entries())if(x.push(de),ne)v.set(x.length,ce===0?ne:{...ne,line:ne.line+ce,column:1,prefixLength:0})},Z=eo(i.filter((H)=>H.kind==="server").map((H)=>H.code).join(`
|
|
1045
|
-
`));if(Z)q(Z);for(let H of i.filter((ne)=>ne.kind==="server")){let ne=Ut(H.code);if(!ne?.unsupported)continue;let ce=H.code.slice(0,ne.offset),de=H.startLine+ce.split(`
|
|
1046
|
-
`).length-1,fe=ne.offset-H.code.lastIndexOf(`
|
|
1047
|
-
`,ne.offset-1)+(de===H.startLine?(H.startColumn??1)-1:0);q(`;({})[${JSON.stringify(ne.unsupported)}];`,{line:de,column:fe,anchor:!0})}if(l?.declarations)q(l.declarations);for(let H of W)q(H.text,H.origin);if(a){if(q(a.declarations),n.nativeChecks!==!1)for(let H of a.checks)q(H.text,{line:H.line,column:H.column,diagnosticOrigin:H.origin,anchor:!0})}if(n.globals!==!1){q("");let H=new Set([...i.flatMap((fe)=>ye(fe.code)),...i.flatMap((fe)=>ws(fe.code))]),ne=(fe)=>{if(!H.has(fe)&&!n.declaredGlobals?.includes(fe))q(`declare var ${fe}: any`)};if(n.runtimeGlobals!==!1){if(!H.has("window"))q("declare var window: any");for(let fe of _)ne(fe)}let ce=[...new Set([..._r,...Pe,...pa])].filter((fe)=>!n.declaredGlobals?.includes(fe)&&(n.runtimeGlobals!==!1||!_.includes(fe)));if(n.contextScope==="global"){q("declare global {");for(let fe of ce)q(` var ${fe}: any`);q("}")}else{for(let fe of _r)ne(fe);for(let fe of Pe)ne(fe);for(let fe of pa)ne(fe)}q(`declare var ${yr}: any`);let de=new Set(i.flatMap((fe)=>ye(fe.code)));q(`type ${ra}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let fe of a?[]:ep(e)){if(de.has(fe.name))continue;let Ce=fe.iterable&&de.has(fe.iterable)?`${ra}<typeof ${fe.iterable}>`:"any";q(`declare var ${fe.name}: ${Ce}`)}}if(n.templateExpressions!==!1){if(L?.declarations)for(let ne of L.declarations.split(`
|
|
1048
|
-
`))q(ne);let H=no(e).map((ne)=>{let ce=L?.events.get(ne.offset??-1);if(ce){ne.anchor=!0;let de=ne.code.trim(),fe=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(de),Ce=fe?`void ((${fe[2]}) satisfies __StxAssignedValue<typeof ${fe[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(de)?`${de} satisfies (($event: ${ce}) => unknown)`:de,Re=`;(($event: ${ce}): void => { `;return{expression:ne,statement:{text:`${Re}${Ce} });`,prefixLength:Re.length}}}return{expression:ne,statement:up(ne)}}).filter((ne)=>ne.statement!==null);if(H.push(...L?.checks||[],...l?.checks||[]),H.length>0){let ne=an(e),ce=ds(ne),de=a?sa(ne):[];if(a)q("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 fe=cp(i.map((xe)=>xe.code)),Re=[...new Set(i.flatMap((xe)=>ye(xe.code)))].filter((xe)=>/^[A-Z_$][\w$]*$/i.test(xe)),we=0;if(a)q("function __stxNativeTemplate(this: __StxNativeComponent) {");if(Re.length>0){q(Zu);for(let xe of Re)q(`function __StxRead_${xe}() { return ${xe} }`),q(`type __StxT_${xe} = ${ma}<ReturnType<typeof __StxRead_${xe}>>`);q(`;((${Re.map((xe)=>`${xe}: __StxT_${xe}`).join(", ")}) => {`),we=1}for(let{expression:xe,statement:He}of H){let tt=" ".repeat(we),ct=xe.offset===void 0?[]:ce.filter((et)=>xe.offset>=et.start&&xe.offset<et.end),nt=xe.offset===void 0?[]:de.filter((et)=>xe.offset>=et.start&&xe.offset<et.end),ht=nt.map((et)=>`;__stxEach(${et.iterable}, (${et.binding}) => { `).join(""),ut=" });".repeat(nt.length),rt=ht+ct.map((et)=>`;((${et.binding.replace(/[\r\n]/g," ")}: any) => { `).join(""),jt=" });".repeat(ct.length)+ut,je=xe.offset===void 0?[]:lp(ne,xe.offset),Te=je.length>0?`${je.map((et)=>`if (${wa(et,fe)}) `).join("")}{ `:"",pt=je.length>0?" }":"";q(tt+rt+Te+He.text+pt+jt,{line:xe.line,column:xe.column,expression:xe,prefixLength:He.prefixLength+tt.length+rt.length+Te.length,guardPrefixLength:tt.length+rt.length+Te.length})}if(we>0)q("});");if(a)q("}")}}let G=!1;if(n.reference&&x[0]!==void 0&&x[0].trim()==="")x[0]=`/// <reference path=${JSON.stringify(n.reference.replace(/\\/g,"/"))} />`,G=!0;return q("export {}"),{text:x.join(`
|
|
1049
|
-
`),lineMap:v,sourceLineCount:f.length,componentDependencies:new Map([...L?.dependencies??[],...l?.dependencies??[]]),referenced:G,scriptColumns:I,importColumns:j,componentColumns:u}}function va(e){let n=[0];for(let r=0;r<e.length;r++)if(e.charCodeAt(r)===10)n.push(r+1);return n}function wr(e,n){let r=0,i=e.length-1;while(r<i){let a=Math.ceil((r+i)/2);if(e[a]<=n)r=a;else i=a-1}return{line:r+1,column:n-e[r]+1}}function ll(e,n){if(!e.expression)return!1;return e.inGuard===!0||n===2774}function Di(e,n,r){let i=e.lineMap.get(n);if(!i)return n<=e.sourceLineCount?{line:n,column:fp(e,n,r)}:null;let a=i.anchor||i.expression?.anchor||i.diagnosticOrigin==="component"?0:Math.max(0,r-1-(i.prefixLength??0));return{line:i.line,column:i.column+a,expression:i.expression,diagnosticOrigin:i.diagnosticOrigin,inGuard:r<=(i.guardPrefixLength??0)}}var vr=S(256),dp=[{pattern:/document\.getElementById\s*\(/g,message:"document.getElementById() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelector\s*\(/g,message:"document.querySelector() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelectorAll\s*\(/g,message:"document.querySelectorAll() is prohibited",suggestion:'Use useRef("name") and access children instead'},{pattern:/document\.getElementsBy\w+\s*\(/g,message:"document.getElementsBy*() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.createElement\s*\(/g,message:"document.createElement() is prohibited",suggestion:"Use template directives or component composition instead"},{pattern:/document\.activeElement(?![A-Za-z])/g,message:"document.activeElement is prohibited",suggestion:"Use useRef() to track focused elements"},{pattern:/document\.title\s*=/g,message:"document.title assignment is prohibited",suggestion:"Use useTitle() from composables"},{pattern:/document\.cookie(?![A-Za-z])/g,message:"document.cookie is prohibited",suggestion:"Use useCookie() from composables"},{pattern:/document\.addEventListener\s*\(/g,message:"document.addEventListener() is prohibited",suggestion:"Use useEventListener() or template @event directives"},{pattern:/window\.location(?![A-Za-z])/g,message:"window.location is prohibited",suggestion:"Use navigate() or useRoute()"},{pattern:/window\.history(?![A-Za-z])/g,message:"window.history is prohibited",suggestion:"Use navigate(), goBack(), goForward()"},{pattern:/window\.addEventListener\s*\(/g,message:"window.addEventListener() is prohibited",suggestion:"Use useEventListener() or @click directives"},{pattern:/(?:\bwindow\.)?localStorage(?![A-Za-z])/g,message:"window.localStorage is prohibited",suggestion:"Use useLocalStorage() from composables \u2014 or, where this must run before first paint and the runtime does not exist yet, the colorMode config for a light/dark theme, or @appearanceBootstrap when there is a second appearance axis"},{pattern:/window\.sessionStorage(?![A-Za-z])/g,message:"window.sessionStorage is prohibited",suggestion:"Use useSessionStorage() from composables"},{pattern:/window\.scrollTo\s*\(/g,message:"window.scrollTo() is prohibited",suggestion:"Use useScroll().scrollTo() from composables"},{pattern:/window\.alert\s*\(/g,message:"window.alert() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.confirm\s*\(/g,message:"window.confirm() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.prompt\s*\(/g,message:"window.prompt() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/(?<!\w)setTimeout\s*\(/g,message:"setTimeout() is prohibited",suggestion:"Use useTimeout() or useDebounce() from composables"},{pattern:/(?<!\w)setInterval\s*\(/g,message:"setInterval() is prohibited",suggestion:"Use useInterval() from composables"},{pattern:/(?<!\w)clearTimeout\s*\(/g,message:"clearTimeout() is prohibited",suggestion:"Use useTimeout().stop() or useDebounce().cancel()"},{pattern:/(?<!\w)clearInterval\s*\(/g,message:"clearInterval() is prohibited",suggestion:"Use useInterval().pause()"},{pattern:/(?<!\w)location\.href\s*=/g,message:"location.href assignment is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.assign\s*\(/g,message:"location.assign() is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.replace\s*\(/g,message:"location.replace() is prohibited",suggestion:"Use navigate() instead"}],Sa=/(?:\/\/|\/\*|\{\{--)\s*stx-strict-ignore(-next-line)?([^\n*}]*)/g;function gp(e){let n=Array.from(e,(a)=>a===`
|
|
1050
|
-
`?`
|
|
1051
|
-
`:" "),r=0,i="";while(r<e.length){let a=e[r],l=e[r+1];if(i){if(a==="\\"){r+=2;continue}if(a===i)i="";r++;continue}if(a==='"'||a==="'"||a==="`"){i=a,r++;continue}if(a==="/"&&l==="/"){while(r<e.length&&e[r]!==`
|
|
1052
|
-
`)n[r]=e[r],r++;continue}if(a==="/"&&l==="*"){let u=e.indexOf("*/",r+2),f=u===-1?e.length:u+2;for(;r<f;r++)n[r]=e[r];continue}if(a==="{"&&l==="{"&&e.slice(r,r+4)==="{{--"){let u=e.indexOf("--}}",r+4),f=u===-1?e.length:u+4;for(;r<f;r++)n[r]=e[r];continue}r++}return n.join("")}function mp(e){let n=new Map,r=gp(e).split(`
|
|
1053
|
-
`),i=e.split(`
|
|
1054
|
-
`);return r.forEach((a,l)=>{Sa.lastIndex=0;for(let u of a.matchAll(Sa)){let f=u[1]==="-next-line",x=(i[l]??"").slice(0,u.index).trim(),v=f||x===""?l+2:l+1,j=(u[2]??"").split("--")[0].split(/[\s,]+/).filter(Boolean),W=j.filter((L)=>/\w/.test(L));if(j.length>0&&W.length===0)continue;let M=n.get(v);if(M&&M.size===0)continue;if(W.length===0){n.set(v,new Set);continue}if(M)W.forEach((L)=>M.add(L));else n.set(v,new Set(W))}}),n}function hp(e,n,r){let i=e.get(n);if(!i)return!1;if(i.size===0)return!0;return[...i].some((a)=>r.includes(a))}function Ue(e,n,r,i){let a=typeof r==="boolean"?{enabled:r,failOnViolation:r}:r??{enabled:!1};if(!a.enabled)return;let l=C(e,n,i,JSON.stringify(a)),u=vr.get(l);if(u!==void 0){if(u&&a.failOnViolation)throw new ee(u,i??n);return}let f=a.allowPatterns??[],x=mp(e),v=[],I=t(e.replace(/\{\{--[\s\S]*?--\}\}/g,(L)=>L.replace(/[^\n]/g," ")));for(let{pattern:L,message:V,suggestion:U}of dp){if(f.some((Z)=>/\w/.test(Z)&&V.includes(Z)))continue;L.lastIndex=0;let q=I.match(L);if(q&&q.length>0){let Z=I.split(`
|
|
1055
|
-
`),G=e.split(`
|
|
1056
|
-
`),H=[];if(Z.forEach((fe,Ce)=>{if(L.lastIndex=0,L.test(fe)&&!hp(x,Ce+1,V))H.push(Ce+1)}),H.length===0&&Z.some((fe)=>(L.lastIndex=0,L.test(fe))))continue;let ne=H.length>0?` (script line${H.length>1?"s":""} ${H.join(", ")})`:"",ce=H.slice(0,3).map((fe)=>` ${fe} | ${(G[fe-1]??"").trim().slice(0,100)}`).join(`
|
|
1057
|
-
`),de=ce?`
|
|
1058
|
-
${ce}`:"";v.push(` \u2717 ${V}${ne}
|
|
1059
|
-
\u2192 ${U}${de}`)}}if(v.length===0){vr.set(l,"");return}let j=(L)=>{let V=`${process.cwd()}/`;return L.startsWith(V)?L.slice(V.length):L},M=`[STX] DOM API violation in ${i&&i!==n?`${j(i)} (composed into ${j(n)})`:j(n)}:
|
|
1060
|
-
${v.join(`
|
|
1061
|
-
`)}
|
|
1062
|
-
Tip: prefer useRef(), navigate(), and composables for component code`;if(vr.set(l,M),console.warn(M),a.failOnViolation)throw new ee(M,i??n)}var xp=[{open:"@if",close:"@endif",name:"if"},{open:"@unless",close:"@endunless",name:"unless"},{open:"@foreach",close:"@endforeach",name:"foreach"},{open:"@for",close:"@endfor",name:"for"},{open:"@while",close:"@endwhile",name:"while"},{open:"@forelse",close:"@endforelse",name:"forelse"},{open:"@switch",close:"@endswitch",name:"switch"},{open:"@isset",close:"@endisset",name:"isset"},{open:"@empty",close:"@endempty",name:"empty"},{open:"@auth",close:"@endauth",name:"auth"},{open:"@guest",close:"@endguest",name:"guest"},{open:"@can",close:"@endcan",name:"can"},{open:"@cannot",close:"@endcannot",name:"cannot"},{open:"@section",close:"@endsection",name:"section",altClose:"@show"},{open:"@push",close:"@endpush",name:"push"},{open:"@prepend",close:"@endprepend",name:"prepend"},{open:"@once",close:"@endonce",name:"once"},{open:"@markdown",close:"@endmarkdown",name:"markdown"},{open:"@component",close:"@endcomponent",name:"component"}],bp=[{pattern:/@if\s*[^(]/,message:"@if directive missing parentheses",suggestion:"Use @if(condition)"},{pattern:/@foreach\s*[^(]/,message:"@foreach directive missing parentheses",suggestion:"Use @foreach(items as item)"},{pattern:/@foreach\([^)]*\)\s*[^@\n<]/,message:"@foreach may have content on same line",suggestion:"Put content on new line after @foreach()"},{pattern:/@include\s*[^(]/,message:"@include directive missing parentheses",suggestion:"Use @include('partial-name')"},{pattern:/@extends\s*[^(]/,message:"@extends directive missing parentheses",suggestion:"Use @extends('layout-name') or @layout('layout-name')"},{pattern:/@layout\s*[^(]/,message:"@layout directive missing parentheses",suggestion:"Use @layout('layout-name')"}],yp=[{pattern:/\{\{\s*constructor\s*\}\}/,message:"Attempting to access constructor property"},{pattern:/\{\{\s*__proto__\s*\}\}/,message:"Attempting to access __proto__ property"},{pattern:/\{\{\s*eval\s*\(/,message:"Attempting to use eval in expression"}];function jg(e){let n=[],r=[];return _p(e,n),wp(e,n,r),vp(e,r),Sp(e,n),{valid:n.length===0,errors:n,warnings:r}}function _p(e,n){let r=(e.match(/\{\{/g)||[]).length,i=(e.match(/\}\}/g)||[]).length;if(r!==i)n.push({type:"expression",message:`Unclosed expression brackets: found ${r} opening '{{' and ${i} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function wp(e,n,r){for(let i of xp){let a=new RegExp(`${i.open}(?:\\s|\\()`,"g"),l=new RegExp(i.close,"g"),u=(e.match(a)||[]).length,f=(e.match(l)||[]).length;if(i.altClose){let x=new RegExp(i.altClose,"g");f+=(e.match(x)||[]).length}if(u>f)n.push({type:"directive",message:`Unclosed @${i.name} directive: found ${u} opening and ${f} closing`,suggestion:`Add ${u-f} missing ${i.close} tag(s)`});else if(f>u)r.push({type:"directive",message:`Extra ${i.close} found: ${f-u} more closing than opening`,suggestion:`Check for orphaned ${i.close} tags`})}}function vp(e,n){for(let r of bp)if(r.pattern.test(e))n.push({type:"syntax",message:r.message,suggestion:r.suggestion})}function Sp(e,n){for(let r of yp)if(r.pattern.test(e))n.push({type:"expression",message:`Security warning: ${r.message}`,suggestion:"Remove dangerous code from template expressions"})}function Bg(e,n){let r=e.slice(0,n).split(`
|
|
1063
|
-
`);return{line:r.length,column:r[r.length-1].length+1}}function Fg(e,n,r){let i=[];switch(e){case"if":case"elseif":case"unless":if(r.length===0)i.push({type:"syntax",message:`@${e} requires a condition`,suggestion:`Use @${e}(condition)`});break;case"foreach":if(r.length===0||!r[0].includes(" as "))i.push({type:"syntax",message:'@foreach requires "items as item" syntax',suggestion:"Use @foreach(items as item) or @foreach(items as key => value)"});break;case"for":if(r.length===0)i.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(r.length===0)i.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(r.length===0)i.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(r.length===0)i.push({type:"syntax",message:`@${e} requires a path`,suggestion:`Use @${e}('path/to/template')`});break}return i}function zg(e){return/@[a-z]+/i.test(e)||/\{\{/.test(e)}function Hg(e){let n=e.matchAll(/@([a-z]+)/gi),r=new Set;for(let i of n){let a=i[1].toLowerCase();if(!a.startsWith("end"))r.add(a)}return Array.from(r)}function $a(e,n,r){let i=/^<script\b([^>]*)>/i.exec(e);if(!i||!/(?:^|\s)src\s*=/i.test(i[1]??""))return null;return P(i[0],n,r)+e.slice(i[0].length)}var zn=new T(500),Er=new Map;function Ea(e){try{let n=ks.statSync(e);return`${n.size}:${n.mtimeMs}`}catch{return""}}var $s=new T(1000),kr=new Map,Cr=new T(2000),Rr=new T(500),ja=33554432,Ar=ja;function $p(e){let n=e.componentRenderCacheBytes;if(typeof n!=="number"||n<0||n===Ar)return;Ar=n,Es.setMaxBytes(n)}var Es=new T(2000,{maxBytes:ja,sizeOf:(e)=>e.output.length});function Ep(e){let n=new WeakSet;try{let r=(i)=>{if(i===void 0)return{__stxType:"undefined"};if(typeof i==="bigint")return{__stxType:"bigint",value:i.toString()};if(typeof i==="function"||typeof i==="symbol")throw TypeError("Non-serializable component input");if(i===null||typeof i!=="object")return i;if(n.has(i))throw TypeError("Circular component input");n.add(i);try{if(i instanceof Date)return{__stxType:"date",value:i.toISOString()};if(Array.isArray(i))return i.map(r);let a=Object.getPrototypeOf(i);if(a!==Object.prototype&&a!==null)throw TypeError("Non-plain component input");let l={};for(let u of Object.keys(i).sort())l[u]=r(i[u]);return l}finally{n.delete(i)}};return JSON.stringify(r(e))}catch{return null}}function kp(e){let n={};for(let[r,i]of Object.entries(e))if(!r.startsWith("__")||r==="__stxServeContext")n[r]=i;return n}function Sr(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function co(e){let n=process.cwd(),r=`${n}\x00${e}`,i=ka.get(r);if(i===void 0)i=Bun.hash(Ma(e,n).split(ge.sep).join("/")).toString(36).slice(0,6),ka.set(r,i);return i}var ka=new Map;function Ma(e,n){if(!ge.isAbsolute(e))return e;let r=(i)=>{try{return ks.realpathSync(i)}catch{return i}};return ge.relative(r(n),r(e))}function Vg(e){return/\bjs\b/.test(e)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test(e)}function Ge(e){return!Vg(e)}var Ss=new Map;function ie(e){let n;try{n=JSON.stringify(e)}catch{return new Bun.Transpiler(e)}let r=Ss.get(n);if(r)return r;if(Ss.size>=16)Ss.clear();let i=new Bun.Transpiler(e);return Ss.set(n,i),i}var Ca=new WeakMap,Cp=256;function Xe(e){try{let n=ie({loader:"ts",target:"browser",define:A()}),r=Ca.get(n);if(!r)r=new Map,Ca.set(n,r);let i=r.get(e);if(i!==void 0)return i;let a=e.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");a=a.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let l=[];a=a.replace(/\{!![\s\S]*?!!\}/g,(f)=>{let x=l.length;return l.push(f),`"__STX_EXPR_${x}__"`}),a=a.replace(/\{\{\{[\s\S]*?\}\}\}/g,(f)=>{let x=l.length;return l.push(f),`"__STX_EXPR_${x}__"`}),a=a.replace(/\{\{[\s\S]*?\}\}/g,(f)=>{let x=l.length;return l.push(f),`"__STX_EXPR_${x}__"`});let u=n.transformSync(a);for(let f=0;f<l.length;f++)u=u.replace(`"__STX_EXPR_${f}__"`,l[f]),u=u.replace(`'__STX_EXPR_${f}__'`,l[f]);if(r.size>=Cp){let f=r.keys().next();if(!f.done)r.delete(f.value)}return r.set(e,u),u}catch(n){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",n);return e}}function Rp(e){let n=[],r=new Set,i=0,a=0,l=e.length,u=(M)=>{a++;while(a<l){if(e[a]==="\\"){a+=2;continue}if(e[a]===M){a++;return}a++}},f=()=>{a++;while(a<l){if(e[a]==="\\"){a+=2;continue}if(e[a]==="`"){a++;return}if(e[a]==="$"&&e[a+1]==="{"){a+=2;let M=1;while(a<l&&M>0)if(e[a]==="{")M++,a++;else if(e[a]==="}")M--,a++;else if(e[a]==="'"||e[a]==='"')u(e[a]);else if(e[a]==="`")f();else a++;continue}a++}},x=()=>{if(e[a]==="/"&&e[a+1]==="/"){while(a<l&&e[a]!==`
|
|
1064
|
-
`)a++;return!0}if(e[a]==="/"&&e[a+1]==="*"){a+=2;while(a<l-1&&!(e[a]==="*"&&e[a+1]==="/"))a++;return a+=2,!0}return!1},v=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]),I=()=>{let M=a-1;while(M>=0&&/\s/.test(e[M]))M--;if(M<0)return!0;let L=e[M];if("(,=:[!&|?{};+-*%<>~^".includes(L))return!0;if(!/[\w$]/.test(L))return!1;let V=M;while(V>0&&/[\w$]/.test(e[V-1]))V--;return v.has(e.slice(V,M+1))},j=()=>{a++;let M=!1;while(a<l&&e[a]!==`
|
|
1065
|
-
`){let L=e[a];if(L==="\\"){a+=2;continue}if(L==="[")M=!0;else if(L==="]")M=!1;else if(L==="/"&&!M){a++;while(a<l&&/[a-z]/i.test(e[a]))a++;return}a++}},W=()=>{if(i!==0)return;let M=e.slice(a).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(M){let q=M[2].split(",").map((Z)=>{let G=Z.trim().split(":");return G[G.length-1].trim()});for(let Z of q)if(Z&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(Z)&&!r.has(Z))n.push(Z),r.add(Z);return}let L=e.slice(a).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(L){let q=L[2];if(!r.has(q))n.push(q),r.add(q);return}let V=e.slice(a).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(V){let q=V[1];if(!r.has(q))n.push(q),r.add(q);return}let U=e.slice(a).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(U){let q=U[1];if(!r.has(q))n.push(q),r.add(q)}};while(a<l){if(x())continue;if(e[a]==="'"||e[a]==='"'){u(e[a]);continue}if(e[a]==="`"){f();continue}if(e[a]==="/"&&I()){j();continue}if(e[a]==="{"){i++,a++;continue}if(e[a]==="}"){i--,a++;continue}if(i===0&&/[a-z]/i.test(e[a])&&(a===0||/\s|[;{}()]/.test(e[a-1])))W();a++}return n}function Ap(e,n,r){for(let i of se(e)){let a=O(i.attrs);if(["server","src","component","stx:component"].some((f)=>a.has(f))||!vt(a))continue;let l=sn(e.slice(i.bodyStart,i.bodyEnd));if(!l)continue;let u=Object.assign(Object.create(null),r);for(let[f,x]of Object.entries(l.defaults))if(u[f]===void 0)u[f]=bs(x);for(let f of new Set([...l.propNames,...Object.keys(l.defaults)])){let x=l.localBindings[f]??(l.propBindings[f]?void 0:f);if(x)Object.defineProperty(n,x,{value:u[f],writable:!0,enumerable:!0,configurable:!0})}if(l.identifier)Object.defineProperty(n,l.identifier,{value:u,writable:!0,enumerable:!0,configurable:!0})}}var Tp=new Set(["tr","td","th","thead","tbody","tfoot","caption","colgroup","col","option","optgroup","li","dt","dd","span"]);function Ug(e,n){let r=Ht(e),i=e.slice(r).match(/^<([a-zA-Z][a-zA-Z0-9-]*)/);if(!i)return null;let a=i[1].toLowerCase();if(!Tp.has(a))return null;let l=new RegExp(`<\\/?${a}(?=[\\s/>])(?:[^>"']|"[^"]*"|'[^']*')*>`,"iy"),u=w(e,(I,j)=>(l.lastIndex=j,l.exec(I)?.index===j?l.lastIndex:-1));if(a==="span"&&/\sdata-stx-scope\s*=/.test(u[0]?.token||""))return null;let f=0,x=!1;for(let I of u){if(f+=I.token.startsWith("</")?-1:1,f<0)return null;if(f===0){if(e.slice(I.end).trim())return null;x=!0;break}}if(!x)return null;let v=r+i[0].length;return e.slice(0,v)+n+e.slice(v)}function Da(e,n){if(!e)return!1;return[...n.additionalComponentsDirs??[],...n.fallbackComponentsDir?[n.fallbackComponentsDir]:[]].some((i)=>{let a=ge.relative(ge.resolve(i),ge.resolve(e));return!a.startsWith("..")&&!ge.isAbsolute(a)})}async function Br(e,n,r,i,a){let l=e.endsWith(".stx")?e.slice(0,-4):e,u=(ce)=>ce.split("-").map((de)=>de.charAt(0).toUpperCase()+de.slice(1)).join(""),f=r.__importedComponents;if(f){for(let ce of[l,l.toLowerCase(),u(l),J(l)])if(f.has(ce))return!0}let x=[...new Set([`${l}.stx`,`${u(l)}.stx`,`${J(l)}.stx`])],v=typeof a.root==="string"?ge.resolve(a.root):void 0,I=v??ge.dirname(i),j=[],W=(ce)=>{if(ce&&!j.includes(ce))j.push(ce)};for(let ce of ts(i,v))W(ce);let M=r.__originalFilePath;if(M)W(ge.join(ge.dirname(M),"components"));if(Da(n,a))W(a._rootComponentsDir);W(n),W(a._rootComponentsDir),W(ge.join(ge.dirname(i),"components")),W(a.componentsDir);for(let ce of a.additionalComponentsDirs??[])W(ce);let L=a._targetComponentFallbackNames?.some((ce)=>ce.toLowerCase()===l.toLowerCase());if(!L)for(let ce of a._targetComponentDirs??[])W(ce);if(v)W(ge.resolve(v,"resources/views/components")),W(ge.resolve(v,"resources/components")),W(ge.resolve(v,"src/components")),W(ge.resolve(v,"components"));for(let ce of a._layerComponentDirs??[])W(ce);let V=a._pluginComponentDirs;if(Array.isArray(V))for(let ce of V)W(typeof ce==="string"?ce:null);if(W(a.fallbackComponentsDir),L)for(let ce of a._targetComponentDirs??[])W(ce);let U=a._nativePrimitivesFallback;if(U&&!U.except.some((ce)=>ce.toLowerCase()===l.toLowerCase()))W(U.dir);if(l.startsWith("./")||l.startsWith("../"))return s(ge.resolve(ge.dirname(i),`${l}.stx`));let q=Ra(ge.resolve(import.meta.dir,"components")),Z=j.map((ce)=>ge.isAbsolute(ce)?ce:ge.resolve(I,ce)),G=`${x.join("\x00")}\x00\x00${Z.join("\x00")}`,H=Cr.get(G);if(H!==void 0)return H;let ne=!1;e:for(let ce of Z){if(Ra(ce)===q)continue;for(let de of x)if(await s(ge.join(ce,de))){ne=!0;break e}}return Cr.set(G,ne),ne}function Ra(e){let n=Rr.get(e);if(n!==void 0)return n;let r=e;try{r=ks.realpathSync(e)}catch{}return Rr.set(e,r),r}function Wg(e){return e==="visible"||e==="idle"||e==="interaction"||e.startsWith("media:")}function Sl(e){if(!e)return!1;let n=e.replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"");return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(n)}function Ip(e,n,r){if(!e.includes("{{")&&!e.includes("{!!"))return e;let i=(a,l)=>{let u;try{u=N(a,n)}catch{return l}if(u===void 0||u===null)return"";let f=String(u);if(/<\/style/i.test(f))return console.warn(`[stx] a <style> expression in ${r??"<unknown>"} evaluated to CSS containing a closing style tag, which would end the element early, so it was dropped rather than emitted.`),"";return f};return e.replace(/\{!!([\s\S]*?)!!\}/g,(a,l)=>i(l,a)).replace(/\{\{([\s\S]*?)\}\}/g,(a,l)=>i(l,a))}var Aa=new Set;function Ta(e,n,r,i){let a=`${e}\x00${n}\x00${i??""}`;if(!process.env.STX_DEBUG&&Aa.has(a))return;Aa.add(a);let l=n?` used in ${n}`:"",u=i?` Cause: ${i}.`:"",f=r.length>0?`
|
|
1066
|
-
searched:
|
|
1067
|
-
${r.map((x)=>` - ${x}`).join(`
|
|
1068
|
-
`)}`:"";console.error(`[stx] component <${e}> could not be resolved${l}, so it rendered as nothing.${u}${f}`)}function Ia(e){return`<!-- stx: component "${e.replace(/--+/g,"-")}" could not be resolved; see the server log -->`}var Pp=new Set(["for","if","show","key","ref","class","className","style"]),Pa=new Set,Na="useMediaQuery|useDark|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useDocumentVisibility|useScrollLock",kl=new RegExp(`\\b(?:${Na})\\s*(?:<[^>]*>)?\\s*\\(`);function Hi(e){let n=new Set,r=new RegExp(`\\b(?:const|let|var)\\s+([a-zA-Z_$][\\w$]*)\\s*=\\s*(?:state|derived|computed|ref|reactive|signal|useModel|useReactiveProp|useLocalStorage|useSessionStorage|keptState|useCookie|useDebouncedValue|${Na})\\s*(?:<[^>]*>)?\\s*\\(`,"g");for(let i of e){let a;while((a=r.exec(i))!==null)n.add(a[1]);r.lastIndex=0}return[...n]}async function Je(e,n,r,i,a,l,u,f=new Set,x,v=gt(a),I,j=e){let{extractVariables:W}=await o("stx/variable-extractor",()=>import("./chunk-mvavjydq.js")),M=f??new Set;if(M.has(e))return`[Circular component reference: ${e}]`;let L=new Set(M);L.add(e);let V=typeof n.client==="string"?n.client.trim():"";if("client"in n)delete n.client;let U=V&&V!=="load"&&Wg(V)?V:"";try{let q=(ue)=>ue.split("-").map((be)=>be.charAt(0).toUpperCase()+be.slice(1)).join(""),Z=j.endsWith(".stx")?j.slice(0,-4):j,G=null,H=a.__importedComponents;if(H){let ue=[Z,Z.toLowerCase(),q(Z),J(Z)];for(let be of ue)if(H.has(be)){G=H.get(be);break}}let ne=[];if(!G){let ue=[`${Z}.stx`,`${q(Z)}.stx`,`${J(Z)}.stx`],be=[...new Set(ue)],Ne=a.__originalFilePath,$e=[];for(let Ee of ts(l))if(!$e.includes(Ee))$e.push(Ee);let at=$e.length;for(let Ee of u._layerComponentDirs??[])if(!$e.includes(Ee))$e.push(Ee);if(Ne){let Ee=ge.join(ge.dirname(Ne),"components");$e.push(Ee)}let Fe=u._rootComponentsDir;if(typeof Fe==="string"&&Da(i,u)&&!$e.includes(Fe))$e.push(Fe);if(i&&!$e.includes(i))$e.push(i);if(typeof Fe==="string"&&!$e.includes(Fe))$e.push(Fe);let Rt=ge.join(ge.dirname(l),"components");if(!$e.includes(Rt))$e.push(Rt);if(u.componentsDir&&u.componentsDir!==i&&!$e.includes(u.componentsDir))$e.push(u.componentsDir);for(let Ee of u.additionalComponentsDirs??[])if(Ee&&!$e.includes(Ee))$e.push(Ee);let Zt=u._nativeHostAttrs&&/^(?:checkbox|switch)$/i.test(Z),Ot=(I?.events??[]).map((Ee)=>Ee.replace(/^@/,"").split(".")[0].toLowerCase().replace(/-/g,"")),Hn=Object.hasOwn(n,"checked")||Boolean(I?.reactiveProps?.includes("checked")),Ps=Object.hasOwn(n,"value")||Boolean(I?.reactiveProps?.includes("value")),Os=!Ot.includes("valuechange")&&(Hn||Ot.includes("change")&&!Ps),Mt=u._nativeHostAttrs&&/^textinput$/i.test(Z),Jt=Ot.includes("update:value")&&!Ot.includes("input"),xn=u._nativeHostAttrs&&/^video$/i.test(Z),js=u._nativeHostAttrs&&/^image$/i.test(Z),Kn=Zs([...Object.keys(n),...I?.reactiveProps??[]],I?.events,n),Xt=Object.hasOwn(n,"src")||Boolean(I?.reactiveProps?.includes("src")),qn=Object.hasOwn(n,"source")||Boolean(I?.reactiveProps?.includes("source")),Zn=xn&&(Xt||qn)&&(I?.events??[]).every((Ee)=>/^(?:play|pause|ended|timeupdate|loadedmetadata|loadstart|error)$/.test(Ee.replace(/^@/,"").split(".")[0])),Jn=new Set(["","primary","secondary","outline","ghost","danger"]),Xn=typeof n.variant==="string"?n.variant.trim().toLowerCase():"",Gn=u._nativeHostAttrs&&/^button$/i.test(Z)&&!Jn.has(Xn),Hr=u._targetComponentFallbackNames?.some((Ee)=>Ee.toLowerCase()===Z.toLowerCase())??!1,Ms=Hr&&(!Zt||Os)&&(!Mt||Jt)&&(!xn||Zn)&&(!js||Kn)&&!Gn;for(let Ee of Ms?[]:u._targetComponentDirs??[])if(Ee&&!$e.includes(Ee))$e.push(Ee);let Gt=typeof u.root==="string"?ge.resolve(u.root):void 0,Kr=Gt??ge.dirname(l),Yt=[];if(Gt)Yt.push(ge.resolve(Gt,"resources/views/components")),Yt.push(ge.resolve(Gt,"resources/components")),Yt.push(ge.resolve(Gt,"src/components")),Yt.push(ge.resolve(Gt,"components"));Yt.push(ge.resolve(import.meta.dir,"components"));for(let Ee of Yt)if(!$e.includes(Ee))$e.push(Ee);if(Hr){let Ee=(u._componentPackageDirs??[]).filter((ft)=>typeof ft==="string"&&ft.length>0),At=(Ms?Ee.length?Ee:u._pluginComponentDirs??[]:u._targetComponentDirs??[]).filter((ft)=>typeof ft==="string"&&ft.length>0);if(At.length){let ft=$e.slice(at).map((lt)=>ge.isAbsolute(lt)?lt:ge.resolve(Kr,lt)).filter((lt)=>!At.includes(lt)),Qn=`${Z}\x00${ft.join("\x00")}`,_t=kr.get(Qn);if(_t===void 0){_t=!1;for(let lt of ft){for(let Dt of be)if(await s(ge.join(lt,Dt))){_t=!0;break}if(_t)break}kr.set(Qn,_t)}if(!_t){for(let lt of At){let Dt=$e.indexOf(lt);if(Dt>=0)$e.splice(Dt,1)}$e.splice(at,0,...At)}}}let qr=u._pluginComponentDirs;if(Array.isArray(qr)){for(let Ee of qr)if(typeof Ee==="string"&&!$e.includes(Ee))$e.push(Ee)}if(u.fallbackComponentsDir&&!$e.includes(u.fallbackComponentsDir))$e.push(u.fallbackComponentsDir);if(Ms){for(let Ee of u._targetComponentDirs??[])if(Ee&&!$e.includes(Ee))$e.push(Ee)}let Yn=u._nativePrimitivesFallback;if(Yn&&!Yn.except.some((Ee)=>Ee.toLowerCase()===Z.toLowerCase())&&!$e.includes(Yn.dir))$e.push(Yn.dir);let Zr=[...new Set($e.map((Ee)=>{if(!Ee)return Ee;return ge.isAbsolute(Ee)?Ee:ge.resolve(Kr,Ee)}))];$e.length=0,$e.push(...Zr);let Ds=`${Z}\x00${l}\x00${Zr.join("\x00")}`,Ns=$s.get(Ds);if(Ns)if(await s(Ns))G=Ns;else $s.delete(Ds);if(!G&&(Z.startsWith("./")||Z.startsWith("../")))G=ge.resolve(ge.dirname(l),`${Z}.stx`),ne.push(G);else if(!G)for(let Ee of $e){if(!Ee)continue;for(let At of be){let ft=ge.join(Ee,At);if(ne.push(ft),await s(ft)){G=ft;break}}if(G)break;if(!G)try{let At=await import("fs");if(!At.statSync(Ee,{throwIfNoEntry:!1})?.isDirectory())continue;let Qn=8,_t=[{path:Ee,depth:0}];while(_t.length>0&&!G){let lt=_t.pop();if(lt.depth>=Qn)continue;let Dt;try{Dt=At.readdirSync(lt.path,{withFileTypes:!0})}catch{continue}for(let es of Dt){if(!es.isDirectory())continue;if(es.name==="node_modules"||es.name.startsWith("."))continue;let Yr=ge.join(lt.path,es.name);for(let Ga of be){let Ls=ge.join(Yr,Ga);if(ne.push(Ls),await s(Ls)){G=Ls;break}}if(G)break;_t.push({path:Yr,depth:lt.depth+1})}}}catch{}if(G)break}if(G)$s.set(Ds,G)}if(!G||!await s(G))return Ta(e,l,ne),Ia(e);x.add(G);let ce;if(zn.has(G)&&Er.get(G)===Ea(G))ce=zn.get(G);else try{let ue=Ea(G);ce=await Bun.file(G).text(),zn.set(G,ce),Er.set(G,ue)}catch(ue){let be=ue instanceof Error?ue.message:String(ue);return Ta(e,l,[G],be),Ia(e)}if(I)for(let ue of new Set([...Object.keys(n),...I.reactiveProps??[]])){let be=ue.toLowerCase();if(be.startsWith("aria-")||be.startsWith("data-"))continue;let Ne=ue.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`\\b${Ne}\\b`).test(ce))I.declaredProps.add(ue);if(new RegExp(`\\$props\\s*(?:\\.\\s*${Ne}\\b|\\[\\s*['"]${Ne}['"]\\s*\\])`).test(ce)||new RegExp(`\\buseReactiveProp\\s*\\(\\s*['"]${Ne}['"]`).test(ce))I.consumedProps?.add(ue)}if(I?.reactiveProps?.length&&/\bdefineProps\s*(?:<[^>]*>)?\s*\(/.test(ce))for(let ue of I.reactiveProps){if(Pp.has(ue)||I.consumedProps?.has(ue))continue;if(new RegExp(`\\buse(?:ReactiveProp|Model)\\s*\\(\\s*['"]${ue.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(ce))continue;let be=`${G}\x00${ue}`;if(Pa.has(be))continue;Pa.add(be),console.warn(`[stx] ${ge.basename(G)} reads \`${ue}\` with defineProps(), which is not live, but ${ge.basename(l)} binds it (:${ue}): the value can arrive empty or stale (on a native screen, and for a :for's rows, it does not arrive at all). Read it with useReactiveProp('${ue}').`)}let de=new Set(["__originalFilePath","__importedComponents",os,"__stx_client_signal_names","__stx_client_declared_names","__stx_runtime_config","__stxServeContext","__stx_scope_seq"]),fe={};for(let[ue,be]of Object.entries(a))if(!ue.startsWith("__")||de.has(ue))fe[ue]=be;let Ce=v.length>0?{[fs]:[...v]}:{},Re=r;if(r.includes("@include")){let{processIncludes:ue}=await o("stx/includes",()=>import("./chunk-sb67wg5x.js"));Re=await ue(r,a,l,u,x)}if(/<[A-Z][\w.-]*[\s/>]/.test(Re)){let{processComponents:ue}=await o("stx/component-renderer",()=>import("./chunk-zhywjwdr.js")),be={...a,__processedComponents:M,...Ce};Re=await ue(Re,be,l,u,x);let Ne=be.__stx_preserved_client_expressions;if(Array.isArray(Ne)&&Ne.length>0)a.__stx_preserved_client_expressions=[...new Set([...Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[],...Ne])]}let we=[];if(Sl(Re)){let{processExpressions:ue}=await o("stx/expressions",()=>import("./chunk-jhbj9ja2.js")),be=a.__stx_signals_gate===void 0?{...a,__stx_signals_gate:!0,...Ce}:v.length>0?{...a,...Ce}:a;Re=ue(Re,be,l);for(let Ne of Re.matchAll(/\{\{([\s\S]*?)\}\}/g))we.push(Ne[1].trim())}let xe=re(Re),He=[],tt=xe.output.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(ue,be)=>{let Ne=xe.scripts[Number(be)]||"",$e=Ne.match(/^<script\b([^>]*)>/i)?.[1]||"",at=$e.match(/\btype\s*=\s*["']([^"']+)["']/i)?.[1]?.toLowerCase(),Fe=!at||["module","text/javascript","application/javascript"].includes(at),Rt=/\sdata-stx-(?:owner|instance)(?=[\s=/>])/i.test(` ${$e}`);if(!/\bserver\b/i.test($e)&&Fe&&!Rt)return He.push(Ne),"";return Ne}),{extractSlotContent:ct}=await o("stx/slots",()=>import("./chunk-qqng9545.js")),nt=ct(tt),ht={};if(nt.defaultSlot?.trim())ht.default=nt.defaultSlot;for(let[ue,be]of nt.namedSlots)ht[ue]=be.content;let ut=a.__stx_scope_seq??={n:0,key:co(String(a.__filename??l))},rt=Ma(e,process.cwd()),je=`stx_${(rt.endsWith(".stx")?rt.slice(0,-4):rt).replace(/[^a-zA-Z0-9]/g,"_")}_${++ut.n}_${ut.key}`,Te={...fe,$uid:je,$native:u._nativeHostAttrs===!0,...n,props:n,slot:tt,$slots:ht,__processedComponents:L,__sections:{},__stx_signals_gate:Oe(ce)||Sl(r),__stx_preserved_client_expressions:[...Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[],...we]};if(/import\s/.test(ce)){Te.__importedComponents=new Map(Te.__importedComponents);let{processESImports:ue}=await o("stx/component-renderer",()=>import("./chunk-zhywjwdr.js"));ce=await ue(ce,Te,G,u,x)}Ap(ce,Te,n);let pt=ce,et=B(pt);if(et)pt=et.content.trim();let ln=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,It=[...ce.matchAll(ln)];for(let[,ue,be]of It)if(!/\bserver\b|\bsrc\s*=|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(ue))Ue(be,G,u.strict);let xt=[],un=null,Rs=It.some((ue)=>/\bserver\b/.test(ue[1]||"")&&/\bcache\b/.test(ue[1]||"")),Ft=null,$t=null,pn=null,Wn=0,fn=null;if($p(u),Rs&&Ar>0){let ue=Ep({props:n,slot:Re,slotContext:r.trim()?kp(fe):void 0,buildMode:u.buildMode??"",skipEventDirectives:u.skipEventDirectives===!0,native:u._nativeHostAttrs===!0,clientLoopNames:[...v].sort(),layers:u._layerGraph?.layers.map((be)=>be.configFile),uid:je});if(ue!==null){Ft=`${G}\x00${C(ce)}\x00${ue}`;let be=Es.get(Ft);if(be){for(let Ne of be.dependencies)x.add(Ne);if(Ci(a,be.clientFactories),ut.n+=be.uidsConsumed,be.preservedClientExpressions.length>0){let Ne=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[]);for(let $e of be.preservedClientExpressions)Ne.add($e);a.__stx_preserved_client_expressions=[...Ne]}return be.output}$t=new Set(x),pn=Ei(a),Wn=ut.n,fn=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[])}}let dn=new Set;for(let ue of It){let be=ue[1]||"",Ne=ue[2]||"",$e=be.includes("server");if(Ge(be)&&Ne.trim())Ne=Xe(Ne);if($e&&Ne){for(let Fe of ye(Ne))dn.add(Fe);try{await W(Ne,Te,G,{onFailure:(Fe)=>{if(Fe.kind!=="unknown")un=Fe.kind}})}catch(Fe){}}if(!$e){let Fe=Ne.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),Rt=Fe.includes("{{")&&Fe.includes("}}"),Zt=Fe.includes("{!!")&&Fe.includes("!!}");if(Rt||Zt)Fe=Ui(Fe,Te,G);let Ot=be.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");xt.push(`<script${Ot}>${Fe}</script>`)}}let bt=re(ce).output.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),gn=bt?bt[1]:"",As=bt?bt[2]:"",Et="",le=gn&&/\bscoped\b/i.test(gn);if(bt)Et=`<style${gn}>${Ip(As,Te,G)}</style>`;let pe=pt;if(pe=pe.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),bt)pe=pe.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let ue=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,be=[];if(pe=pe.replace(ue,(Ne,$e)=>{let at=$e.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(at)be.push(`<style${at[1]}>${at[2]}</style>`);return""}),pe=pe.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),be.length>0)Et=`${Et}${be.join(`
|
|
1069
|
-
`)}`}if(r&&pe.includes("{{ text || slot }}"))pe=pe.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>r);let{applySlots:ve}=await o("stx/slots",()=>import("./chunk-qqng9545.js")),{defaultSlot:Le,namedSlots:Ze}=nt,it=a.__stx_signals_gate===!0&&/\s(?:@[\w:.-]+|x-on:[\w:.-]+)\s*=/.test(tt),yt=xt.length>0&&ar(pe)||u._nativeHostAttrs===!0&&xt.length>0||it&&xt.length>0||xt.some((ue)=>/\b(?:state|derived|effect|ref|useRef|reactive|computed|watch|watchEffect|useModel|useReactiveProp|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots)\s*(?:<[^<>()]*>)?\s*\(/.test(ue)),Ts=(ue)=>yt?Bo(ue,je):ue,Is=new Map([...Ze].map(([ue,be])=>[ue,{...be,content:Ts(be.content)}]));pe=await ve(pe,yt?zo(Ts(Le),je):Le,Is,Te,yt?je:"");let Fn=Hi(xt),mn=(Array.isArray(Te.__stx_client_signal_names)?Te.__stx_client_signal_names:[]).filter((ue)=>!dn.has(ue));if(Fn.length>0||mn.length>0)Te.__stx_client_signal_names=[...new Set([...mn,...Fn])];else delete Te.__stx_client_signal_names;let hn=v.filter((ue)=>!dn.has(ue)&&!(ue in n));if(hn.length>0)Te[fs]=hn;let Vn={...u,_rootComponentsDir:u._rootComponentsDir||u.componentsDir,componentsDir:ge.dirname(G),skipSignalsRuntime:!0,skipEventDirectives:u._nativeHostAttrs===!0||yt||xt.length===0,defaultLayout:void 0};Te.__stxProcessingDepth=(a.__stxProcessingDepth||0)+1;let{processDirectives:Un}=await o("stx/process",()=>import("./chunk-8354mzpd.js")),kt=await Un(pe,Te,G,Vn,x),Pt=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[]);for(let ue of kt.matchAll(/\{\{([\s\S]*?)\}\}/g))Pt.add(ue[1].trim());if(Pt.size>0)a.__stx_preserved_client_expressions=[...Pt];let Ct=je,ot=kt;if(yt){let ue="";if(Object.keys(n).length>0)try{ue=` data-stx-props="${Sr(JSON.stringify(n))}"`}catch{}let be=U?` stx-hydrate="${Sr(U)}"`:"",Ne=Object.fromEntries(Object.entries(ht).map(([Mt,Jt])=>[Mt,Boolean(Jt)])),$e=Object.keys(Ne).length>0?` data-stx-slots="${Sr(JSON.stringify(Ne))}"`:"",at=` data-stx-scope="${Ct}"${ue}${$e}${be}`,Fe=kt.slice(Ht(kt)),Rt=/^<span(?=[\s/>])/i.test(Fe),Zt=/^<[^>]+\bdata-stx-layout-root(?:\s|=|>)/i.test(Fe),Ot=/^<[^>]+\bdata-stx-fill-root(?:\s|=|>)/i.test(Fe),Hn=Rt?"span":"div",Ps=Zt&&u._nativeHostAttrs?' style="display:flex;flex-direction:column;flex:1;min-height:0;min-width:0"':Ot&&u._nativeHostAttrs?' style="width:100%;height:100%"':Rt||Zt?' style="display:contents"':"";ot=Ug(kt,at)??`<${Hn}${at} data-stx-component-wrapper${Ps}>${kt}</${Hn}>`;let Os=await Promise.all(xt.map(async(Mt)=>{let Jt=Mt.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!Jt)return Mt;let[,xn,js]=Jt,Kn=$a(Mt,Te,G);if(Kn!==null)return Kn;let Xt=await jp(js,G,u.buildMode==="compile"),qn=$n(Xt.clientCode,qe(Te)),{vendorStyleTags:Zn}=Xt,Jn=qn?`function(__scopeId) {
|
|
1070
|
-
${qn}
|
|
1071
|
-
return (${Xt.factoryBody})(__scopeId);
|
|
1072
|
-
}`:Xt.factoryBody,Xn=U?null:er(a,Jn),Gn=Xn?`window.__stxComponentFactories[${JSON.stringify(Xn)}](${JSON.stringify(Ct)});`:`(${Jn})(${JSON.stringify(Ct)});`;if(U)return`${Zn}<script type="stx/island" data-stx-island="${Ct}" data-stx-scoped data-stx-owner="${Ct}"${xn}>${me(Gn)}</script>`;return`${Zn}<script data-stx-scoped data-stx-run="always" data-stx-owner="${Ct}"${xn}>${me(Gn)}</script>`}));if(ot=ot+`
|
|
1073
|
-
`+Os.join(`
|
|
1074
|
-
`),Et)ot+=`
|
|
1075
|
-
`+Et}else{if(Et)ot+=`
|
|
1076
|
-
`+Et;if(xt.length>0){let ue=Te.__stx_event_bindings||[],be=qe(Te),Ne=await Promise.all(xt.map(async($e)=>{let at=$a($e,Te,G);if(at!==null)return at;let Fe=$e.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!Fe)return $e;return await Ke(Fe[1],{eventBindings:ue,templateContent:ot,filePath:G,projectRoot:process.cwd(),serverData:be,instanceId:je})}));ot+=`
|
|
1077
|
-
`+Ne.join(`
|
|
1078
|
-
`),Te.__stx_event_bindings=[]}}if(le){let ue=so(ot,G);if(ue.hasScoped)ot=ue.html}if(Ft&&$t){let ue=Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[];Es.set(Ft,{output:ot,dependencies:[...x].filter((be)=>!$t.has(be)),clientFactories:pn?ki(a,pn):[],uidsConsumed:ut.n-Wn,preservedClientExpressions:fn?ue.filter((be)=>!fn.has(be)):[]})}if(un)ot=`<!--stx-render-failed:${un}-->${ot}`;return He.length>0?`${ot}
|
|
1079
|
-
${He.join(`
|
|
1080
|
-
`)}`:ot}catch(q){if(q instanceof ee)throw q;return`[Error processing component: ${q instanceof Error?q.message:String(q)}]`}finally{M.delete(e)}}async function s(e){return Bun.file(e).exists()}function Tr(e,n){let r=ge.resolve(n),i=ge.resolve(e),a=r.endsWith(ge.sep)?r:r+ge.sep;if(i===r||i.startsWith(a))return i;return null}async function Oa(e,n,r,i){let a=n.startsWith("layouts/")?n.slice(8):n,l=ge.join(e,a);for(let u of l.endsWith(".stx")?[l]:[l,`${l}.stx`])if(await s(u)){if(i)console.log(`Found layout in ${e}: ${u}`);return r?.add(u),u}return null}async function Rn(e,n,r,i){let a=await Op(e,n,r,i);if(a===null)return null;let l=Tr(a,process.cwd());if(l)return l;let u=[r.root,r.layoutsDir,r.fallbackLayoutsDir,r.componentsDir,r.partialsDir,r.pagesDir,...r._layerLayoutDirs??[]].filter((f)=>typeof f==="string"&&f.length>0);for(let f of u){let x=ge.isAbsolute(f)?f:ge.resolve(process.cwd(),f);if(Tr(a,x))return ge.resolve(a)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${a} (template: ${e}, from: ${n})`),null}async function Op(e,n,r,i){if(r.debug)console.log(`Resolving template path: ${e} from ${n}`);let a=ge.dirname(n),l=process.cwd();if(e.startsWith("/")){let M=ge.join(l,e),L=Tr(M,l);if(!L)return console.warn(`[stx] rejected template path that escapes project root: ${e} (from ${n})`),null;if(r.debug)console.log(`Checking absolute path: ${L}`);if(await s(L)&&i)i.add(L);return L}let u=async(M)=>{if(!r.layoutsDir||!r.fallbackLayoutsDir)return M;let L=ge.relative(ge.resolve(l,r.fallbackLayoutsDir),M);if(L.startsWith("..")||ge.isAbsolute(L))return M;return await Oa(ge.resolve(l,r.layoutsDir),e,i,r.debug)??M},f=ge.join(a,e);if(await s(f)){if(r.debug)console.log(`Found direct path: ${f}`);let M=await u(f);if(i)i.add(M);return M}if(!e.endsWith(".stx")&&!e.endsWith(".jsx")&&!e.endsWith(".tsx"))for(let M of[".stx",".tsx",".jsx"]){let L=`${f}${M}`;if(await s(L)){if(r.debug)console.log(`Found direct path with extension: ${L}`);let V=await u(L);if(i)i.add(V);return V}}let x=[];if(x.push(...r._layerLayoutDirs??[]),r.layoutsDir)x.push(ge.isAbsolute(r.layoutsDir)?r.layoutsDir:ge.resolve(process.cwd(),r.layoutsDir));let v=ge.resolve(a),I=process.cwd();for(let M=0;M<10;M++){let L=ge.join(v,"layouts"),V=!1;try{V=ks.statSync(L,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(V){x.push(L);break}let U=ge.dirname(v);if(U===v||U.length<I.length)break;v=U}for(let M of x){let L=await Oa(M,e,i,r.debug);if(L)return L}if(r.fallbackLayoutsDir){let M=ge.isAbsolute(r.fallbackLayoutsDir)?r.fallbackLayoutsDir:ge.resolve(process.cwd(),r.fallbackLayoutsDir),L=e.startsWith("layouts/")?e.slice(8):e,V=[ge.join(M,L)];if(!e.endsWith(".stx"))V.push(`${V[0]}.stx`);for(let U of V)if(await s(U)){if(r.debug)console.log(`Found in options.fallbackLayoutsDir: ${U}`);if(i)i.add(U);return U}}if(e.startsWith("layouts/")||e.includes("/layouts/")){let M=e.split("layouts/"),L=ge.join(r.partialsDir||a,"layouts",M[1]);if(await s(L)){if(r.debug)console.log(`Found in layouts path: ${L}`);if(i)i.add(L);return L}if(!L.endsWith(".stx")){let V=`${L}.stx`;if(await s(V)){if(r.debug)console.log(`Found in layouts path with extension: ${V}`);if(i)i.add(V);return V}}}if(r.partialsDir){let M=ge.join(r.partialsDir,"layouts");if(await s(M)){let L=ge.join(M,e);if(await s(L)){if(r.debug)console.log(`Found in partials layouts dir: ${L}`);if(i)i.add(L);return L}if(!e.endsWith(".stx")){let V=`${L}.stx`;if(await s(V)){if(r.debug)console.log(`Found in partials layouts dir with extension: ${V}`);if(i)i.add(V);return V}}}}let j=r.partialsDir||ge.join(process.cwd(),"views"),W=ge.join(j,e);if(await s(W)){if(r.debug)console.log(`Found in views path: ${W}`);if(i)i.add(W);return W}if(!e.endsWith(".stx")){let M=`${W}.stx`;if(await s(M)){if(r.debug)console.log(`Found in views path with extension: ${M}`);if(i)i.add(M);return M}}if(a.includes("temp")){let M=ge.join(ge.dirname(a),"layouts",e);if(await s(M)){if(r.debug)console.log(`Found in temp layouts dir: ${M}`);if(i)i.add(M);return M}if(!e.endsWith(".stx")){let L=`${M}.stx`;if(await s(L)){if(r.debug)console.log(`Found in temp layouts dir with extension: ${L}`);if(i)i.add(L);return L}}}if(r.debug)console.warn(`Template not found after trying all paths: ${e} (referenced from ${n})`);else console.warn(`Template not found: ${e} (referenced from ${n})`);return null}function _l(e,n,r){let i=0,a="",l="";try{if(typeof n==="number"&&n>=0){let u=e.split(`
|
|
1081
|
-
`),f=0;for(let x=0;x<u.length;x++)if(f+=u[x].length+1,f>=n){i=x+1,a=u[x].trim();let v=Math.max(0,x-2),I=Math.min(u.length,x+3);l=u.slice(v,I).map((j,W)=>{let M=v+W+1;return`${M===i?"> ":" "}${M}: ${j}`}).join(`
|
|
1082
|
-
`);break}}else if(r){let u=e.indexOf(r);if(u>=0)return _l(e,u)}}catch{}return{lineNumber:i,lineContent:a,context:l}}var Be={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgYellow:"\x1B[43m"};function y(e,n,r,i,a,l){let{lineNumber:u,context:f}=_l(i,a,l),x=r.split("/").pop(),v=0;if(typeof a==="number"&&a>=0&&i){let j=i.lastIndexOf(`
|
|
1083
|
-
`,Math.max(0,a-1));v=a-(j+1)+1}let I="";if(u>0)I+=`
|
|
1084
|
-
${r}:${u}${v>0?`:${v}`:""}: ${e.toLowerCase()} error: ${n}
|
|
1085
|
-
`;if(I+=`
|
|
1086
|
-
${Be.bold}${Be.red}\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E${Be.reset}
|
|
1087
|
-
`,I+=`${Be.bold}${Be.red}\u2502${Be.reset} ${Be.bold}${Be.bgRed} ERROR ${Be.reset} ${Be.red}${e} Error${Be.reset}${" ".repeat(Math.max(0,43-e.length))}${Be.bold}${Be.red}\u2502${Be.reset}
|
|
1088
|
-
`,I+=`${Be.bold}${Be.red}\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F${Be.reset}
|
|
1089
|
-
`,I+=`
|
|
1090
|
-
${Be.cyan}${Be.bold}File:${Be.reset} ${Be.dim}${x}${Be.reset}`,u>0)I+=` ${Be.gray}(line ${u}${v>0?`, col ${v}`:""})${Be.reset}`;if(I+=`
|
|
1091
|
-
${Be.yellow}${Be.bold}Message:${Be.reset} ${n}
|
|
1092
|
-
`,f)I+=`
|
|
1093
|
-
${Be.blue}${Be.bold}Context:${Be.reset}
|
|
1094
|
-
${Be.dim}${f}${Be.reset}
|
|
1095
|
-
`;return I}function _e(){zn.clear(),Er.clear(),$s.clear(),kr.clear(),Cr.clear(),Rr.clear(),Es.clear()}function $y(){return{size:zn.size,maxSize:500}}var $r=S(128);async function jp(e,n,r){let i=C(e,n,r),a=$r.get(i);if(a){if(Qs(a.deps))return a;$r.delete(i)}let l=Fi(e,{filePath:n,projectRoot:process.cwd()}),u=l.code,f=zi(l.styles);u=Kt(u).code;let{hasUserImports:x,bundleClientScript:v}=await o("stx/client-script-bundler",()=>import("./chunk-rjm515e2.js")),I=[],j=!1;if(x(u)){let Z=u;u=await v(Z,n,{projectRoot:process.cwd(),minify:r,collectInputs:I}),j=u===Z}let{stripStxRuntimeImports:W}=await o("stx/signal-processing",()=>import("./chunk-79vbkez0.js"));u=W(u);let M=D(u),L=Rp(M),V=new Set(X(M,!0).split(",").map((Z)=>Z.trim())),U=`function(__scopeId) {
|
|
1096
|
-
${wt("const",[...Bl,...L],M)}
|
|
1097
|
-
const __scope = window.stx._scopes = window.stx._scopes || {};
|
|
1098
|
-
const __scopeVars = __scope[__scopeId] = __scope[__scopeId] || {};
|
|
1099
|
-
__scopeVars.$refs = __scopeVars.$refs || {};
|
|
1100
|
-
const __previousCurrentElement = window.__STX_CURRENT_ELEMENT__;
|
|
1101
|
-
const __previousCurrentProps = window.__STX_CURRENT_PROPS__;
|
|
1102
|
-
// A clone the runtime is setting up may not be in the document yet (rows
|
|
1103
|
-
// a loop builds inside a closed :if), where a lookup cannot see it, so the
|
|
1104
|
-
// runtime hands its root over in __STX_SETUP_ROOT__ (signals.ts).
|
|
1105
|
-
const __setupRoot = window.__STX_SETUP_ROOT__;
|
|
1106
|
-
const __componentElement = (__setupRoot && __setupRoot.getAttribute('data-stx-scope') === __scopeId && __setupRoot) || document.querySelector('[data-stx-scope="' + __scopeId + '"]');
|
|
1107
|
-
__scopeVars.$slots = Object.create(null);
|
|
1108
|
-
if (__componentElement) {
|
|
1109
|
-
try { Object.assign(__scopeVars.$slots, JSON.parse(__componentElement.getAttribute('data-stx-slots') || '{}')); }
|
|
1110
|
-
catch {}
|
|
1111
|
-
}
|
|
1112
|
-
window.__STX_CURRENT_ELEMENT__ = __componentElement;
|
|
1113
|
-
let __componentProps = __componentElement && __componentElement.__stx_props;
|
|
1114
|
-
if (!__componentProps && __componentElement) {
|
|
1115
|
-
try { __componentProps = JSON.parse(__componentElement.getAttribute('data-stx-props') || '{}'); }
|
|
1116
|
-
catch { __componentProps = {}; }
|
|
1117
|
-
}
|
|
1118
|
-
window.__STX_CURRENT_PROPS__ = __componentProps && typeof __componentProps === 'object' && !Array.isArray(__componentProps) ? __componentProps : {};
|
|
1119
|
-
const __scopeProps = window.__STX_CURRENT_PROPS__;
|
|
1120
|
-
Object.defineProperty(__scopeVars, '$props', { configurable: true, enumerable: true, get: function() {
|
|
1121
|
-
return (__componentElement && __componentElement.__stx_props) || __scopeProps;
|
|
1122
|
-
} });
|
|
1123
|
-
|
|
1124
|
-
// Scope-specific lifecycle callbacks. The queues drain as they run; the
|
|
1125
|
-
// hook lists keep what setup registered, because a component behind an :if
|
|
1126
|
-
// unmounts at each hide and mounts again at each show (signals.ts,
|
|
1127
|
-
// suspendSubtreeScopes).
|
|
1128
|
-
if (__scopeVars.__suspended && !__scopeVars.__mounted) {
|
|
1129
|
-
// Set up again after an :if hid it -- a <template :if> clones the
|
|
1130
|
-
// component afresh on every show, and the clone's script runs. This run's
|
|
1131
|
-
// hooks close over this run's state, so they replace the ones the hide
|
|
1132
|
-
// kept for a re-show rather than queueing beside them.
|
|
1133
|
-
__scopeVars.__mountCallbacks = [];
|
|
1134
|
-
__scopeVars.__destroyCallbacks = [];
|
|
1135
|
-
__scopeVars.__mountHooks = [];
|
|
1136
|
-
__scopeVars.__destroyHooks = [];
|
|
1137
|
-
// So do its effects: the last run's watched a clone that is gone.
|
|
1138
|
-
if (typeof __scopeVars.__disposeEffects === 'function') __scopeVars.__disposeEffects();
|
|
1139
|
-
__scopeVars.__disposeEffects = null;
|
|
1140
|
-
}
|
|
1141
|
-
__scopeVars.__mountCallbacks = __scopeVars.__mountCallbacks || [];
|
|
1142
|
-
__scopeVars.__destroyCallbacks = __scopeVars.__destroyCallbacks || [];
|
|
1143
|
-
__scopeVars.__mountHooks = __scopeVars.__mountHooks || [];
|
|
1144
|
-
__scopeVars.__destroyHooks = __scopeVars.__destroyHooks || [];
|
|
1145
|
-
let __registeringSetupHooks = true;
|
|
1146
|
-
const onMount = (fn) => { __scopeVars.__mountCallbacks.push(fn); __scopeVars.__mountHooks.push(fn); };
|
|
1147
|
-
const onDestroy = (fn) => {
|
|
1148
|
-
__scopeVars.__destroyCallbacks.push(fn);
|
|
1149
|
-
// A teardown registered inside onMount belongs to this mount alone.
|
|
1150
|
-
// Replaying it AND registering the next mount's teardown doubles cleanup.
|
|
1151
|
-
if (__registeringSetupHooks) __scopeVars.__destroyHooks.push(fn);
|
|
1152
|
-
};
|
|
1153
|
-
// The effects this setup makes (effect, watch) belong to the scope and are
|
|
1154
|
-
// disposed with it (disposeSubtreeScopes in the runtime), as its bindings
|
|
1155
|
-
// are. Untracked, one reading a store kept running for a component the
|
|
1156
|
-
// router had long swapped out.
|
|
1157
|
-
const __endEffects = window.stx._beginEffects ? window.stx._beginEffects() : null;
|
|
1158
|
-
|
|
1159
|
-
try {
|
|
1160
|
-
${M}
|
|
1161
|
-
|
|
1162
|
-
// Register all defined signals and functions in this scope
|
|
1163
|
-
const __localVars = {};
|
|
1164
|
-
try {
|
|
1165
|
-
${L.map((Z)=>V.has(Z)?`Object.defineProperty(__localVars, '${Z}', ${Gs(Z)});`:`if (typeof ${Z} !== 'undefined') __localVars['${Z}'] = ${Z};`).join(`
|
|
1166
|
-
`)}
|
|
1167
|
-
}
|
|
1168
|
-
catch (e) {}
|
|
1169
|
-
Object.defineProperties(__scopeVars, Object.getOwnPropertyDescriptors(__localVars));
|
|
1170
|
-
if (typeof __stxLiveBindings !== 'undefined') Object.defineProperties(__scopeVars, Object.getOwnPropertyDescriptors(__stxLiveBindings));
|
|
1171
|
-
}
|
|
1172
|
-
finally {
|
|
1173
|
-
__registeringSetupHooks = false;
|
|
1174
|
-
if (__endEffects) {
|
|
1175
|
-
const __previousDispose = __scopeVars.__disposeEffects;
|
|
1176
|
-
const __disposeSetup = __endEffects();
|
|
1177
|
-
__scopeVars.__disposeEffects = typeof __previousDispose === 'function'
|
|
1178
|
-
? function() { __previousDispose(); __disposeSetup(); }
|
|
1179
|
-
: __disposeSetup;
|
|
1180
|
-
}
|
|
1181
|
-
window.__STX_CURRENT_ELEMENT__ = __previousCurrentElement;
|
|
1182
|
-
window.__STX_CURRENT_PROPS__ = __previousCurrentProps;
|
|
1183
|
-
}
|
|
1184
|
-
}`,q={vendorStyleTags:f,factoryBody:U,clientCode:M,deps:Ir([...I,...l.styles.map((Z)=>Z.resolvedPath)])};if(!j&&l.unresolved.length===0)$r.set(i,q);return q}var Mp=100,Dp=599,Wr="__stxResponseStatus",Bn="__stxResponseHeaders";function Cs(e){return typeof e==="number"&&Number.isInteger(e)&&e>=Mp&&e<=Dp}function En(e){for(let n of e.matchAll(/\bdefinePageMeta\s*\(\s*\{([\s\S]*?)\}\s*\)/g)){let r=n[1].match(/(?:^|,)\s*status\s*:\s*(\d{3})(?=\s*(?:,|$))/);if(!r)continue;let i=Number(r[1]);if(Cs(i))return i}return}function zr(e,n){if(!e||typeof e!=="object")return!1;let r=typeof n==="string"&&/^\d+$/.test(n.trim())?Number(n.trim()):n;if(!Cs(r))return!1;return e[Wr]=r,!0}function Np(e,n,r){if(!e||typeof e!=="object")return;let i=String(n??"").trim();if(!i)return;e[Bn]={...e[Bn],[i]:String(r)}}function Wt(e){let n=e?.[Wr];return Cs(n)?n:void 0}function qt(e){let n=e?.[Bn];if(!n||typeof n!=="object")return;let r=Object.entries(n).map(([i,a])=>[i,String(a)]);return r.length>0?Object.fromEntries(r):void 0}function ul(e,n){if(!e||!n||e===n||typeof n!=="object")return;let r=Wt(e);if(r!==void 0)n[Wr]=r;let i=qt(e);if(i)n[Bn]={...n[Bn],...i}}function oo(e){return{setResponseStatus:(n)=>{zr(e,n)},notFound:(n=404)=>{let r=Cs(n)&&n>=400?n:404;zr(e,r)},setResponseHeader:(n,r)=>{Np(e,n,r)}}}function dl(e,n,r={}){if(!e.includes("@status"))return e;let{filePath:i,buildMode:a}=r,l=a==="compile",u="",f=0,x=/@status\s*\(/g,v;while((v=x.exec(e))!==null){let I=Lp(e,v.index+v[0].length-1);if(I<0)break;let j=e.slice(v.index+v[0].length,I).trim(),W=/^\d+$/.test(j)?Number(j):d(j,n),M=i?` in ${i}`:"";if(l)console.warn(`[stx] @status(${j})${M} is skipped when precompiling: the build has no request, so the branch it sits in is not the one a visitor will get. Call notFound() or setResponseStatus(${j}) from <script server> instead \u2014 that runs per request.`);else if(!zr(n,W))console.warn(`[stx] @status(${j})${M} is not an HTTP status (100-599) \u2014 ignoring it.`);u+=e.slice(f,v.index),f=I+1+(e.slice(I+1).match(/^[^\S\n]*\n?/)?.[0].length??0),x.lastIndex=f}return f===0?e:u+e.slice(f)}function Lp(e,n){let r=1,i=null,a=!1;for(let l=n+1;l<e.length;l++){let u=e[l];if(a){a=!1;continue}if(i){if(u==="\\")a=!0;else if(u===i)i=null;continue}if(u==='"'||u==="'"||u==="`"){i=u;continue}if(u==="(")r++;else if(u===")"&&--r===0)return l}return-1}var La=new Set(mt),zp=new Set(["props","$props","defineProps"]),Bp=new Set(["stx","@stacksjs/stx"]),za=S(128),Ba=S(64);function Wp(e){let n=[],r=0,i=e.split(`
|
|
1185
|
-
`);for(let a of i){let l=r,u=null,f=!1;for(let x=0;x<a.length;x++){let v=a[x];if(f){f=!1;continue}if(v==="\\"){f=!0;continue}if(u){if(v===u)u=null;continue}if(v==="'"||v==='"'||v==="`"){u=v;continue}if(v==="/"&&x+1<a.length&&a[x+1]==="/")break;if(v==="{")r++;else if(v==="}")r--}if(l===0){let x=a.match(/(?:const|let|var)\s+(\w+)\s*=/);if(x)n.push(x[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(a)){let v=a.match(/(?:const|let|var)\s+(\w+)/);if(v)n.push(v[1])}else{let v=a.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(v){let j=v[1].slice(1,-1).split(",").map((W)=>{let M=W.split(":");return(M.length>1?M[1]:M[0]).trim()}).filter((W)=>/^\w+$/.test(W));n.push(...j)}}}}return[...new Set(n)]}function Rg(e){let n=e;n=n.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),n=n.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),n=n.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),n=n.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),n=n.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function r(i){if(!i.includes(":"))return i;let a=[],l="",u=0,f=0,x=null;for(let v=0;v<i.length;v++){let I=i[v];if(x){if(l+=I,I===x)x=null;continue}if(I==='"'||I==="'"||I==="`"){x=I,l+=I;continue}if(I==="<")u++;else if(I===">"&&u>0)u--;else if(I==="(")f++;else if(I===")")f--;if(I===","&&u===0&&f===0){a.push(l),l="";continue}l+=I}if(l)a.push(l);return a.map((v)=>{let I=v.trim(),j=I.startsWith("..."),W=j?I.slice(3):I,M=-1,L=0;for(let ne=0;ne<W.length;ne++)if(W[ne]==="<")L++;else if(W[ne]===">")L--;else if(W[ne]===":"&&L===0){M=ne;break}if(M===-1)return v;let U=W.substring(0,M).trim().replace(/\?$/,""),q=W.substring(M+1),Z=-1,G=0;for(let ne=0;ne<q.length;ne++)if(q[ne]==="<")G++;else if(q[ne]===">")G--;else if(q[ne]==="="&&G===0){Z=ne;break}let H=j?"...":"";if(Z!==-1)return`${H}${U} = ${q.substring(Z+1).trim()}`;return`${H}${U}`}).join(", ")}n=n.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(i,a,l)=>{if(!l.includes(":"))return i;return`${a}(${r(l)})`});{let i=/\b(function\s+\w*\s*)\(/g,a,l=[];while((a=i.exec(n))!==null){let u=a.index+a[0].length-1,f=1,x=u+1,v=0,I=null;while(x<n.length&&f>0){let M=n[x];if(I){if(M===I)I=null;x++;continue}if(M==='"'||M==="'"||M==="`"){I=M,x++;continue}if(M==="<")v++;else if(M===">"&&v>0)v--;else if(v===0){if(M==="(")f++;else if(M===")")f--}if(f>0)x++}if(f!==0)continue;let j=n.substring(u+1,x);if(!j.includes(":"))continue;let W=r(j);l.push({start:u+1,end:x,replacement:W})}for(let u=l.length-1;u>=0;u--){let{start:f,end:x,replacement:v}=l[u];n=n.substring(0,f)+v+n.substring(x)}}return n=n.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(i,a)=>{if(!a.includes(":"))return i;if(a.includes("{")||a.includes("}"))return i;return`(${a.split(",").map((u)=>{let[f,...x]=u.split("="),v=f.split(":")[0].trim();if(x.length>0)return`${v} = ${x.join("=").trim()}`;return v}).join(", ")}) =>`}),n=n.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g,"$1$3"),n=n.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),n=n.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),n=n.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),n=n.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),n=n.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),n=n.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),n=n.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),n=n.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),n=n.replace(/\n\s*\n\s*\n/g,`
|
|
1186
|
-
|
|
1187
|
-
`),n}function Ag(e){return e.replace(/\s*(?:imported from|from)\s+(?:(['"])([^'"\r\n]+)\1|(\S+))/g,(n,...r)=>{let[,i,a]=r,l=i??a;return/(?:[/\\]packages[/\\]stx[/\\]|@stacksjs[/\\]stx[/\\])/.test(l)?"":n})}function Pg(e){return/cannot find module|cannot find package|could not resolve|module not found|failed to resolve/i.test(e)}function Ig(e){if(e instanceof SyntaxError)return!0;let n=e instanceof Error?e.message:String(e);return/SyntaxError|Unexpected (token|identifier|string|number|keyword|end of)|Unterminated|Expected .+ but found/i.test(n)}function Og(e){if(!/is not defined|can't find variable/i.test(e))return!1;return!/\b(document|window|navigator|localStorage|sessionStorage|self)\b/.test(e)}var Wa=new Set;async function h(e,n,r,i={}){if(!e.trim())return;let a=A(),l=C(e,JSON.stringify(a)),u=za.get(l);if(u===void 0){try{let le=ie({loader:"ts",target:"browser",define:a}),pe=e.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");pe=pe.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),u=le.transformSync(pe)}catch{u=Rg(e)}za.set(l,u)}let f={exports:{}},x=f.exports,v=cn.cwd(),I={},j=[...u.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((le)=>le[1]).filter((le)=>!le.startsWith("node:")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(le)),W=new Map;for(let le of j)try{if(le.startsWith(".")){I[le]=await import(St.resolve(St.dirname(r),le));continue}let pe=St.resolve(v,"node_modules",le),ve=St.join(pe,"package.json"),Le=JSON.parse(b("fs").readFileSync(ve,"utf8")),Ze=Le.main||"index.js";if(Le.exports){let it=typeof Le.exports==="string"?Le.exports:Le.exports["."];if(typeof it==="string")Ze=it;else if(it?.bun)Ze=it.bun;else if(it?.import)Ze=it.import;else if(it?.default)Ze=it.default}I[le]=await import(St.resolve(pe,Ze))}catch(pe){if(le.startsWith("."))W.set(le,pe instanceof Error?pe.message:String(pe))}let M=(le)=>{if(I[le])return I[le];let pe=W.get(le);if(pe!==void 0)throw Error(`Cannot require '${le}' from ${r}: ${pe}`);return b(le)},L=n.props||{},V=(le)=>{if(!le)return L;let pe={};for(let[ve,Le]of Object.entries(le)){let Ze=L[ve];if(Ze!==void 0)pe[ve]=Ze;else if(typeof Le==="function")pe[ve]=Le();else pe[ve]=Le}return pe};for(let[le,pe]of Object.entries(L))Object.defineProperty(V,le,{value:pe,enumerable:!0,configurable:!0,writable:!0});let U=(le,pe=!1)=>{if(le===void 0||le===null)return pe;if(typeof le==="string"){let ve=le.trim().toLowerCase();if(ve===""||ve==="true"||ve==="1"||ve==="on"||ve==="yes")return!0;if(ve==="false"||ve==="0"||ve==="off"||ve==="no")return!1;return!0}return Boolean(le)},q=(le,pe=0)=>{if(le===void 0||le===null)return pe;if(typeof le==="string"){let Le=le.trim();if(Le==="")return pe;let Ze=Number(Le);return Number.isFinite(Ze)?Ze:pe}let ve=Number(le);return Number.isFinite(ve)?ve:pe};for(let le of["name","length","caller","arguments"]){if(Object.prototype.hasOwnProperty.call(L,le))continue;try{Object.defineProperty(V,le,{value:void 0,enumerable:!1,configurable:!0,writable:!0})}catch{}}let Z=(le)=>{if(!le)return L;let pe={...L};for(let[ve,Le]of Object.entries(le)){let Ze=Le&&typeof Le==="object"&&!Array.isArray(Le)?Le:{type:Le};if(pe[ve]===void 0&&Ze.default!==void 0)pe[ve]=typeof Ze.default==="function"?Ze.default():Ze.default}return pe},G=()=>n.slots||{},H=(le,pe)=>{let ve={...le};for(let[Le,Ze]of Object.entries(pe))if(ve[Le]===void 0)if(typeof Ze==="function")ve[Le]=Ze();else ve[Le]=Ze;return ve},ne=(le)=>{let pe=()=>le;return pe.set=(ve)=>{},pe.update=(ve)=>{},pe},ce=(le)=>{let pe,ve=!1;return()=>{if(!ve)try{pe=le(),ve=!0}catch{pe=void 0}return pe}},de=(le)=>{},fe=(le)=>le(),Ce=(le)=>{},Re=(le)=>{},we=oo(n);function xe(le){let pe=le||{};if(pe.title!==void 0||pe.description!==void 0)ht({title:pe.title,description:pe.description})}function He(le){if(!le||typeof le!=="object")return;let pe=n.__stxClientPayload??{};Object.assign(pe,le),n.__stxClientPayload=pe}let tt=()=>{let le=n.__stxServeContext,pe=n.__stxServeSearch??le?.search??"",ve=le?.path??"",Le=Object.fromEntries(new URLSearchParams(pe)),Ze=n.query,it=Object.keys(Le).length>0?Le:Ze??{},yt=pe||(Object.keys(it).length>0?`?${new URLSearchParams(it).toString()}`:"");return{params:n.params??{},query:it,path:ve,name:"",fullPath:ve+yt,hash:"",matched:[]}},ct=()=>({push:(le)=>{},replace:(le)=>{},back:()=>{},forward:()=>{},go:(le)=>{}}),nt=(le)=>{let pe=n.__stx_runtime_head||{};n.__stx_runtime_head=Qe(pe,Me(le||{},{known:ho,source:"useHead()"}))},ht=(le)=>{nt(yo(le||{}))},ut=(le)=>({value:le}),rt=(le)=>le,jt=(le)=>({value:typeof le==="function"?le():le}),je=(le,pe)=>{},Te=(le)=>{},pt=(le)=>{},et=(le)=>le?le():Promise.resolve(),ln=(le)=>(pe,...ve)=>{},It=(le)=>{},xt=(le,pe)=>{},un=(le,pe)=>pe,Rs=()=>({value:"light"}),Ft=()=>ne(!1),$t=(le)=>ne(!1),pn=()=>ne(!1),Wn=()=>$t("(prefers-color-scheme: dark)"),fn=()=>$t("(prefers-color-scheme: light)"),dn=()=>$t("(prefers-reduced-motion: reduce)"),Ur=()=>$t("(prefers-contrast: more)"),bt={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},gn=new Proxy(bt,{get(le,pe){if(pe in le)return le[pe];return},set(le,pe,ve){return le[pe]=ve,!0}}),As={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},Et=console;try{let le=Bi(u,r),pe=new Set(Object.keys(L)),ve=Object.keys(n).filter((ue)=>!pe.has(ue)&&!zp.has(ue)&&Fr(ue)),Le=ve.map((ue)=>n[ue]);if(!ve.includes("__stxServeContext"))ve.push("__stxServeContext"),Le.push(void 0);if(!pe.has("cookies")){let ue=n.cookies??n.__stxServeContext?.cookies??{},be=ve.indexOf("cookies");if(be<0)ve.push("cookies"),Le.push(ue);else Le[be]=ue}let Ze=new Set(["async","module","exports","require","params","window","document","console","state","derived","effect"]),it=[],yt=[];for(let[ue,be]of Object.entries(L)){if(!Fr(ue))continue;if(Ze.has(ue))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${ue}\\b`).test(le))continue;it.push(ue),yt.push(be)}let Is=Wp(le).map((ue)=>`module.exports.${ue} = typeof ${ue} !== 'undefined' ? ${ue} : module.exports.${ue};`).join(`
|
|
1188
|
-
`),Fn=n.params??{},mn=[],hn=[];for(let ue=0;ue<ve.length;ue++){if(ve[ue]==="params")continue;mn.push(ve[ue]),hn.push(Le[ue])}let Vn=[...mt,...it,...mn],Un=`return (async () => {
|
|
1189
|
-
${le}
|
|
1190
|
-
${Is}
|
|
1191
|
-
return module.exports
|
|
1192
|
-
})()`,kt=C(Un,Vn.join("\x00")),Pt=Ba.get(kt);if(!Pt)Pt=Function(...Vn,Un),Ba.set(kt,Pt);let Ct=n.__stx_options?.runtimeConfig;if(Ct||/\buse(?:Server)?RuntimeConfig\b/.test(u))await In(n,r,Ct);let ot=await Ye(n.__stx_runtime_config??On()??z(),()=>ei(n,()=>Pt(f,x,M,L,V,U,q,Z,H,He,ti,Ki,uo,ne,ce,de,fe,Ce,Re,xe,tt,ct,nt,ht,we.setResponseStatus,we.setResponseHeader,we.notFound,ut,rt,jt,je,Te,pt,et,ln,It,G,xt,un,Rs,Ft,$t,pn,Wn,fn,dn,Ur,gn,As,Et,bt.confirm,bt.alert,bt.fetch,Fn,...yt,...hn)));if(i.preserveExisting){for(let[ue,be]of Object.entries(ot))if(!(ue in n)||n[ue]===void 0)n[ue]=be}else Object.assign(n,ot);for(let[ue,be]of Object.entries(L))if(!(ue in n))n[ue]=be}catch(le){if(n.__stx_strict_hydration)throw le;let pe=Ag(le instanceof Error?le.message:String(le));if(Pg(pe))console.warn(`[stx] server <script> in ${r??"<unknown>"} imports a module that does not resolve, so every variable in that script is undefined. Cause: ${pe}`),i.onFailure?.({kind:"module-resolution",message:pe,error:le});else if(Ig(le))console.warn(`[stx] server <script> in ${r??"<unknown>"} does not parse, so every variable in that script is undefined. Cause: ${pe}`),i.onFailure?.({kind:"syntax",message:pe,error:le});else if(Og(pe))console.warn(`[stx] server <script> in ${r??"<unknown>"} names something that does not exist, so every variable in that script is undefined. Optional chaining does not help here: an undefined identifier throws before the chain is reached. Cause: ${pe}`),i.onFailure?.({kind:"missing-binding",message:pe,error:le});else{let ve=`${r??"<unknown>"}\x00${pe}`;if(cn.env.STX_DEBUG||!Wa.has(ve))Wa.add(ve),console.warn(`[stx] server <script> in ${r??"<unknown>"} threw, so every variable in that script is undefined and anything that reads one renders empty. Cause: ${pe}`);i.onFailure?.({kind:"unknown",message:pe,error:le})}try{await qp(u,n,r)}catch(ve){if(cn.env.STX_DEBUG){let Le=ve instanceof Error?ve.message:String(ve);console.warn(`[stx] fallback extraction also failed in ${r??"<unknown>"}: ${Le}`)}}}}function Ng(e){let n=0,r=null,i=!1,a=!1;for(let l=0;l<e.length;l++){let u=e[l];if(r){if(u===r){if(r=null,i||n===0)a=!0}continue}if(u==="'"||u==='"'||u==="`"){r=u;continue}if(u==="{")n++;else if(u==="}")n--;else if(e.startsWith("from",l)&&n===0)i=!0}return r===null&&n===0&&a}var Fp=/^(?:export\s+)?(?:const|let|var)\s+[A-Za-z_$][\w$]*(?:\s*,\s*[A-Za-z_$][\w$]*)*\s*;?$/;function Bi(e,n){let r=n?St.dirname(n):cn.cwd(),i=cn.cwd(),a=e.split(`
|
|
1193
|
-
`),l=[],u=0;while(u<a.length){let f=a[u].trim();if(f.startsWith("interface ")||f.startsWith("export interface ")||f.startsWith("type ")||f.startsWith("export type ")){if(f.includes("{")&&!f.includes("}")){let x=0;for(;u<a.length;u++){for(let v of a[u])if(v==="{")x++;else if(v==="}")x--;if(x<=0)break}}u++;continue}if(f.startsWith("definePageMeta(")){let x=0,v=!1,I=u;for(let M=u;M<a.length&&!v;M++){let L=null,V=!1,U=a[M];for(let q=0;q<U.length;q++){let Z=U[q];if(V){V=!1;continue}if(Z==="\\"){V=!0;continue}if(L){if(Z===L)L=null;continue}if(Z==='"'||Z==="'"||Z==="`"){L=Z;continue}if(Z==="(")x++;else if(Z===")"){if(x--,x===0){u=M+1,v=!0;break}}}}if(!v)u=a.length;let j=a.slice(I,u).join(`
|
|
1194
|
-
`),W=[];for(let M of["title","description"]){let L=new RegExp(`\\b${M}\\s*:\\s*(['"\`])((?:\\\\.|(?!\\1)[^\\\\])*)\\1`).exec(j);if(L)W.push(`${M}: ${JSON.stringify(L[2])}`)}if(W.length>0)l.push(`useSeoMeta({ ${W.join(", ")} });`);continue}if(f.startsWith("import ")||f==="import"||f.startsWith("import{")||/^import['"]/.test(f)){let x=f,v=0;while(!Ng(x)&&u+v+1<a.length)v++,x=`${x} ${a[u+v].trim()}`;u+=v;let I=x.match(/^import\s+(\w+)\s+from\s+['"](.+?)['"]/),j=x.match(/^import\s+\{([^}]*)\}\s+from\s+['"](.+?)['"]/),W=x.match(/^import\s*['"](.+?)['"]/),M=x,L=(V)=>{if(V.startsWith("."))return St.resolve(r,V);if(V.startsWith("~/")||V.startsWith("@/"))return St.resolve(i,V.slice(2));try{return Bun.resolveSync(V,r)}catch{return V}};if(I){let[,V,U]=I,q=L(U);l.push(`const ${V} = (await import('${q}')).default`),l.push(`module.exports.${V} = ${V};`)}else if(j){let[,V,U]=j,q=L(U),Z=[],G=[],H=Bp.has(U);for(let ne of V.split(",")){let ce=ne.trim();if(!ce)continue;let de=ce.split(/\s+as\s+/);if(de.length===2){let[fe,Ce]=[de[0].trim(),de[1].trim()];if(H&&La.has(fe)){l.push(`const ${Ce} = ${fe};`);continue}Z.push(`${fe}: ${Ce}`),G.push(Ce)}else{if(H&&La.has(ce))continue;Z.push(ce),G.push(ce)}}if(Z.length>0)l.push(`const { ${Z.join(", ")} } = await import('${q}')`);for(let ne of G)l.push(`module.exports.${ne} = ${ne};`)}else if(W){let V=L(W[1]);l.push(`await import('${V}')`)}else l.push(M);u++;continue}if(Fp.test(f))l.push(a[u]),u++;else if(f.startsWith("export const ")||f.startsWith("export let ")||f.startsWith("export var ")){let x=Va(a,u),{type:v,name:I,value:j}=x;l.push(`${v} ${I} = ${j};`),l.push(`module.exports.${I} = ${I};`),u=x.nextIndex}else if(f.startsWith("export function ")||f.startsWith("export async function ")){let x=Vr(a,u);l.push(x.functionCode),l.push(`module.exports.${x.name} = ${x.name};`),u=x.nextIndex}else if(f.startsWith("const ")||f.startsWith("let ")||f.startsWith("var ")){let x=Va(a,u),{type:v,name:I,value:j}=x;l.push(`${v} ${I} = ${j};`),l.push(`module.exports.${I} = ${I};`),u=x.nextIndex}else if(f.startsWith("function ")||f.startsWith("async function ")){let x=Vr(a,u);l.push(x.functionCode),l.push(`module.exports.${x.name} = ${x.name};`),u=x.nextIndex}else if(f.startsWith("export default function ")||f.startsWith("export default async function ")){let x=a[u].replace(/^(\s*)export\s+default\s+/,"$1"),v=[...a];v[u]=x;let I=Vr(v,u);if(l.push(I.functionCode),I.name)l.push(`module.exports.default = ${I.name};`);u=I.nextIndex}else if(f.startsWith("export default ")){let x=f.replace(/^export\s+default\s+/,"").replace(/;$/,"");l.push(`module.exports.default = ${x};`),u++}else if(f.startsWith("class ")||f.startsWith("export class ")){let x=f.match(/(?:export\s+)?class\s+(\w+)/);if(x){let v=x[1],I=a[u].replace(/^export\s+/,""),j=0,W=u;for(;W<a.length;W++){let M=a[W];for(let L of M)if(L==="{")j++;else if(L==="}")j--;if(W>u)I+=`
|
|
1195
|
-
`+M;if(j<=0&&W>=u)break}l.push(I),l.push(`module.exports.${v} = ${v};`),u=W+1}else l.push(f),u++}else if(f.includes("module.exports"))l.push(f),u++;else if(f.trim()&&!f.startsWith("//"))l.push(f),u++;else u++}return Vp(l.join(`
|
|
1196
|
-
`),r,i)}function Vp(e,n,r){let i=e.length,a="",l=0,u=null,f=!1,x=!1,v=0;while(l<i){let I=e[l],j=e[l+1];if(f){if(a+=I,I===`
|
|
1197
|
-
`)f=!1;l++;continue}if(x){if(a+=I,I==="*"&&j==="/"){a+=j,l+=2,x=!1;continue}l++;continue}if(!u&&I==="/"&&j==="/"){f=!0,a+=I,l++;continue}if(!u&&I==="/"&&j==="*"){x=!0,a+=I,l++;continue}if(u){if(a+=I,I==="\\"){a+=j,l+=2;continue}if(I===u&&u!=="`"){u=null,l++;continue}if(u==="`"){if(I==="$"&&j==="{"){v++,a+=j,l+=2;continue}if(I==="`"){u=null,l++;continue}}l++;continue}if(v>0){if(I==="{")v++;else if(I==="}")v--}if(I==='"'||I==="'"||I==="`"){u=I,a+=I,l++;continue}if(I==="a"&&e.startsWith("await",l)){let W=Up(e,l);if(W){let{quote:M,path:L,end:V}=W;if(L.startsWith(".")||L.startsWith("~/")||L.startsWith("@/")){let U=L.startsWith(".")?St.resolve(n,L):St.resolve(r,L.slice(2));a+=`await import(${M}${U}${M})`,l=V;continue}}}a+=I,l++}return a}function Up(e,n){let r=n+5;if(r>=e.length)return null;if(!/\s/.test(e[r]))return null;while(r<e.length&&/\s/.test(e[r]))r++;if(!e.startsWith("import",r))return null;r+=6;while(r<e.length&&/\s/.test(e[r]))r++;if(e[r]!=="(")return null;r++;while(r<e.length&&/\s/.test(e[r]))r++;let i=e[r];if(i!=="'"&&i!=='"')return null;r++;let a=r;while(r<e.length&&e[r]!==i)if(e[r]==="\\")r+=2;else r++;if(r>=e.length)return null;let l=e.slice(a,r);r++;while(r<e.length&&/\s/.test(e[r]))r++;if(e[r]!==")")return null;return{quote:i,path:l,end:r+1}}function qa(e,n){let r=e[n];if(r!=="{"&&r!=="[")return null;let a=k(e,r,r==="{"?"}":"]",n);if(a===-1)return null;return{pattern:e.slice(n,a+1),endPos:a+1}}function Za(e){let n=[],r=e.slice(1,-1).trim();if(!r)return n;let i=0,a=0,l="";while(i<r.length){let u=r[i];if(u==="{"||u==="["){let f=a===0?qa(r,i):null;if(f){n.push(...Za(f.pattern)),i=f.endPos,l="";continue}a++}else if(u==="}"||u==="]")a--;if(a>0){i++;continue}if(u===","){if(l.trim())n.push(l.trim());l="",i++;continue}if(u===":"){l="",i++;continue}if(u==="="){if(l.trim())n.push(l.trim());l="",i++;while(i<r.length&&r[i]!==","&&a===0){if(r[i]==="{"||r[i]==="[")a++;else if(r[i]==="}"||r[i]==="]")a--;i++}continue}if(/[\w$]/.test(u))l+=u;i++}if(l.trim())n.push(l.trim());return n}function Mg(e){let n=/^(?:export\s+)?(const|let|var)\s+([A-Za-z_$][\w$]*)/.exec(e);if(!n)return null;let r=n[0].length,i=(a)=>a===" "||a==="\t";while(r<e.length&&i(e[r]))r++;if(e[r]===":"){let a=0,l=null;r++;for(;r<e.length;r++){let u=e[r];if(l){if(u==="\\"){r++;continue}if(u===l)l=null;continue}if(u==="'"||u==='"'||u==="`"){l=u;continue}if(u==="("||u==="["||u==="{"||u==="<"){a++;continue}if(u===")"||u==="]"||u==="}"||u===">"){a--;continue}if(u==="="&&a<=0){let f=e[r+1],x=e[r-1];if(f!=="="&&f!==">"&&x!=="="&&x!=="!"&&x!=="<"&&x!==">")break}}if(e[r]!=="=")return null}while(r<e.length&&i(e[r]))r++;if(e[r]!=="=")return null;return{type:n[1],name:n[2],value:e.slice(r+1).trim()}}function Fa(e,n,r,i){let a=null,l=!1;for(let u of e){if(l){l=!1;continue}if(u==="\\"){l=!0;continue}if(a){if(u===a)a=null;continue}if(u==="'"||u==='"'||u==="`"){a=u;continue}if(u===n)i++;else if(u===r)i--}return i}function Va(e,n){let r=e[n].trim(),i=Mg(r),a=i?[r,i.type,i.name,i.value]:null;if(!a){let I=r.match(/^(?:export\s+)?(const|let|var)\s+/);if(I){let j=r.slice(I[0].length),W=n;if(j.startsWith("{")||j.startsWith("[")){let L=j[0],V=L==="{"?"}":"]",U=Fa(j,L,V,0),q=j;for(let Z=n+1;Z<e.length&&U>0;Z++)q+=` ${e[Z].trim()}`,W=Z,U=Fa(e[Z],L,V,U);if(U>0)q=j,W=n;j=q}let M=qa(j,0);if(M){let L=I[1],V=M.pattern,U=j.slice(M.endPos).trim();if(U.startsWith("=")){let q=U.slice(1).trim(),Z=q,G=Math.max(W,n);if(Ua(q)){let de=Ha(e,G,q);Z=de.value,G=de.nextIndex}else G=G+1;Z=Z.trim().replace(/;$/,"");let H=Za(V),ne=`__stx_src_${n}`,ce=H.map((de)=>`module.exports.${de} = ${de};`).join(`
|
|
1198
|
-
`);return{type:L,name:ne,value:`${Z}; ${L} ${V} = ${ne};
|
|
1199
|
-
${ce}`,nextIndex:G}}}}throw Error(`Failed to parse variable declaration: ${r}`)}let[,l,u,f]=a,x=f,v=n;if(Ua(f)){let I=Ha(e,n,f);x=I.value,v=I.nextIndex}else v=n+1;while(v<e.length){let I=e[v].trim();if(I.startsWith(".")||I.startsWith("?."))x+=`
|
|
1200
|
-
${e[v]}`,v++;else break}return x=x.trim().replace(/;$/,""),{type:l,name:u,value:x,nextIndex:v}}function Vr(e,n){let r=e[n].trim(),i=r.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!i)throw Error(`Failed to parse function declaration: ${r}`);let[,a]=i,l=r.replace(/^export\s+/,""),u=n;if(Hp(r)){let f=Kp(e,n,l);l=f.functionCode,u=f.nextIndex}else u=n+1;return{name:a,functionCode:l,nextIndex:u}}function Ua(e){let n=e.trim();if(n.startsWith("{"))return k(n,"{","}",0)===-1;if(n.startsWith("["))return k(n,"[","]",0)===-1;return!Ja(n)}function Ja(e){let n={paren:0,bracket:0,brace:0},r=null,i=0;for(let a=0;a<e.length;a++){let l=e[a];if((a>0?e[a-1]:"")==="\\"&&r)continue;if((l==='"'||l==="'")&&!r){r=l;continue}if(l===r&&r!=="`"){r=null;continue}if(l==="`"&&!r){r="`";continue}if(l==="`"&&r==="`"&&i===0){r=null;continue}if(r==="`"&&l==="$"&&e[a+1]==="{"){i++,a++;continue}if(i>0&&l==="{"){i++;continue}if(i>0&&l==="}"){i--;continue}if(r)continue;if(l==="(")n.paren++;else if(l===")")n.paren--;else if(l==="[")n.bracket++;else if(l==="]")n.bracket--;else if(l==="{")n.brace++;else if(l==="}")n.brace--}return n.paren===0&&n.bracket===0&&n.brace===0&&r===null}function Xa(e){let n=e.indexOf("(");if(n===-1)return e.indexOf("{");let r=k(e,"(",")",n);if(r===-1)return-1;return e.indexOf("{",r)}function Hp(e){let n=Xa(e);if(n===-1)return!0;return k(e,"{","}",n)===-1}function Ha(e,n,r){let i=r,a=n+1;while(a<e.length&&!Ja(i)){let l=e[a];i+=`
|
|
1201
|
-
${l}`,a++}while(a<e.length){let l=e[a].trim();if(l.startsWith(".")||l.startsWith("?."))i+=`
|
|
1202
|
-
${e[a]}`,a++;else break}return{value:i,nextIndex:a}}function Kp(e,n,r){let i=r,a=n+1;while(a<e.length){let l=Xa(i);if(l!==-1){if(k(i,"{","}",l)!==-1)break}let u=e[a];i+=`
|
|
1203
|
-
${u}`,a++}return{functionCode:i,nextIndex:a}}function Ka(e,n){let r=d(e,n)??d(`(${e})`,n);if(r!==void 0)return r;if(!/\bprocess\b/.test(e))return;let i={...n,process:Object.freeze({env:{...cn.env}})},a=Object.keys(i).filter(Fr),l=a.map((u)=>i[u]);try{return Function(...a,`'use strict'; return (${e});`)(...l)}catch{try{return Function(...a,`'use strict'; return ${e};`)(...l)}catch{return}}}async function qp(e,n,r){let i=e.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let l of i){let[,,u,f]=l;try{let x=f.trim().replace(/;$/,""),v=Ka(x,n);if(v!==void 0)n[u]=v}catch(x){console.warn(`Failed to parse export ${u} in fallback:`,x)}}let a=e.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let l of a){let[,,u,f]=l;if(!(u in n))try{let x=f.trim().replace(/;$/,""),v=Ka(x,n);if(v!==void 0)n[u]=v}catch{}}}function bl(e){let n=e.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),r=n?n[1]:"",i=n?e.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):e;return{scriptContent:r,templateWithoutScript:i}}function wl(e){let n=e.trim();if(!n)return!1;return/(?:const|let|var|function)\s+\w+/.test(n)}
|
|
1204
|
-
export{Ve,Ae,X,Gs,Xs,J,Pr,Js,Ys,Ti,$i,Ri,Zs,Ai,tl,zt,o,me,S,nl,C,Ir,Qs,Pe,A,Ue,B,Ht,Ie,Q,kn,We,w,rl,Se,re,Or,se,Nr,Mr,he,Vt,oe,F,gt,O,Dr,Lr,mt,sl,Ut,eo,to,ke,Pi,_n,no,ye,ol,il,Ii,al,Oi,cl,ro,Ni,Mi,ll,Di,Li,Cn,so,En,Wt,qt,ul,oo,dl,pl,Tn,jr,io,ao,fl,ji,gl,ml,hl,yl,Rg,Ag,Pg,Ig,Og,h,Ng,Bi,Mg,bl,wl,Fi,zi,Dg,Kt,vl,Lg,xl,Ty,qe,$n,Ke,jg,Bg,Fg,zg,Hg,co,Vg,Ge,ie,Xe,Ug,Br,Wg,Sl,kl,Hi,Je,s,Rn,_l,y,_e,$y,Cl,El,Tl,Vi,lo,qg,Ry,Kg,Ay,An,g,Y,ae,Pn,Oe,Gg,Ui,Xg,Py,P,Wi,Jg,Iy,N,Oy};
|