@lunora/studio 1.0.0-alpha.3 → 1.0.0-alpha.30
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/__assets__/package-og.svg +1 -1
- package/dist/index.d.ts +29 -18
- package/dist/index.js +29 -29
- package/dist/mount.d.ts +1 -1
- package/dist/mount.js +1 -1
- package/dist/{packem_shared/ApiTab-W3no0KOj.js → packem_chunks/ApiTab.js} +5 -5
- package/dist/{packem_shared/AuditPanel-Bq4o_IqT.js → packem_chunks/AuditPanel.js} +24 -36
- package/dist/{packem_shared/ExportImportPanel-dxY56TDF.js → packem_chunks/ExportImportPanel.js} +13 -9
- package/dist/{packem_shared/FileBrowser-Dhy4zES8.js → packem_chunks/FileBrowser.js} +15 -15
- package/dist/{packem_shared/FunctionRunner--fQJRPAD.js → packem_chunks/FunctionRunner.js} +10 -10
- package/dist/{packem_shared/FunctionStatsPanel-BjRUA_G3.js → packem_chunks/FunctionStatsPanel.js} +147 -204
- package/dist/{packem_shared/HealthPanel-PxclMWmA.js → packem_chunks/HealthPanel.js} +37 -29
- package/dist/{packem_shared/InsightsPanel-CWS_C-xW.js → packem_chunks/InsightsPanel.js} +107 -69
- package/dist/{packem_shared/LogsPanel-CTW8CFcM.js → packem_chunks/LogsPanel.js} +41 -53
- package/dist/{packem_shared/MailPanel-BwkvfIHF.js → packem_chunks/MailPanel.js} +37 -44
- package/dist/{packem_shared/MetricsPanel-BLuOhZQ4.js → packem_chunks/MetricsPanel.js} +41 -322
- package/dist/{packem_shared/MigrationsPanel-DT3lnwHF.js → packem_chunks/MigrationsPanel.js} +39 -46
- package/dist/{packem_shared/PitrPanel-CdErL7EJ.js → packem_chunks/PitrPanel.js} +9 -9
- package/dist/{packem_shared/SchemaViewer-LJDcmNIO.js → packem_chunks/SchemaViewer.js} +15 -15
- package/dist/{packem_shared/SecurityAdvisorPanel-C_ETsPih.js → packem_chunks/SecurityAdvisorPanel.js} +44 -31
- package/dist/packem_chunks/SettingsPanel.js +390 -0
- package/dist/{packem_shared/sql-editor-panel-BFRpzj6r.js → packem_chunks/SqlEditorPanel.js} +12 -252
- package/dist/{packem_shared/TableEditor-ChfUOZec.js → packem_chunks/TableEditor.js} +10 -68
- package/dist/packem_chunks/analytics-panel.js +261 -0
- package/dist/packem_chunks/auth-config-panel.js +179 -0
- package/dist/packem_chunks/auth-sessions-panel.js +175 -0
- package/dist/packem_chunks/dashboards-panel.js +779 -0
- package/dist/packem_chunks/fanout-panel.js +481 -0
- package/dist/packem_chunks/flags-panel.js +176 -0
- package/dist/packem_chunks/kv-browser.js +1896 -0
- package/dist/packem_chunks/log-drains-panel.js +273 -0
- package/dist/packem_chunks/organizations-panel.js +670 -0
- package/dist/packem_chunks/payments-panel.js +185 -0
- package/dist/packem_chunks/permissions-panel.js +804 -0
- package/dist/packem_chunks/queues-panel.js +147 -0
- package/dist/packem_chunks/rls-panel.js +313 -0
- package/dist/packem_chunks/schedule-panel.js +831 -0
- package/dist/packem_chunks/sparkline.js +79 -0
- package/dist/packem_chunks/storage-rules-panel.js +138 -0
- package/dist/packem_chunks/subscriptions-panel.js +236 -0
- package/dist/packem_chunks/users-panel.js +1265 -0
- package/dist/packem_chunks/vector-browser.js +281 -0
- package/dist/packem_chunks/workflows-panel.js +562 -0
- package/dist/packem_shared/{ADMIN_FUNCTIONS-DmBqMZ-z.js → ADMIN_FUNCTIONS-CdaxLGkE.js} +3 -0
- package/dist/packem_shared/{ApiDocsPanel-C5-yJ1p7.js → ApiDocsPanel-B6u_wnz-.js} +2 -2
- package/dist/packem_shared/{ApiReferencePanel-1vubqG5s.js → ApiReferencePanel-Drz4UO0a.js} +2 -1
- package/dist/packem_shared/{CommandPalette-BtgkBzZI.js → CommandPalette-B5BertvU.js} +1 -1
- package/dist/packem_shared/{DataBrowser-CtBe1So9.js → DataBrowser-ANTHLWWh.js} +198 -247
- package/dist/packem_shared/{GlobalDataBrowser-BTEmGrph.js → GlobalDataBrowser-CjgTG_wa.js} +37 -66
- package/dist/packem_shared/HomePanel-c2FodE9t.js +14 -0
- package/dist/packem_shared/{OpenRpcReferencePanel-vbcYbv3V.js → OpenRpcReferencePanel-CspFdbUT.js} +2 -1
- package/dist/packem_shared/{ScheduledJobs-CabfKbyM.js → ScheduledJobs-BEJXtsBn.js} +163 -60
- package/dist/packem_shared/Studio-CVTtA_sB.js +16 -0
- package/dist/packem_shared/{StudioApp-CHOZA-z-.js → StudioApp-BSYV2fz6.js} +277 -3
- package/dist/packem_shared/{advisor-view-CGcfMiPq.js → advisor-view-DzqyvUU3.js} +1 -1
- package/dist/packem_shared/{app.d-CCmwDEVs.d.ts → app.d-B6MyY_al.d.ts} +1 -1
- package/dist/packem_shared/{bar-chart-CzJAgqkp.js → bar-chart-Bb__F5-u.js} +1 -1
- package/dist/packem_shared/browser-storage-d03UsV7v.js +249 -0
- package/dist/packem_shared/{cf-links-2cktDedA.js → cf-links-BZfRdxSE.js} +1 -1
- package/dist/packem_shared/{data-grid-B5CaV3wS.js → data-grid-Dsg6nRjo.js} +1 -1
- package/dist/packem_shared/data-view-params-Cd6yRVbv.js +96 -0
- package/dist/packem_shared/{grid-features-CzUfqgsM.js → grid-features-D7nNzBYm.js} +4 -99
- package/dist/packem_shared/{HomePanel-Cw16stjq.js → home-panel-aOR_drVv.js} +833 -469
- package/dist/packem_shared/{internal-rXJEAhXS.js → internal-FcNZ3beb.js} +1 -1
- package/dist/packem_shared/modal-shell-hyaJvIJ6.js +100 -0
- package/dist/packem_shared/{reference-view-B4E49Lip.js → reference-view-Doy1XlQq.js} +4 -44
- package/dist/packem_shared/select-UkNYCT3s.js +273 -0
- package/dist/packem_shared/skeleton-CGhL0p20.js +45 -0
- package/dist/packem_shared/{sparkline-10dG-_f0.js → sparkline-KgMPHS4u.js} +1 -1
- package/dist/packem_shared/studio-dMTJ-kRR.js +3987 -0
- package/dist/packem_shared/{table-_RzNvy3R.js → table-DsCa9Qp9.js} +1 -1
- package/dist/packem_shared/{table-list-sidebar-Bg7uzbvC.js → table-list-sidebar-VMo0ftxD.js} +1 -1
- package/dist/packem_shared/use-admin-query-BViPA3US.js +105 -0
- package/dist/packem_shared/use-auth-capabilities-BHkoBnbZ.js +32 -0
- package/dist/standalone/chunk-2DS7JLWL.js +13 -0
- package/dist/standalone/chunk-2K47A3P6.js +1 -0
- package/dist/standalone/chunk-2NGUNNGW.js +1 -0
- package/dist/standalone/chunk-2PDQ4KZ6.js +1 -0
- package/dist/standalone/chunk-3BP4BTLR.js +4 -0
- package/dist/standalone/chunk-3OA7PECS.js +6 -0
- package/dist/standalone/chunk-4QHKBC77.js +1 -0
- package/dist/standalone/chunk-57LYXHXH.js +1 -0
- package/dist/standalone/chunk-5NSZVXCS.js +1 -0
- package/dist/standalone/chunk-5OIBXYZM.js +1 -0
- package/dist/standalone/chunk-63XKJQTQ.js +1 -0
- package/dist/standalone/chunk-6RC6L33K.js +4 -0
- package/dist/standalone/chunk-6VTGE3WJ.js +1 -0
- package/dist/standalone/chunk-7PBZKXYA.js +1 -0
- package/dist/standalone/chunk-7POIIWC5.js +3 -0
- package/dist/standalone/chunk-7RYIQKZA.js +1 -0
- package/dist/standalone/chunk-7TJJXVSE.js +1 -0
- package/dist/standalone/chunk-AB6QGMBF.js +1 -0
- package/dist/standalone/chunk-AHILM3ZP.js +1 -0
- package/dist/standalone/chunk-AQGOX5DK.js +1 -0
- package/dist/standalone/chunk-ASLGNHAX.js +1 -0
- package/dist/standalone/chunk-BHTPZS7L.js +4 -0
- package/dist/standalone/chunk-BJGBHGK3.js +1 -0
- package/dist/standalone/chunk-D7HKX4DI.js +1 -0
- package/dist/standalone/chunk-DGWTR4G7.js +1 -0
- package/dist/standalone/chunk-DSX53PBM.js +1 -0
- package/dist/standalone/chunk-DV2MNASX.js +1 -0
- package/dist/standalone/chunk-DWDILV2E.js +1 -0
- package/dist/standalone/chunk-E7AVZZKO.js +1 -0
- package/dist/standalone/chunk-EGJX34WM.js +1 -0
- package/dist/standalone/chunk-FCR3HKFV.js +1 -0
- package/dist/standalone/chunk-FKO3HO6I.js +4 -0
- package/dist/standalone/chunk-FQKNJSRA.js +76 -0
- package/dist/standalone/chunk-G2TFEWEQ.js +4 -0
- package/dist/standalone/chunk-GABMIICA.js +1 -0
- package/dist/standalone/chunk-GTM65MVX.js +1 -0
- package/dist/standalone/chunk-GZXPPJVK.js +1 -0
- package/dist/standalone/chunk-HFBRE65A.js +1 -0
- package/dist/standalone/chunk-HFMQNUBC.js +1 -0
- package/dist/standalone/chunk-HG7Q5B3H.js +1 -0
- package/dist/standalone/chunk-HTQL7AXU.js +1 -0
- package/dist/standalone/chunk-HV7G6DFP.js +5 -0
- package/dist/standalone/chunk-ITLLHEVG.js +1 -0
- package/dist/standalone/chunk-J6J54MBP.js +1 -0
- package/dist/standalone/chunk-JSEXCW5Q.js +1 -0
- package/dist/standalone/chunk-KEGAWN6Y.js +1 -0
- package/dist/standalone/chunk-KG3QTFWE.js +1 -0
- package/dist/standalone/chunk-KGS7KM4A.js +2 -0
- package/dist/standalone/chunk-KODWGUAB.js +1 -0
- package/dist/standalone/chunk-KZ6INM5M.js +1 -0
- package/dist/standalone/chunk-MGFEVTRI.js +1 -0
- package/dist/standalone/chunk-N2QDG3MW.js +1 -0
- package/dist/standalone/chunk-N4JI6VQD.js +1 -0
- package/dist/standalone/chunk-NNISYDNI.js +1 -0
- package/dist/standalone/chunk-O4PXDNR3.js +1 -0
- package/dist/standalone/chunk-O77VNUFD.js +1 -0
- package/dist/standalone/chunk-OD2POGPJ.js +1 -0
- package/dist/standalone/chunk-OXCK3ZUG.js +1 -0
- package/dist/standalone/chunk-P7DSVO4U.js +1 -0
- package/dist/standalone/chunk-PKAM3N5C.js +1 -0
- package/dist/standalone/chunk-QGXGBHQO.js +1 -0
- package/dist/standalone/chunk-QHA3TAEJ.js +1 -0
- package/dist/standalone/chunk-QQWC62X7.js +1 -0
- package/dist/standalone/chunk-RMYA7NAH.js +1 -0
- package/dist/standalone/chunk-RRCPZMC2.js +22 -0
- package/dist/standalone/chunk-S53RUBW5.js +1 -0
- package/dist/standalone/chunk-SB4GT6PK.js +1 -0
- package/dist/standalone/chunk-SEU5V7I6.js +1 -0
- package/dist/standalone/chunk-SHIOUDOT.js +1 -0
- package/dist/standalone/chunk-SIDRSX7Y.js +1 -0
- package/dist/standalone/chunk-SVR644RF.js +1 -0
- package/dist/standalone/chunk-TAD43CG5.js +1 -0
- package/dist/standalone/chunk-TBMYIZIO.js +1 -0
- package/dist/standalone/chunk-TICVNLPM.js +1 -0
- package/dist/standalone/chunk-TQ36RWOP.js +1 -0
- package/dist/standalone/chunk-UGMRUEBU.js +1 -0
- package/dist/standalone/chunk-UII66UVF.js +1 -0
- package/dist/standalone/chunk-VJPQUBN6.js +8 -0
- package/dist/standalone/chunk-VLXV72QE.js +1 -0
- package/dist/standalone/chunk-VMJKJWG6.js +1 -0
- package/dist/standalone/chunk-VPDPN5RR.js +2 -0
- package/dist/standalone/chunk-VSEGZA3J.js +1 -0
- package/dist/standalone/chunk-VXBZQIGY.js +4 -0
- package/dist/standalone/chunk-W7PCVQTE.js +1 -0
- package/dist/standalone/chunk-XLILSHPE.js +1 -0
- package/dist/standalone/chunk-XURNGQSS.js +1 -0
- package/dist/standalone/chunk-YJGANMU7.js +18 -0
- package/dist/standalone/chunk-YQQJ4N6U.js +1 -0
- package/dist/standalone/chunk-ZH7UES4T.js +2 -0
- package/dist/standalone/chunk-ZPUO7FNI.js +1 -0
- package/dist/standalone/chunk-ZQCVDXDL.js +1 -0
- package/dist/standalone/studio.js +104 -246
- package/dist/styles.css +1 -1
- package/package.json +13 -12
- package/dist/packem_shared/SettingsPanel-C0uLRf5P.js +0 -176
- package/dist/packem_shared/SqlEditorPanel-CguV7otm.js +0 -13
- package/dist/packem_shared/Studio-DFWAlcuf.js +0 -33
- package/dist/packem_shared/studio-Bj8psK1c.js +0 -10303
- package/dist/packem_shared/use-live-admin-Dq6g3daN.js +0 -73
- package/dist/packem_shared/use-live-shard-seed-Cuk3dnH0.js +0 -76
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i,e as r,f as c,g as m,h as f,j as n}from"./chunk-RRCPZMC2.js";var p=r(m(),1),b=r(c(),1);var d=r(f(),1);function x(s){let e=(0,p.c)(8),t,a;e[0]!==s?({className:t,...a}=s,e[0]=s,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=n("flex items-center gap-2 text-xs leading-none select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),e[3]=t,e[4]=l):l=e[4];let o;return e[5]!==a||e[6]!==l?(o=(0,d.jsxDEV)("label",{"data-slot":"label",className:l,...a},void 0,!1),e[5]=a,e[6]=l,e[7]=o):o=e[7],o}i(x,"Label");export{x as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,c as v,f as G}from"./chunk-RRCPZMC2.js";var C=v(h=>{"use strict";(function(){function T(e,r){return e===r&&(e!==0||1/e===1/r)||e!==e&&r!==r}a(T,"is");function f(e,r){u||i.startTransition===void 0||(u=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var t=r();if(!c){var o=r();L(t,o)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),c=!0)}o=y({inst:{value:t,getSnapshot:r}});var n=o[0].inst,O=o[1];return D(function(){n.value=t,n.getSnapshot=r,d(n)&&O({inst:n})},[e,t,r]),m(function(){return d(n)&&O({inst:n}),e(function(){d(n)&&O({inst:n})})},[e]),_(t),t}a(f,"useSyncExternalStore$2");function d(e){var r=e.getSnapshot;e=e.value;try{var t=r();return!L(e,t)}catch{return!0}}a(d,"checkIfSnapshotChanged");function A(e,r){return r()}a(A,"useSyncExternalStore$1"),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var i=G(),L=typeof Object.is=="function"?Object.is:T,y=i.useState,m=i.useEffect,D=i.useLayoutEffect,_=i.useDebugValue,u=!1,c=!1,E=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?A:f;h.useSyncExternalStore=i.useSyncExternalStore!==void 0?i.useSyncExternalStore:E,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var B=v((w,g)=>{"use strict";g.exports=C()});var K=v(H=>{"use strict";(function(){function T(_,u){return _===u&&(_!==0||1/_===1/u)||_!==_&&u!==u}a(T,"is"),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var f=G(),d=B(),A=typeof Object.is=="function"?Object.is:T,i=d.useSyncExternalStore,L=f.useRef,y=f.useEffect,m=f.useMemo,D=f.useDebugValue;H.useSyncExternalStoreWithSelector=function(_,u,c,E,e){var r=L(null);if(r.current===null){var t={hasValue:!1,value:null};r.current=t}else t=r.current;r=m(function(){function n(s){if(!O){if(O=!0,p=s,s=E(s),e!==void 0&&t.hasValue){var l=t.value;if(e(l,s))return S=l}return S=s}if(l=S,A(p,s))return l;var R=E(s);return e!==void 0&&e(l,R)?(p=s,l):(p=s,S=R)}a(n,"memoizedSelector");var O=!1,p,S,V=c===void 0?null:c;return[function(){return n(u())},V===null?void 0:function(){return n(V())}]},[u,c,E,e]);var o=i(_,r[0],r[1]);return y(function(){t.hasValue=!0,t.value=o},[o]),D(o),o},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var M=v((z,I)=>{"use strict";I.exports=K()});export{B as a,M as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as A,b as T,c as C,d as I}from"./chunk-FQKNJSRA.js";import{k as w}from"./chunk-ZH7UES4T.js";import{d as S,h as y}from"./chunk-YJGANMU7.js";import{a as i,e as x,f as E,g as _,h as B,j as N}from"./chunk-RRCPZMC2.js";var p=x(_(),1);var m=x(B(),1);var g=x(E(),1);var J=50,R={value:{colors:{dark:["var(--chart-1)"],light:["var(--chart-1)"]},label:"value"}},V=i(e=>{let t=e.columns.find(s=>e.rows.length>0&&e.rows.every(n=>typeof n[s]=="number"))??null;return{label:e.columns.find(s=>s!==t)??null,value:t}},"pickColumns"),z=i(e=>{let t=(0,p.c)(15),{result:r}=e,s=S(),n;t[0]!==r?(n=V(r),t[0]=r,t[1]=n):n=t[1];let{label:o,value:l}=n,a;t[2]!==o||t[3]!==r||t[4]!==l?(a=l===null?[]:r.rows.slice(0,J).map((u,f)=>({label:o===null?`#${(f+1).toString()}`:y(u[o]),value:Number(u[l])||0})),t[2]=o,t[3]=r,t[4]=l,t[5]=a):a=t[5];let c=a;if(l===null){let u;t[6]!==s?(u=s("No numeric column to chart."),t[6]=s,t[7]=u):u=t[7];let f;return t[8]!==u?(f=(0,m.jsxDEV)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-chart-empty",children:u},void 0,!1),t[8]=u,t[9]=f):f=t[9],f}let d,v,b;t[10]===Symbol.for("react.memo_cache_sentinel")?(d=(0,m.jsxDEV)(C,{dataKey:"label"},void 0,!1),v=(0,m.jsxDEV)(T,{dataKey:"value"},void 0,!1),b=(0,m.jsxDEV)(I,{},void 0,!1),t[10]=d,t[11]=v,t[12]=b):(d=t[10],v=t[11],b=t[12]);let h;return t[13]!==c?(h=(0,m.jsxDEV)("div",{className:"h-80 w-full p-3","data-testid":"sql-chart",children:(0,m.jsxDEV)(A,{className:"h-full w-full",config:R,data:c,children:[d,v,b]},void 0,!0)},void 0,!1),t[13]=c,t[14]=h):h=t[14],h},"SqlResultChart"),q=w("flex items-start gap-2 rounded-md border px-3 py-2 text-sm [&>svg]:mt-0.5 [&>svg]:size-4 [&>svg]:shrink-0",{defaultVariants:{variant:"default"},variants:{variant:{default:"border-border bg-muted/40 text-foreground",destructive:"border-destructive/40 bg-destructive/5 text-destructive",warning:"border-amber-500/40 bg-amber-500/5 text-amber-700 dark:text-amber-400"}}}),F=i(e=>{let t=(0,p.c)(10),{children:r,className:s,icon:n,testId:o,variant:l}=e,a;t[0]!==s||t[1]!==l?(a=N(q({variant:l}),s),t[0]=s,t[1]=l,t[2]=a):a=t[2];let c;t[3]!==r?(c=(0,m.jsxDEV)("div",{className:"min-w-0 flex-1",children:r},void 0,!1),t[3]=r,t[4]=c):c=t[4];let d;return t[5]!==n||t[6]!==a||t[7]!==c||t[8]!==o?(d=(0,m.jsxDEV)("div",{className:a,"data-testid":o,role:"alert",children:[n,c]},void 0,!0),t[5]=n,t[6]=a,t[7]=c,t[8]=o,t[9]=d):d=t[9],d},"Alert"),$=i(()=>{try{return globalThis.localStorage}catch{return}},"store"),O=i(function(e){try{let t=$()?.getItem(e)??void 0,r=t===void 0?[]:JSON.parse(t);return Array.isArray(r)?r:[]}catch{return[]}},"loadJsonArray"),U=i((e,t)=>{let r=$();if(r!==void 0)try{r.setItem(e,JSON.stringify(t))}catch{}},"saveJson"),G=i(function(e){let t=(0,p.c)(8),r;t[0]!==e?(r=i(()=>O(e),"t0"),t[0]=e,t[1]=r):r=t[1];let[s,n]=(0,g.useState)(r),o,l;t[2]!==e||t[3]!==s?(o=i(()=>{U(e,s)},"t1"),l=[e,s],t[2]=e,t[3]=s,t[4]=o,t[5]=l):(o=t[4],l=t[5]),(0,g.useEffect)(o,l);let a;return t[6]!==s?(a=[s,n],t[6]=s,t[7]=a):a=t[7],a},"usePersistedList"),H=i(e=>globalThis.crypto?.randomUUID?.()??`${e}-${globalThis.performance.now().toString(36)}`,"newId");export{z as a,F as b,G as c,H as d};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as O,b as $,c as E,d as J,e as R,f as _,g as L,h as U}from"./chunk-7PBZKXYA.js";import{a as B}from"./chunk-AHILM3ZP.js";import{a as I}from"./chunk-OD2POGPJ.js";import{d as D,h as V,i as A}from"./chunk-YJGANMU7.js";import{a as C,e as j,f as Q,g as q,h as z}from"./chunk-RRCPZMC2.js";var S=j(q(),1),H=j(Q(),1);var a=j(z(),1);var k="inline-flex items-center gap-1 rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",K=/["\n,]/u,G=C(n=>{if(n==null)return"";let e;return typeof n=="string"?e=n:typeof n=="number"||typeof n=="boolean"||typeof n=="bigint"?e=String(n):e=JSON.stringify(n),K.test(e)?`"${e.replaceAll('"','""')}"`:e},"csvCell"),P=C((n,e)=>{let t=n.map(s=>G(s)).join(","),o=e.map(s=>n.map(l=>G(s[l])).join(","));return[t,...o].join(`
|
|
2
|
+
`)},"toCsv"),W=C(n=>JSON.stringify(n,null,2),"toJson"),F=C((n,e,t)=>{if(!("document"in globalThis))return;let o=globalThis.URL.createObjectURL(new globalThis.Blob([e],{type:t})),s=globalThis.document.createElement("a");s.href=o,s.download=n,globalThis.document.body.append(s),s.click(),s.remove(),globalThis.URL.revokeObjectURL(o)},"downloadFile"),X=C(n=>{let e=(0,S.c)(26),{columns:t,name:o,rows:s}=n,l=D(),r;e[0]!==t||e[1]!==o||e[2]!==s?(r=C(()=>{F(`${o}.csv`,P(t,s),"text/csv;charset=utf-8")},"t1"),e[0]=t,e[1]=o,e[2]=s,e[3]=r):r=e[3];let u=r,i;e[4]!==o||e[5]!==s?(i=C(()=>{F(`${o}.json`,W(s),"application/json")},"t2"),e[4]=o,e[5]=s,e[6]=i):i=e[6];let m=i,c=s.length===0,f;e[7]!==c?(f=(0,a.jsxDEV)($,{className:k,"data-testid":"grid-export",disabled:c,title:"Exports only the rows loaded on the current page, not the whole table",children:"Export page"},void 0,!1),e[7]=c,e[8]=f):f=e[8];let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=(0,a.jsxDEV)(R,{children:"Export loaded rows"},void 0,!1),e[9]=d):d=e[9];let p;e[10]!==l?(p=l("CSV"),e[10]=l,e[11]=p):p=e[11];let v;e[12]!==u||e[13]!==p?(v=(0,a.jsxDEV)(_,{"data-testid":"grid-export-csv",onClick:u,children:p},void 0,!1),e[12]=u,e[13]=p,e[14]=v):v=e[14];let g;e[15]!==l?(g=l("JSON"),e[15]=l,e[16]=g):g=e[16];let b;e[17]!==m||e[18]!==g?(b=(0,a.jsxDEV)(_,{"data-testid":"grid-export-json",onClick:m,children:g},void 0,!1),e[17]=m,e[18]=g,e[19]=b):b=e[19];let h;e[20]!==v||e[21]!==b?(h=(0,a.jsxDEV)(E,{align:"end",children:[d,v,b]},void 0,!0),e[20]=v,e[21]=b,e[22]=h):h=e[22];let x;return e[23]!==h||e[24]!==f?(x=(0,a.jsxDEV)(O,{children:[f,h]},void 0,!0),e[23]=h,e[24]=f,e[25]=x):x=e[25],x},"ExportMenu"),Y=C(n=>{let e=(0,S.c)(9),{column:t}=n,o;e[0]!==t?(o=C(()=>{t.toggleVisibility()},"t1"),e[0]=t,e[1]=o):o=e[1];let s=o,l;e[2]!==t?(l=t.getIsVisible(),e[2]=t,e[3]=l):l=e[3];let r=`grid-column-${t.id}`,u;return e[4]!==t.id||e[5]!==s||e[6]!==l||e[7]!==r?(u=(0,a.jsxDEV)(L,{checked:l,closeOnClick:!1,"data-testid":r,onCheckedChange:s,children:t.id},void 0,!1),e[4]=t.id,e[5]=s,e[6]=l,e[7]=r,e[8]=u):u=e[8],u},"ColumnToggle"),Z=C(n=>{let e=(0,S.c)(30),{table:t}=n,o=D(),s;e[0]!==t?(s=t.getIsAllColumnsVisible(),e[0]=t,e[1]=s):s=e[1];let l=s,r;e[2]!==l||e[3]!==t?(r=C(()=>{t.toggleAllColumnsVisible(!l)},"t2"),e[2]=l,e[3]=t,e[4]=r):r=e[4];let u=r,i;e[5]!==o?(i=o("Columns"),e[5]=o,e[6]=i):i=e[6];let m;e[7]!==i?(m=(0,a.jsxDEV)($,{className:k,"data-testid":"grid-columns",children:i},void 0,!1),e[7]=i,e[8]=m):m=e[8];let c;e[9]!==o?(c=o("Columns"),e[9]=o,e[10]=c):c=e[10];let f;e[11]!==c?(f=(0,a.jsxDEV)(R,{children:c},void 0,!1),e[11]=c,e[12]=f):f=e[12];let d;e[13]!==l||e[14]!==o?(d=o(l?"Hide all":"Show all"),e[13]=l,e[14]=o,e[15]=d):d=e[15];let p;e[16]!==l||e[17]!==u||e[18]!==d?(p=(0,a.jsxDEV)(L,{checked:l,closeOnClick:!1,"data-testid":"grid-columns-all",onCheckedChange:u,children:d},void 0,!1),e[16]=l,e[17]=u,e[18]=d,e[19]=p):p=e[19];let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=(0,a.jsxDEV)(U,{},void 0,!1),e[20]=v):v=e[20];let g;e[21]!==t?(g=t.getAllLeafColumns().map(te),e[21]=t,e[22]=g):g=e[22];let b;e[23]!==g||e[24]!==f||e[25]!==p?(b=(0,a.jsxDEV)(E,{align:"end",className:"max-h-80 overflow-y-auto",children:(0,a.jsxDEV)(J,{children:[f,p,v,g]},void 0,!0)},void 0,!1),e[23]=g,e[24]=f,e[25]=p,e[26]=b):b=e[26];let h;return e[27]!==b||e[28]!==m?(h=(0,a.jsxDEV)(O,{children:[m,b]},void 0,!0),e[27]=b,e[28]=m,e[29]=h):h=e[29],h},"ColumnsMenu"),ee=C(n=>{let e=(0,S.c)(19),{count:t,editable:o,onClear:s,onDelete:l}=n,r=D(),u;e[0]!==t||e[1]!==r?(u=r("{count} selected",{count:t}),e[0]=t,e[1]=r,e[2]=u):u=e[2];let i;e[3]!==u?(i=(0,a.jsxDEV)("span",{className:"font-medium tabular-nums","data-testid":"grid-selection-count",children:u},void 0,!1),e[3]=u,e[4]=i):i=e[4];let m;e[5]!==r?(m=r("Clear"),e[5]=r,e[6]=m):m=e[6];let c;e[7]!==s||e[8]!==m?(c=(0,a.jsxDEV)("button",{className:k,"data-testid":"grid-selection-clear",onClick:s,type:"button",children:m},void 0,!1),e[7]=s,e[8]=m,e[9]=c):c=e[9];let f;e[10]!==t||e[11]!==o||e[12]!==l||e[13]!==r?(f=o&&(0,a.jsxDEV)(I,{confirmLabel:r("Delete {count} rows?",{count:t}),onConfirm:l,testId:"grid-selection-delete",children:r("Delete {count}",{count:t})},void 0,!1),e[10]=t,e[11]=o,e[12]=l,e[13]=r,e[14]=f):f=e[14];let d;return e[15]!==i||e[16]!==c||e[17]!==f?(d=(0,a.jsxDEV)("div",{className:"flex items-center gap-2 rounded-md border border-border bg-accent/40 px-3 py-1.5 text-xs","data-testid":"grid-selection-bar",children:[i,c,f]},void 0,!0),e[15]=i,e[16]=c,e[17]=f,e[18]=d):d=e[18],d},"SelectionBar"),ae=C(n=>{let e=(0,S.c)(32),{column:t,onClose:o,value:s}=n,l=D(),[r,u]=(0,H.useState)(!1),i;e[0]!==s?(i=V(s),e[0]=s,e[1]=i):i=e[1];let m=i,c;e[2]!==m?(c=C(()=>{let T="navigator"in globalThis?globalThis.navigator.clipboard:void 0;T!==void 0&&(A(T.writeText(m)),u(!0))},"t2"),e[2]=m,e[3]=c):c=e[3];let f=c,d;e[4]!==l?(d=l("Cell value"),e[4]=l,e[5]=d):d=e[5];let p;e[6]!==t?(p=(0,a.jsxDEV)("h2",{className:"truncate font-mono text-sm font-semibold text-foreground",children:t},void 0,!1),e[6]=t,e[7]=p):p=e[7];let v;e[8]!==r||e[9]!==l?(v=l(r?"Copied":"Copy"),e[8]=r,e[9]=l,e[10]=v):v=e[10];let g;e[11]!==f||e[12]!==v?(g=(0,a.jsxDEV)("button",{className:k,"data-testid":"grid-cell-copy",onClick:f,type:"button",children:v},void 0,!1),e[11]=f,e[12]=v,e[13]=g):g=e[13];let b;e[14]!==l?(b=l("Close"),e[14]=l,e[15]=b):b=e[15];let h;e[16]!==o||e[17]!==b?(h=(0,a.jsxDEV)("button",{className:k,"data-testid":"grid-cell-close",onClick:o,type:"button",children:b},void 0,!1),e[16]=o,e[17]=b,e[18]=h):h=e[18];let x;e[19]!==g||e[20]!==h?(x=(0,a.jsxDEV)("div",{className:"flex items-center gap-1.5",children:[g,h]},void 0,!0),e[19]=g,e[20]=h,e[21]=x):x=e[21];let w;e[22]!==p||e[23]!==x?(w=(0,a.jsxDEV)("div",{className:"flex items-center justify-between",children:[p,x]},void 0,!0),e[22]=p,e[23]=x,e[24]=w):w=e[24];let y;e[25]!==m?(y=(0,a.jsxDEV)("pre",{className:"min-h-0 flex-1 overflow-auto rounded-md border border-border bg-muted/30 p-3 font-mono text-xs whitespace-pre-wrap","data-testid":"grid-cell-value",children:m},void 0,!1),e[25]=m,e[26]=y):y=e[26];let N;return e[27]!==o||e[28]!==w||e[29]!==y||e[30]!==d?(N=(0,a.jsxDEV)(B,{className:"max-h-[70vh] w-[min(40rem,90vw)]",label:d,onClose:o,panelTestId:"grid-cell-dialog",testId:"grid-cell-dialog-overlay",variant:"dialog",children:[w,y]},void 0,!0),e[27]=o,e[28]=w,e[29]=y,e[30]=d,e[31]=N):N=e[31],N},"CellDetailDialog"),de=C(n=>{let e=(0,S.c)(33),{columns:t,editable:o,name:s,onBulkDelete:l,onToggleTranspose:r,rows:u,table:i,transposed:m}=n,c=D(),f;e[0]!==i?(f=i.getSelectedRowModel(),e[0]=i,e[1]=f):f=e[1];let d=f.rows,p;e[2]!==i?(p=C(()=>{i.resetRowSelection()},"t2"),e[2]=i,e[3]=p):p=e[3];let v=p,g;e[4]!==l||e[5]!==d||e[6]!==i?(g=C(()=>{l(d.map(le)),i.resetRowSelection()},"t3"),e[4]=l,e[5]=d,e[6]=i,e[7]=g):g=e[7];let b=g,h;e[8]!==t||e[9]!==s||e[10]!==u?(h=(0,a.jsxDEV)(X,{columns:t,name:s,rows:u},void 0,!1),e[8]=t,e[9]=s,e[10]=u,e[11]=h):h=e[11];let x;e[12]!==i?(x=(0,a.jsxDEV)(Z,{table:i},void 0,!1),e[12]=i,e[13]=x):x=e[13];let w;e[14]!==c?(w=c("Swap rows and columns"),e[14]=c,e[15]=w):w=e[15];let y;e[16]!==c?(y=c("Transpose"),e[16]=c,e[17]=y):y=e[17];let N;e[18]!==r||e[19]!==w||e[20]!==y||e[21]!==m?(N=(0,a.jsxDEV)("button",{"aria-pressed":m,className:k,"data-testid":"grid-transpose",onClick:r,title:w,type:"button",children:y},void 0,!1),e[18]=r,e[19]=w,e[20]=y,e[21]=m,e[22]=N):N=e[22];let T;e[23]!==o||e[24]!==v||e[25]!==b||e[26]!==d.length?(T=d.length>0&&(0,a.jsxDEV)(ee,{count:d.length,editable:o,onClear:v,onDelete:b},void 0,!1),e[23]=o,e[24]=v,e[25]=b,e[26]=d.length,e[27]=T):T=e[27];let M;return e[28]!==h||e[29]!==x||e[30]!==N||e[31]!==T?(M=(0,a.jsxDEV)("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"grid-actions",children:[h,x,N,T]},void 0,!0),e[28]=h,e[29]=x,e[30]=N,e[31]=T,e[32]=M):M=e[32],M},"GridActionsBar");function te(n){return(0,a.jsxDEV)(Y,{column:n},n.id,!1)}C(te,"_temp");function le(n){return n.id}C(le,"_temp2");export{X as a,ee as b,ae as c,de as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as nt}from"./chunk-3OA7PECS.js";import{a as o,e as O,f as B,g as st,h as or}from"./chunk-RRCPZMC2.js";var Dt=O(st(),1);var A=class{static{o(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 ar=class extends A{static{o(this,"FocusManager")}#t;#e;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=o(()=>t(),"listener");return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#e||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#r=t,this.#e?.(),this.#e=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#t!==t&&(this.#t=t,this.onFocus())}onFocus(){let t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},V=new ar;var cr={setTimeout:o((t,e)=>setTimeout(t,e),"setTimeout"),clearTimeout:o(t=>clearTimeout(t),"clearTimeout"),setInterval:o((t,e)=>setInterval(t,e),"setInterval"),clearInterval:o(t=>clearInterval(t),"clearInterval")},ur=class{static{o(this,"TimeoutManager")}#t=cr;#e=!1;setTimeoutProvider(t){this.#e&&t!==this.#t&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:this.#t,provider:t}),this.#t=t,this.#e=!1}setTimeout(t,e){return this.#e=!0,this.#t.setTimeout(t,e)}clearTimeout(t){this.#t.clearTimeout(t)}setInterval(t,e){return this.#e=!0,this.#t.setInterval(t,e)}clearInterval(t){this.#t.clearInterval(t)}},x=new ur;function it(t){setTimeout(t,0)}o(it,"systemSetTimeoutZero");var Fe=typeof window>"u"||"Deno"in globalThis;function g(){}o(g,"noop");function ct(t,e){return typeof t=="function"?t(e):t}o(ct,"functionalUpdate");function te(t){return typeof t=="number"&&t>=0&&t!==1/0}o(te,"isValidTimeout");function me(t,e){return Math.max(t+(e||0)-Date.now(),0)}o(me,"timeUntilStale");function _(t,e){return typeof t=="function"?t(e):t}o(_,"resolveStaleTime");function k(t,e){return typeof t=="function"?t(e):t}o(k,"resolveQueryBoolean");function ye(t,e){let{type:r="all",exact:s,fetchStatus:n,predicate:i,queryKey:a,stale:u}=t;if(a){if(s){if(e.queryHash!==re(a,e.options))return!1}else if(!j(e.queryKey,a))return!1}if(r!=="all"){let c=e.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof u=="boolean"&&e.isStale()!==u||n&&n!==e.state.fetchStatus||i&&!i(e))}o(ye,"matchQuery");function ve(t,e){let{exact:r,status:s,predicate:n,mutationKey:i}=t;if(i){if(!e.options.mutationKey)return!1;if(r){if(H(e.options.mutationKey)!==H(i))return!1}else if(!j(e.options.mutationKey,i))return!1}return!(s&&e.state.status!==s||n&&!n(e))}o(ve,"matchMutation");function re(t,e){return(e?.queryKeyHashFn||H)(t)}o(re,"hashQueryKeyByOptions");function H(t){return JSON.stringify(t,(e,r)=>Re(r)?Object.keys(r).sort().reduce((s,n)=>(s[n]=r[n],s),{}):r)}o(H,"hashKey");function j(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>j(t[r],e[r])):!1}o(j,"partialMatchKey");var hr=Object.prototype.hasOwnProperty;function pe(t,e,r=0){if(t===e)return t;if(r>500)return e;let s=ot(t)&&ot(e);if(!s&&!(Re(t)&&Re(e)))return e;let i=(s?t:Object.keys(t)).length,a=s?e:Object.keys(e),u=a.length,c=s?new Array(u):{},h=0;for(let d=0;d<u;d++){let l=s?d:a[d],f=t[l],p=e[l];if(f===p){c[l]=f,(s?d<i:hr.call(t,l))&&h++;continue}if(f===null||p===null||typeof f!="object"||typeof p!="object"){c[l]=p;continue}let y=pe(f,p,r+1);c[l]=y,y===f&&h++}return i===u&&h===i?t:c}o(pe,"replaceEqualDeep");function be(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}o(be,"shallowEqualObjects");function ot(t){return Array.isArray(t)&&t.length===Object.keys(t).length}o(ot,"isPlainArray");function Re(t){if(!at(t))return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(!at(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}o(Re,"isPlainObject");function at(t){return Object.prototype.toString.call(t)==="[object Object]"}o(at,"hasObjectPrototype");function ut(t){return new Promise(e=>{x.setTimeout(e,t)})}o(ut,"sleep");function se(t,e,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(t,e);if(r.structuralSharing!==!1){try{return pe(t,e)}catch(s){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${s}`),s}return pe(t,e)}return e}o(se,"replaceData");function dr(t){return t}o(dr,"keepPreviousData");function ht(t,e,r=0){let s=[...t,e];return r&&s.length>r?s.slice(1):s}o(ht,"addToEnd");function dt(t,e,r=0){let s=[e,...t];return r&&s.length>r?s.slice(0,-1):s}o(dt,"addToStart");var N=Symbol();function ge(t,e){return t.queryFn===N&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`),!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===N?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}o(ge,"ensureQueryFn");function Se(t,e){return typeof t=="function"?t(...e):!!t}o(Se,"shouldThrowError");function lt(t,e,r){let s=!1,n;return Object.defineProperty(t,"signal",{enumerable:!0,get:o(()=>(n??=e(),s||(s=!0,n.aborted?r():n.addEventListener("abort",r,{once:!0})),n),"get")}),t}o(lt,"addConsumeAwareSignal");var R=(()=>{let t=o(()=>Fe,"isServerFn");return{isServer(){return t()},setIsServer(e){t=e}}})();function ne(){let t,e,r=new Promise((n,i)=>{t=n,e=i});r.status="pending",r.catch(()=>{});function s(n){Object.assign(r,n),delete r.resolve,delete r.reject}return o(s,"finalize"),r.resolve=n=>{s({status:"fulfilled",value:n}),t(n)},r.reject=n=>{s({status:"rejected",reason:n}),e(n)},r}o(ne,"pendingThenable");var ft=it;function lr(){let t=[],e=0,r=o(u=>{u()},"notifyFn"),s=o(u=>{u()},"batchNotifyFn"),n=ft,i=o(u=>{e?t.push(u):n(()=>{r(u)})},"schedule"),a=o(()=>{let u=t;t=[],u.length&&n(()=>{s(()=>{u.forEach(c=>{r(c)})})})},"flush");return{batch:o(u=>{let c;e++;try{c=u()}finally{e--,e||a()}return c},"batch"),batchCalls:o(u=>(...c)=>{i(()=>{u(...c)})},"batchCalls"),schedule:i,setNotifyFunction:o(u=>{r=u},"setNotifyFunction"),setBatchNotifyFunction:o(u=>{s=u},"setBatchNotifyFunction"),setScheduler:o(u=>{n=u},"setScheduler")}}o(lr,"createNotifyManager");var v=lr();var fr=class extends A{static{o(this,"OnlineManager")}#t=!0;#e;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=o(()=>t(!0),"onlineListener"),r=o(()=>t(!1),"offlineListener");return window.addEventListener("online",e,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#e||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#r=t,this.#e?.(),this.#e=t(this.setOnline.bind(this))}setOnline(t){this.#t!==t&&(this.#t=t,this.listeners.forEach(r=>{r(t)}))}isOnline(){return this.#t}},W=new fr;function pr(t){return Math.min(1e3*2**t,3e4)}o(pr,"defaultRetryDelay");function Me(t){return(t??"online")==="online"?W.isOnline():!0}o(Me,"canFetch");var we=class extends Error{static{o(this,"CancelledError")}constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Ee(t){let e=!1,r=0,s,n=ne(),i=o(()=>n.status!=="pending","isResolved"),a=o(m=>{if(!i()){let b=new we(m);f(b),t.onCancel?.(b)}},"cancel"),u=o(()=>{e=!0},"cancelRetry"),c=o(()=>{e=!1},"continueRetry"),h=o(()=>V.isFocused()&&(t.networkMode==="always"||W.isOnline())&&t.canRun(),"canContinue"),d=o(()=>Me(t.networkMode)&&t.canRun(),"canStart"),l=o(m=>{i()||(s?.(),n.resolve(m))},"resolve"),f=o(m=>{i()||(s?.(),n.reject(m))},"reject"),p=o(()=>new Promise(m=>{s=o(b=>{(i()||h())&&m(b)},"continueFn"),t.onPause?.()}).then(()=>{s=void 0,i()||t.onContinue?.()}),"pause"),y=o(()=>{if(i())return;let m,b=r===0?t.initialPromise:void 0;try{m=b??t.fn()}catch(w){m=Promise.reject(w)}Promise.resolve(m).then(l).catch(w=>{if(i())return;let T=t.retry??(R.isServer()?0:3),F=t.retryDelay??pr,Q=typeof F=="function"?F(r,w):F,q=T===!0||typeof T=="number"&&r<T||typeof T=="function"&&T(r,w);if(e||!q){f(w);return}r++,t.onFail?.(r,w),ut(Q).then(()=>h()?void 0:p()).then(()=>{e?f(w):y()})})},"run");return{promise:n,status:o(()=>n.status,"status"),cancel:a,continue:o(()=>(s?.(),n),"continue"),cancelRetry:u,continueRetry:c,canStart:d,start:o(()=>(d()?y():p().then(y),n),"start")}}o(Ee,"createRetryer");var Ce=class{static{o(this,"Removable")}#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),te(this.gcTime)&&(this.#t=x.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(R.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#t!==void 0&&(x.clearTimeout(this.#t),this.#t=void 0)}};function mt(t){return{onFetch:o((e,r)=>{let s=e.options,n=e.fetchOptions?.meta?.fetchMore?.direction,i=e.state.data?.pages||[],a=e.state.data?.pageParams||[],u={pages:[],pageParams:[]},c=0,h=o(async()=>{let d=!1,l=o(y=>{lt(y,()=>e.signal,()=>d=!0)},"addSignalProperty"),f=ge(e.options,e.fetchOptions),p=o(async(y,m,b)=>{if(d)return Promise.reject(e.signal.reason);if(m==null&&y.pages.length)return Promise.resolve(y);let T=o(()=>{let xe={client:e.client,queryKey:e.queryKey,pageParam:m,direction:b?"backward":"forward",meta:e.options.meta};return l(xe),xe},"createQueryFnContext")(),F=await f(T),{maxPages:Q}=e.options,q=b?dt:ht;return{pages:q(y.pages,F,Q),pageParams:q(y.pageParams,m,Q)}},"fetchPage");if(n&&i.length){let y=n==="backward",m=y?mr:pt,b={pages:i,pageParams:a},w=m(s,b);u=await p(b,w,y)}else{let y=t??i.length;do{let m=c===0?a[0]??s.initialPageParam:pt(s,u);if(c>0&&m==null)break;u=await p(u,m),c++}while(c<y)}return u},"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")}}o(mt,"infiniteQueryBehavior");function pt(t,{pages:e,pageParams:r}){let s=e.length-1;return e.length>0?t.getNextPageParam(e[s],e,r[s],r):void 0}o(pt,"getNextPageParam");function mr(t,{pages:e,pageParams:r}){return e.length>0?t.getPreviousPageParam?.(e[0],e,r[0],r):void 0}o(mr,"getPreviousPageParam");var bt=class extends Ce{static{o(this,"Query")}#t;#e;#r;#s;#i;#n;#a;#o;constructor(t){super(),this.#o=!1,this.#a=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#i=t.client,this.#s=this.#i.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=vt(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#t}get promise(){return this.#n?.promise}setOptions(t){if(this.options={...this.#a,...t},t?._type&&(this.#t=t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=vt(this.options);e.data!==void 0&&(this.setState(yt(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(t,e){let r=se(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.#n?.promise;return this.#n?.cancel(t),e?e.then(g).catch(g):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>k(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===N||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>_(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.#n?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.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.#n&&(this.#o||this.#h()?this.#n.cancel({revert:!0}):this.#n.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.#n?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(t&&this.setOptions(t),!this.options.queryFn){let c=this.observers.find(h=>h.options.queryFn);c&&this.setOptions(c.options)}Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']");let r=new AbortController,s=o(c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:o(()=>(this.#o=!0,r.signal),"get")})},"addSignalProperty"),n=o(()=>{let c=ge(this.options,e),d=o(()=>{let l={client:this.#i,queryKey:this.queryKey,meta:this.meta};return s(l),l},"createQueryFnContext")();return this.#o=!1,this.options.persister?this.options.persister(c,d,this):c(d)},"fetchFn"),a=o(()=>{let c={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:n};return s(c),c},"createFetchContext")();(this.#t==="infinite"?mt(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#r=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:"fetch",meta:a.fetchOptions?.meta}),this.#n=Ee({initialPromise:e?.initialPromise,fn:a.fetchFn,onCancel:o(c=>{c instanceof we&&c.revert&&this.setState({...this.#r,fetchStatus:"idle"}),r.abort()},"onCancel"),onFail:o((c,h)=>{this.#c({type:"failed",failureCount:c,error:h})},"onFail"),onPause:o(()=>{this.#c({type:"pause"})},"onPause"),onContinue:o(()=>{this.#c({type:"continue"})},"onContinue"),retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:o(()=>!0,"canRun")});try{let c=await this.#n.start();if(c===void 0)throw console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(c),this.#s.config.onSuccess?.(c,this),this.#s.config.onSettled?.(c,this.state.error,this),c}catch(c){if(c instanceof we){if(c.silent)return this.#n.promise;if(c.revert){if(this.state.data===void 0)throw c;return this.state.data}}throw this.#c({type:"error",error:c}),this.#s.config.onError?.(c,this),this.#s.config.onSettled?.(this.state.data,c,this),c}finally{this.scheduleGc()}}#c(t){let e=o(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,...Le(r.data,this.options),fetchMeta:t.meta??null};case"success":let s={...r,...yt(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 n=t.error;return{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,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 Le(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Me(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}o(Le,"fetchState");function yt(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}o(yt,"successState");function vt(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"}}o(vt,"getDefaultState");var Ue=class extends A{static{o(this,"QueryObserver")}constructor(t,e){super(),this.options=e,this.#t=t,this.#o=null,this.#a=ne(),this.bindMethods(),this.setOptions(e)}#t;#e=void 0;#r=void 0;#s=void 0;#i;#n;#a;#o;#h;#c;#p;#d;#l;#u;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),gt(this.#e,this.options)?this.#f():this.updateResult(),this.#g())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return De(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return De(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#w(),this.#e.removeObserver(this)}setOptions(t){let e=this.options,r=this.#e;if(this.options=this.#t.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof k(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#E(),this.#e.setOptions(this.options),e._defaulted&&!be(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});let s=this.hasListeners();s&&St(this.#e,r,this.options,e)&&this.#f(),this.updateResult(),s&&(this.#e!==r||k(this.options.enabled,this.#e)!==k(e.enabled,this.#e)||_(this.options.staleTime,this.#e)!==_(e.staleTime,this.#e))&&this.#y();let n=this.#v();s&&(this.#e!==r||k(this.options.enabled,this.#e)!==k(e.enabled,this.#e)||n!==this.#u)&&this.#b(n)}getOptimisticResult(t){let e=this.#t.getQueryCache().build(this.#t,t),r=this.createResult(e,t);return vr(this,r)&&(this.#s=r,this.#n=this.options,this.#i=this.#e.state),r}getCurrentResult(){return this.#s}trackResult(t,e){return new Proxy(t,{get:o((r,s)=>(this.trackProp(s),e?.(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#a.status==="pending"&&this.#a.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s)),"get")})}trackProp(t){this.#m.add(t)}getCurrentQuery(){return this.#e}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let e=this.#t.defaultQueryOptions(t),r=this.#t.getQueryCache().build(this.#t,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.#E();let e=this.#e.fetch(this.options,t);return t?.throwOnError||(e=e.catch(g)),e}#y(){this.#S();let t=_(this.options.staleTime,this.#e);if(R.isServer()||this.#s.isStale||!te(t))return;let r=me(this.#s.dataUpdatedAt,t)+1;this.#d=x.setTimeout(()=>{this.#s.isStale||this.updateResult()},r)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(t){this.#w(),this.#u=t,!(R.isServer()||k(this.options.enabled,this.#e)===!1||!te(this.#u)||this.#u===0)&&(this.#l=x.setInterval(()=>{(this.options.refetchIntervalInBackground||V.isFocused())&&this.#f()},this.#u))}#g(){this.#y(),this.#b(this.#v())}#S(){this.#d!==void 0&&(x.clearTimeout(this.#d),this.#d=void 0)}#w(){this.#l!==void 0&&(x.clearInterval(this.#l),this.#l=void 0)}createResult(t,e){let r=this.#e,s=this.options,n=this.#s,i=this.#i,a=this.#n,c=t!==r?t.state:this.#r,{state:h}=t,d={...h},l=!1,f;if(e._optimisticResults){let P=this.hasListeners(),ee=!P&>(t,e),de=P&&St(t,r,e,s);(ee||de)&&(d={...d,...Le(h.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:y,status:m}=d;f=d.data;let b=!1;if(e.placeholderData!==void 0&&f===void 0&&m==="pending"){let P;n?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(P=n.data,b=!0):P=typeof e.placeholderData=="function"?e.placeholderData(this.#p?.state.data,this.#p):e.placeholderData,P!==void 0&&(m="success",f=se(n?.data,P,e),l=!0)}if(e.select&&f!==void 0&&!b)if(n&&f===i?.data&&e.select===this.#h)f=this.#c;else try{this.#h=e.select,f=e.select(f),f=se(n?.data,f,e),this.#c=f,this.#o=null}catch(P){this.#o=P}this.#o&&(p=this.#o,f=this.#c,y=Date.now(),m="error");let w=d.fetchStatus==="fetching",T=m==="pending",F=m==="error",Q=T&&w,q=f!==void 0,D={status:m,fetchStatus:d.fetchStatus,isPending:T,isSuccess:m==="success",isError:F,isInitialLoading:Q,isLoading:Q,data:f,dataUpdatedAt:d.dataUpdatedAt,error:p,errorUpdatedAt:y,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:w,isRefetching:w&&!T,isLoadingError:F&&!q,isPaused:d.fetchStatus==="paused",isPlaceholderData:l,isRefetchError:F&&q,isStale:Qe(t,e),refetch:this.refetch,promise:this.#a,isEnabled:k(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){let P=D.data!==void 0,ee=D.status==="error"&&!P,de=o(fe=>{ee?fe.reject(D.error):P&&fe.resolve(D.data)},"finalizeThenableIfPossible"),rt=o(()=>{let fe=this.#a=D.promise=ne();de(fe)},"recreateThenable"),le=this.#a;switch(le.status){case"pending":t.queryHash===r.queryHash&&de(le);break;case"fulfilled":(ee||D.data!==le.value)&&rt();break;case"rejected":(!ee||D.error!==le.reason)&&rt();break}}return D}updateResult(){let t=this.#s,e=this.createResult(this.#e,this.options);if(this.#i=this.#e.state,this.#n=this.options,this.#i.data!==void 0&&(this.#p=this.#e),be(e,t))return;this.#s=e;let r=o(()=>{if(!t)return!0;let{notifyOnChangeProps:s}=this.options,n=typeof s=="function"?s():s;if(n==="all"||!n&&!this.#m.size)return!0;let i=new Set(n??this.#m);return this.options.throwOnError&&i.add("error"),Object.keys(this.#s).some(a=>{let u=a;return this.#s[u]!==t[u]&&i.has(u)})},"shouldNotifyListeners");this.#C({listeners:r()})}#E(){let t=this.#t.getQueryCache().build(this.#t,this.options);if(t===this.#e)return;let e=this.#e;this.#e=t,this.#r=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#g()}#C(t){v.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#s)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function yr(t,e){return k(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&k(e.retryOnMount,t)===!1)}o(yr,"shouldLoadOnMount");function gt(t,e){return yr(t,e)||t.state.data!==void 0&&De(t,e,e.refetchOnMount)}o(gt,"shouldFetchOnMount");function De(t,e,r){if(k(e.enabled,t)!==!1&&_(e.staleTime,t)!=="static"){let s=typeof r=="function"?r(t):r;return s==="always"||s!==!1&&Qe(t,e)}return!1}o(De,"shouldFetchOn");function St(t,e,r,s){return(t!==e||k(s.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&Qe(t,r)}o(St,"shouldFetchOptionally");function Qe(t,e){return k(e.enabled,t)!==!1&&t.isStaleByTime(_(e.staleTime,t))}o(Qe,"isStale");function vr(t,e){return!be(t.getCurrentResult(),e)}o(vr,"shouldAssignObserverCurrentProperties");var wt=class extends Ce{static{o(this,"Mutation")}#t;#e;#r;#s;constructor(t){super(),this.#t=t.client,this.mutationId=t.mutationId,this.#r=t.mutationCache,this.#e=[],this.state=t.state||br(),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.#e.includes(t)||(this.#e.push(t),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#e=this.#e.filter(e=>e!==t),this.scheduleGc(),this.#r.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#e.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=o(()=>{this.#i({type:"continue"})},"onContinue"),r={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#s=Ee({fn:o(()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),"fn"),onFail:o((i,a)=>{this.#i({type:"failed",failureCount:i,error:a})},"onFail"),onPause:o(()=>{this.#i({type:"pause"})},"onPause"),onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:o(()=>this.#r.canRun(this),"canRun")});let s=this.state.status==="pending",n=!this.#s.canStart();try{if(s)e();else{this.#i({type:"pending",variables:t,isPaused:n}),this.#r.config.onMutate&&await this.#r.config.onMutate(t,this,r);let a=await this.options.onMutate?.(t,r);a!==this.state.context&&this.#i({type:"pending",context:a,variables:t,isPaused:n})}let i=await this.#s.start();return await this.#r.config.onSuccess?.(i,t,this.state.context,this,r),await this.options.onSuccess?.(i,t,this.state.context,r),await this.#r.config.onSettled?.(i,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(i,null,t,this.state.context,r),this.#i({type:"success",data:i}),i}catch(i){try{await this.#r.config.onError?.(i,t,this.state.context,this,r)}catch(a){Promise.reject(a)}try{await this.options.onError?.(i,t,this.state.context,r)}catch(a){Promise.reject(a)}try{await this.#r.config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,r)}catch(a){Promise.reject(a)}try{await this.options.onSettled?.(void 0,i,t,this.state.context,r)}catch(a){Promise.reject(a)}throw this.#i({type:"error",error:i}),i}finally{this.#r.runNext(this)}}#i(t){let e=o(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.#e.forEach(r=>{r.onMutationUpdate(t)}),this.#r.notify({mutation:this,type:"updated",action:t})})}};function br(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}o(br,"getDefaultState");var Et=class extends A{static{o(this,"MutationCache")}constructor(t={}){super(),this.config=t,this.#t=new Set,this.#e=new Map,this.#r=0}#t;#e;#r;build(t,e,r){let s=new wt({client:t,mutationCache:this,mutationId:++this.#r,options:t.defaultMutationOptions(e),state:r});return this.add(s),s}add(t){this.#t.add(t);let e=Te(t);if(typeof e=="string"){let r=this.#e.get(e);r?r.push(t):this.#e.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#t.delete(t)){let e=Te(t);if(typeof e=="string"){let r=this.#e.get(e);if(r)if(r.length>1){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&this.#e.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){let e=Te(t);if(typeof e=="string"){let s=this.#e.get(e)?.find(n=>n.state.status==="pending");return!s||s===t}else return!0}runNext(t){let e=Te(t);return typeof e=="string"?this.#e.get(e)?.find(s=>s!==t&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){v.batch(()=>{this.#t.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(t){let e={exact:!0,...t};return this.getAll().find(r=>ve(e,r))}findAll(t={}){return this.getAll().filter(e=>ve(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 Te(t){return t.options.scope?.id}o(Te,"scopeFor");var Ct=class extends A{static{o(this,"QueryCache")}constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,r){let s=e.queryKey,n=e.queryHash??re(s,e),i=this.get(n);return i||(i=new bt({client:t,queryKey:s,queryHash:n,options:t.defaultQueryOptions(e),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(i)),i}add(t){this.#t.has(t.queryHash)||(this.#t.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){let e=this.#t.get(t.queryHash);e&&(t.destroy(),e===t&&this.#t.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){v.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#t.get(t)}getAll(){return[...this.#t.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 qe=class{static{o(this,"QueryClient")}#t;#e;#r;#s;#i;#n;#a;#o;constructor(t={}){this.#t=t.queryCache||new Ct,this.#e=t.mutationCache||new Et,this.#r=t.defaultOptions||{},this.#s=new Map,this.#i=new Map,this.#n=0}mount(){this.#n++,this.#n===1&&(this.#a=V.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#o=W.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#n--,this.#n===0&&(this.#a?.(),this.#a=void 0,this.#o?.(),this.#o=void 0)}isFetching(t){return this.#t.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#e.findAll({...t,status:"pending"}).length}getQueryData(t){let e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state.data}ensureQueryData(t){let e=this.defaultQueryOptions(t),r=this.#t.build(this,e),s=r.state.data;return s===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(_(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(s))}getQueriesData(t){return this.#t.findAll(t).map(({queryKey:e,state:r})=>{let s=r.data;return[e,s]})}setQueryData(t,e,r){let s=this.defaultQueryOptions({queryKey:t}),i=this.#t.get(s.queryHash)?.state.data,a=ct(e,i);if(a!==void 0)return this.#t.build(this,s).setData(a,{...r,manual:!0})}setQueriesData(t,e,r){return v.batch(()=>this.#t.findAll(t).map(({queryKey:s})=>[s,this.setQueryData(s,e,r)]))}getQueryState(t){let e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state}removeQueries(t){let e=this.#t;v.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){let r=this.#t;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.#t.findAll(t).map(n=>n.cancel(r)));return Promise.all(s).then(g).catch(g)}invalidateQueries(t,e={}){return v.batch(()=>(this.#t.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.#t.findAll(t).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let i=n.fetch(void 0,r);return r.throwOnError||(i=i.catch(g)),n.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(s).then(g)}fetchQuery(t){let e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);let r=this.#t.build(this,e);return r.isStaleByTime(_(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 W.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#r}setDefaultOptions(t){this.#r=t}setQueryDefaults(t,e){this.#s.set(H(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){let e=[...this.#s.values()],r={};return e.forEach(s=>{j(t,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(t,e){this.#i.set(H(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){let e=[...this.#i.values()],r={};return e.forEach(s=>{j(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=re(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===N&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#r.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}};var z=O(B(),1),Tt=O(nt(),1);var ie=z.createContext(void 0),Be=o(t=>{let e=z.useContext(ie);if(t)return t;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},"useQueryClient"),He=o(({client:t,children:e})=>(z.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),(0,Tt.jsx)(ie.Provider,{value:t,children:e})),"QueryClientProvider");var ke=O(B(),1);var kt=ke.createContext(!1),It=o(()=>ke.useContext(kt),"useIsRestoring"),Qi=kt.Provider;var oe=O(B(),1),gr=O(nt(),1);function Sr(){let t=!1;return{clearReset:o(()=>{t=!1},"clearReset"),reset:o(()=>{t=!0},"reset"),isReset:o(()=>t,"isReset")}}o(Sr,"createValue");var wr=oe.createContext(Sr()),Pt=o(()=>oe.useContext(wr),"useQueryErrorResetBoundary");var Ot=O(B(),1);var _t=o((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"),At=o(t=>{Ot.useEffect(()=>{t.clearReset()},[t])},"useClearResetErrorBoundary"),xt=o(({result:t,errorResetBoundary:e,throwOnError:r,query:s,suspense:n})=>t.isError&&!e.isReset()&&!t.isFetching&&s&&(n&&t.data===void 0||Se(r,[t.error,s])),"getHasError");var Rt=o(t=>{if(t.suspense){let r=o(n=>n==="static"?n:Math.max(n??1e3,1e3),"clamp"),s=t.staleTime;t.staleTime=typeof s=="function"?(...n)=>r(s(...n)):r(s),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},"ensureSuspenseTimers"),Ft=o((t,e)=>t.isLoading&&t.isFetching&&!e,"willFetch"),Mt=o((t,e)=>t?.suspense&&e.isPending,"shouldSuspend"),Ne=o((t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()}),"fetchOptimistic");var U=O(B(),1);function Lt(t,e,r){if(typeof t!="object"||Array.isArray(t))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');let s=It(),n=Pt(),i=Be(r),a=i.defaultQueryOptions(t);i.getDefaultOptions().queries?._experimental_beforeQuery?.(a);let u=i.getQueryCache().get(a.queryHash);a.queryFn||console.error(`[${a.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`);let c=t.subscribed!==!1;a._optimisticResults=s?"isRestoring":c?"optimistic":void 0,Rt(a),_t(a,n,u),At(n);let h=!i.getQueryCache().get(a.queryHash),[d]=U.useState(()=>new e(i,a)),l=d.getOptimisticResult(a),f=!s&&c;if(U.useSyncExternalStore(U.useCallback(p=>{let y=f?d.subscribe(v.batchCalls(p)):g;return d.updateResult(),y},[d,f]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),U.useEffect(()=>{d.setOptions(a)},[a,d]),Mt(a,l))throw Ne(a,d,n);if(xt({result:l,errorResetBoundary:n,throwOnError:a.throwOnError,query:u,suspense:a.suspense}))throw l.error;return i.getDefaultOptions().queries?._experimental_afterQuery?.(a,l),a.experimental_prefetchInRender&&!R.isServer()&&Ft(l,s)&&(h?Ne(a,d,n):u?.promise)?.catch(g).finally(()=>{d.updateResult()}),a.notifyOnChangeProps?l:d.trackResult(l)}o(Lt,"useBaseQuery");function Er(t,e){return Lt(t,Ue,e)}o(Er,"useQuery");var K=O(B(),1),je=O(or(),1);var Ut=(0,K.createContext)(null),Cr=o(()=>new qe({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),"createDefaultQueryClient"),Tr=o(t=>{let e=(0,Dt.c)(9),{children:r,client:s,queryClient:n}=t,i=(0,K.use)(ie),a;e[0]!==i||e[1]!==n?(a=o(()=>n??i??Cr(),"t1"),e[0]=i,e[1]=n,e[2]=a):a=e[2];let[u]=(0,K.useState)(a),c=n??i??u;if(!c)throw new Error("LunoraProvider: failed to resolve a QueryClient");let h;e[3]!==r||e[4]!==s?(h=(0,je.jsxDEV)(Ut,{value:s,children:r},void 0,!1),e[3]=r,e[4]=s,e[5]=h):h=e[5];let d=h;if(i===c)return d;let l;return e[6]!==d||e[7]!==c?(l=(0,je.jsxDEV)(He,{client:c,children:d},void 0,!1),e[6]=d,e[7]=c,e[8]=l):l=e[8],l},"LunoraProvider"),Ke=o(()=>{let t=(0,K.use)(Ut);if(!t)throw new Error("useLunora must be used inside <LunoraProvider />");return t},"useLunora");var Qt=O(st(),1),qt=O(B(),1);var kr=o(()=>{let t=(0,Qt.c)(4),e=Ke(),r,s,n;return t[0]!==e?(r=o(i=>e.onConnectionStatus(()=>{i()}),"t0"),s=o(()=>e.connectionStatus(),"t1"),n=o(()=>e.connectionStatus(),"t2"),t[0]=e,t[1]=r,t[2]=s,t[3]=n):(r=t[1],s=t[2],n=t[3]),(0,qt.useSyncExternalStore)(r,s,n)},"useConnectionStatus");var Bt=o(()=>{let t=null;return{get:o(()=>t,"get"),set:o(e=>{t=e},"set")}},"createInMemoryBookmarkStorage");var Ht="_creationTime",Ir=o(t=>{if(typeof t!="object"||t===null)return;let e=t._id;return typeof e=="string"?e:void 0},"rowId"),Pr=o((t,e)=>{let r=e[Ht];if(typeof r!="number")return t.length;for(let[s,n]of t.entries()){let i=n[Ht];if(typeof i=="number"&&i>r)return s}return t.length},"insertionIndex"),Nt=o(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")},"isMutationDelta"),jt=o((t,e)=>{if(!Array.isArray(t))return;let r=[];for(let c of t){if(Ir(c)===void 0)return;r.push(c)}let{key:s,op:n,row:i}=e;if(n==="delete"){let c=r.filter(h=>h._id!==s);return c.length===r.length?[...r]:c}if(i===void 0)return;let a=r.findIndex(c=>c._id===s);if(a===-1){let c=[...r];return c.splice(Pr(r,i),0,i),c}let u=[...r];return u[a]=i,u},"applyDelta");var Ie=o((t,e)=>{let r=t;for(let s of e)try{r=s.transform(r)}catch{}return r},"foldOptimistic"),ae=o((t,e)=>{if(e!==t.lastValue){t.lastValue=e;for(let r of t.callbacks)try{r(e)}catch{}}},"notifySubscription"),$e=o((t,e)=>{let r;try{r=e(t.lastValue)}catch{return}let s={id:Symbol("optimistic"),transform:e};t.optimisticLayers.push(s),ae(t,r);let n=o(()=>{let a=t.optimisticLayers.findIndex(u=>u.id===s.id);return a===-1?!1:(t.optimisticLayers.splice(a,1),!0)},"remove"),i=o(()=>{ae(t,Ie(t.serverBase,t.optimisticLayers))},"refold");return{confirm:o(a=>{if(a===void 0){n();return}s.commitCursor=a,t.serverCursor!==void 0&&t.serverCursor>=a&&n()&&i()},"confirm"),rollback:o(()=>{n()&&i()},"rollback")}},"applyOptimisticLayer"),Ge=o((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},"dropConfirmedLayers"),Kt=o((t,e,r)=>{let s=[],n=[],i=o((u,c)=>{for(let h of t.all())if(h.fn.__lunoraRef===u&&h.shardKey===e&&h.argsKey===c)return h},"findState");return{confirms:s,rollbacks:n,store:{getAllQueries:o(u=>{let c=[];for(let h of t.all())h.fn.__lunoraRef===u.__lunoraRef&&h.shardKey===e&&c.push({args:h.args,value:h.lastValue});return c},"getAllQueries"),getQuery:o((u,c)=>i(u.__lunoraRef,r(c??{}))?.lastValue,"getQuery"),setQuery:o((u,c,h)=>{let d=i(u.__lunoraRef,r(c??{}));if(!d)return;let l=$e(d,()=>h);l&&(s.push(l.confirm),n.push(l.rollback))},"setQuery")}}},"createLocalStore");var Or=o((t,e)=>t<e?-1:t>e?1:0,"compareKeys"),J=o(t=>{if(t===void 0)return"null";if(typeof t=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a cache key (query/subscription/shape args) \u2014 pass it as a string");if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(i=>J(i)).join(",")}]`;let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype){let i=t.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${i} in a cache key (query/subscription/shape args) \u2014 only plain objects, arrays, and JSON primitives are supported`)}let r=t,s=Object.keys(r).toSorted(Or),n=[];for(let i of s){let a=r[i];a!==void 0&&n.push(`${JSON.stringify(i)}:${J(a)}`)}return`{${n.join(",")}}`},"stableStringify"),X=class t{static{o(this,"SubscriptionRegistry")}static key(e,r,s){return`${e}::${J(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){this.byKey.delete(t.key(e.fn.__lunoraRef,e.args,e.shardKey)),this.byId.delete(e.id)}all(){return[...this.byKey.values()]}};var Ve=o((t,e)=>t!==void 0&&e!==t,"isStaleVersion"),$t=0,Oe=o(()=>{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();$t+=1;let t=typeof crypto<"u"&&typeof crypto.getRandomValues=="function"?[...crypto.getRandomValues(new Uint8Array(8))].map(e=>e.toString(16).padStart(2,"0")).join(""):Math.random().toString(16).slice(2,12);return`m_${Date.now().toString(36)}_${$t.toString(36)}_${t}`},"nextId"),Y=o((t,e,r,s)=>{if(t){t({error:r,mutationId:s,operation:e});return}console.warn(`[lunora] offline-queue persistence ${e} failed`,r)},"reportPersistenceError"),Pe=class{static{o(this,"OfflineQueue")}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;for(r.id??=Oe(),this.items.push(r),this.persistence?.append({args:r.args,functionPath:r.functionPath,id:r.id,identity:r.identity,shardKey:r.shardKey,...this.version===void 0?{}:{version:this.version}}).catch(s=>{Y(this.onPersistenceError,"append",s,r.id)});this.items.length>this.maxItems;){let s=this.items.shift();if(s){s.id&&this.persistence?.remove(s.id).catch(i=>{Y(this.onPersistenceError,"remove",i,s.id)});let n=new Error("offline queue overflow");n.code="OFFLINE_QUEUE_OVERFLOW",s.reject(n),this.onEvict?.(s,n)}}this.notifySize()}async hydrate(){if(!this.persistence)return[];let e;try{e=await this.persistence.load()}catch(s){throw Y(this.onPersistenceError,"load",s),s}let r=new Set;for(let s of e)if(!this.items.some(n=>n.id===s.id)){if(Ve(this.version,s.version)){this.persistence.remove(s.id).catch(n=>{Y(this.onPersistenceError,"remove",n,s.id)});continue}this.items.push({args:s.args,functionPath:s.functionPath,id:s.id,identity:s.identity,reject:o(()=>{},"reject"),resolve:o(()=>{},"resolve"),shardKey:s.shardKey}),r.add(s.shardKey)}return this.notifySize(),[...r]}drain(e){if(!e){let n=[...this.items];return this.items.length=0,this.notifySize(),n}let r=[],s=[];for(let n of this.items)(e(n)?r:s).push(n);return this.items.length=0,this.items.push(...s),this.notifySize(),r}requeue(e){e.length!==0&&(this.items.unshift(...e),this.notifySize())}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()}notifySize(){this.onSizeChange?.(this.items.length)}};var _r="lunora-outbox",Ar="offline-mutations",Gt="by_id",ce=o(t=>new Promise((e,r)=>{t.addEventListener("success",()=>{e(t.result)}),t.addEventListener("error",()=>{r(t.error??new Error("IndexedDB request failed"))})}),"promisifyRequest"),xr=o((t={})=>{let e=t.indexedDB??(typeof indexedDB>"u"?void 0:indexedDB);if(!e)throw new Error("createIndexedDbPersistence: no IndexedDB available \u2014 pass `indexedDB` or use createInMemoryPersistence()");let r=t.databaseName??_r,s=t.storeName??Ar,n,i=o(()=>n||(n=new Promise((u,c)=>{let h=e.open(r,1);h.addEventListener("upgradeneeded",()=>{let d=h.result;d.objectStoreNames.contains(s)||d.createObjectStore(s,{autoIncrement:!0}).createIndex(Gt,"id",{unique:!0})}),h.addEventListener("success",()=>{u(h.result)}),h.addEventListener("error",()=>{c(h.error??new Error("IndexedDB open failed"))})}),n),"openDatabase"),a=o(async(u,c)=>{let d=(await i()).transaction(s,u),l=await c(d.objectStore(s));return await new Promise((f,p)=>{d.addEventListener("complete",()=>{f()}),d.addEventListener("error",()=>{p(d.error??new Error("IndexedDB transaction failed"))}),d.addEventListener("abort",()=>{p(d.error??new Error("IndexedDB transaction aborted"))})}),l},"withStore");return{append:o(async u=>{await a("readwrite",c=>ce(c.add(u)))},"append"),clear:o(async()=>{await a("readwrite",u=>ce(u.clear()))},"clear"),load:o(async()=>a("readonly",u=>ce(u.getAll())),"load"),remove:o(async u=>{await a("readwrite",async c=>{let h=await ce(c.index(Gt).getKey(u));h!==void 0&&await ce(c.delete(h))})},"remove")}},"createIndexedDbPersistence"),Vt=o((t,e=!0)=>{if(t!==!1){if(t)return t;if(!(!e||typeof indexedDB>"u"))return xr()}},"resolvePersistenceAdapter");var We=o((t,e,r)=>`${t}::${e}::${r??""}`,"queryCacheKey"),Rr=500;var Fr="lunora-query-cache",Mr="query-cache",Wt="by_ts",Lr=1,ue=o(t=>new Promise((e,r)=>{t.addEventListener("success",()=>{e(t.result)}),t.addEventListener("error",()=>{r(t.error??new Error("IndexedDB request failed"))})}),"promisifyRequest"),Dr=o((t={})=>{let e=t.indexedDB??(typeof indexedDB>"u"?void 0:indexedDB);if(!e)throw new Error("createIndexedDbQueryCache: no IndexedDB available \u2014 pass `indexedDB` or use createInMemoryQueryCache()");let r=t.databaseName??Fr,s=t.storeName??Mr,n=t.maxEntries??Rr,i,a=o(()=>i||(i=new Promise((h,d)=>{let l=e.open(r,Lr);l.addEventListener("upgradeneeded",()=>{let f=l.result;f.objectStoreNames.contains(s)||f.createObjectStore(s,{keyPath:"key"}).createIndex(Wt,"ts",{unique:!1})}),l.addEventListener("success",()=>{h(l.result)}),l.addEventListener("error",()=>{d(l.error??new Error("IndexedDB open failed"))})}),i),"openDatabase"),u=o(async(h,d)=>{let f=(await a()).transaction(s,h),p=await d(f.objectStore(s));return await new Promise((y,m)=>{f.addEventListener("complete",()=>{y()}),f.addEventListener("error",()=>{m(f.error??new Error("IndexedDB transaction failed"))}),f.addEventListener("abort",()=>{m(f.error??new Error("IndexedDB transaction aborted"))})}),p},"withStore"),c=o(async h=>{let l=await ue(h.count())-n;l<=0||await new Promise((f,p)=>{let y=h.index(Wt).openCursor();y.addEventListener("success",()=>{let m=y.result;if(!m||l<=0){f();return}m.delete(),l-=1,m.continue()}),y.addEventListener("error",()=>{p(y.error??new Error("IndexedDB eviction failed"))})})},"evict");return{clear:o(async()=>{await u("readwrite",h=>ue(h.clear()))},"clear"),load:o(async()=>u("readonly",h=>ue(h.getAll())),"load"),put:o(async(h,d)=>{await u("readwrite",async l=>{await ue(l.put({...d,key:h})),await c(l)})},"put"),remove:o(async h=>{await u("readwrite",d=>ue(d.delete(h)))},"remove")}},"createIndexedDbQueryCache"),zt=o(t=>{if(t!==!1){if(t)return t;if(!(typeof indexedDB>"u"))return Dr()}},"resolveQueryCacheAdapter");var ze=o((t={},e=Math.random)=>{let r=t.initialDelayMs??250,s=t.maxDelayMs??3e4,n=t.jitter??!0,i=0;return{next(){let a=Math.min(s,r*2**i);if(i+=1,!n)return a;let u=a/2;return Math.floor(u+e()*(a-u))},reset(){i=0}}},"createReconnect");var Jt=o(t=>{let e=t.maxBuffer??1024,r=[],s=[],n=!1,i,a=!1,u=o(()=>{let l=s.shift();if(!l)return!1;if(i)return l.reject(i),!0;if(r.length>0){let f=r.shift();return l.resolve({done:!1,value:f}),!0}return n?(l.resolve({done:!0,value:void 0}),!0):(s.unshift(l),!1)},"flushOne"),c={complete(){if(!(n||i))for(n=!0;u(););},fail(l){if(!(n||i))for(i=l,r.length=0;u(););},push(l){if(!(n||i||a)){if(r.length>=e){c.fail(Object.assign(new Error(`stream buffer overflow (max=${e.toString()}); the consumer cannot keep up with the producer`),{code:"STREAM_BACKPRESSURE"}));return}r.push(l),u()}}},h=o(()=>{if(!a){a=!0,n=!0,r.length=0;try{t.onCancel()}catch{}for(;u(););}},"cancel");return{handle:c,iterable:{cancel:h,[Symbol.asyncIterator](){return{next(){if(i)return Promise.reject(i);if(r.length>0){let l=r.shift();return Promise.resolve({done:!1,value:l})}return n?Promise.resolve({done:!0,value:void 0}):new Promise((l,f)=>{s.push({reject:f,resolve:l})})},return(){return h(),Promise.resolve({done:!0,value:void 0})}}}}}},"createStream");var Je=500,C="$lunora.wire$",Ae=64,Xt=1024,Yt="__proto__",Zt={BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array},er={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},Xe=o(t=>{let e="";for(let s=0;s<t.length;s+=32768)e+=String.fromCharCode(...t.subarray(s,s+32768));return btoa(e)},"toBase64"),Ur=o(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},"fromBase64"),L=o((t,e=0)=>{if(e>Ae)throw new RangeError(`wire-codec: value nesting exceeds the ${Ae}-level limit`);if(t===void 0)return[C,"undefined"];if(t===null)return null;let r=typeof t;if(r==="bigint")return[C,"bigint",t.toString()];if(r==="number"){let a=t;return Number.isNaN(a)?[C,"nan"]:a===1/0?[C,"inf"]:a===-1/0?[C,"-inf"]:a}if(r!=="object")return t;if(t instanceof Date)return[C,"date",L(t.getTime(),e+1)];if(t instanceof Error){let a=t,u={};for(let h of Object.keys(a))a[h]!==void 0&&(u[h]=L(a[h],e+1));let c=[C,"error",a.name,a.message,u];return a.cause!==void 0&&c.push(L(a.cause,e+1)),c}if(t instanceof URL)return[C,"url",t.href];if(t instanceof Map)return[C,"map",[...t.entries()].map(([a,u])=>[L(a,e+1),L(u,e+1)])];if(t instanceof Set)return[C,"set",[...t].map(a=>L(a,e+1))];if(t instanceof ArrayBuffer)return[C,"bytes",Xe(new Uint8Array(t)),"ArrayBuffer"];if(ArrayBuffer.isView(t)){let a=t,u=a.constructor.name,c=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);return u==="Uint8Array"?[C,"bytes",Xe(c)]:[C,"bytes",Xe(c),u]}if(Array.isArray(t)){let a=t.map(u=>L(u,e+1));return a.length>0&&a[0]===C?[C,"arr",a]:a}let s=Object.getPrototypeOf(t);if(s!==null&&s!==Object.prototype){let a=t.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${a} 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 n=t,i={};for(let a of Object.keys(n)){let u=n[a];u!==void 0&&(i[a]=L(u,e+1))}return i},"encodeWire"),S=o((t,e=0)=>{if(e>Ae)throw new RangeError(`wire-codec: value nesting exceeds the ${Ae}-level limit`);if(t===null||typeof t!="object")return t;if(Array.isArray(t)){if(t[0]===C)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>Xt||!/^-?\d+$/.test(i))throw new RangeError(`wire-codec: invalid or over-long bigint (max ${Xt} digits)`);return BigInt(i)}case"date":return new Date(S(t[2],e+1));case"map":return new Map(t[2].map(([i,a])=>[S(i,e+1),S(a,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],a=t[3],u=(Object.hasOwn(er,i)?er[i]:void 0)??Error,c=new u(a);c.name!==i&&Object.defineProperty(c,"name",{configurable:!0,value:i,writable:!0});let h=S(t[4],e+1);for(let d of Object.keys(h))d===Yt?Object.defineProperty(c,d,{configurable:!0,enumerable:!0,value:h[d],writable:!0}):c[d]=h[d];return t.length>5&&Object.defineProperty(c,"cause",{configurable:!0,value:S(t[5],e+1),writable:!0}),c}case"bytes":{let i=Ur(t[2]),a=t[3]??"Uint8Array";if(a==="ArrayBuffer")return i.buffer.byteLength===i.byteLength?i.buffer:i.slice().buffer;let u=Object.hasOwn(Zt,a)?Zt[a]:void 0;return u?new u(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(n=>S(n,e+1))}let r=t,s={};for(let n of Object.keys(r)){let i=S(r[n],e+1);n===Yt?Object.defineProperty(s,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):s[n]=i}return s},"decodeWire"),G=class{static{o(this,"Listeners")}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()}},Qr="/_lunora/rpc",tr="/_lunora/rpc-batch",qr="/_lunora/ws",Ye=o(t=>t===void 0||t===""?"":`&bucket=${encodeURIComponent(t)}`,"bucketQuery"),Ze=o(t=>{for(let e=t.length-1;e>=0;e-=1)t[e]?.()},"rollbackOptimistic"),Br=o((t,e)=>{for(let r of e)r.op==="delete"?t.delete(r.key):r.value!==void 0&&t.set(r.key,r.value)},"applyRowOpsToView"),Hr="lunora-ping",Nr=3e4,jr=1e4,Kr=250,$r=64,Gr="/_lunora/admin/shard-traffic",Vr="/_lunora/admin/scheduled",Wr="/_lunora/admin/scheduled/status",zr="/_lunora/admin/scheduled/ws",Jr="/_lunora/admin/scheduled/cancel",Xr="/_lunora/admin/scheduled/dead",Yr="/_lunora/admin/scheduled/dead/retry",Zr="/_lunora/admin/scheduled/dead/cancel",es="/_lunora/admin/workflows/instances",ts="/_lunora/admin/workflows/instance",rs="/_lunora/admin/workflows/status",_e="/_lunora/admin/storage",ss="/_lunora/admin/storage/url",ns="/_lunora/admin/storage/buckets",is="/_lunora/admin/functions",os="/_lunora/admin/cron-jobs",as="/_lunora/admin/cron-jobs/run",cs="/_lunora/admin/openapi",us="/_lunora/admin/openrpc",hs="/_lunora/admin/global/tables",ds="/_lunora/admin/global/table",ls="/_lunora/admin/global/facet",fs="/_lunora/admin/vector/indexes",ps="/_lunora/admin/vector/query",ms="/_lunora/admin/kv/namespaces",ys="/_lunora/admin/kv/keys",et="/_lunora/admin/kv/value",vs="/_lunora/admin/auth/users",rr="/_lunora/admin/auth/sessions",bs="/_lunora/admin/auth/users/create",gs="/_lunora/admin/auth/users/role",Ss="/_lunora/admin/auth/users/ban",ws="/_lunora/admin/auth/users/unban",Es="/_lunora/admin/auth/users/password",Cs="/_lunora/admin/auth/users/remove",Ts="/_lunora/admin/auth/users/impersonate",ks="/_lunora/admin/auth/sessions/revoke",Is="/_lunora/admin/auth/sessions/revoke-all",Ps="/_lunora/admin/auth/capabilities",Os="/_lunora/admin/auth/users/update",_s="/_lunora/admin/auth/accounts",As="/_lunora/admin/auth/accounts/unlink",xs="/_lunora/admin/auth/passkeys",Rs="/_lunora/admin/auth/passkeys/delete",Fs="/_lunora/admin/auth/two-factor/disable",Ms="/_lunora/admin/auth/organizations",Ls="/_lunora/admin/auth/organizations/members",Ds="/_lunora/admin/auth/organizations/invitations",Us="/_lunora/admin/auth/organizations/members/remove",Qs="/_lunora/admin/auth/organizations/invitations/cancel",qs="/api/auth",Bs="/get-session",sr=o(t=>t.startsWith("https://")?`wss://${t.slice(8)}`:t.startsWith("http://")?`ws://${t.slice(7)}`:t,"deriveWsUrl"),$=o((t,e)=>`${t.endsWith("/")?t.slice(0,-1):t}${e}`,"joinUrl"),M=o((t,e)=>{let r=new URLSearchParams;for(let[n,i]of Object.entries(e))i!==void 0&&i!==""&&r.set(n,String(i));let s=r.toString();return s===""?t:`${t}?${s}`},"withQuery"),E=o(t=>t??"","connectionKey"),Hs=o(t=>{let e=t.error,r=typeof e?.code=="string"?e.code:void 0,s=typeof e?.message=="string"?e.message:void 0,n=(typeof t.message=="string"?t.message:void 0)??s??"stream error";return Object.assign(new Error(n),r===void 0?void 0:{code:r})},"buildStreamError"),nr=o(t=>{let e=t.error,r=typeof e?.code=="string"?e.code:void 0,s=typeof e?.message=="string"?e.message:void 0;return{message:(typeof t.message=="string"?t.message:void 0)??s??"subscription error",...r===void 0?{}:{code:r}}},"buildSubscriptionError"),ir=o((t,e)=>{for(let r of t)try{r(e)}catch{}},"fanSubscriptionError"),Ns=new TextDecoder,js=o(t=>{if(typeof t=="string")return t;if(t instanceof ArrayBuffer)return Ns.decode(t)},"decodeServerFrame"),I=o((t,e)=>{if(!t.socket||t.wsState!=="open")return!1;try{return t.socket.send(JSON.stringify(e)),!0}catch{return!1}},"sendOn"),he=o(t=>{let e=new Error(t.message??"request failed");return e.code=t.code,t.data!==void 0&&(e.data=S(t.data)),e},"reconstructError"),Z=o((t,e)=>{try{return L(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)}},"encodeCallArgs"),Ks=o((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 n=s.body;r[s.id]=n&&"error"in n&&n.error?{error:he(n.error),ok:!1}:{ok:!0,value:S(n?.result)}}return r.map(s=>s??{error:new Error("batch call returned no result"),ok:!1})},"demuxBatchResults"),$s=new Set(["SHARD_ERROR","SHARD_UNAVAILABLE"]),tt=class t{static{o(this,"LunoraClient")}static MAX_POKE_BUFFERS=256;url;wsUrl;wsToken;authBasePath;fetchImpl;WebSocketImpl;bookmark;reconnectOptions;connectTimeoutMs;heartbeatIntervalMs;offlineQueue;outbox;clientId;clientWatermarks=new Map;outboxMutationCounter=0;onPersistenceError;persistence;persistenceVersion;outboxLeaderRelease;queryCache;hydratedQueryCache=new Map;pendingCacheWrites=new Map;cacheFlushTimer;subscriptions=new X;connections=new Map;defaultConnectionContext;connectionContexts=new Map;connectionContextHolders=new Map;authToken=null;authSubject=void 0;queuedIdentities=new Map;closed=!1;authTokenListeners=new G;statusListeners=new G;tokenExpiredListeners=new G;mutationSettledListeners=new G;pendingChangeListeners=new G;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??$(sr(e.url),qr),this.wsToken=e.wsToken;let r=e.authBasePath??qs;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??Bt(),this.reconnectOptions=e.reconnect,this.heartbeatIntervalMs=e.heartbeatIntervalMs??Nr,this.connectTimeoutMs=e.connectTimeoutMs??jr,this.defaultConnectionContext=e.connectionContext,this.persistence=Vt(e.persistence,e.outbox===void 0),this.persistenceVersion=e.persistenceVersion,this.queryCache=zt(e.queryCache),this.onPersistenceError=e.offlineQueue?.onPersistenceError,this.offlineQueue=new Pe(e.offlineQueue,{onEvict:o((s,n)=>{this.emitItemSettled(s,"rejected",n)},"onEvict"),onSizeChange:o(s=>{this.pendingChangeListeners.emit(s)},"onSizeChange"),persistence:this.persistence,version:e.persistenceVersion}),this.outbox=e.outbox,this.clientId=e.clientId??`client-${Oe()}`,this.persistence&&queueMicrotask(()=>{this.hydrateAsOutboxLeader()}),this.queryCache&&queueMicrotask(()=>{this.hydrateQueryCache().catch(()=>{})})}setAuthToken(e,r){let s=this.authToken!==e,n=this.identityFingerprint();this.authToken=e,r!==void 0&&(this.authSubject=r);let i=this.identityFingerprint();i!==n&&(s?this.rejectQueuedForIdentityChange():this.restampQueuedIdentity(n,i)),s&&this.authTokenListeners.emit(e)}getAuthToken(){return this.authToken}currentIdentity(){return this.identityFingerprint()}clientIdentifier(){return this.clientId}confirmedMutationWatermark(e){return this.clientWatermarks.get(e??"")??0}async callMutator(e,r,s){let n=s?.clientSeq;if(n!==void 0&&(!Number.isInteger(n)||n<=0))throw new Error(`callMutator: clientSeq must be a positive integer, got ${String(n)}`);let i=s?.shardKey??"",a,u=await this.rpc(e,r,s?.shardKey,{captureBookmark:!0,clientId:this.clientId,clientSeq:n,onMutationAck:o(h=>{a=h},"onMutationAck")});return a!==void 0&&a>(this.clientWatermarks.get(i)??0)&&this.clientWatermarks.set(i,a),{applied:a===void 0||a===n,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($(this.url,`${this.authBasePath}${Bs}`),{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=E(r.shardKey);e===void 0?this.connectionContexts.delete(s):this.connectionContexts.set(s,e),this.refreshConnectionContext(s)}acquireConnectionContext(e,r={}){let s=E(r.shardKey),n={context:e},i=this.connectionContextHolders.get(s);i?i.push(n):this.connectionContextHolders.set(s,[n]),this.refreshConnectionContext(s);let a=!1;return()=>{if(a)return;a=!0;let u=this.connectionContextHolders.get(s);if(!u)return;let c=u.indexOf(n);c!==-1&&u.splice(c,1),u.length===0&&this.connectionContextHolders.delete(s),this.refreshConnectionContext(s)}}whisperSubscribe(e,r,s={}){let n=E(s.shardKey),i=this.whisperHandlers.get(n);i||(i=new Map,this.whisperHandlers.set(n,i));let a=i.get(e),u=a===void 0;if(a||(a=new Set,i.set(e,a)),a.add(r),this.ensureSocket(s.shardKey),u){let c=this.getConnection(s.shardKey);c&&I(c,{topic:e,type:"whisper_subscribe"})}return()=>{let c=this.whisperHandlers.get(n),h=c?.get(e);if(!h?.delete(r)||h.size>0)return;c?.delete(e),c?.size===0&&this.whisperHandlers.delete(n);let d=this.getConnection(s.shardKey);d&&I(d,{topic:e,type:"whisper_unsubscribe"})}}whisper(e,r,s={}){this.ensureSocket(s.shardKey);let n=this.getConnection(s.shardKey);n&&I(n,{data:Z(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}onPendingChange(e){let r=this.pendingChangeListeners.add(e);return e(this.offlineQueue.size),r}onMutationSettled(e){return this.mutationSettledListeners.add(e)}async query(e,r,s={}){if(this.closed)throw new Error("LunoraClient is closed");return await this.rpc(e.__lunoraRef,r,s.shardKey,{attachBookmark:!0})}async batch(e){if(this.closed)throw new Error("LunoraClient is closed");if(!this.fetchImpl)throw new Error("LunoraClient: no `fetch` implementation available");if(e.length===0)return[];let r=await this.fetchImpl($(this.url,tr),{body:JSON.stringify({calls:e.map((i,a)=>({args:Z(i.args??{},`args for batch call '${i.fn.__lunoraRef}'`),functionPath:i.fn.__lunoraRef,id:a,shardKey:i.shardKey}))}),headers:this.rpcRequestHeaders({attachBookmark:!0}),method:"POST"}),s=r.headers.get("x-d1-bookmark");s&&this.bookmark.set(s);let n;try{n=await r.json()}catch{throw new Error(`LunoraClient: batch response was not JSON (status ${r.status.toString()})`)}if(!r.ok||n.error&&!n.results)throw n.error?he(n.error):new Error(`LunoraClient: batch request failed (status ${r.status.toString()})`);return Ks(n.results??[],e.length)}async mutation(e,r,s={}){if(this.closed)throw new Error("LunoraClient is closed");let n=r,i=s.mutationId??Oe(),{confirms:a,rollbacks:u}=this.applyOptimisticUpdates(e.__lunoraRef,n,s.shardKey,s.optimistic);s.optimisticUpdate&&this.applyOptimisticUpdate(s.optimisticUpdate,r,s.shardKey,u,a);let c=this.getConnection(s.shardKey),h=c?.wsState??"idle",d=c?.socket!==void 0,l=c?.wasEverConnected??!1,{queueBeforeFirstConnect:f}=this.offlineQueue,p=l||f,y=this.WebSocketImpl!==void 0&&p;if(h!=="open"&&!d&&y||h==="connecting"&&p)return this.enqueueOfflineMutation(e,n,s.shardKey,i,u,a);try{let b,w=await this.rpc(e.__lunoraRef,n,s.shardKey,{captureBookmark:!0,mutationId:i,onCommitCursor:o(T=>{b=T},"onCommitCursor")});for(let T of a)T(b);return w}catch(b){throw Ze(u),b}}async action(e,r,s={}){if(this.closed)throw new Error("LunoraClient is closed");return await this.rpc(e.__lunoraRef,r,s.shardKey)}async shardTraffic(e){if(this.closed)throw new Error("LunoraClient is closed");let r=await this.adminFetch(Gr,"POST",{table:e});return{failed:r.failed??0,ok:r.ok??0,shards:r.shards??[]}}async listScheduledJobs(){if(this.closed)throw new Error("LunoraClient is closed");return(await this.adminFetch(Vr,"GET")).records??[]}async schedulerStatus(){if(this.closed)throw new Error("LunoraClient is closed");let e=await this.adminFetch(Wr,"GET");return{backlog:e.backlog??0,inFlight:e.inFlight??0,pools:e.pools??[]}}async cancelScheduledJob(e){if(this.closed)throw new Error("LunoraClient is closed");return{cancelled:(await this.adminFetch(Jr,"POST",{id:e})).cancelled===!0}}async listDeadJobs(){if(this.closed)throw new Error("LunoraClient is closed");return(await this.adminFetch(Xr,"GET")).records??[]}async retryDeadJob(e){if(this.closed)throw new Error("LunoraClient is closed");return{retried:(await this.adminFetch(Yr,"POST",{id:e})).retried===!0}}async removeDeadJob(e){if(this.closed)throw new Error("LunoraClient is closed");return{removed:(await this.adminFetch(Zr,"POST",{id:e})).removed===!0}}async listWorkflowInstances(e){if(this.closed)throw new Error("LunoraClient is closed");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(`${es}?${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){if(this.closed)throw new Error("LunoraClient is closed");let r=new URLSearchParams({id:e.id,name:e.name}),s=await this.adminFetch(`${ts}?${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){if(this.closed)throw new Error("LunoraClient is closed");return{status:(await this.adminFetch(rs,"POST",{action:e.action,id:e.id,name:e.name})).status??"unknown"}}subscribeScheduledJobs(e){if(this.closed)throw new Error("LunoraClient is closed");if(this.WebSocketImpl===void 0)return()=>{};let r=$(sr(this.url),zr),s=ze(this.reconnectOptions),n,i,a=!1,u=o(()=>{if(a||this.WebSocketImpl===void 0)return;let c=this.wsToken===void 0?r:`${r}?token=${encodeURIComponent(this.wsToken)}`;n=new this.WebSocketImpl(c),n.addEventListener("open",()=>{s.reset()}),n.addEventListener("message",h=>{try{let d=JSON.parse(typeof h.data=="string"?h.data:"");d.type==="jobs"&&Array.isArray(d.records)&&e(d.records)}catch{}}),n.addEventListener("close",()=>{n=void 0,a||(i=setTimeout(u,s.next()))}),n.addEventListener("error",()=>{})},"connect");return u(),()=>{a=!0,i!==void 0&&clearTimeout(i),n?.close()}}async listFunctions(){if(this.closed)throw new Error("LunoraClient is closed");return(await this.adminFetch(is,"GET")).functions??[]}async getCronJobs(){if(this.closed)throw new Error("LunoraClient is closed");return(await this.adminFetch(os,"GET")).jobs??[]}async runCronJob(e){if(this.closed)throw new Error("LunoraClient is closed");let r=await this.adminFetch(as,"POST",{name:e});return{name:r.name??e,ran:r.ran===!0}}async fetchOpenApi(){if(this.closed)throw new Error("LunoraClient is closed");return await this.adminFetch(cs,"GET")}async fetchOpenRpc(){if(this.closed)throw new Error("LunoraClient is closed");return await this.adminFetch(us,"GET")}async listStorageObjects(e={}){if(this.closed)throw new Error("LunoraClient is closed");let r=new URLSearchParams;e.prefix!==void 0&&e.prefix!==""&&r.set("prefix",e.prefix),e.cursor!==void 0&&e.cursor!==""&&r.set("cursor",e.cursor),e.limit!==void 0&&r.set("limit",String(e.limit)),e.bucket!==void 0&&e.bucket!==""&&r.set("bucket",e.bucket);let s=r.toString(),n=s===""?_e:`${_e}?${s}`,i=await this.adminFetch(n,"GET");return{cursor:i.cursor,objects:i.objects??[]}}async deleteStorageObject(e,r){if(this.closed)throw new Error("LunoraClient is closed");let s=`${_e}?key=${encodeURIComponent(e)}${Ye(r?.bucket)}`,n=await this.adminFetch(s,"DELETE");return{deleted:n.deleted??!0,key:n.key??e}}async listStorageBuckets(){if(this.closed)throw new Error("LunoraClient is closed");return(await this.adminFetch(ns,"GET")).buckets??[]}async uploadStorageObject(e){if(this.closed)throw new Error("LunoraClient is closed");let r=`${_e}?key=${encodeURIComponent(e.key)}${Ye(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){if(this.closed)throw new Error("LunoraClient is closed");let s=r?.expiresInSeconds,n=s===void 0?"":`&expiresIn=${encodeURIComponent(s.toString())}`,i=`${ss}?key=${encodeURIComponent(e)}${n}${Ye(r?.bucket)}`,a=await this.adminFetch(i,"GET");if(typeof a.url!="string")throw new TypeError("LunoraClient: storage URL endpoint returned no `url`");return a.url}async listGlobalTables(){if(this.closed)throw new Error("LunoraClient is closed");return await this.adminFetch(hs,"GET")}async readGlobalTablePage(e){if(this.closed)throw new Error("LunoraClient is closed");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(`${ds}?${r.toString()}`,"GET")}async facetGlobalColumn(e){if(this.closed)throw new Error("LunoraClient is closed");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(){if(this.closed)throw new Error("LunoraClient is closed");return(await this.adminFetch(fs,"GET")).indexes??[]}async queryVectorIndex(e){if(this.closed)throw new Error("LunoraClient is closed");return(await this.adminFetch(ps,"POST",e)).matches??[]}async listKvNamespaces(){if(this.closed)throw new Error("LunoraClient is closed");return(await this.adminFetch(ms,"GET")).namespaces??[]}async listKvKeys(e){if(this.closed)throw new Error("LunoraClient is closed");let r=M(ys,{cursor:e.cursor,limit:e.limit,namespace:e.namespace,prefix:e.prefix});return await this.adminFetch(r,"GET")}async getKvValue(e){if(this.closed)throw new Error("LunoraClient is closed");let r=M(et,{key:e.key,namespace:e.namespace});return await this.adminFetch(r,"GET")}async putKvValue(e){if(this.closed)throw new Error("LunoraClient is closed");await this.adminFetch(et,"PUT",e)}async deleteKvKey(e){if(this.closed)throw new Error("LunoraClient is closed");let r=M(et,{key:e.key,namespace:e.namespace});await this.adminFetch(r,"DELETE")}async listAuthUsers(e={}){if(this.closed)throw new Error("LunoraClient is closed");let r=M(vs,{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(bs,"POST",e)}async setAuthUserRole(e){return await this.adminFetch(gs,"POST",e)}async banAuthUser(e){return await this.adminFetch(Ss,"POST",e)}async unbanAuthUser(e){return await this.adminFetch(ws,"POST",e)}async setAuthUserPassword(e){await this.adminFetch(Es,"POST",e)}async removeAuthUser(e){await this.adminFetch(Cs,"POST",e)}async impersonateAuthUser(e){return await this.adminFetch(Ts,"POST",e)}async revokeAuthSession(e){await this.adminFetch(ks,"POST",e)}async revokeAuthUserSessions(e){await this.adminFetch(Is,"POST",e)}async getAuthCapabilities(){return await this.adminFetch(Ps,"GET")}async updateAuthUser(e){return await this.adminFetch(Os,"POST",e)}async listAuthAccounts(e){return await this.adminFetch(M(_s,{userId:e.userId}),"GET")}async unlinkAuthAccount(e){await this.adminFetch(As,"POST",e)}async listAuthPasskeys(e){return await this.adminFetch(M(xs,{userId:e.userId}),"GET")}async deleteAuthPasskey(e){await this.adminFetch(Rs,"POST",e)}async disableAuthTwoFactor(e){await this.adminFetch(Fs,"POST",e)}async listAuthOrganizations(e={}){return await this.adminFetch(M(Ms,{limit:e.limit,offset:e.offset}),"GET")}async listAuthOrgMembers(e){let r=M(Ls,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async listAuthOrgInvitations(e){let r=M(Ds,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async removeAuthOrgMember(e){await this.adminFetch(Us,"POST",e)}async cancelAuthOrgInvitation(e){await this.adminFetch(Qs,"POST",e)}async listAuthSessions(e={}){if(this.closed)throw new Error("LunoraClient is closed");let r=new URLSearchParams;e.userId!==void 0&&e.userId!==""&&r.set("userId",e.userId),e.limit!==void 0&&r.set("limit",String(e.limit)),e.offset!==void 0&&r.set("offset",String(e.offset));let s=r.toString();return await this.adminFetch(s===""?rr:`${rr}?${s}`,"GET")}subscribe(e,r,s,n={}){if(this.closed)throw new Error("LunoraClient is closed");let i=r??{},a=X.key(e.__lunoraRef,i,n.shardKey),u=this.subscriptions.get(a),c=s,h=n.onError;if(!u){this.nextSubId+=1;let l=`sub_${this.nextSubId.toString()}`,f=J(i),p=this.takeHydratedCache(e.__lunoraRef,f,n.shardKey);u={acked:!1,args:i,argsKey:f,callbacks:new Set,checkpointCallbacks:new Set,errorCallbacks:new Set,fn:e,id:l,lastValue:p?.value,optimisticLayers:[],serverBase:p?.value,serverCursor:p?.serverCursor,shardKey:n.shardKey,...p?.serverEpoch===void 0?{}:{serverEpoch:p.serverEpoch}},this.subscriptions.add(u)}if(u.callbacks.add(c),h&&u.errorCallbacks.add(h),n.onCheckpoint&&u.checkpointCallbacks.add(n.onCheckpoint),u.lastValue!==void 0)try{c(u.lastValue)}catch{}this.ensureSocket(n.shardKey),this.sendSubscribeIfOpen(u);let d=u;return()=>{if(d.callbacks.delete(c),h&&d.errorCallbacks.delete(h),n.onCheckpoint&&d.checkpointCallbacks.delete(n.onCheckpoint),d.callbacks.size===0){let l=this.getConnection(d.shardKey);!(l&&I(l,{id:d.id,type:"unsubscribe"}))&&l&&l.pendingUnsubscribes.push({id:d.id,type:"unsubscribe"}),this.subscriptions.remove(d)}}}subscribeShape(e,r,s={}){if(this.closed)throw new Error("LunoraClient is closed");this.nextShapeId+=1;let n=`shape_${this.nextShapeId.toString()}`,i={args:e.args,callbacks:new Set([r]),errorCallbacks:s.onError?new Set([s.onError]):new Set,id:n,name:e.name,onCheckpoint:s.onCheckpoint,rows:new Map,shardKey:s.shardKey};return this.shapeSubscriptions.set(n,i),this.ensureSocket(s.shardKey),this.sendShapeSubscribeIfOpen(i),()=>{this.shapeSubscriptions.delete(n);let a=this.getConnection(i.shardKey);!(a&&I(a,{id:n,type:"shape_unsubscribe"}))&&a&&a.pendingUnsubscribes.push({id:n,type:"shape_unsubscribe"})}}stream(e,r,s={}){if(this.closed)throw new Error("LunoraClient is closed");if(this.WebSocketImpl===void 0)throw new Error("LunoraClient: streams require a WebSocket implementation");this.nextStreamId+=1;let n=`stream_${this.nextStreamId.toString()}`,{shardKey:i}=s,a=r??{},{handle:u,iterable:c}=Jt({maxBuffer:s.maxBuffer,onCancel:o(()=>{let f=this.getConnection(i);f&&I(f,{id:n,type:"unsubscribe"}),this.streams.delete(n)},"onCancel")});this.streams.set(n,{handle:u,shardKey:i}),this.ensureSocket(i);let h=this.getConnection(i),d={id:n,query:{args:Z(a,`stream args for '${e.__lunoraRef}'`),functionPath:e.__lunoraRef,shardKey:i},type:"stream"};if(!(h?.wsState==="open"&&I(h,d))&&h){for(h.pendingStreams=h.pendingStreams??[];h.pendingStreams.length>=$r;){let p=h.pendingStreams.shift()?.id,y=p?this.streams.get(p):void 0;y&&(y.handle.fail(Object.assign(new Error("stream-start frame evicted while socket was unreachable"),{code:"STREAM_QUEUE_OVERFLOW"})),this.streams.delete(p))}h.pendingStreams.push(d)}return c}close(){this.closed=!0,this.outboxLeaderRelease?.(),this.outboxLeaderRelease=void 0;for(let e of this.streams.values())e.handle.fail(Object.assign(new Error("LunoraClient closed"),{code:"CLIENT_CLOSED"}));this.streams.clear();for(let e of this.connections.values()){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"}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()}async enqueueOfflineMutation(e,r,s,n,i,a){let u=this.identityFingerprint();if(this.outbox){this.outboxMutationCounter+=1;let c=this.outboxMutationCounter;try{await this.outbox.enqueue({args:r,clientId:this.clientId,functionPath:e.__lunoraRef,idempotencyKey:`${this.clientId}:${String(c)}`,identity:u,mutationId:c,shardKey:s})}catch(h){throw Ze(i),h instanceof Error?h:new Error(String(h))}for(let h of a)h(void 0);return}return new Promise((c,h)=>{let d={args:r,functionPath:e.__lunoraRef,liveAwaiter:!0,id:n,identity:u,onCommit:o(l=>{for(let f of a)f(l)},"onCommit"),reject:o(l=>{this.queuedIdentities.delete(n),Ze(i),h(l instanceof Error?l:new Error(String(l)))},"reject"),resolve:c,shardKey:s};this.offlineQueue.enqueue(d),d.id!==void 0&&this.queuedIdentities.set(d.id,u)})}async hydratePersistedQueue(){try{let e=await this.offlineQueue.hydrate();for(let r of e)this.ensureSocket(r)}catch{}}hydrateAsOutboxLeader(){let e=o(()=>{this.hydratePersistedQueue().catch(()=>{})},"hydrate"),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(Ve(this.persistenceVersion,s.version)){this.queryCache.remove(r).catch(()=>{});continue}this.hydratedQueryCache.set(r,s)}}catch{}}takeHydratedCache(e,r,s){let n=We(e,r,s),i=this.hydratedQueryCache.get(n);if(i!==void 0)return this.hydratedQueryCache.delete(n),i.identity===this.identityFingerprint()?i:void 0}persistQueryValue(e){let r=e.serverBase;if(!this.queryCache||r===void 0)return;let s=We(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(()=>{})},Kr)}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,n])=>e.put(s,n)))}computeStatus(){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))}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,n){let i=[],a=[];if(!n)return{confirms:i,rollbacks:a};let u=X.key(e,r,s),c=this.subscriptions.get(u);if(c){let h=$e(c,n);h&&(i.push(h.confirm),a.push(h.rollback))}return{confirms:i,rollbacks:a}}applyOptimisticUpdate(e,r,s,n,i){let{confirms:a,rollbacks:u,store:c}=Kt(this.subscriptions,s,J);try{e(c,r)}catch{for(let h=u.length-1;h>=0;h-=1)u[h]?.();return}n.push(...u),i.push(...a)}getConnection(e){return this.connections.get(E(e))}getOrCreateConnection(e){let r=E(e),s=this.connections.get(r);return s||(s={connectTimer:void 0,heartbeatTimer:void 0,pendingUnsubscribes:[],reconnect:ze(this.reconnectOptions),reconnectTimer:void 0,shardKey:e,socket:void 0,wasEverConnected:!1,wsState:"idle"},this.connections.set(r,s)),s}wsUrlFor(e){let r=[];if(e!==void 0&&r.push(`shard=${encodeURIComponent(e)}`),this.wsToken!==void 0&&r.push(`token=${encodeURIComponent(this.wsToken)}`),r.length===0)return this.wsUrl;let s=this.wsUrl.includes("?")?"&":"?";return`${this.wsUrl}${s}${r.join("&")}`}rpcRequestHeaders(e){let r={"content-type":"application/json"};if(this.authToken&&(r.authorization=`Bearer ${this.authToken}`),e.mutationId&&(r["x-lunora-mutation-id"]=e.mutationId),e.clientId!==void 0&&(r["x-lunora-client-id"]=e.clientId),e.clientSeq!==void 0&&(r["x-lunora-client-seq"]=e.clientSeq.toString()),e.attachBookmark){let s=this.bookmark.get();s&&(r["x-d1-bookmark"]=s)}return r}async rpc(e,r,s,n={}){if(!this.fetchImpl)throw new Error("LunoraClient: no `fetch` implementation available");let i=this.rpcRequestHeaders(n),a=await this.fetchImpl($(this.url,Qr),{body:JSON.stringify({args:Z(r,`args for '${e}'`),functionPath:e,shardKey:s}),headers:i,method:"POST"});if(n.captureBookmark){let c=a.headers.get("x-d1-bookmark");c&&this.bookmark.set(c)}let u;try{u=await a.json()}catch{let c=a.statusText?` ${a.statusText}`:"";throw new Error(`LunoraClient: response was not JSON (status ${a.status.toString()}${c})`)}if("error"in u)throw he(u.error);if(!a.ok){let c=a.statusText?` ${a.statusText}`:"";throw new Error(`LunoraClient: request failed (status ${a.status.toString()}${c})`)}return n.onMutationAck?.(u.lastMutationId),n.onCommitCursor?.(u.commitCursor),S(u.result)}async adminFetch(e,r,s,n){if(!this.fetchImpl)throw new Error("LunoraClient: no `fetch` implementation available");let i={};this.authToken&&(i.authorization=`Bearer ${this.authToken}`);let a=s instanceof ArrayBuffer||s instanceof Blob,u;s===void 0?u=void 0:a?(u=s,n!==void 0&&(i["content-type"]=n)):(u=JSON.stringify(s),i["content-type"]="application/json");let c=await this.fetchImpl($(this.url,e),{body:u,headers:i,method:r}),h;try{h=await c.json()}catch{let d=c.statusText?` ${c.statusText}`:"";throw new Error(`LunoraClient: response was not JSON (status ${c.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(!c.ok){let d=c.statusText?` ${c.statusText}`:"";throw new Error(`LunoraClient: admin request failed (status ${c.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(E(e.shardKey));I(e,{clientId:this.clientId,id:"connect",type:"connect",...r===void 0?{}:{context:r}})}resendShapeSubscriptions(e){for(let r of this.shapeSubscriptions.values())E(r.shardKey)===E(e)&&this.sendShapeSubscribeIfOpen(r)}ensureSocket(e){if(this.closed||this.WebSocketImpl===void 0)return;let r=this.getOrCreateConnection(e);if(r.wsState==="open"||r.wsState==="connecting")return;r.wsState="connecting",this.emitConnectionStatus();let s=new this.WebSocketImpl(this.wsUrlFor(e));r.socket=s,this.connectTimeoutMs>0&&(r.connectTimer=setTimeout(()=>{if(r.connectTimer=void 0,!(r.socket!==s||r.wsState!=="connecting")){try{s.close()}catch{}this.handleDisconnect(r)}},this.connectTimeoutMs)),s.addEventListener("open",()=>{if(r.socket!==s)return;r.connectTimer!==void 0&&(clearTimeout(r.connectTimer),r.connectTimer=void 0),r.wsState="open",r.wasEverConnected=!0,r.reconnect.reset(),this.emitConnectionStatus(),this.sendConnectEnvelope(r),this.markShardPendingAck(e);for(let i of this.subscriptions.all())E(i.shardKey)===E(e)&&this.sendSubscribeIfOpen(i);if(this.resendShapeSubscriptions(e),r.pendingUnsubscribes.length>0){let i=r.pendingUnsubscribes;r.pendingUnsubscribes=[];for(let{id:a,type:u}of i)I(r,{id:a,type:u})}if(r.pendingStreams&&r.pendingStreams.length>0){let i=r.pendingStreams;r.pendingStreams=[];for(let a of i)I(r,a)}let n=this.whisperHandlers.get(E(e));if(n)for(let i of n.keys())I(r,{topic:i,type:"whisper_subscribe"});this.flushOfflineQueue(e).catch(()=>{}),this.startHeartbeat(r)}),s.addEventListener("message",n=>{this.handleServerMessage(n.data,e)}),s.addEventListener("close",n=>{r.socket===s&&(n?.code===4001&&this.notifyTokenExpired(),this.handleDisconnect(r))}),s.addEventListener("error",()=>{r.socket===s&&(r.wsState==="connecting"||r.wsState==="open")&&this.handleDisconnect(r)})}handleDisconnect(e){if(this.closed||e.wsState==="idle"||e.wsState==="closed"||(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),this.WebSocketImpl===void 0))return;let r=e.reconnect.next();e.reconnectTimer=setTimeout(()=>{e.reconnectTimer=void 0,this.ensureSocket(e.shardKey)},r)}startHeartbeat(e){this.stopHeartbeat(e),!(this.heartbeatIntervalMs<=0)&&(e.heartbeatTimer=setInterval(()=>{if(!(e.wsState!=="open"||!e.socket))try{e.socket.send(Hr)}catch{}},this.heartbeatIntervalMs))}stopHeartbeat(e){e.heartbeatTimer!==void 0&&(clearInterval(e.heartbeatTimer),e.heartbeatTimer=void 0)}markShardPendingAck(e){let r=E(e);for(let s of this.subscriptions.all())E(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;I(r,{id:e.id,query:{args: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"&&I(r,{id:e.id,shape:{name:e.name,...e.args===void 0?{}:{args:e.args}},type:"shape_subscribe",...e.serverCursor===void 0?{}:{sinceCheckpoint:e.serverCursor},...e.serverEpoch===void 0?{}:{sinceEpoch:e.serverEpoch}})}handleServerMessage(e,r){let s=js(e);if(s===void 0)return;let n;try{n=JSON.parse(s)}catch{return}switch(n.type){case"ack":{let i=this.subscriptions.getById(n.id);i&&(i.acked=!0);return}case"chunk":{let{data:i,id:a}=n;this.streams.get(a)?.handle.push(S(i));return}case"complete":{this.handleCompleteMessage(n.id);return}case"data":case"delta":{this.handleDataMessage(n);return}case"error":{this.handleErrorMessage(n);break}case"pokeEnd":{this.handlePokeEnd(n);break}case"pokePart":{this.handlePokePart(n);break}case"pokeStart":{this.handlePokeStart(n);break}case"resume":{this.handleResumeMessage(n);break}case"settled":{this.handleSettledMessage(n);break}case"whisper":{this.dispatchWhisper(n,r);break}}}handleErrorMessage(e){if(e.error?.code==="TOKEN_EXPIRED"){this.notifyTokenExpired();return}let{id:s}=e,n=s===void 0?void 0:this.streams.get(s);if(n&&s!==void 0){n.handle.fail(Hs(e)),this.streams.delete(s);return}let i=s===void 0?void 0:this.subscriptions.getById(s);if(i){ir(i.errorCallbacks,nr(e));return}let a=s===void 0?void 0:this.shapeSubscriptions.get(s);a&&ir(a.errorCallbacks,nr(e))}handlePokeStart(e){if(this.pokeBuffers.size>=t.MAX_POKE_BUFFERS){let r=this.pokeBuffers.keys().next().value;r!==void 0&&this.pokeBuffers.delete(r)}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 n of e.rowsPatch)s.push(n.value===void 0?n:{...n,value:S(n.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,n]of r.parts){let i=this.shapeSubscriptions.get(s);if(!i)continue;let a=r.epoch!==void 0&&i.serverEpoch!==void 0&&r.epoch!==i.serverEpoch,u=r.baseCheckpoint!==void 0&&i.serverCursor!==void 0&&i.serverCursor!==r.baseCheckpoint;if(a||u){i.rows.clear(),i.serverCursor=void 0,i.serverEpoch=void 0,this.emitShapeRows(i),this.sendShapeSubscribeIfOpen(i);continue}Br(i.rows,n),e.checkpoint!==void 0&&(i.serverCursor=e.checkpoint),e.epoch!==void 0&&(i.serverEpoch=e.epoch);let c=r.lastMutationId.get(s);c!==void 0&&(i.lastMutationId=c),this.emitShapeRows(i),i.onCheckpoint?.({checkpoint:i.serverCursor,mutationId:i.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 n=this.resolveDataPayload(e,s);s.serverBase=n,e.cursor!==void 0&&(s.serverCursor=e.cursor),e.epoch!==void 0&&(s.serverEpoch=e.epoch),this.persistQueryValue(s),Ge(s,s.serverCursor),ae(s,s.optimisticLayers.length===0?n:Ie(n,s.optimisticLayers))}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})}}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),Ge(e,e.serverCursor)&&ae(e,Ie(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(Nt(s)&&r.serverBase!==void 0){let n=jt(r.serverBase,s);if(n!==void 0)return n}return s}dispatchWhisper(e,r){let s=this.whisperHandlers.get(E(r))?.get(e.topic);if(!s)return;let n=S(e.data);for(let i of s)try{i(n,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&&this.subscriptions.remove(s)}unpersist(e){e&&this.persistence?.remove(e).catch(r=>{Y(this.onPersistenceError,"remove",r,e)})}identityFingerprint(){if(this.authSubject!==void 0)return this.authSubject===null?null:`subj:${this.authSubject}`;let e=this.authToken;if(e===null)return null;let r=2166136261,s=5381;for(let n=0;n<e.length;n+=1){let i=e.charCodeAt(n);r^=i,r=Math.imul(r,16777619),s=Math.imul(s,33)+i}return`${e.length.toString(36)}:${(r>>>0).toString(36)}:${(s>>>0).toString(36)}`}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,n]of this.queuedIdentities)n===e&&this.queuedIdentities.set(s,r)}clearQueryCacheForIdentityChange(){this.cacheFlushTimer!==void 0&&(clearTimeout(this.cacheFlushTimer),this.cacheFlushTimer=void 0),this.pendingCacheWrites.clear(),this.hydratedQueryCache.clear(),this.queryCache?.clear().catch(()=>{})}async flushOfflineQueue(e){let r=E(e),s=this.offlineQueue.drain(c=>E(c.shardKey)===r);if(s.length===0)return;let n=this.identityFingerprint(),i=[];for(let c of s)this.passesReplayIdentityGate(c,n)&&i.push(c);if(i.length===0)return;let a=this.encodableOrSettleTerminal(i);if(a.length===0)return;if(a.length===1){await this.replaySequential(a);return}let u=[];for(let c=0;c<a.length;c+=Je){let h=a.slice(c,c+Je),d=await this.replayBatched(h);if(u.push(...d.requeue),d.stop){u.push(...a.slice(c+Je));break}}u.length>0&&this.offlineQueue.requeue(u)}encodableOrSettleTerminal(e){let r=[];for(let s of e)try{Z(s.args,`args for '${s.functionPath}'`),r.push(s)}catch(n){this.settleReplayTerminal(s,n instanceof Error?n:new Error(String(n)))}return r}passesReplayIdentityGate(e,r){let s=e.id===void 0?void 0:this.queuedIdentities.get(e.id),n=s===void 0?e.identity:s;if(n!==void 0&&n!==r){this.queuedIdentities.delete(e.id??""),this.unpersist(e.id);let i=new Error("offline mutation skipped: auth identity changed before replay");return i.code="OFFLINE_IDENTITY_CHANGED",e.reject(i),this.emitItemSettled(e,"rejected",i),!1}return this.queuedIdentities.delete(e.id??""),!0}settleReplaySuccess(e,r,s){this.unpersist(e.id),e.onCommit?.(s),e.resolve(r),this.emitItemSettled(e,"committed")}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 n,i=await this.rpc(s.functionPath,s.args,s.shardKey,{captureBookmark:!0,mutationId:s.id,onCommitCursor:o(a=>{n=a},"onCommitCursor")});this.settleReplaySuccess(s,i,n)}catch(n){if(n.code!==void 0){this.settleReplayTerminal(s,n);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($(this.url,tr),{body:JSON.stringify({calls:e.map((i,a)=>({args:Z(i.args,`args for '${i.functionPath}'`),functionPath:i.functionPath,id:a,mutationId:i.id,shardKey:i.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 n;try{n=await r.json()}catch{return{requeue:e,stop:!0}}if(!n.results){if(n.error){let i=he(n.error);for(let a of e)this.settleReplayTerminal(a,i);return{requeue:[],stop:!1}}return{requeue:e,stop:!0}}return{requeue:this.settleReplayBatchSlots(e,n.results),stop:!1}}settleReplayBatchSlots(e,r){let s=new Map;for(let i of r)typeof i.id=="number"&&i.body!==void 0&&s.set(i.id,i.body);let n=[];for(let[i,a]of e.entries()){let u=s.get(i);u===void 0?n.push(a):"error"in u?$s.has(u.error.code)?n.push(a):this.settleReplayTerminal(a,he(u.error)):this.settleReplaySuccess(a,S(u.result),u.commitCursor)}return n}};export{tt as a,dr as b,Be as c,Er as d,Tr as e,Ke as f,kr as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as m,e as r,g as c,h as d,j as i}from"./chunk-RRCPZMC2.js";var n=r(c(),1);var f=r(d(),1);function u(a){let e=(0,n.c)(8),t,s;e[0]!==a?({className:t,...s}=a,e[0]=a,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=i("animate-pulse rounded-md bg-muted",t),e[3]=t,e[4]=o):o=e[4];let l;return e[5]!==s||e[6]!==o?(l=(0,f.jsxDEV)("div",{"data-slot":"skeleton",className:o,...s},void 0,!1),e[5]=s,e[6]=o,e[7]=l):l=e[7],l}m(u,"Skeleton");export{u as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as B,b as D}from"./chunk-FKO3HO6I.js";import{a as k}from"./chunk-7RYIQKZA.js";import{a as O}from"./chunk-2K47A3P6.js";import{a as V,b as _,c as z,d as v,e as l,f as n}from"./chunk-GTM65MVX.js";import{a as M}from"./chunk-RMYA7NAH.js";import"./chunk-TBMYIZIO.js";import{R as L}from"./chunk-BHTPZS7L.js";import"./chunk-TICVNLPM.js";import"./chunk-HV7G6DFP.js";import{a as A}from"./chunk-AQGOX5DK.js";import{a as I}from"./chunk-TAD43CG5.js";import{b as H}from"./chunk-FCR3HKFV.js";import{a as y,e as E}from"./chunk-SEU5V7I6.js";import{b as T}from"./chunk-O4PXDNR3.js";import"./chunk-ZH7UES4T.js";import"./chunk-KODWGUAB.js";import"./chunk-3OA7PECS.js";import{d as C,l as R}from"./chunk-YJGANMU7.js";import{a as i,e as w,f as $,h as Y}from"./chunk-RRCPZMC2.js";var r=w($(),1);var e=w(Y(),1);var j=80,ee=i(s=>{if(s===void 0)return"";let t=JSON.stringify(s);return t.length>j?`${t.slice(0,j)}\u2026`:t},"formatDetail"),te=41,U=480,K=5,ae=i((s,t)=>B(s,d=>{t(d.height>0?d:{height:U,width:d.width})}),"observeViewportRect"),pe=i(({initialShardKey:s})=>{let t=C(),[d,F]=(0,r.useState)(s??""),[m,G]=(0,r.useState)(""),W=O(d.trim(),400),{data:p,error:u,isLoading:q,liveError:J}=H(A.getAuditLog,{},{live:!0,shardKey:W}),h=(0,r.useMemo)(()=>p?.entries??[],[p]),c=(0,r.useMemo)(()=>{let o=m.trim().toLowerCase();return o===""?h:h.filter(a=>a.op.toLowerCase().includes(o)||(a.table??"").toLowerCase().includes(o)||(a.id??"").toLowerCase().includes(o))},[h,m]),g=(0,r.useRef)(null),x=D({count:c.length,estimateSize:i(()=>te,"estimateSize"),getScrollElement:i(()=>g.current,"getScrollElement"),initialRect:{height:U,width:800},observeElementRect:ae,overscan:8}),f=x.getVirtualItems(),P=x.getTotalSize(),S=f[0]?.start??0,b=P-(f.at(-1)?.end??0),Q={height:S},X={height:b},Z=i(o=>{G(o.target.value)},"onSearchChange");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)(M,{onChange:F,testId:"au-shard-input",value:d},void 0,!1),(0,e.jsxDEV)(k,{message:J,prefix:"au"},void 0,!1),(0,e.jsxDEV)(L,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:Z,placeholder:t("filter op, table, id"),value:m},void 0,!1)]},void 0,!0),u!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"au-error",role:"alert",children:u},void 0,!1),u===null&&!q&&c.length===0&&(0,e.jsxDEV)(I,{description:t("State-changing admin operations are recorded here."),icon:(0,e.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsxDEV)("path",{d:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"},void 0,!1)},void 0,!1),testId:"au-empty",title:t("No audit entries.")},void 0,!1),c.length>0&&(0,e.jsxDEV)(y,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:g,children:(0,e.jsxDEV)(V,{"data-testid":"au-table",children:[(0,e.jsxDEV)(_,{children:(0,e.jsxDEV)(v,{children:[(0,e.jsxDEV)(l,{children:t("time")},void 0,!1),(0,e.jsxDEV)(l,{children:t("op")},void 0,!1),(0,e.jsxDEV)(l,{children:t("table")},void 0,!1),(0,e.jsxDEV)(l,{children:t("id")},void 0,!1),(0,e.jsxDEV)(l,{children:t("detail")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(z,{children:[S>0&&(0,e.jsxDEV)("tr",{"aria-hidden":"true",children:(0,e.jsxDEV)("td",{colSpan:K,style:Q},void 0,!1)},void 0,!1),f.map(o=>{let a=c[o.index],N=ee(a.detail);return(0,e.jsxDEV)(v,{"data-testid":"au-row",children:[(0,e.jsxDEV)(n,{className:"text-muted-foreground tabular-nums",children:R(a.ts,"\u2014")},void 0,!1),(0,e.jsxDEV)(n,{children:(0,e.jsxDEV)(T,{variant:"secondary",children:a.op},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"font-medium",children:a.table??(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"max-w-[20ch] truncate font-mono text-xs",children:a.id??(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:N||void 0,children:N||(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1)]},a.seq,!0)}),b>0&&(0,e.jsxDEV)("tr",{"aria-hidden":"true",children:(0,e.jsxDEV)("td",{colSpan:K,style:X},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0)},"AuditPanel");export{pe as AuditPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as _,b as O,c as $,d as I,e as n,f as c}from"./chunk-GTM65MVX.js";import{a as F}from"./chunk-AQGOX5DK.js";import{a as E}from"./chunk-TAD43CG5.js";import{b as U}from"./chunk-FCR3HKFV.js";import{a as B,e as D}from"./chunk-SEU5V7I6.js";import{b as k}from"./chunk-O4PXDNR3.js";import"./chunk-ZH7UES4T.js";import"./chunk-KODWGUAB.js";import"./chunk-3OA7PECS.js";import{d as M}from"./chunk-YJGANMU7.js";import{a as C,e as H,g as V,h as q}from"./chunk-RRCPZMC2.js";var Q=H(V(),1);var l=H(q(),1);var L=["read","insert","update","delete"],z=C((e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],"operationLabel"),J=C(e=>{let t=new Map;for(let a of e){let s=t.get(a.table)??{operations:new Set,procedures:[],table:a.table};s.operations.add(a.on),s.procedures.includes(a.procedure)||s.procedures.push(a.procedure),t.set(a.table,s)}return[...t.values()].toSorted((a,s)=>a.table.localeCompare(s.table))},"groupByTable"),ae=C(()=>{let e=(0,Q.c)(47),t=M(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:s,error:f}=U(F.rlsPolicies,a),p=s!==void 0,m,d,u,r,h,v,b,x,i;if(e[1]!==s||e[2]!==f||e[3]!==p||e[4]!==t){let j=J(Array.isArray(s?.policies)?s.policies:[]),S;e[14]!==s?(S=Array.isArray(s?.roles)?s.roles:[],e[14]=s,e[15]=S):S=e[15],d=S,b="flex flex-col gap-6",x="lunora-rls-panel",e[16]!==f?(i=f!==null&&(0,l.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"rls-error",role:"alert",children:f},void 0,!1),e[16]=f,e[17]=i):i=e[17],v="flex flex-col gap-2",m=B,u="overflow-hidden py-0";let R;e[18]!==t?(R=t("Policies"),e[18]=t,e[19]=R):R=e[19],e[20]!==R?(r=(0,l.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,l.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:R},void 0,!1)},void 0,!1),e[20]=R,e[21]=r):r=e[21],h=p&&j.length===0?(0,l.jsxDEV)(E,{description:t("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:t("No policies defined")},void 0,!1):(0,l.jsxDEV)(D,{className:"px-0",children:(0,l.jsxDEV)(_,{"data-testid":"rls-policies-table",children:[(0,l.jsxDEV)(O,{children:(0,l.jsxDEV)(I,{children:[(0,l.jsxDEV)(n,{children:t("Table")},void 0,!1),L.map(o=>(0,l.jsxDEV)(n,{children:z(t,o)},o,!1)),(0,l.jsxDEV)(n,{children:t("Guarded by")},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)($,{children:j.map(o=>(0,l.jsxDEV)(I,{"data-testid":`rls-table-${o.table}`,children:[(0,l.jsxDEV)(c,{className:"font-mono text-xs",children:o.table},void 0,!1),L.map(G=>(0,l.jsxDEV)(c,{children:o.operations.has(G)?(0,l.jsxDEV)(k,{variant:"secondary",children:t("Guarded")},void 0,!1):(0,l.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1)},G,!1)),(0,l.jsxDEV)(c,{className:"font-mono text-xs text-muted-foreground",children:o.procedures.join(", ")},void 0,!1)]},o.table,!0))},void 0,!1)]},void 0,!0)},void 0,!1),e[1]=s,e[2]=f,e[3]=p,e[4]=t,e[5]=m,e[6]=d,e[7]=u,e[8]=r,e[9]=h,e[10]=v,e[11]=b,e[12]=x,e[13]=i}else m=e[5],d=e[6],u=e[7],r=e[8],h=e[9],v=e[10],b=e[11],x=e[12],i=e[13];let N;e[22]!==m||e[23]!==u||e[24]!==r||e[25]!==h?(N=(0,l.jsxDEV)(m,{className:u,children:[r,h]},void 0,!0),e[22]=m,e[23]=u,e[24]=r,e[25]=h,e[26]=N):N=e[26];let y;e[27]!==v||e[28]!==N?(y=(0,l.jsxDEV)("section",{className:v,children:N},void 0,!1),e[27]=v,e[28]=N,e[29]=y):y=e[29];let g;e[30]!==t?(g=t("Roles"),e[30]=t,e[31]=g):g=e[31];let T;e[32]!==g?(T=(0,l.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,l.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g},void 0,!1)},void 0,!1),e[32]=g,e[33]=T):T=e[33];let w;e[34]!==p||e[35]!==d||e[36]!==t?(w=p&&d.length===0?(0,l.jsxDEV)(E,{description:t("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:t("No roles defined")},void 0,!1):(0,l.jsxDEV)(D,{className:"px-0",children:(0,l.jsxDEV)(_,{"data-testid":"rls-roles-table",children:[(0,l.jsxDEV)(O,{children:(0,l.jsxDEV)(I,{children:[(0,l.jsxDEV)(n,{children:t("Role")},void 0,!1),(0,l.jsxDEV)(n,{children:t("Description")},void 0,!1),(0,l.jsxDEV)(n,{children:t("Permissions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)($,{children:d.map(W)},void 0,!1)]},void 0,!0)},void 0,!1),e[34]=p,e[35]=d,e[36]=t,e[37]=w):w=e[37];let A;e[38]!==T||e[39]!==w?(A=(0,l.jsxDEV)("section",{className:"flex flex-col gap-2",children:(0,l.jsxDEV)(B,{className:"overflow-hidden py-0",children:[T,w]},void 0,!0)},void 0,!1),e[38]=T,e[39]=w,e[40]=A):A=e[40];let P;return e[41]!==A||e[42]!==b||e[43]!==x||e[44]!==i||e[45]!==y?(P=(0,l.jsxDEV)("div",{className:b,"data-testid":x,children:[i,y,A]},void 0,!0),e[41]=A,e[42]=b,e[43]=x,e[44]=i,e[45]=y,e[46]=P):P=e[46],P},"RlsPanel");function K(e){return(0,l.jsxDEV)(k,{variant:"outline",children:e},e,!1)}C(K,"_temp");function W(e){return(0,l.jsxDEV)(I,{"data-testid":`rls-role-${e.name}`,children:[(0,l.jsxDEV)(c,{className:"font-mono text-xs",children:e.name},void 0,!1),(0,l.jsxDEV)(c,{className:"text-muted-foreground",children:e.description??""},void 0,!1),(0,l.jsxDEV)(c,{children:e.permissions.length===0?(0,l.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1):(0,l.jsxDEV)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(K)},void 0,!1)},void 0,!1)]},e.name,!0)}C(W,"_temp2");export{ae as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as g,b as S}from"./chunk-FQKNJSRA.js";import{a as i,e as m,g as v,h as C,j as d}from"./chunk-RRCPZMC2.js";var w=i(e=>{let t=0,n=0,o=0,r=0,s=0,l=0,c=0;for(let{metrics:a}of e){if(a===null){s+=1;continue}r+=1,t+=a.requests,n+=a.errors,o+=a.databaseSize??0,a.cache!==null&&(l+=a.cache.hits,c+=a.cache.hits+a.cache.misses)}return{failed:s,hitRate:c===0?null:l/c,reachable:r,totalDatabaseSize:o,totalErrors:n,totalRequests:t}},"aggregateMetrics"),E=i((e,t)=>{let n=new Set,o=[];for(let r of["",e.trim(),...t])n.has(r)||(n.add(r),o.push(r));return o},"shardsToAggregate"),x=i((e,t)=>{if(e.length===0)return 0;if(e.sort((o,r)=>o-r),t<=0)return e[0]??0;if(t>=100)return e.at(-1)??0;let n=Math.ceil(t/100*e.length)-1;return e[n]??0},"percentile"),N=i(e=>{let n=e.functions;if(!n||n.length===0)return{p90:0,p95:0};let o=1e3,r=[];for(let s of n){if(s.calls<=0)continue;let l=s.totalDurationMs/s.calls,c=Math.min(s.calls,o);for(let a=0;a<c;a+=1)r.push(l)}return r.length===0?{p90:0,p95:0}:{p90:x([...r],90),p95:x([...r],95)}},"computeLatencyPercentiles");var _=i(e=>e.map(t=>({...t,avgDurationMs:t.execCount>0?t.totalDurationMs/t.execCount:0})),"enrichQueryStats");var b=m(v(),1);var p=m(C(),1);var D={value:{colors:{dark:["var(--foreground)"],light:["var(--foreground)"]},label:""}},P=i(e=>{let t=(0,b.c)(12),{ariaLabel:n,className:o,series:r,testId:s}=e;if(r.length<2)return null;let l;t[0]!==r?(l=r.slice(-40).map(M),t[0]=r,t[1]=l):l=t[1];let c=l,a;t[2]!==o?(a=d("h-6 w-[120px]",o),t[2]=o,t[3]=a):a=t[3];let u;t[4]===Symbol.for("react.memo_cache_sentinel")?(u=(0,p.jsxDEV)(S,{dataKey:"value"},void 0,!1),t[4]=u):u=t[4];let f;t[5]!==c?(f=(0,p.jsxDEV)(g,{animationType:"none",barCategoryGap:1,className:"h-full w-full",config:D,data:c,children:u},void 0,!1),t[5]=c,t[6]=f):f=t[6];let h;return t[7]!==n||t[8]!==a||t[9]!==f||t[10]!==s?(h=(0,p.jsxDEV)("div",{"aria-label":n,className:a,"data-testid":s,role:"img",children:f},void 0,!1),t[7]=n,t[8]=a,t[9]=f,t[10]=s,t[11]=h):h=t[11],h},"Sparkline");function M(e,t){return{index:t,value:e}}i(M,"_temp");export{w as a,E as b,N as c,_ as d,P as e};
|