@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/index.js
CHANGED
|
@@ -3862,7 +3862,7 @@ ${Y}
|
|
|
3862
3862
|
</script>`}function CU($,Z,Y){if(bU=0,!Gw($))return $;let X=eA($);if(X.length===0)return $;let J=Qw($,X),Q=Jw(X,Z),G=J.lastIndexOf("</body>");if(G!==-1)J=J.slice(0,G)+Q+`
|
|
3863
3863
|
`+J.slice(G);else J+=Q;return J}function Qw($,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*["']${R8(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*["']${R8(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*"${R8(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*'${R8(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 Gw($){return/x-data\s*=\s*["']/.test($)}var bU=0,tA=0;var yU=D(()=>{c0()});import Kw from"fs";import kJ from"path";import{createHighlighter as Ww}from"ts-syntax-highlighter";async function J$($,Z={}){try{if(!await t($))throw Error(`Markdown file not found: ${$}`);let X=(await Kw.promises.stat($)).mtime.getTime();if(Z.cache&&T8.has($)){let _=T8.get($);if(_.updatedAt>=X)return{content:_.content,data:_.data}}let J=await Bun.file($).text(),{data:Q,content:G}=tK(J),K=Z.markdown||W1.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},U=A4(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)U=await Uw(U,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let B={content:U,data:Q||{}};if(Z.cache)T8.set($,{...B,updatedAt:X});return B}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:L0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function Uw($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!M8)try{M8=await Ww({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,W,U,B)=>{let _=B.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),z=U||(Y?"text":"");if(!z)return K;try{if(!M8.getSupportedLanguages().includes(z))return K;return(await M8.highlight(_,z,{theme:Z})).html}catch(q){console.error(`Error highlighting code block with language ${U}:`,q)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[W,U,B,_]=K,z=await J(W,U,B,_);Q=Q.replace(W,z)}return Q}async function SJ($,Z,Y="",X={}){return await Bw($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,W,U)=>{try{let B=K;if(!kJ.isAbsolute(K))B=kJ.resolve(kJ.dirname(Y),K);let _={};if(W)try{try{_=JSON.parse(W)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let L=W.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of L){let N=V.indexOf(":");if(N>0){let A=V.substring(0,N).trim(),w=V.substring(N+1).trim(),R=w.startsWith('"')&&w.endsWith('"'),T=w.startsWith("'")&&w.endsWith("'");if(R||T)w=w.substring(1,w.length-1);_[A]=w}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:z,data:q}=await J$(B,X),j={...Z,...q,..._},H=z,O=/\{\{([^}]+)\}\}/g;return H=H.replace(O,(F,L)=>{let V=L.trim();return j[V]!==void 0?String(j[V]):F}),H}catch(B){let _=B instanceof Error?B.message:String(B);return L0("Markdown File",`Error including markdown file: ${_}`,Y,$,U,G)}})}async function Bw($,Z,Y){let X=[],J;while((J=Z.exec($))!==null){let K=J[0],W=J.index,U=J;X.push(Y(...U).then((B)=>({match:K,replacement:B,index:W})))}let Q=await Promise.all(X);Q.sort((K,W)=>W.index-K.index);let G=$;for(let{match:K,replacement:W}of Q)G=G.replace(K,()=>W);return G}var T8,M8=null;var N7=D(()=>{n0();N0();T8=new Map});function Q$($,Z){try{let Y=$.trim();if(H0(Y))return O0(Y,Object.keys(Z))(...Object.values(Z));else return z0(Y,Z)}catch{return!1}}var bJ=D(()=>{d0()});class u4{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]!==`
|
|
3864
3864
|
`)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]===`
|
|
3865
|
-
`)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,W=!1;while(Q<$.length){let U=$[Q];if(G&&W){W=!1,Q++;continue}if(G&&U==="\\"){W=!0,Q++;continue}if(W=!1,(U==='"'||U==="'"||U==="`")&&!G){G=U,Q++;continue}if(U===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&U==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&U==="}"){K--,Q++;continue}if(U==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(U===Z)J++;else if(U===Y){if(J--,J===0)return Q}Q++}return-1}function CJ($,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 I8($){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 G$($,Z){let Y=_w($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function _w($,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 y$($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),B=W?W.index:1/0,_=U?U.index:1/0;if(B<_)J++,Q=B+W[0].length;else if(_<1/0){if(J--,J===0)return _;Q=_+U[0].length}else break}return-1}function yJ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=G$($,X);if(!J)return null;let Q=J.endPos,G=y$($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,B="if",_=J.expression,z=0,q=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){q++,U++;continue}if(/^@endif(?![a-z])/.test(H)){q--,U+=6;continue}if(q===0){let O=H.match(/^@elseif\s*/);if(O){W.push({type:B,condition:_,content:K.substring(z,U),start:Q+z,end:Q+U});let F=U+O[0].length,L=G$(K,F);if(!L){U++;continue}B="elseif",_=L.expression,U=L.endPos,z=U;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:B,condition:_,content:K.substring(z,U),start:Q+z,end:Q+U}),B="else",_=void 0,U+=5,z=U;continue}}U++}return W.push({type:B,condition:_,content:K.slice(z),start:Q+z,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function A7($){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=yJ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function m4($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,W=K+Q[0].length-1,U=v0($,"(",")",W);if(U===-1){Q=J.exec($);continue}let B=$.slice(W+1,U),_=U+1,z=y$($,Z,Y,_);if(z===-1){Q=J.exec($);continue}let q=$.slice(_,z),j=z+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:B,content:q,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function E8($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=G$($,X);if(!J)return null;let Q=J.endPos,G=y$($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,B=null,_=0;while(U<K.length){let z=K.slice(U),q=z.match(/^@switch\s*\(/),j=z.match(/^@endswitch(?![a-z])/);if(q){if(_++,B)B.content+=q[0];U+=q[0].length;continue}if(j){if(_--,B)B.content+=j[0];U+=j[0].length;continue}if(_>0){if(B)B.content+=K[U];U++;continue}let H=z.match(/^@case\s*/),O=z.match(/^@default(?![a-z])/),F=z.match(/^@break(?![a-z])/);if(H&&z.startsWith("@case")){if(B)W.push(B);let L=U+H[0].length,V=G$(K,L);if(!V){U++;continue}B={type:"case",value:V.expression,content:""},U=V.endPos}else if(O&&z.startsWith("@default")){if(B)W.push(B);B={type:"default",content:""},U+=O[0].length}else if(F&&z.startsWith("@break"))U+=F[0].length;else{if(B)B.content+=K[U];U++}}if(B)W.push(B);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:W,start:Z,end:G+10}}var PU=()=>{};function fU($){let Z=[],Y=0;while(Y<$.length){let X=$.indexOf("{{",Y),J=$.indexOf("{!!",Y),Q=!1,G;if(X===-1&&J===-1)break;else if(X===-1)G=J,Q=!0;else if(J===-1)G=X,Q=!1;else if(J<X)G=J,Q=!0;else G=X,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",W=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,B=zw($,U,W);if(B===-1){Y=G+1;continue}let _=$.slice(U,B).trim(),z=B+W.length;Z.push({fullMatch:$.slice(G,z),expression:_,start:G,end:z,isRaw:Q}),Y=z}return Z}function zw($,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 gU($){let Z=I8($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=qw(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function qw($){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=PJ(G);return{name:X,args:K}}function PJ($){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 hU($,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 dU($){let Z=[],X=new u4($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let B=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let _=J<X.length?X[J].start:$.length,z=xU(X,J,$);J=z.nextIndex,Z.push({type:"variable",name:B,value:$.slice(_,z.endPos),exported:G,start:K.start,end:z.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let B=U.start,_=U.value==="{"?"}":"]",z=v0($,U.value,_,B);if(z!==-1){let q=$.slice(B,z+1);if(J=vU(X,z+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=xU(X,J,$);J=H.nextIndex;let O=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:O,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${O}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let B=U.value;J++;let _=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){_=X[J].start;break}J++}if(_!==-1){let z=v0($,"{","}",_);if(z!==-1)Z.push({type:"function",name:B,value:$.slice(W,z+1).replace(/^export\s+/,""),exported:G,start:W,end:z+1}),J=vU(X,z+1)}}}else J++}return Z}function xU($,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 vU($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var uU=()=>{};var p4=D(()=>{PU();uU()});function jw($,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=E8(X,G);if(!K)break;try{let W;if(H0(K.expression))W=O0(K.expression,Object.keys(Z))(...Object.values(Z));else W=z0(K.expression,Z);let U="",B=!1;for(let _ of K.cases)if(_.type==="default"){if(!B)U=_.content.trim()}else try{let z;if(_.value&&H0(_.value))z=O0(_.value,Object.keys(Z))(...Object.values(Z));else if(_.value)z=z0(_.value,Z);if(W===z){U=_.content.trim(),B=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(W){let U=W instanceof Error?W.message:String(W),B=J0("Switch",`Error evaluating @switch expression: ${U}`,e.EVALUATION_ERROR);X=X.substring(0,G)+B+X.substring(K.end);break}}return X}function q5($,Z,Y){let X=$;X=jw(X,Z,Y);{let Q=!0;while(Q){Q=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=G$(X,K+7);if(!W)break;let U=W.endPos,B=y$(X,"unless","endunless",U);if(B===-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(U,B),z=W.expression,q=-1;{let H=0,O=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,L=/@else(?![a-z])/g,V=[],N;while((N=O.exec(_))!==null)V.push({pos:N.index,type:"open"});while((N=F.exec(_))!==null)V.push({pos:N.index,type:"close"});while((N=L.exec(_))!==null)V.push({pos:N.index,type:"else"});V.sort((A,w)=>A.pos-w.pos);for(let A of V)if(A.type==="open")H++;else if(A.type==="close")H--;else if(A.type==="else"&&H===0){q=A.pos;break}}let j;if(q!==-1){let H=_.slice(0,q),O=_.slice(q+5);j=`@if (${z})${O}@else ${H}@endif`}else j=`@if (!(${z}))${_}@endif`;X=X.substring(0,K)+j+X.substring(B+10),Q=!0}}X=vJ(X,Z,Y),X=fJ(X,Z,Y),X=xJ(X,Z);let J=()=>{let Q=A7(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let W="",U=!1;for(let B of K.branches){if(U)break;if(B.type==="else")W=B.content,U=!0;else try{let _;if(B.condition&&H0(B.condition))_=O0(B.condition,Object.keys(Z))(...Object.values(Z));else if(B.condition)_=z0(B.condition,Z);if(_)W=B.content,U=!0}catch(_){W=J0(B.type==="if"?"If":"Elseif",`Error in @${B.type}(${B.condition}): ${_ instanceof Error?_.message:String(_)}`,e.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+W+X.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),B=J0("If",`Error processing @if block: ${U}`,e.EVALUATION_ERROR);X=X.substring(0,K.start)+B+X.substring(K.end)}}return!0};while(J());return X}function mU($){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 xJ($,Z){let Y=$;function X(K,W,U,B){let _=1,z=B,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(z<K.length&&_>0){q.lastIndex=z,j.lastIndex=z;let H=q.exec(K),O=j.exec(K),F=H?H.index:1/0,L=O?O.index:1/0;if(F<L)_++,z=F+H[0].length;else if(L<1/0){if(_--,_===0)return L;z=L+O[0].length}else break}return-1}function J(K,W,U){let B=0,_=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),z=new RegExp(`@${U}(?![a-z])`,"g"),q=/@else(?![a-z])/g,j=[],H;while((H=_.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=z.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=q.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((O,F)=>O.pos-F.pos);for(let O of j)if(O.type==="open")B++;else if(O.type==="close")B--;else if(O.type==="else"&&B===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,B,_,z=Y.slice(U+5),q=mU(z);if(q)B=q.value,_=U+5+q.consumed;else _=U+5;let j=X(Y,"auth","endauth",_);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(_,j),O=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=B?Q$(`auth?.check && auth?.user?.[${B}]`,Z):Q$("auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),N=H.slice(O+5);L=F?V:N}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,B,_,z=Y.slice(U+6),q=mU(z);if(q)B=q.value,_=U+6+q.consumed;else _=U+6;let j=X(Y,"guest","endguest",_);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(_,j),O=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=B?Q$(`!auth?.check || !auth?.user?.[${B}]`,Z):Q$("!auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),N=H.slice(O+5);L=F?V:N}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let B=[K];if(W)B.push(W);if(U){let _=Q$(U,Z);B.push(_)}return Z.permissions.check(...B)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,U=K==="can"?"elsecan":"elsecannot",B=!0;while(B){B=!1;let _=Y.match(new RegExp(`@${K}\\s*\\(`));if(!_||_.index===void 0)break;let z=_.index,q=Y.slice(z+`@${K}`.length),j=G(q);if(!j)break;let H=z+`@${K}`.length+j.paramsEnd,O=X(Y,K,W,H);if(O===-1){console.warn(`[stx] @${K} directive at position ${z} has no matching @${W} \u2014 the block was skipped.`);break}let F=Y.slice(H,O),L=[],V=0,N=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${W}(?![a-z])`,"g"),w=new RegExp(`@${U}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],I;while((I=N.exec(F))!==null)T.push({pos:I.index,type:"open"});while((I=A.exec(F))!==null)T.push({pos:I.index,type:"close"});while((I=w.exec(F))!==null)T.push({pos:I.index,type:"elseDirective"});while((I=R.exec(F))!==null)T.push({pos:I.index,type:"else"});T.sort((b,f)=>b.pos-f.pos);for(let b of T){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)L.push(b)}let E=[],S=0;for(let b=0;b<L.length;b++){let f=L[b];if(E.push({content:F.slice(S,f.pos),ability:void 0}),f.type==="elseDirective"){let r=F.slice(f.pos+`@${U}`.length),u=G(r);if(u){E[E.length-1]={content:F.slice(S,f.pos)},S=f.pos+`@${U}`.length+u.paramsEnd,E.push({content:"",ability:u.ability,type:u.type,id:u.id}),E.pop();let C=L[b+1],h=C?C.pos:F.length;E.push({content:F.slice(S,h),ability:u.ability,type:u.type,id:u.id}),S=h}}else S=f.pos+5}if(S<F.length){let b=E[E.length-1];if(L.length>0&&L[L.length-1].type==="else")E.push({content:F.slice(S),isFinalElse:!0});else if(E.length===0)E.push({content:F.slice(S)})}let k=Q(j.ability,j.type,j.id),P=K==="can"?k:!k,y="";if(P)y=E[0]?.content||"";else{let b=!1;for(let f=1;f<E.length;f++){let r=E[f];if(r.isFinalElse){y=r.content,b=!0;break}if(r.ability){let u=Q(r.ability,r.type,r.id);if(K==="can"?u:!u){y=r.content,b=!0;break}}}if(!b&&E.length>0){let f=E[E.length-1];if(f.isFinalElse)y=f.content}}Y=Y.substring(0,z)+y+Y.substring(O+`@${W}`.length),B=!0}}return Y}function vJ($,Z,Y){let X=$;function J(Q,G,K,W,U){let B=!0;while(B){B=!1;let _=new RegExp(`@${G}\\s*\\(`),z=Q.match(_);if(!z||z.index===void 0)break;let q=z.index,j=G$(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,O=y$(Q,G,K,H);if(O===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,O),L=j.expression,V=-1,N=0,A=0;while(A<F.length){let w=F.indexOf("@",A);if(w===-1)break;let R=F.substring(w);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){N++,A=w+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){N--,A=w+1;continue}if(N===0&&/^@else(?![a-z])/.test(R)){V=w;break}A=w+1}try{let w=W(L.trim()),R;if(V!==-1){let T=F.slice(0,V),I=F.slice(V+5);R=w?T:I}else R=w?F:"";Q=Q.substring(0,q)+R+Q.substring(O+`@${K}`.length),B=!0}catch(w){let R=w instanceof Error?w.message:String(w),T=J0(U,`Error processing @${G} directive: ${R}`,e.EVALUATION_ERROR);Q=Q.substring(0,q)+T+Q.substring(O+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=Q$(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=Q$(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 fJ($,Z,Y){let X=$,J="development";function Q(G,K,W,U){let B=new RegExp(`@${K}(?![a-z])`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),z=new RegExp(`^@${K}(?![a-z])`),q=new RegExp(`^@${W}(?![a-z])`),j=G,H=!0;while(H){H=!1,B.lastIndex=0;let O=B.exec(j);if(!O)break;let F=O.index,L=F+O[0].length;if(K==="env"){let k=j.substring(L).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!k)break;L+=k[0].length,U=J===k[2]}let V=1,N=L,A=-1;while(V>0&&N<j.length){B.lastIndex=N,_.lastIndex=N;let k=B.exec(j),P=_.exec(j),y=k?k.index:1/0,b=P?P.index:1/0;if(y<b)V++,N=y+k[0].length;else if(b<1/0){if(V--,V===0){A=b;break}N=b+P[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${W} \u2014 the block was skipped.`);break}let w=j.substring(L,A),R=-1,T=0,I=0;while(I<w.length){let k=w.indexOf("@",I);if(k===-1)break;let P=w.substring(k);if(z.test(P)){T++,I=k+1;continue}if(q.test(P)){T--,I=k+1;continue}if(T===0&&/^@else(?![a-z])/.test(P)){R=k;break}I=k+1}let E;if(R!==-1){let k=w.slice(0,R),P=w.slice(R+5);E=U?k:P}else E=U?w:"";let S=`@${W}`.length;j=j.substring(0,F)+E+j.substring(A+S),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var D8=D(()=>{bJ();j1();p4();d0()});function hJ($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function P$($,Z){if(!$)return Z?.nonceGenerator?.()??hJ();let Y=gJ.get($);if(!Y)Y=Z?.nonceGenerator?.()??hJ(),gJ.set($,Y);return Y}function Hw($){gJ.delete($)}function dJ($,Z){let Y=[];for(let[X,J]of Object.entries($)){if(J===void 0||J===null)continue;if(typeof J==="boolean"){if(J)Y.push(X);continue}if(Array.isArray(J)){let Q=[...J];if(Z&&(X==="script-src"||X==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)Y.push(`${X} ${Q.join(" ")}`)}}return Y.join("; ")}function S8($,Z){return`<meta http-equiv="Content-Security-Policy" content="${dJ($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function Ow($){return{enabled:!0,directives:{strict:pU,moderate:k8,relaxed:cU,api:lU}[$]||k8,useNonce:$==="strict",addMetaTag:!0}}function Lw($,Z){let Y={...$};for(let[X,J]of Object.entries(Z)){let Q=X,G=Y[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")Y[Q]=G||J;else if(Array.isArray(J)){let K=Array.isArray(G)?G:[],W=[...new Set([...K,...J])];Y[Q]=W}}return Y}function uJ($,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?P$(Y,Z):void 0,J=S8(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
3865
|
+
`)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,W=!1;while(Q<$.length){let U=$[Q];if(G&&W){W=!1,Q++;continue}if(G&&U==="\\"){W=!0,Q++;continue}if(W=!1,(U==='"'||U==="'"||U==="`")&&!G){G=U,Q++;continue}if(U===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&U==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&U==="}"){K--,Q++;continue}if(U==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(U===Z)J++;else if(U===Y){if(J--,J===0)return Q}Q++}return-1}function CJ($,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 I8($){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 G$($,Z){let Y=_w($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function _w($,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 y$($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),B=W?W.index:1/0,_=U?U.index:1/0;if(B<_)J++,Q=B+W[0].length;else if(_<1/0){if(J--,J===0)return _;Q=_+U[0].length}else break}return-1}function yJ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=G$($,X);if(!J)return null;let Q=J.endPos,G=y$($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,B="if",_=J.expression,z=0,q=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){q++,U++;continue}if(/^@endif(?![a-z])/.test(H)){q--,U+=6;continue}if(q===0){let O=H.match(/^@elseif\s*/);if(O){W.push({type:B,condition:_,content:K.substring(z,U),start:Q+z,end:Q+U});let F=U+O[0].length,L=G$(K,F);if(!L){U++;continue}B="elseif",_=L.expression,U=L.endPos,z=U;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:B,condition:_,content:K.substring(z,U),start:Q+z,end:Q+U}),B="else",_=void 0,U+=5,z=U;continue}}U++}return W.push({type:B,condition:_,content:K.slice(z),start:Q+z,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function A7($){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=yJ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function m4($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,W=K+Q[0].length-1,U=v0($,"(",")",W);if(U===-1){Q=J.exec($);continue}let B=$.slice(W+1,U),_=U+1,z=y$($,Z,Y,_);if(z===-1){Q=J.exec($);continue}let q=$.slice(_,z),j=z+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:B,content:q,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function E8($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=G$($,X);if(!J)return null;let Q=J.endPos,G=y$($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,B=null,_=0;while(U<K.length){let z=K.slice(U),q=z.match(/^@switch\s*\(/),j=z.match(/^@endswitch(?![a-z])/);if(q){if(_++,B)B.content+=q[0];U+=q[0].length;continue}if(j){if(_--,B)B.content+=j[0];U+=j[0].length;continue}if(_>0){if(B)B.content+=K[U];U++;continue}let H=z.match(/^@case\s*/),O=z.match(/^@default(?![a-z])/),F=z.match(/^@break(?![a-z])/);if(H&&z.startsWith("@case")){if(B)W.push(B);let L=U+H[0].length,V=G$(K,L);if(!V){U++;continue}B={type:"case",value:V.expression,content:""},U=V.endPos}else if(O&&z.startsWith("@default")){if(B)W.push(B);B={type:"default",content:""},U+=O[0].length}else if(F&&z.startsWith("@break"))U+=F[0].length;else{if(B)B.content+=K[U];U++}}if(B)W.push(B);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:W,start:Z,end:G+10}}var PU=()=>{};function fU($){let Z=[],Y=0;while(Y<$.length){let X=$.indexOf("{{",Y),J=$.indexOf("{!!",Y),Q=!1,G;if(X===-1&&J===-1)break;else if(X===-1)G=J,Q=!0;else if(J===-1)G=X,Q=!1;else if(J<X)G=J,Q=!0;else G=X,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",W=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,B=zw($,U,W);if(B===-1){Y=G+1;continue}let _=$.slice(U,B).trim(),z=B+W.length;Z.push({fullMatch:$.slice(G,z),expression:_,start:G,end:z,isRaw:Q}),Y=z}return Z}function zw($,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 gU($){let Z=I8($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=qw(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function qw($){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=PJ(G);return{name:X,args:K}}function PJ($){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 hU($,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 dU($){let Z=[],X=new u4($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let B=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let _=J<X.length?X[J].start:$.length,z=xU(X,J,$);J=z.nextIndex,Z.push({type:"variable",name:B,value:$.slice(_,z.endPos),exported:G,start:K.start,end:z.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let B=U.start,_=U.value==="{"?"}":"]",z=v0($,U.value,_,B);if(z!==-1){let q=$.slice(B,z+1);if(J=vU(X,z+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=xU(X,J,$);J=H.nextIndex;let O=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:O,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${O}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let B=U.value;J++;let _=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){_=X[J].start;break}J++}if(_!==-1){let z=v0($,"{","}",_);if(z!==-1)Z.push({type:"function",name:B,value:$.slice(W,z+1).replace(/^export\s+/,""),exported:G,start:W,end:z+1}),J=vU(X,z+1)}}}else J++}return Z}function xU($,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 vU($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var uU=()=>{};var p4=D(()=>{PU();uU()});function jw($,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=E8(X,G);if(!K)break;try{let W;if(H0(K.expression))W=O0(K.expression,Object.keys(Z))(...Object.values(Z));else W=z0(K.expression,Z);let U="",B=!1;for(let _ of K.cases)if(_.type==="default"){if(!B)U=_.content.trim()}else try{let z;if(_.value&&H0(_.value))z=O0(_.value,Object.keys(Z))(...Object.values(Z));else if(_.value)z=z0(_.value,Z);if(W===z){U=_.content.trim(),B=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(W){let U=W instanceof Error?W.message:String(W),B=J0("Switch",`Error evaluating @switch expression: ${U}`,e.EVALUATION_ERROR);X=X.substring(0,G)+B+X.substring(K.end);break}}return X}function q5($,Z,Y){let X=$;X=jw(X,Z,Y);{let Q=!0;while(Q){Q=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=G$(X,K+7);if(!W)break;let U=W.endPos,B=y$(X,"unless","endunless",U);if(B===-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(U,B),z=W.expression,q=-1;{let H=0,O=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,L=/@else(?![a-z])/g,V=[],N;while((N=O.exec(_))!==null)V.push({pos:N.index,type:"open"});while((N=F.exec(_))!==null)V.push({pos:N.index,type:"close"});while((N=L.exec(_))!==null)V.push({pos:N.index,type:"else"});V.sort((A,w)=>A.pos-w.pos);for(let A of V)if(A.type==="open")H++;else if(A.type==="close")H--;else if(A.type==="else"&&H===0){q=A.pos;break}}let j;if(q!==-1){let H=_.slice(0,q),O=_.slice(q+5);j=`@if (${z})${O}@else ${H}@endif`}else j=`@if (!(${z}))${_}@endif`;X=X.substring(0,K)+j+X.substring(B+10),Q=!0}}X=vJ(X,Z,Y),X=fJ(X,Z,Y),X=xJ(X,Z);let J=()=>{let Q=A7(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let W="",U=!1;for(let B of K.branches){if(U)break;if(B.type==="else")W=B.content,U=!0;else try{let _;if(B.condition&&H0(B.condition))_=O0(B.condition,Object.keys(Z))(...Object.values(Z));else if(B.condition)_=z0(B.condition,Z);if(_)W=B.content,U=!0}catch(_){W=J0(B.type==="if"?"If":"Elseif",`Error in @${B.type}(${B.condition}): ${_ instanceof Error?_.message:String(_)}`,e.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+W+X.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),B=J0("If",`Error processing @if block: ${U}`,e.EVALUATION_ERROR);X=X.substring(0,K.start)+B+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function mU($){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 xJ($,Z){let Y=$;function X(K,W,U,B){let _=1,z=B,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(z<K.length&&_>0){q.lastIndex=z,j.lastIndex=z;let H=q.exec(K),O=j.exec(K),F=H?H.index:1/0,L=O?O.index:1/0;if(F<L)_++,z=F+H[0].length;else if(L<1/0){if(_--,_===0)return L;z=L+O[0].length}else break}return-1}function J(K,W,U){let B=0,_=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),z=new RegExp(`@${U}(?![a-z])`,"g"),q=/@else(?![a-z])/g,j=[],H;while((H=_.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=z.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=q.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((O,F)=>O.pos-F.pos);for(let O of j)if(O.type==="open")B++;else if(O.type==="close")B--;else if(O.type==="else"&&B===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,B,_,z=Y.slice(U+5),q=mU(z);if(q)B=q.value,_=U+5+q.consumed;else _=U+5;let j=X(Y,"auth","endauth",_);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(_,j),O=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=B?Q$(`auth?.check && auth?.user?.[${B}]`,Z):Q$("auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),N=H.slice(O+5);L=F?V:N}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,B,_,z=Y.slice(U+6),q=mU(z);if(q)B=q.value,_=U+6+q.consumed;else _=U+6;let j=X(Y,"guest","endguest",_);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(_,j),O=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=B?Q$(`!auth?.check || !auth?.user?.[${B}]`,Z):Q$("!auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),N=H.slice(O+5);L=F?V:N}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let B=[K];if(W)B.push(W);if(U){let _=Q$(U,Z);B.push(_)}return Z.permissions.check(...B)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,U=K==="can"?"elsecan":"elsecannot",B=!0;while(B){B=!1;let _=Y.match(new RegExp(`@${K}\\s*\\(`));if(!_||_.index===void 0)break;let z=_.index,q=Y.slice(z+`@${K}`.length),j=G(q);if(!j)break;let H=z+`@${K}`.length+j.paramsEnd,O=X(Y,K,W,H);if(O===-1){console.warn(`[stx] @${K} directive at position ${z} has no matching @${W} \u2014 the block was skipped.`);break}let F=Y.slice(H,O),L=[],V=0,N=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${W}(?![a-z])`,"g"),w=new RegExp(`@${U}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],I;while((I=N.exec(F))!==null)T.push({pos:I.index,type:"open"});while((I=A.exec(F))!==null)T.push({pos:I.index,type:"close"});while((I=w.exec(F))!==null)T.push({pos:I.index,type:"elseDirective"});while((I=R.exec(F))!==null)T.push({pos:I.index,type:"else"});T.sort((b,f)=>b.pos-f.pos);for(let b of T){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)L.push(b)}let E=[],S=0;for(let b=0;b<L.length;b++){let f=L[b];if(E.push({content:F.slice(S,f.pos),ability:void 0}),f.type==="elseDirective"){let r=F.slice(f.pos+`@${U}`.length),u=G(r);if(u){E[E.length-1]={content:F.slice(S,f.pos)},S=f.pos+`@${U}`.length+u.paramsEnd,E.push({content:"",ability:u.ability,type:u.type,id:u.id}),E.pop();let C=L[b+1],h=C?C.pos:F.length;E.push({content:F.slice(S,h),ability:u.ability,type:u.type,id:u.id}),S=h}}else S=f.pos+5}if(S<F.length){let b=E[E.length-1];if(L.length>0&&L[L.length-1].type==="else")E.push({content:F.slice(S),isFinalElse:!0});else if(E.length===0)E.push({content:F.slice(S)})}let k=Q(j.ability,j.type,j.id),P=K==="can"?k:!k,y="";if(P)y=E[0]?.content||"";else{let b=!1;for(let f=1;f<E.length;f++){let r=E[f];if(r.isFinalElse){y=r.content,b=!0;break}if(r.ability){let u=Q(r.ability,r.type,r.id);if(K==="can"?u:!u){y=r.content,b=!0;break}}}if(!b&&E.length>0){let f=E[E.length-1];if(f.isFinalElse)y=f.content}}Y=Y.substring(0,z)+y+Y.substring(O+`@${W}`.length),B=!0}}return Y}function vJ($,Z,Y){let X=$;function J(Q,G,K,W,U){let B=!0;while(B){B=!1;let _=new RegExp(`@${G}\\s*\\(`),z=Q.match(_);if(!z||z.index===void 0)break;let q=z.index,j=G$(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,O=y$(Q,G,K,H);if(O===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,O),L=j.expression,V=-1,N=0,A=0;while(A<F.length){let w=F.indexOf("@",A);if(w===-1)break;let R=F.substring(w);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){N++,A=w+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){N--,A=w+1;continue}if(N===0&&/^@else(?![a-z])/.test(R)){V=w;break}A=w+1}try{let w=W(L.trim()),R;if(V!==-1){let T=F.slice(0,V),I=F.slice(V+5);R=w?T:I}else R=w?F:"";Q=Q.substring(0,q)+R+Q.substring(O+`@${K}`.length),B=!0}catch(w){let R=w instanceof Error?w.message:String(w),T=J0(U,`Error processing @${G} directive: ${R}`,e.EVALUATION_ERROR);Q=Q.substring(0,q)+T+Q.substring(O+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=Q$(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=Q$(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 fJ($,Z,Y){let X=$,J="development";function Q(G,K,W,U){let B=new RegExp(`@${K}(?![a-z])`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),z=new RegExp(`^@${K}(?![a-z])`),q=new RegExp(`^@${W}(?![a-z])`),j=G,H=!0;while(H){H=!1,B.lastIndex=0;let O=B.exec(j);if(!O)break;let F=O.index,L=F+O[0].length;if(K==="env"){let k=j.substring(L).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!k)break;L+=k[0].length,U=J===k[2]}let V=1,N=L,A=-1;while(V>0&&N<j.length){B.lastIndex=N,_.lastIndex=N;let k=B.exec(j),P=_.exec(j),y=k?k.index:1/0,b=P?P.index:1/0;if(y<b)V++,N=y+k[0].length;else if(b<1/0){if(V--,V===0){A=b;break}N=b+P[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${W} \u2014 the block was skipped.`);break}let w=j.substring(L,A),R=-1,T=0,I=0;while(I<w.length){let k=w.indexOf("@",I);if(k===-1)break;let P=w.substring(k);if(z.test(P)){T++,I=k+1;continue}if(q.test(P)){T--,I=k+1;continue}if(T===0&&/^@else(?![a-z])/.test(P)){R=k;break}I=k+1}let E;if(R!==-1){let k=w.slice(0,R),P=w.slice(R+5);E=U?k:P}else E=U?w:"";let S=`@${W}`.length;j=j.substring(0,F)+E+j.substring(A+S),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var D8=D(()=>{bJ();j1();p4();d0()});function hJ($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function P$($,Z){if(!$)return Z?.nonceGenerator?.()??hJ();let Y=gJ.get($);if(!Y)Y=Z?.nonceGenerator?.()??hJ(),gJ.set($,Y);return Y}function Hw($){gJ.delete($)}function dJ($,Z){let Y=[];for(let[X,J]of Object.entries($)){if(J===void 0||J===null)continue;if(typeof J==="boolean"){if(J)Y.push(X);continue}if(Array.isArray(J)){let Q=[...J];if(Z&&(X==="script-src"||X==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)Y.push(`${X} ${Q.join(" ")}`)}}return Y.join("; ")}function S8($,Z){return`<meta http-equiv="Content-Security-Policy" content="${dJ($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function Ow($){return{enabled:!0,directives:{strict:pU,moderate:k8,relaxed:cU,api:lU}[$]||k8,useNonce:$==="strict",addMetaTag:!0}}function Lw($,Z){let Y={...$};for(let[X,J]of Object.entries(Z)){let Q=X,G=Y[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")Y[Q]=G||J;else if(Array.isArray(J)){let K=Array.isArray(G)?G:[],W=[...new Set([...K,...J])];Y[Q]=W}}return Y}function uJ($,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?P$(Y,Z):void 0,J=S8(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
3866
3866
|
${J}`)}function Fw($,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 mJ($,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?P$(Z,Q):void 0;return S8(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return P$(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=P$(Z,Q);return J}function Vw(){return[iU,nU]}function Nw($){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 sU($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function Aw($,Z){if(!$.enabled)return{};let Y=$.useNonce?P$(Z,$):void 0,X=dJ($.directives,Y);return{[sU($.reportOnly)]:X}}var gJ,pU,k8,cU,lU,iU,nU,ww;var pJ=D(()=>{gJ=new WeakMap;pU={"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},k8={"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},cU={"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'"]},lU={"default-src":["'none'"],"frame-ancestors":["'none'"]};iU={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?P$(Y,Q):void 0;return S8(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},nU={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return P$(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};ww={enabled:!1,reportOnly:!1,directives:k8,useNonce:!1,addMetaTag:!0}});import Rw from"crypto";function Tw($=Mw){let Z=Rw.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return cJ=Z,Z}function Iw(){if(!cJ)Tw();return cJ}function Ew($=rU){let Z=Iw();return`<input type="hidden" name="${$}" value="${Z}">`}function oU($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return Ew(X||rU)})}var Mw=40,rU="_token",cJ=null;var aU=()=>{};async function lJ($,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 Dw(J,Q,Z,Y,X);else J=await kw(J,Q,Z,Y,X)}return J}async function Dw($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,W=`@end${Q}`,U=$,B=c5(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${W}`,"g"),_=[],z=B.exec(U);while(z!==null){let[q,j="",H=""]=z,O=z.index||0;try{let F=j?tU(j):[],L=H.trim(),V=await G(L,F,Y,X);_.push({original:q,processed:V,startIndex:O})}catch(F){let L=F instanceof Error?F.message:String(F);if(J.debug)console.error(`Error processing custom directive @${Q}:`,F);_.push({original:q,processed:J0("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${L}`,e.EVALUATION_ERROR),startIndex:O})}z=B.exec(U)}for(let q=_.length-1;q>=0;q--){let{original:j,processed:H}=_[q];U=U.replace(j,H)}return U}async function kw($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,W=c5(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),U=[],B=W.exec(K);while(B!==null){let[q,j=""]=B,H=B.index||0;try{let O=tU(j),F=await G("",O,Y,X);U.push({original:q,processed:F,startIndex:H})}catch(O){let F=O instanceof Error?O.message:String(O);if(J.debug)console.error(`Error processing custom directive @${Q}:`,O);U.push({original:q,processed:J0("CustomDirective",`Error in @${Q}(${j}): ${F}`,e.EVALUATION_ERROR),startIndex:H})}B=W.exec(K)}let _=c5(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),z=_.exec(K);while(z!==null){let[q]=z,j=z.index||0;try{let H=await G("",[],Y,X);U.push({original:q,processed:H,startIndex:j})}catch(H){let O=H instanceof Error?H.message:String(H);if(J.debug)console.error(`Error processing custom directive @${Q}:`,H);U.push({original:q,processed:J0("CustomDirective",`Error in @${Q}: ${O}`,e.EVALUATION_ERROR),startIndex:j})}z=_.exec(K)}for(let q=U.length-1;q>=0;q--){let{original:j,processed:H}=U[q];K=K.replace(j,H)}return K}function tU($){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 iJ=D(()=>{j1();_5()});var y8={};Z0(y8,{useTitle:()=>ZB,useSeoMeta:()=>c4,usePageTitle:()=>ZB,useHead:()=>v$,resetHead:()=>eU,renderHtmlAttrs:()=>XB,renderHead:()=>YB,renderBodyAttrs:()=>JB,processTitleDirective:()=>KB,processMetaDirective:()=>WB,processHeadDirective:()=>GB,getPageMeta:()=>C8,getHead:()=>w7,definePageMeta:()=>$B,applyHead:()=>QB});function w7(){return x$}function C8(){return b8}function eU(){x$={},Sw.length=0,b8={}}function v$($){x$=bw(x$,$)}function bw($,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 c4($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let W=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:W})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,X=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(X)Z.push({property:"og:description",content:X});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let J=$.twitterTitle??$.title,Q=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(J)Z.push({name:"twitter:title",content:J});if(Q)Z.push({name:"twitter:description",content:Q});if(G)Z.push({name:"twitter:image",content:G});if($.twitterSite)Z.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)Z.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)Z.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)Z.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)Z.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)Z.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let W of $.articleTags)Z.push({property:"article:tag",content:W});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});v$({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function $B($){if(b8={...b8,...$},$.title||$.description)c4({title:$.title,description:$.description})}function ZB($){let Z=typeof $==="function"?$():$;v$({title:Z})}function YB($=x$){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${j5(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${j5(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}="${j5(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}="${j5(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}="${j5(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(`
|
|
3867
3867
|
`)}function XB($=x$){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${j5(Y)}"`).join(" ")}function JB($=x$){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${j5(Y)}"`).join(" ")}function j5($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function QB($=x$){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 GB($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
|
|
3868
3868
|
`,""}),headContent:Z.trim()}}function KB($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return v$({title:G}),""})}function WB($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let W=Q?G:K,U=Q?W:Z[(W||"").trim()]??W,_=J.includes(":")?{property:J,content:U}:{name:J,content:U};return v$({meta:[_]}),""})}var x$,Sw,b8;var f$=D(()=>{x$={},Sw=[],b8={}});import Cw from"crypto";function s0($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function yw($){return{...x8,...$.forms?.classes}}function P8($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function Pw(){return Cw.randomUUID()}function xw($,Z,Y,X){let J=yw(X),Q=$;return Q=zB(Q,Z),Q=R7(Q,Z),Q=v8(Q,Z,J),Q=f8(Q,Z,J),Q}function R7($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=Pw();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${s0(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="${s0(Q)}">`;return X}),Y}function v8($,Z,Y=x8){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,W,U="")=>{let B=Q||G||"POST",_=K||W||"",z=g$(U),q=B.toUpperCase(),j=["GET","POST"].includes(q)?q:"POST",H=`<form method="${s0(j)}" action="${s0(_)}"${z?` ${z}`:""}>`;if(H+=`
|
package/dist/interactive.js
CHANGED
|
@@ -3769,7 +3769,7 @@ ${Y}
|
|
|
3769
3769
|
</script>`}function cZ($,Z,Y){if(pZ=0,!eq($))return $;let X=iq($);if(X.length===0)return $;let J=tq($,X),Q=aq(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 tq($,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*["']${J4(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*["']${J4(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*"${J4(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*'${J4(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 eq($){return/x-data\s*=\s*["']/.test($)}var pZ=0,cq=0;var iZ=P(()=>{l0()});import $z from"fs";import N3 from"path";import{createHighlighter as Zz}from"ts-syntax-highlighter";async function Yz($,Z={}){try{if(!await i($))throw Error(`Markdown file not found: ${$}`);let X=(await $z.promises.stat($)).mtime.getTime();if(Z.cache&&T3.has($)){let W=T3.get($);if(W.updatedAt>=X)return{content:W.content,data:W.data}}let J=await Bun.file($).text(),{data:Q,content:G}=r9(J),K=Z.markdown||B3.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},z=y5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)z=await Xz(z,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let U={content:z,data:Q||{}};if(Z.cache)T3.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 Xz($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!Q4)try{Q4=await Zz({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,q,z,U)=>{let W=U.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),_=z||(Y?"text":"");if(!_)return K;try{if(!Q4.getSupportedLanguages().includes(_))return K;return(await Q4.highlight(W,_,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${z}:`,B)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[q,z,U,W]=K,_=await J(q,z,U,W);Q=Q.replace(q,_)}return Q}async function nZ($,Z,Y="",X={}){return await Jz($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,q,z)=>{try{let U=K;if(!N3.isAbsolute(K))U=N3.resolve(N3.dirname(Y),K);let W={};if(q)try{try{W=JSON.parse(q)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let O=q.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let 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[w]=R}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:_,data:B}=await Yz(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 Q0("Markdown File",`Error including markdown file: ${W}`,Y,$,z,G)}})}async function Jz($,Z,Y){let X=[],J;while((J=Z.exec($))!==null){let K=J[0],q=J.index,z=J;X.push(Y(...z).then((U)=>({match:K,replacement:U,index:q})))}let Q=await Promise.all(X);Q.sort((K,q)=>q.index-K.index);let G=$;for(let{match:K,replacement:q}of Q)G=G.replace(K,()=>q);return G}var T3,Q4=null;var oZ=P(()=>{x5();A0();T3=new Map});function j1($,Z){try{let Y=$.trim();if(Z0(Y))return Y0(Y,Object.keys(Z))(...Object.values(Z));else return $0(Y,Z)}catch{return!1}}var sZ=P(()=>{w0()});class G4{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,q=!1;while(Q<$.length){let z=$[Q];if(G&&q){q=!1,Q++;continue}if(G&&z==="\\"){q=!0,Q++;continue}if(q=!1,(z==='"'||z==="'"||z==="`")&&!G){G=z,Q++;continue}if(z===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&z==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&z==="}"){K--,Q++;continue}if(z==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(z===Z)J++;else if(z===Y){if(J--,J===0)return Q}Q++}return-1}function rZ($,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 M3($){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=Qz($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Qz($,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 v1($,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 q=G.exec($),z=K.exec($),U=q?q.index:1/0,W=z?z.index:1/0;if(U<W)J++,Q=U+q[0].length;else if(W<1/0){if(J--,J===0)return W;Q=W+z[0].length}else break}return-1}function aZ($,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=v1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],z=0,U="if",W=J.expression,_=0,B=0;while(z<K.length){let j=K.indexOf("@",z);if(j===-1)break;z=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,z++;continue}if(/^@endif(?![a-z])/.test(H)){B--,z+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){q.push({type:U,condition:W,content:K.substring(_,z),start:Q+_,end:Q+z});let F=z+L[0].length,O=H1(K,F);if(!O){z++;continue}U="elseif",W=O.expression,z=O.endPos,_=z;continue}else if(/^@else(?![a-z])/.test(H)){q.push({type:U,condition:W,content:K.substring(_,z),start:Q+_,end:Q+z}),U="else",W=void 0,z+=5,_=z;continue}}z++}return q.push({type:U,condition:W,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:q,start:Z,end:G+6}}function g5($){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=aZ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function K4($,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,q=K+Q[0].length-1,z=F0($,"(",")",q);if(z===-1){Q=J.exec($);continue}let U=$.slice(q+1,z),W=z+1,_=v1($,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 I3($,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=v1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],z=0,U=null,W=0;while(z<K.length){let _=K.slice(z),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(W++,U)U.content+=B[0];z+=B[0].length;continue}if(j){if(W--,U)U.content+=j[0];z+=j[0].length;continue}if(W>0){if(U)U.content+=K[z];z++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(U)q.push(U);let O=z+H[0].length,V=H1(K,O);if(!V){z++;continue}U={type:"case",value:V.expression,content:""},z=V.endPos}else if(L&&_.startsWith("@default")){if(U)q.push(U);U={type:"default",content:""},z+=L[0].length}else if(F&&_.startsWith("@break"))z+=F[0].length;else{if(U)U.content+=K[z];z++}}if(U)q.push(U);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:q,start:Z,end:G+10}}var tZ=()=>{};function Gz($){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)==="{{{"?"{{{":"{!!":"{{",q=Q?K==="{{{"?"}}}":"!!}":"}}",z=G+K.length,U=Kz($,z,q);if(U===-1){Y=G+1;continue}let W=$.slice(z,U).trim(),_=U+q.length;Z.push({fullMatch:$.slice(G,_),expression:W,start:G,end:_,isRaw:Q}),Y=_}return Z}function Kz($,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 qz($){let Z=M3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=zz(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function zz($){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=Z2(G);return{name:X,args:K}}function Z2($){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 Uz($,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 Wz($){let Z=[],X=new G4($).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 q=K.value;if(J++,J>=X.length)break;let z=X[J];if(z.type==="IDENTIFIER"){let U=z.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let W=J<X.length?X[J].start:$.length,_=eZ(X,J,$);J=_.nextIndex,Z.push({type:"variable",name:U,value:$.slice(W,_.endPos),exported:G,start:K.start,end:_.endPos})}}else if(z.type==="PUNCTUATION"&&(z.value==="{"||z.value==="[")){let U=z.start,W=z.value==="{"?"}":"]",_=F0($,z.value,W,U);if(_!==-1){let B=$.slice(U,_+1);if(J=$2(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=eZ(X,J,$);J=H.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,H.endPos)}; ${q} ${B} = ${L}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let q=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let z=X[J];if(z.type==="IDENTIFIER"){let U=z.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(q,_+1).replace(/^export\s+/,""),exported:G,start:q,end:_+1}),J=$2(X,_+1)}}}else J++}return Z}function eZ($,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 $2($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var Y2=()=>{};var q4=P(()=>{tZ();Y2()});function _z($,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=I3(X,G);if(!K)break;try{let q;if(Z0(K.expression))q=Y0(K.expression,Object.keys(Z))(...Object.values(Z));else q=$0(K.expression,Z);let z="",U=!1;for(let W of K.cases)if(W.type==="default"){if(!U)z=W.content.trim()}else try{let _;if(W.value&&Z0(W.value))_=Y0(W.value,Object.keys(Z))(...Object.values(Z));else if(W.value)_=$0(W.value,Z);if(q===_){z=W.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+z+X.substring(K.end),J=!0}catch(q){let z=q instanceof Error?q.message:String(q),U=a("Switch",`Error evaluating @switch expression: ${z}`,p.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function x1($,Z,Y){let X=$;X=_z(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,q=H1(X,K+7);if(!q)break;let z=q.endPos,U=v1(X,"unless","endunless",z);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(z,U),_=q.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(W))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(W))!==null)V.push({pos:A.index,type:"close"});while((A=O.exec(W))!==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=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=E3(X,Z,Y),X=k3(X,Z,Y),X=D3(X,Z);let J=()=>{let Q=g5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let q="",z=!1;for(let U of K.branches){if(z)break;if(U.type==="else")q=U.content,z=!0;else try{let W;if(U.condition&&Z0(U.condition))W=Y0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)W=$0(U.condition,Z);if(W)q=U.content,z=!0}catch(W){q=a(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${W instanceof Error?W.message:String(W)}`,p.EVALUATION_ERROR),z=!0}}X=X.substring(0,K.start)+q+X.substring(K.end)}catch(q){let z=q instanceof Error?q.message:String(q),U=a("If",`Error processing @if block: ${z}`,p.EVALUATION_ERROR);X=X.substring(0,K.start)+U+X.substring(K.end)}}return!0};while(J());return X}function X2($){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 D3($,Z){let Y=$;function X(K,q,z,U){let W=1,_=U,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${z}(?![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,q,z){let U=0,W=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${z}(?![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 q=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let z=q.index,U,W,_=Y.slice(z+5),B=X2(_);if(B)U=B.value,W=z+5+B.consumed;else W=z+5;let j=X(Y,"auth","endauth",W);if(j===-1){console.warn(`[stx] @auth directive at position ${z} 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),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,z)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let q=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let z=q.index,U,W,_=Y.slice(z+6),B=X2(_);if(B)U=B.value,W=z+6+B.consumed;else W=z+6;let j=X(Y,"guest","endguest",W);if(j===-1){console.warn(`[stx] @guest directive at position ${z} 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),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,z)+O+Y.substring(j+9),K=!0}}function Q(K,q,z){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(q)U.push(q);if(z){let W=j1(z,Z);U.push(W)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let q=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!q)return null;return{ability:q[1],type:q[2],id:q[3]?.trim(),paramsEnd:q[0].length}}for(let K of["can","cannot"]){let q=`end${K}`,z=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,q,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${q} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${q}(?![a-z])`,"g"),R=new RegExp(`@${z}\\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((y,C)=>y.pos-C.pos);for(let y of T){if(y.type==="open"){V++;continue}if(y.type==="close"){V--;continue}if(V===0)O.push(y)}let I=[],E=0;for(let y=0;y<O.length;y++){let C=O[y];if(I.push({content:F.slice(E,C.pos),ability:void 0}),C.type==="elseDirective"){let m=F.slice(C.pos+`@${z}`.length),g=G(m);if(g){I[I.length-1]={content:F.slice(E,C.pos)},E=C.pos+`@${z}`.length+g.paramsEnd,I.push({content:"",ability:g.ability,type:g.type,id:g.id}),I.pop();let u=O[y+1],s=u?u.pos:F.length;I.push({content:F.slice(E,s),ability:g.ability,type:g.type,id:g.id}),E=s}}else E=C.pos+5}if(E<F.length){let y=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),k=K==="can"?D:!D,b="";if(k)b=I[0]?.content||"";else{let y=!1;for(let C=1;C<I.length;C++){let m=I[C];if(m.isFinalElse){b=m.content,y=!0;break}if(m.ability){let g=Q(m.ability,m.type,m.id);if(K==="can"?g:!g){b=m.content,y=!0;break}}}if(!y&&I.length>0){let C=I[I.length-1];if(C.isFinalElse)b=C.content}}Y=Y.substring(0,_)+b+Y.substring(L+`@${q}`.length),U=!0}}return Y}function E3($,Z,Y){let X=$;function J(Q,G,K,q,z){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=v1(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=q(O.trim()),N;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);N=R?T:M}else N=R?F:"";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=a(z,`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=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 k3($,Z,Y){let X=$,J="development";function Q(G,K,q,z){let U=new RegExp(`@${K}(?![a-z])`,"g"),W=new RegExp(`@${q}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${q}(?![a-z])`),j=G,H=!0;while(H){H=!1,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,z=J===D[2]}let V=1,A=O,w=-1;while(V>0&&A<j.length){U.lastIndex=A,W.lastIndex=A;let D=U.exec(j),k=W.exec(j),b=D?D.index:1/0,y=k?k.index:1/0;if(b<y)V++,A=b+D[0].length;else if(y<1/0){if(V--,V===0){w=y;break}A=y+k[0].length}else break}if(w===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${q} \u2014 the block was skipped.`);break}let R=j.substring(O,w),N=-1,T=0,M=0;while(M<R.length){let D=R.indexOf("@",M);if(D===-1)break;let k=R.substring(D);if(_.test(k)){T++,M=D+1;continue}if(B.test(k)){T--,M=D+1;continue}if(T===0&&/^@else(?![a-z])/.test(k)){N=D;break}M=D+1}let I;if(N!==-1){let D=R.slice(0,N),k=R.slice(N+5);I=z?D:k}else I=z?R:"";let E=`@${q}`.length;j=j.substring(0,F)+I+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 z4=P(()=>{sZ();Q1();q4();w0()});function J2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function f1($,Z){if(!$)return Z?.nonceGenerator?.()??J2();let Y=b3.get($);if(!Y)Y=Z?.nonceGenerator?.()??J2(),b3.set($,Y);return Y}function Zw($){b3.delete($)}function Q2($,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 y3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${Q2($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function Yw($){return{enabled:!0,directives:{strict:Bz,moderate:S3,relaxed:jz,api:Hz}[$]||S3,useNonce:$==="strict",addMetaTag:!0}}function Xw($,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:[],q=[...new Set([...K,...J])];Y[Q]=q}}return Y}function G2($,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?f1(Y,Z):void 0,J=y3(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,q=!1;while(Q<$.length){let z=$[Q];if(G&&q){q=!1,Q++;continue}if(G&&z==="\\"){q=!0,Q++;continue}if(q=!1,(z==='"'||z==="'"||z==="`")&&!G){G=z,Q++;continue}if(z===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&z==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&z==="}"){K--,Q++;continue}if(z==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(z===Z)J++;else if(z===Y){if(J--,J===0)return Q}Q++}return-1}function rZ($,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 M3($){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=Qz($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Qz($,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 v1($,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 q=G.exec($),z=K.exec($),U=q?q.index:1/0,W=z?z.index:1/0;if(U<W)J++,Q=U+q[0].length;else if(W<1/0){if(J--,J===0)return W;Q=W+z[0].length}else break}return-1}function aZ($,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=v1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],z=0,U="if",W=J.expression,_=0,B=0;while(z<K.length){let j=K.indexOf("@",z);if(j===-1)break;z=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,z++;continue}if(/^@endif(?![a-z])/.test(H)){B--,z+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){q.push({type:U,condition:W,content:K.substring(_,z),start:Q+_,end:Q+z});let F=z+L[0].length,O=H1(K,F);if(!O){z++;continue}U="elseif",W=O.expression,z=O.endPos,_=z;continue}else if(/^@else(?![a-z])/.test(H)){q.push({type:U,condition:W,content:K.substring(_,z),start:Q+_,end:Q+z}),U="else",W=void 0,z+=5,_=z;continue}}z++}return q.push({type:U,condition:W,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:q,start:Z,end:G+6}}function g5($){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=aZ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function K4($,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,q=K+Q[0].length-1,z=F0($,"(",")",q);if(z===-1){Q=J.exec($);continue}let U=$.slice(q+1,z),W=z+1,_=v1($,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 I3($,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=v1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],z=0,U=null,W=0;while(z<K.length){let _=K.slice(z),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(W++,U)U.content+=B[0];z+=B[0].length;continue}if(j){if(W--,U)U.content+=j[0];z+=j[0].length;continue}if(W>0){if(U)U.content+=K[z];z++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(U)q.push(U);let O=z+H[0].length,V=H1(K,O);if(!V){z++;continue}U={type:"case",value:V.expression,content:""},z=V.endPos}else if(L&&_.startsWith("@default")){if(U)q.push(U);U={type:"default",content:""},z+=L[0].length}else if(F&&_.startsWith("@break"))z+=F[0].length;else{if(U)U.content+=K[z];z++}}if(U)q.push(U);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:q,start:Z,end:G+10}}var tZ=()=>{};function Gz($){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)==="{{{"?"{{{":"{!!":"{{",q=Q?K==="{{{"?"}}}":"!!}":"}}",z=G+K.length,U=Kz($,z,q);if(U===-1){Y=G+1;continue}let W=$.slice(z,U).trim(),_=U+q.length;Z.push({fullMatch:$.slice(G,_),expression:W,start:G,end:_,isRaw:Q}),Y=_}return Z}function Kz($,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 qz($){let Z=M3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=zz(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function zz($){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=Z2(G);return{name:X,args:K}}function Z2($){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 Uz($,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 Wz($){let Z=[],X=new G4($).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 q=K.value;if(J++,J>=X.length)break;let z=X[J];if(z.type==="IDENTIFIER"){let U=z.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let W=J<X.length?X[J].start:$.length,_=eZ(X,J,$);J=_.nextIndex,Z.push({type:"variable",name:U,value:$.slice(W,_.endPos),exported:G,start:K.start,end:_.endPos})}}else if(z.type==="PUNCTUATION"&&(z.value==="{"||z.value==="[")){let U=z.start,W=z.value==="{"?"}":"]",_=F0($,z.value,W,U);if(_!==-1){let B=$.slice(U,_+1);if(J=$2(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=eZ(X,J,$);J=H.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,H.endPos)}; ${q} ${B} = ${L}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let q=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let z=X[J];if(z.type==="IDENTIFIER"){let U=z.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(q,_+1).replace(/^export\s+/,""),exported:G,start:q,end:_+1}),J=$2(X,_+1)}}}else J++}return Z}function eZ($,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 $2($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var Y2=()=>{};var q4=P(()=>{tZ();Y2()});function _z($,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=I3(X,G);if(!K)break;try{let q;if(Z0(K.expression))q=Y0(K.expression,Object.keys(Z))(...Object.values(Z));else q=$0(K.expression,Z);let z="",U=!1;for(let W of K.cases)if(W.type==="default"){if(!U)z=W.content.trim()}else try{let _;if(W.value&&Z0(W.value))_=Y0(W.value,Object.keys(Z))(...Object.values(Z));else if(W.value)_=$0(W.value,Z);if(q===_){z=W.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+z+X.substring(K.end),J=!0}catch(q){let z=q instanceof Error?q.message:String(q),U=a("Switch",`Error evaluating @switch expression: ${z}`,p.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function x1($,Z,Y){let X=$;X=_z(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,q=H1(X,K+7);if(!q)break;let z=q.endPos,U=v1(X,"unless","endunless",z);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(z,U),_=q.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(W))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(W))!==null)V.push({pos:A.index,type:"close"});while((A=O.exec(W))!==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=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=E3(X,Z,Y),X=k3(X,Z,Y),X=D3(X,Z);let J=()=>{let Q=g5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let q="",z=!1;for(let U of K.branches){if(z)break;if(U.type==="else")q=U.content,z=!0;else try{let W;if(U.condition&&Z0(U.condition))W=Y0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)W=$0(U.condition,Z);if(W)q=U.content,z=!0}catch(W){q=a(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${W instanceof Error?W.message:String(W)}`,p.EVALUATION_ERROR),z=!0}}X=X.substring(0,K.start)+q+X.substring(K.end)}catch(q){let z=q instanceof Error?q.message:String(q),U=a("If",`Error processing @if block: ${z}`,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 X2($){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 D3($,Z){let Y=$;function X(K,q,z,U){let W=1,_=U,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${z}(?![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,q,z){let U=0,W=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${z}(?![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 q=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let z=q.index,U,W,_=Y.slice(z+5),B=X2(_);if(B)U=B.value,W=z+5+B.consumed;else W=z+5;let j=X(Y,"auth","endauth",W);if(j===-1){console.warn(`[stx] @auth directive at position ${z} 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),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,z)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let q=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let z=q.index,U,W,_=Y.slice(z+6),B=X2(_);if(B)U=B.value,W=z+6+B.consumed;else W=z+6;let j=X(Y,"guest","endguest",W);if(j===-1){console.warn(`[stx] @guest directive at position ${z} 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),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,z)+O+Y.substring(j+9),K=!0}}function Q(K,q,z){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(q)U.push(q);if(z){let W=j1(z,Z);U.push(W)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let q=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!q)return null;return{ability:q[1],type:q[2],id:q[3]?.trim(),paramsEnd:q[0].length}}for(let K of["can","cannot"]){let q=`end${K}`,z=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,q,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${q} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${q}(?![a-z])`,"g"),R=new RegExp(`@${z}\\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((y,C)=>y.pos-C.pos);for(let y of T){if(y.type==="open"){V++;continue}if(y.type==="close"){V--;continue}if(V===0)O.push(y)}let I=[],E=0;for(let y=0;y<O.length;y++){let C=O[y];if(I.push({content:F.slice(E,C.pos),ability:void 0}),C.type==="elseDirective"){let m=F.slice(C.pos+`@${z}`.length),g=G(m);if(g){I[I.length-1]={content:F.slice(E,C.pos)},E=C.pos+`@${z}`.length+g.paramsEnd,I.push({content:"",ability:g.ability,type:g.type,id:g.id}),I.pop();let u=O[y+1],s=u?u.pos:F.length;I.push({content:F.slice(E,s),ability:g.ability,type:g.type,id:g.id}),E=s}}else E=C.pos+5}if(E<F.length){let y=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),k=K==="can"?D:!D,b="";if(k)b=I[0]?.content||"";else{let y=!1;for(let C=1;C<I.length;C++){let m=I[C];if(m.isFinalElse){b=m.content,y=!0;break}if(m.ability){let g=Q(m.ability,m.type,m.id);if(K==="can"?g:!g){b=m.content,y=!0;break}}}if(!y&&I.length>0){let C=I[I.length-1];if(C.isFinalElse)b=C.content}}Y=Y.substring(0,_)+b+Y.substring(L+`@${q}`.length),U=!0}}return Y}function E3($,Z,Y){let X=$;function J(Q,G,K,q,z){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=v1(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=q(O.trim()),N;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);N=R?T:M}else N=R?F:"";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=a(z,`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=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 k3($,Z,Y){let X=$,J="development";function Q(G,K,q,z){let U=new RegExp(`@${K}(?![a-z])`,"g"),W=new RegExp(`@${q}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${q}(?![a-z])`),j=G,H=!0;while(H){H=!1,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,z=J===D[2]}let V=1,A=O,w=-1;while(V>0&&A<j.length){U.lastIndex=A,W.lastIndex=A;let D=U.exec(j),k=W.exec(j),b=D?D.index:1/0,y=k?k.index:1/0;if(b<y)V++,A=b+D[0].length;else if(y<1/0){if(V--,V===0){w=y;break}A=y+k[0].length}else break}if(w===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${q} \u2014 the block was skipped.`);break}let R=j.substring(O,w),N=-1,T=0,M=0;while(M<R.length){let D=R.indexOf("@",M);if(D===-1)break;let k=R.substring(D);if(_.test(k)){T++,M=D+1;continue}if(B.test(k)){T--,M=D+1;continue}if(T===0&&/^@else(?![a-z])/.test(k)){N=D;break}M=D+1}let I;if(N!==-1){let D=R.slice(0,N),k=R.slice(N+5);I=z?D:k}else I=z?R:"";let E=`@${q}`.length;j=j.substring(0,F)+I+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 z4=P(()=>{sZ();Q1();q4();w0()});function J2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function f1($,Z){if(!$)return Z?.nonceGenerator?.()??J2();let Y=b3.get($);if(!Y)Y=Z?.nonceGenerator?.()??J2(),b3.set($,Y);return Y}function Zw($){b3.delete($)}function Q2($,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 y3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${Q2($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function Yw($){return{enabled:!0,directives:{strict:Bz,moderate:S3,relaxed:jz,api:Hz}[$]||S3,useNonce:$==="strict",addMetaTag:!0}}function Xw($,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:[],q=[...new Set([...K,...J])];Y[Q]=q}}return Y}function G2($,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?f1(Y,Z):void 0,J=y3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
3773
3773
|
${J}`)}function Jw($,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 K2($,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?f1(Z,Q):void 0;return y3(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return f1(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=f1(Z,Q);return J}function Qw(){return[Oz,Lz]}function Gw($){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 Fz($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function Kw($,Z){if(!$.enabled)return{};let Y=$.useNonce?f1(Z,$):void 0,X=Q2($.directives,Y);return{[Fz($.reportOnly)]:X}}var b3,Bz,S3,jz,Hz,Oz,Lz,qw;var q2=P(()=>{b3=new WeakMap;Bz={"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},S3={"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},jz={"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'"]},Hz={"default-src":["'none'"],"frame-ancestors":["'none'"]};Oz={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?f1(Y,Q):void 0;return y3(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},Lz={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return f1(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};qw={enabled:!1,reportOnly:!1,directives:S3,useNonce:!1,addMetaTag:!0}});import{Buffer as z2}from"buffer";import U2 from"crypto";function wz($=Vz){let Z=U2.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return W5=Z,Z}function Az(){if(!W5)wz();return W5}function _w(){W5=null}function Bw($){W5=$}function Rz($=W2){let Z=Az();return`<input type="hidden" name="${$}" value="${Z}">`}function _2($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return Rz(X||W2)})}function jw($,Z){let Y=Z??W5;if(!Y)return!1;let X=z2.from($),J=z2.from(Y);if(X.length!==J.length)return!1;return U2.timingSafeEqual(X,J)}var Vz=40,W2="_token",W5=null;var B2=()=>{};async function j2($,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 Nz(J,Q,Z,Y,X);else J=await Tz(J,Q,Z,Y,X)}return J}async function Nz($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,q=`@end${Q}`,z=$,U=E1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${q}`,"g"),W=[],_=U.exec(z);while(_!==null){let[B,j="",H=""]=_,L=_.index||0;try{let F=j?H2(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:a("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${O}`,p.EVALUATION_ERROR),startIndex:L})}_=U.exec(z)}for(let B=W.length-1;B>=0;B--){let{original:j,processed:H}=W[B];z=z.replace(j,H)}return z}async function Tz($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,q=E1(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),z=[],U=q.exec(K);while(U!==null){let[B,j=""]=U,H=U.index||0;try{let L=H2(j),F=await G("",L,Y,X);z.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);z.push({original:B,processed:a("CustomDirective",`Error in @${Q}(${j}): ${F}`,p.EVALUATION_ERROR),startIndex:H})}U=q.exec(K)}let W=E1(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),_=W.exec(K);while(_!==null){let[B]=_,j=_.index||0;try{let H=await G("",[],Y,X);z.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);z.push({original:B,processed:a("CustomDirective",`Error in @${Q}: ${L}`,p.EVALUATION_ERROR),startIndex:j})}_=W.exec(K)}for(let B=z.length-1;B>=0;B--){let{original:j,processed:H}=z[B];K=K.replace(j,H)}return K}function H2($){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 O2=P(()=>{Q1();$5()});var C3={};n(C3,{useTitle:()=>bz,useSeoMeta:()=>W4,usePageTitle:()=>bz,useHead:()=>h1,resetHead:()=>Dz,renderHtmlAttrs:()=>yz,renderHead:()=>Sz,renderBodyAttrs:()=>Cz,processTitleDirective:()=>xz,processMetaDirective:()=>fz,processHeadDirective:()=>vz,getPageMeta:()=>Iz,getHead:()=>h5,definePageMeta:()=>kz,applyHead:()=>Pz});function h5(){return O1}function Iz(){return U4}function Dz(){O1={},Mz.length=0,U4={}}function h1($){O1=Ez(O1,$)}function Ez($,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 W4($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let q=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:q})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,X=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(X)Z.push({property:"og:description",content:X});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let 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 q of $.articleTags)Z.push({property:"article:tag",content:q});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});h1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function kz($){if(U4={...U4,...$},$.title||$.description)W4({title:$.title,description:$.description})}function bz($){let Z=typeof $==="function"?$():$;h1({title:Z})}function Sz($=O1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${g1(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${g1(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}="${g1(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}="${g1(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}="${g1(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 yz($=O1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${g1(Y)}"`).join(" ")}function Cz($=O1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${g1(Y)}"`).join(" ")}function g1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Pz($=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 vz($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
|
|
3775
3775
|
`,""}),headContent:Z.trim()}}function xz($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return h1({title:G}),""})}function fz($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let q=Q?G:K,z=Q?q:Z[(q||"").trim()]??q,W=J.includes(":")?{property:J,content:z}:{name:J,content:z};return h1({meta:[W]}),""})}var O1,Mz,U4;var d5=P(()=>{O1={},Mz=[],U4={}});import gz from"crypto";function R0($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function hz($){return{...P3,...$.forms?.classes}}function _4($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function dz(){return gz.randomUUID()}function Aw($,Z,Y,X){let J=hz(X),Q=$;return Q=uz(Q,Z),Q=l5(Q,Z),Q=v3(Q,Z,J),Q=x3(Q,Z,J),Q}function l5($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=dz();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 v3($,Z,Y=P3){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,q,z="")=>{let U=Q||G||"POST",W=K||q||"",_=L1(z),B=U.toUpperCase(),j=["GET","POST"].includes(B)?B:"POST",H=`<form method="${R0(j)}" action="${R0(W)}"${_?` ${_}`:""}>`;if(H+=`
|
package/dist/lazy-loader.js
CHANGED
|
@@ -3769,7 +3769,7 @@ ${Y}
|
|
|
3769
3769
|
</script>`}function cZ($,Z,Y){if(pZ=0,!aq($))return $;let X=pq($);if(X.length===0)return $;let J=rq($,X),Q=sq(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 rq($,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*["']${Y4(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*["']${Y4(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*"${Y4(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*'${Y4(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 aq($){return/x-data\s*=\s*["']/.test($)}var pZ=0,lq=0;var iZ=P(()=>{r0()});import tq from"fs";import F3 from"path";import{createHighlighter as eq}from"ts-syntax-highlighter";async function $z($,Z={}){try{if(!await c($))throw Error(`Markdown file not found: ${$}`);let X=(await tq.promises.stat($)).mtime.getTime();if(Z.cache&&V3.has($)){let W=V3.get($);if(W.updatedAt>=X)return{content:W.content,data:W.data}}let J=await Bun.file($).text(),{data:Q,content:G}=s9(J),K=Z.markdown||q3.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},z=k5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)z=await Zz(z,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let U={content:z,data:Q||{}};if(Z.cache)V3.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 Zz($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!X4)try{X4=await eq({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,q,z,U)=>{let W=U.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),_=z||(Y?"text":"");if(!_)return K;try{if(!X4.getSupportedLanguages().includes(_))return K;return(await X4.highlight(W,_,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${z}:`,B)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[q,z,U,W]=K,_=await J(q,z,U,W);Q=Q.replace(q,_)}return Q}async function nZ($,Z,Y="",X={}){return await Yz($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,q,z)=>{try{let U=K;if(!F3.isAbsolute(K))U=F3.resolve(F3.dirname(Y),K);let W={};if(q)try{try{W=JSON.parse(q)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let O=q.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let 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[w]=R}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:_,data:B}=await $z(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,$,z,G)}})}async function Yz($,Z,Y){let X=[],J;while((J=Z.exec($))!==null){let K=J[0],q=J.index,z=J;X.push(Y(...z).then((U)=>({match:K,replacement:U,index:q})))}let Q=await Promise.all(X);Q.sort((K,q)=>q.index-K.index);let G=$;for(let{match:K,replacement:q}of Q)G=G.replace(K,()=>q);return G}var V3,X4=null;var oZ=P(()=>{C5();V0();V3=new Map});function B1($,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 sZ=P(()=>{F0()});class J4{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 O0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,q=!1;while(Q<$.length){let z=$[Q];if(G&&q){q=!1,Q++;continue}if(G&&z==="\\"){q=!0,Q++;continue}if(q=!1,(z==='"'||z==="'"||z==="`")&&!G){G=z,Q++;continue}if(z===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&z==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&z==="}"){K--,Q++;continue}if(z==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(z===Z)J++;else if(z===Y){if(J--,J===0)return Q}Q++}return-1}function rZ($,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 w3($){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 j1($,Z){let Y=Xz($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Xz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=O0($,"(",")",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 q=G.exec($),z=K.exec($),U=q?q.index:1/0,W=z?z.index:1/0;if(U<W)J++,Q=U+q[0].length;else if(W<1/0){if(J--,J===0)return W;Q=W+z[0].length}else break}return-1}function aZ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=j1($,X);if(!J)return null;let Q=J.endPos,G=C1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],z=0,U="if",W=J.expression,_=0,B=0;while(z<K.length){let j=K.indexOf("@",z);if(j===-1)break;z=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,z++;continue}if(/^@endif(?![a-z])/.test(H)){B--,z+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){q.push({type:U,condition:W,content:K.substring(_,z),start:Q+_,end:Q+z});let F=z+L[0].length,O=j1(K,F);if(!O){z++;continue}U="elseif",W=O.expression,z=O.endPos,_=z;continue}else if(/^@else(?![a-z])/.test(H)){q.push({type:U,condition:W,content:K.substring(_,z),start:Q+_,end:Q+z}),U="else",W=void 0,z+=5,_=z;continue}}z++}return q.push({type:U,condition:W,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:q,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=aZ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function Q4($,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,q=K+Q[0].length-1,z=O0($,"(",")",q);if(z===-1){Q=J.exec($);continue}let U=$.slice(q+1,z),W=z+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 A3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=j1($,X);if(!J)return null;let Q=J.endPos,G=C1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],z=0,U=null,W=0;while(z<K.length){let _=K.slice(z),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(W++,U)U.content+=B[0];z+=B[0].length;continue}if(j){if(W--,U)U.content+=j[0];z+=j[0].length;continue}if(W>0){if(U)U.content+=K[z];z++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(U)q.push(U);let O=z+H[0].length,V=j1(K,O);if(!V){z++;continue}U={type:"case",value:V.expression,content:""},z=V.endPos}else if(L&&_.startsWith("@default")){if(U)q.push(U);U={type:"default",content:""},z+=L[0].length}else if(F&&_.startsWith("@break"))z+=F[0].length;else{if(U)U.content+=K[z];z++}}if(U)q.push(U);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:q,start:Z,end:G+10}}var tZ=()=>{};function Jz($){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)==="{{{"?"{{{":"{!!":"{{",q=Q?K==="{{{"?"}}}":"!!}":"}}",z=G+K.length,U=Qz($,z,q);if(U===-1){Y=G+1;continue}let W=$.slice(z,U).trim(),_=U+q.length;Z.push({fullMatch:$.slice(G,_),expression:W,start:G,end:_,isRaw:Q}),Y=_}return Z}function Qz($,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 Gz($){let Z=w3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=Kz(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function Kz($){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=O0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=ZY(G);return{name:X,args:K}}function ZY($){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 qz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=O0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function zz($){let Z=[],X=new J4($).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 q=K.value;if(J++,J>=X.length)break;let z=X[J];if(z.type==="IDENTIFIER"){let U=z.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let W=J<X.length?X[J].start:$.length,_=eZ(X,J,$);J=_.nextIndex,Z.push({type:"variable",name:U,value:$.slice(W,_.endPos),exported:G,start:K.start,end:_.endPos})}}else if(z.type==="PUNCTUATION"&&(z.value==="{"||z.value==="[")){let U=z.start,W=z.value==="{"?"}":"]",_=O0($,z.value,W,U);if(_!==-1){let B=$.slice(U,_+1);if(J=$Y(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=eZ(X,J,$);J=H.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,H.endPos)}; ${q} ${B} = ${L}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let q=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let z=X[J];if(z.type==="IDENTIFIER"){let U=z.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 _=O0($,"{","}",W);if(_!==-1)Z.push({type:"function",name:U,value:$.slice(q,_+1).replace(/^export\s+/,""),exported:G,start:q,end:_+1}),J=$Y(X,_+1)}}}else J++}return Z}function eZ($,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 $Y($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var YY=()=>{};var G4=P(()=>{tZ();YY()});function Uz($,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=A3(X,G);if(!K)break;try{let q;if($0(K.expression))q=Z0(K.expression,Object.keys(Z))(...Object.values(Z));else q=e(K.expression,Z);let z="",U=!1;for(let W of K.cases)if(W.type==="default"){if(!U)z=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(q===_){z=W.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+z+X.substring(K.end),J=!0}catch(q){let z=q instanceof Error?q.message:String(q),U=r("Switch",`Error evaluating @switch expression: ${z}`,l.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function P1($,Z,Y){let X=$;X=Uz(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,q=j1(X,K+7);if(!q)break;let z=q.endPos,U=C1(X,"unless","endunless",z);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(z,U),_=q.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(W))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(W))!==null)V.push({pos:A.index,type:"close"});while((A=O.exec(W))!==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=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=N3(X,Z,Y),X=T3(X,Z,Y),X=R3(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 q="",z=!1;for(let U of K.branches){if(z)break;if(U.type==="else")q=U.content,z=!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)q=U.content,z=!0}catch(W){q=r(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${W instanceof Error?W.message:String(W)}`,l.EVALUATION_ERROR),z=!0}}X=X.substring(0,K.start)+q+X.substring(K.end)}catch(q){let z=q instanceof Error?q.message:String(q),U=r("If",`Error processing @if block: ${z}`,l.EVALUATION_ERROR);X=X.substring(0,K.start)+U+X.substring(K.end)}}return!0};while(J());return X}function XY($){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 R3($,Z){let Y=$;function X(K,q,z,U){let W=1,_=U,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${z}(?![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,q,z){let U=0,W=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${z}(?![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 q=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let z=q.index,U,W,_=Y.slice(z+5),B=XY(_);if(B)U=B.value,W=z+5+B.consumed;else W=z+5;let j=X(Y,"auth","endauth",W);if(j===-1){console.warn(`[stx] @auth directive at position ${z} 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?B1(`auth?.check && auth?.user?.[${U}]`,Z):B1("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,z)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let q=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let z=q.index,U,W,_=Y.slice(z+6),B=XY(_);if(B)U=B.value,W=z+6+B.consumed;else W=z+6;let j=X(Y,"guest","endguest",W);if(j===-1){console.warn(`[stx] @guest directive at position ${z} 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?B1(`!auth?.check || !auth?.user?.[${U}]`,Z):B1("!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,z)+O+Y.substring(j+9),K=!0}}function Q(K,q,z){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(q)U.push(q);if(z){let W=B1(z,Z);U.push(W)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let q=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!q)return null;return{ability:q[1],type:q[2],id:q[3]?.trim(),paramsEnd:q[0].length}}for(let K of["can","cannot"]){let q=`end${K}`,z=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,q,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${q} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${q}(?![a-z])`,"g"),R=new RegExp(`@${z}\\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((S,y)=>S.pos-y.pos);for(let S of T){if(S.type==="open"){V++;continue}if(S.type==="close"){V--;continue}if(V===0)O.push(S)}let I=[],E=0;for(let S=0;S<O.length;S++){let y=O[S];if(I.push({content:F.slice(E,y.pos),ability:void 0}),y.type==="elseDirective"){let d=F.slice(y.pos+`@${z}`.length),f=G(d);if(f){I[I.length-1]={content:F.slice(E,y.pos)},E=y.pos+`@${z}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=O[S+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 S=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:F.slice(E),isFinalElse:!0});else if(I.length===0)I.push({content:F.slice(E)})}let D=Q(j.ability,j.type,j.id),k=K==="can"?D:!D,b="";if(k)b=I[0]?.content||"";else{let S=!1;for(let y=1;y<I.length;y++){let d=I[y];if(d.isFinalElse){b=d.content,S=!0;break}if(d.ability){let f=Q(d.ability,d.type,d.id);if(K==="can"?f:!f){b=d.content,S=!0;break}}}if(!S&&I.length>0){let y=I[I.length-1];if(y.isFinalElse)b=y.content}}Y=Y.substring(0,_)+b+Y.substring(L+`@${q}`.length),U=!0}}return Y}function N3($,Z,Y){let X=$;function J(Q,G,K,q,z){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=j1(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,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=q(O.trim()),N;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);N=R?T:M}else N=R?F:"";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(z,`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=B1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=B1(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 T3($,Z,Y){let X=$,J="development";function Q(G,K,q,z){let U=new RegExp(`@${K}(?![a-z])`,"g"),W=new RegExp(`@${q}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${q}(?![a-z])`),j=G,H=!0;while(H){H=!1,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,z=J===D[2]}let V=1,A=O,w=-1;while(V>0&&A<j.length){U.lastIndex=A,W.lastIndex=A;let D=U.exec(j),k=W.exec(j),b=D?D.index:1/0,S=k?k.index:1/0;if(b<S)V++,A=b+D[0].length;else if(S<1/0){if(V--,V===0){w=S;break}A=S+k[0].length}else break}if(w===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${q} \u2014 the block was skipped.`);break}let R=j.substring(O,w),N=-1,T=0,M=0;while(M<R.length){let D=R.indexOf("@",M);if(D===-1)break;let k=R.substring(D);if(_.test(k)){T++,M=D+1;continue}if(B.test(k)){T--,M=D+1;continue}if(T===0&&/^@else(?![a-z])/.test(k)){N=D;break}M=D+1}let I;if(N!==-1){let D=R.slice(0,N),k=R.slice(N+5);I=z?D:k}else I=z?R:"";let E=`@${q}`.length;j=j.substring(0,F)+I+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 K4=P(()=>{sZ();J1();G4();F0()});function JY($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function v1($,Z){if(!$)return Z?.nonceGenerator?.()??JY();let Y=M3.get($);if(!Y)Y=Z?.nonceGenerator?.()??JY(),M3.set($,Y);return Y}function aV($){M3.delete($)}function QY($,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 D3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${QY($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function tV($){return{enabled:!0,directives:{strict:Wz,moderate:I3,relaxed:_z,api:Bz}[$]||I3,useNonce:$==="strict",addMetaTag:!0}}function eV($,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:[],q=[...new Set([...K,...J])];Y[Q]=q}}return Y}function GY($,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?v1(Y,Z):void 0,J=D3(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 O0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,q=!1;while(Q<$.length){let z=$[Q];if(G&&q){q=!1,Q++;continue}if(G&&z==="\\"){q=!0,Q++;continue}if(q=!1,(z==='"'||z==="'"||z==="`")&&!G){G=z,Q++;continue}if(z===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&z==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&z==="}"){K--,Q++;continue}if(z==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(z===Z)J++;else if(z===Y){if(J--,J===0)return Q}Q++}return-1}function rZ($,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 w3($){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 j1($,Z){let Y=Xz($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Xz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=O0($,"(",")",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 q=G.exec($),z=K.exec($),U=q?q.index:1/0,W=z?z.index:1/0;if(U<W)J++,Q=U+q[0].length;else if(W<1/0){if(J--,J===0)return W;Q=W+z[0].length}else break}return-1}function aZ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=j1($,X);if(!J)return null;let Q=J.endPos,G=C1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],z=0,U="if",W=J.expression,_=0,B=0;while(z<K.length){let j=K.indexOf("@",z);if(j===-1)break;z=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,z++;continue}if(/^@endif(?![a-z])/.test(H)){B--,z+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){q.push({type:U,condition:W,content:K.substring(_,z),start:Q+_,end:Q+z});let F=z+L[0].length,O=j1(K,F);if(!O){z++;continue}U="elseif",W=O.expression,z=O.endPos,_=z;continue}else if(/^@else(?![a-z])/.test(H)){q.push({type:U,condition:W,content:K.substring(_,z),start:Q+_,end:Q+z}),U="else",W=void 0,z+=5,_=z;continue}}z++}return q.push({type:U,condition:W,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:q,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=aZ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function Q4($,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,q=K+Q[0].length-1,z=O0($,"(",")",q);if(z===-1){Q=J.exec($);continue}let U=$.slice(q+1,z),W=z+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 A3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=j1($,X);if(!J)return null;let Q=J.endPos,G=C1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],z=0,U=null,W=0;while(z<K.length){let _=K.slice(z),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(W++,U)U.content+=B[0];z+=B[0].length;continue}if(j){if(W--,U)U.content+=j[0];z+=j[0].length;continue}if(W>0){if(U)U.content+=K[z];z++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(U)q.push(U);let O=z+H[0].length,V=j1(K,O);if(!V){z++;continue}U={type:"case",value:V.expression,content:""},z=V.endPos}else if(L&&_.startsWith("@default")){if(U)q.push(U);U={type:"default",content:""},z+=L[0].length}else if(F&&_.startsWith("@break"))z+=F[0].length;else{if(U)U.content+=K[z];z++}}if(U)q.push(U);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:q,start:Z,end:G+10}}var tZ=()=>{};function Jz($){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)==="{{{"?"{{{":"{!!":"{{",q=Q?K==="{{{"?"}}}":"!!}":"}}",z=G+K.length,U=Qz($,z,q);if(U===-1){Y=G+1;continue}let W=$.slice(z,U).trim(),_=U+q.length;Z.push({fullMatch:$.slice(G,_),expression:W,start:G,end:_,isRaw:Q}),Y=_}return Z}function Qz($,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 Gz($){let Z=w3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=Kz(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function Kz($){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=O0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=ZY(G);return{name:X,args:K}}function ZY($){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 qz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=O0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function zz($){let Z=[],X=new J4($).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 q=K.value;if(J++,J>=X.length)break;let z=X[J];if(z.type==="IDENTIFIER"){let U=z.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let W=J<X.length?X[J].start:$.length,_=eZ(X,J,$);J=_.nextIndex,Z.push({type:"variable",name:U,value:$.slice(W,_.endPos),exported:G,start:K.start,end:_.endPos})}}else if(z.type==="PUNCTUATION"&&(z.value==="{"||z.value==="[")){let U=z.start,W=z.value==="{"?"}":"]",_=O0($,z.value,W,U);if(_!==-1){let B=$.slice(U,_+1);if(J=$Y(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=eZ(X,J,$);J=H.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,H.endPos)}; ${q} ${B} = ${L}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let q=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let z=X[J];if(z.type==="IDENTIFIER"){let U=z.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 _=O0($,"{","}",W);if(_!==-1)Z.push({type:"function",name:U,value:$.slice(q,_+1).replace(/^export\s+/,""),exported:G,start:q,end:_+1}),J=$Y(X,_+1)}}}else J++}return Z}function eZ($,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 $Y($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var YY=()=>{};var G4=P(()=>{tZ();YY()});function Uz($,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=A3(X,G);if(!K)break;try{let q;if($0(K.expression))q=Z0(K.expression,Object.keys(Z))(...Object.values(Z));else q=e(K.expression,Z);let z="",U=!1;for(let W of K.cases)if(W.type==="default"){if(!U)z=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(q===_){z=W.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+z+X.substring(K.end),J=!0}catch(q){let z=q instanceof Error?q.message:String(q),U=r("Switch",`Error evaluating @switch expression: ${z}`,l.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function P1($,Z,Y){let X=$;X=Uz(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,q=j1(X,K+7);if(!q)break;let z=q.endPos,U=C1(X,"unless","endunless",z);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(z,U),_=q.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(W))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(W))!==null)V.push({pos:A.index,type:"close"});while((A=O.exec(W))!==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=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=N3(X,Z,Y),X=T3(X,Z,Y),X=R3(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 q="",z=!1;for(let U of K.branches){if(z)break;if(U.type==="else")q=U.content,z=!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)q=U.content,z=!0}catch(W){q=r(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${W instanceof Error?W.message:String(W)}`,l.EVALUATION_ERROR),z=!0}}X=X.substring(0,K.start)+q+X.substring(K.end)}catch(q){let z=q instanceof Error?q.message:String(q),U=r("If",`Error processing @if block: ${z}`,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 XY($){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 R3($,Z){let Y=$;function X(K,q,z,U){let W=1,_=U,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${z}(?![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,q,z){let U=0,W=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${z}(?![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 q=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let z=q.index,U,W,_=Y.slice(z+5),B=XY(_);if(B)U=B.value,W=z+5+B.consumed;else W=z+5;let j=X(Y,"auth","endauth",W);if(j===-1){console.warn(`[stx] @auth directive at position ${z} 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?B1(`auth?.check && auth?.user?.[${U}]`,Z):B1("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,z)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let q=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let z=q.index,U,W,_=Y.slice(z+6),B=XY(_);if(B)U=B.value,W=z+6+B.consumed;else W=z+6;let j=X(Y,"guest","endguest",W);if(j===-1){console.warn(`[stx] @guest directive at position ${z} 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?B1(`!auth?.check || !auth?.user?.[${U}]`,Z):B1("!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,z)+O+Y.substring(j+9),K=!0}}function Q(K,q,z){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(q)U.push(q);if(z){let W=B1(z,Z);U.push(W)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let q=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!q)return null;return{ability:q[1],type:q[2],id:q[3]?.trim(),paramsEnd:q[0].length}}for(let K of["can","cannot"]){let q=`end${K}`,z=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,q,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${q} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${q}(?![a-z])`,"g"),R=new RegExp(`@${z}\\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((S,y)=>S.pos-y.pos);for(let S of T){if(S.type==="open"){V++;continue}if(S.type==="close"){V--;continue}if(V===0)O.push(S)}let I=[],E=0;for(let S=0;S<O.length;S++){let y=O[S];if(I.push({content:F.slice(E,y.pos),ability:void 0}),y.type==="elseDirective"){let d=F.slice(y.pos+`@${z}`.length),f=G(d);if(f){I[I.length-1]={content:F.slice(E,y.pos)},E=y.pos+`@${z}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=O[S+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 S=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:F.slice(E),isFinalElse:!0});else if(I.length===0)I.push({content:F.slice(E)})}let D=Q(j.ability,j.type,j.id),k=K==="can"?D:!D,b="";if(k)b=I[0]?.content||"";else{let S=!1;for(let y=1;y<I.length;y++){let d=I[y];if(d.isFinalElse){b=d.content,S=!0;break}if(d.ability){let f=Q(d.ability,d.type,d.id);if(K==="can"?f:!f){b=d.content,S=!0;break}}}if(!S&&I.length>0){let y=I[I.length-1];if(y.isFinalElse)b=y.content}}Y=Y.substring(0,_)+b+Y.substring(L+`@${q}`.length),U=!0}}return Y}function N3($,Z,Y){let X=$;function J(Q,G,K,q,z){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=j1(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,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=q(O.trim()),N;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);N=R?T:M}else N=R?F:"";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(z,`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=B1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=B1(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 T3($,Z,Y){let X=$,J="development";function Q(G,K,q,z){let U=new RegExp(`@${K}(?![a-z])`,"g"),W=new RegExp(`@${q}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${q}(?![a-z])`),j=G,H=!0;while(H){H=!1,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,z=J===D[2]}let V=1,A=O,w=-1;while(V>0&&A<j.length){U.lastIndex=A,W.lastIndex=A;let D=U.exec(j),k=W.exec(j),b=D?D.index:1/0,S=k?k.index:1/0;if(b<S)V++,A=b+D[0].length;else if(S<1/0){if(V--,V===0){w=S;break}A=S+k[0].length}else break}if(w===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${q} \u2014 the block was skipped.`);break}let R=j.substring(O,w),N=-1,T=0,M=0;while(M<R.length){let D=R.indexOf("@",M);if(D===-1)break;let k=R.substring(D);if(_.test(k)){T++,M=D+1;continue}if(B.test(k)){T--,M=D+1;continue}if(T===0&&/^@else(?![a-z])/.test(k)){N=D;break}M=D+1}let I;if(N!==-1){let D=R.slice(0,N),k=R.slice(N+5);I=z?D:k}else I=z?R:"";let E=`@${q}`.length;j=j.substring(0,F)+I+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 K4=P(()=>{sZ();J1();G4();F0()});function JY($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function v1($,Z){if(!$)return Z?.nonceGenerator?.()??JY();let Y=M3.get($);if(!Y)Y=Z?.nonceGenerator?.()??JY(),M3.set($,Y);return Y}function aV($){M3.delete($)}function QY($,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 D3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${QY($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function tV($){return{enabled:!0,directives:{strict:Wz,moderate:I3,relaxed:_z,api:Bz}[$]||I3,useNonce:$==="strict",addMetaTag:!0}}function eV($,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:[],q=[...new Set([...K,...J])];Y[Q]=q}}return Y}function GY($,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?v1(Y,Z):void 0,J=D3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
3773
3773
|
${J}`)}function $w($,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 KY($,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?v1(Z,Q):void 0;return D3(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return v1(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=v1(Z,Q);return J}function Zw(){return[jz,Hz]}function Yw($){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 Oz($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function Xw($,Z){if(!$.enabled)return{};let Y=$.useNonce?v1(Z,$):void 0,X=QY($.directives,Y);return{[Oz($.reportOnly)]:X}}var M3,Wz,I3,_z,Bz,jz,Hz,Jw;var qY=P(()=>{M3=new WeakMap;Wz={"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},I3={"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'"]},Bz={"default-src":["'none'"],"frame-ancestors":["'none'"]};jz={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?v1(Y,Q):void 0;return D3(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},Hz={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return v1(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};Jw={enabled:!1,reportOnly:!1,directives:I3,useNonce:!1,addMetaTag:!0}});import{Buffer as zY}from"buffer";import UY from"crypto";function Fz($=Lz){let Z=UY.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return q5=Z,Z}function Vz(){if(!q5)Fz();return q5}function qw(){q5=null}function zw($){q5=$}function wz($=WY){let Z=Vz();return`<input type="hidden" name="${$}" value="${Z}">`}function _Y($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return wz(X||WY)})}function Uw($,Z){let Y=Z??q5;if(!Y)return!1;let X=zY.from($),J=zY.from(Y);if(X.length!==J.length)return!1;return UY.timingSafeEqual(X,J)}var Lz=40,WY="_token",q5=null;var BY=()=>{};async function jY($,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 Az(J,Q,Z,Y,X);else J=await Rz(J,Q,Z,Y,X)}return J}async function Az($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,q=`@end${Q}`,z=$,U=I1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${q}`,"g"),W=[],_=U.exec(z);while(_!==null){let[B,j="",H=""]=_,L=_.index||0;try{let F=j?HY(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(z)}for(let B=W.length-1;B>=0;B--){let{original:j,processed:H}=W[B];z=z.replace(j,H)}return z}async function Rz($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,q=I1(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),z=[],U=q.exec(K);while(U!==null){let[B,j=""]=U,H=U.index||0;try{let L=HY(j),F=await G("",L,Y,X);z.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);z.push({original:B,processed:r("CustomDirective",`Error in @${Q}(${j}): ${F}`,l.EVALUATION_ERROR),startIndex:H})}U=q.exec(K)}let W=I1(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),_=W.exec(K);while(_!==null){let[B]=_,j=_.index||0;try{let H=await G("",[],Y,X);z.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);z.push({original:B,processed:r("CustomDirective",`Error in @${Q}: ${L}`,l.EVALUATION_ERROR),startIndex:j})}_=W.exec(K)}for(let B=z.length-1;B>=0;B--){let{original:j,processed:H}=z[B];K=K.replace(j,H)}return K}function HY($){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 OY=P(()=>{J1();a1()});var E3={};i(E3,{useTitle:()=>Ez,useSeoMeta:()=>z4,usePageTitle:()=>Ez,useHead:()=>f1,resetHead:()=>Mz,renderHtmlAttrs:()=>bz,renderHead:()=>kz,renderBodyAttrs:()=>Sz,processTitleDirective:()=>Pz,processMetaDirective:()=>vz,processHeadDirective:()=>Cz,getPageMeta:()=>Tz,getHead:()=>x5,definePageMeta:()=>Dz,applyHead:()=>yz});function x5(){return H1}function Tz(){return q4}function Mz(){H1={},Nz.length=0,q4={}}function f1($){H1=Iz(H1,$)}function Iz($,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 z4($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let q=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:q})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,X=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(X)Z.push({property:"og:description",content:X});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let 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 q of $.articleTags)Z.push({property:"article:tag",content:q});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});f1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function Dz($){if(q4={...q4,...$},$.title||$.description)z4({title:$.title,description:$.description})}function Ez($){let Z=typeof $==="function"?$():$;f1({title:Z})}function kz($=H1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${x1(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${x1(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}="${x1(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}="${x1(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}="${x1(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 bz($=H1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${x1(Y)}"`).join(" ")}function Sz($=H1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${x1(Y)}"`).join(" ")}function x1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function yz($=H1){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 Cz($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
|
|
3775
3775
|
`,""}),headContent:Z.trim()}}function Pz($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return f1({title:G}),""})}function vz($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let q=Q?G:K,z=Q?q:Z[(q||"").trim()]??q,W=J.includes(":")?{property:J,content:z}:{name:J,content:z};return f1({meta:[W]}),""})}var H1,Nz,q4;var f5=P(()=>{H1={},Nz=[],q4={}});import xz from"crypto";function w0($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function fz($){return{...k3,...$.forms?.classes}}function U4($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function gz(){return xz.randomUUID()}function Lw($,Z,Y,X){let J=fz(X),Q=$;return Q=dz(Q,Z),Q=d5(Q,Z),Q=b3(Q,Z,J),Q=S3(Q,Z,J),Q}function d5($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=gz();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${w0(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="${w0(Q)}">`;return X}),Y}function b3($,Z,Y=k3){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,q,z="")=>{let U=Q||G||"POST",W=K||q||"",_=O1(z),B=U.toUpperCase(),j=["GET","POST"].includes(B)?B:"POST",H=`<form method="${w0(j)}" action="${w0(W)}"${_?` ${_}`:""}>`;if(H+=`
|