@lunora/studio 1.0.0-alpha.100 → 1.0.0-alpha.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -1
- package/dist/packem_chunks/LogsPanel.js +1 -1
- package/dist/packem_chunks/MetricsPanel.js +1 -1
- package/dist/packem_chunks/traces-panel.js +1 -1
- package/dist/packem_shared/log-line-CmtmbZNE.js +1 -0
- package/dist/packem_shared/trace-handoff-D7j9TjUT.js +1 -0
- package/dist/packem_shared/use-open-trace-D9XDDHHS.js +1 -0
- package/dist/standalone/chunk-22SUVVIR.js +1 -0
- package/dist/standalone/{chunk-C2OHUG2J.js → chunk-35SAF2LS.js} +1 -1
- package/dist/standalone/chunk-37PXYIVK.js +1 -0
- package/dist/standalone/{chunk-JN2Y24PY.js → chunk-3DH35OZ5.js} +1 -1
- package/dist/standalone/chunk-3RC2X4I2.js +1 -0
- package/dist/standalone/chunk-4KPBTODU.js +1 -0
- package/dist/standalone/{chunk-EALHAMLB.js → chunk-4PDTGZDC.js} +2 -2
- package/dist/standalone/{chunk-MQ2GKKQ6.js → chunk-4V4RO52I.js} +1 -1
- package/dist/standalone/{chunk-FMM3XUZH.js → chunk-5BEGIQM7.js} +1 -1
- package/dist/standalone/chunk-5HMBKUFH.js +1 -0
- package/dist/standalone/chunk-6C6FRIYD.js +1 -0
- package/dist/standalone/{chunk-322ZP3GW.js → chunk-6IZBFC3G.js} +1 -1
- package/dist/standalone/{chunk-BUVIRYQM.js → chunk-6THGMZNI.js} +1 -1
- package/dist/standalone/chunk-7AY2447G.js +1 -0
- package/dist/standalone/{chunk-5NCGZJ55.js → chunk-7GNNMMT4.js} +1 -1
- package/dist/standalone/chunk-7MT6C3FS.js +1 -0
- package/dist/standalone/chunk-A3DCTWSA.js +1 -0
- package/dist/standalone/{chunk-M43KO276.js → chunk-APBWFKW5.js} +1 -1
- package/dist/standalone/chunk-B5FMYLVA.js +1 -0
- package/dist/standalone/chunk-BB7WLC24.js +1 -0
- package/dist/standalone/{chunk-Y7XGNPT6.js → chunk-BCMLQ3LV.js} +1 -1
- package/dist/standalone/{chunk-55PVLIN3.js → chunk-BIVP5DZB.js} +1 -1
- package/dist/standalone/{chunk-DGRAPESO.js → chunk-DBAMCESO.js} +1 -1
- package/dist/standalone/{chunk-GGADAESO.js → chunk-DC23USXJ.js} +1 -1
- package/dist/standalone/chunk-DJZYD5I5.js +1 -0
- package/dist/standalone/chunk-DSDJ3QRD.js +1 -0
- package/dist/standalone/chunk-DY34ZZ5K.js +1 -0
- package/dist/standalone/chunk-ELI5HREQ.js +2 -0
- package/dist/standalone/{chunk-XAEG372C.js → chunk-ELJZNBBJ.js} +1 -1
- package/dist/standalone/{chunk-RTMMB3OY.js → chunk-EWGPDRH3.js} +1 -1
- package/dist/standalone/chunk-G6VZTEGG.js +1 -0
- package/dist/standalone/{chunk-4KIQ5RLS.js → chunk-GG6PIGQO.js} +1 -1
- package/dist/standalone/{chunk-MZ2JNVMR.js → chunk-GRRBUXEI.js} +1 -1
- package/dist/standalone/{chunk-F7IRBXWY.js → chunk-GSQDZMV5.js} +1 -1
- package/dist/standalone/{chunk-NE4N6I57.js → chunk-IID7VT2A.js} +1 -1
- package/dist/standalone/{chunk-PVF5J5UD.js → chunk-IRXDBOOU.js} +1 -1
- package/dist/standalone/chunk-K2E4OECF.js +1 -0
- package/dist/standalone/chunk-LKBKYLWK.js +1 -0
- package/dist/standalone/{chunk-UF6XZKV3.js → chunk-LPBWDHKM.js} +1 -1
- package/dist/standalone/{chunk-M3NGYXDR.js → chunk-LYVP5PT6.js} +1 -1
- package/dist/standalone/chunk-LZFOZFYW.js +1 -0
- package/dist/standalone/{chunk-WMLKVJUX.js → chunk-MRK53LUL.js} +1 -1
- package/dist/standalone/chunk-MWIKAR7F.js +1 -0
- package/dist/standalone/{chunk-5GQFG6QI.js → chunk-NH4HJFG3.js} +1 -1
- package/dist/standalone/chunk-NLHEYDAA.js +1 -0
- package/dist/standalone/{chunk-GVSKCIJR.js → chunk-NLWDTGEP.js} +1 -1
- package/dist/standalone/chunk-OHOWUEQ3.js +1 -0
- package/dist/standalone/chunk-ORNIQZ2P.js +1 -0
- package/dist/standalone/chunk-PCAI3G4M.js +1 -0
- package/dist/standalone/{chunk-V76WCOMM.js → chunk-QJW2Z3SI.js} +1 -1
- package/dist/standalone/{chunk-MKYEFQCA.js → chunk-RA5DW5MU.js} +1 -1
- package/dist/standalone/chunk-RO6LEET3.js +1 -0
- package/dist/standalone/chunk-RTXAZLAE.js +1 -0
- package/dist/standalone/{chunk-AB5WGAX6.js → chunk-SBZXUGZ7.js} +1 -1
- package/dist/standalone/chunk-T6YGEL6X.js +1 -0
- package/dist/standalone/chunk-TFSGDOCG.js +1 -0
- package/dist/standalone/{chunk-FKAUVTSS.js → chunk-TQEVFVNP.js} +1 -1
- package/dist/standalone/{chunk-JXF2J6QZ.js → chunk-U4THUBUT.js} +1 -1
- package/dist/standalone/{chunk-4HNNNIDW.js → chunk-U62QRT34.js} +1 -1
- package/dist/standalone/chunk-UALL2OBT.js +1 -0
- package/dist/standalone/{chunk-BQNVN2OD.js → chunk-UP7OTXKF.js} +1 -1
- package/dist/standalone/chunk-VITTPKH5.js +1 -0
- package/dist/standalone/{chunk-CJLOWFCK.js → chunk-W3VOX7VR.js} +1 -1
- package/dist/standalone/chunk-W3XKLUWQ.js +1 -0
- package/dist/standalone/{chunk-6UPCJAAI.js → chunk-WMBDXCYL.js} +1 -1
- package/dist/standalone/{chunk-6V27P65N.js → chunk-WPK2Q33V.js} +1 -1
- package/dist/standalone/{chunk-YC52XCPK.js → chunk-X7B6PLEW.js} +4 -4
- package/dist/standalone/chunk-Y32QIKBS.js +1 -0
- package/dist/standalone/{chunk-K3PSOZXH.js → chunk-YZ7OINPX.js} +1 -1
- package/dist/standalone/{chunk-HGSIVV32.js → chunk-ZMDNTTAC.js} +1 -1
- package/dist/standalone/{chunk-P4BOVBMR.js → chunk-ZNNKWEH5.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +6 -6
- package/dist/packem_shared/log-fields-CoL3hsIQ.js +0 -1
- package/dist/packem_shared/trace-handoff-CuZ6WGgo.js +0 -1
- package/dist/standalone/chunk-5PQCUZIE.js +0 -1
- package/dist/standalone/chunk-6UPIWTCN.js +0 -1
- package/dist/standalone/chunk-7LJL6UC2.js +0 -1
- package/dist/standalone/chunk-APXXEXIX.js +0 -1
- package/dist/standalone/chunk-AREBQI6D.js +0 -1
- package/dist/standalone/chunk-DB2D42KJ.js +0 -1
- package/dist/standalone/chunk-DBCMZ4NF.js +0 -1
- package/dist/standalone/chunk-EIK3BLGV.js +0 -1
- package/dist/standalone/chunk-EV2NKHXP.js +0 -1
- package/dist/standalone/chunk-F6W6WUAJ.js +0 -1
- package/dist/standalone/chunk-FXCBF4XT.js +0 -1
- package/dist/standalone/chunk-GRTTHN6U.js +0 -1
- package/dist/standalone/chunk-IVQUDVQV.js +0 -1
- package/dist/standalone/chunk-JYYXXMLM.js +0 -1
- package/dist/standalone/chunk-KESD5PH6.js +0 -1
- package/dist/standalone/chunk-LUIZB427.js +0 -1
- package/dist/standalone/chunk-PKEBAPJY.js +0 -1
- package/dist/standalone/chunk-PKSAWP56.js +0 -1
- package/dist/standalone/chunk-QC2SRHZV.js +0 -1
- package/dist/standalone/chunk-QNWJ5Q2O.js +0 -1
- package/dist/standalone/chunk-QWGT25SE.js +0 -1
- package/dist/standalone/chunk-QZFRZEDN.js +0 -1
- package/dist/standalone/chunk-UETRSNZI.js +0 -2
- package/dist/standalone/chunk-UF7QFJ65.js +0 -1
- package/dist/standalone/chunk-VC4WBYE6.js +0 -1
- package/dist/standalone/chunk-VJHQW5X5.js +0 -1
- package/dist/standalone/chunk-W25EQ7YQ.js +0 -1
- package/dist/standalone/chunk-WGEZGQZ5.js +0 -1
- package/dist/standalone/chunk-XHMHOSGK.js +0 -1
- package/dist/standalone/chunk-Z6CJGUSL.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{R as Q}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{a as W}from"./chunk-MWIKAR7F.js";import"./chunk-DJZYD5I5.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{f as F}from"./chunk-LYVP5PT6.js";import"./chunk-XBDKZZ67.js";import{a as Z}from"./chunk-XQCVZAGU.js";import{a as q,b as L,c as B,d as f,e as c,f as d}from"./chunk-WJQLNYGX.js";import{a as I,e as j}from"./chunk-WQH3LT2P.js";import{d as K,h as S,m as $,o as V}from"./chunk-IUYFXK4X.js";import"./chunk-X7B6PLEW.js";import{a as h,e as C,f as R,g as P,h as U}from"./chunk-3XIESWL4.js";var A=C(P(),1);var n=C(R(),1);var e=C(U(),1);var X=10,b=h(v=>{let l=(0,A.c)(7),{label:m,value:a}=v,r;l[0]!==m?(r=(0,e.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:m}),l[0]=m,l[1]=r):r=l[1];let p=a??"\u2014",s;l[2]!==p?(s=(0,e.jsx)("span",{className:"font-mono text-sm",children:p}),l[2]=p,l[3]=s):s=l[3];let u;return l[4]!==r||l[5]!==s?(u=(0,e.jsxs)("div",{className:"flex flex-col gap-0.5",children:[r,s]}),l[4]=r,l[5]=s,l[6]=u):u=l[6],u},"g"),se=h(({loadIndexes:v,runQuery:l}={})=>{let m=F(),a=K(),[r,p]=(0,n.useState)(null),[s,u]=(0,n.useState)(null),[N,E]=(0,n.useState)(null),[g,D]=(0,n.useState)(""),[x,y]=(0,n.useState)(null),[M,w]=(0,n.useState)(null),[T,z]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let t={cancelled:!1};return V((async()=>{try{let i=await(v??(()=>m.listVectorIndexes()))();t.cancelled||(p(i),u(null),E(k=>k??i[0]?.name??null))}catch(i){t.cancelled||(p(null),u(S(i)))}})()),()=>{t.cancelled=!0}},[m,v]);let o=r?.find(t=>t.name===N)??null,G=h(t=>{E(t.currentTarget.dataset.index??null),y(null),w(null)},"K"),H=h(t=>{D(t.target.value)},"T"),J=h(async()=>{let t=g.trim();if(!(N===null||t==="")){z(!0),w(null);try{let i=await(l??(k=>m.queryVectorIndex(k)))({name:N,text:t,topK:X});y(i)}catch(i){y(null),w(S(i))}z(!1)}},"Z"),O=h(()=>{V(J())},"z");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[s!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:s}),r!==null&&r.length===0&&(0,e.jsx)(Z,{description:a("Indexes declared with .vectorize() or defineVectorIndex() appear here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:a("No vector indexes.")}),r!==null&&r.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-table",children:[(0,e.jsx)(L,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:a("name")}),(0,e.jsx)(c,{children:a("table")}),(0,e.jsx)(c,{children:a("dimensions")}),(0,e.jsx)(c,{children:a("metric")}),(0,e.jsx)(c,{children:a("vectors")})]})}),(0,e.jsx)(B,{children:r.map(t=>(0,e.jsxs)(f,{className:t.name===N?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":t.name,"data-testid":`vector-row-${t.name}`,onClick:G,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.name}),(0,e.jsx)(d,{className:"font-mono text-xs",children:t.table}),(0,e.jsx)(d,{className:"tabular-nums",children:t.dimensions??"\u2014"}),(0,e.jsx)(d,{children:t.metric??"\u2014"}),(0,e.jsx)(d,{className:"tabular-nums",children:t.vectorsCount??"\u2014"})]},t.name))})]})})}),o!==null&&(0,e.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[(0,e.jsx)(b,{label:a("field"),value:o.field}),(0,e.jsx)(b,{label:a("dimensions"),value:o.dimensions}),(0,e.jsx)(b,{label:a("metric"),value:o.metric}),(0,e.jsx)(b,{label:a("vectors"),value:o.vectorsCount})]}),o.metadata!==void 0&&o.metadata.length>0&&(0,e.jsxs)("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[a("metadata"),": ",(0,e.jsx)("span",{className:"font-mono",children:o.metadata.join(", ")})]}),(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,e.jsx)(Q,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:H,placeholder:a("Search by similarity\u2026"),value:g}),(0,e.jsx)(W,{"data-testid":"vector-search",disabled:T||g.trim()==="",onClick:O,children:a(T?"Searching\u2026":"Search")})]}),M!==null&&(0,e.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:M}),x!==null&&x.length===0&&(0,e.jsx)("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:a("No matches.")}),x!==null&&x.length>0&&(0,e.jsx)(I,{className:"mt-3 overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-matches",children:[(0,e.jsx)(L,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:a("id")}),(0,e.jsx)(c,{children:a("score")}),(0,e.jsx)(c,{children:a("metadata")})]})}),(0,e.jsx)(B,{children:x.map(t=>(0,e.jsxs)(f,{"data-testid":`vector-match-${t.id}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.id}),(0,e.jsx)(d,{className:"tabular-nums",children:t.score.toFixed(4)}),(0,e.jsx)(d,{className:"max-w-md truncate font-mono text-xs",children:t.metadata===void 0?"\u2014":$(t.metadata)})]},t.id))})]})})})]})]})},"ce");export{se as VectorBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as W}from"./chunk-54MMVNPT.js";import{a as F}from"./chunk-3CWGJYBB.js";import{a as E}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as L}from"./chunk-
|
|
1
|
+
import{a as W}from"./chunk-54MMVNPT.js";import{a as F}from"./chunk-3CWGJYBB.js";import{a as E}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as L}from"./chunk-6IZBFC3G.js";import"./chunk-XXQUMVWH.js";import"./chunk-ZNNKWEH5.js";import"./chunk-QLQADHFE.js";import{a as D}from"./chunk-VDW32UET.js";import{c as _}from"./chunk-UP7OTXKF.js";import"./chunk-LYVP5PT6.js";import"./chunk-XBDKZZ67.js";import{a as T}from"./chunk-XQCVZAGU.js";import{a as O,b as P,c as U,d as w,e as h,f as p}from"./chunk-WJQLNYGX.js";import{a as $,e as j}from"./chunk-WQH3LT2P.js";import{d as M}from"./chunk-IUYFXK4X.js";import"./chunk-X7B6PLEW.js";import{a as S,e as A,g as R,h as Z}from"./chunk-3XIESWL4.js";var B=A(R(),1);var t=A(Z(),1);var q=80,z=S(a=>{if(a===void 0)return"";let e=JSON.stringify(a);return e.length>q?`${e.slice(0,q)}\u2026`:e},"W"),G=S(a=>{let e=[];for(let r of a){let n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((l,i)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${i.toString()}`,subscription:l})})}return e},"B"),C=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),oe=S(a=>{let e=(0,B.c)(22),{initialShardKey:r}=a,n=M(),{queryShardKey:l,setShardKey:i,shardKey:m}=F(r),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let b;e[1]!==l?(b={keepPreviousData:!0,shardKey:l},e[1]=l,e[2]=b):b=e[2];let{data:s,error:o,errorSource:u,refetch:J}=_(D.listSubscriptions,f,b);W(J,!0);let x;if(e[3]!==o||e[4]!==u||e[5]!==s||e[6]!==i||e[7]!==m||e[8]!==n){let k=s===void 0?[]:G(s.connections),c;e[10]!==i||e[11]!==m?(c=(0,t.jsx)(E,{onChange:i,testId:"subs-shard-input",value:m}),e[10]=i,e[11]=m,e[12]=c):c=e[12];let d;e[13]!==s||e[14]!==n?(d=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[(0,t.jsx)(y,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),(0,t.jsx)(y,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=d):d=e[15];let g;e[16]!==c||e[17]!==d?(g=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,d]}),e[16]=c,e[17]=d,e[18]=g):g=e[18];let v;e[19]!==o||e[20]!==u?(v=o!==null&&(0,t.jsx)(L,{error:u,testId:"subs-error"}),e[19]=o,e[20]=u,e[21]=v):v=e[21],x=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,v,o===null&&s!==void 0&&k.length===0&&(0,t.jsx)(T,{description:n("Active WebSocket subscriptions on this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),o===null&&k.length>0&&(0,t.jsx)($,{className:"overflow-hidden py-0",children:(0,t.jsx)(j,{className:"px-0",children:(0,t.jsxs)(O,{"data-testid":"subs-table",children:[(0,t.jsx)(P,{children:(0,t.jsxs)(w,{children:[(0,t.jsx)(h,{children:n("Connection")}),(0,t.jsx)(h,{children:n("Function path")}),(0,t.jsx)(h,{children:n("Table")}),(0,t.jsx)(h,{children:n("Arguments")})]})}),(0,t.jsx)(U,{children:k.map(N=>{let{subscription:I}=N,K=z(I?.args);return(0,t.jsxs)(w,{"data-testid":"subs-row",children:[(0,t.jsx)(p,{className:"font-medium tabular-nums",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:["#",N.connectionId,N.admin&&(0,t.jsx)(y,{variant:"outline",children:n("admin")})]})}),(0,t.jsx)(p,{className:"font-mono text-xs",children:I?.functionPath??C}),(0,t.jsx)(p,{children:I?.table??C}),(0,t.jsx)(p,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:K||void 0,children:K||C})]},N.key)})})]})})})]}),e[3]=o,e[4]=u,e[5]=s,e[6]=i,e[7]=m,e[8]=n,e[9]=x}else x=e[9];return x},"oe");export{oe as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as p}from"./chunk-YC52XCPK.js";import{a,e as P,f as $,g as lt,h as Ue}from"./chunk-3XIESWL4.js";var L=class{static{a(this,"Subscribable")}constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var fr=class extends L{static{a(this,"FocusManager")}#e;#t;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=a(()=>t(),"listener");return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#r=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){let t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},X=new fr;var pr={setTimeout:a((t,e)=>setTimeout(t,e),"setTimeout"),clearTimeout:a(t=>clearTimeout(t),"clearTimeout"),setInterval:a((t,e)=>setInterval(t,e),"setInterval"),clearInterval:a(t=>clearInterval(t),"clearInterval")},mr=class{static{a(this,"TimeoutManager")}#e=pr;#t=!1;setTimeoutProvider(t){this.#e=t}setTimeout(t,e){return this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},Q=new mr;function ft(t){setTimeout(t,0)}a(ft,"systemSetTimeoutZero");var Ne=typeof window>"u"||"Deno"in globalThis;function g(){}a(g,"noop");function yt(t,e){return typeof t=="function"?t(e):t}a(yt,"functionalUpdate");function ie(t){return typeof t=="number"&&t>=0&&t!==1/0}a(ie,"isValidTimeout");function me(t,e){return Math.max(t+(e||0)-Date.now(),0)}a(me,"timeUntilStale");function x(t,e){return typeof t=="function"?t(e):t}a(x,"resolveStaleTime");function I(t,e){return typeof t=="function"?t(e):t}a(I,"resolveQueryBoolean");function ye(t,e){let{type:r="all",exact:s,fetchStatus:i,predicate:n,queryKey:o,stale:c}=t;if(o){if(s){if(e.queryHash!==ne(o,e.options))return!1}else if(!N(e.queryKey,o))return!1}if(r!=="all"){let u=e.isActive();if(r==="active"&&!u||r==="inactive"&&u)return!1}return!(typeof c=="boolean"&&e.isStale()!==c||i&&i!==e.state.fetchStatus||n&&!n(e))}a(ye,"matchQuery");function be(t,e){let{exact:r,status:s,predicate:i,mutationKey:n}=t;if(n){if(!e.options.mutationKey)return!1;if(r){if(H(e.options.mutationKey)!==H(n))return!1}else if(!N(e.options.mutationKey,n))return!1}return!(s&&e.state.status!==s||i&&!i(e))}a(be,"matchMutation");function ne(t,e){return(e?.queryKeyHashFn||H)(t)}a(ne,"hashQueryKeyByOptions");function H(t){return JSON.stringify(t,(e,r)=>qe(r)?Object.keys(r).sort().reduce((s,i)=>(s[i]=r[i],s),{}):r)}a(H,"hashKey");function N(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(Array.isArray(t)&&Array.isArray(e)){for(let s=0;s<e.length;s++)if(!N(t[s],e[s]))return!1;return!0}let r=Object.keys(e);for(let s of r)if(!N(t[s],e[s]))return!1;return!0}return!1}a(N,"partialMatchKey");var yr=Object.prototype.hasOwnProperty;function Be(t,e,r=0){if(t===e)return t;if(r>500)return e;let s=pt(t)&&pt(e);if(!s&&!(qe(t)&&qe(e)))return e;let n=(s?t:Object.keys(t)).length,o=s?e:Object.keys(e),c=o.length,u=s?new Array(c):{},d=0;for(let h=0;h<c;h++){let l=s?h:o[h],f=t[l],m=e[l];if(f===m){u[l]=f,(s?h<n:yr.call(t,l))&&d++;continue}if(f===null||m===null||typeof f!="object"||typeof m!="object"){u[l]=m;continue}let y=Be(f,m,r+1);u[l]=y,y===f&&d++}return n===c&&d===n?t:u}a(Be,"replaceEqualDeep");function ve(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(let r in t)if(t[r]!==e[r])return!1;return!0}a(ve,"shallowEqualObjects");function pt(t){return Array.isArray(t)&&t.length===Object.keys(t).length}a(pt,"isPlainArray");function qe(t){if(!mt(t))return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(!mt(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}a(qe,"isPlainObject");function mt(t){return Object.prototype.toString.call(t)==="[object Object]"}a(mt,"hasObjectPrototype");function bt(t){return new Promise(e=>{Q.setTimeout(e,t)})}a(bt,"sleep");function ae(t,e,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,e):r.structuralSharing!==!1?Be(t,e):e}a(ae,"replaceData");function br(t){return t}a(br,"keepPreviousData");function vt(t,e,r=0){let s=[...t,e];return r&&s.length>r?s.slice(1):s}a(vt,"addToEnd");function gt(t,e,r=0){let s=[e,...t];return r&&s.length>r?s.slice(0,-1):s}a(gt,"addToStart");var Y=Symbol();function ge(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===Y?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}a(ge,"ensureQueryFn");function Se(t,e){return typeof t=="function"?t(...e):!!t}a(Se,"shouldThrowError");function St(t,e,r){let s=!1,i;return Object.defineProperty(t,"signal",{enumerable:!0,get:a(()=>(i??=e(),s||(s=!0,i.aborted?r():i.addEventListener("abort",r,{once:!0})),i),"get")}),t}a(St,"addConsumeAwareSignal");var D=(()=>{let t=a(()=>Ne,"isServerFn");return{isServer(){return t()},setIsServer(e){t=e}}})();function oe(){let t,e,r=new Promise((i,n)=>{t=i,e=n});r.status="pending",r.catch(()=>{});function s(i){Object.assign(r,i),delete r.resolve,delete r.reject}return a(s,"finalize"),r.resolve=i=>{s({status:"fulfilled",value:i}),t(i)},r.reject=i=>{s({status:"rejected",reason:i}),e(i)},r}a(oe,"pendingThenable");var wt=ft;function vr(){let t=[],e=0,r=a(c=>{c()},"notifyFn"),s=a(c=>{c()},"batchNotifyFn"),i=wt,n=a(c=>{e?t.push(c):i(()=>{r(c)})},"schedule"),o=a(()=>{let c=t;t=[],c.length&&i(()=>{s(()=>{c.forEach(u=>{r(u)})})})},"flush");return{batch:a(c=>{let u;e++;try{u=c()}finally{e--,e||o()}return u},"batch"),batchCalls:a(c=>(...u)=>{n(()=>{c(...u)})},"batchCalls"),schedule:n,setNotifyFunction:a(c=>{r=c},"setNotifyFunction"),setBatchNotifyFunction:a(c=>{s=c},"setBatchNotifyFunction"),setScheduler:a(c=>{i=c},"setScheduler")}}a(vr,"createNotifyManager");var v=vr();var gr=class extends L{static{a(this,"OnlineManager")}#e=!0;#t;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=a(()=>t(!0),"onlineListener"),r=a(()=>t(!1),"offlineListener");return window.addEventListener("online",e,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#r=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(r=>{r(t)}))}isOnline(){return this.#e}},Z=new gr;function Sr(t){return Math.min(1e3*2**t,3e4)}a(Sr,"defaultRetryDelay");function Ke(t){return(t??"online")==="online"?Z.isOnline():!0}a(Ke,"canFetch");var we=class extends Error{static{a(this,"CancelledError")}constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Ce(t){let e=!1,r=0,s,i=oe(),n=a(()=>i.status!=="pending","isResolved"),o=a(b=>{if(!n()){let w=new we(b);f(w),t.onCancel?.(w)}},"cancel"),c=a(()=>{e=!0},"cancelRetry"),u=a(()=>{e=!1},"continueRetry"),d=a(()=>X.isFocused()&&(t.networkMode==="always"||Z.isOnline())&&t.canRun(),"canContinue"),h=a(()=>Ke(t.networkMode)&&t.canRun(),"canStart"),l=a(b=>{n()||(s?.(),i.resolve(b))},"resolve"),f=a(b=>{n()||(s?.(),i.reject(b))},"reject"),m=a(()=>new Promise(b=>{s=a(w=>{(n()||d())&&b(w)},"continueFn"),t.onPause?.()}).then(()=>{s=void 0,n()||t.onContinue?.()}),"pause"),y=a(()=>{if(n())return;let b,w=r===0?t.initialPromise:void 0;try{b=w??t.fn()}catch(E){b=Promise.reject(E)}Promise.resolve(b).then(l).catch(E=>{if(n())return;let M=t.retry??(D.isServer()?0:3),U=t.retryDelay??Sr,K=typeof U=="function"?U(r,E):U,j=M===!0||typeof M=="number"&&r<M||typeof M=="function"&&M(r,E);if(e||!j){f(E);return}r++,t.onFail?.(r,E),bt(K).then(()=>d()?void 0:m()).then(()=>{e?f(E):y()})})},"run");return{promise:i,status:a(()=>i.status,"status"),cancel:o,continue:a(()=>(s?.(),i),"continue"),cancelRetry:c,continueRetry:u,canStart:h,start:a(()=>(h()?y():m().then(y),i),"start")}}a(Ce,"createRetryer");var ke=class{static{a(this,"Removable")}#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ie(this.gcTime)&&(this.#e=Q.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(D.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(Q.clearTimeout(this.#e),this.#e=void 0)}};function kt(t){return{onFetch:a((e,r)=>{let s=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,n=e.state.data?.pages||[],o=e.state.data?.pageParams||[],c={pages:[],pageParams:[]},u=0,d=a(async()=>{let h=!1,l=a(y=>{St(y,()=>e.signal,()=>h=!0)},"addSignalProperty"),f=ge(e.options,e.fetchOptions),m=a(async(y,b,w)=>{if(h)return Promise.reject(e.signal.reason);if(b==null&&y.pages.length)return Promise.resolve(y);let M=a(()=>{let De={client:e.client,queryKey:e.queryKey,pageParam:b,direction:w?"backward":"forward",meta:e.options.meta};return l(De),De},"createQueryFnContext")(),U=await f(M),{maxPages:K}=e.options,j=w?gt:vt;return{pages:j(y.pages,U,K),pageParams:j(y.pageParams,b,K)}},"fetchPage");if(i&&n.length){let y=i==="backward",b=y?wr:Ct,w={pages:n,pageParams:o},E=b(s,w);c=await m(w,E,y)}else{let y=t??n.length;do{let b=u===0?o[0]??s.initialPageParam:Ct(s,c);if(u>0&&b==null)break;c=await m(c,b),u++}while(u<y)}return c},"fetchFn");e.options.persister?e.fetchFn=()=>e.options.persister?.(d,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r):e.fetchFn=d},"onFetch")}}a(kt,"infiniteQueryBehavior");function Ct(t,{pages:e,pageParams:r}){let s=e.length-1;return e.length>0?t.getNextPageParam(e[s],e,r[s],r):void 0}a(Ct,"getNextPageParam");function wr(t,{pages:e,pageParams:r}){return e.length>0?t.getPreviousPageParam?.(e[0],e,r[0],r):void 0}a(wr,"getPreviousPageParam");var Tt=class extends ke{static{a(this,"Query")}#e;#t;#r;#s;#n;#i;#o;#a;constructor(t){super(),this.#a=!1,this.#o=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#n=t.client,this.#s=this.#n.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#t=Et(this.options),this.state=t.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#i?.promise}setOptions(t){if(this.options={...this.#o,...t},t?._type&&(this.#e=t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Et(this.options);e.data!==void 0&&(this.setState(It(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(t,e){let r=ae(this.state.data,t,this.options);return this.#c({data:r,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),r}setState(t){this.#c({type:"setState",state:t})}cancel(t){let e=this.#i?.promise;return this.#i?.cancel(t),e?e.then(g).catch(g):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>I(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Y||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>x(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!me(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#i&&(this.#a||this.#h()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}#h(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#c({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#i?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(t&&this.setOptions(t),!this.options.queryFn){let u=this.observers.find(d=>d.options.queryFn);u&&this.setOptions(u.options)}let r=new AbortController,s=a(u=>{Object.defineProperty(u,"signal",{enumerable:!0,get:a(()=>(this.#a=!0,r.signal),"get")})},"addSignalProperty"),i=a(()=>{let u=ge(this.options,e),h=a(()=>{let l={client:this.#n,queryKey:this.queryKey,meta:this.meta};return s(l),l},"createQueryFnContext")();return this.#a=!1,this.options.persister?this.options.persister(u,h,this):u(h)},"fetchFn"),o=a(()=>{let u={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#n,state:this.state,fetchFn:i};return s(u),u},"createFetchContext")();(this.#e==="infinite"?kt(this.options.pages):this.options.behavior)?.onFetch(o,this),this.#r=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#c({type:"fetch",meta:o.fetchOptions?.meta}),this.#i=Ce({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:a(u=>{u instanceof we&&u.revert&&this.setState({...this.#r,fetchStatus:"idle"}),r.abort()},"onCancel"),onFail:a((u,d)=>{this.#c({type:"failed",failureCount:u,error:d})},"onFail"),onPause:a(()=>{this.#c({type:"pause"})},"onPause"),onContinue:a(()=>{this.#c({type:"continue"})},"onContinue"),retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:a(()=>!0,"canRun")});try{let u=await this.#i.start();if(u===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(u),this.#s.config.onSuccess?.(u,this),this.#s.config.onSettled?.(u,this.state.error,this),u}catch(u){if(u instanceof we){if(u.silent)return this.#i.promise;if(u.revert){if(this.state.data===void 0)throw u;return this.state.data}}throw this.#c({type:"error",error:u}),this.#s.config.onError?.(u,this),this.#s.config.onSettled?.(this.state.data,u,this),u}finally{this.scheduleGc()}}#c(t){let e=a(r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...je(r.data,this.options),fetchMeta:t.meta??null};case"success":let s={...r,...It(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#r=t.manual?s:void 0,s;case"error":let i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}},"reducer");this.state=e(this.state),v.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:t})})}};function je(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ke(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}a(je,"fetchState");function It(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}a(It,"successState");function Et(t){let e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,s=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}a(Et,"getDefaultState");var He=class extends L{static{a(this,"QueryObserver")}constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=oe(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#r=void 0;#s=void 0;#n;#i;#o;#a;#h;#c;#p;#d;#l;#u;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Ot(this.#t,this.options)?this.#f():this.updateResult(),this.#g())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return $e(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return $e(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#w(),this.#t.removeObserver(this)}setOptions(t){let e=this.options,r=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof I(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#C(),this.#t.setOptions(this.options),e._defaulted&&!ve(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});let s=this.hasListeners();s&&Rt(this.#t,r,this.options,e)&&this.#f(),this.updateResult(),s&&(this.#t!==r||I(this.options.enabled,this.#t)!==I(e.enabled,this.#t)||x(this.options.staleTime,this.#t)!==x(e.staleTime,this.#t))&&this.#y();let i=this.#b();s&&(this.#t!==r||I(this.options.enabled,this.#t)!==I(e.enabled,this.#t)||i!==this.#u)&&this.#v(i)}getOptimisticResult(t){let e=this.#e.getQueryCache().build(this.#e,t),r=this.createResult(e,t);return kr(this,r)&&(this.#s=r,this.#i=this.options,this.#n=this.#t.state),r}getCurrentResult(){return this.#s}trackResult(t,e){return new Proxy(t,{get:a((r,s)=>(this.trackProp(s),e?.(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s)),"get")})}trackProp(t){this.#m.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let e=this.#e.defaultQueryOptions(t),r=this.#e.getQueryCache().build(this.#e,e);return r.fetch().then(()=>this.createResult(r,e))}fetch(t){return this.#f({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#f(t){this.#C();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(g)),e}#y(){this.#S();let t=x(this.options.staleTime,this.#t);if(D.isServer()||this.#s.isStale||!ie(t))return;let r=me(this.#s.dataUpdatedAt,t)+1;this.#d=Q.setTimeout(()=>{this.#s.isStale||this.updateResult()},r)}#b(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(t){this.#w(),this.#u=t,!(D.isServer()||I(this.options.enabled,this.#t)===!1||!ie(this.#u)||this.#u===0)&&(this.#l=Q.setInterval(()=>{(this.options.refetchIntervalInBackground||X.isFocused())&&this.#f()},this.#u))}#g(){this.#y(),this.#v(this.#b())}#S(){this.#d!==void 0&&(Q.clearTimeout(this.#d),this.#d=void 0)}#w(){this.#l!==void 0&&(Q.clearInterval(this.#l),this.#l=void 0)}createResult(t,e){let r=this.#t,s=this.options,i=this.#s,n=this.#n,o=this.#i,u=t!==r?t.state:this.#r,{state:d}=t,h={...d},l=!1,f;if(e._optimisticResults){let R=this.hasListeners(),se=!R&&Ot(t,e),le=R&&Rt(t,r,e,s);(se||le)&&(h={...h,...je(d.data,t.options)}),e._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:m,errorUpdatedAt:y,status:b}=h;f=h.data;let w=!1;if(e.placeholderData!==void 0&&f===void 0&&b==="pending"){let R;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(R=i.data,w=!0):R=typeof e.placeholderData=="function"?e.placeholderData(this.#p?.state.data,this.#p):e.placeholderData,R!==void 0&&(b="success",f=ae(i?.data,R,e),l=!0)}if(e.select&&f!==void 0&&!w)if(i&&f===n?.data&&e.select===this.#h)f=this.#c;else try{this.#h=e.select,f=e.select(f),f=ae(i?.data,f,e),this.#c=f,this.#a=null}catch(R){this.#a=R}this.#a&&(m=this.#a,f=this.#c,y=Date.now(),b="error");let E=h.fetchStatus==="fetching",M=b==="pending",U=b==="error",K=M&&E,j=f!==void 0,q={status:b,fetchStatus:h.fetchStatus,isPending:M,isSuccess:b==="success",isError:U,isInitialLoading:K,isLoading:K,data:f,dataUpdatedAt:h.dataUpdatedAt,error:m,errorUpdatedAt:y,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:E,isRefetching:E&&!M,isLoadingError:U&&!j,isPaused:h.fetchStatus==="paused",isPlaceholderData:l,isRefetchError:U&&j,isStale:ze(t,e),refetch:this.refetch,promise:this.#o,isEnabled:I(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){let R=q.data!==void 0,se=q.status==="error"&&!R,le=a(pe=>{se?pe.reject(q.error):R&&pe.resolve(q.data)},"finalizeThenableIfPossible"),dt=a(()=>{let pe=this.#o=q.promise=oe();le(pe)},"recreateThenable"),fe=this.#o;switch(fe.status){case"pending":t.queryHash===r.queryHash&&le(fe);break;case"fulfilled":(se||q.data!==fe.value)&&dt();break;case"rejected":(!se||q.error!==fe.reason)&&dt();break}}return q}updateResult(){let t=this.#s,e=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#i=this.options,this.#n.data!==void 0&&(this.#p=this.#t),ve(e,t))return;this.#s=e;let r=a(()=>{if(!t)return!0;let{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!this.#m.size)return!0;let n=new Set(i??this.#m);return this.options.throwOnError&&n.add("error"),Object.keys(this.#s).some(o=>{let c=o;return this.#s[c]!==t[c]&&n.has(c)})},"shouldNotifyListeners");this.#k({listeners:r()})}#C(){let t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;let e=this.#t;this.#t=t,this.#r=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#g()}#k(t){v.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function Cr(t,e){return I(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&I(e.retryOnMount,t)===!1)}a(Cr,"shouldLoadOnMount");function Ot(t,e){return Cr(t,e)||t.state.data!==void 0&&$e(t,e,e.refetchOnMount)}a(Ot,"shouldFetchOnMount");function $e(t,e,r){if(I(e.enabled,t)!==!1&&x(e.staleTime,t)!=="static"){let s=typeof r=="function"?r(t):r;return s==="always"||s!==!1&&ze(t,e)}return!1}a($e,"shouldFetchOn");function Rt(t,e,r,s){return(t!==e||I(s.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&ze(t,r)}a(Rt,"shouldFetchOptionally");function ze(t,e){return I(e.enabled,t)!==!1&&t.isStaleByTime(x(e.staleTime,t))}a(ze,"isStale");function kr(t,e){return!ve(t.getCurrentResult(),e)}a(kr,"shouldAssignObserverCurrentProperties");var Pt=class extends ke{static{a(this,"Mutation")}#e;#t;#r;#s;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#r=t.mutationCache,this.#t=[],this.state=t.state||Ir(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#r.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#r.remove(this))}continue(){return this.#s?.continue()??this.execute(this.state.variables)}async execute(t){let e=a(()=>{this.#n({type:"continue"})},"onContinue"),r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#s=Ce({fn:a(()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),"fn"),onFail:a((n,o)=>{this.#n({type:"failed",failureCount:n,error:o})},"onFail"),onPause:a(()=>{this.#n({type:"pause"})},"onPause"),onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:a(()=>this.#r.canRun(this),"canRun")});let s=this.state.status==="pending",i=!this.#s.canStart();try{if(s)e();else{this.#n({type:"pending",variables:t,isPaused:i}),this.#r.config.onMutate&&await this.#r.config.onMutate(t,this,r);let o=await this.options.onMutate?.(t,r);o!==this.state.context&&this.#n({type:"pending",context:o,variables:t,isPaused:i})}let n=await this.#s.start();return await this.#r.config.onSuccess?.(n,t,this.state.context,this,r),await this.options.onSuccess?.(n,t,this.state.context,r),await this.#r.config.onSettled?.(n,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(n,null,t,this.state.context,r),this.#n({type:"success",data:n}),n}catch(n){try{await this.#r.config.onError?.(n,t,this.state.context,this,r)}catch(o){Promise.reject(o)}try{await this.options.onError?.(n,t,this.state.context,r)}catch(o){Promise.reject(o)}try{await this.#r.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this,r)}catch(o){Promise.reject(o)}try{await this.options.onSettled?.(void 0,n,t,this.state.context,r)}catch(o){Promise.reject(o)}throw this.#n({type:"error",error:n}),n}finally{this.#r.runNext(this)}}#n(t){let e=a(r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}},"reducer");this.state=e(this.state),v.batch(()=>{this.#t.forEach(r=>{r.onMutationUpdate(t)}),this.#r.notify({mutation:this,type:"updated",action:t})})}};function Ir(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}a(Ir,"getDefaultState");var At=class extends L{static{a(this,"MutationCache")}constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(t,e,r){let s=new Pt({client:t,mutationCache:this,mutationId:++this.#r,options:t.defaultMutationOptions(e),state:r});return this.add(s),s}add(t){this.#e.add(t);let e=Ie(t);if(typeof e=="string"){let r=this.#t.get(e);r?r.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){let e=Ie(t);if(typeof e=="string"){let r=this.#t.get(e);if(r)if(r.length>1){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){let e=Ie(t);if(typeof e=="string"){let s=this.#t.get(e)?.find(i=>i.state.status==="pending");return!s||s===t}else return!0}runNext(t){let e=Ie(t);return typeof e=="string"?this.#t.get(e)?.find(s=>s!==t&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){v.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){let e={exact:!0,...t};return this.getAll().find(r=>be(e,r))}findAll(t={}){return this.getAll().filter(e=>be(t,e))}notify(t){v.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){let t=this.getAll().filter(e=>e.state.isPaused);return v.batch(()=>Promise.all(t.map(e=>e.continue().catch(g))))}};function Ie(t){return t.options.scope?.id}a(Ie,"scopeFor");var Ft=class extends L{static{a(this,"QueryCache")}constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,r){let s=e.queryKey,i=e.queryHash??ne(s,e),n=this.get(i);return n||(n=new Tt({client:t,queryKey:s,queryHash:i,options:t.defaultQueryOptions(e),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(n)),n}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){let e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){v.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){let e={exact:!0,...t};return this.getAll().find(r=>ye(e,r))}findAll(t={}){let e=this.getAll();return Object.keys(t).length>0?e.filter(r=>ye(t,r)):e}notify(t){v.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){v.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){v.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}};var We=class{static{a(this,"QueryClient")}#e;#t;#r;#s;#n;#i;#o;#a;constructor(t={}){this.#e=t.queryCache||new Ft,this.#t=t.mutationCache||new At,this.#r=t.defaultOptions||{},this.#s=new Map,this.#n=new Map,this.#i=0}mount(){this.#i++,this.#i===1&&(this.#o=X.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=Z.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#i--,this.#i===0&&(this.#o?.(),this.#o=void 0,this.#a?.(),this.#a=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){let e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){let e=this.defaultQueryOptions(t),r=this.#e.build(this,e),s=r.state.data;return s===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(x(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(s))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:r})=>{let s=r.data;return[e,s]})}setQueryData(t,e,r){let s=this.defaultQueryOptions({queryKey:t}),n=this.#e.get(s.queryHash)?.state.data,o=yt(e,n);if(o!==void 0)return this.#e.build(this,s).setData(o,{...r,manual:!0})}setQueriesData(t,e,r){return v.batch(()=>this.#e.findAll(t).map(({queryKey:s})=>[s,this.setQueryData(s,e,r)]))}getQueryState(t){let e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){let e=this.#e;v.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){let r=this.#e;return v.batch(()=>(r.findAll(t).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){let r={revert:!0,...e},s=v.batch(()=>this.#e.findAll(t).map(i=>i.cancel(r)));return Promise.all(s).then(g).catch(g)}invalidateQueries(t,e={}){return v.batch(()=>(this.#e.findAll(t).forEach(r=>{r.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){let r={...e,cancelRefetch:e.cancelRefetch??!0},s=v.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let n=i.fetch(void 0,r);return r.throwOnError||(n=n.catch(g)),i.state.fetchStatus==="paused"?Promise.resolve():n}));return Promise.all(s).then(g)}fetchQuery(t){let e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);let r=this.#e.build(this,e);return r.isStaleByTime(x(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(g).catch(g)}fetchInfiniteQuery(t){return t._type="infinite",this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(g).catch(g)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return Z.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(t){this.#r=t}setQueryDefaults(t,e){this.#s.set(H(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){let e=[...this.#s.values()],r={};return e.forEach(s=>{N(t,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(t,e){this.#n.set(H(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){let e=[...this.#n.values()],r={};return e.forEach(s=>{N(t,s.mutationKey)&&Object.assign(r,s.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;let e={...this.#r.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=ne(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Y&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#r.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};var B=P($(),1);var ee=P($(),1),Mt=P(Ue(),1);var ce=ee.createContext(void 0),Ve=a(t=>{let e=ee.useContext(ce);if(t)return t;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},"useQueryClient"),Ge=a(({client:t,children:e})=>(ee.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),(0,Mt.jsx)(ce.Provider,{value:t,children:e})),"QueryClientProvider");var ue=P($(),1),Er=P(Ue(),1);function Tr(){let t=!1;return{clearReset:a(()=>{t=!1},"clearReset"),reset:a(()=>{t=!0},"reset"),isReset:a(()=>t,"isReset")}}a(Tr,"createValue");var Or=ue.createContext(Tr()),xt=a(()=>ue.useContext(Or),"useQueryErrorResetBoundary");var _t=P($(),1);var Lt=a((t,e,r)=>{let s=r?.state.error&&typeof t.throwOnError=="function"?Se(t.throwOnError,[r.state.error,r]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||s)&&(e.isReset()||(t.retryOnMount=!1))},"ensurePreventErrorBoundaryRetry"),Qt=a(t=>{_t.useEffect(()=>{t.clearReset()},[t])},"useClearResetErrorBoundary"),Dt=a(({result:t,errorResetBoundary:e,throwOnError:r,query:s,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&s&&(i&&t.data===void 0||Se(r,[t.error,s])),"getHasError");var Ee=P($(),1);var Ut=Ee.createContext(!1),qt=a(()=>Ee.useContext(Ut),"useIsRestoring"),Ra=Ut.Provider;var Nt=a(t=>{if(t.suspense){let r=a(i=>i==="static"?i:Math.max(i??1e3,1e3),"clamp"),s=t.staleTime;t.staleTime=typeof s=="function"?(...i)=>r(s(...i)):r(s),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},"ensureSuspenseTimers"),Bt=a((t,e)=>t.isLoading&&t.isFetching&&!e,"willFetch"),Kt=a((t,e)=>t?.suspense&&e.isPending,"shouldSuspend"),Je=a((t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()}),"fetchOptimistic");function jt(t,e,r){let s=qt(),i=xt(),n=Ve(r),o=n.defaultQueryOptions(t);n.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let c=n.getQueryCache().get(o.queryHash),u=t.subscribed!==!1;o._optimisticResults=s?"isRestoring":u?"optimistic":void 0,Nt(o),Lt(o,i,c),Qt(i);let d=!n.getQueryCache().get(o.queryHash),[h]=B.useState(()=>new e(n,o)),l=h.getOptimisticResult(o),f=!s&&u;if(B.useSyncExternalStore(B.useCallback(m=>{let y=f?h.subscribe(v.batchCalls(m)):g;return h.updateResult(),y},[h,f]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),B.useEffect(()=>{h.setOptions(o)},[o,h]),Kt(o,l))throw Je(o,h,i);if(Dt({result:l,errorResetBoundary:i,throwOnError:o.throwOnError,query:c,suspense:o.suspense}))throw l.error;return n.getDefaultOptions().queries?._experimental_afterQuery?.(o,l),o.experimental_prefetchInRender&&!D.isServer()&&Bt(l,s)&&(d?Je(o,h,i):c?.promise)?.catch(g).finally(()=>{h.updateResult()}),o.notifyOnChangeProps?l:h.trackResult(l)}a(jt,"useBaseQuery");function Rr(t,e){return jt(t,He,e)}a(Rr,"useQuery");var $t=P(lt(),1);var z=P($(),1),Xe=P(Ue(),1);var Ht=(0,z.createContext)(null),Pr=a(()=>new We({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),"v"),Ar=a(t=>{let e=(0,$t.c)(9),{children:r,client:s,queryClient:i}=t,n=(0,z.use)(ce),o;e[0]!==n||e[1]!==i?(o=a(()=>i??n??Pr(),"o"),e[0]=n,e[1]=i,e[2]=o):o=e[2];let[c]=(0,z.useState)(o),u=i??n??c,d;e[3]!==r||e[4]!==s?(d=(0,Xe.jsx)(Ht,{value:s,children:r}),e[3]=r,e[4]=s,e[5]=d):d=e[5];let h=d;if(n===u)return h;let l;return e[6]!==h||e[7]!==u?(l=(0,Xe.jsx)(Ge,{client:u,children:h}),e[6]=h,e[7]=u,e[8]=l):l=e[8],l},"b"),Ye=a(()=>{let t=(0,z.use)(Ht);if(!t)throw new p("INTERNAL","useLunora must be used inside <LunoraProvider />");return t},"q");var zt=a(()=>{let t=null;return{get:a(()=>t,"get"),set:a(e=>{t=e},"set")}},"l");var Te=class{static{a(this,"u")}values=new Map;subscribers=new Map;get(e){return this.values.has(e.key)?this.values.get(e.key):e.defaultValue}set(e,r){if(r===void 0){this.reset(e);return}this.values.set(e.key,r),this.notify(e.key,r)}reset(e){this.values.delete(e.key),this.notify(e.key,e.defaultValue)}subscribe(e,r){let s=this.subscribers.get(e.key);return s||(s=new Set,this.subscribers.set(e.key,s)),s.add(r),()=>{s.delete(r),s.size===0&&this.subscribers.delete(e.key)}}notify(e,r){let s=this.subscribers.get(e);if(s)for(let i of s)try{i(r)}catch{}}};var Wt=0,Fr="lunora-bridge",Mr=1e3,xr=3e3,Oe=class{static{a(this,"c")}bc;tabId;heartbeatInterval;leaderTimeout;knownLeader=void 0;leader=!1;running=!1;promotionPending=!1;lastHeartbeat=0;heartbeatTimer=void 0;leaderCheckTimer=void 0;onBecomeLeader;onStopBeingLeader;onConnectionStatus;onSubscriptionData;onSubscriptionError;onSubscriptionSettled;constructor(e={}){if(Wt+=1,this.tabId=`tab_${String(Wt)}_${crypto.randomUUID()}`,this.heartbeatInterval=e.heartbeatInterval??Mr,this.leaderTimeout=e.leaderTimeout??xr,this.onBecomeLeader=e.onBecomeLeader,this.onStopBeingLeader=e.onStopBeingLeader,this.onConnectionStatus=e.onConnectionStatus,this.onSubscriptionData=e.onSubscriptionData,this.onSubscriptionError=e.onSubscriptionError,this.onSubscriptionSettled=e.onSubscriptionSettled,typeof BroadcastChannel>"u"){this.bc=void 0;return}this.bc=new BroadcastChannel(e.channelName??Fr),this.bc.addEventListener("message",r=>{this.handleMessage(r.data)})}start(){if(!this.running){if(this.running=!0,this.bc===void 0){this.becomeLeader();return}this.broadcast({type:"claim-leadership",tabId:this.tabId,ts:Date.now()}),setTimeout(()=>{this.running&&this.knownLeader===void 0&&this.becomeLeader()},this.leaderTimeout),this.leaderCheckTimer=setInterval(()=>{this.checkLeaderHealth()},this.leaderTimeout),this.heartbeatTimer=setInterval(()=>{this.sendHeartbeat()},this.heartbeatInterval)}}stop(){this.running=!1,this.leader&&(this.broadcast({type:"yield-leadership",tabId:this.tabId}),this.leader=!1,this.knownLeader=void 0,this.onStopBeingLeader?.()),this.heartbeatTimer!==void 0&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0),this.leaderCheckTimer!==void 0&&(clearInterval(this.leaderCheckTimer),this.leaderCheckTimer=void 0),this.bc?.close()}isLeader(){return this.leader}promoteImmediately(){this.running&&this.becomeLeader()}get leaderTabId(){return this.knownLeader}get id(){return this.tabId}get isRunning(){return this.running}broadcastSubscriptionData(e,r,s,i,n){this.leader&&this.broadcast({type:"subscription-data",tabId:this.tabId,key:e,data:r,...s===void 0?{}:{cursor:s},...i===void 0?{}:{epoch:i},...n===void 0?{}:{identity:n}})}broadcastSubscriptionError(e,r){this.leader&&this.broadcast({type:"subscription-error",tabId:this.tabId,key:e,error:r})}broadcastSubscriptionSettled(e,r,s,i,n,o){this.leader&&this.broadcast({type:"subscription-settled",tabId:this.tabId,key:e,...r===void 0?{}:{cursor:r},...s===void 0?{}:{epoch:s},...i===void 0?{}:{lastMutationId:i},...n===void 0?{}:{clientId:n},...o===void 0?{}:{identity:o}})}broadcastConnectionStatus(e,r){this.leader&&this.broadcast({type:"connection-status",tabId:this.tabId,status:e,...r===void 0?{}:{identity:r}})}broadcast(e){this.bc?.postMessage(e)}handleMessage(e){switch(e.type){case"claim-leadership":{this.handleClaimLeadership(e);break}case"connection-status":{if(this.leader||e.tabId===this.tabId)break;this.onConnectionStatus?.(e.status,e.identity);break}case"heartbeat":{this.handleHeartbeat(e);break}case"subscription-data":{if(this.leader||e.tabId===this.tabId)break;this.onSubscriptionData?.(e.key,e.data,e.cursor,e.epoch,e.identity);break}case"subscription-error":{if(this.leader||e.tabId===this.tabId)break;this.onSubscriptionError?.(e.key,e.error);break}case"subscription-settled":{if(this.leader||e.tabId===this.tabId)break;this.onSubscriptionSettled?.(e.key,e.cursor,e.epoch,e.lastMutationId,e.clientId,e.identity);break}case"yield-leadership":{this.knownLeader===e.tabId&&(this.knownLeader=void 0,this.running&&!this.leader&&this.claimAndPromote());break}}}handleClaimLeadership(e){if(e.tabId!==this.tabId){if(this.leader){this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()});return}this.knownLeader===void 0&&e.tabId<this.tabId&&(this.knownLeader=e.tabId,this.lastHeartbeat=e.ts)}}handleHeartbeat(e){if(e.tabId!==this.tabId){if(this.leader){this.resolveLeaderVsLeaderTieBreak(e);return}this.lastHeartbeat=e.ts,this.knownLeader=e.tabId}}resolveLeaderVsLeaderTieBreak(e){e.tabId<this.tabId?(this.leader=!1,this.knownLeader=e.tabId,this.lastHeartbeat=e.ts,this.onStopBeingLeader?.()):this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()})}becomeLeader(){this.leader||(this.leader=!0,this.knownLeader=this.tabId,this.lastHeartbeat=Date.now(),this.onBecomeLeader?.(),this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()}))}sendHeartbeat(){this.leader&&this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()})}checkLeaderHealth(){if(!(!this.running||this.leader)){if(this.knownLeader===void 0){this.claimAndPromote();return}Date.now()-this.lastHeartbeat>this.leaderTimeout&&(this.knownLeader=void 0,this.claimAndPromote())}}claimAndPromote(){this.promotionPending||(this.promotionPending=!0,this.broadcast({type:"claim-leadership",tabId:this.tabId,ts:Date.now()}),setTimeout(()=>{this.promotionPending=!1,this.running&&this.knownLeader===void 0&&this.becomeLeader()},this.leaderTimeout))}};var Ze="_creationTime",_r=a(t=>{if(typeof t!="object"||t===null)return;let e=t._id;return typeof e=="string"?e:void 0},"p"),Lr=a(t=>{let e;for(let r of t){let s=r[Ze];if(typeof s=="number"){if(e!==void 0){if(s<e)return!0;if(s>e)return!1}e=s}}return!1},"a"),Qr=a((t,e)=>{let r=e[Ze];if(typeof r!="number")return t.length;let s=Lr(t);for(let[i,n]of t.entries()){let o=n[Ze];if(typeof o=="number"&&(s?o<r:o>r))return i}return t.length},"d"),Vt=a(t=>{if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.key=="string"&&typeof e.table=="string"&&(e.op==="insert"||e.op==="update"||e.op==="delete")},"y"),Gt=a((t,e)=>{if(!Array.isArray(t))return;let r=[];for(let u of t){if(_r(u)===void 0)return;r.push(u)}let{key:s,op:i,row:n}=e;if(i==="delete"){let u=r.filter(d=>d._id!==s);return u.length===r.length?[...r]:u}if(n===void 0)return;let o=r.findIndex(u=>u._id===s);if(o===-1){let u=[...r];return u.splice(Qr(r,n),0,n),u}let c=[...r];return c[o]=n,c},"g");var Dr=1024,Re=a(t=>{let e=t.maxBuffer??Dr,r=[],s=[],i=!1,n,o=!1,c=a(()=>{let h=s.shift();if(!h)return!1;if(n)return h.reject(n),!0;if(r.length>0){let l=r.shift();return h.resolve({done:!1,value:l}),!0}return i?(h.resolve({done:!0,value:void 0}),!0):(s.unshift(h),!1)},"n"),u={complete(){if(!(i||n))for(i=!0;c(););},fail(h){if(!(i||n))for(n=h,r.length=0;c(););},push(h){if(!(i||n||o)){if(r.length>=e){u.fail(new p("STREAM_BACKPRESSURE",`stream buffer overflow (max=${e.toString()}); the consumer cannot keep up with the producer`));return}r.push(h),c()}}},d=a(()=>{if(!o){o=!0,i=!0,r.length=0;try{t.onCancel()}catch{}for(;c(););}},"c");return{handle:u,iterable:{cancel:d,[Symbol.asyncIterator](){return{next(){if(n)return Promise.reject(n);if(r.length>0){let h=r.shift();return Promise.resolve({done:!1,value:h})}return i?Promise.resolve({done:!0,value:void 0}):new Promise((h,l)=>{s.push({reject:l,resolve:h})})},return(){return d(),Promise.resolve({done:!0,value:void 0})}}}}}},"d");var Jt=/^ /u,Xt=a(t=>typeof t=="object"&&t!==null?JSON.stringify(t):String(t),"u"),Ur=a(t=>{let e="",r=[];for(let s of t.split(`
|
|
1
|
+
import{c as p}from"./chunk-X7B6PLEW.js";import{a,e as P,f as $,g as lt,h as Ue}from"./chunk-3XIESWL4.js";var L=class{static{a(this,"Subscribable")}constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var fr=class extends L{static{a(this,"FocusManager")}#e;#t;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=a(()=>t(),"listener");return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#r=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){let t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},X=new fr;var pr={setTimeout:a((t,e)=>setTimeout(t,e),"setTimeout"),clearTimeout:a(t=>clearTimeout(t),"clearTimeout"),setInterval:a((t,e)=>setInterval(t,e),"setInterval"),clearInterval:a(t=>clearInterval(t),"clearInterval")},mr=class{static{a(this,"TimeoutManager")}#e=pr;#t=!1;setTimeoutProvider(t){this.#e=t}setTimeout(t,e){return this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},Q=new mr;function ft(t){setTimeout(t,0)}a(ft,"systemSetTimeoutZero");var Ne=typeof window>"u"||"Deno"in globalThis;function g(){}a(g,"noop");function yt(t,e){return typeof t=="function"?t(e):t}a(yt,"functionalUpdate");function ie(t){return typeof t=="number"&&t>=0&&t!==1/0}a(ie,"isValidTimeout");function me(t,e){return Math.max(t+(e||0)-Date.now(),0)}a(me,"timeUntilStale");function x(t,e){return typeof t=="function"?t(e):t}a(x,"resolveStaleTime");function I(t,e){return typeof t=="function"?t(e):t}a(I,"resolveQueryBoolean");function ye(t,e){let{type:r="all",exact:s,fetchStatus:i,predicate:n,queryKey:o,stale:c}=t;if(o){if(s){if(e.queryHash!==ne(o,e.options))return!1}else if(!N(e.queryKey,o))return!1}if(r!=="all"){let u=e.isActive();if(r==="active"&&!u||r==="inactive"&&u)return!1}return!(typeof c=="boolean"&&e.isStale()!==c||i&&i!==e.state.fetchStatus||n&&!n(e))}a(ye,"matchQuery");function be(t,e){let{exact:r,status:s,predicate:i,mutationKey:n}=t;if(n){if(!e.options.mutationKey)return!1;if(r){if(H(e.options.mutationKey)!==H(n))return!1}else if(!N(e.options.mutationKey,n))return!1}return!(s&&e.state.status!==s||i&&!i(e))}a(be,"matchMutation");function ne(t,e){return(e?.queryKeyHashFn||H)(t)}a(ne,"hashQueryKeyByOptions");function H(t){return JSON.stringify(t,(e,r)=>qe(r)?Object.keys(r).sort().reduce((s,i)=>(s[i]=r[i],s),{}):r)}a(H,"hashKey");function N(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(Array.isArray(t)&&Array.isArray(e)){for(let s=0;s<e.length;s++)if(!N(t[s],e[s]))return!1;return!0}let r=Object.keys(e);for(let s of r)if(!N(t[s],e[s]))return!1;return!0}return!1}a(N,"partialMatchKey");var yr=Object.prototype.hasOwnProperty;function Be(t,e,r=0){if(t===e)return t;if(r>500)return e;let s=pt(t)&&pt(e);if(!s&&!(qe(t)&&qe(e)))return e;let n=(s?t:Object.keys(t)).length,o=s?e:Object.keys(e),c=o.length,u=s?new Array(c):{},d=0;for(let h=0;h<c;h++){let l=s?h:o[h],f=t[l],m=e[l];if(f===m){u[l]=f,(s?h<n:yr.call(t,l))&&d++;continue}if(f===null||m===null||typeof f!="object"||typeof m!="object"){u[l]=m;continue}let y=Be(f,m,r+1);u[l]=y,y===f&&d++}return n===c&&d===n?t:u}a(Be,"replaceEqualDeep");function ve(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(let r in t)if(t[r]!==e[r])return!1;return!0}a(ve,"shallowEqualObjects");function pt(t){return Array.isArray(t)&&t.length===Object.keys(t).length}a(pt,"isPlainArray");function qe(t){if(!mt(t))return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(!mt(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}a(qe,"isPlainObject");function mt(t){return Object.prototype.toString.call(t)==="[object Object]"}a(mt,"hasObjectPrototype");function bt(t){return new Promise(e=>{Q.setTimeout(e,t)})}a(bt,"sleep");function ae(t,e,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,e):r.structuralSharing!==!1?Be(t,e):e}a(ae,"replaceData");function br(t){return t}a(br,"keepPreviousData");function vt(t,e,r=0){let s=[...t,e];return r&&s.length>r?s.slice(1):s}a(vt,"addToEnd");function gt(t,e,r=0){let s=[e,...t];return r&&s.length>r?s.slice(0,-1):s}a(gt,"addToStart");var Y=Symbol();function ge(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===Y?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}a(ge,"ensureQueryFn");function Se(t,e){return typeof t=="function"?t(...e):!!t}a(Se,"shouldThrowError");function St(t,e,r){let s=!1,i;return Object.defineProperty(t,"signal",{enumerable:!0,get:a(()=>(i??=e(),s||(s=!0,i.aborted?r():i.addEventListener("abort",r,{once:!0})),i),"get")}),t}a(St,"addConsumeAwareSignal");var D=(()=>{let t=a(()=>Ne,"isServerFn");return{isServer(){return t()},setIsServer(e){t=e}}})();function oe(){let t,e,r=new Promise((i,n)=>{t=i,e=n});r.status="pending",r.catch(()=>{});function s(i){Object.assign(r,i),delete r.resolve,delete r.reject}return a(s,"finalize"),r.resolve=i=>{s({status:"fulfilled",value:i}),t(i)},r.reject=i=>{s({status:"rejected",reason:i}),e(i)},r}a(oe,"pendingThenable");var wt=ft;function vr(){let t=[],e=0,r=a(c=>{c()},"notifyFn"),s=a(c=>{c()},"batchNotifyFn"),i=wt,n=a(c=>{e?t.push(c):i(()=>{r(c)})},"schedule"),o=a(()=>{let c=t;t=[],c.length&&i(()=>{s(()=>{c.forEach(u=>{r(u)})})})},"flush");return{batch:a(c=>{let u;e++;try{u=c()}finally{e--,e||o()}return u},"batch"),batchCalls:a(c=>(...u)=>{n(()=>{c(...u)})},"batchCalls"),schedule:n,setNotifyFunction:a(c=>{r=c},"setNotifyFunction"),setBatchNotifyFunction:a(c=>{s=c},"setBatchNotifyFunction"),setScheduler:a(c=>{i=c},"setScheduler")}}a(vr,"createNotifyManager");var v=vr();var gr=class extends L{static{a(this,"OnlineManager")}#e=!0;#t;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=a(()=>t(!0),"onlineListener"),r=a(()=>t(!1),"offlineListener");return window.addEventListener("online",e,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#r=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(r=>{r(t)}))}isOnline(){return this.#e}},Z=new gr;function Sr(t){return Math.min(1e3*2**t,3e4)}a(Sr,"defaultRetryDelay");function Ke(t){return(t??"online")==="online"?Z.isOnline():!0}a(Ke,"canFetch");var we=class extends Error{static{a(this,"CancelledError")}constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Ce(t){let e=!1,r=0,s,i=oe(),n=a(()=>i.status!=="pending","isResolved"),o=a(b=>{if(!n()){let w=new we(b);f(w),t.onCancel?.(w)}},"cancel"),c=a(()=>{e=!0},"cancelRetry"),u=a(()=>{e=!1},"continueRetry"),d=a(()=>X.isFocused()&&(t.networkMode==="always"||Z.isOnline())&&t.canRun(),"canContinue"),h=a(()=>Ke(t.networkMode)&&t.canRun(),"canStart"),l=a(b=>{n()||(s?.(),i.resolve(b))},"resolve"),f=a(b=>{n()||(s?.(),i.reject(b))},"reject"),m=a(()=>new Promise(b=>{s=a(w=>{(n()||d())&&b(w)},"continueFn"),t.onPause?.()}).then(()=>{s=void 0,n()||t.onContinue?.()}),"pause"),y=a(()=>{if(n())return;let b,w=r===0?t.initialPromise:void 0;try{b=w??t.fn()}catch(E){b=Promise.reject(E)}Promise.resolve(b).then(l).catch(E=>{if(n())return;let M=t.retry??(D.isServer()?0:3),U=t.retryDelay??Sr,K=typeof U=="function"?U(r,E):U,j=M===!0||typeof M=="number"&&r<M||typeof M=="function"&&M(r,E);if(e||!j){f(E);return}r++,t.onFail?.(r,E),bt(K).then(()=>d()?void 0:m()).then(()=>{e?f(E):y()})})},"run");return{promise:i,status:a(()=>i.status,"status"),cancel:o,continue:a(()=>(s?.(),i),"continue"),cancelRetry:c,continueRetry:u,canStart:h,start:a(()=>(h()?y():m().then(y),i),"start")}}a(Ce,"createRetryer");var ke=class{static{a(this,"Removable")}#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ie(this.gcTime)&&(this.#e=Q.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(D.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(Q.clearTimeout(this.#e),this.#e=void 0)}};function kt(t){return{onFetch:a((e,r)=>{let s=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,n=e.state.data?.pages||[],o=e.state.data?.pageParams||[],c={pages:[],pageParams:[]},u=0,d=a(async()=>{let h=!1,l=a(y=>{St(y,()=>e.signal,()=>h=!0)},"addSignalProperty"),f=ge(e.options,e.fetchOptions),m=a(async(y,b,w)=>{if(h)return Promise.reject(e.signal.reason);if(b==null&&y.pages.length)return Promise.resolve(y);let M=a(()=>{let De={client:e.client,queryKey:e.queryKey,pageParam:b,direction:w?"backward":"forward",meta:e.options.meta};return l(De),De},"createQueryFnContext")(),U=await f(M),{maxPages:K}=e.options,j=w?gt:vt;return{pages:j(y.pages,U,K),pageParams:j(y.pageParams,b,K)}},"fetchPage");if(i&&n.length){let y=i==="backward",b=y?wr:Ct,w={pages:n,pageParams:o},E=b(s,w);c=await m(w,E,y)}else{let y=t??n.length;do{let b=u===0?o[0]??s.initialPageParam:Ct(s,c);if(u>0&&b==null)break;c=await m(c,b),u++}while(u<y)}return c},"fetchFn");e.options.persister?e.fetchFn=()=>e.options.persister?.(d,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r):e.fetchFn=d},"onFetch")}}a(kt,"infiniteQueryBehavior");function Ct(t,{pages:e,pageParams:r}){let s=e.length-1;return e.length>0?t.getNextPageParam(e[s],e,r[s],r):void 0}a(Ct,"getNextPageParam");function wr(t,{pages:e,pageParams:r}){return e.length>0?t.getPreviousPageParam?.(e[0],e,r[0],r):void 0}a(wr,"getPreviousPageParam");var Tt=class extends ke{static{a(this,"Query")}#e;#t;#r;#s;#n;#i;#o;#a;constructor(t){super(),this.#a=!1,this.#o=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#n=t.client,this.#s=this.#n.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#t=Et(this.options),this.state=t.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#i?.promise}setOptions(t){if(this.options={...this.#o,...t},t?._type&&(this.#e=t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Et(this.options);e.data!==void 0&&(this.setState(It(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(t,e){let r=ae(this.state.data,t,this.options);return this.#c({data:r,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),r}setState(t){this.#c({type:"setState",state:t})}cancel(t){let e=this.#i?.promise;return this.#i?.cancel(t),e?e.then(g).catch(g):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>I(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Y||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>x(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!me(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#i&&(this.#a||this.#h()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}#h(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#c({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#i?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(t&&this.setOptions(t),!this.options.queryFn){let u=this.observers.find(d=>d.options.queryFn);u&&this.setOptions(u.options)}let r=new AbortController,s=a(u=>{Object.defineProperty(u,"signal",{enumerable:!0,get:a(()=>(this.#a=!0,r.signal),"get")})},"addSignalProperty"),i=a(()=>{let u=ge(this.options,e),h=a(()=>{let l={client:this.#n,queryKey:this.queryKey,meta:this.meta};return s(l),l},"createQueryFnContext")();return this.#a=!1,this.options.persister?this.options.persister(u,h,this):u(h)},"fetchFn"),o=a(()=>{let u={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#n,state:this.state,fetchFn:i};return s(u),u},"createFetchContext")();(this.#e==="infinite"?kt(this.options.pages):this.options.behavior)?.onFetch(o,this),this.#r=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#c({type:"fetch",meta:o.fetchOptions?.meta}),this.#i=Ce({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:a(u=>{u instanceof we&&u.revert&&this.setState({...this.#r,fetchStatus:"idle"}),r.abort()},"onCancel"),onFail:a((u,d)=>{this.#c({type:"failed",failureCount:u,error:d})},"onFail"),onPause:a(()=>{this.#c({type:"pause"})},"onPause"),onContinue:a(()=>{this.#c({type:"continue"})},"onContinue"),retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:a(()=>!0,"canRun")});try{let u=await this.#i.start();if(u===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(u),this.#s.config.onSuccess?.(u,this),this.#s.config.onSettled?.(u,this.state.error,this),u}catch(u){if(u instanceof we){if(u.silent)return this.#i.promise;if(u.revert){if(this.state.data===void 0)throw u;return this.state.data}}throw this.#c({type:"error",error:u}),this.#s.config.onError?.(u,this),this.#s.config.onSettled?.(this.state.data,u,this),u}finally{this.scheduleGc()}}#c(t){let e=a(r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...je(r.data,this.options),fetchMeta:t.meta??null};case"success":let s={...r,...It(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#r=t.manual?s:void 0,s;case"error":let i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}},"reducer");this.state=e(this.state),v.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:t})})}};function je(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ke(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}a(je,"fetchState");function It(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}a(It,"successState");function Et(t){let e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,s=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}a(Et,"getDefaultState");var He=class extends L{static{a(this,"QueryObserver")}constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=oe(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#r=void 0;#s=void 0;#n;#i;#o;#a;#h;#c;#p;#d;#l;#u;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Ot(this.#t,this.options)?this.#f():this.updateResult(),this.#g())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return $e(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return $e(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#w(),this.#t.removeObserver(this)}setOptions(t){let e=this.options,r=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof I(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#C(),this.#t.setOptions(this.options),e._defaulted&&!ve(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});let s=this.hasListeners();s&&Rt(this.#t,r,this.options,e)&&this.#f(),this.updateResult(),s&&(this.#t!==r||I(this.options.enabled,this.#t)!==I(e.enabled,this.#t)||x(this.options.staleTime,this.#t)!==x(e.staleTime,this.#t))&&this.#y();let i=this.#b();s&&(this.#t!==r||I(this.options.enabled,this.#t)!==I(e.enabled,this.#t)||i!==this.#u)&&this.#v(i)}getOptimisticResult(t){let e=this.#e.getQueryCache().build(this.#e,t),r=this.createResult(e,t);return kr(this,r)&&(this.#s=r,this.#i=this.options,this.#n=this.#t.state),r}getCurrentResult(){return this.#s}trackResult(t,e){return new Proxy(t,{get:a((r,s)=>(this.trackProp(s),e?.(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s)),"get")})}trackProp(t){this.#m.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let e=this.#e.defaultQueryOptions(t),r=this.#e.getQueryCache().build(this.#e,e);return r.fetch().then(()=>this.createResult(r,e))}fetch(t){return this.#f({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#f(t){this.#C();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(g)),e}#y(){this.#S();let t=x(this.options.staleTime,this.#t);if(D.isServer()||this.#s.isStale||!ie(t))return;let r=me(this.#s.dataUpdatedAt,t)+1;this.#d=Q.setTimeout(()=>{this.#s.isStale||this.updateResult()},r)}#b(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(t){this.#w(),this.#u=t,!(D.isServer()||I(this.options.enabled,this.#t)===!1||!ie(this.#u)||this.#u===0)&&(this.#l=Q.setInterval(()=>{(this.options.refetchIntervalInBackground||X.isFocused())&&this.#f()},this.#u))}#g(){this.#y(),this.#v(this.#b())}#S(){this.#d!==void 0&&(Q.clearTimeout(this.#d),this.#d=void 0)}#w(){this.#l!==void 0&&(Q.clearInterval(this.#l),this.#l=void 0)}createResult(t,e){let r=this.#t,s=this.options,i=this.#s,n=this.#n,o=this.#i,u=t!==r?t.state:this.#r,{state:d}=t,h={...d},l=!1,f;if(e._optimisticResults){let R=this.hasListeners(),se=!R&&Ot(t,e),le=R&&Rt(t,r,e,s);(se||le)&&(h={...h,...je(d.data,t.options)}),e._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:m,errorUpdatedAt:y,status:b}=h;f=h.data;let w=!1;if(e.placeholderData!==void 0&&f===void 0&&b==="pending"){let R;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(R=i.data,w=!0):R=typeof e.placeholderData=="function"?e.placeholderData(this.#p?.state.data,this.#p):e.placeholderData,R!==void 0&&(b="success",f=ae(i?.data,R,e),l=!0)}if(e.select&&f!==void 0&&!w)if(i&&f===n?.data&&e.select===this.#h)f=this.#c;else try{this.#h=e.select,f=e.select(f),f=ae(i?.data,f,e),this.#c=f,this.#a=null}catch(R){this.#a=R}this.#a&&(m=this.#a,f=this.#c,y=Date.now(),b="error");let E=h.fetchStatus==="fetching",M=b==="pending",U=b==="error",K=M&&E,j=f!==void 0,q={status:b,fetchStatus:h.fetchStatus,isPending:M,isSuccess:b==="success",isError:U,isInitialLoading:K,isLoading:K,data:f,dataUpdatedAt:h.dataUpdatedAt,error:m,errorUpdatedAt:y,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:E,isRefetching:E&&!M,isLoadingError:U&&!j,isPaused:h.fetchStatus==="paused",isPlaceholderData:l,isRefetchError:U&&j,isStale:ze(t,e),refetch:this.refetch,promise:this.#o,isEnabled:I(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){let R=q.data!==void 0,se=q.status==="error"&&!R,le=a(pe=>{se?pe.reject(q.error):R&&pe.resolve(q.data)},"finalizeThenableIfPossible"),dt=a(()=>{let pe=this.#o=q.promise=oe();le(pe)},"recreateThenable"),fe=this.#o;switch(fe.status){case"pending":t.queryHash===r.queryHash&&le(fe);break;case"fulfilled":(se||q.data!==fe.value)&&dt();break;case"rejected":(!se||q.error!==fe.reason)&&dt();break}}return q}updateResult(){let t=this.#s,e=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#i=this.options,this.#n.data!==void 0&&(this.#p=this.#t),ve(e,t))return;this.#s=e;let r=a(()=>{if(!t)return!0;let{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!this.#m.size)return!0;let n=new Set(i??this.#m);return this.options.throwOnError&&n.add("error"),Object.keys(this.#s).some(o=>{let c=o;return this.#s[c]!==t[c]&&n.has(c)})},"shouldNotifyListeners");this.#k({listeners:r()})}#C(){let t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;let e=this.#t;this.#t=t,this.#r=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#g()}#k(t){v.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function Cr(t,e){return I(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&I(e.retryOnMount,t)===!1)}a(Cr,"shouldLoadOnMount");function Ot(t,e){return Cr(t,e)||t.state.data!==void 0&&$e(t,e,e.refetchOnMount)}a(Ot,"shouldFetchOnMount");function $e(t,e,r){if(I(e.enabled,t)!==!1&&x(e.staleTime,t)!=="static"){let s=typeof r=="function"?r(t):r;return s==="always"||s!==!1&&ze(t,e)}return!1}a($e,"shouldFetchOn");function Rt(t,e,r,s){return(t!==e||I(s.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&ze(t,r)}a(Rt,"shouldFetchOptionally");function ze(t,e){return I(e.enabled,t)!==!1&&t.isStaleByTime(x(e.staleTime,t))}a(ze,"isStale");function kr(t,e){return!ve(t.getCurrentResult(),e)}a(kr,"shouldAssignObserverCurrentProperties");var Pt=class extends ke{static{a(this,"Mutation")}#e;#t;#r;#s;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#r=t.mutationCache,this.#t=[],this.state=t.state||Ir(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#r.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#r.remove(this))}continue(){return this.#s?.continue()??this.execute(this.state.variables)}async execute(t){let e=a(()=>{this.#n({type:"continue"})},"onContinue"),r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#s=Ce({fn:a(()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),"fn"),onFail:a((n,o)=>{this.#n({type:"failed",failureCount:n,error:o})},"onFail"),onPause:a(()=>{this.#n({type:"pause"})},"onPause"),onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:a(()=>this.#r.canRun(this),"canRun")});let s=this.state.status==="pending",i=!this.#s.canStart();try{if(s)e();else{this.#n({type:"pending",variables:t,isPaused:i}),this.#r.config.onMutate&&await this.#r.config.onMutate(t,this,r);let o=await this.options.onMutate?.(t,r);o!==this.state.context&&this.#n({type:"pending",context:o,variables:t,isPaused:i})}let n=await this.#s.start();return await this.#r.config.onSuccess?.(n,t,this.state.context,this,r),await this.options.onSuccess?.(n,t,this.state.context,r),await this.#r.config.onSettled?.(n,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(n,null,t,this.state.context,r),this.#n({type:"success",data:n}),n}catch(n){try{await this.#r.config.onError?.(n,t,this.state.context,this,r)}catch(o){Promise.reject(o)}try{await this.options.onError?.(n,t,this.state.context,r)}catch(o){Promise.reject(o)}try{await this.#r.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this,r)}catch(o){Promise.reject(o)}try{await this.options.onSettled?.(void 0,n,t,this.state.context,r)}catch(o){Promise.reject(o)}throw this.#n({type:"error",error:n}),n}finally{this.#r.runNext(this)}}#n(t){let e=a(r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}},"reducer");this.state=e(this.state),v.batch(()=>{this.#t.forEach(r=>{r.onMutationUpdate(t)}),this.#r.notify({mutation:this,type:"updated",action:t})})}};function Ir(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}a(Ir,"getDefaultState");var At=class extends L{static{a(this,"MutationCache")}constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(t,e,r){let s=new Pt({client:t,mutationCache:this,mutationId:++this.#r,options:t.defaultMutationOptions(e),state:r});return this.add(s),s}add(t){this.#e.add(t);let e=Ie(t);if(typeof e=="string"){let r=this.#t.get(e);r?r.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){let e=Ie(t);if(typeof e=="string"){let r=this.#t.get(e);if(r)if(r.length>1){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){let e=Ie(t);if(typeof e=="string"){let s=this.#t.get(e)?.find(i=>i.state.status==="pending");return!s||s===t}else return!0}runNext(t){let e=Ie(t);return typeof e=="string"?this.#t.get(e)?.find(s=>s!==t&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){v.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){let e={exact:!0,...t};return this.getAll().find(r=>be(e,r))}findAll(t={}){return this.getAll().filter(e=>be(t,e))}notify(t){v.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){let t=this.getAll().filter(e=>e.state.isPaused);return v.batch(()=>Promise.all(t.map(e=>e.continue().catch(g))))}};function Ie(t){return t.options.scope?.id}a(Ie,"scopeFor");var Ft=class extends L{static{a(this,"QueryCache")}constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,r){let s=e.queryKey,i=e.queryHash??ne(s,e),n=this.get(i);return n||(n=new Tt({client:t,queryKey:s,queryHash:i,options:t.defaultQueryOptions(e),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(n)),n}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){let e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){v.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){let e={exact:!0,...t};return this.getAll().find(r=>ye(e,r))}findAll(t={}){let e=this.getAll();return Object.keys(t).length>0?e.filter(r=>ye(t,r)):e}notify(t){v.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){v.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){v.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}};var We=class{static{a(this,"QueryClient")}#e;#t;#r;#s;#n;#i;#o;#a;constructor(t={}){this.#e=t.queryCache||new Ft,this.#t=t.mutationCache||new At,this.#r=t.defaultOptions||{},this.#s=new Map,this.#n=new Map,this.#i=0}mount(){this.#i++,this.#i===1&&(this.#o=X.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=Z.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#i--,this.#i===0&&(this.#o?.(),this.#o=void 0,this.#a?.(),this.#a=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){let e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){let e=this.defaultQueryOptions(t),r=this.#e.build(this,e),s=r.state.data;return s===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(x(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(s))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:r})=>{let s=r.data;return[e,s]})}setQueryData(t,e,r){let s=this.defaultQueryOptions({queryKey:t}),n=this.#e.get(s.queryHash)?.state.data,o=yt(e,n);if(o!==void 0)return this.#e.build(this,s).setData(o,{...r,manual:!0})}setQueriesData(t,e,r){return v.batch(()=>this.#e.findAll(t).map(({queryKey:s})=>[s,this.setQueryData(s,e,r)]))}getQueryState(t){let e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){let e=this.#e;v.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){let r=this.#e;return v.batch(()=>(r.findAll(t).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){let r={revert:!0,...e},s=v.batch(()=>this.#e.findAll(t).map(i=>i.cancel(r)));return Promise.all(s).then(g).catch(g)}invalidateQueries(t,e={}){return v.batch(()=>(this.#e.findAll(t).forEach(r=>{r.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){let r={...e,cancelRefetch:e.cancelRefetch??!0},s=v.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let n=i.fetch(void 0,r);return r.throwOnError||(n=n.catch(g)),i.state.fetchStatus==="paused"?Promise.resolve():n}));return Promise.all(s).then(g)}fetchQuery(t){let e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);let r=this.#e.build(this,e);return r.isStaleByTime(x(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(g).catch(g)}fetchInfiniteQuery(t){return t._type="infinite",this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(g).catch(g)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return Z.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(t){this.#r=t}setQueryDefaults(t,e){this.#s.set(H(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){let e=[...this.#s.values()],r={};return e.forEach(s=>{N(t,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(t,e){this.#n.set(H(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){let e=[...this.#n.values()],r={};return e.forEach(s=>{N(t,s.mutationKey)&&Object.assign(r,s.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;let e={...this.#r.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=ne(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Y&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#r.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};var B=P($(),1);var ee=P($(),1),Mt=P(Ue(),1);var ce=ee.createContext(void 0),Ve=a(t=>{let e=ee.useContext(ce);if(t)return t;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},"useQueryClient"),Ge=a(({client:t,children:e})=>(ee.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),(0,Mt.jsx)(ce.Provider,{value:t,children:e})),"QueryClientProvider");var ue=P($(),1),Er=P(Ue(),1);function Tr(){let t=!1;return{clearReset:a(()=>{t=!1},"clearReset"),reset:a(()=>{t=!0},"reset"),isReset:a(()=>t,"isReset")}}a(Tr,"createValue");var Or=ue.createContext(Tr()),xt=a(()=>ue.useContext(Or),"useQueryErrorResetBoundary");var _t=P($(),1);var Lt=a((t,e,r)=>{let s=r?.state.error&&typeof t.throwOnError=="function"?Se(t.throwOnError,[r.state.error,r]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||s)&&(e.isReset()||(t.retryOnMount=!1))},"ensurePreventErrorBoundaryRetry"),Qt=a(t=>{_t.useEffect(()=>{t.clearReset()},[t])},"useClearResetErrorBoundary"),Dt=a(({result:t,errorResetBoundary:e,throwOnError:r,query:s,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&s&&(i&&t.data===void 0||Se(r,[t.error,s])),"getHasError");var Ee=P($(),1);var Ut=Ee.createContext(!1),qt=a(()=>Ee.useContext(Ut),"useIsRestoring"),Ra=Ut.Provider;var Nt=a(t=>{if(t.suspense){let r=a(i=>i==="static"?i:Math.max(i??1e3,1e3),"clamp"),s=t.staleTime;t.staleTime=typeof s=="function"?(...i)=>r(s(...i)):r(s),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},"ensureSuspenseTimers"),Bt=a((t,e)=>t.isLoading&&t.isFetching&&!e,"willFetch"),Kt=a((t,e)=>t?.suspense&&e.isPending,"shouldSuspend"),Je=a((t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()}),"fetchOptimistic");function jt(t,e,r){let s=qt(),i=xt(),n=Ve(r),o=n.defaultQueryOptions(t);n.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let c=n.getQueryCache().get(o.queryHash),u=t.subscribed!==!1;o._optimisticResults=s?"isRestoring":u?"optimistic":void 0,Nt(o),Lt(o,i,c),Qt(i);let d=!n.getQueryCache().get(o.queryHash),[h]=B.useState(()=>new e(n,o)),l=h.getOptimisticResult(o),f=!s&&u;if(B.useSyncExternalStore(B.useCallback(m=>{let y=f?h.subscribe(v.batchCalls(m)):g;return h.updateResult(),y},[h,f]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),B.useEffect(()=>{h.setOptions(o)},[o,h]),Kt(o,l))throw Je(o,h,i);if(Dt({result:l,errorResetBoundary:i,throwOnError:o.throwOnError,query:c,suspense:o.suspense}))throw l.error;return n.getDefaultOptions().queries?._experimental_afterQuery?.(o,l),o.experimental_prefetchInRender&&!D.isServer()&&Bt(l,s)&&(d?Je(o,h,i):c?.promise)?.catch(g).finally(()=>{h.updateResult()}),o.notifyOnChangeProps?l:h.trackResult(l)}a(jt,"useBaseQuery");function Rr(t,e){return jt(t,He,e)}a(Rr,"useQuery");var $t=P(lt(),1);var z=P($(),1),Xe=P(Ue(),1);var Ht=(0,z.createContext)(null),Pr=a(()=>new We({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),"v"),Ar=a(t=>{let e=(0,$t.c)(9),{children:r,client:s,queryClient:i}=t,n=(0,z.use)(ce),o;e[0]!==n||e[1]!==i?(o=a(()=>i??n??Pr(),"o"),e[0]=n,e[1]=i,e[2]=o):o=e[2];let[c]=(0,z.useState)(o),u=i??n??c,d;e[3]!==r||e[4]!==s?(d=(0,Xe.jsx)(Ht,{value:s,children:r}),e[3]=r,e[4]=s,e[5]=d):d=e[5];let h=d;if(n===u)return h;let l;return e[6]!==h||e[7]!==u?(l=(0,Xe.jsx)(Ge,{client:u,children:h}),e[6]=h,e[7]=u,e[8]=l):l=e[8],l},"b"),Ye=a(()=>{let t=(0,z.use)(Ht);if(!t)throw new p("INTERNAL","useLunora must be used inside <LunoraProvider />");return t},"q");var zt=a(()=>{let t=null;return{get:a(()=>t,"get"),set:a(e=>{t=e},"set")}},"l");var Te=class{static{a(this,"u")}values=new Map;subscribers=new Map;get(e){return this.values.has(e.key)?this.values.get(e.key):e.defaultValue}set(e,r){if(r===void 0){this.reset(e);return}this.values.set(e.key,r),this.notify(e.key,r)}reset(e){this.values.delete(e.key),this.notify(e.key,e.defaultValue)}subscribe(e,r){let s=this.subscribers.get(e.key);return s||(s=new Set,this.subscribers.set(e.key,s)),s.add(r),()=>{s.delete(r),s.size===0&&this.subscribers.delete(e.key)}}notify(e,r){let s=this.subscribers.get(e);if(s)for(let i of s)try{i(r)}catch{}}};var Wt=0,Fr="lunora-bridge",Mr=1e3,xr=3e3,Oe=class{static{a(this,"c")}bc;tabId;heartbeatInterval;leaderTimeout;knownLeader=void 0;leader=!1;running=!1;promotionPending=!1;lastHeartbeat=0;heartbeatTimer=void 0;leaderCheckTimer=void 0;onBecomeLeader;onStopBeingLeader;onConnectionStatus;onSubscriptionData;onSubscriptionError;onSubscriptionSettled;constructor(e={}){if(Wt+=1,this.tabId=`tab_${String(Wt)}_${crypto.randomUUID()}`,this.heartbeatInterval=e.heartbeatInterval??Mr,this.leaderTimeout=e.leaderTimeout??xr,this.onBecomeLeader=e.onBecomeLeader,this.onStopBeingLeader=e.onStopBeingLeader,this.onConnectionStatus=e.onConnectionStatus,this.onSubscriptionData=e.onSubscriptionData,this.onSubscriptionError=e.onSubscriptionError,this.onSubscriptionSettled=e.onSubscriptionSettled,typeof BroadcastChannel>"u"){this.bc=void 0;return}this.bc=new BroadcastChannel(e.channelName??Fr),this.bc.addEventListener("message",r=>{this.handleMessage(r.data)})}start(){if(!this.running){if(this.running=!0,this.bc===void 0){this.becomeLeader();return}this.broadcast({type:"claim-leadership",tabId:this.tabId,ts:Date.now()}),setTimeout(()=>{this.running&&this.knownLeader===void 0&&this.becomeLeader()},this.leaderTimeout),this.leaderCheckTimer=setInterval(()=>{this.checkLeaderHealth()},this.leaderTimeout),this.heartbeatTimer=setInterval(()=>{this.sendHeartbeat()},this.heartbeatInterval)}}stop(){this.running=!1,this.leader&&(this.broadcast({type:"yield-leadership",tabId:this.tabId}),this.leader=!1,this.knownLeader=void 0,this.onStopBeingLeader?.()),this.heartbeatTimer!==void 0&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0),this.leaderCheckTimer!==void 0&&(clearInterval(this.leaderCheckTimer),this.leaderCheckTimer=void 0),this.bc?.close()}isLeader(){return this.leader}promoteImmediately(){this.running&&this.becomeLeader()}get leaderTabId(){return this.knownLeader}get id(){return this.tabId}get isRunning(){return this.running}broadcastSubscriptionData(e,r,s,i,n){this.leader&&this.broadcast({type:"subscription-data",tabId:this.tabId,key:e,data:r,...s===void 0?{}:{cursor:s},...i===void 0?{}:{epoch:i},...n===void 0?{}:{identity:n}})}broadcastSubscriptionError(e,r){this.leader&&this.broadcast({type:"subscription-error",tabId:this.tabId,key:e,error:r})}broadcastSubscriptionSettled(e,r,s,i,n,o){this.leader&&this.broadcast({type:"subscription-settled",tabId:this.tabId,key:e,...r===void 0?{}:{cursor:r},...s===void 0?{}:{epoch:s},...i===void 0?{}:{lastMutationId:i},...n===void 0?{}:{clientId:n},...o===void 0?{}:{identity:o}})}broadcastConnectionStatus(e,r){this.leader&&this.broadcast({type:"connection-status",tabId:this.tabId,status:e,...r===void 0?{}:{identity:r}})}broadcast(e){this.bc?.postMessage(e)}handleMessage(e){switch(e.type){case"claim-leadership":{this.handleClaimLeadership(e);break}case"connection-status":{if(this.leader||e.tabId===this.tabId)break;this.onConnectionStatus?.(e.status,e.identity);break}case"heartbeat":{this.handleHeartbeat(e);break}case"subscription-data":{if(this.leader||e.tabId===this.tabId)break;this.onSubscriptionData?.(e.key,e.data,e.cursor,e.epoch,e.identity);break}case"subscription-error":{if(this.leader||e.tabId===this.tabId)break;this.onSubscriptionError?.(e.key,e.error);break}case"subscription-settled":{if(this.leader||e.tabId===this.tabId)break;this.onSubscriptionSettled?.(e.key,e.cursor,e.epoch,e.lastMutationId,e.clientId,e.identity);break}case"yield-leadership":{this.knownLeader===e.tabId&&(this.knownLeader=void 0,this.running&&!this.leader&&this.claimAndPromote());break}}}handleClaimLeadership(e){if(e.tabId!==this.tabId){if(this.leader){this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()});return}this.knownLeader===void 0&&e.tabId<this.tabId&&(this.knownLeader=e.tabId,this.lastHeartbeat=e.ts)}}handleHeartbeat(e){if(e.tabId!==this.tabId){if(this.leader){this.resolveLeaderVsLeaderTieBreak(e);return}this.lastHeartbeat=e.ts,this.knownLeader=e.tabId}}resolveLeaderVsLeaderTieBreak(e){e.tabId<this.tabId?(this.leader=!1,this.knownLeader=e.tabId,this.lastHeartbeat=e.ts,this.onStopBeingLeader?.()):this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()})}becomeLeader(){this.leader||(this.leader=!0,this.knownLeader=this.tabId,this.lastHeartbeat=Date.now(),this.onBecomeLeader?.(),this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()}))}sendHeartbeat(){this.leader&&this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()})}checkLeaderHealth(){if(!(!this.running||this.leader)){if(this.knownLeader===void 0){this.claimAndPromote();return}Date.now()-this.lastHeartbeat>this.leaderTimeout&&(this.knownLeader=void 0,this.claimAndPromote())}}claimAndPromote(){this.promotionPending||(this.promotionPending=!0,this.broadcast({type:"claim-leadership",tabId:this.tabId,ts:Date.now()}),setTimeout(()=>{this.promotionPending=!1,this.running&&this.knownLeader===void 0&&this.becomeLeader()},this.leaderTimeout))}};var Ze="_creationTime",_r=a(t=>{if(typeof t!="object"||t===null)return;let e=t._id;return typeof e=="string"?e:void 0},"p"),Lr=a(t=>{let e;for(let r of t){let s=r[Ze];if(typeof s=="number"){if(e!==void 0){if(s<e)return!0;if(s>e)return!1}e=s}}return!1},"a"),Qr=a((t,e)=>{let r=e[Ze];if(typeof r!="number")return t.length;let s=Lr(t);for(let[i,n]of t.entries()){let o=n[Ze];if(typeof o=="number"&&(s?o<r:o>r))return i}return t.length},"d"),Vt=a(t=>{if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.key=="string"&&typeof e.table=="string"&&(e.op==="insert"||e.op==="update"||e.op==="delete")},"y"),Gt=a((t,e)=>{if(!Array.isArray(t))return;let r=[];for(let u of t){if(_r(u)===void 0)return;r.push(u)}let{key:s,op:i,row:n}=e;if(i==="delete"){let u=r.filter(d=>d._id!==s);return u.length===r.length?[...r]:u}if(n===void 0)return;let o=r.findIndex(u=>u._id===s);if(o===-1){let u=[...r];return u.splice(Qr(r,n),0,n),u}let c=[...r];return c[o]=n,c},"g");var Dr=1024,Re=a(t=>{let e=t.maxBuffer??Dr,r=[],s=[],i=!1,n,o=!1,c=a(()=>{let h=s.shift();if(!h)return!1;if(n)return h.reject(n),!0;if(r.length>0){let l=r.shift();return h.resolve({done:!1,value:l}),!0}return i?(h.resolve({done:!0,value:void 0}),!0):(s.unshift(h),!1)},"n"),u={complete(){if(!(i||n))for(i=!0;c(););},fail(h){if(!(i||n))for(n=h,r.length=0;c(););},push(h){if(!(i||n||o)){if(r.length>=e){u.fail(new p("STREAM_BACKPRESSURE",`stream buffer overflow (max=${e.toString()}); the consumer cannot keep up with the producer`));return}r.push(h),c()}}},d=a(()=>{if(!o){o=!0,i=!0,r.length=0;try{t.onCancel()}catch{}for(;c(););}},"c");return{handle:u,iterable:{cancel:d,[Symbol.asyncIterator](){return{next(){if(n)return Promise.reject(n);if(r.length>0){let h=r.shift();return Promise.resolve({done:!1,value:h})}return i?Promise.resolve({done:!0,value:void 0}):new Promise((h,l)=>{s.push({reject:l,resolve:h})})},return(){return d(),Promise.resolve({done:!0,value:void 0})}}}}}},"d");var Jt=/^ /u,Xt=a(t=>typeof t=="object"&&t!==null?JSON.stringify(t):String(t),"u"),Ur=a(t=>{let e="",r=[];for(let s of t.split(`
|
|
2
2
|
`))s.startsWith("event:")?e=s.slice(6).replace(Jt,""):s.startsWith("data:")&&r.push(s.slice(5).replace(Jt,""));return{data:r.join(`
|
|
3
3
|
`),event:e}},"p"),qr=a((t,e,r)=>{let s=e.params??{},i=t.path.split("/").map(c=>{if(!c.startsWith(":"))return c;let u=c.slice(1),d=s[u];if(d===void 0)throw new p("HTTP_STREAM_MISSING_PARAM",`httpStream: missing path param ":${u}" for route ${t.path}`);return encodeURIComponent(Xt(d))}).join("/"),n=new URLSearchParams;for(let[c,u]of Object.entries(e.searchParams??{}))u!==void 0&&n.set(c,Xt(u));let o=n.toString();return`${r.endsWith("/")?r.slice(0,-1):r}${i}${o===""?"":`?${o}`}`},"S"),Nr=a((t,e)=>{if(t.event==="complete")return e.complete(),!0;if(t.event==="error"){let r={};try{r=JSON.parse(t.data)}catch{}let s=typeof r.message=="string"?r.message:"stream error",i=typeof r.code=="string"?r.code:"HTTP_STREAM_ERROR";return e.fail(new p(i,s)),!0}if((t.event===""||t.event==="message")&&t.data!=="")try{e.push(JSON.parse(t.data))}catch{return e.fail(new p("HTTP_STREAM_BAD_CHUNK","httpStream: malformed SSE chunk (invalid JSON)")),!0}return!1},"T"),Br=a(async(t,e)=>{let r=t.getReader(),s=new TextDecoder,i="",n=a(()=>{let o=i.indexOf(`
|
|
4
4
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as x}from"./chunk-K2E4OECF.js";import{b as h}from"./chunk-THIXMMZD.js";import{r as v}from"./chunk-IUYFXK4X.js";import{a as g,e as p,g as k,h as y}from"./chunk-3XIESWL4.js";var N=p(k(),1);var l=p(y(),1);var b={debug:"secondary",error:"destructive",fatal:"destructive",info:"outline",log:"outline",trace:"outline",warn:"secondary"},F=g(w=>{let e=(0,N.c)(21),{entry:t}=w,c;e[0]!==t.fields?(c=x(t.fields),e[0]=t.fields,e[1]=c):c=e[1];let m=c,s;e[2]!==t.timestamp?(s=v(t.timestamp),e[2]=t.timestamp,e[3]=s):s=e[3];let r;e[4]!==s?(r=(0,l.jsx)("span",{className:"w-44 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:s}),e[4]=s,e[5]=r):r=e[5];let u=b[t.level],a;e[6]!==t.level||e[7]!==u?(a=(0,l.jsx)("span",{className:"w-20 shrink-0",role:"gridcell",children:(0,l.jsx)(h,{variant:u,children:t.level})}),e[6]=t.level,e[7]=u,e[8]=a):a=e[8];let f=t.functionPath??"\u2014",n;e[9]!==f?(n=(0,l.jsx)("span",{className:"w-48 shrink-0 truncate text-muted-foreground",role:"gridcell",children:f}),e[9]=f,e[10]=n):n=e[10];let i;e[11]!==m?(i=m===""?null:(0,l.jsx)("span",{className:"ml-2 text-muted-foreground","data-testid":"lg-fields",children:m}),e[11]=m,e[12]=i):i=e[12];let o;e[13]!==t.message||e[14]!==i?(o=(0,l.jsxs)("span",{className:"flex-1 truncate",role:"gridcell",children:[t.message,i]}),e[13]=t.message,e[14]=i,e[15]=o):o=e[15];let d;return e[16]!==r||e[17]!==a||e[18]!==n||e[19]!==o?(d=(0,l.jsxs)(l.Fragment,{children:[r,a,n,o]}),e[16]=r,e[17]=a,e[18]=n,e[19]=o,e[20]=d):d=e[20],d},"A");export{b as a,F as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as x}from"./chunk-VDW32UET.js";import{c as C}from"./chunk-
|
|
1
|
+
import{a as x}from"./chunk-VDW32UET.js";import{c as C}from"./chunk-UP7OTXKF.js";import{f as q}from"./chunk-LYVP5PT6.js";import{d as k,f as g,g as y,m as S}from"./chunk-IUYFXK4X.js";import{a as f,e as w,f as L,g as F,h as O}from"./chunk-3XIESWL4.js";var v=w(L(),1);var j={},I=g(x.aiGenerateSql),T=g(x.aiTableFilter),A=g(x.aiChartConfig),R=f(s=>{let e=q(),[l,d]=(0,v.useState)({}),[n,r]=(0,v.useState)({}),a=C(x.aiAvailable,j,{shardKey:s}),[u,i]=(0,v.useState)(!1),b=u||a.data?.available===!1,p=f(t=>{d(o=>({...o,[t]:!0})),r(o=>({...o,[t]:void 0}))},"n"),h=f((t,o)=>{d(c=>({...c,[t]:!1})),o!==void 0&&r(c=>({...c,[t]:o})),o==="no-ai-binding"&&i(!0)},"t");return{generate:f(async(t,o)=>{p("sql");try{let{result:c}=await e.query(I,{failedError:o?.error,failedSql:o?.sql,prompt:t},y(s));return h("sql",c.degraded?c.reason:void 0),c.degraded?void 0:c.sql}catch{h("sql","ai-error");return}},"generate"),inferChart:f(async t=>{p("chart");try{let{result:o}=await e.query(A,t,y(s));return h("chart",o.degraded?o.reason:void 0),o.degraded?void 0:o.chart}catch{h("chart","ai-error");return}},"inferChart"),pending:f(t=>l[t]===!0,"pending"),reason:f(t=>n[t],"reason"),suggestFilter:f(async(t,o)=>{p("filter");try{let{result:c}=await e.query(T,{prompt:t,table:o},y(s));return h("filter",c.degraded?c.reason:void 0),c.degraded?void 0:c.clauses}catch{h("filter","ai-error");return}},"suggestFilter"),unavailable:b}},"k");var N=w(F(),1);var m=w(O(),1);var U=f((s,e)=>{if(e==="")return[{match:!1,offset:0,text:s}];let l=[],d=s.toLowerCase(),n=e.toLowerCase(),r=0;for(let a=d.indexOf(n);a!==-1;a=d.indexOf(n,r))a>r&&l.push({match:!1,offset:r,text:s.slice(r,a)}),l.push({match:!0,offset:a,text:s.slice(a,a+e.length)}),r=a+e.length;return r<s.length&&l.push({match:!1,offset:r,text:s.slice(r)}),l},"N"),z=f(s=>{let e=(0,N.c)(9),{highlight:l,value:d}=s;if(d==null){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,m.jsx)("span",{className:"text-muted-foreground/50 italic",children:"NULL"}),e[0]=i):i=e[0],i}let n,r,a;if(e[1]!==l||e[2]!==d){a=Symbol.for("react.early_return_sentinel");e:{let i=S(d);if(l===void 0||l===""){a=(0,m.jsx)("span",{title:i,children:i});break e}n=i,r=U(i,l).map(D)}e[1]=l,e[2]=d,e[3]=n,e[4]=r,e[5]=a}else n=e[3],r=e[4],a=e[5];if(a!==Symbol.for("react.early_return_sentinel"))return a;let u;return e[6]!==n||e[7]!==r?(u=(0,m.jsx)("span",{title:n,children:r}),e[6]=n,e[7]=r,e[8]=u):u=e[8],u},"v"),Q=f(s=>{let e=(0,N.c)(22),{columns:l,rows:d}=s,n=k(),r;e[0]!==n?(r=n("Field"),e[0]=n,e[1]=r):r=e[1];let a;e[2]!==r?(a=(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:r}),e[2]=r,e[3]=a):a=e[3];let u;if(e[4]!==d||e[5]!==n){let t;e[7]!==n?(t=f((o,c)=>(0,m.jsx)("th",{className:"border-b border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase tabular-nums text-muted-foreground",children:n("Row {n}",{n:c+1})},c),"i"),e[7]=n,e[8]=t):t=e[8],u=d.map(t),e[4]=d,e[5]=n,e[6]=u}else u=e[6];let i;e[9]!==a||e[10]!==u?(i=(0,m.jsx)("thead",{className:"sticky top-0 z-10 bg-muted",children:(0,m.jsxs)("tr",{children:[a,u]})}),e[9]=a,e[10]=u,e[11]=i):i=e[11];let b;if(e[12]!==l||e[13]!==d){let t;e[15]!==d?(t=f(o=>(0,m.jsxs)("tr",{className:"hover:bg-muted/40",children:[(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono font-medium whitespace-nowrap",scope:"row",children:o}),d.map((c,_)=>(0,m.jsx)("td",{className:"max-w-md truncate border-b border-border px-3 py-1.5 font-mono",children:(0,m.jsx)(z,{value:c[o]})},_))]},o),"i"),e[15]=d,e[16]=t):t=e[16],b=l.map(t),e[12]=l,e[13]=d,e[14]=b}else b=e[14];let p;e[17]!==b?(p=(0,m.jsx)("tbody",{children:b}),e[17]=b,e[18]=p):p=e[18];let h;return e[19]!==i||e[20]!==p?(h=(0,m.jsx)("div",{className:"min-h-0 flex-1 overflow-auto","data-testid":"db-transposed",children:(0,m.jsxs)("table",{className:"border-collapse text-xs",children:[i,p]})}),e[19]=i,e[20]=p,e[21]=h):h=e[21],h},"j"),V=f(({children:s,layout:e="card",testId:l})=>(0,m.jsx)("div",{className:e==="fill"?"flex min-h-0 flex-1 flex-col overflow-hidden border-t border-border":"overflow-x-auto border border-border bg-card","data-testid":l,children:s}),"O");function D(s){return(0,m.jsx)("mark",{className:s.match?"rounded-sm bg-warning/40 text-foreground":"bg-transparent text-inherit",children:s.text},s.offset)}f(D,"k");export{R as a,z as b,Q as c,V as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as l}from"./chunk-DJZYD5I5.js";import{j as u}from"./chunk-6ST5ECQA.js";import{a as c}from"./chunk-XBDKZZ67.js";import{a as t,e as o,f as h,h as z,j as d}from"./chunk-3XIESWL4.js";var p=o(h(),1);var a=p.forwardRef(t(function(e,r){let{render:n,className:k,disabled:s=!1,focusableWhenDisabled:g=!1,nativeButton:f=!0,style:B,...b}=e,{getButtonProps:m,buttonRef:x}=l({disabled:s,focusableWhenDisabled:g,native:f});return u("button",e,{state:{disabled:s},ref:[r,x],props:[b,m]})},"Button"));var v=o(z(),1);var y=c("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-xs font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",xs:"h-6 gap-1 rounded-md px-2 text-xs has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-md px-2.5 has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",icon:"size-8","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-md","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function W({className:i,variant:e="default",size:r="default",...n}){return(0,v.jsx)(a,{"data-slot":"button",className:d(y({variant:e,size:r,className:i})),...n})}t(W,"g");export{W as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ze}from"./chunk-
|
|
1
|
+
import{a as Ze}from"./chunk-GRRBUXEI.js";import{a as Je,b as Ve}from"./chunk-MRK53LUL.js";import{a as Xe}from"./chunk-WPK2Q33V.js";import"./chunk-GG6PIGQO.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import"./chunk-ESVP44Y3.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import{a as Ge}from"./chunk-FURI47Z2.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import"./chunk-ZMDNTTAC.js";import"./chunk-4UOFSGUS.js";import"./chunk-CZZWYUTR.js";import"./chunk-Y32QIKBS.js";import{a as Qe}from"./chunk-RMN2JN4S.js";import{b as Pe}from"./chunk-GRL5MG3Z.js";import{d as Ce,e as Oe,f as Me}from"./chunk-7T7UOTYK.js";import{R as Fe}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-MWIKAR7F.js";import"./chunk-DJZYD5I5.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as We}from"./chunk-XXQUMVWH.js";import{a as we}from"./chunk-VDW32UET.js";import"./chunk-UP7OTXKF.js";import{f as ke}from"./chunk-LYVP5PT6.js";import"./chunk-XBDKZZ67.js";import{a as He,b as je,c as Ke,d as De,e as Ye,f as Ue}from"./chunk-WJQLNYGX.js";import{d as oe,f as ve,g as ye,h as _e,o as ie}from"./chunk-IUYFXK4X.js";import"./chunk-X7B6PLEW.js";import{a as i,e as Ee,f as dt,g as ut,h as mt,j as ue}from"./chunk-3XIESWL4.js";var K=Ee(ut(),1);var P=Ee(dt(),1);var c=Ee(mt(),1);var ht=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],ft=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],Ie=String.fromCodePoint(0),pt=new RegExp(`${Ie}${String.raw`(\d+)`}${Ie}`,"gu"),bt=ht.map(l=>({pattern:new RegExp(String.raw`\b${l.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:l})),gt=ft.map(l=>({pattern:new RegExp(String.raw`\s+${l.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
|
|
2
2
|
${l}`})),xt=i(l=>{let e=[],t=l.replaceAll(/'(?:[^']|'')*'/gu,n=>(e.push(n),`${Ie}${(e.length-1).toString()}${Ie}`)).replaceAll(/\s+/gu," ").trim();for(let{pattern:n,replacement:r}of bt)t=t.replaceAll(n,r);for(let{pattern:n,replacement:r}of gt)t=t.replaceAll(n,r);return t=t.replaceAll(pt,(n,r)=>e[Number(r)]??""),t},"yt"),vt=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,yt=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|replace|truncate|update|vacuum)\b/iu,wt=/^\w+/u,St=/;\s*$/u,Nt=/\s/u,kt=i((l,e)=>{let t=e+2;for(;t<l.length&&l[t]!==`
|
|
3
3
|
`;)t+=1;return t},"$t"),Ct=i((l,e)=>{let t=l.indexOf("*/",e+2);return t===-1?-1:t+2},"qt"),qt=i(l=>{let e=0;for(;e<l.length;){let t=l[e];if(t!==void 0&&Nt.test(t))e+=1;else if(t==="-"&&l[e+1]==="-")e=kt(l,e);else if(t==="/"&&l[e+1]==="*"){let n=Ct(l,e);if(n===-1)break;e=n}else break}return e},"Tt"),Tt=i(l=>{let e=qt(l),t=l.slice(e).trimEnd();if(t==="")return{code:"SQL_EMPTY",message:"the query is empty"};let n=t.replace(St,""),r=n.indexOf(";");if(r!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+r};let o="the SQL editor is read-only \u2014 only SELECT / WITH / EXPLAIN queries are allowed";if(!vt.test(n))return{code:"SQL_NOT_READONLY",length:wt.exec(n)?.[0].length??1,message:o,offset:e};let s=yt.exec(n);if(s!==null)return{code:"SQL_NOT_READONLY",length:s[0].length,message:`${o} (\`${s[0].toUpperCase()}\` is not allowed)`,offset:e+s.index}},"Rt"),It=/\b(?:from|join)\s+([a-z_][\w$]*)(?:\s+(?:as\s+)?([a-z_][\w$]*))?/giu,Rt=/(?:\bwith\s+(?:recursive\s+)?|,\s*)([a-z_][\w$]*)\s+as\s*\(/giu,Lt=new Set(["cross","full","group","having","inner","join","left","limit","offset","on","order","right","union","using","where","window"]),Et=/[^\n]/gu,_t=i((l,e)=>{let t=l[e];if(t==="'"){let n=e+1;for(;n<l.length&&l[n]!=="'";)n+=1;return Math.min(n+1,l.length)}if(t==="-"&&l[e+1]==="-"){let n=l.indexOf(`
|
|
4
4
|
`,e);return n===-1?l.length:n}if(t==="/"&&l[e+1]==="*"){let n=l.indexOf("*/",e+2);return n===-1?l.length:n+2}return-1},"Ot"),Ot=i(l=>{let e="",t=0;for(;t<l.length;){let n=_t(l,t);n===-1?(e+=l.slice(t,t+1),t+=1):(e+=l.slice(t,n).replaceAll(Et," "),t=n)}return e},"Mt"),Mt=i(l=>{let e=new Set;for(let t of l.matchAll(Rt))e.add((t[1]??"").toLowerCase());return e},"Dt"),Dt=i((l,e)=>{let t=new Map;for(let n of l.matchAll(It)){let r=(n[1]??"").toLowerCase(),o=(n[2]??"").toLowerCase();e.has(r)&&(t.set(r,r),o!==""&&!Lt.has(o)&&t.set(o,r))}return t},"At"),ot=i((l,e)=>{let t=Ot(l),n=new Set(e.map(r=>r.toLowerCase()));return{ctes:Mt(t),masked:t,targets:Dt(t,n)}},"Ke"),At=/^(?:__lunora|sqlite_)/iu,$t=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,Bt=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,zt=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),Ft=i((l,e,t)=>{let n=[];for(let r of l.matchAll($t)){let o=r[1]??"",s=o.toLowerCase();!e.has(s)&&!t.has(s)&&!zt.has(s)&&!At.test(o)&&n.push({length:o.length,message:`unknown table \`${o}\``,offset:r.index+r[0].length-o.length,severity:"error",source:"schema"})}return n},"Ft"),Pt=i((l,e,t)=>{let n=[],r=new Map;for(let[o,s]of Object.entries(e.columns))r.set(o.toLowerCase(),new Set(s.map(m=>m.toLowerCase())));for(let o of l.matchAll(Bt)){let s=(o[1]??"").toLowerCase(),m=o[2]??"",a=t.get(s),d=a===void 0?void 0:r.get(a);d!==void 0&&!d.has(m.toLowerCase())&&n.push({length:m.length,message:`\`${a??""}\` has no column \`${m}\``,offset:o.index+o[0].length-m.length,severity:"error",source:"schema"})}return n},"Qt"),Qt=i((l,e)=>{if(l.trim()==="")return[];let t=Tt(l);if(t!==void 0)return t.code==="SQL_EMPTY"?[]:[{length:t.length,message:t.message,offset:t.offset,severity:"error",source:"gate"}];let{ctes:n,masked:r,targets:o}=ot(l,e.tables),s=new Set(e.tables.map(m=>m.toLowerCase()));return[...Ft(r,s,n),...Pt(r,e,o)]},"jt"),Wt=ve(we.lintSql),Ht=600,jt=i((l,e,t)=>{let n=ke(),[r,o]=(0,P.useState)([]),s=(0,P.useMemo)(()=>Qt(l,e),[l,e]),m=Ge(l,Ht),a=s.some(p=>p.source==="gate")||m.trim()==="",d=(0,P.useCallback)(async p=>{try{let b=await n.query(Wt,{sql:m},ye(t));p.cancelled||o(b.diagnostics??[])}catch{p.cancelled||o([])}},[n,m,t]);(0,P.useEffect)(()=>{if(a){o([]);return}let p={cancelled:!1};return ie(d(p)),()=>{p.cancelled=!0}},[d,a]);let f=m===l;return(0,P.useMemo)(()=>f?[...s,...r]:s,[s,r,f])},"Ut"),qe=8,Kt=["AND","ASC","AS","BY","COUNT","DESC","DISTINCT","EXPLAIN","FROM","GROUP","HAVING","INNER","JOIN","LEFT","LIKE","LIMIT","NOT","NULL","OFFSET","ON","ORDER","OR","QUERY","SELECT","WHERE","WITH"],Yt=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),Ut=/[\w$]/,rt=i(l=>l!==void 0&&Ut.test(l),"Ue"),lt=i(l=>{let e=l.length;for(;e>0&&rt(l[e-1]);)e-=1;return l.slice(e)},"Ye"),st=i((l,e)=>{let t=e;for(;t>0&&rt(l[t-1]);)t-=1;return{end:e,start:t,text:l.slice(t,e)}},"Je"),et=i((l,e)=>{let t=l.slice(0,e).trimEnd();return t.endsWith(".")||Yt.has(lt(t).toUpperCase())},"Pe"),Gt=i((l,e,t)=>{let n=l.slice(0,e);if(!n.endsWith("."))return;let r=lt(n.slice(0,-1));if(r!=="")return ot(l,t).targets.get(r.toLowerCase())??r},"Vt"),$e=i((l,e)=>l.toLowerCase().startsWith(e.toLowerCase()),"Me"),tt=i((l,e,t,n)=>{let r=[];for(let o of l)if($e(o,e)&&(r.push(n(o)),r.length>=t))break;return r},"Fe"),Jt=i((l,e,t)=>{let n=new Map;for(let[r,o]of Object.entries(l.columns))for(let s of o)if($e(s,e)&&!n.has(s)&&(n.set(s,r),n.size>=t))return[...n].map(([m,a])=>({detail:a,kind:"column",label:m}));return[...n].map(([r,o])=>({detail:o,kind:"column",label:r}))},"Xt"),Vt=i((l,e,t)=>{let n=st(l,e),r=Gt(l,n.start,t.tables);if(r!==void 0){let a=t.columns[r]??t.columns[r.toLowerCase()]??[];return tt(a,n.text,qe,d=>({detail:r,kind:"column",label:d}))}if(n.text===""&&!et(l,n.start))return[];let o=tt(t.tables,n.text,qe,a=>({kind:"table",label:a})),s=Jt(t,n.text,qe),m=Kt.flatMap(a=>n.text!==""&&$e(a,n.text)&&a.toLowerCase()!==n.text.toLowerCase()?[{kind:"keyword",label:a}]:[]);return(et(l,n.start)?[...s,...o,...m]:[...o,...s,...m]).slice(0,qe)},"Zt"),Xt=i((l,e,t)=>{let n=st(l,e),r=l.slice(0,n.start)+t.label+l.slice(n.end);return{caret:n.start+t.label.length,value:r}},"en"),Zt=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],en=i((l,e)=>{let t=globalThis.getComputedStyle(l),n=globalThis.document.createElement("div"),{style:r}=n;r.position="absolute",r.visibility="hidden",r.whiteSpace="pre-wrap",r.overflowWrap="break-word";for(let a of Zt)r[a]=t[a];n.textContent=l.value.slice(0,Math.max(0,e));let o=globalThis.document.createElement("span");o.textContent=l.value.slice(Math.max(0,e))||".",n.append(o),globalThis.document.body.append(n);let s=o.offsetLeft-l.scrollLeft,m=o.offsetTop-l.scrollTop;return n.remove(),{left:s,top:m}},"nn"),tn=i((l,e,t)=>{let n=(0,K.c)(16),[r,o]=(0,P.useState)(null),s;n[0]!==l||n[1]!==e?(s=i((w,g)=>{let h=Vt(w,g,l);if(h.length===0){o(null);return}let S=e.current,{left:k,top:N}=S===null?{left:0,top:0}:en(S,g);o(C=>C!==null&&C.active===0&&C.left===k&&C.top===N&&C.suggestions.length===h.length&&C.suggestions.every((L,R)=>{let E=h.at(R);return L.kind===E?.kind&&L.label===E.label&&L.detail===E.detail})?C:{active:0,left:k,suggestions:h,top:N})},"s"),n[0]=l,n[1]=e,n[2]=s):s=n[2];let m=s,a;n[3]===Symbol.for("react.memo_cache_sentinel")?(a=i(()=>{o(null)},"a"),n[3]=a):a=n[3];let d=a,f;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=i(w=>{o(g=>{if(g===null)return g;let h=g.suggestions.length,S=(g.active+w+h)%h;return{...g,active:S}})},"f"),n[4]=f):f=n[4];let p=f,b;n[5]!==t||n[6]!==r||n[7]!==e?(b=i(w=>{let g=e.current;if(r===null||g===null)return!1;let h=r.suggestions[w??r.active];if(h===void 0)return!1;let S=Xt(g.value,g.selectionStart,h);return t(S.value),o(null),requestAnimationFrame(()=>{let k=e.current;k!==null&&(k.focus(),k.setSelectionRange(S.caret,S.caret))}),!0},"p"),n[5]=t,n[6]=r,n[7]=e,n[8]=b):b=n[8];let v=b,u;n[9]!==v?(u=i(()=>v(),"c"),n[9]=v,n[10]=u):u=n[10];let x=u,y;return n[11]!==x||n[12]!==v||n[13]!==m||n[14]!==r?(y={close:d,commit:x,commitAt:v,move:p,refresh:m,state:r},n[11]=x,n[12]=v,n[13]=m,n[14]=r,n[15]=y):y=n[15],y},"on"),nn={column:"column",keyword:"keyword",table:"table"},on=20,rn=i(l=>{let e=(0,K.c)(17),{listboxId:t,onPick:n,state:r}=l,o=oe(),s;e[0]!==r?(s=r===null?void 0:{left:r.left,top:r.top+on},e[0]=r,e[1]=s):s=e[1];let m=s;if(r===null)return null;let a;if(e[2]!==t||e[3]!==n||e[4]!==r.active||e[5]!==r.suggestions||e[6]!==o){let f;e[8]!==t||e[9]!==n||e[10]!==r.active||e[11]!==o?(f=i((p,b)=>(0,c.jsxs)("li",{"aria-selected":b===r.active,className:ue("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",b===r.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${t}-opt-${b.toString()}`,onMouseDown:i(v=>{v.preventDefault(),n(b)},"onMouseDown"),role:"option",children:[(0,c.jsx)("span",{className:"truncate font-mono",children:p.label}),p.detail!==void 0&&(0,c.jsx)("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:p.detail}),(0,c.jsx)("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:o(nn[p.kind])})]},`${p.kind}:${p.label}`),"f"),e[8]=t,e[9]=n,e[10]=r.active,e[11]=o,e[12]=f):f=e[12],a=r.suggestions.map(f),e[2]=t,e[3]=n,e[4]=r.active,e[5]=r.suggestions,e[6]=o,e[7]=a}else a=e[7];let d;return e[13]!==t||e[14]!==m||e[15]!==a?(d=(0,c.jsx)("ul",{className:"absolute z-30 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-autocomplete",id:t,role:"listbox",style:m,children:a}),e[13]=t,e[14]=m,e[15]=a,e[16]=d):d=e[16],d},"sn"),ln=ve(we.listTables),sn=ve(we.readTablePage),an=i(l=>{let e=(0,K.c)(16),t=ke(),n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[0]=n):n=e[0];let[r,o]=(0,P.useState)(n),s;e[1]===Symbol.for("react.memo_cache_sentinel")?(s={},e[1]=s):s=e[1];let[m,a]=(0,P.useState)(s),d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,e[2]=d):d=e[2];let f=(0,P.useRef)(d),p,b;e[3]!==t||e[4]!==l?(p=i(()=>{let g={cancelled:!1};return ie((async()=>{try{let h=await t.query(ln,{},ye(l));g.cancelled||(o(h.map(dn)),a({}),f.current=new Set)}catch{g.cancelled||(o([]),a({}),f.current=new Set)}})()),()=>{g.cancelled=!0}},"h"),b=[t,l],e[3]=t,e[4]=l,e[5]=p,e[6]=b):(p=e[5],b=e[6]),(0,P.useEffect)(p,b);let v;e[7]!==t||e[8]!==l?(v=i(g=>{f.current.has(g)||(f.current.add(g),ie((async()=>{try{let h=await t.query(sn,{limit:1,offset:0,table:g},ye(l));a(S=>({...S,[g]:h.columns}))}catch{f.current.delete(g)}})()))},"x"),e[7]=t,e[8]=l,e[9]=v):v=e[9];let u=v,x;e[10]!==m||e[11]!==r?(x={columns:m,tables:r},e[10]=m,e[11]=r,e[12]=x):x=e[12];let y=x,w;return e[13]!==u||e[14]!==y?(w={probe:u,schema:y},e[13]=u,e[14]=y,e[15]=w):w=e[15],w},"dn"),Ae=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,cn=i(l=>{let e=new Set;Ae.lastIndex=0;let t=Ae.exec(l);for(;t!==null;)e.add(t[1]??t[2]),t=Ae.exec(l);return[...e]},"un");function dn(l){return l.name}i(dn,"mn");var un=i(l=>{let e=(0,K.c)(34),{onSubmit:t,probe:n,schema:r,setDraft:o}=l,s=(0,P.useId)(),m=(0,P.useRef)(null),a=(0,P.useRef)(null),d=(0,P.useRef)(null),f=tn(r,d,o),{close:p,commit:b,commitAt:v,move:u,refresh:x,state:y}=f,w;e[0]!==v?(w=i(I=>{v(I)},"y"),e[0]=v,e[1]=w):w=e[1];let g=w,h;e[2]!==x?(h=i(()=>{let I=d.current;I!==null&&I===document.activeElement&&x(I.value,I.selectionStart)},"m"),e[2]=x,e[3]=h):h=e[3];let S;e[4]!==x||e[5]!==r?(S=[x,r],e[4]=x,e[5]=r,e[6]=S):S=e[6],(0,P.useEffect)(h,S);let k;e[7]!==n||e[8]!==x||e[9]!==o?(k=i(I=>{let{selectionStart:B,value:W}=I.target;o(W);for(let Q of cn(W))n(Q);x(W,B)},"N"),e[7]=n,e[8]=x,e[9]=o,e[10]=k):k=e[10];let N=k,C;e[11]!==x?(C=i(I=>{let B=I.currentTarget;x(B.value,B.selectionStart)},"k"),e[11]=x,e[12]=C):C=e[12];let L=C,R;e[13]!==y||e[14]!==p||e[15]!==b||e[16]!==u||e[17]!==t?(R=i(I=>{if(y!==null){if(I.key==="ArrowDown"){I.preventDefault(),u(1);return}if(I.key==="ArrowUp"){I.preventDefault(),u(-1);return}if(I.key==="Escape"){I.preventDefault(),p();return}if((I.key==="Enter"||I.key==="Tab")&&!I.metaKey&&!I.ctrlKey&&b()){I.preventDefault();return}}(I.metaKey||I.ctrlKey)&&I.key==="Enter"&&(I.preventDefault(),t())},"T"),e[13]=y,e[14]=p,e[15]=b,e[16]=u,e[17]=t,e[18]=R):R=e[18];let E=R,q;e[19]!==p?(q=i(()=>{requestAnimationFrame(()=>{p()})},"C"),e[19]=p,e[20]=q):q=e[20];let O=q,M;e[21]===Symbol.for("react.memo_cache_sentinel")?(M=i(I=>{let{scrollLeft:B,scrollTop:W}=I.currentTarget;m.current!==null&&(m.current.scrollTop=W),a.current!==null&&(a.current.scrollTop=W,a.current.scrollLeft=B)},"_"),e[21]=M):M=e[21];let D=M,T;e[22]===Symbol.for("react.memo_cache_sentinel")?(T=i(I=>{let B=d.current;B===null||I.offset===void 0||(B.focus(),B.setSelectionRange(I.offset,I.offset+(I.length??0)))},"$"),e[22]=T):T=e[22];let _=T,A;e[23]!==N||e[24]!==O||e[25]!==E||e[26]!==L?(A={onBlur:O,onChange:N,onKeyDown:E,onScroll:D,onSelect:L},e[23]=N,e[24]=O,e[25]=E,e[26]=L,e[27]=A):A=e[27];let $;return e[28]!==y||e[29]!==p||e[30]!==s||e[31]!==g||e[32]!==A?($={autocompleteState:y,closeAutocomplete:p,handlers:A,listboxId:s,onPickSuggestion:g,editorRef:d,gutterRef:m,overlayRef:a,revealDiagnostic:_},e[28]=y,e[29]=p,e[30]=s,e[31]=g,e[32]=A,e[33]=$):$=e[33],$},"fn"),mn="lunora-studio-sql-tabs",hn="lunora-studio-sql-active-tab",Be=12,Se=i((l="",e="")=>({activeId:null,id:Me("tab"),name:e,sql:l}),"ve"),fn=i(()=>Oe(hn,""),"bn"),pn=i(l=>{let e=(0,K.c)(16),[t,n]=Ce(mn),[r,o]=fn(),[s]=(0,P.useState)(l),m,a;e[0]!==s||e[1]!==n||e[2]!==t.length?(m=i(()=>{t.length===0&&n([s])},"d"),a=[s,n,t.length],e[0]=s,e[1]=n,e[2]=t.length,e[3]=m,e[4]=a):(m=e[3],a=e[4]),(0,P.useEffect)(m,a);let d;e[5]!==s||e[6]!==t?(d=t.length===0?[s]:t,e[5]=s,e[6]=t,e[7]=d):d=e[7];let f=d,p;e[8]!==r||e[9]!==f?(p=f.some(u=>u.id===r)?r:f[0]?.id??"",e[8]=r,e[9]=f,e[10]=p):p=e[10];let b=p,v;return e[11]!==b||e[12]!==o||e[13]!==n||e[14]!==f?(v={activeId:b,setActiveId:o,setTabs:n,tabs:f},e[11]=b,e[12]=o,e[13]=n,e[14]=f,e[15]=v):v=e[15],v},"gn"),at=i(l=>l.activeId===null&&l.sql.trim()!=="","Ge"),bn=i((l,e)=>[...l,e].slice(-Be),"xn"),gn=i((l,e,t)=>{let n=l.findIndex(o=>o.id===e);if(n===-1)return{activeId:l[0]?.id??"",tabs:[...l]};let r=l.filter(o=>o.id!==e);if(r.length===0){let o=t();return{activeId:o.id,tabs:[o]}}return{activeId:r[Math.min(n,r.length-1)].id,tabs:r}},"vn"),xn=i((l,e)=>{let t=l.filter(n=>n.id===e);return t.length===0?{activeId:l[0]?.id??"",tabs:[...l]}:{activeId:e,tabs:t}},"yn"),vn=i((l,e,t)=>{let n=l.findIndex(o=>o.id===e);if(n===-1)return{activeId:t,tabs:[...l]};let r=l.slice(0,n+1);return{activeId:r.some(o=>o.id===t)?t:e,tabs:r}},"wn"),yn=i(l=>{let e=l();return{activeId:e.id,tabs:[e]}},"Sn"),wn=i((l,e,t)=>{if(l==="others")return e.filter(n=>n.id!==t);if(l==="right"){let n=e.findIndex(r=>r.id===t);return n===-1?[]:e.slice(n+1)}return[...e]},"Nn"),nt={error:null,pane:"results",result:null,running:!1},Sn=i(l=>{let e=(0,K.c)(66),{activeId:t,setActiveId:n,setTabs:r,tabs:o}=pn(l),s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];let[m,a]=(0,P.useState)(s),[d,f]=(0,P.useState)(null),[p,b]=(0,P.useState)(null),v;e[1]!==t||e[2]!==o?(v=o.find(F=>F.id===t)??o[0]??Se(),e[1]=t,e[2]=o,e[3]=v):v=e[3];let u=v,x=m[u.id]??nt,y;e[4]!==u.id||e[5]!==r?(y=i(F=>{r(j=>j.map(U=>U.id===u.id?{...U,...F}:U))},"v"),e[4]=u.id,e[5]=r,e[6]=y):y=e[6];let w=y,g;e[7]!==u.id?(g=i(F=>{a(j=>{let U=j[u.id]??nt;return{...j,[u.id]:{...U,...F}}})},"b"),e[7]=u.id,e[8]=g):g=e[8];let h=g,S;e[9]!==n||e[10]!==r||e[11]!==o.length?(S=i(()=>{if(o.length>=Be)return;let F=Se();r(j=>bn(j,F)),n(F.id)},"w"),e[9]=n,e[10]=r,e[11]=o.length,e[12]=S):S=e[12];let k=S,N;e[13]!==n||e[14]!==r?(N=i(F=>{f(null),b(null),r(F.tabs),n(F.activeId);let j=new Set(F.tabs.map(Nn));a(U=>Object.fromEntries(Object.entries(U).filter(ae=>{let[xe]=ae;return j.has(xe)})))},"S"),e[13]=n,e[14]=r,e[15]=N):N=e[15];let C=N,L;e[16]!==C||e[17]!==o?(L=i(F=>{C(gn(o,F,Se))},"R"),e[16]=C,e[17]=o,e[18]=L):L=e[18];let R=L,E;e[19]!==t||e[20]!==C||e[21]!==o?(E=i((F,j)=>{C(F==="others"?xn(o,j):F==="right"?vn(o,j,t):yn(Se))},"I"),e[19]=t,e[20]=C,e[21]=o,e[22]=E):E=e[22];let q=E,O;e[23]!==q||e[24]!==d||e[25]!==o?(O=i(F=>{d!==null&&(wn(F,o,d.id).some(kn)?b(F):q(F,d.id))},"L"),e[23]=q,e[24]=d,e[25]=o,e[26]=O):O=e[26];let M=O,D;e[27]===Symbol.for("react.memo_cache_sentinel")?(D=i((F,j)=>{j.preventDefault(),b(null),f({id:F,x:j.clientX,y:j.clientY})},"O"),e[27]=D):D=e[27];let T=D,_;e[28]===Symbol.for("react.memo_cache_sentinel")?(_=i(()=>{f(null),b(null)},"E"),e[28]=_):_=e[28];let A=_,$;e[29]===Symbol.for("react.memo_cache_sentinel")?($=i(F=>{F.preventDefault(),f(null),b(null)},"D"),e[29]=$):$=e[29];let I=$,B;e[30]!==M?(B=i(()=>{M("others")},"B"),e[30]=M,e[31]=B):B=e[31];let W=B,Q;e[32]!==M?(Q=i(()=>{M("right")},"P"),e[32]=M,e[33]=Q):Q=e[33];let Y=Q,H;e[34]!==M?(H=i(()=>{M("all")},"Q"),e[34]=M,e[35]=H):H=e[35];let G=H,J;e[36]!==q||e[37]!==p||e[38]!==d?(J=i(()=>{d!==null&&p!==null&&q(p,d.id),b(null)},"J"),e[36]=q,e[37]=p,e[38]=d,e[39]=J):J=e[39];let z=J,V;e[40]===Symbol.for("react.memo_cache_sentinel")?(V=i(()=>{b(null)},"G"),e[40]=V):V=e[40];let re=V,X;e[41]!==d?(X=d===null?void 0:{left:d.x,top:d.y},e[41]=d,e[42]=X):X=e[42];let Z=X,ee;e[43]!==r?(ee=i(F=>{r(j=>j.map(U=>U.activeId===F?{...U,activeId:null}:U))},"Z"),e[43]=r,e[44]=ee):ee=e[44];let te=ee,ne;e[45]!==r?(ne=i((F,j)=>{r(U=>U.map(ae=>ae.id===F?{...ae,name:j}:ae))},"te"),e[45]=r,e[46]=ne):ne=e[46];let le=ne,ce;return e[47]!==u||e[48]!==t||e[49]!==k||e[50]!==R||e[51]!==z||e[52]!==G||e[53]!==W||e[54]!==Y||e[55]!==x||e[56]!==h||e[57]!==w||e[58]!==p||e[59]!==le||e[60]!==n||e[61]!==d||e[62]!==Z||e[63]!==o||e[64]!==te?(ce={activeTab:u,activeTabId:t,addEditorTab:k,cancelBulk:re,closeEditorTab:R,closeTabMenu:A,confirmBulk:z,menuStyle:Z,onBackdropContextMenu:I,onCloseAll:G,onCloseOthers:W,onCloseToRight:Y,openTabMenu:T,output:x,patchActiveOutput:h,patchActiveTab:w,pendingBulk:p,renameTab:le,setActiveTabId:n,tabMenu:d,tabs:o,unlinkQuery:te},e[47]=u,e[48]=t,e[49]=k,e[50]=R,e[51]=z,e[52]=G,e[53]=W,e[54]=Y,e[55]=x,e[56]=h,e[57]=w,e[58]=p,e[59]=le,e[60]=n,e[61]=d,e[62]=Z,e[63]=o,e[64]=te,e[65]=ce):ce=e[65],ce},"kn");function Nn(l){return l.id}i(Nn,"Cn");function kn(l){return at(l)}i(kn,"$n");var Cn="lunora-studio-sql-queries",qn="lunora-studio-sql-history",Tn=25,In=i(l=>{let e=(0,K.c)(33),{loadIntoActiveTab:t,unlinkQuery:n}=l,r=oe(),[o,s]=Ce(Cn),[m,a]=Ce(qn),[d,f]=(0,P.useState)(""),p=(0,P.useRef)(null),b;e[0]!==a?(b=i(T=>{a(_=>_[0]?.sql===T?_:[{at:Date.now(),sql:T},..._.filter(A=>A.sql!==T)].slice(0,Tn))},"p"),e[0]=a,e[1]=b):b=e[1];let v=b,u;e[2]!==t||e[3]!==s||e[4]!==r?(u=i(()=>{let T={id:Me("q"),name:r("Untitled query"),sql:""};s(_=>[T,..._]),t("",T.id)},"c"),e[2]=t,e[3]=s,e[4]=r,e[5]=u):u=e[5];let x=u,y;e[6]!==t||e[7]!==o?(y=i(T=>{let _=o.find(A=>A.id===T);_!==void 0&&(t(_.sql,T),p.current?.querySelector(`[data-testid="sql-query-${T}"]`)?.scrollIntoView({block:"nearest"}))},"v"),e[6]=t,e[7]=o,e[8]=y):y=e[8];let w=y,g;e[9]!==s||e[10]!==n?(g=i(T=>{s(_=>_.filter(A=>A.id!==T)),n(T)},"b"),e[9]=s,e[10]=n,e[11]=g):g=e[11];let h=g,S;e[12]!==t?(S=i(T=>{t(T.currentTarget.dataset.sql??"",null)},"w"),e[12]=t,e[13]=S):S=e[13];let k=S,N;e[14]!==t?(N=i(T=>{t(T.currentTarget.dataset.sql??"",null)},"S"),e[14]=t,e[15]=N):N=e[15];let C=N,L;e[16]!==a?(L=i(()=>{a([])},"R"),e[16]=a,e[17]=L):L=e[17];let R=L,E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=i(T=>{f(T.target.value)},"I"),e[18]=E):E=e[18];let q=E,O;e[19]!==s?(O=i((T,_)=>{s(A=>A.map($=>$.id===T?{...$,sql:_}:$))},"L"),e[19]=s,e[20]=O):O=e[20];let M=O,D;return e[21]!==R||e[22]!==h||e[23]!==m||e[24]!==C||e[25]!==k||e[26]!==x||e[27]!==o||e[28]!==v||e[29]!==d||e[30]!==w||e[31]!==M?(D={clearHistory:R,deleteQuery:h,history:m,listRef:p,loadFromHistory:C,loadTemplate:k,newQuery:x,onSearchChange:q,queries:o,recordHistory:v,search:d,selectQuery:w,updateQuerySql:M},e[21]=R,e[22]=h,e[23]=m,e[24]=C,e[25]=k,e[26]=x,e[27]=o,e[28]=v,e[29]=d,e[30]=w,e[31]=M,e[32]=D):D=e[32],D},"In"),it="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",Rn=i((l,e)=>{let t=[];for(let r of l){if(r.offset===void 0||r.length===void 0||r.length<=0)continue;let o=Math.max(0,Math.min(r.offset,e)),s=Math.max(o,Math.min(r.offset+r.length,e));o!==s&&t.push({end:s,severity:r.severity,start:o})}t.sort((r,o)=>r.start-o.start);let n=[];for(let r of t)r.start>=(n.at(-1)?.end??0)&&n.push(r);return n},"En"),Ln=i(l=>l==="unsafe-response"?"The model returned a statement that is not read-only, so it was discarded.":l==="empty-response"?"The model returned nothing usable.":"The model could not be reached.","Ln"),En=i(l=>{let e=(0,K.c)(51),{assistant:t,failed:n,onGenerated:r}=l,o=oe(),[s,m]=(0,P.useState)("");if(t.unavailable)return null;let a;e[0]!==t?(a=t.pending("sql"),e[0]=t,e[1]=a):a=e[1];let d=a,f;if(e[2]!==t||e[3]!==n||e[4]!==r||e[5]!==d||e[6]!==s||e[7]!==o){let p=t.reason("sql"),b;e[9]!==t||e[10]!==n||e[11]!==r||e[12]!==s?(b=i(q=>{let O=s.trim();O===""&&!q||ie((async()=>{let M=await t.generate(O===""?"fix the failing statement":O,q?n:void 0);M!==void 0&&r(M)})())},"p"),e[9]=t,e[10]=n,e[11]=r,e[12]=s,e[13]=b):b=e[13];let v=b,u;e[14]!==o?(u=o("Describe the query you want"),e[14]=o,e[15]=u):u=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=i(q=>{m(q.target.value)},"g"),e[16]=x):x=e[16];let y;e[17]!==v?(y=i(q=>{q.key==="Enter"&&(q.preventDefault(),v(!1))},"v"),e[17]=v,e[18]=y):y=e[18];let w;e[19]!==o?(w=o("Describe the query you want"),e[19]=o,e[20]=w):w=e[20];let g;e[21]!==d||e[22]!==s||e[23]!==u||e[24]!==y||e[25]!==w?(g=(0,c.jsx)(Fe,{"aria-label":u,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:d,onChange:x,onKeyDown:y,placeholder:w,value:s}),e[21]=d,e[22]=s,e[23]=u,e[24]=y,e[25]=w,e[26]=g):g=e[26];let h=d&&"opacity-60",S;e[27]!==h?(S=ue("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",h),e[27]=h,e[28]=S):S=e[28];let k;e[29]!==d||e[30]!==s?(k=d||s.trim()==="",e[29]=d,e[30]=s,e[31]=k):k=e[31];let N;e[32]!==v?(N=i(()=>{v(!1)},"S"),e[32]=v,e[33]=N):N=e[33];let C;e[34]!==d||e[35]!==o?(C=o(d?"Thinking\u2026":"Draft SQL"),e[34]=d,e[35]=o,e[36]=C):C=e[36];let L;e[37]!==S||e[38]!==k||e[39]!==N||e[40]!==C?(L=(0,c.jsx)("button",{className:S,"data-testid":"sql-assistant-generate",disabled:k,onClick:N,type:"button",children:C}),e[37]=S,e[38]=k,e[39]=N,e[40]=C,e[41]=L):L=e[41];let R;e[42]!==n||e[43]!==d||e[44]!==v||e[45]!==o?(R=n!==void 0&&(0,c.jsx)("button",{className:"rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-assistant-fix",disabled:d,onClick:i(()=>{v(!0)},"onClick"),type:"button",children:o("Fix this")}),e[42]=n,e[43]=d,e[44]=v,e[45]=o,e[46]=R):R=e[46];let E;e[47]!==L||e[48]!==R||e[49]!==g?(E=(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[g,L,R]}),e[47]=L,e[48]=R,e[49]=g,e[50]=E):E=e[50],f=(0,c.jsxs)("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[E,p!==void 0&&(0,c.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:Ln(p)})]}),e[2]=t,e[3]=n,e[4]=r,e[5]=d,e[6]=s,e[7]=o,e[8]=f}else f=e[8];return f},"_n"),_n=i(l=>{let e=(0,K.c)(8),{diagnostics:t,draft:n,scrollRef:r}=l,o,s;if(e[0]!==t||e[1]!==n){s=Symbol.for("react.early_return_sentinel");e:{let d=Rn(t,n.length);if(d.length===0){s=null;break e}o=[];let f=0;for(let[p,b]of d.entries())b.start>f&&o.push(n.slice(f,b.start)),o.push((0,c.jsx)("span",{className:ue("decoration-wavy underline underline-offset-4",b.severity==="error"?"decoration-destructive":"decoration-amber-500"),children:n.slice(b.start,b.end)},`${b.start.toString()}-${p.toString()}`)),f=b.end;o.push(n.slice(f))}e[0]=t,e[1]=n,e[2]=o,e[3]=s}else o=e[2],s=e[3];if(s!==Symbol.for("react.early_return_sentinel"))return s;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=ue("pointer-events-none absolute inset-0 overflow-hidden text-transparent",it),e[4]=m):m=e[4];let a;return e[5]!==o||e[6]!==r?(a=(0,c.jsx)("div",{"aria-hidden":"true",className:m,"data-testid":"sql-diagnostics-overlay",ref:r,children:o}),e[5]=o,e[6]=r,e[7]=a):a=e[7],a},"On"),On={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},Mn=i(l=>{let e=(0,K.c)(10),{diagnostics:t,onSelect:n}=l,r=oe();if(t.length===0)return null;let o;e[0]!==r?(o=r("SQL problems"),e[0]=r,e[1]=o):o=e[1];let s;if(e[2]!==t||e[3]!==n){let a;e[5]!==n?(a=i((d,f)=>(0,c.jsx)("li",{children:(0,c.jsxs)("button",{className:"flex w-full items-start gap-2 px-3 py-1 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-problem",onClick:i(()=>{n(d)},"onClick"),type:"button",children:[(0,c.jsx)("span",{className:ue("mt-px shrink-0 rounded px-1 font-mono text-[10px] uppercase",d.severity==="error"?"bg-destructive/15 text-destructive":"bg-amber-500/15 text-amber-600"),children:On[d.source]}),(0,c.jsx)("span",{className:"min-w-0 text-muted-foreground",children:d.message})]})},`${d.source}-${(d.offset??f).toString()}-${f.toString()}`),"a"),e[5]=n,e[6]=a):a=e[6],s=t.map(a),e[2]=t,e[3]=n,e[4]=s}else s=e[4];let m;return e[7]!==o||e[8]!==s?(m=(0,c.jsx)("ul",{"aria-label":o,className:"max-h-24 shrink-0 overflow-y-auto border-t border-border bg-muted/30","data-testid":"sql-problems",children:s}),e[7]=o,e[8]=s,e[9]=m):m=e[9],m},"Dn"),Dn={minWidth:"2.75rem",paddingInline:"0.5rem"},An=i(l=>{let e=(0,K.c)(64),{assistant:t,autocomplete:n,diagnostics:r,draft:o,failed:s,handlers:m,editorRef:a,gutterRef:d,listboxId:f,onGenerated:p,onPickSuggestion:b,onRevealDiagnostic:v,overlayRef:u}=l,x=oe(),y,w,g,h,S,k,N,C;if(e[0]!==t||e[1]!==o||e[2]!==s||e[3]!==d||e[4]!==p){let B=o.split(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as k}from"./chunk-MLT5MMMY.js";import{a as j}from"./chunk-54MMVNPT.js";import{a as T}from"./chunk-4PDTGZDC.js";import"./chunk-SFDOII3B.js";import"./chunk-SMIESS7P.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-MWIKAR7F.js";import"./chunk-DJZYD5I5.js";import"./chunk-2OUPA2WJ.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as E}from"./chunk-6IZBFC3G.js";import"./chunk-XXQUMVWH.js";import"./chunk-ZNNKWEH5.js";import"./chunk-QLQADHFE.js";import{a as y}from"./chunk-VDW32UET.js";import{c as b}from"./chunk-UP7OTXKF.js";import"./chunk-LYVP5PT6.js";import"./chunk-XBDKZZ67.js";import{a as w}from"./chunk-XQCVZAGU.js";import{a as I,b as R,c as A,d as v,e as l,f as n}from"./chunk-WJQLNYGX.js";import{a as u,e as N}from"./chunk-WQH3LT2P.js";import{d as _,r as S}from"./chunk-IUYFXK4X.js";import"./chunk-X7B6PLEW.js";import{a as c,e as M,h as G}from"./chunk-3XIESWL4.js";var e=M(G(),1);var H=["subscriptions","events"],$={},D=new Set(["active","trialing"]),q=new Set(["past_due","unpaid"]),a=c((s,t)=>{if(s[t]!==void 0)return s[t];let m=s.__doc__;return typeof m=="string"?k(m)?.[t]:void 0},"i"),i=c(s=>typeof s=="string"?s:typeof s=="number"||typeof s=="bigint"||typeof s=="boolean"?String(s):"","s"),z=c(s=>D.has(s)?"default":q.has(s)?"destructive":"outline","L"),ae=c(({limit:s=100})=>{let t=_(),m=T(),{data:g}=b(y.listTables,$,{live:!0}),O=g!==void 0,B=Array.isArray(g)&&H.every(r=>g.some(d=>d.name===r)),p=m.payments&&B,o=b(y.readTablePage,{filters:[],limit:s,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:p}),f=b(y.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:p});j(()=>{p&&(o.refetch(),f.refetch())},!0);let h=o.data?.rows??[],U=f.data?.rows??[],C=o.error??f.error,F=o.error===null?f.errorSource:o.errorSource,P=h.filter(r=>D.has(i(a(r,"state")))).length,L=U.toSorted((r,d)=>Number(a(d,"processedAt")??0)-Number(a(r,"processedAt")??0));return O&&!p?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(w,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, \u2026) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(u,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:P}),(0,e.jsx)(x,{variant:"default",children:t("{count} active",{count:P})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:h.length})})]})}),C===null?void 0:(0,e.jsx)(E,{error:F}),h.length===0&&!o.isLoading?(0,e.jsx)(w,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(u,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(I,{children:[(0,e.jsx)(R,{children:(0,e.jsxs)(v,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(A,{children:h.map(r=>{let d=i(a(r,"state"));return(0,e.jsxs)(v,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:i(a(r,"provider"))}),(0,e.jsx)(n,{children:i(a(r,"referenceId"))}),(0,e.jsx)(n,{children:i(a(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(x,{variant:z(d),children:d})}),(0,e.jsx)(n,{children:S(a(r,"currentPeriodEnd"))})]},i(a(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(u,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(N,{className:"px-0",children:(0,e.jsx)(I,{children:(0,e.jsx)(A,{children:L.map(r=>(0,e.jsxs)(v,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:i(a(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:i(a(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:i(a(r,"providerEventId"))}),(0,e.jsx)(n,{children:S(a(r,"processedAt"))})]},i(a(r,"providerEventId"))))})})})]})]})},"ae");export{ae as PaymentsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as B}from"./chunk-XF2B7P5A.js";import{b as A}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as P}from"./chunk-
|
|
1
|
+
import{b as B}from"./chunk-XF2B7P5A.js";import{b as A}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as P}from"./chunk-6IZBFC3G.js";import"./chunk-XXQUMVWH.js";import"./chunk-ZNNKWEH5.js";import"./chunk-QLQADHFE.js";import{a as M}from"./chunk-VDW32UET.js";import{c as F}from"./chunk-UP7OTXKF.js";import"./chunk-LYVP5PT6.js";import"./chunk-XBDKZZ67.js";import{a as R,b as q,c as z,d as K,e as U,f as _}from"./chunk-WJQLNYGX.js";import{a as E,e as j}from"./chunk-WQH3LT2P.js";import{d as V}from"./chunk-IUYFXK4X.js";import"./chunk-X7B6PLEW.js";import{a as k,e as O,g as H,h as W}from"./chunk-3XIESWL4.js";var G=O(H(),1);var t=O(W(),1);var $={binding:"outline",secret:"destructive",var:"secondary"},J=k((n,e)=>{if(n===void 0)return[];let m=[];return n.workerUrl!==void 0&&m.push({label:e("URL"),value:n.workerUrl}),n.environment!==void 0&&m.push({label:e("Environment"),value:n.environment}),n.deploymentId!==void 0&&m.push({label:e("Deployment"),value:n.deploymentId}),n.versionTag!==void 0&&m.push({label:e("Version"),value:n.versionTag}),m},"B"),le=k(n=>{let e=(0,G.c)(52),{initialShardKey:m}=n,r=V(),w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={},e[0]=w):w=e[0];let C=m??"",S;e[1]!==C?(S={shardKey:C},e[1]=C,e[2]=S):S=e[2];let{data:s,error:l,errorSource:N,isLoading:D}=F(M.getSettings,w,S),a,c,p,d,o,i,u;if(e[3]!==l||e[4]!==N||e[5]!==s?.deploy||e[6]!==s?.settings||e[7]!==r){let L=J(s?.deploy,r),T;e[15]!==s?.settings?(T=s?.settings??[],e[15]=s?.settings,e[16]=T):T=e[16],a=T,c="flex flex-col gap-4",p="lunora-settings";let y;e[17]!==r?(y=r("Open in Cloudflare"),e[17]=r,e[18]=y):y=e[18],e[19]!==y?(d=(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:B,rel:"noreferrer",target:"_blank",children:y})}),e[19]=y,e[20]=d):d=e[20];let b;e[21]!==r?(b=r("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=r,e[22]=b):b=e[22],e[23]!==b?(o=(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:b}),e[23]=b,e[24]=o):o=e[24],e[25]!==l||e[26]!==N?(i=l!==null&&(0,t.jsx)(P,{error:N,testId:"set-error"}),e[25]=l,e[26]=N,e[27]=i):i=e[27],u=L.length>0&&(0,t.jsxs)(E,{className:"py-0","data-testid":"set-deploy",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Deployment")})}),(0,t.jsx)(j,{className:"py-3",children:(0,t.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:L.map(Q)})})]}),e[3]=l,e[4]=N,e[5]=s?.deploy,e[6]=s?.settings,e[7]=r,e[8]=a,e[9]=c,e[10]=p,e[11]=d,e[12]=o,e[13]=i,e[14]=u}else a=e[8],c=e[9],p=e[10],d=e[11],o=e[12],i=e[13],u=e[14];let h;e[28]!==r?(h=r("Environment & bindings"),e[28]=r,e[29]=h):h=e[29];let f;e[30]!==h?(f=(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h})}),e[30]=h,e[31]=f):f=e[31];let g;e[32]!==l||e[33]!==D||e[34]!==a.length||e[35]!==r?(g=l===null&&!D&&a.length===0&&(0,t.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:r("No environment variables or bindings.")}),e[32]=l,e[33]=D,e[34]=a.length,e[35]=r,e[36]=g):g=e[36];let x;e[37]!==a||e[38]!==r?(x=a.length>0&&(0,t.jsx)(j,{className:"px-0 py-0",children:(0,t.jsxs)(R,{"data-testid":"set-table",children:[(0,t.jsx)(q,{children:(0,t.jsxs)(K,{children:[(0,t.jsx)(U,{children:r("name")}),(0,t.jsx)(U,{children:r("kind")}),(0,t.jsx)(U,{children:r("value")})]})}),(0,t.jsx)(z,{children:a.map(X)})]})}),e[37]=a,e[38]=r,e[39]=x):x=e[39];let v;e[40]!==f||e[41]!==g||e[42]!==x?(v=(0,t.jsxs)(E,{className:"py-0",children:[f,g,x]}),e[40]=f,e[41]=g,e[42]=x,e[43]=v):v=e[43];let I;return e[44]!==v||e[45]!==c||e[46]!==p||e[47]!==d||e[48]!==o||e[49]!==i||e[50]!==u?(I=(0,t.jsxs)("div",{className:c,"data-testid":p,children:[d,o,i,u,v]}),e[44]=v,e[45]=c,e[46]=p,e[47]=d,e[48]=o,e[49]=i,e[50]=u,e[51]=I):I=e[51],I},"le");function Q(n){return(0,t.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,t.jsx)("dt",{className:"text-muted-foreground",children:n.label}),(0,t.jsx)("dd",{className:"truncate font-mono text-xs",title:n.value,children:n.value})]},n.label)}k(Q,"G");function X(n){return(0,t.jsxs)(K,{"data-testid":"set-row",children:[(0,t.jsx)(_,{className:"font-mono text-xs font-medium",children:n.name}),(0,t.jsx)(_,{children:(0,t.jsx)(A,{variant:$[n.kind],children:n.bindingType??n.kind})}),(0,t.jsx)(_,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:n.value??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},n.name)}k(X,"H");export{le as SettingsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Qe}from"./chunk-3DH35OZ5.js";import{a as Me}from"./chunk-DBAMCESO.js";import{a as Ve}from"./chunk-ESVP44Y3.js";import{a as Je}from"./chunk-3SCGCJYS.js";import{a as D}from"./chunk-5Y3QLNWX.js";import{a as He}from"./chunk-54MMVNPT.js";import{a as Ke}from"./chunk-FURI47Z2.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import{R as B}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{a as z}from"./chunk-MWIKAR7F.js";import"./chunk-DJZYD5I5.js";import"./chunk-2OUPA2WJ.js";import{b as T}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as Ge}from"./chunk-UP7OTXKF.js";import{f as E}from"./chunk-LYVP5PT6.js";import"./chunk-XBDKZZ67.js";import{a as Ze}from"./chunk-XQCVZAGU.js";import{a as Ue,b as _e,c as $e,d as L,e as U,f as _}from"./chunk-WJQLNYGX.js";import{a as we,e as Ce}from"./chunk-WQH3LT2P.js";import{d as W,h as je,m as Ae,o as ze,r as Ie}from"./chunk-IUYFXK4X.js";import"./chunk-X7B6PLEW.js";import{a as r,e as Le,f as Ye,g as et,h as tt}from"./chunk-3XIESWL4.js";var k=Le(Ye(),1);var Z=Le(et(),1);var t=Le(tt(),1);var at=r(()=>{let u=(0,Z.c)(3),{config:e,ready:l}=Me(),s;return u[0]!==e.capabilities||u[1]!==l?(s={capabilities:e.capabilities,ready:l},u[0]=e.capabilities,u[1]=l,u[2]=s):s=u[2],s},"et"),st={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},lt=r((u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),"at"),rt=r((u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;let l=typeof e=="string"?e.trim():"";if(l!==""){if(u.type==="number"){let s=Number(l);return Number.isNaN(s)?void 0:{value:s}}return{value:l}}},"lt"),it=r(u=>{let e=(0,Z.c)(105),{onClose:l,onCreated:s}=u,c=E(),a=W(),{config:o}=Me(),{busy:i,error:n,run:m}=Je(),[w,S]=(0,k.useState)(""),[b,C]=(0,k.useState)(""),[y,I]=(0,k.useState)(""),[h,g]=(0,k.useState)(""),v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];let[f,d]=(0,k.useState)(v),A;e[1]===Symbol.for("react.memo_cache_sentinel")?(A=r(p=>{S(p.target.value)},"C"),e[1]=A):A=e[1];let x=A,F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F=r(p=>{C(p.target.value)},"F"),e[2]=F):F=e[2];let O=F,P;e[3]===Symbol.for("react.memo_cache_sentinel")?(P=r(p=>{I(p.target.value)},"P"),e[3]=P):P=e[3];let Be=P,G;e[4]===Symbol.for("react.memo_cache_sentinel")?(G=r(p=>{g(p.target.value)},"O"),e[4]=G):G=e[4];let Te=G,H;e[5]===Symbol.for("react.memo_cache_sentinel")?(H=r((p,$)=>{d(V=>({...V,[p]:$}))},"G"),e[5]=H):H=e[5];let Pe=H,J;e[6]!==f?(J=r(p=>f[p.name]??(p.type==="boolean"?!1:""),"H"),e[6]=f,e[7]=J):J=e[7];let R=J,K;if(e[8]!==o.userFields||e[9]!==R){let p;e[11]!==R?(p=r($=>!$.required||lt($,R($)),"p"),e[11]=R,e[12]=p):p=e[12],K=o.userFields.every(p),e[8]=o.userFields,e[9]=R,e[10]=K}else K=e[10];let Fe=K,Q;e[13]!==i||e[14]!==w||e[15]!==b||e[16]!==Fe?(Q=!i&&w.trim()!==""&&b.trim()!==""&&Fe,e[13]=i,e[14]=w,e[15]=b,e[16]=Fe,e[17]=Q):Q=e[17];let De=Q,X;e[18]!==o.userFields||e[19]!==R?(X=r(()=>{let p={};for(let $ of o.userFields){let V=rt($,R($));V!==void 0&&(p[$.name]=V.value)}return Object.keys(p).length===0?void 0:p},"W"),e[18]=o.userFields,e[19]=R,e[20]=X):X=e[20];let Se=X,Y;e[21]!==Se||e[22]!==c||e[23]!==w||e[24]!==b||e[25]!==l||e[26]!==s||e[27]!==y||e[28]!==h||e[29]!==m?(Y=r(()=>{m(async()=>{await c.createAuthUser({data:Se(),email:w.trim(),name:b.trim(),password:y===""?void 0:y,role:h.trim()===""?void 0:h.trim()}),s(),l()})},"Z"),e[21]=Se,e[22]=c,e[23]=w,e[24]=b,e[25]=l,e[26]=s,e[27]=y,e[28]=h,e[29]=m,e[30]=Y):Y=e[30];let N=Y,j;e[31]!==a?(j=a("Create user"),e[31]=a,e[32]=j):j=e[32];let q;e[33]!==a?(q=a("Create user"),e[33]=a,e[34]=q):q=e[34];let M;e[35]!==q?(M=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:q}),e[35]=q,e[36]=M):M=e[36];let ee;e[37]!==a?(ee=a("email"),e[37]=a,e[38]=ee):ee=e[38];let te;e[39]!==ee?(te=(0,t.jsx)(D,{htmlFor:"uc-email",children:ee}),e[39]=ee,e[40]=te):te=e[40];let ae;e[41]!==w?(ae=(0,t.jsx)(B,{"data-testid":"uc-email",id:"uc-email",onChange:x,type:"email",value:w}),e[41]=w,e[42]=ae):ae=e[42];let se;e[43]!==te||e[44]!==ae?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[te,ae]}),e[43]=te,e[44]=ae,e[45]=se):se=e[45];let le;e[46]!==a?(le=a("name"),e[46]=a,e[47]=le):le=e[47];let re;e[48]!==le?(re=(0,t.jsx)(D,{htmlFor:"uc-name",children:le}),e[48]=le,e[49]=re):re=e[49];let ie;e[50]!==b?(ie=(0,t.jsx)(B,{"data-testid":"uc-name",id:"uc-name",onChange:O,value:b}),e[50]=b,e[51]=ie):ie=e[51];let ne;e[52]!==re||e[53]!==ie?(ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[re,ie]}),e[52]=re,e[53]=ie,e[54]=ne):ne=e[54];let de;e[55]!==a?(de=a("Password (optional)"),e[55]=a,e[56]=de):de=e[56];let oe;e[57]!==de?(oe=(0,t.jsx)(D,{htmlFor:"uc-password",children:de}),e[57]=de,e[58]=oe):oe=e[58];let ce;e[59]!==y?(ce=(0,t.jsx)(B,{"data-testid":"uc-password",id:"uc-password",onChange:Be,type:"password",value:y}),e[59]=y,e[60]=ce):ce=e[60];let ue;e[61]!==oe||e[62]!==ce?(ue=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[oe,ce]}),e[61]=oe,e[62]=ce,e[63]=ue):ue=e[63];let me;e[64]!==a?(me=a("Role (optional)"),e[64]=a,e[65]=me):me=e[65];let he;e[66]!==me?(he=(0,t.jsx)(D,{htmlFor:"uc-role",children:me}),e[66]=me,e[67]=he):he=e[67];let pe;e[68]!==h?(pe=(0,t.jsx)(B,{"data-testid":"uc-role",id:"uc-role",onChange:Te,value:h}),e[68]=h,e[69]=pe):pe=e[69];let fe;e[70]!==he||e[71]!==pe?(fe=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[he,pe]}),e[70]=he,e[71]=pe,e[72]=fe):fe=e[72];let ve;e[73]!==o.userFields||e[74]!==R||e[75]!==a?(ve=o.userFields.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),o.userFields.map(p=>{let $=`uc-field-${p.name}`,V=p.required?"":` (${a("optional")})`;if(p.type==="boolean"){let qe=R(p)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:$,children:[(0,t.jsx)(Qe,{checked:qe,"data-testid":$,id:$,onCheckedChange:r(Xe=>{Pe(p.name,Xe)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[p.name,V]})]},p.name)}let We=R(p);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(D,{htmlFor:$,children:[p.name,V]}),(0,t.jsx)(B,{"data-testid":$,id:$,onChange:r(qe=>{Pe(p.name,qe.target.value)},"onChange"),type:st[p.type],value:typeof We=="string"?We:""})]},p.name)})]}),e[73]=o.userFields,e[74]=R,e[75]=a,e[76]=ve):ve=e[76];let xe;e[77]!==n?(xe=n!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:n}),e[77]=n,e[78]=xe):xe=e[78];let be;e[79]!==a?(be=a("Cancel"),e[79]=a,e[80]=be):be=e[80];let ye;e[81]!==l||e[82]!==be?(ye=(0,t.jsx)(z,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:be}),e[81]=l,e[82]=be,e[83]=ye):ye=e[83];let Oe=!De,ge;e[84]!==i||e[85]!==a?(ge=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=ge):ge=e[86];let Ne;e[87]!==N||e[88]!==Oe||e[89]!==ge?(Ne=(0,t.jsx)(z,{"data-testid":"uc-submit",disabled:Oe,onClick:N,size:"sm",type:"button",children:ge}),e[87]=N,e[88]=Oe,e[89]=ge,e[90]=Ne):Ne=e[90];let ke;e[91]!==ye||e[92]!==Ne?(ke=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[ye,Ne]}),e[91]=ye,e[92]=Ne,e[93]=ke):ke=e[93];let Re;return e[94]!==l||e[95]!==j||e[96]!==M||e[97]!==se||e[98]!==ne||e[99]!==ue||e[100]!==fe||e[101]!==ve||e[102]!==xe||e[103]!==ke?(Re=(0,t.jsxs)(Ve,{label:j,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[M,se,ne,ue,fe,ve,xe,ke]}),e[94]=l,e[95]=j,e[96]=M,e[97]=se,e[98]=ne,e[99]=ue,e[100]=fe,e[101]=ve,e[102]=xe,e[103]=ke,e[104]=Re):Re=e[104],Re},"st"),Ee=r(u=>{let e=(0,Z.c)(2),{children:l}=u,s;return e[0]!==l?(s=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=s):s=e[1],s},"Le"),nt=r(u=>{let e=(0,Z.c)(29),{busy:l,runAction:s,userId:c,version:a}=u,o=E(),i=W(),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),b;e[0]!==o||e[1]!==c?(b=r(()=>{ze((async()=>{S(null);try{let x=await o.listAuthSessions({limit:50,userId:c});m(x.rows)}catch(x){let F=x;m(null),S(je(F))}})())},"x"),e[0]=o,e[1]=c,e[2]=b):b=e[2];let C;e[3]!==o||e[4]!==c||e[5]!==a?(C=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=C):C=e[6],(0,k.useEffect)(b,C);let y;e[7]!==o||e[8]!==s?(y=r(x=>{s(()=>o.revokeAuthSession({sessionId:x}))},"y"),e[7]=o,e[8]=s,e[9]=y):y=e[9];let I=y,h;e[10]!==i?(h=i("Sessions"),e[10]=i,e[11]=h):h=e[11];let g;e[12]!==h?(g=(0,t.jsx)(Ee,{children:h}),e[12]=h,e[13]=g):g=e[13];let v;e[14]!==w?(v=w!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:w}),e[14]=w,e[15]=v):v=e[15];let f;e[16]!==n||e[17]!==i?(f=n!==null&&n.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=n,e[17]=i,e[18]=f):f=e[18];let d;e[19]!==l||e[20]!==I||e[21]!==n||e[22]!==i?(d=n!==null&&n.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:i("expires")}),(0,t.jsx)(U,{children:i("ip")}),(0,t.jsx)(U,{children:i("user agent")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)($e,{children:n.map(x=>(0,t.jsxs)(L,{"data-testid":`ud-session-${x.id}`,children:[(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(x.expiresAt)}),(0,t.jsx)(_,{children:x.ipAddress??""}),(0,t.jsx)(_,{className:"max-w-40 truncate",children:x.userAgent??""}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-revoke-${x.id}`,disabled:l,onClick:r(()=>{I(x.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},x.id))})]})})}),e[19]=l,e[20]=I,e[21]=n,e[22]=i,e[23]=d):d=e[23];let A;return e[24]!==g||e[25]!==v||e[26]!==f||e[27]!==d?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,v,f,d]}),e[24]=g,e[25]=v,e[26]=f,e[27]=d,e[28]=A):A=e[28],A},"rt"),dt=r(u=>{let e=(0,Z.c)(30),{busy:l,runAction:s,userId:c,version:a}=u,o=E(),i=W(),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),b;e[0]!==o||e[1]!==c?(b=r(()=>{ze((async()=>{S(null);try{m(await o.listAuthAccounts({userId:c}))}catch(x){let F=x;m(null),S(je(F))}})())},"x"),e[0]=o,e[1]=c,e[2]=b):b=e[2];let C;e[3]!==o||e[4]!==c||e[5]!==a?(C=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=C):C=e[6],(0,k.useEffect)(b,C);let y;e[7]!==o||e[8]!==s||e[9]!==c?(y=r(x=>{s(()=>o.unlinkAuthAccount({accountId:x,userId:c}))},"y"),e[7]=o,e[8]=s,e[9]=c,e[10]=y):y=e[10];let I=y,h;e[11]!==i?(h=i("Linked accounts"),e[11]=i,e[12]=h):h=e[12];let g;e[13]!==h?(g=(0,t.jsx)(Ee,{children:h}),e[13]=h,e[14]=g):g=e[14];let v;e[15]!==w?(v=w!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:w}),e[15]=w,e[16]=v):v=e[16];let f;e[17]!==n||e[18]!==i?(f=n!==null&&n.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=n,e[18]=i,e[19]=f):f=e[19];let d;e[20]!==n||e[21]!==l||e[22]!==I||e[23]!==i?(d=n!==null&&n.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:i("provider")}),(0,t.jsx)(U,{children:i("created")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)($e,{children:n.map(x=>{let F=Ae(x.id);return(0,t.jsxs)(L,{"data-testid":`ud-account-${F}`,children:[(0,t.jsx)(_,{children:Ae(x.providerId)}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(x.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-unlink-${F}`,disabled:l,onClick:r(()=>{I(F)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},F)})})]})})}),e[20]=n,e[21]=l,e[22]=I,e[23]=i,e[24]=d):d=e[24];let A;return e[25]!==g||e[26]!==v||e[27]!==f||e[28]!==d?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,v,f,d]}),e[25]=g,e[26]=v,e[27]=f,e[28]=d,e[29]=A):A=e[29],A},"it"),ot=r(u=>{let e=(0,Z.c)(40),{busy:l,capabilities:s,runAction:c,userId:a,version:o}=u,i=E(),n=W(),[m,w]=(0,k.useState)(null),S;e[0]!==s.passkey||e[1]!==i||e[2]!==a?(S=r(()=>{s.passkey&&ze((async()=>{try{w(await i.listAuthPasskeys({userId:a}))}catch{w(null)}})())},"I"),e[0]=s.passkey,e[1]=i,e[2]=a,e[3]=S):S=e[3];let b;e[4]!==s.passkey||e[5]!==i||e[6]!==a||e[7]!==o?(b=[s.passkey,i,a,o],e[4]=s.passkey,e[5]=i,e[6]=a,e[7]=o,e[8]=b):b=e[8],(0,k.useEffect)(S,b);let C;e[9]!==i||e[10]!==c||e[11]!==a?(C=r(()=>{c(()=>i.disableAuthTwoFactor({userId:a}))},"w"),e[9]=i,e[10]=c,e[11]=a,e[12]=C):C=e[12];let y=C,I;e[13]!==i||e[14]!==c?(I=r(F=>{c(()=>i.deleteAuthPasskey({passkeyId:F}))},"A"),e[13]=i,e[14]=c,e[15]=I):I=e[15];let h=I,g;e[16]!==n?(g=n("Security"),e[16]=n,e[17]=g):g=e[17];let v;e[18]!==g?(v=(0,t.jsx)(Ee,{children:g}),e[18]=g,e[19]=v):v=e[19];let f;e[20]!==l||e[21]!==s.twoFactor||e[22]!==y||e[23]!==n?(f=s.twoFactor&&(0,t.jsx)(z,{"data-testid":"ud-disable-2fa",disabled:l,onClick:y,size:"sm",type:"button",variant:"outline",children:n("Disable two-factor")}),e[20]=l,e[21]=s.twoFactor,e[22]=y,e[23]=n,e[24]=f):f=e[24];let d;e[25]!==s.passkey||e[26]!==m||e[27]!==n?(d=s.passkey&&m!==null&&m.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("No passkeys.")}),e[25]=s.passkey,e[26]=m,e[27]=n,e[28]=d):d=e[28];let A;e[29]!==l||e[30]!==s.passkey||e[31]!==h||e[32]!==m||e[33]!==n?(A=s.passkey&&m!==null&&m.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:n("name")}),(0,t.jsx)(U,{children:n("created")}),(0,t.jsx)(U,{"aria-label":n("Actions")})]})}),(0,t.jsx)($e,{children:m.map(F=>{let O=Ae(F.id);return(0,t.jsxs)(L,{"data-testid":`ud-passkey-${O}`,children:[(0,t.jsx)(_,{children:Ae(F.name)||O}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(F.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-delete-passkey-${O}`,disabled:l,onClick:r(()=>{h(O)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")})})]},O)})})]})})}),e[29]=l,e[30]=s.passkey,e[31]=h,e[32]=m,e[33]=n,e[34]=A):A=e[34];let x;return e[35]!==v||e[36]!==f||e[37]!==d||e[38]!==A?(x=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[v,f,d,A]}),e[35]=v,e[36]=f,e[37]=d,e[38]=A,e[39]=x):x=e[39],x},"nt"),ct=/(?:at|expires)$/iu,ut=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),mt=r((u,e)=>typeof e=="number"&&ct.test(u)?Ie(e):Ae(e),"ct"),ht=r(({capabilities:u,onChanged:e,onClose:l,user:s})=>{let c=E(),a=W(),o=s.banned===!0,[i,n]=(0,k.useState)(null),[m,w]=(0,k.useState)(!1),[S,b]=(0,k.useState)(0),[C,y]=(0,k.useState)(typeof s.role=="string"?s.role:""),[I,h]=(0,k.useState)(""),[g,v]=(0,k.useState)(""),[f,d]=(0,k.useState)(""),[A,x]=(0,k.useState)(null),[F,O]=(0,k.useState)(!1),P=r((N,j)=>{ze((async()=>{w(!0),n(null);try{let q=await N();j?.refresh!==!1&&(b(M=>M+1),e()),j?.onResult?.(q)}catch(q){n(je(q))}w(!1)})())},"P"),Be=r(N=>{y(N.target.value)},"De"),G=r(N=>{h(N.target.value)},"O"),Te=r(N=>{v(N.target.value)},"je"),H=r(N=>{d(N.target.value)},"G"),Pe=r(()=>{let N=C.trim();N!==""&&P(async()=>{await c.setAuthUserRole({role:N,userId:s.id})})},"Se"),J=r(()=>{let N=Number.parseInt(g,10),j=Number.isFinite(N)&&N>0?N*86400:void 0;P(async()=>{await c.banAuthUser({expiresInSeconds:j,reason:I.trim()===""?void 0:I.trim(),userId:s.id})})},"H"),R=r(()=>{P(async()=>{await c.unbanAuthUser({userId:s.id})})},"R"),K=r(()=>{P(async()=>{await c.setAuthUserPassword({newPassword:f,userId:s.id}),d("")})},"J"),Fe=r(()=>{P(()=>c.impersonateAuthUser({userId:s.id}),{onResult:r(N=>{x(N.token)},"onResult"),refresh:!1})},"we"),Q=r(()=>{P(async()=>{await c.revokeAuthUserSessions({userId:s.id})})},"K"),De=r(()=>{P(async()=>{await c.removeAuthUser({userId:s.id}),l()})},"Te"),X=r(()=>{O(!0)},"W"),Se=r(()=>{O(!1)},"Ce"),Y=Object.entries(s).filter(([N])=>!ut.has(N));return(0,t.jsxs)(Ve,{label:a("User details"),onClose:l,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:s.name??s.email??s.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:s.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof s.role=="string"&&s.role!==""&&(0,t.jsx)(T,{variant:"secondary",children:s.role}),o?(0,t.jsx)(T,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(T,{variant:"outline",children:a("Active")}),s.emailVerified===!0?(0,t.jsx)(T,{variant:"secondary",children:a("verified")}):(0,t.jsx)(T,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(z,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),i!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:i}),u.admin&&(0,t.jsxs)(we,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Actions")})}),(0,t.jsxs)(Ce,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(B,{"data-testid":"ud-role-input",id:"ud-role",onChange:Be,value:C})]}),(0,t.jsx)(z,{"data-testid":"ud-set-role",disabled:m||C.trim()==="",onClick:Pe,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),o?(0,t.jsx)(z,{"data-testid":"ud-unban",disabled:m,onClick:R,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),(0,t.jsx)(B,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:G,value:I})]}),(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-ban-days",children:a("Days")}),(0,t.jsx)(B,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:Te,type:"number",value:g})]}),(0,t.jsx)(z,{"data-testid":"ud-ban",disabled:m,onClick:J,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(B,{"data-testid":"ud-password",id:"ud-password",onChange:H,type:"password",value:f})]}),(0,t.jsx)(z,{"data-testid":"ud-set-password",disabled:m||f==="",onClick:K,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(z,{"data-testid":"ud-impersonate",disabled:m,onClick:Fe,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(z,{"data-testid":"ud-revoke-all",disabled:m,onClick:Q,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),F?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(z,{"data-testid":"ud-delete-confirm",disabled:m,onClick:De,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(z,{"data-testid":"ud-delete-cancel",onClick:Se,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(z,{"data-testid":"ud-delete",disabled:m,onClick:X,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),A!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(D,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(B,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:A})]})]})]}),(0,t.jsx)(nt,{busy:m,runAction:P,userId:s.id,version:S}),u.accounts&&(0,t.jsx)(dt,{busy:m,runAction:P,userId:s.id,version:S}),(u.twoFactor||u.passkey)&&(0,t.jsx)(ot,{busy:m,capabilities:u,runAction:P,userId:s.id,version:S}),(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),(0,t.jsx)("dl",{className:"flex flex-col",children:Y.map(([N,j])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:N}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:mt(N,j)})]},N))})]})]})},"ut"),pt=50,$t=r(({pageSize:u=pt}={})=>{let e=E(),l=W(),[s,c]=(0,k.useState)(""),[a,o]=(0,k.useState)(""),i=Ke(s),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(!1),{capabilities:b}=at(),C=i.trim(),y=a.trim(),I=Ge(["lunora-auth-users",C,y,u],()=>e.listAuthUsers({filterField:y===""?void 0:"role",filterValue:y===""?void 0:y,limit:u,search:C===""?void 0:C}),{keepPreviousData:!0}),h=I.data?.rows??null,g=I.error,v=r(()=>{I.refetch()},"v");He(()=>{I.refetch()},!0);let f=n===null?null:h?.find(d=>d.id===n)??null;return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(B,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:r(d=>{c(d.target.value)},"onChange"),placeholder:l("Search by email or name\u2026"),value:s}),(0,t.jsx)(B,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:r(d=>{o(d.target.value)},"onChange"),placeholder:l("Filter by role"),value:a}),(0,t.jsx)(z,{"data-testid":"us-new",onClick:r(()=>{S(!0)},"onClick"),size:"sm",type:"button",children:l("New user")})]}),g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g}),h!==null&&h.length===0&&(0,t.jsx)(Ze,{description:l("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:l("No users.")}),h!==null&&h.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"us-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(U,{children:l("id")}),(0,t.jsx)(U,{children:l("email")}),(0,t.jsx)(U,{children:l("name")}),(0,t.jsx)(U,{children:l("role")}),(0,t.jsx)(U,{children:l("status")}),(0,t.jsx)(U,{children:l("verified")}),(0,t.jsx)(U,{children:l("created")}),(0,t.jsx)(U,{"aria-label":l("Actions")})]})}),(0,t.jsx)($e,{children:h.map(d=>(0,t.jsxs)(L,{"data-testid":`us-row-${d.id}`,children:[(0,t.jsx)(_,{className:"font-mono text-xs",children:d.id}),(0,t.jsx)(_,{children:d.email??""}),(0,t.jsx)(_,{children:d.name??""}),(0,t.jsx)(_,{children:typeof d.role=="string"&&d.role!==""?(0,t.jsx)(T,{variant:"secondary",children:d.role}):""}),(0,t.jsx)(_,{children:d.banned===!0?(0,t.jsx)(T,{variant:"destructive",children:l("Banned")}):(0,t.jsx)(T,{variant:"success",children:l("Active")})}),(0,t.jsx)(_,{children:d.emailVerified===!0?(0,t.jsx)(T,{variant:"success",children:l("yes")}):(0,t.jsx)(T,{variant:"outline",children:l("no")})}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(d.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`us-manage-${d.id}`,onClick:r(()=>{m(d.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},d.id))})]})})}),f!==null&&(0,t.jsx)(ht,{capabilities:b,onChanged:v,onClose:r(()=>{m(null)},"onClose"),user:f}),w&&(0,t.jsx)(it,{onClose:r(()=>{S(!1)},"onClose"),onCreated:v})]})},"Pt");export{$t as UsersPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{R as k}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{a as q}from"./chunk-MWIKAR7F.js";import"./chunk-DJZYD5I5.js";import"./chunk-2OUPA2WJ.js";import{b as F}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as B}from"./chunk-6IZBFC3G.js";import"./chunk-XXQUMVWH.js";import"./chunk-ZNNKWEH5.js";import"./chunk-QLQADHFE.js";import{a as R}from"./chunk-VDW32UET.js";import{c as P}from"./chunk-UP7OTXKF.js";import"./chunk-LYVP5PT6.js";import"./chunk-XBDKZZ67.js";import{a as M}from"./chunk-XQCVZAGU.js";import{a as G,b as H,c as J,d as T,e as x,f as w}from"./chunk-WJQLNYGX.js";import{a as z,e as D}from"./chunk-WQH3LT2P.js";import{d as U,r as O}from"./chunk-IUYFXK4X.js";import"./chunk-X7B6PLEW.js";import{a as b,e as j,f as V,g as X,h as Y}from"./chunk-3XIESWL4.js";var K=j(X(),1),W=j(V(),1);var t=j(Y(),1);var de=b(()=>{let e=(0,K.c)(39),r=U(),[s,$]=(0,W.useState)(""),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:A,error:i,errorSource:S,isLoading:_,refetch:E}=P(R.getAuthAuditLog,y),C;if(e[1]!==A?.entries||e[2]!==s){let a=A?.entries??[],v=s.trim().toLowerCase();C=v===""?a:a.filter(N=>N.event.toLowerCase().includes(v)||(N.actorId??"").toLowerCase().includes(v)||(N.actorEmail??"").toLowerCase().includes(v)||(N.ip??"").toLowerCase().includes(v)||N.outcome.toLowerCase().includes(v)),e[1]=A?.entries,e[2]=s,e[3]=C}else C=e[3];let o=C,I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I=b(a=>{$(a.target.value)},"I"),e[4]=I):I=e[4];let Q=I,l;e[5]!==r?(l=r("Filter security events"),e[5]=r,e[6]=l):l=e[6];let n;e[7]!==r?(n=r("filter event, actor, IP"),e[7]=r,e[8]=n):n=e[8];let c;e[9]!==s||e[10]!==l||e[11]!==n?(c=(0,t.jsx)(k,{"aria-label":l,className:"h-8 w-56","data-testid":"aa-search",onChange:Q,placeholder:n,value:s}),e[9]=s,e[10]=l,e[11]=n,e[12]=c):c=e[12];let d;e[13]!==E?(d=b(()=>{E()},"m"),e[13]=E,e[14]=d):d=e[14];let m;e[15]!==r?(m=r("Refresh"),e[15]=r,e[16]=m):m=e[16];let u;e[17]!==d||e[18]!==m?(u=(0,t.jsx)(q,{"data-testid":"aa-refresh",onClick:d,size:"xs",type:"button",variant:"ghost",children:m}),e[17]=d,e[18]=m,e[19]=u):u=e[19];let h;e[20]!==c||e[21]!==u?(h=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u]}),e[20]=c,e[21]=u,e[22]=h):h=e[22];let f;e[23]!==i||e[24]!==S?(f=i!==null&&(0,t.jsx)(B,{error:S,testId:"aa-error"}),e[23]=i,e[24]=S,e[25]=f):f=e[25];let p;e[26]!==i||e[27]!==o.length||e[28]!==_||e[29]!==r?(p=i===null&&!_&&o.length===0&&(0,t.jsx)(M,{description:r("Authentication and security events are recorded here."),testId:"aa-empty",title:r("No security events.")}),e[26]=i,e[27]=o.length,e[28]=_,e[29]=r,e[30]=p):p=e[30];let g;e[31]!==o||e[32]!==r?(g=o.length>0&&(0,t.jsx)(z,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"aa-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(x,{children:r("time")}),(0,t.jsx)(x,{children:r("event")}),(0,t.jsx)(x,{children:r("actor")}),(0,t.jsx)(x,{children:r("ip / user agent")}),(0,t.jsx)(x,{children:r("outcome")})]})}),(0,t.jsx)(J,{children:o.map(a=>(0,t.jsxs)(T,{"data-testid":"aa-row",children:[(0,t.jsx)(w,{className:"text-muted-foreground tabular-nums",children:O(a.ts,"\u2014")}),(0,t.jsx)(w,{children:(0,t.jsx)(F,{variant:"secondary",children:a.event})}),(0,t.jsx)(w,{className:"max-w-[24ch] truncate font-mono text-xs",title:a.actorId??void 0,children:a.actorEmail??a.actorId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsxs)(w,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:a.userAgent??void 0,children:[a.ip??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),a.userAgent!==void 0&&(0,t.jsxs)("span",{className:"ml-1 opacity-70",children:["\xB7 ",a.userAgent]})]}),(0,t.jsx)(w,{children:(0,t.jsx)(F,{variant:a.outcome==="failure"?"destructive":"outline",children:r(a.outcome)})})]},a.seq))})]})})}),e[31]=o,e[32]=r,e[33]=g):g=e[33];let L;return e[34]!==f||e[35]!==p||e[36]!==g||e[37]!==h?(L=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[h,f,p,g]}),e[34]=f,e[35]=p,e[36]=g,e[37]=h,e[38]=L):L=e[38],L},"ce");export{de as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as G}from"./chunk-V53KNYRN.js";import{a as g}from"./chunk-5Y3QLNWX.js";import{a as B}from"./chunk-RMN2JN4S.js";import{b as U}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as O}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{a as h}from"./chunk-MWIKAR7F.js";import"./chunk-DJZYD5I5.js";import"./chunk-2OUPA2WJ.js";import{b as w}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as M}from"./chunk-VDW32UET.js";import{f as D}from"./chunk-LYVP5PT6.js";import"./chunk-XBDKZZ67.js";import{d as K,e as _,f as z,h as P,o as q,r as E}from"./chunk-IUYFXK4X.js";import"./chunk-X7B6PLEW.js";import{a as s,e as T,f as ie,h as oe}from"./chunk-3XIESWL4.js";var i=T(ie(),1);var e=T(oe(),1);var de=s(r=>r.kind==="id"?r.table===void 0?"id":`id<${r.table}>`:r.kind==="array"?r.element===void 0?"array":`${r.element}[]`:r.kind,"ie"),le=s(r=>r===void 0||r.length===0?"()":`(${r.map(o=>`${o.name}${o.optional?"?":""}: ${de(o)}`).join(", ")})`,"oe"),ue=s(r=>{switch(r){case"array":return[];case"bigint":case"number":return 0;case"boolean":return!1;case"object":case"record":return{};default:return""}},"de"),ce=s(r=>{let o={};for(let a of r??[])a.optional||(o[a.name]=ue(a.kind));return JSON.stringify(o,void 0,2)},"le"),me=z(M.runAs),fe=10,pe=s(r=>r===void 0?"undefined":JSON.stringify(r,null,2),"me"),Fe=s(({functions:r,runAsIdentity:o=!1}={})=>{let a=K(),c=D(),[H,Q]=(0,i.useState)(null),[k,V]=(0,i.useState)(null),x=r??H??[],[I,S]=(0,i.useState)(""),[m,b]=(0,i.useState)("{}"),[u,F]=(0,i.useState)(""),[f,W]=(0,i.useState)(""),[v,p]=(0,i.useState)("idle"),[X,y]=(0,i.useState)(void 0),[C,N]=(0,i.useState)(null),[$,Y]=(0,i.useState)([]);(0,i.useEffect)(()=>{if(r!==void 0)return;let t=!1;return c.listFunctions().then(d=>(t||Q(d),d)).catch(d=>{t||V(P(d))}),()=>{t=!0}},[c,r]);let R=I===""?x[0]?.path??"":I,n=x.find(t=>t.path===R),Z=s(async()=>{if(!n)return;let t;try{t=m.trim()===""?{}:JSON.parse(m)}catch(l){p("error"),y(void 0),N(a("Invalid JSON args: {message}",{message:l.message}));return}let d={__lunoraRef:n.path},j=u.trim()===""?{}:{shardKey:u.trim()},A=o?f.trim():"",J=s(l=>{Y(L=>[{argsText:m,at:Date.now(),id:(L[0]?.id??0)+1,kind:n.kind,path:n.path,shardKey:u,status:l},...L].slice(0,fe))},"j");p("running"),N(null);try{let l=A===""?await _(c,n.kind,d,t,j):await c.query(me,{args:t,functionPath:n.path,userId:A},j);U(u),y(l),p("success"),J("success")}catch(l){y(void 0),N(l.message),p("error"),J("error")}},"_"),ee=s(t=>{S(t.path),b(t.argsText),F(t.shardKey)},"q"),te=s(t=>{S(t.target.value)},"B"),re=s(t=>{b(t.target.value)},"D"),ae=s(t=>{W(t.target.value)},"E"),se=s(()=>{q(Z())},"U"),ne=s(()=>{b(ce(n?.args))},"X");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[k!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:k}),(0,e.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)(g,{htmlFor:"function-select",children:a("Function")}),(0,e.jsx)("select",{"aria-label":a("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:te,value:R,children:x.map(t=>(0,e.jsxs)("option",{value:t.path,children:[t.path," (",t.kind,")"]},t.path))}),n!==void 0&&(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"mr-1.5 font-medium",children:a("Signature")}),(0,e.jsx)("code",{className:"font-mono","data-testid":"function-signature",children:le(n.args)})]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)(g,{htmlFor:"args-input",children:a("Arguments")}),(0,e.jsx)(h,{"data-testid":"prefill-button",disabled:n===void 0,onClick:ne,size:"xs",type:"button",variant:"ghost",children:a("Prefill")})]}),(0,e.jsx)(G,{"aria-label":a("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:re,value:m})]}),(0,e.jsx)(B,{onChange:F,testId:"shard-input",value:u}),o&&(0,e.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[(0,e.jsx)(g,{htmlFor:"run-as-input",children:a("Run as identity (userId)")}),(0,e.jsx)(O,{"aria-label":a("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:ae,placeholder:a("Leave empty to run as admin"),value:f}),(0,e.jsx)("p",{className:"text-[11px] text-muted-foreground",children:a("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(h,{"data-testid":"run-button",disabled:v==="running"||n===void 0,onClick:se,type:"button",children:a("Run")}),n!==void 0&&(0,e.jsx)(w,{variant:"outline",children:n.kind}),o&&f.trim()!==""&&(0,e.jsx)(w,{"data-testid":"run-as-badge",variant:"secondary",children:a("as {userId}",{userId:f.trim()})})]})]}),v==="error"&&C!==null&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:C}),v==="success"&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:pe(X)}),$.length>0&&(0,e.jsx)("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:$.map((t,d)=>(0,e.jsxs)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[(0,e.jsx)("span",{className:t.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${d.toString()}`,children:t.status==="success"?"\u2713":"\u2717"})," ",(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t.path," (",t.kind,")"]})," ",(0,e.jsx)("time",{className:"text-xs text-muted-foreground",children:E(t.at)})," ",(0,e.jsx)(h,{className:"ml-auto","data-testid":`fn-history-load-${d.toString()}`,onClick:s(()=>{ee(t)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Load")})]},t.id))})]})},"Ie");export{Fe as FunctionRunner};
|