@lunora/studio 1.0.0-alpha.117 → 1.0.0-alpha.119
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/mount.js +1 -1
- package/dist/packem_chunks/AdvisorHealthPanel.js +1 -1
- package/dist/packem_chunks/ApiTab.js +1 -1
- package/dist/packem_chunks/AuditPanel.js +1 -1
- package/dist/packem_chunks/ExportImportPanel.js +1 -1
- package/dist/packem_chunks/FileBrowser.js +1 -1
- package/dist/packem_chunks/FunctionRunner.js +1 -1
- package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
- package/dist/packem_chunks/HealthPanel.js +1 -1
- package/dist/packem_chunks/InsightsPanel.js +1 -1
- package/dist/packem_chunks/LogsPanel.js +1 -1
- package/dist/packem_chunks/MailPanel.js +1 -1
- package/dist/packem_chunks/MetricsPanel.js +1 -1
- package/dist/packem_chunks/NotificationsPanel.js +1 -1
- package/dist/packem_chunks/PitrPanel.js +1 -1
- package/dist/packem_chunks/SchemaViewer.js +1 -1
- package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
- package/dist/packem_chunks/SettingsPanel.js +1 -1
- package/dist/packem_chunks/SqlEditorPanel.js +1 -1
- package/dist/packem_chunks/TableEditor.js +1 -1
- package/dist/packem_chunks/agents-panel.js +1 -1
- package/dist/packem_chunks/auth-audit-panel.js +1 -1
- package/dist/packem_chunks/containers-panel.js +1 -1
- package/dist/packem_chunks/dashboards-panel.js +1 -1
- package/dist/packem_chunks/evals-panel.js +1 -1
- package/dist/packem_chunks/fanout-panel.js +1 -1
- package/dist/packem_chunks/flags-panel.js +1 -1
- package/dist/packem_chunks/issues-panel.js +1 -1
- package/dist/packem_chunks/kv-browser.js +1 -1
- package/dist/packem_chunks/migrations-route.js +1 -1
- package/dist/packem_chunks/payments-panel.js +1 -1
- package/dist/packem_chunks/permissions-panel.js +1 -1
- package/dist/packem_chunks/queues-panel.js +1 -1
- package/dist/packem_chunks/reactors-panel.js +1 -0
- package/dist/packem_chunks/rls-panel.js +1 -1
- package/dist/packem_chunks/storage-rules-panel.js +1 -1
- package/dist/packem_chunks/subscriptions-panel.js +1 -1
- package/dist/packem_chunks/traces-panel.js +1 -1
- package/dist/packem_chunks/workflows-panel.js +1 -1
- package/dist/packem_shared/ADMIN_FUNCTIONS-B6z7VLYt.js +1 -0
- package/dist/packem_shared/{ApiDocsPanel-C_dZt4ve.js → ApiDocsPanel-BMzLPgvv.js} +1 -1
- package/dist/packem_shared/{DataBrowser-BPCr2f8V.js → DataBrowser-C68K5QHO.js} +1 -1
- package/dist/packem_shared/{HomePanel-B8U_LJkK.js → HomePanel-B-tcMcTZ.js} +1 -1
- package/dist/packem_shared/{MigrationsPanel-CF73xHke.js → MigrationsPanel-CLRWwPyL.js} +1 -1
- package/dist/packem_shared/{Studio-RFVDC2sC.js → Studio-BYdUxnM5.js} +1 -1
- package/dist/packem_shared/{StudioApp-jTW-QnDo.js → StudioApp-Bxmtp-Fi.js} +1 -1
- package/dist/packem_shared/{home-panel-DywiFhDs.js → home-panel-ecz6-nHV.js} +1 -1
- package/dist/packem_shared/studio-Cvdwfzxm.js +2 -0
- package/dist/packem_shared/{use-sql-assistant-DFO2i-n-.js → use-sql-assistant-CXgVX_PP.js} +1 -1
- package/dist/standalone/{chunk-H2WBIULE.js → chunk-27IF4PXG.js} +1 -1
- package/dist/standalone/{chunk-K5XFXW6D.js → chunk-2F6FYL5O.js} +1 -1
- package/dist/standalone/{chunk-KEMHRM53.js → chunk-2RASQG3R.js} +1 -1
- package/dist/standalone/{chunk-SCXAZ74Y.js → chunk-2VLBFSIX.js} +1 -1
- package/dist/standalone/{chunk-I4XA3BBM.js → chunk-4DJQV5UA.js} +1 -1
- package/dist/standalone/{chunk-2WAWYLUP.js → chunk-4LVLLM6B.js} +1 -1
- package/dist/standalone/{chunk-FEW2WNS7.js → chunk-4PVSXT34.js} +1 -1
- package/dist/standalone/{chunk-BBXNPD22.js → chunk-4Y2QHI65.js} +1 -1
- package/dist/standalone/{chunk-ZNNKKJRT.js → chunk-5COHJLQF.js} +1 -1
- package/dist/standalone/{chunk-W5CYX66B.js → chunk-5HICO276.js} +1 -1
- package/dist/standalone/{chunk-FKNT7GEB.js → chunk-5JF2HAU4.js} +1 -1
- package/dist/standalone/chunk-5QAT5NQ4.js +1 -0
- package/dist/standalone/{chunk-CZK4GZ5C.js → chunk-6J5TEYI5.js} +1 -1
- package/dist/standalone/{chunk-F5YULDNX.js → chunk-6KJLNWPJ.js} +1 -1
- package/dist/standalone/{chunk-2P6N5XES.js → chunk-6QKKYBML.js} +1 -1
- package/dist/standalone/{chunk-P2GOC5GL.js → chunk-7CVIN6KU.js} +1 -1
- package/dist/standalone/{chunk-ZIYO55T2.js → chunk-A44VDLY3.js} +1 -1
- package/dist/standalone/{chunk-A7WKYEQ4.js → chunk-ATGYWQUI.js} +1 -1
- package/dist/standalone/{chunk-H4SLAZAN.js → chunk-B3BKR5ZW.js} +1 -1
- package/dist/standalone/{chunk-RUIWLLAI.js → chunk-BKW7FMAU.js} +1 -1
- package/dist/standalone/{chunk-JACBQWRB.js → chunk-BYJZGWWY.js} +1 -1
- package/dist/standalone/{chunk-S6UHG354.js → chunk-CFQQSG6L.js} +1 -1
- package/dist/standalone/{chunk-SM764GPA.js → chunk-D3ZLKFO4.js} +1 -1
- package/dist/standalone/{chunk-LFEDP3Y6.js → chunk-D52S7TOI.js} +1 -1
- package/dist/standalone/{chunk-SLOB2B2T.js → chunk-DYKGLIBC.js} +1 -1
- package/dist/standalone/chunk-DZGOHOOE.js +1 -0
- package/dist/standalone/{chunk-O2VDNK4B.js → chunk-FJ6G6FNE.js} +1 -1
- package/dist/standalone/{chunk-RND4232Z.js → chunk-G3NGXYJY.js} +1 -1
- package/dist/standalone/{chunk-PLI4LCPS.js → chunk-GTEXP4P3.js} +1 -1
- package/dist/standalone/{chunk-6UOC4ZJL.js → chunk-J2GQE4PW.js} +1 -1
- package/dist/standalone/{chunk-KQ6HYQCE.js → chunk-JIPVSPSG.js} +1 -1
- package/dist/standalone/{chunk-TNVZJKGN.js → chunk-KPQROFH5.js} +1 -1
- package/dist/standalone/{chunk-TNFIYZPY.js → chunk-KWGHNORP.js} +1 -1
- package/dist/standalone/{chunk-2UWKGSEA.js → chunk-L6ATKZKO.js} +1 -1
- package/dist/standalone/{chunk-DC5AAWSA.js → chunk-P4QIDUCY.js} +1 -1
- package/dist/standalone/{chunk-CYLI7GO3.js → chunk-P54YTPHL.js} +1 -1
- package/dist/standalone/{chunk-6MRGARL5.js → chunk-PRWFHSHC.js} +1 -1
- package/dist/standalone/{chunk-LMAI2ESY.js → chunk-PS66CRK5.js} +1 -1
- package/dist/standalone/{chunk-3IXTF53Q.js → chunk-QDGAB4R2.js} +1 -1
- package/dist/standalone/{chunk-DEGERMXH.js → chunk-QKN5EHEF.js} +1 -1
- package/dist/standalone/{chunk-CE7WVPLK.js → chunk-QLG2EJU3.js} +1 -1
- package/dist/standalone/{chunk-MDWJRPZG.js → chunk-QXLU6YPU.js} +1 -1
- package/dist/standalone/{chunk-BE76GAFE.js → chunk-R3G55P4J.js} +1 -1
- package/dist/standalone/chunk-R4HRS232.js +1 -0
- package/dist/standalone/{chunk-22664OOM.js → chunk-R52YOHVU.js} +1 -1
- package/dist/standalone/{chunk-R3VDUL6F.js → chunk-RK5XWYUL.js} +1 -1
- package/dist/standalone/{chunk-7W6TQTW7.js → chunk-RSG2DVHH.js} +1 -1
- package/dist/standalone/{chunk-WSNFV7ZW.js → chunk-T5SC5RAD.js} +1 -1
- package/dist/standalone/{chunk-EEIKRCWD.js → chunk-TCKQ4E5Y.js} +1 -1
- package/dist/standalone/{chunk-TYOIBCR6.js → chunk-UBT2FIU5.js} +1 -1
- package/dist/standalone/{chunk-VKQZAEUQ.js → chunk-VDSFYFDH.js} +1 -1
- package/dist/standalone/{chunk-V2KCESII.js → chunk-W3PCX3TU.js} +1 -1
- package/dist/standalone/{chunk-J7GGD2O2.js → chunk-WFABZPAK.js} +1 -1
- package/dist/standalone/{chunk-VVB7SOO7.js → chunk-WIFYD4A6.js} +1 -1
- package/dist/standalone/{chunk-CU7KGPAQ.js → chunk-WYSR5F77.js} +1 -1
- package/dist/standalone/{chunk-FRSTZO5P.js → chunk-XFU6YBYL.js} +1 -1
- package/dist/standalone/{chunk-N7WIVIP2.js → chunk-XRC7KEEN.js} +1 -1
- package/dist/standalone/{chunk-IZ6AVENL.js → chunk-XTNSQYXW.js} +1 -1
- package/dist/standalone/chunk-XUX7B54Z.js +1 -0
- package/dist/standalone/{chunk-VTPKVALV.js → chunk-YN2KHW3B.js} +1 -1
- package/dist/standalone/chunk-YTYRZTG6.js +11 -0
- package/dist/standalone/studio.js +1 -1
- package/package.json +5 -5
- package/dist/packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js +0 -1
- package/dist/packem_shared/studio-BdV57x3O.js +0 -2
- package/dist/standalone/chunk-22WJHOC4.js +0 -11
- package/dist/standalone/chunk-OQS4HFKC.js +0 -1
- package/dist/standalone/chunk-TOZK5WX3.js +0 -1
- package/dist/standalone/chunk-VDW32UET.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import{c as k}from"react/compiler-runtime";import{createRootRoute as Xt,createRoute as St,createBrowserHistory as es,createMemoryHistory as ts,createRouter as ss,useNavigate as At,useSearch as as,RouterProvider as os,useRouterState as ns,Outlet as rs}from"@tanstack/react-router";import*as nt from"react";import{use as Nt,createContext as Et,useState as it,useEffect as rt,useSyncExternalStore as ls,lazy as A,Suspense as is}from"react";import{c as L}from"./utils-bhneXptQ.js";import{jsx as o,jsxs as w,Fragment as Rt}from"react/jsx-runtime";import{ErrorBoundary as ds}from"./ErrorBoundary-BWNF98VF.js";import{O as cs,u as us}from"./operation-console-provider-DoloEvon.js";import{useT as ee}from"./DEFAULT_LOCALE-A1Yg5ORA.js";import{LunoraError as It}from"@lunora/errors";import{B as dt}from"./badge-cAk9Di1Q.js";import{I as $t}from"./input-CY5W3wzv.js";import{Popover as lt}from"@base-ui/react/popover";import{Cancel01Icon as ms,SidebarLeftIcon as fs}from"@hugeicons/core-free-icons";import{HugeiconsIcon as Ht}from"@hugeicons/react";import{mergeProps as Bt}from"@base-ui/react/merge-props";import{useRender as zt}from"@base-ui/react/use-render";import{cva as hs}from"class-variance-authority";import{B as Vt}from"./button-BOPLD1un.js";import{Dialog as ae}from"@base-ui/react/dialog";import{Tooltip as se}from"@base-ui/react/tooltip";import{S as vt}from"./skeleton-DFBBaJU6.js";import{H as ps,u as gs}from"./home-panel-DywiFhDs.js";import{g as bs,f as wt}from"./internal-7bgd8inO.js";import{o as ft}from"./use-admin-query-DV9xmFl8.js";import{StudioI18nProvider as vs}from"./StudioI18nProvider-Bl547evf.js";import{v as xs,a as ys}from"./data-view-params-qoSTqjAj.js";import{CommandPalette as ws,openCommandPalette as ks}from"./CommandPalette-kQLn0xlS.js";import{motion as Ns}from"motion/react";import{u as Ms}from"./shortcuts-lH4Vaqjc.js";const Ot="(prefers-color-scheme: dark)",Dt=()=>{try{return globalThis.localStorage}catch{return}},Ss=t=>t==="system"||t==="light"||t==="dark",Zt=()=>globalThis.matchMedia,Ft="lunora-studio-theme",xt=["system","light","dark"],Cs=(t="system")=>{try{const e=Dt()?.getItem(Ft);return Ss(e)?e:t}catch{return t}},Ct=t=>{const e=Dt();if(e!==void 0)try{e.setItem(Ft,t)}catch{}},Ps=()=>{try{return Zt()?.(Ot).matches?"dark":"light"}catch{return"light"}},_s=(t,e)=>t==="system"?e:t,Ts=t=>{let e;try{e=Zt()?.(Ot)}catch{e=void 0}if(e===void 0)return()=>{};const s=a=>{t(a.matches?"dark":"light")};return e.addEventListener("change",s),()=>{e.removeEventListener("change",s)}},Mt=Et(null),Ls=({children:t,defaultTheme:e="system"})=>{const[s,a]=it(()=>Cs(e)),[n,r]=it(()=>Ps());rt(()=>Ts(r),[]);const l=u=>{Ct(u),a(u)},d={cycleTheme:()=>{a(u=>{const c=xt[(xt.indexOf(u)+1)%xt.length]??u;return Ct(c),c})},resolvedTheme:_s(s,n),setTheme:l,systemTheme:n,theme:s};return o(Mt,{value:d,children:t})},As=t=>{const e=k(3),{children:s}=t,a=Nt(Mt);let n;return e[0]!==s||e[1]!==a?(n=a===null?o(Ls,{children:s}):s,e[0]=s,e[1]=a,e[2]=n):n=e[2],n},Es=()=>{const t=Nt(Mt);if(t===null)throw new It("INTERNAL","useTheme must be used within a <ThemeProvider>");return t};function pn({delay:t=0,...e}){return o(se.Provider,{"data-slot":"tooltip-provider",delay:t,...e})}function Rs(t){const e=k(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let a;return e[2]!==s?(a=o(se.Root,{"data-slot":"tooltip",...s}),e[2]=s,e[3]=a):a=e[3],a}function Is(t){const e=k(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let a;return e[2]!==s?(a=o(se.Trigger,{"data-slot":"tooltip-trigger",...s}),e[2]=s,e[3]=a):a=e[3],a}function $s({className:t,side:e="top",sideOffset:s=4,align:a="center",alignOffset:n=0,children:r,...l}){return o(se.Portal,{children:o(se.Positioner,{align:a,alignOffset:n,side:e,sideOffset:s,className:"isolate z-50",children:w(se.Popup,{"data-slot":"tooltip-content",className:L("z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pe-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-md data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",t),...l,children:[r,o(se.Arrow,{className:"z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-md bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-start-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-end-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5"})]})})})}const Hs=t=>{const e=k(5),{className:s}=t;let a;e[0]!==s?(a=L("h-full w-full text-foreground",s),e[0]=s,e[1]=a):a=e[1];let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=o("path",{d:"M 259.500 10.552 C 220.080 15.859, 182.424 32.566, 152.500 58.025 C 110.179 94.031, 85.380 137.183, 77.518 188.500 C 75.410 202.255, 74.569 225.677, 75.796 236.466 C 76.757 244.917, 76.683 245.692, 74.518 249.966 C 63.118 272.466, 53.141 303.876, 51.382 322.799 L 50.718 329.943 71.960 320.471 C 83.643 315.262, 93.326 311, 93.478 311 C 93.630 311, 96.547 316.063, 99.959 322.250 C 103.371 328.438, 107.249 334.850, 108.577 336.500 L 110.990 339.500 110.981 336 C 110.977 334.075, 111.499 324.991, 112.143 315.813 L 113.312 299.127 121.406 293.336 C 132.495 285.403, 149.593 271.554, 161 261.268 C 171.556 251.748, 189.116 235, 188.540 235 C 188.337 235, 183.069 238.648, 176.835 243.106 C 142.318 267.789, 68.537 314, 63.646 314 C 61.843 314, 72.791 281.179, 80.905 262.259 C 92.233 235.845, 107.473 212.389, 132.106 183.453 L 138.451 176 148.268 176 C 176.192 176, 197.512 187.154, 212.868 209.797 C 216.470 215.108, 217.035 216.595, 216.477 219.297 C 211.386 243.968, 202.359 274.496, 193.797 296 C 183.898 320.861, 167.147 352.101, 152.395 373.215 L 147.004 380.930 152.891 385.830 C 161.400 392.911, 165.563 396, 166.594 395.998 C 167.092 395.998, 168.772 391.641, 170.327 386.317 C 176.279 365.934, 188.422 338.749, 200.942 317.778 C 223.060 280.731, 256.432 244.369, 294.500 215.836 C 309.956 204.252, 313.937 201.603, 314.719 202.385 C 315.116 202.783, 315.449 213.096, 315.460 225.304 C 315.474 241.855, 315.021 250.405, 313.680 258.924 C 307.009 301.272, 291.175 336.677, 263.112 372 C 255.259 381.883, 227.182 410.673, 218.516 417.727 L 213.532 421.783 223.439 424.880 C 281.705 443.093, 349.165 436.018, 398.616 406.508 C 446.728 377.797, 483.322 331.466, 497.366 281.481 C 503.381 260.075, 504.480 250.741, 504.491 221 C 504.501 191.997, 503.598 184.047, 497.987 163.732 C 484.768 115.871, 452.505 72.708, 407.718 42.964 C 381.051 25.254, 352.818 14.828, 319.695 10.460 C 305.932 8.645, 273.298 8.695, 259.500 10.552",fillRule:"evenodd"}),e[2]=n):n=e[2];let r;return e[3]!==a?(r=o("svg",{"aria-hidden":"true",className:a,fill:"currentColor",viewBox:"0 0 543 446",children:n}),e[3]=a,e[4]=r):r=e[4],r},qt="lunora.studio.rulesBannerDismissed",Bs=()=>{try{return globalThis.localStorage.getItem(qt)==="1"}catch{return!1}},zs=()=>{try{globalThis.localStorage.setItem(qt,"1")}catch{}},Vs=()=>{const t=k(18),e=ee(),[s,a]=it(Os);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=()=>{a(!0),zs()},t[0]=n):n=t[0];const r=n;if(s)return null;let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l=o("span",{"aria-hidden":"true",className:"text-warning",children:"⚠"}),t[1]=l):l=t[1];let i;t[2]!==e?(i=e("Lunora AI rules aren't installed."),t[2]=e,t[3]=i):i=t[3];let d;t[4]===Symbol.for("react.memo_cache_sentinel")?(d=o("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px]",children:"lunora rules install"}),t[4]=d):d=t[4];let u;t[5]!==e?(u=e("lets your coding agent use Lunora correctly."),t[5]=e,t[6]=u):u=t[6];let c;t[7]!==i||t[8]!==u?(c=w("span",{children:[i," ",d," ",u]}),t[7]=i,t[8]=u,t[9]=c):c=t[9];let f;t[10]!==e?(f=e("Dismiss"),t[10]=e,t[11]=f):f=t[11];let p;t[12]===Symbol.for("react.memo_cache_sentinel")?(p=o("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:o("path",{d:"M18 6 6 18M6 6l12 12"})}),t[12]=p):p=t[12];let m;t[13]!==f?(m=o("button",{"aria-label":f,className:"ms-auto flex size-5 items-center justify-center rounded text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent","data-testid":"dash-app-rules-banner-dismiss",onClick:r,type:"button",children:p}),t[13]=f,t[14]=m):m=t[14];let h;return t[15]!==c||t[16]!==m?(h=w("div",{className:"flex shrink-0 items-center gap-2 border-b border-warning/30 bg-warning/10 px-6 py-2 text-[12px] text-foreground","data-testid":"dash-app-rules-banner",role:"note",children:[l,c,m]}),t[15]=c,t[16]=m,t[17]=h):h=t[17],h};function Os(){return Bs()}function Wt(t){const e=k(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let a;return e[2]!==s?(a=o(lt.Root,{"data-slot":"popover",...s}),e[2]=s,e[3]=a):a=e[3],a}function jt(t){const e=k(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let a;return e[2]!==s?(a=o(lt.Trigger,{"data-slot":"popover-trigger",...s}),e[2]=s,e[3]=a):a=e[3],a}function Ut({align:t="end",alignOffset:e=0,className:s,keepMounted:a=!1,side:n="bottom",sideOffset:r=6,...l}){return o(lt.Portal,{keepMounted:a,children:o(lt.Positioner,{align:t,alignOffset:e,className:"isolate z-50 outline-none",side:n,sideOffset:r,children:o(lt.Popup,{className:L("z-50 w-72 origin-(--transform-origin) rounded-lg border border-border bg-popover p-3 text-popover-foreground shadow-md outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",s),"data-slot":"popover-content",...l})})})}const yt=768;function Ds(){const t=k(2),[e,s]=it(void 0);let a,n;return t[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const r=globalThis.matchMedia(`(max-width: ${yt-1}px)`),l=()=>{s(globalThis.innerWidth<yt)};return r.addEventListener("change",l),s(globalThis.innerWidth<yt),()=>{r.removeEventListener("change",l)}},n=[],t[0]=a,t[1]=n):(a=t[0],n=t[1]),rt(a,n),!!e}function Zs(t){const e=k(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let a;return e[2]!==s?(a=o(ae.Root,{"data-slot":"sheet",...s}),e[2]=s,e[3]=a):a=e[3],a}function Fs(t){const e=k(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let a;return e[2]!==s?(a=o(ae.Portal,{"data-slot":"sheet-portal",...s}),e[2]=s,e[3]=a):a=e[3],a}function qs(t){const e=k(8);let s,a;e[0]!==t?({className:s,...a}=t,e[0]=t,e[1]=s,e[2]=a):(s=e[1],a=e[2]);let n;e[3]!==s?(n=L("fixed inset-0 z-50 bg-black/10 text-xs/relaxed transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:",s),e[3]=s,e[4]=n):n=e[4];let r;return e[5]!==a||e[6]!==n?(r=o(ae.Backdrop,{"data-slot":"sheet-overlay",className:n,...a}),e[5]=a,e[6]=n,e[7]=r):r=e[7],r}function Ws({className:t,children:e,side:s="right",showCloseButton:a=!0,...n}){return w(Fs,{children:[o(qs,{}),w(ae.Popup,{"data-slot":"sheet-content","data-side":s,className:L("fixed z-50 flex flex-col bg-popover bg-clip-padding text-xs/relaxed text-popover-foreground shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-e data-[side=left]:data-ending-style:translate-x-[-2.5rem] rtl:data-[side=left]:data-ending-style:-translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] rtl:data-[side=left]:data-starting-style:-translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-s data-[side=right]:data-ending-style:translate-x-[2.5rem] rtl:data-[side=right]:data-ending-style:-translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] rtl:data-[side=right]:data-starting-style:-translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm",t),...n,children:[e,a&&w(ae.Close,{"data-slot":"sheet-close",render:o(Vt,{variant:"ghost",className:"absolute top-3 end-3",size:"icon-sm"}),children:[o(Ht,{icon:ms,strokeWidth:2}),o("span",{className:"sr-only",children:"Close"})]})]})]})}function js(t){const e=k(8);let s,a;e[0]!==t?({className:s,...a}=t,e[0]=t,e[1]=s,e[2]=a):(s=e[1],a=e[2]);let n;e[3]!==s?(n=L("flex flex-col gap-0.5 p-4",s),e[3]=s,e[4]=n):n=e[4];let r;return e[5]!==a||e[6]!==n?(r=o("div",{"data-slot":"sheet-header",className:n,...a}),e[5]=a,e[6]=n,e[7]=r):r=e[7],r}function Us(t){const e=k(8);let s,a;e[0]!==t?({className:s,...a}=t,e[0]=t,e[1]=s,e[2]=a):(s=e[1],a=e[2]);let n;e[3]!==s?(n=L("text-sm font-medium text-foreground",s),e[3]=s,e[4]=n):n=e[4];let r;return e[5]!==a||e[6]!==n?(r=o(ae.Title,{"data-slot":"sheet-title",className:n,...a}),e[5]=a,e[6]=n,e[7]=r):r=e[7],r}function Ks(t){const e=k(8);let s,a;e[0]!==t?({className:s,...a}=t,e[0]=t,e[1]=s,e[2]=a):(s=e[1],a=e[2]);let n;e[3]!==s?(n=L("text-xs/relaxed text-muted-foreground",s),e[3]=s,e[4]=n):n=e[4];let r;return e[5]!==a||e[6]!==n?(r=o(ae.Description,{"data-slot":"sheet-description",className:n,...a}),e[5]=a,e[6]=n,e[7]=r):r=e[7],r}const Gs="sidebar_state",Qs=3600*24*7,Ys="16rem",Js="18rem",Xs="3rem",ea="b",Kt=nt.createContext(null);function ht(){const t=nt.useContext(Kt);if(!t)throw new It("INTERNAL","useSidebar must be used within a SidebarProvider.");return t}function ta({defaultOpen:t=!0,open:e,onOpenChange:s,className:a,style:n,children:r,...l}){const i=Ds(),[d,u]=nt.useState(!1),[c,f]=nt.useState(t),p=e??c,m=x=>{const y=typeof x=="function"?x(p):x;s?s(y):f(y),document.cookie=`${Gs}=${y}; path=/; max-age=${Qs}`},h=()=>i?u(x=>!x):m(x=>!x),b=nt.useEffectEvent(()=>{h()});nt.useEffect(()=>{const x=y=>{y.key===ea&&(y.metaKey||y.ctrlKey)&&(y.preventDefault(),b())};return globalThis.addEventListener("keydown",x),()=>globalThis.removeEventListener("keydown",x)},[]);const g={state:p?"expanded":"collapsed",open:p,setOpen:m,isMobile:i,openMobile:d,setOpenMobile:u,toggleSidebar:h};return o(Kt.Provider,{value:g,children:o("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":Ys,"--sidebar-width-icon":Xs,...n},className:L("group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",a),...l,children:r})})}function sa({side:t="left",variant:e="sidebar",collapsible:s="offcanvas",className:a,children:n,dir:r,...l}){const{isMobile:i,state:d,openMobile:u,setOpenMobile:c}=ht();return s==="none"?o("div",{"data-slot":"sidebar",className:L("flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",a),...l,children:n}):i?o(Zs,{open:u,onOpenChange:c,...l,children:w(Ws,{dir:r,"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":Js},side:t,children:[w(js,{className:"sr-only",children:[o(Us,{children:"Sidebar"}),o(Ks,{children:"Displays the mobile sidebar."})]}),o("div",{className:"flex h-full w-full flex-col",children:n})]})}):w("div",{className:"group peer hidden text-sidebar-foreground md:block","data-state":d,"data-collapsible":d==="collapsed"?s:"","data-variant":e,"data-side":t,"data-slot":"sidebar",children:[o("div",{"data-slot":"sidebar-gap",className:L("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",e==="floating"||e==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),o("div",{"data-slot":"sidebar-container","data-side":t,className:L("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",e==="floating"||e==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-e group-data-[side=right]:border-s",a),...l,children:o("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-none group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border",children:n})})]})}function aa(t){const e=k(15);let s,a,n;e[0]!==t?({className:s,onClick:a,...n}=t,e[0]=t,e[1]=s,e[2]=a,e[3]=n):(s=e[1],a=e[2],n=e[3]);const{toggleSidebar:r}=ht();let l;e[4]!==s?(l=L(s),e[4]=s,e[5]=l):l=e[5];let i;e[6]!==a||e[7]!==r?(i=f=>{a?.(f),r()},e[6]=a,e[7]=r,e[8]=i):i=e[8];let d,u;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=o(Ht,{icon:fs,strokeWidth:2,className:"rtl:rotate-180"}),u=o("span",{className:"sr-only",children:"Toggle Sidebar"}),e[9]=d,e[10]=u):(d=e[9],u=e[10]);let c;return e[11]!==n||e[12]!==l||e[13]!==i?(c=w(Vt,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon-sm",className:l,onClick:i,...n,children:[d,u]}),e[11]=n,e[12]=l,e[13]=i,e[14]=c):c=e[14],c}function oa(t){const e=k(8);let s,a;e[0]!==t?({className:s,...a}=t,e[0]=t,e[1]=s,e[2]=a):(s=e[1],a=e[2]);let n;e[3]!==s?(n=L("relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ms-0 md:peer-data-[variant=inset]:rounded-none md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ms-2",s),e[3]=s,e[4]=n):n=e[4];let r;return e[5]!==a||e[6]!==n?(r=o("main",{"data-slot":"sidebar-inset",className:n,...a}),e[5]=a,e[6]=n,e[7]=r):r=e[7],r}function na(t){const e=k(8);let s,a;e[0]!==t?({className:s,...a}=t,e[0]=t,e[1]=s,e[2]=a):(s=e[1],a=e[2]);let n;e[3]!==s?(n=L("flex flex-col gap-2 p-2",s),e[3]=s,e[4]=n):n=e[4];let r;return e[5]!==a||e[6]!==n?(r=o("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:n,...a}),e[5]=a,e[6]=n,e[7]=r):r=e[7],r}function ra(t){const e=k(8);let s,a;e[0]!==t?({className:s,...a}=t,e[0]=t,e[1]=s,e[2]=a):(s=e[1],a=e[2]);let n;e[3]!==s?(n=L("flex flex-col gap-2 p-2",s),e[3]=s,e[4]=n):n=e[4];let r;return e[5]!==a||e[6]!==n?(r=o("div",{"data-slot":"sidebar-footer","data-sidebar":"footer",className:n,...a}),e[5]=a,e[6]=n,e[7]=r):r=e[7],r}function la(t){const e=k(8);let s,a;e[0]!==t?({className:s,...a}=t,e[0]=t,e[1]=s,e[2]=a):(s=e[1],a=e[2]);let n;e[3]!==s?(n=L("flex min-h-0 flex-1 flex-col gap-0 overflow-x-hidden overflow-y-auto [scrollbar-color:color-mix(in_oklch,var(--muted-foreground)_25%,transparent)_transparent] [scrollbar-width:thin] [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-muted-foreground/25 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar]:w-1.5 hover:[scrollbar-color:color-mix(in_oklch,var(--muted-foreground)_50%,transparent)_transparent] hover:[&::-webkit-scrollbar-thumb]:bg-muted-foreground/50",s),e[3]=s,e[4]=n):n=e[4];let r;return e[5]!==a||e[6]!==n?(r=o("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:n,...a}),e[5]=a,e[6]=n,e[7]=r):r=e[7],r}function ia(t){const e=k(8);let s,a;e[0]!==t?({className:s,...a}=t,e[0]=t,e[1]=s,e[2]=a):(s=e[1],a=e[2]);let n;e[3]!==s?(n=L("relative flex w-full min-w-0 flex-col p-2",s),e[3]=s,e[4]=n):n=e[4];let r;return e[5]!==a||e[6]!==n?(r=o("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:n,...a}),e[5]=a,e[6]=n,e[7]=r):r=e[7],r}function da(t){const e=k(10);let s,a,n,r;if(e[0]!==t){const{className:d,render:u,...c}=t;s=u,r=zt,a="div",n=Bt({className:L("flex h-8 shrink-0 items-center rounded-none px-2 text-xs text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",d)},c),e[0]=t,e[1]=s,e[2]=a,e[3]=n,e[4]=r}else s=e[1],a=e[2],n=e[3],r=e[4];let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l={slot:"sidebar-group-label",sidebar:"group-label"},e[5]=l):l=e[5];let i;return e[6]!==s||e[7]!==a||e[8]!==n?(i={defaultTagName:a,props:n,render:s,state:l},e[6]=s,e[7]=a,e[8]=n,e[9]=i):i=e[9],r(i)}function ca(t){const e=k(8);let s,a;e[0]!==t?({className:s,...a}=t,e[0]=t,e[1]=s,e[2]=a):(s=e[1],a=e[2]);let n;e[3]!==s?(n=L("w-full text-xs",s),e[3]=s,e[4]=n):n=e[4];let r;return e[5]!==a||e[6]!==n?(r=o("div",{"data-slot":"sidebar-group-content","data-sidebar":"group-content",className:n,...a}),e[5]=a,e[6]=n,e[7]=r):r=e[7],r}function Pt(t){const e=k(8);let s,a;e[0]!==t?({className:s,...a}=t,e[0]=t,e[1]=s,e[2]=a):(s=e[1],a=e[2]);let n;e[3]!==s?(n=L("flex w-full min-w-0 flex-col gap-0",s),e[3]=s,e[4]=n):n=e[4];let r;return e[5]!==a||e[6]!==n?(r=o("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:n,...a}),e[5]=a,e[6]=n,e[7]=r):r=e[7],r}function _t(t){const e=k(8);let s,a;e[0]!==t?({className:s,...a}=t,e[0]=t,e[1]=s,e[2]=a):(s=e[1],a=e[2]);let n;e[3]!==s?(n=L("group/menu-item relative",s),e[3]=s,e[4]=n):n=e[4];let r;return e[5]!==a||e[6]!==n?(r=o("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:n,...a}),e[5]=a,e[6]=n,e[7]=r):r=e[7],r}const ua=hs("peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-none p-2 text-start text-xs ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pe-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]"},size:{default:"h-8 text-xs",sm:"h-7 text-xs",lg:"h-12 text-xs group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function Gt({render:t,isActive:e=!1,variant:s="default",size:a="default",tooltip:n,className:r,...l}){const{isMobile:i,state:d}=ht(),u=zt({defaultTagName:"button",props:Bt({className:L(ua({variant:s,size:a}),r)},l),render:n?o(Is,{render:t}):t,state:{slot:"sidebar-menu-button",sidebar:"menu-button",size:a,active:e}});return n?(typeof n=="string"&&(n={children:n}),w(Rs,{children:[u,o($s,{side:"right",align:"center",hidden:d!=="collapsed"||i,...n})]})):u}const ma=t=>t.replace("__lunora_admin__:",""),fa=()=>ls(ft.subscribe,ft.getSnapshot,ft.getSnapshot),ha=t=>t==="error"?"destructive":t==="pending"?"secondary":"default",pa=t=>{const e=k(56),{entry:s,focused:a}=t,n=ee();let r;e[0]!==a?(r=I=>{I!==null&&a&&I.scrollIntoView({block:"nearest"})},e[0]=a,e[1]=r):r=e[1];const l=r;let i;e[2]!==s.functionPath||e[3]!==s.shardKey||e[4]!==s.summary?(i=()=>{bs(`${s.functionPath} ${s.summary}${s.shardKey===""?"":` (shard ${s.shardKey})`}`)},e[2]=s.functionPath,e[3]=s.shardKey,e[4]=s.summary,e[5]=i):i=e[5];const d=i,u=a&&"bg-accent ring-1 ring-inset ring-primary/40";let c;e[6]!==u?(c=L("border-b border-border/60 last:border-b-0",u),e[6]=u,e[7]=c):c=e[7];let f;e[8]!==s.status?(f=ha(s.status),e[8]=s.status,e[9]=f):f=e[9];const p=s.status==="pending"?"…":s.status;let m;e[10]!==f||e[11]!==p?(m=o(dt,{className:"mt-px shrink-0",variant:f,children:p}),e[10]=f,e[11]=p,e[12]=m):m=e[12];let h;e[13]!==s.functionPath?(h=ma(s.functionPath),e[13]=s.functionPath,e[14]=h):h=e[14];let b;e[15]!==h?(b=o("span",{className:"shrink-0 font-mono text-[11px] text-foreground",children:h}),e[15]=h,e[16]=b):b=e[16];let v;e[17]!==s.kind||e[18]!==n?(v=s.kind==="subscription"&&o(dt,{className:"shrink-0",variant:"outline",children:n("live")}),e[17]=s.kind,e[18]=n,e[19]=v):v=e[19];let g;e[20]!==s.summary?(g=s.summary!==""&&o("span",{className:"min-w-0 truncate text-muted-foreground",children:s.summary}),e[20]=s.summary,e[21]=g):g=e[21];let x;e[22]!==s.shardKey?(x=s.shardKey!==""&&o("span",{className:"font-mono",children:s.shardKey}),e[22]=s.shardKey,e[23]=x):x=e[23];let y;e[24]!==s.resultCount||e[25]!==n?(y=s.resultCount!==void 0&&o("span",{children:n("{count} rows",{count:s.resultCount})}),e[24]=s.resultCount,e[25]=n,e[26]=y):y=e[26];let M;e[27]!==s.pushes||e[28]!==n?(M=s.pushes!==void 0&&s.pushes>0&&o("span",{children:n("{count} pushes",{count:s.pushes})}),e[27]=s.pushes,e[28]=n,e[29]=M):M=e[29];let S;e[30]!==s.durationMs?(S=s.durationMs!==void 0&&w("span",{children:[s.durationMs,"ms"]}),e[30]=s.durationMs,e[31]=S):S=e[31];let P;e[32]!==n?(P=n("Copy"),e[32]=n,e[33]=P):P=e[33];let N;e[34]!==d||e[35]!==P?(N=o("button",{"aria-label":P,className:"rounded px-1 outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"oc-copy",onClick:d,type:"button",children:"⧉"}),e[34]=d,e[35]=P,e[36]=N):N=e[36];let T;e[37]!==x||e[38]!==y||e[39]!==M||e[40]!==S||e[41]!==N?(T=w("span",{className:"ms-auto flex shrink-0 items-center gap-2 text-[11px] text-muted-foreground",children:[x,y,M,S,N]}),e[37]=x,e[38]=y,e[39]=M,e[40]=S,e[41]=N,e[42]=T):T=e[42];let _;e[43]!==v||e[44]!==g||e[45]!==T||e[46]!==m||e[47]!==b?(_=w("div",{className:"flex items-start gap-2 px-3 py-1.5 text-xs",children:[m,b,v,g,T]}),e[43]=v,e[44]=g,e[45]=T,e[46]=m,e[47]=b,e[48]=_):_=e[48];let C;e[49]!==s.error?(C=s.error!==void 0&&o("p",{className:"px-3 pb-1.5 font-mono text-[11px] text-destructive","data-testid":"oc-error",children:s.error}),e[49]=s.error,e[50]=C):C=e[50];let E;return e[51]!==l||e[52]!==_||e[53]!==C||e[54]!==c?(E=w("li",{className:c,"data-testid":"oc-row",ref:l,children:[_,C]}),e[51]=l,e[52]=_,e[53]=C,e[54]=c,e[55]=E):E=e[55],E},ga=t=>{const e=k(62),{focusSeq:s,onClose:a,onShownChange:n,shown:r}=t,l=ee(),i=fa(),[d,u]=it("");let c;if(e[0]!==i||e[1]!==s||e[2]!==d||e[3]!==a||e[4]!==n||e[5]!==r||e[6]!==l){const f=d.trim().toLowerCase(),p=i.filter($=>(r==="errors"?$.status==="error":!0)&&(f===""||`${$.functionPath} ${$.summary} ${$.shardKey}`.toLowerCase().includes(f))).toReversed();let m;e[8]!==i?(m=i.filter(ba),e[8]=i,e[9]=m):m=e[9];const h=m.length;let b;e[10]!==l?(b=l("Operation console"),e[10]=l,e[11]=b):b=e[11];let v;e[12]!==l?(v=l("Operation console"),e[12]=l,e[13]=v):v=e[13];let g;e[14]!==v?(g=o("span",{className:"text-xs font-medium",children:v}),e[14]=v,e[15]=g):g=e[15];let x;e[16]!==i.length||e[17]!==l?(x=l("{count} calls",{count:i.length}),e[16]=i.length,e[17]=l,e[18]=x):x=e[18];let y;e[19]!==x?(y=o(dt,{variant:"secondary",children:x}),e[19]=x,e[20]=y):y=e[20];let M;e[21]!==h||e[22]!==l?(M=h>0&&o(dt,{variant:"destructive",children:l("{count} failed",{count:h})}),e[21]=h,e[22]=l,e[23]=M):M=e[23];const S=r==="errors",P=r==="errors"&&"bg-accent";let N;e[24]!==P?(N=L("rounded px-2 py-0.5 text-xs outline-none hover:bg-accent focus-visible:bg-accent",P),e[24]=P,e[25]=N):N=e[25];let T;e[26]!==n||e[27]!==r?(T=()=>{n(r==="errors"?"all":"errors")},e[26]=n,e[27]=r,e[28]=T):T=e[28];let _;e[29]!==l?(_=l("Errors"),e[29]=l,e[30]=_):_=e[30];let C;e[31]!==N||e[32]!==T||e[33]!==_||e[34]!==S?(C=o("button",{"aria-pressed":S,className:N,"data-testid":"oc-filter-errors",onClick:T,type:"button",children:_}),e[31]=N,e[32]=T,e[33]=_,e[34]=S,e[35]=C):C=e[35];let E;e[36]!==l?(E=l("Filter"),e[36]=l,e[37]=E):E=e[37];let I;e[38]===Symbol.for("react.memo_cache_sentinel")?(I=$=>{u($.target.value)},e[38]=I):I=e[38];let H;e[39]!==l?(H=l("Filter"),e[39]=l,e[40]=H):H=e[40];let V;e[41]!==d||e[42]!==E||e[43]!==H?(V=o($t,{"aria-label":E,className:"h-7 w-40 text-xs","data-testid":"oc-search",onChange:I,placeholder:H,value:d}),e[41]=d,e[42]=E,e[43]=H,e[44]=V):V=e[44];let O;e[45]!==l?(O=l("Clear"),e[45]=l,e[46]=O):O=e[46];let B;e[47]!==O?(B=o("button",{className:"ms-auto rounded px-2 py-0.5 text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"oc-clear",onClick:va,type:"button",children:O}),e[47]=O,e[48]=B):B=e[48];let z;e[49]!==l?(z=l("Hide"),e[49]=l,e[50]=z):z=e[50];let D;e[51]!==a||e[52]!==z?(D=o("button",{"aria-label":z,className:"rounded px-2 py-0.5 text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"oc-close",onClick:a,type:"button",children:"✕"}),e[51]=a,e[52]=z,e[53]=D):D=e[53];let F;e[54]!==C||e[55]!==V||e[56]!==B||e[57]!==D||e[58]!==g||e[59]!==y||e[60]!==M?(F=w("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-1.5",children:[g,y,M,C,V,B,D]}),e[54]=C,e[55]=V,e[56]=B,e[57]=D,e[58]=g,e[59]=y,e[60]=M,e[61]=F):F=e[61],c=w("section",{"aria-label":b,className:"flex max-h-80 flex-col border-t border-border bg-card","data-testid":"lunora-operation-console",children:[F,p.length===0?o("p",{className:"p-3 text-xs text-muted-foreground","data-testid":"oc-empty",children:l("Every admin call this studio makes is recorded here.")}):o("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"oc-rows",children:p.map($=>o(pa,{entry:$,focused:$.seq===s},$.seq))})]}),e[0]=i,e[1]=s,e[2]=d,e[3]=a,e[4]=n,e[5]=r,e[6]=l,e[7]=c}else c=e[7];return c};function ba(t){return t.status==="error"}function va(){ft.clear()}const xa=()=>{const t=k(310),e=ee();let s;t[0]!==e?(s=e("Health score"),t[0]=e,t[1]=s):s=t[1];let a;t[2]!==e?(a=e("Agents"),t[2]=e,t[3]=a):a=t[3];let n;t[4]!==e?(n=e("Evals"),t[4]=e,t[5]=n):n=t[5];let r;t[6]!==e?(r=e("Analytics"),t[6]=e,t[7]=r):r=t[7];let l;t[8]!==e?(l=e("API"),t[8]=e,t[9]=l):l=t[9];let i;t[10]!==e?(i=e("Audit"),t[10]=e,t[11]=i):i=t[11];let d;t[12]!==e?(d=e("Auth audit"),t[12]=e,t[13]=d):d=t[13];let u;t[14]!==e?(u=e("Configuration"),t[14]=e,t[15]=u):u=t[15];let c;t[16]!==e?(c=e("Sessions"),t[16]=e,t[17]=c):c=t[17];let f;t[18]!==e?(f=e("Containers"),t[18]=e,t[19]=f):f=t[19];let p;t[20]!==e?(p=e("Dashboards"),t[20]=e,t[21]=p):p=t[21];let m;t[22]!==e?(m=e("Data"),t[22]=e,t[23]=m):m=t[23];let h;t[24]!==e?(h=e("Deployment health"),t[24]=e,t[25]=h):h=t[25];let b;t[26]!==e?(b=e("Log drains"),t[26]=e,t[27]=b):b=t[27];let v;t[28]!==e?(v=e("Export / Import"),t[28]=e,t[29]=v):v=t[29];let g;t[30]!==e?(g=e("Fan-out"),t[30]=e,t[31]=g):g=t[31];let x;t[32]!==e?(x=e("Files"),t[32]=e,t[33]=x):x=t[33];let y;t[34]!==e?(y=e("Flags"),t[34]=e,t[35]=y):y=t[35];let M;t[36]!==e?(M=e("Functions"),t[36]=e,t[37]=M):M=t[37];let S;t[38]!==e?(S=e("Health"),t[38]=e,t[39]=S):S=t[39];let P;t[40]!==e?(P=e("Home"),t[40]=e,t[41]=P):P=t[41];let N;t[42]!==e?(N=e("Performance"),t[42]=e,t[43]=N):N=t[43];let T;t[44]!==e?(T=e("Issues"),t[44]=e,t[45]=T):T=t[45];let _;t[46]!==e?(_=e("KV"),t[46]=e,t[47]=_):_=t[47];let C;t[48]!==e?(C=e("Logs"),t[48]=e,t[49]=C):C=t[49];let E;t[50]!==e?(E=e("Metrics"),t[50]=e,t[51]=E):E=t[51];let I;t[52]!==e?(I=e("Migrations"),t[52]=e,t[53]=I):I=t[53];let H;t[54]!==e?(H=e("Notifications"),t[54]=e,t[55]=H):H=t[55];let V;t[56]!==e?(V=e("Organizations"),t[56]=e,t[57]=V):V=t[57];let O;t[58]!==e?(O=e("Time Travel"),t[58]=e,t[59]=O):O=t[59];let B;t[60]!==e?(B=e("Mail"),t[60]=e,t[61]=B):B=t[61];let z;t[62]!==e?(z=e("Payments"),t[62]=e,t[63]=z):z=t[63];let D;t[64]!==e?(D=e("Permissions"),t[64]=e,t[65]=D):D=t[65];let F;t[66]!==e?(F=e("Queues"),t[66]=e,t[67]=F):F=t[67];let $;t[68]!==e?($=e("Realtime"),t[68]=e,t[69]=$):$=t[69];let q;t[70]!==e?(q=e("RLS Policies"),t[70]=e,t[71]=q):q=t[71];let X;t[72]!==e?(X=e("Scheduled"),t[72]=e,t[73]=X):X=t[73];let W;t[74]!==e?(W=e("Schema"),t[74]=e,t[75]=W):W=t[75];let Y;t[76]!==e?(Y=e("Security"),t[76]=e,t[77]=Y):Y=t[77];let j;t[78]!==e?(j=e("Settings"),t[78]=e,t[79]=j):j=t[79];let U;t[80]!==e?(U=e("SQL editor"),t[80]=e,t[81]=U):U=t[81];let K;t[82]!==e?(K=e("Traces"),t[82]=e,t[83]=K):K=t[83];let G;t[84]!==e?(G=e("Access Rules"),t[84]=e,t[85]=G):G=t[85];let Q;t[86]!==e?(Q=e("Users"),t[86]=e,t[87]=Q):Q=t[87];let J;t[88]!==e?(J=e("Vectors"),t[88]=e,t[89]=J):J=t[89];let Z;t[90]!==e?(Z=e("Workflows"),t[90]=e,t[91]=Z):Z=t[91];let te;t[92]!==s||t[93]!==a||t[94]!==p||t[95]!==m||t[96]!==h||t[97]!==b||t[98]!==v||t[99]!==g||t[100]!==x||t[101]!==y||t[102]!==M||t[103]!==S||t[104]!==n||t[105]!==P||t[106]!==N||t[107]!==T||t[108]!==_||t[109]!==C||t[110]!==E||t[111]!==I||t[112]!==H||t[113]!==V||t[114]!==O||t[115]!==r||t[116]!==B||t[117]!==z||t[118]!==D||t[119]!==F||t[120]!==$||t[121]!==q||t[122]!==X||t[123]!==W||t[124]!==Y||t[125]!==j||t[126]!==l||t[127]!==U||t[128]!==K||t[129]!==G||t[130]!==Q||t[131]!==J||t[132]!==Z||t[133]!==i||t[134]!==d||t[135]!==u||t[136]!==c||t[137]!==f?(te={advisorHealth:s,agents:a,evals:n,analytics:r,api:l,audit:i,authAudit:d,authConfig:u,authSessions:c,containers:f,dashboards:p,data:m,deploymentHealth:h,drains:b,export:v,fanout:g,files:x,flags:y,functions:M,health:S,home:P,insights:N,issues:T,kv:_,logs:C,metrics:E,migrations:I,notifications:H,organizations:V,pitr:O,mail:B,payments:z,permissions:D,queues:F,realtime:$,rls:q,schedule:X,schema:W,security:Y,settings:j,sql:U,traces:K,storageRules:G,users:Q,vectors:J,workflows:Z},t[92]=s,t[93]=a,t[94]=p,t[95]=m,t[96]=h,t[97]=b,t[98]=v,t[99]=g,t[100]=x,t[101]=y,t[102]=M,t[103]=S,t[104]=n,t[105]=P,t[106]=N,t[107]=T,t[108]=_,t[109]=C,t[110]=E,t[111]=I,t[112]=H,t[113]=V,t[114]=O,t[115]=r,t[116]=B,t[117]=z,t[118]=D,t[119]=F,t[120]=$,t[121]=q,t[122]=X,t[123]=W,t[124]=Y,t[125]=j,t[126]=l,t[127]=U,t[128]=K,t[129]=G,t[130]=Q,t[131]=J,t[132]=Z,t[133]=i,t[134]=d,t[135]=u,t[136]=c,t[137]=f,t[138]=te):te=t[138];const pt=te;let oe;t[139]!==e?(oe=e("Advisors"),t[139]=e,t[140]=oe):oe=t[140];let ne;t[141]!==e?(ne=e("Auth"),t[141]=e,t[142]=ne):ne=t[142];let re;t[143]!==e?(re=e("Database"),t[143]=e,t[144]=re):re=t[144];let le;t[145]!==e?(le=e("Functions"),t[145]=e,t[146]=le):le=t[146];let ie;t[147]!==e?(ie=e("Observability"),t[147]=e,t[148]=ie):ie=t[148];let de;t[149]!==e?(de=e("Operations"),t[149]=e,t[150]=de):de=t[150];let ce;t[151]!==e?(ce=e("Overview"),t[151]=e,t[152]=ce):ce=t[152];let ue;t[153]!==e?(ue=e("Settings"),t[153]=e,t[154]=ue):ue=t[154];let me;t[155]!==e?(me=e("Storage"),t[155]=e,t[156]=me):me=t[156];let ct;t[157]!==oe||t[158]!==ne||t[159]!==re||t[160]!==le||t[161]!==ie||t[162]!==de||t[163]!==ce||t[164]!==ue||t[165]!==me?(ct={advisors:oe,auth:ne,database:re,functions:le,observability:ie,operations:de,overview:ce,settings:ue,storage:me},t[157]=oe,t[158]=ne,t[159]=re,t[160]=le,t[161]=ie,t[162]=de,t[163]=ce,t[164]=ue,t[165]=me,t[166]=ct):ct=t[166];const gt=ct;let fe;t[167]!==e?(fe=e("Score your app's advisor findings: a grade, the coverage split, and every procedure ranked worst-first."),t[167]=e,t[168]=fe):fe=t[168];let he;t[169]!==e?(he=e("Inspect agent threads, message timelines, tool calls, and token usage."),t[169]=e,t[170]=he):he=t[170];let pe;t[171]!==e?(pe=e("Scores recorded by recordEvaluation — the latest verdict per eval, its trend, and the graded runs behind it."),t[171]=e,t[172]=pe):pe=t[172];let ge;t[173]!==e?(ge=e("Usage and latency from Analytics Engine — request volume, p50/p95, and hot shards."),t[173]=e,t[174]=ge):ge=t[174];let be;t[175]!==e?(be=e("Interactive OpenAPI reference and copy-paste snippets for your functions."),t[175]=e,t[176]=be):be=t[176];let ve;t[177]!==e?(ve=e("A durable log of admin state-changing operations."),t[177]=e,t[178]=ve):ve=t[178];let xe;t[179]!==e?(xe=e("Authentication and security events — sign-ins, MFA, and session changes."),t[179]=e,t[180]=xe):xe=t[180];let ye;t[181]!==e?(ye=e("Enabled plugins and session config (read-only)."),t[181]=e,t[182]=ye):ye=t[182];let we;t[183]!==e?(we=e("Browse and revoke active sessions across all users."),t[183]=e,t[184]=we):we=t[184];let ke;t[185]!==e?(ke=e("Live Cloudflare Containers — current lifecycle state per instance from the log stream."),t[185]=e,t[186]=ke):ke=t[186];let Ne;t[187]!==e?(Ne=e("Chart widgets backed by saved read-only SQL queries."),t[187]=e,t[188]=Ne):Ne=t[188];let Me;t[189]!==e?(Me=e("Browse and edit rows across your shard and global tables."),t[189]=e,t[190]=Me):Me=t[190];let Se;t[191]!==e?(Se=e("Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint."),t[191]=e,t[192]=Se):Se=t[192];let Ce;t[193]!==e?(Ce=e("Forward logs to Logpush, Tail Workers, or a webhook collector."),t[193]=e,t[194]=Ce):Ce=t[194];let Pe;t[195]!==e?(Pe=e("Export a shard to NDJSON, or import rows from it."),t[195]=e,t[196]=Pe):Pe=t[196];let _e;t[197]!==e?(_e=e("Realtime fan-out cost and per-topic subscriber counts for this shard."),t[197]=e,t[198]=_e):_e=t[198];let Te;t[199]!==e?(Te=e("Browse objects in your R2 storage buckets."),t[199]=e,t[200]=Te):Te=t[200];let Le;t[201]!==e?(Le=e("Inspect feature flags and their live evaluation under a targeting context."),t[201]=e,t[202]=Le):Le=t[202];let Ae;t[203]!==e?(Ae=e("Run registered queries, mutations, and actions."),t[203]=e,t[204]=Ae):Ae=t[204];let Ee;t[205]!==e?(Ee=e("At-a-glance connection, error, and shard signals."),t[205]=e,t[206]=Ee):Ee=t[206];let Re;t[207]!==e?(Re=e("Connection, health, and advisor summary for your deployment."),t[207]=e,t[208]=Re):Re=t[208];let Ie;t[209]!==e?(Ie=e("Surface slow functions, error spikes, and cache problems."),t[209]=e,t[210]=Ie):Ie=t[210];let $e;t[211]!==e?($e=e("Grouped error triage — Worker throws and container crashes folded by fingerprint."),t[211]=e,t[212]=$e):$e=t[212];let He;t[213]!==e?(He=e("A live stream of recent function logs."),t[213]=e,t[214]=He):He=t[214];let Be;t[215]!==e?(Be=e("Per-shard health and aggregate metrics."),t[215]=e,t[216]=Be):Be=t[216];let ze;t[217]!==e?(ze=e("Review migration status and run them."),t[217]=e,t[218]=ze):ze=t[218];let Ve;t[219]!==e?(Ve=e("Registered push devices — endpoint, kind, last-send status, and delivery errors."),t[219]=e,t[220]=Ve):Ve=t[220];let Oe;t[221]!==e?(Oe=e("Browse and manage organizations, members, and invitations."),t[221]=e,t[222]=Oe):Oe=t[222];let De;t[223]!==e?(De=e("Restore a shard to a point in the last 30 days."),t[223]=e,t[224]=De):De=t[224];let Ze;t[225]!==e?(Ze=e("Email your app sent, captured in dev."),t[225]=e,t[226]=Ze):Ze=t[226];let Fe;t[227]!==e?(Fe=e("Synced customers, subscriptions, and webhook events."),t[227]=e,t[228]=Fe):Fe=t[228];let qe;t[229]!==e?(qe=e("Inspect access policies per table, and probe a function as any identity."),t[229]=e,t[230]=qe):qe=t[230];let We;t[231]!==e?(We=e("Inspect declared Cloudflare Queues — their producer bindings, consumer mode, and dead-letter queue."),t[231]=e,t[232]=We):We=t[232];let je;t[233]!==e?(je=e("Active WebSocket subscriptions on this shard."),t[233]=e,t[234]=je):je=t[234];let Ue;t[235]!==e?(Ue=e("Inspect row-level-security policies and roles, per table."),t[235]=e,t[236]=Ue):Ue=t[236];let Ke;t[237]!==e?(Ke=e("Inspect and cancel scheduled jobs."),t[237]=e,t[238]=Ke):Ke=t[238];let Ge;t[239]!==e?(Ge=e("Inspect each table and its columns."),t[239]=e,t[240]=Ge):Ge=t[240];let Qe;t[241]!==e?(Qe=e("Review admin gates, credentials, and log redaction."),t[241]=e,t[242]=Qe):Qe=t[242];let Ye;t[243]!==e?(Ye=e("Read-only deployment config — vars, secrets, and bindings."),t[243]=e,t[244]=Ye):Ye=t[244];let Je;t[245]!==e?(Je=e("Run read-only SQL against a shard."),t[245]=e,t[246]=Je):Je=t[246];let Xe;t[247]!==e?(Xe=e("Browse and edit key-value pairs in your Workers KV namespaces."),t[247]=e,t[248]=Xe):Xe=t[248];let et;t[249]!==e?(et=e("Inspect storage access rules — per bucket, operation, and key prefix."),t[249]=e,t[250]=et):et=t[250];let tt;t[251]!==e?(tt=e("Recent ctx.trace waterfalls for this shard — the drill-down from a log line."),t[251]=e,t[252]=tt):tt=t[252];let st;t[253]!==e?(st=e("Manage auth users — roles, bans, sessions, and identity."),t[253]=e,t[254]=st):st=t[254];let at;t[255]!==e?(at=e("Browse Vectorize indexes and run similarity searches."),t[255]=e,t[256]=at):at=t[256];let ot;t[257]!==e?(ot=e("Inspect declared Cloudflare Workflows and their bindings."),t[257]=e,t[258]=ot):ot=t[258];let ut;t[259]!==st||t[260]!==at||t[261]!==ot||t[262]!==fe||t[263]!==he||t[264]!==pe||t[265]!==ge||t[266]!==be||t[267]!==ve||t[268]!==xe||t[269]!==ye||t[270]!==we||t[271]!==ke||t[272]!==Ne||t[273]!==Me||t[274]!==Se||t[275]!==Ce||t[276]!==Pe||t[277]!==_e||t[278]!==Te||t[279]!==Le||t[280]!==Ae||t[281]!==Ee||t[282]!==Re||t[283]!==Ie||t[284]!==$e||t[285]!==He||t[286]!==Be||t[287]!==ze||t[288]!==Ve||t[289]!==Oe||t[290]!==De||t[291]!==Ze||t[292]!==Fe||t[293]!==qe||t[294]!==We||t[295]!==je||t[296]!==Ue||t[297]!==Ke||t[298]!==Ge||t[299]!==Qe||t[300]!==Ye||t[301]!==Je||t[302]!==Xe||t[303]!==et||t[304]!==tt?(ut={advisorHealth:fe,agents:he,evals:pe,analytics:ge,api:be,audit:ve,authAudit:xe,authConfig:ye,authSessions:we,containers:ke,dashboards:Ne,data:Me,deploymentHealth:Se,drains:Ce,export:Pe,fanout:_e,files:Te,flags:Le,functions:Ae,health:Ee,home:Re,insights:Ie,issues:$e,logs:He,metrics:Be,migrations:ze,notifications:Ve,organizations:Oe,pitr:De,mail:Ze,payments:Fe,permissions:qe,queues:We,realtime:je,rls:Ue,schedule:Ke,schema:Ge,security:Qe,settings:Ye,sql:Je,kv:Xe,storageRules:et,traces:tt,users:st,vectors:at,workflows:ot},t[259]=st,t[260]=at,t[261]=ot,t[262]=fe,t[263]=he,t[264]=pe,t[265]=ge,t[266]=be,t[267]=ve,t[268]=xe,t[269]=ye,t[270]=we,t[271]=ke,t[272]=Ne,t[273]=Me,t[274]=Se,t[275]=Ce,t[276]=Pe,t[277]=_e,t[278]=Te,t[279]=Le,t[280]=Ae,t[281]=Ee,t[282]=Re,t[283]=Ie,t[284]=$e,t[285]=He,t[286]=Be,t[287]=ze,t[288]=Ve,t[289]=Oe,t[290]=De,t[291]=Ze,t[292]=Fe,t[293]=qe,t[294]=We,t[295]=je,t[296]=Ue,t[297]=Ke,t[298]=Ge,t[299]=Qe,t[300]=Ye,t[301]=Je,t[302]=Xe,t[303]=et,t[304]=tt,t[305]=ut):ut=t[305];const bt=ut;let mt;return t[306]!==gt||t[307]!==bt||t[308]!==pt?(mt={groupLabel:gt,tabDescription:bt,tabLabel:pt},t[306]=gt,t[307]=bt,t[308]=pt,t[309]=mt):mt=t[309],mt},ya=()=>{const t=k(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=w("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:[o("rect",{height:"14",rx:"2",width:"20",x:"2",y:"3"}),o("path",{d:"M8 21h8M12 17v4"})]}),t[0]=e):e=t[0],e},wa=()=>{const t=k(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=w("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:[o("circle",{cx:"12",cy:"12",r:"4"}),o("path",{d:"M12 2v2m0 16v2M4.9 4.9l1.4 1.4m11.4 11.4 1.4 1.4M2 12h2m16 0h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"})]}),t[0]=e):e=t[0],e},ka=()=>{const t=k(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:o("path",{d:"M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8Z"})}),t[0]=e):e=t[0],e},Na=[{Icon:ya,value:"system"},{Icon:wa,value:"light"},{Icon:ka,value:"dark"}],Ma=()=>{const t=k(19),{theme:e,setTheme:s}=Es(),a=ee();let n;t[0]!==a?(n=a("Dark theme"),t[0]=a,t[1]=n):n=t[1];let r;t[2]!==a?(r=a("Light theme"),t[2]=a,t[3]=r):r=t[3];let l;t[4]!==a?(l=a("System theme"),t[4]=a,t[5]=l):l=t[5];let i;t[6]!==n||t[7]!==r||t[8]!==l?(i={dark:n,light:r,system:l},t[6]=n,t[7]=r,t[8]=l,t[9]=i):i=t[9];const d=i;let u;t[10]!==a?(u=a("Theme"),t[10]=a,t[11]=u):u=t[11];let c;t[12]!==d||t[13]!==s||t[14]!==e?(c=Na.map(p=>{const{Icon:m,value:h}=p,b=e===h;return w("button",{"aria-checked":b,"aria-label":d[h],className:L("relative flex size-7 cursor-pointer items-center justify-center rounded-md outline-none transition-colors focus-visible:bg-accent",b?"text-foreground":"text-muted-foreground hover:text-foreground"),"data-testid":`dash-app-theme-${h}`,onClick:()=>{s(h)},role:"radio",title:d[h],type:"button",children:[b&&o(Ns.span,{className:"absolute inset-0 rounded-md border border-muted-foreground/40 bg-background/40",layoutId:"studio-theme-active",transition:{bounce:.1,duration:.45,type:"spring"}}),o("span",{className:"relative",children:o(m,{})})]},h)}),t[12]=d,t[13]=s,t[14]=e,t[15]=c):c=t[15];let f;return t[16]!==u||t[17]!==c?(f=o("div",{"aria-label":u,className:"inline-flex items-center gap-0.5 overflow-hidden rounded-md border border-border bg-muted/60 p-0.5","data-testid":"dash-app-theme",role:"radiogroup",children:c}),t[16]=u,t[17]=c,t[18]=f):f=t[18],f},Sa=t=>{const e=k(23),{domain:s,onOpenCommandPalette:a,page:n}=t,r=ee();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=o(aa,{className:"-ms-1"}),e[0]=l):l=e[0];let i;e[1]!==r?(i=r("Breadcrumb"),e[1]=r,e[2]=i):i=e[2];let d;e[3]!==s?(d=o("span",{className:"text-muted-foreground",children:s}),e[3]=s,e[4]=d):d=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=o("svg",{"aria-hidden":"true",className:"size-3.5 text-muted-foreground/60",fill:"none",stroke:"currentColor",strokeWidth:1.7,viewBox:"0 0 24 24",children:o("path",{d:"m9 6 6 6-6 6",strokeLinecap:"round",strokeLinejoin:"round"})}),e[5]=u):u=e[5];let c;e[6]!==n?(c=o("span",{className:"font-medium text-foreground",children:n}),e[6]=n,e[7]=c):c=e[7];let f;e[8]!==i||e[9]!==d||e[10]!==c?(f=w("nav",{"aria-label":i,className:"flex items-center gap-1.5 text-[13px]",children:[d,u,c]}),e[8]=i,e[9]=d,e[10]=c,e[11]=f):f=e[11];let p;e[12]===Symbol.for("react.memo_cache_sentinel")?(p=w("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeWidth:1.8,viewBox:"0 0 24 24",children:[o("circle",{cx:"11",cy:"11",r:"7"}),o("path",{d:"m21 21-4.3-4.3",strokeLinecap:"round"})]}),e[12]=p):p=e[12];let m;e[13]!==r?(m=r("Search…"),e[13]=r,e[14]=m):m=e[14];let h;e[15]===Symbol.for("react.memo_cache_sentinel")?(h=o("kbd",{className:"ms-auto rounded border border-border bg-background px-1 font-sans text-[10px] text-muted-foreground",children:"⌘K"}),e[15]=h):h=e[15];let b;e[16]!==a||e[17]!==m?(b=w("button",{className:"mx-auto hidden h-8 w-72 items-center gap-2 rounded-lg border border-border bg-muted/40 px-3 text-xs text-muted-foreground transition-colors hover:bg-muted md:flex","data-testid":"dash-app-search",onClick:a,type:"button",children:[p,m,h]}),e[16]=a,e[17]=m,e[18]=b):b=e[18];let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=o("div",{className:"ms-auto flex items-center gap-1.5 md:ms-0",children:o(Ma,{})}),e[19]=v):v=e[19];let g;return e[20]!==b||e[21]!==f?(g=w("header",{className:"flex h-11 shrink-0 items-center gap-2 border-b border-border px-4","data-testid":"dash-app-header",children:[l,f,b,v]}),e[20]=b,e[21]=f,e[22]=g):g=e[22],g},Ca=t=>{const e=k(4),{console:s}=Ms();let a,n;e[0]!==s||e[1]!==t?(a=()=>{if(t===void 0)return;const r=l=>{if(!l.ctrlKey||l.metaKey||l.altKey||l.shiftKey||l.repeat||l.key.toLowerCase()!==s)return;const{target:i}=l;i instanceof HTMLElement&&(i.isContentEditable||["INPUT","SELECT","TEXTAREA"].includes(i.tagName))||(l.preventDefault(),t())};return globalThis.addEventListener("keydown",r),()=>{globalThis.removeEventListener("keydown",r)}},n=[s,t],e[0]=s,e[1]=t,e[2]=a,e[3]=n):(a=e[2],n=e[3]),rt(a,n)},R=(t,e)=>A(()=>t().then(s=>({default:s[e]}))),Pa=R(()=>import("../packem_chunks/InsightsPanel.js"),"InsightsPanel"),_a=A(()=>import("../packem_chunks/rls-panel.js")),Ta=A(()=>import("../packem_chunks/AdvisorHealthPanel.js")),La=A(()=>import("../packem_chunks/SecurityAdvisorPanel.js")),Aa=A(()=>import("../packem_chunks/agents-panel.js")),Ea=R(()=>import("../packem_chunks/analytics-panel.js"),"AnalyticsPanel"),Ra=A(()=>import("../packem_chunks/ApiTab.js")),Ia=A(()=>import("../packem_chunks/auth-audit-panel.js")),$a=A(()=>import("../packem_chunks/auth-config-panel.js")),Ha=A(()=>import("../packem_chunks/auth-sessions-panel.js")),Ba=A(()=>import("../packem_chunks/organizations-panel.js")),za=R(()=>import("../packem_chunks/users-panel.js"),"UsersPanel"),Va=A(()=>import("../packem_chunks/containers-panel.js")),Oa=R(()=>import("../packem_chunks/DeploymentHealthPanel.js"),"DeploymentHealthPanel"),Da=R(()=>import("../packem_chunks/TableEditor.js"),"TableEditor"),Za=R(()=>import("../packem_chunks/ExportImportPanel.js"),"ExportImportPanel"),Fa=A(()=>import("../packem_chunks/migrations-route.js")),qa={data:ys,migrations:xs},Wa=R(()=>import("../packem_chunks/PitrPanel.js"),"PitrPanel"),ja=A(()=>import("../packem_chunks/flags-panel.js")),Ua=R(()=>import("../packem_chunks/FunctionRunner.js"),"FunctionRunner"),Ka=R(()=>import("../packem_chunks/FunctionStatsPanel.js"),"FunctionStatsPanel"),Ga=A(()=>import("../packem_chunks/issues-panel.js")),Qa=R(()=>import("../packem_chunks/AuditPanel.js"),"AuditPanel"),Ya=A(()=>import("../packem_chunks/log-drains-panel.js")),Ja=A(()=>import("../packem_chunks/LogsPanel.js").then(t=>({default:t.LogsPanel}))),Xa=R(()=>import("../packem_chunks/MailPanel.js"),"MailPanel"),eo=R(()=>import("../packem_chunks/schedule-panel.js"),"SchedulePanel"),to=A(()=>import("../packem_chunks/subscriptions-panel.js")),so=A(()=>import("../packem_chunks/sync-client-panel.js")),ao=R(()=>import("../packem_chunks/kv-browser.js"),"KvBrowser"),oo=A(()=>import("../packem_chunks/NotificationsPanel.js")),no=R(()=>import("../packem_chunks/payments-panel.js"),"PaymentsPanel"),ro=R(()=>import("../packem_chunks/permissions-panel.js"),"PermissionsPanel"),lo=A(()=>import("../packem_chunks/queues-panel.js")),io=A(()=>import("../packem_chunks/dashboards-panel.js")),co=A(()=>import("../packem_chunks/fanout-panel.js")),uo=R(()=>import("../packem_chunks/HealthPanel.js"),"HealthPanel"),mo=R(()=>import("../packem_chunks/MetricsPanel.js"),"MetricsPanel"),fo=R(()=>import("../packem_chunks/SchemaViewer.js"),"SchemaViewer"),ho=R(()=>import("../packem_chunks/SettingsPanel.js"),"SettingsPanel"),po=R(()=>import("../packem_chunks/SqlEditorPanel.js"),"SqlEditorPanel"),go=R(()=>import("../packem_chunks/FileBrowser.js"),"FileBrowser"),bo=A(()=>import("../packem_chunks/storage-rules-panel.js")),vo=A(()=>import("../packem_chunks/traces-panel.js")),xo=A(()=>import("../packem_chunks/evals-panel.js")),yo=R(()=>import("../packem_chunks/vector-browser.js"),"VectorBrowser"),wo=A(()=>import("../packem_chunks/workflows-panel.js")),Qt=Et(null),ko={analytics:o("path",{d:"M5 20V10m6.5 10V4M18 20v-7M3 20h18"}),api:o("path",{d:"m9 8-4 4 4 4m6-8 4 4-4 4M13 5l-2 14"}),audit:o("path",{d:"M7 4h7l4 4v11a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1Zm6 0v5h5M9 13h6M9 16h6M9 10h2"}),authAudit:o("path",{d:"M12 3 5 6v5c0 4.5 3 7.8 7 9 4-1.2 7-4.5 7-9V6l-7-3Zm-3 8h6m-6 3h6"}),authConfig:o("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Zm7.4-3a7.4 7.4 0 0 0-.1-1.2l2-1.6-2-3.4-2.4 1a7.3 7.3 0 0 0-2-1.2l-.4-2.6h-3.6l-.4 2.6a7.3 7.3 0 0 0-2 1.2l-2.4-1-2 3.4 2 1.6a7.4 7.4 0 0 0 0 2.4l-2 1.6 2 3.4 2.4-1a7.3 7.3 0 0 0 2 1.2l.4 2.6h3.6l.4-2.6a7.3 7.3 0 0 0 2-1.2l2.4 1 2-3.4-2-1.6a7.4 7.4 0 0 0 .1-1.2Z"}),agents:o("path",{d:"M12 8V5m0 0a2 2 0 1 0 0-4 2 2 0 0 0 0 4ZM6 8h12a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-6a2 2 0 0 1 2-2Zm3 5h.01M15 13h.01M9 21h6"}),authSessions:o("path",{d:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18Zm0-13.5V12l4 2"}),containers:o("path",{d:"M3 7.5 12 3l9 4.5v9L12 21l-9-4.5v-9Zm0 0 9 4.5m0 0 9-4.5m-9 4.5V21"}),dashboards:o("path",{d:"M4 5h7v6H4V5Zm9 0h7v4h-7V5ZM4 14h7v5H4v-5Zm9-1h7v6h-7v-6Z"}),deploymentHealth:o("path",{d:"M12 3 5 6v5c0 4.5 3 7.8 7 9 4-1.2 7-4.5 7-9V6l-7-3Zm-3 8 2 3 4-5"}),drains:o("path",{d:"M5 5h14M7 5v6a5 5 0 0 0 10 0V5M10 16h4v3h-4zM12 19v2"}),data:o("path",{d:"M5 6c0-1.4 3.1-2.5 7-2.5s7 1.1 7 2.5-3.1 2.5-7 2.5S5 7.4 5 6Zm0 0v12c0 1.4 3.1 2.5 7 2.5s7-1.1 7-2.5V6M5 12c0 1.4 3.1 2.5 7 2.5s7-1.1 7-2.5"}),export:o("path",{d:"M12 3v11m0 0 4-4m-4 4-4-4M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"}),fanout:o("path",{d:"M12 5a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm-7 16a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm14 0a2 2 0 1 0 0-4 2 2 0 0 0 0 4ZM12 7v3.5M12 10.5 6 17m6-6.5 6 6.5"}),files:o("path",{d:"M4 7a2 2 0 0 1 2-2h3l2 2.5h7a2 2 0 0 1 2 2V18a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7Z"}),flags:o("path",{d:"M6 21V4m0 0h11l-2 3 2 3H6"}),functions:o("path",{d:"m9 8-4 4 4 4m6-8 4 4-4 4"}),evals:o("path",{d:"M4 19V5m0 14h16M8 15l3-4 3 3 4-6M8 15v.01"}),health:o("path",{d:"M3 12h4l2 6 4-14 2 8h6"}),home:o("path",{d:"M3 11.5 12 4l9 7.5M5 10v9a1 1 0 0 0 1 1h4v-6h4v6h4a1 1 0 0 0 1-1v-9"}),insights:o("path",{d:"M12 3a6 6 0 0 0-3.6 10.8c.5.4.8.9.9 1.5l.2 1.2h5l.2-1.2c.1-.6.4-1.1.9-1.5A6 6 0 0 0 12 3ZM9.5 20.5h5M10 18h4"}),issues:o("path",{d:"M10.3 4.3 2.5 18a2 2 0 0 0 1.7 3h15.6a2 2 0 0 0 1.7-3L13.7 4.3a2 2 0 0 0-3.4 0ZM12 9v4m0 3v.01"}),kv:o("path",{d:"M5 5h14v4H5V5Zm0 5h14v4H5v-4Zm0 5h14v4H5v-4Z"}),logs:o("path",{d:"M5 6h14M5 10h14M5 14h9M5 18h11"}),mail:o("path",{d:"M4 5h16v14H4V5Zm0 1.5 8 6 8-6"}),payments:o("path",{d:"M3 7h18v10H3V7Zm0 3h18M7 14h4"}),metrics:o("path",{d:"M5 20V10m6.5 10V4M18 20v-7M3 20h18"}),migrations:o("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"}),notifications:o("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"}),organizations:o("path",{d:"M3 21V8l6-4 6 4v13M9 21v-5h2v5M15 11h6v10M18 14v.01M18 17v.01M6 9v.01M6 12v.01M6 15v.01"}),permissions:o("path",{d:"M12 3 5 6v5c0 4.5 3 7.8 7 9 4-1.2 7-4.5 7-9V6l-7-3Zm-3 8 2.2 2.2L15 9.5M8.5 16h7"}),pitr:o("path",{d:"M12 21a9 9 0 1 0-9-9M12 7.5V12l3 2M3 12l-2-2m2 2 2-2"}),queues:o("path",{d:"M4 6h16M4 10h16M4 14h10M4 18h10m4-2 3 2-3 2v-4Z"}),realtime:o("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"}),rls:o("path",{d:"M12 3 5 6v5c0 4.5 3 7.8 7 9 4-1.2 7-4.5 7-9V6l-7-3ZM8.5 10h7M8.5 13h7"}),schedule:o("path",{d:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18Zm0-13.5V12l4 2"}),schema:o("path",{d:"M4 5h16v14H4V5Zm0 5h16M10 10v9M4 14.5h16"}),sql:o("path",{d:"M4 5h16v14H4V5Zm3 4 3 3-3 3m6 0h4"}),storageRules:o("path",{d:"M7 10V7a5 5 0 0 1 10 0v3m-11 0h12a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-8a1 1 0 0 1 1-1Zm6 4v2"}),advisorHealth:o("path",{d:"M3 12h4l2-5 3 10 2-5h5"}),security:o("path",{d:"M12 3 5 6v5c0 4.5 3 7.8 7 9 4-1.2 7-4.5 7-9V6l-7-3Zm-2.5 8.5 2 2 4-4"}),traces:o("path",{d:"M3 6h9M6 12h12M10 18h7"}),settings:o("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Zm7.4-3a7.4 7.4 0 0 0-.1-1.2l2-1.6-2-3.4-2.4 1a7.3 7.3 0 0 0-2-1.2l-.4-2.6H10.5l-.4 2.6a7.3 7.3 0 0 0-2 1.2l-2.4-1-2 3.4 2 1.6a7.4 7.4 0 0 0 0 2.4l-2 1.6 2 3.4 2.4-1a7.3 7.3 0 0 0 2 1.2l.4 2.6h3.6l.4-2.6a7.3 7.3 0 0 0 2-1.2l2.4 1 2-3.4-2-1.6a7.4 7.4 0 0 0 .1-1.2Z"}),users:o("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85M16 3.13A4 4 0 0 1 16 11"}),vectors:o("path",{d:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"}),workflows:o("path",{d:"M5 5h5v5H5V5Zm9 9h5v5h-5v-5ZM7.5 10v2a2 2 0 0 0 2 2H14m2.5-4V8a2 2 0 0 0-2-2H10"})},Tt=[{key:"overview",tabs:["home","dashboards"]},{key:"database",tabs:["data","sql","schema","migrations","vectors","pitr","export"]},{key:"functions",tabs:["functions","api","workflows","agents","queues"]},{key:"auth",tabs:["users","organizations","authSessions","authAudit","authConfig"]},{key:"storage",tabs:["files","storageRules","kv"]},{key:"observability",tabs:["issues","logs","traces","evals","audit","realtime","fanout","containers","metrics","analytics","health","deploymentHealth"]},{key:"advisors",tabs:["advisorHealth","security","rls","permissions","insights"]},{key:"operations",tabs:["schedule","mail","drains","notifications","payments","flags"]},{key:"settings",tabs:["settings"]}],No={analytics:"analytics",authAudit:"auth",authConfig:"auth",authSessions:"auth",containers:"containers",files:"storage",flags:"flags",kv:"kv",mail:"mail",notifications:"notifications",organizations:"auth",payments:"payments",queues:"queues",schedule:"scheduler",storageRules:"storage",users:"auth",vectors:"vectors",workflows:"workflows"},Lt=(t,e)=>{const s=No[t];return s===void 0||e[s]},kt=t=>{const e=k(2),{tab:s}=t,a=ko[s];let n;return e[0]!==a?(n=o("svg",{"aria-hidden":"true",className:"size-4 shrink-0",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:a}),e[0]=a,e[1]=n):n=e[1],n},Mo=t=>t,Yt=Mo(["home","data","sql","functions","api","workflows","agents","queues","containers","schema","migrations","vectors","export","pitr","users","organizations","authSessions","authAudit","authConfig","files","storageRules","kv","dashboards","metrics","analytics","health","deploymentHealth","advisorHealth","security","rls","permissions","insights","issues","logs","traces","evals","realtime","fanout","mail","notifications","payments","audit","schedule","drains","flags","settings"]),So=new Set(["api","data","migrations","sql"]),Co=t=>{const e=t.split("/").findLast(Boolean)??"";return Yt.includes(e)?e:"home"},Po=t=>{const e=k(19),{chrome:s,connected:a}=t,n=ee();let r;e[0]!==n?(r=n("admin token"),e[0]=n,e[1]=r):r=e[1];let l;e[2]!==r?(l=o("label",{className:"text-xs font-medium text-foreground",htmlFor:"dash-app-token",children:r}),e[2]=r,e[3]=l):l=e[3];let i;e[4]!==s.onTokenChange||e[5]!==s.token?(i=o($t,{className:"h-8","data-testid":"dash-app-token",id:"dash-app-token",onChange:s.onTokenChange,placeholder:"LUNORA_ADMIN_TOKEN",type:"password",value:s.token}),e[4]=s.onTokenChange,e[5]=s.token,e[6]=i):i=e[6];let d;e[7]!==a||e[8]!==n?(d=a&&w("p",{className:"flex items-start gap-1.5 text-[11px] text-muted-foreground","data-testid":"dash-app-token-warning",role:"note",children:[o("span",{"aria-hidden":"true",className:"text-warning",children:"⚠"}),n("Token rides the WebSocket URL — it can surface in browser DevTools and server logs. Use a dev-only token.")]}),e[7]=a,e[8]=n,e[9]=d):d=e[9];let u;e[10]!==s.clearToken||e[11]!==a||e[12]!==n?(u=a&&o("button",{className:"self-start rounded-md border border-border px-2.5 py-1 text-xs font-medium outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"dash-app-clear-token",onClick:s.clearToken,type:"button",children:n("Clear")}),e[10]=s.clearToken,e[11]=a,e[12]=n,e[13]=u):u=e[13];let c;return e[14]!==l||e[15]!==i||e[16]!==d||e[17]!==u?(c=w("div",{className:"flex flex-col gap-2",children:[l,i,d,u]}),e[14]=l,e[15]=i,e[16]=d,e[17]=u,e[18]=c):c=e[18],c},_o=t=>{const e=k(25),{current:s,group:a,groupLabel:n,selectTab:r,tabDescription:l,tabLabel:i}=t,d=a.tabs.includes(s)?"page":void 0,u=n[a.key],c=a.tabs[0];let f;e[0]!==c?(f=o(kt,{tab:c}),e[0]=c,e[1]=f):f=e[1];let p;e[2]!==d||e[3]!==u||e[4]!==f?(p=o(jt,{"aria-current":d,"aria-label":u,className:"mx-auto flex size-8 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent data-[popup-open]:bg-sidebar-accent data-[popup-open]:text-sidebar-accent-foreground data-[popup-open]:shadow-xs aria-[current=page]:bg-sidebar-accent aria-[current=page]:text-sidebar-accent-foreground aria-[current=page]:shadow-xs",delay:120,openOnHover:!0,children:f}),e[2]=d,e[3]=u,e[4]=f,e[5]=p):p=e[5];const m=n[a.key];let h;e[6]!==m?(h=o("div",{className:"px-2 py-1.5 text-[11px] font-medium tracking-wider text-muted-foreground uppercase",children:m}),e[6]=m,e[7]=h):h=e[7];let b;if(e[8]!==s||e[9]!==a.tabs||e[10]!==r||e[11]!==l||e[12]!==i){let x;e[14]!==s||e[15]!==r||e[16]!==l||e[17]!==i?(x=y=>w("button",{"aria-current":s===y?"page":void 0,className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent aria-[current=page]:bg-accent aria-[current=page]:font-medium [&_svg]:opacity-70 aria-[current=page]:[&_svg]:opacity-100","data-tab":y,"data-testid":`dash-tab-${y}`,onClick:r,title:l[y],type:"button",children:[o(kt,{tab:y}),o("span",{children:i[y]})]},y),e[14]=s,e[15]=r,e[16]=l,e[17]=i,e[18]=x):x=e[18],b=a.tabs.map(x),e[8]=s,e[9]=a.tabs,e[10]=r,e[11]=l,e[12]=i,e[13]=b}else b=e[13];let v;e[19]!==h||e[20]!==b?(v=w(Ut,{align:"start",className:"w-56 p-1",side:"right",sideOffset:8,children:[h,b]}),e[19]=h,e[20]=b,e[21]=v):v=e[21];let g;return e[22]!==p||e[23]!==v?(g=w(Wt,{children:[p,v]}),e[22]=p,e[23]=v,e[24]=g):g=e[24],g},To=t=>{const e=k(45),{chrome:s,collapsed:a,connected:n}=t,r=ee();if(s===null){let y;e[0]!==r?(y=r("Admin"),e[0]=r,e[1]=y):y=e[1];let M;e[2]===Symbol.for("react.memo_cache_sentinel")?(M=o("span",{className:"flex size-8 items-center justify-center rounded-full bg-sidebar-accent text-[11px] font-medium",children:"C"}),e[2]=M):M=e[2];let S;e[3]!==r?(S=r("Admin"),e[3]=r,e[4]=S):S=e[4];let P;e[5]!==S?(P=o("span",{className:"truncate text-[13px] font-medium",children:S}),e[5]=S,e[6]=P):P=e[6];let N;e[7]!==r?(N=r("Studio"),e[7]=r,e[8]=N):N=e[8];let T;e[9]!==N?(T=o("span",{className:"truncate text-[11px] text-muted-foreground",children:N}),e[9]=N,e[10]=T):T=e[10];let _;e[11]!==P||e[12]!==T?(_=w("span",{className:"grid flex-1 text-start leading-tight",children:[P,T]}),e[11]=P,e[12]=T,e[13]=_):_=e[13];let C;return e[14]!==y||e[15]!==_?(C=w(Gt,{className:"data-active:bg-transparent",size:"lg",tooltip:y,children:[M,_]}),e[14]=y,e[15]=_,e[16]=C):C=e[16],C}const l=a?"mx-auto size-8 justify-center":"w-full p-2";let i;e[17]!==l?(i=L("flex items-center gap-2 rounded-md text-start outline-none transition-colors hover:bg-sidebar-accent focus-visible:bg-sidebar-accent",l),e[17]=l,e[18]=i):i=e[18];let d;e[19]!==n||e[20]!==r?(d=r(n?"Connected":"Not connected"),e[19]=n,e[20]=r,e[21]=d):d=e[21];const u=n?"bg-success":"bg-muted-foreground/50";let c;e[22]!==u?(c=L("absolute -end-0.5 -bottom-0.5 size-2.5 rounded-full border-2 border-sidebar",u),e[22]=u,e[23]=c):c=e[23];let f;e[24]!==c?(f=w("span",{className:"relative flex size-8 shrink-0 items-center justify-center rounded-full bg-sidebar-accent text-[11px] font-medium",children:["C",o("span",{"aria-hidden":"true",className:c})]}),e[24]=c,e[25]=f):f=e[25];let p;e[26]!==a||e[27]!==n||e[28]!==r?(p=!a&&w(Rt,{children:[w("span",{className:"grid flex-1 text-start leading-tight",children:[o("span",{className:"truncate text-[13px] font-medium",children:r("Admin")}),o("span",{className:"truncate text-[11px] text-muted-foreground",children:r(n?"Connected":"Not connected")})]}),o("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:1.7,viewBox:"0 0 24 24",children:o("path",{d:"m8 9 4-4 4 4M8 15l4 4 4-4",strokeLinecap:"round",strokeLinejoin:"round"})})]}),e[26]=a,e[27]=n,e[28]=r,e[29]=p):p=e[29];let m;e[30]!==i||e[31]!==d||e[32]!==f||e[33]!==p?(m=w(jt,{className:i,"data-testid":"dash-app-connect",title:d,children:[f,p]}),e[30]=i,e[31]=d,e[32]=f,e[33]=p,e[34]=m):m=e[34];const h=a?"end":"start",b=a?"right":"top";let v;e[35]!==s||e[36]!==n?(v=o(Po,{chrome:s,connected:n}),e[35]=s,e[36]=n,e[37]=v):v=e[37];let g;e[38]!==b||e[39]!==v||e[40]!==h?(g=o(Ut,{align:h,keepMounted:!0,side:b,children:v}),e[38]=b,e[39]=v,e[40]=h,e[41]=g):g=e[41];let x;return e[42]!==g||e[43]!==m?(x=w(Wt,{children:[m,g]}),e[42]=g,e[43]=m,e[44]=x):x=e[44],x},Lo=t=>{const e=k(28),{chrome:s,connected:a,current:n,groupLabel:r,groups:l,selectTab:i,tabDescription:d,tabLabel:u}=t,c=ee(),{state:f}=ht(),p=f==="collapsed",m=p&&"justify-center px-0";let h;e[0]!==m?(h=L("flex items-center gap-2.5 px-1.5 py-1",m),e[0]=m,e[1]=h):h=e[1];let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=o(Hs,{className:"size-9 shrink-0 text-foreground"}),e[2]=b):b=e[2];let v;e[3]!==p||e[4]!==a||e[5]!==c?(v=!p&&w(Rt,{children:[w("span",{className:"grid flex-1 leading-tight",children:[o("span",{className:"truncate text-sm font-semibold text-foreground",children:"lunora"}),o("span",{className:"truncate text-[11px] text-muted-foreground",children:c("Studio")})]}),o(dt,{className:"px-1.5 text-[10px] tracking-wider uppercase",variant:"secondary",children:c(a?"Live":"Local")})]}),e[3]=p,e[4]=a,e[5]=c,e[6]=v):v=e[6];let g;e[7]!==h||e[8]!==v?(g=o(na,{children:w("div",{className:h,children:[b,v]})}),e[7]=h,e[8]=v,e[9]=g):g=e[9];let x;e[10]!==p||e[11]!==n||e[12]!==r||e[13]!==l||e[14]!==i||e[15]!==d||e[16]!==u?(x=p?l.map(P=>o(_o,{current:n,group:P,groupLabel:r,selectTab:i,tabDescription:d,tabLabel:u},P.key)):l.map(P=>w(ia,{children:[o(da,{className:"text-[11px] font-medium tracking-wider uppercase",children:r[P.key]}),o(ca,{children:o(Pt,{children:P.tabs.map(N=>o(_t,{children:w(Gt,{className:"data-active:text-foreground dark:data-active:text-royal-amethyst data-active:shadow-[inset_2px_0_0_0_var(--royal-amethyst)]","data-tab":N,"data-testid":`dash-tab-${N}`,isActive:n===N,onClick:i,title:d[N],tooltip:d[N],children:[o(kt,{tab:N}),o("span",{children:u[N]})]})},N))})})]},P.key)),e[10]=p,e[11]=n,e[12]=r,e[13]=l,e[14]=i,e[15]=d,e[16]=u,e[17]=x):x=e[17];let y;e[18]!==x?(y=o(la,{children:x}),e[18]=x,e[19]=y):y=e[19];let M;e[20]!==s||e[21]!==p||e[22]!==a?(M=o(ra,{children:o(Pt,{children:o(_t,{children:o(To,{chrome:s,collapsed:p,connected:a})})})}),e[20]=s,e[21]=p,e[22]=a,e[23]=M):M=e[23];let S;return e[24]!==g||e[25]!==y||e[26]!==M?(S=w(sa,{collapsible:"icon",variant:"inset",children:[g,y,M]}),e[24]=g,e[25]=y,e[26]=M,e[27]=S):S=e[27],S},Jt=()=>{const t=k(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=w("div",{className:"flex flex-col gap-4","data-testid":"dash-pending",children:[w("div",{className:"flex items-center gap-2",children:[o(vt,{className:"h-8 w-40"}),o(vt,{className:"h-8 w-24"})]}),o(vt,{className:"h-72 w-full"})]}),t[0]=e):e=t[0],e},Ao=()=>{const t=k(64),e=ee(),s=At();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a={select:Bo},t[0]=a):a=t[0];const n=ns(a);let r,l;t[1]!==n?(r=Co(n),l=So.has(r),t[1]=n,t[2]=r,t[3]=l):(r=t[2],l=t[3]);const i=l,d=us(),u=d?.toggle;Ca(u);const c=gs(),{groupLabel:f,tabDescription:p,tabLabel:m}=xa();let h;t[4]!==c?(h=Z=>({...Z,tabs:Z.tabs.filter(te=>Lt(te,c))}),t[4]=c,t[5]=h):h=t[5];const b=Tt.map(h).filter(zo);let v,g;t[6]!==r||t[7]!==c||t[8]!==s?(v=()=>{Lt(r,c)||wt(s({replace:!0,to:"/home"}))},g=[r,c,s],t[6]=r,t[7]=c,t[8]=s,t[9]=v,t[10]=g):(v=t[9],g=t[10]),rt(v,g);let x;t[11]!==s?(x=Z=>{wt(s({to:`/${Z.currentTarget.dataset.tab??""}`}))},t[11]=s,t[12]=x):x=t[12];const y=x;let M,S;t[13]!==r||t[14]!==m?(M=()=>{typeof document<"u"&&(document.title=`${m[r]} · lunora`)},S=[r,m],t[13]=r,t[14]=m,t[15]=M,t[16]=S):(M=t[15],S=t[16]),rt(M,S);const P=b.find(Z=>Z.tabs.includes(r))??Tt[0];let N;t[17]!==f||t[18]!==m?(N=Z=>Z.tabs.map(te=>({group:f[Z.key],label:m[te],to:`/${te}`})),t[17]=f,t[18]=m,t[19]=N):N=t[19];const T=b.flatMap(N),_=u===void 0?T:[...T,{group:e("Operations"),label:e("Toggle operation console"),run:u}],C=Nt(Qt),E=C!==null&&C.token!=="";let I;t[20]!==_?(I=o(ws,{items:_}),t[20]=_,t[21]=I):I=t[21];let H;t[22]!==C||t[23]!==E||t[24]!==r||t[25]!==f||t[26]!==y||t[27]!==p||t[28]!==m||t[29]!==b?(H=o(Lo,{chrome:C,connected:E,current:r,groupLabel:f,groups:b,selectTab:y,tabDescription:p,tabLabel:m}),t[22]=C,t[23]=E,t[24]=r,t[25]=f,t[26]=y,t[27]=p,t[28]=m,t[29]=b,t[30]=H):H=t[30];const V=f[P.key],O=m[r];let B;t[31]!==V||t[32]!==O?(B=o(Sa,{domain:V,onOpenCommandPalette:ks,page:O}),t[31]=V,t[32]=O,t[33]=B):B=t[33];let z;t[34]!==C?.rulesInstalled?(z=C?.rulesInstalled===!1&&o(Vs,{}),t[34]=C?.rulesInstalled,t[35]=z):z=t[35];const D=`dash-tab-${r}`,F=i?"flex min-w-0 flex-1 flex-col overflow-hidden":"min-w-0 flex-1 overflow-auto p-6",$=m[r];let q;t[36]!==e||t[37]!==$?(q=e("{title} failed",{title:$}),t[36]=e,t[37]=$,t[38]=q):q=t[38];const X=m[r];let W;t[39]!==e?(W=e("Try again"),t[39]=e,t[40]=W):W=t[40];let Y;t[41]===Symbol.for("react.memo_cache_sentinel")?(Y=o(is,{fallback:o(Jt,{}),children:o(rs,{})}),t[41]=Y):Y=t[41];let j;t[42]!==r||t[43]!==q||t[44]!==X||t[45]!==W?(j=o(ds,{fallbackTitle:q,label:X,retryLabel:W,children:Y},r),t[42]=r,t[43]=q,t[44]=X,t[45]=W,t[46]=j):j=t[46];let U;t[47]!==F||t[48]!==j?(U=o("div",{className:F,children:j}),t[47]=F,t[48]=j,t[49]=U):U=t[49];let K;t[50]!==d?(K=d?.open===!0&&o(ga,{focusSeq:d.focusSeq,onClose:d.close,onShownChange:d.setShown,shown:d.shown}),t[50]=d,t[51]=K):K=t[51];let G;t[52]!==D||t[53]!==U||t[54]!==K?(G=w("div",{"aria-labelledby":D,className:"flex min-w-0 flex-1 flex-col overflow-hidden","data-testid":"dash-panel",id:"dash-panel",role:"tabpanel",children:[U,K]}),t[52]=D,t[53]=U,t[54]=K,t[55]=G):G=t[55];let Q;t[56]!==B||t[57]!==z||t[58]!==G?(Q=w(oa,{className:"overflow-hidden md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm",children:[B,z,G]}),t[56]=B,t[57]=z,t[58]=G,t[59]=Q):Q=t[59];let J;return t[60]!==H||t[61]!==Q||t[62]!==I?(J=w(ta,{className:"min-h-0 flex-1","data-testid":"lunora-studio",children:[I,H,Q]}),t[60]=H,t[61]=Q,t[62]=I,t[63]=J):J=t[63],J},Eo=()=>{const t=k(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o(cs,{children:o(Ao,{})}),t[0]=e):e=t[0],e},Ro=t=>{const e=k(5),{initialShardKey:s,schemaEditable:a}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},e[0]=n):n=e[0];const r=as(n),{table:l}=r,i=typeof l=="string"?l:void 0;let d;return e[1]!==s||e[2]!==i||e[3]!==a?(d=o(fo,{initialShardKey:s,initialTable:i,schemaEditable:a}),e[1]=s,e[2]=i,e[3]=a,e[4]=d):d=e[4],d},Io=()=>{const t=k(3),e=At();let s,a;return t[0]!==e?(s=()=>{wt(e({replace:!0,to:"/home"}))},a=[e],t[0]=e,t[1]=s,t[2]=a):(s=t[1],a=t[2]),rt(s,a),null},$o=({basePath:t,dataEditable:e=!1,functions:s,initialShardKey:a,openApiSpec:n,openRpcSpec:r,runAsIdentity:l=!1,schemaEditable:i=!1,scheduledCancel:d,scheduledCron:u,scheduledLoad:c})=>{const f=Xt({component:Eo}),p={agents:o(Aa,{initialShardKey:a}),analytics:o(Ea,{}),api:o(Ra,{functions:s,initialShardKey:a,openApiSpec:n,openRpcSpec:r}),audit:o(Qa,{initialShardKey:a}),authAudit:o(Ia,{}),authConfig:o($a,{}),authSessions:o(Ha,{}),containers:o(Va,{}),dashboards:o(io,{initialShardKey:a}),data:o(Da,{editable:e,initialShardKey:a}),deploymentHealth:o(Oa,{}),drains:o(Ya,{}),export:o(Za,{initialShardKey:a}),fanout:o(co,{initialShardKey:a}),files:o(go,{}),kv:o(ao,{}),flags:o(ja,{initialShardKey:a}),functions:w("div",{className:"flex flex-col gap-8",children:[o(Ka,{functions:s,initialShardKey:a}),o(Ua,{functions:s,runAsIdentity:l})]}),health:o(uo,{initialShardKey:a}),home:o(ps,{initialShardKey:a}),insights:o(Pa,{initialShardKey:a}),issues:o(Ga,{initialShardKey:a}),logs:o(Ja,{initialShardKey:a}),traces:o(vo,{initialShardKey:a}),evals:o(xo,{initialShardKey:a}),metrics:o(mo,{initialShardKey:a}),migrations:o(Fa,{initialShardKey:a}),notifications:o(oo,{}),organizations:o(Ba,{}),permissions:o(ro,{functions:s,runAsIdentity:l,schemaEditable:i}),pitr:o(Wa,{initialShardKey:a}),mail:o(Xa,{}),payments:o(no,{}),queues:o(lo,{}),realtime:w("div",{className:"flex flex-col gap-8",children:[o(to,{initialShardKey:a}),o(so,{})]}),rls:o(_a,{}),schedule:o(eo,{loadCronJobs:u,scheduledCancel:d,scheduledLoad:c}),schema:o(Ro,{initialShardKey:a,schemaEditable:i}),advisorHealth:o(Ta,{}),security:o(La,{}),settings:o(ho,{initialShardKey:a}),sql:o(po,{initialShardKey:a}),storageRules:o(bo,{}),users:o(za,{}),vectors:o(yo,{}),workflows:o(wo,{})},m=St({component:()=>p.home,getParentRoute:()=>f,path:"/"}),h=Yt.map(g=>St({component:()=>p[g],getParentRoute:()=>f,path:`/${g}`,validateSearch:qa[g]})),b=f.addChildren([m,...h]),v="window"in globalThis?es():ts({initialEntries:["/home"]});return ss({...t===void 0||t==="/"?{}:{basepath:t},defaultNotFoundComponent:Io,defaultPendingComponent:Jt,defaultPendingMinMs:0,defaultPendingMs:0,history:v,routeTree:b})},Ho=t=>{const e=k(17),{basePath:s,chrome:a,dataEditable:n,functions:r,initialShardKey:l,openApiSpec:i,openRpcSpec:d,runAsIdentity:u,schemaEditable:c,scheduledCancel:f,scheduledCron:p,scheduledLoad:m}=t;let h;e[0]!==s||e[1]!==n||e[2]!==r||e[3]!==l||e[4]!==i||e[5]!==d||e[6]!==u||e[7]!==f||e[8]!==p||e[9]!==m||e[10]!==c?(h=$o({basePath:s,dataEditable:n,functions:r,initialShardKey:l,openApiSpec:i,openRpcSpec:d,runAsIdentity:u,schemaEditable:c,scheduledCancel:f,scheduledCron:p,scheduledLoad:m}),e[0]=s,e[1]=n,e[2]=r,e[3]=l,e[4]=i,e[5]=d,e[6]=u,e[7]=f,e[8]=p,e[9]=m,e[10]=c,e[11]=h):h=e[11];const b=h,v=a??null;let g;e[12]!==b?(g=o(os,{router:b}),e[12]=b,e[13]=g):g=e[13];let x;return e[14]!==v||e[15]!==g?(x=o(Qt,{value:v,children:g}),e[14]=v,e[15]=g,e[16]=x):x=e[16],x},gn=t=>{const e=k(17),{basePath:s,chrome:a,dataEditable:n,functions:r,i18n:l,initialShardKey:i,locale:d,openApiSpec:u,openRpcSpec:c,runAsIdentity:f,schemaEditable:p,scheduledCancel:m,scheduledCron:h,scheduledLoad:b}=t;let v;e[0]!==s||e[1]!==a||e[2]!==n||e[3]!==r||e[4]!==i||e[5]!==u||e[6]!==c||e[7]!==f||e[8]!==m||e[9]!==h||e[10]!==b||e[11]!==p?(v=o(As,{children:o(Ho,{basePath:s,chrome:a,dataEditable:n,functions:r,initialShardKey:i,openApiSpec:u,openRpcSpec:c,runAsIdentity:f,scheduledCancel:m,scheduledCron:h,scheduledLoad:b,schemaEditable:p})}),e[0]=s,e[1]=a,e[2]=n,e[3]=r,e[4]=i,e[5]=u,e[6]=c,e[7]=f,e[8]=m,e[9]=h,e[10]=b,e[11]=p,e[12]=v):v=e[12];const g=v;if(l===void 0&&d===void 0)return g;let x;return e[13]!==l||e[14]!==d||e[15]!==g?(x=o(vs,{i18n:l,locale:d,children:g}),e[13]=l,e[14]=d,e[15]=g,e[16]=x):x=e[16],x};function Bo(t){return t.location.pathname}function zo(t){return t.tabs.length>0}export{Hs as B,gn as S,Ls as T,pn as a,Zs as b,Ws as c,js as d,Us as e,Es as u};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{c as p}from"./chunk-VYW2PAWC.js";import{a,d as R,e as H,f as mt,g as Ue}from"./chunk-R5ZTCHCE.js";var L=class{static{a(this,"Subscribable")}constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var vr=class extends L{static{a(this,"FocusManager")}#e;#t;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=a(()=>t(),"listener");return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#r=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){let t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},X=new vr;var gr={setTimeout:a((t,e)=>setTimeout(t,e),"setTimeout"),clearTimeout:a(t=>clearTimeout(t),"clearTimeout"),setInterval:a((t,e)=>setInterval(t,e),"setInterval"),clearInterval:a(t=>clearInterval(t),"clearInterval")},Sr=class{static{a(this,"TimeoutManager")}#e=gr;#t=!1;setTimeoutProvider(t){this.#e=t}setTimeout(t,e){return this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},Q=new Sr;function yt(t){setTimeout(t,0)}a(yt,"systemSetTimeoutZero");var Ne=typeof window>"u"||"Deno"in globalThis;function g(){}a(g,"noop");function gt(t,e){return typeof t=="function"?t(e):t}a(gt,"functionalUpdate");function ie(t){return typeof t=="number"&&t>=0&&t!==1/0}a(ie,"isValidTimeout");function me(t,e){return Math.max(t+(e||0)-Date.now(),0)}a(me,"timeUntilStale");function x(t,e){return typeof t=="function"?t(e):t}a(x,"resolveStaleTime");function I(t,e){return typeof t=="function"?t(e):t}a(I,"resolveQueryBoolean");function ye(t,e){let{type:r="all",exact:s,fetchStatus:i,predicate:n,queryKey:o,stale:c}=t;if(o){if(s){if(e.queryHash!==ne(o,e.options))return!1}else if(!N(e.queryKey,o))return!1}if(r!=="all"){let u=e.isActive();if(r==="active"&&!u||r==="inactive"&&u)return!1}return!(typeof c=="boolean"&&e.isStale()!==c||i&&i!==e.state.fetchStatus||n&&!n(e))}a(ye,"matchQuery");function be(t,e){let{exact:r,status:s,predicate:i,mutationKey:n}=t;if(n){if(!e.options.mutationKey)return!1;if(r){if(z(e.options.mutationKey)!==z(n))return!1}else if(!N(e.options.mutationKey,n))return!1}return!(s&&e.state.status!==s||i&&!i(e))}a(be,"matchMutation");function ne(t,e){return(e?.queryKeyHashFn||z)(t)}a(ne,"hashQueryKeyByOptions");function z(t){return JSON.stringify(t,(e,r)=>qe(r)?Object.keys(r).sort().reduce((s,i)=>(s[i]=r[i],s),{}):r)}a(z,"hashKey");function N(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(Array.isArray(t)&&Array.isArray(e)){for(let s=0;s<e.length;s++)if(!N(t[s],e[s]))return!1;return!0}let r=Object.keys(e);for(let s of r)if(!N(t[s],e[s]))return!1;return!0}return!1}a(N,"partialMatchKey");var wr=Object.prototype.hasOwnProperty;function Ke(t,e,r=0){if(t===e)return t;if(r>500)return e;let s=bt(t)&&bt(e);if(!s&&!(qe(t)&&qe(e)))return e;let n=(s?t:Object.keys(t)).length,o=s?e:Object.keys(e),c=o.length,u=s?new Array(c):{},h=0;for(let d=0;d<c;d++){let l=s?d:o[d],f=t[l],m=e[l];if(f===m){u[l]=f,(s?d<n:wr.call(t,l))&&h++;continue}if(f===null||m===null||typeof f!="object"||typeof m!="object"){u[l]=m;continue}let y=Ke(f,m,r+1);u[l]=y,y===f&&h++}return n===c&&h===n?t:u}a(Ke,"replaceEqualDeep");function ve(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(let r in t)if(t[r]!==e[r])return!1;return!0}a(ve,"shallowEqualObjects");function bt(t){return Array.isArray(t)&&t.length===Object.keys(t).length}a(bt,"isPlainArray");function qe(t){if(!vt(t))return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(!vt(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}a(qe,"isPlainObject");function vt(t){return Object.prototype.toString.call(t)==="[object Object]"}a(vt,"hasObjectPrototype");function St(t){return new Promise(e=>{Q.setTimeout(e,t)})}a(St,"sleep");function ae(t,e,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,e):r.structuralSharing!==!1?Ke(t,e):e}a(ae,"replaceData");function Cr(t){return t}a(Cr,"keepPreviousData");function wt(t,e,r=0){let s=[...t,e];return r&&s.length>r?s.slice(1):s}a(wt,"addToEnd");function Ct(t,e,r=0){let s=[e,...t];return r&&s.length>r?s.slice(0,-1):s}a(Ct,"addToStart");var Y=Symbol();function ge(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===Y?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}a(ge,"ensureQueryFn");function Se(t,e){return typeof t=="function"?t(...e):!!t}a(Se,"shouldThrowError");function kt(t,e,r){let s=!1,i;return Object.defineProperty(t,"signal",{enumerable:!0,get:a(()=>(i??=e(),s||(s=!0,i.aborted?r():i.addEventListener("abort",r,{once:!0})),i),"get")}),t}a(kt,"addConsumeAwareSignal");var D=(()=>{let t=a(()=>Ne,"isServerFn");return{isServer(){return t()},setIsServer(e){t=e}}})();function oe(){let t,e,r=new Promise((i,n)=>{t=i,e=n});r.status="pending",r.catch(()=>{});function s(i){Object.assign(r,i),delete r.resolve,delete r.reject}return a(s,"finalize"),r.resolve=i=>{s({status:"fulfilled",value:i}),t(i)},r.reject=i=>{s({status:"rejected",reason:i}),e(i)},r}a(oe,"pendingThenable");var It=yt;function kr(){let t=[],e=0,r=a(c=>{c()},"notifyFn"),s=a(c=>{c()},"batchNotifyFn"),i=It,n=a(c=>{e?t.push(c):i(()=>{r(c)})},"schedule"),o=a(()=>{let c=t;t=[],c.length&&i(()=>{s(()=>{c.forEach(u=>{r(u)})})})},"flush");return{batch:a(c=>{let u;e++;try{u=c()}finally{e--,e||o()}return u},"batch"),batchCalls:a(c=>(...u)=>{n(()=>{c(...u)})},"batchCalls"),schedule:n,setNotifyFunction:a(c=>{r=c},"setNotifyFunction"),setBatchNotifyFunction:a(c=>{s=c},"setBatchNotifyFunction"),setScheduler:a(c=>{i=c},"setScheduler")}}a(kr,"createNotifyManager");var v=kr();var Ir=class extends L{static{a(this,"OnlineManager")}#e=!0;#t;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=a(()=>t(!0),"onlineListener"),r=a(()=>t(!1),"offlineListener");return window.addEventListener("online",e,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#r=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(r=>{r(t)}))}isOnline(){return this.#e}},Z=new Ir;function Er(t){return Math.min(1e3*2**t,3e4)}a(Er,"defaultRetryDelay");function Be(t){return(t??"online")==="online"?Z.isOnline():!0}a(Be,"canFetch");var we=class extends Error{static{a(this,"CancelledError")}constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Ce(t){let e=!1,r=0,s,i=oe(),n=a(()=>i.status!=="pending","isResolved"),o=a(b=>{if(!n()){let w=new we(b);f(w),t.onCancel?.(w)}},"cancel"),c=a(()=>{e=!0},"cancelRetry"),u=a(()=>{e=!1},"continueRetry"),h=a(()=>X.isFocused()&&(t.networkMode==="always"||Z.isOnline())&&t.canRun(),"canContinue"),d=a(()=>Be(t.networkMode)&&t.canRun(),"canStart"),l=a(b=>{n()||(s?.(),i.resolve(b))},"resolve"),f=a(b=>{n()||(s?.(),i.reject(b))},"reject"),m=a(()=>new Promise(b=>{s=a(w=>{(n()||h())&&b(w)},"continueFn"),t.onPause?.()}).then(()=>{s=void 0,n()||t.onContinue?.()}),"pause"),y=a(()=>{if(n())return;let b,w=r===0?t.initialPromise:void 0;try{b=w??t.fn()}catch(E){b=Promise.reject(E)}Promise.resolve(b).then(l).catch(E=>{if(n())return;let M=t.retry??(D.isServer()?0:3),U=t.retryDelay??Er,j=typeof U=="function"?U(r,E):U,$=M===!0||typeof M=="number"&&r<M||typeof M=="function"&&M(r,E);if(e||!$){f(E);return}r++,t.onFail?.(r,E),St(j).then(()=>h()?void 0:m()).then(()=>{e?f(E):y()})})},"run");return{promise:i,status:a(()=>i.status,"status"),cancel:o,continue:a(()=>(s?.(),i),"continue"),cancelRetry:c,continueRetry:u,canStart:d,start:a(()=>(d()?y():m().then(y),i),"start")}}a(Ce,"createRetryer");var ke=class{static{a(this,"Removable")}#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ie(this.gcTime)&&(this.#e=Q.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(D.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(Q.clearTimeout(this.#e),this.#e=void 0)}};function Tt(t){return{onFetch:a((e,r)=>{let s=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,n=e.state.data?.pages||[],o=e.state.data?.pageParams||[],c={pages:[],pageParams:[]},u=0,h=a(async()=>{let d=!1,l=a(y=>{kt(y,()=>e.signal,()=>d=!0)},"addSignalProperty"),f=ge(e.options,e.fetchOptions),m=a(async(y,b,w)=>{if(d)return Promise.reject(e.signal.reason);if(b==null&&y.pages.length)return Promise.resolve(y);let M=a(()=>{let De={client:e.client,queryKey:e.queryKey,pageParam:b,direction:w?"backward":"forward",meta:e.options.meta};return l(De),De},"createQueryFnContext")(),U=await f(M),{maxPages:j}=e.options,$=w?Ct:wt;return{pages:$(y.pages,U,j),pageParams:$(y.pageParams,b,j)}},"fetchPage");if(i&&n.length){let y=i==="backward",b=y?Tr:Et,w={pages:n,pageParams:o},E=b(s,w);c=await m(w,E,y)}else{let y=t??n.length;do{let b=u===0?o[0]??s.initialPageParam:Et(s,c);if(u>0&&b==null)break;c=await m(c,b),u++}while(u<y)}return c},"fetchFn");e.options.persister?e.fetchFn=()=>e.options.persister?.(h,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r):e.fetchFn=h},"onFetch")}}a(Tt,"infiniteQueryBehavior");function Et(t,{pages:e,pageParams:r}){let s=e.length-1;return e.length>0?t.getNextPageParam(e[s],e,r[s],r):void 0}a(Et,"getNextPageParam");function Tr(t,{pages:e,pageParams:r}){return e.length>0?t.getPreviousPageParam?.(e[0],e,r[0],r):void 0}a(Tr,"getPreviousPageParam");var Rt=class extends ke{static{a(this,"Query")}#e;#t;#r;#s;#n;#i;#o;#a;constructor(t){super(),this.#a=!1,this.#o=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#n=t.client,this.#s=this.#n.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#t=Pt(this.options),this.state=t.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#i?.promise}setOptions(t){if(this.options={...this.#o,...t},t?._type&&(this.#e=t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Pt(this.options);e.data!==void 0&&(this.setState(Ot(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(t,e){let r=ae(this.state.data,t,this.options);return this.#c({data:r,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),r}setState(t){this.#c({type:"setState",state:t})}cancel(t){let e=this.#i?.promise;return this.#i?.cancel(t),e?e.then(g).catch(g):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>I(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Y||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>x(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!me(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#i&&(this.#a||this.#h()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}#h(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#c({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#i?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(t&&this.setOptions(t),!this.options.queryFn){let u=this.observers.find(h=>h.options.queryFn);u&&this.setOptions(u.options)}let r=new AbortController,s=a(u=>{Object.defineProperty(u,"signal",{enumerable:!0,get:a(()=>(this.#a=!0,r.signal),"get")})},"addSignalProperty"),i=a(()=>{let u=ge(this.options,e),d=a(()=>{let l={client:this.#n,queryKey:this.queryKey,meta:this.meta};return s(l),l},"createQueryFnContext")();return this.#a=!1,this.options.persister?this.options.persister(u,d,this):u(d)},"fetchFn"),o=a(()=>{let u={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#n,state:this.state,fetchFn:i};return s(u),u},"createFetchContext")();(this.#e==="infinite"?Tt(this.options.pages):this.options.behavior)?.onFetch(o,this),this.#r=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#c({type:"fetch",meta:o.fetchOptions?.meta}),this.#i=Ce({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:a(u=>{u instanceof we&&u.revert&&this.setState({...this.#r,fetchStatus:"idle"}),r.abort()},"onCancel"),onFail:a((u,h)=>{this.#c({type:"failed",failureCount:u,error:h})},"onFail"),onPause:a(()=>{this.#c({type:"pause"})},"onPause"),onContinue:a(()=>{this.#c({type:"continue"})},"onContinue"),retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:a(()=>!0,"canRun")});try{let u=await this.#i.start();if(u===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(u),this.#s.config.onSuccess?.(u,this),this.#s.config.onSettled?.(u,this.state.error,this),u}catch(u){if(u instanceof we){if(u.silent)return this.#i.promise;if(u.revert){if(this.state.data===void 0)throw u;return this.state.data}}throw this.#c({type:"error",error:u}),this.#s.config.onError?.(u,this),this.#s.config.onSettled?.(this.state.data,u,this),u}finally{this.scheduleGc()}}#c(t){let e=a(r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...je(r.data,this.options),fetchMeta:t.meta??null};case"success":let s={...r,...Ot(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#r=t.manual?s:void 0,s;case"error":let i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}},"reducer");this.state=e(this.state),v.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:t})})}};function je(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Be(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}a(je,"fetchState");function Ot(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}a(Ot,"successState");function Pt(t){let e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,s=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}a(Pt,"getDefaultState");var He=class extends L{static{a(this,"QueryObserver")}constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=oe(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#r=void 0;#s=void 0;#n;#i;#o;#a;#h;#c;#p;#d;#l;#u;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),At(this.#t,this.options)?this.#f():this.updateResult(),this.#g())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return $e(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return $e(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#w(),this.#t.removeObserver(this)}setOptions(t){let e=this.options,r=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof I(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#C(),this.#t.setOptions(this.options),e._defaulted&&!ve(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});let s=this.hasListeners();s&&Ft(this.#t,r,this.options,e)&&this.#f(),this.updateResult(),s&&(this.#t!==r||I(this.options.enabled,this.#t)!==I(e.enabled,this.#t)||x(this.options.staleTime,this.#t)!==x(e.staleTime,this.#t))&&this.#y();let i=this.#b();s&&(this.#t!==r||I(this.options.enabled,this.#t)!==I(e.enabled,this.#t)||i!==this.#u)&&this.#v(i)}getOptimisticResult(t){let e=this.#e.getQueryCache().build(this.#e,t),r=this.createResult(e,t);return Pr(this,r)&&(this.#s=r,this.#i=this.options,this.#n=this.#t.state),r}getCurrentResult(){return this.#s}trackResult(t,e){return new Proxy(t,{get:a((r,s)=>(this.trackProp(s),e?.(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s)),"get")})}trackProp(t){this.#m.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let e=this.#e.defaultQueryOptions(t),r=this.#e.getQueryCache().build(this.#e,e);return r.fetch().then(()=>this.createResult(r,e))}fetch(t){return this.#f({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#f(t){this.#C();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(g)),e}#y(){this.#S();let t=x(this.options.staleTime,this.#t);if(D.isServer()||this.#s.isStale||!ie(t))return;let r=me(this.#s.dataUpdatedAt,t)+1;this.#d=Q.setTimeout(()=>{this.#s.isStale||this.updateResult()},r)}#b(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(t){this.#w(),this.#u=t,!(D.isServer()||I(this.options.enabled,this.#t)===!1||!ie(this.#u)||this.#u===0)&&(this.#l=Q.setInterval(()=>{(this.options.refetchIntervalInBackground||X.isFocused())&&this.#f()},this.#u))}#g(){this.#y(),this.#v(this.#b())}#S(){this.#d!==void 0&&(Q.clearTimeout(this.#d),this.#d=void 0)}#w(){this.#l!==void 0&&(Q.clearInterval(this.#l),this.#l=void 0)}createResult(t,e){let r=this.#t,s=this.options,i=this.#s,n=this.#n,o=this.#i,u=t!==r?t.state:this.#r,{state:h}=t,d={...h},l=!1,f;if(e._optimisticResults){let P=this.hasListeners(),se=!P&&At(t,e),le=P&&Ft(t,r,e,s);(se||le)&&(d={...d,...je(h.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:y,status:b}=d;f=d.data;let w=!1;if(e.placeholderData!==void 0&&f===void 0&&b==="pending"){let P;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(P=i.data,w=!0):P=typeof e.placeholderData=="function"?e.placeholderData(this.#p?.state.data,this.#p):e.placeholderData,P!==void 0&&(b="success",f=ae(i?.data,P,e),l=!0)}if(e.select&&f!==void 0&&!w)if(i&&f===n?.data&&e.select===this.#h)f=this.#c;else try{this.#h=e.select,f=e.select(f),f=ae(i?.data,f,e),this.#c=f,this.#a=null}catch(P){this.#a=P}this.#a&&(m=this.#a,f=this.#c,y=Date.now(),b="error");let E=d.fetchStatus==="fetching",M=b==="pending",U=b==="error",j=M&&E,$=f!==void 0,q={status:b,fetchStatus:d.fetchStatus,isPending:M,isSuccess:b==="success",isError:U,isInitialLoading:j,isLoading:j,data:f,dataUpdatedAt:d.dataUpdatedAt,error:m,errorUpdatedAt:y,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:d.dataUpdateCount>u.dataUpdateCount||d.errorUpdateCount>u.errorUpdateCount,isFetching:E,isRefetching:E&&!M,isLoadingError:U&&!$,isPaused:d.fetchStatus==="paused",isPlaceholderData:l,isRefetchError:U&&$,isStale:ze(t,e),refetch:this.refetch,promise:this.#o,isEnabled:I(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){let P=q.data!==void 0,se=q.status==="error"&&!P,le=a(pe=>{se?pe.reject(q.error):P&&pe.resolve(q.data)},"finalizeThenableIfPossible"),pt=a(()=>{let pe=this.#o=q.promise=oe();le(pe)},"recreateThenable"),fe=this.#o;switch(fe.status){case"pending":t.queryHash===r.queryHash&&le(fe);break;case"fulfilled":(se||q.data!==fe.value)&&pt();break;case"rejected":(!se||q.error!==fe.reason)&&pt();break}}return q}updateResult(){let t=this.#s,e=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#i=this.options,this.#n.data!==void 0&&(this.#p=this.#t),ve(e,t))return;this.#s=e;let r=a(()=>{if(!t)return!0;let{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!this.#m.size)return!0;let n=new Set(i??this.#m);return this.options.throwOnError&&n.add("error"),Object.keys(this.#s).some(o=>{let c=o;return this.#s[c]!==t[c]&&n.has(c)})},"shouldNotifyListeners");this.#k({listeners:r()})}#C(){let t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;let e=this.#t;this.#t=t,this.#r=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#g()}#k(t){v.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function Or(t,e){return I(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&I(e.retryOnMount,t)===!1)}a(Or,"shouldLoadOnMount");function At(t,e){return Or(t,e)||t.state.data!==void 0&&$e(t,e,e.refetchOnMount)}a(At,"shouldFetchOnMount");function $e(t,e,r){if(I(e.enabled,t)!==!1&&x(e.staleTime,t)!=="static"){let s=typeof r=="function"?r(t):r;return s==="always"||s!==!1&&ze(t,e)}return!1}a($e,"shouldFetchOn");function Ft(t,e,r,s){return(t!==e||I(s.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&ze(t,r)}a(Ft,"shouldFetchOptionally");function ze(t,e){return I(e.enabled,t)!==!1&&t.isStaleByTime(x(e.staleTime,t))}a(ze,"isStale");function Pr(t,e){return!ve(t.getCurrentResult(),e)}a(Pr,"shouldAssignObserverCurrentProperties");var Mt=class extends ke{static{a(this,"Mutation")}#e;#t;#r;#s;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#r=t.mutationCache,this.#t=[],this.state=t.state||Rr(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#r.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#r.remove(this))}continue(){return this.#s?.continue()??this.execute(this.state.variables)}async execute(t){let e=a(()=>{this.#n({type:"continue"})},"onContinue"),r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#s=Ce({fn:a(()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),"fn"),onFail:a((n,o)=>{this.#n({type:"failed",failureCount:n,error:o})},"onFail"),onPause:a(()=>{this.#n({type:"pause"})},"onPause"),onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:a(()=>this.#r.canRun(this),"canRun")});let s=this.state.status==="pending",i=!this.#s.canStart();try{if(s)e();else{this.#n({type:"pending",variables:t,isPaused:i}),this.#r.config.onMutate&&await this.#r.config.onMutate(t,this,r);let o=await this.options.onMutate?.(t,r);o!==this.state.context&&this.#n({type:"pending",context:o,variables:t,isPaused:i})}let n=await this.#s.start();return await this.#r.config.onSuccess?.(n,t,this.state.context,this,r),await this.options.onSuccess?.(n,t,this.state.context,r),await this.#r.config.onSettled?.(n,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(n,null,t,this.state.context,r),this.#n({type:"success",data:n}),n}catch(n){try{await this.#r.config.onError?.(n,t,this.state.context,this,r)}catch(o){Promise.reject(o)}try{await this.options.onError?.(n,t,this.state.context,r)}catch(o){Promise.reject(o)}try{await this.#r.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this,r)}catch(o){Promise.reject(o)}try{await this.options.onSettled?.(void 0,n,t,this.state.context,r)}catch(o){Promise.reject(o)}throw this.#n({type:"error",error:n}),n}finally{this.#r.runNext(this)}}#n(t){let e=a(r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}},"reducer");this.state=e(this.state),v.batch(()=>{this.#t.forEach(r=>{r.onMutationUpdate(t)}),this.#r.notify({mutation:this,type:"updated",action:t})})}};function Rr(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}a(Rr,"getDefaultState");var xt=class extends L{static{a(this,"MutationCache")}constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(t,e,r){let s=new Mt({client:t,mutationCache:this,mutationId:++this.#r,options:t.defaultMutationOptions(e),state:r});return this.add(s),s}add(t){this.#e.add(t);let e=Ie(t);if(typeof e=="string"){let r=this.#t.get(e);r?r.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){let e=Ie(t);if(typeof e=="string"){let r=this.#t.get(e);if(r)if(r.length>1){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){let e=Ie(t);if(typeof e=="string"){let s=this.#t.get(e)?.find(i=>i.state.status==="pending");return!s||s===t}else return!0}runNext(t){let e=Ie(t);return typeof e=="string"?this.#t.get(e)?.find(s=>s!==t&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){v.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){let e={exact:!0,...t};return this.getAll().find(r=>be(e,r))}findAll(t={}){return this.getAll().filter(e=>be(t,e))}notify(t){v.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){let t=this.getAll().filter(e=>e.state.isPaused);return v.batch(()=>Promise.all(t.map(e=>e.continue().catch(g))))}};function Ie(t){return t.options.scope?.id}a(Ie,"scopeFor");var _t=class extends L{static{a(this,"QueryCache")}constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,r){let s=e.queryKey,i=e.queryHash??ne(s,e),n=this.get(i);return n||(n=new Rt({client:t,queryKey:s,queryHash:i,options:t.defaultQueryOptions(e),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(n)),n}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){let e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){v.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){let e={exact:!0,...t};return this.getAll().find(r=>ye(e,r))}findAll(t={}){let e=this.getAll();return Object.keys(t).length>0?e.filter(r=>ye(t,r)):e}notify(t){v.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){v.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){v.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}};var We=class{static{a(this,"QueryClient")}#e;#t;#r;#s;#n;#i;#o;#a;constructor(t={}){this.#e=t.queryCache||new _t,this.#t=t.mutationCache||new xt,this.#r=t.defaultOptions||{},this.#s=new Map,this.#n=new Map,this.#i=0}mount(){this.#i++,this.#i===1&&(this.#o=X.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=Z.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#i--,this.#i===0&&(this.#o?.(),this.#o=void 0,this.#a?.(),this.#a=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){let e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){let e=this.defaultQueryOptions(t),r=this.#e.build(this,e),s=r.state.data;return s===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(x(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(s))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:r})=>{let s=r.data;return[e,s]})}setQueryData(t,e,r){let s=this.defaultQueryOptions({queryKey:t}),n=this.#e.get(s.queryHash)?.state.data,o=gt(e,n);if(o!==void 0)return this.#e.build(this,s).setData(o,{...r,manual:!0})}setQueriesData(t,e,r){return v.batch(()=>this.#e.findAll(t).map(({queryKey:s})=>[s,this.setQueryData(s,e,r)]))}getQueryState(t){let e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){let e=this.#e;v.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){let r=this.#e;return v.batch(()=>(r.findAll(t).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){let r={revert:!0,...e},s=v.batch(()=>this.#e.findAll(t).map(i=>i.cancel(r)));return Promise.all(s).then(g).catch(g)}invalidateQueries(t,e={}){return v.batch(()=>(this.#e.findAll(t).forEach(r=>{r.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){let r={...e,cancelRefetch:e.cancelRefetch??!0},s=v.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let n=i.fetch(void 0,r);return r.throwOnError||(n=n.catch(g)),i.state.fetchStatus==="paused"?Promise.resolve():n}));return Promise.all(s).then(g)}fetchQuery(t){let e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);let r=this.#e.build(this,e);return r.isStaleByTime(x(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(g).catch(g)}fetchInfiniteQuery(t){return t._type="infinite",this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(g).catch(g)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return Z.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(t){this.#r=t}setQueryDefaults(t,e){this.#s.set(z(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){let e=[...this.#s.values()],r={};return e.forEach(s=>{N(t,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(t,e){this.#n.set(z(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){let e=[...this.#n.values()],r={};return e.forEach(s=>{N(t,s.mutationKey)&&Object.assign(r,s.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;let e={...this.#r.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=ne(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Y&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#r.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};var K=R(H(),1);var ee=R(H(),1),Lt=R(Ue(),1);var ce=ee.createContext(void 0),Ve=a(t=>{let e=ee.useContext(ce);if(t)return t;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},"useQueryClient"),Ge=a(({client:t,children:e})=>(ee.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),(0,Lt.jsx)(ce.Provider,{value:t,children:e})),"QueryClientProvider");var ue=R(H(),1),Ar=R(Ue(),1);function Fr(){let t=!1;return{clearReset:a(()=>{t=!1},"clearReset"),reset:a(()=>{t=!0},"reset"),isReset:a(()=>t,"isReset")}}a(Fr,"createValue");var Mr=ue.createContext(Fr()),Qt=a(()=>ue.useContext(Mr),"useQueryErrorResetBoundary");var Dt=R(H(),1);var Ut=a((t,e,r)=>{let s=r?.state.error&&typeof t.throwOnError=="function"?Se(t.throwOnError,[r.state.error,r]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||s)&&(e.isReset()||(t.retryOnMount=!1))},"ensurePreventErrorBoundaryRetry"),qt=a(t=>{Dt.useEffect(()=>{t.clearReset()},[t])},"useClearResetErrorBoundary"),Nt=a(({result:t,errorResetBoundary:e,throwOnError:r,query:s,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&s&&(i&&t.data===void 0||Se(r,[t.error,s])),"getHasError");var Ee=R(H(),1);var Kt=Ee.createContext(!1),Bt=a(()=>Ee.useContext(Kt),"useIsRestoring"),La=Kt.Provider;var jt=a(t=>{if(t.suspense){let r=a(i=>i==="static"?i:Math.max(i??1e3,1e3),"clamp"),s=t.staleTime;t.staleTime=typeof s=="function"?(...i)=>r(s(...i)):r(s),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},"ensureSuspenseTimers"),$t=a((t,e)=>t.isLoading&&t.isFetching&&!e,"willFetch"),Ht=a((t,e)=>t?.suspense&&e.isPending,"shouldSuspend"),Je=a((t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()}),"fetchOptimistic");function zt(t,e,r){let s=Bt(),i=Qt(),n=Ve(r),o=n.defaultQueryOptions(t);n.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let c=n.getQueryCache().get(o.queryHash),u=t.subscribed!==!1;o._optimisticResults=s?"isRestoring":u?"optimistic":void 0,jt(o),Ut(o,i,c),qt(i);let h=!n.getQueryCache().get(o.queryHash),[d]=K.useState(()=>new e(n,o)),l=d.getOptimisticResult(o),f=!s&&u;if(K.useSyncExternalStore(K.useCallback(m=>{let y=f?d.subscribe(v.batchCalls(m)):g;return d.updateResult(),y},[d,f]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),K.useEffect(()=>{d.setOptions(o)},[o,d]),Ht(o,l))throw Je(o,d,i);if(Nt({result:l,errorResetBoundary:i,throwOnError:o.throwOnError,query:c,suspense:o.suspense}))throw l.error;return n.getDefaultOptions().queries?._experimental_afterQuery?.(o,l),o.experimental_prefetchInRender&&!D.isServer()&&$t(l,s)&&(h?Je(o,d,i):c?.promise)?.catch(g).finally(()=>{d.updateResult()}),o.notifyOnChangeProps?l:d.trackResult(l)}a(zt,"useBaseQuery");function xr(t,e){return zt(t,He,e)}a(xr,"useQuery");var Wt=R(mt(),1);var W=R(H(),1),Xe=R(Ue(),1);var Vt=(0,W.createContext)(null),_r=a(()=>new We({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),"Q"),Lr=a(t=>{let e=(0,Wt.c)(9),{children:r,client:s,queryClient:i}=t,n=(0,W.use)(ce),o;e[0]!==n||e[1]!==i?(o=a(()=>i??n??_r(),"o"),e[0]=n,e[1]=i,e[2]=o):o=e[2];let[c]=(0,W.useState)(o),u=i??n??c,h;e[3]!==r||e[4]!==s?(h=(0,Xe.jsx)(Vt,{value:s,children:r}),e[3]=r,e[4]=s,e[5]=h):h=e[5];let d=h;if(n===u)return d;let l;return e[6]!==d||e[7]!==u?(l=(0,Xe.jsx)(Ge,{client:u,children:d}),e[6]=d,e[7]=u,e[8]=l):l=e[8],l},"b"),Ye=a(()=>{let t=(0,W.use)(Vt);if(!t)throw new p("INTERNAL","useLunora must be used inside <LunoraProvider />");return t},"q");var Gt=a(()=>{let t=null;return{get:a(()=>t,"get"),set:a(e=>{t=e},"set")}},"r");var Te=class{static{a(this,"u")}values=new Map;subscribers=new Map;get(e){return this.values.has(e.key)?this.values.get(e.key):e.defaultValue}set(e,r){if(r===void 0){this.reset(e);return}this.values.set(e.key,r),this.notify(e.key,r)}reset(e){this.values.delete(e.key),this.notify(e.key,e.defaultValue)}subscribe(e,r){let s=this.subscribers.get(e.key);return s||(s=new Set,this.subscribers.set(e.key,s)),s.add(r),()=>{s.delete(r),s.size===0&&this.subscribers.delete(e.key)}}notify(e,r){let s=this.subscribers.get(e);if(s)for(let i of s)try{i(r)}catch{}}};var Jt=0,Qr="lunora-bridge",Dr=1e3,Ur=3e3,Oe=class{static{a(this,"c")}bc;tabId;heartbeatInterval;leaderTimeout;knownLeader=void 0;leader=!1;running=!1;promotionPending=!1;lastHeartbeat=0;heartbeatTimer=void 0;leaderCheckTimer=void 0;onBecomeLeader;onStopBeingLeader;onConnectionStatus;onSubscriptionData;onSubscriptionError;onSubscriptionSettled;constructor(e={}){if(Jt+=1,this.tabId=`tab_${String(Jt)}_${crypto.randomUUID()}`,this.heartbeatInterval=e.heartbeatInterval??Dr,this.leaderTimeout=e.leaderTimeout??Ur,this.onBecomeLeader=e.onBecomeLeader,this.onStopBeingLeader=e.onStopBeingLeader,this.onConnectionStatus=e.onConnectionStatus,this.onSubscriptionData=e.onSubscriptionData,this.onSubscriptionError=e.onSubscriptionError,this.onSubscriptionSettled=e.onSubscriptionSettled,typeof BroadcastChannel>"u"){this.bc=void 0;return}this.bc=new BroadcastChannel(e.channelName??Qr),this.bc.addEventListener("message",r=>{this.handleMessage(r.data)})}start(){if(!this.running){if(this.running=!0,this.bc===void 0){this.becomeLeader();return}this.broadcast({type:"claim-leadership",tabId:this.tabId,ts:Date.now()}),setTimeout(()=>{this.running&&this.knownLeader===void 0&&this.becomeLeader()},this.leaderTimeout),this.leaderCheckTimer=setInterval(()=>{this.checkLeaderHealth()},this.leaderTimeout),this.heartbeatTimer=setInterval(()=>{this.sendHeartbeat()},this.heartbeatInterval)}}stop(){this.running=!1,this.leader&&(this.broadcast({type:"yield-leadership",tabId:this.tabId}),this.leader=!1,this.knownLeader=void 0,this.onStopBeingLeader?.()),this.heartbeatTimer!==void 0&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0),this.leaderCheckTimer!==void 0&&(clearInterval(this.leaderCheckTimer),this.leaderCheckTimer=void 0),this.bc?.close()}isLeader(){return this.leader}promoteImmediately(){this.running&&this.becomeLeader()}get leaderTabId(){return this.knownLeader}get id(){return this.tabId}get isRunning(){return this.running}broadcastSubscriptionData(e,r,s,i,n){this.leader&&this.broadcast({type:"subscription-data",tabId:this.tabId,key:e,data:r,...s===void 0?{}:{cursor:s},...i===void 0?{}:{epoch:i},...n===void 0?{}:{identity:n}})}broadcastSubscriptionError(e,r){this.leader&&this.broadcast({type:"subscription-error",tabId:this.tabId,key:e,error:r})}broadcastSubscriptionSettled(e,r,s,i,n,o){this.leader&&this.broadcast({type:"subscription-settled",tabId:this.tabId,key:e,...r===void 0?{}:{cursor:r},...s===void 0?{}:{epoch:s},...i===void 0?{}:{lastMutationId:i},...n===void 0?{}:{clientId:n},...o===void 0?{}:{identity:o}})}broadcastConnectionStatus(e,r){this.leader&&this.broadcast({type:"connection-status",tabId:this.tabId,status:e,...r===void 0?{}:{identity:r}})}broadcast(e){this.bc?.postMessage(e)}handleMessage(e){switch(e.type){case"claim-leadership":{this.handleClaimLeadership(e);break}case"connection-status":{if(this.leader||e.tabId===this.tabId)break;this.onConnectionStatus?.(e.status,e.identity);break}case"heartbeat":{this.handleHeartbeat(e);break}case"subscription-data":{if(this.leader||e.tabId===this.tabId)break;this.onSubscriptionData?.(e.key,e.data,e.cursor,e.epoch,e.identity);break}case"subscription-error":{if(this.leader||e.tabId===this.tabId)break;this.onSubscriptionError?.(e.key,e.error);break}case"subscription-settled":{if(this.leader||e.tabId===this.tabId)break;this.onSubscriptionSettled?.(e.key,e.cursor,e.epoch,e.lastMutationId,e.clientId,e.identity);break}case"yield-leadership":{this.knownLeader===e.tabId&&(this.knownLeader=void 0,this.running&&!this.leader&&this.claimAndPromote());break}}}handleClaimLeadership(e){if(e.tabId!==this.tabId){if(this.leader){this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()});return}this.knownLeader===void 0&&e.tabId<this.tabId&&(this.knownLeader=e.tabId,this.lastHeartbeat=e.ts)}}handleHeartbeat(e){if(e.tabId!==this.tabId){if(this.leader){this.resolveLeaderVsLeaderTieBreak(e);return}this.lastHeartbeat=e.ts,this.knownLeader=e.tabId}}resolveLeaderVsLeaderTieBreak(e){e.tabId<this.tabId?(this.leader=!1,this.knownLeader=e.tabId,this.lastHeartbeat=e.ts,this.onStopBeingLeader?.()):this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()})}becomeLeader(){this.leader||(this.leader=!0,this.knownLeader=this.tabId,this.lastHeartbeat=Date.now(),this.onBecomeLeader?.(),this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()}))}sendHeartbeat(){this.leader&&this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()})}checkLeaderHealth(){if(!(!this.running||this.leader)){if(this.knownLeader===void 0){this.claimAndPromote();return}Date.now()-this.lastHeartbeat>this.leaderTimeout&&(this.knownLeader=void 0,this.claimAndPromote())}}claimAndPromote(){this.promotionPending||(this.promotionPending=!0,this.broadcast({type:"claim-leadership",tabId:this.tabId,ts:Date.now()}),setTimeout(()=>{this.promotionPending=!1,this.running&&this.knownLeader===void 0&&this.becomeLeader()},this.leaderTimeout))}};var Ze=a(t=>{let e="";for(let r=0;r<t.length;r+=32768)e+=String.fromCharCode(...t.subarray(r,r+32768));return btoa(e)},"A"),qr=a(t=>{let e=atob(t),r=new Uint8Array(e.length);for(let s=0;s<e.length;s+=1)r[s]=e.codePointAt(s)??0;return r},"E"),k="$lunora.wire$",et="__proto__",Xt={BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array},Yt={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},tt=a(t=>{if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e===null||e===Object.prototype},"p"),O=a((t,e=0)=>{if(e>64)throw new RangeError("wire-codec: value nesting exceeds the 64-level limit");if(t===void 0)return[k,"undefined"];if(t===null)return null;let r=typeof t;if(r==="bigint")return[k,"bigint",t.toString()];if(r==="number"){let n=t;return Number.isNaN(n)?[k,"nan"]:n===1/0?[k,"inf"]:n===-1/0?[k,"-inf"]:n}if(r!=="object")return t;if(t instanceof Date)return[k,"date",O(t.getTime(),e+1)];if(t instanceof Error){let n=t,o={};for(let u of Object.keys(n))n[u]!==void 0&&(o[u]=O(n[u],e+1));let c=[k,"error",n.name,n.message,o];return n.cause!==void 0&&c.push(O(n.cause,e+1)),c}if(t instanceof URL)return[k,"url",t.href];if(t instanceof Map)return[k,"map",[...t.entries()].map(([n,o])=>[O(n,e+1),O(o,e+1)])];if(t instanceof Set)return[k,"set",[...t].map(n=>O(n,e+1))];if(t instanceof ArrayBuffer)return[k,"bytes",Ze(new Uint8Array(t)),"ArrayBuffer"];if(ArrayBuffer.isView(t)){let n=t,o=n.constructor.name,c=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);return o==="Uint8Array"?[k,"bytes",Ze(c)]:[k,"bytes",Ze(c),o]}if(Array.isArray(t)){let n=t.map(o=>O(o,e+1));return n.length>0&&n[0]===k?[k,"arr",n]:n}if(!tt(t)){let n=t.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${n} over the Lunora wire \u2014 only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}let s=t,i={};for(let n of Object.keys(s)){let o=s[n];if(o===void 0)continue;let c=O(o,e+1);n===et?Object.defineProperty(i,n,{configurable:!0,enumerable:!0,value:c,writable:!0}):i[n]=c}return i},"u"),S=a((t,e=0)=>{if(e>64)throw new RangeError("wire-codec: value nesting exceeds the 64-level limit");if(t===null||typeof t!="object")return t;if(Array.isArray(t)){if(t[0]===k)switch(t[1]){case"-inf":return-1/0;case"arr":return t[2].map(i=>S(i,e+1));case"bigint":{let i=t[2];if(typeof i!="string"||i.length>1024||!/^-?\d+$/.test(i))throw new RangeError("wire-codec: invalid or over-long bigint (max 1024 digits)");return BigInt(i)}case"date":return new Date(S(t[2],e+1));case"map":return new Map(t[2].map(([i,n])=>[S(i,e+1),S(n,e+1)]));case"set":return new Set(t[2].map(i=>S(i,e+1)));case"url":return new URL(t[2]);case"error":{let i=t[2],n=t[3],o=(Object.hasOwn(Yt,i)?Yt[i]:void 0)??Error,c=new o(n);c.name!==i&&Object.defineProperty(c,"name",{configurable:!0,value:i,writable:!0});let u=S(t[4],e+1);for(let h of Object.keys(u))h===et?Object.defineProperty(c,h,{configurable:!0,enumerable:!0,value:u[h],writable:!0}):c[h]=u[h];return t.length>5&&Object.defineProperty(c,"cause",{configurable:!0,value:S(t[5],e+1),writable:!0}),c}case"bytes":{let i=qr(t[2]),n=t[3]??"Uint8Array";if(n==="ArrayBuffer")return i.buffer.byteLength===i.byteLength?i.buffer:i.slice().buffer;let o=Object.hasOwn(Xt,n)?Xt[n]:void 0;return o?new o(i.slice().buffer):i}case"inf":return 1/0;case"nan":return Number.NaN;case"undefined":return;default:return t.map(i=>S(i,e+1))}return t.map(i=>S(i,e+1))}let r=t,s={};for(let i of Object.keys(r)){let n=S(r[i],e+1);i===et?Object.defineProperty(s,i,{configurable:!0,enumerable:!0,value:n,writable:!0}):s[i]=n}return s},"y");var rt="_id",st="_creationTime",it="page",Zt="pageDelta",Nr=a(t=>{if(Array.isArray(t))return t;if(tt(t)&&Array.isArray(t[it]))return t[it]},"y"),Kr=a(t=>{let e;for(let r of t){let s=r[st];if(typeof s=="number"){if(e!==void 0){if(s<e)return!0;if(s>e)return!1}e=s}}return!1},"l"),Br=a((t,e)=>{let r=e[st];if(typeof r!="number")return t.length;let s=Kr(t);for(let[i,n]of t.entries()){let o=n[st];if(typeof o=="number"&&(s?o<r:o>r))return i}return t.length},"x"),jr=a(t=>{if(typeof t!="object"||t===null)return;let e=t[rt];return typeof e=="string"?e:void 0},"A"),er=a(t=>{if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.key=="string"&&typeof e.table=="string"&&(e.op==="insert"||e.op==="update"||e.op==="delete")},"b"),$r=a((t,e)=>{let r=[];for(let u of t){if(jr(u)===void 0)return;r.push(u)}let{key:s,op:i,row:n}=e;if(i==="delete"){let u=r.filter(h=>h[rt]!==s);return u.length===r.length?[...r]:u}if(n===void 0)return;let o=[...r],c=r.findIndex(u=>u[rt]===s);return c===-1?o.splice(Br(r,n),0,n):o[c]=n,o},"I"),tr=a((t,e)=>{let r=Nr(t);if(r===void 0)return;let s=$r(r,e);return s===void 0||Array.isArray(t)?s:{...t,[it]:s}},"E");var Hr=1024,Pe=a(t=>{let e=t.maxBuffer??Hr,r=[],s=[],i=!1,n,o=!1,c=a(()=>{let d=s.shift();if(!d)return!1;if(n)return d.reject(n),!0;if(r.length>0){let l=r.shift();return d.resolve({done:!1,value:l}),!0}return i?(d.resolve({done:!0,value:void 0}),!0):(s.unshift(d),!1)},"u"),u={complete(){if(!(i||n))for(i=!0;c(););},fail(d){if(!(i||n))for(n=d,r.length=0;c(););},push(d){if(!(i||n||o)){if(r.length>=e){u.fail(new p("STREAM_BACKPRESSURE",`stream buffer overflow (max=${e.toString()}); the consumer cannot keep up with the producer`));return}r.push(d),c()}}},h=a(()=>{if(!o){o=!0,i=!0,r.length=0;try{t.onCancel()}catch{}for(;c(););}},"c");return{handle:u,iterable:{cancel:h,[Symbol.asyncIterator](){return{next(){if(n)return Promise.reject(n);if(r.length>0){let d=r.shift();return Promise.resolve({done:!1,value:d})}return i?Promise.resolve({done:!0,value:void 0}):new Promise((d,l)=>{s.push({reject:l,resolve:d})})},return(){return h(),Promise.resolve({done:!0,value:void 0})}}}}}},"p");var rr=/^ /u,sr=a(t=>typeof t=="object"&&t!==null?JSON.stringify(t):String(t),"h"),zr=a(t=>{let e="",r=[];for(let s of t.split(`
|
|
2
|
-
`))s.startsWith("event:")?e=s.slice(6).replace(rr,""):s.startsWith("data:")&&r.push(s.slice(5).replace(rr,""));return{data:r.join(`
|
|
3
|
-
`),event:e}},"u"),Wr=a((t,e,r)=>{let s=e.params??{},i=t.path.split("/").map(c=>{if(!c.startsWith(":"))return c;let u=c.slice(1),h=s[u];if(h===void 0)throw new p("HTTP_STREAM_MISSING_PARAM",`httpStream: missing path param ":${u}" for route ${t.path}`);return encodeURIComponent(sr(h))}).join("/"),n=new URLSearchParams;for(let[c,u]of Object.entries(e.searchParams??{}))u!==void 0&&n.set(c,sr(u));let o=n.toString();return`${r.endsWith("/")?r.slice(0,-1):r}${i}${o===""?"":`?${o}`}`},"S"),Vr=a((t,e)=>{if(t.event==="complete")return e.complete(),!0;if(t.event==="error"){let r={};try{r=JSON.parse(t.data)}catch{}let s=typeof r.message=="string"?r.message:"stream error",i=typeof r.code=="string"?r.code:"HTTP_STREAM_ERROR";return e.fail(new p(i,s)),!0}if((t.event===""||t.event==="message")&&t.data!=="")try{e.push(JSON.parse(t.data))}catch{return e.fail(new p("HTTP_STREAM_BAD_CHUNK","httpStream: malformed SSE chunk (invalid JSON)")),!0}return!1},"T"),Gr=a(async(t,e)=>{let r=t.getReader(),s=new TextDecoder,i="",n=a(()=>{let o=i.indexOf(`
|
|
4
|
-
|
|
5
|
-
`);for(;o!==-1;){let c=zr(i.slice(0,o));if(i=i.slice(o+2),Vr(c,e))return!0;o=i.indexOf(`
|
|
6
|
-
|
|
7
|
-
`)}return!1},"i");for(;;){let{done:o,value:c}=await r.read();if(o)break;if(i+=s.decode(c,{stream:!0}).replaceAll(`\r
|
|
8
|
-
`,`
|
|
9
|
-
`),n()){await r.cancel().catch(()=>{});return}}i+=s.decode().replaceAll(`\r
|
|
10
|
-
`,`
|
|
11
|
-
`),n()||e.fail(new p("HTTP_STREAM_INTERRUPTED","httpStream: stream ended without a complete frame"))},"E"),ir=a((t,e,r={})=>{let s=r.fetch??(typeof fetch=="function"?fetch.bind(globalThis):void 0);if(!s)throw new p("INTERNAL","httpStream: no `fetch` implementation available");let i=Wr(t,e??{},r.baseUrl??""),n=new AbortController,o;r.signal&&(r.signal.aborted?n.abort():(o=a(()=>{n.abort()},"s"),r.signal.addEventListener("abort",o,{once:!0})));let c=a(()=>{o&&r.signal?.removeEventListener("abort",o)},"d"),{handle:u,iterable:h}=Pe({maxBuffer:r.maxBuffer,onCancel:a(()=>{n.abort()},"onCancel")});return(async()=>{try{let d=await s(i,{headers:{accept:"text/event-stream",...r.headers},method:t.method,signal:n.signal});if(!d.ok){await d.body?.cancel().catch(()=>{}),u.fail(new p("HTTP_STREAM_STATUS",`httpStream: request failed (status ${d.status.toString()})`,{status:d.status}));return}if(!d.body){u.fail(new p("HTTP_STREAM_NO_BODY","httpStream: response has no body"));return}await Gr(d.body,u)}finally{c()}})().catch(d=>{if(n.signal.aborted){u.complete();return}if(d instanceof Error&&"code"in d){u.fail(d);return}u.fail(new p("HTTP_STREAM_TRANSPORT",d instanceof Error?d.message:String(d),{cause:d}))}),h},"w");var Jr=a((t,e)=>t<e?-1:t>e?1:0,"f"),nt=a(t=>{if(t===void 0)return"null";if(typeof t=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key \u2014 pass it as a string, or use stableWireKey");if(typeof t=="number"){if(Number.isNaN(t))return"nan";if(t===1/0)return"inf";if(t===-1/0)return"-inf";if(Object.is(t,-0))return"-0"}if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(n=>nt(n)).join(",")}]`;let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype){let n=t.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${n} in a stable JSON cache key \u2014 only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}let r=t,s=Object.keys(r).toSorted(Jr),i=[];for(let n of s){let o=r[n];o!==void 0&&i.push(`${JSON.stringify(n)}:${nt(o)}`)}return`{${i.join(",")}}`},"e"),B=a(t=>nt(O(t)),"p");var _=class t{static{a(this,"r")}static key(e,r,s){return`${e}::${B(r)}::${s??""}`}byKey=new Map;byId=new Map;get(e){return this.byKey.get(e)}getById(e){return this.byId.get(e)}add(e){this.byKey.set(t.key(e.fn.__lunoraRef,e.args,e.shardKey),e),this.byId.set(e.id,e)}remove(e){let r=t.key(e.fn.__lunoraRef,e.args,e.shardKey);this.byKey.get(r)===e&&this.byKey.delete(r),this.byId.delete(e.id)}all(){return[...this.byKey.values()]}};var he=a((t,e)=>{let r=t;for(let s of e)try{r=s.transform(r)}catch{}return r},"p"),te=a((t,e)=>{if(e!==t.lastValue){t.lastValue=e;for(let r of t.callbacks)try{r(e)}catch{}}},"u"),at=a((t,e)=>{let r;try{r=e(t.lastValue)}catch{return}let s={id:Symbol("optimistic"),transform:e};t.optimisticLayers.push(s),te(t,r);let i=a(()=>{let o=t.optimisticLayers.findIndex(c=>c.id===s.id);return o===-1?!1:(t.optimisticLayers.splice(o,1),!0)},"c"),n=a(()=>{te(t,he(t.serverBase,t.optimisticLayers))},"a");return{confirm:a(o=>{if(o===void 0){i();return}s.commitCursor=o,t.serverCursor!==void 0&&t.serverCursor>=o&&i()&&n()},"confirm"),rollback:a(()=>{i()&&n()},"rollback")}},"y"),Re=a((t,e)=>{if(e===void 0||t.optimisticLayers.length===0)return!1;let r=t.optimisticLayers.length;return t.optimisticLayers=t.optimisticLayers.filter(s=>s.commitCursor===void 0||s.commitCursor>e),t.optimisticLayers.length!==r},"h"),nr=a((t,e)=>{let r=[],s=[],i=a((n,o)=>t.get(_.key(n,o,e)),"c");return{confirms:r,rollbacks:s,store:{getAllQueries:a(n=>{let o=[];for(let c of t.all())c.fn.__lunoraRef===n.__lunoraRef&&(c.shardKey??"")===(e??"")&&o.push({args:c.args,value:c.lastValue});return o},"getAllQueries"),getQuery:a((n,o)=>i(n.__lunoraRef,o??{})?.lastValue,"getQuery"),setQuery:a((n,o,c)=>{let u=i(n.__lunoraRef,o??{});if(!u)return;let h=at(u,()=>c);h&&(r.push(h.confirm),s.push(h.rollback))},"setQuery")}}},"L");var ar=0,Xr=a(()=>{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();ar+=1;let t=typeof crypto<"u"&&typeof crypto.getRandomValues=="function"?Array.from(crypto.getRandomValues(new Uint8Array(8)),e=>e.toString(16).padStart(2,"0")).join(""):Math.random().toString(16).slice(2,12);return`id_${Date.now().toString(36)}_${ar.toString(36)}_${t}`},"d"),ot=a((t,e)=>t!==void 0&&e!==t,"a"),Fe=Xr,re=a((t,e,r,s)=>{if(t){t({error:r,mutationId:s,operation:e});return}console.warn(`[lunora] offline-queue persistence ${e} failed`,r)},"c"),Ae=class{static{a(this,"u")}queueBeforeFirstConnect;maxItems;onPersistenceError;persistence;onEvict;onSizeChange;version;items=[];constructor(e={},r={}){this.maxItems=e.maxItems??1e3,this.queueBeforeFirstConnect=e.queueBeforeFirstConnect??!1,this.onPersistenceError=e.onPersistenceError,this.persistence=r.persistence,this.onEvict=r.onEvict,this.onSizeChange=r.onSizeChange,this.version=r.version}get size(){return this.items.length}enqueue(e){let r=e;r.id??=Fe(),this.items.push(r),this.persistence?.append({args:r.args,clientId:r.clientId,functionPath:r.functionPath,id:r.id,identity:r.identity,shardKey:r.shardKey,...this.version===void 0?{}:{version:this.version}}).catch(s=>{re(this.onPersistenceError,"append",s,r.id)}),this.evictOverflow(),this.notifySize()}async hydrate(){if(!this.persistence)return[];let e;try{e=await this.persistence.load()}catch(n){throw re(this.onPersistenceError,"load",n),n}let r=[];for(let n of e)if(!(this.items.some(o=>o.id===n.id)||r.some(o=>o.id===n.id))){if(ot(this.version,n.version)){this.persistence.remove(n.id).catch(o=>{re(this.onPersistenceError,"remove",o,n.id)});continue}r.push({args:n.args,clientId:n.clientId,functionPath:n.functionPath,id:n.id,identity:n.identity,reject:a(()=>{},"reject"),resolve:a(()=>{},"resolve"),shardKey:n.shardKey})}this.items.unshift(...r),this.evictOverflow(),this.notifySize();let s=new Set(this.items),i=new Set;for(let n of r)s.has(n)&&i.add(n.shardKey);return[...i]}drain(e){if(!e){let i=[...this.items];return this.items.length=0,this.notifySize(),i}let r=[],s=[];for(let i of this.items)(e(i)?r:s).push(i);return this.items.length=0,this.items.push(...s),this.notifySize(),r}requeue(e){e.length!==0&&(this.items.unshift(...e),this.notifySize())}drainConflict(){let e=[],r=[];for(let s of this.items)if(s.precondition!==void 0&&!s.precondition()){let i=new Error("offline mutation skipped: precondition failed before replay");i.code="OFFLINE_PRECONDITION_FAILED",s.reject(i),e.push(s)}else r.push(s);return e.length>0&&(this.items.length=0,this.items.push(...r),this.notifySize()),e}clear(){for(let e of this.items){let r=new Error("CLIENT_CLOSED");r.code="CLIENT_CLOSED",e.reject(r)}this.items.length=0,this.notifySize()}evictOverflow(){for(;this.items.length>this.maxItems;){let e=this.items.shift();if(e){e.id&&this.persistence?.remove(e.id).catch(s=>{re(this.onPersistenceError,"remove",s,e.id)});let r=new Error("offline queue overflow");r.code="OFFLINE_QUEUE_OVERFLOW",e.reject(r),this.onEvict?.(e,r)}}}notifySize(){this.onSizeChange?.(this.items.length)}};var A=a(t=>new Promise((e,r)=>{t.addEventListener("success",()=>{e(t.result)}),t.addEventListener("error",()=>{r(t.error??new Error("IndexedDB request failed"))})}),"c"),Me=a((t,e,r,s)=>{let i;return()=>i||(i=new Promise((n,o)=>{let c=t.open(e,r);c.addEventListener("upgradeneeded",()=>{s(c.result)}),c.addEventListener("success",()=>{n(c.result)}),c.addEventListener("error",()=>{o(c.error??new Error("IndexedDB open failed"))})}),i)},"E"),xe=a((t,e)=>async(r,s)=>{let i=(await t()).transaction(e,r),n=await s(i.objectStore(e));return await new Promise((o,c)=>{i.addEventListener("complete",()=>{o()}),i.addEventListener("error",()=>{c(i.error??new Error("IndexedDB transaction failed"))}),i.addEventListener("abort",()=>{c(i.error??new Error("IndexedDB transaction aborted"))})}),n},"u");var Yr="lunora-outbox",Zr="offline-mutations",or="by_id",es=a((t={})=>{let e=t.indexedDB??(typeof indexedDB>"u"?void 0:indexedDB);if(!e)throw new p("INTERNAL","createIndexedDbPersistence: no IndexedDB available \u2014 pass `indexedDB` or use createInMemoryPersistence()");let r=t.databaseName??Yr,s=t.storeName??Zr,i=Me(e,r,1,o=>{o.objectStoreNames.contains(s)||o.createObjectStore(s,{autoIncrement:!0}).createIndex(or,"id",{unique:!0})}),n=xe(i,s);return{append:a(async o=>{await n("readwrite",c=>A(c.add(o)))},"append"),clear:a(async()=>{await n("readwrite",o=>A(o.clear()))},"clear"),load:a(async()=>n("readonly",o=>A(o.getAll())),"load"),remove:a(async o=>{await n("readwrite",async c=>{let u=await A(c.index(or).getKey(o));u!==void 0&&await A(c.delete(u))})},"remove")}},"p"),cr=a((t,e=!0)=>{if(t!==!1){if(t)return t;if(!(!e||typeof indexedDB>"u"))return es()}},"P");var _e=a((t,e,r)=>`${t}::${e}::${r??""}`,"B"),ts=500;var rs="lunora-query-cache",ss="query-cache",ur="by_ts",is=1,ns=a((t={})=>{let e=t.indexedDB??(typeof indexedDB>"u"?void 0:indexedDB);if(!e)throw new p("INTERNAL","createIndexedDbQueryCache: no IndexedDB available \u2014 pass `indexedDB` or use createInMemoryQueryCache()");let r=t.databaseName??rs,s=t.storeName??ss,i=t.maxEntries??ts,n=Me(e,r,is,u=>{u.objectStoreNames.contains(s)||u.createObjectStore(s,{keyPath:"key"}).createIndex(ur,"ts",{unique:!1})}),o=xe(n,s),c=a(async u=>{let h=await A(u.count())-i;h<=0||await new Promise((d,l)=>{let f=u.index(ur).openCursor();f.addEventListener("success",()=>{let m=f.result;if(!m||h<=0){d();return}m.delete(),h-=1,m.continue()}),f.addEventListener("error",()=>{l(f.error??new Error("IndexedDB eviction failed"))})})},"y");return{clear:a(async()=>{await o("readwrite",u=>A(u.clear()))},"clear"),load:a(async()=>o("readonly",u=>A(u.getAll())),"load"),put:a(async(u,h)=>{await o("readwrite",async d=>{await A(d.put({...h,key:u})),await c(d)})},"put"),remove:a(async u=>{await o("readwrite",h=>A(h.delete(u)))},"remove")}},"S"),hr=a(t=>{if(t!==!1){if(t)return t;if(!(typeof indexedDB>"u"))return ns()}},"C");var ct=a((t={},e=Math.random)=>{let r=t.initialDelayMs??250,s=t.maxDelayMs??3e4,i=t.jitter??!0,n=0;return{next(){let o=Math.min(s,r*2**n);if(n+=1,!i)return o;let c=o/2;return Math.floor(c+e()*(o-c))},reset(){n=0}}},"s");var dr=a((t,e,r,s)=>{let i=t.peekActiveQuerySnapshot(e.__lunoraRef,r,s),n=i.present?B(i.value):void 0;return()=>{let o=t.peekActiveQuerySnapshot(e.__lunoraRef,r,s);return!i.present||!o.present?!0:B(o.value)===n}},"c");var ut=500,as=a((t,e)=>{if(t.size<e)return;let r=t.keys().next().value;r!==void 0&&t.delete(r)},"he"),J=class{static{a(this,"C")}listeners=new Set;add(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}emit(...e){let[r]=e;for(let s of this.listeners)try{s(r)}catch{}}clear(){this.listeners.clear()}},os="/_lunora/rpc",lr="/_lunora/rpc-batch",cs="/_lunora/ws",ht=a(t=>t===void 0||t===""?"":`&bucket=${encodeURIComponent(t)}`,"L"),Le=a(t=>{for(let e=t.length-1;e>=0;e-=1)t[e]?.()},"E"),us=a((t,e)=>{for(let r of e)r.op==="delete"?t.delete(r.key):r.value!==void 0&&t.set(r.key,r.value)},"le"),hs="lunora-ping",ds=3e4,ls=1e4,fs=250,ps=64,ms="/_lunora/admin/shard-traffic",ys="/_lunora/admin/scheduled",bs="/_lunora/admin/scheduled/status",vs="/_lunora/admin/scheduled/ws",gs="/_lunora/admin/scheduled/cancel",Ss="/_lunora/admin/scheduled/dead",ws="/_lunora/admin/scheduled/dead/retry",Cs="/_lunora/admin/scheduled/dead/cancel",ks="/_lunora/admin/workflows/instances",Is="/_lunora/admin/workflows/instance",Es="/_lunora/admin/workflows/status",dt="/_lunora/admin/storage",Ts="/_lunora/admin/storage/url",Os="/_lunora/admin/storage/buckets",Ps="/_lunora/admin/functions",Rs="/_lunora/admin/cron-jobs",As="/_lunora/admin/cron-jobs/run",Fs="/_lunora/admin/openapi",Ms="/_lunora/admin/openrpc",xs="/_lunora/admin/global/tables",_s="/_lunora/admin/global/table",Ls="/_lunora/admin/global/facet",Qs="/_lunora/admin/vector/indexes",Ds="/_lunora/admin/vector/query",Us="/_lunora/admin/logs/archive",qs="/_lunora/admin/kv/namespaces",Ns="/_lunora/admin/kv/keys",lt="/_lunora/admin/kv/value",Ks="/_lunora/admin/auth/users",Bs="/_lunora/admin/auth/sessions",js="/_lunora/admin/auth/users/create",$s="/_lunora/admin/auth/users/role",Hs="/_lunora/admin/auth/users/ban",zs="/_lunora/admin/auth/users/unban",Ws="/_lunora/admin/auth/users/password",Vs="/_lunora/admin/auth/users/remove",Gs="/_lunora/admin/auth/users/impersonate",Js="/_lunora/admin/auth/sessions/revoke",Xs="/_lunora/admin/auth/sessions/revoke-all",Ys="/_lunora/admin/auth/capabilities",Zs="/_lunora/admin/auth/users/update",ei="/_lunora/admin/auth/accounts",ti="/_lunora/admin/auth/accounts/unlink",ri="/_lunora/admin/auth/passkeys",si="/_lunora/admin/auth/passkeys/delete",ii="/_lunora/admin/auth/two-factor/disable",ni="/_lunora/admin/auth/organizations",ai="/_lunora/admin/auth/organizations/members",oi="/_lunora/admin/auth/organizations/invitations",ci="/_lunora/admin/auth/organizations/members/remove",ui="/_lunora/admin/auth/organizations/invitations/cancel",hi="/_lunora/admin/auth/config",di="/_lunora/admin/auth/organizations/create",li="/_lunora/admin/auth/organizations/update",fi="/_lunora/admin/auth/organizations/remove",pi="/_lunora/admin/auth/organizations/members/add",mi="/_lunora/admin/auth/organizations/members/invite",yi="/_lunora/admin/auth/organizations/members/role",bi="/_lunora/admin/auth/organizations/teams",vi="/_lunora/admin/auth/organizations/teams/create",gi="/_lunora/admin/auth/organizations/teams/update",Si="/_lunora/admin/auth/organizations/teams/remove",wi="/_lunora/admin/auth/organizations/teams/members",Ci="/_lunora/admin/auth/organizations/teams/members/add",ki="/_lunora/admin/auth/organizations/teams/members/remove",Ii="/_lunora/admin/auth/organizations/roles",Ei="/_lunora/admin/auth/organizations/roles/create",Ti="/_lunora/admin/auth/organizations/roles/update",Oi="/_lunora/admin/auth/organizations/roles/remove",Pi="/api/auth",Ri="/get-session",fr=a(t=>t.startsWith("https://")?`wss://${t.slice(8)}`:t.startsWith("http://")?`ws://${t.slice(7)}`:t,"W"),V=a((t,e)=>`${t.endsWith("/")?t.slice(0,-1):t}${e}`,"k"),T=a((t,e)=>{let r=new URLSearchParams;for(let[i,n]of Object.entries(e))n!==void 0&&n!==""&&r.set(i,String(n));let s=r.toString();return s===""?t:`${t}?${s}`},"y"),Ai=[Zt],C=a(t=>t??"","m"),mr=a((t,e)=>{let r=t.error,s=typeof r?.code=="string"?r.code:void 0,i=typeof r?.message=="string"?r.message:void 0;return{code:s,messageText:(typeof t.message=="string"?t.message:void 0)??i??e}},"$"),Fi=a(t=>{let{code:e,messageText:r}=mr(t,"stream error");return e===void 0?new Error(r):new p(e,r)},"Lt"),pr=a(t=>{let{code:e,messageText:r}=mr(t,"subscription error");return{message:r,...e===void 0?{}:{code:e}}},"q"),Qe=a((t,e)=>{for(let r of t)try{r(e)}catch{}},"A"),Mi=new TextDecoder,xi=a(t=>{if(typeof t=="string")return t;if(t instanceof ArrayBuffer)return Mi.decode(t)},"Ut"),F=a((t,e)=>{if(!t.socket||t.wsState!=="open")return!1;try{return t.socket.send(JSON.stringify(e)),!0}catch{return!1}},"S"),de=a(t=>{let e=new Error(t.message??"request failed");return e.code=t.code,t.data!==void 0&&(e.data=S(t.data)),t.hint!==void 0&&(e.hint=t.hint),t.docsUrl!==void 0&&(e.docsUrl=t.docsUrl),e},"_"),G=a((t,e)=>{try{return O(t)}catch(r){let s=r instanceof Error?r.message:String(r);throw new TypeError(`LunoraClient: cannot encode ${e} \u2014 ${s}`,r instanceof Error?{cause:r}:void 0)}},"v"),_i=a((t,e)=>{let r=Array.from({length:e});for(let s of t){if(typeof s.id!="number"||s.id<0||s.id>=e)continue;let i=s.body;r[s.id]=i&&"error"in i&&i.error?{error:de(i.error),ok:!1}:{ok:!0,value:S(i?.result)}}return r.map(s=>s??{error:new Error("batch call returned no result"),ok:!1})},"xt"),Li=new Set(["SHARD_ERROR","SHARD_UNAVAILABLE"]),Qi=Promise.resolve(),ft=class t{static{a(this,"Q")}static MAX_POKE_BUFFERS=256;static createClientQuery(e,r){return{defaultValue:r,key:e}}url;wsUrl;clientQueryStore;wsToken;authBasePath;fetchImpl;WebSocketImpl;bookmark;reconnectOptions;connectTimeoutMs;heartbeatIntervalMs;offlineQueue;outbox;clientId;shardCursors=new Map;defaultShardKey;readyResolved=!1;readyResolve;readyPromise;clientWatermarks=new Map;outboxMutationCounter=0;onPersistenceError;persistence;persistenceVersion;outboxLeaderRelease;queryCache;hydratedQueryCache=new Map;pendingCacheWrites=new Map;cacheFlushTimer;subscriptions=new _;tabCoordinator;leaderStatus;leaderWasEverConnected=!1;connections=new Map;defaultConnectionContext;connectionContexts=new Map;connectionContextHolders=new Map;authToken=null;authSubject=void 0;queuedIdentities=new Map;queuedOfflineShardKeys=new Set;closed=!1;authTokenListeners=new J;statusListeners=new J;tokenExpiredListeners=new J;mutationSettledListeners=new J;pendingChangeListeners=new J;whisperHandlers=new Map;lastStatus="idle";nextSubId=0;nextStreamId=0;streams=new Map;shapeSubscriptions=new Map;pokeBuffers=new Map;nextShapeId=0;constructor(e){this.url=e.url,this.wsUrl=e.wsUrl??V(fr(e.url),cs),this.wsToken=e.wsToken;let r=e.authBasePath??Pi;this.authBasePath=r.endsWith("/")?r.slice(0,-1):r,this.fetchImpl=e.fetch??(typeof fetch=="function"?fetch.bind(globalThis):void 0),this.WebSocketImpl=e.WebSocket??(typeof WebSocket=="function"?WebSocket:void 0),this.bookmark=e.bookmarkStorage??Gt(),this.reconnectOptions=e.reconnect,this.heartbeatIntervalMs=e.heartbeatIntervalMs??ds,this.connectTimeoutMs=e.connectTimeoutMs??ls,this.defaultConnectionContext=e.connectionContext,this.persistence=cr(e.persistence,e.outbox===void 0),this.persistenceVersion=e.persistenceVersion,this.queryCache=hr(e.queryCache),this.onPersistenceError=e.offlineQueue?.onPersistenceError,this.clientQueryStore=new Te,e.crossTabSync?(this.tabCoordinator=this.createTabCoordinator(),this.tabCoordinator.start()):this.tabCoordinator=void 0,e.hydrateOnStart&&this.queryCache?this.readyPromise=new Promise(s=>{this.readyResolve=s}):(this.readyResolved=!0,this.readyPromise=Qi),this.offlineQueue=new Ae(e.offlineQueue,{onEvict:a((s,i)=>{this.emitItemSettled(s,"rejected",i)},"onEvict"),onSizeChange:a(s=>{this.pendingChangeListeners.emit(s)},"onSizeChange"),persistence:this.persistence,version:e.persistenceVersion}),this.outbox=e.outbox,this.clientId=e.clientId??`client-${Fe()}`,this.persistence&&queueMicrotask(()=>{this.hydrateAsOutboxLeader()}),this.queryCache&&queueMicrotask(()=>{(async()=>{try{await this.hydrateQueryCache()}catch{}finally{this.readyResolved=!0,this.readyResolve?.()}})().catch(()=>{})})}setAuthToken(e,r){let s=this.authToken!==e,i=this.identityFingerprint();this.authToken=e,r!==void 0&&(this.authSubject=r);let n=this.identityFingerprint();if(n!==i&&(s?this.rejectQueuedForIdentityChange():(this.restampQueuedIdentity(i,n),this.restampWatermarks(i,n)),this.tabCoordinator)){let o=this.tabCoordinator.isLeader();this.tabCoordinator.stop(),this.tabCoordinator=this.createTabCoordinator(),this.tabCoordinator.start(),o&&this.tabCoordinator.promoteImmediately()}s&&this.authTokenListeners.emit(e)}getAuthToken(){return this.authToken}currentIdentity(){return this.identityFingerprint()}clientIdentifier(){return this.clientId}confirmedMutationWatermark(e){return this.clientWatermarks.get(this.identityFingerprint()??"")?.get(e??"")??0}async callMutator(e,r,s){let i=s?.clientSeq;if(i!==void 0&&(!Number.isInteger(i)||i<=0))throw new p("INTERNAL",`callMutator: clientSeq must be a positive integer, got ${String(i)}`);let n=s?.shardKey??"",o=this.identityFingerprint(),c,u=await this.rpc(e,r,s?.shardKey,{captureBookmark:!0,clientId:this.clientId,clientSeq:i,onMutationAck:a(h=>{c=h},"onMutationAck")});if(c!==void 0&&c>(this.clientWatermarks.get(o??"")?.get(n)??0)){let h=this.clientWatermarks.get(o??"");h===void 0&&(h=new Map,this.clientWatermarks.set(o??"",h)),h.set(n,c)}return{applied:c===void 0||c===i,result:u}}onAuthTokenChange(e){return this.authTokenListeners.add(e)}async getCurrentUser(){if(this.closed||!this.fetchImpl)return null;let e={};this.authToken&&(e.authorization=`Bearer ${this.authToken}`);try{let r=await this.fetchImpl(V(this.url,`${this.authBasePath}${Ri}`),{credentials:"include",headers:e,method:"GET"});return r.ok?(await r.json())?.user??null:null}catch{return null}}setWsToken(e){if(this.wsToken!==e){this.wsToken=e;for(let r of this.connections.values())if(r.socket)try{r.socket.close()}catch{}}}setConnectionContext(e,r={}){let s=C(r.shardKey);e===void 0?this.connectionContexts.delete(s):this.connectionContexts.set(s,e),this.refreshConnectionContext(s)}acquireConnectionContext(e,r={}){let s=C(r.shardKey),i={context:e},n=this.connectionContextHolders.get(s);n?n.push(i):this.connectionContextHolders.set(s,[i]),this.refreshConnectionContext(s);let o=!1;return()=>{if(o)return;o=!0;let c=this.connectionContextHolders.get(s);if(!c)return;let u=c.indexOf(i);u!==-1&&c.splice(u,1),c.length===0&&this.connectionContextHolders.delete(s),this.refreshConnectionContext(s)}}whisperSubscribe(e,r,s={}){let i=C(s.shardKey),n=this.whisperHandlers.get(i);n||(n=new Map,this.whisperHandlers.set(i,n));let o=n.get(e),c=o===void 0;if(o||(o=new Set,n.set(e,o)),o.add(r),this.ensureSocket(s.shardKey),c){let u=this.getConnection(s.shardKey);u&&F(u,{topic:e,type:"whisper_subscribe"})}return()=>{let u=this.whisperHandlers.get(i),h=u?.get(e);if(!h?.delete(r)||h.size>0)return;u?.delete(e),u?.size===0&&this.whisperHandlers.delete(i);let d=this.getConnection(s.shardKey);d&&F(d,{topic:e,type:"whisper_unsubscribe"})}}whisper(e,r,s={}){this.ensureSocket(s.shardKey);let i=this.getConnection(s.shardKey);i&&F(i,{data:G(r??null,`whisper data for topic '${e}'`),topic:e,type:"whisper"})}onTokenExpired(e){return this.tokenExpiredListeners.add(e)}connectionStatus(){return this.computeStatus()}onConnectionStatus(e){let r=this.statusListeners.add(e);return e(this.computeStatus()),r}pendingCount(){return this.offlineQueue.size}debug(){let e=[],r=this.clientWatermarks.get(this.identityFingerprint()??""),s=new Set([...this.connections.keys(),...r?.keys()??[]]);for(let n of s){let o=this.connections.get(n);e.push({confirmedMutationWatermark:r?.get(n)??0,hasSocket:o?.socket!==void 0,shardKey:n===""?void 0:n,wasEverConnected:o?.wasEverConnected??!1,wsState:o?.wsState??"idle"})}let i=this.subscriptions.all().map(n=>({acked:n.acked,functionPath:n.fn.__lunoraRef,id:n.id,kind:"query",lastMutationId:n.lastMutationId,pendingOptimisticLayers:n.optimisticLayers.length,serverCursor:n.serverCursor,shardKey:n.shardKey,subscriberCount:n.callbacks.size}));for(let n of this.shapeSubscriptions.values())i.push({acked:n.serverCursor!==void 0,functionPath:`shape:${n.name}`,id:n.id,kind:"shape",lastMutationId:n.lastMutationId,pendingOptimisticLayers:0,rowCount:n.rows.size,serverCursor:n.serverCursor,shardKey:n.shardKey,subscriberCount:n.callbacks.size});return{clientId:this.clientId,closed:this.closed,connectionStatus:this.computeStatus(),pendingWrites:this.offlineQueue.size,shards:e.toSorted((n,o)=>(n.shardKey??"").localeCompare(o.shardKey??"")),subscriptions:i.toSorted((n,o)=>n.functionPath.localeCompare(o.functionPath))}}onPendingChange(e){let r=this.pendingChangeListeners.add(e);return e(this.offlineQueue.size),r}onMutationSettled(e){return this.mutationSettledListeners.add(e)}getWebSocketImpl(){return this.WebSocketImpl}getClientQuery(e){return this.clientQueryStore.get(e)}setClientQuery(e,r){this.clientQueryStore.set(e,r)}subscribeClientQuery(e,r){return this.clientQueryStore.subscribe(e,r)}resetClientQuery(e){this.clientQueryStore.reset(e)}snapshotPrecondition(e,r,s){return dr(this,e,r,s)}whenReady(){return this.readyPromise}get isReady(){return this.readyResolved}peekHydratedQuery(e,r,s){if(!this.readyResolved)return;let i=B(r),n=_e(e,i,s),o=this.hydratedQueryCache.get(n);if(o!==void 0)return o.identity===this.identityFingerprint()?o.value:void 0}peekActiveQuerySnapshot(e,r,s){let i=_.key(e,r,s),n=this.subscriptions.get(i);return{present:n!==void 0,value:n?.lastValue}}async query(e,r,s={}){return this.assertOpen(),await this.rpc(e.__lunoraRef,r,s.shardKey,{attachBookmark:!0})}async batch(e){if(this.assertOpen(),!this.fetchImpl)throw new p("INTERNAL","LunoraClient: no `fetch` implementation available");if(e.length===0)return[];let r=await this.fetchImpl(V(this.url,lr),{body:JSON.stringify({calls:e.map((n,o)=>({args:G(n.args??{},`args for batch call '${n.fn.__lunoraRef}'`),functionPath:n.fn.__lunoraRef,id:o,shardKey:n.shardKey}))}),headers:this.rpcRequestHeaders({attachBookmark:!0}),method:"POST"}),s=r.headers.get("x-d1-bookmark");s&&this.bookmark.set(s);let i;try{i=await r.json()}catch{throw new p("INTERNAL",`LunoraClient: batch response was not JSON (status ${r.status.toString()})`)}if(!r.ok||i.error&&!i.results)throw i.error?de(i.error):new p("INTERNAL",`LunoraClient: batch request failed (status ${r.status.toString()})`);for(let n of i.results??[]){let o=n.body?.commitCursor;typeof n.id=="number"&&typeof o=="number"&&this.recordShardCursor(e[n.id]?.shardKey,o)}return _i(i.results??[],e.length)}async mutation(e,r,s={}){this.assertOpen();let i=r,n=s.mutationId??Fe(),{confirms:o,rollbacks:c}=this.applyOptimisticUpdates(e.__lunoraRef,i,s.shardKey,s.optimistic);s.optimisticUpdate&&this.applyOptimisticUpdate(s.optimisticUpdate,r,s.shardKey,c,o);let{hasSocket:u,wasEverConnected:h,wsState:d}=this.connectionGateState(s.shardKey),{queueBeforeFirstConnect:l}=this.offlineQueue,f=h||l,m=this.WebSocketImpl!==void 0&&f;if(d!=="open"&&!u&&m||d==="connecting"&&f)return this.enqueueOfflineMutation(e,i,s.shardKey,n,c,o,s.precondition);try{let y,b=await this.rpc(e.__lunoraRef,i,s.shardKey,{captureBookmark:!0,mutationId:n,onCommitCursor:a(w=>{y=w},"onCommitCursor")});for(let w of o)w(y);return b}catch(y){throw Le(c),y}}async action(e,r,s={}){return this.assertOpen(),await this.rpc(e.__lunoraRef,r,s.shardKey)}async importRows(e,r,s={}){this.assertOpen();let i=Math.max(1,Math.trunc(s.chunkSize??500)),n=s.toArgs??(h=>({rows:h})),o=r.length,c=0,u=0;for(let h=0;h<o;h+=i){let d=r.slice(h,h+i),l=u;await this.mutation(e,n(d),{...s.importId===void 0?{}:{mutationId:`${s.importId}:${String(l)}`},shardKey:s.shardKey}),u+=1,c+=d.length,s.onProgress?.({done:c,total:o})}return{chunks:u,imported:c}}async shardTraffic(e){this.assertOpen();let r=await this.adminFetch(ms,"POST",{table:e});return{failed:r.failed??0,ok:r.ok??0,shards:r.shards??[]}}async listScheduledJobs(){return this.assertOpen(),(await this.adminFetch(ys,"GET")).records??[]}async schedulerStatus(){this.assertOpen();let e=await this.adminFetch(bs,"GET");return{backlog:e.backlog??0,inFlight:e.inFlight??0,pools:e.pools??[]}}async cancelScheduledJob(e){return this.assertOpen(),{cancelled:(await this.adminFetch(gs,"POST",{id:e})).cancelled===!0}}async listDeadJobs(){return this.assertOpen(),(await this.adminFetch(Ss,"GET")).records??[]}async retryDeadJob(e){return this.assertOpen(),{retried:(await this.adminFetch(ws,"POST",{id:e})).retried===!0}}async removeDeadJob(e){return this.assertOpen(),{removed:(await this.adminFetch(Cs,"POST",{id:e})).removed===!0}}async listWorkflowInstances(e){this.assertOpen();let r=new URLSearchParams({name:e.name});e.status!==void 0&&r.set("status",e.status),e.page!==void 0&&r.set("page",String(e.page)),e.perPage!==void 0&&r.set("perPage",String(e.perPage));let s=await this.adminFetch(`${ks}?${r.toString()}`,"GET");return{configured:s.configured,instances:s.instances??[],page:s.page??1,perPage:s.perPage??e.perPage??0,totalCount:s.totalCount}}async getWorkflowInstance(e){this.assertOpen();let r=new URLSearchParams({id:e.id,name:e.name}),s=await this.adminFetch(`${Is}?${r.toString()}`,"GET");return{createdOn:s.createdOn,endedOn:s.endedOn,error:s.error,id:s.id??e.id,output:s.output,params:s.params,startedOn:s.startedOn,status:s.status??"unknown",steps:s.steps??[]}}async setWorkflowInstanceStatus(e){return this.assertOpen(),{status:(await this.adminFetch(Es,"POST",{action:e.action,id:e.id,name:e.name})).status??"unknown"}}subscribeScheduledJobs(e){if(this.assertOpen(),this.WebSocketImpl===void 0)return()=>{};let r=V(fr(this.url),vs),s=ct(this.reconnectOptions),i={connectTimer:void 0,heartbeatTimer:void 0,lastFrameAt:0,socket:void 0},n,o=!1,c=a(()=>{o||(n=setTimeout(d,s.next()))},"a"),u=a(l=>{if(o||this.WebSocketImpl===void 0)return;let f=l===void 0?r:`${r}?token=${encodeURIComponent(l)}`;this.openManagedSocket(i,f,this.connectTimeoutMs,{onClose:a(()=>{c()},"onClose"),onMessage:a(m=>{try{let y=JSON.parse(typeof m.data=="string"?m.data:"");y.type==="jobs"&&Array.isArray(y.records)&&e(y.records)}catch{}},"onMessage"),onOpen:a(()=>{s.reset()},"onOpen")})},"o"),h=a(async l=>{let f;try{f=await l()}catch{c();return}u(f)},"c"),d=a(()=>{if(o||this.WebSocketImpl===void 0)return;let{wsToken:l}=this;if(typeof l=="function"){h(l).catch(()=>{});return}u(l)},"d");return d(),()=>{o=!0,n!==void 0&&clearTimeout(n),i.connectTimer!==void 0&&(clearTimeout(i.connectTimer),i.connectTimer=void 0),this.stopHeartbeat(i),i.socket?.close()}}async listFunctions(){return this.assertOpen(),(await this.adminFetch(Ps,"GET")).functions??[]}async getCronJobs(){return this.assertOpen(),(await this.adminFetch(Rs,"GET")).jobs??[]}async runCronJob(e){this.assertOpen();let r=await this.adminFetch(As,"POST",{name:e});return{name:r.name??e,ran:r.ran===!0}}async fetchOpenApi(){return this.assertOpen(),await this.adminFetch(Fs,"GET")}async fetchOpenRpc(){return this.assertOpen(),await this.adminFetch(Ms,"GET")}async listStorageObjects(e={}){this.assertOpen();let r=T(dt,{bucket:e.bucket,cursor:e.cursor,limit:e.limit,prefix:e.prefix}),s=await this.adminFetch(r,"GET");return{cursor:s.cursor,objects:s.objects??[]}}async deleteStorageObject(e,r){this.assertOpen();let s=`${dt}?key=${encodeURIComponent(e)}${ht(r?.bucket)}`,i=await this.adminFetch(s,"DELETE");return{deleted:i.deleted??!0,key:i.key??e}}async listStorageBuckets(){return this.assertOpen(),(await this.adminFetch(Os,"GET")).buckets??[]}async uploadStorageObject(e){this.assertOpen();let r=`${dt}?key=${encodeURIComponent(e.key)}${ht(e.bucket)}`,s=await this.adminFetch(r,"PUT",e.body,e.contentType);return{etag:s.etag,key:s.key??e.key}}async signedStorageUrl(e,r){this.assertOpen();let s=r?.expiresInSeconds,i=s===void 0?"":`&expiresIn=${encodeURIComponent(s.toString())}`,n=`${Ts}?key=${encodeURIComponent(e)}${i}${ht(r?.bucket)}`,o=await this.adminFetch(n,"GET");if(typeof o.url!="string")throw new TypeError("LunoraClient: storage URL endpoint returned no `url`");return o.url}async listGlobalTables(){return this.assertOpen(),await this.adminFetch(xs,"GET")}async readGlobalTablePage(e){this.assertOpen();let r=new URLSearchParams({table:e.table});return e.limit!==void 0&&r.set("limit",String(e.limit)),e.offset!==void 0&&r.set("offset",String(e.offset)),e.filters!==void 0&&e.filters.length>0&&r.set("filters",JSON.stringify(e.filters)),await this.adminFetch(`${_s}?${r.toString()}`,"GET")}async facetGlobalColumn(e){this.assertOpen();let r=new URLSearchParams({column:e.column,table:e.table});return e.limit!==void 0&&r.set("limit",String(e.limit)),e.filters!==void 0&&e.filters.length>0&&r.set("filters",JSON.stringify(e.filters)),await this.adminFetch(`${Ls}?${r.toString()}`,"GET")}async listVectorIndexes(){return this.assertOpen(),(await this.adminFetch(Qs,"GET")).indexes??[]}async queryVectorIndex(e){return this.assertOpen(),(await this.adminFetch(Ds,"POST",e)).matches??[]}async queryLogArchive(e={}){this.assertOpen();let r=await this.adminFetch(Us,"POST",e);return{nextCursor:r.nextCursor,rows:r.rows??[]}}async listKvNamespaces(){return this.assertOpen(),(await this.adminFetch(qs,"GET")).namespaces??[]}async listKvKeys(e){this.assertOpen();let r=T(Ns,{cursor:e.cursor,limit:e.limit,namespace:e.namespace,prefix:e.prefix});return await this.adminFetch(r,"GET")}async getKvValue(e){this.assertOpen();let r=T(lt,{key:e.key,namespace:e.namespace});return await this.adminFetch(r,"GET")}async putKvValue(e){this.assertOpen(),await this.adminFetch(lt,"PUT",e)}async deleteKvKey(e){this.assertOpen();let r=T(lt,{key:e.key,namespace:e.namespace});await this.adminFetch(r,"DELETE")}async listAuthUsers(e={}){this.assertOpen();let r=T(Ks,{filterField:e.filterField,filterValue:e.filterValue,limit:e.limit,offset:e.offset,search:e.search,searchField:e.searchField,sortBy:e.sortBy,sortDirection:e.sortDirection});return await this.adminFetch(r,"GET")}async createAuthUser(e){return await this.adminFetch(js,"POST",e)}async setAuthUserRole(e){return await this.adminFetch($s,"POST",e)}async banAuthUser(e){return await this.adminFetch(Hs,"POST",e)}async unbanAuthUser(e){return await this.adminFetch(zs,"POST",e)}async setAuthUserPassword(e){await this.adminFetch(Ws,"POST",e)}async removeAuthUser(e){await this.adminFetch(Vs,"POST",e)}async impersonateAuthUser(e){return await this.adminFetch(Gs,"POST",e)}async revokeAuthSession(e){await this.adminFetch(Js,"POST",e)}async revokeAuthUserSessions(e){await this.adminFetch(Xs,"POST",e)}async getAuthCapabilities(){return await this.adminFetch(Ys,"GET")}async updateAuthUser(e){return await this.adminFetch(Zs,"POST",e)}async listAuthAccounts(e){return await this.adminFetch(T(ei,{userId:e.userId}),"GET")}async unlinkAuthAccount(e){await this.adminFetch(ti,"POST",e)}async listAuthPasskeys(e){return await this.adminFetch(T(ri,{userId:e.userId}),"GET")}async deleteAuthPasskey(e){await this.adminFetch(si,"POST",e)}async disableAuthTwoFactor(e){await this.adminFetch(ii,"POST",e)}async listAuthOrganizations(e={}){return await this.adminFetch(T(ni,{limit:e.limit,offset:e.offset}),"GET")}async listAuthOrgMembers(e){let r=T(ai,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async listAuthOrgInvitations(e){let r=T(oi,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async removeAuthOrgMember(e){await this.adminFetch(ci,"POST",e)}async cancelAuthOrgInvitation(e){await this.adminFetch(ui,"POST",e)}async getAuthConfig(){return await this.adminFetch(hi,"GET")}async createAuthOrganization(e){return await this.adminFetch(di,"POST",e)}async updateAuthOrganization(e){return await this.adminFetch(li,"POST",e)}async deleteAuthOrganization(e){await this.adminFetch(fi,"POST",e)}async addAuthOrgMember(e){return await this.adminFetch(pi,"POST",e)}async inviteAuthOrgMember(e){return await this.adminFetch(mi,"POST",e)}async setAuthOrgMemberRole(e){return await this.adminFetch(yi,"POST",e)}async listAuthOrgTeams(e){let r=T(bi,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async createAuthOrgTeam(e){return await this.adminFetch(vi,"POST",e)}async updateAuthOrgTeam(e){return await this.adminFetch(gi,"POST",e)}async removeAuthOrgTeam(e){await this.adminFetch(Si,"POST",e)}async listAuthOrgTeamMembers(e){let r=T(wi,{limit:e.limit,offset:e.offset,teamId:e.teamId});return await this.adminFetch(r,"GET")}async addAuthOrgTeamMember(e){return await this.adminFetch(Ci,"POST",e)}async removeAuthOrgTeamMember(e){await this.adminFetch(ki,"POST",e)}async listAuthOrgRoles(e){let r=T(Ii,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async createAuthOrgRole(e){return await this.adminFetch(Ei,"POST",e)}async updateAuthOrgRole(e){return await this.adminFetch(Ti,"POST",e)}async deleteAuthOrgRole(e){await this.adminFetch(Oi,"POST",e)}async listAuthSessions(e={}){this.assertOpen();let r=T(Bs,{limit:e.limit,offset:e.offset,userId:e.userId});return await this.adminFetch(r,"GET")}subscribe(e,r,s,i={}){this.assertOpen();let n=r??{},o=_.key(e.__lunoraRef,n,i.shardKey),c=this.subscriptions.get(o),u=s,h=i.onError;if(!c){this.nextSubId+=1;let l=`sub_${this.nextSubId.toString()}`,f=B(n),m=this.takeHydratedCache(e.__lunoraRef,f,i.shardKey);c={acked:!1,args:n,argsKey:f,callbacks:new Set,checkpointCallbacks:new Set,errorCallbacks:new Set,fn:e,id:l,lastValue:m?.value,optimisticLayers:[],serverBase:m?.value,serverCursor:m?.serverCursor,shardKey:i.shardKey,...m?.serverEpoch===void 0?{}:{serverEpoch:m.serverEpoch}},this.subscriptions.add(c)}if(c.callbacks.add(u),h&&c.errorCallbacks.add(h),i.onCheckpoint&&c.checkpointCallbacks.add(i.onCheckpoint),c.lastValue!==void 0)try{u(c.lastValue)}catch{}this.ensureSocket(i.shardKey),this.sendSubscribeIfOpen(c);let d=c;return()=>{d.callbacks.delete(u),h&&d.errorCallbacks.delete(h),i.onCheckpoint&&d.checkpointCallbacks.delete(i.onCheckpoint),d.callbacks.size===0&&(this.sendOrQueueUnsubscribe(d.shardKey,d.id,"unsubscribe"),this.subscriptions.remove(d))}}subscribeShape(e,r,s={}){this.assertOpen(),this.nextShapeId+=1;let i=`shape_${this.nextShapeId.toString()}`,n={args:e.args,callbacks:new Set([r]),errorCallbacks:s.onError?new Set([s.onError]):new Set,id:i,name:e.name,onCheckpoint:s.onCheckpoint,rows:new Map,shardKey:s.shardKey,wireArgs:e.args===void 0?void 0:G(e.args,`shape args for '${e.name}'`)};return this.shapeSubscriptions.set(i,n),this.ensureSocket(s.shardKey),this.sendShapeSubscribeIfOpen(n),()=>{this.shapeSubscriptions.delete(i),this.sendOrQueueUnsubscribe(n.shardKey,i,"shape_unsubscribe")}}stream(e,r,s={}){if(this.assertOpen(),this.WebSocketImpl===void 0)throw new p("INTERNAL","LunoraClient: streams require a WebSocket implementation");this.nextStreamId+=1;let i=`stream_${this.nextStreamId.toString()}`,{shardKey:n}=s,o=r??{},{handle:c,iterable:u}=Pe({maxBuffer:s.maxBuffer,onCancel:a(()=>{let l=this.getConnection(n);l&&F(l,{id:i,type:"unsubscribe"}),this.streams.delete(i)},"onCancel")});this.ensureSocket(n);let h=this.getConnection(n),d={id:i,query:{args:G(o,`stream args for '${e.__lunoraRef}'`),functionPath:e.__lunoraRef,shardKey:n},type:"stream"};if(this.streams.set(i,{durable:s.durable===!0,handle:c,lastSeq:0,message:d,shardKey:n}),!(h?.wsState==="open"&&F(h,d))&&h){for(h.pendingStreams=h.pendingStreams??[];h.pendingStreams.length>=ps;){let l=h.pendingStreams.shift()?.id,f=l?this.streams.get(l):void 0;f&&(f.handle.fail(new p("STREAM_QUEUE_OVERFLOW","stream-start frame evicted while socket was unreachable")),this.streams.delete(l))}h.pendingStreams.push(d)}return u}httpStream(e,r,s={}){if(this.closed)throw new p("CLIENT_CLOSED","LunoraClient is closed");if(!this.fetchImpl)throw new p("INTERNAL","LunoraClient: no `fetch` implementation available");let i={...this.authToken?{authorization:`Bearer ${this.authToken}`}:{},...s.headers};return ir(e,r,{baseUrl:this.url,fetch:this.fetchImpl,headers:i,maxBuffer:s.maxBuffer,signal:s.signal})}close(){this.closed=!0,this.outboxLeaderRelease?.(),this.outboxLeaderRelease=void 0;for(let e of this.streams.values())e.handle.fail(new p("CLIENT_CLOSED","LunoraClient closed"));this.streams.clear();for(let e of this.connections.values())this.teardownConnection(e);this.offlineQueue.clear(),this.queuedIdentities.clear(),this.cacheFlushTimer!==void 0&&(clearTimeout(this.cacheFlushTimer),this.cacheFlushTimer=void 0),this.pendingCacheWrites.size>0&&this.flushQueryCacheWrites().catch(()=>{}),this.authTokenListeners.clear(),this.statusListeners.clear(),this.tokenExpiredListeners.clear(),this.mutationSettledListeners.clear(),this.pendingChangeListeners.clear(),this.whisperHandlers.clear(),this.shapeSubscriptions.clear(),this.pokeBuffers.clear(),this.tabCoordinator?.stop(),this.tabCoordinator=void 0}assertOpen(){if(this.closed)throw new p("INTERNAL","LunoraClient is closed")}teardownConnection(e){if(e.reconnectTimer!==void 0&&(clearTimeout(e.reconnectTimer),e.reconnectTimer=void 0),e.connectTimer!==void 0&&(clearTimeout(e.connectTimer),e.connectTimer=void 0),this.stopHeartbeat(e),e.socket){try{e.socket.close()}catch{}e.socket=void 0}e.wsState="closed"}createTabCoordinator(){let e=`lunora-bridge::${this.url}::${this.identityFingerprint()??"anon"}`;return new Oe({channelName:e,onBecomeLeader:a(()=>{for(let r of this.subscriptions.all())this.ensureSocket(r.shardKey),this.sendSubscribeIfOpen(r);this.tabCoordinator?.broadcastConnectionStatus(this.computeStatus(),this.identityFingerprint())},"onBecomeLeader"),onStopBeingLeader:a(()=>{for(let[r,s]of this.connections)this.teardownConnection(s),this.connections.delete(r);this.leaderStatus=void 0,this.leaderWasEverConnected=!1},"onStopBeingLeader"),onConnectionStatus:a((r,s)=>{if(s!==void 0&&s!==this.identityFingerprint())return;let i=r==="connected"&&this.leaderStatus!=="connected";this.leaderStatus=r,r==="connected"&&(this.leaderWasEverConnected=!0),this.emitConnectionStatus(),i&&this.flushAllOfflineQueues()},"onConnectionStatus"),onSubscriptionData:a((r,s,i,n,o)=>{if(o!==void 0&&o!==this.identityFingerprint())return;let c=this.subscriptions.get(r);c&&(c.serverBase=s,i!==void 0&&(c.serverCursor=i,n!==void 0&&(c.serverEpoch=n),Re(c,i)),te(c,he(s,c.optimisticLayers)))},"onSubscriptionData"),onSubscriptionError:a((r,s)=>{let i=this.subscriptions.get(r);i&&Qe(i.errorCallbacks,s)},"onSubscriptionError"),onSubscriptionSettled:a((r,s,i,n,o,c)=>{if(c!==void 0&&c!==this.identityFingerprint())return;let u=this.subscriptions.get(r);if(u){this.ackAndAdvanceCursor(u,s,i),n!==void 0&&o===this.clientId&&(u.lastMutationId=Math.max(u.lastMutationId??0,n));for(let h of u.checkpointCallbacks)h({checkpoint:u.serverCursor,mutationId:u.lastMutationId})}},"onSubscriptionSettled")})}async enqueueOfflineMutation(e,r,s,i,n,o,c){let u=this.identityFingerprint();if(this.outbox){this.outboxMutationCounter+=1;let h=this.outboxMutationCounter;try{await this.outbox.enqueue({args:r,clientId:this.clientId,functionPath:e.__lunoraRef,idempotencyKey:`${this.clientId}:${String(h)}`,identity:u,mutationId:h,shardKey:s})}catch(d){throw Le(n),d instanceof Error?d:new Error(String(d))}for(let d of o)d(void 0);return}return new Promise((h,d)=>{let l={args:r,functionPath:e.__lunoraRef,liveAwaiter:!0,id:i,clientId:this.clientId,identity:u,precondition:c,onCommit:a(f=>{for(let m of o)m(f)},"onCommit"),reject:a(f=>{this.queuedIdentities.delete(i),Le(n),d(f instanceof Error?f:new Error(String(f)))},"reject"),resolve:h,shardKey:s};this.offlineQueue.enqueue(l),this.queuedOfflineShardKeys.add(s),l.id!==void 0&&this.queuedIdentities.set(l.id,u)})}async hydratePersistedQueue(){try{let e=await this.offlineQueue.hydrate();for(let r of e)this.queuedOfflineShardKeys.add(r),this.ensureSocket(r)}catch{}}hydrateAsOutboxLeader(){let e=a(()=>{this.hydratePersistedQueue().catch(()=>{})},"e"),r=globalThis.navigator?.locks;if(!r){e();return}r.request(`lunora:outbox-leader:${this.url}`,()=>(this.closed||e(),new Promise(s=>{if(this.closed){s();return}this.outboxLeaderRelease=s}))).catch(e)}async hydrateQueryCache(){if(this.queryCache)try{let e=await this.queryCache.load();for(let{key:r,...s}of e){if(ot(this.persistenceVersion,s.version)){this.queryCache.remove(r).catch(()=>{});continue}this.hydratedQueryCache.set(r,s)}}catch{}}takeHydratedCache(e,r,s){let i=_e(e,r,s),n=this.hydratedQueryCache.get(i);if(n!==void 0)return this.hydratedQueryCache.delete(i),n.identity===this.identityFingerprint()?n:void 0}persistQueryValue(e){let r=e.serverBase;if(!this.queryCache||r===void 0)return;let s=_e(e.fn.__lunoraRef,e.argsKey,e.shardKey);this.pendingCacheWrites.set(s,{identity:this.identityFingerprint(),serverCursor:e.serverCursor,ts:Date.now(),value:r,...e.serverEpoch===void 0?{}:{serverEpoch:e.serverEpoch},...this.persistenceVersion===void 0?{}:{version:this.persistenceVersion}}),this.cacheFlushTimer??=setTimeout(()=>{this.flushQueryCacheWrites().catch(()=>{})},fs)}async flushQueryCacheWrites(){this.cacheFlushTimer=void 0;let{queryCache:e}=this;if(!e){this.pendingCacheWrites.clear();return}let r=[...this.pendingCacheWrites.entries()];this.pendingCacheWrites.clear(),await Promise.allSettled(r.map(([s,i])=>e.put(s,i)))}computeStatus(){if(this.tabCoordinator&&!this.tabCoordinator.isLeader())return this.leaderStatus??"idle";let e=[...this.connections.values()];return e.length===0?"idle":e.some(r=>r.wsState==="open")?"connected":e.some(r=>r.wsState==="connecting")?"connecting":"offline"}emitConnectionStatus(){let e=this.computeStatus();e!==this.lastStatus&&(this.lastStatus=e,this.statusListeners.emit(e),this.tabCoordinator?.isLeader()&&this.tabCoordinator.broadcastConnectionStatus(e,this.identityFingerprint()))}emitItemSettled(e,r,s){this.mutationSettledListeners.emit({args:e.args,code:s===void 0?void 0:s.code,error:s,functionPath:e.functionPath,hadAwaiter:e.liveAwaiter??!1,id:e.id??"",shardKey:e.shardKey,status:r})}applyOptimisticUpdates(e,r,s,i){let n=[],o=[];if(!i)return{confirms:n,rollbacks:o};let c=_.key(e,r,s),u=this.subscriptions.get(c);if(u){let h=at(u,i);h&&(n.push(h.confirm),o.push(h.rollback))}return{confirms:n,rollbacks:o}}applyOptimisticUpdate(e,r,s,i,n){let{confirms:o,rollbacks:c,store:u}=nr(this.subscriptions,s);try{e(u,r)}catch{Le(c);return}i.push(...c),n.push(...o)}getConnection(e){return this.connections.get(C(e))}sendOrQueueUnsubscribe(e,r,s){let i=this.getConnection(e);i&&!F(i,{id:r,type:s})&&i.pendingUnsubscribes.push({id:r,type:s})}connectionGateState(e){if(this.tabCoordinator&&!this.tabCoordinator.isLeader()){let s="idle";return this.leaderStatus==="connected"?s="open":this.leaderStatus==="connecting"&&(s="connecting"),{hasSocket:!1,wasEverConnected:this.leaderWasEverConnected,wsState:s}}let r=this.getConnection(e);return{hasSocket:r?.socket!==void 0,wasEverConnected:r?.wasEverConnected??!1,wsState:r?.wsState??"idle"}}getOrCreateConnection(e){let r=C(e),s=this.connections.get(r);return s||(s={connectTimer:void 0,heartbeatTimer:void 0,lastFrameAt:0,pendingUnsubscribes:[],reconnect:ct(this.reconnectOptions),reconnectTimer:void 0,shardKey:e,socket:void 0,wasEverConnected:!1,wsState:"idle"},this.connections.set(r,s)),s}wsUrlFor(e,r){let s=[];if(e!==void 0&&s.push(`shard=${encodeURIComponent(e)}`),r!==void 0&&s.push(`token=${encodeURIComponent(r)}`),s.length===0)return this.wsUrl;let i=this.wsUrl.includes("?")?"&":"?";return`${this.wsUrl}${i}${s.join("&")}`}rpcRequestHeaders(e,r){let s={"content-type":"application/json"},i=this.shardCursors.get(this.cursorKeyFor(r));if(i!==void 0&&(s["x-lunora-min-seq"]=i.toString()),this.authToken&&(s.authorization=`Bearer ${this.authToken}`),e.mutationId&&(s["x-lunora-mutation-id"]=e.mutationId),(e.clientId!==void 0||e.mutationId!==void 0)&&(s["x-lunora-client-id"]=e.clientId??this.clientId),e.clientSeq!==void 0&&(s["x-lunora-client-seq"]=e.clientSeq.toString()),e.attachBookmark){let n=this.bookmark.get();n&&(s["x-d1-bookmark"]=n)}return s}async rpc(e,r,s,i={}){if(!this.fetchImpl)throw new p("INTERNAL","LunoraClient: no `fetch` implementation available");let n=this.rpcRequestHeaders(i,s),o=await this.fetchImpl(V(this.url,os),{body:JSON.stringify({args:G(r,`args for '${e}'`),functionPath:e,shardKey:s}),headers:n,method:"POST"});if(i.captureBookmark){let u=o.headers.get("x-d1-bookmark");u&&this.bookmark.set(u)}let c;try{c=await o.json()}catch{let u=o.statusText?` ${o.statusText}`:"";throw new p("INTERNAL",`LunoraClient: response was not JSON (status ${o.status.toString()}${u})`)}if("error"in c)throw de(c.error);if(!o.ok){let u=o.statusText?` ${o.statusText}`:"";throw new p("INTERNAL",`LunoraClient: request failed (status ${o.status.toString()}${u})`)}return i.onMutationAck?.(c.lastMutationId),i.onCommitCursor?.(c.commitCursor),this.learnDefaultShardKey(o,s),this.recordShardCursor(s,c.commitCursor),S(c.result)}async adminFetch(e,r,s,i){if(!this.fetchImpl)throw new p("INTERNAL","LunoraClient: no `fetch` implementation available");let n={};this.authToken&&(n.authorization=`Bearer ${this.authToken}`);let o=s instanceof ArrayBuffer||s instanceof Blob,c;s===void 0?c=void 0:o?(c=s,i!==void 0&&(n["content-type"]=i)):(c=JSON.stringify(s),n["content-type"]="application/json");let u=await this.fetchImpl(V(this.url,e),{body:c,headers:n,method:r}),h;try{h=await u.json()}catch{let d=u.statusText?` ${u.statusText}`:"";throw new p("INTERNAL",`LunoraClient: response was not JSON (status ${u.status.toString()}${d})`)}if(typeof h=="object"&&h!==null&&"error"in h){let d=h.error,l=new Error(d.message??"admin request failed");throw l.code=d.code,l}if(!u.ok){let d=u.statusText?` ${u.statusText}`:"";throw new p("INTERNAL",`LunoraClient: admin request failed (status ${u.status.toString()}${d})`)}return h}effectiveConnectionContext(e){let r=this.connectionContextHolders.get(e);return r&&r.length>0?r[r.length-1]?.context:this.connectionContexts.get(e)??this.defaultConnectionContext}refreshConnectionContext(e){let r=this.connections.get(e);r?.wsState==="open"&&this.sendConnectEnvelope(r)}sendConnectEnvelope(e){let r=this.effectiveConnectionContext(C(e.shardKey));F(e,{caps:Ai,clientId:this.clientId,id:"connect",type:"connect",...r===void 0?{}:{context:r}})}resendShapeSubscriptions(e){for(let r of this.shapeSubscriptions.values())C(r.shardKey)===C(e)&&this.sendShapeSubscribeIfOpen(r)}ensureSocket(e){if(this.closed||this.WebSocketImpl===void 0||this.tabCoordinator&&!this.tabCoordinator.isLeader())return;let r=this.getOrCreateConnection(e);if(!(r.wsState==="open"||r.wsState==="connecting")){if(r.wsState="connecting",this.emitConnectionStatus(),typeof this.wsToken=="function"){this.openSocketWithProvidedToken(r,e,this.wsToken).catch(()=>{});return}this.openSocket(r,e,this.wsToken)}}async openSocketWithProvidedToken(e,r,s){let i;try{i=await s()}catch{this.handleDisconnect(e);return}this.closed||this.WebSocketImpl===void 0||e.wsState!=="connecting"||e.socket!==void 0||this.openSocket(e,r,i)}openManagedSocket(e,r,s,i){let{WebSocketImpl:n}=this;if(n===void 0)throw new p("INTERNAL","no WebSocket implementation available");let o=new n(r);e.socket=o;let c=a(()=>{this.stopHeartbeat(e),e.connectTimer!==void 0&&(clearTimeout(e.connectTimer),e.connectTimer=void 0),e.socket===o&&(e.socket=void 0)},"a"),u=a(h=>{c(),i.onClose(h)},"o");s>0&&(e.connectTimer=setTimeout(()=>{if(e.connectTimer=void 0,e.socket===o){try{o.close()}catch{}u()}},s)),o.addEventListener("open",()=>{e.socket===o&&(e.connectTimer!==void 0&&(clearTimeout(e.connectTimer),e.connectTimer=void 0),e.lastFrameAt=Date.now(),i.onOpen(),this.startHeartbeat(e,u))}),o.addEventListener("message",h=>{e.socket===o&&(e.lastFrameAt=Date.now(),i.onMessage(h))}),o.addEventListener("close",h=>{e.socket===o&&u(h)}),o.addEventListener("error",()=>{e.socket===o&&u()})}openSocket(e,r,s){this.WebSocketImpl!==void 0&&this.openManagedSocket(e,this.wsUrlFor(r,s),this.connectTimeoutMs,{onClose:a(i=>{i?.code===4001&&this.notifyTokenExpired(),this.handleDisconnect(e)},"onClose"),onMessage:a(i=>{this.handleServerMessage(i.data,r)},"onMessage"),onOpen:a(()=>{e.wsState="open",e.wasEverConnected=!0,e.reconnect.reset(),this.emitConnectionStatus(),this.sendConnectEnvelope(e),this.markShardPendingAck(r);for(let n of this.subscriptions.all())C(n.shardKey)===C(r)&&this.sendSubscribeIfOpen(n);if(this.resendShapeSubscriptions(r),e.pendingUnsubscribes.length>0){let n=e.pendingUnsubscribes;e.pendingUnsubscribes=[];for(let{id:o,type:c}of n)F(e,{id:o,type:c})}if(e.pendingStreams&&e.pendingStreams.length>0){let n=e.pendingStreams;e.pendingStreams=[];for(let o of n)F(e,o)}let i=this.whisperHandlers.get(C(r));if(i)for(let n of i.keys())F(e,{topic:n,type:"whisper_subscribe"});this.flushOfflineQueue(r).catch(()=>{})},"onOpen")})}handleDisconnect(e){if(this.closed||e.wsState==="idle"||e.wsState==="closed")return;this.stopHeartbeat(e),e.connectTimer!==void 0&&(clearTimeout(e.connectTimer),e.connectTimer=void 0),e.socket=void 0,e.wsState="idle",this.emitConnectionStatus(),this.markShardPendingAck(e.shardKey);let r=new Set((e.pendingStreams??[]).map(i=>i.id));for(let[i,n]of this.streams)if(!(C(n.shardKey)!==C(e.shardKey)||r.has(i))){if(n.durable){let o={...n.message,sinceChunk:n.lastSeq};n.message=o,e.pendingStreams=[...(e.pendingStreams??[]).filter(c=>c.id!==i),o];continue}n.handle.fail(new p("STREAM_DISCONNECTED","stream terminated: WebSocket disconnected")),this.streams.delete(i)}if(this.WebSocketImpl===void 0)return;let s=e.reconnect.next();e.reconnectTimer=setTimeout(()=>{e.reconnectTimer=void 0,this.ensureSocket(e.shardKey)},s)}startHeartbeat(e,r){this.stopHeartbeat(e),!(this.heartbeatIntervalMs<=0)&&(e.heartbeatTimer=setInterval(()=>{if(!e.socket)return;let{socket:s}=e;if(Date.now()-e.lastFrameAt>this.heartbeatIntervalMs*2.5){try{s.close()}catch{}r();return}try{s.send(hs)}catch{}},this.heartbeatIntervalMs))}stopHeartbeat(e){e.heartbeatTimer!==void 0&&(clearInterval(e.heartbeatTimer),e.heartbeatTimer=void 0)}markShardPendingAck(e){let r=C(e);for(let s of this.subscriptions.all())C(s.shardKey)===r&&(s.acked=!1)}sendSubscribeIfOpen(e){let r=this.getConnection(e.shardKey);if(r?.wsState!=="open"||e.acked)return;let s=e.fn.__lunoraTable??e.fn.__lunoraRef;F(r,{id:e.id,query:{args:O(e.args),functionPath:e.fn.__lunoraRef,table:s,...e.serverCursor===void 0?{}:{sinceSeq:e.serverCursor},...e.serverEpoch===void 0?{}:{sinceEpoch:e.serverEpoch}},type:"subscribe"})}sendShapeSubscribeIfOpen(e){let r=this.getConnection(e.shardKey);r?.wsState==="open"&&F(r,{id:e.id,shape:{name:e.name,...e.wireArgs===void 0?{}:{args:e.wireArgs}},type:"shape_subscribe",...e.serverCursor===void 0?{}:{sinceCheckpoint:e.serverCursor},...e.serverEpoch===void 0?{}:{sinceEpoch:e.serverEpoch}})}handleServerMessage(e,r){let s=xi(e);if(s===void 0)return;let i;try{i=JSON.parse(s)}catch{return}switch(i.type){case"ack":{let n=this.subscriptions.getById(i.id);n&&(n.acked=!0);return}case"chunk":{let{data:n,id:o,seq:c}=i,u=this.streams.get(o);u&&typeof c=="number"&&(u.lastSeq=c,u.durable=!0),u?.handle.push(S(n));return}case"complete":{this.handleCompleteMessage(i.id);return}case"data":case"delta":{this.handleDataMessage(i);return}case"error":{this.handleErrorMessage(i);break}case"pokeEnd":{this.handlePokeEnd(i);break}case"pokePart":{this.handlePokePart(i);break}case"pokeStart":{this.handlePokeStart(i);break}case"resume":{this.handleResumeMessage(i);break}case"settled":{this.handleSettledMessage(i);break}case"whisper":{this.dispatchWhisper(i,r);break}}}handleErrorMessage(e){if(e.error?.code==="TOKEN_EXPIRED"){this.notifyTokenExpired();return}let{id:r}=e,s=r===void 0?void 0:this.streams.get(r);if(s&&r!==void 0){s.handle.fail(Fi(e)),this.streams.delete(r);return}let i=r===void 0?void 0:this.subscriptions.getById(r);if(i){Qe(i.errorCallbacks,pr(e));return}let n=r===void 0?void 0:this.shapeSubscriptions.get(r);n&&Qe(n.errorCallbacks,pr(e))}handlePokeStart(e){as(this.pokeBuffers,t.MAX_POKE_BUFFERS),this.pokeBuffers.set(e.pokeId,{baseCheckpoint:e.baseCheckpoint,epoch:e.epoch,lastMutationId:new Map,parts:new Map})}handlePokePart(e){let r=this.pokeBuffers.get(e.pokeId);if(!r)return;let s=r.parts.get(e.shapeId)??[];for(let i of e.rowsPatch)s.push(i.value===void 0?i:{...i,value:S(i.value)});r.parts.set(e.shapeId,s),e.lastMutationId!==void 0&&r.lastMutationId.set(e.shapeId,e.lastMutationId)}handlePokeEnd(e){let r=this.pokeBuffers.get(e.pokeId);if(r){this.pokeBuffers.delete(e.pokeId);for(let[s,i]of r.parts){let n=this.shapeSubscriptions.get(s);if(!n)continue;let o=r.epoch!==void 0&&n.serverEpoch!==void 0&&r.epoch!==n.serverEpoch,c=r.baseCheckpoint!==void 0&&n.serverCursor!==void 0&&n.serverCursor!==r.baseCheckpoint;if(o||c){n.rows.clear(),n.serverCursor=void 0,n.serverEpoch=void 0,this.emitShapeRows(n),this.sendShapeSubscribeIfOpen(n);continue}us(n.rows,i),e.checkpoint!==void 0&&(n.serverCursor=e.checkpoint),e.epoch!==void 0&&(n.serverEpoch=e.epoch);let u=r.lastMutationId.get(s);u!==void 0&&(n.lastMutationId=u),this.emitShapeRows(n),n.onCheckpoint?.({checkpoint:n.serverCursor,mutationId:n.lastMutationId})}}}emitShapeRows(e){let r=[...e.rows.values()];for(let s of e.callbacks)try{s(r)}catch{}}handleDataMessage(e){let{id:r}=e,s=r?this.subscriptions.getById(r):void 0;if(!s)return;let i=this.resolveDataPayload(e,s);if(s.serverBase=i,e.cursor!==void 0&&(s.serverCursor=e.cursor),e.epoch!==void 0&&(s.serverEpoch=e.epoch),e.lastMutationId!==void 0){s.lastMutationId=Math.max(s.lastMutationId??0,e.lastMutationId);for(let n of s.checkpointCallbacks)n({checkpoint:s.serverCursor,mutationId:s.lastMutationId})}if(this.persistQueryValue(s),Re(s,s.serverCursor),te(s,he(i,s.optimisticLayers)),this.tabCoordinator?.isLeader()){let n=_.key(s.fn.__lunoraRef,s.args,s.shardKey);this.tabCoordinator.broadcastSubscriptionData(n,i,s.serverCursor,s.serverEpoch,this.identityFingerprint())}}handleResumeMessage(e){let r=this.subscriptions.getById(e.id);r&&this.ackAndAdvanceCursor(r,e.cursor,e.epoch)}handleSettledMessage(e){let r=this.subscriptions.getById(e.id);if(r){this.ackAndAdvanceCursor(r,e.cursor,e.epoch),e.lastMutationId!==void 0&&(r.lastMutationId=e.lastMutationId);for(let s of r.checkpointCallbacks)s({checkpoint:r.serverCursor,mutationId:r.lastMutationId});if(this.tabCoordinator?.isLeader()){let s=_.key(r.fn.__lunoraRef,r.args,r.shardKey);this.tabCoordinator.broadcastSubscriptionSettled(s,r.serverCursor,r.serverEpoch,r.lastMutationId,this.clientId,this.identityFingerprint())}}}ackAndAdvanceCursor(e,r,s){e.acked=!0,(r!==void 0&&r!==e.serverCursor||s!==void 0&&s!==e.serverEpoch)&&(r!==void 0&&(e.serverCursor=r),s!==void 0&&(e.serverEpoch=s),this.persistQueryValue(e),Re(e,e.serverCursor)&&te(e,he(e.serverBase,e.optimisticLayers)))}resolveDataPayload(e,r){if("data"in e&&e.data!==void 0)return S(e.data);let s=S(e.delta);if(er(s)&&r.serverBase!==void 0){let i=tr(r.serverBase,s);if(i!==void 0)return i}return s}dispatchWhisper(e,r){let s=this.whisperHandlers.get(C(r))?.get(e.topic);if(!s)return;let i=S(e.data);for(let n of s)try{n(i,e.from)}catch{}}notifyTokenExpired(){this.tokenExpiredListeners.emit()}handleCompleteMessage(e){let r=this.streams.get(e);if(r){r.handle.complete(),this.streams.delete(e);return}let s=this.subscriptions.getById(e);s&&(s.acked=!1,Qe(s.errorCallbacks,{code:"SUBSCRIPTION_CANCELLED",message:"subscription was cancelled by the server"}))}unpersist(e){e&&this.persistence?.remove(e).catch(r=>{re(this.onPersistenceError,"remove",r,e)})}identityFingerprint(){if(this.authSubject!==void 0)return this.authSubject===null?null:`subj:${this.authSubject}`;let e=this.authToken;return e===null?null:this.hashToken(e)}hashToken(e){let r=2166136261,s=5381;for(let i=0;i<e.length;i+=1){let n=e.charCodeAt(i);r^=n,r=Math.imul(r,16777619),s=Math.imul(s,33)+n}return`${e.length.toString(36)}:${(r>>>0).toString(36)}:${(s>>>0).toString(36)}`}isSameCredentialUnderTokenHash(e){if(e===null||e.startsWith("subj:"))return!1;let r=this.authToken;return r===null?!1:this.hashToken(r)===e}rejectQueuedForIdentityChange(){let e=this.offlineQueue.drain();for(let r of e){this.queuedIdentities.delete(r.id??""),this.unpersist(r.id);let s=new Error("offline mutation discarded: auth identity changed before replay");s.code="OFFLINE_IDENTITY_CHANGED",r.reject(s),this.emitItemSettled(r,"rejected",s)}this.clearQueryCacheForIdentityChange()}restampQueuedIdentity(e,r){for(let[s,i]of this.queuedIdentities)i===e&&this.queuedIdentities.set(s,r)}restampWatermarks(e,r){let s=e??"",i=this.clientWatermarks.get(s);if(i===void 0)return;this.clientWatermarks.delete(s);let n=r??"",o=this.clientWatermarks.get(n);if(o===void 0)this.clientWatermarks.set(n,i);else for(let[c,u]of i)o.set(c,u)}clearQueryCacheForIdentityChange(){this.cacheFlushTimer!==void 0&&(clearTimeout(this.cacheFlushTimer),this.cacheFlushTimer=void 0),this.pendingCacheWrites.clear(),this.hydratedQueryCache.clear(),this.queryCache?.clear().catch(()=>{})}flushAllOfflineQueues(){for(let e of this.queuedOfflineShardKeys)this.flushOfflineQueue(e).catch(()=>{})}async flushOfflineQueue(e){let r=this.offlineQueue.drainConflict();for(let h of r){this.unpersist(h.id),this.queuedIdentities.delete(h.id??"");let d=new Error("offline mutation skipped: precondition failed before replay");d.code="OFFLINE_PRECONDITION_FAILED",this.emitItemSettled(h,"rejected",d)}let s=C(e),i=this.offlineQueue.drain(h=>C(h.shardKey)===s);if(i.length===0)return;let n=this.identityFingerprint(),o=[];for(let h of i)this.passesReplayIdentityGate(h,n)&&o.push(h);if(o.length===0)return;let c=this.encodableOrSettleTerminal(o);if(c.length===0)return;if(c.length===1){await this.replaySequential(c);return}let u=[];for(let h=0;h<c.length;h+=ut){let d=c.slice(h,h+ut),l=await this.replayBatched(d);if(u.push(...l.requeue),l.stop){u.push(...c.slice(h+ut));break}}u.length>0&&this.offlineQueue.requeue(u)}encodableOrSettleTerminal(e){let r=[];for(let s of e)try{G(s.args,`args for '${s.functionPath}'`),r.push(s)}catch(i){this.settleReplayTerminal(s,i instanceof Error?i:new Error(String(i)))}return r}passesReplayIdentityGate(e,r){let s=e.id===void 0?void 0:this.queuedIdentities.get(e.id),i=s===void 0?e.identity:s;if(i!==void 0&&i!==r&&!this.isSameCredentialUnderTokenHash(i)){this.queuedIdentities.delete(e.id??""),this.unpersist(e.id);let n=new Error("offline mutation skipped: auth identity changed before replay");return n.code="OFFLINE_IDENTITY_CHANGED",e.reject(n),this.emitItemSettled(e,"rejected",n),!1}return this.queuedIdentities.delete(e.id??""),!0}settleReplaySuccess(e,r,s){this.unpersist(e.id),this.recordShardCursor(e.shardKey,s),e.onCommit?.(s),e.resolve(r),this.emitItemSettled(e,"committed")}cursorKeyFor(e){return e??this.defaultShardKey??""}learnDefaultShardKey(e,r){let s=e.headers.get("x-lunora-shard-key");if(s===null||r!==void 0||this.defaultShardKey===s)return;this.defaultShardKey=s;let i=this.shardCursors.get("");i!==void 0&&(this.shardCursors.set(s,Math.max(this.shardCursors.get(s)??0,i)),this.shardCursors.delete(""))}recordShardCursor(e,r){if(typeof r!="number")return;let s=this.cursorKeyFor(e);this.shardCursors.set(s,Math.max(this.shardCursors.get(s)??0,r))}settleReplayTerminal(e,r){this.unpersist(e.id),e.reject(r),this.emitItemSettled(e,"rejected",r)}async replaySequential(e){for(let r=0;r<e.length;r+=1){let s=e[r];if(s)try{let i,n=await this.rpc(s.functionPath,s.args,s.shardKey,{captureBookmark:!0,clientId:s.clientId??this.clientId,mutationId:s.id,onCommitCursor:a(o=>{i=o},"onCommitCursor")});this.settleReplaySuccess(s,n,i)}catch(i){if(i.code!==void 0){this.settleReplayTerminal(s,i);continue}this.offlineQueue.requeue(e.slice(r));return}}}async replayBatched(e){if(!this.fetchImpl)return{requeue:e,stop:!0};let r;try{r=await this.fetchImpl(V(this.url,lr),{body:JSON.stringify({calls:e.map((n,o)=>({args:G(n.args,`args for '${n.functionPath}'`),functionPath:n.functionPath,id:o,clientId:n.clientId??this.clientId,mutationId:n.id,shardKey:n.shardKey}))}),headers:this.rpcRequestHeaders({attachBookmark:!0}),method:"POST"})}catch{return{requeue:e,stop:!0}}let s=r.headers.get("x-d1-bookmark");s&&this.bookmark.set(s);let i;try{i=await r.json()}catch{return{requeue:e,stop:!0}}if(!i.results){if(i.error){let n=de(i.error);for(let o of e)this.settleReplayTerminal(o,n);return{requeue:[],stop:!1}}return{requeue:e,stop:!0}}return{requeue:this.settleReplayBatchSlots(e,i.results),stop:!1}}settleReplayBatchSlots(e,r){let s=new Map;for(let n of r)typeof n.id=="number"&&n.body!==void 0&&s.set(n.id,n.body);let i=[];for(let[n,o]of e.entries()){let c=s.get(n);c===void 0?i.push(o):"error"in c?Li.has(c.error.code)?i.push(o):this.settleReplayTerminal(o,de(c.error)):this.settleReplaySuccess(o,S(c.result),c.commitCursor)}return i}};var yr=R(mt(),1),br=R(H(),1);var Di=a(()=>{let t=(0,yr.c)(4),e=Ye(),r,s,i;return t[0]!==e?(r=a(n=>e.onConnectionStatus(()=>{n()}),"o"),s=a(()=>e.connectionStatus(),"e"),i=a(()=>e.connectionStatus(),"c"),t[0]=e,t[1]=r,t[2]=s,t[3]=i):(r=t[1],s=t[2],i=t[3]),(0,br.useSyncExternalStore)(r,s,i)},"S");export{ft as a,Cr as b,Ve as c,xr as d,Lr as e,Ye as f,Di as g};
|