shapewall 0.6.0 → 0.7.1
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/CHANGELOG.md +267 -0
- package/README.md +39 -2
- package/THIRD_PARTY.md +15 -0
- package/dist/agent/package-lock.json +594 -2
- package/dist/client/assets/{BoardChat-DdwBcb2N.js → BoardChat-Bv4UDOjO.js} +1 -1
- package/dist/client/assets/{BuzzDialog-DpUcnU6S.js → BuzzDialog-DwEAN6va.js} +1 -1
- package/dist/client/assets/{ChecksPanel-CngYV4yz.js → ChecksPanel-C6r_Tc9g.js} +1 -1
- package/dist/client/assets/{History-CD0saQA5.js → History-ajFROfWC.js} +1 -1
- package/dist/client/assets/{LocalSettings-MZy2baig.js → LocalSettings-BSbmmpbN.js} +1 -1
- package/dist/client/assets/{Management-CSvZ-SHO.js → Management-mo8uv2qG.js} +1 -1
- package/dist/client/assets/{QuickConnect-foLh2QUm.js → QuickConnect-DlaijESK.js} +1 -1
- package/dist/client/assets/{ShareDialog-DPWDftoL.js → ShareDialog-CdLdd6WQ.js} +1 -1
- package/dist/client/assets/{app-update-dialog-CtiXpTRD.js → app-update-dialog-BHVNR5Cp.js} +1 -1
- package/dist/client/assets/{circle-x-CteRBtXC.js → circle-x-D5MkDLJk.js} +1 -1
- package/dist/client/assets/index-B4AoX3ZW.css +2 -0
- package/dist/client/assets/index-CQeHY7en.js +37 -0
- package/dist/client/assets/{play-BjRNIGSf.js → play--xrZ7VCR.js} +1 -1
- package/dist/client/assets/{refresh-cw-r_tZiFfB.js → refresh-cw-B-npxKae.js} +1 -1
- package/dist/client/assets/{ui-zQpn-PdL.js → ui-2lMx-4bc.js} +2 -2
- package/dist/client/build-info.json +1 -1
- package/dist/client/index.html +3 -3
- package/dist/client/sw.js +2 -2
- package/dist/console/assets/LocalAccountsApp-C1sCag6a.js +1 -0
- package/dist/console/assets/LocalConsole-LXQmzRFT.js +2 -0
- package/dist/console/assets/LocalUsage-Br3Ddp7_.js +1 -0
- package/dist/console/assets/app-update-dialog-CVniDJKA.js +1 -0
- package/dist/console/assets/app-version-CTHwlY6g.js +1 -0
- package/dist/console/assets/console-CMNNLtFw.js +11 -0
- package/dist/console/assets/console-sMMn_Rwc.css +2 -0
- package/dist/console/assets/local-agents-DwYJ9cPb.js +6 -0
- package/dist/console/assets/minus-887msXez.js +1 -0
- package/dist/console/assets/tailnet--wXsG3uh.js +2 -0
- package/dist/console/assets/theme-CPfJOmcz.js +1 -0
- package/dist/console/assets/ui-DnyJhoQU.js +41 -0
- package/dist/console/assets/usage-C5CJHejQ.js +5 -0
- package/dist/console/assets/usage-CIPWnHaS.css +1 -0
- package/dist/console/assets/usage-DjmUlnXL.js +56 -0
- package/dist/console/build-info.json +1 -1
- package/dist/console/console.html +8 -2
- package/docs/agent-hardening.md +31 -17
- package/docs/agents.md +35 -0
- package/docs/architecture.md +10 -4
- package/docs/deployment.md +39 -17
- package/docs/design-system.md +56 -7
- package/docs/hosted.md +1004 -43
- package/docs/images/board-overview.png +0 -0
- package/docs/images/journeys.png +0 -0
- package/docs/images/live-comment.png +0 -0
- package/docs/images/phone-comment.png +0 -0
- package/docs/images/phone-overview.png +0 -0
- package/docs/images/variant.png +0 -0
- package/docs/where-to-run.md +82 -1
- package/package.json +6 -1
- package/src/agent/backends/acp.js +224 -26
- package/src/agent/routes.js +21 -0
- package/src/agent/usage-log.js +251 -0
- package/src/cli/args.js +24 -0
- package/src/cli/help.js +37 -2
- package/src/cli/init.js +2 -1
- package/src/cli/serve.js +20 -5
- package/src/cli.js +8 -0
- package/src/hosted/access-cli.js +99 -1
- package/src/hosted/activity-core.js +232 -0
- package/src/hosted/activity.js +375 -0
- package/src/hosted/admin.js +80 -13
- package/src/hosted/agent-approvals.js +2 -2
- package/src/hosted/agent-routes.js +3 -3
- package/src/hosted/agents.js +11 -4
- package/src/hosted/app.js +89 -7
- package/src/hosted/auth-routes.js +156 -15
- package/src/hosted/auth.js +123 -20
- package/src/hosted/board-routes.js +3 -3
- package/src/hosted/chat-frames.js +5 -15
- package/src/hosted/chat-permissions.js +12 -0
- package/src/hosted/chat-routes.js +8 -8
- package/src/hosted/chat-store.js +20 -3
- package/src/hosted/comment-files.js +5 -2
- package/src/hosted/console-routes.js +111 -34
- package/src/hosted/db.js +130 -0
- package/src/hosted/device-routes.js +25 -3
- package/src/hosted/device.js +23 -4
- package/src/hosted/guards.js +337 -27
- package/src/hosted/http.js +6 -3
- package/src/hosted/membership.js +13 -2
- package/src/hosted/operator-access.js +418 -0
- package/src/hosted/operator.js +106 -2
- package/src/hosted/ops-cli.js +238 -3
- package/src/hosted/pages.js +2 -0
- package/src/hosted/passkey-policy.js +75 -0
- package/src/hosted/permissions.js +14 -6
- package/src/hosted/presence.js +14 -2
- package/src/hosted/projects.js +2 -1
- package/src/hosted/public.js +4 -4
- package/src/hosted/ratelimit.js +6 -0
- package/src/hosted/retention.js +18 -2
- package/src/hosted/server.js +123 -11
- package/src/hosted/shares.js +2 -2
- package/src/hosted/step-up-settings.js +68 -0
- package/src/hosted/step-up.js +135 -0
- package/src/hosted/tailnet-identity.js +24 -0
- package/src/hosted/tailnet-routes.js +342 -0
- package/src/hosted/tailnet.js +220 -0
- package/src/hosted/tailscale.js +75 -9
- package/src/hosted/tenancy.js +48 -1
- package/src/hosted/token-api.js +2 -2
- package/src/hosted/tokens.js +9 -2
- package/src/hosted/usage-core.js +624 -0
- package/src/hosted/usage-layout.js +724 -0
- package/src/hosted/usage-routes.js +375 -0
- package/src/hosted/usage-shape.js +256 -0
- package/src/hosted/usage.js +641 -0
- package/src/remote/agent-connect.js +37 -1
- package/src/remote/agent-link.js +2 -0
- package/src/remote/login.js +33 -8
- package/src/remote/share.js +1 -1
- package/src/remote/tailnet-cli.js +547 -0
- package/src/server/app.js +15 -0
- package/src/server/pairing-routes.js +34 -5
- package/src/server/tailscale.js +97 -4
- package/src/tailnet-proof.js +766 -0
- package/dist/client/assets/index-Cxz1UVcV.css +0 -2
- package/dist/client/assets/index-uUZVBYUS.js +0 -37
- package/dist/console/assets/LocalAccountsApp-DIdy1KnN.js +0 -1
- package/dist/console/assets/LocalConsole-DfcQztF-.js +0 -1
- package/dist/console/assets/app-update-dialog-ttl9lF5A.js +0 -1
- package/dist/console/assets/console-OqAjD0kV.js +0 -55
- package/dist/console/assets/console-kvjrAArQ.css +0 -2
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{A as e,At as t,C as n,D as r,Dt as i,E as a,F as o,Ft as s,It as c,J as l,Lt as u,Mt as d,Nt as f,P as p,Pt as m,Rt as h,S as g,U as _,Vt as v,Y as y,_ as b,_t as x,c as S,ct as C,d as w,g as T,h as E,j as D,kt as O,l as k,p as A,t as j,u as M,v as N,w as ee,x as P,y as F,zt as I}from"./ui-DnyJhoQU.js";import{S as L,_ as te,a as ne,b as re,d as ie,f as ae,g as R,m as oe,p as se,x as ce,y as le}from"./tailnet--wXsG3uh.js";import{$ as z,D as ue,Et as B,F as V,G as de,L as fe,N as H,Q as U,R as pe,Tt as me,U as W,_ as G,_t as he,a as K,at as ge,b as _e,c as ve,ct as ye,dt as be,gt as xe,ht as Se,it as Ce,m as we,mt as Te,o as Ee,p as De,pt as Oe,rt as ke,u as Ae,v as je,wt as Me,x as Ne,xt as Pe,yt as Fe}from"./theme-CPfJOmcz.js";import{A as Ie,M as Le,S as Re,k as ze,v as Be,y as Ve}from"./local-agents-DwYJ9cPb.js";import{A as He,B as Ue,C as We,D as Ge,E as Ke,F as qe,I as Je,L as Ye,M as Xe,N as Ze,O as Qe,P as $e,R as et,S as tt,T as nt,_ as rt,a as it,b as at,c as ot,d as st,f as ct,g as lt,h as ut,i as dt,j as ft,k as pt,l as mt,m as ht,n as gt,o as _t,p as vt,r as q,s as yt,t as bt,u as xt,v as St,w as Ct,x as J,y as wt,z as Tt}from"./usage-DjmUlnXL.js";var Et={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};Et.node;var Dt=c(Et),Ot={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};Ot.node;var kt=c(Ot),At={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};At.node;var jt=c(At),Mt={name:`calendar-days`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M8 13h.01`,key:`1sbv64`}],[`path`,{d:`M12 13h.01`,key:`y0uutt`}],[`path`,{d:`M16 13h.01`,key:`wip0gl`}],[`path`,{d:`M8 17h.01`,key:`p3bg7i`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M16 17h.01`,key:`ql8jdd`}]]};Mt.node;var Nt=c(Mt),Pt={name:`chart-pie`,size:24,node:[[`path`,{d:`M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z`,key:`pzmjnu`}],[`path`,{d:`M21.21 15.89A10 10 0 1 1 8 2.83`,key:`k2fpak`}]],aliases:[`pie-chart`]};Pt.node;var Ft=c(Pt),It={name:`chevrons-left-right`,size:24,node:[[`path`,{d:`m9 7-5 5 5 5`,key:`j5w590`}],[`path`,{d:`m15 7 5 5-5 5`,key:`1bl6da`}]]};It.node;var Lt=c(It),Rt={name:`chevrons-right-left`,size:24,node:[[`path`,{d:`m20 17-5-5 5-5`,key:`30x0n2`}],[`path`,{d:`m4 17 5-5-5-5`,key:`16spf4`}]]};Rt.node;var zt=c(Rt),Bt={name:`circle-dollar-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`,key:`1h4pet`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}]]};Bt.node;var Vt=c(Bt),Ht={name:`coins`,size:24,node:[[`path`,{d:`M13.744 17.736a6 6 0 1 1-7.48-7.48`,key:`bq4yh3`}],[`path`,{d:`M15 6h1v4`,key:`11y1tn`}],[`path`,{d:`m6.134 14.768.866-.5 2 3.464`,key:`17snzx`}],[`circle`,{cx:`16`,cy:`8`,r:`6`,key:`14bfc9`}]]};Ht.node;var Ut=c(Ht),Wt={name:`columns-3`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]],aliases:[`panels-left-right`]};Wt.node;var Gt=c(Wt),Kt={name:`ellipsis-vertical`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]],aliases:[`more-vertical`]};Kt.node;var qt=c(Kt),Jt={name:`eye-off`,size:24,node:[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Jt.node;var Yt=c(Jt),Xt={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};Xt.node;var Zt=c(Xt),Qt={name:`git-compare-arrows`,size:24,node:[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]};Qt.node;var $t=c(Qt),en={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};en.node;var tn=c(en),nn={name:`hourglass`,size:24,node:[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]};nn.node;var rn=c(nn),an={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};an.node;var on=c(an),sn={name:`messages-square`,size:24,node:[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]};sn.node;var cn=c(sn),ln={name:`pin-off`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]};ln.node;var un=c(ln),dn={name:`pin`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]};dn.node;var fn=c(dn),pn={name:`printer`,size:24,node:[[`path`,{d:`M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2`,key:`143wyd`}],[`path`,{d:`M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6`,key:`1itne7`}],[`rect`,{x:`6`,y:`14`,width:`12`,height:`8`,rx:`1`,key:`1ue0tg`}]]};pn.node;var mn=c(pn),hn={name:`rows-3`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]],aliases:[`panels-top-bottom`]};hn.node;var gn=c(hn),_n={name:`rows-4`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 7.5H3`,key:`1hm9pq`}],[`path`,{d:`M21 12H3`,key:`2avoz0`}],[`path`,{d:`M21 16.5H3`,key:`n7jzkj`}]]};_n.node;var vn=c(_n),yn={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};yn.node;var bn=c(yn),xn={name:`timer`,size:24,node:[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]};xn.node;var Sn=c(xn),Cn={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};Cn.node;var wn=c(Cn),Y=v(h(),1),X=x(),Tn=Y.createContext(void 0),En=e=>{let t=Y.useContext(Tn);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Dn=({client:e,children:t})=>(Y.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,X.jsx)(Tn.Provider,{value:e,children:t})),On={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},kn=new class{#e=On;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function An(e){setTimeout(e,0)}var jn=typeof window>`u`||`Deno`in globalThis;function Mn(){}function Nn(e,t){return typeof e==`function`?e(t):e}function Pn(e){return typeof e==`number`&&e>=0&&e!==1/0}function Fn(e,t){return Math.max(e+(t||0)-Date.now(),0)}function In(e,t){return typeof e==`function`?e(t):e}function Ln(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==zn(o,t.options))return!1}else if(!Vn(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function Rn(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Bn(t.options.mutationKey)!==Bn(a))return!1}else if(!Vn(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function zn(e,t){return(t?.queryKeyHashFn||Bn)(e)}function Bn(e){return JSON.stringify(e,(e,t)=>Kn(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Vn(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){if(t.length>e.length)return!1;for(let n=0;n<t.length;n++)if(!Vn(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Vn(e[r],t[r]))return!1;return!0}return!1}var Hn=Object.prototype.hasOwnProperty;function Un(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Gn(e)&&Gn(t);if(!r&&!(Kn(e)&&Kn(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:Hn.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Un(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Wn(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n of Object.keys(e))if(!Hn.call(t,n)||e[n]!==t[n])return!1;return!0}function Gn(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Kn(e){if(!qn(e))return!1;let t=Object.getPrototypeOf(e),n=t?.constructor;if(n===void 0)return!0;if(typeof n!=`function`)return!1;let r=n.prototype;return!(!qn(r)||!r.hasOwnProperty(`isPrototypeOf`)||t!==Object.prototype)}function qn(e){return Object.prototype.toString.call(e)===`[object Object]`}function Jn(e){return new Promise(t=>{kn.setTimeout(t,e)})}function Yn(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Un(e,t)}function Xn(e){return e}function Zn(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(-n):r}function Qn(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,n):r}var $n=Symbol();function er(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===$n?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function tr(e,t){return typeof e==`function`?e(...t):!!e}var nr=Symbol();function rr(e,t,n,r){let i=!1,a;return Object.defineProperties(e,{[nr]:{value:r},signal:{enumerable:!0,get:()=>(a??=t(),i||(i=!0,a.aborted?n():a.addEventListener(`abort`,n,{once:!0})),a)}}),e}var ir=()=>jn,ar=()=>ir(),or=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},sr=new class extends or{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},cr=An;function lr(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=cr,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var ur=lr(),dr=new class extends or{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function fr(e){return Math.min(1e3*2**e,3e4)}function pr(e){return(e??`online`)!==`online`||dr.isOnline()}var mr=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function hr(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(Mn);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new mr(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>sr.isFocused()&&(e.networkMode===`always`||dr.isOnline())&&e.canRun(),p=()=>pr(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},g=t=>new Promise(n=>{r=e=>{(c()||t())&&n(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),_=()=>{if(c())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(m).catch(r=>{if(c())return;let i=e.retry??(ar()?0:3),a=e.retryDelay??fr,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);t||!s?h(r):(n++,e.onFail?.(n,r),Jn(o).then(()=>c()||f()?void 0:g(f)).then(()=>{t?h(r):_()}))})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?_():g(p).then(_),s)}}var gr=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Pn(this.gcTime)&&(this.#e=kn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ar()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(kn.clearTimeout(this.#e),this.#e=void 0)}};function _r(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=t,u=e=>{rr(e,()=>t.signal,()=>n=!0,l[nr])},d=er(t.options,t.fetchOptions),f=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return u(e),e})(),o=await d(a),{maxPages:s}=t.options,c=i?Qn:Zn;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?yr:vr,n={pages:a,pageParams:o};s=await f(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]===void 0?r.initialPageParam:o[0]:vr(r,s);if(c>0&&e==null)break;s=await f(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function vr(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function yr(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function br(e,t){return t?vr(e,t)!=null:!1}function xr(e,t){return!t||!e.getPreviousPageParam?!1:yr(e,t)!=null}var Sr=class extends gr{#e;#t;#n;#r;#i;#a;#o;#s;#c;constructor(e){super(),this.#c=!1,this.#s=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Tr(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#s,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Tr(this.options);e.data!==void 0&&(this.setState(wr(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=Yn(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(Mn).catch(Mn):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(e=>In(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===$n||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.state.data!==void 0&&this.getObserversCount()>0&&this.observers.some(e=>In(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Fn(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#c||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a&&this.#o)return this.#a.continueRetry(),this.#o}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperties(e,{[nr]:{value:n.signal,enumerable:!0},signal:{enumerable:!0,get:()=>(this.#c=!0,n.signal)}})},i=()=>{let e=er(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#c=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?_r(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=hr({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof mr&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}),s=(async()=>{try{let e=await o.promise;if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof mr){if(e.silent){if(this.#a!==o&&this.#o)return this.#o;throw e}if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0,this.#o=void 0),this.scheduleGc()}})();return this.#o=s,o.start(),s}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Cr(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...wr(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),ur.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function Cr(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:pr(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function wr(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Tr(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Er=class extends or{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Or(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return kr(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return kr(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof In(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Wn(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Ar(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||In(this.options.enabled,this.#t)!==In(t.enabled,this.#t)||In(this.options.staleTime,this.#t)!==In(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||In(this.options.enabled,this.#t)!==In(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Wn(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch(t).then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Mn)),t}#h(e){return!ar()&&In(this.options.enabled,this.#t)!==!1&&Pn(e)}#g(){this.#b();let e=In(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=Fn(this.#r.dataUpdatedAt,e)+1;this.#u=kn.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return In(this.options.refetchInterval,this.#t)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=kn.setInterval(()=>{(this.options.refetchIntervalInBackground||sr.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(kn.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(kn.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Or(e,t),o=i&&Ar(e,n,t,r);(a||o)&&(l={...l,...Cr(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=Yn(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=Yn(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=i?.error===f?i.errorUpdatedAt:Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0;return{status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:jr(e,t),refetch:this.refetch,isEnabled:In(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),Wn(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size||this.options.throwOnError&&this.#r.error!==e.error)return!0;for(let t of n??this.#p)if(this.#r[t]!==e[t])return!0;return!1})();ur.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function Dr(e,t){return In(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||In(t.retryOnMount,e)!==!1)}function Or(e,t){return Dr(e,t)||e.state.data!==void 0&&kr(e,t,t.refetchOnMount)}function kr(e,t,n){if(In(t.enabled,e)!==!1&&In(t.staleTime,e)!==`static`){let r=In(n,e);return r===`always`||r!==!1&&jr(e,t)}return!1}function Ar(e,t,n,r){return(e!==t||In(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&jr(e,n)}function jr(e,t){return In(t.enabled,e)!==!1&&e.isStaleByTime(In(t.staleTime,e))}var Mr=class extends Er{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:br(t,n.data),hasPreviousPage:xr(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},Nr=class extends gr{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Pr(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=hr({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}this.state.isPaused&&r.canStart()&&t();let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),ur.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Pr(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Fr=class extends or{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new Nr({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Ir(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Ir(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Ir(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Ir(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){ur.batch(()=>{let e=this.getAll();this.#e.clear(),this.#t.clear(),e.forEach(e=>{this.notify({type:`removed`,mutation:e})})})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Rn(t,e))}findAll(e={}){return this.getAll().filter(t=>Rn(e,t))}notify(e){ur.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return ur.batch(()=>Promise.all(e.map(e=>e.continue().catch(Mn))))}};function Ir(e){return e.options.scope?.id}var Lr=class extends or{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),Wn(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Bn(t.mutationKey)!==Bn(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Pr();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){ur.batch(()=>{let t=this.#r;if(t&&this.hasListeners()){let n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{t.onSuccess?.(e.data,n,r,i)}catch(e){Promise.reject(e)}try{t.onSettled?.(e.data,null,n,r,i)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{t.onError?.(e.error,n,r,i)}catch(e){Promise.reject(e)}try{t.onSettled?.(void 0,e.error,n,r,i)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function Rr(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var zr=class extends or{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,ur.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!Wn(e,n)});(o||s)&&(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Rr(e,n).forEach(e=>{e.destroy()}),Rr(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){let n=new Set;return t.map((r,i)=>{let a=e[i];return r.defaultedQueryOptions.notifyOnChangeProps?a:r.observer.trackResult(a,e=>{n.has(e)||(n.add(e),t.forEach(t=>{t.observer.trackProp(e)}))})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=Un(this.#a,t(e))),this.#a}return e}#f(){return!this.#r?.combine||this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new Er(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#h())}#h(){if(this.hasListeners()){let e=this.#f(),t=this.#a,n=e?t:this.#d(this.#u(this.#t,this.#l),this.#r?.combine);(e||t!==n)&&ur.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},Br=class extends or{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??zn(r,t),a=this.get(i);return a||(a=new Sr({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){this.#e.get(e.queryHash)===e&&(e.destroy(),this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){ur.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Ln(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Ln(e,t)):t}notify(e){ur.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){ur.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ur.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Vr=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Br,this.#t=e.mutationCache||new Fr,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=sr.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=dr.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(In(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=Nn(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return ur.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;ur.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return ur.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=ur.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Mn).catch(Mn)}invalidateQueries(e,t={}){return ur.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=ur.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n),r=e.state.fetchStatus===`paused`;return(!n.throwOnError||r)&&(t=t.catch(Mn)),r?Promise.resolve():t}));return Promise.all(r).then(Mn)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(In(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(In(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Mn).catch(Mn)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Mn).catch(Mn)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return dr.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Bn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Vn(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Bn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Vn(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=zn(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===$n&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Hr=Y.createContext(!1),Ur=()=>Y.useContext(Hr);Hr.Provider;function Wr(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Gr=Y.createContext(Wr()),Kr=()=>Y.useContext(Gr),qr=(e,t,n)=>{let r=n?.state.status===`error`&&typeof e.throwOnError==`function`?tr(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},Jr=e=>{Y.useEffect(()=>{e.clearReset()},[e])},Yr=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||tr(n,[e.error,r])),Xr=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Zr=(e,t)=>e?.suspense&&t.isPending,Qr=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function $r({queries:e,...t},n){let r=En(n),i=Ur(),a=Kr(),o=t.subscribed!==!1,s=Y.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:o?`optimistic`:void 0,t}),[e,r,i,o]);s.forEach(e=>{Xr(e);let t=r.getQueryCache().get(e.queryHash);qr(e,a,t)}),Jr(a);let[c]=Y.useState(()=>new zr(r,s,t)),[l,u,d]=c.getOptimisticResult(s,t.combine);Y.useEffect(()=>{c.setQueries(s,t)},[s,t,c]);let f=!i&&o;Y.useSyncExternalStore(Y.useCallback(e=>f?c.subscribe(ur.batchCalls(e)):Mn,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult());let p=l.some((e,t)=>Zr(s[t],e))?l.flatMap((e,t)=>{let n=s[t];return n&&Zr(n,e)?Qr(n,new Er(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=s[t];return n&&Yr({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m)throw m.error;return u(d())}function ei(e,t,n){let r=Ur(),i=Kr(),a=En(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Xr(o),qr(o,i,s),Jr(i);let[l]=Y.useState(()=>new t(a,o)),u=l.getOptimisticResult(o);Y.useEffect(()=>{l.setOptions(o)},[o,l]);let d=!r&&c;if(Y.useSyncExternalStore(Y.useCallback(e=>{let t=d?l.subscribe(ur.batchCalls(e)):Mn;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),Zr(o,u))throw Qr(o,l,i);if(Yr({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:l.trackResult(u)}function ti(e,t){return ei(e,Er,t)}function ni(e,t){let n=En(t),[r]=Y.useState(()=>new Lr(n,e));Y.useEffect(()=>{r.setOptions(e)},[r,e]);let i=Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(ur.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=Y.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(Mn)},[r]);if(i.error&&tr(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function ri(e,t){return ei(e,Mr,t)}var ii=[`model`],ai=(e,t)=>e.getAll(t).flatMap(e=>ii.includes(t)?[e]:e.split(`,`)).filter(Boolean);function oi(e,t){let n=new URLSearchParams(e);for(let[e,r]of Object.entries(t)){let t=typeof r==`function`?r(ai(n,e)):r;n.delete(e);for(let r of Array.isArray(t)?t:[t])r!=null&&r!==``&&r!==!1&&n.append(e,String(r))}return n.toString()}var si=e=>t=>t.includes(e)?t.filter(t=>t!==e):[...t,e],ci=new Vr({defaultOptions:{queries:{staleTime:3e4,gcTime:3e5,refetchOnWindowFocus:!1,retry:(e,t)=>e<1&&(!t?.status||t.status>=500)}}}),li=(e,t)=>p(()=>W(e.toString(),t));function ui(){let e=de(),t=(0,Y.useMemo)(()=>new URLSearchParams(e),[e]);return{params:t,search:e,get:(0,Y.useCallback)((e,n=``)=>t.get(e)??n,[t]),list:(0,Y.useCallback)(e=>ai(t,e),[t]),set:(0,Y.useCallback)((e,t)=>{p(()=>W(oi(pe(),e),t))},[])}}var di=[`agent`,`project`,`person`,`kind`,`model`,`outcome`],fi=[`tokensMin`,`tokensMax`,`durationMin`,`durationMax`],pi=[`row`,`view`];function mi(){let e=ui(),{params:t}=e,n=(0,Y.useMemo)(()=>Ke({range:t.get(`range`)||`30d`,from:t.get(`from`),to:t.get(`to`)}),[t]),r=(0,Y.useMemo)(()=>{let e=new URLSearchParams;e.set(`from`,n.from.toISOString()),e.set(`to`,n.to.toISOString()),e.set(`prevFrom`,n.previous.from.toISOString()),e.set(`prevTo`,n.previous.to.toISOString()),e.set(`tz`,Qe());for(let n of di)for(let r of t.getAll(n).flatMap(e=>ii.includes(n)?[e]:e.split(`,`)))r&&e.append(n,r);for(let n of[...fi,`q`])t.get(n)&&e.set(n,t.get(n));return e.toString()},[t,n]),i=[...di,...fi,`q`].filter(e=>t.get(e));return{...e,period:n,query:r,active:i}}var hi=e=>()=>U.get(e);function gi(e,t,{enabled:n=!0,keep:r=!0}={}){let i=ke(e,t);return ti({queryKey:[i],queryFn:hi(i),enabled:n,placeholderData:r?Xn:void 0})}function _i(e,t,{next:n,enabled:r=!0,key:i}){return ri({queryKey:[ke(e,t(null)),...i||[]],queryFn:({pageParam:n})=>U.get(ke(e,t(n))),initialPageParam:null,getNextPageParam:e=>n(e)??void 0,enabled:r,placeholderData:Xn})}function vi(e,t){let n=En(),r=ke(e,`/views?page=${t}`),i=ti({queryKey:[r],queryFn:hi(r)}),a=()=>n.invalidateQueries({queryKey:[r]}),o=ni({mutationFn:n=>U.post(ke(e,`/views`),{page:t,...n}),onSuccess:a}),s=ni({mutationFn:t=>U.delete(ke(e,`/views/${t}`)),onSuccess:a});return{views:i.data?.views||[],loading:i.isLoading,save:o,remove:s}}var yi=`inline-flex h-9 max-w-full items-center gap-1.5 rounded-md border px-2.5 text-xs font-medium outline-none focus-visible:outline-2 focus-visible:outline-accent`,bi=`border-line bg-surface text-fg hover:bg-surface-2`,xi=`border-accent/50 bg-accent/10 text-fg`,Si=e=>e===``?`~`:e,Ci=e=>e===`~`?``:e;function wi({period:e,onChange:t}){let[n,r]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{n&&(o(St(e.from)),c(St(new Date(e.to.getTime()-864e5))))},[n,e]);let u=e=>{t(e),r(!1)},d=a&&s&&a<=s;return(0,X.jsxs)(b,{open:n,onOpenChange:r,history:!1,children:[(0,X.jsx)(F,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,className:i(yi,bi),"data-sw-period":!0,children:[(0,X.jsx)(Nt,{size:14,className:`text-muted`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.label}),(0,X.jsx)(f,{size:13,className:`text-muted`,"aria-hidden":`true`})]})}),(0,X.jsxs)(N,{className:`w-64 p-1.5`,children:[(0,X.jsx)(`ul`,{role:`listbox`,"aria-label":`Period`,children:ut.map(([t,n])=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e.range===t,onClick:()=>u({range:t===`30d`?null:t,from:null,to:null}),className:`flex h-9 w-full items-center justify-between rounded-md px-2.5 text-sm text-fg outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent`,"data-sw-period-preset":t,children:[n,e.range===t?(0,X.jsx)(m,{size:16,strokeWidth:3,className:`text-accent`,"aria-hidden":`true`}):null]})},t))}),(0,X.jsxs)(`form`,{className:`mt-1.5 border-t border-line px-1 pt-2.5 pb-1`,onSubmit:e=>{e.preventDefault(),d&&u({range:`custom`,from:a,to:s})},children:[(0,X.jsxs)(`p`,{className:`mb-1.5 flex items-center justify-between text-xs font-medium text-fg`,children:[`Custom range`,e.range===`custom`?(0,X.jsx)(m,{size:16,strokeWidth:3,className:`text-accent`,"aria-hidden":`true`}):null]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,X.jsxs)(`label`,{className:`text-caption text-muted`,children:[`From`,(0,X.jsx)(P,{type:`date`,value:a,max:s||void 0,onChange:e=>o(e.target.value),className:`mt-0.5`,"data-sw-period-from":!0})]}),(0,X.jsxs)(`label`,{className:`text-caption text-muted`,children:[`To`,(0,X.jsx)(P,{type:`date`,value:s,min:a||void 0,onChange:e=>c(e.target.value),className:`mt-0.5`,"data-sw-period-to":!0})]})]}),(0,X.jsx)(l,{type:`submit`,size:`sm`,variant:`default`,disabled:!d,className:`mt-2 w-full`,"data-sw-period-apply":!0,children:`Apply`}),(0,X.jsx)(`p`,{className:`mt-1.5 text-caption text-muted`,children:`Days are in your time zone. Up to 400 days.`})]})]})]})}function Ti({id:e,label:n,options:r,values:a,onToggle:o,onChange:s}){let[c,u]=(0,Y.useState)(!1),[d,p]=(0,Y.useState)(``),h=new Set(a.map(Ci)),g=r.filter(e=>!d||e.label.toLowerCase().includes(d.toLowerCase())),_=e=>o(Si(e)),v=r.find(e=>h.has(e.key));return(0,X.jsxs)(b,{open:c,onOpenChange:u,history:!1,children:[(0,X.jsx)(F,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,className:i(yi,h.size?xi:bi),"data-sw-filter":e,children:[(0,X.jsxs)(`span`,{className:`truncate`,children:[n,h.size?`: ${v?.label||[...h][0]||`none`}${h.size>1?` +${h.size-1}`:``}`:``]}),(0,X.jsx)(f,{size:13,className:`shrink-0 text-muted`,"aria-hidden":`true`})]})}),(0,X.jsxs)(N,{className:`w-64 p-1.5`,children:[r.length>8?(0,X.jsx)(P,{icon:se,value:d,onChange:e=>p(e.target.value),placeholder:`Find ${n.toLowerCase()}`,"aria-label":`Find ${n.toLowerCase()}`,className:`mb-1`}):null,(0,X.jsxs)(`ul`,{className:`max-h-64 overflow-y-auto`,role:`listbox`,"aria-label":n,"aria-multiselectable":`true`,children:[g.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":h.has(e.key),onClick:()=>_(e.key),className:`flex min-h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent`,"data-sw-filter-option":Si(e.key),children:[(0,X.jsx)(`span`,{className:i(`inline-flex h-4 w-4 shrink-0 items-center justify-center rounded border`,h.has(e.key)?`border-accent bg-accent text-accent-fg`:`border-line-strong bg-surface`),"aria-hidden":`true`,children:h.has(e.key)?(0,X.jsx)(m,{size:12,strokeWidth:3}):null}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate`,children:e.label}),e.hint?(0,X.jsx)(`span`,{className:`block truncate text-caption text-muted`,children:e.hint}):null]}),e.calls===void 0?null:(0,X.jsx)(`span`,{className:`tabular text-xs text-muted`,children:J(e.calls)})]})},e.key)),g.length?null:(0,X.jsx)(`li`,{className:`px-2 py-3 text-center text-xs text-muted`,children:`Nothing matches.`})]}),h.size?(0,X.jsx)(`div`,{className:`mt-1 border-t border-line pt-1`,children:(0,X.jsxs)(l,{size:`sm`,variant:`ghost`,className:`w-full justify-start`,onClick:()=>s([]),children:[(0,X.jsx)(t,{size:13,"aria-hidden":`true`}),` Clear`]})}):null]})]})}function Ei({get:e,set:t}){let[n,r]=(0,Y.useState)(!1),a=()=>({tokensMin:e(`tokensMin`),tokensMax:e(`tokensMax`),durationMin:e(`durationMin`)?String(Number(e(`durationMin`))/1e3):``,durationMax:e(`durationMax`)?String(Number(e(`durationMax`))/1e3):``}),[o,s]=(0,Y.useState)(a);(0,Y.useEffect)(()=>{n&&s(a())},[n]);let c=fi.filter(t=>e(t)).length,u=(e,t=1)=>e!==``&&Number.isFinite(Number(e))&&Number(e)>=0?String(Math.round(Number(e)*t)):null,d=e=>{e.preventDefault(),t({tokensMin:u(o.tokensMin),tokensMax:u(o.tokensMax),durationMin:u(o.durationMin,1e3),durationMax:u(o.durationMax,1e3)}),r(!1)},f=(e,t)=>(0,X.jsxs)(`label`,{className:`text-caption text-muted`,children:[t,(0,X.jsx)(P,{type:`number`,min:`0`,inputMode:`numeric`,value:o[e],onChange:t=>s({...o,[e]:t.target.value}),className:`mt-0.5`,"data-sw-range":e})]});return(0,X.jsxs)(b,{open:n,onOpenChange:r,history:!1,children:[(0,X.jsx)(F,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,className:i(yi,c?xi:bi),"data-sw-filter":`ranges`,children:[(0,X.jsx)(bn,{size:14,className:`text-muted`,"aria-hidden":`true`}),`Ranges`,c?`: ${c}`:``]})}),(0,X.jsx)(N,{className:`w-64 p-3`,children:(0,X.jsxs)(`form`,{onSubmit:d,className:`space-y-3`,children:[(0,X.jsxs)(`fieldset`,{children:[(0,X.jsx)(`legend`,{className:`mb-1 text-xs font-medium text-fg`,children:`Tokens (input plus output)`}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[f(`tokensMin`,`At least`),f(`tokensMax`,`At most`)]})]}),(0,X.jsxs)(`fieldset`,{children:[(0,X.jsx)(`legend`,{className:`mb-1 text-xs font-medium text-fg`,children:`Duration, in seconds`}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[f(`durationMin`,`At least`),f(`durationMax`,`At most`)]})]}),(0,X.jsx)(`p`,{className:`text-caption text-muted`,children:`A range leaves out turns that did not report the number.`}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(l,{type:`submit`,size:`sm`,variant:`default`,className:`flex-1`,"data-sw-range-apply":!0,children:`Apply`}),c?(0,X.jsx)(l,{size:`sm`,variant:`ghost`,onClick:()=>{t(Object.fromEntries(fi.map(e=>[e,null]))),r(!1)},children:`Clear`}):null]})]})})]})}function Di({value:e,onChange:t}){let[n,r]=(0,Y.useState)(e);return(0,Y.useEffect)(()=>r(e),[e]),(0,Y.useEffect)(()=>{if(n.trim()===e)return;let r=window.setTimeout(()=>t(n.trim()),350);return()=>window.clearTimeout(r)},[n,e,t]),(0,X.jsx)(P,{icon:se,value:n,onChange:e=>r(e.target.value),placeholder:`Search ids`,"aria-label":`Search by an id: a turn, an agent, a project, a board or a comment number`,maxLength:80,wrapperClassName:`w-full sm:w-44`,className:`h-9`,"data-sw-usage-search":!0})}function Oi(e){return(0,Y.useMemo)(()=>{let t=t=>e?.[t]||[];return{agent:t(`agent`).map(e=>({key:e.key,label:e.label,hint:e.machine||null,calls:e.calls})),project:t(`project`).map(e=>({key:e.key,label:e.label,calls:e.calls})),person:t(`person`).map(e=>({key:e.key,label:e.label,hint:e.handle?`@${e.handle}`:null,calls:e.calls})),model:t(`model`).map(e=>({key:e.key,label:e.label,calls:e.calls})),kind:Tt.map(e=>({key:e,label:Ze[e],calls:t(`kind`).find(t=>t.key===e)?.calls})),outcome:qe.map(e=>({key:e,label:Je[e],calls:t(`outcome`).find(t=>t.key===e)?.calls}))}},[e])}function ki({filter:e,options:n,children:r}){let{period:i,get:a,list:s,set:c,active:u}=e,d=Oi(n),f=o(`(max-width: 639px)`),p=(e,t)=>d[e].find(e=>e.key===Ci(t))?.label||(t===`~`?`None`:t),m=[];for(let e of di)for(let t of s(e))m.push({id:`${e}:${t}`,text:`${Xe[e]}: ${p(e,t)}`,clear:()=>c({[e]:e=>e.filter(e=>e!==t)},{push:!0})});for(let e of fi)if(a(e)){let t=e.startsWith(`duration`),n=`${t?`Duration`:`Tokens`} ${e.endsWith(`Min`)?`at least`:`at most`} ${t?`${Number(a(e))/1e3} s`:J(Number(a(e)),{exact:!0})}`;m.push({id:e,text:n,clear:()=>c({[e]:null},{push:!0})})}return a(`q`)&&m.push({id:`q`,text:`Id contains "${a(`q`)}"`,clear:()=>c({q:null},{push:!0})}),(0,X.jsxs)(`div`,{className:`mb-4 print:hidden`,"data-sw-usage-filters":!0,children:[(0,X.jsxs)(`div`,{className:`sw-scroll-x -mx-3 flex items-center gap-1.5 overflow-x-auto px-3 pb-1 sm:mx-0 sm:flex-wrap sm:overflow-visible sm:px-0 sm:pb-0 [&>*]:shrink-0`,children:[(0,X.jsx)(wi,{period:i,onChange:e=>c(e,{push:!0})}),di.map(e=>(0,X.jsx)(Ti,{id:e,label:Xe[e],options:d[e],values:s(e),onToggle:t=>c({[e]:si(t)},{push:!0}),onChange:t=>c({[e]:t},{push:!0})},e)),(0,X.jsx)(Ei,{get:a,set:e=>c(e,{push:!0})}),f?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Di,{value:a(`q`),onChange:e=>c({q:e||null})}),(0,X.jsx)(`span`,{className:`ml-auto flex items-center gap-1.5`,children:r})]})]}),f?(0,X.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,X.jsx)(Di,{value:a(`q`),onChange:e=>c({q:e||null})}),(0,X.jsx)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:r})]}):null,m.length?(0,X.jsxs)(`ul`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,"aria-label":`Filters in effect`,"data-sw-usage-chips":!0,children:[m.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,onClick:e.clear,className:`inline-flex h-7 max-w-[16rem] items-center gap-1 rounded-full border border-line bg-surface-2 pr-1.5 pl-2.5 text-xs text-fg outline-none hover:border-line-strong focus-visible:outline-2 focus-visible:outline-accent`,"aria-label":`Remove the filter ${e.text}`,"data-sw-chip":e.id,children:[(0,X.jsx)(`span`,{className:`truncate`,children:e.text}),(0,X.jsx)(t,{size:12,className:`shrink-0 text-muted`,"aria-hidden":`true`})]})},e.id)),(0,X.jsx)(`li`,{children:(0,X.jsx)(l,{size:`xs`,variant:`ghost`,onClick:()=>c(Object.fromEntries(u.map(e=>[e,null])),{push:!0}),"data-sw-usage-clear":!0,children:`Clear all`})})]}):null]})}function Ai({workspaceId:t,page:o,search:s,onOpen:c,layout:u=null}){let{views:d,save:p,remove:h}=vi(t,o),g=H(),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(``),[w,T]=(0,Y.useState)(!0),E=(0,Y.useMemo)(()=>new URLSearchParams(s).get(`view`),[s]),O=(0,Y.useMemo)(()=>{let e=new URLSearchParams(s);for(let t of pi)e.delete(t);return e.toString()},[s]),k=d.find(e=>e.query===O&&(!E||e.id===E))||d.find(e=>e.query===O),A=e=>e.hasLayout?`${e.query}${e.query?`&`:``}view=${e.id}`:e.query;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(n,{open:v,onOpenChange:y,children:[(0,X.jsx)(D,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,className:i(yi,k?xi:bi),"data-sw-views":!0,children:[(0,X.jsx)(jt,{size:14,className:`text-muted`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`max-w-[9rem] truncate`,children:k?k.name:`Views`}),(0,X.jsx)(f,{size:13,className:`text-muted`,"aria-hidden":`true`})]})}),(0,X.jsxs)(ee,{className:`w-64`,children:[(0,X.jsx)(r,{children:`Your saved views`}),d.length?d.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center`,children:[(0,X.jsxs)(a,{className:`min-w-0 flex-1`,onSelect:()=>c(A(e)),"data-sw-view":e.name,children:[(0,X.jsx)(`span`,{className:`truncate`,children:e.name}),e.hasLayout?(0,X.jsx)(ze,{size:13,"aria-label":`Carries a layout`,"data-sw-view-has-layout":!0}):null,k?.id===e.id?(0,X.jsx)(m,{size:14,className:`ml-auto text-accent`,"aria-hidden":`true`}):null]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Delete the view ${e.name}`,onClick:()=>h.mutate(e.id),className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted outline-none hover:bg-surface-2 hover:text-bad focus-visible:outline-2 focus-visible:outline-accent`,"data-sw-view-delete":e.name,children:(0,X.jsx)(Ve,{size:13,"aria-hidden":`true`})})]},e.id)):(0,X.jsx)(`p`,{className:`px-2.5 pb-1.5 text-xs text-muted`,children:`None yet. Set the filters you want, then save them here.`}),(0,X.jsx)(e,{}),(0,X.jsxs)(a,{onSelect:()=>x(!0),"data-sw-view-save":!0,children:[(0,X.jsx)(jt,{size:14,"aria-hidden":`true`}),` Save this view`]}),(0,X.jsxs)(a,{onSelect:async()=>{try{let e=_?`#${fe()}`:``,t=E||(k?.hasLayout?k.id:null),n=[O,t?`view=${t}`:``].filter(Boolean).join(`&`);await navigator.clipboard.writeText(`${window.location.origin}${window.location.pathname}${e}${n?`?${n}`:``}`),g(t?`Link copied. It carries the filters and the layout, not your access.`:`Link copied. It carries the filters, not your access.`)}catch{g(`This browser did not allow copying`,`bad`)}},"data-sw-view-link":!0,children:[(0,X.jsx)(R,{size:14,"aria-hidden":`true`}),` Copy a link to this view`]})]})]}),b?(0,X.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault();try{await p.mutateAsync({name:S,query:O,layout:w&&u?u:null}),g(w&&u?`Saved the view "${S.trim()}" with this layout`:`Saved the view "${S.trim()}"`),x(!1),C(``),T(!0)}catch(e){g(e.message,`bad`)}},className:`flex flex-wrap items-center gap-1.5`,"data-sw-view-form":!0,children:[(0,X.jsx)(P,{autoFocus:!0,value:S,onChange:e=>C(e.target.value),placeholder:`Name this view`,"aria-label":`Name this view`,maxLength:60,className:`h-9`,wrapperClassName:`w-40`,onKeyDown:e=>e.key===`Escape`?x(!1):null}),u?(0,X.jsxs)(`label`,{className:`inline-flex h-9 cursor-pointer items-center gap-1.5 text-xs text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>T(e.target.checked),className:`h-4 w-4 accent-[var(--accent)]`,"data-sw-view-with-layout":!0}),`Include this layout`]}):null,(0,X.jsx)(l,{type:`submit`,size:`md`,variant:`default`,className:`h-9`,disabled:!S.trim()||p.isPending,children:`Save`}),(0,X.jsx)(l,{size:`md`,variant:`ghost`,className:`h-9`,onClick:()=>x(!1),children:`Cancel`})]}):null]})}function ji(e){return Mi(e)||typeof e==`function`||Ni(e)}function Mi(e){return typeof e==`function`&&(()=>{let t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function Ni(e){return typeof e==`object`&&typeof e.$$typeof==`symbol`&&[`react.memo`,`react.forward_ref`].includes(e.$$typeof.description)}function Pi(e,t){return e==null?null:ji(e)?Y.createElement(e,t):e}function Fi(e){if(`cell`in e&&e.cell){let t=e.cell,n=t.column.columnDef,r=t,i=n;return r.getIsAggregated?.()?Pi(i.aggregatedCell??n.cell,t.getContext()):r.getIsPlaceholder?.()?null:Pi(n.cell,t.getContext())}return`header`in e&&e.header?Pi(e.header.column.columnDef.header,e.header.getContext()):`footer`in e&&e.footer?Pi(e.footer.column.columnDef.footer,e.footer.getContext()):null}function Ii({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0)n=e.nextSub;else{for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}}while(1)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(1)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function Li(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var Ri=[],zi=0,{link:Bi,unlink:Vi,propagate:Hi,checkDirty:Ui,shallowPropagate:Wi}=Ii({update(e){return e._update()},notify(e){Ri[Ki++]=e,e.flags&=-3},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,Xi(e))}}),Gi=0,Ki=0,qi,Ji=0;function Yi(e){try{++Ji,e()}finally{--Ji||Zi()}}function Xi(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=Vi(n,e)}function Zi(){if(!(Ji>0)){for(;Gi<Ki;){let e=Ri[Gi];Ri[Gi++]=void 0,e.notify()}Gi=0,Ki=0}}function Qi(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:+!n,get(){return qi!==void 0&&Bi(i,qi,zi),i._snapshot},subscribe(e){let t=Li(e),n={current:!1},r=$i(()=>{i.get(),n.current?(qi=void 0,t.next?.(i._snapshot)):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=qi,o=t?.compare??Object.is;if(n)qi=i,++zi,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=5);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{qi=a,n&&(i.flags&=-5),Xi(i)}}};return n?(i.flags=17,i.get=function(){let e=i.flags;if(e&16||e&32&&Ui(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&Wi(e)}}else e&32&&(i.flags=e&-33);return qi!==void 0&&Bi(i,qi,zi),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(Hi(e),Wi(e),Zi())}},i}function $i(e){let t=()=>{let t=qi;qi=n,++zi,n.depsTail=void 0,n.flags=6;try{return e()}finally{qi=t,n.flags&=-5,Xi(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let e=this.flags;e&16||e&32&&Ui(this.deps,this)?t():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,Xi(this)}};return t(),n}function ea(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();let n=ta(e);if(n.length!==ta(t).length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(t,n[r])||!Object.is(e[n[r]],t[n[r]]))return!1;return!0}function ta(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}var na=pt();function ra(e,t){return e===t}function ia(e,t=e=>e,n){let r=n?.compare??ra,i=(0,Y.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,Y.useCallback)(()=>e.get(),[e]);return(0,na.useSyncExternalStoreWithSelector)(i,a,a,t,r)}function aa(e){let t=ia(e.source,e.selector,{compare:ea});return typeof e.children==`function`?e.children(t):e.children}function oa(e){let t=e;return Object.defineProperty(e,"state",{get(){return e.get()}}),`set`in e&&(t.setState=e.set.bind(e)),t}function sa(e){let{createAtom:t,batch:n}=e,r=t(0);return{createOptionsStore:!1,wrapExternalAtoms:!1,addSubscription:()=>{throw Error(`Feature not supported in current reactivity implementation`)},unmount:()=>{throw Error(`Feature not supported in current reactivity implementation`)},schedule:e.schedule??(e=>queueMicrotask(e)),batch:n,untrack:e=>e(),createReadonlyAtom:(e,n)=>{let i=n?.compare??Object.is,a=!1,o,s=()=>{let t=e();return a&&i(o,t)||(o=t,a=!0),o},c=t(()=>(r.get(),s()),{compare:i});return{get:s,subscribe:c.subscribe.bind(c)}},createWritableAtom:(e,n)=>t(e,{compare:n?.compare}),commit:()=>{r.set(e=>e+1)}}}function ca(e,t=Object.is){let n=!1,r;return{get:e.get,markCommitted:e=>{r=e,n=!0},subscribe:i=>e.subscribe(e=>{n&&t(r,e)||i(e)})}}function la(){return sa({createAtom:Qi,batch:Yi})}function ua(e,t){return typeof e==`function`?e(t):e}function da(e){if(Array.isArray(e))return e.map(da);if(e&&typeof e==`object`){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)return e;let n=t===null?fa():{},r=Object.keys(e);for(let t=0;t<r.length;t++){let i=r[t];Object.defineProperty(n,i,{configurable:!0,enumerable:!0,value:da(e[i]),writable:!0})}return n}return e}function fa(){return Object.create(null)}function pa(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ma(e,t){return n=>{(t.options.atoms?.[e]??t.baseAtoms[e]).set(e=>ua(n,e))}}function ha(e){if(typeof e!=`object`||!e)return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ga(e){return Reflect.ownKeys(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}var _a=3;function va(e,t){return ya(e,t,_a)}function ya(e,t,n){if(Object.is(e,t))return!0;if(n<=0||!ha(e)||!ha(t)||(Array.isArray(e)||Array.isArray(t))&&(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length))return!1;let r=ga(e),i=ga(t);if(r.length!==i.length)return!1;let a=e,o=t;for(let e=0;e<r.length;e++){let i=r[e];if(!Object.prototype.propertyIsEnumerable.call(t,i)||!ya(a[i],o[i],n-1))return!1}return!0}function ba(e,t,n,r=va){let i=`on${t.charAt(0).toUpperCase()}${t.slice(1)}Change`,a=e.options[i];a&&a(e=>{let t=ua(n,e);return r(e,t)?e:t})}function xa(e){return e instanceof Function}function Sa(e,t){let n=[],r=e=>{e.forEach(e=>{n.push(e);let i=t(e);i.length&&r(i)})};return r(e),n}var Ca=({fn:e,memoDeps:t,onAfterCompare:n,onAfterUpdate:r,onBeforeCompare:i,onBeforeUpdate:a})=>{let o=[],s;return c=>{i?.();let l=t?.(c),u=!l||l.length!==o?.length;if(!u&&l){for(let e=0;e<l.length;e++)if(l[e]!==o[e]){u=!0;break}}return n?.(u),u&&(o=l,a?.(),s=e(...l??[]),r?.(s)),s}};function wa(e){let t=!1;return()=>{t?e():t=!0}}function Ta({feature:e,fnName:t,objectId:n,onAfterUpdate:r,table:i,...a}){let o={onAfterUpdate:r?()=>{let{schedule:e,untrack:t}=i._reactivity;e(()=>t(()=>r()))}:void 0};return Ca({...a,...o})}function Ea(e,t=`_`){let[n,r]=e.replace(t,` `).split(` `);return{fnKey:r,fnName:`${n}.${r}`,parentName:n}}function Da(e,t,n){for(let[r,{fn:i,memoDeps:a}]of Object.entries(n)){let{fnKey:n,fnName:o}=Ea(r);t[n]=a?Ta({memoDeps:a,fn:i,fnName:o,table:t,feature:e}):i}}function Oa(e,t,n,r){for(let[i,{fn:a,memoDeps:o}]of Object.entries(r)){let{fnKey:r,fnName:s}=Ea(i);if(o){let i=`_memo_${r}`;t[r]=function(...t){if(!this[i]){let t=this;this[i]=Ta({memoDeps:e=>o(t,e),fn:(...e)=>a(t,...e),fnName:s,objectId:t.id,table:n,feature:e})}return this[i](...t)}}else t[r]=function(...e){return a(this,...e)}}}function Z(e,t,n,...r){return e[t]?.(...r)??n(e,...r)}function ka(e){return e.row.getValue(e.column.id)}function Aa(e){return e.getValue()??e.table.options.renderFallbackValue}function ja(e){return{table:e.table,column:e.column,row:e.row,cell:e,getValue:()=>e.getValue(),renderValue:()=>e.renderValue()}}var Ma={assignCellPrototype:(e,t)=>{Oa(`coreCellsFeature`,e,t,{cell_getValue:{fn:e=>ka(e)},cell_renderValue:{fn:e=>Aa(e)},cell_getContext:{fn:e=>ja(e),memoDeps:e=>[e]}})}};function Na(e){if(!e._columnPrototype){e._columnPrototype={table:e};let t=Object.values(e._features);for(let n=0;n<t.length;n++)t[n].assignColumnPrototype?.(e._columnPrototype,e)}return e._columnPrototype}function Pa(e,t,n,r){let i={...e.getDefaultColumnDef(),...t},a=i.accessorKey,o=a===void 0?void 0:String(a),s=i.id??o?.replaceAll(`.`,`_`)??(typeof i.header==`string`?i.header:void 0),c;if(i.accessorFn)c=i.accessorFn;else if(a!==void 0){if(typeof a==`string`&&a.includes(`.`)){let e=a.split(`.`);c=t=>{let n=t;for(let t=0;t<e.length;t++){let r=e[t];n=n?.[r]}return n}}else c=e=>e[i.accessorKey]}if(!s)throw Error();let l=Na(e),u=Object.create(l);u.accessorFn=c,u.columnDef=i,u.columns=[],u.depth=n,u.id=`${String(s)}`,u.parent=r;let d=e._columnInstanceInitFns;for(let e=0;e<d.length;e++)d[e](u);return u}function Fa(e){return e.getIsVisible?.()??!0}function Ia(e){return e.getVisibleLeafColumns?.()??e.getAllLeafColumns()}function La(e){return e.getVisibleCells?.()??e.getAllCells()}function Ra(e){return e.getVisibleCellsByColumnId?.()??e.getAllCellsByColumnId()}function za(e,t){let n=e,r=t;return n.getOrderColumnsFn?.()(r)??n._orderGroupedColumns?.(r)??t}function Ba(e,t,n,r){return e._orderByColumnPinning?.(t,n,r)??t}function Va(e,t){return e.getPinnedVisibleLeafColumns?.(t)??(t&&t!==`center`?[]:Ia(e))}function Ha(e,t){return e._expandRows?.(t)??t}function Ua(e){e.autoResetExpanded?.()}function Wa(e){e.autoResetPageIndex?.()}function Ga(e){e.autoResetSorting?.()}function Ka(e){e.autoResetCellSelection?.()}function qa(e){return[e,...e.columns.flatMap(e=>e.getFlatColumns())]}function Ja(e){if(e.columns.length){let t=e.columns.flatMap(e=>e.getLeafColumns());return za(e.table,t)}return[e]}function Ya(e){return{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>e.renderValue()?.toString?.()??null,...Object.values(e._features).reduce((e,t)=>Object.assign(e,t.getDefaultColumnDef?.()),{}),...e.options.defaultColumn}}function Xa(e,t,n,r=0){let i=Array(t.length);for(let a=0;a<t.length;a++){if(!(a in t))continue;let o=t[a],s=Pa(e,o,r,n),c=o;s.columns=c.columns?Xa(e,c.columns,s,r+1):[],i[a]=s}return i}function Za(e){return Xa(e,e.options.columns)}function Qa(e){return e.getAllColumns().flatMap(e=>e.getFlatColumns())}function $a(e){let t=fa(),n=e.getAllFlatColumns();for(let e=0;e<n.length;e++){let r=n[e];t[r.id]=r}return t}function eo(e){return za(e,e.getAllColumns().flatMap(e=>e.getLeafColumns()))}function to(e){let t=fa(),n=e.getAllLeafColumns();for(let e=0;e<n.length;e++){let r=n[e];t[r.id]=r}return t}function no(e,t){return e.getAllFlatColumnsById()[t]}var ro={assignColumnPrototype:(e,t)=>{Oa(`coreColumnsFeature`,e,t,{column_getFlatColumns:{fn:e=>qa(e),memoDeps:e=>[e.table.options.columns]},column_getLeafColumns:{fn:e=>Ja(e),memoDeps:e=>[e.table.atoms.columnOrder?.get(),e.table.atoms.grouping?.get(),e.table.options.columns,e.table.options.groupedColumnMode]}})},constructTableAPIs:e=>{Da(`coreColumnsFeature`,e,{table_getDefaultColumnDef:{fn:()=>Ya(e),memoDeps:()=>[e.options.defaultColumn]},table_getAllColumns:{fn:()=>Za(e),memoDeps:()=>[e.options.columns]},table_getAllFlatColumns:{fn:()=>Qa(e),memoDeps:()=>[e.options.columns]},table_getAllFlatColumnsById:{fn:()=>$a(e),memoDeps:()=>[e.options.columns]},table_getAllLeafColumns:{fn:()=>eo(e),memoDeps:()=>[e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.options.columns,e.options.groupedColumnMode]},table_getAllLeafColumnsById:{fn:()=>to(e),memoDeps:()=>[e.getAllLeafColumns()]},table_getColumn:{fn:t=>no(e,t)}})}};function io(e){if(!e._headerPrototype){e._headerPrototype={table:e};let t=Object.values(e._features);for(let n=0;n<t.length;n++)t[n].assignHeaderPrototype?.(e._headerPrototype,e)}return e._headerPrototype}function ao(e,t,n){let r=io(e),i=Object.create(r);i.colSpan=0,i.column=t,i.depth=n.depth,i.headerGroup=null,i.id=n.id??t.id,i.index=n.index,i.isPlaceholder=!!n.isPlaceholder,i.placeholderId=n.placeholderId,i.rowSpan=0,i.subHeaders=[];let a=e._headerInstanceInitFns;for(let e=0;e<a.length;e++)a[e](i);return i}function oo(e,t=1){let n=t;for(let r=0;r<e.length;r++){let i=e[r];Fa(i)&&i.columns.length&&(n=Math.max(n,oo(i.columns,t+1)))}return n}function so(e,t){return e?`${e}_${t}`:String(t)}function co(e,t,n,r){let i=e??``;return t&&(i=i?`${i}_${t}`:String(t)),n&&(i=i?`${i}_${n}`:n),r&&(i=i?`${i}_${r}`:r),i}function lo(e,t){let n=0;for(let r=0;r<e.length;r++)e[r].column===t&&n++;return n}function uo(e,t,n,r,i,a){let o={depth:t,id:so(r,t),headers:[]},s=[];for(let i=0;i<e.length;i++){if(!(i in e))continue;let a=e[i],c=s[s.length-1],l=a.column.depth===o.depth,u,d=!1;if(l&&a.column.parent?u=a.column.parent:(u=a.column,d=!0),c&&c.column===u)c.subHeaders.push(a);else{let e=ao(n,u,{id:co(r,t,u.id,a.id),isPlaceholder:d,placeholderId:d?String(lo(s,u)):void 0,depth:t,index:s.length});e.subHeaders.push(a),s.push(e)}o.headers.push(a),a.headerGroup=o}for(let e=0;e<a.length;e++)a[e](o);i.push(o),t>0&&uo(s,t-1,n,r,i,a)}function fo(e){for(let t=0;t<e.length;t++){let n=e[t];if(!Fa(n.column))continue;let r=0;if(n.subHeaders.length){fo(n.subHeaders);for(let e=0;e<n.subHeaders.length;e++){let t=n.subHeaders[e];Fa(t.column)&&(r+=t.colSpan)}}else r=1;if(n.colSpan=r,n.isPlaceholder&&n.subHeaders.length===1&&n.subHeaders[0].column===n.column){let e=1,t=n.subHeaders[0];for(;t;)t.rowSpan=0,e++,t=t.subHeaders.length===1&&t.subHeaders[0].column===n.column?t.subHeaders[0]:void 0;n.rowSpan=e}else n.rowSpan=1}}function po(e,t,n,r){let i=oo(e),a=[],o=n._headerGroupInstanceInitFns,s=Array(t.length);for(let e=0;e<t.length;e++)e in t&&(s[e]=ao(n,t[e],{depth:i,index:e}));return uo(s,i-1,n,r,a,o),a.reverse(),fo(a[0]?.headers??[]),a}function mo(e,t){for(let n=0;n<e.subHeaders.length;n++)mo(e.subHeaders[n],t);t.push(e)}function ho(e){let t=[];return mo(e,t),t}function go(e){return{column:e.column,header:e,table:e.column.table}}function _o(e){return po(e.getAllColumns(),Ba(e,Ia(e),e=>e.id),e)}function vo(e){return[...e.getHeaderGroups()].reverse()}function yo(e){let t=e.getHeaderGroups(),n=[];for(let e=0;e<t.length;e++){let r=t[e].headers;for(let e=0;e<r.length;e++)n.push(r[e])}return n}function bo(e){let t=e.getHeaderGroups()[0]?.headers??[],n=[];for(let e=0;e<t.length;e++){let r=t[e].getLeafHeaders();for(let e=0;e<r.length;e++)n.push(r[e])}return n}var xo={assignHeaderPrototype:(e,t)=>{Oa(`coreHeadersFeature`,e,t,{header_getLeafHeaders:{fn:e=>ho(e),memoDeps:e=>[e.column.table.options.columns]},header_getContext:{fn:e=>go(e),memoDeps:e=>[e.column.table.options.columns]}})},constructTableAPIs:e=>{Da(`coreHeadersFeature`,e,{table_getHeaderGroups:{fn:()=>_o(e),memoDeps:()=>[e.options.columns,e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.atoms.columnPinning?.get(),e.atoms.columnVisibility?.get(),e.options.groupedColumnMode]},table_getFooterGroups:{fn:()=>vo(e),memoDeps:()=>[e.getHeaderGroups()]},table_getFlatHeaders:{fn:()=>yo(e),memoDeps:()=>[e.getHeaderGroups()]},table_getLeafHeaders:{fn:()=>bo(e),memoDeps:()=>[e.getHeaderGroups()]}})}};function So(e){if(!e._rowPrototype){e._rowPrototype={table:e};let t=Object.values(e._features);for(let n=0;n<t.length;n++)t[n].assignRowPrototype?.(e._rowPrototype,e)}return e._rowPrototype}var Co=(e,t,n,r,i,a,o)=>{let s=So(e),c=Object.create(s);c._displayIndexCache=-1,c._uniqueValuesCache=fa(),c._valuesCache=fa(),c.depth=i,c.id=t,c.index=r,c.original=n,c.parentId=o,c.subRows=a??[];let l=e._rowInstanceInitFns;for(let e=0;e<l.length;e++)l[e](c);return c};function wo(){return e=>Ta({feature:`coreRowModelsFeature`,table:e,fnName:`table.getCoreRowModel`,memoDeps:()=>[e.options.data],fn:()=>Eo(e,e.options.data),onAfterUpdate:wa(()=>{Ua(e),Wa(e),Ga(e),Ka(e)})})}function To(e,t,n,r=0,i){let a=[];for(let o=0;o<n.length;o++){let s=n[o],c=Co(e,e.getRowId(s,o,i),s,o,r,void 0,i?.id);t.flatRows.push(c),t.rowsById[c.id]=c,a.push(c),e.options.getSubRows&&(c.originalSubRows=e.options.getSubRows(s,o),c.originalSubRows?.length&&(c.subRows=To(e,t,c.originalSubRows,r+1,c)))}return a}function Eo(e,t){let n={rows:[],flatRows:[],rowsById:fa()};return n.rows=To(e,n,t),n}function Do(e){return e._rowModels.coreRowModel||(e._rowModels.coreRowModel=e.options.features.coreRowModel?.(e)??wo()(e)),e._rowModels.coreRowModel()}function Oo(e){return e.getCoreRowModel()}function ko(e){return e._rowModels.filteredRowModel||(e._rowModels.filteredRowModel=e.options.features.filteredRowModel?.(e)),e.options.manualFiltering||!e._rowModels.filteredRowModel?e.getPreFilteredRowModel():e._rowModels.filteredRowModel()}function Ao(e){return e.getFilteredRowModel()}function jo(e){return e._rowModels.groupedRowModel||(e._rowModels.groupedRowModel=e.options.features.groupedRowModel?.(e)),e.options.manualGrouping||!e._rowModels.groupedRowModel?e.getPreGroupedRowModel():e._rowModels.groupedRowModel()}function Mo(e){return e.getGroupedRowModel()}function No(e){return e._rowModels.sortedRowModel||(e._rowModels.sortedRowModel=e.options.features.sortedRowModel?.(e)),e.options.manualSorting||!e._rowModels.sortedRowModel?e.getPreSortedRowModel():e._rowModels.sortedRowModel()}function Po(e){return e.getSortedRowModel()}function Fo(e){return e._rowModels.expandedRowModel||(e._rowModels.expandedRowModel=e.options.features.expandedRowModel?.(e)),e.options.manualExpanding||!e._rowModels.expandedRowModel?e.getPreExpandedRowModel():e._rowModels.expandedRowModel()}function Io(e){return e.getExpandedRowModel()}function Lo(e){return e._rowModels.paginatedRowModel||(e._rowModels.paginatedRowModel=e.options.features.paginatedRowModel?.(e)),e.options.manualPagination||!e._rowModels.paginatedRowModel?e.getPrePaginatedRowModel():e._rowModels.paginatedRowModel()}function Ro(e){return e.getPaginatedRowModel()}var zo={constructTableAPIs:e=>{Da(`coreRowModelsFeature`,e,{table_getCoreRowModel:{fn:()=>Do(e)},table_getPreFilteredRowModel:{fn:()=>Oo(e)},table_getFilteredRowModel:{fn:()=>ko(e)},table_getPreGroupedRowModel:{fn:()=>Ao(e)},table_getGroupedRowModel:{fn:()=>jo(e)},table_getPreSortedRowModel:{fn:()=>Mo(e)},table_getSortedRowModel:{fn:()=>No(e)},table_getPreExpandedRowModel:{fn:()=>Po(e)},table_getExpandedRowModel:{fn:()=>Fo(e)},table_getPrePaginatedRowModel:{fn:()=>Io(e)},table_getPaginatedRowModel:{fn:()=>Lo(e)},table_getRowModel:{fn:()=>Ro(e)}})}};function Bo(e){if(!e._cellPrototype){e._cellPrototype={table:e};let t=Object.values(e._features);for(let n=0;n<t.length;n++)t[n].assignCellPrototype?.(e._cellPrototype,e)}return e._cellPrototype}function Vo(e,t,n){let r=Bo(n),i=Object.create(r);i.column=e,i.id=`${t.id}_${e.id}`,i.row=t;let a=n._cellInstanceInitFns;for(let e=0;e<a.length;e++)a[e](i);return i}function Ho(e){let t=e.table.getRowsInDisplayOrder(),n=e._displayIndexCache;return t[n]===e?n:-1}function Uo(e){let t=e.getPrePaginatedRowModel(),n=e.options.paginateExpandedRows===!1?Ha(e,t).rows:t.rows;for(let e=0;e<n.length;e++)n[e]._displayIndexCache=e;return n}function Wo(e,t){if(pa(e._valuesCache,t))return e._valuesCache[t];let n=e.table.getColumn(t);if(n?.accessorFn)return e._valuesCache[t]=n.accessorFn(e.original,e.index),e._valuesCache[t]}function Go(e,t){if(pa(e._uniqueValuesCache,t))return e._uniqueValuesCache[t];let n=e.table.getColumn(t);if(n?.accessorFn)return n.columnDef.getUniqueValues?(e._uniqueValuesCache[t]=n.columnDef.getUniqueValues(e.original,e.index),e._uniqueValuesCache[t]):(e._uniqueValuesCache[t]=[e.getValue(t)],e._uniqueValuesCache[t])}function Ko(e,t){return e.getValue(t)??e.table.options.renderFallbackValue}function qo(e){return Sa(e.subRows,e=>e.subRows)}function Jo(e){let t=e.getCoreRowModel().flatRows,n=0;for(let e=0;e<t.length;e++)n=Math.max(n,t[e].depth);return n}function Yo(e){if(e.parentId)return e.table.getCoreRowModel().rowsById[e.parentId]??e.table.getRow(e.parentId,!0)}function Xo(e){let t=[],n=e;for(;;){let e=n.getParentRow();if(!e)break;t.push(e),n=e}return t.reverse()}function Zo(e){let t=e.table.getAllLeafColumns(),n=e._cellsCache;n||=e._cellsCache=new WeakMap;let r=Array(t.length);for(let i=0;i<t.length;i++){let a=t[i],o=n.get(a);o||(o=Vo(a,e,e.table),n.set(a,o)),r[i]=o}return r}function Qo(e){let t=fa(),n=e.getAllCells();for(let e=0;e<n.length;e++){let r=n[e];t[r.column.id]=r}return t}function $o(e,t,n,r){return t.options.getRowId?.(e,n,r)??(r?`${r.id}.${n}`:String(n))}function es(e,t,n){let r=(n?e.getPrePaginatedRowModel():e.getRowModel()).rowsById[t];if(!r&&(r=e.getCoreRowModel().rowsById[t],!r))throw Error();return r}var ts={assignRowPrototype:(e,t)=>{Oa(`coreRowsFeature`,e,t,{row_getDisplayIndex:{fn:e=>Ho(e)},row_getAllCellsByColumnId:{fn:e=>Qo(e),memoDeps:e=>[e.getAllCells()]},row_getAllCells:{fn:e=>Zo(e),memoDeps:e=>[e.table.getAllLeafColumns()]},row_getLeafRows:{fn:e=>qo(e),memoDeps:e=>[e.subRows]},row_getParentRow:{fn:e=>Yo(e)},row_getParentRows:{fn:e=>Xo(e)},row_getUniqueValues:{fn:(e,t)=>Go(e,t)},row_getValue:{fn:(e,t)=>Wo(e,t)},row_renderValue:{fn:(e,t)=>Ko(e,t)}})},constructTableAPIs:e=>{Da(`coreRowsFeature`,e,{table_getRowsInDisplayOrder:{fn:()=>Uo(e),memoDeps:()=>[e.getPrePaginatedRowModel().rows,e.options.paginateExpandedRows,e.options.paginateExpandedRows===!1?e.atoms.expanded?.get():void 0]},table_getRowId:{fn:(t,n,r)=>$o(t,e,n,r)},table_getRow:{fn:(t,n)=>es(e,t,n)},table_getMaxSubRowDepth:{fn:()=>Jo(e),memoDeps:()=>[e.getCoreRowModel()]}})}};function ns(e,t,n=(e,t)=>e===t){let r=t===void 0?e.options.state:t;e._reactivity.batch(()=>{if(r)for(let t in r){let i=e.baseAtoms[t];if(!i)continue;let a=r[t],o=a===void 0?e.initialState[t]:a;n(e._reactivity.untrack(()=>i.get()),o)||i.set(()=>o)}})}function rs(e,t,n=(e,t)=>e===t){e._reactivity.batch(()=>{ns(e,t,n),e._reactivity.commit?.()})}function is(e){let t=da(e.initialState);e._reactivity.batch(()=>{let n=Object.keys(t);for(let r=0;r<n.length;r++){let i=n[r];e.baseAtoms[i].set(t[i])}});let n=Object.values(e._features);for(let t=0;t<n.length;t++)n[t].resetTableInstanceData?.(e)}function as(e,t){let{features:n,atoms:r,initialState:i}=e.options;if(!e.options.mergeOptions)return{...e.options,...t,features:n,atoms:r,initialState:i};let a=e.options.mergeOptions(e.options,t),o={...Object.getOwnPropertyDescriptors(a)};return Object.defineProperties(Object.create(Object.getPrototypeOf(a)),{...o,features:{value:n,enumerable:!0,configurable:!0,writable:!0},atoms:{value:r,enumerable:!0,configurable:!0,writable:!0},initialState:{value:i,enumerable:!0,configurable:!0,writable:!0}})}function os(e,t,n){let r=as(e,ua(t,e.options));e.optionsStore?e.optionsStore.set(()=>r):e.options=r,n?.syncExternalState!==!1&&rs(e,r.state??null)}var ss={coreCellsFeature:Ma,coreColumnsFeature:ro,coreHeadersFeature:xo,coreRowModelsFeature:zo,coreRowsFeature:ts,coreTablesFeature:{constructTableAPIs:e=>{Da(`coreTablesFeature`,e,{table_reset:{fn:()=>is(e)},table_setOptions:{fn:t=>os(e,t)}})}}};function cs(e){return e}function ls(e,t={}){return Object.values(e).forEach(e=>{t=e.getInitialState?.(t)??t}),da(t)}function us(e){let t=e.features.coreReactivityFeature,{aggregationFns:n,columnMeta:r,coreRowModel:i,expandedRowModel:a,facetedMinMaxValues:o,facetedRowModel:s,facetedUniqueValues:c,filterFns:l,filterMeta:u,filteredRowModel:d,groupedRowModel:f,paginatedRowModel:p,sortFns:m,sortedRowModel:h,tableMeta:g,..._}=e.features,v={_cellInstanceInitFns:[],_columnInstanceInitFns:[],_features:{...ss,..._},_headerGroupInstanceInitFns:[],_headerInstanceInitFns:[],_reactivity:t,_rowInstanceInitFns:[],_rowModelFns:{aggregationFns:n,filterFns:l,sortFns:m},_rowModels:{},atoms:{},baseAtoms:{}},y=Object.values(v._features),b={...y.reduce((e,t)=>Object.assign(e,t.getDefaultTableOptions?.(v)),{}),...e};if(t.wrapExternalAtoms&&b.atoms)for(let[e,n]of Object.entries(b.atoms)){let r=n,i=t.createWritableAtom(r.get(),{debugName:`externalAtom/${e}`});b.atoms[e]=i;let a=!1,o=r.subscribe(e=>{a||i.set(e)}),s=i.subscribe(e=>{a=!0,r.set(e),a=!1});t.addSubscription(o),t.addSubscription(s)}t.createOptionsStore?(v.optionsStore=t.createWritableAtom(b,{debugName:`table/optionsStore`}),Object.defineProperty(v,"options",{configurable:!0,enumerable:!0,get(){return v.optionsStore.get()},set(e){v.optionsStore.set(()=>e)}})):v.options=b,v.initialState=ls(v._features,v.options.initialState);let x=Object.keys(v.initialState);for(let e=0;e<x.length;e++){let n=x[e];v.baseAtoms[n]=t.createWritableAtom(v.initialState[n],{debugName:`table/baseAtoms/${n}`}),v.atoms[n]=t.createReadonlyAtom(()=>{let e=v.options,t=e.atoms?.[n],r=t?t.get():v.baseAtoms[n].get();if(t)return r;let i=e.state;if(i&&pa(i,n)){let e=i[n];return e===void 0?v.initialState[n]:e}return r},{debugName:`table/atoms/${n}`})}ns(v),v.store=oa(t.createReadonlyAtom(()=>{let e={};for(let t=0;t<x.length;t++){let n=x[t];e[n]=v.atoms[n].get()}return e},{compare:ea,debugName:`table/store`}));for(let e=0;e<y.length;e++){let t=y[e];t.initTableInstanceData?.(v),t.initCellInstanceData&&v._cellInstanceInitFns.push(t.initCellInstanceData.bind(t)),t.initColumnInstanceData&&v._columnInstanceInitFns.push(t.initColumnInstanceData.bind(t)),t.initHeaderGroupInstanceData&&v._headerGroupInstanceInitFns.push(t.initHeaderGroupInstanceData.bind(t)),t.initHeaderInstanceData&&v._headerInstanceInitFns.push(t.initHeaderInstanceData.bind(t)),t.initRowInstanceData&&v._rowInstanceInitFns.push(t.initRowInstanceData.bind(t)),t.constructTableAPIs?.(v)}return v}function ds(){return[]}function fs(e){let t=e=>{let t=fa();for(let n=0;n<e.length;n++)t[e[n].id]=n;return t};return{all:t(Va(e)),center:t(Va(e,`center`)),start:t(Va(e,`start`)),end:t(Va(e,`end`))}}function ps(e,t){return Z(e.table,`getColumnIndexes`,fs)[t===`start`?`start`:t===`end`?`end`:t===`center`?`center`:`all`][e.id]??-1}function ms(e,t){return Va(e.table,t)[0]?.id===e.id}function hs(e,t){let n=Va(e.table,t);return n[n.length-1]?.id===e.id}function gs(e,t){ba(e,`columnOrder`,t)}function _s(e,t){gs(e,t?[]:da(e.initialState.columnOrder??[]))}function vs(e){let t=e.atoms.columnOrder?.get();return n=>{let r=[];if(!t?.length)r=n;else{let e=new Map;for(let t=0;t<n.length;t++){let r=n[t];e.set(r.id,r)}for(let n=0;n<t.length;n++){let i=t[n],a=e.get(i);a&&(r.push(a),e.delete(i))}for(let t=0;t<n.length;t++){let i=n[t];e.has(i.id)&&r.push(i)}}return ys(e,r)}}function ys(e,t){let n=e.atoms.grouping?.get()??[],{groupedColumnMode:r}=e.options;if(!n.length||!r)return t;let i=t.filter(e=>!n.includes(e.id));if(r===`remove`)return i;let a=new Map;for(let e=0;e<t.length;e++){let n=t[e];a.set(n.id,n)}let o=[];for(let e=0;e<n.length;e++){let t=a.get(n[e]);t&&o.push(t)}return[...o,...i]}var bs={getInitialState:e=>({columnOrder:ds(),...e}),getDefaultTableOptions:e=>({onColumnOrderChange:ma(`columnOrder`,e)}),assignColumnPrototype:(e,t)=>{Oa(`columnOrderingFeature`,e,t,{column_getIndex:{fn:(e,t)=>ps(e,t)},column_getIsFirstColumn:{fn:(e,t)=>ms(e,t)},column_getIsLastColumn:{fn:(e,t)=>hs(e,t)}})},constructTableAPIs:e=>{Da(`columnOrderingFeature`,e,{table_getColumnIndexes:{fn:()=>fs(e),memoDeps:()=>[e.options.columns,e.atoms.columnOrder?.get(),e.atoms.columnPinning?.get(),e.atoms.columnVisibility?.get(),e.atoms.grouping?.get(),e.options.groupedColumnMode]},table_setColumnOrder:{fn:t=>gs(e,t)},table_resetColumnOrder:{fn:t=>_s(e,t)},table_getOrderColumnsFn:{fn:()=>vs(e),memoDeps:()=>[e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.options.groupedColumnMode]}})}};function xs(){return{start:[],end:[]}}function Ss(e,t){let n=e.getLeafColumns(),r=[];for(let e=0;e<n.length;e++){let t=n[e].id;t&&r.push(t)}ks(e.table,e=>t===`end`?{start:e.start.filter(e=>!r.includes(e)),end:[...e.end.filter(e=>!r.includes(e)),...r]}:t===`start`?{start:[...e.start.filter(e=>!r.includes(e)),...r],end:e.end.filter(e=>!r.includes(e))}:{start:e.start.filter(e=>!r.includes(e)),end:e.end.filter(e=>!r.includes(e))})}function Cs(e){return e.getLeafColumns().some(t=>(t.columnDef.enablePinning??!0)&&(e.table.options.enableColumnPinning??!0))}function ws(e){let t=e.getLeafColumns(),{start:n,end:r}=e.table.atoms.columnPinning?.get()??xs();for(let e=0;e<t.length;e++)if(n.includes(t[e].id))return`start`;for(let e=0;e<t.length;e++)if(r.includes(t[e].id))return`end`;return!1}function Ts(e){let t=ws(e);return t?e.table.atoms.columnPinning?.get()?.[t].indexOf(e.id)??-1:0}function Es(e){let t=La(e),{start:n,end:r}=e.table.atoms.columnPinning?.get()??xs();if(!n.length&&!r.length)return t;let i=[...n,...r];return t.filter(e=>!i.includes(e.column.id))}function Ds(e){let{start:t}=e.table.atoms.columnPinning?.get()??xs();if(!t.length)return[];let n=Ra(e),r=[];for(let e=0;e<t.length;e++){let i=n[t[e]];i&&(i.position=`start`,r.push(i))}return r}function Os(e){let{end:t}=e.table.atoms.columnPinning?.get()??xs();if(!t.length)return[];let n=Ra(e),r=[];for(let e=0;e<t.length;e++){let i=n[t[e]];i&&(i.position=`end`,r.push(i))}return r}function ks(e,t){ba(e,`columnPinning`,t)}function As(e,t){ks(e,t?xs():da(e.initialState.columnPinning??xs()))}function js(e,t){let n=e.atoms.columnPinning?.get();return t?!!n?.[t].length:!!(n?.start.length||n?.end.length)}function Ms(e){let t=e.getAllColumns(),n=e.getAllLeafColumnsById(),{start:r}=e.atoms.columnPinning?.get()??xs(),i=[];for(let e=0;e<r.length;e++){let t=n[r[e]];t&&Fa(t)&&i.push(t)}return po(t,i,e,`start`)}function Ns(e){let t=e.getAllColumns(),n=e.getAllLeafColumnsById(),{end:r}=e.atoms.columnPinning?.get()??xs(),i=[];for(let e=0;e<r.length;e++){let t=n[r[e]];t&&Fa(t)&&i.push(t)}return po(t,i,e,`end`)}function Ps(e){let t=e.getAllColumns(),n=Ia(e),{start:r,end:i}=e.atoms.columnPinning?.get()??xs();if(r.length||i.length){let e=[...r,...i];n=n.filter(t=>!e.includes(t.id))}return po(t,n,e,`center`)}function Fs(e){return[...Z(e,`getStartHeaderGroups`,Ms)].reverse()}function Is(e){return[...Z(e,`getEndHeaderGroups`,Ns)].reverse()}function Ls(e){return[...Z(e,`getCenterHeaderGroups`,Ps)].reverse()}function Rs(e){let t=Z(e,`getStartHeaderGroups`,Ms),n=[];for(let e=0;e<t.length;e++){let r=t[e].headers;for(let e=0;e<r.length;e++)n.push(r[e])}return n}function zs(e){let t=Z(e,`getEndHeaderGroups`,Ns),n=[];for(let e=0;e<t.length;e++){let r=t[e].headers;for(let e=0;e<r.length;e++)n.push(r[e])}return n}function Bs(e){let t=Z(e,`getCenterHeaderGroups`,Ps),n=[];for(let e=0;e<t.length;e++){let r=t[e].headers;for(let e=0;e<r.length;e++)n.push(r[e])}return n}function Vs(e){return Z(e,`getStartFlatHeaders`,Rs).filter(e=>!e.subHeaders.length)}function Hs(e){return Z(e,`getEndFlatHeaders`,zs).filter(e=>!e.subHeaders.length)}function Us(e){return Z(e,`getCenterFlatHeaders`,Bs).filter(e=>!e.subHeaders.length)}function Ws(e){let{start:t}=e.atoms.columnPinning?.get()??xs(),n=e.getAllLeafColumnsById(),r=[];for(let e=0;e<t.length;e++){let i=n[t[e]];i&&r.push(i)}return r}function Gs(e){let{end:t}=e.atoms.columnPinning?.get()??xs(),n=e.getAllLeafColumnsById(),r=[];for(let e=0;e<t.length;e++){let i=n[t[e]];i&&r.push(i)}return r}function Ks(e){let{start:t,end:n}=e.atoms.columnPinning?.get()??xs();if(!t.length&&!n.length)return e.getAllLeafColumns();let r=[...t,...n];return e.getAllLeafColumns().filter(e=>!r.includes(e.id))}function qs(e,t){return t?t===`start`?Z(e,`getStartLeafColumns`,Ws):t===`end`?Z(e,`getEndLeafColumns`,Gs):Z(e,`getCenterLeafColumns`,Ks):e.getAllLeafColumns()}function Js(e){return Z(e,`getStartLeafColumns`,Ws).filter(e=>Fa(e))}function Ys(e){return Z(e,`getEndLeafColumns`,Gs).filter(e=>Fa(e))}function Xs(e){return Z(e,`getCenterLeafColumns`,Ks).filter(e=>Fa(e))}function Zs(e,t){return t?t===`start`?Z(e,`getStartVisibleLeafColumns`,Js):t===`end`?Z(e,`getEndVisibleLeafColumns`,Ys):Z(e,`getCenterVisibleLeafColumns`,Xs):Ia(e)}function Qs(e,t,n,r){let i=e.atoms.columnPinning?.get();if(!i||!i.start.length&&!i.end.length)return t;let{start:a,end:o}=i,s=r?.();if(!s){s=fa();for(let e=0;e<t.length;e++)s[n(t[e])]=t[e]}let c=[];for(let e=0;e<a.length;e++){let t=s[a[e]];t&&c.push(t)}for(let e=0;e<t.length;e++){let r=n(t[e]);!a.includes(r)&&!o.includes(r)&&c.push(t[e])}for(let e=0;e<o.length;e++){let t=s[o[e]];t&&c.push(t)}return c}var $s={getInitialState:e=>({columnPinning:{...xs(),...e.columnPinning},...e}),getDefaultTableOptions:e=>({onColumnPinningChange:ma(`columnPinning`,e)}),assignColumnPrototype:(e,t)=>{Oa(`columnPinningFeature`,e,t,{column_pin:{fn:(e,t)=>Ss(e,t)},column_getCanPin:{fn:e=>Cs(e)},column_getPinnedIndex:{fn:e=>Ts(e)},column_getIsPinned:{fn:e=>ws(e)}})},assignRowPrototype:(e,t)=>{Oa(`columnPinningFeature`,e,t,{row_getCenterVisibleCells:{fn:e=>Es(e),memoDeps:e=>[e.getAllCells(),e.table.atoms.columnPinning?.get(),e.table.atoms.columnVisibility?.get()]},row_getStartVisibleCells:{fn:e=>Ds(e),memoDeps:e=>[e.getAllCells(),e.table.atoms.columnPinning?.get()?.start,e.table.atoms.columnVisibility?.get()]},row_getEndVisibleCells:{fn:e=>Os(e),memoDeps:e=>[e.getAllCells(),e.table.atoms.columnPinning?.get()?.end,e.table.atoms.columnVisibility?.get()]}})},constructTableAPIs:e=>{Da(`columnPinningFeature`,e,{table_setColumnPinning:{fn:t=>ks(e,t)},table_resetColumnPinning:{fn:t=>As(e,t)},table_getIsSomeColumnsPinned:{fn:t=>js(e,t)},table__orderByColumnPinning:{fn:(t,n,r)=>Qs(e,t,n,r)},table_getStartHeaderGroups:{fn:()=>Ms(e),memoDeps:()=>[e.getAllColumns(),Ia(e),e.atoms.columnPinning?.get()?.start,e.atoms.columnOrder?.get()]},table_getCenterHeaderGroups:{fn:()=>Ps(e),memoDeps:()=>[e.getAllColumns(),Ia(e),e.atoms.columnPinning?.get(),e.atoms.columnOrder?.get()]},table_getEndHeaderGroups:{fn:()=>Ns(e),memoDeps:()=>[e.getAllColumns(),Ia(e),e.atoms.columnPinning?.get()?.end,e.atoms.columnOrder?.get()]},table_getStartFooterGroups:{fn:()=>Fs(e),memoDeps:()=>[Z(e,`getStartHeaderGroups`,Ms)]},table_getCenterFooterGroups:{fn:()=>Ls(e),memoDeps:()=>[Z(e,`getCenterHeaderGroups`,Ps)]},table_getEndFooterGroups:{fn:()=>Is(e),memoDeps:()=>[Z(e,`getEndHeaderGroups`,Ns)]},table_getStartFlatHeaders:{fn:()=>Rs(e),memoDeps:()=>[Z(e,`getStartHeaderGroups`,Ms)]},table_getEndFlatHeaders:{fn:()=>zs(e),memoDeps:()=>[Z(e,`getEndHeaderGroups`,Ns)]},table_getCenterFlatHeaders:{fn:()=>Bs(e),memoDeps:()=>[Z(e,`getCenterHeaderGroups`,Ps)]},table_getStartLeafHeaders:{fn:()=>Vs(e),memoDeps:()=>[Z(e,`getStartHeaderGroups`,Ms)]},table_getEndLeafHeaders:{fn:()=>Hs(e),memoDeps:()=>[Z(e,`getEndHeaderGroups`,Ns)]},table_getCenterLeafHeaders:{fn:()=>Us(e),memoDeps:()=>[Z(e,`getCenterHeaderGroups`,Ps)]},table_getStartLeafColumns:{fn:()=>Ws(e),memoDeps:()=>[e.options.columns,e.atoms.columnPinning?.get(),e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.options.groupedColumnMode]},table_getEndLeafColumns:{fn:()=>Gs(e),memoDeps:()=>[e.options.columns,e.atoms.columnPinning?.get(),e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.options.groupedColumnMode]},table_getCenterLeafColumns:{fn:()=>Ks(e),memoDeps:()=>[e.options.columns,e.atoms.columnPinning?.get(),e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.options.groupedColumnMode]},table_getPinnedLeafColumns:{fn:t=>qs(e,t)},table_getStartVisibleLeafColumns:{fn:()=>Js(e),memoDeps:()=>[e.options.columns,e.atoms.columnPinning?.get(),e.atoms.columnVisibility?.get(),e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.options.groupedColumnMode]},table_getCenterVisibleLeafColumns:{fn:()=>Xs(e),memoDeps:()=>[e.options.columns,e.atoms.columnPinning?.get(),e.atoms.columnVisibility?.get(),e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.options.groupedColumnMode]},table_getEndVisibleLeafColumns:{fn:()=>Ys(e),memoDeps:()=>[e.options.columns,e.atoms.columnPinning?.get(),e.atoms.columnVisibility?.get(),e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.options.groupedColumnMode]},table_getPinnedVisibleLeafColumns:{fn:t=>Zs(e,t)}})}};function ec(){return fa()}function tc(){return{size:150,minSize:20,maxSize:2**53-1}}function nc(e){let t=tc(),n=e.table.atoms.columnSizing?.get(),r=n&&pa(n,e.id)?n[e.id]:void 0;return Math.min(Math.max(e.columnDef.minSize??t.minSize,r??e.columnDef.size??t.size),e.columnDef.maxSize??t.maxSize)}function rc(e){let t=fa(),n=fa(),r=Array(e.length),i=0;for(let n=0;n<e.length;n++){let a=e[n],o=Z(a,`getSize`,nc);r[n]=o,t[a.id]=i,i+=o}let a=0;for(let t=e.length-1;t>=0;t--)n[e[t].id]=a,a+=r[t];return{starts:t,afters:n}}function ic(e){return{all:rc(Va(e)),center:rc(Va(e,`center`)),start:rc(Va(e,`start`)),end:rc(Va(e,`end`))}}function ac(e){return e===`start`?`start`:e===`end`?`end`:e===`center`?`center`:`all`}function oc(e,t){return Z(e.table,`getColumnOffsets`,ic)[ac(t)].starts[e.id]??0}function sc(e,t){return Z(e.table,`getColumnOffsets`,ic)[ac(t)].afters[e.id]??0}function cc(e){fc(e.table,t=>{let n=fa(),r=Object.keys(t);for(let i=0;i<r.length;i++){let a=r[i];a!==e.id&&(n[a]=t[a])}return n})}function lc(e){if(!e.subHeaders.length)return nc(e.column);let t=0;for(let n=0;n<e.subHeaders.length;n++)t+=lc(e.subHeaders[n]);return t}function uc(e){return lc(e)}function dc(e){if(e.index>0){let t=e.headerGroup?.headers[e.index-1];if(t)return Z(t,`getStart`,dc)+Z(t,`getSize`,uc)}return 0}function fc(e,t){e.options.onColumnSizingChange?.(t)}function pc(e,t){fc(e,t?fa():Object.assign(fa(),da(e.initialState.columnSizing??{})))}function mc(e){let t=0;for(let n=0;n<e.length;n++)t+=Z(e[n],`getSize`,nc);return t}function hc(e){return e.getHeaderGroups()[0]?.headers.reduce((e,t)=>e+uc(t),0)??0}function gc(e){return mc(Va(e,`start`))}function _c(e){return mc(Va(e,`center`))}function vc(e){return mc(Va(e,`end`))}var yc={getInitialState:e=>({columnSizing:ec(),...e}),getDefaultColumnDef:()=>tc(),getDefaultTableOptions:e=>({onColumnSizingChange:ma(`columnSizing`,e)}),assignColumnPrototype:(e,t)=>{Oa(`columnSizingFeature`,e,t,{column_getSize:{fn:e=>nc(e),memoDeps:e=>[t.options.columns,t.atoms.columnSizing?.get()?.[e.id]]},column_getStart:{fn:(e,t)=>oc(e,t)},column_getAfter:{fn:(e,t)=>sc(e,t)},column_resetSize:{fn:e=>cc(e)}})},assignHeaderPrototype:(e,t)=>{Oa(`columnSizingFeature`,e,t,{header_getSize:{fn:e=>uc(e),memoDeps:e=>[t.options.columns,e.column.columns.length>0?t.atoms.columnSizing?.get():t.atoms.columnSizing?.get()?.[e.column.id]]},header_getStart:{fn:e=>dc(e),memoDeps:()=>[t.options.columns,t.atoms.columnSizing?.get(),t.atoms.columnOrder?.get(),t.atoms.columnPinning?.get(),t.atoms.columnVisibility?.get(),t.atoms.grouping?.get(),t.options.groupedColumnMode]}})},constructTableAPIs:e=>{Da(`columnSizingFeature`,e,{table_getColumnOffsets:{fn:()=>ic(e),memoDeps:()=>[e.options.columns,e.atoms.columnSizing?.get(),e.atoms.columnOrder?.get(),e.atoms.columnPinning?.get(),e.atoms.columnVisibility?.get(),e.atoms.grouping?.get(),e.options.groupedColumnMode]},table_setColumnSizing:{fn:t=>fc(e,t)},table_resetColumnSizing:{fn:t=>pc(e,t)},table_getTotalSize:{fn:()=>hc(e),memoDeps:()=>[e.atoms.columnSizing?.get(),e.getHeaderGroups()]},table_getStartTotalSize:{fn:()=>gc(e),memoDeps:()=>[e.atoms.columnSizing?.get(),e.getHeaderGroups()]},table_getCenterTotalSize:{fn:()=>_c(e),memoDeps:()=>[e.atoms.columnSizing?.get(),e.getHeaderGroups()]},table_getEndTotalSize:{fn:()=>vc(e),memoDeps:()=>[e.atoms.columnSizing?.get(),e.getHeaderGroups()]}})}};function bc(){return fa()}function xc(e,t){Cc(e)&&kc(e.table,n=>{let r=Object.assign(fa(),n),i=t??!Z(e,`getIsVisible`,Sc),a=e.getLeafColumns();for(let e=0;e<a.length;e++){let t=a[e];Cc(t)&&(r[t.id]=i)}return r})}function Sc(e){let t=e.table.atoms.columnVisibility?.get();if(!t)return!0;let n=e.columns;return n.length?n.some(e=>Z(e,`getIsVisible`,Sc)):(pa(t,e.id)?t[e.id]:void 0)??!0}function Cc(e){return(e.columnDef.enableHiding??!0)&&(e.table.options.enableHiding??!0)}function wc(e){return t=>{xc(e,t.target.checked)}}function Tc(e){let t=e.getAllCells(),n=[];for(let e=0;e<t.length;e++){let r=t[e];Z(r.column,`getIsVisible`,Sc)&&n.push(r)}return Ba(e.table,n,e=>e.column.id,()=>Z(e,`getVisibleCellsByColumnId`,Ec))}function Ec(e){let t=fa(),n=e.getAllCells();for(let e=0;e<n.length;e++){let r=n[e];Z(r.column,`getIsVisible`,Sc)&&(t[r.column.id]=r)}return t}function Dc(e){return e.getAllFlatColumns().filter(e=>Z(e,`getIsVisible`,Sc))}function Oc(e){return e.getAllLeafColumns().filter(e=>Z(e,`getIsVisible`,Sc))}function kc(e,t){ba(e,`columnVisibility`,t)}function Ac(e,t){kc(e,t?fa():Object.assign(fa(),da(e.initialState.columnVisibility??{})))}function jc(e,t){t??=!Mc(e);let n=fa(),r=e.getAllLeafColumns();for(let e=0;e<r.length;e++){let i=r[e];n[i.id]=t||!Cc(i)}kc(e,n)}function Mc(e){return!e.getAllLeafColumns().some(e=>!Z(e,`getIsVisible`,Sc))}function Nc(e){return e.getAllLeafColumns().some(e=>Z(e,`getIsVisible`,Sc))}function Pc(e){return t=>{jc(e,t.target.checked)}}var Fc={getInitialState:e=>({columnVisibility:bc(),...e}),getDefaultTableOptions:e=>({onColumnVisibilityChange:ma(`columnVisibility`,e)}),assignColumnPrototype:(e,t)=>{Oa(`columnVisibilityFeature`,e,t,{column_getIsVisible:{fn:e=>Sc(e),memoDeps:e=>[t.options.columns,t.atoms.columnVisibility?.get(),e.columns]},column_getCanHide:{fn:e=>Cc(e)},column_getToggleVisibilityHandler:{fn:e=>wc(e)},column_toggleVisibility:{fn:(e,t)=>xc(e,t)}})},assignRowPrototype:(e,t)=>{Oa(`columnVisibilityFeature`,e,t,{row_getVisibleCells:{fn:e=>Tc(e),memoDeps:e=>[e.getAllCells(),t.atoms.columnPinning?.get(),t.atoms.columnVisibility?.get()]},row_getVisibleCellsByColumnId:{fn:e=>Ec(e),memoDeps:e=>[e.getAllCells(),t.atoms.columnVisibility?.get()]}})},constructTableAPIs:e=>{Da(`columnVisibilityFeature`,e,{table_getVisibleFlatColumns:{fn:()=>Dc(e),memoDeps:()=>[e.atoms.columnVisibility?.get(),e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.options.columns,e.options.groupedColumnMode]},table_getVisibleLeafColumns:{fn:()=>Oc(e),memoDeps:()=>[e.atoms.columnVisibility?.get(),e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.options.columns,e.options.groupedColumnMode]},table_setColumnVisibility:{fn:t=>kc(e,t)},table_resetColumnVisibility:{fn:t=>Ac(e,t)},table_toggleAllColumnsVisible:{fn:t=>jc(e,t)},table_getIsAllColumnsVisible:{fn:()=>Mc(e)},table_getIsSomeColumnsVisible:{fn:()=>Nc(e)},table_getToggleAllColumnsVisibilityHandler:{fn:()=>Pc(e)}})}},Ic=/([0-9]+)/gm;function Lc(e){let t=Object.assign((e,n,r)=>{let i=e.getValue(r),a=n.getValue(r),o=t.resolveDataValue;return o&&(i=o(i),a=o(a)),t.sort(i,a,e,n,r)},e);return t}var Rc=Lc({sort:(e,t)=>zc(e,t)});function zc(e,t){return e===t?0:e>t?1:-1}function Bc(){return[]}function Vc(e,t){ba(e,`sorting`,t)}function Hc(e,t){Vc(e,t?[]:da(e.initialState.sorting??[]))}function Uc(e){e.atoms.sorting&&(e.options.autoResetAll??e.options.autoResetSorting??!1)&&Hc(e)}function Wc(e){let t=e.table._rowModelFns.sortFns,n=e.table.getFilteredRowModel().flatRows.slice(0,10),r,i=!1;for(let t=0;t<n.length;t++){let a=n[t].getValue(e.id);if(Object.prototype.toString.call(a)===`[object Date]`){r=`datetime`;break}if(typeof a==`string`&&(i=!0,a.split(Ic).length>1)){r=`alphanumeric`;break}}if(!r&&i&&(r=`text`),r){let e=t?.[r];if(e||r===`alphanumeric`&&(e=t?.text),e)return e}return Rc}function Gc(e){let t=e.table.getFilteredRowModel().flatRows.slice(0,10);for(let n=0;n<t.length;n++){let r=t[n].getValue(e.id);if(r!=null)return typeof r==`string`?`asc`:`desc`}return`desc`}function Kc(e){let t=e.table._rowModelFns.sortFns;return xa(e.columnDef.sortFn)?e.columnDef.sortFn:e.columnDef.sortFn===`auto`?Wc(e):t?.[e.columnDef.sortFn]??Rc}function qc(e,t,n){let r=Yc(e,n&&Zc(e)),i=t!==void 0;Vc(e.table,a=>{let o=a.findIndex(t=>t.id===e.id),s=o===-1?void 0:a[o],c=[],l,u=i?t:r===`desc`,d=!!(a.length&&Zc(e)&&n);return l=d?s?`toggle`:`add`:s?`toggle`:`replace`,l===`toggle`&&(i||r||(l=`remove`)),l===`add`?(c=[...a,{id:e.id,desc:u}],c.splice(0,c.length-(e.table.options.maxMultiSortColCount??2**53-1))):c=l===`toggle`?d?a.map(t=>t.id===e.id?{...t,desc:u}:t):[{id:e.id,desc:u}]:l===`remove`?d?a.filter(t=>t.id!==e.id):[]:[{id:e.id,desc:u}],c})}function Jc(e){return e.columnDef.sortDescFirst??e.table.options.sortDescFirst??Gc(e)===`desc`?`desc`:`asc`}function Yc(e,t){let n=Jc(e),r=Qc(e);return r?r!==n&&(e.table.options.enableSortingRemoval??!0)&&(!t||(e.table.options.enableMultiRemove??!0))?!1:r===`desc`?`asc`:`desc`:n}function Xc(e){return(e.columnDef.enableSorting??!0)&&(e.table.options.enableSorting??!0)&&!!e.accessorFn}function Zc(e){return e.columnDef.enableMultiSort??e.table.options.enableMultiSort??!!e.accessorFn}function Qc(e){let t=e.table.atoms.sorting?.get()?.find(t=>t.id===e.id);return t?t.desc?`desc`:`asc`:!1}function $c(e){return e.table.atoms.sorting?.get()?.findIndex(t=>t.id===e.id)??-1}function el(e){Vc(e.table,t=>t.length?t.filter(t=>t.id!==e.id):[])}function tl(e){let t=Xc(e);return n=>{t&&qc(e,void 0,Zc(e)?e.table.options.isMultiSortEvent?.(n):!1)}}var nl={getInitialState(e){return{sorting:Bc(),...e}},getDefaultColumnDef(){return{sortFn:`auto`,sortUndefined:1}},getDefaultTableOptions(e){return{autoResetSorting:!1,onSortingChange:ma(`sorting`,e),isMultiSortEvent:e=>e.shiftKey}},assignColumnPrototype(e,t){Oa(`rowSortingFeature`,e,t,{column_getAutoSortFn:{fn:e=>Wc(e)},column_getAutoSortDir:{fn:e=>Gc(e)},column_getSortFn:{fn:e=>Kc(e)},column_toggleSorting:{fn:(e,t,n)=>qc(e,t,n)},column_getFirstSortDir:{fn:e=>Jc(e)},column_getNextSortingOrder:{fn:(e,t)=>Yc(e,t)},column_getCanSort:{fn:e=>Xc(e)},column_getCanMultiSort:{fn:e=>Zc(e)},column_getIsSorted:{fn:e=>Qc(e)},column_getSortIndex:{fn:e=>$c(e)},column_clearSorting:{fn:e=>el(e)},column_getToggleSortingHandler:{fn:e=>tl(e)}})},constructTableAPIs(e){Da(`rowSortingFeature`,e,{table_autoResetSorting:{fn:()=>Uc(e)},table_setSorting:{fn:t=>Vc(e,t)},table_resetSorting:{fn:t=>Hc(e,t)}})}},rl=typeof window>`u`?Y.useEffect:Y.useLayoutEffect;function il(e,t){let[{table:n,rootSource:r}]=(0,Y.useState)(()=>{let t=us({...e,features:{coreReactivityFeature:la(),...e.features}});return t.Subscribe=(e=>aa({...e,source:e.source??t.store})),t.FlexRender=Fi,{table:t,rootSource:ca(t.store,ea)}}),i=n;os(i,t=>({...t,...e}),{syncExternalState:!1});let a=i.options.state,o=r.get(),s=ia(r,t,{compare:ea});return rl(()=>{r.markCommitted(o),rs(i,a??null,ea)}),(0,Y.useMemo)(()=>({...n,options:e,state:s}),[n,e,s])}var al=v(u(),1);function ol(e){return typeof e==`object`?e.key:e}function sl(e,t){let n=e.length;return new Proxy(e,{get(e,r,i){if(typeof r==`string`){let i=r.charCodeAt(0);if(i>=48&&i<=57){let i=+r;if(Number.isInteger(i)&&i>=0&&i<n){let n=e[i];if(typeof n!=`object`){let r=t[i*2];n=e[i]={index:i,key:n,start:r,size:t[i*2+1],end:r+t[i*2+1],lane:0}}return n}}if(r===`length`)return n}return Reflect.get(e,r,i)}})}function cl(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return(o.length!==r.length||o.some((e,t)=>r[t]!==e))&&(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1),i}return o.updateDeps=e=>{r=e},o}function ll(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var ul=(e,t)=>Math.abs(e-t)<1.01,dl=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})};function fl({offset:e,isScrolling:t,elementMax:n,holdOffset:r,scrollOffset:i,pendingWrite:a,clampedMaxAtWrite:o}){return t&&a===null&&e===i?`spurious`:a!==null&&Math.abs(e-a.target)<1.5?`readBack`:a!==null&&!a.smooth&&n!==null&&a.target>n+r+.5&&Math.abs(e-(n+r))<1.5||a!==null&&!a.smooth&&a.lowMaxes?.some(t=>Math.abs(e-t)<1.5)?`clampedReadBack`:o!==null&&Math.abs(e-o)<1.5?`clampedEcho`:`external`}var pl=e=>e===`smooth`||e===`smoothFinishing`;function ml({kind:e,offset:t,command:n,target:r}){return e!==`spurious`&&e!==`readBack`&&e!==`clampedReadBack`&&n?.index!=null&&n.phase!==`queued`&&!pl(n.phase)&&!ul(t,n.lastTargetOffset)&&!ul(t,r())&&e!==`clampedEcho`}var hl=40;function gl(e){let t=e[e.length-1];if(t===void 0)return!1;let n=e.length-2;for(;n>=0&&t.t-e[n].t<hl;)n--;if(n<0)return!1;let r=e[n],i=n-1;for(;i>=0&&r.t-e[i].t<hl;)i--;if(i<0)return!1;let a=e[i],o=(t.offset-r.offset)/(t.t-r.t),s=(r.offset-a.offset)/(r.t-a.t);return o*s>=0&&Math.abs(o)>=2*Math.abs(s)&&Math.abs(o)-Math.abs(s)>=.8}function _l(e){let t=e[e.length-1];if(t===void 0)return!1;let n=e.length-2;for(;n>=0&&t.t-e[n].t<hl;)n--;if(n<0)return!1;let r=e[n];return Math.abs(t.offset-r.offset)/(t.t-r.t)>=.05}var vl,yl=()=>{if(vl!==void 0)return vl;if(typeof navigator>`u`)return vl=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return vl=!0;let e=navigator.maxTouchPoints;return vl=navigator.platform===`MacIntel`&&e!==void 0&&e>0},bl,xl=()=>bl===void 0?bl=yl()&&typeof CSS<`u`&&typeof CSS.supports==`function`&&CSS.supports(`overflow-anchor: auto`):bl,Sl=()=>!yl()||xl(),Cl={capture:!0,passive:!0},wl=class{constructor(e){this.host=e,this._touch=null,this.inMotion=()=>this._touch!==null&&this._touch.phase!==`lateFling`,this.dragging=()=>this._touch?.phase===`down`&&this._touch.moved,this.tail=()=>this._touch?.phase===`tail`?this._touch.moved?`fling`:`tap`:null,this.onScroll=({isScrolling:e,ownReadBack:t,moved:n,external:r})=>(e&&this._touch?.phase===`tail`?this._openTail(this._touch.moved||!t,!1):this._touch?.phase===`lateFling`&&(this.host.now()>this._touch.until?this._touch=null:r&&e&&n&&this._openTail(!0,!1)),!t&&e&&n&&this._touch?.phase===`down`?(this._touch.moved=!0,!0):!1),this.touchStart=()=>{this.end(),this._touch={phase:`down`,moved:!1}},this.touchEnd=()=>{let e=this._touch?.phase===`down`&&this._touch.moved;this.end(),this._openTail(e,e)},this.end=()=>{let e=this.host.getWindow();this._touch?.phase===`tail`&&e!=null&&e.clearTimeout(this._touch.timerId),this._touch=null},this.listen=e=>{let t=()=>this.touchStart(),n=()=>this.touchEnd();return e.addEventListener(`touchstart`,t,Cl),e.addEventListener(`touchend`,n,Cl),e.addEventListener(`touchcancel`,n,Cl),()=>{e.removeEventListener(`touchstart`,t,Cl),e.removeEventListener(`touchend`,n,Cl),e.removeEventListener(`touchcancel`,n,Cl),this.end()}},this._openTail=(e,t)=>{let n=this.host.getWindow();if(n==null)return;this.end();let r={phase:`tail`,moved:e,awaitingFling:t,timerId:n.setTimeout(()=>{this.host.tailStillMoving()?this._openTail(r.moved,r.awaitingFling):(this._touch=r.awaitingFling?{phase:`lateFling`,until:this.host.now()+1e3}:null,this.host.onTailClosed())},150)};this._touch=r}}get touch(){return this._touch}},Tl=e=>{let{clientWidth:t,clientHeight:n}=e;return{width:t,height:n}},El=e=>{let t=new Set;return{schedule:n=>{let r=e.requestAnimationFrame(()=>{t.delete(r),n()});t.add(r)},cancel:()=>{t.forEach(t=>e.cancelAnimationFrame(t)),t.clear()}}},Dl=e=>e,Ol=e=>{let t=e.overscan*Math.max(e.lanes??1,1),n=Math.max(e.startIndex-t,0),r=Math.min(e.endIndex+t,e.count-1)-n+1,i=Array(r);for(let e=0;e<r;e++)i[e]=n+e;return i},kl=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(Tl(n)),!r.ResizeObserver)return()=>{};let a=El(r),o=new r.ResizeObserver(()=>{let t=()=>{i(Tl(n))};e.options.useAnimationFrameWithResizeObserver?a.schedule(t):t()});return o.observe(n,{box:`content-box`}),()=>{o.unobserve(n),a.cancel()}},Al={passive:!0},jl=typeof window>`u`||`onscrollend`in window,Ml=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&jl,o=0,s=a?null:dl(i,()=>t(n(r),!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,Al),a&&r.addEventListener(`scrollend`,u,Al),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},Nl=(e,t)=>Ml(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),Pl=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},Fl=(e,{adjustments:t=0,behavior:n},r)=>{var i;let{scrollElement:a,options:o}=r,s=e+t,c=o.horizontal&&o.isRtl&&a!==null&&`ownerDocument`in a;(i=a?.scrollTo)==null||i.call(a,{[o.horizontal?`left`:`top`]:c?-s:s,behavior:n})},Il=(e,t)=>e===`smooth`?t?`smoothLanded`:`smooth`:`instant`,Ll=e=>e?.phase===`smooth`||e?.phase===`smoothLanded`;function Rl(e,t,n,r){if(t===0)return!1;let i=r(0),a=new Set,o=0;for(;o<e;){let e=n(o);if(e===i)break;a.add(e),o++}let s=e-o;if(s===0||s>=t)return!1;for(let e=0;e<s;e++)if(r(e)!==n(o+e))return!1;for(let e=s;e<t;e++)if(a.has(r(e)))return!1;return!0}var zl=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this._holdOffset=0,this._reportedOverscroll=!1,this._iosGesture=new wl({getWindow:()=>this.targetWindow,now:()=>this.now(),tailStillMoving:()=>{let e=this.scrollState;if(e?.phase!==`queued`||this.pendingWrite!==null)return!1;let t=this._readElementOffset();return t===null||this._lastElementOffset===null||Math.abs(t-this._lastElementOffset)<1?!1:(this._lastElementOffset=t,e.samples=[...e.samples??[],{t:this.now(),offset:t}],!0)},onTailClosed:()=>{let e=this.scrollState;e?.phase===`queued`&&_l(e.samples??[])&&(this.scrollState=null),this._flushHoldIfReady(!0),this._writeAwaitingCommand(),this._retryClampedAdjustment()}}),this._lastElementOffset=null,this.pendingWrite=null,this._clampedAdjustment=null,this.elementsCache=new Map,this._resizeBatch=null,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=null,n=!1,r=!1,i=new Set,a=()=>{if(e)return e;let r=this.targetWindow;if(!r||!r.ResizeObserver)return null;let i=t=El(r);return e=new r.ResizeObserver(e=>{let t=()=>{let t={sync:!1};this._resizeBatch=t;try{e.forEach(o)}finally{this._resizeBatch=null,t.notify&&(this.notify(t.sync),this._noteClampMax(),this._flushHoldIfReady(!0),this._retryClampedAdjustment(),this.measureElement(null))}};if(this.options.useAnimationFrameWithResizeObserver)i.schedule(t);else{n=!0;try{t()}finally{n=!1}}})},o=e=>{let t=e.target,n=this.indexFromElement(t);if(t.isConnected)this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this));else{this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}}};return{disconnect:()=>{var n;(n=a())==null||n.disconnect(),t?.cancel(),i.clear(),r=!1,e=null,t=null},observe:o=>{let s=a();s&&(n?(i.add(o),r||(r=!0,t?.schedule(()=>{r=!1,i.forEach(t=>{t.isConnected&&e?.observe(t,{box:`border-box`})}),i.clear()}))):s.observe(o,{box:`border-box`}))},unobserve:e=>{var t;i.delete(e),(t=a())==null||t.unobserve(e)}}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Dl,rangeExtractor:Ol,onChange:()=>{},measureElement:Pl,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=this._singleLaneMeasurements?.items??s,l=e=>ol(c[e]),u=e>0?l(0):null,d=e>0?l(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==u||t.getItemKey(o-1)!==d)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==d)&&(o>e||Rl(e,o,l,t.getItemKey))&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=null;if(r&&this.scrollOffset!==null&&!this._awaitingCommandReadBack()){let[e,t]=r,n=this.getMeasurements(),{count:a,getItemKey:s}=this.options,c=0;for(;c<a&&s(c)!==e;)c++;if(c<a){let e=n[c];if(e){let n=Math.max(0,e.start+t);!i&&n!==this.scrollOffset&&(o=n-this.scrollOffset,this.scrollOffset=n)}}}i?this.pendingScrollAnchor={kind:`follow`,behavior:i}:o!==null&&(this._canWriteScroll()?this.pendingScrollAnchor={kind:`anchor`,delta:o}:(this._holdOffset+=o,this._followOffsetTarget(o)))},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=cl(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{var e;this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,(e=this._momentumStop)==null||e.restore(),this._momentumStop=null,this.isScrolling=!1,this.scrollDirection=null,this._holdOffset=0,this._reportedOverscroll=!1,this._clampedAdjustment=null,this.pendingWrite=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{let n=t?this._elementMaxScrollOffset():null,r=this._reportedOverscroll;this._reportedOverscroll=e<0||n!==null&&e>n+1;let i=e;this._lastElementOffset=i,e=this._toLayoutOffset(e);let a=this._classifyScrollEvent(e,t,n);if(a===`spurious`)return;a===`readBack`?e=this.pendingWrite.target:a===`clampedReadBack`&&this.scrollState?.index!=null&&e<this.getMaxScrollOffset()-1.5?this.scrollState.lastTargetOffset=e:ml({kind:a,offset:e,command:this.scrollState,target:()=>this.getScrollStateTarget(this.scrollState)})&&(this.scrollState=null),this.pendingWrite=null,this._clampedAdjustment!==null&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null);let o=this.getScrollOffset(),s=this.scrollDirection;this.scrollDirection=t?o===e?this.scrollDirection:o<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t;let c=this.scrollState;if(c?.phase===`queued`&&a===`external`&&t){if(r||this._reportedOverscroll)c.samples=[];else{let e=this.now();c.samples=[...(c.samples??[]).filter(t=>e-t.t<=200),{t:e,offset:i}],(s!==null&&this.scrollDirection!==s||gl(c.samples))&&(this.scrollState=null)}}this._iosGesture.onScroll({isScrolling:t,ownReadBack:a===`readBack`,moved:e!==o,external:a===`external`&&this.scrollState?.phase!==`smooth`&&this.scrollState?.phase!==`smoothFinishing`})&&this.scrollState?.phase===`queued`&&(this.scrollState=null),this._flushHoldIfReady(!0),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement&&this.unsubs.push(this._iosGesture.listen(this.scrollElement)),this._scrollToOffset(this.getScrollOffset())}this._noteClampMax();let t=this.pendingScrollAnchor;this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled&&(t.kind===`anchor`?this._canWriteScroll()?Ll(this.scrollState)&&!ul(this.getScrollOffset()-t.delta,this.scrollState.lastTargetOffset)||(this._followOffsetTarget(t.delta),this._scrollToOffset(this.getScrollOffset())):(this._holdOffset+=t.delta,this._followOffsetTarget(t.delta),this.notify(!1)):this.scrollToEnd({behavior:t.behavior})),this._flushHoldIfReady(!1),this._retryClampedAdjustment()},this._classifyScrollEvent=(e,t,n)=>fl({offset:e,isScrolling:t,elementMax:n,holdOffset:this._holdOffset,scrollOffset:this.scrollOffset,pendingWrite:this.pendingWrite,clampedMaxAtWrite:this._clampedAdjustment?.maxAtWrite??null}),this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled||!this._canWriteScroll())return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,n=this.getMaxScrollOffset();n>t+.5&&(this._clampedAdjustment=e>n+.5?{target:e,maxAtWrite:n}:null,this._scrollToOffset(e))},this._writeAwaitingCommand=()=>{let e=this.scrollState;if(e===null||e.phase!==`queued`)return;let{behavior:t}=e;this.getMeasurements();let n=this.getScrollStateTarget(e);e.lastTargetOffset=n,this._clampedAdjustment=null,e.phase=Il(t,e.index!=null&&ul(n,this.getScrollOffset())),this._scrollToOffset(n,{behavior:t}),this.scheduleScrollReconcile()},this._readElementOffset=()=>{let e=this.scrollElement;if(e==null)return null;let{horizontal:t,isRtl:n}=this.options;return typeof e.scrollTop==`number`?t?e.scrollLeft*(n&&-1||1):e.scrollTop:typeof e.scrollY==`number`?t?e.scrollX:e.scrollY:null},this._canWriteScroll=()=>!(yl()&&this._iosGesture.inMotion())&&!this._reportedOverscroll,this._flushHoldIfReady=e=>{if(this._holdOffset===0||!this.scrollElement||!this.options.enabled||!this._canWriteScroll()||this.scrollState?.phase===`smooth`)return;this._holdOffset=0,this.scrollOffset!==null&&this.scrollOffset<0&&(this.scrollOffset=0),this.notify(e);let t=this.getCommandWrittenOffset()??this.getScrollOffset();this._clampedAdjustment=this._clampedBy(t),this._scrollToOffset(t)},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=cl(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=cl(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._singleLaneMeasurements?.flat;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e}let o=u===0?Array(e):this._singleLaneMeasurements.items.slice(),c;if(u===0)c=t+n;else{let e=u-1;c=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t);o[t]=e;let n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=c,a[t*2+1]=i,c+=i+s}this._singleLaneMeasurements={flat:a,items:o};let d=sl(o,a);return this.measurementsCache=d,d}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=cl(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes,this._getLayoutTotalSize()+this.options.scrollMargin],(e,t,n,r,i)=>{if(e.length===0||t===0)return this.range=null,null;let a=Math.max(i-t,0);return this.range=Hl(e,t,Math.min(n,a),r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range},{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=cl(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t,this.options.lanes]},(e,t,n,r,i,a)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n,lanes:a}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!Ll(this.scrollState))return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),e.isConnected&&(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var n;if(!this.isIndexInRange(e))return;this._resizeBatch?.sync&&this.getMeasurements();let r,i,a,o=this._singleLaneMeasurements?.flat;if(this.options.lanes===1&&o!=null)a=this.options.getItemKey(e),i=o[e*2],r=o[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;a=t.key,i=t.start,r=t.size}let s=this.itemSizeCache.get(a)??r,c=t-s;if(c!==0){let o=this.options.anchorTo===`end`&&!Ll(this.scrollState)&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,l=o?this._getLayoutTotalSize():0,u=this.getScrollOffset(),d=this.itemSizeCache.has(a)?i+s<=u&&this.scrollDirection!==`backward`:i<u,f=!Ll(this.scrollState)&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?d:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:a,start:i,size:r,end:i+r,lane:0},c,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(a,t),this.itemSizeCacheVersion++;let p=!1;if(this._awaitingCommandReadBack()||(o?p=this.applyScrollAdjustment(this._getLayoutTotalSize()-l):f&&(p=this.applyScrollAdjustment(c))),this._resizeBatch){this._resizeBatch.notify=!0,(n=this._resizeBatch).sync||(n.sync=p);return}this.notify(p),this._noteClampMax(),this._flushHoldIfReady(!0),this._retryClampedAdjustment()}},this.getVirtualItems=cl(()=>[this.getVirtualIndexes(),this.getMeasurements(),this._holdOffset],(e,t,n)=>{let r=[];for(let i=0,a=e.length;i<a;i++){let a=t[e[i]];r.push(n===0?a:{...a,start:a.start-n,end:a.end-n})}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._singleLaneMeasurements?.flat,r=this.options.lanes===1&&n!=null;return ll(t[Bl(0,t.length-1,r?e=>n[e*2]:e=>ll(t[e]).start,e)])},this._noteClampMax=()=>{if(!this._awaitingCommandReadBack())return;let e=this._elementMaxScrollOffset();if(e===null)return;let t=this.pendingWrite,n=Math.max(e,0)+this._holdOffset;if(n>=t.target)return;let r=t.lowMaxes??=[];r[r.length-1]!==n&&r.push(n)},this.getMaxScrollOffset=()=>(this._elementMaxScrollOffset()??0)+this._holdOffset,this._toLayoutOffset=e=>{let t=e+this._holdOffset;return this.pendingScrollAnchor?.kind===`anchor`&&(t+=this.pendingScrollAnchor.delta),t},this._elementMaxScrollOffset=()=>{let e=this.scrollElement;if(e===null)return null;if(`scrollHeight`in e)return this.options.horizontal?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight;if(`document`in e){let t=e.document.documentElement;return this.options.horizontal?t.scrollWidth-e.innerWidth:t.scrollHeight-e.innerHeight}return null},this._momentumStop=null,this._stopMomentum=e=>{let t=this.scrollElement,n=this.targetWindow;if(t===null||n===null)return;let r=`document`in t?t.document.scrollingElement:t;if(!r?.style)return;if(this._momentumStop){this._momentumStop.done=e;return}let{style:i}=r,a=this.options.horizontal?`overflow-x`:`overflow-y`,o=i.getPropertyValue(a),s=i.getPropertyPriority(a),c=()=>this.options.horizontal?r.clientHeight:r.clientWidth,l=c();if(i.setProperty(a,`hidden`,`important`),c()!==l){i.setProperty(a,o,s);return}let u={restore:()=>i.getPropertyValue(a)!==`hidden`||i.getPropertyPriority(a)!==`important`?!1:(i.setProperty(a,o,s),!0),done:e};this._momentumStop=u,n.requestAnimationFrame(()=>n.requestAnimationFrame(()=>{this._momentumStop===u&&(this._momentumStop=null,u.restore()&&u.done())}))},this._clampedBy=e=>{let t=this._elementMaxScrollOffset();if(t===null)return null;let n=t+this._holdOffset;return e>n+.5?{target:e,maxAtWrite:n}:null},this.getVirtualDistanceFromEnd=()=>Math.max(this._getLayoutTotalSize()+this.options.scrollMargin-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.getMeasurements()[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1){let e=this.getMaxScrollOffset(),n=e-this.options.paddingEnd+this.options.scrollPaddingEnd;return[Math.max(Math.min(n,e),0),t]}let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._startScroll({index:null,align:t},this.getOffsetForAlignment(e,t),n,`absolute`)},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r;this._startScroll({index:e,align:a},i,n,`absolute`)},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getOffsetForAlignment((this.getCommandWrittenOffset()??this.getScrollOffset())+e,`start`);this._startScroll({index:null,align:`start`},n,t,`relative`)},this.scrollToEnd=({behavior:e=`auto`}={})=>{this.options.count>0?this._startScroll({index:this.options.count-1,align:`end`,toEnd:!0},Math.max(this.getMaxScrollOffset(),0),e,`absolute`):this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.cancelScroll=()=>{this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null},this.getTotalSize=()=>Math.max(this._getLayoutTotalSize()-this._holdOffset,0),this._getLayoutTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._singleLaneMeasurements?.flat;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n}={})=>{let r={target:e+(t??0),smooth:n===`smooth`};return this.pendingWrite=r,this.options.scrollToFn(e-this._holdOffset,{behavior:n,adjustments:t},this),r},this.getCommandWrittenOffset=()=>this.scrollState!==null&&this.pendingWrite!==null&&!this.pendingWrite.smooth?this.pendingWrite.target:null,this._awaitingCommandReadBack=()=>{let e=this.getCommandWrittenOffset();return!(yl()&&this._iosGesture.dragging())&&e!==null&&!ul(e,this.getScrollOffset())},this._followOffsetTarget=e=>{this.scrollState!==null&&this.scrollState.index==null&&(this.scrollState.lastTargetOffset+=e)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}get scrollAdjustments(){return 0}applyScrollAdjustment(e,t){if(e===0)return!1;if(this._followOffsetTarget(e),this._canWriteScroll()){let n=this.getScrollOffset();this._clampedAdjustment=this._clampedBy(n+e);let r=this._scrollToOffset(n,{adjustments:e,behavior:t});return this.scrollOffset!==null&&(this.pendingWrite===r&&(this.scrollOffset+=e),this.scrollOffset<0&&(this.scrollOffset=0)),!0}return this._holdOffset+=e,this.scrollOffset!==null&&(this.scrollOffset+=e),!0}scheduleScrollReconcile(){this.targetWindow?this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}):this.scrollState=null}getScrollStateTarget(e){let t=e.toEnd?[Math.max(this.getMaxScrollOffset(),0)]:e.index==null?void 0:this.getOffsetForIndex(e.index,e.align);return t?t[0]:e.lastTargetOffset}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}if(this.scrollState.phase===`queued`){this.scheduleScrollReconcile();return}this.getMeasurements();let e=this.getScrollStateTarget(this.scrollState),t=this.scrollState.index==null?1:this.options.useAnimationFrameWithResizeObserver?3:2,n=e!==this.scrollState.lastTargetOffset;if(!n&&ul(e,this.getScrollOffset())){if(this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothLanded`:this.scrollState.phase===`smoothFinishing`&&(this.scrollState.phase=`instant`),this.scrollState.stableFrames++,this.scrollState.stableFrames>=t){this.getScrollOffset()!==e&&this._scrollToOffset(e,{behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let t=this.getSize()||600,n=Math.abs(e-this.getScrollOffset()),r=Ll(this.scrollState)&&n>t;this.scrollState.lastTargetOffset=e,r?this.scrollState.phase=`smooth`:this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothFinishing`:this.scrollState.phase===`smoothLanded`&&(this.scrollState.phase=`instant`),this._scrollToOffset(e,{behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}_startScroll(e,t,n,r){this.pendingScrollAnchor=null,this._clampedAdjustment=null;let i=this._iosGesture.tail();if(r===`absolute`&&i!==null){if(i===`fling`&&Sl()){this._stopMomentum(()=>{this.scrollState?.phase!==`queued`||this._iosGesture.tail()!==`fling`||this._reportedOverscroll||(this._iosGesture.end(),this._flushHoldIfReady(!0),this._writeAwaitingCommand())}),this.scrollState={...e,startedAt:this.now(),lastTargetOffset:t,stableFrames:0,phase:`queued`,behavior:n,samples:[]},this.scheduleScrollReconcile();return}this._iosGesture.end()}this.scrollState={...e,startedAt:this.now(),lastTargetOffset:t,stableFrames:0,behavior:n,phase:Il(n,e.index!=null&&ul(t,this.getScrollOffset()))},this._scrollToOffset(t,{behavior:n}),this.scheduleScrollReconcile()}},Bl=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Vl(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function Hl(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=Vl(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=Bl(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var Ul=typeof document<`u`?Y.useLayoutEffect:Y.useEffect;function Wl({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=Y.useReducer(e=>e+1,0)[1],a=Y.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=Y.useRef(!1),s=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},c=(e,t,n)=>{let r=a.current,i=!!e.options.horizontal,o=t.start-e.options.scrollMargin;r.lastPositions.get(n)!==o&&(r.lastPositions.set(n,o),r.mode===`transform`?n.style.transform=i?`translate3d(${o}px, 0, 0)`:`translate3d(0, ${o}px, 0)`:n.style[i?`left`:`top`]=`${o}px`)},l=e=>{let t=a.current;if(t.enabled&&t.container){s(e);for(let t of e.getVirtualItems()){let n=e.elementsCache.get(t.key);n&&c(e,t,n)}}},u={...r,onChange:(t,n)=>{var s;let c=a.current,u=!0;if(c.enabled){l(t);let e=t.range,n=c.prevRange;u=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,u&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&n&&!o.current?(0,al.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[d]=Y.useState(()=>{let e=new zl(u),t=e.measureElement;return e.measureElement=n=>{o.current=!0;try{t(n)}finally{o.current=!1}let r=a.current;if(n!==null&&r.enabled&&r.container){let t=e.measurementsCache[e.indexFromElement(n)];t&&c(e,t,n)}},Object.assign(e,{containerRef:t=>{let n=a.current;n.container=t,n.lastSize=null,t!==null&&l(e)}})});return d.setOptions(u),Ul(()=>d._didMount(),[]),Ul(()=>(s(d),d._willUpdate())),Ul(()=>{l(d)}),d}function Gl(e){return Wl({observeElementRect:kl,observeElementOffset:Nl,scrollToFn:Fl,...e})}var Kl=cs({columnVisibilityFeature:Fc,columnOrderingFeature:bs,columnPinningFeature:$s,columnSizingFeature:yc,rowSortingFeature:nl}),ql=[],Jl=e=>Math.min(640,Math.max(64,Math.round(e)));function Yl(e,{cols:t,pin:n,widths:r=null,defaults:i}){let a=new Set(e.map(e=>e.id)),o=(t?t.split(`,`):i.shown).filter(e=>a.has(e));for(let t of e)t.always&&!o.includes(t.id)&&o.unshift(t.id);let s=e.map(e=>e.id).filter(e=>!o.includes(e));return{order:[...o,...s],hidden:s,pinned:(n==null?i.pinned:n.split(`,`)).filter(e=>o.includes(e)),sizes:Object.fromEntries(String(r||``).split(`,`).map(e=>e.split(`:`)).filter(([e,t])=>a.has(e)&&Number.isFinite(Number(t))&&Number(t)>0).map(([e,t])=>[e,Jl(Number(t))]))}}var Xl=(e,t)=>{let n=e.order.filter(t=>!e.hidden.includes(t)),r=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]);return{cols:r(n,t.shown)?null:n.join(`,`),pin:r(e.pinned,t.pinned)?null:e.pinned.join(`,`)||`none`,w:Object.entries(e.sizes||{}).map(([e,t])=>`${e}:${t}`).join(`,`)||null}};function Zl({label:e,columns:t,items:n,rowKey:r,layout:a,onLayout:s,sort:c=null,onSort:u=null,dense:p=!1,onOpen:m,openId:h=null,onToggleGroup:g=null,onMore:_=null,hasMore:v=!1,loadingMore:y=!1,card:b,footer:x=null,busy:C=!1}){let w=o(`(max-width: 639px)`),T=(0,Y.useRef)(null),[E,D]=(0,Y.useState)(0),[O,k]=(0,Y.useState)(null),[A,j]=(0,Y.useState)(null),[M,N]=(0,Y.useState)(null),ee=O?{...a.sizes,[O.id]:O.width}:a.sizes||{},P=w?84:p?34:44,F=il({features:Kl,columns:(0,Y.useMemo)(()=>t.map(e=>({id:e.id,accessorFn:e=>e,header:e.header,size:e.width,enableSorting:!!e.sort,enableHiding:!e.always,meta:e})),[t]),data:ql,manualSorting:!0,enableSortingRemoval:!1,state:{columnOrder:a.order,columnVisibility:Object.fromEntries(a.hidden.map(e=>[e,!1])),columnPinning:{start:a.pinned,end:[]},columnSizing:ee,sorting:c?[{id:t.find(e=>e.sort===c.id)?.id||``,desc:c.dir===`desc`}]:[]},onColumnOrderChange:e=>s({...a,order:typeof e==`function`?e(a.order):e}),onColumnVisibilityChange:e=>{let t=Object.fromEntries(a.hidden.map(e=>[e,!1])),n=typeof e==`function`?e(t):e,r=Object.keys(n).filter(e=>n[e]===!1);s({...a,hidden:r,pinned:a.pinned.filter(e=>!r.includes(e))})},onColumnSizingChange:e=>s({...a,sizes:typeof e==`function`?e(a.sizes||{}):e}),onColumnPinningChange:e=>{let t=typeof e==`function`?e({start:a.pinned,end:[]}):e;s({...a,pinned:t.start||t.left||[]})},onSortingChange:e=>{let n=c?[{id:t.find(e=>e.sort===c.id)?.id||``,desc:c.dir===`desc`}]:[],r=(typeof e==`function`?e(n):e)[0],i=t.find(e=>e.id===r?.id);i?.sort&&u?.({id:i.sort,dir:r.desc?`desc`:`asc`})}}),I=F.getVisibleLeafColumns(),L=[...I.filter(e=>e.getIsPinned()),...I.filter(e=>!e.getIsPinned())],te=[],ne=0;for(let e of L)te.push(ne),ne+=e.getSize();let re=ne,ie=L.filter(e=>e.getIsPinned()).length-1,ae=(e,t)=>{e.preventDefault(),e.stopPropagation();let n=e.clientX,r=t.getSize(),i=r,o=e=>{i=Jl(r+e.clientX-n),k({id:t.id,width:i})},s=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),k(null),i!==r&&F.setColumnSizing({...a.sizes||{},[t.id]:i})};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s),k({id:t.id,width:i})},R=e=>{let t=A;if(j(null),N(null),!t||t===e)return;let n=a.order.filter(e=>e!==t),r=n.indexOf(e),i=a.order.indexOf(t)<a.order.indexOf(e);n.splice(i?r+1:r,0,t),F.setColumnOrder(n)},oe=Gl({count:n.length,getScrollElement:()=>T.current,estimateSize:()=>P,overscan:12});(0,Y.useEffect)(()=>{oe.measure()},[P]);let se=oe.getVirtualItems(),ce=se.at(-1)?.index??0;(0,Y.useEffect)(()=>{v&&!y&&n.length&&ce>=n.length-15&&_?.()},[v,y,n.length,ce,_]),(0,Y.useEffect)(()=>{E>n.length-1&&D(Math.max(0,n.length-1))},[n.length,E]);let le=(0,Y.useCallback)(e=>{e&&(e.type===`row`?m?.(e.row):e.type===`group`?g?.(e.group.key):e.type===`more`&&e.load?.())},[m,g]),z=e=>{let t=Math.min(Math.max(e,0),n.length-1);D(t),oe.scrollToIndex(t,{align:`auto`})},ue=e=>{if(e.target!==e.currentTarget&&e.target.closest(`button, a, input, [role="menuitem"]`))return;let t=n[E],r={ArrowDown:()=>z(E+1),ArrowUp:()=>z(E-1),Home:()=>z(0),End:()=>z(n.length-1),PageDown:()=>z(E+10),PageUp:()=>z(E-10),Enter:()=>le(t)," ":()=>le(t),ArrowRight:()=>t?.type===`group`&&!t.open?g?.(t.group.key):null,ArrowLeft:()=>t?.type===`group`&&t.open?g?.(t.group.key):null};r[e.key]&&(e.preventDefault(),r[e.key]())},B=e=>`sw-grid-row-${e}`,V=(e,t)=>e.type===`row`?r(e.row):`${e.type}:${e.group?.key??t}`;if(w)return(0,X.jsxs)(`div`,{className:i(`transition-opacity`,C&&`opacity-60`),"data-sw-grid":`cards`,children:[(0,X.jsx)(`ul`,{"aria-label":e,className:`divide-y divide-line`,children:n.map((e,t)=>(0,X.jsx)(`li`,{children:e.type===`row`?(0,X.jsx)(`button`,{type:`button`,onClick:()=>m?.(e.row),className:`block w-full px-4 py-3 text-left outline-none active:bg-surface-2 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent`,"data-sw-grid-row":r(e.row),children:b(e.row)}):e.type===`group`?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>g?.(e.group.key),"aria-expanded":e.open,className:`flex min-h-11 w-full items-center gap-2 bg-surface-2 px-4 py-2 text-left text-sm font-medium text-fg outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent`,"data-sw-grid-group":e.group.key,children:[e.open?(0,X.jsx)(f,{size:15,"aria-hidden":`true`}):(0,X.jsx)(d,{size:15,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.group.label}),(0,X.jsx)(`span`,{className:`tabular text-xs font-normal text-muted`,children:e.summary})]}):(0,X.jsx)(`div`,{className:`px-4 py-2`,children:(0,X.jsxs)(l,{size:`touch`,variant:`secondary`,className:`w-full`,onClick:e.load,disabled:e.busy,children:[e.busy?(0,X.jsx)(S,{}):null,` Show more`]})})},V(e,t)))}),v?(0,X.jsx)(`div`,{className:`border-t border-line p-3`,children:(0,X.jsxs)(l,{size:`touch`,variant:`secondary`,className:`w-full`,onClick:_,disabled:y,"data-sw-grid-more":!0,children:[y?(0,X.jsx)(S,{}):null,` Show more`]})}):null,x]});let de=F.getHeaderGroups()[0]?.headers||[],fe=new Map(de.map(e=>[e.column.id,e]));return(0,X.jsxs)(`div`,{className:i(`transition-opacity`,C&&`opacity-60`),"data-sw-grid":`table`,children:[(0,X.jsx)(`div`,{ref:T,role:`grid`,"aria-label":e,"aria-rowcount":n.length+1,"aria-colcount":L.length,"aria-activedescendant":n.length?B(E):void 0,tabIndex:0,onKeyDown:ue,className:`group/grid relative max-h-[min(72vh,720px)] min-h-[220px] overflow-auto outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent`,"data-sw-grid-scroll":!0,children:(0,X.jsxs)(`div`,{style:{width:re,minWidth:`100%`},children:[(0,X.jsx)(`div`,{role:`row`,"aria-rowindex":1,className:`sticky top-0 z-20 flex border-b border-line bg-surface-2`,children:L.map((e,t)=>{let n=e.columnDef.meta,r=e.getIsSorted(),o=!!e.getIsPinned();return(0,X.jsxs)(`div`,{role:`columnheader`,"aria-colindex":t+1,"aria-sort":r?r===`desc`?`descending`:`ascending`:e.getCanSort()?`none`:void 0,style:{width:e.getSize(),flex:t===L.length-1?`1 0 auto`:`0 0 auto`,...o?{left:te[t]}:{}},className:i(`group/header relative flex h-9 items-center gap-0.5 bg-surface-2 pr-1 pl-3 text-xs font-medium text-muted`,o&&`sticky z-10`,o&&t===ie&&`border-r border-line`,n.align===`right`&&`justify-end`,A===e.id&&`opacity-50`,M===e.id&&A!==e.id&&`bg-accent/15 shadow-[inset_2px_0_0_var(--accent)]`),draggable:!O,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.id),j(e.id)},onDragOver:t=>{A&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,M!==e.id&&N(e.id))},onDrop:t=>{t.preventDefault(),R(e.id)},onDragEnd:()=>{j(null),N(null)},"data-sw-grid-header":e.id,children:[e.getCanSort()?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>e.toggleSorting(!r||r!==`desc`),className:i(`inline-flex min-w-0 items-center gap-1 rounded px-1 py-1 outline-none hover:text-fg focus-visible:outline-2 focus-visible:outline-accent`,r&&`text-fg`),title:`Sort by ${n.title||n.header}`,"data-sw-grid-sort":e.id,children:[(0,X.jsx)(`span`,{className:`truncate`,children:n.header}),r===`desc`?(0,X.jsx)(Dt,{size:12,"aria-hidden":`true`}):r===`asc`?(0,X.jsx)(kt,{size:12,"aria-hidden":`true`}):null]}):(0,X.jsx)(`span`,{className:`truncate px-1`,children:n.header}),(0,X.jsx)(Ql,{column:e,meta:n,index:a.order.indexOf(e.id),layout:a,onLayout:s,canHide:fe.get(e.id)?.column.getCanHide()!==!1,onWidth:t=>F.setColumnSizing({...a.sizes||{},[e.id]:Jl(t)}),onResetWidth:()=>F.setColumnSizing(Object.fromEntries(Object.entries(a.sizes||{}).filter(([t])=>t!==e.id)))}),(0,X.jsx)(`span`,{"aria-hidden":`true`,onPointerDown:t=>ae(t,e),onDoubleClick:()=>F.setColumnSizing(Object.fromEntries(Object.entries(a.sizes||{}).filter(([t])=>t!==e.id))),draggable:!1,className:i(`absolute inset-y-0 -right-1 z-10 w-2 cursor-col-resize touch-none select-none after:absolute after:inset-y-1.5 after:left-1/2 after:w-px after:bg-line-strong after:opacity-0 group-hover/header:after:opacity-100`,O?.id===e.id&&`after:w-0.5 after:bg-accent after:opacity-100`),"data-sw-grid-resize":e.id})]},e.id)})}),(0,X.jsx)(`div`,{style:{height:oe.getTotalSize(),position:`relative`},children:se.map(e=>{let t=n[e.index];if(!t)return null;let a=e.index===E,o={position:`absolute`,top:0,left:0,width:`100%`,height:e.size,transform:`translateY(${e.start}px)`};if(t.type===`more`)return(0,X.jsx)(`div`,{id:B(e.index),role:`row`,"aria-rowindex":e.index+2,style:o,className:`flex items-center border-b border-line/60 pl-10`,children:(0,X.jsxs)(l,{size:`xs`,variant:`ghost`,onClick:t.load,disabled:t.busy,tabIndex:-1,"data-sw-grid-group-more":t.group?.key,children:[t.busy?(0,X.jsx)(S,{}):null,` Show more of `,t.group?.label]})},V(t,e.index));if(t.type===`group`){let n=L.findIndex((e,t)=>t>0&&e.columnDef.meta.subtotal),r=n<0?L.length:n,s=L.slice(0,r).reduce((e,t)=>e+t.getSize(),0);return(0,X.jsxs)(`div`,{id:B(e.index),role:`row`,"aria-rowindex":e.index+2,"aria-expanded":t.open,"aria-selected":a,style:o,onClick:()=>{D(e.index),g?.(t.group.key)},className:i(`flex cursor-pointer items-center border-b border-line bg-surface-2/70 text-xs font-medium text-fg hover:bg-surface-2`,a&&`group-focus-visible/grid:outline-2 group-focus-visible/grid:-outline-offset-2 group-focus-visible/grid:outline-accent`),"data-sw-grid-group":t.group.key,children:[(0,X.jsxs)(`div`,{role:`gridcell`,style:{width:s,flex:`0 0 auto`},className:`sticky left-0 z-10 flex items-center gap-1.5 pl-3`,children:[t.open?(0,X.jsx)(f,{size:14,"aria-hidden":`true`}):(0,X.jsx)(d,{size:14,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`truncate`,children:t.group.label}),(0,X.jsx)(`span`,{className:`tabular font-normal text-muted`,children:t.summary})]}),L.slice(r).map((e,n)=>(0,X.jsx)(`div`,{role:`gridcell`,style:{width:e.getSize(),flex:r+n===L.length-1?`1 0 auto`:`0 0 auto`},className:i(`tabular truncate px-3`,e.columnDef.meta.align===`right`&&`text-right`),children:e.columnDef.meta.subtotal?.(t.group)??``},e.id))]},V(t,e.index))}let s=r(t.row);return(0,X.jsx)(`div`,{id:B(e.index),role:`row`,"aria-rowindex":e.index+2,"aria-selected":a,style:o,onClick:()=>{D(e.index),m?.(t.row)},className:i(`group/row flex cursor-pointer border-b border-line/60 text-xs text-fg hover:bg-surface-2`,h===s&&`bg-accent/8`,a&&`group-focus-visible/grid:outline-2 group-focus-visible/grid:-outline-offset-2 group-focus-visible/grid:outline-accent`),"data-sw-grid-row":s,children:L.map((e,n)=>{let r=e.columnDef.meta,a=!!e.getIsPinned();return(0,X.jsx)(`div`,{role:`gridcell`,"aria-colindex":n+1,style:{width:e.getSize(),flex:n===L.length-1?`1 0 auto`:`0 0 auto`,...a?{left:te[n]}:{}},className:i(`flex min-w-0 items-center px-3`,r.align===`right`&&`tabular justify-end`,a&&`sticky z-10 bg-surface group-hover/row:bg-surface-2`,a&&h===s&&`bg-[color-mix(in_srgb,var(--accent)_8%,var(--surface))]`,a&&n===ie&&`border-r border-line`,t.depth&&n===0&&`pl-8`),"data-sw-grid-cell":e.id,children:(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:r.cell(t.row)})},e.id)})},s)})})]})}),x]})}function Ql({column:t,meta:r,index:i,layout:o,onLayout:s,canHide:c,onWidth:l,onResetWidth:u}){let d=!!t.getIsPinned(),f=o.order.filter(e=>!o.hidden.includes(e)),p=f.indexOf(t.id),m=e=>{let n=f[p+e];if(!n)return;let r=[...o.order],i=r.indexOf(t.id),a=r.indexOf(n);r[i]=n,r[a]=t.id,s({...o,order:r})};return(0,X.jsxs)(n,{children:[(0,X.jsx)(D,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":`${r.title||r.header}: column options`,className:`inline-flex h-6 w-5 shrink-0 items-center justify-center rounded text-faint opacity-0 outline-none hover:bg-surface hover:text-fg focus-visible:opacity-100 focus-visible:outline-2 focus-visible:outline-accent data-[state=open]:opacity-100 [[role=columnheader]:hover_&]:opacity-100`,"data-sw-grid-menu":t.id,children:(0,X.jsx)(qt,{size:13,"aria-hidden":`true`})})}),(0,X.jsxs)(ee,{align:`start`,className:`w-48`,children:[t.getCanSort()?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(a,{onSelect:()=>t.toggleSorting(!1),children:[(0,X.jsx)(kt,{size:14,"aria-hidden":`true`}),` Sort ascending`]}),(0,X.jsxs)(a,{onSelect:()=>t.toggleSorting(!0),children:[(0,X.jsx)(Dt,{size:14,"aria-hidden":`true`}),` Sort descending`]}),(0,X.jsx)(e,{})]}):null,(0,X.jsxs)(a,{onSelect:()=>t.pin(!d&&`start`),"data-sw-grid-pin":t.id,children:[d?(0,X.jsx)(un,{size:14,"aria-hidden":`true`}):(0,X.jsx)(fn,{size:14,"aria-hidden":`true`}),` `,d?`Unpin`:`Pin to the left`]}),(0,X.jsxs)(a,{disabled:p<=0,onSelect:()=>m(-1),children:[(0,X.jsx)(ce,{size:14,"aria-hidden":`true`}),` Move left`]}),(0,X.jsxs)(a,{disabled:p<0||p>=f.length-1,onSelect:()=>m(1),children:[(0,X.jsx)(re,{size:14,"aria-hidden":`true`}),` Move right`]}),(0,X.jsx)(e,{}),(0,X.jsxs)(a,{disabled:t.getSize()>=640,onSelect:()=>l(t.getSize()+32),"data-sw-grid-wider":t.id,children:[(0,X.jsx)(Lt,{size:14,"aria-hidden":`true`}),` Wider`]}),(0,X.jsxs)(a,{disabled:t.getSize()<=64,onSelect:()=>l(t.getSize()-32),"data-sw-grid-narrower":t.id,children:[(0,X.jsx)(zt,{size:14,"aria-hidden":`true`}),` Narrower`]}),o.sizes?.[t.id]?(0,X.jsxs)(a,{onSelect:u,children:[(0,X.jsx)(Re,{size:14,"aria-hidden":`true`}),` Its usual width`]}):null,c&&!r.always?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(e,{}),(0,X.jsxs)(a,{onSelect:()=>t.toggleVisibility(!1),"data-sw-grid-hide":t.id,children:[(0,X.jsx)(Yt,{size:14,"aria-hidden":`true`}),` Hide this column`]})]}):null,(0,X.jsxs)(`span`,{className:`sr-only`,children:[`Column `,i+1]})]})]})}function $l({columns:e,layout:t,onLayout:n,onReset:r}){let i=new Map(e.map(e=>[e.id,e])),a=e=>{let r=t.hidden.includes(e)?t.hidden.filter(t=>t!==e):[...t.hidden,e],i=[...t.order.filter(e=>!r.includes(e)),...t.order.filter(e=>r.includes(e))];n({...t,order:i,hidden:r,pinned:t.pinned.filter(e=>!r.includes(e))})},o=(e,r)=>{let i=[...t.order],a=i.indexOf(e),o=a+r;o<0||o>=i.length||([i[a],i[o]]=[i[o],i[a]],n({...t,order:i}))},s=e=>n({...t,pinned:t.pinned.includes(e)?t.pinned.filter(t=>t!==e):[...t.pinned,e]});return(0,X.jsxs)(b,{history:!1,children:[(0,X.jsx)(F,{asChild:!0,children:(0,X.jsxs)(l,{size:`sm`,variant:`secondary`,className:`h-9`,"data-sw-grid-columns":!0,children:[(0,X.jsx)(Gt,{size:14,"aria-hidden":`true`}),` Columns`]})}),(0,X.jsxs)(N,{align:`end`,className:`w-72 p-1.5`,children:[(0,X.jsx)(`ul`,{className:`max-h-80 overflow-y-auto`,"aria-label":`Columns`,children:t.order.map((e,n)=>{let r=i.get(e);if(!r)return null;let c=!t.hidden.includes(e);return(0,X.jsxs)(`li`,{className:`flex items-center gap-0.5 rounded-md px-1 hover:bg-surface-2`,children:[(0,X.jsxs)(`label`,{className:`flex min-h-8 min-w-0 flex-1 cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:c,disabled:r.always,onChange:()=>a(e),className:`h-4 w-4 accent-[var(--accent)]`,"data-sw-grid-column":e}),(0,X.jsx)(`span`,{className:`truncate`,children:r.title||r.header})]}),(0,X.jsx)(y,{label:t.pinned.includes(e)?`Unpin ${r.header}`:`Pin ${r.header} to the left`,size:`icon-xs`,disabled:!c,onClick:()=>s(e),children:t.pinned.includes(e)?(0,X.jsx)(fn,{size:13,className:`text-accent`,"aria-hidden":`true`}):(0,X.jsx)(fn,{size:13,"aria-hidden":`true`})}),(0,X.jsx)(y,{label:`Move ${r.header} up`,size:`icon-xs`,disabled:n===0,onClick:()=>o(e,-1),children:(0,X.jsx)(kt,{size:13,"aria-hidden":`true`})}),(0,X.jsx)(y,{label:`Move ${r.header} down`,size:`icon-xs`,disabled:n===t.order.length-1,onClick:()=>o(e,1),children:(0,X.jsx)(Dt,{size:13,"aria-hidden":`true`})})]},e)})}),(0,X.jsx)(`div`,{className:`mt-1 border-t border-line pt-1`,children:(0,X.jsxs)(l,{size:`sm`,variant:`ghost`,className:`w-full justify-start`,onClick:r,"data-sw-grid-columns-reset":!0,children:[(0,X.jsx)(Re,{size:13,"aria-hidden":`true`}),` Back to the usual columns`]})})]})]})}function eu(e){let{margin:t,containerPadding:n,containerWidth:r,cols:i}=e;return(r-t[0]*(i-1)-n[0]*2)/i}function tu(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function nu(e,t,n,r,i,a,o){let{margin:s,containerPadding:c,rowHeight:l}=e,u=eu(e),d,f,p,m;if(o?(d=Math.round(o.width),f=Math.round(o.height)):(d=tu(r,u,s[0]),f=tu(i,l,s[1])),a?(p=Math.round(a.top),m=Math.round(a.left)):o?(p=Math.round(o.top),m=Math.round(o.left)):(p=Math.round((l+s[1])*n+c[1]),m=Math.round((u+s[0])*t+c[0])),!a&&!o){if(Number.isFinite(r)){let e=Math.round((u+s[0])*(t+r)+c[0])-m-d;e!==s[0]&&(d+=e-s[0])}if(Number.isFinite(i)){let e=Math.round((l+s[1])*(n+i)+c[1])-p-f;e!==s[1]&&(f+=e-s[1])}}return{top:p,left:m,width:d,height:f}}function ru(e,t,n,r,i){let{margin:a,containerPadding:o,cols:s,rowHeight:c,maxRows:l}=e,u=eu(e),d=Math.round((n-o[0])/(u+a[0])),f=Math.round((t-o[1])/(c+a[1]));return d=ou(d,0,s-r),f=ou(f,0,l-i),{x:d,y:f}}function iu(e,t,n){let{margin:r,containerPadding:i,rowHeight:a}=e,o=eu(e);return{x:Math.round((n-i[0])/(o+r[0])),y:Math.round((t-i[1])/(a+r[1]))}}function au(e,t,n){let{margin:r,rowHeight:i}=e,a=eu(e);return{w:Math.max(1,Math.round((t+r[0])/(a+r[0]))),h:Math.max(1,Math.round((n+r[1])/(i+r[1])))}}function ou(e,t,n){return Math.max(Math.min(e,n),t)}function su(e,t){return!(e.i===t.i||e.x+e.w<=t.x||e.x>=t.x+t.w||e.y+e.h<=t.y||e.y>=t.y+t.h)}function cu(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0&&su(r,t))return r}}function lu(e,t){return e.filter(e=>su(e,t))}function uu(e,t){return t===`horizontal`?fu(e):t===`vertical`||t===`wrap`?du(e):[...e]}function du(e){return[...e].sort((e,t)=>e.y===t.y?e.x-t.x:e.y-t.y)}function fu(e){return[...e].sort((e,t)=>e.x===t.x?e.y-t.y:e.x-t.x)}function pu(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0){let e=r.y+r.h;e>t&&(t=e)}}return t}function mu(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0&&r.i===t)return r}}function hu(e){return e.filter(e=>e.static===!0)}function gu(e){return{i:e.i,x:e.x,y:e.y,w:e.w,h:e.h,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,moved:!!e.moved,static:!!e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,constraints:e.constraints,isBounded:e.isBounded}}function _u(e){let t=Array(e.length);for(let n=0;n<e.length;n++){let r=e[n];r!==void 0&&(t[n]=gu(r))}return t}function vu(e,t){let n=Array(e.length);for(let r=0;r<e.length;r++){let i=e[r];i!==void 0&&(t.i===i.i?n[r]=t:n[r]=i)}return n}function yu(e,t,n){let r=mu(e,t);return r?(r=n(gu(r)),[vu(e,r),r]):[[...e],null]}function bu(e,t){let n=hu(e);for(let r=0;r<e.length;r++){let i=e[r];if(i!==void 0){if(i.x+i.w>t.cols&&(i.x=t.cols-i.w),i.x<0&&(i.x=0,i.w=t.cols),i.y===1/0&&(i.y=pu(n)),!i.static)n.push(i);else for(;cu(n,i);)i.y++}}return e}function xu(e,t,n,r,i,a,o,s,c){if(t.static&&t.isDraggable!==!0||t.y===r&&t.x===n)return[...e];let l=t.x,u=t.y;typeof n==`number`&&(t.x=n),typeof r==`number`&&(t.y=r),t.moved=!0;let d=uu(e,o);(o===`vertical`&&typeof r==`number`?u>=r:o===`horizontal`&&typeof n==`number`&&l>=n)&&(d=d.reverse());let f=lu(d,t),p=f.length>0;if(p&&c)return _u(e);if(p&&a)return t.x=l,t.y=u,t.moved=!1,e;let m=[...e];for(let e=0;e<f.length;e++){let n=f[e];n!==void 0&&(n.moved||(m=n.static?Su(m,n,t,i,o):Su(m,t,n,i,o)))}return m}function Su(e,t,n,r,i,a){let o=i===`horizontal`||i===`wrap`,s=i===`vertical`,c=t.static;if(r){r=!1;let a={x:o?Math.max(t.x-n.w,0):n.x,y:s?Math.max(t.y-n.h,0):n.y,w:n.w,h:n.h,i:`-1`},l=cu(e,a),u=l!==void 0&&l.y+l.h>t.y,d=l!==void 0&&t.x+t.w>l.x;if(!l)return xu(e,n,o?a.x:void 0,s?a.y:void 0,r,c,i);if(u&&s)return xu(e,n,void 0,n.y+1,r,c,i);if(u&&i===null){let r=n.y;return t.y=r,n.y=r+t.h,[...e]}if(d&&o)return xu(e,t,n.x,void 0,r,c,i)}let l=o?n.x+1:void 0,u=s?n.y+1:void 0;return l===void 0&&u===void 0?[...e]:xu(e,n,l,u,r,c,i)}function Cu(e,t,n){return Math.max(t,Math.min(n,e))}var wu=[{name:`gridBounds`,constrainPosition(e,t,n,{cols:r,maxRows:i}){return{x:Cu(t,0,Math.max(0,r-e.w)),y:Cu(n,0,Math.max(0,i-e.h))}},constrainSize(e,t,n,r,{cols:i,maxRows:a}){let o=r===`w`||r===`nw`||r===`sw`?e.x+e.w:i-e.x,s=r===`n`||r===`nw`||r===`ne`?e.y+e.h:a-e.y;return{w:Cu(t,1,Math.max(1,o)),h:Cu(n,1,Math.max(1,s))}}},{name:`minMaxSize`,constrainSize(e,t,n){return{w:Cu(t,e.minW??1,e.maxW??1/0),h:Cu(n,e.minH??1,e.maxH??1/0)}}}];function Tu(e,t,n,r,i){let a={x:n,y:r};for(let n of e)n.constrainPosition&&(a=n.constrainPosition(t,a.x,a.y,i));if(t.constraints)for(let e of t.constraints)e.constrainPosition&&(a=e.constrainPosition(t,a.x,a.y,i));return a}function Eu(e,t,n,r,i,a){let o={w:n,h:r};for(let n of e)n.constrainSize&&(o=n.constrainSize(t,o.w,o.h,i,a));if(t.constraints)for(let e of t.constraints)e.constrainSize&&(o=e.constrainSize(t,o.w,o.h,i,a));return o}function Du({top:e,left:t,width:n,height:r}){let i=`translate(${t}px,${e}px)`;return{transform:i,WebkitTransform:i,MozTransform:i,msTransform:i,OTransform:i,width:`${n}px`,height:`${r}px`,position:`absolute`}}function Ou({top:e,left:t,width:n,height:r}){return{top:`${e}px`,left:`${t}px`,width:`${n}px`,height:`${r}px`,position:`absolute`}}function ku(e){return e*100+`%`}function Au(e,t,n,r){return e+n>r?t:n}function ju(e,t,n){return e<0?t:n}function Mu(e){return Math.max(0,e)}function Nu(e){return Math.max(0,e)}var Pu=(e,t,n)=>{let{left:r,height:i,width:a}=t,o=e.top-(i-e.height);return{left:r,width:a,height:ju(o,e.height,i),top:Nu(o)}},Fu=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{top:r,height:a,width:Au(e.left,e.width,o,n),left:Mu(i)}},Iu=(e,t,n)=>{let{top:r,height:i,width:a}=t,o=e.left+e.width-a;return o<0?{height:i,width:e.left+e.width,top:Nu(r),left:0}:{height:i,width:a,top:Nu(r),left:o}},Lu=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{width:o,left:i,height:ju(r,e.height,a),top:Nu(r)}},Ru={n:Pu,ne:(e,t,n)=>Pu(e,Fu(e,t,n)),e:Fu,se:(e,t,n)=>Lu(e,Fu(e,t,n)),s:Lu,sw:(e,t,n)=>Lu(e,Iu(e,t)),w:Iu,nw:(e,t,n)=>Pu(e,Iu(e,t))};function zu(e,t,n,r){let i=Ru[e];return i?i(t,{...t,...n},r):n}var Bu={type:`transform`,scale:1,calcStyle(e){return Du(e)}},Vu={cols:12,rowHeight:150,margin:[10,10],containerPadding:null,maxRows:1/0},Hu={enabled:!0,bounded:!1,threshold:3},Uu={enabled:!0,handles:[`se`]},Wu={enabled:!1,defaultItem:{w:1,h:1},touchEnabled:!0,touchDragSource:`[data-rgl-draggable]`};function Gu(e,t,n,r,i){let a=r===`x`?`w`:`h`;t[r]+=1;let o=e.findIndex(e=>e.i===t.i),s=i??hu(e).length>0;for(let i=o+1;i<e.length;i++){let o=e[i];if(o!==void 0&&!o.static){if(!s&&o.y>t.y+t.h)break;su(t,o)&&Gu(e,o,n+t[a],r,s)}}t[r]=n}function Ku(e,t,n,r){for(t.x=Math.max(t.x,0),t.y=Math.max(t.y,0),t.y=Math.min(r,t.y);t.y>0&&!cu(e,t);)t.y--;let i;for(;(i=cu(e,t))!==void 0;)Gu(n,t,i.y+i.h,`y`);return t.y=Math.max(t.y,0),t}function qu(e,t,n,r){for(t.x=Math.max(t.x,0),t.y=Math.max(t.y,0);t.x>0&&!cu(e,t);)t.x--;let i;for(;(i=cu(e,t))!==void 0;)if(Gu(r,t,i.x+i.w,`x`),t.x+t.w>n)for(t.x=n-t.w,t.y++;t.x>0&&!cu(e,t);)t.x--;return t.x=Math.max(t.x,0),t}var Ju={type:`vertical`,allowOverlap:!1,compact(e,t){let n=hu(e),r=pu(n),i=du(e),a=Array(e.length);for(let t=0;t<i.length;t++){let o=i[t];if(o===void 0)continue;let s=gu(o);s.static||(s=Ku(n,s,i,r),r=Math.max(r,s.y+s.h),n.push(s));let c=e.indexOf(o);a[c]=s,s.moved=!1}return a}},Yu={type:`horizontal`,allowOverlap:!1,compact(e,t){let n=hu(e),r=fu(e),i=Array(e.length);for(let a=0;a<r.length;a++){let o=r[a];if(o===void 0)continue;let s=gu(o);s.static||(s=qu(n,s,t,r),n.push(s));let c=e.indexOf(o);i[c]=s,s.moved=!1}return i}},Xu={type:null,allowOverlap:!1,compact(e,t){return _u(e)}},Zu={...Ju,allowOverlap:!0,compact(e,t){return _u(e)}},Qu={...Yu,allowOverlap:!0,compact(e,t){return _u(e)}},$u={...Xu,allowOverlap:!0};function ed(e,t=!1,n=!1){let r;return r=t?e===`vertical`?Zu:e===`horizontal`?Qu:$u:e===`vertical`?Ju:e===`horizontal`?Yu:Xu,n?{...r,preventCollision:n}:r}function td(e){return Object.keys(e).sort((t,n)=>e[t]-e[n])}function nd(e,t){let n=td(e),r=n[0];if(r===void 0)throw Error(`No breakpoints defined`);for(let i=1;i<n.length;i++){let a=n[i];a!==void 0&&t>e[a]&&(r=a)}return r}function rd(e,t){let n=t[e];if(n===void 0)throw Error(`ResponsiveReactGridLayout: \`cols\` entry for breakpoint ${String(e)} is missing!`);return n}function id(e,t,n,r,i,a){let o=e[n];if(o)return _u(o);let s=e[r],c=td(t),l=c.slice(c.indexOf(n));for(let t=0;t<l.length;t++){let n=l[t];if(n===void 0)continue;let r=e[n];if(r){s=r;break}}let u=bu(_u(s||[]),{cols:i});return(typeof a==`object`&&a?a:ed(a)).compact(u,i)}function ad(e,t){if(Array.isArray(e))return e;let n=e,r=n[t];if(r!==void 0)return r;let i=Object.keys(n);for(let e of i){let t=n[e];if(t!==void 0)return t}return[10,10]}var od=I(((e,t,n)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):(n=typeof globalThis<`u`?globalThis:n||self,r(n[`fast-equals`]={}))})(n,(function(e){function t(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function n(e){return function(t,n,r,i){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r,i);var a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);var s=e(t,n,r,i);return i.delete(t),i.delete(n),s}}function r(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n}function i(e){return e.constructor===Object||e.constructor==null}function a(e){return typeof e.then==`function`}function o(e,t){return e===t||e!==e&&t!==t}var s=Object.prototype.toString;function c(e){var t=e.areArraysEqual,n=e.areDatesEqual,r=e.areMapsEqual,c=e.areObjectsEqual,l=e.areRegExpsEqual,u=e.areSetsEqual,d=e.createIsNestedEqual,f=d(p);function p(e,d,p){if(e===d)return!0;if(!e||!d||typeof e!=`object`||typeof d!=`object`)return e!==e&&d!==d;if(i(e)&&i(d))return c(e,d,f,p);var m=Array.isArray(e),h=Array.isArray(d);if(m||h)return m===h&&t(e,d,f,p);var g=s.call(e);return g===s.call(d)?g===`[object Date]`?n(e,d,f,p):g===`[object RegExp]`?l(e,d,f,p):g===`[object Map]`?r(e,d,f,p):g===`[object Set]`?u(e,d,f,p):g===`[object Object]`||g===`[object Arguments]`?a(e)||a(d)?!1:c(e,d,f,p):g===`[object Boolean]`||g===`[object Number]`||g===`[object String]`?o(e.valueOf(),d.valueOf()):!1:!1}return p}function l(e,t,n,r){var i=e.length;if(t.length!==i)return!1;for(;i-->0;)if(!n(e[i],t[i],i,i,e,t,r))return!1;return!0}var u=n(l);function d(e,t){return o(e.valueOf(),t.valueOf())}function f(e,t,n,r){var i=e.size===t.size;if(!i)return!1;if(!e.size)return!0;var a={},o=0;return e.forEach(function(s,c){if(i){var l=!1,u=0;t.forEach(function(i,d){!l&&!a[u]&&(l=n(c,d,o,u,e,t,r)&&n(s,i,c,d,e,t,r))&&(a[u]=!0),u++}),o++,i=l}}),i}var p=n(f),m=`_owner`,h=Object.prototype.hasOwnProperty;function g(e,t,n,r){var i=Object.keys(e),a=i.length;if(Object.keys(t).length!==a)return!1;for(var o;a-->0;){if(o=i[a],o===m){var s=!!e.$$typeof,c=!!t.$$typeof;if((s||c)&&s!==c)return!1}if(!h.call(t,o)||!n(e[o],t[o],o,o,e,t,r))return!1}return!0}var _=n(g);function v(e,t){return e.source===t.source&&e.flags===t.flags}function y(e,t,n,r){var i=e.size===t.size;if(!i)return!1;if(!e.size)return!0;var a={};return e.forEach(function(o,s){if(i){var c=!1,l=0;t.forEach(function(i,u){!c&&!a[l]&&(c=n(o,i,s,u,e,t,r))&&(a[l]=!0),l++}),i=c}}),i}var b=n(y),x=Object.freeze({areArraysEqual:l,areDatesEqual:d,areMapsEqual:f,areObjectsEqual:g,areRegExpsEqual:v,areSetsEqual:y,createIsNestedEqual:t}),S=Object.freeze({areArraysEqual:u,areDatesEqual:d,areMapsEqual:p,areObjectsEqual:_,areRegExpsEqual:v,areSetsEqual:b,createIsNestedEqual:t}),C=c(x);function w(e,t){return C(e,t,void 0)}var T=c(r(x,{createIsNestedEqual:function(){return o}}));function E(e,t){return T(e,t,void 0)}var D=c(S);function O(e,t){return D(e,t,new WeakMap)}var k=c(r(S,{createIsNestedEqual:function(){return o}}));function A(e,t){return k(e,t,new WeakMap)}function j(e){return c(r(x,e(x)))}function M(e){var t=c(r(S,e(S)));return(function(e,n,r){return r===void 0&&(r=new WeakMap),t(e,n,r)})}e.circularDeepEqual=O,e.circularShallowEqual=A,e.createCustomCircularEqual=M,e.createCustomEqual=j,e.deepEqual=w,e.sameValueZeroEqual=o,e.shallowEqual=E,Object.defineProperty(e,"__esModule",{value:!0})}))})),sd=I(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),cd=I(((e,t)=>{var n=sd();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),ld=I(((e,t)=>{t.exports=cd()()})),Q=v(ld(),1);function ud(e,t){for(let n=0,r=e.length;n<r;n++)if(t.apply(t,[e[n],n,e]))return e[n]}function dd(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Function]`}function fd(e){return typeof e==`number`&&!isNaN(e)}function pd(e){return parseInt(e,10)}function md(e,t,n){if(e[t])return Error(`Invalid prop ${t} passed to ${n} - do not set this, set it on the child.`)}var hd=[`Moz`,`Webkit`,`O`,`ms`];function gd(e=`transform`){if(typeof window>`u`)return``;let t=window.document?.documentElement?.style;if(!t||e in t)return``;for(let n=0;n<hd.length;n++)if(_d(e,hd[n])in t)return hd[n];return``}function _d(e,t){return t?`${t}${vd(e)}`:e}function vd(e){let t=``,n=!0;for(let r=0;r<e.length;r++)n?(t+=e[r].toUpperCase(),n=!1):e[r]===`-`?n=!0:t+=e[r];return t}var yd=gd(),bd=``;function xd(e,t){bd||=ud([`matches`,`webkitMatchesSelector`,`mozMatchesSelector`,`msMatchesSelector`,`oMatchesSelector`],function(t){return dd(e[t])})??``;let n=e[bd];return dd(n)?!!n.call(e,t):!1}function Sd(e,t,n){let r=e;do{if(xd(r,t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function Cd(e,t,n,r){if(!e)return;let i={capture:!0,...r},a=n;e.addEventListener?e.addEventListener(t,a,i):e.attachEvent?e.attachEvent(`on`+t,a):e[`on`+t]=a}function wd(e,t,n,r){if(!e)return;let i={capture:!0,...r},a=n;e.removeEventListener?e.removeEventListener(t,a,i):e.detachEvent?e.detachEvent(`on`+t,a):e[`on`+t]=null}function Td(e){let t=e.clientHeight,n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=pd(n.borderTopWidth),t+=pd(n.borderBottomWidth),t}function Ed(e){let t=e.clientWidth,n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=pd(n.borderLeftWidth),t+=pd(n.borderRightWidth),t}function Dd(e){let t=e.clientHeight,n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=pd(n.paddingTop),t-=pd(n.paddingBottom),t}function Od(e){let t=e.clientWidth,n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=pd(n.paddingLeft),t-=pd(n.paddingRight),t}function kd(e,t,n){let r=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect();return{x:(e.clientX+t.scrollLeft-r.left)/n,y:(e.clientY+t.scrollTop-r.top)/n}}function Ad(e,t){let n=Md(e,t,`px`);return{[_d(`transform`,yd)]:n}}function jd(e,t){return Md(e,t,``)}function Md({x:e,y:t},n,r){let i=`translate(${e}${r},${t}${r})`;return n&&(i=`translate(${`${typeof n.x==`string`?n.x:n.x+r}`}, ${`${typeof n.y==`string`?n.y:n.y+r}`})`+i),i}function Nd(e,t){return e.targetTouches&&ud(e.targetTouches,e=>t===e.identifier)||e.changedTouches&&ud(e.changedTouches,e=>t===e.identifier)}function Pd(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function Fd(){return typeof __webpack_nonce__<`u`?__webpack_nonce__:void 0}function Id(e,t){if(!e)return;let n=e.getElementById(`react-draggable-style-el`);if(!n){n=e.createElement(`style`),n.type=`text/css`,n.id=`react-draggable-style-el`;let r=t??Fd();r&&n.setAttribute(`nonce`,r),n.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;}
|
|
2
|
+
`,n.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;}
|
|
3
|
+
`,e.getElementsByTagName(`head`)[0].appendChild(n)}e.body&&zd(e.body,`react-draggable-transparent-selection`)}function Ld(e){window.requestAnimationFrame?window.requestAnimationFrame(()=>{Rd(e)}):Rd(e)}function Rd(e){if(e)try{e.body&&Bd(e.body,`react-draggable-transparent-selection`);let t=e.selection;if(t)t.empty();else{let t=(e.defaultView||window).getSelection();t&&t.type!==`Caret`&&t.removeAllRanges()}}catch{}}function zd(e,t){e.classList?e.classList.add(t):e.className.match(RegExp(`(?:^|\\s)${t}(?!\\S)`))||(e.className+=` ${t}`)}function Bd(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(RegExp(`(?:^|\\s)${t}(?!\\S)`,`g`),``)}function Vd(e,t,n){if(!e.props.bounds)return[t,n];let{bounds:r}=e.props;r=typeof r==`string`?r:Jd(r);let i=Yd(e);if(typeof r==`string`){let{ownerDocument:e}=i,t=e.defaultView;if(!t)throw Error(`Cannot resolve the owner window of the draggable node.`);let n;if(n=r===`parent`?i.parentNode:i.getRootNode().querySelector(r),!(n instanceof t.HTMLElement))throw Error(`Bounds selector "`+r+`" could not find an element.`);let a=n,o=t.getComputedStyle(i),s=t.getComputedStyle(a);r={left:-i.offsetLeft+pd(s.paddingLeft)+pd(o.marginLeft),top:-i.offsetTop+pd(s.paddingTop)+pd(o.marginTop),right:Od(a)-Ed(i)-i.offsetLeft+pd(s.paddingRight)-pd(o.marginRight),bottom:Dd(a)-Td(i)-i.offsetTop+pd(s.paddingBottom)-pd(o.marginBottom)}}return fd(r.right)&&(t=Math.min(t,r.right)),fd(r.bottom)&&(n=Math.min(n,r.bottom)),fd(r.left)&&(t=Math.max(t,r.left)),fd(r.top)&&(n=Math.max(n,r.top)),[t,n]}function Hd(e,t,n){return[Math.round(t/e[0])*e[0],Math.round(n/e[1])*e[1]]}function Ud(e){return e.props.axis===`both`||e.props.axis===`x`}function Wd(e){return e.props.axis===`both`||e.props.axis===`y`}function Gd(e,t,n){let r=typeof t==`number`?Nd(e,t):null;if(typeof t==`number`&&!r)return null;let i=Yd(n),a=n.props.offsetParent||i.offsetParent||i.ownerDocument.body;return kd(r||e,a,n.props.scale)}function Kd(e,t,n){let r=!fd(e.lastX),i=Yd(e);return r?{node:i,deltaX:0,deltaY:0,lastX:t,lastY:n,x:t,y:n}:{node:i,deltaX:t-e.lastX,deltaY:n-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:n}}function qd(e,t){let n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}}function Jd(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function Yd(e){let t=e.findDOMNode();if(!t)throw Error(`<DraggableCore>: Unmounted during event!`);return t}var Xd=typeof process<`u`&&{}.DRAGGABLE_DEBUG?console.log.bind(console):function(){},Zd={touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`},mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`}},Qd=Zd.mouse,$d=class extends Y.Component{constructor(){super(...arguments),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,this.touchIdentifier=null,this.mounted=!1,this.handleDragStart=e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&(typeof e.button==`number`&&e.button!==0||e.ctrlKey))return!1;let t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw Error(`<DraggableCore> not mounted on DragStart!`);let{ownerDocument:n}=t;if(this.props.disabled||!(e.target instanceof n.defaultView.Node)||this.props.handle&&!Sd(e.target,this.props.handle,t)||this.props.cancel&&Sd(e.target,this.props.cancel,t))return;e.type===`touchstart`&&!this.props.allowMobileScroll&&e.preventDefault();let r=Pd(e);this.touchIdentifier=r;let i=Gd(e,r,this);if(i==null)return;let{x:a,y:o}=i,s=Kd(this,a,o);Xd(`DraggableCore: handleDragStart: %j`,s),Xd(`calling`,this.props.onStart),this.props.onStart(e,s)!==!1&&this.mounted!==!1&&(this.props.enableUserSelectHack&&Id(n,this.props.nonce),this.dragging=!0,this.lastX=a,this.lastY=o,Cd(n,Qd.move,this.handleDrag),Cd(n,Qd.stop,this.handleDragStop))},this.handleDrag=e=>{let t=Gd(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX,t=r-this.lastY;if([e,t]=Hd(this.props.grid,e,t),!e&&!t)return;n=this.lastX+e,r=this.lastY+t}let i=Kd(this,n,r);if(Xd(`DraggableCore: handleDrag: %j`,i),this.props.onDrag(e,i)===!1||this.mounted===!1)try{this.handleDragStop(new MouseEvent(`mouseup`))}catch{let e=document.createEvent(`MouseEvents`);e.initMouseEvent(`mouseup`,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(e)}else this.lastX=n,this.lastY=r},this.handleDragStop=e=>{if(!this.dragging)return;let t=Gd(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX||0,t=r-this.lastY||0;[e,t]=Hd(this.props.grid,e,t),n=this.lastX+e,r=this.lastY+t}let i=Kd(this,n,r);if(this.props.onStop(e,i)===!1||this.mounted===!1)return!1;let a=this.findDOMNode();a&&this.props.enableUserSelectHack&&Ld(a.ownerDocument),Xd(`DraggableCore: handleDragStop: %j`,i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,a&&(Xd(`DraggableCore: Removing handlers`),wd(a.ownerDocument,Qd.move,this.handleDrag),wd(a.ownerDocument,Qd.stop,this.handleDragStop))},this.onMouseDown=e=>(Qd=Zd.mouse,this.handleDragStart(e)),this.onMouseUp=e=>(Qd=Zd.mouse,this.handleDragStop(e)),this.onTouchStart=e=>(Qd=Zd.touch,this.handleDragStart(e)),this.onTouchEnd=e=>(Qd=Zd.touch,this.handleDragStop(e))}componentDidMount(){this.mounted=!0;let e=this.findDOMNode();e&&Cd(e,Zd.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;let e=this.findDOMNode();if(e){let{ownerDocument:t}=e;wd(t,Zd.mouse.move,this.handleDrag),wd(t,Zd.touch.move,this.handleDrag),wd(t,Zd.mouse.stop,this.handleDragStop),wd(t,Zd.touch.stop,this.handleDragStop),wd(e,Zd.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&Ld(t)}}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=al.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):(Xd(`react-draggable: ReactDOM.findDOMNode is not available in React 19+. You must provide a nodeRef prop. See: https://github.com/react-grid-layout/react-draggable#noderef`),null)}render(){return Y.cloneElement(Y.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};$d.displayName=`DraggableCore`,$d.propTypes={allowAnyClick:Q.default.bool,allowMobileScroll:Q.default.bool,children:Q.default.node.isRequired,disabled:Q.default.bool,enableUserSelectHack:Q.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw Error(`Draggable's offsetParent must be a DOM Node.`)},grid:Q.default.arrayOf(Q.default.number),handle:Q.default.string,cancel:Q.default.string,nodeRef:Q.default.object,nonce:Q.default.string,onStart:Q.default.func,onDrag:Q.default.func,onStop:Q.default.func,onMouseDown:Q.default.func,scale:Q.default.number,className:md,style:md,transform:md},$d.defaultProps={allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1};var ef=class extends Y.Component{constructor(e){super(e),this.onDragStart=(e,t)=>{if(Xd(`Draggable: onDragStart: %j`,t),this.props.onStart(e,qd(this,t))===!1)return!1;this.setState({dragging:!0,dragged:!0})},this.onDrag=(e,t)=>{if(!this.state.dragging)return!1;Xd(`Draggable: onDrag: %j`,t);let n=qd(this,t),r={x:n.x,y:n.y,slackX:0,slackY:0};if(this.props.bounds){let{x:e,y:t}=r;r.x+=this.state.slackX,r.y+=this.state.slackY;let[i,a]=Vd(this,r.x,r.y);r.x=i,r.y=a,r.slackX=this.state.slackX+(e-r.x),r.slackY=this.state.slackY+(t-r.y),n.x=r.x,n.y=r.y,n.deltaX=r.x-this.state.x,n.deltaY=r.y-this.state.y}if(this.props.onDrag(e,n)===!1)return!1;this.setState(r)},this.onDragStop=(e,t)=>{if(!this.state.dragging||this.props.onStop(e,qd(this,t))===!1)return!1;Xd(`Draggable: onDragStop: %j`,t);let n={dragging:!1,slackX:0,slackY:0};if(this.props.position){let{x:e,y:t}=this.props.position;n.x=e,n.y=t}this.setState(n)},this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},e.position&&!(e.onDrag||e.onStop)&&console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}static getDerivedStateFromProps({position:e},{prevPropsPosition:t}){return e&&(!t||e.x!==t.x||e.y!==t.y)?(Xd(`Draggable: getDerivedStateFromProps %j`,{position:e,prevPropsPosition:t}),{x:e.x,y:e.y,prevPropsPosition:{...e}}):null}componentDidMount(){window.SVGElement!==void 0&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=al.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):null}render(){let{axis:e,bounds:t,children:n,defaultPosition:r,defaultClassName:i,defaultClassNameDragging:a,defaultClassNameDragged:o,position:s,positionOffset:c,scale:l,...u}=this.props,d={},f=null,p=!s||this.state.dragging,m=s||r,h={x:Ud(this)&&p?this.state.x:m.x,y:Wd(this)&&p?this.state.y:m.y};this.state.isElementSVG?f=jd(h,c):d=Ad(h,c);let g=Y.Children.only(n),_=O(g.props.className||``,i,{[a]:this.state.dragging,[o]:this.state.dragged});return Y.createElement($d,{...u,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop},Y.cloneElement(g,{className:_,style:{...g.props.style,...d},transform:f}))}};ef.displayName=`Draggable`,ef.propTypes={...$d.propTypes,axis:Q.default.oneOf([`both`,`x`,`y`,`none`]),bounds:Q.default.oneOfType([Q.default.shape({left:Q.default.number,right:Q.default.number,top:Q.default.number,bottom:Q.default.number}),Q.default.string,Q.default.oneOf([!1])]),defaultClassName:Q.default.string,defaultClassNameDragging:Q.default.string,defaultClassNameDragged:Q.default.string,defaultPosition:Q.default.shape({x:Q.default.number,y:Q.default.number}),positionOffset:Q.default.shape({x:Q.default.oneOfType([Q.default.number,Q.default.string]),y:Q.default.oneOfType([Q.default.number,Q.default.string])}),position:Q.default.shape({x:Q.default.number,y:Q.default.number}),className:md,style:md,transform:md},ef.defaultProps={...$d.defaultProps,axis:`both`,bounds:!1,defaultClassName:`react-draggable`,defaultClassNameDragging:`react-draggable-dragging`,defaultClassNameDragged:`react-draggable-dragged`,defaultPosition:{x:0,y:0},scale:1};var tf=I(((e,t)=>{function n(e){var t,r,i=``;if(typeof e==`string`||typeof e==`number`)i+=e;else if(typeof e==`object`){if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=n(e[t]))&&(i&&(i+=` `),i+=r)}else for(r in e)e[r]&&(i&&(i+=` `),i+=r)}return i}function r(){for(var e,t,r=0,i=``,a=arguments.length;r<a;r++)(e=arguments[r])&&(t=n(e))&&(i&&(i+=` `),i+=t);return i}t.exports=r,t.exports.clsx=r})),nf=I(((e,t)=>{var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},l=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!s.call(e,c)&&c!==n&&r(e,c,{get:()=>t[c],enumerable:!(o=i(t,c))||o.enumerable});return e},d=(e,t,i)=>(i=e==null?{}:n(o(e)),l(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e)),f=e=>l(r({},`__esModule`,{value:!0}),e),p={};c(p,{DraggableCore:()=>ve,default:()=>ye}),t.exports=f(p);var m=d(h()),g=d(ld()),_=d(u()),v=tf();function y(e,t){for(let n=0,r=e.length;n<r;n++)if(t.apply(t,[e[n],n,e]))return e[n]}function b(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Function]`}function x(e){return typeof e==`number`&&!isNaN(e)}function S(e){return parseInt(e,10)}function C(e,t,n){if(e[t])return Error(`Invalid prop ${t} passed to ${n} - do not set this, set it on the child.`)}var w=[`Moz`,`Webkit`,`O`,`ms`];function T(e=`transform`){if(typeof window>`u`)return``;let t=window.document?.documentElement?.style;if(!t||e in t)return``;for(let n=0;n<w.length;n++)if(E(e,w[n])in t)return w[n];return``}function E(e,t){return t?`${t}${D(e)}`:e}function D(e){let t=``,n=!0;for(let r=0;r<e.length;r++)n?(t+=e[r].toUpperCase(),n=!1):e[r]===`-`?n=!0:t+=e[r];return t}var O=T(),k=``;function A(e,t){k||=y([`matches`,`webkitMatchesSelector`,`mozMatchesSelector`,`msMatchesSelector`,`oMatchesSelector`],function(t){return b(e[t])})??``;let n=e[k];return b(n)?!!n.call(e,t):!1}function j(e,t,n){let r=e;do{if(A(r,t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function M(e,t,n,r){if(!e)return;let i={capture:!0,...r},a=n;e.addEventListener?e.addEventListener(t,a,i):e.attachEvent?e.attachEvent(`on`+t,a):e[`on`+t]=a}function N(e,t,n,r){if(!e)return;let i={capture:!0,...r},a=n;e.removeEventListener?e.removeEventListener(t,a,i):e.detachEvent?e.detachEvent(`on`+t,a):e[`on`+t]=null}function ee(e){let t=e.clientHeight,n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=S(n.borderTopWidth),t+=S(n.borderBottomWidth),t}function P(e){let t=e.clientWidth,n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=S(n.borderLeftWidth),t+=S(n.borderRightWidth),t}function F(e){let t=e.clientHeight,n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=S(n.paddingTop),t-=S(n.paddingBottom),t}function I(e){let t=e.clientWidth,n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=S(n.paddingLeft),t-=S(n.paddingRight),t}function L(e,t,n){let r=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect();return{x:(e.clientX+t.scrollLeft-r.left)/n,y:(e.clientY+t.scrollTop-r.top)/n}}function te(e,t){let n=re(e,t,`px`);return{[E(`transform`,O)]:n}}function ne(e,t){return re(e,t,``)}function re({x:e,y:t},n,r){let i=`translate(${e}${r},${t}${r})`;return n&&(i=`translate(${`${typeof n.x==`string`?n.x:n.x+r}`}, ${`${typeof n.y==`string`?n.y:n.y+r}`})`+i),i}function ie(e,t){return e.targetTouches&&y(e.targetTouches,e=>t===e.identifier)||e.changedTouches&&y(e.changedTouches,e=>t===e.identifier)}function ae(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function R(){return typeof __webpack_nonce__<`u`?__webpack_nonce__:void 0}function oe(e,t){if(!e)return;let n=e.getElementById(`react-draggable-style-el`);if(!n){n=e.createElement(`style`),n.type=`text/css`,n.id=`react-draggable-style-el`;let r=t??R();r&&n.setAttribute(`nonce`,r),n.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;}
|
|
4
|
+
`,n.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;}
|
|
5
|
+
`,e.getElementsByTagName(`head`)[0].appendChild(n)}e.body&&le(e.body,`react-draggable-transparent-selection`)}function se(e){window.requestAnimationFrame?window.requestAnimationFrame(()=>{ce(e)}):ce(e)}function ce(e){if(e)try{e.body&&z(e.body,`react-draggable-transparent-selection`);let t=e.selection;if(t)t.empty();else{let t=(e.defaultView||window).getSelection();t&&t.type!==`Caret`&&t.removeAllRanges()}}catch{}}function le(e,t){e.classList?e.classList.add(t):e.className.match(RegExp(`(?:^|\\s)${t}(?!\\S)`))||(e.className+=` ${t}`)}function z(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(RegExp(`(?:^|\\s)${t}(?!\\S)`,`g`),``)}function ue(e,t,n){if(!e.props.bounds)return[t,n];let{bounds:r}=e.props;r=typeof r==`string`?r:pe(r);let i=me(e);if(typeof r==`string`){let{ownerDocument:e}=i,t=e.defaultView;if(!t)throw Error(`Cannot resolve the owner window of the draggable node.`);let n;if(n=r===`parent`?i.parentNode:i.getRootNode().querySelector(r),!(n instanceof t.HTMLElement))throw Error(`Bounds selector "`+r+`" could not find an element.`);let a=n,o=t.getComputedStyle(i),s=t.getComputedStyle(a);r={left:-i.offsetLeft+S(s.paddingLeft)+S(o.marginLeft),top:-i.offsetTop+S(s.paddingTop)+S(o.marginTop),right:I(a)-P(i)-i.offsetLeft+S(s.paddingRight)-S(o.marginRight),bottom:F(a)-ee(i)-i.offsetTop+S(s.paddingBottom)-S(o.marginBottom)}}return x(r.right)&&(t=Math.min(t,r.right)),x(r.bottom)&&(n=Math.min(n,r.bottom)),x(r.left)&&(t=Math.max(t,r.left)),x(r.top)&&(n=Math.max(n,r.top)),[t,n]}function B(e,t,n){return[Math.round(t/e[0])*e[0],Math.round(n/e[1])*e[1]]}function V(e){return e.props.axis===`both`||e.props.axis===`x`}function de(e){return e.props.axis===`both`||e.props.axis===`y`}function fe(e,t,n){let r=typeof t==`number`?ie(e,t):null;if(typeof t==`number`&&!r)return null;let i=me(n),a=n.props.offsetParent||i.offsetParent||i.ownerDocument.body;return L(r||e,a,n.props.scale)}function H(e,t,n){let r=!x(e.lastX),i=me(e);return r?{node:i,deltaX:0,deltaY:0,lastX:t,lastY:n,x:t,y:n}:{node:i,deltaX:t-e.lastX,deltaY:n-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:n}}function U(e,t){let n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}}function pe(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function me(e){let t=e.findDOMNode();if(!t)throw Error(`<DraggableCore>: Unmounted during event!`);return t}var W=d(h()),G=d(ld()),he=d(u()),K=typeof process<`u`&&{}.DRAGGABLE_DEBUG?console.log.bind(console):function(){},ge={touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`},mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`}},_e=ge.mouse,ve=class extends W.Component{constructor(){super(...arguments),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,this.touchIdentifier=null,this.mounted=!1,this.handleDragStart=e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&(typeof e.button==`number`&&e.button!==0||e.ctrlKey))return!1;let t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw Error(`<DraggableCore> not mounted on DragStart!`);let{ownerDocument:n}=t;if(this.props.disabled||!(e.target instanceof n.defaultView.Node)||this.props.handle&&!j(e.target,this.props.handle,t)||this.props.cancel&&j(e.target,this.props.cancel,t))return;e.type===`touchstart`&&!this.props.allowMobileScroll&&e.preventDefault();let r=ae(e);this.touchIdentifier=r;let i=fe(e,r,this);if(i==null)return;let{x:a,y:o}=i,s=H(this,a,o);K(`DraggableCore: handleDragStart: %j`,s),K(`calling`,this.props.onStart),this.props.onStart(e,s)!==!1&&this.mounted!==!1&&(this.props.enableUserSelectHack&&oe(n,this.props.nonce),this.dragging=!0,this.lastX=a,this.lastY=o,M(n,_e.move,this.handleDrag),M(n,_e.stop,this.handleDragStop))},this.handleDrag=e=>{let t=fe(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX,t=r-this.lastY;if([e,t]=B(this.props.grid,e,t),!e&&!t)return;n=this.lastX+e,r=this.lastY+t}let i=H(this,n,r);if(K(`DraggableCore: handleDrag: %j`,i),this.props.onDrag(e,i)===!1||this.mounted===!1)try{this.handleDragStop(new MouseEvent(`mouseup`))}catch{let e=document.createEvent(`MouseEvents`);e.initMouseEvent(`mouseup`,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(e)}else this.lastX=n,this.lastY=r},this.handleDragStop=e=>{if(!this.dragging)return;let t=fe(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX||0,t=r-this.lastY||0;[e,t]=B(this.props.grid,e,t),n=this.lastX+e,r=this.lastY+t}let i=H(this,n,r);if(this.props.onStop(e,i)===!1||this.mounted===!1)return!1;let a=this.findDOMNode();a&&this.props.enableUserSelectHack&&se(a.ownerDocument),K(`DraggableCore: handleDragStop: %j`,i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,a&&(K(`DraggableCore: Removing handlers`),N(a.ownerDocument,_e.move,this.handleDrag),N(a.ownerDocument,_e.stop,this.handleDragStop))},this.onMouseDown=e=>(_e=ge.mouse,this.handleDragStart(e)),this.onMouseUp=e=>(_e=ge.mouse,this.handleDragStop(e)),this.onTouchStart=e=>(_e=ge.touch,this.handleDragStart(e)),this.onTouchEnd=e=>(_e=ge.touch,this.handleDragStop(e))}componentDidMount(){this.mounted=!0;let e=this.findDOMNode();e&&M(e,ge.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;let e=this.findDOMNode();if(e){let{ownerDocument:t}=e;N(t,ge.mouse.move,this.handleDrag),N(t,ge.touch.move,this.handleDrag),N(t,ge.mouse.stop,this.handleDragStop),N(t,ge.touch.stop,this.handleDragStop),N(e,ge.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&se(t)}}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=he.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):(K(`react-draggable: ReactDOM.findDOMNode is not available in React 19+. You must provide a nodeRef prop. See: https://github.com/react-grid-layout/react-draggable#noderef`),null)}render(){return W.cloneElement(W.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};ve.displayName=`DraggableCore`,ve.propTypes={allowAnyClick:G.default.bool,allowMobileScroll:G.default.bool,children:G.default.node.isRequired,disabled:G.default.bool,enableUserSelectHack:G.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw Error(`Draggable's offsetParent must be a DOM Node.`)},grid:G.default.arrayOf(G.default.number),handle:G.default.string,cancel:G.default.string,nodeRef:G.default.object,nonce:G.default.string,onStart:G.default.func,onDrag:G.default.func,onStop:G.default.func,onMouseDown:G.default.func,scale:G.default.number,className:C,style:C,transform:C},ve.defaultProps={allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1};var ye=class extends m.Component{constructor(e){super(e),this.onDragStart=(e,t)=>{if(K(`Draggable: onDragStart: %j`,t),this.props.onStart(e,U(this,t))===!1)return!1;this.setState({dragging:!0,dragged:!0})},this.onDrag=(e,t)=>{if(!this.state.dragging)return!1;K(`Draggable: onDrag: %j`,t);let n=U(this,t),r={x:n.x,y:n.y,slackX:0,slackY:0};if(this.props.bounds){let{x:e,y:t}=r;r.x+=this.state.slackX,r.y+=this.state.slackY;let[i,a]=ue(this,r.x,r.y);r.x=i,r.y=a,r.slackX=this.state.slackX+(e-r.x),r.slackY=this.state.slackY+(t-r.y),n.x=r.x,n.y=r.y,n.deltaX=r.x-this.state.x,n.deltaY=r.y-this.state.y}if(this.props.onDrag(e,n)===!1)return!1;this.setState(r)},this.onDragStop=(e,t)=>{if(!this.state.dragging||this.props.onStop(e,U(this,t))===!1)return!1;K(`Draggable: onDragStop: %j`,t);let n={dragging:!1,slackX:0,slackY:0};if(this.props.position){let{x:e,y:t}=this.props.position;n.x=e,n.y=t}this.setState(n)},this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},e.position&&!(e.onDrag||e.onStop)&&console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}static getDerivedStateFromProps({position:e},{prevPropsPosition:t}){return e&&(!t||e.x!==t.x||e.y!==t.y)?(K(`Draggable: getDerivedStateFromProps %j`,{position:e,prevPropsPosition:t}),{x:e.x,y:e.y,prevPropsPosition:{...e}}):null}componentDidMount(){window.SVGElement!==void 0&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=_.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):null}render(){let{axis:e,bounds:t,children:n,defaultPosition:r,defaultClassName:i,defaultClassNameDragging:a,defaultClassNameDragged:o,position:s,positionOffset:c,scale:l,...u}=this.props,d={},f=null,p=!s||this.state.dragging,h=s||r,g={x:V(this)&&p?this.state.x:h.x,y:de(this)&&p?this.state.y:h.y};this.state.isElementSVG?f=ne(g,c):d=te(g,c);let _=m.Children.only(n),y=(0,v.clsx)(_.props.className||``,i,{[a]:this.state.dragging,[o]:this.state.dragged});return m.createElement(ve,{...u,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop},m.cloneElement(_,{className:y,style:{..._.props.style,...d},transform:f}))}};ye.displayName=`Draggable`,ye.propTypes={...ve.propTypes,axis:g.default.oneOf([`both`,`x`,`y`,`none`]),bounds:g.default.oneOfType([g.default.shape({left:g.default.number,right:g.default.number,top:g.default.number,bottom:g.default.number}),g.default.string,g.default.oneOf([!1])]),defaultClassName:g.default.string,defaultClassNameDragging:g.default.string,defaultClassNameDragged:g.default.string,defaultPosition:g.default.shape({x:g.default.number,y:g.default.number}),positionOffset:g.default.shape({x:g.default.oneOfType([g.default.number,g.default.string]),y:g.default.oneOfType([g.default.number,g.default.string])}),position:g.default.shape({x:g.default.number,y:g.default.number}),className:C,style:C,transform:C},ye.defaultProps={...ve.defaultProps,axis:`both`,bounds:!1,defaultClassName:`react-draggable`,defaultClassNameDragging:`react-draggable-dragging`,defaultClassNameDragged:`react-draggable-dragged`,defaultPosition:{x:0,y:0},scale:1},0&&(t.exports={DraggableCore:ve})})),rf=I(((e,t)=>{var n=nf(),r=n.DraggableCore,i=n.default||n;t.exports=i,t.exports.default=i,t.exports.DraggableCore=r})),af=I((e=>{e.__esModule=!0,e.cloneElement=c;var t=n(h());function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?r(Object(n),!0).forEach(function(t){a(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function a(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e){var t=s(e,`string`);return typeof t==`symbol`?t:t+``}function s(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function c(e,n){return n.style&&e.props.style&&(n.style=i(i({},e.props.style),n.style)),n.className&&e.props.className&&(n.className=e.props.className+` `+n.className),t.default.cloneElement(e,n)}})),of=I((e=>{e.__esModule=!0,e.resizableProps=void 0;var t=n(ld());rf();function n(e){return e&&e.__esModule?e:{default:e}}e.resizableProps={axis:t.default.oneOf([`both`,`x`,`y`,`none`]),className:t.default.string,children:t.default.element.isRequired,draggableOpts:t.default.shape({allowAnyClick:t.default.bool,cancel:t.default.string,children:t.default.node,disabled:t.default.bool,enableUserSelectHack:t.default.bool,offsetParent:typeof Element<`u`?t.default.instanceOf(Element):t.default.any,grid:t.default.arrayOf(t.default.number),handle:t.default.string,nodeRef:t.default.object,onStart:t.default.func,onDrag:t.default.func,onStop:t.default.func,onMouseDown:t.default.func,scale:t.default.number}),height:function(){var e=[...arguments];let n=e[0];return n.axis===`both`||n.axis===`y`?t.default.number.isRequired(...e):t.default.number(...e)},handle:t.default.oneOfType([t.default.node,t.default.func]),handleSize:t.default.arrayOf(t.default.number),lockAspectRatio:t.default.bool,maxConstraints:t.default.arrayOf(t.default.number),minConstraints:t.default.arrayOf(t.default.number),onResizeStop:t.default.func,onResizeStart:t.default.func,onResize:t.default.func,resizeHandles:t.default.arrayOf(t.default.oneOf([`s`,`w`,`e`,`n`,`sw`,`nw`,`se`,`ne`])),transformScale:t.default.number,width:function(){var e=[...arguments];let n=e[0];return n.axis===`both`||n.axis===`x`?t.default.number.isRequired(...e):t.default.number(...e)}}})),sf=I((e=>{e.__esModule=!0,e.default=void 0;var t=o(h()),n=rf(),r=af(),i=of(),a=[`children`,`className`,`draggableOpts`,`width`,`height`,`handle`,`handleSize`,`lockAspectRatio`,`axis`,`minConstraints`,`maxConstraints`,`onResize`,`onResizeStop`,`onResizeStart`,`resizeHandles`,`transformScale`];function o(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(o=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!=="default"&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(null,arguments)}function c(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?l(Object(n),!0).forEach(function(t){d(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function d(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e){var t=p(e,`string`);return typeof t==`symbol`?t:t+``}function p(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var m=class extends t.Component{constructor(){super(...arguments),this.handleRefs={},this.lastHandleRect=null,this.slack=null,this.lastSize=null}componentWillUnmount(){this.resetData()}resetData(){this.lastHandleRect=this.slack=this.lastSize=null}runConstraints(e,t){let n=this.props,r=n.minConstraints,i=n.maxConstraints,a=n.lockAspectRatio;if(!r&&!i&&!a)return[e,t];if(a){let n=this.props.width/this.props.height,r=e-this.props.width,i=t-this.props.height;Math.abs(r)>Math.abs(i*n)?t=e/n:e=t*n}let o=e,s=t,c=this.slack||[0,0],l=c[0],u=c[1];return e+=l,t+=u,r&&(e=Math.max(r[0],e),t=Math.max(r[1],t)),i&&(e=Math.min(i[0],e),t=Math.min(i[1],t)),this.slack=[l+(o-e),u+(s-t)],[e,t]}resizeHandler(e,t){return(n,r)=>{let i=r.node,a=r.deltaX,o=r.deltaY;e===`onResizeStart`&&this.resetData();let s=(this.props.axis===`both`||this.props.axis===`x`)&&t!==`n`&&t!==`s`,c=(this.props.axis===`both`||this.props.axis===`y`)&&t!==`e`&&t!==`w`;if(!s&&!c)return;let l=t[0],u=t[t.length-1],d=i.getBoundingClientRect();if(this.lastHandleRect!=null){if(u===`w`){let e=d.left-this.lastHandleRect.left;a+=e}if(l===`n`){let e=d.top-this.lastHandleRect.top;o+=e}}this.lastHandleRect=d,u===`w`&&(a=-a),l===`n`&&(o=-o);let f=this.lastSize?.width??this.props.width,p=this.lastSize?.height??this.props.height,m=f+(s?a/this.props.transformScale:0),h=p+(c?o/this.props.transformScale:0);var g=this.runConstraints(m,h);if(m=g[0],h=g[1],e===`onResizeStop`&&this.lastSize){var _=this.lastSize;m=_.width,h=_.height}let v=m!==f||h!==p;e!==`onResizeStop`&&(this.lastSize={width:m,height:h});let y=typeof this.props[e]==`function`?this.props[e]:null;y&&(e!==`onResize`||v)&&(n.persist==null||n.persist(),y(n,{node:i,size:{width:m,height:h},handle:t})),e===`onResizeStop`&&this.resetData()}}renderResizeHandle(e,n){let r=this.props.handle;if(!r)return t.createElement(`span`,{className:`react-resizable-handle react-resizable-handle-`+e,ref:n});if(typeof r==`function`)return r(e,n);let i=typeof r.type==`string`,a=u({ref:n},i?{}:{handleAxis:e});return t.cloneElement(r,a)}render(){let e=this.props,i=e.children,o=e.className,l=e.draggableOpts;e.width,e.height,e.handle,e.handleSize,e.lockAspectRatio,e.axis,e.minConstraints,e.maxConstraints,e.onResize,e.onResizeStop,e.onResizeStart;let d=e.resizeHandles;e.transformScale;let f=c(e,a);return(0,r.cloneElement)(i,u(u({},f),{},{className:(o?o+` `:``)+`react-resizable`,children:[...t.Children.toArray(i.props.children),...d.map(e=>{let r=this.handleRefs[e]??(this.handleRefs[e]=t.createRef());return t.createElement(n.DraggableCore,s({},l,{nodeRef:r,key:`resizableHandle-`+e,onStop:this.resizeHandler(`onResizeStop`,e),onStart:this.resizeHandler(`onResizeStart`,e),onDrag:this.resizeHandler(`onResize`,e)}),this.renderResizeHandle(e,r))})]}))}};e.default=m,m.propTypes=i.resizableProps,m.defaultProps={axis:`both`,handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:[`se`],transformScale:1}})),cf=I((e=>{e.__esModule=!0,e.default=void 0;var t=s(h()),n=o(ld()),r=o(sf()),i=of(),a=[`handle`,`handleSize`,`onResize`,`onResizeStart`,`onResizeStop`,`draggableOpts`,`minConstraints`,`maxConstraints`,`lockAspectRatio`,`axis`,`width`,`height`,`resizeHandles`,`style`,`transformScale`];function o(e){return e&&e.__esModule?e:{default:e}}function s(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(s=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!=="default"&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(null,arguments)}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?l(Object(n),!0).forEach(function(t){d(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function d(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e){var t=p(e,`string`);return typeof t==`symbol`?t:t+``}function p(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function m(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var g=class extends t.Component{constructor(){super(...arguments),this.state={width:this.props.width,height:this.props.height,propsWidth:this.props.width,propsHeight:this.props.height},this.onResize=(e,t)=>{let n=t.size;this.props.onResize?(e.persist==null||e.persist(),this.setState(n,()=>this.props.onResize&&this.props.onResize(e,t))):this.setState(n)}}static getDerivedStateFromProps(e,t){return t.propsWidth!==e.width||t.propsHeight!==e.height?{width:e.width,height:e.height,propsWidth:e.width,propsHeight:e.height}:null}render(){let e=this.props,n=e.handle,i=e.handleSize;e.onResize;let o=e.onResizeStart,s=e.onResizeStop,l=e.draggableOpts,d=e.minConstraints,f=e.maxConstraints,p=e.lockAspectRatio,h=e.axis;e.width,e.height;let g=e.resizeHandles,_=e.style,v=e.transformScale,y=m(e,a);return t.createElement(r.default,{axis:h,draggableOpts:l,handle:n,handleSize:i,height:this.state.height,lockAspectRatio:p,maxConstraints:f,minConstraints:d,onResizeStart:o,onResize:this.onResize,onResizeStop:s,resizeHandles:g,transformScale:v,width:this.state.width},t.createElement(`div`,c({},y,{style:u(u({},_),{},{width:this.state.width+`px`,height:this.state.height+`px`})})))}};e.default=g,g.propTypes=u(u({},i.resizableProps),{},{children:n.default.element})})),lf=I(((e,t)=>{t.exports=function(){throw Error(`Don't instantiate Resizable directly! Use require('react-resizable').Resizable`)},t.exports.Resizable=sf().default,t.exports.ResizableBox=cf().default}))(),uf=od(),df=50,ff=12;function pf(e){let t=e;for(;t;){let e=window.getComputedStyle(t).overflowY;if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function mf(e){let t=pf(e),n=null,r=0,i=0,a=!1;function o(){let e=t;if(!e)return;let s=e.getBoundingClientRect(),{clientHeight:c,scrollTop:l,scrollHeight:u}=e,{scrollLeft:d,scrollWidth:f,clientWidth:p}=e,m=0,h=0;i<s.top+df&&l>0?m=-ff:i>s.bottom-df&&l+c<u&&(m=ff),r<s.left+df&&d>0?h=-ff:r>s.right-df&&d+p<f&&(h=ff),(m!==0||h!==0)&&(e.scrollTop+=m,e.scrollLeft+=h),a&&(n=requestAnimationFrame(o))}return{feed(e,t){r=e,i=t,a||(a=!0,n=requestAnimationFrame(o))},stop(){a=!1,n!==null&&(cancelAnimationFrame(n),n=null)}}}function hf(e){let{children:t,cols:n,containerWidth:r,margin:i,containerPadding:a,rowHeight:o,maxRows:s,isDraggable:c,isResizable:l,isBounded:u,allowMobileScroll:d,static:f,useCSSTransforms:p=!0,usePercentages:m=!1,transformScale:h=1,positionStrategy:g,dragThreshold:_=0,droppingPosition:v,className:y=``,style:b,handle:x=``,cancel:S=``,x:C,y:w,w:T,h:E,minW:D=1,maxW:k=1/0,minH:A=1,maxH:j=1/0,i:M,resizeHandles:N,resizeHandle:ee,constraints:P=wu,layoutItem:F,layout:I=[],onDragStart:L,onDrag:te,onDragStop:ne,onResizeStart:re,onResize:ie,onResizeStop:ae}=e,[R,oe]=(0,Y.useState)(!1),[se,ce]=(0,Y.useState)(!1),le=(0,Y.useRef)(null),z=(0,Y.useRef)({left:0,top:0}),ue=(0,Y.useRef)({top:0,left:0,width:0,height:0}),B=(0,Y.useRef)(void 0),V=(0,Y.useRef)(I);V.current=I;let de=(0,Y.useRef)(null),fe=(0,Y.useRef)(null),H=(0,Y.useRef)(!1),U=(0,Y.useRef)({x:0,y:0}),pe=(0,Y.useRef)(!1),me=(0,Y.useRef)(null),W=(0,Y.useMemo)(()=>({cols:n,containerPadding:a,containerWidth:r,margin:i,maxRows:s,rowHeight:o}),[n,a,r,i,s,o]),G=(0,Y.useMemo)(()=>({cols:n,maxRows:s,containerWidth:r,containerHeight:0,rowHeight:o,margin:i,layout:[]}),[n,s,r,o,i]),he=(0,Y.useCallback)(e=>({...G,containerHeight:e??G.containerHeight,layout:V.current}),[G]),K=(0,Y.useMemo)(()=>F??{i:M,x:C,y:w,w:T,h:E,minW:D,maxW:k,minH:A,maxH:j},[F,M,C,w,T,E,D,k,A,j]),ge=(0,Y.useCallback)(e=>{if(g?.calcStyle)return g.calcStyle(e);if(p)return Du(e);let t=Ou(e);return m?{...t,left:ku(e.left/r),width:ku(e.width/r)}:t},[g,p,m,r]),_e=(0,Y.useCallback)((e,{node:t})=>{if(!L)return;let{offsetParent:n}=t;if(!n)return;let r=n.getBoundingClientRect(),i=t.getBoundingClientRect(),a=i.left/h,o=r.left/h,s=i.top/h,c=r.top/h,l;if(g?.calcDragPosition){let t=e;l=g.calcDragPosition(t.clientX,t.clientY,t.clientX-i.left,t.clientY-i.top)}else l={left:a-o+n.scrollLeft,top:s-c+n.scrollTop};if(z.current=l,me.current||=mf(t instanceof HTMLElement?t:null),_>0){let t=e;U.current={x:t.clientX,y:t.clientY},H.current=!0,pe.current=!1,oe(!0);return}oe(!0);let u=iu(W,l.top,l.left),{x:d,y:f}=Tu(P,K,u.x,u.y,he());L(M,d,f,{e,node:t,newPosition:l})},[L,h,W,g,_,P,K,he,M]),ve=(0,Y.useCallback)((e,{node:t,deltaX:n,deltaY:a})=>{if(!te||!R)return;let s=e;if(H.current&&!pe.current){let n=s.clientX-U.current.x,r=s.clientY-U.current.y;if(Math.hypot(n,r)<_)return;if(pe.current=!0,H.current=!1,L){let n=iu(W,z.current.top,z.current.left),{x:r,y:i}=Tu(P,K,n.x,n.y,he());L(M,r,i,{e,node:t,newPosition:z.current})}}me.current?.feed(s.clientX,s.clientY);let c=z.current.top+a,l=z.current.left+n;if(u){let{offsetParent:e}=t;if(e){let t=e.clientHeight-tu(E,o,i[1]);c=ou(c,0,t);let n=eu(W),a=r-tu(T,n,i[0]);l=ou(l,0,a)}}let d={top:c,left:l};z.current=d;let f=iu(W,c,l),{x:p,y:m}=Tu(P,K,f.x,f.y,he());te(M,p,m,{e,node:t,newPosition:d})},[te,L,R,_,u,E,o,i,W,r,T,M,P,K,he]),ye=(0,Y.useCallback)((e,{node:t})=>{if(!ne||!R)return;me.current?.stop(),me.current=null;let n=H.current;if(H.current=!1,pe.current=!1,U.current={x:0,y:0},n){oe(!1),z.current={left:0,top:0};return}let{left:r,top:i}=z.current,a={top:i,left:r};oe(!1),z.current={left:0,top:0};let o=iu(W,i,r),{x:s,y:c}=Tu(P,K,o.x,o.y,he());ne(M,s,c,{e,node:t,newPosition:a})},[ne,R,W,P,K,he,M]);de.current=_e,fe.current=ve;let be=(0,Y.useCallback)((e,{node:t,size:n,handle:i},a,o)=>{let s=o===`onResizeStart`?re:o===`onResize`?ie:ae;if(!s)return;let c;c=t?zu(i,a,n,r):{...n,top:a.top,left:a.left},ue.current=c;let l=t?.offsetParent?.clientHeight??0,u=au(W,c.width,c.height),{w:d,h:f}=Eu(P,K,u.w,u.h,i,he(l));s(M,d,f,{e:e.nativeEvent??e,node:t,size:c,handle:i})},[re,ie,ae,r,W,M,P,K,he]),xe=(0,Y.useCallback)((e,t)=>{ce(!0);let n=nu(W,C,w,T,E),r={...t,handle:t.handle};be(e,r,n,`onResizeStart`)},[be,W,C,w,T,E]),Se=(0,Y.useCallback)((e,t)=>{let n=nu(W,C,w,T,E),r={...t,handle:t.handle};be(e,r,n,`onResize`)},[be,W,C,w,T,E]),Ce=(0,Y.useCallback)((e,t)=>{ce(!1),ue.current={top:0,left:0,width:0,height:0};let n=nu(W,C,w,T,E),r={...t,handle:t.handle};be(e,r,n,`onResizeStop`)},[be,W,C,w,T,E]);(0,Y.useEffect)(()=>{if(!v)return;let e=le.current;if(!e)return;let t=B.current||{left:0,top:0},n=R&&(v.left!==t.left||v.top!==t.top);if(!R){let t={node:e,deltaX:v.left,deltaY:v.top,lastX:0,lastY:0,x:v.left,y:v.top};de.current?.(v.e,t)}else if(n){let t={node:e,deltaX:v.left-z.current.left,deltaY:v.top-z.current.top,lastX:z.current.left,lastY:z.current.top,x:v.left,y:v.top};fe.current?.(v.e,t)}B.current=v},[v,R,M]);let we=nu(W,C,w,T,E,R?z.current:null,se?ue.current:null),Te=Y.Children.only(t),Ee=eu(W),De=[tu(D,Ee,i[0]),tu(A,o,i[1])],Oe=[tu(k,Ee,i[0]),tu(j,o,i[1])],ke=Te.props,Ae=ke.className,je=ke.style,Me=Y.cloneElement(Te,{ref:le,className:O(`react-grid-item`,Ae,y,{static:f,resizing:se,"react-draggable":c,"react-draggable-dragging":R,dropping:!!v,cssTransforms:p}),style:{...b,...je,...ge(we)}}),Ne=ee;return Me=(0,X.jsx)(lf.Resizable,{draggableOpts:{disabled:!l},className:l?void 0:`react-resizable-hide`,width:we.width,height:we.height,minConstraints:De,maxConstraints:Oe,onResizeStart:xe,onResize:Se,onResizeStop:Ce,transformScale:h,resizeHandles:N,handle:Ne,children:Me}),Me=(0,X.jsx)($d,{disabled:!c,onStart:_e,onDrag:ve,onStop:ye,handle:x,cancel:`.react-resizable-handle`+(S?`,`+S:``),scale:h,allowMobileScroll:d,nodeRef:le,children:Me}),Me}var gf=Y.memo(hf,(e,t)=>e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h&&e.minW===t.minW&&e.maxW===t.maxW&&e.minH===t.minH&&e.maxH===t.maxH&&e.cols===t.cols&&e.containerWidth===t.containerWidth&&e.rowHeight===t.rowHeight&&e.maxRows===t.maxRows&&e.margin===t.margin&&e.containerPadding===t.containerPadding&&e.transformScale===t.transformScale&&e.isDraggable===t.isDraggable&&e.isResizable===t.isResizable&&e.isBounded===t.isBounded&&e.allowMobileScroll===t.allowMobileScroll&&e.useCSSTransforms===t.useCSSTransforms&&e.usePercentages===t.usePercentages&&e.children===t.children&&e.onDrag===t.onDrag&&e.onDragStop===t.onDragStop&&e.onResize===t.onResize&&e.onResizeStop===t.onResizeStop&&e.droppingPosition===t.droppingPosition);gf.displayName=`GridItem`;function _f(e){let{clientX:t,clientY:n,gridElement:r,droppingItem:i,event:a,dragOffsetX:o=0,dragOffsetY:s=0,transformScale:c,cols:l,margin:u,maxRows:d,rowHeight:f,width:p,containerPadding:m}=e,h=r.getBoundingClientRect(),g={cols:l,margin:u,maxRows:d,rowHeight:f,containerWidth:p,containerPadding:m},_=eu(g),v=tu(i.w,_,u[0]),y=tu(i.h,f,u[1]),b=v/2,x=y/2,S=r.scrollLeft??0,C=r.scrollTop??0,w=t-h.left+S+o-b,T=n-h.top+C+s-x,E=Math.max(0,w),D=Math.max(0,T);return{newDroppingPosition:{left:E/c,top:D/c,e:a},calculatedXY:ru(g,D,E,i.w,i.h)}}var vf=()=>{},yf=`react-grid-layout`,bf=!1;try{bf=/firefox/i.test(navigator.userAgent)}catch{}function xf(e,t){let n=Y.Children.toArray(e),r=Y.Children.toArray(t);if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(t?.key!==i?.key)return!1}return!0}function Sf(e,t,n,r){let i=[],a=new Set;Y.Children.forEach(t,t=>{if(!Y.isValidElement(t)||t.key===null)return;let n=String(t.key);a.add(n);let r=e.find(e=>e.i===n);if(r)i.push(gu(r));else{let e=t.props[`data-grid`];e?i.push({i:n,x:e.x??0,y:e.y??0,w:e.w??1,h:e.h??1,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,static:e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}):i.push({i:n,x:0,y:pu(i),w:1,h:1})}});let o=bu(i,{cols:n});return r.compact(o,n)}function Cf(e){let{children:t,width:n,gridConfig:r,dragConfig:i,resizeConfig:a,dropConfig:o,positionStrategy:s=Bu,compactor:c,constraints:l=wu,layout:u=[],droppingItem:d,autoSize:f=!0,className:p=``,style:m={},innerRef:h,onLayoutChange:g=vf,onDragStart:_=vf,onDrag:v=vf,onDragStop:y=vf,onResizeStart:b=vf,onResize:x=vf,onResizeStop:S=vf,onDrop:C=vf,onDropDragOver:w=vf}=e,T=(0,Y.useMemo)(()=>({...Vu,...r}),[r]),E=(0,Y.useMemo)(()=>({...Hu,...i}),[i]),D=(0,Y.useMemo)(()=>({...Uu,...a}),[a]),k=(0,Y.useMemo)(()=>({...Wu,...o}),[o]),{cols:A,rowHeight:j,maxRows:M,margin:N,containerPadding:ee}=T,{enabled:P,bounded:F,handle:I,cancel:L,threshold:te,allowMobileScroll:ne}=E,{enabled:re,handles:ie,handleComponent:ae}=D,{enabled:R,defaultItem:oe,onDragOver:se,touchEnabled:ce=!0,touchDragSource:le=`[data-rgl-draggable]`}=k,z=c??ed(`vertical`),ue=z.type,B=z.allowOverlap,V=z.preventCollision??!1,de=(0,Y.useMemo)(()=>d??{i:`__dropping-elem__`,...oe},[d,oe]),fe=s.type===`transform`,H=s.scale,U=ee??N,[pe,me]=(0,Y.useState)(!1),[W,G]=(0,Y.useState)(()=>Sf(u,t,A,z)),[he,K]=(0,Y.useState)(null),[ge,_e]=(0,Y.useState)(!1),[ve,ye]=(0,Y.useState)(null),[be,xe]=(0,Y.useState)(),Se=(0,Y.useRef)(void 0);Se.current=be;let Ce=(0,Y.useRef)(null),we=(0,Y.useRef)(null),Te=(0,Y.useRef)(null),Ee=(0,Y.useRef)(0),De=(0,Y.useRef)(W),Oe=(0,Y.useRef)(u),ke=(0,Y.useRef)(t),Ae=(0,Y.useRef)(ue),je=(0,Y.useRef)(null),Me=(0,Y.useRef)(!1),Ne=(0,Y.useRef)(null),Pe=(0,Y.useRef)(null);Pe.current=ve;let Fe=(0,Y.useRef)(C);(0,Y.useLayoutEffect)(()=>{Fe.current=C});let Ie=(0,Y.useRef)(W);Ie.current=W,(0,Y.useEffect)(()=>{me(!0),(0,uf.deepEqual)(W,u)||g(W)},[]),(0,Y.useEffect)(()=>{if(he||ve)return;let e=!(0,uf.deepEqual)(u,Oe.current),n=!xf(t,ke.current),r=ue!==Ae.current;if(e||n||r){let n=Sf(e?u:W,t,A,z);(0,uf.deepEqual)(n,W)||G(n)}Oe.current=u,ke.current=t,Ae.current=ue},[u,t,A,ue,z,he,ve,W]),(0,Y.useEffect)(()=>{if(!he&&!ve&&!(0,uf.deepEqual)(W,De.current)){De.current=W;let e=W.filter(e=>e.i!==de.i);g(e)}},[W,he,ve,g,de.i]);let Le=(0,Y.useMemo)(()=>{if(!f)return;let e=pu(W),t=U[1];return e*j+(e-1)*N[1]+t*2+`px`},[f,W,j,N,U]),Re=(0,Y.useCallback)((e,t,n,r)=>{let i=Ie.current,a=mu(i,e);if(!a)return;let o={w:a.w,h:a.h,x:a.x,y:a.y,i:e};Ce.current=gu(a),Te.current=i,K(o),_(i,a,a,null,r.e,r.node)},[_]),ze=(0,Y.useCallback)((e,t,n,r)=>{let i=Ie.current,a=Ce.current,o=mu(i,e);if(!o)return;let s={w:o.w,h:o.h,x:o.x,y:o.y,i:e},c=xu(i,o,t,n,!0,V,ue,A,B);v(c,a,o,s,r.e,r.node),G(z.compact(c,A)),K(s)},[V,ue,A,B,z,v]),Be=(0,Y.useCallback)((e,t,n,r)=>{if(!Ce.current)return;let i=Ie.current,a=Ce.current,o=mu(i,e);if(!o)return;let s=xu(i,o,t,n,!0,V,ue,A,B),c=z.compact(s,A);y(c,a,o,null,r.e,r.node);let l=Te.current;Ce.current=null,Te.current=null,K(null),G(c),l&&!(0,uf.deepEqual)(l,c)&&g(c)},[V,ue,A,B,z,y,g]),Ve=(0,Y.useCallback)((e,t,n,r)=>{let i=Ie.current,a=mu(i,e);a&&(we.current=gu(a),Te.current=i,_e(!0),b(i,a,a,null,r.e,r.node))},[b]),He=(0,Y.useCallback)((e,t,n,r)=>{let i=Ie.current,a=we.current,{handle:o}=r,s=!1,c,l,[u,d]=yu(i,e,e=>(c=e.x,l=e.y,[`sw`,`w`,`nw`,`n`,`ne`].includes(o)&&([`sw`,`nw`,`w`].includes(o)&&(c=e.x+(e.w-t),t=e.x!==c&&c<0?e.w:t,c=c<0?0:c),[`ne`,`n`,`nw`].includes(o)&&(l=e.y+(e.h-n),n=e.y!==l&&l<0?e.h:n,l=l<0?0:l),s=!0),V&&!B&&lu(i,{...e,w:t,h:n,x:c??e.x,y:l??e.y}).filter(t=>t.i!==e.i).length>0&&(l=e.y,n=e.h,c=e.x,t=e.w,s=!1),e.w=t,e.h=n,(o===`n`||o===`nw`||o===`ne`)&&(e.y=l??e.y),e));if(!d)return;let f=u;s&&c!==void 0&&l!==void 0&&(f=xu(u,d,c,l,!0,V,ue,A,B));let p={w:d.w,h:d.h,x:d.x,y:d.y,i:e,static:!0};x(f,a,d,p,r.e,r.node);let m=z.compact(f,A);if(o===`n`||o===`nw`||o===`ne`){let t=m.find(t=>t.i===e);t&&(t.y=d.y)}G(m),K(p)},[V,ue,A,B,z,x]),Ue=(0,Y.useCallback)((e,t,n,r)=>{let i=Ie.current,a=we.current,o=mu(i,e),s=z.compact(i,A);S(s,a,o??null,null,r.e,r.node);let c=Te.current;we.current=null,Te.current=null,K(null),_e(!1),G(s),c&&!(0,uf.deepEqual)(c,s)&&g(s)},[A,z,S,g]),We=(0,Y.useCallback)((e,t,n,r)=>{if(r)Se.current&&(Se.current.left!==t.left||Se.current.top!==t.top)&&(xe(t),G(t=>t.map(t=>t.i===e.i&&(t.x!==n.x||t.y!==n.y)?{...t,x:n.x,y:n.y}:t)));else{ye((0,X.jsx)(`div`,{},e.i)),xe(t);let r=Ie.current.filter(t=>t.i!==e.i);G([...r,{...e,x:n.x,y:n.y,static:!1,isDraggable:!0}])}},[]),Ge=(0,Y.useCallback)((e,t,r)=>{let i=je.current;if(!i)return;let{newDroppingPosition:a,calculatedXY:o}=_f({clientX:e,clientY:t,gridElement:i,droppingItem:de,event:r,transformScale:H,cols:A,margin:N,maxRows:M,rowHeight:j,width:n,containerPadding:U});We(de,a,o,!!Pe.current)},[de,H,A,N,M,j,n,U,We]),Ke=(0,Y.useCallback)(()=>{let e=Ie.current;if(!e.some(e=>e.i===de.i)){ye(null),K(null),xe(void 0);return}let t=z.compact(e.filter(e=>e.i!==de.i),A);G(t),ye(null),K(null),xe(void 0)},[de.i,A,z]),qe=(0,Y.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),bf&&!e.nativeEvent.target?.classList.contains(yf))return!1;let t=se?se(e.nativeEvent):w(e);if(t===!1)return ve&&Ke(),!1;let{dragOffsetX:r=0,dragOffsetY:i=0,...a}=t??{},o={...de,...a},{newDroppingPosition:s,calculatedXY:c}=_f({clientX:e.clientX,clientY:e.clientY,gridElement:e.currentTarget,droppingItem:o,event:e.nativeEvent,dragOffsetX:r,dragOffsetY:i,transformScale:H,cols:A,margin:N,maxRows:M,rowHeight:j,width:n,containerPadding:U});We(o,s,c,!!ve)},[ve,de,se,w,Ke,We,H,A,N,M,j,n,U]),Je=(0,Y.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),Ee.current--,Ee.current<0&&(Ee.current=0),Ee.current===0&&Ke()},[Ke]),Ye=(0,Y.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),Ee.current++},[]),Xe=(0,Y.useCallback)(e=>{let t=Ie.current,n=t.find(e=>e.i===de.i);Ke(),Fe.current(t,n,e)},[de.i,Ke]),Ze=(0,Y.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),Ee.current=0,Xe(e.nativeEvent)},[Xe]);(0,Y.useEffect)(()=>{if(!R||!ce)return;let e=je.current;if(!e)return;let t=(t,n)=>{let r=document.elementFromPoint(t,n);return r?e.contains(r):!1},n=e=>e instanceof HTMLElement&&e.closest(le)!==null,r=e=>{let t=e.changedTouches;if(!t||t.length===0)return;let n=Ne.current;if(n===null)return t[0];for(let e=0;e<t.length;e++){let r=t[e];if(r&&r.identifier===n)return r}},i=e=>{if(!n(e.target)||Ne.current!==null)return;e.preventDefault();let t=e.changedTouches?.[0];t&&(Ne.current=t.identifier,Me.current=!0)},a=e=>{if(!Me.current)return;e.preventDefault();let n=r(e);n&&(t(n.clientX,n.clientY)?Ge(n.clientX,n.clientY,e):Pe.current&&Ke())},o=e=>{if(!Me.current)return;e.preventDefault();let n=r(e);Me.current=!1,Ne.current=null,n&&(t(n.clientX,n.clientY)?Xe(e):Ke())},s=()=>{Me.current&&(Me.current=!1,Ne.current=null,Ke())},c={passive:!1};return document.addEventListener(`touchstart`,i,c),document.addEventListener(`touchmove`,a,c),document.addEventListener(`touchend`,o,c),document.addEventListener(`touchcancel`,s,c),()=>{document.removeEventListener(`touchstart`,i,c),document.removeEventListener(`touchmove`,a,c),document.removeEventListener(`touchend`,o,c),document.removeEventListener(`touchcancel`,s,c)}},[R,ce,le,Ge,Ke,Xe,de.i]);let Qe=(0,Y.useCallback)((e,t)=>{if(!e||!e.key)return null;let r=mu(W,String(e.key));if(!r)return null;let i=typeof r.isDraggable==`boolean`?r.isDraggable:!r.static&&P,a=typeof r.isResizable==`boolean`?r.isResizable:!r.static&&re,o=r.resizeHandles||[...ie],c=i&&F&&r.isBounded!==!1,u=ae;return(0,X.jsx)(gf,{containerWidth:n,cols:A,margin:N,containerPadding:U,maxRows:M,rowHeight:j,cancel:L,handle:I,onDragStart:Re,onDrag:ze,onDragStop:Be,onResizeStart:Ve,onResize:He,onResizeStop:Ue,isDraggable:i,isResizable:a,isBounded:c,allowMobileScroll:ne,useCSSTransforms:fe&&pe,usePercentages:!pe,transformScale:H,positionStrategy:s,dragThreshold:te,w:r.w,h:r.h,x:r.x,y:r.y,i:r.i,minH:r.minH,minW:r.minW,maxH:r.maxH,maxW:r.maxW,static:r.static,droppingPosition:t?be:void 0,resizeHandles:o,resizeHandle:u,constraints:l,layoutItem:r,layout:W,children:e},r.i)},[W,n,A,N,U,M,j,L,I,Re,ze,Be,Ve,He,Ue,P,re,F,fe,pe,H,s,te,be,ie,ae,l]),$e=()=>he?(0,X.jsx)(gf,{w:he.w,h:he.h,x:he.x,y:he.y,i:he.i,className:`react-grid-placeholder ${ge?`placeholder-resizing`:``}`,containerWidth:n,cols:A,margin:N,containerPadding:U,maxRows:M,rowHeight:j,isDraggable:!1,isResizable:!1,isBounded:!1,useCSSTransforms:fe,transformScale:H,constraints:l,layout:W,children:(0,X.jsx)(`div`,{})}):null,et=(0,Y.useCallback)(e=>{je.current=e,typeof h==`function`?h(e):h&&`current`in h&&(h.current=e)},[h]),tt=O(yf,p),nt={height:Le,...m};return(0,X.jsxs)(`div`,{ref:et,className:tt,style:nt,onDrop:R?Ze:void 0,onDragLeave:R?Je:void 0,onDragEnter:R?Ye:void 0,onDragOver:R?qe:void 0,children:[Y.Children.map(t,e=>Y.isValidElement(e)?Qe(e):null),R&&ve&&Qe(ve,!0),$e()]})}var wf={lg:1200,md:996,sm:768,xs:480,xxs:0},Tf={lg:12,md:10,sm:6,xs:4,xxs:2},Ef=()=>{};function Df(e,t,n,r,i=!1){let a=[];Y.Children.forEach(t,t=>{if(!Y.isValidElement(t)||t.key===null)return;let n=String(t.key),r=t.props[`data-grid`],o=e.find(e=>e.i===n);o?i&&r?a.push({...o,i:n,w:r.w??o.w,h:r.h??o.h,minW:r.minW??o.minW,maxW:r.maxW??o.maxW,minH:r.minH??o.minH,maxH:r.maxH??o.maxH}):a.push({...o,i:n}):r?a.push({i:n,x:r.x??0,y:r.y??0,w:r.w??1,h:r.h??1,minW:r.minW,maxW:r.maxW,minH:r.minH,maxH:r.maxH,static:r.static,isDraggable:r.isDraggable,isResizable:r.isResizable,resizeHandles:r.resizeHandles,isBounded:r.isBounded}):a.push({i:n,x:0,y:pu(a),w:1,h:1})});let o=bu(a,{cols:n});return r.compact(o,n)}function Of(e){let{children:t,width:n,breakpoint:r,breakpoints:i=wf,cols:a=Tf,layouts:o={},rowHeight:s=150,maxRows:c=1/0,margin:l=[10,10],containerPadding:u=null,compactor:d,onBreakpointChange:f=Ef,onLayoutChange:p=Ef,onWidthChange:m=Ef,...h}=e,g=d??ed(`vertical`),_=g.type,v=g.allowOverlap,y=(0,Y.useMemo)(()=>r??nd(i,n),[]),b=(0,Y.useMemo)(()=>rd(y,a),[y,a]),x=(0,Y.useMemo)(()=>id(o,i,y,y,b,_),[]),[S,C]=(0,Y.useState)(y),[w,T]=(0,Y.useState)(b),[E,D]=(0,Y.useState)(x),[O,k]=(0,Y.useState)(o),A=(0,Y.useRef)(n),j=(0,Y.useRef)(r),M=(0,Y.useRef)(i),N=(0,Y.useRef)(a),ee=(0,Y.useRef)(o),P=(0,Y.useRef)(_),F=(0,Y.useRef)(O);(0,Y.useEffect)(()=>{F.current=O},[O]);let I=(0,Y.useMemo)(()=>(0,uf.deepEqual)(o,ee.current)?null:id(o,i,S,S,w,g),[o,i,S,w,g]),L=I??E;(0,Y.useEffect)(()=>{I!==null&&(D(I),k(o),F.current=o,ee.current=o)},[I,o]),(0,Y.useEffect)(()=>{if(_!==P.current){let e=g.compact(_u(L),w),t={...F.current,[S]:e};D(e),k(t),F.current=t,p(e,t),P.current=_}},[_,g,L,w,v,S,p]),(0,Y.useEffect)(()=>{let e=n!==A.current,o=r!==j.current,s=!(0,uf.deepEqual)(i,M.current),c=!(0,uf.deepEqual)(a,N.current);if(e||o||s||c){let e=r??nd(i,n),o=rd(e,a),d=S;if(d!==e||s||c){let n={...F.current};n[d]||(n[d]=_u(E));let r=id(n,i,e,d,o,g),a=!n[e];r=Df(r,t,o,g,a),n[e]=r,C(e),T(o),D(r),k(n),F.current=n,f(e,o),p(r,n)}let h=ad(l,e),_=u?ad(u,e):null;m(n,h,o,_),A.current=n,j.current=r,M.current=i,N.current=a}},[n,r,i,a,S,w,E,t,g,_,v,l,u,f,p,m]);let te=(0,Y.useCallback)(e=>{let t={...F.current,[S]:e};D(e),k(t),F.current=t,p(e,t)},[S,p]),ne=(0,Y.useMemo)(()=>ad(l,S),[l,S]),re=(0,Y.useMemo)(()=>u===null?null:ad(u,S),[u,S]),ie=(0,Y.useMemo)(()=>({cols:w,rowHeight:s,maxRows:c,margin:ne,containerPadding:re}),[w,s,c,ne,re]);return(0,X.jsx)(Cf,{...h,width:n,gridConfig:ie,compactor:g,onLayoutChange:te,layout:L,children:t})}var kf=Y.forwardRef(function(e,t){let{innerRef:n,...r}=e,i=n??t;return(0,X.jsx)(Of,{...r,innerRef:i})});kf.displayName=`ResponsiveGridLayout`;var Af={bytes:16e3,items:40,copies:4,rows:400},jf=[{cols:12,min:840},{cols:6,min:560},{cols:2,min:0}],Mf=e=>jf.find(t=>e>=t.min).cols,Nf=(e,t,n)=>Math.min(Math.max(e,t),n),Pf=e=>({kind:`bool`,fallback:e}),Ff=(e,t)=>({kind:`enum`,values:e,fallback:t}),If=(e,t)=>({kind:`set`,values:e,fallback:t}),Lf={w:4,h:2,minW:3,oldMinW:2,maxW:4,minH:2,maxH:2},Rf={w:6,h:5,minW:4,maxW:12,minH:4,maxH:8},zf={w:3,h:4,minW:3,maxW:6,minH:3,maxH:9},Bf=Ff([`chart`,`table`],`chart`),Vf=(e,t)=>({title:e,group:`tile`,size:Lf,options:{...t===null?{}:{spark:Pf(t)},compare:Pf(!0)}}),Hf=e=>({title:e,group:`list`,size:zf,options:{rows:Ff([3,5,10],5)},auto:e=>({3:3,5:4,10:7})[e.rows]}),Uf=[`stacked`,`grouped`,`lines`],Wf=[`p50`,`p90`,`p95`,`p99`],$={tile_calls:Vf(`Turns`,!0),tile_tokens:Vf(`Tokens`,!1),tile_duration:Vf(`Agent time`,!1),tile_cost:Vf(`Reported cost`,!1),tile_fixes:Vf(`Fixes ready`,null),tile_failed:Vf(`Failed or stopped`,!1),time:{title:`Usage over time`,group:`chart`,many:!0,size:{w:12,h:6,minW:4,maxW:12,minH:4,maxH:10},options:{metric:Ff(Ue,`calls`),by:Ff([...et,`none`],`agent`),bucket:Ff([`auto`,...Ye],`auto`),style:Ff(Uf,`stacked`),legend:Pf(!0),brush:Pf(!0),view:Bf}},breakdown:{title:`Breakdown`,group:`chart`,many:!0,size:{w:6,h:5,minW:3,maxW:12,minH:3,maxH:10},options:{by:Ff(et,`project`),metric:Ff([`chart`,...Ue],`chart`),rows:Ff([5,8,12,20],8),share:Pf(!0),view:Bf},auto:e=>({5:4,8:5,12:7,20:10})[e.rows]},outcomes:{title:`How turns ended`,group:`chart`,many:!0,size:Rf,options:{mode:Ff([`share`,`counts`],`share`),view:Bf}},approvals:{title:`Approvals`,group:`chart`,many:!0,size:Rf,options:{mode:Ff([`stacked`,`separate`],`stacked`),view:Bf}},latency:{title:`Turn duration`,group:`chart`,many:!0,size:Rf,options:{percentiles:If(Wf,[`p50`,`p95`]),log:Pf(!1),view:Bf}},top_agents:Hf(`Busiest agents`),top_threads:Hf(`Threads that used the most tokens`),top_slowest:Hf(`Slowest turns`),top_denied:Hf(`Most denied approvals`),budgets:{title:`Budgets today`,group:`budgets`,admin:!0,size:{w:12,h:4,minW:4,maxW:12,minH:3,maxH:10},options:{},auto:(e,t)=>Number.isInteger(t?.budgets)?Nf(Math.ceil((89+Math.max(t.budgets,1)*65)/72),3,6):null}},Gf=Object.keys($),Kf=e=>typeof e==`string`&&Object.hasOwn($,e),qf=/^[a-z][a-z0-9_]{0,23}(?:-[1-9][0-9]?)?$/,Jf=class extends Error{constructor(e,t){super(t),this.code=e}};function Yf(e,t){let n={};if(!Kf(e))return n;let r=t&&typeof t==`object`&&!Array.isArray(t)?t:{};for(let[t,i]of Object.entries($[e].options)){let e=Object.hasOwn(r,t)?r[t]:void 0;if(i.kind===`bool`)n[t]=typeof e==`boolean`?e:i.fallback;else if(i.kind===`enum`)n[t]=i.values.includes(e)?e:i.fallback;else{let r=Array.isArray(e)?i.values.filter(t=>e.includes(t)):[];n[t]=r.length?r:[...i.fallback]}}return n}var Xf=e=>Number.isInteger(e),Zf=(e,t)=>e.id!==t.id&&e.x<t.x+t.w&&t.x<e.x+e.w&&e.y<t.y+t.h&&t.y<e.y+e.h,Qf=(e,t)=>e.y-t.y||e.x-t.x||(e.id<t.id?-1:+(e.id>t.id)),$f=(e,t)=>e.find(e=>Zf(e,t)),ep=e=>[...e].sort(Qf);function tp(e,t=12){let n=[],r={x:0,y:0};for(let i of e){let e=Math.min(i.w,t),a=null;for(let o=r.y;!a;o+=1)for(let s=o===r.y?r.x:0;s+e<=t&&!a;s+=1){let t={...i,w:e,x:s,y:o};$f(n,t)||(a=t)}n.push(a),r={x:a.x+1,y:a.y}}return n}var np=(e,t=12)=>tp(ep(e),t);function rp(e,t,n,r){let i=ep(e),a=i.find(e=>e.id===t);if(!a)return null;let o=i.filter(e=>e.id!==t),s=o.find(e=>n>=e.x&&n<e.x+e.w&&r>=e.y&&r<e.y+e.h);if(s)return i.indexOf(s)>i.indexOf(a)?o[o.indexOf(s)+1]?.id??null:s.id;let c=Math.floor(n),l=Math.floor(r);return o.find(e=>e.y>l||e.y===l&&e.x>c)?.id??null}var ip=e=>$[e].size;function ap(e,t,n,r=0){let i=ip(e);return{w:Nf(t,i.minW,Math.min(i.maxW,12-r)),h:Nf(n,i.minH,i.maxH)}}function op(e){return Array.isArray(e)?{v:1,items:e.map(e=>e&&typeof e==`object`?{id:e.i,type:typeof e.i==`string`?e.i.replace(/-[0-9]+$/,``):void 0,x:e.x,y:e.y,w:e.w,h:e.h,options:e.options}:e)}:!e||typeof e!=`object`||e.v!==1?null:e}function sp(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return null;let{id:r,type:i,x:a,y:o,w:s,h:c}=e;if(!Kf(i)||typeof r!=`string`||!qf.test(r)||t.has(r))return null;let l=ip(i);if(![a,o,s,c].every(Xf)||s<(l.oldMinW??l.minW)||s>l.maxW||c<l.minH||c>l.maxH||a<0||a+s>12||o<0||o>Af.rows)return null;let u=n.get(i)||0;if(u>=($[i].many?Af.copies:1))return null;n.set(i,u+1),t.add(r);let d={id:r,type:i,x:a,y:o,w:Math.max(s,l.minW),h:c,options:Yf(i,e.options)};return $[i].auto&&(d.auto=typeof e.auto==`boolean`?e.auto:c===l.h),d}function cp(e){let t;try{t=JSON.stringify(e)?.length??0}catch{throw new Jf(`invalid_layout`,`layout: an object with its widgets.`)}if(t>Af.bytes)throw new Jf(`layout_too_large`,`A layout holds at most ${Af.bytes} characters.`);let n=op(e);if(!n||!Array.isArray(n.items))throw new Jf(`invalid_layout`,`layout: { v, items } as the page saves it.`);let r=new Set,i=new Map,a=[];for(let e of n.items){if(a.length>=Af.items)break;let t=sp(e,r,i);t&&a.push(t)}return{v:1,items:np(a)}}function lp(e){try{return e==null?null:cp(e)}catch{return null}}var up=(e,t,n,r={})=>({id:e,type:e,x:t,y:n,w:ip(e).w,h:ip(e).h,options:Yf(e,{}),...$[e].auto?{auto:!0}:{},...r});function dp(){return{v:1,items:[up(`tile_calls`,0,0),up(`tile_tokens`,4,0),up(`tile_duration`,8,0),up(`tile_cost`,0,2),up(`tile_fixes`,4,2),up(`tile_failed`,8,2),up(`time`,0,4),up(`breakdown`,0,10),up(`outcomes`,6,10),up(`approvals`,0,15),up(`latency`,6,15),up(`top_agents`,0,20),up(`top_threads`,3,20),up(`top_slowest`,6,20),up(`top_denied`,9,20),up(`budgets`,0,24)]}}var fp=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function pp(e,{admin:t=!1}={}){let n=e.items.filter(e=>t||!$[e.type].admin);return n.length===e.items.length?e.items:np(n)}function mp(e,t={}){let n=!1,r=e.items.map(e=>{if(!e.auto)return e;let r=$[e.type].auto(e.options,t),i=ip(e.type),a=Number.isInteger(r)?Nf(r,i.minH,i.maxH):e.h;return a===e.h?e:(n=!0,{...e,h:a})});return n?{v:1,items:np(r)}:e}var hp=(e,t)=>({v:1,items:t}),gp=(e,t)=>e.items.find(e=>e.id===t);function _p(e,t,n){let r=ep(e.items),i=r.find(e=>e.id===t);if(!i||n===t)return e;let a=r.filter(e=>e.id!==t),o=n===null?a.length:a.findIndex(e=>e.id===n);if(o<0)return e;a.splice(o,0,i);let s=tp(a);return fp(s,e.items)?e:hp(e,s)}function vp(e,t,n,r){let i=gp(e,t);if(!i)return e;let a={...i,...ap(i.type,Math.round(n),Math.round(r),i.x)};if(a.w===i.w&&a.h===i.h)return e;i.auto&&a.h!==i.h&&(a.auto=!1);let o=new Map([[t,a]]),s=e.items.filter(e=>e.id!==t&&e.y===i.y),c=a.w-i.w,l=$[i.type]?.group===`tile`;if(c&&l)for(let n of e.items)n.id!==t&&$[n.type]?.group===`tile`&&o.set(n.id,{...n,w:a.w});let u=c&&!l?s.find(e=>e.x===i.x+i.w):null,d=c<0&&!l&&!u&&i.x+i.w===12?s.find(e=>e.x+e.w===i.x):null;for(let e of[u,d]){if(!e)continue;let t=ip(e.type),n=e.w-c;n>=t.minW&&n<=t.maxW&&o.set(e.id,{...e,w:n})}let f=tp(ep(e.items).map(e=>o.get(e.id)??e));if(a.h!==i.h){let e=f.find(e=>e.id===t),n=n=>{let r=ip(n.type);return n.id!==t&&!n.auto&&n.y===e.y&&n.h===i.h&&a.h>=r.minH&&a.h<=r.maxH};f.some(n)&&(f=tp(f.map(e=>n(e)?{...e,h:a.h,...e.auto?{auto:!1}:{}}:e)))}return hp(e,f)}var yp=(e,t)=>e.x<t.x+t.w&&t.x<e.x+e.w;function bp(e,t,n){let r=ep(e.items),i=r.findIndex(e=>e.id===t);if(i<0)return e;let a=r[i];if(n===`left`)return i>0?_p(e,t,r[i-1].id):e;if(n===`right`)return i<r.length-1?_p(e,t,r[i+2]?.id??null):e;let o=r.filter(e=>e.id!==t&&yp(e,a)),s=n===`up`?o.filter(e=>e.y+e.h<=a.y).sort((e,t)=>t.y+t.h-(e.y+e.h)||e.x-t.x)[0]:o.filter(e=>e.y>=a.y+a.h).sort((e,t)=>e.y-t.y||e.x-t.x)[0];if(!s)return e;let c=[...r];return c[i]=s,c[r.indexOf(s)]=a,hp(e,tp(c))}function xp(e,t,n){return hp(e,e.items.map(e=>e.id===t?{...e,options:Yf(e.type,{...e.options,...n})}:e))}var Sp=(e,t)=>hp(e,np(e.items.filter(e=>e.id!==t))),Cp=e=>e.reduce((e,t)=>Math.max(e,t.y+t.h),0);function wp(e,t){if(!gp(e,t))return t;for(let n=2;n<100;n+=1)if(!gp(e,`${t}-${n}`))return`${t}-${n}`;return null}function Tp(e,t){if(!Kf(t)||e.items.length>=Af.items)return 0;let n=e.items.filter(e=>e.type===t).length;return Math.max(0,($[t].many?Af.copies:1)-n)}var Ep=(e,{admin:t=!1}={})=>Gf.filter(n=>(t||!$[n].admin)&&!e.items.some(e=>e.type===n));function Dp(e,t,n={},{before:r=null}={}){let i=Tp(e,t)?wp(e,t):null;if(!i)return{layout:e,id:null};let a={...up(t,0,Cp(e.items)),id:i,options:Yf(t,n)},o=ep(e.items),s=r===null?-1:o.findIndex(e=>e.id===r);return o.splice(s<0?o.length:s,0,a),{layout:hp(e,tp(o)),id:i}}function Op(e,t){let n=gp(e,t);if(!n||!$[n.type].many||!Tp(e,n.type))return{layout:e,id:null};let r={...n,id:wp(e,n.type),options:Yf(n.type,n.options)},i=ep(e.items);return i.splice(i.indexOf(n)+1,0,r),{layout:hp(e,tp(i)),id:r.id}}function kp(e,t){if(t>=12)return e.w;let n=$[e.type].group;if(t===2)return n===`tile`?1:2;let r=n===`tile`?2:n===`list`?3:t;return Nf(Math.round(e.w*t/12),r,t)}function Ap(e,t=12){return t>=12?e:tp(ep(e).map(e=>({...e,w:kp(e,t)})),t)}function jp(e,t=12){let n=e.map(e=>({...e})),r=(e,t,r,i)=>n.some(n=>!i.has(n)&&n.x<=e&&e<n.x+n.w&&n.y<r&&t<n.y+n.h);for(let e of[...new Set(n.map(e=>e.y))].sort((e,t)=>e-t)){let i=n.filter(t=>t.y===e).sort((e,t)=>e.x-t.x),a=i[i.length-1],o=[a];for(let e=i.length-2;e>=0;e--){let t=i[e];if(t.x+t.w!==o[0].x||t.h!==a.h)break;o.unshift(t)}let s=new Set(o),c=0;for(;a.x+a.w+c<t&&!r(a.x+a.w+c,e,e+a.h,s);)c++;if(!c)continue;let l=o[0].x;o.forEach((e,t)=>{e.w+=Math.floor(c/o.length)+ +(t<c%o.length),e.x=l,l+=e.w})}return n}var Mp=e=>Math.max(6,Math.ceil((e+16)/18)),Np=e=>!!(e.auto&&$[e.type]?.auto);function Pp(e,t=12,n={}){let r=ep(e),i=e=>Np(e)&&Number.isInteger(n[e.id])?Math.min(n[e.id],e.h*4):null,a=new Map(r.map(e=>[e.id,i(e)??e.h*4]));for(let e of r){if($[e.type].group!==`list`||i(e)===null)continue;let t=r.filter(t=>t.y===e.y&&t.h===e.h&&$[t.type].group===`list`&&i(t)!==null);a.set(e.id,Math.max(...t.map(e=>i(e))))}let o=[],s=-1;for(let e of r)e.y>=s&&o.push([]),o[o.length-1].push(e),s=Math.max(s,e.y+e.h);let c=e=>$[e.type].group===`chart`&&!$[e.type].auto,l=e=>e.map(e=>`${e.x}:${e.w}`).join(` `),u=[];o.forEach((e,t)=>{t&&(l(e)===l(o[t-1])||e.every(c))?u[u.length-1].push(...e):u.push([...e])});let d=[],f=0;for(let e of u){let n=e.filter(e=>a.get(e.id)!==e.h*4),r=null;for(let i of[null,...n.map(e=>e.id),...n.length>1?[`*`]:[]]){let n=e=>i===`*`||i===e.id?e.h*4:a.get(e.id),o=new Set(e.filter(e=>n(e)!==e.h*4).map(e=>e.id)),s=Fp(e.map(e=>({...e,h:n(e)})),t,c,o);if((!r||s.holes<r.holes)&&(r=s),!r.holes)break}for(let e of r.placed)d.push({...e,y:e.y+f});f+=r.end}return d}function Fp(e,t,n,r){let i=tp(e,t),a=i.reduce((e,t)=>Math.max(e,t.y+t.h),0),o=(e,t,n)=>i.some(r=>r!==n&&r.x<=e&&e<r.x+r.w&&r.y<=t&&t<r.y+r.h),s=e=>{let t=Math.min(a,...i.filter(t=>t!==e&&t.y>=e.y+e.h&&t.x<e.x+e.w&&e.x<t.x+t.w).map(e=>e.y)),n=t=>!Array.from({length:e.w},(t,n)=>e.x+n).some(n=>o(n,t,e));for(;e.y+e.h<t&&n(e.y+e.h);)e.h+=1};for(let e of i)n(e)&&s(e);for(let e of i)!n(e)&&r.has(e.id)&&s(e);let c=new Set(i.map(e=>e.x+e.w)),l=Math.max(...c),u=0;for(let e=0;e<l;e+=1)for(let t=0;t<a;t+=1)o(e,t,null)||(u+=1);return{placed:i,end:a,holes:u}}function Ip(e,t,n){let r=ep(e.items),i=r.findIndex(e=>e.id===t);if(i<0)return e;let a=Nf(n,0,r.length-1);return a===i?e:_p(e,t,r.filter(e=>e.id!==t)[a]?.id??null)}function Lp(e){return`row ${e.y+1}, column ${e.x+1}; ${e.w} wide, ${e.h} tall`}var Rp=`h-8 w-auto min-w-0 gap-1 px-2 text-xs`;function zp({label:e,value:t,onChange:n,options:r,testId:a,className:o}){return(0,X.jsxs)(M,{value:String(t),onValueChange:n,children:[(0,X.jsx)(E,{className:i(Rp,o),"aria-label":e,"data-sw-pick":a,children:(0,X.jsx)(T,{})}),(0,X.jsx)(w,{children:r.map(([e,t])=>(0,X.jsx)(A,{value:String(e),children:t},e))})]})}var Bp=e=>[e,`By ${Xe[e].toLowerCase()}`],Vp={key:`view`,label:`Show as`,choices:[[`chart`,`Chart`],[`table`,`Table`]]},Hp=[{key:`spark`,label:`Trend line`},{key:`compare`,label:`Change against the period before`}],Up=[{key:`rows`,label:`Rows`,choices:[3,5,10].map(e=>[e,`Top ${e}`]),number:!0}],Wp={time:[{key:`metric`,label:`Measure`,choices:Ue.map(e=>[e,$e[e]])},{key:`by`,label:`Split by`,choices:[...et.map(Bp),[`none`,`No split`]]},{key:`bucket`,label:`Bucket`,choices:[[`auto`,`Automatic`],...Ye.map(e=>[e,e[0].toUpperCase()+e.slice(1)])]},{key:`style`,label:`Draw as`,choices:[[`stacked`,`Stacked bars`],[`grouped`,`Grouped bars`],[`lines`,`Lines`]]},{key:`legend`,label:`Legend`},{key:`brush`,label:`Zoom brush`},Vp],breakdown:[{key:`by`,label:`Break down by`,choices:et.map(Bp)},{key:`metric`,label:`Measure`,choices:[[`chart`,`Same as the chart over time`],...Ue.map(e=>[e,$e[e]])]},{key:`rows`,label:`Rows`,choices:[5,8,12,20].map(e=>[e,`Top ${e}`]),number:!0},{key:`share`,label:`Share of the total`},Vp],outcomes:[{key:`mode`,label:`Measure`,choices:[[`share`,`Share of turns`],[`counts`,`Number of turns`]]},Vp],approvals:[{key:`mode`,label:`Bars`,choices:[[`stacked`,`Stacked`],[`separate`,`Side by side`]]},Vp],latency:[{key:`percentiles`,label:`Lines`,set:[[`p50`,`Median`],[`p90`,`90th`],[`p95`,`95th`],[`p99`,`99th`]]},{key:`log`,label:`Logarithmic scale`},Vp],top_agents:Up,top_threads:Up,top_slowest:Up,top_denied:Up},Gp=e=>(Wp[e]||($[e].group===`tile`?Hp:[])).filter(t=>Object.hasOwn($[e].options,t.key));function Kp({item:e,options:t,onChange:n,title:r,className:a}){let o=Gp(e.type);return o.length?(0,X.jsxs)(b,{history:!1,children:[(0,X.jsx)(F,{asChild:!0,children:(0,X.jsx)(y,{label:`Options for ${r}`,size:`icon-xs`,className:i(`print:hidden`,a),"data-sw-widget-options":e.id,children:(0,X.jsx)(le,{size:15,"aria-hidden":`true`})})}),(0,X.jsxs)(N,{align:`end`,className:`w-72 p-3`,"data-sw-widget-options-panel":e.id,children:[(0,X.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:r}),(0,X.jsx)(`ul`,{className:`space-y-2`,children:o.map(r=>(0,X.jsxs)(`li`,{className:`flex min-h-8 items-center justify-between gap-3`,"data-sw-widget-option":r.key,children:[(0,X.jsx)(`span`,{className:`text-xs text-muted`,id:`option-${e.id}-${r.key}`,children:r.label}),r.choices?r.choices.length<=2?(0,X.jsx)(j,{label:r.label,value:String(t[r.key]),onChange:e=>n({[r.key]:e}),options:r.choices.map(([e,t])=>({id:String(e),label:t}))}):(0,X.jsx)(zp,{label:r.label,testId:`option-${r.key}`,value:t[r.key],onChange:e=>n({[r.key]:r.number?Number(e):e}),options:r.choices}):r.set?(0,X.jsx)(`span`,{className:`flex flex-wrap justify-end gap-x-2.5 gap-y-1`,role:`group`,"aria-labelledby":`option-${e.id}-${r.key}`,children:r.set.map(([e,i])=>{let a=t[r.key].includes(e);return(0,X.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-xs text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:a,disabled:a&&t[r.key].length===1,onChange:()=>n({[r.key]:a?t[r.key].filter(t=>t!==e):[...t[r.key],e]}),className:`h-4 w-4 accent-[var(--accent)]`,"data-sw-widget-option-item":e}),i]},e)})}):(0,X.jsx)(_e,{checked:!!t[r.key],onChange:e=>n({[r.key]:e}),label:r.label})]},r.key))})]})]}):null}var qp={tile_calls:`calls`,tile_tokens:`tokens`,tile_duration:`duration`,tile_cost:`cost`,tile_fixes:`fixes`,tile_failed:`failed`};function Jp(e,{now:t,before:n,trendOf:r}){let i=e=>t&&t.calls?t.reported[e]===t.calls?null:`${J(t.reported[e])} of ${J(t.calls)} turns reported`:null;switch(e){case`tile_calls`:return{value:J(t?.calls??0),current:t?.calls,previous:n?.calls,trend:r(`calls`)};case`tile_tokens`:return{value:t?.tokens===null?`Not reported`:J(t?.tokens),current:t?.tokens,previous:n?.tokens,hint:t?.tokens===null?null:i(`tokens`)??`${J(t?.input)} in · ${J(t?.output)} out`,note:t?.tokens===null?`No agent reported tokens`:void 0,trend:r(`tokens`)};case`tile_duration`:return{value:tt(t?.duration),current:t?.duration,previous:n?.duration,hint:t?.latency?.turns?`Median ${tt(t.latency.p50)} · 95th ${tt(t.latency.p95)}`:null,trend:r(`duration`)};case`tile_cost`:return{value:t?.cost===null?`Not reported`:at(t?.cost),current:t?.cost,previous:n?.cost,hint:t?.cost===null?null:i(`cost`),note:t?.cost===null?`No agent reported a cost`:void 0,trend:r(`cost`)};case`tile_fixes`:return{value:t?.fixes?`${J(t.fixesDone)} of ${J(t.fixes)}`:`0`,current:t?.fixes?t.fixesDone/t.fixes:null,previous:n?.fixes?n.fixesDone/n.fixes:null,better:`up`,hint:t?.fixes?`${nt(t.fixesDone,t.fixes)} ended with a fix or an answer`:`No fix was asked for`};default:return{value:t?nt(t.outcomes.failed+t.outcomes.stopped,t.calls):``,current:t?.calls?(t.outcomes.failed+t.outcomes.stopped)/t.calls:null,previous:n?.calls?(n.outcomes.failed+n.outcomes.stopped)/n.calls:null,better:`down`,hint:t?`${J(t.outcomes.failed)} failed · ${J(t.outcomes.stopped)} stopped`:null,trend:r(`failed`)}}}function Yp({item:e,options:t,ctx:n,menu:r}){let i=gi(n.workspaceId,`/usage/summary?${n.query}`),a=!!t.spark,o=gi(n.workspaceId,`/usage/series?${n.query}&bucket=${n.bucket}&groupBy=none&metric=calls`,{enabled:a}),s=Jp(e.type,{now:i.data?.current,before:i.data?.previous,trendOf:e=>{if(!a||!o.data)return null;let t=new Map(o.data.points.map(e=>[e.bucket,e]));return o.data.buckets.map(n=>{let r=t.get(n);return e===`calls`?r?r.calls:0:e===`failed`?r?.calls?((r.outcomes?.failed||0)+(r.outcomes?.stopped||0))/r.calls:null:r?r[e]??null:null})}});return(0,X.jsx)(_t,{testId:qp[e.type],compare:n.period.compare,label:$[e.type].title,loading:i.isLoading,fill:!0,menu:r,spark:a,showCompare:t.compare,...s})}function Xp({options:e,setOptions:t,ctx:n,menu:r}){let{metric:i,by:a}=e,o=e.bucket===`auto`?n.autoBucket:e.bucket,s=gi(n.workspaceId,`/usage/series?${n.query}&bucket=${o}&groupBy=${a}&metric=${i}`);return(0,X.jsx)(vt,{data:s.data,metric:i,bucket:o,dimension:s.data?.groupBy??a,state:s,onPick:a===`none`?null:n.toggle(a),pressed:a===`none`?[]:n.filter.list(a).map(e=>e===`~`?``:e),onRange:(e,t)=>n.filter.set({range:`custom`,from:lt(e,o).from,to:lt(t,o).to},{push:!0}),style:e.style,showLegend:e.legend,showBrush:e.brush,fill:!0,menu:r,view:e.view,onView:e=>t({view:e}),controls:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(zp,{label:`Measure`,testId:`metric`,value:i,onChange:e=>t({metric:e}),options:Ue.map(e=>[e,$e[e]])}),(0,X.jsx)(zp,{label:`Split by`,testId:`by`,value:a,onChange:e=>t({by:e}),options:[...et.map(Bp),[`none`,`No split`]]}),(0,X.jsx)(j,{label:`Bucket`,value:o,onChange:e=>t({bucket:e}),options:Ye.map(e=>({id:e,label:e[0].toUpperCase()+e.slice(1)}))})]})})}function Zp({options:e,setOptions:t,ctx:n,menu:r}){let i=e.by,a=e.metric===`chart`?n.metric:e.metric,o=gi(n.workspaceId,`/usage/breakdown?${n.query}&groupBy=${i}`);return(0,X.jsx)(xt,{groups:o.data?.groups,metric:a,dimension:i,title:Xe[i],state:o,onPick:n.toggle(i),pressed:n.filter.list(i).map(e=>e===`~`?``:e),rows:e.rows,showShare:e.share,fill:!0,menu:r,view:e.view,onView:e=>t({view:e}),controls:(0,X.jsx)(zp,{label:`Break down by`,testId:`bd`,value:i,onChange:e=>t({by:e}),options:et.map(Bp)})})}var Qp=e=>gi(e.workspaceId,`/usage/series?${e.query}&bucket=${e.bucket}&groupBy=none&metric=calls`);function $p({options:e,setOptions:t,ctx:n,menu:r}){let i=Qp(n);return(0,X.jsx)(ct,{data:i.data,bucket:n.bucket,state:i,onPick:n.toggle(`outcome`),pressed:n.filter.list(`outcome`),mode:e.mode,fill:!0,menu:r,view:e.view,onView:e=>t({view:e})})}function em({options:e,setOptions:t,ctx:n,menu:r}){let i=Qp(n);return(0,X.jsx)(mt,{data:i.data,bucket:n.bucket,state:i,mode:e.mode,fill:!0,menu:r,view:e.view,onView:e=>t({view:e})})}function tm({options:e,setOptions:t,ctx:n,menu:r}){let i=gi(n.workspaceId,`/usage/latency?${n.query}&bucket=${n.bucket}`);return(0,X.jsx)(st,{data:i.data,bucket:n.bucket,state:i,percentiles:e.percentiles,log:e.log,fill:!0,menu:r,view:e.view,onView:e=>t({view:e})})}var nm={top_agents:`agents`,top_threads:`threads`,top_slowest:`slowest`,top_denied:`denied`},rm={agents:`No agent took a turn.`,threads:`No agent reported tokens.`,slowest:`No turn has finished.`,denied:`No approval was denied.`};function im(e,t,{workspaceId:n,filter:r,isAdmin:i}){let a=e=>r.set({tab:`turns`,...e},{push:!0});return e===`agents`?(t?.agents||[]).map(e=>({key:e.key,label:e.label,hint:e.machine,value:`${J(e.calls)} turns`,to:i&&e.key?`/w/${n}/activity/${e.key}`:null,onClick:()=>a({agent:[e.key||`~`]})})):e===`threads`?(t?.threads||[]).map((e,t)=>({key:t,label:e.thread.kind===`comment`?`Comment #${e.commentNumber}`:e.thread.kind===`chat`?`A private chat`:`The board’s chat`,hint:`${e.project.name} · ${e.boardId}`,value:`${J(e.tokens)} tokens`,onClick:e.thread.id?()=>a({q:e.thread.id,project:[e.project.id]}):null})):e===`slowest`?(t?.slowest||[]).map(e=>({key:e.id,label:`${Ze[e.kind]||e.kind} by ${e.agent?.name||`no agent`}`,hint:`${e.project.name} · ${Ct(e.startedAt)}`,value:tt(e.durationMs),onClick:()=>r.set({row:e.id})})):(t?.denied||[]).map(e=>({key:e.key,label:e.label,hint:`${J(e.asked)} asked`,value:`${J(e.denied)} denied`,onClick:()=>a({agent:[e.key||`~`],kind:[`fix`,`push`]})}))}function am({item:e,options:t,ctx:n,menu:r}){let i=nm[e.type],a=gi(n.workspaceId,`/usage/top?${n.query}${t.rows===5?``:`&limit=${t.rows}`}`),o=im(i,a.data,n).slice(0,t.rows),s=$[e.type].title;return(0,X.jsxs)(K,{className:`flex h-full min-w-0 flex-col overflow-hidden`,"data-sw-top":i,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-1 border-b border-line py-1.5 pr-2 pl-4`,"data-sw-top-head":!0,children:[(0,X.jsx)(`h2`,{className:`truncate py-1 text-ui font-semibold text-fg`,title:s,children:s}),r]}),a.isLoading?(0,X.jsx)(`p`,{className:`px-4 py-6 text-center text-xs text-muted`,role:`status`,"data-sw-fit-wait":!0,children:`Loading`}):o.length?(0,X.jsx)(`ol`,{className:`min-h-0 flex-1 overflow-y-auto py-1`,"data-sw-top-rows":o.length,"data-sw-fit":!0,children:o.map((e,t)=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,onClick:e.onClick||void 0,disabled:!e.onClick,className:`flex w-full items-center gap-2.5 px-4 py-1 text-left outline-none enabled:hover:bg-surface-2 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent`,children:[(0,X.jsx)(`span`,{className:`tabular w-4 shrink-0 text-xs text-faint`,children:t+1}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate text-xs font-medium text-fg`,children:e.label}),e.hint?(0,X.jsx)(`span`,{className:`block truncate text-caption text-muted`,children:e.hint}):null]}),(0,X.jsx)(`span`,{className:`tabular shrink-0 text-xs text-fg`,children:e.value})]})},e.key))}):(0,X.jsx)(`p`,{className:`px-4 py-6 text-center text-xs text-muted`,"data-sw-fit":!0,"data-sw-fit-end":!0,children:rm[i]})]})}function om({ctx:e}){let t=gi(e.workspaceId,`/usage/budgets`,{keep:!1}),n=t.data?.projects||[];return(0,X.jsxs)(K,{className:`flex h-full min-w-0 flex-col overflow-hidden`,"data-sw-usage-budgets":!0,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-start gap-3 border-b border-line px-4 py-3 sm:px-5`,"data-sw-budgets-head":!0,children:[(0,X.jsx)(`span`,{className:`mt-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted`,children:(0,X.jsx)(Zt,{size:16,"aria-hidden":`true`})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h2`,{className:`text-title font-semibold text-fg`,children:`Budgets today`}),(0,X.jsx)(`p`,{className:`mt-0.5 truncate text-ui text-muted`,title:`Each project's agent policy caps chat turns and fixes per day (the day is UTC). A forecast shows once enough of the day has passed.`,children:`Each project's agent policy caps chat turns and fixes per day (the day is UTC). A forecast shows once enough of the day has passed.`})]})]}),t.isLoading?(0,X.jsx)(`p`,{className:`px-4 py-6 text-center text-xs text-muted`,role:`status`,"data-sw-fit-wait":!0,children:`Loading`}):n.length?(0,X.jsx)(`ul`,{className:`min-h-0 flex-1 divide-y divide-line overflow-y-auto`,"data-sw-fit":!0,children:n.map(({project:t,budgets:n})=>(0,X.jsxs)(`li`,{className:`grid gap-x-6 gap-y-2 px-4 py-2 sm:grid-cols-[minmax(0,12rem)_repeat(2,minmax(0,1fr))] sm:px-5`,"data-sw-budget":t.name,children:[(0,X.jsx)(V,{to:`/w/${e.workspaceId}/projects/${t.id}`,className:`truncate text-sm font-medium text-fg underline-offset-2 hover:underline`,children:t.name}),n.map(e=>{let n=e.limit?Math.min(1,e.used/e.limit):0,r=e.limit>0&&e.used>=e.limit,a=!r&&n>=.8,o=e.forecast!==null&&e.limit>0&&e.forecast>e.limit&&!r;return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`p`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,X.jsx)(`span`,{className:`truncate text-muted`,children:e.label}),(0,X.jsxs)(`span`,{className:`tabular shrink-0 font-medium text-fg`,children:[J(e.used,{exact:!0}),` of`,` `,e.limit?J(e.limit,{exact:!0}):`none allowed`]})]}),(0,X.jsx)(`div`,{className:`mt-1 h-2 overflow-hidden rounded-full bg-surface-2`,role:`meter`,"aria-label":`${e.label} for ${t.name}`,"aria-valuemin":0,"aria-valuemax":e.limit||0,"aria-valuenow":e.used,children:(0,X.jsx)(`div`,{className:i(`h-full rounded-full`,r?`bg-bad`:a?`bg-warn`:`bg-accent`),style:{width:`${n*100}%`}})}),(0,X.jsxs)(`p`,{className:`mt-1 truncate text-caption text-muted`,children:[r?`Used up for today. `:a?`Nearly used up. `:``,e.forecast===null?``:`On course for ${J(e.forecast)} by the end of the day${o?`, over the budget`:``}. `,`Daily average last week: `,e.average,`.`]})]},e.id)})]},t.id))}):(0,X.jsx)(`p`,{className:`px-4 py-6 text-center text-xs text-muted`,"data-sw-fit":!0,"data-sw-fit-end":!0,children:`No project has an agent policy with a budget yet.`})]})}var sm={time:Xp,breakdown:Zp,outcomes:$p,approvals:em,latency:tm,budgets:om};function cm({item:e,options:t,setOptions:n,ctx:r,menu:i}){let a=$[e.type].group,o=a===`tile`?Yp:a===`list`?am:sm[e.type];return(0,X.jsx)(o,{item:e,options:t,setOptions:n,ctx:r,menu:i})}var lm=(e,t,n)=>t.includes(e)?e:n,um={ArrowLeft:`left`,ArrowRight:`right`,ArrowUp:`up`,ArrowDown:`down`},dm={left:[-1,0],right:[1,0],up:[0,-1],down:[0,1]},fm={tile:`Tiles`,chart:`Charts`,list:`Top lists`,budgets:`Budgets`},pm=1500,mm={tile_calls:[cn,`How many agent turns, with a trend line`],tile_tokens:[Ut,`Tokens the agents reported, in and out`],tile_duration:[Sn,`Time the agents spent, with the median turn`],tile_cost:[Vt,`What the agents reported it cost`],tile_fixes:[Be,`Fixes asked for, and how many were made`],tile_failed:[xe,`Share of turns that failed or were stopped`],time:[me,`Turns, tokens or cost over time, split as you like`],breakdown:[Ft,`The biggest projects, agents, people or models`],outcomes:[L,`How turns ended, over time`],approvals:[he,`Approvals asked for, given and denied`],latency:[rn,`How long turns took: median and slowest`],top_agents:[on,`The agents that took the most turns`],top_threads:[on,`The threads that used the most tokens`],top_slowest:[on,`The turns that took longest`],top_denied:[on,`Who had the most approvals denied`],budgets:[Zt,`Each project’s daily budgets and today’s use`]},hm={tile:[`e`],chart:[`s`,`e`,`se`],list:[`s`,`e`,`se`],budgets:[`s`,`e`,`se`]};function gm(e,t){let n=ep(e.items),r=$[t].group,i=n.findLastIndex(e=>$[e.type].group===r);return i<0?null:n[i+1]?.id??null}function _m(){let e=(0,Y.useRef)(null),[t,n]=(0,Y.useState)(null),r=(0,Y.useCallback)(t=>{e.current=t,n(t)},[]),[i,a]=(0,Y.useState)(0);return(0,Y.useLayoutEffect)(()=>{if(!t)return;a(Math.floor(t.getBoundingClientRect().width));let e=0,n=new ResizeObserver(t=>{let n=Math.floor(t[t.length-1].contentRect.width);window.cancelAnimationFrame(e),e=window.requestAnimationFrame(()=>a(e=>e===n?e:n))});return n.observe(t),()=>{window.cancelAnimationFrame(e),n.disconnect()}},[t]),[r,t?i:0,e]}var vm=(e,t)=>(0,X.jsx)(`span`,{ref:t,className:`react-resizable-handle react-resizable-handle-${e} sw-resize sw-resize-${e}`,...e===`se`?{"data-sw-widget-resize":``}:{"data-sw-widget-resize-edge":e},"aria-hidden":`true`});function ym({editing:e,onEditing:t,disabled:n=!1,why:r=null}){return e?null:(0,X.jsxs)(l,{size:`touch`,variant:`secondary`,className:`lg:h-9`,onClick:()=>t(!0),disabled:n,title:n?r:void 0,"data-sw-layout-edit":`off`,children:[(0,X.jsx)(ze,{size:15,"aria-hidden":`true`}),`Edit layout`]})}function bm({hidden:e,onAdd:t,onAdded:n}){let[r,i]=(0,Y.useState)(!1);return(0,X.jsxs)(b,{open:r,onOpenChange:i,history:!1,children:[(0,X.jsx)(F,{asChild:!0,children:(0,X.jsxs)(l,{size:`sm`,variant:`secondary`,"data-sw-layout-add":!0,children:[(0,X.jsx)(oe,{size:14,"aria-hidden":`true`}),` Add widget`,e.length?(0,X.jsxs)(`span`,{className:`tabular -mr-1 ml-0.5 inline-flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-accent px-1 text-[11px] leading-none font-semibold text-accent-fg`,"data-sw-layout-add-count":e.length,children:[e.length,(0,X.jsx)(`span`,{className:`sr-only`,children:` not on the dashboard`})]}):null]})}),(0,X.jsxs)(N,{align:`end`,className:`w-[min(22rem,calc(100vw-2rem))] p-0`,onCloseAutoFocus:e=>{n()&&e.preventDefault()},"data-sw-layout-add-menu":!0,children:[(0,X.jsxs)(`div`,{className:`border-b border-line px-3.5 py-2.5`,children:[(0,X.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:`Add a widget`}),(0,X.jsx)(`p`,{className:`text-xs text-muted`,children:e.length?`Not on your dashboard. Pick one to put it back.`:`Hidden widgets wait here.`})]}),e.length?(0,X.jsx)(`div`,{className:`max-h-[min(60vh,26rem)] overflow-y-auto p-1.5`,children:Object.keys(fm).filter(t=>e.some(e=>$[e].group===t)).map(n=>(0,X.jsxs)(`div`,{className:`pb-1`,children:[(0,X.jsx)(`p`,{className:`px-2 pt-1.5 pb-1 text-[11px] font-semibold tracking-wide text-muted uppercase`,children:fm[n]}),(0,X.jsx)(`ul`,{children:e.filter(e=>$[e].group===n).map(e=>{let[n,r]=mm[e];return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{t(e),i(!1)},className:`group/add flex w-full items-center gap-3 rounded-lg px-2 py-2 text-left outline-none hover:bg-surface-2 focus-visible:bg-surface-2 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent`,"data-sw-layout-add-item":e,children:[(0,X.jsx)(`span`,{className:`inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-line bg-surface-2 text-muted group-hover/add:border-accent/40 group-hover/add:text-accent`,children:(0,X.jsx)(n,{size:17,"aria-hidden":`true`})}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:$[e].title}),(0,X.jsx)(`span`,{className:`line-clamp-2 block text-xs text-muted`,children:r})]}),(0,X.jsx)(oe,{size:16,className:`shrink-0 text-faint group-hover/add:text-accent`,"aria-hidden":`true`})]})},e)})})]},n))}):(0,X.jsxs)(`div`,{className:`flex flex-col items-center px-6 py-7 text-center`,"data-sw-layout-add-none":!0,children:[(0,X.jsx)(`span`,{className:`mb-2.5 inline-flex h-10 w-10 items-center justify-center rounded-full bg-accent/10 text-accent`,children:(0,X.jsx)(m,{size:18,"aria-hidden":`true`})}),(0,X.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:`Every widget is on the dashboard`}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Hide one with its × and it waits here to come back. Charts can also be duplicated.`})]})]})]})}function xm({filter:o,isAdmin:s,board:c,editing:u,onEditing:d}){let{workspaceId:f}=ne(),{get:p,set:h,period:_}=o,v=o.query,[b,x,C]=_m(),w=x?Mf(x):12,T=w===12,[E,O]=(0,Y.useState)({text:``,n:0}),[k,A]=(0,Y.useState)(null),[j,M]=(0,Y.useState)(null),N=(0,Y.useRef)(null),{change:P}=c,F=gi(f,`/usage/budgets`,{enabled:s,keep:!1}),I=F.data?F.data.projects.length:null,L=(0,Y.useMemo)(()=>mp(c.layout,{budgets:I}),[c.layout,I]),te=gi(f,`/usage/summary?${v}`),re=te.data?.current,ie=(0,Y.useMemo)(()=>pp(L,{admin:s}),[L,s]),ae=(0,Y.useCallback)(e=>u&&w<=2?tp(ep(e).map(e=>({...e,w})),w):jp(Ap(e,w),w),[u,w]),R=(0,Y.useMemo)(()=>ae(ie),[ie,ae]),oe=(0,Y.useMemo)(()=>ep(R),[R]),se=`sw-usage-fit:${f}`,[ce,le]=(0,Y.useState)(()=>{try{let e=JSON.parse(window.localStorage.getItem(se)||`{}`);return e&&typeof e==`object`&&!Array.isArray(e)?Object.fromEntries(Object.entries(e).filter(([,e])=>Number.isInteger(e)&&e>0&&e<200)):{}}catch{return{}}}),z=(0,Y.useRef)(ce);z.current=ce;let ue=(0,Y.useMemo)(()=>Pp(R,w,ce),[R,w,ce]),B=R.every(e=>!Np(e)||Number.isInteger(ce[e.id])),[V,de]=(0,Y.useState)(B);(0,Y.useEffect)(()=>{if(V)return;if(B){de(!0);return}let e=window.setTimeout(()=>de(!0),pm);return()=>window.clearTimeout(e)},[V,B]);let fe=(0,Y.useCallback)(e=>{let t=oe.filter(t=>t.type===e.type),n=$[e.type].title;return t.length>1?`${n} ${t.indexOf(t.find(t=>t.id===e.id))+1}`:n},[oe]),H=oe.find(e=>e.type===`time`),U=oe.find(e=>e.type===`breakdown`),pe=wt(_),W=(0,Y.useCallback)(e=>e.id===H?.id?{...e.options,metric:lm(p(`metric`),Ue,e.options.metric),by:lm(p(`by`),[...et,`none`],e.options.by),bucket:lm(p(`bucket`),Ye,e.options.bucket)}:e.id===U?.id?{...e.options,by:lm(p(`bd`),et,e.options.by)}:e.options,[H,U,p]),G=H?W(H):null,he=G&&G.bucket!==`auto`?G.bucket:pe,ge=G?G.metric:`calls`,_e=(0,Y.useCallback)(e=>t=>{let n=t===``?`~`:t;h({[e]:e=>e.length===1&&e[0]===n?[]:[n]},{push:!0})},[h]),ye=(0,Y.useMemo)(()=>({workspaceId:f,filter:o,query:v,isAdmin:s,period:_,bucket:he,autoBucket:pe,metric:ge,toggle:_e}),[f,o,v,s,_,he,pe,ge,_e]),be=(0,Y.useCallback)(e=>O(t=>({text:e,n:t.n+1})),[]),xe=(e,t)=>{let n=ae(pp(e,{admin:s})).find(e=>e.id===t);return n?Lp(n):``},Se=(e,t,{verb:n,key:r=null,unchanged:i=null})=>{let a=L.items.find(t=>t.id===e);if(!a)return;let o=t(L),s=fe(a);o===L||JSON.stringify(o.items)===JSON.stringify(L.items)?i&&be(`${s} ${i}`):(P(o,{key:r}),be(`${s} ${n} ${xe(o,e)}`))},Ce=(e,t)=>{let n={metric:`metric`,by:e.type===`breakdown`?`bd`:`by`,bucket:`bucket`},r=Object.keys(t).map(e=>n[e]).filter(e=>e&&p(e));P(n=>xp(n,e.id,{...W(e),...t}),{key:`options:${e.id}`}),r.length&&(e.id===H?.id||e.id===U?.id)&&h(Object.fromEntries(r.map(e=>[e,null]))),c.preview||A({text:`Saved for this widget`,undo:!0})},we=e=>{let t=fe(e);P(t=>Sp(t,e.id)),A({text:`${t} is hidden`,undo:!0}),be(`${t} hidden. Add widget brings it back.`)},Te=e=>{let{layout:t,id:n}=Dp(L,e,{},{before:gm(L,e)});n&&(P(t),N.current=n,A({text:`${$[e].title} added`,undo:!0}),be(`${$[e].title} added at ${xe(t,n)}`))},Ee=e=>{let{layout:t,id:n}=Op(L,e.id);n&&(P(xp(t,n,W(e))),M(n),A({text:`${$[e.type].title} duplicated`,undo:!0}),be(`${$[e.type].title} duplicated. The copy is at ${xe(t,n)}`))},Oe=(e,t)=>{let n=oe.findIndex(t=>t.id===e.id);Se(e.id,r=>Ip(r,e.id,n+t),{verb:`moved to`,key:`move:${e.id}`,unchanged:t<0?`is already first`:`is already last`})},ke=(e,t,n)=>{let[r,i]=dm[n],a=e.items.find(e=>e.id===t.id),o=e;for(let n=1;n<=12;n+=1){let c=vp(e,t.id,a.w+r*n,a.h+i*n),l=c.items.find(e=>e.id===t.id),u=o.items.find(e=>e.id===t.id);if(l.w===u.w&&l.h===u.h)return o;let d=ae(pp(c,{admin:s})).find(e=>e.id===t.id);if(d&&(d.w!==t.w||d.h!==t.h))return c;o=c}return o},Ae=(e,t)=>{let n=um[e.key];if(!(!n||e.target!==e.currentTarget||e.altKey||e.ctrlKey||e.metaKey)){if(e.preventDefault(),!T){let r=n===`up`||n===`down`;e.shiftKey&&w>2&&r?Se(t.id,e=>ke(e,t,n),{verb:`resized:`,key:`size:${t.id}`,unchanged:n===`up`?`is as small as it goes`:`is as large as it goes`}):e.shiftKey?be(w>2?`Widths are set on a wider screen.`:`Widgets are resized on a wider screen.`):Oe(t,n===`left`||n===`up`?-1:1)}else e.shiftKey?Se(t.id,e=>ke(e,t,n),{verb:`resized:`,key:`size:${t.id}`,unchanged:n===`left`||n===`up`?`is as small as it goes`:`is as large as it goes`}):Se(t.id,e=>bp(e,t.id,n),{verb:`moved to`,key:`move:${t.id}`,unchanged:`cannot move further ${n}`})}},je=(0,Y.useRef)(null),Ne=(e,t)=>{let n=e.base.items.find(t=>t.id===e.id),r=e.wide?t.w:n.w,i=n.h,a=!1;if(t.h!==e.startH){let n=Math.round(t.h/4);(t.h>e.startH?n*4>e.startH:n*4<e.startH)&&(i=n,a=!0)}let o=vp(e.base,e.id,r,i);return!a||!o.items.find(t=>t.id===e.id)?.auto?o:{...o,items:o.items.map(t=>t.id===e.id?{...t,auto:!1}:t)}},Fe=(0,Y.useRef)(null);Fe.current=e=>Pp(ae(pp(e,{admin:s})),w,z.current);let Ie=(0,Y.useMemo)(()=>({type:`vertical`,allowOverlap:!1,compact(e){let t=je.current;if(!t)return e.map(e=>({...e}));let n=e.find(e=>e.i===t.id);t.kind===`resize`&&n?t.next=Ne(t,n):t.kind===`drag`&&t.point&&(t.next=_p(t.base,t.id,rp(t.drawn,t.id,t.point.x,t.point.y)));let r=new Map(Fe.current(t.next||t.base).map(e=>[e.id,e]));return e.map(e=>{let t=r.get(e.i);return t?{...e,x:t.x,y:t.y,w:t.w,h:t.h,moved:!1}:{...e}})}}),[]),Le=e=>{let t=C.current?.getBoundingClientRect(),n=e?.touches?.[0]||e?.changedTouches?.[0]||e;if(!t||!n||typeof n.clientX!=`number`)return null;let r=(x-16*(w-1))/w+16;return{x:(n.clientX-t.left)/r,y:(n.clientY-t.top)/18}},Be=e=>(t,n,r)=>{if(!r)return;let i=ue.find(e=>e.id===r.i);je.current={kind:e,id:r.i,base:L,drawn:ue,wide:T,point:null,next:null,startH:i?.h??r.h}},Ve=(e,t,n,r,i)=>{je.current&&(je.current.point=Le(i)??je.current.point)},He=(e,t,n,r)=>{let i=je.current;if(!i||!n||!r)return;let a=Fe.current(Ne(i,n)).find(e=>e.id===i.id);a&&Object.assign(r,{x:a.x,y:a.y,w:a.w,h:a.h})},We=e=>()=>{let t=je.current;je.current=null,t?.next&&t.next!==t.base&&Se(t.id,()=>t.next,{verb:e})},Ge=(0,Y.useCallback)(()=>{let e=C.current;if(!e||!e.querySelector(`[data-sw-widget]`))return;let t=z.current,n={};for(let r of e.querySelectorAll(`[data-sw-widget]`)){let e=r.getAttribute(`data-sw-widget`),i=R.find(t=>t.id===e);if(!i||!Np(i))continue;let a=r.querySelector(`.sw-widget-body > *`);if(!a)continue;if(a.querySelector(`[data-sw-fit-wait]`)){Number.isInteger(t[e])&&(n[e]=t[e]);continue}let o=a.querySelector(`[data-sw-fit]`);if(!o)continue;let s=o.getBoundingClientRect(),c=a.getBoundingClientRect(),l;if(o.hasAttribute(`data-sw-fit-end`)){let e=getComputedStyle(a);l=s.bottom-c.top+(parseFloat(e.paddingBottom)||0)+(parseFloat(e.borderBottomWidth)||0)}else{let e=Math.max(s.top,...Array.from(o.children,e=>e.getBoundingClientRect().bottom))-s.top+o.scrollTop+(parseFloat(getComputedStyle(o).paddingBottom)||0);l=c.height-o.clientHeight+e}n[e]=Mp(Math.ceil(l-.5))}le(e=>{let t=Object.keys(n);return t.length===Object.keys(e).length&&t.every(t=>e[t]===n[t])?e:n})},[R,C]);(0,Y.useEffect)(()=>{try{window.localStorage.setItem(se,JSON.stringify(ce))}catch{}},[ce,se]),(0,Y.useLayoutEffect)(()=>{Ge()}),(0,Y.useEffect)(()=>{let e=C.current;if(!e)return;let t=0,n=new MutationObserver(()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(Ge)});return n.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>{window.cancelAnimationFrame(t),n.disconnect()}},[Ge,C,x]),(0,Y.useEffect)(()=>{if(!u)return;let e=e=>{e.key===`Escape`&&(document.querySelector(`[data-radix-popper-content-wrapper] :is([role="menu"], [role="dialog"], [role="listbox"])`)||d(!1))};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[u,d]),(0,Y.useEffect)(()=>{if(!j)return;let e=0,t=0,n=()=>{let r=C.current?.querySelector(`[data-sw-widget="${j}"]`);if(r)r.scrollIntoView({block:`nearest`}),r.focus({preventScroll:!0});else if((t+=1)<30){e=window.requestAnimationFrame(n);return}M(null)};return n(),()=>window.cancelAnimationFrame(e)},[j,C]),(0,Y.useEffect)(()=>{if(!k)return;let e=window.setTimeout(()=>A(null),7e3);return()=>window.clearTimeout(e)},[k]);let Ke=c.status===`failed`,qe=(0,Y.useMemo)(()=>ue.map(e=>{let t=$[e.type].size,n=$[e.type].group;return w<=2?{i:e.id,x:e.x,y:e.y,w:e.w,h:e.h}:{i:e.id,x:e.x,y:e.y,w:e.w,h:e.h,minW:T?t.minW:e.w,maxW:T?Math.max(t.maxW,e.w):e.w,minH:Math.min(t.minH*4,e.h),maxH:Math.max(t.maxH*4,e.h),resizeHandles:T?hm[n]:n===`tile`?[]:[`s`]}}),[ue,T,w]),[Je,Xe]=(0,Y.useState)(!1),Ze=()=>{Xe(!1),c.reset(),A({text:c.hasDefault?`Back to the workspace’s layout`:`Back to the default layout`,undo:!0}),be(`The layout is back to the default.`)};if(te.error&&!te.data)return(0,X.jsx)(`div`,{"data-sw-usage-error":!0,children:(0,X.jsx)(De,{error:te.error,onRetry:te.refetch})});if(re&&re.calls===0&&!u&&!c.customised&&!c.hasDefault&&!c.preview)return(0,X.jsx)(K,{"data-sw-usage-empty":!0,children:(0,X.jsx)(g,{icon:me,size:`lg`,title:`No agent turns in this period`,children:o.active.length?`Nothing matches these filters. Clear one, or choose a longer period.`:`When someone chats with a connected agent, or an agent takes a comment, each turn shows up here: who asked, how it ended, and what the agent reported.`})});let Qe=Ep(L,{admin:s}),$e=e=>{let t=ue.find(t=>t.id===e);return t?`${t.x},${t.y},${t.w},${t.h}${Np(t)&&Number.isInteger(ce[e])?`,fit`:``}`:``},tt=u&&w>2,nt=typeof window<`u`&&!!window.matchMedia?.(`(pointer: coarse)`).matches,rt=e=>{let t=$[e.type].group===`tile`,n=tt?20:56;return!(w===2&&t)&&Gp(e.type).length&&(n+=28),$[e.type].many&&w>2&&(n+=28),n+28+22};return(0,X.jsxs)(`div`,{"data-sw-usage-overview":!0,"data-sw-layout-cols":w,"data-sw-layout-mode":u?`edit`:`view`,"data-sw-layout-state":c.status,className:i(u&&`sw-layout-editing`),children:[c.preview?.mine?(0,X.jsxs)(`p`,{className:`mb-3 inline-flex max-w-full items-center gap-2 rounded-full border border-line bg-surface-2 py-1 pr-1 pl-3 text-xs text-fg print:hidden`,role:`status`,"data-sw-layout-view-chip":c.preview.id,children:[(0,X.jsx)(ze,{size:13,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`View: `,(0,X.jsx)(`strong`,{className:`font-semibold`,children:c.preview.name})]}),(0,X.jsx)(l,{size:`xs`,variant:`ghost`,className:`rounded-full`,onClick:()=>h({view:null}),"data-sw-layout-dismiss":!0,children:`Back to my layout`})]}):c.preview?(0,X.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-xl border border-accent/40 bg-accent/8 px-4 py-2.5 text-sm text-fg print:hidden`,role:`status`,"data-sw-layout-preview":c.preview.id,children:[(0,X.jsx)(ze,{size:15,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,X.jsxs)(`p`,{className:`min-w-0 flex-[1_1_16rem]`,children:[`This is the layout of the view `,(0,X.jsx)(`strong`,{className:`font-semibold`,children:c.preview.name}),`. Your own layout is unchanged.`]}),(0,X.jsx)(l,{size:`sm`,variant:`default`,onClick:()=>{c.adopt(),h({view:null}),A({text:`This is your layout now`,undo:!0})},"data-sw-layout-adopt":!0,children:`Use this layout`}),(0,X.jsx)(l,{size:`sm`,variant:`secondary`,onClick:()=>h({view:null}),"data-sw-layout-dismiss":!0,children:`Back to my layout`})]}):null,u?(0,X.jsxs)(`div`,{className:`sticky top-2 z-30 mb-3 flex flex-wrap items-center gap-x-2 gap-y-2 rounded-xl border border-line bg-surface py-2 pr-2 pl-3.5 shadow-pop print:hidden`,role:`toolbar`,"aria-label":`Edit layout`,"data-sw-layout-bar":!0,children:[(0,X.jsxs)(`div`,{className:`mr-auto flex min-w-0 flex-[1_1_16rem] items-center gap-3`,children:[(0,X.jsxs)(`p`,{className:`flex min-w-0 flex-1 items-center gap-2 text-sm text-fg`,id:`sw-layout-help`,children:[(0,X.jsx)(ze,{size:15,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{className:`min-w-0`,children:[(0,X.jsx)(`strong`,{className:`font-semibold`,children:`Editing layout`}),(0,X.jsxs)(`span`,{className:`text-muted`,children:[` · `,T?`Drag a widget to move it, drag an edge to resize.`:w>2?`Drag a widget to move it, its bottom edge to resize.`:`Use the arrows to reorder.`]}),(0,X.jsx)(`span`,{className:`sr-only`,children:` The arrow keys move the widget in focus; with Shift, they resize it.`})]})]}),(0,X.jsx)(`span`,{className:i(`inline-flex shrink-0 items-center justify-end gap-1 text-xs whitespace-nowrap`,Ke?`text-bad`:`text-muted`),role:`status`,"data-sw-layout-status":c.status,children:c.status===`saving`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(S,{}),` Saving`]}):c.status===`saved`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(m,{size:13,"aria-hidden":`true`}),` Saved`]}):Ke?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Me,{size:13,"aria-hidden":`true`}),` Not saved`]}):null})]}),(0,X.jsx)(`span`,{className:`ml-auto flex flex-wrap items-center justify-end gap-x-2 gap-y-2`,children:(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,X.jsxs)(l,{size:`sm`,variant:`secondary`,onClick:c.undo,disabled:!c.canUndo,"data-sw-layout-undo":!0,children:[(0,X.jsx)(wn,{size:14,"aria-hidden":`true`}),` Undo`]}),(0,X.jsx)(bm,{hidden:Qe,onAdd:Te,onAdded:()=>N.current?(M(N.current),N.current=null,!0):!1}),c.canSetDefault?(0,X.jsxs)(n,{children:[(0,X.jsx)(D,{asChild:!0,children:(0,X.jsxs)(l,{size:`sm`,variant:`secondary`,"data-sw-layout-reset-menu":!0,children:[(0,X.jsx)(Re,{size:14,"aria-hidden":`true`}),` Reset`]})}),(0,X.jsxs)(ee,{align:`end`,className:`w-72`,children:[(0,X.jsxs)(a,{disabled:!c.customised,onSelect:()=>Xe(!0),"data-sw-layout-reset":!0,children:[(0,X.jsx)(Re,{size:14,"aria-hidden":`true`}),` `,c.hasDefault?`Reset to the workspace layout`:`Reset to default`]}),(0,X.jsx)(e,{}),(0,X.jsx)(r,{children:`For the workspace`}),(0,X.jsxs)(a,{onSelect:async()=>{try{await c.setDefault(),A({text:`Everyone without a layout of their own now starts from this one`})}catch(e){A({text:`The default was not set: ${e.message}`,bad:!0})}},"data-sw-layout-set-default":!0,children:[(0,X.jsx)(ze,{size:14,"aria-hidden":`true`}),` Set as default for everyone`]}),c.hasDefault?(0,X.jsxs)(a,{onSelect:async()=>{try{await c.clearDefault(),A({text:`The workspace has no layout of its own any more`})}catch(e){A({text:`The default was not removed: ${e.message}`,bad:!0})}},"data-sw-layout-clear-default":!0,children:[(0,X.jsx)(t,{size:14,"aria-hidden":`true`}),` Remove the workspace default`]}):null]})]}):(0,X.jsxs)(l,{size:`sm`,variant:`secondary`,disabled:!c.customised,title:c.customised?void 0:`This is already the default layout`,onClick:()=>Xe(!0),"data-sw-layout-reset":!0,children:[(0,X.jsx)(Re,{size:14,"aria-hidden":`true`}),` Reset`]}),(0,X.jsx)(l,{size:`sm`,variant:`default`,className:`min-w-16`,onClick:()=>d(!1),"data-sw-layout-done":!0,children:`Done`})]})})]}):null,(0,X.jsx)(ve,{open:Je,onClose:()=>Xe(!1),title:`Reset the layout?`,confirmLabel:`Reset`,onConfirm:Ze,children:(0,X.jsx)(`p`,{className:`text-sm text-muted`,children:c.hasDefault?`Your dashboard goes back to the layout your workspace starts everyone from. Undo brings yours back.`:`Your dashboard goes back to the layout everyone starts from. Undo brings yours back.`})}),(0,X.jsxs)(`div`,{ref:b,className:`sw-layout`,"data-sw-layout":!0,"data-sw-layout-ready":V?`true`:`false`,"aria-busy":!V||void 0,"data-sw-usage-tiles":!0,"data-sw-usage-top":!0,children:[x?(0,X.jsx)(Cf,{layout:qe,width:x,gridConfig:{cols:w,rowHeight:2,margin:[16,16],containerPadding:[0,0]},dragConfig:{enabled:tt,...nt?{handle:`[data-sw-widget-handle]`}:{},cancel:`button, a, input, [role="menu"], .react-resizable-handle`,threshold:4},resizeConfig:{enabled:u&&w>2,handles:[`s`,`e`,`se`],handleComponent:vm},compactor:Ie,onDragStart:Be(`drag`),onDrag:Ve,onDragStop:We(`moved to`),onResizeStart:Be(`resize`),onResize:He,onResizeStop:We(`resized:`),children:oe.map((e,n)=>{let r=fe(e),a=W(e),o=(0,X.jsx)(Kp,{item:e,options:a,onChange:t=>Ce(e,t),title:r});return(0,X.jsxs)(`div`,{className:i(`sw-widget`,tt&&!nt&&`sw-widget-drag`),style:{"--sw-w":e.w,...u?{"--sw-tools":`${rt(e)}px`}:{}},"data-sw-widget":e.id,"data-sw-widget-type":e.type,"data-sw-widget-place":`${e.x},${e.y},${e.w},${e.h}`,"data-sw-widget-drawn":$e(e.id),...u?{tabIndex:0,role:`group`,"aria-label":`${r}: ${Lp(e)}`,"aria-describedby":`sw-layout-help`,onKeyDown:t=>Ae(t,e)}:{},children:[(0,X.jsx)(`div`,{className:`sw-widget-body h-full min-w-0`,inert:u,children:(0,X.jsx)(cm,{item:e,options:a,setOptions:t=>Ce(e,t),ctx:ye,menu:!u&&o})}),u?(0,X.jsxs)(`div`,{className:`sw-widget-tools`,"data-sw-widget-bar":!0,children:[tt?(0,X.jsx)(`span`,{className:`sw-widget-grip`,"data-sw-widget-handle":!0,title:`Drag to move`,"aria-hidden":`true`,children:(0,X.jsx)(tn,{size:14})}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(y,{label:`Move ${r} up`,size:`icon-xs`,disabled:n===0,onClick:()=>Oe(e,-1),"data-sw-widget-up":!0,children:(0,X.jsx)(kt,{size:14,"aria-hidden":`true`})}),(0,X.jsx)(y,{label:`Move ${r} down`,size:`icon-xs`,disabled:n===oe.length-1,onClick:()=>Oe(e,1),"data-sw-widget-down":!0,children:(0,X.jsx)(Dt,{size:14,"aria-hidden":`true`})})]}),o,$[e.type].many&&w>2?(0,X.jsx)(y,{label:Tp(L,e.type)?`Duplicate ${r}`:`No more copies of ${$[e.type].title} fit`,size:`icon-xs`,disabled:!Tp(L,e.type),onClick:()=>Ee(e),"data-sw-widget-duplicate":!0,children:(0,X.jsx)(Pe,{size:14,"aria-hidden":`true`})}):null,(0,X.jsx)(y,{label:`Hide ${r}`,size:`icon-xs`,onClick:()=>we(e),"data-sw-widget-hide":!0,children:(0,X.jsx)(t,{size:15,"aria-hidden":`true`})})]}):null]},e.id)})}):null,x&&!oe.length?(0,X.jsx)(K,{"data-sw-layout-empty":!0,children:(0,X.jsx)(g,{icon:ze,title:`Every widget is hidden`,children:u?`Add one back with Add widget, or reset the layout.`:`Press Edit layout to add widgets back.`})}):null]}),(0,X.jsx)(`p`,{className:`sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,"data-sw-layout-live":!0,children:(0,X.jsx)(`span`,{children:E.text},E.n)}),k||Ke?(0,X.jsx)(`div`,{className:`pointer-events-none fixed inset-x-0 bottom-16 z-[70] flex justify-center px-4 print:hidden`,children:(0,X.jsxs)(`div`,{className:i(`pointer-events-auto flex max-w-lg items-center gap-3 rounded-lg border px-4 py-2 text-sm shadow-pop`,Ke||k?.bad?`border-bad/40 bg-surface text-bad`:`border-line bg-fg text-surface`),role:Ke?`alert`:`status`,"data-sw-layout-toast":Ke?`failed`:`ok`,children:[(0,X.jsx)(`span`,{children:Ke?`The layout could not be saved${c.failure?.message?` (${c.failure.message})`:``}. Your change is kept on this page until you leave it.`:k.text}),Ke?(0,X.jsx)(l,{size:`xs`,variant:`secondary`,onClick:c.retry,"data-sw-layout-retry":!0,children:`Try again`}):k.undo&&c.canUndo?(0,X.jsx)(l,{size:`xs`,variant:`inverse`,className:`underline underline-offset-2`,onClick:()=>{c.undo(),A({text:`Undone`}),be(`Undone.`)},"data-sw-layout-toast-undo":!0,children:`Undo`}):null]})}):null]})}var Sm=350;function Cm(e,{viewId:t=null}={}){let n=En(),r=ke(e,`/usage/layout`),i=ti({queryKey:[r],queryFn:()=>U.get(r),staleTime:1/0}),a=t?ke(e,`/views/${encodeURIComponent(t)}/layout`):null,o=ti({queryKey:[a],queryFn:()=>U.get(a),enabled:!!a,staleTime:1/0,retry:!1}),[s,c]=(0,Y.useState)(void 0),[l,u]=(0,Y.useState)(`idle`),[d,f]=(0,Y.useState)(null),p=(0,Y.useRef)([]),[m,h]=(0,Y.useState)(0),g=e=>{p.current=[...p.current.slice(-19),e??null],h(p.current.length)},[_,v]=(0,Y.useState)(null),y=(0,Y.useMemo)(()=>lp(i.data?.default)||dp(),[i.data]);(0,Y.useEffect)(()=>{if(!i.data||s!==void 0)return;let e=lp(i.data.layout);b.current.saved=e,c(e)},[i.data,s]),(0,Y.useEffect)(()=>v(null),[t]);let b=(0,Y.useRef)({own:s,saved:void 0,timer:null,busy:!1,again:!1,lastKey:null,lastAt:0});b.current.own=s;let x=(0,Y.useCallback)(e=>n.setQueryData([r],t=>t&&{...t,layout:e}),[n,r]),S=(0,Y.useCallback)(async()=>{let e=b.current;if(e.busy){e.again=!0;return}e.busy=!0;let t=e.own;u(`saving`);try{t===null?await U.delete(r):await U.put(r,{layout:t}),e.saved=t,x(t),f(null),u(`saved`)}catch(e){f(e),u(`failed`)}finally{e.busy=!1,e.again&&(e.again=!1,S())}},[r,x]),C=(0,Y.useCallback)(()=>{let e=b.current;window.clearTimeout(e.timer),e.timer=window.setTimeout(S,Sm)},[S]);(0,Y.useEffect)(()=>{let e=b.current;return()=>{window.clearTimeout(e.timer),e.own!==void 0&&e.saved!==void 0&&!fp(e.own,e.saved)&&S()}},[S]);let w=(0,Y.useMemo)(()=>o.data?.view?{id:o.data.view.id,name:o.data.view.name,mine:!!o.data.view.mine}:null,[o.data]),T=(0,Y.useMemo)(()=>o.data?.view?lp(o.data.view.layout):null,[o.data]),E=w&&T?_??T:s??y,D=(0,Y.useCallback)((e,{key:t=null}={})=>{if(w&&T){v(t=>typeof e==`function`?e(t??T):e);return}let n=b.current,r=n.own,i=r??y,a=typeof e==`function`?e(i):e;if(a===null?r==null:fp(a,i))return;let o=Date.now(),s=t!==null&&t===n.lastKey&&o-n.lastAt<1500;n.lastKey=t,n.lastAt=o,s||g(r),n.own=a,c(a),u(`saving`),C()},[y,w,T,C]),O=(0,Y.useCallback)(()=>{let e=b.current;if(!p.current.length)return;let t=p.current[p.current.length-1];p.current=p.current.slice(0,-1),h(p.current.length),e.own=t,e.lastKey=null,c(t),u(`saving`),C()},[C]),k=(0,Y.useCallback)(()=>D(null),[D]),A=(0,Y.useCallback)(()=>S(),[S]),j=(0,Y.useCallback)(()=>{let e=_??T;if(!e)return;let t=b.current;g(t.own),t.own=e,t.lastKey=null,c(e),u(`saving`),C()},[_,T,C]),M=(0,Y.useCallback)(async()=>{let e=await U.put(`${r}/default`,{layout:b.current.own??y});n.setQueryData([r],t=>t&&{...t,default:e.default})},[r,n,y]),N=(0,Y.useCallback)(async()=>{await U.delete(`${r}/default`),n.setQueryData([r],e=>e&&{...e,default:null})},[r,n]);return{ready:s!==void 0&&(!a||!o.isLoading),error:i.error,refetch:i.refetch,layout:E,customised:!!s,hasDefault:!!i.data?.default,canSetDefault:!!i.data?.canSetDefault,preview:w&&T?w:null,previewMissing:!!(a&&o.error),status:l,failure:d,canUndo:m>0&&!(w&&T),change:D,undo:O,reset:k,retry:A,adopt:j,setDefault:M,clearDefault:N}}var wm=`inline-flex items-center gap-1 font-medium text-accent underline-offset-2 hover:underline`;function Tm({id:e,onClose:t}){let{workspaceId:n,isAdmin:r,data:i}=ne(),a=gi(n,`/usage/rows/${encodeURIComponent(e)}`,{keep:!1}),o=ht(),s=a.data?.row,c=(e,t=We,n)=>e==null?(0,X.jsx)(yt,{what:n}):t(e),l=s?.tools?Object.entries(s.tools).sort((e,t)=>t[1]-e[1]):[],u=Math.max(1,...l.map(([,e])=>e)),d=s&&r&&s.agent?.exists?`/w/${n}/activity?agent=${s.agent.id}&range=custom&from=${s.startedAt.slice(0,10)}&to=${(s.endedAt||s.startedAt).slice(0,10)}`:null;return(0,X.jsx)(gt,{open:!0,onClose:t,title:s?`${Ze[s.kind]||s.kind} by ${s.agent?.name||`no agent`}`:`Agent turn`,description:s?Ct(s.startedAt):null,testId:`turn`,children:a.isLoading?(0,X.jsxs)(`div`,{className:`space-y-3 p-5`,role:`status`,children:[(0,X.jsx)(`span`,{className:`sr-only`,children:`Loading the turn`}),[60,80,50,70,40].map((e,t)=>(0,X.jsx)(k,{className:`h-4`,style:{width:`${e}%`}},t))]}):a.error?(0,X.jsx)(`div`,{className:`p-5`,children:a.error.status===404?(0,X.jsx)(`p`,{className:`text-sm text-muted`,"data-sw-turn-missing":!0,children:`This turn is not there, or it is not yours to see. Usage shows a member their own turns and the agents they connected.`}):(0,X.jsx)(De,{error:a.error,onRetry:a.refetch})}):(0,X.jsxs)(`div`,{"data-sw-turn":s.id,children:[(0,X.jsxs)(dt,{title:`What happened`,children:[(0,X.jsxs)(q,{label:`Outcome`,children:[(0,X.jsx)(it,{outcome:s.outcome}),(0,X.jsxs)(`span`,{className:`ml-1.5 text-xs text-muted`,children:[`(`,Je[s.outcomeGroup],`)`]})]}),(0,X.jsx)(q,{label:`Started`,children:Ct(s.startedAt)}),(0,X.jsx)(q,{label:`Ended`,children:s.endedAt?Ct(s.endedAt):(0,X.jsx)(`span`,{className:`text-muted`,children:`Still running`})}),(0,X.jsx)(q,{label:`Duration`,children:s.durationMs===null?(0,X.jsx)(`span`,{className:`text-muted`,children:`Still running`}):tt(s.durationMs)}),(0,X.jsx)(q,{label:`Agent's own time`,children:c(s.agentMs,tt,`The agent’s own time`)})]}),(0,X.jsxs)(dt,{title:`Who and where`,children:[(0,X.jsx)(q,{label:`Asked by`,children:s.person?s.person.member&&(r||s.person.id===i.me.userId)?(0,X.jsx)(V,{to:`/w/${n}/activity/${s.person.id}`,className:wm,children:s.person.name}):s.person.name:(0,X.jsx)(`span`,{className:`text-muted`,children:`Nobody (the agent took it on its own)`})}),(0,X.jsx)(q,{label:`Agent`,children:s.agent?r&&s.agent.exists?(0,X.jsx)(V,{to:`/w/${n}/activity/${s.agent.id}`,className:wm,children:s.agent.name}):s.agent.name:(0,X.jsx)(`span`,{className:`text-muted`,children:`None`})}),(0,X.jsx)(q,{label:`Machine`,children:s.agent?.machine||(0,X.jsx)(`span`,{className:`text-muted`,children:`Not known`})}),(0,X.jsx)(q,{label:`Project`,children:s.project.name}),(0,X.jsx)(q,{label:`Board`,children:s.boardId||(0,X.jsx)(`span`,{className:`text-muted`,children:`None`})}),(0,X.jsx)(q,{label:`Thread`,children:s.thread?s.thread.kind===`comment`?`Comment #${s.commentNumber}`:s.thread.kind===`chat`?s.thread.id?`Your private chat`:`A private chat (only its starter reads it)`:`The board’s chat`:s.commentNumber?`Comment #${s.commentNumber}`:`None`}),s.link?(0,X.jsx)(q,{label:`Open`,children:(0,X.jsxs)(`a`,{href:s.link.url,className:wm,"data-sw-turn-link":!0,children:[s.link.label,` `,(0,X.jsx)(B,{size:13,"aria-hidden":`true`})]})}):null]}),(0,X.jsxs)(dt,{title:`As the agent reported`,children:[(0,X.jsx)(q,{label:`Model`,children:s.model||(0,X.jsx)(yt,{what:`Model`})}),(0,X.jsx)(q,{label:`Effort`,children:s.effort||(0,X.jsx)(yt,{what:`Effort`})}),(0,X.jsx)(q,{label:`Input tokens`,children:c(s.inputTokens,We,`Input tokens`)}),(0,X.jsx)(q,{label:`Output tokens`,children:c(s.outputTokens,We,`Output tokens`)}),(0,X.jsx)(q,{label:`Cached tokens`,children:c(s.cachedTokens,We,`Cached tokens`)}),(0,X.jsx)(q,{label:`Context used`,children:s.contextUsed===null?(0,X.jsx)(yt,{what:`Context`}):`${J(s.contextUsed,{exact:!0})}${s.contextSize?` of ${J(s.contextSize,{exact:!0})} (${nt(s.contextUsed,s.contextSize)})`:``}`}),(0,X.jsx)(q,{label:`Cost`,children:s.costMicros===null?(0,X.jsx)(yt,{what:`Cost`}):at(s.costMicros)})]}),(0,X.jsx)(dt,{title:`Steps${s.steps?` (${s.steps})`:``}`,children:l.length?(0,X.jsx)(`div`,{className:`col-span-2 space-y-1`,"data-sw-turn-tools":!0,children:l.map(([e,t])=>(0,X.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,7rem)_minmax(0,1fr)_2.5rem] items-center gap-2 text-xs`,children:[(0,X.jsx)(`span`,{className:`truncate text-fg`,children:e}),(0,X.jsx)(`span`,{className:`block h-2.5`,children:(0,X.jsx)(`span`,{className:`block h-full rounded-r`,style:{width:`${t/u*100}%`,background:o.series[0]}})}),(0,X.jsx)(`span`,{className:`tabular text-right text-fg`,children:t})]},e))}):(0,X.jsx)(`p`,{className:`col-span-2 text-sm text-muted`,children:s.steps===0?`No tool call.`:`No tool call was reported.`})}),(0,X.jsx)(dt,{title:`Approvals`,children:s.approvals.asked?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(q,{label:`Asked`,children:s.approvals.asked}),(0,X.jsxs)(q,{label:`Allowed`,children:[s.approvals.allowed??0,s.approvals.auto?(0,X.jsxs)(`span`,{className:`text-muted`,children:[` (`,s.approvals.auto,` without asking)`]}):null]}),(0,X.jsx)(q,{label:`Denied`,children:s.approvals.denied??0}),s.approvals.by.length?(0,X.jsx)(q,{label:`Answered by`,children:(0,X.jsx)(`ul`,{children:s.approvals.by.map(e=>(0,X.jsxs)(`li`,{children:[e.name,`: `,e.allowed,` allowed`,e.denied?`, ${e.denied} denied`:``]},e.userId))})}):null]}):(0,X.jsx)(`p`,{className:`col-span-2 text-sm text-muted`,children:s.approvals.asked===0?`It asked for none.`:`This kind of turn asks for none.`})}),(0,X.jsxs)(`section`,{className:`space-y-2 px-5 py-3.5`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold tracking-wide text-muted uppercase`,children:`Turn id`}),(0,X.jsx)(Ae,{value:s.id,label:`Copy`,testId:`turn-id`}),d?(0,X.jsx)(`p`,{className:`pt-1 text-sm`,children:(0,X.jsxs)(V,{to:d,className:wm,"data-sw-turn-activity":!0,children:[`Activity around this turn `,(0,X.jsx)(B,{size:13,"aria-hidden":`true`})]})}):null]})]})})}var Em=(e,t,n)=>t.includes(e)?e:n;function Dm(){let{workspaceId:e,data:t,isAdmin:r}=ne(),i=mi(),{get:o,set:s,query:c,period:u,search:d}=i,f=Em(o(`tab`),[`overview`,`turns`],`overview`),p=gi(e,`/usage/options`,{keep:!1}),m=ue(),h=H(),g=p.data?.scope===`own`,v=Cm(e,{viewId:o(`view`)||null}),[y,b]=(0,Y.useState)(!1),x=y&&f===`overview`&&!v.preview;(0,Y.useEffect)(()=>{v.previewMissing&&(s({view:null}),h(`That view no longer carries a layout. This is your own.`,`bad`))},[v.previewMissing,s,h]);let C=t=>m.run(async()=>{let n=await z(`GET`,ke(e,`/usage/export?${c}&format=${t}`),void 0,`usage.${t}`);h(`Saved ${n.name}`)});return(0,X.jsxs)(`div`,{"data-sw-usage":f,"data-sw-usage-report":!0,children:[(0,X.jsx)(G,{title:`Usage`,description:g?`Your own agent turns, and every turn of an agent you connected. Numbers are what each agent reported.`:`Every agent turn in this workspace: who asked, which agent, how it ended, and the numbers each agent reported.`,actions:(0,X.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 print:hidden`,children:[f===`overview`?(0,X.jsx)(ym,{editing:x,onEditing:b,disabled:!v.ready||!!v.preview,why:v.preview?v.preview.mine?`Choose "Back to my layout" first`:`Choose "Use this layout" or "Back to my layout" first`:null}):null,(0,X.jsxs)(l,{size:`touch`,variant:`secondary`,className:`lg:h-9`,onClick:()=>window.print(),"data-sw-usage-print":!0,children:[(0,X.jsx)(mn,{size:15,"aria-hidden":`true`}),` Print`]}),(0,X.jsxs)(n,{children:[(0,X.jsx)(D,{asChild:!0,children:(0,X.jsxs)(l,{size:`touch`,variant:`secondary`,className:`lg:h-9`,disabled:m.busy,"data-sw-usage-export":!0,children:[m.busy?(0,X.jsx)(S,{}):(0,X.jsx)(Le,{size:15,"aria-hidden":`true`}),` Export`]})}),(0,X.jsxs)(ee,{children:[(0,X.jsx)(a,{onSelect:()=>C(`csv`),"data-sw-usage-export-csv":!0,children:`The turns of this filter, as CSV`}),(0,X.jsx)(a,{onSelect:()=>C(`json`),"data-sw-usage-export-json":!0,children:`The turns of this filter, as JSON`})]})]})]})}),(0,X.jsx)(bt,{testId:`usage`,children:`This is a demo with made-up numbers: about sixty days of a pretend team's agent turns. Ask the agent on the board, or run a fix, and your turn is added here. Exports are made in this browser; Reset puts everything back.`}),_&&f===`overview`&&!x&&!v.preview?(0,X.jsxs)(`p`,{className:`mb-4 flex flex-wrap items-center gap-x-2 gap-y-1.5 rounded-md border border-accent/40 bg-accent/8 px-3 py-2 text-xs text-fg print:hidden`,"data-sw-demo-try":`layout`,children:[(0,X.jsx)(ze,{size:14,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-[1_1_14rem]`,children:[(0,X.jsx)(`strong`,{className:`font-semibold`,children:`Try this:`}),` press Edit layout, then drag a chart to a new place, resize it from an edge, or hide a tile and add it back. Reset puts it back.`]})]}):null,m.error?(0,X.jsx)(`p`,{className:`mb-3 text-sm text-bad`,role:`alert`,children:m.error}):null,(0,X.jsxs)(`p`,{className:`mb-3 hidden text-sm text-fg print:block`,children:[t.workspace.name,` · `,u.label,` (`,Ge(u.from),` to `,Ge(new Date(u.to.getTime()-1)),`) · printed`,` `,Ge(new Date),i.active.length?` · filtered by ${i.active.join(`, `)}`:``]}),(0,X.jsx)(ki,{filter:i,options:p.data?.options,children:(0,X.jsx)(Ai,{workspaceId:e,page:`usage`,search:d,layout:f===`overview`?v.layout:null,onOpen:e=>{b(!1),li(new URLSearchParams(e),{push:!0})}})}),(0,X.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-2 print:hidden`,children:[(0,X.jsx)(j,{label:`View`,value:f,onChange:e=>s({tab:e===`overview`?null:e,row:null},{push:!0}),options:[{id:`overview`,label:`Overview`},{id:`turns`,label:`Turns`}]}),p.data?(0,X.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Usage records are kept for `,p.data.retentionDays,` days.`,` `,(0,X.jsx)(V,{to:`/w/${e}/activity`,className:`font-medium text-accent underline-offset-2 hover:underline`,children:r?`People’s activity`:`Your activity`})]}):null]}),f===`turns`?(0,X.jsx)(Lm,{filter:i}):v.error&&!v.ready?(0,X.jsx)(De,{error:v.error,onRetry:v.refetch}):v.ready?(0,X.jsx)(xm,{filter:i,isAdmin:r,board:v,editing:x,onEditing:b}):(0,X.jsxs)(`p`,{className:`flex items-center justify-center gap-2 px-4 py-16 text-sm text-muted`,role:`status`,"data-sw-layout-loading":!0,children:[(0,X.jsx)(S,{}),` Loading the dashboard`]}),o(`row`)?(0,X.jsx)(Tm,{id:o(`row`),onClose:()=>s({row:null})}):null]})}function Om({filter:e,extraQuery:t=``}){let{workspaceId:n}=ne(),{get:r,set:i,list:a,period:o}=e,s=`${e.query}${t}`,c=Em(r(`metric`),Ue,`calls`),l=Em(r(`by`),[...et,`none`],`kind`),u=Em(r(`bucket`),Ye,wt(o)),d=Em(r(`bd`),et,`project`),f=gi(n,`/usage/summary?${s}`),p=gi(n,`/usage/series?${s}&bucket=${u}&groupBy=${l}&metric=${c}`),m=gi(n,`/usage/series?${s}&bucket=${u}&groupBy=none&metric=calls`),h=gi(n,`/usage/breakdown?${s}&groupBy=${d}`),g=(0,Y.useCallback)(e=>t=>{let n=t===``?`~`:t;i({[e]:e=>e.length===1&&e[0]===n?[]:[n]},{push:!0})},[i]),_=(e,t)=>i({range:`custom`,from:lt(e,u).from,to:lt(t,u).to},{push:!0}),v=f.data?.current,y=f.data?.previous,b=f.isLoading;if(f.error&&!f.data)return(0,X.jsx)(`div`,{"data-sw-usage-error":!0,children:(0,X.jsx)(De,{error:f.error,onRetry:f.refetch})});let x=o.compare,S=e=>v&&v.calls?v.reported[e]===v.calls?null:`${J(v.reported[e])} of ${J(v.calls)} turns reported`:null;return(0,X.jsxs)(`div`,{className:`space-y-4`,"data-sw-usage-overview":!0,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,"data-sw-usage-tiles":!0,children:[(0,X.jsx)(_t,{testId:`calls`,compare:x,label:`Turns`,loading:b,value:J(v?.calls??0),current:v?.calls,previous:y?.calls,trend:m.data?m.data.buckets.map(e=>m.data.points.find(t=>t.bucket===e)?.calls??0):null}),(0,X.jsx)(_t,{testId:`tokens`,compare:x,label:`Tokens`,loading:b,value:v?.tokens===null?`Not reported`:J(v?.tokens),current:v?.tokens,previous:y?.tokens,hint:v?.tokens===null?null:S(`tokens`)??`${J(v?.input)} in · ${J(v?.output)} out`,note:v?.tokens===null?`No agent reported tokens`:void 0}),(0,X.jsx)(_t,{testId:`duration`,compare:x,label:`Agent time`,loading:b,value:tt(v?.duration),current:v?.duration,previous:y?.duration,hint:v?.latency?.turns?`Median ${tt(v.latency.p50)} · 95th ${tt(v.latency.p95)}`:null}),(0,X.jsx)(_t,{testId:`cost`,compare:x,label:`Reported cost`,loading:b,value:v?.cost===null?`Not reported`:at(v?.cost),current:v?.cost,previous:y?.cost,hint:v?.cost===null?null:S(`cost`),note:v?.cost===null?`No agent reported a cost`:void 0})]}),(0,X.jsx)(vt,{data:p.data,metric:c,bucket:u,dimension:p.data?.groupBy??l,state:p,onPick:l===`none`?null:g(l),pressed:l===`none`?[]:a(l).map(e=>e===`~`?``:e),onRange:_,controls:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(zp,{label:`Measure`,testId:`metric`,value:c,onChange:e=>i({metric:e===`calls`?null:e}),options:Ue.map(e=>[e,$e[e]])}),(0,X.jsx)(zp,{label:`Split by`,testId:`by`,value:l,onChange:e=>i({by:e}),options:[...et.map(e=>[e,`By ${Xe[e].toLowerCase()}`]),[`none`,`No split`]]}),(0,X.jsx)(j,{label:`Bucket`,value:u,onChange:e=>i({bucket:e}),options:Ye.map(e=>({id:e,label:e[0].toUpperCase()+e.slice(1)}))})]})}),(0,X.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,X.jsx)(xt,{groups:h.data?.groups,metric:c,dimension:d,title:Xe[d],state:h,onPick:g(d),pressed:a(d).map(e=>e===`~`?``:e),controls:(0,X.jsx)(zp,{label:`Break down by`,testId:`bd`,value:d,onChange:e=>i({bd:e}),options:et.map(e=>[e,`By ${Xe[e].toLowerCase()}`])})}),(0,X.jsx)(ct,{data:m.data,bucket:u,state:m,onPick:g(`outcome`),pressed:a(`outcome`)})]})]})}var km=(0,X.jsx)(`span`,{className:`text-faint`,children:`–`}),Am=[{id:`started`,header:`When`,width:146,sort:`started`,always:!0,cell:e=>Ct(e.startedAt)},{id:`kind`,header:`Kind`,width:128,cell:e=>Ze[e.kind]||e.kind},{id:`agent`,header:`Agent`,width:146,cell:e=>e.agent?e.agent.name:km},{id:`machine`,header:`Machine`,width:130,cell:e=>e.agent?.machine||km},{id:`project`,header:`Project`,width:128,cell:e=>e.project.name},{id:`person`,header:`Asked by`,width:104,cell:e=>e.person?.name||(0,X.jsx)(`span`,{className:`text-muted`,children:`Nobody`})},{id:`outcome`,header:`Outcome`,width:138,cell:e=>(0,X.jsx)(it,{outcome:e.outcome})},{id:`model`,header:`Model`,width:140,cell:e=>e.model||(0,X.jsx)(yt,{what:`Model`})},{id:`effort`,header:`Effort`,width:84,cell:e=>e.effort||km},{id:`duration`,header:`Duration`,width:104,align:`right`,sort:`duration`,cell:e=>e.durationMs===null?(0,X.jsx)(`span`,{className:`text-muted`,children:`Running`}):tt(e.durationMs),subtotal:e=>tt(e.duration)},{id:`tokens`,header:`Tokens`,title:`Tokens (input plus output)`,width:88,align:`right`,sort:`tokens`,cell:e=>ot(e.totalTokens,e=>J(e,{exact:!0}),`Tokens`),subtotal:e=>e.tokens===null?(0,X.jsx)(yt,{what:`Tokens`}):J(e.tokens)},{id:`input`,header:`Input`,title:`Input tokens`,width:96,align:`right`,sort:`input`,cell:e=>ot(e.inputTokens,e=>J(e,{exact:!0}),`Input tokens`),subtotal:e=>e.input===null?``:J(e.input)},{id:`output`,header:`Output`,title:`Output tokens`,width:96,align:`right`,sort:`output`,cell:e=>ot(e.outputTokens,e=>J(e,{exact:!0}),`Output tokens`),subtotal:e=>e.output===null?``:J(e.output)},{id:`cached`,header:`Cached`,title:`Cached tokens`,width:96,align:`right`,sort:`cached`,cell:e=>ot(e.cachedTokens,e=>J(e,{exact:!0}),`Cached tokens`),subtotal:e=>e.cached===null?``:J(e.cached)},{id:`cost`,header:`Cost`,title:`Reported cost`,width:92,align:`right`,sort:`cost`,cell:e=>ot(e.costMicros,at,`Cost`),subtotal:e=>e.cost===null?(0,X.jsx)(yt,{what:`Cost`}):at(e.cost)},{id:`steps`,header:`Steps`,title:`Steps (tool calls)`,width:84,align:`right`,sort:`steps`,cell:e=>e.steps===null?km:J(e.steps),subtotal:e=>e.steps===null?``:J(e.steps)},{id:`approvals`,header:`Approvals`,width:150,cell:e=>e.approvals.asked?(0,X.jsxs)(`span`,{children:[e.approvals.allowed,` allowed`,e.approvals.denied?`, ${e.approvals.denied} denied`:``]}):km},{id:`where`,header:`Where`,width:150,cell:e=>e.commentNumber?`${e.boardId} #${e.commentNumber}`:e.boardId||km},{id:`id`,header:`Turn id`,width:232,cell:e=>(0,X.jsx)(`code`,{className:`font-mono text-[11px] text-muted`,children:e.id})}],jm=[`before`,`change`],Mm=[...Am,{id:`before`,header:`Before`,title:`Turns in the period before`,width:116,align:`right`,cell:()=>``,subtotal:e=>e.before?J(e.before.calls):``},{id:`change`,header:`Change`,title:`Change in turns against the period before`,width:96,align:`right`,cell:()=>``,subtotal:e=>{if(!e.before)return``;let t=rt(e.calls,e.before.calls);return t?t.text:e.before.calls?``:`New`}}],Nm=(e,t)=>{if(!t)return e;let n=e.order.filter(e=>!jm.includes(e)),r=e.hidden.filter(e=>!jm.includes(e)),i=n.findIndex((e,t)=>t>0&&!r.includes(e)&&Am.find(t=>t.id===e)?.subtotal);return n.splice(i<0?n.length-r.length:i,0,...jm),{...e,order:n,hidden:r}},Pm={shown:[`started`,`kind`,`agent`,`project`,`person`,`outcome`,`duration`,`tokens`,`cost`],pinned:[`started`]},Fm=100;function Im({row:e}){return(0,X.jsxs)(`span`,{className:`block`,"data-sw-turn-card":!0,children:[(0,X.jsxs)(`span`,{className:`flex items-baseline justify-between gap-2`,children:[(0,X.jsxs)(`span`,{className:`truncate text-sm font-medium text-fg`,children:[Ze[e.kind]||e.kind,` · `,e.agent?.name||`No agent`]}),(0,X.jsx)(`span`,{className:`tabular shrink-0 text-xs text-muted`,children:e.durationMs===null?`Running`:tt(e.durationMs)})]}),(0,X.jsxs)(`span`,{className:`mt-0.5 flex items-center justify-between gap-2 text-xs text-muted`,children:[(0,X.jsxs)(`span`,{className:`truncate`,children:[e.project.name,` · `,e.person?.name||`Nobody`]}),(0,X.jsx)(`span`,{className:`tabular shrink-0`,children:e.durationMs===null?``:e.totalTokens===null?`Tokens not reported`:`${J(e.totalTokens)} tokens`})]}),(0,X.jsxs)(`span`,{className:`mt-1 flex items-center justify-between gap-2 text-xs text-fg`,children:[(0,X.jsx)(it,{outcome:e.outcome}),(0,X.jsx)(`span`,{className:`shrink-0 text-muted`,children:Ct(e.startedAt)})]})]})}function Lm({filter:e}){let{workspaceId:t}=ne(),{get:n,set:r,query:a}=e,o={id:Em(n(`sort`),[`started`,`duration`,`tokens`,`input`,`output`,`cached`,`cost`,`steps`],`started`),dir:Em(n(`dir`),[`asc`,`desc`],`desc`)},s=Em(n(`group`),et,``),c=n(`dense`)===`1`,l=!!s&&n(`cmp`)===`1`,u=l?Mm:Am,d=(0,Y.useMemo)(()=>Nm(Yl(u,{cols:n(`cols`)||null,pin:e.params.has(`pin`)?n(`pin`)===`none`?``:n(`pin`):null,widths:n(`w`)||null,defaults:Pm}),l),[n,e.params,u,l]),f=e=>r(Xl({...e,order:e.order.filter(e=>!jm.includes(e)),hidden:e.hidden.filter(e=>!jm.includes(e))},Pm)),p=`&sort=${o.id}&dir=${o.dir}`,m=_i(t,e=>`/usage/rows?${a}${p}&limit=100${e?`&cursor=${encodeURIComponent(e)}`:``}`,{next:e=>e.next,enabled:!s}),h=gi(t,`/usage/breakdown?${a}&groupBy=${s||`agent`}`,{enabled:!!s}),_=gi(t,`/usage/breakdown?${a}&groupBy=${s||`agent`}&previous=1`,{enabled:l}),[v,b]=(0,Y.useState)({}),x=s?Object.keys(v).filter(e=>v[e]&&e.startsWith(`${s}:`)):[],C=$r({queries:x.map(e=>{let n=e.slice(s.length+1),r=new URLSearchParams(a);r.set(s,n===``?`~`:n);let i=ke(t,`/usage/rows?${r}${p}&limit=${v[e]}`);return{queryKey:[i],queryFn:()=>U.get(i),placeholderData:e=>e}})}),w=s?(h.data?.groups||[]).reduce((e,t)=>e+t.calls,0):m.data?.pages[0]?.total??null,T=C.map(e=>`${e.dataUpdatedAt}:${e.isFetching}`).join(`,`),E=(0,Y.useMemo)(()=>{if(!s)return(m.data?.pages||[]).flatMap(e=>e.rows).map(e=>({type:`row`,row:e}));let e=[];for(let t of h.data?.groups||[]){let n=`${s}:${t.key}`,i=v[n],a=s===`outcome`?Je[t.key]||t.label:s===`kind`&&Ze[t.key]||t.label,o=l&&_.data?_.data.groups.find(e=>e.key===t.key)||{calls:0}:null;if(e.push({type:`group`,group:{...t,label:a,before:o},open:!!i,summary:`${J(t.calls)} ${t.calls===1?`turn`:`turns`}`}),!i)continue;let c=C[x.indexOf(n)];for(let t of c?.data?.rows||[])e.push({type:`row`,row:t,depth:1});(!c?.data||c.data.next)&&e.push({type:`more`,group:{...t,label:a},busy:!c?.data||c.isFetching,load:i>=500?()=>r({group:null,[s]:[t.key===``?`~`:t.key]},{push:!0}):()=>b(e=>({...e,[n]:Math.min(500,i+200)}))})}return e},[s,m.data,h.data,v,T,l,_.data]),D=e=>b(t=>({...t,[`${s}:${e}`]:t[`${s}:${e}`]?0:Fm})),O=s?h:m,k=E.filter(e=>e.type===`row`).length;return(0,X.jsxs)(K,{"data-sw-usage-turns":!0,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-3 py-2.5 sm:px-4`,children:[(0,X.jsxs)(`p`,{className:`mr-auto text-sm text-fg`,role:`status`,"data-sw-turn-count":w??``,children:[w===null?`Loading turns`:`${J(w,{exact:!0})} ${w===1?`turn`:`turns`}`,w!==null&&!s&&k<w?(0,X.jsxs)(`span`,{className:`text-muted`,children:[` · `,J(k,{exact:!0}),` loaded`]}):null]}),(0,X.jsx)(zp,{label:`Group the turns`,testId:`group`,value:s||`none`,onChange:e=>r({group:e===`none`?null:e},{push:!0}),options:[[`none`,`Not grouped`],...et.map(e=>[e,`Group by ${Xe[e].toLowerCase()}`])]}),s?(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":l,onClick:()=>r({cmp:l?null:`1`}),title:`Show each group's turns in ${e.period.compare}, and the change`,className:i(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs font-medium outline-none focus-visible:outline-2 focus-visible:outline-accent`,l?`border-accent/50 bg-accent/10 text-fg`:`border-line bg-surface text-fg hover:bg-surface-2`),"data-sw-grid-compare":l?`on`:`off`,children:[(0,X.jsx)($t,{size:14,className:`text-muted`,"aria-hidden":`true`}),` Compare`]}):null,(0,X.jsxs)(`span`,{className:`hidden items-center gap-2 sm:flex`,children:[(0,X.jsx)(y,{label:c?`Roomier rows`:`Denser rows`,variant:`secondary`,size:`icon-sm`,className:`h-9 w-9`,onClick:()=>r({dense:c?null:`1`}),"data-sw-grid-density":c?`dense`:`roomy`,children:c?(0,X.jsx)(gn,{size:15,"aria-hidden":`true`}):(0,X.jsx)(vn,{size:15,"aria-hidden":`true`})}),(0,X.jsx)($l,{columns:Am,layout:{...d,order:d.order.filter(e=>!jm.includes(e))},onLayout:f,onReset:()=>r({cols:null,pin:null,w:null})})]})]}),O.error&&!O.data?(0,X.jsx)(`div`,{className:`p-4`,children:(0,X.jsx)(De,{error:O.error,onRetry:O.refetch})}):O.isLoading?(0,X.jsxs)(`p`,{className:`flex items-center justify-center gap-2 px-4 py-16 text-sm text-muted`,role:`status`,children:[(0,X.jsx)(S,{}),` Loading turns`]}):E.length?(0,X.jsx)(Zl,{label:`Agent turns`,columns:u,items:E,rowKey:e=>e.id,layout:d,onLayout:f,sort:o,onSort:e=>r({sort:e.id===`started`?null:e.id,dir:e.dir===`desc`?null:e.dir},{push:!0}),dense:c,onOpen:e=>r({row:e.id}),openId:n(`row`)||null,onToggleGroup:D,hasMore:!s&&!!m.hasNextPage,loadingMore:m.isFetchingNextPage,onMore:()=>m.fetchNextPage(),busy:O.isPlaceholderData&&O.isFetching,card:e=>(0,X.jsx)(Im,{row:e}),footer:(0,X.jsxs)(`p`,{className:`flex items-center justify-between gap-2 border-t border-line px-4 py-2 text-caption text-muted`,children:[(0,X.jsx)(`span`,{children:m.isFetchingNextPage?`Loading more turns`:`Arrow keys move through the rows; Enter opens one.`}),(0,X.jsxs)(V,{to:`/w/${t}/usage?${new URLSearchParams([...e.params].filter(([e])=>![`tab`,`row`].includes(e)))}`,className:`inline-flex items-center gap-1 font-medium text-accent underline-offset-2 hover:underline`,children:[`Charts for this filter `,(0,X.jsx)(B,{size:12,"aria-hidden":`true`})]})]})}):(0,X.jsx)(g,{icon:me,title:`No turns match`,"data-sw-turns-empty":!0,children:`Clear a filter or choose a longer period.`})]})}var Rm=`__all__`,zm=`font-medium text-accent underline-offset-2 hover:underline`,Bm={person:Se,token:s,guest:Ie,system:ae},Vm={person:`A person`,token:`An API token`,guest:`A share link guest`,system:`The server`},Hm=(0,X.jsx)(`span`,{className:`text-faint`,children:`–`});function Um(e={}){let t=ui(),{params:n}=t,r=n.get(`range`)||`any`,i=(0,Y.useMemo)(()=>r===`any`?null:Ke({range:r,from:n.get(`from`),to:n.get(`to`)}),[n,r]),a=(0,Y.useMemo)(()=>{let t=new URLSearchParams;for(let r of[`person`,`agent`,`project`,`group`,`source`,`q`]){let i=e[r]??n.get(r);i&&t.set(r,i)}return n.get(`sensitive`)===`1`&&t.set(`sensitive`,`1`),i&&(t.set(`from`,i.from.toISOString()),t.set(`to`,i.to.toISOString())),t.toString()},[n,i,e.person,e.agent]),o=[`person`,`agent`,`project`,`group`,`source`,`q`,`sensitive`].filter(t=>n.get(t)&&!e[t]);return r!==`any`&&o.push(`range`),{...t,period:i,range:r,query:a,active:o}}function Wm({entry:e}){let t=Bm[e.source]||ae;return(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,X.jsx)(t,{size:13,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{className:`truncate`,children:[e.actor.label,e.actor.type===`token`?(0,X.jsx)(`span`,{className:`text-muted`,children:` (token)`}):null,e.actor.type===`guest`&&e.actor.named?(0,X.jsx)(`span`,{className:`text-muted`,children:` (guest)`}):null]})]})}function Gm({change:e}){return e?(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,"data-sw-change":!0,children:[(0,X.jsx)(`span`,{className:`truncate text-muted line-through decoration-line-strong`,children:e.before||`none`}),(0,X.jsx)(`span`,{className:`text-faint`,"aria-label":`changed to`,children:`→`}),(0,X.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.after||`none`})]}):Hm}var Km=[{id:`at`,header:`When`,width:146,always:!0,cell:e=>Ct(e.at)},{id:`who`,header:`Who`,width:150,cell:e=>(0,X.jsx)(Wm,{entry:e})},{id:`what`,header:`What`,width:350,cell:e=>(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[e.sensitive?(0,X.jsx)(ie,{size:13,className:`shrink-0 text-warn`,"aria-label":`A security-relevant change`}):null,(0,X.jsx)(`span`,{className:`truncate first-letter:uppercase`,children:be(e)}),e.tailnetSession?(0,X.jsx)(`span`,{className:`shrink-0 rounded border border-line px-1 text-[10px] text-muted`,title:`Done in a session their tailnet signed in`,"data-sw-activity-tailnet":!0,children:`tailnet`}):null]})},{id:`change`,header:`Before and after`,width:200,cell:e=>(0,X.jsx)(Gm,{change:e.change})},{id:`group`,header:`Kind`,width:160,cell:e=>ft[e.group]||`Other`},{id:`agent`,header:`Agent`,width:136,cell:e=>e.agent?.name||Hm},{id:`project`,header:`Project`,width:150,cell:e=>e.project?.name||Hm},{id:`source`,header:`Through`,width:150,cell:e=>Vm[e.source]||Hm},{id:`ip`,header:`Address`,width:116,cell:e=>e.ip||Hm},{id:`device`,header:`Device`,width:160,cell:e=>e.device||Hm},{id:`action`,header:`Action name`,width:220,cell:e=>(0,X.jsx)(`code`,{className:`font-mono text-[11px] text-muted`,children:e.action})}],qm={shown:[`at`,`who`,`what`,`change`,`agent`,`ip`],pinned:[`at`]};function Jm({entry:e}){return(0,X.jsxs)(`span`,{className:`block`,"data-sw-activity-card":!0,children:[(0,X.jsxs)(`span`,{className:`block text-sm text-fg`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.actor.label}),` `,be(e)]}),e.change?(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs`,children:(0,X.jsx)(Gm,{change:e.change})}):null,(0,X.jsxs)(`span`,{className:`mt-0.5 block truncate text-xs text-muted`,children:[Ct(e.at),e.ip?` · ${e.ip}`:``]})]})}function Ym({entry:e,onClose:t,workspaceId:n,isAdmin:r}){return e?(0,X.jsx)(gt,{open:!0,onClose:t,title:ft[e.group]||`Activity`,description:Te(e.at),testId:`activity`,children:(0,X.jsxs)(`div`,{"data-sw-activity-entry":e.id,children:[(0,X.jsxs)(`p`,{className:`border-b border-line px-5 py-3.5 text-sm text-fg`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.actor.label}),` `,be(e)]}),e.change?(0,X.jsxs)(dt,{title:`What changed`,children:[(0,X.jsx)(q,{label:`Before`,children:e.change.before||`none`}),(0,X.jsx)(q,{label:`After`,children:(0,X.jsx)(`span`,{className:`font-medium`,children:e.change.after||`none`})})]}):null,(0,X.jsxs)(dt,{title:`Who, when and from where`,children:[(0,X.jsxs)(q,{label:`Who`,children:[e.actor.type===`user`&&r?(0,X.jsx)(V,{to:`/w/${n}/activity/${e.actor.id}`,className:zm,children:e.actor.label}):e.actor.label,e.actor.handle?(0,X.jsxs)(`span`,{className:`text-muted`,children:[` @`,e.actor.handle]}):null]}),(0,X.jsx)(q,{label:`Through`,children:Vm[e.source]}),(0,X.jsx)(q,{label:`When`,children:Ct(e.at)}),(0,X.jsx)(q,{label:`Address`,children:e.ip||(0,X.jsx)(`span`,{className:`text-muted`,children:`Not recorded`})}),e.device?(0,X.jsx)(q,{label:`Device`,children:e.device}):null,(0,X.jsx)(q,{label:`Belongs to`,children:e.scope===`account`?`The person’s account (sign-in)`:`This workspace`})]}),(0,X.jsxs)(dt,{title:`About`,children:[(0,X.jsx)(q,{label:`Action`,children:(0,X.jsx)(`code`,{className:`font-mono text-xs`,children:e.action})}),e.agent?(0,X.jsx)(q,{label:`Agent`,children:r?(0,X.jsx)(V,{to:`/w/${n}/activity/${e.agent.id}`,className:zm,children:e.agent.name}):e.agent.name}):null,e.project?(0,X.jsx)(q,{label:`Project`,children:e.project.name}):null,e.target?(0,X.jsx)(q,{label:`Target`,children:e.targetLabel||(0,X.jsx)(`code`,{className:`font-mono text-xs break-all`,children:e.target})}):null]}),Object.keys(e.detail).length?(0,X.jsxs)(`section`,{className:`px-5 py-3.5`,children:[(0,X.jsx)(`h3`,{className:`mb-2 text-xs font-semibold tracking-wide text-muted uppercase`,children:`As recorded`}),(0,X.jsx)(`pre`,{className:`overflow-x-auto rounded-md border border-line bg-surface-2 px-3 py-2 font-mono text-[11px] leading-5 whitespace-pre-wrap text-fg`,children:JSON.stringify(e.detail,null,2)}),(0,X.jsx)(`p`,{className:`mt-1.5 text-caption text-muted`,children:`Names, ids and settings. The log never holds comment text, prompts or answers.`})]}):null,e.agent&&r?(0,X.jsx)(`p`,{className:`border-t border-line px-5 py-3 text-sm`,children:(0,X.jsxs)(V,{to:`/w/${n}/usage?agent=${e.agent.id}&tab=turns`,className:i(zm,`inline-flex items-center gap-1`),children:[`Usage of `,e.agent.name,` `,(0,X.jsx)(B,{size:13,"aria-hidden":`true`})]})}):null]})}):null}function Xm({fixed:e={},embedded:t=!1}){let{workspaceId:n,isAdmin:r}=ne(),a=Um(e),{get:o,set:s,query:c,search:u}=a,d=gi(n,`/activity/filters`,{keep:!1,enabled:!t}),f=_i(n,e=>`/activity?${c}&limit=100${e?`&before=${e}`:``}`,{next:e=>e.next}),p=(0,Y.useMemo)(()=>(f.data?.pages||[]).flatMap(e=>e.entries),[f.data]),m=(0,Y.useMemo)(()=>p.map(e=>({type:`row`,row:e})),[p]),[h,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(o(`q`)),b=ue(),x=H(),C=(0,Y.useMemo)(()=>Yl(Km,{cols:o(`cols`)||null,pin:a.params.has(`pin`)?o(`pin`)===`none`?``:o(`pin`):null,widths:o(`w`)||null,defaults:qm}),[o,a.params]),D=e=>s(Xl(e,qm)),O=()=>b.run(async()=>{let e=await z(`GET`,ke(n,`/activity/export?${c}`),void 0,`activity.csv`);x(`Saved ${e.name}`)}),k=(e,t,n,r)=>(0,X.jsxs)(M,{value:o(e)||Rm,onValueChange:t=>s({[e]:t===Rm?null:t},{push:!0}),children:[(0,X.jsx)(E,{className:i(`h-9 w-full min-w-0 text-xs font-medium sm:w-auto`,o(e)&&`border-accent/50 bg-accent/10`),"aria-label":t,"data-sw-activity-filter":r||e,children:(0,X.jsx)(T,{})}),(0,X.jsxs)(w,{children:[(0,X.jsx)(A,{value:Rm,children:t}),n.map(([e,t])=>(0,X.jsx)(A,{value:e,children:t},e))]})]}),j=a.period||{range:`any`,from:new Date(Date.now()-2592e6),to:new Date(Date.now()+864e5),label:`Any time`},N=p.find(e=>e.id===h);return(0,X.jsxs)(`div`,{"data-sw-activity-log":!0,children:[(0,X.jsxs)(`div`,{className:`mb-3 grid grid-cols-2 gap-1.5 sm:flex sm:flex-wrap sm:items-center print:hidden`,"data-sw-activity-filters":!0,children:[(0,X.jsxs)(`span`,{className:`col-span-2 flex items-center gap-1.5 sm:col-span-1`,children:[(0,X.jsx)(wi,{period:j,onChange:e=>s({range:e.range||`30d`,from:e.from,to:e.to},{push:!0})}),a.range===`any`?null:(0,X.jsx)(l,{size:`sm`,variant:`ghost`,className:`h-9`,onClick:()=>s({range:null,from:null,to:null},{push:!0}),children:`Any time`})]}),r&&!e.person&&!t?k(`person`,`Everyone`,(d.data?.people||[]).map(e=>[e.id,e.name])):null,k(`group`,`Every kind of action`,He.map(e=>[e,ft[e]])),r&&!e.agent&&!t?k(`agent`,`Any agent`,(d.data?.agents||[]).map(e=>[e.id,e.name])):null,r&&!t?k(`project`,`Any project`,(d.data?.projects||[]).map(e=>[e.id,e.name])):null,r&&!t?k(`source`,`Through anything`,Object.entries(Vm)):null,(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":o(`sensitive`)===`1`,onClick:()=>s({sensitive:e=>e.includes(`1`)?null:`1`},{push:!0}),className:i(`inline-flex h-9 items-center justify-center gap-1.5 rounded-md border px-2.5 text-xs font-medium outline-none focus-visible:outline-2 focus-visible:outline-accent`,o(`sensitive`)===`1`?`border-accent/50 bg-accent/10 text-fg`:`border-line bg-surface text-fg hover:bg-surface-2`),"data-sw-activity-sensitive":!0,children:[(0,X.jsx)(ie,{size:14,className:`text-warn`,"aria-hidden":`true`}),` Worth a look`]}),(0,X.jsx)(`form`,{className:`col-span-2 sm:col-span-1`,onSubmit:e=>{e.preventDefault(),s({q:v.trim()||null},{push:!0})},children:(0,X.jsx)(P,{icon:se,value:v,onChange:e=>y(e.target.value),placeholder:`Search names and details`,"aria-label":`Search the activity`,maxLength:100,className:`h-9`,wrapperClassName:`w-full sm:w-52`,"data-sw-activity-search":!0})}),t?null:(0,X.jsxs)(`span`,{className:`col-span-2 flex items-center gap-1.5 sm:ml-auto`,children:[(0,X.jsx)(Ai,{workspaceId:n,page:`activity`,search:u,onOpen:e=>li(new URLSearchParams(e),{push:!0})}),(0,X.jsx)(`span`,{className:`hidden sm:inline-flex`,children:(0,X.jsx)($l,{columns:Km,layout:C,onLayout:D,onReset:()=>s({cols:null,pin:null,w:null})})}),(0,X.jsxs)(l,{size:`sm`,variant:`secondary`,className:`h-9`,onClick:O,disabled:b.busy,"data-sw-activity-export":!0,children:[b.busy?(0,X.jsx)(S,{}):(0,X.jsx)(Le,{size:14,"aria-hidden":`true`}),` Export CSV`]})]})]}),b.error?(0,X.jsx)(`p`,{className:`mb-2 text-sm text-bad`,role:`alert`,children:b.error}):null,f.data?.pages[0]?.searchedFrom?(0,X.jsx)(`p`,{className:`mb-2 text-xs text-muted`,"data-sw-activity-search-bound":!0,children:`Searching the last 90 days. Choose a period to search further back.`}):null,!t&&d.data?(0,X.jsx)(`p`,{className:`mb-2 text-xs text-muted`,"data-sw-activity-accounts":d.data.accounts,children:d.data.accounts===`members`?`Sign-ins, passkeys and devices of this workspace’s members are shown here, to owners: this server’s operator switched that on.`:r?`Sign-ins and passkeys belong to each person and are not shown here. Everyone sees their own on their own page.`:`This is your own activity here, with your sign-ins.`}):null,(0,X.jsx)(K,{children:f.error&&!f.data?(0,X.jsx)(`div`,{className:`p-4`,children:(0,X.jsx)(De,{error:f.error,onRetry:f.refetch})}):f.isLoading?(0,X.jsx)(we,{label:`Loading the activity`,rows:5}):m.length?(0,X.jsx)(Zl,{label:`Activity`,columns:Km,items:m,rowKey:e=>e.id,layout:C,onLayout:D,onOpen:e=>_(e.id),openId:h,hasMore:!!f.hasNextPage,loadingMore:f.isFetchingNextPage,onMore:()=>f.fetchNextPage(),busy:f.isPlaceholderData&&f.isFetching,card:e=>(0,X.jsx)(Jm,{entry:e}),footer:(0,X.jsxs)(`p`,{className:`border-t border-line px-4 py-2 text-caption text-muted`,children:[J(p.length,{exact:!0}),` `,p.length===1?`entry`:`entries`,` loaded`,f.hasNextPage?`; older ones load as you scroll`:``,`. Newest first.`]})}):(0,X.jsx)(g,{icon:L,title:a.active.length?`Nothing matches these filters`:`No activity yet`,"data-sw-activity-empty":!0,children:a.active.length?`Clear a filter or choose a longer period.`:`Sign-ins, settings, agents, approvals, tokens and exports show up here as they happen.`})}),(0,X.jsx)(Ym,{entry:N,onClose:()=>_(null),workspaceId:n,isAdmin:r})]})}function Zm(){let{workspaceId:e,isAdmin:t}=ne(),{get:n,set:r}=ui(),a=t&&n(`tab`)===`review`?`review`:`log`;return(0,X.jsxs)(`div`,{"data-sw-activity":a,children:[(0,X.jsx)(G,{title:`Activity`,description:t?`What people did here: sign-ins, settings with before and after, agents, approvals, tokens and exports. Read from the audit log.`:`Your own activity in this workspace: your sign-ins, what you changed and what you exported. Admins and owners see everyone’s.`,actions:(0,X.jsxs)(V,{to:`/w/${e}/usage`,className:i(zm,`inline-flex items-center gap-1 text-sm`),children:[`Agent usage `,(0,X.jsx)(B,{size:14,"aria-hidden":`true`})]})}),(0,X.jsx)(bt,{testId:`activity`,children:`This is a demo with a made-up history: the sign-ins, settings, agents and approvals of a pretend team. What you do in the demo is added on top; Reset puts everything back.`}),t?(0,X.jsx)(`div`,{className:`mb-4 flex print:hidden`,children:(0,X.jsx)(j,{label:`View`,value:a,onChange:e=>r({tab:e===`log`?null:e},{push:!0}),options:[{id:`log`,label:`Activity`},{id:`review`,label:`Access review`}]})}):null,a===`review`?(0,X.jsx)(ih,{}):(0,X.jsx)(Xm,{})]})}function Qm({workspaceId:e}){return(0,X.jsxs)(V,{to:`/w/${e}/activity`,className:`mb-3 inline-flex items-center gap-1 text-sm font-medium text-muted hover:text-fg print:hidden`,children:[(0,X.jsx)(ce,{size:14,"aria-hidden":`true`}),` Activity`]})}var $m=({workspaceId:e,what:t})=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Qm,{workspaceId:e}),(0,X.jsx)(K,{"data-sw-subject-missing":!0,children:(0,X.jsx)(g,{icon:Se,size:`lg`,title:`${t} not found`,children:`It is not in this workspace, or this page is not yours to see.`})})]});function eh({userId:e}){let{workspaceId:t,isAdmin:n,data:r}=ne(),a=gi(t,`/people/${e}`,{keep:!1}),o=mi();if(a.isLoading)return(0,X.jsx)(we,{label:`Loading the person`,rows:4});if(a.error)return a.error.status===404?(0,X.jsx)($m,{workspaceId:t,what:`Person`}):(0,X.jsx)(De,{error:a.error,onRetry:a.refetch});let c=a.data.person,l=c.userId===r.me.userId;return(0,X.jsxs)(`div`,{"data-sw-person":c.handle,children:[n?(0,X.jsx)(Qm,{workspaceId:t}):null,(0,X.jsx)(G,{title:c.displayName,badge:(0,X.jsx)(je,{role:c.role}),description:`@${c.handle} · joined ${Oe(c.joinedAt)}${c.roleChanged?.from?` · ${ye[c.roleChanged.from]||c.roleChanged.from} until ${Oe(c.roleChanged.at)}`:``}`}),(0,X.jsxs)(bt,{testId:`person`,children:[`This is a demo: `,c.displayName,` is made up, and so are these numbers.`]}),(0,X.jsxs)(`div`,{className:`mb-5 grid gap-4 lg:grid-cols-3`,children:[(0,X.jsxs)(K,{children:[(0,X.jsx)(Ee,{icon:he,title:`What they can reach`}),(0,X.jsxs)(dt,{children:[(0,X.jsx)(q,{label:`Role`,children:ye[c.role]}),(0,X.jsx)(q,{label:`On every project`,children:Ce[c.access]}),(0,X.jsx)(q,{label:`Projects`,children:c.projects.length?c.projects.map(e=>e.name).join(`, `):`None yet`}),(0,X.jsx)(q,{label:`Last active`,children:(0,X.jsx)(Ne,{value:c.lastActiveAt})}),(0,X.jsxs)(q,{label:`Comments`,children:[J(c.counts.comments.count),c.counts.comments.lastAt?(0,X.jsxs)(`span`,{className:`text-muted`,children:[` · last `,Oe(c.counts.comments.lastAt)]}):null]}),(0,X.jsx)(q,{label:`Chat messages`,children:J(c.counts.chatMessages.count)}),(0,X.jsx)(q,{label:`Approvals answered`,children:J(c.counts.approvalsAnswered.count)})]})]}),(0,X.jsxs)(K,{children:[(0,X.jsx)(Ee,{icon:Fe,title:`What they made`,description:`Tokens and agents work only while their maker is an admin or owner here.`}),(0,X.jsxs)(`ul`,{className:`divide-y divide-line text-sm`,"data-sw-person-made":!0,children:[c.agents.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-2 px-4 py-2 sm:px-5`,children:[(0,X.jsx)(s,{size:14,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[n?(0,X.jsx)(V,{to:`/w/${t}/activity/${e.id}`,className:i(zm,`block truncate`),children:e.name}):(0,X.jsx)(`span`,{className:`block truncate text-fg`,children:e.name}),(0,X.jsxs)(`span`,{className:`block truncate text-caption text-muted`,children:[`Agent on `,e.projectName,e.machine?` · ${e.machine}`:``]})]}),e.revoked?(0,X.jsx)(C,{tone:`neutral`,children:`Revoked`}):null]},e.id)),c.tokens.filter(e=>!e.scopes.includes(`claim`)).map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-2 px-4 py-2 sm:px-5`,children:[(0,X.jsx)(Fe,{size:14,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate text-fg`,children:e.name}),(0,X.jsxs)(`span`,{className:`block truncate text-caption text-muted`,children:[`Token on `,e.projectName,` · `,e.scopes.join(`, `)]})]}),e.status===`active`?null:(0,X.jsx)(C,{tone:`neutral`,children:e.status})]},e.id)),!c.agents.length&&!c.tokens.length?(0,X.jsx)(`li`,{className:`px-5 py-6 text-center text-xs text-muted`,children:`No tokens or agents.`}):null]}),c.shares?(0,X.jsxs)(`p`,{className:`border-t border-line px-5 py-2 text-xs text-muted`,children:[c.shares,` open share links.`]}):null]}),(0,X.jsxs)(K,{children:[(0,X.jsx)(Ee,{icon:te,title:`Signed in on`,description:`Devices with a live session, by when each was last seen.`}),(0,X.jsxs)(`ul`,{className:`divide-y divide-line text-sm`,"data-sw-person-devices":!0,children:[(c.sessions||[]).map((e,t)=>(0,X.jsxs)(`li`,{className:`px-4 py-2 sm:px-5`,children:[(0,X.jsx)(`span`,{className:`block truncate text-fg`,children:e.device||`An unknown device`}),(0,X.jsxs)(`span`,{className:`block text-caption text-muted`,children:[`Last seen `,(0,X.jsx)(Ne,{value:e.lastSeenAt}),` · signed in `,Oe(e.createdAt),e.via===`recovery`?` with a recovery code`:``]})]},t)),c.sessions===null?(0,X.jsx)(`li`,{className:`px-5 py-6 text-center text-xs text-muted`,"data-sw-person-devices-private":!0,children:`Where someone is signed in is theirs to see: it covers every workspace they are in.`}):c.sessions.length?null:(0,X.jsx)(`li`,{className:`px-5 py-6 text-center text-xs text-muted`,children:`Not signed in anywhere.`})]})]})]}),(0,X.jsx)(th,{title:l?`Your agent usage`:`${c.displayName}'s agent usage`,filter:o,extra:`&person=${c.userId}`,to:`/w/${t}/usage?person=${c.userId}`}),(0,X.jsx)(`h2`,{className:`mt-6 mb-3 text-heading font-semibold text-fg`,children:l?`Your activity`:`${c.displayName}'s activity`}),(0,X.jsx)(Xm,{fixed:{person:c.userId},embedded:!0})]})}function th({title:e,filter:t,extra:n,to:r}){return(0,X.jsxs)(`section`,{"data-sw-subject-usage":!0,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`h2`,{className:`text-heading font-semibold text-fg`,children:e}),(0,X.jsxs)(`span`,{className:`flex items-center gap-2 print:hidden`,children:[(0,X.jsx)(wi,{period:t.period,onChange:e=>t.set(e,{push:!0})}),(0,X.jsxs)(V,{to:r,className:i(zm,`inline-flex items-center gap-1 text-sm`),children:[`Open in Usage `,(0,X.jsx)(B,{size:14,"aria-hidden":`true`})]})]})]}),(0,X.jsx)(Om,{filter:t,extraQuery:n})]})}function nh({agentId:e}){let{workspaceId:t,isAdmin:n}=ne(),r=gi(t,`/agents/${e}/profile`,{keep:!1,enabled:n}),a=mi();if(!n)return(0,X.jsx)($m,{workspaceId:t,what:`Agent`});if(r.isLoading)return(0,X.jsx)(we,{label:`Loading the agent`,rows:4});if(r.error)return r.error.status===404?(0,X.jsx)($m,{workspaceId:t,what:`Agent`}):(0,X.jsx)(De,{error:r.error,onRetry:r.refetch});let o=r.data.agent,s={online:`Online`,busy:`Working`,offline:`Offline`,revoked:`Revoked`}[o.state]||o.state;return(0,X.jsxs)(`div`,{"data-sw-agent-page":o.name,children:[(0,X.jsx)(Qm,{workspaceId:t}),(0,X.jsx)(G,{title:o.name,badge:(0,X.jsx)(C,{tone:o.state===`revoked`?`bad`:o.state===`offline`?`neutral`:`ok`,children:s}),description:`An agent of ${o.projectName}${o.machine?`, on ${o.machine}`:``}.`,actions:(0,X.jsxs)(V,{to:_?`/w/${t}/tokens`:`/w/${t}/agents/${o.projectId}`,className:i(zm,`inline-flex items-center gap-1 text-sm`),"data-sw-agent-settings":!0,children:[_?`Its token`:`Its settings`,` `,(0,X.jsx)(B,{size:14,"aria-hidden":`true`})]})}),(0,X.jsxs)(bt,{testId:`agent`,children:[`This is a demo: the machine, the models and the numbers of `,o.name,` are made up.`]}),(0,X.jsx)(K,{className:`mb-5`,children:(0,X.jsxs)(dt,{children:[(0,X.jsxs)(q,{label:`Connected by`,children:[o.createdBy?(0,X.jsx)(V,{to:`/w/${t}/activity/${o.createdBy.userId}`,className:zm,children:o.createdBy.displayName||`Former member`}):`Nobody on record`,(0,X.jsxs)(`span`,{className:`text-muted`,children:[` on `,Oe(o.createdAt)]})]}),(0,X.jsx)(q,{label:`Who may use it`,children:o.audience.text||ge[o.audience.kind]}),(0,X.jsx)(q,{label:`Edits and commands`,children:o.approval.effectiveRule===`auto`?`Allowed without asking, where its machine says so`:`Always wait for a person`}),(0,X.jsx)(q,{label:`Machine`,children:o.machine||(0,X.jsx)(`span`,{className:`text-muted`,children:`Not known`})}),(0,X.jsx)(q,{label:`Last seen`,children:(0,X.jsx)(Ne,{value:o.lastSeenAt})}),(0,X.jsxs)(q,{label:`Token`,children:[(0,X.jsxs)(`code`,{className:`font-mono text-xs`,children:[o.token.prefix,`…`]}),` · `,o.token.scopes.join(`, `),o.token.revokedAt?(0,X.jsxs)(`span`,{className:`text-bad`,children:[` · revoked `,Oe(o.token.revokedAt)]}):null]})]})}),(0,X.jsx)(th,{title:`Usage of ${o.name}`,filter:a,extra:`&agent=${o.id}`,to:`/w/${t}/usage?agent=${o.id}`}),(0,X.jsxs)(`h2`,{className:`mt-6 mb-3 text-heading font-semibold text-fg`,children:[`Activity about `,o.name]}),(0,X.jsx)(Xm,{fixed:{agent:o.id},embedded:!0})]})}function rh({title:e,icon:t,description:n,columns:r,rows:i,empty:a,manage:o,testId:s}){return(0,X.jsxs)(K,{"data-sw-review":s,children:[(0,X.jsx)(Ee,{icon:t,title:`${e} (${i.length})`,description:n,actions:o}),i.length?(0,X.jsx)(`div`,{className:`overflow-x-auto`,children:(0,X.jsxs)(`table`,{className:`w-full min-w-[640px] border-collapse text-sm`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsx)(`tr`,{children:r.map(e=>(0,X.jsx)(`th`,{scope:`col`,className:`border-b border-line px-4 py-2 text-left text-xs font-medium whitespace-nowrap text-muted first:sm:pl-5`,children:e.label},e.label))})}),(0,X.jsx)(`tbody`,{children:i.map(e=>(0,X.jsx)(`tr`,{className:`border-b border-line/60 last:border-0`,"data-sw-review-row":e.name||e.displayName||e.id,children:r.map((t,n)=>n?(0,X.jsx)(`td`,{className:`max-w-[16rem] truncate px-4 py-2 text-fg`,children:t.cell(e)},t.label):(0,X.jsxs)(`th`,{scope:`row`,className:`max-w-[16rem] truncate px-4 py-2 text-left font-medium text-fg sm:pl-5`,children:[t.cell(e),e.stale?(0,X.jsx)(C,{tone:`warn`,className:`ml-2 align-middle`,"data-sw-stale":!0,children:`Unused`}):null]},t.label))},e.id||e.userId))})]})}):(0,X.jsx)(`p`,{className:`px-5 py-6 text-center text-xs text-muted`,children:a})]})}function ih(){let{workspaceId:e}=ne(),t=gi(e,`/access-review`,{keep:!1}),n=ue(),r=H();if(t.isLoading)return(0,X.jsx)(we,{label:`Loading the access review`,rows:5});if(t.error)return(0,X.jsx)(De,{error:t.error,onRetry:t.refetch});let a=t.data,o=e=>e.createdBy?.displayName||(e.createdBy?`Former member`:Hm),c=e=>e?Oe(e):(0,X.jsx)(`span`,{className:`text-muted`,children:`Never`}),u=[a.people,a.tokens,a.agents,a.shares].flat().filter(e=>e.stale).length,d=(t,n)=>(0,X.jsx)(V,{to:`/w/${e}/${t}`,className:i(zm,`text-xs`),children:n});return(0,X.jsxs)(`div`,{className:`space-y-4`,"data-sw-access-review":!0,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`p`,{className:`max-w-2xl text-sm text-muted`,children:[`Every way into this workspace, with who made it and when it was last used.`,` `,u?(0,X.jsxs)(`span`,{className:`text-fg`,children:[u,` `,u===1?`has`:`have`,` not been used for `,a.staleDays,` days.`]}):`Nothing has gone unused for ${a.staleDays} days.`]}),(0,X.jsxs)(l,{size:`sm`,variant:`secondary`,className:`h-9 print:hidden`,disabled:n.busy,onClick:()=>n.run(async()=>{let t=await z(`GET`,ke(e,`/access-review/export`),void 0,`access-review.csv`);r(`Saved ${t.name}`)}),"data-sw-review-export":!0,children:[n.busy?(0,X.jsx)(S,{}):(0,X.jsx)(Le,{size:14,"aria-hidden":`true`}),` Export CSV`]})]}),(0,X.jsx)(rh,{testId:`people`,title:`People`,icon:Se,description:`A person's role applies to every project.`,manage:d(`members`,`Manage members`),rows:a.people,columns:[{label:`Person`,cell:t=>(0,X.jsx)(V,{to:`/w/${e}/activity/${t.userId}`,className:zm,children:t.displayName})},{label:`Role`,cell:e=>ye[e.role]},{label:`Reaches`,cell:e=>`${e.reaches} (${Ce[e.access].toLowerCase()})`},{label:`Joined`,cell:e=>c(e.joinedAt)},{label:`Last active`,cell:e=>c(e.lastActiveAt)}]}),(0,X.jsx)(rh,{testId:`agents`,title:`Agents`,icon:s,description:`Each agent serves one project, with its own token.`,manage:_?d(`tokens`,`Their tokens`):d(`agents`,`Manage agents`),rows:a.agents,empty:`No agent is connected.`,columns:[{label:`Agent`,cell:t=>(0,X.jsx)(V,{to:`/w/${e}/activity/${t.id}`,className:zm,children:t.name})},{label:`Project`,cell:e=>e.projectName},{label:`Machine`,cell:e=>e.machine||Hm},{label:`Who may send it work`,cell:e=>e.audienceLabel||Hm},{label:`Approvals`,cell:e=>e.approvalRule===`auto`?`Without asking`:`Always ask`},{label:`Connected by`,cell:o},{label:`Last seen`,cell:e=>c(e.lastSeenAt)}]}),(0,X.jsx)(rh,{testId:`tokens`,title:`API tokens`,icon:Fe,description:`Each token reaches one project with the scopes listed. Agents' tokens are among them.`,manage:d(`tokens`,`Manage tokens`),rows:a.tokens,empty:`No API token.`,columns:[{label:`Token`,cell:e=>e.name},{label:`Project`,cell:e=>e.projectName},{label:`Scopes`,cell:e=>e.scopes.join(`, `)},{label:`Made by`,cell:o},{label:`Made`,cell:e=>c(e.createdAt)},{label:`Last used`,cell:e=>c(e.lastUsedAt)},{label:`Expires`,cell:e=>e.expiresAt?Oe(e.expiresAt):(0,X.jsx)(`span`,{className:`text-muted`,children:`Never`})}]}),(0,X.jsx)(rh,{testId:`shares`,title:`Share links`,icon:Ie,description:`Links that let people outside the workspace see, or comment on, one project.`,manage:d(`access`,`Manage share links`),rows:a.shares,empty:`No share link is open.`,columns:[{label:`Link`,cell:e=>e.name},{label:`Project`,cell:e=>e.projectName},{label:`Lets guests`,cell:e=>`${e.mode===`comment`?`Comment`:`View`}${e.passcode?` (passcode)`:``}`},{label:`Made by`,cell:o},{label:`Opened`,cell:e=>`${e.opens} ${e.opens===1?`time`:`times`}`},{label:`Last used`,cell:e=>c(e.lastUsedAt)},{label:`Expires`,cell:e=>Oe(e.expiresAt)}]}),a.publicProjects.length?(0,X.jsx)(rh,{testId:`public`,title:`Public projects`,icon:Ie,description:`Anyone with the address can see these.`,rows:a.publicProjects,columns:[{label:`Project`,cell:e=>e.name},{label:`Public since`,cell:e=>c(e.publicAt)}]}):null,a.invites.length?(0,X.jsx)(rh,{testId:`invites`,title:`Open invites`,icon:Se,description:`Links that let someone join until they expire.`,manage:d(`invites`,`Manage invites`),rows:a.invites,columns:[{label:`For`,cell:e=>e.note||`An invite link`},{label:`Joins as`,cell:e=>ye[e.role]},{label:`Made by`,cell:o},{label:`Expires`,cell:e=>Oe(e.expiresAt)}]}):null]})}function ah({section:e,subjectId:t=null}){let n;return n=e===`usage`?(0,X.jsx)(Dm,{}):t?.startsWith(`us_`)?(0,X.jsx)(eh,{userId:t},t):t?.startsWith(`ag_`)?(0,X.jsx)(nh,{agentId:t},t):(0,X.jsx)(Zm,{}),(0,X.jsx)(Dn,{client:ci,children:n})}export{ah as default};
|