diff --git a/dist/@rip/rip.js b/dist/@rip/rip.js index 3cb65e05..bd93f4c8 100644 --- a/dist/@rip/rip.js +++ b/dist/@rip/rip.js @@ -14016,6 +14016,10 @@ ${pad ?? ""}`); const ind = this.ind; this.rejectYieldInIIFE(node); this.b.emit(Emitter.containsAwait(node) ? "await (async () => { " : "(() => { "); + this.tryBranches(node, ind); + this.b.emit(" })()"); + } + tryBranches(node, ind) { this.mark(node, "$self", () => { this.b.emit("try "); const vbody = isBlock(node[1]) ? node[1] : ["block", node[1]]; @@ -14065,7 +14069,6 @@ ${pad ?? ""}`); } } }); - this.b.emit(" })()"); } valueSwitch(node) { const [, subject, cases, dflt] = node; @@ -20723,9 +20726,7 @@ ${" ".repeat(ind)}`); return; } if (h === "try") { - this.b.emit("return "); - this.withTailReturn(() => this.valueTry(stmt)); - this.b.emit(";"); + this.withTailReturn(() => this.tryBranches(stmt, ind)); return; } if (h === "switch" && stmt.length === 4) { @@ -26505,43 +26506,41 @@ makeSourceCell = function(fetchFn, staleTime, onSettle = null) { if (!background) loading.value = true; let wasLoaded = loaded; - return await (async () => { - try { - pending = fetchFn(controller?.signal); - if (!(pending != null && typeof pending.then === "function")) { - throw new TypeError("Rip App: source fetch must return a Promise"); - } - result = await pending; - if (mine !== generation) - return result; - failure.value = null; - data.value = result; - loaded = true; - loadedAt = Date.now(); - freshUntil = preload && !preloadConsumed ? loadedAt + PRELOAD_FRESH_MS : 0; + try { + pending = fetchFn(controller?.signal); + if (!(pending != null && typeof pending.then === "function")) { + throw new TypeError("Rip App: source fetch must return a Promise"); + } + result = await pending; + if (mine !== generation) return result; - } catch (error) { - if (mine !== generation) - return; - if (error?.name === "AbortError") - return; - failure.value = error; - if (!wasLoaded) { - loaded = false; - loadedAt = 0; - throw error; - } + failure.value = null; + data.value = result; + loaded = true; + loadedAt = Date.now(); + freshUntil = preload && !preloadConsumed ? loadedAt + PRELOAD_FRESH_MS : 0; + return result; + } catch (error) { + if (mine !== generation) return; - } finally { - if (mine === generation) { - loading.value = false; - inflight = null; - inflightPreload = false; - preloadConsumed = false; - onSettle?.(); - } + if (error?.name === "AbortError") + return; + failure.value = error; + if (!wasLoaded) { + loaded = false; + loadedAt = 0; + throw error; } - })(); + return; + } finally { + if (mine === generation) { + loading.value = false; + inflight = null; + inflightPreload = false; + preloadConsumed = false; + onSettle?.(); + } + } }; let start = function(background = false, preload = false) { let pending = load(background, preload); @@ -27370,16 +27369,14 @@ function createMutation(fn, opts = {}) { } if (!(me === generation)) return; - return await (async () => { - try { - _succeeded.value = true; - await opts.onSuccess?.(r); - return r; - } finally { - if (me === generation) - _pending.value = false; - } - })(); + try { + _succeeded.value = true; + await opts.onSuccess?.(r); + return r; + } finally { + if (me === generation) + _pending.value = false; + } }; Object.defineProperty(mutation, "pending", { get() { return _pending.value; @@ -27661,13 +27658,11 @@ fail = function(message) { throw new Error(`Rip App: ${message}`); }; var decodeSegment = function(segment) { - return (() => { - try { - return decodeURIComponent(segment); - } catch (error) { - return null; - } - })(); + try { + return decodeURIComponent(segment); + } catch (error) { + return null; + } }; validRoot = function(root) { if (root === "") @@ -29254,30 +29249,28 @@ function createRenderer(opts) { let mine = ++generation; if (Array.isArray(router) || typeof router === "string" ? router.includes("navigating") : ("navigating" in router)) router.navigating = true; - return await (async () => { - try { - return await performMount(info, mine, componentRegistry); - } catch (caught) { - error = caught; - if (mine !== generation) - return null; - failure = (() => { - if (error?.name === "GateFailure") { - return error; - } else { - file = info?.route?.file ?? ""; - return failureFor(error?.path ?? file, file, error); - } - })(); - onError?.(failure); - if (!(current != null)) - showFatalCard(failure); - throw failure; - } finally { - if (mine === generation && (Array.isArray(router) || typeof router === "string" ? router.includes("navigating") : ("navigating" in router))) - router.navigating = false; - } - })(); + try { + return await performMount(info, mine, componentRegistry); + } catch (caught) { + error = caught; + if (mine !== generation) + return null; + failure = (() => { + if (error?.name === "GateFailure") { + return error; + } else { + file = info?.route?.file ?? ""; + return failureFor(error?.path ?? file, file, error); + } + })(); + onError?.(failure); + if (!(current != null)) + showFatalCard(failure); + throw failure; + } finally { + if (mine === generation && (Array.isArray(router) || typeof router === "string" ? router.includes("navigating") : ("navigating" in router))) + router.navigating = false; + } }; let renderer = null; renderer = { @@ -30201,26 +30194,24 @@ function connectFeed(client, opts = {}) { let verdict; if (failed || closed) return false; - return await (async () => { - try { - verdict = await client.apply(change); - if (verdict === "rejected") { - if (validHash2(change?.hash)) - rejectedHash = change?.hash; - return false; - } - if (verdict === "reload" || !verdict) { - reload("change could not be applied"); - return false; - } - rejectedHash = null; - return true; - } catch (error) { - report("[Rip] publication change failed:", error); - reload("change failed"); + try { + verdict = await client.apply(change); + if (verdict === "rejected") { + if (validHash2(change?.hash)) + rejectedHash = change?.hash; return false; } - })(); + if (verdict === "reload" || !verdict) { + reload("change could not be applied"); + return false; + } + rejectedHash = null; + return true; + } catch (error) { + report("[Rip] publication change failed:", error); + reload("change failed"); + return false; + } }; let enqueue = function(change, owner) { tail = tail.then(async function() { @@ -30304,11 +30295,9 @@ function connectFeed(client, opts = {}) { return; report("[Rip] publication reconnect check failed:", error); ready = false; - return (() => { - try { - return socket?.close(); - } catch {} - })(); + try { + return socket?.close(); + } catch {} }); tail = task.then(function() { return true; @@ -30414,11 +30403,9 @@ function connectFeed(client, opts = {}) { if (closed || failed || owner !== connection || ready) return; report("[Rip] publication subscription acknowledgement timed out"); - return (() => { - try { - return socket.close(); - } catch {} - })(); + try { + return socket.close(); + } catch {} }, ackTimeout); return; }; diff --git a/dist/@rip/rip.min.js b/dist/@rip/rip.min.js index 1a156370..b6130e8d 100644 --- a/dist/@rip/rip.min.js +++ b/dist/@rip/rip.min.js @@ -127,10 +127,10 @@ ${s??""}`);let h=()=>{if(f)this.b.emit(f);else this.expr(i)};if(this.b.emit("for `),this.b.emit(`${l} return ${c}; `),this.b.emit(`${l}})()`)})}static objectComprehension(e){if(e.length!==2)return null;let t=e[1];if(!E(t)||t[0]!==":")return null;if(!(typeof t[1]==="string"||E(t[1])&&t[1][0]==="dynamicKey"))return null;if(!be(t[2]))return null;if(t[2][2][0][0]!=="for-of")return null;return t}static ifArms(e){let t=[],r=e,i=null;while(!0){if(t.push(r),r.length<4)break;if(E(r[3])&&r[3][0]==="if"){r=r[3];continue}i=r[3];break}return{arms:t,elseBlock:i}}static branchStmts(e){return T.stripErased(u1(e)?e.slice(1):[e[0]])}branchLive(e,t=!1){let r=u1(e)?e.slice(1):[e[0]];if(this.ts&&t){for(let i of r)if(E(i)&&i[0]==="type-decl")this.pendingTypeDecls.push(i)}return this.liveStmts(r)}static statementOnly(e){if(typeof e==="string"&&(e==="break"||e==="continue"||e==="debugger"))return!0;return E(e)&&(e[0]==="return"||e[0]==="throw"||g1(e[0]))}static containsReturn(e){if(!E(e))return!1;let t=e[0];if(t==="return")return!0;if(t==="->"||t==="=>"||g1(t)||t==="class")return!1;return e.some((r)=>T.containsReturn(r))}static containsCtrl(e){if(typeof e==="string")return e==="break"||e==="continue";if(!E(e))return!1;let t=e[0];if(t==="break"||t==="continue"||t==="return"||t==="throw")return!0;if(t==="->"||t==="=>"||g1(t)||t==="class")return!1;return e.some((r)=>T.containsCtrl(r))}static ifIsSimple(e){let{arms:t,elseBlock:r}=T.ifArms(e),i=(n)=>{let s=T.branchStmts(n);return s.length===1&&!T.statementOnly(s[0])};return t.every((n)=>i(n[2]))&&(r===null||i(r))}valueIf(e){if(!T.ifIsSimple(e)){let t=this.ind;this.rejectYieldInIIFE(e);let r=T.containsAwait(e);this.b.emit(r?"await (async () => { ":"(() => { "),this.mark(e,"$self",()=>this.returnifyIf(e,t)),this.b.emit(" })()");return}this.mark(e,"$self",()=>this.ifTernary(e))}ifTernary(e){if(this.grouped(e,"condition",e[1],T.needsGrouping(e[1],"operand")||E(e[1])&&(e[1][0]==="await"||e[1][0]==="yield")),this.b.emit(" ? "),this.ternaryArm(e,"then",this.branchLive(e[2],!0)[0]),this.b.emit(" : "),e.length<4)this.b.emit("undefined");else if(E(e[3])&&e[3][0]==="if")this.mark(e,"else",()=>{this.b.emit("("),this.ifTernary(e[3]),this.b.emit(")")});else this.ternaryArm(e,"else",this.branchLive(e[3],!0)[0])}ternaryArm(e,t,r){this.mark(e,t,()=>{let i=T.needsGrouping(r,"operand")||W1(r);if(i)this.b.emit("(");if(this.expr(r),i)this.b.emit(")")})}returnBlock(e,t){let r=this.branchLive(e);this.b.emit(`{ `),this.emitTsTypeDecls(u1(e)?e.slice(1):[e[0]]," ".repeat(t+1)),r.forEach((i,n)=>{if(this.b.emit(" ".repeat(t+1)),n===r.length-1)this.implicitReturn(i,t+1);else this.statement(i,t+1);this.b.emit(` -`)}),this.b.emit(" ".repeat(t)+"}")}returnifyIf(e,t){if(this.b.emit("if ("),this.grouped(e,"condition",e[1],T.needsGrouping(e[1],"operand")),this.b.emit(") "),this.mark(e,"then",()=>this.returnBlock(e[2],t)),e.length>=4)if(this.b.emit(" else "),E(e[3])&&e[3][0]==="if")this.returnifyIf(e[3],t);else this.mark(e,"else",()=>this.returnBlock(e[3],t))}rejectYieldInIIFE(e){if(T.containsYield(e))throw this.positionedError(e,"emitter: yield inside an expression-lowered construct cannot cross the IIFE boundary; restructure as statements");this.rejectCapturedCtrl(e)}static findCapturedCtrl(e,t=d3){let r=null,i=(n,s,a)=>{if(r!==null||!E(n))return;let o=n[0];if(T1(n)||g1(o)||o==="class")return;if(o==="return"){if(t.has("return"))r={kind:"return",node:n};return}let l=ct(n)||be(n)?s+1:s,c=o==="switch"?a+1:a,f=o==="block"||o==="program"||o==="try";for(let h=1;h { ":"(() => { "),this.mark(e,"$self",()=>{this.b.emit("try ");let r=u1(e[1])?e[1]:["block",e[1]];if(this.mark(e,"body",()=>this.returnBlock(r,t)),e.length===2)this.b.emit(" catch {}");for(let i of e.slice(2)){if(!E(i))continue;if(u1(i))this.b.emit(" finally "),this.braceBlock(i,t);else{let[n,s]=i;if(n===null)this.b.emit(" catch "),this.returnBlock(s,t);else if(T.isPattern(n)){this.checkExportedConstWrite(i,n);let a=this.loopTempName("_err");this.b.emit(` catch (${a}`),this.tsScaffoldAny(),this.b.emit(`) { +`)}),this.b.emit(" ".repeat(t)+"}")}returnifyIf(e,t){if(this.b.emit("if ("),this.grouped(e,"condition",e[1],T.needsGrouping(e[1],"operand")),this.b.emit(") "),this.mark(e,"then",()=>this.returnBlock(e[2],t)),e.length>=4)if(this.b.emit(" else "),E(e[3])&&e[3][0]==="if")this.returnifyIf(e[3],t);else this.mark(e,"else",()=>this.returnBlock(e[3],t))}rejectYieldInIIFE(e){if(T.containsYield(e))throw this.positionedError(e,"emitter: yield inside an expression-lowered construct cannot cross the IIFE boundary; restructure as statements");this.rejectCapturedCtrl(e)}static findCapturedCtrl(e,t=d3){let r=null,i=(n,s,a)=>{if(r!==null||!E(n))return;let o=n[0];if(T1(n)||g1(o)||o==="class")return;if(o==="return"){if(t.has("return"))r={kind:"return",node:n};return}let l=ct(n)||be(n)?s+1:s,c=o==="switch"?a+1:a,f=o==="block"||o==="program"||o==="try";for(let h=1;h { ":"(() => { "),this.tryBranches(e,t),this.b.emit(" })()")}tryBranches(e,t){this.mark(e,"$self",()=>{this.b.emit("try ");let r=u1(e[1])?e[1]:["block",e[1]];if(this.mark(e,"body",()=>this.returnBlock(r,t)),e.length===2)this.b.emit(" catch {}");for(let i of e.slice(2)){if(!E(i))continue;if(u1(i))this.b.emit(" finally "),this.braceBlock(i,t);else{let[n,s]=i;if(n===null)this.b.emit(" catch "),this.returnBlock(s,t);else if(T.isPattern(n)){this.checkExportedConstWrite(i,n);let a=this.loopTempName("_err");this.b.emit(` catch (${a}`),this.tsScaffoldAny(),this.b.emit(`) { `),this.b.emit(" ".repeat(t+1)+"("),this.mark(i,"binding",()=>this.withPattern(()=>this.expr(n))),this.b.emit(` = ${a}); `);let o=this.branchLive(s);this.emitTsTypeDecls(u1(s)?s.slice(1):[s[0]]," ".repeat(t+1)),o.forEach((l,c)=>{if(this.b.emit(" ".repeat(t+1)),c===o.length-1)this.implicitReturn(l,t+1);else this.statement(l,t+1);this.b.emit(` -`)}),this.b.emit(" ".repeat(t)+"}")}else this.b.emit(" catch ("),this.mark(i,"binding",()=>this.b.emit(n)),this.b.emit(") "),this.withBindings([n],()=>this.returnBlock(s,t))}}}),this.b.emit(" })()")}valueSwitch(e){let[,t,r,i]=e,n=this.ind,s=" ".repeat(n);this.rejectYieldInIIFE(e),this.b.emit(T.containsAwait(e)?"await (async () => { ":"(() => { "),this.mark(e,"$self",()=>{if(T.hasMatchArms(r))this.checkMatchSwitch(e),this.matchChain(e,n,(a)=>this.returnBlock(a,n));else if(t!==null){this.b.emit("switch ("),this.mark(e,"subject",()=>this.expr(t)),this.b.emit(`) { +`)}),this.b.emit(" ".repeat(t)+"}")}else this.b.emit(" catch ("),this.mark(i,"binding",()=>this.b.emit(n)),this.b.emit(") "),this.withBindings([n],()=>this.returnBlock(s,t))}}})}valueSwitch(e){let[,t,r,i]=e,n=this.ind,s=" ".repeat(n);this.rejectYieldInIIFE(e),this.b.emit(T.containsAwait(e)?"await (async () => { ":"(() => { "),this.mark(e,"$self",()=>{if(T.hasMatchArms(r))this.checkMatchSwitch(e),this.matchChain(e,n,(a)=>this.returnBlock(a,n));else if(t!==null){this.b.emit("switch ("),this.mark(e,"subject",()=>this.expr(t)),this.b.emit(`) { `);for(let a of r){let[,o,l]=a;for(let c of o)this.b.emit(`${s} case `),this.expr(c),this.b.emit(`: `);this.returnCaseBody(l,n)}if(i!==null)this.b.emit(`${s} default: `),this.returnCaseBody(i,n);this.b.emit(`${s}}`)}else if(r.forEach((a,o)=>{let[,l,c]=a;if(o>0)this.b.emit(" else ");this.b.emit("if (("),(Array.isArray(l)?l:[l]).forEach((h,u)=>{if(u>0)this.b.emit(") || (");this.expr(h)}),this.b.emit(")) "),this.returnBlock(c,n)}),i!==null)this.b.emit(" else "),this.returnBlock(i,n)}),this.b.emit(" })()")}returnCaseBody(e,t){this.inCtrl(()=>this.returnCaseBodyCtrl(e,t))}returnCaseBodyCtrl(e,t){let r=this.branchLive(e);this.emitTsTypeDecls(u1(e)?e.slice(1):[e[0]]," ".repeat(t+2)),r.forEach((i,n)=>{if(this.b.emit(" ".repeat(t+2)),n===r.length-1)this.implicitReturn(i,t+2);else this.statement(i,t+2);this.b.emit(` @@ -286,7 +286,7 @@ ${" ".repeat(t)}`);n.forEach((h,u)=>{this.b.emit(`${h} = `),c(),this.b.emit(`[$ `);for(let f of o){let h=E(f.name)&&f.name[0]==="default",u=h?T.paramCore(f.name[1]):f.name,d=h?f.name[1]:f.node;if(E(u)&&u[0]==="rest")throw this.positionedError(f.node,"emitter: a rest parameter cannot follow the '...' gap — the gap already binds every argument between the head and the tail, so a second rest has nothing left to collect; name the tail parameter instead");if(this.b.emit(" ".repeat(i+1)+"const "),typeof u==="string")this.mark(f.node,"$self",()=>this.emitPrimitive(u));else this.withPattern(()=>this.expr(u),!0);let S=this.ts?this.annotationText(d):null;if(S!==null)this.tsAnnotate(d,"annotation",S);if(this.b.emit(" = "),h)this.b.emit(`${f.slot} === undefined ? `),this.withExpression(()=>this.expr(f.name[2])),this.b.emit(` : ${f.slot}`);else this.b.emit(f.slot);this.b.emit(`; `)}this.emitTsTypeDecls(u1(t)?t.slice(1):[t]," ".repeat(i+1)),this.mark(t,"statements",()=>{r.forEach((f,h)=>{if(this.b.emit(" ".repeat(i+1)),!s&&h===r.length-1)this.implicitReturn(f,i+1);else this.statement(f,i+1,!0);this.b.emit(` `)})}),this.voidTailReturn(r,i),this.b.emit(" ".repeat(i)+"}")})}),this.sideEffectOnly=l,this.voidReason=c}voidTailReturn(e,t){if(!this.sideEffectOnly||e.length===0)return;let r=e[e.length-1],i=E(r)?r[0]:null;if(["return","throw","break","continue"].includes(i))return;this.b.emit(" ".repeat(t+1)+`return; -`)}implicitReturn(e,t){this.withTsDirectives(e," ".repeat(t),()=>this.implicitReturnCore(e,t))}implicitReturnCore(e,t){if(E(e)&&(e[0]==="return"||e[0]==="throw"))return this.statement(e,t);if(typeof e==="string"&&(e==="break"||e==="continue"||e==="debugger"))return this.statement(e,t);if(this.ind=t,E(e)){let r=e[0];if(r==="if"&&e.length>=3&&e.length<=4){if(T.ifIsSimple(e))this.b.emit("return ("),this.mark(e,"$self",()=>this.ifTernary(e)),this.b.emit(");");else this.mark(e,"$self",()=>this.returnifyIf(e,t));return}if(r==="try"){this.b.emit("return "),this.withTailReturn(()=>this.valueTry(e)),this.b.emit(";");return}if(r==="switch"&&e.length===4){this.b.emit("return "),this.withTailReturn(()=>this.valueSwitch(e)),this.b.emit(";");return}if(r==="while"&&(e.length===3||e.length===4)||r==="loop"&&e.length===2)return this.statement(e,t);if(T.returnGuard(e)||T.stmtGuard(e)||r==="="&&e.length===3&&(T.returnGuard(e[2])||T.stmtGuard(e[2])))return this.statement(e,t);if(r===".="&&e.length===3)return this.statement(e,t);if(r==="="&&e.length===3&&T.sliceTarget(e[1])!==null)return this.statement(e,t);if(r==="enum")return this.statement(e,t);if(this.isReactiveDecl(e)||this.isReadonlyDecl(e))return this.statement(e,t);if(this.isEffectDecl(e)&&e[1]!==null)return this.statement(e,t);if((r==="for-in"||r==="for-of"||r==="for-as")&&e.length===6)return this.returnifyLoop(e,t);if(g1(r))throw this.positionedError(e,"emitter: implicit return of a 'def' body is not supported yet")}this.b.emit("return "),this.withTailReturn(()=>{let r=T.needsGrouping(e,"return");if(r)this.b.emit("(");if(this.expr(e),r)this.b.emit(")")}),this.b.emit(";")}update(e){if(typeof e[1]==="string"&&this.isComputedName(e[1]))throw this.positionedError(e,`emitter: cannot assign to computed '${e[1]}' — a '~=' binding derives from its dependencies; write to those instead`);if(typeof e[1]==="string"&&this.isAmbientReadonly(e[1]))throw this.positionedError(e,`emitter: cannot assign to readonly '${e[1]}' — a '=!' binding never changes after its declaration`);if(this.checkExportedConstWrite(e,e[1]),this.checkMemberWrite(e,e[1]),E(e[1])&&T.optionalGuard(e[1])!==null)throw this.positionedError(e,"emitter: an optional chain cannot be an update target — no reference exists for `obj?.x++`; "+"guard it explicitly (`obj.x++ if obj?`)");this.mark(e,"$self",()=>{let[t,r,i]=e;if(i)this.mark(e,"target",()=>this.withTarget(()=>this.expr(r))),this.mark(e,"operator",()=>this.b.emit(t));else this.mark(e,"operator",()=>this.b.emit(t)),this.mark(e,"target",()=>this.withTarget(()=>this.expr(r)))})}relation(e){let[t,r,i]=e,n=t[0]==="!",s=n?t.slice(1):t;this.mark(e,"$self",()=>{if(n)this.b.emit("!(");if(s==="instanceof"){if(this.operand(e,"left",r),this.b.emit(" instanceof "),this.operand(e,"right",i),n)this.b.emit(")");return}if(s==="of"||s==="in"&&O1(i))this.operand(e,"left",r),this.b.emit(" in "),this.operand(e,"right",i);else if(E(i))this.b.emit(T.MEMBER_IN+"("),this.mark(e,"left",()=>this.expr(r)),this.b.emit(", "),this.mark(e,"right",()=>this.expr(i)),this.b.emit(")");else this.b.emit("Array.isArray("),this.expr(i),this.b.emit(") || typeof "),this.expr(i),this.b.emit(" === 'string' ? "),this.expr(i),this.b.emit(".includes("),this.mark(e,"left",()=>this.expr(r)),this.b.emit(") : ("),this.expr(r),this.b.emit(" in "),this.mark(e,"right",()=>this.expr(i)),this.b.emit(")");if(n)this.b.emit(")")})}static ternaryHoists(e){let t=e;while(E(t[2])&&t[2][0]==="?:"&&t[2].length===4&&!t[2].parenthesized)t=t[2];let r=t[2];return E(r)&&r[0]==="="&&r.length===3&&typeof r[1]==="string"&&!r.parenthesized}ternary(e){let t=[e];while(!0){let a=t[t.length-1][2];if(E(a)&&a[0]==="?:"&&a.length===4&&!a.parenthesized)t.push(a);else break}let r=t[t.length-1],i=T.ternaryHoists(r),n=(a,o,l)=>{this.grouped(a,o,l,T.needsGrouping(l,"operand")||W1(l))},s=(a)=>this.grouped(a,"condition",a[1],E(a[1])&&a[1][0]==="?:");this.mark(e,"$self",()=>{if(i)this.expr(r[2][1]),this.b.emit(" = (");s(r),this.b.emit(" ? "),n(r,"then",i?r[2][2]:r[2]);for(let a=t.length-2;a>=0;a--)this.b.emit(" : ("),s(t[a]),this.b.emit(" ? "),n(t[a+1],"else",t[a+1][3]);if(this.b.emit(" : "),n(t[0],"else",t[0][3]),this.b.emit(")".repeat(t.length-1)),i)this.b.emit(")")})}strTemplate(e){this.mark(e,"$self",()=>{this.b.emit("`"),this.templateChunks(e.slice(1)),this.b.emit("`")})}templateChunks(e){for(let t of e){if(t==="")continue;if(E(t)){if(t.length!==1)throw this.positionedError(t,"emitter: multi-statement interpolations are not supported yet");this.b.emit("${"),this.mark(t,"$self",()=>{let r=T.needsGrouping(t[0],"operand")||W1(t[0]);if(r)this.b.emit("(");if(this.expr(t[0]),r)this.b.emit(")")}),this.b.emit("}")}else{let r=t.slice(1,-1);if(r!=="")this.b.emit(T.escapeTemplate(r))}}}heregex(e){let[,t,...r]=e;this.mark(e,"$self",()=>{if(this.b.emit("RegExp(`"),this.templateChunks(r),this.b.emit("`"),t!=="")this.b.emit(`, '${t}'`);this.b.emit(")")})}call(e){if(this.browserModule&&e[0]==="import"&&this.lockedHead(e,"dynimport")){let t=this.positionedError(e,"emitter: dynamic import is not supported in a browser App module — use a static import so Rip can publish and resolve the dependency");if(typeof t.start!=="number"&&this.b.currentMark)t.start=this.b.currentMark.sourceStart,t.end=this.b.currentMark.sourceEnd;throw t}if(this.repl&&e[0]==="import"&&(e.length===2||e.length===3)&&this.lockedHead(e,"dynimport")){this.mark(e,"$self",()=>{this.b.emit(`import(${this.replResolver()}(`),this.mark(e,"args",()=>{if(this.callArg(e[1]),this.b.emit(")"),e.length===3)this.b.emit(", "),this.callArg(e[2])}),this.b.emit(")")});return}if(e[0]==="rest"&&this.inPattern)throw this.positionedError(e,this.bindingPattern?"emitter: a `rest` element is only legal at an array pattern's tail":"emitter: Cannot use 'rest' expression as a destructuring target (destructuring rest is spelled '...name')");if(E(e[0])&&e[0][0]==="dammit!"){if(e[0].parenthesized){this.mark(e,"$self",()=>{this.b.emit("("),this.dammit(e[0]),this.b.emit(")"),this.mark(e,"args",()=>{this.b.emit("("),e.slice(1).forEach((i,n)=>{if(n>0)this.b.emit(", ");this.callArg(i)}),this.b.emit(")")})});return}let t=e[0][1],r=wn(t);this.mark(e,"$self",()=>{this.b.emit(r?"await new ":"await "),this.mark(e[0],"$self",()=>{if(r)this.mark(e[0],"target",()=>this.rubyNewTarget(t));else this.head(e[0],"target",t)}),this.mark(e,"args",()=>{this.b.emit("("),e.slice(1).forEach((i,n)=>{if(n>0)this.b.emit(", ");this.callArg(i)}),this.b.emit(")")})});return}if(E(e[0])&&e[0][0]==="."&&e[0].length===3&&e[0][2]==="new"){this.mark(e,"$self",()=>{this.b.emit("new "),this.rubyNewTarget(e[0]),this.mark(e,"args",()=>{this.b.emit("("),e.slice(1).forEach((t,r)=>{if(r>0)this.b.emit(", ");this.callArg(t)}),this.b.emit(")")})});return}this.chain(e)}rubyNewTarget(e){let t=e[1];this.mark(e,"object",()=>{if(E(t))this.b.emit("("),this.expr(t),this.b.emit(T.optionalGuard(t)?" ?? undefined)":")");else this.expr(t)})}static MODULO="((n, d) => { n = +n; d = +d; return (n % d + d) % d; })";static LITERAL_WORDS=new Set(["true","false","null","undefined","NaN","Infinity"]);static ownKeyText(e,t){return t==="__proto__"?'["__proto__"]':e}static MEMBER_IN="((k, c) => Array.isArray(c) || typeof c === 'string' ? c.includes(k) : k in c)";floorDiv(e){this.mark(e,"$self",()=>{this.b.emit("Math.floor("),this.operand(e,"left",e[1]),this.b.emit(" "),this.mark(e,"operator",()=>this.b.emit("/")),this.b.emit(" "),this.operand(e,"right",e[2]),this.b.emit(")")})}returnGuardStatement(e,t){let r=e[2],i=typeof r==="string"?r:r[0];if(i==="return"&&this.scopes.length<=1)throw this.positionedError(r,"emitter: 'return' outside a function");if((i==="break"||i==="continue")&&this.ctrlDepth===0)throw this.positionedError(e,`emitter: '${i}' outside a loop${i==="break"?" or switch":""}`);let n=e[0],s=()=>{let a=()=>{if(t!==null)this.mark(t,"$self",()=>{this.mark(t,"target",()=>this.b.emit(t[1])),this.b.emit(" "),this.mark(t,"operator",()=>this.b.emit("=")),this.b.emit(" "),this.mark(t,"value",()=>this.expr(e[1]))});else this.mark(e,"left",()=>this.expr(e[1]))},o=t!==null||T.jsTier(e[1])!=="primary";if(n==="||")if(this.b.emit("!"),o)this.b.emit("("),a(),this.b.emit(")");else a();else if(n==="??"){if(o)this.b.emit("("),a(),this.b.emit(")");else a();this.b.emit(" == null")}else if(o&&t!==null)this.b.emit("("),a(),this.b.emit(")");else a()};this.mark(e,"$self",()=>{this.b.emit("if ("),s(),this.b.emit(") ");let a=()=>{if(this.b.emit(i),E(r)&&r.length>1)this.b.emit(" "),this.mark(r,"value",()=>{if(r[0]==="return"&&T.needsGrouping(r[1],"return"))this.b.emit("("),this.expr(r[1]),this.b.emit(")");else this.expr(r[1])})};if(typeof r==="string")a();else this.mark(r,"$self",a);this.b.emit(";")})}compoundTarget(e,t,r){if(this.checkExportedConstWrite(e,t),this.repeatSafeValue(t))return this.mark(e,"target",()=>this.withTarget(()=>this.expr(t))),t;if(E(t)&&(t[0]==="."||t[0]==="[]")&&t.length===3){let i=t[1];if(!this.repeatSafeValue(i))i=this.loopTempName("_ref"),this.temps.used.add(i),this.b.emit(`const ${i} = `),this.expr(t[1]),this.b.emit(`; +`)}implicitReturn(e,t){this.withTsDirectives(e," ".repeat(t),()=>this.implicitReturnCore(e,t))}implicitReturnCore(e,t){if(E(e)&&(e[0]==="return"||e[0]==="throw"))return this.statement(e,t);if(typeof e==="string"&&(e==="break"||e==="continue"||e==="debugger"))return this.statement(e,t);if(this.ind=t,E(e)){let r=e[0];if(r==="if"&&e.length>=3&&e.length<=4){if(T.ifIsSimple(e))this.b.emit("return ("),this.mark(e,"$self",()=>this.ifTernary(e)),this.b.emit(");");else this.mark(e,"$self",()=>this.returnifyIf(e,t));return}if(r==="try"){this.withTailReturn(()=>this.tryBranches(e,t));return}if(r==="switch"&&e.length===4){this.b.emit("return "),this.withTailReturn(()=>this.valueSwitch(e)),this.b.emit(";");return}if(r==="while"&&(e.length===3||e.length===4)||r==="loop"&&e.length===2)return this.statement(e,t);if(T.returnGuard(e)||T.stmtGuard(e)||r==="="&&e.length===3&&(T.returnGuard(e[2])||T.stmtGuard(e[2])))return this.statement(e,t);if(r===".="&&e.length===3)return this.statement(e,t);if(r==="="&&e.length===3&&T.sliceTarget(e[1])!==null)return this.statement(e,t);if(r==="enum")return this.statement(e,t);if(this.isReactiveDecl(e)||this.isReadonlyDecl(e))return this.statement(e,t);if(this.isEffectDecl(e)&&e[1]!==null)return this.statement(e,t);if((r==="for-in"||r==="for-of"||r==="for-as")&&e.length===6)return this.returnifyLoop(e,t);if(g1(r))throw this.positionedError(e,"emitter: implicit return of a 'def' body is not supported yet")}this.b.emit("return "),this.withTailReturn(()=>{let r=T.needsGrouping(e,"return");if(r)this.b.emit("(");if(this.expr(e),r)this.b.emit(")")}),this.b.emit(";")}update(e){if(typeof e[1]==="string"&&this.isComputedName(e[1]))throw this.positionedError(e,`emitter: cannot assign to computed '${e[1]}' — a '~=' binding derives from its dependencies; write to those instead`);if(typeof e[1]==="string"&&this.isAmbientReadonly(e[1]))throw this.positionedError(e,`emitter: cannot assign to readonly '${e[1]}' — a '=!' binding never changes after its declaration`);if(this.checkExportedConstWrite(e,e[1]),this.checkMemberWrite(e,e[1]),E(e[1])&&T.optionalGuard(e[1])!==null)throw this.positionedError(e,"emitter: an optional chain cannot be an update target — no reference exists for `obj?.x++`; "+"guard it explicitly (`obj.x++ if obj?`)");this.mark(e,"$self",()=>{let[t,r,i]=e;if(i)this.mark(e,"target",()=>this.withTarget(()=>this.expr(r))),this.mark(e,"operator",()=>this.b.emit(t));else this.mark(e,"operator",()=>this.b.emit(t)),this.mark(e,"target",()=>this.withTarget(()=>this.expr(r)))})}relation(e){let[t,r,i]=e,n=t[0]==="!",s=n?t.slice(1):t;this.mark(e,"$self",()=>{if(n)this.b.emit("!(");if(s==="instanceof"){if(this.operand(e,"left",r),this.b.emit(" instanceof "),this.operand(e,"right",i),n)this.b.emit(")");return}if(s==="of"||s==="in"&&O1(i))this.operand(e,"left",r),this.b.emit(" in "),this.operand(e,"right",i);else if(E(i))this.b.emit(T.MEMBER_IN+"("),this.mark(e,"left",()=>this.expr(r)),this.b.emit(", "),this.mark(e,"right",()=>this.expr(i)),this.b.emit(")");else this.b.emit("Array.isArray("),this.expr(i),this.b.emit(") || typeof "),this.expr(i),this.b.emit(" === 'string' ? "),this.expr(i),this.b.emit(".includes("),this.mark(e,"left",()=>this.expr(r)),this.b.emit(") : ("),this.expr(r),this.b.emit(" in "),this.mark(e,"right",()=>this.expr(i)),this.b.emit(")");if(n)this.b.emit(")")})}static ternaryHoists(e){let t=e;while(E(t[2])&&t[2][0]==="?:"&&t[2].length===4&&!t[2].parenthesized)t=t[2];let r=t[2];return E(r)&&r[0]==="="&&r.length===3&&typeof r[1]==="string"&&!r.parenthesized}ternary(e){let t=[e];while(!0){let a=t[t.length-1][2];if(E(a)&&a[0]==="?:"&&a.length===4&&!a.parenthesized)t.push(a);else break}let r=t[t.length-1],i=T.ternaryHoists(r),n=(a,o,l)=>{this.grouped(a,o,l,T.needsGrouping(l,"operand")||W1(l))},s=(a)=>this.grouped(a,"condition",a[1],E(a[1])&&a[1][0]==="?:");this.mark(e,"$self",()=>{if(i)this.expr(r[2][1]),this.b.emit(" = (");s(r),this.b.emit(" ? "),n(r,"then",i?r[2][2]:r[2]);for(let a=t.length-2;a>=0;a--)this.b.emit(" : ("),s(t[a]),this.b.emit(" ? "),n(t[a+1],"else",t[a+1][3]);if(this.b.emit(" : "),n(t[0],"else",t[0][3]),this.b.emit(")".repeat(t.length-1)),i)this.b.emit(")")})}strTemplate(e){this.mark(e,"$self",()=>{this.b.emit("`"),this.templateChunks(e.slice(1)),this.b.emit("`")})}templateChunks(e){for(let t of e){if(t==="")continue;if(E(t)){if(t.length!==1)throw this.positionedError(t,"emitter: multi-statement interpolations are not supported yet");this.b.emit("${"),this.mark(t,"$self",()=>{let r=T.needsGrouping(t[0],"operand")||W1(t[0]);if(r)this.b.emit("(");if(this.expr(t[0]),r)this.b.emit(")")}),this.b.emit("}")}else{let r=t.slice(1,-1);if(r!=="")this.b.emit(T.escapeTemplate(r))}}}heregex(e){let[,t,...r]=e;this.mark(e,"$self",()=>{if(this.b.emit("RegExp(`"),this.templateChunks(r),this.b.emit("`"),t!=="")this.b.emit(`, '${t}'`);this.b.emit(")")})}call(e){if(this.browserModule&&e[0]==="import"&&this.lockedHead(e,"dynimport")){let t=this.positionedError(e,"emitter: dynamic import is not supported in a browser App module — use a static import so Rip can publish and resolve the dependency");if(typeof t.start!=="number"&&this.b.currentMark)t.start=this.b.currentMark.sourceStart,t.end=this.b.currentMark.sourceEnd;throw t}if(this.repl&&e[0]==="import"&&(e.length===2||e.length===3)&&this.lockedHead(e,"dynimport")){this.mark(e,"$self",()=>{this.b.emit(`import(${this.replResolver()}(`),this.mark(e,"args",()=>{if(this.callArg(e[1]),this.b.emit(")"),e.length===3)this.b.emit(", "),this.callArg(e[2])}),this.b.emit(")")});return}if(e[0]==="rest"&&this.inPattern)throw this.positionedError(e,this.bindingPattern?"emitter: a `rest` element is only legal at an array pattern's tail":"emitter: Cannot use 'rest' expression as a destructuring target (destructuring rest is spelled '...name')");if(E(e[0])&&e[0][0]==="dammit!"){if(e[0].parenthesized){this.mark(e,"$self",()=>{this.b.emit("("),this.dammit(e[0]),this.b.emit(")"),this.mark(e,"args",()=>{this.b.emit("("),e.slice(1).forEach((i,n)=>{if(n>0)this.b.emit(", ");this.callArg(i)}),this.b.emit(")")})});return}let t=e[0][1],r=wn(t);this.mark(e,"$self",()=>{this.b.emit(r?"await new ":"await "),this.mark(e[0],"$self",()=>{if(r)this.mark(e[0],"target",()=>this.rubyNewTarget(t));else this.head(e[0],"target",t)}),this.mark(e,"args",()=>{this.b.emit("("),e.slice(1).forEach((i,n)=>{if(n>0)this.b.emit(", ");this.callArg(i)}),this.b.emit(")")})});return}if(E(e[0])&&e[0][0]==="."&&e[0].length===3&&e[0][2]==="new"){this.mark(e,"$self",()=>{this.b.emit("new "),this.rubyNewTarget(e[0]),this.mark(e,"args",()=>{this.b.emit("("),e.slice(1).forEach((t,r)=>{if(r>0)this.b.emit(", ");this.callArg(t)}),this.b.emit(")")})});return}this.chain(e)}rubyNewTarget(e){let t=e[1];this.mark(e,"object",()=>{if(E(t))this.b.emit("("),this.expr(t),this.b.emit(T.optionalGuard(t)?" ?? undefined)":")");else this.expr(t)})}static MODULO="((n, d) => { n = +n; d = +d; return (n % d + d) % d; })";static LITERAL_WORDS=new Set(["true","false","null","undefined","NaN","Infinity"]);static ownKeyText(e,t){return t==="__proto__"?'["__proto__"]':e}static MEMBER_IN="((k, c) => Array.isArray(c) || typeof c === 'string' ? c.includes(k) : k in c)";floorDiv(e){this.mark(e,"$self",()=>{this.b.emit("Math.floor("),this.operand(e,"left",e[1]),this.b.emit(" "),this.mark(e,"operator",()=>this.b.emit("/")),this.b.emit(" "),this.operand(e,"right",e[2]),this.b.emit(")")})}returnGuardStatement(e,t){let r=e[2],i=typeof r==="string"?r:r[0];if(i==="return"&&this.scopes.length<=1)throw this.positionedError(r,"emitter: 'return' outside a function");if((i==="break"||i==="continue")&&this.ctrlDepth===0)throw this.positionedError(e,`emitter: '${i}' outside a loop${i==="break"?" or switch":""}`);let n=e[0],s=()=>{let a=()=>{if(t!==null)this.mark(t,"$self",()=>{this.mark(t,"target",()=>this.b.emit(t[1])),this.b.emit(" "),this.mark(t,"operator",()=>this.b.emit("=")),this.b.emit(" "),this.mark(t,"value",()=>this.expr(e[1]))});else this.mark(e,"left",()=>this.expr(e[1]))},o=t!==null||T.jsTier(e[1])!=="primary";if(n==="||")if(this.b.emit("!"),o)this.b.emit("("),a(),this.b.emit(")");else a();else if(n==="??"){if(o)this.b.emit("("),a(),this.b.emit(")");else a();this.b.emit(" == null")}else if(o&&t!==null)this.b.emit("("),a(),this.b.emit(")");else a()};this.mark(e,"$self",()=>{this.b.emit("if ("),s(),this.b.emit(") ");let a=()=>{if(this.b.emit(i),E(r)&&r.length>1)this.b.emit(" "),this.mark(r,"value",()=>{if(r[0]==="return"&&T.needsGrouping(r[1],"return"))this.b.emit("("),this.expr(r[1]),this.b.emit(")");else this.expr(r[1])})};if(typeof r==="string")a();else this.mark(r,"$self",a);this.b.emit(";")})}compoundTarget(e,t,r){if(this.checkExportedConstWrite(e,t),this.repeatSafeValue(t))return this.mark(e,"target",()=>this.withTarget(()=>this.expr(t))),t;if(E(t)&&(t[0]==="."||t[0]==="[]")&&t.length===3){let i=t[1];if(!this.repeatSafeValue(i))i=this.loopTempName("_ref"),this.temps.used.add(i),this.b.emit(`const ${i} = `),this.expr(t[1]),this.b.emit(`; ${" ".repeat(r)}`);let n;if(t[0]==="[]"){let s=t[2];if(!this.repeatSafeValue(s)){let a=this.loopTempName("_key");this.temps.used.add(a),this.b.emit(`const ${a} = `),this.expr(s),this.b.emit(`; ${" ".repeat(r)}`),s=a}n=["[]",i,s]}else n=[".",i,t[2]];return this.mark(e,"target",()=>this.expr(n)),n}throw this.positionedError(e,`emitter: ${e[0]} needs a stable target — a plain name or member/index chain (an optional chain has no reference to write back to)`)}static sliceTarget(e){return E(e)&&e[0]==="[]"&&e.length===3&&E(e[2])&&(e[2][0]===".."||e[2][0]==="...")&&e[2].length===3?e:null}sliceAssignStatement(e){let[,t,r]=e,[,i,n]=t,[s,a,o]=n,l=(h)=>T.isIntegerLiteral(h)?parseInt(h.replace(/_/g,""),10):null,c=(h)=>typeof h==="string";for(let h of[a,o])if(E(h)&&h[0]==="-"&&h.length===2&&T.isIntegerLiteral(h[1]))throw this.positionedError(e,"emitter: a slice assignment cannot count from the end — `splice` takes a count, not a negative index; open the range instead (`a[i..] = v`) or compute the bound from `a.length`");let f=(h)=>{if(c(h))this.expr(h);else this.b.emit("("),this.expr(h),this.b.emit(")")};this.mark(e,"$self",()=>{this.mark(e,"target",()=>this.mark(t,"$self",()=>{this.head(t,"object",i),this.b.emit(".splice("),this.mark(t,"key",()=>{if(a===null)this.b.emit("0");else f(a);if(this.b.emit(", "),o===null)this.b.emit("Infinity");else if(l(o)!==null&&(a===null||l(a)!==null))this.b.emit(String(l(o)-(a===null?0:l(a))+(s===".."?1:0)));else{if(f(o),a!==null)this.b.emit(" - "),f(a);if(s==="..")this.b.emit(" + 1")}})})),this.mark(e,"operator",()=>{});let h=E(r)&&r[0]==="array"&&r.slice(1).every((u)=>!(E(u)&&u[0]==="...")&&u!==",");this.mark(e,"value",()=>{if(h)r.slice(1).forEach((u)=>{this.b.emit(", "),this.callArg(u)});else this.b.emit(", ...[].concat("),this.expr(r),this.b.emit(")")}),this.b.emit(")")})}methodAssignStatement(e,t){let[,r,i]=e,n=i;while(E(n)){let l=T.chainHeadSlot(n);if(l===null)break;n=n[l]}let s=E(n)?this.stores.idOf(n):null,a=s!==null?this.stores.node(s)?.semanticKind:null;if(!(E(n)&&typeof n[0]==="string"&&/^[A-Za-z_$][\w$]*$/.test(n[0])&&(a==="call"||a==null&&T.jsTier(n)==="primary")))throw this.positionedError(e,"emitter: `.=` re-binds its target to a METHOD CALL on itself — the right side must be a call chain (`x .= trim()`)");this.mark(e,"$self",()=>{let l=this.compoundTarget(e,r,t),c=(h)=>{if(h===n)return[[".",l,n[0]],...n.slice(1)];let u=T.chainHeadSlot(h),d=h.slice();return d[u]=c(h[u]),d};this.b.emit(" "),this.mark(e,"operator",()=>this.b.emit("=")),this.b.emit(" ");let f=typeof l==="string"?this.bindingNameSpan(e,"target",l):null;if(f!==null)this.primitiveReuse={name:l,span:f.span};this.mark(e,"value",()=>this.expr(c(i))),this.primitiveReuse=null})}taggedTemplate(e){this.mark(e,"$self",()=>{let t=e[1];this.mark(e,"tag",()=>{if(T.needsGrouping(t,"head"))this.b.emit("("),this.expr(t),this.b.emit(")");else this.expr(t)});let r=e[2];this.mark(e,"str",()=>{if(typeof r==="string")if(r[0]==="`")this.b.emit(r);else this.b.emit("`"+T.escapeTemplate(r.slice(1,-1).replace(/\\"/g,'"'))+"`");else this.expr(r)})})}mapLiteral(e){this.mark(e,"$self",()=>{let t=e.slice(1);if(t.length===0){this.b.emit("new Map()");return}this.b.emit("new Map(["),t.forEach((r,i)=>{if(i>0)this.b.emit(", ");if(E(r)&&r[0]==="..."&&r.length===2){this.mark(r,"$self",()=>{this.b.emit("..."),this.expr(r[1])});return}if(!E(r)||r[0]!==":"||r.length!==3)throw this.positionedError(E(r)?r:e,"emitter: a map literal takes explicit `key: value` pairs — shorthand has no Map reading");this.mark(r,"$self",()=>{this.b.emit("[");let n=r[1];this.mark(r,"key",()=>{if(typeof n==="string"&&/^[A-Za-z_$][\w$]*$/.test(n)&&n!=="true"&&n!=="false"&&n!=="null"&&n!=="undefined")this.b.emit('"'),this.emitPrimitive(n),this.b.emit('"');else if(E(n)&&n[0]==="dynamicKey")this.expr(n[1]);else this.expr(n)}),this.b.emit(", "),this.mark(r,"value",()=>this.expr(r[2])),this.b.emit("]")})}),this.b.emit("])")})}matchReceiverClose(){this.b.emit(")"),this.b.emit(".match(")}regexIndex(e,t,r,i){this.mark(e,"$self",()=>{if(this.b.emit(`((_ = ${this.runtimeName("toMatchable")}(`),this.mark(e,"object",()=>this.expr(t)),this.matchReceiverClose(),this.mark(e,"key",()=>this.b.emit(r)),this.b.emit(")) && _["),i===null)this.b.emit("0");else this.mark(e,"capture",()=>this.expr(i));this.b.emit("])")})}static isMatchWrite(e){if(!E(e))return!1;if(e[0]==="=~"&&e.length===3)return!0;if(e[0]==="regex-index"&&e.length===4)return!0;return e[0]==="[]"&&e.length===3&&typeof e[2]==="string"&&e[2][0]==="/"}static paramMatchWrite(e){if(!E(e)||T1(e)||g1(e[0]))return null;if(T.isMatchWrite(e))return e;for(let t of e){let r=T.paramMatchWrite(t);if(r!==null)return r}return null}matchOp(e){if(E(e[1])&&e[1][0]==="=~"&&!e[1].parenthesized)throw this.positionedError(e,"emitter: `=~` does not chain — `a =~ b =~ c` would match the first match RESULT against the second pattern (parenthesize: `(a =~ b) =~ c`, or split the matches)");let t=e[2];this.mark(e,"$self",()=>{this.b.emit(`(_ = ${this.runtimeName("toMatchable")}(`),this.mark(e,"left",()=>this.expr(e[1])),this.matchReceiverClose(),this.mark(e,"right",()=>this.expr(t)),this.b.emit("))")})}modulo(e){this.mark(e,"$self",()=>{this.b.emit(T.MODULO+"("),this.mark(e,"left",()=>this.expr(e[1])),this.b.emit(", "),this.mark(e,"right",()=>this.expr(e[2])),this.b.emit(")")})}synthCompound(e,t,r,i){let n=e[1];if(this.checkExportedConstWrite(e,n),E(n)&&(n[0]==="."||n[0]==="[]")&&n.length===3){let s=this.refPlans.get(e)??{recv:null,obj:null,key:null};if(s.obj===null&&!this.repeatSafeValue(n[1]))throw this.positionedError(e,"emitter: reference plan missing for a compound target with an impure object — a capture site the planner walk did not reach");if(s.key===null&&n[0]==="[]"&&!this.repeatSafeValue(n[2]))throw this.positionedError(e,"emitter: reference plan missing for a compound target with an impure key — a capture site the planner walk did not reach");this.mark(e,"$self",()=>{let a=s.obj!==null||s.key!==null;if(a)this.b.emit("(");if(s.obj!==null)this.b.emit(`${s.obj} = `),this.mark(n,"object",()=>this.withExpression(()=>this.expr(n[1]))),this.b.emit(", ");if(s.key!==null)this.b.emit(`${s.key} = `),this.mark(n,"key",()=>this.withExpression(()=>this.expr(n[2]))),this.b.emit(", ");let o=this.stores.alias([n[0],s.obj??n[1],s.key??n[2]],n),l=()=>this.mark(e,"target",()=>this.withTarget(()=>this.expr(o)));if(l(),this.b.emit(" "),this.mark(e,"operator",()=>this.b.emit("=")),this.b.emit(" "),this.mark(e,"operator",()=>{this.b.emit(t),l(),this.b.emit(r),this.operand(e,"value",e[2]),this.b.emit(i)}),a)this.b.emit(")")});return}this.mark(e,"$self",()=>{let s=()=>this.mark(e,"target",()=>this.withTarget(()=>this.expr(e[1])));s(),this.b.emit(" "),this.mark(e,"operator",()=>this.b.emit("=")),this.b.emit(" "),this.mark(e,"operator",()=>{this.b.emit(t),s(),this.b.emit(r),this.operand(e,"value",e[2]),this.b.emit(i)})})}floorDivAssign(e){this.synthCompound(e,"Math.floor("," / ",")")}moduloAssign(e){this.synthCompound(e,T.MODULO+"(",", ",")")}awaitExpr(e){this.mark(e,"$self",()=>{this.mark(e,"operator",()=>this.b.emit("await")),this.b.emit(" "),this.operand(e,"value",e[1])})}doIife(e){let[,t]=e;this.mark(e,"$self",()=>{if(this.b.emit("("),this.mark(e,"func",()=>this.expr(t)),this.b.emit(")("),T1(t)){let r=t[1],i=r.map((s)=>{let a=T.paramCore(s);if(typeof a==="string")return()=>this.expr(a);if(E(a)&&a[0]==="default"&&typeof T.paramCore(a[1])==="string")return()=>this.expr(a[2]);throw this.positionedError(s,"emitter: do-IIFE parameters must be plain names or defaulted names — patterns and rests have no capture argument",e)}),n=r.length;while(n>0&&E(r[n-1])&&r[n-1][0]==="default")n--;i.slice(0,n).forEach((s,a)=>{if(a>0)this.b.emit(", ");s()})}this.b.emit(")")})}dammit(e){if(wn(e[1])){this.mark(e,"$self",()=>{this.mark(e,"operator",()=>this.b.emit("await")),this.b.emit(" new "),this.mark(e,"target",()=>this.rubyNewTarget(e[1])),this.b.emit("()")});return}this.mark(e,"$self",()=>{this.mark(e,"operator",()=>this.b.emit("await")),this.b.emit(" "),this.head(e,"target",e[1]),this.b.emit("()")})}maybeDammit(e){this.mark(e,"$self",()=>{this.mark(e,"operator",()=>this.b.emit("await")),this.b.emit(" "),this.head(e,"callee",e[1]),this.mark(e,"operator",()=>this.b.emit("?.")),this.mark(e,"args",()=>{this.b.emit("("),e.slice(2).forEach((t,r)=>{if(r>0)this.b.emit(", ");this.expr(t)}),this.b.emit(")")})})}yieldExpr(e){if(this.scopes.length<=1)throw this.positionedError(e,"emitter: 'yield' outside a function");this.mark(e,"$self",()=>{this.b.emit(e[0]==="yield-from"?"yield*":"yield");let t=e[0]==="yield-from"?e[1]:e[1];if(e.length>1)this.b.emit(" "),this.operand(e,"value",t)})}}var ea=(e)=>{if(!E(e))return!1;if(e[0]==="schema"&&e.length===2&&typeof e[1]==="object")return!0;return e.some(ea)},ta=(e)=>{if(!E(e))return!1;if(e[0]==="schema"&&e.length===2&&e[1]&&typeof e[1]==="object"&&e[1].kind==="model")return!0;return e.some(ta)},ra=(e,t)=>{if(!E(e))return!1;if(t(e))return!0;return e.some((r)=>ra(r,t))},na=(e,t)=>{if(!E(e))return!1;if(t(e))return!0;return e.some((r)=>na(r,t))},ia=(e)=>{if(!E(e))return!1;if(e[0]==="object"&&T.objectComprehension(e)!==null)return!0;return e.some(ia)},sa=(e)=>{if(!E(e))return!1;if(T.isMatchWrite(e))return!0;return e.some(sa)},ft=[{key:"intrinsics",names:["__toPropertyKey","__defineOwnDataProperty"],generatedNames:["__toPropertyKey","__defineOwnDataProperty"],url:new URL("./runtime/intrinsics.js",import.meta.url),triggers:(e,t)=>ia(e)},{key:"vocab",names:[],url:new URL("./runtime/vocab.js",import.meta.url),triggers:()=>!1},{key:"schema",names:["__schema","SchemaError","registerCoercer"],url:new URL("./runtime/schema.js",import.meta.url),requires:["vocab"],triggers:(e,t)=>ea(e)},{key:"duckdb",names:[],url:new URL("./runtime/duckdb.js",import.meta.url),triggers:()=>!1},{key:"orm",names:["schema","__schemaSetAdapter"],url:new URL("./runtime/orm.js",import.meta.url),requires:["schema","duckdb","vocab"],triggers:(e,t)=>ta(e)},{key:"reactive",names:["__state","__computed","__effect","__batch","__readonly","__setErrorHandler","__handleError","__catchErrors","getEffectSignal"],generatedNames:["__state","__computed","__effect","__batch"],url:new URL("./runtime/reactive.js",import.meta.url),triggers:(e,t)=>ra(e,t.isTrigger),types:{__state:"(value: T | { value: T; read(): T }) => { value: T; read(): T; touch(): void }",__computed:"(fn: () => T) => { readonly value: T; read(): T }",__effect:"(fn: () => void | (() => void)) => () => void",__batch:"(fn: () => T) => T",__readonly:"(value: T) => T",__setErrorHandler:"(handler: ((error: any, source?: string) => void) | null) => void",__handleError:"(error: any, source?: string) => void",__catchErrors:"(fn: () => T, onError?: (e: any) => void) => T | undefined",getEffectSignal:"() => AbortSignal | null"}},{key:"stdlib",names:["abort","assert","exit","kind","noop","p","pp","pj","pr","raise","rand","sleep","toMatchable","todo","warn","zip"],generatedNames:["toMatchable"],url:new URL("./runtime/stdlib.js",import.meta.url),triggers:(e,t)=>sa(e),types:{abort:"(msg?: string) => never",assert:"(v: any, msg?: string) => void",exit:"(code?: number) => never",kind:"(v: any) => string",noop:"() => void",p:"(...args: any[]) => void",pp:"(v: T) => T",pj:"(v: T) => T",pr:"(v: T) => T",raise:"(a: any, b?: any) => never",rand:"(a?: number, b?: number) => number",sleep:"(ms: number) => Promise",toMatchable:"(v: any) => string",todo:"(msg?: string) => never",warn:"(...args: any[]) => void",zip:"(...arrays: any[][]) => any[][]"}},{key:"components",names:["setContext","getContext","hasContext","__Component","__pushComponent","__popComponent","__clsx","__style","__lis","__reconcile","__transition","__handleComponentError","__gateBind","__detach","__ownerFrame","__pushOwner","__popOwner","__detachRef"],generatedNames:["setContext","getContext","__Component","__pushComponent","__popComponent","__clsx","__style","__reconcile","__transition","__gateBind","__detach","__ownerFrame","__pushOwner","__popOwner","__detachRef"],types:{__clsx:ys,__style:Es},url:new URL("./runtime/components.js",import.meta.url),requires:"reactive",triggers:(e,t)=>na(e,t.isComponent)}],An=new Map,Xs=(e)=>{if(!An.has(e.key)){let r=ps(e.url,"utf8").replace(/^export \{[^}]*\};\s*$/gm,"").replace(/^import \{[^}]*\} from '\.\/[a-z-]+\.js';\s*$/gm,"").trimEnd(),i=/^[ \t]*(import|export)\b.*$/m.exec(r);if(i)throw Error(`emitter: runtime '${e.key}' carries a top-level ${i[1]} that inline delivery cannot strip — `+`${JSON.stringify(i[0].trim())}. Inline bodies share one IIFE scope, so it would emit unparseable output. Use the './name.js' import form, or move the dependency into RUNTIME_TABLE 'requires'.`);An.set(e.key,r)}return An.get(e.key)},vn=(e)=>e.requires==null?[]:Array.isArray(e.requires)?e.requires:[e.requires],Ie=(e,t,r=()=>!1)=>{if(t.size===0)return!1;let i=(o)=>typeof o==="string"&&t.has(o),n=(o)=>E(o)&&o.some(s),s=(o)=>{if(!E(o))return!1;let[l]=o;if(l==="object"||l==="array")return o.slice(1).some(s);if(l===null&&o.length===3)return!1;if(l===":"&&o.length===3)return E(o[1])&&a(o[1])||s(o[2]);if(l==="="&&o.length===3)return s(o[1])||a(o[2]);if((l==="rest"||l==="..."||l==="expansion")&&o.length===2)return s(o[1]);if(l==="typed-var"&&o.length===3)return s(o[1]);return a(o)},a=(o)=>{if(i(o))return!0;if(!E(o))return!1;let[l]=o;if(l==="schema"&&o.length===2&&o[1]&&typeof o[1]==="object"&&Array.isArray(o[1].entries))return!1;if(l==="."||l==="?.")return a(o[1]);if((l===":"||l==="void-pair")&&o.length===3)return E(o[1])&&a(o[1])||a(o[2]);if(T1(o))return n(o[1])||a(o[2]);if(g1(l)&&o.length===4)return n(o[2])||a(o[3]);if(r(o))return a(o[2]);if(M1.has(l)&&o.length===3)return E(o[1])&&s(o[1])||a(o[2]);if(l==="for-in"||l==="for-of"||l==="for-as")return E(o[1])&&o[1].some(s)||o.slice(2).some(a);if(l==="try")return o.slice(1).some((c)=>{if(!E(c))return!1;if(c[0]==="block")return a(c);return s(c[0])||a(c[1])});if(l==="class"&&o.length>=2)return o.slice(2).some(a);if(l==="typed-var"&&o.length===3)return E(o[1])&&a(o[1]);if(l==="cast"&&o.length===3)return a(o[1]);if(l==="import"||l==="type-decl")return!1;return o.some(a)};return a(e)},g3=(e,t)=>{let r=[],i=(n,s,a=[])=>{let o=(h)=>T.isReactiveDeclIn(s,h)||T.isEffectDeclIn(s,h)||T.isReadonlyDeclIn(s,h)||T.isGateDeclIn(s,h),l=(h)=>T.isReactiveDeclIn(s,h)||T.isEffectDeclIn(s,h),c=(h)=>T.isComponentDeclIn(s,h);r.push({tree:n,atoms:a,isDecl:o,isTrigger:l,isComponent:c});let f=(h)=>{if(!E(h))return;if(h[0]==="schema"&&h.length===2&&h[1]&&typeof h[1]==="object"&&Array.isArray(h[1].entries)){for(let{entry:u,tokens:d,value:S}of T.schemaBodies(h[1])){let g=e.subParse(d);if(g.stmts.length)i(["program",...g.stmts],g.stores,S?[]:e.schemaBodyParams(u).map((p)=>p.name))}return}h.forEach(f)};f(n)};return i(t,e.stores),r},b3=(e,t)=>{let r=new Set,i=(s)=>{for(let a of e.patternNames(s,[],!0))r.add(a)},n=(s,a)=>{if(!E(s))return;let[o]=s;if(e.isModuleImport(s)){for(let l of T.importedNames([s]))r.add(l);return}if(T1(s)){if(E(s[1]))for(let l of s[1])i(l);n(s[2],a);return}if(g1(o)&&s.length===4){if(typeof s[1]==="string")r.add(s[1]);if(E(s[2]))for(let l of s[2])i(l);n(s[3],a);return}if(o==="class"){if(typeof s[1]==="string")r.add(s[1]);for(let l of s.slice(2)){let c=E(l)&&l[0]==="block"?l.slice(1):[l];for(let f of c)if(E(f)&&g1(f[0])&&f.length===4){if(E(f[2]))for(let h of f[2])i(h);n(f[3],a)}else n(f,a)}return}if(o==="enum"){if(typeof s[1]==="string")r.add(s[1]);for(let l of s.slice(2))n(l,a);return}if(a(s)){if(typeof s[1]==="string")r.add(s[1]);else if(E(s[1]))i(s[1]);n(s[2],a);return}if((M1.has(o)||o==="void-assign")&&s.length>=2){if(typeof s[1]==="string")r.add(s[1]);else if(T.isPattern(s[1]))i(s[1])}if((o==="for-in"||o==="for-of"||o==="for-as")&&E(s[1]))for(let l of s[1])i(l);if(o==="try"){for(let l of s.slice(2))if(E(l)&&l.length===2&&T.isPattern(l[0]))i(l[0])}for(let l of s)n(l,a)};for(let{tree:s,atoms:a,isDecl:o}of t){n(s,o);for(let l of a)i(l)}return r},y3=(e,t)=>{let r=t.slice(1),i=new Set(e.hoistTargets(r).map(([a])=>a)),n=r.filter((a)=>e.isModuleImport(a));for(let a of T.importedNames(n))i.add(a);for(let a of e.collectReactiveNames(r))i.add(a);for(let a of e.collectEffectHandles(r))i.add(a);for(let a of e.collectReadonlyNames(r))i.add(a);let s=(a)=>{if(!E(a))return;if(a[0]==="enum"&&typeof a[1]==="string")i.add(a[1]);if(a[0]==="class"&&typeof a[1]==="string")i.add(a[1]);if(g1(a[0])&&a.length===4&&typeof a[1]==="string")i.add(a[1]);if((a[0]==="="||a[0]==="void-assign")&&typeof a[1]==="string")i.add(a[1])};for(let a of r)if(s(a),E(a)&&a[0]==="export"&&E(a[1]))s(a[1]);return i},Js=new Set(["plain","state","computed","effect","readonly","import","class","def","enum"]),S3=(e)=>{if(e==null)return[];if(!Array.isArray(e))throw Error(`emitter: ambientBindings must be an array of {name, kind}; got ${typeof e}`);let t=new Set;for(let r of e){if(r===null||typeof r!=="object"||!X1(r.name))throw Error(`emitter: ambientBindings entries are {name, kind} with an identifier name; got ${JSON.stringify(r)}`);if(!Js.has(r.kind))throw Error(`emitter: ambientBindings kind '${r.kind}' for '${r.name}' is not a binding kind — expected one of ${[...Js].join(", ")}`);if(t.has(r.name))throw Error(`emitter: ambientBindings names '${r.name}' twice — one binding per name`);t.add(r.name)}return e},R3=(e,t,r)=>{let i=t.slice(1),n=new Map,s=(c,f)=>{if(typeof c==="string"&&!n.has(c))n.set(c,f)},a=(c)=>{if(!r.has(c))s(c,"plain")};for(let c of i)if(e.isModuleImport(c))for(let f of T.importedNames([c]))s(f,"import");let o=e.collectComputedNames(i);for(let c of e.collectReactiveNames(i))s(c,o.has(c)?"computed":"state");for(let c of e.collectEffectHandles(i))s(c,"effect");for(let c of e.collectReadonlyNames(i))s(c,"readonly");let l=(c,f)=>{if(!E(c))return;if(c[0]==="enum"&&typeof c[1]==="string")s(c[1],"enum");if(c[0]==="class"&&typeof c[1]==="string")s(c[1],"class");if(g1(c[0])&&c.length===4&&typeof c[1]==="string")s(c[1],"def");if((c[0]==="="||c[0]==="void-assign")&&typeof c[1]==="string")if(f)s(c[1],"plain");else a(c[1])};for(let c of i)if(l(c,!1),E(c)&&c[0]==="export"&&E(c[1]))l(c[1],!0);for(let[c,,f]of e.hoistTargets(i))if(f==="target")a(c);return[...n].map(([c,f])=>({name:c,kind:f}))},On={field:"field",computed:"computed",derived:"derived",method:"method"};function E3(e,t,r,i){let n=[],s=(l)=>l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");for(let l of t.story?.decl?.descriptor?.entries??[]){let c=l.tag==="union-member"?{name:l.name,start:l.start}:l.tag==="directive"&&l.name==="mixin"&&l.argTokens?.[0]?.kind==="IDENTIFIER"?{name:l.argTokens[0].value,start:l.argTokens[0].start}:null;if(c!==null&&typeof c.start==="number"){let h=new RegExp(`(= |\\| |& )(${s(c.name)})(?= \\||;| &)`).exec(r);if(h!==null)n.push({at:h.index+h[1].length,len:c.name.length,start:c.start,end:c.start+c.name.length});continue}if((On[l.tag]??null)===null||typeof l.start!=="number")continue;let f=new RegExp(`([{;] )((?:readonly )?)(${s(l.name)})(\\??: )`).exec(r);if(f===null)continue;if(n.push({at:f.index+f[1].length+f[2].length,len:l.name.length,start:l.start,end:l.start+l.name.length}),l.tag==="field"&&Array.isArray(l.typeSpan)&&e.b.source!==null){let h=/[A-Za-z_$][\w$]*/.exec(e.b.source.slice(l.typeSpan[0],l.typeSpan[1]));if(h!==null){let u=f.index+f[0].length,d=r.indexOf(";",u)<0?r.length:r.indexOf(";",u)+1,S=new RegExp(`(?u[1]))];for(let u of f){if(c.has(u))continue;let d=a[0]+1,S=-1;while(d>0){let g=l.lastIndexOf(u,d-1);if(g<0)break;if(!/[\w$]/.test(l[g-1]??" ")&&!/[\w$]/.test(l[g+u.length]??" ")){S=g;break}d=g}if(S>=0)c.set(u,[S,S+u.length])}let h=(u,d)=>n.some((S)=>ul.at-c.at);let o=0;for(let l of n){if(l.ate.b.emit(r.slice(l.at,l.at+l.len)));else e.b.emit(r.slice(l.at,l.at+l.len));o=l.at+l.len}e.b.emit(r.slice(o))}function k3(e,t,r,i){let n=t.story?.decl?.descriptor?.entries??null;if(n===null)return;let s=(a)=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");for(let a of n){let o=a.tag==="union-member"?{name:a.name,start:a.start}:a.tag==="directive"&&a.name==="mixin"&&a.argTokens?.[0]?.kind==="IDENTIFIER"?{name:a.argTokens[0].value,start:a.argTokens[0].start}:null;if(o===null||typeof o.start!=="number")continue;let l=new RegExp(`(= |\\| |& )(${s(o.name)})(?= \\||;| &)`).exec(r);if(l===null)continue;e.intrinsics.push({start:o.start,end:o.start+o.name.length,kind:"schema",label:null,name:o.name,gen:i+l.index+l[1].length})}for(let a of n){let o=On[a.tag]??null;if(o===null||typeof a.start!=="number")continue;let l=s(a.name),c=new RegExp(`([{;] )((?:readonly )?)(${l})(\\??: )`).exec(r);if(c===null)continue;let f=i+c.index+c[1].length+c[2].length;if(e.intrinsics.push({start:a.start,end:a.start+a.name.length,kind:"schema",label:o,name:a.name,gen:f,optional:c[4].startsWith("?")}),a.tag==="field"&&a.typeSpan!==null&&a.typeSpan!==void 0)e.intrinsics.push({start:a.typeSpan[0],end:a.typeSpan[1],kind:"schema",label:null,name:a.name,gen:f+c[3].length+c[4].length})}}function aa(e,{source:t="",runtimeDelivery:r="none",face:i="js",pins:n=null,strict:s=!1,script:a=!1,browserModule:o=!1,dataPayload:l=null,ambientBindings:c=null,repl:f=!1,hmr:h=!1,tolerant:u=!1,modulePath:d=null,appStashSpec:S=null,routesUnion:g=null,routeParams:p=null}={}){if(!e.sexpr)throw Error("emitter: cannot emit a failed parse");if(i!=="js"&&i!=="ts")throw Error(`emitter: unknown face '${i}' — expected 'js' (the shipping emission) or 'ts' (the editor face)`);let R=S3(c),b=new Qt(e.stores),_=new ge(b,{source:t,primitives:i==="ts"}),y=new T(b,_,{face:i,pins:n,strict:s,script:a,browserModule:o,repl:f,hmr:h,tolerant:u,modulePath:d,appStashSpec:S,routesUnion:g,routeParams:p});if(y.dataPayload=l,r!=="none"&&r!=="import"&&r!=="inline")throw Error(`emitter: unknown runtimeDelivery '${r}' — expected 'none', 'import', or 'inline'`);if(y.collectTsDirectives(e.sexpr,e.trivia??[],t),y.collectTypeOnlyImports(e.sexpr,t),y.collectAppAccessors(e.sexpr),y.tsNocheck!==null){let V=b.idOf(e.sexpr),j=y.tsNocheck;_.tsOnly(()=>{let q=()=>_.emit("//"+j.text.slice(1));if(V!==null)_.markSpan(V,"tsDirective",j.start,j.end,q);else q();_.emit(` `)})}let m=g3(y,e.sexpr),k=(V)=>{if(typeof V==="string")y.temps.used.add(V);else if(E(V))for(let j of V)k(j)};for(let{tree:V,atoms:j}of m)k(V),k(j);for(let{name:V}of R)y.temps.used.add(V);let O=b3(y,m);for(let{name:V}of R)O.add(V);let N=[...O];for(let V of ft)for(let j of V.generatedNames??[])y.runtimeAliases.set(j,T.mintName(j,O));let x=y3(y,e.sexpr),I=R3(y,e.sexpr,new Set(R.map(({name:V})=>V)));for(let{name:V}of R)x.add(V);let H=new Set;for(let V of ft){let j=new Set(V.names.filter((q)=>!x.has(q)));if(m.some(({tree:q,isDecl:t1,isTrigger:M,isComponent:A})=>V.triggers?.(q,{isTrigger:M,isComponent:A})||Ie(q,j,t1)))H.add(V.key)}for(let V=!0;V;){V=!1;for(let j of ft){if(!H.has(j.key))continue;for(let q of vn(j))if(!H.has(q))H.add(q),V=!0}}if(r!=="none"){let V=ft.filter((t1)=>H.has(t1.key)),j=[];if(r==="import")for(let t1 of V)j.push({runtimes:[t1],names:t1.names,imp:t1.url.pathname});else{let t1=new Set(V.flatMap((M)=>vn(M)));for(let M of V){if(t1.has(M.key))continue;let A=[],C=(D)=>{if(A.includes(D))return;for(let B of vn(D)){let a1=ft.find((h1)=>h1.key===B);if(a1)C(a1)}A.push(D)};if(C(M),A.length===1){j.push({runtimes:[M],names:M.names,body:Xs(M),types:M.types});continue}let w=A.some((D)=>D.types)?Object.assign({},...A.map((D)=>D.types)):void 0;j.push({runtimes:A,names:A.flatMap((D)=>D.names),body:A.map((D)=>Xs(D)).join(` @@ -335,7 +335,7 @@ ${w3(e,i)}`;return new Fe(o,{path:t,start:i,end:n,line:s+1,col:a+1})},_3=(e,t)=> `+c+"]"}if(o==="object"){let l=Object.getPrototypeOf(s);if(l!==Object.prototype&&l!==null)return null;let c=Object.keys(s);if(c.length===0)return"{}";let f=" ".repeat(a+1),h=" ".repeat(a),u=c.map((d)=>{let S=n(s[d],a+1);return S===null?null:i(d)+": "+S});if(u.some((d)=>d===null))return null;return`{ `+f+u.join(` `+f)+` -`+h+"}"}return null};return(s)=>{let a=n(s,0);if(a!==null)console.log(a);else console.dir(s,{depth:null,colors:!0});return s}})(),Ra=(e,t)=>{throw t!==void 0?new e(t):Error(e)},Ea=(e,t)=>t!==void 0?(e>t&&([e,t]=[t,e]),Math.floor(Math.random()*(t-e+1)+e)):e?Math.floor(Math.random()*e):Math.random(),ka=(e)=>new Promise((t)=>setTimeout(t,e)),Ta=(e)=>{throw Error(e||"Not implemented")},wa=(...e)=>console.warn(...e),_a=(...e)=>e[0].map((t,r)=>e.map((i)=>i[r])),Na=(e)=>{if(typeof e==="string")return e;if(e==null)return"";if(typeof e==="number"||typeof e==="bigint"||typeof e==="boolean")return String(e);if(typeof e==="symbol")return e.description||"";if(e instanceof Uint8Array||e instanceof ArrayBuffer)return new TextDecoder().decode(e instanceof Uint8Array?e:new Uint8Array(e));if(Array.isArray(e))return e.join(",");if(typeof e.toString==="function"&&e.toString!==Object.prototype.toString)try{return e.toString()}catch{return""}return""};var fr={};xe(fr,{SchemaDef:()=>gt,SchemaError:()=>v1,SchemaRegistry:()=>ee,__schema:()=>M3,installPersistence:()=>D3,registerCoercer:()=>C3});var $a=Symbol.for("rip.runtime.schema");if(globalThis[$a])throw Error("two copies of the Rip schema runtime loaded in one process — schemas from different copies "+"cannot see each other (separate registries, distinct SchemaError classes). Run .rip sources through the rip CLI/loader (one shared runtime module per process), or load only one standalone-compiled file per process.");globalThis[$a]=!0;var Se=null;function D3(e){if(Se&&Se!==e)throw Error("the Rip schema persistence runtime is already installed — two different copies met in one process");Se=e}class v1 extends Error{constructor(e,t,r){super(x3(e,t));this.name="SchemaError",this.issues=e,this.schemaName=t||null,this.schemaKind=r||null}}function x3(e,t){if(!e||!e.length)return"SchemaError";return(t?t+": ":"")+e.map((i)=>i.message||i.error||"invalid").join("; ")}var Da={__proto__:null,string:(e)=>typeof e==="string",number:(e)=>typeof e==="number"&&!Number.isNaN(e),integer:(e)=>Number.isInteger(e),boolean:(e)=>typeof e==="boolean",date:(e)=>e instanceof Date&&!Number.isNaN(e.getTime()),datetime:(e)=>e instanceof Date&&!Number.isNaN(e.getTime()),email:(e)=>typeof e==="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),url:(e)=>typeof e==="string"&&/^https?:\/\/.+/.test(e),uuid:(e)=>typeof e==="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e),phone:(e)=>typeof e==="string"&&/^[\d\s\-+()]+$/.test(e),zip:(e)=>typeof e==="string"&&/^\d{5}(-\d{4})?$/.test(e),text:(e)=>typeof e==="string",json:(e)=>e!==void 0,any:()=>!0},cr={integer(e){if(typeof e==="number")return Number.isInteger(e)?{ok:!0,value:e}:{ok:!1};if(typeof e==="string"&&/^[+-]?\d+$/.test(e.trim()))return{ok:!0,value:parseInt(e.trim(),10)};return{ok:!1}},number(e){if(typeof e==="number")return Number.isNaN(e)?{ok:!1}:{ok:!0,value:e};if(typeof e==="string"&&/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/.test(e.trim()))return{ok:!0,value:Number(e.trim())};return{ok:!1}},boolean(e){if(typeof e==="boolean")return{ok:!0,value:e};if(e==="true"||e==="1"||e===1)return{ok:!0,value:!0};if(e==="false"||e==="0"||e===0)return{ok:!0,value:!1};return{ok:!1}},date(e){if(e instanceof Date)return Number.isNaN(e.getTime())?{ok:!1}:{ok:!0,value:e};if(typeof e==="number"&&Number.isFinite(e))return{ok:!0,value:new Date(e)};let t=typeof e==="string"?/^(\d{4})-(\d{2})-(\d{2})/.exec(e):null;if(t){let r=+t[2],i=+t[3],n=new Date(Date.UTC(+t[1],r,0)).getUTCDate();if(r<1||r>12||i<1||i>n)return{ok:!1};let s=new Date(e);if(!Number.isNaN(s.getTime()))return{ok:!0,value:s}}return{ok:!1}}};cr.datetime=cr.date;function ar(e){if(e!==null&&typeof e==="object"&&!Array.isArray(e))return null;return{field:"",error:"object",message:"input must be an object; got "+(e===null?"null":Array.isArray(e)?"an array":"a "+typeof e)}}var Dn=new Map;function C3(e,t,r){if(typeof e!=="string"||typeof t!=="function")throw Error("registerCoercer(name, fn, opts?): name string and fn required");let i=Object.prototype.toString.call(t);if(i==="[object AsyncFunction]"||i==="[object GeneratorFunction]"||i==="[object AsyncGeneratorFunction]")throw Error("registerCoercer: coercer '~:"+e+"' must be a plain synchronous function");let n=r?.raw===!0,s=Dn.get(e);if(s){if(s.raw===n&&String(s.fn)===String(t))return t;throw Error("registerCoercer: coercer '~:"+e+"' is already registered")}return Dn.set(e,{fn:t,raw:n}),t}function mt(e){if(Da[e])return null;let t=ee.get(e);return t&&(t.kind==="shape"||t.kind==="input"||t.kind==="model"||t.kind==="union")?t:null}function xn(e,t,r){let i=Da[t];if(i)return i(e)?{value:e}:{errors:[{field:"",error:"type",message:"must be "+t}]};let n=ee.get(t);if(!n)return{value:e};if(n.kind==="enum"){let a=n._validateEnum(e,!0);return a.length?{errors:[{field:"",error:"enum",message:a[0].message}]}:{value:n._materializeEnum(e)}}if(n.kind==="mixin")return{errors:[{field:"",error:"type",message:":mixin "+t+" is not usable as a field type"}]};if(n.kind==="union"){let a=n._unionResolve(e);if(a.issue)return{errors:[a.issue]};let o=r?.existing?a.def._runExistingSync(e,{...r,materialize:!1,materializeNested:!1}):a.def._runSync(e,{...r,materialize:!1,materializeNested:!1});if(o.thrown){if(r?.derived==="throw")throw o.thrown;return{errors:[{field:"",error:"derived",message:o.thrown?.message||String(o.thrown)}]}}return o.ok?{value:o.value}:{errors:o.errors}}if(e===null||typeof e!=="object"||Array.isArray(e))return{errors:[{field:"",error:"type",message:"must be a "+t+" object"}]};let s=r?.existing?n._runExistingSync(e,{...r,materialize:!1,materializeNested:!1}):n._runSync(e,{...r,materialize:!1,materializeNested:!1});if(s.thrown){if(r?.derived==="throw")throw s.thrown;return{errors:[{field:"",error:"derived",message:s.thrown?.message||String(s.thrown)}]}}return s.ok?{value:s.value}:{errors:s.errors}}async function Aa(e,t,r){let i=mt(t);if(i===null)return xn(e,t,r);if(i.kind==="union"){let s=i._unionResolve(e);if(s.issue)return{errors:[s.issue]};let a=r?.existing?await s.def._runExistingAsync(e,{...r,materialize:!1,materializeNested:!1}):await s.def._runAsync(e,{...r,materialize:!1,materializeNested:!1});if(a.thrown){if(r?.derived==="throw")throw a.thrown;return{errors:[{field:"",error:"derived",message:a.thrown?.message||String(a.thrown)}]}}return a.ok?{value:a.value}:{errors:a.errors}}if(e===null||typeof e!=="object"||Array.isArray(e))return{errors:[{field:"",error:"type",message:"must be a "+t+" object"}]};let n=r?.existing?await i._runExistingAsync(e,{...r,materialize:!1,materializeNested:!1}):await i._runAsync(e,{...r,materialize:!1,materializeNested:!1});if(n.thrown){if(r?.derived==="throw")throw n.thrown;return{errors:[{field:"",error:"derived",message:n.thrown?.message||String(n.thrown)}]}}return n.ok?{value:n.value}:{errors:n.errors}}function pt(e,t){if(!t)return e;return e+(t.startsWith("[")?t:"."+t)}function or(e,t,r){if(!t)return e+" "+r;if(r.startsWith(t))return e+r.slice(t.length);return e+": "+r}var lr=Symbol("schema.materialization-error");function va(e,t){if(e&&e[lr])return{[lr]:!0,error:e.error,field:pt(t,e.field)};return{[lr]:!0,error:e,field:t}}function Be(e){return e&&e[lr]?{thrown:e.error,derivedField:e.field}:{thrown:e,derivedField:""}}var P3=Je;function Oa(e){let t=(i)=>JSON.stringify(i??null,(n,s)=>s instanceof RegExp?String(s):typeof s==="function"?"":s),r=[e.kind];for(let i of e._desc.entries||[])switch(i.tag){case"field":r.push("f:"+i.name+":"+(i.typeName||"")+(i.array?"[]":"")+":"+(i.modifiers||[]).join("")+(i.literals?":"+i.literals.join(","):"")+":"+t(i.constraints)+(i.coerce?":~"+(i.coercer||""):"")+(i.transform?":t":""));break;case"enum-member":r.push("e:"+i.name+"="+String(i.value));break;case"directive":r.push("d:"+i.name+":"+t(i.args));break;case"ensure":r.push("n:"+(i.message||""));break;default:r.push(i.tag+":"+(i.name||""))}return r.join("|")}var ye=0,ee={_entries:new Map,replace:!1,register(e){if(!e.name)return;ye++;let t=this._entries.get(e.name);if(t&&t.def!==e&&!this.replace){if(Oa(t.def)!==Oa(e))throw new v1([{field:e.name,error:"collision",message:"schema name '"+e.name+"' is already registered with a different definition. Schema names are app-global (they resolve nested field types and @mixin references), so two "+"different schemas cannot share one name. Rename one — or, for dev/HMR reload semantics, set "+"SchemaRegistry.replace = true before re-evaluating modules."}],e.name,e.kind)}this._entries.set(e.name,{def:e,kind:e.kind})},get(e){let t=this._entries.get(e);return t?t.def:null},getKind(e,t){let r=this._entries.get(e);return r&&r.kind===t?r.def:null},has(e){return this._entries.has(e)},names(){return[...this._entries.keys()]},reset(){this._entries.clear(),ye++},scope(e){let t=this._entries;this._entries=new Map,ye++;let r=()=>{this._entries=t,ye++};try{let i=e();if(i&&typeof i.then==="function")return i.finally(r);return r(),i}catch(i){throw r(),i}}};class gt{constructor(e){if(e.kind==="model"&&!Se)throw Error("schema: kind 'model' needs the persistence runtime (src/runtime/orm.js), which is not "+"loaded in this process — reference a persistence name (schema.transaction, __schemaSetAdapter) "+"or import the module directly");if(this._desc=e,this.kind=e.kind,this.name=e.name||null,this._norm=null,this._klass=null,this._unionPlanCache=null,this._sourceModel=null,e.kind==="model")Se.decorateDef(this,e)}_normalize(){if(this._norm)return this._norm;let e=new Map,t=new Map,r=new Map,i=new Map,n=new Map,s=new Map,a=null,o=[],l=new Map,c=[],f=(b,_)=>{throw new v1([{field:b,error:"collision",message:b+" collides with "+_}],this.name,this.kind)},h=(b)=>{if(e.has(b))f(b,"field");if(t.has(b))f(b,"method");if(r.has(b))f(b,"computed");if(i.has(b))f(b,"derived");if(n.has(b))f(b,"hook")},u=(b)=>{throw new v1([{field:"",error:"kind",message:b+" is :model-only (this schema is :"+this.kind+")"}],this.name,this.kind)},d=this.kind==="union"?new Set(["on"]):new Set(["mixin"]),S=(b,_)=>{if(!P3(b))throw new v1([{field:b,error:"invalid-name",message:_+" name '"+b+"' is not canonical camelCase. Use a lowercase-first, alphanumeric identifier with no consecutive uppercase letters (e.g. 'mdmId' not 'mdmID')."}],this.name,this.kind)};for(let b of this._desc.entries)switch(b.tag){case"field":S(b.name,"field"),h(b.name),e.set(b.name,{name:b.name,required:b.modifiers.includes("!"),optional:b.modifiers.includes("?"),unique:b.unique===!0,primary:b.primary===!0,attrs:b.attrs||null,typeName:b.typeName,literals:b.literals||null,array:b.array===!0,coerce:b.coerce===!0,coercer:b.coercer||null,constraints:b.constraints||null,transform:b.transform||null});break;case"method":h(b.name),t.set(b.name,b.fn);break;case"computed":h(b.name),r.set(b.name,b.fn);break;case"derived":h(b.name),i.set(b.name,b.fn);break;case"hook":if(this.kind!=="model")u("lifecycle hook '"+b.name+"'");if(n.has(b.name))f(b.name,"duplicate hook");n.set(b.name,b.fn);break;case"scope":if(this.kind!=="model")u("query scope '@scope :"+b.name+"'");if(s.has(b.name))f(b.name,"scope");s.set(b.name,b.fn);break;case"defaultScope":if(this.kind!=="model")u("@defaultScope");if(a)throw new v1([{field:"",error:"collision",message:"only one @defaultScope per model"}],this.name,this.kind);a=b.fn;break;case"directive":if(this.kind!=="model"&&!d.has(b.name))throw new v1([{field:"",error:"directive",message:"unknown directive '@"+b.name+"' on :"+this.kind+" — legal here: "+[...d].map((_)=>"@"+_).join(", ")}],this.name,this.kind);o.push({name:b.name,args:b.args||[]});break;case"enum-member":l.set(b.name,b.value!==void 0?b.value:b.name);break;case"union-member":break;case"ensure":c.push({message:b.message,field:b.field||"",async:b.async===!0,fn:b.fn});break;default:throw new v1([{field:"",error:"entry",message:"unknown schema entry tag '"+b.tag+"'"}],this.name,this.kind)}if(this.kind==="shape"||this.kind==="input"||this.kind==="mixin"||this.kind==="model")Pa(this,e,o,{stack:[this.name||""],seen:new Set([this.name||""])});let g=null,p=[];if(this.kind==="union"){for(let b of o)if(b.name==="on"&&b.args?.[0]?.field)g=b.args[0].field;for(let b of this._desc.entries)if(b.tag==="union-member")p.push(b.name)}let R={fields:e,methods:t,computed:r,derived:i,hooks:n,scopes:s,defaultScope:a,directives:o,enumMembers:l,ensures:c,hasAsyncEnsures:c.some((b)=>b.async),unionOn:g,unionMembers:p};if(this.kind==="model")Se.finishModelNorm(this,R);return this._norm=R,this._norm}_unionPlan(){if(this._unionPlanCache&&this._unionPlanCache.gen===ye)return this._unionPlanCache.plan;let e=this._normalize(),t=e.unionOn;if(this.kind!=="union"||!t)throw Error("schema: '"+(this.name||"anon")+"' is not a :union");let r=new Map,i=[];for(let s of e.unionMembers){let a=ee.get(s);if(!a)throw new v1([{field:"",error:"union",message:"unknown union constituent: "+s+" (import the file that declares it)"}],this.name,this.kind);i.push(a);let o=a._normalize().fields.get(t);if(!o||o.typeName!=="literal-union"||!o.literals?.length)throw new v1([{field:t,error:"union",message:s+" must declare '"+t+"' as a string-literal type (e.g. "+t+'! "click") to join union '+(this.name||"")}],this.name,this.kind);for(let l of o.literals){if(r.has(l))throw new v1([{field:t,error:"union",message:"duplicate discriminator value "+JSON.stringify(l)+" in "+(r.get(l).name||"anon")+" and "+s}],this.name,this.kind);r.set(l,a)}}let n={disc:t,map:r,expected:[...r.keys()].join(" | "),hasAsyncEnsures:i.some((s)=>s._normalize().hasAsyncEnsures)};return this._unionPlanCache={gen:ye,plan:n},n}_unionResolve(e){let t=this._unionPlan();if(e===null||typeof e!=="object"||Array.isArray(e))return{issue:{field:t.disc,error:"union",message:"expected an object with "+t.disc}};let r=t.map.get(e[t.disc]);if(!r)return{issue:{field:t.disc,error:"union",message:"expected one of "+t.expected}};return{def:r}}_applyEagerDerived(e){let t=this._normalize();if(!t.derived.size)return;for(let[r,i]of t.derived){let n=i.call(e);Object.defineProperty(e,r,{value:n,enumerable:!0,writable:!0,configurable:!0})}}_materializeValidatedValue(e,t,r){return this._materializeNestedValues(e,t,r),this._materializeOwnValidatedValue(e,t,r)}_materializeNestedValues(e,t,r){let i=this._normalize();for(let[n,s]of i.fields){let a=mt(s.typeName);if(!a)continue;let o=e[n];if(o===void 0||o===null)continue;let l=t==null?void 0:t[n];if(s.array){if(!Array.isArray(o))continue;let c=Array(o.length);for(let f=0;f{let a=()=>({field:n.field||"",error:"ensure",message:n.message||"ensure failed"});if(n.async)i.push((async()=>{let o=!1;try{o=!!await n.fn(e)}catch{o=!1}if(!o)r.push({idx:s,issue:a()})})());else{let o=!1;try{o=!!n.fn(e)}catch{o=!1}if(!o)r.push({idx:s,issue:a()})}}),await Promise.all(i),r.sort((n,s)=>n.idx-s.idx),r.map((n)=>n.issue)}_transitiveAsync(){if(this._taGen===ye)return this._taCache;let e=new Set,t=(r)=>{if(e.has(r))return!1;e.add(r);let i=r._normalize();if(i.hasAsyncEnsures)return!0;if(r.kind==="union"){for(let n of i.unionMembers){let s=ee.get(n);if(s&&t(s))return!0}return!1}for(let n of i.fields.values()){let s=mt(n.typeName);if(s&&t(s))return!0}return!1};return this._taCache=t(this),this._taGen=ye,this._taCache}_assertSyncValidatable(e){if(!this._transitiveAsync())return;let t=this.kind!=="union"&&this._normalize().hasAsyncEnsures;throw Error("schema '"+(this.name||"anon")+"' has async refinements (@ensure!"+(t?"":" in a nested or constituent schema")+"); ."+e+"() is sync. Use parseAsync/safeAsync/okAsync instead.")}_getClass(){if(this._klass)return this._klass;let e=this._normalize(),t=this.name||"Schema",r=[...e.fields.keys()],i={[t]:class{constructor(n){if(n&&typeof n==="object"){for(let s of r)if(s in n&&n[s]!==void 0)this[s]=n[s]}}}}[t];for(let[n,s]of e.methods)Object.defineProperty(i.prototype,n,{value:s,writable:!0,enumerable:!1,configurable:!0});for(let[n,s]of e.computed)Object.defineProperty(i.prototype,n,{get:s,enumerable:!1,configurable:!0});return this._klass=i,i}_coerceDates(e){let t=this._normalize(),r=(s)=>typeof s==="string"&&/^\d{4}-\d{2}-\d{2}([T ].*)?$/.test(s),i=(s)=>{let a=/^(\d{4})-(\d{2})-(\d{2})/.exec(s),o=+a[2],l=+a[3];return o>=1&&o<=12&&l>=1&&l<=new Date(Date.UTC(+a[1],o,0)).getUTCDate()},n=(s)=>{if(!i(s))return s;let a=new Date(s);return Number.isNaN(a.getTime())?s:a};for(let[s,a]of t.fields){if(a.typeName!=="date"&&a.typeName!=="datetime")continue;let o=e[s];if(a.array&&Array.isArray(o))e[s]=o.map((l)=>r(l)?n(l):l);else if(r(o))e[s]=n(o)}}_validateFields(e,t,r,i){let n=this._normalize(),s=t?[]:null;for(let[a,o]of n.fields){if(r&&r.has(a))continue;let l=e==null?void 0:e[a];if(l===void 0||l===null){if(o.required){if(!t)return!1;s.push({field:a,error:"required",message:a+" is required"})}continue}if(o.array){if(!Array.isArray(l)){if(!t)return!1;s.push({field:a,error:"type",message:a+" must be an array"});continue}let f=o.constraints;if(f){if(f.min!=null&&l.lengthf.max){if(!t)return!1;s.push({field:a,error:"max",message:a+" must have at most "+f.max+" items"})}}if(i?.deferNested&&mt(o.typeName))continue;let h=!1,u=!1,d=Array(l.length);for(let S=0;SJSON.stringify(f)).join(", ")});continue}}else{if(i?.deferNested&&mt(o.typeName))continue;let f=xn(l,o.typeName,i);if(f.errors){if(!t)return!1;for(let h of f.errors){let u=pt(a,h.field);s.push({field:u,error:h.error,message:or(u,h.field,h.message)})}continue}if(f.value!==l)e[a]=f.value}let c=o.constraints;if(c){if(typeof l==="string"){if(c.min!=null&&l.lengthc.max){if(!t)return!1;s.push({field:a,error:"max",message:a+" must be at most "+c.max+" chars"})}if(c.regex){if(c.regex.global||c.regex.sticky)c.regex.lastIndex=0;if(!c.regex.test(l)){if(!t)return!1;s.push({field:a,error:"pattern",message:a+" is invalid"})}}}else if(typeof l==="number"){if(c.min!=null&&l= "+c.min})}if(c.max!=null&&l>c.max){if(!t)return!1;s.push({field:a,error:"max",message:a+" must be <= "+c.max})}}}}return t?s:!0}_applyDefaults(e){let t=this._normalize();for(let[r,i]of t.fields)if((e[r]===void 0||e[r]===null)&&i.constraints?.default!==void 0){let n=i.constraints.default;e[r]=typeof n==="object"&&n!==null&&!(n instanceof RegExp)?structuredClone(n):n}return e}_applyTransforms(e,t){let r=this._normalize(),i=[];for(let[n,s]of r.fields){if(!s.transform)continue;try{t[n]=s.transform(e)}catch(a){i.push({field:n,error:"transform",message:a?.message||String(a)})}}return i}_applyCoercions(e,t){let r=this._normalize(),i=[];for(let[n,s]of r.fields){if(!s.coerce)continue;let a=e[n];if(a===void 0||a===null)continue;if(s.coercer){let l=Dn.get(s.coercer);if(!l)throw Error("schema: no coercer registered for '~:"+s.coercer+"' (field '"+n+"' on "+(this.name||"anon")+"). Register it with registerCoercer('"+s.coercer+"', fn).");let c=l.raw?a:String(a).trim(),f;try{f=l.fn(c)}catch{f=null}if(f===null||f===void 0)i.push({field:n,error:"coerce",message:n+" is not a valid "+s.coercer}),t.add(n);else e[n]=f;continue}let o=cr[s.typeName]?cr[s.typeName](a):{ok:!1};if(o.ok)e[n]=o.value;else i.push({field:n,error:"coerce",message:n+" cannot be coerced to "+s.typeName}),t.add(n)}return i}_orderFieldErrors(...e){let t=new Map,r=0;for(let[i]of this._normalize().fields)t.set(i,r++);return e.flat().map((i,n)=>{let s=String(i.field||"").split(/[.[]/,1)[0];return{issue:i,seq:n,rank:t.has(s)?t.get(s):r}}).sort((i,n)=>i.rank-n.rank||i.seq-n.seq).map((i)=>i.issue)}_validateEnum(e,t){let r=this._normalize();for(let[n,s]of r.enumMembers)if(e===n||e===s)return t?[]:!0;if(!t)return!1;let i=[...r.enumMembers.keys()].join(", ");return[{field:"",error:"enum",message:(this.name||"enum")+" expected one of: "+i}]}_materializeEnum(e){let t=this._normalize();for(let[r,i]of t.enumMembers)if(e===r||e===i)return i;return e}_runSync(e,t){if(this.kind==="union"){let f=this._unionResolve(e);if(f.issue)return{ok:!1,errors:[f.issue]};let h=f.def._runSync(e,t);return h.ok?h:{...h,from:h.from||f.def}}if(this.kind==="enum"){let f=this._validateEnum(e,!0);return f.length?{ok:!1,errors:f}:{ok:!0,value:this._materializeEnum(e)}}let r=ar(e);if(r)return{ok:!1,errors:[r]};let i=e,n={...i},s=new Set,a=this._applyTransforms(i,n),o=this._applyCoercions(n,s);this._applyDefaults(n),this._coerceDates(n);let l=this._orderFieldErrors(a,o,this._validateFields(n,!0,s,t));if(l.length)return{ok:!1,errors:l};let c=t?.skipEnsures?[]:this._applyEnsures(n);if(c.length)return{ok:!1,errors:c};if(t?.materializeNested)try{this._materializeNestedValues(n,null,!1)}catch(f){return{ok:!1,errors:null,...Be(f)}}if(!t?.materialize)return{ok:!0,value:n};try{return{ok:!0,value:this._materializeOwnValidatedValue(n,null,!1)}}catch(f){return{ok:!1,errors:null,...Be(f)}}}async _runAsync(e,t){if(this.kind==="union"){let h=this._unionResolve(e);if(h.issue)return{ok:!1,errors:[h.issue]};let u=await h.def._runAsync(e,t);return u.ok?u:{...u,from:u.from||h.def}}if(this.kind==="enum")return this._runSync(e,t);let r=ar(e);if(r)return{ok:!1,errors:[r]};let i=e,n={...i},s=new Set,a=this._applyTransforms(i,n),o=this._applyCoercions(n,s);this._applyDefaults(n),this._coerceDates(n);let l=await this._validateFieldsAsync(n,s,t),c=this._orderFieldErrors(a,o,l);if(c.length)return{ok:!1,errors:c};let f=t?.skipEnsures?[]:await this._applyEnsuresAsync(n);if(f.length)return{ok:!1,errors:f};if(t?.materializeNested)try{this._materializeNestedValues(n,null,!1)}catch(h){return{ok:!1,errors:null,...Be(h)}}if(!t?.materialize)return{ok:!0,value:n};try{return{ok:!0,value:this._materializeOwnValidatedValue(n,null,!1)}}catch(h){return{ok:!1,errors:null,...Be(h)}}}async _validateFieldsAsync(e,t,r){let i=this._normalize(),n=[];for(let[s,a]of i.fields){if(t&&t.has(s))continue;let o=e[s];if(o===void 0||o===null){if(a.required)n.push({field:s,error:"required",message:s+" is required"});continue}if(a.array){if(!Array.isArray(o)){n.push({field:s,error:"type",message:s+" must be an array"});continue}let f=a.constraints;if(f?.min!=null&&o.lengthf.max)n.push({field:s,error:"max",message:s+" must have at most "+f.max+" items"});let h=Array(o.length),u=!1;for(let d=0;dJSON.stringify(f)).join(", ")})}else{let f=await Aa(o,a.typeName,r);if(f.errors)for(let h of f.errors){let u=pt(s,h.field);n.push({field:u,error:h.error,message:or(u,h.field,h.message)})}else e[s]=f.value}let l=e[s],c=a.constraints;if(c){if(typeof l==="string"){if(c.min!=null&&l.lengthc.max)n.push({field:s,error:"max",message:s+" must be at most "+c.max+" chars"});if(c.regex){if(c.regex.global||c.regex.sticky)c.regex.lastIndex=0;if(!c.regex.test(l))n.push({field:s,error:"pattern",message:s+" is invalid"})}}else if(typeof l==="number"){if(c.min!=null&&l= "+c.min});if(c.max!=null&&l>c.max)n.push({field:s,error:"max",message:s+" must be <= "+c.max})}}}return n}_runExistingSync(e,t){if(this.kind==="union"){let a=this._unionResolve(e);if(a.issue)return{ok:!1,errors:[a.issue]};let o=a.def._runExistingSync(e,t);return o.ok?o:{...o,from:o.from||a.def}}if(this.kind==="enum")return this._runSync(e,t);let r=ar(e);if(r)return{ok:!1,errors:[r]};let i={...e},n=this._validateFields(i,!0,null,{...t,existing:!0});if(n.length)return{ok:!1,errors:n};let s=t?.skipEnsures?[]:this._applyEnsures(i);if(s.length)return{ok:!1,errors:s};if(t?.materializeNested)try{this._materializeNestedValues(i,e,!0)}catch(a){return{ok:!1,errors:null,...Be(a)}}return this._finishExistingValue(e,i,t)}async _runExistingAsync(e,t){if(this.kind==="union"){let a=this._unionResolve(e);if(a.issue)return{ok:!1,errors:[a.issue]};let o=await a.def._runExistingAsync(e,t);return o.ok?o:{...o,from:o.from||a.def}}if(this.kind==="enum")return this._runSync(e,t);let r=ar(e);if(r)return{ok:!1,errors:[r]};let i={...e},n=await this._validateFieldsAsync(i,null,{...t,existing:!0});if(n.length)return{ok:!1,errors:n};let s=t?.skipEnsures?[]:await this._applyEnsuresAsync(i);if(s.length)return{ok:!1,errors:s};if(t?.materializeNested)try{this._materializeNestedValues(i,e,!0)}catch(a){return{ok:!1,errors:null,...Be(a)}}return this._finishExistingValue(e,i,t)}_finishExistingValue(e,t,r){if(!r?.materialize)return{ok:!0,value:t};let i=this._getClass(),n=!0;for(let[a]of this._normalize().fields)if(t[a]!==e[a]){n=!1;break}if(n)return{ok:!0,value:e};let s=new i(t);try{this._applyEagerDerived(s)}catch(a){return{ok:!1,errors:null,thrown:a}}return{ok:!0,value:s}}parse(e){if(this.kind==="mixin")throw Error(":mixin schema '"+(this.name||"anon")+"' is not instantiable");this._assertSyncValidatable("parse");let t=this._runSync(e,{materialize:!0,materializeNested:!0,derived:"throw"});if(t.ok)return t.value;if(t.thrown)throw t.thrown;let r=t.from||this;throw new v1(t.errors,r.name,r.kind)}get array(){let e=this,t=(s)=>({field:"",error:"not_array",message:"expected an array, received "+(s===null?"null":s===void 0?"undefined":typeof s==="object"?"an object with keys ["+Object.keys(s).join(", ")+"]":typeof s)}),r=(s)=>{let a=[],o=[];return s.forEach((l,c)=>{if(l.ok)a.push(l.value);else for(let f of l.errors)o.push({...f,field:"["+c+"]"+(f.field?"."+f.field:"")})}),{value:a,errors:o}},i=(s)=>{let a=[],o=[];return s.forEach((l,c)=>{try{a.push(e.parse(l))}catch(f){if(!(f instanceof v1))throw f;for(let h of f.issues)o.push({...h,field:"["+c+"]"+(h.field?"."+h.field:"")})}}),{value:a,errors:o}},n=async(s)=>{let a=[],o=[];for(let l=0;le.safe(l)));return o.length?{ok:!1,value:null,errors:o}:{ok:!0,value:a,errors:null}},ok(s){return Array.isArray(s)&&s.every((a)=>e.ok(a))},async parseAsync(s){if(!Array.isArray(s))throw new v1([t(s)],e.name,e.kind);let{value:a,errors:o}=await n(s);if(o.length)throw new v1(o,e.name,e.kind);return a},async safeAsync(s){if(!Array.isArray(s))return{ok:!1,value:null,errors:[t(s)]};let{value:a,errors:o}=r(await Promise.all(s.map((l)=>e.safeAsync(l))));return o.length?{ok:!1,value:null,errors:o}:{ok:!0,value:a,errors:null}},async okAsync(s){return Array.isArray(s)&&(await Promise.all(s.map((a)=>e.okAsync(a)))).every(Boolean)},toJSONSchema(){return{type:"array",items:e.toJSONSchema()}}}}safe(e){if(this.kind==="mixin")return{ok:!1,value:null,errors:[{field:"",error:"mixin",message:"not instantiable"}]};this._assertSyncValidatable("safe");let t=this._runSync(e,{materialize:!0,materializeNested:!0,derived:"issue"});if(t.ok)return{ok:!0,value:t.value,errors:null};if(t.thrown)return{ok:!1,value:null,errors:[{field:t.derivedField||"",error:"derived",message:t.thrown?.message||String(t.thrown)}]};return{ok:!1,value:null,errors:t.errors}}ok(e){if(this.kind==="mixin")return!1;return this._assertSyncValidatable("ok"),this._runSync(e,{materialize:!1,materializeNested:!1,derived:"issue"}).ok}async parseAsync(e){if(this.kind==="mixin")throw Error(":mixin schema '"+(this.name||"anon")+"' is not instantiable");let t=await this._runAsync(e,{materialize:!0,materializeNested:!0,derived:"throw"});if(t.ok)return t.value;if(t.thrown)throw t.thrown;let r=t.from||this;throw new v1(t.errors,r.name,r.kind)}async safeAsync(e){if(this.kind==="mixin")return{ok:!1,value:null,errors:[{field:"",error:"mixin",message:"not instantiable"}]};let t=await this._runAsync(e,{materialize:!0,materializeNested:!0,derived:"issue"});if(t.ok)return{ok:!0,value:t.value,errors:null};if(t.thrown)return{ok:!1,value:null,errors:[{field:t.derivedField||"",error:"derived",message:t.thrown?.message||String(t.thrown)}]};return{ok:!1,value:null,errors:t.errors}}async okAsync(e){if(this.kind==="mixin")return!1;return(await this._runAsync(e,{materialize:!1,materializeNested:!1,derived:"issue"})).ok}pick(...e){return dt(this,(t)=>{let r=$n(e),i=new Map;for(let n of r){if(!t.has(n))throw Error("pick: unknown field '"+n+"' on "+(this.name||"schema"));i.set(n,t.get(n))}return i})}omit(...e){return dt(this,(t)=>{let r=new Set($n(e)),i=new Map;for(let[n,s]of t)if(!r.has(n))i.set(n,s);return i})}partial(){return dt(this,(e)=>{let t=new Map;for(let[r,i]of e)t.set(r,{...i,required:!1});return t})}required(...e){return dt(this,(t)=>{let r=new Set($n(e)),i=new Map;for(let[n,s]of t)i.set(n,{...s,required:r.has(n)?!0:s.required});return i})}extend(e){if(!(e instanceof gt))throw Error("extend(): argument must be a schema value");if(e.kind==="union")throw Error("extend(): :union schemas have no fields to merge");return dt(this,(t)=>{let r=new Map(t),i=e._normalize().fields;for(let[n,s]of i){if(r.has(n))throw Error("extend(): field '"+n+"' collides between "+(this.name||"schema")+" and "+(e.name||"other"));r.set(n,s)}return r})}toJSONSchema(){let e={defs:new Map,expanding:new Set},t=Ca(this,e);if(t.$schema="https://json-schema.org/draft/2020-12/schema",this.name)t.title=this.name;if(e.defs.size){t.$defs={};for(let[r,i]of e.defs)t.$defs[r]=i}return t}}var Ia={__proto__:null,string:()=>({type:"string"}),text:()=>({type:"string"}),email:()=>({type:"string",format:"email"}),url:()=>({type:"string",format:"uri"}),uuid:()=>({type:"string",format:"uuid"}),phone:()=>({type:"string",pattern:"^[\\d\\s\\-+()]+$"}),zip:()=>({type:"string",pattern:"^\\d{5}(-\\d{4})?$"}),number:()=>({type:"number"}),integer:()=>({type:"integer"}),boolean:()=>({type:"boolean"}),date:()=>({type:"string",format:"date"}),datetime:()=>({type:"string",format:"date-time"}),json:()=>({}),any:()=>({})};function L3(e,t){let r;if(e.typeName==="literal-union"&&e.literals?.length)r=e.literals.length===1?{const:e.literals[0]}:{enum:[...e.literals]};else if(Ia[e.typeName])r=Ia[e.typeName]();else{let n=ee.get(e.typeName);r=n?xa(n,t):{}}let i=e.constraints;if(i&&!e.array){if(r.type==="string"){if(i.min!=null)r.minLength=i.min;if(i.max!=null)r.maxLength=i.max;if(i.regex)r.pattern=i.regex.source}else if(r.type==="number"||r.type==="integer"){if(i.min!=null)r.minimum=i.min;if(i.max!=null)r.maximum=i.max}}if(e.array){if(r={type:"array",items:r},i){if(i.min!=null)r.minItems=i.min;if(i.max!=null)r.maxItems=i.max}}if(i&&i.default!==void 0)r.default=i.default;if(e.coerce)r.description=((r.description?r.description+" ":"")+"Coerced from wire data ("+(e.coercer?"~:"+e.coercer:"~"+e.typeName)+").").trim();if(e.transform)r.description=((r.description?r.description+" ":"")+"Derived via transform; the raw input may use different keys.").trim();return r}function xa(e,t){let r=e.name||"Anon";if(!t.defs.has(r)&&!t.expanding.has(r))t.expanding.add(r),t.defs.set(r,null),t.defs.set(r,Ca(e,t)),t.expanding.delete(r);return{$ref:"#/$defs/"+r}}function Ca(e,t){let r=e._normalize();if(e.kind==="enum")return{enum:[...new Set(r.enumMembers.values())]};if(e.kind==="union"){let a=e._unionPlan();return{oneOf:r.unionMembers.map((l)=>{let c=ee.get(l);return c?xa(c,t):{}}),discriminator:{propertyName:a.disc}}}let i={},n=[];for(let[a,o]of r.fields)if(i[a]=L3(o,t),o.required&&o.constraints?.default===void 0)n.push(a);if(e.kind==="model")Se.jsonSchemaModelColumns(e,i);let s={type:"object",properties:i};if(n.length)s.required=n;if(r.ensures.length)s.description="Refinements (not expressible in JSON Schema): "+r.ensures.map((a)=>a.message).join("; ")+".";return s}function $n(e){let t=[];for(let r of e)if(Array.isArray(r))for(let i of r)t.push(i);else t.push(r);return t}function dt(e,t){if(e.kind==="union")throw Error("schema algebra (.pick/.omit/.partial/.required/.extend) is not supported on :union — derive from a constituent schema instead");if(e.kind==="enum")throw Error("schema algebra is not supported on :enum — an enum has no field set");let r=e.kind==="model"?Se.projectableFields(e):e._normalize().fields,i=t(r),n=[];for(let[,o]of i){let l=[];if(o.required)l.push("!");if(o.optional&&!o.required)l.push("?");n.push({tag:"field",name:o.name,modifiers:l,unique:o.unique===!0,primary:o.primary===!0,attrs:o.attrs||null,typeName:o.typeName,array:o.array,literals:o.literals||null,coerce:o.coerce===!0,coercer:o.coercer||null,constraints:o.constraints,transform:o.transform||null})}let s=(e.name||"Schema")+"Derived",a=new gt({kind:"shape",name:s,entries:n});return a._sourceModel=e._sourceModel||(e.kind==="model"?e:null),a}function Pa(e,t,r,i){for(let n of r){if(n.name!=="mixin"||!n.args||!n.args[0])continue;let s=n.args[0].target;if(!s)continue;if(i.stack.includes(s))throw new v1([{field:"",error:"mixin-cycle",message:"mixin cycle: "+i.stack.concat(s).join(" -> ")}],e.name,e.kind);if(i.seen.has(s))continue;let a=ee.getKind(s,"mixin");if(!a)throw new v1([{field:"",error:"mixin-missing",message:"unknown mixin: "+s}],e.name,e.kind);i.seen.add(s),i.stack.push(s);let o=a._desc.entries.filter((l)=>l.tag==="directive"&&l.name==="mixin").map((l)=>({name:l.name,args:l.args||[]}));Pa(e,t,o,i);for(let l of a._desc.entries){if(l.tag!=="field")continue;if(t.has(l.name))throw new v1([{field:l.name,error:"mixin-collision",message:l.name+" from mixin "+s+" collides with existing field"}],e.name,e.kind);if(e.kind!=="model"&&(l.unique===!0||l.attrs))throw new v1([{field:l.name,error:"mixin-persistence",message:l.name+" from mixin "+s+" carries persistence metadata (@unique/attrs) — :model-only; a :"+e.kind+" cannot include it"}],e.name,e.kind);t.set(l.name,{name:l.name,required:l.modifiers.includes("!"),optional:l.modifiers.includes("?"),unique:l.unique===!0,attrs:l.attrs||null,typeName:l.typeName,literals:l.literals||null,array:l.array===!0,coerce:l.coerce===!0,coercer:l.coercer||null,constraints:l.constraints||null,transform:l.transform||null})}i.stack.pop()}}function M3(e){let t=new gt(e);if(t.name)ee.register(t);return t}if(typeof globalThis<"u")globalThis.__ripSchema=globalThis.__ripSchema||{},globalThis.__ripSchema.SchemaRegistry=ee;var gr={};xe(gr,{__batch:()=>L1,__catchErrors:()=>ue,__computed:()=>H1,__detachRef:()=>Cn,__effect:()=>$1,__handleError:()=>te,__ownerFrame:()=>yt,__popOwner:()=>Y1,__pushOwner:()=>le,__readonly:()=>fe,__setEffectErrorReporter:()=>j3,__setErrorHandler:()=>he,__state:()=>_1,getEffectSignal:()=>ce});var Ma=Symbol.for("rip.runtime.reactive");if(globalThis[Ma])throw Error("two copies of the Rip reactive runtime loaded in one process — states from different copies "+"cannot notify each other (separate dependency graphs, separate effect queues). Run .rip sources through the rip CLI/loader (one shared runtime module per process), or load only one standalone-compiled file per process.");globalThis[Ma]=!0;var N1=null,mr=[],Ue={buckets:[],size:0,low:0,add(e){let t=e.depth,r=this.buckets[t];if(r===void 0)r=this.buckets[t]=new Set;if(r.has(e))return;if(r.add(e),this.size++,tconsole.error(e,t);function j3(e){let t=bt;return bt=e,t}function ja(){try{while(Ue.size>0){let e=Ue.shift();if(!e._disposed)e.run()}}catch(e){throw Ue.clear(),e}}var Fa={valueOf(){return this.value},toString(){return String(this.value)},[Symbol.toPrimitive](e){return e==="string"?this.toString():this.valueOf()}};function _1(e){if(e!=null&&typeof e==="object"&&typeof e.read==="function")return e;let t=e,r=new Set,i=!1,n=!1,s=!1,a=()=>{if(N1&&typeof N1.markDirty==="function"&&N1.dependencies.has(r))throw Error("reactive runtime: computed dependency changed during evaluation — "+"computed functions must derive without writing or touching a dependency")},o=()=>{for(let f of mr)f.writtenSignals.add(r)},l=()=>{i=!0;try{for(let f of r)if(f.markDirty)f.markDirty(!0);else f._hard=!0,Ue.add(f);if(!dr)ja()}finally{i=!1}},c={get value(){if(s)return t;if(N1?.writtenSignals&&mr.some((f)=>f.writtenSignals.has(r)))throw Error("reactive runtime: computed dependency changed during evaluation — "+"computed functions must derive without writing or touching a dependency");if(N1)r.add(N1),N1.dependencies.add(r);return t},set value(f){if(s||n||f===t)return;if(a(),i)return;o(),t=f,l()},read(){return t},touch(){if(s)return;if(a(),i)return;o(),l()},lock(){return n=!0,c},free(){return r.clear(),c},kill(){return s=!0,r.clear(),t},...Fa};return c}var hr=0,La=1,ur=2;function Ba(e){let t=N1;N1=null;try{for(let[r,i]of e.computedDeps)if(r.value,r.version!==i)return!0;return!1}finally{N1=t}}function H1(e){let t,r=ur,i=new Set,n=!1,s=!1,a=!1,o={dependencies:new Set,computedDeps:new Map,writtenSignals:new Set,version:0,markDirty(l){if(s||n)return;if(a)throw Error("reactive runtime: computed dependency changed during evaluation — "+"computed functions must derive without writing or touching a dependency");let c=r;if(l)r=ur;else if(r===hr)r=La;if(c!==hr)return;for(let f of i)if(f.markDirty)f.markDirty(!1);else Ue.add(f)},get value(){if(s)return t;if(N1&&N1!==o)i.add(N1),N1.dependencies.add(i),N1.computedDeps.set(o,-1);if(a)throw Error("reactive runtime: computed value read during its own evaluation — "+"recursive computed reads are not supported");if(r===La&&!n)r=Ba(o)?ur:hr;if(r===ur&&!n){for(let c of o.dependencies)c.delete(o);o.dependencies.clear(),o.computedDeps.clear();let l=N1;o.writtenSignals.clear(),N1=o,mr.push(o),a=!0;try{let c=e();if(c!==t)o.version++;t=c,r=hr}finally{a=!1,mr.pop(),o.writtenSignals.clear(),N1=l}}if(N1&&N1!==o)N1.computedDeps.set(o,o.version);return t},read(){return t},lock(){return n=!0,o.value,o},free(){for(let l of o.dependencies)l.delete(o);return o.dependencies.clear(),o.computedDeps.clear(),i.clear(),o},kill(){s=!0;let l=t;return o.free(),l},...Fa};return o}function $1(e){let t=null,r=0,i=j1,n={depth:i?i.depth+1:0,dependencies:new Set,computedDeps:new Map,_hard:!0,_disposed:!1,signal:null,run(){if(n._disposed)return;let a=n._hard;if(n._hard=!1,!a&&!Ba(n))return;if(t)try{t.abort()}catch{}t=typeof AbortController<"u"?new AbortController:null,n.signal=t?t.signal:null;let o=++r;if(n._cleanup)n._cleanup(),n._cleanup=null;for(let f of n.dependencies)f.delete(n);n.dependencies.clear(),n.computedDeps.clear();let l=N1;N1=n;let c=j1;j1=i;try{let f=e();if(typeof f==="function")n._cleanup=f;else if(f&&typeof f.then==="function")f.then((h)=>{if(o!==r||n._disposed){if(typeof h==="function")try{h()}catch(u){bt("[Rip] superseded async cleanup error:",u)}return}if(typeof h==="function")n._cleanup=h},(h)=>{if(h&&h.name==="AbortError")return;if(o!==r||n._disposed)return;bt("[Rip] async effect error:",h)})}finally{N1=l,j1=c}},dispose(){if(n._disposed)return;if(n._disposed=!0,Ue.delete(n),t)try{t.abort()}catch{}if(n._cleanup)n._cleanup(),n._cleanup=null;for(let a of n.dependencies)a.delete(n);n.dependencies.clear()}};try{n.run()}catch(a){throw n.dispose(),a}let s=()=>n.dispose();if(j1)j1.add(s);return s}function L1(e){if(dr)return e();dr=!0;try{return e()}finally{dr=!1,ja()}}function yt({nested:e=!0}={}){let t=[],r=null,n={depth:j1?j1.depth+1:0,get disposed(){return t===null},get size(){return t===null?0:t.length},add(s){if(t===null)s();else t.push(s)},remove(s){if(t===null)return;let a=t.indexOf(s);if(a>=0)t.splice(a,1)},dispose(){if(t===null)return;let s=t;if(t=null,r!==null){let a=r;r=null,a()}for(let a of s)try{a()}catch(o){bt("[Rip] effect disposer error:",o)}}};if(e&&j1){let s=j1;s.add(n.dispose),r=()=>s.remove(n.dispose)}return n}function le(e){let t={frame:e,prev:j1};return j1=e,t}function Y1(e){if(!e||typeof e!=="object"||!("frame"in e))throw Error("reactive runtime: __popOwner takes the token the matching __pushOwner returned");if(j1!==e.frame)throw Error("reactive runtime: __popOwner out of order — the frame being popped is not the current owner "+"(an inner push was not popped, or this token was already popped)");j1=e.prev}function ce(){return N1?N1.signal:null}function fe(e){return Object.freeze({value:e})}function Cn(e,t){if(e&&typeof e.read==="function"&&e.read()===t)e.value=null}var pr=null;function he(e){let t=pr;return pr=e,t}function te(e){if(pr)try{pr(e)}catch(t){console.error("Error in error handler:",t),console.error("Original error:",e)}else throw e}function ue(e){return function(...t){try{return e.apply(this,t)}catch(r){te(r)}}}var Et={};xe(Et,{__Component:()=>ro,__claimGateConstructor:()=>Un,__clsx:()=>Er,__detach:()=>Rr,__detachRef:()=>Cn,__gateBind:()=>rc,__handleComponentError:()=>Mn,__hmrClassify:()=>Rt,__hmrEmit:()=>ke,__hmrEntries:()=>jn,__hmrEvents:()=>W3,__hmrLookup:()=>F3,__hmrMigrateDiff:()=>qa,__hmrMigrateRemount:()=>Y3,__hmrPatch:()=>Bn,__hmrPreserveState:()=>kr,__hmrRegisterDefinition:()=>St,__hmrRegistry:()=>Ee,__hmrRestoreUi:()=>Tr,__hmrSnapshotUi:()=>Fn,__lis:()=>eo,__ownerFrame:()=>yt,__popComponent:()=>Re,__popOwner:()=>Y1,__pushComponent:()=>Ve,__pushOwner:()=>le,__reconcile:()=>J3,__style:()=>to,__transition:()=>Q3,getContext:()=>q3,hasContext:()=>X3,setContext:()=>z3});var Ka=Symbol.for("rip.runtime.components");if(globalThis[Ka])throw Error("two copies of the Rip component runtime loaded in one process — components from different "+"copies cannot see each other (separate component stacks: context, parent chains, and error boundaries silently break across copies). Run .rip sources through the rip CLI/loader (one shared runtime module per process), or load only one standalone-compiled file per process.");globalThis[Ka]=!0;var re=null,Ya={},yr=null,za=new WeakMap,Ua=!1,Ee=new Map;function Pn(e,t){if(e===t)return!0;if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;rn.has(c)),o=i.filter((c)=>!n.has(c)),l=r.filter((c)=>!s.has(c));return{kept:a,added:o,removed:l}}var Sr=[],V3=64;function ke(e,t={}){let r={type:e,at:Date.now(),...t};if(Sr.push(r),Sr.length>V3)Sr.shift();if(typeof window<"u"&&typeof window.dispatchEvent==="function"&&typeof CustomEvent==="function")try{window.dispatchEvent(new CustomEvent("rip:hmr",{detail:r}))}catch{}return r}function W3(){return Sr.slice()}function kr(e,t){let r=e?.constructor?.__hmrSig,i=t?.constructor?.__hmrSig,n=r?.state,s=i?.state,a=qa(r,i);if(!Array.isArray(n)||!Array.isArray(s))return ke("migrate",{id:t?.constructor?.__hmrId??null,...a,copied:[]}),a;let o=new Set(n),l=[];for(let f of s){if(!o.has(f))continue;let h=e[f],u=t[f];if(h!=null&&u!=null&&typeof h==="object"&&typeof u==="object"&&"value"in h&&"value"in u)u.value=h.value,l.push(f)}let c=t?.constructor?.__hmrId??e?.constructor?.__hmrId??null;return ke("migrate",{id:c,...a,copied:l}),{...a,copied:l}}var Xa=["name","type","placeholder"];function Ja(e){let t=(i)=>typeof e[i]==="string"&&e[i]?e[i]:null,r={tag:e.tagName??null};for(let i of Xa)r[i]=t(i);return r.label=typeof e.getAttribute==="function"?e.getAttribute("aria-label"):null,r.value=typeof e.value==="string"?e.value:null,r}function Ln(e,t,r){if(!e||!t)return!1;let i=Ja(e);for(let n of["tag",...Xa,"label"])if(i[n]!==t[n])return!1;return!r||t.value==null||i.value===t.value}function H3(e){let t=Ja(e),r=typeof e.id==="string"&&e.id?e.id:null,i=[],n=e;while(n&&n!==document.body){let s=n.parentElement??n.parentNode??null;if(!s||!s.children)return{identity:t,id:r,path:null};i.unshift(Array.prototype.indexOf.call(s.children,n)),n=s}return{identity:t,id:r,path:n===document.body?i:null}}function G3(e){let t=e.active;if(t&&t.isConnected!==!1&&typeof document.contains==="function"&&document.contains(t))return t;let r=e.locator;if(!r)return null;if(r.id&&typeof document.getElementById==="function"){let o=document.getElementById(r.id);if(Ln(o,r.identity,!1))return o}if(!Array.isArray(r.path)||r.path.length===0)return null;let i=document.body;for(let o of r.path.slice(0,-1))if(i=i?.children?.[o]??null,!i)return null;let n=Array.from(i.children??[]),s=n[r.path[r.path.length-1]]??null;if(Ln(s,r.identity,!0))return s;let a=n.filter((o)=>Ln(o,r.identity,!0));return a.length===1?a[0]:null}function Fn(){if(typeof document>"u")return null;let e=document.activeElement,t=e&&e!==document.body&&e!==document.documentElement?e:null,r=null;if(t&&typeof t.selectionStart==="number")r={start:t.selectionStart,end:t.selectionEnd,direction:t.selectionDirection};return{active:t,locator:t?H3(t):null,selection:r,scrollX:typeof window<"u"?window.scrollX:0,scrollY:typeof window<"u"?window.scrollY:0}}function Tr(e){if(!e||typeof document>"u")return;if(typeof window<"u")window.scrollTo(e.scrollX??0,e.scrollY??0);let t=G3(e);if(!t||typeof t.focus!=="function")return;try{if(t.focus({preventScroll:!0}),e.selection&&typeof t.setSelectionRange==="function")t.setSelectionRange(e.selection.start,e.selection.end,e.selection.direction??"none")}catch{}}function Za(e,t){let r=e.constructor?.__hmrId;if(typeof r==="string"&&r)Ee.get(r)?.instances.delete(e);Object.setPrototypeOf(e,t.prototype),Object.defineProperty(e,"constructor",{value:t,writable:!0,configurable:!0}),St(t),Ee.get(t.__hmrId)?.instances.add(e)}function Bn(e,t){if(!e||!t)throw Error("__hmrPatch requires a living instance and a replacement constructor");let r=e.constructor?.__hmrId;return Za(e,t),e._hmrRerender(),ke("patch",{id:t.__hmrId??r??null}),e}function Qa(e){return Object.keys(e).sort().join(",")}function K3(e,t){let r=re?._hmrOrphans;if(!r||r.length===0)return null;let i=e.__hmrId;if(typeof i!=="string")return null;let n=Qa(t),s=null;for(let a of r){if(a._state!=="mounted"||a.constructor.__hmrId!==i||a._hmrPropKeys!==n)continue;if(s)return null;s=a}if(!s||Rt(s.constructor,e)!=="patch")return null;if(r.splice(r.indexOf(s),1),s.constructor!==e)Za(s,e);s._hmrRelease();try{s._hmrApplyProps(t)}catch(a){throw s._teardown({state:"failed",hooks:!1,removeDOM:!0}),a}if(!s._hmrRebind())return null;return s}function Y3(e,t,r={}){let i=new t(r);return kr(e,i),i}function Un(){if(Ua)throw Error("[Rip] the render-gate construction capability is already claimed");return Ua=!0,(e,t)=>{let r=yr;yr={brand:Ya,component:e,gates:t.gates,parent:t.parent??null,stash:t.stash??null,router:t.router??null,used:!1};try{return new e({})}finally{yr=r}}}function Rr(e){if(!e||e.nodeType===11)return;if(typeof e.remove==="function")e.remove();else if(e.parentNode)e.parentNode.removeChild(e)}function Ve(e){let t=re;if(e&&e._parent==null&&t&&t!==e)e._parent=t;return re=e,t}function Re(e){re=e}function z3(e,t){if(!re)throw Error("setContext must be called during component initialization");if(!re._context)re._context=new Map;re._context.set(e,t)}function q3(e){let t=re,r=new Set;while(t&&!r.has(t)){if(r.add(t),t._context&&t._context.has(e))return t._context.get(e);t=t._parent}throw Error(`getContext: no provider for context ${JSON.stringify(e)} in this component's parent chain — `+"offer it from an ancestor, or probe with hasContext(key) where absence is legal")}function X3(e){let t=re,r=new Set;while(t&&!r.has(t)){if(r.add(t),t._context&&t._context.has(e))return!0;t=t._parent}return!1}function Er(...e){let t="";for(let r of e){if(!r)continue;if(typeof r==="string")t&&(t+=" "),t+=r;else if(typeof r==="object"){if(Array.isArray(r)){let i=Er(...r);i&&(t&&(t+=" "),t+=i)}else for(let i in r)if(r[i])t&&(t+=" "),t+=i}}return t}function eo(e){let t=e.length;if(t===0)return[];let r=[],i=[],n=Array(t).fill(-1);for(let o=0;o>1;if(r[f]0)n[o]=i[l-1]}let s=[],a=i[r.length-1];for(let o=r.length-1;o>=0;o--)s.push(a),a=n[a];return s.reverse(),s}function J3(e,t,r,i,n,s,...a){let o=e.parentNode;if(!o)return;let l=t.keys,c=t.items||[],f=t.blocks,h=l.length,u=r.length,d=Array(u),S=s!=null,g=S?r.map((y,m)=>s(y,m)):r;if(S){let y=new Set;for(let m of g){if(y.has(m))throw Error(`__reconcile: duplicate key ${JSON.stringify(String(m))} — keyed rows need unique keys `+"(the key function must be injective over the items)");y.add(m)}}if(h===0){if(u>0){let y=document.createDocumentFragment();for(let m=0;m=p&&_>=p&&l[b]===g[_]){let y=f[b];if(!y._s)y.p(i,r[_],_,...a);d[_]=y,b--,_--}if(p>_)for(let y=p;y<=b;y++)f[y].d(!0);else if(p>b){let y=_+1=p;x--){let I=d[x];if(!O.has(x-p))I.m(o,N);N=I._first}}t.keys=S?g:r.slice(),t.items=r.slice(),t.blocks=d}var Va=!1;function Z3(){if(Va)return;Va=!0;let e=document.createElement("style");e.textContent=[".fade-enter-active,.fade-leave-active{transition:opacity .2s ease}",".fade-enter-from,.fade-leave-to{opacity:0}",".slide-enter-active,.slide-leave-active{transition:opacity .2s ease,transform .2s ease}",".slide-enter-from{opacity:0;transform:translateY(-8px)}",".slide-leave-to{opacity:0;transform:translateY(8px)}",".scale-enter-active,.scale-leave-active{transition:opacity .2s ease,transform .2s ease}",".scale-enter-from,.scale-leave-to{opacity:0;transform:scale(.95)}",".blur-enter-active,.blur-leave-active{transition:opacity .2s ease,filter .2s ease}",".blur-enter-from,.blur-leave-to{opacity:0;filter:blur(4px)}",".fly-enter-active,.fly-leave-active{transition:opacity .2s ease,transform .2s ease}",".fly-enter-from{opacity:0;transform:translateY(-20px)}",".fly-leave-to{opacity:0;transform:translateY(20px)}"].join(""),document.head.appendChild(e)}function Q3(e,t,r,i){Z3();let n=e.classList,s=t+"-"+r+"-from",a=t+"-"+r+"-active",o=t+"-"+r+"-to",l=!1,c=null;n.add(s,a),requestAnimationFrame(()=>{requestAnimationFrame(()=>{n.remove(s),n.add(o);let f=(u)=>{if(l||u&&u.target!==e)return;if(l=!0,clearTimeout(c),e.removeEventListener("transitionend",f),e.removeEventListener("transitioncancel",f),n.remove(a,o),i)i()};e.addEventListener("transitionend",f),e.addEventListener("transitioncancel",f);let h=0;try{let u=getComputedStyle(e),d=(S)=>Math.max(0,...String(S).split(",").map((g)=>(parseFloat(g)||0)*(/ms\s*$/.test(g.trim())?1:1000)));h=d(u.transitionDuration)+d(u.transitionDelay)}catch{}c=setTimeout(()=>f(),h+50)})})}function ec(e){let t=e!=null&&typeof e==="object"?e.name:null;if(t==="GateFailure"||t==="ComponentFailure")return e;let r=Error(e!=null&&e.message!==void 0?e.message:String(e));r.name="ComponentFailure";let i=e!=null?e.status??e.response?.status:void 0;if(i!==void 0)r.status=i;return r.error=e,r}function Mn(e,t){let r=ec(e),i=t,n=new Set;while(i&&!n.has(i)){if(n.add(i),i.onError){let s=Ve(i),a=le(i._frame);try{i.onError(r,t);return}catch(o){}finally{Y1(a),Re(s)}}i=i._parent}throw e}var Wa=new WeakSet;function tc(e,t){if(Wa.has(e))return;let r=e.__props??[];if(!Array.isArray(r))throw Error(`${e.name||"component"}: static __props must be an array of declared prop names`);for(let i of r){if(typeof i!=="string"||i.length===0)throw Error(`${e.name||"component"}: static __props entries must be non-empty strings`);if(i.startsWith("_"))throw Error(`${e.name||"component"}: declared prop '${i}' collides with component internals — `+"underscore-prefixed names are reserved for the runtime");if(i in t)throw Error(`${e.name||"component"}: declared prop '${i}' collides with a component member (a method or lifecycle slot already answers '${i}')`)}Wa.add(e)}function rc(e,t){let i=za.get(e)?.gates?.[t];if(!i?.cell)throw Error(`[Rip] render gate ${t} has no renderer-resolved source binding — `+"gated components may only be constructed by rip/app createRenderer()");let n=i.value,s=!0;return H1(()=>{if(s)return s=!1,i.cell.read(),n;let a=i.cell.read();for(let o of i.tail){if(a==null)break;a=a[o]}if(a!=null)n=a;return n})}var br=new WeakMap;function Ha(e,t,r){if(t.startsWith("--")&&typeof e.setProperty==="function")if(r==null||r==="")e.removeProperty(t);else e.setProperty(t,String(r));else e[t]=r}function to(e,t){let r=br.get(e);if(t==null){e.removeAttribute("style"),br.delete(e);return}if(typeof t!=="object"){e.setAttribute("style",String(t)),br.delete(e);return}if(r){for(let i of r)if(!(i in t))Ha(e.style,i,"")}br.set(e,Object.keys(t));for(let i of Object.keys(t))Ha(e.style,i,t[i])}function Ga(e,t){let r=e.__props??[],i=e.__extends??null,n=null;for(let s of Object.keys(t)){if(s==="children")continue;if(s.startsWith("__bind_")&&s.endsWith("__")){let a=s.slice(7,-2);if(r.includes(a))continue;throw Error(`${e.name||"component"}: cannot bind unknown prop '${a}' — declared `+`props are [${r.join(", ")}]`)}if(r.includes(s))continue;if(i!==null){(n??={})[s]=t[s];continue}throw Error(`${e.name||"component"}: unknown prop '${s}' — declared props are `+`[${r.join(", ")}]`)}return n}class ro{constructor(e={}){let t=K3(this.constructor,e);if(t)return t;this._state="new",tc(this.constructor,this);let r=this.constructor.__gates,i=yr,n=i?.brand===Ya&&i.component===this.constructor&&i.used!==!0;if(n)i.used=!0;if(r?.length&&!n)throw Error("[Rip] component declares render gates (<~) and cannot be constructed directly or as an embedded child; render gates are honored only by rip/app createRenderer()");if(n){if(za.set(this,i),i.parent)this._parent=i.parent;if(i.stash!=null)this.stash=i.stash;if(i.router!=null)this.router=i.router,Object.defineProperty(this,"params",{get:()=>i.router.params,configurable:!0}),Object.defineProperty(this,"query",{get:()=>i.router.query,configurable:!0})}if(this.stash==null&&globalThis.__ripStash!=null)this.stash=globalThis.__ripStash;if(this.router==null&&globalThis.__ripRouter!=null)this.router=globalThis.__ripRouter;let s=Ga(this.constructor,e);if("children"in e)this.children=e.children;if(this.constructor.__hmrId)this._hmrPropKeys=Qa(e);if(this.constructor.__extends!=null)this._rest=s??{},this.rest=_1(this._rest);this._frame=yt({nested:!1});let a=Ve(this),o=le(this._frame);try{this._init(e)}catch(l){Y1(o),Re(a),this._teardown({state:"failed",hooks:!1,removeDOM:!0}),this._initFailed=!0,Mn(l,this);return}if(Y1(o),Re(a),this.constructor.__hmrId)B3(this)}_init(e){}_updateProp(e,t){if(this._state==="failed"||this._state==="unmounted")return;let r=this.constructor.__props??[];if(!r.includes(e)){if(this.constructor.__extends){this._setRestProp(e,t);return}throw Error(`${this.constructor.name||"component"}: cannot update unknown prop '${e}' — declared `+`props are [${r.join(", ")}]`)}let i=this[e];if(i&&typeof i==="object"&&"value"in i){i.value=t;return}throw Error(`${this.constructor.name||"component"}: prop '${e}' is non-reactive — parent updates `+"cannot reach it (declare it with ':=' to receive updates)")}_setRestProp(e,t){if(e.startsWith("__bind_"))return;if(this._state==="failed"||this._state==="unmounted")return;if(this._rest||(this._rest={}),t==null)delete this._rest[e];else this._rest[e]=t;this.rest.touch();let r=le(this._frame);try{this._applyInheritedProp(this._inheritedEl,e,t)}finally{Y1(r)}}_applyRestToInheritedEl(){if(this._state==="failed"||this._state==="unmounted")return;if(!this._inheritedEl||!this._rest)return;for(let e in this._rest)this._applyInheritedProp(this._inheritedEl,e,this._rest[e])}_applyInheritedProp(e,t,r){if(this._state==="failed"||this._state==="unmounted")return;if(!e||t==="key"||t==="ref"||t==="children"||t.startsWith("__bind_"))return;let i=this._restWriters?.[t];if(i){if(i(),this._frame)this._frame.remove(i);delete this._restWriters[t]}if(r!=null&&typeof r==="object"&&typeof r.read==="function"){(this._restWriters??={})[t]=$1(()=>{this._applyPlainInheritedProp(e,t,r.value)});return}this._applyPlainInheritedProp(e,t,r)}_applyPlainInheritedProp(e,t,r){if(t[0]==="@"){let i=t.slice(1).split(".")[0];this._restHandlers||(this._restHandlers={});let n=this._restHandlers[t];if(n)e.removeEventListener(i,n);if(typeof r==="function"){let s=(a)=>L1(()=>r(a));this._restHandlers[t]=s,e.addEventListener(i,s)}else delete this._restHandlers[t];return}if(t==="class"||t==="className"){if(e instanceof SVGElement)e.setAttribute("class",Er(r));else e.className=Er(r);return}if(t==="style"){to(e,r);return}if(t==="innerHTML"||t==="textContent"||t==="innerText"){e[t]=r??"";return}if(t in e&&!t.includes("-")){e[t]=r;return}if(r==null||r===!1){e.removeAttribute(t);return}if(r===!0){e.setAttribute(t,"");return}e.setAttribute(t,r)}_beginMount(){if(this._state==="new"){this._state="mounting";return}let e=this.constructor.name||"component";if(this._state==="mounting")throw Error(`${e}: cannot mount an instance whose mount is already in progress`);if(this._state==="mounted")throw Error(`${e}: cannot mount an already-mounted instance — construct a new instance for another target`);if(this._state==="failed")throw Error(`${e}: cannot mount a failed instance — its mount rolled back; construct a new instance`);throw Error(`${e}: cannot mount an unmounted instance — its effects were disposed on unmount; construct a new instance`)}_mountCreate(){this._beginMount();let e=Ve(this),t=le(this._frame),r=null,i=!1;try{this._root=this._create()}catch(n){r=n,i=!0}finally{Y1(t),Re(e)}if(i)return this._failMount(r),!1;return!0}_mountSetup(e=null){if(this._state!=="mounting")return this._nodes?.[0]??this._root;let t=Ve(this),r=le(this._frame),i=null,n=!1;try{if(e){let s=this._nodes?.[0]??this._root;if(s?.parentNode)s.parentNode.insertBefore(e,s)}if(this.beforeMount)this.beforeMount();if(this._setup)this._setup();if(this.mounted)this.mounted();this._state="mounted",Rr(e),this._hmrDrainOrphans((s,a)=>console.error(`[Rip] ${s} error:`,a))}catch(s){i=s,n=!0}finally{Y1(r),Re(t)}if(n)return this._failMount(i),e;return this._nodes?.[0]??this._root}_failMount(e){this._teardown({state:"failed",hooks:!1,removeDOM:!0}),Mn(e,this)}_dispose(e,t){if(this._children){for(let r of this._children)try{t(r)}catch(i){e("child teardown",i)}this._children=null}try{this._frame?.dispose()}catch(r){e("owner disposal",r)}if(this._restWriters){for(let r of Object.values(this._restWriters))try{r()}catch(i){e("rest writer cleanup",i)}this._restWriters=null}if(this._restHandlers){if(this._inheritedEl)for(let[r,i]of Object.entries(this._restHandlers))try{this._inheritedEl.removeEventListener(r.slice(1).split(".")[0],i)}catch(n){e("rest handler cleanup",n)}this._restHandlers=null}if(this._refCleanups){let r=this._refCleanups;this._refCleanups=null;try{L1(()=>{for(let i of r)try{i()}catch(n){e("ref cleanup",n)}})}catch(i){e("ref cleanup batch flush",i)}}this._children=null,this._refCleanups=null,this._restWriters=null,this._restHandlers=null}_detachDOM(e,t){if(t)if(this._nodes)for(let r of this._nodes)try{Rr(r)}catch(i){e("DOM detach",i)}else try{Rr(this._root)}catch(r){e("DOM detach",r)}this._root=null,this._nodes=null,this._inheritedEl=null}_teardown({state:e,hooks:t,removeDOM:r}){if(this._state==="failed"||this._state==="unmounted")return;if(this.constructor.__hmrId)U3(this);this._state=e;let i=(n,s)=>console.error(`[Rip] ${n} error:`,s);if(this._hmrDrainOrphans(i),t)try{if(this.beforeUnmount)this.beforeUnmount()}catch(n){i("beforeUnmount",n)}if(this._dispose(i,(n)=>{if(t)n.unmount({removeDOM:r});else n._teardown({state:n._state==="mounted"?"unmounted":"failed",hooks:!1,removeDOM:!0})}),t)try{if(this.unmounted)this.unmounted()}catch(n){i("unmounted",n)}this._detachDOM(i,r),this._target=null}_hmrRelease(){let e=(t,r)=>console.error(`[Rip] ${t} error:`,r);try{if(this.beforeUnmount)this.beforeUnmount()}catch(t){e("beforeUnmount",t)}this._hmrOrphans=[],this._hmrReleasing=!0;try{this._dispose(e,(t)=>t.unmount({removeDOM:!0}))}finally{this._hmrReleasing=!1}this._detachDOM(e,!0),this._frame=yt({nested:!1}),this._state="new"}_hmrRebind(){let e=(i,n)=>console.error(`[Rip] ${i} error:`,n),t=Ve(this),r=le(this._frame);try{if(typeof this._hmrRefreshComputeds==="function")this._hmrRefreshComputeds();if(typeof this._hmrBindEffects==="function")this._hmrBindEffects()}catch(i){return Y1(r),Re(t),e("hmr rebind",i),this._failMount(i),!1}return Y1(r),Re(t),!0}_hmrApplyProps(e){let t=Ga(this.constructor,e);if("children"in e)this.children=e.children;for(let r of this.constructor.__props??[]){let i=`__bind_${r}__`;if(i in e){this[r]=e[i];continue}if(!(r in e))continue;let n=e[r];if(n!=null&&typeof n==="object"&&typeof n.read==="function")this[r]=n;else this._updateProp(r,n)}if(this.constructor.__extends!=null)this._rest=t??{},this.rest.value=this._rest}_hmrDrainOrphans(e){let t=this._hmrOrphans;if(!t)return;this._hmrOrphans=null;for(let r of t)try{r.unmount({removeDOM:!0})}catch(i){e("orphan teardown",i)}}_hmrRerender(){let e=this.constructor.name||"component";if(this._state!=="mounted")throw Error(`${e}: _hmrRerender requires a mounted instance`);let t=this._target,r=this._nodes,n=(r?.[0]??this._root)?.parentNode??null,s=r?.length?r[r.length-1].nextSibling:this._root?this._root.nextSibling:null;if(this._hmrRelease(),!this._hmrRebind())return this;if(typeof this._create!=="function")return this._state="mounted",this._hmrDrainOrphans((a,o)=>console.error(`[Rip] ${a} error:`,o)),this;if(!this._mountCreate())return this;try{let a=n&&n.nodeType!==11?n:null;if(a&&a.isConnected===!1)a=null;if(!a&&typeof t==="string"&&typeof document<"u")a=document.querySelector(t);else if(!a&&t&&t.nodeType!==11&&t.isConnected!==!1)a=t;else if(!a&&typeof document<"u")a=document.querySelector("#content")||document.querySelector("#app");if(a){let o=s&&(typeof a.contains!=="function"||a.contains(s))?s:null;if(this._nodes)for(let l of this._nodes)a.insertBefore(l,o);else if(this._root)a.insertBefore(this._root,o);this._target=a.nodeType===11?null:a}}catch(a){return this._failMount(a),this}return this._mountSetup(),this}mount(e){if(!this._mountCreate())return this;try{if(typeof e==="string")e=document.querySelector(e);if(this._target=e,this._root)e.appendChild(this._root)}catch(t){return this._failMount(t),this}return this._mountSetup(),this}unmount({removeDOM:e=!0}={}){if(this._state==="failed"||this._state==="unmounted")return;if(this._state==="mounted"&&this._parent?._hmrReleasing){this._parent._hmrOrphans.push(this);return}if(this._state==="mounting")throw Error(`${this.constructor.name||"component"}: cannot unmount while mounting`);this._teardown({state:"unmounted",hooks:this._state==="mounted",removeDOM:e})}emit(e,t){if(this._state!=="mounted"||!this._root)throw Error(`${this.constructor.name||"component"}: emit('${e}') outside the mounted window — `+"emit dispatches on the live root; call after mount and before unmount");(this._nodes?.[0]??this._root).dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0}))}static mount(e="body"){return new this().mount(e)}}var Hr={};xe(Hr,{ariaCurrent:()=>Cr,browserAdapter:()=>$r,buildRoutes:()=>Ot,check:()=>Wr,connectFeed:()=>Ur,createApply:()=>Vr,createComponents:()=>vr,createMutation:()=>uo,createRenderer:()=>Dr,createRouter:()=>Ir,createStash:()=>Nr,createWorkspace:()=>Fr,currentRouter:()=>Rc,currentStash:()=>Sc,debounce:()=>mo,delay:()=>Ar,hold:()=>go,interceptClicks:()=>Pr,launch:()=>Mr,ownsAnchor:()=>$t,parseQuery:()=>ze,persistStash:()=>xr,preloadLinks:()=>Lr,rash:()=>Dt,source:()=>so,throttle:()=>po,unwrapStash:()=>Te,validatePrepared:()=>ai});var wr,Vn,no,io=Symbol.for("rip.source"),Wn=Symbol.for("rip.source.family"),nc=64,ic=30000,sc=/^(\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)$/;function D1(e){return e!=null&&(typeof e==="object"||typeof e==="function")&&(e[io]===!0||e[Wn]===!0)}function de(e){return e!=null&&typeof e==="function"&&e[Wn]===!0}no=function(e){let t,r;if(e==null)return 0;if(typeof e==="number"){if(!(Number.isFinite(e)&&e>=0))throw TypeError('Rip App: source staleTime must be a non-negative finite number, a duration string, or "forever"');return e}if(typeof e==="string"){if(e==="forever")return 1/0;if(r=e.match(sc),r)return t=parseFloat(r[1]),(()=>{switch(r[2][0]){case"s":return t*1000;case"m":return t*60000;case"h":return t*3600000;case"d":return t*86400000;case"w":return t*604800000;case"y":return t*31536000000}})()}throw TypeError('Rip App: source staleTime must be a non-negative number, a duration such as "5 min", or "forever"')};wr=function(e,t,r=null){let i=_1(null),n=_1(!1),s=_1(null),a=0,o=null,l=null,c=!1,f=!1,h=!1,u=0,d=0,S=async function(b=!1,_=!1){let y,m;o?.abort(),o=typeof AbortController<"u"?new AbortController:null;let k=++a;if(!b)n.value=!0;let O=h;return await(async()=>{try{if(y=e(o?.signal),!(y!=null&&typeof y.then==="function"))throw TypeError("Rip App: source fetch must return a Promise");if(m=await y,k!==a)return m;return s.value=null,i.value=m,h=!0,u=Date.now(),d=_&&!f?u+ic:0,m}catch(N){if(k!==a)return;if(N?.name==="AbortError")return;if(s.value=N,!O)throw h=!1,u=0,N;return}finally{if(k===a)n.value=!1,l=null,c=!1,f=!1,r?.()}})()},g=function(b=!1,_=!1){let y=S(b,_);return l=y,c=_,f=!1,y},p=function(){return t===1/0||Date.now()-unc){o=!1;for(let[l,c]of r){if(l===a)continue;if(c.loading)continue;r.delete(l),c.reset(),o=!0;break}if(!o)break}return},n=function(a){if(a==null)throw TypeError("Rip App: keyed source requires a key");let o=ac(a),l=r.get(o);if(l)return r.delete(o),r.set(o,l),l;return l=wr(function(c){return e(a,c)},t,i),r.set(o,l),i(o),l},s=function(a){return n(a).read()};return s[Wn]=!0,s.cellFor=n,s.reset=function(){let a=Array.from(r.values());r.clear();for(let o of a)o.reset();return},s};function so(e){if(!(e!=null&&typeof e==="object"&&!Array.isArray(e)))throw TypeError("Rip App: source expects an options object");if(typeof e.fetch!=="function")throw TypeError("Rip App: source options require a fetch function");let t=no(e.staleTime);if(Object.prototype.hasOwnProperty.call(e,"kind")){if(!(e.kind==="singleton"||e.kind==="keyed"))throw TypeError("Rip App: source kind must be 'singleton' or 'keyed'");if(e.kind==="singleton"){if(e.fetch.length>1)throw TypeError("Rip App: singleton source fetch accepts at most one AbortSignal parameter");return wr(e.fetch,t)}if(e.fetch.length<1||e.fetch.length>2)throw TypeError("Rip App: keyed source fetch requires a key parameter and accepts one optional AbortSignal parameter");return Vn(e.fetch,t)}if(e.fetch.length>1)throw TypeError("Rip App: inferred source fetch accepts no parameters for a singleton or one key parameter for a keyed family");return e.fetch.length===1?Vn(e.fetch,t):wr(e.fetch,t)}var zn,_t,Hn,Tt,I1=Symbol("rip.app.stash.raw"),We=Symbol("rip.app.stash.signals"),oc=Symbol("rip.app.stash.keys"),lo=Symbol("rip.app.stash.defaults"),lc=Symbol.for("rip.app.stash.purge"),co=new WeakMap,cc=0,qn=_1(0),Gn=function(){return qn.value++},fo=function(e,t){let r=e[We];if(!r)r=new Map,Object.defineProperty(e,We,{value:r});let i=r.get(t);if(!i)i=_1(e[t]),r.set(t,i);return i},wt=function(e){return fo(e,oc)},Kn=function(e){wt(e).value=++cc;return};_t=function(e){if(!(e!=null&&typeof e==="object"))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Array.isArray(e)};var ao=function(e){if(!_t(e))return e;let t=co.get(e);if(t)return t;return zn(e)},He=function(e,t){let r=e?.[I1];if(!r)return e[t];let i=r[t];if(D1(i)){if(de(i))return i;return ao(i.read())}return ao(fo(r,t).value)},Yn=function(e,t,r){let i,n,s,a,o=e?.[I1];if(!o)return e[t]=r,r;if(Array.isArray(o)&&t==="length"){if(a=o.length,s=+r,o.length=s,s!==a){if(o[We]){for(let h=Math.min(a,s),u=Math.max(a,s);h0))throw TypeError("Rip App: stash path must be a non-empty string");let s=[],a=0;if(e[0]!=="["){n=a;while(a=e.length||a===n)throw TypeError(`Rip App: malformed stash path '${e}'`);if(r=e.slice(n,a),a++,e[a]!=="]")throw TypeError(`Rip App: malformed stash path '${e}'`);a++,s.push(r)}else{n=a;while(a{let i=[];for(let n in r){if(!Object.hasOwn(r,n))continue;let s=r[n];i.push(Hn(s,t))}return i})()};Tt=function(e){if(!_t(e))return e;let t=e[I1]?e[I1]:e;if(Array.isArray(t))return(()=>{let i=[];for(let n of t)if(!D1(n))i.push(Tt(n));return i})();let r={};for(let i in t){if(!Object.hasOwn(t,i))continue;let n=t[i];if(D1(n))continue;r[i]=Tt(n)}return r};function ho(e){let t=e?.[I1]?e[I1]:e;if(!(t!=null&&typeof t==="object"))return;Object.defineProperty(t,lo,{value:Tt(t),configurable:!0});return}function _r(e){if(D1(e))return e;if(!_t(e))return e;let t=e[I1]?e[I1]:e;if(Array.isArray(t))return(()=>{let i=[];for(let n of t)i.push(_r(n));return i})();let r={};for(let i in t){if(!Object.hasOwn(t,i))continue;let n=t[i];Object.defineProperty(r,i,{value:_r(n),writable:!0,enumerable:!0,configurable:!0})}return r}function Ye(e,t){let r,i,n;if(!(e!=null&&typeof e==="object"))return;if(!(t!=null&&typeof t==="object"))return;let s=e[I1]?e[I1]:e;for(let a in t){if(!Object.hasOwn(t,a))continue;let o=t[a];if(r=Object.prototype.hasOwnProperty.call(s,a)?s[a]:void 0,D1(r))continue;if(Array.isArray(r)&&r.some(function(l){return D1(l)}))continue;if(i=r!=null&&typeof r==="object"&&!Array.isArray(r),n=o!=null&&typeof o==="object"&&!Array.isArray(o),i&&n)Ye(e[a],o);else e[a]=Tt(o)}return}var uc=function(e,t){let r,i=t[lo];if(!i)return;r=function(n,s,a){let o;for(let l in s){if(!Object.hasOwn(s,l))continue;if(o=s[l],D1(o))continue;if(!(a!=null&&Object.prototype.hasOwnProperty.call(a,l))){delete n[l];continue}if(o!=null&&typeof o==="object"&&!Array.isArray(o))r(n[l],o,a[l])}return},r(e,t,i),Ye(e,i);return},dc={inc:!0,dec:!0,flip:!0,join:!0,keys:!0,has:!0,del:!0,peek:!0,reset:!0,source:!0},mc=function(e,t,r){if(r==="inc")return function(i,n=1){let s=($e(e,i)??0)+n;return kt(e,i,s),s};if(r==="dec")return function(i,n=1){let s=($e(e,i)??0)-n;return kt(e,i,s),s};if(r==="flip")return function(i){let n=!($e(e,i)??!1);return kt(e,i,n),n};if(r==="join")return function(i,n){if(!(n!=null&&typeof n==="object"&&!Array.isArray(n)))throw TypeError("Rip App: join expects a plain object");L1(function(){let s=$e(e,i);if(!(s!=null&&typeof s==="object"&&!Array.isArray(s)))kt(e,i,{}),s=$e(e,i);return(()=>{let a=[];for(let o in n){if(!Object.hasOwn(n,o))continue;let l=n[o];a.push(s[o]=l)}return a})()});return};if(r==="keys")return function(i){let n=i!=null?$e(e,i):e;if(!(n!=null&&typeof n==="object"))return[];let s=n[I1]?n[I1]:n;return wt(s).value,Object.keys(s)};if(r==="has")return function(i){let n,s,a=Ge(i);if(!(a.length>0))return!1;let o=e;for(let l=0;l0))return;let a=e;for(let o=0;o{try{return i.value=!0,await t.onSuccess?.(l),l}finally{if(c===s)r.value=!1}})()};return Object.defineProperty(a,"pending",{get(){return r.value}}),Object.defineProperty(a,"succeeded",{get(){return i.value}}),Object.defineProperty(a,"error",{get(){return n.value}}),a}var Nt,At;Nt=function(e){return typeof e==="function"?e:function(){return e.value}};At=function(e,t,r){let i={read(){return e.read()}},n={get(){return e.value}};if(typeof t!=="function")n.set=function(s){return t.value=s};return Object.defineProperty(i,"value",n),i.dispose=function(){return r?.()},i};function Ar(e,t){let r=Nt(t),i=_1(!!r()),n=$1(function(){let s;if(r()){if(i.read())return;return s=setTimeout(function(){return i.value=!0},e),function(){return clearTimeout(s)}}i.value=!1;return});return At(i,t,n)}function mo(e,t){let r=Nt(t),i=_1(r()),n=$1(function(){let s=r(),a=setTimeout(function(){return i.value=s},e);return function(){return clearTimeout(a)}});return At(i,t,n)}function po(e,t){let r=Nt(t),i=_1(r()),n=0,s=$1(function(){let a=r(),o=Date.now(),l=e-(o-n);if(l<=0){i.value=a,n=o;return}let c=setTimeout(function(){return i.value=r(),n=Date.now()},l);return function(){return clearTimeout(c)}});return At(i,t,s)}function go(e,t){let r=Nt(t),i=_1(!!r()),n=$1(function(){if(r()){i.value=!0;return}if(!i.read())return;let s=setTimeout(function(){return i.value=!1},e);return function(){return clearTimeout(s)}});return At(i,t,n)}var Xn,Jn,we;we=function(e){if(!(typeof e==="string"&&e.length>0))throw TypeError("Rip App: component path must be a non-empty string");let t=e.split("/"),r=t.some(function(s){return!s||s==="."||s===".."}),i=t.at(-1),n=t.slice(0,-1).some(function(s){return s.endsWith(".rip")});if(e.includes("\\")||r||n||i===".rip"||!i.endsWith(".rip"))throw TypeError(`Rip App: invalid component path '${e}'`);return e};Xn=function(e){if(typeof e!=="string")throw TypeError("Rip App: component source must be a string");return e};Jn=function(e){if(e===""||e==null)return"";if(typeof e!=="string")throw TypeError("Rip App: component directory must be a string");let t=e.split("/");if(e.includes("\\")||t.some(function(r){return!r||r==="."||r===".."}))throw TypeError(`Rip App: invalid component directory '${e}'`);return e};function vr(){let e=new Map,t=new Map,r=new Set,i=function(s,a){let o=[];for(let l of Array.from(r))o.push((()=>{try{return l(s,a)}catch(c){return console.error("[Rip] component watcher error:",c)}})());return o};return{read(s){return e.get(we(s))},write(s,a){s=we(s),a=Xn(a);let o=e.has(s)?"change":"create";e.set(s,a),t.delete(s),i(o,s);return},del(s){s=we(s),e.delete(s),t.delete(s),i("delete",s);return},exists(s){return e.has(we(s))},size(){return e.size},list(s=""){let a;s=Jn(s);let o=s?s+"/":"",l=[];for(let[c]of e)if(c.startsWith(o)){if(a=c.slice(o.length),!a.includes("/"))l.push(c)}return l},listAll(s=""){s=Jn(s);let a=s?s+"/":"",o=[];for(let[l]of e)if(l.startsWith(a))o.push(l);return o},load(s){let a,o;if(!(s!=null&&typeof s==="object"&&!Array.isArray(s)))throw TypeError("Rip App: component load expects a source object");for(let l in s){if(!Object.hasOwn(s,l))continue;let c=s[l];l=we(l),c=Xn(c),e.set(l,c),t.delete(l)}return},watch(s){if(typeof s!=="function")throw TypeError("Rip App: component watch expects a function");r.add(s);let a=!1;return function(){if(a)return;a=!0,r.delete(s);return}},getCompiled(s){return t.get(we(s))},setCompiled(s,a){if(s=we(s),!(a!=null&&typeof a==="object"&&!Array.isArray(a)))throw TypeError("Rip App: compiled component module must be an object");t.set(s,a);return}}}var yo,So,C1,Qn,Ro,Eo,ko,Zn=/^\w+$/,To={static:0,dynamic:1,optional:2,catchall:3},bo=8;C1=function(e){throw Error(`Rip App: ${e}`)};var vt=function(e){return(()=>{try{return decodeURIComponent(e)}catch(t){return null}})()};ko=function(e){if(e==="")return"";if(typeof e!=="string")throw TypeError("Rip App: route root must be a string");let t=e.split("/");if(e.includes("\\")||t.some(function(r){return!r||r==="."||r===".."}))throw TypeError(`Rip App: invalid route root '${e}'`);return e};var wo=function(e,t){let r;if(r=/^\[\[(.+)\]\]$/.exec(e)){if(!Zn.test(r[1]))C1(`invalid optional segment '${e}' in '${t}'`);return{kind:"optional",name:r[1]}}else if(r=/^\[\.\.\.(.+)\]$/.exec(e)){if(!Zn.test(r[1]))C1(`invalid catch-all segment '${e}' in '${t}'`);return{kind:"catchall",name:r[1]}}else if(e.startsWith("[..."))return C1(`invalid catch-all segment '${e}' in '${t}'`);else if(r=/^\[(.+)\]$/.exec(e)){if(!Zn.test(r[1]))C1(`invalid dynamic segment '${e}' in '${t}'`);return{kind:"dynamic",name:r[1]}}else if(/^\(.+\)$/.test(e))return{kind:"group"};else if(e.includes("[")||e.includes("]"))return C1(`invalid segment '${e}' in '${t}': markers claim a whole segment`);else return{kind:"static",text:e}};yo=function(e){let t,r=(()=>{let h=[];for(let u of e.slice(0,-4).split("/"))h.push(wo(u,e));return h})();if(r[r.length-1].kind==="group")C1(`route file name cannot be a group segment: '${e}'`);let i=r.filter(function(h){return h.kind!=="group"});for(let h=0;hbo)C1(`more than ${bo} optional segments in '${e}'`);let o="",l=[],c=[{shape:"",display:""}];for(let h of i)switch(l.push(To[h.kind]),h.kind){case"static":t="/"+h.text,o+=t,c=c.map(function(u){return{shape:u.shape+t,display:u.display+t}});break;case"dynamic":o+=`/:${h.name}`,c=c.map(function(u){return{shape:u.shape+"/:",display:`${u.display}/:${h.name}`}});break;case"optional":o+=`/:${h.name}?`,c=c.flatMap(function(u){return[u,{shape:u.shape+"/:",display:`${u.display}/:${h.name}`}]});break;case"catchall":o+=`/*${h.name}`,c=c.map(function(u){return{shape:u.shape+"/*",display:`${u.display}/*${h.name}`}});break}if(o==="")o="/";if(new Set(c.map(function(h){return h.shape||"/"})).size{let l=[];for(let c of e)l.push(wo(c,t));return l})().filter(function(l){return l.kind!=="group"});for(let l of i)if(l.kind==="optional"||l.kind==="catchall")C1(`not-found page under an optional or catch-all segment: '${t}'`);let n=[];for(let l of i)if(l.name!=null){if(n.includes(l.name))C1(`duplicate parameter name '${l.name}' in '${t}'`);n.push(l.name)}let s="",a="",o=[];for(let l of i)if(o.push(To[l.kind]),l.kind==="static")s+="/"+l.text,a+="/"+l.text;else s+=`/:${l.name}`,a+="/:";return{pattern:s+"/*",shape:a+"/*",parts:i,ranks:o}};Ro=function(e,t){let r;return r=function(i,n){let s,a,o,l;if(i===e.length)return n===t.length?[]:null;let c=e[i];return(()=>{switch(c.kind){case"static":if(!(nf.length))continue;if(a=m.slice(f.length),l=a.split("/"),s=l.some(function(k){return!k||k==="."||k===".."}),a.includes("\\")||s||l.at(-1)===".rip")throw TypeError(`Rip App: invalid route file path '${m}'`);if(l.at(-1)==="_layout.rip"){h.set(l.slice(0,-1).join("/"),m);continue}if(l.at(-1)==="_404.rip"){if(l.slice(0,-1).some(function(k){return k.startsWith("_")}))continue;u.push({...So(l.slice(0,-1),a),rel:a,file:m});continue}if(l.some(function(k){return k.startsWith("_")}))continue;if(!a.endsWith(".rip"))throw TypeError(`Rip App: route files must be .rip sources: '${m}'`);d.push({...yo(a),rel:a,file:m})}let S=new Map;for(let m of[...d].sort(function(k,O){return k.relk.pattern)return 1;return 0});let g=new Map;for(let m of[...u].sort(function(k,O){return k.relk.pattern)return 1;return 0});let p=d.map(function(m){return{route:Object.freeze({pattern:m.pattern,file:m.file,layouts:Object.freeze(Qn(m.rel,h))}),parts:m.parts}}),R=u.map(function(m){return{route:Object.freeze({pattern:m.pattern,file:m.file,layouts:Object.freeze(Qn(m.rel,h))}),parts:m.parts}}),b=function(m){if(typeof m!=="string")throw TypeError("Rip App: route match expects a path string");if(!m.startsWith("/"))return null;while(m.length>1&&m.endsWith("/"))m=m.slice(0,-1);return m==="/"?[]:m.slice(1).split("/")},_=function(m){let k;if(l=b(m),!l)return null;for(let O of p){if(k=Ro(O.parts,l),!k)continue;return{route:O.route,params:Object.fromEntries(k)}}return null},y=function(m){let k;if(l=b(m),!l)return null;for(let O of R){if(k=Eo(O.parts,l),!k)continue;return{route:O.route,params:Object.fromEntries(k)}}return null};return Object.freeze({routes:Object.freeze(p.map(function(m){return m.route})),match:_,notFound:y})}function ze(e){if(typeof e!=="string")throw TypeError("Rip App: parseQuery expects a query string");return Object.fromEntries(new URLSearchParams(e))}var G1,ei,_o,Or;G1=function(e){let t=e.indexOf("#"),r=t>=0?e.slice(t+1):"",i=t>=0?e.slice(0,t):e,n=i.indexOf("?"),s=n>=0?i.slice(n+1):"";return{path:n>=0?i.slice(0,n):i,query:s,hash:r}};ei=function(e,t){let r=Object.keys(t);return r.length===Object.keys(e).length&&r.every(function(n){return e[n]===t[n]})?e:t};Or=function(e){if(!(e!=null&&typeof e.match==="function"&&Array.isArray(e.routes)))throw TypeError("Rip App: createRouter requires a route manifest");return e};_o=function(e){if(e===""||e==null)return"";if(!(typeof e==="string"&&e.startsWith("/")&&!e.endsWith("/")))throw TypeError(`Rip App: invalid router base '${e}'`);return e};function Ir(e){let t,{routes:r,adapter:i,onError:n}=e??{};if(!(r!=null&&(typeof r==="function"||typeof r.match==="function"&&Array.isArray(r.routes))))throw TypeError("Rip App: createRouter requires a route manifest or manifest thunk");for(let j of["read","push","replace","go","listen"])if(typeof i?.[j]!=="function")throw TypeError(`Rip App: router adapter requires a ${j} function`);let s=_o(e?.base),a=e?.hash===!0;if(s&&a)throw TypeError("Rip App: a base path does not apply in hash mode");let o=typeof r==="function"?Or(r()):Or(r),l=new Set,c=null,f=_1(null),h=_1(null),u=_1({}),d=_1({}),S=_1(""),g=Ar(100,_1(!1)),p=H1(function(){let j=h.value;if(!j)return null;return{route:j,layouts:j.layouts,params:u.value,query:d.value}}),R=function(j){if(!s)return j;if(j===s)return"/";if(j.startsWith(s+"/"))return j.slice(s.length);return null},b=function(j){if(!s)return j;return j==="/"?s:s+j},_=function(j){return a?i.read().split("#")[0]+"#"+j:b(j)},y=function(j){return n?.({status:404,path:j}),!1},m=0,k=function(j){return typeof j==="string"&&!j.startsWith("//")&&!j.includes("\\")},O=function(j){if(!k(j))return null;return o.match(j)},N=function(j){if(!k(j))return null;return o.match(j)??o.notFound?.(j)??null},x=function(j,q,t1,M){let A=ei(u.value,j.params),C=ei(d.value,ze(t1));L1(function(){return f.value=q,h.value=j.route,u.value=A,d.value=C,S.value=M});let w={path:q,route:j.route,params:A,query:C,hash:M};m+=1;try{for(let D of Array.from(l))try{D(w)}catch(B){console.error("[Rip] router onNavigate error:",B)}}finally{m-=1}return!0},I=function(){if(m>=10)throw Error("Rip App: navigation loop — ten nested navigations from onNavigate")},H=function(){let j,q,t1,M,A,C=i.read();if(a){if(j=C.indexOf("#"),t1=j>=0?C.slice(j+1):"/",t1==="")t1="/";({path:M,query:A,hash:q}=G1(t1))}else if({path:M,query:A,hash:q}=G1(C),M=R(M),M==null)return y(G1(C).path);let w=N(M);if(!w)return y(M);return x(w,M,A,q)},G=null,K=null,Z=function(){G=null;let j=i.readState?.()??{};return i.replace(i.read(),{...j,__ripScroll:i.scroll?.save?.()??null})},V=function(){return!G?G=setTimeout(Z,100):void 0};return t={init(){if(c)return t;return H(),c=i.listen(function(){if(!H())return;let j=i.readState?.();return i.scroll?.restore?.(j?.__ripScroll??null)}),K=i.scroll?.watch?.(V)??null,t},push(j,q={}){I();let{path:t1,query:M,hash:A}=G1(j),C=N(t1);if(!C)return y(t1);let w=i.scroll?.save?.()??null,D=i.readState?.()??{};if(i.replace(i.read(),{...D,__ripScroll:w}),i.push(_(j),null),x(C,t1,M,A),!q.noScroll)i.scroll?.top?.();return!0},replace(j,q={}){I();let{path:t1,query:M,hash:A}=G1(j),C=N(t1);if(!C)return y(t1);let w=i.readState?.()??{};if(i.replace(_(j),{...w,__ripScroll:null}),x(C,t1,M,A),!q.noScroll)i.scroll?.top?.();return!0},back(){return i.go(-1)},forward(){return i.go(1)},match(j){let{path:q,query:t1,hash:M}=G1(j),A=O(q);if(!A)return null;return{route:A.route,params:A.params,query:ze(t1),hash:M}},claims(j){let q,t1,M,A,C;if(!(typeof j==="string"&&j.length>0))return null;if(a){if(q=j.indexOf("#"),q<0)return null;if(M=j.slice(q+1),M==="")M="/";({path:A,query:C,hash:t1}=G1(M))}else{if(!j.startsWith("/"))return null;if({path:A,query:C,hash:t1}=G1(j),A=R(A),A==null)return null}let w=O(A);if(!w)return null;let D=A+(C?"?"+C:"")+(t1?"#"+t1:"");return{path:A,url:D,route:w.route,params:w.params,query:ze(C),hash:t1}},onNavigate(j){if(typeof j!=="function")throw TypeError("Rip App: onNavigate expects a function");return l.add(j),function(){return l.delete(j)}},rebuild(){let j,q,t1,M,A;if(o=typeof r==="function"?Or(r()):o,!c)return;let C=i.read();if(a){if(j=C.indexOf("#"),t1=j>=0?C.slice(j+1):"/",t1==="")t1="/";({path:M,query:A,hash:q}=G1(t1))}else if({path:M,query:A,hash:q}=G1(C),M=R(M),M==null)return y(G1(C).path);let w=N(M);if(!w)return y(M);let D=h.value,B=D?.layouts??[],a1=w.route.layouts??[],h1=B.length===a1.length&&B.every(function(f1,z){return f1===a1[z]});if(D?.file===w.route.file&&h1&&f.value===M)return;x(w,M,A,q);return},destroy(){if(c?.(),c=null,K?.(),K=null,G)clearTimeout(G);G=null;return}},Object.defineProperty(t,"current",{get(){return p.value}}),Object.defineProperty(t,"path",{get(){return f.value}}),Object.defineProperty(t,"hash",{get(){return S.value}}),Object.defineProperty(t,"params",{get(){return u.value}}),Object.defineProperty(t,"query",{get(){return d.value}}),Object.defineProperty(t,"navigating",{get(){return g.value},set(j){return g.value=j}}),t}function $r(){if(typeof window>"u"||window.history==null||window.location==null)throw Error("Rip App: browserAdapter requires a browser environment");window.history.scrollRestoration="manual";let e=function(r){return window.requestAnimationFrame?window.requestAnimationFrame(r):setTimeout(r,16)},t=0;return{read(){return window.location.pathname+window.location.search+window.location.hash},readState(){return window.history.state},push(r,i){return window.history.pushState(i,"",r)},replace(r,i){return window.history.replaceState(i,"",r)},go(r){return window.history.go(r)},listen(r){return window.addEventListener("popstate",r),function(){return window.removeEventListener("popstate",r)}},scroll:{save(){return{x:window.scrollX,y:window.scrollY}},restore(r){let i;if(r==null)return;let n=++t,s=r.x||0,a=r.y||0,o=0;i=function(){if(n!==t)return;let l=Math.max(0,(window.document?.documentElement?.scrollHeight||0)-window.innerHeight);return window.scrollTo(s,Math.min(a,l)),o+=1,a>l&&o<20?e(i):void 0},e(i);return},top(){return t+=1,window.scrollTo(0,0)},watch(r){return window.addEventListener("scroll",r,{passive:!0}),function(){return window.removeEventListener("scroll",r)}}}}}var ti,No,De;No=Un();De=function(e,t,r,i=null){let n=i??r?.message??String(r),s=Error(n);return s.name="GateFailure",s.status=r?.status??r?.response?.status??500,s.path=e,s.file=t,s.error=r,s};ti=function(e,t){let r=e.getCompiled(t);if(!(r!=null&&typeof r==="object"))throw Error(`Rip App: no precompiled component module for '${t}'`);let i=function(s){return typeof s==="function"&&typeof s.prototype?.mount==="function"};if(i(r.default))return r.default;let n=[];for(let s in r){let a=r[s];if(s==="default")continue;if(i(a))n.push(a)}if(n.length!==1)throw Error(`Rip App: precompiled module '${t}' must export exactly one component class`);return n[0]};function Dr(e){let t;if(!(e!=null&&typeof e==="object"))throw TypeError("Rip App: createRenderer expects an options object");let{router:r,stash:i,components:n,target:s,onError:a}=e;if(!(r!=null&&typeof r==="object"))throw TypeError("Rip App: createRenderer requires a router object");if(!(i!=null&&Te(i)!==i))throw TypeError("Rip App: createRenderer requires a stash built by createStash");if(!(n!=null&&typeof n.getCompiled==="function"))throw TypeError("Rip App: createRenderer requires a component registry");if(!(s!=null&&typeof s.appendChild==="function"))throw TypeError("Rip App: createRenderer requires a target with appendChild()");if(a!=null&&typeof a!=="function")throw TypeError("Rip App: createRenderer onError must be a function");let o=[],l=null,c=0,f=null,h=[],u=null,d=null,S=null,g=!1,p=function(z,i1){let X=Object.keys(z);return X.length===Object.keys(i1).length&&X.every(function(r1){return z[r1]===i1[r1]})},R=function(z,i1){return z.length===i1.length&&z.every(function(X,r1){return i1[r1]===X})},b=function(z){let i1=Te(i),X=z.split(".");for(let r1=0;r1",P.file,`Rip App: ${P.file} static __gates must be an array`);for(let W=0;W0))throw _(String(J),P.file,`Rip App: ${P.file} has a malformed render gate path`);if(F!=null&&typeof F!=="function")throw _(J,P.file,`Rip App: gate '${J}' has a non-function key`);if(o1=b(J),!o1)throw _(J,P.file,`Rip App: gate '${J}' does not resolve to a source`);if(r1=o1.cell,de(r1)){if(!F)throw _(J,P.file,`Rip App: gate '${J}' is keyed and requires a key function`);try{c1=F(i1,X),r1=r1.cellFor(c1)}catch(L){throw Q=L,De(J,P.file,Q,`Rip App: gate '${J}' key failed: ${Q.message}`)}}else if(F)throw _(J,P.file,`Rip App: gate '${J}' is a singleton and does not accept a key function`);if(P.bindings[W]={cell:r1,tail:o1.tail,path:J,file:P.file},!n1.has(r1))n1.set(r1,{cell:r1,path:J,file:P.file,entryIndex:v})}}return Array.from(n1.values())},k=async function(z,i1,X,r1){let Q,l1,c1=m(z,i1,X),F=await Promise.allSettled((()=>{let n1=[];for(let v of c1)n1.push(v.cell.ensure());return n1})());if(r1!==c)return!1;let J=null,o1=function(n1,v){if(n1.entryIndex=v,J==null||v=J.entryIndex)break;for(let P of v.bindings){l1=P.cell.peek();for(let W of P.tail){if(l1==null)break;l1=l1[W]}if(l1==null){o1(_(P.path,P.file,`Rip App: gate '${P.path}' resolved to ${l1}; every gated subpath must exist and be non-null`),n1);break}P.value=l1}}if(J!=null)throw J;return!0},O=function(z,i1){return No(z.cls,{gates:z.bindings,parent:i1,stash:i,router:r})},N=function(z){let i1=[];for(let X=z.length-1;X>=0;X--){let r1=z[X];try{r1.unmount?.()}catch(Q){i1.push(Q);try{r1._teardown?.({state:"unmounted",hooks:!1,removeDOM:!0})}catch(l1){i1.push(l1)}}}return i1},x=function(){let z=o;o=[],l=null,h=[],u=null,d=null;let i1=N(z);if(i1.length)throw i1[0];return},I=null,H=function(){I?.remove?.(),I=null;return},G=function(z){let i1,X;H();let r1=z.error?.stack??z.stack??z.message??String(z);I=(()=>{if(typeof document<"u"&&typeof document.createElement==="function")return i1=document.createElement("pre"),i1.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",i1.textContent=r1,i1;else return X={nodeName:"PRE",textContent:r1,parentNode:null,remove(){let Q=X.parentNode?.children,l1=Q?.indexOf(X)??-1;if(l1>=0)Q.splice(l1,1);X.parentNode=null;return}},X})(),s.appendChild(I);return},K=function(){if(typeof document<"u"&&typeof document.createDocumentFragment==="function")return document.createDocumentFragment();let z=[];return{children:z,appendChild(i1){return z.push(i1),i1}}},Z=function(z,i1=s){if(H(),z.nodeType===11)i1.appendChild(z);else for(let X of z.children)i1.appendChild(X);return},V=function(z,i1){let X,r1=z._nodes??[z._root];for(let Q of r1){if(!Q)continue;if(Q.matches?.("#content"))return Q;if(X=Q.querySelector?.("#content"),X)return X}return r1.find(function(Q){return Q!=null})??i1},j=function(z){return z?.childNodes??z?.children??[]},q=function(z,i1){z.slot=i1,z.slotOwned=j(i1).length;return},t1=function(){let z,i1,X=s;for(let r1=0;r10&&Q.slot!=null&&Q.slot!==X){i1=Array.from(j(Q.slot)).slice(Q.slotOwned??0),q(Q,X);for(let l1 of i1)X.appendChild(l1);z._target=X}if(r1===h.length-1)break;X=V(z,X)}if(h.length>1)u=X;return},M=function(z,i1,X){let r1,Q,l1;if(!z.some(function(n1){return typeof n1.cls.prototype?.onError==="function"}))return!1;let c1=K(),F=c1,J=[];try{for(let n1=0;n10)q(v,F);if(Q.mount?.(F),Q._state==="failed")return N(J),!1;F=V(Q,F)}if(X!==c)return N(J),!1;r1=null;for(let n1=J.length-1;n1>=0;n1--){let v=J[n1];if(typeof v.onError==="function"){r1=v;break}}Z(c1)}catch(n1){return console.error("[Rip] boundary chain failed to mount:",n1),N(J),!1}let o1=o;o=J,l=J[J.length-1]??null,h=z,u=F,d=null;try{r1.onError(i1)}catch(n1){console.error("[Rip] boundary onError error:",n1)}for(let n1 of N(o1))console.error("[Rip] boundary teardown error:",n1);return!0},A=function(z,i1){let X=null;for(let Q=z.length-1;Q>=0;Q--){let l1=z[Q];if(typeof l1.instance?.onError==="function"){X=l1.instance;break}}if(!X)return!1;let r1=o.slice(z.length);o=z.map(function(Q){return Q.instance}),l=o[o.length-1]??null,h=z,d=null;try{X.onError(i1)}catch(Q){console.error("[Rip] boundary onError error:",Q)}for(let Q of N(r1))console.error("[Rip] boundary teardown error:",Q);return!0},C=async function(z,i1,X=n){let r1,Q,l1,c1,F,J,o1=z?.route;if(!o1?.file)throw Error("Rip App: renderer route state requires route.file");let n1=z.params??{},v=z.query??{},P=z.layouts??[];if(!Array.isArray(P))throw Error("Rip App: renderer route state layouts must be an array");let W=h.map(function(S1){return S1.file}),s1=S;if(S=null,s1==null&&l!=null&&d!=null&&o1.file===d.file){if(R([...P,o1.file],W)&&p(n1,d.params)){if(!(p(v,d.query)||y(h,n1,v))){if(typeof l.load==="function")await l.load(n1,v);if(i1!==c)return null;return d={file:o1.file,params:n1,query:v},l}}}let L=[...P,o1.file],U=d!=null&&P.length>0&&h.length===P.length+1&&R(P,W.slice(0,-1))&&!y(h.slice(0,-1),n1,v),e1=s1!=null?Math.max(0,Math.min(s1,L.length-1)):U?P.length:0;if(s1!=null&&e1>0){if(!(h.length===L.length&&R(L.slice(0,e1),W.slice(0,e1))))e1=0}let m1=[];for(let S1=0;S10){if(l1=U?A(m1.slice(0,r1),Q):M(m1.slice(0,r1),Q,i1),l1)return null}}throw Q}let d1=K(),R1=d1,E1=[],A1=e1>0?m1[e1-1].instance:null,k1=e1>0,w1=k1?V(A1,s):s;try{for(let S1=m1.slice(e1),q1=0;q10)q(xt,R1);if(c1.mount?.(R1),c1._state==="failed")throw Error(`Rip App: component '${xt.file}' failed during mount`);if(e1+q11?R1:w1,h=m1,d={file:o1.file,params:n1,query:v};let y1=N(p1);if(g=y1.length>0,y1.length)for(let S1 of y1)if(Q=De("","",S1),a!=null)try{a(Q)}catch(q1){console.error("[Rip] renderer teardown reporter failed:",q1)}else console.error("[Rip] renderer teardown error:",Q);return l},w=function(z){let i1,X,r1=z?.route;if(!r1?.file)return;let Q=z.params??{},l1=z.query??{},c1=z.layouts??r1.layouts??[],F=h.map(function(n1){return n1.file}),J=d!=null&&R(c1,F.slice(0,-1));if(J&&r1.file===d.file&&p(Q,d.params))return;let o1=J?[r1.file]:[...c1,r1.file];try{i1=(()=>{let n1=[];for(let v of o1)n1.push({file:v,cls:ti(n,v)});return n1})(),X=m(i1,Q,l1)}catch(n1){return}for(let n1 of X)n1.cell.preload().catch(function(){return null});return},D=function(z,i1){if(!(z!=null&&typeof z==="object"&&typeof i1==="string"))return null;let X=function(r1){return typeof r1==="function"&&r1.__hmrId===i1};if(X(z.default))return z.default;for(let r1 in z){let Q=z[r1];if(X(Q))return Q}return null},B=function(z){let i1=z+"#",X=[];for(let Q of h)if(Q.file===z&&Q.instance!=null)X.push(Q.instance);for(let[Q,l1]of jn())if(typeof Q==="string"&&Q.startsWith(i1)){for(let c1 of l1.instances)if(!X.includes(c1))X.push(c1)}let r1=[];for(let Q of X)r1.push({instance:Q,entry:h.find(function(l1){return l1.instance===Q})??null});return r1},a1=function(z,i1){let X,r1,Q,l1,c1=(()=>{let n1=[];for(let v of z)if(typeof v==="string"&&v.endsWith(".rip"))n1.push(v);return n1})();if(!(c1.length>0))return"unknown";let F=0,J=!1,o1=new Set;for(let n1 of c1){if(l1=i1.getCompiled(n1),Q=B(n1),l1==null){if(typeof i1.exists==="function"&&!i1.exists(n1)){if(Q.some(function(v){return v.instance._state!=="unmounted"}))return"fallback"}else J=!0;continue}for(let{instance:v,entry:P}of Q){if(o1.has(v))continue;if(v._state==="unmounted")continue;if(v._state!=="mounted")return"fallback";if(r1=v.constructor?.__hmrId,X=typeof r1==="string"?D(l1,r1):null,X==null)return"fallback";if(St(X),Rt(v.constructor,X)!=="patch")return"fallback";if(Bn(v,X),o1.add(v),F+=1,P!=null){if(P.cls=X,P!==h[h.length-1])t1()}}}if(F>0)return"done";return J?"unknown":"idle"},h1=async function(z,i1=n){let X,r1,Q,l1,c1;if(!(Array.isArray(z)&&z.length>0))return"noop";for(let U of z)if(U==="stash.rip"||U.startsWith("stash/")||U==="seed.rip")return"escape";let F=r.current;if(!(F?.route?.file&&h.length>0))return"noop";let o1=[...F.layouts??F.route.layouts??[],F.route.file],n1=R(o1,h.map(function(U){return U.file})),v=Fn();try{if(c1=a1(z,i1),c1==="done")return Tr(v),"narrow";if(c1==="idle"&&n1)return ke("noop",{paths:[...z]}),"noop"}catch(U){console.error("[Rip] HMR patch failed; falling back to remount:",U),ke("reject",{reason:"patch-failed",paths:[...z],message:U?.message?String(U.message):String(U)})}let P=new Set(z),W=-1;for(let U=0;U{try{return await C(z,l1,i1)}catch(c1){if(X=c1,l1!==c)return null;if(r1=(()=>{if(X?.name==="GateFailure")return X;else return Q=z?.route?.file??"",De(X?.path??Q,Q,X)})(),a?.(r1),l==null)G(r1);throw r1}finally{if(l1===c&&(Array.isArray(r)||typeof r==="string"?r.includes("navigating"):("navigating"in r)))r.navigating=!1}})()};let f1=null;return f1={current:null,mount:t,preload:w,remountDirty:h1,start(){if(f)return f1;return r.init?.(),f=$1(function(){let z=r.current;if(z?.route)t(z).catch(function(){return null});return}),f1},stop(){let z,i1;if(c++,f?.(),f=null,Array.isArray(r)||typeof r==="string"?r.includes("navigating"):("navigating"in r))r.navigating=!1;try{x()}catch(X){throw z=X,i1=De("","",z),a?.(i1),i1}return}},Object.defineProperty(f1,"current",{get(){return l}}),f1}var vo,Oo,ri=Symbol.for("rip.app.stash.persisted"),Ao=Symbol.for("rip.app.stash.purge");Oo=function(e,t){return D1(t)?void 0:t};vo=function(e){if(e.storage!=null)return e.storage;if(!(typeof window<"u"&&window.localStorage!=null))throw Error("Rip App: persistStash requires a browser or an injected storage");return e.local?window.localStorage:window.sessionStorage};function xr(e,t={}){let r,i=Te(e)||e;if(i[ri])return function(){return null};i[ri]=!0;let n=vo(t),s=t.key||"__rip_app",a=t.debounce??2000;try{if(r=n.getItem(s),r)Ye(e,JSON.parse(r))}catch(u){}let o=null,l=function(){o=null;try{n.setItem(s,JSON.stringify(Te(e),Oo))}catch(u){}return},c=!1,f=$1(function(){if(qn.value,!c){c=!0;return}if(o!=null)clearTimeout(o);return o=setTimeout(l,a),function(){return o!=null?clearTimeout(o):void 0}});if(typeof window<"u")window.addEventListener("beforeunload",l);Object.defineProperty(i,Ao,{value(){if(o!=null)clearTimeout(o),o=null;try{n.removeItem(s)}catch(u){}return},configurable:!0,writable:!0});let h=!1;return function(){if(h)return;if(h=!0,f?.(),typeof window<"u")window.removeEventListener("beforeunload",l);l(),i[Ao]=null,i[ri]=!1;return}}var Io,ni;ni=function(e){if(e.hasAttribute?.("data-router-ignore"))return!0;if(e.hasAttribute?.("download"))return!0;let t=e.getAttribute?.("target");if(t&&t.toLowerCase()!=="_self")return!0;return!1};function It(e){let t,r=e.getAttribute?.("href")??e.href;if(!(typeof r==="string"&&r.length>0))return null;if(/^[a-z][a-z0-9+.-]*:/i.test(r)){if(t=typeof location<"u"?location.origin:null,!(t!=null&&r.startsWith(t)))return null;r=r.slice(t.length)}if(r.startsWith("//")||r.includes("\\"))return null;return r}function $t(e,t){if(t==null)return!1;if(ni(t))return!1;let r=It(t);if(r==null)return!1;return e.claims(r)!=null}Io=function(){if(!(typeof document<"u"&&typeof document.querySelectorAll==="function"))throw Error("Rip App: ariaCurrent requires a browser or an injected host");return{anchors(){return Array.from(document.querySelectorAll("a[href]"))},observe(e){if(typeof MutationObserver>"u")return null;let t=!1,r=new MutationObserver(function(){if(t)return;return t=!0,requestAnimationFrame(function(){return t=!1,e()})});return r.observe(document.documentElement??document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["href","target","download","data-router-ignore"]}),function(){return r.disconnect()}}}};function Cr(e,t=null){if(!(e!=null&&typeof e.claims==="function"))throw TypeError("Rip App: ariaCurrent requires a router");t=t??Io();let r=new WeakMap,i=function(){let l,c,f,h,u=e.path;for(let d of t.anchors()){if(l=ni(d)?null:e.claims(It(d)??""),f=l==null||u==null?null:l.path===u?"page":l.path!=="/"&&u.startsWith(l.path+"/")?"true":null,c=d.getAttribute?.("aria-current")??null,h=r.get(d),h!==void 0&&c!==h){if(r.delete(d),c!=null)continue;h=void 0}if(f!=null){if(h===void 0&&c!=null)continue;if(c!==f)d.setAttribute("aria-current",f);r.set(d,f)}else if(h!==void 0)d.removeAttribute("aria-current"),r.delete(d)}return},n=function(){try{i()}catch(l){console.error("[Rip] aria-current walk failed:",l)}return},s=$1(function(){return e.path,n()}),a=t.observe?.(n)??null,o=!1;return function(){if(o)return;o=!0,s(),a?.();try{for(let l of t.anchors())if(r.has(l)){if((l.getAttribute?.("aria-current")??null)===r.get(l))l.removeAttribute("aria-current");r.delete(l)}}catch(l){}return}}var $o,Do,ii,si;Do=50;$o=3000;si=function(){if(!(typeof document<"u"&&typeof document.addEventListener==="function"))throw Error("Rip App: link listeners require a browser or an injected host");return{listen(e,t,r=null){return document.addEventListener(e,t,r??!1),function(){return document.removeEventListener(e,t,r??!1)}}}};ii=function(e){while(e!=null&&e.tagName!=="A")e=e.parentElement;return e??null};function Pr(e,t=null){if(!(e!=null&&typeof e.claims==="function"&&typeof e.push==="function"))throw TypeError("Rip App: interceptClicks requires a router");t=t??si();let r=function(s){if(s.defaultPrevented)return;if(s.button!==0||s.metaKey||s.ctrlKey||s.shiftKey||s.altKey)return;let a=ii(s.target);if(!(a!=null&&$t(e,a)))return;let o=e.claims(It(a));if(o==null)return;s.preventDefault(),e.push(o.url,{noScroll:a.hasAttribute?.("data-router-noscroll")===!0});return},i=t.listen("click",r),n=!1;return function(){if(n)return;n=!0,i();return}}function Lr(e,t,r=null){if(!(e!=null&&typeof e.claims==="function"))throw TypeError("Rip App: preloadLinks requires a router");if(!(t!=null&&typeof t.preload==="function"))throw TypeError("Rip App: preloadLinks requires a renderer with preload()");r=r??si();let i=null,n=null,s={href:null,at:0},a=function(){if(i!=null)clearTimeout(i);i=null,n=null;return},o=function(h){let u=ii(h.target);if(!(u!=null&&$t(e,u)))return;if(u===n)return;a(),n=u;let d=It(u);i=setTimeout(function(){i=null,n=null;let S=Date.now();if(d===s.href&&S-s.at<$o)return;s.href=d,s.at=S;let g=e.claims(d);return g!=null?t.preload(g):void 0},Do);return},l=function(h){if(n==null)return;let u=h.relatedTarget;if(!(u!=null&&n.contains?.(u)))a();return},c=[r.listen("pointerover",o,{passive:!0}),r.listen("focusin",o,{passive:!0}),r.listen("pointerout",l,{passive:!0}),r.listen("focusout",l,{passive:!0})],f=!1;return function(){if(f)return;f=!0,a();for(let h of c)h();return}}var qe,xo,z1,Co;qe="routes";z1=function(e){throw Error(`Rip App: ${e}`)};var pc=function(e){let t;if(!(e!=null&&typeof e==="object"&&!Array.isArray(e)))z1("launch requires a bundle object");for(let r of["modules","compiled"]){if(t=e[r],t==null)continue;if(!(typeof t==="object"&&!Array.isArray(t)))z1(`launch bundle ${r} must be an object of store paths`)}if(e.seed!=null&&(typeof e.seed!=="object"||Array.isArray(e.seed)))z1("launch bundle seed must be an object");return e},gc=["read","write","del","exists","size","list","listAll","load","watch","getCompiled","setCompiled"];Co=function(e){if(!(typeof e==="object"&&!Array.isArray(e)))z1("launch components must be an object");for(let t of gc)if(typeof e[t]!=="function")z1(`launch components store is missing '${t}'`);return e};var ai=function(e,t=null){let r=pc(e),n=[...new Set([...Object.keys(r.modules??{}),...Object.keys(r.compiled??{})])].filter(function(o){return o.startsWith(qe+"/")});Ot(n,qe);let s=r.compiled?.["stash.rip"],a=t??s?.stash;if(a==null&&s!=null)z1("the bundle's 'stash.rip' module must export 'stash'");if(a!=null&&(typeof a!=="object"||Array.isArray(a)))z1("the application stash must be a plain object");return{bundle:r,declaration:a}};xo=function(){if(!(typeof document<"u"&&typeof document.querySelector==="function"))z1("launch requires a target outside the browser");let e=document.querySelector("#app");if(!e)e=document.createElement("div"),e.id="app",document.body.appendChild(e);return e};function Mr(e){let t,r;if(!(e!=null&&typeof e==="object"))z1("launch requires an options object");if(globalThis.__ripStash!=null)z1("an application is already launched; destroy it first");let i=ai(e.bundle,e.declaration),n=i.bundle,s=e.target??xo(),a=e.adapter??$r(),o=i.declaration,l=Nr(_r(o??{}));Ye(l,n.seed??{}),ho(l);let c=e.components!=null?Co(e.components):vr();if(n.modules!=null)c.load(n.modules);if(n.compiled!=null){let b=n.compiled;for(let _ in b){if(!Object.hasOwn(b,_))continue;let y=b[_];if(!c.exists(_))c.write(_,"");c.setCompiled(_,y)}}let f=Ir({routes(){return Ot(c.listAll(qe),qe)},adapter:a,base:e.base,hash:e.hash,onError:e.onError}),h=Dr({router:f,stash:l,components:c,target:s,onError:e.onError}),u=c.watch(function(b,_){return _.startsWith(qe+"/")?f.rebuild():void 0}),d=null;if(e.links!=null||typeof document<"u"&&typeof document.addEventListener==="function")t=Pr(f,e.links),r=Lr(f,h,e.links),d=function(){t(),r();return};let S=null;if(typeof document<"u"&&typeof document.querySelectorAll==="function")S=Cr(f);let g=null;if(e.persist)g=xr(l,{local:e.persist==="local",key:"__rip_app",storage:e.storage});let p=!1,R=function(){if(p)return;p=!0;let b=[],_=function(y){try{y()}catch(m){b.push(m)}return};if(_(function(){return S?.()}),_(function(){return d?.()}),_(function(){return h.stop()}),_(function(){return f.destroy()}),_(function(){return u()}),_(function(){return g?.()}),globalThis.__ripStash===l)delete globalThis.__ripStash;if(globalThis.__ripRouter===f)delete globalThis.__ripRouter;if(b.length===1)throw b[0];if(b.length>1)throw AggregateError(b,"Rip App: launch.destroy failed");return};globalThis.__ripStash=l,globalThis.__ripRouter=f;try{if(typeof s.replaceChildren==="function")s.replaceChildren();else if(Array.isArray(s.children))s.children.length=0;h.start()}catch(b){throw R(),b}return{stash:l,components:c,router:f,renderer:h,destroy:R}}var oi,jr,li,ci,fi,B1;B1=function(e){if(!(typeof e==="string"&&e.length>0))throw TypeError("Rip Workspace: component path must be a non-empty string");let t=e.split("/"),r=t.some(function(s){return!s||s==="."||s===".."||s.startsWith(".")}),i=t.at(-1),n=t.slice(0,-1).some(function(s){return s.endsWith(".rip")});if(e.includes("\\")||e.startsWith("/")||r||n||i===".rip"||!i.endsWith(".rip"))throw TypeError(`Rip Workspace: invalid component path '${e}'`);return e};jr=function(e){if(typeof e!=="string")throw TypeError("Rip Workspace: component source must be a string");return e};li=function(e){if(e===""||e==null)return"";if(typeof e!=="string")throw TypeError("Rip Workspace: component directory must be a string");let t=e.split("/");if(e.includes("\\")||e.startsWith("/")||t.some(function(r){return!r||r==="."||r===".."||r.startsWith(".")}))throw TypeError(`Rip Workspace: invalid component directory '${e}'`);return e};ci=function(e){if(!(typeof e==="string"&&/^[A-Za-z0-9_]{6}$/.test(e)))throw TypeError("Rip Workspace: publication hash must be six Base64URL-folded characters");return e};fi=function(e){if(!(e!=null&&typeof e==="object"&&!Array.isArray(e)))throw TypeError("Rip Workspace: compiled component module must be an object");return e};oi=function(e){let t;if(!(e!=null&&typeof e==="object"&&!Array.isArray(e)))throw TypeError("Rip Workspace: prepared state must be an object");let r=ci(e.hash);if(!(e.sources!=null&&typeof e.sources==="object"&&!Array.isArray(e.sources)))throw TypeError("Rip Workspace: prepared sources must be an object");if(!(e.compiled!=null&&typeof e.compiled==="object"&&!Array.isArray(e.compiled)))throw TypeError("Rip Workspace: prepared compiled modules must be an object");let i=new Map,n=new Map,s=e.sources;for(let o in s){if(!Object.hasOwn(s,o))continue;let l=s[o];i.set(B1(o),jr(l))}let a=e.compiled;for(let o in a){if(!Object.hasOwn(a,o))continue;let l=a[o];if(o=B1(o),!i.has(o))throw Error(`Rip Workspace: compiled module '${o}' has no source`);n.set(o,fi(l))}return{hash:r,sources:i,compiled:n}};function Fr(){let e,t=new Map,r=new Map,i=new Set,n=null,s=!1,a=function(l,c){for(let f of Array.from(i))try{f(l,c)}catch(h){console.error("[Rip] workspace watcher error:",h)}return},o=function(l){t=l.sources,r=l.compiled,n=l.hash;return};return e={read(l){return t.get(B1(l))},write(l,c){if(s)throw Error("Rip Workspace: cannot write during a publication transition");l=B1(l),c=jr(c);let f=t.has(l)?"change":"create";t.set(l,c),r.delete(l),a(f,l);return},del(l){if(s)throw Error("Rip Workspace: cannot delete during a publication transition");l=B1(l),t.delete(l),r.delete(l),a("delete",l);return},exists(l){return t.has(B1(l))},size(){return t.size},list(l=""){let c;l=li(l);let f=l?l+"/":"",h=[];for(let[u]of t)if(u.startsWith(f)){if(c=u.slice(f.length),!c.includes("/"))h.push(u)}return h},listAll(l=""){l=li(l);let c=l?l+"/":"",f=[];for(let[h]of t)if(h.startsWith(c))f.push(h);return f},load(l){if(s)throw Error("Rip Workspace: cannot load during a publication transition");if(!(l!=null&&typeof l==="object"&&!Array.isArray(l)))throw TypeError("Rip Workspace: component load expects a source object");let c=[];for(let f in l){if(!Object.hasOwn(l,f))continue;let h=l[f];c.push([B1(f),jr(h)])}for(let[f,h]of c)t.set(f,h),r.delete(f);return},watch(l){if(typeof l!=="function")throw TypeError("Rip Workspace: component watch expects a function");i.add(l);let c=!1;return function(){if(c)return;c=!0,i.delete(l);return}},getCompiled(l){return r.get(B1(l))},setCompiled(l,c){if(s)throw Error("Rip Workspace: cannot compile during a publication transition");if(l=B1(l),!t.has(l))throw Error(`Rip Workspace: setCompiled for unknown component path '${l}'`);r.set(l,fi(c));return},hash(){return n},activate(l){if(n!=null)throw Error("Rip Workspace: a publication is already active");if(s)throw Error("Rip Workspace: a publication transition is already staged");o(oi(l));return},stage(l,c,f){if(s)throw Error("Rip Workspace: a publication transition is already staged");if(l=ci(l),n!==l)throw Error(`Rip Workspace: change starts at ${l}, not ${n}`);if(!Array.isArray(f))throw TypeError("Rip Workspace: changed paths must be an array");let h=f.map(function(p){return B1(p)});if(new Set(h).size!==h.length)throw Error("Rip Workspace: changed paths must be unique");let u=oi(c),d={sources:t,compiled:r,hash:n};s=!0;let S=!1,g=function(p){let R;if(S)throw Error("Rip Workspace: publication transition is already finished");if(S=!0,s=!1,!p)return;o(u);for(let b of h)R=!u.sources.has(b)?"delete":d.sources.has(b)?"change":"create",a(R,b);return};return{components:{getCompiled(p){return u.compiled.get(B1(p))},exists(p){return u.sources.has(B1(p))}},commit(){return g(!0)},rollback(){return g(!1)}}},commit(l,c,f){e.stage(l,c,f).commit();return}},e}var Po,Lo,Mo,jo,Fo,Bo,Uo,Br;Mo=250;Lo=8000;Po=5000;Uo=0;Br=function(e){return typeof e==="string"&&/^[A-Za-z0-9_]{6}$/.test(e)};Fo=function(){if(typeof location>"u")throw Error("Rip App: connectFeed needs a hub URL (no location to derive one from)");return`${location.protocol==="https:"?"wss":"ws"}://${location.host}/hub`};Bo=function(){if(typeof WebSocket>"u")throw Error("Rip App: connectFeed needs a socket factory (no global WebSocket)");return function(e){return new WebSocket(e)}};jo=function(){if(typeof fetch>"u")throw Error("Rip App: connectFeed needs a fetch (no global fetch)");return function(e,t){return fetch(e,t)}};function Ur(e,t={}){let r;if(!(e!=null&&typeof e.hash==="function"&&typeof e.apply==="function"&&typeof e.reload==="function"))throw TypeError("Rip App: connectFeed expects hash, apply, and reload callbacks");if(!Br(e.hash()))throw TypeError("Rip App: connectFeed client hash must be six Base64URL-folded characters");let i=t.hub??Fo(),n=t.latestUrl??"/latest.json",s=t.makeSocket??Bo(),a=t.fetch??jo(),o=t.report??function(...M){return console.error(...M)},l=t.backoff?.min??Mo,c=t.backoff?.max??Lo,f=t.ackTimeout??Po,h=!1,u=!1,d=!1,S=!1,g=null,p=0,R=null,b=null,_=0,y=null,m=[],k=Promise.resolve(),O=new Map,N=null,x=function(M){if(u||h)return;u=!0,e.reload(M);return},I=async function(M){let A;if(u||h)return!1;return await(async()=>{try{if(A=await e.apply(M),A==="rejected"){if(Br(M?.hash))N=M?.hash;return!1}if(A==="reload"||!A)return x("change could not be applied"),!1;return N=null,!0}catch(C){return o("[Rip] publication change failed:",C),x("change failed"),!1}})()},H=function(M,A){k=k.then(async function(){if(A!==_)return!0;return await I(M)}),k=k.catch(function(C){return o("[Rip] publication queue failed:",C),x("change queue failed"),!1});return},G=async function(M){let A,C;if(h||u||M!==_)return;let w=e.hash(),D=await a(n,{cache:"no-store"});if(!D?.ok)throw Error(`latest.json fetch failed (${D?.status})`);let B=await D.json();if(!(B!=null&&typeof B==="object"&&!Array.isArray(B)&&Object.keys(B).length===1&&Object.hasOwn(B,"hash")&&Br(B.hash)))throw Error("latest.json is malformed");if(h||u||M!==_)return;if(N!=null){if(B.hash!==N){x(`a newer App generation followed rejected ${N}`);return}m=[],S=!0,p=0;return}let a1=new Set([w]),h1=0;while(h1{try{return g?.close()}catch{}})()}),k=C.then(function(){return!0},function(){return!1}),O.set(M,C),C.finally(function(){return O.get(M)===C?O.delete(M):void 0}),C},Z=function(M,A){if(A!==_)return;let C=null;try{C=JSON.parse(M)}catch{o("[Rip] publication feed received invalid JSON:",M),x("malformed publication frame");return}let w=Array.isArray(C)?C:[C];for(let D of w){if(!(D!=null&&typeof D==="object"))continue;if(Object.keys(D).length===1&&Object.hasOwn(D,"!")&&D["!"]===y&&b!=null){if(b!=null)clearTimeout(b),b=null;K(_)}else if(D.change!==void 0&&!Object.hasOwn(D,"<"))if(N!=null){if(D.change?.hash===N)continue;if(S)H(D.change,A);else m.push(D.change)}else if(S)H(D.change,A);else m.push(D.change);else if(D.reload!==void 0&&!Object.hasOwn(D,"<"))if(N!=null)K(A,!0);else x("server generation changed")}return},V=function(){if(h||u||R!=null)return;let M=Math.min(l*2**p,c);p+=1,R=setTimeout(function(){return R=null,r()},M);return};r=function(){if(h||u)return;_+=1;let M=_;S=!1,m=[],y=`rip-${++Uo}`;try{g=s(i)}catch(A){o("[Rip] publication socket open failed:",A),V();return}g.onmessage=function(A){Z(String(A.data),M);return},g.onopen=function(){if(M!==_||h)return;d=!0;try{g.send(JSON.stringify({"+":["/hub"],"?":y}))}catch(A){o("[Rip] publication subscription failed:",A);try{g.close()}catch{}return}b=setTimeout(function(){if(h||u||M!==_||S)return;return o("[Rip] publication subscription acknowledgement timed out"),(()=>{try{return g.close()}catch{}})()},f);return},g.onclose=function(){if(M!==_)return;if(d=!1,S=!1,b!=null)clearTimeout(b),b=null;V();return},g.onerror=function(){return};return};let j=function(){if(h||u)return;if(g!=null)try{g.close()}catch{}else V();return},q=[],t1=function(M,A,C){if(typeof M?.addEventListener!=="function")return;M.addEventListener(A,C),q.push(function(){return M.removeEventListener(A,C)});return};if(t1(globalThis,"online",function(){return j()}),t1(globalThis,"pageshow",function(M){return M.persisted===!0?j():void 0}),typeof document<"u")t1(document,"visibilitychange",function(){return document.visibilityState==="visible"?j():void 0});return r(),{close(){if(h)return;if(h=!0,_+=1,R!=null)clearTimeout(R);if(b!=null)clearTimeout(b);for(let M of q)M();try{g?.close()}catch{}return},connected(){return d&&S&&!h&&!u},resync(){return j()}}}function Vr(e){if(!(e!=null&&typeof e==="object"))throw TypeError("Rip App: createApply expects an options object");if(typeof e.renderer?.remountDirty!=="function")throw TypeError("Rip App: createApply requires renderer.remountDirty");if(typeof e.escape!=="function")throw TypeError("Rip App: createApply requires an escape remount");let t=e.report??function(...i){return console.log(...i)};return{absorb:async function(i,n=null){if(!(Array.isArray(i)&&i.length>0))return"ignore";let s=(()=>{let f=[];for(let h of i)if(typeof h==="string"&&h.endsWith(".css"))f.push(h);return f})(),a=(()=>{let f=[];for(let h of i)if(typeof h==="string"&&h.endsWith(".rip"))f.push(h);return f})(),o=(()=>{let f=[];for(let h of i)if(typeof h==="string"&&!h.endsWith(".rip")&&!h.endsWith(".css"))f.push(h);return f})();if(a.length===0){if(o.length>0)return"reload";if(s.length>0)return"css";return"ignore"}let l=await e.renderer.remountDirty(a,n);if(l==="narrow")return t(`[Rip] applied ${a.join(", ")} — update`),"update";if(l==="reload")return t(`[Rip] applied ${a.join(", ")} — reload`),"reload";if(l==="noop")return"ignore";if(await e.escape(a,n)==="reload")return"reload";return t(`[Rip] applied ${a.join(", ")} — update`),"update"}}}var bc=function(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError("Rip App: rash expects bytes")},yc=function(e){let t,r,i,n,s,a,o,l,c,f,h,u,d,S,g,p,R=bc(e);if(typeof Bun<"u"&&Bun.CryptoHasher!=null)return new Uint8Array(new Bun.CryptoHasher("sha256").update(R).digest());let b=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],_=R.length*8,y=new Uint8Array(R.length+9+63&-64);y.set(R),y[R.length]=128;let m=new DataView(y.buffer);m.setUint32(y.length-4,_>>>0,!1),m.setUint32(y.length-8,Math.floor(_/4294967296)>>>0,!1);let k=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],O=function(G,K){return G>>>K|G<<32-K},N=new Uint32Array(64),x=0;while(x>>3,S=O(N[G-2],17)^O(N[G-2],19)^N[G-2]>>>10,N[G]=N[G-16]+d+N[G-7]+S>>>0;[i,n,s,o,l,c,f,h]=k;for(let G=0;G<64;G++)r=O(l,6)^O(l,11)^O(l,25),a=l&c^~l&f,g=h+r+a+b[G]+N[G]>>>0,t=O(i,2)^O(i,13)^O(i,22),u=i&n^i&s^n&s,p=t+u>>>0,h=f,f=c,c=l,l=o+g>>>0,o=s,s=n,n=i,i=g+p>>>0;k[0]=k[0]+i>>>0,k[1]=k[1]+n>>>0,k[2]=k[2]+s>>>0,k[3]=k[3]+o>>>0,k[4]=k[4]+l>>>0,k[5]=k[5]+c>>>0,k[6]=k[6]+f>>>0,k[7]=k[7]+h>>>0,x+=64}let I=new Uint8Array(32),H=new DataView(I.buffer);for(let G=0;G<8;G++)H.setUint32(G*4,k[G],!1);return I},Dt=function(e){let t=yc(e),r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";return(r[t[0]>>2]+r[(t[0]&3)<<4|t[1]>>4]+r[(t[1]&15)<<2|t[2]>>6]+r[t[2]&63]+r[t[3]>>2]+r[(t[3]&3)<<4|t[4]>>4]).replaceAll("-","_")},Wr=function(e){let t=JSON.stringify(e.map(function(r){return[r.id,r.hash]}));return Dt(new TextEncoder().encode(t))};var Sc=function(){return globalThis.__ripStash},Rc=function(){return globalThis.__ripRouter};(()=>{if(typeof document>"u"||typeof WebSocket>"u")return;let e=document.currentScript;if(!(e?/\bwatch\.js\b/.test(e.src||""):!!document.querySelector("script[watch]"))||globalThis.__ripWatch)return;globalThis.__ripWatch=!0;let r=location.pathname,i=(f)=>Array.isArray(f)&&(f.includes(r)||r.endsWith("/")&&f.includes(r+"index.html")),n=(f)=>f.headers.get("etag")||f.headers.get("last-modified")||"",s=null;fetch(location.href,{method:"HEAD",cache:"no-store"}).then((f)=>{s=n(f)}).catch(()=>{});let a=()=>{if(s===null)return;fetch(location.href,{method:"HEAD",cache:"no-store"}).then((f)=>{if(n(f)!==s)location.reload()}).catch(()=>{})},o=!1,l=0,c=()=>{let f=location.protocol==="https:"?"wss://":"ws://",h=new WebSocket(f+location.host+"/hub");h.onopen=()=>h.send('{"+":["/assets"],"?":"observe"}'),h.onmessage=(u)=>{let d;try{d=JSON.parse(u.data)}catch{return}for(let S of Array.isArray(d)?d:[d]){if(!S||typeof S!=="object"||"<"in S)continue;if("!"in S){if(o)a();o=!0,l=0}if(i(S.touched))location.reload()}},h.onclose=()=>{if(l+=1,!o&&l>=6)return;setTimeout(c,Math.min(8000,500*2**(l-1)))},h.onerror=()=>{}};c()})();var{__hmrEmit:Ec}=Et;function ui(e,t={}){if(t.face==="ts")throw Error("rip: TypeScript face is unavailable in the browser");return fa(e,{...t,face:"js"})}var Yo={intrinsics:ir,stdlib:sr,schema:fr,reactive:gr,components:Et},zo=Object.freeze({...ir,...sr,...fr,...gr,...Et}),kc=Object.freeze({rash:Dt,check:Wr}),qo=Object.freeze({"rip/app":Hr,"rip/app/rash":kc});var Tc=new Map(Object.keys(Yo).map((e)=>[new URL(`./runtime/${e}.js`,import.meta.url).pathname,e])),wc=/(?:^|\/)src\/runtime\/(intrinsics|stdlib|schema|reactive|components)\.js$/,Gr="__ripModuleBridge",_c=(e)=>e.slice(1,-1),Vo=(e,t)=>{let r=e.split("/").slice(0,-1);for(let i of t.split("/")){if(i===""||i===".")continue;if(i===".."){if(!r.length)return null;r.pop()}else r.push(i)}return r.join("/")},Wo=(e)=>{if(typeof URL<"u"&&typeof URL.createObjectURL==="function"&&typeof Blob<"u")return URL.createObjectURL(new Blob([e],{type:"text/javascript"}));return`data:text/javascript;base64,${btoa(unescape(encodeURIComponent(e)))}`};function Xo({components:e,embeddedPackages:t={},debug:r=!1,hmr:i=!1}={}){if(!e||typeof e.read!=="function")throw TypeError("rip: createModuleLoader requires a component registry");let n=new Map,s=new Map,a=new Map,o=new Map,l=new Map,c=new Set,f=(g)=>{if(typeof g==="string"&&g.startsWith("blob:")&&typeof URL?.revokeObjectURL==="function")URL.revokeObjectURL(g)},h=async()=>{let g=[...c];c.clear(),await Promise.allSettled(g.map(async(p)=>f(await p)))},u=(g,p)=>{if(a.has(g))return a.get(g);globalThis[Gr]??={};let R=globalThis[Gr][g];if(R&&R!==p)throw Error(`rip: two copies of embedded module '${g}' are active on one page`);globalThis[Gr][g]=p;let b=[`const ns = globalThis['${Gr}'][${JSON.stringify(g)}];`];for(let y of Object.keys(p))if(y==="default")b.push("export default ns['default'];");else if(/^[A-Za-z_$][\w$]*$/.test(y))b.push(`export const ${y} = ns[${JSON.stringify(y)}];`);else throw Error(`rip: embedded module '${g}' exports '${y}', which cannot cross the module bridge`);let _=Wo(b.join(` +`+h+"}"}return null};return(s)=>{let a=n(s,0);if(a!==null)console.log(a);else console.dir(s,{depth:null,colors:!0});return s}})(),Ra=(e,t)=>{throw t!==void 0?new e(t):Error(e)},Ea=(e,t)=>t!==void 0?(e>t&&([e,t]=[t,e]),Math.floor(Math.random()*(t-e+1)+e)):e?Math.floor(Math.random()*e):Math.random(),ka=(e)=>new Promise((t)=>setTimeout(t,e)),Ta=(e)=>{throw Error(e||"Not implemented")},wa=(...e)=>console.warn(...e),_a=(...e)=>e[0].map((t,r)=>e.map((i)=>i[r])),Na=(e)=>{if(typeof e==="string")return e;if(e==null)return"";if(typeof e==="number"||typeof e==="bigint"||typeof e==="boolean")return String(e);if(typeof e==="symbol")return e.description||"";if(e instanceof Uint8Array||e instanceof ArrayBuffer)return new TextDecoder().decode(e instanceof Uint8Array?e:new Uint8Array(e));if(Array.isArray(e))return e.join(",");if(typeof e.toString==="function"&&e.toString!==Object.prototype.toString)try{return e.toString()}catch{return""}return""};var fr={};xe(fr,{SchemaDef:()=>gt,SchemaError:()=>v1,SchemaRegistry:()=>ee,__schema:()=>M3,installPersistence:()=>D3,registerCoercer:()=>C3});var $a=Symbol.for("rip.runtime.schema");if(globalThis[$a])throw Error("two copies of the Rip schema runtime loaded in one process — schemas from different copies "+"cannot see each other (separate registries, distinct SchemaError classes). Run .rip sources through the rip CLI/loader (one shared runtime module per process), or load only one standalone-compiled file per process.");globalThis[$a]=!0;var Se=null;function D3(e){if(Se&&Se!==e)throw Error("the Rip schema persistence runtime is already installed — two different copies met in one process");Se=e}class v1 extends Error{constructor(e,t,r){super(x3(e,t));this.name="SchemaError",this.issues=e,this.schemaName=t||null,this.schemaKind=r||null}}function x3(e,t){if(!e||!e.length)return"SchemaError";return(t?t+": ":"")+e.map((i)=>i.message||i.error||"invalid").join("; ")}var Da={__proto__:null,string:(e)=>typeof e==="string",number:(e)=>typeof e==="number"&&!Number.isNaN(e),integer:(e)=>Number.isInteger(e),boolean:(e)=>typeof e==="boolean",date:(e)=>e instanceof Date&&!Number.isNaN(e.getTime()),datetime:(e)=>e instanceof Date&&!Number.isNaN(e.getTime()),email:(e)=>typeof e==="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),url:(e)=>typeof e==="string"&&/^https?:\/\/.+/.test(e),uuid:(e)=>typeof e==="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e),phone:(e)=>typeof e==="string"&&/^[\d\s\-+()]+$/.test(e),zip:(e)=>typeof e==="string"&&/^\d{5}(-\d{4})?$/.test(e),text:(e)=>typeof e==="string",json:(e)=>e!==void 0,any:()=>!0},cr={integer(e){if(typeof e==="number")return Number.isInteger(e)?{ok:!0,value:e}:{ok:!1};if(typeof e==="string"&&/^[+-]?\d+$/.test(e.trim()))return{ok:!0,value:parseInt(e.trim(),10)};return{ok:!1}},number(e){if(typeof e==="number")return Number.isNaN(e)?{ok:!1}:{ok:!0,value:e};if(typeof e==="string"&&/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/.test(e.trim()))return{ok:!0,value:Number(e.trim())};return{ok:!1}},boolean(e){if(typeof e==="boolean")return{ok:!0,value:e};if(e==="true"||e==="1"||e===1)return{ok:!0,value:!0};if(e==="false"||e==="0"||e===0)return{ok:!0,value:!1};return{ok:!1}},date(e){if(e instanceof Date)return Number.isNaN(e.getTime())?{ok:!1}:{ok:!0,value:e};if(typeof e==="number"&&Number.isFinite(e))return{ok:!0,value:new Date(e)};let t=typeof e==="string"?/^(\d{4})-(\d{2})-(\d{2})/.exec(e):null;if(t){let r=+t[2],i=+t[3],n=new Date(Date.UTC(+t[1],r,0)).getUTCDate();if(r<1||r>12||i<1||i>n)return{ok:!1};let s=new Date(e);if(!Number.isNaN(s.getTime()))return{ok:!0,value:s}}return{ok:!1}}};cr.datetime=cr.date;function ar(e){if(e!==null&&typeof e==="object"&&!Array.isArray(e))return null;return{field:"",error:"object",message:"input must be an object; got "+(e===null?"null":Array.isArray(e)?"an array":"a "+typeof e)}}var Dn=new Map;function C3(e,t,r){if(typeof e!=="string"||typeof t!=="function")throw Error("registerCoercer(name, fn, opts?): name string and fn required");let i=Object.prototype.toString.call(t);if(i==="[object AsyncFunction]"||i==="[object GeneratorFunction]"||i==="[object AsyncGeneratorFunction]")throw Error("registerCoercer: coercer '~:"+e+"' must be a plain synchronous function");let n=r?.raw===!0,s=Dn.get(e);if(s){if(s.raw===n&&String(s.fn)===String(t))return t;throw Error("registerCoercer: coercer '~:"+e+"' is already registered")}return Dn.set(e,{fn:t,raw:n}),t}function mt(e){if(Da[e])return null;let t=ee.get(e);return t&&(t.kind==="shape"||t.kind==="input"||t.kind==="model"||t.kind==="union")?t:null}function xn(e,t,r){let i=Da[t];if(i)return i(e)?{value:e}:{errors:[{field:"",error:"type",message:"must be "+t}]};let n=ee.get(t);if(!n)return{value:e};if(n.kind==="enum"){let a=n._validateEnum(e,!0);return a.length?{errors:[{field:"",error:"enum",message:a[0].message}]}:{value:n._materializeEnum(e)}}if(n.kind==="mixin")return{errors:[{field:"",error:"type",message:":mixin "+t+" is not usable as a field type"}]};if(n.kind==="union"){let a=n._unionResolve(e);if(a.issue)return{errors:[a.issue]};let o=r?.existing?a.def._runExistingSync(e,{...r,materialize:!1,materializeNested:!1}):a.def._runSync(e,{...r,materialize:!1,materializeNested:!1});if(o.thrown){if(r?.derived==="throw")throw o.thrown;return{errors:[{field:"",error:"derived",message:o.thrown?.message||String(o.thrown)}]}}return o.ok?{value:o.value}:{errors:o.errors}}if(e===null||typeof e!=="object"||Array.isArray(e))return{errors:[{field:"",error:"type",message:"must be a "+t+" object"}]};let s=r?.existing?n._runExistingSync(e,{...r,materialize:!1,materializeNested:!1}):n._runSync(e,{...r,materialize:!1,materializeNested:!1});if(s.thrown){if(r?.derived==="throw")throw s.thrown;return{errors:[{field:"",error:"derived",message:s.thrown?.message||String(s.thrown)}]}}return s.ok?{value:s.value}:{errors:s.errors}}async function Aa(e,t,r){let i=mt(t);if(i===null)return xn(e,t,r);if(i.kind==="union"){let s=i._unionResolve(e);if(s.issue)return{errors:[s.issue]};let a=r?.existing?await s.def._runExistingAsync(e,{...r,materialize:!1,materializeNested:!1}):await s.def._runAsync(e,{...r,materialize:!1,materializeNested:!1});if(a.thrown){if(r?.derived==="throw")throw a.thrown;return{errors:[{field:"",error:"derived",message:a.thrown?.message||String(a.thrown)}]}}return a.ok?{value:a.value}:{errors:a.errors}}if(e===null||typeof e!=="object"||Array.isArray(e))return{errors:[{field:"",error:"type",message:"must be a "+t+" object"}]};let n=r?.existing?await i._runExistingAsync(e,{...r,materialize:!1,materializeNested:!1}):await i._runAsync(e,{...r,materialize:!1,materializeNested:!1});if(n.thrown){if(r?.derived==="throw")throw n.thrown;return{errors:[{field:"",error:"derived",message:n.thrown?.message||String(n.thrown)}]}}return n.ok?{value:n.value}:{errors:n.errors}}function pt(e,t){if(!t)return e;return e+(t.startsWith("[")?t:"."+t)}function or(e,t,r){if(!t)return e+" "+r;if(r.startsWith(t))return e+r.slice(t.length);return e+": "+r}var lr=Symbol("schema.materialization-error");function va(e,t){if(e&&e[lr])return{[lr]:!0,error:e.error,field:pt(t,e.field)};return{[lr]:!0,error:e,field:t}}function Be(e){return e&&e[lr]?{thrown:e.error,derivedField:e.field}:{thrown:e,derivedField:""}}var P3=Je;function Oa(e){let t=(i)=>JSON.stringify(i??null,(n,s)=>s instanceof RegExp?String(s):typeof s==="function"?"":s),r=[e.kind];for(let i of e._desc.entries||[])switch(i.tag){case"field":r.push("f:"+i.name+":"+(i.typeName||"")+(i.array?"[]":"")+":"+(i.modifiers||[]).join("")+(i.literals?":"+i.literals.join(","):"")+":"+t(i.constraints)+(i.coerce?":~"+(i.coercer||""):"")+(i.transform?":t":""));break;case"enum-member":r.push("e:"+i.name+"="+String(i.value));break;case"directive":r.push("d:"+i.name+":"+t(i.args));break;case"ensure":r.push("n:"+(i.message||""));break;default:r.push(i.tag+":"+(i.name||""))}return r.join("|")}var ye=0,ee={_entries:new Map,replace:!1,register(e){if(!e.name)return;ye++;let t=this._entries.get(e.name);if(t&&t.def!==e&&!this.replace){if(Oa(t.def)!==Oa(e))throw new v1([{field:e.name,error:"collision",message:"schema name '"+e.name+"' is already registered with a different definition. Schema names are app-global (they resolve nested field types and @mixin references), so two "+"different schemas cannot share one name. Rename one — or, for dev/HMR reload semantics, set "+"SchemaRegistry.replace = true before re-evaluating modules."}],e.name,e.kind)}this._entries.set(e.name,{def:e,kind:e.kind})},get(e){let t=this._entries.get(e);return t?t.def:null},getKind(e,t){let r=this._entries.get(e);return r&&r.kind===t?r.def:null},has(e){return this._entries.has(e)},names(){return[...this._entries.keys()]},reset(){this._entries.clear(),ye++},scope(e){let t=this._entries;this._entries=new Map,ye++;let r=()=>{this._entries=t,ye++};try{let i=e();if(i&&typeof i.then==="function")return i.finally(r);return r(),i}catch(i){throw r(),i}}};class gt{constructor(e){if(e.kind==="model"&&!Se)throw Error("schema: kind 'model' needs the persistence runtime (src/runtime/orm.js), which is not "+"loaded in this process — reference a persistence name (schema.transaction, __schemaSetAdapter) "+"or import the module directly");if(this._desc=e,this.kind=e.kind,this.name=e.name||null,this._norm=null,this._klass=null,this._unionPlanCache=null,this._sourceModel=null,e.kind==="model")Se.decorateDef(this,e)}_normalize(){if(this._norm)return this._norm;let e=new Map,t=new Map,r=new Map,i=new Map,n=new Map,s=new Map,a=null,o=[],l=new Map,c=[],f=(b,_)=>{throw new v1([{field:b,error:"collision",message:b+" collides with "+_}],this.name,this.kind)},h=(b)=>{if(e.has(b))f(b,"field");if(t.has(b))f(b,"method");if(r.has(b))f(b,"computed");if(i.has(b))f(b,"derived");if(n.has(b))f(b,"hook")},u=(b)=>{throw new v1([{field:"",error:"kind",message:b+" is :model-only (this schema is :"+this.kind+")"}],this.name,this.kind)},d=this.kind==="union"?new Set(["on"]):new Set(["mixin"]),S=(b,_)=>{if(!P3(b))throw new v1([{field:b,error:"invalid-name",message:_+" name '"+b+"' is not canonical camelCase. Use a lowercase-first, alphanumeric identifier with no consecutive uppercase letters (e.g. 'mdmId' not 'mdmID')."}],this.name,this.kind)};for(let b of this._desc.entries)switch(b.tag){case"field":S(b.name,"field"),h(b.name),e.set(b.name,{name:b.name,required:b.modifiers.includes("!"),optional:b.modifiers.includes("?"),unique:b.unique===!0,primary:b.primary===!0,attrs:b.attrs||null,typeName:b.typeName,literals:b.literals||null,array:b.array===!0,coerce:b.coerce===!0,coercer:b.coercer||null,constraints:b.constraints||null,transform:b.transform||null});break;case"method":h(b.name),t.set(b.name,b.fn);break;case"computed":h(b.name),r.set(b.name,b.fn);break;case"derived":h(b.name),i.set(b.name,b.fn);break;case"hook":if(this.kind!=="model")u("lifecycle hook '"+b.name+"'");if(n.has(b.name))f(b.name,"duplicate hook");n.set(b.name,b.fn);break;case"scope":if(this.kind!=="model")u("query scope '@scope :"+b.name+"'");if(s.has(b.name))f(b.name,"scope");s.set(b.name,b.fn);break;case"defaultScope":if(this.kind!=="model")u("@defaultScope");if(a)throw new v1([{field:"",error:"collision",message:"only one @defaultScope per model"}],this.name,this.kind);a=b.fn;break;case"directive":if(this.kind!=="model"&&!d.has(b.name))throw new v1([{field:"",error:"directive",message:"unknown directive '@"+b.name+"' on :"+this.kind+" — legal here: "+[...d].map((_)=>"@"+_).join(", ")}],this.name,this.kind);o.push({name:b.name,args:b.args||[]});break;case"enum-member":l.set(b.name,b.value!==void 0?b.value:b.name);break;case"union-member":break;case"ensure":c.push({message:b.message,field:b.field||"",async:b.async===!0,fn:b.fn});break;default:throw new v1([{field:"",error:"entry",message:"unknown schema entry tag '"+b.tag+"'"}],this.name,this.kind)}if(this.kind==="shape"||this.kind==="input"||this.kind==="mixin"||this.kind==="model")Pa(this,e,o,{stack:[this.name||""],seen:new Set([this.name||""])});let g=null,p=[];if(this.kind==="union"){for(let b of o)if(b.name==="on"&&b.args?.[0]?.field)g=b.args[0].field;for(let b of this._desc.entries)if(b.tag==="union-member")p.push(b.name)}let R={fields:e,methods:t,computed:r,derived:i,hooks:n,scopes:s,defaultScope:a,directives:o,enumMembers:l,ensures:c,hasAsyncEnsures:c.some((b)=>b.async),unionOn:g,unionMembers:p};if(this.kind==="model")Se.finishModelNorm(this,R);return this._norm=R,this._norm}_unionPlan(){if(this._unionPlanCache&&this._unionPlanCache.gen===ye)return this._unionPlanCache.plan;let e=this._normalize(),t=e.unionOn;if(this.kind!=="union"||!t)throw Error("schema: '"+(this.name||"anon")+"' is not a :union");let r=new Map,i=[];for(let s of e.unionMembers){let a=ee.get(s);if(!a)throw new v1([{field:"",error:"union",message:"unknown union constituent: "+s+" (import the file that declares it)"}],this.name,this.kind);i.push(a);let o=a._normalize().fields.get(t);if(!o||o.typeName!=="literal-union"||!o.literals?.length)throw new v1([{field:t,error:"union",message:s+" must declare '"+t+"' as a string-literal type (e.g. "+t+'! "click") to join union '+(this.name||"")}],this.name,this.kind);for(let l of o.literals){if(r.has(l))throw new v1([{field:t,error:"union",message:"duplicate discriminator value "+JSON.stringify(l)+" in "+(r.get(l).name||"anon")+" and "+s}],this.name,this.kind);r.set(l,a)}}let n={disc:t,map:r,expected:[...r.keys()].join(" | "),hasAsyncEnsures:i.some((s)=>s._normalize().hasAsyncEnsures)};return this._unionPlanCache={gen:ye,plan:n},n}_unionResolve(e){let t=this._unionPlan();if(e===null||typeof e!=="object"||Array.isArray(e))return{issue:{field:t.disc,error:"union",message:"expected an object with "+t.disc}};let r=t.map.get(e[t.disc]);if(!r)return{issue:{field:t.disc,error:"union",message:"expected one of "+t.expected}};return{def:r}}_applyEagerDerived(e){let t=this._normalize();if(!t.derived.size)return;for(let[r,i]of t.derived){let n=i.call(e);Object.defineProperty(e,r,{value:n,enumerable:!0,writable:!0,configurable:!0})}}_materializeValidatedValue(e,t,r){return this._materializeNestedValues(e,t,r),this._materializeOwnValidatedValue(e,t,r)}_materializeNestedValues(e,t,r){let i=this._normalize();for(let[n,s]of i.fields){let a=mt(s.typeName);if(!a)continue;let o=e[n];if(o===void 0||o===null)continue;let l=t==null?void 0:t[n];if(s.array){if(!Array.isArray(o))continue;let c=Array(o.length);for(let f=0;f{let a=()=>({field:n.field||"",error:"ensure",message:n.message||"ensure failed"});if(n.async)i.push((async()=>{let o=!1;try{o=!!await n.fn(e)}catch{o=!1}if(!o)r.push({idx:s,issue:a()})})());else{let o=!1;try{o=!!n.fn(e)}catch{o=!1}if(!o)r.push({idx:s,issue:a()})}}),await Promise.all(i),r.sort((n,s)=>n.idx-s.idx),r.map((n)=>n.issue)}_transitiveAsync(){if(this._taGen===ye)return this._taCache;let e=new Set,t=(r)=>{if(e.has(r))return!1;e.add(r);let i=r._normalize();if(i.hasAsyncEnsures)return!0;if(r.kind==="union"){for(let n of i.unionMembers){let s=ee.get(n);if(s&&t(s))return!0}return!1}for(let n of i.fields.values()){let s=mt(n.typeName);if(s&&t(s))return!0}return!1};return this._taCache=t(this),this._taGen=ye,this._taCache}_assertSyncValidatable(e){if(!this._transitiveAsync())return;let t=this.kind!=="union"&&this._normalize().hasAsyncEnsures;throw Error("schema '"+(this.name||"anon")+"' has async refinements (@ensure!"+(t?"":" in a nested or constituent schema")+"); ."+e+"() is sync. Use parseAsync/safeAsync/okAsync instead.")}_getClass(){if(this._klass)return this._klass;let e=this._normalize(),t=this.name||"Schema",r=[...e.fields.keys()],i={[t]:class{constructor(n){if(n&&typeof n==="object"){for(let s of r)if(s in n&&n[s]!==void 0)this[s]=n[s]}}}}[t];for(let[n,s]of e.methods)Object.defineProperty(i.prototype,n,{value:s,writable:!0,enumerable:!1,configurable:!0});for(let[n,s]of e.computed)Object.defineProperty(i.prototype,n,{get:s,enumerable:!1,configurable:!0});return this._klass=i,i}_coerceDates(e){let t=this._normalize(),r=(s)=>typeof s==="string"&&/^\d{4}-\d{2}-\d{2}([T ].*)?$/.test(s),i=(s)=>{let a=/^(\d{4})-(\d{2})-(\d{2})/.exec(s),o=+a[2],l=+a[3];return o>=1&&o<=12&&l>=1&&l<=new Date(Date.UTC(+a[1],o,0)).getUTCDate()},n=(s)=>{if(!i(s))return s;let a=new Date(s);return Number.isNaN(a.getTime())?s:a};for(let[s,a]of t.fields){if(a.typeName!=="date"&&a.typeName!=="datetime")continue;let o=e[s];if(a.array&&Array.isArray(o))e[s]=o.map((l)=>r(l)?n(l):l);else if(r(o))e[s]=n(o)}}_validateFields(e,t,r,i){let n=this._normalize(),s=t?[]:null;for(let[a,o]of n.fields){if(r&&r.has(a))continue;let l=e==null?void 0:e[a];if(l===void 0||l===null){if(o.required){if(!t)return!1;s.push({field:a,error:"required",message:a+" is required"})}continue}if(o.array){if(!Array.isArray(l)){if(!t)return!1;s.push({field:a,error:"type",message:a+" must be an array"});continue}let f=o.constraints;if(f){if(f.min!=null&&l.lengthf.max){if(!t)return!1;s.push({field:a,error:"max",message:a+" must have at most "+f.max+" items"})}}if(i?.deferNested&&mt(o.typeName))continue;let h=!1,u=!1,d=Array(l.length);for(let S=0;SJSON.stringify(f)).join(", ")});continue}}else{if(i?.deferNested&&mt(o.typeName))continue;let f=xn(l,o.typeName,i);if(f.errors){if(!t)return!1;for(let h of f.errors){let u=pt(a,h.field);s.push({field:u,error:h.error,message:or(u,h.field,h.message)})}continue}if(f.value!==l)e[a]=f.value}let c=o.constraints;if(c){if(typeof l==="string"){if(c.min!=null&&l.lengthc.max){if(!t)return!1;s.push({field:a,error:"max",message:a+" must be at most "+c.max+" chars"})}if(c.regex){if(c.regex.global||c.regex.sticky)c.regex.lastIndex=0;if(!c.regex.test(l)){if(!t)return!1;s.push({field:a,error:"pattern",message:a+" is invalid"})}}}else if(typeof l==="number"){if(c.min!=null&&l= "+c.min})}if(c.max!=null&&l>c.max){if(!t)return!1;s.push({field:a,error:"max",message:a+" must be <= "+c.max})}}}}return t?s:!0}_applyDefaults(e){let t=this._normalize();for(let[r,i]of t.fields)if((e[r]===void 0||e[r]===null)&&i.constraints?.default!==void 0){let n=i.constraints.default;e[r]=typeof n==="object"&&n!==null&&!(n instanceof RegExp)?structuredClone(n):n}return e}_applyTransforms(e,t){let r=this._normalize(),i=[];for(let[n,s]of r.fields){if(!s.transform)continue;try{t[n]=s.transform(e)}catch(a){i.push({field:n,error:"transform",message:a?.message||String(a)})}}return i}_applyCoercions(e,t){let r=this._normalize(),i=[];for(let[n,s]of r.fields){if(!s.coerce)continue;let a=e[n];if(a===void 0||a===null)continue;if(s.coercer){let l=Dn.get(s.coercer);if(!l)throw Error("schema: no coercer registered for '~:"+s.coercer+"' (field '"+n+"' on "+(this.name||"anon")+"). Register it with registerCoercer('"+s.coercer+"', fn).");let c=l.raw?a:String(a).trim(),f;try{f=l.fn(c)}catch{f=null}if(f===null||f===void 0)i.push({field:n,error:"coerce",message:n+" is not a valid "+s.coercer}),t.add(n);else e[n]=f;continue}let o=cr[s.typeName]?cr[s.typeName](a):{ok:!1};if(o.ok)e[n]=o.value;else i.push({field:n,error:"coerce",message:n+" cannot be coerced to "+s.typeName}),t.add(n)}return i}_orderFieldErrors(...e){let t=new Map,r=0;for(let[i]of this._normalize().fields)t.set(i,r++);return e.flat().map((i,n)=>{let s=String(i.field||"").split(/[.[]/,1)[0];return{issue:i,seq:n,rank:t.has(s)?t.get(s):r}}).sort((i,n)=>i.rank-n.rank||i.seq-n.seq).map((i)=>i.issue)}_validateEnum(e,t){let r=this._normalize();for(let[n,s]of r.enumMembers)if(e===n||e===s)return t?[]:!0;if(!t)return!1;let i=[...r.enumMembers.keys()].join(", ");return[{field:"",error:"enum",message:(this.name||"enum")+" expected one of: "+i}]}_materializeEnum(e){let t=this._normalize();for(let[r,i]of t.enumMembers)if(e===r||e===i)return i;return e}_runSync(e,t){if(this.kind==="union"){let f=this._unionResolve(e);if(f.issue)return{ok:!1,errors:[f.issue]};let h=f.def._runSync(e,t);return h.ok?h:{...h,from:h.from||f.def}}if(this.kind==="enum"){let f=this._validateEnum(e,!0);return f.length?{ok:!1,errors:f}:{ok:!0,value:this._materializeEnum(e)}}let r=ar(e);if(r)return{ok:!1,errors:[r]};let i=e,n={...i},s=new Set,a=this._applyTransforms(i,n),o=this._applyCoercions(n,s);this._applyDefaults(n),this._coerceDates(n);let l=this._orderFieldErrors(a,o,this._validateFields(n,!0,s,t));if(l.length)return{ok:!1,errors:l};let c=t?.skipEnsures?[]:this._applyEnsures(n);if(c.length)return{ok:!1,errors:c};if(t?.materializeNested)try{this._materializeNestedValues(n,null,!1)}catch(f){return{ok:!1,errors:null,...Be(f)}}if(!t?.materialize)return{ok:!0,value:n};try{return{ok:!0,value:this._materializeOwnValidatedValue(n,null,!1)}}catch(f){return{ok:!1,errors:null,...Be(f)}}}async _runAsync(e,t){if(this.kind==="union"){let h=this._unionResolve(e);if(h.issue)return{ok:!1,errors:[h.issue]};let u=await h.def._runAsync(e,t);return u.ok?u:{...u,from:u.from||h.def}}if(this.kind==="enum")return this._runSync(e,t);let r=ar(e);if(r)return{ok:!1,errors:[r]};let i=e,n={...i},s=new Set,a=this._applyTransforms(i,n),o=this._applyCoercions(n,s);this._applyDefaults(n),this._coerceDates(n);let l=await this._validateFieldsAsync(n,s,t),c=this._orderFieldErrors(a,o,l);if(c.length)return{ok:!1,errors:c};let f=t?.skipEnsures?[]:await this._applyEnsuresAsync(n);if(f.length)return{ok:!1,errors:f};if(t?.materializeNested)try{this._materializeNestedValues(n,null,!1)}catch(h){return{ok:!1,errors:null,...Be(h)}}if(!t?.materialize)return{ok:!0,value:n};try{return{ok:!0,value:this._materializeOwnValidatedValue(n,null,!1)}}catch(h){return{ok:!1,errors:null,...Be(h)}}}async _validateFieldsAsync(e,t,r){let i=this._normalize(),n=[];for(let[s,a]of i.fields){if(t&&t.has(s))continue;let o=e[s];if(o===void 0||o===null){if(a.required)n.push({field:s,error:"required",message:s+" is required"});continue}if(a.array){if(!Array.isArray(o)){n.push({field:s,error:"type",message:s+" must be an array"});continue}let f=a.constraints;if(f?.min!=null&&o.lengthf.max)n.push({field:s,error:"max",message:s+" must have at most "+f.max+" items"});let h=Array(o.length),u=!1;for(let d=0;dJSON.stringify(f)).join(", ")})}else{let f=await Aa(o,a.typeName,r);if(f.errors)for(let h of f.errors){let u=pt(s,h.field);n.push({field:u,error:h.error,message:or(u,h.field,h.message)})}else e[s]=f.value}let l=e[s],c=a.constraints;if(c){if(typeof l==="string"){if(c.min!=null&&l.lengthc.max)n.push({field:s,error:"max",message:s+" must be at most "+c.max+" chars"});if(c.regex){if(c.regex.global||c.regex.sticky)c.regex.lastIndex=0;if(!c.regex.test(l))n.push({field:s,error:"pattern",message:s+" is invalid"})}}else if(typeof l==="number"){if(c.min!=null&&l= "+c.min});if(c.max!=null&&l>c.max)n.push({field:s,error:"max",message:s+" must be <= "+c.max})}}}return n}_runExistingSync(e,t){if(this.kind==="union"){let a=this._unionResolve(e);if(a.issue)return{ok:!1,errors:[a.issue]};let o=a.def._runExistingSync(e,t);return o.ok?o:{...o,from:o.from||a.def}}if(this.kind==="enum")return this._runSync(e,t);let r=ar(e);if(r)return{ok:!1,errors:[r]};let i={...e},n=this._validateFields(i,!0,null,{...t,existing:!0});if(n.length)return{ok:!1,errors:n};let s=t?.skipEnsures?[]:this._applyEnsures(i);if(s.length)return{ok:!1,errors:s};if(t?.materializeNested)try{this._materializeNestedValues(i,e,!0)}catch(a){return{ok:!1,errors:null,...Be(a)}}return this._finishExistingValue(e,i,t)}async _runExistingAsync(e,t){if(this.kind==="union"){let a=this._unionResolve(e);if(a.issue)return{ok:!1,errors:[a.issue]};let o=await a.def._runExistingAsync(e,t);return o.ok?o:{...o,from:o.from||a.def}}if(this.kind==="enum")return this._runSync(e,t);let r=ar(e);if(r)return{ok:!1,errors:[r]};let i={...e},n=await this._validateFieldsAsync(i,null,{...t,existing:!0});if(n.length)return{ok:!1,errors:n};let s=t?.skipEnsures?[]:await this._applyEnsuresAsync(i);if(s.length)return{ok:!1,errors:s};if(t?.materializeNested)try{this._materializeNestedValues(i,e,!0)}catch(a){return{ok:!1,errors:null,...Be(a)}}return this._finishExistingValue(e,i,t)}_finishExistingValue(e,t,r){if(!r?.materialize)return{ok:!0,value:t};let i=this._getClass(),n=!0;for(let[a]of this._normalize().fields)if(t[a]!==e[a]){n=!1;break}if(n)return{ok:!0,value:e};let s=new i(t);try{this._applyEagerDerived(s)}catch(a){return{ok:!1,errors:null,thrown:a}}return{ok:!0,value:s}}parse(e){if(this.kind==="mixin")throw Error(":mixin schema '"+(this.name||"anon")+"' is not instantiable");this._assertSyncValidatable("parse");let t=this._runSync(e,{materialize:!0,materializeNested:!0,derived:"throw"});if(t.ok)return t.value;if(t.thrown)throw t.thrown;let r=t.from||this;throw new v1(t.errors,r.name,r.kind)}get array(){let e=this,t=(s)=>({field:"",error:"not_array",message:"expected an array, received "+(s===null?"null":s===void 0?"undefined":typeof s==="object"?"an object with keys ["+Object.keys(s).join(", ")+"]":typeof s)}),r=(s)=>{let a=[],o=[];return s.forEach((l,c)=>{if(l.ok)a.push(l.value);else for(let f of l.errors)o.push({...f,field:"["+c+"]"+(f.field?"."+f.field:"")})}),{value:a,errors:o}},i=(s)=>{let a=[],o=[];return s.forEach((l,c)=>{try{a.push(e.parse(l))}catch(f){if(!(f instanceof v1))throw f;for(let h of f.issues)o.push({...h,field:"["+c+"]"+(h.field?"."+h.field:"")})}}),{value:a,errors:o}},n=async(s)=>{let a=[],o=[];for(let l=0;le.safe(l)));return o.length?{ok:!1,value:null,errors:o}:{ok:!0,value:a,errors:null}},ok(s){return Array.isArray(s)&&s.every((a)=>e.ok(a))},async parseAsync(s){if(!Array.isArray(s))throw new v1([t(s)],e.name,e.kind);let{value:a,errors:o}=await n(s);if(o.length)throw new v1(o,e.name,e.kind);return a},async safeAsync(s){if(!Array.isArray(s))return{ok:!1,value:null,errors:[t(s)]};let{value:a,errors:o}=r(await Promise.all(s.map((l)=>e.safeAsync(l))));return o.length?{ok:!1,value:null,errors:o}:{ok:!0,value:a,errors:null}},async okAsync(s){return Array.isArray(s)&&(await Promise.all(s.map((a)=>e.okAsync(a)))).every(Boolean)},toJSONSchema(){return{type:"array",items:e.toJSONSchema()}}}}safe(e){if(this.kind==="mixin")return{ok:!1,value:null,errors:[{field:"",error:"mixin",message:"not instantiable"}]};this._assertSyncValidatable("safe");let t=this._runSync(e,{materialize:!0,materializeNested:!0,derived:"issue"});if(t.ok)return{ok:!0,value:t.value,errors:null};if(t.thrown)return{ok:!1,value:null,errors:[{field:t.derivedField||"",error:"derived",message:t.thrown?.message||String(t.thrown)}]};return{ok:!1,value:null,errors:t.errors}}ok(e){if(this.kind==="mixin")return!1;return this._assertSyncValidatable("ok"),this._runSync(e,{materialize:!1,materializeNested:!1,derived:"issue"}).ok}async parseAsync(e){if(this.kind==="mixin")throw Error(":mixin schema '"+(this.name||"anon")+"' is not instantiable");let t=await this._runAsync(e,{materialize:!0,materializeNested:!0,derived:"throw"});if(t.ok)return t.value;if(t.thrown)throw t.thrown;let r=t.from||this;throw new v1(t.errors,r.name,r.kind)}async safeAsync(e){if(this.kind==="mixin")return{ok:!1,value:null,errors:[{field:"",error:"mixin",message:"not instantiable"}]};let t=await this._runAsync(e,{materialize:!0,materializeNested:!0,derived:"issue"});if(t.ok)return{ok:!0,value:t.value,errors:null};if(t.thrown)return{ok:!1,value:null,errors:[{field:t.derivedField||"",error:"derived",message:t.thrown?.message||String(t.thrown)}]};return{ok:!1,value:null,errors:t.errors}}async okAsync(e){if(this.kind==="mixin")return!1;return(await this._runAsync(e,{materialize:!1,materializeNested:!1,derived:"issue"})).ok}pick(...e){return dt(this,(t)=>{let r=$n(e),i=new Map;for(let n of r){if(!t.has(n))throw Error("pick: unknown field '"+n+"' on "+(this.name||"schema"));i.set(n,t.get(n))}return i})}omit(...e){return dt(this,(t)=>{let r=new Set($n(e)),i=new Map;for(let[n,s]of t)if(!r.has(n))i.set(n,s);return i})}partial(){return dt(this,(e)=>{let t=new Map;for(let[r,i]of e)t.set(r,{...i,required:!1});return t})}required(...e){return dt(this,(t)=>{let r=new Set($n(e)),i=new Map;for(let[n,s]of t)i.set(n,{...s,required:r.has(n)?!0:s.required});return i})}extend(e){if(!(e instanceof gt))throw Error("extend(): argument must be a schema value");if(e.kind==="union")throw Error("extend(): :union schemas have no fields to merge");return dt(this,(t)=>{let r=new Map(t),i=e._normalize().fields;for(let[n,s]of i){if(r.has(n))throw Error("extend(): field '"+n+"' collides between "+(this.name||"schema")+" and "+(e.name||"other"));r.set(n,s)}return r})}toJSONSchema(){let e={defs:new Map,expanding:new Set},t=Ca(this,e);if(t.$schema="https://json-schema.org/draft/2020-12/schema",this.name)t.title=this.name;if(e.defs.size){t.$defs={};for(let[r,i]of e.defs)t.$defs[r]=i}return t}}var Ia={__proto__:null,string:()=>({type:"string"}),text:()=>({type:"string"}),email:()=>({type:"string",format:"email"}),url:()=>({type:"string",format:"uri"}),uuid:()=>({type:"string",format:"uuid"}),phone:()=>({type:"string",pattern:"^[\\d\\s\\-+()]+$"}),zip:()=>({type:"string",pattern:"^\\d{5}(-\\d{4})?$"}),number:()=>({type:"number"}),integer:()=>({type:"integer"}),boolean:()=>({type:"boolean"}),date:()=>({type:"string",format:"date"}),datetime:()=>({type:"string",format:"date-time"}),json:()=>({}),any:()=>({})};function L3(e,t){let r;if(e.typeName==="literal-union"&&e.literals?.length)r=e.literals.length===1?{const:e.literals[0]}:{enum:[...e.literals]};else if(Ia[e.typeName])r=Ia[e.typeName]();else{let n=ee.get(e.typeName);r=n?xa(n,t):{}}let i=e.constraints;if(i&&!e.array){if(r.type==="string"){if(i.min!=null)r.minLength=i.min;if(i.max!=null)r.maxLength=i.max;if(i.regex)r.pattern=i.regex.source}else if(r.type==="number"||r.type==="integer"){if(i.min!=null)r.minimum=i.min;if(i.max!=null)r.maximum=i.max}}if(e.array){if(r={type:"array",items:r},i){if(i.min!=null)r.minItems=i.min;if(i.max!=null)r.maxItems=i.max}}if(i&&i.default!==void 0)r.default=i.default;if(e.coerce)r.description=((r.description?r.description+" ":"")+"Coerced from wire data ("+(e.coercer?"~:"+e.coercer:"~"+e.typeName)+").").trim();if(e.transform)r.description=((r.description?r.description+" ":"")+"Derived via transform; the raw input may use different keys.").trim();return r}function xa(e,t){let r=e.name||"Anon";if(!t.defs.has(r)&&!t.expanding.has(r))t.expanding.add(r),t.defs.set(r,null),t.defs.set(r,Ca(e,t)),t.expanding.delete(r);return{$ref:"#/$defs/"+r}}function Ca(e,t){let r=e._normalize();if(e.kind==="enum")return{enum:[...new Set(r.enumMembers.values())]};if(e.kind==="union"){let a=e._unionPlan();return{oneOf:r.unionMembers.map((l)=>{let c=ee.get(l);return c?xa(c,t):{}}),discriminator:{propertyName:a.disc}}}let i={},n=[];for(let[a,o]of r.fields)if(i[a]=L3(o,t),o.required&&o.constraints?.default===void 0)n.push(a);if(e.kind==="model")Se.jsonSchemaModelColumns(e,i);let s={type:"object",properties:i};if(n.length)s.required=n;if(r.ensures.length)s.description="Refinements (not expressible in JSON Schema): "+r.ensures.map((a)=>a.message).join("; ")+".";return s}function $n(e){let t=[];for(let r of e)if(Array.isArray(r))for(let i of r)t.push(i);else t.push(r);return t}function dt(e,t){if(e.kind==="union")throw Error("schema algebra (.pick/.omit/.partial/.required/.extend) is not supported on :union — derive from a constituent schema instead");if(e.kind==="enum")throw Error("schema algebra is not supported on :enum — an enum has no field set");let r=e.kind==="model"?Se.projectableFields(e):e._normalize().fields,i=t(r),n=[];for(let[,o]of i){let l=[];if(o.required)l.push("!");if(o.optional&&!o.required)l.push("?");n.push({tag:"field",name:o.name,modifiers:l,unique:o.unique===!0,primary:o.primary===!0,attrs:o.attrs||null,typeName:o.typeName,array:o.array,literals:o.literals||null,coerce:o.coerce===!0,coercer:o.coercer||null,constraints:o.constraints,transform:o.transform||null})}let s=(e.name||"Schema")+"Derived",a=new gt({kind:"shape",name:s,entries:n});return a._sourceModel=e._sourceModel||(e.kind==="model"?e:null),a}function Pa(e,t,r,i){for(let n of r){if(n.name!=="mixin"||!n.args||!n.args[0])continue;let s=n.args[0].target;if(!s)continue;if(i.stack.includes(s))throw new v1([{field:"",error:"mixin-cycle",message:"mixin cycle: "+i.stack.concat(s).join(" -> ")}],e.name,e.kind);if(i.seen.has(s))continue;let a=ee.getKind(s,"mixin");if(!a)throw new v1([{field:"",error:"mixin-missing",message:"unknown mixin: "+s}],e.name,e.kind);i.seen.add(s),i.stack.push(s);let o=a._desc.entries.filter((l)=>l.tag==="directive"&&l.name==="mixin").map((l)=>({name:l.name,args:l.args||[]}));Pa(e,t,o,i);for(let l of a._desc.entries){if(l.tag!=="field")continue;if(t.has(l.name))throw new v1([{field:l.name,error:"mixin-collision",message:l.name+" from mixin "+s+" collides with existing field"}],e.name,e.kind);if(e.kind!=="model"&&(l.unique===!0||l.attrs))throw new v1([{field:l.name,error:"mixin-persistence",message:l.name+" from mixin "+s+" carries persistence metadata (@unique/attrs) — :model-only; a :"+e.kind+" cannot include it"}],e.name,e.kind);t.set(l.name,{name:l.name,required:l.modifiers.includes("!"),optional:l.modifiers.includes("?"),unique:l.unique===!0,attrs:l.attrs||null,typeName:l.typeName,literals:l.literals||null,array:l.array===!0,coerce:l.coerce===!0,coercer:l.coercer||null,constraints:l.constraints||null,transform:l.transform||null})}i.stack.pop()}}function M3(e){let t=new gt(e);if(t.name)ee.register(t);return t}if(typeof globalThis<"u")globalThis.__ripSchema=globalThis.__ripSchema||{},globalThis.__ripSchema.SchemaRegistry=ee;var gr={};xe(gr,{__batch:()=>L1,__catchErrors:()=>ue,__computed:()=>H1,__detachRef:()=>Cn,__effect:()=>$1,__handleError:()=>te,__ownerFrame:()=>yt,__popOwner:()=>Y1,__pushOwner:()=>le,__readonly:()=>fe,__setEffectErrorReporter:()=>j3,__setErrorHandler:()=>he,__state:()=>_1,getEffectSignal:()=>ce});var Ma=Symbol.for("rip.runtime.reactive");if(globalThis[Ma])throw Error("two copies of the Rip reactive runtime loaded in one process — states from different copies "+"cannot notify each other (separate dependency graphs, separate effect queues). Run .rip sources through the rip CLI/loader (one shared runtime module per process), or load only one standalone-compiled file per process.");globalThis[Ma]=!0;var N1=null,mr=[],Ue={buckets:[],size:0,low:0,add(e){let t=e.depth,r=this.buckets[t];if(r===void 0)r=this.buckets[t]=new Set;if(r.has(e))return;if(r.add(e),this.size++,tconsole.error(e,t);function j3(e){let t=bt;return bt=e,t}function ja(){try{while(Ue.size>0){let e=Ue.shift();if(!e._disposed)e.run()}}catch(e){throw Ue.clear(),e}}var Fa={valueOf(){return this.value},toString(){return String(this.value)},[Symbol.toPrimitive](e){return e==="string"?this.toString():this.valueOf()}};function _1(e){if(e!=null&&typeof e==="object"&&typeof e.read==="function")return e;let t=e,r=new Set,i=!1,n=!1,s=!1,a=()=>{if(N1&&typeof N1.markDirty==="function"&&N1.dependencies.has(r))throw Error("reactive runtime: computed dependency changed during evaluation — "+"computed functions must derive without writing or touching a dependency")},o=()=>{for(let f of mr)f.writtenSignals.add(r)},l=()=>{i=!0;try{for(let f of r)if(f.markDirty)f.markDirty(!0);else f._hard=!0,Ue.add(f);if(!dr)ja()}finally{i=!1}},c={get value(){if(s)return t;if(N1?.writtenSignals&&mr.some((f)=>f.writtenSignals.has(r)))throw Error("reactive runtime: computed dependency changed during evaluation — "+"computed functions must derive without writing or touching a dependency");if(N1)r.add(N1),N1.dependencies.add(r);return t},set value(f){if(s||n||f===t)return;if(a(),i)return;o(),t=f,l()},read(){return t},touch(){if(s)return;if(a(),i)return;o(),l()},lock(){return n=!0,c},free(){return r.clear(),c},kill(){return s=!0,r.clear(),t},...Fa};return c}var hr=0,La=1,ur=2;function Ba(e){let t=N1;N1=null;try{for(let[r,i]of e.computedDeps)if(r.value,r.version!==i)return!0;return!1}finally{N1=t}}function H1(e){let t,r=ur,i=new Set,n=!1,s=!1,a=!1,o={dependencies:new Set,computedDeps:new Map,writtenSignals:new Set,version:0,markDirty(l){if(s||n)return;if(a)throw Error("reactive runtime: computed dependency changed during evaluation — "+"computed functions must derive without writing or touching a dependency");let c=r;if(l)r=ur;else if(r===hr)r=La;if(c!==hr)return;for(let f of i)if(f.markDirty)f.markDirty(!1);else Ue.add(f)},get value(){if(s)return t;if(N1&&N1!==o)i.add(N1),N1.dependencies.add(i),N1.computedDeps.set(o,-1);if(a)throw Error("reactive runtime: computed value read during its own evaluation — "+"recursive computed reads are not supported");if(r===La&&!n)r=Ba(o)?ur:hr;if(r===ur&&!n){for(let c of o.dependencies)c.delete(o);o.dependencies.clear(),o.computedDeps.clear();let l=N1;o.writtenSignals.clear(),N1=o,mr.push(o),a=!0;try{let c=e();if(c!==t)o.version++;t=c,r=hr}finally{a=!1,mr.pop(),o.writtenSignals.clear(),N1=l}}if(N1&&N1!==o)N1.computedDeps.set(o,o.version);return t},read(){return t},lock(){return n=!0,o.value,o},free(){for(let l of o.dependencies)l.delete(o);return o.dependencies.clear(),o.computedDeps.clear(),i.clear(),o},kill(){s=!0;let l=t;return o.free(),l},...Fa};return o}function $1(e){let t=null,r=0,i=j1,n={depth:i?i.depth+1:0,dependencies:new Set,computedDeps:new Map,_hard:!0,_disposed:!1,signal:null,run(){if(n._disposed)return;let a=n._hard;if(n._hard=!1,!a&&!Ba(n))return;if(t)try{t.abort()}catch{}t=typeof AbortController<"u"?new AbortController:null,n.signal=t?t.signal:null;let o=++r;if(n._cleanup)n._cleanup(),n._cleanup=null;for(let f of n.dependencies)f.delete(n);n.dependencies.clear(),n.computedDeps.clear();let l=N1;N1=n;let c=j1;j1=i;try{let f=e();if(typeof f==="function")n._cleanup=f;else if(f&&typeof f.then==="function")f.then((h)=>{if(o!==r||n._disposed){if(typeof h==="function")try{h()}catch(u){bt("[Rip] superseded async cleanup error:",u)}return}if(typeof h==="function")n._cleanup=h},(h)=>{if(h&&h.name==="AbortError")return;if(o!==r||n._disposed)return;bt("[Rip] async effect error:",h)})}finally{N1=l,j1=c}},dispose(){if(n._disposed)return;if(n._disposed=!0,Ue.delete(n),t)try{t.abort()}catch{}if(n._cleanup)n._cleanup(),n._cleanup=null;for(let a of n.dependencies)a.delete(n);n.dependencies.clear()}};try{n.run()}catch(a){throw n.dispose(),a}let s=()=>n.dispose();if(j1)j1.add(s);return s}function L1(e){if(dr)return e();dr=!0;try{return e()}finally{dr=!1,ja()}}function yt({nested:e=!0}={}){let t=[],r=null,n={depth:j1?j1.depth+1:0,get disposed(){return t===null},get size(){return t===null?0:t.length},add(s){if(t===null)s();else t.push(s)},remove(s){if(t===null)return;let a=t.indexOf(s);if(a>=0)t.splice(a,1)},dispose(){if(t===null)return;let s=t;if(t=null,r!==null){let a=r;r=null,a()}for(let a of s)try{a()}catch(o){bt("[Rip] effect disposer error:",o)}}};if(e&&j1){let s=j1;s.add(n.dispose),r=()=>s.remove(n.dispose)}return n}function le(e){let t={frame:e,prev:j1};return j1=e,t}function Y1(e){if(!e||typeof e!=="object"||!("frame"in e))throw Error("reactive runtime: __popOwner takes the token the matching __pushOwner returned");if(j1!==e.frame)throw Error("reactive runtime: __popOwner out of order — the frame being popped is not the current owner "+"(an inner push was not popped, or this token was already popped)");j1=e.prev}function ce(){return N1?N1.signal:null}function fe(e){return Object.freeze({value:e})}function Cn(e,t){if(e&&typeof e.read==="function"&&e.read()===t)e.value=null}var pr=null;function he(e){let t=pr;return pr=e,t}function te(e){if(pr)try{pr(e)}catch(t){console.error("Error in error handler:",t),console.error("Original error:",e)}else throw e}function ue(e){return function(...t){try{return e.apply(this,t)}catch(r){te(r)}}}var Et={};xe(Et,{__Component:()=>ro,__claimGateConstructor:()=>Un,__clsx:()=>Er,__detach:()=>Rr,__detachRef:()=>Cn,__gateBind:()=>rc,__handleComponentError:()=>Mn,__hmrClassify:()=>Rt,__hmrEmit:()=>ke,__hmrEntries:()=>jn,__hmrEvents:()=>W3,__hmrLookup:()=>F3,__hmrMigrateDiff:()=>qa,__hmrMigrateRemount:()=>Y3,__hmrPatch:()=>Bn,__hmrPreserveState:()=>kr,__hmrRegisterDefinition:()=>St,__hmrRegistry:()=>Ee,__hmrRestoreUi:()=>Tr,__hmrSnapshotUi:()=>Fn,__lis:()=>eo,__ownerFrame:()=>yt,__popComponent:()=>Re,__popOwner:()=>Y1,__pushComponent:()=>Ve,__pushOwner:()=>le,__reconcile:()=>J3,__style:()=>to,__transition:()=>Q3,getContext:()=>q3,hasContext:()=>X3,setContext:()=>z3});var Ka=Symbol.for("rip.runtime.components");if(globalThis[Ka])throw Error("two copies of the Rip component runtime loaded in one process — components from different "+"copies cannot see each other (separate component stacks: context, parent chains, and error boundaries silently break across copies). Run .rip sources through the rip CLI/loader (one shared runtime module per process), or load only one standalone-compiled file per process.");globalThis[Ka]=!0;var re=null,Ya={},yr=null,za=new WeakMap,Ua=!1,Ee=new Map;function Pn(e,t){if(e===t)return!0;if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;rn.has(c)),o=i.filter((c)=>!n.has(c)),l=r.filter((c)=>!s.has(c));return{kept:a,added:o,removed:l}}var Sr=[],V3=64;function ke(e,t={}){let r={type:e,at:Date.now(),...t};if(Sr.push(r),Sr.length>V3)Sr.shift();if(typeof window<"u"&&typeof window.dispatchEvent==="function"&&typeof CustomEvent==="function")try{window.dispatchEvent(new CustomEvent("rip:hmr",{detail:r}))}catch{}return r}function W3(){return Sr.slice()}function kr(e,t){let r=e?.constructor?.__hmrSig,i=t?.constructor?.__hmrSig,n=r?.state,s=i?.state,a=qa(r,i);if(!Array.isArray(n)||!Array.isArray(s))return ke("migrate",{id:t?.constructor?.__hmrId??null,...a,copied:[]}),a;let o=new Set(n),l=[];for(let f of s){if(!o.has(f))continue;let h=e[f],u=t[f];if(h!=null&&u!=null&&typeof h==="object"&&typeof u==="object"&&"value"in h&&"value"in u)u.value=h.value,l.push(f)}let c=t?.constructor?.__hmrId??e?.constructor?.__hmrId??null;return ke("migrate",{id:c,...a,copied:l}),{...a,copied:l}}var Xa=["name","type","placeholder"];function Ja(e){let t=(i)=>typeof e[i]==="string"&&e[i]?e[i]:null,r={tag:e.tagName??null};for(let i of Xa)r[i]=t(i);return r.label=typeof e.getAttribute==="function"?e.getAttribute("aria-label"):null,r.value=typeof e.value==="string"?e.value:null,r}function Ln(e,t,r){if(!e||!t)return!1;let i=Ja(e);for(let n of["tag",...Xa,"label"])if(i[n]!==t[n])return!1;return!r||t.value==null||i.value===t.value}function H3(e){let t=Ja(e),r=typeof e.id==="string"&&e.id?e.id:null,i=[],n=e;while(n&&n!==document.body){let s=n.parentElement??n.parentNode??null;if(!s||!s.children)return{identity:t,id:r,path:null};i.unshift(Array.prototype.indexOf.call(s.children,n)),n=s}return{identity:t,id:r,path:n===document.body?i:null}}function G3(e){let t=e.active;if(t&&t.isConnected!==!1&&typeof document.contains==="function"&&document.contains(t))return t;let r=e.locator;if(!r)return null;if(r.id&&typeof document.getElementById==="function"){let o=document.getElementById(r.id);if(Ln(o,r.identity,!1))return o}if(!Array.isArray(r.path)||r.path.length===0)return null;let i=document.body;for(let o of r.path.slice(0,-1))if(i=i?.children?.[o]??null,!i)return null;let n=Array.from(i.children??[]),s=n[r.path[r.path.length-1]]??null;if(Ln(s,r.identity,!0))return s;let a=n.filter((o)=>Ln(o,r.identity,!0));return a.length===1?a[0]:null}function Fn(){if(typeof document>"u")return null;let e=document.activeElement,t=e&&e!==document.body&&e!==document.documentElement?e:null,r=null;if(t&&typeof t.selectionStart==="number")r={start:t.selectionStart,end:t.selectionEnd,direction:t.selectionDirection};return{active:t,locator:t?H3(t):null,selection:r,scrollX:typeof window<"u"?window.scrollX:0,scrollY:typeof window<"u"?window.scrollY:0}}function Tr(e){if(!e||typeof document>"u")return;if(typeof window<"u")window.scrollTo(e.scrollX??0,e.scrollY??0);let t=G3(e);if(!t||typeof t.focus!=="function")return;try{if(t.focus({preventScroll:!0}),e.selection&&typeof t.setSelectionRange==="function")t.setSelectionRange(e.selection.start,e.selection.end,e.selection.direction??"none")}catch{}}function Za(e,t){let r=e.constructor?.__hmrId;if(typeof r==="string"&&r)Ee.get(r)?.instances.delete(e);Object.setPrototypeOf(e,t.prototype),Object.defineProperty(e,"constructor",{value:t,writable:!0,configurable:!0}),St(t),Ee.get(t.__hmrId)?.instances.add(e)}function Bn(e,t){if(!e||!t)throw Error("__hmrPatch requires a living instance and a replacement constructor");let r=e.constructor?.__hmrId;return Za(e,t),e._hmrRerender(),ke("patch",{id:t.__hmrId??r??null}),e}function Qa(e){return Object.keys(e).sort().join(",")}function K3(e,t){let r=re?._hmrOrphans;if(!r||r.length===0)return null;let i=e.__hmrId;if(typeof i!=="string")return null;let n=Qa(t),s=null;for(let a of r){if(a._state!=="mounted"||a.constructor.__hmrId!==i||a._hmrPropKeys!==n)continue;if(s)return null;s=a}if(!s||Rt(s.constructor,e)!=="patch")return null;if(r.splice(r.indexOf(s),1),s.constructor!==e)Za(s,e);s._hmrRelease();try{s._hmrApplyProps(t)}catch(a){throw s._teardown({state:"failed",hooks:!1,removeDOM:!0}),a}if(!s._hmrRebind())return null;return s}function Y3(e,t,r={}){let i=new t(r);return kr(e,i),i}function Un(){if(Ua)throw Error("[Rip] the render-gate construction capability is already claimed");return Ua=!0,(e,t)=>{let r=yr;yr={brand:Ya,component:e,gates:t.gates,parent:t.parent??null,stash:t.stash??null,router:t.router??null,used:!1};try{return new e({})}finally{yr=r}}}function Rr(e){if(!e||e.nodeType===11)return;if(typeof e.remove==="function")e.remove();else if(e.parentNode)e.parentNode.removeChild(e)}function Ve(e){let t=re;if(e&&e._parent==null&&t&&t!==e)e._parent=t;return re=e,t}function Re(e){re=e}function z3(e,t){if(!re)throw Error("setContext must be called during component initialization");if(!re._context)re._context=new Map;re._context.set(e,t)}function q3(e){let t=re,r=new Set;while(t&&!r.has(t)){if(r.add(t),t._context&&t._context.has(e))return t._context.get(e);t=t._parent}throw Error(`getContext: no provider for context ${JSON.stringify(e)} in this component's parent chain — `+"offer it from an ancestor, or probe with hasContext(key) where absence is legal")}function X3(e){let t=re,r=new Set;while(t&&!r.has(t)){if(r.add(t),t._context&&t._context.has(e))return!0;t=t._parent}return!1}function Er(...e){let t="";for(let r of e){if(!r)continue;if(typeof r==="string")t&&(t+=" "),t+=r;else if(typeof r==="object"){if(Array.isArray(r)){let i=Er(...r);i&&(t&&(t+=" "),t+=i)}else for(let i in r)if(r[i])t&&(t+=" "),t+=i}}return t}function eo(e){let t=e.length;if(t===0)return[];let r=[],i=[],n=Array(t).fill(-1);for(let o=0;o>1;if(r[f]0)n[o]=i[l-1]}let s=[],a=i[r.length-1];for(let o=r.length-1;o>=0;o--)s.push(a),a=n[a];return s.reverse(),s}function J3(e,t,r,i,n,s,...a){let o=e.parentNode;if(!o)return;let l=t.keys,c=t.items||[],f=t.blocks,h=l.length,u=r.length,d=Array(u),S=s!=null,g=S?r.map((y,m)=>s(y,m)):r;if(S){let y=new Set;for(let m of g){if(y.has(m))throw Error(`__reconcile: duplicate key ${JSON.stringify(String(m))} — keyed rows need unique keys `+"(the key function must be injective over the items)");y.add(m)}}if(h===0){if(u>0){let y=document.createDocumentFragment();for(let m=0;m=p&&_>=p&&l[b]===g[_]){let y=f[b];if(!y._s)y.p(i,r[_],_,...a);d[_]=y,b--,_--}if(p>_)for(let y=p;y<=b;y++)f[y].d(!0);else if(p>b){let y=_+1=p;x--){let I=d[x];if(!O.has(x-p))I.m(o,N);N=I._first}}t.keys=S?g:r.slice(),t.items=r.slice(),t.blocks=d}var Va=!1;function Z3(){if(Va)return;Va=!0;let e=document.createElement("style");e.textContent=[".fade-enter-active,.fade-leave-active{transition:opacity .2s ease}",".fade-enter-from,.fade-leave-to{opacity:0}",".slide-enter-active,.slide-leave-active{transition:opacity .2s ease,transform .2s ease}",".slide-enter-from{opacity:0;transform:translateY(-8px)}",".slide-leave-to{opacity:0;transform:translateY(8px)}",".scale-enter-active,.scale-leave-active{transition:opacity .2s ease,transform .2s ease}",".scale-enter-from,.scale-leave-to{opacity:0;transform:scale(.95)}",".blur-enter-active,.blur-leave-active{transition:opacity .2s ease,filter .2s ease}",".blur-enter-from,.blur-leave-to{opacity:0;filter:blur(4px)}",".fly-enter-active,.fly-leave-active{transition:opacity .2s ease,transform .2s ease}",".fly-enter-from{opacity:0;transform:translateY(-20px)}",".fly-leave-to{opacity:0;transform:translateY(20px)}"].join(""),document.head.appendChild(e)}function Q3(e,t,r,i){Z3();let n=e.classList,s=t+"-"+r+"-from",a=t+"-"+r+"-active",o=t+"-"+r+"-to",l=!1,c=null;n.add(s,a),requestAnimationFrame(()=>{requestAnimationFrame(()=>{n.remove(s),n.add(o);let f=(u)=>{if(l||u&&u.target!==e)return;if(l=!0,clearTimeout(c),e.removeEventListener("transitionend",f),e.removeEventListener("transitioncancel",f),n.remove(a,o),i)i()};e.addEventListener("transitionend",f),e.addEventListener("transitioncancel",f);let h=0;try{let u=getComputedStyle(e),d=(S)=>Math.max(0,...String(S).split(",").map((g)=>(parseFloat(g)||0)*(/ms\s*$/.test(g.trim())?1:1000)));h=d(u.transitionDuration)+d(u.transitionDelay)}catch{}c=setTimeout(()=>f(),h+50)})})}function ec(e){let t=e!=null&&typeof e==="object"?e.name:null;if(t==="GateFailure"||t==="ComponentFailure")return e;let r=Error(e!=null&&e.message!==void 0?e.message:String(e));r.name="ComponentFailure";let i=e!=null?e.status??e.response?.status:void 0;if(i!==void 0)r.status=i;return r.error=e,r}function Mn(e,t){let r=ec(e),i=t,n=new Set;while(i&&!n.has(i)){if(n.add(i),i.onError){let s=Ve(i),a=le(i._frame);try{i.onError(r,t);return}catch(o){}finally{Y1(a),Re(s)}}i=i._parent}throw e}var Wa=new WeakSet;function tc(e,t){if(Wa.has(e))return;let r=e.__props??[];if(!Array.isArray(r))throw Error(`${e.name||"component"}: static __props must be an array of declared prop names`);for(let i of r){if(typeof i!=="string"||i.length===0)throw Error(`${e.name||"component"}: static __props entries must be non-empty strings`);if(i.startsWith("_"))throw Error(`${e.name||"component"}: declared prop '${i}' collides with component internals — `+"underscore-prefixed names are reserved for the runtime");if(i in t)throw Error(`${e.name||"component"}: declared prop '${i}' collides with a component member (a method or lifecycle slot already answers '${i}')`)}Wa.add(e)}function rc(e,t){let i=za.get(e)?.gates?.[t];if(!i?.cell)throw Error(`[Rip] render gate ${t} has no renderer-resolved source binding — `+"gated components may only be constructed by rip/app createRenderer()");let n=i.value,s=!0;return H1(()=>{if(s)return s=!1,i.cell.read(),n;let a=i.cell.read();for(let o of i.tail){if(a==null)break;a=a[o]}if(a!=null)n=a;return n})}var br=new WeakMap;function Ha(e,t,r){if(t.startsWith("--")&&typeof e.setProperty==="function")if(r==null||r==="")e.removeProperty(t);else e.setProperty(t,String(r));else e[t]=r}function to(e,t){let r=br.get(e);if(t==null){e.removeAttribute("style"),br.delete(e);return}if(typeof t!=="object"){e.setAttribute("style",String(t)),br.delete(e);return}if(r){for(let i of r)if(!(i in t))Ha(e.style,i,"")}br.set(e,Object.keys(t));for(let i of Object.keys(t))Ha(e.style,i,t[i])}function Ga(e,t){let r=e.__props??[],i=e.__extends??null,n=null;for(let s of Object.keys(t)){if(s==="children")continue;if(s.startsWith("__bind_")&&s.endsWith("__")){let a=s.slice(7,-2);if(r.includes(a))continue;throw Error(`${e.name||"component"}: cannot bind unknown prop '${a}' — declared `+`props are [${r.join(", ")}]`)}if(r.includes(s))continue;if(i!==null){(n??={})[s]=t[s];continue}throw Error(`${e.name||"component"}: unknown prop '${s}' — declared props are `+`[${r.join(", ")}]`)}return n}class ro{constructor(e={}){let t=K3(this.constructor,e);if(t)return t;this._state="new",tc(this.constructor,this);let r=this.constructor.__gates,i=yr,n=i?.brand===Ya&&i.component===this.constructor&&i.used!==!0;if(n)i.used=!0;if(r?.length&&!n)throw Error("[Rip] component declares render gates (<~) and cannot be constructed directly or as an embedded child; render gates are honored only by rip/app createRenderer()");if(n){if(za.set(this,i),i.parent)this._parent=i.parent;if(i.stash!=null)this.stash=i.stash;if(i.router!=null)this.router=i.router,Object.defineProperty(this,"params",{get:()=>i.router.params,configurable:!0}),Object.defineProperty(this,"query",{get:()=>i.router.query,configurable:!0})}if(this.stash==null&&globalThis.__ripStash!=null)this.stash=globalThis.__ripStash;if(this.router==null&&globalThis.__ripRouter!=null)this.router=globalThis.__ripRouter;let s=Ga(this.constructor,e);if("children"in e)this.children=e.children;if(this.constructor.__hmrId)this._hmrPropKeys=Qa(e);if(this.constructor.__extends!=null)this._rest=s??{},this.rest=_1(this._rest);this._frame=yt({nested:!1});let a=Ve(this),o=le(this._frame);try{this._init(e)}catch(l){Y1(o),Re(a),this._teardown({state:"failed",hooks:!1,removeDOM:!0}),this._initFailed=!0,Mn(l,this);return}if(Y1(o),Re(a),this.constructor.__hmrId)B3(this)}_init(e){}_updateProp(e,t){if(this._state==="failed"||this._state==="unmounted")return;let r=this.constructor.__props??[];if(!r.includes(e)){if(this.constructor.__extends){this._setRestProp(e,t);return}throw Error(`${this.constructor.name||"component"}: cannot update unknown prop '${e}' — declared `+`props are [${r.join(", ")}]`)}let i=this[e];if(i&&typeof i==="object"&&"value"in i){i.value=t;return}throw Error(`${this.constructor.name||"component"}: prop '${e}' is non-reactive — parent updates `+"cannot reach it (declare it with ':=' to receive updates)")}_setRestProp(e,t){if(e.startsWith("__bind_"))return;if(this._state==="failed"||this._state==="unmounted")return;if(this._rest||(this._rest={}),t==null)delete this._rest[e];else this._rest[e]=t;this.rest.touch();let r=le(this._frame);try{this._applyInheritedProp(this._inheritedEl,e,t)}finally{Y1(r)}}_applyRestToInheritedEl(){if(this._state==="failed"||this._state==="unmounted")return;if(!this._inheritedEl||!this._rest)return;for(let e in this._rest)this._applyInheritedProp(this._inheritedEl,e,this._rest[e])}_applyInheritedProp(e,t,r){if(this._state==="failed"||this._state==="unmounted")return;if(!e||t==="key"||t==="ref"||t==="children"||t.startsWith("__bind_"))return;let i=this._restWriters?.[t];if(i){if(i(),this._frame)this._frame.remove(i);delete this._restWriters[t]}if(r!=null&&typeof r==="object"&&typeof r.read==="function"){(this._restWriters??={})[t]=$1(()=>{this._applyPlainInheritedProp(e,t,r.value)});return}this._applyPlainInheritedProp(e,t,r)}_applyPlainInheritedProp(e,t,r){if(t[0]==="@"){let i=t.slice(1).split(".")[0];this._restHandlers||(this._restHandlers={});let n=this._restHandlers[t];if(n)e.removeEventListener(i,n);if(typeof r==="function"){let s=(a)=>L1(()=>r(a));this._restHandlers[t]=s,e.addEventListener(i,s)}else delete this._restHandlers[t];return}if(t==="class"||t==="className"){if(e instanceof SVGElement)e.setAttribute("class",Er(r));else e.className=Er(r);return}if(t==="style"){to(e,r);return}if(t==="innerHTML"||t==="textContent"||t==="innerText"){e[t]=r??"";return}if(t in e&&!t.includes("-")){e[t]=r;return}if(r==null||r===!1){e.removeAttribute(t);return}if(r===!0){e.setAttribute(t,"");return}e.setAttribute(t,r)}_beginMount(){if(this._state==="new"){this._state="mounting";return}let e=this.constructor.name||"component";if(this._state==="mounting")throw Error(`${e}: cannot mount an instance whose mount is already in progress`);if(this._state==="mounted")throw Error(`${e}: cannot mount an already-mounted instance — construct a new instance for another target`);if(this._state==="failed")throw Error(`${e}: cannot mount a failed instance — its mount rolled back; construct a new instance`);throw Error(`${e}: cannot mount an unmounted instance — its effects were disposed on unmount; construct a new instance`)}_mountCreate(){this._beginMount();let e=Ve(this),t=le(this._frame),r=null,i=!1;try{this._root=this._create()}catch(n){r=n,i=!0}finally{Y1(t),Re(e)}if(i)return this._failMount(r),!1;return!0}_mountSetup(e=null){if(this._state!=="mounting")return this._nodes?.[0]??this._root;let t=Ve(this),r=le(this._frame),i=null,n=!1;try{if(e){let s=this._nodes?.[0]??this._root;if(s?.parentNode)s.parentNode.insertBefore(e,s)}if(this.beforeMount)this.beforeMount();if(this._setup)this._setup();if(this.mounted)this.mounted();this._state="mounted",Rr(e),this._hmrDrainOrphans((s,a)=>console.error(`[Rip] ${s} error:`,a))}catch(s){i=s,n=!0}finally{Y1(r),Re(t)}if(n)return this._failMount(i),e;return this._nodes?.[0]??this._root}_failMount(e){this._teardown({state:"failed",hooks:!1,removeDOM:!0}),Mn(e,this)}_dispose(e,t){if(this._children){for(let r of this._children)try{t(r)}catch(i){e("child teardown",i)}this._children=null}try{this._frame?.dispose()}catch(r){e("owner disposal",r)}if(this._restWriters){for(let r of Object.values(this._restWriters))try{r()}catch(i){e("rest writer cleanup",i)}this._restWriters=null}if(this._restHandlers){if(this._inheritedEl)for(let[r,i]of Object.entries(this._restHandlers))try{this._inheritedEl.removeEventListener(r.slice(1).split(".")[0],i)}catch(n){e("rest handler cleanup",n)}this._restHandlers=null}if(this._refCleanups){let r=this._refCleanups;this._refCleanups=null;try{L1(()=>{for(let i of r)try{i()}catch(n){e("ref cleanup",n)}})}catch(i){e("ref cleanup batch flush",i)}}this._children=null,this._refCleanups=null,this._restWriters=null,this._restHandlers=null}_detachDOM(e,t){if(t)if(this._nodes)for(let r of this._nodes)try{Rr(r)}catch(i){e("DOM detach",i)}else try{Rr(this._root)}catch(r){e("DOM detach",r)}this._root=null,this._nodes=null,this._inheritedEl=null}_teardown({state:e,hooks:t,removeDOM:r}){if(this._state==="failed"||this._state==="unmounted")return;if(this.constructor.__hmrId)U3(this);this._state=e;let i=(n,s)=>console.error(`[Rip] ${n} error:`,s);if(this._hmrDrainOrphans(i),t)try{if(this.beforeUnmount)this.beforeUnmount()}catch(n){i("beforeUnmount",n)}if(this._dispose(i,(n)=>{if(t)n.unmount({removeDOM:r});else n._teardown({state:n._state==="mounted"?"unmounted":"failed",hooks:!1,removeDOM:!0})}),t)try{if(this.unmounted)this.unmounted()}catch(n){i("unmounted",n)}this._detachDOM(i,r),this._target=null}_hmrRelease(){let e=(t,r)=>console.error(`[Rip] ${t} error:`,r);try{if(this.beforeUnmount)this.beforeUnmount()}catch(t){e("beforeUnmount",t)}this._hmrOrphans=[],this._hmrReleasing=!0;try{this._dispose(e,(t)=>t.unmount({removeDOM:!0}))}finally{this._hmrReleasing=!1}this._detachDOM(e,!0),this._frame=yt({nested:!1}),this._state="new"}_hmrRebind(){let e=(i,n)=>console.error(`[Rip] ${i} error:`,n),t=Ve(this),r=le(this._frame);try{if(typeof this._hmrRefreshComputeds==="function")this._hmrRefreshComputeds();if(typeof this._hmrBindEffects==="function")this._hmrBindEffects()}catch(i){return Y1(r),Re(t),e("hmr rebind",i),this._failMount(i),!1}return Y1(r),Re(t),!0}_hmrApplyProps(e){let t=Ga(this.constructor,e);if("children"in e)this.children=e.children;for(let r of this.constructor.__props??[]){let i=`__bind_${r}__`;if(i in e){this[r]=e[i];continue}if(!(r in e))continue;let n=e[r];if(n!=null&&typeof n==="object"&&typeof n.read==="function")this[r]=n;else this._updateProp(r,n)}if(this.constructor.__extends!=null)this._rest=t??{},this.rest.value=this._rest}_hmrDrainOrphans(e){let t=this._hmrOrphans;if(!t)return;this._hmrOrphans=null;for(let r of t)try{r.unmount({removeDOM:!0})}catch(i){e("orphan teardown",i)}}_hmrRerender(){let e=this.constructor.name||"component";if(this._state!=="mounted")throw Error(`${e}: _hmrRerender requires a mounted instance`);let t=this._target,r=this._nodes,n=(r?.[0]??this._root)?.parentNode??null,s=r?.length?r[r.length-1].nextSibling:this._root?this._root.nextSibling:null;if(this._hmrRelease(),!this._hmrRebind())return this;if(typeof this._create!=="function")return this._state="mounted",this._hmrDrainOrphans((a,o)=>console.error(`[Rip] ${a} error:`,o)),this;if(!this._mountCreate())return this;try{let a=n&&n.nodeType!==11?n:null;if(a&&a.isConnected===!1)a=null;if(!a&&typeof t==="string"&&typeof document<"u")a=document.querySelector(t);else if(!a&&t&&t.nodeType!==11&&t.isConnected!==!1)a=t;else if(!a&&typeof document<"u")a=document.querySelector("#content")||document.querySelector("#app");if(a){let o=s&&(typeof a.contains!=="function"||a.contains(s))?s:null;if(this._nodes)for(let l of this._nodes)a.insertBefore(l,o);else if(this._root)a.insertBefore(this._root,o);this._target=a.nodeType===11?null:a}}catch(a){return this._failMount(a),this}return this._mountSetup(),this}mount(e){if(!this._mountCreate())return this;try{if(typeof e==="string")e=document.querySelector(e);if(this._target=e,this._root)e.appendChild(this._root)}catch(t){return this._failMount(t),this}return this._mountSetup(),this}unmount({removeDOM:e=!0}={}){if(this._state==="failed"||this._state==="unmounted")return;if(this._state==="mounted"&&this._parent?._hmrReleasing){this._parent._hmrOrphans.push(this);return}if(this._state==="mounting")throw Error(`${this.constructor.name||"component"}: cannot unmount while mounting`);this._teardown({state:"unmounted",hooks:this._state==="mounted",removeDOM:e})}emit(e,t){if(this._state!=="mounted"||!this._root)throw Error(`${this.constructor.name||"component"}: emit('${e}') outside the mounted window — `+"emit dispatches on the live root; call after mount and before unmount");(this._nodes?.[0]??this._root).dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0}))}static mount(e="body"){return new this().mount(e)}}var Hr={};xe(Hr,{ariaCurrent:()=>Cr,browserAdapter:()=>$r,buildRoutes:()=>Ot,check:()=>Wr,connectFeed:()=>Ur,createApply:()=>Vr,createComponents:()=>vr,createMutation:()=>uo,createRenderer:()=>Dr,createRouter:()=>Ir,createStash:()=>Nr,createWorkspace:()=>Fr,currentRouter:()=>Rc,currentStash:()=>Sc,debounce:()=>mo,delay:()=>Ar,hold:()=>go,interceptClicks:()=>Pr,launch:()=>Mr,ownsAnchor:()=>$t,parseQuery:()=>ze,persistStash:()=>xr,preloadLinks:()=>Lr,rash:()=>Dt,source:()=>so,throttle:()=>po,unwrapStash:()=>Te,validatePrepared:()=>ai});var wr,Vn,no,io=Symbol.for("rip.source"),Wn=Symbol.for("rip.source.family"),nc=64,ic=30000,sc=/^(\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)$/;function D1(e){return e!=null&&(typeof e==="object"||typeof e==="function")&&(e[io]===!0||e[Wn]===!0)}function de(e){return e!=null&&typeof e==="function"&&e[Wn]===!0}no=function(e){let t,r;if(e==null)return 0;if(typeof e==="number"){if(!(Number.isFinite(e)&&e>=0))throw TypeError('Rip App: source staleTime must be a non-negative finite number, a duration string, or "forever"');return e}if(typeof e==="string"){if(e==="forever")return 1/0;if(r=e.match(sc),r)return t=parseFloat(r[1]),(()=>{switch(r[2][0]){case"s":return t*1000;case"m":return t*60000;case"h":return t*3600000;case"d":return t*86400000;case"w":return t*604800000;case"y":return t*31536000000}})()}throw TypeError('Rip App: source staleTime must be a non-negative number, a duration such as "5 min", or "forever"')};wr=function(e,t,r=null){let i=_1(null),n=_1(!1),s=_1(null),a=0,o=null,l=null,c=!1,f=!1,h=!1,u=0,d=0,S=async function(b=!1,_=!1){let y,m;o?.abort(),o=typeof AbortController<"u"?new AbortController:null;let k=++a;if(!b)n.value=!0;let O=h;try{if(y=e(o?.signal),!(y!=null&&typeof y.then==="function"))throw TypeError("Rip App: source fetch must return a Promise");if(m=await y,k!==a)return m;return s.value=null,i.value=m,h=!0,u=Date.now(),d=_&&!f?u+ic:0,m}catch(N){if(k!==a)return;if(N?.name==="AbortError")return;if(s.value=N,!O)throw h=!1,u=0,N;return}finally{if(k===a)n.value=!1,l=null,c=!1,f=!1,r?.()}},g=function(b=!1,_=!1){let y=S(b,_);return l=y,c=_,f=!1,y},p=function(){return t===1/0||Date.now()-unc){o=!1;for(let[l,c]of r){if(l===a)continue;if(c.loading)continue;r.delete(l),c.reset(),o=!0;break}if(!o)break}return},n=function(a){if(a==null)throw TypeError("Rip App: keyed source requires a key");let o=ac(a),l=r.get(o);if(l)return r.delete(o),r.set(o,l),l;return l=wr(function(c){return e(a,c)},t,i),r.set(o,l),i(o),l},s=function(a){return n(a).read()};return s[Wn]=!0,s.cellFor=n,s.reset=function(){let a=Array.from(r.values());r.clear();for(let o of a)o.reset();return},s};function so(e){if(!(e!=null&&typeof e==="object"&&!Array.isArray(e)))throw TypeError("Rip App: source expects an options object");if(typeof e.fetch!=="function")throw TypeError("Rip App: source options require a fetch function");let t=no(e.staleTime);if(Object.prototype.hasOwnProperty.call(e,"kind")){if(!(e.kind==="singleton"||e.kind==="keyed"))throw TypeError("Rip App: source kind must be 'singleton' or 'keyed'");if(e.kind==="singleton"){if(e.fetch.length>1)throw TypeError("Rip App: singleton source fetch accepts at most one AbortSignal parameter");return wr(e.fetch,t)}if(e.fetch.length<1||e.fetch.length>2)throw TypeError("Rip App: keyed source fetch requires a key parameter and accepts one optional AbortSignal parameter");return Vn(e.fetch,t)}if(e.fetch.length>1)throw TypeError("Rip App: inferred source fetch accepts no parameters for a singleton or one key parameter for a keyed family");return e.fetch.length===1?Vn(e.fetch,t):wr(e.fetch,t)}var zn,_t,Hn,Tt,I1=Symbol("rip.app.stash.raw"),We=Symbol("rip.app.stash.signals"),oc=Symbol("rip.app.stash.keys"),lo=Symbol("rip.app.stash.defaults"),lc=Symbol.for("rip.app.stash.purge"),co=new WeakMap,cc=0,qn=_1(0),Gn=function(){return qn.value++},fo=function(e,t){let r=e[We];if(!r)r=new Map,Object.defineProperty(e,We,{value:r});let i=r.get(t);if(!i)i=_1(e[t]),r.set(t,i);return i},wt=function(e){return fo(e,oc)},Kn=function(e){wt(e).value=++cc;return};_t=function(e){if(!(e!=null&&typeof e==="object"))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Array.isArray(e)};var ao=function(e){if(!_t(e))return e;let t=co.get(e);if(t)return t;return zn(e)},He=function(e,t){let r=e?.[I1];if(!r)return e[t];let i=r[t];if(D1(i)){if(de(i))return i;return ao(i.read())}return ao(fo(r,t).value)},Yn=function(e,t,r){let i,n,s,a,o=e?.[I1];if(!o)return e[t]=r,r;if(Array.isArray(o)&&t==="length"){if(a=o.length,s=+r,o.length=s,s!==a){if(o[We]){for(let h=Math.min(a,s),u=Math.max(a,s);h0))throw TypeError("Rip App: stash path must be a non-empty string");let s=[],a=0;if(e[0]!=="["){n=a;while(a=e.length||a===n)throw TypeError(`Rip App: malformed stash path '${e}'`);if(r=e.slice(n,a),a++,e[a]!=="]")throw TypeError(`Rip App: malformed stash path '${e}'`);a++,s.push(r)}else{n=a;while(a{let i=[];for(let n in r){if(!Object.hasOwn(r,n))continue;let s=r[n];i.push(Hn(s,t))}return i})()};Tt=function(e){if(!_t(e))return e;let t=e[I1]?e[I1]:e;if(Array.isArray(t))return(()=>{let i=[];for(let n of t)if(!D1(n))i.push(Tt(n));return i})();let r={};for(let i in t){if(!Object.hasOwn(t,i))continue;let n=t[i];if(D1(n))continue;r[i]=Tt(n)}return r};function ho(e){let t=e?.[I1]?e[I1]:e;if(!(t!=null&&typeof t==="object"))return;Object.defineProperty(t,lo,{value:Tt(t),configurable:!0});return}function _r(e){if(D1(e))return e;if(!_t(e))return e;let t=e[I1]?e[I1]:e;if(Array.isArray(t))return(()=>{let i=[];for(let n of t)i.push(_r(n));return i})();let r={};for(let i in t){if(!Object.hasOwn(t,i))continue;let n=t[i];Object.defineProperty(r,i,{value:_r(n),writable:!0,enumerable:!0,configurable:!0})}return r}function Ye(e,t){let r,i,n;if(!(e!=null&&typeof e==="object"))return;if(!(t!=null&&typeof t==="object"))return;let s=e[I1]?e[I1]:e;for(let a in t){if(!Object.hasOwn(t,a))continue;let o=t[a];if(r=Object.prototype.hasOwnProperty.call(s,a)?s[a]:void 0,D1(r))continue;if(Array.isArray(r)&&r.some(function(l){return D1(l)}))continue;if(i=r!=null&&typeof r==="object"&&!Array.isArray(r),n=o!=null&&typeof o==="object"&&!Array.isArray(o),i&&n)Ye(e[a],o);else e[a]=Tt(o)}return}var uc=function(e,t){let r,i=t[lo];if(!i)return;r=function(n,s,a){let o;for(let l in s){if(!Object.hasOwn(s,l))continue;if(o=s[l],D1(o))continue;if(!(a!=null&&Object.prototype.hasOwnProperty.call(a,l))){delete n[l];continue}if(o!=null&&typeof o==="object"&&!Array.isArray(o))r(n[l],o,a[l])}return},r(e,t,i),Ye(e,i);return},dc={inc:!0,dec:!0,flip:!0,join:!0,keys:!0,has:!0,del:!0,peek:!0,reset:!0,source:!0},mc=function(e,t,r){if(r==="inc")return function(i,n=1){let s=($e(e,i)??0)+n;return kt(e,i,s),s};if(r==="dec")return function(i,n=1){let s=($e(e,i)??0)-n;return kt(e,i,s),s};if(r==="flip")return function(i){let n=!($e(e,i)??!1);return kt(e,i,n),n};if(r==="join")return function(i,n){if(!(n!=null&&typeof n==="object"&&!Array.isArray(n)))throw TypeError("Rip App: join expects a plain object");L1(function(){let s=$e(e,i);if(!(s!=null&&typeof s==="object"&&!Array.isArray(s)))kt(e,i,{}),s=$e(e,i);return(()=>{let a=[];for(let o in n){if(!Object.hasOwn(n,o))continue;let l=n[o];a.push(s[o]=l)}return a})()});return};if(r==="keys")return function(i){let n=i!=null?$e(e,i):e;if(!(n!=null&&typeof n==="object"))return[];let s=n[I1]?n[I1]:n;return wt(s).value,Object.keys(s)};if(r==="has")return function(i){let n,s,a=Ge(i);if(!(a.length>0))return!1;let o=e;for(let l=0;l0))return;let a=e;for(let o=0;o0))throw TypeError("Rip App: component path must be a non-empty string");let t=e.split("/"),r=t.some(function(s){return!s||s==="."||s===".."}),i=t.at(-1),n=t.slice(0,-1).some(function(s){return s.endsWith(".rip")});if(e.includes("\\")||r||n||i===".rip"||!i.endsWith(".rip"))throw TypeError(`Rip App: invalid component path '${e}'`);return e};Xn=function(e){if(typeof e!=="string")throw TypeError("Rip App: component source must be a string");return e};Jn=function(e){if(e===""||e==null)return"";if(typeof e!=="string")throw TypeError("Rip App: component directory must be a string");let t=e.split("/");if(e.includes("\\")||t.some(function(r){return!r||r==="."||r===".."}))throw TypeError(`Rip App: invalid component directory '${e}'`);return e};function vr(){let e=new Map,t=new Map,r=new Set,i=function(s,a){let o=[];for(let l of Array.from(r))o.push((()=>{try{return l(s,a)}catch(c){return console.error("[Rip] component watcher error:",c)}})());return o};return{read(s){return e.get(we(s))},write(s,a){s=we(s),a=Xn(a);let o=e.has(s)?"change":"create";e.set(s,a),t.delete(s),i(o,s);return},del(s){s=we(s),e.delete(s),t.delete(s),i("delete",s);return},exists(s){return e.has(we(s))},size(){return e.size},list(s=""){let a;s=Jn(s);let o=s?s+"/":"",l=[];for(let[c]of e)if(c.startsWith(o)){if(a=c.slice(o.length),!a.includes("/"))l.push(c)}return l},listAll(s=""){s=Jn(s);let a=s?s+"/":"",o=[];for(let[l]of e)if(l.startsWith(a))o.push(l);return o},load(s){let a,o;if(!(s!=null&&typeof s==="object"&&!Array.isArray(s)))throw TypeError("Rip App: component load expects a source object");for(let l in s){if(!Object.hasOwn(s,l))continue;let c=s[l];l=we(l),c=Xn(c),e.set(l,c),t.delete(l)}return},watch(s){if(typeof s!=="function")throw TypeError("Rip App: component watch expects a function");r.add(s);let a=!1;return function(){if(a)return;a=!0,r.delete(s);return}},getCompiled(s){return t.get(we(s))},setCompiled(s,a){if(s=we(s),!(a!=null&&typeof a==="object"&&!Array.isArray(a)))throw TypeError("Rip App: compiled component module must be an object");t.set(s,a);return}}}var yo,So,C1,Qn,Ro,Eo,ko,Zn=/^\w+$/,To={static:0,dynamic:1,optional:2,catchall:3},bo=8;C1=function(e){throw Error(`Rip App: ${e}`)};var vt=function(e){try{return decodeURIComponent(e)}catch(t){return null}};ko=function(e){if(e==="")return"";if(typeof e!=="string")throw TypeError("Rip App: route root must be a string");let t=e.split("/");if(e.includes("\\")||t.some(function(r){return!r||r==="."||r===".."}))throw TypeError(`Rip App: invalid route root '${e}'`);return e};var wo=function(e,t){let r;if(r=/^\[\[(.+)\]\]$/.exec(e)){if(!Zn.test(r[1]))C1(`invalid optional segment '${e}' in '${t}'`);return{kind:"optional",name:r[1]}}else if(r=/^\[\.\.\.(.+)\]$/.exec(e)){if(!Zn.test(r[1]))C1(`invalid catch-all segment '${e}' in '${t}'`);return{kind:"catchall",name:r[1]}}else if(e.startsWith("[..."))return C1(`invalid catch-all segment '${e}' in '${t}'`);else if(r=/^\[(.+)\]$/.exec(e)){if(!Zn.test(r[1]))C1(`invalid dynamic segment '${e}' in '${t}'`);return{kind:"dynamic",name:r[1]}}else if(/^\(.+\)$/.test(e))return{kind:"group"};else if(e.includes("[")||e.includes("]"))return C1(`invalid segment '${e}' in '${t}': markers claim a whole segment`);else return{kind:"static",text:e}};yo=function(e){let t,r=(()=>{let h=[];for(let u of e.slice(0,-4).split("/"))h.push(wo(u,e));return h})();if(r[r.length-1].kind==="group")C1(`route file name cannot be a group segment: '${e}'`);let i=r.filter(function(h){return h.kind!=="group"});for(let h=0;hbo)C1(`more than ${bo} optional segments in '${e}'`);let o="",l=[],c=[{shape:"",display:""}];for(let h of i)switch(l.push(To[h.kind]),h.kind){case"static":t="/"+h.text,o+=t,c=c.map(function(u){return{shape:u.shape+t,display:u.display+t}});break;case"dynamic":o+=`/:${h.name}`,c=c.map(function(u){return{shape:u.shape+"/:",display:`${u.display}/:${h.name}`}});break;case"optional":o+=`/:${h.name}?`,c=c.flatMap(function(u){return[u,{shape:u.shape+"/:",display:`${u.display}/:${h.name}`}]});break;case"catchall":o+=`/*${h.name}`,c=c.map(function(u){return{shape:u.shape+"/*",display:`${u.display}/*${h.name}`}});break}if(o==="")o="/";if(new Set(c.map(function(h){return h.shape||"/"})).size{let l=[];for(let c of e)l.push(wo(c,t));return l})().filter(function(l){return l.kind!=="group"});for(let l of i)if(l.kind==="optional"||l.kind==="catchall")C1(`not-found page under an optional or catch-all segment: '${t}'`);let n=[];for(let l of i)if(l.name!=null){if(n.includes(l.name))C1(`duplicate parameter name '${l.name}' in '${t}'`);n.push(l.name)}let s="",a="",o=[];for(let l of i)if(o.push(To[l.kind]),l.kind==="static")s+="/"+l.text,a+="/"+l.text;else s+=`/:${l.name}`,a+="/:";return{pattern:s+"/*",shape:a+"/*",parts:i,ranks:o}};Ro=function(e,t){let r;return r=function(i,n){let s,a,o,l;if(i===e.length)return n===t.length?[]:null;let c=e[i];return(()=>{switch(c.kind){case"static":if(!(nf.length))continue;if(a=m.slice(f.length),l=a.split("/"),s=l.some(function(k){return!k||k==="."||k===".."}),a.includes("\\")||s||l.at(-1)===".rip")throw TypeError(`Rip App: invalid route file path '${m}'`);if(l.at(-1)==="_layout.rip"){h.set(l.slice(0,-1).join("/"),m);continue}if(l.at(-1)==="_404.rip"){if(l.slice(0,-1).some(function(k){return k.startsWith("_")}))continue;u.push({...So(l.slice(0,-1),a),rel:a,file:m});continue}if(l.some(function(k){return k.startsWith("_")}))continue;if(!a.endsWith(".rip"))throw TypeError(`Rip App: route files must be .rip sources: '${m}'`);d.push({...yo(a),rel:a,file:m})}let S=new Map;for(let m of[...d].sort(function(k,O){return k.relk.pattern)return 1;return 0});let g=new Map;for(let m of[...u].sort(function(k,O){return k.relk.pattern)return 1;return 0});let p=d.map(function(m){return{route:Object.freeze({pattern:m.pattern,file:m.file,layouts:Object.freeze(Qn(m.rel,h))}),parts:m.parts}}),R=u.map(function(m){return{route:Object.freeze({pattern:m.pattern,file:m.file,layouts:Object.freeze(Qn(m.rel,h))}),parts:m.parts}}),b=function(m){if(typeof m!=="string")throw TypeError("Rip App: route match expects a path string");if(!m.startsWith("/"))return null;while(m.length>1&&m.endsWith("/"))m=m.slice(0,-1);return m==="/"?[]:m.slice(1).split("/")},_=function(m){let k;if(l=b(m),!l)return null;for(let O of p){if(k=Ro(O.parts,l),!k)continue;return{route:O.route,params:Object.fromEntries(k)}}return null},y=function(m){let k;if(l=b(m),!l)return null;for(let O of R){if(k=Eo(O.parts,l),!k)continue;return{route:O.route,params:Object.fromEntries(k)}}return null};return Object.freeze({routes:Object.freeze(p.map(function(m){return m.route})),match:_,notFound:y})}function ze(e){if(typeof e!=="string")throw TypeError("Rip App: parseQuery expects a query string");return Object.fromEntries(new URLSearchParams(e))}var G1,ei,_o,Or;G1=function(e){let t=e.indexOf("#"),r=t>=0?e.slice(t+1):"",i=t>=0?e.slice(0,t):e,n=i.indexOf("?"),s=n>=0?i.slice(n+1):"";return{path:n>=0?i.slice(0,n):i,query:s,hash:r}};ei=function(e,t){let r=Object.keys(t);return r.length===Object.keys(e).length&&r.every(function(n){return e[n]===t[n]})?e:t};Or=function(e){if(!(e!=null&&typeof e.match==="function"&&Array.isArray(e.routes)))throw TypeError("Rip App: createRouter requires a route manifest");return e};_o=function(e){if(e===""||e==null)return"";if(!(typeof e==="string"&&e.startsWith("/")&&!e.endsWith("/")))throw TypeError(`Rip App: invalid router base '${e}'`);return e};function Ir(e){let t,{routes:r,adapter:i,onError:n}=e??{};if(!(r!=null&&(typeof r==="function"||typeof r.match==="function"&&Array.isArray(r.routes))))throw TypeError("Rip App: createRouter requires a route manifest or manifest thunk");for(let j of["read","push","replace","go","listen"])if(typeof i?.[j]!=="function")throw TypeError(`Rip App: router adapter requires a ${j} function`);let s=_o(e?.base),a=e?.hash===!0;if(s&&a)throw TypeError("Rip App: a base path does not apply in hash mode");let o=typeof r==="function"?Or(r()):Or(r),l=new Set,c=null,f=_1(null),h=_1(null),u=_1({}),d=_1({}),S=_1(""),g=Ar(100,_1(!1)),p=H1(function(){let j=h.value;if(!j)return null;return{route:j,layouts:j.layouts,params:u.value,query:d.value}}),R=function(j){if(!s)return j;if(j===s)return"/";if(j.startsWith(s+"/"))return j.slice(s.length);return null},b=function(j){if(!s)return j;return j==="/"?s:s+j},_=function(j){return a?i.read().split("#")[0]+"#"+j:b(j)},y=function(j){return n?.({status:404,path:j}),!1},m=0,k=function(j){return typeof j==="string"&&!j.startsWith("//")&&!j.includes("\\")},O=function(j){if(!k(j))return null;return o.match(j)},N=function(j){if(!k(j))return null;return o.match(j)??o.notFound?.(j)??null},x=function(j,q,t1,M){let A=ei(u.value,j.params),C=ei(d.value,ze(t1));L1(function(){return f.value=q,h.value=j.route,u.value=A,d.value=C,S.value=M});let w={path:q,route:j.route,params:A,query:C,hash:M};m+=1;try{for(let D of Array.from(l))try{D(w)}catch(B){console.error("[Rip] router onNavigate error:",B)}}finally{m-=1}return!0},I=function(){if(m>=10)throw Error("Rip App: navigation loop — ten nested navigations from onNavigate")},H=function(){let j,q,t1,M,A,C=i.read();if(a){if(j=C.indexOf("#"),t1=j>=0?C.slice(j+1):"/",t1==="")t1="/";({path:M,query:A,hash:q}=G1(t1))}else if({path:M,query:A,hash:q}=G1(C),M=R(M),M==null)return y(G1(C).path);let w=N(M);if(!w)return y(M);return x(w,M,A,q)},G=null,K=null,Z=function(){G=null;let j=i.readState?.()??{};return i.replace(i.read(),{...j,__ripScroll:i.scroll?.save?.()??null})},V=function(){return!G?G=setTimeout(Z,100):void 0};return t={init(){if(c)return t;return H(),c=i.listen(function(){if(!H())return;let j=i.readState?.();return i.scroll?.restore?.(j?.__ripScroll??null)}),K=i.scroll?.watch?.(V)??null,t},push(j,q={}){I();let{path:t1,query:M,hash:A}=G1(j),C=N(t1);if(!C)return y(t1);let w=i.scroll?.save?.()??null,D=i.readState?.()??{};if(i.replace(i.read(),{...D,__ripScroll:w}),i.push(_(j),null),x(C,t1,M,A),!q.noScroll)i.scroll?.top?.();return!0},replace(j,q={}){I();let{path:t1,query:M,hash:A}=G1(j),C=N(t1);if(!C)return y(t1);let w=i.readState?.()??{};if(i.replace(_(j),{...w,__ripScroll:null}),x(C,t1,M,A),!q.noScroll)i.scroll?.top?.();return!0},back(){return i.go(-1)},forward(){return i.go(1)},match(j){let{path:q,query:t1,hash:M}=G1(j),A=O(q);if(!A)return null;return{route:A.route,params:A.params,query:ze(t1),hash:M}},claims(j){let q,t1,M,A,C;if(!(typeof j==="string"&&j.length>0))return null;if(a){if(q=j.indexOf("#"),q<0)return null;if(M=j.slice(q+1),M==="")M="/";({path:A,query:C,hash:t1}=G1(M))}else{if(!j.startsWith("/"))return null;if({path:A,query:C,hash:t1}=G1(j),A=R(A),A==null)return null}let w=O(A);if(!w)return null;let D=A+(C?"?"+C:"")+(t1?"#"+t1:"");return{path:A,url:D,route:w.route,params:w.params,query:ze(C),hash:t1}},onNavigate(j){if(typeof j!=="function")throw TypeError("Rip App: onNavigate expects a function");return l.add(j),function(){return l.delete(j)}},rebuild(){let j,q,t1,M,A;if(o=typeof r==="function"?Or(r()):o,!c)return;let C=i.read();if(a){if(j=C.indexOf("#"),t1=j>=0?C.slice(j+1):"/",t1==="")t1="/";({path:M,query:A,hash:q}=G1(t1))}else if({path:M,query:A,hash:q}=G1(C),M=R(M),M==null)return y(G1(C).path);let w=N(M);if(!w)return y(M);let D=h.value,B=D?.layouts??[],a1=w.route.layouts??[],h1=B.length===a1.length&&B.every(function(f1,z){return f1===a1[z]});if(D?.file===w.route.file&&h1&&f.value===M)return;x(w,M,A,q);return},destroy(){if(c?.(),c=null,K?.(),K=null,G)clearTimeout(G);G=null;return}},Object.defineProperty(t,"current",{get(){return p.value}}),Object.defineProperty(t,"path",{get(){return f.value}}),Object.defineProperty(t,"hash",{get(){return S.value}}),Object.defineProperty(t,"params",{get(){return u.value}}),Object.defineProperty(t,"query",{get(){return d.value}}),Object.defineProperty(t,"navigating",{get(){return g.value},set(j){return g.value=j}}),t}function $r(){if(typeof window>"u"||window.history==null||window.location==null)throw Error("Rip App: browserAdapter requires a browser environment");window.history.scrollRestoration="manual";let e=function(r){return window.requestAnimationFrame?window.requestAnimationFrame(r):setTimeout(r,16)},t=0;return{read(){return window.location.pathname+window.location.search+window.location.hash},readState(){return window.history.state},push(r,i){return window.history.pushState(i,"",r)},replace(r,i){return window.history.replaceState(i,"",r)},go(r){return window.history.go(r)},listen(r){return window.addEventListener("popstate",r),function(){return window.removeEventListener("popstate",r)}},scroll:{save(){return{x:window.scrollX,y:window.scrollY}},restore(r){let i;if(r==null)return;let n=++t,s=r.x||0,a=r.y||0,o=0;i=function(){if(n!==t)return;let l=Math.max(0,(window.document?.documentElement?.scrollHeight||0)-window.innerHeight);return window.scrollTo(s,Math.min(a,l)),o+=1,a>l&&o<20?e(i):void 0},e(i);return},top(){return t+=1,window.scrollTo(0,0)},watch(r){return window.addEventListener("scroll",r,{passive:!0}),function(){return window.removeEventListener("scroll",r)}}}}}var ti,No,De;No=Un();De=function(e,t,r,i=null){let n=i??r?.message??String(r),s=Error(n);return s.name="GateFailure",s.status=r?.status??r?.response?.status??500,s.path=e,s.file=t,s.error=r,s};ti=function(e,t){let r=e.getCompiled(t);if(!(r!=null&&typeof r==="object"))throw Error(`Rip App: no precompiled component module for '${t}'`);let i=function(s){return typeof s==="function"&&typeof s.prototype?.mount==="function"};if(i(r.default))return r.default;let n=[];for(let s in r){let a=r[s];if(s==="default")continue;if(i(a))n.push(a)}if(n.length!==1)throw Error(`Rip App: precompiled module '${t}' must export exactly one component class`);return n[0]};function Dr(e){let t;if(!(e!=null&&typeof e==="object"))throw TypeError("Rip App: createRenderer expects an options object");let{router:r,stash:i,components:n,target:s,onError:a}=e;if(!(r!=null&&typeof r==="object"))throw TypeError("Rip App: createRenderer requires a router object");if(!(i!=null&&Te(i)!==i))throw TypeError("Rip App: createRenderer requires a stash built by createStash");if(!(n!=null&&typeof n.getCompiled==="function"))throw TypeError("Rip App: createRenderer requires a component registry");if(!(s!=null&&typeof s.appendChild==="function"))throw TypeError("Rip App: createRenderer requires a target with appendChild()");if(a!=null&&typeof a!=="function")throw TypeError("Rip App: createRenderer onError must be a function");let o=[],l=null,c=0,f=null,h=[],u=null,d=null,S=null,g=!1,p=function(z,i1){let X=Object.keys(z);return X.length===Object.keys(i1).length&&X.every(function(r1){return z[r1]===i1[r1]})},R=function(z,i1){return z.length===i1.length&&z.every(function(X,r1){return i1[r1]===X})},b=function(z){let i1=Te(i),X=z.split(".");for(let r1=0;r1",P.file,`Rip App: ${P.file} static __gates must be an array`);for(let W=0;W0))throw _(String(J),P.file,`Rip App: ${P.file} has a malformed render gate path`);if(F!=null&&typeof F!=="function")throw _(J,P.file,`Rip App: gate '${J}' has a non-function key`);if(o1=b(J),!o1)throw _(J,P.file,`Rip App: gate '${J}' does not resolve to a source`);if(r1=o1.cell,de(r1)){if(!F)throw _(J,P.file,`Rip App: gate '${J}' is keyed and requires a key function`);try{c1=F(i1,X),r1=r1.cellFor(c1)}catch(L){throw Q=L,De(J,P.file,Q,`Rip App: gate '${J}' key failed: ${Q.message}`)}}else if(F)throw _(J,P.file,`Rip App: gate '${J}' is a singleton and does not accept a key function`);if(P.bindings[W]={cell:r1,tail:o1.tail,path:J,file:P.file},!n1.has(r1))n1.set(r1,{cell:r1,path:J,file:P.file,entryIndex:v})}}return Array.from(n1.values())},k=async function(z,i1,X,r1){let Q,l1,c1=m(z,i1,X),F=await Promise.allSettled((()=>{let n1=[];for(let v of c1)n1.push(v.cell.ensure());return n1})());if(r1!==c)return!1;let J=null,o1=function(n1,v){if(n1.entryIndex=v,J==null||v=J.entryIndex)break;for(let P of v.bindings){l1=P.cell.peek();for(let W of P.tail){if(l1==null)break;l1=l1[W]}if(l1==null){o1(_(P.path,P.file,`Rip App: gate '${P.path}' resolved to ${l1}; every gated subpath must exist and be non-null`),n1);break}P.value=l1}}if(J!=null)throw J;return!0},O=function(z,i1){return No(z.cls,{gates:z.bindings,parent:i1,stash:i,router:r})},N=function(z){let i1=[];for(let X=z.length-1;X>=0;X--){let r1=z[X];try{r1.unmount?.()}catch(Q){i1.push(Q);try{r1._teardown?.({state:"unmounted",hooks:!1,removeDOM:!0})}catch(l1){i1.push(l1)}}}return i1},x=function(){let z=o;o=[],l=null,h=[],u=null,d=null;let i1=N(z);if(i1.length)throw i1[0];return},I=null,H=function(){I?.remove?.(),I=null;return},G=function(z){let i1,X;H();let r1=z.error?.stack??z.stack??z.message??String(z);I=(()=>{if(typeof document<"u"&&typeof document.createElement==="function")return i1=document.createElement("pre"),i1.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",i1.textContent=r1,i1;else return X={nodeName:"PRE",textContent:r1,parentNode:null,remove(){let Q=X.parentNode?.children,l1=Q?.indexOf(X)??-1;if(l1>=0)Q.splice(l1,1);X.parentNode=null;return}},X})(),s.appendChild(I);return},K=function(){if(typeof document<"u"&&typeof document.createDocumentFragment==="function")return document.createDocumentFragment();let z=[];return{children:z,appendChild(i1){return z.push(i1),i1}}},Z=function(z,i1=s){if(H(),z.nodeType===11)i1.appendChild(z);else for(let X of z.children)i1.appendChild(X);return},V=function(z,i1){let X,r1=z._nodes??[z._root];for(let Q of r1){if(!Q)continue;if(Q.matches?.("#content"))return Q;if(X=Q.querySelector?.("#content"),X)return X}return r1.find(function(Q){return Q!=null})??i1},j=function(z){return z?.childNodes??z?.children??[]},q=function(z,i1){z.slot=i1,z.slotOwned=j(i1).length;return},t1=function(){let z,i1,X=s;for(let r1=0;r10&&Q.slot!=null&&Q.slot!==X){i1=Array.from(j(Q.slot)).slice(Q.slotOwned??0),q(Q,X);for(let l1 of i1)X.appendChild(l1);z._target=X}if(r1===h.length-1)break;X=V(z,X)}if(h.length>1)u=X;return},M=function(z,i1,X){let r1,Q,l1;if(!z.some(function(n1){return typeof n1.cls.prototype?.onError==="function"}))return!1;let c1=K(),F=c1,J=[];try{for(let n1=0;n10)q(v,F);if(Q.mount?.(F),Q._state==="failed")return N(J),!1;F=V(Q,F)}if(X!==c)return N(J),!1;r1=null;for(let n1=J.length-1;n1>=0;n1--){let v=J[n1];if(typeof v.onError==="function"){r1=v;break}}Z(c1)}catch(n1){return console.error("[Rip] boundary chain failed to mount:",n1),N(J),!1}let o1=o;o=J,l=J[J.length-1]??null,h=z,u=F,d=null;try{r1.onError(i1)}catch(n1){console.error("[Rip] boundary onError error:",n1)}for(let n1 of N(o1))console.error("[Rip] boundary teardown error:",n1);return!0},A=function(z,i1){let X=null;for(let Q=z.length-1;Q>=0;Q--){let l1=z[Q];if(typeof l1.instance?.onError==="function"){X=l1.instance;break}}if(!X)return!1;let r1=o.slice(z.length);o=z.map(function(Q){return Q.instance}),l=o[o.length-1]??null,h=z,d=null;try{X.onError(i1)}catch(Q){console.error("[Rip] boundary onError error:",Q)}for(let Q of N(r1))console.error("[Rip] boundary teardown error:",Q);return!0},C=async function(z,i1,X=n){let r1,Q,l1,c1,F,J,o1=z?.route;if(!o1?.file)throw Error("Rip App: renderer route state requires route.file");let n1=z.params??{},v=z.query??{},P=z.layouts??[];if(!Array.isArray(P))throw Error("Rip App: renderer route state layouts must be an array");let W=h.map(function(S1){return S1.file}),s1=S;if(S=null,s1==null&&l!=null&&d!=null&&o1.file===d.file){if(R([...P,o1.file],W)&&p(n1,d.params)){if(!(p(v,d.query)||y(h,n1,v))){if(typeof l.load==="function")await l.load(n1,v);if(i1!==c)return null;return d={file:o1.file,params:n1,query:v},l}}}let L=[...P,o1.file],U=d!=null&&P.length>0&&h.length===P.length+1&&R(P,W.slice(0,-1))&&!y(h.slice(0,-1),n1,v),e1=s1!=null?Math.max(0,Math.min(s1,L.length-1)):U?P.length:0;if(s1!=null&&e1>0){if(!(h.length===L.length&&R(L.slice(0,e1),W.slice(0,e1))))e1=0}let m1=[];for(let S1=0;S10){if(l1=U?A(m1.slice(0,r1),Q):M(m1.slice(0,r1),Q,i1),l1)return null}}throw Q}let d1=K(),R1=d1,E1=[],A1=e1>0?m1[e1-1].instance:null,k1=e1>0,w1=k1?V(A1,s):s;try{for(let S1=m1.slice(e1),q1=0;q10)q(xt,R1);if(c1.mount?.(R1),c1._state==="failed")throw Error(`Rip App: component '${xt.file}' failed during mount`);if(e1+q11?R1:w1,h=m1,d={file:o1.file,params:n1,query:v};let y1=N(p1);if(g=y1.length>0,y1.length)for(let S1 of y1)if(Q=De("","",S1),a!=null)try{a(Q)}catch(q1){console.error("[Rip] renderer teardown reporter failed:",q1)}else console.error("[Rip] renderer teardown error:",Q);return l},w=function(z){let i1,X,r1=z?.route;if(!r1?.file)return;let Q=z.params??{},l1=z.query??{},c1=z.layouts??r1.layouts??[],F=h.map(function(n1){return n1.file}),J=d!=null&&R(c1,F.slice(0,-1));if(J&&r1.file===d.file&&p(Q,d.params))return;let o1=J?[r1.file]:[...c1,r1.file];try{i1=(()=>{let n1=[];for(let v of o1)n1.push({file:v,cls:ti(n,v)});return n1})(),X=m(i1,Q,l1)}catch(n1){return}for(let n1 of X)n1.cell.preload().catch(function(){return null});return},D=function(z,i1){if(!(z!=null&&typeof z==="object"&&typeof i1==="string"))return null;let X=function(r1){return typeof r1==="function"&&r1.__hmrId===i1};if(X(z.default))return z.default;for(let r1 in z){let Q=z[r1];if(X(Q))return Q}return null},B=function(z){let i1=z+"#",X=[];for(let Q of h)if(Q.file===z&&Q.instance!=null)X.push(Q.instance);for(let[Q,l1]of jn())if(typeof Q==="string"&&Q.startsWith(i1)){for(let c1 of l1.instances)if(!X.includes(c1))X.push(c1)}let r1=[];for(let Q of X)r1.push({instance:Q,entry:h.find(function(l1){return l1.instance===Q})??null});return r1},a1=function(z,i1){let X,r1,Q,l1,c1=(()=>{let n1=[];for(let v of z)if(typeof v==="string"&&v.endsWith(".rip"))n1.push(v);return n1})();if(!(c1.length>0))return"unknown";let F=0,J=!1,o1=new Set;for(let n1 of c1){if(l1=i1.getCompiled(n1),Q=B(n1),l1==null){if(typeof i1.exists==="function"&&!i1.exists(n1)){if(Q.some(function(v){return v.instance._state!=="unmounted"}))return"fallback"}else J=!0;continue}for(let{instance:v,entry:P}of Q){if(o1.has(v))continue;if(v._state==="unmounted")continue;if(v._state!=="mounted")return"fallback";if(r1=v.constructor?.__hmrId,X=typeof r1==="string"?D(l1,r1):null,X==null)return"fallback";if(St(X),Rt(v.constructor,X)!=="patch")return"fallback";if(Bn(v,X),o1.add(v),F+=1,P!=null){if(P.cls=X,P!==h[h.length-1])t1()}}}if(F>0)return"done";return J?"unknown":"idle"},h1=async function(z,i1=n){let X,r1,Q,l1,c1;if(!(Array.isArray(z)&&z.length>0))return"noop";for(let U of z)if(U==="stash.rip"||U.startsWith("stash/")||U==="seed.rip")return"escape";let F=r.current;if(!(F?.route?.file&&h.length>0))return"noop";let o1=[...F.layouts??F.route.layouts??[],F.route.file],n1=R(o1,h.map(function(U){return U.file})),v=Fn();try{if(c1=a1(z,i1),c1==="done")return Tr(v),"narrow";if(c1==="idle"&&n1)return ke("noop",{paths:[...z]}),"noop"}catch(U){console.error("[Rip] HMR patch failed; falling back to remount:",U),ke("reject",{reason:"patch-failed",paths:[...z],message:U?.message?String(U.message):String(U)})}let P=new Set(z),W=-1;for(let U=0;U{if(X?.name==="GateFailure")return X;else return Q=z?.route?.file??"",De(X?.path??Q,Q,X)})(),a?.(r1),l==null)G(r1);throw r1}finally{if(l1===c&&(Array.isArray(r)||typeof r==="string"?r.includes("navigating"):("navigating"in r)))r.navigating=!1}};let f1=null;return f1={current:null,mount:t,preload:w,remountDirty:h1,start(){if(f)return f1;return r.init?.(),f=$1(function(){let z=r.current;if(z?.route)t(z).catch(function(){return null});return}),f1},stop(){let z,i1;if(c++,f?.(),f=null,Array.isArray(r)||typeof r==="string"?r.includes("navigating"):("navigating"in r))r.navigating=!1;try{x()}catch(X){throw z=X,i1=De("","",z),a?.(i1),i1}return}},Object.defineProperty(f1,"current",{get(){return l}}),f1}var vo,Oo,ri=Symbol.for("rip.app.stash.persisted"),Ao=Symbol.for("rip.app.stash.purge");Oo=function(e,t){return D1(t)?void 0:t};vo=function(e){if(e.storage!=null)return e.storage;if(!(typeof window<"u"&&window.localStorage!=null))throw Error("Rip App: persistStash requires a browser or an injected storage");return e.local?window.localStorage:window.sessionStorage};function xr(e,t={}){let r,i=Te(e)||e;if(i[ri])return function(){return null};i[ri]=!0;let n=vo(t),s=t.key||"__rip_app",a=t.debounce??2000;try{if(r=n.getItem(s),r)Ye(e,JSON.parse(r))}catch(u){}let o=null,l=function(){o=null;try{n.setItem(s,JSON.stringify(Te(e),Oo))}catch(u){}return},c=!1,f=$1(function(){if(qn.value,!c){c=!0;return}if(o!=null)clearTimeout(o);return o=setTimeout(l,a),function(){return o!=null?clearTimeout(o):void 0}});if(typeof window<"u")window.addEventListener("beforeunload",l);Object.defineProperty(i,Ao,{value(){if(o!=null)clearTimeout(o),o=null;try{n.removeItem(s)}catch(u){}return},configurable:!0,writable:!0});let h=!1;return function(){if(h)return;if(h=!0,f?.(),typeof window<"u")window.removeEventListener("beforeunload",l);l(),i[Ao]=null,i[ri]=!1;return}}var Io,ni;ni=function(e){if(e.hasAttribute?.("data-router-ignore"))return!0;if(e.hasAttribute?.("download"))return!0;let t=e.getAttribute?.("target");if(t&&t.toLowerCase()!=="_self")return!0;return!1};function It(e){let t,r=e.getAttribute?.("href")??e.href;if(!(typeof r==="string"&&r.length>0))return null;if(/^[a-z][a-z0-9+.-]*:/i.test(r)){if(t=typeof location<"u"?location.origin:null,!(t!=null&&r.startsWith(t)))return null;r=r.slice(t.length)}if(r.startsWith("//")||r.includes("\\"))return null;return r}function $t(e,t){if(t==null)return!1;if(ni(t))return!1;let r=It(t);if(r==null)return!1;return e.claims(r)!=null}Io=function(){if(!(typeof document<"u"&&typeof document.querySelectorAll==="function"))throw Error("Rip App: ariaCurrent requires a browser or an injected host");return{anchors(){return Array.from(document.querySelectorAll("a[href]"))},observe(e){if(typeof MutationObserver>"u")return null;let t=!1,r=new MutationObserver(function(){if(t)return;return t=!0,requestAnimationFrame(function(){return t=!1,e()})});return r.observe(document.documentElement??document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["href","target","download","data-router-ignore"]}),function(){return r.disconnect()}}}};function Cr(e,t=null){if(!(e!=null&&typeof e.claims==="function"))throw TypeError("Rip App: ariaCurrent requires a router");t=t??Io();let r=new WeakMap,i=function(){let l,c,f,h,u=e.path;for(let d of t.anchors()){if(l=ni(d)?null:e.claims(It(d)??""),f=l==null||u==null?null:l.path===u?"page":l.path!=="/"&&u.startsWith(l.path+"/")?"true":null,c=d.getAttribute?.("aria-current")??null,h=r.get(d),h!==void 0&&c!==h){if(r.delete(d),c!=null)continue;h=void 0}if(f!=null){if(h===void 0&&c!=null)continue;if(c!==f)d.setAttribute("aria-current",f);r.set(d,f)}else if(h!==void 0)d.removeAttribute("aria-current"),r.delete(d)}return},n=function(){try{i()}catch(l){console.error("[Rip] aria-current walk failed:",l)}return},s=$1(function(){return e.path,n()}),a=t.observe?.(n)??null,o=!1;return function(){if(o)return;o=!0,s(),a?.();try{for(let l of t.anchors())if(r.has(l)){if((l.getAttribute?.("aria-current")??null)===r.get(l))l.removeAttribute("aria-current");r.delete(l)}}catch(l){}return}}var $o,Do,ii,si;Do=50;$o=3000;si=function(){if(!(typeof document<"u"&&typeof document.addEventListener==="function"))throw Error("Rip App: link listeners require a browser or an injected host");return{listen(e,t,r=null){return document.addEventListener(e,t,r??!1),function(){return document.removeEventListener(e,t,r??!1)}}}};ii=function(e){while(e!=null&&e.tagName!=="A")e=e.parentElement;return e??null};function Pr(e,t=null){if(!(e!=null&&typeof e.claims==="function"&&typeof e.push==="function"))throw TypeError("Rip App: interceptClicks requires a router");t=t??si();let r=function(s){if(s.defaultPrevented)return;if(s.button!==0||s.metaKey||s.ctrlKey||s.shiftKey||s.altKey)return;let a=ii(s.target);if(!(a!=null&&$t(e,a)))return;let o=e.claims(It(a));if(o==null)return;s.preventDefault(),e.push(o.url,{noScroll:a.hasAttribute?.("data-router-noscroll")===!0});return},i=t.listen("click",r),n=!1;return function(){if(n)return;n=!0,i();return}}function Lr(e,t,r=null){if(!(e!=null&&typeof e.claims==="function"))throw TypeError("Rip App: preloadLinks requires a router");if(!(t!=null&&typeof t.preload==="function"))throw TypeError("Rip App: preloadLinks requires a renderer with preload()");r=r??si();let i=null,n=null,s={href:null,at:0},a=function(){if(i!=null)clearTimeout(i);i=null,n=null;return},o=function(h){let u=ii(h.target);if(!(u!=null&&$t(e,u)))return;if(u===n)return;a(),n=u;let d=It(u);i=setTimeout(function(){i=null,n=null;let S=Date.now();if(d===s.href&&S-s.at<$o)return;s.href=d,s.at=S;let g=e.claims(d);return g!=null?t.preload(g):void 0},Do);return},l=function(h){if(n==null)return;let u=h.relatedTarget;if(!(u!=null&&n.contains?.(u)))a();return},c=[r.listen("pointerover",o,{passive:!0}),r.listen("focusin",o,{passive:!0}),r.listen("pointerout",l,{passive:!0}),r.listen("focusout",l,{passive:!0})],f=!1;return function(){if(f)return;f=!0,a();for(let h of c)h();return}}var qe,xo,z1,Co;qe="routes";z1=function(e){throw Error(`Rip App: ${e}`)};var pc=function(e){let t;if(!(e!=null&&typeof e==="object"&&!Array.isArray(e)))z1("launch requires a bundle object");for(let r of["modules","compiled"]){if(t=e[r],t==null)continue;if(!(typeof t==="object"&&!Array.isArray(t)))z1(`launch bundle ${r} must be an object of store paths`)}if(e.seed!=null&&(typeof e.seed!=="object"||Array.isArray(e.seed)))z1("launch bundle seed must be an object");return e},gc=["read","write","del","exists","size","list","listAll","load","watch","getCompiled","setCompiled"];Co=function(e){if(!(typeof e==="object"&&!Array.isArray(e)))z1("launch components must be an object");for(let t of gc)if(typeof e[t]!=="function")z1(`launch components store is missing '${t}'`);return e};var ai=function(e,t=null){let r=pc(e),n=[...new Set([...Object.keys(r.modules??{}),...Object.keys(r.compiled??{})])].filter(function(o){return o.startsWith(qe+"/")});Ot(n,qe);let s=r.compiled?.["stash.rip"],a=t??s?.stash;if(a==null&&s!=null)z1("the bundle's 'stash.rip' module must export 'stash'");if(a!=null&&(typeof a!=="object"||Array.isArray(a)))z1("the application stash must be a plain object");return{bundle:r,declaration:a}};xo=function(){if(!(typeof document<"u"&&typeof document.querySelector==="function"))z1("launch requires a target outside the browser");let e=document.querySelector("#app");if(!e)e=document.createElement("div"),e.id="app",document.body.appendChild(e);return e};function Mr(e){let t,r;if(!(e!=null&&typeof e==="object"))z1("launch requires an options object");if(globalThis.__ripStash!=null)z1("an application is already launched; destroy it first");let i=ai(e.bundle,e.declaration),n=i.bundle,s=e.target??xo(),a=e.adapter??$r(),o=i.declaration,l=Nr(_r(o??{}));Ye(l,n.seed??{}),ho(l);let c=e.components!=null?Co(e.components):vr();if(n.modules!=null)c.load(n.modules);if(n.compiled!=null){let b=n.compiled;for(let _ in b){if(!Object.hasOwn(b,_))continue;let y=b[_];if(!c.exists(_))c.write(_,"");c.setCompiled(_,y)}}let f=Ir({routes(){return Ot(c.listAll(qe),qe)},adapter:a,base:e.base,hash:e.hash,onError:e.onError}),h=Dr({router:f,stash:l,components:c,target:s,onError:e.onError}),u=c.watch(function(b,_){return _.startsWith(qe+"/")?f.rebuild():void 0}),d=null;if(e.links!=null||typeof document<"u"&&typeof document.addEventListener==="function")t=Pr(f,e.links),r=Lr(f,h,e.links),d=function(){t(),r();return};let S=null;if(typeof document<"u"&&typeof document.querySelectorAll==="function")S=Cr(f);let g=null;if(e.persist)g=xr(l,{local:e.persist==="local",key:"__rip_app",storage:e.storage});let p=!1,R=function(){if(p)return;p=!0;let b=[],_=function(y){try{y()}catch(m){b.push(m)}return};if(_(function(){return S?.()}),_(function(){return d?.()}),_(function(){return h.stop()}),_(function(){return f.destroy()}),_(function(){return u()}),_(function(){return g?.()}),globalThis.__ripStash===l)delete globalThis.__ripStash;if(globalThis.__ripRouter===f)delete globalThis.__ripRouter;if(b.length===1)throw b[0];if(b.length>1)throw AggregateError(b,"Rip App: launch.destroy failed");return};globalThis.__ripStash=l,globalThis.__ripRouter=f;try{if(typeof s.replaceChildren==="function")s.replaceChildren();else if(Array.isArray(s.children))s.children.length=0;h.start()}catch(b){throw R(),b}return{stash:l,components:c,router:f,renderer:h,destroy:R}}var oi,jr,li,ci,fi,B1;B1=function(e){if(!(typeof e==="string"&&e.length>0))throw TypeError("Rip Workspace: component path must be a non-empty string");let t=e.split("/"),r=t.some(function(s){return!s||s==="."||s===".."||s.startsWith(".")}),i=t.at(-1),n=t.slice(0,-1).some(function(s){return s.endsWith(".rip")});if(e.includes("\\")||e.startsWith("/")||r||n||i===".rip"||!i.endsWith(".rip"))throw TypeError(`Rip Workspace: invalid component path '${e}'`);return e};jr=function(e){if(typeof e!=="string")throw TypeError("Rip Workspace: component source must be a string");return e};li=function(e){if(e===""||e==null)return"";if(typeof e!=="string")throw TypeError("Rip Workspace: component directory must be a string");let t=e.split("/");if(e.includes("\\")||e.startsWith("/")||t.some(function(r){return!r||r==="."||r===".."||r.startsWith(".")}))throw TypeError(`Rip Workspace: invalid component directory '${e}'`);return e};ci=function(e){if(!(typeof e==="string"&&/^[A-Za-z0-9_]{6}$/.test(e)))throw TypeError("Rip Workspace: publication hash must be six Base64URL-folded characters");return e};fi=function(e){if(!(e!=null&&typeof e==="object"&&!Array.isArray(e)))throw TypeError("Rip Workspace: compiled component module must be an object");return e};oi=function(e){let t;if(!(e!=null&&typeof e==="object"&&!Array.isArray(e)))throw TypeError("Rip Workspace: prepared state must be an object");let r=ci(e.hash);if(!(e.sources!=null&&typeof e.sources==="object"&&!Array.isArray(e.sources)))throw TypeError("Rip Workspace: prepared sources must be an object");if(!(e.compiled!=null&&typeof e.compiled==="object"&&!Array.isArray(e.compiled)))throw TypeError("Rip Workspace: prepared compiled modules must be an object");let i=new Map,n=new Map,s=e.sources;for(let o in s){if(!Object.hasOwn(s,o))continue;let l=s[o];i.set(B1(o),jr(l))}let a=e.compiled;for(let o in a){if(!Object.hasOwn(a,o))continue;let l=a[o];if(o=B1(o),!i.has(o))throw Error(`Rip Workspace: compiled module '${o}' has no source`);n.set(o,fi(l))}return{hash:r,sources:i,compiled:n}};function Fr(){let e,t=new Map,r=new Map,i=new Set,n=null,s=!1,a=function(l,c){for(let f of Array.from(i))try{f(l,c)}catch(h){console.error("[Rip] workspace watcher error:",h)}return},o=function(l){t=l.sources,r=l.compiled,n=l.hash;return};return e={read(l){return t.get(B1(l))},write(l,c){if(s)throw Error("Rip Workspace: cannot write during a publication transition");l=B1(l),c=jr(c);let f=t.has(l)?"change":"create";t.set(l,c),r.delete(l),a(f,l);return},del(l){if(s)throw Error("Rip Workspace: cannot delete during a publication transition");l=B1(l),t.delete(l),r.delete(l),a("delete",l);return},exists(l){return t.has(B1(l))},size(){return t.size},list(l=""){let c;l=li(l);let f=l?l+"/":"",h=[];for(let[u]of t)if(u.startsWith(f)){if(c=u.slice(f.length),!c.includes("/"))h.push(u)}return h},listAll(l=""){l=li(l);let c=l?l+"/":"",f=[];for(let[h]of t)if(h.startsWith(c))f.push(h);return f},load(l){if(s)throw Error("Rip Workspace: cannot load during a publication transition");if(!(l!=null&&typeof l==="object"&&!Array.isArray(l)))throw TypeError("Rip Workspace: component load expects a source object");let c=[];for(let f in l){if(!Object.hasOwn(l,f))continue;let h=l[f];c.push([B1(f),jr(h)])}for(let[f,h]of c)t.set(f,h),r.delete(f);return},watch(l){if(typeof l!=="function")throw TypeError("Rip Workspace: component watch expects a function");i.add(l);let c=!1;return function(){if(c)return;c=!0,i.delete(l);return}},getCompiled(l){return r.get(B1(l))},setCompiled(l,c){if(s)throw Error("Rip Workspace: cannot compile during a publication transition");if(l=B1(l),!t.has(l))throw Error(`Rip Workspace: setCompiled for unknown component path '${l}'`);r.set(l,fi(c));return},hash(){return n},activate(l){if(n!=null)throw Error("Rip Workspace: a publication is already active");if(s)throw Error("Rip Workspace: a publication transition is already staged");o(oi(l));return},stage(l,c,f){if(s)throw Error("Rip Workspace: a publication transition is already staged");if(l=ci(l),n!==l)throw Error(`Rip Workspace: change starts at ${l}, not ${n}`);if(!Array.isArray(f))throw TypeError("Rip Workspace: changed paths must be an array");let h=f.map(function(p){return B1(p)});if(new Set(h).size!==h.length)throw Error("Rip Workspace: changed paths must be unique");let u=oi(c),d={sources:t,compiled:r,hash:n};s=!0;let S=!1,g=function(p){let R;if(S)throw Error("Rip Workspace: publication transition is already finished");if(S=!0,s=!1,!p)return;o(u);for(let b of h)R=!u.sources.has(b)?"delete":d.sources.has(b)?"change":"create",a(R,b);return};return{components:{getCompiled(p){return u.compiled.get(B1(p))},exists(p){return u.sources.has(B1(p))}},commit(){return g(!0)},rollback(){return g(!1)}}},commit(l,c,f){e.stage(l,c,f).commit();return}},e}var Po,Lo,Mo,jo,Fo,Bo,Uo,Br;Mo=250;Lo=8000;Po=5000;Uo=0;Br=function(e){return typeof e==="string"&&/^[A-Za-z0-9_]{6}$/.test(e)};Fo=function(){if(typeof location>"u")throw Error("Rip App: connectFeed needs a hub URL (no location to derive one from)");return`${location.protocol==="https:"?"wss":"ws"}://${location.host}/hub`};Bo=function(){if(typeof WebSocket>"u")throw Error("Rip App: connectFeed needs a socket factory (no global WebSocket)");return function(e){return new WebSocket(e)}};jo=function(){if(typeof fetch>"u")throw Error("Rip App: connectFeed needs a fetch (no global fetch)");return function(e,t){return fetch(e,t)}};function Ur(e,t={}){let r;if(!(e!=null&&typeof e.hash==="function"&&typeof e.apply==="function"&&typeof e.reload==="function"))throw TypeError("Rip App: connectFeed expects hash, apply, and reload callbacks");if(!Br(e.hash()))throw TypeError("Rip App: connectFeed client hash must be six Base64URL-folded characters");let i=t.hub??Fo(),n=t.latestUrl??"/latest.json",s=t.makeSocket??Bo(),a=t.fetch??jo(),o=t.report??function(...M){return console.error(...M)},l=t.backoff?.min??Mo,c=t.backoff?.max??Lo,f=t.ackTimeout??Po,h=!1,u=!1,d=!1,S=!1,g=null,p=0,R=null,b=null,_=0,y=null,m=[],k=Promise.resolve(),O=new Map,N=null,x=function(M){if(u||h)return;u=!0,e.reload(M);return},I=async function(M){let A;if(u||h)return!1;try{if(A=await e.apply(M),A==="rejected"){if(Br(M?.hash))N=M?.hash;return!1}if(A==="reload"||!A)return x("change could not be applied"),!1;return N=null,!0}catch(C){return o("[Rip] publication change failed:",C),x("change failed"),!1}},H=function(M,A){k=k.then(async function(){if(A!==_)return!0;return await I(M)}),k=k.catch(function(C){return o("[Rip] publication queue failed:",C),x("change queue failed"),!1});return},G=async function(M){let A,C;if(h||u||M!==_)return;let w=e.hash(),D=await a(n,{cache:"no-store"});if(!D?.ok)throw Error(`latest.json fetch failed (${D?.status})`);let B=await D.json();if(!(B!=null&&typeof B==="object"&&!Array.isArray(B)&&Object.keys(B).length===1&&Object.hasOwn(B,"hash")&&Br(B.hash)))throw Error("latest.json is malformed");if(h||u||M!==_)return;if(N!=null){if(B.hash!==N){x(`a newer App generation followed rejected ${N}`);return}m=[],S=!0,p=0;return}let a1=new Set([w]),h1=0;while(h10))return"ignore";let s=(()=>{let f=[];for(let h of i)if(typeof h==="string"&&h.endsWith(".css"))f.push(h);return f})(),a=(()=>{let f=[];for(let h of i)if(typeof h==="string"&&h.endsWith(".rip"))f.push(h);return f})(),o=(()=>{let f=[];for(let h of i)if(typeof h==="string"&&!h.endsWith(".rip")&&!h.endsWith(".css"))f.push(h);return f})();if(a.length===0){if(o.length>0)return"reload";if(s.length>0)return"css";return"ignore"}let l=await e.renderer.remountDirty(a,n);if(l==="narrow")return t(`[Rip] applied ${a.join(", ")} — update`),"update";if(l==="reload")return t(`[Rip] applied ${a.join(", ")} — reload`),"reload";if(l==="noop")return"ignore";if(await e.escape(a,n)==="reload")return"reload";return t(`[Rip] applied ${a.join(", ")} — update`),"update"}}}var bc=function(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError("Rip App: rash expects bytes")},yc=function(e){let t,r,i,n,s,a,o,l,c,f,h,u,d,S,g,p,R=bc(e);if(typeof Bun<"u"&&Bun.CryptoHasher!=null)return new Uint8Array(new Bun.CryptoHasher("sha256").update(R).digest());let b=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],_=R.length*8,y=new Uint8Array(R.length+9+63&-64);y.set(R),y[R.length]=128;let m=new DataView(y.buffer);m.setUint32(y.length-4,_>>>0,!1),m.setUint32(y.length-8,Math.floor(_/4294967296)>>>0,!1);let k=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],O=function(G,K){return G>>>K|G<<32-K},N=new Uint32Array(64),x=0;while(x>>3,S=O(N[G-2],17)^O(N[G-2],19)^N[G-2]>>>10,N[G]=N[G-16]+d+N[G-7]+S>>>0;[i,n,s,o,l,c,f,h]=k;for(let G=0;G<64;G++)r=O(l,6)^O(l,11)^O(l,25),a=l&c^~l&f,g=h+r+a+b[G]+N[G]>>>0,t=O(i,2)^O(i,13)^O(i,22),u=i&n^i&s^n&s,p=t+u>>>0,h=f,f=c,c=l,l=o+g>>>0,o=s,s=n,n=i,i=g+p>>>0;k[0]=k[0]+i>>>0,k[1]=k[1]+n>>>0,k[2]=k[2]+s>>>0,k[3]=k[3]+o>>>0,k[4]=k[4]+l>>>0,k[5]=k[5]+c>>>0,k[6]=k[6]+f>>>0,k[7]=k[7]+h>>>0,x+=64}let I=new Uint8Array(32),H=new DataView(I.buffer);for(let G=0;G<8;G++)H.setUint32(G*4,k[G],!1);return I},Dt=function(e){let t=yc(e),r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";return(r[t[0]>>2]+r[(t[0]&3)<<4|t[1]>>4]+r[(t[1]&15)<<2|t[2]>>6]+r[t[2]&63]+r[t[3]>>2]+r[(t[3]&3)<<4|t[4]>>4]).replaceAll("-","_")},Wr=function(e){let t=JSON.stringify(e.map(function(r){return[r.id,r.hash]}));return Dt(new TextEncoder().encode(t))};var Sc=function(){return globalThis.__ripStash},Rc=function(){return globalThis.__ripRouter};(()=>{if(typeof document>"u"||typeof WebSocket>"u")return;let e=document.currentScript;if(!(e?/\bwatch\.js\b/.test(e.src||""):!!document.querySelector("script[watch]"))||globalThis.__ripWatch)return;globalThis.__ripWatch=!0;let r=location.pathname,i=(f)=>Array.isArray(f)&&(f.includes(r)||r.endsWith("/")&&f.includes(r+"index.html")),n=(f)=>f.headers.get("etag")||f.headers.get("last-modified")||"",s=null;fetch(location.href,{method:"HEAD",cache:"no-store"}).then((f)=>{s=n(f)}).catch(()=>{});let a=()=>{if(s===null)return;fetch(location.href,{method:"HEAD",cache:"no-store"}).then((f)=>{if(n(f)!==s)location.reload()}).catch(()=>{})},o=!1,l=0,c=()=>{let f=location.protocol==="https:"?"wss://":"ws://",h=new WebSocket(f+location.host+"/hub");h.onopen=()=>h.send('{"+":["/assets"],"?":"observe"}'),h.onmessage=(u)=>{let d;try{d=JSON.parse(u.data)}catch{return}for(let S of Array.isArray(d)?d:[d]){if(!S||typeof S!=="object"||"<"in S)continue;if("!"in S){if(o)a();o=!0,l=0}if(i(S.touched))location.reload()}},h.onclose=()=>{if(l+=1,!o&&l>=6)return;setTimeout(c,Math.min(8000,500*2**(l-1)))},h.onerror=()=>{}};c()})();var{__hmrEmit:Ec}=Et;function ui(e,t={}){if(t.face==="ts")throw Error("rip: TypeScript face is unavailable in the browser");return fa(e,{...t,face:"js"})}var Yo={intrinsics:ir,stdlib:sr,schema:fr,reactive:gr,components:Et},zo=Object.freeze({...ir,...sr,...fr,...gr,...Et}),kc=Object.freeze({rash:Dt,check:Wr}),qo=Object.freeze({"rip/app":Hr,"rip/app/rash":kc});var Tc=new Map(Object.keys(Yo).map((e)=>[new URL(`./runtime/${e}.js`,import.meta.url).pathname,e])),wc=/(?:^|\/)src\/runtime\/(intrinsics|stdlib|schema|reactive|components)\.js$/,Gr="__ripModuleBridge",_c=(e)=>e.slice(1,-1),Vo=(e,t)=>{let r=e.split("/").slice(0,-1);for(let i of t.split("/")){if(i===""||i===".")continue;if(i===".."){if(!r.length)return null;r.pop()}else r.push(i)}return r.join("/")},Wo=(e)=>{if(typeof URL<"u"&&typeof URL.createObjectURL==="function"&&typeof Blob<"u")return URL.createObjectURL(new Blob([e],{type:"text/javascript"}));return`data:text/javascript;base64,${btoa(unescape(encodeURIComponent(e)))}`};function Xo({components:e,embeddedPackages:t={},debug:r=!1,hmr:i=!1}={}){if(!e||typeof e.read!=="function")throw TypeError("rip: createModuleLoader requires a component registry");let n=new Map,s=new Map,a=new Map,o=new Map,l=new Map,c=new Set,f=(g)=>{if(typeof g==="string"&&g.startsWith("blob:")&&typeof URL?.revokeObjectURL==="function")URL.revokeObjectURL(g)},h=async()=>{let g=[...c];c.clear(),await Promise.allSettled(g.map(async(p)=>f(await p)))},u=(g,p)=>{if(a.has(g))return a.get(g);globalThis[Gr]??={};let R=globalThis[Gr][g];if(R&&R!==p)throw Error(`rip: two copies of embedded module '${g}' are active on one page`);globalThis[Gr][g]=p;let b=[`const ns = globalThis['${Gr}'][${JSON.stringify(g)}];`];for(let y of Object.keys(p))if(y==="default")b.push("export default ns['default'];");else if(/^[A-Za-z_$][\w$]*$/.test(y))b.push(`export const ${y} = ns[${JSON.stringify(y)}];`);else throw Error(`rip: embedded module '${g}' exports '${y}', which cannot cross the module bridge`);let _=Wo(b.join(` `));return a.set(g,_),_},d=(g,p)=>{let R=_c(g),b=Tc.get(R)??R.match(wc)?.[1];if(b)return{bridge:`runtime:${b}`,namespace:Yo[b]};let _=(k)=>{try{return e.exists(k)}catch{return!1}},y=R.endsWith(".rip")?"":` — did you mean '${R}.rip'?`;if(R.startsWith("./")||R.startsWith("../")){let k=Vo(p,R);if(k&&_(k))return{path:k};if(!p.startsWith("rip/")){let O=Vo(`app/${p}`,R),N=O?.startsWith("app/")?O.slice(4):O;if(N&&_(N))return{path:N}}throw Error(`rip: '${p}' imports '${R}', which is not in the bundle${y}`)}let m=R.match(/^rip\/([\w-]+)(?:\/(.+))?$/);if(m){if(_(R))return{path:R};let k=`rip/${m[1]}`,O=t[R];if(O)return{bridge:`package:${R}`,namespace:O};if(t[k])throw Error(`rip: '${p}' imports '${R}', which '${k}' does not export in the browser`);let N=m[2]?m[2].endsWith(".rip")?m[2]:`${m[2]}.rip`:"index.rip",x=`${k}/${N}`;if(!_(x))throw Error(`rip: '${p}' imports '${R}', but '${x}' is not in the bundle — `+"only packages declaring browser safety travel to the browser");return{path:x}}throw Error(`rip: '${p}' imports '${R}', which is not loadable in a browser — `+"server-only and unknown modules never travel to the browser")},S=(g,p)=>{if(p.includes(g))throw Error(`rip: import cycle through '${g}' (${p.join(" -> ")} -> ${g})`);if(n.has(g))return n.get(g);let R=(async()=>{let b=e.read(g);if(b===void 0)throw Error(`rip: '${g}' is not in the bundle`);let _=ui(b,{path:g,runtimeDelivery:"import",browserModule:!0,...i?{hmr:!0}:null}),y=_.code;for(let m of[..._.imports].reverse()){let k=d(m.specifier,g);if(k.path){let N=o.get(k.path);if(!N)o.set(k.path,N=new Set);N.add(g);let x=l.get(g);if(!x)l.set(g,x=new Set);x.add(k.path)}let O=k.bridge?u(k.bridge,k.namespace):await S(k.path,[...p,g]);y=`${y.slice(0,m.start)}${JSON.stringify(O)}${y.slice(m.end)}`}if(r){let m=btoa(unescape(encodeURIComponent(JSON.stringify(_.map))));y+=` //# sourceMappingURL=data:application/json;charset=utf-8;base64,${m}`}return Wo(y)})();return n.set(g,R),R.catch(()=>n.delete(g)),R};return{async import(g){if(s.has(g))return s.get(g);let R=await import(await S(g,[]));return s.set(g,R),e.setCompiled(g,{...R}),R},invalidate(g){let p=[g],R=new Set;while(p.length){let b=p.pop();if(R.has(b))continue;if(R.add(b),n.has(b))c.add(n.get(b));n.delete(b),s.delete(b);for(let _ of o.get(b)??[])p.push(_);o.delete(b);for(let _ of l.get(b)??[]){let y=o.get(_);if(y?.delete(b),y?.size===0)o.delete(_)}l.delete(b)}return R},collect:h,dispose(){for(let g of n.values())c.add(g);n.clear(),s.clear(),o.clear(),l.clear();for(let g of a.values())f(g);a.clear(),h()}}}var Jo=Object.keys(zo),Nc=Jo.map((e)=>zo[e]),Ac=()=>{if(typeof document>"u"||typeof document.querySelectorAll!=="function")throw Error("rip: processRipScripts requires a browser or an injected host");return{scripts(){return Array.from(document.querySelectorAll('script[type="text/rip"]')).map((e)=>({src:e.getAttribute("src"),text:e.textContent??""}))},async fetchText(e){let t=await fetch(e);if(!t.ok)throw Error(`${t.status} ${t.statusText}`);return t.text()},prepare(e,t){return Function(...t,e)},async ready(){if(document.readyState==="loading")await new Promise((e)=>document.addEventListener("DOMContentLoaded",e,{once:!0}))},report(e){console.error("[Rip]",String(e))}}},vc=(e)=>{let t=e.split(` `),r=null;for(let i of t){if(!i.trim())continue;let n=i.match(/^[ \t]*/)[0];if(r===null){r=n;continue}let s=0;while(si.trim()?i.slice(r.length):i).join(` diff --git a/dist/@rip/rip.min.js.br b/dist/@rip/rip.min.js.br index 0904f5a0..0708202b 100644 Binary files a/dist/@rip/rip.min.js.br and b/dist/@rip/rip.min.js.br differ diff --git a/src/emitter.js b/src/emitter.js index 9a370c9a..12429b33 100644 --- a/src/emitter.js +++ b/src/emitter.js @@ -7343,6 +7343,14 @@ class Emitter { const ind = this.ind; this.rejectYieldInIIFE(node); this.b.emit(Emitter.containsAwait(node) ? 'await (async () => { ' : '(() => { '); + this.tryBranches(node, ind); + this.b.emit(' })()'); + } + + // The try with every branch returning its value: the body of the + // value form's IIFE, and the whole of a tail-position try, which + // returns from the enclosing function in place. + tryBranches(node, ind) { this.mark(node, '$self', () => { this.b.emit('try '); // An inline body (`x = try f()`) is its own one-statement @@ -7392,7 +7400,6 @@ class Emitter { } } }); - this.b.emit(' })()'); } valueSwitch(node) { @@ -16202,9 +16209,7 @@ class Emitter { return; } if (h === 'try') { - this.b.emit('return '); - this.withTailReturn(() => this.valueTry(stmt)); - this.b.emit(';'); + this.withTailReturn(() => this.tryBranches(stmt, ind)); return; } if (h === 'switch' && stmt.length === 4) { diff --git a/test/corpus/expected/lowerings.js b/test/corpus/expected/lowerings.js index 3d5649d5..baf74e82 100644 --- a/test/corpus/expected/lowerings.js +++ b/test/corpus/expected/lowerings.js @@ -78,11 +78,11 @@ let tailMulti = function(v) { } }; let tailTry = function() { - return (() => { try { + try { return risky(); } catch (e) { return 42; - } })(); + } }; let tailSwitch = function(v) { return (() => { switch (v) { diff --git a/test/corpus/expected/lowerings.map.json b/test/corpus/expected/lowerings.map.json index 971006b3..86a8c0fa 100644 --- a/test/corpus/expected/lowerings.map.json +++ b/test/corpus/expected/lowerings.map.json @@ -1 +1 @@ -{"version":3,"file":"lowerings.rip.js","sources":["lowerings.rip"],"sourcesContent":["# composition matrix rows for value-usage lowerings: statement\n# constructs in expression and tail positions — if→ternary (simple) and\n# IIFE (multi-statement), try/switch→IIFE with returns, loops→\n# accumulator IIFEs, postfix-if-ELSE ternaries with the assignment\n# hoist, statement-position comprehensions — instantiated so every row\n# evals.\nflag = true\nn = 7\n\nt1 = if flag then 1 else 2\nt2 = if flag then 1\nt3 = unless flag then 1 else 2\nt4 = if n > 5 then \"big\" else if n > 2 then \"mid\" else \"small\"\nt5 = (if flag then 1 else 2) + 3\nt6 = [if flag then 10 else 20, 30]\n\nseen = \"\"\nm1 = if flag\n seen += \"a\"\n n + 1\nelse\n 0\n\np1 = 5 if flag else 6\np2 = (n + 1) if n > 100 else (n - 1)\ndouble = (x) -> x * 2\np3 = double n if flag else 0\n\nrisky = -> throw \"bad\"\ntv = try\n risky()\ncatch e\n \"caught\"\n\nsw = switch n\n when 7 then \"seven\"\n else \"other\"\n\ni = 0\nacc = while i < 3\n i += 1\n i * 10\n\nevens = for v in [1, 2, 3, 4]\n v * 2\n\nlp = loop\n break\n\nsum = 0\ntally = (v) -> sum += v\ntally v for v in [1, 2, 3]\n\ntailIf = (v) ->\n if v > 0\n \"pos\"\n else\n \"neg\"\n\ntailMulti = (v) ->\n if v > 0\n w = v * 2\n w + 1\n else\n 0\n\ntailTry = ->\n try\n risky()\n catch e\n 42\n\ntailSwitch = (v) ->\n switch v\n when 7 then \"lucky\"\n else \"plain\"\n\ntailFor = (xs) ->\n for x in xs\n x + 100\n\nresults = [t1, t2, t3, t4, t5, m1, p1, p2, p3, tv, sw, acc, evens, sum, tailIf(n), tailMulti(2), tailTry(), tailSwitch(7), tailFor([1])]\n"],"names":["p1","p2","p3","flag","true","n","t1","t2","t3","t4","t5","t6","seen","m1","double","x","risky","tv","e","sw","i","acc","evens","v","lp","sum","tally","tailIf","tailMulti","w","tailTry","tailSwitch","tailFor","xs","results"],"mappings":"AAMA,IAiBAA,IACAC,IAEAC;;IApBAC,OAAOC;IACPC,IAAI;IAEJC,KAAQH,OAAU;IAClBI,KAAQJ,OAAU;IAClBK,KAAY,CAAAL,OAAU,IAAO;IAC7BM,KAAK,CAAGJ,EAAE,EAAE,KAAO,UAAcA,EAAE,EAAE,KAAO;IAC5CK,KAAK,CAAIP,OAAU,SAAY;IAC/BQ,KAAK,EAAIR,OAAU;IAEnBS,OAAO;IACPC,cAAK,IAAGV;EACNS,KAAK,GAAG;UACRP,IAAI;;;;AAIN,MAAUF,WAAU;AACpB,MAAgBE,EAAE,EAAE,OAAdA,IAAI,MAAoBA,IAAI;IAClCS,SAAS,SAACC,GAAM;UAAAA,EAAE,EAAE;;AACpB,MAAiBZ,OAAZW,YAAsB;IAE3BE,QAAQ,WAAG;EAAA,MAAM;;IACjBC,cAAK;SACHD,KAAK;SACDE;;;IAGNC,cAAK,QAAOd;;;;;;IAIZe,IAAI;IACJC;;EAAM,OAAMD,EAAE,EAAE;IACdA,EAAE,GAAG;iBACLA,EAAE,EAAE;;;;IAENE;;EAAQ,SAAIC,KAAK,CAAC;iBAChBA,EAAE,EAAE;;;;IAENC;;EAAK;;;;;IAGLC,MAAM;IACNC,QAAQ,SAACH,GAAM;UAAAE,IAAI,GAAGF;;AACtB,cAAiB,CAAC;EAAlBG;;IAEAC,SAAS,SAACJ,GACR;UAAA,CAAGA,EAAE,EAAE,KACL;;IAIJK,YAAY,SAACL,GACX;MACEM;EADF,KAAGN,EAAE,EAAE;IACLM,IAAIN,EAAE,EAAE;YACRM,IAAI;;;;;IAIRC,UAAU,WACR;kBAAA;WACEd,KAAK;WACDE;;;;IAGRa,aAAa,SAACR,GACZ;kBAAA,QAAOA;;;;;;;IAITS,UAAU,SAACC,IACT;;EAAA,SAAIlB,KAAKkB;kBACPlB,IAAI;;;;IAERmB,UAAU,CAAC,6DAA6DP,MAAM,KAAKC,SAAS,KAAKE,OAAO,IAAIC,UAAU,KAAKC,OAAO,CAAC,CAAC"} +{"version":3,"file":"lowerings.rip.js","sources":["lowerings.rip"],"sourcesContent":["# composition matrix rows for value-usage lowerings: statement\n# constructs in expression and tail positions — if→ternary (simple) and\n# IIFE (multi-statement), try/switch→IIFE with returns, loops→\n# accumulator IIFEs, postfix-if-ELSE ternaries with the assignment\n# hoist, statement-position comprehensions — instantiated so every row\n# evals.\nflag = true\nn = 7\n\nt1 = if flag then 1 else 2\nt2 = if flag then 1\nt3 = unless flag then 1 else 2\nt4 = if n > 5 then \"big\" else if n > 2 then \"mid\" else \"small\"\nt5 = (if flag then 1 else 2) + 3\nt6 = [if flag then 10 else 20, 30]\n\nseen = \"\"\nm1 = if flag\n seen += \"a\"\n n + 1\nelse\n 0\n\np1 = 5 if flag else 6\np2 = (n + 1) if n > 100 else (n - 1)\ndouble = (x) -> x * 2\np3 = double n if flag else 0\n\nrisky = -> throw \"bad\"\ntv = try\n risky()\ncatch e\n \"caught\"\n\nsw = switch n\n when 7 then \"seven\"\n else \"other\"\n\ni = 0\nacc = while i < 3\n i += 1\n i * 10\n\nevens = for v in [1, 2, 3, 4]\n v * 2\n\nlp = loop\n break\n\nsum = 0\ntally = (v) -> sum += v\ntally v for v in [1, 2, 3]\n\ntailIf = (v) ->\n if v > 0\n \"pos\"\n else\n \"neg\"\n\ntailMulti = (v) ->\n if v > 0\n w = v * 2\n w + 1\n else\n 0\n\ntailTry = ->\n try\n risky()\n catch e\n 42\n\ntailSwitch = (v) ->\n switch v\n when 7 then \"lucky\"\n else \"plain\"\n\ntailFor = (xs) ->\n for x in xs\n x + 100\n\nresults = [t1, t2, t3, t4, t5, m1, p1, p2, p3, tv, sw, acc, evens, sum, tailIf(n), tailMulti(2), tailTry(), tailSwitch(7), tailFor([1])]\n"],"names":["p1","p2","p3","flag","true","n","t1","t2","t3","t4","t5","t6","seen","m1","double","x","risky","tv","e","sw","i","acc","evens","v","lp","sum","tally","tailIf","tailMulti","w","tailTry","tailSwitch","tailFor","xs","results"],"mappings":"AAMA,IAiBAA,IACAC,IAEAC;;IApBAC,OAAOC;IACPC,IAAI;IAEJC,KAAQH,OAAU;IAClBI,KAAQJ,OAAU;IAClBK,KAAY,CAAAL,OAAU,IAAO;IAC7BM,KAAK,CAAGJ,EAAE,EAAE,KAAO,UAAcA,EAAE,EAAE,KAAO;IAC5CK,KAAK,CAAIP,OAAU,SAAY;IAC/BQ,KAAK,EAAIR,OAAU;IAEnBS,OAAO;IACPC,cAAK,IAAGV;EACNS,KAAK,GAAG;UACRP,IAAI;;;;AAIN,MAAUF,WAAU;AACpB,MAAgBE,EAAE,EAAE,OAAdA,IAAI,MAAoBA,IAAI;IAClCS,SAAS,SAACC,GAAM;UAAAA,EAAE,EAAE;;AACpB,MAAiBZ,OAAZW,YAAsB;IAE3BE,QAAQ,WAAG;EAAA,MAAM;;IACjBC,cAAK;SACHD,KAAK;SACDE;;;IAGNC,cAAK,QAAOd;;;;;;IAIZe,IAAI;IACJC;;EAAM,OAAMD,EAAE,EAAE;IACdA,EAAE,GAAG;iBACLA,EAAE,EAAE;;;;IAENE;;EAAQ,SAAIC,KAAK,CAAC;iBAChBA,EAAE,EAAE;;;;IAENC;;EAAK;;;;;IAGLC,MAAM;IACNC,QAAQ,SAACH,GAAM;UAAAE,IAAI,GAAGF;;AACtB,cAAiB,CAAC;EAAlBG;;IAEAC,SAAS,SAACJ,GACR;UAAA,CAAGA,EAAE,EAAE,KACL;;IAIJK,YAAY,SAACL,GACX;MACEM;EADF,KAAGN,EAAE,EAAE;IACLM,IAAIN,EAAE,EAAE;YACRM,IAAI;;;;;IAIRC,UAAU,WACR;EAAA;WACEd,KAAK;WACDE;;;;IAGRa,aAAa,SAACR,GACZ;kBAAA,QAAOA;;;;;;;IAITS,UAAU,SAACC,IACT;;EAAA,SAAIlB,KAAKkB;kBACPlB,IAAI;;;;IAERmB,UAAU,CAAC,6DAA6DP,MAAM,KAAKC,SAAS,KAAKE,OAAO,IAAIC,UAAU,KAAKC,OAAO,CAAC,CAAC"} diff --git a/test/rip/errors.rip b/test/rip/errors.rip index e77ea6d7..d9e397d9 100644 --- a/test/rip/errors.rip +++ b/test/rip/errors.rip @@ -309,3 +309,134 @@ test 'value-position throw preserves await', ''' msg = e.message msg ''', 'boom' + +# ============================================================================== +# Tail-position try: a statement whose branches return, never a wrapper +# ============================================================================== + +test "tail try returns the body value", ''' + f = (x) -> + try + x * 2 + catch e + null + f(21) + ''', 42 + +test "tail try returns the handler value on throw", ''' + f = -> + try + throw 'boom' + catch e + "caught #{e}" + f() + ''', "caught boom" + +test "tail try without a handler returns undefined on throw", ''' + f = -> + try + throw 'boom' + f() is undefined + ''', true + +test "tail try runs finally after returning", ''' + log = [] + f = -> + try + log.push 'body' + 1 + finally + log.push 'finally' + [f(), log] + ''', [1, ['body', 'finally']] + +test "tail try with an explicit return inside", ''' + f = (x) -> + try + return x + 1 if x > 0 + 0 + catch e + -1 + [f(5), f(-5)] + ''', [6, 0] + +test "tail try with a catch pattern", ''' + f = -> + try + throw { message: 'bad', code: 7 } + catch { message, code } + "#{message}:#{code}" + f() + ''', "bad:7" + +test "tail try after other statements", ''' + f = (xs) -> + total = 0 + total += x for x in xs + try + total / xs.length + catch e + 0 + f([2, 4]) + ''', 3 + +test "tail try inside a generator may yield", ''' + g = -> + try + yield 1 + yield 2 + catch e + yield -1 + [...g()] + ''', [1, 2] + +test "tail try with await", ''' + f = (p) -> + try + await p + catch e + 'failed' + [await f(Promise.resolve(1)), await f(Promise.reject('x'))] + ''', [1, 'failed'] + +code "tail try compiles to a returning statement", ''' + f = (x) -> + try + parse x + catch e + null + ''', ''' + let f = function(x) { + try { + return parse(x); + } catch (e) { + return null; + } + }; + ''' + +code "tail try with await stays inside the function", ''' + f = (x) -> + try + await parse x + catch e + null + ''', ''' + let f = async function(x) { + try { + return await parse(x); + } catch (e) { + return null; + } + }; + ''' + +code "value-position try keeps its wrapper", ''' + x = try parse(s) catch e then null + ''', ''' + let x = (() => { try { + return parse(s); + } catch (e) { + return null; + } })(); + ''' diff --git a/test/rip/sweep.rip b/test/rip/sweep.rip index 01433244..85108ebd 100644 --- a/test/rip/sweep.rip +++ b/test/rip/sweep.rip @@ -1098,9 +1098,9 @@ code "inline try on a statement", ''' f = -> try return 1 ''', ''' let f = function() { - return (() => { try { + try { return 1; - } catch {} })(); + } catch {} }; ''' @@ -1113,13 +1113,13 @@ code "inline try statement with catch and finally", ''' cleanup() ''', ''' let f = function() { - return (() => { try { + try { return 1; } catch { return 2; } finally { cleanup(); - } })(); + } }; '''