@stacksjs/stx 0.2.78 → 0.2.79
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/app-shell.js +1 -1
- package/dist/build-mode-detector.js +1 -1
- package/dist/build-views.js +1 -1
- package/dist/build.js +1 -1
- package/dist/cli.js +2 -2
- package/dist/component-processing.js +1 -1
- package/dist/component-renderer.js +1 -1
- package/dist/components.js +1 -1
- package/dist/conditionals.js +1 -1
- package/dist/dev-server/index.js +1 -1
- package/dist/dev-server/serve-app.js +1 -1
- package/dist/dev-server/serve-file.js +1 -1
- package/dist/dev-server/serve-markdown.js +1 -1
- package/dist/dev-server/serve-multi.js +1 -1
- package/dist/dev-server.js +1 -1
- package/dist/docs.js +1 -1
- package/dist/dynamic-components.js +1 -1
- package/dist/includes.js +1 -1
- package/dist/index.js +1 -1
- package/dist/interactive.js +1 -1
- package/dist/lazy-loader.js +1 -1
- package/dist/loops.js +1 -1
- package/dist/plugin.js +1 -1
- package/dist/process.js +1 -1
- package/dist/production-builder.js +1 -1
- package/dist/production-server.js +1 -1
- package/dist/pwa/index.js +1 -1
- package/dist/pwa/offline.js +1 -1
- package/dist/pwa.js +1 -1
- package/dist/render.js +1 -1
- package/dist/serve.js +1 -1
- package/dist/site-builder/build.js +1 -1
- package/dist/site-builder/index.js +1 -1
- package/dist/ssg.js +1 -1
- package/dist/ssr.js +1 -1
- package/dist/story/cli.js +1 -1
- package/dist/story/commands/dev.js +1 -1
- package/dist/story/commands/index.js +1 -1
- package/dist/story/index.js +1 -1
- package/dist/story/renderer.js +1 -1
- package/dist/story/server.js +1 -1
- package/dist/story/visual-testing.js +1 -1
- package/dist/streaming.js +1 -1
- package/dist/template-compiler.js +1 -1
- package/dist/template-hydrator.js +1 -1
- package/dist/testing.js +1 -1
- package/dist/utils.js +1 -1
- package/dist/web-components.js +1 -1
- package/package.json +5 -5
package/dist/build.js
CHANGED
|
@@ -1648,7 +1648,7 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
|
|
|
1648
1648
|
|
|
1649
1649
|
`),"utf-8")}}async flush(){await this.writeQueue}}var n4,c0,s4;var k9=b(()=>{W$();n4={isEnabled(){return G$().enableAutoRecovery},fixCommonSyntaxErrors($){let Z=G$();if(!Z.enableAutoRecovery)return{fixed:$,fixes:[]};let Y=$,J=[],X=(Y.match(/\{\{/g)||[]).length,Q=(Y.match(/\}\}/g)||[]).length;if(X>Q){let K=X-Q;Y+="}}".repeat(K),J.push(`Added ${K} missing closing braces '}}'`)}let G=["if","foreach","for","switch","section"];for(let K of G){let q=(Y.match(new RegExp(`@${K}\\b`,"g"))||[]).length,W=(Y.match(new RegExp(`@end${K}\\b`,"g"))||[]).length;if(q>W){let z=q-W;for(let U=0;U<z;U++)Y+=`
|
|
1650
1650
|
@end${K}`;J.push(`Added ${z} missing @end${K}`)}}if(J.length>0&&Z.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),J.forEach((K)=>console.warn(` - ${K}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:Y,fixes:J}},createFallbackContent($,Z){if(R5())return`<!-- ${$} failed: ${Z.message} -->`;return"<!-- stx rendering error -->"}};c0=new o4,s4={isDevelopment(){return R5()},logDetailedError($,Z){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",$.message),console.error("Stack:",$.stack),Z)console.error("Context:",Z);console.error("========================")},createErrorReport($,Z){let Y=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${$.message}`,`Type: ${$.constructor.name}`,`Stack: ${$.stack}`];if(Z)Y.push(`Context: ${JSON.stringify(Z,null,2)}`);return Y.push("========================"),Y.join(`
|
|
1651
|
-
`)}}});var b9=()=>{};var S9=b(()=>{Q$();E9();k9();b9();W$()});var G1=b(()=>{S9()});function y0($,Z,Y,J=0){let X=0,Q=J,G=null,K=0,q=!1;while(Q<$.length){let W=$[Q];if(G&&q){q=!1,Q++;continue}if(G&&W==="\\"){q=!0,Q++;continue}if(q=!1,(W==='"'||W==="'"||W==="`")&&!G){G=W,Q++;continue}if(W===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&W==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&W==="}"){K--,Q++;continue}if(W==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(W===Z)X++;else if(W===Y){if(X--,X===0)return Q}Q++}return-1}function _1($,Z){let Y=XG($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function XG($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let J=y0($,"(",")",Y);if(J===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,J),endPos:J+1}}function E1($,Z,Y,J){let X=1,Q=J,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&X>0){G.lastIndex=Q,K.lastIndex=Q;let q=G.exec($),W=K.exec($),z=q?q.index:1/0,U=W?W.index:1/0;if(z<U)X++,Q=z+q[0].length;else if(U<1/0){if(X--,X===0)return U;Q=U+W[0].length}else break}return-1}function y9($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let J=Z+Y[0].length,X=_1($,J);if(!X)return null;let Q=X.endPos,G=E1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],W=0,z="if",U=X.expression,_=0,B=0;while(W<K.length){let j=K.indexOf("@",W);if(j===-1)break;W=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,W++;continue}if(/^@endif(?![a-z])/.test(H)){B--,W+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){q.push({type:z,condition:U,content:K.substring(_,W),start:Q+_,end:Q+W});let F=W+L[0].length,O=_1(K,F);if(!O){W++;continue}z="elseif",U=O.expression,W=O.endPos,_=W;continue}else if(/^@else(?![a-z])/.test(H)){q.push({type:z,condition:U,content:K.substring(_,W),start:Q+_,end:Q+W}),z="else",U=void 0,W+=5,_=W;continue}}W++}return q.push({type:z,condition:U,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:q,start:Z,end:G+6}}function T5($){let Z=[],Y=/@if\s*\(/g,J=Y.exec($);while(J!==null){if(Z.some((G)=>J.index>G.start&&J.index<G.end)){J=Y.exec($);continue}let Q=y9($,J.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;J=Y.exec($)}return Z}function U$($,Z,Y){let J=[],X=new RegExp(`@${Z}\\s*\\(`,"g"),Q=X.exec($);while(Q!==null){if(J.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=X.exec($);continue}let K=Q.index,q=K+Q[0].length-1,W=y0($,"(",")",q);if(W===-1){Q=X.exec($);continue}let z=$.slice(q+1,W),U=W+1,_=E1($,Z,Y,U);if(_===-1){Q=X.exec($);continue}let B=$.slice(U,_),j=_+`@${Y}`.length;J.push({fullMatch:$.slice(K,j),name:Z,params:z,content:B,start:K,end:j}),X.lastIndex=j,Q=X.exec($)}return J}function r4($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let J=Z+Y[0].length,X=_1($,J);if(!X)return null;let Q=X.endPos,G=E1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],W=0,z=null,U=0;while(W<K.length){let _=K.slice(W),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(U++,z)z.content+=B[0];W+=B[0].length;continue}if(j){if(U--,z)z.content+=j[0];W+=j[0].length;continue}if(U>0){if(z)z.content+=K[W];W++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(z)q.push(z);let O=W+H[0].length,V=_1(K,O);if(!V){W++;continue}z={type:"case",value:V.expression,content:""},W=V.endPos}else if(L&&_.startsWith("@default")){if(z)q.push(z);z={type:"default",content:""},W+=L[0].length}else if(F&&_.startsWith("@break"))W+=F[0].length;else{if(z)z.content+=K[W];W++}}if(z)q.push(z);return{fullMatch:$.slice(Z,G+10),expression:X.expression,cases:q,start:Z,end:G+10}}var C9=()=>{};var P9=()=>{};var _$=b(()=>{C9();P9()});function qG($,Z,Y){let J=$,X=!0;while(X){X=!1;let Q=J.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=r4(J,G);if(!K)break;try{let q;if(X0(K.expression))q=Q0(K.expression,Object.keys(Z))(...Object.values(Z));else q=Z0(K.expression,Z);let W="",z=!1;for(let U of K.cases)if(U.type==="default"){if(!z)W=U.content.trim()}else try{let _;if(U.value&&X0(U.value))_=Q0(U.value,Object.keys(Z))(...Object.values(Z));else if(U.value)_=Z0(U.value,Z);if(q===_){W=U.content.trim(),z=!0;break}}catch{continue}J=J.substring(0,G)+W+J.substring(K.end),X=!0}catch(q){let W=q instanceof Error?q.message:String(q),z=r("Switch",`Error evaluating @switch expression: ${W}`,n.EVALUATION_ERROR);J=J.substring(0,G)+z+J.substring(K.end);break}}return J}function k1($,Z,Y){let J=$;J=qG(J,Z,Y);{let Q=!0;while(Q){Q=!1;let G=J.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,q=_1(J,K+7);if(!q)break;let W=q.endPos,z=E1(J,"unless","endunless",W);if(z===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let U=J.slice(W,z),_=q.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],w;while((w=L.exec(U))!==null)V.push({pos:w.index,type:"open"});while((w=F.exec(U))!==null)V.push({pos:w.index,type:"close"});while((w=O.exec(U))!==null)V.push({pos:w.index,type:"else"});V.sort((N,A)=>N.pos-A.pos);for(let N of V)if(N.type==="open")H++;else if(N.type==="close")H--;else if(N.type==="else"&&H===0){B=N.pos;break}}let j;if(B!==-1){let H=U.slice(0,B),L=U.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${U}@endif`;J=J.substring(0,K)+j+J.substring(z+10),Q=!0}}J=t4(J,Z,Y),J=e4(J,Z,Y),J=a4(J,Z);let X=()=>{let Q=T5(J);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let q="",W=!1;for(let z of K.branches){if(W)break;if(z.type==="else")q=z.content,W=!0;else try{let U;if(z.condition&&X0(z.condition))U=Q0(z.condition,Object.keys(Z))(...Object.values(Z));else if(z.condition)U=Z0(z.condition,Z);if(U)q=z.content,W=!0}catch(U){q=r(z.type==="if"?"If":"Elseif",`Error in @${z.type}(${z.condition}): ${U instanceof Error?U.message:String(U)}`,n.EVALUATION_ERROR),W=!0}}J=J.substring(0,K.start)+q+J.substring(K.end)}catch(q){let W=q instanceof Error?q.message:String(q),z=r("If",`Error processing @if block: ${W}`,n.EVALUATION_ERROR);J=J.substring(0,K.start)+z+J.substring(K.end)}}return!0};while(X());return J}function v9($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let Y=$[Z];if(Y!=="'"&&Y!=='"')return null;Z++;let J=[];while(Z<$.length){let X=$[Z];if(X==="\\"&&Z+1<$.length){J.push($[Z+1]),Z+=2;continue}if(X===Y){Z++;break}J.push(X),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:J.join(""),consumed:Z}}function a4($,Z){let Y=$;function J(K,q,W,z){let U=1,_=z,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(_<K.length&&U>0){B.lastIndex=_,j.lastIndex=_;let H=B.exec(K),L=j.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)U++,_=F+H[0].length;else if(O<1/0){if(U--,U===0)return O;_=O+L[0].length}else break}return-1}function X(K,q,W){let z=0,U=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=U.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=_.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")z++;else if(L.type==="close")z--;else if(L.type==="else"&&z===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let q=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let W=q.index,z,U,_=Y.slice(W+5),B=v9(_);if(B)z=B.value,U=W+5+B.consumed;else U=W+5;let j=J(Y,"auth","endauth",U);if(j===-1){console.warn(`[stx] @auth directive at position ${W} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=X(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=z?U1(`auth?.check && auth?.user?.[${z}]`,Z):U1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let q=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let W=q.index,z,U,_=Y.slice(W+6),B=v9(_);if(B)z=B.value,U=W+6+B.consumed;else U=W+6;let j=J(Y,"guest","endguest",U);if(j===-1){console.warn(`[stx] @guest directive at position ${W} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=X(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=z?U1(`!auth?.check || !auth?.user?.[${z}]`,Z):U1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+9),K=!0}}function Q(K,q,W){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let z=[K];if(q)z.push(q);if(W){let U=U1(W,Z);z.push(U)}return Z.permissions.check(...z)}catch{return!1}return!1}function G(K){let q=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!q)return null;return{ability:q[1],type:q[2],id:q[3]?.trim(),paramsEnd:q[0].length}}for(let K of["can","cannot"]){let q=`end${K}`,W=K==="can"?"elsecan":"elsecannot",z=!0;while(z){z=!1;let U=Y.match(new RegExp(`@${K}\\s*\\(`));if(!U||U.index===void 0)break;let _=U.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let H=_+`@${K}`.length+j.paramsEnd,L=J(Y,K,q,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${q} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),N=new RegExp(`@${q}(?![a-z])`,"g"),A=new RegExp(`@${W}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],M;while((M=w.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=N.exec(F))!==null)T.push({pos:M.index,type:"close"});while((M=A.exec(F))!==null)T.push({pos:M.index,type:"elseDirective"});while((M=R.exec(F))!==null)T.push({pos:M.index,type:"else"});T.sort((k,P)=>k.pos-P.pos);for(let k of T){if(k.type==="open"){V++;continue}if(k.type==="close"){V--;continue}if(V===0)O.push(k)}let I=[],E=0;for(let k=0;k<O.length;k++){let P=O[k];if(I.push({content:F.slice(E,P.pos),ability:void 0}),P.type==="elseDirective"){let h=F.slice(P.pos+`@${W}`.length),f=G(h);if(f){I[I.length-1]={content:F.slice(E,P.pos)},E=P.pos+`@${W}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=O[k+1],l=m?m.pos:F.length;I.push({content:F.slice(E,l),ability:f.ability,type:f.type,id:f.id}),E=l}}else E=P.pos+5}if(E<F.length){let k=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:F.slice(E),isFinalElse:!0});else if(I.length===0)I.push({content:F.slice(E)})}let D=Q(j.ability,j.type,j.id),y=K==="can"?D:!D,S="";if(y)S=I[0]?.content||"";else{let k=!1;for(let P=1;P<I.length;P++){let h=I[P];if(h.isFinalElse){S=h.content,k=!0;break}if(h.ability){let f=Q(h.ability,h.type,h.id);if(K==="can"?f:!f){S=h.content,k=!0;break}}}if(!k&&I.length>0){let P=I[I.length-1];if(P.isFinalElse)S=P.content}}Y=Y.substring(0,_)+S+Y.substring(L+`@${q}`.length),z=!0}}return Y}function t4($,Z,Y){let J=$;function X(Q,G,K,q,W){let z=!0;while(z){z=!1;let U=new RegExp(`@${G}\\s*\\(`),_=Q.match(U);if(!_||_.index===void 0)break;let B=_.index,j=_1(Q,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=E1(Q,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${B} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,L),O=j.expression,V=-1,w=0,N=0;while(N<F.length){let A=F.indexOf("@",N);if(A===-1)break;let R=F.substring(A);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){w++,N=A+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){w--,N=A+1;continue}if(w===0&&/^@else(?![a-z])/.test(R)){V=A;break}N=A+1}try{let A=q(O.trim()),R;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);R=A?T:M}else R=A?F:"";Q=Q.substring(0,B)+R+Q.substring(L+`@${K}`.length),z=!0}catch(A){let R=A instanceof Error?A.message:String(A),T=r(W,`Error processing @${G} directive: ${R}`,n.EVALUATION_ERROR);Q=Q.substring(0,B)+T+Q.substring(L+`@${K}`.length);break}}return Q}return J=X(J,"isset","endisset",(Q)=>{let G=U1(Q,Z);return G!==void 0&&G!==null},"Isset"),J=X(J,"empty","endempty",(Q)=>{let G=U1(Q,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),J}function e4($,Z,Y){let J=$,X="development";function Q(G,K,q,W){let z=new RegExp(`@${K}(?![a-z])`,"g"),U=new RegExp(`@${q}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${q}(?![a-z])`),j=G,H=!0;while(H){H=!1,z.lastIndex=0;let L=z.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let D=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!D)break;O+=D[0].length,W=X===D[2]}let V=1,w=O,N=-1;while(V>0&&w<j.length){z.lastIndex=w,U.lastIndex=w;let D=z.exec(j),y=U.exec(j),S=D?D.index:1/0,k=y?y.index:1/0;if(S<k)V++,w=S+D[0].length;else if(k<1/0){if(V--,V===0){N=k;break}w=k+y[0].length}else break}if(N===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${q} \u2014 the block was skipped.`);break}let A=j.substring(O,N),R=-1,T=0,M=0;while(M<A.length){let D=A.indexOf("@",M);if(D===-1)break;let y=A.substring(D);if(_.test(y)){T++,M=D+1;continue}if(B.test(y)){T--,M=D+1;continue}if(T===0&&/^@else(?![a-z])/.test(y)){R=D;break}M=D+1}let I;if(R!==-1){let D=A.slice(0,R),y=A.slice(R+5);I=W?D:y}else I=W?A:"";let E=`@${q}`.length;j=j.substring(0,F)+I+j.substring(N+E),H=!0}return j}return J=Q(J,"env","endenv",!1),J=Q(J,"production","endproduction",X==="production"),J=Q(J,"development","enddevelopment",X==="development"),J=Q(J,"staging","endstaging",X==="staging"),J=Q(J,"testing","endtesting",X==="testing"),J}var B$=b(()=>{M9();G1();_$();T0()});function f9($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function j$($,Z){if(!$)return Z?.nonceGenerator?.()??f9();let Y=x9.get($);if(!Y)Y=Z?.nonceGenerator?.()??f9(),x9.set($,Y);return Y}function zG($,Z){let Y=[];for(let[J,X]of Object.entries($)){if(X===void 0||X===null)continue;if(typeof X==="boolean"){if(X)Y.push(J);continue}if(Array.isArray(X)){let Q=[...X];if(Z&&(J==="script-src"||J==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)Y.push(`${J} ${Q.join(" ")}`)}}return Y.join("; ")}function g9($,Z){return`<meta http-equiv="Content-Security-Policy" content="${zG($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function h9($,Z,Y){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let J=Z.useNonce?j$(Y,Z):void 0,X=g9(Z.directives,J);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
1651
|
+
`)}}});var b9=()=>{};var S9=b(()=>{Q$();E9();k9();b9();W$()});var G1=b(()=>{S9()});function y0($,Z,Y,J=0){let X=0,Q=J,G=null,K=0,q=!1;while(Q<$.length){let W=$[Q];if(G&&q){q=!1,Q++;continue}if(G&&W==="\\"){q=!0,Q++;continue}if(q=!1,(W==='"'||W==="'"||W==="`")&&!G){G=W,Q++;continue}if(W===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&W==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&W==="}"){K--,Q++;continue}if(W==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(W===Z)X++;else if(W===Y){if(X--,X===0)return Q}Q++}return-1}function _1($,Z){let Y=XG($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function XG($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let J=y0($,"(",")",Y);if(J===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,J),endPos:J+1}}function E1($,Z,Y,J){let X=1,Q=J,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&X>0){G.lastIndex=Q,K.lastIndex=Q;let q=G.exec($),W=K.exec($),z=q?q.index:1/0,U=W?W.index:1/0;if(z<U)X++,Q=z+q[0].length;else if(U<1/0){if(X--,X===0)return U;Q=U+W[0].length}else break}return-1}function y9($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let J=Z+Y[0].length,X=_1($,J);if(!X)return null;let Q=X.endPos,G=E1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],W=0,z="if",U=X.expression,_=0,B=0;while(W<K.length){let j=K.indexOf("@",W);if(j===-1)break;W=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,W++;continue}if(/^@endif(?![a-z])/.test(H)){B--,W+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){q.push({type:z,condition:U,content:K.substring(_,W),start:Q+_,end:Q+W});let F=W+L[0].length,O=_1(K,F);if(!O){W++;continue}z="elseif",U=O.expression,W=O.endPos,_=W;continue}else if(/^@else(?![a-z])/.test(H)){q.push({type:z,condition:U,content:K.substring(_,W),start:Q+_,end:Q+W}),z="else",U=void 0,W+=5,_=W;continue}}W++}return q.push({type:z,condition:U,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:q,start:Z,end:G+6}}function T5($){let Z=[],Y=/@if\s*\(/g,J=Y.exec($);while(J!==null){if(Z.some((G)=>J.index>G.start&&J.index<G.end)){J=Y.exec($);continue}let Q=y9($,J.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;J=Y.exec($)}return Z}function U$($,Z,Y){let J=[],X=new RegExp(`@${Z}\\s*\\(`,"g"),Q=X.exec($);while(Q!==null){if(J.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=X.exec($);continue}let K=Q.index,q=K+Q[0].length-1,W=y0($,"(",")",q);if(W===-1){Q=X.exec($);continue}let z=$.slice(q+1,W),U=W+1,_=E1($,Z,Y,U);if(_===-1){Q=X.exec($);continue}let B=$.slice(U,_),j=_+`@${Y}`.length;J.push({fullMatch:$.slice(K,j),name:Z,params:z,content:B,start:K,end:j}),X.lastIndex=j,Q=X.exec($)}return J}function r4($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let J=Z+Y[0].length,X=_1($,J);if(!X)return null;let Q=X.endPos,G=E1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],W=0,z=null,U=0;while(W<K.length){let _=K.slice(W),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(U++,z)z.content+=B[0];W+=B[0].length;continue}if(j){if(U--,z)z.content+=j[0];W+=j[0].length;continue}if(U>0){if(z)z.content+=K[W];W++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(z)q.push(z);let O=W+H[0].length,V=_1(K,O);if(!V){W++;continue}z={type:"case",value:V.expression,content:""},W=V.endPos}else if(L&&_.startsWith("@default")){if(z)q.push(z);z={type:"default",content:""},W+=L[0].length}else if(F&&_.startsWith("@break"))W+=F[0].length;else{if(z)z.content+=K[W];W++}}if(z)q.push(z);return{fullMatch:$.slice(Z,G+10),expression:X.expression,cases:q,start:Z,end:G+10}}var C9=()=>{};var P9=()=>{};var _$=b(()=>{C9();P9()});function qG($,Z,Y){let J=$,X=!0;while(X){X=!1;let Q=J.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=r4(J,G);if(!K)break;try{let q;if(X0(K.expression))q=Q0(K.expression,Object.keys(Z))(...Object.values(Z));else q=Z0(K.expression,Z);let W="",z=!1;for(let U of K.cases)if(U.type==="default"){if(!z)W=U.content.trim()}else try{let _;if(U.value&&X0(U.value))_=Q0(U.value,Object.keys(Z))(...Object.values(Z));else if(U.value)_=Z0(U.value,Z);if(q===_){W=U.content.trim(),z=!0;break}}catch{continue}J=J.substring(0,G)+W+J.substring(K.end),X=!0}catch(q){let W=q instanceof Error?q.message:String(q),z=r("Switch",`Error evaluating @switch expression: ${W}`,n.EVALUATION_ERROR);J=J.substring(0,G)+z+J.substring(K.end);break}}return J}function k1($,Z,Y){let J=$;J=qG(J,Z,Y);{let Q=!0;while(Q){Q=!1;let G=J.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,q=_1(J,K+7);if(!q)break;let W=q.endPos,z=E1(J,"unless","endunless",W);if(z===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let U=J.slice(W,z),_=q.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],w;while((w=L.exec(U))!==null)V.push({pos:w.index,type:"open"});while((w=F.exec(U))!==null)V.push({pos:w.index,type:"close"});while((w=O.exec(U))!==null)V.push({pos:w.index,type:"else"});V.sort((N,A)=>N.pos-A.pos);for(let N of V)if(N.type==="open")H++;else if(N.type==="close")H--;else if(N.type==="else"&&H===0){B=N.pos;break}}let j;if(B!==-1){let H=U.slice(0,B),L=U.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${U}@endif`;J=J.substring(0,K)+j+J.substring(z+10),Q=!0}}J=t4(J,Z,Y),J=e4(J,Z,Y),J=a4(J,Z);let X=()=>{let Q=T5(J);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let q="",W=!1;for(let z of K.branches){if(W)break;if(z.type==="else")q=z.content,W=!0;else try{let U;if(z.condition&&X0(z.condition))U=Q0(z.condition,Object.keys(Z))(...Object.values(Z));else if(z.condition)U=Z0(z.condition,Z);if(U)q=z.content,W=!0}catch(U){q=r(z.type==="if"?"If":"Elseif",`Error in @${z.type}(${z.condition}): ${U instanceof Error?U.message:String(U)}`,n.EVALUATION_ERROR),W=!0}}J=J.substring(0,K.start)+q+J.substring(K.end)}catch(q){let W=q instanceof Error?q.message:String(q),z=r("If",`Error processing @if block: ${W}`,n.EVALUATION_ERROR);J=J.substring(0,K.start)+z+J.substring(K.end)}}return!0};while(!0){let Q=J;if(!X())break;if(J===Q)break}return J}function v9($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let Y=$[Z];if(Y!=="'"&&Y!=='"')return null;Z++;let J=[];while(Z<$.length){let X=$[Z];if(X==="\\"&&Z+1<$.length){J.push($[Z+1]),Z+=2;continue}if(X===Y){Z++;break}J.push(X),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:J.join(""),consumed:Z}}function a4($,Z){let Y=$;function J(K,q,W,z){let U=1,_=z,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(_<K.length&&U>0){B.lastIndex=_,j.lastIndex=_;let H=B.exec(K),L=j.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)U++,_=F+H[0].length;else if(O<1/0){if(U--,U===0)return O;_=O+L[0].length}else break}return-1}function X(K,q,W){let z=0,U=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=U.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=_.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")z++;else if(L.type==="close")z--;else if(L.type==="else"&&z===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let q=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let W=q.index,z,U,_=Y.slice(W+5),B=v9(_);if(B)z=B.value,U=W+5+B.consumed;else U=W+5;let j=J(Y,"auth","endauth",U);if(j===-1){console.warn(`[stx] @auth directive at position ${W} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=X(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=z?U1(`auth?.check && auth?.user?.[${z}]`,Z):U1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let q=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let W=q.index,z,U,_=Y.slice(W+6),B=v9(_);if(B)z=B.value,U=W+6+B.consumed;else U=W+6;let j=J(Y,"guest","endguest",U);if(j===-1){console.warn(`[stx] @guest directive at position ${W} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=X(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=z?U1(`!auth?.check || !auth?.user?.[${z}]`,Z):U1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+9),K=!0}}function Q(K,q,W){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let z=[K];if(q)z.push(q);if(W){let U=U1(W,Z);z.push(U)}return Z.permissions.check(...z)}catch{return!1}return!1}function G(K){let q=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!q)return null;return{ability:q[1],type:q[2],id:q[3]?.trim(),paramsEnd:q[0].length}}for(let K of["can","cannot"]){let q=`end${K}`,W=K==="can"?"elsecan":"elsecannot",z=!0;while(z){z=!1;let U=Y.match(new RegExp(`@${K}\\s*\\(`));if(!U||U.index===void 0)break;let _=U.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let H=_+`@${K}`.length+j.paramsEnd,L=J(Y,K,q,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${q} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),N=new RegExp(`@${q}(?![a-z])`,"g"),A=new RegExp(`@${W}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],M;while((M=w.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=N.exec(F))!==null)T.push({pos:M.index,type:"close"});while((M=A.exec(F))!==null)T.push({pos:M.index,type:"elseDirective"});while((M=R.exec(F))!==null)T.push({pos:M.index,type:"else"});T.sort((k,P)=>k.pos-P.pos);for(let k of T){if(k.type==="open"){V++;continue}if(k.type==="close"){V--;continue}if(V===0)O.push(k)}let I=[],E=0;for(let k=0;k<O.length;k++){let P=O[k];if(I.push({content:F.slice(E,P.pos),ability:void 0}),P.type==="elseDirective"){let h=F.slice(P.pos+`@${W}`.length),f=G(h);if(f){I[I.length-1]={content:F.slice(E,P.pos)},E=P.pos+`@${W}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=O[k+1],l=m?m.pos:F.length;I.push({content:F.slice(E,l),ability:f.ability,type:f.type,id:f.id}),E=l}}else E=P.pos+5}if(E<F.length){let k=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:F.slice(E),isFinalElse:!0});else if(I.length===0)I.push({content:F.slice(E)})}let D=Q(j.ability,j.type,j.id),y=K==="can"?D:!D,S="";if(y)S=I[0]?.content||"";else{let k=!1;for(let P=1;P<I.length;P++){let h=I[P];if(h.isFinalElse){S=h.content,k=!0;break}if(h.ability){let f=Q(h.ability,h.type,h.id);if(K==="can"?f:!f){S=h.content,k=!0;break}}}if(!k&&I.length>0){let P=I[I.length-1];if(P.isFinalElse)S=P.content}}Y=Y.substring(0,_)+S+Y.substring(L+`@${q}`.length),z=!0}}return Y}function t4($,Z,Y){let J=$;function X(Q,G,K,q,W){let z=!0;while(z){z=!1;let U=new RegExp(`@${G}\\s*\\(`),_=Q.match(U);if(!_||_.index===void 0)break;let B=_.index,j=_1(Q,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=E1(Q,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${B} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,L),O=j.expression,V=-1,w=0,N=0;while(N<F.length){let A=F.indexOf("@",N);if(A===-1)break;let R=F.substring(A);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){w++,N=A+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){w--,N=A+1;continue}if(w===0&&/^@else(?![a-z])/.test(R)){V=A;break}N=A+1}try{let A=q(O.trim()),R;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);R=A?T:M}else R=A?F:"";Q=Q.substring(0,B)+R+Q.substring(L+`@${K}`.length),z=!0}catch(A){let R=A instanceof Error?A.message:String(A),T=r(W,`Error processing @${G} directive: ${R}`,n.EVALUATION_ERROR);Q=Q.substring(0,B)+T+Q.substring(L+`@${K}`.length);break}}return Q}return J=X(J,"isset","endisset",(Q)=>{let G=U1(Q,Z);return G!==void 0&&G!==null},"Isset"),J=X(J,"empty","endempty",(Q)=>{let G=U1(Q,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),J}function e4($,Z,Y){let J=$,X="development";function Q(G,K,q,W){let z=new RegExp(`@${K}(?![a-z])`,"g"),U=new RegExp(`@${q}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${q}(?![a-z])`),j=G,H=!0;while(H){H=!1,z.lastIndex=0;let L=z.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let D=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!D)break;O+=D[0].length,W=X===D[2]}let V=1,w=O,N=-1;while(V>0&&w<j.length){z.lastIndex=w,U.lastIndex=w;let D=z.exec(j),y=U.exec(j),S=D?D.index:1/0,k=y?y.index:1/0;if(S<k)V++,w=S+D[0].length;else if(k<1/0){if(V--,V===0){N=k;break}w=k+y[0].length}else break}if(N===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${q} \u2014 the block was skipped.`);break}let A=j.substring(O,N),R=-1,T=0,M=0;while(M<A.length){let D=A.indexOf("@",M);if(D===-1)break;let y=A.substring(D);if(_.test(y)){T++,M=D+1;continue}if(B.test(y)){T--,M=D+1;continue}if(T===0&&/^@else(?![a-z])/.test(y)){R=D;break}M=D+1}let I;if(R!==-1){let D=A.slice(0,R),y=A.slice(R+5);I=W?D:y}else I=W?A:"";let E=`@${q}`.length;j=j.substring(0,F)+I+j.substring(N+E),H=!0}return j}return J=Q(J,"env","endenv",!1),J=Q(J,"production","endproduction",X==="production"),J=Q(J,"development","enddevelopment",X==="development"),J=Q(J,"staging","endstaging",X==="staging"),J=Q(J,"testing","endtesting",X==="testing"),J}var B$=b(()=>{M9();G1();_$();T0()});function f9($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function j$($,Z){if(!$)return Z?.nonceGenerator?.()??f9();let Y=x9.get($);if(!Y)Y=Z?.nonceGenerator?.()??f9(),x9.set($,Y);return Y}function zG($,Z){let Y=[];for(let[J,X]of Object.entries($)){if(X===void 0||X===null)continue;if(typeof X==="boolean"){if(X)Y.push(J);continue}if(Array.isArray(X)){let Q=[...X];if(Z&&(J==="script-src"||J==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)Y.push(`${J} ${Q.join(" ")}`)}}return Y.join("; ")}function g9($,Z){return`<meta http-equiv="Content-Security-Policy" content="${zG($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function h9($,Z,Y){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let J=Z.useNonce?j$(Y,Z):void 0,X=g9(Z.directives,J);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
1652
1652
|
${X}`)}function d9($,Z,Y,J){let X=$,Q=J.csp;if(X=X.replace(/@csp\b/g,()=>{if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?j$(Z,Q):void 0;return g9(Q.directives,G)}),X=X.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return j$(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=j$(Z,Q);return X}var x9;var m9=b(()=>{x9=new WeakMap});import WG from"crypto";function _G($=UG){let Z=WG.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return $7=Z,Z}function BG(){if(!$7)_G();return $7}function jG($=u9){let Z=BG();return`<input type="hidden" name="${$}" value="${Z}">`}function p9($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,J)=>{return jG(J||u9)})}var UG=40,u9="_token",$7=null;var l9=()=>{};async function c9($,Z,Y,J){if(!J.customDirectives||J.customDirectives.length===0)return $;let X=$;for(let Q of J.customDirectives){if(!Q.name||typeof Q.handler!=="function"){if(J.debug)console.warn("Invalid custom directive:",Q);continue}if(Q.hasEndTag)X=await HG(X,Q,Z,Y,J);else X=await OG(X,Q,Z,Y,J)}return X}async function HG($,Z,Y,J,X){let{name:Q,handler:G}=Z,K=`@${Q}`,q=`@end${Q}`,W=$,z=c1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${q}`,"g"),U=[],_=z.exec(W);while(_!==null){let[B,j="",H=""]=_,L=_.index||0;try{let F=j?i9(j):[],O=H.trim(),V=await G(O,F,Y,J);U.push({original:B,processed:V,startIndex:L})}catch(F){let O=F instanceof Error?F.message:String(F);if(X.debug)console.error(`Error processing custom directive @${Q}:`,F);U.push({original:B,processed:r("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${O}`,n.EVALUATION_ERROR),startIndex:L})}_=z.exec(W)}for(let B=U.length-1;B>=0;B--){let{original:j,processed:H}=U[B];W=W.replace(j,H)}return W}async function OG($,Z,Y,J,X){let{name:Q,handler:G}=Z,K=$,q=c1(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),W=[],z=q.exec(K);while(z!==null){let[B,j=""]=z,H=z.index||0;try{let L=i9(j),F=await G("",L,Y,J);W.push({original:B,processed:F,startIndex:H})}catch(L){let F=L instanceof Error?L.message:String(L);if(X.debug)console.error(`Error processing custom directive @${Q}:`,L);W.push({original:B,processed:r("CustomDirective",`Error in @${Q}(${j}): ${F}`,n.EVALUATION_ERROR),startIndex:H})}z=q.exec(K)}let U=c1(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),_=U.exec(K);while(_!==null){let[B]=_,j=_.index||0;try{let H=await G("",[],Y,J);W.push({original:B,processed:H,startIndex:j})}catch(H){let L=H instanceof Error?H.message:String(H);if(X.debug)console.error(`Error processing custom directive @${Q}:`,H);W.push({original:B,processed:r("CustomDirective",`Error in @${Q}: ${L}`,n.EVALUATION_ERROR),startIndex:j})}_=U.exec(K)}for(let B=W.length-1;B>=0;B--){let{original:j,processed:H}=W[B];K=K.replace(j,H)}return K}function i9($){if(!$.trim())return[];let Z=[],Y="",J=!1,X="";for(let Q=0;Q<$.length;Q++){let G=$[Q];if((G==='"'||G==="'")&&(Q===0||$[Q-1]!=="\\"))if(!J)J=!0,X=G;else if(G===X)J=!1;else Y+=G;else if(G===","&&!J)Z.push(Y.trim()),Y="";else Y+=G}if(Y.trim())Z.push(Y.trim());return Z.map((Q)=>{let G=Q.trim();if(G.startsWith('"')&&G.endsWith('"')||G.startsWith("'")&&G.endsWith("'"))return G.substring(1,G.length-1);return G})}var n9=b(()=>{G1();i1()});var Z7={};o(Z7,{useTitle:()=>AG,useSeoMeta:()=>O$,usePageTitle:()=>AG,useHead:()=>S1,resetHead:()=>VG,renderHtmlAttrs:()=>TG,renderHead:()=>RG,renderBodyAttrs:()=>MG,processTitleDirective:()=>EG,processMetaDirective:()=>kG,processHeadDirective:()=>DG,getPageMeta:()=>FG,getHead:()=>M5,definePageMeta:()=>NG,applyHead:()=>IG});function M5(){return B1}function FG(){return H$}function VG(){B1={},LG.length=0,H$={}}function S1($){B1=wG(B1,$)}function wG($,Z){return{title:Z.title??$.title,titleTemplate:Z.titleTemplate??$.titleTemplate,base:Z.base??$.base,meta:[...$.meta||[],...Z.meta||[]],link:[...$.link||[],...Z.link||[]],script:[...$.script||[],...Z.script||[]],style:[...$.style||[],...Z.style||[]],htmlAttrs:{...$.htmlAttrs,...Z.htmlAttrs},bodyAttrs:{...$.bodyAttrs,...Z.bodyAttrs}}}function O$($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let q=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:q})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,J=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(J)Z.push({property:"og:description",content:J});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let X=$.twitterTitle??$.title,Q=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(X)Z.push({name:"twitter:title",content:X});if(Q)Z.push({name:"twitter:description",content:Q});if(G)Z.push({name:"twitter:image",content:G});if($.twitterSite)Z.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)Z.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)Z.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)Z.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)Z.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)Z.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let q of $.articleTags)Z.push({property:"article:tag",content:q});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});S1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function NG($){if(H$={...H$,...$},$.title||$.description)O$({title:$.title,description:$.description})}function AG($){let Z=typeof $==="function"?$():$;S1({title:Z})}function RG($=B1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${b1(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([J,X])=>`${J}="${b1(X)}"`).join(" ");Z.push(`<base ${Y}>`)}for(let Y of $.meta||[]){let J=Object.entries(Y).filter(([X,Q])=>Q!==void 0).map(([X,Q])=>{return`${X==="httpEquiv"?"http-equiv":X}="${b1(String(Q))}"`}).join(" ");Z.push(`<meta ${J}>`)}for(let Y of $.link||[]){let J=Object.entries(Y).filter(([X,Q])=>Q!==void 0).map(([X,Q])=>`${X}="${b1(String(Q))}"`).join(" ");Z.push(`<link ${J}>`)}for(let Y of $.script||[]){let{content:J,...X}=Y,Q=Object.entries(X).filter(([G,K])=>K!==void 0).map(([G,K])=>{if(typeof K==="boolean")return K?G:"";return`${G}="${b1(String(K))}"`}).filter(Boolean).join(" ");if(J)Z.push(`<script ${Q}>${J}</script>`);else Z.push(`<script ${Q}></script>`)}for(let Y of $.style||[]){let J=Y.type?` type="${Y.type}"`:"";Z.push(`<style${J}>${Y.content}</style>`)}return Z.join(`
|
|
1653
1653
|
`)}function TG($=B1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${b1(Y)}"`).join(" ")}function MG($=B1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${b1(Y)}"`).join(" ")}function b1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function IG($=B1){if(typeof document>"u")return;if($.title){let Z=$.title;if($.titleTemplate)Z=typeof $.titleTemplate==="function"?$.titleTemplate(Z):$.titleTemplate.replace("%s",Z);document.title=Z}for(let Z of $.meta||[]){let Y=Z.name?`meta[name="${Z.name}"]`:Z.property?`meta[property="${Z.property}"]`:null;if(Y){let J=document.querySelector(Y);if(!J){if(J=document.createElement("meta"),Z.name)J.setAttribute("name",Z.name);if(Z.property)J.setAttribute("property",Z.property);document.head.appendChild(J)}J.setAttribute("content",Z.content)}}for(let Z of $.link||[]){let Y=`link[rel="${Z.rel}"]${Z.href?`[href="${Z.href}"]`:""}`,J=document.querySelector(Y);if(!J)J=document.createElement("link"),document.head.appendChild(J);for(let[X,Q]of Object.entries(Z))if(Q!==void 0)J.setAttribute(X,String(Q))}if($.htmlAttrs)for(let[Z,Y]of Object.entries($.htmlAttrs))document.documentElement.setAttribute(Z,Y);if($.bodyAttrs)for(let[Z,Y]of Object.entries($.bodyAttrs))document.body.setAttribute(Z,Y)}function DG($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(J,X)=>{return Z+=X.trim()+`
|
|
1654
1654
|
`,""}),headContent:Z.trim()}}function EG($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,J,X,Q)=>{let G=J?X:Z[(Q||"").trim()]??Q;return S1({title:G}),""})}function kG($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,J,X,Q,G,K)=>{let q=Q?G:K,W=Q?q:Z[(q||"").trim()]??q,U=X.includes(":")?{property:X,content:W}:{name:X,content:W};return S1({meta:[U]}),""})}var B1,LG,H$;var I5=b(()=>{B1={},LG=[],H$={}});import bG from"crypto";function M0($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function L$($,Z,Y,J){let X=$||Z;return Y?`${X} ${J}`:X}function SG(){return bG.randomUUID()}function F$($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let J=SG();Z.csrf={token:J}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${M0(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),Y=Y.replace(/@method\(['"]([^'"]+)['"]\)/g,(J,X)=>{let Q=X.toUpperCase();if(X&&!["GET","POST"].includes(Q))return`<input type="hidden" name="_method" value="${M0(Q)}">`;return J}),Y}function r9($,Z,Y=s9){let J=$;return J=J.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(X,Q,G,K,q,W="")=>{let z=Q||G||"POST",U=K||q||"",_=j1(W),B=z.toUpperCase(),j=["GET","POST"].includes(B)?B:"POST",H=`<form method="${M0(j)}" action="${M0(U)}"${_?` ${_}`:""}>`;if(H+=`
|
package/dist/cli.js
CHANGED
|
@@ -1828,7 +1828,7 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
|
|
|
1828
1828
|
@end${K}`;X.push(`Added ${_} missing @end${K}`)}}if(X.length>0&&Z.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),X.forEach((K)=>console.warn(` - ${K}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:Y,fixes:X}},createFallbackContent($,Z){if(f4())return`<!-- ${$} failed: ${Z.message} -->`;return"<!-- stx rendering error -->"}};J1=new g3,z$={isDevelopment(){return f4()},logDetailedError($,Z){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",$.message),console.error("Stack:",$.stack),Z)console.error("Context:",Z);console.error("========================")},createErrorReport($,Z){let Y=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${$.message}`,`Type: ${$.constructor.name}`,`Stack: ${$.stack}`];if(Z)Y.push(`Context: ${JSON.stringify(Z,null,2)}`);return Y.push("========================"),Y.join(`
|
|
1829
1829
|
`)}}});import VJ from"path";function yR($){let Z={"&":"&","<":"<",">":">",'"':""","'":"'"};return $.replace(/[&<>"']/g,(Y)=>Z[Y]||Y)}function s5($,Z={}){let{allowHtml:Y=!1,maxLength:X=1e4,allowSpecialChars:J=!0,customSanitizer:Q}=Z,G=[],K=$,W=!1;if(Q){let _=Q(K);if(_!==K)K=_,W=!0}if(K.includes("\x00"))K=K.replace(/\0/g,""),W=!0,G.push("Null bytes removed from parameter");if(K.length>X)K=K.substring(0,X),W=!0,G.push(`Parameter truncated to ${X} characters`);if(!Y&&/<[^>]+>/.test(K))K=yR(K),W=!0,G.push("HTML content was escaped");let U=[{pattern:/javascript:/gi,replacement:"",name:"javascript: URI"},{pattern:/vbscript:/gi,replacement:"",name:"vbscript: URI"},{pattern:/data:text\/html/gi,replacement:"",name:"data:text/html URI"}];for(let{pattern:_,replacement:z,name:B}of U)if(_.test(K))K=K.replace(_,z),W=!0,G.push(`Removed ${B} from parameter`);if(!J){let _=K;if(K=K.split("").filter((z)=>{let B=z.charCodeAt(0);return B>=32&&B!==127}).join(""),K!==_)W=!0,G.push("Control characters removed")}return{value:K,modified:W,warnings:G}}function z_($,Z){let Y=$.replace(/\0/g,"");Y=Y.replace(/\\/g,"/"),Y=Y.replace(/^[a-z][a-z0-9+.-]*:/i,"");while(Y.includes("../")||Y.includes("./"))Y=Y.replace(/\.\.\//g,"").replace(/\.\//g,"");if(!h3.isValidFilePath(Y,Z))return null;return Y}function B_($){let Z=[],Y=$.trim(),X=Y!==$,J=[{pattern:/\beval\s*\(/gi,name:"eval()"},{pattern:/\bFunction\s*\(/gi,name:"Function()"},{pattern:/\bsetTimeout\s*\(/gi,name:"setTimeout()"},{pattern:/\bsetInterval\s*\(/gi,name:"setInterval()"},{pattern:/\bimport\s*\(/gi,name:"dynamic import()"},{pattern:/\brequire\s*\(/gi,name:"require()"},{pattern:/\b__proto__\b/gi,name:"__proto__"},{pattern:/\bconstructor\b/gi,name:"constructor"},{pattern:/\bprototype\b/gi,name:"prototype"}];for(let{pattern:Q,name:G}of J)if(Q.test(Y))Z.push(`Potentially dangerous pattern detected: ${G}`);if(Y.includes("\x00"))Y=Y.replace(/\0/g,""),X=!0,Z.push("Null bytes removed from expression");return{value:Y,modified:X,warnings:Z}}function q_($,Z={}){return $.map((Y)=>s5(Y,Z))}function FJ($){let Z={};for(let[Y,X]of Object.entries($)){if(!h3.isValidVariableName(Y))continue;if(typeof X==="string"){let J=s5(X);Z[Y]=J.value}else if(Array.isArray(X))Z[Y]=X.map((J)=>typeof J==="string"?s5(J).value:J);else if(typeof X==="object"&&X!==null)Z[Y]=FJ(X);else Z[Y]=X}return Z}var h3;var j_=D(()=>{h3={isValidFilePath($,Z){let Y=$.replace(/\\/g,"/");if(Y.includes("\x00"))return!1;if(Y.includes("../")||Y.includes("..\\")||Y===".."||Y.startsWith("../")||Y.endsWith("/..")||Y.includes("/..\\")||Y.includes("\\../"))return!1;if(/^[a-z][a-z0-9+.-]*:/i.test(Y))return!1;if(Y.startsWith("/")){if(["/etc/","/root/","/var/","/usr/","/bin/","/sbin/","/proc/","/sys/","/dev/","/boot/","/home/","/private/","/Library/","/System/"].some((Q)=>Y===Q.slice(0,-1)||Y.startsWith(Q)))return!1}if(/^[a-z]:/i.test(Y)){if(["Windows/","Windows\\","System32/","System32\\","Program Files/","Program Files\\"].some((Q)=>Y.includes(Q)))return!1}if(Z){let J=VJ.resolve(Z,$),Q=VJ.resolve(Z);if(!J.startsWith(Q+VJ.sep)&&J!==Q)return!1}return!0},isValidVariableName($){return/^[a-z_$]\w*$/i.test($)},isValidDirectiveName($){return/^[a-z][\w-]*$/i.test($)},isSafeContent($){return![/<script[^>]*>[\s\S]*?<\/script>/i,/javascript:/i,/data:text\/html/i,/vbscript:/i,/on\w+\s*=/i].some((Y)=>Y.test($))}}});var H_=D(()=>{y3();U_();__();j_();x3()});var R1=D(()=>{H_()});class o5{source;pos=0;line=1;column=0;tokens=[];constructor($){this.source=$}tokenize(){this.tokens=[],this.pos=0,this.line=1,this.column=0;while(this.pos<this.source.length){let $=this.nextToken();if($)this.tokens.push($)}return this.tokens.push({type:"EOF",value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),this.tokens}nextToken(){if(this.pos>=this.source.length)return null;let $=this.pos,Z=this.line,Y=this.column,X=this.source[this.pos];if(/\s/.test(X))return this.readWhitespace($,Z,Y);if(X==="/"&&this.peek(1)==="/")return this.readLineComment($,Z,Y);if(X==="/"&&this.peek(1)==="*")return this.readBlockComment($,Z,Y);if(X==='"'||X==="'")return this.readString(X,$,Z,Y);if(X==="`")return this.readTemplateString($,Z,Y);if(/\d/.test(X)||X==="."&&/\d/.test(this.peek(1)||""))return this.readNumber($,Z,Y);if(/[a-z_$]/i.test(X))return this.readIdentifier($,Z,Y);if(X==="{"){if(this.peek(1)==="{"&&this.peek(2)==="{")return this.advance(3),{type:"RAW_START",value:"{{{",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="{")return this.advance(2),{type:"EXPRESSION_START",value:"{{",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="!"&&this.peek(2)==="!")return this.advance(3),{type:"RAW_START",value:"{!!",start:$,end:this.pos,line:Z,column:Y}}if(X==="}"){if(this.peek(1)==="}"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"}}}",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="}")return this.advance(2),{type:"EXPRESSION_END",value:"}}",start:$,end:this.pos,line:Z,column:Y}}if(X==="!"&&this.peek(1)==="!"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"!!}",start:$,end:this.pos,line:Z,column:Y};if(X==="@"&&/[a-z]/i.test(this.peek(1)||""))return this.readDirective($,Z,Y);let J=["===","!==","==","!=","<=",">=","&&","||","??","++","--","+=","-=","*=","/=","%=","**","=>","?.","...","<<",">>",">>>","&=","|=","^="];for(let Q of J)if(this.source.slice(this.pos,this.pos+Q.length)===Q)return this.advance(Q.length),{type:"OPERATOR",value:Q,start:$,end:this.pos,line:Z,column:Y};if(/[+\-*/%<>=!&|^~?:]/.test(X))return this.advance(),{type:"OPERATOR",value:X,start:$,end:this.pos,line:Z,column:Y};if(/[()[\]{},;.]/.test(X))return this.advance(),{type:"PUNCTUATION",value:X,start:$,end:this.pos,line:Z,column:Y};return this.advance(),{type:"PUNCTUATION",value:X,start:$,end:this.pos,line:Z,column:Y}}readWhitespace($,Z,Y){while(this.pos<this.source.length&&/\s/.test(this.source[this.pos]))this.advance();return{type:"WHITESPACE",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readLineComment($,Z,Y){this.advance(2);while(this.pos<this.source.length&&this.source[this.pos]!==`
|
|
1830
1830
|
`)this.advance();return{type:"COMMENT",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readBlockComment($,Z,Y){this.advance(2);while(this.pos<this.source.length-1){if(this.source[this.pos]==="*"&&this.source[this.pos+1]==="/"){this.advance(2);break}this.advance()}return{type:"COMMENT",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readString($,Z,Y,X){this.advance();while(this.pos<this.source.length){let J=this.source[this.pos];if(J==="\\"){this.advance(2);continue}if(J===$){this.advance();break}this.advance()}return{type:"STRING",value:this.source.slice(Z,this.pos),start:Z,end:this.pos,line:Y,column:X}}readTemplateString($,Z,Y){this.advance();let X=0,J=256;while(this.pos<this.source.length){let Q=this.source[this.pos];if(Q==="\\"){this.advance(2);continue}if(Q==="$"&&this.peek(1)==="{"){if(X>=J){this.pos=this.source.length;break}this.advance(2),X++;continue}if(Q==="{"&&X>0){X++,this.advance();continue}if(Q==="}"&&X>0){X--,this.advance();continue}if(Q==="`"&&X===0){this.advance();break}this.advance()}return{type:"TEMPLATE_STRING",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readNumber($,Z,Y){if(this.source[this.pos]==="0"){let X=this.peek(1)?.toLowerCase();if(X==="x"||X==="o"||X==="b"){this.advance(2);while(this.pos<this.source.length&&/[\da-f_]/i.test(this.source[this.pos]))this.advance();return{type:"NUMBER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}}while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance();if(this.source[this.pos]==="."&&/\d/.test(this.peek(1)||"")){this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(/e/i.test(this.source[this.pos]||"")){if(this.advance(),/[+-]/.test(this.source[this.pos]||""))this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(this.source[this.pos]==="n")this.advance();return{type:"NUMBER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readIdentifier($,Z,Y){while(this.pos<this.source.length&&/[\w$]/.test(this.source[this.pos]))this.advance();return{type:"IDENTIFIER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readDirective($,Z,Y){this.advance();while(this.pos<this.source.length&&/[a-z]/i.test(this.source[this.pos]))this.advance();return{type:"DIRECTIVE",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}advance($=1){for(let Z=0;Z<$&&this.pos<this.source.length;Z++){if(this.source[this.pos]===`
|
|
1831
|
-
`)this.line++,this.column=0;else this.column++;this.pos++}}peek($){return this.source[this.pos+$]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState($){this.pos=$.pos,this.line=$.line,this.column=$.column}}function u0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,W=!1;while(Q<$.length){let U=$[Q];if(G&&W){W=!1,Q++;continue}if(G&&U==="\\"){W=!0,Q++;continue}if(W=!1,(U==='"'||U==="'"||U==="`")&&!G){G=U,Q++;continue}if(U===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&U==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&U==="}"){K--,Q++;continue}if(U==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(U===Z)J++;else if(U===Y){if(J--,J===0)return Q}Q++}return-1}function AJ($,Z){let Y=Z,X={paren:0,bracket:0,brace:0},J=null,Q=0;while(Y<$.length){let G=$[Y];if((Y>0?$[Y-1]:"")==="\\"&&J){Y++;continue}if((G==='"'||G==="'")&&!J){J=G,Y++;continue}if(G===J&&J!=="`"){J=null,Y++;continue}if(G==="`"&&!J){J="`",Y++;continue}if(G==="`"&&J==="`"&&Q===0){J=null,Y++;continue}if(J==="`"&&G==="$"&&$[Y+1]==="{"){Q++,Y+=2;continue}if(Q>0){if(G==="{")Q++;else if(G==="}")Q--;Y++;continue}if(J){Y++;continue}if(X.paren===0&&X.bracket===0&&X.brace===0){if($.slice(Y,Y+2)==="}}"||$.slice(Y,Y+3)==="!!}")break;if(G===","||G===";")break}if(G==="(")X.paren++;else if(G===")"){if(X.paren--,X.paren<0)break}else if(G==="[")X.bracket++;else if(G==="]"){if(X.bracket--,X.bracket<0)break}else if(G==="{")X.brace++;else if(G==="}"){if(X.brace--,X.brace<0)break}Y++}return{expression:$.slice(Z,Y),endPos:Y}}function d3($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+=K+$[G+1],G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K==="|"&&$[G+1]!=="|"&&(G===0||$[G-1]!=="|")&&$[G-1]!=="\\"&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}if(K==="|"&&$[G-1]==="\\"&&!J){Y=Y.slice(0,-1)+K;continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function z4($,Z){let Y=xR($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function xR($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=u0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function h4($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),_=W?W.index:1/0,z=U?U.index:1/0;if(_<z)J++,Q=_+W[0].length;else if(z<1/0){if(J--,J===0)return z;Q=z+U[0].length}else break}return-1}function NJ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=z4($,X);if(!J)return null;let Q=J.endPos,G=h4($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_="if",z=J.expression,B=0,q=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){q++,U++;continue}if(/^@endif(?![a-z])/.test(H)){q--,U+=6;continue}if(q===0){let O=H.match(/^@elseif\s*/);if(O){W.push({type:_,condition:z,content:K.substring(B,U),start:Q+B,end:Q+U});let V=U+O[0].length,L=z4(K,V);if(!L){U++;continue}_="elseif",z=L.expression,U=L.endPos,B=U;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:_,condition:z,content:K.substring(B,U),start:Q+B,end:Q+U}),_="else",z=void 0,U+=5,B=U;continue}}U++}return W.push({type:_,condition:z,content:K.slice(B),start:Q+B,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function B$($){let Z=[],Y=/@if\s*\(/g,X=Y.exec($);while(X!==null){if(Z.some((G)=>X.index>G.start&&X.index<G.end)){X=Y.exec($);continue}let Q=NJ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function t5($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,W=K+Q[0].length-1,U=u0($,"(",")",W);if(U===-1){Q=J.exec($);continue}let _=$.slice(W+1,U),z=U+1,B=h4($,Z,Y,z);if(B===-1){Q=J.exec($);continue}let q=$.slice(z,B),j=B+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:_,content:q,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function u3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=z4($,X);if(!J)return null;let Q=J.endPos,G=h4($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_=null,z=0;while(U<K.length){let B=K.slice(U),q=B.match(/^@switch\s*\(/),j=B.match(/^@endswitch(?![a-z])/);if(q){if(z++,_)_.content+=q[0];U+=q[0].length;continue}if(j){if(z--,_)_.content+=j[0];U+=j[0].length;continue}if(z>0){if(_)_.content+=K[U];U++;continue}let H=B.match(/^@case\s*/),O=B.match(/^@default(?![a-z])/),V=B.match(/^@break(?![a-z])/);if(H&&B.startsWith("@case")){if(_)W.push(_);let L=U+H[0].length,F=z4(K,L);if(!F){U++;continue}_={type:"case",value:F.expression,content:""},U=F.endPos}else if(O&&B.startsWith("@default")){if(_)W.push(_);_={type:"default",content:""},U+=O[0].length}else if(V&&B.startsWith("@break"))U+=V[0].length;else{if(_)_.content+=K[U];U++}}if(_)W.push(_);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:W,start:Z,end:G+10}}var O_=()=>{};function F_($){let Z=[],Y=0;while(Y<$.length){let X=$.indexOf("{{",Y),J=$.indexOf("{!!",Y),Q=!1,G;if(X===-1&&J===-1)break;else if(X===-1)G=J,Q=!0;else if(J===-1)G=X,Q=!1;else if(J<X)G=J,Q=!0;else G=X,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",W=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,_=vR($,U,W);if(_===-1){Y=G+1;continue}let z=$.slice(U,_).trim(),B=_+W.length;Z.push({fullMatch:$.slice(G,B),expression:z,start:G,end:B,isRaw:Q}),Y=B}return Z}function vR($,Z,Y){let X=Z,J=null,Q={paren:0,bracket:0,brace:0},G=0;while(X<$.length){let K=$[X];if((X>0?$[X-1]:"")==="\\"&&J){X++;continue}if((K==='"'||K==="'")&&!J){J=K,X++;continue}if(K===J&&J!=="`"){J=null,X++;continue}if(K==="`"&&!J){J="`",X++;continue}if(K==="`"&&J==="`"&&G===0){J=null,X++;continue}if(J==="`"&&K==="$"&&$[X+1]==="{"){G++,X+=2;continue}if(G>0){if(K==="{")G++;else if(K==="}")G--;X++;continue}if(J){X++;continue}if(K==="(")Q.paren++;else if(K===")")Q.paren--;else if(K==="[")Q.bracket++;else if(K==="]")Q.bracket--;else if(K==="{")Q.brace++;else if(K==="}")Q.brace--;if(Q.paren===0&&Q.bracket===0&&Q.brace<=0){if($.slice(X,X+Y.length)===Y)return X}X++}return-1}function A_($){let Z=d3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=fR(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function fR($){let Z=$.trim();if(!Z)return null;let Y=Z.indexOf("(");if(Y===-1)return{name:Z,args:[]};let X=Z.slice(0,Y).trim(),J=Y+1,Q=u0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=wJ(G);return{name:X,args:K}}function wJ($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+="${",G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K===","&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function N_($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=u0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function w_($){let Z=[],X=new o5($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let z=J<X.length?X[J].start:$.length,B=L_(X,J,$);J=B.nextIndex,Z.push({type:"variable",name:_,value:$.slice(z,B.endPos),exported:G,start:K.start,end:B.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let _=U.start,z=U.value==="{"?"}":"]",B=u0($,U.value,z,_);if(B!==-1){let q=$.slice(_,B+1);if(J=V_(X,B+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=L_(X,J,$);J=H.nextIndex;let O=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:O,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${O}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;J++;let z=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){z=X[J].start;break}J++}if(z!==-1){let B=u0($,"{","}",z);if(B!==-1)Z.push({type:"function",name:_,value:$.slice(W,B+1).replace(/^export\s+/,""),exported:G,start:W,end:B+1}),J=V_(X,B+1)}}}else J++}return Z}function L_($,Z,Y){let X=Z,J={paren:0,bracket:0,brace:0},Q=Z<$.length?$[Z].start:Y.length;while(X<$.length){let G=$[X];if(G.type==="PUNCTUATION"){if(G.value==="(")J.paren++;else if(G.value===")")J.paren--;else if(G.value==="[")J.bracket++;else if(G.value==="]")J.bracket--;else if(G.value==="{")J.brace++;else if(G.value==="}")J.brace--;if(G.value===";"&&J.paren===0&&J.bracket===0&&J.brace===0){Q=G.start,X++;break}}if(G.type==="IDENTIFIER"&&(G.value==="const"||G.value==="let"||G.value==="var"||G.value==="function"||G.value==="export")){if(J.paren===0&&J.bracket===0&&J.brace===0){Q=$[X-1]?.end??G.start;break}}Q=G.end,X++}return{nextIndex:X,endPos:Q}}function V_($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var R_=()=>{};var e5=D(()=>{O_();R_()});function gR($,Z,Y){let X=$,J=!0;while(J){J=!1;let Q=X.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=u3(X,G);if(!K)break;try{let W;if(N0(K.expression))W=w0(K.expression,Object.keys(Z))(...Object.values(Z));else W=L0(K.expression,Z);let U="",_=!1;for(let z of K.cases)if(z.type==="default"){if(!_)U=z.content.trim()}else try{let B;if(z.value&&N0(z.value))B=w0(z.value,Object.keys(Z))(...Object.values(Z));else if(z.value)B=L0(z.value,Z);if(W===B){U=z.content.trim(),_=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(W){let U=W instanceof Error?W.message:String(W),_=U0("Switch",`Error evaluating @switch expression: ${U}`,J0.EVALUATION_ERROR);X=X.substring(0,G)+_+X.substring(K.end);break}}return X}function M6($,Z,Y){let X=$;X=gR(X,Z,Y);{let Q=!0;while(Q){Q=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=z4(X,K+7);if(!W)break;let U=W.endPos,_=h4(X,"unless","endunless",U);if(_===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let z=X.slice(U,_),B=W.expression,q=-1;{let H=0,O=/@(?:if|unless)\s*\(/g,V=/@(?:endif|endunless)(?![a-z])/g,L=/@else(?![a-z])/g,F=[],A;while((A=O.exec(z))!==null)F.push({pos:A.index,type:"open"});while((A=V.exec(z))!==null)F.push({pos:A.index,type:"close"});while((A=L.exec(z))!==null)F.push({pos:A.index,type:"else"});F.sort((N,w)=>N.pos-w.pos);for(let N of F)if(N.type==="open")H++;else if(N.type==="close")H--;else if(N.type==="else"&&H===0){q=N.pos;break}}let j;if(q!==-1){let H=z.slice(0,q),O=z.slice(q+5);j=`@if (${B})${O}@else ${H}@endif`}else j=`@if (!(${B}))${z}@endif`;X=X.substring(0,K)+j+X.substring(_+10),Q=!0}}X=MJ(X,Z,Y),X=TJ(X,Z,Y),X=RJ(X,Z);let J=()=>{let Q=B$(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let W="",U=!1;for(let _ of K.branches){if(U)break;if(_.type==="else")W=_.content,U=!0;else try{let z;if(_.condition&&N0(_.condition))z=w0(_.condition,Object.keys(Z))(...Object.values(Z));else if(_.condition)z=L0(_.condition,Z);if(z)W=_.content,U=!0}catch(z){W=U0(_.type==="if"?"If":"Elseif",`Error in @${_.type}(${_.condition}): ${z instanceof Error?z.message:String(z)}`,J0.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+W+X.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),_=U0("If",`Error processing @if block: ${U}`,J0.EVALUATION_ERROR);X=X.substring(0,K.start)+_+X.substring(K.end)}}return!0};while(J());return X}function M_($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let Y=$[Z];if(Y!=="'"&&Y!=='"')return null;Z++;let X=[];while(Z<$.length){let J=$[Z];if(J==="\\"&&Z+1<$.length){X.push($[Z+1]),Z+=2;continue}if(J===Y){Z++;break}X.push(J),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:X.join(""),consumed:Z}}function RJ($,Z){let Y=$;function X(K,W,U,_){let z=1,B=_,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(B<K.length&&z>0){q.lastIndex=B,j.lastIndex=B;let H=q.exec(K),O=j.exec(K),V=H?H.index:1/0,L=O?O.index:1/0;if(V<L)z++,B=V+H[0].length;else if(L<1/0){if(z--,z===0)return L;B=L+O[0].length}else break}return-1}function J(K,W,U){let _=0,z=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),B=new RegExp(`@${U}(?![a-z])`,"g"),q=/@else(?![a-z])/g,j=[],H;while((H=z.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=q.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((O,V)=>O.pos-V.pos);for(let O of j)if(O.type==="open")_++;else if(O.type==="close")_--;else if(O.type==="else"&&_===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,z,B=Y.slice(U+5),q=M_(B);if(q)_=q.value,z=U+5+q.consumed;else z=U+5;let j=X(Y,"auth","endauth",z);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(z,j),O=J(H,"auth","endauth"),V;if(!Z.auth)V=!1;else V=_?_4(`auth?.check && auth?.user?.[${_}]`,Z):_4("auth?.check",Z);let L;if(O!==-1){let F=H.slice(0,O),A=H.slice(O+5);L=V?F:A}else L=V?H:"";Y=Y.substring(0,U)+L+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,z,B=Y.slice(U+6),q=M_(B);if(q)_=q.value,z=U+6+q.consumed;else z=U+6;let j=X(Y,"guest","endguest",z);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(z,j),O=J(H,"guest","endguest"),V;if(!Z.auth)V=!0;else V=_?_4(`!auth?.check || !auth?.user?.[${_}]`,Z):_4("!auth?.check",Z);let L;if(O!==-1){let F=H.slice(0,O),A=H.slice(O+5);L=V?F:A}else L=V?H:"";Y=Y.substring(0,U)+L+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let _=[K];if(W)_.push(W);if(U){let z=_4(U,Z);_.push(z)}return Z.permissions.check(..._)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,U=K==="can"?"elsecan":"elsecannot",_=!0;while(_){_=!1;let z=Y.match(new RegExp(`@${K}\\s*\\(`));if(!z||z.index===void 0)break;let B=z.index,q=Y.slice(B+`@${K}`.length),j=G(q);if(!j)break;let H=B+`@${K}`.length+j.paramsEnd,O=X(Y,K,W,H);if(O===-1){console.warn(`[stx] @${K} directive at position ${B} has no matching @${W} \u2014 the block was skipped.`);break}let V=Y.slice(H,O),L=[],F=0,A=new RegExp(`@${K}\\s*\\(`,"g"),N=new RegExp(`@${W}(?![a-z])`,"g"),w=new RegExp(`@${U}\\s*\\(`,"g"),R=/@else(?![a-z])/g,M=[],E;while((E=A.exec(V))!==null)M.push({pos:E.index,type:"open"});while((E=N.exec(V))!==null)M.push({pos:E.index,type:"close"});while((E=w.exec(V))!==null)M.push({pos:E.index,type:"elseDirective"});while((E=R.exec(V))!==null)M.push({pos:E.index,type:"else"});M.sort((C,g)=>C.pos-g.pos);for(let C of M){if(C.type==="open"){F++;continue}if(C.type==="close"){F--;continue}if(F===0)L.push(C)}let I=[],S=0;for(let C=0;C<L.length;C++){let g=L[C];if(I.push({content:V.slice(S,g.pos),ability:void 0}),g.type==="elseDirective"){let s=V.slice(g.pos+`@${U}`.length),m=G(s);if(m){I[I.length-1]={content:V.slice(S,g.pos)},S=g.pos+`@${U}`.length+m.paramsEnd,I.push({content:"",ability:m.ability,type:m.type,id:m.id}),I.pop();let b=L[C+1],d=b?b.pos:V.length;I.push({content:V.slice(S,d),ability:m.ability,type:m.type,id:m.id}),S=d}}else S=g.pos+5}if(S<V.length){let C=I[I.length-1];if(L.length>0&&L[L.length-1].type==="else")I.push({content:V.slice(S),isFinalElse:!0});else if(I.length===0)I.push({content:V.slice(S)})}let k=Q(j.ability,j.type,j.id),y=K==="can"?k:!k,P="";if(y)P=I[0]?.content||"";else{let C=!1;for(let g=1;g<I.length;g++){let s=I[g];if(s.isFinalElse){P=s.content,C=!0;break}if(s.ability){let m=Q(s.ability,s.type,s.id);if(K==="can"?m:!m){P=s.content,C=!0;break}}}if(!C&&I.length>0){let g=I[I.length-1];if(g.isFinalElse)P=g.content}}Y=Y.substring(0,B)+P+Y.substring(O+`@${W}`.length),_=!0}}return Y}function MJ($,Z,Y){let X=$;function J(Q,G,K,W,U){let _=!0;while(_){_=!1;let z=new RegExp(`@${G}\\s*\\(`),B=Q.match(z);if(!B||B.index===void 0)break;let q=B.index,j=z4(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,O=h4(Q,G,K,H);if(O===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let V=Q.slice(H,O),L=j.expression,F=-1,A=0,N=0;while(N<V.length){let w=V.indexOf("@",N);if(w===-1)break;let R=V.substring(w);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){A++,N=w+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){A--,N=w+1;continue}if(A===0&&/^@else(?![a-z])/.test(R)){F=w;break}N=w+1}try{let w=W(L.trim()),R;if(F!==-1){let M=V.slice(0,F),E=V.slice(F+5);R=w?M:E}else R=w?V:"";Q=Q.substring(0,q)+R+Q.substring(O+`@${K}`.length),_=!0}catch(w){let R=w instanceof Error?w.message:String(w),M=U0(U,`Error processing @${G} directive: ${R}`,J0.EVALUATION_ERROR);Q=Q.substring(0,q)+M+Q.substring(O+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=_4(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=_4(Q,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),X}function TJ($,Z,Y){let X=$,J="development";function Q(G,K,W,U){let _=new RegExp(`@${K}(?![a-z])`,"g"),z=new RegExp(`@${W}(?![a-z])`,"g"),B=new RegExp(`^@${K}(?![a-z])`),q=new RegExp(`^@${W}(?![a-z])`),j=G,H=!0;while(H){H=!1,_.lastIndex=0;let O=_.exec(j);if(!O)break;let V=O.index,L=V+O[0].length;if(K==="env"){let k=j.substring(L).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!k)break;L+=k[0].length,U=J===k[2]}let F=1,A=L,N=-1;while(F>0&&A<j.length){_.lastIndex=A,z.lastIndex=A;let k=_.exec(j),y=z.exec(j),P=k?k.index:1/0,C=y?y.index:1/0;if(P<C)F++,A=P+k[0].length;else if(C<1/0){if(F--,F===0){N=C;break}A=C+y[0].length}else break}if(N===-1){console.warn(`[stx] @${K} directive at position ${V} has no matching @${W} \u2014 the block was skipped.`);break}let w=j.substring(L,N),R=-1,M=0,E=0;while(E<w.length){let k=w.indexOf("@",E);if(k===-1)break;let y=w.substring(k);if(B.test(y)){M++,E=k+1;continue}if(q.test(y)){M--,E=k+1;continue}if(M===0&&/^@else(?![a-z])/.test(y)){R=k;break}E=k+1}let I;if(R!==-1){let k=w.slice(0,R),y=w.slice(R+5);I=U?k:y}else I=U?w:"";let S=`@${W}`.length;j=j.substring(0,V)+I+j.substring(N+S),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var m3=D(()=>{jJ();R1();e5();p0()});function IJ($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function d4($,Z){if(!$)return Z?.nonceGenerator?.()??IJ();let Y=EJ.get($);if(!Y)Y=Z?.nonceGenerator?.()??IJ(),EJ.set($,Y);return Y}function hR($){EJ.delete($)}function DJ($,Z){let Y=[];for(let[X,J]of Object.entries($)){if(J===void 0||J===null)continue;if(typeof J==="boolean"){if(J)Y.push(X);continue}if(Array.isArray(J)){let Q=[...J];if(Z&&(X==="script-src"||X==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)Y.push(`${X} ${Q.join(" ")}`)}}return Y.join("; ")}function l3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${DJ($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function dR($){return{enabled:!0,directives:{strict:T_,moderate:c3,relaxed:E_,api:I_}[$]||c3,useNonce:$==="strict",addMetaTag:!0}}function uR($,Z){let Y={...$};for(let[X,J]of Object.entries(Z)){let Q=X,G=Y[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")Y[Q]=G||J;else if(Array.isArray(J)){let K=Array.isArray(G)?G:[],W=[...new Set([...K,...J])];Y[Q]=W}}return Y}function kJ($,Z,Y){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let X=Z.useNonce?d4(Y,Z):void 0,J=l3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
1831
|
+
`)this.line++,this.column=0;else this.column++;this.pos++}}peek($){return this.source[this.pos+$]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState($){this.pos=$.pos,this.line=$.line,this.column=$.column}}function u0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,W=!1;while(Q<$.length){let U=$[Q];if(G&&W){W=!1,Q++;continue}if(G&&U==="\\"){W=!0,Q++;continue}if(W=!1,(U==='"'||U==="'"||U==="`")&&!G){G=U,Q++;continue}if(U===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&U==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&U==="}"){K--,Q++;continue}if(U==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(U===Z)J++;else if(U===Y){if(J--,J===0)return Q}Q++}return-1}function AJ($,Z){let Y=Z,X={paren:0,bracket:0,brace:0},J=null,Q=0;while(Y<$.length){let G=$[Y];if((Y>0?$[Y-1]:"")==="\\"&&J){Y++;continue}if((G==='"'||G==="'")&&!J){J=G,Y++;continue}if(G===J&&J!=="`"){J=null,Y++;continue}if(G==="`"&&!J){J="`",Y++;continue}if(G==="`"&&J==="`"&&Q===0){J=null,Y++;continue}if(J==="`"&&G==="$"&&$[Y+1]==="{"){Q++,Y+=2;continue}if(Q>0){if(G==="{")Q++;else if(G==="}")Q--;Y++;continue}if(J){Y++;continue}if(X.paren===0&&X.bracket===0&&X.brace===0){if($.slice(Y,Y+2)==="}}"||$.slice(Y,Y+3)==="!!}")break;if(G===","||G===";")break}if(G==="(")X.paren++;else if(G===")"){if(X.paren--,X.paren<0)break}else if(G==="[")X.bracket++;else if(G==="]"){if(X.bracket--,X.bracket<0)break}else if(G==="{")X.brace++;else if(G==="}"){if(X.brace--,X.brace<0)break}Y++}return{expression:$.slice(Z,Y),endPos:Y}}function d3($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+=K+$[G+1],G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K==="|"&&$[G+1]!=="|"&&(G===0||$[G-1]!=="|")&&$[G-1]!=="\\"&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}if(K==="|"&&$[G-1]==="\\"&&!J){Y=Y.slice(0,-1)+K;continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function z4($,Z){let Y=xR($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function xR($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=u0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function h4($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),_=W?W.index:1/0,z=U?U.index:1/0;if(_<z)J++,Q=_+W[0].length;else if(z<1/0){if(J--,J===0)return z;Q=z+U[0].length}else break}return-1}function NJ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=z4($,X);if(!J)return null;let Q=J.endPos,G=h4($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_="if",z=J.expression,B=0,q=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){q++,U++;continue}if(/^@endif(?![a-z])/.test(H)){q--,U+=6;continue}if(q===0){let O=H.match(/^@elseif\s*/);if(O){W.push({type:_,condition:z,content:K.substring(B,U),start:Q+B,end:Q+U});let V=U+O[0].length,L=z4(K,V);if(!L){U++;continue}_="elseif",z=L.expression,U=L.endPos,B=U;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:_,condition:z,content:K.substring(B,U),start:Q+B,end:Q+U}),_="else",z=void 0,U+=5,B=U;continue}}U++}return W.push({type:_,condition:z,content:K.slice(B),start:Q+B,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function B$($){let Z=[],Y=/@if\s*\(/g,X=Y.exec($);while(X!==null){if(Z.some((G)=>X.index>G.start&&X.index<G.end)){X=Y.exec($);continue}let Q=NJ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function t5($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,W=K+Q[0].length-1,U=u0($,"(",")",W);if(U===-1){Q=J.exec($);continue}let _=$.slice(W+1,U),z=U+1,B=h4($,Z,Y,z);if(B===-1){Q=J.exec($);continue}let q=$.slice(z,B),j=B+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:_,content:q,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function u3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=z4($,X);if(!J)return null;let Q=J.endPos,G=h4($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_=null,z=0;while(U<K.length){let B=K.slice(U),q=B.match(/^@switch\s*\(/),j=B.match(/^@endswitch(?![a-z])/);if(q){if(z++,_)_.content+=q[0];U+=q[0].length;continue}if(j){if(z--,_)_.content+=j[0];U+=j[0].length;continue}if(z>0){if(_)_.content+=K[U];U++;continue}let H=B.match(/^@case\s*/),O=B.match(/^@default(?![a-z])/),V=B.match(/^@break(?![a-z])/);if(H&&B.startsWith("@case")){if(_)W.push(_);let L=U+H[0].length,F=z4(K,L);if(!F){U++;continue}_={type:"case",value:F.expression,content:""},U=F.endPos}else if(O&&B.startsWith("@default")){if(_)W.push(_);_={type:"default",content:""},U+=O[0].length}else if(V&&B.startsWith("@break"))U+=V[0].length;else{if(_)_.content+=K[U];U++}}if(_)W.push(_);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:W,start:Z,end:G+10}}var O_=()=>{};function F_($){let Z=[],Y=0;while(Y<$.length){let X=$.indexOf("{{",Y),J=$.indexOf("{!!",Y),Q=!1,G;if(X===-1&&J===-1)break;else if(X===-1)G=J,Q=!0;else if(J===-1)G=X,Q=!1;else if(J<X)G=J,Q=!0;else G=X,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",W=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,_=vR($,U,W);if(_===-1){Y=G+1;continue}let z=$.slice(U,_).trim(),B=_+W.length;Z.push({fullMatch:$.slice(G,B),expression:z,start:G,end:B,isRaw:Q}),Y=B}return Z}function vR($,Z,Y){let X=Z,J=null,Q={paren:0,bracket:0,brace:0},G=0;while(X<$.length){let K=$[X];if((X>0?$[X-1]:"")==="\\"&&J){X++;continue}if((K==='"'||K==="'")&&!J){J=K,X++;continue}if(K===J&&J!=="`"){J=null,X++;continue}if(K==="`"&&!J){J="`",X++;continue}if(K==="`"&&J==="`"&&G===0){J=null,X++;continue}if(J==="`"&&K==="$"&&$[X+1]==="{"){G++,X+=2;continue}if(G>0){if(K==="{")G++;else if(K==="}")G--;X++;continue}if(J){X++;continue}if(K==="(")Q.paren++;else if(K===")")Q.paren--;else if(K==="[")Q.bracket++;else if(K==="]")Q.bracket--;else if(K==="{")Q.brace++;else if(K==="}")Q.brace--;if(Q.paren===0&&Q.bracket===0&&Q.brace<=0){if($.slice(X,X+Y.length)===Y)return X}X++}return-1}function A_($){let Z=d3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=fR(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function fR($){let Z=$.trim();if(!Z)return null;let Y=Z.indexOf("(");if(Y===-1)return{name:Z,args:[]};let X=Z.slice(0,Y).trim(),J=Y+1,Q=u0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=wJ(G);return{name:X,args:K}}function wJ($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+="${",G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K===","&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function N_($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=u0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function w_($){let Z=[],X=new o5($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let z=J<X.length?X[J].start:$.length,B=L_(X,J,$);J=B.nextIndex,Z.push({type:"variable",name:_,value:$.slice(z,B.endPos),exported:G,start:K.start,end:B.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let _=U.start,z=U.value==="{"?"}":"]",B=u0($,U.value,z,_);if(B!==-1){let q=$.slice(_,B+1);if(J=V_(X,B+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=L_(X,J,$);J=H.nextIndex;let O=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:O,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${O}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;J++;let z=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){z=X[J].start;break}J++}if(z!==-1){let B=u0($,"{","}",z);if(B!==-1)Z.push({type:"function",name:_,value:$.slice(W,B+1).replace(/^export\s+/,""),exported:G,start:W,end:B+1}),J=V_(X,B+1)}}}else J++}return Z}function L_($,Z,Y){let X=Z,J={paren:0,bracket:0,brace:0},Q=Z<$.length?$[Z].start:Y.length;while(X<$.length){let G=$[X];if(G.type==="PUNCTUATION"){if(G.value==="(")J.paren++;else if(G.value===")")J.paren--;else if(G.value==="[")J.bracket++;else if(G.value==="]")J.bracket--;else if(G.value==="{")J.brace++;else if(G.value==="}")J.brace--;if(G.value===";"&&J.paren===0&&J.bracket===0&&J.brace===0){Q=G.start,X++;break}}if(G.type==="IDENTIFIER"&&(G.value==="const"||G.value==="let"||G.value==="var"||G.value==="function"||G.value==="export")){if(J.paren===0&&J.bracket===0&&J.brace===0){Q=$[X-1]?.end??G.start;break}}Q=G.end,X++}return{nextIndex:X,endPos:Q}}function V_($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var R_=()=>{};var e5=D(()=>{O_();R_()});function gR($,Z,Y){let X=$,J=!0;while(J){J=!1;let Q=X.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=u3(X,G);if(!K)break;try{let W;if(N0(K.expression))W=w0(K.expression,Object.keys(Z))(...Object.values(Z));else W=L0(K.expression,Z);let U="",_=!1;for(let z of K.cases)if(z.type==="default"){if(!_)U=z.content.trim()}else try{let B;if(z.value&&N0(z.value))B=w0(z.value,Object.keys(Z))(...Object.values(Z));else if(z.value)B=L0(z.value,Z);if(W===B){U=z.content.trim(),_=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(W){let U=W instanceof Error?W.message:String(W),_=U0("Switch",`Error evaluating @switch expression: ${U}`,J0.EVALUATION_ERROR);X=X.substring(0,G)+_+X.substring(K.end);break}}return X}function M6($,Z,Y){let X=$;X=gR(X,Z,Y);{let Q=!0;while(Q){Q=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=z4(X,K+7);if(!W)break;let U=W.endPos,_=h4(X,"unless","endunless",U);if(_===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let z=X.slice(U,_),B=W.expression,q=-1;{let H=0,O=/@(?:if|unless)\s*\(/g,V=/@(?:endif|endunless)(?![a-z])/g,L=/@else(?![a-z])/g,F=[],A;while((A=O.exec(z))!==null)F.push({pos:A.index,type:"open"});while((A=V.exec(z))!==null)F.push({pos:A.index,type:"close"});while((A=L.exec(z))!==null)F.push({pos:A.index,type:"else"});F.sort((N,w)=>N.pos-w.pos);for(let N of F)if(N.type==="open")H++;else if(N.type==="close")H--;else if(N.type==="else"&&H===0){q=N.pos;break}}let j;if(q!==-1){let H=z.slice(0,q),O=z.slice(q+5);j=`@if (${B})${O}@else ${H}@endif`}else j=`@if (!(${B}))${z}@endif`;X=X.substring(0,K)+j+X.substring(_+10),Q=!0}}X=MJ(X,Z,Y),X=TJ(X,Z,Y),X=RJ(X,Z);let J=()=>{let Q=B$(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let W="",U=!1;for(let _ of K.branches){if(U)break;if(_.type==="else")W=_.content,U=!0;else try{let z;if(_.condition&&N0(_.condition))z=w0(_.condition,Object.keys(Z))(...Object.values(Z));else if(_.condition)z=L0(_.condition,Z);if(z)W=_.content,U=!0}catch(z){W=U0(_.type==="if"?"If":"Elseif",`Error in @${_.type}(${_.condition}): ${z instanceof Error?z.message:String(z)}`,J0.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+W+X.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),_=U0("If",`Error processing @if block: ${U}`,J0.EVALUATION_ERROR);X=X.substring(0,K.start)+_+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function M_($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let Y=$[Z];if(Y!=="'"&&Y!=='"')return null;Z++;let X=[];while(Z<$.length){let J=$[Z];if(J==="\\"&&Z+1<$.length){X.push($[Z+1]),Z+=2;continue}if(J===Y){Z++;break}X.push(J),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:X.join(""),consumed:Z}}function RJ($,Z){let Y=$;function X(K,W,U,_){let z=1,B=_,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(B<K.length&&z>0){q.lastIndex=B,j.lastIndex=B;let H=q.exec(K),O=j.exec(K),V=H?H.index:1/0,L=O?O.index:1/0;if(V<L)z++,B=V+H[0].length;else if(L<1/0){if(z--,z===0)return L;B=L+O[0].length}else break}return-1}function J(K,W,U){let _=0,z=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),B=new RegExp(`@${U}(?![a-z])`,"g"),q=/@else(?![a-z])/g,j=[],H;while((H=z.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=q.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((O,V)=>O.pos-V.pos);for(let O of j)if(O.type==="open")_++;else if(O.type==="close")_--;else if(O.type==="else"&&_===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,z,B=Y.slice(U+5),q=M_(B);if(q)_=q.value,z=U+5+q.consumed;else z=U+5;let j=X(Y,"auth","endauth",z);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(z,j),O=J(H,"auth","endauth"),V;if(!Z.auth)V=!1;else V=_?_4(`auth?.check && auth?.user?.[${_}]`,Z):_4("auth?.check",Z);let L;if(O!==-1){let F=H.slice(0,O),A=H.slice(O+5);L=V?F:A}else L=V?H:"";Y=Y.substring(0,U)+L+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,z,B=Y.slice(U+6),q=M_(B);if(q)_=q.value,z=U+6+q.consumed;else z=U+6;let j=X(Y,"guest","endguest",z);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(z,j),O=J(H,"guest","endguest"),V;if(!Z.auth)V=!0;else V=_?_4(`!auth?.check || !auth?.user?.[${_}]`,Z):_4("!auth?.check",Z);let L;if(O!==-1){let F=H.slice(0,O),A=H.slice(O+5);L=V?F:A}else L=V?H:"";Y=Y.substring(0,U)+L+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let _=[K];if(W)_.push(W);if(U){let z=_4(U,Z);_.push(z)}return Z.permissions.check(..._)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,U=K==="can"?"elsecan":"elsecannot",_=!0;while(_){_=!1;let z=Y.match(new RegExp(`@${K}\\s*\\(`));if(!z||z.index===void 0)break;let B=z.index,q=Y.slice(B+`@${K}`.length),j=G(q);if(!j)break;let H=B+`@${K}`.length+j.paramsEnd,O=X(Y,K,W,H);if(O===-1){console.warn(`[stx] @${K} directive at position ${B} has no matching @${W} \u2014 the block was skipped.`);break}let V=Y.slice(H,O),L=[],F=0,A=new RegExp(`@${K}\\s*\\(`,"g"),N=new RegExp(`@${W}(?![a-z])`,"g"),w=new RegExp(`@${U}\\s*\\(`,"g"),R=/@else(?![a-z])/g,M=[],E;while((E=A.exec(V))!==null)M.push({pos:E.index,type:"open"});while((E=N.exec(V))!==null)M.push({pos:E.index,type:"close"});while((E=w.exec(V))!==null)M.push({pos:E.index,type:"elseDirective"});while((E=R.exec(V))!==null)M.push({pos:E.index,type:"else"});M.sort((C,g)=>C.pos-g.pos);for(let C of M){if(C.type==="open"){F++;continue}if(C.type==="close"){F--;continue}if(F===0)L.push(C)}let I=[],S=0;for(let C=0;C<L.length;C++){let g=L[C];if(I.push({content:V.slice(S,g.pos),ability:void 0}),g.type==="elseDirective"){let s=V.slice(g.pos+`@${U}`.length),m=G(s);if(m){I[I.length-1]={content:V.slice(S,g.pos)},S=g.pos+`@${U}`.length+m.paramsEnd,I.push({content:"",ability:m.ability,type:m.type,id:m.id}),I.pop();let b=L[C+1],d=b?b.pos:V.length;I.push({content:V.slice(S,d),ability:m.ability,type:m.type,id:m.id}),S=d}}else S=g.pos+5}if(S<V.length){let C=I[I.length-1];if(L.length>0&&L[L.length-1].type==="else")I.push({content:V.slice(S),isFinalElse:!0});else if(I.length===0)I.push({content:V.slice(S)})}let k=Q(j.ability,j.type,j.id),y=K==="can"?k:!k,P="";if(y)P=I[0]?.content||"";else{let C=!1;for(let g=1;g<I.length;g++){let s=I[g];if(s.isFinalElse){P=s.content,C=!0;break}if(s.ability){let m=Q(s.ability,s.type,s.id);if(K==="can"?m:!m){P=s.content,C=!0;break}}}if(!C&&I.length>0){let g=I[I.length-1];if(g.isFinalElse)P=g.content}}Y=Y.substring(0,B)+P+Y.substring(O+`@${W}`.length),_=!0}}return Y}function MJ($,Z,Y){let X=$;function J(Q,G,K,W,U){let _=!0;while(_){_=!1;let z=new RegExp(`@${G}\\s*\\(`),B=Q.match(z);if(!B||B.index===void 0)break;let q=B.index,j=z4(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,O=h4(Q,G,K,H);if(O===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let V=Q.slice(H,O),L=j.expression,F=-1,A=0,N=0;while(N<V.length){let w=V.indexOf("@",N);if(w===-1)break;let R=V.substring(w);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){A++,N=w+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){A--,N=w+1;continue}if(A===0&&/^@else(?![a-z])/.test(R)){F=w;break}N=w+1}try{let w=W(L.trim()),R;if(F!==-1){let M=V.slice(0,F),E=V.slice(F+5);R=w?M:E}else R=w?V:"";Q=Q.substring(0,q)+R+Q.substring(O+`@${K}`.length),_=!0}catch(w){let R=w instanceof Error?w.message:String(w),M=U0(U,`Error processing @${G} directive: ${R}`,J0.EVALUATION_ERROR);Q=Q.substring(0,q)+M+Q.substring(O+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=_4(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=_4(Q,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),X}function TJ($,Z,Y){let X=$,J="development";function Q(G,K,W,U){let _=new RegExp(`@${K}(?![a-z])`,"g"),z=new RegExp(`@${W}(?![a-z])`,"g"),B=new RegExp(`^@${K}(?![a-z])`),q=new RegExp(`^@${W}(?![a-z])`),j=G,H=!0;while(H){H=!1,_.lastIndex=0;let O=_.exec(j);if(!O)break;let V=O.index,L=V+O[0].length;if(K==="env"){let k=j.substring(L).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!k)break;L+=k[0].length,U=J===k[2]}let F=1,A=L,N=-1;while(F>0&&A<j.length){_.lastIndex=A,z.lastIndex=A;let k=_.exec(j),y=z.exec(j),P=k?k.index:1/0,C=y?y.index:1/0;if(P<C)F++,A=P+k[0].length;else if(C<1/0){if(F--,F===0){N=C;break}A=C+y[0].length}else break}if(N===-1){console.warn(`[stx] @${K} directive at position ${V} has no matching @${W} \u2014 the block was skipped.`);break}let w=j.substring(L,N),R=-1,M=0,E=0;while(E<w.length){let k=w.indexOf("@",E);if(k===-1)break;let y=w.substring(k);if(B.test(y)){M++,E=k+1;continue}if(q.test(y)){M--,E=k+1;continue}if(M===0&&/^@else(?![a-z])/.test(y)){R=k;break}E=k+1}let I;if(R!==-1){let k=w.slice(0,R),y=w.slice(R+5);I=U?k:y}else I=U?w:"";let S=`@${W}`.length;j=j.substring(0,V)+I+j.substring(N+S),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var m3=D(()=>{jJ();R1();e5();p0()});function IJ($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function d4($,Z){if(!$)return Z?.nonceGenerator?.()??IJ();let Y=EJ.get($);if(!Y)Y=Z?.nonceGenerator?.()??IJ(),EJ.set($,Y);return Y}function hR($){EJ.delete($)}function DJ($,Z){let Y=[];for(let[X,J]of Object.entries($)){if(J===void 0||J===null)continue;if(typeof J==="boolean"){if(J)Y.push(X);continue}if(Array.isArray(J)){let Q=[...J];if(Z&&(X==="script-src"||X==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)Y.push(`${X} ${Q.join(" ")}`)}}return Y.join("; ")}function l3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${DJ($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function dR($){return{enabled:!0,directives:{strict:T_,moderate:c3,relaxed:E_,api:I_}[$]||c3,useNonce:$==="strict",addMetaTag:!0}}function uR($,Z){let Y={...$};for(let[X,J]of Object.entries(Z)){let Q=X,G=Y[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")Y[Q]=G||J;else if(Array.isArray(J)){let K=Array.isArray(G)?G:[],W=[...new Set([...K,...J])];Y[Q]=W}}return Y}function kJ($,Z,Y){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let X=Z.useNonce?d4(Y,Z):void 0,J=l3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
1832
1832
|
${J}`)}function mR($,Z){let Y=$;return Y=Y.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(X,J)=>{if(J.includes("nonce="))return X;return`<script nonce="${Z}"${J}>`}),Y=Y.replace(/<style([^>]*)>/gi,(X,J)=>{if(J.includes("nonce="))return X;return`<style nonce="${Z}"${J}>`}),Y}function SJ($,Z,Y,X){let J=$,Q=X.csp;if(J=J.replace(/@csp\b/g,()=>{if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?d4(Z,Q):void 0;return l3(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return d4(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=d4(Z,Q);return J}function cR(){return[D_,k_]}function lR($){let Z=[];if($["script-src"]?.includes("'unsafe-inline'"))Z.push("CSP: Using unsafe-inline in script-src significantly reduces XSS protection");if($["script-src"]?.includes("'unsafe-eval'"))Z.push("CSP: Using unsafe-eval in script-src allows eval() and related functions");if(!$["default-src"])Z.push("CSP: No default-src specified. Recommend adding default-src as a fallback");if($["default-src"]?.includes("*"))Z.push("CSP: Using * in default-src provides minimal protection");if(!$["object-src"]&&!$["default-src"]?.includes("'none'"))Z.push("CSP: Consider adding object-src: none to block plugins");if(!$["base-uri"])Z.push("CSP: Consider adding base-uri to prevent base tag injection attacks");for(let[Y,X]of Object.entries($))if(Array.isArray(X)&&X.includes("http:"))Z.push(`CSP: Using http: in ${Y} allows insecure resources`);return Z}function S_($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function pR($,Z){if(!$.enabled)return{};let Y=$.useNonce?d4(Z,$):void 0,X=DJ($.directives,Y);return{[S_($.reportOnly)]:X}}var EJ,T_,c3,E_,I_,D_,k_,iR;var CJ=D(()=>{EJ=new WeakMap;T_={"default-src":["'self'"],"script-src":["'self'","'strict-dynamic'"],"style-src":["'self'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'none'"],"base-uri":["'self'"],"form-action":["'self'"],"frame-ancestors":["'self'"],"upgrade-insecure-requests":!0},c3={"default-src":["'self'"],"script-src":["'self'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'","https:"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'self'"],"base-uri":["'self'"],"form-action":["'self'"],"upgrade-insecure-requests":!0},E_={"default-src":["'self'"],"script-src":["'self'","'unsafe-inline'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","https:","http:"],"font-src":["'self'","https:","http:","data:"],"connect-src":["'self'","https:","http:","ws:","wss:"],"media-src":["'self'","https:","http:"],"object-src":["'none'"],"frame-src":["'self'","https:"],"base-uri":["'self'"]},I_={"default-src":["'none'"],"frame-ancestors":["'none'"]};D_={name:"csp",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?d4(Y,Q):void 0;return l3(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},k_={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return d4(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};iR={enabled:!1,reportOnly:!1,directives:c3,useNonce:!1,addMetaTag:!0}});import nR from"crypto";function aR($=rR){let Z=nR.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return bJ=Z,Z}function sR(){if(!bJ)aR();return bJ}function oR($=C_){let Z=sR();return`<input type="hidden" name="${$}" value="${Z}">`}function b_($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return oR(X||C_)})}var rR=40,C_="_token",bJ=null;var P_=()=>{};async function PJ($,Z,Y,X){if(!X.customDirectives||X.customDirectives.length===0)return $;let J=$;for(let Q of X.customDirectives){if(!Q.name||typeof Q.handler!=="function"){if(X.debug)console.warn("Invalid custom directive:",Q);continue}if(Q.hasEndTag)J=await tR(J,Q,Z,Y,X);else J=await eR(J,Q,Z,Y,X)}return J}async function tR($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,W=`@end${Q}`,U=$,_=Q$(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${W}`,"g"),z=[],B=_.exec(U);while(B!==null){let[q,j="",H=""]=B,O=B.index||0;try{let V=j?y_(j):[],L=H.trim(),F=await G(L,V,Y,X);z.push({original:q,processed:F,startIndex:O})}catch(V){let L=V instanceof Error?V.message:String(V);if(J.debug)console.error(`Error processing custom directive @${Q}:`,V);z.push({original:q,processed:U0("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${L}`,J0.EVALUATION_ERROR),startIndex:O})}B=_.exec(U)}for(let q=z.length-1;q>=0;q--){let{original:j,processed:H}=z[q];U=U.replace(j,H)}return U}async function eR($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,W=Q$(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),U=[],_=W.exec(K);while(_!==null){let[q,j=""]=_,H=_.index||0;try{let O=y_(j),V=await G("",O,Y,X);U.push({original:q,processed:V,startIndex:H})}catch(O){let V=O instanceof Error?O.message:String(O);if(J.debug)console.error(`Error processing custom directive @${Q}:`,O);U.push({original:q,processed:U0("CustomDirective",`Error in @${Q}(${j}): ${V}`,J0.EVALUATION_ERROR),startIndex:H})}_=W.exec(K)}let z=Q$(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),B=z.exec(K);while(B!==null){let[q]=B,j=B.index||0;try{let H=await G("",[],Y,X);U.push({original:q,processed:H,startIndex:j})}catch(H){let O=H instanceof Error?H.message:String(H);if(J.debug)console.error(`Error processing custom directive @${Q}:`,H);U.push({original:q,processed:U0("CustomDirective",`Error in @${Q}: ${O}`,J0.EVALUATION_ERROR),startIndex:j})}B=z.exec(K)}for(let q=U.length-1;q>=0;q--){let{original:j,processed:H}=U[q];K=K.replace(j,H)}return K}function y_($){if(!$.trim())return[];let Z=[],Y="",X=!1,J="";for(let Q=0;Q<$.length;Q++){let G=$[Q];if((G==='"'||G==="'")&&(Q===0||$[Q-1]!=="\\"))if(!X)X=!0,J=G;else if(G===J)X=!1;else Y+=G;else if(G===","&&!X)Z.push(Y.trim()),Y="";else Y+=G}if(Y.trim())Z.push(Y.trim());return Z.map((Q)=>{let G=Q.trim();if(G.startsWith('"')&&G.endsWith('"')||G.startsWith("'")&&G.endsWith("'"))return G.substring(1,G.length-1);return G})}var yJ=D(()=>{R1();x4()});var n3={};e(n3,{useTitle:()=>f_,useSeoMeta:()=>$7,usePageTitle:()=>f_,useHead:()=>m4,resetHead:()=>x_,renderHtmlAttrs:()=>h_,renderHead:()=>g_,renderBodyAttrs:()=>d_,processTitleDirective:()=>c_,processMetaDirective:()=>l_,processHeadDirective:()=>m_,getPageMeta:()=>i3,getHead:()=>q$,definePageMeta:()=>v_,applyHead:()=>u_});function q$(){return u4}function i3(){return p3}function x_(){u4={},$M.length=0,p3={}}function m4($){u4=ZM(u4,$)}function ZM($,Z){return{title:Z.title??$.title,titleTemplate:Z.titleTemplate??$.titleTemplate,base:Z.base??$.base,meta:[...$.meta||[],...Z.meta||[]],link:[...$.link||[],...Z.link||[]],script:[...$.script||[],...Z.script||[]],style:[...$.style||[],...Z.style||[]],htmlAttrs:{...$.htmlAttrs,...Z.htmlAttrs},bodyAttrs:{...$.bodyAttrs,...Z.bodyAttrs}}}function $7($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let W=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:W})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,X=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(X)Z.push({property:"og:description",content:X});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let J=$.twitterTitle??$.title,Q=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(J)Z.push({name:"twitter:title",content:J});if(Q)Z.push({name:"twitter:description",content:Q});if(G)Z.push({name:"twitter:image",content:G});if($.twitterSite)Z.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)Z.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)Z.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)Z.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)Z.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)Z.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let W of $.articleTags)Z.push({property:"article:tag",content:W});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});m4({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function v_($){if(p3={...p3,...$},$.title||$.description)$7({title:$.title,description:$.description})}function f_($){let Z=typeof $==="function"?$():$;m4({title:Z})}function g_($=u4){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${T6(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${T6(J)}"`).join(" ");Z.push(`<base ${Y}>`)}for(let Y of $.meta||[]){let X=Object.entries(Y).filter(([J,Q])=>Q!==void 0).map(([J,Q])=>{return`${J==="httpEquiv"?"http-equiv":J}="${T6(String(Q))}"`}).join(" ");Z.push(`<meta ${X}>`)}for(let Y of $.link||[]){let X=Object.entries(Y).filter(([J,Q])=>Q!==void 0).map(([J,Q])=>`${J}="${T6(String(Q))}"`).join(" ");Z.push(`<link ${X}>`)}for(let Y of $.script||[]){let{content:X,...J}=Y,Q=Object.entries(J).filter(([G,K])=>K!==void 0).map(([G,K])=>{if(typeof K==="boolean")return K?G:"";return`${G}="${T6(String(K))}"`}).filter(Boolean).join(" ");if(X)Z.push(`<script ${Q}>${X}</script>`);else Z.push(`<script ${Q}></script>`)}for(let Y of $.style||[]){let X=Y.type?` type="${Y.type}"`:"";Z.push(`<style${X}>${Y.content}</style>`)}return Z.join(`
|
|
1833
1833
|
`)}function h_($=u4){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${T6(Y)}"`).join(" ")}function d_($=u4){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${T6(Y)}"`).join(" ")}function T6($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function u_($=u4){if(typeof document>"u")return;if($.title){let Z=$.title;if($.titleTemplate)Z=typeof $.titleTemplate==="function"?$.titleTemplate(Z):$.titleTemplate.replace("%s",Z);document.title=Z}for(let Z of $.meta||[]){let Y=Z.name?`meta[name="${Z.name}"]`:Z.property?`meta[property="${Z.property}"]`:null;if(Y){let X=document.querySelector(Y);if(!X){if(X=document.createElement("meta"),Z.name)X.setAttribute("name",Z.name);if(Z.property)X.setAttribute("property",Z.property);document.head.appendChild(X)}X.setAttribute("content",Z.content)}}for(let Z of $.link||[]){let Y=`link[rel="${Z.rel}"]${Z.href?`[href="${Z.href}"]`:""}`,X=document.querySelector(Y);if(!X)X=document.createElement("link"),document.head.appendChild(X);for(let[J,Q]of Object.entries(Z))if(Q!==void 0)X.setAttribute(J,String(Q))}if($.htmlAttrs)for(let[Z,Y]of Object.entries($.htmlAttrs))document.documentElement.setAttribute(Z,Y);if($.bodyAttrs)for(let[Z,Y]of Object.entries($.bodyAttrs))document.body.setAttribute(Z,Y)}function m_($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
|
|
1834
1834
|
`,""}),headContent:Z.trim()}}function c_($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return m4({title:G}),""})}function l_($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let W=Q?G:K,U=Q?W:Z[(W||"").trim()]??W,z=J.includes(":")?{property:J,content:U}:{name:J,content:U};return m4({meta:[z]}),""})}var u4,$M,p3;var c4=D(()=>{u4={},$M=[],p3={}});import YM from"crypto";function t0($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function XM($){return{...a3,...$.forms?.classes}}function r3($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function JM(){return YM.randomUUID()}function QM($,Z,Y,X){let J=XM(X),Q=$;return Q=r_(Q,Z),Q=j$(Q,Z),Q=s3(Q,Z,J),Q=o3(Q,Z,J),Q}function j$($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=JM();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${t0(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),Y=Y.replace(/@method\(['"]([^'"]+)['"]\)/g,(X,J)=>{let Q=J.toUpperCase();if(J&&!["GET","POST"].includes(Q))return`<input type="hidden" name="_method" value="${t0(Q)}">`;return X}),Y}function s3($,Z,Y=a3){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,W,U="")=>{let _=Q||G||"POST",z=K||W||"",B=l4(U),q=_.toUpperCase(),j=["GET","POST"].includes(q)?q:"POST",H=`<form method="${t0(j)}" action="${t0(z)}"${B?` ${B}`:""}>`;if(H+=`
|
|
@@ -20390,7 +20390,7 @@ else {
|
|
|
20390
20390
|
`)}function SN($,Z){let Y=" ".repeat(Z),X=[];for(let[K,W]of Object.entries($.props))if(W.type==="literal"){let U=typeof W.value==="string"?`"${W.value}"`:String(W.value);X.push(`${K}: ${U}`)}let J=X.length>0?`{ ${X.join(", ")} }`:"{}",Q=$.children.map((K)=>K.type==="text"?`"${K.props.text?.type==="literal"?K.props.text.value:""}"`:SN(K,Z+1)),G=Q.length>0?`,
|
|
20391
20391
|
${Y} [${Q.join(`,
|
|
20392
20392
|
${Y} `)}]`:"";return`Craft.create("${$.zigType}", ${J}${G})`}function Rf($,Z,Y){if(Z.target==="universal"){let X=[];X.push("// Universal entry point"),X.push("");for(let[J,Q]of Y)X.push(`// --- ${J.toUpperCase()} ---`),X.push(`#if ${J.toUpperCase()}`),X.push(Q),X.push("#endif"),X.push("");return X.join(`
|
|
20393
|
-
`)}return Y.get(Z.target)||mW($,Z)}function Mf($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:bN(JSON.stringify(Q.props)),props:Object.keys(Q.props),events:Array.from(Q.events.keys()),slots:[],isNative:Q.zigType.startsWith("craft.")});for(let G of Q.children)J(G)}return J(Z),{version:"1.0.0",components:X,entry:$.id,assets:[],styles:$.styles}}function Tf($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function CN(){return`id_${++Ef}`}function bN($){let Z=0;for(let Y=0;Y<$.length;Y++){let X=$.charCodeAt(Y);Z=(Z<<5)-Z+X,Z=Z&Z}return Math.abs(Z).toString(36)}function If($){return $.charAt(0).toUpperCase()+$.slice(1)}function Df($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function kf($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function cW($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=cW(Y);return Z}function lW($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=lW(Y);return Z}function PN($){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(Z)=>{console.log(`[craft-compiler] File changed: ${Z}`)}}}var pW,Ef=0,Sf,Cf;var xN=D(()=>{pW=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-sidebar",{name:"Sidebar",zigType:"craft.NativeSidebar",props:[{name:"id",type:"string",required:!1},{name:"variant",type:"string",required:!1,default:"desktop"},{name:"material",type:"string",required:!1,default:"sidebar"},{name:"backgroundEffect",type:"string",required:!1,default:"shimmer"},{name:"allowsVibrancy",type:"boolean",required:!1,default:!0},{name:"materialOpacity",type:"number",required:!1,default:0.68},{name:"minWidth",type:"number",required:!1,default:240},{name:"maxWidth",type:"number",required:!1,default:340},{name:"canCollapse",type:"boolean",required:!1,default:!0},{name:"selectedItem",type:"string",required:!1},{name:"sections",type:"array",required:!1}],children:"multiple",platform:["macos"],fallback:"aside"}],["craft-sidebar-section",{name:"SidebarSection",zigType:"craft.NativeSidebarSection",props:[{name:"id",type:"string",required:!0},{name:"title",type:"string",required:!1},{name:"header",type:"string",required:!1}],children:"multiple",platform:["macos"],fallback:"section"}],["craft-sidebar-item",{name:"SidebarItem",zigType:"craft.NativeSidebarItem",props:[{name:"id",type:"string",required:!0},{name:"label",type:"string",required:!0},{name:"icon",type:"string",required:!1},{name:"badge",type:"string",required:!1},{name:"tintColor",type:"color",required:!1}],children:"none",platform:["macos"],fallback:"button"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);Sf={compileToNative:TN,createHotReloadServer:PN,NATIVE_COMPONENTS:pW},Cf=Sf});import{spawn as gN}from"child_process";import y0 from"fs";import bf from"os";import Y0 from"path";import v from"process";import{CLI as Pf}from"@stacksjs/clapp";var F6="0.2.78";Z$();FW();IG();vG();x4();PG();UW();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",O0=new Pf("stx");function vN($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(Z<1024||Z>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function fN($){try{if(!y0.existsSync($)){let Y=Y0.dirname($),X=Y0.basename($);if(y0.existsSync(Y)){let Q=y0.readdirSync(Y).filter((K)=>K.toLowerCase().includes(X.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Y}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Y} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${$}`,suggestion:G}}return{isValid:!1,error:`File does not exist: ${$}`,suggestion:"Check the file path and try again"}}if(y0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(Z){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function iW($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(Z<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(Z>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var P5=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),yf=($)=>$.endsWith(".stx")||$.endsWith(".md");function b5($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);v.exit(Z)}async function xf($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(P5(W))try{let U=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(U.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(X.push(...U),Z.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else X.push(W);if(X.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Y.push(...X),Z.filter)Y.push("--pattern",Z.filter);if(Z.timeout)Y.push("--timeout",Z.timeout.toString());if(Z.reporter&&Z.reporter!=="default")if(Z.reporter==="junit"){let W=Y0.join(bf.tmpdir(),`stx-test-report-${Date.now()}.xml`);Y.push("--reporter",Z.reporter),Y.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${Z.reporter}' is not supported. Using default reporter.`);if(Z.coverage)Y.push("--coverage");if(Z.watch)Y.push("--watch");Y.push("--preload",Y0.join(__dirname,"../../../test-utils/happy-dom.ts"));let J={...v.env,STX_TEST_MODE:"true",STX_TEST_UI:Z.ui?"true":"false",STX_TEST_VERBOSE:Z.verbose?"true":"false"},Q="bun";if(Z.verbose)console.log(`Running: ${Q} ${Y.join(" ")}`);let G=performance.now(),K=gN(Q,Y,{stdio:"inherit",shell:!1,env:J});return new Promise((W)=>{K.on("close",(U)=>{let z=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),v.on("SIGINT",()=>{console.log(`
|
|
20393
|
+
`)}return Y.get(Z.target)||mW($,Z)}function Mf($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:bN(JSON.stringify(Q.props)),props:Object.keys(Q.props),events:Array.from(Q.events.keys()),slots:[],isNative:Q.zigType.startsWith("craft.")});for(let G of Q.children)J(G)}return J(Z),{version:"1.0.0",components:X,entry:$.id,assets:[],styles:$.styles}}function Tf($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function CN(){return`id_${++Ef}`}function bN($){let Z=0;for(let Y=0;Y<$.length;Y++){let X=$.charCodeAt(Y);Z=(Z<<5)-Z+X,Z=Z&Z}return Math.abs(Z).toString(36)}function If($){return $.charAt(0).toUpperCase()+$.slice(1)}function Df($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function kf($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function cW($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=cW(Y);return Z}function lW($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=lW(Y);return Z}function PN($){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(Z)=>{console.log(`[craft-compiler] File changed: ${Z}`)}}}var pW,Ef=0,Sf,Cf;var xN=D(()=>{pW=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-sidebar",{name:"Sidebar",zigType:"craft.NativeSidebar",props:[{name:"id",type:"string",required:!1},{name:"variant",type:"string",required:!1,default:"desktop"},{name:"material",type:"string",required:!1,default:"sidebar"},{name:"backgroundEffect",type:"string",required:!1,default:"shimmer"},{name:"allowsVibrancy",type:"boolean",required:!1,default:!0},{name:"materialOpacity",type:"number",required:!1,default:0.68},{name:"minWidth",type:"number",required:!1,default:240},{name:"maxWidth",type:"number",required:!1,default:340},{name:"canCollapse",type:"boolean",required:!1,default:!0},{name:"selectedItem",type:"string",required:!1},{name:"sections",type:"array",required:!1}],children:"multiple",platform:["macos"],fallback:"aside"}],["craft-sidebar-section",{name:"SidebarSection",zigType:"craft.NativeSidebarSection",props:[{name:"id",type:"string",required:!0},{name:"title",type:"string",required:!1},{name:"header",type:"string",required:!1}],children:"multiple",platform:["macos"],fallback:"section"}],["craft-sidebar-item",{name:"SidebarItem",zigType:"craft.NativeSidebarItem",props:[{name:"id",type:"string",required:!0},{name:"label",type:"string",required:!0},{name:"icon",type:"string",required:!1},{name:"badge",type:"string",required:!1},{name:"tintColor",type:"color",required:!1}],children:"none",platform:["macos"],fallback:"button"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);Sf={compileToNative:TN,createHotReloadServer:PN,NATIVE_COMPONENTS:pW},Cf=Sf});import{spawn as gN}from"child_process";import y0 from"fs";import bf from"os";import Y0 from"path";import v from"process";import{CLI as Pf}from"@stacksjs/clapp";var F6="0.2.79";Z$();FW();IG();vG();x4();PG();UW();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",O0=new Pf("stx");function vN($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(Z<1024||Z>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function fN($){try{if(!y0.existsSync($)){let Y=Y0.dirname($),X=Y0.basename($);if(y0.existsSync(Y)){let Q=y0.readdirSync(Y).filter((K)=>K.toLowerCase().includes(X.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Y}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Y} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${$}`,suggestion:G}}return{isValid:!1,error:`File does not exist: ${$}`,suggestion:"Check the file path and try again"}}if(y0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(Z){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function iW($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(Z<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(Z>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var P5=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),yf=($)=>$.endsWith(".stx")||$.endsWith(".md");function b5($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);v.exit(Z)}async function xf($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(P5(W))try{let U=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(U.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(X.push(...U),Z.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else X.push(W);if(X.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Y.push(...X),Z.filter)Y.push("--pattern",Z.filter);if(Z.timeout)Y.push("--timeout",Z.timeout.toString());if(Z.reporter&&Z.reporter!=="default")if(Z.reporter==="junit"){let W=Y0.join(bf.tmpdir(),`stx-test-report-${Date.now()}.xml`);Y.push("--reporter",Z.reporter),Y.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${Z.reporter}' is not supported. Using default reporter.`);if(Z.coverage)Y.push("--coverage");if(Z.watch)Y.push("--watch");Y.push("--preload",Y0.join(__dirname,"../../../test-utils/happy-dom.ts"));let J={...v.env,STX_TEST_MODE:"true",STX_TEST_UI:Z.ui?"true":"false",STX_TEST_VERBOSE:Z.verbose?"true":"false"},Q="bun";if(Z.verbose)console.log(`Running: ${Q} ${Y.join(" ")}`);let G=performance.now(),K=gN(Q,Y,{stdio:"inherit",shell:!1,env:J});return new Promise((W)=>{K.on("close",(U)=>{let z=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),v.on("SIGINT",()=>{console.log(`
|
|
20394
20394
|
Test run interrupted`),K.kill("SIGINT"),v.exit(1)})})}catch(Y){return console.error("Error running tests:",Y instanceof Error?Y.message:String(Y)),!1}}var vf=v.argv.length>=3&&(yf(v.argv[2])&&y0.existsSync(v.argv[2])||P5(v.argv[2]));if(vf){let $=v.argv[2],Z={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let Y=3;Y<v.argv.length;Y++){let X=v.argv[Y];if(X==="--port"&&Y+1<v.argv.length){let J=vN(v.argv[++Y]);if(!J.isValid)b5(J);Z.port=Number.parseInt(v.argv[Y],10)}else if(X==="--no-watch")Z.watch=!1;else if(X==="--highlight-theme"&&Y+1<v.argv.length){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.defaultTheme=v.argv[++Y]}else if(X==="--no-highlight"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.enabled=!1}else if(X==="--no-highlight-unknown"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(X==="--no-cache")Z.cache=!1;else if(X==="--native")Z.native=!0}if(P5($))try{let Y=await Array.fromAsync(new Bun.Glob($).scan({onlyFiles:!0,absolute:!0})),X=$.endsWith(".stx")?Y.filter((K)=>K.endsWith(".stx")):$.endsWith(".md")?Y.filter((K)=>K.endsWith(".md")):Y.filter((K)=>K.endsWith(".stx")||K.endsWith(".md")),J=$.split("*")[0].replace(/\/$/,"")||".",Q=Y0.resolve(J);try{let K=new Bun.Glob("**/*.stx"),U=(await Array.fromAsync(K.scan({cwd:Q,onlyFiles:!0,absolute:!0}))).filter((_)=>/\[.+\]/.test(Y0.basename(_)));for(let _ of U)if(!X.includes(_))X.push(_)}catch{}if(X.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${$}`),v.exit(1);if(!await u8(X,Z))v.exit(1)}catch(Y){console.error("Failed to process files:",Y),v.exit(1)}else d8($,Z).catch((Y)=>{console.error("Failed to start dev server:",Y),v.exit(1)})}else{let $=function(X,J){let Q=[];for(let G=0;G<=J.length;G++)Q[G]=[G];for(let G=0;G<=X.length;G++)Q[0][G]=G;for(let G=1;G<=J.length;G++)for(let K=1;K<=X.length;K++)if(J.charAt(G-1)===X.charAt(K-1))Q[G][K]=Q[G-1][K-1];else Q[G][K]=Math.min(Q[G-1][K-1]+1,Q[G][K-1]+1,Q[G-1][K]+1);return Q[J.length][X.length]};O0.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(X)=>{try{if(await EG(X))console.log("Documentation generated successfully."),v.exit(0);else console.error("Documentation generation failed."),v.exit(1)}catch(J){console.error("Error generating documentation:",J),v.exit(1)}}),O0.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(X,J)=>{try{let{fetchCollections:Q,generatePackage:G}=await import("@stacksjs/iconify-generator");if(X==="list"){console.log(`
|
|
20395
20395
|
\uD83D\uDCDA Fetching available icon collections...
|
|
20396
20396
|
`);let K=await Q(),W=Object.entries(K).sort((U,_)=>_[1].total-U[1].total);console.log(`Available collections:
|
|
@@ -2435,7 +2435,7 @@ window.__stx_reactive = (function() {
|
|
|
2435
2435
|
${VG()}
|
|
2436
2436
|
${Y}
|
|
2437
2437
|
</script>`}function L8($,Z,Y){if(O8=0,!RG($))return $;let X=HG($);if(X.length===0)return $;let Q=AG($,X),J=wG(X,Z),G=Q.lastIndexOf("</body>");if(G!==-1)Q=Q.slice(0,G)+J+`
|
|
2438
|
-
`+Q.slice(G);else Q+=J;return Q}function AG($,Z){let Y=$;for(let X of Z){let J=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${R$(X.stateExpr)}["']`,"gi").exec(Y);if(J)X.id=J[1],X.selector=`[data-stx-scope="${X.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${R$(X.stateExpr)}["'][^>]*data-stx-scope="([^"]*)"`,"gi").exec(Y);if(K)X.id=K[1],X.selector=`[data-stx-scope="${X.id}"]`;else Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*"${R$(X.stateExpr)}")([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`),Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*'${R$(X.stateExpr)}')([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`)}}return Y=Y.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),Y=Y.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),Y=Y.replace(/\s*x-init\s*=\s*"[^"]*"/g,""),Y=Y.replace(/\s*x-init\s*=\s*'[^']*'/g,""),Y}function RG($){return/x-data\s*=\s*["']/.test($)}var O8=0,jG=0;var F8=P(()=>{c0()});import NG from"fs";import z7 from"path";import{createHighlighter as TG}from"ts-syntax-highlighter";async function MG($,Z={}){try{if(!await l($))throw Error(`Markdown file not found: ${$}`);let X=(await NG.promises.stat($)).mtime.getTime();if(Z.cache&&W7.has($)){let U=W7.get($);if(U.updatedAt>=X)return{content:U.content,data:U.data}}let Q=await Bun.file($).text(),{data:J,content:G}=D6(Q),K=Z.markdown||J7.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},W=q5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)W=await IG(W,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let z={content:W,data:J||{}};if(Z.cache)W7.set($,{...z,updatedAt:X});return z}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:J0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function IG($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!N$)try{N$=await TG({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let Q=async(K,q,W,z)=>{let U=z.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),_=W||(Y?"text":"");if(!_)return K;try{if(!N$.getSupportedLanguages().includes(_))return K;return(await N$.highlight(U,_,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${W}:`,B)}return K},J=$,G=$.matchAll(X);for(let K of G){let[q,W,z,U]=K,_=await Q(q,W,z,U);J=J.replace(q,_)}return J}async function V8($,Z,Y="",X={}){return await DG($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,q,W)=>{try{let z=K;if(!z7.isAbsolute(K))z=z7.resolve(z7.dirname(Y),K);let U={};if(q)try{try{U=JSON.parse(q)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let O=q.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let w=V.indexOf(":");if(w>0){let A=V.substring(0,w).trim(),R=V.substring(w+1).trim(),N=R.startsWith('"')&&R.endsWith('"'),T=R.startsWith("'")&&R.endsWith("'");if(N||T)R=R.substring(1,R.length-1);U[A]=R}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:_,data:B}=await MG(z,X),j={...Z,...B,...U},H=_,L=/\{\{([^}]+)\}\}/g;return H=H.replace(L,(F,O)=>{let V=O.trim();return j[V]!==void 0?String(j[V]):F}),H}catch(z){let U=z instanceof Error?z.message:String(z);return J0("Markdown File",`Error including markdown file: ${U}`,Y,$,W,G)}})}async function DG($,Z,Y){let X=[],Q;while((Q=Z.exec($))!==null){let K=Q[0],q=Q.index,W=Q;X.push(Y(...W).then((z)=>({match:K,replacement:z,index:q})))}let J=await Promise.all(X);J.sort((K,q)=>q.index-K.index);let G=$;for(let{match:K,replacement:q}of J)G=G.replace(K,()=>q);return G}var W7,N$=null;var w8=P(()=>{B5();O0();W7=new Map});function Y1($,Z){try{let Y=$.trim();if(e(Y))return $0(Y,Object.keys(Z))(...Object.values(Z));else return Y0(Y,Z)}catch{return!1}}var A8=P(()=>{H0()});function D0($,Z,Y,X=0){let Q=0,J=X,G=null,K=0,q=!1;while(J<$.length){let W=$[J];if(G&&q){q=!1,J++;continue}if(G&&W==="\\"){q=!0,J++;continue}if(q=!1,(W==='"'||W==="'"||W==="`")&&!G){G=W,J++;continue}if(W===G&&G!=="`"){G=null,J++;continue}if(G==="`"&&W==="$"&&$[J+1]==="{"){K++,J+=2;continue}if(K>0&&W==="}"){K--,J++;continue}if(W==="`"&&G==="`"&&K===0){G=null,J++;continue}if(G){J++;continue}if(W===Z)Q++;else if(W===Y){if(Q--,Q===0)return J}J++}return-1}function X1($,Z){let Y=EG($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function EG($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=D0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function R1($,Z,Y,X){let Q=1,J=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(J<$.length&&Q>0){G.lastIndex=J,K.lastIndex=J;let q=G.exec($),W=K.exec($),z=q?q.index:1/0,U=W?W.index:1/0;if(z<U)Q++,J=z+q[0].length;else if(U<1/0){if(Q--,Q===0)return U;J=U+W[0].length}else break}return-1}function R8($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,Q=X1($,X);if(!Q)return null;let J=Q.endPos,G=R1($,"if","endif",J);if(G===-1)return null;let K=$.slice(J,G),q=[],W=0,z="if",U=Q.expression,_=0,B=0;while(W<K.length){let j=K.indexOf("@",W);if(j===-1)break;W=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,W++;continue}if(/^@endif(?![a-z])/.test(H)){B--,W+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){q.push({type:z,condition:U,content:K.substring(_,W),start:J+_,end:J+W});let F=W+L[0].length,O=X1(K,F);if(!O){W++;continue}z="elseif",U=O.expression,W=O.endPos,_=W;continue}else if(/^@else(?![a-z])/.test(H)){q.push({type:z,condition:U,content:K.substring(_,W),start:J+_,end:J+W}),z="else",U=void 0,W+=5,_=W;continue}}W++}return q.push({type:z,condition:U,content:K.slice(_),start:J+_,end:J+K.length}),{fullMatch:$.slice(Z,G+6),branches:q,start:Z,end:G+6}}function H5($){let Z=[],Y=/@if\s*\(/g,X=Y.exec($);while(X!==null){if(Z.some((G)=>X.index>G.start&&X.index<G.end)){X=Y.exec($);continue}let J=R8($,X.index);if(J)Z.push(J),Y.lastIndex=J.end;X=Y.exec($)}return Z}function T$($,Z,Y){let X=[],Q=new RegExp(`@${Z}\\s*\\(`,"g"),J=Q.exec($);while(J!==null){if(X.some((H)=>J.index>H.start&&J.index<H.end)){J=Q.exec($);continue}let K=J.index,q=K+J[0].length-1,W=D0($,"(",")",q);if(W===-1){J=Q.exec($);continue}let z=$.slice(q+1,W),U=W+1,_=R1($,Z,Y,U);if(_===-1){J=Q.exec($);continue}let B=$.slice(U,_),j=_+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:z,content:B,start:K,end:j}),Q.lastIndex=j,J=Q.exec($)}return X}function U7($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,Q=X1($,X);if(!Q)return null;let J=Q.endPos,G=R1($,"switch","endswitch",J);if(G===-1)return null;let K=$.slice(J,G),q=[],W=0,z=null,U=0;while(W<K.length){let _=K.slice(W),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(U++,z)z.content+=B[0];W+=B[0].length;continue}if(j){if(U--,z)z.content+=j[0];W+=j[0].length;continue}if(U>0){if(z)z.content+=K[W];W++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(z)q.push(z);let O=W+H[0].length,V=X1(K,O);if(!V){W++;continue}z={type:"case",value:V.expression,content:""},W=V.endPos}else if(L&&_.startsWith("@default")){if(z)q.push(z);z={type:"default",content:""},W+=L[0].length}else if(F&&_.startsWith("@break"))W+=F[0].length;else{if(z)z.content+=K[W];W++}}if(z)q.push(z);return{fullMatch:$.slice(Z,G+10),expression:Q.expression,cases:q,start:Z,end:G+10}}var N8=()=>{};var T8=()=>{};var M$=P(()=>{N8();T8()});function yG($,Z,Y){let X=$,Q=!0;while(Q){Q=!1;let J=X.match(/@switch\s*\(/);if(!J||J.index===void 0)break;let G=J.index,K=U7(X,G);if(!K)break;try{let q;if(e(K.expression))q=$0(K.expression,Object.keys(Z))(...Object.values(Z));else q=Y0(K.expression,Z);let W="",z=!1;for(let U of K.cases)if(U.type==="default"){if(!z)W=U.content.trim()}else try{let _;if(U.value&&e(U.value))_=$0(U.value,Object.keys(Z))(...Object.values(Z));else if(U.value)_=Y0(U.value,Z);if(q===_){W=U.content.trim(),z=!0;break}}catch{continue}X=X.substring(0,G)+W+X.substring(K.end),Q=!0}catch(q){let W=q instanceof Error?q.message:String(q),z=s("Switch",`Error evaluating @switch expression: ${W}`,i.EVALUATION_ERROR);X=X.substring(0,G)+z+X.substring(K.end);break}}return X}function N1($,Z,Y){let X=$;X=yG(X,Z,Y);{let J=!0;while(J){J=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,q=X1(X,K+7);if(!q)break;let W=q.endPos,z=R1(X,"unless","endunless",W);if(z===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let U=X.slice(W,z),_=q.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],w;while((w=L.exec(U))!==null)V.push({pos:w.index,type:"open"});while((w=F.exec(U))!==null)V.push({pos:w.index,type:"close"});while((w=O.exec(U))!==null)V.push({pos:w.index,type:"else"});V.sort((A,R)=>A.pos-R.pos);for(let A of V)if(A.type==="open")H++;else if(A.type==="close")H--;else if(A.type==="else"&&H===0){B=A.pos;break}}let j;if(B!==-1){let H=U.slice(0,B),L=U.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${U}@endif`;X=X.substring(0,K)+j+X.substring(z+10),J=!0}}X=B7(X,Z,Y),X=j7(X,Z,Y),X=_7(X,Z);let Q=()=>{let J=H5(X);if(J.length===0)return!1;for(let G=J.length-1;G>=0;G--){let K=J[G];try{let q="",W=!1;for(let z of K.branches){if(W)break;if(z.type==="else")q=z.content,W=!0;else try{let U;if(z.condition&&e(z.condition))U=$0(z.condition,Object.keys(Z))(...Object.values(Z));else if(z.condition)U=Y0(z.condition,Z);if(U)q=z.content,W=!0}catch(U){q=s(z.type==="if"?"If":"Elseif",`Error in @${z.type}(${z.condition}): ${U instanceof Error?U.message:String(U)}`,i.EVALUATION_ERROR),W=!0}}X=X.substring(0,K.start)+q+X.substring(K.end)}catch(q){let W=q instanceof Error?q.message:String(q),z=s("If",`Error processing @if block: ${W}`,i.EVALUATION_ERROR);X=X.substring(0,K.start)+z+X.substring(K.end)}}return!0};while(Q());return X}function M8($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let Y=$[Z];if(Y!=="'"&&Y!=='"')return null;Z++;let X=[];while(Z<$.length){let Q=$[Z];if(Q==="\\"&&Z+1<$.length){X.push($[Z+1]),Z+=2;continue}if(Q===Y){Z++;break}X.push(Q),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:X.join(""),consumed:Z}}function _7($,Z){let Y=$;function X(K,q,W,z){let U=1,_=z,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(_<K.length&&U>0){B.lastIndex=_,j.lastIndex=_;let H=B.exec(K),L=j.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)U++,_=F+H[0].length;else if(O<1/0){if(U--,U===0)return O;_=O+L[0].length}else break}return-1}function Q(K,q,W){let z=0,U=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=U.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=_.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")z++;else if(L.type==="close")z--;else if(L.type==="else"&&z===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let q=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let W=q.index,z,U,_=Y.slice(W+5),B=M8(_);if(B)z=B.value,U=W+5+B.consumed;else U=W+5;let j=X(Y,"auth","endauth",U);if(j===-1){console.warn(`[stx] @auth directive at position ${W} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=Q(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=z?Y1(`auth?.check && auth?.user?.[${z}]`,Z):Y1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let q=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let W=q.index,z,U,_=Y.slice(W+6),B=M8(_);if(B)z=B.value,U=W+6+B.consumed;else U=W+6;let j=X(Y,"guest","endguest",U);if(j===-1){console.warn(`[stx] @guest directive at position ${W} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=Q(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=z?Y1(`!auth?.check || !auth?.user?.[${z}]`,Z):Y1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+9),K=!0}}function J(K,q,W){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let z=[K];if(q)z.push(q);if(W){let U=Y1(W,Z);z.push(U)}return Z.permissions.check(...z)}catch{return!1}return!1}function G(K){let q=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!q)return null;return{ability:q[1],type:q[2],id:q[3]?.trim(),paramsEnd:q[0].length}}for(let K of["can","cannot"]){let q=`end${K}`,W=K==="can"?"elsecan":"elsecannot",z=!0;while(z){z=!1;let U=Y.match(new RegExp(`@${K}\\s*\\(`));if(!U||U.index===void 0)break;let _=U.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let H=_+`@${K}`.length+j.paramsEnd,L=X(Y,K,q,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${q} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${q}(?![a-z])`,"g"),R=new RegExp(`@${W}\\s*\\(`,"g"),N=/@else(?![a-z])/g,T=[],M;while((M=w.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=A.exec(F))!==null)T.push({pos:M.index,type:"close"});while((M=R.exec(F))!==null)T.push({pos:M.index,type:"elseDirective"});while((M=N.exec(F))!==null)T.push({pos:M.index,type:"else"});T.sort((S,C)=>S.pos-C.pos);for(let S of T){if(S.type==="open"){V++;continue}if(S.type==="close"){V--;continue}if(V===0)O.push(S)}let I=[],E=0;for(let S=0;S<O.length;S++){let C=O[S];if(I.push({content:F.slice(E,C.pos),ability:void 0}),C.type==="elseDirective"){let d=F.slice(C.pos+`@${W}`.length),f=G(d);if(f){I[I.length-1]={content:F.slice(E,C.pos)},E=C.pos+`@${W}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=O[S+1],n=m?m.pos:F.length;I.push({content:F.slice(E,n),ability:f.ability,type:f.type,id:f.id}),E=n}}else E=C.pos+5}if(E<F.length){let S=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:F.slice(E),isFinalElse:!0});else if(I.length===0)I.push({content:F.slice(E)})}let D=J(j.ability,j.type,j.id),b=K==="can"?D:!D,k="";if(b)k=I[0]?.content||"";else{let S=!1;for(let C=1;C<I.length;C++){let d=I[C];if(d.isFinalElse){k=d.content,S=!0;break}if(d.ability){let f=J(d.ability,d.type,d.id);if(K==="can"?f:!f){k=d.content,S=!0;break}}}if(!S&&I.length>0){let C=I[I.length-1];if(C.isFinalElse)k=C.content}}Y=Y.substring(0,_)+k+Y.substring(L+`@${q}`.length),z=!0}}return Y}function B7($,Z,Y){let X=$;function Q(J,G,K,q,W){let z=!0;while(z){z=!1;let U=new RegExp(`@${G}\\s*\\(`),_=J.match(U);if(!_||_.index===void 0)break;let B=_.index,j=X1(J,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=R1(J,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${B} has no matching @${K} \u2014 the block was skipped.`);break}let F=J.slice(H,L),O=j.expression,V=-1,w=0,A=0;while(A<F.length){let R=F.indexOf("@",A);if(R===-1)break;let N=F.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){w++,A=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){w--,A=R+1;continue}if(w===0&&/^@else(?![a-z])/.test(N)){V=R;break}A=R+1}try{let R=q(O.trim()),N;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);N=R?T:M}else N=R?F:"";J=J.substring(0,B)+N+J.substring(L+`@${K}`.length),z=!0}catch(R){let N=R instanceof Error?R.message:String(R),T=s(W,`Error processing @${G} directive: ${N}`,i.EVALUATION_ERROR);J=J.substring(0,B)+T+J.substring(L+`@${K}`.length);break}}return J}return X=Q(X,"isset","endisset",(J)=>{let G=Y1(J,Z);return G!==void 0&&G!==null},"Isset"),X=Q(X,"empty","endempty",(J)=>{let G=Y1(J,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),X}function j7($,Z,Y){let X=$,Q="development";function J(G,K,q,W){let z=new RegExp(`@${K}(?![a-z])`,"g"),U=new RegExp(`@${q}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${q}(?![a-z])`),j=G,H=!0;while(H){H=!1,z.lastIndex=0;let L=z.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let D=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!D)break;O+=D[0].length,W=Q===D[2]}let V=1,w=O,A=-1;while(V>0&&w<j.length){z.lastIndex=w,U.lastIndex=w;let D=z.exec(j),b=U.exec(j),k=D?D.index:1/0,S=b?b.index:1/0;if(k<S)V++,w=k+D[0].length;else if(S<1/0){if(V--,V===0){A=S;break}w=S+b[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${q} \u2014 the block was skipped.`);break}let R=j.substring(O,A),N=-1,T=0,M=0;while(M<R.length){let D=R.indexOf("@",M);if(D===-1)break;let b=R.substring(D);if(_.test(b)){T++,M=D+1;continue}if(B.test(b)){T--,M=D+1;continue}if(T===0&&/^@else(?![a-z])/.test(b)){N=D;break}M=D+1}let I;if(N!==-1){let D=R.slice(0,N),b=R.slice(N+5);I=W?D:b}else I=W?R:"";let E=`@${q}`.length;j=j.substring(0,F)+I+j.substring(A+E),H=!0}return j}return X=J(X,"env","endenv",!1),X=J(X,"production","endproduction",Q==="production"),X=J(X,"development","enddevelopment",Q==="development"),X=J(X,"staging","endstaging",Q==="staging"),X=J(X,"testing","endtesting",Q==="testing"),X}var I$=P(()=>{A8();a0();M$();H0()});function D8($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function D$($,Z){if(!$)return Z?.nonceGenerator?.()??D8();let Y=I8.get($);if(!Y)Y=Z?.nonceGenerator?.()??D8(),I8.set($,Y);return Y}function CG($,Z){let Y=[];for(let[X,Q]of Object.entries($)){if(Q===void 0||Q===null)continue;if(typeof Q==="boolean"){if(Q)Y.push(X);continue}if(Array.isArray(Q)){let J=[...Q];if(Z&&(X==="script-src"||X==="style-src"))J=J.filter((G)=>!G.startsWith("'nonce-")),J.push(`'nonce-${Z}'`);if(J.length>0)Y.push(`${X} ${J.join(" ")}`)}}return Y.join("; ")}function E8($,Z){return`<meta http-equiv="Content-Security-Policy" content="${CG($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function k8($,Z,Y){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let X=Z.useNonce?D$(Y,Z):void 0,Q=E8(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
2438
|
+
`+Q.slice(G);else Q+=J;return Q}function AG($,Z){let Y=$;for(let X of Z){let J=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${R$(X.stateExpr)}["']`,"gi").exec(Y);if(J)X.id=J[1],X.selector=`[data-stx-scope="${X.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${R$(X.stateExpr)}["'][^>]*data-stx-scope="([^"]*)"`,"gi").exec(Y);if(K)X.id=K[1],X.selector=`[data-stx-scope="${X.id}"]`;else Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*"${R$(X.stateExpr)}")([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`),Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*'${R$(X.stateExpr)}')([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`)}}return Y=Y.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),Y=Y.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),Y=Y.replace(/\s*x-init\s*=\s*"[^"]*"/g,""),Y=Y.replace(/\s*x-init\s*=\s*'[^']*'/g,""),Y}function RG($){return/x-data\s*=\s*["']/.test($)}var O8=0,jG=0;var F8=P(()=>{c0()});import NG from"fs";import z7 from"path";import{createHighlighter as TG}from"ts-syntax-highlighter";async function MG($,Z={}){try{if(!await l($))throw Error(`Markdown file not found: ${$}`);let X=(await NG.promises.stat($)).mtime.getTime();if(Z.cache&&W7.has($)){let U=W7.get($);if(U.updatedAt>=X)return{content:U.content,data:U.data}}let Q=await Bun.file($).text(),{data:J,content:G}=D6(Q),K=Z.markdown||J7.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},W=q5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)W=await IG(W,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let z={content:W,data:J||{}};if(Z.cache)W7.set($,{...z,updatedAt:X});return z}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:J0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function IG($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!N$)try{N$=await TG({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let Q=async(K,q,W,z)=>{let U=z.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),_=W||(Y?"text":"");if(!_)return K;try{if(!N$.getSupportedLanguages().includes(_))return K;return(await N$.highlight(U,_,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${W}:`,B)}return K},J=$,G=$.matchAll(X);for(let K of G){let[q,W,z,U]=K,_=await Q(q,W,z,U);J=J.replace(q,_)}return J}async function V8($,Z,Y="",X={}){return await DG($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,q,W)=>{try{let z=K;if(!z7.isAbsolute(K))z=z7.resolve(z7.dirname(Y),K);let U={};if(q)try{try{U=JSON.parse(q)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let O=q.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let w=V.indexOf(":");if(w>0){let A=V.substring(0,w).trim(),R=V.substring(w+1).trim(),N=R.startsWith('"')&&R.endsWith('"'),T=R.startsWith("'")&&R.endsWith("'");if(N||T)R=R.substring(1,R.length-1);U[A]=R}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:_,data:B}=await MG(z,X),j={...Z,...B,...U},H=_,L=/\{\{([^}]+)\}\}/g;return H=H.replace(L,(F,O)=>{let V=O.trim();return j[V]!==void 0?String(j[V]):F}),H}catch(z){let U=z instanceof Error?z.message:String(z);return J0("Markdown File",`Error including markdown file: ${U}`,Y,$,W,G)}})}async function DG($,Z,Y){let X=[],Q;while((Q=Z.exec($))!==null){let K=Q[0],q=Q.index,W=Q;X.push(Y(...W).then((z)=>({match:K,replacement:z,index:q})))}let J=await Promise.all(X);J.sort((K,q)=>q.index-K.index);let G=$;for(let{match:K,replacement:q}of J)G=G.replace(K,()=>q);return G}var W7,N$=null;var w8=P(()=>{B5();O0();W7=new Map});function Y1($,Z){try{let Y=$.trim();if(e(Y))return $0(Y,Object.keys(Z))(...Object.values(Z));else return Y0(Y,Z)}catch{return!1}}var A8=P(()=>{H0()});function D0($,Z,Y,X=0){let Q=0,J=X,G=null,K=0,q=!1;while(J<$.length){let W=$[J];if(G&&q){q=!1,J++;continue}if(G&&W==="\\"){q=!0,J++;continue}if(q=!1,(W==='"'||W==="'"||W==="`")&&!G){G=W,J++;continue}if(W===G&&G!=="`"){G=null,J++;continue}if(G==="`"&&W==="$"&&$[J+1]==="{"){K++,J+=2;continue}if(K>0&&W==="}"){K--,J++;continue}if(W==="`"&&G==="`"&&K===0){G=null,J++;continue}if(G){J++;continue}if(W===Z)Q++;else if(W===Y){if(Q--,Q===0)return J}J++}return-1}function X1($,Z){let Y=EG($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function EG($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=D0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function R1($,Z,Y,X){let Q=1,J=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(J<$.length&&Q>0){G.lastIndex=J,K.lastIndex=J;let q=G.exec($),W=K.exec($),z=q?q.index:1/0,U=W?W.index:1/0;if(z<U)Q++,J=z+q[0].length;else if(U<1/0){if(Q--,Q===0)return U;J=U+W[0].length}else break}return-1}function R8($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,Q=X1($,X);if(!Q)return null;let J=Q.endPos,G=R1($,"if","endif",J);if(G===-1)return null;let K=$.slice(J,G),q=[],W=0,z="if",U=Q.expression,_=0,B=0;while(W<K.length){let j=K.indexOf("@",W);if(j===-1)break;W=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,W++;continue}if(/^@endif(?![a-z])/.test(H)){B--,W+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){q.push({type:z,condition:U,content:K.substring(_,W),start:J+_,end:J+W});let F=W+L[0].length,O=X1(K,F);if(!O){W++;continue}z="elseif",U=O.expression,W=O.endPos,_=W;continue}else if(/^@else(?![a-z])/.test(H)){q.push({type:z,condition:U,content:K.substring(_,W),start:J+_,end:J+W}),z="else",U=void 0,W+=5,_=W;continue}}W++}return q.push({type:z,condition:U,content:K.slice(_),start:J+_,end:J+K.length}),{fullMatch:$.slice(Z,G+6),branches:q,start:Z,end:G+6}}function H5($){let Z=[],Y=/@if\s*\(/g,X=Y.exec($);while(X!==null){if(Z.some((G)=>X.index>G.start&&X.index<G.end)){X=Y.exec($);continue}let J=R8($,X.index);if(J)Z.push(J),Y.lastIndex=J.end;X=Y.exec($)}return Z}function T$($,Z,Y){let X=[],Q=new RegExp(`@${Z}\\s*\\(`,"g"),J=Q.exec($);while(J!==null){if(X.some((H)=>J.index>H.start&&J.index<H.end)){J=Q.exec($);continue}let K=J.index,q=K+J[0].length-1,W=D0($,"(",")",q);if(W===-1){J=Q.exec($);continue}let z=$.slice(q+1,W),U=W+1,_=R1($,Z,Y,U);if(_===-1){J=Q.exec($);continue}let B=$.slice(U,_),j=_+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:z,content:B,start:K,end:j}),Q.lastIndex=j,J=Q.exec($)}return X}function U7($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,Q=X1($,X);if(!Q)return null;let J=Q.endPos,G=R1($,"switch","endswitch",J);if(G===-1)return null;let K=$.slice(J,G),q=[],W=0,z=null,U=0;while(W<K.length){let _=K.slice(W),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(U++,z)z.content+=B[0];W+=B[0].length;continue}if(j){if(U--,z)z.content+=j[0];W+=j[0].length;continue}if(U>0){if(z)z.content+=K[W];W++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(z)q.push(z);let O=W+H[0].length,V=X1(K,O);if(!V){W++;continue}z={type:"case",value:V.expression,content:""},W=V.endPos}else if(L&&_.startsWith("@default")){if(z)q.push(z);z={type:"default",content:""},W+=L[0].length}else if(F&&_.startsWith("@break"))W+=F[0].length;else{if(z)z.content+=K[W];W++}}if(z)q.push(z);return{fullMatch:$.slice(Z,G+10),expression:Q.expression,cases:q,start:Z,end:G+10}}var N8=()=>{};var T8=()=>{};var M$=P(()=>{N8();T8()});function yG($,Z,Y){let X=$,Q=!0;while(Q){Q=!1;let J=X.match(/@switch\s*\(/);if(!J||J.index===void 0)break;let G=J.index,K=U7(X,G);if(!K)break;try{let q;if(e(K.expression))q=$0(K.expression,Object.keys(Z))(...Object.values(Z));else q=Y0(K.expression,Z);let W="",z=!1;for(let U of K.cases)if(U.type==="default"){if(!z)W=U.content.trim()}else try{let _;if(U.value&&e(U.value))_=$0(U.value,Object.keys(Z))(...Object.values(Z));else if(U.value)_=Y0(U.value,Z);if(q===_){W=U.content.trim(),z=!0;break}}catch{continue}X=X.substring(0,G)+W+X.substring(K.end),Q=!0}catch(q){let W=q instanceof Error?q.message:String(q),z=s("Switch",`Error evaluating @switch expression: ${W}`,i.EVALUATION_ERROR);X=X.substring(0,G)+z+X.substring(K.end);break}}return X}function N1($,Z,Y){let X=$;X=yG(X,Z,Y);{let J=!0;while(J){J=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,q=X1(X,K+7);if(!q)break;let W=q.endPos,z=R1(X,"unless","endunless",W);if(z===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let U=X.slice(W,z),_=q.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],w;while((w=L.exec(U))!==null)V.push({pos:w.index,type:"open"});while((w=F.exec(U))!==null)V.push({pos:w.index,type:"close"});while((w=O.exec(U))!==null)V.push({pos:w.index,type:"else"});V.sort((A,R)=>A.pos-R.pos);for(let A of V)if(A.type==="open")H++;else if(A.type==="close")H--;else if(A.type==="else"&&H===0){B=A.pos;break}}let j;if(B!==-1){let H=U.slice(0,B),L=U.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${U}@endif`;X=X.substring(0,K)+j+X.substring(z+10),J=!0}}X=B7(X,Z,Y),X=j7(X,Z,Y),X=_7(X,Z);let Q=()=>{let J=H5(X);if(J.length===0)return!1;for(let G=J.length-1;G>=0;G--){let K=J[G];try{let q="",W=!1;for(let z of K.branches){if(W)break;if(z.type==="else")q=z.content,W=!0;else try{let U;if(z.condition&&e(z.condition))U=$0(z.condition,Object.keys(Z))(...Object.values(Z));else if(z.condition)U=Y0(z.condition,Z);if(U)q=z.content,W=!0}catch(U){q=s(z.type==="if"?"If":"Elseif",`Error in @${z.type}(${z.condition}): ${U instanceof Error?U.message:String(U)}`,i.EVALUATION_ERROR),W=!0}}X=X.substring(0,K.start)+q+X.substring(K.end)}catch(q){let W=q instanceof Error?q.message:String(q),z=s("If",`Error processing @if block: ${W}`,i.EVALUATION_ERROR);X=X.substring(0,K.start)+z+X.substring(K.end)}}return!0};while(!0){let J=X;if(!Q())break;if(X===J)break}return X}function M8($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let Y=$[Z];if(Y!=="'"&&Y!=='"')return null;Z++;let X=[];while(Z<$.length){let Q=$[Z];if(Q==="\\"&&Z+1<$.length){X.push($[Z+1]),Z+=2;continue}if(Q===Y){Z++;break}X.push(Q),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:X.join(""),consumed:Z}}function _7($,Z){let Y=$;function X(K,q,W,z){let U=1,_=z,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(_<K.length&&U>0){B.lastIndex=_,j.lastIndex=_;let H=B.exec(K),L=j.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)U++,_=F+H[0].length;else if(O<1/0){if(U--,U===0)return O;_=O+L[0].length}else break}return-1}function Q(K,q,W){let z=0,U=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=U.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=_.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")z++;else if(L.type==="close")z--;else if(L.type==="else"&&z===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let q=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let W=q.index,z,U,_=Y.slice(W+5),B=M8(_);if(B)z=B.value,U=W+5+B.consumed;else U=W+5;let j=X(Y,"auth","endauth",U);if(j===-1){console.warn(`[stx] @auth directive at position ${W} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=Q(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=z?Y1(`auth?.check && auth?.user?.[${z}]`,Z):Y1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let q=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let W=q.index,z,U,_=Y.slice(W+6),B=M8(_);if(B)z=B.value,U=W+6+B.consumed;else U=W+6;let j=X(Y,"guest","endguest",U);if(j===-1){console.warn(`[stx] @guest directive at position ${W} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=Q(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=z?Y1(`!auth?.check || !auth?.user?.[${z}]`,Z):Y1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+9),K=!0}}function J(K,q,W){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let z=[K];if(q)z.push(q);if(W){let U=Y1(W,Z);z.push(U)}return Z.permissions.check(...z)}catch{return!1}return!1}function G(K){let q=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!q)return null;return{ability:q[1],type:q[2],id:q[3]?.trim(),paramsEnd:q[0].length}}for(let K of["can","cannot"]){let q=`end${K}`,W=K==="can"?"elsecan":"elsecannot",z=!0;while(z){z=!1;let U=Y.match(new RegExp(`@${K}\\s*\\(`));if(!U||U.index===void 0)break;let _=U.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let H=_+`@${K}`.length+j.paramsEnd,L=X(Y,K,q,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${q} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${q}(?![a-z])`,"g"),R=new RegExp(`@${W}\\s*\\(`,"g"),N=/@else(?![a-z])/g,T=[],M;while((M=w.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=A.exec(F))!==null)T.push({pos:M.index,type:"close"});while((M=R.exec(F))!==null)T.push({pos:M.index,type:"elseDirective"});while((M=N.exec(F))!==null)T.push({pos:M.index,type:"else"});T.sort((S,C)=>S.pos-C.pos);for(let S of T){if(S.type==="open"){V++;continue}if(S.type==="close"){V--;continue}if(V===0)O.push(S)}let I=[],E=0;for(let S=0;S<O.length;S++){let C=O[S];if(I.push({content:F.slice(E,C.pos),ability:void 0}),C.type==="elseDirective"){let d=F.slice(C.pos+`@${W}`.length),f=G(d);if(f){I[I.length-1]={content:F.slice(E,C.pos)},E=C.pos+`@${W}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=O[S+1],n=m?m.pos:F.length;I.push({content:F.slice(E,n),ability:f.ability,type:f.type,id:f.id}),E=n}}else E=C.pos+5}if(E<F.length){let S=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:F.slice(E),isFinalElse:!0});else if(I.length===0)I.push({content:F.slice(E)})}let D=J(j.ability,j.type,j.id),b=K==="can"?D:!D,k="";if(b)k=I[0]?.content||"";else{let S=!1;for(let C=1;C<I.length;C++){let d=I[C];if(d.isFinalElse){k=d.content,S=!0;break}if(d.ability){let f=J(d.ability,d.type,d.id);if(K==="can"?f:!f){k=d.content,S=!0;break}}}if(!S&&I.length>0){let C=I[I.length-1];if(C.isFinalElse)k=C.content}}Y=Y.substring(0,_)+k+Y.substring(L+`@${q}`.length),z=!0}}return Y}function B7($,Z,Y){let X=$;function Q(J,G,K,q,W){let z=!0;while(z){z=!1;let U=new RegExp(`@${G}\\s*\\(`),_=J.match(U);if(!_||_.index===void 0)break;let B=_.index,j=X1(J,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=R1(J,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${B} has no matching @${K} \u2014 the block was skipped.`);break}let F=J.slice(H,L),O=j.expression,V=-1,w=0,A=0;while(A<F.length){let R=F.indexOf("@",A);if(R===-1)break;let N=F.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){w++,A=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){w--,A=R+1;continue}if(w===0&&/^@else(?![a-z])/.test(N)){V=R;break}A=R+1}try{let R=q(O.trim()),N;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);N=R?T:M}else N=R?F:"";J=J.substring(0,B)+N+J.substring(L+`@${K}`.length),z=!0}catch(R){let N=R instanceof Error?R.message:String(R),T=s(W,`Error processing @${G} directive: ${N}`,i.EVALUATION_ERROR);J=J.substring(0,B)+T+J.substring(L+`@${K}`.length);break}}return J}return X=Q(X,"isset","endisset",(J)=>{let G=Y1(J,Z);return G!==void 0&&G!==null},"Isset"),X=Q(X,"empty","endempty",(J)=>{let G=Y1(J,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),X}function j7($,Z,Y){let X=$,Q="development";function J(G,K,q,W){let z=new RegExp(`@${K}(?![a-z])`,"g"),U=new RegExp(`@${q}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${q}(?![a-z])`),j=G,H=!0;while(H){H=!1,z.lastIndex=0;let L=z.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let D=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!D)break;O+=D[0].length,W=Q===D[2]}let V=1,w=O,A=-1;while(V>0&&w<j.length){z.lastIndex=w,U.lastIndex=w;let D=z.exec(j),b=U.exec(j),k=D?D.index:1/0,S=b?b.index:1/0;if(k<S)V++,w=k+D[0].length;else if(S<1/0){if(V--,V===0){A=S;break}w=S+b[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${q} \u2014 the block was skipped.`);break}let R=j.substring(O,A),N=-1,T=0,M=0;while(M<R.length){let D=R.indexOf("@",M);if(D===-1)break;let b=R.substring(D);if(_.test(b)){T++,M=D+1;continue}if(B.test(b)){T--,M=D+1;continue}if(T===0&&/^@else(?![a-z])/.test(b)){N=D;break}M=D+1}let I;if(N!==-1){let D=R.slice(0,N),b=R.slice(N+5);I=W?D:b}else I=W?R:"";let E=`@${q}`.length;j=j.substring(0,F)+I+j.substring(A+E),H=!0}return j}return X=J(X,"env","endenv",!1),X=J(X,"production","endproduction",Q==="production"),X=J(X,"development","enddevelopment",Q==="development"),X=J(X,"staging","endstaging",Q==="staging"),X=J(X,"testing","endtesting",Q==="testing"),X}var I$=P(()=>{A8();a0();M$();H0()});function D8($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function D$($,Z){if(!$)return Z?.nonceGenerator?.()??D8();let Y=I8.get($);if(!Y)Y=Z?.nonceGenerator?.()??D8(),I8.set($,Y);return Y}function CG($,Z){let Y=[];for(let[X,Q]of Object.entries($)){if(Q===void 0||Q===null)continue;if(typeof Q==="boolean"){if(Q)Y.push(X);continue}if(Array.isArray(Q)){let J=[...Q];if(Z&&(X==="script-src"||X==="style-src"))J=J.filter((G)=>!G.startsWith("'nonce-")),J.push(`'nonce-${Z}'`);if(J.length>0)Y.push(`${X} ${J.join(" ")}`)}}return Y.join("; ")}function E8($,Z){return`<meta http-equiv="Content-Security-Policy" content="${CG($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function k8($,Z,Y){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let X=Z.useNonce?D$(Y,Z):void 0,Q=E8(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
2439
2439
|
${Q}`)}function b8($,Z,Y,X){let Q=$,J=X.csp;if(Q=Q.replace(/@csp\b/g,()=>{if(!J?.enabled||!J.directives)return"<!-- CSP not configured -->";let G=J.useNonce?D$(Z,J):void 0;return E8(J.directives,G)}),Q=Q.replace(/@cspNonce\b/g,()=>{if(!J?.enabled||!J.useNonce)return"";return D$(Z,J)}),J?.enabled&&J.useNonce)Z.cspNonce=D$(Z,J);return Q}var I8;var S8=P(()=>{I8=new WeakMap});import PG from"crypto";function xG($=vG){let Z=PG.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return H7=Z,Z}function fG(){if(!H7)xG();return H7}function gG($=y8){let Z=fG();return`<input type="hidden" name="${$}" value="${Z}">`}function C8($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return gG(X||y8)})}var vG=40,y8="_token",H7=null;var P8=()=>{};async function v8($,Z,Y,X){if(!X.customDirectives||X.customDirectives.length===0)return $;let Q=$;for(let J of X.customDirectives){if(!J.name||typeof J.handler!=="function"){if(X.debug)console.warn("Invalid custom directive:",J);continue}if(J.hasEndTag)Q=await hG(Q,J,Z,Y,X);else Q=await dG(Q,J,Z,Y,X)}return Q}async function hG($,Z,Y,X,Q){let{name:J,handler:G}=Z,K=`@${J}`,q=`@end${J}`,W=$,z=v1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${q}`,"g"),U=[],_=z.exec(W);while(_!==null){let[B,j="",H=""]=_,L=_.index||0;try{let F=j?x8(j):[],O=H.trim(),V=await G(O,F,Y,X);U.push({original:B,processed:V,startIndex:L})}catch(F){let O=F instanceof Error?F.message:String(F);if(Q.debug)console.error(`Error processing custom directive @${J}:`,F);U.push({original:B,processed:s("CustomDirective",`Error in @${J}${j?`(${j})`:""}: ${O}`,i.EVALUATION_ERROR),startIndex:L})}_=z.exec(W)}for(let B=U.length-1;B>=0;B--){let{original:j,processed:H}=U[B];W=W.replace(j,H)}return W}async function dG($,Z,Y,X,Q){let{name:J,handler:G}=Z,K=$,q=v1(`@${J}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),W=[],z=q.exec(K);while(z!==null){let[B,j=""]=z,H=z.index||0;try{let L=x8(j),F=await G("",L,Y,X);W.push({original:B,processed:F,startIndex:H})}catch(L){let F=L instanceof Error?L.message:String(L);if(Q.debug)console.error(`Error processing custom directive @${J}:`,L);W.push({original:B,processed:s("CustomDirective",`Error in @${J}(${j}): ${F}`,i.EVALUATION_ERROR),startIndex:H})}z=q.exec(K)}let U=v1(`@${J}(?!\\w)(?!\\s*\\()`,"g"),_=U.exec(K);while(_!==null){let[B]=_,j=_.index||0;try{let H=await G("",[],Y,X);W.push({original:B,processed:H,startIndex:j})}catch(H){let L=H instanceof Error?H.message:String(H);if(Q.debug)console.error(`Error processing custom directive @${J}:`,H);W.push({original:B,processed:s("CustomDirective",`Error in @${J}: ${L}`,i.EVALUATION_ERROR),startIndex:j})}_=U.exec(K)}for(let B=W.length-1;B>=0;B--){let{original:j,processed:H}=W[B];K=K.replace(j,H)}return K}function x8($){if(!$.trim())return[];let Z=[],Y="",X=!1,Q="";for(let J=0;J<$.length;J++){let G=$[J];if((G==='"'||G==="'")&&(J===0||$[J-1]!=="\\"))if(!X)X=!0,Q=G;else if(G===Q)X=!1;else Y+=G;else if(G===","&&!X)Z.push(Y.trim()),Y="";else Y+=G}if(Y.trim())Z.push(Y.trim());return Z.map((J)=>{let G=J.trim();if(G.startsWith('"')&&G.endsWith('"')||G.startsWith("'")&&G.endsWith("'"))return G.substring(1,G.length-1);return G})}var f8=P(()=>{a0();x1()});var O7={};t(O7,{useTitle:()=>iG,useSeoMeta:()=>k$,usePageTitle:()=>iG,useHead:()=>M1,resetHead:()=>pG,renderHtmlAttrs:()=>oG,renderHead:()=>nG,renderBodyAttrs:()=>sG,processTitleDirective:()=>tG,processMetaDirective:()=>eG,processHeadDirective:()=>aG,getPageMeta:()=>uG,getHead:()=>O5,definePageMeta:()=>cG,applyHead:()=>rG});function O5(){return J1}function uG(){return E$}function pG(){J1={},mG.length=0,E$={}}function M1($){J1=lG(J1,$)}function lG($,Z){return{title:Z.title??$.title,titleTemplate:Z.titleTemplate??$.titleTemplate,base:Z.base??$.base,meta:[...$.meta||[],...Z.meta||[]],link:[...$.link||[],...Z.link||[]],script:[...$.script||[],...Z.script||[]],style:[...$.style||[],...Z.style||[]],htmlAttrs:{...$.htmlAttrs,...Z.htmlAttrs},bodyAttrs:{...$.bodyAttrs,...Z.bodyAttrs}}}function k$($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let q=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:q})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,X=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(X)Z.push({property:"og:description",content:X});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let Q=$.twitterTitle??$.title,J=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(Q)Z.push({name:"twitter:title",content:Q});if(J)Z.push({name:"twitter:description",content:J});if(G)Z.push({name:"twitter:image",content:G});if($.twitterSite)Z.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)Z.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)Z.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)Z.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)Z.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)Z.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let q of $.articleTags)Z.push({property:"article:tag",content:q});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});M1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function cG($){if(E$={...E$,...$},$.title||$.description)k$({title:$.title,description:$.description})}function iG($){let Z=typeof $==="function"?$():$;M1({title:Z})}function nG($=J1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${T1(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,Q])=>`${X}="${T1(Q)}"`).join(" ");Z.push(`<base ${Y}>`)}for(let Y of $.meta||[]){let X=Object.entries(Y).filter(([Q,J])=>J!==void 0).map(([Q,J])=>{return`${Q==="httpEquiv"?"http-equiv":Q}="${T1(String(J))}"`}).join(" ");Z.push(`<meta ${X}>`)}for(let Y of $.link||[]){let X=Object.entries(Y).filter(([Q,J])=>J!==void 0).map(([Q,J])=>`${Q}="${T1(String(J))}"`).join(" ");Z.push(`<link ${X}>`)}for(let Y of $.script||[]){let{content:X,...Q}=Y,J=Object.entries(Q).filter(([G,K])=>K!==void 0).map(([G,K])=>{if(typeof K==="boolean")return K?G:"";return`${G}="${T1(String(K))}"`}).filter(Boolean).join(" ");if(X)Z.push(`<script ${J}>${X}</script>`);else Z.push(`<script ${J}></script>`)}for(let Y of $.style||[]){let X=Y.type?` type="${Y.type}"`:"";Z.push(`<style${X}>${Y.content}</style>`)}return Z.join(`
|
|
2440
2440
|
`)}function oG($=J1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${T1(Y)}"`).join(" ")}function sG($=J1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${T1(Y)}"`).join(" ")}function T1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function rG($=J1){if(typeof document>"u")return;if($.title){let Z=$.title;if($.titleTemplate)Z=typeof $.titleTemplate==="function"?$.titleTemplate(Z):$.titleTemplate.replace("%s",Z);document.title=Z}for(let Z of $.meta||[]){let Y=Z.name?`meta[name="${Z.name}"]`:Z.property?`meta[property="${Z.property}"]`:null;if(Y){let X=document.querySelector(Y);if(!X){if(X=document.createElement("meta"),Z.name)X.setAttribute("name",Z.name);if(Z.property)X.setAttribute("property",Z.property);document.head.appendChild(X)}X.setAttribute("content",Z.content)}}for(let Z of $.link||[]){let Y=`link[rel="${Z.rel}"]${Z.href?`[href="${Z.href}"]`:""}`,X=document.querySelector(Y);if(!X)X=document.createElement("link"),document.head.appendChild(X);for(let[Q,J]of Object.entries(Z))if(J!==void 0)X.setAttribute(Q,String(J))}if($.htmlAttrs)for(let[Z,Y]of Object.entries($.htmlAttrs))document.documentElement.setAttribute(Z,Y);if($.bodyAttrs)for(let[Z,Y]of Object.entries($.bodyAttrs))document.body.setAttribute(Z,Y)}function aG($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,Q)=>{return Z+=Q.trim()+`
|
|
2441
2441
|
`,""}),headContent:Z.trim()}}function tG($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,Q,J)=>{let G=X?Q:Z[(J||"").trim()]??J;return M1({title:G}),""})}function eG($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,Q,J,G,K)=>{let q=J?G:K,W=J?q:Z[(q||"").trim()]??q,U=Q.includes(":")?{property:Q,content:W}:{name:Q,content:W};return M1({meta:[U]}),""})}var J1,mG,E$;var L5=P(()=>{J1={},mG=[],E$={}});import $K from"crypto";function F0($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function b$($,Z,Y,X){let Q=$||Z;return Y?`${Q} ${X}`:Q}function ZK(){return $K.randomUUID()}function S$($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=ZK();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${F0(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),Y=Y.replace(/@method\(['"]([^'"]+)['"]\)/g,(X,Q)=>{let J=Q.toUpperCase();if(Q&&!["GET","POST"].includes(J))return`<input type="hidden" name="_method" value="${F0(J)}">`;return X}),Y}function d8($,Z,Y=h8){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(Q,J,G,K,q,W="")=>{let z=J||G||"POST",U=K||q||"",_=Q1(W),B=z.toUpperCase(),j=["GET","POST"].includes(B)?B:"POST",H=`<form method="${F0(j)}" action="${F0(U)}"${_?` ${_}`:""}>`;if(H+=`
|