@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/ssr.js
CHANGED
|
@@ -3769,7 +3769,7 @@ ${Y}
|
|
|
3769
3769
|
</script>`}function uZ($,Z,Y){if(mZ=0,!ez($))return $;let X=iz($);if(X.length===0)return $;let J=tz($,X),Q=az(X,Z),G=J.lastIndexOf("</body>");if(G!==-1)J=J.slice(0,G)+Q+`
|
|
3770
3770
|
`+J.slice(G);else J+=Q;return J}function tz($,Z){let Y=$;for(let X of Z){let Q=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${$4(X.stateExpr)}["']`,"gi").exec(Y);if(Q)X.id=Q[1],X.selector=`[data-stx-scope="${X.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${$4(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*"${$4(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*'${$4(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 ez($){return/x-data\s*=\s*["']/.test($)}var mZ=0,cz=0;var lZ=P(()=>{r0()});import $q from"fs";import w3 from"path";import{createHighlighter as Zq}from"ts-syntax-highlighter";async function Yq($,Z={}){try{if(!await c($))throw Error(`Markdown file not found: ${$}`);let X=(await $q.promises.stat($)).mtime.getTime();if(Z.cache&&A3.has($)){let W=A3.get($);if(W.updatedAt>=X)return{content:W.content,data:W.data}}let J=await Bun.file($).text(),{data:Q,content:G}=n9(J),K=Z.markdown||U3.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},q=k5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)q=await Xq(q,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let U={content:q,data:Q||{}};if(Z.cache)A3.set($,{...U,updatedAt:X});return U}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 Xq($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!Z4)try{Z4=await Zq({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,z,q,U)=>{let W=U.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),_=q||(Y?"text":"");if(!_)return K;try{if(!Z4.getSupportedLanguages().includes(_))return K;return(await Z4.highlight(W,_,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${q}:`,B)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[z,q,U,W]=K,_=await J(z,q,U,W);Q=Q.replace(z,_)}return Q}async function pZ($,Z,Y="",X={}){return await Jq($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,z,q)=>{try{let U=K;if(!w3.isAbsolute(K))U=w3.resolve(w3.dirname(Y),K);let W={};if(z)try{try{W=JSON.parse(z)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let O=z.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);W[A]=R}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:_,data:B}=await Yq(U,X),j={...Z,...B,...W},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(U){let W=U instanceof Error?U.message:String(U);return J0("Markdown File",`Error including markdown file: ${W}`,Y,$,q,G)}})}async function Jq($,Z,Y){let X=[],J;while((J=Z.exec($))!==null){let K=J[0],z=J.index,q=J;X.push(Y(...q).then((U)=>({match:K,replacement:U,index:z})))}let Q=await Promise.all(X);Q.sort((K,z)=>z.index-K.index);let G=$;for(let{match:K,replacement:z}of Q)G=G.replace(K,()=>z);return G}var A3,Z4=null;var cZ=P(()=>{P5();O0();A3=new Map});function j1($,Z){try{let Y=$.trim();if($0(Y))return Z0(Y,Object.keys(Z))(...Object.values(Z));else return e(Y,Z)}catch{return!1}}var iZ=P(()=>{w0()});class Y4{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]!==`
|
|
3771
3771
|
`)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]===`
|
|
3772
|
-
`)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 F0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,z=!1;while(Q<$.length){let q=$[Q];if(G&&z){z=!1,Q++;continue}if(G&&q==="\\"){z=!0,Q++;continue}if(z=!1,(q==='"'||q==="'"||q==="`")&&!G){G=q,Q++;continue}if(q===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&q==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&q==="}"){K--,Q++;continue}if(q==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(q===Z)J++;else if(q===Y){if(J--,J===0)return Q}Q++}return-1}function nZ($,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 R3($){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 H1($,Z){let Y=Qq($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Qq($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=F0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function C1($,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 z=G.exec($),q=K.exec($),U=z?z.index:1/0,W=q?q.index:1/0;if(U<W)J++,Q=U+z[0].length;else if(W<1/0){if(J--,J===0)return W;Q=W+q[0].length}else break}return-1}function oZ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=H1($,X);if(!J)return null;let Q=J.endPos,G=C1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],q=0,U="if",W=J.expression,_=0,B=0;while(q<K.length){let j=K.indexOf("@",q);if(j===-1)break;q=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,q++;continue}if(/^@endif(?![a-z])/.test(H)){B--,q+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){z.push({type:U,condition:W,content:K.substring(_,q),start:Q+_,end:Q+q});let F=q+L[0].length,O=H1(K,F);if(!O){q++;continue}U="elseif",W=O.expression,q=O.endPos,_=q;continue}else if(/^@else(?![a-z])/.test(H)){z.push({type:U,condition:W,content:K.substring(_,q),start:Q+_,end:Q+q}),U="else",W=void 0,q+=5,_=q;continue}}q++}return z.push({type:U,condition:W,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:z,start:Z,end:G+6}}function v5($){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=oZ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function X4($,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,z=K+Q[0].length-1,q=F0($,"(",")",z);if(q===-1){Q=J.exec($);continue}let U=$.slice(z+1,q),W=q+1,_=C1($,Z,Y,W);if(_===-1){Q=J.exec($);continue}let B=$.slice(W,_),j=_+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:U,content:B,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function N3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=H1($,X);if(!J)return null;let Q=J.endPos,G=C1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],q=0,U=null,W=0;while(q<K.length){let _=K.slice(q),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(W++,U)U.content+=B[0];q+=B[0].length;continue}if(j){if(W--,U)U.content+=j[0];q+=j[0].length;continue}if(W>0){if(U)U.content+=K[q];q++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(U)z.push(U);let O=q+H[0].length,V=H1(K,O);if(!V){q++;continue}U={type:"case",value:V.expression,content:""},q=V.endPos}else if(L&&_.startsWith("@default")){if(U)z.push(U);U={type:"default",content:""},q+=L[0].length}else if(F&&_.startsWith("@break"))q+=F[0].length;else{if(U)U.content+=K[q];q++}}if(U)z.push(U);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:z,start:Z,end:G+10}}var sZ=()=>{};function Gq($){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)==="{{{"?"{{{":"{!!":"{{",z=Q?K==="{{{"?"}}}":"!!}":"}}",q=G+K.length,U=Kq($,q,z);if(U===-1){Y=G+1;continue}let W=$.slice(q,U).trim(),_=U+z.length;Z.push({fullMatch:$.slice(G,_),expression:W,start:G,end:_,isRaw:Q}),Y=_}return Z}function Kq($,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 zq($){let Z=R3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=qq(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function qq($){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=F0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=tZ(G);return{name:X,args:K}}function tZ($){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 Uq($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=F0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function Wq($){let Z=[],X=new Y4($).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 z=K.value;if(J++,J>=X.length)break;let q=X[J];if(q.type==="IDENTIFIER"){let U=q.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let W=J<X.length?X[J].start:$.length,_=rZ(X,J,$);J=_.nextIndex,Z.push({type:"variable",name:U,value:$.slice(W,_.endPos),exported:G,start:K.start,end:_.endPos})}}else if(q.type==="PUNCTUATION"&&(q.value==="{"||q.value==="[")){let U=q.start,W=q.value==="{"?"}":"]",_=F0($,q.value,W,U);if(_!==-1){let B=$.slice(U,_+1);if(J=aZ(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=rZ(X,J,$);J=H.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,H.endPos)}; ${z} ${B} = ${L}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let z=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let q=X[J];if(q.type==="IDENTIFIER"){let U=q.value;J++;let W=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){W=X[J].start;break}J++}if(W!==-1){let _=F0($,"{","}",W);if(_!==-1)Z.push({type:"function",name:U,value:$.slice(z,_+1).replace(/^export\s+/,""),exported:G,start:z,end:_+1}),J=aZ(X,_+1)}}}else J++}return Z}function rZ($,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 aZ($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var eZ=()=>{};var J4=P(()=>{sZ();eZ()});function _q($,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=N3(X,G);if(!K)break;try{let z;if($0(K.expression))z=Z0(K.expression,Object.keys(Z))(...Object.values(Z));else z=e(K.expression,Z);let q="",U=!1;for(let W of K.cases)if(W.type==="default"){if(!U)q=W.content.trim()}else try{let _;if(W.value&&$0(W.value))_=Z0(W.value,Object.keys(Z))(...Object.values(Z));else if(W.value)_=e(W.value,Z);if(z===_){q=W.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+q+X.substring(K.end),J=!0}catch(z){let q=z instanceof Error?z.message:String(z),U=r("Switch",`Error evaluating @switch expression: ${q}`,l.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function v1($,Z,Y){let X=$;X=_q(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,z=H1(X,K+7);if(!z)break;let q=z.endPos,U=C1(X,"unless","endunless",q);if(U===-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 W=X.slice(q,U),_=z.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(W))!==null)V.push({pos:w.index,type:"open"});while((w=F.exec(W))!==null)V.push({pos:w.index,type:"close"});while((w=O.exec(W))!==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=W.slice(0,B),L=W.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${W}@endif`;X=X.substring(0,K)+j+X.substring(U+10),Q=!0}}X=M3(X,Z,Y),X=I3(X,Z,Y),X=T3(X,Z);let J=()=>{let Q=v5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let z="",q=!1;for(let U of K.branches){if(q)break;if(U.type==="else")z=U.content,q=!0;else try{let W;if(U.condition&&$0(U.condition))W=Z0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)W=e(U.condition,Z);if(W)z=U.content,q=!0}catch(W){z=r(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${W instanceof Error?W.message:String(W)}`,l.EVALUATION_ERROR),q=!0}}X=X.substring(0,K.start)+z+X.substring(K.end)}catch(z){let q=z instanceof Error?z.message:String(z),U=r("If",`Error processing @if block: ${q}`,l.EVALUATION_ERROR);X=X.substring(0,K.start)+U+X.substring(K.end)}}return!0};while(J());return X}function $2($){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 T3($,Z){let Y=$;function X(K,z,q,U){let W=1,_=U,B=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${q}(?![a-z])`,"g");while(_<K.length&&W>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)W++,_=F+H[0].length;else if(O<1/0){if(W--,W===0)return O;_=O+L[0].length}else break}return-1}function J(K,z,q){let U=0,W=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${q}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=W.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")U++;else if(L.type==="close")U--;else if(L.type==="else"&&U===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let z=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let q=z.index,U,W,_=Y.slice(q+5),B=$2(_);if(B)U=B.value,W=q+5+B.consumed;else W=q+5;let j=X(Y,"auth","endauth",W);if(j===-1){console.warn(`[stx] @auth directive at position ${q} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(W,j),L=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?j1(`auth?.check && auth?.user?.[${U}]`,Z):j1("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,q)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let z=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let q=z.index,U,W,_=Y.slice(q+6),B=$2(_);if(B)U=B.value,W=q+6+B.consumed;else W=q+6;let j=X(Y,"guest","endguest",W);if(j===-1){console.warn(`[stx] @guest directive at position ${q} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(W,j),L=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?j1(`!auth?.check || !auth?.user?.[${U}]`,Z):j1("!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,q)+O+Y.substring(j+9),K=!0}}function Q(K,z,q){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let U=[K];if(z)U.push(z);if(q){let W=j1(q,Z);U.push(W)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let z=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!z)return null;return{ability:z[1],type:z[2],id:z[3]?.trim(),paramsEnd:z[0].length}}for(let K of["can","cannot"]){let z=`end${K}`,q=K==="can"?"elsecan":"elsecannot",U=!0;while(U){U=!1;let W=Y.match(new RegExp(`@${K}\\s*\\(`));if(!W||W.index===void 0)break;let _=W.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let H=_+`@${K}`.length+j.paramsEnd,L=X(Y,K,z,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${z} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${z}(?![a-z])`,"g"),R=new RegExp(`@${q}\\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((k,y)=>k.pos-y.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 y=O[k];if(I.push({content:F.slice(E,y.pos),ability:void 0}),y.type==="elseDirective"){let h=F.slice(y.pos+`@${q}`.length),f=G(h);if(f){I[I.length-1]={content:F.slice(E,y.pos)},E=y.pos+`@${q}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=O[k+1],o=m?m.pos:F.length;I.push({content:F.slice(E,o),ability:f.ability,type:f.type,id:f.id}),E=o}}else E=y.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),b=K==="can"?D:!D,S="";if(b)S=I[0]?.content||"";else{let k=!1;for(let y=1;y<I.length;y++){let h=I[y];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 y=I[I.length-1];if(y.isFinalElse)S=y.content}}Y=Y.substring(0,_)+S+Y.substring(L+`@${z}`.length),U=!0}}return Y}function M3($,Z,Y){let X=$;function J(Q,G,K,z,q){let U=!0;while(U){U=!1;let W=new RegExp(`@${G}\\s*\\(`),_=Q.match(W);if(!_||_.index===void 0)break;let B=_.index,j=H1(Q,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=C1(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,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=z(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:"";Q=Q.substring(0,B)+N+Q.substring(L+`@${K}`.length),U=!0}catch(R){let N=R instanceof Error?R.message:String(R),T=r(q,`Error processing @${G} directive: ${N}`,l.EVALUATION_ERROR);Q=Q.substring(0,B)+T+Q.substring(L+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=j1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=j1(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 I3($,Z,Y){let X=$,J="development";function Q(G,K,z,q){let U=new RegExp(`@${K}(?![a-z])`,"g"),W=new RegExp(`@${z}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${z}(?![a-z])`),j=G,H=!0;while(H){H=!1,U.lastIndex=0;let L=U.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,q=J===D[2]}let V=1,w=O,A=-1;while(V>0&&w<j.length){U.lastIndex=w,W.lastIndex=w;let D=U.exec(j),b=W.exec(j),S=D?D.index:1/0,k=b?b.index:1/0;if(S<k)V++,w=S+D[0].length;else if(k<1/0){if(V--,V===0){A=k;break}w=k+b[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${z} \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=q?D:b}else I=q?R:"";let E=`@${z}`.length;j=j.substring(0,F)+I+j.substring(A+E),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 Q4=P(()=>{iZ();t0();J4();w0()});function Z2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function x1($,Z){if(!$)return Z?.nonceGenerator?.()??Z2();let Y=D3.get($);if(!Y)Y=Z?.nonceGenerator?.()??Z2(),D3.set($,Y);return Y}function Qw($){D3.delete($)}function Y2($,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 k3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${Y2($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function Gw($){return{enabled:!0,directives:{strict:Bq,moderate:E3,relaxed:jq,api:Hq}[$]||E3,useNonce:$==="strict",addMetaTag:!0}}function Kw($,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:[],z=[...new Set([...K,...J])];Y[Q]=z}}return Y}function X2($,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?x1(Y,Z):void 0,J=k3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
3772
|
+
`)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 F0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,z=!1;while(Q<$.length){let q=$[Q];if(G&&z){z=!1,Q++;continue}if(G&&q==="\\"){z=!0,Q++;continue}if(z=!1,(q==='"'||q==="'"||q==="`")&&!G){G=q,Q++;continue}if(q===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&q==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&q==="}"){K--,Q++;continue}if(q==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(q===Z)J++;else if(q===Y){if(J--,J===0)return Q}Q++}return-1}function nZ($,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 R3($){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 H1($,Z){let Y=Qq($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Qq($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=F0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function C1($,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 z=G.exec($),q=K.exec($),U=z?z.index:1/0,W=q?q.index:1/0;if(U<W)J++,Q=U+z[0].length;else if(W<1/0){if(J--,J===0)return W;Q=W+q[0].length}else break}return-1}function oZ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=H1($,X);if(!J)return null;let Q=J.endPos,G=C1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],q=0,U="if",W=J.expression,_=0,B=0;while(q<K.length){let j=K.indexOf("@",q);if(j===-1)break;q=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,q++;continue}if(/^@endif(?![a-z])/.test(H)){B--,q+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){z.push({type:U,condition:W,content:K.substring(_,q),start:Q+_,end:Q+q});let F=q+L[0].length,O=H1(K,F);if(!O){q++;continue}U="elseif",W=O.expression,q=O.endPos,_=q;continue}else if(/^@else(?![a-z])/.test(H)){z.push({type:U,condition:W,content:K.substring(_,q),start:Q+_,end:Q+q}),U="else",W=void 0,q+=5,_=q;continue}}q++}return z.push({type:U,condition:W,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:z,start:Z,end:G+6}}function v5($){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=oZ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function X4($,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,z=K+Q[0].length-1,q=F0($,"(",")",z);if(q===-1){Q=J.exec($);continue}let U=$.slice(z+1,q),W=q+1,_=C1($,Z,Y,W);if(_===-1){Q=J.exec($);continue}let B=$.slice(W,_),j=_+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:U,content:B,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function N3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=H1($,X);if(!J)return null;let Q=J.endPos,G=C1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],q=0,U=null,W=0;while(q<K.length){let _=K.slice(q),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(W++,U)U.content+=B[0];q+=B[0].length;continue}if(j){if(W--,U)U.content+=j[0];q+=j[0].length;continue}if(W>0){if(U)U.content+=K[q];q++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(U)z.push(U);let O=q+H[0].length,V=H1(K,O);if(!V){q++;continue}U={type:"case",value:V.expression,content:""},q=V.endPos}else if(L&&_.startsWith("@default")){if(U)z.push(U);U={type:"default",content:""},q+=L[0].length}else if(F&&_.startsWith("@break"))q+=F[0].length;else{if(U)U.content+=K[q];q++}}if(U)z.push(U);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:z,start:Z,end:G+10}}var sZ=()=>{};function Gq($){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)==="{{{"?"{{{":"{!!":"{{",z=Q?K==="{{{"?"}}}":"!!}":"}}",q=G+K.length,U=Kq($,q,z);if(U===-1){Y=G+1;continue}let W=$.slice(q,U).trim(),_=U+z.length;Z.push({fullMatch:$.slice(G,_),expression:W,start:G,end:_,isRaw:Q}),Y=_}return Z}function Kq($,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 zq($){let Z=R3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=qq(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function qq($){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=F0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=tZ(G);return{name:X,args:K}}function tZ($){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 Uq($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=F0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function Wq($){let Z=[],X=new Y4($).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 z=K.value;if(J++,J>=X.length)break;let q=X[J];if(q.type==="IDENTIFIER"){let U=q.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let W=J<X.length?X[J].start:$.length,_=rZ(X,J,$);J=_.nextIndex,Z.push({type:"variable",name:U,value:$.slice(W,_.endPos),exported:G,start:K.start,end:_.endPos})}}else if(q.type==="PUNCTUATION"&&(q.value==="{"||q.value==="[")){let U=q.start,W=q.value==="{"?"}":"]",_=F0($,q.value,W,U);if(_!==-1){let B=$.slice(U,_+1);if(J=aZ(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=rZ(X,J,$);J=H.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,H.endPos)}; ${z} ${B} = ${L}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let z=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let q=X[J];if(q.type==="IDENTIFIER"){let U=q.value;J++;let W=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){W=X[J].start;break}J++}if(W!==-1){let _=F0($,"{","}",W);if(_!==-1)Z.push({type:"function",name:U,value:$.slice(z,_+1).replace(/^export\s+/,""),exported:G,start:z,end:_+1}),J=aZ(X,_+1)}}}else J++}return Z}function rZ($,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 aZ($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var eZ=()=>{};var J4=P(()=>{sZ();eZ()});function _q($,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=N3(X,G);if(!K)break;try{let z;if($0(K.expression))z=Z0(K.expression,Object.keys(Z))(...Object.values(Z));else z=e(K.expression,Z);let q="",U=!1;for(let W of K.cases)if(W.type==="default"){if(!U)q=W.content.trim()}else try{let _;if(W.value&&$0(W.value))_=Z0(W.value,Object.keys(Z))(...Object.values(Z));else if(W.value)_=e(W.value,Z);if(z===_){q=W.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+q+X.substring(K.end),J=!0}catch(z){let q=z instanceof Error?z.message:String(z),U=r("Switch",`Error evaluating @switch expression: ${q}`,l.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function v1($,Z,Y){let X=$;X=_q(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,z=H1(X,K+7);if(!z)break;let q=z.endPos,U=C1(X,"unless","endunless",q);if(U===-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 W=X.slice(q,U),_=z.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(W))!==null)V.push({pos:w.index,type:"open"});while((w=F.exec(W))!==null)V.push({pos:w.index,type:"close"});while((w=O.exec(W))!==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=W.slice(0,B),L=W.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${W}@endif`;X=X.substring(0,K)+j+X.substring(U+10),Q=!0}}X=M3(X,Z,Y),X=I3(X,Z,Y),X=T3(X,Z);let J=()=>{let Q=v5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let z="",q=!1;for(let U of K.branches){if(q)break;if(U.type==="else")z=U.content,q=!0;else try{let W;if(U.condition&&$0(U.condition))W=Z0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)W=e(U.condition,Z);if(W)z=U.content,q=!0}catch(W){z=r(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${W instanceof Error?W.message:String(W)}`,l.EVALUATION_ERROR),q=!0}}X=X.substring(0,K.start)+z+X.substring(K.end)}catch(z){let q=z instanceof Error?z.message:String(z),U=r("If",`Error processing @if block: ${q}`,l.EVALUATION_ERROR);X=X.substring(0,K.start)+U+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function $2($){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 T3($,Z){let Y=$;function X(K,z,q,U){let W=1,_=U,B=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${q}(?![a-z])`,"g");while(_<K.length&&W>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)W++,_=F+H[0].length;else if(O<1/0){if(W--,W===0)return O;_=O+L[0].length}else break}return-1}function J(K,z,q){let U=0,W=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${q}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=W.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")U++;else if(L.type==="close")U--;else if(L.type==="else"&&U===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let z=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let q=z.index,U,W,_=Y.slice(q+5),B=$2(_);if(B)U=B.value,W=q+5+B.consumed;else W=q+5;let j=X(Y,"auth","endauth",W);if(j===-1){console.warn(`[stx] @auth directive at position ${q} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(W,j),L=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?j1(`auth?.check && auth?.user?.[${U}]`,Z):j1("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,q)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let z=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let q=z.index,U,W,_=Y.slice(q+6),B=$2(_);if(B)U=B.value,W=q+6+B.consumed;else W=q+6;let j=X(Y,"guest","endguest",W);if(j===-1){console.warn(`[stx] @guest directive at position ${q} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(W,j),L=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?j1(`!auth?.check || !auth?.user?.[${U}]`,Z):j1("!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,q)+O+Y.substring(j+9),K=!0}}function Q(K,z,q){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let U=[K];if(z)U.push(z);if(q){let W=j1(q,Z);U.push(W)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let z=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!z)return null;return{ability:z[1],type:z[2],id:z[3]?.trim(),paramsEnd:z[0].length}}for(let K of["can","cannot"]){let z=`end${K}`,q=K==="can"?"elsecan":"elsecannot",U=!0;while(U){U=!1;let W=Y.match(new RegExp(`@${K}\\s*\\(`));if(!W||W.index===void 0)break;let _=W.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let H=_+`@${K}`.length+j.paramsEnd,L=X(Y,K,z,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${z} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${z}(?![a-z])`,"g"),R=new RegExp(`@${q}\\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((k,y)=>k.pos-y.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 y=O[k];if(I.push({content:F.slice(E,y.pos),ability:void 0}),y.type==="elseDirective"){let h=F.slice(y.pos+`@${q}`.length),f=G(h);if(f){I[I.length-1]={content:F.slice(E,y.pos)},E=y.pos+`@${q}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=O[k+1],o=m?m.pos:F.length;I.push({content:F.slice(E,o),ability:f.ability,type:f.type,id:f.id}),E=o}}else E=y.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),b=K==="can"?D:!D,S="";if(b)S=I[0]?.content||"";else{let k=!1;for(let y=1;y<I.length;y++){let h=I[y];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 y=I[I.length-1];if(y.isFinalElse)S=y.content}}Y=Y.substring(0,_)+S+Y.substring(L+`@${z}`.length),U=!0}}return Y}function M3($,Z,Y){let X=$;function J(Q,G,K,z,q){let U=!0;while(U){U=!1;let W=new RegExp(`@${G}\\s*\\(`),_=Q.match(W);if(!_||_.index===void 0)break;let B=_.index,j=H1(Q,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=C1(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,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=z(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:"";Q=Q.substring(0,B)+N+Q.substring(L+`@${K}`.length),U=!0}catch(R){let N=R instanceof Error?R.message:String(R),T=r(q,`Error processing @${G} directive: ${N}`,l.EVALUATION_ERROR);Q=Q.substring(0,B)+T+Q.substring(L+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=j1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=j1(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 I3($,Z,Y){let X=$,J="development";function Q(G,K,z,q){let U=new RegExp(`@${K}(?![a-z])`,"g"),W=new RegExp(`@${z}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${z}(?![a-z])`),j=G,H=!0;while(H){H=!1,U.lastIndex=0;let L=U.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,q=J===D[2]}let V=1,w=O,A=-1;while(V>0&&w<j.length){U.lastIndex=w,W.lastIndex=w;let D=U.exec(j),b=W.exec(j),S=D?D.index:1/0,k=b?b.index:1/0;if(S<k)V++,w=S+D[0].length;else if(k<1/0){if(V--,V===0){A=k;break}w=k+b[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${z} \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=q?D:b}else I=q?R:"";let E=`@${z}`.length;j=j.substring(0,F)+I+j.substring(A+E),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 Q4=P(()=>{iZ();t0();J4();w0()});function Z2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function x1($,Z){if(!$)return Z?.nonceGenerator?.()??Z2();let Y=D3.get($);if(!Y)Y=Z?.nonceGenerator?.()??Z2(),D3.set($,Y);return Y}function Qw($){D3.delete($)}function Y2($,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 k3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${Y2($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function Gw($){return{enabled:!0,directives:{strict:Bq,moderate:E3,relaxed:jq,api:Hq}[$]||E3,useNonce:$==="strict",addMetaTag:!0}}function Kw($,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:[],z=[...new Set([...K,...J])];Y[Q]=z}}return Y}function X2($,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?x1(Y,Z):void 0,J=k3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
3773
3773
|
${J}`)}function zw($,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 J2($,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?x1(Z,Q):void 0;return k3(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return x1(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=x1(Z,Q);return J}function qw(){return[Oq,Lq]}function Uw($){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 Fq($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function Ww($,Z){if(!$.enabled)return{};let Y=$.useNonce?x1(Z,$):void 0,X=Y2($.directives,Y);return{[Fq($.reportOnly)]:X}}var D3,Bq,E3,jq,Hq,Oq,Lq,_w;var Q2=P(()=>{D3=new WeakMap;Bq={"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},E3={"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},jq={"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'"]},Hq={"default-src":["'none'"],"frame-ancestors":["'none'"]};Oq={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?x1(Y,Q):void 0;return k3(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},Lq={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return x1(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};_w={enabled:!1,reportOnly:!1,directives:E3,useNonce:!1,addMetaTag:!0}});import{Buffer as G2}from"buffer";import K2 from"crypto";function wq($=Vq){let Z=K2.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return z5=Z,Z}function Aq(){if(!z5)wq();return z5}function Ow(){z5=null}function Lw($){z5=$}function Rq($=z2){let Z=Aq();return`<input type="hidden" name="${$}" value="${Z}">`}function q2($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return Rq(X||z2)})}function Fw($,Z){let Y=Z??z5;if(!Y)return!1;let X=G2.from($),J=G2.from(Y);if(X.length!==J.length)return!1;return K2.timingSafeEqual(X,J)}var Vq=40,z2="_token",z5=null;var U2=()=>{};async function W2($,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 Nq(J,Q,Z,Y,X);else J=await Tq(J,Q,Z,Y,X)}return J}async function Nq($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,z=`@end${Q}`,q=$,U=D1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${z}`,"g"),W=[],_=U.exec(q);while(_!==null){let[B,j="",H=""]=_,L=_.index||0;try{let F=j?_2(j):[],O=H.trim(),V=await G(O,F,Y,X);W.push({original:B,processed:V,startIndex:L})}catch(F){let O=F instanceof Error?F.message:String(F);if(J.debug)console.error(`Error processing custom directive @${Q}:`,F);W.push({original:B,processed:r("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${O}`,l.EVALUATION_ERROR),startIndex:L})}_=U.exec(q)}for(let B=W.length-1;B>=0;B--){let{original:j,processed:H}=W[B];q=q.replace(j,H)}return q}async function Tq($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,z=D1(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),q=[],U=z.exec(K);while(U!==null){let[B,j=""]=U,H=U.index||0;try{let L=_2(j),F=await G("",L,Y,X);q.push({original:B,processed:F,startIndex:H})}catch(L){let F=L instanceof Error?L.message:String(L);if(J.debug)console.error(`Error processing custom directive @${Q}:`,L);q.push({original:B,processed:r("CustomDirective",`Error in @${Q}(${j}): ${F}`,l.EVALUATION_ERROR),startIndex:H})}U=z.exec(K)}let W=D1(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),_=W.exec(K);while(_!==null){let[B]=_,j=_.index||0;try{let H=await G("",[],Y,X);q.push({original:B,processed:H,startIndex:j})}catch(H){let L=H instanceof Error?H.message:String(H);if(J.debug)console.error(`Error processing custom directive @${Q}:`,H);q.push({original:B,processed:r("CustomDirective",`Error in @${Q}: ${L}`,l.EVALUATION_ERROR),startIndex:j})}_=W.exec(K)}for(let B=q.length-1;B>=0;B--){let{original:j,processed:H}=q[B];K=K.replace(j,H)}return K}function _2($){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 B2=P(()=>{t0();a1()});var b3={};i(b3,{useTitle:()=>bq,useSeoMeta:()=>K4,usePageTitle:()=>bq,useHead:()=>g1,resetHead:()=>Dq,renderHtmlAttrs:()=>yq,renderHead:()=>Sq,renderBodyAttrs:()=>Pq,processTitleDirective:()=>xq,processMetaDirective:()=>fq,processHeadDirective:()=>vq,getPageMeta:()=>Iq,getHead:()=>x5,definePageMeta:()=>kq,applyHead:()=>Cq});function x5(){return O1}function Iq(){return G4}function Dq(){O1={},Mq.length=0,G4={}}function g1($){O1=Eq(O1,$)}function Eq($,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 K4($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let z=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:z})}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 z of $.articleTags)Z.push({property:"article:tag",content:z});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});g1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function kq($){if(G4={...G4,...$},$.title||$.description)K4({title:$.title,description:$.description})}function bq($){let Z=typeof $==="function"?$():$;g1({title:Z})}function Sq($=O1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${f1(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${f1(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}="${f1(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}="${f1(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}="${f1(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(`
|
|
3774
3774
|
`)}function yq($=O1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${f1(Y)}"`).join(" ")}function Pq($=O1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${f1(Y)}"`).join(" ")}function f1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Cq($=O1){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 vq($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
|
|
3775
3775
|
`,""}),headContent:Z.trim()}}function xq($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return g1({title:G}),""})}function fq($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let z=Q?G:K,q=Q?z:Z[(z||"").trim()]??z,W=J.includes(":")?{property:J,content:q}:{name:J,content:q};return g1({meta:[W]}),""})}var O1,Mq,G4;var f5=P(()=>{O1={},Mq=[],G4={}});import gq from"crypto";function A0($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function hq($){return{...S3,...$.forms?.classes}}function z4($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function dq(){return gq.randomUUID()}function Mw($,Z,Y,X){let J=hq(X),Q=$;return Q=uq(Q,Z),Q=d5(Q,Z),Q=y3(Q,Z,J),Q=P3(Q,Z,J),Q}function d5($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=dq();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${A0(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="${A0(Q)}">`;return X}),Y}function y3($,Z,Y=S3){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,z,q="")=>{let U=Q||G||"POST",W=K||z||"",_=L1(q),B=U.toUpperCase(),j=["GET","POST"].includes(B)?B:"POST",H=`<form method="${A0(j)}" action="${A0(W)}"${_?` ${_}`:""}>`;if(H+=`
|
package/dist/story/cli.js
CHANGED
|
@@ -3769,7 +3769,7 @@ ${Y}
|
|
|
3769
3769
|
</script>`}function pY($,Z,Y){if(lY=0,!dU($))return $;let X=CU($);if(X.length===0)return $;let J=hU($,X),Q=gU(X,Z),G=J.lastIndexOf("</body>");if(G!==-1)J=J.slice(0,G)+Q+`
|
|
3770
3770
|
`+J.slice(G);else J+=Q;return J}function hU($,Z){let Y=$;for(let X of Z){let Q=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${b4(X.stateExpr)}["']`,"gi").exec(Y);if(Q)X.id=Q[1],X.selector=`[data-stx-scope="${X.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${b4(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*"${b4(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*'${b4(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 dU($){return/x-data\s*=\s*["']/.test($)}var lY=0,PU=0;var cY=P(()=>{Y1()});import uU from"fs";import Z3 from"path";import{createHighlighter as mU}from"ts-syntax-highlighter";async function lU($,Z={}){try{if(!await i($))throw Error(`Markdown file not found: ${$}`);let X=(await uU.promises.stat($)).mtime.getTime();if(Z.cache&&Y3.has($)){let _=Y3.get($);if(_.updatedAt>=X)return{content:_.content,data:_.data}}let J=await Bun.file($).text(),{data:Q,content:G}=o8(J),K=Z.markdown||c6.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},W=n5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)W=await pU(W,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let U={content:W,data:Q||{}};if(Z.cache)Y3.set($,{...U,updatedAt:X});return U}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:Q0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function pU($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!P4)try{P4=await mU({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,z,W,U)=>{let _=U.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),q=W||(Y?"text":"");if(!q)return K;try{if(!P4.getSupportedLanguages().includes(q))return K;return(await P4.highlight(_,q,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${W}:`,B)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[z,W,U,_]=K,q=await J(z,W,U,_);Q=Q.replace(z,q)}return Q}async function iY($,Z,Y="",X={}){return await cU($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,z,W)=>{try{let U=K;if(!Z3.isAbsolute(K))U=Z3.resolve(Z3.dirname(Y),K);let _={};if(z)try{try{_=JSON.parse(z)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let O=z.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let A=V.indexOf(":");if(A>0){let w=V.substring(0,A).trim(),R=V.substring(A+1).trim(),N=R.startsWith('"')&&R.endsWith('"'),T=R.startsWith("'")&&R.endsWith("'");if(N||T)R=R.substring(1,R.length-1);_[w]=R}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:q,data:B}=await lU(U,X),j={...Z,...B,..._},H=q,L=/\{\{([^}]+)\}\}/g;return H=H.replace(L,(F,O)=>{let V=O.trim();return j[V]!==void 0?String(j[V]):F}),H}catch(U){let _=U instanceof Error?U.message:String(U);return Q0("Markdown File",`Error including markdown file: ${_}`,Y,$,W,G)}})}async function cU($,Z,Y){let X=[],J;while((J=Z.exec($))!==null){let K=J[0],z=J.index,W=J;X.push(Y(...W).then((U)=>({match:K,replacement:U,index:z})))}let Q=await Promise.all(X);Q.sort((K,z)=>z.index-K.index);let G=$;for(let{match:K,replacement:z}of Q)G=G.replace(K,()=>z);return G}var Y3,P4=null;var nY=P(()=>{a5();L0();Y3=new Map});function w1($,Z){try{let Y=$.trim();if($0(Y))return Z0(Y,Object.keys(Z))(...Object.values(Z));else return e(Y,Z)}catch{return!1}}var sY=P(()=>{A0()});class C4{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]!==`
|
|
3771
3771
|
`)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]===`
|
|
3772
|
-
`)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 V0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,z=!1;while(Q<$.length){let W=$[Q];if(G&&z){z=!1,Q++;continue}if(G&&W==="\\"){z=!0,Q++;continue}if(z=!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)J++;else if(W===Y){if(J--,J===0)return Q}Q++}return-1}function oY($,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 X3($){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 A1($,Z){let Y=iU($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function iU($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=V0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function l1($,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 z=G.exec($),W=K.exec($),U=z?z.index:1/0,_=W?W.index:1/0;if(U<_)J++,Q=U+z[0].length;else if(_<1/0){if(J--,J===0)return _;Q=_+W[0].length}else break}return-1}function rY($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=A1($,X);if(!J)return null;let Q=J.endPos,G=l1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],W=0,U="if",_=J.expression,q=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){z.push({type:U,condition:_,content:K.substring(q,W),start:Q+q,end:Q+W});let F=W+L[0].length,O=A1(K,F);if(!O){W++;continue}U="elseif",_=O.expression,W=O.endPos,q=W;continue}else if(/^@else(?![a-z])/.test(H)){z.push({type:U,condition:_,content:K.substring(q,W),start:Q+q,end:Q+W}),U="else",_=void 0,W+=5,q=W;continue}}W++}return z.push({type:U,condition:_,content:K.slice(q),start:Q+q,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:z,start:Z,end:G+6}}function e5($){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=rY($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function y4($,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,z=K+Q[0].length-1,W=V0($,"(",")",z);if(W===-1){Q=J.exec($);continue}let U=$.slice(z+1,W),_=W+1,q=l1($,Z,Y,_);if(q===-1){Q=J.exec($);continue}let B=$.slice(_,q),j=q+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:U,content:B,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function J3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=A1($,X);if(!J)return null;let Q=J.endPos,G=l1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],W=0,U=null,_=0;while(W<K.length){let q=K.slice(W),B=q.match(/^@switch\s*\(/),j=q.match(/^@endswitch(?![a-z])/);if(B){if(_++,U)U.content+=B[0];W+=B[0].length;continue}if(j){if(_--,U)U.content+=j[0];W+=j[0].length;continue}if(_>0){if(U)U.content+=K[W];W++;continue}let H=q.match(/^@case\s*/),L=q.match(/^@default(?![a-z])/),F=q.match(/^@break(?![a-z])/);if(H&&q.startsWith("@case")){if(U)z.push(U);let O=W+H[0].length,V=A1(K,O);if(!V){W++;continue}U={type:"case",value:V.expression,content:""},W=V.endPos}else if(L&&q.startsWith("@default")){if(U)z.push(U);U={type:"default",content:""},W+=L[0].length}else if(F&&q.startsWith("@break"))W+=F[0].length;else{if(U)U.content+=K[W];W++}}if(U)z.push(U);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:z,start:Z,end:G+10}}var aY=()=>{};function nU($){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)==="{{{"?"{{{":"{!!":"{{",z=Q?K==="{{{"?"}}}":"!!}":"}}",W=G+K.length,U=sU($,W,z);if(U===-1){Y=G+1;continue}let _=$.slice(W,U).trim(),q=U+z.length;Z.push({fullMatch:$.slice(G,q),expression:_,start:G,end:q,isRaw:Q}),Y=q}return Z}function sU($,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 oU($){let Z=X3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=rU(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function rU($){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=V0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=$2(G);return{name:X,args:K}}function $2($){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 aU($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=V0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function tU($){let Z=[],X=new C4($).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 z=K.value;if(J++,J>=X.length)break;let W=X[J];if(W.type==="IDENTIFIER"){let U=W.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let _=J<X.length?X[J].start:$.length,q=tY(X,J,$);J=q.nextIndex,Z.push({type:"variable",name:U,value:$.slice(_,q.endPos),exported:G,start:K.start,end:q.endPos})}}else if(W.type==="PUNCTUATION"&&(W.value==="{"||W.value==="[")){let U=W.start,_=W.value==="{"?"}":"]",q=V0($,W.value,_,U);if(q!==-1){let B=$.slice(U,q+1);if(J=eY(X,q+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=tY(X,J,$);J=H.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,H.endPos)}; ${z} ${B} = ${L}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let z=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let W=X[J];if(W.type==="IDENTIFIER"){let U=W.value;J++;let _=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){_=X[J].start;break}J++}if(_!==-1){let q=V0($,"{","}",_);if(q!==-1)Z.push({type:"function",name:U,value:$.slice(z,q+1).replace(/^export\s+/,""),exported:G,start:z,end:q+1}),J=eY(X,q+1)}}}else J++}return Z}function tY($,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 eY($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var Z2=()=>{};var v4=P(()=>{aY();Z2()});function eU($,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=J3(X,G);if(!K)break;try{let z;if($0(K.expression))z=Z0(K.expression,Object.keys(Z))(...Object.values(Z));else z=e(K.expression,Z);let W="",U=!1;for(let _ of K.cases)if(_.type==="default"){if(!U)W=_.content.trim()}else try{let q;if(_.value&&$0(_.value))q=Z0(_.value,Object.keys(Z))(...Object.values(Z));else if(_.value)q=e(_.value,Z);if(z===q){W=_.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+W+X.substring(K.end),J=!0}catch(z){let W=z instanceof Error?z.message:String(z),U=r("Switch",`Error evaluating @switch expression: ${W}`,p.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function p1($,Z,Y){let X=$;X=eU(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,z=A1(X,K+7);if(!z)break;let W=z.endPos,U=l1(X,"unless","endunless",W);if(U===-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 _=X.slice(W,U),q=z.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],A;while((A=L.exec(_))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(_))!==null)V.push({pos:A.index,type:"close"});while((A=O.exec(_))!==null)V.push({pos:A.index,type:"else"});V.sort((w,R)=>w.pos-R.pos);for(let w of V)if(w.type==="open")H++;else if(w.type==="close")H--;else if(w.type==="else"&&H===0){B=w.pos;break}}let j;if(B!==-1){let H=_.slice(0,B),L=_.slice(B+5);j=`@if (${q})${L}@else ${H}@endif`}else j=`@if (!(${q}))${_}@endif`;X=X.substring(0,K)+j+X.substring(U+10),Q=!0}}X=G3(X,Z,Y),X=K3(X,Z,Y),X=Q3(X,Z);let J=()=>{let Q=e5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let z="",W=!1;for(let U of K.branches){if(W)break;if(U.type==="else")z=U.content,W=!0;else try{let _;if(U.condition&&$0(U.condition))_=Z0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)_=e(U.condition,Z);if(_)z=U.content,W=!0}catch(_){z=r(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${_ instanceof Error?_.message:String(_)}`,p.EVALUATION_ERROR),W=!0}}X=X.substring(0,K.start)+z+X.substring(K.end)}catch(z){let W=z instanceof Error?z.message:String(z),U=r("If",`Error processing @if block: ${W}`,p.EVALUATION_ERROR);X=X.substring(0,K.start)+U+X.substring(K.end)}}return!0};while(J());return X}function Y2($){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 Q3($,Z){let Y=$;function X(K,z,W,U){let _=1,q=U,B=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(q<K.length&&_>0){B.lastIndex=q,j.lastIndex=q;let H=B.exec(K),L=j.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)_++,q=F+H[0].length;else if(O<1/0){if(_--,_===0)return O;q=O+L[0].length}else break}return-1}function J(K,z,W){let U=0,_=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),q=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=_.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=q.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")U++;else if(L.type==="close")U--;else if(L.type==="else"&&U===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let z=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let W=z.index,U,_,q=Y.slice(W+5),B=Y2(q);if(B)U=B.value,_=W+5+B.consumed;else _=W+5;let j=X(Y,"auth","endauth",_);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(_,j),L=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?w1(`auth?.check && auth?.user?.[${U}]`,Z):w1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let z=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let W=z.index,U,_,q=Y.slice(W+6),B=Y2(q);if(B)U=B.value,_=W+6+B.consumed;else _=W+6;let j=X(Y,"guest","endguest",_);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(_,j),L=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?w1(`!auth?.check || !auth?.user?.[${U}]`,Z):w1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+9),K=!0}}function Q(K,z,W){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let U=[K];if(z)U.push(z);if(W){let _=w1(W,Z);U.push(_)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let z=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!z)return null;return{ability:z[1],type:z[2],id:z[3]?.trim(),paramsEnd:z[0].length}}for(let K of["can","cannot"]){let z=`end${K}`,W=K==="can"?"elsecan":"elsecannot",U=!0;while(U){U=!1;let _=Y.match(new RegExp(`@${K}\\s*\\(`));if(!_||_.index===void 0)break;let q=_.index,B=Y.slice(q+`@${K}`.length),j=G(B);if(!j)break;let H=q+`@${K}`.length+j.paramsEnd,L=X(Y,K,z,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${q} has no matching @${z} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${z}(?![a-z])`,"g"),R=new RegExp(`@${W}\\s*\\(`,"g"),N=/@else(?![a-z])/g,T=[],M;while((M=A.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=w.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((b,C)=>b.pos-C.pos);for(let b of T){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)O.push(b)}let D=[],I=0;for(let b=0;b<O.length;b++){let C=O[b];if(D.push({content:F.slice(I,C.pos),ability:void 0}),C.type==="elseDirective"){let d=F.slice(C.pos+`@${W}`.length),f=G(d);if(f){D[D.length-1]={content:F.slice(I,C.pos)},I=C.pos+`@${W}`.length+f.paramsEnd,D.push({content:"",ability:f.ability,type:f.type,id:f.id}),D.pop();let u=O[b+1],s=u?u.pos:F.length;D.push({content:F.slice(I,s),ability:f.ability,type:f.type,id:f.id}),I=s}}else I=C.pos+5}if(I<F.length){let b=D[D.length-1];if(O.length>0&&O[O.length-1].type==="else")D.push({content:F.slice(I),isFinalElse:!0});else if(D.length===0)D.push({content:F.slice(I)})}let E=Q(j.ability,j.type,j.id),k=K==="can"?E:!E,S="";if(k)S=D[0]?.content||"";else{let b=!1;for(let C=1;C<D.length;C++){let d=D[C];if(d.isFinalElse){S=d.content,b=!0;break}if(d.ability){let f=Q(d.ability,d.type,d.id);if(K==="can"?f:!f){S=d.content,b=!0;break}}}if(!b&&D.length>0){let C=D[D.length-1];if(C.isFinalElse)S=C.content}}Y=Y.substring(0,q)+S+Y.substring(L+`@${z}`.length),U=!0}}return Y}function G3($,Z,Y){let X=$;function J(Q,G,K,z,W){let U=!0;while(U){U=!1;let _=new RegExp(`@${G}\\s*\\(`),q=Q.match(_);if(!q||q.index===void 0)break;let B=q.index,j=A1(Q,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=l1(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,A=0,w=0;while(w<F.length){let R=F.indexOf("@",w);if(R===-1)break;let N=F.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){A++,w=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){A--,w=R+1;continue}if(A===0&&/^@else(?![a-z])/.test(N)){V=R;break}w=R+1}try{let R=z(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:"";Q=Q.substring(0,B)+N+Q.substring(L+`@${K}`.length),U=!0}catch(R){let N=R instanceof Error?R.message:String(R),T=r(W,`Error processing @${G} directive: ${N}`,p.EVALUATION_ERROR);Q=Q.substring(0,B)+T+Q.substring(L+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=w1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=w1(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 K3($,Z,Y){let X=$,J="development";function Q(G,K,z,W){let U=new RegExp(`@${K}(?![a-z])`,"g"),_=new RegExp(`@${z}(?![a-z])`,"g"),q=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${z}(?![a-z])`),j=G,H=!0;while(H){H=!1,U.lastIndex=0;let L=U.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let E=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!E)break;O+=E[0].length,W=J===E[2]}let V=1,A=O,w=-1;while(V>0&&A<j.length){U.lastIndex=A,_.lastIndex=A;let E=U.exec(j),k=_.exec(j),S=E?E.index:1/0,b=k?k.index:1/0;if(S<b)V++,A=S+E[0].length;else if(b<1/0){if(V--,V===0){w=b;break}A=b+k[0].length}else break}if(w===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${z} \u2014 the block was skipped.`);break}let R=j.substring(O,w),N=-1,T=0,M=0;while(M<R.length){let E=R.indexOf("@",M);if(E===-1)break;let k=R.substring(E);if(q.test(k)){T++,M=E+1;continue}if(B.test(k)){T--,M=E+1;continue}if(T===0&&/^@else(?![a-z])/.test(k)){N=E;break}M=E+1}let D;if(N!==-1){let E=R.slice(0,N),k=R.slice(N+5);D=W?E:k}else D=W?R:"";let I=`@${z}`.length;j=j.substring(0,F)+D+j.substring(w+I),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 x4=P(()=>{sY();U1();v4();A0()});function X2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function c1($,Z){if(!$)return Z?.nonceGenerator?.()??X2();let Y=z3.get($);if(!Y)Y=Z?.nonceGenerator?.()??X2(),z3.set($,Y);return Y}function bR($){z3.delete($)}function J2($,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 U3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${J2($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function PR($){return{enabled:!0,directives:{strict:$_,moderate:W3,relaxed:Z_,api:Y_}[$]||W3,useNonce:$==="strict",addMetaTag:!0}}function CR($,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:[],z=[...new Set([...K,...J])];Y[Q]=z}}return Y}function Q2($,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?c1(Y,Z):void 0,J=U3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
3772
|
+
`)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 V0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,z=!1;while(Q<$.length){let W=$[Q];if(G&&z){z=!1,Q++;continue}if(G&&W==="\\"){z=!0,Q++;continue}if(z=!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)J++;else if(W===Y){if(J--,J===0)return Q}Q++}return-1}function oY($,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 X3($){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 A1($,Z){let Y=iU($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function iU($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=V0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function l1($,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 z=G.exec($),W=K.exec($),U=z?z.index:1/0,_=W?W.index:1/0;if(U<_)J++,Q=U+z[0].length;else if(_<1/0){if(J--,J===0)return _;Q=_+W[0].length}else break}return-1}function rY($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=A1($,X);if(!J)return null;let Q=J.endPos,G=l1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],W=0,U="if",_=J.expression,q=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){z.push({type:U,condition:_,content:K.substring(q,W),start:Q+q,end:Q+W});let F=W+L[0].length,O=A1(K,F);if(!O){W++;continue}U="elseif",_=O.expression,W=O.endPos,q=W;continue}else if(/^@else(?![a-z])/.test(H)){z.push({type:U,condition:_,content:K.substring(q,W),start:Q+q,end:Q+W}),U="else",_=void 0,W+=5,q=W;continue}}W++}return z.push({type:U,condition:_,content:K.slice(q),start:Q+q,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:z,start:Z,end:G+6}}function e5($){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=rY($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function y4($,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,z=K+Q[0].length-1,W=V0($,"(",")",z);if(W===-1){Q=J.exec($);continue}let U=$.slice(z+1,W),_=W+1,q=l1($,Z,Y,_);if(q===-1){Q=J.exec($);continue}let B=$.slice(_,q),j=q+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:U,content:B,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function J3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=A1($,X);if(!J)return null;let Q=J.endPos,G=l1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],W=0,U=null,_=0;while(W<K.length){let q=K.slice(W),B=q.match(/^@switch\s*\(/),j=q.match(/^@endswitch(?![a-z])/);if(B){if(_++,U)U.content+=B[0];W+=B[0].length;continue}if(j){if(_--,U)U.content+=j[0];W+=j[0].length;continue}if(_>0){if(U)U.content+=K[W];W++;continue}let H=q.match(/^@case\s*/),L=q.match(/^@default(?![a-z])/),F=q.match(/^@break(?![a-z])/);if(H&&q.startsWith("@case")){if(U)z.push(U);let O=W+H[0].length,V=A1(K,O);if(!V){W++;continue}U={type:"case",value:V.expression,content:""},W=V.endPos}else if(L&&q.startsWith("@default")){if(U)z.push(U);U={type:"default",content:""},W+=L[0].length}else if(F&&q.startsWith("@break"))W+=F[0].length;else{if(U)U.content+=K[W];W++}}if(U)z.push(U);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:z,start:Z,end:G+10}}var aY=()=>{};function nU($){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)==="{{{"?"{{{":"{!!":"{{",z=Q?K==="{{{"?"}}}":"!!}":"}}",W=G+K.length,U=sU($,W,z);if(U===-1){Y=G+1;continue}let _=$.slice(W,U).trim(),q=U+z.length;Z.push({fullMatch:$.slice(G,q),expression:_,start:G,end:q,isRaw:Q}),Y=q}return Z}function sU($,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 oU($){let Z=X3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=rU(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function rU($){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=V0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=$2(G);return{name:X,args:K}}function $2($){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 aU($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=V0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function tU($){let Z=[],X=new C4($).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 z=K.value;if(J++,J>=X.length)break;let W=X[J];if(W.type==="IDENTIFIER"){let U=W.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let _=J<X.length?X[J].start:$.length,q=tY(X,J,$);J=q.nextIndex,Z.push({type:"variable",name:U,value:$.slice(_,q.endPos),exported:G,start:K.start,end:q.endPos})}}else if(W.type==="PUNCTUATION"&&(W.value==="{"||W.value==="[")){let U=W.start,_=W.value==="{"?"}":"]",q=V0($,W.value,_,U);if(q!==-1){let B=$.slice(U,q+1);if(J=eY(X,q+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=tY(X,J,$);J=H.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,H.endPos)}; ${z} ${B} = ${L}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let z=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let W=X[J];if(W.type==="IDENTIFIER"){let U=W.value;J++;let _=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){_=X[J].start;break}J++}if(_!==-1){let q=V0($,"{","}",_);if(q!==-1)Z.push({type:"function",name:U,value:$.slice(z,q+1).replace(/^export\s+/,""),exported:G,start:z,end:q+1}),J=eY(X,q+1)}}}else J++}return Z}function tY($,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 eY($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var Z2=()=>{};var v4=P(()=>{aY();Z2()});function eU($,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=J3(X,G);if(!K)break;try{let z;if($0(K.expression))z=Z0(K.expression,Object.keys(Z))(...Object.values(Z));else z=e(K.expression,Z);let W="",U=!1;for(let _ of K.cases)if(_.type==="default"){if(!U)W=_.content.trim()}else try{let q;if(_.value&&$0(_.value))q=Z0(_.value,Object.keys(Z))(...Object.values(Z));else if(_.value)q=e(_.value,Z);if(z===q){W=_.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+W+X.substring(K.end),J=!0}catch(z){let W=z instanceof Error?z.message:String(z),U=r("Switch",`Error evaluating @switch expression: ${W}`,p.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function p1($,Z,Y){let X=$;X=eU(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,z=A1(X,K+7);if(!z)break;let W=z.endPos,U=l1(X,"unless","endunless",W);if(U===-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 _=X.slice(W,U),q=z.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],A;while((A=L.exec(_))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(_))!==null)V.push({pos:A.index,type:"close"});while((A=O.exec(_))!==null)V.push({pos:A.index,type:"else"});V.sort((w,R)=>w.pos-R.pos);for(let w of V)if(w.type==="open")H++;else if(w.type==="close")H--;else if(w.type==="else"&&H===0){B=w.pos;break}}let j;if(B!==-1){let H=_.slice(0,B),L=_.slice(B+5);j=`@if (${q})${L}@else ${H}@endif`}else j=`@if (!(${q}))${_}@endif`;X=X.substring(0,K)+j+X.substring(U+10),Q=!0}}X=G3(X,Z,Y),X=K3(X,Z,Y),X=Q3(X,Z);let J=()=>{let Q=e5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let z="",W=!1;for(let U of K.branches){if(W)break;if(U.type==="else")z=U.content,W=!0;else try{let _;if(U.condition&&$0(U.condition))_=Z0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)_=e(U.condition,Z);if(_)z=U.content,W=!0}catch(_){z=r(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${_ instanceof Error?_.message:String(_)}`,p.EVALUATION_ERROR),W=!0}}X=X.substring(0,K.start)+z+X.substring(K.end)}catch(z){let W=z instanceof Error?z.message:String(z),U=r("If",`Error processing @if block: ${W}`,p.EVALUATION_ERROR);X=X.substring(0,K.start)+U+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function Y2($){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 Q3($,Z){let Y=$;function X(K,z,W,U){let _=1,q=U,B=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(q<K.length&&_>0){B.lastIndex=q,j.lastIndex=q;let H=B.exec(K),L=j.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)_++,q=F+H[0].length;else if(O<1/0){if(_--,_===0)return O;q=O+L[0].length}else break}return-1}function J(K,z,W){let U=0,_=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),q=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=_.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=q.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")U++;else if(L.type==="close")U--;else if(L.type==="else"&&U===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let z=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let W=z.index,U,_,q=Y.slice(W+5),B=Y2(q);if(B)U=B.value,_=W+5+B.consumed;else _=W+5;let j=X(Y,"auth","endauth",_);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(_,j),L=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?w1(`auth?.check && auth?.user?.[${U}]`,Z):w1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let z=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let W=z.index,U,_,q=Y.slice(W+6),B=Y2(q);if(B)U=B.value,_=W+6+B.consumed;else _=W+6;let j=X(Y,"guest","endguest",_);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(_,j),L=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?w1(`!auth?.check || !auth?.user?.[${U}]`,Z):w1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+9),K=!0}}function Q(K,z,W){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let U=[K];if(z)U.push(z);if(W){let _=w1(W,Z);U.push(_)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let z=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!z)return null;return{ability:z[1],type:z[2],id:z[3]?.trim(),paramsEnd:z[0].length}}for(let K of["can","cannot"]){let z=`end${K}`,W=K==="can"?"elsecan":"elsecannot",U=!0;while(U){U=!1;let _=Y.match(new RegExp(`@${K}\\s*\\(`));if(!_||_.index===void 0)break;let q=_.index,B=Y.slice(q+`@${K}`.length),j=G(B);if(!j)break;let H=q+`@${K}`.length+j.paramsEnd,L=X(Y,K,z,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${q} has no matching @${z} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${z}(?![a-z])`,"g"),R=new RegExp(`@${W}\\s*\\(`,"g"),N=/@else(?![a-z])/g,T=[],M;while((M=A.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=w.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((b,C)=>b.pos-C.pos);for(let b of T){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)O.push(b)}let D=[],I=0;for(let b=0;b<O.length;b++){let C=O[b];if(D.push({content:F.slice(I,C.pos),ability:void 0}),C.type==="elseDirective"){let d=F.slice(C.pos+`@${W}`.length),f=G(d);if(f){D[D.length-1]={content:F.slice(I,C.pos)},I=C.pos+`@${W}`.length+f.paramsEnd,D.push({content:"",ability:f.ability,type:f.type,id:f.id}),D.pop();let u=O[b+1],s=u?u.pos:F.length;D.push({content:F.slice(I,s),ability:f.ability,type:f.type,id:f.id}),I=s}}else I=C.pos+5}if(I<F.length){let b=D[D.length-1];if(O.length>0&&O[O.length-1].type==="else")D.push({content:F.slice(I),isFinalElse:!0});else if(D.length===0)D.push({content:F.slice(I)})}let E=Q(j.ability,j.type,j.id),k=K==="can"?E:!E,S="";if(k)S=D[0]?.content||"";else{let b=!1;for(let C=1;C<D.length;C++){let d=D[C];if(d.isFinalElse){S=d.content,b=!0;break}if(d.ability){let f=Q(d.ability,d.type,d.id);if(K==="can"?f:!f){S=d.content,b=!0;break}}}if(!b&&D.length>0){let C=D[D.length-1];if(C.isFinalElse)S=C.content}}Y=Y.substring(0,q)+S+Y.substring(L+`@${z}`.length),U=!0}}return Y}function G3($,Z,Y){let X=$;function J(Q,G,K,z,W){let U=!0;while(U){U=!1;let _=new RegExp(`@${G}\\s*\\(`),q=Q.match(_);if(!q||q.index===void 0)break;let B=q.index,j=A1(Q,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=l1(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,A=0,w=0;while(w<F.length){let R=F.indexOf("@",w);if(R===-1)break;let N=F.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){A++,w=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){A--,w=R+1;continue}if(A===0&&/^@else(?![a-z])/.test(N)){V=R;break}w=R+1}try{let R=z(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:"";Q=Q.substring(0,B)+N+Q.substring(L+`@${K}`.length),U=!0}catch(R){let N=R instanceof Error?R.message:String(R),T=r(W,`Error processing @${G} directive: ${N}`,p.EVALUATION_ERROR);Q=Q.substring(0,B)+T+Q.substring(L+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=w1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=w1(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 K3($,Z,Y){let X=$,J="development";function Q(G,K,z,W){let U=new RegExp(`@${K}(?![a-z])`,"g"),_=new RegExp(`@${z}(?![a-z])`,"g"),q=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${z}(?![a-z])`),j=G,H=!0;while(H){H=!1,U.lastIndex=0;let L=U.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let E=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!E)break;O+=E[0].length,W=J===E[2]}let V=1,A=O,w=-1;while(V>0&&A<j.length){U.lastIndex=A,_.lastIndex=A;let E=U.exec(j),k=_.exec(j),S=E?E.index:1/0,b=k?k.index:1/0;if(S<b)V++,A=S+E[0].length;else if(b<1/0){if(V--,V===0){w=b;break}A=b+k[0].length}else break}if(w===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${z} \u2014 the block was skipped.`);break}let R=j.substring(O,w),N=-1,T=0,M=0;while(M<R.length){let E=R.indexOf("@",M);if(E===-1)break;let k=R.substring(E);if(q.test(k)){T++,M=E+1;continue}if(B.test(k)){T--,M=E+1;continue}if(T===0&&/^@else(?![a-z])/.test(k)){N=E;break}M=E+1}let D;if(N!==-1){let E=R.slice(0,N),k=R.slice(N+5);D=W?E:k}else D=W?R:"";let I=`@${z}`.length;j=j.substring(0,F)+D+j.substring(w+I),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 x4=P(()=>{sY();U1();v4();A0()});function X2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function c1($,Z){if(!$)return Z?.nonceGenerator?.()??X2();let Y=z3.get($);if(!Y)Y=Z?.nonceGenerator?.()??X2(),z3.set($,Y);return Y}function bR($){z3.delete($)}function J2($,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 U3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${J2($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function PR($){return{enabled:!0,directives:{strict:$_,moderate:W3,relaxed:Z_,api:Y_}[$]||W3,useNonce:$==="strict",addMetaTag:!0}}function CR($,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:[],z=[...new Set([...K,...J])];Y[Q]=z}}return Y}function Q2($,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?c1(Y,Z):void 0,J=U3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
3773
3773
|
${J}`)}function yR($,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 G2($,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?c1(Z,Q):void 0;return U3(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return c1(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=c1(Z,Q);return J}function vR(){return[X_,J_]}function xR($){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 Q_($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function fR($,Z){if(!$.enabled)return{};let Y=$.useNonce?c1(Z,$):void 0,X=J2($.directives,Y);return{[Q_($.reportOnly)]:X}}var z3,$_,W3,Z_,Y_,X_,J_,gR;var K2=P(()=>{z3=new WeakMap;$_={"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},W3={"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},Z_={"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'"]},Y_={"default-src":["'none'"],"frame-ancestors":["'none'"]};X_={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?c1(Y,Q):void 0;return U3(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},J_={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return c1(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};gR={enabled:!1,reportOnly:!1,directives:W3,useNonce:!1,addMetaTag:!0}});import{Buffer as z2}from"buffer";import W2 from"crypto";function K_($=G_){let Z=W2.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return F5=Z,Z}function z_(){if(!F5)K_();return F5}function mR(){F5=null}function lR($){F5=$}function W_($=U2){let Z=z_();return`<input type="hidden" name="${$}" value="${Z}">`}function _2($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return W_(X||U2)})}function pR($,Z){let Y=Z??F5;if(!Y)return!1;let X=z2.from($),J=z2.from(Y);if(X.length!==J.length)return!1;return W2.timingSafeEqual(X,J)}var G_=40,U2="_token",F5=null;var q2=()=>{};async function B2($,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 U_(J,Q,Z,Y,X);else J=await __(J,Q,Z,Y,X)}return J}async function U_($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,z=`@end${Q}`,W=$,U=x1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${z}`,"g"),_=[],q=U.exec(W);while(q!==null){let[B,j="",H=""]=q,L=q.index||0;try{let F=j?j2(j):[],O=H.trim(),V=await G(O,F,Y,X);_.push({original:B,processed:V,startIndex:L})}catch(F){let O=F instanceof Error?F.message:String(F);if(J.debug)console.error(`Error processing custom directive @${Q}:`,F);_.push({original:B,processed:r("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${O}`,p.EVALUATION_ERROR),startIndex:L})}q=U.exec(W)}for(let B=_.length-1;B>=0;B--){let{original:j,processed:H}=_[B];W=W.replace(j,H)}return W}async function __($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,z=x1(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),W=[],U=z.exec(K);while(U!==null){let[B,j=""]=U,H=U.index||0;try{let L=j2(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(J.debug)console.error(`Error processing custom directive @${Q}:`,L);W.push({original:B,processed:r("CustomDirective",`Error in @${Q}(${j}): ${F}`,p.EVALUATION_ERROR),startIndex:H})}U=z.exec(K)}let _=x1(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),q=_.exec(K);while(q!==null){let[B]=q,j=q.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(J.debug)console.error(`Error processing custom directive @${Q}:`,H);W.push({original:B,processed:r("CustomDirective",`Error in @${Q}: ${L}`,p.EVALUATION_ERROR),startIndex:j})}q=_.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 j2($){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 H2=P(()=>{U1();K5()});var _3={};l(_3,{useTitle:()=>L_,useSeoMeta:()=>g4,usePageTitle:()=>L_,useHead:()=>n1,resetHead:()=>j_,renderHtmlAttrs:()=>V_,renderHead:()=>F_,renderBodyAttrs:()=>w_,processTitleDirective:()=>N_,processMetaDirective:()=>T_,processHeadDirective:()=>R_,getPageMeta:()=>B_,getHead:()=>$$,definePageMeta:()=>O_,applyHead:()=>A_});function $$(){return R1}function B_(){return f4}function j_(){R1={},q_.length=0,f4={}}function n1($){R1=H_(R1,$)}function H_($,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 g4($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let z=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:z})}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 z of $.articleTags)Z.push({property:"article:tag",content:z});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});n1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function O_($){if(f4={...f4,...$},$.title||$.description)g4({title:$.title,description:$.description})}function L_($){let Z=typeof $==="function"?$():$;n1({title:Z})}function F_($=R1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${i1(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${i1(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}="${i1(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}="${i1(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}="${i1(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(`
|
|
3774
3774
|
`)}function V_($=R1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${i1(Y)}"`).join(" ")}function w_($=R1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${i1(Y)}"`).join(" ")}function i1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function A_($=R1){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 R_($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
|
|
3775
3775
|
`,""}),headContent:Z.trim()}}function N_($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return n1({title:G}),""})}function T_($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let z=Q?G:K,W=Q?z:Z[(z||"").trim()]??z,_=J.includes(":")?{property:J,content:W}:{name:J,content:W};return n1({meta:[_]}),""})}var R1,q_,f4;var Z$=P(()=>{R1={},q_=[],f4={}});import M_ from"crypto";function R0($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D_($){return{...q3,...$.forms?.classes}}function h4($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function E_(){return M_.randomUUID()}function aR($,Z,Y,X){let J=D_(X),Q=$;return Q=k_(Q,Z),Q=J$(Q,Z),Q=B3(Q,Z,J),Q=j3(Q,Z,J),Q}function J$($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=E_();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${R0(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="${R0(Q)}">`;return X}),Y}function B3($,Z,Y=q3){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,z,W="")=>{let U=Q||G||"POST",_=K||z||"",q=N1(W),B=U.toUpperCase(),j=["GET","POST"].includes(B)?B:"POST",H=`<form method="${R0(j)}" action="${R0(_)}"${q?` ${q}`:""}>`;if(H+=`
|
|
@@ -3769,7 +3769,7 @@ ${Y}
|
|
|
3769
3769
|
</script>`}function P2($,Z,Y){if(C2=0,!NU($))return $;let X=OU($);if(X.length===0)return $;let J=RU($,X),Q=AU(X,Z),G=J.lastIndexOf("</body>");if(G!==-1)J=J.slice(0,G)+Q+`
|
|
3770
3770
|
`+J.slice(G);else J+=Q;return J}function RU($,Z){let Y=$;for(let X of Z){let Q=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${H4(X.stateExpr)}["']`,"gi").exec(Y);if(Q)X.id=Q[1],X.selector=`[data-stx-scope="${X.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${H4(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*"${H4(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*'${H4(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 NU($){return/x-data\s*=\s*["']/.test($)}var C2=0,HU=0;var v2=y(()=>{$1()});import TU from"fs";import m3 from"path";import{createHighlighter as MU}from"ts-syntax-highlighter";async function DU($,Z={}){try{if(!await i($))throw Error(`Markdown file not found: ${$}`);let X=(await TU.promises.stat($)).mtime.getTime();if(Z.cache&&l3.has($)){let q=l3.get($);if(q.updatedAt>=X)return{content:q.content,data:q.data}}let J=await Bun.file($).text(),{data:Q,content:G}=h8(J),K=Z.markdown||y3.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},W=f5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)W=await IU(W,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let U={content:W,data:Q||{}};if(Z.cache)l3.set($,{...U,updatedAt:X});return U}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:Q0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function IU($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!O4)try{O4=await MU({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,z,W,U)=>{let q=U.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),_=W||(Y?"text":"");if(!_)return K;try{if(!O4.getSupportedLanguages().includes(_))return K;return(await O4.highlight(q,_,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${W}:`,B)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[z,W,U,q]=K,_=await J(z,W,U,q);Q=Q.replace(z,_)}return Q}async function x2($,Z,Y="",X={}){return await EU($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,z,W)=>{try{let U=K;if(!m3.isAbsolute(K))U=m3.resolve(m3.dirname(Y),K);let q={};if(z)try{try{q=JSON.parse(z)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let O=z.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let A=V.indexOf(":");if(A>0){let w=V.substring(0,A).trim(),R=V.substring(A+1).trim(),N=R.startsWith('"')&&R.endsWith('"'),T=R.startsWith("'")&&R.endsWith("'");if(N||T)R=R.substring(1,R.length-1);q[w]=R}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:_,data:B}=await DU(U,X),j={...Z,...B,...q},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(U){let q=U instanceof Error?U.message:String(U);return Q0("Markdown File",`Error including markdown file: ${q}`,Y,$,W,G)}})}async function EU($,Z,Y){let X=[],J;while((J=Z.exec($))!==null){let K=J[0],z=J.index,W=J;X.push(Y(...W).then((U)=>({match:K,replacement:U,index:z})))}let Q=await Promise.all(X);Q.sort((K,z)=>z.index-K.index);let G=$;for(let{match:K,replacement:z}of Q)G=G.replace(K,()=>z);return G}var l3,O4=null;var f2=y(()=>{u5();O0();l3=new Map});function F1($,Z){try{let Y=$.trim();if($0(Y))return Z0(Y,Object.keys(Z))(...Object.values(Z));else return e(Y,Z)}catch{return!1}}var g2=y(()=>{w0()});class L4{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]!==`
|
|
3771
3771
|
`)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]===`
|
|
3772
|
-
`)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 F0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,z=!1;while(Q<$.length){let W=$[Q];if(G&&z){z=!1,Q++;continue}if(G&&W==="\\"){z=!0,Q++;continue}if(z=!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)J++;else if(W===Y){if(J--,J===0)return Q}Q++}return-1}function h2($,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 p3($){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 V1($,Z){let Y=kU($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function kU($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=F0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function h1($,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 z=G.exec($),W=K.exec($),U=z?z.index:1/0,q=W?W.index:1/0;if(U<q)J++,Q=U+z[0].length;else if(q<1/0){if(J--,J===0)return q;Q=q+W[0].length}else break}return-1}function d2($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=V1($,X);if(!J)return null;let Q=J.endPos,G=h1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],W=0,U="if",q=J.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){z.push({type:U,condition:q,content:K.substring(_,W),start:Q+_,end:Q+W});let F=W+L[0].length,O=V1(K,F);if(!O){W++;continue}U="elseif",q=O.expression,W=O.endPos,_=W;continue}else if(/^@else(?![a-z])/.test(H)){z.push({type:U,condition:q,content:K.substring(_,W),start:Q+_,end:Q+W}),U="else",q=void 0,W+=5,_=W;continue}}W++}return z.push({type:U,condition:q,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:z,start:Z,end:G+6}}function l5($){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=d2($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function F4($,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,z=K+Q[0].length-1,W=F0($,"(",")",z);if(W===-1){Q=J.exec($);continue}let U=$.slice(z+1,W),q=W+1,_=h1($,Z,Y,q);if(_===-1){Q=J.exec($);continue}let B=$.slice(q,_),j=_+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:U,content:B,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function c3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=V1($,X);if(!J)return null;let Q=J.endPos,G=h1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],W=0,U=null,q=0;while(W<K.length){let _=K.slice(W),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(q++,U)U.content+=B[0];W+=B[0].length;continue}if(j){if(q--,U)U.content+=j[0];W+=j[0].length;continue}if(q>0){if(U)U.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(U)z.push(U);let O=W+H[0].length,V=V1(K,O);if(!V){W++;continue}U={type:"case",value:V.expression,content:""},W=V.endPos}else if(L&&_.startsWith("@default")){if(U)z.push(U);U={type:"default",content:""},W+=L[0].length}else if(F&&_.startsWith("@break"))W+=F[0].length;else{if(U)U.content+=K[W];W++}}if(U)z.push(U);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:z,start:Z,end:G+10}}var u2=()=>{};function SU($){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)==="{{{"?"{{{":"{!!":"{{",z=Q?K==="{{{"?"}}}":"!!}":"}}",W=G+K.length,U=bU($,W,z);if(U===-1){Y=G+1;continue}let q=$.slice(W,U).trim(),_=U+z.length;Z.push({fullMatch:$.slice(G,_),expression:q,start:G,end:_,isRaw:Q}),Y=_}return Z}function bU($,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 yU($){let Z=p3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=CU(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function CU($){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=F0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=p2(G);return{name:X,args:K}}function p2($){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 PU($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=F0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function vU($){let Z=[],X=new L4($).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 z=K.value;if(J++,J>=X.length)break;let W=X[J];if(W.type==="IDENTIFIER"){let U=W.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let q=J<X.length?X[J].start:$.length,_=m2(X,J,$);J=_.nextIndex,Z.push({type:"variable",name:U,value:$.slice(q,_.endPos),exported:G,start:K.start,end:_.endPos})}}else if(W.type==="PUNCTUATION"&&(W.value==="{"||W.value==="[")){let U=W.start,q=W.value==="{"?"}":"]",_=F0($,W.value,q,U);if(_!==-1){let B=$.slice(U,_+1);if(J=l2(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=m2(X,J,$);J=H.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,H.endPos)}; ${z} ${B} = ${L}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let z=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let W=X[J];if(W.type==="IDENTIFIER"){let U=W.value;J++;let q=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){q=X[J].start;break}J++}if(q!==-1){let _=F0($,"{","}",q);if(_!==-1)Z.push({type:"function",name:U,value:$.slice(z,_+1).replace(/^export\s+/,""),exported:G,start:z,end:_+1}),J=l2(X,_+1)}}}else J++}return Z}function m2($,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 l2($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var c2=()=>{};var V4=y(()=>{u2();c2()});function xU($,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=c3(X,G);if(!K)break;try{let z;if($0(K.expression))z=Z0(K.expression,Object.keys(Z))(...Object.values(Z));else z=e(K.expression,Z);let W="",U=!1;for(let q of K.cases)if(q.type==="default"){if(!U)W=q.content.trim()}else try{let _;if(q.value&&$0(q.value))_=Z0(q.value,Object.keys(Z))(...Object.values(Z));else if(q.value)_=e(q.value,Z);if(z===_){W=q.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+W+X.substring(K.end),J=!0}catch(z){let W=z instanceof Error?z.message:String(z),U=r("Switch",`Error evaluating @switch expression: ${W}`,p.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function d1($,Z,Y){let X=$;X=xU(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,z=V1(X,K+7);if(!z)break;let W=z.endPos,U=h1(X,"unless","endunless",W);if(U===-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 q=X.slice(W,U),_=z.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],A;while((A=L.exec(q))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(q))!==null)V.push({pos:A.index,type:"close"});while((A=O.exec(q))!==null)V.push({pos:A.index,type:"else"});V.sort((w,R)=>w.pos-R.pos);for(let w of V)if(w.type==="open")H++;else if(w.type==="close")H--;else if(w.type==="else"&&H===0){B=w.pos;break}}let j;if(B!==-1){let H=q.slice(0,B),L=q.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${q}@endif`;X=X.substring(0,K)+j+X.substring(U+10),Q=!0}}X=n3(X,Z,Y),X=s3(X,Z,Y),X=i3(X,Z);let J=()=>{let Q=l5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let z="",W=!1;for(let U of K.branches){if(W)break;if(U.type==="else")z=U.content,W=!0;else try{let q;if(U.condition&&$0(U.condition))q=Z0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)q=e(U.condition,Z);if(q)z=U.content,W=!0}catch(q){z=r(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${q instanceof Error?q.message:String(q)}`,p.EVALUATION_ERROR),W=!0}}X=X.substring(0,K.start)+z+X.substring(K.end)}catch(z){let W=z instanceof Error?z.message:String(z),U=r("If",`Error processing @if block: ${W}`,p.EVALUATION_ERROR);X=X.substring(0,K.start)+U+X.substring(K.end)}}return!0};while(J());return X}function i2($){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 i3($,Z){let Y=$;function X(K,z,W,U){let q=1,_=U,B=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(_<K.length&&q>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)q++,_=F+H[0].length;else if(O<1/0){if(q--,q===0)return O;_=O+L[0].length}else break}return-1}function J(K,z,W){let U=0,q=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=q.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")U++;else if(L.type==="close")U--;else if(L.type==="else"&&U===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let z=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let W=z.index,U,q,_=Y.slice(W+5),B=i2(_);if(B)U=B.value,q=W+5+B.consumed;else q=W+5;let j=X(Y,"auth","endauth",q);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(q,j),L=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?F1(`auth?.check && auth?.user?.[${U}]`,Z):F1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let z=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let W=z.index,U,q,_=Y.slice(W+6),B=i2(_);if(B)U=B.value,q=W+6+B.consumed;else q=W+6;let j=X(Y,"guest","endguest",q);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(q,j),L=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?F1(`!auth?.check || !auth?.user?.[${U}]`,Z):F1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+9),K=!0}}function Q(K,z,W){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let U=[K];if(z)U.push(z);if(W){let q=F1(W,Z);U.push(q)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let z=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!z)return null;return{ability:z[1],type:z[2],id:z[3]?.trim(),paramsEnd:z[0].length}}for(let K of["can","cannot"]){let z=`end${K}`,W=K==="can"?"elsecan":"elsecannot",U=!0;while(U){U=!1;let q=Y.match(new RegExp(`@${K}\\s*\\(`));if(!q||q.index===void 0)break;let _=q.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let H=_+`@${K}`.length+j.paramsEnd,L=X(Y,K,z,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${z} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${z}(?![a-z])`,"g"),R=new RegExp(`@${W}\\s*\\(`,"g"),N=/@else(?![a-z])/g,T=[],M;while((M=A.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=w.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((b,C)=>b.pos-C.pos);for(let b of T){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)O.push(b)}let D=[],E=0;for(let b=0;b<O.length;b++){let C=O[b];if(D.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){D[D.length-1]={content:F.slice(E,C.pos)},E=C.pos+`@${W}`.length+f.paramsEnd,D.push({content:"",ability:f.ability,type:f.type,id:f.id}),D.pop();let u=O[b+1],s=u?u.pos:F.length;D.push({content:F.slice(E,s),ability:f.ability,type:f.type,id:f.id}),E=s}}else E=C.pos+5}if(E<F.length){let b=D[D.length-1];if(O.length>0&&O[O.length-1].type==="else")D.push({content:F.slice(E),isFinalElse:!0});else if(D.length===0)D.push({content:F.slice(E)})}let I=Q(j.ability,j.type,j.id),k=K==="can"?I:!I,S="";if(k)S=D[0]?.content||"";else{let b=!1;for(let C=1;C<D.length;C++){let d=D[C];if(d.isFinalElse){S=d.content,b=!0;break}if(d.ability){let f=Q(d.ability,d.type,d.id);if(K==="can"?f:!f){S=d.content,b=!0;break}}}if(!b&&D.length>0){let C=D[D.length-1];if(C.isFinalElse)S=C.content}}Y=Y.substring(0,_)+S+Y.substring(L+`@${z}`.length),U=!0}}return Y}function n3($,Z,Y){let X=$;function J(Q,G,K,z,W){let U=!0;while(U){U=!1;let q=new RegExp(`@${G}\\s*\\(`),_=Q.match(q);if(!_||_.index===void 0)break;let B=_.index,j=V1(Q,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=h1(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,A=0,w=0;while(w<F.length){let R=F.indexOf("@",w);if(R===-1)break;let N=F.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){A++,w=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){A--,w=R+1;continue}if(A===0&&/^@else(?![a-z])/.test(N)){V=R;break}w=R+1}try{let R=z(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:"";Q=Q.substring(0,B)+N+Q.substring(L+`@${K}`.length),U=!0}catch(R){let N=R instanceof Error?R.message:String(R),T=r(W,`Error processing @${G} directive: ${N}`,p.EVALUATION_ERROR);Q=Q.substring(0,B)+T+Q.substring(L+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=F1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=F1(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 s3($,Z,Y){let X=$,J="development";function Q(G,K,z,W){let U=new RegExp(`@${K}(?![a-z])`,"g"),q=new RegExp(`@${z}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${z}(?![a-z])`),j=G,H=!0;while(H){H=!1,U.lastIndex=0;let L=U.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let I=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!I)break;O+=I[0].length,W=J===I[2]}let V=1,A=O,w=-1;while(V>0&&A<j.length){U.lastIndex=A,q.lastIndex=A;let I=U.exec(j),k=q.exec(j),S=I?I.index:1/0,b=k?k.index:1/0;if(S<b)V++,A=S+I[0].length;else if(b<1/0){if(V--,V===0){w=b;break}A=b+k[0].length}else break}if(w===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${z} \u2014 the block was skipped.`);break}let R=j.substring(O,w),N=-1,T=0,M=0;while(M<R.length){let I=R.indexOf("@",M);if(I===-1)break;let k=R.substring(I);if(_.test(k)){T++,M=I+1;continue}if(B.test(k)){T--,M=I+1;continue}if(T===0&&/^@else(?![a-z])/.test(k)){N=I;break}M=I+1}let D;if(N!==-1){let I=R.slice(0,N),k=R.slice(N+5);D=W?I:k}else D=W?R:"";let E=`@${z}`.length;j=j.substring(0,F)+D+j.substring(w+E),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 w4=y(()=>{g2();z1();V4();w0()});function n2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function u1($,Z){if(!$)return Z?.nonceGenerator?.()??n2();let Y=o3.get($);if(!Y)Y=Z?.nonceGenerator?.()??n2(),o3.set($,Y);return Y}function GR($){o3.delete($)}function s2($,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 a3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${s2($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function KR($){return{enabled:!0,directives:{strict:fU,moderate:r3,relaxed:gU,api:hU}[$]||r3,useNonce:$==="strict",addMetaTag:!0}}function zR($,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:[],z=[...new Set([...K,...J])];Y[Q]=z}}return Y}function o2($,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?u1(Y,Z):void 0,J=a3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
3772
|
+
`)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 F0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,z=!1;while(Q<$.length){let W=$[Q];if(G&&z){z=!1,Q++;continue}if(G&&W==="\\"){z=!0,Q++;continue}if(z=!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)J++;else if(W===Y){if(J--,J===0)return Q}Q++}return-1}function h2($,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 p3($){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 V1($,Z){let Y=kU($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function kU($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=F0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function h1($,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 z=G.exec($),W=K.exec($),U=z?z.index:1/0,q=W?W.index:1/0;if(U<q)J++,Q=U+z[0].length;else if(q<1/0){if(J--,J===0)return q;Q=q+W[0].length}else break}return-1}function d2($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=V1($,X);if(!J)return null;let Q=J.endPos,G=h1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],W=0,U="if",q=J.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){z.push({type:U,condition:q,content:K.substring(_,W),start:Q+_,end:Q+W});let F=W+L[0].length,O=V1(K,F);if(!O){W++;continue}U="elseif",q=O.expression,W=O.endPos,_=W;continue}else if(/^@else(?![a-z])/.test(H)){z.push({type:U,condition:q,content:K.substring(_,W),start:Q+_,end:Q+W}),U="else",q=void 0,W+=5,_=W;continue}}W++}return z.push({type:U,condition:q,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:z,start:Z,end:G+6}}function l5($){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=d2($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function F4($,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,z=K+Q[0].length-1,W=F0($,"(",")",z);if(W===-1){Q=J.exec($);continue}let U=$.slice(z+1,W),q=W+1,_=h1($,Z,Y,q);if(_===-1){Q=J.exec($);continue}let B=$.slice(q,_),j=_+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:U,content:B,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function c3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=V1($,X);if(!J)return null;let Q=J.endPos,G=h1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],W=0,U=null,q=0;while(W<K.length){let _=K.slice(W),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(q++,U)U.content+=B[0];W+=B[0].length;continue}if(j){if(q--,U)U.content+=j[0];W+=j[0].length;continue}if(q>0){if(U)U.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(U)z.push(U);let O=W+H[0].length,V=V1(K,O);if(!V){W++;continue}U={type:"case",value:V.expression,content:""},W=V.endPos}else if(L&&_.startsWith("@default")){if(U)z.push(U);U={type:"default",content:""},W+=L[0].length}else if(F&&_.startsWith("@break"))W+=F[0].length;else{if(U)U.content+=K[W];W++}}if(U)z.push(U);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:z,start:Z,end:G+10}}var u2=()=>{};function SU($){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)==="{{{"?"{{{":"{!!":"{{",z=Q?K==="{{{"?"}}}":"!!}":"}}",W=G+K.length,U=bU($,W,z);if(U===-1){Y=G+1;continue}let q=$.slice(W,U).trim(),_=U+z.length;Z.push({fullMatch:$.slice(G,_),expression:q,start:G,end:_,isRaw:Q}),Y=_}return Z}function bU($,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 yU($){let Z=p3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=CU(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function CU($){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=F0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=p2(G);return{name:X,args:K}}function p2($){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 PU($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=F0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function vU($){let Z=[],X=new L4($).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 z=K.value;if(J++,J>=X.length)break;let W=X[J];if(W.type==="IDENTIFIER"){let U=W.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let q=J<X.length?X[J].start:$.length,_=m2(X,J,$);J=_.nextIndex,Z.push({type:"variable",name:U,value:$.slice(q,_.endPos),exported:G,start:K.start,end:_.endPos})}}else if(W.type==="PUNCTUATION"&&(W.value==="{"||W.value==="[")){let U=W.start,q=W.value==="{"?"}":"]",_=F0($,W.value,q,U);if(_!==-1){let B=$.slice(U,_+1);if(J=l2(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=m2(X,J,$);J=H.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,H.endPos)}; ${z} ${B} = ${L}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let z=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let W=X[J];if(W.type==="IDENTIFIER"){let U=W.value;J++;let q=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){q=X[J].start;break}J++}if(q!==-1){let _=F0($,"{","}",q);if(_!==-1)Z.push({type:"function",name:U,value:$.slice(z,_+1).replace(/^export\s+/,""),exported:G,start:z,end:_+1}),J=l2(X,_+1)}}}else J++}return Z}function m2($,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 l2($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var c2=()=>{};var V4=y(()=>{u2();c2()});function xU($,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=c3(X,G);if(!K)break;try{let z;if($0(K.expression))z=Z0(K.expression,Object.keys(Z))(...Object.values(Z));else z=e(K.expression,Z);let W="",U=!1;for(let q of K.cases)if(q.type==="default"){if(!U)W=q.content.trim()}else try{let _;if(q.value&&$0(q.value))_=Z0(q.value,Object.keys(Z))(...Object.values(Z));else if(q.value)_=e(q.value,Z);if(z===_){W=q.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+W+X.substring(K.end),J=!0}catch(z){let W=z instanceof Error?z.message:String(z),U=r("Switch",`Error evaluating @switch expression: ${W}`,p.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function d1($,Z,Y){let X=$;X=xU(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,z=V1(X,K+7);if(!z)break;let W=z.endPos,U=h1(X,"unless","endunless",W);if(U===-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 q=X.slice(W,U),_=z.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],A;while((A=L.exec(q))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(q))!==null)V.push({pos:A.index,type:"close"});while((A=O.exec(q))!==null)V.push({pos:A.index,type:"else"});V.sort((w,R)=>w.pos-R.pos);for(let w of V)if(w.type==="open")H++;else if(w.type==="close")H--;else if(w.type==="else"&&H===0){B=w.pos;break}}let j;if(B!==-1){let H=q.slice(0,B),L=q.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${q}@endif`;X=X.substring(0,K)+j+X.substring(U+10),Q=!0}}X=n3(X,Z,Y),X=s3(X,Z,Y),X=i3(X,Z);let J=()=>{let Q=l5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let z="",W=!1;for(let U of K.branches){if(W)break;if(U.type==="else")z=U.content,W=!0;else try{let q;if(U.condition&&$0(U.condition))q=Z0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)q=e(U.condition,Z);if(q)z=U.content,W=!0}catch(q){z=r(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${q instanceof Error?q.message:String(q)}`,p.EVALUATION_ERROR),W=!0}}X=X.substring(0,K.start)+z+X.substring(K.end)}catch(z){let W=z instanceof Error?z.message:String(z),U=r("If",`Error processing @if block: ${W}`,p.EVALUATION_ERROR);X=X.substring(0,K.start)+U+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function i2($){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 i3($,Z){let Y=$;function X(K,z,W,U){let q=1,_=U,B=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(_<K.length&&q>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)q++,_=F+H[0].length;else if(O<1/0){if(q--,q===0)return O;_=O+L[0].length}else break}return-1}function J(K,z,W){let U=0,q=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=q.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")U++;else if(L.type==="close")U--;else if(L.type==="else"&&U===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let z=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let W=z.index,U,q,_=Y.slice(W+5),B=i2(_);if(B)U=B.value,q=W+5+B.consumed;else q=W+5;let j=X(Y,"auth","endauth",q);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(q,j),L=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?F1(`auth?.check && auth?.user?.[${U}]`,Z):F1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let z=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let W=z.index,U,q,_=Y.slice(W+6),B=i2(_);if(B)U=B.value,q=W+6+B.consumed;else q=W+6;let j=X(Y,"guest","endguest",q);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(q,j),L=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?F1(`!auth?.check || !auth?.user?.[${U}]`,Z):F1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+9),K=!0}}function Q(K,z,W){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let U=[K];if(z)U.push(z);if(W){let q=F1(W,Z);U.push(q)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let z=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!z)return null;return{ability:z[1],type:z[2],id:z[3]?.trim(),paramsEnd:z[0].length}}for(let K of["can","cannot"]){let z=`end${K}`,W=K==="can"?"elsecan":"elsecannot",U=!0;while(U){U=!1;let q=Y.match(new RegExp(`@${K}\\s*\\(`));if(!q||q.index===void 0)break;let _=q.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let H=_+`@${K}`.length+j.paramsEnd,L=X(Y,K,z,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${z} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${z}(?![a-z])`,"g"),R=new RegExp(`@${W}\\s*\\(`,"g"),N=/@else(?![a-z])/g,T=[],M;while((M=A.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=w.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((b,C)=>b.pos-C.pos);for(let b of T){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)O.push(b)}let D=[],E=0;for(let b=0;b<O.length;b++){let C=O[b];if(D.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){D[D.length-1]={content:F.slice(E,C.pos)},E=C.pos+`@${W}`.length+f.paramsEnd,D.push({content:"",ability:f.ability,type:f.type,id:f.id}),D.pop();let u=O[b+1],s=u?u.pos:F.length;D.push({content:F.slice(E,s),ability:f.ability,type:f.type,id:f.id}),E=s}}else E=C.pos+5}if(E<F.length){let b=D[D.length-1];if(O.length>0&&O[O.length-1].type==="else")D.push({content:F.slice(E),isFinalElse:!0});else if(D.length===0)D.push({content:F.slice(E)})}let I=Q(j.ability,j.type,j.id),k=K==="can"?I:!I,S="";if(k)S=D[0]?.content||"";else{let b=!1;for(let C=1;C<D.length;C++){let d=D[C];if(d.isFinalElse){S=d.content,b=!0;break}if(d.ability){let f=Q(d.ability,d.type,d.id);if(K==="can"?f:!f){S=d.content,b=!0;break}}}if(!b&&D.length>0){let C=D[D.length-1];if(C.isFinalElse)S=C.content}}Y=Y.substring(0,_)+S+Y.substring(L+`@${z}`.length),U=!0}}return Y}function n3($,Z,Y){let X=$;function J(Q,G,K,z,W){let U=!0;while(U){U=!1;let q=new RegExp(`@${G}\\s*\\(`),_=Q.match(q);if(!_||_.index===void 0)break;let B=_.index,j=V1(Q,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=h1(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,A=0,w=0;while(w<F.length){let R=F.indexOf("@",w);if(R===-1)break;let N=F.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){A++,w=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){A--,w=R+1;continue}if(A===0&&/^@else(?![a-z])/.test(N)){V=R;break}w=R+1}try{let R=z(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:"";Q=Q.substring(0,B)+N+Q.substring(L+`@${K}`.length),U=!0}catch(R){let N=R instanceof Error?R.message:String(R),T=r(W,`Error processing @${G} directive: ${N}`,p.EVALUATION_ERROR);Q=Q.substring(0,B)+T+Q.substring(L+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=F1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=F1(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 s3($,Z,Y){let X=$,J="development";function Q(G,K,z,W){let U=new RegExp(`@${K}(?![a-z])`,"g"),q=new RegExp(`@${z}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${z}(?![a-z])`),j=G,H=!0;while(H){H=!1,U.lastIndex=0;let L=U.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let I=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!I)break;O+=I[0].length,W=J===I[2]}let V=1,A=O,w=-1;while(V>0&&A<j.length){U.lastIndex=A,q.lastIndex=A;let I=U.exec(j),k=q.exec(j),S=I?I.index:1/0,b=k?k.index:1/0;if(S<b)V++,A=S+I[0].length;else if(b<1/0){if(V--,V===0){w=b;break}A=b+k[0].length}else break}if(w===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${z} \u2014 the block was skipped.`);break}let R=j.substring(O,w),N=-1,T=0,M=0;while(M<R.length){let I=R.indexOf("@",M);if(I===-1)break;let k=R.substring(I);if(_.test(k)){T++,M=I+1;continue}if(B.test(k)){T--,M=I+1;continue}if(T===0&&/^@else(?![a-z])/.test(k)){N=I;break}M=I+1}let D;if(N!==-1){let I=R.slice(0,N),k=R.slice(N+5);D=W?I:k}else D=W?R:"";let E=`@${z}`.length;j=j.substring(0,F)+D+j.substring(w+E),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 w4=y(()=>{g2();z1();V4();w0()});function n2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function u1($,Z){if(!$)return Z?.nonceGenerator?.()??n2();let Y=o3.get($);if(!Y)Y=Z?.nonceGenerator?.()??n2(),o3.set($,Y);return Y}function GR($){o3.delete($)}function s2($,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 a3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${s2($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function KR($){return{enabled:!0,directives:{strict:fU,moderate:r3,relaxed:gU,api:hU}[$]||r3,useNonce:$==="strict",addMetaTag:!0}}function zR($,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:[],z=[...new Set([...K,...J])];Y[Q]=z}}return Y}function o2($,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?u1(Y,Z):void 0,J=a3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
3773
3773
|
${J}`)}function WR($,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 r2($,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?u1(Z,Q):void 0;return a3(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return u1(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=u1(Z,Q);return J}function UR(){return[dU,uU]}function qR($){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 mU($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function _R($,Z){if(!$.enabled)return{};let Y=$.useNonce?u1(Z,$):void 0,X=s2($.directives,Y);return{[mU($.reportOnly)]:X}}var o3,fU,r3,gU,hU,dU,uU,BR;var a2=y(()=>{o3=new WeakMap;fU={"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},r3={"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},gU={"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'"]},hU={"default-src":["'none'"],"frame-ancestors":["'none'"]};dU={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?u1(Y,Q):void 0;return a3(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},uU={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return u1(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};BR={enabled:!1,reportOnly:!1,directives:r3,useNonce:!1,addMetaTag:!0}});import{Buffer as t2}from"buffer";import e2 from"crypto";function pU($=lU){let Z=e2.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return B5=Z,Z}function cU(){if(!B5)pU();return B5}function LR(){B5=null}function FR($){B5=$}function iU($=$Y){let Z=cU();return`<input type="hidden" name="${$}" value="${Z}">`}function ZY($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return iU(X||$Y)})}function VR($,Z){let Y=Z??B5;if(!Y)return!1;let X=t2.from($),J=t2.from(Y);if(X.length!==J.length)return!1;return e2.timingSafeEqual(X,J)}var lU=40,$Y="_token",B5=null;var YY=()=>{};async function XY($,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 nU(J,Q,Z,Y,X);else J=await sU(J,Q,Z,Y,X)}return J}async function nU($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,z=`@end${Q}`,W=$,U=y1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${z}`,"g"),q=[],_=U.exec(W);while(_!==null){let[B,j="",H=""]=_,L=_.index||0;try{let F=j?JY(j):[],O=H.trim(),V=await G(O,F,Y,X);q.push({original:B,processed:V,startIndex:L})}catch(F){let O=F instanceof Error?F.message:String(F);if(J.debug)console.error(`Error processing custom directive @${Q}:`,F);q.push({original:B,processed:r("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${O}`,p.EVALUATION_ERROR),startIndex:L})}_=U.exec(W)}for(let B=q.length-1;B>=0;B--){let{original:j,processed:H}=q[B];W=W.replace(j,H)}return W}async function sU($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,z=y1(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),W=[],U=z.exec(K);while(U!==null){let[B,j=""]=U,H=U.index||0;try{let L=JY(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(J.debug)console.error(`Error processing custom directive @${Q}:`,L);W.push({original:B,processed:r("CustomDirective",`Error in @${Q}(${j}): ${F}`,p.EVALUATION_ERROR),startIndex:H})}U=z.exec(K)}let q=y1(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),_=q.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(J.debug)console.error(`Error processing custom directive @${Q}:`,H);W.push({original:B,processed:r("CustomDirective",`Error in @${Q}: ${L}`,p.EVALUATION_ERROR),startIndex:j})}_=q.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 JY($){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 QY=y(()=>{z1();Y5()});var t3={};l(t3,{useTitle:()=>$q,useSeoMeta:()=>R4,usePageTitle:()=>$q,useHead:()=>l1,resetHead:()=>aU,renderHtmlAttrs:()=>Yq,renderHead:()=>Zq,renderBodyAttrs:()=>Xq,processTitleDirective:()=>Gq,processMetaDirective:()=>Kq,processHeadDirective:()=>Qq,getPageMeta:()=>rU,getHead:()=>p5,definePageMeta:()=>eU,applyHead:()=>Jq});function p5(){return w1}function rU(){return A4}function aU(){w1={},oU.length=0,A4={}}function l1($){w1=tU(w1,$)}function tU($,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 R4($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let z=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:z})}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 z of $.articleTags)Z.push({property:"article:tag",content:z});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});l1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function eU($){if(A4={...A4,...$},$.title||$.description)R4({title:$.title,description:$.description})}function $q($){let Z=typeof $==="function"?$():$;l1({title:Z})}function Zq($=w1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${m1(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${m1(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}="${m1(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}="${m1(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}="${m1(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(`
|
|
3774
3774
|
`)}function Yq($=w1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${m1(Y)}"`).join(" ")}function Xq($=w1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${m1(Y)}"`).join(" ")}function m1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Jq($=w1){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 Qq($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
|
|
3775
3775
|
`,""}),headContent:Z.trim()}}function Gq($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return l1({title:G}),""})}function Kq($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let z=Q?G:K,W=Q?z:Z[(z||"").trim()]??z,q=J.includes(":")?{property:J,content:W}:{name:J,content:W};return l1({meta:[q]}),""})}var w1,oU,A4;var c5=y(()=>{w1={},oU=[],A4={}});import zq from"crypto";function A0($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Wq($){return{...e3,...$.forms?.classes}}function N4($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function Uq(){return zq.randomUUID()}function DR($,Z,Y,X){let J=Wq(X),Q=$;return Q=_q(Q,Z),Q=s5(Q,Z),Q=$6(Q,Z,J),Q=Z6(Q,Z,J),Q}function s5($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=Uq();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${A0(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="${A0(Q)}">`;return X}),Y}function $6($,Z,Y=e3){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,z,W="")=>{let U=Q||G||"POST",q=K||z||"",_=A1(W),B=U.toUpperCase(),j=["GET","POST"].includes(B)?B:"POST",H=`<form method="${A0(j)}" action="${A0(q)}"${_?` ${_}`:""}>`;if(H+=`
|