@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
|
@@ -3769,7 +3769,7 @@ ${Y}
|
|
|
3769
3769
|
</script>`}function h2($,Z,Y){if(g2=0,!PU($))return $;let X=DU($);if(X.length===0)return $;let J=CU($,X),Q=bU(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 CU($,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*["']${E4(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*["']${E4(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*"${E4(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*'${E4(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 PU($){return/x-data\s*=\s*["']/.test($)}var g2=0,MU=0;var d2=C(()=>{Z1()});import yU from"fs";import o3 from"path";import{createHighlighter as vU}from"ts-syntax-highlighter";async function xU($,Z={}){try{if(!await i($))throw Error(`Markdown file not found: ${$}`);let X=(await yU.promises.stat($)).mtime.getTime();if(Z.cache&&r3.has($)){let _=r3.get($);if(_.updatedAt>=X)return{content:_.content,data:_.data}}let J=await Bun.file($).text(),{data:Q,content:G}=p8(J),K=Z.markdown||h3.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},W=c5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)W=await fU(W,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let U={content:W,data:Q||{}};if(Z.cache)r3.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 fU($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!I4)try{I4=await vU({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,z,W,U)=>{let _=U.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),q=W||(Y?"text":"");if(!q)return K;try{if(!I4.getSupportedLanguages().includes(q))return K;return(await I4.highlight(_,q,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${W}:`,B)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[z,W,U,_]=K,q=await J(z,W,U,_);Q=Q.replace(z,q)}return Q}async function u2($,Z,Y="",X={}){return await gU($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,z,W)=>{try{let U=K;if(!o3.isAbsolute(K))U=o3.resolve(o3.dirname(Y),K);let _={};if(z)try{try{_=JSON.parse(z)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let O=z.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let A=V.indexOf(":");if(A>0){let w=V.substring(0,A).trim(),R=V.substring(A+1).trim(),N=R.startsWith('"')&&R.endsWith('"'),T=R.startsWith("'")&&R.endsWith("'");if(N||T)R=R.substring(1,R.length-1);_[w]=R}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:q,data:B}=await xU(U,X),j={...Z,...B,..._},H=q,L=/\{\{([^}]+)\}\}/g;return H=H.replace(L,(F,O)=>{let V=O.trim();return j[V]!==void 0?String(j[V]):F}),H}catch(U){let _=U instanceof Error?U.message:String(U);return Q0("Markdown File",`Error including markdown file: ${_}`,Y,$,W,G)}})}async function gU($,Z,Y){let X=[],J;while((J=Z.exec($))!==null){let K=J[0],z=J.index,W=J;X.push(Y(...W).then((U)=>({match:K,replacement:U,index:z})))}let Q=await Promise.all(X);Q.sort((K,z)=>z.index-K.index);let G=$;for(let{match:K,replacement:z}of Q)G=G.replace(K,()=>z);return G}var r3,I4=null;var m2=C(()=>{o5();O0();r3=new Map});function V1($,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 l2=C(()=>{w0()});class k4{source;pos=0;line=1;column=0;tokens=[];constructor($){this.source=$}tokenize(){this.tokens=[],this.pos=0,this.line=1,this.column=0;while(this.pos<this.source.length){let $=this.nextToken();if($)this.tokens.push($)}return this.tokens.push({type:"EOF",value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),this.tokens}nextToken(){if(this.pos>=this.source.length)return null;let $=this.pos,Z=this.line,Y=this.column,X=this.source[this.pos];if(/\s/.test(X))return this.readWhitespace($,Z,Y);if(X==="/"&&this.peek(1)==="/")return this.readLineComment($,Z,Y);if(X==="/"&&this.peek(1)==="*")return this.readBlockComment($,Z,Y);if(X==='"'||X==="'")return this.readString(X,$,Z,Y);if(X==="`")return this.readTemplateString($,Z,Y);if(/\d/.test(X)||X==="."&&/\d/.test(this.peek(1)||""))return this.readNumber($,Z,Y);if(/[a-z_$]/i.test(X))return this.readIdentifier($,Z,Y);if(X==="{"){if(this.peek(1)==="{"&&this.peek(2)==="{")return this.advance(3),{type:"RAW_START",value:"{{{",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="{")return this.advance(2),{type:"EXPRESSION_START",value:"{{",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="!"&&this.peek(2)==="!")return this.advance(3),{type:"RAW_START",value:"{!!",start:$,end:this.pos,line:Z,column:Y}}if(X==="}"){if(this.peek(1)==="}"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"}}}",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="}")return this.advance(2),{type:"EXPRESSION_END",value:"}}",start:$,end:this.pos,line:Z,column:Y}}if(X==="!"&&this.peek(1)==="!"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"!!}",start:$,end:this.pos,line:Z,column:Y};if(X==="@"&&/[a-z]/i.test(this.peek(1)||""))return this.readDirective($,Z,Y);let J=["===","!==","==","!=","<=",">=","&&","||","??","++","--","+=","-=","*=","/=","%=","**","=>","?.","...","<<",">>",">>>","&=","|=","^="];for(let Q of J)if(this.source.slice(this.pos,this.pos+Q.length)===Q)return this.advance(Q.length),{type:"OPERATOR",value:Q,start:$,end:this.pos,line:Z,column:Y};if(/[+\-*/%<>=!&|^~?:]/.test(X))return this.advance(),{type:"OPERATOR",value:X,start:$,end:this.pos,line:Z,column:Y};if(/[()[\]{},;.]/.test(X))return this.advance(),{type:"PUNCTUATION",value:X,start:$,end:this.pos,line:Z,column:Y};return this.advance(),{type:"PUNCTUATION",value:X,start:$,end:this.pos,line:Z,column:Y}}readWhitespace($,Z,Y){while(this.pos<this.source.length&&/\s/.test(this.source[this.pos]))this.advance();return{type:"WHITESPACE",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readLineComment($,Z,Y){this.advance(2);while(this.pos<this.source.length&&this.source[this.pos]!==`
|
|
3771
3771
|
`)this.advance();return{type:"COMMENT",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readBlockComment($,Z,Y){this.advance(2);while(this.pos<this.source.length-1){if(this.source[this.pos]==="*"&&this.source[this.pos+1]==="/"){this.advance(2);break}this.advance()}return{type:"COMMENT",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readString($,Z,Y,X){this.advance();while(this.pos<this.source.length){let J=this.source[this.pos];if(J==="\\"){this.advance(2);continue}if(J===$){this.advance();break}this.advance()}return{type:"STRING",value:this.source.slice(Z,this.pos),start:Z,end:this.pos,line:Y,column:X}}readTemplateString($,Z,Y){this.advance();let X=0,J=256;while(this.pos<this.source.length){let Q=this.source[this.pos];if(Q==="\\"){this.advance(2);continue}if(Q==="$"&&this.peek(1)==="{"){if(X>=J){this.pos=this.source.length;break}this.advance(2),X++;continue}if(Q==="{"&&X>0){X++,this.advance();continue}if(Q==="}"&&X>0){X--,this.advance();continue}if(Q==="`"&&X===0){this.advance();break}this.advance()}return{type:"TEMPLATE_STRING",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readNumber($,Z,Y){if(this.source[this.pos]==="0"){let X=this.peek(1)?.toLowerCase();if(X==="x"||X==="o"||X==="b"){this.advance(2);while(this.pos<this.source.length&&/[\da-f_]/i.test(this.source[this.pos]))this.advance();return{type:"NUMBER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}}while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance();if(this.source[this.pos]==="."&&/\d/.test(this.peek(1)||"")){this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(/e/i.test(this.source[this.pos]||"")){if(this.advance(),/[+-]/.test(this.source[this.pos]||""))this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(this.source[this.pos]==="n")this.advance();return{type:"NUMBER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readIdentifier($,Z,Y){while(this.pos<this.source.length&&/[\w$]/.test(this.source[this.pos]))this.advance();return{type:"IDENTIFIER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readDirective($,Z,Y){this.advance();while(this.pos<this.source.length&&/[a-z]/i.test(this.source[this.pos]))this.advance();return{type:"DIRECTIVE",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}advance($=1){for(let Z=0;Z<$&&this.pos<this.source.length;Z++){if(this.source[this.pos]===`
|
|
3772
|
-
`)this.line++,this.column=0;else this.column++;this.pos++}}peek($){return this.source[this.pos+$]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState($){this.pos=$.pos,this.line=$.line,this.column=$.column}}function F0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,z=!1;while(Q<$.length){let W=$[Q];if(G&&z){z=!1,Q++;continue}if(G&&W==="\\"){z=!0,Q++;continue}if(z=!1,(W==='"'||W==="'"||W==="`")&&!G){G=W,Q++;continue}if(W===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&W==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&W==="}"){K--,Q++;continue}if(W==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(W===Z)J++;else if(W===Y){if(J--,J===0)return Q}Q++}return-1}function p2($,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 a3($){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 w1($,Z){let Y=hU($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function hU($,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 m1($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let z=G.exec($),W=K.exec($),U=z?z.index:1/0,_=W?W.index:1/0;if(U<_)J++,Q=U+z[0].length;else if(_<1/0){if(J--,J===0)return _;Q=_+W[0].length}else break}return-1}function c2($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=w1($,X);if(!J)return null;let Q=J.endPos,G=m1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],W=0,U="if",_=J.expression,q=0,B=0;while(W<K.length){let j=K.indexOf("@",W);if(j===-1)break;W=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,W++;continue}if(/^@endif(?![a-z])/.test(H)){B--,W+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){z.push({type:U,condition:_,content:K.substring(q,W),start:Q+q,end:Q+W});let F=W+L[0].length,O=w1(K,F);if(!O){W++;continue}U="elseif",_=O.expression,W=O.endPos,q=W;continue}else if(/^@else(?![a-z])/.test(H)){z.push({type:U,condition:_,content:K.substring(q,W),start:Q+q,end:Q+W}),U="else",_=void 0,W+=5,q=W;continue}}W++}return z.push({type:U,condition:_,content:K.slice(q),start:Q+q,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:z,start:Z,end:G+6}}function a5($){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=c2($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function S4($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,z=K+Q[0].length-1,W=F0($,"(",")",z);if(W===-1){Q=J.exec($);continue}let U=$.slice(z+1,W),_=W+1,q=m1($,Z,Y,_);if(q===-1){Q=J.exec($);continue}let B=$.slice(_,q),j=q+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:U,content:B,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function t3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=w1($,X);if(!J)return null;let Q=J.endPos,G=m1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],W=0,U=null,_=0;while(W<K.length){let q=K.slice(W),B=q.match(/^@switch\s*\(/),j=q.match(/^@endswitch(?![a-z])/);if(B){if(_++,U)U.content+=B[0];W+=B[0].length;continue}if(j){if(_--,U)U.content+=j[0];W+=j[0].length;continue}if(_>0){if(U)U.content+=K[W];W++;continue}let H=q.match(/^@case\s*/),L=q.match(/^@default(?![a-z])/),F=q.match(/^@break(?![a-z])/);if(H&&q.startsWith("@case")){if(U)z.push(U);let O=W+H[0].length,V=w1(K,O);if(!V){W++;continue}U={type:"case",value:V.expression,content:""},W=V.endPos}else if(L&&q.startsWith("@default")){if(U)z.push(U);U={type:"default",content:""},W+=L[0].length}else if(F&&q.startsWith("@break"))W+=F[0].length;else{if(U)U.content+=K[W];W++}}if(U)z.push(U);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:z,start:Z,end:G+10}}var i2=()=>{};function dU($){let Z=[],Y=0;while(Y<$.length){let X=$.indexOf("{{",Y),J=$.indexOf("{!!",Y),Q=!1,G;if(X===-1&&J===-1)break;else if(X===-1)G=J,Q=!0;else if(J===-1)G=X,Q=!1;else if(J<X)G=J,Q=!0;else G=X,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",z=Q?K==="{{{"?"}}}":"!!}":"}}",W=G+K.length,U=uU($,W,z);if(U===-1){Y=G+1;continue}let _=$.slice(W,U).trim(),q=U+z.length;Z.push({fullMatch:$.slice(G,q),expression:_,start:G,end:q,isRaw:Q}),Y=q}return Z}function uU($,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 mU($){let Z=a3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=lU(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function lU($){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=o2(G);return{name:X,args:K}}function o2($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+="${",G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K===","&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function pU($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=F0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function cU($){let Z=[],X=new k4($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let z=K.value;if(J++,J>=X.length)break;let W=X[J];if(W.type==="IDENTIFIER"){let U=W.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let _=J<X.length?X[J].start:$.length,q=n2(X,J,$);J=q.nextIndex,Z.push({type:"variable",name:U,value:$.slice(_,q.endPos),exported:G,start:K.start,end:q.endPos})}}else if(W.type==="PUNCTUATION"&&(W.value==="{"||W.value==="[")){let U=W.start,_=W.value==="{"?"}":"]",q=F0($,W.value,_,U);if(q!==-1){let B=$.slice(U,q+1);if(J=s2(X,q+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=n2(X,J,$);J=H.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,H.endPos)}; ${z} ${B} = ${L}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let z=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let W=X[J];if(W.type==="IDENTIFIER"){let U=W.value;J++;let _=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){_=X[J].start;break}J++}if(_!==-1){let q=F0($,"{","}",_);if(q!==-1)Z.push({type:"function",name:U,value:$.slice(z,q+1).replace(/^export\s+/,""),exported:G,start:z,end:q+1}),J=s2(X,q+1)}}}else J++}return Z}function n2($,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 s2($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var r2=()=>{};var b4=C(()=>{i2();r2()});function iU($,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=t3(X,G);if(!K)break;try{let z;if($0(K.expression))z=Z0(K.expression,Object.keys(Z))(...Object.values(Z));else z=e(K.expression,Z);let W="",U=!1;for(let _ of K.cases)if(_.type==="default"){if(!U)W=_.content.trim()}else try{let q;if(_.value&&$0(_.value))q=Z0(_.value,Object.keys(Z))(...Object.values(Z));else if(_.value)q=e(_.value,Z);if(z===q){W=_.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+W+X.substring(K.end),J=!0}catch(z){let W=z instanceof Error?z.message:String(z),U=r("Switch",`Error evaluating @switch expression: ${W}`,p.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function l1($,Z,Y){let X=$;X=iU(X,Z,Y);{let Q=!0;while(Q){Q=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,z=w1(X,K+7);if(!z)break;let W=z.endPos,U=m1(X,"unless","endunless",W);if(U===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let _=X.slice(W,U),q=z.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],A;while((A=L.exec(_))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(_))!==null)V.push({pos:A.index,type:"close"});while((A=O.exec(_))!==null)V.push({pos:A.index,type:"else"});V.sort((w,R)=>w.pos-R.pos);for(let w of V)if(w.type==="open")H++;else if(w.type==="close")H--;else if(w.type==="else"&&H===0){B=w.pos;break}}let j;if(B!==-1){let H=_.slice(0,B),L=_.slice(B+5);j=`@if (${q})${L}@else ${H}@endif`}else j=`@if (!(${q}))${_}@endif`;X=X.substring(0,K)+j+X.substring(U+10),Q=!0}}X=$6(X,Z,Y),X=Z6(X,Z,Y),X=e3(X,Z);let J=()=>{let Q=a5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let z="",W=!1;for(let U of K.branches){if(W)break;if(U.type==="else")z=U.content,W=!0;else try{let _;if(U.condition&&$0(U.condition))_=Z0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)_=e(U.condition,Z);if(_)z=U.content,W=!0}catch(_){z=r(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${_ instanceof Error?_.message:String(_)}`,p.EVALUATION_ERROR),W=!0}}X=X.substring(0,K.start)+z+X.substring(K.end)}catch(z){let W=z instanceof Error?z.message:String(z),U=r("If",`Error processing @if block: ${W}`,p.EVALUATION_ERROR);X=X.substring(0,K.start)+U+X.substring(K.end)}}return!0};while(J());return X}function a2($){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 e3($,Z){let Y=$;function X(K,z,W,U){let _=1,q=U,B=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(q<K.length&&_>0){B.lastIndex=q,j.lastIndex=q;let H=B.exec(K),L=j.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)_++,q=F+H[0].length;else if(O<1/0){if(_--,_===0)return O;q=O+L[0].length}else break}return-1}function J(K,z,W){let U=0,_=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),q=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=_.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=q.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")U++;else if(L.type==="close")U--;else if(L.type==="else"&&U===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let z=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let W=z.index,U,_,q=Y.slice(W+5),B=a2(q);if(B)U=B.value,_=W+5+B.consumed;else _=W+5;let j=X(Y,"auth","endauth",_);if(j===-1){console.warn(`[stx] @auth directive at position ${W} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(_,j),L=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?V1(`auth?.check && auth?.user?.[${U}]`,Z):V1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let z=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let W=z.index,U,_,q=Y.slice(W+6),B=a2(q);if(B)U=B.value,_=W+6+B.consumed;else _=W+6;let j=X(Y,"guest","endguest",_);if(j===-1){console.warn(`[stx] @guest directive at position ${W} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(_,j),L=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?V1(`!auth?.check || !auth?.user?.[${U}]`,Z):V1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+9),K=!0}}function Q(K,z,W){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let U=[K];if(z)U.push(z);if(W){let _=V1(W,Z);U.push(_)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let z=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!z)return null;return{ability:z[1],type:z[2],id:z[3]?.trim(),paramsEnd:z[0].length}}for(let K of["can","cannot"]){let z=`end${K}`,W=K==="can"?"elsecan":"elsecannot",U=!0;while(U){U=!1;let _=Y.match(new RegExp(`@${K}\\s*\\(`));if(!_||_.index===void 0)break;let q=_.index,B=Y.slice(q+`@${K}`.length),j=G(B);if(!j)break;let H=q+`@${K}`.length+j.paramsEnd,L=X(Y,K,z,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${q} has no matching @${z} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${z}(?![a-z])`,"g"),R=new RegExp(`@${W}\\s*\\(`,"g"),N=/@else(?![a-z])/g,T=[],M;while((M=A.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=w.exec(F))!==null)T.push({pos:M.index,type:"close"});while((M=R.exec(F))!==null)T.push({pos:M.index,type:"elseDirective"});while((M=N.exec(F))!==null)T.push({pos:M.index,type:"else"});T.sort((b,P)=>b.pos-P.pos);for(let b of T){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)O.push(b)}let D=[],I=0;for(let b=0;b<O.length;b++){let P=O[b];if(D.push({content:F.slice(I,P.pos),ability:void 0}),P.type==="elseDirective"){let d=F.slice(P.pos+`@${W}`.length),f=G(d);if(f){D[D.length-1]={content:F.slice(I,P.pos)},I=P.pos+`@${W}`.length+f.paramsEnd,D.push({content:"",ability:f.ability,type:f.type,id:f.id}),D.pop();let u=O[b+1],s=u?u.pos:F.length;D.push({content:F.slice(I,s),ability:f.ability,type:f.type,id:f.id}),I=s}}else I=P.pos+5}if(I<F.length){let b=D[D.length-1];if(O.length>0&&O[O.length-1].type==="else")D.push({content:F.slice(I),isFinalElse:!0});else if(D.length===0)D.push({content:F.slice(I)})}let E=Q(j.ability,j.type,j.id),k=K==="can"?E:!E,S="";if(k)S=D[0]?.content||"";else{let b=!1;for(let P=1;P<D.length;P++){let d=D[P];if(d.isFinalElse){S=d.content,b=!0;break}if(d.ability){let f=Q(d.ability,d.type,d.id);if(K==="can"?f:!f){S=d.content,b=!0;break}}}if(!b&&D.length>0){let P=D[D.length-1];if(P.isFinalElse)S=P.content}}Y=Y.substring(0,q)+S+Y.substring(L+`@${z}`.length),U=!0}}return Y}function $6($,Z,Y){let X=$;function J(Q,G,K,z,W){let U=!0;while(U){U=!1;let _=new RegExp(`@${G}\\s*\\(`),q=Q.match(_);if(!q||q.index===void 0)break;let B=q.index,j=w1(Q,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=m1(Q,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${B} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,L),O=j.expression,V=-1,A=0,w=0;while(w<F.length){let R=F.indexOf("@",w);if(R===-1)break;let N=F.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){A++,w=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){A--,w=R+1;continue}if(A===0&&/^@else(?![a-z])/.test(N)){V=R;break}w=R+1}try{let R=z(O.trim()),N;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);N=R?T:M}else N=R?F:"";Q=Q.substring(0,B)+N+Q.substring(L+`@${K}`.length),U=!0}catch(R){let N=R instanceof Error?R.message:String(R),T=r(W,`Error processing @${G} directive: ${N}`,p.EVALUATION_ERROR);Q=Q.substring(0,B)+T+Q.substring(L+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=V1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=V1(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 Z6($,Z,Y){let X=$,J="development";function Q(G,K,z,W){let U=new RegExp(`@${K}(?![a-z])`,"g"),_=new RegExp(`@${z}(?![a-z])`,"g"),q=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${z}(?![a-z])`),j=G,H=!0;while(H){H=!1,U.lastIndex=0;let L=U.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let E=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!E)break;O+=E[0].length,W=J===E[2]}let V=1,A=O,w=-1;while(V>0&&A<j.length){U.lastIndex=A,_.lastIndex=A;let E=U.exec(j),k=_.exec(j),S=E?E.index:1/0,b=k?k.index:1/0;if(S<b)V++,A=S+E[0].length;else if(b<1/0){if(V--,V===0){w=b;break}A=b+k[0].length}else break}if(w===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${z} \u2014 the block was skipped.`);break}let R=j.substring(O,w),N=-1,T=0,M=0;while(M<R.length){let E=R.indexOf("@",M);if(E===-1)break;let k=R.substring(E);if(q.test(k)){T++,M=E+1;continue}if(B.test(k)){T--,M=E+1;continue}if(T===0&&/^@else(?![a-z])/.test(k)){N=E;break}M=E+1}let D;if(N!==-1){let E=R.slice(0,N),k=R.slice(N+5);D=W?E:k}else D=W?R:"";let I=`@${z}`.length;j=j.substring(0,F)+D+j.substring(w+I),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var C4=C(()=>{l2();W1();b4();w0()});function t2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function p1($,Z){if(!$)return Z?.nonceGenerator?.()??t2();let Y=Y6.get($);if(!Y)Y=Z?.nonceGenerator?.()??t2(),Y6.set($,Y);return Y}function AR($){Y6.delete($)}function e2($,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 J6($,Z){return`<meta http-equiv="Content-Security-Policy" content="${e2($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function RR($){return{enabled:!0,directives:{strict:nU,moderate:X6,relaxed:sU,api:oU}[$]||X6,useNonce:$==="strict",addMetaTag:!0}}function NR($,Z){let Y={...$};for(let[X,J]of Object.entries(Z)){let Q=X,G=Y[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")Y[Q]=G||J;else if(Array.isArray(J)){let K=Array.isArray(G)?G:[],z=[...new Set([...K,...J])];Y[Q]=z}}return Y}function $Y($,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?p1(Y,Z):void 0,J=J6(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
3772
|
+
`)this.line++,this.column=0;else this.column++;this.pos++}}peek($){return this.source[this.pos+$]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState($){this.pos=$.pos,this.line=$.line,this.column=$.column}}function F0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,z=!1;while(Q<$.length){let W=$[Q];if(G&&z){z=!1,Q++;continue}if(G&&W==="\\"){z=!0,Q++;continue}if(z=!1,(W==='"'||W==="'"||W==="`")&&!G){G=W,Q++;continue}if(W===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&W==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&W==="}"){K--,Q++;continue}if(W==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(W===Z)J++;else if(W===Y){if(J--,J===0)return Q}Q++}return-1}function p2($,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 a3($){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 w1($,Z){let Y=hU($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function hU($,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 m1($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let z=G.exec($),W=K.exec($),U=z?z.index:1/0,_=W?W.index:1/0;if(U<_)J++,Q=U+z[0].length;else if(_<1/0){if(J--,J===0)return _;Q=_+W[0].length}else break}return-1}function c2($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=w1($,X);if(!J)return null;let Q=J.endPos,G=m1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],W=0,U="if",_=J.expression,q=0,B=0;while(W<K.length){let j=K.indexOf("@",W);if(j===-1)break;W=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,W++;continue}if(/^@endif(?![a-z])/.test(H)){B--,W+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){z.push({type:U,condition:_,content:K.substring(q,W),start:Q+q,end:Q+W});let F=W+L[0].length,O=w1(K,F);if(!O){W++;continue}U="elseif",_=O.expression,W=O.endPos,q=W;continue}else if(/^@else(?![a-z])/.test(H)){z.push({type:U,condition:_,content:K.substring(q,W),start:Q+q,end:Q+W}),U="else",_=void 0,W+=5,q=W;continue}}W++}return z.push({type:U,condition:_,content:K.slice(q),start:Q+q,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:z,start:Z,end:G+6}}function a5($){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=c2($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function S4($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,z=K+Q[0].length-1,W=F0($,"(",")",z);if(W===-1){Q=J.exec($);continue}let U=$.slice(z+1,W),_=W+1,q=m1($,Z,Y,_);if(q===-1){Q=J.exec($);continue}let B=$.slice(_,q),j=q+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:U,content:B,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function t3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=w1($,X);if(!J)return null;let Q=J.endPos,G=m1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],W=0,U=null,_=0;while(W<K.length){let q=K.slice(W),B=q.match(/^@switch\s*\(/),j=q.match(/^@endswitch(?![a-z])/);if(B){if(_++,U)U.content+=B[0];W+=B[0].length;continue}if(j){if(_--,U)U.content+=j[0];W+=j[0].length;continue}if(_>0){if(U)U.content+=K[W];W++;continue}let H=q.match(/^@case\s*/),L=q.match(/^@default(?![a-z])/),F=q.match(/^@break(?![a-z])/);if(H&&q.startsWith("@case")){if(U)z.push(U);let O=W+H[0].length,V=w1(K,O);if(!V){W++;continue}U={type:"case",value:V.expression,content:""},W=V.endPos}else if(L&&q.startsWith("@default")){if(U)z.push(U);U={type:"default",content:""},W+=L[0].length}else if(F&&q.startsWith("@break"))W+=F[0].length;else{if(U)U.content+=K[W];W++}}if(U)z.push(U);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:z,start:Z,end:G+10}}var i2=()=>{};function dU($){let Z=[],Y=0;while(Y<$.length){let X=$.indexOf("{{",Y),J=$.indexOf("{!!",Y),Q=!1,G;if(X===-1&&J===-1)break;else if(X===-1)G=J,Q=!0;else if(J===-1)G=X,Q=!1;else if(J<X)G=J,Q=!0;else G=X,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",z=Q?K==="{{{"?"}}}":"!!}":"}}",W=G+K.length,U=uU($,W,z);if(U===-1){Y=G+1;continue}let _=$.slice(W,U).trim(),q=U+z.length;Z.push({fullMatch:$.slice(G,q),expression:_,start:G,end:q,isRaw:Q}),Y=q}return Z}function uU($,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 mU($){let Z=a3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=lU(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function lU($){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=o2(G);return{name:X,args:K}}function o2($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+="${",G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K===","&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function pU($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=F0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function cU($){let Z=[],X=new k4($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let z=K.value;if(J++,J>=X.length)break;let W=X[J];if(W.type==="IDENTIFIER"){let U=W.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let _=J<X.length?X[J].start:$.length,q=n2(X,J,$);J=q.nextIndex,Z.push({type:"variable",name:U,value:$.slice(_,q.endPos),exported:G,start:K.start,end:q.endPos})}}else if(W.type==="PUNCTUATION"&&(W.value==="{"||W.value==="[")){let U=W.start,_=W.value==="{"?"}":"]",q=F0($,W.value,_,U);if(q!==-1){let B=$.slice(U,q+1);if(J=s2(X,q+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=n2(X,J,$);J=H.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,H.endPos)}; ${z} ${B} = ${L}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let z=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let W=X[J];if(W.type==="IDENTIFIER"){let U=W.value;J++;let _=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){_=X[J].start;break}J++}if(_!==-1){let q=F0($,"{","}",_);if(q!==-1)Z.push({type:"function",name:U,value:$.slice(z,q+1).replace(/^export\s+/,""),exported:G,start:z,end:q+1}),J=s2(X,q+1)}}}else J++}return Z}function n2($,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 s2($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var r2=()=>{};var b4=C(()=>{i2();r2()});function iU($,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=t3(X,G);if(!K)break;try{let z;if($0(K.expression))z=Z0(K.expression,Object.keys(Z))(...Object.values(Z));else z=e(K.expression,Z);let W="",U=!1;for(let _ of K.cases)if(_.type==="default"){if(!U)W=_.content.trim()}else try{let q;if(_.value&&$0(_.value))q=Z0(_.value,Object.keys(Z))(...Object.values(Z));else if(_.value)q=e(_.value,Z);if(z===q){W=_.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+W+X.substring(K.end),J=!0}catch(z){let W=z instanceof Error?z.message:String(z),U=r("Switch",`Error evaluating @switch expression: ${W}`,p.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function l1($,Z,Y){let X=$;X=iU(X,Z,Y);{let Q=!0;while(Q){Q=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,z=w1(X,K+7);if(!z)break;let W=z.endPos,U=m1(X,"unless","endunless",W);if(U===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let _=X.slice(W,U),q=z.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],A;while((A=L.exec(_))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(_))!==null)V.push({pos:A.index,type:"close"});while((A=O.exec(_))!==null)V.push({pos:A.index,type:"else"});V.sort((w,R)=>w.pos-R.pos);for(let w of V)if(w.type==="open")H++;else if(w.type==="close")H--;else if(w.type==="else"&&H===0){B=w.pos;break}}let j;if(B!==-1){let H=_.slice(0,B),L=_.slice(B+5);j=`@if (${q})${L}@else ${H}@endif`}else j=`@if (!(${q}))${_}@endif`;X=X.substring(0,K)+j+X.substring(U+10),Q=!0}}X=$6(X,Z,Y),X=Z6(X,Z,Y),X=e3(X,Z);let J=()=>{let Q=a5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let z="",W=!1;for(let U of K.branches){if(W)break;if(U.type==="else")z=U.content,W=!0;else try{let _;if(U.condition&&$0(U.condition))_=Z0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)_=e(U.condition,Z);if(_)z=U.content,W=!0}catch(_){z=r(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${_ instanceof Error?_.message:String(_)}`,p.EVALUATION_ERROR),W=!0}}X=X.substring(0,K.start)+z+X.substring(K.end)}catch(z){let W=z instanceof Error?z.message:String(z),U=r("If",`Error processing @if block: ${W}`,p.EVALUATION_ERROR);X=X.substring(0,K.start)+U+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function a2($){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 e3($,Z){let Y=$;function X(K,z,W,U){let _=1,q=U,B=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(q<K.length&&_>0){B.lastIndex=q,j.lastIndex=q;let H=B.exec(K),L=j.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)_++,q=F+H[0].length;else if(O<1/0){if(_--,_===0)return O;q=O+L[0].length}else break}return-1}function J(K,z,W){let U=0,_=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),q=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=_.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=q.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")U++;else if(L.type==="close")U--;else if(L.type==="else"&&U===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let z=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let W=z.index,U,_,q=Y.slice(W+5),B=a2(q);if(B)U=B.value,_=W+5+B.consumed;else _=W+5;let j=X(Y,"auth","endauth",_);if(j===-1){console.warn(`[stx] @auth directive at position ${W} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(_,j),L=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?V1(`auth?.check && auth?.user?.[${U}]`,Z):V1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let z=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let W=z.index,U,_,q=Y.slice(W+6),B=a2(q);if(B)U=B.value,_=W+6+B.consumed;else _=W+6;let j=X(Y,"guest","endguest",_);if(j===-1){console.warn(`[stx] @guest directive at position ${W} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(_,j),L=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?V1(`!auth?.check || !auth?.user?.[${U}]`,Z):V1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+9),K=!0}}function Q(K,z,W){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let U=[K];if(z)U.push(z);if(W){let _=V1(W,Z);U.push(_)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let z=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!z)return null;return{ability:z[1],type:z[2],id:z[3]?.trim(),paramsEnd:z[0].length}}for(let K of["can","cannot"]){let z=`end${K}`,W=K==="can"?"elsecan":"elsecannot",U=!0;while(U){U=!1;let _=Y.match(new RegExp(`@${K}\\s*\\(`));if(!_||_.index===void 0)break;let q=_.index,B=Y.slice(q+`@${K}`.length),j=G(B);if(!j)break;let H=q+`@${K}`.length+j.paramsEnd,L=X(Y,K,z,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${q} has no matching @${z} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${z}(?![a-z])`,"g"),R=new RegExp(`@${W}\\s*\\(`,"g"),N=/@else(?![a-z])/g,T=[],M;while((M=A.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=w.exec(F))!==null)T.push({pos:M.index,type:"close"});while((M=R.exec(F))!==null)T.push({pos:M.index,type:"elseDirective"});while((M=N.exec(F))!==null)T.push({pos:M.index,type:"else"});T.sort((b,P)=>b.pos-P.pos);for(let b of T){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)O.push(b)}let D=[],I=0;for(let b=0;b<O.length;b++){let P=O[b];if(D.push({content:F.slice(I,P.pos),ability:void 0}),P.type==="elseDirective"){let d=F.slice(P.pos+`@${W}`.length),f=G(d);if(f){D[D.length-1]={content:F.slice(I,P.pos)},I=P.pos+`@${W}`.length+f.paramsEnd,D.push({content:"",ability:f.ability,type:f.type,id:f.id}),D.pop();let u=O[b+1],s=u?u.pos:F.length;D.push({content:F.slice(I,s),ability:f.ability,type:f.type,id:f.id}),I=s}}else I=P.pos+5}if(I<F.length){let b=D[D.length-1];if(O.length>0&&O[O.length-1].type==="else")D.push({content:F.slice(I),isFinalElse:!0});else if(D.length===0)D.push({content:F.slice(I)})}let E=Q(j.ability,j.type,j.id),k=K==="can"?E:!E,S="";if(k)S=D[0]?.content||"";else{let b=!1;for(let P=1;P<D.length;P++){let d=D[P];if(d.isFinalElse){S=d.content,b=!0;break}if(d.ability){let f=Q(d.ability,d.type,d.id);if(K==="can"?f:!f){S=d.content,b=!0;break}}}if(!b&&D.length>0){let P=D[D.length-1];if(P.isFinalElse)S=P.content}}Y=Y.substring(0,q)+S+Y.substring(L+`@${z}`.length),U=!0}}return Y}function $6($,Z,Y){let X=$;function J(Q,G,K,z,W){let U=!0;while(U){U=!1;let _=new RegExp(`@${G}\\s*\\(`),q=Q.match(_);if(!q||q.index===void 0)break;let B=q.index,j=w1(Q,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=m1(Q,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${B} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,L),O=j.expression,V=-1,A=0,w=0;while(w<F.length){let R=F.indexOf("@",w);if(R===-1)break;let N=F.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){A++,w=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){A--,w=R+1;continue}if(A===0&&/^@else(?![a-z])/.test(N)){V=R;break}w=R+1}try{let R=z(O.trim()),N;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);N=R?T:M}else N=R?F:"";Q=Q.substring(0,B)+N+Q.substring(L+`@${K}`.length),U=!0}catch(R){let N=R instanceof Error?R.message:String(R),T=r(W,`Error processing @${G} directive: ${N}`,p.EVALUATION_ERROR);Q=Q.substring(0,B)+T+Q.substring(L+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=V1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=V1(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 Z6($,Z,Y){let X=$,J="development";function Q(G,K,z,W){let U=new RegExp(`@${K}(?![a-z])`,"g"),_=new RegExp(`@${z}(?![a-z])`,"g"),q=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${z}(?![a-z])`),j=G,H=!0;while(H){H=!1,U.lastIndex=0;let L=U.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let E=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!E)break;O+=E[0].length,W=J===E[2]}let V=1,A=O,w=-1;while(V>0&&A<j.length){U.lastIndex=A,_.lastIndex=A;let E=U.exec(j),k=_.exec(j),S=E?E.index:1/0,b=k?k.index:1/0;if(S<b)V++,A=S+E[0].length;else if(b<1/0){if(V--,V===0){w=b;break}A=b+k[0].length}else break}if(w===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${z} \u2014 the block was skipped.`);break}let R=j.substring(O,w),N=-1,T=0,M=0;while(M<R.length){let E=R.indexOf("@",M);if(E===-1)break;let k=R.substring(E);if(q.test(k)){T++,M=E+1;continue}if(B.test(k)){T--,M=E+1;continue}if(T===0&&/^@else(?![a-z])/.test(k)){N=E;break}M=E+1}let D;if(N!==-1){let E=R.slice(0,N),k=R.slice(N+5);D=W?E:k}else D=W?R:"";let I=`@${z}`.length;j=j.substring(0,F)+D+j.substring(w+I),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var C4=C(()=>{l2();W1();b4();w0()});function t2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function p1($,Z){if(!$)return Z?.nonceGenerator?.()??t2();let Y=Y6.get($);if(!Y)Y=Z?.nonceGenerator?.()??t2(),Y6.set($,Y);return Y}function AR($){Y6.delete($)}function e2($,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 J6($,Z){return`<meta http-equiv="Content-Security-Policy" content="${e2($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function RR($){return{enabled:!0,directives:{strict:nU,moderate:X6,relaxed:sU,api:oU}[$]||X6,useNonce:$==="strict",addMetaTag:!0}}function NR($,Z){let Y={...$};for(let[X,J]of Object.entries(Z)){let Q=X,G=Y[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")Y[Q]=G||J;else if(Array.isArray(J)){let K=Array.isArray(G)?G:[],z=[...new Set([...K,...J])];Y[Q]=z}}return Y}function $Y($,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?p1(Y,Z):void 0,J=J6(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
3773
3773
|
${J}`)}function TR($,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 ZY($,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?p1(Z,Q):void 0;return J6(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return p1(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=p1(Z,Q);return J}function MR(){return[rU,aU]}function DR($){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 tU($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function ER($,Z){if(!$.enabled)return{};let Y=$.useNonce?p1(Z,$):void 0,X=e2($.directives,Y);return{[tU($.reportOnly)]:X}}var Y6,nU,X6,sU,oU,rU,aU,IR;var YY=C(()=>{Y6=new WeakMap;nU={"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},X6={"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},sU={"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'"]},oU={"default-src":["'none'"],"frame-ancestors":["'none'"]};rU={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?p1(Y,Q):void 0;return J6(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},aU={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return p1(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};IR={enabled:!1,reportOnly:!1,directives:X6,useNonce:!1,addMetaTag:!0}});import{Buffer as XY}from"buffer";import JY from"crypto";function $_($=eU){let Z=JY.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return L5=Z,Z}function Z_(){if(!L5)$_();return L5}function CR(){L5=null}function PR($){L5=$}function Y_($=QY){let Z=Z_();return`<input type="hidden" name="${$}" value="${Z}">`}function GY($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return Y_(X||QY)})}function yR($,Z){let Y=Z??L5;if(!Y)return!1;let X=XY.from($),J=XY.from(Y);if(X.length!==J.length)return!1;return JY.timingSafeEqual(X,J)}var eU=40,QY="_token",L5=null;var KY=()=>{};async function zY($,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 X_(J,Q,Z,Y,X);else J=await J_(J,Q,Z,Y,X)}return J}async function X_($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,z=`@end${Q}`,W=$,U=v1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${z}`,"g"),_=[],q=U.exec(W);while(q!==null){let[B,j="",H=""]=q,L=q.index||0;try{let F=j?WY(j):[],O=H.trim(),V=await G(O,F,Y,X);_.push({original:B,processed:V,startIndex:L})}catch(F){let O=F instanceof Error?F.message:String(F);if(J.debug)console.error(`Error processing custom directive @${Q}:`,F);_.push({original:B,processed:r("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${O}`,p.EVALUATION_ERROR),startIndex:L})}q=U.exec(W)}for(let B=_.length-1;B>=0;B--){let{original:j,processed:H}=_[B];W=W.replace(j,H)}return W}async function J_($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,z=v1(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),W=[],U=z.exec(K);while(U!==null){let[B,j=""]=U,H=U.index||0;try{let L=WY(j),F=await G("",L,Y,X);W.push({original:B,processed:F,startIndex:H})}catch(L){let F=L instanceof Error?L.message:String(L);if(J.debug)console.error(`Error processing custom directive @${Q}:`,L);W.push({original:B,processed:r("CustomDirective",`Error in @${Q}(${j}): ${F}`,p.EVALUATION_ERROR),startIndex:H})}U=z.exec(K)}let _=v1(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),q=_.exec(K);while(q!==null){let[B]=q,j=q.index||0;try{let H=await G("",[],Y,X);W.push({original:B,processed:H,startIndex:j})}catch(H){let L=H instanceof Error?H.message:String(H);if(J.debug)console.error(`Error processing custom directive @${Q}:`,H);W.push({original:B,processed:r("CustomDirective",`Error in @${Q}: ${L}`,p.EVALUATION_ERROR),startIndex:j})}q=_.exec(K)}for(let B=W.length-1;B>=0;B--){let{original:j,processed:H}=W[B];K=K.replace(j,H)}return K}function WY($){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 UY=C(()=>{W1();G5()});var Q6={};l(Q6,{useTitle:()=>U_,useSeoMeta:()=>y4,usePageTitle:()=>U_,useHead:()=>i1,resetHead:()=>K_,renderHtmlAttrs:()=>q_,renderHead:()=>__,renderBodyAttrs:()=>B_,processTitleDirective:()=>O_,processMetaDirective:()=>L_,processHeadDirective:()=>H_,getPageMeta:()=>G_,getHead:()=>t5,definePageMeta:()=>W_,applyHead:()=>j_});function t5(){return A1}function G_(){return P4}function K_(){A1={},Q_.length=0,P4={}}function i1($){A1=z_(A1,$)}function z_($,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 y4($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let z=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:z})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,X=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(X)Z.push({property:"og:description",content:X});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let J=$.twitterTitle??$.title,Q=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(J)Z.push({name:"twitter:title",content:J});if(Q)Z.push({name:"twitter:description",content:Q});if(G)Z.push({name:"twitter:image",content:G});if($.twitterSite)Z.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)Z.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)Z.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)Z.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)Z.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)Z.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let z of $.articleTags)Z.push({property:"article:tag",content:z});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});i1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function W_($){if(P4={...P4,...$},$.title||$.description)y4({title:$.title,description:$.description})}function U_($){let Z=typeof $==="function"?$():$;i1({title:Z})}function __($=A1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${c1(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${c1(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}="${c1(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}="${c1(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}="${c1(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 q_($=A1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${c1(Y)}"`).join(" ")}function B_($=A1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${c1(Y)}"`).join(" ")}function c1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function j_($=A1){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 H_($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
|
|
3775
3775
|
`,""}),headContent:Z.trim()}}function O_($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return i1({title:G}),""})}function L_($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let z=Q?G:K,W=Q?z:Z[(z||"").trim()]??z,_=J.includes(":")?{property:J,content:W}:{name:J,content:W};return i1({meta:[_]}),""})}var A1,Q_,P4;var e5=C(()=>{A1={},Q_=[],P4={}});import F_ from"crypto";function A0($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function V_($){return{...G6,...$.forms?.classes}}function v4($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function w_(){return F_.randomUUID()}function uR($,Z,Y,X){let J=V_(X),Q=$;return Q=R_(Q,Z),Q=Y$(Q,Z),Q=K6(Q,Z,J),Q=z6(Q,Z,J),Q}function Y$($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=w_();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${A0(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),Y=Y.replace(/@method\(['"]([^'"]+)['"]\)/g,(X,J)=>{let Q=J.toUpperCase();if(J&&!["GET","POST"].includes(Q))return`<input type="hidden" name="_method" value="${A0(Q)}">`;return X}),Y}function K6($,Z,Y=G6){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,z,W="")=>{let U=Q||G||"POST",_=K||z||"",q=R1(W),B=U.toUpperCase(),j=["GET","POST"].includes(B)?B:"POST",H=`<form method="${A0(j)}" action="${A0(_)}"${q?` ${q}`:""}>`;if(H+=`
|
package/dist/story/index.js
CHANGED
|
@@ -3769,7 +3769,7 @@ ${Y}
|
|
|
3769
3769
|
</script>`}function kX($,Z,Y){if(IX=0,!rq($))return $;let X=lq($);if(X.length===0)return $;let J=oq($,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 oq($,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*["']${a4(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*["']${a4(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*"${a4(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*'${a4(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 rq($){return/x-data\s*=\s*["']/.test($)}var IX=0,mq=0;var SX=P(()=>{G1()});import aq from"fs";import D9 from"path";import{createHighlighter as tq}from"ts-syntax-highlighter";async function eq($,Z={}){try{if(!await i($))throw Error(`Markdown file not found: ${$}`);let X=(await aq.promises.stat($)).mtime.getTime();if(Z.cache&&E9.has($)){let q=E9.get($);if(q.updatedAt>=X)return{content:q.content,data:q.data}}let J=await Bun.file($).text(),{data:Q,content:G}=yZ(J),K=Z.markdown||H9.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},U=K$(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)U=await $_(U,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let W={content:U,data:Q||{}};if(Z.cache)E9.set($,{...W,updatedAt:X});return W}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 $_($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!t4)try{t4=await tq({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,z,U,W)=>{let q=W.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),_=U||(Y?"text":"");if(!_)return K;try{if(!t4.getSupportedLanguages().includes(_))return K;return(await t4.highlight(q,_,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${U}:`,B)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[z,U,W,q]=K,_=await J(z,U,W,q);Q=Q.replace(z,_)}return Q}async function bX($,Z,Y="",X={}){return await Z_($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,z,U)=>{try{let W=K;if(!D9.isAbsolute(K))W=D9.resolve(D9.dirname(Y),K);let q={};if(z)try{try{q=JSON.parse(z)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let H=z.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of H){let A=V.indexOf(":");if(A>0){let w=V.substring(0,A).trim(),R=V.substring(A+1).trim(),N=R.startsWith('"')&&R.endsWith('"'),T=R.startsWith("'")&&R.endsWith("'");if(N||T)R=R.substring(1,R.length-1);q[w]=R}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:_,data:B}=await eq(W,X),j={...Z,...B,...q},O=_,L=/\{\{([^}]+)\}\}/g;return O=O.replace(L,(F,H)=>{let V=H.trim();return j[V]!==void 0?String(j[V]):F}),O}catch(W){let q=W instanceof Error?W.message:String(W);return Q0("Markdown File",`Error including markdown file: ${q}`,Y,$,U,G)}})}async function Z_($,Z,Y){let X=[],J;while((J=Z.exec($))!==null){let K=J[0],z=J.index,U=J;X.push(Y(...U).then((W)=>({match:K,replacement:W,index:z})))}let Q=await Promise.all(X);Q.sort((K,z)=>z.index-K.index);let G=$;for(let{match:K,replacement:z}of Q)G=G.replace(K,()=>z);return G}var E9,t4=null;var PX=P(()=>{q$();F0();E9=new Map});function k1($,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 CX=P(()=>{R0()});class e4{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 w0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,z=!1;while(Q<$.length){let U=$[Q];if(G&&z){z=!1,Q++;continue}if(G&&U==="\\"){z=!0,Q++;continue}if(z=!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 yX($,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 I9($){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 S1($,Z){let Y=Y_($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Y_($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=w0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function e1($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let z=G.exec($),U=K.exec($),W=z?z.index:1/0,q=U?U.index:1/0;if(W<q)J++,Q=W+z[0].length;else if(q<1/0){if(J--,J===0)return q;Q=q+U[0].length}else break}return-1}function vX($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=S1($,X);if(!J)return null;let Q=J.endPos,G=e1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],U=0,W="if",q=J.expression,_=0,B=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let O=K.substring(j);if(/^@if\s*\(/.test(O)){B++,U++;continue}if(/^@endif(?![a-z])/.test(O)){B--,U+=6;continue}if(B===0){let L=O.match(/^@elseif\s*/);if(L){z.push({type:W,condition:q,content:K.substring(_,U),start:Q+_,end:Q+U});let F=U+L[0].length,H=S1(K,F);if(!H){U++;continue}W="elseif",q=H.expression,U=H.endPos,_=U;continue}else if(/^@else(?![a-z])/.test(O)){z.push({type:W,condition:q,content:K.substring(_,U),start:Q+_,end:Q+U}),W="else",q=void 0,U+=5,_=U;continue}}U++}return z.push({type:W,condition:q,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:z,start:Z,end:G+6}}function B$($){let Z=[],Y=/@if\s*\(/g,X=Y.exec($);while(X!==null){if(Z.some((G)=>X.index>G.start&&X.index<G.end)){X=Y.exec($);continue}let Q=vX($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function $7($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((O)=>Q.index>O.start&&Q.index<O.end)){Q=J.exec($);continue}let K=Q.index,z=K+Q[0].length-1,U=w0($,"(",")",z);if(U===-1){Q=J.exec($);continue}let W=$.slice(z+1,U),q=U+1,_=e1($,Z,Y,q);if(_===-1){Q=J.exec($);continue}let B=$.slice(q,_),j=_+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:W,content:B,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function k9($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=S1($,X);if(!J)return null;let Q=J.endPos,G=e1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],U=0,W=null,q=0;while(U<K.length){let _=K.slice(U),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(q++,W)W.content+=B[0];U+=B[0].length;continue}if(j){if(q--,W)W.content+=j[0];U+=j[0].length;continue}if(q>0){if(W)W.content+=K[U];U++;continue}let O=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(O&&_.startsWith("@case")){if(W)z.push(W);let H=U+O[0].length,V=S1(K,H);if(!V){U++;continue}W={type:"case",value:V.expression,content:""},U=V.endPos}else if(L&&_.startsWith("@default")){if(W)z.push(W);W={type:"default",content:""},U+=L[0].length}else if(F&&_.startsWith("@break"))U+=F[0].length;else{if(W)W.content+=K[U];U++}}if(W)z.push(W);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:z,start:Z,end:G+10}}var xX=()=>{};function X_($){let Z=[],Y=0;while(Y<$.length){let X=$.indexOf("{{",Y),J=$.indexOf("{!!",Y),Q=!1,G;if(X===-1&&J===-1)break;else if(X===-1)G=J,Q=!0;else if(J===-1)G=X,Q=!1;else if(J<X)G=J,Q=!0;else G=X,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",z=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,W=J_($,U,z);if(W===-1){Y=G+1;continue}let q=$.slice(U,W).trim(),_=W+z.length;Z.push({fullMatch:$.slice(G,_),expression:q,start:G,end:_,isRaw:Q}),Y=_}return Z}function J_($,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 Q_($){let Z=I9($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=G_(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function G_($){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=w0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=hX(G);return{name:X,args:K}}function hX($){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 K_($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=w0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function S9($){let Z=[],X=new e4($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let z=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let W=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let q=J<X.length?X[J].start:$.length,_=fX(X,J,$);J=_.nextIndex,Z.push({type:"variable",name:W,value:$.slice(q,_.endPos),exported:G,start:K.start,end:_.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let W=U.start,q=U.value==="{"?"}":"]",_=w0($,U.value,q,W);if(_!==-1){let B=$.slice(W,_+1);if(J=gX(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,O=fX(X,J,$);J=O.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,O.endPos)}; ${z} ${B} = ${L}`,exported:G,start:K.start,end:O.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let z=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let W=U.value;J++;let q=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){q=X[J].start;break}J++}if(q!==-1){let _=w0($,"{","}",q);if(_!==-1)Z.push({type:"function",name:W,value:$.slice(z,_+1).replace(/^export\s+/,""),exported:G,start:z,end:_+1}),J=gX(X,_+1)}}}else J++}return Z}function fX($,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 gX($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var dX=()=>{};var j$=P(()=>{xX();dX()});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=k9(X,G);if(!K)break;try{let z;if(Z0(K.expression))z=Y0(K.expression,Object.keys(Z))(...Object.values(Z));else z=$0(K.expression,Z);let U="",W=!1;for(let q of K.cases)if(q.type==="default"){if(!W)U=q.content.trim()}else try{let _;if(q.value&&Z0(q.value))_=Y0(q.value,Object.keys(Z))(...Object.values(Z));else if(q.value)_=$0(q.value,Z);if(z===_){U=q.content.trim(),W=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(z){let U=z instanceof Error?z.message:String(z),W=a("Switch",`Error evaluating @switch expression: ${U}`,c.EVALUATION_ERROR);X=X.substring(0,G)+W+X.substring(K.end);break}}return X}function $5($,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,z=S1(X,K+7);if(!z)break;let U=z.endPos,W=e1(X,"unless","endunless",U);if(W===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let q=X.slice(U,W),_=z.expression,B=-1;{let O=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,H=/@else(?![a-z])/g,V=[],A;while((A=L.exec(q))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(q))!==null)V.push({pos:A.index,type:"close"});while((A=H.exec(q))!==null)V.push({pos:A.index,type:"else"});V.sort((w,R)=>w.pos-R.pos);for(let w of V)if(w.type==="open")O++;else if(w.type==="close")O--;else if(w.type==="else"&&O===0){B=w.pos;break}}let j;if(B!==-1){let O=q.slice(0,B),L=q.slice(B+5);j=`@if (${_})${L}@else ${O}@endif`}else j=`@if (!(${_}))${q}@endif`;X=X.substring(0,K)+j+X.substring(W+10),Q=!0}}X=P9(X,Z,Y),X=C9(X,Z,Y),X=b9(X,Z);let J=()=>{let Q=B$(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let z="",U=!1;for(let W of K.branches){if(U)break;if(W.type==="else")z=W.content,U=!0;else try{let q;if(W.condition&&Z0(W.condition))q=Y0(W.condition,Object.keys(Z))(...Object.values(Z));else if(W.condition)q=$0(W.condition,Z);if(q)z=W.content,U=!0}catch(q){z=a(W.type==="if"?"If":"Elseif",`Error in @${W.type}(${W.condition}): ${q instanceof Error?q.message:String(q)}`,c.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+z+X.substring(K.end)}catch(z){let U=z instanceof Error?z.message:String(z),W=a("If",`Error processing @if block: ${U}`,c.EVALUATION_ERROR);X=X.substring(0,K.start)+W+X.substring(K.end)}}return!0};while(J());return X}function uX($){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 b9($,Z){let Y=$;function X(K,z,U,W){let q=1,_=W,B=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(_<K.length&&q>0){B.lastIndex=_,j.lastIndex=_;let O=B.exec(K),L=j.exec(K),F=O?O.index:1/0,H=L?L.index:1/0;if(F<H)q++,_=F+O[0].length;else if(H<1/0){if(q--,q===0)return H;_=H+L[0].length}else break}return-1}function J(K,z,U){let W=0,q=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${U}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],O;while((O=q.exec(K))!==null)j.push({pos:O.index,type:"open"});while((O=_.exec(K))!==null)j.push({pos:O.index,type:"close"});while((O=B.exec(K))!==null)j.push({pos:O.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")W++;else if(L.type==="close")W--;else if(L.type==="else"&&W===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let z=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let U=z.index,W,q,_=Y.slice(U+5),B=uX(_);if(B)W=B.value,q=U+5+B.consumed;else q=U+5;let j=X(Y,"auth","endauth",q);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let O=Y.slice(q,j),L=J(O,"auth","endauth"),F;if(!Z.auth)F=!1;else F=W?k1(`auth?.check && auth?.user?.[${W}]`,Z):k1("auth?.check",Z);let H;if(L!==-1){let V=O.slice(0,L),A=O.slice(L+5);H=F?V:A}else H=F?O:"";Y=Y.substring(0,U)+H+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let z=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let U=z.index,W,q,_=Y.slice(U+6),B=uX(_);if(B)W=B.value,q=U+6+B.consumed;else q=U+6;let j=X(Y,"guest","endguest",q);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let O=Y.slice(q,j),L=J(O,"guest","endguest"),F;if(!Z.auth)F=!0;else F=W?k1(`!auth?.check || !auth?.user?.[${W}]`,Z):k1("!auth?.check",Z);let H;if(L!==-1){let V=O.slice(0,L),A=O.slice(L+5);H=F?V:A}else H=F?O:"";Y=Y.substring(0,U)+H+Y.substring(j+9),K=!0}}function Q(K,z,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let W=[K];if(z)W.push(z);if(U){let q=k1(U,Z);W.push(q)}return Z.permissions.check(...W)}catch{return!1}return!1}function G(K){let z=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!z)return null;return{ability:z[1],type:z[2],id:z[3]?.trim(),paramsEnd:z[0].length}}for(let K of["can","cannot"]){let z=`end${K}`,U=K==="can"?"elsecan":"elsecannot",W=!0;while(W){W=!1;let q=Y.match(new RegExp(`@${K}\\s*\\(`));if(!q||q.index===void 0)break;let _=q.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let O=_+`@${K}`.length+j.paramsEnd,L=X(Y,K,z,O);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${z} \u2014 the block was skipped.`);break}let F=Y.slice(O,L),H=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${z}(?![a-z])`,"g"),R=new RegExp(`@${U}\\s*\\(`,"g"),N=/@else(?![a-z])/g,T=[],M;while((M=A.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=w.exec(F))!==null)T.push({pos:M.index,type:"close"});while((M=R.exec(F))!==null)T.push({pos:M.index,type:"elseDirective"});while((M=N.exec(F))!==null)T.push({pos:M.index,type:"else"});T.sort((b,C)=>b.pos-C.pos);for(let b of T){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)H.push(b)}let D=[],E=0;for(let b=0;b<H.length;b++){let C=H[b];if(D.push({content:F.slice(E,C.pos),ability:void 0}),C.type==="elseDirective"){let d=F.slice(C.pos+`@${U}`.length),f=G(d);if(f){D[D.length-1]={content:F.slice(E,C.pos)},E=C.pos+`@${U}`.length+f.paramsEnd,D.push({content:"",ability:f.ability,type:f.type,id:f.id}),D.pop();let u=H[b+1],o=u?u.pos:F.length;D.push({content:F.slice(E,o),ability:f.ability,type:f.type,id:f.id}),E=o}}else E=C.pos+5}if(E<F.length){let b=D[D.length-1];if(H.length>0&&H[H.length-1].type==="else")D.push({content:F.slice(E),isFinalElse:!0});else if(D.length===0)D.push({content:F.slice(E)})}let I=Q(j.ability,j.type,j.id),k=K==="can"?I:!I,S="";if(k)S=D[0]?.content||"";else{let b=!1;for(let C=1;C<D.length;C++){let d=D[C];if(d.isFinalElse){S=d.content,b=!0;break}if(d.ability){let f=Q(d.ability,d.type,d.id);if(K==="can"?f:!f){S=d.content,b=!0;break}}}if(!b&&D.length>0){let C=D[D.length-1];if(C.isFinalElse)S=C.content}}Y=Y.substring(0,_)+S+Y.substring(L+`@${z}`.length),W=!0}}return Y}function P9($,Z,Y){let X=$;function J(Q,G,K,z,U){let W=!0;while(W){W=!1;let q=new RegExp(`@${G}\\s*\\(`),_=Q.match(q);if(!_||_.index===void 0)break;let B=_.index,j=S1(Q,B+`@${G}`.length);if(!j)break;let O=j.endPos,L=e1(Q,G,K,O);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(O,L),H=j.expression,V=-1,A=0,w=0;while(w<F.length){let R=F.indexOf("@",w);if(R===-1)break;let N=F.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){A++,w=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){A--,w=R+1;continue}if(A===0&&/^@else(?![a-z])/.test(N)){V=R;break}w=R+1}try{let R=z(H.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),W=!0}catch(R){let N=R instanceof Error?R.message:String(R),T=a(U,`Error processing @${G} directive: ${N}`,c.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=k1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=k1(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 C9($,Z,Y){let X=$,J="development";function Q(G,K,z,U){let W=new RegExp(`@${K}(?![a-z])`,"g"),q=new RegExp(`@${z}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${z}(?![a-z])`),j=G,O=!0;while(O){O=!1,W.lastIndex=0;let L=W.exec(j);if(!L)break;let F=L.index,H=F+L[0].length;if(K==="env"){let I=j.substring(H).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!I)break;H+=I[0].length,U=J===I[2]}let V=1,A=H,w=-1;while(V>0&&A<j.length){W.lastIndex=A,q.lastIndex=A;let I=W.exec(j),k=q.exec(j),S=I?I.index:1/0,b=k?k.index:1/0;if(S<b)V++,A=S+I[0].length;else if(b<1/0){if(V--,V===0){w=b;break}A=b+k[0].length}else break}if(w===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${z} \u2014 the block was skipped.`);break}let R=j.substring(H,w),N=-1,T=0,M=0;while(M<R.length){let I=R.indexOf("@",M);if(I===-1)break;let k=R.substring(I);if(_.test(k)){T++,M=I+1;continue}if(B.test(k)){T--,M=I+1;continue}if(T===0&&/^@else(?![a-z])/.test(k)){N=I;break}M=I+1}let D;if(N!==-1){let I=R.slice(0,N),k=R.slice(N+5);D=U?I:k}else D=U?R:"";let E=`@${z}`.length;j=j.substring(0,F)+D+j.substring(w+E),O=!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 Z7=P(()=>{CX();O1();j$();R0()});function mX($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function Z5($,Z){if(!$)return Z?.nonceGenerator?.()??mX();let Y=y9.get($);if(!Y)Y=Z?.nonceGenerator?.()??mX(),y9.set($,Y);return Y}function WM($){y9.delete($)}function lX($,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 x9($,Z){return`<meta http-equiv="Content-Security-Policy" content="${lX($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function qM($){return{enabled:!0,directives:{strict:U_,moderate:v9,relaxed:W_,api:q_}[$]||v9,useNonce:$==="strict",addMetaTag:!0}}function _M($,Z){let Y={...$};for(let[X,J]of Object.entries(Z)){let Q=X,G=Y[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")Y[Q]=G||J;else if(Array.isArray(J)){let K=Array.isArray(G)?G:[],z=[...new Set([...K,...J])];Y[Q]=z}}return Y}function cX($,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?Z5(Y,Z):void 0,J=x9(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 w0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,z=!1;while(Q<$.length){let U=$[Q];if(G&&z){z=!1,Q++;continue}if(G&&U==="\\"){z=!0,Q++;continue}if(z=!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 yX($,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 I9($){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 S1($,Z){let Y=Y_($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Y_($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=w0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function e1($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let z=G.exec($),U=K.exec($),W=z?z.index:1/0,q=U?U.index:1/0;if(W<q)J++,Q=W+z[0].length;else if(q<1/0){if(J--,J===0)return q;Q=q+U[0].length}else break}return-1}function vX($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=S1($,X);if(!J)return null;let Q=J.endPos,G=e1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],U=0,W="if",q=J.expression,_=0,B=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let O=K.substring(j);if(/^@if\s*\(/.test(O)){B++,U++;continue}if(/^@endif(?![a-z])/.test(O)){B--,U+=6;continue}if(B===0){let L=O.match(/^@elseif\s*/);if(L){z.push({type:W,condition:q,content:K.substring(_,U),start:Q+_,end:Q+U});let F=U+L[0].length,H=S1(K,F);if(!H){U++;continue}W="elseif",q=H.expression,U=H.endPos,_=U;continue}else if(/^@else(?![a-z])/.test(O)){z.push({type:W,condition:q,content:K.substring(_,U),start:Q+_,end:Q+U}),W="else",q=void 0,U+=5,_=U;continue}}U++}return z.push({type:W,condition:q,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:z,start:Z,end:G+6}}function B$($){let Z=[],Y=/@if\s*\(/g,X=Y.exec($);while(X!==null){if(Z.some((G)=>X.index>G.start&&X.index<G.end)){X=Y.exec($);continue}let Q=vX($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function $7($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((O)=>Q.index>O.start&&Q.index<O.end)){Q=J.exec($);continue}let K=Q.index,z=K+Q[0].length-1,U=w0($,"(",")",z);if(U===-1){Q=J.exec($);continue}let W=$.slice(z+1,U),q=U+1,_=e1($,Z,Y,q);if(_===-1){Q=J.exec($);continue}let B=$.slice(q,_),j=_+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:W,content:B,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function k9($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=S1($,X);if(!J)return null;let Q=J.endPos,G=e1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],U=0,W=null,q=0;while(U<K.length){let _=K.slice(U),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(q++,W)W.content+=B[0];U+=B[0].length;continue}if(j){if(q--,W)W.content+=j[0];U+=j[0].length;continue}if(q>0){if(W)W.content+=K[U];U++;continue}let O=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(O&&_.startsWith("@case")){if(W)z.push(W);let H=U+O[0].length,V=S1(K,H);if(!V){U++;continue}W={type:"case",value:V.expression,content:""},U=V.endPos}else if(L&&_.startsWith("@default")){if(W)z.push(W);W={type:"default",content:""},U+=L[0].length}else if(F&&_.startsWith("@break"))U+=F[0].length;else{if(W)W.content+=K[U];U++}}if(W)z.push(W);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:z,start:Z,end:G+10}}var xX=()=>{};function X_($){let Z=[],Y=0;while(Y<$.length){let X=$.indexOf("{{",Y),J=$.indexOf("{!!",Y),Q=!1,G;if(X===-1&&J===-1)break;else if(X===-1)G=J,Q=!0;else if(J===-1)G=X,Q=!1;else if(J<X)G=J,Q=!0;else G=X,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",z=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,W=J_($,U,z);if(W===-1){Y=G+1;continue}let q=$.slice(U,W).trim(),_=W+z.length;Z.push({fullMatch:$.slice(G,_),expression:q,start:G,end:_,isRaw:Q}),Y=_}return Z}function J_($,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 Q_($){let Z=I9($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=G_(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function G_($){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=w0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=hX(G);return{name:X,args:K}}function hX($){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 K_($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=w0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function S9($){let Z=[],X=new e4($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let z=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let W=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let q=J<X.length?X[J].start:$.length,_=fX(X,J,$);J=_.nextIndex,Z.push({type:"variable",name:W,value:$.slice(q,_.endPos),exported:G,start:K.start,end:_.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let W=U.start,q=U.value==="{"?"}":"]",_=w0($,U.value,q,W);if(_!==-1){let B=$.slice(W,_+1);if(J=gX(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,O=fX(X,J,$);J=O.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,O.endPos)}; ${z} ${B} = ${L}`,exported:G,start:K.start,end:O.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let z=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let W=U.value;J++;let q=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){q=X[J].start;break}J++}if(q!==-1){let _=w0($,"{","}",q);if(_!==-1)Z.push({type:"function",name:W,value:$.slice(z,_+1).replace(/^export\s+/,""),exported:G,start:z,end:_+1}),J=gX(X,_+1)}}}else J++}return Z}function fX($,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 gX($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var dX=()=>{};var j$=P(()=>{xX();dX()});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=k9(X,G);if(!K)break;try{let z;if(Z0(K.expression))z=Y0(K.expression,Object.keys(Z))(...Object.values(Z));else z=$0(K.expression,Z);let U="",W=!1;for(let q of K.cases)if(q.type==="default"){if(!W)U=q.content.trim()}else try{let _;if(q.value&&Z0(q.value))_=Y0(q.value,Object.keys(Z))(...Object.values(Z));else if(q.value)_=$0(q.value,Z);if(z===_){U=q.content.trim(),W=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(z){let U=z instanceof Error?z.message:String(z),W=a("Switch",`Error evaluating @switch expression: ${U}`,c.EVALUATION_ERROR);X=X.substring(0,G)+W+X.substring(K.end);break}}return X}function $5($,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,z=S1(X,K+7);if(!z)break;let U=z.endPos,W=e1(X,"unless","endunless",U);if(W===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let q=X.slice(U,W),_=z.expression,B=-1;{let O=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,H=/@else(?![a-z])/g,V=[],A;while((A=L.exec(q))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(q))!==null)V.push({pos:A.index,type:"close"});while((A=H.exec(q))!==null)V.push({pos:A.index,type:"else"});V.sort((w,R)=>w.pos-R.pos);for(let w of V)if(w.type==="open")O++;else if(w.type==="close")O--;else if(w.type==="else"&&O===0){B=w.pos;break}}let j;if(B!==-1){let O=q.slice(0,B),L=q.slice(B+5);j=`@if (${_})${L}@else ${O}@endif`}else j=`@if (!(${_}))${q}@endif`;X=X.substring(0,K)+j+X.substring(W+10),Q=!0}}X=P9(X,Z,Y),X=C9(X,Z,Y),X=b9(X,Z);let J=()=>{let Q=B$(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let z="",U=!1;for(let W of K.branches){if(U)break;if(W.type==="else")z=W.content,U=!0;else try{let q;if(W.condition&&Z0(W.condition))q=Y0(W.condition,Object.keys(Z))(...Object.values(Z));else if(W.condition)q=$0(W.condition,Z);if(q)z=W.content,U=!0}catch(q){z=a(W.type==="if"?"If":"Elseif",`Error in @${W.type}(${W.condition}): ${q instanceof Error?q.message:String(q)}`,c.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+z+X.substring(K.end)}catch(z){let U=z instanceof Error?z.message:String(z),W=a("If",`Error processing @if block: ${U}`,c.EVALUATION_ERROR);X=X.substring(0,K.start)+W+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function uX($){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 b9($,Z){let Y=$;function X(K,z,U,W){let q=1,_=W,B=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(_<K.length&&q>0){B.lastIndex=_,j.lastIndex=_;let O=B.exec(K),L=j.exec(K),F=O?O.index:1/0,H=L?L.index:1/0;if(F<H)q++,_=F+O[0].length;else if(H<1/0){if(q--,q===0)return H;_=H+L[0].length}else break}return-1}function J(K,z,U){let W=0,q=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${U}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],O;while((O=q.exec(K))!==null)j.push({pos:O.index,type:"open"});while((O=_.exec(K))!==null)j.push({pos:O.index,type:"close"});while((O=B.exec(K))!==null)j.push({pos:O.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")W++;else if(L.type==="close")W--;else if(L.type==="else"&&W===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let z=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let U=z.index,W,q,_=Y.slice(U+5),B=uX(_);if(B)W=B.value,q=U+5+B.consumed;else q=U+5;let j=X(Y,"auth","endauth",q);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let O=Y.slice(q,j),L=J(O,"auth","endauth"),F;if(!Z.auth)F=!1;else F=W?k1(`auth?.check && auth?.user?.[${W}]`,Z):k1("auth?.check",Z);let H;if(L!==-1){let V=O.slice(0,L),A=O.slice(L+5);H=F?V:A}else H=F?O:"";Y=Y.substring(0,U)+H+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let z=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let U=z.index,W,q,_=Y.slice(U+6),B=uX(_);if(B)W=B.value,q=U+6+B.consumed;else q=U+6;let j=X(Y,"guest","endguest",q);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let O=Y.slice(q,j),L=J(O,"guest","endguest"),F;if(!Z.auth)F=!0;else F=W?k1(`!auth?.check || !auth?.user?.[${W}]`,Z):k1("!auth?.check",Z);let H;if(L!==-1){let V=O.slice(0,L),A=O.slice(L+5);H=F?V:A}else H=F?O:"";Y=Y.substring(0,U)+H+Y.substring(j+9),K=!0}}function Q(K,z,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let W=[K];if(z)W.push(z);if(U){let q=k1(U,Z);W.push(q)}return Z.permissions.check(...W)}catch{return!1}return!1}function G(K){let z=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!z)return null;return{ability:z[1],type:z[2],id:z[3]?.trim(),paramsEnd:z[0].length}}for(let K of["can","cannot"]){let z=`end${K}`,U=K==="can"?"elsecan":"elsecannot",W=!0;while(W){W=!1;let q=Y.match(new RegExp(`@${K}\\s*\\(`));if(!q||q.index===void 0)break;let _=q.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let O=_+`@${K}`.length+j.paramsEnd,L=X(Y,K,z,O);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${z} \u2014 the block was skipped.`);break}let F=Y.slice(O,L),H=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${z}(?![a-z])`,"g"),R=new RegExp(`@${U}\\s*\\(`,"g"),N=/@else(?![a-z])/g,T=[],M;while((M=A.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=w.exec(F))!==null)T.push({pos:M.index,type:"close"});while((M=R.exec(F))!==null)T.push({pos:M.index,type:"elseDirective"});while((M=N.exec(F))!==null)T.push({pos:M.index,type:"else"});T.sort((b,C)=>b.pos-C.pos);for(let b of T){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)H.push(b)}let D=[],E=0;for(let b=0;b<H.length;b++){let C=H[b];if(D.push({content:F.slice(E,C.pos),ability:void 0}),C.type==="elseDirective"){let d=F.slice(C.pos+`@${U}`.length),f=G(d);if(f){D[D.length-1]={content:F.slice(E,C.pos)},E=C.pos+`@${U}`.length+f.paramsEnd,D.push({content:"",ability:f.ability,type:f.type,id:f.id}),D.pop();let u=H[b+1],o=u?u.pos:F.length;D.push({content:F.slice(E,o),ability:f.ability,type:f.type,id:f.id}),E=o}}else E=C.pos+5}if(E<F.length){let b=D[D.length-1];if(H.length>0&&H[H.length-1].type==="else")D.push({content:F.slice(E),isFinalElse:!0});else if(D.length===0)D.push({content:F.slice(E)})}let I=Q(j.ability,j.type,j.id),k=K==="can"?I:!I,S="";if(k)S=D[0]?.content||"";else{let b=!1;for(let C=1;C<D.length;C++){let d=D[C];if(d.isFinalElse){S=d.content,b=!0;break}if(d.ability){let f=Q(d.ability,d.type,d.id);if(K==="can"?f:!f){S=d.content,b=!0;break}}}if(!b&&D.length>0){let C=D[D.length-1];if(C.isFinalElse)S=C.content}}Y=Y.substring(0,_)+S+Y.substring(L+`@${z}`.length),W=!0}}return Y}function P9($,Z,Y){let X=$;function J(Q,G,K,z,U){let W=!0;while(W){W=!1;let q=new RegExp(`@${G}\\s*\\(`),_=Q.match(q);if(!_||_.index===void 0)break;let B=_.index,j=S1(Q,B+`@${G}`.length);if(!j)break;let O=j.endPos,L=e1(Q,G,K,O);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(O,L),H=j.expression,V=-1,A=0,w=0;while(w<F.length){let R=F.indexOf("@",w);if(R===-1)break;let N=F.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){A++,w=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){A--,w=R+1;continue}if(A===0&&/^@else(?![a-z])/.test(N)){V=R;break}w=R+1}try{let R=z(H.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),W=!0}catch(R){let N=R instanceof Error?R.message:String(R),T=a(U,`Error processing @${G} directive: ${N}`,c.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=k1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=k1(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 C9($,Z,Y){let X=$,J="development";function Q(G,K,z,U){let W=new RegExp(`@${K}(?![a-z])`,"g"),q=new RegExp(`@${z}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${z}(?![a-z])`),j=G,O=!0;while(O){O=!1,W.lastIndex=0;let L=W.exec(j);if(!L)break;let F=L.index,H=F+L[0].length;if(K==="env"){let I=j.substring(H).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!I)break;H+=I[0].length,U=J===I[2]}let V=1,A=H,w=-1;while(V>0&&A<j.length){W.lastIndex=A,q.lastIndex=A;let I=W.exec(j),k=q.exec(j),S=I?I.index:1/0,b=k?k.index:1/0;if(S<b)V++,A=S+I[0].length;else if(b<1/0){if(V--,V===0){w=b;break}A=b+k[0].length}else break}if(w===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${z} \u2014 the block was skipped.`);break}let R=j.substring(H,w),N=-1,T=0,M=0;while(M<R.length){let I=R.indexOf("@",M);if(I===-1)break;let k=R.substring(I);if(_.test(k)){T++,M=I+1;continue}if(B.test(k)){T--,M=I+1;continue}if(T===0&&/^@else(?![a-z])/.test(k)){N=I;break}M=I+1}let D;if(N!==-1){let I=R.slice(0,N),k=R.slice(N+5);D=U?I:k}else D=U?R:"";let E=`@${z}`.length;j=j.substring(0,F)+D+j.substring(w+E),O=!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 Z7=P(()=>{CX();O1();j$();R0()});function mX($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function Z5($,Z){if(!$)return Z?.nonceGenerator?.()??mX();let Y=y9.get($);if(!Y)Y=Z?.nonceGenerator?.()??mX(),y9.set($,Y);return Y}function WM($){y9.delete($)}function lX($,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 x9($,Z){return`<meta http-equiv="Content-Security-Policy" content="${lX($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function qM($){return{enabled:!0,directives:{strict:U_,moderate:v9,relaxed:W_,api:q_}[$]||v9,useNonce:$==="strict",addMetaTag:!0}}function _M($,Z){let Y={...$};for(let[X,J]of Object.entries(Z)){let Q=X,G=Y[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")Y[Q]=G||J;else if(Array.isArray(J)){let K=Array.isArray(G)?G:[],z=[...new Set([...K,...J])];Y[Q]=z}}return Y}function cX($,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?Z5(Y,Z):void 0,J=x9(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
3773
3773
|
${J}`)}function BM($,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 pX($,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?Z5(Z,Q):void 0;return x9(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return Z5(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=Z5(Z,Q);return J}function jM(){return[__,B_]}function OM($){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 j_($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function HM($,Z){if(!$.enabled)return{};let Y=$.useNonce?Z5(Z,$):void 0,X=lX($.directives,Y);return{[j_($.reportOnly)]:X}}var y9,U_,v9,W_,q_,__,B_,LM;var iX=P(()=>{y9=new WeakMap;U_={"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},v9={"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},W_={"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'"]},q_={"default-src":["'none'"],"frame-ancestors":["'none'"]};__={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?Z5(Y,Q):void 0;return x9(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},B_={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return Z5(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};LM={enabled:!1,reportOnly:!1,directives:v9,useNonce:!1,addMetaTag:!0}});import{Buffer as nX}from"buffer";import sX from"crypto";function H_($=O_){let Z=sX.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return P5=Z,Z}function L_(){if(!P5)H_();return P5}function AM(){P5=null}function RM($){P5=$}function F_($=oX){let Z=L_();return`<input type="hidden" name="${$}" value="${Z}">`}function rX($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return F_(X||oX)})}function NM($,Z){let Y=Z??P5;if(!Y)return!1;let X=nX.from($),J=nX.from(Y);if(X.length!==J.length)return!1;return sX.timingSafeEqual(X,J)}var O_=40,oX="_token",P5=null;var aX=()=>{};async function tX($,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 V_(J,Q,Z,Y,X);else J=await w_(J,Q,Z,Y,X)}return J}async function V_($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,z=`@end${Q}`,U=$,W=i1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${z}`,"g"),q=[],_=W.exec(U);while(_!==null){let[B,j="",O=""]=_,L=_.index||0;try{let F=j?eX(j):[],H=O.trim(),V=await G(H,F,Y,X);q.push({original:B,processed:V,startIndex:L})}catch(F){let H=F instanceof Error?F.message:String(F);if(J.debug)console.error(`Error processing custom directive @${Q}:`,F);q.push({original:B,processed:a("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${H}`,c.EVALUATION_ERROR),startIndex:L})}_=W.exec(U)}for(let B=q.length-1;B>=0;B--){let{original:j,processed:O}=q[B];U=U.replace(j,O)}return U}async function w_($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,z=i1(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),U=[],W=z.exec(K);while(W!==null){let[B,j=""]=W,O=W.index||0;try{let L=eX(j),F=await G("",L,Y,X);U.push({original:B,processed:F,startIndex:O})}catch(L){let F=L instanceof Error?L.message:String(L);if(J.debug)console.error(`Error processing custom directive @${Q}:`,L);U.push({original:B,processed:a("CustomDirective",`Error in @${Q}(${j}): ${F}`,c.EVALUATION_ERROR),startIndex:O})}W=z.exec(K)}let q=i1(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),_=q.exec(K);while(_!==null){let[B]=_,j=_.index||0;try{let O=await G("",[],Y,X);U.push({original:B,processed:O,startIndex:j})}catch(O){let L=O instanceof Error?O.message:String(O);if(J.debug)console.error(`Error processing custom directive @${Q}:`,O);U.push({original:B,processed:a("CustomDirective",`Error in @${Q}: ${L}`,c.EVALUATION_ERROR),startIndex:j})}_=q.exec(K)}for(let B=U.length-1;B>=0;B--){let{original:j,processed:O}=U[B];K=K.replace(j,O)}return K}function eX($){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 $2=P(()=>{O1();A5()});var f9={};l(f9,{useTitle:()=>D_,useSeoMeta:()=>X7,usePageTitle:()=>D_,useHead:()=>X5,resetHead:()=>N_,renderHtmlAttrs:()=>I_,renderHead:()=>E_,renderBodyAttrs:()=>k_,processTitleDirective:()=>P_,processMetaDirective:()=>C_,processHeadDirective:()=>b_,getPageMeta:()=>R_,getHead:()=>O$,definePageMeta:()=>M_,applyHead:()=>S_});function O$(){return b1}function R_(){return Y7}function N_(){b1={},A_.length=0,Y7={}}function X5($){b1=T_(b1,$)}function T_($,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 X7($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let z=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:z})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,X=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(X)Z.push({property:"og:description",content:X});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let J=$.twitterTitle??$.title,Q=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(J)Z.push({name:"twitter:title",content:J});if(Q)Z.push({name:"twitter:description",content:Q});if(G)Z.push({name:"twitter:image",content:G});if($.twitterSite)Z.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)Z.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)Z.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)Z.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)Z.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)Z.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let z of $.articleTags)Z.push({property:"article:tag",content:z});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});X5({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function M_($){if(Y7={...Y7,...$},$.title||$.description)X7({title:$.title,description:$.description})}function D_($){let Z=typeof $==="function"?$():$;X5({title:Z})}function E_($=b1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${Y5(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${Y5(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}="${Y5(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}="${Y5(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}="${Y5(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 I_($=b1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${Y5(Y)}"`).join(" ")}function k_($=b1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${Y5(Y)}"`).join(" ")}function Y5($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function S_($=b1){if(typeof document>"u")return;if($.title){let Z=$.title;if($.titleTemplate)Z=typeof $.titleTemplate==="function"?$.titleTemplate(Z):$.titleTemplate.replace("%s",Z);document.title=Z}for(let Z of $.meta||[]){let Y=Z.name?`meta[name="${Z.name}"]`:Z.property?`meta[property="${Z.property}"]`:null;if(Y){let 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 b_($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
|
|
3775
3775
|
`,""}),headContent:Z.trim()}}function P_($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return X5({title:G}),""})}function C_($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let z=Q?G:K,U=Q?z:Z[(z||"").trim()]??z,q=J.includes(":")?{property:J,content:U}:{name:J,content:U};return X5({meta:[q]}),""})}var b1,A_,Y7;var H$=P(()=>{b1={},A_=[],Y7={}});import y_ from"crypto";function N0($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function v_($){return{...g9,...$.forms?.classes}}function J7($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function x_(){return y_.randomUUID()}function SM($,Z,Y,X){let J=v_(X),Q=$;return Q=g_(Q,Z),Q=V$(Q,Z),Q=h9(Q,Z,J),Q=d9(Q,Z,J),Q}function V$($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=x_();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${N0(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="${N0(Q)}">`;return X}),Y}function h9($,Z,Y=g9){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,z,U="")=>{let W=Q||G||"POST",q=K||z||"",_=P1(U),B=W.toUpperCase(),j=["GET","POST"].includes(B)?B:"POST",O=`<form method="${N0(j)}" action="${N0(q)}"${_?` ${_}`:""}>`;if(O+=`
|
package/dist/story/renderer.js
CHANGED
|
@@ -3769,7 +3769,7 @@ ${Y}
|
|
|
3769
3769
|
</script>`}function nZ($,Z,Y){if(iZ=0,!Jz($))return $;let X=aq($);if(X.length===0)return $;let J=Xz($,X),Q=Yz(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 Xz($,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*["']${Q4(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*["']${Q4(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*"${Q4(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*'${Q4(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 Jz($){return/x-data\s*=\s*["']/.test($)}var iZ=0,rq=0;var oZ=C(()=>{a0()});import Qz from"fs";import N3 from"path";import{createHighlighter as Gz}from"ts-syntax-highlighter";async function Kz($,Z={}){try{if(!await i($))throw Error(`Markdown file not found: ${$}`);let X=(await Qz.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}=t9(J),K=Z.markdown||B3.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},z=b5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)z=await qz(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:J0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function qz($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!G4)try{G4=await Gz({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(!G4.getSupportedLanguages().includes(_))return K;return(await G4.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 sZ($,Z,Y="",X={}){return await zz($,/@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 Kz(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 zz($,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,G4=null;var rZ=C(()=>{P5();H0();T3=new Map});function j1($,Z){try{let Y=$.trim();if($0(Y))return Z0(Y,Object.keys(Z))(...Object.values(Z));else return e(Y,Z)}catch{return!1}}var aZ=C(()=>{V0()});class K4{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 L0($,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 tZ($,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=Uz($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Uz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=L0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function P1($,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 eZ($,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=P1($,"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 x5($){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=eZ($,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=L0($,"(",")",q);if(z===-1){Q=J.exec($);continue}let U=$.slice(q+1,z),W=z+1,_=P1($,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=P1($,"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 $2=()=>{};function Wz($){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=_z($,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 _z($,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 Bz($){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=jz(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function jz($){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=L0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=X2(G);return{name:X,args:K}}function X2($){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 Hz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=L0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function Oz($){let Z=[],X=new K4($).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,_=Z2(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==="{"?"}":"]",_=L0($,z.value,W,U);if(_!==-1){let B=$.slice(U,_+1);if(J=Y2(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=Z2(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 _=L0($,"{","}",W);if(_!==-1)Z.push({type:"function",name:U,value:$.slice(q,_+1).replace(/^export\s+/,""),exported:G,start:q,end:_+1}),J=Y2(X,_+1)}}}else J++}return Z}function Z2($,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 Y2($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var J2=()=>{};var z4=C(()=>{$2();J2()});function Lz($,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($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}`,p.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function v1($,Z,Y){let X=$;X=Lz(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=P1(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=x5(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)}`,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=r("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 Q2($){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=Q2(_);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=Q2(_);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((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 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=P1(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}`,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,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 U4=C(()=>{aZ();Q1();z4();V0()});function G2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function x1($,Z){if(!$)return Z?.nonceGenerator?.()??G2();let Y=b3.get($);if(!Y)Y=Z?.nonceGenerator?.()??G2(),b3.set($,Y);return Y}function Ww($){b3.delete($)}function K2($,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="${K2($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function _w($){return{enabled:!0,directives:{strict:Fz,moderate:S3,relaxed:Vz,api:wz}[$]||S3,useNonce:$==="strict",addMetaTag:!0}}function Bw($,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 q2($,Z,Y){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let X=Z.useNonce?x1(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 L0($,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 tZ($,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=Uz($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Uz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=L0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function P1($,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 eZ($,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=P1($,"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 x5($){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=eZ($,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=L0($,"(",")",q);if(z===-1){Q=J.exec($);continue}let U=$.slice(q+1,z),W=z+1,_=P1($,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=P1($,"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 $2=()=>{};function Wz($){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=_z($,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 _z($,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 Bz($){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=jz(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function jz($){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=L0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=X2(G);return{name:X,args:K}}function X2($){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 Hz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=L0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function Oz($){let Z=[],X=new K4($).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,_=Z2(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==="{"?"}":"]",_=L0($,z.value,W,U);if(_!==-1){let B=$.slice(U,_+1);if(J=Y2(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=Z2(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 _=L0($,"{","}",W);if(_!==-1)Z.push({type:"function",name:U,value:$.slice(q,_+1).replace(/^export\s+/,""),exported:G,start:q,end:_+1}),J=Y2(X,_+1)}}}else J++}return Z}function Z2($,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 Y2($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var J2=()=>{};var z4=C(()=>{$2();J2()});function Lz($,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($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}`,p.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function v1($,Z,Y){let X=$;X=Lz(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=P1(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=x5(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)}`,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=r("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 Q2($){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=Q2(_);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=Q2(_);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((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 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=P1(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}`,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,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 U4=C(()=>{aZ();Q1();z4();V0()});function G2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function x1($,Z){if(!$)return Z?.nonceGenerator?.()??G2();let Y=b3.get($);if(!Y)Y=Z?.nonceGenerator?.()??G2(),b3.set($,Y);return Y}function Ww($){b3.delete($)}function K2($,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="${K2($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function _w($){return{enabled:!0,directives:{strict:Fz,moderate:S3,relaxed:Vz,api:wz}[$]||S3,useNonce:$==="strict",addMetaTag:!0}}function Bw($,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 q2($,Z,Y){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let X=Z.useNonce?x1(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 z2($,Z,Y,X){let J=$,Q=X.csp;if(J=J.replace(/@csp\b/g,()=>{if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?x1(Z,Q):void 0;return y3(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return x1(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=x1(Z,Q);return J}function Hw(){return[Az,Rz]}function Ow($){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 Nz($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function Lw($,Z){if(!$.enabled)return{};let Y=$.useNonce?x1(Z,$):void 0,X=K2($.directives,Y);return{[Nz($.reportOnly)]:X}}var b3,Fz,S3,Vz,wz,Az,Rz,Fw;var U2=C(()=>{b3=new WeakMap;Fz={"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},Vz={"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'"]},wz={"default-src":["'none'"],"frame-ancestors":["'none'"]};Az={name:"csp",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?x1(Y,Q):void 0;return y3(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},Rz={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return x1(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};Fw={enabled:!1,reportOnly:!1,directives:S3,useNonce:!1,addMetaTag:!0}});import{Buffer as W2}from"buffer";import _2 from"crypto";function Mz($=Tz){let Z=_2.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return q5=Z,Z}function Iz(){if(!q5)Mz();return q5}function Rw(){q5=null}function Nw($){q5=$}function Dz($=B2){let Z=Iz();return`<input type="hidden" name="${$}" value="${Z}">`}function j2($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return Dz(X||B2)})}function Tw($,Z){let Y=Z??q5;if(!Y)return!1;let X=W2.from($),J=W2.from(Y);if(X.length!==J.length)return!1;return _2.timingSafeEqual(X,J)}var Tz=40,B2="_token",q5=null;var H2=()=>{};async function O2($,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 Ez(J,Q,Z,Y,X);else J=await kz(J,Q,Z,Y,X)}return J}async function Ez($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,q=`@end${Q}`,z=$,U=D1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${q}`,"g"),W=[],_=U.exec(z);while(_!==null){let[B,j="",H=""]=_,L=_.index||0;try{let F=j?L2(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}`,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 kz($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,q=D1(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),z=[],U=q.exec(K);while(U!==null){let[B,j=""]=U,H=U.index||0;try{let L=L2(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}`,p.EVALUATION_ERROR),startIndex:H})}U=q.exec(K)}let W=D1(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),_=W.exec(K);while(_!==null){let[B]=_,j=_.index||0;try{let H=await G("",[],Y,X);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}`,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 L2($){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 F2=C(()=>{Q1();a1()});var C3={};l(C3,{useTitle:()=>vz,useSeoMeta:()=>_4,usePageTitle:()=>vz,useHead:()=>g1,resetHead:()=>yz,renderHtmlAttrs:()=>fz,renderHead:()=>xz,renderBodyAttrs:()=>gz,processTitleDirective:()=>mz,processMetaDirective:()=>uz,processHeadDirective:()=>dz,getPageMeta:()=>Sz,getHead:()=>f5,definePageMeta:()=>Pz,applyHead:()=>hz});function f5(){return O1}function Sz(){return W4}function yz(){O1={},bz.length=0,W4={}}function g1($){O1=Cz(O1,$)}function Cz($,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 _4($){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});g1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function Pz($){if(W4={...W4,...$},$.title||$.description)_4({title:$.title,description:$.description})}function vz($){let Z=typeof $==="function"?$():$;g1({title:Z})}function xz($=O1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${f1(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${f1(J)}"`).join(" ");Z.push(`<base ${Y}>`)}for(let Y of $.meta||[]){let X=Object.entries(Y).filter(([J,Q])=>Q!==void 0).map(([J,Q])=>{return`${J==="httpEquiv"?"http-equiv":J}="${f1(String(Q))}"`}).join(" ");Z.push(`<meta ${X}>`)}for(let Y of $.link||[]){let X=Object.entries(Y).filter(([J,Q])=>Q!==void 0).map(([J,Q])=>`${J}="${f1(String(Q))}"`).join(" ");Z.push(`<link ${X}>`)}for(let Y of $.script||[]){let{content:X,...J}=Y,Q=Object.entries(J).filter(([G,K])=>K!==void 0).map(([G,K])=>{if(typeof K==="boolean")return K?G:"";return`${G}="${f1(String(K))}"`}).filter(Boolean).join(" ");if(X)Z.push(`<script ${Q}>${X}</script>`);else Z.push(`<script ${Q}></script>`)}for(let Y of $.style||[]){let X=Y.type?` type="${Y.type}"`:"";Z.push(`<style${X}>${Y.content}</style>`)}return Z.join(`
|
|
3774
3774
|
`)}function fz($=O1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${f1(Y)}"`).join(" ")}function gz($=O1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${f1(Y)}"`).join(" ")}function f1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function hz($=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 dz($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
|
|
3775
3775
|
`,""}),headContent:Z.trim()}}function mz($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return g1({title:G}),""})}function uz($,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 g1({meta:[W]}),""})}var O1,bz,W4;var g5=C(()=>{O1={},bz=[],W4={}});import lz from"crypto";function w0($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function pz($){return{...P3,...$.forms?.classes}}function B4($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function cz(){return lz.randomUUID()}function Sw($,Z,Y,X){let J=pz(X),Q=$;return Q=nz(Q,Z),Q=m5(Q,Z),Q=v3(Q,Z,J),Q=x3(Q,Z,J),Q}function m5($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=cz();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 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="${w0(j)}" action="${w0(W)}"${_?` ${_}`:""}>`;if(H+=`
|