rip-lang 3.17.2 → 3.17.3

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.
@@ -1863,15 +1863,15 @@ Expecting ${u.join(", ")}, got '${this.tokenNames[S]||S}'`;else return`Parse err
1863
1863
  `+Pl;break;case"server":case"migration":throw Error("schema runtime mode '"+n+"' is not available in the browser. ORM and DDL features require side-effect-importing loader-server.js.");default:throw Error(`unknown schema runtime mode: ${n}`)}return(Xl+f+bl).trimStart()}jl(lf);var ze=lf({mode:"browser"});if(typeof globalThis<"u"&&!globalThis.__ripSchema)try{(0,eval)(ze)}catch{}class Hn extends Error{constructor(n,{code:f=null,file:e=null,line:t=null,column:i=null,length:u=1,source:l=null,suggestion:a=null,phase:c=null}={}){super(n);this.name="RipError",this.code=f,this.file=e,this.line=t,this.column=i,this.length=u,this.source=l,this.suggestion=a,this.phase=c}static fromLexer(n,f,e){let t=n.location||{};return new Hn(n.message,{code:"E_SYNTAX",file:e,line:t.first_line??null,column:t.first_column??null,length:t.last_column!=null&&t.first_column!=null?t.last_column-t.first_column+1:1,source:f,phase:"lexer"})}static fromParser(n,f,e){let t=n.hash||{},i=t.loc||{},u=t.line??i.r??null,l=i.first_column??i.c??null,a=null;if(t.expected?.length){if(a=`Expected ${t.expected.slice(0,5).map((_)=>_.replace(/'/g,"")).join(", ")}`,t.expected.length>5)a+=`, ... (${t.expected.length} total)`}let c=t.token||"token",r=new Set((t.expected||[]).map((w)=>w.replace(/'/g,""))),h=new Set(["TERMINATOR",",",")","]","OUTDENT","CALL_END","INDEX_END","PARAM_END","EOF"]);if(r.has(":")&&(r.has("POST_IF")||r.has("POST_UNLESS")||r.has("FOR")||r.has("WHILE"))&&h.has(c))a="Binary `x ? y` was removed — use `x ?? y` for nullish coalescing, or a full ternary `x ? y : z`";let o=t.text?` near '${t.text}'`:"",s=`Unexpected ${c}${o}`;return new Hn(s,{code:"E_PARSE",file:e,line:u,column:l,length:t.text?.length||1,source:f,suggestion:a,phase:"parser"})}static fromSExpr(n,f,e,t,i){let u=f?.loc||{};return new Hn(n,{code:"E_CODEGEN",file:t,line:u.r??null,column:u.c??null,length:u.n??1,source:e,suggestion:i,phase:"codegen"})}get locationString(){let n=[];if(this.file)n.push(this.file);if(this.line!=null)n.push(`${this.line+1}:${(this.column??0)+1}`);return n.join(":")}format({color:n=!0}={}){let f=n?{red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",dim:"\x1B[2m",bold:"\x1B[1m",reset:"\x1B[0m"}:{red:"",yellow:"",cyan:"",dim:"",bold:"",reset:""},e=[],t=this.locationString,i=t?`${f.cyan}${t}${f.reset} `:"";e.push(`${i}${f.red}${f.bold}error${f.reset}${f.bold}: ${this.message}${f.reset}`);let u=this._snippet();if(u){e.push("");for(let l of u)if(l.type==="source")e.push(`${f.dim}${l.gutter}${f.reset}${l.text}`);else if(l.type==="caret")e.push(`${f.dim}${l.gutter}${f.reset}${f.red}${f.bold}${l.text}${f.reset}`)}if(this.suggestion)e.push(""),e.push(`${f.yellow}hint${f.reset}: ${this.suggestion}`);return e.join(`
1864
1864
  `)}formatHTML(){let n=[];n.push('<div class="rip-error">'),n.push("<style>"),n.push('.rip-error { font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace; font-size: 13px; line-height: 1.5; padding: 16px 20px; background: #1e1e2e; color: #cdd6f4; border-radius: 8px; overflow-x: auto; }'),n.push(".rip-error .re-header { color: #f38ba8; font-weight: 600; }"),n.push(".rip-error .re-loc { color: #89b4fa; }"),n.push(".rip-error .re-gutter { color: #585b70; user-select: none; }"),n.push(".rip-error .re-caret { color: #f38ba8; font-weight: 700; }"),n.push(".rip-error .re-hint { color: #f9e2af; }"),n.push(".rip-error .re-snippet { margin: 8px 0; }"),n.push("</style>");let f=this.locationString,e=f?`<span class="re-loc">${ui(f)}</span> `:"";n.push(`<div class="re-header">${e}error: ${ui(this.message)}</div>`);let t=this._snippet();if(t){n.push('<pre class="re-snippet">');for(let i of t)if(i.type==="source")n.push(`<span class="re-gutter">${ui(i.gutter)}</span>${ui(i.text)}`);else if(i.type==="caret")n.push(`<span class="re-gutter">${ui(i.gutter)}</span><span class="re-caret">${ui(i.text)}</span>`);n.push("</pre>")}if(this.suggestion)n.push(`<div class="re-hint">hint: ${ui(this.suggestion)}</div>`);return n.push("</div>"),n.join(`
1865
1865
  `)}_snippet(){if(this.source==null||this.line==null)return null;let n=this.source.split(`
1866
- `),f=this.line;if(f<0||f>=n.length)return null;let e=2,t=Math.max(0,f-e),i=Math.min(n.length-1,f+e),u=String(i+1).length,l=[];for(let a=t;a<=i;a++){let r=` ${String(a+1).padStart(u)} │ `;if(l.push({type:"source",gutter:r,text:n[a]}),a===f&&this.column!=null){let h=" ".repeat(this.column),o=Math.max(1,Math.min(this.length||1,n[a].length-this.column)),s="^".repeat(o),w=" ".repeat(u+2)+"│ ";l.push({type:"caret",gutter:w,text:`${h}${s}`})}}return l}}function He(n){return n instanceof SyntaxError&&n.location!=null}function Ke(n){return!(n instanceof SyntaxError)&&n.hash!=null}function hi(n,f,e){if(n instanceof Hn){if(e&&!n.file)n.file=e;if(f&&!n.source)n.source=f;return n}if(He(n))return Hn.fromLexer(n,f,e);if(Ke(n))return Hn.fromParser(n,f,e);return new Hn(n.message,{file:e,source:f,phase:"unknown"})}function ei(n,{source:f,file:e,color:t=!0}={}){return(n instanceof Hn?n:hi(n,f,e)).format({color:t})}function el(n,{source:f,file:e}={}){return(n instanceof Hn?n:hi(n,f,e)).formatHTML()}function ui(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function tf(n){let f=n.prototype;f.rewriteTypes=function(){let e=this.tokens,t=this.typeRefNames=new Set;Je(e);let i=(u,l,a)=>{let c=[u,l];if(c.pre=0,c.data=null,c.loc=a?.loc??{r:0,c:0,n:0},c.spaced=!1,c.newLine=!1,c.generated=!0,a)c.origin=a;return c};this.scanTokens((u,l,a)=>{let c=u[0];if(c==="IDENTIFIER"){let r=a[l+1];if(r&&r[0]==="COMPARE"&&r[1]==="<"&&!r.spaced){let h=a[l-1]?.[0]==="DEF",o=ef(a,l+1);if(o){let s=l+1+o.length,w=!h&&a[s]?.[0]==="="&&a[s+1]?.[0]==="COMPONENT";if(h||w){if(!u.data)u.data={};if(u.data.typeParams=Vn(o),a.splice(l+1,o.length),h&&a[l+1]?.[0]==="("){a[l+1][0]="CALL_START";let _=1,A=l+2;while(A<a.length&&_>0){if(a[A][0]==="("||a[A][0]==="CALL_START")_++;if(a[A][0]===")"||a[A][0]==="CALL_END")_--;if(_===0)a[A][0]="CALL_END";A++}}}}}}if(c==="TYPE_ANNOTATION"){let r=a[l-1];if(!r)return 1;let h=r[0]==="PARAM_END",o=uf(a,l+1,{stopAtFatArrow:h});if(h&&Qe(o)){let y=a[l+1]?.loc;throw new Hn("A function-type return on an arrow must be parenthesized",{code:"E_SYNTAX",phase:"lexer",line:y?.r??null,column:y?.c??null,length:y?.n??1,suggestion:"wrap the whole function type in parens — "+"`(x):: ((a: T) => R) => body`, not `(x):: (a: T) => R => body`"})}let s=Vn(o),w=r,_="type";if(r[0]==="CALL_END"||r[0]===")"){let y=1,R=l-2;while(R>=0&&y>0){let U=a[R][0];if(U==="CALL_END"||U===")")y++;if(U==="CALL_START"||U==="(")y--;R--}if(R>=0)w=a[R];_="returnType"}else if(r[0]==="PARAM_END"){let y=l+1+o.consumed,R=a[y];if(R&&(R[0]==="->"||R[0]==="=>"))w=R;_="returnType"}else if(r[0]==="IDENTIFIER"&&l>=2&&a[l-2]?.[0]==="DEF")_="returnType";if(!w.data)w.data={};w.data[_]=s;for(let y of o)if(y[0]==="IDENTIFIER")t.add(y[1]);let A=1+o.consumed;return a.splice(l,A),0}if(c==="IDENTIFIER"&&u[1]==="type"){let r=a[l-1]?.[0];if(!(!r||r==="TERMINATOR"||r==="INDENT"||r==="EXPORT"))return 1;let o=l+1,s=a[o];if(!s||s[0]!=="IDENTIFIER")return 1;let w=s[1],_=r==="EXPORT",A=_?l-1:l,y=o+1;if(a[y]?.[0]==="COMPARE"&&a[y]?.[1]==="<"&&!a[y].spaced){let q=ef(a,y);if(q){if(!s.data)s.data={};s.data.typeParams=Vn(q),a.splice(y,q.length)}}if(a[y]?.[0]!=="=")return 1;let R=(q)=>{let S=i("TYPE_DECL",w,s);if(S.data={name:w,typeText:q,exported:_},s.data?.typeParams)S.data.typeParams=s.data.typeParams;return S},U=y+1,m=a[U],D=(q,S)=>{for(let d=q;d<=S&&d<a.length;d++)if(a[d][0]==="IDENTIFIER")t.add(a[d][1])};if(m&&(m[0]==="TERMINATOR"||m[0]==="INDENT")){let q=Ye(a,U);if(q)return D(U,q.endIdx),a.splice(A,q.endIdx-A+1,R(q.typeText)),0}if(m&&m[0]==="INDENT"){let q=al(a,U);return D(U,q),a.splice(A,q-A+1,R(tl(a,U))),0}let M=uf(a,U);return D(U,U+M.consumed-1),a.splice(A,U+M.consumed-A,R(Vn(M))),0}if(c==="INTERFACE"){let r=l>=1&&a[l-1]?.[0]==="EXPORT",h=l+1,o=a[h];if(!o)return 1;let s=o[1],w=null,_=h+1;if(a[_]?.[0]==="EXTENDS")w=a[_+1]?.[1],_=_+2;if(a[_]?.[0]==="INDENT"){let A=tl(a,_),y=al(a,_);for(let D=_;D<=y&&D<a.length;D++)if(a[D][0]==="IDENTIFIER")t.add(a[D][1]);if(w)t.add(w);let R=i("TYPE_DECL",s,o);R.data={name:s,kind:"interface",extends:w,typeText:A,exported:r};let U=r?l-1:l,m=y-U+1;return a.splice(U,m,R),0}return 1}return 1});for(let u=e.length-1;u>=0;u--){if(e[u][0]!=="DEF")continue;let l=e[u+1];if(!l||l[0]!=="IDENTIFIER")continue;let a=u+2;if(e[a]?.[0]!=="CALL_START")continue;let c=1;a++;while(a<e.length&&c>0){if(e[a][0]==="CALL_START")c++;if(e[a][0]==="CALL_END")c--;a++}let r=a-1,h=e[a];if(h&&h[0]!=="TERMINATOR")continue;let o=l.data?.returnType;if(!o){for(let R=u+2;R<=r;R++)if(e[R].data?.type){o=!0;break}}if(!o)continue;let s=e.slice(u,a+1),w=u>=1&&e[u-1]?.[0]==="EXPORT",_=w?u-1:u,A=a+1-_,y=i("TYPE_DECL",l[1],l);if(y.data={name:l[1],kind:"overload",overloadTokens:s,exported:w},l.data?.typeParams)y.data.typeParams=l.data.typeParams;e.splice(_,A,y)}}}function Qe(n){let f=(l)=>l==="("||l==="PARAM_START"||l==="CALL_START",e=(l)=>l===")"||l==="PARAM_END"||l==="CALL_END";if(n.length<2||!f(n[0][0]))return!1;let t=0;for(let l=0;l<n.length;l++){let a=n[l][0];if(f(a))t++;else if(e(a)){if(--t===0&&l!==n.length-1)return!1}}if(t!==0)return!1;if(n.length===2)return!0;let i=0,u=!1;for(let l of n){let a=l[0];if(f(a)||a==="["||a==="{"||a==="INDEX_START")i++;else if(e(a)||a==="]"||a==="}"||a==="INDEX_END")i--;else if(i===1&&a==="TERNARY")u=!0;else if(i===1&&a===":")if(u)u=!1;else return!0}return!1}function ff(n,f,e){if(e<=f)return!1;let t=new Set(["|","&",",",":","?",".","..."]),i=0,u=0,l=0,a=0,c=!1,r=[],h=null;for(let o=f;o<e;o++){let s=n[o][0],w=n[o][1];if(s==="=>"){let _=o>f?n[o-1][0]:null;if((_===")"||_==="PARAM_END")&&h&&(h.colon||h.empty)){c=!1;continue}return!1}if(s==="("||s==="PARAM_START"){r.push({colon:!1,open:o}),i++,c=!1;continue}if(s===")"||s==="PARAM_END"){if(--i<0)return!1;let _=r.pop();h=_?{colon:_.colon,empty:o===_.open+1}:null,c=!0;continue}if(s==="["||s==="INDEX_START"){u++,c=!1;continue}if(s==="]"||s==="INDEX_END"){if(--u<0)return!1;c=!0;continue}if(s==="{"){l++,c=!1;continue}if(s==="}"){if(--l<0)return!1;c=!0;continue}if(s==="COMPARE"){if(w==="<"){a++,c=!1;continue}if(w===">"){if(a<=0)return!1;a--,c=!0;continue}return!1}if(s==="SHIFT"){if(w===">>"){if(a<2)return!1;a-=2,c=!0;continue}return!1}if(s==="="){if(a>0){c=!1;continue}return!1}if(t.has(s)){if(s===":"&&r.length)r[r.length-1].colon=!0;c=!1;continue}if(s==="IDENTIFIER"||s==="PROPERTY"||s==="NUMBER"||s==="STRING"||s==="NULL"||s==="UNDEFINED"||s==="BOOL"){if(c)return!1;c=!0;continue}return!1}return i===0&&u===0&&l===0&&a===0&&c}function We(n,f,e){let t=new Set(["=","REACTIVE_ASSIGN","COMPUTED_ASSIGN","READONLY_ASSIGN"]),i=0,u=0,l=0,a=[];for(let c=f;c<n.length;c++){let r=n[c][0];if(r==="INDENT"){i++;let h=n[c-1]?.[0];if(h==="->"||h==="=>")a.push(i),l++;continue}if(r==="OUTDENT"){if(i===0)return!1;if(a[a.length-1]===i)a.pop(),l--;i--;continue}if(r==="("||r==="CALL_START"||r==="PARAM_START"||r==="["||r==="INDEX_START"||r==="{"){u++;continue}if(r===")"||r==="CALL_END"||r==="PARAM_END"||r==="]"||r==="INDEX_END"||r==="}"){u--;continue}if(l===0&&u===0&&(r==="IDENTIFIER"||r==="PROPERTY")&&n[c][1]===e&&t.has(n[c+1]?.[0]))return!0}return!1}function Je(n){let f=(m)=>m==="("||m==="CALL_START"||m==="PARAM_START"||m==="{"||m==="["||m==="INDEX_START",e=(m)=>m===")"||m==="CALL_END"||m==="PARAM_END"||m==="}"||m==="]"||m==="INDEX_END",t=(m)=>{let D=m-1,M=n[D]?.[0],q=n[D]?.[1];if(M==="COMPARE"&&q===">"||M==="SHIFT"&&q===">>"){let S=M==="SHIFT"?2:1;D--;while(D>=0&&S>0){let d=n[D][0],K=n[D][1];if(d==="COMPARE"&&K===">")S++;else if(d==="SHIFT"&&K===">>")S+=2;else if(d==="COMPARE"&&K==="<")S--;else if(d==="SHIFT"&&K==="<<")S-=2;D--}}if(n[D]?.[0]!=="IDENTIFIER"&&n[D]?.[0]!=="PROPERTY")return!1;return n[D-1]?.[0]==="DEF"},i=new Set(["TERMINATOR","INDENT","OUTDENT","EXPORT"]),u=new Set(["=","REACTIVE_ASSIGN","COMPUTED_ASSIGN","READONLY_ASSIGN"]),l=(m)=>!m||i.has(m[0]),a=(m)=>{let D=0;for(let M=m;M<n.length;M++){let q=n[M][0];if(f(q))D++;else if(e(q))D--;else if(D===0){if(q==="->"||q==="=>")return!1;if(u.has(q))return!0;if((q==="EFFECT"||q==="GATE")&&M>m)return!0;if(q==="TERMINATOR"||q==="INDENT"||q==="OUTDENT")return!1}}return!1},c=(m)=>{let D=0;for(let M=m;M<n.length;M++){let q=n[M][0];if(f(q))D++;else if(e(q))D--;else if(D===0){if(q==="->"||q==="=>")return!0;if(q==="TERMINATOR"||q==="INDENT"||q==="OUTDENT")return!1}}return!1},r=!1,h=[],o=()=>h.length>0&&h[h.length-1],s=(m)=>{let D=n[m-1]?.[0];if(D!=="PROPERTY"&&D!=="IDENTIFIER")return!1;if(n[m-2]?.[0]==="@")return l(n[m-3]);return l(n[m-2])},w=!1,_=0,A=()=>{w=!0,_=U.length},y=!1,R=!1,U=[];for(let m=0;m<n.length;m++){let D=n[m][0];if(D==="CLASS"||D==="COMPONENT"){r=!0;continue}if(D==="INDENT"){if(h.push(r),r=!1,y=R=!1,w&&U.length<=_)w=!1;continue}if(D==="OUTDENT"){if(h.pop(),y=R=!1,w&&U.length<=_)w=!1;continue}if(f(D)){let q="other";if(!w){if(D==="PARAM_START")q="param";else if((D==="CALL_START"||D==="(")&&t(m))q="defparam"}U.push({kind:q,sawEq:!1,sawType:!1});continue}if(e(D)){if(U.pop()?.kind==="defparam")(n[m].data??={}).isDefParamEnd=!0;if(w&&U.length<_)w=!1;continue}if(D==="TYPE_ANNOTATION"){if(!w)A();continue}if(w)if(U.length<=_&&(D==="="||D===","||D==="TERMINATOR"||D==="->"||u.has(D)))w=!1;else continue;if(D==="TERMINATOR"&&U.length===0)y=R,R=!1;if(D===":"){let q=n[m-1],S=q?.[0];if(U.length===0&&(S==="IDENTIFIER"||S==="PROPERTY")&&l(n[m-2]))R=!0;if(S==="PARAM_END"||(S===")"||S==="CALL_END")&&q.data?.isDefParamEnd){n[m][0]="TYPE_ANNOTATION",A();continue}if((S==="IDENTIFIER"||S==="PROPERTY")&&n[m-2]?.[0]==="DEF"){if(S==="PROPERTY")q[0]="IDENTIFIER";n[m][0]="TYPE_ANNOTATION",A();continue}if(U.length===0&&s(m)&&a(m+1)){if(S==="PROPERTY"&&n[m-2]?.[0]!=="@")q[0]="IDENTIFIER";n[m][0]="TYPE_ANNOTATION",A();continue}if(U.length===0&&s(m)){let d=0;for(let K=m+1;K<n.length;K++){let E=n[K][0];if(f(E))d++;else if(e(E)){if(d===0)break;d--}else if(d===0){if(E==="TERMINATOR"||E==="INDENT"||E==="OUTDENT")break;if(E==="="&&ff(n,m+1,K)){if(S==="PROPERTY"&&n[m-2]?.[0]!=="@")q[0]="IDENTIFIER";n[m][0]="TYPE_ANNOTATION",A();break}}}if(n[m][0]==="TYPE_ANNOTATION")continue}if(o()&&U.length===0&&s(m)&&!c(m+1)){if(S==="PROPERTY"&&n[m-2]?.[0]!=="@")q[0]="IDENTIFIER";n[m][0]="TYPE_ANNOTATION",A();continue}if(U.length===0&&s(m)&&n[m-2]?.[0]!=="@"){let d=0,K=-1;for(let Q=m+1;Q<n.length;Q++){let W=n[Q][0];if(f(W))d++;else if(e(W)){if(d===0)break;d--}else if(d===0){if(W==="TERMINATOR"){K=Q;break}if(W==="INDENT"||W==="OUTDENT"||W==="="||u.has(W))break}}let E=n[K+1],Z=E&&(E[0]==="IDENTIFIER"||E[0]==="PROPERTY")&&n[K+2]?.[0]===":";if(K>m+1&&E&&E[0]!=="OUTDENT"&&!y&&!Z&&ff(n,m+1,K)&&We(n,K+1,q[1])){if(S==="PROPERTY")q[0]="IDENTIFIER";n[m][0]="TYPE_ANNOTATION",A();continue}}}let M=U[U.length-1];if(M&&(M.kind==="param"||M.kind==="defparam")){if(D===","){M.sawEq=!1,M.sawType=!1;continue}if(D==="="){M.sawEq=!0;continue}if(D===":"&&!M.sawEq&&!M.sawType){let q=n[m-1],S=q?.[0];if(S==="PROPERTY"||S==="IDENTIFIER"){if(S==="PROPERTY"&&n[m-2]?.[0]!=="@")q[0]="IDENTIFIER";n[m][0]="TYPE_ANNOTATION",M.sawType=!0,A()}else if(S==="}"||S==="]"||S==="INDEX_END")n[m][0]="TYPE_ANNOTATION",M.sawType=!0,A()}}}}function uf(n,f,e={}){let t=[],i=0,u=[],l=f;while(f<n.length){let a=n[f],c=a[0],r=c==="("||c==="["||c==="{"||c==="CALL_START"||c==="PARAM_START"||c==="INDEX_START"||c==="COMPARE"&&a[1]==="<",h=c===")"||c==="]"||c==="}"||c==="CALL_END"||c==="PARAM_END"||c==="INDEX_END"||c==="COMPARE"&&a[1]===">";if(c==="SHIFT"&&a[1]===">>"&&i>=2){if(i-=2,u[u.length-1]==="<")u.pop();if(u[u.length-1]==="<")u.pop();t.push(a),f++;continue}if(r){i++;let o=c==="{"?"{":c==="["||c==="INDEX_START"?"[":c==="COMPARE"&&a[1]==="<"?"<":"(";u.push(o),t.push(a),f++;continue}if(h){if(i>0){i--,u.pop(),t.push(a),f++;continue}break}if(i===0){if(e.stopAtFatArrow&&c==="=>")break;if(c==="INDENT"&&t.length>0&&t[t.length-1][0]==="=>"){f++;let o=1;while(f<n.length&&o>0)if(n[f][0]==="INDENT")o++,f++;else if(n[f][0]==="OUTDENT")o--,f++;else t.push(n[f]),f++;continue}if(c==="="||c==="REACTIVE_ASSIGN"||c==="COMPUTED_ASSIGN"||c==="READONLY_ASSIGN"||c==="EFFECT"||c==="GATE"||c==="TERMINATOR"||c==="INDENT"||c==="OUTDENT"||c==="->"||c===",")break}if(i>0&&(c==="INDENT"||c==="OUTDENT")){f++;continue}if(i>0&&c==="TERMINATOR"){t.push(["",";"]),f++;continue}if(c==="PROPERTY"&&u[u.length-1]==="{"){let o=t[t.length-1],s=o?.[0],w=o?.[1];if(o&&s!=="{"&&s!==","&&!(s===""&&w===";"))t.push(["",";"])}t.push(a),f++}return t.consumed=f-l,t}function Vn(n){if(n.length===0)return"";if(n[0]?.[0]==="=>")n.unshift(["","()"]);{let t=0;for(let i of n){let u=i[0];if(u==="{")t++;else if(u==="}")t--;else if(u==="TYPE_ANNOTATION"&&t>0){let l=i.loc,a=l?` (line ${l.r}, col ${l.c})`:"",c=Error(`Use \`:\` (not \`::\`) inside a structural type literal${a}. \`::\` binds a name to a type; inside \`{ ... }\` in type position, fields use \`:\` (TS-style).`);throw c.loc=l,c}}}let e=n.map((t,i)=>{let u=n[i+1];if(t.data?.optional&&u&&(u[0]==="TYPE_ANNOTATION"||u[0]===":"))return`${t[1]}?`;if(t[0]==="JS")return"`"+t[1]+"`";return t[1]}).join(" ").replace(/\s+/g," ").trim();return e=e.replace(/\s*<\s*/g,"<").replace(/\s*>\s*/g,">").replace(/\s*\[\s*/g,"[").replace(/\s*\]\s*/g,"]").replace(/\s*\(\s*/g,"(").replace(/\s*\)\s*/g,")").replace(/\s*,\s*/g,", ").replace(/\s*=>\s*/g," => ").replace(/ :: /g,": ").replace(/:: /g,": ").replace(/ : /g,": "),e}function ef(n,f){if(f>=n.length)return null;let e=n[f];if(e[0]!=="COMPARE"||e[1]!=="<")return null;let t=[e],i=1,u=f+1;while(u<n.length&&i>0){let l=n[u];if(t.push(l),l[0]==="COMPARE"&&l[1]==="<")i++;else if(l[0]==="COMPARE"&&l[1]===">")i--;u++}return i===0?t:null}function tl(n,f){let e=[],t=f+1,i=1;while(t<n.length&&i>0){let u=n[t];if(u[0]==="INDENT"){i++,t++;continue}if(u[0]==="OUTDENT"){if(i--,i===0)break;t++;continue}if(u[0]==="TERMINATOR"){t++;continue}if(i===1&&u[0]==="["){let a=[];t++;while(t<n.length&&n[t][0]!=="]")a.push(n[t]),t++;if(t++,n[t]?.[1]===":"||n[t]?.[0]==="TYPE_ANNOTATION")t++;let c=[];while(t<n.length){let o=n[t];if(o[0]==="TERMINATOR"||o[0]==="OUTDENT")break;c.push(o),t++}let r=Vn(a),h=Vn(c);e.push(`[${r}]: ${h}`);continue}let l=u[0]==="PROPERTY"||u[0]==="IDENTIFIER"||i===1&&/^[a-zA-Z_$]/.test(u[1])&&n[t+1]?.[0]==="TYPE_ANNOTATION";if(i===1&&l){let a=u[1],c=!1,r=!1;if(t++,a==="readonly"&&n[t]&&(n[t][0]==="PROPERTY"||n[t][0]==="IDENTIFIER"||/^[a-zA-Z_$]/.test(n[t][1])&&n[t+1]?.[0]==="TYPE_ANNOTATION")){if(r=!0,a=n[t][1],n[t].data?.optional)c=!0;t++}if(u.data?.optional)c=!0;if(n[t]?.[1]==="?"&&!n[t]?.spaced)c=!0,t++;if(n[t]?.[1]===":"||n[t]?.[0]==="TYPE_ANNOTATION")t++;let h=[],o=0;while(t<n.length){let y=n[t];if(y[0]==="IDENTIFIER"&&y[1]==="type"&&n[t+1]?.[0]==="INDENT"){t++;let R=tl(n,t);h.push(["",R]);let U=1;t++;while(t<n.length&&U>0){if(n[t][0]==="INDENT")U++;if(n[t][0]==="OUTDENT")U--;t++}continue}if(y[0]==="INDENT"){o++,t++;continue}if(y[0]==="OUTDENT"){if(o>0){o--,t++;continue}break}if(y[0]==="TERMINATOR"&&o===0)break;h.push(y),t++}let s=Vn(h),w=r?"readonly ":"",_=c?"?":"",A=!1;if(!c&&s.startsWith("(")){let y=0;for(let R=0;R<s.length;R++){let U=s[R];if(U==="(")y++;else if(U===")"){if(y--,y===0){let m=s.slice(R+1).trimStart();if(m===""||m.startsWith(":")&&!m.startsWith("::"))A=!0;break}}}}if(A)e.push(`${w}${a}${s}`);else e.push(`${w}${a}${_}: ${s}`)}else t++}return"{ "+e.join("; ")+" }"}function al(n,f){let e=0;for(let t=f;t<n.length;t++){if(n[t][0]==="INDENT")e++;if(n[t][0]==="OUTDENT"){if(e--,e===0)return t}}return n.length-1}function Ye(n,f){let e=f;if(n[e]?.[0]==="TERMINATOR")e++;if(n[e]?.[0]!=="INDENT")return null;let t=e;e++;while(e<n.length&&n[e][0]==="TERMINATOR")e++;if(!n[e]||n[e][1]!=="|")return null;let i=[],u=1;e=t+1;while(e<n.length&&u>0){let a=n[e];if(a[0]==="INDENT"){u++,e++;continue}if(a[0]==="OUTDENT"){if(u--,u===0)break;e++;continue}if(a[0]==="TERMINATOR"){e++;continue}if(a[1]==="|"&&u===1){e++;let c=[];while(e<n.length){let r=n[e];if(r[0]==="TERMINATOR"||r[0]==="OUTDENT"||r[1]==="|"&&u===1)break;c.push(r),e++}if(c.length>0)i.push(Vn(c));continue}e++}if(i.length===0)return null;let l=al(n,t);return{typeText:i.join(" | "),endIdx:l}}var af=new Set(["true","false","null","this","new","delete","typeof","in","instanceof","return","throw","break","continue","debugger","yield","await","if","else","switch","for","while","do","try","catch","finally","class","extends","super","import","export","default"]),rf=new Set(["undefined","Infinity","NaN","then","unless","until","loop","of","by","when","def","component","render","enum","interface"]),cl={and:"&&",or:"||",is:"==",isnt:"!=",not:"!",yes:"true",no:"false",on:"true",off:"false"},cf=new Set(Object.keys(cl)),Ze=new Set(["case","function","var","void","with","const","let","native","implements","package","private","protected","public","static"]),Ge=new Set(["break","continue","debugger"]),Ne=new Set(["NEW","TYPEOF","DELETE"]),Xe=new Set(["IN","OF","INSTANCEOF"]),Xi=new Set(["IDENTIFIER","PROPERTY",")","]","@","THIS","SUPER","DYNAMIC_IMPORT","?."]),bi=new Set([...Xi,"NUMBER","INFINITY","NAN","STRING","STRING_END","REGEX","REGEX_END","BOOL","NULL","UNDEFINED","}","MAP_END","SYMBOL"]),Gi=new Set(["IDENTIFIER","PROPERTY","NUMBER","INFINITY","NAN","STRING","STRING_START","REGEX","REGEX_START","JS","NEW","PARAM_START","CLASS","IF","TRY","SWITCH","THIS","DYNAMIC_IMPORT","IMPORT_META","NEW_TARGET","UNDEFINED","NULL","BOOL","UNARY","DO","DO_IIFE","YIELD","AWAIT","UNARY_MATH","SUPER","THROW","@","->","=>","[","(","{","MAP_START","--","++","SYMBOL"]),be=new Set(["+","-"]),Pe=new Set(["POST_IF","POST_UNLESS","FOR","WHILE","UNTIL","WHEN","BY","LOOP","TERMINATOR","||","&&","??"]),Oe=new Set(["STRING","STRING_END","REGEX","REGEX_END","NUMBER","BOOL","NULL","UNDEFINED","INFINITY","NAN","]","}","MAP_END","SYMBOL"]),jn=new Set(["(","[","{","MAP_START","PICK_START","OPTPICK_START","INDENT","CALL_START","PARAM_START","INDEX_START","STRING_START","INTERPOLATION_START","REGEX_START"]),Cn=new Set([")","]","}","MAP_END","PICK_END","OUTDENT","CALL_END","PARAM_END","INDEX_END","STRING_END","INTERPOLATION_END","REGEX_END"]),Be={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{",INDENT:"OUTDENT",OUTDENT:"INDENT",CALL_START:"CALL_END",CALL_END:"CALL_START",PARAM_START:"PARAM_END",PARAM_END:"PARAM_START",INDEX_START:"INDEX_END",INDEX_END:"INDEX_START",STRING_START:"STRING_END",STRING_END:"STRING_START",INTERPOLATION_START:"INTERPOLATION_END",INTERPOLATION_END:"INTERPOLATION_START",REGEX_START:"REGEX_END",REGEX_END:"REGEX_START",MAP_START:"MAP_END",MAP_END:"MAP_START",PICK_START:"PICK_END",PICK_END:"PICK_START",OPTPICK_START:"PICK_END"},hf=new Set(["CATCH","THEN","ELSE","FINALLY",...Cn]),rl=new Set(["IDENTIFIER","PROPERTY","SUPER",")","CALL_END","]","INDEX_END","@","THIS"]),Ie=new Set(["IDENTIFIER","PROPERTY",")","CALL_END","]","INDEX_END"]),ge=new Set(["IF","TRY","FINALLY","CATCH","CLASS","SWITCH","COMPONENT","FOR"]),Ce=new Set(["IDENTIFIER","PROPERTY","NUMBER","STRING","STRING_END","REGEX","REGEX_END",")","CALL_END","]","INDEX_END","}","MAP_END","PICK_END","BOOL","NULL","UNDEFINED","INFINITY","NAN","SUPER","THIS","@","SYMBOL"]),sf=new Set(["ELSE","->","=>","TRY","FINALLY","THEN"]),ve=new Set(["TERMINATOR","CATCH","FINALLY","ELSE","OUTDENT","LEADING_WHEN"]),si=new Set(["INDENT","OUTDENT","TERMINATOR"]),ti=(n)=>n?.[0]==="IDENTIFIER"||n?.[0]==="PROPERTY",Ni=(n,f)=>{if(n?.[0]===".")return!0;if(n?.[0]==="-")return n.spaced===!1&&!n.newLine&&f?.spaced===!1&&!f?.newLine;return!1},of=new Set([".","?."]),wf=new Set(["\\",".","?.","UNARY","DO","DO_IIFE","MATH","UNARY_MATH","+","-","**","SHIFT","RELATION","COMPARE","&","^","|","&&","||","TERNARY","EXTENDS"]),Te=new Set([...bi,"++","--"]),_f=new Set(["-=","+=","/=","*=","%=","||=","&&=","?=","??=","<<=",">>=",">>>=","&=","^=","|=","**=","//=","%%="]),Ve=new Set(["*","/","%","//","%%"]),je=new Set(["==","!=","===","!==","<",">","<=",">=","=~"]),Le=new Set(["<<",">>",">>>"]),pe=new Set(["!","~"]),xe=/^(?!\d)((?:(?!\s)[$\w\x7f-\uffff])+(?:!|[?](?![.?![(]))?)([^\n\S]*:(?![=:]))?/,$e=/^0b[01](?:_?[01])*n?|^0o[0-7](?:_?[0-7])*n?|^0x[\da-f](?:_?[\da-f])*n?|^\d+(?:_\d+)*n|^(?:\d+(?:_\d+)*)?\.?\d+(?:_\d+)*(?:e[+-]?\d+(?:_\d+)*)?/i,ke=/^(?:<=>|<~|::|\*>|[-=]>|~>|~=|:=|=!|===|!==|\?\!|\?\?|=~|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>*\/%])\2=?|\?\.?|\.{2,3})/,nt=/^[^\n\S]+/,it=/^(?:\n[^\n\S]*)+/,lt=/^(\s*)###([^#][\s\S]*?)(?:###([^\n\S]*)|###$)|^((?:\s*#(?!##[^#]).*)+)/,ft=/^[-=]>/,ut=/^(?:~[=>]|=!)/,et=/^(?:'''\\|"""\\|'''|"""|'|")/,tt=/^(?:[^\\']|\\[\s\S])*/,at=/^(?:[^\\"#$]|\\[\s\S]|\#(?!\{)|\$(?!\{))*/,rt=/^(?:[^\\']|\\[\s\S]|'(?!''))*/,ct=/^(?:[^\\"#$]|\\[\s\S]|"(?!"")|\#(?!\{)|\$(?!\{))*/,mf=/\n+([^\n\S]*)(?=\S)/g,ht=/^\/(?!\/)((?:[^[\/\n\\]|\\[^\n]|\[(?:\\[^\n]|[^\]\n\\])*\])*)(\/)?/,yf=/^\w*/,st=/^(?!.*(.).*\1)[gimsuy]*$/,ot=/^(?:[^\\\/#\s]|\\[\s\S]|\/(?!\/\/)|\#(?!\{)|\s+(?:#(?!\{).*)?)*/,wt=/^`(?!``)((?:[^`\\]|\\[\s\S])*)`/,_t=/^```((?:[^`\\]|\\[\s\S]|`(?!``))*)```/,mt=/\s+$/,Af=/^\s*(?:,|\??\.(?![.\d]))/,yt=65279;function Pi(n,f,{pre:e=0,row:t=0,col:i=0,len:u=0,data:l=null}={}){let a=[n,f];return a.pre=e,a.data=l,a.loc={r:t,c:i,n:u},a.spaced=e>0,a.newLine=!1,a}function On(n,f,e){let t=Pi(n,f);if(t.generated=!0,e)t.origin=e;return t}function Bn(n,{row:f=0,col:e=0,len:t=1}={}){let i=SyntaxError(n);throw i.location={first_line:f,first_column:e,last_column:e+t-1},i}function At(n){if(n==null)return NaN;switch(n.charAt(1)){case"b":return parseInt(n.slice(2).replace(/_/g,""),2);case"o":return parseInt(n.slice(2).replace(/_/g,""),8);case"x":return parseInt(n.slice(2).replace(/_/g,""),16);default:return parseFloat(n.replace(/_/g,""))}}class vn{tokenize(n,f={}){this.code=n,this.tokens=[],this.ends=[],this.chunk="",this.pos=0,this.row=f.row||0,this.col=f.col||0,this.indent=0,this.indents=[],this.seenFor=!1,this.seenImport=!1,this.seenExport=!1,this.importSpecifierList=!1,this.exportSpecifierList=!1,this.inRenderBlock=!1,this.renderIndent=0,this.inTypeAnnotation=!1,n=this.clean(n),this.code=n;while(this.pos<n.length){this.chunk=n.slice(this.pos);let e=this.identifierToken()||this.commentToken()||this.whitespaceToken()||this.lineToken()||this.stringToken()||this.numberToken()||this.regexToken()||this.jsToken()||this.literalToken();if(e===0)Bn(`unexpected character: ${this.chunk.charAt(0)}`,{row:this.row,col:this.col});if(this.advance(e),f.untilBalanced&&this.ends.length===0)return{tokens:this.tokens,index:this.pos}}if(this.closeIndentation(),this.ends.length>0){let e=this.ends[this.ends.length-1];Bn(`missing ${e.tag}`,{row:this.row,col:this.col})}if(f.rewrite===!1)return this.tokens;return this.rewrite(this.tokens)}clean(n){if(n.charCodeAt(0)===yt)n=n.slice(1);if(n=n.replace(/\r\n?/g,`
1866
+ `),f=this.line;if(f<0||f>=n.length)return null;let e=2,t=Math.max(0,f-e),i=Math.min(n.length-1,f+e),u=String(i+1).length,l=[];for(let a=t;a<=i;a++){let r=` ${String(a+1).padStart(u)} │ `;if(l.push({type:"source",gutter:r,text:n[a]}),a===f&&this.column!=null){let h=" ".repeat(this.column),o=Math.max(1,Math.min(this.length||1,n[a].length-this.column)),s="^".repeat(o),w=" ".repeat(u+2)+"│ ";l.push({type:"caret",gutter:w,text:`${h}${s}`})}}return l}}function He(n){return n instanceof SyntaxError&&n.location!=null}function Ke(n){return!(n instanceof SyntaxError)&&n.hash!=null}function hi(n,f,e){if(n instanceof Hn){if(e&&!n.file)n.file=e;if(f&&!n.source)n.source=f;return n}if(He(n))return Hn.fromLexer(n,f,e);if(Ke(n))return Hn.fromParser(n,f,e);return new Hn(n.message,{file:e,source:f,phase:"unknown"})}function ei(n,{source:f,file:e,color:t=!0}={}){return(n instanceof Hn?n:hi(n,f,e)).format({color:t})}function el(n,{source:f,file:e}={}){return(n instanceof Hn?n:hi(n,f,e)).formatHTML()}function ui(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function tf(n){let f=n.prototype;f.rewriteTypes=function(){let e=this.tokens,t=this.typeRefNames=new Set;Je(e);let i=(u,l,a)=>{let c=[u,l];if(c.pre=0,c.data=null,c.loc=a?.loc??{r:0,c:0,n:0},c.spaced=!1,c.newLine=!1,c.generated=!0,a)c.origin=a;return c};this.scanTokens((u,l,a)=>{let c=u[0];if(c==="IDENTIFIER"){let r=a[l+1];if(r&&r[0]==="COMPARE"&&r[1]==="<"&&!r.spaced){let h=a[l-1]?.[0]==="DEF",o=ef(a,l+1);if(o){let s=l+1+o.length,w=!h&&a[s]?.[0]==="="&&a[s+1]?.[0]==="COMPONENT";if(h||w){if(!u.data)u.data={};if(u.data.typeParams=Vn(o),a.splice(l+1,o.length),h&&a[l+1]?.[0]==="("){a[l+1][0]="CALL_START";let _=1,A=l+2;while(A<a.length&&_>0){if(a[A][0]==="("||a[A][0]==="CALL_START")_++;if(a[A][0]===")"||a[A][0]==="CALL_END")_--;if(_===0)a[A][0]="CALL_END";A++}}}}}}if(c==="TYPE_ANNOTATION"){let r=a[l-1];if(!r)return 1;let h=r[0]==="PARAM_END",o=uf(a,l+1,{stopAtFatArrow:h});if(h&&Qe(o)){let y=a[l+1]?.loc;throw new Hn("A function-type return on an arrow must be parenthesized",{code:"E_SYNTAX",phase:"lexer",line:y?.r??null,column:y?.c??null,length:y?.n??1,suggestion:"wrap the whole function type in parens — "+"`(x):: ((a: T) => R) => body`, not `(x):: (a: T) => R => body`"})}let s=Vn(o),w=r,_="type";if(r[0]==="CALL_END"||r[0]===")"){let y=1,R=l-2;while(R>=0&&y>0){let U=a[R][0];if(U==="CALL_END"||U===")")y++;if(U==="CALL_START"||U==="(")y--;R--}if(R>=0)w=a[R];_="returnType"}else if(r[0]==="PARAM_END"){let y=l+1+o.consumed,R=a[y];if(R&&(R[0]==="->"||R[0]==="=>"))w=R;_="returnType"}else if(r[0]==="IDENTIFIER"&&l>=2&&a[l-2]?.[0]==="DEF")_="returnType";if(!w.data)w.data={};w.data[_]=s;for(let y of o)if(y[0]==="IDENTIFIER")t.add(y[1]);let A=1+o.consumed;return a.splice(l,A),0}if(c==="IDENTIFIER"&&u[1]==="type"){let r=a[l-1]?.[0];if(!(!r||r==="TERMINATOR"||r==="INDENT"||r==="EXPORT"))return 1;let o=l+1,s=a[o];if(!s||s[0]!=="IDENTIFIER")return 1;let w=s[1],_=r==="EXPORT",A=_?l-1:l,y=o+1;if(a[y]?.[0]==="COMPARE"&&a[y]?.[1]==="<"&&!a[y].spaced){let q=ef(a,y);if(q){if(!s.data)s.data={};s.data.typeParams=Vn(q),a.splice(y,q.length)}}if(a[y]?.[0]!=="=")return 1;let R=(q)=>{let S=i("TYPE_DECL",w,s);if(S.data={name:w,typeText:q,exported:_},s.data?.typeParams)S.data.typeParams=s.data.typeParams;return S},U=y+1,m=a[U],D=(q,S)=>{for(let d=q;d<=S&&d<a.length;d++)if(a[d][0]==="IDENTIFIER")t.add(a[d][1])};if(m&&(m[0]==="TERMINATOR"||m[0]==="INDENT")){let q=Ye(a,U);if(q)return D(U,q.endIdx),a.splice(A,q.endIdx-A+1,R(q.typeText)),0}if(m&&m[0]==="INDENT"){let q=al(a,U);return D(U,q),a.splice(A,q-A+1,R(tl(a,U))),0}let M=uf(a,U);return D(U,U+M.consumed-1),a.splice(A,U+M.consumed-A,R(Vn(M))),0}if(c==="INTERFACE"){let r=l>=1&&a[l-1]?.[0]==="EXPORT",h=l+1,o=a[h];if(!o)return 1;let s=o[1],w=null,_=h+1;if(a[_]?.[0]==="EXTENDS")w=a[_+1]?.[1],_=_+2;if(a[_]?.[0]==="INDENT"){let A=tl(a,_),y=al(a,_);for(let D=_;D<=y&&D<a.length;D++)if(a[D][0]==="IDENTIFIER")t.add(a[D][1]);if(w)t.add(w);let R=i("TYPE_DECL",s,o);R.data={name:s,kind:"interface",extends:w,typeText:A,exported:r};let U=r?l-1:l,m=y-U+1;return a.splice(U,m,R),0}return 1}return 1});for(let u=e.length-1;u>=0;u--){if(e[u][0]!=="DEF")continue;let l=e[u+1];if(!l||l[0]!=="IDENTIFIER")continue;let a=u+2;if(e[a]?.[0]!=="CALL_START")continue;let c=1;a++;while(a<e.length&&c>0){if(e[a][0]==="CALL_START")c++;if(e[a][0]==="CALL_END")c--;a++}let r=a-1,h=e[a];if(h&&h[0]!=="TERMINATOR")continue;let o=l.data?.returnType;if(!o){for(let R=u+2;R<=r;R++)if(e[R].data?.type){o=!0;break}}if(!o)continue;let s=e.slice(u,a+1),w=u>=1&&e[u-1]?.[0]==="EXPORT",_=w?u-1:u,A=a+1-_,y=i("TYPE_DECL",l[1],l);if(y.data={name:l[1],kind:"overload",overloadTokens:s,exported:w},l.data?.typeParams)y.data.typeParams=l.data.typeParams;e.splice(_,A,y)}}}function Qe(n){let f=(l)=>l==="("||l==="PARAM_START"||l==="CALL_START",e=(l)=>l===")"||l==="PARAM_END"||l==="CALL_END";if(n.length<2||!f(n[0][0]))return!1;let t=0;for(let l=0;l<n.length;l++){let a=n[l][0];if(f(a))t++;else if(e(a)){if(--t===0&&l!==n.length-1)return!1}}if(t!==0)return!1;if(n.length===2)return!0;let i=0,u=!1;for(let l of n){let a=l[0];if(f(a)||a==="["||a==="{"||a==="INDEX_START")i++;else if(e(a)||a==="]"||a==="}"||a==="INDEX_END")i--;else if(i===1&&a==="TERNARY")u=!0;else if(i===1&&a===":")if(u)u=!1;else return!0}return!1}function ff(n,f,e){if(e<=f)return!1;let t=new Set(["|","&",",",":","?",".","..."]),i=0,u=0,l=0,a=0,c=!1,r=[],h=null;for(let o=f;o<e;o++){let s=n[o][0],w=n[o][1];if(s==="=>"){let _=o>f?n[o-1][0]:null;if((_===")"||_==="PARAM_END")&&h&&(h.colon||h.empty)){c=!1;continue}return!1}if(s==="("||s==="PARAM_START"){r.push({colon:!1,open:o}),i++,c=!1;continue}if(s===")"||s==="PARAM_END"){if(--i<0)return!1;let _=r.pop();h=_?{colon:_.colon,empty:o===_.open+1}:null,c=!0;continue}if(s==="["||s==="INDEX_START"){u++,c=!1;continue}if(s==="]"||s==="INDEX_END"){if(--u<0)return!1;c=!0;continue}if(s==="{"){l++,c=!1;continue}if(s==="}"){if(--l<0)return!1;c=!0;continue}if(s==="COMPARE"){if(w==="<"){a++,c=!1;continue}if(w===">"){if(a<=0)return!1;a--,c=!0;continue}return!1}if(s==="SHIFT"){if(w===">>"){if(a<2)return!1;a-=2,c=!0;continue}return!1}if(s==="="){if(a>0){c=!1;continue}return!1}if(t.has(s)){if(s===":"&&r.length)r[r.length-1].colon=!0;c=!1;continue}if(s==="IDENTIFIER"||s==="PROPERTY"||s==="NUMBER"||s==="STRING"||s==="NULL"||s==="UNDEFINED"||s==="BOOL"){if(c)return!1;c=!0;continue}return!1}return i===0&&u===0&&l===0&&a===0&&c}function We(n,f,e){let t=new Set(["=","REACTIVE_ASSIGN","COMPUTED_ASSIGN","READONLY_ASSIGN"]),i=0,u=0,l=0,a=[];for(let c=f;c<n.length;c++){let r=n[c][0];if(r==="INDENT"){i++;let h=n[c-1]?.[0];if(h==="->"||h==="=>")a.push(i),l++;continue}if(r==="OUTDENT"){if(i===0)return!1;if(a[a.length-1]===i)a.pop(),l--;i--;continue}if(r==="("||r==="CALL_START"||r==="PARAM_START"||r==="["||r==="INDEX_START"||r==="{"){u++;continue}if(r===")"||r==="CALL_END"||r==="PARAM_END"||r==="]"||r==="INDEX_END"||r==="}"){u--;continue}if(l===0&&u===0&&(r==="IDENTIFIER"||r==="PROPERTY")&&n[c][1]===e&&t.has(n[c+1]?.[0]))return!0}return!1}function Je(n){let f=(m)=>m==="("||m==="CALL_START"||m==="PARAM_START"||m==="{"||m==="["||m==="INDEX_START",e=(m)=>m===")"||m==="CALL_END"||m==="PARAM_END"||m==="}"||m==="]"||m==="INDEX_END",t=(m)=>{let D=m-1,M=n[D]?.[0],q=n[D]?.[1];if(M==="COMPARE"&&q===">"||M==="SHIFT"&&q===">>"){let S=M==="SHIFT"?2:1;D--;while(D>=0&&S>0){let d=n[D][0],K=n[D][1];if(d==="COMPARE"&&K===">")S++;else if(d==="SHIFT"&&K===">>")S+=2;else if(d==="COMPARE"&&K==="<")S--;else if(d==="SHIFT"&&K==="<<")S-=2;D--}}if(n[D]?.[0]!=="IDENTIFIER"&&n[D]?.[0]!=="PROPERTY")return!1;return n[D-1]?.[0]==="DEF"},i=new Set(["TERMINATOR","INDENT","OUTDENT","EXPORT"]),u=new Set(["=","REACTIVE_ASSIGN","COMPUTED_ASSIGN","READONLY_ASSIGN"]),l=(m)=>!m||i.has(m[0]),a=(m)=>{let D=0;for(let M=m;M<n.length;M++){let q=n[M][0];if(f(q))D++;else if(e(q))D--;else if(D===0){if(q==="->"||q==="=>")return!1;if(u.has(q))return!0;if((q==="EFFECT"||q==="GATE")&&M>m)return!0;if(q==="TERMINATOR"||q==="INDENT"||q==="OUTDENT")return!1}}return!1},c=(m)=>{let D=0;for(let M=m;M<n.length;M++){let q=n[M][0];if(f(q))D++;else if(e(q))D--;else if(D===0){if(q==="->"||q==="=>")return!0;if(q==="TERMINATOR"||q==="INDENT"||q==="OUTDENT")return!1}}return!1},r=!1,h=[],o=()=>h.length>0&&h[h.length-1],s=(m)=>{let D=n[m-1]?.[0];if(D!=="PROPERTY"&&D!=="IDENTIFIER")return!1;if(n[m-2]?.[0]==="@")return l(n[m-3]);return l(n[m-2])},w=!1,_=0,A=()=>{w=!0,_=U.length},y=!1,R=!1,U=[];for(let m=0;m<n.length;m++){let D=n[m][0];if(D==="CLASS"||D==="COMPONENT"){r=!0;continue}if(D==="INDENT"){if(h.push(r),r=!1,y=R=!1,w&&U.length<=_)w=!1;continue}if(D==="OUTDENT"){if(h.pop(),y=R=!1,w&&U.length<=_)w=!1;continue}if(f(D)){let q="other";if(!w){if(D==="PARAM_START")q="param";else if((D==="CALL_START"||D==="(")&&t(m))q="defparam"}U.push({kind:q,sawEq:!1,sawType:!1});continue}if(e(D)){if(U.pop()?.kind==="defparam")(n[m].data??={}).isDefParamEnd=!0;if(w&&U.length<_)w=!1;continue}if(D==="TYPE_ANNOTATION"){if(!w)A();continue}if(w)if(U.length<=_&&(D==="="||D===","||D==="TERMINATOR"||D==="->"||u.has(D)))w=!1;else continue;if(D==="TERMINATOR"&&U.length===0)y=R,R=!1;if(D===":"){let q=n[m-1],S=q?.[0];if(U.length===0&&(S==="IDENTIFIER"||S==="PROPERTY")&&l(n[m-2]))R=!0;if(S==="PARAM_END"||(S===")"||S==="CALL_END")&&q.data?.isDefParamEnd){n[m][0]="TYPE_ANNOTATION",A();continue}if((S==="IDENTIFIER"||S==="PROPERTY")&&n[m-2]?.[0]==="DEF"){if(S==="PROPERTY")q[0]="IDENTIFIER";n[m][0]="TYPE_ANNOTATION",A();continue}if(U.length===0&&s(m)&&a(m+1)){if(S==="PROPERTY"&&n[m-2]?.[0]!=="@")q[0]="IDENTIFIER";n[m][0]="TYPE_ANNOTATION",A();continue}if(U.length===0&&s(m)){let d=0;for(let K=m+1;K<n.length;K++){let E=n[K][0];if(f(E))d++;else if(e(E)){if(d===0)break;d--}else if(d===0){if(E==="TERMINATOR"||E==="INDENT"||E==="OUTDENT")break;if(E==="="&&ff(n,m+1,K)){if(S==="PROPERTY"&&n[m-2]?.[0]!=="@")q[0]="IDENTIFIER";n[m][0]="TYPE_ANNOTATION",A();break}}}if(n[m][0]==="TYPE_ANNOTATION")continue}if(o()&&U.length===0&&s(m)&&!c(m+1)){if(S==="PROPERTY"&&n[m-2]?.[0]!=="@")q[0]="IDENTIFIER";n[m][0]="TYPE_ANNOTATION",A();continue}if(U.length===0&&s(m)&&n[m-2]?.[0]!=="@"){let d=0,K=-1;for(let Q=m+1;Q<n.length;Q++){let W=n[Q][0];if(f(W))d++;else if(e(W)){if(d===0)break;d--}else if(d===0){if(W==="TERMINATOR"){K=Q;break}if(W==="INDENT"||W==="OUTDENT"||W==="="||u.has(W))break}}let E=n[K+1],Z=E&&(E[0]==="IDENTIFIER"||E[0]==="PROPERTY")&&n[K+2]?.[0]===":";if(K>m+1&&E&&E[0]!=="OUTDENT"&&!y&&!Z&&ff(n,m+1,K)&&We(n,K+1,q[1])){if(S==="PROPERTY")q[0]="IDENTIFIER";n[m][0]="TYPE_ANNOTATION",A();continue}}}let M=U[U.length-1];if(M&&(M.kind==="param"||M.kind==="defparam")){if(D===","){M.sawEq=!1,M.sawType=!1;continue}if(D==="="){M.sawEq=!0;continue}if(D===":"&&!M.sawEq&&!M.sawType){let q=n[m-1],S=q?.[0];if(S==="PROPERTY"||S==="IDENTIFIER"){if(S==="PROPERTY"&&n[m-2]?.[0]!=="@")q[0]="IDENTIFIER";n[m][0]="TYPE_ANNOTATION",M.sawType=!0,A()}else if(S==="}"||S==="]"||S==="INDEX_END")n[m][0]="TYPE_ANNOTATION",M.sawType=!0,A()}}}}function uf(n,f,e={}){let t=[],i=0,u=[],l=f;while(f<n.length){let a=n[f],c=a[0],r=c==="("||c==="["||c==="{"||c==="CALL_START"||c==="PARAM_START"||c==="INDEX_START"||c==="COMPARE"&&a[1]==="<",h=c===")"||c==="]"||c==="}"||c==="CALL_END"||c==="PARAM_END"||c==="INDEX_END"||c==="COMPARE"&&a[1]===">";if(c==="SHIFT"&&a[1]===">>"&&i>=2){if(i-=2,u[u.length-1]==="<")u.pop();if(u[u.length-1]==="<")u.pop();t.push(a),f++;continue}if(r){i++;let o=c==="{"?"{":c==="["||c==="INDEX_START"?"[":c==="COMPARE"&&a[1]==="<"?"<":"(";u.push(o),t.push(a),f++;continue}if(h){if(i>0){i--,u.pop(),t.push(a),f++;continue}break}if(i===0){if(e.stopAtFatArrow&&c==="=>")break;if(c==="INDENT"&&t.length>0&&t[t.length-1][0]==="=>"){f++;let o=1;while(f<n.length&&o>0)if(n[f][0]==="INDENT")o++,f++;else if(n[f][0]==="OUTDENT")o--,f++;else t.push(n[f]),f++;continue}if(c==="="||c==="REACTIVE_ASSIGN"||c==="COMPUTED_ASSIGN"||c==="READONLY_ASSIGN"||c==="EFFECT"||c==="GATE"||c==="TERMINATOR"||c==="INDENT"||c==="OUTDENT"||c==="->"||c===",")break}if(i>0&&(c==="INDENT"||c==="OUTDENT")){f++;continue}if(i>0&&c==="TERMINATOR"){t.push(["",";"]),f++;continue}if(c==="PROPERTY"&&u[u.length-1]==="{"){let o=t[t.length-1],s=o?.[0],w=o?.[1];if(o&&s!=="{"&&s!==","&&!(s===""&&w===";"))t.push(["",";"])}t.push(a),f++}return t.consumed=f-l,t}function Vn(n){if(n.length===0)return"";if(n[0]?.[0]==="=>")n.unshift(["","()"]);{let t=0;for(let i of n){let u=i[0];if(u==="{")t++;else if(u==="}")t--;else if(u==="TYPE_ANNOTATION"&&t>0){let l=i.loc,a=l?` (line ${l.r}, col ${l.c})`:"",c=Error(`Use \`:\` (not \`::\`) inside a structural type literal${a}. \`::\` binds a name to a type; inside \`{ ... }\` in type position, fields use \`:\` (TS-style).`);throw c.loc=l,c}}}let e=n.map((t,i)=>{let u=n[i+1];if(t.data?.optional&&u&&(u[0]==="TYPE_ANNOTATION"||u[0]===":"))return`${t[1]}?`;if(t[0]==="JS")return"`"+t[1]+"`";return t[1]}).join(" ").replace(/\s+/g," ").trim();return e=e.replace(/\s*<\s*/g,"<").replace(/\s*>\s*/g,">").replace(/\s*\[\s*/g,"[").replace(/\s*\]\s*/g,"]").replace(/\s*\(\s*/g,"(").replace(/\s*\)\s*/g,")").replace(/\s*,\s*/g,", ").replace(/\s*=>\s*/g," => ").replace(/ :: /g,": ").replace(/:: /g,": ").replace(/ : /g,": "),e}function ef(n,f){if(f>=n.length)return null;let e=n[f];if(e[0]!=="COMPARE"||e[1]!=="<")return null;let t=[e],i=1,u=f+1;while(u<n.length&&i>0){let l=n[u];if(t.push(l),l[0]==="COMPARE"&&l[1]==="<")i++;else if(l[0]==="COMPARE"&&l[1]===">")i--;u++}return i===0?t:null}function tl(n,f){let e=[],t=f+1,i=1;while(t<n.length&&i>0){let u=n[t];if(u[0]==="INDENT"){i++,t++;continue}if(u[0]==="OUTDENT"){if(i--,i===0)break;t++;continue}if(u[0]==="TERMINATOR"){t++;continue}if(i===1&&u[0]==="["){let a=[];t++;while(t<n.length&&n[t][0]!=="]")a.push(n[t]),t++;if(t++,n[t]?.[1]===":"||n[t]?.[0]==="TYPE_ANNOTATION")t++;let c=[];while(t<n.length){let o=n[t];if(o[0]==="TERMINATOR"||o[0]==="OUTDENT")break;c.push(o),t++}let r=Vn(a),h=Vn(c);e.push(`[${r}]: ${h}`);continue}let l=u[0]==="PROPERTY"||u[0]==="IDENTIFIER"||i===1&&/^[a-zA-Z_$]/.test(u[1])&&n[t+1]?.[0]==="TYPE_ANNOTATION";if(i===1&&l){let a=u[1],c=!1,r=!1;if(t++,a==="readonly"&&n[t]&&(n[t][0]==="PROPERTY"||n[t][0]==="IDENTIFIER"||/^[a-zA-Z_$]/.test(n[t][1])&&n[t+1]?.[0]==="TYPE_ANNOTATION")){if(r=!0,a=n[t][1],n[t].data?.optional)c=!0;t++}if(u.data?.optional)c=!0;if(n[t]?.[1]==="?"&&!n[t]?.spaced)c=!0,t++;if(n[t]?.[1]===":"||n[t]?.[0]==="TYPE_ANNOTATION")t++;let h=[],o=0;while(t<n.length){let y=n[t];if(y[0]==="IDENTIFIER"&&y[1]==="type"&&n[t+1]?.[0]==="INDENT"){t++;let R=tl(n,t);h.push(["",R]);let U=1;t++;while(t<n.length&&U>0){if(n[t][0]==="INDENT")U++;if(n[t][0]==="OUTDENT")U--;t++}continue}if(y[0]==="INDENT"){o++,t++;continue}if(y[0]==="OUTDENT"){if(o>0){o--,t++;continue}break}if(y[0]==="TERMINATOR"&&o===0)break;h.push(y),t++}let s=Vn(h),w=r?"readonly ":"",_=c?"?":"",A=!1;if(!c&&s.startsWith("(")){let y=0;for(let R=0;R<s.length;R++){let U=s[R];if(U==="(")y++;else if(U===")"){if(y--,y===0){let m=s.slice(R+1).trimStart();if(m===""||m.startsWith(":")&&!m.startsWith("::"))A=!0;break}}}}if(A)e.push(`${w}${a}${s}`);else e.push(`${w}${a}${_}: ${s}`)}else t++}return"{ "+e.join("; ")+" }"}function al(n,f){let e=0;for(let t=f;t<n.length;t++){if(n[t][0]==="INDENT")e++;if(n[t][0]==="OUTDENT"){if(e--,e===0)return t}}return n.length-1}function Ye(n,f){let e=f;if(n[e]?.[0]==="TERMINATOR")e++;if(n[e]?.[0]!=="INDENT")return null;let t=e;e++;while(e<n.length&&n[e][0]==="TERMINATOR")e++;if(!n[e]||n[e][1]!=="|")return null;let i=[],u=1;e=t+1;while(e<n.length&&u>0){let a=n[e];if(a[0]==="INDENT"){u++,e++;continue}if(a[0]==="OUTDENT"){if(u--,u===0)break;e++;continue}if(a[0]==="TERMINATOR"){e++;continue}if(a[1]==="|"&&u===1){e++;let c=[];while(e<n.length){let r=n[e];if(r[0]==="TERMINATOR"||r[0]==="OUTDENT"||r[1]==="|"&&u===1)break;c.push(r),e++}if(c.length>0)i.push(Vn(c));continue}e++}if(i.length===0)return null;let l=al(n,t);return{typeText:i.join(" | "),endIdx:l}}var af=new Set(["true","false","null","this","new","delete","typeof","in","instanceof","return","throw","break","continue","debugger","yield","await","if","else","switch","for","while","do","try","catch","finally","class","extends","super","import","export","default"]),rf=new Set(["undefined","Infinity","NaN","then","unless","until","loop","of","by","when","def","component","render","enum","interface"]),cl={and:"&&",or:"||",is:"==",isnt:"!=",not:"!",yes:"true",no:"false",on:"true",off:"false"},cf=new Set(Object.keys(cl)),Ze=new Set(["case","function","var","void","with","const","let","native","implements","package","private","protected","public","static"]),Ge=new Set(["break","continue","debugger"]),Ne=new Set(["NEW","TYPEOF","DELETE"]),Xe=new Set(["IN","OF","INSTANCEOF"]),Xi=new Set(["IDENTIFIER","PROPERTY",")","]","@","THIS","SUPER","DYNAMIC_IMPORT","?."]),bi=new Set([...Xi,"NUMBER","INFINITY","NAN","STRING","STRING_END","REGEX","REGEX_END","BOOL","NULL","UNDEFINED","}","MAP_END","SYMBOL"]),Gi=new Set(["IDENTIFIER","PROPERTY","NUMBER","INFINITY","NAN","STRING","STRING_START","REGEX","REGEX_START","JS","NEW","PARAM_START","CLASS","IF","TRY","SWITCH","THIS","DYNAMIC_IMPORT","IMPORT_META","NEW_TARGET","UNDEFINED","NULL","BOOL","UNARY","DO","DO_IIFE","YIELD","AWAIT","UNARY_MATH","SUPER","THROW","@","->","=>","[","(","{","MAP_START","--","++","SYMBOL"]),be=new Set(["+","-"]),Pe=new Set(["POST_IF","POST_UNLESS","FOR","WHILE","UNTIL","WHEN","BY","LOOP","TERMINATOR","||","&&","??"]),Oe=new Set(["STRING","STRING_END","REGEX","REGEX_END","NUMBER","BOOL","NULL","UNDEFINED","INFINITY","NAN","]","}","MAP_END","SYMBOL"]),jn=new Set(["(","[","{","MAP_START","PICK_START","OPTPICK_START","INDENT","CALL_START","PARAM_START","INDEX_START","STRING_START","INTERPOLATION_START","REGEX_START"]),Cn=new Set([")","]","}","MAP_END","PICK_END","OUTDENT","CALL_END","PARAM_END","INDEX_END","STRING_END","INTERPOLATION_END","REGEX_END"]),Be={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{",INDENT:"OUTDENT",OUTDENT:"INDENT",CALL_START:"CALL_END",CALL_END:"CALL_START",PARAM_START:"PARAM_END",PARAM_END:"PARAM_START",INDEX_START:"INDEX_END",INDEX_END:"INDEX_START",STRING_START:"STRING_END",STRING_END:"STRING_START",INTERPOLATION_START:"INTERPOLATION_END",INTERPOLATION_END:"INTERPOLATION_START",REGEX_START:"REGEX_END",REGEX_END:"REGEX_START",MAP_START:"MAP_END",MAP_END:"MAP_START",PICK_START:"PICK_END",PICK_END:"PICK_START",OPTPICK_START:"PICK_END"},hf=new Set(["CATCH","THEN","ELSE","FINALLY",...Cn]),rl=new Set(["IDENTIFIER","PROPERTY","SUPER",")","CALL_END","]","INDEX_END","@","THIS"]),Ie=new Set(["IDENTIFIER","PROPERTY",")","CALL_END","]","INDEX_END"]),ge=new Set(["IF","TRY","FINALLY","CATCH","CLASS","SWITCH","COMPONENT","FOR"]),Ce=new Set(["IDENTIFIER","PROPERTY","NUMBER","STRING","STRING_END","REGEX","REGEX_END",")","CALL_END","]","INDEX_END","}","MAP_END","PICK_END","BOOL","NULL","UNDEFINED","INFINITY","NAN","SUPER","THIS","@","SYMBOL"]),sf=new Set(["ELSE","->","=>","TRY","FINALLY","THEN"]),ve=new Set(["TERMINATOR","CATCH","FINALLY","ELSE","OUTDENT","LEADING_WHEN"]),si=new Set(["INDENT","OUTDENT","TERMINATOR"]),ti=(n)=>n?.[0]==="IDENTIFIER"||n?.[0]==="PROPERTY",Ni=(n,f)=>{if(n?.[0]===".")return!0;if(n?.[0]==="-")return n.spaced===!1&&!n.newLine&&f?.spaced===!1&&!f?.newLine;return!1},of=new Set([".","?."]),wf=new Set(["\\",".","?.","UNARY","DO","DO_IIFE","MATH","UNARY_MATH","+","-","**","SHIFT","RELATION","COMPARE","&","^","|","&&","||","TERNARY","EXTENDS"]),Te=new Set([...bi,"++","--"]),_f=new Set(["-=","+=","/=","*=","%=","||=","&&=","?=","??=","<<=",">>=",">>>=","&=","^=","|=","**=","//=","%%="]),Ve=new Set(["*","/","%","//","%%"]),je=new Set(["==","!=","===","!==","<",">","<=",">=","=~"]),Le=new Set(["<<",">>",">>>"]),pe=new Set(["!","~"]),xe=/^(?!\d)((?:(?!\s)[$\w\x7f-\uffff])+(?:!|[?](?![.?![(]))?)([^\n\S]*:(?![=:]))?/,$e=/^0b[01](?:_?[01])*n?|^0o[0-7](?:_?[0-7])*n?|^0x[\da-f](?:_?[\da-f])*n?|^\d+(?:_\d+)*n|^(?:\d+(?:_\d+)*)?\.?\d+(?:_\d+)*(?:e[+-]?\d+(?:_\d+)*)?/i,ke=/^(?:<=>|<~|::|\*>|[-=]>|~>|~=|:=|=!|===|!==|\?\!|\?\?|=~|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>*\/%])\2=?|\?\.?|\.{2,3})/,nt=/^[^\n\S]+/,it=/^(?:\n[^\n\S]*)+/,lt=/^(\s*)###([^#][\s\S]*?)(?:###([^\n\S]*)|###$)|^((?:\s*#(?!##[^#]).*)+)/,ft=/^[-=]>/,ut=/^(?:~[=>]|=!)/,et=/^(?:'''\\|"""\\|'''|"""|'|")/,tt=/^(?:[^\\']|\\[\s\S])*/,at=/^(?:[^\\"#$]|\\[\s\S]|\#(?!\{)|\$(?!\{))*/,rt=/^(?:[^\\']|\\[\s\S]|'(?!''))*/,ct=/^(?:[^\\"#$]|\\[\s\S]|"(?!"")|\#(?!\{)|\$(?!\{))*/,mf=/\n+([^\n\S]*)(?=\S)/g,ht=/^\/(?!\/)((?:[^[\/\n\\]|\\[^\n]|\[(?:\\[^\n]|[^\]\n\\])*\])*)(\/)?/,yf=/^\w*/,st=/^(?!.*(.).*\1)[gimsuy]*$/,ot=/^(?:[^\\\/#\s]|\\[\s\S]|\/(?!\/\/)|\#(?!\{)|\s+(?:#(?!\{).*)?)*/,wt=/^`(?!``)((?:[^`\\]|\\[\s\S])*)`/,_t=/^```((?:[^`\\]|\\[\s\S]|`(?!``))*)```/,mt=/\s+$/,Af=/^\s*(?:,|\??\.(?![.\d]))/,yt=65279;function Pi(n,f,{pre:e=0,row:t=0,col:i=0,len:u=0,data:l=null}={}){let a=[n,f];return a.pre=e,a.data=l,a.loc={r:t,c:i,n:u},a.spaced=e>0,a.newLine=!1,a}function Bn(n,f,e){let t=Pi(n,f);if(t.generated=!0,e)t.origin=e;return t}function Pn(n,{row:f=0,col:e=0,len:t=1}={}){let i=SyntaxError(n);throw i.location={first_line:f,first_column:e,last_column:e+t-1},i}function At(n){if(n==null)return NaN;switch(n.charAt(1)){case"b":return parseInt(n.slice(2).replace(/_/g,""),2);case"o":return parseInt(n.slice(2).replace(/_/g,""),8);case"x":return parseInt(n.slice(2).replace(/_/g,""),16);default:return parseFloat(n.replace(/_/g,""))}}class vn{tokenize(n,f={}){this.code=n,this.tokens=[],this.ends=[],this.chunk="",this.pos=0,this.row=f.row||0,this.col=f.col||0,this.indent=0,this.indents=[],this.seenFor=!1,this.seenImport=!1,this.seenExport=!1,this.importSpecifierList=!1,this.exportSpecifierList=!1,this.inRenderBlock=!1,this.renderIndent=0,this.inTypeAnnotation=!1,n=this.clean(n),this.code=n;while(this.pos<n.length){this.chunk=n.slice(this.pos);let e=this.identifierToken()||this.commentToken()||this.whitespaceToken()||this.lineToken()||this.stringToken()||this.numberToken()||this.regexToken()||this.jsToken()||this.literalToken();if(e===0)Pn(`unexpected character: ${this.chunk.charAt(0)}`,{row:this.row,col:this.col});if(this.advance(e),f.untilBalanced&&this.ends.length===0)return{tokens:this.tokens,index:this.pos}}if(this.closeIndentation(),this.ends.length>0){let e=this.ends[this.ends.length-1];Pn(`missing ${e.tag}`,{row:this.row,col:this.col})}if(f.rewrite===!1)return this.tokens;return this.rewrite(this.tokens)}clean(n){if(n.charCodeAt(0)===yt)n=n.slice(1);if(n=n.replace(/\r\n?/g,`
1867
1867
  `),n=n.replace(mt,""),/^[^\n\S]/.test(n))n=`
1868
1868
  `+n;return n}advance(n){let f=this.code.slice(this.pos,this.pos+n);for(let e=0;e<f.length;e++)if(f[e]===`
1869
- `)this.row++,this.col=0;else this.col++;this.pos+=n}emit(n,f,{len:e,data:t,pre:i}={}){let u=Pi(n,f,{pre:i??0,row:this.row,col:this.col,len:e??(typeof f==="string"?f.length:0),data:t});return this.tokens.push(u),u}prev(){return this.tokens[this.tokens.length-1]}prevTag(){let n=this.prev();return n?n[0]:void 0}prevVal(){let n=this.prev();return n?n[1]:void 0}isReturnTypeSlot(){let n=this.tokens.length;if(n<2)return!1;let f=this.tokens[n-1];if(!f||f[1]!==":")return!1;let e=this.tokens[n-2];if(!e)return!1;let t=e[0];return t===")"||t==="CALL_END"||t==="PARAM_END"}inPickKeyPos(){let n=this.prev();if(!n)return!1;let f=n[0];if(f!=="{"&&f!==","&&f!==":"&&f!=="TERMINATOR"&&f!=="INDENT"&&f!=="OUTDENT")return!1;let e=0,t=this.tokens;for(let i=t.length-1;i>=0;i--){let u=t[i],l=u[0];if(l==="}"||l==="PICK_END"){e++;continue}if(l==="{"||l==="PICK_START"||l==="OPTPICK_START"){if(e===0){let a=t[i-1];return!!(a&&(a[0]==="."||a[0]==="?.")&&!a.spaced&&!u.spaced)}e--;continue}if(e===0&&(l==="("||l==="CALL_START"||l==="["||l==="INDEX_START"))return!1}return!1}identifierToken(){if(ut.test(this.chunk))return 0;let n=xe.exec(this.chunk);if(!n)return 0;let[,f,e]=n,t=f.length,i={},u;if(f==="own"&&this.prevTag()==="FOR")return this.emit("OWN",f,{len:t}),t;if(f==="from"&&this.prevTag()==="YIELD")return this.emit("FROM",f,{len:t}),t;if(f==="as"&&!this.seenFor&&(this.seenImport||this.seenExport)){if(this.seenImport){if(this.prevVal()==="*")this.prev()[0]="IMPORT_ALL"}let h=this.prevTag();if(h==="DEFAULT"||h==="IMPORT_ALL"||h==="IDENTIFIER")return this.emit("AS",f,{len:t}),t}if((f==="as"||f==="as!")&&this.seenFor)return this.seenFor=!1,this.emit(f==="as!"?"FORASAWAIT":"FORAS","as",{len:t}),t;if(f==="default"&&this.seenExport&&(this.prevTag()==="EXPORT"||this.prevTag()==="AS"))return this.emit("DEFAULT",f,{len:t}),t;let l;if(f==="do"&&(l=/^(\s*super)(?!\(\))/.exec(this.chunk.slice(3))))return this.emit("SUPER","super"),this.emit("CALL_START","("),this.emit("CALL_END",")"),l[1].length+3;let a=this.prev();if(e&&a&&a[0]==="TERNARY")e=null;if(e&&e.length>1&&/[a-zA-Z_$]/.test(this.chunk[t+e.length]))e=null;if(e||a&&(a[0]==="."||a[0]==="?."||!a.spaced&&a[0]==="@")||this.inPickKeyPos()){if(u="PROPERTY",this.inRenderBlock&&a&&a[0]==="."&&!e){let h=this.chunk.slice(t);while(h[0]==="-"&&/^-[a-zA-Z]/.test(h)){let o=/^-([a-zA-Z][\w]*)/.exec(h);if(!o)break;f+="-"+o[1],t+=1+o[1].length,h=this.chunk.slice(t)}}}else u="IDENTIFIER";let c=f.endsWith("!")||f.endsWith("?")?f.slice(0,-1):f;if(u==="IDENTIFIER"&&!f.endsWith("!")&&!f.endsWith("?")&&(af.has(f)||rf.has(f)||cf.has(f))&&!(this.exportSpecifierList&&cf.has(f))){if(cl[f]!==void 0)i.original=f,f=cl[f];u=this.classifyKeyword(f,u,i)}if(u==="IDENTIFIER"&&Ze.has(c))if(c==="void"&&(this.inTypeAnnotation||this.prevTag()==="=>"||this.isReturnTypeSlot()));else Bn(`reserved word '${c}'`,{row:this.row,col:this.col,len:t});if(u==="PROPERTY"&&a){if(a[0]==="."&&this.tokens.length>1){let h=this.tokens[this.tokens.length-2];if(h[0]==="UNARY"&&h[1]==="new")h[0]="NEW_TARGET";if(h[0]==="IMPORT"&&h[1]==="import")this.seenImport=!1,h[0]="IMPORT_META"}}if(f.length>1&&f.endsWith("!"))i.bang=!0,f=f.slice(0,-1);if(f.length>1&&f.endsWith("?"))i.optional=!0,f=f.slice(0,-1);let r=this.emit(u,f,{len:t,data:Object.keys(i).length?i:null});if(u==="RENDER")this.inRenderBlock=!0,this.renderIndent=this.indent;if(e)return this.emit(":",":",{len:1}),t+e.length;return t}classifyKeyword(n,f,e){switch(n){case"!":return"UNARY";case"==":case"!=":return"COMPARE";case"true":case"false":return"BOOL";case"&&":case"||":return n}if(Ge.has(n))return"STATEMENT";let t=n.toUpperCase();if(t==="WHEN"&&si.has(this.prevTag()))return"LEADING_WHEN";if(t==="FOR")return this.seenFor={endsLength:this.ends.length},"FOR";if(t==="UNLESS")return"UNLESS";if(t==="IMPORT")return this.seenImport=!0,"IMPORT";if(t==="EXPORT")return this.seenExport=!0,"EXPORT";if(Ne.has(t))return"UNARY";if(Xe.has(t)){if(t!=="INSTANCEOF"&&this.seenFor)return this.seenFor=!1,"FOR"+t;if(this.prevVal()==="!"){let i=this.tokens.pop();e.invert=i.data?.original||i[1]}return"RELATION"}if(af.has(n)||rf.has(n))return t;return f}commentToken(){if(this.inRenderBlock){if(/^#[a-zA-Z_]/.test(this.chunk)){let f=this.prev();if(f&&(f[0]==="IDENTIFIER"||f[0]==="PROPERTY"))return 0;let e=/^#([a-zA-Z_][\w-]*)/.exec(this.chunk);if(e)return this.emit("IDENTIFIER","div#"+e[1]),e[0].length}if(/^\s+#[a-zA-Z_]/.test(this.chunk))return 0}let n=lt.exec(this.chunk);if(!n)return 0;return n[0].length}whitespaceToken(){let n=nt.exec(this.chunk);if(!n&&this.chunk[0]!==`
1869
+ `)this.row++,this.col=0;else this.col++;this.pos+=n}emit(n,f,{len:e,data:t,pre:i}={}){let u=Pi(n,f,{pre:i??0,row:this.row,col:this.col,len:e??(typeof f==="string"?f.length:0),data:t});return this.tokens.push(u),u}prev(){return this.tokens[this.tokens.length-1]}prevTag(){let n=this.prev();return n?n[0]:void 0}prevVal(){let n=this.prev();return n?n[1]:void 0}isReturnTypeSlot(){let n=this.tokens.length;if(n<2)return!1;let f=this.tokens[n-1];if(!f||f[1]!==":")return!1;let e=this.tokens[n-2];if(!e)return!1;let t=e[0];return t===")"||t==="CALL_END"||t==="PARAM_END"}inPickKeyPos(){let n=this.prev();if(!n)return!1;let f=n[0];if(f!=="{"&&f!==","&&f!==":"&&f!=="TERMINATOR"&&f!=="INDENT"&&f!=="OUTDENT")return!1;let e=0,t=this.tokens;for(let i=t.length-1;i>=0;i--){let u=t[i],l=u[0];if(l==="}"||l==="PICK_END"){e++;continue}if(l==="{"||l==="PICK_START"||l==="OPTPICK_START"){if(e===0){let a=t[i-1];return!!(a&&(a[0]==="."||a[0]==="?.")&&!a.spaced&&!u.spaced)}e--;continue}if(e===0&&(l==="("||l==="CALL_START"||l==="["||l==="INDEX_START"))return!1}return!1}identifierToken(){if(ut.test(this.chunk))return 0;let n=xe.exec(this.chunk);if(!n)return 0;let[,f,e]=n,t=f.length,i={},u;if(f==="own"&&this.prevTag()==="FOR")return this.emit("OWN",f,{len:t}),t;if(f==="from"&&this.prevTag()==="YIELD")return this.emit("FROM",f,{len:t}),t;if(f==="as"&&!this.seenFor&&(this.seenImport||this.seenExport)){if(this.seenImport){if(this.prevVal()==="*")this.prev()[0]="IMPORT_ALL"}let h=this.prevTag();if(h==="DEFAULT"||h==="IMPORT_ALL"||h==="IDENTIFIER")return this.emit("AS",f,{len:t}),t}if((f==="as"||f==="as!")&&this.seenFor)return this.seenFor=!1,this.emit(f==="as!"?"FORASAWAIT":"FORAS","as",{len:t}),t;if(f==="default"&&this.seenExport&&(this.prevTag()==="EXPORT"||this.prevTag()==="AS"))return this.emit("DEFAULT",f,{len:t}),t;let l;if(f==="do"&&(l=/^(\s*super)(?!\(\))/.exec(this.chunk.slice(3))))return this.emit("SUPER","super"),this.emit("CALL_START","("),this.emit("CALL_END",")"),l[1].length+3;let a=this.prev();if(e&&a&&a[0]==="TERNARY")e=null;if(e&&e.length>1&&/[a-zA-Z_$]/.test(this.chunk[t+e.length]))e=null;if(e||a&&(a[0]==="."||a[0]==="?."||!a.spaced&&a[0]==="@")||this.inPickKeyPos()){if(u="PROPERTY",this.inRenderBlock&&a&&a[0]==="."&&!e){let h=this.chunk.slice(t);while(h[0]==="-"&&/^-[a-zA-Z]/.test(h)){let o=/^-([a-zA-Z][\w]*)/.exec(h);if(!o)break;f+="-"+o[1],t+=1+o[1].length,h=this.chunk.slice(t)}}}else u="IDENTIFIER";let c=f.endsWith("!")||f.endsWith("?")?f.slice(0,-1):f;if(u==="IDENTIFIER"&&!f.endsWith("!")&&!f.endsWith("?")&&(af.has(f)||rf.has(f)||cf.has(f))&&!(this.exportSpecifierList&&cf.has(f))){if(cl[f]!==void 0)i.original=f,f=cl[f];u=this.classifyKeyword(f,u,i)}if(u==="IDENTIFIER"&&Ze.has(c))if(c==="void"&&(this.inTypeAnnotation||this.prevTag()==="=>"||this.isReturnTypeSlot()));else Pn(`reserved word '${c}'`,{row:this.row,col:this.col,len:t});if(u==="PROPERTY"&&a){if(a[0]==="."&&this.tokens.length>1){let h=this.tokens[this.tokens.length-2];if(h[0]==="UNARY"&&h[1]==="new")h[0]="NEW_TARGET";if(h[0]==="IMPORT"&&h[1]==="import")this.seenImport=!1,h[0]="IMPORT_META"}}if(f.length>1&&f.endsWith("!"))i.bang=!0,f=f.slice(0,-1);if(f.length>1&&f.endsWith("?"))i.optional=!0,f=f.slice(0,-1);let r=this.emit(u,f,{len:t,data:Object.keys(i).length?i:null});if(u==="RENDER")this.inRenderBlock=!0,this.renderIndent=this.indent;if(e)return this.emit(":",":",{len:1}),t+e.length;return t}classifyKeyword(n,f,e){switch(n){case"!":return"UNARY";case"==":case"!=":return"COMPARE";case"true":case"false":return"BOOL";case"&&":case"||":return n}if(Ge.has(n))return"STATEMENT";let t=n.toUpperCase();if(t==="WHEN"&&si.has(this.prevTag()))return"LEADING_WHEN";if(t==="FOR")return this.seenFor={endsLength:this.ends.length},"FOR";if(t==="UNLESS")return"UNLESS";if(t==="IMPORT")return this.seenImport=!0,"IMPORT";if(t==="EXPORT")return this.seenExport=!0,"EXPORT";if(Ne.has(t))return"UNARY";if(Xe.has(t)){if(t!=="INSTANCEOF"&&this.seenFor)return this.seenFor=!1,"FOR"+t;if(this.prevVal()==="!"){let i=this.tokens.pop();e.invert=i.data?.original||i[1]}return"RELATION"}if(af.has(n)||rf.has(n))return t;return f}commentToken(){if(this.inRenderBlock){if(/^#[a-zA-Z_]/.test(this.chunk)){let f=this.prev();if(f&&(f[0]==="IDENTIFIER"||f[0]==="PROPERTY"))return 0;let e=/^#([a-zA-Z_][\w-]*)/.exec(this.chunk);if(e)return this.emit("IDENTIFIER","div#"+e[1]),e[0].length}if(/^\s+#[a-zA-Z_]/.test(this.chunk))return 0}let n=lt.exec(this.chunk);if(!n)return 0;return n[0].length}whitespaceToken(){let n=nt.exec(this.chunk);if(!n&&this.chunk[0]!==`
1870
1870
  `)return 0;let f=this.prev();if(f)if(n)f.spaced=!0,f.pre=n[0].length;else f.newLine=!0;return n?n[0].length:0}lineToken(){let n=it.exec(this.chunk);if(!n)return 0;let f=n[0],e=f.length-1-f.lastIndexOf(`
1871
1871
  `);if(this.isUnfinished()){if(e<this.indent&&/^\s*,/.test(this.chunk)&&!wf.has(this.prevTag())){if(this.outdentTo(e,f.length),this.prevTag()==="TERMINATOR")this.tokens.pop();return f.length}return f.length}if(this.seenFor&&!(this.seenFor.endsLength<this.ends.length))this.seenFor=!1;if(!this.importSpecifierList)this.seenImport=!1;if(!this.exportSpecifierList)this.seenExport=!1;if(this.inTypeAnnotation=!1,e===this.indent)return this.emitNewline(),f.length;if(e>this.indent){if(!this.tokens.length)return this.indent=e,f.length;let t=e-this.indent;return this.emit("INDENT",t,{len:e}),this.indents.push(t),this.ends.push({tag:"OUTDENT"}),this.indent=e,f.length}return this.outdentTo(e,f.length),f.length}outdentTo(n,f=0){if(this.inRenderBlock&&n<=this.renderIndent)this.inRenderBlock=!1;let e=this.indent-n;while(e>0){let t=this.indents[this.indents.length-1];if(!t)e=0;else this.indents.pop(),this.pair("OUTDENT"),this.emit("OUTDENT",e,{len:f}),e-=t}this.emitNewline(),this.indent=n}closeIndentation(){this.outdentTo(0)}emitNewline(){if(this.prevTag()!=="TERMINATOR")this.emit("TERMINATOR",`
1872
- `,{len:0})}isUnfinished(){if(this.inRenderBlock&&Af.test(this.chunk)&&/^\s*\./.test(this.chunk))return!1;if(this.inRenderBlock&&this.prevTag()==="."){let e=this.tokens.length;if(e>=2){let t=this.tokens[e-2][0];if(t==="INDENT"||t==="TERMINATOR"||t==="OUTDENT")return!1}}let n=this.tokens[this.tokens.length-1];if(n?.[0]==="COMPARE"&&n[1]===">"||n?.[0]==="SHIFT"&&(n[1]===">>"||n[1]===">>>")){let e=0;for(let t=this.tokens.length-1;t>=0;t--){let i=this.tokens[t];if(i[0]==="COMPARE"&&i[1]===">")e++;else if(i[0]==="SHIFT"&&i[1]===">>")e+=2;else if(i[0]==="SHIFT"&&i[1]===">>>")e+=3;else if(i[0]==="COMPARE"&&i[1]==="<")e--;if(e===0&&i[0]==="TYPE_ANNOTATION")return!1;if(e===0&&i[0]===":"){let u=this.tokens[t-1];if(u&&(u[0]===")"||u[0]==="PARAM_END"||u[0]==="CALL_END"))return!1}if(e===0&&i[0]==="IDENTIFIER"&&i[1]==="type")return!1;if(i[0]==="INTERFACE")return!1;if(i[0]==="TERMINATOR"||i[0]==="INDENT"||i[0]==="OUTDENT"){let u=-1;if(i[0]==="INDENT")u=t;else{let l=i[0]==="OUTDENT"?1:0;for(let a=t-1;a>=0;a--){let c=this.tokens[a];if(c[0]==="OUTDENT")l++;else if(c[0]==="INDENT"){if(l===0){u=a;break}l--}}}if(u>0)for(let l=u-1;l>=0;l--){let a=this.tokens[l];if(a[0]==="TERMINATOR"||a[0]==="INDENT"||a[0]==="OUTDENT")break;if(a[0]==="INTERFACE")return!1;if(a[0]==="IDENTIFIER"&&a[1]==="type"){let c=this.tokens[l-1];if(!c||c[0]==="TERMINATOR"||c[0]==="EXPORT")return!1;break}}break}}}return Af.test(this.chunk)||wf.has(this.prevTag())}pair(n){let f=this.ends[this.ends.length-1];if(!f||n!==f.tag){if(f?.tag==="OUTDENT"){let e=this.indents[this.indents.length-1];if(e)this.outdentTo(this.indent-e);return this.pair(n)}Bn(`unmatched ${n}`,{row:this.row,col:this.col})}return this.ends.pop()}stringToken(){let n=et.exec(this.chunk);if(!n)return 0;let f=n[0],e=f.length>1&&f.endsWith("\\"),t=e?f.slice(0,-1):f,i=this.prev();if(i&&this.prevVal()==="from"&&(this.seenImport||this.seenExport))i[0]="FROM";let u;switch(t){case"'":u=tt;break;case'"':u=at;break;case"'''":u=rt;break;case'"""':u=ct;break}let{tokens:l,index:a}=this.matchWithInterpolations(u,f,t),c=t.length===3,r=null;if(c)r=this.processHeredocIndent(a,t,l);return this.mergeInterpolationTokens(l,{quote:t,indent:r,endOffset:a,raw:e}),a}processHeredocIndent(n,f,e){let t=n-f.length,i=t-1;while(i>=0&&this.chunk[i]!==`
1873
- `)i--;i++;let u=this.chunk.slice(i,t),l=/^\s*$/.test(u)?u.length:null,a="";for(let h of e)if(h[0]==="NEOSTRING")a+=h[1];let c=null,r;mf.lastIndex=0;while(r=mf.exec(a))if(c===null||r[1].length>0&&r[1].length<c.length)c=r[1];if(l===null)return c;if(c===null)return" ".repeat(l);if(l<=c.length)return" ".repeat(l);return c}matchWithInterpolations(n,f,e,t){if(!e)e=f;if(!t)t=/^[#$]\{/;let i=[],u=f.length;if(this.chunk.slice(0,u)!==f)return null;let l=this.chunk.slice(u);while(!0){let[a]=n.exec(l);i.push(["NEOSTRING",a,{offset:u}]),l=l.slice(a.length),u+=a.length;let c=t.exec(l);if(!c)break;let h=c[0].length-1,o=l.slice(h),s=new vn().tokenize(o,{row:this.row,col:this.col+u+h,untilBalanced:!0,rewrite:!1}),w=s.index+h;if(l[w-1]==="}"){let A=s.tokens[0],y=s.tokens[s.tokens.length-1];A[0]="INTERPOLATION_START",A[1]="(",y[0]="INTERPOLATION_END",y[1]=")"}if(s.tokens[1]?.[0]==="TERMINATOR")s.tokens.splice(1,1);let _=s.tokens.length;if(_>2&&s.tokens[_-3]?.[0]==="INDENT"&&s.tokens[_-2]?.[0]==="OUTDENT")s.tokens.splice(_-3,2);i.push(["TOKENS",s.tokens]),l=l.slice(w),u+=w}if(l.slice(0,e.length)!==e)Bn(`missing ${e}`,{row:this.row,col:this.col});return{tokens:i,index:u+e.length}}mergeInterpolationTokens(n,{quote:f,indent:e,endOffset:t,raw:i}){if(n.length>1)this.emit("STRING_START","(",{len:f?.length||0,data:{quote:f}});for(let u=0;u<n.length;u++){let[l,a]=n[u];if(l==="TOKENS")for(let c of a)this.tokens.push(c);else if(l==="NEOSTRING"){let c=a;if(e){let r=new RegExp("\\n"+e,"g");c=c.replace(r,`
1874
- `)}if(u===0&&f?.length===3)c=c.replace(/^\n/,"");if(u===n.length-1&&f?.length===3)c=c.replace(/\n[^\S\n]*$/,"");if(i)c=c.replace(/\\([nrtbfv0\\'"`xu])/g,"\\\\$1");this.emit("STRING",`"${c}"`,{len:a.length,data:{quote:f}})}}if(n.length>1)this.emit("STRING_END",")",{len:f?.length||0});return t}numberToken(){let n=$e.exec(this.chunk);if(!n)return 0;let f=n[0],e=f.length,t={row:this.row,col:this.col};if(/^0[BOX]/.test(f))Bn(`radix prefix in '${f}' must be lowercase`,{...t,col:t.col+1});if(/^0\d*[89]/.test(f))Bn(`decimal literal '${f}' must not be prefixed with '0'`,{...t,len:e});if(/^0\d+/.test(f))Bn(`octal literal '${f}' must be prefixed with '0o'`,{...t,len:e});let i=At(f),u=i===1/0?"INFINITY":"NUMBER",l={parsedValue:i};if(u==="INFINITY")l.original=f;return this.emit(u,f,{len:e,data:l}),e}regexToken(){let n=this.matchWithInterpolations(ot,"///");if(n){let{tokens:r,index:h}=n,[o]=yf.exec(this.chunk.slice(h)),s=h+o.length;if(r.length===1||!r.some((w)=>w[0]==="TOKENS")){let w=(r[0]?.[1]||"").replace(/(?<!\\)\//g,"\\/");this.emit("REGEX",`/${w}/${o}`,{len:s,data:{delimiter:"///",heregex:{flags:o}}})}else{if(this.emit("REGEX_START","(",{len:0}),this.emit("IDENTIFIER","RegExp",{len:0}),this.emit("CALL_START","(",{len:0}),this.mergeInterpolationTokens(r,{quote:"///",endOffset:s-o.length}),o)this.emit(",",",",{len:0}),this.emit("STRING",`"${o}"`,{len:o.length});this.emit(")",")",{len:0}),this.emit("REGEX_END",")",{len:0})}return s}let f=ht.exec(this.chunk);if(!f)return 0;let[e,t,i]=f,u=this.prev();if(u){if(u.spaced&&Xi.has(u[0])&&(!i||/^\/=?\s/.test(e)))return 0;if(Te.has(u[0])&&!(u.spaced&&Xi.has(u[0])))return 0}if(!i)Bn("missing / (unclosed regex)",{row:this.row,col:this.col});let l=e.length,[a]=yf.exec(this.chunk.slice(l)),c=l+a.length;if(!st.test(a))Bn(`invalid regular expression flags ${a}`,{row:this.row,col:this.col+l,len:a.length});return this.emit("REGEX",`/${t}/${a}`,{len:c,data:{delimiter:"/"}}),c}jsToken(){if(this.chunk[0]!=="`")return 0;let n=_t.exec(this.chunk)||wt.exec(this.chunk);if(!n)return 0;let f=n[1],e=n[0].length;return this.emit("JS",f,{len:e,data:{here:n[0].startsWith("```")}}),e}wordLiteral(){if(this.chunk[0]!=="%"||this.chunk[1]!=="w")return 0;let n=this.chunk[2];if(!n||/\s/.test(n))return 0;let e={"[":"]","(":")","{":"}","<":">"}[n]||n,t=e!==n,i=1,u=3;while(u<this.chunk.length&&i>0){let r=this.chunk[u];if(r==="\\"){u+=2;continue}if(t&&r===n)i++;if(r===e)i--;if(i>0)u++}if(i!==0)return 0;let l=this.chunk.slice(3,u),a=u+1,c=[];if(l.trim()){let r=l.trim().split(/(?<!\\)\s+/);for(let h of r)c.push(h.replace(/\\ /g," "))}this.emit("[","[",{len:a});for(let r=0;r<c.length;r++){if(r>0)this.emit(",",",");this.emit("STRING",`"${c[r]}"`)}return this.emit("]","]"),a}symbolToken(){if(this.chunk[0]!==":")return 0;let n=this.chunk[1];if(!n||n==="="||n===":"||/\s/.test(n))return 0;if(!/[a-zA-Z_$]/.test(n))return 0;let f=/^((?:(?!\s)[$\w\x7f-\uffff])+)/.exec(this.chunk.slice(1));if(!f)return 0;let e=f[1],t=e.length+1;return this.emit("SYMBOL",e,{len:t}),t}literalToken(){let n=this.wordLiteral();if(n)return n;let f=this.symbolToken();if(f)return f;let e=ke.exec(this.chunk),t=e?e[0]:this.chunk.charAt(0),i=t,u=this.prev();if(ft.test(t))this.tagParameters();if(t==="="&&u&&u[1]==="."&&!u.spaced){let l=this.tokens,a=l.length-2;while(a>=1&&l[a][0]==="PROPERTY"&&l[a-1]?.[1]===".")a-=2;if(a>=0&&(l[a][0]==="IDENTIFIER"||l[a][0]===")"||l[a][0]==="]")){let c=l.slice(a,l.length-1);u[0]="=",u[1]="=";for(let r of c)this.tokens.push(Pi(r[0],r[1],{pre:0,row:r[2],col:r[3],len:r[4]}));return this.tokens.push(Pi(".",".",{pre:0,row:this.row,col:this.col,len:1})),t.length}}if(u&&(t==="="||_f.has(t))){if(t==="="&&(u[1]==="||"||u[1]==="&&"||u[1]==="??")&&!u.spaced)return u[0]="COMPOUND_ASSIGN",u[1]+="=",t.length}if(t==="("&&u?.[0]==="IMPORT")u[0]="DYNAMIC_IMPORT";if(t==="{"&&this.seenImport)this.importSpecifierList=!0;if(t==="}"&&this.importSpecifierList)this.importSpecifierList=!1;if(t==="{"&&u?.[0]==="EXPORT")this.exportSpecifierList=!0;if(t==="}"&&this.exportSpecifierList)this.exportSpecifierList=!1;if(t===";")this.seenFor=this.seenImport=this.seenExport=!1,this.inTypeAnnotation=!1,i="TERMINATOR";else if(t==="::"&&/^[a-zA-Z_$]/.test(this.chunk[2]||""))return this.emit(".","."),this.emit("PROPERTY","prototype"),this.emit(".","."),2;else if(t==="::")i="TYPE_ANNOTATION",this.inTypeAnnotation=!0;else if(t==="~=")i="COMPUTED_ASSIGN";else if(t===":=")i="REACTIVE_ASSIGN";else if(t==="<=>")i="BIND";else if(t==="<~")i="GATE",this.inTypeAnnotation=!1;else if(t==="~>")i="EFFECT",this.inTypeAnnotation=!1;else if(t==="=!")i="READONLY_ASSIGN",this.inTypeAnnotation=!1;else if(t==="*>"&&(!u||u[0]==="TERMINATOR"||u[0]==="INDENT"||u[0]==="OUTDENT")&&(/^[a-zA-Z_$]/.test(this.chunk[2]||"")||this.chunk[2]==="@")){let l=this.chunk.slice(2),a=/^@(\s*)=(?!=)/.exec(l);if(a){let r=a[1];this.emit("IDENTIFIER","Object"),this.emit(".",".");let h=this.emit("PROPERTY","assign");return h.spaced=!0,this.emit("@","@"),this.emit(",",","),3+r.length+1}let c=/^(@?(?:(?!\s)[$\w\x7f-\uffff])+(?:\.[a-zA-Z_$][\w]*)*)(\s*)=(?!=)/.exec(l);if(c){let r=c[1],h=c[2],o=r[0]==="@",s=o?r.slice(1):r,w=s?s.split("."):[],_=()=>{if(o){if(this.emit("@","@"),w.length>0)this.emit("PROPERTY",w[0])}else this.emit("IDENTIFIER",w[0]);for(let y=1;y<w.length;y++)this.emit(".","."),this.emit("PROPERTY",w[y])};_(),this.emit("=","="),this.emit("IDENTIFIER","Object"),this.emit(".","."),this.emit("PROPERTY","assign"),this.emit("CALL_START","("),_(),this.emit("COMPOUND_ASSIGN","??="),this.emit("{","{"),this.emit("}","}"),this.emit(",",",");let A=this.prev();return A.mergeClose=!0,2+r.length+h.length+1}}else if(t==="*"&&u?.[0]==="EXPORT")i="EXPORT_ALL";else if(Ve.has(t))i="MATH";else if(je.has(t))i="COMPARE";else if(_f.has(t))i="COMPOUND_ASSIGN";else if(pe.has(t))i="UNARY_MATH";else if(Le.has(t))i="SHIFT";else if(t==="?"&&u?.spaced)i="TERNARY";else if(t==="?!"&&u&&!u.spaced)i="PRESENCE";else if(t==="?"&&(this.chunk[1]==="["||this.chunk[1]==="("))i="?.";else if(u){if(t==="("&&!u.spaced&&Xi.has(u[0])){if(u[0]==="?.")u[0]="ES6_OPTIONAL_CALL";i="CALL_START"}if(t==="["&&!u.spaced&&bi.has(u[0])){if(i="INDEX_START",u[0]==="?.")u[0]="ES6_OPTIONAL_INDEX"}}if(this.inTypeAnnotation&&(t==="="||i==="COMPOUND_ASSIGN"))this.inTypeAnnotation=!1;if(t==="="){let l=this.tokens.length;if(l>=2&&this.tokens[l-1][0]==="IDENTIFIER"&&this.tokens[l-2][0]==="IDENTIFIER"&&this.tokens[l-2][1]==="type"&&(l===2||this.tokens[l-3][0]==="TERMINATOR"||this.tokens[l-3][0]==="INDENT"||this.tokens[l-3][0]==="OUTDENT"||this.tokens[l-3][0]==="EXPORT"))this.inTypeAnnotation=!0}if(t==="("||t==="{"||t==="[")this.ends.push({tag:Be[t],origin:[i,t]});else if(t===")"||t==="}"||t==="]")this.pair(t);return this.emit(i,t,{len:t.length}),t.length}tagParameters(){let n=this.tokens.length-1;if(this.tokens[n]?.[0]!==")"){let t=this.tokens.length,i=0,u=t-1,l=-1;while(u>=0){let a=this.tokens[u],c=a[0];if(c===")"||c==="]"||c==="}"||c==="CALL_END"||c==="PARAM_END"||c==="INDEX_END"||c==="COMPARE"&&a[1]===">")i++;else if(c==="("||c==="["||c==="{"||c==="CALL_START"||c==="PARAM_START"||c==="INDEX_START"||c==="COMPARE"&&a[1]==="<")i--;else if(i===0){if(c==="TYPE_ANNOTATION"||c===":"){if(u>0&&this.tokens[u-1][0]===")")l=u-1;break}if(c==="TERMINATOR"||c==="INDENT"||c==="OUTDENT"||c==="="||c==="->"||c==="=>")break}u--}if(l<0)return this.tagDoIife();n=l}else{let t=0,i=-1;for(let u=n;u>=0;u--){let l=this.tokens[u][0];if(l===")"||l==="CALL_END"||l==="PARAM_END")t++;else if(l==="("||l==="CALL_START"||l==="PARAM_START"){if(--t===0){i=u;break}}}if(i>1&&this.tokens[i-1][0]==="TYPE_ANNOTATION"&&this.tokens[i-2]?.[0]===")")n=i-2}let f=n,e=[];this.tokens[f][0]="PARAM_END";while(f-- >0){let t=this.tokens[f];if(t[0]===")")e.push(t);else if(t[0]==="("||t[0]==="CALL_START")if(e.length)e.pop();else if(t[0]==="(")return t[0]="PARAM_START",this.tagDoIife(f-1);else{this.tokens[n][0]="CALL_END";return}}}tagDoIife(n){let f=this.tokens[n??this.tokens.length-1];if(f?.[0]==="DO")f[0]="DO_IIFE"}rewrite(n){return this.tokens=n,this.removeLeadingNewlines(),this.rewriteDottedPicks(),this.rewriteMapLiterals(),this.closeMergeAssignments(),this.closeOpenCalls(),this.closeOpenIndexes(),this.rewriteTypes(),this.normalizeLines(),this.rewriteRender?.(),this.rewriteSchema?.(),this.tagPostfixConditionals(),this.rewriteTaggedTemplates(),this.addImplicitBracesAndParens(),this.addImplicitCallCommas(),this.tokens}removeLeadingNewlines(){let n=0;while(this.tokens[n]?.[0]==="TERMINATOR")n++;if(n>0)this.tokens.splice(0,n)}rewriteMapLiterals(){let n=this.tokens;for(let f=0;f<n.length;f++){if(n[f][0]!=="MATH"||n[f][1]!=="*")continue;let e=n[f+1];if(!e||e[0]!=="{")continue;if(n[f].spaced||n[f].newLine)continue;let t=n[f-1];if(t&&bi.has(t[0]))continue;n.splice(f,1),n[f][0]="MAP_START";let i=1;for(let u=f+1;u<n.length&&i>0;u++){let l=n[u][0];if(l==="{"||l==="MAP_START")i++;if(l==="}"){if(i--,i===0)n[u][0]="MAP_END"}}}}rewriteDottedPicks(){let n=this.tokens;for(let f=0;f<n.length;f++){let e=n[f][0];if(e!=="."&&e!=="?.")continue;let t=n[f+1];if(!t||t[0]!=="{")continue;if(n[f].spaced||n[f].newLine)continue;let i=n[f-1];if(!i||!bi.has(i[0]))continue;let u=e==="?.";n.splice(f,1),n[f][0]=u?"OPTPICK_START":"PICK_START";let l=1;for(let a=f+1;a<n.length&&l>0;a++){let c=n[a][0];if(c==="{"||c==="PICK_START"||c==="OPTPICK_START")l++;else if(c==="}"){if(l--,l===0){n[a][0]="PICK_END";break}}}}}closeOpenCalls(){this.scanTokens((n,f)=>{if(n[0]==="CALL_START")this.detectEnd(f+1,(e)=>e[0]===")"||e[0]==="CALL_END",(e)=>e[0]="CALL_END");return 1})}closeOpenIndexes(){this.scanTokens((n,f)=>{if(n[0]==="INDEX_START")this.detectEnd(f+1,(e)=>e[0]==="]"||e[0]==="INDEX_END",(e,t)=>{if(this.tokens[t+1]?.[0]===":")n[0]="[",e[0]="]";else e[0]="INDEX_END"});return 1})}normalizeLines(){let n=null,f=null,e=null,t=(u,l)=>{return u[1]!==";"&&ve.has(u[0])&&!(u[0]==="TERMINATOR"&&hf.has(this.tokens[l+1]?.[0]))&&!(u[0]==="ELSE"&&n!=="THEN")||u[0]==="INDENT"&&!u.generated&&(n==="->"||n==="=>")||u[0]===","&&(n==="->"||n==="=>"||n==="THEN"||n==="ELSE")&&!this.commaInImplicitCall(l)&&!this.commaInImplicitObject(l)||of.has(u[0])&&(this.tokens[l-1]?.newLine||this.tokens[l-1]?.[0]==="OUTDENT")},i=(u,l)=>{let a=this.tokens[l-1]?.[0]===","?l-1:l;this.tokens.splice(a,0,e)};this.scanTokens((u,l,a)=>{let[c]=u;if(c==="TERMINATOR"){if(this.tokens[l+1]?.[0]==="ELSE"&&this.tokens[l-1]?.[0]!=="OUTDENT")return a.splice(l,1,...this.makeIndentation()),1;if(hf.has(this.tokens[l+1]?.[0]))return a.splice(l,1),0}if(c==="CATCH")for(let r=1;r<=2;r++){let h=this.tokens[l+r]?.[0];if(h==="OUTDENT"||h==="TERMINATOR"||h==="FINALLY")return a.splice(l+r,0,...this.makeIndentation()),2+r}if((c==="->"||c==="=>")&&(this.tokens[l+1]?.[0]===","||this.tokens[l+1]?.[0]==="]"))return[f,e]=this.makeIndentation(),a.splice(l+1,0,f,e),1;if(sf.has(c)&&this.tokens[l+1]?.[0]!=="INDENT"&&!(c==="ELSE"&&this.tokens[l+1]?.[0]==="IF")&&!(c==="ELSE"&&this.tokens[l-1]?.[0]!=="OUTDENT")){if(n=c,[f,e]=this.makeIndentation(),c==="THEN")f.fromThen=!0;if(a.splice(l+1,0,f),c==="THEN"&&this.singleLineOwner(l)==="LEADING_WHEN")this.detectWhenThenEnd(l+2,t,i);else this.detectEnd(l+2,t,i);if(c==="THEN")a.splice(l,1);return 1}return 1})}singleLineOwner(n){let f=new Set(["LEADING_WHEN","IF","POST_IF","UNLESS","POST_UNLESS","ELSE","CATCH","TRY","FINALLY","->","=>"]);for(let e=n-1;e>=0;e--){let t=this.tokens[e],i=t?.[0];if(f.has(i))return i;if(si.has(i)||t?.newLine)return null}return null}detectWhenThenEnd(n,f,e){let t=0,i=0;while(n<this.tokens.length){let u=this.tokens[n],l=u[0];if(t===0){if(l==="THEN"&&this.singleLineOwner(n)!=="LEADING_WHEN")i++;else if(l==="ELSE"&&i>0)i--;else if(f.call(this,u,n))return e.call(this,u,n)}if(jn.has(l))t++;if(Cn.has(l))t--;if(t<0)return e.call(this,u,n);n++}}tagPostfixConditionals(){let n=null,f=(t,i)=>{return t[0]==="TERMINATOR"||t[0]==="INDENT"&&!sf.has(this.tokens[i-1]?.[0])},e=(t)=>{if(t[0]!=="INDENT"||t.generated&&!t.fromThen)n[0]="POST_"+n[0]};this.scanTokens((t,i)=>{if(t[0]!=="IF"&&t[0]!=="UNLESS")return 1;if(this.tokens[i-1]?.[0]==="INTERPOLATION_START")return 1;return n=t,this.detectEnd(i+1,f,e),1})}rewriteTaggedTemplates(){let n=this.tokens;for(let f=n.length-2;f>=0;f--)if(n[f][0]==="IDENTIFIER"&&n[f][1]==="$"&&(n[f+1]?.[0]==="STRING"||n[f+1]?.[0]==="STRING_START")){let e=n[f-1];if(e&&Ie.has(e[0])){if(n.splice(f,1),e.spaced=!1,n[f].spaced=!1,n[f].pre=0,n[f].newLine)n[f].newLine=!1}}}addImplicitBracesAndParens(){let n=[],f=!1;this.scanTokens((e,t,i)=>{let[u]=e,l=i[t-1]||[],a=i[t+1]||[],[c]=l,[r]=a,h=t,o=(E)=>t-h+E,s=()=>n[n.length-1],w=(E)=>E?.[2]?.ours,_=()=>w(s())&&s()?.[0]==="(",A=()=>w(s())&&s()?.[0]==="{",y=(E)=>{n.push(["(",E,{ours:!0}]),i.splice(E,0,On("CALL_START","("))},R=()=>{n.pop(),i.splice(t,0,On("CALL_END",")")),t+=1},U=(E,Z={})=>{n.push(["{",E,{sameLine:!0,startsLine:Z.startsLine??!0,ours:!0}]);let Q=On("{","{");if(!Q.data)Q.data={};Q.data.generated=!0,i.splice(E,0,Q)},m=(E)=>{E=E??t,n.pop(),i.splice(E,0,On("}","}")),t+=1},D=u==="FOR"&&!e.newLine&&Ce.has(c);if((_()||A())&&ge.has(u)&&!D)return n.push(["CONTROL",t,{ours:!0}]),o(1);if(u==="INDENT"&&w(s())){if(c!=="=>"&&c!=="->"&&c!=="["&&c!=="("&&c!==","&&c!=="{"&&c!=="ELSE"&&c!=="=")while(_()||A()&&c!==":")if(_())R();else m();if(s()?.[2]?.ours&&s()[0]==="CONTROL")n.pop();return n.push([u,t]),o(1)}if(jn.has(u))return n.push([u,t]),o(1);if(Cn.has(u)){while(w(s()))if(_())R();else if(A())m();else n.pop();n.pop()}let M=!1;if(r==="-"&&!a.spaced&&!a.newLine&&ti(e))for(let E=t;E<i.length-2;E+=2){if(!Ni(i[E+1],i[E+2]))break;if(!ti(i[E+2]))break;if(i[E+3]?.[0]===":"){M=!0;break}}if(!M&&rl.has(u)&&e.spaced&&(Gi.has(r)||r==="..."&&Gi.has(i[t+2]?.[0])||be.has(r)&&!a.spaced&&!a.newLine)&&!((u==="]"||u==="}")&&(r==="->"||r==="=>")))return y(t+1),o(2);if(rl.has(u)&&this.tokens[t+1]?.[0]==="INDENT"&&this.looksObjectish(t+2)&&!this.findTagsBackwards(t,["CLASS","EXTENDS","IF","CATCH","SWITCH","LEADING_WHEN","FOR","WHILE","UNTIL"]))return y(t+1),n.push(["INDENT",t+2]),o(3);if(u==="TERNARY")f=!0;if(u===":"){if(f)return f=!1,o(1);if(ti(i[t-1])&&Ni(i[t-2],i[t-1])){let Q=t-2;while(Q>=2&&Ni(i[Q],i[Q+1])&&ti(i[Q-1]))Q-=2;if(Q+=1,ti(i[Q])){let W="";for(let L=Q;L<t;L++)W+=i[L][1];let C=On("STRING",`"${W}"`,i[Q]);C.pre=i[Q].pre,C.spaced=i[Q].spaced,C.newLine=i[Q].newLine,C.loc=i[Q].loc,i.splice(Q,t-Q,C),t=Q+1}}let E=Cn.has(this.tokens[t-1]?.[0])?n[n.length-1]?.[1]??t-1:t-1;if(this.tokens[t-2]?.[0]==="@")E=t-2;let Z=E<=0||si.has(this.tokens[E-1]?.[0])||this.tokens[E-1]?.newLine;if(s()){let[Q,W]=s(),C=n[n.length-2],L=(X)=>X==="{"||X==="MAP_START"||X==="PICK_START"||X==="OPTPICK_START";if((L(Q)||Q==="INDENT"&&L(C?.[0])&&!w(C))&&(Z||this.tokens[E-1]?.[0]===","||L(this.tokens[E-1]?.[0])||L(this.tokens[E]?.[0])))return o(1)}return U(E,{startsLine:!!Z}),o(2)}if(si.has(u))for(let E=n.length-1;E>=0;E--){if(!w(n[E]))break;if(n[E][0]==="{")n[E][2].sameLine=!1}let q=c==="OUTDENT"||l.newLine,S=u==="||"||u==="&&"||u==="??",d=!1;if(S){let E=t+1,Z=i[E]?.[0];if(Z==="("||Z==="["||Z==="{"){for(let Q=1;++E<i.length&&Q>0;)if(Z=i[E][0],Z==="("||Z==="["||Z==="{")Q++;else if(Z===")"||Z==="]"||Z==="}")Q--}else if(Z&&Z!=="TERMINATOR"&&Z!=="OUTDENT"&&Z!==",")E++;d=i[E]?.[0]===","}let K=(E)=>{for(let Z=0;E<i.length;E++){let Q=i[E][0];if(Q==="("||Q==="["||Q==="{"||Q==="CALL_START"||Q==="INDEX_START"||Q==="INDENT")Z++;else if(Q===")"||Q==="]"||Q==="}"||Q==="CALL_END"||Q==="INDEX_END"||Q==="OUTDENT"){if(Z===0)return!1;Z--}else if(Q==="TERMINATOR"&&Z===0)return this.looksObjectish(E+1)}return!1};if(Pe.has(u)&&!d||of.has(u)&&q)while(w(s())){let[E,,{sameLine:Z,startsLine:Q}]=s();if(_()&&c!==",")R();else if(A()&&!S&&Z&&u!=="TERMINATOR"&&c!==":"&&!((u==="POST_IF"||u==="POST_UNLESS")&&K(t+1)))m();else if(A()&&u==="TERMINATOR"&&c!==","&&!(Q&&this.looksObjectish(t+1)))m();else if(s()?.[2]?.ours&&s()[0]==="CONTROL"&&i[s()[1]]?.[0]==="CLASS"&&u==="TERMINATOR")n.pop();else break}if(u===","&&!this.looksObjectish(t+1)&&A()&&(r!=="TERMINATOR"||!this.looksObjectish(t+2))){let E=r==="OUTDENT"?1:0;while(A())m(t+E)}return o(1)})}addImplicitCallCommas(){let n=0,f=0,e=this.tokens;while(f<e.length){let t=e[f][0],i=f>0?e[f-1][0]:null;if(t==="CALL_START"||t==="(")n++;if(t==="CALL_END"||t===")")n--;if(n>0&&(t==="->"||t==="=>")&&Oe.has(i))e.splice(f,0,On(",",",")),f++;f++}}scanTokens(n){let f=0;while(f<this.tokens.length)f+=n.call(this,this.tokens[f],f,this.tokens)}detectEnd(n,f,e,t={}){let i=0;while(n<this.tokens.length){let u=this.tokens[n];if(i===0&&f.call(this,u,n))return e.call(this,u,n);if(jn.has(u[0]))i++;if(Cn.has(u[0]))i--;if(i<0){if(t.returnOnNegativeLevel)return;return e.call(this,u,n)}n++}}closeMergeAssignments(){let n=this.tokens;for(let f=0;f<n.length;f++){if(!n[f].mergeClose)continue;let e=0;for(let t=f+1;t<n.length;t++){let i=n[t][0];if(i==="("||i==="["||i==="{"||i==="CALL_START"||i==="INDEX_START"||i==="INDENT")e++;if(i===")"||i==="]"||i==="}"||i==="CALL_END"||i==="INDEX_END"||i==="OUTDENT")e--;if(e<0||e===0&&i==="TERMINATOR"){n.splice(t,0,On("CALL_END",")",n[t-1]));break}if(t===n.length-1){n.splice(t+1,0,On("CALL_END",")",n[t]));break}}}}commaInImplicitCall(n){let f=0;for(let e=n-1;e>=0;e--){let t=this.tokens[e][0];if(Cn.has(t)){f++;continue}if(jn.has(t)){if(t==="INDENT")return!1;if(f--,f<0)return!1;continue}if(f>0)continue;if(rl.has(t)&&this.tokens[e].spaced){let i=this.tokens[e+1]?.[0];return Gi.has(i)||i==="..."&&Gi.has(this.tokens[e+2]?.[0])}}return!1}commaInImplicitObject(n){let f=0;for(let e=n-1;e>=0;e--){let t=this.tokens[e][0];if(Cn.has(t)){f++;continue}if(jn.has(t)){if(f--,f<0)return!1;continue}if(f>0)continue;if(t===":"&&e>0&&this.tokens[e-1][0]==="PROPERTY")return this.looksObjectish(n+1);if(si.has(t))return!1}return!1}looksObjectish(n){if(!this.tokens[n])return!1;if(this.tokens[n]?.[0]==="@"&&this.tokens[n+2]?.[0]===":")return!0;if(this.tokens[n+1]?.[0]===":")return!0;if(ti(this.tokens[n]))for(let f=n+1;f<this.tokens.length;f+=2){if(!Ni(this.tokens[f],this.tokens[f+1]))break;if(!ti(this.tokens[f+1]))break;if(this.tokens[f+2]?.[0]===":")return!0}if(jn.has(this.tokens[n]?.[0])){let f=null;if(this.detectEnd(n+1,(e)=>Cn.has(e[0]),(e,t)=>f=t),f&&this.tokens[f+1]?.[0]===":")return!0}return!1}findTagsBackwards(n,f){let e=new Set(f),t=[];while(n>=0){let i=this.tokens[n]?.[0];if(!t.length&&e.has(i))return!0;if(Cn.has(i))t.push(i);if(jn.has(i)&&t.length)t.pop();if(!t.length&&(jn.has(i)&&!this.tokens[n]?.generated||si.has(i)))break;n--}return!1}makeIndentation(n){let f=On("INDENT",2),e=On("OUTDENT",2);if(n)f.generated=e.generated=!0,f.origin=e.origin=n;else f.explicit=e.explicit=!0;return[f,e]}}tf(vn);Yi(vn);var Dt=["abort","animationcancel","animationend","animationiteration","animationstart","auxclick","beforeinput","beforematch","beforetoggle","blur","cancel","canplay","canplaythrough","change","click","close","compositionend","compositionstart","compositionupdate","contextlost","contextmenu","contextrestored","copy","cuechange","cut","dblclick","drag","dragend","dragenter","dragleave","dragover","dragstart","drop","durationchange","emptied","ended","error","focus","focusin","focusout","formdata","fullscreenchange","fullscreenerror","gotpointercapture","input","invalid","keydown","keypress","keyup","load","loadeddata","loadedmetadata","loadstart","lostpointercapture","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","paste","pause","play","playing","pointercancel","pointerdown","pointerenter","pointerleave","pointermove","pointerout","pointerover","pointerrawupdate","pointerup","progress","ratechange","reset","resize","scroll","scrollend","securitypolicyviolation","seeked","seeking","select","selectionchange","selectstart","slotchange","stalled","submit","suspend","timeupdate","toggle","touchcancel","touchend","touchmove","touchstart","transitioncancel","transitionend","transitionrun","transitionstart","volumechange","waiting","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend","wheel"],Df=new Set(Dt);var Rt=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"];var Mt=["animate","animateMotion","animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tspan","use","view"],Ut=["math","param","portal"],Rf=new Set([...Rt,...Ut]),Ln=new Set(Mt),ai=new Set([...Rf,...Ln]);var Mf="__bind_",Uf="__",hl=new Set(["beforeMount","mounted","beforeUnmount","unmounted","onError"]),qf="{ status?: number; message?: string; error?: Error; path?: string }",qt=new Set(["disabled","hidden","readonly","required","checked","selected","autofocus","autoplay","controls","loop","muted","multiple","novalidate","open","reversed","defer","async","formnovalidate","allowfullscreen","inert"]),sl="http://www.w3.org/2000/svg";function St(n){for(let f of n){if(!Array.isArray(f))continue;let e=f[1]instanceof String?f[1].valueOf():f[1],t=f[2]instanceof String?f[2].valueOf():f[2];if(e==="type"&&typeof t==="string")return t.replace(/^["']|["']$/g,"")}return null}function pn(n){if(typeof n==="string"||n instanceof String)return n.valueOf();if(Array.isArray(n)&&n[0]==="."&&n[1]==="this"&&(typeof n[2]==="string"||n[2]instanceof String))return n[2].valueOf();return null}function ol(n){return Array.isArray(n)&&n[0]==="."&&n[1]==="this"}function qi(n){if(n instanceof String&&n.type)return n.type;if(Array.isArray(n)&&n[2]instanceof String&&n[2].type)return n[2].type;return null}function Oi(n){if(n instanceof String&&n.optional)return!0;if(Array.isArray(n)&&n[2]instanceof String&&n[2].optional)return!0;return!1}function Sf(n){let f=[];while(Array.isArray(n)&&n[0]==="."){let e=n[2];if(!(typeof e==="string"||e instanceof String))return null;f.unshift(e.valueOf()),n=n[1]}if(typeof n==="string"||n instanceof String)f.unshift(n.valueOf());else return null;return f}function Et(n){let f,e=n;if(Array.isArray(n)&&Array.isArray(n[0])&&n[0][0]==="."){if(n.length!==2)return{error:"a keyed gate takes exactly one key argument"};e=n[0],f=n[1]}let t=Sf(e);if(!t)return{error:"'<~' requires a literal @app.data.… path on the right-hand side"};if(t[0]==="this")t.shift();if(t[0]!=="app"||t[1]!=="data"||t.length<3)return{error:"'<~' requires a literal @app.data.… path on the right-hand side"};return{path:t.slice(2).join("."),keyExpr:f}}function dt(n){let f={error:"a keyed gate key may only reference params or query (e.g. params.id)"},e=typeof n==="string"||n instanceof String?n.valueOf():null;if(e!=null){if(/^-?[\d.]/.test(e)||e.startsWith('"')||e.startsWith("'"))return{code:e,stubCode:e};return f}let t=Sf(n);if(!t)return f;if(t[0]==="this")t.shift();if(t[0]!=="params"&&t[0]!=="query"||t.length<2)return f;let i=t.join(".");return{code:i,stubCode:`this.${i}`}}function Ef(n,f){let e=(r,h)=>r instanceof String?r[h]:void 0,t=f.prototype.classifyKeyword;f.prototype.classifyKeyword=function(r,h,o){if(r==="offer"||r==="accept"){let s=0;for(let w=this.tokens.length-1;w>=0;w--){let _=this.tokens[w][0];if(_==="OUTDENT")s++;else if(_==="INDENT")s--;if(s<0&&this.tokens[w-1]?.[0]==="COMPONENT")return r.toUpperCase()}return h}return t.call(this,r,h,o)},f.prototype.rewriteRender=function(){let r=(m,D,M)=>{let q=[m,D];if(q.pre=0,q.data=null,q.loc=M?.loc??{r:0,c:0,n:0},q.spaced=!1,q.newLine=!1,q.generated=!0,M)q.origin=M;return q},h=!1,o=0,s=0,w=[],_=(m)=>{let D=m.split("#")[0];return ai.has(D)},A=(m)=>{if(!m||typeof m!=="string")return!1;return/^[A-Z][A-Za-z0-9]*[a-z][A-Za-z0-9]*$/.test(m)},y=(m)=>{return _(m)||A(m)},R=(m,D,M,q)=>{let S=1,d=D;while(d>=0&&S>0){let K=m[d][0];if(K===M)S++;else if(K===q)S--;if(S>0)d--}return d},U=(m,D)=>{let M=D;while(M>0&&m[M][0]==="OUTDENT")M=R(m,M-1,"OUTDENT","INDENT");while(M>0){let q=m[M-1][0];if(q==="TERMINATOR"||q==="RENDER")break;if(q==="OUTDENT"){M=R(m,M-2,"OUTDENT","INDENT");continue}if(q==="INDENT"){let S=m[M][0];if(S==="CALL_END"||S===")"){M=R(m,M-1,S,S==="CALL_END"?"CALL_START":"(");continue}break}if(q==="CALL_END"||q===")"){M=R(m,M-2,q,q==="CALL_END"?"CALL_START":"(");continue}if(q==="INTERPOLATION_END"){M=R(m,M-2,"INTERPOLATION_END","INTERPOLATION_START");continue}if(q==="STRING_END"){M=R(m,M-2,"STRING_END","STRING_START");continue}M--}return m[M]&&m[M][0]==="IDENTIFIER"&&(y(m[M][1])||(M===0||m[M-1][0]==="INDENT"||m[M-1][0]==="TERMINATOR"||m[M-1][0]==="RENDER"))};this.scanTokens(function(m,D,M){let q=m[0],S=D<M.length-1?M[D+1]:null;if(q==="RENDER")return h=!0,o=s+1,1;if(q==="INDENT")return s++,1;if(q==="OUTDENT"){s--;let d=0;while(w.length>0&&w[w.length-1]>s){let K=r("CALL_END",")",m);M.splice(D+1+d,0,K),w.pop(),d++}if(h&&s<o)h=!1;return 1+d}if(!h)return 1;if(q==="="&&D>0){let d=M[D-1][0];if(d==="TERMINATOR"||d==="INDENT"||d==="RENDER"){let K=r("IDENTIFIER","__text__",m),E=r("CALL_START","(",m);return M.splice(D,1,K,E),this.detectEnd(D+2,(Z)=>Z[0]==="TERMINATOR"||Z[0]==="OUTDENT",(Z,Q)=>M.splice(Q,0,r("CALL_END",")",Z)),{returnOnNegativeLevel:!0}),2}}if(q==="UNARY_MATH"&&m[1]==="~"&&S&&S[0]==="IDENTIFIER"){m[0]="PROPERTY",m[1]="__transition__";let d=r(":",":",m),K=r("STRING",`"${S[1]}"`,S);return M.splice(D+1,1,d,K),1}if(q==="PROPERTY"&&m[1][0]==="$"&&m[1].length>1)return m[0]="STRING",m[1]=`"data-${m[1].slice(1)}"`,1;if(q==="IDENTIFIER"&&!m.spaced){let d=[m[1]],K=D+1;while(K+1<M.length){let E=M[K],Z=M[K+1];if(E[0]==="-"&&!E.spaced&&(Z[0]==="IDENTIFIER"||Z[0]==="PROPERTY")){if(d.push(Z[1]),K+=2,Z[0]==="PROPERTY")break}else break}if(d.length>1&&K>D+1&&M[K-1][0]==="PROPERTY"){let E=d.join("-");if(E[0]==="$")E="data-"+E.slice(1);return m[0]="STRING",m[1]=`"${E}"`,M.splice(D+1,K-D-1),1}}if(q==="."){let d=D>0?M[D-1]:null,K=d?d[0]:null;if(K==="INDENT"||K==="TERMINATOR"){if(S&&S[0]==="PROPERTY"){let E=D+2<M.length?M[D+2]:null;if(!E||E[0]!==":"){let Z=r("IDENTIFIER","div",m);return M.splice(D,0,Z),2}}if(!S||S[0]!=="(")return m[0]="IDENTIFIER",m[1]="div",0}}if(q==="IDENTIFIER"||q==="PROPERTY"){let d=M[D+1],K=M[D+2];if(d&&d[0]==="#"&&K&&(K[0]==="PROPERTY"||K[0]==="IDENTIFIER")){if(m[1]=m[1]+"#"+K[1],K.spaced)m.spaced=!0;return M.splice(D+1,2),0}}if(q==="BIND"){let d=D>0?M[D-1]:null,K=M[D+1];if(d&&(d[0]==="IDENTIFIER"||d[0]==="PROPERTY")&&K&&K[0]==="IDENTIFIER")return d[1]=`__bind_${d[1]}__`,m[0]=":",m[1]=":",1}if(q==="@"){let d=D+1;if(d<M.length&&M[d][0]==="PROPERTY"){d++;while(d+1<M.length&&M[d][0]==="."&&M[d+1][0]==="PROPERTY")d+=2;if(d>D+2&&d<M.length&&M[d][0]===":"){let K=r("[","[",m);M.splice(D,0,K);let E=r("]","]",M[d+1]);return M.splice(d+1,0,E),2}}}if(q==="."&&S&&S[0]==="("){let d=D>0?M[D-1]:null,K=d?d[0]:null,E=K==="INDENT"||K==="TERMINATOR",Z=r("PROPERTY","__clsx",m);S[0]="CALL_START";let Q=1;for(let W=D+2;W<M.length&&Q>0;W++)if(M[W][0]==="("||M[W][0]==="CALL_START")Q++;else if(M[W][0]===")"){if(Q--,Q===0)M[W][0]="CALL_END"}else if(M[W][0]==="CALL_END")Q--;if(E){let W=r("IDENTIFIER","div",m);return M.splice(D,0,W),M.splice(D+2,0,Z),3}else if(K===":")return M[D]=r("IDENTIFIER","__clsx",m),1;else return M.splice(D+1,0,Z),2}if(S&&S[0]==="INDENT"){if(S.fromThen)return 1;if(q==="->"||q==="=>"||q==="CALL_START"||q==="(")return 1;let d=!1,K=D>0?M[D-1][0]:null,E=K==="IF"||K==="UNLESS"||K==="WHILE"||K==="UNTIL"||K==="WHEN"||K==="FORIN"||K==="FOROF"||K==="FORAS"||K==="FORASAWAIT"||K==="BY",Z=!1;if(q==="CALL_END"){let W=1;for(let C=D-1;C>=0&&W>0;C--)if(M[C][0]==="CALL_END")W++;else if(M[C][0]==="CALL_START"){if(W--,W===0&&C>0&&M[C-1][0]==="PROPERTY"&&M[C-1][1]==="__clsx")Z=!0}}let Q=q==="IDENTIFIER"&&(K==="INDENT"||K==="TERMINATOR"||K==="RENDER");if(Z)d=!0;else if(q==="IDENTIFIER"&&y(m[1])&&!E)d=!0;else if(q==="IDENTIFIER"&&!E)d=Q||U(M,D);else if(q==="PROPERTY"||q==="STRING"||q==="STRING_END"||q==="NUMBER"||q==="BOOL"||q==="CALL_END"||q===")"||q==="]"||q==="INDEX_END"||q==="}"||q==="MAP_END"||q==="PRESENCE")d=U(M,D);if(d){let W=!1;if(q==="PROPERTY"&&D>0&&M[D-1][0]==="."){let L=D;while(L>=2&&M[L-1][0]==="."&&M[L-2][0]==="PROPERTY")L-=2;if(L>=2&&M[L-1][0]==="."&&M[L-2][0]==="IDENTIFIER"&&y(M[L-2][1])){let X=L>=3?M[L-3][0]:null;if(!X||X==="INDENT"||X==="OUTDENT"||X==="TERMINATOR"||X==="RENDER")W=!0}}if(Z||q==="IDENTIFIER"&&(y(m[1])||Q)||W){let L=r("CALL_START","(",m),X=r("->","->",m);return X.newLine=!0,M.splice(D+1,0,L,X),w.push(s+1),3}else{let L=r(",",",",m),X=r("->","->",m);return X.newLine=!0,M.splice(D+1,0,L,X),3}}}if(q==="IDENTIFIER"&&A(m[1])&&S&&(S[0]==="OUTDENT"||S[0]==="TERMINATOR"))return M.splice(D+1,0,r("CALL_START","(",m),r("CALL_END",")",m)),3;return 1})};let i=n.prototype;i.isHtmlTag=function(r){let h=r.split("#")[0];return ai.has(h.toLowerCase())},i.isComponent=function(r){if(!r||typeof r!=="string")return!1;return/^[A-Z][A-Za-z0-9]*[a-z][A-Za-z0-9]*$/.test(r)},i.collectTemplateClasses=function(r){let h=[],o=r;while(this.is(o,".")){let A=o[2];if(typeof A==="string"||A instanceof String)h.unshift(A.valueOf());o=o[1]}let s=typeof o==="string"?o:o instanceof String?o.valueOf():null;if(s===null)return{tag:null,classes:h,id:void 0,base:o};let[w,_]=s.split("#");if(!w)w="div";return{tag:w,classes:h,id:_,base:o}};let u=(r)=>typeof r==="string"?r:r instanceof String?r.valueOf():null,l=(r,h)=>{if(!(r instanceof String))return h;let o=new String(h);if(r.optional)o.optional=!0;if(r.bang)o.bang=!0;return o.optional||o.bang?o:h};i.addBodyRipSrcMarkers=function(r,h){if(typeof r!=="string"||!r)return r;let o=Array.isArray(h)&&h[0]==="block"?h.slice(1):Array.isArray(h)?[h]:[];if(o.length===0)return r;let s=(y)=>{if(y==null)return null;if(!Array.isArray(y))return y?.loc?.r??null;if(y.loc?.r)return y.loc.r;if(y[0]?.loc?.r)return y[0].loc.r;for(let R of y){if(R?.loc?.r)return R.loc.r;if(Array.isArray(R)){let U=s(R);if(U!=null)return U}}return null},w=o.map(s);if(w.every((y)=>y==null))return r;let _=r.split(`
1872
+ `,{len:0})}isUnfinished(){if(this.inRenderBlock&&Af.test(this.chunk)&&/^\s*\./.test(this.chunk))return!1;if(this.inRenderBlock&&this.prevTag()==="."){let e=this.tokens.length;if(e>=2){let t=this.tokens[e-2][0];if(t==="INDENT"||t==="TERMINATOR"||t==="OUTDENT")return!1}}let n=this.tokens[this.tokens.length-1];if(n?.[0]==="COMPARE"&&n[1]===">"||n?.[0]==="SHIFT"&&(n[1]===">>"||n[1]===">>>")){let e=0;for(let t=this.tokens.length-1;t>=0;t--){let i=this.tokens[t];if(i[0]==="COMPARE"&&i[1]===">")e++;else if(i[0]==="SHIFT"&&i[1]===">>")e+=2;else if(i[0]==="SHIFT"&&i[1]===">>>")e+=3;else if(i[0]==="COMPARE"&&i[1]==="<")e--;if(e===0&&i[0]==="TYPE_ANNOTATION")return!1;if(e===0&&i[0]===":"){let u=this.tokens[t-1];if(u&&(u[0]===")"||u[0]==="PARAM_END"||u[0]==="CALL_END"))return!1}if(e===0&&i[0]==="IDENTIFIER"&&i[1]==="type")return!1;if(i[0]==="INTERFACE")return!1;if(i[0]==="TERMINATOR"||i[0]==="INDENT"||i[0]==="OUTDENT"){let u=-1;if(i[0]==="INDENT")u=t;else{let l=i[0]==="OUTDENT"?1:0;for(let a=t-1;a>=0;a--){let c=this.tokens[a];if(c[0]==="OUTDENT")l++;else if(c[0]==="INDENT"){if(l===0){u=a;break}l--}}}if(u>0)for(let l=u-1;l>=0;l--){let a=this.tokens[l];if(a[0]==="TERMINATOR"||a[0]==="INDENT"||a[0]==="OUTDENT")break;if(a[0]==="INTERFACE")return!1;if(a[0]==="IDENTIFIER"&&a[1]==="type"){let c=this.tokens[l-1];if(!c||c[0]==="TERMINATOR"||c[0]==="EXPORT")return!1;break}}break}}}return Af.test(this.chunk)||wf.has(this.prevTag())}pair(n){let f=this.ends[this.ends.length-1];if(!f||n!==f.tag){if(f?.tag==="OUTDENT"){let e=this.indents[this.indents.length-1];if(e)this.outdentTo(this.indent-e);return this.pair(n)}Pn(`unmatched ${n}`,{row:this.row,col:this.col})}return this.ends.pop()}stringToken(){let n=et.exec(this.chunk);if(!n)return 0;let f=n[0],e=f.length>1&&f.endsWith("\\"),t=e?f.slice(0,-1):f,i=this.prev();if(i&&this.prevVal()==="from"&&(this.seenImport||this.seenExport))i[0]="FROM";let u;switch(t){case"'":u=tt;break;case'"':u=at;break;case"'''":u=rt;break;case'"""':u=ct;break}let{tokens:l,index:a}=this.matchWithInterpolations(u,f,t),c=t.length===3,r=null;if(c)r=this.processHeredocIndent(a,t,l);return this.mergeInterpolationTokens(l,{quote:t,indent:r,endOffset:a,raw:e}),a}processHeredocIndent(n,f,e){let t=n-f.length,i=t-1;while(i>=0&&this.chunk[i]!==`
1873
+ `)i--;i++;let u=this.chunk.slice(i,t),l=/^\s*$/.test(u)?u.length:null,a="";for(let h of e)if(h[0]==="NEOSTRING")a+=h[1];let c=null,r;mf.lastIndex=0;while(r=mf.exec(a))if(c===null||r[1].length>0&&r[1].length<c.length)c=r[1];if(l===null)return c;if(c===null)return" ".repeat(l);if(l<=c.length)return" ".repeat(l);return c}matchWithInterpolations(n,f,e,t){if(!e)e=f;if(!t)t=/^[#$]\{/;let i=[],u=f.length;if(this.chunk.slice(0,u)!==f)return null;let l=this.chunk.slice(u);while(!0){let[a]=n.exec(l);i.push(["NEOSTRING",a,{offset:u}]),l=l.slice(a.length),u+=a.length;let c=t.exec(l);if(!c)break;let h=c[0].length-1,o=l.slice(h),s=new vn().tokenize(o,{row:this.row,col:this.col+u+h,untilBalanced:!0,rewrite:!1}),w=s.index+h;if(l[w-1]==="}"){let A=s.tokens[0],y=s.tokens[s.tokens.length-1];A[0]="INTERPOLATION_START",A[1]="(",y[0]="INTERPOLATION_END",y[1]=")"}if(s.tokens[1]?.[0]==="TERMINATOR")s.tokens.splice(1,1);let _=s.tokens.length;if(_>2&&s.tokens[_-3]?.[0]==="INDENT"&&s.tokens[_-2]?.[0]==="OUTDENT")s.tokens.splice(_-3,2);i.push(["TOKENS",s.tokens]),l=l.slice(w),u+=w}if(l.slice(0,e.length)!==e)Pn(`missing ${e}`,{row:this.row,col:this.col});return{tokens:i,index:u+e.length}}mergeInterpolationTokens(n,{quote:f,indent:e,endOffset:t,raw:i}){if(n.length>1)this.emit("STRING_START","(",{len:f?.length||0,data:{quote:f}});for(let u=0;u<n.length;u++){let[l,a]=n[u];if(l==="TOKENS")for(let c of a)this.tokens.push(c);else if(l==="NEOSTRING"){let c=a;if(e){let r=new RegExp("\\n"+e,"g");c=c.replace(r,`
1874
+ `)}if(u===0&&f?.length===3)c=c.replace(/^\n/,"");if(u===n.length-1&&f?.length===3)c=c.replace(/\n[^\S\n]*$/,"");if(i)c=c.replace(/\\([nrtbfv0\\'"`xu])/g,"\\\\$1");this.emit("STRING",`"${c}"`,{len:a.length,data:{quote:f}})}}if(n.length>1)this.emit("STRING_END",")",{len:f?.length||0});return t}numberToken(){let n=$e.exec(this.chunk);if(!n)return 0;let f=n[0],e=f.length,t={row:this.row,col:this.col};if(/^0[BOX]/.test(f))Pn(`radix prefix in '${f}' must be lowercase`,{...t,col:t.col+1});if(/^0\d*[89]/.test(f))Pn(`decimal literal '${f}' must not be prefixed with '0'`,{...t,len:e});if(/^0\d+/.test(f))Pn(`octal literal '${f}' must be prefixed with '0o'`,{...t,len:e});let i=At(f),u=i===1/0?"INFINITY":"NUMBER",l={parsedValue:i};if(u==="INFINITY")l.original=f;return this.emit(u,f,{len:e,data:l}),e}regexToken(){let n=this.matchWithInterpolations(ot,"///");if(n){let{tokens:r,index:h}=n,[o]=yf.exec(this.chunk.slice(h)),s=h+o.length;if(r.length===1||!r.some((w)=>w[0]==="TOKENS")){let w=(r[0]?.[1]||"").replace(/(?<!\\)\//g,"\\/");this.emit("REGEX",`/${w}/${o}`,{len:s,data:{delimiter:"///",heregex:{flags:o}}})}else{if(this.emit("REGEX_START","(",{len:0}),this.emit("IDENTIFIER","RegExp",{len:0}),this.emit("CALL_START","(",{len:0}),this.mergeInterpolationTokens(r,{quote:"///",endOffset:s-o.length}),o)this.emit(",",",",{len:0}),this.emit("STRING",`"${o}"`,{len:o.length});this.emit(")",")",{len:0}),this.emit("REGEX_END",")",{len:0})}return s}let f=ht.exec(this.chunk);if(!f)return 0;let[e,t,i]=f,u=this.prev();if(u){if(u.spaced&&Xi.has(u[0])&&(!i||/^\/=?\s/.test(e)))return 0;if(Te.has(u[0])&&!(u.spaced&&Xi.has(u[0])))return 0}if(!i)Pn("missing / (unclosed regex)",{row:this.row,col:this.col});let l=e.length,[a]=yf.exec(this.chunk.slice(l)),c=l+a.length;if(!st.test(a))Pn(`invalid regular expression flags ${a}`,{row:this.row,col:this.col+l,len:a.length});return this.emit("REGEX",`/${t}/${a}`,{len:c,data:{delimiter:"/"}}),c}jsToken(){if(this.chunk[0]!=="`")return 0;let n=_t.exec(this.chunk)||wt.exec(this.chunk);if(!n)return 0;let f=n[1],e=n[0].length;return this.emit("JS",f,{len:e,data:{here:n[0].startsWith("```")}}),e}wordLiteral(){if(this.chunk[0]!=="%"||this.chunk[1]!=="w")return 0;let n=this.chunk[2];if(!n||/\s/.test(n))return 0;let e={"[":"]","(":")","{":"}","<":">"}[n]||n,t=e!==n,i=1,u=3;while(u<this.chunk.length&&i>0){let r=this.chunk[u];if(r==="\\"){u+=2;continue}if(t&&r===n)i++;if(r===e)i--;if(i>0)u++}if(i!==0)return 0;let l=this.chunk.slice(3,u),a=u+1,c=[];if(l.trim()){let r=l.trim().split(/(?<!\\)\s+/);for(let h of r)c.push(h.replace(/\\ /g," "))}this.emit("[","[",{len:a});for(let r=0;r<c.length;r++){if(r>0)this.emit(",",",");this.emit("STRING",`"${c[r]}"`)}return this.emit("]","]"),a}symbolToken(){if(this.chunk[0]!==":")return 0;let n=this.chunk[1];if(!n||n==="="||n===":"||/\s/.test(n))return 0;if(!/[a-zA-Z_$]/.test(n))return 0;let f=/^((?:(?!\s)[$\w\x7f-\uffff])+)/.exec(this.chunk.slice(1));if(!f)return 0;let e=f[1],t=e.length+1;return this.emit("SYMBOL",e,{len:t}),t}literalToken(){let n=this.wordLiteral();if(n)return n;let f=this.symbolToken();if(f)return f;let e=ke.exec(this.chunk),t=e?e[0]:this.chunk.charAt(0),i=t,u=this.prev();if(ft.test(t))this.tagParameters();if(t==="="&&u&&u[1]==="."&&!u.spaced){let l=this.tokens,a=l.length-2;while(a>=1&&l[a][0]==="PROPERTY"&&l[a-1]?.[1]===".")a-=2;if(a>=0&&(l[a][0]==="IDENTIFIER"||l[a][0]===")"||l[a][0]==="]")){let c=l.slice(a,l.length-1);u[0]="=",u[1]="=";for(let r of c)this.tokens.push(Pi(r[0],r[1],{pre:0,row:r[2],col:r[3],len:r[4]}));return this.tokens.push(Pi(".",".",{pre:0,row:this.row,col:this.col,len:1})),t.length}}if(u&&(t==="="||_f.has(t))){if(t==="="&&(u[1]==="||"||u[1]==="&&"||u[1]==="??")&&!u.spaced)return u[0]="COMPOUND_ASSIGN",u[1]+="=",t.length}if(t==="("&&u?.[0]==="IMPORT")u[0]="DYNAMIC_IMPORT";if(t==="{"&&this.seenImport)this.importSpecifierList=!0;if(t==="}"&&this.importSpecifierList)this.importSpecifierList=!1;if(t==="{"&&u?.[0]==="EXPORT")this.exportSpecifierList=!0;if(t==="}"&&this.exportSpecifierList)this.exportSpecifierList=!1;if(t===";")this.seenFor=this.seenImport=this.seenExport=!1,this.inTypeAnnotation=!1,i="TERMINATOR";else if(t==="::"&&/^[a-zA-Z_$]/.test(this.chunk[2]||""))return this.emit(".","."),this.emit("PROPERTY","prototype"),this.emit(".","."),2;else if(t==="::")Pn("type annotations use a single ':' (e.g. `x: number`), not '::'",{row:this.row,col:this.col,len:2});else if(t==="~=")i="COMPUTED_ASSIGN";else if(t===":=")i="REACTIVE_ASSIGN";else if(t==="<=>")i="BIND";else if(t==="<~")i="GATE",this.inTypeAnnotation=!1;else if(t==="~>")i="EFFECT",this.inTypeAnnotation=!1;else if(t==="=!")i="READONLY_ASSIGN",this.inTypeAnnotation=!1;else if(t==="*>"&&(!u||u[0]==="TERMINATOR"||u[0]==="INDENT"||u[0]==="OUTDENT")&&(/^[a-zA-Z_$]/.test(this.chunk[2]||"")||this.chunk[2]==="@")){let l=this.chunk.slice(2),a=/^@(\s*)=(?!=)/.exec(l);if(a){let r=a[1];this.emit("IDENTIFIER","Object"),this.emit(".",".");let h=this.emit("PROPERTY","assign");return h.spaced=!0,this.emit("@","@"),this.emit(",",","),3+r.length+1}let c=/^(@?(?:(?!\s)[$\w\x7f-\uffff])+(?:\.[a-zA-Z_$][\w]*)*)(\s*)=(?!=)/.exec(l);if(c){let r=c[1],h=c[2],o=r[0]==="@",s=o?r.slice(1):r,w=s?s.split("."):[],_=()=>{if(o){if(this.emit("@","@"),w.length>0)this.emit("PROPERTY",w[0])}else this.emit("IDENTIFIER",w[0]);for(let y=1;y<w.length;y++)this.emit(".","."),this.emit("PROPERTY",w[y])};_(),this.emit("=","="),this.emit("IDENTIFIER","Object"),this.emit(".","."),this.emit("PROPERTY","assign"),this.emit("CALL_START","("),_(),this.emit("COMPOUND_ASSIGN","??="),this.emit("{","{"),this.emit("}","}"),this.emit(",",",");let A=this.prev();return A.mergeClose=!0,2+r.length+h.length+1}}else if(t==="*"&&u?.[0]==="EXPORT")i="EXPORT_ALL";else if(Ve.has(t))i="MATH";else if(je.has(t))i="COMPARE";else if(_f.has(t))i="COMPOUND_ASSIGN";else if(pe.has(t))i="UNARY_MATH";else if(Le.has(t))i="SHIFT";else if(t==="?"&&u?.spaced)i="TERNARY";else if(t==="?!"&&u&&!u.spaced)i="PRESENCE";else if(t==="?"&&(this.chunk[1]==="["||this.chunk[1]==="("))i="?.";else if(u){if(t==="("&&!u.spaced&&Xi.has(u[0])){if(u[0]==="?.")u[0]="ES6_OPTIONAL_CALL";i="CALL_START"}if(t==="["&&!u.spaced&&bi.has(u[0])){if(i="INDEX_START",u[0]==="?.")u[0]="ES6_OPTIONAL_INDEX"}}if(this.inTypeAnnotation&&(t==="="||i==="COMPOUND_ASSIGN"))this.inTypeAnnotation=!1;if(t==="="){let l=this.tokens.length;if(l>=2&&this.tokens[l-1][0]==="IDENTIFIER"&&this.tokens[l-2][0]==="IDENTIFIER"&&this.tokens[l-2][1]==="type"&&(l===2||this.tokens[l-3][0]==="TERMINATOR"||this.tokens[l-3][0]==="INDENT"||this.tokens[l-3][0]==="OUTDENT"||this.tokens[l-3][0]==="EXPORT"))this.inTypeAnnotation=!0}if(t==="("||t==="{"||t==="[")this.ends.push({tag:Be[t],origin:[i,t]});else if(t===")"||t==="}"||t==="]")this.pair(t);return this.emit(i,t,{len:t.length}),t.length}tagParameters(){let n=this.tokens.length-1;if(this.tokens[n]?.[0]!==")"){let t=this.tokens.length,i=0,u=t-1,l=-1;while(u>=0){let a=this.tokens[u],c=a[0];if(c===")"||c==="]"||c==="}"||c==="CALL_END"||c==="PARAM_END"||c==="INDEX_END"||c==="COMPARE"&&a[1]===">")i++;else if(c==="("||c==="["||c==="{"||c==="CALL_START"||c==="PARAM_START"||c==="INDEX_START"||c==="COMPARE"&&a[1]==="<")i--;else if(i===0){if(c==="TYPE_ANNOTATION"||c===":"){if(u>0&&this.tokens[u-1][0]===")")l=u-1;break}if(c==="TERMINATOR"||c==="INDENT"||c==="OUTDENT"||c==="="||c==="->"||c==="=>")break}u--}if(l<0)return this.tagDoIife();n=l}else{let t=0,i=-1;for(let u=n;u>=0;u--){let l=this.tokens[u][0];if(l===")"||l==="CALL_END"||l==="PARAM_END")t++;else if(l==="("||l==="CALL_START"||l==="PARAM_START"){if(--t===0){i=u;break}}}if(i>1&&this.tokens[i-1][0]==="TYPE_ANNOTATION"&&this.tokens[i-2]?.[0]===")")n=i-2}let f=n,e=[];this.tokens[f][0]="PARAM_END";while(f-- >0){let t=this.tokens[f];if(t[0]===")")e.push(t);else if(t[0]==="("||t[0]==="CALL_START")if(e.length)e.pop();else if(t[0]==="(")return t[0]="PARAM_START",this.tagDoIife(f-1);else{this.tokens[n][0]="CALL_END";return}}}tagDoIife(n){let f=this.tokens[n??this.tokens.length-1];if(f?.[0]==="DO")f[0]="DO_IIFE"}rewrite(n){return this.tokens=n,this.removeLeadingNewlines(),this.rewriteDottedPicks(),this.rewriteMapLiterals(),this.closeMergeAssignments(),this.closeOpenCalls(),this.closeOpenIndexes(),this.rewriteTypes(),this.normalizeLines(),this.rewriteRender?.(),this.rewriteSchema?.(),this.tagPostfixConditionals(),this.rewriteTaggedTemplates(),this.addImplicitBracesAndParens(),this.addImplicitCallCommas(),this.tokens}removeLeadingNewlines(){let n=0;while(this.tokens[n]?.[0]==="TERMINATOR")n++;if(n>0)this.tokens.splice(0,n)}rewriteMapLiterals(){let n=this.tokens;for(let f=0;f<n.length;f++){if(n[f][0]!=="MATH"||n[f][1]!=="*")continue;let e=n[f+1];if(!e||e[0]!=="{")continue;if(n[f].spaced||n[f].newLine)continue;let t=n[f-1];if(t&&bi.has(t[0]))continue;n.splice(f,1),n[f][0]="MAP_START";let i=1;for(let u=f+1;u<n.length&&i>0;u++){let l=n[u][0];if(l==="{"||l==="MAP_START")i++;if(l==="}"){if(i--,i===0)n[u][0]="MAP_END"}}}}rewriteDottedPicks(){let n=this.tokens;for(let f=0;f<n.length;f++){let e=n[f][0];if(e!=="."&&e!=="?.")continue;let t=n[f+1];if(!t||t[0]!=="{")continue;if(n[f].spaced||n[f].newLine)continue;let i=n[f-1];if(!i||!bi.has(i[0]))continue;let u=e==="?.";n.splice(f,1),n[f][0]=u?"OPTPICK_START":"PICK_START";let l=1;for(let a=f+1;a<n.length&&l>0;a++){let c=n[a][0];if(c==="{"||c==="PICK_START"||c==="OPTPICK_START")l++;else if(c==="}"){if(l--,l===0){n[a][0]="PICK_END";break}}}}}closeOpenCalls(){this.scanTokens((n,f)=>{if(n[0]==="CALL_START")this.detectEnd(f+1,(e)=>e[0]===")"||e[0]==="CALL_END",(e)=>e[0]="CALL_END");return 1})}closeOpenIndexes(){this.scanTokens((n,f)=>{if(n[0]==="INDEX_START")this.detectEnd(f+1,(e)=>e[0]==="]"||e[0]==="INDEX_END",(e,t)=>{if(this.tokens[t+1]?.[0]===":")n[0]="[",e[0]="]";else e[0]="INDEX_END"});return 1})}normalizeLines(){let n=null,f=null,e=null,t=(u,l)=>{return u[1]!==";"&&ve.has(u[0])&&!(u[0]==="TERMINATOR"&&hf.has(this.tokens[l+1]?.[0]))&&!(u[0]==="ELSE"&&n!=="THEN")||u[0]==="INDENT"&&!u.generated&&(n==="->"||n==="=>")||u[0]===","&&(n==="->"||n==="=>"||n==="THEN"||n==="ELSE")&&!this.commaInImplicitCall(l)&&!this.commaInImplicitObject(l)||of.has(u[0])&&(this.tokens[l-1]?.newLine||this.tokens[l-1]?.[0]==="OUTDENT")},i=(u,l)=>{let a=this.tokens[l-1]?.[0]===","?l-1:l;this.tokens.splice(a,0,e)};this.scanTokens((u,l,a)=>{let[c]=u;if(c==="TERMINATOR"){if(this.tokens[l+1]?.[0]==="ELSE"&&this.tokens[l-1]?.[0]!=="OUTDENT")return a.splice(l,1,...this.makeIndentation()),1;if(hf.has(this.tokens[l+1]?.[0]))return a.splice(l,1),0}if(c==="CATCH")for(let r=1;r<=2;r++){let h=this.tokens[l+r]?.[0];if(h==="OUTDENT"||h==="TERMINATOR"||h==="FINALLY")return a.splice(l+r,0,...this.makeIndentation()),2+r}if((c==="->"||c==="=>")&&(this.tokens[l+1]?.[0]===","||this.tokens[l+1]?.[0]==="]"))return[f,e]=this.makeIndentation(),a.splice(l+1,0,f,e),1;if(sf.has(c)&&this.tokens[l+1]?.[0]!=="INDENT"&&!(c==="ELSE"&&this.tokens[l+1]?.[0]==="IF")&&!(c==="ELSE"&&this.tokens[l-1]?.[0]!=="OUTDENT")){if(n=c,[f,e]=this.makeIndentation(),c==="THEN")f.fromThen=!0;if(a.splice(l+1,0,f),c==="THEN"&&this.singleLineOwner(l)==="LEADING_WHEN")this.detectWhenThenEnd(l+2,t,i);else this.detectEnd(l+2,t,i);if(c==="THEN")a.splice(l,1);return 1}return 1})}singleLineOwner(n){let f=new Set(["LEADING_WHEN","IF","POST_IF","UNLESS","POST_UNLESS","ELSE","CATCH","TRY","FINALLY","->","=>"]);for(let e=n-1;e>=0;e--){let t=this.tokens[e],i=t?.[0];if(f.has(i))return i;if(si.has(i)||t?.newLine)return null}return null}detectWhenThenEnd(n,f,e){let t=0,i=0;while(n<this.tokens.length){let u=this.tokens[n],l=u[0];if(t===0){if(l==="THEN"&&this.singleLineOwner(n)!=="LEADING_WHEN")i++;else if(l==="ELSE"&&i>0)i--;else if(f.call(this,u,n))return e.call(this,u,n)}if(jn.has(l))t++;if(Cn.has(l))t--;if(t<0)return e.call(this,u,n);n++}}tagPostfixConditionals(){let n=null,f=(t,i)=>{return t[0]==="TERMINATOR"||t[0]==="INDENT"&&!sf.has(this.tokens[i-1]?.[0])},e=(t)=>{if(t[0]!=="INDENT"||t.generated&&!t.fromThen)n[0]="POST_"+n[0]};this.scanTokens((t,i)=>{if(t[0]!=="IF"&&t[0]!=="UNLESS")return 1;if(this.tokens[i-1]?.[0]==="INTERPOLATION_START")return 1;return n=t,this.detectEnd(i+1,f,e),1})}rewriteTaggedTemplates(){let n=this.tokens;for(let f=n.length-2;f>=0;f--)if(n[f][0]==="IDENTIFIER"&&n[f][1]==="$"&&(n[f+1]?.[0]==="STRING"||n[f+1]?.[0]==="STRING_START")){let e=n[f-1];if(e&&Ie.has(e[0])){if(n.splice(f,1),e.spaced=!1,n[f].spaced=!1,n[f].pre=0,n[f].newLine)n[f].newLine=!1}}}addImplicitBracesAndParens(){let n=[],f=!1;this.scanTokens((e,t,i)=>{let[u]=e,l=i[t-1]||[],a=i[t+1]||[],[c]=l,[r]=a,h=t,o=(E)=>t-h+E,s=()=>n[n.length-1],w=(E)=>E?.[2]?.ours,_=()=>w(s())&&s()?.[0]==="(",A=()=>w(s())&&s()?.[0]==="{",y=(E)=>{n.push(["(",E,{ours:!0}]),i.splice(E,0,Bn("CALL_START","("))},R=()=>{n.pop(),i.splice(t,0,Bn("CALL_END",")")),t+=1},U=(E,Z={})=>{n.push(["{",E,{sameLine:!0,startsLine:Z.startsLine??!0,ours:!0}]);let Q=Bn("{","{");if(!Q.data)Q.data={};Q.data.generated=!0,i.splice(E,0,Q)},m=(E)=>{E=E??t,n.pop(),i.splice(E,0,Bn("}","}")),t+=1},D=u==="FOR"&&!e.newLine&&Ce.has(c);if((_()||A())&&ge.has(u)&&!D)return n.push(["CONTROL",t,{ours:!0}]),o(1);if(u==="INDENT"&&w(s())){if(c!=="=>"&&c!=="->"&&c!=="["&&c!=="("&&c!==","&&c!=="{"&&c!=="ELSE"&&c!=="=")while(_()||A()&&c!==":")if(_())R();else m();if(s()?.[2]?.ours&&s()[0]==="CONTROL")n.pop();return n.push([u,t]),o(1)}if(jn.has(u))return n.push([u,t]),o(1);if(Cn.has(u)){while(w(s()))if(_())R();else if(A())m();else n.pop();n.pop()}let M=!1;if(r==="-"&&!a.spaced&&!a.newLine&&ti(e))for(let E=t;E<i.length-2;E+=2){if(!Ni(i[E+1],i[E+2]))break;if(!ti(i[E+2]))break;if(i[E+3]?.[0]===":"){M=!0;break}}if(!M&&rl.has(u)&&e.spaced&&(Gi.has(r)||r==="..."&&Gi.has(i[t+2]?.[0])||be.has(r)&&!a.spaced&&!a.newLine)&&!((u==="]"||u==="}")&&(r==="->"||r==="=>")))return y(t+1),o(2);if(rl.has(u)&&this.tokens[t+1]?.[0]==="INDENT"&&this.looksObjectish(t+2)&&!this.findTagsBackwards(t,["CLASS","EXTENDS","IF","CATCH","SWITCH","LEADING_WHEN","FOR","WHILE","UNTIL"]))return y(t+1),n.push(["INDENT",t+2]),o(3);if(u==="TERNARY")f=!0;if(u===":"){if(f)return f=!1,o(1);if(ti(i[t-1])&&Ni(i[t-2],i[t-1])){let Q=t-2;while(Q>=2&&Ni(i[Q],i[Q+1])&&ti(i[Q-1]))Q-=2;if(Q+=1,ti(i[Q])){let W="";for(let L=Q;L<t;L++)W+=i[L][1];let C=Bn("STRING",`"${W}"`,i[Q]);C.pre=i[Q].pre,C.spaced=i[Q].spaced,C.newLine=i[Q].newLine,C.loc=i[Q].loc,i.splice(Q,t-Q,C),t=Q+1}}let E=Cn.has(this.tokens[t-1]?.[0])?n[n.length-1]?.[1]??t-1:t-1;if(this.tokens[t-2]?.[0]==="@")E=t-2;let Z=E<=0||si.has(this.tokens[E-1]?.[0])||this.tokens[E-1]?.newLine;if(s()){let[Q,W]=s(),C=n[n.length-2],L=(X)=>X==="{"||X==="MAP_START"||X==="PICK_START"||X==="OPTPICK_START";if((L(Q)||Q==="INDENT"&&L(C?.[0])&&!w(C))&&(Z||this.tokens[E-1]?.[0]===","||L(this.tokens[E-1]?.[0])||L(this.tokens[E]?.[0])))return o(1)}return U(E,{startsLine:!!Z}),o(2)}if(si.has(u))for(let E=n.length-1;E>=0;E--){if(!w(n[E]))break;if(n[E][0]==="{")n[E][2].sameLine=!1}let q=c==="OUTDENT"||l.newLine,S=u==="||"||u==="&&"||u==="??",d=!1;if(S){let E=t+1,Z=i[E]?.[0];if(Z==="("||Z==="["||Z==="{"){for(let Q=1;++E<i.length&&Q>0;)if(Z=i[E][0],Z==="("||Z==="["||Z==="{")Q++;else if(Z===")"||Z==="]"||Z==="}")Q--}else if(Z&&Z!=="TERMINATOR"&&Z!=="OUTDENT"&&Z!==",")E++;d=i[E]?.[0]===","}let K=(E)=>{for(let Z=0;E<i.length;E++){let Q=i[E][0];if(Q==="("||Q==="["||Q==="{"||Q==="CALL_START"||Q==="INDEX_START"||Q==="INDENT")Z++;else if(Q===")"||Q==="]"||Q==="}"||Q==="CALL_END"||Q==="INDEX_END"||Q==="OUTDENT"){if(Z===0)return!1;Z--}else if(Q==="TERMINATOR"&&Z===0)return this.looksObjectish(E+1)}return!1};if(Pe.has(u)&&!d||of.has(u)&&q)while(w(s())){let[E,,{sameLine:Z,startsLine:Q}]=s();if(_()&&c!==",")R();else if(A()&&!S&&Z&&u!=="TERMINATOR"&&c!==":"&&!((u==="POST_IF"||u==="POST_UNLESS")&&K(t+1)))m();else if(A()&&u==="TERMINATOR"&&c!==","&&!(Q&&this.looksObjectish(t+1)))m();else if(s()?.[2]?.ours&&s()[0]==="CONTROL"&&i[s()[1]]?.[0]==="CLASS"&&u==="TERMINATOR")n.pop();else break}if(u===","&&!this.looksObjectish(t+1)&&A()&&(r!=="TERMINATOR"||!this.looksObjectish(t+2))){let E=r==="OUTDENT"?1:0;while(A())m(t+E)}return o(1)})}addImplicitCallCommas(){let n=0,f=0,e=this.tokens;while(f<e.length){let t=e[f][0],i=f>0?e[f-1][0]:null;if(t==="CALL_START"||t==="(")n++;if(t==="CALL_END"||t===")")n--;if(n>0&&(t==="->"||t==="=>")&&Oe.has(i))e.splice(f,0,Bn(",",",")),f++;f++}}scanTokens(n){let f=0;while(f<this.tokens.length)f+=n.call(this,this.tokens[f],f,this.tokens)}detectEnd(n,f,e,t={}){let i=0;while(n<this.tokens.length){let u=this.tokens[n];if(i===0&&f.call(this,u,n))return e.call(this,u,n);if(jn.has(u[0]))i++;if(Cn.has(u[0]))i--;if(i<0){if(t.returnOnNegativeLevel)return;return e.call(this,u,n)}n++}}closeMergeAssignments(){let n=this.tokens;for(let f=0;f<n.length;f++){if(!n[f].mergeClose)continue;let e=0;for(let t=f+1;t<n.length;t++){let i=n[t][0];if(i==="("||i==="["||i==="{"||i==="CALL_START"||i==="INDEX_START"||i==="INDENT")e++;if(i===")"||i==="]"||i==="}"||i==="CALL_END"||i==="INDEX_END"||i==="OUTDENT")e--;if(e<0||e===0&&i==="TERMINATOR"){n.splice(t,0,Bn("CALL_END",")",n[t-1]));break}if(t===n.length-1){n.splice(t+1,0,Bn("CALL_END",")",n[t]));break}}}}commaInImplicitCall(n){let f=0;for(let e=n-1;e>=0;e--){let t=this.tokens[e][0];if(Cn.has(t)){f++;continue}if(jn.has(t)){if(t==="INDENT")return!1;if(f--,f<0)return!1;continue}if(f>0)continue;if(rl.has(t)&&this.tokens[e].spaced){let i=this.tokens[e+1]?.[0];return Gi.has(i)||i==="..."&&Gi.has(this.tokens[e+2]?.[0])}}return!1}commaInImplicitObject(n){let f=0;for(let e=n-1;e>=0;e--){let t=this.tokens[e][0];if(Cn.has(t)){f++;continue}if(jn.has(t)){if(f--,f<0)return!1;continue}if(f>0)continue;if(t===":"&&e>0&&this.tokens[e-1][0]==="PROPERTY")return this.looksObjectish(n+1);if(si.has(t))return!1}return!1}looksObjectish(n){if(!this.tokens[n])return!1;if(this.tokens[n]?.[0]==="@"&&this.tokens[n+2]?.[0]===":")return!0;if(this.tokens[n+1]?.[0]===":")return!0;if(ti(this.tokens[n]))for(let f=n+1;f<this.tokens.length;f+=2){if(!Ni(this.tokens[f],this.tokens[f+1]))break;if(!ti(this.tokens[f+1]))break;if(this.tokens[f+2]?.[0]===":")return!0}if(jn.has(this.tokens[n]?.[0])){let f=null;if(this.detectEnd(n+1,(e)=>Cn.has(e[0]),(e,t)=>f=t),f&&this.tokens[f+1]?.[0]===":")return!0}return!1}findTagsBackwards(n,f){let e=new Set(f),t=[];while(n>=0){let i=this.tokens[n]?.[0];if(!t.length&&e.has(i))return!0;if(Cn.has(i))t.push(i);if(jn.has(i)&&t.length)t.pop();if(!t.length&&(jn.has(i)&&!this.tokens[n]?.generated||si.has(i)))break;n--}return!1}makeIndentation(n){let f=Bn("INDENT",2),e=Bn("OUTDENT",2);if(n)f.generated=e.generated=!0,f.origin=e.origin=n;else f.explicit=e.explicit=!0;return[f,e]}}tf(vn);Yi(vn);var Dt=["abort","animationcancel","animationend","animationiteration","animationstart","auxclick","beforeinput","beforematch","beforetoggle","blur","cancel","canplay","canplaythrough","change","click","close","compositionend","compositionstart","compositionupdate","contextlost","contextmenu","contextrestored","copy","cuechange","cut","dblclick","drag","dragend","dragenter","dragleave","dragover","dragstart","drop","durationchange","emptied","ended","error","focus","focusin","focusout","formdata","fullscreenchange","fullscreenerror","gotpointercapture","input","invalid","keydown","keypress","keyup","load","loadeddata","loadedmetadata","loadstart","lostpointercapture","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","paste","pause","play","playing","pointercancel","pointerdown","pointerenter","pointerleave","pointermove","pointerout","pointerover","pointerrawupdate","pointerup","progress","ratechange","reset","resize","scroll","scrollend","securitypolicyviolation","seeked","seeking","select","selectionchange","selectstart","slotchange","stalled","submit","suspend","timeupdate","toggle","touchcancel","touchend","touchmove","touchstart","transitioncancel","transitionend","transitionrun","transitionstart","volumechange","waiting","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend","wheel"],Df=new Set(Dt);var Rt=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"];var Mt=["animate","animateMotion","animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tspan","use","view"],Ut=["math","param","portal"],Rf=new Set([...Rt,...Ut]),Ln=new Set(Mt),ai=new Set([...Rf,...Ln]);var Mf="__bind_",Uf="__",hl=new Set(["beforeMount","mounted","beforeUnmount","unmounted","onError"]),qf="{ status?: number; message?: string; error?: Error; path?: string }",qt=new Set(["disabled","hidden","readonly","required","checked","selected","autofocus","autoplay","controls","loop","muted","multiple","novalidate","open","reversed","defer","async","formnovalidate","allowfullscreen","inert"]),sl="http://www.w3.org/2000/svg";function St(n){for(let f of n){if(!Array.isArray(f))continue;let e=f[1]instanceof String?f[1].valueOf():f[1],t=f[2]instanceof String?f[2].valueOf():f[2];if(e==="type"&&typeof t==="string")return t.replace(/^["']|["']$/g,"")}return null}function pn(n){if(typeof n==="string"||n instanceof String)return n.valueOf();if(Array.isArray(n)&&n[0]==="."&&n[1]==="this"&&(typeof n[2]==="string"||n[2]instanceof String))return n[2].valueOf();return null}function ol(n){return Array.isArray(n)&&n[0]==="."&&n[1]==="this"}function qi(n){if(n instanceof String&&n.type)return n.type;if(Array.isArray(n)&&n[2]instanceof String&&n[2].type)return n[2].type;return null}function Oi(n){if(n instanceof String&&n.optional)return!0;if(Array.isArray(n)&&n[2]instanceof String&&n[2].optional)return!0;return!1}function Sf(n){let f=[];while(Array.isArray(n)&&n[0]==="."){let e=n[2];if(!(typeof e==="string"||e instanceof String))return null;f.unshift(e.valueOf()),n=n[1]}if(typeof n==="string"||n instanceof String)f.unshift(n.valueOf());else return null;return f}function Et(n){let f,e=n;if(Array.isArray(n)&&Array.isArray(n[0])&&n[0][0]==="."){if(n.length!==2)return{error:"a keyed gate takes exactly one key argument"};e=n[0],f=n[1]}let t=Sf(e);if(!t)return{error:"'<~' requires a literal @app.data.… path on the right-hand side"};if(t[0]==="this")t.shift();if(t[0]!=="app"||t[1]!=="data"||t.length<3)return{error:"'<~' requires a literal @app.data.… path on the right-hand side"};return{path:t.slice(2).join("."),keyExpr:f}}function dt(n){let f={error:"a keyed gate key may only reference params or query (e.g. params.id)"},e=typeof n==="string"||n instanceof String?n.valueOf():null;if(e!=null){if(/^-?[\d.]/.test(e)||e.startsWith('"')||e.startsWith("'"))return{code:e,stubCode:e};return f}let t=Sf(n);if(!t)return f;if(t[0]==="this")t.shift();if(t[0]!=="params"&&t[0]!=="query"||t.length<2)return f;let i=t.join(".");return{code:i,stubCode:`this.${i}`}}function Ef(n,f){let e=(r,h)=>r instanceof String?r[h]:void 0,t=f.prototype.classifyKeyword;f.prototype.classifyKeyword=function(r,h,o){if(r==="offer"||r==="accept"){let s=0;for(let w=this.tokens.length-1;w>=0;w--){let _=this.tokens[w][0];if(_==="OUTDENT")s++;else if(_==="INDENT")s--;if(s<0&&this.tokens[w-1]?.[0]==="COMPONENT")return r.toUpperCase()}return h}return t.call(this,r,h,o)},f.prototype.rewriteRender=function(){let r=(m,D,M)=>{let q=[m,D];if(q.pre=0,q.data=null,q.loc=M?.loc??{r:0,c:0,n:0},q.spaced=!1,q.newLine=!1,q.generated=!0,M)q.origin=M;return q},h=!1,o=0,s=0,w=[],_=(m)=>{let D=m.split("#")[0];return ai.has(D)},A=(m)=>{if(!m||typeof m!=="string")return!1;return/^[A-Z][A-Za-z0-9]*[a-z][A-Za-z0-9]*$/.test(m)},y=(m)=>{return _(m)||A(m)},R=(m,D,M,q)=>{let S=1,d=D;while(d>=0&&S>0){let K=m[d][0];if(K===M)S++;else if(K===q)S--;if(S>0)d--}return d},U=(m,D)=>{let M=D;while(M>0&&m[M][0]==="OUTDENT")M=R(m,M-1,"OUTDENT","INDENT");while(M>0){let q=m[M-1][0];if(q==="TERMINATOR"||q==="RENDER")break;if(q==="OUTDENT"){M=R(m,M-2,"OUTDENT","INDENT");continue}if(q==="INDENT"){let S=m[M][0];if(S==="CALL_END"||S===")"){M=R(m,M-1,S,S==="CALL_END"?"CALL_START":"(");continue}break}if(q==="CALL_END"||q===")"){M=R(m,M-2,q,q==="CALL_END"?"CALL_START":"(");continue}if(q==="INTERPOLATION_END"){M=R(m,M-2,"INTERPOLATION_END","INTERPOLATION_START");continue}if(q==="STRING_END"){M=R(m,M-2,"STRING_END","STRING_START");continue}M--}return m[M]&&m[M][0]==="IDENTIFIER"&&(y(m[M][1])||(M===0||m[M-1][0]==="INDENT"||m[M-1][0]==="TERMINATOR"||m[M-1][0]==="RENDER"))};this.scanTokens(function(m,D,M){let q=m[0],S=D<M.length-1?M[D+1]:null;if(q==="RENDER")return h=!0,o=s+1,1;if(q==="INDENT")return s++,1;if(q==="OUTDENT"){s--;let d=0;while(w.length>0&&w[w.length-1]>s){let K=r("CALL_END",")",m);M.splice(D+1+d,0,K),w.pop(),d++}if(h&&s<o)h=!1;return 1+d}if(!h)return 1;if(q==="="&&D>0){let d=M[D-1][0];if(d==="TERMINATOR"||d==="INDENT"||d==="RENDER"){let K=r("IDENTIFIER","__text__",m),E=r("CALL_START","(",m);return M.splice(D,1,K,E),this.detectEnd(D+2,(Z)=>Z[0]==="TERMINATOR"||Z[0]==="OUTDENT",(Z,Q)=>M.splice(Q,0,r("CALL_END",")",Z)),{returnOnNegativeLevel:!0}),2}}if(q==="UNARY_MATH"&&m[1]==="~"&&S&&S[0]==="IDENTIFIER"){m[0]="PROPERTY",m[1]="__transition__";let d=r(":",":",m),K=r("STRING",`"${S[1]}"`,S);return M.splice(D+1,1,d,K),1}if(q==="PROPERTY"&&m[1][0]==="$"&&m[1].length>1)return m[0]="STRING",m[1]=`"data-${m[1].slice(1)}"`,1;if(q==="IDENTIFIER"&&!m.spaced){let d=[m[1]],K=D+1;while(K+1<M.length){let E=M[K],Z=M[K+1];if(E[0]==="-"&&!E.spaced&&(Z[0]==="IDENTIFIER"||Z[0]==="PROPERTY")){if(d.push(Z[1]),K+=2,Z[0]==="PROPERTY")break}else break}if(d.length>1&&K>D+1&&M[K-1][0]==="PROPERTY"){let E=d.join("-");if(E[0]==="$")E="data-"+E.slice(1);return m[0]="STRING",m[1]=`"${E}"`,M.splice(D+1,K-D-1),1}}if(q==="."){let d=D>0?M[D-1]:null,K=d?d[0]:null;if(K==="INDENT"||K==="TERMINATOR"){if(S&&S[0]==="PROPERTY"){let E=D+2<M.length?M[D+2]:null;if(!E||E[0]!==":"){let Z=r("IDENTIFIER","div",m);return M.splice(D,0,Z),2}}if(!S||S[0]!=="(")return m[0]="IDENTIFIER",m[1]="div",0}}if(q==="IDENTIFIER"||q==="PROPERTY"){let d=M[D+1],K=M[D+2];if(d&&d[0]==="#"&&K&&(K[0]==="PROPERTY"||K[0]==="IDENTIFIER")){if(m[1]=m[1]+"#"+K[1],K.spaced)m.spaced=!0;return M.splice(D+1,2),0}}if(q==="BIND"){let d=D>0?M[D-1]:null,K=M[D+1];if(d&&(d[0]==="IDENTIFIER"||d[0]==="PROPERTY")&&K&&K[0]==="IDENTIFIER")return d[1]=`__bind_${d[1]}__`,m[0]=":",m[1]=":",1}if(q==="@"){let d=D+1;if(d<M.length&&M[d][0]==="PROPERTY"){d++;while(d+1<M.length&&M[d][0]==="."&&M[d+1][0]==="PROPERTY")d+=2;if(d>D+2&&d<M.length&&M[d][0]===":"){let K=r("[","[",m);M.splice(D,0,K);let E=r("]","]",M[d+1]);return M.splice(d+1,0,E),2}}}if(q==="."&&S&&S[0]==="("){let d=D>0?M[D-1]:null,K=d?d[0]:null,E=K==="INDENT"||K==="TERMINATOR",Z=r("PROPERTY","__clsx",m);S[0]="CALL_START";let Q=1;for(let W=D+2;W<M.length&&Q>0;W++)if(M[W][0]==="("||M[W][0]==="CALL_START")Q++;else if(M[W][0]===")"){if(Q--,Q===0)M[W][0]="CALL_END"}else if(M[W][0]==="CALL_END")Q--;if(E){let W=r("IDENTIFIER","div",m);return M.splice(D,0,W),M.splice(D+2,0,Z),3}else if(K===":")return M[D]=r("IDENTIFIER","__clsx",m),1;else return M.splice(D+1,0,Z),2}if(S&&S[0]==="INDENT"){if(S.fromThen)return 1;if(q==="->"||q==="=>"||q==="CALL_START"||q==="(")return 1;let d=!1,K=D>0?M[D-1][0]:null,E=K==="IF"||K==="UNLESS"||K==="WHILE"||K==="UNTIL"||K==="WHEN"||K==="FORIN"||K==="FOROF"||K==="FORAS"||K==="FORASAWAIT"||K==="BY",Z=!1;if(q==="CALL_END"){let W=1;for(let C=D-1;C>=0&&W>0;C--)if(M[C][0]==="CALL_END")W++;else if(M[C][0]==="CALL_START"){if(W--,W===0&&C>0&&M[C-1][0]==="PROPERTY"&&M[C-1][1]==="__clsx")Z=!0}}let Q=q==="IDENTIFIER"&&(K==="INDENT"||K==="TERMINATOR"||K==="RENDER");if(Z)d=!0;else if(q==="IDENTIFIER"&&y(m[1])&&!E)d=!0;else if(q==="IDENTIFIER"&&!E)d=Q||U(M,D);else if(q==="PROPERTY"||q==="STRING"||q==="STRING_END"||q==="NUMBER"||q==="BOOL"||q==="CALL_END"||q===")"||q==="]"||q==="INDEX_END"||q==="}"||q==="MAP_END"||q==="PRESENCE")d=U(M,D);if(d){let W=!1;if(q==="PROPERTY"&&D>0&&M[D-1][0]==="."){let L=D;while(L>=2&&M[L-1][0]==="."&&M[L-2][0]==="PROPERTY")L-=2;if(L>=2&&M[L-1][0]==="."&&M[L-2][0]==="IDENTIFIER"&&y(M[L-2][1])){let X=L>=3?M[L-3][0]:null;if(!X||X==="INDENT"||X==="OUTDENT"||X==="TERMINATOR"||X==="RENDER")W=!0}}if(Z||q==="IDENTIFIER"&&(y(m[1])||Q)||W){let L=r("CALL_START","(",m),X=r("->","->",m);return X.newLine=!0,M.splice(D+1,0,L,X),w.push(s+1),3}else{let L=r(",",",",m),X=r("->","->",m);return X.newLine=!0,M.splice(D+1,0,L,X),3}}}if(q==="IDENTIFIER"&&A(m[1])&&S&&(S[0]==="OUTDENT"||S[0]==="TERMINATOR"))return M.splice(D+1,0,r("CALL_START","(",m),r("CALL_END",")",m)),3;return 1})};let i=n.prototype;i.isHtmlTag=function(r){let h=r.split("#")[0];return ai.has(h.toLowerCase())},i.isComponent=function(r){if(!r||typeof r!=="string")return!1;return/^[A-Z][A-Za-z0-9]*[a-z][A-Za-z0-9]*$/.test(r)},i.collectTemplateClasses=function(r){let h=[],o=r;while(this.is(o,".")){let A=o[2];if(typeof A==="string"||A instanceof String)h.unshift(A.valueOf());o=o[1]}let s=typeof o==="string"?o:o instanceof String?o.valueOf():null;if(s===null)return{tag:null,classes:h,id:void 0,base:o};let[w,_]=s.split("#");if(!w)w="div";return{tag:w,classes:h,id:_,base:o}};let u=(r)=>typeof r==="string"?r:r instanceof String?r.valueOf():null,l=(r,h)=>{if(!(r instanceof String))return h;let o=new String(h);if(r.optional)o.optional=!0;if(r.bang)o.bang=!0;return o.optional||o.bang?o:h};i.addBodyRipSrcMarkers=function(r,h){if(typeof r!=="string"||!r)return r;let o=Array.isArray(h)&&h[0]==="block"?h.slice(1):Array.isArray(h)?[h]:[];if(o.length===0)return r;let s=(y)=>{if(y==null)return null;if(!Array.isArray(y))return y?.loc?.r??null;if(y.loc?.r)return y.loc.r;if(y[0]?.loc?.r)return y[0].loc.r;for(let R of y){if(R?.loc?.r)return R.loc.r;if(Array.isArray(R)){let U=s(R);if(U!=null)return U}}return null},w=o.map(s);if(w.every((y)=>y==null))return r;let _=r.split(`
1875
1875
  `),A=0;for(let y=0;y<_.length&&A<w.length;y++){let R=_[y].trim();if(!R)continue;if(R==="{"||R==="}"||R.startsWith("//"))continue;if(_[y].includes("@rip-src:")){A++;continue}if(w[A]!=null)_[y]=`${_[y]} // @rip-src:${w[A]}`;A++}return _.join(`
1876
1876
  `)},i.transformComponentMembers=function(r,h=new Set){let o=this._self;if(!Array.isArray(r)){let s=u(r);if(s&&h.has(s))return r;if(s&&this.reactiveMembers&&this.reactiveMembers.has(s))return[".",[".",o,s],l(r,"value")];if(s&&this.componentMembers&&this.componentMembers.has(s))return[".",o,l(r,s)];return r}if(r[0]==="."&&r[1]==="this"&&u(r[2])!=null){let s=r[2],w=u(s);if(this.reactiveMembers&&this.reactiveMembers.has(w))return[".",[".",o,w],l(s,"value")];return this._factoryMode?[".",o,s]:r}if(r[0]==="."||r[0]==="?.")return[r[0],this.transformComponentMembers(r[1]),r[2]];if(r[0]==="->"){let s=r[1],w=new Set(h);if(Array.isArray(s))for(let _ of s){let A=u(Array.isArray(_)&&_[0]==="default"?_[1]:_);if(A)w.add(A)}return["=>",r[1],this.transformComponentMembers(r[2],w)]}if(r[0]==="object"||r[0]==="map-literal")return[r[0],...r.slice(1).map((s)=>{if(Array.isArray(s)&&s[0]==="...")return["...",this.transformComponentMembers(s[1],h)];if(Array.isArray(s)&&s.length>=2){let w=s[1],_=Array.isArray(w)?this.transformComponentMembers(w,h):w,A=this.transformComponentMembers(s[2],h);return[s[0],_,A]}return this.transformComponentMembers(s,h)})];if(r[0]==="block"||r[0]==="program"){let s=new Set(h),w=[r[0]];for(let _=1;_<r.length;_++){let A=r[_];if(Array.isArray(A)&&A[0]==="="){let y=u(A[1]);if(y&&!(this.reactiveMembers&&this.reactiveMembers.has(y))){w.push(["=",A[1],this.transformComponentMembers(A[2],s)]),s.add(y);continue}}w.push(this.transformComponentMembers(A,s))}return w}return r.map((s)=>this.transformComponentMembers(s,h))},i.emitComponent=function(r,h,o,s){let[,w]=h,_=this.is(w,"block")?w.slice(1):[],A=[],y=[],R=[],U=[],m=[],D=[],M=[],q=[],S=[],d=null,K=new Set,E=new Set;for(let G of _){if(!Array.isArray(G))continue;let[O]=G;if(O==="offer"){if(G=G[1],!Array.isArray(G))continue;O=G[0];let J=pn(G[1]);if(J)q.push(J)}if(O==="accept"){let J=typeof G[1]==="string"?G[1]:pn(G[1]);if(J)S.push(J),K.add(J),E.add(J)}else if(O==="."&&G[1]==="this"&&pn(G)){let J=typeof G[2]==="string"||G[2]instanceof String?G[2].valueOf():null;if(J){let P=Oi(G);A.push({name:J,value:void 0,isPublic:!0,type:G[2]?.type||null,required:!P,optional:P,srcLine:G.loc?.r}),K.add(J),E.add(J)}}else if(O==="state"){let J=pn(G[1]);if(J)A.push({name:J,value:G[2],isPublic:ol(G[1]),type:qi(G[1]),optional:Oi(G[1]),srcLine:G.loc?.r}),K.add(J),E.add(J)}else if(O==="computed"){let J=pn(G[1]);if(J)y.push({name:J,expr:G[2],type:qi(G[1]),srcLine:G.loc?.r}),K.add(J),E.add(J)}else if(O==="gate"){let J=pn(G[1]);if(J){let P=Et(G[2]);if(P.error)this.error(P.error,G);let F=null;if(P.keyExpr!==void 0){if(F=dt(P.keyExpr),F.error)this.error(F.error,G)}R.push({name:J,path:P.path,key:F,type:qi(G[1]),srcLine:G.loc?.r}),K.add(J),E.add(J)}}else if(O==="readonly"){let J=pn(G[1]);if(J)U.push({name:J,value:G[2],isPublic:ol(G[1]),type:qi(G[1]),optional:Oi(G[1]),srcLine:G.loc?.r}),K.add(J)}else if(O==="="){let J=pn(G[1]);if(J)if(hl.has(J))D.push({name:J,value:G[2]});else{let P=G[2];if(Array.isArray(P)&&(P[0]==="->"||P[0]==="=>"))m.push({name:J,func:P}),K.add(J);else A.push({name:J,value:P,isPublic:ol(G[1]),type:qi(G[1]),optional:Oi(G[1]),srcLine:G.loc?.r}),K.add(J),E.add(J)}}else if(O==="effect")M.push(G);else if(O==="render")d=G;else if(O==="object")for(let J=1;J<G.length;J++){let P=G[J];if(!Array.isArray(P))continue;let[,F,N]=P;if(typeof F==="string"&&hl.has(F))D.push({name:F,value:N});else if(typeof F==="string")m.push({name:F,func:N}),K.add(F)}}if(R.length>0){if(!this._gateDecls)this._gateDecls=[];for(let{path:G,key:O,srcLine:J}of R)this._gateDecls.push({path:G,keyed:!!O,line:(J??0)+1})}let Z=new Map;for(let{name:G}of m)if(/^on[A-Z]/.test(G)&&!hl.has(G)){let O=G[2].toLowerCase()+G.slice(3);if(Df.has(O))Z.set(O,G)}let Q=h[0]?.valueOf?.()??null,W=new Set;for(let{name:G,isPublic:O}of A)if(O)W.add(G);for(let{name:G,isPublic:O}of U)if(O)W.add(G);if(Q)K.add("rest"),E.add("rest");let C=this.componentMembers,L=this.reactiveMembers,X=this._autoEventHandlers,fn=this._inheritsTag;if(this.componentMembers=K,this.reactiveMembers=E,this._autoEventHandlers=Z.size>0?Z:null,this._inheritsTag=Q||null,this.options.stubComponents){let G=(b)=>b?b.replace(/::/g,":"):null,O=[],J=this._componentTypeParams||"";O.push(`class ${J}{`),O.push(" declare _root: Element | null; declare app: any; declare router: any; declare params: Record<string, string>; declare query: Record<string, string>; declare children: any;");let P=new Set(D.map((b)=>b.name)),F=[];if(!P.has("beforeMount"))F.push("beforeMount?(): void;");if(!P.has("mounted"))F.push("mounted?(): void;");if(!P.has("beforeUnmount"))F.push("beforeUnmount?(): void;");if(!P.has("unmounted"))F.push("unmounted?(): void;");if(!P.has("onError"))F.push(`onError?(err: ${qf}): void;`);if(F.length)O.push(" "+F.join(" "));O.push(" emit(_name: string, _detail?: any): void {}");let N=[],un=[];for(let{name:b,type:p,isPublic:v,required:ln,optional:rn}of A){if(!v)continue;let en=G(p)||"any";if(rn??!ln)N.push(`${b}?: ${en}`),N.push(`__bind_${b}__?: Signal<${en}>`);else un.push(`({ ${b}: ${en}; __bind_${b}__?: Signal<${en}> } | { ${b}?: ${en}; __bind_${b}__: Signal<${en}> })`)}for(let{name:b,type:p,isPublic:v}of U){if(!v)continue;let ln=G(p)||"any";N.push(`${b}?: ${ln}`)}{let b=un.length>0?"":"?",p=[];if(N.length)p.push(`{${N.join("; ")}}`);p.push(...un);let v=p.length?p.join(" & "):"{}";if(Q)v+=` & __RipProps<'${Q}'>`;O.push(` constructor(_props${b}: ${v}) {}`)}let $=(b)=>{let p=b?.valueOf?.()??b;if(typeof p!=="string")return null;if(p==="true"||p==="false")return"boolean";if(/^-?\d+(\.\d+)?$/.test(p))return"number";if(p.startsWith('"')||p.startsWith("'"))return"string";return null},tn=(b)=>{if(!Array.isArray(b)){if(typeof b==="string"||b instanceof String){let v=b.valueOf();return v==="this"||E.has(v)}return!1}let p=b[0]?.valueOf?.()??b[0];if(p==="->"||p==="=>")return!1;return b.some(tn)},cn=[];for(let{name:b,type:p,value:v,isPublic:ln,optional:rn,srcLine:en}of A){let sn=G(p)||$(v),wn=v===void 0||(v?.valueOf?.()??v)==="undefined",Rn=sn?rn&&wn?`${sn} | undefined`:sn:null,An=en!=null?` // @rip-src:${en}`:"";if(!Rn&&!ln&&!wn&&!tn(v))cn.push({name:b,value:v,marker:An});else O.push((Rn?` declare ${b}: Signal<${Rn}>;`:` declare ${b}: Signal<any>;`)+An)}if(Q)O.push(` declare rest: Signal<__RipProps<'${Q}'>>;`);for(let{name:b,type:p,value:v}of U){let ln=G(p)||$(v);O.push(ln?` declare ${b}: ${ln};`:` declare ${b}: any;`)}for(let{name:b,path:p,key:v,type:ln,srcLine:rn}of R){let en=G(ln),sn=en?`: Computed<${en}>`:"",wn=v?`this.app.data.${p}(${v.stubCode})`:`this.app.data.${p}`,_n=rn!=null?` // @rip-src:${rn}`:"";O.push(` ${b}${sn} = __computed(() => __ripGate(${wn}));`+_n)}for(let{name:b,expr:p,type:v}of y){let ln=G(v),rn=ln?`: Computed<${ln}>`:"";if(this.is(p,"block")){let en=this.transformComponentMembers(p),sn=this.emitFunctionBody(en);O.push(` ${b}${rn} = __computed(() => ${sn});`)}else{let en=this.emitInComponent(p,"value");O.push(` ${b}${rn} = __computed(() => ${en});`)}}for(let{name:b,value:p,marker:v}of cn){let ln=this.emitInComponent(p,"value");O.push(` ${b} = __state(${ln});`+v)}O.push(" _init(props) {");for(let{name:b,value:p,isPublic:v,srcLine:ln}of U){let rn=this.emitInComponent(p,"value"),en=ln!=null?` // @rip-src:${ln}`:"";O.push((v?` this.${b} = props.${b} ?? ${rn};`:` this.${b} = ${rn};`)+en)}for(let{name:b,value:p,isPublic:v,required:ln,type:rn,srcLine:en}of A){if(cn.some((wn)=>wn.name===b))continue;let sn=en!=null?` // @rip-src:${en}`:"";if(v&&(ln||p===void 0))O.push(` this.${b} = __state(props.__bind_${b}__ ?? props.${b});`+sn);else if(v){let wn=this.emitInComponent(p,"value");O.push(` this.${b} = __state(props.__bind_${b}__ ?? props.${b} ?? ${wn});`+sn)}else{let wn=this.emitInComponent(p,"value");O.push(` this.${b} = __state(${wn});`+sn)}}for(let b of M){let p=b[2],v=this.containsAwait(p)?"async ":"";if(this.is(p,"block")){let ln=this.transformComponentMembers(p),rn=this.emitFunctionBody(ln);O.push(` __effect(${v}() => ${rn});`)}else{let ln=this.emitInComponent(p,"value");O.push(` __effect(${v}() => { return ${ln}; });`)}}O.push(" }");let on=new Map;for(let[b,p]of Z)on.set(p,b);if(d){let b=(p)=>{if(!Array.isArray(p))return;let v=p[0]?.valueOf?.()??p[0];if(typeof v==="string"&&v!=="object"&&v!=="switch"&&ai.has(v.split(/[.#]/)[0]))for(let ln=1;ln<p.length;ln++){let rn=p[ln],en=this.is(rn,"object")?rn:null;if(!en&&Array.isArray(rn)&&(rn[0]==="->"||rn[0]==="=>")&&this.is(rn[2],"block")){for(let sn=1;sn<rn[2].length;sn++)if(this.is(rn[2][sn],"object")){en=rn[2][sn];break}}if(!en)continue;for(let sn=1;sn<en.length;sn++){let wn=en[sn];if(!Array.isArray(wn)||wn.length<2)continue;let[,_n,Rn]=wn;if(Array.isArray(_n)&&_n[0]==="."&&_n[1]==="this"&&Array.isArray(Rn)&&Rn[0]==="."&&Rn[1]==="this"){let An=typeof _n[2]==="string"?_n[2]:_n[2]?.valueOf?.(),g=typeof Rn[2]==="string"?Rn[2]:Rn[2]?.valueOf?.();if(An&&g&&!on.has(g))on.set(g,An)}}}for(let ln=1;ln<p.length;ln++)b(p[ln])};b(d)}for(let{name:b,func:p}of m)if(Array.isArray(p)&&(p[0]==="->"||p[0]==="=>")){let[,v,ln]=p;if((!v||Array.isArray(v)&&v.length===0)&&this.containsIt(ln))v=["it"];let rn=Array.isArray(v)?v.map((Rn)=>this.formatParam(Rn)).join(", "):"",en=on.get(b);if(en&&Array.isArray(v)&&v.length>0){let Rn=v[0];if(!(Rn?.type||Rn instanceof String&&Rn.type)&&typeof(Rn?.valueOf?.()??Rn)==="string"){let g=Rn?.valueOf?.()??Rn;rn=rn.replace(g,`${g}: HTMLElementEventMap['${en}']`)}}let sn=this.reactiveMembers?this.transformComponentMembers(ln):ln,wn=this.containsAwait(ln),_n=this.emitFunctionBody(sn,v||[]);_n=this.addBodyRipSrcMarkers(_n,ln),O.push(` ${wn?"async ":""}${b}(${rn}) ${_n}`)}for(let{name:b,value:p}of D)if(Array.isArray(p)&&(p[0]==="->"||p[0]==="=>")){let[,v,ln]=p,rn=Array.isArray(v)?v.map((_n)=>this.formatParam(_n)).join(", "):"";if(b==="onError"&&Array.isArray(v)&&v.length===1){let _n=v[0];if((typeof _n==="string"||_n instanceof String)&&!e(_n,"type"))rn=`${_n.valueOf()}: ${qf}`}let en=this.reactiveMembers?this.transformComponentMembers(ln):ln,sn=this.containsAwait(ln),wn=this.emitFunctionBody(en,v||[]);wn=this.addBodyRipSrcMarkers(wn,ln),O.push(` ${sn?"async ":""}${b}(${rn}) ${wn}`)}if(d){let b=[],p=0,v=this.options.source?.split(`
1877
1877
  `),ln=(g)=>typeof g==="string"&&/^["'`]\//.test(g)?`__ripRoute(${g})`:g,rn=/^[a-zA-Z_$][\w$]*$/,en=(g)=>typeof g==="string"&&rn.test(g)&&!/^(?:true|false|null|undefined)$/.test(g)&&!n.GENERATORS[g]&&!this._isInScopeValue(g),sn=(g,nn)=>{if(nn==null||!v)return nn;let zn=new RegExp(`(?<![\\w$.#@])${g}(?![\\w$])`);for(let Mn=nn;Mn<v.length;Mn++)if(v[Mn]&&zn.test(v[Mn]))return Mn;return nn},wn=(g,nn,zn)=>{let Mn=sn(g,nn);if(Mn!=null&&Mn===zn)return;b.push(` ({ ${g}: true });`+(Mn!=null?` // @rip-src:${Mn}`:""))},_n=(g,nn)=>{let zn=[],Mn=[];for(let B of g){let T=null;if(this.is(B,"object"))T=B;else if(Array.isArray(B)&&(B[0]==="->"||B[0]==="=>")&&this.is(B[2],"block")){let x=B[2].loc?.r??nn;for(let k=1;k<B[2].length;k++){let an=B[2][k];if(this.is(an,"object")){if(!T)T=an}else if(en(an))wn(an,x,nn)}}else if(en(B)){wn(B,nn,nn);continue}if(T)for(let x=1;x<T.length;x++){let k=T[x],[,an,V]=k,hn=k.loc?.r??T.loc?.r;if(Array.isArray(an)&&an[0]==="."&&an[1]==="this"){try{let yn=this.emitInComponent(V,"value");Mn.push({code:yn,srcLine:hn})}catch{}continue}if(typeof an==="string"&&an.startsWith("@")){try{let yn=this.emitInComponent(V,"value");Mn.push({code:yn,srcLine:hn})}catch{}continue}if(typeof an==="string")if(an.startsWith("__bind_")&&an.endsWith("__")){let yn=typeof V==="string"&&this.reactiveMembers?.has(V)?`this.${V}`:this.emitInComponent(V,"value");zn.push({code:`${an}: ${yn}`,srcLine:hn})}else{let yn=this.emitInComponent(V,"value"),mn=an==="href"?ln(yn):yn;zn.push({code:`${an}: ${mn}`,srcLine:hn})}}}return zn.sideExprs=Mn,zn},Rn=(g,nn,zn)=>{let Mn=[],B=(T)=>{if(nn!=="a")return T;if(typeof T!=="string")return T;if(T.length<2)return T;if(T[0]!=="`")return T;if(T[1]!=="/")return T;return`__ripRoute(${T})`};for(let T of g){let x=null;if(this.is(T,"object"))x=T;else if(Array.isArray(T)&&(T[0]==="->"||T[0]==="=>")&&this.is(T[2],"block")){let k=T[2].loc?.r??zn;for(let an=1;an<T[2].length;an++){let V=T[2][an];if(this.is(V,"object")){if(!x)x=V}else if(en(V))wn(V,k,zn)}}else if(en(T)){wn(T,zn,zn);continue}if(x)for(let k=1;k<x.length;k++){let an=x[k];if(!Array.isArray(an)||an.length<2)continue;let[,V,hn]=an,yn=an.loc?.r??x.loc?.r;if(Array.isArray(V)&&V[0]==="."&&V[1]==="this"){let mn=typeof V[2]==="string"?V[2]:V[2]?.valueOf?.();if(!mn)continue;let En=mn.split(".")[0],Jn=this.emitInComponent(hn,"value");if(Array.isArray(hn)&&(hn[0]==="->"||hn[0]==="=>")){let Gn=hn[1]?.[0],Yn=typeof Gn==="string"?Gn:Gn?.valueOf?.();if(Yn&&!(Gn&&Gn.type)&&/^[A-Za-z_$][\w$]*$/.test(Yn)){let gn=`RipEvent<HTMLElementEventMap['${En}'], __RipElementMap['${nn}']>`;Jn=Jn[0]==="("?Jn.replace(new RegExp("^\\(\\s*"+Yn+"\\b"),`(${Yn}: ${gn}`):Jn.replace(new RegExp("^"+Yn+"\\b"),`(${Yn}: ${gn})`)}}Mn.push({code:`'@${En}': ${Jn}`,srcLine:yn})}else if(typeof V==="string"){if(V==="key"){let mn=this.emitInComponent(hn,"value"),En=yn!=null?` // @rip-src:${yn}`:"";b.push(` (${mn});${En}`);continue}if(V.startsWith("__bind_")&&V.endsWith("__")){let mn=V.slice(7,-2),En=this.emitInComponent(hn,"value");Mn.push({code:`${mn}: ${En}`,srcLine:yn})}else{let mn=this.emitInComponent(hn,"value"),En=V==="href"?B(mn):mn;Mn.push({code:`${V}: ${En}`,srcLine:yn})}}}}return Mn},An=(g)=>{if(!Array.isArray(g))return;let nn=g[0]?.valueOf?.()??g[0];if(Array.isArray(nn)&&nn[0]==="."){let B=[],T=(x)=>{if(typeof x==="string")return B.push(x),!0;if(Array.isArray(x)&&x[0]==="."&&B.length===0){if(!T(x[1]))return!1;if(typeof x[2]!=="string"||!/^[\w-]+$/.test(x[2]))return!1;return B.push(".",x[2]),!0}return!1};if(T(nn)&&B.length>=3&&/^[a-z][\w-]*$/.test(B[0])){let x=B.join(""),k=[x];for(let V=1;V<g.length;V++)k.push(g[V]);if(g.loc)k.loc=g.loc;k._astNode=g;let an=(V)=>{if(Array.isArray(V)&&V[0]==="."){if(V.loc)delete V.loc;an(V[1])}};an(nn),g=k,nn=x}}if(nn==="object")return;if(nn==="if"||nn==="unless"){let B=g[1];if(B!=null){let T=this.emitInComponent(B,"value"),x=g.loc?.r,k=x!=null?` // @rip-src:${x}`:"",an=nn==="unless"?`!(${T})`:T;if(b.push(` if (${an}) {${k}`),g[2]!=null)An(g[2]);let V=g.slice(3).filter((hn)=>hn!=null);if(V.length){b.push(" } else {");for(let hn of V)An(hn)}b.push(" }");return}}else if(nn==="?:"){let B=this.emitInComponent(g,"value"),T=g.loc?.r,x=T!=null?` // @rip-src:${T}`:"";b.push(` ${B};${x}`);return}else if(nn==="switch"){let B=g[1];if(B!=null){let T=this.emitInComponent(B,"value"),x=g.loc?.r,k=x!=null?` // @rip-src:${x}`:"";b.push(` ${T};${k}`)}}else if(nn==="for-in"||nn==="for-of"||nn==="for-as"){let B=g[1],T=g[2];if(T!=null){let x=this.emitInComponent(T,"value"),k=g.loc?.r,an=k!=null?` // @rip-src:${k}`:"",V;if(Array.isArray(B))if(B.length===1){let mn=B[0];V=Array.isArray(mn)?this.emitDestructuringPattern(mn):String(mn)}else if(nn==="for-of")V=`[${B.map((mn)=>String(mn)).join(", ")}]`;else V=String(B[0]);else V=String(B);if(nn==="for-of")b.push(` for (const ${V} of Object.entries(${x})) {${an}`);else b.push(` for (const ${V} of ${x}) {${an}`);let hn=(mn)=>typeof mn==="string"||mn instanceof String?String(mn):null,yn=Array.isArray(B)?{itemVar:hn(B[0]),indexVar:hn(B[1])}:{itemVar:hn(B),indexVar:null};(this._loopVarStack||(this._loopVarStack=[])).push(yn);for(let mn=3;mn<g.length;mn++)if(g[mn]!=null)An(g[mn]);this._loopVarStack.pop(),b.push(" }");return}}else if(nn==="__text__"){let B=g[1];if(B!=null){let T=this.emitInComponent(B,"value"),x=g.loc?.r,k=x!=null?` // @rip-src:${x}`:"";b.push(` ${T};${k}`)}return}else if(nn==="str"){try{let B=this.emitInComponent(g,"value"),T=g.loc?.r,x=T!=null?` // @rip-src:${T}`:"";b.push(` ${B};${x}`)}catch{}return}else if(nn==="."||nn==="?."){let B=g;while(Array.isArray(B)&&(B[0]==="."||B[0]==="?."))B=B[1];let T=typeof B==="string"?B:B?.valueOf?.();if(typeof T==="string"&&!this.isHtmlTag(T)&&!n.GENERATORS[T])try{let x=this.emitInComponent(g,"value"),k=g.loc?.r,an=k!=null?` // @rip-src:${k}`:"";b.push(` ${x};${an}`)}catch{}return}let zn=(B,T,x)=>{if(typeof B!=="string"||!/^[a-z][\w-]*$/.test(B))return;if(n.GENERATORS[B])return;if(B==="null"||B==="undefined"||B==="true"||B==="false")return;let k=T.loc?.r,an=null;if(k!=null&&v){let hn=new RegExp(`\\b${B}\\b`,"g");for(let yn=k;yn<v.length;yn++){let mn=v[yn];if(!mn)continue;let En=yn===T.loc.r?T.loc.c+1:0;hn.lastIndex=En;let Jn,Gn=-1;while((Jn=hn.exec(mn))!==null){let Yn=Jn.index>0?mn[Jn.index-1]:"";if(Yn==="."||Yn==="#")continue;Gn=Jn.index;break}if(Gn>=0){k=yn,an=Gn;break}}}let V=k!=null?` // @rip-src:${k}`:"";if(k!=null&&an!=null){let hn=T._astNode||T;if(!hn._anchors)hn._anchors=[];hn._anchors.push({name:B,origLine:k,origCol:an})}if(this.componentMembers&&this.componentMembers.has(B))b.push(` this.${B};${V}`);else if(this._isInScopeValue(B))b.push(` ${B};${V}`);else if(!x&&this.isHtmlTag(B))b.push(` __ripEl('${B}');${V}`)},Mn=typeof nn==="string"&&/^[a-z][\w-]*(?:[.#][\w-]+)*$/.test(nn)&&!n.GENERATORS[nn]&&ai.has(nn.split(/[.#]/)[0]);if(nn==="block")for(let B=1;B<g.length;B++)zn(g[B],g,!1);else if(typeof nn==="string"&&/^[A-Z]/.test(nn))for(let B=1;B<g.length;B++)zn(g[B],g,!0);else if(Mn){for(let B=1;B<g.length;B++)zn(g[B],g,!0);for(let B=1;B<g.length;B++){let T=g[B];if(!Array.isArray(T))continue;let x=T[0]?.valueOf?.()??T[0];if(x==="object"||x==="block"||x==="__text__")continue;if(typeof x==="string"){if(/^[A-Z]/.test(x))continue;if(ai.has(x.split(/[.#]/)[0]))continue;if(/^[a-z][\w-]*$/.test(x)&&!n.GENERATORS[x])continue;if(/^(if|unless|switch|for-in|for-of|for-as|while|until|loop|loop-n|try|throw|break|continue|break-if|continue-if|control|when|return|def|->|=>|class|enum|state|computed|readonly|effect|=|program)$/.test(x))continue}try{let k=this.emitInComponent(T,"value"),an=T.loc?.r??g.loc?.r,V=an!=null?` // @rip-src:${an}`:"";b.push(` ${k};${V}`)}catch{}}}for(let B=1;B<g.length;B++)An(g[B]);if(typeof nn==="string"&&/^[A-Z]/.test(nn)){let B=_n(g.slice(1),g.loc?.r),T=`_${p++}`,x=`ConstructorParameters<typeof ${nn}>[0] & {}`;if(B.length===0){let k=g.loc?.r;b.push(` const ${T}: ${x} = {};`+(k!=null?` // @rip-src:${k}`:""))}else if(B.length===1){let k=g.loc?.r??B[0].srcLine;b.push(` const ${T}: ${x} = {${B[0].code}};`+(k!=null?` // @rip-src:${k}`:""))}else{let k=g.loc?.r;if(new Set(B.map((V)=>V.srcLine).filter((V)=>V!=null)).size<=1){let V=B[0].srcLine??k;b.push(` const ${T}: ${x} = {${B.map((hn)=>hn.code).join(", ")}};`+(V!=null?` // @rip-src:${V}`:""))}else{b.push(` const ${T}: ${x} = {`+(k!=null?` // @rip-src:${k}`:""));for(let V of B)b.push(` ${V.code},`+(V.srcLine!=null?` // @rip-src:${V.srcLine}`:""));b.push(" };")}}if(B.sideExprs)for(let k of B.sideExprs)b.push(` ${k.code};`+(k.srcLine!=null?` // @rip-src:${k.srcLine}`:""))}else if(typeof nn==="string"&&!n.GENERATORS[nn]&&(ai.has(nn.split(/[.#]/)[0])||/^[a-z][\w-]*$/.test(nn)&&g.length>1)){let B=nn.split(/[.#]/)[0],T=Ln.has(B)?"__ripSvgEl":"__ripEl",x=Rn(g.slice(1),B,g.loc?.r),k=g.loc?.r,an=k!=null?` // @rip-src:${k}`:"";if(x.length===0)b.push(` ${T}('${B}');${an}`);else if(x.length===1){let V=x[0].srcLine??k,hn=V!=null?` // @rip-src:${V}`:"";b.push(` ${T}('${B}', {${x[0].code}});${hn}`)}else if(new Set(x.map((hn)=>hn.srcLine).filter((hn)=>hn!=null)).size<=1){let hn=x[0].srcLine??k,yn=hn!=null?` // @rip-src:${hn}`:"";b.push(` ${T}('${B}', {${x.map((mn)=>mn.code).join(", ")}});${yn}`)}else{b.push(` ${T}('${B}', {${an}`);for(let hn of x)b.push(` ${hn.code},`+(hn.srcLine!=null?` // @rip-src:${hn.srcLine}`:""));b.push(" });")}}};if(An(d),b.length>0){O.push(" _render() {");for(let g of b)O.push(g);O.push(" }")}}return O.push("}"),this.componentMembers=C,this.reactiveMembers=L,this._autoEventHandlers=X,this._inheritsTag=fn,O.join(`
@@ -2955,7 +2955,7 @@ if (typeof globalThis !== 'undefined') {
2955
2955
  `:"",n=t.slice(0,i).join(`
2956
2956
  `)}let u=new vn,l;try{l=u.tokenize(n)}catch(y){throw hi(y,n,this.options.filename)}if(this.options.showTokens)l.forEach((y)=>console.log(`${y[0].padEnd(12)} ${JSON.stringify(y[1])}`)),console.log();let a=null,c=null;if(this.options.types==="emit"||this.options.types==="check"||this.options.types===!0)c=[...l];if(l=l.filter((y)=>y[0]!=="TYPE_DECL"),u.typeRefNames?.size>0&&!this.options.inlineTypes){let y=new Set,R=!1;for(let m of l){if(m[0]==="IMPORT"){R=!0;continue}if(R&&m[0]==="TERMINATOR"){R=!1;continue}if(R)continue;if(m[0]==="IDENTIFIER")y.add(m[1])}let U=(m)=>!y.has(m);for(let m=l.length-1;m>=0;m--){if(l[m][0]!=="IMPORT")continue;let D=m+1;if(D>=l.length)continue;if(l[D][0]==="CALL_START"||l[D][0]==="(")continue;if(l[D][0]==="STRING")continue;let M=-1,q=D;while(q<l.length&&l[q][0]!=="TERMINATOR"){if(M===-1&&l[q][0]==="FROM")M=q;q++}if(M===-1)continue;let S=-1,d=-1;for(let X=m+1;X<M;X++)if(l[X][0]==="{"){S=X;break}if(S!==-1){for(let X=S+1;X<M;X++)if(l[X][0]==="}"){d=X;break}}let K=!1,E=S!==-1?S:M;for(let X=m+1;X<E;X++){let fn=l[X][0];if(fn==="IDENTIFIER"||fn==="*"){K=!0;break}}if(S===-1||d===-1){if(K){let X=[],fn=m+1;while(fn<M)if(l[fn][0]==="AS"&&fn+1<M&&l[fn+1][0]==="IDENTIFIER")X.push(l[fn+1][1]),fn+=2;else if(l[fn][0]==="IDENTIFIER")X.push(l[fn][1]),fn++;else fn++;if(X.length===0||!X.every(U))continue;let Y=q<l.length?q+1:q;l.splice(m,Y-m)}continue}let Z=[],Q=S+1;while(Q<d){let X=Q;while(X<d&&l[X][0]!==",")X++;if(X>Q)Z.push({start:Q,end:X});Q=X+1}for(let X of Z){let fn=null;for(let Y=X.start;Y<X.end;Y++){if(l[Y][0]!=="IDENTIFIER")continue;if(fn===null)fn=l[Y][1];else if(l[Y-1]?.[0]==="AS")fn=l[Y][1]}X.local=fn,X.drop=fn!=null&&U(fn)}if(!Z.some((X)=>X.drop))continue;let C=Z.every((X)=>X.drop),L=[];if(C&&K){let X=m+1;while(X<S)if(l[X][0]==="AS"&&X+1<S&&l[X+1][0]==="IDENTIFIER")L.push(l[X+1][1]),X+=2;else if(l[X][0]==="IDENTIFIER")L.push(l[X][1]),X++;else X++}if(C)if(!K){let X=q<l.length?q+1:q;l.splice(m,X-m)}else if(L.length>0&&L.every(U)){let X=q<l.length?q+1:q;l.splice(m,X-m)}else{let X=S,fn=d+1,Y=S-1;while(Y>m&&l[Y][0]!==","&&l[Y][0]!=="IDENTIFIER"&&l[Y][0]!=="*")Y--;if(Y>m&&l[Y][0]===",")X=Y;l.splice(X,fn-X)}else for(let X=Z.length-1;X>=0;X--){let fn=Z[X];if(!fn.drop)continue;let{start:Y,end:Un}=fn;if(Un<d&&l[Un][0]===",")Un++;else if(Y>S+1&&l[Y-1][0]===",")Y--;l.splice(Y,Un-Y)}}}while(l.length>0&&l[0][0]==="TERMINATOR")l.shift();if(l.every((y)=>y[0]==="TERMINATOR")){if(c&&Bi)a=Bi(c,["program"],n);return{tokens:l,sexpr:["program"],code:"",dts:a,data:e,reactiveVars:{},gates:[]}}let r=null;Nn.lexer={tokens:l,pos:0,setInput:function(){},lex:function(){if(this.pos>=this.tokens.length)return 1;let y=this.tokens[this.pos++],R=y[1];if(y.data)R=new String(R),Object.assign(R,y.data);return this.text=R,this.loc=y.loc,this.line=y.loc?.r,r=y.loc,y[0]}},Ol(!!this.options.exactMarks);let h;try{h=Nn.parse(n)}catch(y){if(/\?\s*\([^)]*\?[^)]*:[^)]*\)\s*:/.test(n)||/\?\s+\w+\s+\?\s+/.test(n))throw new Hn("Nested ternary operators are not supported",{code:"E_PARSE",source:n,file:this.options.filename,suggestion:"Use if/else statements instead.",phase:"parser"});let R=hi(y,n,this.options.filename);if(R.phase==="parser"&&r)R.line=r.r??R.line,R.column=r.c??R.column,R.length=r.n||1;throw R}if(this.options.showSExpr)console.log(In(h,0,!0)),console.log();let o=null;if(this.options.sourceMap){let y=(this.options.filename||"output")+".js",R=this.options.filename||"input.rip";o=new _l(y,R,n)}let s=new Fn({dataSection:e,source:n,filename:this.options.filename,skipPreamble:this.options.skipPreamble,skipRuntimes:this.options.skipRuntimes,skipExports:this.options.skipExports,skipImports:this.options.skipImports,skipDataPart:this.options.skipDataPart,stubComponents:this.options.stubComponents,reactiveVars:this.options.reactiveVars,inlineTypes:this.options.inlineTypes,schemaMode:this.options.schemaMode,foldProjections:this.options.foldProjections,exactMarks:this.options.exactMarks,sourceMap:o}),w=s.compile(h),_=o?o.toJSON():null,A=o?o.toReverseMap():null;if(_&&this.options.sourceMap==="inline"){let y;if(typeof Buffer<"u")y=Buffer.from(_,"utf8").toString("base64");else{let R=new TextEncoder().encode(_),U="";for(let m=0;m<R.length;m++)U+=String.fromCharCode(R[m]);y=btoa(U)}w+=`
2957
2957
  //# sourceMappingURL=data:application/json;base64,${y}`}else if(_&&this.options.filename)w+=`
2958
- //# sourceMappingURL=${this.options.filename}.js.map`;if(c&&Bi)a=Bi(c,h,n,s._schemaBehavior,s._schemaAnon);return{tokens:l,sexpr:h,code:w,dts:a,map:_,reverseMap:A,data:e,reactiveVars:s.reactiveVars,gates:s._gateDecls||[]}}compileToJS(n){return this.compile(n).code}compileToSExpr(n){return this.compile(n).sexpr}}Ef(Fn,vn);Fn.prototype.emitEnum=function(f,e,t){let[i,u]=e,l=i?.valueOf?.()??i,a=[];if(Array.isArray(u)){let h=u[0]==="block"?u.slice(1):[u];for(let o of h)if(Array.isArray(o)){if(o[0]?.valueOf?.()==="="){let s=o[1]?.valueOf?.()??o[1],w=o[2]?.valueOf?.()??o[2];a.push([s,w])}}}if(a.length===0)return`const ${l} = {}`;let c=a.map(([h,o])=>`${h}: ${o}`).join(", "),r=a.map(([h,o])=>`${o}: "${h}"`).join(", ");return`const ${l} = {${c}, ${r}}`};Yi(null,Fn);function gi(n,f={}){return new Ei(f).compile(n)}function Tn(n,f={}){return new Ei(f).compileToJS(n)}function di(){return new Fn({}).getReactiveRuntime()}function Fi(){return new Fn({}).getComponentRuntime()}var Qf="3.17.2",Wf="2026-06-28@03:29:47GMT";if(typeof globalThis<"u"){if(!globalThis.__rip)Function(di())();if(!globalThis.__ripComponent)Function(Fi())()}var bt=(n)=>{let f=n.match(/^[ \t]*(?=\S)/gm),e=Math.min(...(f||[]).map((t)=>t.length));return n.replace(RegExp(`^[ ]{${e}}`,"gm"),"").trim()},Al=(n)=>String(n).replace(/[\r\n]/g,"").replace(/\s+$/g,"");function yl(n){let f=/^(\s*)import\s+([^'"]+?)\s+from\s+['"](@rip-lang\/[^'"]+)['"];?\s*$/gm;return n.replace(f,(e,t,i,u)=>{let l=i.trim();if(l.startsWith("type "))return`${t}// type-only import erased: ${u}`;let a=l.indexOf("{"),c=l.lastIndexOf("}");if(a<0||c<=a)return console.warn(`[Rip] Skipping non-named import from ${u}; only \`import { … } from '@rip-lang/*'\` is supported in browser bundles.`),e;let r=l.slice(a+1,c),h=[];for(let o of r.split(",")){let s=o.trim().replace(/^type\s+/,"");if(!s)continue;if(/\s+as\s+/.test(s)){let[w,_]=s.split(/\s+as\s+/).map((A)=>A.trim());h.push(`${w}: ${_}`)}else h.push(s)}if(h.length===0)return`${t}// import erased: ${u}`;return`${t}const { ${h.join(", ")} } = globalThis;`})}function Jf(n,f){let t=`//# sourceURL=${Al(f)}`,i=/\n?\/\/# sourceMappingURL=[^\n]*\s*$/,u=n.match(i);if(u)return n.slice(0,u.index)+`
2958
+ //# sourceMappingURL=${this.options.filename}.js.map`;if(c&&Bi)a=Bi(c,h,n,s._schemaBehavior,s._schemaAnon);return{tokens:l,sexpr:h,code:w,dts:a,map:_,reverseMap:A,data:e,reactiveVars:s.reactiveVars,gates:s._gateDecls||[]}}compileToJS(n){return this.compile(n).code}compileToSExpr(n){return this.compile(n).sexpr}}Ef(Fn,vn);Fn.prototype.emitEnum=function(f,e,t){let[i,u]=e,l=i?.valueOf?.()??i,a=[];if(Array.isArray(u)){let h=u[0]==="block"?u.slice(1):[u];for(let o of h)if(Array.isArray(o)){if(o[0]?.valueOf?.()==="="){let s=o[1]?.valueOf?.()??o[1],w=o[2]?.valueOf?.()??o[2];a.push([s,w])}}}if(a.length===0)return`const ${l} = {}`;let c=a.map(([h,o])=>`${h}: ${o}`).join(", "),r=a.map(([h,o])=>`${o}: "${h}"`).join(", ");return`const ${l} = {${c}, ${r}}`};Yi(null,Fn);function gi(n,f={}){return new Ei(f).compile(n)}function Tn(n,f={}){return new Ei(f).compileToJS(n)}function di(){return new Fn({}).getReactiveRuntime()}function Fi(){return new Fn({}).getComponentRuntime()}var Qf="3.17.3",Wf="2026-06-28@04:18:51GMT";if(typeof globalThis<"u"){if(!globalThis.__rip)Function(di())();if(!globalThis.__ripComponent)Function(Fi())()}var bt=(n)=>{let f=n.match(/^[ \t]*(?=\S)/gm),e=Math.min(...(f||[]).map((t)=>t.length));return n.replace(RegExp(`^[ ]{${e}}`,"gm"),"").trim()},Al=(n)=>String(n).replace(/[\r\n]/g,"").replace(/\s+$/g,"");function yl(n){let f=/^(\s*)import\s+([^'"]+?)\s+from\s+['"](@rip-lang\/[^'"]+)['"];?\s*$/gm;return n.replace(f,(e,t,i,u)=>{let l=i.trim();if(l.startsWith("type "))return`${t}// type-only import erased: ${u}`;let a=l.indexOf("{"),c=l.lastIndexOf("}");if(a<0||c<=a)return console.warn(`[Rip] Skipping non-named import from ${u}; only \`import { … } from '@rip-lang/*'\` is supported in browser bundles.`),e;let r=l.slice(a+1,c),h=[];for(let o of r.split(",")){let s=o.trim().replace(/^type\s+/,"");if(!s)continue;if(/\s+as\s+/.test(s)){let[w,_]=s.split(/\s+as\s+/).map((A)=>A.trim());h.push(`${w}: ${_}`)}else h.push(s)}if(h.length===0)return`${t}// import erased: ${u}`;return`${t}const { ${h.join(", ")} } = globalThis;`})}function Jf(n,f){let t=`//# sourceURL=${Al(f)}`,i=/\n?\/\/# sourceMappingURL=[^\n]*\s*$/,u=n.match(i);if(u)return n.slice(0,u.index)+`
2959
2959
  `+t+n.slice(u.index);return n+`
2960
2960
  `+t}function Yf(n,f){if(!f)return n;return n.replace(/\/\/# sourceMappingURL=data:application\/json;base64,([A-Za-z0-9+/=]+)/,(e,t)=>{let i;try{let c=atob(t),r=new Uint8Array(c.length);for(let h=0;h<c.length;h++)r[h]=c.charCodeAt(h);i=new TextDecoder().decode(r)}catch{return e}let u;try{u=JSON.parse(i)}catch{return e}u.mappings=";".repeat(f)+u.mappings;let l=new TextEncoder().encode(JSON.stringify(u)),a="";for(let c=0;c<l.length;c++)a+=String.fromCharCode(l[c]);return`//# sourceMappingURL=data:application/json;base64,${btoa(a)}`})}function Pt(n,f){let e=`${Al(f)}.js`,t=Yf(n,1);return`(async()=>{
2961
2961
  ${Jf(t,e)}
@@ -2975,4 +2975,4 @@ ${f}`).replace(/^let\s+[^;]+;\s*\n\s*/m,"");t=t.replace(/^const\s+(\w+)\s*=/gm,"
2975
2975
  `+h)+`
2976
2976
  `+o+"}"}return null};return(u)=>{let l=i(u,0);return l!==null?console.log(l):console.dir(u,{depth:null,colors:!0}),u}})();globalThis.raise??=(n,f)=>{throw f!==void 0?new n(f):Error(n)};globalThis.rand??=(n,f)=>f!==void 0?(n>f&&([n,f]=[f,n]),Math.floor(Math.random()*(f-n+1)+n)):n?Math.floor(Math.random()*n):Math.random();globalThis.sleep??=(n)=>new Promise((f)=>setTimeout(f,n));globalThis.todo??=(n)=>{throw Error(n||"Not implemented")};globalThis.warn??=console.warn;globalThis.zip??=(...n)=>n[0].map((f,e)=>n.map((t)=>t[e]));({__state:Sn,__computed:If,__effect:ni,__batch:ji}=globalThis.__rip);xi=globalThis.__ripComponent||{};var Ot=function(n,f){return xi.setContext(n,f)},Bt=function(n){return xi.getContext(n)},It=function(n){return xi.hasContext(n)};Ui=function(n){if(typeof window>"u"||typeof document>"u")throw Error(`Rip App: '${n}' requires a browser environment`)};Ql=new WeakMap;Dl=new WeakMap;Li=Symbol.for("rip.source");pi=Symbol.for("rip.source.family");Kl=Symbol.for("rip.defaults");Vi=Symbol.for("rip.persist");Wn=function(n){return n!=null&&(typeof n==="object"||typeof n==="function")&&(n[Li]===!0||n[pi]===!0)};Di=function(n){return n!=null&&typeof n==="function"&&n[pi]===!0};vi=0;mi=Sn(0);Qn=0;dl=function(n){return typeof n==="string"&&(n.indexOf(".")!==-1||n.indexOf("/")!==-1||n.indexOf("[")!==-1)};ru=function(n){return/^-?\d+$/.test(n)};Jl=function(n,f){let e;if(!n[Symbol.for("signals")])Object.defineProperty(n,Symbol.for("signals"),{value:new Map,enumerable:!1});if(e=n[Symbol.for("signals")].get(f),!e)e=Sn(n[f]),n[Symbol.for("signals")].set(f,e);return e};xn=function(n){return Jl(n,Symbol.for("keys"))};Hl=function(n){let f;if(!(n!=null&&typeof n==="object"))return n;if(n[Symbol.for("stash")])return n;if(n[Li])return n;if(n instanceof Date||n instanceof RegExp||n instanceof Map||n instanceof Set||n instanceof Promise)return n;if(f=Ql.get(n),f)return f;return Yl(n)};Yl=function(n){let f,e;return e=null,f={get(t,i){let u,l,a,c,r;if(i===Symbol.for("stash"))return!0;if(i===Symbol.for("raw"))return t;if(typeof i==="symbol")return Reflect.get(t,i);if(i==="length"&&Array.isArray(t))return xn(t).value,t.length;if(!Qn&&dl(i))return ci(e,i);if(u=wu(e,i),u)return u;if(l=t[i],Wn(l)){if(typeof l==="function")return l;return c=l.read(),c!=null&&typeof c==="object"?Hl(c):c}if(a=Jl(t,i),r=a.value,r!=null&&typeof r==="object")return Hl(r);return r},set(t,i,u){let l,a,c,r,h;if(!Qn&&dl(i))return yi(e,i,u),!0;if(Array.isArray(t)&&i==="length"){if(c=t.length,l=+u,t.length=l,l!==c){if(t[Symbol.for("signals")]){for(let o of((s,w)=>Array.from({length:Math.max(0,Math.abs(w-s))},(_,A)=>s+A*(s<=w?1:-1)))(Math.min(c,l),Math.max(c,l)))if(h=t[Symbol.for("signals")].get(String(o)),h!=null)h.value=t[o]}xn(t).value=++vi,mi.value++}return!0}if(a=t[i],Wn(a)&&!Wn(u)){if(Di(a))throw Error(`Rip App: cannot assign a value to keyed source '${String(i)}' — use source('${String(i)}', key) and set .value`);return a.write(u?.[Symbol.for("raw")]?u[Symbol.for("raw")]:u),mi.value++,!0}if(r=u?.[Symbol.for("raw")]?u[Symbol.for("raw")]:u,r===a)return!0;if(t[i]=r,t[Symbol.for("signals")]?.has(i))t[Symbol.for("signals")].get(i).value=r;if(a===void 0&&r!==void 0)xn(t).value=++vi;return mi.value++,!0},deleteProperty(t,i){let u;if(delete t[i],u=t[Symbol.for("signals")]?.get(i),u!=null)u.value=void 0;return xn(t).value=++vi,mi.value++,!0},ownKeys(t){return xn(t).value,Reflect.ownKeys(t)}},e=new Proxy(n,f),Ql.set(n,e),e};Xf=/([./][^./\[\s]+|\[[-+]?\d+\]|\[(?:"[^"]+"|'[^']+')\])/;$n=function(n){let f,e,t,i,u;t=("."+n).split(Xf),t.shift(),u=[],e=0;while(e<t.length){if(i=t[e],f=i[0],f==="."||f==="/")u.push(i.slice(1));else if(f==="[")if(i[1]==='"'||i[1]==="'")u.push(i.slice(2,-2));else u.push(+i.slice(1,-1));e+=2}return u};Ri=function(n,f){let e;if(typeof n==="number"&&n<0){if(e=Zn(f),Array.isArray(e))return e.length+n}return n};ci=function(n,f){let e,t;return t=$n(f),e=n,Qn++,(()=>{try{for(let i of t){if(e==null)return;e=e[Ri(i,e)]}return e}finally{Qn--}})()};yi=function(n,f,e){let t,i,u,l;return l=$n(f),u=n,Qn++,(()=>{try{for(let a=0;a<l.length;a++){let c=l[a];if(t=Ri(c,u),a===l.length-1)u[t]=e;else{if(u[t]==null)i=l[a+1],u[t]=typeof i==="number"||ru(i)?[]:{};u=u[t]}}return e}finally{Qn--}})()};Of={inc:!0,dec:!0,flip:!0,join:!0,keys:!0,has:!0,del:!0,peek:!0,reset:!0,source:!0};Ki=function(n){let f;if(!(n!=null&&typeof n==="object"))return n;if(n instanceof Date||n instanceof RegExp||n instanceof Map||n instanceof Set||n instanceof Promise)return n;if(Array.isArray(n))return(()=>{let e=[];for(let t of n)e.push(Ki(t));return e})();f={};for(let e in n){if(!Object.hasOwn(n,e))continue;let t=n[e];if(Wn(t))continue;f[e]=Ki(t)}return f};ou=function(n){if(!(n!=null&&typeof n==="object"))return;Object.defineProperty(n,Kl,{value:Ki(n),configurable:!0});return};wu=function(n,f){let e,t;if(!Of[f])return;if(e=Dl.get(n),!e)e={},Dl.set(n,e);if(e[f])return e[f];return t=(()=>{switch(f){case"inc":return function(i,u=1){let l;return l=ci(n,i)??0,yi(n,i,l+u)};case"dec":return function(i,u=1){let l;return l=ci(n,i)??0,yi(n,i,l-u)};case"flip":return function(i){let u;return u=ci(n,i)??!1,yi(n,i,!u)};case"join":return function(i,u){return ji(function(){let l;if(l=ci(n,i),!(l!=null&&typeof l==="object"))yi(n,i,{}),l=ci(n,i);return Qn++,(()=>{try{return(()=>{let a=[];for(let c in u){let r=u[c];a.push(l[c]=r)}return a})()}finally{Qn--}})()})};case"keys":return function(i){let u,l,a;return Qn++,(()=>{try{l=$n(i),u=n;for(let c of l){if(u==null)return[];u=u[Ri(c,u)]}if(!(u!=null&&typeof u==="object"))return[];return a=Zn(u),xn(a).value,Object.keys(a)}finally{Qn--}})()};case"has":return function(i){let u,l,a,c;return Qn++,(()=>{try{if(a=$n(i),!(a.length>0))return!1;l=n;for(let r=0;r<a.length;r++){let h=a[r];if(u=Ri(h,l),r===a.length-1)return c=Zn(l),xn(c).value,Object.prototype.hasOwnProperty.call(c,u);if(l==null)return!1;l=l[u]}return!1}finally{Qn--}})()};case"del":return function(i){let u,l,a;return Qn++,(()=>{try{if(a=$n(i),!(a.length>0))return;return l=n,(()=>{let c=[];for(let r=0;r<a.length;r++){let h=a[r];if(u=Ri(h,l),r===a.length-1){delete l[u];return}if(l==null)return;c.push(l=l[u])}return c})()}finally{Qn--}})()};case"reset":return function(){ji(function(){let i,u;u=Zn(n),i=u[Kl];for(let l in u){if(!Object.hasOwn(u,l))continue;let a=u[l];if(Wn(a))a.reset();else if(i)if(Object.prototype.hasOwnProperty.call(i,l))n[l]=Ki(i[l]);else delete n[l]}return u[Vi]?.()});return};case"source":return function(i,u){let l,a,c;l=null,c=Zn(n);for(let r of $n(i)){if(!(c!=null&&typeof c==="object"))break;if(c=c[r],Wn(c)){l=c;break}}if(!l)throw Error(`Rip App: source('${i}') does not resolve to a source key — declare it with source() in app/stash.rip`);if(Di(l)){if(u==null)throw Error(`Rip App: keyed source('${i}') requires a key — source('${i}', key)`);l=l.cellFor(u)}else if(u!=null)throw Error(`Rip App: source('${i}') is not keyed — drop the key argument`);return a={refetch:l.refetch,reset:l.reset},Object.defineProperty(a,"value",{get(){return l.read()},set(r){return l.write(r)}}),Object.defineProperty(a,"loading",{get(){return l.loading}}),Object.defineProperty(a,"error",{get(){return l.error}}),a};case"peek":return function(i){let u,l;if(l=Zn(n),i==null)return l;for(let a of $n(i)){if(l==null)return;if(Wn(l)){if(Di(l))return;if(l=l.peek(),l==null)return}u=typeof a==="number"&&a<0&&Array.isArray(l)?l.length+a:a,l=l[u]}return Wn(l)?Di(l)?void 0:l.peek():l}}})(),e[f]=t,t};function _u(n={}){return Yl(n)}function Zn(n){return n?.[Symbol.for("raw")]?n[Symbol.for("raw")]:n}fu=function(n,f){return Wn(f)?void 0:f};Rl=function(n){if(!(n!=null&&typeof n==="object"))return!1;for(let f in n){if(!Object.hasOwn(n,f))continue;let e=n[f];if(e==null)continue;if(Wn(e))return!0;if(typeof e==="object"&&Rl(e))return!0}return!1};Ml=function(n,f){let e,t;t=Zn(n);for(let i in f){let u=f[i];if(e=t[i],Wn(e))continue;if(u!=null&&e!=null&&typeof u==="object"&&!Array.isArray(u)&&typeof e==="object"&&!Array.isArray(e)&&Rl(e))Ml(n[i],u);else n[i]=u}return};function mu(n,f={}){let e,t,i,u,l,a,c,r,h;if(Ui("persistStash"),h=Zn(n)||n,h[Symbol.for("persisted")])return function(){return null};h[Symbol.for("persisted")]=!0,c=f.local?localStorage:sessionStorage,r=f.key||"__rip_app";try{if(l=c.getItem(r),l)a=JSON.parse(l),Ml(n.data,a)}catch{}if(e=function(){return(()=>{try{return c.setItem(r,JSON.stringify(Zn(n.data),fu))}catch{return null}})()},u=ni(function(){let o;return mi.value,o=setTimeout(e,2000),function(){return clearTimeout(o)}}),window.addEventListener("beforeunload",e),t=Zn(n.data),t!=null&&typeof t==="object")Object.defineProperty(t,Vi,{value(){return(()=>{try{return c.removeItem(r)}catch{return null}})()},configurable:!0,writable:!0});return i=!1,function(){if(i)return;if(i=!0,u?.(),window.removeEventListener("beforeunload",e),e(),t!=null&&typeof t==="object")t[Vi]=null;return h[Symbol.for("persisted")]=!1}}function gt(n,f={}){let e,t,i,u,l,a,c,r;if(e=Sn(f.initial??null),i=Sn(!1),t=Sn(null),a=0,u=null,c=async function(){let h,o;return u?.abort(),u=typeof AbortController<"u"?new AbortController:null,h=++a,i.value=!0,t.value=null,await(async()=>{try{if(o=await n(u?.signal),h!==a)return;return e.value=o,o}catch(s){if(h!==a)return;if(s?.name==="AbortError")return;throw t.value=s,s}finally{if(h===a)i.value=!1}})()},l=function(){return a++,u?.abort(),u=null,i.value=!1,t.value=null},r={data:void 0,loading:void 0,error:void 0,refetch:c,dispose:l},Object.defineProperty(r,"data",{get(){return e.value}}),Object.defineProperty(r,"loading",{get(){return i.value}}),Object.defineProperty(r,"error",{get(){return t.value}}),!f.lazy)c().catch(function(){return null});return r}Nf=/^(\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\s*(s|sec|second|seconds|m|min|minute|minutes|h|hr|hour|hours|d|day|days|w|week|weeks|y|year|years)$/i;function Ct(n){let f,e,t;if(n==null)return 0;if(typeof n==="number")return n;if(typeof n==="string"){if(n==="forever")return 1/0;if(t=n.match(Nf),t)return e=parseFloat(t[1]),(()=>{switch(t[2][0].toLowerCase()){case"s":return e*1000;case"m":return e*60000;case"h":return e*3600000;case"d":return e*86400000;case"w":return e*604800000;case"y":return e*31536000000;default:return e*1000}})();if(/^\d+$/.test(n))return parseInt(n,10)}return f=typeof n==="symbol"?String(n):JSON.stringify(n),console.warn(`[Rip] source: unrecognized staleTime ${f} — treating as 0 (use e.g. '5 min', '2 hours', a number of ms, or 'forever')`),0}bf=30000;Zl=function(n,f){let e,t,i,u,l,a,c,r,h,o,s,w;return e=Sn(null),i=Sn(!1),t=Sn(null),c=0,l=null,r=null,s=0,a=0,o=async function(_,A){let y,R;if(l?.abort(),l=typeof AbortController<"u"?new AbortController:null,y=++c,!_)i.value=!0;return await(async()=>{try{if(R=await n(l?.signal),y!==c)return R;return t.value=null,e.value=R,s=Date.now(),a=A?s+bf:0,R}catch(U){if(y!==c)return;if(U?.name==="AbortError")return;if(t.value=U,e.read()==null)throw s=0,U;return}finally{if(y===c)i.value=!1,r=null}})()},w=function(_,A){let y;return y=o(_,A),r=y,y},h=function(){return f===1/0||Date.now()-s<f||Date.now()<a},u={},u[Li]=!0,u.read=function(){let _;if(_=e.value,_==null&&!r&&s===0)w(!1).catch(function(){return null});return _},u.peek=function(){return e.read()},u.ensure=function(){let _,A;if(A=e.read(),s!==0){if(_=!h(),a=0,_&&!r)w(!0).catch(function(){return null});return Promise.resolve(A)}if(r)return r.finally(function(){return a=0});return w(!1)},u.preload=function(){let _;if(_=e.read(),s!==0){if(!h()&&!r)w(!0,!0).catch(function(){return null});return Promise.resolve(_)}if(r)return r;return w(!1,!0)},u.write=function(_){return c++,l?.abort(),l=null,r=null,i.value=!1,t.value=null,e.value=_,s=_!=null?Date.now():0,a=0,_},u.reset=function(){c++,l?.abort(),l=null,r=null,i.value=!1,t.value=null,e.value=null,s=0,a=0;return},u.refetch=function(){return w(!1)},Object.defineProperty(u,"loading",{get(){return i.value}}),Object.defineProperty(u,"error",{get(){return t.value}}),u};Pf=64;cu=function(n,f){let e,t,i;return t=new Map,e=function(u){let l,a,c;if(c=u!=null&&typeof u==="object"?JSON.stringify(u):u,l=t.get(c),l)t.delete(c),t.set(c,l);else if(l=Zl(function(r){return n(u,r)},f),t.set(c,l),t.size>Pf)for(let r of t.keys()){if(a=t.get(r),a.loading)continue;a.reset(),t.delete(r);break}return l},i=function(u){return e(u).read()},i[pi]=!0,i.cellFor=e,i.reset=function(){for(let u of t.values())u.reset();t.clear();return},i};function vt(n){let f,e;return e=Ct(n.staleTime),f=n.fetch.length>=1?cu(n.fetch,e):Zl(n.fetch,e),f}function Tt(n,f={}){let e,t,i,u,l;return t=Sn(!1),i=Sn(!1),e=Sn(null),u=0,l=async function(...a){let c,r;c=++u,t.value=!0,i.value=!1,e.value=null;try{r=await n(...a)}catch(h){if(c!==u)return;e.value=h;try{if(f.onError)return await f.onError(h);else throw h}finally{t.value=!1}}if(c!==u)return;return await(async()=>{try{return i.value=!0,await f.onSuccess?.(r),r}finally{if(c===u)t.value=!1}})()},Object.defineProperty(l,"pending",{get(){return t.value}}),Object.defineProperty(l,"succeeded",{get(){return i.value}}),Object.defineProperty(l,"error",{get(){return e.value}}),l}Wi=function(n){return typeof n==="function"?n:function(){return n.value}};Mi=function(n,f){return Object.defineProperty(n,"dispose",{value(){return f?.()},configurable:!0,writable:!0}),n};Qi=function(n,f,e){let t;return t={read(){return n.read()}},Object.defineProperty(t,"value",{get(){return n.value},set(i){return f.value=i}}),Mi(t,e)};var yu=function(n,f){let e,t,i;return t=Wi(f),i=Sn(!!t()),e=ni(function(){let u;if(t())return u=setTimeout(function(){return i.value=!0},n),function(){return clearTimeout(u)};else return i.value=!1}),typeof f!=="function"?Qi(i,f,e):Mi(i,e)},Vt=function(n,f){let e,t,i;return t=Wi(f),i=Sn(t()),e=ni(function(){let u,l;return l=t(),u=setTimeout(function(){return i.value=l},n),function(){return clearTimeout(u)}}),typeof f!=="function"?Qi(i,f,e):Mi(i,e)},jt=function(n,f){let e,t,i,u;return t=Wi(f),u=Sn(t()),i=0,e=ni(function(){let l,a,c,r;if(r=t(),l=Date.now(),a=n-(l-i),a<=0)return u.value=r,i=l;else return c=setTimeout(function(){return u.value=t(),i=Date.now()},a),function(){return clearTimeout(c)}}),typeof f!=="function"?Qi(u,f,e):Mi(u,e)},Lt=function(n,f){let e,t,i;return t=Wi(f),i=Sn(!!t()),e=ni(function(){let u;if(t())return i.value=!0;else return u=setTimeout(function(){return i.value=!1},n),function(){return clearTimeout(u)}}),typeof f!=="function"?Qi(i,f,e):Mi(i,e)};function Au(){let n,f,e,t;return f=new Map,t=new Set,n=new Map,e=function(i,u){let l=[];for(let a of Array.from(t))l.push((()=>{try{return a(i,u)}catch(c){return console.error("[Rip] watcher error:",c)}})());return l},{read(i){return f.get(i)},write(i,u){let l;return l=!f.has(i),f.set(i,u),n.delete(i),e(l?"create":"change",i)},del(i){return f.delete(i),n.delete(i),e("delete",i)},exists(i){return f.has(i)},size(){return f.size},list(i=""){let u,l,a;a=[],u=i?i+"/":"";for(let[c]of f)if(c.startsWith(u)){if(l=c.slice(u.length),l.includes("/"))continue;a.push(c)}return a},listAll(i=""){let u,l;l=[],u=i?i+"/":"";for(let[a]of f)if(a.startsWith(u))l.push(a);return l},load(i){let u=[];for(let l in i){let a=i[l];f.set(l,a),u.push(n.delete(l))}return u},watch(i){let u;return t.add(i),u=!1,function(){if(u)return;return u=!0,t.delete(i)}},getCompiled(i){return n.get(i)},setCompiled(i,u){return n.set(i,u)}}}au=function(n){let f;if(f=n.replace(/\.rip$/,""),f=f.replace(/\[\.\.\.(\w+)\]/g,"*$1"),f=f.replace(/\[(\w+)\]/g,":$1"),f=f.split("/").filter(function(e){return!/^\(.+\)$/.test(e)}).join("/"),f==="index"||f==="")return"/";return f=f.replace(/\/index$/,""),"/"+f};hu=function(n){let f,e,t;return e=[],f=n.replace(/[.+?^${}()|[\]\\]/g,"\\$&"),t=f.replace(/\*(\w+)/g,function(i,u){return e.push(u),"(.*)"}).replace(/:(\w+)/g,function(i,u){return e.push(u),"([^/]+)"}),{regex:new RegExp("^"+t+"$"),names:e}};Fl=function(n,f){let e,t;for(let i of f)if(e=n.match(i.regex.regex),e){t={};for(let u=0;u<i.regex.names.length;u++){let l=i.regex.names[u];t[l]=decodeURIComponent(e[u+1])}return{route:i,params:t}}return null};Ti=function(n,f="_route"){let e,t,i,u,l,a,c,r,h,o;c=[],i=new Map,e=n.listAll(f);for(let s of e){if(a=s.slice(f.length+1),!a.endsWith(".rip"))continue;if(u=a.split("/").pop(),u==="_layout.rip"){t=a==="_layout.rip"?"":a.slice(0,-12),i.set(t,s);continue}if(u.startsWith("_"))continue;if(h=a.split("/"),h.length>1&&h.some(function(w,_){return _<h.length-1&&w.startsWith("_")}))continue;o=au(a),l=hu(o),c.push({pattern:o,regex:l,file:s,rel:a})}r=new Map;for(let s of c){if(r.has(s.pattern))throw Error(`Rip App: '${r.get(s.pattern)}' and '${s.rel}' both resolve to '${s.pattern}'`);r.set(s.pattern,s.rel)}return c.sort(function(s,w){let _,A,y,R;if(A=(s.pattern.match(/:/g)||[]).length,R=(w.pattern.match(/:/g)||[]).length,_=s.pattern.includes("*")?1:0,y=w.pattern.includes("*")?1:0,_!==y)return _-y;if(A!==R)return A-R;return s.pattern.localeCompare(w.pattern)}),{routes:c,layouts:i}};El=function(n,f,e){let t,i,u,l;if(t=[],u=n.slice(f.length+1),l=u.split("/"),i="",e.has(""))t.push(e.get(""));for(let a=0;a<l.length;a++){let c=l[a];if(a===l.length-1)break;if(i=i?i+"/"+c:c,e.has(i))t.push(e.get(i))}return t};function Du(n,f={}){let e,t,i,u,l,a,c,r,h,o,s,w,_,A,y,R,U,m,D,M,q,S,d,K,E,Z,Q,W,C,L,X,fn,Y,Un,G,O,J,P;if(Ui("createRouter"),L=f.root||"_route",R=f.base||"",m=f.hash||!1,S=f.onError||null,G=function(F){if(!R)return F;if(F===R)return"/";if(F.startsWith(R+"/"))return F.slice(R.length);return F},o=function(F){return R?R+F:F},W=function(){let F;if(m){if(F=location.hash.slice(1),!F)return"/";return F[0]==="/"?F:"/"+F}else return location.pathname+location.search+location.hash},P=function(F){return m?F==="/"?location.pathname:"#"+F.slice(1):o(F)},c=Sn(G(m?W():location.pathname)),a=Sn({}),h=Sn(null),i=Sn([]),r=Sn({}),t=Sn(""),u=yu(100,Sn(!1)),l=Sn(c.value),O=Ti(n,L),D=new Set,J=n.watch(function(F,N){if(!N.startsWith(L+"/"))return;return O=Ti(n,L)}),C=function(F){let N,un,$,tn,cn,on,b;if(cn=F.split("?")[0].split("#")[0],$=G(cn),$=$[0]==="/"?$:"/"+$,tn=F.split("?")[1]?.split("#")[0]||"",un=F.includes("#")?F.split("#")[1]:"",on=Fl($,O.routes),on){if(N=$,tn)N+=`?${tn}`;if(un)N+=`#${un}`;ji(function(){return c.value=$,a.value=on.params,h.value=on.route,i.value=El(on.route.file,L,O.layouts),r.value=Object.fromEntries(new URLSearchParams(tn)),t.value=un,l.value=N}),b=Array.from(D);for(let p of b)try{p(X.current)}catch(v){console.error("[Rip] router onNavigate callback error:",v)}return!0}if(S)S({status:404,path:$});return!1},Z=null,typeof history<"u"&&"scrollRestoration"in history)Z=history.scrollRestoration,history.scrollRestoration="manual";if(Q=function(F){return typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame(F):setTimeout(F,16)},w=function(F){let N,un;if(typeof window>"u")return;return N=0,un=function(){let $;return $=Math.max(0,(document?.documentElement?.scrollHeight||0)-window.innerHeight),window.scrollTo(0,Math.min(F,$)),N+=1,F>$&&N<20?Q(un):void 0},Q(un)},Y=null,K=function(){if(Y||typeof window>"u")return;return Y=setTimeout(function(){return Y=null,(()=>{try{return history.replaceState({...history.state||{},_ripScroll:window.scrollY},"",location.href)}catch{}})()},100)},typeof window<"u")window.addEventListener("scroll",K,{passive:!0});if(d=function(F){let N;return N=F?.state?._ripScroll,C(W()),typeof N==="number"?w(N):void 0},typeof window<"u")window.addEventListener("popstate",d);if(Un=function(F){let N;if(!F?.href)return!0;if(N=(()=>{try{return new URL(F.href,location.origin)}catch{return null}})(),!N)return!0;if(N.origin!==location.origin)return!0;if(F.target==="_blank")return!0;if(F.hasAttribute("download"))return!0;if(F.hasAttribute("data-router-ignore"))return!0;if(R&&!m){if(!(N.pathname===R||N.pathname.startsWith(R+"/")))return!0}return!1},q=function(F){let N,un,$,tn;if(F.defaultPrevented)return;if(F.button!==0||F.metaKey||F.ctrlKey||F.shiftKey||F.altKey)return;$=F.target;while($&&$.tagName!=="A")$=$.parentElement;if(!$)return;if(Un($))return;return tn=new URL($.href,location.origin),F.preventDefault(),N=m&&tn.hash?tn.hash.slice(1)||"/":tn.pathname+tn.search+tn.hash,un=$.hasAttribute("data-router-noscroll"),X.push(N,{noScroll:un})},typeof document<"u")document.addEventListener("click",q);return E=new WeakSet,M=function(F){let N;if(N=F.split("?")[0].split("#")[0],N=decodeURIComponent(N),N=G(N),N[0]!=="/")N="/"+N;if(N.length>1&&N.endsWith("/"))N=N.slice(0,-1);return N},U=function(){let F;if(F=m?G(W()).split("?")[0].split("#")[0]:c.value.split("?")[0].split("#")[0],F[0]!=="/")F="/"+F;if(F.length>1&&F.endsWith("/"))F=F.slice(0,-1);return F},s=function(){let F,N,un,$,tn,cn;if(typeof document>"u")return;N=U(),F=document.querySelectorAll("a[href]");for(let on of F){if(Un(on))continue;if(cn=(()=>{try{return new URL(on.href,location.origin)}catch{return null}})(),!cn)continue;if(tn=M(cn.pathname+cn.search+cn.hash),un=null,tn===N)un="page";if(!un&&N!=="/"&&N.startsWith(tn+"/")&&tn!=="")un="true";if($=on.getAttribute("aria-current"),un){if($&&!E.has(on))continue;on.setAttribute("aria-current",un),E.add(on)}else if(E.has(on))on.removeAttribute("aria-current"),E.delete(on)}return},A=null,y=!1,fn=function(){let F;if(y)return;return y=!0,F=function(){return y=!1,s()},typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame(F):setTimeout(F,0)},_=ni(function(){let F;if(typeof document>"u")return;if(U(),fn(),!A)A=new MutationObserver(function(){return fn()}),F=document.body||document.documentElement,A.observe(F,{childList:!0,subtree:!0});return}),X={push(F,N){let un;if(un=typeof window<"u"?window.scrollY:0,C(F)){try{history.replaceState({...history.state||{},_ripScroll:un},"",location.href)}catch{}return history.pushState({_ripScroll:0},"",P(l.read())),!N?.noScroll&&typeof window<"u"?window.scrollTo(0,0):void 0}},replace(F,N){if(C(F))return history.replaceState({_ripScroll:0},"",P(l.read())),!N?.noScroll&&typeof window<"u"?window.scrollTo(0,0):void 0},back(){return history.back()},forward(){return history.forward()},current:void 0,path:void 0,params:void 0,route:void 0,layouts:void 0,query:void 0,hash:void 0,navigating:void 0,onNavigate(F){return D.add(F),function(){return D.delete(F)}},rebuild(){return O=Ti(n,L)},match(F){let N,un,$,tn,cn;if(/^[a-z][a-z0-9+.-]*:\/\//i.test(F)){if(cn=(()=>{try{return new URL(F,location.origin)}catch{return null}})(),!cn)return null;F=m&&cn.hash?cn.hash.slice(1)||"/":cn.pathname+cn.search+cn.hash}if($=F.split("?")[0].split("#")[0],N=G($),N=N[0]==="/"?N:"/"+N,un=F.split("?")[1]?.split("#")[0]||"",tn=Fl(N,O.routes),!tn)return null;return{path:N,params:tn.params,route:tn.route,layouts:El(tn.route.file,L,O.layouts),query:Object.fromEntries(new URLSearchParams(un)),hash:F.includes("#")?F.split("#")[1]:""}},ownsAnchor(F){return!Un(F)},routes:void 0,init(){return C(W()),X},destroy(){if(typeof window<"u")window.removeEventListener("popstate",d);if(typeof window<"u")window.removeEventListener("scroll",K);if(typeof document<"u")document.removeEventListener("click",q);if(Z!==null&&typeof history<"u")history.scrollRestoration=Z;return A?.disconnect(),A=null,_?.(),J?.(),J=null,u?.dispose?.(),D.clear()}},e=If(function(){return{path:c.value,params:a.value,route:h.value,layouts:i.value,query:r.value,hash:t.value}}),Object.defineProperty(X,"current",{get(){return e.value}}),Object.defineProperty(X,"path",{get(){return c.value}}),Object.defineProperty(X,"params",{get(){return a.value}}),Object.defineProperty(X,"route",{get(){return h.value}}),Object.defineProperty(X,"layouts",{get(){return i.value}}),Object.defineProperty(X,"query",{get(){return r.value}}),Object.defineProperty(X,"hash",{get(){return t.value}}),Object.defineProperty(X,"navigating",{get(){return u.value},set(F){return u.value=F}}),Object.defineProperty(X,"routes",{get(){return O.routes}}),X}Ul=function(n,f){if(n.length!==f.length)return!1;for(let e=0;e<n.length;e++)if(n[e]!==f[e])return!1;return!0};Hi=function(n){if(typeof n.default==="function"&&(n.default.prototype?.mount||n.default.prototype?._create))return n.default;for(let f in n){let e=n[f];if(typeof e==="function"&&(e.prototype?.mount||e.prototype?._create))return e}return typeof n.default==="function"?n.default:void 0};Sl=function(n){let f;f={};for(let e in n){let t=n[e];if(typeof t==="function"&&(t.prototype?.mount||t.prototype?._create))f[e]=t}return f};tu=function(n){let f;return f=n.split("/").pop().replace(/\.rip$/,""),f.replace(/(^|[-_])([a-z])/g,function(e,t,i){return i.toUpperCase()})};uu=function(n,f=["_app","_lib","_pkg","_route"]){let e,t,i,u,l;t={},l=Array.isArray(f)?f:[f],u=[];for(let a of l)for(let c of n.listAll(a))u.push(c);for(let a of u){if(!a.endsWith(".rip"))continue;if(e=a.split("/").pop(),e.startsWith("_"))continue;if(e==="index.rip")continue;if(i=tu(a),t[i])console.warn(`[Rip] Component name collision: ${i} (${t[i]} vs ${a})`);t[i]=a}return t};su=function(n,f,e){let t,i,u,l;if(i=n.replace(/^(\.\.\/|\.\/)+/,""),f){u=f.split("/"),u.pop();for(let a of n.split("/"))if(a==="..")u.pop();else if(a!==".")u.push(a);if(t=u.join("/"),e.exists(t))return t}if(e.exists(i))return i;for(let a of["_pkg","_lib","_app","_route"])if(l=`${a}/${i}`,e.exists(l))return l;return null};ql=function(n){let f,e,t,i,u,l,a;if(!n)return[];if(l=n.trim(),!l)return[];if(i=[],f=l.indexOf("{"),f>=0){if(e=l.lastIndexOf("}"),e<0)return i;t=l.slice(f+1,e);for(let c of t.split(",")){if(a=c.trim(),!a)continue;i.push(a.split(/\s+as\s+/).pop().trim())}l=l.slice(0,f).replace(/,\s*$/,"").trim()}for(let c of l.split(",")){if(u=c.trim(),!u)continue;if(/^\*\s+as\s+/.test(u))i.push(u.replace(/^\*\s+as\s+/,"").trim());else i.push(u)}return i};kn=async function(n,f,e=null,t=null,i=null){let u,l,a,c,r,h,o,s,w,_,A,y,R,U,m,D,M,q,S,d,K,E,Z,Q,W,C,L,X,fn,Y,Un,G,O,J,P;if(e&&t){if(h=e.getCompiled(t),h)return h}if(i&&t)i.compiling??={},i.compiling[t]=!0;return await(async()=>{try{if(s=globalThis?.__ripDebug?.enabled&&t,fn=0,D=s?f(n,{sourceMap:"inline",filename:t}):f(n),i){if(m=new Set,W=i.packages||{},Object.keys(W).length>0)l=/^(\s*import\s+(?:.*?\s+from\s+)?['"])(@rip-lang\/[^\/'"]+)((?:\/[^'"]*)?)(['"];?\s*)$/gm,D=D.replace(l,function(F,N,un,$,tn){let cn,on;if(cn=W[un],!cn)return F;return on=!$?`_pkg/${cn.short}/${cn.entry}`:$.endsWith(".rip")?`_pkg/${cn.short}${$}`:`_pkg/${cn.short}${$}.rip`,`${N}${on}${tn}`});if(Q=/^(\s*)import\s+([^'"]+?)\s+from\s+['"](@rip-lang\/[^'"]+)['"];?\s*$/gm,D=D.replace(Q,function(F,N,un,$){let tn,cn,on,b,p,v,ln,rn;if(ln=$.replace(/^(@rip-lang\/[^\/]+).*$/,"$1"),W[ln])return F;if(rn=un.trim(),rn.startsWith("type "))return`${N}// type-only import erased: ${$}`;if(b=rn.indexOf("{"),cn=rn.lastIndexOf("}"),b<0||cn<=b)return console.warn(`[Rip] Skipping non-named import from ${$}; only named imports from '@rip-lang/*' are supported.`),F;v=[];for(let en of rn.slice(b+1,cn).split(",")){if(on=en.trim().replace(/^type\s+/,""),!on)continue;if(/\s+as\s+/.test(on))[p,tn]=on.split(/\s+as\s+/).map(function(sn){return sn.trim()}),v.push(`${p}: ${tn}`);else v.push(on)}if(v.length===0)return`${N}// import erased: ${$}`;return`${N}const { ${v.join(", ")} } = globalThis;`}),e){G=/^(\s*(?:import|export)\s+(?:(.*?)\s+from\s+)?['"])([^'"]*\.rip)(['"];?\s*)$/gm,q=Array.from(D.matchAll(G));for(let F=q.length-1;F>=0;F--){let N=q[F];if([R,L,a,O,C]=N,J=su(O,t,e),J===t)continue;if(!J){if(d=`[Rip] Could not resolve import: ${O}`,t)d+=` (from ${t})`;console.warn(d);continue}if(!i.blobUrls?.[J]){if(i.compiling?.[J])continue;if(_=e.read(J),_)await kn(_,f,e,J,i)}if(r=i.blobUrls?.[J],r){Un=`${L}${r}${C}`,D=D.slice(0,N.index)+Un+D.slice(N.index+R.length);for(let un of ql(a))m.add(un)}}}u=/^\s*(?:import|export)\s+(?:(.*?)\s+from\s+)?['"][^'"]*['"];?\s*$/gm;for(let F of D.matchAll(u))for(let N of ql(F[1]))m.add(N);E={};for(let F in i.map){let N=i.map[F];if(m.has(F))continue;if(N!==t&&D.includes(`new ${F}(`)){if(!i.classes[F]){if(_=e.read(N),_){w=await kn(_,f,e,N,i),y=Sl(w);for(let un in y){let $=y[un];i.classes[un]=$}}}if(i.classes[F])E[F]=!0}}if(K=Object.keys(E),K.length>0)M=JSON.stringify(i.key),X=`const {${K.join(", ")}} = globalThis[${M}];
2977
2977
  `,D=X+D,fn+=1}if(U=t?`// ${t}
2978
- `:"",U)fn+=1;if(A=U+D,s&&fn>0){if(Z=globalThis?.__ripDebug?.offsetSourceMap,Z)A=Z(A,fn)}if(c=new Blob([A],{type:"application/javascript"}),P=URL.createObjectURL(c),Y=null,i&&t){if(i.blobUrls??={},Y=i.blobUrls[t],Y&&Y!==P)try{URL.revokeObjectURL(Y)}catch{}i.blobUrls[t]=P}if(S=await import(P),o=!0,i){y=Sl(S);for(let F in y){let N=y[F];i.classes[F]=N}}if(e&&t)e.setCompiled(t,S);return S}finally{if(i&&t){if(i.compiling)delete i.compiling[t]}if(!o&&P&&i&&t){try{URL.revokeObjectURL(P)}catch{}if(i.blobUrls?.[t]===P)delete i.blobUrls[t]}}})()};zl=function(n,f){let e;return n.innerHTML="",e=document.createElement("pre"),e.style.cssText="margin:2rem;padding:1rem 1.25rem;color:#b91c1c;background:#fef2f2;border:1px solid #fecaca;border-radius:8px;font:13px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;overflow-wrap:anywhere",e.textContent=f,n.appendChild(e)};function Ru(n){let f,e,t,i,u,l,a,c,r,h,o,s,w,_,A,y,R,U,m,D,M,q,S,d,K,E,Z,Q,W,C,L,X,fn,Y,Un,G,O;if(Ui("createRenderer"),{router:W,app:e,components:u,resolver:Z,compile:i,target:Y,onError:D}=n,d=n.preload==="intent",l=typeof Y==="string"?document.querySelector(Y):Y||document.getElementById("app"),!l)l=document.createElement("div"),l.id="app",document.body.appendChild(l);return a=null,o=null,r=null,h=null,c=[],R=[],U=l,_=0,s=null,O=null,A=function(J){if(!Z)return;if(Z.blobUrls?.[J]){try{URL.revokeObjectURL(Z.blobUrls[J])}catch{}delete Z.blobUrls[J]}return Z.classes&&Z.map?(()=>{let P=[];for(let F in Z.map){let N=Z.map[F];P.push(N===J?delete Z.classes[F]:void 0)}return P})():void 0},G=function(){if(a){try{a.unmount?.({removeDOM:!1})}catch(J){console.error("[Rip] page unmount error:",J)}return a=null,o=null}},Un=function(){G();for(let J=R.length-1;J>=0;J--){let P=R[J];try{P.unmount?.({removeDOM:!0})}catch(F){console.error("[Rip] layout unmount error:",F)}}return R=[],U=l,r=null,h=null,c=[]},C=function(J,P){if(!(J&&P))return!1;if(Object.keys(J).length!==Object.keys(P).length)return!1;for(let F in J){let N=J[F];if(P[F]!==N)return!1}return!0},E=function(J){let P;P=Zn(e.data);for(let F of J.split(".")){if(!(P!=null&&typeof P==="object"))return null;if(P=P[F],Wn(P))return P}return null},w=async function(J,P,F,N=!1,un=0){let $,tn,cn,on,b,p,v,ln,rn,en,sn,wn,_n,Rn;ln=new Map;for(let An=0;An<J.length;An++){let g=J[An];if(An<un)continue;if(b=g.cls?.__gates,!(b&&b.length))continue;for(let nn of b){if(_n=typeof nn==="string"?nn:nn.path,en=typeof nn==="string"?null:nn.key,$=E(_n),!$)throw Error(`[Rip] ${g.file}: '${_n} <~' does not resolve to a source — declare it with source() in app/stash.rip`);if(rn=void 0,Di($)){if(!en)throw Error(`[Rip] ${g.file}: '${_n}' is a keyed source — gate with a key: ${_n}(params.…)`);rn=en(P||{},F||{}),$=$.cellFor(rn)}else if(en)throw Error(`[Rip] ${g.file}: '${_n}' is not a keyed source — drop the key argument`);if(p=_n+"|"+String(rn??""),v=ln.get(p),!v)v={cell:$,owners:[],path:_n},ln.set(p,v);v.owners.push(An)}}if(sn=[...ln.values()],!sn.length)return{failedIndex:1/0,failure:null};Rn=await Promise.allSettled(sn.map(function(An){return N?An.cell.preload():An.cell.ensure()})),cn=1/0,on=null;for(let An=0;An<Rn.length;An++){let g=Rn[An];if(tn=null,g.status==="rejected")tn=g.reason;else if(!N&&g.value==null)tn=Error(`[Rip] gate '${sn[An].path} <~' resolved to ${g.value}: a gated source must resolve to a non-null value or throw. For a value that can be absent, read it ungated with ~= instead of gating it.`);if(!tn)continue;if(wn=Math.min(...sn[An].owners),wn<cn)cn=wn,on={status:tn?.status??tn?.response?.status??500,message:tn?.message??String(tn),error:tn,path:sn[An].path}}return{failedIndex:cn,failure:on}},Q=function(J){let P;P=!1;for(let F=R.length-1;F>=0;F--){let N=R[F];if(N.onError)try{N.onError(J),P=!0;break}catch(un){console.error("Renderer: error boundary failed:",un)}}if(!P){if(console.error(`Renderer: gate '${J.path}' failed:`,J.error),D)D(J);return Un(),zl(l,`${J.status}: ${J.message}`)}},m=async function(J,P=!1){let F,N,un,$,tn,cn,on,b,p,v,ln,rn,en,sn,wn,_n,Rn,An,g,nn,zn,Mn,B,T,x,k,an,V,hn,yn,mn,En,Jn,Gn,Yn,gn;if({route:En,params:V,layouts:_n,query:yn}=J,!En)return;if(Jn=En.file===o&&C(V,r),mn=function(){let dn,Pn;if(dn=a?.constructor,Pn=dn?.__gates,!Pn)return!1;for(let ii of Pn)if(typeof ii!=="string"&&ii.key)try{if(ii.key(V||{},h||{})!==ii.key(V||{},yn||{}))return!0}catch{return!0}return!1},Jn&&!P&&!mn()){if(!C(yn,h)){if(h=yn,a?.load)try{await a.load(V,yn)}catch(dn){if(console.error(`Renderer: error in query-only load for ${En.file}:`,dn),D)D({status:500,message:dn.message,error:dn})}}return}return ln=++_,W.navigating=!0,await(async()=>{try{if(Yn=u.read(En.file),!Yn){if(D)D({status:404,message:`File not found: ${En.file}`});W.navigating=!1;return}if(nn=await kn(Yn,i,u,En.file,Z),ln!==_){W.navigating=!1;return}if(F=Hi(nn),!F){if(D)D({status:500,message:`No component found in ${En.file}`});W.navigating=!1;return}wn=[];for(let dn of _n){if(An=u.read(dn),!An)continue;if(Rn=await kn(An,i,u,dn,Z),ln!==_){W.navigating=!1;return}if(N=Hi(Rn),!N)continue;wn.push({file:dn,cls:N})}if(on=[...wn,{file:En.file,cls:F}],g=!Ul(_n,c),zn=g?0:wn.length,{failedIndex:p,failure:v}=await w(on,V,yn,!1,zn),ln!==_){W.navigating=!1;return}if(B=a?._target,g)Un();else G();if(r=V,h=yn,Mn=g?l:U,b=Math.min(p,wn.length),g&&_n.length>0){l.innerHTML="",Mn=l,cn=globalThis.__ripComponent?.__pushComponent,$=globalThis.__ripComponent?.__popComponent,T=null;for(let dn=0;dn<wn.length;dn++){let Pn=wn[dn];if(dn>=b)break;N=Pn.cls,hn=cn?.(T),globalThis.__ripGateMount=N;try{en=new N({app:e,params:V,router:W})}finally{globalThis.__ripGateMount=null,$?.(hn)}if(en.beforeMount){un=cn?.(en);try{en.beforeMount()}finally{$?.(un)}}gn=document.createElement("div"),gn.setAttribute("data-layout",Pn.file),Mn.appendChild(gn),en.mount(gn),R.push(en),T=en,Gn=gn.querySelector("#content")||gn,Mn=Gn}c=b<wn.length?_n.slice(0,b):[..._n],U=Mn}else if(g)l.innerHTML="",c=[],U=l;if(v){B?.remove(),Q(v),W.navigating=!1;return}an=document.createElement("div"),an.setAttribute("data-component",En.file),Mn.appendChild(an),cn=globalThis.__ripComponent?.__pushComponent,$=globalThis.__ripComponent?.__popComponent,x=R[R.length-1]||null,k=cn?.(x),globalThis.__ripGateMount=F;try{sn=new F({app:e,params:V,query:yn,router:W})}finally{globalThis.__ripGateMount=null,$?.(k)}if(sn.beforeMount){tn=cn?.(sn);try{sn.beforeMount()}finally{$?.(tn)}}if(sn.mount(an),a=sn,o=En.file,sn.load)await sn.load(V,yn);return B?.remove(),W.navigating=!1}catch(dn){if(W.navigating=!1,console.error(`Renderer: error mounting ${En.file}:`,dn),D)D({status:500,message:dn.message,error:dn});rn=!1;for(let Pn=R.length-1;Pn>=0;Pn--){let ii=R[Pn];if(ii.onError)try{ii.onError(dn),rn=!0;break}catch(Mu){console.error("Renderer: error boundary failed:",Mu)}}return(()=>{if(!rn)return Un(),zl(l,dn.stack||dn.message)})()}})()},fn=!1,S=async function(J){let P,F,N,un,$,tn,cn,on;if(N=W.match?.(J),!N?.route)return;if(tn=Ul(N.layouts,c),tn&&N.route.file===o&&C(N.params,r))return;if(P=[],!tn)for(let b of N.layouts){if($=u.read(b),!$)continue;if(un=await kn($,i,u,b,Z),F=Hi(un),F)P.push({file:b,cls:F})}if(on=u.read(N.route.file),on){if(cn=await kn(on,i,u,N.route.file,Z),F=Hi(cn),F)P.push({file:N.route.file,cls:F})}await w(P,N.params,N.query,!0);return},f=50,y={href:null,at:0},X=null,L=null,t=function(){if(X)clearTimeout(X),X=null;return L=null},M=function(J){let P,F;P=J.target;while(P&&P.tagName!=="A")P=P.parentElement;if(!P)return;if(!W.ownsAnchor?.(P))return;if(P===L)return;return t(),L=P,F=P.href,X=setTimeout(function(){let N;if(X=null,L=null,N=Date.now(),F===y.href&&N-y.at<3000)return;return y.href=F,y.at=N,S(F).catch(function(){return null})},f)},q=function(J){let P;if(!L)return;return P=J.relatedTarget,!(P&&L.contains(P))?t():void 0},K={start(){if(fn)return K;if(fn=!0,s=ni(function(){let J;return J=W.current,J.route?m(J):void 0}),O=u?.watch(function(J,P){return(Array.isArray(["change","delete"])?["change","delete"].includes(J):(J in["change","delete"]))?A(P):void 0}),d)document.addEventListener("pointerover",M,{passive:!0}),document.addEventListener("focusin",M,{passive:!0}),document.addEventListener("pointerout",q,{passive:!0}),document.addEventListener("focusout",q,{passive:!0});return W.init(),K},stop(){if(!fn)return;if(fn=!1,Un(),s)s(),s=null;if(O?.(),O=null,t(),d)document.removeEventListener("pointerover",M),document.removeEventListener("focusin",M),document.removeEventListener("pointerout",q),document.removeEventListener("focusout",q);if(Z?.blobUrls){for(let J in Z.blobUrls){if(!Object.hasOwn(Z.blobUrls,J))continue;let P=Z.blobUrls[J];try{URL.revokeObjectURL(P)}catch{}}Z.blobUrls={}}return l.innerHTML=""},remount(J=!1){let P,F;return F=typeof J==="object"?!!J.force:!!J,P=W.current,P.route?m(P,F):void 0}},K}eu=function(n){let f,e,t,i,u,l;return Ui("connectWatch"),u=1000,i=30000,f=!1,t=null,l=null,e=function(){if(f)return;return t=new EventSource(n),t.addEventListener("connected",function(){return u=1000,console.log("[Rip] Hot reload connected")}),t.addEventListener("reload",function(){return console.log("[Rip] Reloading..."),location.reload()}),t.addEventListener("css",function(){let a,c;c=document.querySelectorAll('link[rel="stylesheet"]');let r=[];for(let h of c)a=new URL(h.href),a.searchParams.set("_t",Date.now()),h.href=a.toString();return r}),t.onerror=function(){if(t.close(),t=null,f)return;return l=setTimeout(e,u),u=Math.min(u*2,i)}},e(),function(){if(f)return;if(f=!0,l)clearTimeout(l),l=null;return t?.close(),t=null}};async function pt(n={}){let f,e,t,i,u,l,a,c,r,h,o,s,w,_,A,y,R,U,m,D,M,q,S,d,K,E,Z,Q;if(Ui("launch"),e=(n.base||"").replace(/\/+$/,""),E=n.target||"#app",a=n.compile||null,A=n.persist||!1,w=n.hash||!1,!a)a=globalThis?.compileToJS||null;if(!document.querySelector(E))h=document.createElement("div"),h.id=E.replace(/^#/,""),document.body.prepend(h);if(n.bundle)i=n.bundle;else if(n.bundleUrl){if(_={},s=`__rip_etag_${n.bundleUrl}`,u=sessionStorage.getItem(s),u)_["If-None-Match"]=u;if(U=await fetch(n.bundleUrl,{headers:_}),U.status===304)i=JSON.parse(sessionStorage.getItem(`${s}_data`));else if(U.ok){if(i=await U.json(),o=U.headers.get("etag"),o)sessionStorage.setItem(s,o),sessionStorage.setItem(`${s}_data`,JSON.stringify(i))}else throw Error(`launch: ${n.bundleUrl} (${U.status})`)}else throw Error("launch: no bundle or bundleUrl provided");if(f=_u({components:{},routes:{},data:{}}),globalThis.__ripApp=f,t=Au(),i.modules)t.load(i.modules);if(l=`__rip_${e.replace(/\//g,"_")||"app"}`,m={map:uu(t),classes:{},key:l,packages:i.packages||{}},globalThis[l]=m.classes,d=null,S="_app/stash.rip",t.exists(S)){if(K=t.read(S),K)try{if(q=await kn(K,a,t,S,m),q?.stash)d=q.stash}catch(W){console.error(`[Rip] Failed to load app/stash.rip: ${W.message}`,W)}}if(d&&i.data)for(let W in i.data){let C=i.data[W];if(!Wn(d[W]))d[W]=C}if(M=d??i.data,M)f.data=M;if(ou(Zn(f.data)),i.routes)f.routes=i.routes;if(y=null,A)y=mu(f,{local:A==="local",key:`__rip_${e}`});if(f.data.title)document.title=f.data.title;if(D=Du(t,{root:"_route",base:e,hash:w,onError(W){return console.error(`[Rip] Error ${W.status}: ${W.message||W.path}`)}}),globalThis.__ripRouter=D,R=Ru({router:D,app:f,components:t,resolver:m,compile:a,target:E,preload:i.data?.preload==="intent"?"intent":!1,onError(W){return console.error(`[Rip] ${W.message}`,W.error)}}),R.start(),Z=null,i.data?.watch)Z=eu(`${e}/watch`);return Q=window,r=!1,c=function(){if(r)return;if(r=!0,Z?.(),R.stop(),D.destroy(),y?.(),delete globalThis[l],delete globalThis.__ripApp,delete globalThis.__ripRouter,delete globalThis.__ripLaunched,Q.app===f)delete Q.app;return Q.__RIP__?.app===f?delete Q.__RIP__:void 0},Q.app=f,Q.__RIP__={app:f,components:t,router:D,renderer:R,resolver:m,destroy:c,version:"0.3.0"},globalThis.__ripLaunched=!0,{app:f,components:t,router:D,renderer:R,destroy:c}}Kn=function(n,f){if(!f)return;return n.preventDefault(),n.stopPropagation(),f()};globalThis.__ariaLastFocusedEl??=null;if(typeof document<"u"&&!globalThis.__ariaFocusTrackerBound)document.addEventListener("focusin",function(n){return globalThis.__ariaLastFocusedEl=n.target},!0),globalThis.__ariaFocusTrackerBound=!0;Tf=function(n,f){if(n.isComposing)return;return(()=>{switch(n.key){case"ArrowDown":return Kn(n,f.next);case"ArrowUp":return Kn(n,f.prev);case"Home":case"PageUp":return Kn(n,f.first);case"End":case"PageDown":return Kn(n,f.last);case"Enter":case" ":return Kn(n,f.select);case"Escape":return Kn(n,f.dismiss);case"Tab":return f.tab?.();default:return n.key.length===1?f.char?.(n.key):void 0}})()};jf=function(n,f,e,t=[],i=null){let u,l,a,c,r;if(l=function(h){return typeof h==="function"?h():h},r=l(f),r&&r.__ariaPopupDismiss)r.__ariaPopupDismiss(),r.__ariaPopupDismiss=null;if(!(n&&r))return;return a=(h)=>{return![r,...t.map(l)].some(function(o){return o?.contains(h.target)})?e():void 0},c=(h)=>{if(r?.contains(h.target))return;return i?i():e()},document.addEventListener("mousedown",a),window.addEventListener("scroll",c,!0),u=function(){return document.removeEventListener("mousedown",a),window.removeEventListener("scroll",c,!0)},r.__ariaPopupDismiss=u,u};Lf=function(n=250){let f;return f=0,{block(e=n){return f=Date.now()+e},canOpen(){return Date.now()>=f}}};Cf=function(n,f,e,t=null){let i,u,l,a,c,r,h,o,s,w,_;if(a=function(A){return typeof A==="function"?A():A},i=function(){let A,y;if(A=document.activeElement,A&&A!==document.body)return A;if(y=globalThis.__ariaLastFocusedEl,y?.isConnected!==!1)return y;return null},l=a(f),!l)return;if(!Object.hasOwn(HTMLElement.prototype,"togglePopover"))return;if(h=null,_=function(A){if(A){l.hidden=!1;try{l.inert=!1}catch{}return l.removeAttribute("aria-hidden")}else{try{l.inert=!0}catch{}return l.setAttribute("aria-hidden","true"),l.hidden=!0}},o=function(){let A,y;if(y=h,h=null,!y?.focus)return;return A=function(R=6){if(y.isConnected===!1)return;try{y.focus({preventScroll:!0})}catch{y.focus()}if(document.activeElement===y||R<=1)return;return setTimeout(function(){return A(R-1)},16)},requestAnimationFrame(function(){return A()})},l.__ariaBindPopover)l.removeEventListener("toggle",l.__ariaBindPopover),l.__ariaBindPopover=null;if(c=function(A){let y;if(y=A.newState==="open",y)h=a(t)||i(),_(!0);else _(!1),o();return e?.(y)},l.addEventListener("toggle",c),l.__ariaBindPopover=c,s=l.matches(":popover-open"),u=!!n,s!==u){if(w=a(t),u)h=w||i(),_(!0);r=w&&u?{force:u,source:w}:{force:u};try{l.togglePopover(r)}catch{}}else _(u);return function(){return l.removeEventListener("toggle",c),l.__ariaBindPopover===c?l.__ariaBindPopover=null:void 0}};gf=function(n,f,e,t=!0){let i,u,l,a,c,r,h,o,s,w;if(l=function(_){return typeof _==="function"?_():_},i=function(){let _,A;if(_=document.activeElement,_&&_!==document.body)return _;if(A=globalThis.__ariaLastFocusedEl,A?.isConnected!==!1)return A;return null},u=l(f),!u?.showModal)return;if(o=null,w=function(_){if(_){u.hidden=!1;try{u.inert=!1}catch{}return u.removeAttribute("aria-hidden")}else{try{u.inert=!0}catch{}return u.setAttribute("aria-hidden","true"),u.hidden=!0}},s=function(){let _,A;if(A=o,o=null,!A?.focus)return;return _=function(y=6){if(A.isConnected===!1)return;try{A.focus({preventScroll:!0})}catch{A.focus()}if(document.activeElement===A||y<=1)return;return setTimeout(function(){return _(y-1)},16)},requestAnimationFrame(function(){return _()})},u.__ariaBindDialog)[r,h]=u.__ariaBindDialog,u.removeEventListener("cancel",r),u.removeEventListener("close",h),u.__ariaBindDialog=null;if(a=function(_){if(!t){_.preventDefault();return}return e?.(!1)},c=function(){return e?.(!1),w(!1),s()},u.addEventListener("cancel",a),u.addEventListener("close",c),u.__ariaBindDialog=[a,c],n&&!u.open){if(!o)o=i();w(!0);try{u.showModal()}catch{}}else if(!n&&u.open)u.close();else w(!!n);return function(){return u.removeEventListener("cancel",a),u.removeEventListener("close",c),u.__ariaBindDialog?.[0]===a?u.__ariaBindDialog=null:void 0}};kf=function(n,f,e="vertical"){let t,i;if(n.isComposing)return;return i=e!=="horizontal",t=e!=="vertical",(()=>{switch(n.key){case"ArrowDown":return i?Kn(n,f.next):void 0;case"ArrowUp":return i?Kn(n,f.prev):void 0;case"ArrowRight":return t?Kn(n,f.next):void 0;case"ArrowLeft":return t?Kn(n,f.prev):void 0;case"Home":case"PageUp":return Kn(n,f.first);case"End":case"PageDown":return Kn(n,f.last);case"Enter":case" ":return Kn(n,f.select);case"Escape":return Kn(n,f.dismiss);default:return n.key.length===1?f.char?.(n.key):void 0}})()};xf=function(n,f,e=4,t=!0){let i,u;if(!(n&&f))return;if(u=n.getBoundingClientRect(),f.style.position="fixed",f.style.left=`${u.left}px`,f.style.top=`${u.bottom+e}px`,f.style.minWidth=`${u.width}px`,i=f.getBoundingClientRect(),i.bottom>window.innerHeight)f.style.top=`${u.top-i.height-e}px`;if(i.right>window.innerWidth)f.style.left=`${window.innerWidth-i.width-e}px`;return t?f.style.visibility="visible":void 0};var xt='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])';nu=function(n){let f;return f=function(e){let t,i,u,l;if(e.key!=="Tab")return;if(l=n.querySelectorAll(xt),u=Array.from(l).filter(function(a){return a.offsetParent!==null}),!u.length)return;return t=u[0],i=u[u.length-1],e.shiftKey?document.activeElement===t?(e.preventDefault(),i.focus()):void 0:document.activeElement===i?(e.preventDefault(),t.focus()):void 0},n.addEventListener("keydown",f),function(){return n.removeEventListener("keydown",f)}};lu=function(n,f){let e,t;if(!n)return;if(t=n.querySelector("h1,h2,h3,h4,h5,h6"),t)t.id??=`${f}-title`,n.setAttribute("aria-labelledby",t.id);if(e=n.querySelector("p"),e)return e.id??=`${f}-desc`,n.setAttribute("aria-describedby",e.id)};Ai=[];Vf=function(n){let f;if(f=window.scrollY,Ai.push({instance:n,scrollY:f}),Ai.length===1)return document.body.style.position="fixed",document.body.style.top=`-${f}px`,document.body.style.width="100%"};iu=function(n){let f,e;if(f=Ai.findIndex(function(t){return t.instance===n}),f<0)return;if({scrollY:e}=Ai.splice(f,1)[0],!Ai.length)return document.body.style.position="",document.body.style.top="",document.body.style.width="",window.scrollTo(0,e)};Ci=!1;zi=!1;Wl=function(){let n,f,e;if(Ci)return zi;if(!(typeof document<"u"&&document.body))return!1;return(()=>{try{return n=document.createElement("div"),f=document.createElement("div"),n.style.cssText="position:fixed;top:100px;left:100px;width:10px;height:10px;anchor-name:--probe",f.style.cssText="position:fixed;inset:auto;margin:0;position-anchor:--probe;position-area:bottom start;width:10px;height:10px",document.body.appendChild(n),document.body.appendChild(f),e=f.getBoundingClientRect(),n.remove(),f.remove(),zi=e.top>50,Ci=!0,zi}catch{return Ci=!0,zi=!1}})()};Bf=["position","inset","top","right","bottom","left","margin","marginTop","marginRight","marginBottom","marginLeft","transform","minWidth","positionAnchor","positionArea","positionTry","positionVisibility"];$f=function(n){let f=[];for(let e of Bf)f.push(n.style[e]="");return f};pf=function(n,f,e={}){let t,i,u,l,a,c,r,h;if(!(n&&f))return;if(a=e.placement??"bottom start",l=e.offset??4,i=e.matchWidth??!1,$f(f),Wl()){if(u=`--anchor-${f.id||Math.random().toString(36).slice(2,8)}`,c=f.__ariaPrevTrigger,c&&c!==n)try{c.style.anchorName=""}catch{}switch(f.__ariaPrevTrigger=n,n.style.anchorName=u,f.style.positionAnchor=u,f.style.position="fixed",f.style.inset="auto",f.style.margin="0",f.style.positionArea=a,f.style.positionTry="flip-block, flip-inline, flip-block flip-inline",f.style.positionVisibility="anchors-visible",[h]=a.split(" "),h){case"bottom":f.style.marginTop=`${l}px`;break;case"top":f.style.marginBottom=`${l}px`;break;case"left":f.style.marginRight=`${l}px`;break;case"right":f.style.marginLeft=`${l}px`;break}return i?f.style.minWidth="anchor-size(width)":void 0}else{switch(r=n.getBoundingClientRect(),f.style.position="fixed",f.style.inset="auto",f.style.margin="0",[h,t]=a.split(" "),t??="start",h){case"bottom":f.style.top=`${r.bottom+l}px`;break;case"top":f.style.bottom=`${window.innerHeight-r.top+l}px`;break;case"left":f.style.right=`${window.innerWidth-r.left+l}px`;break;case"right":f.style.left=`${r.right+l}px`;break}if(Array.isArray(["bottom","top"])?["bottom","top"].includes(h):(h in["bottom","top"]))switch(t){case"start":f.style.left=`${r.left}px`;break;case"center":f.style.left=`${r.left+r.width/2}px`,f.style.transform="translateX(-50%)";break;case"end":f.style.right=`${window.innerWidth-r.right}px`;break}else switch(t){case"start":f.style.top=`${r.top}px`;break;case"center":f.style.top=`${r.top+r.height/2}px`,f.style.transform="translateY(-50%)";break;case"end":f.style.bottom=`${window.innerHeight-r.bottom}px`;break}return i?f.style.minWidth=`${r.width}px`:void 0}};vf=function(...n){return function(){let f=[];for(let e of n)f.push((()=>{try{return e?.()}catch{return null}})());return f}};globalThis.__aria??={listNav:Tf,rovingNav:kf,popupDismiss:jf,popupGuard:Lf,bindPopover:Cf,bindDialog:gf,positionBelow:xf,trapFocus:nu,wireAria:lu,lockScroll:Vf,unlockScroll:iu,position:pf,hasAnchor:Wl,combine:vf};globalThis.ARIA??=globalThis.__aria;ri.modules["app.rip"]=$i;for(let[n,f]of Object.entries($i))if(typeof f==="function")globalThis[n]=f;})();
2978
+ `:"",U)fn+=1;if(A=U+D,s&&fn>0){if(Z=globalThis?.__ripDebug?.offsetSourceMap,Z)A=Z(A,fn)}if(c=new Blob([A],{type:"application/javascript"}),P=URL.createObjectURL(c),Y=null,i&&t){if(i.blobUrls??={},Y=i.blobUrls[t],Y&&Y!==P)try{URL.revokeObjectURL(Y)}catch{}i.blobUrls[t]=P}if(S=await import(P),o=!0,i){y=Sl(S);for(let F in y){let N=y[F];i.classes[F]=N}}if(e&&t)e.setCompiled(t,S);return S}finally{if(i&&t){if(i.compiling)delete i.compiling[t]}if(!o&&P&&i&&t){try{URL.revokeObjectURL(P)}catch{}if(i.blobUrls?.[t]===P)delete i.blobUrls[t]}}})()};zl=function(n,f){let e;return n.innerHTML="",e=document.createElement("pre"),e.style.cssText="margin:2rem;padding:1rem 1.25rem;color:#b91c1c;background:#fef2f2;border:1px solid #fecaca;border-radius:8px;font:13px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;overflow-wrap:anywhere",e.textContent=f,n.appendChild(e)};function Ru(n){let f,e,t,i,u,l,a,c,r,h,o,s,w,_,A,y,R,U,m,D,M,q,S,d,K,E,Z,Q,W,C,L,X,fn,Y,Un,G,O;if(Ui("createRenderer"),{router:W,app:e,components:u,resolver:Z,compile:i,target:Y,onError:D}=n,d=n.preload==="intent",l=typeof Y==="string"?document.querySelector(Y):Y||document.getElementById("app"),!l)l=document.createElement("div"),l.id="app",document.body.appendChild(l);return a=null,o=null,r=null,h=null,c=[],R=[],U=l,_=0,s=null,O=null,A=function(J){if(!Z)return;if(Z.blobUrls?.[J]){try{URL.revokeObjectURL(Z.blobUrls[J])}catch{}delete Z.blobUrls[J]}return Z.classes&&Z.map?(()=>{let P=[];for(let F in Z.map){let N=Z.map[F];P.push(N===J?delete Z.classes[F]:void 0)}return P})():void 0},G=function(){if(a){try{a.unmount?.({removeDOM:!1})}catch(J){console.error("[Rip] page unmount error:",J)}return a=null,o=null}},Un=function(){G();for(let J=R.length-1;J>=0;J--){let P=R[J];try{P.unmount?.({removeDOM:!0})}catch(F){console.error("[Rip] layout unmount error:",F)}}return R=[],U=l,r=null,h=null,c=[]},C=function(J,P){if(!(J&&P))return!1;if(Object.keys(J).length!==Object.keys(P).length)return!1;for(let F in J){let N=J[F];if(P[F]!==N)return!1}return!0},E=function(J){let P;P=Zn(e.data);for(let F of J.split(".")){if(!(P!=null&&typeof P==="object"))return null;if(P=P[F],Wn(P))return P}return null},w=async function(J,P,F,N=!1,un=0){let $,tn,cn,on,b,p,v,ln,rn,en,sn,wn,_n,Rn;ln=new Map;for(let An=0;An<J.length;An++){let g=J[An];if(An<un)continue;if(b=g.cls?.__gates,!(b&&b.length))continue;for(let nn of b){if(_n=typeof nn==="string"?nn:nn.path,en=typeof nn==="string"?null:nn.key,$=E(_n),!$)throw Error(`[Rip] ${g.file}: '${_n} <~' does not resolve to a source — declare it with source() in app/stash.rip`);if(rn=void 0,Di($)){if(!en)throw Error(`[Rip] ${g.file}: '${_n}' is a keyed source — gate with a key: ${_n}(params.…)`);rn=en(P||{},F||{}),$=$.cellFor(rn)}else if(en)throw Error(`[Rip] ${g.file}: '${_n}' is not a keyed source — drop the key argument`);if(p=_n+"|"+String(rn??""),v=ln.get(p),!v)v={cell:$,owners:[],path:_n},ln.set(p,v);v.owners.push(An)}}if(sn=[...ln.values()],!sn.length)return{failedIndex:1/0,failure:null};Rn=await Promise.allSettled(sn.map(function(An){return N?An.cell.preload():An.cell.ensure()})),cn=1/0,on=null;for(let An=0;An<Rn.length;An++){let g=Rn[An];if(tn=null,g.status==="rejected")tn=g.reason;else if(!N&&g.value==null)tn=Error(`[Rip] gate '${sn[An].path} <~' resolved to ${g.value}: a gated source must resolve to a non-null value or throw. For a value that can be absent, read it ungated with ~= instead of gating it.`);if(!tn)continue;if(wn=Math.min(...sn[An].owners),wn<cn)cn=wn,on={status:tn?.status??tn?.response?.status??500,message:tn?.message??String(tn),error:tn,path:sn[An].path}}return{failedIndex:cn,failure:on}},Q=function(J){let P;P=!1;for(let F=R.length-1;F>=0;F--){let N=R[F];if(N.onError)try{N.onError(J),P=!0;break}catch(un){console.error("Renderer: error boundary failed:",un)}}if(!P){if(console.error(`Renderer: gate '${J.path}' failed:`,J.error),D)D(J);return Un(),zl(l,`${J.status}: ${J.message}`)}},m=async function(J,P=!1){let F,N,un,$,tn,cn,on,b,p,v,ln,rn,en,sn,wn,_n,Rn,An,g,nn,zn,Mn,B,T,x,k,an,V,hn,yn,mn,En,Jn,Gn,Yn,gn;if({route:En,params:V,layouts:_n,query:yn}=J,!En)return;if(Jn=En.file===o&&C(V,r),mn=function(){let dn,On;if(dn=a?.constructor,On=dn?.__gates,!On)return!1;for(let ii of On)if(typeof ii!=="string"&&ii.key)try{if(ii.key(V||{},h||{})!==ii.key(V||{},yn||{}))return!0}catch{return!0}return!1},Jn&&!P&&!mn()){if(!C(yn,h)){if(h=yn,a?.load)try{await a.load(V,yn)}catch(dn){if(console.error(`Renderer: error in query-only load for ${En.file}:`,dn),D)D({status:500,message:dn.message,error:dn})}}return}return ln=++_,W.navigating=!0,await(async()=>{try{if(Yn=u.read(En.file),!Yn){if(D)D({status:404,message:`File not found: ${En.file}`});W.navigating=!1;return}if(nn=await kn(Yn,i,u,En.file,Z),ln!==_){W.navigating=!1;return}if(F=Hi(nn),!F){if(D)D({status:500,message:`No component found in ${En.file}`});W.navigating=!1;return}wn=[];for(let dn of _n){if(An=u.read(dn),!An)continue;if(Rn=await kn(An,i,u,dn,Z),ln!==_){W.navigating=!1;return}if(N=Hi(Rn),!N)continue;wn.push({file:dn,cls:N})}if(on=[...wn,{file:En.file,cls:F}],g=!Ul(_n,c),zn=g?0:wn.length,{failedIndex:p,failure:v}=await w(on,V,yn,!1,zn),ln!==_){W.navigating=!1;return}if(B=a?._target,g)Un();else G();if(r=V,h=yn,Mn=g?l:U,b=Math.min(p,wn.length),g&&_n.length>0){l.innerHTML="",Mn=l,cn=globalThis.__ripComponent?.__pushComponent,$=globalThis.__ripComponent?.__popComponent,T=null;for(let dn=0;dn<wn.length;dn++){let On=wn[dn];if(dn>=b)break;N=On.cls,hn=cn?.(T),globalThis.__ripGateMount=N;try{en=new N({app:e,params:V,router:W})}finally{globalThis.__ripGateMount=null,$?.(hn)}if(en.beforeMount){un=cn?.(en);try{en.beforeMount()}finally{$?.(un)}}gn=document.createElement("div"),gn.setAttribute("data-layout",On.file),Mn.appendChild(gn),en.mount(gn),R.push(en),T=en,Gn=gn.querySelector("#content")||gn,Mn=Gn}c=b<wn.length?_n.slice(0,b):[..._n],U=Mn}else if(g)l.innerHTML="",c=[],U=l;if(v){B?.remove(),Q(v),W.navigating=!1;return}an=document.createElement("div"),an.setAttribute("data-component",En.file),Mn.appendChild(an),cn=globalThis.__ripComponent?.__pushComponent,$=globalThis.__ripComponent?.__popComponent,x=R[R.length-1]||null,k=cn?.(x),globalThis.__ripGateMount=F;try{sn=new F({app:e,params:V,query:yn,router:W})}finally{globalThis.__ripGateMount=null,$?.(k)}if(sn.beforeMount){tn=cn?.(sn);try{sn.beforeMount()}finally{$?.(tn)}}if(sn.mount(an),a=sn,o=En.file,sn.load)await sn.load(V,yn);return B?.remove(),W.navigating=!1}catch(dn){if(W.navigating=!1,console.error(`Renderer: error mounting ${En.file}:`,dn),D)D({status:500,message:dn.message,error:dn});rn=!1;for(let On=R.length-1;On>=0;On--){let ii=R[On];if(ii.onError)try{ii.onError(dn),rn=!0;break}catch(Mu){console.error("Renderer: error boundary failed:",Mu)}}return(()=>{if(!rn)return Un(),zl(l,dn.stack||dn.message)})()}})()},fn=!1,S=async function(J){let P,F,N,un,$,tn,cn,on;if(N=W.match?.(J),!N?.route)return;if(tn=Ul(N.layouts,c),tn&&N.route.file===o&&C(N.params,r))return;if(P=[],!tn)for(let b of N.layouts){if($=u.read(b),!$)continue;if(un=await kn($,i,u,b,Z),F=Hi(un),F)P.push({file:b,cls:F})}if(on=u.read(N.route.file),on){if(cn=await kn(on,i,u,N.route.file,Z),F=Hi(cn),F)P.push({file:N.route.file,cls:F})}await w(P,N.params,N.query,!0);return},f=50,y={href:null,at:0},X=null,L=null,t=function(){if(X)clearTimeout(X),X=null;return L=null},M=function(J){let P,F;P=J.target;while(P&&P.tagName!=="A")P=P.parentElement;if(!P)return;if(!W.ownsAnchor?.(P))return;if(P===L)return;return t(),L=P,F=P.href,X=setTimeout(function(){let N;if(X=null,L=null,N=Date.now(),F===y.href&&N-y.at<3000)return;return y.href=F,y.at=N,S(F).catch(function(){return null})},f)},q=function(J){let P;if(!L)return;return P=J.relatedTarget,!(P&&L.contains(P))?t():void 0},K={start(){if(fn)return K;if(fn=!0,s=ni(function(){let J;return J=W.current,J.route?m(J):void 0}),O=u?.watch(function(J,P){return(Array.isArray(["change","delete"])?["change","delete"].includes(J):(J in["change","delete"]))?A(P):void 0}),d)document.addEventListener("pointerover",M,{passive:!0}),document.addEventListener("focusin",M,{passive:!0}),document.addEventListener("pointerout",q,{passive:!0}),document.addEventListener("focusout",q,{passive:!0});return W.init(),K},stop(){if(!fn)return;if(fn=!1,Un(),s)s(),s=null;if(O?.(),O=null,t(),d)document.removeEventListener("pointerover",M),document.removeEventListener("focusin",M),document.removeEventListener("pointerout",q),document.removeEventListener("focusout",q);if(Z?.blobUrls){for(let J in Z.blobUrls){if(!Object.hasOwn(Z.blobUrls,J))continue;let P=Z.blobUrls[J];try{URL.revokeObjectURL(P)}catch{}}Z.blobUrls={}}return l.innerHTML=""},remount(J=!1){let P,F;return F=typeof J==="object"?!!J.force:!!J,P=W.current,P.route?m(P,F):void 0}},K}eu=function(n){let f,e,t,i,u,l;return Ui("connectWatch"),u=1000,i=30000,f=!1,t=null,l=null,e=function(){if(f)return;return t=new EventSource(n),t.addEventListener("connected",function(){return u=1000,console.log("[Rip] Hot reload connected")}),t.addEventListener("reload",function(){return console.log("[Rip] Reloading..."),location.reload()}),t.addEventListener("css",function(){let a,c;c=document.querySelectorAll('link[rel="stylesheet"]');let r=[];for(let h of c)a=new URL(h.href),a.searchParams.set("_t",Date.now()),h.href=a.toString();return r}),t.onerror=function(){if(t.close(),t=null,f)return;return l=setTimeout(e,u),u=Math.min(u*2,i)}},e(),function(){if(f)return;if(f=!0,l)clearTimeout(l),l=null;return t?.close(),t=null}};async function pt(n={}){let f,e,t,i,u,l,a,c,r,h,o,s,w,_,A,y,R,U,m,D,M,q,S,d,K,E,Z,Q;if(Ui("launch"),e=(n.base||"").replace(/\/+$/,""),E=n.target||"#app",a=n.compile||null,A=n.persist||!1,w=n.hash||!1,!a)a=globalThis?.compileToJS||null;if(!document.querySelector(E))h=document.createElement("div"),h.id=E.replace(/^#/,""),document.body.prepend(h);if(n.bundle)i=n.bundle;else if(n.bundleUrl){if(_={},s=`__rip_etag_${n.bundleUrl}`,u=sessionStorage.getItem(s),u)_["If-None-Match"]=u;if(U=await fetch(n.bundleUrl,{headers:_}),U.status===304)i=JSON.parse(sessionStorage.getItem(`${s}_data`));else if(U.ok){if(i=await U.json(),o=U.headers.get("etag"),o)sessionStorage.setItem(s,o),sessionStorage.setItem(`${s}_data`,JSON.stringify(i))}else throw Error(`launch: ${n.bundleUrl} (${U.status})`)}else throw Error("launch: no bundle or bundleUrl provided");if(f=_u({components:{},routes:{},data:{}}),globalThis.__ripApp=f,t=Au(),i.modules)t.load(i.modules);if(l=`__rip_${e.replace(/\//g,"_")||"app"}`,m={map:uu(t),classes:{},key:l,packages:i.packages||{}},globalThis[l]=m.classes,d=null,S="_app/stash.rip",t.exists(S)){if(K=t.read(S),K)try{if(q=await kn(K,a,t,S,m),q?.stash)d=q.stash}catch(W){console.error(`[Rip] Failed to load app/stash.rip: ${W.message}`,W)}}if(d&&i.data)for(let W in i.data){let C=i.data[W];if(!Wn(d[W]))d[W]=C}if(M=d??i.data,M)f.data=M;if(ou(Zn(f.data)),i.routes)f.routes=i.routes;if(y=null,A)y=mu(f,{local:A==="local",key:`__rip_${e}`});if(f.data.title)document.title=f.data.title;if(D=Du(t,{root:"_route",base:e,hash:w,onError(W){return console.error(`[Rip] Error ${W.status}: ${W.message||W.path}`)}}),globalThis.__ripRouter=D,R=Ru({router:D,app:f,components:t,resolver:m,compile:a,target:E,preload:i.data?.preload==="intent"?"intent":!1,onError(W){return console.error(`[Rip] ${W.message}`,W.error)}}),R.start(),Z=null,i.data?.watch)Z=eu(`${e}/watch`);return Q=window,r=!1,c=function(){if(r)return;if(r=!0,Z?.(),R.stop(),D.destroy(),y?.(),delete globalThis[l],delete globalThis.__ripApp,delete globalThis.__ripRouter,delete globalThis.__ripLaunched,Q.app===f)delete Q.app;return Q.__RIP__?.app===f?delete Q.__RIP__:void 0},Q.app=f,Q.__RIP__={app:f,components:t,router:D,renderer:R,resolver:m,destroy:c,version:"0.3.0"},globalThis.__ripLaunched=!0,{app:f,components:t,router:D,renderer:R,destroy:c}}Kn=function(n,f){if(!f)return;return n.preventDefault(),n.stopPropagation(),f()};globalThis.__ariaLastFocusedEl??=null;if(typeof document<"u"&&!globalThis.__ariaFocusTrackerBound)document.addEventListener("focusin",function(n){return globalThis.__ariaLastFocusedEl=n.target},!0),globalThis.__ariaFocusTrackerBound=!0;Tf=function(n,f){if(n.isComposing)return;return(()=>{switch(n.key){case"ArrowDown":return Kn(n,f.next);case"ArrowUp":return Kn(n,f.prev);case"Home":case"PageUp":return Kn(n,f.first);case"End":case"PageDown":return Kn(n,f.last);case"Enter":case" ":return Kn(n,f.select);case"Escape":return Kn(n,f.dismiss);case"Tab":return f.tab?.();default:return n.key.length===1?f.char?.(n.key):void 0}})()};jf=function(n,f,e,t=[],i=null){let u,l,a,c,r;if(l=function(h){return typeof h==="function"?h():h},r=l(f),r&&r.__ariaPopupDismiss)r.__ariaPopupDismiss(),r.__ariaPopupDismiss=null;if(!(n&&r))return;return a=(h)=>{return![r,...t.map(l)].some(function(o){return o?.contains(h.target)})?e():void 0},c=(h)=>{if(r?.contains(h.target))return;return i?i():e()},document.addEventListener("mousedown",a),window.addEventListener("scroll",c,!0),u=function(){return document.removeEventListener("mousedown",a),window.removeEventListener("scroll",c,!0)},r.__ariaPopupDismiss=u,u};Lf=function(n=250){let f;return f=0,{block(e=n){return f=Date.now()+e},canOpen(){return Date.now()>=f}}};Cf=function(n,f,e,t=null){let i,u,l,a,c,r,h,o,s,w,_;if(a=function(A){return typeof A==="function"?A():A},i=function(){let A,y;if(A=document.activeElement,A&&A!==document.body)return A;if(y=globalThis.__ariaLastFocusedEl,y?.isConnected!==!1)return y;return null},l=a(f),!l)return;if(!Object.hasOwn(HTMLElement.prototype,"togglePopover"))return;if(h=null,_=function(A){if(A){l.hidden=!1;try{l.inert=!1}catch{}return l.removeAttribute("aria-hidden")}else{try{l.inert=!0}catch{}return l.setAttribute("aria-hidden","true"),l.hidden=!0}},o=function(){let A,y;if(y=h,h=null,!y?.focus)return;return A=function(R=6){if(y.isConnected===!1)return;try{y.focus({preventScroll:!0})}catch{y.focus()}if(document.activeElement===y||R<=1)return;return setTimeout(function(){return A(R-1)},16)},requestAnimationFrame(function(){return A()})},l.__ariaBindPopover)l.removeEventListener("toggle",l.__ariaBindPopover),l.__ariaBindPopover=null;if(c=function(A){let y;if(y=A.newState==="open",y)h=a(t)||i(),_(!0);else _(!1),o();return e?.(y)},l.addEventListener("toggle",c),l.__ariaBindPopover=c,s=l.matches(":popover-open"),u=!!n,s!==u){if(w=a(t),u)h=w||i(),_(!0);r=w&&u?{force:u,source:w}:{force:u};try{l.togglePopover(r)}catch{}}else _(u);return function(){return l.removeEventListener("toggle",c),l.__ariaBindPopover===c?l.__ariaBindPopover=null:void 0}};gf=function(n,f,e,t=!0){let i,u,l,a,c,r,h,o,s,w;if(l=function(_){return typeof _==="function"?_():_},i=function(){let _,A;if(_=document.activeElement,_&&_!==document.body)return _;if(A=globalThis.__ariaLastFocusedEl,A?.isConnected!==!1)return A;return null},u=l(f),!u?.showModal)return;if(o=null,w=function(_){if(_){u.hidden=!1;try{u.inert=!1}catch{}return u.removeAttribute("aria-hidden")}else{try{u.inert=!0}catch{}return u.setAttribute("aria-hidden","true"),u.hidden=!0}},s=function(){let _,A;if(A=o,o=null,!A?.focus)return;return _=function(y=6){if(A.isConnected===!1)return;try{A.focus({preventScroll:!0})}catch{A.focus()}if(document.activeElement===A||y<=1)return;return setTimeout(function(){return _(y-1)},16)},requestAnimationFrame(function(){return _()})},u.__ariaBindDialog)[r,h]=u.__ariaBindDialog,u.removeEventListener("cancel",r),u.removeEventListener("close",h),u.__ariaBindDialog=null;if(a=function(_){if(!t){_.preventDefault();return}return e?.(!1)},c=function(){return e?.(!1),w(!1),s()},u.addEventListener("cancel",a),u.addEventListener("close",c),u.__ariaBindDialog=[a,c],n&&!u.open){if(!o)o=i();w(!0);try{u.showModal()}catch{}}else if(!n&&u.open)u.close();else w(!!n);return function(){return u.removeEventListener("cancel",a),u.removeEventListener("close",c),u.__ariaBindDialog?.[0]===a?u.__ariaBindDialog=null:void 0}};kf=function(n,f,e="vertical"){let t,i;if(n.isComposing)return;return i=e!=="horizontal",t=e!=="vertical",(()=>{switch(n.key){case"ArrowDown":return i?Kn(n,f.next):void 0;case"ArrowUp":return i?Kn(n,f.prev):void 0;case"ArrowRight":return t?Kn(n,f.next):void 0;case"ArrowLeft":return t?Kn(n,f.prev):void 0;case"Home":case"PageUp":return Kn(n,f.first);case"End":case"PageDown":return Kn(n,f.last);case"Enter":case" ":return Kn(n,f.select);case"Escape":return Kn(n,f.dismiss);default:return n.key.length===1?f.char?.(n.key):void 0}})()};xf=function(n,f,e=4,t=!0){let i,u;if(!(n&&f))return;if(u=n.getBoundingClientRect(),f.style.position="fixed",f.style.left=`${u.left}px`,f.style.top=`${u.bottom+e}px`,f.style.minWidth=`${u.width}px`,i=f.getBoundingClientRect(),i.bottom>window.innerHeight)f.style.top=`${u.top-i.height-e}px`;if(i.right>window.innerWidth)f.style.left=`${window.innerWidth-i.width-e}px`;return t?f.style.visibility="visible":void 0};var xt='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])';nu=function(n){let f;return f=function(e){let t,i,u,l;if(e.key!=="Tab")return;if(l=n.querySelectorAll(xt),u=Array.from(l).filter(function(a){return a.offsetParent!==null}),!u.length)return;return t=u[0],i=u[u.length-1],e.shiftKey?document.activeElement===t?(e.preventDefault(),i.focus()):void 0:document.activeElement===i?(e.preventDefault(),t.focus()):void 0},n.addEventListener("keydown",f),function(){return n.removeEventListener("keydown",f)}};lu=function(n,f){let e,t;if(!n)return;if(t=n.querySelector("h1,h2,h3,h4,h5,h6"),t)t.id??=`${f}-title`,n.setAttribute("aria-labelledby",t.id);if(e=n.querySelector("p"),e)return e.id??=`${f}-desc`,n.setAttribute("aria-describedby",e.id)};Ai=[];Vf=function(n){let f;if(f=window.scrollY,Ai.push({instance:n,scrollY:f}),Ai.length===1)return document.body.style.position="fixed",document.body.style.top=`-${f}px`,document.body.style.width="100%"};iu=function(n){let f,e;if(f=Ai.findIndex(function(t){return t.instance===n}),f<0)return;if({scrollY:e}=Ai.splice(f,1)[0],!Ai.length)return document.body.style.position="",document.body.style.top="",document.body.style.width="",window.scrollTo(0,e)};Ci=!1;zi=!1;Wl=function(){let n,f,e;if(Ci)return zi;if(!(typeof document<"u"&&document.body))return!1;return(()=>{try{return n=document.createElement("div"),f=document.createElement("div"),n.style.cssText="position:fixed;top:100px;left:100px;width:10px;height:10px;anchor-name:--probe",f.style.cssText="position:fixed;inset:auto;margin:0;position-anchor:--probe;position-area:bottom start;width:10px;height:10px",document.body.appendChild(n),document.body.appendChild(f),e=f.getBoundingClientRect(),n.remove(),f.remove(),zi=e.top>50,Ci=!0,zi}catch{return Ci=!0,zi=!1}})()};Bf=["position","inset","top","right","bottom","left","margin","marginTop","marginRight","marginBottom","marginLeft","transform","minWidth","positionAnchor","positionArea","positionTry","positionVisibility"];$f=function(n){let f=[];for(let e of Bf)f.push(n.style[e]="");return f};pf=function(n,f,e={}){let t,i,u,l,a,c,r,h;if(!(n&&f))return;if(a=e.placement??"bottom start",l=e.offset??4,i=e.matchWidth??!1,$f(f),Wl()){if(u=`--anchor-${f.id||Math.random().toString(36).slice(2,8)}`,c=f.__ariaPrevTrigger,c&&c!==n)try{c.style.anchorName=""}catch{}switch(f.__ariaPrevTrigger=n,n.style.anchorName=u,f.style.positionAnchor=u,f.style.position="fixed",f.style.inset="auto",f.style.margin="0",f.style.positionArea=a,f.style.positionTry="flip-block, flip-inline, flip-block flip-inline",f.style.positionVisibility="anchors-visible",[h]=a.split(" "),h){case"bottom":f.style.marginTop=`${l}px`;break;case"top":f.style.marginBottom=`${l}px`;break;case"left":f.style.marginRight=`${l}px`;break;case"right":f.style.marginLeft=`${l}px`;break}return i?f.style.minWidth="anchor-size(width)":void 0}else{switch(r=n.getBoundingClientRect(),f.style.position="fixed",f.style.inset="auto",f.style.margin="0",[h,t]=a.split(" "),t??="start",h){case"bottom":f.style.top=`${r.bottom+l}px`;break;case"top":f.style.bottom=`${window.innerHeight-r.top+l}px`;break;case"left":f.style.right=`${window.innerWidth-r.left+l}px`;break;case"right":f.style.left=`${r.right+l}px`;break}if(Array.isArray(["bottom","top"])?["bottom","top"].includes(h):(h in["bottom","top"]))switch(t){case"start":f.style.left=`${r.left}px`;break;case"center":f.style.left=`${r.left+r.width/2}px`,f.style.transform="translateX(-50%)";break;case"end":f.style.right=`${window.innerWidth-r.right}px`;break}else switch(t){case"start":f.style.top=`${r.top}px`;break;case"center":f.style.top=`${r.top+r.height/2}px`,f.style.transform="translateY(-50%)";break;case"end":f.style.bottom=`${window.innerHeight-r.bottom}px`;break}return i?f.style.minWidth=`${r.width}px`:void 0}};vf=function(...n){return function(){let f=[];for(let e of n)f.push((()=>{try{return e?.()}catch{return null}})());return f}};globalThis.__aria??={listNav:Tf,rovingNav:kf,popupDismiss:jf,popupGuard:Lf,bindPopover:Cf,bindDialog:gf,positionBelow:xf,trapFocus:nu,wireAria:lu,lockScroll:Vf,unlockScroll:iu,position:pf,hasAnchor:Wl,combine:vf};globalThis.ARIA??=globalThis.__aria;ri.modules["app.rip"]=$i;for(let[n,f]of Object.entries($i))if(typeof f==="function")globalThis[n]=f;})();