@marimo-team/frontend 0.9.15-dev7 → 0.9.15-dev8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ConnectedDataExplorerComponent-p1uhaLu5.js → ConnectedDataExplorerComponent-D2R0YFFh.js} +1 -1
- package/dist/assets/{VegaLite-D30S6ZCi.js → VegaLite-CZugH90p.js} +1 -1
- package/dist/assets/{_baseEach-BMye5Nwh.js → _baseEach-B93NjDuP.js} +1 -1
- package/dist/assets/_baseMap-D4MvCFBz.js +1 -0
- package/dist/assets/{_baseUniq-DAxdF8Pw.js → _baseUniq-hXr1TQ2b.js} +1 -1
- package/dist/assets/{any-language-editor-DZ_JhVtg.js → any-language-editor-B_PDqHJJ.js} +1 -1
- package/dist/assets/{architectureDiagram-IFBEXTG3-BUUyUyY4.js → architectureDiagram-IFBEXTG3-CC4FZjer.js} +1 -1
- package/dist/assets/{blockDiagram-TCMKQVZ6-C8hwVnTX.js → blockDiagram-TCMKQVZ6-COR7ZfRw.js} +1 -1
- package/dist/assets/{c4Diagram-ZCSEYPFN-B6hKiRsz.js → c4Diagram-ZCSEYPFN-D14u52tn.js} +1 -1
- package/dist/assets/channel-CYIZ_PKW.js +1 -0
- package/dist/assets/{chunk-4LC2V6XN-C3CCiOAa.js → chunk-4LC2V6XN-COY3fyPS.js} +1 -1
- package/dist/assets/{chunk-5RIWM3LS-DFfFzycc.js → chunk-5RIWM3LS-CiFSzid6.js} +1 -1
- package/dist/assets/{chunk-6JKP7OK7-BeVRKhip.js → chunk-6JKP7OK7-BMp6Jlwh.js} +1 -1
- package/dist/assets/{chunk-NGC4727B-BOHRbEG_.js → chunk-NGC4727B-CXzrhor-.js} +1 -1
- package/dist/assets/{chunk-REEJFE46-BnpA03VW.js → chunk-REEJFE46-D888vVtb.js} +1 -1
- package/dist/assets/{chunk-RYO7GUH3-Q1dXGX63.js → chunk-RYO7GUH3-b6oqMds3.js} +1 -1
- package/dist/assets/{chunk-V35ELUW5-Bx4QWhcn.js → chunk-V35ELUW5-CQgAD1rq.js} +1 -1
- package/dist/assets/{classDiagram-Q73GJZWF-DAdn1Yxt.js → classDiagram-Q73GJZWF-DTRvMy2A.js} +1 -1
- package/dist/assets/{classDiagram-v2-C6QPLPW4-DnOh94Ik.js → classDiagram-v2-C6QPLPW4-CckMfbP3.js} +1 -1
- package/dist/assets/clone-VE85hIME.js +1 -0
- package/dist/assets/{dagre-7KT5K2WU-kcp6m67r.js → dagre-7KT5K2WU-AU2dZOj1.js} +1 -1
- package/dist/assets/{data-editor-CqM3d1bn.js → data-editor-CvMXe-1q.js} +1 -1
- package/dist/assets/{diagram-AVGMFHF7-Qk4KB2WS.js → diagram-AVGMFHF7-9I2Mgly3.js} +1 -1
- package/dist/assets/{edit-page-CbdUq7F3.js → edit-page-fBw-Jxh3.js} +3 -3
- package/dist/assets/{erDiagram-DKC2X5TE-CmqYNL45.js → erDiagram-DKC2X5TE-G9ExrsM4.js} +1 -1
- package/dist/assets/{flowDiagram-NWEUNK3L-Cts11xJ5.js → flowDiagram-NWEUNK3L-tGf9aUEV.js} +1 -1
- package/dist/assets/{ganttDiagram-HLVPPPRE-CICB85_m.js → ganttDiagram-HLVPPPRE-CZJ4DjLs.js} +1 -1
- package/dist/assets/{gitGraph-YCYPL57B-DyaQXeFu.js → gitGraph-YCYPL57B-BR-9yubZ.js} +1 -1
- package/dist/assets/{gitGraphDiagram-JPZ3KUXI-B62QkoYb.js → gitGraphDiagram-JPZ3KUXI-DJWDjlpy.js} +1 -1
- package/dist/assets/{graph-aLbp0MJ5.js → graph-D3QrVCxu.js} +1 -1
- package/dist/assets/{home-page-Bw8sEVuj.js → home-page-G_wcVoKB.js} +1 -1
- package/dist/assets/{index-JjcyCuGv.js → index-B15uv7yp.js} +1 -1
- package/dist/assets/{index-6jhjDpD6.js → index-B4bupjpl.js} +1 -1
- package/dist/assets/{index-Bcta8bk3.js → index-BAUEorbi.js} +6 -6
- package/dist/assets/{index-tRzawE5e.js → index-BHbs0MCK.js} +1 -1
- package/dist/assets/{index-Bkwu2tTQ.js → index-BmQXWWla.js} +1 -1
- package/dist/assets/{index-BQj2RWzc.js → index-C1cP1AR5.js} +1 -1
- package/dist/assets/{index-CdNgRkVT.js → index-CQcHAMVd.js} +1 -1
- package/dist/assets/{index-CSy7Kxz1.js → index-C_Ik03gu.js} +1 -1
- package/dist/assets/{index-DwHRjKyo.js → index-CqnZIJEj.js} +1 -1
- package/dist/assets/{index-CaGSC-6k.js → index-CvFpQyWQ.js} +1 -1
- package/dist/assets/{index-CV-uY42I.js → index-DFQc8oTV.js} +1 -1
- package/dist/assets/{index-CufiiwRr.js → index-DoFYnucb.js} +1 -1
- package/dist/assets/{index-Br4oqDgh.js → index-ES7DDfXY.js} +1 -1
- package/dist/assets/{index-CaKmvdEq.js → index-NDQkKTwE.js} +1 -1
- package/dist/assets/{index-Bw_Rh7go.js → index-Uhfiwqeu.js} +1 -1
- package/dist/assets/{index-C_kqgOXb.js → index-ZW7ZMcHC.js} +1 -1
- package/dist/assets/{index-D8ec0kQd.js → index-bAc8bvfw.js} +1 -1
- package/dist/assets/{infoDiagram-RZZSJVI2-CLz7BARX.js → infoDiagram-RZZSJVI2-VbIl4TD2.js} +1 -1
- package/dist/assets/{journeyDiagram-BLD6N6MZ-ea1xaw37.js → journeyDiagram-BLD6N6MZ-1G_8m5OU.js} +1 -1
- package/dist/assets/{json-CGzZ7BEF.js → json-BQIFRQHE.js} +1 -1
- package/dist/assets/{layout-Dxx_T5Fu.js → layout-D9RCAMw1.js} +1 -1
- package/dist/assets/{linear-0xhgjE6J.js → linear-BJ3qMTXF.js} +1 -1
- package/dist/assets/{mermaid-mN6VUGYt.js → mermaid-DLNpN9Vk.js} +3 -3
- package/dist/assets/{min-C0S9vRnd.js → min-CbDTYtGB.js} +1 -1
- package/dist/assets/{mindmap-definition-OEB2RXX2-BQglr0GN.js → mindmap-definition-OEB2RXX2-UqQW9lsd.js} +1 -1
- package/dist/assets/{pieDiagram-X7YZ5ZEZ-Bh4I4PCv.js → pieDiagram-X7YZ5ZEZ-Ot2Hrkf5.js} +1 -1
- package/dist/assets/{quadrantDiagram-F36EZAVT-DG9YWis2.js → quadrantDiagram-F36EZAVT-CwswbRMb.js} +1 -1
- package/dist/assets/{react-plotly-Xj3XKGYl.js → react-plotly-C640udVs.js} +1 -1
- package/dist/assets/{requirementDiagram-JG2LMPGF-D0LraHwS.js → requirementDiagram-JG2LMPGF-BEXUDMmC.js} +1 -1
- package/dist/assets/{run-page-BXcvFxWF.js → run-page-DJQA-kwE.js} +1 -1
- package/dist/assets/{sankeyDiagram-ATFNWWW6-DqcM---j.js → sankeyDiagram-ATFNWWW6-CcR9JYd4.js} +1 -1
- package/dist/assets/{sequenceDiagram-WK7YDQ3N-CsMJ2kiZ.js → sequenceDiagram-WK7YDQ3N-CA8ao-Vh.js} +1 -1
- package/dist/assets/{slides-component-C8FMx0N4.js → slides-component-DOIhvz4Y.js} +1 -1
- package/dist/assets/{sortBy-CPLZzu9-.js → sortBy-Ci-WL73m.js} +1 -1
- package/dist/assets/{stateDiagram-4JV6CC6H-CZLqWq3w.js → stateDiagram-4JV6CC6H-CFHisNTw.js} +1 -1
- package/dist/assets/stateDiagram-v2-7KT6RKTD-Ct85wpmG.js +1 -0
- package/dist/assets/{terminal-BfyxvY8t.js → terminal-DQvARn1F.js} +1 -1
- package/dist/assets/{time-B7JN12xP.js → time-DXvWlxvS.js} +1 -1
- package/dist/assets/{timeline-definition-3ZMEY6HS-3zsztxZX.js → timeline-definition-3ZMEY6HS-DE8Ayy-m.js} +1 -1
- package/dist/assets/{transform-YcSIPL63.js → transform-CDFo6bEc.js} +1 -1
- package/dist/assets/{tree-hzte9cco.js → tree-CI_YQWup.js} +1 -1
- package/dist/assets/{useMarimoWebSocket-Ddo0DAVC.js → useMarimoWebSocket-9x5OVFZU.js} +3 -3
- package/dist/assets/{vega-component-CYw4xJt7.js → vega-component-eUctaYcR.js} +1 -1
- package/dist/assets/{xychartDiagram-KECQ2H5Q-Cp64CgUv.js → xychartDiagram-KECQ2H5Q-CT5KtK6l.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/_baseMap-nfKKBQAG.js +0 -1
- package/dist/assets/channel-XJk9YWMd.js +0 -1
- package/dist/assets/clone-Dj6Hk00g.js +0 -1
- package/dist/assets/stateDiagram-v2-7KT6RKTD-DAo1O7e4.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-
|
|
2
|
-
var e,t=Object.defineProperty,n=(e,n,o)=>((e,n,o)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o)(e,"symbol"!=typeof n?n+"":n,o);import{a$ as o,F as r,fl as a,fm as s,fn as i,fo as l,fp as c,fq as d,R as u,fr as h,bm as f,K as m,ar as p,W as g,Y as v,Z as x,fs as y,V as b,a0 as w,ek as k,ft as N,d3 as E,dE as C,cW as j,cX as S,cY as I,cZ as A,c_ as M,c$ as T,d0 as O,fu as D,dH as _,dK as P,ak as R,fv as F,D as L,eA as z,fw as B,ap as U,cV as V,cc as $,dI as G,fx as H,fy as W,_ as q,fz as Y,dM as J,fA as K,H as X,be as Z,fB as Q,fC as ee,fD as te,dB as ne,fE as oe,X as re,bc as ae,dF as se,fF as ie,fG as le,fH as ce,bD as de,fI as ue,fJ as he,fK as fe,de as me,fL as pe,bh as ge,fM as ve,fN as xe,fO as ye,fP as be,a4 as we,dC as ke,fb as Ne,eN as Ee,fe as Ce,b6 as je,eO as Se,aq as Ie,eP as Ae,fQ as Me,fR as Te,fS as Oe,fT as De,fU as _e,fV as Pe,fW as Re,fX as Fe,fY as Le,dr as ze,fZ as Be,b9 as Ue,$ as Ve,ao as $e,bn as Ge,f_ as He,f$ as We,di as qe,cU as Ye,d2 as Je,bC as Ke,g0 as Xe,g1 as Ze,dx as Qe,g2 as et,g3 as tt,bB as nt,g4 as ot,g5 as rt,g6 as at,g7 as st,g8 as it,g9 as lt,S as ct,a1 as dt,ga as ut,ds as ht,bE as ft,eV as mt,dg as pt,gb as gt,fi as vt,bs as xt,bt as yt,bv as bt,gc as wt,gd as kt,ge as Nt,gf as Et,dG as Ct,gg as jt,bw as St,e0 as It,cT as At,gh as Mt,ez as Tt,k as Ot,j as Dt,gi as _t,gj as Pt,gk as Rt,ev as Ft,gl as Lt,gm as zt,dh as Bt,gn as Ut,go as Vt,a5 as $t,b0 as Gt,ah as Ht,gp as Wt,bg as qt,ff as Yt,gq as Jt,gr as Kt,fh as Xt,bF as Zt,eD as Qt,gs as en,gt as tn,eK as nn,gu as on,eu as rn,gv as an,gw as sn,gx as ln,gy as cn,gz as dn,gA as un,m as hn,gB as fn,gC as mn,gD as pn,t as gn,gE as vn,gF as xn,gG as yn,gH as bn,gI as wn,gJ as kn,gK as Nn,gL as En,gM as Cn,gN as jn,gO as Sn,gP as In,gQ as An,gR as Mn,gS as Tn,gT as On,gU as Dn,gV as _n,gW as Pn,gX as Rn,gY as Fn,gZ as Ln,g_ as zn,g$ as Bn,h0 as Un,h1 as Vn,h2 as $n,h3 as Gn,h4 as Hn,h5 as Wn,h6 as qn,h7 as Yn,h8 as Jn,fj as Kn,h9 as Xn,ha as Zn,hb as Qn,hc as eo,hd as to,he as no,hf as oo,hg as ro,hh as ao,hi as so,hj as io,hk as lo,hl as co,hm as uo,dO as ho,hn as fo,ho as mo,hp as po,dR as go,hq as vo,hr as xo,hs as yo,ht as bo,hu as wo,hv as ko,a6 as No,dy as Eo,hw as Co,dZ as jo,hx as So,hy as Io,a2 as Ao,hz as Mo,hA as To,fg as Oo,hB as Do,hC as _o,hD as Po,ba as Ro,eI as Fo,hE as Lo,hF as zo,hG as Bo,hH as Uo,hI as Vo,hJ as $o,hK as Go,hL as Ho,ex as Wo,hM as qo,bq as Yo,hN as Jo,bS as Ko,b1 as Xo,hO as Zo,af as Qo,hP as er,b8 as tr,hQ as nr,e3 as or,bX as rr,da as ar,hR as sr,bb as ir,hS as lr,hT as cr,hU as dr,hV as ur,hW as hr,hX as fr,hY as mr,hZ as pr,bi as gr,h_ as vr,bd as xr,h$ as yr,i0 as br,dw as wr,i1 as kr,i2 as Nr,i3 as Er,i4 as Cr,db as jr,ep as Sr,dA as Ir,i5 as Ar,b7 as Mr,i6 as Tr,em as Or,i7 as Dr,eW as _r,eX as Pr,eY as Rr,eZ as Fr,f1 as Lr,f2 as zr,f4 as Br,f5 as Ur,f9 as Vr,f6 as $r,i8 as Gr,e1 as Hr,i9 as Wr,ia as qr,ei as Yr,ib as Jr,ic as Kr,id as Xr,ie as Zr,J as Qr,G as ea,M as ta,ig as na,dD as oa,ih as ra,dJ as aa,ii as sa,ij as ia,ik as la,O as ca,il as da,im as ua,io as ha,ip as fa,et as ma,b3 as pa,iq as ga,ir as va,is as xa,f8 as ya,it as ba,e8 as wa,iu as ka,iv as Na,dv as Ea,iw as Ca,ix as ja,iy as Sa,iz as Ia,d7 as Aa,iA as Ma,iB as Ta,dN as Oa,iC as Da,iD as _a,iE as Pa,iF as Ra,iG as Fa,iH as La,iI as za,iJ as Ba,iK as Ua,iL as Va,iM as $a,iN as Ga,iO as Ha,iP as Wa,iQ as qa,dk as Ya,iR as Ja,iS as Ka,iT as Xa,iU as Za,iV as Qa,ai as es,bk as ts,iW as ns,iX as os,iY as rs,iZ as as,i_ as ss,i$ as is,j0 as ls,j1 as cs,j2 as ds,j3 as us,j4 as hs,j5 as fs,j6 as ms,eC as ps,j7 as gs,j8 as vs,j9 as xs,ja as ys,jb as bs,eh as ws,jc as ks,cL as Ns,b5 as Es,jd as Cs,je as js,jf as Ss,jg as Is,as as As,jh as Ms,ji as Ts}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-ES7DDfXY.js","./VegaLite-CZugH90p.js","./index-BAUEorbi.js","./index-BkD6C0P6.css","./time-DXvWlxvS.js","./timer-CK-RIWfW.js","./linear-BJ3qMTXF.js","./init-DLRA0X12.js","./range-CtcPcB_L.js","./zoom-COrs4lFh.js","./ordinal-DDUp3AbE.js","./colors-bszWmPJw.js","./arc-lt4NHaVr.js","./step-CNn2V7Th.js","./index-BHbs0MCK.js","./terminal-DQvARn1F.js","./terminal-DMtZkNnb.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var e,t=Object.defineProperty,n=(e,n,o)=>((e,n,o)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o)(e,"symbol"!=typeof n?n+"":n,o);import{a$ as o,F as r,fl as a,fm as s,fn as i,fo as l,fp as c,fq as d,R as u,fr as h,bm as f,K as m,ar as p,W as g,Y as v,Z as x,fs as y,V as b,a0 as w,ek as k,ft as N,d3 as E,dE as C,cW as j,cX as S,cY as I,cZ as A,c_ as M,c$ as T,d0 as O,fu as D,dH as _,dK as P,ak as R,fv as F,D as L,eA as z,fw as B,ap as U,cV as V,cc as $,dI as G,fx as H,fy as W,_ as q,fz as Y,dM as J,fA as K,H as X,be as Z,fB as Q,fC as ee,fD as te,dB as ne,fE as oe,X as re,bc as ae,dF as se,fF as ie,fG as le,fH as ce,bD as de,fI as ue,fJ as he,fK as fe,de as me,fL as pe,bh as ge,fM as ve,fN as xe,fO as ye,fP as be,a4 as we,dC as ke,fb as Ne,eN as Ee,fe as Ce,b6 as je,eO as Se,aq as Ie,eP as Ae,fQ as Me,fR as Te,fS as Oe,fT as De,fU as _e,fV as Pe,fW as Re,fX as Fe,fY as Le,dr as ze,fZ as Be,b9 as Ue,$ as Ve,ao as $e,bn as Ge,f_ as He,f$ as We,di as qe,cU as Ye,d2 as Je,bC as Ke,g0 as Xe,g1 as Ze,dx as Qe,g2 as et,g3 as tt,bB as nt,g4 as ot,g5 as rt,g6 as at,g7 as st,g8 as it,g9 as lt,S as ct,a1 as dt,ga as ut,ds as ht,bE as ft,eV as mt,dg as pt,gb as gt,fi as vt,bs as xt,bt as yt,bv as bt,gc as wt,gd as kt,ge as Nt,gf as Et,dG as Ct,gg as jt,bw as St,e0 as It,cT as At,gh as Mt,ez as Tt,k as Ot,j as Dt,gi as _t,gj as Pt,gk as Rt,ev as Ft,gl as Lt,gm as zt,dh as Bt,gn as Ut,go as Vt,a5 as $t,b0 as Gt,ah as Ht,gp as Wt,bg as qt,ff as Yt,gq as Jt,gr as Kt,fh as Xt,bF as Zt,eD as Qt,gs as en,gt as tn,eK as nn,gu as on,eu as rn,gv as an,gw as sn,gx as ln,gy as cn,gz as dn,gA as un,m as hn,gB as fn,gC as mn,gD as pn,t as gn,gE as vn,gF as xn,gG as yn,gH as bn,gI as wn,gJ as kn,gK as Nn,gL as En,gM as Cn,gN as jn,gO as Sn,gP as In,gQ as An,gR as Mn,gS as Tn,gT as On,gU as Dn,gV as _n,gW as Pn,gX as Rn,gY as Fn,gZ as Ln,g_ as zn,g$ as Bn,h0 as Un,h1 as Vn,h2 as $n,h3 as Gn,h4 as Hn,h5 as Wn,h6 as qn,h7 as Yn,h8 as Jn,fj as Kn,h9 as Xn,ha as Zn,hb as Qn,hc as eo,hd as to,he as no,hf as oo,hg as ro,hh as ao,hi as so,hj as io,hk as lo,hl as co,hm as uo,dO as ho,hn as fo,ho as mo,hp as po,dR as go,hq as vo,hr as xo,hs as yo,ht as bo,hu as wo,hv as ko,a6 as No,dy as Eo,hw as Co,dZ as jo,hx as So,hy as Io,a2 as Ao,hz as Mo,hA as To,fg as Oo,hB as Do,hC as _o,hD as Po,ba as Ro,eI as Fo,hE as Lo,hF as zo,hG as Bo,hH as Uo,hI as Vo,hJ as $o,hK as Go,hL as Ho,ex as Wo,hM as qo,bq as Yo,hN as Jo,bS as Ko,b1 as Xo,hO as Zo,af as Qo,hP as er,b8 as tr,hQ as nr,e3 as or,bX as rr,da as ar,hR as sr,bb as ir,hS as lr,hT as cr,hU as dr,hV as ur,hW as hr,hX as fr,hY as mr,hZ as pr,bi as gr,h_ as vr,bd as xr,h$ as yr,i0 as br,dw as wr,i1 as kr,i2 as Nr,i3 as Er,i4 as Cr,db as jr,ep as Sr,dA as Ir,i5 as Ar,b7 as Mr,i6 as Tr,em as Or,i7 as Dr,eW as _r,eX as Pr,eY as Rr,eZ as Fr,f1 as Lr,f2 as zr,f4 as Br,f5 as Ur,f9 as Vr,f6 as $r,i8 as Gr,e1 as Hr,i9 as Wr,ia as qr,ei as Yr,ib as Jr,ic as Kr,id as Xr,ie as Zr,J as Qr,G as ea,M as ta,ig as na,dD as oa,ih as ra,dJ as aa,ii as sa,ij as ia,ik as la,O as ca,il as da,im as ua,io as ha,ip as fa,et as ma,b3 as pa,iq as ga,ir as va,is as xa,f8 as ya,it as ba,e8 as wa,iu as ka,iv as Na,dv as Ea,iw as Ca,ix as ja,iy as Sa,iz as Ia,d7 as Aa,iA as Ma,iB as Ta,dN as Oa,iC as Da,iD as _a,iE as Pa,iF as Ra,iG as Fa,iH as La,iI as za,iJ as Ba,iK as Ua,iL as Va,iM as $a,iN as Ga,iO as Ha,iP as Wa,iQ as qa,dk as Ya,iR as Ja,iS as Ka,iT as Xa,iU as Za,iV as Qa,ai as es,bk as ts,iW as ns,iX as os,iY as rs,iZ as as,i_ as ss,i$ as is,j0 as ls,j1 as cs,j2 as ds,j3 as us,j4 as hs,j5 as fs,j6 as ms,eC as ps,j7 as gs,j8 as vs,j9 as xs,ja as ys,jb as bs,eh as ws,jc as ks,cL as Ns,b5 as Es,jd as Cs,je as js,jf as Ss,jg as Is,as as As,jh as Ms,ji as Ts}from"./index-BAUEorbi.js";import{a as Os,r as Ds,B as _s,G as Ps,g as Rs,b as Fs,M as Ls,c as zs,d as Bs,e as Us,K as Vs,s as $s,k as Gs,f as Hs,C as Ws,S as qs,h as Ys,i as Js,j as Ks,l as Xs,m as Zs,n as Qs,L as ei,o as ti,p as ni,q as oi,t as ri,v as ai,u as si,w as ii,x as li,y as ci,P as di,z as ui,A as hi,T as fi}from"./tree-CI_YQWup.js";import{b as mi,c as pi,L as gi,N as vi,I as xi,V as yi,d as bi,W as wi,F as ki,e as Ni,M as Ei,E as Ci,g as ji,f as Si,h as Ii,i as Ai,j as Mi,k as Ti,l as Oi,m as Di,s as _i,n as Pi,o as Ri,p as Fi,q as Li,r as zi,t as Bi,v as Ui,w as Vi,x as $i,y as Gi,z as Hi,B as Wi,D as qi,G as Yi,H as Ji,J as Ki,K as Xi,O as Zi,P as Qi,Q as el,S as tl,T as nl,U as ol,X as rl,R as al,u as sl,Y as il,A as ll,a as cl,C as dl,Z as ul,_ as hl,$ as fl,a0 as ml}from"./useMarimoWebSocket-9x5OVFZU.js";import{s as pl,i as gl,T as vl,c as xl}from"./transform-CDFo6bEc.js";import{g as yl}from"./timer-CK-RIWfW.js";import{i as bl}from"./zoom-COrs4lFh.js";import{s as wl}from"./sortBy-Ci-WL73m.js";import"./main-cdvIQCIX.js";import"./index-BHbs0MCK.js";import"./_baseEach-B93NjDuP.js";import"./_baseMap-D4MvCFBz.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license lucide-react v0.428.0 - ISC
|
|
5
5
|
*
|
|
@@ -11,4 +11,4 @@ var e,t=Object.defineProperty,n=(e,n,o)=>((e,n,o)=>n in e?t(e,n,{enumerable:!0,c
|
|
|
11
11
|
*
|
|
12
12
|
* This source code is licensed under the ISC license.
|
|
13
13
|
* See the LICENSE file in the root directory of this source tree.
|
|
14
|
-
*/const Fc=r.createContext({});function Lc(e,t){[e,t]=l(e,t,Fc);let{toolbarProps:n}=function(e,t){const{"aria-label":n,"aria-labelledby":o,orientation:l="horizontal"}=e;let[c,d]=r.useState(!1);a((()=>{var e;d(!(!t.current||!(null===(e=t.current.parentElement)||void 0===e?void 0:e.closest('[role="toolbar"]'))))}));const{direction:u}=s(),h="rtl"===u&&"horizontal"===l;let f=i(t);const m=r.useRef(null);return{toolbarProps:{role:c?"group":"toolbar","aria-orientation":l,"aria-label":n,"aria-labelledby":null==n?o:void 0,onKeyDownCapture:c?void 0:e=>{if(e.currentTarget.contains(e.target)){if("horizontal"===l&&"ArrowRight"===e.key||"vertical"===l&&"ArrowDown"===e.key)h?f.focusPrevious():f.focusNext();else{if(!("horizontal"===l&&"ArrowLeft"===e.key||"vertical"===l&&"ArrowUp"===e.key))return"Tab"===e.key?(e.stopPropagation(),m.current=document.activeElement,void(e.shiftKey?f.focusFirst():f.focusLast())):void 0;h?f.focusNext():f.focusPrevious()}e.stopPropagation(),e.preventDefault()}},onFocusCapture:c?void 0:e=>{var n,o;m.current&&!e.currentTarget.contains(e.relatedTarget)&&(null===(n=t.current)||void 0===n?void 0:n.contains(e.target))&&(null===(o=m.current)||void 0===o||o.focus(),m.current=null)},onBlurCapture:c?void 0:e=>{e.currentTarget.contains(e.relatedTarget)||m.current||(m.current=e.target)}}}}(e,t),o=c({...e,values:{orientation:e.orientation||"horizontal"},defaultClassName:"react-aria-Toolbar"}),f=d(e);return delete f.id,u.createElement("div",{...h(n,f),...o,ref:t,slot:e.slot||void 0,"data-orientation":e.orientation||"horizontal"},o.children)}const zc=r.forwardRef(Lc),Bc=e=>m.jsx(g,{className:"w-fit",children:m.jsxs("form",{onSubmit:t=>{t.preventDefault(),w(new Blob([e.getCellsAsJSON()],{type:"text/plain"}),`${e.proposedName}.json`),e.closeModal()},onKeyDown:t=>{"Escape"===t.key&&e.closeModal()},children:[m.jsx(v,{className:"text-accent mb-6",children:"Download unsaved changes?"}),m.jsxs(x,{className:"markdown break-words",style:{wordBreak:"break-word"},children:[m.jsx("p",{children:"This app has unsaved changes. To recover:"}),m.jsxs("ol",{children:[m.jsxs("li",{style:{paddingBottom:"10px"},children:['Click the "Download" button. This will download a file called ',m.jsxs("code",{children:[e.proposedName,".json"]}),". This file contains your code."]}),m.jsxs("li",{style:{paddingBottom:"10px"},children:["In your terminal, type",m.jsxs("code",{style:{display:"block",padding:"10px"},children:["marimo recover ",e.proposedName,".json ",">"," ",e.proposedName,".py"]}),"to overwrite ",m.jsxs("code",{children:[e.proposedName,".py"]})," with the recovered changes."]})]})]}),m.jsxs(y,{children:[m.jsx(b,{"aria-label":"Cancel",variant:"secondary","data-testid":"cancel-recovery-button",onClick:e.closeModal,children:"Cancel"}),m.jsx(b,{"data-testid":"download-recovery-button","aria-label":"Download",variant:"default",type:"submit",children:"Download"})]})]})}),Uc=e=>{const{filename:t,needsSave:n,getCellsAsJSON:o}=e,{openModal:r,closeModal:a}=f(),s=null===t?"app":t.slice(0,-3),i=()=>{n&&r(m.jsx(Bc,{getCellsAsJSON:o,proposedName:s,closeModal:a}))};return Os("global.save",i),m.jsx(p,{content:Ds("global.save"),children:m.jsx(_s,{onClick:i,id:"save-button","aria-label":"Save",className:"rectangle",color:n?"yellow":"gray",children:m.jsx(gc,{strokeWidth:1.5,size:18})})})},Vc=()=>{const{selectedLayout:e}=mi(),{setLayoutView:t}=pi();return C()&&!Rs("wasm_layouts")?null:m.jsxs(j,{"data-testid":"layout-select",value:e,onValueChange:e=>t(e),children:[m.jsx(S,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:m.jsx(I,{placeholder:"Select a view"})}),m.jsx(A,{children:m.jsxs(M,{children:[m.jsx(T,{children:"View as"}),gi.map((e=>m.jsx(O,{value:e,children:m.jsxs("div",{className:"flex items-center gap-1.5 leading-5",children:[$c(e),m.jsx("span",{children:Hc(e)})]})},e)))]})})]})};function $c(e){const t=Gc(e);return m.jsx(t,{className:"h-4 w-4"})}function Gc(e){switch(e){case"vertical":return Ql;case"grid":return Ps;case"slides":return hc;default:return k(e),N}}function Hc(e){return E(e)}function Wc(){const[e,t]=function(e,t){const n=new D(e,t),[o,a]=r.useState((()=>n.get()));return[o,e=>{a(e),n.set(e)}]}("marimo:commands",[]);return{recentCommands:e,addRecentCommand:n=>{const o=(r=[n,...e],[...new Set(r)]);var r;t(o.slice(0,3))}}}function qc(e){return void 0!==e.dropdown}function Yc(e,t=""){return e.flatMap((e=>e.label?qc(e)?Yc(e.dropdown,`${t+e.label} > `):{...e,label:t+e.label}:[]))}const Jc=({children:e,layerTop:t=!1})=>{const[n,o]=u.Children.toArray(e),r=t?"top-[-1px] left-[-1px]":"bottom-[-1px] right-[-1px]";return m.jsxs("div",{className:"multi-icon relative w-fit",children:[n,m.jsx("div",{className:`second-icon absolute ${r} rounded-full`,children:o})]})};function Kc(){const e=P(),{prepareForRun:t}=L();return R((async n=>{if(0===n.length)return;const{cellHandles:o,cellData:r}=e,a=[];for(const e of n){const n=o[e];n.current?(a.push(z(n.current.editorView)),n.current.registerRun()):(t({cellId:e}),a.push(r[e].code))}await B({cellIds:n,codes:a}).catch((e=>{U.error(e)}))}))}const Xc=V(null),Zc=V(!1),Qc=e=>{$(window,"keydown",(t=>{var n;(t.ctrlKey||t.metaKey)&&"z"===t.key&&(t.preventDefault(),t.stopPropagation(),null==(n=e.onClick)||n.call(e,t))}),{capture:!0});const t=e.children??"Undo";return m.jsxs(b,{"data-testid":"undo-button",size:"sm",variant:"outline",...e,children:[t," ",m.jsx(Fs,{className:"ml-2",shortcut:"cmd-z"})]})};function ed(){const{deleteCell:e,undoDeleteCell:t}=L();return R((n=>{if(G.get(H))return;const{cellId:o}=n;e({cellId:o}),W({cellId:o}).catch((()=>{t()}));const{dismiss:r}=q({title:"Cell deleted",description:"You can bring it back by clicking undo or through the command palette.",action:m.jsx(Qc,{"data-testid":"undo-delete-button",onClick:()=>{t(),r()}})})}))}function td(e,t,n,o=G){if(t in o.get(Y))return!1;const{cellData:r,cellIds:a}=o.get(J),s=new RegExp(`import[ \t]+${e}[ \t]+as[ \t]+${t}`,"g");for(const i of a.inOrderIds)if(s.test(r[i].code))return!1;return n(`import ${e} as ${t}`),!0}function nd(e,t,n){return td("marimo","mo",(o=>{const r=K.create();t({cellId:n??"__end__",before:!1,code:o,lastCodeRun:e?o:void 0,newCellId:r,autoFocus:!1}),e&&B({cellIds:[r],codes:[o]})}))}function od({cell:e}){const{createNewCell:t,updateCellConfig:n,updateCellCode:o,updateCellName:r,moveCell:a,sendToTop:s,sendToBottom:i,addColumnBreakpoint:l}=L(),c=function(e){const t=Kc();return R((()=>{void 0!==e&&t([e])}))}(null==e?void 0:e.cellId),d=!X(H),u=ed(),{openModal:h}=f(),p=Z(Xc),x=X(Q),y=X(ee),b=te(),w=X(ne),k=X(oe);if(!e||w)return[];const{cellId:N,config:E,getEditorView:C,name:j,hasOutput:S,status:I}=e,A=b.inOrderIds.indexOf(N),M=C(),T=async()=>{const e={disabled:!E.disabled};await ye({configs:{[N]:e}}),n({cellId:N,config:e})};return[[{icon:m.jsx(Ac,{size:13,strokeWidth:1.5}),label:"Name",disableClick:!0,handle:e=>{null==e||e.stopPropagation(),null==e||e.preventDefault()},handleHeadless:()=>{h(m.jsxs(g,{children:[m.jsx(re,{children:m.jsx(v,{children:"Rename cell"})}),m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx(ae,{htmlFor:"cell-name",children:"Cell name"}),m.jsx(vi,{placeholder:`cell_${A}`,value:j,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),h(null))},onChange:e=>r({cellId:N,name:e})})]})]}))},rightElement:m.jsx(vi,{placeholder:`cell_${A}`,value:j,onChange:e=>r({cellId:N,name:e})})},{icon:m.jsx(uc,{size:13,strokeWidth:1.5}),label:"Run cell",hotkey:"cell.run",hidden:"running"===I||"queued"===I||"disabled-transitively"===I||E.disabled,handle:()=>c()},{icon:m.jsx(bc,{size:13,strokeWidth:1.5}),label:"AI completion",hidden:!x,handle:()=>{p((e=>(null==e?void 0:e.cellId)===N?null:{cellId:N}))},hotkey:"cell.aiCompletion"},{icon:m.jsx(xi,{size:13,strokeWidth:1.5}),label:"Export output as PNG",hidden:!S,handle:()=>function(e){const t=document.getElementById(`output-${e}`);t&&(t.classList.add("printing-output"),_(t,"result.png").finally((()=>{t.classList.remove("printing-output")})))}(N)},{icon:m.jsx(se,{size:13,strokeWidth:1.5}),label:"Format cell",hotkey:"cell.format",handle:()=>{M&&ie({[N]:M},o)}},{icon:m.jsx(Ls,{}),label:"View as Markdown",hotkey:"cell.viewAsMarkdown",hidden:"python"!==le(M),handle:()=>{M&&(nd(y,t),ce(M,"markdown",{force:!0}))}},{icon:m.jsx(de,{size:13,strokeWidth:1.5}),label:"View as SQL",hidden:!ue(M,"sql"),handle:()=>{M&&ce(M,"sql")}},{icon:m.jsx(zs,{}),label:"View as Python",hotkey:"markdown"===le(M)?"cell.viewAsMarkdown":void 0,hidden:!ue(M,"python"),handle:()=>{M&&(nd(y,t),ce(M,"python"))}},{icon:E.hide_code?m.jsx(he,{size:13,strokeWidth:1.5}):m.jsx(fe,{size:13,strokeWidth:1.5}),label:E.hide_code?"Show code":"Hide code",handle:async()=>{const e={hide_code:!E.hide_code};await ye({configs:{[N]:e}}),n({cellId:N,config:e}),M&&(e.hide_code?M.contentDOM.blur():M.focus())},hotkey:"cell.hideCode"},{icon:E.disabled?m.jsx(Pc,{size:13,strokeWidth:1.5}):m.jsx(Rc,{size:13,strokeWidth:1.5}),label:"Reactive execution",rightElement:m.jsx(me,{"data-testid":"cell-disable-switch",checked:!E.disabled,size:"sm",onCheckedChange:T}),handle:T}],[{icon:m.jsxs(Jc,{children:[m.jsx(Dl,{size:13,strokeWidth:1.5}),m.jsx(pe,{size:8,strokeWidth:2})]}),label:"Create cell above",hotkey:"cell.createAbove",handle:()=>t({cellId:N,before:!0})},{icon:m.jsxs(Jc,{children:[m.jsx(Dl,{size:13,strokeWidth:1.5}),m.jsx(ge,{size:8,strokeWidth:2})]}),label:"Create cell below",hotkey:"cell.createBelow",handle:()=>t({cellId:N,before:!1})},{icon:m.jsx(pe,{size:13,strokeWidth:1.5}),label:"Move cell up",hotkey:"cell.moveUp",handle:()=>a({cellId:N,before:!0})},{icon:m.jsx(ge,{size:13,strokeWidth:1.5}),label:"Move cell down",hotkey:"cell.moveDown",handle:()=>a({cellId:N,before:!1})},{icon:m.jsx(Tl,{size:13,strokeWidth:1.5}),label:"Send to top",hotkey:"cell.sendToTop",handle:()=>s({cellId:N})},{icon:m.jsx(Ml,{size:13,strokeWidth:1.5}),label:"Send to bottom",hotkey:"cell.sendToBottom",handle:()=>i({cellId:N})},{icon:m.jsx(ve,{size:13,strokeWidth:1.5}),label:"Break into new column",hotkey:"cell.addColumnBreakpoint",hidden:"columns"!==k,handle:()=>l({cellId:N})}],[{label:"Delete",hidden:!d,variant:"danger",icon:m.jsx(xe,{size:13,strokeWidth:1.5}),handle:()=>{u({cellId:N})}}]].map((e=>e.filter((e=>!e.hidden)))).filter((e=>e.length>0))}const rd=V(null);function ad(){return X(rd)}const sd=V((e=>{const t=e(rd);return t?t===be?null:id(t,e(J)):null}));function id(e,t){var n;const{cellData:o,cellHandles:r,cellRuntime:a}=t,s=o[e],i=a[e],l=null==(n=r[e])?void 0:n.current;if(!s||!l)return null;return{cellId:e,name:s.name,config:s.config,status:i?i.status:"idle",getEditorView:()=>l.editorView,hasOutput:null!=(null==i?void 0:i.output)}}function ld(){const{theme:e}=we(),[t,n]=ke(),[o,r]=Ne(),a=async e=>{await Ee({config:e}).then((()=>{n(e)}))};return[...Bs().filter((e=>e!==o.width)).map((e=>({label:`App config > Set width=${e}`,handle:()=>{(async e=>{await Ce({config:e}).then((()=>{r(e)}))})({...o,width:e})}}))),{label:"Config > Toggle dark mode",handle:()=>{a({...t,display:{...t.display,theme:"dark"===e?"light":"dark"}})}},{label:"Config > Switch keymap to VIM",hidden:"vim"===t.keymap.preset,handle:()=>{a({...t,keymap:{...t.keymap,preset:"vim"}})}},{label:"Config > Switch keymap to default (current: VIM)",hidden:"default"===t.keymap.preset,handle:()=>{a({...t,keymap:{...t.keymap,preset:"default"}})}},{label:"Config > Disable GitHub Copilot",handle:()=>{a({...t,completion:{...t.completion,copilot:!1}})},hidden:"github"!==t.completion.copilot},{label:"Config > Enable GitHub Copilot",handle:()=>{a({...t,completion:{...t.completion,copilot:"github"}})},hidden:"github"===t.completion.copilot}].filter((e=>!e.hidden))}const cd=V(!1),dd=()=>{const[e,t]=je(cd),n=Us(),o=X(sd),r=X(Se);let a=od({cell:o}).flat();a=Yc(a);const s=ld();let i=Cd();i=[...Yc(i),...Yc(s)];const l=i.filter((e=>!e.hotkey)),c=Ie.keyBy(l,(e=>e.label)),{recentCommands:d,addRecentCommand:u}=Wc(),h=new Set(d);$(document,"keydown",(e=>{Ae(r.getHotkey("global.commandPalette").key)(e)&&(e.preventDefault(),t((e=>!e)))}));const f=(e,o)=>{const a=n[e];if(!a)return null;const s=r.getHotkey(e);return m.jsxs(Fe,{disabled:o.disabled,onSelect:()=>{u(e),t(!1),requestAnimationFrame((()=>{a()}))},value:s.name,children:[m.jsxs("span",{children:[s.name,o.tooltip&&m.jsx("span",{className:"ml-2",children:o.tooltip})]}),m.jsx(Le,{children:m.jsx(Vs,{shortcut:s.key})})]},e)},p=(e,n,o={},r)=>m.jsxs(Fe,{disabled:o.disabled,onSelect:()=>{u(e),t(!1),requestAnimationFrame((()=>{n()}))},value:e,children:[m.jsxs("span",{children:[e,o.tooltip&&m.jsxs("span",{className:"ml-2",children:["(",o.tooltip,")"]})]}),r]},e);return m.jsxs(Me,{open:e,onOpenChange:t,children:[m.jsx(Te,{placeholder:"Type to search..."}),m.jsxs(Oe,{children:[m.jsx(De,{children:"No results found."}),d.length>0&&m.jsxs(m.Fragment,{children:[m.jsx(_e,{heading:"Recently Used",children:d.map((e=>{const t=c[e];return Pe(e)?f(e,{disabled:null==t?void 0:t.disabled,tooltip:null==t?void 0:t.tooltip}):t&&!qc(t)?p(t.label,t.handleHeadless||t.handle,{disabled:t.disabled,tooltip:t.tooltip}):null}))}),m.jsx(Re,{})]}),m.jsxs(_e,{heading:"Commands",children:[r.iterate().map((e=>{if(h.has(e))return null;const t=c[e];return f(e,{disabled:null==t?void 0:t.disabled,tooltip:null==t?void 0:t.tooltip})})),l.map((e=>h.has(e.label)?null:p(e.label,e.handleHeadless||e.handle,{disabled:e.disabled,tooltip:e.tooltip}))),a.map((e=>h.has(e.label)?null:p(`Cell > ${e.label}`,e.handleHeadless||e.handle,{disabled:e.disabled,tooltip:e.tooltip})))]})]})]})},ud="https://static.marimo.app",hd=({onClose:e})=>{const[t,n]=r.useState(""),o=`${t}-${r.useRef(Math.random().toString(36).slice(2,6)).current}`,a=`${ud}/static/${o}`;return m.jsx(g,{className:"w-fit",children:m.jsxs("form",{onSubmit:async t=>{t.preventDefault(),e();const n=await ze({download:!1,includeCode:!0,files:yi.INSTANCE.filenames()}),r=q({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${ud}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:n,path:o})}).catch((()=>{r.dismiss(),q({title:"Error uploading static page",description:m.jsxs("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",m.jsx("a",{href:Be.issuesPage,target:"_blank",rel:"noreferrer",className:"underline",children:"GitHub"}),"."]})})})),r.dismiss(),q({title:"Static page uploaded!",description:m.jsxs("div",{children:["The URL has been copied to your clipboard.",m.jsx("br",{}),"You can share it with anyone."]})})},children:[m.jsxs(re,{children:[m.jsx(v,{children:"Share static notebook"}),m.jsxs(x,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",m.jsx("a",{href:ud,target:"_blank",rel:"noreferrer",children:ud}),"."]})]}),m.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[m.jsx(Ue,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:t,placeholder:"Notebook slug",onChange:e=>{const t=e.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,"");n(t)},required:!0,autoComplete:"off"}),m.jsxs("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(fd,{text:a}),m.jsx("span",{className:"text-primary",children:a})]})]})]}),m.jsxs(y,{children:[m.jsx(b,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:e,children:"Cancel"}),m.jsx(b,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:()=>{navigator.clipboard.writeText(a)},children:"Create"})]})]})})},fd=e=>{const[t,n]=u.useState(!1),o=$e.stopPropagation((t=>{t.preventDefault(),navigator.clipboard.writeText(e.text),n(!0),setTimeout((()=>n(!1)),2e3)}));return m.jsx(p,{content:"Copied!",open:t,children:m.jsx(b,{"data-testid":"copy-static-notebook-url-button",onClick:o,size:"xs",variant:"secondary",children:m.jsx(Ve,{size:14,strokeWidth:1.5})})})};function md(){const{openConfirm:e}=f(),t=Z(bi);return()=>{e({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:m.jsx(Ge,{onClick:async()=>{t({state:wi.CLOSING}),await He(),window.location.reload()},"aria-label":"Confirm Restart",children:"Restart"})})}}const pd=new We("marimo:sidebar",qe.object({selectedPanel:qe.string().optional().transform((e=>e)),isSidebarOpen:qe.boolean(),isTerminalOpen:qe.boolean()}),(function(){return{selectedPanel:"variables",isSidebarOpen:!1,isTerminalOpen:!1}}));const{reducer:gd,createActions:vd,valueAtom:xd,useActions:yd}=Ye((()=>pd.get()),{openApplication:(e,t)=>({...e,selectedPanel:t,isSidebarOpen:!e.isSidebarOpen||e.selectedPanel!==t}),toggleSidebarPanel:e=>({...e,isSidebarOpen:!e.isSidebarOpen}),setIsSidebarOpen:(e,t)=>({...e,isSidebarOpen:t}),toggleTerminal:e=>({...e,isTerminalOpen:!e.isTerminalOpen}),setIsTerminalOpen:(e,t)=>({...e,isTerminalOpen:t})},[(e,t)=>pd.set(t)]),bd=()=>{const e=X(xd);return e.isSidebarOpen?e:{...e,selectedPanel:void 0}};function wd(){return yd()}const kd=[{type:"files",Icon:Wl,tooltip:"View files",position:"sidebar"},{type:"variables",Icon:Je,tooltip:"Explore variables",position:"sidebar"},{type:"datasources",Icon:de,tooltip:"Explore data sources",position:"sidebar"},{type:"dependencies",Icon:oc,tooltip:"Explore dependencies",position:"sidebar"},{type:"packages",Icon:Al,tooltip:"Manage packages",position:"sidebar"},{type:"outline",Icon:xc,tooltip:"View outline",position:"sidebar"},{type:"documentation",Icon:Mc,tooltip:"View live docs",position:"sidebar"},{type:"logs",Icon:Ke,tooltip:"Notebook logs",position:"sidebar"},{type:"snippets",Icon:kc,tooltip:"Snippets",position:"sidebar"},{type:"scratchpad",Icon:rc,hidden:!Rs("scratchpad"),tooltip:"Scratchpad",position:"sidebar"},{type:"errors",Icon:Xe,tooltip:"View errors",position:"footer"}];function Nd(){const e=Z(Ze);return r.useCallback((()=>{const t=document.getElementsByClassName("output-area"),n=window.innerHeight||document.documentElement.clientHeight;let o=null;for(const e of Array.from(t)){const t=e.getBoundingClientRect();if(t.top>=0&&t.top<=n||t.bottom>=0&&t.bottom<=n){o=Qe.parse(e.parentNode.id);break}}e((e=>({mode:et(e.mode),cellAnchor:o}))),requestAnimationFrame((()=>{var e;null!==o&&(null==(e=document.getElementById(Qe.create(o)))||e.scrollIntoView())}))}),[e])}const Ed=e=>{null==e||e.preventDefault(),null==e||e.stopPropagation()};function Cd(){const[e]=rt(),{openModal:t,closeModal:n}=f(),{openApplication:o}=wd(),{selectedPanel:r}=bd(),[a]=je(Ze),s=X(ne),i=P(),{updateCellConfig:l,undoDeleteCell:c}=L(),d=md(),u=function(e){const{openPrompt:t,closeModal:n}=f();return()=>{if(!e)return null;const o=tt.guessDeliminator(e),r=nt.basename(e);t({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${r}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:t=>{const r=o.join(nt.dirname(e),t);ot({source:e,destination:r}).then((()=>{n(),q({title:"Notebook copied",description:"A copy of the notebook has been created."}),window.open(`/?file=${r}`,"_blank")}))}})}}(e),h=Z(cd),p=Z($s),g=Z(Gs),v=at(i),x=st(i),{selectedLayout:y}=mi(),{setLayoutView:b}=pi(),k=Nd();return[{icon:m.jsx(yc,{size:14,strokeWidth:1.5}),label:"Share",handle:Ed,dropdown:[{icon:m.jsx(it,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",handle:async()=>{t(m.jsx(hd,{onClose:n}))}},{icon:m.jsx(Zl,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",handle:async()=>{const e=await lt(),t=ct({code:e.contents});window.navigator.clipboard.writeText(t),q({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:m.jsx(dt,{size:14,strokeWidth:1.5}),label:"Download",handle:Ed,dropdown:[{icon:m.jsx(ki,{size:14,strokeWidth:1.5}),label:"Download as HTML",handle:async()=>{e?await Ni({filename:e,includeCode:!0}):q({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},{icon:m.jsx(ki,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{e?await Ni({filename:e,includeCode:!1}):q({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},{icon:m.jsx(Ls,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{const e=await ut({download:!1});w(new Blob([e],{type:"text/plain"}),ht.toMarkdown(document.title))}},{icon:m.jsx(Fl,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{const e=await lt();w(new Blob([e.contents],{type:"text/plain"}),ht.toPY(document.title))}},{divider:!0,icon:m.jsx(xi,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:"present"!==a.mode,tooltip:"present"===a.mode?void 0:m.jsxs("span",{children:["Only available in app view. ",m.jsx("br",{}),"Toggle with: ",Ds("global.hideCode",!1)]}),handle:async()=>{const e=document.getElementById("App");e&&await _(e,document.title)}},{icon:m.jsx(ft,{size:14,strokeWidth:1.5}),label:"Download as PDF",disabled:"present"!==a.mode,tooltip:"present"===a.mode?void 0:m.jsxs("span",{children:["Only available in app view. ",m.jsx("br",{}),"Toggle with: ",Ds("global.hideCode",!1)]}),handle:async()=>{const e=new Event("export-beforeprint"),t=new Event("export-afterprint");window.dispatchEvent(e),setTimeout((()=>window.print()),0),setTimeout((()=>window.dispatchEvent(t)),0)}}]},{divider:!0,icon:m.jsx(lc,{size:14,strokeWidth:1.5}),label:"Helper panel",handle:Ed,dropdown:kd.flatMap((({type:e,Icon:t,hidden:n})=>{return n?[]:{label:E(e),rightElement:(a=r===e,m.jsx("div",{className:"w-8 flex justify-end",children:a&&m.jsx(pt,{size:14})})),icon:m.jsx(t,{size:14,strokeWidth:1.5}),handle:()=>o(e)};var a}))},{icon:m.jsx(hc,{size:14,strokeWidth:1.5}),label:"Present as",handle:Ed,dropdown:[{icon:"present"===a.mode?m.jsx(mt,{size:14,strokeWidth:1.5}):m.jsx(Xl,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{k()}},...gi.map(((e,t)=>{const n=Gc(e);return{divider:0===t,label:Hc(e),icon:m.jsx(n,{size:14,strokeWidth:1.5}),rightElement:m.jsx("div",{className:"w-8 flex justify-end",children:y===e&&m.jsx(pt,{size:14})}),handle:()=>{b(e),"edit"===a.mode&&k()}}}))]},{icon:m.jsx(Gl,{size:14,strokeWidth:1.5}),label:"Create notebook copy",hidden:!e||C(),handle:u},{icon:m.jsx(_l,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!e,handle:async()=>{const e=await lt();navigator.clipboard.writeText(e.contents),q({title:"Copied",description:"Code copied to clipboard."})}},{icon:m.jsx(Rc,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:0===v.length||s,handle:async()=>{const e=v.map((e=>e.id)),t=Ie.fromEntries(e.map((e=>[e,{disabled:!1}])));await ye({configs:t});for(const n of e)l({cellId:n,config:{disabled:!1}})}},{icon:m.jsx(Pc,{size:14,strokeWidth:1.5}),label:"Disable all cells",hidden:0===x.length||s,handle:async()=>{const e=x.map((e=>e.id)),t=Ie.fromEntries(e.map((e=>[e,{disabled:!0}])));await ye({configs:t});for(const n of e)l({cellId:n,config:{disabled:!0}})}},{icon:m.jsx(Tc,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!gt(i)||s,handle:()=>{c()}},{divider:!0,icon:m.jsx(Ll,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>h((e=>!e))},{icon:m.jsx(vt,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>p((e=>!e))},{icon:m.jsx(Kl,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>g((e=>!e))},{icon:m.jsx(Il,{size:14,strokeWidth:1.5}),label:"Open documentation",handle:()=>{window.open("https://docs.marimo.io","_blank")}},{divider:!0,icon:m.jsx(Jl,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:()=>{window.location.href=document.baseURI}},{icon:m.jsx(Sc,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:d}].filter((e=>!e.hidden))}const jd=()=>{const e=Cd(),t=m.jsx(_s,{"aria-label":"Config",shape:"circle",size:"small",className:"h-[27px] w-[27px]","data-testid":"notebook-menu-dropdown",color:"hint-green",children:m.jsx(Ei,{strokeWidth:1.8})}),n=e=>m.jsxs(m.Fragment,{children:[e.icon&&m.jsx("span",{className:"flex-0 mr-2",children:e.icon}),m.jsx("span",{className:"flex-1",children:e.labelElement||e.label}),e.hotkey&&m.jsx(Hs,{shortcut:e.hotkey,className:"ml-4"}),e.rightElement]}),o=e=>{const t=m.jsx(St,{variant:e.variant,disabled:e.disabled,onSelect:t=>e.handle(t),"data-testid":`notebook-menu-dropdown-${e.label}`,children:n(e)},e.label);return e.tooltip?m.jsx(p,{content:e.tooltip,side:"left",delayDuration:100,children:m.jsx("span",{children:t})},e.label):t};return m.jsxs(xt,{modal:!1,children:[m.jsx(yt,{asChild:!0,children:t}),m.jsxs(bt,{align:"end",className:"no-print w-[240px]",children:[e.map((e=>e.hidden?null:e.dropdown?m.jsxs(wt,{children:[m.jsx(kt,{"data-testid":`notebook-menu-dropdown-${e.label}`,children:n(e)}),m.jsx(Nt,{children:m.jsx(Et,{children:e.dropdown.map((e=>m.jsxs(u.Fragment,{children:[e.divider&&m.jsx(Ct,{}),o(e)]},e.label)))})})]},e.label):m.jsxs(u.Fragment,{children:[e.divider&&m.jsx(Ct,{}),o(e)]},e.label))),m.jsx(Ct,{}),m.jsx("div",{className:"flex-1 px-2 text-xs text-muted-foreground",children:m.jsxs("span",{children:["Version: ",jt()]})})]})]})},Sd=It({findText:"",replaceText:"",caseSensitive:!1,wholeWord:!1,regexp:!1,isOpen:!1,currentView:void 0},((e,t)=>{if(void 0===t)return e;switch(t.type){case"setFind":return{...e,findText:t.find};case"setReplace":return{...e,replaceText:t.replace};case"setCaseSensitive":return{...e,caseSensitive:t.caseSensitive};case"setWholeWord":return{...e,wholeWord:t.wholeWord};case"setRegex":return{...e,regexp:t.regexp};case"setIsOpen":return{...e,isOpen:t.isOpen};case"setCurrentView":return{...e,currentView:{view:t.view,range:t.range}};case"clearCurrentView":return{...e,currentView:void 0}}}));function Id(e){if([...document.querySelectorAll('[role="dialog"][data-state="open"]')].some((e=>e instanceof HTMLElement&&e.childNodes.length>0)))return!1;if(e){const t=e.state.selection.main,n=e.state.sliceDoc(t.from,t.to);n?(G.set(Sd,{type:"setFind",find:n}),G.set(Sd,{type:"setCurrentView",view:e,range:{from:t.from,to:t.to}})):G.set(Sd,{type:"setCurrentView",view:e,range:{from:0,to:0}})}return G.get(Sd).isOpen?(G.set(Sd,{type:"setIsOpen",isOpen:!1}),requestAnimationFrame((()=>{G.set(Sd,{type:"setIsOpen",isOpen:!0})})),!0):(G.set(Sd,{type:"setIsOpen",isOpen:!0}),!0)}function Ad(){return!!G.get(Sd).isOpen&&(G.set(Sd,{type:"setIsOpen",isOpen:!1}),!0)}function Md(e){return At("create"in e,'Expected query to have a "create" method'),e}function Td(e){return()=>{const t=G.get(Sd),n=new Mt({search:t.findText,caseSensitive:t.caseSensitive,regexp:t.regexp,replace:t.replaceText,wholeWord:t.wholeWord});return!!n.valid&&e({query:Md(n).create(),search:n})}}const Od=e=>Td((({query:t})=>{const n=Tt(),o=G.get(Sd).currentView||{view:n[0],range:{from:0,to:0}};let r=o.range.to;"prev"===e&&(n.reverse(),r=o.range.from);let a=n.indexOf(o.view);a<0&&(a=0);const s=[...n,...n].slice(a);for(const i of s){const n="next"===e?t.nextMatch(i.state,0,r??0):t.prevMatch(i.state,r??i.state.doc.length,i.state.doc.length);if(!n){r=null,i.dispatch({selection:Ot.single(0)});continue}const o=Ot.single(n.from,n.to);return i.dispatch({selection:o,effects:[Dt.scrollIntoView(o.main,{y:"center"})],userEvent:"select.search"}),G.set(Sd,{type:"setCurrentView",view:i,range:{from:n.from,to:n.to}}),n}return!1})),Dd=Od("next"),_d=Od("prev"),Pd=Td((({query:e})=>{var t;const n=Tt(),o=[];for(const r of n){if(r.state.readOnly)continue;const n=null==(t=e.matchAll(r.state,1e9))?void 0:t.map((t=>{const{from:n,to:o}=t;return{from:n,to:o,insert:e.getReplacement(t)}}));if(!n||0===n.length)continue;const a=r.state.doc.toString();o.push((()=>{r.dispatch({changes:[{from:0,to:r.state.doc.length,insert:a}],userEvent:"input.replace.all"})})),r.dispatch({changes:n,userEvent:"input.replace.all"})}return()=>{for(const e of o)e()}})),Rd=Td((({query:e})=>{const t=Tt(),n=G.get(Sd).currentView||{view:t[0],range:{from:0,to:0}};let o=n.range.from,r=t.indexOf(n.view);r<0&&(r=0);const a=[...t,...t].slice(r);for(const s of a){const t=e.nextMatch(s.state,0,o??0);if(!t){o=null,s.dispatch({selection:Ot.single(0)});continue}const n=s.state.toText(e.getReplacement(t));return s.dispatch({changes:[{from:t.from,to:t.to,insert:n}],userEvent:"input.replace"}),Dd()}return!1})),Fd=Td((({query:e})=>{const t=Tt();let n=0;const o=new Map;for(const r of t){const t=e.matchAll(r.state,1e9)||[];for(const e of t){const{from:t,to:a}=e,s=o.get(r)||new Map;s.set(`${t}:${a}`,n++),o.set(r,s)}}return{count:n,position:o}})),Ld=_t.define();function zd(){const e=Tt();for(const t of e)t.state.readOnly||t.dispatch({effects:Ld.of(new Mt({search:""}))})}const Bd=Pt.define({create(){const e=G.get(Sd);return Md(new Mt({search:e.findText,caseSensitive:e.caseSensitive,regexp:e.regexp,replace:e.replaceText,wholeWord:e.wholeWord})).create()},update(e,t){for(const n of t.effects)n.is(Ld)&&(e=Md(n.value).create());return e}}),Ud=Rt.mark({class:"cm-searchMatch"}),Vd=Rt.mark({class:"cm-searchMatch cm-searchMatch-selected"}),$d=Ft.fromClass(class{constructor(e){n(this,"decorations"),this.view=e,this.decorations=this.highlight(e.state.field(Bd))}update(e){const t=e.state.field(Bd);(t!==e.startState.field(Bd)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight(e){if(!e.spec.valid)return Rt.none;const{view:t}=this,n=new Lt,o=t.visibleRanges,r=o.length;for(let a=0;a<r;a++){let{to:s}=o[a];const{from:i}=o[a];for(;a<r-1&&s>o[a+1].from-500;)s=o[++a].to;e.highlight(t.state,i,s,((e,o)=>{const r=t.state.selection.ranges.some((t=>t.from===e&&t.to===o));n.add(e,o,r?Vd:Ud)}))}return n.finish()}},{decorations:e=>e.decorations}),Gd=Dt.baseTheme({"&light .cm-searchMatch":{backgroundColor:"#99ff7780"},"&dark .cm-searchMatch":{backgroundColor:"#22bb0070"},"&light .cm-searchMatch-selected":{backgroundColor:"transparent"},"&dark .cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff88 !important"}}),Hd=()=>{var e;const[t,n]=r.useState(!1),[o,a]=je(Sd),[s,i]=r.useState(),l=r.useRef(null),c=X(Se);if(Os("cell.findAndReplace",(()=>(!t||!o.isOpen)&&Id())),r.useEffect((()=>{o.isOpen&&l.current&&(l.current.focus(),l.current.select())}),[o.isOpen]),r.useEffect((()=>{if(!o.isOpen)return void zd();if(""===o.findText)return i(void 0),void zd();const e=Fd();i(!1===e?void 0:e),function(){const e=G.get(Sd),t=Tt();for(const n of t)n.state.readOnly||n.dispatch({effects:Ld.of(new Mt({search:e.findText,caseSensitive:e.caseSensitive,regexp:e.regexp,replace:e.replaceText,wholeWord:e.wholeWord}))})}()}),[o.findText,o.isOpen,o.caseSensitive,o.regexp,o.wholeWord]),!o.isOpen)return null;const d=o.currentView,u=d&&s?null==(e=s.position.get(d.view))?void 0:e.get(`${d.range.from}:${d.range.to}`):void 0;return m.jsx(zt,{restoreFocus:!0,autoFocus:!0,children:m.jsxs("div",{onFocus:()=>n(!0),onClick:e=>{e.stopPropagation(),e.preventDefault()},onBlur:()=>n(!1),className:"fixed top-0 right-0 w-[500px] flex flex-col bg-[var(--sage-1)] p-4 z-50 mt-2 mr-3 rounded-md shadow-lg border gap-2 print:hidden",onKeyDown:e=>{"Escape"===e.key&&a({type:"setIsOpen",isOpen:!1})},children:[m.jsx("div",{className:"absolute top-0 right-0",children:m.jsx(b,{"data-testid":"close-find-replace-button",onClick:()=>a({type:"setIsOpen",isOpen:!1}),size:"xs",variant:"text",children:m.jsx(Bt,{className:"w-4 h-4"})})}),m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsxs("div",{className:"flex flex-col flex-2 gap-2 w-[55%]",children:[m.jsx(Ue,{ref:l,"data-testid":"find-input",value:o.findText,autoFocus:!0,className:"mr-2 mb-0",placeholder:"Find",onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey?_d():Dd())},onChange:e=>{a({type:"setFind",find:e.target.value})}}),m.jsx(Ue,{"data-testid":"replace-input",value:o.replaceText,placeholder:"Replace",onChange:e=>{a({type:"setReplace",replace:e.target.value})}})]}),m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("div",{className:"flex items-center gap-[2px]",children:[m.jsx(p,{content:"Case Sensitive",children:m.jsx(Ut,{size:"sm",pressed:o.caseSensitive,"data-state":o.caseSensitive?"on":"off",onPressedChange:e=>a({type:"setCaseSensitive",caseSensitive:e}),children:m.jsx(Vt,{className:"w-4 h-4"})})}),m.jsx(p,{content:"Match Whole Word",children:m.jsx(Ut,{size:"sm",pressed:o.wholeWord,"data-state":o.wholeWord?"on":"off",onPressedChange:e=>a({type:"setWholeWord",wholeWord:e}),children:m.jsx(Dc,{className:"w-4 h-4"})})}),m.jsx(p,{content:"Use Regular Expression",children:m.jsx(Ut,{size:"sm",pressed:o.regexp,"data-state":o.regexp?"on":"off",onPressedChange:e=>a({type:"setRegex",regexp:e}),children:m.jsx(fc,{className:"w-4 h-4"})})})]}),m.jsxs("div",{className:"flex items-center gap-[2px]",children:[m.jsx(b,{"data-testid":"replace-next-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:()=>Rd(),disabled:""===o.findText||""===o.replaceText,children:"Replace Next"}),m.jsx(b,{"data-testid":"replace-all-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:()=>{const e=Pd();if(!e)return;const{dismiss:t}=q({title:"Replaced all occurrences",action:m.jsx(Qc,{"data-testid":"undo-replace-all-button",onClick:()=>{e(),t()}})})},disabled:""===o.findText||""===o.replaceText,children:"Replace All"})]})]})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(p,{content:"Find Previous",children:m.jsx(b,{"data-testid":"find-prev-button",size:"xs",variant:"secondary",onClick:()=>_d(),children:m.jsx(kl,{className:"w-4 h-4"})})}),m.jsx(p,{content:"Find Next",children:m.jsx(b,{"data-testid":"find-next-button",size:"xs",variant:"secondary",onClick:()=>Dd(),children:m.jsx(Cl,{className:"w-4 h-4"})})}),null!=s&&null==u&&m.jsxs("span",{className:"text-sm",children:[s.count," matches"]}),null!=s&&null!=u&&m.jsxs("span",{className:"text-sm",children:[u+1," of ",s.count]})]}),m.jsxs("div",{className:"text-xs text-muted-foreground flex gap-1 mt-2",children:["Press"," ",m.jsx(Vs,{shortcut:c.getHotkey("cell.findAndReplace").key})," ","again to open the native browser search."]})]})})};function Wd(e){const[t,n]=r.useState(!1);return r.useEffect((()=>{if(!e)return;n(!1);const t=setTimeout((()=>{n(!0)}),200);return()=>clearTimeout(t)}),[e]),e&&t}const qd=()=>{const e=Z(cd);return m.jsx(p,{content:Ds("global.commandPalette"),children:m.jsx(_s,{"data-testid":"command-palette-button",onClick:()=>e((e=>!e)),shape:"rectangle",color:"hint-green",children:m.jsx(Ll,{strokeWidth:1.5,size:18})})})},Yd=({children:e})=>X(ne)?null:e,Jd=({children:e})=>X(ne)?e:null,Kd=({filename:e,needsSave:t,onSaveNotebook:n,getCellsAsJSON:o,presenting:r,onTogglePresenting:a,onInterrupt:s,onRun:i,closed:l,running:c,needsRun:d,undoAvailable:u,appWidth:h})=>{const{undoDeleteCell:f}=L();let g=null;return!l&&u&&(g=m.jsx(p,{content:"Undo cell deletion",children:m.jsx(_s,{"data-testid":"undo-delete-cell",size:"medium",color:"hint-green",shape:"circle",onClick:f,children:m.jsx(Tc,{size:16,strokeWidth:1.5})})})),m.jsxs(m.Fragment,{children:[!r&&m.jsx(Hd,{}),!l&&m.jsxs("div",{className:Qd,children:[r&&m.jsx(Vc,{}),m.jsx(jd,{}),m.jsx(Ws,{}),m.jsx(qs,{description:"This will terminate the Python kernel. You'll lose all data that's in memory."})]}),m.jsxs("div",{className:$t(eu,"compact"===h&&"xl:flex-row items-end"),children:[m.jsx(Yd,{children:l?m.jsx(Uc,{filename:e,getCellsAsJSON:o,needsSave:t}):m.jsx(p,{content:Ds("global.save"),children:m.jsx(_s,{"data-testid":"save-button",id:"save-button",shape:"rectangle",color:t?"yellow":"hint-green",onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},children:m.jsx(gc,{strokeWidth:1.5,size:18})})})}),m.jsx(p,{content:Ds("global.hideCode"),children:m.jsx(_s,{"data-testid":"hide-code-button",id:"preview-button",shape:"rectangle",color:"hint-green",onClick:a,children:r?m.jsx(mt,{strokeWidth:1.5,size:18}):m.jsx(Xl,{strokeWidth:1.5,size:18})})}),m.jsx(qd,{}),m.jsx(Ys,{}),m.jsx("div",{}),m.jsx(Yd,{children:m.jsxs("div",{className:"flex flex-col gap-2 items-center",children:[g,!l&&m.jsx(Zd,{running:c,onInterrupt:s}),!l&&m.jsx(Xd,{needsRun:d,onRun:i})]})})]})]})},Xd=({needsRun:e,onRun:t})=>e?m.jsx(p,{content:Ds("global.runStale"),children:m.jsx(_s,{"data-testid":"run-button",size:"medium",color:"yellow",shape:"circle",onClick:t,children:m.jsx(uc,{strokeWidth:1.5,size:16})})}):m.jsx(p,{content:"Nothing to run",children:m.jsx(_s,{"data-testid":"run-button",className:"inactive-button",color:"disabled",size:"medium",shape:"circle",children:m.jsx(uc,{strokeWidth:1.5,size:16})})}),Zd=({running:e,onInterrupt:t})=>{const n=Wd(e);return m.jsx(p,{content:Ds("global.interrupt"),children:m.jsx(_s,{className:$t(!n&&"inactive-button active:shadow-xsSolid"),"data-testid":"interrupt-button",size:"medium",color:n?"yellow":"disabled",shape:"circle",onClick:n?t:Gt.NOOP,children:m.jsx(N,{strokeWidth:1.5,size:16})})})},Qd="absolute top-3 right-5 m-0 flex items-center space-x-3 min-h-[28px] no-print pointer-events-auto z-30 print:hidden",eu="absolute bottom-5 right-5 flex flex-col gap-2 items-center no-print pointer-events-auto z-30 print:hidden",tu=({resetOnBlur:e=!1,placeholderText:t,initialValue:n=null,flexibleWidth:o=!1,onNameChange:a,className:s})=>{const[i,l]=r.useState(n),[c,d]=r.useState([]),[u,h]=r.useState(!1),f=r.useRef(null),p=r.useRef(!1);r.useEffect((()=>{l(n)}),[n]);const g=nt.dirname(i||""),v=nt.basename(i||""),x=c.filter((e=>nt.basename(e.path).startsWith(v))),{loading:y}=Ht((async()=>{if(!u)return void d([]);const e=await Wt({path:g});d(e.files)}),[g,u]),b=function(e,t,n){if(!e)return;if(e.endsWith("/"))return;(Rs("markdown")?new Set(["py","md","markdown","qmd"]):new Set(["py"])).has(nt.extension(e))||(e=e.endsWith(".")?`${e}py`:e.endsWith(".p")?`${e}y`:`${e}.py`);if(t.some((t=>t.path===e||nt.basename(t.path)===e)))return;if(n&&(n===e||nt.basename(n)===e))return;return e}(i,c,n),w=(b||x.length>0)&&m.jsxs(Oe,{className:"font-mono",children:[!y&&m.jsx(De,{children:"No files"}),b&&m.jsxs(Fe,{variant:"success",className:"py-2 px-3",onSelect:()=>{var e;b&&(p.current=!0,a(b),null==(e=f.current)||e.blur())},children:[m.jsx(Vl,{className:"w-4 h-4 mr-2"})," ",m.jsxs("span",{className:"text-sm",children:[n?"Rename to: ":"Save as: ",m.jsx("span",{className:"font-medium text-sm",children:nt.basename(b)})]})]},"_rename_"),x.map((e=>{const t=e.isDirectory?"directory":qt(e.path),n=Zt[t];return m.jsxs(Fe,{variant:e.isDirectory?"default":"muted",className:"py-2 px-3",onSelect:()=>{e.isDirectory?l(`${e.path}/`):l(e.path)},children:[m.jsx(n,{className:"w-4 h-4 mr-2"})," ",nt.basename(e.path)]},e.path)}))]}),k=10*Math.max(20,(null==i?void 0:i.length)||(null==t?void 0:t.length)||0);return m.jsx(Yt,{open:!0,modal:!1,children:m.jsx(Jt,{onFocus:()=>{h(!0)},onBlur:t=>{var o;(null==(o=t.relatedTarget)?void 0:o.closest(".filename-input"))||(h(!1),e&&l(n))},shouldFilter:!1,className:"bg-transparent group filename-input",children:m.jsxs(Oe,{children:[m.jsx(Kt,{children:m.jsx(Te,{"data-testid":"dir-completion-input",tabIndex:-1,rootClassName:"border-none justify-center px-1",spellCheck:"false",value:u?i||"":n||"",onKeyDown:e=>{"Escape"===e.key&&e.currentTarget.blur()},icon:null,ref:f,onValueChange:l,placeholder:t,autoComplete:"off",style:o?{maxWidth:k}:void 0,className:$t(s,"w-full px-4 py-1 my-1 h-9 font-mono text-foreground/60")})}),m.jsx(Xt,{side:"bottom",className:$t("p-0 w-full min-w-80 max-w-80vw hidden",w&&"group-focus-within:block"),portal:!1,children:w})]})})})};const nu=({filename:e,setFilename:t})=>m.jsx(tu,{placeholderText:e?nt.basename(e):"untitled marimo app",initialValue:e,onNameChange:t,flexibleWidth:!0,resetOnBlur:!0,"data-testid":"filename-input",className:null===e?"missing-filename":"filename"});function ou(e){return[Qt.of([{key:"Escape",preventDefault:!1,run:Ad},{key:e.getHotkey("cell.selectNextOccurrence").key,preventDefault:!0,run:en},{key:e.getHotkey("cell.findAndReplace").key,preventDefault:!0,run:Id}]),tn(),$d,Bd,Gd]}var ru=Object.defineProperty,au=(e,t,n)=>(((e,t,n)=>{t in e?ru(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!=typeof t?t+"":t,n),n);const su=Pt.define({create:()=>({suggestion:null}),update(e,t){const n=t.effects.find((e=>e.is(iu)));return t.state.doc&&n&&t.state.doc==n.value.doc?{suggestion:n.value.text}:{suggestion:null}}}),iu=_t.define();class lu extends on{constructor(e){super(),au(this,"suggestion"),this.suggestion=e}toDOM(){const e=document.createElement("span");return e.style.opacity="0.4",e.className="cm-inline-suggestion",e.textContent=this.suggestion,e}get lineBreaks(){return this.suggestion.split("\n").length-1}}const cu=e=>Ft.fromClass(class{async update(t){const n=t.state.doc;if(!t.docChanged)return;const o=await e(t.state);t.view.dispatch({effects:iu.of({text:o,doc:n})})}}),du=Ft.fromClass(class{constructor(){au(this,"decorations"),this.decorations=Rt.none}update(e){var t;const n=null==(t=e.state.field(su))?void 0:t.suggestion;this.decorations=n?function(e,t){const n=e.state.selection.main.head,o=[],r=Rt.widget({widget:new lu(t),side:1});return o.push(r.range(n)),Rt.set(o)}(e.view,n):Rt.none}},{decorations:e=>e.decorations}),uu=nn.highest(Qt.of([{key:"Tab",run:e=>{var t;const n=null==(t=e.state.field(su))?void 0:t.suggestion;return!!n&&(e.dispatch({...hu(e.state,n,e.state.selection.main.head,e.state.selection.main.head)}),!0)}}]));function hu(e,t,n,o){return{...e.changeByRange((r=>{if(r==e.selection.main)return{changes:{from:n,to:o,insert:t},range:Ot.cursor(n+t.length)};const a=o-n;return!r.empty||a&&e.sliceDoc(r.from-a,r.from)!=e.sliceDoc(n,o)?{range:r}:{changes:{from:r.from-a,to:r.from,insert:t},range:Ot.cursor(r.from-a+t.length)}})),userEvent:"input.complete"}}function fu(e){const{delay:t=500}=e,n=function(e,t,n){let o=()=>{};return(...r)=>(o(),new Promise(((a,s)=>{const i=setTimeout((()=>a(e(...r))),t);o=()=>{clearTimeout(i),void 0!==n&&s(n)}})))}(e.fetchFn,t);return[su,cu(n),du,uu]}const mu=_t.define(),pu=_t.define(),gu=_t.define();function vu(e,t){if(!e)throw new Error(t)}function xu(e){if("number"!=typeof e)throw new Error("invalid int 32: "+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw new Error("invalid int 32: "+e)}function yu(e){if("number"!=typeof e)throw new Error("invalid uint 32: "+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw new Error("invalid uint 32: "+e)}function bu(e){if("number"!=typeof e)throw new Error("invalid float 32: "+typeof e);if(Number.isFinite(e)&&(e>34028234663852886e22||e<-34028234663852886e22))throw new Error("invalid float 32: "+e)}const wu=Symbol("@bufbuild/protobuf/enum-type");function ku(e){const t=e[wu];return vu(t,"missing enum type on enum object"),t}function Nu(e,t,n,o){e[wu]=Eu(t,n.map((t=>({no:t.no,name:t.name,localName:e[t.no]}))))}function Eu(e,t,n){const o=Object.create(null),r=Object.create(null),a=[];for(const s of t){const e=ju(s);a.push(e),o[s.name]=e,r[s.no]=e}return{typeName:e,values:a,findName:e=>o[e],findNumber:e=>r[e]}}function Cu(e,t,n){const o={};for(const r of t){const e=ju(r);o[e.localName]=e.no,o[e.no]=e.localName}return Nu(o,e,t),o}function ju(e){return"localName"in e?e:Object.assign(Object.assign({},e),{localName:e.name})}class Su{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const n=this.getType().runtime.bin,o=n.makeReadOptions(t);return n.readMessage(this,o.readerFactory(e),e.byteLength,o),this}fromJson(e,t){const n=this.getType(),o=n.runtime.json,r=o.makeReadOptions(t);return o.readMessage(n,e,r,this),this}fromJsonString(e,t){let n;try{n=JSON.parse(e)}catch(o){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${o instanceof Error?o.message:String(o)}`)}return this.fromJson(n,t)}toBinary(e){const t=this.getType().runtime.bin,n=t.makeWriteOptions(e),o=n.writerFactory();return t.writeMessage(this,o,n),o.finish()}toJson(e){const t=this.getType().runtime.json,n=t.makeWriteOptions(e);return t.writeMessage(this,n)}toJsonString(e){var t;const n=this.toJson(e);return JSON.stringify(n,null,null!==(t=null==e?void 0:e.prettySpaces)&&void 0!==t?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function Iu(){let e=0,t=0;for(let o=0;o<28;o+=7){let n=this.buf[this.pos++];if(e|=(127&n)<<o,!(128&n))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(15&n)<<28,t=(112&n)>>4,!(128&n))return this.assertBounds(),[e,t];for(let o=3;o<=31;o+=7){let n=this.buf[this.pos++];if(t|=(127&n)<<o,!(128&n))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function Au(e,t,n){for(let a=0;a<28;a+=7){const o=e>>>a,r=!(o>>>7==0&&0==t),s=255&(r?128|o:o);if(n.push(s),!r)return}const o=e>>>28&15|(7&t)<<4,r=!!(t>>3);if(n.push(255&(r?128|o:o)),r){for(let e=3;e<31;e+=7){const o=t>>>e,r=!(o>>>7==0),a=255&(r?128|o:o);if(n.push(a),!r)return}n.push(t>>>31&1)}}const Mu=4294967296;function Tu(e){const t="-"===e[0];t&&(e=e.slice(1));const n=1e6;let o=0,r=0;function a(t,a){const s=Number(e.slice(t,a));r*=n,o=o*n+s,o>=Mu&&(r+=o/Mu|0,o%=Mu)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?_u(o,r):Du(o,r)}function Ou(e,t){if(({lo:e,hi:t}=function(e,t){return{lo:e>>>0,hi:t>>>0}}(e,t)),t<=2097151)return String(Mu*t+e);const n=16777215&(e>>>24|t<<8),o=t>>16&65535;let r=(16777215&e)+6777216*n+6710656*o,a=n+8147497*o,s=2*o;const i=1e7;return r>=i&&(a+=Math.floor(r/i),r%=i),a>=i&&(s+=Math.floor(a/i),a%=i),s.toString()+Pu(a)+Pu(r)}function Du(e,t){return{lo:0|e,hi:0|t}}function _u(e,t){return t=~t,e?e=1+~e:t+=1,Du(e,t)}const Pu=e=>{const t=String(e);return"0000000".slice(t.length)+t};function Ru(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(127&e|128),e>>=7;t.push(1)}}function Fu(){let e=this.buf[this.pos++],t=127&e;if(!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,!(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let n=5;128&e&&n<10;n++)e=this.buf[this.pos++];if(128&e)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var Lu={};const zu=function(){const e=new DataView(new ArrayBuffer(8));if("function"==typeof BigInt&&"function"==typeof e.getBigInt64&&"function"==typeof e.getBigUint64&&"function"==typeof e.setBigInt64&&"function"==typeof e.setBigUint64&&("object"!=typeof process||"1"!==Lu.BUF_BIGINT_DISABLE)){const t=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),o=BigInt("0"),r=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(e){const o="bigint"==typeof e?e:BigInt(e);if(o>n||o<t)throw new Error(`int64 invalid: ${e}`);return o},uParse(e){const t="bigint"==typeof e?e:BigInt(e);if(t>r||t<o)throw new Error(`uint64 invalid: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)),uDec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0))}}const t=e=>vu(/^-?[0-9]+$/.test(e),`int64 invalid: ${e}`),n=e=>vu(/^[0-9]+$/.test(e),`uint64 invalid: ${e}`);return{zero:"0",supported:!1,parse:e=>("string"!=typeof e&&(e=e.toString()),t(e),e),uParse:e=>("string"!=typeof e&&(e=e.toString()),n(e),e),enc:e=>("string"!=typeof e&&(e=e.toString()),t(e),Tu(e)),uEnc:e=>("string"!=typeof e&&(e=e.toString()),n(e),Tu(e)),dec:(e,t)=>function(e,t){let n=Du(e,t);const o=2147483648&n.hi;o&&(n=_u(n.lo,n.hi));const r=Ou(n.lo,n.hi);return o?"-"+r:r}(e,t),uDec:(e,t)=>Ou(e,t)}}();var Bu,Uu,Vu,$u,Gu,Hu;function Wu(e,t,n){if(t===n)return!0;if(e==Bu.BYTES){if(!(t instanceof Uint8Array&&n instanceof Uint8Array))return!1;if(t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==n[e])return!1;return!0}switch(e){case Bu.UINT64:case Bu.FIXED64:case Bu.INT64:case Bu.SFIXED64:case Bu.SINT64:return t==n}return!1}function qu(e,t){switch(e){case Bu.BOOL:return!1;case Bu.UINT64:case Bu.FIXED64:case Bu.INT64:case Bu.SFIXED64:case Bu.SINT64:return 0==t?zu.zero:"0";case Bu.DOUBLE:case Bu.FLOAT:return 0;case Bu.BYTES:return new Uint8Array(0);case Bu.STRING:return"";default:return 0}}function Yu(e,t){switch(e){case Bu.BOOL:return!1===t;case Bu.STRING:return""===t;case Bu.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return 0==t}}(Uu=Bu||(Bu={}))[Uu.DOUBLE=1]="DOUBLE",Uu[Uu.FLOAT=2]="FLOAT",Uu[Uu.INT64=3]="INT64",Uu[Uu.UINT64=4]="UINT64",Uu[Uu.INT32=5]="INT32",Uu[Uu.FIXED64=6]="FIXED64",Uu[Uu.FIXED32=7]="FIXED32",Uu[Uu.BOOL=8]="BOOL",Uu[Uu.STRING=9]="STRING",Uu[Uu.BYTES=12]="BYTES",Uu[Uu.UINT32=13]="UINT32",Uu[Uu.SFIXED32=15]="SFIXED32",Uu[Uu.SFIXED64=16]="SFIXED64",Uu[Uu.SINT32=17]="SINT32",Uu[Uu.SINT64=18]="SINT64",($u=Vu||(Vu={}))[$u.BIGINT=0]="BIGINT",$u[$u.STRING=1]="STRING",(Hu=Gu||(Gu={}))[Hu.Varint=0]="Varint",Hu[Hu.Bit64=1]="Bit64",Hu[Hu.LengthDelimited=2]="LengthDelimited",Hu[Hu.StartGroup=3]="StartGroup",Hu[Hu.EndGroup=4]="EndGroup",Hu[Hu.Bit32=5]="Bit32";class Ju{constructor(e){this.stack=[],this.textEncoder=null!=e?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let o=0;o<this.chunks.length;o++)e+=this.chunks[o].length;let t=new Uint8Array(e),n=0;for(let o=0;o<this.chunks.length;o++)t.set(this.chunks[o],n),n+=this.chunks[o].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(yu(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return xu(e),Ru(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){bu(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){yu(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){xu(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return xu(e),Ru(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),o=zu.enc(e);return n.setInt32(0,o.lo,!0),n.setInt32(4,o.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),o=zu.uEnc(e);return n.setInt32(0,o.lo,!0),n.setInt32(4,o.hi,!0),this.raw(t)}int64(e){let t=zu.enc(e);return Au(t.lo,t.hi,this.buf),this}sint64(e){let t=zu.enc(e),n=t.hi>>31;return Au(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=zu.uEnc(e);return Au(t.lo,t.hi,this.buf),this}}class Ku{constructor(e,t){this.varint64=Iu,this.uint32=Fu,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=null!=t?t:new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,n=7&e;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case Gu.Varint:for(;128&this.buf[this.pos++];);break;case Gu.Bit64:this.pos+=4;case Gu.Bit32:this.pos+=4;break;case Gu.LengthDelimited:let n=this.uint32();this.pos+=n;break;case Gu.StartGroup:for(;;){const[e,n]=this.tag();if(n===Gu.EndGroup){if(void 0!==t&&e!==t)throw new Error("invalid end group tag");break}this.skip(n,e)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return zu.dec(...this.varint64())}uint64(){return zu.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(1&e);return e=(e>>>1|(1&t)<<31)^n,t=t>>>1^n,zu.dec(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return zu.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return zu.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function Xu(e){const t=e.field.localName,n=Object.create(null);return n[t]=function(e){const t=e.field;if(t.repeated)return[];if(void 0!==t.default)return t.default;switch(t.kind){case"enum":return t.T.values[0].no;case"scalar":return qu(t.T,t.L);case"message":const e=t.T,n=new e;return e.fieldWrapper?e.fieldWrapper.unwrapField(n):n;case"map":throw"map fields are not allowed to be extensions"}}(e),[n,()=>n[t]]}let Zu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Qu=[];for(let FT=0;FT<Zu.length;FT++)Qu[Zu[FT].charCodeAt(0)]=FT;Qu["-".charCodeAt(0)]=Zu.indexOf("+"),Qu["_".charCodeAt(0)]=Zu.indexOf("/");const eh={dec(e){let t=3*e.length/4;"="==e[e.length-2]?t-=2:"="==e[e.length-1]&&(t-=1);let n,o=new Uint8Array(t),r=0,a=0,s=0;for(let i=0;i<e.length;i++){if(n=Qu[e.charCodeAt(i)],void 0===n)switch(e[i]){case"=":a=0;case"\n":case"\r":case"\t":case" ":continue;default:throw Error("invalid base64 string.")}switch(a){case 0:s=n,a=1;break;case 1:o[r++]=s<<2|(48&n)>>4,s=n,a=2;break;case 2:o[r++]=(15&s)<<4|(60&n)>>2,s=n,a=3;break;case 3:o[r++]=(3&s)<<6|n,a=0}}if(1==a)throw Error("invalid base64 string.");return o.subarray(0,r)},enc(e){let t,n="",o=0,r=0;for(let a=0;a<e.length;a++)switch(t=e[a],o){case 0:n+=Zu[t>>2],r=(3&t)<<4,o=1;break;case 1:n+=Zu[r|t>>4],r=(15&t)<<2,o=2;break;case 2:n+=Zu[r|t>>6],n+=Zu[63&t],o=0}return o&&(n+=Zu[r],n+="=",1==o&&(n+="=")),n}};function th(e,t,n){rh(t,e);const o=t.runtime.bin.makeReadOptions(n),r=function(e,t){if(!t.repeated&&("enum"==t.kind||"scalar"==t.kind)){for(let n=e.length-1;n>=0;--n)if(e[n].no==t.no)return[e[n]];return[]}return e.filter((e=>e.no===t.no))}(e.getType().runtime.bin.listUnknownFields(e),t.field),[a,s]=Xu(t);for(const i of r)t.runtime.bin.readField(a,o.readerFactory(i.data),t.field,i.wireType,o);return s()}function nh(e,t,n,o){rh(t,e);const r=t.runtime.bin.makeReadOptions(o),a=t.runtime.bin.makeWriteOptions(o);if(oh(e,t)){const n=e.getType().runtime.bin.listUnknownFields(e).filter((e=>e.no!=t.field.no));e.getType().runtime.bin.discardUnknownFields(e);for(const t of n)e.getType().runtime.bin.onUnknownField(e,t.no,t.wireType,t.data)}const s=a.writerFactory();let i=t.field;i.opt||i.repeated||"enum"!=i.kind&&"scalar"!=i.kind||(i=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(i,n,s,a);const l=r.readerFactory(s.finish());for(;l.pos<l.len;){const[t,n]=l.tag(),o=l.skip(n,t);e.getType().runtime.bin.onUnknownField(e,t,n,o)}}function oh(e,t){const n=e.getType();return t.extendee.typeName===n.typeName&&!!n.runtime.bin.listUnknownFields(e).find((e=>e.no==t.field.no))}function rh(e,t){vu(e.extendee.typeName==t.getType().typeName,`extension ${e.typeName} can only be applied to message ${e.extendee.typeName}`)}function ah(e,t){const n=e.localName;if(e.repeated)return t[n].length>0;if(e.oneof)return t[e.oneof.localName].case===n;switch(e.kind){case"enum":case"scalar":return e.opt||e.req?void 0!==t[n]:"enum"==e.kind?t[n]!==e.T.values[0].no:!Yu(e.T,t[n]);case"message":return void 0!==t[n];case"map":return Object.keys(t[n]).length>0}}function sh(e,t){const n=e.localName,o=!e.opt&&!e.req;if(e.repeated)t[n]=[];else if(e.oneof)t[e.oneof.localName]={case:void 0};else switch(e.kind){case"map":t[n]={};break;case"enum":t[n]=o?e.T.values[0].no:void 0;break;case"scalar":t[n]=o?qu(e.T,e.L):void 0;break;case"message":t[n]=void 0}}function ih(e,t){if(null===e||"object"!=typeof e)return!1;if(!Object.getOwnPropertyNames(Su.prototype).every((t=>t in e&&"function"==typeof e[t])))return!1;const n=e.getType();return null!==n&&"function"==typeof n&&"typeName"in n&&"string"==typeof n.typeName&&(void 0===t||n.typeName==t.typeName)}function lh(e,t){return ih(t)||!e.fieldWrapper?t:e.fieldWrapper.wrapField(t)}Bu.DOUBLE,Bu.FLOAT,Bu.INT64,Bu.UINT64,Bu.INT32,Bu.UINT32,Bu.BOOL,Bu.STRING,Bu.BYTES;const ch={ignoreUnknownFields:!1},dh={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function uh(e){return e?Object.assign(Object.assign({},ch),e):ch}function hh(e){return e?Object.assign(Object.assign({},dh),e):dh}const fh=Symbol(),mh=Symbol();function ph(e){if(null===e)return"null";switch(typeof e){case"object":return Array.isArray(e)?"array":"object";case"string":return e.length>100?"string":`"${e.split('"').join('\\"')}"`;default:return String(e)}}function gh(e,t,n,o,r){let a=n.localName;if(n.repeated){if(vu("map"!=n.kind),null===t)return;if(!Array.isArray(t))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${ph(t)}`);const i=e[a];for(const e of t){if(null===e)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${ph(e)}`);switch(n.kind){case"message":i.push(n.T.fromJson(e,o));break;case"enum":const t=yh(n.T,e,o.ignoreUnknownFields,!0);t!==mh&&i.push(t);break;case"scalar":try{i.push(xh(n.T,e,n.L,!0))}catch(s){let t=`cannot decode field ${r.typeName}.${n.name} from JSON: ${ph(e)}`;throw s instanceof Error&&s.message.length>0&&(t+=`: ${s.message}`),new Error(t)}}}}else if("map"==n.kind){if(null===t)return;if("object"!=typeof t||Array.isArray(t))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${ph(t)}`);const i=e[a];for(const[e,a]of Object.entries(t)){if(null===a)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: map value null`);let l;try{l=vh(n.K,e)}catch(s){let e=`cannot decode map key for field ${r.typeName}.${n.name} from JSON: ${ph(t)}`;throw s instanceof Error&&s.message.length>0&&(e+=`: ${s.message}`),new Error(e)}switch(n.V.kind){case"message":i[l]=n.V.T.fromJson(a,o);break;case"enum":const e=yh(n.V.T,a,o.ignoreUnknownFields,!0);e!==mh&&(i[l]=e);break;case"scalar":try{i[l]=xh(n.V.T,a,Vu.BIGINT,!0)}catch(s){let e=`cannot decode map value for field ${r.typeName}.${n.name} from JSON: ${ph(t)}`;throw s instanceof Error&&s.message.length>0&&(e+=`: ${s.message}`),new Error(e)}}}}else switch(n.oneof&&(e=e[n.oneof.localName]={case:a},a="value"),n.kind){case"message":const i=n.T;if(null===t&&"google.protobuf.Value"!=i.typeName)return;let l=e[a];ih(l)?l.fromJson(t,o):(e[a]=l=i.fromJson(t,o),i.fieldWrapper&&!n.oneof&&(e[a]=i.fieldWrapper.unwrapField(l)));break;case"enum":const c=yh(n.T,t,o.ignoreUnknownFields,!1);switch(c){case fh:sh(n,e);break;case mh:break;default:e[a]=c}break;case"scalar":try{const o=xh(n.T,t,n.L,!1);if(o===fh)sh(n,e);else e[a]=o}catch(s){let e=`cannot decode field ${r.typeName}.${n.name} from JSON: ${ph(t)}`;throw s instanceof Error&&s.message.length>0&&(e+=`: ${s.message}`),new Error(e)}}}function vh(e,t){if(e===Bu.BOOL)switch(t){case"true":t=!0;break;case"false":t=!1}return xh(e,t,Vu.BIGINT,!0).toString()}function xh(e,t,n,o){if(null===t)return o?qu(e,n):fh;switch(e){case Bu.DOUBLE:case Bu.FLOAT:if("NaN"===t)return Number.NaN;if("Infinity"===t)return Number.POSITIVE_INFINITY;if("-Infinity"===t)return Number.NEGATIVE_INFINITY;if(""===t)break;if("string"==typeof t&&t.trim().length!==t.length)break;if("string"!=typeof t&&"number"!=typeof t)break;const o=Number(t);if(Number.isNaN(o))break;if(!Number.isFinite(o))break;return e==Bu.FLOAT&&bu(o),o;case Bu.INT32:case Bu.FIXED32:case Bu.SFIXED32:case Bu.SINT32:case Bu.UINT32:let a;if("number"==typeof t?a=t:"string"==typeof t&&t.length>0&&t.trim().length===t.length&&(a=Number(t)),void 0===a)break;return e==Bu.UINT32||e==Bu.FIXED32?yu(a):xu(a),a;case Bu.INT64:case Bu.SFIXED64:case Bu.SINT64:if("number"!=typeof t&&"string"!=typeof t)break;const s=zu.parse(t);return n?s.toString():s;case Bu.FIXED64:case Bu.UINT64:if("number"!=typeof t&&"string"!=typeof t)break;const i=zu.uParse(t);return n?i.toString():i;case Bu.BOOL:if("boolean"!=typeof t)break;return t;case Bu.STRING:if("string"!=typeof t)break;try{encodeURIComponent(t)}catch(r){throw new Error("invalid UTF8")}return t;case Bu.BYTES:if(""===t)return new Uint8Array(0);if("string"!=typeof t)break;return eh.dec(t)}throw new Error}function yh(e,t,n,o){if(null===t)return"google.protobuf.NullValue"==e.typeName?0:o?e.values[0].no:fh;switch(typeof t){case"number":if(Number.isInteger(t))return t;break;case"string":const o=e.findName(t);if(void 0!==o)return o.no;if(n)return mh}throw new Error(`cannot decode enum ${e.typeName} from JSON: ${ph(t)}`)}function bh(e){return!(!e.repeated&&"map"!=e.kind)||!e.oneof&&("message"!=e.kind&&(!e.opt&&!e.req))}function wh(e,t,n){if("map"==e.kind){vu("object"==typeof t&&null!=t);const o={},r=Object.entries(t);switch(e.V.kind){case"scalar":for(const[n,a]of r)o[n.toString()]=Nh(e.V.T,a);break;case"message":for(const[e,a]of r)o[e.toString()]=a.toJson(n);break;case"enum":const t=e.V.T;for(const[e,a]of r)o[e.toString()]=kh(t,a,n.enumAsInteger)}return n.emitDefaultValues||r.length>0?o:void 0}if(e.repeated){vu(Array.isArray(t));const o=[];switch(e.kind){case"scalar":for(let n=0;n<t.length;n++)o.push(Nh(e.T,t[n]));break;case"enum":for(let r=0;r<t.length;r++)o.push(kh(e.T,t[r],n.enumAsInteger));break;case"message":for(let e=0;e<t.length;e++)o.push(t[e].toJson(n))}return n.emitDefaultValues||o.length>0?o:void 0}switch(e.kind){case"scalar":return Nh(e.T,t);case"enum":return kh(e.T,t,n.enumAsInteger);case"message":return lh(e.T,t).toJson(n)}}function kh(e,t,n){var o;if(vu("number"==typeof t),"google.protobuf.NullValue"==e.typeName)return null;if(n)return t;const r=e.findNumber(t);return null!==(o=null==r?void 0:r.name)&&void 0!==o?o:t}function Nh(e,t){switch(e){case Bu.INT32:case Bu.SFIXED32:case Bu.SINT32:case Bu.FIXED32:case Bu.UINT32:return vu("number"==typeof t),t;case Bu.FLOAT:case Bu.DOUBLE:return vu("number"==typeof t),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t;case Bu.STRING:return vu("string"==typeof t),t;case Bu.BOOL:return vu("boolean"==typeof t),t;case Bu.UINT64:case Bu.FIXED64:case Bu.INT64:case Bu.SFIXED64:case Bu.SINT64:return vu("bigint"==typeof t||"string"==typeof t||"number"==typeof t),t.toString();case Bu.BYTES:return vu(t instanceof Uint8Array),eh.enc(t)}}const Eh=Symbol("@bufbuild/protobuf/unknown-fields"),Ch={readUnknownFields:!0,readerFactory:e=>new Ku(e)},jh={writeUnknownFields:!0,writerFactory:()=>new Ju};function Sh(e){return e?Object.assign(Object.assign({},Ch),e):Ch}function Ih(e){return e?Object.assign(Object.assign({},jh),e):jh}function Ah(e,t,n,o,r){let{repeated:a,localName:s}=n;switch(n.oneof&&((e=e[n.oneof.localName]).case!=s&&delete e.value,e.case=s,s="value"),n.kind){case"scalar":case"enum":const i="enum"==n.kind?Bu.INT32:n.T;let l=Oh;if("scalar"==n.kind&&n.L>0&&(l=Th),a){let n=e[s];if(o==Gu.LengthDelimited&&i!=Bu.STRING&&i!=Bu.BYTES){let e=t.uint32()+t.pos;for(;t.pos<e;)n.push(l(t,i))}else n.push(l(t,i))}else e[s]=l(t,i);break;case"message":const c=n.T;a?e[s].push(Mh(t,new c,r,n)):ih(e[s])?Mh(t,e[s],r,n):(e[s]=Mh(t,new c,r,n),!c.fieldWrapper||n.oneof||n.repeated||(e[s]=c.fieldWrapper.unwrapField(e[s])));break;case"map":let[d,u]=function(e,t,n){const o=t.uint32(),r=t.pos+o;let a,s;for(;t.pos<r;){const[o]=t.tag();switch(o){case 1:a=Oh(t,e.K);break;case 2:switch(e.V.kind){case"scalar":s=Oh(t,e.V.T);break;case"enum":s=t.int32();break;case"message":s=Mh(t,new e.V.T,n,void 0)}}}void 0===a&&(a=qu(e.K,Vu.BIGINT));"string"!=typeof a&&"number"!=typeof a&&(a=a.toString());if(void 0===s)switch(e.V.kind){case"scalar":s=qu(e.V.T,Vu.BIGINT);break;case"enum":s=e.V.T.values[0].no;break;case"message":s=new e.V.T}return[a,s]}(n,t,r);e[s][d]=u}}function Mh(e,t,n,o){const r=t.getType().runtime.bin,a=null==o?void 0:o.delimited;return r.readMessage(t,e,a?o.no:e.uint32(),n,a),t}function Th(e,t){const n=Oh(e,t);return"bigint"==typeof n?n.toString():n}function Oh(e,t){switch(t){case Bu.STRING:return e.string();case Bu.BOOL:return e.bool();case Bu.DOUBLE:return e.double();case Bu.FLOAT:return e.float();case Bu.INT32:return e.int32();case Bu.INT64:return e.int64();case Bu.UINT64:return e.uint64();case Bu.FIXED64:return e.fixed64();case Bu.BYTES:return e.bytes();case Bu.FIXED32:return e.fixed32();case Bu.SFIXED32:return e.sfixed32();case Bu.SFIXED64:return e.sfixed64();case Bu.SINT64:return e.sint64();case Bu.UINT32:return e.uint32();case Bu.SINT32:return e.sint32()}}function Dh(e,t,n,o){vu(void 0!==t);const r=e.repeated;switch(e.kind){case"scalar":case"enum":let a="enum"==e.kind?Bu.INT32:e.T;if(r)if(vu(Array.isArray(t)),e.packed)!function(e,t,n,o){if(!o.length)return;e.tag(n,Gu.LengthDelimited).fork();let[,r]=Fh(t);for(let a=0;a<o.length;a++)e[r](o[a]);e.join()}(n,a,e.no,t);else for(const o of t)Rh(n,a,e.no,o);else Rh(n,a,e.no,t);break;case"message":if(r){vu(Array.isArray(t));for(const r of t)Ph(n,o,e,r)}else Ph(n,o,e,t);break;case"map":vu("object"==typeof t&&null!=t);for(const[r,s]of Object.entries(t))_h(n,o,e,r,s)}}function _h(e,t,n,o,r){e.tag(n.no,Gu.LengthDelimited),e.fork();let a=o;switch(n.K){case Bu.INT32:case Bu.FIXED32:case Bu.UINT32:case Bu.SFIXED32:case Bu.SINT32:a=Number.parseInt(o);break;case Bu.BOOL:vu("true"==o||"false"==o),a="true"==o}switch(Rh(e,n.K,1,a),n.V.kind){case"scalar":Rh(e,n.V.T,2,r);break;case"enum":Rh(e,Bu.INT32,2,r);break;case"message":vu(void 0!==r),e.tag(2,Gu.LengthDelimited).bytes(r.toBinary(t))}e.join()}function Ph(e,t,n,o){const r=lh(n.T,o);n.delimited?e.tag(n.no,Gu.StartGroup).raw(r.toBinary(t)).tag(n.no,Gu.EndGroup):e.tag(n.no,Gu.LengthDelimited).bytes(r.toBinary(t))}function Rh(e,t,n,o){vu(void 0!==o);let[r,a]=Fh(t);e.tag(n,r)[a](o)}function Fh(e){let t=Gu.Varint;switch(e){case Bu.BYTES:case Bu.STRING:t=Gu.LengthDelimited;break;case Bu.DOUBLE:case Bu.FIXED64:case Bu.SFIXED64:t=Gu.Bit64;break;case Bu.FIXED32:case Bu.SFIXED32:case Bu.FLOAT:t=Gu.Bit32}return[t,Bu[e].toLowerCase()]}function Lh(e){if(void 0===e)return e;if(ih(e))return e.clone();if(e instanceof Uint8Array){const t=new Uint8Array(e.byteLength);return t.set(e),t}return e}function zh(e){return e instanceof Uint8Array?e:new Uint8Array(e)}class Bh{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const e={};for(const t of this.list())e[t.jsonName]=e[t.name]=t;this.jsonNames=e}return this.jsonNames[e]}find(e){if(!this.numbers){const e={};for(const t of this.list())e[t.no]=t;this.numbers=e}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort(((e,t)=>e.no-t.no))),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const n of this.list())n.oneof?n.oneof!==t&&(t=n.oneof,e.push(t)):e.push(n)}return this.members}}function Uh(e,t){const n=$h(e);return t?n:Yh(qh(n))}const Vh=$h;function $h(e){let t=!1;const n=[];for(let o=0;o<e.length;o++){let r=e.charAt(o);switch(r){case"_":t=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n.push(r),t=!1;break;default:t&&(t=!1,r=r.toUpperCase()),n.push(r)}}return n.join("")}const Gh=new Set(["constructor","toString","toJSON","valueOf"]),Hh=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),Wh=e=>`${e}$`,qh=e=>Hh.has(e)?Wh(e):e,Yh=e=>Gh.has(e)?Wh(e):e;class Jh{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=Uh(e,!1)}addField(e){vu(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let e=0;e<this.fields.length;e++)this._lookup[this.fields[e].localName]=this.fields[e]}return this._lookup[e]}}const Kh=(Xh=e=>new Bh(e,(e=>function(e){var t,n,o,r,a,s;const i=[];let l;for(const c of"function"==typeof e?e():e){const e=c;if(e.localName=Uh(c.name,void 0!==c.oneof),e.jsonName=null!==(t=c.jsonName)&&void 0!==t?t:Vh(c.name),e.repeated=null!==(n=c.repeated)&&void 0!==n&&n,"scalar"==c.kind&&(e.L=null!==(o=c.L)&&void 0!==o?o:Vu.BIGINT),e.delimited=null!==(r=c.delimited)&&void 0!==r&&r,e.req=null!==(a=c.req)&&void 0!==a&&a,e.opt=null!==(s=c.opt)&&void 0!==s&&s,void 0===c.packed&&(e.packed="enum"==c.kind||"scalar"==c.kind&&c.T!=Bu.BYTES&&c.T!=Bu.STRING),void 0!==c.oneof){const t="string"==typeof c.oneof?c.oneof:c.oneof.name;l&&l.name==t||(l=new Jh(t)),e.oneof=l,l.addField(e)}i.push(e)}return i}(e))),Zh=e=>{for(const t of e.getType().fields.byMember()){if(t.opt)continue;const n=t.localName,o=e;if(t.repeated)o[n]=[];else switch(t.kind){case"oneof":o[n]={case:void 0};break;case"enum":o[n]=0;break;case"map":o[n]={};break;case"scalar":o[n]=qu(t.T,t.L)}}},{syntax:"proto3",json:{makeReadOptions:uh,makeWriteOptions:hh,readMessage(e,t,n,o){if(null==t||Array.isArray(t)||"object"!=typeof t)throw new Error(`cannot decode message ${e.typeName} from JSON: ${ph(t)}`);o=null!=o?o:new e;const r=new Map,a=n.typeRegistry;for(const[s,i]of Object.entries(t)){const t=e.fields.findJsonName(s);if(t){if(t.oneof){if(null===i&&"scalar"==t.kind)continue;const n=r.get(t.oneof);if(void 0!==n)throw new Error(`cannot decode message ${e.typeName} from JSON: multiple keys for oneof "${t.oneof.name}" present: "${n}", "${s}"`);r.set(t.oneof,s)}gh(o,i,t,n,e)}else{let t=!1;if((null==a?void 0:a.findExtension)&&s.startsWith("[")&&s.endsWith("]")){const r=a.findExtension(s.substring(1,s.length-1));if(r&&r.extendee.typeName==e.typeName){t=!0;const[e,a]=Xu(r);gh(e,i,r.field,n,r),nh(o,r,a(),n)}}if(!t&&!n.ignoreUnknownFields)throw new Error(`cannot decode message ${e.typeName} from JSON: key "${s}" is unknown`)}}return o},writeMessage(e,t){const n=e.getType(),o={};let r;try{for(r of n.fields.byNumber()){if(!ah(r,e)){if(r.req)throw"required field not set";if(!t.emitDefaultValues)continue;if(!bh(r))continue}const n=wh(r,r.oneof?e[r.oneof.localName].value:e[r.localName],t);void 0!==n&&(o[t.useProtoFieldName?r.name:r.jsonName]=n)}const a=t.typeRegistry;if(null==a?void 0:a.findExtensionFor)for(const r of n.runtime.bin.listUnknownFields(e)){const s=a.findExtensionFor(n.typeName,r.no);if(s&&oh(e,s)){const n=th(e,s,t),r=wh(s.field,n,t);void 0!==r&&(o[s.field.jsonName]=r)}}}catch(a){const e=r?`cannot encode field ${n.typeName}.${r.name} to JSON`:`cannot encode message ${n.typeName} to JSON`,t=a instanceof Error?a.message:String(a);throw new Error(e+(t.length>0?`: ${t}`:""))}return o},readScalar:(e,t,n)=>xh(e,t,null!=n?n:Vu.BIGINT,!0),writeScalar(e,t,n){if(void 0!==t)return n||Yu(e,t)?Nh(e,t):void 0},debug:ph},bin:{makeReadOptions:Sh,makeWriteOptions:Ih,listUnknownFields(e){var t;return null!==(t=e[Eh])&&void 0!==t?t:[]},discardUnknownFields(e){delete e[Eh]},writeUnknownFields(e,t){const n=e[Eh];if(n)for(const o of n)t.tag(o.no,o.wireType).raw(o.data)},onUnknownField(e,t,n,o){const r=e;Array.isArray(r[Eh])||(r[Eh]=[]),r[Eh].push({no:t,wireType:n,data:o})},readMessage(e,t,n,o,r){const a=e.getType(),s=r?t.len:t.pos+n;let i,l;for(;t.pos<s&&([i,l]=t.tag(),!0!==r||l!=Gu.EndGroup);){const n=a.fields.find(i);if(n)Ah(e,t,n,l,o);else{const n=t.skip(l,i);o.readUnknownFields&&this.onUnknownField(e,i,l,n)}}if(r&&(l!=Gu.EndGroup||i!==n))throw new Error("invalid end group tag")},readField:Ah,writeMessage(e,t,n){const o=e.getType();for(const r of o.fields.byNumber())if(ah(r,e))Dh(r,r.oneof?e[r.oneof.localName].value:e[r.localName],t,n);else if(r.req)throw new Error(`cannot encode field ${o.typeName}.${r.name} to binary: required field not set`);return n.writeUnknownFields&&this.writeUnknownFields(e,t),t},writeField(e,t,n,o){void 0!==t&&Dh(e,t,n,o)}},util:Object.assign(Object.assign({},{setEnumType:Nu,initPartial(e,t){if(void 0===e)return;const n=t.getType();for(const o of n.fields.byMember()){const n=o.localName,r=t,a=e;if(null!=a[n])switch(o.kind){case"oneof":const e=a[n].case;if(void 0===e)continue;const t=o.findField(e);let s=a[n].value;t&&"message"==t.kind&&!ih(s,t.T)?s=new t.T(s):t&&"scalar"===t.kind&&t.T===Bu.BYTES&&(s=zh(s)),r[n]={case:e,value:s};break;case"scalar":case"enum":let i=a[n];o.T===Bu.BYTES&&(i=o.repeated?i.map(zh):zh(i)),r[n]=i;break;case"map":switch(o.V.kind){case"scalar":case"enum":if(o.V.T===Bu.BYTES)for(const[t,o]of Object.entries(a[n]))r[n][t]=zh(o);else Object.assign(r[n],a[n]);break;case"message":const e=o.V.T;for(const t of Object.keys(a[n])){let o=a[n][t];e.fieldWrapper||(o=new e(o)),r[n][t]=o}}break;case"message":const l=o.T;if(o.repeated)r[n]=a[n].map((e=>ih(e,l)?e:new l(e)));else{const e=a[n];l.fieldWrapper?"google.protobuf.BytesValue"===l.typeName?r[n]=zh(e):r[n]=e:r[n]=ih(e,l)?e:new l(e)}}}},equals:(e,t,n)=>t===n||!(!t||!n)&&e.fields.byMember().every((e=>{const o=t[e.localName],r=n[e.localName];if(e.repeated){if(o.length!==r.length)return!1;switch(e.kind){case"message":return o.every(((t,n)=>e.T.equals(t,r[n])));case"scalar":return o.every(((t,n)=>Wu(e.T,t,r[n])));case"enum":return o.every(((e,t)=>Wu(Bu.INT32,e,r[t])))}throw new Error(`repeated cannot contain ${e.kind}`)}switch(e.kind){case"message":return e.T.equals(o,r);case"enum":return Wu(Bu.INT32,o,r);case"scalar":return Wu(e.T,o,r);case"oneof":if(o.case!==r.case)return!1;const t=e.findField(o.case);if(void 0===t)return!0;switch(t.kind){case"message":return t.T.equals(o.value,r.value);case"enum":return Wu(Bu.INT32,o.value,r.value);case"scalar":return Wu(t.T,o.value,r.value)}throw new Error(`oneof cannot contain ${t.kind}`);case"map":const n=Object.keys(o).concat(Object.keys(r));switch(e.V.kind){case"message":const t=e.V.T;return n.every((e=>t.equals(o[e],r[e])));case"enum":return n.every((e=>Wu(Bu.INT32,o[e],r[e])));case"scalar":const a=e.V.T;return n.every((e=>Wu(a,o[e],r[e])))}}})),clone(e){const t=e.getType(),n=new t,o=n;for(const r of t.fields.byMember()){const t=e[r.localName];let n;if(r.repeated)n=t.map(Lh);else if("map"==r.kind){n=o[r.localName];for(const[e,o]of Object.entries(t))n[e]=Lh(o)}else n="oneof"==r.kind?r.findField(t.case)?{case:t.case,value:Lh(t.value)}:{case:void 0}:Lh(t);o[r.localName]=n}for(const r of t.runtime.bin.listUnknownFields(e))t.runtime.bin.onUnknownField(o,r.no,r.wireType,r.data);return n}}),{newFieldList:Xh,initFields:Zh}),makeMessageType(e,t,n){return function(e,t,n,o){var r;const a=null!==(r=null==o?void 0:o.localName)&&void 0!==r?r:t.substring(t.lastIndexOf(".")+1),s={[a]:function(t){e.util.initFields(this),e.util.initPartial(t,this)}}[a];return Object.setPrototypeOf(s.prototype,new Su),Object.assign(s,{runtime:e,typeName:t,fields:e.util.newFieldList(n),fromBinary:(e,t)=>(new s).fromBinary(e,t),fromJson:(e,t)=>(new s).fromJson(e,t),fromJsonString:(e,t)=>(new s).fromJsonString(e,t),equals:(t,n)=>e.util.equals(s,t,n)}),s}(this,e,t,n)},makeEnum:Cu,makeEnumType:Eu,getEnumType:ku,makeExtension(e,t,n){return function(e,t,n,o){let r;return{typeName:t,extendee:n,get field(){if(!r){const n="function"==typeof o?o():o;n.name=t.split(".").pop(),n.jsonName=`[${t}]`,r=e.util.newFieldList([n]).list()[0]}return r},runtime:e}}(this,e,t,n)}});var Xh,Zh,Qh,ef,tf,nf,of,rf,af,sf,lf,cf,df,uf,hf,ff;(ef=Qh||(Qh={}))[ef.Unary=0]="Unary",ef[ef.ServerStreaming=1]="ServerStreaming",ef[ef.ClientStreaming=2]="ClientStreaming",ef[ef.BiDiStreaming=3]="BiDiStreaming",(nf=tf||(tf={}))[nf.NoSideEffects=1]="NoSideEffects",nf[nf.Idempotent=2]="Idempotent",(rf=of||(of={}))[rf.UNSPECIFIED=0]="UNSPECIFIED",rf[rf.JUPYTER_FORMAT=77]="JUPYTER_FORMAT",Kh.util.setEnumType(of,"exa.codeium_common_pb.ExperimentKey",[{no:0,name:"UNSPECIFIED"},{no:77,name:"JUPYTER_FORMAT"}]),(sf=af||(af={}))[sf.CODEIUM=0]="CODEIUM",Kh.util.setEnumType(af,"exa.codeium_common_pb.AuthSource",[{no:0,name:"AUTH_SOURCE_CODEIUM"}]),(cf=lf||(lf={}))[cf.UNSPECIFIED=0]="UNSPECIFIED",cf[cf.ENABLE_CODEIUM=1]="ENABLE_CODEIUM",cf[cf.DISABLE_CODEIUM=2]="DISABLE_CODEIUM",cf[cf.SHOW_PREVIOUS_COMPLETION=3]="SHOW_PREVIOUS_COMPLETION",cf[cf.SHOW_NEXT_COMPLETION=4]="SHOW_NEXT_COMPLETION",Kh.util.setEnumType(lf,"exa.codeium_common_pb.EventType",[{no:0,name:"EVENT_TYPE_UNSPECIFIED"},{no:1,name:"EVENT_TYPE_ENABLE_CODEIUM"},{no:2,name:"EVENT_TYPE_DISABLE_CODEIUM"},{no:3,name:"EVENT_TYPE_SHOW_PREVIOUS_COMPLETION"},{no:4,name:"EVENT_TYPE_SHOW_NEXT_COMPLETION"}]),(uf=df||(df={}))[uf.UNSPECIFIED=0]="UNSPECIFIED",uf[uf.TYPING_AS_SUGGESTED=1]="TYPING_AS_SUGGESTED",uf[uf.CACHE=2]="CACHE",uf[uf.NETWORK=3]="NETWORK",Kh.util.setEnumType(df,"exa.codeium_common_pb.CompletionSource",[{no:0,name:"COMPLETION_SOURCE_UNSPECIFIED"},{no:1,name:"COMPLETION_SOURCE_TYPING_AS_SUGGESTED"},{no:2,name:"COMPLETION_SOURCE_CACHE"},{no:3,name:"COMPLETION_SOURCE_NETWORK"}]),(ff=hf||(hf={}))[ff.UNSPECIFIED=0]="UNSPECIFIED",ff[ff.C=1]="C",ff[ff.CLOJURE=2]="CLOJURE",ff[ff.COFFEESCRIPT=3]="COFFEESCRIPT",ff[ff.CPP=4]="CPP",ff[ff.CSHARP=5]="CSHARP",ff[ff.CSS=6]="CSS",ff[ff.CUDACPP=7]="CUDACPP",ff[ff.DOCKERFILE=8]="DOCKERFILE",ff[ff.GO=9]="GO",ff[ff.GROOVY=10]="GROOVY",ff[ff.HANDLEBARS=11]="HANDLEBARS",ff[ff.HASKELL=12]="HASKELL",ff[ff.HCL=13]="HCL",ff[ff.HTML=14]="HTML",ff[ff.INI=15]="INI",ff[ff.JAVA=16]="JAVA",ff[ff.JAVASCRIPT=17]="JAVASCRIPT",ff[ff.JSON=18]="JSON",ff[ff.JULIA=19]="JULIA",ff[ff.KOTLIN=20]="KOTLIN",ff[ff.LATEX=21]="LATEX",ff[ff.LESS=22]="LESS",ff[ff.LUA=23]="LUA",ff[ff.MAKEFILE=24]="MAKEFILE",ff[ff.MARKDOWN=25]="MARKDOWN",ff[ff.OBJECTIVEC=26]="OBJECTIVEC",ff[ff.OBJECTIVECPP=27]="OBJECTIVECPP",ff[ff.PERL=28]="PERL",ff[ff.PHP=29]="PHP",ff[ff.PLAINTEXT=30]="PLAINTEXT",ff[ff.PROTOBUF=31]="PROTOBUF",ff[ff.PBTXT=32]="PBTXT",ff[ff.PYTHON=33]="PYTHON",ff[ff.R=34]="R",ff[ff.RUBY=35]="RUBY",ff[ff.RUST=36]="RUST",ff[ff.SASS=37]="SASS",ff[ff.SCALA=38]="SCALA",ff[ff.SCSS=39]="SCSS",ff[ff.SHELL=40]="SHELL",ff[ff.SQL=41]="SQL",ff[ff.STARLARK=42]="STARLARK",ff[ff.SWIFT=43]="SWIFT",ff[ff.TSX=44]="TSX",ff[ff.TYPESCRIPT=45]="TYPESCRIPT",ff[ff.VISUALBASIC=46]="VISUALBASIC",ff[ff.VUE=47]="VUE",ff[ff.XML=48]="XML",ff[ff.XSL=49]="XSL",ff[ff.YAML=50]="YAML",ff[ff.SVELTE=51]="SVELTE",ff[ff.TOML=52]="TOML",ff[ff.DART=53]="DART",ff[ff.RST=54]="RST",ff[ff.OCAML=55]="OCAML",ff[ff.CMAKE=56]="CMAKE",ff[ff.PASCAL=57]="PASCAL",ff[ff.ELIXIR=58]="ELIXIR",ff[ff.FSHARP=59]="FSHARP",ff[ff.LISP=60]="LISP",ff[ff.MATLAB=61]="MATLAB",ff[ff.POWERSHELL=62]="POWERSHELL",ff[ff.SOLIDITY=63]="SOLIDITY",ff[ff.ADA=64]="ADA",ff[ff.OCAML_INTERFACE=65]="OCAML_INTERFACE",Kh.util.setEnumType(hf,"exa.codeium_common_pb.Language",[{no:0,name:"LANGUAGE_UNSPECIFIED"},{no:1,name:"LANGUAGE_C"},{no:2,name:"LANGUAGE_CLOJURE"},{no:3,name:"LANGUAGE_COFFEESCRIPT"},{no:4,name:"LANGUAGE_CPP"},{no:5,name:"LANGUAGE_CSHARP"},{no:6,name:"LANGUAGE_CSS"},{no:7,name:"LANGUAGE_CUDACPP"},{no:8,name:"LANGUAGE_DOCKERFILE"},{no:9,name:"LANGUAGE_GO"},{no:10,name:"LANGUAGE_GROOVY"},{no:11,name:"LANGUAGE_HANDLEBARS"},{no:12,name:"LANGUAGE_HASKELL"},{no:13,name:"LANGUAGE_HCL"},{no:14,name:"LANGUAGE_HTML"},{no:15,name:"LANGUAGE_INI"},{no:16,name:"LANGUAGE_JAVA"},{no:17,name:"LANGUAGE_JAVASCRIPT"},{no:18,name:"LANGUAGE_JSON"},{no:19,name:"LANGUAGE_JULIA"},{no:20,name:"LANGUAGE_KOTLIN"},{no:21,name:"LANGUAGE_LATEX"},{no:22,name:"LANGUAGE_LESS"},{no:23,name:"LANGUAGE_LUA"},{no:24,name:"LANGUAGE_MAKEFILE"},{no:25,name:"LANGUAGE_MARKDOWN"},{no:26,name:"LANGUAGE_OBJECTIVEC"},{no:27,name:"LANGUAGE_OBJECTIVECPP"},{no:28,name:"LANGUAGE_PERL"},{no:29,name:"LANGUAGE_PHP"},{no:30,name:"LANGUAGE_PLAINTEXT"},{no:31,name:"LANGUAGE_PROTOBUF"},{no:32,name:"LANGUAGE_PBTXT"},{no:33,name:"LANGUAGE_PYTHON"},{no:34,name:"LANGUAGE_R"},{no:35,name:"LANGUAGE_RUBY"},{no:36,name:"LANGUAGE_RUST"},{no:37,name:"LANGUAGE_SASS"},{no:38,name:"LANGUAGE_SCALA"},{no:39,name:"LANGUAGE_SCSS"},{no:40,name:"LANGUAGE_SHELL"},{no:41,name:"LANGUAGE_SQL"},{no:42,name:"LANGUAGE_STARLARK"},{no:43,name:"LANGUAGE_SWIFT"},{no:44,name:"LANGUAGE_TSX"},{no:45,name:"LANGUAGE_TYPESCRIPT"},{no:46,name:"LANGUAGE_VISUALBASIC"},{no:47,name:"LANGUAGE_VUE"},{no:48,name:"LANGUAGE_XML"},{no:49,name:"LANGUAGE_XSL"},{no:50,name:"LANGUAGE_YAML"},{no:51,name:"LANGUAGE_SVELTE"},{no:52,name:"LANGUAGE_TOML"},{no:53,name:"LANGUAGE_DART"},{no:54,name:"LANGUAGE_RST"},{no:55,name:"LANGUAGE_OCAML"},{no:56,name:"LANGUAGE_CMAKE"},{no:57,name:"LANGUAGE_PASCAL"},{no:58,name:"LANGUAGE_ELIXIR"},{no:59,name:"LANGUAGE_FSHARP"},{no:60,name:"LANGUAGE_LISP"},{no:61,name:"LANGUAGE_MATLAB"},{no:62,name:"LANGUAGE_POWERSHELL"},{no:63,name:"LANGUAGE_SOLIDITY"},{no:64,name:"LANGUAGE_ADA"},{no:65,name:"LANGUAGE_OCAML_INTERFACE"}]);const mf=class e extends Su{constructor(e){super(),n(this,"completionId",""),n(this,"text",""),n(this,"prefix",""),n(this,"stop",""),n(this,"score",0),n(this,"tokens",[]),n(this,"decodedTokens",[]),n(this,"probabilities",[]),n(this,"adjustedProbabilities",[]),n(this,"generatedLength",zu.zero),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(mf,"runtime",Kh),n(mf,"typeName","exa.codeium_common_pb.Completion"),n(mf,"fields",Kh.util.newFieldList((()=>[{no:1,name:"completion_id",kind:"scalar",T:9},{no:2,name:"text",kind:"scalar",T:9},{no:3,name:"prefix",kind:"scalar",T:9},{no:4,name:"stop",kind:"scalar",T:9},{no:5,name:"score",kind:"scalar",T:1},{no:6,name:"tokens",kind:"scalar",T:4,repeated:!0},{no:7,name:"decoded_tokens",kind:"scalar",T:9,repeated:!0},{no:8,name:"probabilities",kind:"scalar",T:1,repeated:!0},{no:9,name:"adjusted_probabilities",kind:"scalar",T:1,repeated:!0},{no:10,name:"generated_length",kind:"scalar",T:4}])));let pf=mf;const gf=class e extends Su{constructor(e){super(),n(this,"ideName",""),n(this,"ideVersion",""),n(this,"extensionName",""),n(this,"extensionVersion",""),n(this,"apiKey",""),n(this,"locale",""),n(this,"sessionId",""),n(this,"requestId",zu.zero),n(this,"userAgent",""),n(this,"url",""),n(this,"authSource",af.CODEIUM),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(gf,"runtime",Kh),n(gf,"typeName","exa.codeium_common_pb.Metadata"),n(gf,"fields",Kh.util.newFieldList((()=>[{no:1,name:"ide_name",kind:"scalar",T:9},{no:7,name:"ide_version",kind:"scalar",T:9},{no:12,name:"extension_name",kind:"scalar",T:9},{no:2,name:"extension_version",kind:"scalar",T:9},{no:3,name:"api_key",kind:"scalar",T:9},{no:4,name:"locale",kind:"scalar",T:9},{no:10,name:"session_id",kind:"scalar",T:9},{no:9,name:"request_id",kind:"scalar",T:4},{no:13,name:"user_agent",kind:"scalar",T:9},{no:14,name:"url",kind:"scalar",T:9},{no:15,name:"auth_source",kind:"enum",T:Kh.getEnumType(af)}])));let vf=gf;const xf=class e extends Su{constructor(e){super(),n(this,"tabSize",zu.zero),n(this,"insertSpaces",!1),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(xf,"runtime",Kh),n(xf,"typeName","exa.codeium_common_pb.EditorOptions"),n(xf,"fields",Kh.util.newFieldList((()=>[{no:1,name:"tab_size",kind:"scalar",T:4},{no:2,name:"insert_spaces",kind:"scalar",T:8}])));let yf=xf;e=class extends Su{constructor(e){super(),n(this,"eventType",lf.UNSPECIFIED),n(this,"eventJson",""),n(this,"timestampUnixMs",zu.zero),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}},n(e,"runtime",Kh),n(e,"typeName","exa.codeium_common_pb.Event"),n(e,"fields",Kh.util.newFieldList((()=>[{no:1,name:"event_type",kind:"enum",T:Kh.getEnumType(lf)},{no:2,name:"event_json",kind:"scalar",T:9},{no:3,name:"timestamp_unix_ms",kind:"scalar",T:3}])));class bf extends on{constructor(e,t){super(),n(this,"index"),n(this,"total"),this.index=e,this.total=t}toDOM(){const e=document.createElement("span");e.setAttribute("aria-hidden","true"),e.className="cm-codeium-cycle";const t=e.appendChild(document.createElement("span"));t.className="cm-codeium-cycle-explanation",t.innerText=`${this.index+1}/${this.total}`;const n=e.appendChild(document.createElement("button"));return n.className="cm-codeium-cycle-key",n.innerText="→ (Ctrl ])",n.dataset.action="codeium-cycle",e}ignoreEvent(){return!1}}const wf=rn.define({combine:e=>an(e,{language:hf.TYPESCRIPT,timeout:150,widgetClass:bf,alwaysOn:!0},{})}),kf=rn.define({combine:e=>an(e,{override:()=>[]},{})}),Nf=Rt.mark({class:"cm-ghostText"}),Ef=Pt.define({create:e=>null,update(e,t){var n;const o=t.state.facet(wf);for(const r of t.effects){if(r.is(mu)){const{changeSpecs:e,index:t}=r.value,a=e[t].map((e=>Nf.range(e.absoluteStartPos,e.absoluteEndPos))),s=null==(n=a.at(-1))?void 0:n.to;return{index:t,decorations:Rt.set([...a,...void 0!==s&&e.length>1&&o.widgetClass?[Rt.widget({widget:new o.widgetClass(t,e.length),side:1}).range(s)]:[]]),changeSpecs:e,reverseChangeSet:r.value.reverseChangeSet}}if(r.is(pu))return null;if(r.is(gu))return null}return e?{...e,decorations:e.decorations.map(t.changes),reverseChangeSet:e.reverseChangeSet.map(t.changes)}:e},provide:e=>Dt.decorations.from(e,(e=>(null==e?void 0:e.decorations)||Rt.none))}),Cf=sn.define(),jf=sn.define();var Sf,If;function Af(e){const t=Sf[e];return"string"!=typeof t?e.toString():t[0].toLowerCase()+t.substring(1).replace(/[A-Z]/g,(e=>"_"+e.toLowerCase()))}let Mf;(If=Sf||(Sf={}))[If.Canceled=1]="Canceled",If[If.Unknown=2]="Unknown",If[If.InvalidArgument=3]="InvalidArgument",If[If.DeadlineExceeded=4]="DeadlineExceeded",If[If.NotFound=5]="NotFound",If[If.AlreadyExists=6]="AlreadyExists",If[If.PermissionDenied=7]="PermissionDenied",If[If.ResourceExhausted=8]="ResourceExhausted",If[If.FailedPrecondition=9]="FailedPrecondition",If[If.Aborted=10]="Aborted",If[If.OutOfRange=11]="OutOfRange",If[If.Unimplemented=12]="Unimplemented",If[If.Internal=13]="Internal",If[If.Unavailable=14]="Unavailable",If[If.DataLoss=15]="DataLoss",If[If.Unauthenticated=16]="Unauthenticated";class Tf extends Error{constructor(e,t=Sf.Unknown,n,o,r){super(function(e,t){return e.length?`[${Af(t)}] ${e}`:`[${Af(t)}]`}(e,t)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=t,this.metadata=new Headers(null!=n?n:{}),this.details=null!=o?o:[],this.cause=r}static from(e,t=Sf.Unknown){return e instanceof Tf?e:e instanceof Error?"AbortError"==e.name?new Tf(e.message,Sf.Canceled):new Tf(e.message,t,void 0,void 0,e):new Tf(String(e),t,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error&&(Object.getPrototypeOf(e)===Tf.prototype||"ConnectError"===e.name&&"code"in e&&"number"==typeof e.code&&"metadata"in e&&"details"in e&&Array.isArray(e.details)&&"rawMessage"in e&&"string"==typeof e.rawMessage&&"cause"in e)}findDetails(e){const t="typeName"in e?{findMessage:t=>t===e.typeName?e:void 0}:e,n=[];for(const r of this.details){if("getType"in r){t.findMessage(r.getType().typeName)&&n.push(r);continue}const e=t.findMessage(r.type);if(e)try{n.push(e.fromBinary(r.value))}catch(o){}}return n}}var Of=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(n){t[n]=e[n]&&function(t){return new Promise((function(o,r){(function(e,t,n,o){Promise.resolve(o).then((function(t){e({value:t,done:n})}),t)})(o,r,(t=e[n](t)).done,t.value)}))}}},Df=function(e){return this instanceof Df?(this.v=e,this):new Df(e)},_f=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(e,t||[]),a=[];return o={},s("next"),s("throw"),s("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),o[Symbol.asyncIterator]=function(){return this},o;function s(e,t){r[e]&&(o[e]=function(t){return new Promise((function(n,o){a.push([e,t,n,o])>1||i(e,t)}))},t&&(o[e]=t(o[e])))}function i(e,t){try{(n=r[e](t)).value instanceof Df?Promise.resolve(n.value.v).then(l,c):d(a[0][2],n)}catch(o){d(a[0][3],o)}var n}function l(e){i("next",e)}function c(e){i("throw",e)}function d(e,t){e(t),a.shift(),a.length&&i(a[0][0],a[0][1])}};function Pf(e){return _f(this,arguments,(function*(){yield Df(yield*function(e){var t,n;return t={},o("next"),o("throw",(function(e){throw e})),o("return"),t[Symbol.iterator]=function(){return this},t;function o(o,r){t[o]=e[o]?function(t){return(n=!n)?{value:Df(e[o](t)),done:!1}:r?r(t):t}:r}}(Of(e)))}))}var Rf=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(n){t[n]=e[n]&&function(t){return new Promise((function(o,r){(function(e,t,n,o){Promise.resolve(o).then((function(t){e({value:t,done:n})}),t)})(o,r,(t=e[n](t)).done,t.value)}))}}},Ff=function(e){return this instanceof Ff?(this.v=e,this):new Ff(e)},Lf=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(e,t||[]),a=[];return o={},s("next"),s("throw"),s("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),o[Symbol.asyncIterator]=function(){return this},o;function s(e,t){r[e]&&(o[e]=function(t){return new Promise((function(n,o){a.push([e,t,n,o])>1||i(e,t)}))},t&&(o[e]=t(o[e])))}function i(e,t){try{(n=r[e](t)).value instanceof Ff?Promise.resolve(n.value.v).then(l,c):d(a[0][2],n)}catch(o){d(a[0][3],o)}var n}function l(e){i("next",e)}function c(e){i("throw",e)}function d(e,t){e(t),a.shift(),a.length&&i(a[0][0],a[0][1])}};function zf(e,t){const n=function(){var n,o;return Lf(this,arguments,(function*(){const r=yield Ff(e);null===(n=null==t?void 0:t.onHeader)||void 0===n||n.call(t,r.header),yield Ff(yield*function(e){var t,n;return t={},o("next"),o("throw",(function(e){throw e})),o("return"),t[Symbol.iterator]=function(){return this},t;function o(o,r){t[o]=e[o]?function(t){return(n=!n)?{value:Ff(e[o](t)),done:!1}:r?r(t):t}:r}}(Rf(r.message))),null===(o=null==t?void 0:t.onTrailer)||void 0===o||o.call(t,r.trailer)}))}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>n.next()})}}function Bf(e){if(!e.aborted)return;if(void 0!==e.reason)return e.reason;const t=new Error("This operation was aborted");return t.name="AbortError",t}function Uf(){return{get(e){return e.id in this?this[e.id]:e.defaultValue},set(e,t){return this[e.id]=t,this},delete(e){return delete this[e.id],this}}}function Vf(e,t,n){const o="string"==typeof t?t:t.typeName,r="string"==typeof n?n:n.name;return e.toString().replace(/\/?$/,`/${o}/${r}`)}function $f(e,t){return t instanceof e?t:new e(t)}function Gf(e,t){function n(t){return!0===t.done?t:{done:t.done,value:$f(e,t.value)}}return{[Symbol.asyncIterator](){const e=t[Symbol.asyncIterator](),o={next:()=>e.next().then(n)};return void 0!==e.throw&&(o.throw=t=>e.throw(t).then(n)),void 0!==e.return&&(o.return=t=>e.return(t).then(n)),o}}}function Hf(e,t){var n;return null!==(n=null==t?void 0:t.concat().reverse().reduce(((e,t)=>t(e)),e))&&void 0!==n?n:e}function Wf(e){var t;const n=Object.assign({},e);return null!==(t=n.ignoreUnknownFields)&&void 0!==t||(n.ignoreUnknownFields=!0),n}function qf(e,t,n,o){const r=t?Yf(e.I,o):Jf(e.I,n);return{parse:(t?Yf(e.O,o):Jf(e.O,n)).parse,serialize:r.serialize}}function Yf(e,t){return{parse(n){try{return e.fromBinary(n,t)}catch(o){const e=o instanceof Error?o.message:String(o);throw new Tf(`parse binary: ${e}`,Sf.InvalidArgument)}},serialize(e){try{return e.toBinary(t)}catch(n){const e=n instanceof Error?n.message:String(n);throw new Tf(`serialize binary: ${e}`,Sf.Internal)}}}}function Jf(e,t){var n,o;const r=null!==(n=null==t?void 0:t.textEncoder)&&void 0!==n?n:new TextEncoder,a=null!==(o=null==t?void 0:t.textDecoder)&&void 0!==o?o:new TextDecoder,s=Wf(t);return{parse(t){try{const n=a.decode(t);return e.fromJsonString(n,s)}catch(n){throw Tf.from(n,Sf.InvalidArgument)}},serialize(e){try{const t=e.toJsonString(s);return r.encode(t)}catch(t){throw Tf.from(t,Sf.Internal)}}}}const Kf=/^application\/(connect\+)?(?:(json)(?:; ?charset=utf-?8)?|(proto))$/i;function Xf(e,t,n){if(t&&new Headers(t).forEach(((e,t)=>n.metadata.append(t,e))),"object"!=typeof e||null==e||Array.isArray(e)||!("code"in e)||"string"!=typeof e.code)throw n;const o=function(e){if(!Mf){Mf={};for(const e of Object.values(Sf))"string"!=typeof e&&(Mf[Af(e)]=e)}return Mf[e]}(e.code);if(void 0===o)throw n;const r=e.message;if(null!=r&&"string"!=typeof r)throw n;const a=new Tf(null!=r?r:"",o,t);if("details"in e&&Array.isArray(e.details))for(const i of e.details){if(null===i||"object"!=typeof i||Array.isArray(i)||"string"!=typeof i.type||"string"!=typeof i.value||"debug"in i&&"object"!=typeof i.debug)throw n;try{a.details.push({type:i.type,value:eh.dec(i.value),debug:i.debug})}catch(s){throw n}}return a}function Zf(e){const t=new Tf("invalid end stream",Sf.InvalidArgument);let n;try{n=JSON.parse("string"==typeof e?e:(new TextDecoder).decode(e))}catch(r){throw t}if("object"!=typeof n||null==n||Array.isArray(n))throw t;const o=new Headers;if("metadata"in n){if("object"!=typeof n.metadata||null==n.metadata||Array.isArray(n.metadata))throw t;for(const[e,r]of Object.entries(n.metadata)){if(!Array.isArray(r)||r.some((e=>"string"!=typeof e)))throw t;for(const t of r)o.append(e,t)}}return{metadata:o,error:"error"in n?Xf(n.error,o,t):void 0}}const Qf="Content-Type",em="Content-Length",tm="Content-Encoding",nm="Accept-Encoding",om="Connect-Protocol-Version";function rm(e){const t=new Headers,n=new Headers;return e.forEach(((e,o)=>{o.toLowerCase().startsWith("trailer-")?n.set(o.substring(8),e):t.set(o,e)})),[t,n]}function am(e,t,n,o,r){const a=new Headers(null!=o?o:{});return void 0!==n&&a.set("Connect-Timeout-Ms",`${n}`),a.set(Qf,e==Qh.Unary?t?"application/proto":"application/json":t?"application/connect+proto":"application/connect+json"),a.set(om,"1"),a}function sm(e,t,n){const o=function(e){const t=null==e?void 0:e.match(Kf);if(!t)return;return{stream:!!t[1],binary:!!t[3]}}(n.get("Content-Type"));if(200!==t){const r=new Tf(`HTTP ${t}`,function(e){switch(e){case 400:return Sf.InvalidArgument;case 401:return Sf.Unauthenticated;case 403:return Sf.PermissionDenied;case 404:return Sf.Unimplemented;case 408:return Sf.DeadlineExceeded;case 409:return Sf.Aborted;case 412:return Sf.FailedPrecondition;case 413:case 431:return Sf.ResourceExhausted;case 415:return Sf.Internal;case 429:case 502:case 503:case 504:return Sf.Unavailable;default:return Sf.Unknown}}(t),n);if(e==Qh.Unary&&o&&!o.binary)return{isUnaryError:!0,unaryError:r};throw r}return{isUnaryError:!1}}const im="application/";function lm(e,t,n){let o="?connect=v1";const r=e.header.get(Qf);0===(null==r?void 0:r.indexOf(im))&&(o+="&encoding="+encodeURIComponent(r.slice(12)));const a=e.header.get(tm);null!==a&&"identity"!==a&&(o+="&compression="+encodeURIComponent(a),n=!0),n&&(o+="&base64=1"),o+="&message="+function(e,t){return t?eh.enc(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):encodeURIComponent((new TextDecoder).decode(e))}(t,n);const s=e.url+o,i=new Headers(e.header);return[om,Qf,em,tm,nm].forEach((e=>i.delete(e))),Object.assign(Object.assign({},e),{init:Object.assign(Object.assign({},e.init),{method:"GET"}),url:s,header:i})}function cm(e){const{signal:t,cleanup:n}=function(e){const t=new AbortController,n=()=>{t.abort(new Tf("the operation timed out",Sf.DeadlineExceeded))};let o;return void 0!==e&&(e<=0?n():o=setTimeout(n,e)),{signal:t.signal,cleanup:()=>clearTimeout(o)}}(e.timeoutMs),o=function(...e){const t=new AbortController,n=e.filter((e=>void 0!==e)).concat(t.signal);for(const r of n){if(r.aborted){o.apply(r);break}r.addEventListener("abort",o)}function o(){t.signal.aborted||t.abort(Bf(this));for(const e of n)e.removeEventListener("abort",o)}return t}(e.signal,t);return[o.signal,function(e){const r=Tf.from(t.aborted?Bf(t):e);return o.abort(r),n(),Promise.reject(r)},function(){n(),o.abort()}]}var dm,um,hm,fm,mm,pm;(um=dm||(dm={}))[um.UNSPECIFIED=0]="UNSPECIFIED",um[um.INACTIVE=1]="INACTIVE",um[um.PROCESSING=2]="PROCESSING",um[um.SUCCESS=3]="SUCCESS",um[um.WARNING=4]="WARNING",um[um.ERROR=5]="ERROR",Kh.util.setEnumType(dm,"exa.language_server_pb.CodeiumState",[{no:0,name:"CODEIUM_STATE_UNSPECIFIED"},{no:1,name:"CODEIUM_STATE_INACTIVE"},{no:2,name:"CODEIUM_STATE_PROCESSING"},{no:3,name:"CODEIUM_STATE_SUCCESS"},{no:4,name:"CODEIUM_STATE_WARNING"},{no:5,name:"CODEIUM_STATE_ERROR"}]),(fm=hm||(hm={}))[fm.UNSPECIFIED=0]="UNSPECIFIED",fm[fm.SINGLE=1]="SINGLE",fm[fm.MULTI=2]="MULTI",Kh.util.setEnumType(hm,"exa.language_server_pb.LineType",[{no:0,name:"LINE_TYPE_UNSPECIFIED"},{no:1,name:"LINE_TYPE_SINGLE"},{no:2,name:"LINE_TYPE_MULTI"}]),(pm=mm||(mm={}))[pm.UNSPECIFIED=0]="UNSPECIFIED",pm[pm.INLINE=1]="INLINE",pm[pm.BLOCK=2]="BLOCK",pm[pm.INLINE_MASK=3]="INLINE_MASK",Kh.util.setEnumType(mm,"exa.language_server_pb.CompletionPartType",[{no:0,name:"COMPLETION_PART_TYPE_UNSPECIFIED"},{no:1,name:"COMPLETION_PART_TYPE_INLINE"},{no:2,name:"COMPLETION_PART_TYPE_BLOCK"},{no:3,name:"COMPLETION_PART_TYPE_INLINE_MASK"}]);const gm=class e extends Su{constructor(e){super(),n(this,"threshold",0),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(gm,"runtime",Kh),n(gm,"typeName","exa.language_server_pb.MultilineConfig"),n(gm,"fields",Kh.util.newFieldList((()=>[{no:1,name:"threshold",kind:"scalar",T:2}])));let vm=gm;const xm=class e extends Su{constructor(e){super(),n(this,"metadata"),n(this,"document"),n(this,"editorOptions"),n(this,"otherDocuments",[]),n(this,"experimentConfig"),n(this,"modelName",""),n(this,"multilineConfig"),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(xm,"runtime",Kh),n(xm,"typeName","exa.language_server_pb.GetCompletionsRequest"),n(xm,"fields",Kh.util.newFieldList((()=>[{no:1,name:"metadata",kind:"message",T:vf},{no:2,name:"document",kind:"message",T:Dm},{no:3,name:"editor_options",kind:"message",T:yf},{no:5,name:"other_documents",kind:"message",T:Dm,repeated:!0},{no:7,name:"experiment_config",kind:"message",T:Pm},{no:10,name:"model_name",kind:"scalar",T:9},{no:13,name:"multiline_config",kind:"message",T:vm}])));let ym=xm;const bm=class e extends Su{constructor(e){super(),n(this,"state"),n(this,"completionItems",[]),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(bm,"runtime",Kh),n(bm,"typeName","exa.language_server_pb.GetCompletionsResponse"),n(bm,"fields",Kh.util.newFieldList((()=>[{no:1,name:"state",kind:"message",T:Fm},{no:2,name:"completion_items",kind:"message",T:Hm,repeated:!0}])));let wm=bm;const km=class e extends Su{constructor(e){super(),n(this,"metadata"),n(this,"completionId",""),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(km,"runtime",Kh),n(km,"typeName","exa.language_server_pb.AcceptCompletionRequest"),n(km,"fields",Kh.util.newFieldList((()=>[{no:1,name:"metadata",kind:"message",T:vf},{no:2,name:"completion_id",kind:"scalar",T:9}])));let Nm=km;const Em=class e extends Su{constructor(e){super(),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(Em,"runtime",Kh),n(Em,"typeName","exa.language_server_pb.AcceptCompletionResponse"),n(Em,"fields",Kh.util.newFieldList((()=>[])));let Cm=Em;const jm=class e extends Su{constructor(e){super(),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(jm,"runtime",Kh),n(jm,"typeName","exa.language_server_pb.GetAuthTokenRequest"),n(jm,"fields",Kh.util.newFieldList((()=>[])));let Sm=jm;const Im=class e extends Su{constructor(e){super(),n(this,"authToken",""),n(this,"uuid",""),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(Im,"runtime",Kh),n(Im,"typeName","exa.language_server_pb.GetAuthTokenResponse"),n(Im,"fields",Kh.util.newFieldList((()=>[{no:1,name:"auth_token",kind:"scalar",T:9},{no:2,name:"uuid",kind:"scalar",T:9}])));let Am=Im;const Mm=class e extends Su{constructor(e){super(),n(this,"row",zu.zero),n(this,"col",zu.zero),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(Mm,"runtime",Kh),n(Mm,"typeName","exa.language_server_pb.DocumentPosition"),n(Mm,"fields",Kh.util.newFieldList((()=>[{no:1,name:"row",kind:"scalar",T:4},{no:2,name:"col",kind:"scalar",T:4}])));let Tm=Mm;const Om=class e extends Su{constructor(e){super(),n(this,"absolutePath",""),n(this,"relativePath",""),n(this,"text",""),n(this,"editorLanguage",""),n(this,"language",hf.UNSPECIFIED),n(this,"cursorOffset",zu.zero),n(this,"cursorPosition"),n(this,"lineEnding",""),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(Om,"runtime",Kh),n(Om,"typeName","exa.language_server_pb.Document"),n(Om,"fields",Kh.util.newFieldList((()=>[{no:1,name:"absolute_path",kind:"scalar",T:9},{no:2,name:"relative_path",kind:"scalar",T:9},{no:3,name:"text",kind:"scalar",T:9},{no:4,name:"editor_language",kind:"scalar",T:9},{no:5,name:"language",kind:"enum",T:Kh.getEnumType(hf)},{no:6,name:"cursor_offset",kind:"scalar",T:4},{no:8,name:"cursor_position",kind:"message",T:Tm},{no:7,name:"line_ending",kind:"scalar",T:9}])));let Dm=Om;const _m=class e extends Su{constructor(e){super(),n(this,"forceEnableExperiments",[]),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(_m,"runtime",Kh),n(_m,"typeName","exa.language_server_pb.ExperimentConfig"),n(_m,"fields",Kh.util.newFieldList((()=>[{no:1,name:"force_enable_experiments",kind:"enum",T:Kh.getEnumType(of),repeated:!0}])));let Pm=_m;const Rm=class e extends Su{constructor(e){super(),n(this,"state",dm.UNSPECIFIED),n(this,"message",""),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(Rm,"runtime",Kh),n(Rm,"typeName","exa.language_server_pb.State"),n(Rm,"fields",Kh.util.newFieldList((()=>[{no:1,name:"state",kind:"enum",T:Kh.getEnumType(dm)},{no:2,name:"message",kind:"scalar",T:9}])));let Fm=Rm;const Lm=class e extends Su{constructor(e){super(),n(this,"startOffset",zu.zero),n(this,"endOffset",zu.zero),n(this,"startPosition"),n(this,"endPosition"),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(Lm,"runtime",Kh),n(Lm,"typeName","exa.language_server_pb.Range"),n(Lm,"fields",Kh.util.newFieldList((()=>[{no:1,name:"start_offset",kind:"scalar",T:4},{no:2,name:"end_offset",kind:"scalar",T:4},{no:3,name:"start_position",kind:"message",T:Tm},{no:4,name:"end_position",kind:"message",T:Tm}])));let zm=Lm;const Bm=class e extends Su{constructor(e){super(),n(this,"text",""),n(this,"deltaCursorOffset",zu.zero),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(Bm,"runtime",Kh),n(Bm,"typeName","exa.language_server_pb.Suffix"),n(Bm,"fields",Kh.util.newFieldList((()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"delta_cursor_offset",kind:"scalar",T:3}])));let Um=Bm;const Vm=class e extends Su{constructor(e){super(),n(this,"text",""),n(this,"offset",zu.zero),n(this,"type",mm.UNSPECIFIED),n(this,"prefix",""),n(this,"line",zu.zero),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(Vm,"runtime",Kh),n(Vm,"typeName","exa.language_server_pb.CompletionPart"),n(Vm,"fields",Kh.util.newFieldList((()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"offset",kind:"scalar",T:4},{no:3,name:"type",kind:"enum",T:Kh.getEnumType(mm)},{no:4,name:"prefix",kind:"scalar",T:9},{no:5,name:"line",kind:"scalar",T:4}])));let $m=Vm;const Gm=class e extends Su{constructor(e){super(),n(this,"completion"),n(this,"suffix"),n(this,"range"),n(this,"source",df.UNSPECIFIED),n(this,"completionParts",[]),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(Gm,"runtime",Kh),n(Gm,"typeName","exa.language_server_pb.CompletionItem"),n(Gm,"fields",Kh.util.newFieldList((()=>[{no:1,name:"completion",kind:"message",T:pf},{no:5,name:"suffix",kind:"message",T:Um},{no:2,name:"range",kind:"message",T:zm},{no:3,name:"source",kind:"enum",T:Kh.getEnumType(df)},{no:8,name:"completion_parts",kind:"message",T:$m,repeated:!0}])));let Hm=Gm;const Wm={typeName:"exa.language_server_pb.LanguageServerService",methods:{getCompletions:{name:"GetCompletions",I:ym,O:wm,kind:Qh.Unary},acceptCompletion:{name:"AcceptCompletion",I:Nm,O:Cm,kind:Qh.Unary},getAuthToken:{name:"GetAuthToken",I:Sm,O:Am,kind:Qh.Unary}}};var qm=function(e){return this instanceof qm?(this.v=e,this):new qm(e)},Ym=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(e,t||[]),a=[];return o={},s("next"),s("throw"),s("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),o[Symbol.asyncIterator]=function(){return this},o;function s(e,t){r[e]&&(o[e]=function(t){return new Promise((function(n,o){a.push([e,t,n,o])>1||i(e,t)}))},t&&(o[e]=t(o[e])))}function i(e,t){try{(n=r[e](t)).value instanceof qm?Promise.resolve(n.value.v).then(l,c):d(a[0][2],n)}catch(o){d(a[0][3],o)}var n}function l(e){i("next",e)}function c(e){i("throw",e)}function d(e,t){e(t),a.shift(),a.length&&i(a[0][0],a[0][1])}};const Jm=function(e){var t;!function(){try{new Headers}catch(e){throw new Error("connect-web requires the fetch API. Are you running on an old version of Node.js? Node.js is not supported in Connect for Web - please stay tuned for Connect for Node.")}}();const n=null!==(t=e.useBinaryFormat)&&void 0!==t&&t;return{async unary(t,o,r,a,s,i,l){var c;const{serialize:d,parse:u}=qf(o,n,e.jsonOptions,e.binaryOptions);return a=void 0===a?e.defaultTimeoutMs:a<=0?void 0:a,await function(e){const t=Hf(e.next,e.interceptors),[n,o,r]=cm(e);return t(Object.assign(Object.assign({},e.req),{message:$f(e.req.method.I,e.req.message),signal:n})).then((e=>(r(),e)),o)}({interceptors:e.interceptors,signal:r,timeoutMs:a,req:{stream:!1,service:t,method:o,url:Vf(e.baseUrl,t,o),init:{method:"POST",credentials:null!==(c=e.credentials)&&void 0!==c?c:"same-origin",redirect:"error",mode:"cors"},header:am(o.kind,n,a,s),contextValues:null!=l?l:Uf(),message:i},next:async r=>{var a;let s=null;!0===e.useHttpGet&&o.idempotency===tf.NoSideEffects?r=lm(r,d(r.message),n):s=d(r.message);const i=null!==(a=e.fetch)&&void 0!==a?a:globalThis.fetch,l=await i(r.url,Object.assign(Object.assign({},r.init),{headers:r.header,signal:r.signal,body:s})),{isUnaryError:c,unaryError:h}=sm(o.kind,l.status,l.headers);if(c)throw Xf(await l.json(),function(...e){const t=new Headers;for(const n of e)n.forEach(((e,n)=>{t.append(n,e)}));return t}(...rm(l.headers)),h);const[f,m]=rm(l.headers);return{stream:!1,service:t,method:o,header:f,message:n?u(new Uint8Array(await l.arrayBuffer())):o.O.fromJson(await l.json(),Wf(e.jsonOptions)),trailer:m}}})},async stream(t,o,r,a,s,i,l){var c;const{serialize:d,parse:u}=qf(o,n,e.jsonOptions,e.binaryOptions);function h(e,t,n){return Ym(this,arguments,(function*(){const o=function(e){let t,n=new Uint8Array(0);function o(e){const t=new Uint8Array(n.length+e.length);t.set(n),t.set(e,n.length),n=t}return new ReadableStream({start(){t=e.getReader()},async pull(e){let r;for(;;){if(void 0===r&&n.byteLength>=5){let e=0;for(let t=1;t<5;t++)e=(e<<8)+n[t];r={flags:n[0],length:e}}if(void 0!==r&&n.byteLength>=r.length+5)break;const e=await t.read();if(e.done)break;o(e.value)}if(void 0===r)return 0==n.byteLength?void e.close():void e.error(new Tf("premature end of stream",Sf.DataLoss));const a=n.subarray(5,5+r.length);n=n.subarray(5+r.length),e.enqueue({flags:r.flags,data:a})}})}(e).getReader();let r=!1;for(;;){const e=yield qm(o.read());if(e.done)break;const{flags:a,data:s}=e.value;if(2&~a)yield yield qm(u(s));else{r=!0;const e=Zf(s);if(e.error){const t=e.error;throw n.forEach(((e,n)=>{t.metadata.append(n,e)})),t}e.metadata.forEach(((e,n)=>t.set(n,e)))}}if(!r)throw"missing EndStreamResponse"}))}async function f(e){if(o.kind!=Qh.ServerStreaming)throw"The fetch API does not support streaming request bodies";const t=await e[Symbol.asyncIterator]().next();if(1==t.done)throw"missing request message";return function(e,t){const n=new Uint8Array(t.length+5);n.set(t,5);const o=new DataView(n.buffer,n.byteOffset,n.byteLength);return o.setUint8(0,e),o.setUint32(1,t.length),n}(0,d(t.value))}return a=void 0===a?e.defaultTimeoutMs:a<=0?void 0:a,await function(e){const t=Hf(e.next,e.interceptors),[n,o,r]=cm(e),a=Object.assign(Object.assign({},e.req),{message:Gf(e.req.method.I,e.req.message),signal:n});let s=!1;return n.addEventListener("abort",(function(){var t,n;const o=e.req.message[Symbol.asyncIterator]();s||null===(t=o.throw)||void 0===t||t.call(o,this.reason).catch((()=>{})),null===(n=o.return)||void 0===n||n.call(o).catch((()=>{}))})),t(a).then((e=>Object.assign(Object.assign({},e),{message:{[Symbol.asyncIterator](){const t=e.message[Symbol.asyncIterator]();return{next:()=>t.next().then((e=>(1==e.done&&(s=!0,r()),e)),o)}}}})),o)}({interceptors:e.interceptors,timeoutMs:a,signal:r,req:{stream:!0,service:t,method:o,url:Vf(e.baseUrl,t,o),init:{method:"POST",credentials:null!==(c=e.credentials)&&void 0!==c?c:"same-origin",redirect:"error",mode:"cors"},header:am(o.kind,n,a,s),contextValues:null!=l?l:Uf(),message:i},next:async t=>{var n;const r=null!==(n=e.fetch)&&void 0!==n?n:globalThis.fetch,a=await r(t.url,Object.assign(Object.assign({},t.init),{headers:t.header,signal:t.signal,body:await f(t.message)}));if(sm(o.kind,a.status,a.headers),null===a.body)throw"missing response body";const s=new Headers;return Object.assign(Object.assign({},t),{header:a.headers,trailer:s,message:h(a.body,s,a.headers)})}})}}}({baseUrl:"https://web-backend.codeium.com",useBinaryFormat:!0}),Km=(Zm=Jm,function(e,t){const n={};for(const[o,r]of Object.entries(e.methods)){const a=t(Object.assign(Object.assign({},r),{localName:o,service:e}));null!=a&&(n[o]=a)}return n}(Xm=Wm,(e=>{switch(e.kind){case Qh.Unary:return function(e,t,n){return async function(o,r){var a,s;const i=await e.unary(t,n,null==r?void 0:r.signal,null==r?void 0:r.timeoutMs,null==r?void 0:r.headers,o,null==r?void 0:r.contextValues);return null===(a=null==r?void 0:r.onHeader)||void 0===a||a.call(r,i.header),null===(s=null==r?void 0:r.onTrailer)||void 0===s||s.call(r,i.trailer),i.message}}(Zm,Xm,e);case Qh.ServerStreaming:return function(e,t,n){return function(o,r){return zf(e.stream(t,n,null==r?void 0:r.signal,null==r?void 0:r.timeoutMs,null==r?void 0:r.headers,Pf([o]),null==r?void 0:r.contextValues),r)}}(Zm,Xm,e);case Qh.ClientStreaming:return function(e,t,n){return async function(o,r){var a,s,i,l,c,d;const u=await e.stream(t,n,null==r?void 0:r.signal,null==r?void 0:r.timeoutMs,null==r?void 0:r.headers,o,null==r?void 0:r.contextValues);let h;null===(c=null==r?void 0:r.onHeader)||void 0===c||c.call(r,u.header);try{for(var f,m=!0,p=Rf(u.message);!(a=(f=await p.next()).done);m=!0)l=f.value,m=!1,h=l}catch(g){s={error:g}}finally{try{m||a||!(i=p.return)||await i.call(p)}finally{if(s)throw s.error}}if(!h)throw new Tf("protocol error: missing response message",Sf.Internal);return null===(d=null==r?void 0:r.onTrailer)||void 0===d||d.call(r,u.trailer),h}}(Zm,Xm,e);case Qh.BiDiStreaming:return function(e,t,n){return function(o,r){return zf(e.stream(t,n,null==r?void 0:r.signal,null==r?void 0:r.timeoutMs,null==r?void 0:r.headers,o,null==r?void 0:r.contextValues),r)}}(Zm,Xm,e);default:return null}})));var Xm,Zm;let Qm;try{Qm=crypto.randomUUID()}catch{Qm=function(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>(+e^(crypto.getRandomValues(new Uint8Array(1))[0]??0)&15>>+e/4).toString(16)))}()}async function ep(e,t){const n=e.state.facet(wf),{override:o}=e.state.facet(kf),r=await o(),a=e.state,s=a.selection.main.head,i=a.doc.toString();try{const o=await async function({text:e,cursorOffset:t,config:n,otherDocuments:o}){return await Km.getCompletions({metadata:{ideName:"web",ideVersion:"0.0.5",extensionName:"@valtown/codemirror-codeium",extensionVersion:"1.0.0",apiKey:n.apiKey,sessionId:Qm,authSource:n.authSource},document:{text:e,cursorOffset:BigInt(t),language:n.language,editorLanguage:"typescript",lineEnding:"\n"},editorOptions:{tabSize:2n,insertSpaces:!0},otherDocuments:o,multilineConfig:void 0},{headers:{Authorization:`Basic ${n.apiKey}-${Qm}`}})}({text:i,cursorOffset:s,config:n,otherDocuments:r});if(!o||0===o.completionItems.length)return;if(void 0!==t&&s!==t||"active"===ln(e.state)||!e.hasFocus)return;const l=o.completionItems.map((e=>{let t=0;return e.completionParts.filter((e=>3!==e.type)).map((e=>{const n=Number(e.offset),o=2===e.type?`\n${e.text}`:e.text,r={absoluteStartPos:t+n,absoluteEndPos:t+n+o.length,from:n,to:n,insert:o};return t+=o.length,r}))})),c=0,d=l.at(c);if(!d)return;const u=cn.of(d,a.doc.length),h=u.invert(a.doc);e.dispatch({changes:u,effects:mu.of({index:c,reverseChangeSet:h,changeSpecs:l}),annotations:[jf.of(null),Cf.of(null),dn.addToHistory.of(!1)]})}catch(l){console.warn("copilot completion failed",l),await new Promise((e=>setTimeout(e,300)))}}function tp(){let e=null,t=0;return Dt.updateListener.of((n=>{const o=n.view.state.facet(wf);if(!o.alwaysOn)return;if(!function(e){return e.docChanged&&!e.transactions.some((e=>e.effects.some((e=>e.is(pu)||e.is(gu)))))}(n))return;if(e&&clearTimeout(e),function(e){if(!e.view.hasFocus)return!0;if(e.state.field(Ef))return!0;if("active"===ln(e.state))return!0;for(const t of e.transactions)if(void 0!==t.annotation(Cf))return!0}(n))return;const r=n.state.selection.main.head;o.shouldComplete&&!o.shouldComplete(new un(n.view.state,r,!1))||(e=setTimeout((async()=>{r===t&&await ep(n.view,t)}),o.timeout),t=r)}))}function np(e){var t;const n=e.state.field(Ef);if(!n)return!1;const o=null==(t=n.reverseChangeSet)?void 0:t.invert(e.state.doc);e.dispatch({changes:n.reverseChangeSet,effects:pu.of(null),annotations:[jf.of(null),Cf.of(null),dn.addToHistory.of(!1)]});let r=0;return null==o||o.iterChangedRanges(((e,t,n,o)=>{r=o})),e.dispatch({changes:o,selection:Ot.cursor(r),annotations:[Cf.of(null),dn.addToHistory.of(!0)]}),!0}const op=e=>{const{state:t}=e,n=t.field(Ef);if(!n)return!1;const{changeSpecs:o}=n;if(o.length<2)return!1;const r=(n.index+1)%o.length,a=o.at(r);if(!a)return!1;const s=n.reverseChangeSet.apply(t.doc),i=cn.of(n.reverseChangeSet,t.doc.length).compose(cn.of(a,s.length)),l=cn.of(a,s.length).invert(s);return e.dispatch({changes:i,effects:mu.of({index:r,reverseChangeSet:l,changeSpecs:o}),annotations:[jf.of(null),Cf.of(null),dn.addToHistory.of(!1)]}),!0};function rp(e){const t=e.state.field(Ef);return!!t&&(e.dispatch({changes:t.reverseChangeSet,effects:gu.of(null),annotations:[jf.of(null),Cf.of(null),dn.addToHistory.of(!1)]}),!1)}function ap(){return Dt.domEventHandlers({keydown:(e,t)=>("]"!==e.key||!e.ctrlKey)&&("Shift"!==e.key&&"Control"!==e.key&&"Alt"!==e.key&&"Meta"!==e.key&&function(e,t){return!!e.state.field(Ef)&&("Tab"===t?np(e):rp(e))}(t,e.key)),mouseup(e,t){const n=e.target;return"BUTTON"===n.nodeName&&"codeium-cycle"===n.dataset.action?(op(t),e.stopPropagation(),e.preventDefault(),!0):function(e){var t,n;let o=!1;const r=null==(t=e.state.selection.asSingle().ranges.at(0))?void 0:t.head,a=e.state.field(Ef);return!(void 0===r||!a)&&(null==(n=a.decorations)||n.between(r,r,(()=>{o=!0})),o)}(t)?np(t):rp(t)}})}const sp=e=>{const t=[];return"codeium"===e.copilot&&e.codeium_api_key&&t.push(function(e){return[wf.of(e),Ef,nn.highest(Qt.of([{key:"Ctrl-]",run:op}])),nn.highest(Dt.updateListener.of((e=>{e.focusChanged&&rp(e.view)}))),nn.high(ap()),tp()]}({apiKey:e.codeium_api_key,language:hf.PYTHON}),kf.of({override:async()=>[{text:Js(""),language:hf.PYTHON,editorLanguage:"python"}]})),"github"===e.copilot&&t.push(fu({delay:500,fetchFn:async e=>{if(!Xs())return"";if(0===e.doc.length)return"";await new Promise((e=>setTimeout(e,20)));const t=e.doc.toString(),n=function(e,t){const n=e.doc.toString(),o=t.split("\n").length-n.split("\n").length,r=function(e,t){const n=e.lineAt(t);return{line:n.number-1,character:t-n.from}}(e.doc,e.selection.main.head);return r.line+=o,{doc:{source:t,tabSize:e.tabSize,indentSize:1,insertSpaces:!0,path:Qs,version:"replace_me",uri:`file://${Qs}`,relativePath:Qs,languageId:ei,position:r}}}(e,Js(t)),o=function(e,t,n){if(0===e.completions.length)return"";const{displayText:o,position:r}=e.completions[0],a=r.character-t.character,s=a<0?o.slice(-a):o,i=n.doc.sliceString(n.selection.main.head,n.doc.length);for(let l=0;l<s.length;l++){const e=s.slice(l);if(i.startsWith(e))return s.slice(0,l)}return s}(await Zs().getCompletion(n),n.doc.position,e);return o&&U.debug("Copilot suggestion:",o),o}})),[...t,Ks().slice(0,-2)]};const ip=Rt.mark({class:"underline"}),lp=_t.define(),cp=_t.define(),dp=Pt.define({create:()=>Rt.none,update(e,t){let n=e.map(t.changes);for(const o of t.effects)o.is(lp)?n=e.update({add:[ip.range(o.value.from,o.value.to)]}):o.is(cp)&&(n=Rt.none);return n},provide:e=>Dt.decorations.from(e)});class up{constructor(e,t){n(this,"view"),n(this,"commandClickMode"),n(this,"hoveredRange"),n(this,"onClick"),n(this,"keydown",(e=>{"Meta"!==e.key&&"Control"!==e.key||(this.commandClickMode=!0,this.view.dom.addEventListener("mousemove",this.mousemove),this.view.dom.addEventListener("click",this.click))})),n(this,"keyup",(e=>{"Meta"!==e.key&&"Control"!==e.key||this.exitCommandClickMode()})),n(this,"windowBlur",(()=>{this.commandClickMode&&this.exitCommandClickMode()})),n(this,"mousemove",(e=>{if(!e.metaKey&&!e.ctrlKey)return void this.exitCommandClickMode();if(!this.commandClickMode)return void this.clearUnderline();const t=this.view.posAtCoords({x:e.clientX,y:e.clientY});if(null==t)return void this.clearUnderline();const n=hn(this.view.state).cursorAt(t);if("VariableName"===n.name){const{from:e,to:o}=n;if(this.hoveredRange&&this.hoveredRange.from===e&&this.hoveredRange.to===o)return;this.clearUnderline(),this.hoveredRange={from:e,to:o,position:t},this.view.dispatch({effects:lp.of(this.hoveredRange)})}else this.clearUnderline()})),n(this,"click",(e=>{if(this.hoveredRange){const t=this.view.state.doc.sliceString(this.hoveredRange.from,this.hoveredRange.to);e.preventDefault(),e.stopPropagation(),this.onClick(this.view,t),this.view.dispatch({selection:{head:this.hoveredRange.position,anchor:this.hoveredRange.position}})}})),this.view=e,this.commandClickMode=!1,this.hoveredRange=null,this.onClick=t,window.addEventListener("keydown",this.keydown),window.addEventListener("keyup",this.keyup),window.addEventListener("blur",this.windowBlur),window.addEventListener("mouseleave",this.windowBlur)}update(e){}destroy(){window.removeEventListener("keydown",this.keydown),window.removeEventListener("keyup",this.keyup),window.removeEventListener("blur",this.windowBlur),window.removeEventListener("mouseleave",this.windowBlur),this.view.dom.removeEventListener("mousemove",this.mousemove),this.view.dom.removeEventListener("click",this.click)}exitCommandClickMode(){this.commandClickMode=!1,this.view.dom.removeEventListener("mousemove",this.mousemove),this.view.dom.removeEventListener("click",this.click),this.clearUnderline()}clearUnderline(){this.hoveredRange&&(this.view.dispatch({effects:cp.of(null)}),this.hoveredRange=null)}}const hp=({variant:e,settings:t,styles:n})=>{const o=Dt.theme({"&":{backgroundColor:t.background,color:t.foreground},".cm-content":{caretColor:t.caret},".cm-cursor, .cm-dropCursor":{borderLeftColor:t.caret},"&.cm-focused .cm-selectionBackgroundm .cm-selectionBackground, .cm-content ::selection":{backgroundColor:t.selection},".cm-activeLine":{backgroundColor:t.lineHighlight},".cm-gutters":{backgroundColor:t.gutterBackground,color:t.gutterForeground},".cm-activeLineGutter":{backgroundColor:t.lineHighlight}},{dark:"dark"===e}),r=mn.define(n);return[o,pn(r)]};hp({variant:"dark",settings:{background:"#200020",foreground:"#D0D0FF",caret:"#7070FF",selection:"#80000080",gutterBackground:"#200020",gutterForeground:"#C080C0",lineHighlight:"#80000040"},styles:[{tag:gn.comment,color:"#404080"},{tag:[gn.string,gn.regexp],color:"#999999"},{tag:gn.number,color:"#7090B0"},{tag:[gn.bool,gn.null],color:"#8080A0"},{tag:[gn.punctuation,gn.derefOperator],color:"#805080"},{tag:gn.keyword,color:"#60B0FF"},{tag:gn.definitionKeyword,color:"#B0FFF0"},{tag:gn.moduleKeyword,color:"#60B0FF"},{tag:gn.operator,color:"#A0A0FF"},{tag:[gn.variableName,gn.self],color:"#008080"},{tag:gn.operatorKeyword,color:"#A0A0FF"},{tag:gn.controlKeyword,color:"#80A0FF"},{tag:gn.className,color:"#70E080"},{tag:[gn.function(gn.propertyName),gn.propertyName],color:"#50A0A0"},{tag:gn.tagName,color:"#009090"},{tag:gn.modifier,color:"#B0FFF0"},{tag:[gn.squareBracket,gn.attributeName],color:"#D0D0FF"}]}),hp({variant:"light",settings:{background:"#fcfcfc",foreground:"#5c6166",caret:"#ffaa33",selection:"#036dd626",gutterBackground:"#fcfcfc",gutterForeground:"#8a919966",lineHighlight:"#8a91991a"},styles:[{tag:gn.comment,color:"#787b8099"},{tag:gn.string,color:"#86b300"},{tag:gn.regexp,color:"#4cbf99"},{tag:[gn.number,gn.bool,gn.null],color:"#ffaa33"},{tag:gn.variableName,color:"#5c6166"},{tag:[gn.definitionKeyword,gn.modifier],color:"#fa8d3e"},{tag:[gn.keyword,gn.special(gn.brace)],color:"#fa8d3e"},{tag:gn.operator,color:"#ed9366"},{tag:gn.separator,color:"#5c6166b3"},{tag:gn.punctuation,color:"#5c6166"},{tag:[gn.definition(gn.propertyName),gn.function(gn.variableName)],color:"#f2ae49"},{tag:[gn.className,gn.definition(gn.typeName)],color:"#22a4e6"},{tag:[gn.tagName,gn.typeName,gn.self,gn.labelName],color:"#55b4d4"},{tag:gn.angleBracket,color:"#55b4d480"},{tag:gn.attributeName,color:"#f2ae49"}]}),hp({variant:"dark",settings:{background:"#15191EFA",foreground:"#EEF2F7",caret:"#C4C4C4",selection:"#90B2D557",gutterBackground:"#15191EFA",gutterForeground:"#aaaaaa95",lineHighlight:"#57575712"},styles:[{tag:gn.comment,color:"#6E6E6E"},{tag:[gn.string,gn.regexp,gn.special(gn.brace)],color:"#5C81B3"},{tag:gn.number,color:"#C1E1B8"},{tag:gn.bool,color:"#53667D"},{tag:[gn.definitionKeyword,gn.modifier,gn.function(gn.propertyName)],color:"#A3D295",fontWeight:"bold"},{tag:[gn.keyword,gn.moduleKeyword,gn.operatorKeyword,gn.operator],color:"#697A8E",fontWeight:"bold"},{tag:[gn.variableName,gn.attributeName],color:"#708E67"},{tag:[gn.function(gn.variableName),gn.definition(gn.propertyName),gn.derefOperator],color:"#fff"},{tag:gn.tagName,color:"#A3D295"}]}),hp({variant:"dark",settings:{background:"#2e241d",foreground:"#BAAE9E",caret:"#A7A7A7",selection:"#DDF0FF33",gutterBackground:"#28211C",gutterForeground:"#BAAE9E90",lineHighlight:"#FFFFFF08"},styles:[{tag:gn.comment,color:"#666666"},{tag:[gn.string,gn.special(gn.brace)],color:"#54BE0D"},{tag:gn.regexp,color:"#E9C062"},{tag:gn.number,color:"#CF6A4C"},{tag:[gn.keyword,gn.operator],color:"#5EA6EA"},{tag:gn.variableName,color:"#7587A6"},{tag:[gn.definitionKeyword,gn.modifier],color:"#F9EE98"},{tag:[gn.propertyName,gn.function(gn.variableName)],color:"#937121"},{tag:[gn.typeName,gn.angleBracket,gn.tagName],color:"#9B859D"}]}),hp({variant:"dark",settings:{background:"#3b2627",foreground:"#E6E1C4",caret:"#E6E1C4",selection:"#16120E",gutterBackground:"#3b2627",gutterForeground:"#E6E1C490",lineHighlight:"#1F1611"},styles:[{tag:gn.comment,color:"#6B4E32"},{tag:[gn.keyword,gn.operator,gn.derefOperator],color:"#EF5D32"},{tag:gn.className,color:"#EFAC32",fontWeight:"bold"},{tag:[gn.typeName,gn.propertyName,gn.function(gn.variableName),gn.definition(gn.variableName)],color:"#EFAC32"},{tag:gn.definition(gn.typeName),color:"#EFAC32",fontWeight:"bold"},{tag:gn.labelName,color:"#EFAC32",fontWeight:"bold"},{tag:[gn.number,gn.bool],color:"#6C99BB"},{tag:[gn.variableName,gn.self],color:"#7DAF9C"},{tag:[gn.string,gn.special(gn.brace),gn.regexp],color:"#D9D762"},{tag:[gn.angleBracket,gn.tagName,gn.attributeName],color:"#EFCB43"}]}),hp({variant:"dark",settings:{background:"#000205",foreground:"#FFFFFF",caret:"#E60065",selection:"#E60C6559",gutterBackground:"#000205",gutterForeground:"#ffffff90",lineHighlight:"#4DD7FC1A"},styles:[{tag:gn.comment,color:"#404040"},{tag:[gn.string,gn.special(gn.brace),gn.regexp],color:"#00D8FF"},{tag:gn.number,color:"#E62286"},{tag:[gn.variableName,gn.attributeName,gn.self],color:"#E62286",fontWeight:"bold"},{tag:gn.function(gn.variableName),color:"#fff",fontWeight:"bold"}]}),hp({variant:"light",settings:{background:"#fff",foreground:"#000",caret:"#000",selection:"#BDD5FC",gutterBackground:"#fff",gutterForeground:"#00000070",lineHighlight:"#FFFBD1"},styles:[{tag:gn.comment,color:"#BCC8BA"},{tag:[gn.string,gn.special(gn.brace),gn.regexp],color:"#5D90CD"},{tag:[gn.number,gn.bool,gn.null],color:"#46A609"},{tag:gn.keyword,color:"#AF956F"},{tag:[gn.definitionKeyword,gn.modifier],color:"#C52727"},{tag:[gn.angleBracket,gn.tagName,gn.attributeName],color:"#606060"},{tag:gn.self,color:"#000"}]}),hp({variant:"dark",settings:{background:"#00254b",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#B36539BF",gutterBackground:"#00254b",gutterForeground:"#FFFFFF70",lineHighlight:"#00000059"},styles:[{tag:gn.comment,color:"#0088FF"},{tag:gn.string,color:"#3AD900"},{tag:gn.regexp,color:"#80FFC2"},{tag:[gn.number,gn.bool,gn.null],color:"#FF628C"},{tag:[gn.definitionKeyword,gn.modifier],color:"#FFEE80"},{tag:gn.variableName,color:"#CCCCCC"},{tag:gn.self,color:"#FF80E1"},{tag:[gn.className,gn.definition(gn.propertyName),gn.function(gn.variableName),gn.definition(gn.typeName),gn.labelName],color:"#FFDD00"},{tag:[gn.keyword,gn.operator],color:"#FF9D00"},{tag:[gn.propertyName,gn.typeName],color:"#80FFBB"},{tag:gn.special(gn.brace),color:"#EDEF7D"},{tag:gn.attributeName,color:"#9EFFFF"},{tag:gn.derefOperator,color:"#fff"}]}),hp({variant:"dark",settings:{background:"#060521",foreground:"#E0E0E0",caret:"#FFFFFFA6",selection:"#122BBB",gutterBackground:"#060521",gutterForeground:"#E0E0E090",lineHighlight:"#FFFFFF0F"},styles:[{tag:gn.comment,color:"#AEAEAE"},{tag:[gn.string,gn.special(gn.brace),gn.regexp],color:"#8DFF8E"},{tag:[gn.className,gn.definition(gn.propertyName),gn.function(gn.variableName),gn.function(gn.definition(gn.variableName)),gn.definition(gn.typeName)],color:"#A3EBFF"},{tag:[gn.number,gn.bool,gn.null],color:"#62E9BD"},{tag:[gn.keyword,gn.operator],color:"#2BF1DC"},{tag:[gn.definitionKeyword,gn.modifier],color:"#F8FBB1"},{tag:[gn.variableName,gn.self],color:"#B683CA"},{tag:[gn.angleBracket,gn.tagName,gn.typeName,gn.propertyName],color:"#60A4F1"},{tag:gn.derefOperator,color:"#E0E0E0"},{tag:gn.attributeName,color:"#7BACCA"}]}),hp({variant:"dark",settings:{background:"#2d2f3f",foreground:"#f8f8f2",caret:"#f8f8f0",selection:"#44475a",gutterBackground:"#282a36",gutterForeground:"rgb(144, 145, 148)",lineHighlight:"#44475a"},styles:[{tag:gn.comment,color:"#6272a4"},{tag:[gn.string,gn.special(gn.brace)],color:"#f1fa8c"},{tag:[gn.number,gn.self,gn.bool,gn.null],color:"#bd93f9"},{tag:[gn.keyword,gn.operator],color:"#ff79c6"},{tag:[gn.definitionKeyword,gn.typeName],color:"#8be9fd"},{tag:gn.definition(gn.typeName),color:"#f8f8f2"},{tag:[gn.className,gn.definition(gn.propertyName),gn.function(gn.variableName),gn.attributeName],color:"#50fa7b"}]}),hp({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#80C7FF",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#C1E2F8"},styles:[{tag:gn.comment,color:"#AAAAAA"},{tag:[gn.keyword,gn.operator,gn.typeName,gn.tagName,gn.propertyName],color:"#2F6F9F",fontWeight:"bold"},{tag:[gn.attributeName,gn.definition(gn.propertyName)],color:"#4F9FD0"},{tag:[gn.className,gn.string,gn.special(gn.brace)],color:"#CF4F5F"},{tag:gn.number,color:"#CF4F5F",fontWeight:"bold"},{tag:gn.variableName,fontWeight:"bold"}]}),hp({variant:"light",settings:{background:"#f2f1f8",foreground:"#0c006b",caret:"#5c49e9",selection:"#d5d1f2",gutterBackground:"#f2f1f8",gutterForeground:"#0c006b70",lineHighlight:"#e1def3"},styles:[{tag:gn.comment,color:"#9995b7"},{tag:gn.keyword,color:"#ff5792",fontWeight:"bold"},{tag:[gn.definitionKeyword,gn.modifier],color:"#ff5792"},{tag:[gn.className,gn.tagName,gn.definition(gn.typeName)],color:"#0094f0"},{tag:[gn.number,gn.bool,gn.null,gn.special(gn.brace)],color:"#5842ff"},{tag:[gn.definition(gn.propertyName),gn.function(gn.variableName)],color:"#0095a8"},{tag:gn.typeName,color:"#b3694d"},{tag:[gn.propertyName,gn.variableName],color:"#fa8900"},{tag:gn.operator,color:"#ff5792"},{tag:gn.self,color:"#e64100"},{tag:[gn.string,gn.regexp],color:"#00b368"},{tag:[gn.paren,gn.bracket],color:"#0431fa"},{tag:gn.labelName,color:"#00bdd6"},{tag:gn.attributeName,color:"#e64100"},{tag:gn.angleBracket,color:"#9995b7"}]}),hp({variant:"light",settings:{background:"#faf4ed",foreground:"#575279",caret:"#575279",selection:"#6e6a8614",gutterBackground:"#faf4ed",gutterForeground:"#57527970",lineHighlight:"#6e6a860d"},styles:[{tag:gn.comment,color:"#9893a5"},{tag:[gn.bool,gn.null],color:"#286983"},{tag:gn.number,color:"#d7827e"},{tag:gn.className,color:"#d7827e"},{tag:[gn.angleBracket,gn.tagName,gn.typeName],color:"#56949f"},{tag:gn.attributeName,color:"#907aa9"},{tag:gn.punctuation,color:"#797593"},{tag:[gn.keyword,gn.modifier],color:"#286983"},{tag:[gn.string,gn.regexp],color:"#ea9d34"},{tag:gn.variableName,color:"#d7827e"}]}),hp({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#FFFD0054",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#00000008"},styles:[{tag:gn.comment,color:"#CFCFCF"},{tag:[gn.number,gn.bool,gn.null],color:"#E66C29"},{tag:[gn.className,gn.definition(gn.propertyName),gn.function(gn.variableName),gn.labelName,gn.definition(gn.typeName)],color:"#2EB43B"},{tag:gn.keyword,color:"#D8B229"},{tag:gn.operator,color:"#4EA44E",fontWeight:"bold"},{tag:[gn.definitionKeyword,gn.modifier],color:"#925A47"},{tag:gn.string,color:"#704D3D"},{tag:gn.typeName,color:"#2F8996"},{tag:[gn.variableName,gn.propertyName],color:"#77ACB0"},{tag:gn.self,color:"#77ACB0",fontWeight:"bold"},{tag:gn.regexp,color:"#E3965E"},{tag:[gn.tagName,gn.angleBracket],color:"#BAA827"},{tag:gn.attributeName,color:"#B06520"},{tag:gn.derefOperator,color:"#000"}]}),hp({variant:"light",settings:{background:"#fef7e5",foreground:"#586E75",caret:"#000000",selection:"#073642",gutterBackground:"#fef7e5",gutterForeground:"#586E7580",lineHighlight:"#EEE8D5"},styles:[{tag:gn.comment,color:"#93A1A1"},{tag:gn.string,color:"#2AA198"},{tag:gn.regexp,color:"#D30102"},{tag:gn.number,color:"#D33682"},{tag:gn.variableName,color:"#268BD2"},{tag:[gn.keyword,gn.operator,gn.punctuation],color:"#859900"},{tag:[gn.definitionKeyword,gn.modifier],color:"#073642",fontWeight:"bold"},{tag:[gn.className,gn.self,gn.definition(gn.propertyName)],color:"#268BD2"},{tag:gn.function(gn.variableName),color:"#268BD2"},{tag:[gn.bool,gn.null],color:"#B58900"},{tag:gn.tagName,color:"#268BD2",fontWeight:"bold"},{tag:gn.angleBracket,color:"#93A1A1"},{tag:gn.attributeName,color:"#93A1A1"},{tag:gn.typeName,color:"#859900"}]}),hp({variant:"light",settings:{background:"#FFFFFF",foreground:"#4D4D4C",caret:"#AEAFAD",selection:"#D6D6D6",gutterBackground:"#FFFFFF",gutterForeground:"#4D4D4C80",lineHighlight:"#EFEFEF"},styles:[{tag:gn.comment,color:"#8E908C"},{tag:[gn.variableName,gn.self,gn.propertyName,gn.attributeName,gn.regexp],color:"#C82829"},{tag:[gn.number,gn.bool,gn.null],color:"#F5871F"},{tag:[gn.className,gn.typeName,gn.definition(gn.typeName)],color:"#C99E00"},{tag:[gn.string,gn.special(gn.brace)],color:"#718C00"},{tag:gn.operator,color:"#3E999F"},{tag:[gn.definition(gn.propertyName),gn.function(gn.variableName)],color:"#4271AE"},{tag:gn.keyword,color:"#8959A8"},{tag:gn.derefOperator,color:"#4D4D4C"}]});const fp=hp({variant:"light",settings:{background:"#ffffff",foreground:"#000000",caret:"#000000",selection:"#d7d4f0",lineHighlight:"#f7f7f7",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:gn.comment,color:"#708090"},{tag:gn.variableName,color:"#000000"},{tag:[gn.string,gn.special(gn.brace)],color:"#a11"},{tag:gn.number,color:"#164"},{tag:gn.bool,color:"#219"},{tag:gn.null,color:"#219"},{tag:gn.keyword,color:"#708",fontWeight:500},{tag:gn.className,color:"#00f"},{tag:gn.definition(gn.typeName),color:"#00f"},{tag:gn.typeName,color:"#085"},{tag:gn.angleBracket,color:"#000000"},{tag:gn.tagName,color:"#170"},{tag:gn.attributeName,color:"#00c"},{tag:gn.operator,color:"#a2f",fontWeight:500},{tag:[gn.function(gn.variableName)],color:"#00c"},{tag:[gn.propertyName],color:"#05a"}]}),mp=e=>{const{theme:t,hotkeys:n,completionConfig:o}=e;return[Dt.lineWrapping,yn(),bn(),wn(),kn(),Nn(),En(),Cn(),jn({position:"fixed",parent:document.querySelector("#App")??void 0}),Sn(),"dark"===t?In:fp,An(),sp(o),Mn(),Tn(),nn.high(Qt.of(On)),Dn(),_n(),Pn.of(" "),pn(Rn,{fallback:!0}),Qt.of(Fn),Ln(e),zn.of(Bn()),Un.allowMultipleSelections.of(!0),ou(n),Qt.of([{key:"Tab",run:e=>Vn(e)||(e=>{const{from:t,to:n}=e.state.selection.main;if(t!==n)return!1;const o=e.state.doc.lineAt(n);return""!==o.text.slice(0,n-o.from).trim()&&Wn(e)})(e)||$n(e),preventDefault:!0}]),Qt.of([...Gn,Hn])]};function pp(e){const t=e.current;if(null===t)throw new ReferenceError("Attempting to dereference null object.");return t}const gp="ContextMenu",[vp,xp]=qn(gp,[Yn]),yp=Yn(),[bp,wp]=vp(gp),kp=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,disabled:o=!1,...a}=e,s=wp("ContextMenuTrigger",n),i=yp(n),l=r.useRef({x:0,y:0}),c=r.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),d=r.useRef(0),u=r.useCallback((()=>window.clearTimeout(d.current)),[]),h=e=>{l.current={x:e.clientX,y:e.clientY},s.onOpenChange(!0)};return r.useEffect((()=>u),[u]),r.useEffect((()=>{o&&u()}),[o,u]),r.createElement(r.Fragment,null,r.createElement(lo,Kn({},i,{virtualRef:c})),r.createElement(co.span,Kn({"data-state":s.open?"open":"closed","data-disabled":o?"":void 0},a,{ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:o?e.onContextMenu:uo(e.onContextMenu,(e=>{u(),h(e),e.preventDefault()})),onPointerDown:o?e.onPointerDown:uo(e.onPointerDown,Np((e=>{u(),d.current=window.setTimeout((()=>h(e)),700)}))),onPointerMove:o?e.onPointerMove:uo(e.onPointerMove,Np(u)),onPointerCancel:o?e.onPointerCancel:uo(e.onPointerCancel,Np(u)),onPointerUp:o?e.onPointerUp:uo(e.onPointerUp,Np(u))})))}));function Np(e){return t=>"mouse"!==t.pointerType?e(t):void 0}const Ep=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=wp("ContextMenuContent",n),s=yp(n),i=r.useRef(!1);return r.createElement(Xn,Kn({},s,o,{ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:t=>{var n;null===(n=e.onCloseAutoFocus)||void 0===n||n.call(e,t),!t.defaultPrevented&&i.current&&t.preventDefault(),i.current=!1},onInteractOutside:t=>{var n;null===(n=e.onInteractOutside)||void 0===n||n.call(e,t),t.defaultPrevented||a.modal||(i.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))})),Cp=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=yp(n);return r.createElement(Zn,Kn({},a,o,{ref:t}))})),jp=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=yp(n);return r.createElement(Qn,Kn({},a,o,{ref:t}))})),Sp=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=yp(n);return r.createElement(eo,Kn({},a,o,{ref:t}))})),Ip=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=yp(n);return r.createElement(to,Kn({},a,o,{ref:t}))})),Ap=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=yp(n);return r.createElement(no,Kn({},a,o,{ref:t}))})),Mp=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=yp(n);return r.createElement(oo,Kn({},a,o,{ref:t}))})),Tp=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=yp(n);return r.createElement(ro,Kn({},a,o,{ref:t}))})),Op=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=yp(n);return r.createElement(ao,Kn({},a,o,{ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))})),Dp=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:o,dir:a,modal:s=!0}=e,[i,l]=r.useState(!1),c=yp(t),d=so(o),u=r.useCallback((e=>{l(e),d(e)}),[d]);return r.createElement(bp,{scope:t,open:i,onOpenChange:u,modal:s},r.createElement(io,Kn({},c,{dir:a,open:i,onOpenChange:u,modal:s}),n))},_p=kp,Pp=ho((e=>{const{__scopeContextMenu:t,...n}=e,o=yp(t);return r.createElement(Jn,Kn({},o,n))}));r.forwardRef((({className:e,inset:t,children:n,...o},r)=>m.jsxs(Tp,{ref:r,className:fo({className:e,inset:t}),...o,children:[n,m.jsx(mo,{className:"ml-auto h-4 w-4"})]}))).displayName=Tp.displayName;const Rp="data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2";r.forwardRef((({className:e,...t},n)=>m.jsx(Op,{ref:n,className:$t(po({subcontent:!0}),Rp,e),...t}))).displayName=Op.displayName;const Fp=r.forwardRef((({className:e,...t},n)=>m.jsx(Pp,{children:m.jsx(go,{children:m.jsx(Ep,{ref:n,className:$t(po(),Rp,e),...t})})})));Fp.displayName=Ep.displayName;const Lp=r.forwardRef((({className:e,inset:t,variant:n,...o},r)=>m.jsx(jp,{ref:r,className:vo({className:e,inset:t,variant:n}),...o})));Lp.displayName=jp.displayName;r.forwardRef((({className:e,children:t,checked:n,...o},r)=>m.jsxs(Sp,{ref:r,className:xo({className:e}),checked:n,...o,children:[m.jsx("span",{className:xo(),children:m.jsx(Ap,{children:m.jsx(yo,{className:"h-4 w-4"})})}),t]}))).displayName=Sp.displayName;r.forwardRef((({className:e,children:t,...n},o)=>m.jsxs(Ip,{ref:o,className:xo({className:e}),...n,children:[m.jsx("span",{className:xo(),children:m.jsx(Ap,{children:m.jsx(bo,{className:"h-4 w-4 fill-current"})})}),t]}))).displayName=Ip.displayName;r.forwardRef((({className:e,inset:t,...n},o)=>m.jsx(Cp,{ref:o,className:wo({className:e,inset:t}),...n}))).displayName=Cp.displayName;const zp=r.forwardRef((({className:e,...t},n)=>m.jsx(Mp,{ref:n,className:$t(ko({className:e})),...t})));zp.displayName=Mp.displayName;const Bp=({appClosed:e,onClick:t,tooltipContent:n})=>m.jsx(Up,{onClick:t,children:m.jsx(p,{content:n,usePortal:!1,children:m.jsx(_s,{onClick:()=>null==t?void 0:t({code:""}),className:$t("shoulder-button hover-action",e&&" inactive-button"),onMouseDown:$e.preventFocus,shape:"circle",size:"small",color:"hint-green","data-testid":"create-cell-button",children:m.jsx(No,{strokeWidth:1.8})})})}),Up=e=>{const{children:t,onClick:n}=e;return n?m.jsxs(Dp,{children:[m.jsx(_p,{children:t}),m.jsxs(Fp,{children:[m.jsxs(Lp,{onSelect:e=>{e.stopPropagation(),n({code:""})},children:[m.jsx("div",{className:"mr-3",children:m.jsx(zs,{})}),"Python cell"]},"python"),m.jsxs(Lp,{onSelect:e=>{e.stopPropagation(),n({code:(new Eo).defaultCode})},children:[m.jsx("div",{className:"mr-3",children:m.jsx(Ls,{})}),"Markdown cell"]},"markdown"),m.jsxs(Lp,{onSelect:e=>{e.stopPropagation(),n({code:(new Co).defaultCode})},children:[m.jsx("div",{className:"mr-3",children:m.jsx(de,{size:13,strokeWidth:1.5})}),"SQL cell"]},"sql")]})]}):t},Vp=jo("rounded-full shadow-xsSolid border p-[5px] transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 [&>svg]:size-3 active:shadow-none bg-background",{variants:{variant:{default:"hover:bg-accent hover:text-accent-foreground",stale:"bg-[var(--yellow-3)] hover:bg-[var(--yellow-4)] text-[var(--yellow-11)]",green:"hover:bg-[var(--grass-2)] hover:text-[var(--grass-11)] hover:border-[var(--grass-7)],",disabled:"opacity-50 cursor-not-allowed",danger:"hover:bg-[var(--red-3)] hover:text-[var(--red-11)]"}},defaultVariants:{variant:"default"}}),$p=({children:e,tooltip:t,disabled:n=!1,variant:o,...r})=>{const a=m.jsx("button",{disabled:n,...r,onClick:e=>{var t;n||null==(t=r.onClick)||t.call(r,e)},onMouseDown:$e.preventFocus,className:$t(Vp({variant:o}),r.className),children:e});return t?m.jsx(p,{content:t,side:"top",delayDuration:200,usePortal:!1,children:a}):a},Gp=({children:e,className:t})=>m.jsx(zc,{className:$t("flex items-center gap-1 bg-background m-[2px] rounded-full",t),children:e});const Hp=e=>{const{onClick:t,appClosed:n,needsRun:o,status:r,config:a,edited:s}=e,i="disabled-transitively"===r,l="running"===r||"queued"===r,c=n||l||!a.disabled&&i&&!s,d=function(e,t,n,o){return e?"disabled":t&&!n?"stale":n||o?"disabled":"green"}(n,o,l,c);if(a.disabled)return m.jsx($p,{tooltip:"Add code to notebook",disabled:c,onClick:t,variant:d,"data-testid":"run-button",children:m.jsx(Yl,{})});if(!a.disabled&&i&&!s)return m.jsx($p,{disabled:c,tooltip:"This cell can't be run because it has a disabled ancestor",onClick:t,variant:d,"data-testid":"run-button",children:m.jsx(uc,{strokeWidth:1.2})});let u="";return u=n?"App disconnected":"queued"===r?"This cell is already queued to run":"running"===r?"This cell is already running.":Ds("cell.run"),m.jsx($p,{tooltip:u,disabled:c,onClick:t,variant:d,"data-testid":"run-button",children:m.jsx(uc,{strokeWidth:1.2})})},Wp=e=>{const{status:t,appClosed:n,onClick:o}=e,r="running"===t||"queued"===t;let a=null;return a=n?"App disconnected":"running"===t?"A cell can't be deleted when it's running":"queued"===t?"A cell can't be deleted when it's queued to run":"Delete",m.jsx(p,{content:a,usePortal:!1,children:m.jsx(b,{variant:"ghost",size:"icon",onClick:o,"data-testid":"delete-button",onMouseDown:$e.preventFocus,className:$t("hover:bg-transparent text-destructive/60 hover:text-destructive",(n||r)&&"inactive-button"),style:{boxShadow:"none"},children:m.jsx(xe,{size:14})})})};const qp=({editing:e,status:t,disabled:n,staleInputs:o,edited:r,interrupted:a,elapsedTime:s,runStartTimestamp:i,uninstantiated:l})=>{if(!e)return null;if(n&&"running"===t)return U.error("CellStatusComponent: disabled and running"),null;if(n&&o)return m.jsx(p,{content:"This cell is stale, but it's disabled and can't be run",usePortal:!1,children:m.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:m.jsxs(Jc,{children:[m.jsx(jl,{className:"h-5 w-5",strokeWidth:1.5}),m.jsx(Io,{className:"h-3 w-3",strokeWidth:2.5})]})})});if(n)return m.jsx(p,{content:"This cell is disabled",usePortal:!1,children:m.jsx("div",{className:"cell-status-icon cell-status-disabled","data-testid":"cell-status","data-status":"disabled",children:m.jsx(jl,{className:"h-5 w-5",strokeWidth:1.5})})});if(!o&&"disabled-transitively"===t)return m.jsx(p,{content:"An ancestor of this cell is disabled, so it can't be run",usePortal:!1,children:m.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"disabled-transitively",children:m.jsxs(Jc,{layerTop:!0,children:[m.jsx(_c,{className:"h-5 w-5",strokeWidth:1.5}),m.jsx(jl,{className:"h-3 w-3",strokeWidth:2.5})]})})});if(o&&"disabled-transitively"===t)return m.jsx(p,{content:"This cell is stale, but an ancestor is disabled so it can't be run",usePortal:!1,children:m.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:m.jsxs(Jc,{children:[m.jsx(Io,{className:"h-5 w-5",strokeWidth:1}),m.jsx(jl,{className:"h-3 w-3",strokeWidth:2.5})]})})});if("running"===t)return m.jsx(p,{content:"This cell is running",usePortal:!1,children:m.jsx("div",{className:"cell-status-icon elapsed-time running","data-testid":"cell-status","data-status":"running",children:m.jsx(Jp,{startTime:So.fromSeconds(i)||So.now()})})});if("queued"===t)return m.jsx(p,{content:"This cell is queued to run",usePortal:!1,children:m.jsx("div",{className:"cell-status-icon cell-status-queued","data-testid":"cell-status","data-status":"queued",children:m.jsx(Ci,{className:"h-5 w-5",strokeWidth:1.5})})});if(r||a||o||l){const e=Yp(s);let t="",n="";return l?t="This cell has not yet been run":a?(t="This cell was interrupted when it was last run",n=`This cell ran for ${e} before being interrupted`):r?(t="This cell has been modified since it was last run",n=`This cell took ${e} to run`):(t="This cell has not been run with the latest inputs",n=`This cell took ${e} to run`),m.jsxs("div",{className:"cell-status-icon flex items-center gap-2",children:[m.jsx(p,{content:t,usePortal:!1,children:m.jsx("div",{className:"cell-status-stale","data-testid":"cell-status","data-status":"outdated",children:m.jsx(Io,{className:"h-5 w-5",strokeWidth:1.5})})}),e&&m.jsx(p,{content:n,usePortal:!1,children:m.jsx("div",{className:"elapsed-time hover-action","data-testid":"cell-status","data-status":"outdated",children:m.jsx("span",{children:e})})})]})}if(null!==s){const e=Yp(s);return m.jsx(p,{content:`This cell took ${e} to run`,usePortal:!1,children:m.jsx("div",{className:"cell-status-icon elapsed-time hover-action","data-testid":"cell-status","data-status":"idle",children:m.jsx("span",{children:e})})})}return null};function Yp(e){if(null===e)return"";if(e>6e4){const t=(e/6e4).toFixed(0),n=(e%6e4/1e3).toFixed(0);return`${t.toString()}m${n.toString()}s`}return e>1e3?`${(e/1e3).toFixed(2).toString()}s`:`${e.toFixed(0).toString()}ms`}const Jp=e=>{const t=function(e){const t=r.useRef(e),[n,o]=r.useState(e);return r.useEffect((()=>{const e=setInterval((()=>{o(So.now().toMilliseconds())}),17);return()=>clearInterval(e)}),[]),n-t.current}(e.startTime.toMilliseconds());return m.jsx("span",{children:Yp(t)})};function Kp(...e){return t=>{e.forEach((e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)}))}}const Xp={display:"none"};function Zp(e){let{id:t,value:n}=e;return u.createElement("div",{id:t,style:Xp},n)}function Qp(e){let{id:t,announcement:n,ariaLiveType:o="assertive"}=e;return u.createElement("div",{id:t,style:{position:"fixed",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":o,"aria-atomic":!0},n)}const eg=r.createContext(null);const tg={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},ng={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function og(e){let{announcements:t=ng,container:n,hiddenTextDescribedById:o,screenReaderInstructions:a=tg}=e;const{announce:s,announcement:i}=function(){const[e,t]=r.useState("");return{announce:r.useCallback((e=>{null!=e&&t(e)}),[]),announcement:e}}(),l=Ii("DndLiveRegion"),[c,d]=r.useState(!1);if(r.useEffect((()=>{d(!0)}),[]),function(e){const t=r.useContext(eg);r.useEffect((()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)}),[e,t])}(r.useMemo((()=>({onDragStart(e){let{active:n}=e;s(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:o}=e;t.onDragMove&&s(t.onDragMove({active:n,over:o}))},onDragOver(e){let{active:n,over:o}=e;s(t.onDragOver({active:n,over:o}))},onDragEnd(e){let{active:n,over:o}=e;s(t.onDragEnd({active:n,over:o}))},onDragCancel(e){let{active:n,over:o}=e;s(t.onDragCancel({active:n,over:o}))}})),[s,t])),!c)return null;const h=u.createElement(u.Fragment,null,u.createElement(Zp,{id:o,value:a.draggable}),u.createElement(Qp,{id:l,announcement:i}));return n?Ao.createPortal(h,n):h}var rg,ag;function sg(){}function ig(e,t){return r.useMemo((()=>({sensor:e,options:null!=t?t:{}})),[e,t])}(ag=rg||(rg={})).DragStart="dragStart",ag.DragMove="dragMove",ag.DragEnd="dragEnd",ag.DragCancel="dragCancel",ag.DragOver="dragOver",ag.RegisterDroppable="registerDroppable",ag.SetDroppableDisabled="setDroppableDisabled",ag.UnregisterDroppable="unregisterDroppable";const lg=Object.freeze({x:0,y:0});function cg(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function dg(e,t){let{data:{value:n}}=e,{data:{value:o}}=t;return n-o}function ug(e,t){let{data:{value:n}}=e,{data:{value:o}}=t;return o-n}function hg(e){let{left:t,top:n,height:o,width:r}=e;return[{x:t,y:n},{x:t+r,y:n},{x:t,y:n+o},{x:t+r,y:n+o}]}function fg(e,t){if(!e||0===e.length)return null;const[n]=e;return t?n[t]:n}function mg(e,t,n){return void 0===t&&(t=e.left),void 0===n&&(n=e.top),{x:t+.5*e.width,y:n+.5*e.height}}const pg=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:o}=e;const r=mg(t,t.left,t.top),a=[];for(const s of o){const{id:e}=s,t=n.get(e);if(t){const n=cg(mg(t),r);a.push({id:e,data:{droppableContainer:s,value:n}})}}return a.sort(dg)};function gg(e,t){const n=Math.max(t.top,e.top),o=Math.max(t.left,e.left),r=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),s=r-o,i=a-n;if(o<r&&n<a){const n=t.width*t.height,o=e.width*e.height,r=s*i;return Number((r/(n+o-r)).toFixed(4))}return 0}const vg=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:o}=e;const r=[];for(const a of o){const{id:e}=a,o=n.get(e);if(o){const n=gg(o,t);n>0&&r.push({id:e,data:{droppableContainer:a,value:n}})}}return r.sort(ug)};function xg(e,t){const{top:n,left:o,bottom:r,right:a}=t;return n<=e.y&&e.y<=r&&o<=e.x&&e.x<=a}function yg(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:lg}function bg(e){return function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return o.reduce(((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x})),{...t})}}const wg=bg(1);const kg={ignoreTransform:!1};function Ng(e,t){void 0===t&&(t=kg);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:o}=ji(e).getComputedStyle(e);t&&(n=function(e,t,n){const o=function(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}(t);if(!o)return e;const{scaleX:r,scaleY:a,x:s,y:i}=o,l=e.left-s-(1-r)*parseFloat(n),c=e.top-i-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),d=r?e.width/r:e.width,u=a?e.height/a:e.height;return{width:d,height:u,top:c,right:l+d,bottom:c+u,left:l}}(n,t,o))}const{top:o,left:r,width:a,height:s,bottom:i,right:l}=n;return{top:o,left:r,width:a,height:s,bottom:i,right:l}}function Eg(e){return Ng(e,{ignoreTransform:!0})}function Cg(e,t){const n=[];return e?function o(r){if(null!=t&&n.length>=t)return n;if(!r)return n;if(Gi(r)&&null!=r.scrollingElement&&!n.includes(r.scrollingElement))return n.push(r.scrollingElement),n;if(!zi(r)||Wi(r))return n;if(n.includes(r))return n;const a=ji(e).getComputedStyle(r);return r!==e&&function(e,t){void 0===t&&(t=ji(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some((e=>{const o=t[e];return"string"==typeof o&&n.test(o)}))}(r,a)&&n.push(r),function(e,t){return void 0===t&&(t=ji(e).getComputedStyle(e)),"fixed"===t.position}(r,a)?n:o(r.parentNode)}(e):n}function jg(e){const[t]=Cg(e,1);return null!=t?t:null}function Sg(e){return Li&&e?Vi(e)?e:$i(e)?Gi(e)||e===Oi(e).scrollingElement?window:zi(e)?e:null:null:null}function Ig(e){return Vi(e)?e.scrollX:e.scrollLeft}function Ag(e){return Vi(e)?e.scrollY:e.scrollTop}function Mg(e){return{x:Ig(e),y:Ag(e)}}var Tg,Og;function Dg(e){return!(!Li||!e)&&e===document.scrollingElement}function _g(e){const t={x:0,y:0},n=Dg(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=o.y,isRight:e.scrollLeft>=o.x,maxScroll:o,minScroll:t}}(Og=Tg||(Tg={}))[Og.Forward=1]="Forward",Og[Og.Backward=-1]="Backward";const Pg={x:.2,y:.2};function Rg(e,t,n,o,r){let{top:a,left:s,right:i,bottom:l}=n;void 0===o&&(o=10),void 0===r&&(r=Pg);const{isTop:c,isBottom:d,isLeft:u,isRight:h}=_g(e),f={x:0,y:0},m={x:0,y:0},p=t.height*r.y,g=t.width*r.x;return!c&&a<=t.top+p?(f.y=Tg.Backward,m.y=o*Math.abs((t.top+p-a)/p)):!d&&l>=t.bottom-p&&(f.y=Tg.Forward,m.y=o*Math.abs((t.bottom-p-l)/p)),!h&&i>=t.right-g?(f.x=Tg.Forward,m.x=o*Math.abs((t.right-g-i)/g)):!u&&s<=t.left+g&&(f.x=Tg.Backward,m.x=o*Math.abs((t.left+g-s)/g)),{direction:f,speed:m}}function Fg(e){if(e===document.scrollingElement){const{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}const{top:t,left:n,right:o,bottom:r}=e.getBoundingClientRect();return{top:t,left:n,right:o,bottom:r,width:e.clientWidth,height:e.clientHeight}}function Lg(e){return e.reduce(((e,t)=>Mi(e,Mg(t))),lg)}const zg=[["x",["left","right"],function(e){return e.reduce(((e,t)=>e+Ig(t)),0)}],["y",["top","bottom"],function(e){return e.reduce(((e,t)=>e+Ag(t)),0)}]];class Bg{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=Cg(t),o=Lg(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[r,a,s]of zg)for(const e of a)Object.defineProperty(this,e,{get:()=>{const t=s(n),a=o[r]-t;return this.rect[e]+a},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ug{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach((e=>{var t;return null==(t=this.target)?void 0:t.removeEventListener(...e)}))},this.target=e}add(e,t,n){var o;null==(o=this.target)||o.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function Vg(e,t){const n=Math.abs(e.x),o=Math.abs(e.y);return"number"==typeof t?Math.sqrt(n**2+o**2)>t:"x"in t&&"y"in t?n>t.x&&o>t.y:"x"in t?n>t.x:"y"in t&&o>t.y}var $g,Gg,Hg,Wg;function qg(e){e.preventDefault()}function Yg(e){e.stopPropagation()}(Gg=$g||($g={})).Click="click",Gg.DragStart="dragstart",Gg.Keydown="keydown",Gg.ContextMenu="contextmenu",Gg.Resize="resize",Gg.SelectionChange="selectionchange",Gg.VisibilityChange="visibilitychange",(Wg=Hg||(Hg={})).Space="Space",Wg.Down="ArrowDown",Wg.Right="ArrowRight",Wg.Left="ArrowLeft",Wg.Up="ArrowUp",Wg.Esc="Escape",Wg.Enter="Enter";const Jg={start:[Hg.Space,Hg.Enter],cancel:[Hg.Esc],end:[Hg.Space,Hg.Enter]},Kg=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Hg.Right:return{...n,x:n.x+25};case Hg.Left:return{...n,x:n.x-25};case Hg.Down:return{...n,y:n.y+25};case Hg.Up:return{...n,y:n.y-25}}};class Xg{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:t}}=e;this.props=e,this.listeners=new Ug(Oi(t)),this.windowListeners=new Ug(ji(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add($g.Resize,this.handleCancel),this.windowListeners.add($g.VisibilityChange,this.handleCancel),setTimeout((()=>this.listeners.add($g.Keydown,this.handleKeyDown)))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&function(e,t){if(void 0===t&&(t=Ng),!e)return;const{top:n,left:o,bottom:r,right:a}=t(e);jg(e)&&(r<=0||a<=0||n>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}(n),t(lg)}handleKeyDown(e){if(Di(e)){const{active:t,context:n,options:o}=this.props,{keyboardCodes:r=Jg,coordinateGetter:a=Kg,scrollBehavior:s="smooth"}=o,{code:i}=e;if(r.end.includes(i))return void this.handleEnd(e);if(r.cancel.includes(i))return void this.handleCancel(e);const{collisionRect:l}=n.current,c=l?{x:l.left,y:l.top}:lg;this.referenceCoordinates||(this.referenceCoordinates=c);const d=a(e,{active:t,context:n.current,currentCoordinates:c});if(d){const t=_i(d,c),o={x:0,y:0},{scrollableAncestors:r}=n.current;for(const n of r){const r=e.code,{isTop:a,isRight:i,isLeft:l,isBottom:c,maxScroll:u,minScroll:h}=_g(n),f=Fg(n),m={x:Math.min(r===Hg.Right?f.right-f.width/2:f.right,Math.max(r===Hg.Right?f.left:f.left+f.width/2,d.x)),y:Math.min(r===Hg.Down?f.bottom-f.height/2:f.bottom,Math.max(r===Hg.Down?f.top:f.top+f.height/2,d.y))},p=r===Hg.Right&&!i||r===Hg.Left&&!l,g=r===Hg.Down&&!c||r===Hg.Up&&!a;if(p&&m.x!==d.x){const e=n.scrollLeft+t.x,a=r===Hg.Right&&e<=u.x||r===Hg.Left&&e>=h.x;if(a&&!t.y)return void n.scrollTo({left:e,behavior:s});o.x=a?n.scrollLeft-e:r===Hg.Right?n.scrollLeft-u.x:n.scrollLeft-h.x,o.x&&n.scrollBy({left:-o.x,behavior:s});break}if(g&&m.y!==d.y){const e=n.scrollTop+t.y,a=r===Hg.Down&&e<=u.y||r===Hg.Up&&e>=h.y;if(a&&!t.x)return void n.scrollTo({top:e,behavior:s});o.y=a?n.scrollTop-e:r===Hg.Down?n.scrollTop-u.y:n.scrollTop-h.y,o.y&&n.scrollBy({top:-o.y,behavior:s});break}}this.handleMove(e,Mi(_i(d,this.referenceCoordinates),o))}}}handleMove(e,t){const{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){const{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){const{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function Zg(e){return Boolean(e&&"distance"in e)}function Qg(e){return Boolean(e&&"delay"in e)}Xg.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:o=Jg,onActivation:r}=t,{active:a}=n;const{code:s}=e.nativeEvent;if(o.start.includes(s)){const t=a.activatorNode.current;return(!t||e.target===t)&&(e.preventDefault(),null==r||r({event:e.nativeEvent}),!0)}return!1}}];class ev{constructor(e,t,n){var o;void 0===n&&(n=function(e){const{EventTarget:t}=ji(e);return e instanceof t?e:Oi(e)}(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;const{event:r}=e,{target:a}=r;this.props=e,this.events=t,this.document=Oi(a),this.documentListeners=new Ug(this.document),this.listeners=new Ug(n),this.windowListeners=new Ug(ji(a)),this.initialCoordinates=null!=(o=Ai(r))?o:lg,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),this.windowListeners.add($g.Resize,this.handleCancel),this.windowListeners.add($g.DragStart,qg),this.windowListeners.add($g.VisibilityChange,this.handleCancel),this.windowListeners.add($g.ContextMenu,qg),this.documentListeners.add($g.Keydown,this.handleKeydown),t){if(null!=n&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Qg(t))return void(this.timeoutId=setTimeout(this.handleStart,t.delay));if(Zg(t))return}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add($g.Click,Yg,{capture:!0}),this.removeTextSelection(),this.documentListeners.add($g.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:o,props:r}=this,{onMove:a,options:{activationConstraint:s}}=r;if(!o)return;const i=null!=(t=Ai(e))?t:lg,l=_i(o,i);if(!n&&s){if(Zg(s)){if(null!=s.tolerance&&Vg(l,s.tolerance))return this.handleCancel();if(Vg(l,s.distance))return this.handleStart()}return Qg(s)&&Vg(l,s.tolerance)?this.handleCancel():void 0}e.cancelable&&e.preventDefault(),a(i)}handleEnd(){const{onEnd:e}=this.props;this.detach(),e()}handleCancel(){const{onCancel:e}=this.props;this.detach(),e()}handleKeydown(e){e.code===Hg.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const tv={move:{name:"pointermove"},end:{name:"pointerup"}};class nv extends ev{constructor(e){const{event:t}=e,n=Oi(t.target);super(e,tv,n)}}nv.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;return!(!n.isPrimary||0!==n.button)&&(null==o||o({event:n}),!0)}}];const ov={move:{name:"mousemove"},end:{name:"mouseup"}};var rv,av;(av=rv||(rv={}))[av.RightClick=2]="RightClick";(class extends ev{constructor(e){super(e,ov,Oi(e.event.target))}}).activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;return n.button!==rv.RightClick&&(null==o||o({event:n}),!0)}}];const sv={move:{name:"touchmove"},end:{name:"touchend"}};var iv,lv,cv,dv;function uv(e){let{acceleration:t,activator:n=iv.Pointer,canScroll:o,draggingRect:a,enabled:s,interval:i=5,order:l=cv.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:u,delta:h,threshold:f}=e;const m=function(e){let{delta:t,disabled:n}=e;const o=Ri(t);return Fi((e=>{if(n||!o||!e)return hv;const r={x:Math.sign(t.x-o.x),y:Math.sign(t.y-o.y)};return{x:{[Tg.Backward]:e.x[Tg.Backward]||-1===r.x,[Tg.Forward]:e.x[Tg.Forward]||1===r.x},y:{[Tg.Backward]:e.y[Tg.Backward]||-1===r.y,[Tg.Forward]:e.y[Tg.Forward]||1===r.y}}}),[n,t,o])}({delta:h,disabled:!s}),[p,g]=Pi(),v=r.useRef({x:0,y:0}),x=r.useRef({x:0,y:0}),y=r.useMemo((()=>{switch(n){case iv.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case iv.DraggableRect:return a}}),[n,a,c]),b=r.useRef(null),w=r.useCallback((()=>{const e=b.current;if(!e)return;const t=v.current.x*x.current.x,n=v.current.y*x.current.y;e.scrollBy(t,n)}),[]),k=r.useMemo((()=>l===cv.TreeOrder?[...d].reverse():d),[l,d]);r.useEffect((()=>{if(s&&d.length&&y){for(const e of k){if(!1===(null==o?void 0:o(e)))continue;const n=d.indexOf(e),r=u[n];if(!r)continue;const{direction:a,speed:s}=Rg(e,r,y,t,f);for(const e of["x","y"])m[e][a[e]]||(s[e]=0,a[e]=0);if(s.x>0||s.y>0)return g(),b.current=e,p(w,i),v.current=s,void(x.current=a)}v.current={x:0,y:0},x.current={x:0,y:0},g()}else g()}),[t,w,o,g,s,i,JSON.stringify(y),JSON.stringify(m),p,d,k,u,JSON.stringify(f)])}(class extends ev{constructor(e){super(e,sv)}static setup(){return window.addEventListener(sv.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(sv.move.name,e)};function e(){}}}).activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;const{touches:r}=n;return!(r.length>1)&&(null==o||o({event:n}),!0)}}],(lv=iv||(iv={}))[lv.Pointer=0]="Pointer",lv[lv.DraggableRect=1]="DraggableRect",(dv=cv||(cv={}))[dv.TreeOrder=0]="TreeOrder",dv[dv.ReversedTreeOrder=1]="ReversedTreeOrder";const hv={x:{[Tg.Backward]:!1,[Tg.Forward]:!1},y:{[Tg.Backward]:!1,[Tg.Forward]:!1}};var fv,mv,pv;(mv=fv||(fv={}))[mv.Always=0]="Always",mv[mv.BeforeDragging=1]="BeforeDragging",mv[mv.WhileDragging=2]="WhileDragging",(pv||(pv={})).Optimized="optimized";const gv=new Map;function vv(e,t){return Fi((n=>e?n||("function"==typeof t?t(e):e):null),[t,e])}function xv(e){let{callback:t,disabled:n}=e;const o=Hi(t),a=r.useMemo((()=>{if(n||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(o)}),[n]);return r.useEffect((()=>()=>null==a?void 0:a.disconnect()),[a]),a}function yv(e){return new Bg(Ng(e),e)}function bv(e,t,n){void 0===t&&(t=yv);const[o,a]=r.useReducer((function(o){if(!e)return null;var r;if(!1===e.isConnected)return null!=(r=null!=o?o:n)?r:null;const a=t(e);if(JSON.stringify(o)===JSON.stringify(a))return o;return a}),null),s=function(e){let{callback:t,disabled:n}=e;const o=Hi(t),a=r.useMemo((()=>{if(n||"undefined"==typeof window||void 0===window.MutationObserver)return;const{MutationObserver:e}=window;return new e(o)}),[o,n]);return r.useEffect((()=>()=>null==a?void 0:a.disconnect()),[a]),a}({callback(t){if(e)for(const n of t){const{type:t,target:o}=n;if("childList"===t&&o instanceof HTMLElement&&o.contains(e)){a();break}}}}),i=xv({callback:a});return Ti((()=>{a(),e?(null==i||i.observe(e),null==s||s.observe(document.body,{childList:!0,subtree:!0})):(null==i||i.disconnect(),null==s||s.disconnect())}),[e]),o}const wv=[];function kv(e,t){void 0===t&&(t=[]);const n=r.useRef(null);return r.useEffect((()=>{n.current=null}),t),r.useEffect((()=>{const t=e!==lg;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)}),[e]),n.current?_i(e,n.current):lg}function Nv(e){return r.useMemo((()=>e?function(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}(e):null),[e])}const Ev=[];function Cv(e){let{measure:t}=e;const[n,o]=r.useState(null),a=xv({callback:r.useCallback((e=>{for(const{target:n}of e)if(zi(n)){o((e=>{const o=t(n);return e?{...e,width:o.width,height:o.height}:o}));break}}),[t])}),s=r.useCallback((e=>{const n=function(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return zi(t)?t:e}(e);null==a||a.disconnect(),n&&(null==a||a.observe(n)),o(n?t(n):null)}),[t,a]),[i,l]=Bi(s);return r.useMemo((()=>({nodeRef:i,rect:n,setRef:l})),[n,i,l])}const jv=[{sensor:nv,options:{}},{sensor:Xg,options:{}}],Sv={current:{}},Iv={draggable:{measure:Eg},droppable:{measure:Eg,strategy:fv.WhileDragging,frequency:pv.Optimized},dragOverlay:{measure:Ng}};class Av extends Map{get(e){var t;return null!=e&&null!=(t=super.get(e))?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter((e=>{let{disabled:t}=e;return!t}))}getNodeFor(e){var t,n;return null!=(t=null==(n=this.get(e))?void 0:n.node.current)?t:void 0}}const Mv={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Av,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:sg},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Iv,measureDroppableContainers:sg,windowRect:null,measuringScheduled:!1},Tv={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:sg,draggableNodes:new Map,over:null,measureDroppableContainers:sg},Ov=r.createContext(Tv),Dv=r.createContext(Mv);function _v(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Av}}}function Pv(e,t){switch(t.type){case rg.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case rg.DragMove:return e.draggable.active?{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}}:e;case rg.DragEnd:case rg.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case rg.RegisterDroppable:{const{element:n}=t,{id:o}=n,r=new Av(e.droppable.containers);return r.set(o,n),{...e,droppable:{...e.droppable,containers:r}}}case rg.SetDroppableDisabled:{const{id:n,key:o,disabled:r}=t,a=e.droppable.containers.get(n);if(!a||o!==a.key)return e;const s=new Av(e.droppable.containers);return s.set(n,{...a,disabled:r}),{...e,droppable:{...e.droppable,containers:s}}}case rg.UnregisterDroppable:{const{id:n,key:o}=t,r=e.droppable.containers.get(n);if(!r||o!==r.key)return e;const a=new Av(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Rv(e){let{disabled:t}=e;const{active:n,activatorEvent:o,draggableNodes:a}=r.useContext(Ov),s=Ri(o),i=Ri(null==n?void 0:n.id);return r.useEffect((()=>{if(!t&&!o&&s&&null!=i){if(!Di(s))return;if(document.activeElement===s.target)return;const e=a.get(i);if(!e)return;const{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame((()=>{for(const e of[t.current,n.current]){if(!e)continue;const t=Ui(e);if(t){t.focus();break}}}))}}),[o,t,a,i,s]),null}const Fv=r.createContext({...lg,scaleX:1,scaleY:1});var Lv,zv;(zv=Lv||(Lv={}))[zv.Uninitialized=0]="Uninitialized",zv[zv.Initializing=1]="Initializing",zv[zv.Initialized=2]="Initialized";const Bv=r.memo((function(e){var t,n,o,a;let{id:s,accessibility:i,autoScroll:l=!0,children:c,sensors:d=jv,collisionDetection:h=vg,measuring:f,modifiers:m,...p}=e;const g=r.useReducer(Pv,void 0,_v),[v,x]=g,[y,b]=function(){const[e]=r.useState((()=>new Set)),t=r.useCallback((t=>(e.add(t),()=>e.delete(t))),[e]);return[r.useCallback((t=>{let{type:n,event:o}=t;e.forEach((e=>{var t;return null==(t=e[n])?void 0:t.call(e,o)}))}),[e]),t]}(),[w,k]=r.useState(Lv.Uninitialized),N=w===Lv.Initialized,{draggable:{active:E,nodes:C,translate:j},droppable:{containers:S}}=v,I=E?C.get(E):null,A=r.useRef({initial:null,translated:null}),M=r.useMemo((()=>{var e;return null!=E?{id:E,data:null!=(e=null==I?void 0:I.data)?e:Sv,rect:A}:null}),[E,I]),T=r.useRef(null),[O,D]=r.useState(null),[_,P]=r.useState(null),R=Si(p,Object.values(p)),F=Ii("DndDescribedBy",s),L=r.useMemo((()=>S.getEnabled()),[S]),z=(B=f,r.useMemo((()=>({draggable:{...Iv.draggable,...null==B?void 0:B.draggable},droppable:{...Iv.droppable,...null==B?void 0:B.droppable},dragOverlay:{...Iv.dragOverlay,...null==B?void 0:B.dragOverlay}})),[null==B?void 0:B.draggable,null==B?void 0:B.droppable,null==B?void 0:B.dragOverlay]));var B;const{droppableRects:U,measureDroppableContainers:V,measuringScheduled:$}=function(e,t){let{dragging:n,dependencies:o,config:a}=t;const[s,i]=r.useState(null),{frequency:l,measure:c,strategy:d}=a,u=r.useRef(e),h=function(){switch(d){case fv.Always:return!1;case fv.BeforeDragging:return n;default:return!n}}(),f=Si(h),m=r.useCallback((function(e){void 0===e&&(e=[]),f.current||i((t=>null===t?e:t.concat(e.filter((e=>!t.includes(e))))))}),[f]),p=r.useRef(null),g=Fi((t=>{if(h&&!n)return gv;if(!t||t===gv||u.current!==e||null!=s){const t=new Map;for(let n of e){if(!n)continue;if(s&&s.length>0&&!s.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}const e=n.node.current,o=e?new Bg(c(e),e):null;n.rect.current=o,o&&t.set(n.id,o)}return t}return t}),[e,s,n,h,c]);return r.useEffect((()=>{u.current=e}),[e]),r.useEffect((()=>{h||m()}),[n,h]),r.useEffect((()=>{s&&s.length>0&&i(null)}),[JSON.stringify(s)]),r.useEffect((()=>{h||"number"!=typeof l||null!==p.current||(p.current=setTimeout((()=>{m(),p.current=null}),l))}),[l,h,m,...o]),{droppableRects:g,measureDroppableContainers:m,measuringScheduled:null!=s}}(L,{dragging:N,dependencies:[j.x,j.y],config:z.droppable}),G=function(e,t){const n=null!==t?e.get(t):void 0,o=n?n.node.current:null;return Fi((e=>{var n;return null===t?null:null!=(n=null!=o?o:e)?n:null}),[o,t])}(C,E),H=r.useMemo((()=>_?Ai(_):null),[_]),W=function(){const e=!1===(null==O?void 0:O.autoScrollEnabled),t="object"==typeof l?!1===l.enabled:!1===l,n=N&&!e&&!t;if("object"==typeof l)return{...l,enabled:n};return{enabled:n}}(),q=function(e,t){return vv(e,t)}(G,z.draggable.measure);!function(e){let{activeNode:t,measure:n,initialRect:o,config:a=!0}=e;const s=r.useRef(!1),{x:i,y:l}="boolean"==typeof a?{x:a,y:a}:a;Ti((()=>{if(!i&&!l||!t)return void(s.current=!1);if(s.current||!o)return;const e=null==t?void 0:t.node.current;if(!e||!1===e.isConnected)return;const r=yg(n(e),o);if(i||(r.x=0),l||(r.y=0),s.current=!0,Math.abs(r.x)>0||Math.abs(r.y)>0){const t=jg(e);t&&t.scrollBy({top:r.y,left:r.x})}}),[t,i,l,o,n])}({activeNode:E?C.get(E):null,config:W.layoutShiftCompensation,initialRect:q,measure:z.draggable.measure});const Y=bv(G,z.draggable.measure,q),J=bv(G?G.parentElement:null),K=r.useRef({activatorEvent:null,active:null,activeNode:G,collisionRect:null,collisions:null,droppableRects:U,draggableNodes:C,draggingNode:null,draggingNodeRect:null,droppableContainers:S,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),X=S.getNodeFor(null==(t=K.current.over)?void 0:t.id),Z=Cv({measure:z.dragOverlay.measure}),Q=null!=(n=Z.nodeRef.current)?n:G,ee=N?null!=(o=Z.rect)?o:Y:null,te=Boolean(Z.nodeRef.current&&Z.rect),ne=yg(oe=te?null:Y,vv(oe));var oe;const re=Nv(Q?ji(Q):null),ae=function(e){const t=r.useRef(e),n=Fi((n=>e?n&&n!==wv&&e&&t.current&&e.parentNode===t.current.parentNode?n:Cg(e):wv),[e]);return r.useEffect((()=>{t.current=e}),[e]),n}(N?null!=X?X:G:null),se=function(e,t){void 0===t&&(t=Ng);const[n]=e,o=Nv(n?ji(n):null),[a,s]=r.useReducer((function(){return e.length?e.map((e=>Dg(e)?o:new Bg(t(e),e))):Ev}),Ev),i=xv({callback:s});return e.length>0&&a===Ev&&s(),Ti((()=>{e.length?e.forEach((e=>null==i?void 0:i.observe(e))):(null==i||i.disconnect(),s())}),[e]),a}(ae),ie=function(e,t){let{transform:n,...o}=t;return null!=e&&e.length?e.reduce(((e,t)=>t({transform:e,...o})),n):n}(m,{transform:{x:j.x-ne.x,y:j.y-ne.y,scaleX:1,scaleY:1},activatorEvent:_,active:M,activeNodeRect:Y,containerNodeRect:J,draggingNodeRect:ee,over:K.current.over,overlayNodeRect:Z.rect,scrollableAncestors:ae,scrollableAncestorRects:se,windowRect:re}),le=H?Mi(H,j):null,ce=function(e){const[t,n]=r.useState(null),o=r.useRef(e),a=r.useCallback((e=>{const t=Sg(e.target);t&&n((e=>e?(e.set(t,Mg(t)),new Map(e)):null))}),[]);return r.useEffect((()=>{const t=o.current;if(e!==t){r(t);const s=e.map((e=>{const t=Sg(e);return t?(t.addEventListener("scroll",a,{passive:!0}),[t,Mg(t)]):null})).filter((e=>null!=e));n(s.length?new Map(s):null),o.current=e}return()=>{r(e),r(t)};function r(e){e.forEach((e=>{const t=Sg(e);null==t||t.removeEventListener("scroll",a)}))}}),[a,e]),r.useMemo((()=>e.length?t?Array.from(t.values()).reduce(((e,t)=>Mi(e,t)),lg):Lg(e):lg),[e,t])}(ae),de=kv(ce),ue=kv(ce,[Y]),he=Mi(ie,de),fe=ee?wg(ee,ie):null,me=M&&fe?h({active:M,collisionRect:fe,droppableRects:U,droppableContainers:L,pointerCoordinates:le}):null,pe=fg(me,"id"),[ge,ve]=r.useState(null),xe=function(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}(te?ie:Mi(ie,ue),null!=(a=null==ge?void 0:ge.rect)?a:null,Y),ye=r.useCallback(((e,t)=>{let{sensor:n,options:o}=t;if(null==T.current)return;const r=C.get(T.current);if(!r)return;const a=e.nativeEvent,s=new n({active:T.current,activeNode:r,event:a,options:o,context:K,onStart(e){const t=T.current;if(null==t)return;const n=C.get(t);if(!n)return;const{onDragStart:o}=R.current,r={active:{id:t,data:n.data,rect:A}};Ao.unstable_batchedUpdates((()=>{null==o||o(r),k(Lv.Initializing),x({type:rg.DragStart,initialCoordinates:e,active:t}),y({type:"onDragStart",event:r})}))},onMove(e){x({type:rg.DragMove,coordinates:e})},onEnd:i(rg.DragEnd),onCancel:i(rg.DragCancel)});function i(e){return async function(){const{active:t,collisions:n,over:o,scrollAdjustedTranslate:r}=K.current;let s=null;if(t&&r){const{cancelDrop:i}=R.current;if(s={activatorEvent:a,active:t,collisions:n,delta:r,over:o},e===rg.DragEnd&&"function"==typeof i){await Promise.resolve(i(s))&&(e=rg.DragCancel)}}T.current=null,Ao.unstable_batchedUpdates((()=>{x({type:e}),k(Lv.Uninitialized),ve(null),D(null),P(null);const t=e===rg.DragEnd?"onDragEnd":"onDragCancel";if(s){const e=R.current[t];null==e||e(s),y({type:t,event:s})}}))}}Ao.unstable_batchedUpdates((()=>{D(s),P(e.nativeEvent)}))}),[C]),be=function(e,t){return r.useMemo((()=>e.reduce(((e,n)=>{const{sensor:o}=n;return[...e,...o.activators.map((e=>({eventName:e.eventName,handler:t(e.handler,n)})))]}),[])),[e,t])}(d,r.useCallback(((e,t)=>(n,o)=>{const r=n.nativeEvent,a=C.get(o);if(null!==T.current||!a||r.dndKit||r.defaultPrevented)return;const s={active:a};!0===e(n,t.options,s)&&(r.dndKit={capturedBy:t.sensor},T.current=o,ye(n,t))}),[C,ye]));!function(e){r.useEffect((()=>{if(!Li)return;const t=e.map((e=>{let{sensor:t}=e;return null==t.setup?void 0:t.setup()}));return()=>{for(const e of t)null==e||e()}}),e.map((e=>{let{sensor:t}=e;return t})))}(d),Ti((()=>{Y&&w===Lv.Initializing&&k(Lv.Initialized)}),[Y,w]),r.useEffect((()=>{const{onDragMove:e}=R.current,{active:t,activatorEvent:n,collisions:o,over:r}=K.current;if(!t||!n)return;const a={active:t,activatorEvent:n,collisions:o,delta:{x:he.x,y:he.y},over:r};Ao.unstable_batchedUpdates((()=>{null==e||e(a),y({type:"onDragMove",event:a})}))}),[he.x,he.y]),r.useEffect((()=>{const{active:e,activatorEvent:t,collisions:n,droppableContainers:o,scrollAdjustedTranslate:r}=K.current;if(!e||null==T.current||!t||!r)return;const{onDragOver:a}=R.current,s=o.get(pe),i=s&&s.rect.current?{id:s.id,rect:s.rect.current,data:s.data,disabled:s.disabled}:null,l={active:e,activatorEvent:t,collisions:n,delta:{x:r.x,y:r.y},over:i};Ao.unstable_batchedUpdates((()=>{ve(i),null==a||a(l),y({type:"onDragOver",event:l})}))}),[pe]),Ti((()=>{K.current={activatorEvent:_,active:M,activeNode:G,collisionRect:fe,collisions:me,droppableRects:U,draggableNodes:C,draggingNode:Q,draggingNodeRect:ee,droppableContainers:S,over:ge,scrollableAncestors:ae,scrollAdjustedTranslate:he},A.current={initial:ee,translated:fe}}),[M,G,me,fe,C,Q,ee,U,S,ge,ae,he]),uv({...W,delta:j,draggingRect:fe,pointerCoordinates:le,scrollableAncestors:ae,scrollableAncestorRects:se});const we=r.useMemo((()=>({active:M,activeNode:G,activeNodeRect:Y,activatorEvent:_,collisions:me,containerNodeRect:J,dragOverlay:Z,draggableNodes:C,droppableContainers:S,droppableRects:U,over:ge,measureDroppableContainers:V,scrollableAncestors:ae,scrollableAncestorRects:se,measuringConfiguration:z,measuringScheduled:$,windowRect:re})),[M,G,Y,_,me,J,Z,C,S,U,ge,V,ae,se,z,$,re]),ke=r.useMemo((()=>({activatorEvent:_,activators:be,active:M,activeNodeRect:Y,ariaDescribedById:{draggable:F},dispatch:x,draggableNodes:C,over:ge,measureDroppableContainers:V})),[_,be,M,Y,x,F,C,ge,V]);return u.createElement(eg.Provider,{value:b},u.createElement(Ov.Provider,{value:ke},u.createElement(Dv.Provider,{value:we},u.createElement(Fv.Provider,{value:xe},c)),u.createElement(Rv,{disabled:!1===(null==i?void 0:i.restoreFocus)})),u.createElement(og,{...i,hiddenTextDescribedById:F}))})),Uv=r.createContext(null),Vv="button";function $v(e){let{id:t,data:n,disabled:o=!1,attributes:a}=e;const s=Ii("Droppable"),{activators:i,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:u,draggableNodes:h,over:f}=r.useContext(Ov),{role:m=Vv,roleDescription:p="draggable",tabIndex:g=0}=null!=a?a:{},v=(null==c?void 0:c.id)===t,x=r.useContext(v?Fv:Uv),[y,b]=Bi(),[w,k]=Bi(),N=function(e,t){return r.useMemo((()=>e.reduce(((e,n)=>{let{eventName:o,handler:r}=n;return e[o]=e=>{r(e,t)},e}),{})),[e,t])}(i,t),E=Si(n);Ti((()=>(h.set(t,{id:t,key:s,node:y,activatorNode:w,data:E}),()=>{const e=h.get(t);e&&e.key===s&&h.delete(t)})),[h,t]);return{active:c,activatorEvent:l,activeNodeRect:d,attributes:r.useMemo((()=>({role:m,tabIndex:g,"aria-disabled":o,"aria-pressed":!(!v||m!==Vv)||void 0,"aria-roledescription":p,"aria-describedby":u.draggable})),[o,m,g,v,p,u.draggable]),isDragging:v,listeners:o?void 0:N,node:y,over:f,setNodeRef:b,setActivatorNodeRef:k,transform:x}}const Gv={timeout:25};function Hv(e,t,n){const o=e.slice();return o.splice(n<0?o.length+n:n,0,o.splice(t,1)[0]),o}function Wv(e,t){return e.reduce(((e,n,o)=>{const r=t.get(n);return r&&(e[o]=r),e}),Array(e.length))}function qv(e){return null!==e&&e>=0}const Yv={scaleX:1,scaleY:1},Jv=e=>{var t;let{rects:n,activeNodeRect:o,activeIndex:r,overIndex:a,index:s}=e;const i=null!=(t=n[r])?t:o;if(!i)return null;const l=function(e,t,n){const o=e[t],r=e[t-1],a=e[t+1];if(!o||!r&&!a)return 0;if(n<t)return r?o.left-(r.left+r.width):a.left-(o.left+o.width);return a?a.left-(o.left+o.width):o.left-(r.left+r.width)}(n,s,r);if(s===r){const e=n[a];return e?{x:r<a?e.left+e.width-(i.left+i.width):e.left-i.left,y:0,...Yv}:null}return s>r&&s<=a?{x:-i.width-l,y:0,...Yv}:s<r&&s>=a?{x:i.width+l,y:0,...Yv}:{x:0,y:0,...Yv}};const Kv=e=>{let{rects:t,activeIndex:n,overIndex:o,index:r}=e;const a=Hv(t,o,n),s=t[r],i=a[r];return i&&s?{x:i.left-s.left,y:i.top-s.top,scaleX:i.width/s.width,scaleY:i.height/s.height}:null},Xv={scaleX:1,scaleY:1},Zv=e=>{var t;let{activeIndex:n,activeNodeRect:o,index:r,rects:a,overIndex:s}=e;const i=null!=(t=a[n])?t:o;if(!i)return null;if(r===n){const e=a[s];return e?{x:0,y:n<s?e.top+e.height-(i.top+i.height):e.top-i.top,...Xv}:null}const l=function(e,t,n){const o=e[t],r=e[t-1],a=e[t+1];if(!o)return 0;if(n<t)return r?o.top-(r.top+r.height):a?a.top-(o.top+o.height):0;return a?a.top-(o.top+o.height):r?o.top-(r.top+r.height):0}(a,r,n);return r>n&&r<=s?{x:0,y:-i.height-l,...Xv}:r<n&&r>=s?{x:0,y:i.height+l,...Xv}:{x:0,y:0,...Xv}};const Qv="Sortable",ex=u.createContext({activeIndex:-1,containerId:Qv,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Kv,disabled:{draggable:!1,droppable:!1}});function tx(e){let{children:t,id:n,items:o,strategy:a=Kv,disabled:s=!1}=e;const{active:i,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:h}=r.useContext(Dv),f=Ii(Qv,n),m=Boolean(null!==l.rect),p=r.useMemo((()=>o.map((e=>"object"==typeof e&&"id"in e?e.id:e))),[o]),g=null!=i,v=i?p.indexOf(i.id):-1,x=d?p.indexOf(d.id):-1,y=r.useRef(p),b=!function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(p,y.current),w=-1!==x&&-1===v||b,k=function(e){return"boolean"==typeof e?{draggable:e,droppable:e}:e}(s);Ti((()=>{b&&g&&h(p)}),[b,p,g,h]),r.useEffect((()=>{y.current=p}),[p]);const N=r.useMemo((()=>({activeIndex:v,containerId:f,disabled:k,disableTransforms:w,items:p,overIndex:x,useDragOverlay:m,sortedRects:Wv(p,c),strategy:a})),[v,f,k.draggable,k.droppable,w,p,x,c,m,a]);return u.createElement(ex.Provider,{value:N},t)}const nx=e=>{let{id:t,items:n,activeIndex:o,overIndex:r}=e;return Hv(n,o,r).indexOf(t)},ox=e=>{let{containerId:t,isSorting:n,wasDragging:o,index:r,items:a,newIndex:s,previousItems:i,previousContainerId:l,transition:c}=e;return!(!c||!o)&&((i===a||r!==s)&&(!!n||s!==r&&t===l))},rx={duration:200,easing:"ease"},ax="transform",sx=Yi.Transition.toString({property:ax,duration:0,easing:"linear"}),ix={roleDescription:"sortable"};function lx(e){let{animateLayoutChanges:t=ox,attributes:n,disabled:o,data:a,getNewIndex:s=nx,id:i,strategy:l,resizeObserverConfig:c,transition:d=rx}=e;const{items:u,containerId:h,activeIndex:f,disabled:m,disableTransforms:p,sortedRects:g,overIndex:v,useDragOverlay:x,strategy:y}=r.useContext(ex),b=function(e,t){var n,o;if("boolean"==typeof e)return{draggable:e,droppable:!1};return{draggable:null!=(n=null==e?void 0:e.draggable)?n:t.draggable,droppable:null!=(o=null==e?void 0:e.droppable)?o:t.droppable}}(o,m),w=u.indexOf(i),k=r.useMemo((()=>({sortable:{containerId:h,index:w,items:u},...a})),[h,a,w,u]),N=r.useMemo((()=>u.slice(u.indexOf(i))),[u,i]),{rect:E,node:C,isOver:j,setNodeRef:S}=function(e){let{data:t,disabled:n=!1,id:o,resizeObserverConfig:a}=e;const s=Ii("Droppable"),{active:i,dispatch:l,over:c,measureDroppableContainers:d}=r.useContext(Ov),u=r.useRef({disabled:n}),h=r.useRef(!1),f=r.useRef(null),m=r.useRef(null),{disabled:p,updateMeasurementsFor:g,timeout:v}={...Gv,...a},x=Si(null!=g?g:o),y=xv({callback:r.useCallback((()=>{h.current?(null!=m.current&&clearTimeout(m.current),m.current=setTimeout((()=>{d(Array.isArray(x.current)?x.current:[x.current]),m.current=null}),v)):h.current=!0}),[v]),disabled:p||!i}),b=r.useCallback(((e,t)=>{y&&(t&&(y.unobserve(t),h.current=!1),e&&y.observe(e))}),[y]),[w,k]=Bi(b),N=Si(t);return r.useEffect((()=>{y&&w.current&&(y.disconnect(),h.current=!1,y.observe(w.current))}),[w,y]),Ti((()=>(l({type:rg.RegisterDroppable,element:{id:o,key:s,disabled:n,node:w,rect:f,data:N}}),()=>l({type:rg.UnregisterDroppable,key:s,id:o}))),[o]),r.useEffect((()=>{n!==u.current.disabled&&(l({type:rg.SetDroppableDisabled,id:o,key:s,disabled:n}),u.current.disabled=n)}),[o,s,n,l]),{active:i,rect:f,isOver:(null==c?void 0:c.id)===o,node:w,over:c,setNodeRef:k}}({id:i,data:k,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:N,...c}}),{active:I,activatorEvent:A,activeNodeRect:M,attributes:T,setNodeRef:O,listeners:D,isDragging:_,over:P,setActivatorNodeRef:R,transform:F}=$v({id:i,data:k,attributes:{...ix,...n},disabled:b.draggable}),L=qi(S,O),z=Boolean(I),B=z&&!p&&qv(f)&&qv(v),U=!x&&_,V=U&&B?F:null,$=B?null!=V?V:(null!=l?l:y)({rects:g,activeNodeRect:M,activeIndex:f,overIndex:v,index:w}):null,G=qv(f)&&qv(v)?s({id:i,items:u,activeIndex:f,overIndex:v}):w,H=null==I?void 0:I.id,W=r.useRef({activeId:H,items:u,newIndex:G,containerId:h}),q=u!==W.current.items,Y=t({active:I,containerId:h,isDragging:_,isSorting:z,id:i,index:w,items:u,newIndex:W.current.newIndex,previousItems:W.current.items,previousContainerId:W.current.containerId,transition:d,wasDragging:null!=W.current.activeId}),J=function(e){let{disabled:t,index:n,node:o,rect:a}=e;const[s,i]=r.useState(null),l=r.useRef(n);return Ti((()=>{if(!t&&n!==l.current&&o.current){const e=a.current;if(e){const t=Ng(o.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&i(n)}}n!==l.current&&(l.current=n)}),[t,n,o,a]),r.useEffect((()=>{s&&i(null)}),[s]),s}({disabled:!Y,index:w,node:C,rect:E});return r.useEffect((()=>{z&&W.current.newIndex!==G&&(W.current.newIndex=G),h!==W.current.containerId&&(W.current.containerId=h),u!==W.current.items&&(W.current.items=u)}),[z,G,h,u]),r.useEffect((()=>{if(H===W.current.activeId)return;if(H&&!W.current.activeId)return void(W.current.activeId=H);const e=setTimeout((()=>{W.current.activeId=H}),50);return()=>clearTimeout(e)}),[H]),{active:I,activeIndex:f,attributes:T,data:k,rect:E,index:w,newIndex:G,items:u,isOver:j,isSorting:z,isDragging:_,listeners:D,node:C,overIndex:v,over:P,setNodeRef:L,setActivatorNodeRef:R,setDroppableNodeRef:S,setDraggableNodeRef:O,transform:null!=J?J:$,transition:function(){if(J||q&&W.current.newIndex===w)return sx;if(U&&!Di(A)||!d)return;if(z||Y)return Yi.Transition.toString({...d,property:ax});return}()}}function cx(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&"object"==typeof t.sortable&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const dx=[Hg.Down,Hg.Right,Hg.Up,Hg.Left],ux=(e,t)=>{let{context:{active:n,collisionRect:o,droppableRects:r,droppableContainers:a,over:s,scrollableAncestors:i}}=t;if(dx.includes(e.code)){if(e.preventDefault(),!n||!o)return;const t=[];a.getEnabled().forEach((n=>{if(!n||null!=n&&n.disabled)return;const a=r.get(n.id);if(a)switch(e.code){case Hg.Down:o.top<a.top&&t.push(n);break;case Hg.Up:o.top>a.top&&t.push(n);break;case Hg.Left:o.left>a.left&&t.push(n);break;case Hg.Right:o.left<a.left&&t.push(n)}}));const l=(e=>{let{collisionRect:t,droppableRects:n,droppableContainers:o}=e;const r=hg(t),a=[];for(const s of o){const{id:e}=s,t=n.get(e);if(t){const n=hg(t),o=r.reduce(((e,t,o)=>e+cg(n[o],t)),0),i=Number((o/4).toFixed(4));a.push({id:e,data:{droppableContainer:s,value:i}})}}return a.sort(dg)})({active:n,collisionRect:o,droppableRects:r,droppableContainers:t,pointerCoordinates:null});let c=fg(l,"id");if(c===(null==s?void 0:s.id)&&l.length>1&&(c=l[1].id),null!=c){const e=a.get(n.id),t=a.get(c),s=t?r.get(t.id):null,l=null==t?void 0:t.node.current;if(l&&s&&e&&t){const n=Cg(l).some(((e,t)=>i[t]!==e)),r=hx(e,t),a=function(e,t){if(!cx(e)||!cx(t))return!1;if(!hx(e,t))return!1;return e.data.current.sortable.index<t.data.current.sortable.index}(e,t),c=n||!r?{x:0,y:0}:{x:a?o.width-s.width:0,y:a?o.height-s.height:0},d={x:s.left,y:s.top};return c.x&&c.y?d:_i(d,c)}}}};function hx(e,t){return!(!cx(e)||!cx(t))&&e.data.current.sortable.containerId===t.data.current.sortable.containerId}const fx=u.createContext(null),mx=r.memo((()=>r.useContext(fx)));mx.displayName="DragHandle";const px=u.forwardRef((({cellId:e,canMoveX:t,...n},o)=>{const{attributes:r,listeners:a,setNodeRef:s,transform:i,transition:l,isDragging:c}=lx({id:e.toString()}),d={transform:i?Yi.Transform.toString({x:t?i.x:0,y:i.y,scaleX:1,scaleY:1}):void 0,transition:l,zIndex:c?2:void 0,position:"relative"},u=Kp(o,s),h=m.jsx("div",{...r,...a,onMouseDown:$e.preventFocus,"data-testid":"drag-button",className:"py-[1px] cursor-grab opacity-50 hover:opacity-100 hover-action hover:bg-muted rounded border border-transparent hover:border-border active:bg-accent",children:m.jsx(ql,{strokeWidth:1,size:20})}),f=Boolean(i);return m.jsx("div",{tabIndex:-1,ref:u,...n,"data-is-dragging":c,className:$t(n.className,f&&"is-moving"),style:d,children:m.jsx(fx.Provider,{value:h,children:n.children})})}));px.displayName="SortableCell";const gx=r.memo(px),vx=u.memo(u.forwardRef((({children:e,showTooltip:t=!0,...n},o)=>{const[a,s]=r.useState(!1),i=od({cell:n}),l=Mo();r.useImperativeHandle(o,(()=>({toggle:()=>s((e=>!e))})));const c=m.jsx(Xt,{className:"w-[300px] p-0 pt-1",...l,children:m.jsxs(Jt,{children:[m.jsx(Te,{placeholder:"Search actions...",className:"h-6 m-1"}),m.jsxs(To,{children:[m.jsx(De,{children:"No results"}),i.map(((e,t)=>m.jsxs(r.Fragment,{children:[m.jsx(_e,{children:e.map((e=>m.jsx(Fe,{onSelect:()=>{e.disableClick||(e.handle(),s(!1))},variant:e.variant,children:m.jsxs("div",{className:"flex items-center flex-1",children:[e.icon&&m.jsx("div",{className:"mr-2 w-5",children:e.icon}),m.jsx("div",{className:"flex-1",children:e.label}),m.jsxs("div",{className:"flex-shrink-0 text-sm",children:[e.hotkey&&ni(e.hotkey),e.rightElement]})]})},e.label)))},t),t<i.length-1&&m.jsx(Re,{})]},t)))]})]})});if(!t)return m.jsxs(Yt,{open:a,onOpenChange:s,children:[m.jsx(Oo,{asChild:!0,children:e}),c]});const d=m.jsx(Po,{tabIndex:-1,children:Ds("cell.cellActions")});return m.jsxs(Yt,{open:a,onOpenChange:s,children:[m.jsxs(Do,{delayDuration:200,disableHoverableContent:!0,children:[!a&&d,m.jsx(_o,{children:m.jsx(Oo,{className:"flex",children:e})})]}),c]})}))),xx=u.memo((({children:e,cellId:t})=>{const n=X(r.useMemo((()=>function(e){return V((t=>id(e,t(J))))}(t)),[t]));return n?m.jsx(vx,{showTooltip:!1,...n,children:e}):null}));xx.displayName="ConnectionCellActionsDropdown";const yx=({children:e,...t})=>{const n=od({cell:t}),[o,a]=u.useState(),s=[{label:"Copy",icon:m.jsx(Ve,{size:13,strokeWidth:1.5}),handle:()=>{document.execCommand("copy")}},{label:"Cut",icon:m.jsx(vc,{size:13,strokeWidth:1.5}),handle:()=>{document.execCommand("cut")}},{label:"Paste",icon:m.jsx(Pl,{size:13,strokeWidth:1.5}),handle:async()=>{const{getEditorView:e}=t,n=e();if(!n)return;const o=await navigator.clipboard.readText();if(o){const{from:e,to:t}=n.state.selection.main,r=n.state.update({changes:{from:e,to:t,insert:o}});n.dispatch(r)}}},{icon:m.jsx(xi,{size:13,strokeWidth:1.5}),label:"Download image",hidden:!o,handle:()=>{if(o){const e=document.createElement("a");e.download="image.png",e.href=o.src,e.click()}}},{label:"Go to Definition",icon:m.jsx(Ro,{size:13,strokeWidth:1.5}),handle:()=>{const{getEditorView:e}=t,n=e();n&&Fo(n)}}];return m.jsxs(Dp,{children:[m.jsx(_p,{onContextMenu:e=>{e.target instanceof HTMLImageElement?a(e.target):a(void 0)},asChild:!0,children:e}),m.jsx(Fp,{className:"w-[300px]",children:[s,...n].map(((e,t)=>m.jsxs(r.Fragment,{children:[e.map((e=>e.hidden?null:m.jsx(Lp,{onSelect:t=>{e.handle(t)},variant:e.variant,children:m.jsxs("div",{className:"flex items-center flex-1",children:[e.icon&&m.jsx("div",{className:"mr-2 w-5",children:e.icon}),m.jsx("div",{className:"flex-1",children:e.label}),m.jsxs("div",{className:"flex-shrink-0 text-sm",children:[e.hotkey&&ni(e.hotkey),e.rightElement]})]})},e.label))),t<e.length-1&&m.jsx(zp,{})]},t)))})]})},bx=({editorView:e,code:t,currentLanguageAdapter:n,onAfterToggle:o})=>{const a=r.useMemo((()=>(new Eo).isSupported(t)),[t]),s=r.useMemo((()=>(new Co).isSupported(t)),[t]);return m.jsxs("div",{className:"absolute right-2 top-2 z-20 flex hover-action",children:[m.jsx(wx,{editorView:e,currentLanguageAdapter:n,canSwitchToLanguage:s&&"python"===n&&!a,icon:m.jsx(de,{color:"var(--sky-11)",strokeWidth:2.5,className:"w-4 h-4"}),toType:"sql",displayName:"SQL",onAfterToggle:o}),m.jsx(wx,{editorView:e,currentLanguageAdapter:n,canSwitchToLanguage:a&&"python"===n,icon:m.jsx(Ls,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),toType:"markdown",displayName:"Markdown",onAfterToggle:o}),m.jsx(wx,{editorView:e,currentLanguageAdapter:n,canSwitchToLanguage:!0,icon:m.jsx(zs,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),toType:"python",displayName:"Python",onAfterToggle:Gt.NOOP})]})},wx=({editorView:e,currentLanguageAdapter:t,canSwitchToLanguage:n,icon:o,toType:r,displayName:a,onAfterToggle:s})=>n?t===r?null:m.jsx(p,{content:`View as ${a}`,children:m.jsx(b,{"data-testid":"language-toggle-button",variant:"text",size:"xs",className:"opacity-80 px-1",onClick:()=>{e&&(Lo(e,r),s())},children:o})}):null;var kx={modified:{doc:""},original:{doc:""}},Nx=r.createContext(kx);function Ex(e,t){return Kn({},e,t,{modified:Kn({},e.modified,t.modified),original:Kn({},e.original,t.original)})}var Cx=()=>r.useContext(Nx),jx=e=>{var{children:t,theme:n}=e,[o,a]=r.useReducer(Ex,Kn({},kx,{theme:n}));return r.useEffect((()=>a({theme:n})),[n]),m.jsx(Nx.Provider,{value:Kn({},o,{dispatch:a}),children:t})},Sx=["extensions","value","selection","onChange"],Ix=e=>{var{extensions:t=[],value:n,selection:o,onChange:a}=e,s=zo(e,Sx),{theme:i,dispatch:l}=Cx(),c=Bo(Kn({},s,{theme:i}));return r.useEffect((()=>l({original:{doc:n,selection:o,extensions:[...c,...t]},originalExtension:{onChange:a,option:s,extension:[t]}})),[e]),null};Ix.displayName="CodeMirrorMerge.Original";var Ax=["extensions","value","selection","onChange"],Mx=e=>{var{extensions:t=[],value:n,selection:o,onChange:a}=e,s=zo(e,Ax),{theme:i,dispatch:l}=Cx(),c=Bo(Kn({},s,{theme:i}));return r.useEffect((()=>{l({modified:{doc:n,selection:o,extensions:[...c,...t]},modifiedExtension:{onChange:a,option:s,extension:[t]}})}),[e]),null};Mx.displayName="CodeMirrorMerge.Modified";class Tx{constructor(e,t,n,o){this.fromA=e,this.toA=t,this.fromB=n,this.toB=o}offset(e,t){return new Tx(this.fromA+e,this.toA+e,this.fromB+t,this.toB+t)}}function Ox(e,t,n,o,r,a){if(e==o)return[];let s=zx(e,t,n,o,r,a),i=Bx(e,t+s,n,o,r+s,a),l=(n-=i)-(t+=s),c=(a-=i)-(r+=s);if(!l||!c)return[new Tx(t,n,r,a)];if(l>c){let s=e.slice(t,n).indexOf(o.slice(r,a));if(s>-1)return[new Tx(t,t+s,r,r),new Tx(t+s+c,n,a,a)]}else if(c>l){let s=o.slice(r,a).indexOf(e.slice(t,n));if(s>-1)return[new Tx(t,t,r,r+s),new Tx(n,n,r+s+l,a)]}if(1==l||1==c)return[new Tx(t,n,r,a)];let d=Vx(e,t,n,o,r,a);if(d){let[s,i,l]=d;return Ox(e,t,s,o,r,i).concat(Ox(e,s+l,n,o,i+l,a))}return function(e,t,n,o,r,a){let s=n-t,i=a-r;if(Dx<1e9&&Math.min(s,i)>16*Dx)return Math.min(s,i)>64*Dx?[new Tx(t,n,r,a)]:$x(e,t,n,o,r,a);let l=Math.ceil((s+i)/2);Px.reset(l),Rx.reset(l);let c=(n,a)=>e.charCodeAt(t+n)==o.charCodeAt(r+a),d=(t,r)=>e.charCodeAt(n-t-1)==o.charCodeAt(a-r-1),u=(s-i)%2!=0?Rx:null,h=u?null:Px;for(let f=0;f<l;f++){if(f>Dx)return $x(e,t,n,o,r,a);let m=Px.advance(f,s,i,l,u,!1,c)||Rx.advance(f,s,i,l,h,!0,d);if(m)return Fx(e,t,n,t+m[0],o,r,a,r+m[1])}return[new Tx(t,n,r,a)]}(e,t,n,o,r,a)}let Dx=1e9;class _x{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let t=0;t<this.len;t++)this.vec[t]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,n,o,r,a,s){for(let i=-e+this.start;i<=e-this.end;i+=2){let l=o+i,c=i==-e||i!=e&&this.vec[l-1]<this.vec[l+1]?this.vec[l+1]:this.vec[l-1]+1,d=c-i;for(;c<t&&d<n&&s(c,d);)c++,d++;if(this.vec[l]=c,c>t)this.end+=2;else if(d>n)this.start+=2;else if(r){let e=o+(t-n)-i;if(e>=0&&e<this.len&&-1!=r.vec[e])if(a){let n=r.vec[e];if(n>=t-c)return[n,o+n-e]}else{if(c>=t-r.vec[e])return[c,d]}}}return null}}const Px=new _x,Rx=new _x;function Fx(e,t,n,o,r,a,s,i){let l=!1;return ey(e,o)||++o!=n||(l=!0),ey(r,i)||++i!=s||(l=!0),l?[new Tx(t,n,a,s)]:Ox(e,t,o,r,a,i).concat(Ox(e,o,n,r,i,s))}function Lx(e,t){let n=1,o=Math.min(e,t);for(;n<o;)n<<=1;return n}function zx(e,t,n,o,r,a){if(t==n||t==a||e.charCodeAt(t)!=o.charCodeAt(r))return 0;let s=Lx(n-t,a-r);for(let i=t,l=r;;){let r=i+s,c=l+s;if(r>n||c>a||e.slice(i,r)!=o.slice(l,c)){if(1==s)return i-t-(ey(e,i)?0:1);s>>=1}else{if(r==n||c==a)return r-t;i=r,l=c}}}function Bx(e,t,n,o,r,a){if(t==n||r==a||e.charCodeAt(n-1)!=o.charCodeAt(a-1))return 0;let s=Lx(n-t,a-r);for(let i=n,l=a;;){let a=i-s,c=l-s;if(a<t||c<r||e.slice(a,i)!=o.slice(c,l)){if(1==s)return n-i-(ey(e,i)?0:1);s>>=1}else{if(a==t||c==r)return n-a;i=a,l=c}}}function Ux(e,t,n,o,r,a,s,i){let l=o.slice(r,a),c=null;for(;;){if(c||s<i)return c;for(let i=t+s;;){ey(e,i)||i++;let d=i+s;if(ey(e,d)||(d+=d==i+1?1:-1),d>=n)break;let u=e.slice(i,d),h=-1;for(;-1!=(h=l.indexOf(u,h+1));){let s=zx(e,d,n,o,r+h+u.length,a),l=Bx(e,t,i,o,r,r+h),f=u.length+s+l;(!c||c[2]<f)&&(c=[i-l,r+h-l,f])}i=d}if(i<0)return c;s>>=1}}function Vx(e,t,n,o,r,a){let s=n-t,i=a-r;if(s<i){let s=Vx(o,r,a,e,t,n);return s&&[s[1],s[0],s[2]]}return s<4||2*i<s?null:Ux(e,t,n,o,r,a,Math.floor(s/4),-1)}function $x(e,t,n,o,r,a){let s,i=n-t,l=a-r;if(i<l){let l=Ux(o,r,a,e,t,n,Math.floor(i/6),50);s=l&&[l[1],l[0],l[2]]}else s=Ux(e,t,n,o,r,a,Math.floor(l/6),50);if(!s)return[new Tx(t,n,r,a)];let[c,d,u]=s;return Ox(e,t,c,o,r,d).concat(Ox(e,c+u,n,o,d+u,a))}function Gx(e,t){for(let n=1;n<e.length;n++){let o=e[n-1],r=e[n];o.toA>r.fromA-t&&o.toB>r.fromB-t&&(e[n-1]=new Tx(o.fromA,r.toA,o.fromB,r.toB),e.splice(n--,1))}}let Hx;try{Hx=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch(RT){}function Wx(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function qx(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?Wx(n)?1:0:Hx?Zx(n)&&t!=e.length-1?Hx.test(e.slice(t,t+2))?2:0:Hx.test(String.fromCharCode(n))?1:0:0}function Yx(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?Wx(n)?1:0:Hx?Qx(n)&&1!=t?Hx.test(e.slice(t-2,t))?2:0:Hx.test(String.fromCharCode(n))?1:0:0}function Jx(e,t,n){if(t==e.length||!Yx(e,t))return t;for(let o=t,r=t+n;;){let n=qx(e,o);if(!n)return o;if(o+=n,o>r)return t}}function Kx(e,t,n){if(!t||!qx(e,t))return t;for(let o=t,r=t-n;;){let n=Yx(e,o);if(!n)return o;if(o-=n,o<r)return t}}function Xx(e,t,n){for(let o=t,r=t-n;;){let n=o?e.charCodeAt(o-1):10;if(10==n)return o;if(o--,o<r||32!=n&&9!=n)return t}}const Zx=e=>e>=55296&&e<=56319,Qx=e=>e>=56320&&e<=57343;function ey(e,t){return!t||t==e.length||!Zx(e.charCodeAt(t-1))||!Qx(e.charCodeAt(t))}function ty(e,t,n){var o;return Dx=(null!==(o=null==n?void 0:n.scanLimit)&&void 0!==o?o:1e9)>>1,function(e,t,n){for(;;){Gx(n,1);let o=!1;for(let r=0;r<n.length;r++){let a,s,i=n[r];(a=zx(e,i.fromA,i.toA,t,i.fromB,i.toB))&&(i=n[r]=new Tx(i.fromA+a,i.toA,i.fromB+a,i.toB)),(s=Bx(e,i.fromA,i.toA,t,i.fromB,i.toB))&&(i=n[r]=new Tx(i.fromA,i.toA-s,i.fromB,i.toB-s));let l=i.toA-i.fromA,c=i.toB-i.fromB;if(l&&c)continue;let d=i.fromA-(r?n[r-1].toA:0),u=(r<n.length-1?n[r+1].fromA:e.length)-i.toA;if(!d||!u)continue;let h=l?e.slice(i.fromA,i.toA):t.slice(i.fromB,i.toB);d<=h.length&&e.slice(i.fromA-d,i.fromA)==h.slice(h.length-d)?(n[r]=new Tx(i.fromA-d,i.toA-d,i.fromB-d,i.toB-d),o=!0):u<=h.length&&e.slice(i.toA,i.toA+u)==h.slice(0,u)&&(n[r]=new Tx(i.fromA+u,i.toA+u,i.fromB+u,i.toB+u),o=!0)}if(!o)break}return n}(e,t,Ox(e,0,e.length,t,0,t.length))}function ny(e,t,n){return function(e,t,n){for(let o=0,r=0;r<e.length;r++){let a=e[r],s=a.toA-a.fromA,i=a.toB-a.fromB;if(s&&i||s>3||i>3){let l=r==e.length-1?t.length:e[r+1].fromA,c=a.fromA-o,d=l-a.toA,u=Kx(t,a.fromA,Math.min(c,5)),h=Jx(t,a.toA,Math.min(d,5)),f=a.fromA-u,m=h-a.toA;if(!s||!i){let d,p,g=Math.max(s,i),[v,x,y]=s?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];f&&m?(g>f&&t.slice(u,a.fromA)==v.slice(y-f,y)?(a=e[r]=new Tx(u,u+s,a.fromB-f,a.toB-f),u=a.fromA,h=Jx(t,a.toA,Math.min(l-a.toA,5))):g>m&&t.slice(a.toA,h)==v.slice(x,x+m)&&(a=e[r]=new Tx(h-s,h,a.fromB+m,a.toB+m),h=a.toA,u=Kx(t,a.fromA,Math.min(a.fromA-o,5))),f=a.fromA-u,m=h-a.toA):f||m||!(p=a.fromA-(d=Xx(t,a.fromA,c)))||t.slice(d,a.fromA)!=v.slice(y-p,y)||(a=e[r]=new Tx(d,d+s,a.fromB-p,a.toB-p))}(f||m)&&(a=e[r]=new Tx(a.fromA-f,a.toA+m,a.fromB-f,a.toB+m)),o=a.toA}}return Gx(e,3),e}(ty(e,t,n),e,t)}const oy=rn.define({combine:e=>e[0]}),ry=_t.define(),ay=Pt.define({create:e=>null,update(e,t){for(let n of t.effects)n.is(ry)&&(e=n.value);return e}});class sy{constructor(e,t,n,o,r){this.changes=e,this.fromA=t,this.toA=n,this.fromB=o,this.toB=r}offset(e,t){return e||t?new sy(this.changes,this.fromA+e,this.toA+e,this.fromB+t,this.toB+t):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,t,n){return cy(ny(e.toString(),t.toString(),n),e,t,0,0)}static updateA(e,t,n,o,r){return fy(hy(e,o,!0,n.length),e,t,n,r)}static updateB(e,t,n,o,r){return fy(hy(e,o,!1,t.length),e,t,n,r)}}function iy(e,t,n,o){let r=n.lineAt(e),a=o.lineAt(t);return r.to==e&&a.to==t&&e<n.length&&t<o.length?[e+1,t+1]:[r.from,a.from]}function ly(e,t,n,o){let r=n.lineAt(e),a=o.lineAt(t);return r.from==e&&a.from==t?[e,t]:[r.to+1,a.to+1]}function cy(e,t,n,o,r){let a=[];for(let s=0;s<e.length;s++){let i=e[s],[l,c]=iy(i.fromA+o,i.fromB+r,t,n),[d,u]=ly(i.toA+o,i.toB+r,t,n),h=[i.offset(-l+o,-c+r)];for(;s<e.length-1;){let a=e[s+1],[i,f]=iy(a.fromA+o,a.fromB+r,t,n);if(i>d+1&&f>u+1)break;h.push(a.offset(-l+o,-c+r)),[d,u]=ly(a.toA+o,a.toB+r,t,n),s++}a.push(new sy(h,l,Math.max(l,d),c,Math.max(c,u)))}return a}const dy=1e3;function uy(e,t,n,o){let r=0,a=e.length;for(;;){if(r==a){let o=0,a=0;r&&({toA:o,toB:a}=e[r-1]);let s=t-(n?o:a);return[o+s,a+s]}let s=r+a>>1,i=e[s],[l,c]=n?[i.fromA,i.toA]:[i.fromB,i.toB];if(l>t)a=s;else{if(!(c<=t))return o?[i.fromA,i.fromB]:[i.toA,i.toB];r=s+1}}}function hy(e,t,n,o){let r=[];return t.iterChangedRanges(((a,s,i,l)=>{let c=0,d=n?t.length:o,u=0,h=n?o:t.length;a>dy&&([c,u]=uy(e,a-dy,n,!0)),s<t.length-dy&&([d,h]=uy(e,s+dy,n,!1));let f,m=l-i-(s-a),[p,g]=n?[m,0]:[0,m];r.length&&(f=r[r.length-1]).toA>=c?r[r.length-1]={fromA:f.fromA,fromB:f.fromB,toA:d,toB:h,diffA:f.diffA+p,diffB:f.diffB+g}:r.push({fromA:c,toA:d,fromB:u,toB:h,diffA:p,diffB:g})})),r}function fy(e,t,n,o,r){if(!e.length)return t;let a=0,s=0,i=0,l=[];for(let c of e){let e=c.fromA+s,d=c.toA+s+c.diffA,u=c.fromB+i,h=c.toB+i+c.diffB;for(;a<t.length;){let n=t[a];if(n.toA+s<=e&&n.toB+i<=u)l.push(n.offset(s,i));else if(n.fromA+s>d)break;a++}for(let t of cy(ny(n.sliceString(e,d),o.sliceString(u,h),r),n,o,e,u))l.push(t);for(s+=c.diffA,i+=c.diffB;a<t.length;){let e=t[a];if(e.fromA>d+s&&e.fromB>h+i)break;a++}}for(;a<t.length;)l.push(t[a++].offset(s,i));return l}const my=Ft.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=ky(e))}update(e){var t,n;(e.docChanged||e.viewportChanged||(t=e.startState,n=e.state,t.field(ay,!1)!=n.field(ay,!1))||function(e,t){return e.facet(oy)!=t.facet(oy)}(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=ky(e.view))}},{decorations:e=>e.deco}),py=nn.low(Uo({class:"cm-changeGutter",markers:e=>{var t;return(null===(t=e.plugin(my))||void 0===t?void 0:t.gutter)||Vo.empty}}));const gy=Rt.line({class:"cm-changedLine"}),vy=Rt.mark({class:"cm-changedText"}),xy=Rt.mark({tagName:"ins",class:"cm-insertedLine"}),yy=Rt.mark({tagName:"del",class:"cm-deletedLine"}),by=new class extends Ho{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function wy(e,t,n,o,r,a){let s=n?e.fromA:e.fromB,i=n?e.toA:e.toB,l=0;if(s!=i){r.add(s,s,gy),r.add(s,i,n?yy:xy),a&&a.add(s,s,by);for(let c=t.iterRange(s,i-1),d=s;!c.next().done;){if(c.lineBreak){d++,r.add(d,d,gy),a&&a.add(d,d,by);continue}let t=d+c.value.length;if(o)for(;l<e.changes.length;){let o=e.changes[l],a=s+(n?o.fromA:o.fromB),i=s+(n?o.toA:o.toB),c=Math.max(d,a),u=Math.min(t,i);if(c<u&&r.add(c,u,vy),!(i<t))break;l++}d=t}}}function ky(e){let t=e.state.field(ay),{side:n,highlightChanges:o,markGutter:r}=e.state.facet(oy),a="a"==n,s=new Lt,i=r?new Lt:null,{from:l,to:c}=e.viewport;for(let d of t){if((a?d.fromA:d.fromB)>=c)break;(a?d.toA:d.toB)>l&&wy(d,e.state.doc,a,o,s,i)}return{deco:s.finish(),gutter:i&&i.finish()}}class Ny extends on{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement("div");return e.className="cm-mergeSpacer",e.style.height=this.height+"px",e}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}const Ey=_t.define({map:(e,t)=>e.map(t)}),Cy=Pt.define({create:()=>Rt.none,update:(e,t)=>{for(let n of t.effects)if(n.is(Ey))return n.value;return e.map(t.changes)},provide:e=>Dt.decorations.from(e)}),jy=.01;const Sy=_t.define({map:(e,t)=>t.mapPos(e)});class Iy extends on{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement("div");return t.className="cm-collapsedLines",t.textContent="⦚ "+e.state.phrase("$ unchanged lines",this.lines)+" ⦚",t.addEventListener("click",(t=>{let n=e.posAtDOM(t.target);e.dispatch({effects:Sy.of(n)});let{side:o,sibling:r}=e.state.facet(oy);r&&r().dispatch({effects:Sy.of(Ay(n,e.state.field(ay),"a"==o))})})),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}}function Ay(e,t,n){let o=0,r=0;for(let a=0;;a++){let s=a<t.length?t[a]:null;if(!s||(n?s.fromA:s.fromB)>=e)return r+(e-o);[o,r]=n?[s.toA,s.toB]:[s.toB,s.toA]}}const My=Pt.define({create:e=>Rt.none,update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Sy)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>Dt.decorations.from(e)});function Ty({margin:e=3,minSize:t=4}){return My.init((n=>function(e,t,n){let o=new Lt,r="a"==e.facet(oy).side,a=e.field(ay),s=1;for(let i=0;;i++){let l=i<a.length?a[i]:null,c=i?s+t:1,d=l?e.doc.lineAt(r?l.fromA:l.fromB).number-1-t:e.doc.lines,u=d-c+1;if(u>=n&&o.add(e.doc.line(c).from,e.doc.line(d).to,Rt.replace({widget:new Iy(u),block:!0})),!l)break;s=e.doc.lineAt(Math.min(e.doc.length,r?l.toA:l.toB)).number}return o.finish()}(n,e,t)))}const Oy=Dt.styleModule.of(new $o({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}})),Dy=Dt.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb2266, #22bb2266) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff8866, #88ff8866) bottom/100% 2px no-repeat"},".cm-insertedLine, .cm-deletedLine":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer"},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"}}),_y=new Go,Py=new Go;class Ry{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig;let t=[nn.low(my),Dy,Oy,Cy,Dt.updateListener.of((e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some((e=>e.effects.some((e=>e.is(Ey)))))&&this.measure()}))],n=[oy.of({side:"a",sibling:()=>this.b,highlightChanges:!1!==e.highlightChanges,markGutter:!1!==e.gutter})];!1!==e.gutter&&n.push(py);let o=Un.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],Dt.editorAttributes.of({class:"cm-merge-a"}),Py.of(n),t]}),r=[oy.of({side:"b",sibling:()=>this.a,highlightChanges:!1!==e.highlightChanges,markGutter:!1!==e.gutter})];!1!==e.gutter&&r.push(py);let a=Un.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],Dt.editorAttributes.of({class:"cm-merge-b"}),Py.of(r),t]});this.chunks=sy.build(o.doc,a.doc,this.diffConf);let s=[ay.init((()=>this.chunks)),_y.of(e.collapseUnchanged?Ty(e.collapseUnchanged):[])];o=o.update({effects:_t.appendConfig.of(s)}).state,a=a.update({effects:_t.appendConfig.of(s)}).state,this.dom=document.createElement("div"),this.dom.className="cm-mergeView",this.editorDOM=this.dom.appendChild(document.createElement("div")),this.editorDOM.className="cm-mergeViewEditors";let i=e.orientation||"a-b",l=document.createElement("div");l.className="cm-mergeViewEditor";let c=document.createElement("div");c.className="cm-mergeViewEditor",this.editorDOM.appendChild("a-b"==i?l:c),this.editorDOM.appendChild("a-b"==i?c:l),this.a=new Dt({state:o,parent:l,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new Dt({state:a,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.b)}),this.setupRevertControls(!!e.revertControls,"b-to-a"==e.revertControls,e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some((e=>e.docChanged))){let n=e[e.length-1],o=e.reduce(((e,t)=>e.compose(t.changes)),cn.empty(e[0].startState.doc.length));this.chunks=t==this.a?sy.updateA(this.chunks,n.newDoc,this.b.state.doc,o,this.diffConf):sy.updateB(this.chunks,this.a.state.doc,n.newDoc,o,this.diffConf),t.update([...e,n.state.update({effects:ry.of(this.chunks)})]);let r=t==this.a?this.b:this.a;r.update([r.state.update({effects:ry.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let t="b-a"!=e.orientation;if(t!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let e=this.a.dom.parentNode,n=this.b.dom.parentNode;e.remove(),n.remove(),this.editorDOM.insertBefore(t?e:n,this.editorDOM.firstChild),this.editorDOM.appendChild(t?n:e),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let t=!!this.revertDOM,n=this.revertToA,o=this.renderRevert;"revertControls"in e&&(t=!!e.revertControls,n="b-to-a"==e.revertControls),"renderRevertControl"in e&&(o=e.renderRevertControl),this.setupRevertControls(t,n,o)}let t="highlightChanges"in e,n="gutter"in e,o="collapseUnchanged"in e;if(t||n||o){let r=[],a=[];if(t||n){let o=this.a.state.facet(oy),s=n?!1!==e.gutter:o.markGutter,i=t?!1!==e.highlightChanges:o.highlightChanges;r.push(Py.reconfigure([oy.of({side:"a",sibling:()=>this.b,highlightChanges:i,markGutter:s}),s?py:[]])),a.push(Py.reconfigure([oy.of({side:"b",sibling:()=>this.a,highlightChanges:i,markGutter:s}),s?py:[]]))}if(o){let t=_y.reconfigure(e.collapseUnchanged?Ty(e.collapseUnchanged):[]);r.push(t),a.push(t)}this.a.dispatch({effects:r}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,t,n){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=n,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener("mousedown",(e=>this.revertClicked(e))),this.revertDOM.className="cm-merge-revert"):this.revertDOM&&(this.revertDOM.textContent="")}scheduleMeasure(){if(this.measuring<0){let e=this.dom.ownerDocument.defaultView||window;this.measuring=e.requestAnimationFrame((()=>{this.measuring=-1,this.measure()}))}}measure(){!function(e,t,n){let o=new Lt,r=new Lt,a=e.state.field(Cy).iter(),s=t.state.field(Cy).iter(),i=0,l=0,c=0,d=0;for(let m=0;;m++){let u=m<n.length?n[m]:null;if(i<(u?u.fromA:e.state.doc.length)){let n=e.lineBlockAt(i).top+c-(t.lineBlockAt(l).top+d);n<-.01?(c-=n,o.add(i,i,Rt.widget({widget:new Ny(-n),block:!0,side:-1}))):n>jy&&(d+=n,r.add(l,l,Rt.widget({widget:new Ny(n),block:!0,side:-1})))}if(!u)break;for(i=u.toA,l=u.toB;a.value&&a.from<i;)c-=a.value.spec.widget.height,a.next();for(;s.value&&s.from<l;)d-=s.value.spec.widget.height,s.next()}for(;a.value;)c-=a.value.spec.widget.height,a.next();for(;s.value;)d-=s.value.spec.widget.height,s.next();let u=e.contentHeight+c-(t.contentHeight+d);u<jy?o.add(e.state.doc.length,e.state.doc.length,Rt.widget({widget:new Ny(-u),block:!0,side:1})):u>jy&&r.add(t.state.doc.length,t.state.doc.length,Rt.widget({widget:new Ny(u),block:!0,side:1}));let h=o.finish(),f=r.finish();Vo.eq([h],[e.state.field(Cy)])||e.dispatch({effects:Ey.of(h)}),Vo.eq([f],[t.state.field(Cy)])||t.dispatch({effects:Ey.of(f)})}(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,n=this.a.viewport,o=this.b.viewport;for(let r=0;r<this.chunks.length;r++){let a=this.chunks[r];if(a.fromA>n.to||a.fromB>o.to)break;if(a.fromA<n.from||a.fromB<o.from)continue;let s=this.a.lineBlockAt(a.fromA).top+"px";for(;t&&+t.dataset.chunk<r;)t=Fy(t);t&&t.dataset.chunk==String(r)?(t.style.top!=s&&(t.style.top=s),t=t.nextSibling):e.insertBefore(this.renderRevertButton(s,r),t)}for(;t;)t=Fy(t)}renderRevertButton(e,t){let n;if(this.renderRevert)n=this.renderRevert();else{n=document.createElement("button");let e=this.a.state.phrase("Revert this chunk");n.setAttribute("aria-label",e),n.setAttribute("title",e),n.textContent=this.revertToLeft?"⇜":"⇝"}return n.style.top=e,n.setAttribute("data-chunk",String(t)),n}revertClicked(e){let t,n=e.target;for(;n&&n.parentNode!=this.revertDOM;)n=n.parentNode;if(n&&(t=this.chunks[n.dataset.chunk])){let[n,o,r,a,s,i]=this.revertToA?[this.b,this.a,t.fromB,t.toB,t.fromA,t.toA]:[this.a,this.b,t.fromA,t.toA,t.fromB,t.toB],l=n.state.sliceDoc(r,Math.max(r,a-1));r!=a&&i<=o.state.doc.length&&(l+=n.state.lineBreak),o.dispatch({changes:{from:s,to:Math.min(o.state.doc.length,i),insert:l},userEvent:"revert"}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}}function Fy(e){let t=e.nextSibling;return e.remove(),t}var Ly=["className","children","orientation","revertControls","highlightChanges","gutter","collapseUnchanged","destroyRerender","renderRevertControl"],zy=["modified","modifiedExtension","original","originalExtension","theme","dispatch"],By=u.forwardRef(((e,t)=>{var{className:n,children:o,orientation:a,revertControls:s,highlightChanges:i,gutter:l,collapseUnchanged:c,destroyRerender:d=!0,renderRevertControl:u}=e,h=zo(e,Ly),f=Cx(),{modified:p,modifiedExtension:g,original:v,originalExtension:x,theme:y,dispatch:b}=f,w=zo(f,zy),k=r.useRef(null),N=r.useRef(),E={orientation:a,revertControls:s,highlightChanges:i,gutter:l,collapseUnchanged:c,renderRevertControl:u};r.useImperativeHandle(t,(()=>({container:k.current,view:N.current,modified:p,original:v,config:Kn({a:v,b:p,parent:k.current},E)})),[k,N,p,v,E]);var C=Dt.updateListener.of((e=>{if(e.docChanged&&"function"==typeof(null==x?void 0:x.onChange)){var t=e.state.doc.toString();null==x||x.onChange(t,e)}})),j=Dt.updateListener.of((e=>{if(e.docChanged&&"function"==typeof(null==g?void 0:g.onChange)){var t=e.state.doc.toString();null==g||g.onChange(t,e)}}));r.useEffect((()=>{!N.current&&k.current&&x&&g&&(N.current=new Ry(Kn({a:Kn({},v,{extensions:[...(null==x?void 0:x.extension)||[],...Bo(Kn({},null==x?void 0:x.option,{theme:y})),C]}),b:Kn({},p,{extensions:[...(null==g?void 0:g.extension)||[],...Bo(Kn({},null==g?void 0:g.option,{theme:y})),j]}),parent:k.current},E)),b({view:N.current}))}),[N,k,x,g]),r.useEffect((()=>{if(v&&v.doc&&N.current){var e,t,n=null==(e=N.current)?void 0:e.a.state.doc.toString();if(n!==v.doc)null==(t=N.current)||t.a.dispatch({changes:{from:0,to:n.length,insert:v.doc||""}})}if(p&&p.doc&&N.current){var o,r,a=null==(o=N.current)?void 0:o.b.state.doc.toString();if(a!==p.doc)null==(r=N.current)||r.b.dispatch({changes:{from:0,to:a.length,insert:p.doc||""}})}if(d&&N.current){var s=N.current.a.state.selection.ranges[0].from,i=N.current.b.state.selection.ranges[0].from;N.current.destroy(),N.current=new Ry(Kn({a:Kn({},v,{extensions:[...(null==x?void 0:x.extension)||[],...Bo(Kn({},null==x?void 0:x.option,{theme:y}))]}),b:Kn({},p,{extensions:[...(null==g?void 0:g.extension)||[],...Bo(Kn({},null==g?void 0:g.option,{theme:y}))]}),parent:k.current},E)),s&&(N.current.a.focus(),N.current.a.dispatch({selection:{anchor:s,head:s}})),i&&(N.current.b.focus(),N.current.b.dispatch({selection:{anchor:i,head:i}}))}}),[N,y,k.current,v,p,x,g,d]),r.useEffect((()=>()=>N.current&&N.current.destroy()),[]),r.useEffect((()=>{if(N.current){var e={};w.orientation!==a&&(e.orientation=a),w.revertControls!==s&&(e.revertControls=s),w.highlightChanges!==i&&(e.highlightChanges=i),w.gutter!==l&&(e.gutter=l),w.collapseUnchanged!==c&&(e.collapseUnchanged=c),w.renderRevertControl!==u&&(e.collapseUnchanged=c),Object.keys(e).length&&b&&N.current&&(N.current.reconfigure(Kn({},e)),b(Kn({},e)))}}),[b,N,a,s,i,l,c,u]);return m.jsx("div",Kn({ref:k,className:"cm-merge-theme"+(n?" "+n:"")},h,{children:o}))}));By.displayName="CodeMirrorMerge.Internal";var Uy=["theme"],Vy=u.forwardRef(((e,t)=>{var{theme:n}=e,o=zo(e,Uy);return m.jsx(jx,{theme:n,children:m.jsx(By,Kn({},o,{ref:t}))})}));function $y(e){return void 0===e&&(e=[]),Wo({override:[t=>{var n=t.matchBefore(/@(\w+)?/);return n?n&&n.from==n.to&&!t.explicit?null:{from:null==n?void 0:n.from,options:[...e]}:null}]})}function Gy(e){const t=function(e){const t=G.get(qo),n=Yo.keyBy(t,(e=>e.name)),o=e.match(/@([\w.]+)/g)||[];return o.map((e=>e.slice(1))).map((e=>n.get(e))).filter(Boolean)}(e);return U.debug("Included datasets",t),{includeOtherCode:Js(""),context:{schema:t.map((e=>({name:e.name,columns:e.columns.map((e=>({name:e.name,type:e.type})))})))},code:""}}Vy.Original=Ix,Vy.Modified=Mx,Vy.displayName="CodeMirrorMerge",$y();const Hy=[Jo(),Dt.lineWrapping],Wy=[Ko(),Dt.lineWrapping],qy=Xo("marimo:ai-language","python"),Yy=({onClose:e})=>{const{createNewCell:t}=L(),[n,o]=r.useState({}),[a,s]=je(qy),{theme:i}=we(),{completion:l,input:c,stop:d,isLoading:u,setCompletion:h,setInput:f,handleSubmit:p}=Zo({api:Qo("api/ai/completion").toString(),headers:er.headers(),streamMode:"text",body:{...n,language:a},onError:e=>{q({title:"Generate with AI failed",description:tr(e)})}}),g=m.jsxs("div",{className:"flex items-center px-3",children:[m.jsx(bc,{className:"size-4 text-[var(--blue-11)]"}),m.jsxs(xt,{modal:!1,children:[m.jsx(yt,{asChild:!0,children:m.jsxs(b,{variant:"text",className:"ml-2",size:"xs","data-testid":"language-button",children:["python"===a?"Python":"SQL",m.jsx(nr,{className:"ml-1 h-3.5 w-3.5 text-muted-foreground/70"})]})}),m.jsxs(bt,{align:"center",children:[m.jsx(St,{onClick:()=>s("python"),children:"Python"}),m.jsx(St,{onClick:()=>s("sql"),children:"SQL"})]})]}),m.jsx(Jy,{theme:i,onClose:()=>{h(""),e()},value:c,onChange:e=>{f(e),o(Gy(e))},onSubmit:()=>{u||p()}}),u&&m.jsxs(b,{"data-testid":"stop-completion-button",variant:"text",size:"sm",className:"mb-0",onClick:d,children:[m.jsx(or,{className:"animate-spin mr-1",size:14}),"Stop"]}),!u&&l&&m.jsx(b,{"data-testid":"accept-completion-button",variant:"text",size:"sm",className:"mb-0",disabled:u,onClick:()=>{t({cellId:"__end__",before:!1,code:"python"===a?l:Co.fromQuery(l)}),h(""),e()},children:m.jsx("span",{className:"text-[var(--grass-11)] opacity-100",children:"Accept"})}),m.jsx(b,{variant:"text",size:"sm",className:"mb-0",onClick:e,children:m.jsx(Bt,{className:"size-4"})})]});return m.jsxs("div",{className:$t("flex flex-col w-full gap-2 py-2"),children:[g,!l&&m.jsxs("span",{className:"text-xs text-muted-foreground px-3 flex flex-col gap-1",children:[m.jsxs("span",{children:["You can mention"," ",m.jsx("span",{className:"text-[var(--cyan-11)]",children:"@dataframe"})," or"," ",m.jsx("span",{className:"text-[var(--cyan-11)]",children:"@sql_table"})," to pull additional context such as column names."]}),m.jsx("span",{children:"Code from other cells is automatically included."})]}),l&&m.jsx(rr,{value:l,className:"cm border-t",onChange:h,theme:"dark"===i?"dark":"light",extensions:"python"===a?Hy:Wy})]})},Jy=({value:e,inputRef:t,onChange:n,onSubmit:o,onClose:a,theme:s})=>{const i=o,l=a,c=X(qo),d=r.useMemo((()=>[$y(c.map((e=>({label:`@${e.name}`,info:()=>{const t=[null==e.num_rows?void 0:`${e.num_rows} rows`,null==e.num_columns?void 0:`${e.num_columns} columns`].filter(Boolean).join(", "),n=document.createElement("div");if(n.classList.add("prose","prose-sm","dark:prose-invert"),t){const e=document.createElement("div");e.textContent=t,e.style.fontWeight="bold",n.append(e)}if(e.source){const t=document.createElement("figcaption");t.textContent=`Source: ${e.source}`,n.append(t)}if(e.columns){const t=document.createElement("table"),o=t.insertRow(),r=o.insertCell();r.textContent="Column",r.style.fontWeight="bold";const a=o.insertCell();a.textContent="Type",a.style.fontWeight="bold",e.columns.forEach((e=>{const n=t.insertRow();n.insertCell().textContent=e.name;n.insertCell().textContent=e.type})),n.append(t)}return n}})))),Dt.lineWrapping,ar(),nn.highest(Qt.of([{preventDefault:!0,stopPropagation:!0,any:(e,t)=>{const n=t.metaKey||t.ctrlKey||t.shiftKey;if("Enter"===t.key&&!n)return i(),t.preventDefault(),t.stopPropagation(),!0;if("Enter"===t.key&&t.shiftKey){const n=e.state.selection.main.from;return e.dispatch({changes:{from:n,to:n,insert:"\n"},selection:{anchor:n+1,head:n+1}}),t.preventDefault(),t.stopPropagation(),!0}return!1}}])),Qt.of([{key:"Escape",preventDefault:!0,stopPropagation:!0,run:()=>(l(),!0)}])]),[c,i,l]);return m.jsx(rr,{ref:t,className:"flex-1 font-sans overflow-auto my-1",autoFocus:!0,width:"100%",value:e,basicSetup:!1,extensions:d,onChange:n,theme:"dark"===s?"dark":"light",placeholder:"Generate with AI"})},Ky=Vy.Original,Xy=Vy.Modified,Zy=[Jo(),Dt.lineWrapping],Qy=({onChange:e,initialPrompt:t,currentLanguageAdapter:n,currentCode:o,declineChange:a,acceptChange:s,enabled:i,children:l})=>{const[c,d]=r.useState({}),[h,f]=je(Zc),{completion:g,input:v,stop:x,isLoading:y,setCompletion:w,setInput:k,handleSubmit:N}=Zo({api:Qo("api/ai/completion").toString(),headers:er.headers(),initialInput:t,streamMode:"text",body:{...c,includeOtherCode:h?Js(o):"",code:o,language:n},onError:e=>{q({title:"Completion failed",description:tr(e)})}}),E=u.useRef(null);r.useEffect((()=>{var e;i&&E.current&&(null==(e=E.current.view)||e.focus(),sr(E.current.view))}),[i]),r.useEffect((()=>{i&&k(t||"")}),[i,t,k]);const{theme:C}=we();return m.jsxs("div",{className:"flex flex-col w-full rounded-[inherit] overflow-hidden",children:[m.jsx("div",{className:$t("flex items-center gap-2 border-b px-3 transition-all rounded-[inherit] rounded-b-none duration-300 overflow-hidden",i&&"max-h-[400px] min-h-11 visible",!i&&"max-h-0 min-h-0 invisible"),children:i&&m.jsxs(m.Fragment,{children:[m.jsx(bc,{className:"text-[var(--blue-10)] flex-shrink-0",size:16}),m.jsx(Jy,{inputRef:E,theme:C,onClose:()=>{a(),w("")},value:v,onChange:e=>{k(e),d(Gy(e))},onSubmit:()=>{y||N()}}),y&&m.jsxs(b,{"data-testid":"stop-completion-button",variant:"text",size:"xs",className:"mb-0",onClick:x,children:[m.jsx(or,{className:"animate-spin mr-1",size:14}),"Stop"]}),!y&&g&&m.jsx(b,{"data-testid":"accept-completion-button",variant:"text",size:"xs",className:"mb-0",disabled:y,onClick:()=>{s(g),w("")},children:m.jsx("span",{className:"text-[var(--grass-11)] opacity-100",children:"Accept"})}),m.jsx("div",{className:"h-full w-px bg-border mx-2"}),m.jsx(p,{content:"Include code from other cells",children:m.jsxs("div",{className:"flex flex-row items-start gap-1 overflow-hidden",children:[m.jsx(ir,{"data-testid":"include-other-cells-checkbox",id:"include-other-cells",checked:h,onCheckedChange:e=>f(Boolean(e))}),m.jsx(ae,{htmlFor:"include-other-cells",className:"text-muted-foreground text-xs whitespace-nowrap ellipsis",children:"Include all code"})]})}),m.jsx(b,{"data-testid":"decline-completion-button",variant:"text",size:"icon",disabled:y,onClick:()=>{x(),a(),w("")},children:m.jsx(Bt,{className:"text-[var(--red-10)]",size:16})})]})}),g&&i&&m.jsxs(Vy,{className:"cm",theme:C,children:[m.jsx(Ky,{onChange:e,value:o,extensions:Zy}),m.jsx(Xy,{value:g,editable:!1,readOnly:!0,extensions:Zy})]}),(!g||!i)&&l]})};const eb=u.forwardRef(((e,t)=>{const{className:n,editorView:o}=e,a=r.useRef(null);return r.useEffect((()=>{null!==o&&null!==a.current&&0===a.current.children.length&&a.current.append(o.dom)}),[o,a]),m.jsx("div",{className:$t("cm",n),ref:Kp(t,a),"data-testid":"cell-editor"})}));eb.displayName="CellCodeMirrorEditor";const tb=r.memo((({theme:e,showPlaceholder:t,allowFocus:n,id:o,code:a,status:s,serializedEditorState:i,runCell:l,updateCellCode:c,createNewCell:d,deleteCell:u,focusCell:h,moveCell:f,moveToNextCell:p,updateCellConfig:g,clearSerializedEditorState:v,userConfig:x,editorViewRef:y,hidden:b,setTemporarilyVisible:w})=>{var k;const[N,E]=je(Xc),[C,j]=r.useState(),S=function(){const e=Z(rd);return t=>{be!==t&&e(t)}}(),I=r.useRef(null),A="running"===s||"queued"===s,{sendToTop:M,sendToBottom:T}=L(),O=function(){const{splitCell:e,undoSplitCell:t}=L();return R((n=>{const o=lr(n.cellId),r=(null==o?void 0:o.state.doc.toString())??"";e(n);const{dismiss:a}=q({title:"Cell split",action:m.jsx(Qc,{"data-testid":"undo-split-button",size:"sm",variant:"outline",onClick:()=>{t({...n,snapshot:r}),a()},children:"Undo"})})}))}(),D=R((()=>!A&&(u({cellId:o}),!0))),_=r.useCallback((()=>d({cellId:o,before:!1})),[o,d]),P=r.useCallback((()=>d({cellId:o,before:!0})),[o,d]),F=r.useCallback((()=>f({cellId:o,before:!1})),[o,f]),z=r.useCallback((()=>f({cellId:o,before:!0})),[o,f]),B=r.useCallback((()=>h({cellId:o,before:!1})),[o,h]),U=r.useCallback((()=>h({cellId:o,before:!0})),[o,h]),V=R((()=>{const e=!b;return ye({configs:{[o]:{hide_code:e}}}),g({cellId:o,config:{hide_code:e}}),e})),$=X(ee),G=R((()=>{nd($,d)})),H=cr(x),W=r.useMemo((()=>{const n=(e=>{const{cellId:t,cellMovementCallbacks:n,cellCodeCallbacks:o,keymapConfig:r,hotkeys:a}=e;return[ti(r,n),vn(t,n,a),xn(t,o,a),mp(e),[dp,(s=(e,t)=>{fn(e,t)},Ft.define((e=>new up(e,s)))),Dt.baseTheme({".underline":{textDecoration:"underline",cursor:"pointer",color:"var(--link)"}})]];var s})({cellId:o,showPlaceholder:t,enableAI:H,cellCodeCallbacks:{updateCellCode:c,afterToggleMarkdown:G},cellMovementCallbacks:{onRun:l,deleteCell:D,createAbove:P,createBelow:_,moveUp:z,moveDown:F,focusUp:U,focusDown:B,sendToTop:M,sendToBottom:T,splitCell:O,moveToNextCell:p,toggleHideCode:V,aiCellCompletion:()=>{let e=!1;return E((t=>(null==t?void 0:t.cellId)===o?(e=!0,null):{cellId:o})),e}},completionConfig:x.completion,keymapConfig:x.keymap,theme:e,hotkeys:new dr(x.keymap.overrides??{})});return n.push(Ft.define((e=>{const t=e.state.field(ur);return j(t.type),{update(e){const t=e.state.field(ur);j(t.type)}}}))),n}),[o,x.keymap,x.completion,H,e,t,P,_,U,B,z,F,p,M,T,O,V,c,D,l,E,G]);r.useEffect((()=>{let e;null===i?null===y.current?(y.current=new Dt({state:Un.create({doc:a,extensions:W})}),e=!0,Lo(y.current,hr(y.current.state).type)):(y.current.dispatch({effects:[_t.reconfigure.of([W]),fr(y.current,x.completion,new dr(x.keymap.overrides??{}))]}),e=!1):(y.current=new Dt({state:Un.fromJSON(i,{doc:a,extensions:W},{history:mr})}),Lo(y.current,hr(y.current.state).type),e=!0,v({cellId:o})),null!==y.current&&null!==I.current&&I.current.replaceChildren(y.current.dom),e&&n&&requestAnimationFrame((()=>{var e,t;null==(e=y.current)||e.focus(),null==(t=y.current)||t.dom.scrollIntoView({behavior:"smooth",block:"nearest"})}))}),[y,W,x.completion,x.keymap,v,o,i]),r.useEffect((()=>()=>{var e;null==(e=y.current)||e.destroy()}),[y]);const Y=r.useCallback((async()=>{var e,t;if(b&&void 0!==w){w(!0),null==(e=y.current)||e.focus();const n=null==(t=I.current)?void 0:t.parentElement,o=new AbortController;null==n||n.addEventListener("focusout",(()=>{requestAnimationFrame((()=>{var e;const t=document.activeElement;(null==n?void 0:n.contains(t))||(w(!1),null==(e=y.current)||e.dom.blur(),o.abort())}))}),{signal:o.signal})}}),[b,w,y,I]);return m.jsx(Qy,{enabled:(null==N?void 0:N.cellId)===o,initialPrompt:null==N?void 0:N.initialPrompt,currentCode:(null==(k=y.current)?void 0:k.state.doc.toString())??a,currentLanguageAdapter:C,declineChange:()=>{var e;E(null),null==(e=y.current)||e.focus()},onChange:e=>{var t;null==(t=y.current)||t.dispatch({changes:{from:0,to:y.current.state.doc.length,insert:e}})},acceptChange:e=>{var t,n;null==(t=y.current)||t.dispatch({changes:{from:0,to:y.current.state.doc.length,insert:e}}),null==(n=y.current)||n.focus(),E(null)},children:m.jsxs("div",{className:"relative w-full",onFocus:()=>S(o),children:[b&&m.jsx(pr,{onClick:Y}),m.jsx(eb,{className:$t(b&&"opacity-20 h-8 overflow-hidden"),editorView:y.current,ref:I}),!b&&m.jsx("div",{className:"absolute top-1 right-5",children:m.jsx(bx,{code:a,editorView:y.current,currentLanguageAdapter:C,onAfterToggle:G})})]})})})),nb=e=>m.jsxs("div",{className:"flex items-center gap-2 w-full px-3",children:[m.jsx("div",{className:"flex-1 flex item-center gap-2",children:e.left}),m.jsx("div",{className:"flex-1 flex item-center gap-2 justify-center",children:e.center}),m.jsx("div",{className:"flex-1 flex item-center gap-2 justify-end",children:e.right})]}),ob=e=>e.canCollapse||e.isCollapsed?m.jsx(b,{variant:"text",size:"icon",onClick:e.onClick,children:m.jsx(p,{content:e.isCollapsed?"Expand":"Collapse",children:m.jsx(rb,{isCollapsed:e.isCollapsed})})}):null,rb=({isCollapsed:e})=>e?m.jsx(gr,{className:"w-5 h-5 flex-shrink-0"}):m.jsx(ge,{className:"w-5 h-5 flex-shrink-0"}),ab=r.memo((({onClick:e,count:t,cellId:n})=>{const o=P(),r=vr(o,n);return m.jsx("div",{onClick:e,className:$t("flex items-center justify-between w-[calc(100%-2rem)] h-9 bg-muted rounded-b mx-4 opacity-80 hover:opacity-100 cursor-pointer"),children:m.jsx(nb,{center:m.jsxs(m.Fragment,{children:[m.jsx(nr,{className:"w-4 h-4 flex-shrink-0"}),m.jsxs("span",{className:"text-sm text-gray-500",children:[t," ",1===t?"cell":"cells"," collapsed"]})]}),right:m.jsxs(m.Fragment,{children:[r.errored&&m.jsx(p,{content:"Has errors",delayDuration:100,children:m.jsx(ac,{className:"w-4 h-4 flex-shrink-0 text-destructive"})}),r.stale&&m.jsx(p,{content:"Has stale cells",delayDuration:100,children:m.jsx(xr,{className:"w-4 h-4 flex-shrink-0 text-[var(--yellow-11)]"})}),r.runningOrQueued&&m.jsx(p,{content:"Running",delayDuration:100,children:m.jsx(or,{className:"w-4 h-4 flex-shrink-0 animate-spin"})})]})})})}));ab.displayName="CollapsedCellBanner";const sb=e=>{const{appClosed:t,status:n}=e,o=Wd("running"===n);return m.jsx($p,{tooltip:Ds("global.interrupt"),disabled:t||!o,onClick:o?yr:Gt.NOOP,variant:o?"stale":"disabled","data-testid":"run-button",children:m.jsx(N,{strokeWidth:1.5})})},ib=({edited:e,appClosed:t,status:n,cellConfig:o,needsRun:r,hasOutput:a,onRun:s,cellActionDropdownRef:i,cellId:l,getEditorView:c,name:d})=>m.jsxs(Gp,{className:$t(!r&&"hover-action"),children:[m.jsx(Hp,{edited:e,onClick:t?Gt.NOOP:s,appClosed:t,status:n,config:o,needsRun:r}),m.jsx(sb,{status:n,appClosed:t}),m.jsx(vx,{ref:i,cellId:l,status:n,getEditorView:c,name:d,config:o,hasOutput:a,children:m.jsx($p,{variant:"green",tooltip:null,children:m.jsx(Ci,{strokeWidth:1.5})})})]}),lb=r.memo(r.forwardRef((({theme:e,showPlaceholder:t,allowFocus:n,id:o,code:a,output:s,consoleOutputs:i,status:l,runStartTimestamp:c,runElapsedTimeMs:d,edited:u,interrupted:h,errored:f,stopped:p,staleInputs:g,serializedEditorState:v,mode:x,debuggerActive:y,appClosed:b,showDeleteButton:w,updateCellCode:k,prepareForRun:N,createNewCell:E,deleteCell:C,focusCell:j,moveCell:S,setStdinResponse:I,moveToNextCell:A,updateCellConfig:M,clearSerializedEditorState:T,sendToBottom:O,sendToTop:D,collapseCell:_,expandCell:P,userConfig:F,outline:L,isCollapsed:V,collapseCount:$,config:G,canMoveX:H,name:W},q)=>{U.debug("Rendering Cell",o);const Y=r.useRef(null),J=r.useRef(null),K=r.useRef(null),X=Z(Xc),[Q,ee]=r.useState(!1),te=G.disabled||"disabled-transitively"===l,ne=br(F.runtime.auto_instantiate,d,l,f,h,p),oe=ne||u||h||g&&!te,re="running"===l||"queued"===l,ae=wr({status:l,output:s,runStartTimestamp:c,interrupted:h,staleInputs:g},u),se=("queued"===l||u||g)&&!h,ie="edit"===x,ce=r.useCallback((()=>{const e=pp(K),t=z(e);return"markdown"!==le(e)&&kr(e),N({cellId:o}),t}),[o,K,N]);r.useImperativeHandle(q,(()=>({get editorView(){return pp(K)},registerRun:ce})),[K,ce]);const de=r.useCallback((()=>K.current),[K]),ue=R((async()=>{if(re)return;const e=ce();await B({cellIds:[o],codes:[e]}).catch((e=>{U.error("Error running cell",e)}))})),he=r.useCallback(((e={})=>E({cellId:o,before:!1,...e})),[o,E]),fe=r.useCallback(((e={})=>E({cellId:o,before:!0,...e})),[o,E]),me=r.useCallback((e=>{null===Y.current||Y.current.contains(e.relatedTarget)||null===K.current||kr(K.current)}),[]),pe=r.useCallback((e=>{if(Y.current===document.activeElement&&null!==K.current&&"active"===ln(K.current.state)){for(const t of Nr)if(e.key===t.key&&t.run){t.run(K.current),e.preventDefault(),e.stopPropagation();break}K.current.focus()}}),[Y,K]),ge=!Er(s),ve=ge&&m.jsxs("div",{className:"relative",children:[m.jsx("div",{className:"absolute top-5 -left-8 z-10 print:hidden",children:m.jsx(ob,{isCollapsed:V,onClick:()=>{V?P({cellId:o}):_({cellId:o})},canCollapse:Cr(L)})}),m.jsx(jr,{allowExpand:ie,output:s,className:"output-area",cellId:o,stale:ae})]}),xe=Sr("Cell","hover-actions-parent z-10",{published:!ie,interactive:ie,"needs-run":oe,"has-error":f,stopped:p,disabled:G.disabled,stale:"disabled-transitively"===l}),be=Qe.create(o);if(oi(ie?Y.current:null,{"cell.run":ue,"cell.runAndNewBelow":()=>{ue(),A({cellId:o,before:!1})},"cell.runAndNewAbove":()=>{ue(),A({cellId:o,before:!0})},"cell.createAbove":fe,"cell.createBelow":he,"cell.moveUp":()=>S({cellId:o,before:!0}),"cell.moveDown":()=>S({cellId:o,before:!1}),"cell.hideCode":()=>{var e,t,n;const r=!G.hide_code;ye({configs:{[o]:{hide_code:r}}}),M({cellId:o,config:{hide_code:r}}),r?(null==(e=K.current)||e.contentDOM.blur(),null==(t=Y.current)||t.focus()):null==(n=K.current)||n.focus()},"cell.focusDown":()=>A({cellId:o,before:!1}),"cell.focusUp":()=>A({cellId:o,before:!0}),"cell.sendToBottom":()=>O({cellId:o}),"cell.sendToTop":()=>D({cellId:o}),"cell.aiCompletion":()=>{let e=!1;X((t=>(null==t?void 0:t.cellId)===o?(e=!0,null):{cellId:o})),e&&pp(K).focus()},"cell.cellActions":()=>{var e;null==(e=J.current)||e.toggle()}}),ri(ie?Y.current:null,{ArrowDown:()=>(A({cellId:o,before:!1,noCreate:!0}),!0),ArrowUp:()=>(A({cellId:o,before:!0,noCreate:!0}),!0),..."vim"===F.keymap.preset&&G.hide_code?{j:()=>(A({cellId:o,before:!1,noCreate:!0}),!0),k:()=>(A({cellId:o,before:!0,noCreate:!0}),!0)}:{}}),!ie){const e=Ir(null==s?void 0:s.mimetype);return f||h||p||e?null:m.jsx("div",{tabIndex:-1,id:be,ref:Y,className:xe,children:ve})}return m.jsx(yx,{cellId:o,config:G,status:l,getEditorView:de,hasOutput:ge,name:W,children:m.jsxs(gx,{tabIndex:-1,ref:Y,"data-status":l,onBlur:me,onKeyDown:pe,cellId:o,canMoveX:H,title:G.disabled?"This cell is disabled":"disabled-transitively"===l?"This cell has a disabled ancestor":void 0,children:[m.jsxs("div",{className:xe,id:be,children:["above"===F.display.cell_output&&ve,m.jsxs("div",{className:"tray",children:[m.jsx("div",{className:"absolute right-2 -top-4 z-10",children:m.jsx(ib,{edited:u,appClosed:b,status:l,cellConfig:G,needsRun:oe,hasOutput:ge,cellActionDropdownRef:J,cellId:o,name:W,getEditorView:de,onRun:ue})}),m.jsxs("div",{className:"absolute flex flex-col gap-[2px] justify-center h-full left-[-34px] z-20",children:[m.jsx(Bp,{tooltipContent:Ds("cell.createAbove"),appClosed:b,onClick:b?void 0:fe}),m.jsx("div",{className:"flex-1"}),m.jsx(Bp,{tooltipContent:Ds("cell.createBelow"),appClosed:b,onClick:b?void 0:he})]}),m.jsx(tb,{theme:e,showPlaceholder:t,allowFocus:n,id:o,code:a,status:l,serializedEditorState:v,runCell:ue,updateCellCode:k,createNewCell:E,deleteCell:C,focusCell:j,moveCell:S,moveToNextCell:A,updateCellConfig:M,clearSerializedEditorState:T,userConfig:F,editorViewRef:K,hidden:G.hide_code&&!Q,setTemporarilyVisible:ee}),m.jsxs("div",{className:"shoulder-right z-20",children:[m.jsx(qp,{status:l,staleInputs:g,interrupted:h,editing:ie,edited:u,disabled:G.disabled??!1,elapsedTime:d,runStartTimestamp:c,uninstantiated:ne}),m.jsx("div",{className:"flex gap-2 items-end",children:m.jsx(mx,{})})]}),m.jsx("div",{className:"shoulder-bottom hover-action",children:w?m.jsx(Wp,{appClosed:b,status:l,onClick:()=>{re||b||C({cellId:o})}}):null})]}),"below"===F.display.cell_output&&ve,m.jsx(Ji,{consoleOutputs:i,stale:se,cellName:W,onRefactorWithAI:e=>{X({cellId:o,initialPrompt:e.prompt})},onSubmitDebugger:(e,t)=>{I({cellId:o,response:e,outputIndex:t}),Ar({text:e})},cellId:o,debuggerActive:y})]}),V&&m.jsx(ab,{onClick:()=>P({cellId:o}),count:$,cellId:o})]})})}))),cb=({width:e})=>{const{banners:t}=Ki(),{removeBanner:n}=Xi();return 0===t.length?null:m.jsx("div",{className:$t("flex flex-col gap-4 mb-5 print:hidden","columns"===e&&"sticky left-12 w-full max-w-[80vw]"),children:t.map((e=>m.jsxs(Mr,{kind:e.variant||"info",className:"flex flex-col rounded p-3",children:[m.jsxs("div",{className:"flex justify-between",children:[m.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[m.jsx(Tr,{className:"w-5 h-5 inline-block mr-2"}),e.title]}),m.jsx(b,{"data-testid":"remove-banner-button",variant:"text",size:"icon",onClick:()=>n(e.id),children:m.jsx(Bt,{className:"w-5 h-5"})})]}),m.jsxs("div",{className:"flex justify-between items-end",children:[m.jsx("span",{children:Or({html:e.description})}),"restart"===e.action&&m.jsx(db,{})]})]},e.id)))})},db=()=>{const e=md();return m.jsxs(b,{"data-testid":"restart-session-button",variant:"link",size:"xs",onClick:e,children:[m.jsx(mc,{className:"w-3 h-3 mr-2"}),"Restart"]})};const ub=(e,t)=>function(e,t){const n=/^(\d+)\.(\d+)\.(\d+)(?:-([\w.-]+))?(?:\+([\w.-]+))?$/,o=e=>{const t=e.match(n);if(!t)return null;const[,o,r,a,s]=t;return{major:Number.parseInt(o,10),minor:Number.parseInt(r,10),patch:Number.parseInt(a,10),preRelease:s||""}};try{const n=o(e),r=o(t);return n&&r?n.major!==r.major?n.major-r.major:n.minor!==r.minor?n.minor-r.minor:n.patch!==r.patch?n.patch-r.patch:""===n.preRelease&&""!==r.preRelease?1:""!==n.preRelease&&""===r.preRelease?-1:n.preRelease.localeCompare(r.preRelease):e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}catch{return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}}(t,e);const hb=()=>{const{packageAlert:e}=Zi(),{clearPackageAlert:t}=Qi(),[n]=ke(),[o,a]=r.useState({});if(null===e)return null;const s="pixi"!==n.package_management.manager;if(el(e))return m.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-[200] opacity-95",children:m.jsxs(Mr,{kind:"danger",className:"flex flex-col rounded py-3 px-5 animate-in slide-in-from-left",children:[m.jsxs("div",{className:"flex justify-between",children:[m.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[m.jsx(ic,{className:"w-5 h-5 inline-block mr-2"}),"Missing packages"]}),m.jsx(b,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:()=>t(e.id),children:m.jsx(Bt,{className:"w-5 h-5"})})]}),m.jsxs("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:[m.jsxs("div",{children:[m.jsx("p",{children:"The following packages were not found:"}),m.jsx("ul",{className:"list-disc ml-4 mt-1",children:e.packages.map(((e,t)=>m.jsxs("li",{className:"flex items-center gap-1 font-mono text-sm",children:[m.jsx(Al,{size:"1rem"}),e,s&&m.jsx(gb,{value:o[e]??"latest",onChange:t=>a((n=>({...n,[e]:t}))),packageName:e})]},t)))})]}),m.jsx("div",{className:"ml-auto flex flex-row items-baseline",children:e.isolated?m.jsxs(m.Fragment,{children:[m.jsx(mb,{manager:n.package_management.manager,versions:o,clearPackageAlert:()=>t(e.id)}),!C()&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"px-2 text-sm",children:"with"})," ",m.jsx(pb,{})]})]}):m.jsxs("p",{children:["If you set up a"," ",m.jsx("a",{href:"https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments",className:"text-accent-foreground hover:underline",target:"_blank",rel:"noreferrer",children:"virtual environment"}),", marimo can install these packages for you."]})})]})]})});if(tl(e)){const{status:n,title:o,titleIcon:r,description:a}=function(e){const t=new Set(Object.values(e)),n=t.has("queued")||t.has("installing")?"installing":t.has("failed")?"failed":"installed";if("installing"===n)return{status:"installing",title:"Installing packages",titleIcon:m.jsx(Rl,{className:"w-5 h-5 inline-block mr-2"}),description:"Installing packages:"};if("installed"===n)return{status:"installed",title:"All packages installed!",titleIcon:m.jsx(sc,{className:"w-5 h-5 inline-block mr-2"}),description:"Installed packages:"};return{status:"failed",title:"Some packages failed to install",titleIcon:m.jsx(ic,{className:"w-5 h-5 inline-block mr-2"}),description:"See terminal for error logs."}}(e.packages);return"installed"===n&&setTimeout((()=>t(e.id)),1e4),m.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-[200] opacity-95",children:m.jsxs(Mr,{kind:"failed"===n?"danger":"info",className:"flex flex-col rounded pt-3 pb-4 px-5",children:[m.jsxs("div",{className:"flex justify-between",children:[m.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[r,o]}),m.jsx(b,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:()=>t(e.id),children:m.jsx(Bt,{className:"w-5 h-5"})})]}),m.jsx("div",{className:$t("flex flex-col gap-4 justify-between items-start text-muted-foreground text-base","installed"===n&&"text-accent-foreground"),children:m.jsxs("div",{children:[m.jsx("p",{children:a}),m.jsx("ul",{className:"list-disc ml-4 mt-1",children:Object.entries(e.packages).map((([e,t],o)=>m.jsxs("li",{className:$t("flex items-center gap-1 font-mono text-sm","installing"===t&&"font-semibold","failed"===t&&"text-destructive","installed"===t&&"text-accent-foreground","installed"===t&&"failed"===n&&"text-muted-foreground"),children:[m.jsx(fb,{status:t}),e]},o)))})]})})]})})}return k(e),null};const fb=({status:e})=>{switch(e){case"queued":return m.jsx(Al,{size:"1rem"});case"installing":return m.jsx(Rl,{size:"1rem"});case"installed":return m.jsx(pt,{size:"1rem"});case"failed":return m.jsx(Bt,{size:"1rem"});default:return k(e),null}},mb=({manager:e,versions:t,clearPackageAlert:n})=>m.jsxs(b,{variant:"outline","data-testid":"install-packages-button",size:"sm",onClick:async()=>{n(),await Dr({manager:e,versions:t}).catch((e=>{U.error(e)}))},children:[m.jsx(Rl,{className:"w-4 h-4 mr-2"}),m.jsx("span",{className:"font-semibold",children:"Install"})]}),pb=()=>{const[e,t]=ke(),n=_r({resolver:Pr(Rr),defaultValues:e});return m.jsx(Fr,{...n,children:m.jsx("form",{onChange:n.handleSubmit((async e=>{await Ee({config:e}).then((()=>{t(e)}))})),className:"flex flex-col gap-5",children:m.jsx("div",{className:"flex flex-col gap-3",children:m.jsx(Lr,{control:n.control,name:"package_management.manager",render:({field:e})=>m.jsxs(zr,{children:[m.jsx(Br,{children:m.jsx(Ur,{"data-testid":"install-package-manager-select",onChange:t=>e.onChange(t.target.value),value:e.value,disabled:e.disabled,className:"inline-flex mr-2",children:Vr.map((e=>m.jsx("option",{value:e,children:e},e)))})}),m.jsx($r,{})]})})})})})},gb=({value:e,onChange:t,packageName:n})=>{const{data:o=[],loading:r,error:a}=Ht((async()=>{const e=await fetch(`https://pypi.org/pypi/${t=n,t.replaceAll(/\[.*]/g,"").trim()}/json`,{method:"GET",signal:AbortSignal.timeout(5e3)});var t;const o=await e.json();return["latest",...Object.keys(o.releases).sort(ub).slice(0,100)]}),[n]);return a?m.jsx(p,{content:"Failed to fetch package versions",children:m.jsx(Ur,{value:e,onChange:e=>t(e.target.value),disabled:!0,className:"inline-flex ml-2",children:m.jsx("option",{value:"latest",children:"latest"})})}):m.jsx(Ur,{value:e,onChange:e=>t(e.target.value),disabled:r,className:"inline-flex ml-2",children:r?m.jsx("option",{value:"latest",children:"latest"}):o.map((e=>m.jsx("option",{value:e,children:e},e)))})},vb=e=>{let{transform:t}=e;return{...t,x:0}},xb={threshold:{x:0,y:.1}},yb=u.memo((({children:e,multiColumn:t})=>{const{cellIds:n}=P(),{dropCellOverCell:o,dropCellOverColumn:a,moveColumn:s,compactColumns:i}=L(),[l,c]=r.useState(null),[d,u]=r.useState(null),[h]=Ne(),f=r.useMemo((()=>"columns"===h.width?Gr.EMPTY:[vb]),[h.width]),p=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.useMemo((()=>[...t].filter((e=>null!=e))),[...t])}(ig(nv,{activationConstraint:{distance:8}}),ig(Xg,{coordinateGetter:ux})),g=R((e=>{c(e.active.id),u(n)})),v=R((()=>{c(null),u(null)})),x=r.useCallback((e=>{const t=e.droppableContainers.filter((e=>wb(e.id)));if(l&&wb(l))return pg({...e,droppableContainers:t});const o=(e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:o}=e;if(!o)return[];const r=[];for(const a of t){const{id:e}=a,t=n.get(e);if(t&&xg(o,t)){const n=hg(t).reduce(((e,t)=>e+cg(o,t)),0),s=Number((n/4).toFixed(4));r.push({id:e,data:{droppableContainer:a,value:s}})}}return r.sort(dg)})({...e,droppableContainers:t}),r=fg(o.length>0?o:vg({...e,droppableContainers:t}),"id");if(!r)return[];At(wb(r),`Expected column id. Got: ${r}`);const a=n.get(r);if(At(a,`Expected column. Got: ${r}`),a&&0===a.topLevelIds.length)return[{id:r}];const s=new Set(a.topLevelIds),i=pg({...e,droppableContainers:e.droppableContainers.filter((e=>e.id!==r&&s.has(e.id)))});if(i.length>0){const e=i[0].id;return At(bb(e),`Expected cell id. Got: ${e}`),[{id:e}]}return[]}),[l,n]),y=R((({active:e,over:t})=>{const n=null==t?void 0:t.id;if(null!=n&&e.id!==n){if(bb(e.id)){if(wb(n))return void a({cellId:e.id,columnId:n});if(bb(n))return void o({cellId:e.id,overCellId:n})}wb(e.id)&&wb(n)&&s({column:e.id,overColumn:n})}})),b=R((e=>{const{active:t,over:n}=e;null!==n&&t.id!==n.id&&i()}));return m.jsx(Bv,{autoScroll:xb,sensors:p,collisionDetection:t?x:pg,modifiers:f,onDragEnd:b,onDragStart:g,onDragCancel:v,onDragOver:y,children:e})}));function bb(e){return"string"==typeof e&&!e.startsWith("tree_")}function wb(e){return"string"==typeof e&&e.startsWith("tree_")}const kb=u.forwardRef((({columnId:e,canDelete:t,canMoveLeft:n,canMoveRight:o,...r},a)=>{const{attributes:s,listeners:i,setNodeRef:l,transform:c,transition:d,isDragging:u,isOver:h}=lx({id:e}),f={transform:c?Yi.Transform.toString({x:c.x,y:0,scaleX:1,scaleY:1}):void 0,transition:d,zIndex:u?2:void 0,position:"relative","--gutter-width":"50px"},g=Kp(a,l),{deleteColumn:v,moveColumn:x,addColumn:y}=L(),w=$t("h-full hover:bg-muted rounded-none"),k=()=>{const e=document.getElementById("App");e&&e.scrollTo({left:e.scrollLeft+1e3,behavior:"smooth"})},N=m.jsxs("div",{className:"h-6 group flex items-center rounded-t-lg border hover:border-border border-[var(--slate-3)] overflow-hidden bg-[var(--slate-1)]",children:[m.jsx(p,{content:"Move column left",side:"top",delayDuration:300,children:m.jsx(b,{variant:"text",size:"sm",className:w,onClick:()=>x({column:e,overColumn:"_left_"}),disabled:!n,children:m.jsx(Hr,{className:"size-4"})})}),m.jsx(p,{content:"Move column right",side:"top",delayDuration:300,children:m.jsx(b,{variant:"text",size:"sm",className:w,onClick:()=>x({column:e,overColumn:"_right_"}),disabled:!o,children:m.jsx(gr,{className:"size-4"})})}),m.jsx("div",{className:"flex gap-2 h-full flex-grow active:bg-accent cursor-grab",...s,...i,"data-testid":"column-drag-button"}),t&&m.jsx(p,{content:"Delete column",side:"top",delayDuration:300,children:m.jsx(b,{variant:"text",size:"sm",className:"opacity-0 group-hover:opacity-70 group-hover:hover:opacity-100 text-destructive h-full hover:bg-destructive/20 rounded-none",onClick:()=>v({columnId:e}),children:m.jsx(Bt,{className:"size-4"})})}),m.jsx(p,{content:"Add column",side:"top",delayDuration:300,children:m.jsx(b,{variant:"text",size:"sm",className:w,onClick:()=>{y({columnId:e}),requestAnimationFrame(k)},children:m.jsx(No,{className:"size-4"})})})]});return m.jsxs("div",{tabIndex:-1,ref:g,...r,style:f,"data-is-dragging":u,className:$t(u?"":r.className,u?"z-20":"z-1 hover:z-10 focus-within:z-10",h&&"bg-accent/20"),children:[N,r.children]})}));kb.displayName="SortableColumn";const Nb=r.memo(kb),Eb=r.memo((e=>{const t=r.useRef(null),n=m.jsx("div",{className:$t("flex flex-col gap-5","columns"===e.width&&"w-contentWidthMedium min-h-[100px] border border-t-0 border-[var(--slate-3)] rounded-b-lg px-11 py-6 bg-[var(--slate-2)]"),children:e.children});return"columns"===e.width?m.jsxs(Nb,{tabIndex:-1,ref:t,canDelete:e.canDelete,columnId:e.columnId,canMoveLeft:e.canMoveLeft,canMoveRight:e.canMoveRight,className:"group/column",children:[n,e.footer]}):m.jsxs(m.Fragment,{children:[n,e.footer]})}));Eb.displayName="Column";const Cb=({notebook:e,mode:t,userConfig:n,appConfig:o,connStatus:a})=>{const s=L(),{theme:i}=we(),{toggleSidebarPanel:l}=wd(),{invisible:c}=nl(e.cellIds.idLength,t);Os("global.focusTop",s.focusTopCell),Os("global.focusBottom",s.focusBottomCell),Os("global.toggleSidebar",l),Os("global.foldCode",s.foldAll),Os("global.unfoldCode",s.unfoldAll),Os("global.formatAll",(()=>{Wr(s.updateCellCode)})),Os("cell.hideCode",Gt.NOOP),Os("cell.format",Gt.NOOP);const d=ed(),u=s.scrollToTarget;r.useEffect((()=>{null!==e.scrollKey&&u()}),[e.cellIds,e.scrollKey,u]);const h=e.cellIds.getColumns(),f=e.cellIds.hasOnlyOneId();return m.jsxs(ol,{className:"pb-[40vh]",invisible:c,appConfig:o,innerClassName:"pr-4",children:[m.jsx(hb,{}),m.jsx(cb,{width:o.width}),m.jsx(yb,{multiColumn:"columns"===o.width,children:m.jsx(tx,{id:"column-container",items:h.map((e=>e.id)),strategy:Jv,children:m.jsx("div",{className:$t("columns"===o.width&&"grid grid-flow-col auto-cols-min gap-6"),children:h.map(((r,l)=>m.jsx(Eb,{columnId:r.id,canMoveLeft:l>0,canMoveRight:l<h.length-1,width:o.width,canDelete:h.length>1,footer:m.jsx(jb,{columnId:r.id,className:$t("columns"===o.width&&"opacity-0 group-hover/column:opacity-100")}),children:m.jsx(tx,{id:`column-${l+1}`,items:r.topLevelIds,strategy:Zv,children:r.topLevelIds.map((l=>{const u=e.cellData[l],h=e.cellRuntime[l];return m.jsx(lb,{theme:i,showPlaceholder:f,allowFocus:!c&&!e.scrollKey,id:u.id,code:u.code,outline:h.outline,output:h.output,consoleOutputs:h.consoleOutputs,status:h.status,edited:u.edited,interrupted:h.interrupted,errored:h.errored,stopped:h.stopped,staleInputs:h.staleInputs,runStartTimestamp:h.runStartTimestamp,runElapsedTimeMs:h.runElapsedTimeMs??u.lastExecutionTime,serializedEditorState:u.serializedEditorState,showDeleteButton:!f&&!u.config.hide_code,mode:t,appClosed:a.state!==wi.OPEN,ref:e.cellHandles[l],userConfig:n,debuggerActive:h.debuggerActive,config:u.config,name:u.name,isCollapsed:r.isCollapsed(l),collapseCount:r.getCount(l),canMoveX:"columns"===o.width,...s,deleteCell:d},u.id.toString())}))})},r.id)))})})}),m.jsx(rl,{})]})},jb=({columnId:e,className:t})=>{const{createNewCell:n}=L(),o=X(ee),[r,a]=qr(!1),s=X(Q),i=X(Yr).sql,l=$t("mb-0 rounded-none sm:px-4 md:px-5 lg:px-8 tracking-wide no-wrap whitespace-nowrap","hover:bg-accent hover:text-accent-foreground font-semibold uppercase text-xs");return m.jsx("div",{className:"flex justify-center mt-4 pt-6 pb-32 group gap-4 w-full print:hidden",children:m.jsx("div",{className:$t("shadow-sm border border-border rounded transition-all duration-200 overflow-hidden divide-x divide-border flex",!r&&"w-fit",r&&"opacity-100 w-full max-w-4xl shadow-lg shadow-[var(--blue-3)]",t),children:r?m.jsx(Yy,{onClose:a.toggle}):m.jsxs(m.Fragment,{children:[m.jsxs(b,{className:l,variant:"text",size:"sm",onClick:()=>n({cellId:{type:"__end__",columnId:e},before:!1}),children:[m.jsx(wc,{className:"mr-2 size-4 flex-shrink-0"}),"Python"]}),m.jsxs(b,{className:l,variant:"text",size:"sm",onClick:()=>{nd(o,n),n({cellId:{type:"__end__",columnId:e},before:!1,code:(new Eo).defaultCode})},children:[m.jsx(Ec,{className:"mr-2 size-4 flex-shrink-0"}),"Markdown"]}),m.jsx(p,{content:i?null:m.jsxs("div",{className:"flex flex-col",children:[m.jsxs("span",{children:["Additional dependencies required:",m.jsx(ai,{className:"inline",children:"pip install marimo[sql]"}),"."]}),m.jsx("span",{children:"You will need to restart the notebook after installing."})]}),delayDuration:100,asChild:!1,children:m.jsxs(b,{className:l,variant:"text",size:"sm",disabled:!i,onClick:()=>{nd(o,n),n({cellId:{type:"__end__",columnId:e},before:!1,code:(new Co).defaultCode})},children:[m.jsx(de,{className:"mr-2 size-4 flex-shrink-0"}),"SQL"]})}),m.jsx(p,{content:s?null:m.jsx("span",{children:"Enable via settings under AI Assist"}),delayDuration:100,asChild:!1,children:m.jsxs(b,{className:l,variant:"text",size:"sm",disabled:!s,onClick:a.toggle,children:[m.jsx(bc,{className:"mr-2 size-4 flex-shrink-0"}),"Generate with AI"]})})]})})})};const Sb=({userConfig:e,appConfig:t})=>{const n=P();Zr(ha,ua.onCellIdsChange);const{setCells:o,updateCellCode:a,mergeAllColumns:s}=L(),i=X(Ze),[l,c]=rt(),[d,u]=r.useState(),h=mi(),{openModal:p,closeModal:g,openAlert:v}=f(),x="edit"===i.mode,y="present"===i.mode,b=X(Qr),w=X(ne);function k(){v("Failed to save notebook: not connected to a kernel.")}r.useEffect((()=>(al.INSTANCE.start(ea),()=>{al.INSTANCE.stop()})),[]);const{connection:N}=sl({autoInstantiate:e.runtime.auto_instantiate,setCells:(e,t)=>{o(e);const n=e.map((e=>e.name)),r=e.map((e=>e.code)),a=e.map((e=>e.config));u({names:n,codes:r,configs:a,layout:t})},sessionId:ta()}),E=R((async e=>N.state!==wi.OPEN?(k(),null):(na((t=>{null===e?t.delete(oa.filePath):t.set(oa.filePath,e)})),ra({filename:e}).then((()=>(c(e),document.title=t.app_title||nt.basename(e)||"Untitled Notebook",e))).catch((e=>(v(e.message),null))))));r.useEffect((()=>{document.title=t.app_title||nt.basename(l??"")||"Untitled Notebook"}),[t.app_title,l]);const C=n.cellIds.colLength,j=Ri(t.width);r.useEffect((()=>{"columns"===j&&"columns"!==t.width&&s()}),[t.width,j,s,C]);const S=aa(n),I=S.map((e=>e.id)),A=S.map((e=>e.code)),M=S.map((e=>e.name)),T=sa(n),O=ia(n,h,d),D=R(((t,n)=>{w||0!==A.length&&(N.state===wi.OPEN?(U.log("saving to ",t),la({cellIds:I,codes:A,names:M,filename:t,configs:T,layout:il(),persist:!0}).then((()=>{n&&(q({title:"Notebook saved"}),e.save.format_on_save&&Wr(a)),u({names:M,codes:A,configs:T,layout:h})}))):k())})),_=R(((e=!1)=>{null!==l&&N.state===wi.OPEN&&D(l,e)})),z=R((()=>{_(!0),null===l&&N.state!==wi.CLOSED&&p(m.jsx(Ib,{onClose:g,onSave:B}))}));!function(e){const{codes:t,cellConfigs:n,config:o,connStatus:a,cellNames:s,needsSave:i,kioskMode:l,onSave:c}=e,d=r.useRef(null);r.useEffect((()=>{if(!l)return"after_delay"===o.save.autosave&&(null!==d.current&&clearTimeout(d.current),i&&a.state===wi.OPEN&&(d.current=setTimeout(c,o.save.autosave_delay))),()=>{null!==d.current&&clearTimeout(d.current)}}),[t,n,s,o.save,a.state,c,l,i])}({onSave:_,needsSave:O,codes:A,cellConfigs:T,cellNames:M,connStatus:N,config:e,kioskMode:w}),function(){const e=X(Jr),{state:t}=X(bi),n=e.auto_download.includes("markdown"),o=e.auto_download.includes("html"),r=!n||t!==wi.OPEN,a=!o||t!==wi.OPEN;si((async()=>{await Kr({download:!1})}),{delayMs:5e3,whenVisible:!0,disabled:r}),si((async()=>{await Xr({download:!1,includeCode:!0,files:yi.INSTANCE.filenames()})}),{delayMs:5e3,whenVisible:!0,disabled:a})}(),$(window,"beforeunload",(e=>{if(!ca())return O?(e.preventDefault(),e.returnValue="You have unsaved changes. Are you sure you want to quit?"):void 0}));const B=e=>{E(e).then((e=>{null!==e&&D(e,!0)}))},V=function(){const e=P(),t=Kc();return R((()=>t(F(e))))}(),G=Nd();Os("global.runStale",(()=>{V()})),Os("global.save",z),Os("global.interrupt",(()=>{yr()})),Os("global.hideCode",(()=>{G()}));const H=R((()=>JSON.stringify({filename:l,cells:S.map((e=>({name:e.name,code:e.code})))},null,2))),W=m.jsx(Cb,{notebook:n,connStatus:N,mode:i.mode,userConfig:e,appConfig:t});return m.jsxs(m.Fragment,{children:[m.jsxs(ll,{connectionState:N.state,isRunning:b,width:t.width,children:[m.jsx(cl,{connection:N,className:$t("pt-4 sm:pt-12 pb-2 mb-4 print:hidden z-50","sticky left-0"),children:x&&m.jsx("div",{className:"flex items-center justify-center container",children:m.jsx(nu,{filename:l,setFilename:E})})}),S.length>0&&m.jsx(dl,{appConfig:t,mode:i.mode,children:W})]}),m.jsx(Kd,{filename:l,needsSave:O,onSaveNotebook:z,getCellsAsJSON:H,presenting:y,onTogglePresenting:G,onInterrupt:yr,onRun:V,closed:N.state===wi.CLOSED,running:b,needsRun:da(n),undoAvailable:gt(n),appWidth:t.width})]})},Ib=e=>{const{onClose:t,onSave:n}=e,[o,a]=r.useState();return m.jsxs(g,{children:[m.jsx(v,{children:"Save notebook"}),m.jsxs("div",{className:"flex flex-col",children:[m.jsx(ae,{className:"text-md pt-6 px-1",children:"Save as"}),m.jsx(tu,{onNameChange:e=>{a(e),e.trim()&&(n(e),t())},placeholderText:"filename",className:"missing-filename"})]}),m.jsxs(y,{children:[m.jsx(b,{"data-testid":"cancel-save-dialog-button","aria-label":"Cancel",variant:"secondary",onClick:t,children:"Cancel"}),m.jsx(b,{"data-testid":"submit-save-dialog-button","aria-label":"Save",variant:"default",disabled:!o,type:"submit",children:"Save"})]})]})},{createElement:Ab,createContext:Mb,createRef:Tb,forwardRef:Ob,useCallback:Db,useContext:_b,useEffect:Pb,useImperativeHandle:Rb,useLayoutEffect:Fb,useMemo:Lb,useRef:zb,useState:Bb}=fa,Ub=fa["useId".toString()],Vb=Fb,$b=Mb(null);$b.displayName="PanelGroupContext";const Gb=Vb,Hb="function"==typeof Ub?Ub:()=>null;let Wb=0;function qb(e=null){const t=Hb(),n=zb(e||t||null);return null===n.current&&(n.current=""+Wb++),null!=e?e:n.current}function Yb({children:e,className:t="",collapsedSize:n,collapsible:o,defaultSize:r,forwardedRef:a,id:s,maxSize:i,minSize:l,onCollapse:c,onExpand:d,onResize:u,order:h,style:f,tagName:m="div",...p}){const g=_b($b);if(null===g)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:v,expandPanel:x,getPanelSize:y,getPanelStyle:b,groupId:w,isPanelCollapsed:k,reevaluatePanelConstraints:N,registerPanel:E,resizePanel:C,unregisterPanel:j}=g,S=qb(s),I=zb({callbacks:{onCollapse:c,onExpand:d,onResize:u},constraints:{collapsedSize:n,collapsible:o,defaultSize:r,maxSize:i,minSize:l},id:S,idIsFromProps:void 0!==s,order:h});zb({didLogMissingDefaultSizeWarning:!1}),Gb((()=>{const{callbacks:e,constraints:t}=I.current,a={...t};I.current.id=S,I.current.idIsFromProps=void 0!==s,I.current.order=h,e.onCollapse=c,e.onExpand=d,e.onResize=u,t.collapsedSize=n,t.collapsible=o,t.defaultSize=r,t.maxSize=i,t.minSize=l,a.collapsedSize===t.collapsedSize&&a.collapsible===t.collapsible&&a.maxSize===t.maxSize&&a.minSize===t.minSize||N(I.current,a)})),Gb((()=>{const e=I.current;return E(e),()=>{j(e)}}),[h,S,E,j]),Rb(a,(()=>({collapse:()=>{v(I.current)},expand:e=>{x(I.current,e)},getId:()=>S,getSize:()=>y(I.current),isCollapsed:()=>k(I.current),isExpanded:()=>!k(I.current),resize:e=>{C(I.current,e)}})),[v,x,y,k,S,C]);const A=b(I.current,r);return Ab(m,{...p,children:e,className:t,id:s,style:{...A,...f},"data-panel":"","data-panel-collapsible":o||void 0,"data-panel-group-id":w,"data-panel-id":S,"data-panel-size":parseFloat(""+A.flexGrow).toFixed(1)})}const Jb=Ob(((e,t)=>Ab(Yb,{...e,forwardedRef:t})));Yb.displayName="Panel",Jb.displayName="forwardRef(Panel)";let Kb=null,Xb=null;function Zb(e,t){const n=function(e,t){if(t){const e=!!(t&uw),n=!!(t&hw);if(t&cw)return e?"se-resize":n?"ne-resize":"e-resize";if(t&dw)return e?"sw-resize":n?"nw-resize":"w-resize";if(e)return"s-resize";if(n)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}(e,t);Kb!==n&&(Kb=n,null===Xb&&(Xb=document.createElement("style"),document.head.appendChild(Xb)),Xb.innerHTML=`*{cursor: ${n}!important;}`)}function Qb(e){return"keydown"===e.type}function ew(e){return e.type.startsWith("pointer")}function tw(e){return e.type.startsWith("mouse")}function nw(e){if(ew(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(tw(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}const ow=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function rw(e){const t=getComputedStyle(e);return"fixed"===t.position||(!("auto"===t.zIndex||"static"===t.position&&!function(e){var t;const n=getComputedStyle(null!==(t=lw(e))&&void 0!==t?t:e).display;return"flex"===n||"inline-flex"===n}(e))||(+t.opacity<1||("transform"in t&&"none"!==t.transform||("webkitTransform"in t&&"none"!==t.webkitTransform||("mixBlendMode"in t&&"normal"!==t.mixBlendMode||("filter"in t&&"none"!==t.filter||("webkitFilter"in t&&"none"!==t.webkitFilter||("isolation"in t&&"isolate"===t.isolation||(!!ow.test(t.willChange)||"touch"===t.webkitOverflowScrolling)))))))))}function aw(e){let t=e.length;for(;t--;){const n=e[t];if(Sw(n,"Missing node"),rw(n))return n}return null}function sw(e){return e&&Number(getComputedStyle(e).zIndex)||0}function iw(e){const t=[];for(;e;)t.push(e),e=lw(e);return t}function lw(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const cw=1,dw=2,uw=4,hw=8,fw="coarse"===function(){if("function"==typeof matchMedia)return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}();let mw=[],pw=!1,gw=new Map,vw=new Map;const xw=new Set;function yw(e){const{target:t}=e,{x:n,y:o}=nw(e);pw=!0,kw({target:t,x:n,y:o}),Cw(),mw.length>0&&(jw("down",e),e.preventDefault(),e.stopPropagation())}function bw(e){const{x:t,y:n}=nw(e);if(!pw){const{target:o}=e;kw({target:o,x:t,y:n})}jw("move",e),Ew(),mw.length>0&&e.preventDefault()}function ww(e){const{target:t}=e,{x:n,y:o}=nw(e);vw.clear(),pw=!1,mw.length>0&&e.preventDefault(),jw("up",e),kw({target:t,x:n,y:o}),Ew(),Cw()}function kw({target:e,x:t,y:n}){mw.splice(0);let o=null;e instanceof HTMLElement&&(o=e),xw.forEach((e=>{const{element:r,hitAreaMargins:a}=e,s=r.getBoundingClientRect(),{bottom:i,left:l,right:c,top:d}=s,u=fw?a.coarse:a.fine;if(t>=l-u&&t<=c+u&&n>=d-u&&n<=i+u){if(null!==o&&r!==o&&!r.contains(o)&&!o.contains(r)&&function(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:iw(e),b:iw(t)};let o;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),o=e;Sw(o,"Stacking order can only be calculated for elements with a common ancestor");const r=sw(aw(n.a)),a=sw(aw(n.b));if(r===a){const e=o.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)};let r=e.length;for(;r--;){const n=e[r];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(r-a)}(o,r)>0){let e=o,t=!1;for(;e&&!e.contains(r);){if(h=e.getBoundingClientRect(),f=s,h.x<f.x+f.width&&h.x+h.width>f.x&&h.y<f.y+f.height&&h.y+h.height>f.y){t=!0;break}e=e.parentElement}if(t)return}mw.push(e)}var h,f}))}function Nw(e,t){vw.set(e,t)}function Ew(){let e=!1,t=!1;mw.forEach((n=>{const{direction:o}=n;"horizontal"===o?e=!0:t=!0}));let n=0;vw.forEach((e=>{n|=e})),e&&t?Zb("intersection",n):e?Zb("horizontal",n):t?Zb("vertical",n):null!==Xb&&(document.head.removeChild(Xb),Kb=null,Xb=null)}function Cw(){gw.forEach(((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",ww),n.removeEventListener("pointerdown",yw),n.removeEventListener("pointerleave",bw),n.removeEventListener("pointermove",bw)})),window.removeEventListener("pointerup",ww),window.removeEventListener("pointercancel",ww),xw.size>0&&(pw?(mw.length>0&&gw.forEach(((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",ww),n.addEventListener("pointerleave",bw),n.addEventListener("pointermove",bw))})),window.addEventListener("pointerup",ww),window.addEventListener("pointercancel",ww)):gw.forEach(((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",yw,{capture:!0}),n.addEventListener("pointermove",bw))})))}function jw(e,t){xw.forEach((n=>{const{setResizeHandlerState:o}=n,r=mw.includes(n);o(e,r,t)}))}function Sw(e,t){if(!e)throw console.error(t),Error(t)}function Iw(e,t,n=10){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Aw(e,t,n=10){return 0===Iw(e,t,n)}function Mw(e,t,n){return 0===Iw(e,t,n)}function Tw({panelConstraints:e,panelIndex:t,size:n}){const o=e[t];Sw(null!=o,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:a,maxSize:s=100,minSize:i=0}=o;if(Iw(n,i)<0)if(a){n=Iw(n,(r+i)/2)<0?r:i}else n=i;return n=Math.min(s,n),n=parseFloat(n.toFixed(10))}function Ow({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:o,prevLayout:r,trigger:a}){if(Mw(e,0))return t;const s=[...t],[i,l]=o;Sw(null!=i,"Invalid first pivot index"),Sw(null!=l,"Invalid second pivot index");let c=0;if("keyboard"===a){{const o=e<0?l:i,r=n[o];Sw(r,`Panel constraints not found for index ${o}`);const{collapsedSize:a=0,collapsible:s,minSize:c=0}=r;if(s){const n=t[o];if(Sw(null!=n,`Previous layout not found for panel index ${o}`),Mw(n,a)){const t=c-n;Iw(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{const o=e<0?i:l,r=n[o];Sw(r,`No panel constraints found for index ${o}`);const{collapsedSize:a=0,collapsible:s,minSize:c=0}=r;if(s){const n=t[o];if(Sw(null!=n,`Previous layout not found for panel index ${o}`),Mw(n,c)){const t=n-a;Iw(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}}{const o=e<0?1:-1;let r=e<0?l:i,a=0;for(;;){const e=t[r];Sw(null!=e,`Previous layout not found for panel index ${r}`);if(a+=Tw({panelConstraints:n,panelIndex:r,size:100})-e,r+=o,r<0||r>=n.length)break}const s=Math.min(Math.abs(e),Math.abs(a));e=e<0?0-s:s}{let o=e<0?i:l;for(;o>=0&&o<n.length;){const r=Math.abs(e)-Math.abs(c),a=t[o];Sw(null!=a,`Previous layout not found for panel index ${o}`);const i=Tw({panelConstraints:n,panelIndex:o,size:a-r});if(!Mw(a,i)&&(c+=a-i,s[o]=i,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?o--:o++}}if(function(e,t,n){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(!Mw(e[o],t[o],n))return!1;return!0}(r,s))return r;{const o=e<0?l:i,r=t[o];Sw(null!=r,`Previous layout not found for panel index ${o}`);const a=r+c,d=Tw({panelConstraints:n,panelIndex:o,size:a});if(s[o]=d,!Mw(d,a)){let t=a-d;let o=e<0?l:i;for(;o>=0&&o<n.length;){const r=s[o];Sw(null!=r,`Previous layout not found for panel index ${o}`);const a=Tw({panelConstraints:n,panelIndex:o,size:r+t});if(Mw(r,a)||(t-=a-r,s[o]=a),Mw(t,0))break;e>0?o--:o++}}}return Mw(s.reduce(((e,t)=>t+e),0),100)?s:r}function Dw({layout:e,panelsArray:t,pivotIndices:n}){let o=0,r=100,a=0,s=0;const i=n[0];Sw(null!=i,"No pivot index found"),t.forEach(((e,t)=>{const{constraints:n}=e,{maxSize:l=100,minSize:c=0}=n;t===i?(o=c,r=l):(a+=c,s+=l)}));return{valueMax:Math.min(r,100-a),valueMin:Math.max(o,100-s),valueNow:e[i]}}function _w(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function Pw(e,t,n=document){const o=_w(e,n).findIndex((e=>e.getAttribute("data-panel-resize-handle-id")===t));return null!=o?o:null}function Rw(e,t,n){const o=Pw(e,t,n);return null!=o?[o,o+1]:[-1,-1]}function Fw(e,t=document){var n;if(t instanceof HTMLElement&&(null==t||null===(n=t.dataset)||void 0===n?void 0:n.panelGroupId)==e)return t;const o=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return o||null}function Lw(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function zw({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:o,panelDataArray:r,panelGroupElement:a,setLayout:s}){zb({didWarnAboutMissingResizeHandle:!1}),Gb((()=>{if(!a)return;const e=_w(n,a);for(let t=0;t<r.length-1;t++){const{valueMax:n,valueMin:a,valueNow:s}=Dw({layout:o,panelsArray:r,pivotIndices:[t,t+1]}),i=e[t];if(null==i);else{const e=r[t];Sw(e,`No panel data found for index "${t}"`),i.setAttribute("aria-controls",e.id),i.setAttribute("aria-valuemax",""+Math.round(n)),i.setAttribute("aria-valuemin",""+Math.round(a)),i.setAttribute("aria-valuenow",null!=s?""+Math.round(s):"")}}return()=>{e.forEach(((e,t)=>{e.removeAttribute("aria-controls"),e.removeAttribute("aria-valuemax"),e.removeAttribute("aria-valuemin"),e.removeAttribute("aria-valuenow")}))}}),[n,o,r,a]),Pb((()=>{if(!a)return;const e=t.current;Sw(e,"Eager values not found");const{panelDataArray:r}=e;Sw(null!=Fw(n,a),`No group found for id "${n}"`);const i=_w(n,a);Sw(i,`No resize handles found for group id "${n}"`);const l=i.map((e=>{const t=e.getAttribute("data-panel-resize-handle-id");Sw(t,"Resize handle element has no handle id attribute");const[i,l]=function(e,t,n,o=document){var r,a,s,i;const l=Lw(t,o),c=_w(e,o),d=l?c.indexOf(l):-1;return[null!==(r=null===(a=n[d])||void 0===a?void 0:a.id)&&void 0!==r?r:null,null!==(s=null===(i=n[d+1])||void 0===i?void 0:i.id)&&void 0!==s?s:null]}(n,t,r,a);if(null==i||null==l)return()=>{};const c=e=>{if(!e.defaultPrevented)switch(e.key){case"Enter":{e.preventDefault();const l=r.findIndex((e=>e.id===i));if(l>=0){const e=r[l];Sw(e,`No panel data found for index ${l}`);const i=o[l],{collapsedSize:c=0,collapsible:d,minSize:u=0}=e.constraints;if(null!=i&&d){const e=Ow({delta:Mw(i,c)?u-c:c-i,initialLayout:o,panelConstraints:r.map((e=>e.constraints)),pivotIndices:Rw(n,t,a),prevLayout:o,trigger:"keyboard"});o!==e&&s(e)}}break}}};return e.addEventListener("keydown",c),()=>{e.removeEventListener("keydown",c)}}));return()=>{l.forEach((e=>e()))}}),[a,e,t,n,o,r,s])}function Bw(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Uw(e,t){const n="horizontal"===e,{x:o,y:r}=nw(t);return n?o:r}function Vw(e,t,n,o,r,a){if(Qb(e)){const t="horizontal"===n;let o=0;o=e.shiftKey?100:null!=r?r:10;let a=0;switch(e.key){case"ArrowDown":a=t?0:o;break;case"ArrowLeft":a=t?-o:0;break;case"ArrowRight":a=t?o:0;break;case"ArrowUp":a=t?0:-o;break;case"End":a=100;break;case"Home":a=-100}return a}return null==o?0:function(e,t,n,o,r){const a="horizontal"===n,s=Lw(t,r);Sw(s,`No resize handle element found for id "${t}"`);const i=s.getAttribute("data-panel-group-id");Sw(i,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=o;const c=Uw(n,e),d=Fw(i,r);Sw(d,`No group element found for id "${i}"`);const u=d.getBoundingClientRect();return(c-l)/(a?u.width:u.height)*100}(e,t,n,o,a)}function $w(e,t,n){t.forEach(((t,o)=>{const r=e[o];Sw(r,`Panel data not found for index ${o}`);const{callbacks:a,constraints:s,id:i}=r,{collapsedSize:l=0,collapsible:c}=s,d=n[i];if(null==d||t!==d){n[i]=t;const{onCollapse:e,onExpand:o,onResize:r}=a;r&&r(t,d),c&&(e||o)&&(!o||null!=d&&!Aw(d,l)||Aw(t,l)||o(),!e||null!=d&&Aw(d,l)||!Aw(t,l)||e())}}))}function Gw(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Hw(e){try{if("undefined"==typeof localStorage)throw new Error("localStorage not supported in this environment");e.getItem=e=>localStorage.getItem(e),e.setItem=(e,t)=>{localStorage.setItem(e,t)}}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function Ww(e){return`react-resizable-panels:${e}`}function qw(e){return e.map((e=>{const{constraints:t,id:n,idIsFromProps:o,order:r}=e;return o?n:r?`${r}:${JSON.stringify(t)}`:JSON.stringify(t)})).sort(((e,t)=>e.localeCompare(t))).join(",")}function Yw(e,t){try{const n=Ww(e),o=t.getItem(n);if(o){const e=JSON.parse(o);if("object"==typeof e&&null!=e)return e}}catch(n){}return null}function Jw(e,t,n,o,r){var a;const s=Ww(e),i=qw(t),l=null!==(a=Yw(e,r))&&void 0!==a?a:{};l[i]={expandToSizes:Object.fromEntries(n.entries()),layout:o};try{r.setItem(s,JSON.stringify(l))}catch(c){console.error(c)}}function Kw({layout:e,panelConstraints:t}){const n=[...e],o=n.reduce(((e,t)=>e+t),0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map((e=>`${e}%`)).join(", ")}`);if(!Mw(o,100))for(let a=0;a<t.length;a++){const e=n[a];Sw(null!=e,`No layout data found for index ${a}`);const t=100/o*e;n[a]=t}let r=0;for(let a=0;a<t.length;a++){const e=n[a];Sw(null!=e,`No layout data found for index ${a}`);const o=Tw({panelConstraints:t,panelIndex:a,size:e});e!=o&&(r+=e-o,n[a]=o)}if(!Mw(r,0))for(let a=0;a<t.length;a++){const e=n[a];Sw(null!=e,`No layout data found for index ${a}`);const o=Tw({panelConstraints:t,panelIndex:a,size:e+r});if(e!==o&&(r-=o-e,n[a]=o,Mw(r,0)))break}return n}const Xw={getItem:e=>(Hw(Xw),Xw.getItem(e)),setItem:(e,t)=>{Hw(Xw),Xw.setItem(e,t)}},Zw={};function Qw({autoSaveId:e=null,children:t,className:n="",direction:o,forwardedRef:r,id:a=null,onLayout:s=null,keyboardResizeBy:i=null,storage:l=Xw,style:c,tagName:d="div",...u}){const h=qb(a),f=zb(null),[m,p]=Bb(null),[g,v]=Bb([]),x=zb({}),y=zb(new Map),b=zb(0),w=zb({autoSaveId:e,direction:o,dragState:m,id:h,keyboardResizeBy:i,onLayout:s,storage:l}),k=zb({layout:g,panelDataArray:[],panelDataArrayChanged:!1});zb({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),Rb(r,(()=>({getId:()=>w.current.id,getLayout:()=>{const{layout:e}=k.current;return e},setLayout:e=>{const{onLayout:t}=w.current,{layout:n,panelDataArray:o}=k.current,r=Kw({layout:e,panelConstraints:o.map((e=>e.constraints))});Bw(n,r)||(v(r),k.current.layout=r,t&&t(r),$w(o,r,x.current))}})),[]),Gb((()=>{w.current.autoSaveId=e,w.current.direction=o,w.current.dragState=m,w.current.id=h,w.current.onLayout=s,w.current.storage=l})),zw({committedValuesRef:w,eagerValuesRef:k,groupId:h,layout:g,panelDataArray:k.current.panelDataArray,setLayout:v,panelGroupElement:f.current}),Pb((()=>{const{panelDataArray:t}=k.current;if(e){if(0===g.length||g.length!==t.length)return;let n=Zw[e];null==n&&(n=function(e,t=10){let n=null;return(...o)=>{null!==n&&clearTimeout(n),n=setTimeout((()=>{e(...o)}),t)}}(Jw,100),Zw[e]=n);const o=[...t],r=new Map(y.current);n(e,o,r,g,l)}}),[e,g,l]),Pb((()=>{}));const N=Db((e=>{const{onLayout:t}=w.current,{layout:n,panelDataArray:o}=k.current;if(e.constraints.collapsible){const r=o.map((e=>e.constraints)),{collapsedSize:a=0,panelSize:s,pivotIndices:i}=nk(o,e,n);if(Sw(null!=s,`Panel size not found for panel "${e.id}"`),!Aw(s,a)){y.current.set(e.id,s);const l=Ow({delta:tk(o,e)===o.length-1?s-a:a-s,initialLayout:n,panelConstraints:r,pivotIndices:i,prevLayout:n,trigger:"imperative-api"});Gw(n,l)||(v(l),k.current.layout=l,t&&t(l),$w(o,l,x.current))}}}),[]),E=Db(((e,t)=>{const{onLayout:n}=w.current,{layout:o,panelDataArray:r}=k.current;if(e.constraints.collapsible){const a=r.map((e=>e.constraints)),{collapsedSize:s=0,panelSize:i=0,minSize:l=0,pivotIndices:c}=nk(r,e,o),d=null!=t?t:l;if(Aw(i,s)){const t=y.current.get(e.id),s=null!=t&&t>=d?t:d,l=Ow({delta:tk(r,e)===r.length-1?i-s:s-i,initialLayout:o,panelConstraints:a,pivotIndices:c,prevLayout:o,trigger:"imperative-api"});Gw(o,l)||(v(l),k.current.layout=l,n&&n(l),$w(r,l,x.current))}}}),[]),C=Db((e=>{const{layout:t,panelDataArray:n}=k.current,{panelSize:o}=nk(n,e,t);return Sw(null!=o,`Panel size not found for panel "${e.id}"`),o}),[]),j=Db(((e,t)=>{const{panelDataArray:n}=k.current,o=tk(n,e);return function({defaultSize:e,dragState:t,layout:n,panelData:o,panelIndex:r,precision:a=3}){const s=n[r];let i;return i=null==s?null!=e?e.toPrecision(a):"1":1===o.length?"1":s.toPrecision(a),{flexBasis:0,flexGrow:i,flexShrink:1,overflow:"hidden",pointerEvents:null!==t?"none":void 0}}({defaultSize:t,dragState:m,layout:g,panelData:n,panelIndex:o})}),[m,g]),S=Db((e=>{const{layout:t,panelDataArray:n}=k.current,{collapsedSize:o=0,collapsible:r,panelSize:a}=nk(n,e,t);return Sw(null!=a,`Panel size not found for panel "${e.id}"`),!0===r&&Aw(a,o)}),[]),I=Db((e=>{const{layout:t,panelDataArray:n}=k.current,{collapsedSize:o=0,collapsible:r,panelSize:a}=nk(n,e,t);return Sw(null!=a,`Panel size not found for panel "${e.id}"`),!r||Iw(a,o)>0}),[]),A=Db((e=>{const{panelDataArray:t}=k.current;t.push(e),t.sort(((e,t)=>{const n=e.order,o=t.order;return null==n&&null==o?0:null==n?-1:null==o?1:n-o})),k.current.panelDataArrayChanged=!0}),[]);Gb((()=>{if(k.current.panelDataArrayChanged){k.current.panelDataArrayChanged=!1;const{autoSaveId:e,onLayout:t,storage:n}=w.current,{layout:o,panelDataArray:r}=k.current;let a=null;if(e){const t=function(e,t,n){var o,r;return null!==(r=(null!==(o=Yw(e,n))&&void 0!==o?o:{})[qw(t)])&&void 0!==r?r:null}(e,r,n);t&&(y.current=new Map(Object.entries(t.expandToSizes)),a=t.layout)}null==a&&(a=function({panelDataArray:e}){const t=Array(e.length),n=e.map((e=>e.constraints));let o=0,r=100;for(let a=0;a<e.length;a++){const e=n[a];Sw(e,`Panel constraints not found for index ${a}`);const{defaultSize:s}=e;null!=s&&(o++,t[a]=s,r-=s)}for(let a=0;a<e.length;a++){const s=n[a];Sw(s,`Panel constraints not found for index ${a}`);const{defaultSize:i}=s;if(null!=i)continue;const l=r/(e.length-o);o++,t[a]=l,r-=l}return t}({panelDataArray:r}));const s=Kw({layout:a,panelConstraints:r.map((e=>e.constraints))});Bw(o,s)||(v(s),k.current.layout=s,t&&t(s),$w(r,s,x.current))}})),Gb((()=>{const e=k.current;return()=>{e.layout=[]}}),[]);const M=Db((e=>function(t){t.preventDefault();const n=f.current;if(!n)return()=>null;const{direction:o,dragState:r,id:a,keyboardResizeBy:s,onLayout:i}=w.current,{layout:l,panelDataArray:c}=k.current,{initialLayout:d}=null!=r?r:{},u=Rw(a,e,n);let h=Vw(t,e,o,r,s,n);if(0===h)return;const m="horizontal"===o;"rtl"===document.dir&&m&&(h=-h);const p=Ow({delta:h,initialLayout:null!=d?d:l,panelConstraints:c.map((e=>e.constraints)),pivotIndices:u,prevLayout:l,trigger:Qb(t)?"keyboard":"mouse-or-touch"}),g=!Gw(l,p);(ew(t)||tw(t))&&b.current!=h&&(b.current=h,Nw(e,g?0:m?h<0?cw:dw:h<0?uw:hw)),g&&(v(p),k.current.layout=p,i&&i(p),$w(c,p,x.current))}),[]),T=Db(((e,t)=>{const{onLayout:n}=w.current,{layout:o,panelDataArray:r}=k.current,a=r.map((e=>e.constraints)),{panelSize:s,pivotIndices:i}=nk(r,e,o);Sw(null!=s,`Panel size not found for panel "${e.id}"`);const l=Ow({delta:tk(r,e)===r.length-1?s-t:t-s,initialLayout:o,panelConstraints:a,pivotIndices:i,prevLayout:o,trigger:"imperative-api"});Gw(o,l)||(v(l),k.current.layout=l,n&&n(l),$w(r,l,x.current))}),[]),O=Db(((e,t)=>{const{layout:n,panelDataArray:o}=k.current,{collapsedSize:r=0,collapsible:a}=t,{collapsedSize:s=0,collapsible:i,maxSize:l=100,minSize:c=0}=e.constraints,{panelSize:d}=nk(o,e,n);null!=d&&(a&&i&&Aw(d,r)?Aw(r,s)||T(e,s):d<c?T(e,c):d>l&&T(e,l))}),[T]),D=Db(((e,t)=>{const{direction:n}=w.current,{layout:o}=k.current;if(!f.current)return;const r=Lw(e,f.current);Sw(r,`Drag handle element not found for id "${e}"`);const a=Uw(n,t);p({dragHandleId:e,dragHandleRect:r.getBoundingClientRect(),initialCursorPosition:a,initialLayout:o})}),[]),_=Db((()=>{p(null)}),[]),P=Db((e=>{const{panelDataArray:t}=k.current,n=tk(t,e);n>=0&&(t.splice(n,1),delete x.current[e.id],k.current.panelDataArrayChanged=!0)}),[]),R=Lb((()=>({collapsePanel:N,direction:o,dragState:m,expandPanel:E,getPanelSize:C,getPanelStyle:j,groupId:h,isPanelCollapsed:S,isPanelExpanded:I,reevaluatePanelConstraints:O,registerPanel:A,registerResizeHandle:M,resizePanel:T,startDragging:D,stopDragging:_,unregisterPanel:P,panelGroupElement:f.current})),[N,m,o,E,C,j,h,S,I,O,A,M,T,D,_,P]),F={display:"flex",flexDirection:"horizontal"===o?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return Ab($b.Provider,{value:R},Ab(d,{...u,children:t,className:n,id:a,ref:f,style:{...F,...c},"data-panel-group":"","data-panel-group-direction":o,"data-panel-group-id":h}))}const ek=Ob(((e,t)=>Ab(Qw,{...e,forwardedRef:t})));function tk(e,t){return e.findIndex((e=>e===t||e.id===t.id))}function nk(e,t,n){const o=tk(e,t),r=o===e.length-1?[o-1,o]:[o,o+1],a=n[o];return{...t.constraints,panelSize:a,pivotIndices:r}}function ok({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:o,id:r,onDragging:a,style:s={},tabIndex:i=0,tagName:l="div",...c}){var d,u;const h=zb(null),f=zb({onDragging:a});Pb((()=>{f.current.onDragging=a}));const m=_b($b);if(null===m)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:p,groupId:g,registerResizeHandle:v,startDragging:x,stopDragging:y,panelGroupElement:b}=m,w=qb(r),[k,N]=Bb("inactive"),[E,C]=Bb(!1),[j,S]=Bb(null),I=zb({state:k});Gb((()=>{I.current.state=k})),Pb((()=>{if(n)S(null);else{const e=v(w);S((()=>e))}}),[n,w,v]);const A=null!==(d=null==o?void 0:o.coarse)&&void 0!==d?d:15,M=null!==(u=null==o?void 0:o.fine)&&void 0!==u?u:5;Pb((()=>{if(n||null==j)return;const e=h.current;Sw(e,"Element ref not attached");return function(e,t,n,o,r){var a;const{ownerDocument:s}=t,i={direction:n,element:t,hitAreaMargins:o,setResizeHandlerState:r},l=null!==(a=gw.get(s))&&void 0!==a?a:0;return gw.set(s,l+1),xw.add(i),Cw(),function(){var t;vw.delete(e),xw.delete(i);const n=null!==(t=gw.get(s))&&void 0!==t?t:1;gw.set(s,n-1),Cw(),1===n&&gw.delete(s)}}(w,e,p,{coarse:A,fine:M},((e,t,n)=>{if(t)switch(e){case"down":{N("drag"),x(w,n);const{onDragging:e}=f.current;e&&e(!0);break}case"move":{const{state:e}=I.current;"drag"!==e&&N("hover"),j(n);break}case"up":{N("hover"),y();const{onDragging:e}=f.current;e&&e(!1);break}}else N("inactive")}))}),[A,p,n,M,v,w,j,x,y]),function({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:o}){Pb((()=>{if(e||null==n||null==o)return;const r=Lw(t,o);if(null==r)return;const a=e=>{if(!e.defaultPrevented)switch(e.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":e.preventDefault(),n(e);break;case"F6":{e.preventDefault();const n=r.getAttribute("data-panel-group-id");Sw(n,`No group element found for id "${n}"`);const a=_w(n,o),s=Pw(n,t,o);Sw(null!==s,`No resize element found for id "${t}"`),a[e.shiftKey?s>0?s-1:a.length-1:s+1<a.length?s+1:0].focus();break}}};return r.addEventListener("keydown",a),()=>{r.removeEventListener("keydown",a)}}),[o,e,t,n])}({disabled:n,handleId:w,resizeHandler:j,panelGroupElement:b});return Ab(l,{...c,children:e,className:t,id:r,onBlur:()=>C(!1),onFocus:()=>C(!0),ref:h,role:"separator",style:{touchAction:"none",userSelect:"none",...s},tabIndex:i,"data-panel-group-direction":p,"data-panel-group-id":g,"data-resize-handle":"","data-resize-handle-active":"drag"===k?"pointer":E?"keyboard":void 0,"data-resize-handle-state":k,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":w})}Qw.displayName="PanelGroup",ek.displayName="forwardRef(PanelGroup)",ok.displayName="PanelResizeHandle";const rk=e=>m.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1.24em",height:"1em",viewBox:"0 0 256 208",fill:"currentColor",...e,children:m.jsx("path",{d:"M205.28 31.36c14.096 14.88 20.016 35.2 22.512 63.68c6.626 0 12.805 1.47 16.976 7.152l7.792 10.56A17.55 17.55 0 0 1 256 123.2v28.688c-.008 3.704-1.843 7.315-4.832 9.504C215.885 187.222 172.35 208 128 208c-49.066 0-98.19-28.273-123.168-46.608c-2.989-2.189-4.825-5.8-4.832-9.504V123.2c0-3.776 1.2-7.424 3.424-10.464l7.792-10.544c4.173-5.657 10.38-7.152 16.992-7.152c2.496-28.48 8.4-48.8 22.512-63.68C77.331 3.165 112.567.06 127.552 0H128c14.72 0 50.4 2.88 77.28 31.36m-77.264 47.376c-3.04 0-6.544.176-10.272.544c-1.312 4.896-3.248 9.312-6.08 12.128c-11.2 11.2-24.704 12.928-31.936 12.928c-6.802 0-13.927-1.42-19.744-5.088c-5.502 1.808-10.786 4.415-11.136 10.912c-.586 12.28-.637 24.55-.688 36.824c-.026 6.16-.05 12.322-.144 18.488c.024 3.579 2.182 6.903 5.44 8.384C79.936 185.92 104.976 192 128.016 192c23.008 0 48.048-6.08 74.512-18.144c3.258-1.48 5.415-4.805 5.44-8.384c.317-18.418.062-36.912-.816-55.312h.016c-.342-6.534-5.648-9.098-11.168-10.912c-5.82 3.652-12.927 5.088-19.728 5.088c-7.232 0-20.72-1.728-31.936-12.928c-2.832-2.816-4.768-7.232-6.08-12.128a106 106 0 0 0-10.24-.544m-26.941 43.93c5.748 0 10.408 4.66 10.408 10.409v19.183c0 5.749-4.66 10.409-10.408 10.409s-10.408-4.66-10.408-10.409v-19.183c0-5.748 4.66-10.408 10.408-10.408m53.333 0c5.749 0 10.409 4.66 10.409 10.409v19.183c0 5.749-4.66 10.409-10.409 10.409c-5.748 0-10.408-4.66-10.408-10.409v-19.183c0-5.748 4.66-10.408 10.408-10.408M81.44 28.32c-11.2 1.12-20.64 4.8-25.44 9.92c-10.4 11.36-8.16 40.16-2.24 46.24c4.32 4.32 12.48 7.2 21.28 7.2c6.72 0 19.52-1.44 30.08-12.16c4.64-4.48 7.52-15.68 7.2-27.04c-.32-9.12-2.88-16.64-6.72-19.84c-4.16-3.68-13.6-5.28-24.16-4.32m68.96 4.32c-3.84 3.2-6.4 10.72-6.72 19.84c-.32 11.36 2.56 22.56 7.2 27.04c10.56 10.72 23.36 12.16 30.08 12.16c8.8 0 16.96-2.88 21.28-7.2c5.92-6.08 8.16-34.88-2.24-46.24c-4.8-5.12-14.24-8.8-25.44-9.92c-10.56-.96-20 .64-24.16 4.32M128 56c-2.56 0-5.6.16-8.96.48c.32 1.76.48 3.68.64 5.76c0 1.44 0 2.88-.16 4.48c3.2-.32 5.92-.32 8.48-.32s5.28 0 8.48.32c-.16-1.6-.16-3.04-.16-4.48c.16-2.08.32-4 .64-5.76c-3.36-.32-6.4-.48-8.96-.48"})}),ak=({children:e,tooltip:t,selected:n,className:o,...r})=>{const a=m.jsx("div",{className:$t("h-full flex items-center p-2 text-sm shadow-inset font-mono cursor-pointer rounded",!n&&"hover:bg-[var(--sage-3)]",n&&"bg-[var(--sage-4)]",o),...r,children:e});return t?m.jsx(p,{content:t,side:"top",delayDuration:200,children:a}):a},sk=()=>{var e;const t=X(lk),n=X(Q),o=(null==(e=null==t?void 0:t.open_ai)?void 0:e.model)||"gpt-4-turbo",{handleClick:r}=ck();return n?m.jsx(ak,{tooltip:m.jsxs(m.Fragment,{children:[m.jsx("b",{children:"Assist model:"})," ",o]}),onClick:r,selected:!1,children:m.jsx(bc,{className:"h-4 w-4"})}):m.jsx(ak,{tooltip:"Assist is disabled",selected:!1,onClick:r,children:m.jsx(bc,{className:"h-4 w-4 opacity-60"})})},ik=V((e=>e(ma).completion.copilot)),lk=V((e=>e(ma).ai));function ck(){const e=Z(ii),t=Z($s);return{handleClick:()=>{e("ai"),t(!0)}}}const dk=()=>"github"===X(ik)?m.jsx(uk,{}):null,uk=()=>{const e=X(li),t=null!==X(ci),{handleClick:n}=ck(),o=e?"Ready":"Not connected";return m.jsx(ak,{tooltip:m.jsxs(m.Fragment,{children:[m.jsx("b",{children:"GitHub Copilot:"})," ",o]}),selected:!1,onClick:n,children:m.jsx("span",{children:t?m.jsx(pa,{className:"h-4 w-4"}):m.jsx(rk,{className:$t("h-4 w-4",!e&&"opacity-60")})})})},hk=e=>{const[t,n]=r.useState(0),o=X(bi);si((()=>n((e=>e+1))),{delayMs:1e4,whenVisible:!0});const{data:a}=Ht((async()=>C()||o.state!==wi.OPEN?null:ga()),[t,o.state]);return m.jsxs("div",{className:"flex gap-2 items-center",children:[a&&m.jsx(mk,{memory:a.memory,kernel:a.kernel,server:a.server}),a&&m.jsx(pk,{cpu:a.cpu}),m.jsxs("div",{className:"flex items-center",children:[m.jsx(sk,{}),m.jsx(dk,{})]}),m.jsx(fk,{connection:o.state})]})},fk=({connection:e})=>m.jsx(p,{delayDuration:200,content:E(e.toLowerCase()),children:m.jsxs("div",{children:[e===wi.OPEN&&m.jsx(Ol,{className:"w-4 h-4"}),e===wi.CLOSED&&m.jsx(di,{className:"w-4 h-4"}),e===wi.CONNECTING&&m.jsx(pa,{size:"small"}),e===wi.CLOSING&&m.jsx(pa,{className:"text-destructive",size:"small"})]})}),mk=({memory:e,kernel:t,server:n})=>{const{percent:o,total:r,used:a}=e,s=Math.round(o);return m.jsx(p,{delayDuration:200,content:m.jsxs("div",{className:"flex flex-col gap-1",children:[m.jsxs("span",{children:[m.jsx("b",{children:"computer memory:"})," ",xk(a)," / ",xk(r)," GB (",s,"%)"]}),(null==n?void 0:n.memory)&&m.jsxs("span",{children:[m.jsx("b",{children:"marimo server:"})," ",vk(n.memory)]}),(null==t?void 0:t.memory)&&m.jsxs("span",{children:[m.jsx("b",{children:"kernel:"})," ",vk(t.memory)]})]}),children:m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx(tc,{className:"w-4 h-4"}),m.jsx(gk,{percent:s})]})})},pk=({cpu:e})=>{const{percent:t}=e,n=Math.round(t);return m.jsx(p,{delayDuration:200,content:m.jsxs("span",{children:[m.jsx("b",{children:"CPU:"})," ",n,"%"]}),children:m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx(ui,{className:"w-4 h-4"}),m.jsx(gk,{percent:n})]})})},gk=({percent:e})=>m.jsx("div",{className:"h-3 w-20 bg-[var(--slate-4)] rounded-lg overflow-hidden border",children:m.jsx("div",{className:"h-full bg-primary",style:{width:`${e}%`}})});function vk(e){return e>1073741824?`${xk(e)} GB`:`${function(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0}).format(e/1048576)}(e)} MB`}function xk(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:2}).format(e/1073741824)}const yk=e=>X(Yr)[e.capability]?e.children:null,bk=()=>{const{selectedPanel:e,isTerminalOpen:t}=bd(),{openApplication:n,toggleTerminal:o}=wd(),[r,a]=ke(),s=X(va),i=kd.find((e=>"errors"===e.type));return At(i,"Error panel not found"),Os("global.toggleTerminal",(()=>{o()})),m.jsxs("footer",{className:"h-10 py-2 bg-background flex items-center text-muted-foreground text-md pl-1 pr-4 border-t border-border select-none no-print text-sm shadow-[0_0_4px_1px_rgba(0,0,0,0.1)] z-50 print:hidden",children:[m.jsxs(ak,{tooltip:i.tooltip,selected:e===i.type,onClick:()=>n(i.type),children:[(({Icon:e},t)=>m.jsx(e,{className:$t("h-5 w-5",t)}))(i,s>0?"text-destructive":""),m.jsx("span",{className:"ml-1 font-mono mt-[0.125rem]",children:s})]}),m.jsx(yk,{capability:"terminal",children:m.jsx(ak,{tooltip:"Open terminal",selected:t,onClick:()=>o(),children:m.jsx(Ic,{className:"h-5 w-5"})})}),m.jsx(ak,{tooltip:r.runtime.auto_instantiate?"Disable autorun on startup":"Enable autorun on startup",selected:!1,onClick:async()=>{const e={...r,runtime:{...r.runtime,auto_instantiate:!r.runtime.auto_instantiate}};await Ee({config:e}).then((()=>a(e)))},children:m.jsxs("div",{className:"font-prose text-sm flex items-center gap-1",children:[m.jsx("span",{children:"on startup: "}),r.runtime.auto_instantiate?m.jsx(Rc,{size:14}):m.jsx(Pc,{size:14}),m.jsx("span",{children:r.runtime.auto_instantiate?"autorun":"lazy"})]})}),m.jsx("div",{className:"border-r border-border h-6 mx-1"}),m.jsx(ak,{tooltip:"autorun"===r.runtime.on_cell_change?"Disable autorun":"Enable autorun",selected:!1,onClick:async()=>{const e={...r,runtime:{...r.runtime,on_cell_change:"autorun"===r.runtime.on_cell_change?"lazy":"autorun"}};await Ee({config:e}).then((()=>a(e)))},children:m.jsxs("div",{className:"font-prose text-sm flex items-center gap-1",children:[m.jsx("span",{children:"on cell change: "}),"autorun"===r.runtime.on_cell_change?m.jsx(Rc,{size:14}):m.jsx(Pc,{size:14}),m.jsx("span",{children:r.runtime.on_cell_change})]})}),m.jsx("div",{className:"border-r border-border h-6 mx-1"}),!C()&&m.jsx(ak,{tooltip:null,selected:!1,children:m.jsxs(xt,{children:[m.jsxs(yt,{className:"font-prose text-sm flex items-center gap-1",children:[m.jsx("span",{children:"on module change: "}),"off"===r.runtime.auto_reload&&m.jsx(di,{size:14}),"lazy"===r.runtime.auto_reload&&m.jsx(Pc,{size:14}),"autorun"===r.runtime.auto_reload&&m.jsx(Rc,{size:14}),m.jsx("span",{children:r.runtime.auto_reload}),m.jsx(ge,{size:14})]}),m.jsx(bt,{children:["off","lazy","autorun"].map((e=>m.jsxs(St,{onClick:async()=>{const t={...r,runtime:{...r.runtime,auto_reload:e}};await Ee({config:t}).then((()=>a(t)))},children:["off"===e&&m.jsx(di,{size:14,className:"mr-2 text-muted-foreground"}),"lazy"===e&&m.jsx(Pc,{size:14,className:"mr-2 text-muted-foreground"}),"autorun"===e&&m.jsx(Rc,{size:14,className:"mr-2 text-muted-foreground"}),e]},e)))})]})}),m.jsx("div",{className:"mx-auto"}),m.jsx(Jd,{children:m.jsx(p,{content:m.jsx("div",{className:"w-[200px]",children:"Kiosk mode is enabled. This allows you to view the outputs of the cells without the ability to edit them."}),children:m.jsx("span",{className:"text-muted-foreground text-sm mr-4",children:"kiosk mode"})})}),m.jsx(hk,{})]})},wk=({children:e})=>{const{openModal:t,closeModal:n}=f();return m.jsx(xa,{onClick:()=>t(m.jsx(Nk,{onClose:n})),children:e})},kk={"😡":1,"🙁":2,"😐":3,"🙂":4,"😍":5},Nk=({onClose:e})=>m.jsx(g,{className:"w-fit",children:m.jsxs("form",{onSubmit:async t=>{t.preventDefault();const n=new FormData(t.target),o=n.get("rating"),r=n.get("message");fetch("https://marimo.io/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rating:o,message:r})}),e(),q({title:"Feedback sent!",description:"Thank you for your feedback!"})},children:[m.jsxs(re,{children:[m.jsx(v,{children:"Send Feedback"}),m.jsxs(x,{children:["Let us know what you think about marimo! If you have a bug that you would like to report, please use the"," ",m.jsx("a",{href:Be.issuesPage,target:"_blank",rel:"noreferrer",className:"underline",children:"GitHub issue tracker"}),"."]}),m.jsx(x,{children:"Your feedback is anonymous and will help us improve marimo. Thank you!"})]}),m.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[m.jsx("div",{className:"flex gap-5 justify-center",children:Object.entries(kk).map((([e,t])=>m.jsxs("label",{className:"flex flex-col items-center select-none",children:[m.jsx("input",{type:"radio",className:"peer hidden",name:"rating",value:t,"aria-label":e},e),m.jsx("span",{className:"text-4xl peer-checked:opacity-100 opacity-40 cursor-pointer",children:e})]},e)))}),m.jsx(ya,{id:"message",name:"message",autoFocus:!0,placeholder:"Your feedback; if you'd like us to respond, please include your email!",rows:5,required:!0,autoComplete:"off"})]}),m.jsxs(y,{children:[m.jsx(b,{"data-testid":"feedback-cancel-button",variant:"secondary",onClick:e,children:"Cancel"}),m.jsx(b,{"data-testid":"feedback-send-button","aria-label":"Save",variant:"default",type:"submit",children:"Send"})]})]})}),Ek=()=>{const{selectedPanel:e}=bd(),{openApplication:t}=wd(),n=({Icon:e},t)=>m.jsx(e,{className:$t("h-5 w-5",t)}),o=kd.filter((e=>!e.hidden&&"sidebar"===e.position));return m.jsxs("div",{className:"h-full pt-4 pb-1 px-1 flex flex-col items-start text-muted-foreground text-md select-none no-print text-sm z-50 dark:bg-background print:hidden",children:[o.map((o=>m.jsx(jk,{tooltip:o.tooltip,selected:e===o.type,onClick:()=>t(o.type),children:n(o)},o.type))),m.jsx(wk,{children:m.jsx(jk,{tooltip:"Send feedback!",selected:!1,children:m.jsx(nc,{className:"h-5 w-5"})})}),m.jsx("div",{className:"flex-1"}),m.jsx(Ck,{})]})},Ck=()=>{const e=X(ba);return m.jsx(p,{content:e>0?m.jsxs("span",{children:[e," cell",e>1?"s":""," queued or running"]}):"No cells queued or running",side:"right",delayDuration:200,children:m.jsx("div",{className:"flex flex-col-reverse gap-[1px] overflow-hidden",children:Array.from({length:e}).map(((e,t)=>m.jsx("div",{className:"flex-shrink-0 h-1 w-2 bg-[var(--grass-6)] border border-[var(--grass-7)]"},t.toString())))})})},jk=({children:e,tooltip:t,selected:n,className:o,...r})=>m.jsx(p,{content:t,side:"right",delayDuration:200,children:m.jsx("div",{className:$t("flex items-center p-2 text-sm mx-[1px] shadow-inset font-mono cursor-pointer rounded",!n&&"hover:bg-[var(--sage-3)]",n&&"bg-[var(--sage-4)]",o),...r,children:e})});qe.record(qe.tuple([qe.number(),qe.number()]));let Sk=null;const Ik=({title:e,description:t,color:n,icon:o})=>m.jsxs("div",{className:"mx-6 my-6 flex flex-col gap-2",children:[m.jsxs("div",{className:"flex flex-row gap-2 items-center",children:[o&&u.cloneElement(o,{className:"text-accent-foreground"}),m.jsx("span",{className:"mt-1 text-accent-foreground",children:e})]}),m.jsx("span",{className:"text-muted-foreground text-sm",children:t})]}),Ak=()=>{const e=wa();return 0===e.length?m.jsx(Ik,{title:"No errors!",icon:m.jsx(cc,{})}):m.jsx("div",{className:"flex flex-col overflow-auto",children:e.map((e=>m.jsxs("div",{children:[m.jsx("div",{className:"text-xs font-mono font-semibold bg-muted border-y px-2 py-1",children:m.jsx(ka,{cellId:e.cellId})}),m.jsx("div",{className:"px-2",children:m.jsx(Na,{errors:e.output.data},e.cellId)},e.cellId)]},e.cellId)))})},Mk=()=>{const{items:e}=X(Ea),t=r.useMemo((()=>ul(e)),[e]),{activeHeaderId:n}=hl(t);return 0===e.length?m.jsx(Ik,{title:"No outline",description:"Add markdown headings to your notebook to create an outline.",icon:m.jsx(xc,{})}):m.jsx(fl,{items:e,activeHeaderId:n})};function Tk(e){if("string"==typeof e||"number"==typeof e)return""+e;let t="";if(Array.isArray(e))for(let n,o=0;o<e.length;o++)""!==(n=Tk(e[o]))&&(t+=(t&&" ")+n);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}const{useDebugValue:Ok}=u,{useSyncExternalStoreWithSelector:Dk}=Ca,_k=e=>e;function Pk(e,t=_k,n){const o=Dk(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Ok(o),o}const Rk=(e,t)=>{const n=ja(e),o=(e,o=t)=>Pk(n,e,o);return Object.assign(o,n),o};function Fk(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[n,o]of e)if(!Object.is(o,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function Lk(e,t){if(e=function(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,[(o=o.matrixTransform(t.getScreenCTM().inverse())).x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const zk={passive:!1},Bk={capture:!0,passive:!1};function Uk(e){e.stopImmediatePropagation()}function Vk(e){e.preventDefault(),e.stopImmediatePropagation()}function $k(e){var t=e.document.documentElement,n=pl(e).on("dragstart.drag",Vk,Bk);"onselectstart"in t?n.on("selectstart.drag",Vk,Bk):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Gk(e,t){var n=e.document.documentElement,o=pl(e).on("dragstart.drag",null);t&&(o.on("click.drag",Vk,Bk),setTimeout((function(){o.on("click.drag",null)}),0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Hk=e=>()=>e;function Wk(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:a,x:s,y:i,dx:l,dy:c,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:i,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:d}})}function qk(e){return!e.ctrlKey&&!e.button}function Yk(){return this.parentNode}function Jk(e,t){return null==t?{x:e.x,y:e.y}:t}function Kk(){return navigator.maxTouchPoints||"ontouchstart"in this}Wk.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};const Xk=e=>()=>e;function Zk(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function Qk(e){e.stopImmediatePropagation()}function eN(e){e.preventDefault(),e.stopImmediatePropagation()}function tN(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function nN(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function oN(){return this.__zoom||gl}function rN(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function aN(){return navigator.maxTouchPoints||"ontouchstart"in this}function sN(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),s>a?(a+s)/2:Math.min(0,a)||Math.max(0,s))}const iN=r.createContext(null),lN=iN.Provider,cN=e=>`Node type "${e}" not found. Using fallback type "default".`,dN=()=>"The React Flow parent container needs a width and a height to render the graph.",uN=()=>"Only child nodes can use a parent extent.",hN=e=>`Marker type "${e}" doesn't exist.`,fN=(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,mN=()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",pN=e=>`Edge type "${e}" not found. Using fallback type "default".`,gN=e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,vN=(()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001")();function xN(e,t){const n=r.useContext(iN);if(null===n)throw new Error(vN);return Pk(n,e,t)}const yN=()=>{const e=r.useContext(iN);if(null===e)throw new Error(vN);return r.useMemo((()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy})),[e])},bN=e=>e.userSelectionActive?"none":"all";function wN({position:e,children:t,className:n,style:o,...r}){const a=xN(bN),s=`${e}`.split("-");return u.createElement("div",{className:Tk(["react-flow__panel",n,...s]),style:{...o,pointerEvents:a},...r},t)}function kN({proOptions:e,position:t="bottom-right"}){return(null==e?void 0:e.hideAttribution)?null:u.createElement(wN,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},u.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}var NN=r.memo((({x:e,y:t,label:n,labelStyle:o={},labelShowBg:a=!0,labelBgStyle:s={},labelBgPadding:i=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...h})=>{const f=r.useRef(null),[m,p]=r.useState({x:0,y:0,width:0,height:0}),g=Tk(["react-flow__edge-textwrapper",d]);return r.useEffect((()=>{if(f.current){const e=f.current.getBBox();p({x:e.x,y:e.y,width:e.width,height:e.height})}}),[n]),void 0!==n&&n?u.createElement("g",{transform:`translate(${e-m.width/2} ${t-m.height/2})`,className:g,visibility:m.width?"visible":"hidden",...h},a&&u.createElement("rect",{width:m.width+2*i[0],x:-i[0],y:-i[1],height:m.height+2*i[1],className:"react-flow__edge-textbg",style:s,rx:l,ry:l}),u.createElement("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:f,style:o},n),c):null}));const EN=e=>({width:e.offsetWidth,height:e.offsetHeight}),CN=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),jN=(e={x:0,y:0},t)=>({x:CN(e.x,t[0][0],t[1][0]),y:CN(e.y,t[0][1],t[1][1])}),SN=(e,t,n)=>e<t?CN(Math.abs(e-t),1,50)/50:e>n?-CN(Math.abs(e-n),1,50)/50:0,IN=(e,t)=>[20*SN(e.x,35,t.width-35),20*SN(e.y,35,t.height-35)],AN=e=>{var t;return(null==(t=e.getRootNode)?void 0:t.call(e))||(null==window?void 0:window.document)},MN=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),TN=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),ON=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},DN=e=>!isNaN(e)&&isFinite(e),_N=Symbol.for("internals"),PN=["Enter"," ","Escape"];function RN(e){var t,n;const o=(e=>"nativeEvent"in e)(e)?e.nativeEvent:e,r=(null==(n=null==(t=o.composedPath)?void 0:t.call(o))?void 0:n[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(null==r?void 0:r.nodeName)||(null==r?void 0:r.hasAttribute("contenteditable"))||!!(null==r?void 0:r.closest(".nokey"))}const FN=e=>"clientX"in e,LN=(e,t)=>{var n,o;const r=FN(e),a=r?e.clientX:null==(n=e.touches)?void 0:n[0].clientX,s=r?e.clientY:null==(o=e.touches)?void 0:o[0].clientY;return{x:a-((null==t?void 0:t.left)??0),y:s-((null==t?void 0:t.top)??0)}},zN=()=>{var e;return"undefined"!=typeof navigator&&(null==(e=null==navigator?void 0:navigator.userAgent)?void 0:e.indexOf("Mac"))>=0},BN=({id:e,path:t,labelX:n,labelY:o,label:r,labelStyle:a,labelShowBg:s,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f,interactionWidth:m=20})=>u.createElement(u.Fragment,null,u.createElement("path",{id:e,style:d,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:h,markerStart:f}),m&&u.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:m,className:"react-flow__edge-interaction"}),r&&DN(n)&&DN(o)?u.createElement(NN,{x:n,y:o,label:r,labelStyle:a,labelShowBg:s,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c}):null);function UN(e,t,n){return void 0===n?n:o=>{const r=t().edges.find((t=>t.id===e));r&&n(o,{...r})}}function VN({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,a=n<e?n+r:n-r,s=Math.abs(o-t)/2;return[a,o<t?o+s:o-s,r,s]}function $N({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:a,targetControlX:s,targetControlY:i}){const l=.125*e+.375*r+.375*s+.125*n,c=.125*t+.375*a+.375*i+.125*o;return[l,c,Math.abs(l-e),Math.abs(c-t)]}var GN,HN,WN,qN,YN,JN,KN,XN,ZN,QN,eE,tE;function nE({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===eE.Left||e===eE.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function oE({sourceX:e,sourceY:t,sourcePosition:n=eE.Bottom,targetX:o,targetY:r,targetPosition:a=eE.Top}){const[s,i]=nE({pos:n,x1:e,y1:t,x2:o,y2:r}),[l,c]=nE({pos:a,x1:o,y1:r,x2:e,y2:t}),[d,u,h,f]=$N({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:s,sourceControlY:i,targetControlX:l,targetControlY:c});return[`M${e},${t} C${s},${i} ${l},${c} ${o},${r}`,d,u,h,f]}BN.displayName="BaseEdge",(HN=GN||(GN={})).Strict="strict",HN.Loose="loose",(qN=WN||(WN={})).Free="free",qN.Vertical="vertical",qN.Horizontal="horizontal",(JN=YN||(YN={})).Partial="partial",JN.Full="full",(XN=KN||(KN={})).Bezier="default",XN.Straight="straight",XN.Step="step",XN.SmoothStep="smoothstep",XN.SimpleBezier="simplebezier",(QN=ZN||(ZN={})).Arrow="arrow",QN.ArrowClosed="arrowclosed",(tE=eE||(eE={})).Left="left",tE.Top="top",tE.Right="right",tE.Bottom="bottom";const rE=r.memo((({sourceX:e,sourceY:t,targetX:n,targetY:o,sourcePosition:r=eE.Bottom,targetPosition:a=eE.Top,label:s,labelStyle:i,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:p,interactionWidth:g})=>{const[v,x,y]=oE({sourceX:e,sourceY:t,sourcePosition:r,targetX:n,targetY:o,targetPosition:a});return u.createElement(BN,{path:v,labelX:x,labelY:y,label:s,labelStyle:i,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:p,interactionWidth:g})}));rE.displayName="SimpleBezierEdge";const aE={[eE.Left]:{x:-1,y:0},[eE.Right]:{x:1,y:0},[eE.Top]:{x:0,y:-1},[eE.Bottom]:{x:0,y:1}},sE=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function iE({source:e,sourcePosition:t=eE.Bottom,target:n,targetPosition:o=eE.Top,center:r,offset:a}){const s=aE[t],i=aE[o],l={x:e.x+s.x*a,y:e.y+s.y*a},c={x:n.x+i.x*a,y:n.y+i.y*a},d=(({source:e,sourcePosition:t=eE.Bottom,target:n})=>t===eE.Left||t===eE.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1})({source:l,sourcePosition:t,target:c}),u=0!==d.x?"x":"y",h=d[u];let f,m,p=[];const g={x:0,y:0},v={x:0,y:0},[x,y,b,w]=VN({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[u]*i[u]==-1){f=r.x??x,m=r.y??y;const e=[{x:f,y:l.y},{x:f,y:c.y}],t=[{x:l.x,y:m},{x:c.x,y:m}];p=s[u]===h?"x"===u?e:t:"x"===u?t:e}else{const r=[{x:l.x,y:c.y}],d=[{x:c.x,y:l.y}];if(p="x"===u?s.x===h?d:r:s.y===h?r:d,t===o){const t=Math.abs(e[u]-n[u]);if(t<=a){const o=Math.min(a-1,a-t);s[u]===h?g[u]=(l[u]>e[u]?-1:1)*o:v[u]=(c[u]>n[u]?-1:1)*o}}if(t!==o){const e="x"===u?"y":"x",t=s[u]===i[e],n=l[e]>c[e],o=l[e]<c[e];(1===s[u]&&(!t&&n||t&&o)||1!==s[u]&&(!t&&o||t&&n))&&(p="x"===u?r:d)}const x={x:l.x+g.x,y:l.y+g.y},y={x:c.x+v.x,y:c.y+v.y};Math.max(Math.abs(x.x-p[0].x),Math.abs(y.x-p[0].x))>=Math.max(Math.abs(x.y-p[0].y),Math.abs(y.y-p[0].y))?(f=(x.x+y.x)/2,m=p[0].y):(f=p[0].x,m=(x.y+y.y)/2)}return[[e,{x:l.x+g.x,y:l.y+g.y},...p,{x:c.x+v.x,y:c.y+v.y},n],f,m,b,w]}function lE({sourceX:e,sourceY:t,sourcePosition:n=eE.Bottom,targetX:o,targetY:r,targetPosition:a=eE.Top,borderRadius:s=5,centerX:i,centerY:l,offset:c=20}){const[d,u,h,f,m]=iE({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:a,center:{x:i,y:l},offset:c});return[d.reduce(((e,t,n)=>{let o="";return o=n>0&&n<d.length-1?function(e,t,n,o){const r=Math.min(sE(e,t)/2,sE(t,n)/2,o),{x:a,y:s}=t;if(e.x===a&&a===n.x||e.y===s&&s===n.y)return`L${a} ${s}`;if(e.y===s)return`L ${a+r*(e.x<n.x?-1:1)},${s}Q ${a},${s} ${a},${s+r*(e.y<n.y?1:-1)}`;const i=e.x<n.x?1:-1;return`L ${a},${s+r*(e.y<n.y?-1:1)}Q ${a},${s} ${a+r*i},${s}`}(d[n-1],t,d[n+1],s):`${0===n?"M":"L"}${t.x} ${t.y}`,e+=o}),""),u,h,f,m]}const cE=r.memo((({sourceX:e,sourceY:t,targetX:n,targetY:o,label:r,labelStyle:a,labelShowBg:s,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c,style:d,sourcePosition:h=eE.Bottom,targetPosition:f=eE.Top,markerEnd:m,markerStart:p,pathOptions:g,interactionWidth:v})=>{const[x,y,b]=lE({sourceX:e,sourceY:t,sourcePosition:h,targetX:n,targetY:o,targetPosition:f,borderRadius:null==g?void 0:g.borderRadius,offset:null==g?void 0:g.offset});return u.createElement(BN,{path:x,labelX:y,labelY:b,label:r,labelStyle:a,labelShowBg:s,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:m,markerStart:p,interactionWidth:v})}));cE.displayName="SmoothStepEdge";const dE=r.memo((e=>{var t;return u.createElement(cE,{...e,pathOptions:r.useMemo((()=>{var t;return{borderRadius:0,offset:null==(t=e.pathOptions)?void 0:t.offset}}),[null==(t=e.pathOptions)?void 0:t.offset])})}));dE.displayName="StepEdge";const uE=r.memo((({sourceX:e,sourceY:t,targetX:n,targetY:o,label:r,labelStyle:a,labelShowBg:s,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f,interactionWidth:m})=>{const[p,g,v]=function({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,a,s,i]=VN({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,a,s,i]}({sourceX:e,sourceY:t,targetX:n,targetY:o});return u.createElement(BN,{path:p,labelX:g,labelY:v,label:r,labelStyle:a,labelShowBg:s,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f,interactionWidth:m})}));function hE(e,t){return e>=0?.5*e:25*t*Math.sqrt(-e)}function fE({pos:e,x1:t,y1:n,x2:o,y2:r,c:a}){switch(e){case eE.Left:return[t-hE(t-o,a),n];case eE.Right:return[t+hE(o-t,a),n];case eE.Top:return[t,n-hE(n-r,a)];case eE.Bottom:return[t,n+hE(r-n,a)]}}function mE({sourceX:e,sourceY:t,sourcePosition:n=eE.Bottom,targetX:o,targetY:r,targetPosition:a=eE.Top,curvature:s=.25}){const[i,l]=fE({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[c,d]=fE({pos:a,x1:o,y1:r,x2:e,y2:t,c:s}),[u,h,f,m]=$N({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:i,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${i},${l} ${c},${d} ${o},${r}`,u,h,f,m]}uE.displayName="StraightEdge";const pE=r.memo((({sourceX:e,sourceY:t,targetX:n,targetY:o,sourcePosition:r=eE.Bottom,targetPosition:a=eE.Top,label:s,labelStyle:i,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:p,pathOptions:g,interactionWidth:v})=>{const[x,y,b]=mE({sourceX:e,sourceY:t,sourcePosition:r,targetX:n,targetY:o,targetPosition:a,curvature:null==g?void 0:g.curvature});return u.createElement(BN,{path:x,labelX:y,labelY:b,label:s,labelStyle:i,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:p,interactionWidth:v})}));pE.displayName="BezierEdge";const gE=r.createContext(null),vE=gE.Provider;gE.Consumer;const xE=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`reactflow__edge-${e}${t||""}-${n}${o||""}`,yE=(e,t)=>{if(void 0===e)return"";if("string"==typeof e)return e;return`${t?`${t}__`:""}${Object.keys(e).sort().map((t=>`${t}=${e[t]}`)).join("&")}`},bE=({x:e,y:t},[n,o,r],a,[s,i])=>{const l={x:(e-n)/r,y:(t-o)/r};return a?{x:s*Math.round(l.x/s),y:i*Math.round(l.y/i)}:l},wE=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o}),kE=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],o=(e.height??0)*t[1],r={x:e.position.x-n,y:e.position.y-o};return{...r,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-o}:r}},NE=(e,t=[0,0])=>{if(0===e.length)return{x:0,y:0,width:0,height:0};return(({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}))(e.reduce(((e,n)=>{const{x:o,y:r}=kE(n,t).positionAbsolute;return a=e,s=MN({x:o,y:r,width:n.width||0,height:n.height||0}),{x:Math.min(a.x,s.x),y:Math.min(a.y,s.y),x2:Math.max(a.x2,s.x2),y2:Math.max(a.y2,s.y2)};var a,s}),{x:1/0,y:1/0,x2:-1/0,y2:-1/0}))},EE=(e,t,[n,o,r]=[0,0,1],a=!1,s=!1,i=[0,0])=>{const l={x:(t.x-n)/r,y:(t.y-o)/r,width:t.width/r,height:t.height/r},c=[];return e.forEach((e=>{const{width:t,height:n,selectable:o=!0,hidden:r=!1}=e;if(s&&!o||r)return!1;const{positionAbsolute:d}=kE(e,i),u={x:d.x,y:d.y,width:t||0,height:n||0},h=ON(l,u);(void 0===t||void 0===n||null===t||null===n||a&&h>0||h>=(t||0)*(n||0)||e.dragging)&&c.push(e)})),c},CE=(e,t)=>{const n=e.map((e=>e.id));return t.filter((e=>n.includes(e.source)||n.includes(e.target)))},jE=(e,t,n,o,r,a=.1)=>{const s=t/(e.width*(1+a)),i=n/(e.height*(1+a)),l=Math.min(s,i),c=CN(l,o,r);return{x:t/2-(e.x+e.width/2)*c,y:n/2-(e.y+e.height/2)*c,zoom:c}},SE=(e,t=0)=>e.transition().duration(t);function IE(e,t,n,o){return(t[n]||[]).reduce(((t,r)=>{var a,s;return`${e.id}-${r.id}-${n}`!==o&&t.push({id:r.id||null,type:n,nodeId:e.id,x:((null==(a=e.positionAbsolute)?void 0:a.x)??0)+r.x+r.width/2,y:((null==(s=e.positionAbsolute)?void 0:s.y)??0)+r.y+r.height/2}),t}),[])}const AE={source:null,target:null,sourceHandle:null,targetHandle:null},ME=()=>({handleDomNode:null,isValid:!1,connection:AE,endHandle:null});function TE(e,t,n,o,r,a,s){const i="target"===r,l=s.querySelector(`.react-flow__handle[data-id="${null==e?void 0:e.nodeId}-${null==e?void 0:e.id}-${null==e?void 0:e.type}"]`),c={...ME(),handleDomNode:l};if(l){const e=OE(void 0,l),r=l.getAttribute("data-nodeid"),s=l.getAttribute("data-handleid"),d=l.classList.contains("connectable"),u=l.classList.contains("connectableend"),h={source:i?r:n,sourceHandle:i?s:o,target:i?n:r,targetHandle:i?o:s};c.connection=h;d&&u&&(t===GN.Strict?i&&"source"===e||!i&&"target"===e:r!==n||s!==o)&&(c.endHandle={nodeId:r,handleId:s,type:e},c.isValid=a(h))}return c}function OE(e,t){return e||((null==t?void 0:t.classList.contains("target"))?"target":(null==t?void 0:t.classList.contains("source"))?"source":null)}function DE(e){null==e||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function _E(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function PE({event:e,handleId:t,nodeId:n,onConnect:o,isTarget:r,getState:a,setState:s,isValidConnection:i,edgeUpdaterType:l,onReconnectEnd:c}){const d=AN(e.target),{connectionMode:u,domNode:h,autoPanOnConnect:f,connectionRadius:m,onConnectStart:p,panBy:g,getNodes:v,cancelConnection:x}=a();let y,b=0;const{x:w,y:k}=LN(e),N=null==d?void 0:d.elementFromPoint(w,k),E=OE(l,N),C=null==h?void 0:h.getBoundingClientRect();if(!C||!E)return;let j,S=LN(e,C),I=!1,A=null,M=!1,T=null;const O=function({nodes:e,nodeId:t,handleId:n,handleType:o}){return e.reduce(((e,r)=>{if(r[_N]){const{handleBounds:a}=r[_N];let s=[],i=[];a&&(s=IE(r,a,"source",`${t}-${n}-${o}`),i=IE(r,a,"target",`${t}-${n}-${o}`)),e.push(...s,...i)}return e}),[])}({nodes:v(),nodeId:n,handleId:t,handleType:E}),D=()=>{if(!f)return;const[e,t]=IN(S,C);g({x:e,y:t}),b=requestAnimationFrame(D)};function _(e){const{transform:o}=a();S=LN(e,C);const{handle:l,validHandleResult:c}=function(e,t,n,o,r,a){const{x:s,y:i}=LN(e),l=t.elementsFromPoint(s,i).find((e=>e.classList.contains("react-flow__handle")));if(l){const e=l.getAttribute("data-nodeid");if(e){const t=OE(void 0,l),o=l.getAttribute("data-handleid"),s=a({nodeId:e,id:o,type:t});if(s){const a=r.find((n=>n.nodeId===e&&n.type===t&&n.id===o));return{handle:{id:o,type:t,nodeId:e,x:(null==a?void 0:a.x)||n.x,y:(null==a?void 0:a.y)||n.y},validHandleResult:s}}}}let c=[],d=1/0;if(r.forEach((e=>{const t=Math.sqrt((e.x-n.x)**2+(e.y-n.y)**2);if(t<=o){const n=a(e);t<=d&&(t<d?c=[{handle:e,validHandleResult:n}]:t===d&&c.push({handle:e,validHandleResult:n}),d=t)}})),!c.length)return{handle:null,validHandleResult:ME()};if(1===c.length)return c[0];const u=c.some((({validHandleResult:e})=>e.isValid)),h=c.some((({handle:e})=>"target"===e.type));return c.find((({handle:e,validHandleResult:t})=>h?"target"===e.type:!u||t.isValid))||c[0]}(e,d,bE(S,o,!1,[1,1]),m,O,(e=>TE(e,u,n,t,r?"target":"source",i,d)));if(y=l,I||(D(),I=!0),T=c.handleDomNode,A=c.connection,M=c.isValid,s({connectionPosition:y&&M?wE({x:y.x,y:y.y},o):S,connectionStatus:_E(!!y,M),connectionEndHandle:c.endHandle}),!y&&!M&&!T)return DE(j);A.source!==A.target&&T&&(DE(j),j=T,T.classList.add("connecting","react-flow__handle-connecting"),T.classList.toggle("valid",M),T.classList.toggle("react-flow__handle-valid",M))}function P(e){var t,n;(y||T)&&A&&M&&(null==o||o(A)),null==(n=(t=a()).onConnectEnd)||n.call(t,e),l&&(null==c||c(e)),DE(j),x(),cancelAnimationFrame(b),I=!1,M=!1,A=null,T=null,d.removeEventListener("mousemove",_),d.removeEventListener("mouseup",P),d.removeEventListener("touchmove",_),d.removeEventListener("touchend",P)}s({connectionPosition:S,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:E,connectionStartHandle:{nodeId:n,handleId:t,type:E},connectionEndHandle:null}),null==p||p(e,{nodeId:n,handleId:t,handleType:E}),d.addEventListener("mousemove",_),d.addEventListener("mouseup",P),d.addEventListener("touchmove",_),d.addEventListener("touchend",P)}const RE=()=>!0,FE=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),LE=r.forwardRef((({type:e="source",position:t=eE.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:a=!0,isConnectableEnd:s=!0,id:i,onConnect:l,children:c,className:d,onMouseDown:h,onTouchStart:f,...m},p)=>{var g,v;const x=i||null,y="target"===e,b=yN(),w=r.useContext(gE),{connectOnClick:k,noPanClassName:N}=xN(FE,Fk),{connecting:E,clickConnecting:C}=xN(((e,t,n)=>o=>{const{connectionStartHandle:r,connectionEndHandle:a,connectionClickStartHandle:s}=o;return{connecting:(null==r?void 0:r.nodeId)===e&&(null==r?void 0:r.handleId)===t&&(null==r?void 0:r.type)===n||(null==a?void 0:a.nodeId)===e&&(null==a?void 0:a.handleId)===t&&(null==a?void 0:a.type)===n,clickConnecting:(null==s?void 0:s.nodeId)===e&&(null==s?void 0:s.handleId)===t&&(null==s?void 0:s.type)===n}})(w,x,e),Fk);w||null==(v=(g=b.getState()).onError)||v.call(g,"010",mN());const j=e=>{const{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:o}=b.getState(),r={...t,...e};if(o){const{edges:e,setEdges:t}=b.getState();t(((e,t)=>{if(!e.source||!e.target)return t;let n;var o;return n="id"in(o=e)&&"source"in o&&"target"in o?{...e}:{...e,id:xE(e)},((e,t)=>t.some((t=>!(t.source!==e.source||t.target!==e.target||t.sourceHandle!==e.sourceHandle&&(t.sourceHandle||e.sourceHandle)||t.targetHandle!==e.targetHandle&&(t.targetHandle||e.targetHandle)))))(n,t)?t:t.concat(n)})(r,e))}null==n||n(r),null==l||l(r)},S=e=>{if(!w)return;const t=FN(e);a&&(t&&0===e.button||!t)&&PE({event:e,handleId:x,nodeId:w,onConnect:j,isTarget:y,getState:b.getState,setState:b.setState,isValidConnection:n||b.getState().isValidConnection||RE}),t?null==h||h(e):null==f||f(e)};return u.createElement("div",{"data-handleid":x,"data-nodeid":w,"data-handlepos":t,"data-id":`${w}-${x}-${e}`,className:Tk(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",N,d,{source:!y,target:y,connectable:o,connectablestart:a,connectableend:s,connecting:C,connectionindicator:o&&(a&&!E||s&&E)}]),onMouseDown:S,onTouchStart:S,onClick:k?t=>{const{onClickConnectStart:o,onClickConnectEnd:r,connectionClickStartHandle:s,connectionMode:i,isValidConnection:l}=b.getState();if(!w||!s&&!a)return;if(!s)return null==o||o(t,{nodeId:w,handleId:x,handleType:e}),void b.setState({connectionClickStartHandle:{nodeId:w,type:e,handleId:x}});const c=AN(t.target),d=n||l||RE,{connection:u,isValid:h}=TE({nodeId:w,id:x,type:e},i,s.nodeId,s.handleId||null,s.type,d,c);h&&j(u),null==r||r(t),b.setState({connectionClickStartHandle:null})}:void 0,ref:p,...m},c)}));LE.displayName="Handle";var zE=r.memo(LE);const BE=({data:e,isConnectable:t,targetPosition:n=eE.Top,sourcePosition:o=eE.Bottom})=>u.createElement(u.Fragment,null,u.createElement(zE,{type:"target",position:n,isConnectable:t}),null==e?void 0:e.label,u.createElement(zE,{type:"source",position:o,isConnectable:t}));BE.displayName="DefaultNode";var UE=r.memo(BE);const VE=({data:e,isConnectable:t,sourcePosition:n=eE.Bottom})=>u.createElement(u.Fragment,null,null==e?void 0:e.label,u.createElement(zE,{type:"source",position:n,isConnectable:t}));VE.displayName="InputNode";var $E=r.memo(VE);const GE=({data:e,isConnectable:t,targetPosition:n=eE.Top})=>u.createElement(u.Fragment,null,u.createElement(zE,{type:"target",position:n,isConnectable:t}),null==e?void 0:e.label);GE.displayName="OutputNode";var HE=r.memo(GE);const WE=()=>null;WE.displayName="GroupNode";const qE=e=>({selectedNodes:e.getNodes().filter((e=>e.selected)),selectedEdges:e.edges.filter((e=>e.selected)).map((e=>({...e})))}),YE=e=>e.id;function JE(e,t){return Fk(e.selectedNodes.map(YE),t.selectedNodes.map(YE))&&Fk(e.selectedEdges.map(YE),t.selectedEdges.map(YE))}const KE=r.memo((({onSelectionChange:e})=>{const t=yN(),{selectedNodes:n,selectedEdges:o}=xN(qE,JE);return r.useEffect((()=>{const r={nodes:n,edges:o};null==e||e(r),t.getState().onSelectionChange.forEach((e=>e(r)))}),[n,o,e]),null}));KE.displayName="SelectionListener";const XE=e=>!!e.onSelectionChange;function ZE({onSelectionChange:e}){const t=xN(XE);return e||t?u.createElement(KE,{onSelectionChange:e}):null}const QE=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function eC(e,t){r.useEffect((()=>{void 0!==e&&t(e)}),[e])}function tC(e,t,n){r.useEffect((()=>{void 0!==t&&n({[e]:t})}),[t])}const nC=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:a,onConnectStart:s,onConnectEnd:i,onClickConnectStart:l,onClickConnectEnd:c,nodesDraggable:d,nodesConnectable:u,nodesFocusable:h,edgesFocusable:f,edgesUpdatable:m,elevateNodesOnSelect:p,minZoom:g,maxZoom:v,nodeExtent:x,onNodesChange:y,onEdgesChange:b,elementsSelectable:w,connectionMode:k,snapGrid:N,snapToGrid:E,translateExtent:C,connectOnClick:j,defaultEdgeOptions:S,fitView:I,fitViewOptions:A,onNodesDelete:M,onEdgesDelete:T,onNodeDrag:O,onNodeDragStart:D,onNodeDragStop:_,onSelectionDrag:P,onSelectionDragStart:R,onSelectionDragStop:F,noPanClassName:L,nodeOrigin:z,rfId:B,autoPanOnConnect:U,autoPanOnNodeDrag:V,onError:$,connectionRadius:G,isValidConnection:H,nodeDragThreshold:W})=>{const{setNodes:q,setEdges:Y,setDefaultNodesAndEdges:J,setMinZoom:K,setMaxZoom:X,setTranslateExtent:Z,setNodeExtent:Q,reset:ee}=xN(QE,Fk),te=yN();return r.useEffect((()=>{const e=null==o?void 0:o.map((e=>({...e,...S})));return J(n,e),()=>{ee()}}),[]),tC("defaultEdgeOptions",S,te.setState),tC("connectionMode",k,te.setState),tC("onConnect",a,te.setState),tC("onConnectStart",s,te.setState),tC("onConnectEnd",i,te.setState),tC("onClickConnectStart",l,te.setState),tC("onClickConnectEnd",c,te.setState),tC("nodesDraggable",d,te.setState),tC("nodesConnectable",u,te.setState),tC("nodesFocusable",h,te.setState),tC("edgesFocusable",f,te.setState),tC("edgesUpdatable",m,te.setState),tC("elementsSelectable",w,te.setState),tC("elevateNodesOnSelect",p,te.setState),tC("snapToGrid",E,te.setState),tC("snapGrid",N,te.setState),tC("onNodesChange",y,te.setState),tC("onEdgesChange",b,te.setState),tC("connectOnClick",j,te.setState),tC("fitViewOnInit",I,te.setState),tC("fitViewOnInitOptions",A,te.setState),tC("onNodesDelete",M,te.setState),tC("onEdgesDelete",T,te.setState),tC("onNodeDrag",O,te.setState),tC("onNodeDragStart",D,te.setState),tC("onNodeDragStop",_,te.setState),tC("onSelectionDrag",P,te.setState),tC("onSelectionDragStart",R,te.setState),tC("onSelectionDragStop",F,te.setState),tC("noPanClassName",L,te.setState),tC("nodeOrigin",z,te.setState),tC("rfId",B,te.setState),tC("autoPanOnConnect",U,te.setState),tC("autoPanOnNodeDrag",V,te.setState),tC("onError",$,te.setState),tC("connectionRadius",G,te.setState),tC("isValidConnection",H,te.setState),tC("nodeDragThreshold",W,te.setState),eC(e,q),eC(t,Y),eC(g,K),eC(v,X),eC(C,Z),eC(x,Q),null},oC={display:"none"},rC={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},aC="react-flow__node-desc",sC="react-flow__edge-desc",iC=e=>e.ariaLiveMessage;function lC({rfId:e}){const t=xN(iC);return u.createElement("div",{id:`react-flow__aria-live-${e}`,"aria-live":"assertive","aria-atomic":"true",style:rC},t)}function cC({rfId:e,disableKeyboardA11y:t}){return u.createElement(u.Fragment,null,u.createElement("div",{id:`${aC}-${e}`,style:oC},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),u.createElement("div",{id:`${sC}-${e}`,style:oC},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&u.createElement(lC,{rfId:e}))}var dC=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,o]=r.useState(!1),a=r.useRef(!1),s=r.useRef(new Set([])),[i,l]=r.useMemo((()=>{if(null!==e){const t=(Array.isArray(e)?e:[e]).filter((e=>"string"==typeof e)).map((e=>e.split("+"))),n=t.reduce(((e,t)=>e.concat(...t)),[]);return[t,n]}return[[],[]]}),[e]);return r.useEffect((()=>{const n="undefined"!=typeof document?document:null,r=(null==t?void 0:t.target)||n;if(null!==e){const e=e=>{a.current=e.ctrlKey||e.metaKey||e.shiftKey;if((!a.current||a.current&&!t.actInsideInputWithModifier)&&RN(e))return!1;const n=hC(e.code,l);s.current.add(e[n]),uC(i,s.current,!1)&&(e.preventDefault(),o(!0))},n=e=>{if((!a.current||a.current&&!t.actInsideInputWithModifier)&&RN(e))return!1;const n=hC(e.code,l);uC(i,s.current,!0)?(o(!1),s.current.clear()):s.current.delete(e[n]),"Meta"===e.key&&s.current.clear(),a.current=!1},c=()=>{s.current.clear(),o(!1)};return null==r||r.addEventListener("keydown",e),null==r||r.addEventListener("keyup",n),window.addEventListener("blur",c),()=>{null==r||r.removeEventListener("keydown",e),null==r||r.removeEventListener("keyup",n),window.removeEventListener("blur",c)}}}),[e,o]),n};function uC(e,t,n){return e.filter((e=>n||e.length===t.size)).some((e=>e.every((e=>t.has(e)))))}function hC(e,t){return t.includes(e)?"code":"key"}function fC(e,t,n,o){var r,a;const s=e.parentNode||e.parentId;if(!s)return n;const i=t.get(s),l=kE(i,o);return fC(i,t,{x:(n.x??0)+l.x,y:(n.y??0)+l.y,z:((null==(r=i[_N])?void 0:r.z)??0)>(n.z??0)?(null==(a=i[_N])?void 0:a.z)??0:n.z??0},o)}function mC(e,t,n){e.forEach((o=>{var r;const a=o.parentNode||o.parentId;if(a&&!e.has(a))throw new Error(`Parent node ${a} not found`);if(a||(null==n?void 0:n[o.id])){const{x:a,y:s,z:i}=fC(o,e,{...o.position,z:(null==(r=o[_N])?void 0:r.z)??0},t);o.positionAbsolute={x:a,y:s},o[_N].z=i,(null==n?void 0:n[o.id])&&(o[_N].isParent=!0)}}))}function pC(e,t,n,o){const r=new Map,a={},s=o?1e3:0;return e.forEach((e=>{var n;const o=(DN(e.zIndex)?e.zIndex:0)+(e.selected?s:0),i=t.get(e.id),l={...e,positionAbsolute:{x:e.position.x,y:e.position.y}},c=e.parentNode||e.parentId;c&&(a[c]=!0);const d=(null==i?void 0:i.type)&&(null==i?void 0:i.type)!==e.type;Object.defineProperty(l,_N,{enumerable:!1,value:{handleBounds:d||null==(n=null==i?void 0:i[_N])?void 0:n.handleBounds,z:o}}),r.set(e.id,l)})),mC(r,n,a),r}function gC(e,t={}){const{getNodes:n,width:o,height:r,minZoom:a,maxZoom:s,d3Zoom:i,d3Selection:l,fitViewOnInitDone:c,fitViewOnInit:d,nodeOrigin:u}=e(),h=t.initial&&!c&&d;if(i&&l&&(h||!t.initial)){const e=n().filter((e=>{var n;const o=t.includeHiddenNodes?e.width&&e.height:!e.hidden;return(null==(n=t.nodes)?void 0:n.length)?o&&t.nodes.some((t=>t.id===e.id)):o})),c=e.every((e=>e.width&&e.height));if(e.length>0&&c){const n=NE(e,u),{x:c,y:d,zoom:h}=jE(n,o,r,t.minZoom??a,t.maxZoom??s,t.padding??.1),f=gl.translate(c,d).scale(h);return"number"==typeof t.duration&&t.duration>0?i.transform(SE(l,t.duration),f):i.transform(l,f),!0}}return!1}function vC(e,t){return e.forEach((e=>{const n=t.get(e.id);n&&t.set(n.id,{...n,[_N]:n[_N],selected:e.selected})})),new Map(t)}function xC(e,t){return t.map((t=>{const n=e.find((e=>e.id===t.id));return n&&(t.selected=n.selected),t}))}function yC({changedNodes:e,changedEdges:t,get:n,set:o}){const{nodeInternals:r,edges:a,onNodesChange:s,onEdgesChange:i,hasDefaultNodes:l,hasDefaultEdges:c}=n();(null==e?void 0:e.length)&&(l&&o({nodeInternals:vC(e,r)}),null==s||s(e)),(null==t?void 0:t.length)&&(c&&o({edges:xC(t,a)}),null==i||i(t))}const bC=()=>{},wC={zoomIn:bC,zoomOut:bC,zoomTo:bC,getZoom:()=>1,setViewport:bC,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:bC,fitBounds:bC,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},kC=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection});function NC(){const e=(()=>{const e=yN(),{d3Zoom:t,d3Selection:n}=xN(kC,Fk);return r.useMemo((()=>n&&t?{zoomIn:e=>t.scaleBy(SE(n,null==e?void 0:e.duration),1.2),zoomOut:e=>t.scaleBy(SE(n,null==e?void 0:e.duration),1/1.2),zoomTo:(e,o)=>t.scaleTo(SE(n,null==o?void 0:o.duration),e),getZoom:()=>e.getState().transform[2],setViewport:(o,r)=>{const[a,s,i]=e.getState().transform,l=gl.translate(o.x??a,o.y??s).scale(o.zoom??i);t.transform(SE(n,null==r?void 0:r.duration),l)},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},fitView:t=>gC(e.getState,t),setCenter:(o,r,a)=>{const{width:s,height:i,maxZoom:l}=e.getState(),c=void 0!==(null==a?void 0:a.zoom)?a.zoom:l,d=s/2-o*c,u=i/2-r*c,h=gl.translate(d,u).scale(c);t.transform(SE(n,null==a?void 0:a.duration),h)},fitBounds:(o,r)=>{const{width:a,height:s,minZoom:i,maxZoom:l}=e.getState(),{x:c,y:d,zoom:u}=jE(o,a,s,i,l,(null==r?void 0:r.padding)??.1),h=gl.translate(c,d).scale(u);t.transform(SE(n,null==r?void 0:r.duration),h)},project:t=>{const{transform:n,snapToGrid:o,snapGrid:r}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),bE(t,n,o,r)},screenToFlowPosition:t=>{const{transform:n,snapToGrid:o,snapGrid:r,domNode:a}=e.getState();if(!a)return t;const{x:s,y:i}=a.getBoundingClientRect(),l={x:t.x-s,y:t.y-i};return bE(l,n,o,r)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:a}=o.getBoundingClientRect(),s=wE(t,n);return{x:s.x+r,y:s.y+a}},viewportInitialized:!0}:wC),[t,n])})(),t=yN(),n=r.useCallback((()=>t.getState().getNodes().map((e=>({...e})))),[]),o=r.useCallback((e=>t.getState().nodeInternals.get(e)),[]),a=r.useCallback((()=>{const{edges:e=[]}=t.getState();return e.map((e=>({...e})))}),[]),s=r.useCallback((e=>{const{edges:n=[]}=t.getState();return n.find((t=>t.id===e))}),[]),i=r.useCallback((e=>{const{getNodes:n,setNodes:o,hasDefaultNodes:r,onNodesChange:a}=t.getState(),s=n(),i="function"==typeof e?e(s):e;if(r)o(i);else if(a){a(0===i.length?s.map((e=>({type:"remove",id:e.id}))):i.map((e=>({item:e,type:"reset"}))))}}),[]),l=r.useCallback((e=>{const{edges:n=[],setEdges:o,hasDefaultEdges:r,onEdgesChange:a}=t.getState(),s="function"==typeof e?e(n):e;if(r)o(s);else if(a){a(0===s.length?n.map((e=>({type:"remove",id:e.id}))):s.map((e=>({item:e,type:"reset"}))))}}),[]),c=r.useCallback((e=>{const n=Array.isArray(e)?e:[e],{getNodes:o,setNodes:r,hasDefaultNodes:a,onNodesChange:s}=t.getState();if(a){r([...o(),...n])}else if(s){s(n.map((e=>({item:e,type:"add"}))))}}),[]),d=r.useCallback((e=>{const n=Array.isArray(e)?e:[e],{edges:o=[],setEdges:r,hasDefaultEdges:a,onEdgesChange:s}=t.getState();if(a)r([...o,...n]);else if(s){s(n.map((e=>({item:e,type:"add"}))))}}),[]),u=r.useCallback((()=>{const{getNodes:e,edges:n=[],transform:o}=t.getState(),[r,a,s]=o;return{nodes:e().map((e=>({...e}))),edges:n.map((e=>({...e}))),viewport:{x:r,y:a,zoom:s}}}),[]),h=r.useCallback((({nodes:e,edges:n})=>{const{nodeInternals:o,getNodes:r,edges:a,hasDefaultNodes:s,hasDefaultEdges:i,onNodesDelete:l,onEdgesDelete:c,onNodesChange:d,onEdgesChange:u}=t.getState(),h=(e||[]).map((e=>e.id)),f=(n||[]).map((e=>e.id)),m=r().reduce(((e,t)=>{const n=t.parentNode||t.parentId,o=!h.includes(t.id)&&n&&e.find((e=>e.id===n));return("boolean"!=typeof t.deletable||t.deletable)&&(h.includes(t.id)||o)&&e.push(t),e}),[]),p=a.filter((e=>"boolean"!=typeof e.deletable||e.deletable)),g=p.filter((e=>f.includes(e.id)));if(m||g){const e=CE(m,p),n=[...g,...e],r=n.reduce(((e,t)=>(e.includes(t.id)||e.push(t.id),e)),[]);if((i||s)&&(i&&t.setState({edges:a.filter((e=>!r.includes(e.id)))}),s&&(m.forEach((e=>{o.delete(e.id)})),t.setState({nodeInternals:new Map(o)}))),r.length>0&&(null==c||c(n),u&&u(r.map((e=>({id:e,type:"remove"}))))),m.length>0&&(null==l||l(m),d)){d(m.map((e=>({id:e.id,type:"remove"}))))}}}),[]),f=r.useCallback((e=>{const n=DN((o=e).width)&&DN(o.height)&&DN(o.x)&&DN(o.y);var o;const r=n?null:t.getState().nodeInternals.get(e.id);if(!n&&!r)return[null,null,n];return[n?e:TN(r),r,n]}),[]),m=r.useCallback(((e,n=!0,o)=>{const[r,a,s]=f(e);return r?(o||t.getState().getNodes()).filter((e=>{if(!(s||e.id!==a.id&&e.positionAbsolute))return!1;const t=TN(e),o=ON(t,r);return n&&o>0||o>=r.width*r.height})):[]}),[]),p=r.useCallback(((e,t,n=!0)=>{const[o]=f(e);if(!o)return!1;const r=ON(o,t);return n&&r>0||r>=o.width*o.height}),[]);return r.useMemo((()=>({...e,getNodes:n,getNode:o,getEdges:a,getEdge:s,setNodes:i,setEdges:l,addNodes:c,addEdges:d,toObject:u,deleteElements:h,getIntersectingNodes:m,isNodeIntersecting:p})),[e,n,o,a,s,i,l,c,d,u,h,m,p])}const EC={actInsideInputWithModifier:!1};const CC={position:"absolute",width:"100%",height:"100%",top:0,left:0},jC=e=>({x:e.x,y:e.y,zoom:e.k}),SC=(e,t)=>e.target.closest(`.${t}`),IC=(e,t)=>2===t&&Array.isArray(e)&&e.includes(2),AC=e=>{const t=e.ctrlKey&&zN()?10:1;return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*t},MC=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),TC=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:o,zoomOnScroll:a=!0,zoomOnPinch:s=!0,panOnScroll:i=!1,panOnScrollSpeed:l=.5,panOnScrollMode:c=WN.Free,zoomOnDoubleClick:d=!0,elementsSelectable:h,panOnDrag:f=!0,defaultViewport:m,translateExtent:p,minZoom:g,maxZoom:v,zoomActivationKeyCode:x,preventScrolling:y=!0,children:b,noWheelClassName:w,noPanClassName:k})=>{const N=r.useRef(),E=yN(),C=r.useRef(!1),j=r.useRef(!1),S=r.useRef(null),I=r.useRef({x:0,y:0,zoom:0}),{d3Zoom:A,d3Selection:M,d3ZoomHandler:T,userSelectionActive:O}=xN(MC,Fk),D=dC(x),_=r.useRef(0),P=r.useRef(!1),R=r.useRef();return function(e){const t=yN();r.useEffect((()=>{let n;const o=()=>{var n,o;if(!e.current)return;const r=EN(e.current);0!==r.height&&0!==r.width||null==(o=(n=t.getState()).onError)||o.call(n,"004",dN()),t.setState({width:r.width||500,height:r.height||500})};return o(),window.addEventListener("resize",o),e.current&&(n=new ResizeObserver((()=>o())),n.observe(e.current)),()=>{window.removeEventListener("resize",o),n&&e.current&&n.unobserve(e.current)}}),[])}(S),r.useEffect((()=>{if(S.current){const e=S.current.getBoundingClientRect(),t=function(){var e,t,n,o=tN,r=nN,a=sN,s=rN,i=aN,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],d=250,u=bl,h=yl("start","zoom","end"),f=0,m=10;function p(e){e.property("__zoom",oN).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",N).on("dblclick.zoom",E).filter(i).on("touchstart.zoom",C).on("touchmove.zoom",j).on("touchend.zoom touchcancel.zoom",S).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(e,t){return(t=Math.max(l[0],Math.min(l[1],t)))===e.k?e:new vl(t,e.x,e.y)}function v(e,t,n){var o=t[0]-n[0]*e.k,r=t[1]-n[1]*e.k;return o===e.x&&r===e.y?e:new vl(e.k,o,r)}function x(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function y(e,t,n,o){e.on("start.zoom",(function(){b(this,arguments).event(o).start()})).on("interrupt.zoom end.zoom",(function(){b(this,arguments).event(o).end()})).tween("zoom",(function(){var e=this,a=arguments,s=b(e,a).event(o),i=r.apply(e,a),l=null==n?x(i):"function"==typeof n?n.apply(e,a):n,c=Math.max(i[1][0]-i[0][0],i[1][1]-i[0][1]),d=e.__zoom,h="function"==typeof t?t.apply(e,a):t,f=u(d.invert(l).concat(c/d.k),h.invert(l).concat(c/h.k));return function(e){if(1===e)e=h;else{var t=f(e),n=c/t[2];e=new vl(n,l[0]-t[0]*n,l[1]-t[1]*n)}s.zoom(null,e)}}))}function b(e,t,n){return!n&&e.__zooming||new w(e,t)}function w(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=r.apply(e,t),this.taps=0}function k(e,...t){if(o.apply(this,arguments)){var n=b(this,t).event(e),r=this.__zoom,i=Math.max(l[0],Math.min(l[1],r.k*Math.pow(2,s.apply(this,arguments)))),d=Lk(e);if(n.wheel)n.mouse[0][0]===d[0]&&n.mouse[0][1]===d[1]||(n.mouse[1]=r.invert(n.mouse[0]=d)),clearTimeout(n.wheel);else{if(r.k===i)return;n.mouse=[d,r.invert(d)],xl(this),n.start()}eN(e),n.wheel=setTimeout((function(){n.wheel=null,n.end()}),150),n.zoom("mouse",a(v(g(r,i),n.mouse[0],n.mouse[1]),n.extent,c))}}function N(e,...t){if(!n&&o.apply(this,arguments)){var r=e.currentTarget,s=b(this,t,!0).event(e),i=pl(e.view).on("mousemove.zoom",(function(e){if(eN(e),!s.moved){var t=e.clientX-d,n=e.clientY-u;s.moved=t*t+n*n>f}s.event(e).zoom("mouse",a(v(s.that.__zoom,s.mouse[0]=Lk(e,r),s.mouse[1]),s.extent,c))}),!0).on("mouseup.zoom",(function(e){i.on("mousemove.zoom mouseup.zoom",null),Gk(e.view,s.moved),eN(e),s.event(e).end()}),!0),l=Lk(e,r),d=e.clientX,u=e.clientY;$k(e.view),Qk(e),s.mouse=[l,this.__zoom.invert(l)],xl(this),s.start()}}function E(e,...t){if(o.apply(this,arguments)){var n=this.__zoom,s=Lk(e.changedTouches?e.changedTouches[0]:e,this),i=n.invert(s),l=n.k*(e.shiftKey?.5:2),u=a(v(g(n,l),s,i),r.apply(this,t),c);eN(e),d>0?pl(this).transition().duration(d).call(y,u,s,e):pl(this).call(p.transform,u,s,e)}}function C(n,...r){if(o.apply(this,arguments)){var a,s,i,l,c=n.touches,d=c.length,u=b(this,r,n.changedTouches.length===d).event(n);for(Qk(n),s=0;s<d;++s)l=[l=Lk(i=c[s],this),this.__zoom.invert(l),i.identifier],u.touch0?u.touch1||u.touch0[2]===l[2]||(u.touch1=l,u.taps=0):(u.touch0=l,a=!0,u.taps=1+!!e);e&&(e=clearTimeout(e)),a&&(u.taps<2&&(t=l[0],e=setTimeout((function(){e=null}),500)),xl(this),u.start())}}function j(e,...t){if(this.__zooming){var n,o,r,s,i=b(this,t).event(e),l=e.changedTouches,d=l.length;for(eN(e),n=0;n<d;++n)r=Lk(o=l[n],this),i.touch0&&i.touch0[2]===o.identifier?i.touch0[0]=r:i.touch1&&i.touch1[2]===o.identifier&&(i.touch1[0]=r);if(o=i.that.__zoom,i.touch1){var u=i.touch0[0],h=i.touch0[1],f=i.touch1[0],m=i.touch1[1],p=(p=f[0]-u[0])*p+(p=f[1]-u[1])*p,x=(x=m[0]-h[0])*x+(x=m[1]-h[1])*x;o=g(o,Math.sqrt(p/x)),r=[(u[0]+f[0])/2,(u[1]+f[1])/2],s=[(h[0]+m[0])/2,(h[1]+m[1])/2]}else{if(!i.touch0)return;r=i.touch0[0],s=i.touch0[1]}i.zoom("touch",a(v(o,r,s),i.extent,c))}}function S(e,...o){if(this.__zooming){var r,a,s=b(this,o).event(e),i=e.changedTouches,l=i.length;for(Qk(e),n&&clearTimeout(n),n=setTimeout((function(){n=null}),500),r=0;r<l;++r)a=i[r],s.touch0&&s.touch0[2]===a.identifier?delete s.touch0:s.touch1&&s.touch1[2]===a.identifier&&delete s.touch1;if(s.touch1&&!s.touch0&&(s.touch0=s.touch1,delete s.touch1),s.touch0)s.touch0[1]=this.__zoom.invert(s.touch0[0]);else if(s.end(),2===s.taps&&(a=Lk(a,this),Math.hypot(t[0]-a[0],t[1]-a[1])<m)){var c=pl(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return p.transform=function(e,t,n,o){var r=e.selection?e.selection():e;r.property("__zoom",oN),e!==r?y(e,t,n,o):r.interrupt().each((function(){b(this,arguments).event(o).start().zoom(null,"function"==typeof t?t.apply(this,arguments):t).end()}))},p.scaleBy=function(e,t,n,o){p.scaleTo(e,(function(){return this.__zoom.k*("function"==typeof t?t.apply(this,arguments):t)}),n,o)},p.scaleTo=function(e,t,n,o){p.transform(e,(function(){var e=r.apply(this,arguments),o=this.__zoom,s=null==n?x(e):"function"==typeof n?n.apply(this,arguments):n,i=o.invert(s),l="function"==typeof t?t.apply(this,arguments):t;return a(v(g(o,l),s,i),e,c)}),n,o)},p.translateBy=function(e,t,n,o){p.transform(e,(function(){return a(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),r.apply(this,arguments),c)}),null,o)},p.translateTo=function(e,t,n,o,s){p.transform(e,(function(){var e=r.apply(this,arguments),s=this.__zoom,i=null==o?x(e):"function"==typeof o?o.apply(this,arguments):o;return a(gl.translate(i[0],i[1]).scale(s.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,c)}),o,s)},w.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(e,t){return this.mouse&&"mouse"!==e&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&"touch"!==e&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&"touch"!==e&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(e){var t=pl(this.that).datum();h.call(e,this.that,new Zk(e,{sourceEvent:this.sourceEvent,target:p,type:e,transform:this.that.__zoom,dispatch:h}),t)}},p.wheelDelta=function(e){return arguments.length?(s="function"==typeof e?e:Xk(+e),p):s},p.filter=function(e){return arguments.length?(o="function"==typeof e?e:Xk(!!e),p):o},p.touchable=function(e){return arguments.length?(i="function"==typeof e?e:Xk(!!e),p):i},p.extent=function(e){return arguments.length?(r="function"==typeof e?e:Xk([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),p):r},p.scaleExtent=function(e){return arguments.length?(l[0]=+e[0],l[1]=+e[1],p):[l[0],l[1]]},p.translateExtent=function(e){return arguments.length?(c[0][0]=+e[0][0],c[1][0]=+e[1][0],c[0][1]=+e[0][1],c[1][1]=+e[1][1],p):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},p.constrain=function(e){return arguments.length?(a=e,p):a},p.duration=function(e){return arguments.length?(d=+e,p):d},p.interpolate=function(e){return arguments.length?(u=e,p):u},p.on=function(){var e=h.on.apply(h,arguments);return e===h?p:e},p.clickDistance=function(e){return arguments.length?(f=(e=+e)*e,p):Math.sqrt(f)},p.tapDistance=function(e){return arguments.length?(m=+e,p):m},p}().scaleExtent([g,v]).translateExtent(p),n=pl(S.current).call(t),o=gl.translate(m.x,m.y).scale(CN(m.zoom,g,v)),r=[[0,0],[e.width,e.height]],a=t.constrain()(o,r,p);t.transform(n,a),t.wheelDelta(AC),E.setState({d3Zoom:t,d3Selection:n,d3ZoomHandler:n.on("wheel.zoom"),transform:[a.x,a.y,a.k],domNode:S.current.closest(".react-flow")})}}),[]),r.useEffect((()=>{M&&A&&(!i||D||O?void 0!==T&&M.on("wheel.zoom",(function(e,t){if(!y&&"wheel"===e.type&&!e.ctrlKey||SC(e,w))return null;e.preventDefault(),T.call(this,e,t)}),{passive:!1}):M.on("wheel.zoom",(o=>{if(SC(o,w))return!1;o.preventDefault(),o.stopImmediatePropagation();const r=M.property("__zoom").k||1;if(o.ctrlKey&&s){const e=Lk(o),t=AC(o),n=r*Math.pow(2,t);return void A.scaleTo(M,n,e,o)}const a=1===o.deltaMode?20:1;let i=c===WN.Vertical?0:o.deltaX*a,d=c===WN.Horizontal?0:o.deltaY*a;!zN()&&o.shiftKey&&c!==WN.Vertical&&(i=o.deltaY*a,d=0),A.translateBy(M,-i/r*l,-d/r*l,{internal:!0});const u=jC(M.property("__zoom")),{onViewportChangeStart:h,onViewportChange:f,onViewportChangeEnd:m}=E.getState();clearTimeout(R.current),P.current||(P.current=!0,null==t||t(o,u),null==h||h(u)),P.current&&(null==e||e(o,u),null==f||f(u),R.current=setTimeout((()=>{null==n||n(o,u),null==m||m(u),P.current=!1}),150))}),{passive:!1}))}),[O,i,c,M,A,T,D,s,y,w,t,e,n]),r.useEffect((()=>{A&&A.on("start",(e=>{var n,o;if(!e.sourceEvent||e.sourceEvent.internal)return null;_.current=null==(n=e.sourceEvent)?void 0:n.button;const{onViewportChangeStart:r}=E.getState(),a=jC(e.transform);C.current=!0,I.current=a,"mousedown"===(null==(o=e.sourceEvent)?void 0:o.type)&&E.setState({paneDragging:!0}),null==r||r(a),null==t||t(e.sourceEvent,a)}))}),[A,t]),r.useEffect((()=>{A&&(O&&!C.current?A.on("zoom",null):O||A.on("zoom",(t=>{var n;const{onViewportChange:r}=E.getState();if(E.setState({transform:[t.transform.x,t.transform.y,t.transform.k]}),j.current=!(!o||!IC(f,_.current??0)),(e||r)&&!(null==(n=t.sourceEvent)?void 0:n.internal)){const n=jC(t.transform);null==r||r(n),null==e||e(t.sourceEvent,n)}})))}),[O,A,e,f,o]),r.useEffect((()=>{A&&A.on("end",(e=>{if(!e.sourceEvent||e.sourceEvent.internal)return null;const{onViewportChangeEnd:t}=E.getState();if(C.current=!1,E.setState({paneDragging:!1}),o&&IC(f,_.current??0)&&!j.current&&o(e.sourceEvent),j.current=!1,(n||t)&&(r=I.current,a=e.transform,r.x!==a.x||r.y!==a.y||r.zoom!==a.k)){const o=jC(e.transform);I.current=o,clearTimeout(N.current),N.current=setTimeout((()=>{null==t||t(o),null==n||n(e.sourceEvent,o)}),i?150:0)}var r,a}))}),[A,i,f,n,o]),r.useEffect((()=>{A&&A.filter((e=>{const t=D||a,n=s&&e.ctrlKey;if((!0===f||Array.isArray(f)&&f.includes(1))&&1===e.button&&"mousedown"===e.type&&(SC(e,"react-flow__node")||SC(e,"react-flow__edge")))return!0;if(!(f||t||i||d||s))return!1;if(O)return!1;if(!d&&"dblclick"===e.type)return!1;if(SC(e,w)&&"wheel"===e.type)return!1;if(SC(e,k)&&("wheel"!==e.type||i&&"wheel"===e.type&&!D))return!1;if(!s&&e.ctrlKey&&"wheel"===e.type)return!1;if(!t&&!i&&!n&&"wheel"===e.type)return!1;if(!f&&("mousedown"===e.type||"touchstart"===e.type))return!1;if(Array.isArray(f)&&!f.includes(e.button)&&"mousedown"===e.type)return!1;const o=Array.isArray(f)&&f.includes(e.button)||!e.button||e.button<=1;return(!e.ctrlKey||"wheel"===e.type)&&o}))}),[O,A,a,s,i,d,f,h,D]),u.createElement("div",{className:"react-flow__renderer",ref:S,style:CC},b)},OC=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function DC(){const{userSelectionActive:e,userSelectionRect:t}=xN(OC,Fk);return e&&t?u.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function _C(e,t){const n=t.parentNode||t.parentId,o=e.find((e=>e.id===n));if(o){const e=t.position.x+t.width-o.width,n=t.position.y+t.height-o.height;if(e>0||n>0||t.position.x<0||t.position.y<0){if(o.style={...o.style},o.style.width=o.style.width??o.width,o.style.height=o.style.height??o.height,e>0&&(o.style.width+=e),n>0&&(o.style.height+=n),t.position.x<0){const e=Math.abs(t.position.x);o.position.x=o.position.x-e,o.style.width+=e,t.position.x=0}if(t.position.y<0){const e=Math.abs(t.position.y);o.position.y=o.position.y-e,o.style.height+=e,t.position.y=0}o.width=o.style.width,o.height=o.style.height}}}function PC(e,t){if(e.some((e=>"reset"===e.type)))return e.filter((e=>"reset"===e.type)).map((e=>e.item));const n=e.filter((e=>"add"===e.type)).map((e=>e.item));return t.reduce(((t,n)=>{const o=e.filter((e=>e.id===n.id));if(0===o.length)return t.push(n),t;const r={...n};for(const e of o)if(e)switch(e.type){case"select":r.selected=e.selected;break;case"position":void 0!==e.position&&(r.position=e.position),void 0!==e.positionAbsolute&&(r.positionAbsolute=e.positionAbsolute),void 0!==e.dragging&&(r.dragging=e.dragging),r.expandParent&&_C(t,r);break;case"dimensions":void 0!==e.dimensions&&(r.width=e.dimensions.width,r.height=e.dimensions.height),void 0!==e.updateStyle&&(r.style={...r.style||{},...e.dimensions}),"boolean"==typeof e.resizing&&(r.resizing=e.resizing),r.expandParent&&_C(t,r);break;case"remove":return t}return t.push(r),t}),n)}function RC(e,t){return PC(e,t)}const FC=(e,t)=>({id:e,type:"select",selected:t});function LC(e,t){return e.reduce(((e,n)=>{const o=t.includes(n.id);return!n.selected&&o?(n.selected=!0,e.push(FC(n.id,!0))):n.selected&&!o&&(n.selected=!1,e.push(FC(n.id,!1))),e}),[])}const zC=(e,t)=>n=>{n.target===t.current&&(null==e||e(n))},BC=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),UC=r.memo((({isSelecting:e,selectionMode:t=YN.Full,panOnDrag:n,onSelectionStart:o,onSelectionEnd:a,onPaneClick:s,onPaneContextMenu:i,onPaneScroll:l,onPaneMouseEnter:c,onPaneMouseMove:d,onPaneMouseLeave:h,children:f})=>{const m=r.useRef(null),p=yN(),g=r.useRef(0),v=r.useRef(0),x=r.useRef(),{userSelectionActive:y,elementsSelectable:b,dragging:w}=xN(BC,Fk),k=()=>{p.setState({userSelectionActive:!1,userSelectionRect:null}),g.current=0,v.current=0},N=e=>{null==s||s(e),p.getState().resetSelectedElements(),p.setState({nodesSelectionActive:!1})},E=l?e=>l(e):void 0,C=b&&(e||y);return u.createElement("div",{className:Tk(["react-flow__pane",{dragging:w,selection:e}]),onClick:C?void 0:zC(N,m),onContextMenu:zC((e=>{Array.isArray(n)&&(null==n?void 0:n.includes(2))?e.preventDefault():null==i||i(e)}),m),onWheel:zC(E,m),onMouseEnter:C?void 0:c,onMouseDown:C?t=>{const{resetSelectedElements:n,domNode:r}=p.getState();if(x.current=null==r?void 0:r.getBoundingClientRect(),!b||!e||0!==t.button||t.target!==m.current||!x.current)return;const{x:a,y:s}=LN(t,x.current);n(),p.setState({userSelectionRect:{width:0,height:0,startX:a,startY:s,x:a,y:s}}),null==o||o(t)}:void 0,onMouseMove:C?n=>{const{userSelectionRect:o,nodeInternals:r,edges:a,transform:s,onNodesChange:i,onEdgesChange:l,nodeOrigin:c,getNodes:d}=p.getState();if(!e||!x.current||!o)return;p.setState({userSelectionActive:!0,nodesSelectionActive:!1});const u=LN(n,x.current),h=o.startX??0,f=o.startY??0,m={...o,x:u.x<h?u.x:h,y:u.y<f?u.y:f,width:Math.abs(u.x-h),height:Math.abs(u.y-f)},y=d(),b=EE(r,m,s,t===YN.Partial,!0,c),w=CE(b,a).map((e=>e.id)),k=b.map((e=>e.id));if(g.current!==k.length){g.current=k.length;const e=LC(y,k);e.length&&(null==i||i(e))}if(v.current!==w.length){v.current=w.length;const e=LC(a,w);e.length&&(null==l||l(e))}p.setState({userSelectionRect:m})}:d,onMouseUp:C?e=>{if(0!==e.button)return;const{userSelectionRect:t}=p.getState();!y&&t&&e.target===m.current&&(null==N||N(e)),p.setState({nodesSelectionActive:g.current>0}),k(),null==a||a(e)}:void 0,onMouseLeave:C?e=>{y&&(p.setState({nodesSelectionActive:g.current>0}),null==a||a(e)),k()}:h,ref:m,style:CC},f,u.createElement(DC,null))}));function VC(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const o=t.get(n);return!!o&&(!!o.selected||VC(o,t))}function $C(e,t,n){let o=e;do{if(null==o?void 0:o.matches(t))return!0;if(o===n.current)return!1;o=o.parentElement}while(o);return!1}function GC(e,t,n,o){return Array.from(e.values()).filter((n=>(n.selected||n.id===o)&&(!n.parentNode||n.parentId||!VC(n,e))&&(n.draggable||t&&void 0===n.draggable))).map((e=>{var t,o;return{id:e.id,position:e.position||{x:0,y:0},positionAbsolute:e.positionAbsolute||{x:0,y:0},distance:{x:n.x-((null==(t=e.positionAbsolute)?void 0:t.x)??0),y:n.y-((null==(o=e.positionAbsolute)?void 0:o.y)??0)},delta:{x:0,y:0},extent:e.extent,parentNode:e.parentNode||e.parentId,parentId:e.parentNode||e.parentId,width:e.width,height:e.height,expandParent:e.expandParent}}))}function HC(e,t,n,o,r=[0,0],a){const s=function(e,t){return t&&"parent"!==t?[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]:t}(e,e.extent||o);let i=s;const l=e.parentNode||e.parentId;if("parent"!==e.extent||e.expandParent){if(e.extent&&l&&"parent"!==e.extent){const t=n.get(l),{x:o,y:a}=kE(t,r).positionAbsolute;i=[[e.extent[0][0]+o,e.extent[0][1]+a],[e.extent[1][0]+o,e.extent[1][1]+a]]}}else if(l&&e.width&&e.height){const t=n.get(l),{x:o,y:a}=kE(t,r).positionAbsolute;i=t&&DN(o)&&DN(a)&&DN(t.width)&&DN(t.height)?[[o+e.width*r[0],a+e.height*r[1]],[o+t.width-e.width+e.width*r[0],a+t.height-e.height+e.height*r[1]]]:i}else null==a||a("005",uN()),i=s;let c={x:0,y:0};if(l){const e=n.get(l);c=kE(e,r).positionAbsolute}const d=i&&"parent"!==i?jN(t,i):t;return{position:{x:d.x-c.x,y:d.y-c.y},positionAbsolute:d}}function WC({nodeId:e,dragItems:t,nodeInternals:n}){const o=t.map((e=>({...n.get(e.id),position:e.position,positionAbsolute:e.positionAbsolute})));return[e?o.find((t=>t.id===e)):o[0],o]}UC.displayName="Pane";const qC=(e,t,n,o)=>{const r=t.querySelectorAll(e);if(!r||!r.length)return null;const a=Array.from(r),s=t.getBoundingClientRect(),i=s.width*o[0],l=s.height*o[1];return a.map((e=>{const t=e.getBoundingClientRect();return{id:e.getAttribute("data-handleid"),position:e.getAttribute("data-handlepos"),x:(t.left-s.left-i)/n,y:(t.top-s.top-l)/n,...EN(e)}}))};function YC(e,t,n){return void 0===n?n:o=>{const r=t().nodeInternals.get(e);r&&n(o,{...r})}}function JC({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:a,multiSelectionActive:s,nodeInternals:i,onError:l}=t.getState(),c=i.get(e);c?(t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&s)&&(a({nodes:[c],edges:[]}),requestAnimationFrame((()=>{var e;return null==(e=null==o?void 0:o.current)?void 0:e.blur()}))):r([e])):null==l||l("012",gN(e))}function KC(e){return(t,n,o)=>null==e?void 0:e(t,o)}function XC({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:a,isSelectable:s,selectNodesOnDrag:i}){const l=yN(),[c,d]=r.useState(!1),u=r.useRef([]),h=r.useRef({x:null,y:null}),f=r.useRef(0),m=r.useRef(null),p=r.useRef({x:0,y:0}),g=r.useRef(null),v=r.useRef(!1),x=r.useRef(!1),y=r.useRef(!1),b=function(){const e=yN();return r.useCallback((({sourceEvent:t})=>{const{transform:n,snapGrid:o,snapToGrid:r}=e.getState(),a=t.touches?t.touches[0].clientX:t.clientX,s=t.touches?t.touches[0].clientY:t.clientY,i={x:(a-n[0])/n[2],y:(s-n[1])/n[2]};return{xSnapped:r?o[0]*Math.round(i.x/o[0]):i.x,ySnapped:r?o[1]*Math.round(i.y/o[1]):i.y,...i}}),[])}();return r.useEffect((()=>{if(null==e?void 0:e.current){const r=pl(e.current),c=({x:e,y:t})=>{const{nodeInternals:n,onNodeDrag:o,onSelectionDrag:r,updateNodePositions:s,nodeExtent:i,snapGrid:c,snapToGrid:f,nodeOrigin:m,onError:p}=l.getState();h.current={x:e,y:t};let v=!1,x={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&i){const e=NE(u.current,m);x=MN(e)}if(u.current=u.current.map((o=>{const r={x:e-o.distance.x,y:t-o.distance.y};f&&(r.x=c[0]*Math.round(r.x/c[0]),r.y=c[1]*Math.round(r.y/c[1]));const a=[[i[0][0],i[0][1]],[i[1][0],i[1][1]]];u.current.length>1&&i&&!o.extent&&(a[0][0]=o.positionAbsolute.x-x.x+i[0][0],a[1][0]=o.positionAbsolute.x+(o.width??0)-x.x2+i[1][0],a[0][1]=o.positionAbsolute.y-x.y+i[0][1],a[1][1]=o.positionAbsolute.y+(o.height??0)-x.y2+i[1][1]);const s=HC(o,r,n,a,m,p);return v=v||o.position.x!==s.position.x||o.position.y!==s.position.y,o.position=s.position,o.positionAbsolute=s.positionAbsolute,o})),!v)return;s(u.current,!0,!0),d(!0);const y=a?o:KC(r);if(y&&g.current){const[e,t]=WC({nodeId:a,dragItems:u.current,nodeInternals:n});y(g.current,e,t)}},w=()=>{if(!m.current)return;const[e,t]=IN(p.current,m.current);if(0!==e||0!==t){const{transform:n,panBy:o}=l.getState();h.current.x=(h.current.x??0)-e/n[2],h.current.y=(h.current.y??0)-t/n[2],o({x:e,y:t})&&c(h.current)}f.current=requestAnimationFrame(w)},k=t=>{var n;const{nodeInternals:o,multiSelectionActive:r,nodesDraggable:c,unselectNodesAndEdges:d,onNodeDragStart:f,onSelectionDragStart:m}=l.getState();x.current=!0;const p=a?f:KC(m);i&&s||r||!a||(null==(n=o.get(a))?void 0:n.selected)||d(),a&&s&&i&&JC({id:a,store:l,nodeRef:e});const g=b(t);if(h.current=g,u.current=GC(o,c,g,a),p&&u.current){const[e,n]=WC({nodeId:a,dragItems:u.current,nodeInternals:o});p(t.sourceEvent,e,n)}};if(!t){const t=function(){var e,t,n,o,r=qk,a=Yk,s=Jk,i=Kk,l={},c=yl("start","drag","end"),d=0,u=0;function h(e){e.on("mousedown.drag",f).filter(i).on("touchstart.drag",g).on("touchmove.drag",v,zk).on("touchend.drag touchcancel.drag",x).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(s,i){if(!o&&r.call(this,s,i)){var l=y(this,a.call(this,s,i),s,i,"mouse");l&&(pl(s.view).on("mousemove.drag",m,Bk).on("mouseup.drag",p,Bk),$k(s.view),Uk(s),n=!1,e=s.clientX,t=s.clientY,l("start",s))}}function m(o){if(Vk(o),!n){var r=o.clientX-e,a=o.clientY-t;n=r*r+a*a>u}l.mouse("drag",o)}function p(e){pl(e.view).on("mousemove.drag mouseup.drag",null),Gk(e.view,n),Vk(e),l.mouse("end",e)}function g(e,t){if(r.call(this,e,t)){var n,o,s=e.changedTouches,i=a.call(this,e,t),l=s.length;for(n=0;n<l;++n)(o=y(this,i,e,t,s[n].identifier,s[n]))&&(Uk(e),o("start",e,s[n]))}}function v(e){var t,n,o=e.changedTouches,r=o.length;for(t=0;t<r;++t)(n=l[o[t].identifier])&&(Vk(e),n("drag",e,o[t]))}function x(e){var t,n,r=e.changedTouches,a=r.length;for(o&&clearTimeout(o),o=setTimeout((function(){o=null}),500),t=0;t<a;++t)(n=l[r[t].identifier])&&(Uk(e),n("end",e,r[t]))}function y(e,t,n,o,r,a){var i,u,f,m=c.copy(),p=Lk(a||n,t);if(null!=(f=s.call(e,new Wk("beforestart",{sourceEvent:n,target:h,identifier:r,active:d,x:p[0],y:p[1],dx:0,dy:0,dispatch:m}),o)))return i=f.x-p[0]||0,u=f.y-p[1]||0,function n(a,s,c){var g,v=p;switch(a){case"start":l[r]=n,g=d++;break;case"end":delete l[r],--d;case"drag":p=Lk(c||s,t),g=d}m.call(a,e,new Wk(a,{sourceEvent:s,subject:f,target:h,identifier:r,active:g,x:p[0]+i,y:p[1]+u,dx:p[0]-v[0],dy:p[1]-v[1],dispatch:m}),o)}}return h.filter=function(e){return arguments.length?(r="function"==typeof e?e:Hk(!!e),h):r},h.container=function(e){return arguments.length?(a="function"==typeof e?e:Hk(e),h):a},h.subject=function(e){return arguments.length?(s="function"==typeof e?e:Hk(e),h):s},h.touchable=function(e){return arguments.length?(i="function"==typeof e?e:Hk(!!e),h):i},h.on=function(){var e=c.on.apply(c,arguments);return e===c?h:e},h.clickDistance=function(e){return arguments.length?(u=(e=+e)*e,h):Math.sqrt(u)},h}().on("start",(e=>{const{domNode:t,nodeDragThreshold:n}=l.getState();0===n&&k(e),y.current=!1;const o=b(e);h.current=o,m.current=(null==t?void 0:t.getBoundingClientRect())||null,p.current=LN(e.sourceEvent,m.current)})).on("drag",(e=>{var t,n;const o=b(e),{autoPanOnNodeDrag:r,nodeDragThreshold:a}=l.getState();if("touchmove"===e.sourceEvent.type&&e.sourceEvent.touches.length>1&&(y.current=!0),!y.current){if(!v.current&&x.current&&r&&(v.current=!0,w()),!x.current){const r=o.xSnapped-((null==(t=null==h?void 0:h.current)?void 0:t.x)??0),s=o.ySnapped-((null==(n=null==h?void 0:h.current)?void 0:n.y)??0);Math.sqrt(r*r+s*s)>a&&k(e)}(h.current.x!==o.xSnapped||h.current.y!==o.ySnapped)&&u.current&&x.current&&(g.current=e.sourceEvent,p.current=LN(e.sourceEvent,m.current),c(o))}})).on("end",(e=>{if(x.current&&!y.current&&(d(!1),v.current=!1,x.current=!1,cancelAnimationFrame(f.current),u.current)){const{updateNodePositions:t,nodeInternals:n,onNodeDragStop:o,onSelectionDragStop:r}=l.getState(),s=a?o:KC(r);if(t(u.current,!1,!1),s){const[t,o]=WC({nodeId:a,dragItems:u.current,nodeInternals:n});s(e.sourceEvent,t,o)}}})).filter((t=>{const r=t.target;return!t.button&&(!n||!$C(r,`.${n}`,e))&&(!o||$C(r,o,e))}));return r.call(t),()=>{r.on(".drag",null)}}r.on(".drag",null)}}),[e,t,n,o,s,l,a,i,b]),c}function ZC(){const e=yN();return r.useCallback((t=>{const{nodeInternals:n,nodeExtent:o,updateNodePositions:r,getNodes:a,snapToGrid:s,snapGrid:i,onError:l,nodesDraggable:c}=e.getState(),d=a().filter((e=>e.selected&&(e.draggable||c&&void 0===e.draggable))),u=s?i[0]:5,h=s?i[1]:5,f=t.isShiftPressed?4:1,m=t.x*u*f,p=t.y*h*f;r(d.map((e=>{if(e.positionAbsolute){const t={x:e.positionAbsolute.x+m,y:e.positionAbsolute.y+p};s&&(t.x=i[0]*Math.round(t.x/i[0]),t.y=i[1]*Math.round(t.y/i[1]));const{positionAbsolute:r,position:a}=HC(e,t,n,o,void 0,l);e.position=a,e.positionAbsolute=r}return e})),!0,!1)}),[])}const QC={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var ej=e=>{const t=({id:t,type:n,data:o,xPos:a,yPos:s,xPosOrigin:i,yPosOrigin:l,selected:c,onClick:d,onMouseEnter:h,onMouseMove:f,onMouseLeave:m,onContextMenu:p,onDoubleClick:g,style:v,className:x,isDraggable:y,isSelectable:b,isConnectable:w,isFocusable:k,selectNodesOnDrag:N,sourcePosition:E,targetPosition:C,hidden:j,resizeObserver:S,dragHandle:I,zIndex:A,isParent:M,noDragClassName:T,noPanClassName:O,initialized:D,disableKeyboardA11y:_,ariaLabel:P,rfId:R,hasHandleBounds:F})=>{const L=yN(),z=r.useRef(null),B=r.useRef(null),U=r.useRef(E),V=r.useRef(C),$=r.useRef(n),G=b||y||d||h||f||m,H=ZC(),W=YC(t,L.getState,h),q=YC(t,L.getState,f),Y=YC(t,L.getState,m),J=YC(t,L.getState,p),K=YC(t,L.getState,g);r.useEffect((()=>()=>{B.current&&(null==S||S.unobserve(B.current),B.current=null)}),[]),r.useEffect((()=>{if(z.current&&!j){const e=z.current;D&&F&&B.current===e||(B.current&&(null==S||S.unobserve(B.current)),null==S||S.observe(e),B.current=e)}}),[j,D,F]),r.useEffect((()=>{const e=$.current!==n,o=U.current!==E,r=V.current!==C;z.current&&(e||o||r)&&(e&&($.current=n),o&&(U.current=E),r&&(V.current=C),L.getState().updateNodeDimensions([{id:t,nodeElement:z.current,forceUpdate:!0}]))}),[t,n,E,C]);const X=XC({nodeRef:z,disabled:j||!y,noDragClassName:T,handleSelector:I,nodeId:t,isSelectable:b,selectNodesOnDrag:N});return j?null:u.createElement("div",{className:Tk(["react-flow__node",`react-flow__node-${n}`,{[O]:y},x,{selected:c,selectable:b,parent:M,dragging:X}]),ref:z,style:{zIndex:A,transform:`translate(${i}px,${l}px)`,pointerEvents:G?"all":"none",visibility:D?"visible":"hidden",...v},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:W,onMouseMove:q,onMouseLeave:Y,onContextMenu:J,onClick:e=>{const{nodeDragThreshold:n}=L.getState();if(b&&(!N||!y||n>0)&&JC({id:t,store:L,nodeRef:z}),d){const n=L.getState().nodeInternals.get(t);n&&d(e,{...n})}},onDoubleClick:K,onKeyDown:k?e=>{if(!RN(e)&&!_)if(PN.includes(e.key)&&b){const n="Escape"===e.key;JC({id:t,store:L,unselect:n,nodeRef:z})}else y&&c&&Object.prototype.hasOwnProperty.call(QC,e.key)&&(L.setState({ariaLiveMessage:`Moved selected node ${e.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~a}, y: ${~~s}`}),H({x:QC[e.key].x,y:QC[e.key].y,isShiftPressed:e.shiftKey}))}:void 0,tabIndex:k?0:void 0,role:k?"button":void 0,"aria-describedby":_?void 0:`${aC}-${R}`,"aria-label":P},u.createElement(vE,{value:t},u.createElement(e,{id:t,data:o,type:n,xPos:a,yPos:s,selected:c,isConnectable:w,sourcePosition:E,targetPosition:C,dragging:X,dragHandle:I,zIndex:A})))};return t.displayName="NodeWrapper",r.memo(t)};const tj=e=>{const t=e.getNodes().filter((e=>e.selected));return{...NE(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};var nj=r.memo((function({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=yN(),{width:a,height:s,x:i,y:l,transformString:c,userSelectionActive:d}=xN(tj,Fk),h=ZC(),f=r.useRef(null);if(r.useEffect((()=>{var e;n||null==(e=f.current)||e.focus({preventScroll:!0})}),[n]),XC({nodeRef:f}),d||!a||!s)return null;const m=e?t=>{const n=o.getState().getNodes().filter((e=>e.selected));e(t,n)}:void 0;return u.createElement("div",{className:Tk(["react-flow__nodesselection","react-flow__container",t]),style:{transform:c}},u.createElement("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:m,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(QC,e.key)&&h({x:QC[e.key].x,y:QC[e.key].y,isShiftPressed:e.shiftKey})},style:{width:a,height:s,top:l,left:i}}))}));const oj=e=>e.nodesSelectionActive,rj=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:a,onPaneContextMenu:s,onPaneScroll:i,deleteKeyCode:l,onMove:c,onMoveStart:d,onMoveEnd:h,selectionKeyCode:f,selectionOnDrag:m,selectionMode:p,onSelectionStart:g,onSelectionEnd:v,multiSelectionKeyCode:x,panActivationKeyCode:y,zoomActivationKeyCode:b,elementsSelectable:w,zoomOnScroll:k,zoomOnPinch:N,panOnScroll:E,panOnScrollSpeed:C,panOnScrollMode:j,zoomOnDoubleClick:S,panOnDrag:I,defaultViewport:A,translateExtent:M,minZoom:T,maxZoom:O,preventScrolling:D,onSelectionContextMenu:_,noWheelClassName:P,noPanClassName:R,disableKeyboardA11y:F})=>{const L=xN(oj),z=dC(f),B=dC(y),U=B||I,V=B||E,$=z||m&&!0!==U;return(({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=yN(),{deleteElements:o}=NC(),a=dC(e,EC),s=dC(t);r.useEffect((()=>{if(a){const{edges:e,getNodes:t}=n.getState(),r=t().filter((e=>e.selected)),a=e.filter((e=>e.selected));o({nodes:r,edges:a}),n.setState({nodesSelectionActive:!1})}}),[a]),r.useEffect((()=>{n.setState({multiSelectionActive:s})}),[s])})({deleteKeyCode:l,multiSelectionKeyCode:x}),u.createElement(TC,{onMove:c,onMoveStart:d,onMoveEnd:h,onPaneContextMenu:s,elementsSelectable:w,zoomOnScroll:k,zoomOnPinch:N,panOnScroll:V,panOnScrollSpeed:C,panOnScrollMode:j,zoomOnDoubleClick:S,panOnDrag:!z&&U,defaultViewport:A,translateExtent:M,minZoom:T,maxZoom:O,zoomActivationKeyCode:b,preventScrolling:D,noWheelClassName:P,noPanClassName:R},u.createElement(UC,{onSelectionStart:g,onSelectionEnd:v,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:a,onPaneContextMenu:s,onPaneScroll:i,panOnDrag:U,isSelecting:!!$,selectionMode:p},e,L&&u.createElement(nj,{onSelectionContextMenu:_,noPanClassName:R,disableKeyboardA11y:F})))};rj.displayName="FlowRenderer";var aj=r.memo(rj);function sj(e){return{...{input:ej(e.input||$E),default:ej(e.default||UE),output:ej(e.output||HE),group:ej(e.group||WE)},...Object.keys(e).filter((e=>!["input","default","output","group"].includes(e))).reduce(((t,n)=>(t[n]=ej(e[n]||UE),t)),{})}}const ij=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),lj=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:a,updateNodeDimensions:s,onError:i}=xN(ij,Fk),l=(c=e.onlyRenderVisibleElements,xN(r.useCallback((e=>c?EE(e.nodeInternals,{x:0,y:0,width:e.width,height:e.height},e.transform,!0):e.getNodes()),[c])));var c;const d=r.useRef(),h=r.useMemo((()=>{if("undefined"==typeof ResizeObserver)return null;const e=new ResizeObserver((e=>{const t=e.map((e=>({id:e.target.getAttribute("data-id"),nodeElement:e.target,forceUpdate:!0})));s(t)}));return d.current=e,e}),[]);return r.useEffect((()=>()=>{var e;null==(e=null==d?void 0:d.current)||e.disconnect()}),[]),u.createElement("div",{className:"react-flow__nodes",style:CC},l.map((r=>{var s,l,c;let d=r.type||"default";e.nodeTypes[d]||(null==i||i("003",cN(d)),d="default");const f=e.nodeTypes[d]||e.nodeTypes.default,m=!!(r.draggable||t&&void 0===r.draggable),p=!!(r.selectable||a&&void 0===r.selectable),g=!!(r.connectable||n&&void 0===r.connectable),v=!!(r.focusable||o&&void 0===r.focusable),x=e.nodeExtent?jN(r.positionAbsolute,e.nodeExtent):r.positionAbsolute,y=(null==x?void 0:x.x)??0,b=(null==x?void 0:x.y)??0,w=(({x:e,y:t,width:n,height:o,origin:r})=>n&&o?r[0]<0||r[1]<0||r[0]>1||r[1]>1?{x:e,y:t}:{x:e-n*r[0],y:t-o*r[1]}:{x:e,y:t})({x:y,y:b,width:r.width??0,height:r.height??0,origin:e.nodeOrigin});return u.createElement(f,{key:r.id,id:r.id,className:r.className,style:r.style,type:d,data:r.data,sourcePosition:r.sourcePosition||eE.Bottom,targetPosition:r.targetPosition||eE.Top,hidden:r.hidden,xPos:y,yPos:b,xPosOrigin:w.x,yPosOrigin:w.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!r.selected,isDraggable:m,isSelectable:p,isConnectable:g,isFocusable:v,resizeObserver:h,dragHandle:r.dragHandle,zIndex:(null==(s=r[_N])?void 0:s.z)??0,isParent:!!(null==(l=r[_N])?void 0:l.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!r.width&&!!r.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:r.ariaLabel,hasHandleBounds:!!(null==(c=r[_N])?void 0:c.handleBounds)})})))};lj.displayName="NodeRenderer";var cj=r.memo(lj);const dj=(e,t,n)=>n===eE.Left?e-t:n===eE.Right?e+t:e,uj=(e,t,n)=>n===eE.Top?e-t:n===eE.Bottom?e+t:e,hj="react-flow__edgeupdater",fj=({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:a,onMouseOut:s,type:i})=>u.createElement("circle",{onMouseDown:r,onMouseEnter:a,onMouseOut:s,className:Tk([hj,`${hj}-${i}`]),cx:dj(t,o,e),cy:uj(n,o,e),r:o,stroke:"transparent",fill:"transparent"}),mj=()=>!0;var pj=e=>{const t=({id:t,className:n,type:o,data:a,onClick:s,onEdgeDoubleClick:i,selected:l,animated:c,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:m,labelBgPadding:p,labelBgBorderRadius:g,style:v,source:x,target:y,sourceX:b,sourceY:w,targetX:k,targetY:N,sourcePosition:E,targetPosition:C,elementsSelectable:j,hidden:S,sourceHandleId:I,targetHandleId:A,onContextMenu:M,onMouseEnter:T,onMouseMove:O,onMouseLeave:D,reconnectRadius:_,onReconnect:P,onReconnectStart:R,onReconnectEnd:F,markerEnd:L,markerStart:z,rfId:B,ariaLabel:U,isFocusable:V,isReconnectable:$,pathOptions:G,interactionWidth:H,disableKeyboardA11y:W})=>{const q=r.useRef(null),[Y,J]=r.useState(!1),[K,X]=r.useState(!1),Z=yN(),Q=r.useMemo((()=>`url('#${yE(z,B)}')`),[z,B]),ee=r.useMemo((()=>`url('#${yE(L,B)}')`),[L,B]);if(S)return null;const te=UN(t,Z.getState,i),ne=UN(t,Z.getState,M),oe=UN(t,Z.getState,T),re=UN(t,Z.getState,O),ae=UN(t,Z.getState,D),se=(e,n)=>{if(0!==e.button)return;const{edges:o,isValidConnection:r}=Z.getState(),a=n?y:x,s=(n?A:I)||null,i=n?"target":"source",l=r||mj,c=n,d=o.find((e=>e.id===t));X(!0),null==R||R(e,d,i);PE({event:e,handleId:s,nodeId:a,onConnect:e=>null==P?void 0:P(d,e),isTarget:c,getState:Z.getState,setState:Z.setState,isValidConnection:l,edgeUpdaterType:i,onReconnectEnd:e=>{X(!1),null==F||F(e,d,i)}})},ie=()=>J(!0),le=()=>J(!1),ce=!j&&!s;return u.createElement("g",{className:Tk(["react-flow__edge",`react-flow__edge-${o}`,n,{selected:l,animated:c,inactive:ce,updating:Y}]),onClick:e=>{var n;const{edges:o,addSelectedEdges:r,unselectNodesAndEdges:a,multiSelectionActive:i}=Z.getState(),l=o.find((e=>e.id===t));l&&(j&&(Z.setState({nodesSelectionActive:!1}),l.selected&&i?(a({nodes:[],edges:[l]}),null==(n=q.current)||n.blur()):r([t])),s&&s(e,l))},onDoubleClick:te,onContextMenu:ne,onMouseEnter:oe,onMouseMove:re,onMouseLeave:ae,onKeyDown:V?e=>{var n;if(!W&&PN.includes(e.key)&&j){const{unselectNodesAndEdges:o,addSelectedEdges:r,edges:a}=Z.getState();"Escape"===e.key?(null==(n=q.current)||n.blur(),o({edges:[a.find((e=>e.id===t))]})):r([t])}}:void 0,tabIndex:V?0:void 0,role:V?"button":"img","data-testid":`rf__edge-${t}`,"aria-label":null===U?void 0:U||`Edge from ${x} to ${y}`,"aria-describedby":V?`${sC}-${B}`:void 0,ref:q},!K&&u.createElement(e,{id:t,source:x,target:y,selected:l,animated:c,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:m,labelBgPadding:p,labelBgBorderRadius:g,data:a,style:v,sourceX:b,sourceY:w,targetX:k,targetY:N,sourcePosition:E,targetPosition:C,sourceHandleId:I,targetHandleId:A,markerStart:Q,markerEnd:ee,pathOptions:G,interactionWidth:H}),$&&u.createElement(u.Fragment,null,("source"===$||!0===$)&&u.createElement(fj,{position:E,centerX:b,centerY:w,radius:_,onMouseDown:e=>se(e,!0),onMouseEnter:ie,onMouseOut:le,type:"source"}),("target"===$||!0===$)&&u.createElement(fj,{position:C,centerX:k,centerY:N,radius:_,onMouseDown:e=>se(e,!1),onMouseEnter:ie,onMouseOut:le,type:"target"})))};return t.displayName="EdgeWrapper",r.memo(t)};function gj(e){return{...{default:pj(e.default||pE),straight:pj(e.bezier||uE),step:pj(e.step||dE),smoothstep:pj(e.step||cE),simplebezier:pj(e.simplebezier||rE)},...Object.keys(e).filter((e=>!["default","bezier"].includes(e))).reduce(((t,n)=>(t[n]=pj(e[n]||pE),t)),{})}}function vj(e,t,n=null){const o=((null==n?void 0:n.x)||0)+t.x,r=((null==n?void 0:n.y)||0)+t.y,a=(null==n?void 0:n.width)||t.width,s=(null==n?void 0:n.height)||t.height;switch(e){case eE.Top:return{x:o+a/2,y:r};case eE.Right:return{x:o+a,y:r+s/2};case eE.Bottom:return{x:o+a/2,y:r+s};case eE.Left:return{x:o,y:r+s/2}}}function xj(e,t){return e?1!==e.length&&t?t&&e.find((e=>e.id===t))||null:e[0]:null}function yj(e){var t,n,o,r,a;const s=(null==(t=null==e?void 0:e[_N])?void 0:t.handleBounds)||null,i=s&&(null==e?void 0:e.width)&&(null==e?void 0:e.height)&&void 0!==(null==(n=null==e?void 0:e.positionAbsolute)?void 0:n.x)&&void 0!==(null==(o=null==e?void 0:e.positionAbsolute)?void 0:o.y);return[{x:(null==(r=null==e?void 0:e.positionAbsolute)?void 0:r.x)||0,y:(null==(a=null==e?void 0:e.positionAbsolute)?void 0:a.y)||0,width:(null==e?void 0:e.width)||0,height:(null==e?void 0:e.height)||0},s,!!i]}const bj=[{level:0,isMaxLevel:!0,edges:[]}];function wj(e,t,n){return function(e,t,n=!1){let o=-1;const r=e.reduce(((e,r)=>{var a,s;const i=DN(r.zIndex);let l=i?r.zIndex:0;if(n){const e=t.get(r.target),n=t.get(r.source),o=r.selected||(null==e?void 0:e.selected)||(null==n?void 0:n.selected),c=Math.max((null==(a=null==n?void 0:n[_N])?void 0:a.z)||0,(null==(s=null==e?void 0:e[_N])?void 0:s.z)||0,1e3);l=(i?r.zIndex:0)+(o?c:0)}return e[l]?e[l].push(r):e[l]=[r],o=l>o?l:o,e}),{}),a=Object.entries(r).map((([e,t])=>{const n=+e;return{edges:t,level:n,isMaxLevel:n===o}}));return 0===a.length?bj:a}(xN(r.useCallback((n=>e?n.edges.filter((e=>{const o=t.get(e.source),r=t.get(e.target);return(null==o?void 0:o.width)&&(null==o?void 0:o.height)&&(null==r?void 0:r.width)&&(null==r?void 0:r.height)&&function({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:o,targetWidth:r,targetHeight:a,width:s,height:i,transform:l}){const c={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+r),y2:Math.max(e.y+o,t.y+a)};c.x===c.x2&&(c.x2+=1),c.y===c.y2&&(c.y2+=1);const d=MN({x:(0-l[0])/l[2],y:(0-l[1])/l[2],width:s/l[2],height:i/l[2]}),u=Math.max(0,Math.min(d.x2,c.x2)-Math.max(d.x,c.x)),h=Math.max(0,Math.min(d.y2,c.y2)-Math.max(d.y,c.y));return Math.ceil(u*h)>0}({sourcePos:o.positionAbsolute||{x:0,y:0},targetPos:r.positionAbsolute||{x:0,y:0},sourceWidth:o.width,sourceHeight:o.height,targetWidth:r.width,targetHeight:r.height,width:n.width,height:n.height,transform:n.transform})})):n.edges),[e,t])),t,n)}const kj={[ZN.Arrow]:({color:e="none",strokeWidth:t=1})=>u.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),[ZN.ArrowClosed]:({color:e="none",strokeWidth:t=1})=>u.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})};const Nj=({id:e,type:t,color:n,width:o=12.5,height:a=12.5,markerUnits:s="strokeWidth",strokeWidth:i,orient:l="auto-start-reverse"})=>{const c=function(e){const t=yN();return r.useMemo((()=>{var n,o;return Object.prototype.hasOwnProperty.call(kj,e)?kj[e]:(null==(o=(n=t.getState()).onError)||o.call(n,"009",hN(e)),null)}),[e])}(t);return c?u.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:l,refX:"0",refY:"0"},u.createElement(c,{color:n,strokeWidth:i})):null},Ej=({defaultColor:e,rfId:t})=>{const n=xN(r.useCallback((({defaultColor:e,rfId:t})=>n=>{const o=[];return n.edges.reduce(((n,r)=>([r.markerStart,r.markerEnd].forEach((r=>{if(r&&"object"==typeof r){const a=yE(r,t);o.includes(a)||(n.push({id:a,color:r.color||e,...r}),o.push(a))}})),n)),[]).sort(((e,t)=>e.id.localeCompare(t.id)))})({defaultColor:e,rfId:t}),[e,t]),((e,t)=>!(e.length!==t.length||e.some(((e,n)=>e.id!==t[n].id)))));return u.createElement("defs",null,n.map((e=>u.createElement(Nj,{id:e.id,key:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient}))))};Ej.displayName="MarkerDefinitions";var Cj=r.memo(Ej);const jj=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),Sj=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:o,edgeTypes:r,noPanClassName:a,onEdgeContextMenu:s,onEdgeMouseEnter:i,onEdgeMouseMove:l,onEdgeMouseLeave:c,onEdgeClick:d,onEdgeDoubleClick:h,onReconnect:f,onReconnectStart:m,onReconnectEnd:p,reconnectRadius:g,children:v,disableKeyboardA11y:x})=>{const{edgesFocusable:y,edgesUpdatable:b,elementsSelectable:w,width:k,height:N,connectionMode:E,nodeInternals:C,onError:j}=xN(jj,Fk),S=wj(t,C,n);return k?u.createElement(u.Fragment,null,S.map((({level:t,edges:n,isMaxLevel:v})=>u.createElement("svg",{key:t,style:{zIndex:t},width:k,height:N,className:"react-flow__edges react-flow__container"},v&&u.createElement(Cj,{defaultColor:e,rfId:o}),u.createElement("g",null,n.map((e=>{const[t,n,v]=yj(C.get(e.source)),[k,N,S]=yj(C.get(e.target));if(!v||!S)return null;let I=e.type||"default";r[I]||(null==j||j("011",pN(I)),I="default");const A=r[I]||r.default,M=E===GN.Strict?N.target:(N.target??[]).concat(N.source??[]),T=xj(n.source,e.sourceHandle),O=xj(M,e.targetHandle),D=(null==T?void 0:T.position)||eE.Bottom,_=(null==O?void 0:O.position)||eE.Top,P=!!(e.focusable||y&&void 0===e.focusable),R=e.reconnectable||e.updatable,F=void 0!==f&&(R||b&&void 0===R);if(!T||!O)return null==j||j("008",fN(T,e)),null;const{sourceX:L,sourceY:z,targetX:B,targetY:U}=((e,t,n,o,r,a)=>{const s=vj(n,e,t),i=vj(a,o,r);return{sourceX:s.x,sourceY:s.y,targetX:i.x,targetY:i.y}})(t,T,D,k,O,_);return u.createElement(A,{key:e.id,id:e.id,className:Tk([e.className,a]),type:I,data:e.data,selected:!!e.selected,animated:!!e.animated,hidden:!!e.hidden,label:e.label,labelStyle:e.labelStyle,labelShowBg:e.labelShowBg,labelBgStyle:e.labelBgStyle,labelBgPadding:e.labelBgPadding,labelBgBorderRadius:e.labelBgBorderRadius,style:e.style,source:e.source,target:e.target,sourceHandleId:e.sourceHandle,targetHandleId:e.targetHandle,markerEnd:e.markerEnd,markerStart:e.markerStart,sourceX:L,sourceY:z,targetX:B,targetY:U,sourcePosition:D,targetPosition:_,elementsSelectable:w,onContextMenu:s,onMouseEnter:i,onMouseMove:l,onMouseLeave:c,onClick:d,onEdgeDoubleClick:h,onReconnect:f,onReconnectStart:m,onReconnectEnd:p,reconnectRadius:g,rfId:o,ariaLabel:e.ariaLabel,isFocusable:P,isReconnectable:F,pathOptions:"pathOptions"in e?e.pathOptions:void 0,interactionWidth:e.interactionWidth,disableKeyboardA11y:x})})))))),v):null};Sj.displayName="EdgeRenderer";var Ij=r.memo(Sj);const Aj=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Mj({children:e}){const t=xN(Aj);return u.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}const Tj={[eE.Left]:eE.Right,[eE.Right]:eE.Left,[eE.Top]:eE.Bottom,[eE.Bottom]:eE.Top},Oj=({nodeId:e,handleType:t,style:n,type:o=KN.Bezier,CustomComponent:a,connectionStatus:s})=>{var i,l,c;const{fromNode:d,handleId:h,toX:f,toY:m,connectionMode:p}=xN(r.useCallback((t=>({fromNode:t.nodeInternals.get(e),handleId:t.connectionHandleId,toX:(t.connectionPosition.x-t.transform[0])/t.transform[2],toY:(t.connectionPosition.y-t.transform[1])/t.transform[2],connectionMode:t.connectionMode})),[e]),Fk),g=null==(i=null==d?void 0:d[_N])?void 0:i.handleBounds;let v=null==g?void 0:g[t];if(p===GN.Loose&&(v=v||(null==g?void 0:g["source"===t?"target":"source"])),!d||!v)return null;const x=h?v.find((e=>e.id===h)):v[0],y=x?x.x+x.width/2:(d.width??0)/2,b=x?x.y+x.height/2:d.height??0,w=((null==(l=d.positionAbsolute)?void 0:l.x)??0)+y,k=((null==(c=d.positionAbsolute)?void 0:c.y)??0)+b,N=null==x?void 0:x.position,E=N?Tj[N]:null;if(!N||!E)return null;if(a)return u.createElement(a,{connectionLineType:o,connectionLineStyle:n,fromNode:d,fromHandle:x,fromX:w,fromY:k,toX:f,toY:m,fromPosition:N,toPosition:E,connectionStatus:s});let C="";const j={sourceX:w,sourceY:k,sourcePosition:N,targetX:f,targetY:m,targetPosition:E};return o===KN.Bezier?[C]=mE(j):o===KN.Step?[C]=lE({...j,borderRadius:0}):o===KN.SmoothStep?[C]=lE(j):o===KN.SimpleBezier?[C]=oE(j):C=`M${w},${k} ${f},${m}`,u.createElement("path",{d:C,fill:"none",className:"react-flow__connection-path",style:n})};Oj.displayName="ConnectionLine";const Dj=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function _j({containerStyle:e,style:t,type:n,component:o}){const{nodeId:r,handleType:a,nodesConnectable:s,width:i,height:l,connectionStatus:c}=xN(Dj,Fk);return!!(r&&a&&i&&s)?u.createElement("svg",{style:e,width:i,height:l,className:"react-flow__edges react-flow__connectionline react-flow__container"},u.createElement("g",{className:Tk(["react-flow__connection",c])},u.createElement(Oj,{nodeId:r,handleType:a,style:t,type:n,CustomComponent:o,connectionStatus:c}))):null}function Pj(e,t){r.useRef(null),yN();return r.useMemo((()=>t(e)),[e])}const Rj=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:o,onMoveEnd:a,onInit:s,onNodeClick:i,onEdgeClick:l,onNodeDoubleClick:c,onEdgeDoubleClick:d,onNodeMouseEnter:h,onNodeMouseMove:f,onNodeMouseLeave:m,onNodeContextMenu:p,onSelectionContextMenu:g,onSelectionStart:v,onSelectionEnd:x,connectionLineType:y,connectionLineStyle:b,connectionLineComponent:w,connectionLineContainerStyle:k,selectionKeyCode:N,selectionOnDrag:E,selectionMode:C,multiSelectionKeyCode:j,panActivationKeyCode:S,zoomActivationKeyCode:I,deleteKeyCode:A,onlyRenderVisibleElements:M,elementsSelectable:T,selectNodesOnDrag:O,defaultViewport:D,translateExtent:_,minZoom:P,maxZoom:R,preventScrolling:F,defaultMarkerColor:L,zoomOnScroll:z,zoomOnPinch:B,panOnScroll:U,panOnScrollSpeed:V,panOnScrollMode:$,zoomOnDoubleClick:G,panOnDrag:H,onPaneClick:W,onPaneMouseEnter:q,onPaneMouseMove:Y,onPaneMouseLeave:J,onPaneScroll:K,onPaneContextMenu:X,onEdgeContextMenu:Z,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:te,onReconnect:ne,onReconnectStart:oe,onReconnectEnd:re,reconnectRadius:ae,noDragClassName:se,noWheelClassName:ie,noPanClassName:le,elevateEdgesOnSelect:ce,disableKeyboardA11y:de,nodeOrigin:ue,nodeExtent:he,rfId:fe})=>{const me=Pj(e,sj),pe=Pj(t,gj);return function(e){const t=NC(),n=r.useRef(!1);r.useEffect((()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout((()=>e(t)),1),n.current=!0)}),[e,t.viewportInitialized])}(s),u.createElement(aj,{onPaneClick:W,onPaneMouseEnter:q,onPaneMouseMove:Y,onPaneMouseLeave:J,onPaneContextMenu:X,onPaneScroll:K,deleteKeyCode:A,selectionKeyCode:N,selectionOnDrag:E,selectionMode:C,onSelectionStart:v,onSelectionEnd:x,multiSelectionKeyCode:j,panActivationKeyCode:S,zoomActivationKeyCode:I,elementsSelectable:T,onMove:n,onMoveStart:o,onMoveEnd:a,zoomOnScroll:z,zoomOnPinch:B,zoomOnDoubleClick:G,panOnScroll:U,panOnScrollSpeed:V,panOnScrollMode:$,panOnDrag:H,defaultViewport:D,translateExtent:_,minZoom:P,maxZoom:R,onSelectionContextMenu:g,preventScrolling:F,noDragClassName:se,noWheelClassName:ie,noPanClassName:le,disableKeyboardA11y:de},u.createElement(Mj,null,u.createElement(Ij,{edgeTypes:pe,onEdgeClick:l,onEdgeDoubleClick:d,onlyRenderVisibleElements:M,onEdgeContextMenu:Z,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:te,onReconnect:ne,onReconnectStart:oe,onReconnectEnd:re,reconnectRadius:ae,defaultMarkerColor:L,noPanClassName:le,elevateEdgesOnSelect:!!ce,disableKeyboardA11y:de,rfId:fe},u.createElement(_j,{style:b,type:y,component:w,containerStyle:k})),u.createElement("div",{className:"react-flow__edgelabel-renderer"}),u.createElement(cj,{nodeTypes:me,onNodeClick:i,onNodeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:f,onNodeMouseLeave:m,onNodeContextMenu:p,selectNodesOnDrag:O,onlyRenderVisibleElements:M,noPanClassName:le,noDragClassName:se,disableKeyboardA11y:de,nodeOrigin:ue,nodeExtent:he,rfId:fe})))};Rj.displayName="GraphView";var Fj=r.memo(Rj);const Lj=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],zj={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:Lj,nodeExtent:Lj,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:GN.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:(e,t)=>{},isValidConnection:void 0},Bj=()=>{return e=(e,t)=>({...zj,setNodes:n=>{const{nodeInternals:o,nodeOrigin:r,elevateNodesOnSelect:a}=t();e({nodeInternals:pC(n,o,r,a)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:o={}}=t();e({edges:n.map((e=>({...o,...e})))})},setDefaultNodesAndEdges:(n,o)=>{const r=void 0!==n,a=void 0!==o,s=r?pC(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:s,edges:a?o:[],hasDefaultNodes:r,hasDefaultEdges:a})},updateNodeDimensions:n=>{const{onNodesChange:o,nodeInternals:r,fitViewOnInit:a,fitViewOnInitDone:s,fitViewOnInitOptions:i,domNode:l,nodeOrigin:c}=t(),d=null==l?void 0:l.querySelector(".react-flow__viewport");if(!d)return;const u=window.getComputedStyle(d),{m22:h}=new window.DOMMatrixReadOnly(u.transform),f=n.reduce(((e,t)=>{const n=r.get(t.id);if(null==n?void 0:n.hidden)r.set(n.id,{...n,[_N]:{...n[_N],handleBounds:void 0}});else if(n){const o=EN(t.nodeElement);o.width&&o.height&&(n.width!==o.width||n.height!==o.height||t.forceUpdate)&&(r.set(n.id,{...n,[_N]:{...n[_N],handleBounds:{source:qC(".source",t.nodeElement,h,c),target:qC(".target",t.nodeElement,h,c)}},...o}),e.push({id:n.id,type:"dimensions",dimensions:o}))}return e}),[]);mC(r,c);const m=s||a&&!s&&gC(t,{initial:!0,...i});e({nodeInternals:new Map(r),fitViewOnInitDone:m}),(null==f?void 0:f.length)>0&&(null==o||o(f))},updateNodePositions:(e,n=!0,o=!1)=>{const{triggerNodeChanges:r}=t();r(e.map((e=>{const t={id:e.id,type:"position",dragging:o};return n&&(t.positionAbsolute=e.positionAbsolute,t.position=e.position),t})))},triggerNodeChanges:n=>{const{onNodesChange:o,nodeInternals:r,hasDefaultNodes:a,nodeOrigin:s,getNodes:i,elevateNodesOnSelect:l}=t();if(null==n?void 0:n.length){if(a){const t=pC(RC(n,i()),r,s,l);e({nodeInternals:t})}null==o||o(n)}},addSelectedNodes:n=>{const{multiSelectionActive:o,edges:r,getNodes:a}=t();let s,i=null;o?s=n.map((e=>FC(e,!0))):(s=LC(a(),n),i=LC(r,[])),yC({changedNodes:s,changedEdges:i,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:o,edges:r,getNodes:a}=t();let s,i=null;o?s=n.map((e=>FC(e,!0))):(s=LC(r,n),i=LC(a(),[])),yC({changedNodes:i,changedEdges:s,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:o}={})=>{const{edges:r,getNodes:a}=t(),s=o||r;yC({changedNodes:(n||a()).map((e=>(e.selected=!1,FC(e.id,!1)))),changedEdges:s.map((e=>FC(e.id,!1))),get:t,set:e})},setMinZoom:n=>{const{d3Zoom:o,maxZoom:r}=t();null==o||o.scaleExtent([n,r]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:o,minZoom:r}=t();null==o||o.scaleExtent([r,n]),e({maxZoom:n})},setTranslateExtent:n=>{var o;null==(o=t().d3Zoom)||o.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:o}=t();yC({changedNodes:o().filter((e=>e.selected)).map((e=>FC(e.id,!1))),changedEdges:n.filter((e=>e.selected)).map((e=>FC(e.id,!1))),get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:o}=t();o.forEach((e=>{e.positionAbsolute=jN(e.position,n)})),e({nodeExtent:n,nodeInternals:new Map(o)})},panBy:e=>{const{transform:n,width:o,height:r,d3Zoom:a,d3Selection:s,translateExtent:i}=t();if(!a||!s||!e.x&&!e.y)return!1;const l=gl.translate(n[0]+e.x,n[1]+e.y).scale(n[2]),c=[[0,0],[o,r]],d=null==a?void 0:a.constrain()(l,c,i);return a.transform(s,d),n[0]!==d.x||n[1]!==d.y||n[2]!==d.k},cancelConnection:()=>e({connectionNodeId:zj.connectionNodeId,connectionHandleId:zj.connectionHandleId,connectionHandleType:zj.connectionHandleType,connectionStatus:zj.connectionStatus,connectionStartHandle:zj.connectionStartHandle,connectionEndHandle:zj.connectionEndHandle}),reset:()=>e({...zj})}),t=Object.is,e?Rk(e,t):Rk;var e,t},Uj=({children:e})=>{const t=r.useRef(null);return t.current||(t.current=Bj()),u.createElement(lN,{value:t.current},e)};Uj.displayName="ReactFlowProvider";const Vj=({children:e})=>r.useContext(iN)?u.createElement(u.Fragment,null,e):u.createElement(Uj,null,e);Vj.displayName="ReactFlowWrapper";const $j={input:$E,default:UE,output:HE,group:WE},Gj={default:pE,straight:uE,step:dE,smoothstep:cE,simplebezier:rE},Hj=[0,0],Wj=[15,15],qj={x:0,y:0,zoom:1},Yj={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Jj=r.forwardRef((({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:a=$j,edgeTypes:s=Gj,onNodeClick:i,onEdgeClick:l,onInit:c,onMove:d,onMoveStart:h,onMoveEnd:f,onConnect:m,onConnectStart:p,onConnectEnd:g,onClickConnectStart:v,onClickConnectEnd:x,onNodeMouseEnter:y,onNodeMouseMove:b,onNodeMouseLeave:w,onNodeContextMenu:k,onNodeDoubleClick:N,onNodeDragStart:E,onNodeDrag:C,onNodeDragStop:j,onNodesDelete:S,onEdgesDelete:I,onSelectionChange:A,onSelectionDragStart:M,onSelectionDrag:T,onSelectionDragStop:O,onSelectionContextMenu:D,onSelectionStart:_,onSelectionEnd:P,connectionMode:R=GN.Strict,connectionLineType:F=KN.Bezier,connectionLineStyle:L,connectionLineComponent:z,connectionLineContainerStyle:B,deleteKeyCode:U="Backspace",selectionKeyCode:V="Shift",selectionOnDrag:$=!1,selectionMode:G=YN.Full,panActivationKeyCode:H="Space",multiSelectionKeyCode:W=(zN()?"Meta":"Control"),zoomActivationKeyCode:q=(zN()?"Meta":"Control"),snapToGrid:Y=!1,snapGrid:J=Wj,onlyRenderVisibleElements:K=!1,selectNodesOnDrag:X=!0,nodesDraggable:Z,nodesConnectable:Q,nodesFocusable:ee,nodeOrigin:te=Hj,edgesFocusable:ne,edgesUpdatable:oe,elementsSelectable:re,defaultViewport:ae=qj,minZoom:se=.5,maxZoom:ie=2,translateExtent:le=Lj,preventScrolling:ce=!0,nodeExtent:de,defaultMarkerColor:ue="#b1b1b7",zoomOnScroll:he=!0,zoomOnPinch:fe=!0,panOnScroll:me=!1,panOnScrollSpeed:pe=.5,panOnScrollMode:ge=WN.Free,zoomOnDoubleClick:ve=!0,panOnDrag:xe=!0,onPaneClick:ye,onPaneMouseEnter:be,onPaneMouseMove:we,onPaneMouseLeave:ke,onPaneScroll:Ne,onPaneContextMenu:Ee,children:Ce,onEdgeContextMenu:je,onEdgeDoubleClick:Se,onEdgeMouseEnter:Ie,onEdgeMouseMove:Ae,onEdgeMouseLeave:Me,onEdgeUpdate:Te,onEdgeUpdateStart:Oe,onEdgeUpdateEnd:De,onReconnect:_e,onReconnectStart:Pe,onReconnectEnd:Re,reconnectRadius:Fe=10,edgeUpdaterRadius:Le=10,onNodesChange:ze,onEdgesChange:Be,noDragClassName:Ue="nodrag",noWheelClassName:Ve="nowheel",noPanClassName:$e="nopan",fitView:Ge=!1,fitViewOptions:He,connectOnClick:We=!0,attributionPosition:qe,proOptions:Ye,defaultEdgeOptions:Je,elevateNodesOnSelect:Ke=!0,elevateEdgesOnSelect:Xe=!1,disableKeyboardA11y:Ze=!1,autoPanOnConnect:Qe=!0,autoPanOnNodeDrag:et=!0,connectionRadius:tt=20,isValidConnection:nt,onError:ot,style:rt,id:at,nodeDragThreshold:st,...it},lt)=>{const ct=at||"1";return u.createElement("div",{...it,style:{...rt,...Yj},ref:lt,className:Tk(["react-flow",r]),"data-testid":"rf__wrapper",id:at},u.createElement(Vj,null,u.createElement(Fj,{onInit:c,onMove:d,onMoveStart:h,onMoveEnd:f,onNodeClick:i,onEdgeClick:l,onNodeMouseEnter:y,onNodeMouseMove:b,onNodeMouseLeave:w,onNodeContextMenu:k,onNodeDoubleClick:N,nodeTypes:a,edgeTypes:s,connectionLineType:F,connectionLineStyle:L,connectionLineComponent:z,connectionLineContainerStyle:B,selectionKeyCode:V,selectionOnDrag:$,selectionMode:G,deleteKeyCode:U,multiSelectionKeyCode:W,panActivationKeyCode:H,zoomActivationKeyCode:q,onlyRenderVisibleElements:K,selectNodesOnDrag:X,defaultViewport:ae,translateExtent:le,minZoom:se,maxZoom:ie,preventScrolling:ce,zoomOnScroll:he,zoomOnPinch:fe,zoomOnDoubleClick:ve,panOnScroll:me,panOnScrollSpeed:pe,panOnScrollMode:ge,panOnDrag:xe,onPaneClick:ye,onPaneMouseEnter:be,onPaneMouseMove:we,onPaneMouseLeave:ke,onPaneScroll:Ne,onPaneContextMenu:Ee,onSelectionContextMenu:D,onSelectionStart:_,onSelectionEnd:P,onEdgeContextMenu:je,onEdgeDoubleClick:Se,onEdgeMouseEnter:Ie,onEdgeMouseMove:Ae,onEdgeMouseLeave:Me,onReconnect:_e??Te,onReconnectStart:Pe??Oe,onReconnectEnd:Re??De,reconnectRadius:Fe??Le,defaultMarkerColor:ue,noDragClassName:Ue,noWheelClassName:Ve,noPanClassName:$e,elevateEdgesOnSelect:Xe,rfId:ct,disableKeyboardA11y:Ze,nodeOrigin:te,nodeExtent:de}),u.createElement(nC,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:m,onConnectStart:p,onConnectEnd:g,onClickConnectStart:v,onClickConnectEnd:x,nodesDraggable:Z,nodesConnectable:Q,nodesFocusable:ee,edgesFocusable:ne,edgesUpdatable:oe,elementsSelectable:re,elevateNodesOnSelect:Ke,minZoom:se,maxZoom:ie,nodeExtent:de,onNodesChange:ze,onEdgesChange:Be,snapToGrid:Y,snapGrid:J,connectionMode:R,translateExtent:le,connectOnClick:We,defaultEdgeOptions:Je,fitView:Ge,fitViewOptions:He,onNodesDelete:S,onEdgesDelete:I,onNodeDragStart:E,onNodeDrag:C,onNodeDragStop:j,onSelectionDrag:T,onSelectionDragStart:M,onSelectionDragStop:O,noPanClassName:$e,nodeOrigin:te,rfId:ct,autoPanOnConnect:Qe,autoPanOnNodeDrag:et,onError:ot,connectionRadius:tt,isValidConnection:nt,nodeDragThreshold:st}),u.createElement(ZE,{onSelectionChange:A}),Ce,u.createElement(kN,{proOptions:Ye,position:qe}),u.createElement(cC,{rfId:ct,disableKeyboardA11y:Ze})))}));function Kj(e){return t=>{const[n,o]=r.useState(t),a=r.useCallback((t=>o((n=>e(t,n)))),[]);return[n,o,a]}}Jj.displayName="ReactFlow";const Xj=Kj(RC),Zj=Kj((function(e,t){return PC(e,t)}));function Qj(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},u.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function eS(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},u.createElement("path",{d:"M0 0h32v4.2H0z"}))}function tS(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},u.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function nS(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},u.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function oS(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},u.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const rS=({children:e,className:t,...n})=>u.createElement("button",{type:"button",className:Tk(["react-flow__controls-button",t]),...n},e);rS.displayName="ControlButton";const aS=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),sS=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:a,onZoomIn:s,onZoomOut:i,onFitView:l,onInteractiveChange:c,className:d,children:h,position:f="bottom-left"})=>{const m=yN(),[p,g]=r.useState(!1),{isInteractive:v,minZoomReached:x,maxZoomReached:y}=xN(aS,Fk),{zoomIn:b,zoomOut:w,fitView:k}=NC();if(r.useEffect((()=>{g(!0)}),[]),!p)return null;return u.createElement(wN,{className:Tk(["react-flow__controls",d]),position:f,style:e,"data-testid":"rf__controls"},t&&u.createElement(u.Fragment,null,u.createElement(rS,{onClick:()=>{b(),null==s||s()},className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:y},u.createElement(Qj,null)),u.createElement(rS,{onClick:()=>{w(),null==i||i()},className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:x},u.createElement(eS,null))),n&&u.createElement(rS,{className:"react-flow__controls-fitview",onClick:()=>{k(a),null==l||l()},title:"fit view","aria-label":"fit view"},u.createElement(tS,null)),o&&u.createElement(rS,{className:"react-flow__controls-interactive",onClick:()=>{m.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),null==c||c(!v)},title:"toggle interactivity","aria-label":"toggle interactivity"},v?u.createElement(oS,null):u.createElement(nS,null)),h)};sS.displayName="Controls";var iS,lS,cS=r.memo(sS);function dS({color:e,dimensions:t,lineWidth:n}){return u.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function uS({color:e,radius:t}){return u.createElement("circle",{cx:t,cy:t,r:t,fill:e})}(lS=iS||(iS={})).Lines="lines",lS.Dots="dots",lS.Cross="cross";const hS={[iS.Dots]:"#91919a",[iS.Lines]:"#eee",[iS.Cross]:"#e2e2e2"},fS={[iS.Dots]:1,[iS.Lines]:1,[iS.Cross]:6},mS=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function pS({id:e,variant:t=iS.Dots,gap:n=20,size:o,lineWidth:a=1,offset:s=2,color:i,style:l,className:c}){const d=r.useRef(null),{transform:h,patternId:f}=xN(mS,Fk),m=i||hS[t],p=o||fS[t],g=t===iS.Dots,v=t===iS.Cross,x=Array.isArray(n)?n:[n,n],y=[x[0]*h[2]||1,x[1]*h[2]||1],b=p*h[2],w=v?[b,b]:y,k=g?[b/s,b/s]:[w[0]/s,w[1]/s];return u.createElement("svg",{className:Tk(["react-flow__background",c]),style:{...l,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:d,"data-testid":"rf__background"},u.createElement("pattern",{id:f+e,x:h[0]%y[0],y:h[1]%y[1],width:y[0],height:y[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`},g?u.createElement(uS,{color:m,radius:b/s}):u.createElement(dS,{dimensions:w,color:m,lineWidth:a})),u.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${f+e})`}))}pS.displayName="Background";var gS=r.memo(pS);function vS(e){return Math.min(11*e+35,200)}const xS=u.createContext("LR"),yS=r.memo((e=>{const{data:t,selected:n}=e,o=X(t.atom),a=te().inOrderIds.indexOf(o.id),s=n?"var(--gray-9)":"var(--gray-3)",i=xN((({width:e})=>e)),l=r.useContext(xS),c=o.code.split("\n").length;return m.jsxs("div",{children:[m.jsx(zE,{type:"target",id:"inputs",position:"LR"===l?eE.Left:eE.Top,style:{background:s}}),m.jsx(zE,{type:"source",id:"inputs",position:"LR"===l?eE.Left:eE.Top,style:{background:s}}),m.jsxs("div",{className:$t("flex flex-col bg-card border border-input/50 rounded-md mx-[2px] overflow-hidden",n&&"border-primary"),style:{height:vS(c),width:t.forceWidth||(d=i,Math.min(Math.max(d-100,100),400))},children:[m.jsx("div",{className:"text-muted-foreground font-semibold text-xs py-1 px-2 bg-muted border-b",children:Sa(o.name,a)}),m.jsx(ml,{code:o.code})]}),m.jsx(zE,{type:"source",id:"outputs",position:"LR"===l?eE.Right:eE.Bottom,style:{background:s}}),m.jsx(zE,{type:"target",id:"outputs",position:"LR"===l?eE.Right:eE.Bottom,style:{background:s}})]});var d}),((e,t)=>["data","selected","id"].every((n=>e[n]===t[n]))));yS.displayName="CustomNode";const bS={custom:yS},wS=({maxCount:e,cellIds:t,onClick:n,skipScroll:o})=>{const r=te(),a=[...t].sort(((e,t)=>r.inOrderIds.indexOf(e)-r.inOrderIds.indexOf(t)));return 0===t.length?m.jsx("div",{className:"text-muted-foreground",children:"--"}):m.jsxs(m.Fragment,{children:[a.slice(0,e).map(((e,r)=>m.jsxs("span",{className:"truncate",children:[m.jsx(Ia,{variant:"focus",cellId:e,skipScroll:o,className:"whitespace-nowrap",onClick:n?()=>n(e):void 0},e),r<t.length-1&&", "]},e))),t.length>e&&m.jsxs(Yt,{children:[m.jsx(Oo,{asChild:!0,children:m.jsxs("span",{className:"whitespace-nowrap text-muted-foreground text-xs hover:underline cursor-pointer",children:["+",t.length-e," more"]})}),m.jsx(Xt,{className:"w-auto",children:m.jsx("div",{className:"flex flex-col gap-1 py-1",children:a.slice(e).map((e=>m.jsx(Ia,{variant:"focus",cellId:e,className:"whitespace-nowrap",onClick:n?()=>n(e):void 0},e)))})})]})]})},kS=({name:e,declaredBy:t,onClick:n,...o})=>m.jsx("div",{className:"max-w-[130px]",...o,children:m.jsx(Aa,{title:e,variant:t.length>1?"destructive":"outline",className:"rounded-sm text-ellipsis block overflow-hidden max-w-fit cursor-pointer font-medium",onClick:t=>{n?n(t):(navigator.clipboard.writeText(e),q({title:"Copied to clipboard"}))},children:e})}),NS=r.memo((({onChange:e,view:t,settings:n,onSettingsChange:o})=>{const r=m.jsxs(Yt,{children:[m.jsx(Oo,{asChild:!0,children:m.jsx(b,{variant:"text",size:"xs",children:m.jsx(vt,{className:"w-4 h-4"})})}),m.jsxs(Xt,{className:"w-auto p-2 text-muted-foreground",children:[m.jsx("div",{className:"font-semibold pb-4",children:"Settings"}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(ir,{"data-testid":"hide-pure-markdown-checkbox",id:"hide-pure-markdown",checked:n.hidePureMarkdown,onCheckedChange:e=>{return t="hidePureMarkdown",r=Boolean(e),void o({...n,[t]:r});var t,r}}),m.jsx(ae,{htmlFor:"hide-pure-markdown",children:"Hide pure markdown"})]})]})]});return m.jsxs(wN,{position:"top-right",className:"flex flex-col items-end gap-2",children:[m.jsxs("div",{className:"flex gap-2",children:[m.jsxs(b,{variant:"outline",className:"bg-background","aria-selected":"_minimap_"===t,size:"xs",onClick:()=>e("_minimap_"),children:[m.jsx(pc,{className:"w-4 h-4 mr-1"}),"Mini Map"]}),m.jsxs(b,{variant:"outline",className:"bg-background","aria-selected":"TB"===t,size:"xs",onClick:()=>e("TB"),children:[m.jsx(oc,{className:"w-4 h-4 mr-1"}),"Vertical Tree"]}),m.jsxs(b,{variant:"outline",className:"bg-background","aria-selected":"LR"===t,size:"xs",onClick:()=>e("LR"),children:[m.jsx(oc,{className:"w-4 h-4 mr-1 transform -rotate-90"})," ","Horizontal Tree"]})]}),"_minimap_"!==t&&r]})}));NS.displayName="GraphToolbar";const ES=r.memo((({selection:e,edges:t,variables:n})=>{if(!e)return null;const o=(e,t)=>{const n=lr(e);n&&Ma(n,t)};return m.jsx(wN,{position:"bottom-left",className:"max-h-[90%] flex flex-col w-[calc(100%-5rem)]",children:m.jsx("div",{className:"min-h-[100px] shadow-md rounded-md border max-w-[550px] border-primary/40 my-4 min-w-[240px] bg-[var(--slate-1)] text-muted-foreground/80 flex flex-col overflow-y-auto",children:(()=>{if("node"===e.type){const t=Object.values(n).filter((t=>t.usedBy.includes(e.id))),r=Object.values(n).filter((t=>t.declaredBy.includes(e.id))),a=(e,t)=>m.jsxs(m.Fragment,{children:[0===e.length&&m.jsx("div",{className:"text-muted-foreground text-sm text-center",children:"--"}),m.jsx("div",{className:"grid grid-cols-5 gap-3 items-center text-sm py-1 flex-1 empty:hidden",children:e.map((e=>m.jsxs(u.Fragment,{children:[m.jsx(kS,{declaredBy:e.declaredBy,name:e.name}),m.jsxs("div",{className:"truncate col-span-2",title:e.value??"",children:[e.value,m.jsxs("span",{className:"ml-1 truncate text-foreground/60 font-mono",children:["(",e.dataType,")"]})]}),m.jsx("div",{className:"truncate col-span-2 gap-1 items-center",children:m.jsx(wS,{skipScroll:!0,onClick:()=>o("in"===t?e.declaredBy[0]:e.usedBy[0],e.name),maxCount:3,cellIds:e.usedBy})})]},e.name)))})]});return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"font-bold py-2 flex items-center gap-2 border-b px-3",children:[m.jsx(Je,{className:"w-5 h-5"}),m.jsx(Ia,{cellId:e.id}),m.jsx("div",{className:"flex-1"}),m.jsx(xx,{cellId:e.id,children:m.jsx(b,{variant:"ghost",size:"icon",children:m.jsx(Bl,{className:"w-4 h-4"})})})]}),m.jsxs("div",{className:"text-sm flex flex-col py-3 pl-2 pr-4 flex-1 justify-center",children:[m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("span",{className:"flex items-center gap-2 font-semibold",children:[m.jsx(Nl,{className:"w-4 h-4"}),"Outputs"]}),a(r,"out")]}),m.jsx("hr",{className:"border-divider my-3"}),m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("span",{className:"flex items-center gap-2 font-semibold",children:[m.jsx(El,{className:"w-4 h-4"}),"Inputs"]}),a(t,"in")]})]})]})}if("edge"===e.type){const t=Object.values(n).filter((t=>t.declaredBy.includes(e.source)&&t.usedBy.includes(e.target)));return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"font-bold py-2 flex items-center gap-2 border-b px-3",children:[m.jsx(_c,{className:"w-4 h-4"}),m.jsx(Ia,{cellId:e.source}),m.jsx(Cl,{className:"w-4 h-4"}),m.jsx(Ia,{cellId:e.target})]}),m.jsx("div",{className:"grid grid-cols-4 gap-3 max-w-[350px] items-center text-sm p-3 flex-1",children:t.map((e=>m.jsxs(u.Fragment,{children:[m.jsx(kS,{declaredBy:e.declaredBy,name:e.name,onClick:()=>{o(e.declaredBy[0],e.name)}}),m.jsx("div",{className:"truncate text-foreground/60 font-mono",children:e.dataType}),m.jsx("div",{className:"truncate col-span-2",title:e.value??"",children:e.value})]},e.name)))})]})}})()})})}));function CS(){const e=NC(),t=xN((({width:e})=>e)),n=xN((({height:e})=>e)),o=Ta((()=>{e.fitView({duration:100})}),100);r.useEffect((()=>{t&&n&&o()}),[t,n,o])}ES.displayName="GraphSelectionPanel";const jS=new class{createEdge(e,t,n){return{type:"smoothstep",pathOptions:{offset:20,borderRadius:100},data:{direction:n},markerEnd:{type:ZN.Arrow},id:`${e}-${t}-${n}`,source:e,sourceHandle:n,targetHandle:n,target:t}}createNode(e,t,n){return{id:e,data:{atom:t},width:250,type:"custom",height:vS(G.get(t).code.trim().split("\n").length),position:{x:0,y:n+20}}}createElements(e,t,n,o){let r=0;const a=[],s=[];for(const[l,c]of Gr.zip(e,t)){const e=this.createNode(l,c,r);a.push(e),r=e.position.y+(e.height||0)}const i=new Set;for(const l of Object.values(n)){const{declaredBy:e,usedBy:t}=l;for(const n of e)for(const e of t){const t=`${n}-${e}`;i.has(t)||(i.add(t),s.push(this.createEdge(n,e,"inputs"),this.createEdge(n,e,"outputs")))}}return{nodes:a,edges:s}}},SS=({cellIds:e,variables:t,cellAtoms:n,children:o})=>{const{nodes:a,edges:s}=jS.createElements(e,n,t,!1),[i,l]=Zj([]),[c,d]=Xj(a),[u,h]=r.useState(),[f,p]=r.useState(),g=r.useRef(!1);CS();const v=xN((({height:e})=>e)),x=R((e=>{d(e.nodes),l([])}));r.useEffect((()=>{g.current?x(jS.createElements(e,n,t,!1)):g.current=!0}),[e,t,n,x]),r.useEffect((()=>{if(u){const e=s.filter((e=>{const{source:t,target:n,data:o}=e;return t===u&&"outputs"===o.direction||n===u&&"inputs"===o.direction}));l(e)}}),[u,l,s]);const y=function(e,t){const n=10;return r.useMemo((()=>{const o=e.reduce(((e,{position:o})=>Math.min(e,o.y-t/2-n)),Number.POSITIVE_INFINITY),r=e.reduce(((e,{position:o})=>Math.max(e,o.y+t/2+n)),Number.NEGATIVE_INFINITY);return[[Number.NEGATIVE_INFINITY,o],[Number.POSITIVE_INFINITY,r]]}),[e,t])}(c,v);return m.jsxs(Jj,{nodes:c,edges:i,nodeTypes:bS,translateExtent:y,onNodeClick:(e,t)=>{const n=t.id;h(n),p(void 0),l([])},onNodeDoubleClick:(e,t)=>{Oa(t.id,"focus")},onEdgeClick:(e,t)=>{p(t)},snapToGrid:!0,fitView:!0,elementsSelectable:!0,minZoom:1,maxZoom:1,draggable:!1,panOnScrollMode:WN.Vertical,zoomOnDoubleClick:!1,nodesDraggable:!1,nodesConnectable:!1,nodesFocusable:!1,edgesFocusable:!1,selectNodesOnDrag:!1,panOnDrag:!1,preventScrolling:!1,zoomOnPinch:!1,panOnScroll:!0,autoPanOnNodeDrag:!1,autoPanOnConnect:!1,children:[f?m.jsx(ES,{selection:{type:"edge",source:f.source,target:f.target},variables:t,edges:i}):u?m.jsx(ES,{selection:{type:"node",id:u},variables:t,edges:i}):null,o]})};var IS="\0";function AS(e,t){e[t]?e[t]++:e[t]=1}function MS(e,t){--e[t]||delete e[t]}function TS(e,t,n,o){var r=""+t,a=""+n;if(!e&&r>a){var s=r;r=a,a=s}return r+""+a+""+(void 0===o?"\0":o)}function OS(e,t){return TS(e,t.v,t.w,t.name)}var DS=class{constructor(e){n(this,"_isDirected",!0),n(this,"_isMultigraph",!1),n(this,"_isCompound",!1),n(this,"_label"),n(this,"_defaultNodeLabelFn",(()=>{})),n(this,"_defaultEdgeLabelFn",(()=>{})),n(this,"_nodes",{}),n(this,"_in",{}),n(this,"_preds",{}),n(this,"_out",{}),n(this,"_sucs",{}),n(this,"_edgeObjs",{}),n(this,"_edgeLabels",{}),n(this,"_nodeCount",0),n(this,"_edgeCount",0),n(this,"_parent"),n(this,"_children"),e&&(this._isDirected=!Object.hasOwn(e,"directed")||e.directed,this._isMultigraph=!!Object.hasOwn(e,"multigraph")&&e.multigraph,this._isCompound=!!Object.hasOwn(e,"compound")&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[IS]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=e,"function"!=typeof e&&(this._defaultNodeLabelFn=()=>e),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var e=this;return this.nodes().filter((t=>0===Object.keys(e._in[t]).length))}sinks(){var e=this;return this.nodes().filter((t=>0===Object.keys(e._out[t]).length))}setNodes(e,t){var n=arguments,o=this;return e.forEach((function(e){n.length>1?o.setNode(e,t):o.setNode(e)})),this}setNode(e,t){return Object.hasOwn(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=IS,this._children[e]={},this._children[IS][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return Object.hasOwn(this._nodes,e)}removeNode(e){var t=this;if(Object.hasOwn(this._nodes,e)){var n=e=>t.removeEdge(t._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach((function(e){t.setParent(e)})),delete this._children[e]),Object.keys(this._in[e]).forEach(n),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(n),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(void 0===t)t=IS;else{for(var n=t+="";void 0!==n;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var t=this._parent[e];if(t!==IS)return t}}children(e=IS){if(this._isCompound){var t=this._children[e];if(t)return Object.keys(t)}else{if(e===IS)return this.nodes();if(this.hasNode(e))return[]}}predecessors(e){var t=this._preds[e];if(t)return Object.keys(t)}successors(e){var t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){var t=this.predecessors(e);if(t){const o=new Set(t);for(var n of this.successors(e))o.add(n);return Array.from(o.values())}}isLeaf(e){return 0===(this.isDirected()?this.successors(e):this.neighbors(e)).length}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var n=this;Object.entries(this._nodes).forEach((function([n,o]){e(n)&&t.setNode(n,o)})),Object.values(this._edgeObjs).forEach((function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,n.edge(e))}));var o={};function r(e){var a=n.parent(e);return void 0===a||t.hasNode(a)?(o[e]=a,a):a in o?o[a]:r(a)}return this._isCompound&&t.nodes().forEach((e=>t.setParent(e,r(e)))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=e,"function"!=typeof e&&(this._defaultEdgeLabelFn=()=>e),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){var n=this,o=arguments;return e.reduce((function(e,r){return o.length>1?n.setEdge(e,r,t):n.setEdge(e,r),r})),this}setEdge(){var e,t,n,o,r=!1,a=arguments[0];"object"==typeof a&&null!==a&&"v"in a?(e=a.v,t=a.w,n=a.name,2===arguments.length&&(o=arguments[1],r=!0)):(e=a,t=arguments[1],n=arguments[3],arguments.length>2&&(o=arguments[2],r=!0)),e=""+e,t=""+t,void 0!==n&&(n=""+n);var s=TS(this._isDirected,e,t,n);if(Object.hasOwn(this._edgeLabels,s))return r&&(this._edgeLabels[s]=o),this;if(void 0!==n&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(t),this._edgeLabels[s]=r?o:this._defaultEdgeLabelFn(e,t,n);var i=function(e,t,n,o){var r=""+t,a=""+n;if(!e&&r>a){var s=r;r=a,a=s}var i={v:r,w:a};o&&(i.name=o);return i}(this._isDirected,e,t,n);return e=i.v,t=i.w,Object.freeze(i),this._edgeObjs[s]=i,AS(this._preds[t],e),AS(this._sucs[e],t),this._in[t][s]=i,this._out[e][s]=i,this._edgeCount++,this}edge(e,t,n){var o=1===arguments.length?OS(this._isDirected,arguments[0]):TS(this._isDirected,e,t,n);return this._edgeLabels[o]}edgeAsObj(){const e=this.edge(...arguments);return"object"!=typeof e?{label:e}:e}hasEdge(e,t,n){var o=1===arguments.length?OS(this._isDirected,arguments[0]):TS(this._isDirected,e,t,n);return Object.hasOwn(this._edgeLabels,o)}removeEdge(e,t,n){var o=1===arguments.length?OS(this._isDirected,arguments[0]):TS(this._isDirected,e,t,n),r=this._edgeObjs[o];return r&&(e=r.v,t=r.w,delete this._edgeLabels[o],delete this._edgeObjs[o],MS(this._preds[t],e),MS(this._sucs[e],t),delete this._in[t][o],delete this._out[e][o],this._edgeCount--),this}inEdges(e,t){var n=this._in[e];if(n){var o=Object.values(n);return t?o.filter((e=>e.v===t)):o}}outEdges(e,t){var n=this._out[e];if(n){var o=Object.values(n);return t?o.filter((e=>e.w===t)):o}}nodeEdges(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))}},_S={Graph:DS,version:"2.2.4"},PS=DS,RS={write:function(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:FS(e),edges:LS(e)};void 0!==e.graph()&&(t.value=structuredClone(e.graph()));return t},read:function(e){var t=new PS(e.options).setGraph(e.value);return e.nodes.forEach((function(e){t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)})),e.edges.forEach((function(e){t.setEdge({v:e.v,w:e.w,name:e.name},e.value)})),t}};function FS(e){return e.nodes().map((function(t){var n=e.node(t),o=e.parent(t),r={v:t};return void 0!==n&&(r.value=n),void 0!==o&&(r.parent=o),r}))}function LS(e){return e.edges().map((function(t){var n=e.edge(t),o={v:t.v,w:t.w};return void 0!==t.name&&(o.name=t.name),void 0!==n&&(o.value=n),o}))}var zS=function(e){var t,n={},o=[];function r(o){Object.hasOwn(n,o)||(n[o]=!0,t.push(o),e.successors(o).forEach(r),e.predecessors(o).forEach(r))}return e.nodes().forEach((function(e){t=[],r(e),t.length&&o.push(t)})),o};var BS=class{constructor(){n(this,"_arr",[]),n(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map((function(e){return e.key}))}has(e){return Object.hasOwn(this._keyIndices,e)}priority(e){var t=this._keyIndices[e];if(void 0!==t)return this._arr[t].priority}min(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key}add(e,t){var n=this._keyIndices;if(e=String(e),!Object.hasOwn(n,e)){var o=this._arr,r=o.length;return n[e]=r,o.push({key:e,priority:t}),this._decrease(r),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){var n=this._keyIndices[e];if(t>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+e+" Old: "+this._arr[n].priority+" New: "+t);this._arr[n].priority=t,this._decrease(n)}_heapify(e){var t=this._arr,n=2*e,o=n+1,r=e;n<t.length&&(r=t[n].priority<t[r].priority?n:r,o<t.length&&(r=t[o].priority<t[r].priority?o:r),r!==e&&(this._swap(e,r),this._heapify(r)))}_decrease(e){for(var t,n=this._arr,o=n[e].priority;0!==e&&!(n[t=e>>1].priority<o);)this._swap(e,t),e=t}_swap(e,t){var n=this._arr,o=this._keyIndices,r=n[e],a=n[t];n[e]=a,n[t]=r,o[a.key]=e,o[r.key]=t}},US=BS,VS=function(e,t,n,o){return function(e,t,n,o){var r,a,s={},i=new US,l=function(e){var t=e.v!==r?e.v:e.w,o=s[t],l=n(e),c=a.distance+l;if(l<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+e+" Weight: "+l);c<o.distance&&(o.distance=c,o.predecessor=r,i.decrease(t,c))};e.nodes().forEach((function(e){var n=e===t?0:Number.POSITIVE_INFINITY;s[e]={distance:n},i.add(e,n)}));for(;i.size()>0&&(r=i.removeMin(),(a=s[r]).distance!==Number.POSITIVE_INFINITY);)o(r).forEach(l);return s}(e,String(t),n||$S,o||function(t){return e.outEdges(t)})},$S=()=>1;var GS=VS,HS=function(e,t,n){return e.nodes().reduce((function(o,r){return o[r]=GS(e,r,t,n),o}),{})};var WS=function(e){var t=0,n=[],o={},r=[];function a(s){var i=o[s]={onStack:!0,lowlink:t,index:t++};if(n.push(s),e.successors(s).forEach((function(e){Object.hasOwn(o,e)?o[e].onStack&&(i.lowlink=Math.min(i.lowlink,o[e].index)):(a(e),i.lowlink=Math.min(i.lowlink,o[e].lowlink))})),i.lowlink===i.index){var l,c=[];do{l=n.pop(),o[l].onStack=!1,c.push(l)}while(s!==l);r.push(c)}}return e.nodes().forEach((function(e){Object.hasOwn(o,e)||a(e)})),r};var qS=WS,YS=function(e){return qS(e).filter((function(t){return t.length>1||1===t.length&&e.hasEdge(t[0],t[0])}))};var JS=function(e,t,n){return function(e,t,n){var o={},r=e.nodes();return r.forEach((function(e){o[e]={},o[e][e]={distance:0},r.forEach((function(t){e!==t&&(o[e][t]={distance:Number.POSITIVE_INFINITY})})),n(e).forEach((function(n){var r=n.v===e?n.w:n.v,a=t(n);o[e][r]={distance:a,predecessor:e}}))})),r.forEach((function(e){var t=o[e];r.forEach((function(n){var a=o[n];r.forEach((function(n){var o=a[e],r=t[n],s=a[n],i=o.distance+r.distance;i<s.distance&&(s.distance=i,s.predecessor=r.predecessor)}))}))})),o}(e,t||KS,n||function(t){return e.outEdges(t)})},KS=()=>1;function XS(e){var t={},n={},o=[];if(e.sinks().forEach((function r(a){if(Object.hasOwn(n,a))throw new ZS;Object.hasOwn(t,a)||(n[a]=!0,t[a]=!0,e.predecessors(a).forEach(r),delete n[a],o.push(a))})),Object.keys(t).length!==e.nodeCount())throw new ZS;return o}class ZS extends Error{constructor(){super(...arguments)}}var QS=XS;XS.CycleException=ZS;var eI=QS;var tI=function(e,t,n){Array.isArray(t)||(t=[t]);var o=e.isDirected()?t=>e.successors(t):t=>e.neighbors(t),r="post"===n?nI:oI,a=[],s={};return t.forEach((t=>{if(!e.hasNode(t))throw new Error("Graph does not have node: "+t);r(t,o,s,a)})),a};function nI(e,t,n,o){for(var r=[[e,!1]];r.length>0;){var a=r.pop();a[1]?o.push(a[0]):Object.hasOwn(n,a[0])||(n[a[0]]=!0,r.push([a[0],!0]),rI(t(a[0]),(e=>r.push([e,!1]))))}}function oI(e,t,n,o){for(var r=[e];r.length>0;){var a=r.pop();Object.hasOwn(n,a)||(n[a]=!0,o.push(a),rI(t(a),(e=>r.push(e))))}}function rI(e,t){for(var n=e.length;n--;)t(e[n],n,e);return e}var aI=tI;var sI=tI;var iI=DS,lI=BS;var cI={Graph:_S.Graph,json:RS,alg:{components:zS,dijkstra:VS,dijkstraAll:HS,findCycles:YS,floydWarshall:JS,isAcyclic:function(e){try{eI(e)}catch(t){if(t instanceof eI.CycleException)return!1;throw t}return!0},postorder:function(e,t){return aI(e,t,"post")},preorder:function(e,t){return sI(e,t,"pre")},prim:function(e,t){var n,o=new iI,r={},a=new lI;function s(e){var o=e.v===n?e.w:e.v,s=a.priority(o);if(void 0!==s){var i=t(e);i<s&&(r[o]=n,a.decrease(o,i))}}if(0===e.nodeCount())return o;e.nodes().forEach((function(e){a.add(e,Number.POSITIVE_INFINITY),o.setNode(e)})),a.decrease(e.nodes()[0],0);var i=!1;for(;a.size()>0;){if(n=a.removeMin(),Object.hasOwn(r,n))o.setEdge(n,r[n]);else{if(i)throw new Error("Input graph is not connected: "+e);i=!0}e.nodeEdges(n).forEach(s)}return o},tarjan:WS,topsort:QS},version:_S.version};function dI(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function uI(e,t){if("_next"!==e&&"_prev"!==e)return t}let hI=cI.Graph,fI=class{constructor(){let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return dI(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&dI(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,uI)),n=n._prev;return"["+e.join(", ")+"]"}};var mI=function(e,t){if(e.nodeCount()<=1)return[];let n=function(e,t){let n=new hI,o=0,r=0;e.nodes().forEach((e=>{n.setNode(e,{v:e,in:0,out:0})})),e.edges().forEach((e=>{let a=n.edge(e.v,e.w)||0,s=t(e),i=a+s;n.setEdge(e.v,e.w,i),r=Math.max(r,n.node(e.v).out+=s),o=Math.max(o,n.node(e.w).in+=s)}));let a=function(e){const t=[];for(let n=0;n<e;n++)t.push(n);return t}(r+o+3).map((()=>new fI)),s=o+1;return n.nodes().forEach((e=>{vI(a,s,n.node(e))})),{graph:n,buckets:a,zeroIdx:s}}(e,t||pI);return function(e,t,n){let o,r=[],a=t[t.length-1],s=t[0];for(;e.nodeCount();){for(;o=s.dequeue();)gI(e,t,n,o);for(;o=a.dequeue();)gI(e,t,n,o);if(e.nodeCount())for(let a=t.length-2;a>0;--a)if(o=t[a].dequeue(),o){r=r.concat(gI(e,t,n,o,!0));break}}return r}(n.graph,n.buckets,n.zeroIdx).flatMap((t=>e.outEdges(t.v,t.w)))};let pI=()=>1;function gI(e,t,n,o,r){let a=r?[]:void 0;return e.inEdges(o.v).forEach((o=>{let s=e.edge(o),i=e.node(o.v);r&&a.push({v:o.v,w:o.w}),i.out-=s,vI(t,n,i)})),e.outEdges(o.v).forEach((o=>{let r=e.edge(o),a=o.w,s=e.node(a);s.in-=r,vI(t,n,s)})),e.removeNode(o.v),a}function vI(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}let xI=cI.Graph;var yI={addBorderNode:function(e,t,n,o){let r={width:0,height:0};arguments.length>=4&&(r.rank=n,r.order=o);return bI(e,"border",r,t)},addDummyNode:bI,applyWithChunking:kI,asNonCompoundGraph:function(e){let t=new xI({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach((n=>{e.children(n).length||t.setNode(n,e.node(n))})),e.edges().forEach((n=>{t.setEdge(n,e.edge(n))})),t},buildLayerMatrix:function(e){let t=jI(NI(e)+1).map((()=>[]));return e.nodes().forEach((n=>{let o=e.node(n),r=o.rank;void 0!==r&&(t[r][o.order]=n)})),t},intersectRect:function(e,t){let n,o,r=e.x,a=e.y,s=t.x-r,i=t.y-a,l=e.width/2,c=e.height/2;if(!s&&!i)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(i)*l>Math.abs(s)*c?(i<0&&(c=-c),n=c*s/i,o=c):(s<0&&(l=-l),n=l,o=l*i/s);return{x:r+n,y:a+o}},mapValues:function(e,t){let n=t;"string"==typeof t&&(n=e=>e[t]);return Object.entries(e).reduce(((e,[t,o])=>(e[t]=n(o,t),e)),{})},maxRank:NI,normalizeRanks:function(e){let t=e.nodes().map((t=>{let n=e.node(t).rank;return void 0===n?Number.MAX_VALUE:n})),n=kI(Math.min,t);e.nodes().forEach((t=>{let o=e.node(t);Object.hasOwn(o,"rank")&&(o.rank-=n)}))},notime:function(e,t){return t()},partition:function(e,t){let n={lhs:[],rhs:[]};return e.forEach((e=>{t(e)?n.lhs.push(e):n.rhs.push(e)})),n},pick:function(e,t){const n={};for(const o of t)void 0!==e[o]&&(n[o]=e[o]);return n},predecessorWeights:function(e){let t=e.nodes().map((t=>{let n={};return e.inEdges(t).forEach((t=>{n[t.v]=(n[t.v]||0)+e.edge(t).weight})),n}));return SI(e.nodes(),t)},range:jI,removeEmptyRanks:function(e){let t=e.nodes().map((t=>e.node(t).rank)),n=kI(Math.min,t),o=[];e.nodes().forEach((t=>{let r=e.node(t).rank-n;o[r]||(o[r]=[]),o[r].push(t)}));let r=0,a=e.graph().nodeRankFactor;Array.from(o).forEach(((t,n)=>{void 0===t&&n%a!=0?--r:void 0!==t&&r&&t.forEach((t=>e.node(t).rank+=r))}))},simplify:function(e){let t=(new xI).setGraph(e.graph());return e.nodes().forEach((n=>t.setNode(n,e.node(n)))),e.edges().forEach((n=>{let o=t.edge(n.v,n.w)||{weight:0,minlen:1},r=e.edge(n);t.setEdge(n.v,n.w,{weight:o.weight+r.weight,minlen:Math.max(o.minlen,r.minlen)})})),t},successorWeights:function(e){let t=e.nodes().map((t=>{let n={};return e.outEdges(t).forEach((t=>{n[t.w]=(n[t.w]||0)+e.edge(t).weight})),n}));return SI(e.nodes(),t)},time:function(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}},uniqueId:CI,zipObject:SI};function bI(e,t,n,o){let r;do{r=CI(o)}while(e.hasNode(r));return n.dummy=t,e.setNode(r,n),r}const wI=65535;function kI(e,t){if(t.length>wI){const n=function(e,t=wI){const n=[];for(let o=0;o<e.length;o+=t){const r=e.slice(o,o+t);n.push(r)}return n}(t);return e.apply(null,n.map((t=>e.apply(null,t))))}return e.apply(null,t)}function NI(e){const t=e.nodes().map((t=>{let n=e.node(t).rank;return void 0===n?Number.MIN_VALUE:n}));return kI(Math.max,t)}let EI=0;function CI(e){var t=++EI;return toString(e)+t}function jI(e,t,n=1){null==t&&(t=e,e=0);let o=e=>e<t;n<0&&(o=e=>t<e);const r=[];for(let a=e;o(a);a+=n)r.push(a);return r}function SI(e,t){return e.reduce(((e,n,o)=>(e[n]=t[o],e)),{})}let II=mI,AI=yI.uniqueId;var MI={run:function(e){("greedy"===e.graph().acyclicer?II(e,(t=e,e=>t.edge(e).weight)):function(e){let t=[],n={},o={};function r(a){Object.hasOwn(o,a)||(o[a]=!0,n[a]=!0,e.outEdges(a).forEach((e=>{Object.hasOwn(n,e.w)?t.push(e):r(e.w)})),delete n[a])}return e.nodes().forEach(r),t}(e)).forEach((t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,AI("rev"))}));var t},undo:function(e){e.edges().forEach((t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let o=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,o)}}))}};let TI=yI;var OI={run:function(e){e.graph().dummyChains=[],e.edges().forEach((t=>function(e,t){let n,o,r,a=t.v,s=e.node(a).rank,i=t.w,l=e.node(i).rank,c=t.name,d=e.edge(t),u=d.labelRank;if(l===s+1)return;for(e.removeEdge(t),r=0,++s;s<l;++r,++s)d.points=[],o={width:0,height:0,edgeLabel:d,edgeObj:t,rank:s},n=TI.addDummyNode(e,"edge",o,"_d"),s===u&&(o.width=d.width,o.height=d.height,o.dummy="edge-label",o.labelpos=d.labelpos),e.setEdge(a,n,{weight:d.weight},c),0===r&&e.graph().dummyChains.push(n),a=n;e.setEdge(a,i,{weight:d.weight},c)}(e,t)))},undo:function(e){e.graph().dummyChains.forEach((t=>{let n,o=e.node(t),r=o.edgeLabel;for(e.setEdge(o.edgeObj,r);o.dummy;)n=e.successors(t)[0],e.removeNode(t),r.points.push({x:o.x,y:o.y}),"edge-label"===o.dummy&&(r.x=o.x,r.y=o.y,r.width=o.width,r.height=o.height),t=n,o=e.node(t)}))}};const{applyWithChunking:DI}=yI;var _I={longestPath:function(e){var t={};e.sources().forEach((function n(o){var r=e.node(o);if(Object.hasOwn(t,o))return r.rank;t[o]=!0;let a=e.outEdges(o).map((t=>null==t?Number.POSITIVE_INFINITY:n(t.w)-e.edge(t).minlen));var s=DI(Math.min,a);return s===Number.POSITIVE_INFINITY&&(s=0),r.rank=s}))},slack:function(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}};var PI=cI.Graph,RI=_I.slack,FI=function(e){var t,n,o=new PI({directed:!1}),r=e.nodes()[0],a=e.nodeCount();o.setNode(r,{});for(;LI(o,e)<a;)t=zI(o,e),n=o.hasNode(t.v)?RI(e,t):-RI(e,t),BI(o,e,n);return o};function LI(e,t){return e.nodes().forEach((function n(o){t.nodeEdges(o).forEach((r=>{var a=r.v,s=o===a?r.w:a;e.hasNode(s)||RI(t,r)||(e.setNode(s,{}),e.setEdge(o,s,{}),n(s))}))})),e.nodeCount()}function zI(e,t){return t.edges().reduce(((n,o)=>{let r=Number.POSITIVE_INFINITY;return e.hasNode(o.v)!==e.hasNode(o.w)&&(r=RI(t,o)),r<n[0]?[r,o]:n}),[Number.POSITIVE_INFINITY,null])[1]}function BI(e,t,n){e.nodes().forEach((e=>t.node(e).rank+=n))}var UI=FI,VI=_I.slack,$I=_I.longestPath,GI=cI.alg.preorder,HI=cI.alg.postorder,WI=yI.simplify,qI=YI;function YI(e){e=WI(e),$I(e);var t,n=UI(e);for(XI(n),JI(n,e);t=QI(n);)tA(n,e,t,eA(n,e,t))}function JI(e,t){var n=HI(e,e.nodes());(n=n.slice(0,n.length-1)).forEach((n=>function(e,t,n){var o=e.node(n),r=o.parent;e.edge(n,r).cutvalue=KI(e,t,n)}(e,t,n)))}function KI(e,t,n){var o=e.node(n).parent,r=!0,a=t.edge(n,o),s=0;return a||(r=!1,a=t.edge(o,n)),s=a.weight,t.nodeEdges(n).forEach((a=>{var i,l,c=a.v===n,d=c?a.w:a.v;if(d!==o){var u=c===r,h=t.edge(a).weight;if(s+=u?h:-h,i=n,l=d,e.hasEdge(i,l)){var f=e.edge(n,d).cutvalue;s+=u?-f:f}}})),s}function XI(e,t){arguments.length<2&&(t=e.nodes()[0]),ZI(e,{},1,t)}function ZI(e,t,n,o,r){var a=n,s=e.node(o);return t[o]=!0,e.neighbors(o).forEach((r=>{Object.hasOwn(t,r)||(n=ZI(e,t,n,r,o))})),s.low=a,s.lim=n++,r?s.parent=r:delete s.parent,n}function QI(e){return e.edges().find((t=>e.edge(t).cutvalue<0))}function eA(e,t,n){var o=n.v,r=n.w;t.hasEdge(o,r)||(o=n.w,r=n.v);var a=e.node(o),s=e.node(r),i=a,l=!1;return a.lim>s.lim&&(i=s,l=!0),t.edges().filter((t=>l===nA(e,e.node(t.v),i)&&l!==nA(e,e.node(t.w),i))).reduce(((e,n)=>VI(t,n)<VI(t,e)?n:e))}function tA(e,t,n,o){var r=n.v,a=n.w;e.removeEdge(r,a),e.setEdge(o.v,o.w,{}),XI(e),JI(e,t),function(e,t){var n=e.nodes().find((e=>!t.node(e).parent)),o=GI(e,n);(o=o.slice(1)).forEach((n=>{var o=e.node(n).parent,r=t.edge(n,o),a=!1;r||(r=t.edge(o,n),a=!0),t.node(n).rank=t.node(o).rank+(a?r.minlen:-r.minlen)}))}(e,t)}function nA(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}YI.initLowLimValues=XI,YI.initCutValues=JI,YI.calcCutValue=KI,YI.leaveEdge=QI,YI.enterEdge=eA,YI.exchangeEdges=tA;var oA=_I.longestPath,rA=FI,aA=qI,sA=function(e){switch(e.graph().ranker){case"network-simplex":default:lA(e);break;case"tight-tree":!function(e){oA(e),rA(e)}(e);break;case"longest-path":iA(e)}};var iA=oA;function lA(e){aA(e)}let cA=yI;function dA(e,t,n,o,r,a,s){let i=e.children(s);if(!i.length)return void(s!==t&&e.setEdge(t,s,{weight:0,minlen:n}));let l=cA.addBorderNode(e,"_bt"),c=cA.addBorderNode(e,"_bb"),d=e.node(s);e.setParent(l,s),d.borderTop=l,e.setParent(c,s),d.borderBottom=c,i.forEach((i=>{dA(e,t,n,o,r,a,i);let d=e.node(i),u=d.borderTop?d.borderTop:i,h=d.borderBottom?d.borderBottom:i,f=d.borderTop?o:2*o,m=u!==h?1:r-a[s]+1;e.setEdge(l,u,{weight:f,minlen:m,nestingEdge:!0}),e.setEdge(h,c,{weight:f,minlen:m,nestingEdge:!0})})),e.parent(s)||e.setEdge(t,l,{weight:0,minlen:r+a[s]})}let uA=yI;function hA(e,t,n,o,r,a){let s={width:0,height:0,rank:a,borderType:t},i=r[t][a-1],l=uA.addDummyNode(e,"border",s,n);r[t][a]=l,e.setParent(l,o),i&&e.setEdge(i,l,{weight:1})}function fA(e){e.nodes().forEach((t=>mA(e.node(t)))),e.edges().forEach((t=>mA(e.edge(t))))}function mA(e){let t=e.width;e.width=e.height,e.height=t}function pA(e){e.y=-e.y}function gA(e){let t=e.x;e.x=e.y,e.y=t}let vA=yI;let xA=yI.zipObject;function yA(e,t,n){let o=xA(n,n.map(((e,t)=>t))),r=t.flatMap((t=>e.outEdges(t).map((t=>({pos:o[t.w],weight:e.edge(t).weight}))).sort(((e,t)=>e.pos-t.pos)))),a=1;for(;a<n.length;)a<<=1;let s=2*a-1;a-=1;let i=new Array(s).fill(0),l=0;return r.forEach((e=>{let t=e.pos+a;i[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=i[t+1]),t=t-1>>1,i[t]+=e.weight;l+=e.weight*n})),l}let bA=yI;let wA=yI;function kA(e,t,n){let o;for(;t.length&&(o=t[t.length-1]).i<=n;)t.pop(),e.push(o.vs),n++;return n}let NA=function(e,t=[]){return t.map((t=>{let n=e.inEdges(t);if(n.length){let o=n.reduce(((t,n)=>{let o=e.edge(n),r=e.node(n.v);return{sum:t.sum+o.weight*r.order,weight:t.weight+o.weight}}),{sum:0,weight:0});return{v:t,barycenter:o.sum/o.weight,weight:o.weight}}return{v:t}}))},EA=function(e,t){let n={};return e.forEach(((e,t)=>{let o=n[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};void 0!==e.barycenter&&(o.barycenter=e.barycenter,o.weight=e.weight)})),t.edges().forEach((e=>{let t=n[e.v],o=n[e.w];void 0!==t&&void 0!==o&&(o.indegree++,t.out.push(n[e.w]))})),function(e){let t=[];function n(e){return t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&function(e,t){let n=0,o=0;e.weight&&(n+=e.barycenter*e.weight,o+=e.weight);t.weight&&(n+=t.barycenter*t.weight,o+=t.weight);e.vs=t.vs.concat(e.vs),e.barycenter=n/o,e.weight=o,e.i=Math.min(t.i,e.i),t.merged=!0}(e,t)}}function o(t){return n=>{n.in.push(t),0==--n.indegree&&e.push(n)}}for(;e.length;){let r=e.pop();t.push(r),r.in.reverse().forEach(n(r)),r.out.forEach(o(r))}return t.filter((e=>!e.merged)).map((e=>bA.pick(e,["vs","i","barycenter","weight"])))}(Object.values(n).filter((e=>!e.indegree)))},CA=function(e,t){let n=wA.partition(e,(e=>Object.hasOwn(e,"barycenter"))),o=n.lhs,r=n.rhs.sort(((e,t)=>t.i-e.i)),a=[],s=0,i=0,l=0;o.sort((c=!!t,(e,t)=>e.barycenter<t.barycenter?-1:e.barycenter>t.barycenter?1:c?t.i-e.i:e.i-t.i)),l=kA(a,r,l),o.forEach((e=>{l+=e.vs.length,a.push(e.vs),s+=e.barycenter*e.weight,i+=e.weight,l=kA(a,r,l)}));var c;let d={vs:a.flat(!0)};i&&(d.barycenter=s/i,d.weight=i);return d};var jA=function e(t,n,o,r){let a=t.children(n),s=t.node(n),i=s?s.borderLeft:void 0,l=s?s.borderRight:void 0,c={};i&&(a=a.filter((e=>e!==i&&e!==l)));let d=NA(t,a);d.forEach((n=>{if(t.children(n.v).length){let i=e(t,n.v,o,r);c[n.v]=i,Object.hasOwn(i,"barycenter")&&(s=i,void 0!==(a=n).barycenter?(a.barycenter=(a.barycenter*a.weight+s.barycenter*s.weight)/(a.weight+s.weight),a.weight+=s.weight):(a.barycenter=s.barycenter,a.weight=s.weight))}var a,s}));let u=EA(d,o);!function(e,t){e.forEach((e=>{e.vs=e.vs.flatMap((e=>t[e]?t[e].vs:e))}))}(u,c);let h=CA(u,r);if(i&&(h.vs=[i,h.vs,l].flat(!0),t.predecessors(i).length)){let e=t.node(t.predecessors(i)[0]),n=t.node(t.predecessors(l)[0]);Object.hasOwn(h,"barycenter")||(h.barycenter=0,h.weight=0),h.barycenter=(h.barycenter*h.weight+e.order+n.order)/(h.weight+2),h.weight+=2}return h};let SA=cI.Graph,IA=yI;let AA=function(e){let t={},n=e.nodes().filter((t=>!e.children(t).length)),o=n.map((t=>e.node(t).rank)),r=vA.applyWithChunking(Math.max,o),a=vA.range(r+1).map((()=>[]));return n.sort(((t,n)=>e.node(t).rank-e.node(n).rank)).forEach((function n(o){if(t[o])return;t[o]=!0;let r=e.node(o);a[r.rank].push(o),e.successors(o).forEach(n)})),a},MA=function(e,t){let n=0;for(let o=1;o<t.length;++o)n+=yA(e,t[o-1],t[o]);return n},TA=jA,OA=function(e,t,n){let o=function(e){var t;for(;e.hasNode(t=IA.uniqueId("_root")););return t}(e),r=new SA({compound:!0}).setGraph({root:o}).setDefaultNodeLabel((t=>e.node(t)));return e.nodes().forEach((a=>{let s=e.node(a),i=e.parent(a);(s.rank===t||s.minRank<=t&&t<=s.maxRank)&&(r.setNode(a),r.setParent(a,i||o),e[n](a).forEach((t=>{let n=t.v===a?t.w:t.v,o=r.edge(n,a),s=void 0!==o?o.weight:0;r.setEdge(n,a,{weight:e.edge(t).weight+s})})),Object.hasOwn(s,"minRank")&&r.setNode(a,{borderLeft:s.borderLeft[t],borderRight:s.borderRight[t]}))})),r},DA=function(e,t,n){let o,r={};n.forEach((n=>{let a,s,i=e.parent(n);for(;i;){if(a=e.parent(i),a?(s=r[a],r[a]=i):(s=o,o=i),s&&s!==i)return void t.setEdge(s,i);i=a}}))},_A=cI.Graph,PA=yI;var RA=function e(t,n){if(n&&"function"==typeof n.customOrder)return void n.customOrder(t,e);let o=PA.maxRank(t),r=FA(t,PA.range(1,o+1),"inEdges"),a=FA(t,PA.range(o-1,-1,-1),"outEdges"),s=AA(t);if(zA(t,s),n&&n.disableOptimalOrderHeuristic)return;let i,l=Number.POSITIVE_INFINITY;for(let c=0,d=0;d<4;++c,++d){LA(c%2?r:a,c%4>=2),s=PA.buildLayerMatrix(t);let e=MA(t,s);e<l&&(d=0,i=Object.assign({},s),l=e)}zA(t,i)};function FA(e,t,n){return t.map((function(t){return OA(e,t,n)}))}function LA(e,t){let n=new _A;e.forEach((function(e){let o=e.graph().root,r=TA(e,o,n,t);r.vs.forEach(((t,n)=>e.node(t).order=n)),DA(e,n,r.vs)}))}function zA(e,t){Object.values(t).forEach((t=>t.forEach(((t,n)=>e.node(t).order=n))))}let BA=cI.Graph,UA=yI;var VA=function(e){let t,n=UA.buildLayerMatrix(e),o=Object.assign($A(e,n),GA(e,n)),r={};["u","d"].forEach((a=>{t="u"===a?n:Object.values(n).reverse(),["l","r"].forEach((n=>{"r"===n&&(t=t.map((e=>Object.values(e).reverse())));let s=("u"===a?e.predecessors:e.successors).bind(e),i=qA(e,t,o,s),l=YA(e,t,i.root,i.align,"r"===n);"r"===n&&(l=UA.mapValues(l,(e=>-e))),r[a+n]=l}))}));let a=JA(e,r);return KA(r,a),XA(r,e.graph().align)};function $A(e,t){let n={};return t.length&&t.reduce((function(t,o){let r=0,a=0,s=t.length,i=o[o.length-1];return o.forEach(((t,l)=>{let c=function(e,t){if(e.node(t).dummy)return e.predecessors(t).find((t=>e.node(t).dummy))}(e,t),d=c?e.node(c).order:s;(c||t===i)&&(o.slice(a,l+1).forEach((t=>{e.predecessors(t).forEach((o=>{let a=e.node(o),s=a.order;!(s<r||d<s)||a.dummy&&e.node(t).dummy||HA(n,o,t)}))})),a=l+1,r=d)})),o})),n}function GA(e,t){let n={};function o(t,o,r,a,s){let i;UA.range(o,r).forEach((o=>{i=t[o],e.node(i).dummy&&e.predecessors(i).forEach((t=>{let o=e.node(t);o.dummy&&(o.order<a||o.order>s)&&HA(n,t,i)}))}))}return t.length&&t.reduce((function(t,n){let r,a=-1,s=0;return n.forEach(((i,l)=>{if("border"===e.node(i).dummy){let t=e.predecessors(i);t.length&&(r=e.node(t[0]).order,o(n,s,l,a,r),s=l,a=r)}o(n,s,n.length,r,t.length)})),n})),n}function HA(e,t,n){if(t>n){let e=t;t=n,n=e}let o=e[t];o||(e[t]=o={}),o[n]=!0}function WA(e,t,n){if(t>n){let e=t;t=n,n=e}return!!e[t]&&Object.hasOwn(e[t],n)}function qA(e,t,n,o){let r={},a={},s={};return t.forEach((e=>{e.forEach(((e,t)=>{r[e]=e,a[e]=e,s[e]=t}))})),t.forEach((e=>{let t=-1;e.forEach((e=>{let i=o(e);if(i.length){i=i.sort(((e,t)=>s[e]-s[t]));let o=(i.length-1)/2;for(let l=Math.floor(o),c=Math.ceil(o);l<=c;++l){let o=i[l];a[e]===e&&t<s[o]&&!WA(n,e,o)&&(a[o]=e,a[e]=r[e]=r[o],t=s[o])}}}))})),{root:r,align:a}}function YA(e,t,n,o,r){let a={},s=function(e,t,n,o){let r=new BA,a=e.graph(),s=function(e,t,n){return(o,r,a)=>{let s,i=o.node(r),l=o.node(a),c=0;if(c+=i.width/2,Object.hasOwn(i,"labelpos"))switch(i.labelpos.toLowerCase()){case"l":s=-i.width/2;break;case"r":s=i.width/2}if(s&&(c+=n?s:-s),s=0,c+=(i.dummy?t:e)/2,c+=(l.dummy?t:e)/2,c+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":s=l.width/2;break;case"r":s=-l.width/2}return s&&(c+=n?s:-s),s=0,c}}(a.nodesep,a.edgesep,o);return t.forEach((t=>{let o;t.forEach((t=>{let a=n[t];if(r.setNode(a),o){var i=n[o],l=r.edge(i,a);r.setEdge(i,a,Math.max(s(e,t,o),l||0))}o=t}))})),r}(e,t,n,r),i=r?"borderLeft":"borderRight";function l(e,t){let n=s.nodes(),o=n.pop(),r={};for(;o;)r[o]?e(o):(r[o]=!0,n.push(o),n=n.concat(t(o))),o=n.pop()}return l((function(e){a[e]=s.inEdges(e).reduce(((e,t)=>Math.max(e,a[t.v]+s.edge(t))),0)}),s.predecessors.bind(s)),l((function(t){let n=s.outEdges(t).reduce(((e,t)=>Math.min(e,a[t.w]-s.edge(t))),Number.POSITIVE_INFINITY),o=e.node(t);n!==Number.POSITIVE_INFINITY&&o.borderType!==i&&(a[t]=Math.max(a[t],n))}),s.successors.bind(s)),Object.keys(o).forEach((e=>a[e]=a[n[e]])),a}function JA(e,t){return Object.values(t).reduce(((t,n)=>{let o=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;Object.entries(n).forEach((([t,n])=>{let a=function(e,t){return e.node(t).width}(e,t)/2;o=Math.max(n+a,o),r=Math.min(n-a,r)}));const a=o-r;return a<t[0]&&(t=[a,n]),t}),[Number.POSITIVE_INFINITY,null])[1]}function KA(e,t){let n=Object.values(t),o=UA.applyWithChunking(Math.min,n),r=UA.applyWithChunking(Math.max,n);["u","d"].forEach((n=>{["l","r"].forEach((a=>{let s=n+a,i=e[s];if(i===t)return;let l=Object.values(i),c=o-UA.applyWithChunking(Math.min,l);"l"!==a&&(c=r-UA.applyWithChunking(Math.max,l)),c&&(e[s]=UA.mapValues(i,(e=>e+c)))}))}))}function XA(e,t){return UA.mapValues(e.ul,((n,o)=>{if(t)return e[t.toLowerCase()][o];{let t=Object.values(e).map((e=>e[o])).sort(((e,t)=>e-t));return(t[1]+t[2])/2}}))}let ZA=yI,QA=VA;let eM=MI,tM=OI,nM=sA,oM=yI.normalizeRanks,rM=function(e){let t=function(e){let t={},n=0;function o(r){let a=n;e.children(r).forEach(o),t[r]={low:a,lim:n++}}return e.children().forEach(o),t}(e);e.graph().dummyChains.forEach((n=>{let o=e.node(n),r=o.edgeObj,a=function(e,t,n,o){let r,a,s=[],i=[],l=Math.min(t[n].low,t[o].low),c=Math.max(t[n].lim,t[o].lim);r=n;do{r=e.parent(r),s.push(r)}while(r&&(t[r].low>l||c>t[r].lim));a=r,r=o;for(;(r=e.parent(r))!==a;)i.push(r);return{path:s.concat(i.reverse()),lca:a}}(e,t,r.v,r.w),s=a.path,i=a.lca,l=0,c=s[l],d=!0;for(;n!==r.w;){if(o=e.node(n),d){for(;(c=s[l])!==i&&e.node(c).maxRank<o.rank;)l++;c===i&&(d=!1)}if(!d){for(;l<s.length-1&&e.node(c=s[l+1]).minRank<=o.rank;)l++;c=s[l]}e.setParent(n,c),n=e.successors(n)[0]}}))},aM=yI.removeEmptyRanks,sM={run:function(e){let t=cA.addDummyNode(e,"root",{},"_root"),n=function(e){var t={};function n(o,r){var a=e.children(o);a&&a.length&&a.forEach((e=>n(e,r+1))),t[o]=r}return e.children().forEach((e=>n(e,1))),t}(e),o=Object.values(n),r=cA.applyWithChunking(Math.max,o)-1,a=2*r+1;e.graph().nestingRoot=t,e.edges().forEach((t=>e.edge(t).minlen*=a));let s=function(e){return e.edges().reduce(((t,n)=>t+e.edge(n).weight),0)}(e)+1;e.children().forEach((o=>dA(e,t,a,s,r,n,o))),e.graph().nodeRankFactor=a},cleanup:function(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach((t=>{e.edge(t).nestingEdge&&e.removeEdge(t)}))}},iM=function(e){e.children().forEach((function t(n){let o=e.children(n),r=e.node(n);if(o.length&&o.forEach(t),Object.hasOwn(r,"minRank")){r.borderLeft=[],r.borderRight=[];for(let t=r.minRank,o=r.maxRank+1;t<o;++t)hA(e,"borderLeft","_bl",n,r,t),hA(e,"borderRight","_br",n,r,t)}}))},lM={adjust:function(e){let t=e.graph().rankdir.toLowerCase();"lr"!==t&&"rl"!==t||fA(e)},undo:function(e){let t=e.graph().rankdir.toLowerCase();"bt"!==t&&"rl"!==t||function(e){e.nodes().forEach((t=>pA(e.node(t)))),e.edges().forEach((t=>{let n=e.edge(t);n.points.forEach(pA),Object.hasOwn(n,"y")&&pA(n)}))}(e);"lr"!==t&&"rl"!==t||(!function(e){e.nodes().forEach((t=>gA(e.node(t)))),e.edges().forEach((t=>{let n=e.edge(t);n.points.forEach(gA),Object.hasOwn(n,"x")&&gA(n)}))}(e),fA(e))}},cM=RA,dM=function(e){(function(e){let t=ZA.buildLayerMatrix(e),n=e.graph().ranksep,o=0;t.forEach((t=>{const r=t.reduce(((t,n)=>{const o=e.node(n).height;return t>o?t:o}),0);t.forEach((t=>e.node(t).y=o+r/2)),o+=r+n}))})(e=ZA.asNonCompoundGraph(e)),Object.entries(QA(e)).forEach((([t,n])=>e.node(t).x=n))},uM=yI,hM=cI.Graph;var fM=function(e,t){let n=t&&t.debugTiming?uM.time:uM.notime;n("layout",(()=>{let o=n(" buildLayoutGraph",(()=>function(e){let t=new hM({multigraph:!0,compound:!0}),n=NM(e.graph());return t.setGraph(Object.assign({},pM,kM(n,mM),uM.pick(n,gM))),e.nodes().forEach((n=>{const o=kM(NM(e.node(n)),vM);Object.keys(xM).forEach((e=>{void 0===o[e]&&(o[e]=xM[e])})),t.setNode(n,o),t.setParent(n,e.parent(n))})),e.edges().forEach((n=>{let o=NM(e.edge(n));t.setEdge(n,Object.assign({},bM,kM(o,yM),uM.pick(o,wM)))})),t}(e)));n(" runLayout",(()=>function(e,t,n){t(" makeSpaceForEdgeLabels",(()=>function(e){let t=e.graph();t.ranksep/=2,e.edges().forEach((n=>{let o=e.edge(n);o.minlen*=2,"c"!==o.labelpos.toLowerCase()&&("TB"===t.rankdir||"BT"===t.rankdir?o.width+=o.labeloffset:o.height+=o.labeloffset)}))}(e))),t(" removeSelfEdges",(()=>function(e){e.edges().forEach((t=>{if(t.v===t.w){var n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}}))}(e))),t(" acyclic",(()=>eM.run(e))),t(" nestingGraph.run",(()=>sM.run(e))),t(" rank",(()=>nM(uM.asNonCompoundGraph(e)))),t(" injectEdgeLabelProxies",(()=>function(e){e.edges().forEach((t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v),o={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};uM.addDummyNode(e,"edge-proxy",o,"_ep")}}))}(e))),t(" removeEmptyRanks",(()=>aM(e))),t(" nestingGraph.cleanup",(()=>sM.cleanup(e))),t(" normalizeRanks",(()=>oM(e))),t(" assignRankMinMax",(()=>function(e){let t=0;e.nodes().forEach((n=>{let o=e.node(n);o.borderTop&&(o.minRank=e.node(o.borderTop).rank,o.maxRank=e.node(o.borderBottom).rank,t=Math.max(t,o.maxRank))})),e.graph().maxRank=t}(e))),t(" removeEdgeLabelProxies",(()=>function(e){e.nodes().forEach((t=>{let n=e.node(t);"edge-proxy"===n.dummy&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))}))}(e))),t(" normalize.run",(()=>tM.run(e))),t(" parentDummyChains",(()=>rM(e))),t(" addBorderSegments",(()=>iM(e))),t(" order",(()=>cM(e,n))),t(" insertSelfEdges",(()=>function(e){var t=uM.buildLayerMatrix(e);t.forEach((t=>{var n=0;t.forEach(((t,o)=>{var r=e.node(t);r.order=o+n,(r.selfEdges||[]).forEach((t=>{uM.addDummyNode(e,"selfedge",{width:t.label.width,height:t.label.height,rank:r.rank,order:o+ ++n,e:t.e,label:t.label},"_se")})),delete r.selfEdges}))}))}(e))),t(" adjustCoordinateSystem",(()=>lM.adjust(e))),t(" position",(()=>dM(e))),t(" positionSelfEdges",(()=>function(e){e.nodes().forEach((t=>{var n=e.node(t);if("selfedge"===n.dummy){var o=e.node(n.e.v),r=o.x+o.width/2,a=o.y,s=n.x-r,i=o.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:r+2*s/3,y:a-i},{x:r+5*s/6,y:a-i},{x:r+s,y:a},{x:r+5*s/6,y:a+i},{x:r+2*s/3,y:a+i}],n.label.x=n.x,n.label.y=n.y}}))}(e))),t(" removeBorderNodes",(()=>function(e){e.nodes().forEach((t=>{if(e.children(t).length){let n=e.node(t),o=e.node(n.borderTop),r=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),s=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(s.x-a.x),n.height=Math.abs(r.y-o.y),n.x=a.x+n.width/2,n.y=o.y+n.height/2}})),e.nodes().forEach((t=>{"border"===e.node(t).dummy&&e.removeNode(t)}))}(e))),t(" normalize.undo",(()=>tM.undo(e))),t(" fixupEdgeLabelCoords",(()=>function(e){e.edges().forEach((t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch("l"!==n.labelpos&&"r"!==n.labelpos||(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset}}))}(e))),t(" undoCoordinateSystem",(()=>lM.undo(e))),t(" translateGraph",(()=>function(e){let t=Number.POSITIVE_INFINITY,n=0,o=Number.POSITIVE_INFINITY,r=0,a=e.graph(),s=a.marginx||0,i=a.marginy||0;function l(e){let a=e.x,s=e.y,i=e.width,l=e.height;t=Math.min(t,a-i/2),n=Math.max(n,a+i/2),o=Math.min(o,s-l/2),r=Math.max(r,s+l/2)}e.nodes().forEach((t=>l(e.node(t)))),e.edges().forEach((t=>{let n=e.edge(t);Object.hasOwn(n,"x")&&l(n)})),t-=s,o-=i,e.nodes().forEach((n=>{let r=e.node(n);r.x-=t,r.y-=o})),e.edges().forEach((n=>{let r=e.edge(n);r.points.forEach((e=>{e.x-=t,e.y-=o})),Object.hasOwn(r,"x")&&(r.x-=t),Object.hasOwn(r,"y")&&(r.y-=o)})),a.width=n-t+s,a.height=r-o+i}(e))),t(" assignNodeIntersects",(()=>function(e){e.edges().forEach((t=>{let n,o,r=e.edge(t),a=e.node(t.v),s=e.node(t.w);r.points?(n=r.points[0],o=r.points[r.points.length-1]):(r.points=[],n=s,o=a),r.points.unshift(uM.intersectRect(a,n)),r.points.push(uM.intersectRect(s,o))}))}(e))),t(" reversePoints",(()=>function(e){e.edges().forEach((t=>{let n=e.edge(t);n.reversed&&n.points.reverse()}))}(e))),t(" acyclic.undo",(()=>eM.undo(e)))}(o,n,t))),n(" updateInputGraph",(()=>function(e,t){e.nodes().forEach((n=>{let o=e.node(n),r=t.node(n);o&&(o.x=r.x,o.y=r.y,o.rank=r.rank,t.children(n).length&&(o.width=r.width,o.height=r.height))})),e.edges().forEach((n=>{let o=e.edge(n),r=t.edge(n);o.points=r.points,Object.hasOwn(r,"x")&&(o.x=r.x,o.y=r.y)})),e.graph().width=t.graph().width,e.graph().height=t.graph().height}(e,o)))}))};let mM=["nodesep","edgesep","ranksep","marginx","marginy"],pM={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},gM=["acyclicer","ranker","rankdir","align"],vM=["width","height"],xM={width:0,height:0},yM=["minlen","weight","width","height","labeloffset"],bM={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},wM=["labelpos"];function kM(e,t){return uM.mapValues(uM.pick(e,t),Number)}function NM(e){var t={};return e&&Object.entries(e).forEach((([e,n])=>{"string"==typeof e&&(e=e.toLowerCase()),t[e]=n})),t}let EM=yI,CM=cI.Graph;var jM={graphlib:cI,layout:fM,debug:{debugOrdering:function(e){let t=EM.buildLayerMatrix(e),n=new CM({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach((t=>{n.setNode(t,{label:t}),n.setParent(t,"layer"+e.node(t).rank)})),e.edges().forEach((e=>n.setEdge(e.v,e.w,{},e.name))),t.forEach(((e,t)=>{let o="layer"+t;n.setNode(o,{rank:"same"}),e.reduce(((e,t)=>(n.setEdge(e,t,{style:"invis"}),t)))})),n}},util:{time:yI.time,notime:yI.notime},version:"1.1.4"};const SM=(new jM.graphlib.Graph).setDefaultEdgeLabel((()=>({}))),IM=(e,t,n)=>(SM.setGraph({rankdir:n.direction,nodesep:150,ranksep:200,ranker:"longest-path"}),t.forEach((e=>SM.setEdge(e.source,e.target))),e.forEach((e=>SM.setNode(e.id,{...e,width:e.width??0,height:e.height??0}))),jM.layout(SM),{nodes:e.map((e=>{const{x:t,y:n}=SM.node(e.id);return{...e,position:{x:t,y:n}}})),edges:t}),AM=new class{createEdge(e,t){return{animated:!0,markerEnd:{type:ZN.ArrowClosed},id:`${e}-${t}`,style:{strokeWidth:2},source:e,sourceHandle:"outputs",targetHandle:"inputs",target:t}}createNode(e,t){return{id:e,data:{atom:t,forceWidth:300},width:300,type:"custom",height:vS(G.get(t).code.trim().split("\n").length),position:{x:0,y:0}}}createElements(e,t,n,o){const r=[],a=[],s=new Set,i=new Set;for(const l of Object.values(n)){if("marimo"===l.value&&"mo"===l.name)continue;const{declaredBy:e,usedBy:t}=l;for(const n of e)for(const e of t){const t=`${n}-${e}`;i.has(t)||(i.add(t),s.add(n),s.add(e),a.push(this.createEdge(n,e)))}}for(const[l,c]of Gr.zip(e,t)){o||r.push(this.createNode(l,c));const e=s.has(l),t=G.get(c).code.trim().startsWith("mo.md");!e&&t||r.push(this.createNode(l,c))}return{nodes:r,edges:a}}},MM=({cellIds:e,variables:t,cellAtoms:n,children:o,layoutDirection:a,settings:s})=>{const i=r.useMemo((()=>{let o=AM.createElements(e,n,t,s.hidePureMarkdown);return o=IM(o.nodes,o.edges,{direction:a}),o}),[]),[l,c,d]=Xj(i.nodes),[u,h,f]=Zj(i.edges),g=NC(),v=R((e=>{const t=IM(e.nodes,e.edges,{direction:a});c(t.nodes),h(t.edges)}));r.useEffect((()=>{v(AM.createElements(e,n,t,s.hidePureMarkdown))}),[e,t,n,v,s.hidePureMarkdown]);const[x,y]=r.useState();return CS(),m.jsx(xS.Provider,{value:a,children:m.jsxs(Jj,{nodes:l,edges:u,nodeTypes:bS,minZoom:.2,fitViewOptions:{minZoom:.5,maxZoom:1.5},onNodeClick:(e,t)=>{y({type:"node",id:t.id})},onEdgeClick:(e,t)=>{const{source:n,target:o}=t;y({type:"edge",source:n,target:o})},onNodeDoubleClick:(e,t)=>{Oa(t.id,"focus")},fitView:!0,onNodesChange:d,onEdgesChange:f,zoomOnDoubleClick:!1,nodesConnectable:!1,children:[m.jsx(gS,{color:"#ccc",variant:iS.Dots}),m.jsx(cS,{position:"bottom-right",showInteractive:!1,children:m.jsx(p,{content:"Jump to focused cell",usePortal:!1,delayDuration:200,side:"left",asChild:!1,children:m.jsx(rS,{onMouseDown:$e.preventFocus,onClick:()=>{const e=G.get(rd);if(e){const t=l.find((t=>t.id===e));t&&(g.fitView({padding:1,duration:600,nodes:[t]}),y({type:"node",id:e}))}},children:m.jsx(ec,{className:"size-4"})})})}),m.jsx(ES,{selection:x,variables:t,edges:u}),o]})})},TM=V("_minimap_"),OM=V({hidePureMarkdown:!0}),DM=e=>{const[t,n]=je(TM),[o,r]=je(OM);return m.jsx(Uj,{children:"_minimap_"===t?m.jsx(SS,{...e,children:m.jsx(NS,{settings:o,onSettingsChange:r,view:t,onChange:n})}):m.jsx(MM,{...e,settings:o,layoutDirection:t,children:m.jsx(NS,{settings:o,onSettingsChange:r,view:t,onChange:n})})},t)},_M=()=>{const e=Da(),t=te(),[n]=_a();return m.jsx("div",{className:$t("w-full h-full flex-1 mx-auto -mb-4 relative"),children:m.jsx(DM,{cellAtoms:n,variables:e,cellIds:t.inOrderIds})})};const PM="name",RM="type-value",FM="defs-refs",LM=[{id:PM,accessorFn:e=>[e.name,e.declaredBy],enableSorting:!0,sortingFn:"alphanumeric",header:({column:e})=>m.jsx(Ja,{header:"Name",column:e}),cell:({getValue:e})=>{const[t,n]=e();return m.jsx(kS,{name:t,declaredBy:n})}},{id:RM,accessorFn:e=>[e.dataType,e.value],enableSorting:!0,sortingFn:"alphanumeric",header:({column:e})=>m.jsx(Ja,{header:m.jsxs("div",{className:"flex flex-col gap-1",children:[m.jsx("span",{children:"Type"}),m.jsx("span",{children:"Value"})]}),column:e}),cell:({getValue:e})=>{const[t,n]=e();return m.jsxs("div",{className:"max-w-[150px]",children:[m.jsx("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap text-muted-foreground font-mono text-xs",children:t}),m.jsx("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap",title:n??"",children:n})]})}},{id:FM,accessorFn:e=>[e.declaredBy,e.usedBy,e.name,e.declaredByNames,e.usedByNames],enableSorting:!0,sortingFn:"basic",header:({column:e})=>m.jsx(Ja,{header:m.jsxs("div",{className:"flex flex-col gap-1",children:[m.jsx("span",{children:"Declared By"}),m.jsx("span",{children:"Used By"})]}),column:e}),cell:({getValue:e})=>{const[t,n,o]=e(),r=e=>{const t=lr(e);t&&Ma(t,o)};return m.jsxs("div",{className:"flex flex-col gap-1 py-1",children:[m.jsxs("div",{className:"flex flex-row overflow-auto gap-2 items-center",children:[m.jsx("span",{title:"Declared by",children:m.jsx(Nc,{className:"w-3.5 h-3.5 text-muted-foreground"})}),1===t.length?m.jsx(Ia,{variant:"focus",cellId:t[0],skipScroll:!0,onClick:()=>r(t[0])}):m.jsx("div",{className:"text-destructive flex flex-row gap-2",children:t.slice(0,3).map(((e,n)=>m.jsxs("span",{className:"flex",children:[m.jsx(Ia,{variant:"focus",cellId:e,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>r(e)},e),n<t.length-1&&", "]},e)))})]}),m.jsxs("div",{className:"flex flex-row overflow-auto gap-2 items-baseline",children:[m.jsx("span",{title:"Used by",children:m.jsx(_c,{className:"w-3.5 h-3.5 text-muted-foreground"})}),m.jsx(wS,{maxCount:3,cellIds:n,skipScroll:!0,onClick:r})]})]})}}];const zM=r.memo((({className:e,cellIds:t,variables:n})=>{const[o,a]=u.useState([]),[s,i]=u.useState(""),l=Pa(),c=r.useMemo((()=>{const e=e=>{const n=l[e];return n===Ya?`cell-${t.indexOf(e)}`:n??`cell-${t.indexOf(e)}`};return Object.values(n).map((t=>({...t,declaredByNames:t.declaredBy.map(e),usedByNames:t.usedBy.map(e)})))}),[n,l,t]),d=r.useMemo((()=>{const e=new Map;return t.forEach(((t,n)=>e.set(t,n))),function(e,t,n){t||(t={id:FM,desc:!1});let o=[];switch(t.id){case PM:o=wl(e,(e=>e.name));break;case RM:o=wl(e,(e=>e.dataType));break;case FM:o=wl(e,(e=>n.get(e.declaredBy[0])))}return t.desc?o.reverse():o}(c,o[0],e)}),[c,o,t]),h=Ra({data:d,columns:LM,getCoreRowModel:Fa(),onGlobalFilterChange:i,getFilteredRowModel:La(),enableFilters:!0,enableGlobalFilter:!0,getColumnCanGlobalFilter:e=>e.columnDef.enableGlobalFilter??!0,globalFilterFn:"auto",manualSorting:!0,onSortingChange:a,getSortedRowModel:za(),state:{sorting:o,globalFilter:s}});return m.jsxs(m.Fragment,{children:[m.jsx(Ba,{className:"w-full",placeholder:"Search",value:s,onChange:e=>i(e.target.value)}),m.jsxs(Ua,{className:$t("w-full text-sm flex-1 border-separate border-spacing-0",e),children:[m.jsx(Va,{children:m.jsx($a,{className:"whitespace-nowrap text-xs",children:h.getFlatHeaders().map((e=>m.jsx(Ga,{className:"sticky top-0 bg-background border-b",children:Ha(e.column.columnDef.header,e.getContext())},e.id)))})}),m.jsx(Wa,{children:h.getRowModel().rows.map((e=>m.jsx($a,{className:"hover:bg-accent",children:e.getVisibleCells().map((e=>m.jsx(qa,{className:"border-b",children:Ha(e.column.columnDef.cell,e.getContext())},e.id)))},e.id)))})]})]})}));zM.displayName="VariableTable";const BM=()=>{const e=Da(),t=te();return 0===Object.keys(e).length?m.jsx(Ik,{title:"No variables",description:"Global variables will appear here.",icon:m.jsx(Je,{})}):m.jsx(zM,{className:"flex-1",cellIds:t.inOrderIds,variables:e})},UM=()=>{const e=Ka(),{clearLogs:t}=L();return 0===e.length?m.jsx(Ik,{title:"No logs",description:m.jsxs("span",{children:[m.jsx("code",{className:"border rounded px-1",children:"stdout"})," and"," ",m.jsx("code",{className:"border rounded px-1",children:"stderr"})," logs will appear here."]}),icon:m.jsx(Ke,{})}):m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"flex flex-row justify-end px-2 py-1",children:m.jsx("button",{"data-testid":"clear-logs-button",className:"text-xs font-semibold text-accent-foreground",onClick:t,children:"Clear"})}),m.jsx("div",{className:"overflow-auto flex-1",children:m.jsx(VM,{logs:e,className:"min-w-[300px]"})})]})},VM=({logs:e,className:t})=>{const n="opacity-70 group-hover:bg-[var(--gray-3)] group-hover:opacity-100";return m.jsx("div",{className:$t("flex flex-col",t),children:m.jsx("pre",{className:"grid text-xs font-mono gap-1 whitespace-break-spaces font-semibold align-left",children:m.jsx("div",{className:"grid grid-cols-[30px,1fr]",style:{whiteSpace:"pre-wrap"},children:e.map(((e,t)=>m.jsxs("div",{className:"contents group",children:[m.jsx("span",{className:$t(n,"text-right col-span-1 py-1 pr-1"),children:t+1}),m.jsx("span",{className:$t(n,"px-2 flex gap-x-1.5 py-1 flex-wrap"),children:$M(e)})]},t)))})})})};function $M(e){const t=Xa(e.timestamp),n=GM[e.level],o=e.level.toUpperCase();return m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"flex-shrink-0 text-[var(--gray-10)]",children:["[",t,"]"]}),m.jsx("span",{className:$t("flex-shrink-0",n),children:o}),m.jsxs("span",{className:"flex-shrink-0 text-[var(--gray-10)]",children:["(",m.jsx(Ia,{cellId:e.cellId}),")"]}),e.message]})}const GM={stdout:"text-[var(--grass-9)]",stderr:"text-[var(--red-9)]"},HM=()=>{const{documentation:e}=X(Za);return e?m.jsx("div",{className:"p-3 overflow-y-auto overflow-x-hidden h-full docs-documentation flex flex-col gap-4",children:Or({html:e})}):m.jsx(Ik,{title:"View docs as you type",description:"Move your text cursor over a symbol to see its documentation.",icon:m.jsx(Mc,{})})};function WM(e,t,n){return e[t]?e[t][0]?e[t][0][n]:e[t][n]:"contentBoxSize"===t?e.contentRect["inlineSize"===n?"width":"height"]:void 0}function qM(e){void 0===e&&(e={});var t=e.onResize,n=r.useRef(void 0);n.current=t;var o=e.round||Math.round,a=r.useRef(),s=r.useState({width:void 0,height:void 0}),i=s[0],l=s[1],c=r.useRef(!1);r.useEffect((function(){return c.current=!1,function(){c.current=!0}}),[]);var d=r.useRef({width:void 0,height:void 0}),u=function(e,t){var n=r.useRef(null),o=r.useRef(null);o.current=t;var a=r.useRef(null);r.useEffect((function(){s()}));var s=r.useCallback((function(){var t=a.current,r=o.current,s=t||(r?r instanceof Element?r:r.current:null);n.current&&n.current.element===s&&n.current.subscriber===e||(n.current&&n.current.cleanup&&n.current.cleanup(),n.current={element:s,subscriber:e,cleanup:s?e(s):void 0})}),[e]);return r.useEffect((function(){return function(){n.current&&n.current.cleanup&&(n.current.cleanup(),n.current=null)}}),[]),r.useCallback((function(e){a.current=e,s()}),[s])}(r.useCallback((function(t){return a.current&&a.current.box===e.box&&a.current.round===o||(a.current={box:e.box,round:o,instance:new ResizeObserver((function(t){var r=t[0],a="border-box"===e.box?"borderBoxSize":"device-pixel-content-box"===e.box?"devicePixelContentBoxSize":"contentBoxSize",s=WM(r,a,"inlineSize"),i=WM(r,a,"blockSize"),u=s?o(s):void 0,h=i?o(i):void 0;if(d.current.width!==u||d.current.height!==h){var f={width:u,height:h};d.current.width=u,d.current.height=h,n.current?n.current(f):c.current||l(f)}}))}),a.current.instance.observe(t,{box:e.box}),function(){a.current&&a.current.instance.unobserve(t)}}),[e.box,o]),e.ref);return r.useMemo((function(){return{ref:u,width:i.width,height:i.height}}),[u,i.width,i.height])}const YM=new Map,JM=({file:e,onOpenNotebook:t})=>{const{theme:n}=we(),o=X(Se),[a,s]=r.useState(""),{data:i,loading:l,error:c,setData:d}=Ht((async()=>{const t=await Qa({path:e.path}),n=t.contents||"";return s(YM.get(e.path)||n),t}),[e.path]),u=async()=>{a!==(null==i?void 0:i.contents)&&await is({path:e.path,contents:a}).then((e=>{e.success&&(d((e=>e?{...e,contents:a}:void 0)),s(a))}))},h=r.useRef(a);if(h.current=a,r.useEffect((()=>()=>{if(!i)return;const t=h.current;t===i.contents?YM.delete(e.path):YM.set(e.path,t)}),[e.path,null==i?void 0:i.contents]),c)return m.jsx(es,{error:c});if(l||!i)return null;const f=i.mimeType||"text/plain",g=f in XM;if(!i.contents&&!g)return m.jsxs("div",{className:"grid grid-cols-2 gap-2 p-6",children:[m.jsx("div",{className:"font-bold text-muted-foreground",children:"Name"}),m.jsx("div",{children:i.file.name}),m.jsx("div",{className:"font-bold text-muted-foreground",children:"Type"}),m.jsx("div",{children:f})]});const v=m.jsxs("div",{className:"text-xs text-muted-foreground p-1 flex justify-end gap-2 border-b",children:[e.isMarimoFile&&!C()&&m.jsx(p,{content:"Open notebook",children:m.jsx(_s,{size:"small",onClick:e=>t(e),children:m.jsx(ts,{})})}),m.jsx(p,{content:"Download",children:m.jsx(_s,{size:"small",onClick:()=>{if(KM(f)){const e=ls(i.contents,f);cs(e,i.file.name)}else w(new Blob([i.contents||a],{type:f}),i.file.name)},children:m.jsx(dt,{})})}),!KM(f)&&m.jsxs(m.Fragment,{children:[m.jsx(p,{content:"Copy contents to clipboard",children:m.jsx(_s,{size:"small",onClick:()=>{navigator.clipboard.writeText(a)},children:m.jsx(Ve,{})})}),m.jsx(p,{content:Ds("global.save"),children:m.jsx(_s,{size:"small",color:a===i.contents?void 0:"green",onClick:u,disabled:a===i.contents,children:m.jsx(gc,{})})})]})]});return f.startsWith("image/")?m.jsxs(m.Fragment,{children:[v,m.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:m.jsx(ns,{base64:i.contents,mime:f})})]}):"text/csv"===f&&i.contents?m.jsxs(m.Fragment,{children:[v,m.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:m.jsx(os,{contents:i.contents})})]}):f.startsWith("audio/")?m.jsxs(m.Fragment,{children:[v,m.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:m.jsx(rs,{base64:i.contents,mime:f})})]}):f.startsWith("video/")?m.jsxs(m.Fragment,{children:[v,m.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:m.jsx(as,{base64:i.contents,mime:f})})]}):m.jsxs(m.Fragment,{children:[v,m.jsx("div",{className:"flex-1 overflow-auto",children:m.jsx(ss,{theme:"dark"===n?"dark":"light",language:XM[f]||XM.default,className:"border-b",extensions:[Dt.lineWrapping,Qt.of([{key:o.getHotkey("global.save").key,stopPropagation:!0,run:()=>a!==i.contents&&(u(),!0)}])],value:a,onChange:s})})]})},KM=e=>!!e&&(e.startsWith("image/")||e.startsWith("audio/")||e.startsWith("video/")),XM={"application/javascript":"javascript","text/markdown":"markdown","text/html":"html","text/css":"css","text/x-python":"python","application/json":"json","application/xml":"xml","text/x-yaml":"yaml","text/csv":"markdown","text/plain":"markdown",default:"markdown"};const ZM=V(new class{constructor(e){n(this,"delegate",new hi([])),n(this,"rootPath",""),n(this,"onChange",Gt.NOOP),n(this,"path",new tt("/")),n(this,"initialize",(async e=>{if(this.onChange=e,0===this.delegate.data.length)try{const e=await this.callbacks.listFiles({path:this.rootPath});this.delegate=new hi(e.files),this.rootPath=e.root,this.path=tt.guessDeliminator(e.root)}catch(t){q({title:"Failed",description:tr(t)})}this.onChange(this.delegate.data)})),n(this,"refreshAll",(async e=>{const t=[this.rootPath,...e.map((e=>{var t;return null==(t=this.delegate.find(e))?void 0:t.data.path}))].filter(Boolean),n=await Promise.all(t.map((e=>this.callbacks.listFiles({path:e}).catch((()=>({files:[]}))))));for(const[o,r]of t.entries()){const e=n[o];r===this.rootPath?this.delegate=new hi(e.files):this.delegate.update({id:r,changes:{children:e.files}})}this.onChange(this.delegate.data)})),n(this,"relativeFromRoot",(e=>{const t=function(e){return e.endsWith("/")?e:`${e}/`}(this.rootPath);return e.startsWith(t)?e.slice(t.length):e})),n(this,"handleResponse",(e=>e.success?e:(q({title:"Failed",description:e.message}),null))),this.callbacks=e}async expand(e){const t=this.delegate.find(e);if(!t)return!1;if(!t.data.isDirectory)return!1;if(t.children&&t.children.length>0)return!0;const n=await this.callbacks.listFiles({path:t.data.path});return this.delegate.update({id:e,changes:{children:n.files}}),this.onChange(this.delegate.data),!0}async rename(e,t){const n=this.delegate.find(e);if(!n)return;const o=n.data.path,r=this.path.join(this.path.dirname(o),t);await this.callbacks.renameFileOrFolder({path:o,newPath:r}).then(this.handleResponse),this.delegate.update({id:e,changes:{name:t,path:r}}),this.onChange(this.delegate.data),await this.refreshAll([r])}async move(e,t){var n;const o=t?(null==(n=this.delegate.find(t))?void 0:n.data.path)??t:this.rootPath;await Promise.all(e.map((e=>{this.delegate.move({id:e,parentId:t,index:0});const n=this.delegate.find(e);if(!n)return Promise.resolve();const r=this.path.join(o,this.path.basename(n.data.path));return this.delegate.update({id:e,changes:{path:r}}),this.callbacks.renameFileOrFolder({path:n.data.path,newPath:r}).then(this.handleResponse)}))),this.onChange(this.delegate.data),await this.refreshAll([o])}async createFile(e,t){var n;const o=t?(null==(n=this.delegate.find(t))?void 0:n.data.path)??t:this.rootPath,r=await this.callbacks.createFileOrFolder({path:o,type:"file",name:e}).then(this.handleResponse);(null==r?void 0:r.info)&&(this.delegate.create({parentId:t,index:0,data:r.info}),this.onChange(this.delegate.data),await this.refreshAll([o]))}async createFolder(e,t){var n;const o=t?(null==(n=this.delegate.find(t))?void 0:n.data.path)??t:this.rootPath,r=await this.callbacks.createFileOrFolder({path:o,type:"directory",name:e}).then(this.handleResponse);(null==r?void 0:r.info)&&(this.delegate.create({parentId:t,index:0,data:r.info}),this.onChange(this.delegate.data),await this.refreshAll([o]))}async delete(e){const t=this.delegate.find(e);t&&(await this.callbacks.deleteFileOrFolder({path:t.data.path}).then(this.handleResponse),this.delegate.drop({id:e}),this.onChange(this.delegate.data))}}({listFiles:Wt,createFileOrFolder:ds,deleteFileOrFolder:us,renameFileOrFolder:hs})),QM=V({});function eT(e={}){return fs({multiple:!0,maxSize:104857600,onError:e=>{U.error(e),q({title:"File upload failed",description:e.message,variant:"danger"})},onDropRejected:e=>{q({title:"File upload failed",description:m.jsx("div",{className:"flex flex-col gap-1",children:e.map((e=>m.jsxs("div",{children:[e.file.name," (",e.errors.map((e=>e.message)).join(", "),")"]},e.file.name)))}),variant:"danger"})},onDrop:async e=>{for(const t of e){const e=(await ms(t)).split(",")[1];await ds({path:"",type:"file",name:t.name,contents:e})}await async function(){await G.get(ZM).refreshAll([])}()},...e})}const tT=u.createContext(null),nT=({height:e})=>{const t=r.useRef(null),[n]=je(ZM),[o,a]=r.useState([]),[s,i]=r.useState(null),{openPrompt:l}=f(),[c,d]=je(QM),{loading:u,error:h}=Ht((()=>n.initialize(a)),[]),p=R((()=>{n.refreshAll(Object.keys(c).filter((e=>c[e])))})),g=R((async()=>{l({title:"Folder name",onConfirm:async e=>{n.createFolder(e,null)}})})),v=R((async()=>{l({title:"File name",onConfirm:async e=>{n.createFile(e,null)}})})),x=R((()=>{var e;null==(e=t.current)||e.closeAll(),d({})}));return u?m.jsx(pa,{size:"medium",centered:!0}):h?m.jsx(es,{error:h}):s?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex items-center pl-1 pr-3 flex-shrink-0 border-b justify-between",children:[m.jsx(b,{onClick:()=>i(null),"data-testid":"file-explorer-back-button",variant:"text",size:"xs",className:"mb-0",children:m.jsx(kl,{size:16})}),m.jsx("span",{className:"font-bold",children:s.name})]}),m.jsx(r.Suspense,{children:m.jsx(JM,{onOpenNotebook:e=>cT(e,n.relativeFromRoot(s.path)),file:s})})]}):m.jsxs(m.Fragment,{children:[m.jsx(rT,{onRefresh:p,onCreateFile:v,onCreateFolder:g,onCollapseAll:x,tree:n}),m.jsx(tT.Provider,{value:n,children:m.jsx(fi,{width:"100%",ref:t,height:e-33,className:"h-full",data:o,initialOpenState:c,openByDefault:!1,renderCursor:()=>null,disableDrop:({parentNode:e})=>!e.data.isDirectory,onDelete:async({ids:e})=>{for(const t of e)await n.delete(t)},onRename:async({id:e,name:t})=>{await n.rename(e,t)},onMove:async({dragIds:e,parentId:t})=>{await n.move(e,t)},onSelect:e=>{const t=e[0];t&&(t.data.isDirectory||i(t.data))},onToggle:async e=>{if(await n.expand(e)){const t=c[e]??!1;d({...c,[e]:!t})}},padding:15,rowHeight:30,indent:oT,overscanCount:1e3,disableMultiSelection:!0,children:iT})})]})},oT=15,rT=({tree:e,onRefresh:t,onCreateFile:n,onCreateFolder:o,onCollapseAll:r})=>{const{getRootProps:a,getInputProps:s}=eT({noDrag:!0,noDragEventsBubbling:!0});return m.jsxs("div",{className:"flex items-center justify-end px-2 flex-shrink-0 border-b",children:[m.jsx(p,{content:"Add file",children:m.jsx(b,{"data-testid":"file-explorer-add-file-button",onClick:n,variant:"text",size:"xs",children:m.jsx($l,{size:16})})}),m.jsx(p,{content:"Add folder",children:m.jsx(b,{"data-testid":"file-explorer-add-folder-button",onClick:o,variant:"text",size:"xs",children:m.jsx(Hl,{size:16})})}),m.jsx(p,{content:"Upload file",children:m.jsx("button",{"data-testid":"file-explorer-upload-button",...a({}),className:ps({variant:"text",size:"xs"}),children:m.jsx(gs,{size:16})})}),m.jsx("input",{...s({}),type:"file"}),m.jsx(p,{content:"Refresh",children:m.jsx(b,{"data-testid":"file-explorer-refresh-button",onClick:t,variant:"text",size:"xs",children:m.jsx(xr,{size:16})})}),m.jsx(p,{content:"Collapse all folders",children:m.jsx(b,{"data-testid":"file-explorer-collapse-button",onClick:r,variant:"text",size:"xs",children:m.jsx(zl,{size:16})})})]})},aT=({node:e,onOpenMarimoFile:t})=>m.jsxs("span",{className:"flex-1 overflow-hidden text-ellipsis",onClick:t=>{e.data.isDirectory||(t.stopPropagation(),e.select())},children:[e.data.name,e.data.isMarimoFile&&!C()&&m.jsxs("span",{className:"flex-shrink-0 ml-2 text-sm hidden group-hover:inline hover:underline",onClick:t,children:["open ",m.jsx(ts,{className:"inline ml-1",size:12})]})]}),sT=({node:e})=>{const t=r.useRef(null);return r.useEffect((()=>{var n,o;null==(n=t.current)||n.focus(),null==(o=t.current)||o.setSelectionRange(0,e.data.name.lastIndexOf("."))}),[e.data.name]),m.jsx("input",{ref:t,className:"flex-1 bg-transparent border border-border text-muted-foreground",defaultValue:e.data.name,onClick:e=>e.stopPropagation(),onBlur:()=>e.reset(),onKeyDown:t=>{"Escape"===t.key&&e.reset(),"Enter"===t.key&&e.submit(t.currentTarget.value)}})},iT=({node:e,style:t,dragHandle:n})=>{const o=e.data.isDirectory?"directory":qt(e.data.name),a=Zt[o],{openConfirm:s,openPrompt:i}=f(),l=r.useContext(tT),c=async t=>{cT(t,l?l.relativeFromRoot(e.data.path):e.data.path)},d=async t=>{t.stopPropagation(),t.preventDefault(),s({title:"Delete file",description:`Are you sure you want to delete ${e.data.name}?`,confirmAction:m.jsx(Ge,{onClick:async()=>{await e.tree.delete(e.id)},"aria-label":"Confirm",children:"Delete"})})},u=R((async()=>{e.open(),i({title:"Folder name",onConfirm:async t=>{null==l||l.createFolder(t,e.id)}})})),h=R((async()=>{e.open(),i({title:"File name",onConfirm:async t=>{null==l||l.createFile(t,e.id)}})}));return m.jsxs("div",{style:t,ref:n,className:$t("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group"),draggable:!0,onClick:t=>{t.stopPropagation(),e.data.isDirectory&&e.toggle()},children:[m.jsx(lT,{node:e}),m.jsxs("span",{className:$t("flex items-center pl-1 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden group",e.willReceiveDrop&&e.data.isDirectory&&"bg-accent/80 hover:bg-accent/80 text-accent-foreground"),children:[e.data.isMarimoFile?m.jsx("img",{src:"/favicon.ico",className:"w-5 h-5 flex-shrink-0 mr-2 filter grayscale",alt:"Marimo"}):m.jsx(a,{className:"w-5 h-5 flex-shrink-0 mr-2",strokeWidth:1.5}),e.isEditing?m.jsx(sT,{node:e}):m.jsx(aT,{node:e,onOpenMarimoFile:c}),m.jsxs(xt,{modal:!1,children:[m.jsx(yt,{asChild:!0,tabIndex:-1,onClick:e=>e.stopPropagation(),children:m.jsx(b,{"data-testid":"file-explorer-more-button",variant:"text",tabIndex:-1,size:"xs",className:"mb-0","aria-label":"More options",children:m.jsx(Bl,{strokeWidth:2,className:"w-5 h-5 hidden group-hover:block"})})}),(()=>{const t={size:14,strokeWidth:1.5,className:"mr-2"};return m.jsxs(bt,{align:"end",className:"no-print w-[220px]",onClick:e=>e.stopPropagation(),onCloseAutoFocus:e=>e.preventDefault(),children:[!e.data.isDirectory&&m.jsxs(St,{onSelect:()=>e.select(),children:[m.jsx(Oc,{...t}),"Open file"]}),e.data.isDirectory&&m.jsxs(m.Fragment,{children:[m.jsxs(St,{onSelect:()=>h(),children:[m.jsx($l,{...t}),"Create file"]}),m.jsxs(St,{onSelect:()=>u(),children:[m.jsx(Hl,{...t}),"Create folder"]}),m.jsx(Ct,{})]}),m.jsxs(St,{onSelect:()=>e.edit(),children:[m.jsx(dc,{...t}),"Rename"]}),m.jsxs(St,{onSelect:()=>{q({title:"Copied to clipboard"}),navigator.clipboard.writeText(e.data.path)},children:[m.jsx(Ve,{...t}),"Copy path"]}),l&&m.jsxs(St,{onSelect:()=>{q({title:"Copied to clipboard"}),navigator.clipboard.writeText(l.relativeFromRoot(e.data.path))},children:[m.jsx(Ve,{...t}),"Copy relative path"]}),m.jsxs(St,{onSelect:()=>{q({title:"Copied to clipboard",description:"Code to open the file has been copied to your clipboard. You can also drag and drop this file into the editor"});const{path:t}=e.data,n=vs[o](t);navigator.clipboard.writeText(n)},children:[m.jsx(xs,{...t}),"Copy snippet for reading file"]}),e.data.isMarimoFile&&!C()&&m.jsxs(m.Fragment,{children:[m.jsx(Ct,{}),m.jsxs(St,{onSelect:c,children:[m.jsx(Cc,{...t}),"Open notebook"]})]}),m.jsx(Ct,{}),m.jsxs(St,{onSelect:d,variant:"danger",children:[m.jsx(xe,{...t}),"Delete"]})]})})()]})]})]})},lT=({node:e})=>e.data.isDirectory?e.isOpen?m.jsx(ge,{className:"w-5 h-5 flex-shrink-0"}):m.jsx(gr,{className:"w-5 h-5 flex-shrink-0"}):m.jsx("span",{className:"w-5 h-5 flex-shrink-0"});function cT(e,t){e.stopPropagation(),e.preventDefault(),window.open(`/?file=${t}`,"_blank")}const dT=()=>{const{ref:e,height:t=1}=qM(),{getRootProps:n,getInputProps:o,isDragActive:r}=eT({noClick:!0,noKeyboard:!0});return m.jsxs("div",{...n(),className:$t("flex flex-col flex-1 overflow-hidden relative"),children:[m.jsx("input",{...o()}),r&&m.jsx("div",{className:"absolute inset-0 flex items-center uppercase justify-center text-xl font-bold text-primary/90 bg-accent/85 z-10 border-2 border-dashed border-primary/90 rounded-lg pointer-events-none",children:"Drop files here"}),m.jsx("div",{ref:e,className:"flex flex-col flex-1 overflow-hidden",children:m.jsx(nT,{height:t})})]})},uT=({children:e})=>{const{openModal:t,closeModal:n}=f();return m.jsx(xa,{onClick:()=>t(m.jsx(fT,{onClose:n})),children:e})},hT=[Dt.lineWrapping],fT=({onClose:e})=>{const[t,n]=r.useState(""),{theme:o}=we();return m.jsx(g,{className:"w-fit",children:m.jsxs("form",{onSubmit:async t=>{t.preventDefault();const n=new FormData(t.target),o=n.get("title"),r=n.get("description"),a=n.get("code");fetch("https://marimo.io/api/suggest-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:o,description:r,code:a})}),e(),q({title:"Snippet Submitted",description:"Thank you for contributing! We will review your snippet shortly."})},children:[m.jsxs(re,{children:[m.jsx(v,{children:"Contribute a Snippet"}),m.jsxs(x,{children:["Have a useful snippet you want to share with the community? Submit it here or make a pull request"," ",m.jsx("a",{href:Be.githubPage,target:"_blank",rel:"noreferrer",className:"underline",children:"on GitHub"}),"."]})]}),m.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[m.jsx(Ue,{id:"title",name:"title",autoFocus:!0,placeholder:"Title",required:!0,autoComplete:"off"}),m.jsx(ya,{id:"description",name:"description",autoFocus:!0,placeholder:"Description",rows:5,required:!0,autoComplete:"off"}),m.jsx("input",{type:"hidden",name:"code",value:t}),m.jsx(ss,{theme:"dark"===o?"dark":"light",language:"python",className:"cm border rounded overflow-hidden",extensions:hT,value:t,onChange:n})]}),m.jsxs(y,{children:[m.jsx(b,{"data-testid":"snippet-cancel-button",variant:"secondary",onClick:e,children:"Cancel"}),m.jsx(b,{"data-testid":"snippet-send-button","aria-label":"Save",variant:"default",type:"submit",children:"Send"})]})]})})},mT=[Dt.lineWrapping],pT=()=>{const[e,t]=u.useState(),{data:n,error:o,loading:a}=Ht((()=>ys()),[]);return o?m.jsx(es,{error:o}):a||!n?m.jsx(pa,{size:"medium",centered:!0}):m.jsxs("div",{className:"flex-1 overflow-hidden",children:[m.jsxs(Jt,{className:$t("border-b rounded-none",e?"h-1/3":"h-full"),children:[m.jsxs("div",{className:"flex items-center w-full",children:[m.jsx(Te,{placeholder:"Search snippets...",className:"h-6 m-1",rootClassName:"flex-1 border-r"}),m.jsx(uT,{children:m.jsx("button",{className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",children:m.jsx(No,{className:"h-4 w-4"})})})]}),m.jsx(De,{children:"No results"}),m.jsx(vT,{onSelect:e=>t(e),snippets:n.snippets})]}),m.jsx(r.Suspense,{children:m.jsx("div",{className:"h-2/3 snippet-viewer flex flex-col",children:e?m.jsx(gT,{snippet:e},e.title):m.jsx(Ik,{title:"",description:"Click on a snippet to view its content."})})})]})},gT=({snippet:e})=>{const{theme:t}=we(),{createNewCell:n}=L(),o=ad();return m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"text-sm font-semibold bg-muted border-y px-2 py-1",children:e.title}),m.jsxs("div",{className:"px-2 py-2 space-y-4 overflow-auto flex-1",children:[m.jsx("div",{className:"flex justify-end",children:m.jsx(Yd,{children:m.jsxs(b,{className:"float-right",size:"xs",variant:"outline",onClick:()=>{for(const t of[...e.sections].reverse())t.code&&n({code:t.code,before:!1,cellId:o??"__end__"})},children:["Insert snippet",m.jsx(Sl,{className:"ml-2 h-4 w-4"})]})})}),e.sections.map((r=>{const{code:a,html:s,id:i}=r;return s?m.jsx("div",{children:Or({html:s})},`${e.title}-${i}`):a?m.jsxs("div",{className:"relative hover-actions-parent pr-2",children:[m.jsx(Yd,{children:m.jsx(p,{content:"Insert snippet",children:m.jsx(b,{className:"absolute -top-2 -right-1 z-10 hover-action px-2 bg-background",size:"sm",variant:"outline",onClick:()=>{(e=>{n({code:e,before:!1,cellId:o??"__end__"})})(a)},children:m.jsx(Sl,{className:"h-5 w-5"})})})}),m.jsx(ss,{theme:"dark"===t?"dark":"light",language:"python",className:"cm border rounded overflow-hidden",extensions:mT,value:a,readOnly:!0},`${e.title}-${i}`)]},`${e.title}-${i}`):null}))]})]})},vT=({snippets:e,onSelect:t})=>m.jsx(To,{className:"flex flex-col overflow-auto",children:e.map((e=>m.jsx(Fe,{className:"rounded-none",onSelect:()=>t(e),children:m.jsx("div",{className:"flex flex-row gap-2 items-center",children:m.jsx("span",{className:"mt-1 text-accent-foreground",children:e.title})})},e.title)))}),xT=({value:e,className:t,tooltip:n})=>{const[o,a]=r.useState(!1),s=$e.stopPropagation((()=>{navigator.clipboard.writeText(e).then((()=>{a(!0),setTimeout((()=>a(!1)),2e3)}))})),i=m.jsx("span",{onClick:s,children:o?m.jsx(pt,{className:$t(t,"text-[var(--grass-11)]")}):m.jsx(Ve,{className:t})});return!1===n?i:m.jsx(p,{content:o?"Copied!":n??"Copy to clipboard",delayDuration:400,children:i})},yT=V((e=>{const t=e(qo),n=e(Y),o=e(ha);return wl(t,(e=>{if(!e.variable_name)return-1;const t=Object.values(n).find((t=>t.name===e.variable_name));if(!t)return 0;const r=o.inOrderIds.indexOf(t.declaredBy[0]);return-1===r?0:r}))})),bT=()=>{const[e,t]=u.useState(""),n=X(ee),o=ad(),{expandedColumns:r,expandedTables:a,columnsPreviews:s}=bs(),{toggleTable:i,toggleColumn:l,closeAllColumns:c}=ws(),{createNewCell:d}=L(),h=X(yT);if(0===h.length)return m.jsx(Ik,{title:"No tables found",description:"Any datasets/dataframes in the global scope will be shown here.",icon:m.jsx(de,{})});const f=!!e.trim();return m.jsx("div",{className:"flex-1 overflow-hidden",children:m.jsxs(Jt,{className:$t("border-b bg-background rounded-none","h-full"),children:[m.jsxs("div",{className:"flex items-center w-full",children:[m.jsx(Te,{placeholder:"Search tables...",className:"h-6 m-1",value:e,onValueChange:e=>{e.length>0&&c(),t(e)},rootClassName:"flex-1 border-r"}),f&&m.jsx("button",{type:"button",className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",onClick:()=>t(""),children:m.jsx(Bt,{className:"h-4 w-4"})})]}),m.jsx(wT,{onAddColumnChart:e=>{e.includes("alt")&&function(e,t,n){td("altair","alt",(o=>{const r=K.create();t({cellId:n??"__end__",before:!1,code:o,lastCodeRun:e?o:void 0,newCellId:r,autoFocus:!1}),e&&B({cellIds:[r],codes:[o]})}))}(n,d,o),d({code:e,before:!1,cellId:o??"__end__"})},onAddTable:e=>{nd(n,d,o);let t="";switch(e.source_type){case"local":t=`mo.ui.table(${e.name})`;break;case"duckdb":t=`_df = mo.sql(f"SELECT * FROM ${e.name} LIMIT 100")`;break;default:k(e.source_type)}d({code:t,before:!1,cellId:o??"__end__"})},onExpandColumn:(e,t)=>{const n=`${e.name}:${t.name}`;l({table:e.name,column:t.name}),s.has(n)||ks({source:e.source,tableName:e.name,columnName:t.name,sourceType:e.source_type})},onExpandTable:e=>{i(e.name)},columnPreviews:s,tables:h,isSearching:f,isTableExpanded:e=>!!f||a.has(e.name),isColumnExpanded:(e,t)=>{const n=`${e.name}:${t.name}`;return r.has(n)}})]})})},wT=({tables:e,isSearching:t,columnPreviews:n,onAddColumnChart:o,onAddTable:r,onExpandTable:a,onExpandColumn:s,isTableExpanded:i,isColumnExpanded:l})=>{let c=Object.entries(Ie.groupBy(e,(e=>e.source),(e=>e)));c=wl(c,(([e])=>"memory"===e?0:1));const d=e=>{const c=i(e),d=[m.jsx(kT,{table:e,forceMount:t,onExpand:()=>a(e),onAddTable:()=>r(e),isExpanded:c},e.name)];return c&&d.push(...e.columns.map((t=>m.jsxs(u.Fragment,{children:[m.jsx(NT,{table:e,column:t,onExpandColumn:s,isExpanded:l(e,t)},`${e.name}.${t.name}`),l(e,t)&&m.jsx("div",{className:"pl-10 pr-2 py-2 bg-[var(--slate-1)] shadow-inner border-b",children:m.jsx(Es,{children:m.jsx(CT,{table:e,column:t,onAddColumnChart:o,preview:n.get(`${e.name}:${t.name}`)})})})]},`${e.name}.${t.name}`)))),d};return m.jsx(To,{className:"flex flex-col overflow-auto",children:0===c.length?null:1===c.length?c[0][1].flatMap(d):c.flatMap((([e,t],n)=>[m.jsx("div",{className:$t("font-bold px-2 py-1 text-muted-foreground bg-[var(--slate-2)] border-t text-sm",n>0&&"border-t"),children:"memory"===e?"In-Memory":e},e),...t.flatMap(d)]))})},kT=({table:e,onExpand:t,onAddTable:n,isExpanded:o})=>m.jsxs(Fe,{className:"rounded-none py-1 group min-h-9 border-t",value:e.name,"aria-selected":o,forceMount:!0,onSelect:t,children:[m.jsxs("div",{className:"flex gap-1 items-center flex-1",children:[m.jsx(gr,{className:$t("h-3 w-3 transition-transform",o&&"rotate-90")}),m.jsx("span",{className:"text-sm",children:e.name})]}),(()=>{const t=[];return null!=e.num_rows&&t.push(`${e.num_rows} rows`),null!=e.num_columns&&t.push(`${e.num_columns} columns`),0===t.length?null:m.jsx("div",{className:"flex flex-row gap-2 items-center pl-6 group-hover:hidden",children:m.jsx("span",{className:"text-xs text-muted-foreground",children:t.join(", ")})})})(),m.jsx(p,{content:"Add table to notebook",delayDuration:400,children:m.jsx(b,{className:"group-hover:inline-flex hidden",variant:"text",size:"icon",onClick:$e.stopPropagation((()=>n(e))),children:m.jsx(jc,{className:"h-3 w-3"})})})]}),NT=({table:e,column:t,onExpandColumn:n})=>{const o=Cs[t.type];return m.jsxs(Fe,{className:"rounded-none py-1 group",value:`${e.name}.${t.name}`,onSelect:()=>n(e,t),children:[m.jsxs("div",{className:"flex flex-row gap-2 items-center pl-6 flex-1",children:[m.jsx(o,{className:"flex-shrink-0 h-3 w-3",strokeWidth:1.5}),m.jsx("span",{children:t.name})]}),m.jsx(p,{content:"Copy column name",delayDuration:400,children:m.jsx(b,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:m.jsx(xT,{tooltip:!1,value:t.name,className:"h-3 w-3"})})}),m.jsx("span",{className:"text-xs text-muted-foreground",children:t.external_type})]},`${e.name}.${t.name}`)},ET=u.lazy((()=>Ns((()=>import("./index-Br4oqDgh.js")),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]),import.meta.url).then((e=>({default:e.VegaLite}))))),CT=({table:e,column:t,preview:n,onAddColumnChart:o})=>{const{theme:r}=we();if(!n)return m.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading..."});const a=n.error&&m.jsx("span",{className:"text-xs text-muted-foreground",children:n.error}),s=n.summary&&m.jsx("div",{className:"gap-x-16 gap-y-1 grid grid-cols-2-fit border rounded p-2 empty:hidden",children:Object.entries(n.summary).map((([e,t])=>null==t?null:m.jsxs("div",{className:"flex items-center gap-1 group",children:[m.jsx(xT,{className:"h-3 w-3 invisible group-hover:visible",value:String(t)}),m.jsx("span",{className:"text-xs min-w-[60px] uppercase",children:e}),m.jsx("span",{className:"text-xs font-bold text-muted-foreground tracking-wide",children:js(t)})]},e)))}),i=n.chart_spec&&m.jsx(ET,{spec:(l=JSON.parse(n.chart_spec),{...l,config:{...l.config,background:"transparent"}}),width:"container",height:100,actions:!1,theme:"dark"===r?"dark":"vox"});var l;const c=n.chart_code&&"local"===e.source_type&&m.jsx(p,{content:"Add chart to notebook",delayDuration:400,children:m.jsx(b,{variant:"outline",size:"icon",className:"z-10 bg-background absolute right-1 -top-1",onClick:$e.stopPropagation((()=>o(n.chart_code||""))),children:m.jsx(jc,{className:"h-3 w-3"})})}),d="duckdb"===e.source_type&&m.jsx(p,{content:"Add SQL cell",delayDuration:400,children:m.jsx(b,{variant:"outline",size:"icon",className:"z-10 bg-background absolute right-1 -top-1",onClick:$e.stopPropagation((()=>{const n=`_df = mo.sql(f'SELECT "${t.name}" FROM ${e.name} LIMIT 100')`;o(n)})),children:m.jsx(jc,{className:"h-3 w-3"})})}),u=n.chart_max_rows_errors&&m.jsx("span",{className:"text-xs text-muted-foreground",children:"Too many rows to render the chart."});return a||s||i||u?m.jsxs("div",{className:"flex flex-col gap-2 relative",children:[a,c,d,u,i,s]}):m.jsx("span",{className:"text-xs text-muted-foreground",children:"No data"})},jT=({isOpen:e,children:t})=>{const[n,o]=u.useState(!1);return u.useEffect((()=>{e&&!n&&o(!0)}),[e,n]),n?t:null},ST=()=>{const e=P(),[t]=ke(),{theme:n}=we(),o=r.useRef(null),a=ad(),{createNewCell:s,updateCellCode:i}=L(),l=be,c=e.cellRuntime[l],d=null==c?void 0:c.output,u=null==c?void 0:c.status,h=null==c?void 0:c.consoleOutputs,f=e.cellData[l],g=(null==f?void 0:f.code)??"",v=R((()=>{Ss({code:g})})),x=R((()=>{g.trim()&&s({code:g,before:!1,cellId:a??"__end__"})})),y=R((()=>{i({cellId:l,code:"",formattingChange:!1}),Ss({code:""});const e=o.current;e&&e.dispatch({changes:{from:0,to:e.state.doc.length,insert:""}})}));return m.jsxs("div",{className:"flex flex-col h-full overflow-hidden divide-y",id:Qe.create(l),children:[m.jsxs("div",{className:"flex items-center flex-shrink-0",children:[m.jsx(p,{content:Ds("cell.run"),children:m.jsx(b,{"data-testid":"scratchpad-run-button",onClick:v,variant:"text",size:"xs",children:m.jsx(uc,{color:"var(--grass-11)",size:16})})}),m.jsx(p,{content:"Clear code and outputs",children:m.jsx(b,{size:"xs",variant:"text",onClick:y,children:m.jsx(Ul,{size:16})})}),m.jsx(Yd,{children:m.jsx(p,{content:"Insert code",children:m.jsx(b,{size:"xs",variant:"text",onClick:x,children:m.jsx(Sl,{size:16})})})}),("running"===u||"queued"===u)&&m.jsx(pa,{className:"inline",size:"small"})]}),m.jsx("div",{className:"overflow-auto flex-shrink-0 max-h-[40%]",children:m.jsx(tb,{theme:n,allowFocus:!1,showPlaceholder:!1,id:l,code:g,status:"idle",serializedEditorState:null,runCell:v,updateCellCode:i,createNewCell:Gt.NOOP,deleteCell:Gt.NOOP,focusCell:Gt.NOOP,moveCell:Gt.NOOP,moveToNextCell:void 0,updateCellConfig:Gt.NOOP,clearSerializedEditorState:Gt.NOOP,userConfig:t,editorViewRef:o,hidden:!1})}),m.jsx("div",{className:"flex-1 overflow-auto flex-shrink-0",children:m.jsx(jr,{allowExpand:!1,output:d,className:"output-area",cellId:l,stale:!1})}),m.jsx("div",{className:"overflow-auto flex-shrink-0 max-h-[35%]",children:m.jsx(Ji,{consoleOutputs:h,className:"overflow-auto",stale:!1,cellName:Ya,onSubmitDebugger:Gt.NOOP,cellId:l,debuggerActive:!1})})]})},IT=()=>m.jsx(ST,{}),AT=()=>{const[e]=ke(),t=e.package_management.manager,{data:n,loading:o,error:r,reload:a}=Ht((()=>Is()),[t]);if(o&&!n)return m.jsx(pa,{size:"medium",centered:!0});if(r)return m.jsx(es,{error:r});const s=(null==n?void 0:n.packages)||[];return m.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[m.jsx(MT,{packageManager:t,onSuccess:a}),m.jsx(TT,{packages:s,onSuccess:a})]})},MT=({onSuccess:e,packageManager:t})=>{const[n,o]=u.useState(""),[r,a]=u.useState(!1),s=async()=>{try{a(!0);const t=await Ms({package:n});t.success?(e(),q({title:"Package added",description:m.jsxs("span",{children:["The package ",m.jsx(ai,{className:"inline",children:n})," and its dependencies has been added to your environment."]})})):q({title:"Failed to add package",description:t.error,variant:"danger"})}finally{o(""),a(!1)}};return m.jsxs("div",{className:"flex items-center w-full border-b",children:[m.jsx(Ba,{placeholder:`Install packages with ${t}...`,icon:r?m.jsx(pa,{size:"small",className:"mr-2 h-4 w-4 shrink-0 opacity-50"}):m.jsx(Al,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),rootClassName:"flex-1 border-none",value:n,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),s())},onChange:e=>o(e.target.value)}),m.jsx(p,{delayDuration:300,side:"left",align:"start",content:m.jsxs("div",{className:"text-sm flex flex-col w-full max-w-[360px]",children:["Packages are installed using the package manager specified in your user configuration. Depending on your package manager, you can install packages with various formats:",m.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[m.jsxs("div",{children:[m.jsx("span",{className:"font-bold tracking-wide",children:"Package name:"})," A package name; this will install the latest version.",m.jsx("div",{className:"text-muted-foreground",children:"Example: httpx"})]}),m.jsxs("div",{children:[m.jsx("span",{className:"font-bold tracking-wide",children:"Package and version:"})," ","A package with a specific version or version range.",m.jsx("div",{className:"text-muted-foreground",children:"Examples: httpx==0.27.0, httpx>=0.27.0"})]}),m.jsxs("div",{children:[m.jsx("span",{className:"font-bold tracking-wide",children:"Git:"})," A Git repository",m.jsx("div",{className:"text-muted-foreground",children:"Example: git+https://github.com/encode/httpx"})]}),m.jsxs("div",{children:[m.jsx("span",{className:"font-bold tracking-wide",children:"URL:"})," A remote wheel or source distribution.",m.jsx("div",{className:"text-muted-foreground",children:"Example: https://example.com/httpx-0.27.0.tar.gz"})]}),m.jsxs("div",{children:[m.jsx("span",{className:"font-bold tracking-wide",children:"Path:"})," A local wheel, source distribution, or project directory.",m.jsx("div",{className:"text-muted-foreground",children:"Example: /example/foo-0.1.0-py3-none-any.whl"})]})]})]}),children:m.jsx(As,{className:"h-4 w-4 cursor-help text-muted-foreground hover:text-foreground bg-transparent"})}),m.jsx("button",{type:"button",className:$t("float-right px-2 m-0 h-full text-sm text-secondary-foreground ml-2",n&&"bg-accent text-accent-foreground","disabled:cursor-not-allowed disabled:opacity-50"),onClick:s,disabled:!n,children:"Add"})]})},TT=({onSuccess:e,packages:t})=>0===t.length?m.jsx(Ik,{title:"No packages",description:"No packages are installed in this environment.",icon:m.jsx(Al,{})}):m.jsxs(Ua,{className:"overflow-auto flex-1",children:[m.jsx(Va,{children:m.jsxs($a,{children:[m.jsx(Ga,{children:"Name"}),m.jsx(Ga,{children:"Version"}),m.jsx(Ga,{})]})}),m.jsx(Wa,{children:t.map((t=>m.jsxs($a,{className:"group",onClick:()=>{navigator.clipboard.writeText(`${t.name}==${t.version}`),q({title:"Copied to clipboard"})},children:[m.jsx(qa,{children:t.name}),m.jsx(qa,{children:t.version}),m.jsx(qa,{children:m.jsx(OT,{packageName:t.name,onSuccess:e})})]},t.name)))})]}),OT=({packageName:e,onSuccess:t})=>{const[n,o]=u.useState(!1);return n?m.jsx(pa,{size:"small",className:"float-right mr-2 h-4 w-4 shrink-0 opacity-50"}):m.jsx("button",{type:"button",className:$t("float-right px-2 h-full text-xs text-muted-foreground hover:text-foreground","invisible group-hover:visible"),onClick:$e.stopPropagation((async()=>{try{o(!0);const n=await Ts({package:e});n.success?(t(),q({title:"Package removed",description:m.jsxs("span",{children:["The package ",m.jsx(ai,{className:"inline",children:e})," has been removed from your environment."]})})):q({title:"Failed to add package",description:n.error,variant:"danger"})}finally{o(!1)}})),children:"Remove"})},DT=u.lazy((()=>Ns((()=>import("./terminal-BfyxvY8t.js")),__vite__mapDeps([15,2,3,16]),import.meta.url))),_T=({children:e})=>{const{isSidebarOpen:t,isTerminalOpen:n,selectedPanel:o}=bd(),{setIsSidebarOpen:a,setIsTerminalOpen:s}=wd(),i=u.useRef(null),l=u.useRef(null);r.useEffect((()=>{if(!i.current)return;const e=i.current.isCollapsed();t&&e&&i.current.expand(),t||e||i.current.collapse(),requestAnimationFrame((()=>{requestAnimationFrame((()=>{window.dispatchEvent(new Event("resize"))}))}))}),[t]),r.useEffect((()=>{if(!l.current)return;const e=l.current.isCollapsed();n&&e&&l.current.expand(),n||e||l.current.collapse(),requestAnimationFrame((()=>{requestAnimationFrame((()=>{window.dispatchEvent(new Event("resize"))}))}))}),[n]);const c=m.jsx(Jb,{id:"app",className:"relative h-full",children:m.jsx(r.Suspense,{children:e})},"app"),d=e=>{e||window.dispatchEvent(new Event("resize"))},h=m.jsx(ok,{onDragging:d,className:$t("border-border no-print z-10",t?"resize-handle":"resize-handle-collapsed","vertical")}),f=m.jsx(ok,{onDragging:d,className:$t("border-border no-print z-20",n?"resize-handle":"resize-handle-collapsed","horizontal")}),p=m.jsx(Es,{children:m.jsx(r.Suspense,{children:m.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden mr-[-4px]",children:[m.jsxs("div",{className:"p-3 border-b flex justify-between items-center",children:[m.jsx("div",{className:"text-sm text-[var(--slate-11)] uppercase tracking-wide font-semibold flex-1",children:o}),m.jsx(b,{"data-testid":"close-helper-pane",className:"m-0",size:"xs",variant:"text",onClick:()=>a(!1),children:m.jsx(Bt,{className:"w-4 h-4"})})]}),"files"===o&&m.jsx(dT,{}),"errors"===o&&m.jsx(Ak,{}),"variables"===o&&m.jsx(BM,{}),"dependencies"===o&&m.jsx(_M,{}),"packages"===o&&m.jsx(AT,{}),"outline"===o&&m.jsx(Mk,{}),"datasources"===o&&m.jsx(bT,{}),"documentation"===o&&m.jsx(HM,{}),"snippets"===o&&m.jsx(pT,{}),"scratchpad"===o&&m.jsx(IT,{}),"logs"===o&&m.jsx(UM,{})]})})}),g=m.jsx(Jb,{ref:i,id:"helper",collapsedSize:0,collapsible:!0,className:$t("dark:bg-[var(--slate-1)] no-print print:hidden",t&&"border-r border-l border-[var(--slate-7)]"),minSize:10,defaultSize:0,maxSize:75,onResize:(e,t)=>{var n;0===t&&10===e&&(null==(n=i.current)||n.resize(30))},onCollapse:()=>a(!1),onExpand:()=>a(!0),children:m.jsxs("span",{className:"flex flex-row h-full",children:[p," ",h]})},"helper"),v=m.jsxs(Jb,{ref:l,id:"terminal",collapsedSize:0,collapsible:!0,className:$t("dark:bg-[var(--slate-1)] no-print print:hidden",n&&"border-[var(--slate-7)]"),minSize:10,defaultSize:0,maxSize:75,onResize:(e,t)=>{var n;0===t&&10===e&&(null==(n=l.current)||n.resize(30))},onCollapse:()=>s(!1),onExpand:()=>s(!0),children:[f,m.jsx(jT,{isOpen:n,children:m.jsx(DT,{visible:n,onClose:()=>s(!1)})})]},"terminal");return m.jsxs("div",{className:"flex flex-col flex-1 overflow-hidden absolute inset-0 print:relative",children:[m.jsxs(ek,{autoSaveId:"marimo:chrome:v1:l2",direction:"horizontal",storage:{getItem:e=>Sk||(Sk??null),setItem(e,t){Sk=t||null}},children:[m.jsx(Ek,{}),g,m.jsx(Jb,{children:m.jsxs(ek,{autoSaveId:"marimo:chrome:v1:l1",direction:"vertical",children:[c,m.jsx(yk,{capability:"terminal",children:v})]})})]}),m.jsx(Es,{children:m.jsx(bk,{})})]})},PT=e=>m.jsxs(_T,{children:[m.jsx(Sb,{...e}),m.jsx(dd,{})]});export{PT as default};
|
|
14
|
+
*/const Fc=r.createContext({});function Lc(e,t){[e,t]=l(e,t,Fc);let{toolbarProps:n}=function(e,t){const{"aria-label":n,"aria-labelledby":o,orientation:l="horizontal"}=e;let[c,d]=r.useState(!1);a((()=>{var e;d(!(!t.current||!(null===(e=t.current.parentElement)||void 0===e?void 0:e.closest('[role="toolbar"]'))))}));const{direction:u}=s(),h="rtl"===u&&"horizontal"===l;let f=i(t);const m=r.useRef(null);return{toolbarProps:{role:c?"group":"toolbar","aria-orientation":l,"aria-label":n,"aria-labelledby":null==n?o:void 0,onKeyDownCapture:c?void 0:e=>{if(e.currentTarget.contains(e.target)){if("horizontal"===l&&"ArrowRight"===e.key||"vertical"===l&&"ArrowDown"===e.key)h?f.focusPrevious():f.focusNext();else{if(!("horizontal"===l&&"ArrowLeft"===e.key||"vertical"===l&&"ArrowUp"===e.key))return"Tab"===e.key?(e.stopPropagation(),m.current=document.activeElement,void(e.shiftKey?f.focusFirst():f.focusLast())):void 0;h?f.focusNext():f.focusPrevious()}e.stopPropagation(),e.preventDefault()}},onFocusCapture:c?void 0:e=>{var n,o;m.current&&!e.currentTarget.contains(e.relatedTarget)&&(null===(n=t.current)||void 0===n?void 0:n.contains(e.target))&&(null===(o=m.current)||void 0===o||o.focus(),m.current=null)},onBlurCapture:c?void 0:e=>{e.currentTarget.contains(e.relatedTarget)||m.current||(m.current=e.target)}}}}(e,t),o=c({...e,values:{orientation:e.orientation||"horizontal"},defaultClassName:"react-aria-Toolbar"}),f=d(e);return delete f.id,u.createElement("div",{...h(n,f),...o,ref:t,slot:e.slot||void 0,"data-orientation":e.orientation||"horizontal"},o.children)}const zc=r.forwardRef(Lc),Bc=e=>m.jsx(g,{className:"w-fit",children:m.jsxs("form",{onSubmit:t=>{t.preventDefault(),w(new Blob([e.getCellsAsJSON()],{type:"text/plain"}),`${e.proposedName}.json`),e.closeModal()},onKeyDown:t=>{"Escape"===t.key&&e.closeModal()},children:[m.jsx(v,{className:"text-accent mb-6",children:"Download unsaved changes?"}),m.jsxs(x,{className:"markdown break-words",style:{wordBreak:"break-word"},children:[m.jsx("p",{children:"This app has unsaved changes. To recover:"}),m.jsxs("ol",{children:[m.jsxs("li",{style:{paddingBottom:"10px"},children:['Click the "Download" button. This will download a file called ',m.jsxs("code",{children:[e.proposedName,".json"]}),". This file contains your code."]}),m.jsxs("li",{style:{paddingBottom:"10px"},children:["In your terminal, type",m.jsxs("code",{style:{display:"block",padding:"10px"},children:["marimo recover ",e.proposedName,".json ",">"," ",e.proposedName,".py"]}),"to overwrite ",m.jsxs("code",{children:[e.proposedName,".py"]})," with the recovered changes."]})]})]}),m.jsxs(y,{children:[m.jsx(b,{"aria-label":"Cancel",variant:"secondary","data-testid":"cancel-recovery-button",onClick:e.closeModal,children:"Cancel"}),m.jsx(b,{"data-testid":"download-recovery-button","aria-label":"Download",variant:"default",type:"submit",children:"Download"})]})]})}),Uc=e=>{const{filename:t,needsSave:n,getCellsAsJSON:o}=e,{openModal:r,closeModal:a}=f(),s=null===t?"app":t.slice(0,-3),i=()=>{n&&r(m.jsx(Bc,{getCellsAsJSON:o,proposedName:s,closeModal:a}))};return Os("global.save",i),m.jsx(p,{content:Ds("global.save"),children:m.jsx(_s,{onClick:i,id:"save-button","aria-label":"Save",className:"rectangle",color:n?"yellow":"gray",children:m.jsx(gc,{strokeWidth:1.5,size:18})})})},Vc=()=>{const{selectedLayout:e}=mi(),{setLayoutView:t}=pi();return C()&&!Rs("wasm_layouts")?null:m.jsxs(j,{"data-testid":"layout-select",value:e,onValueChange:e=>t(e),children:[m.jsx(S,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:m.jsx(I,{placeholder:"Select a view"})}),m.jsx(A,{children:m.jsxs(M,{children:[m.jsx(T,{children:"View as"}),gi.map((e=>m.jsx(O,{value:e,children:m.jsxs("div",{className:"flex items-center gap-1.5 leading-5",children:[$c(e),m.jsx("span",{children:Hc(e)})]})},e)))]})})]})};function $c(e){const t=Gc(e);return m.jsx(t,{className:"h-4 w-4"})}function Gc(e){switch(e){case"vertical":return Ql;case"grid":return Ps;case"slides":return hc;default:return k(e),N}}function Hc(e){return E(e)}function Wc(){const[e,t]=function(e,t){const n=new D(e,t),[o,a]=r.useState((()=>n.get()));return[o,e=>{a(e),n.set(e)}]}("marimo:commands",[]);return{recentCommands:e,addRecentCommand:n=>{const o=(r=[n,...e],[...new Set(r)]);var r;t(o.slice(0,3))}}}function qc(e){return void 0!==e.dropdown}function Yc(e,t=""){return e.flatMap((e=>e.label?qc(e)?Yc(e.dropdown,`${t+e.label} > `):{...e,label:t+e.label}:[]))}const Jc=({children:e,layerTop:t=!1})=>{const[n,o]=u.Children.toArray(e),r=t?"top-[-1px] left-[-1px]":"bottom-[-1px] right-[-1px]";return m.jsxs("div",{className:"multi-icon relative w-fit",children:[n,m.jsx("div",{className:`second-icon absolute ${r} rounded-full`,children:o})]})};function Kc(){const e=P(),{prepareForRun:t}=L();return R((async n=>{if(0===n.length)return;const{cellHandles:o,cellData:r}=e,a=[];for(const e of n){const n=o[e];n.current?(a.push(z(n.current.editorView)),n.current.registerRun()):(t({cellId:e}),a.push(r[e].code))}await B({cellIds:n,codes:a}).catch((e=>{U.error(e)}))}))}const Xc=V(null),Zc=V(!1),Qc=e=>{$(window,"keydown",(t=>{var n;(t.ctrlKey||t.metaKey)&&"z"===t.key&&(t.preventDefault(),t.stopPropagation(),null==(n=e.onClick)||n.call(e,t))}),{capture:!0});const t=e.children??"Undo";return m.jsxs(b,{"data-testid":"undo-button",size:"sm",variant:"outline",...e,children:[t," ",m.jsx(Fs,{className:"ml-2",shortcut:"cmd-z"})]})};function ed(){const{deleteCell:e,undoDeleteCell:t}=L();return R((n=>{if(G.get(H))return;const{cellId:o}=n;e({cellId:o}),W({cellId:o}).catch((()=>{t()}));const{dismiss:r}=q({title:"Cell deleted",description:"You can bring it back by clicking undo or through the command palette.",action:m.jsx(Qc,{"data-testid":"undo-delete-button",onClick:()=>{t(),r()}})})}))}function td(e,t,n,o=G){if(t in o.get(Y))return!1;const{cellData:r,cellIds:a}=o.get(J),s=new RegExp(`import[ \t]+${e}[ \t]+as[ \t]+${t}`,"g");for(const i of a.inOrderIds)if(s.test(r[i].code))return!1;return n(`import ${e} as ${t}`),!0}function nd(e,t,n){return td("marimo","mo",(o=>{const r=K.create();t({cellId:n??"__end__",before:!1,code:o,lastCodeRun:e?o:void 0,newCellId:r,autoFocus:!1}),e&&B({cellIds:[r],codes:[o]})}))}function od({cell:e}){const{createNewCell:t,updateCellConfig:n,updateCellCode:o,updateCellName:r,moveCell:a,sendToTop:s,sendToBottom:i,addColumnBreakpoint:l}=L(),c=function(e){const t=Kc();return R((()=>{void 0!==e&&t([e])}))}(null==e?void 0:e.cellId),d=!X(H),u=ed(),{openModal:h}=f(),p=Z(Xc),x=X(Q),y=X(ee),b=te(),w=X(ne),k=X(oe);if(!e||w)return[];const{cellId:N,config:E,getEditorView:C,name:j,hasOutput:S,status:I}=e,A=b.inOrderIds.indexOf(N),M=C(),T=async()=>{const e={disabled:!E.disabled};await ye({configs:{[N]:e}}),n({cellId:N,config:e})};return[[{icon:m.jsx(Ac,{size:13,strokeWidth:1.5}),label:"Name",disableClick:!0,handle:e=>{null==e||e.stopPropagation(),null==e||e.preventDefault()},handleHeadless:()=>{h(m.jsxs(g,{children:[m.jsx(re,{children:m.jsx(v,{children:"Rename cell"})}),m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx(ae,{htmlFor:"cell-name",children:"Cell name"}),m.jsx(vi,{placeholder:`cell_${A}`,value:j,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),h(null))},onChange:e=>r({cellId:N,name:e})})]})]}))},rightElement:m.jsx(vi,{placeholder:`cell_${A}`,value:j,onChange:e=>r({cellId:N,name:e})})},{icon:m.jsx(uc,{size:13,strokeWidth:1.5}),label:"Run cell",hotkey:"cell.run",hidden:"running"===I||"queued"===I||"disabled-transitively"===I||E.disabled,handle:()=>c()},{icon:m.jsx(bc,{size:13,strokeWidth:1.5}),label:"AI completion",hidden:!x,handle:()=>{p((e=>(null==e?void 0:e.cellId)===N?null:{cellId:N}))},hotkey:"cell.aiCompletion"},{icon:m.jsx(xi,{size:13,strokeWidth:1.5}),label:"Export output as PNG",hidden:!S,handle:()=>function(e){const t=document.getElementById(`output-${e}`);t&&(t.classList.add("printing-output"),_(t,"result.png").finally((()=>{t.classList.remove("printing-output")})))}(N)},{icon:m.jsx(se,{size:13,strokeWidth:1.5}),label:"Format cell",hotkey:"cell.format",handle:()=>{M&&ie({[N]:M},o)}},{icon:m.jsx(Ls,{}),label:"View as Markdown",hotkey:"cell.viewAsMarkdown",hidden:"python"!==le(M),handle:()=>{M&&(nd(y,t),ce(M,"markdown",{force:!0}))}},{icon:m.jsx(de,{size:13,strokeWidth:1.5}),label:"View as SQL",hidden:!ue(M,"sql"),handle:()=>{M&&ce(M,"sql")}},{icon:m.jsx(zs,{}),label:"View as Python",hotkey:"markdown"===le(M)?"cell.viewAsMarkdown":void 0,hidden:!ue(M,"python"),handle:()=>{M&&(nd(y,t),ce(M,"python"))}},{icon:E.hide_code?m.jsx(he,{size:13,strokeWidth:1.5}):m.jsx(fe,{size:13,strokeWidth:1.5}),label:E.hide_code?"Show code":"Hide code",handle:async()=>{const e={hide_code:!E.hide_code};await ye({configs:{[N]:e}}),n({cellId:N,config:e}),M&&(e.hide_code?M.contentDOM.blur():M.focus())},hotkey:"cell.hideCode"},{icon:E.disabled?m.jsx(Pc,{size:13,strokeWidth:1.5}):m.jsx(Rc,{size:13,strokeWidth:1.5}),label:"Reactive execution",rightElement:m.jsx(me,{"data-testid":"cell-disable-switch",checked:!E.disabled,size:"sm",onCheckedChange:T}),handle:T}],[{icon:m.jsxs(Jc,{children:[m.jsx(Dl,{size:13,strokeWidth:1.5}),m.jsx(pe,{size:8,strokeWidth:2})]}),label:"Create cell above",hotkey:"cell.createAbove",handle:()=>t({cellId:N,before:!0})},{icon:m.jsxs(Jc,{children:[m.jsx(Dl,{size:13,strokeWidth:1.5}),m.jsx(ge,{size:8,strokeWidth:2})]}),label:"Create cell below",hotkey:"cell.createBelow",handle:()=>t({cellId:N,before:!1})},{icon:m.jsx(pe,{size:13,strokeWidth:1.5}),label:"Move cell up",hotkey:"cell.moveUp",handle:()=>a({cellId:N,before:!0})},{icon:m.jsx(ge,{size:13,strokeWidth:1.5}),label:"Move cell down",hotkey:"cell.moveDown",handle:()=>a({cellId:N,before:!1})},{icon:m.jsx(Tl,{size:13,strokeWidth:1.5}),label:"Send to top",hotkey:"cell.sendToTop",handle:()=>s({cellId:N})},{icon:m.jsx(Ml,{size:13,strokeWidth:1.5}),label:"Send to bottom",hotkey:"cell.sendToBottom",handle:()=>i({cellId:N})},{icon:m.jsx(ve,{size:13,strokeWidth:1.5}),label:"Break into new column",hotkey:"cell.addColumnBreakpoint",hidden:"columns"!==k,handle:()=>l({cellId:N})}],[{label:"Delete",hidden:!d,variant:"danger",icon:m.jsx(xe,{size:13,strokeWidth:1.5}),handle:()=>{u({cellId:N})}}]].map((e=>e.filter((e=>!e.hidden)))).filter((e=>e.length>0))}const rd=V(null);function ad(){return X(rd)}const sd=V((e=>{const t=e(rd);return t?t===be?null:id(t,e(J)):null}));function id(e,t){var n;const{cellData:o,cellHandles:r,cellRuntime:a}=t,s=o[e],i=a[e],l=null==(n=r[e])?void 0:n.current;if(!s||!l)return null;return{cellId:e,name:s.name,config:s.config,status:i?i.status:"idle",getEditorView:()=>l.editorView,hasOutput:null!=(null==i?void 0:i.output)}}function ld(){const{theme:e}=we(),[t,n]=ke(),[o,r]=Ne(),a=async e=>{await Ee({config:e}).then((()=>{n(e)}))};return[...Bs().filter((e=>e!==o.width)).map((e=>({label:`App config > Set width=${e}`,handle:()=>{(async e=>{await Ce({config:e}).then((()=>{r(e)}))})({...o,width:e})}}))),{label:"Config > Toggle dark mode",handle:()=>{a({...t,display:{...t.display,theme:"dark"===e?"light":"dark"}})}},{label:"Config > Switch keymap to VIM",hidden:"vim"===t.keymap.preset,handle:()=>{a({...t,keymap:{...t.keymap,preset:"vim"}})}},{label:"Config > Switch keymap to default (current: VIM)",hidden:"default"===t.keymap.preset,handle:()=>{a({...t,keymap:{...t.keymap,preset:"default"}})}},{label:"Config > Disable GitHub Copilot",handle:()=>{a({...t,completion:{...t.completion,copilot:!1}})},hidden:"github"!==t.completion.copilot},{label:"Config > Enable GitHub Copilot",handle:()=>{a({...t,completion:{...t.completion,copilot:"github"}})},hidden:"github"===t.completion.copilot}].filter((e=>!e.hidden))}const cd=V(!1),dd=()=>{const[e,t]=je(cd),n=Us(),o=X(sd),r=X(Se);let a=od({cell:o}).flat();a=Yc(a);const s=ld();let i=Cd();i=[...Yc(i),...Yc(s)];const l=i.filter((e=>!e.hotkey)),c=Ie.keyBy(l,(e=>e.label)),{recentCommands:d,addRecentCommand:u}=Wc(),h=new Set(d);$(document,"keydown",(e=>{Ae(r.getHotkey("global.commandPalette").key)(e)&&(e.preventDefault(),t((e=>!e)))}));const f=(e,o)=>{const a=n[e];if(!a)return null;const s=r.getHotkey(e);return m.jsxs(Fe,{disabled:o.disabled,onSelect:()=>{u(e),t(!1),requestAnimationFrame((()=>{a()}))},value:s.name,children:[m.jsxs("span",{children:[s.name,o.tooltip&&m.jsx("span",{className:"ml-2",children:o.tooltip})]}),m.jsx(Le,{children:m.jsx(Vs,{shortcut:s.key})})]},e)},p=(e,n,o={},r)=>m.jsxs(Fe,{disabled:o.disabled,onSelect:()=>{u(e),t(!1),requestAnimationFrame((()=>{n()}))},value:e,children:[m.jsxs("span",{children:[e,o.tooltip&&m.jsxs("span",{className:"ml-2",children:["(",o.tooltip,")"]})]}),r]},e);return m.jsxs(Me,{open:e,onOpenChange:t,children:[m.jsx(Te,{placeholder:"Type to search..."}),m.jsxs(Oe,{children:[m.jsx(De,{children:"No results found."}),d.length>0&&m.jsxs(m.Fragment,{children:[m.jsx(_e,{heading:"Recently Used",children:d.map((e=>{const t=c[e];return Pe(e)?f(e,{disabled:null==t?void 0:t.disabled,tooltip:null==t?void 0:t.tooltip}):t&&!qc(t)?p(t.label,t.handleHeadless||t.handle,{disabled:t.disabled,tooltip:t.tooltip}):null}))}),m.jsx(Re,{})]}),m.jsxs(_e,{heading:"Commands",children:[r.iterate().map((e=>{if(h.has(e))return null;const t=c[e];return f(e,{disabled:null==t?void 0:t.disabled,tooltip:null==t?void 0:t.tooltip})})),l.map((e=>h.has(e.label)?null:p(e.label,e.handleHeadless||e.handle,{disabled:e.disabled,tooltip:e.tooltip}))),a.map((e=>h.has(e.label)?null:p(`Cell > ${e.label}`,e.handleHeadless||e.handle,{disabled:e.disabled,tooltip:e.tooltip})))]})]})]})},ud="https://static.marimo.app",hd=({onClose:e})=>{const[t,n]=r.useState(""),o=`${t}-${r.useRef(Math.random().toString(36).slice(2,6)).current}`,a=`${ud}/static/${o}`;return m.jsx(g,{className:"w-fit",children:m.jsxs("form",{onSubmit:async t=>{t.preventDefault(),e();const n=await ze({download:!1,includeCode:!0,files:yi.INSTANCE.filenames()}),r=q({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${ud}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:n,path:o})}).catch((()=>{r.dismiss(),q({title:"Error uploading static page",description:m.jsxs("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",m.jsx("a",{href:Be.issuesPage,target:"_blank",rel:"noreferrer",className:"underline",children:"GitHub"}),"."]})})})),r.dismiss(),q({title:"Static page uploaded!",description:m.jsxs("div",{children:["The URL has been copied to your clipboard.",m.jsx("br",{}),"You can share it with anyone."]})})},children:[m.jsxs(re,{children:[m.jsx(v,{children:"Share static notebook"}),m.jsxs(x,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",m.jsx("a",{href:ud,target:"_blank",rel:"noreferrer",children:ud}),"."]})]}),m.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[m.jsx(Ue,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:t,placeholder:"Notebook slug",onChange:e=>{const t=e.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,"");n(t)},required:!0,autoComplete:"off"}),m.jsxs("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(fd,{text:a}),m.jsx("span",{className:"text-primary",children:a})]})]})]}),m.jsxs(y,{children:[m.jsx(b,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:e,children:"Cancel"}),m.jsx(b,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:()=>{navigator.clipboard.writeText(a)},children:"Create"})]})]})})},fd=e=>{const[t,n]=u.useState(!1),o=$e.stopPropagation((t=>{t.preventDefault(),navigator.clipboard.writeText(e.text),n(!0),setTimeout((()=>n(!1)),2e3)}));return m.jsx(p,{content:"Copied!",open:t,children:m.jsx(b,{"data-testid":"copy-static-notebook-url-button",onClick:o,size:"xs",variant:"secondary",children:m.jsx(Ve,{size:14,strokeWidth:1.5})})})};function md(){const{openConfirm:e}=f(),t=Z(bi);return()=>{e({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:m.jsx(Ge,{onClick:async()=>{t({state:wi.CLOSING}),await He(),window.location.reload()},"aria-label":"Confirm Restart",children:"Restart"})})}}const pd=new We("marimo:sidebar",qe.object({selectedPanel:qe.string().optional().transform((e=>e)),isSidebarOpen:qe.boolean(),isTerminalOpen:qe.boolean()}),(function(){return{selectedPanel:"variables",isSidebarOpen:!1,isTerminalOpen:!1}}));const{reducer:gd,createActions:vd,valueAtom:xd,useActions:yd}=Ye((()=>pd.get()),{openApplication:(e,t)=>({...e,selectedPanel:t,isSidebarOpen:!e.isSidebarOpen||e.selectedPanel!==t}),toggleSidebarPanel:e=>({...e,isSidebarOpen:!e.isSidebarOpen}),setIsSidebarOpen:(e,t)=>({...e,isSidebarOpen:t}),toggleTerminal:e=>({...e,isTerminalOpen:!e.isTerminalOpen}),setIsTerminalOpen:(e,t)=>({...e,isTerminalOpen:t})},[(e,t)=>pd.set(t)]),bd=()=>{const e=X(xd);return e.isSidebarOpen?e:{...e,selectedPanel:void 0}};function wd(){return yd()}const kd=[{type:"files",Icon:Wl,tooltip:"View files",position:"sidebar"},{type:"variables",Icon:Je,tooltip:"Explore variables",position:"sidebar"},{type:"datasources",Icon:de,tooltip:"Explore data sources",position:"sidebar"},{type:"dependencies",Icon:oc,tooltip:"Explore dependencies",position:"sidebar"},{type:"packages",Icon:Al,tooltip:"Manage packages",position:"sidebar"},{type:"outline",Icon:xc,tooltip:"View outline",position:"sidebar"},{type:"documentation",Icon:Mc,tooltip:"View live docs",position:"sidebar"},{type:"logs",Icon:Ke,tooltip:"Notebook logs",position:"sidebar"},{type:"snippets",Icon:kc,tooltip:"Snippets",position:"sidebar"},{type:"scratchpad",Icon:rc,hidden:!Rs("scratchpad"),tooltip:"Scratchpad",position:"sidebar"},{type:"errors",Icon:Xe,tooltip:"View errors",position:"footer"}];function Nd(){const e=Z(Ze);return r.useCallback((()=>{const t=document.getElementsByClassName("output-area"),n=window.innerHeight||document.documentElement.clientHeight;let o=null;for(const e of Array.from(t)){const t=e.getBoundingClientRect();if(t.top>=0&&t.top<=n||t.bottom>=0&&t.bottom<=n){o=Qe.parse(e.parentNode.id);break}}e((e=>({mode:et(e.mode),cellAnchor:o}))),requestAnimationFrame((()=>{var e;null!==o&&(null==(e=document.getElementById(Qe.create(o)))||e.scrollIntoView())}))}),[e])}const Ed=e=>{null==e||e.preventDefault(),null==e||e.stopPropagation()};function Cd(){const[e]=rt(),{openModal:t,closeModal:n}=f(),{openApplication:o}=wd(),{selectedPanel:r}=bd(),[a]=je(Ze),s=X(ne),i=P(),{updateCellConfig:l,undoDeleteCell:c}=L(),d=md(),u=function(e){const{openPrompt:t,closeModal:n}=f();return()=>{if(!e)return null;const o=tt.guessDeliminator(e),r=nt.basename(e);t({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${r}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:t=>{const r=o.join(nt.dirname(e),t);ot({source:e,destination:r}).then((()=>{n(),q({title:"Notebook copied",description:"A copy of the notebook has been created."}),window.open(`/?file=${r}`,"_blank")}))}})}}(e),h=Z(cd),p=Z($s),g=Z(Gs),v=at(i),x=st(i),{selectedLayout:y}=mi(),{setLayoutView:b}=pi(),k=Nd();return[{icon:m.jsx(yc,{size:14,strokeWidth:1.5}),label:"Share",handle:Ed,dropdown:[{icon:m.jsx(it,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",handle:async()=>{t(m.jsx(hd,{onClose:n}))}},{icon:m.jsx(Zl,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",handle:async()=>{const e=await lt(),t=ct({code:e.contents});window.navigator.clipboard.writeText(t),q({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:m.jsx(dt,{size:14,strokeWidth:1.5}),label:"Download",handle:Ed,dropdown:[{icon:m.jsx(ki,{size:14,strokeWidth:1.5}),label:"Download as HTML",handle:async()=>{e?await Ni({filename:e,includeCode:!0}):q({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},{icon:m.jsx(ki,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{e?await Ni({filename:e,includeCode:!1}):q({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},{icon:m.jsx(Ls,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{const e=await ut({download:!1});w(new Blob([e],{type:"text/plain"}),ht.toMarkdown(document.title))}},{icon:m.jsx(Fl,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{const e=await lt();w(new Blob([e.contents],{type:"text/plain"}),ht.toPY(document.title))}},{divider:!0,icon:m.jsx(xi,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:"present"!==a.mode,tooltip:"present"===a.mode?void 0:m.jsxs("span",{children:["Only available in app view. ",m.jsx("br",{}),"Toggle with: ",Ds("global.hideCode",!1)]}),handle:async()=>{const e=document.getElementById("App");e&&await _(e,document.title)}},{icon:m.jsx(ft,{size:14,strokeWidth:1.5}),label:"Download as PDF",disabled:"present"!==a.mode,tooltip:"present"===a.mode?void 0:m.jsxs("span",{children:["Only available in app view. ",m.jsx("br",{}),"Toggle with: ",Ds("global.hideCode",!1)]}),handle:async()=>{const e=new Event("export-beforeprint"),t=new Event("export-afterprint");window.dispatchEvent(e),setTimeout((()=>window.print()),0),setTimeout((()=>window.dispatchEvent(t)),0)}}]},{divider:!0,icon:m.jsx(lc,{size:14,strokeWidth:1.5}),label:"Helper panel",handle:Ed,dropdown:kd.flatMap((({type:e,Icon:t,hidden:n})=>{return n?[]:{label:E(e),rightElement:(a=r===e,m.jsx("div",{className:"w-8 flex justify-end",children:a&&m.jsx(pt,{size:14})})),icon:m.jsx(t,{size:14,strokeWidth:1.5}),handle:()=>o(e)};var a}))},{icon:m.jsx(hc,{size:14,strokeWidth:1.5}),label:"Present as",handle:Ed,dropdown:[{icon:"present"===a.mode?m.jsx(mt,{size:14,strokeWidth:1.5}):m.jsx(Xl,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{k()}},...gi.map(((e,t)=>{const n=Gc(e);return{divider:0===t,label:Hc(e),icon:m.jsx(n,{size:14,strokeWidth:1.5}),rightElement:m.jsx("div",{className:"w-8 flex justify-end",children:y===e&&m.jsx(pt,{size:14})}),handle:()=>{b(e),"edit"===a.mode&&k()}}}))]},{icon:m.jsx(Gl,{size:14,strokeWidth:1.5}),label:"Create notebook copy",hidden:!e||C(),handle:u},{icon:m.jsx(_l,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!e,handle:async()=>{const e=await lt();navigator.clipboard.writeText(e.contents),q({title:"Copied",description:"Code copied to clipboard."})}},{icon:m.jsx(Rc,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:0===v.length||s,handle:async()=>{const e=v.map((e=>e.id)),t=Ie.fromEntries(e.map((e=>[e,{disabled:!1}])));await ye({configs:t});for(const n of e)l({cellId:n,config:{disabled:!1}})}},{icon:m.jsx(Pc,{size:14,strokeWidth:1.5}),label:"Disable all cells",hidden:0===x.length||s,handle:async()=>{const e=x.map((e=>e.id)),t=Ie.fromEntries(e.map((e=>[e,{disabled:!0}])));await ye({configs:t});for(const n of e)l({cellId:n,config:{disabled:!0}})}},{icon:m.jsx(Tc,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!gt(i)||s,handle:()=>{c()}},{divider:!0,icon:m.jsx(Ll,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>h((e=>!e))},{icon:m.jsx(vt,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>p((e=>!e))},{icon:m.jsx(Kl,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>g((e=>!e))},{icon:m.jsx(Il,{size:14,strokeWidth:1.5}),label:"Open documentation",handle:()=>{window.open("https://docs.marimo.io","_blank")}},{divider:!0,icon:m.jsx(Jl,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:()=>{window.location.href=document.baseURI}},{icon:m.jsx(Sc,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:d}].filter((e=>!e.hidden))}const jd=()=>{const e=Cd(),t=m.jsx(_s,{"aria-label":"Config",shape:"circle",size:"small",className:"h-[27px] w-[27px]","data-testid":"notebook-menu-dropdown",color:"hint-green",children:m.jsx(Ei,{strokeWidth:1.8})}),n=e=>m.jsxs(m.Fragment,{children:[e.icon&&m.jsx("span",{className:"flex-0 mr-2",children:e.icon}),m.jsx("span",{className:"flex-1",children:e.labelElement||e.label}),e.hotkey&&m.jsx(Hs,{shortcut:e.hotkey,className:"ml-4"}),e.rightElement]}),o=e=>{const t=m.jsx(St,{variant:e.variant,disabled:e.disabled,onSelect:t=>e.handle(t),"data-testid":`notebook-menu-dropdown-${e.label}`,children:n(e)},e.label);return e.tooltip?m.jsx(p,{content:e.tooltip,side:"left",delayDuration:100,children:m.jsx("span",{children:t})},e.label):t};return m.jsxs(xt,{modal:!1,children:[m.jsx(yt,{asChild:!0,children:t}),m.jsxs(bt,{align:"end",className:"no-print w-[240px]",children:[e.map((e=>e.hidden?null:e.dropdown?m.jsxs(wt,{children:[m.jsx(kt,{"data-testid":`notebook-menu-dropdown-${e.label}`,children:n(e)}),m.jsx(Nt,{children:m.jsx(Et,{children:e.dropdown.map((e=>m.jsxs(u.Fragment,{children:[e.divider&&m.jsx(Ct,{}),o(e)]},e.label)))})})]},e.label):m.jsxs(u.Fragment,{children:[e.divider&&m.jsx(Ct,{}),o(e)]},e.label))),m.jsx(Ct,{}),m.jsx("div",{className:"flex-1 px-2 text-xs text-muted-foreground",children:m.jsxs("span",{children:["Version: ",jt()]})})]})]})},Sd=It({findText:"",replaceText:"",caseSensitive:!1,wholeWord:!1,regexp:!1,isOpen:!1,currentView:void 0},((e,t)=>{if(void 0===t)return e;switch(t.type){case"setFind":return{...e,findText:t.find};case"setReplace":return{...e,replaceText:t.replace};case"setCaseSensitive":return{...e,caseSensitive:t.caseSensitive};case"setWholeWord":return{...e,wholeWord:t.wholeWord};case"setRegex":return{...e,regexp:t.regexp};case"setIsOpen":return{...e,isOpen:t.isOpen};case"setCurrentView":return{...e,currentView:{view:t.view,range:t.range}};case"clearCurrentView":return{...e,currentView:void 0}}}));function Id(e){if([...document.querySelectorAll('[role="dialog"][data-state="open"]')].some((e=>e instanceof HTMLElement&&e.childNodes.length>0)))return!1;if(e){const t=e.state.selection.main,n=e.state.sliceDoc(t.from,t.to);n?(G.set(Sd,{type:"setFind",find:n}),G.set(Sd,{type:"setCurrentView",view:e,range:{from:t.from,to:t.to}})):G.set(Sd,{type:"setCurrentView",view:e,range:{from:0,to:0}})}return G.get(Sd).isOpen?(G.set(Sd,{type:"setIsOpen",isOpen:!1}),requestAnimationFrame((()=>{G.set(Sd,{type:"setIsOpen",isOpen:!0})})),!0):(G.set(Sd,{type:"setIsOpen",isOpen:!0}),!0)}function Ad(){return!!G.get(Sd).isOpen&&(G.set(Sd,{type:"setIsOpen",isOpen:!1}),!0)}function Md(e){return At("create"in e,'Expected query to have a "create" method'),e}function Td(e){return()=>{const t=G.get(Sd),n=new Mt({search:t.findText,caseSensitive:t.caseSensitive,regexp:t.regexp,replace:t.replaceText,wholeWord:t.wholeWord});return!!n.valid&&e({query:Md(n).create(),search:n})}}const Od=e=>Td((({query:t})=>{const n=Tt(),o=G.get(Sd).currentView||{view:n[0],range:{from:0,to:0}};let r=o.range.to;"prev"===e&&(n.reverse(),r=o.range.from);let a=n.indexOf(o.view);a<0&&(a=0);const s=[...n,...n].slice(a);for(const i of s){const n="next"===e?t.nextMatch(i.state,0,r??0):t.prevMatch(i.state,r??i.state.doc.length,i.state.doc.length);if(!n){r=null,i.dispatch({selection:Ot.single(0)});continue}const o=Ot.single(n.from,n.to);return i.dispatch({selection:o,effects:[Dt.scrollIntoView(o.main,{y:"center"})],userEvent:"select.search"}),G.set(Sd,{type:"setCurrentView",view:i,range:{from:n.from,to:n.to}}),n}return!1})),Dd=Od("next"),_d=Od("prev"),Pd=Td((({query:e})=>{var t;const n=Tt(),o=[];for(const r of n){if(r.state.readOnly)continue;const n=null==(t=e.matchAll(r.state,1e9))?void 0:t.map((t=>{const{from:n,to:o}=t;return{from:n,to:o,insert:e.getReplacement(t)}}));if(!n||0===n.length)continue;const a=r.state.doc.toString();o.push((()=>{r.dispatch({changes:[{from:0,to:r.state.doc.length,insert:a}],userEvent:"input.replace.all"})})),r.dispatch({changes:n,userEvent:"input.replace.all"})}return()=>{for(const e of o)e()}})),Rd=Td((({query:e})=>{const t=Tt(),n=G.get(Sd).currentView||{view:t[0],range:{from:0,to:0}};let o=n.range.from,r=t.indexOf(n.view);r<0&&(r=0);const a=[...t,...t].slice(r);for(const s of a){const t=e.nextMatch(s.state,0,o??0);if(!t){o=null,s.dispatch({selection:Ot.single(0)});continue}const n=s.state.toText(e.getReplacement(t));return s.dispatch({changes:[{from:t.from,to:t.to,insert:n}],userEvent:"input.replace"}),Dd()}return!1})),Fd=Td((({query:e})=>{const t=Tt();let n=0;const o=new Map;for(const r of t){const t=e.matchAll(r.state,1e9)||[];for(const e of t){const{from:t,to:a}=e,s=o.get(r)||new Map;s.set(`${t}:${a}`,n++),o.set(r,s)}}return{count:n,position:o}})),Ld=_t.define();function zd(){const e=Tt();for(const t of e)t.state.readOnly||t.dispatch({effects:Ld.of(new Mt({search:""}))})}const Bd=Pt.define({create(){const e=G.get(Sd);return Md(new Mt({search:e.findText,caseSensitive:e.caseSensitive,regexp:e.regexp,replace:e.replaceText,wholeWord:e.wholeWord})).create()},update(e,t){for(const n of t.effects)n.is(Ld)&&(e=Md(n.value).create());return e}}),Ud=Rt.mark({class:"cm-searchMatch"}),Vd=Rt.mark({class:"cm-searchMatch cm-searchMatch-selected"}),$d=Ft.fromClass(class{constructor(e){n(this,"decorations"),this.view=e,this.decorations=this.highlight(e.state.field(Bd))}update(e){const t=e.state.field(Bd);(t!==e.startState.field(Bd)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight(e){if(!e.spec.valid)return Rt.none;const{view:t}=this,n=new Lt,o=t.visibleRanges,r=o.length;for(let a=0;a<r;a++){let{to:s}=o[a];const{from:i}=o[a];for(;a<r-1&&s>o[a+1].from-500;)s=o[++a].to;e.highlight(t.state,i,s,((e,o)=>{const r=t.state.selection.ranges.some((t=>t.from===e&&t.to===o));n.add(e,o,r?Vd:Ud)}))}return n.finish()}},{decorations:e=>e.decorations}),Gd=Dt.baseTheme({"&light .cm-searchMatch":{backgroundColor:"#99ff7780"},"&dark .cm-searchMatch":{backgroundColor:"#22bb0070"},"&light .cm-searchMatch-selected":{backgroundColor:"transparent"},"&dark .cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff88 !important"}}),Hd=()=>{var e;const[t,n]=r.useState(!1),[o,a]=je(Sd),[s,i]=r.useState(),l=r.useRef(null),c=X(Se);if(Os("cell.findAndReplace",(()=>(!t||!o.isOpen)&&Id())),r.useEffect((()=>{o.isOpen&&l.current&&(l.current.focus(),l.current.select())}),[o.isOpen]),r.useEffect((()=>{if(!o.isOpen)return void zd();if(""===o.findText)return i(void 0),void zd();const e=Fd();i(!1===e?void 0:e),function(){const e=G.get(Sd),t=Tt();for(const n of t)n.state.readOnly||n.dispatch({effects:Ld.of(new Mt({search:e.findText,caseSensitive:e.caseSensitive,regexp:e.regexp,replace:e.replaceText,wholeWord:e.wholeWord}))})}()}),[o.findText,o.isOpen,o.caseSensitive,o.regexp,o.wholeWord]),!o.isOpen)return null;const d=o.currentView,u=d&&s?null==(e=s.position.get(d.view))?void 0:e.get(`${d.range.from}:${d.range.to}`):void 0;return m.jsx(zt,{restoreFocus:!0,autoFocus:!0,children:m.jsxs("div",{onFocus:()=>n(!0),onClick:e=>{e.stopPropagation(),e.preventDefault()},onBlur:()=>n(!1),className:"fixed top-0 right-0 w-[500px] flex flex-col bg-[var(--sage-1)] p-4 z-50 mt-2 mr-3 rounded-md shadow-lg border gap-2 print:hidden",onKeyDown:e=>{"Escape"===e.key&&a({type:"setIsOpen",isOpen:!1})},children:[m.jsx("div",{className:"absolute top-0 right-0",children:m.jsx(b,{"data-testid":"close-find-replace-button",onClick:()=>a({type:"setIsOpen",isOpen:!1}),size:"xs",variant:"text",children:m.jsx(Bt,{className:"w-4 h-4"})})}),m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsxs("div",{className:"flex flex-col flex-2 gap-2 w-[55%]",children:[m.jsx(Ue,{ref:l,"data-testid":"find-input",value:o.findText,autoFocus:!0,className:"mr-2 mb-0",placeholder:"Find",onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey?_d():Dd())},onChange:e=>{a({type:"setFind",find:e.target.value})}}),m.jsx(Ue,{"data-testid":"replace-input",value:o.replaceText,placeholder:"Replace",onChange:e=>{a({type:"setReplace",replace:e.target.value})}})]}),m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("div",{className:"flex items-center gap-[2px]",children:[m.jsx(p,{content:"Case Sensitive",children:m.jsx(Ut,{size:"sm",pressed:o.caseSensitive,"data-state":o.caseSensitive?"on":"off",onPressedChange:e=>a({type:"setCaseSensitive",caseSensitive:e}),children:m.jsx(Vt,{className:"w-4 h-4"})})}),m.jsx(p,{content:"Match Whole Word",children:m.jsx(Ut,{size:"sm",pressed:o.wholeWord,"data-state":o.wholeWord?"on":"off",onPressedChange:e=>a({type:"setWholeWord",wholeWord:e}),children:m.jsx(Dc,{className:"w-4 h-4"})})}),m.jsx(p,{content:"Use Regular Expression",children:m.jsx(Ut,{size:"sm",pressed:o.regexp,"data-state":o.regexp?"on":"off",onPressedChange:e=>a({type:"setRegex",regexp:e}),children:m.jsx(fc,{className:"w-4 h-4"})})})]}),m.jsxs("div",{className:"flex items-center gap-[2px]",children:[m.jsx(b,{"data-testid":"replace-next-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:()=>Rd(),disabled:""===o.findText||""===o.replaceText,children:"Replace Next"}),m.jsx(b,{"data-testid":"replace-all-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:()=>{const e=Pd();if(!e)return;const{dismiss:t}=q({title:"Replaced all occurrences",action:m.jsx(Qc,{"data-testid":"undo-replace-all-button",onClick:()=>{e(),t()}})})},disabled:""===o.findText||""===o.replaceText,children:"Replace All"})]})]})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(p,{content:"Find Previous",children:m.jsx(b,{"data-testid":"find-prev-button",size:"xs",variant:"secondary",onClick:()=>_d(),children:m.jsx(kl,{className:"w-4 h-4"})})}),m.jsx(p,{content:"Find Next",children:m.jsx(b,{"data-testid":"find-next-button",size:"xs",variant:"secondary",onClick:()=>Dd(),children:m.jsx(Cl,{className:"w-4 h-4"})})}),null!=s&&null==u&&m.jsxs("span",{className:"text-sm",children:[s.count," matches"]}),null!=s&&null!=u&&m.jsxs("span",{className:"text-sm",children:[u+1," of ",s.count]})]}),m.jsxs("div",{className:"text-xs text-muted-foreground flex gap-1 mt-2",children:["Press"," ",m.jsx(Vs,{shortcut:c.getHotkey("cell.findAndReplace").key})," ","again to open the native browser search."]})]})})};function Wd(e){const[t,n]=r.useState(!1);return r.useEffect((()=>{if(!e)return;n(!1);const t=setTimeout((()=>{n(!0)}),200);return()=>clearTimeout(t)}),[e]),e&&t}const qd=()=>{const e=Z(cd);return m.jsx(p,{content:Ds("global.commandPalette"),children:m.jsx(_s,{"data-testid":"command-palette-button",onClick:()=>e((e=>!e)),shape:"rectangle",color:"hint-green",children:m.jsx(Ll,{strokeWidth:1.5,size:18})})})},Yd=({children:e})=>X(ne)?null:e,Jd=({children:e})=>X(ne)?e:null,Kd=({filename:e,needsSave:t,onSaveNotebook:n,getCellsAsJSON:o,presenting:r,onTogglePresenting:a,onInterrupt:s,onRun:i,closed:l,running:c,needsRun:d,undoAvailable:u,appWidth:h})=>{const{undoDeleteCell:f}=L();let g=null;return!l&&u&&(g=m.jsx(p,{content:"Undo cell deletion",children:m.jsx(_s,{"data-testid":"undo-delete-cell",size:"medium",color:"hint-green",shape:"circle",onClick:f,children:m.jsx(Tc,{size:16,strokeWidth:1.5})})})),m.jsxs(m.Fragment,{children:[!r&&m.jsx(Hd,{}),!l&&m.jsxs("div",{className:Qd,children:[r&&m.jsx(Vc,{}),m.jsx(jd,{}),m.jsx(Ws,{}),m.jsx(qs,{description:"This will terminate the Python kernel. You'll lose all data that's in memory."})]}),m.jsxs("div",{className:$t(eu,"compact"===h&&"xl:flex-row items-end"),children:[m.jsx(Yd,{children:l?m.jsx(Uc,{filename:e,getCellsAsJSON:o,needsSave:t}):m.jsx(p,{content:Ds("global.save"),children:m.jsx(_s,{"data-testid":"save-button",id:"save-button",shape:"rectangle",color:t?"yellow":"hint-green",onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},children:m.jsx(gc,{strokeWidth:1.5,size:18})})})}),m.jsx(p,{content:Ds("global.hideCode"),children:m.jsx(_s,{"data-testid":"hide-code-button",id:"preview-button",shape:"rectangle",color:"hint-green",onClick:a,children:r?m.jsx(mt,{strokeWidth:1.5,size:18}):m.jsx(Xl,{strokeWidth:1.5,size:18})})}),m.jsx(qd,{}),m.jsx(Ys,{}),m.jsx("div",{}),m.jsx(Yd,{children:m.jsxs("div",{className:"flex flex-col gap-2 items-center",children:[g,!l&&m.jsx(Zd,{running:c,onInterrupt:s}),!l&&m.jsx(Xd,{needsRun:d,onRun:i})]})})]})]})},Xd=({needsRun:e,onRun:t})=>e?m.jsx(p,{content:Ds("global.runStale"),children:m.jsx(_s,{"data-testid":"run-button",size:"medium",color:"yellow",shape:"circle",onClick:t,children:m.jsx(uc,{strokeWidth:1.5,size:16})})}):m.jsx(p,{content:"Nothing to run",children:m.jsx(_s,{"data-testid":"run-button",className:"inactive-button",color:"disabled",size:"medium",shape:"circle",children:m.jsx(uc,{strokeWidth:1.5,size:16})})}),Zd=({running:e,onInterrupt:t})=>{const n=Wd(e);return m.jsx(p,{content:Ds("global.interrupt"),children:m.jsx(_s,{className:$t(!n&&"inactive-button active:shadow-xsSolid"),"data-testid":"interrupt-button",size:"medium",color:n?"yellow":"disabled",shape:"circle",onClick:n?t:Gt.NOOP,children:m.jsx(N,{strokeWidth:1.5,size:16})})})},Qd="absolute top-3 right-5 m-0 flex items-center space-x-3 min-h-[28px] no-print pointer-events-auto z-30 print:hidden",eu="absolute bottom-5 right-5 flex flex-col gap-2 items-center no-print pointer-events-auto z-30 print:hidden",tu=({resetOnBlur:e=!1,placeholderText:t,initialValue:n=null,flexibleWidth:o=!1,onNameChange:a,className:s})=>{const[i,l]=r.useState(n),[c,d]=r.useState([]),[u,h]=r.useState(!1),f=r.useRef(null),p=r.useRef(!1);r.useEffect((()=>{l(n)}),[n]);const g=nt.dirname(i||""),v=nt.basename(i||""),x=c.filter((e=>nt.basename(e.path).startsWith(v))),{loading:y}=Ht((async()=>{if(!u)return void d([]);const e=await Wt({path:g});d(e.files)}),[g,u]),b=function(e,t,n){if(!e)return;if(e.endsWith("/"))return;(Rs("markdown")?new Set(["py","md","markdown","qmd"]):new Set(["py"])).has(nt.extension(e))||(e=e.endsWith(".")?`${e}py`:e.endsWith(".p")?`${e}y`:`${e}.py`);if(t.some((t=>t.path===e||nt.basename(t.path)===e)))return;if(n&&(n===e||nt.basename(n)===e))return;return e}(i,c,n),w=(b||x.length>0)&&m.jsxs(Oe,{className:"font-mono",children:[!y&&m.jsx(De,{children:"No files"}),b&&m.jsxs(Fe,{variant:"success",className:"py-2 px-3",onSelect:()=>{var e;b&&(p.current=!0,a(b),null==(e=f.current)||e.blur())},children:[m.jsx(Vl,{className:"w-4 h-4 mr-2"})," ",m.jsxs("span",{className:"text-sm",children:[n?"Rename to: ":"Save as: ",m.jsx("span",{className:"font-medium text-sm",children:nt.basename(b)})]})]},"_rename_"),x.map((e=>{const t=e.isDirectory?"directory":qt(e.path),n=Zt[t];return m.jsxs(Fe,{variant:e.isDirectory?"default":"muted",className:"py-2 px-3",onSelect:()=>{e.isDirectory?l(`${e.path}/`):l(e.path)},children:[m.jsx(n,{className:"w-4 h-4 mr-2"})," ",nt.basename(e.path)]},e.path)}))]}),k=10*Math.max(20,(null==i?void 0:i.length)||(null==t?void 0:t.length)||0);return m.jsx(Yt,{open:!0,modal:!1,children:m.jsx(Jt,{onFocus:()=>{h(!0)},onBlur:t=>{var o;(null==(o=t.relatedTarget)?void 0:o.closest(".filename-input"))||(h(!1),e&&l(n))},shouldFilter:!1,className:"bg-transparent group filename-input",children:m.jsxs(Oe,{children:[m.jsx(Kt,{children:m.jsx(Te,{"data-testid":"dir-completion-input",tabIndex:-1,rootClassName:"border-none justify-center px-1",spellCheck:"false",value:u?i||"":n||"",onKeyDown:e=>{"Escape"===e.key&&e.currentTarget.blur()},icon:null,ref:f,onValueChange:l,placeholder:t,autoComplete:"off",style:o?{maxWidth:k}:void 0,className:$t(s,"w-full px-4 py-1 my-1 h-9 font-mono text-foreground/60")})}),m.jsx(Xt,{side:"bottom",className:$t("p-0 w-full min-w-80 max-w-80vw hidden",w&&"group-focus-within:block"),portal:!1,children:w})]})})})};const nu=({filename:e,setFilename:t})=>m.jsx(tu,{placeholderText:e?nt.basename(e):"untitled marimo app",initialValue:e,onNameChange:t,flexibleWidth:!0,resetOnBlur:!0,"data-testid":"filename-input",className:null===e?"missing-filename":"filename"});function ou(e){return[Qt.of([{key:"Escape",preventDefault:!1,run:Ad},{key:e.getHotkey("cell.selectNextOccurrence").key,preventDefault:!0,run:en},{key:e.getHotkey("cell.findAndReplace").key,preventDefault:!0,run:Id}]),tn(),$d,Bd,Gd]}var ru=Object.defineProperty,au=(e,t,n)=>(((e,t,n)=>{t in e?ru(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!=typeof t?t+"":t,n),n);const su=Pt.define({create:()=>({suggestion:null}),update(e,t){const n=t.effects.find((e=>e.is(iu)));return t.state.doc&&n&&t.state.doc==n.value.doc?{suggestion:n.value.text}:{suggestion:null}}}),iu=_t.define();class lu extends on{constructor(e){super(),au(this,"suggestion"),this.suggestion=e}toDOM(){const e=document.createElement("span");return e.style.opacity="0.4",e.className="cm-inline-suggestion",e.textContent=this.suggestion,e}get lineBreaks(){return this.suggestion.split("\n").length-1}}const cu=e=>Ft.fromClass(class{async update(t){const n=t.state.doc;if(!t.docChanged)return;const o=await e(t.state);t.view.dispatch({effects:iu.of({text:o,doc:n})})}}),du=Ft.fromClass(class{constructor(){au(this,"decorations"),this.decorations=Rt.none}update(e){var t;const n=null==(t=e.state.field(su))?void 0:t.suggestion;this.decorations=n?function(e,t){const n=e.state.selection.main.head,o=[],r=Rt.widget({widget:new lu(t),side:1});return o.push(r.range(n)),Rt.set(o)}(e.view,n):Rt.none}},{decorations:e=>e.decorations}),uu=nn.highest(Qt.of([{key:"Tab",run:e=>{var t;const n=null==(t=e.state.field(su))?void 0:t.suggestion;return!!n&&(e.dispatch({...hu(e.state,n,e.state.selection.main.head,e.state.selection.main.head)}),!0)}}]));function hu(e,t,n,o){return{...e.changeByRange((r=>{if(r==e.selection.main)return{changes:{from:n,to:o,insert:t},range:Ot.cursor(n+t.length)};const a=o-n;return!r.empty||a&&e.sliceDoc(r.from-a,r.from)!=e.sliceDoc(n,o)?{range:r}:{changes:{from:r.from-a,to:r.from,insert:t},range:Ot.cursor(r.from-a+t.length)}})),userEvent:"input.complete"}}function fu(e){const{delay:t=500}=e,n=function(e,t,n){let o=()=>{};return(...r)=>(o(),new Promise(((a,s)=>{const i=setTimeout((()=>a(e(...r))),t);o=()=>{clearTimeout(i),void 0!==n&&s(n)}})))}(e.fetchFn,t);return[su,cu(n),du,uu]}const mu=_t.define(),pu=_t.define(),gu=_t.define();function vu(e,t){if(!e)throw new Error(t)}function xu(e){if("number"!=typeof e)throw new Error("invalid int 32: "+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw new Error("invalid int 32: "+e)}function yu(e){if("number"!=typeof e)throw new Error("invalid uint 32: "+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw new Error("invalid uint 32: "+e)}function bu(e){if("number"!=typeof e)throw new Error("invalid float 32: "+typeof e);if(Number.isFinite(e)&&(e>34028234663852886e22||e<-34028234663852886e22))throw new Error("invalid float 32: "+e)}const wu=Symbol("@bufbuild/protobuf/enum-type");function ku(e){const t=e[wu];return vu(t,"missing enum type on enum object"),t}function Nu(e,t,n,o){e[wu]=Eu(t,n.map((t=>({no:t.no,name:t.name,localName:e[t.no]}))))}function Eu(e,t,n){const o=Object.create(null),r=Object.create(null),a=[];for(const s of t){const e=ju(s);a.push(e),o[s.name]=e,r[s.no]=e}return{typeName:e,values:a,findName:e=>o[e],findNumber:e=>r[e]}}function Cu(e,t,n){const o={};for(const r of t){const e=ju(r);o[e.localName]=e.no,o[e.no]=e.localName}return Nu(o,e,t),o}function ju(e){return"localName"in e?e:Object.assign(Object.assign({},e),{localName:e.name})}class Su{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const n=this.getType().runtime.bin,o=n.makeReadOptions(t);return n.readMessage(this,o.readerFactory(e),e.byteLength,o),this}fromJson(e,t){const n=this.getType(),o=n.runtime.json,r=o.makeReadOptions(t);return o.readMessage(n,e,r,this),this}fromJsonString(e,t){let n;try{n=JSON.parse(e)}catch(o){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${o instanceof Error?o.message:String(o)}`)}return this.fromJson(n,t)}toBinary(e){const t=this.getType().runtime.bin,n=t.makeWriteOptions(e),o=n.writerFactory();return t.writeMessage(this,o,n),o.finish()}toJson(e){const t=this.getType().runtime.json,n=t.makeWriteOptions(e);return t.writeMessage(this,n)}toJsonString(e){var t;const n=this.toJson(e);return JSON.stringify(n,null,null!==(t=null==e?void 0:e.prettySpaces)&&void 0!==t?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function Iu(){let e=0,t=0;for(let o=0;o<28;o+=7){let n=this.buf[this.pos++];if(e|=(127&n)<<o,!(128&n))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(15&n)<<28,t=(112&n)>>4,!(128&n))return this.assertBounds(),[e,t];for(let o=3;o<=31;o+=7){let n=this.buf[this.pos++];if(t|=(127&n)<<o,!(128&n))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function Au(e,t,n){for(let a=0;a<28;a+=7){const o=e>>>a,r=!(o>>>7==0&&0==t),s=255&(r?128|o:o);if(n.push(s),!r)return}const o=e>>>28&15|(7&t)<<4,r=!!(t>>3);if(n.push(255&(r?128|o:o)),r){for(let e=3;e<31;e+=7){const o=t>>>e,r=!(o>>>7==0),a=255&(r?128|o:o);if(n.push(a),!r)return}n.push(t>>>31&1)}}const Mu=4294967296;function Tu(e){const t="-"===e[0];t&&(e=e.slice(1));const n=1e6;let o=0,r=0;function a(t,a){const s=Number(e.slice(t,a));r*=n,o=o*n+s,o>=Mu&&(r+=o/Mu|0,o%=Mu)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?_u(o,r):Du(o,r)}function Ou(e,t){if(({lo:e,hi:t}=function(e,t){return{lo:e>>>0,hi:t>>>0}}(e,t)),t<=2097151)return String(Mu*t+e);const n=16777215&(e>>>24|t<<8),o=t>>16&65535;let r=(16777215&e)+6777216*n+6710656*o,a=n+8147497*o,s=2*o;const i=1e7;return r>=i&&(a+=Math.floor(r/i),r%=i),a>=i&&(s+=Math.floor(a/i),a%=i),s.toString()+Pu(a)+Pu(r)}function Du(e,t){return{lo:0|e,hi:0|t}}function _u(e,t){return t=~t,e?e=1+~e:t+=1,Du(e,t)}const Pu=e=>{const t=String(e);return"0000000".slice(t.length)+t};function Ru(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(127&e|128),e>>=7;t.push(1)}}function Fu(){let e=this.buf[this.pos++],t=127&e;if(!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,!(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let n=5;128&e&&n<10;n++)e=this.buf[this.pos++];if(128&e)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var Lu={};const zu=function(){const e=new DataView(new ArrayBuffer(8));if("function"==typeof BigInt&&"function"==typeof e.getBigInt64&&"function"==typeof e.getBigUint64&&"function"==typeof e.setBigInt64&&"function"==typeof e.setBigUint64&&("object"!=typeof process||"1"!==Lu.BUF_BIGINT_DISABLE)){const t=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),o=BigInt("0"),r=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(e){const o="bigint"==typeof e?e:BigInt(e);if(o>n||o<t)throw new Error(`int64 invalid: ${e}`);return o},uParse(e){const t="bigint"==typeof e?e:BigInt(e);if(t>r||t<o)throw new Error(`uint64 invalid: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)),uDec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0))}}const t=e=>vu(/^-?[0-9]+$/.test(e),`int64 invalid: ${e}`),n=e=>vu(/^[0-9]+$/.test(e),`uint64 invalid: ${e}`);return{zero:"0",supported:!1,parse:e=>("string"!=typeof e&&(e=e.toString()),t(e),e),uParse:e=>("string"!=typeof e&&(e=e.toString()),n(e),e),enc:e=>("string"!=typeof e&&(e=e.toString()),t(e),Tu(e)),uEnc:e=>("string"!=typeof e&&(e=e.toString()),n(e),Tu(e)),dec:(e,t)=>function(e,t){let n=Du(e,t);const o=2147483648&n.hi;o&&(n=_u(n.lo,n.hi));const r=Ou(n.lo,n.hi);return o?"-"+r:r}(e,t),uDec:(e,t)=>Ou(e,t)}}();var Bu,Uu,Vu,$u,Gu,Hu;function Wu(e,t,n){if(t===n)return!0;if(e==Bu.BYTES){if(!(t instanceof Uint8Array&&n instanceof Uint8Array))return!1;if(t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==n[e])return!1;return!0}switch(e){case Bu.UINT64:case Bu.FIXED64:case Bu.INT64:case Bu.SFIXED64:case Bu.SINT64:return t==n}return!1}function qu(e,t){switch(e){case Bu.BOOL:return!1;case Bu.UINT64:case Bu.FIXED64:case Bu.INT64:case Bu.SFIXED64:case Bu.SINT64:return 0==t?zu.zero:"0";case Bu.DOUBLE:case Bu.FLOAT:return 0;case Bu.BYTES:return new Uint8Array(0);case Bu.STRING:return"";default:return 0}}function Yu(e,t){switch(e){case Bu.BOOL:return!1===t;case Bu.STRING:return""===t;case Bu.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return 0==t}}(Uu=Bu||(Bu={}))[Uu.DOUBLE=1]="DOUBLE",Uu[Uu.FLOAT=2]="FLOAT",Uu[Uu.INT64=3]="INT64",Uu[Uu.UINT64=4]="UINT64",Uu[Uu.INT32=5]="INT32",Uu[Uu.FIXED64=6]="FIXED64",Uu[Uu.FIXED32=7]="FIXED32",Uu[Uu.BOOL=8]="BOOL",Uu[Uu.STRING=9]="STRING",Uu[Uu.BYTES=12]="BYTES",Uu[Uu.UINT32=13]="UINT32",Uu[Uu.SFIXED32=15]="SFIXED32",Uu[Uu.SFIXED64=16]="SFIXED64",Uu[Uu.SINT32=17]="SINT32",Uu[Uu.SINT64=18]="SINT64",($u=Vu||(Vu={}))[$u.BIGINT=0]="BIGINT",$u[$u.STRING=1]="STRING",(Hu=Gu||(Gu={}))[Hu.Varint=0]="Varint",Hu[Hu.Bit64=1]="Bit64",Hu[Hu.LengthDelimited=2]="LengthDelimited",Hu[Hu.StartGroup=3]="StartGroup",Hu[Hu.EndGroup=4]="EndGroup",Hu[Hu.Bit32=5]="Bit32";class Ju{constructor(e){this.stack=[],this.textEncoder=null!=e?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let o=0;o<this.chunks.length;o++)e+=this.chunks[o].length;let t=new Uint8Array(e),n=0;for(let o=0;o<this.chunks.length;o++)t.set(this.chunks[o],n),n+=this.chunks[o].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(yu(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return xu(e),Ru(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){bu(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){yu(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){xu(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return xu(e),Ru(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),o=zu.enc(e);return n.setInt32(0,o.lo,!0),n.setInt32(4,o.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),o=zu.uEnc(e);return n.setInt32(0,o.lo,!0),n.setInt32(4,o.hi,!0),this.raw(t)}int64(e){let t=zu.enc(e);return Au(t.lo,t.hi,this.buf),this}sint64(e){let t=zu.enc(e),n=t.hi>>31;return Au(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=zu.uEnc(e);return Au(t.lo,t.hi,this.buf),this}}class Ku{constructor(e,t){this.varint64=Iu,this.uint32=Fu,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=null!=t?t:new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,n=7&e;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case Gu.Varint:for(;128&this.buf[this.pos++];);break;case Gu.Bit64:this.pos+=4;case Gu.Bit32:this.pos+=4;break;case Gu.LengthDelimited:let n=this.uint32();this.pos+=n;break;case Gu.StartGroup:for(;;){const[e,n]=this.tag();if(n===Gu.EndGroup){if(void 0!==t&&e!==t)throw new Error("invalid end group tag");break}this.skip(n,e)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return zu.dec(...this.varint64())}uint64(){return zu.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(1&e);return e=(e>>>1|(1&t)<<31)^n,t=t>>>1^n,zu.dec(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return zu.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return zu.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function Xu(e){const t=e.field.localName,n=Object.create(null);return n[t]=function(e){const t=e.field;if(t.repeated)return[];if(void 0!==t.default)return t.default;switch(t.kind){case"enum":return t.T.values[0].no;case"scalar":return qu(t.T,t.L);case"message":const e=t.T,n=new e;return e.fieldWrapper?e.fieldWrapper.unwrapField(n):n;case"map":throw"map fields are not allowed to be extensions"}}(e),[n,()=>n[t]]}let Zu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Qu=[];for(let FT=0;FT<Zu.length;FT++)Qu[Zu[FT].charCodeAt(0)]=FT;Qu["-".charCodeAt(0)]=Zu.indexOf("+"),Qu["_".charCodeAt(0)]=Zu.indexOf("/");const eh={dec(e){let t=3*e.length/4;"="==e[e.length-2]?t-=2:"="==e[e.length-1]&&(t-=1);let n,o=new Uint8Array(t),r=0,a=0,s=0;for(let i=0;i<e.length;i++){if(n=Qu[e.charCodeAt(i)],void 0===n)switch(e[i]){case"=":a=0;case"\n":case"\r":case"\t":case" ":continue;default:throw Error("invalid base64 string.")}switch(a){case 0:s=n,a=1;break;case 1:o[r++]=s<<2|(48&n)>>4,s=n,a=2;break;case 2:o[r++]=(15&s)<<4|(60&n)>>2,s=n,a=3;break;case 3:o[r++]=(3&s)<<6|n,a=0}}if(1==a)throw Error("invalid base64 string.");return o.subarray(0,r)},enc(e){let t,n="",o=0,r=0;for(let a=0;a<e.length;a++)switch(t=e[a],o){case 0:n+=Zu[t>>2],r=(3&t)<<4,o=1;break;case 1:n+=Zu[r|t>>4],r=(15&t)<<2,o=2;break;case 2:n+=Zu[r|t>>6],n+=Zu[63&t],o=0}return o&&(n+=Zu[r],n+="=",1==o&&(n+="=")),n}};function th(e,t,n){rh(t,e);const o=t.runtime.bin.makeReadOptions(n),r=function(e,t){if(!t.repeated&&("enum"==t.kind||"scalar"==t.kind)){for(let n=e.length-1;n>=0;--n)if(e[n].no==t.no)return[e[n]];return[]}return e.filter((e=>e.no===t.no))}(e.getType().runtime.bin.listUnknownFields(e),t.field),[a,s]=Xu(t);for(const i of r)t.runtime.bin.readField(a,o.readerFactory(i.data),t.field,i.wireType,o);return s()}function nh(e,t,n,o){rh(t,e);const r=t.runtime.bin.makeReadOptions(o),a=t.runtime.bin.makeWriteOptions(o);if(oh(e,t)){const n=e.getType().runtime.bin.listUnknownFields(e).filter((e=>e.no!=t.field.no));e.getType().runtime.bin.discardUnknownFields(e);for(const t of n)e.getType().runtime.bin.onUnknownField(e,t.no,t.wireType,t.data)}const s=a.writerFactory();let i=t.field;i.opt||i.repeated||"enum"!=i.kind&&"scalar"!=i.kind||(i=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(i,n,s,a);const l=r.readerFactory(s.finish());for(;l.pos<l.len;){const[t,n]=l.tag(),o=l.skip(n,t);e.getType().runtime.bin.onUnknownField(e,t,n,o)}}function oh(e,t){const n=e.getType();return t.extendee.typeName===n.typeName&&!!n.runtime.bin.listUnknownFields(e).find((e=>e.no==t.field.no))}function rh(e,t){vu(e.extendee.typeName==t.getType().typeName,`extension ${e.typeName} can only be applied to message ${e.extendee.typeName}`)}function ah(e,t){const n=e.localName;if(e.repeated)return t[n].length>0;if(e.oneof)return t[e.oneof.localName].case===n;switch(e.kind){case"enum":case"scalar":return e.opt||e.req?void 0!==t[n]:"enum"==e.kind?t[n]!==e.T.values[0].no:!Yu(e.T,t[n]);case"message":return void 0!==t[n];case"map":return Object.keys(t[n]).length>0}}function sh(e,t){const n=e.localName,o=!e.opt&&!e.req;if(e.repeated)t[n]=[];else if(e.oneof)t[e.oneof.localName]={case:void 0};else switch(e.kind){case"map":t[n]={};break;case"enum":t[n]=o?e.T.values[0].no:void 0;break;case"scalar":t[n]=o?qu(e.T,e.L):void 0;break;case"message":t[n]=void 0}}function ih(e,t){if(null===e||"object"!=typeof e)return!1;if(!Object.getOwnPropertyNames(Su.prototype).every((t=>t in e&&"function"==typeof e[t])))return!1;const n=e.getType();return null!==n&&"function"==typeof n&&"typeName"in n&&"string"==typeof n.typeName&&(void 0===t||n.typeName==t.typeName)}function lh(e,t){return ih(t)||!e.fieldWrapper?t:e.fieldWrapper.wrapField(t)}Bu.DOUBLE,Bu.FLOAT,Bu.INT64,Bu.UINT64,Bu.INT32,Bu.UINT32,Bu.BOOL,Bu.STRING,Bu.BYTES;const ch={ignoreUnknownFields:!1},dh={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function uh(e){return e?Object.assign(Object.assign({},ch),e):ch}function hh(e){return e?Object.assign(Object.assign({},dh),e):dh}const fh=Symbol(),mh=Symbol();function ph(e){if(null===e)return"null";switch(typeof e){case"object":return Array.isArray(e)?"array":"object";case"string":return e.length>100?"string":`"${e.split('"').join('\\"')}"`;default:return String(e)}}function gh(e,t,n,o,r){let a=n.localName;if(n.repeated){if(vu("map"!=n.kind),null===t)return;if(!Array.isArray(t))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${ph(t)}`);const i=e[a];for(const e of t){if(null===e)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${ph(e)}`);switch(n.kind){case"message":i.push(n.T.fromJson(e,o));break;case"enum":const t=yh(n.T,e,o.ignoreUnknownFields,!0);t!==mh&&i.push(t);break;case"scalar":try{i.push(xh(n.T,e,n.L,!0))}catch(s){let t=`cannot decode field ${r.typeName}.${n.name} from JSON: ${ph(e)}`;throw s instanceof Error&&s.message.length>0&&(t+=`: ${s.message}`),new Error(t)}}}}else if("map"==n.kind){if(null===t)return;if("object"!=typeof t||Array.isArray(t))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${ph(t)}`);const i=e[a];for(const[e,a]of Object.entries(t)){if(null===a)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: map value null`);let l;try{l=vh(n.K,e)}catch(s){let e=`cannot decode map key for field ${r.typeName}.${n.name} from JSON: ${ph(t)}`;throw s instanceof Error&&s.message.length>0&&(e+=`: ${s.message}`),new Error(e)}switch(n.V.kind){case"message":i[l]=n.V.T.fromJson(a,o);break;case"enum":const e=yh(n.V.T,a,o.ignoreUnknownFields,!0);e!==mh&&(i[l]=e);break;case"scalar":try{i[l]=xh(n.V.T,a,Vu.BIGINT,!0)}catch(s){let e=`cannot decode map value for field ${r.typeName}.${n.name} from JSON: ${ph(t)}`;throw s instanceof Error&&s.message.length>0&&(e+=`: ${s.message}`),new Error(e)}}}}else switch(n.oneof&&(e=e[n.oneof.localName]={case:a},a="value"),n.kind){case"message":const i=n.T;if(null===t&&"google.protobuf.Value"!=i.typeName)return;let l=e[a];ih(l)?l.fromJson(t,o):(e[a]=l=i.fromJson(t,o),i.fieldWrapper&&!n.oneof&&(e[a]=i.fieldWrapper.unwrapField(l)));break;case"enum":const c=yh(n.T,t,o.ignoreUnknownFields,!1);switch(c){case fh:sh(n,e);break;case mh:break;default:e[a]=c}break;case"scalar":try{const o=xh(n.T,t,n.L,!1);if(o===fh)sh(n,e);else e[a]=o}catch(s){let e=`cannot decode field ${r.typeName}.${n.name} from JSON: ${ph(t)}`;throw s instanceof Error&&s.message.length>0&&(e+=`: ${s.message}`),new Error(e)}}}function vh(e,t){if(e===Bu.BOOL)switch(t){case"true":t=!0;break;case"false":t=!1}return xh(e,t,Vu.BIGINT,!0).toString()}function xh(e,t,n,o){if(null===t)return o?qu(e,n):fh;switch(e){case Bu.DOUBLE:case Bu.FLOAT:if("NaN"===t)return Number.NaN;if("Infinity"===t)return Number.POSITIVE_INFINITY;if("-Infinity"===t)return Number.NEGATIVE_INFINITY;if(""===t)break;if("string"==typeof t&&t.trim().length!==t.length)break;if("string"!=typeof t&&"number"!=typeof t)break;const o=Number(t);if(Number.isNaN(o))break;if(!Number.isFinite(o))break;return e==Bu.FLOAT&&bu(o),o;case Bu.INT32:case Bu.FIXED32:case Bu.SFIXED32:case Bu.SINT32:case Bu.UINT32:let a;if("number"==typeof t?a=t:"string"==typeof t&&t.length>0&&t.trim().length===t.length&&(a=Number(t)),void 0===a)break;return e==Bu.UINT32||e==Bu.FIXED32?yu(a):xu(a),a;case Bu.INT64:case Bu.SFIXED64:case Bu.SINT64:if("number"!=typeof t&&"string"!=typeof t)break;const s=zu.parse(t);return n?s.toString():s;case Bu.FIXED64:case Bu.UINT64:if("number"!=typeof t&&"string"!=typeof t)break;const i=zu.uParse(t);return n?i.toString():i;case Bu.BOOL:if("boolean"!=typeof t)break;return t;case Bu.STRING:if("string"!=typeof t)break;try{encodeURIComponent(t)}catch(r){throw new Error("invalid UTF8")}return t;case Bu.BYTES:if(""===t)return new Uint8Array(0);if("string"!=typeof t)break;return eh.dec(t)}throw new Error}function yh(e,t,n,o){if(null===t)return"google.protobuf.NullValue"==e.typeName?0:o?e.values[0].no:fh;switch(typeof t){case"number":if(Number.isInteger(t))return t;break;case"string":const o=e.findName(t);if(void 0!==o)return o.no;if(n)return mh}throw new Error(`cannot decode enum ${e.typeName} from JSON: ${ph(t)}`)}function bh(e){return!(!e.repeated&&"map"!=e.kind)||!e.oneof&&("message"!=e.kind&&(!e.opt&&!e.req))}function wh(e,t,n){if("map"==e.kind){vu("object"==typeof t&&null!=t);const o={},r=Object.entries(t);switch(e.V.kind){case"scalar":for(const[n,a]of r)o[n.toString()]=Nh(e.V.T,a);break;case"message":for(const[e,a]of r)o[e.toString()]=a.toJson(n);break;case"enum":const t=e.V.T;for(const[e,a]of r)o[e.toString()]=kh(t,a,n.enumAsInteger)}return n.emitDefaultValues||r.length>0?o:void 0}if(e.repeated){vu(Array.isArray(t));const o=[];switch(e.kind){case"scalar":for(let n=0;n<t.length;n++)o.push(Nh(e.T,t[n]));break;case"enum":for(let r=0;r<t.length;r++)o.push(kh(e.T,t[r],n.enumAsInteger));break;case"message":for(let e=0;e<t.length;e++)o.push(t[e].toJson(n))}return n.emitDefaultValues||o.length>0?o:void 0}switch(e.kind){case"scalar":return Nh(e.T,t);case"enum":return kh(e.T,t,n.enumAsInteger);case"message":return lh(e.T,t).toJson(n)}}function kh(e,t,n){var o;if(vu("number"==typeof t),"google.protobuf.NullValue"==e.typeName)return null;if(n)return t;const r=e.findNumber(t);return null!==(o=null==r?void 0:r.name)&&void 0!==o?o:t}function Nh(e,t){switch(e){case Bu.INT32:case Bu.SFIXED32:case Bu.SINT32:case Bu.FIXED32:case Bu.UINT32:return vu("number"==typeof t),t;case Bu.FLOAT:case Bu.DOUBLE:return vu("number"==typeof t),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t;case Bu.STRING:return vu("string"==typeof t),t;case Bu.BOOL:return vu("boolean"==typeof t),t;case Bu.UINT64:case Bu.FIXED64:case Bu.INT64:case Bu.SFIXED64:case Bu.SINT64:return vu("bigint"==typeof t||"string"==typeof t||"number"==typeof t),t.toString();case Bu.BYTES:return vu(t instanceof Uint8Array),eh.enc(t)}}const Eh=Symbol("@bufbuild/protobuf/unknown-fields"),Ch={readUnknownFields:!0,readerFactory:e=>new Ku(e)},jh={writeUnknownFields:!0,writerFactory:()=>new Ju};function Sh(e){return e?Object.assign(Object.assign({},Ch),e):Ch}function Ih(e){return e?Object.assign(Object.assign({},jh),e):jh}function Ah(e,t,n,o,r){let{repeated:a,localName:s}=n;switch(n.oneof&&((e=e[n.oneof.localName]).case!=s&&delete e.value,e.case=s,s="value"),n.kind){case"scalar":case"enum":const i="enum"==n.kind?Bu.INT32:n.T;let l=Oh;if("scalar"==n.kind&&n.L>0&&(l=Th),a){let n=e[s];if(o==Gu.LengthDelimited&&i!=Bu.STRING&&i!=Bu.BYTES){let e=t.uint32()+t.pos;for(;t.pos<e;)n.push(l(t,i))}else n.push(l(t,i))}else e[s]=l(t,i);break;case"message":const c=n.T;a?e[s].push(Mh(t,new c,r,n)):ih(e[s])?Mh(t,e[s],r,n):(e[s]=Mh(t,new c,r,n),!c.fieldWrapper||n.oneof||n.repeated||(e[s]=c.fieldWrapper.unwrapField(e[s])));break;case"map":let[d,u]=function(e,t,n){const o=t.uint32(),r=t.pos+o;let a,s;for(;t.pos<r;){const[o]=t.tag();switch(o){case 1:a=Oh(t,e.K);break;case 2:switch(e.V.kind){case"scalar":s=Oh(t,e.V.T);break;case"enum":s=t.int32();break;case"message":s=Mh(t,new e.V.T,n,void 0)}}}void 0===a&&(a=qu(e.K,Vu.BIGINT));"string"!=typeof a&&"number"!=typeof a&&(a=a.toString());if(void 0===s)switch(e.V.kind){case"scalar":s=qu(e.V.T,Vu.BIGINT);break;case"enum":s=e.V.T.values[0].no;break;case"message":s=new e.V.T}return[a,s]}(n,t,r);e[s][d]=u}}function Mh(e,t,n,o){const r=t.getType().runtime.bin,a=null==o?void 0:o.delimited;return r.readMessage(t,e,a?o.no:e.uint32(),n,a),t}function Th(e,t){const n=Oh(e,t);return"bigint"==typeof n?n.toString():n}function Oh(e,t){switch(t){case Bu.STRING:return e.string();case Bu.BOOL:return e.bool();case Bu.DOUBLE:return e.double();case Bu.FLOAT:return e.float();case Bu.INT32:return e.int32();case Bu.INT64:return e.int64();case Bu.UINT64:return e.uint64();case Bu.FIXED64:return e.fixed64();case Bu.BYTES:return e.bytes();case Bu.FIXED32:return e.fixed32();case Bu.SFIXED32:return e.sfixed32();case Bu.SFIXED64:return e.sfixed64();case Bu.SINT64:return e.sint64();case Bu.UINT32:return e.uint32();case Bu.SINT32:return e.sint32()}}function Dh(e,t,n,o){vu(void 0!==t);const r=e.repeated;switch(e.kind){case"scalar":case"enum":let a="enum"==e.kind?Bu.INT32:e.T;if(r)if(vu(Array.isArray(t)),e.packed)!function(e,t,n,o){if(!o.length)return;e.tag(n,Gu.LengthDelimited).fork();let[,r]=Fh(t);for(let a=0;a<o.length;a++)e[r](o[a]);e.join()}(n,a,e.no,t);else for(const o of t)Rh(n,a,e.no,o);else Rh(n,a,e.no,t);break;case"message":if(r){vu(Array.isArray(t));for(const r of t)Ph(n,o,e,r)}else Ph(n,o,e,t);break;case"map":vu("object"==typeof t&&null!=t);for(const[r,s]of Object.entries(t))_h(n,o,e,r,s)}}function _h(e,t,n,o,r){e.tag(n.no,Gu.LengthDelimited),e.fork();let a=o;switch(n.K){case Bu.INT32:case Bu.FIXED32:case Bu.UINT32:case Bu.SFIXED32:case Bu.SINT32:a=Number.parseInt(o);break;case Bu.BOOL:vu("true"==o||"false"==o),a="true"==o}switch(Rh(e,n.K,1,a),n.V.kind){case"scalar":Rh(e,n.V.T,2,r);break;case"enum":Rh(e,Bu.INT32,2,r);break;case"message":vu(void 0!==r),e.tag(2,Gu.LengthDelimited).bytes(r.toBinary(t))}e.join()}function Ph(e,t,n,o){const r=lh(n.T,o);n.delimited?e.tag(n.no,Gu.StartGroup).raw(r.toBinary(t)).tag(n.no,Gu.EndGroup):e.tag(n.no,Gu.LengthDelimited).bytes(r.toBinary(t))}function Rh(e,t,n,o){vu(void 0!==o);let[r,a]=Fh(t);e.tag(n,r)[a](o)}function Fh(e){let t=Gu.Varint;switch(e){case Bu.BYTES:case Bu.STRING:t=Gu.LengthDelimited;break;case Bu.DOUBLE:case Bu.FIXED64:case Bu.SFIXED64:t=Gu.Bit64;break;case Bu.FIXED32:case Bu.SFIXED32:case Bu.FLOAT:t=Gu.Bit32}return[t,Bu[e].toLowerCase()]}function Lh(e){if(void 0===e)return e;if(ih(e))return e.clone();if(e instanceof Uint8Array){const t=new Uint8Array(e.byteLength);return t.set(e),t}return e}function zh(e){return e instanceof Uint8Array?e:new Uint8Array(e)}class Bh{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const e={};for(const t of this.list())e[t.jsonName]=e[t.name]=t;this.jsonNames=e}return this.jsonNames[e]}find(e){if(!this.numbers){const e={};for(const t of this.list())e[t.no]=t;this.numbers=e}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort(((e,t)=>e.no-t.no))),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const n of this.list())n.oneof?n.oneof!==t&&(t=n.oneof,e.push(t)):e.push(n)}return this.members}}function Uh(e,t){const n=$h(e);return t?n:Yh(qh(n))}const Vh=$h;function $h(e){let t=!1;const n=[];for(let o=0;o<e.length;o++){let r=e.charAt(o);switch(r){case"_":t=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n.push(r),t=!1;break;default:t&&(t=!1,r=r.toUpperCase()),n.push(r)}}return n.join("")}const Gh=new Set(["constructor","toString","toJSON","valueOf"]),Hh=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),Wh=e=>`${e}$`,qh=e=>Hh.has(e)?Wh(e):e,Yh=e=>Gh.has(e)?Wh(e):e;class Jh{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=Uh(e,!1)}addField(e){vu(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let e=0;e<this.fields.length;e++)this._lookup[this.fields[e].localName]=this.fields[e]}return this._lookup[e]}}const Kh=(Xh=e=>new Bh(e,(e=>function(e){var t,n,o,r,a,s;const i=[];let l;for(const c of"function"==typeof e?e():e){const e=c;if(e.localName=Uh(c.name,void 0!==c.oneof),e.jsonName=null!==(t=c.jsonName)&&void 0!==t?t:Vh(c.name),e.repeated=null!==(n=c.repeated)&&void 0!==n&&n,"scalar"==c.kind&&(e.L=null!==(o=c.L)&&void 0!==o?o:Vu.BIGINT),e.delimited=null!==(r=c.delimited)&&void 0!==r&&r,e.req=null!==(a=c.req)&&void 0!==a&&a,e.opt=null!==(s=c.opt)&&void 0!==s&&s,void 0===c.packed&&(e.packed="enum"==c.kind||"scalar"==c.kind&&c.T!=Bu.BYTES&&c.T!=Bu.STRING),void 0!==c.oneof){const t="string"==typeof c.oneof?c.oneof:c.oneof.name;l&&l.name==t||(l=new Jh(t)),e.oneof=l,l.addField(e)}i.push(e)}return i}(e))),Zh=e=>{for(const t of e.getType().fields.byMember()){if(t.opt)continue;const n=t.localName,o=e;if(t.repeated)o[n]=[];else switch(t.kind){case"oneof":o[n]={case:void 0};break;case"enum":o[n]=0;break;case"map":o[n]={};break;case"scalar":o[n]=qu(t.T,t.L)}}},{syntax:"proto3",json:{makeReadOptions:uh,makeWriteOptions:hh,readMessage(e,t,n,o){if(null==t||Array.isArray(t)||"object"!=typeof t)throw new Error(`cannot decode message ${e.typeName} from JSON: ${ph(t)}`);o=null!=o?o:new e;const r=new Map,a=n.typeRegistry;for(const[s,i]of Object.entries(t)){const t=e.fields.findJsonName(s);if(t){if(t.oneof){if(null===i&&"scalar"==t.kind)continue;const n=r.get(t.oneof);if(void 0!==n)throw new Error(`cannot decode message ${e.typeName} from JSON: multiple keys for oneof "${t.oneof.name}" present: "${n}", "${s}"`);r.set(t.oneof,s)}gh(o,i,t,n,e)}else{let t=!1;if((null==a?void 0:a.findExtension)&&s.startsWith("[")&&s.endsWith("]")){const r=a.findExtension(s.substring(1,s.length-1));if(r&&r.extendee.typeName==e.typeName){t=!0;const[e,a]=Xu(r);gh(e,i,r.field,n,r),nh(o,r,a(),n)}}if(!t&&!n.ignoreUnknownFields)throw new Error(`cannot decode message ${e.typeName} from JSON: key "${s}" is unknown`)}}return o},writeMessage(e,t){const n=e.getType(),o={};let r;try{for(r of n.fields.byNumber()){if(!ah(r,e)){if(r.req)throw"required field not set";if(!t.emitDefaultValues)continue;if(!bh(r))continue}const n=wh(r,r.oneof?e[r.oneof.localName].value:e[r.localName],t);void 0!==n&&(o[t.useProtoFieldName?r.name:r.jsonName]=n)}const a=t.typeRegistry;if(null==a?void 0:a.findExtensionFor)for(const r of n.runtime.bin.listUnknownFields(e)){const s=a.findExtensionFor(n.typeName,r.no);if(s&&oh(e,s)){const n=th(e,s,t),r=wh(s.field,n,t);void 0!==r&&(o[s.field.jsonName]=r)}}}catch(a){const e=r?`cannot encode field ${n.typeName}.${r.name} to JSON`:`cannot encode message ${n.typeName} to JSON`,t=a instanceof Error?a.message:String(a);throw new Error(e+(t.length>0?`: ${t}`:""))}return o},readScalar:(e,t,n)=>xh(e,t,null!=n?n:Vu.BIGINT,!0),writeScalar(e,t,n){if(void 0!==t)return n||Yu(e,t)?Nh(e,t):void 0},debug:ph},bin:{makeReadOptions:Sh,makeWriteOptions:Ih,listUnknownFields(e){var t;return null!==(t=e[Eh])&&void 0!==t?t:[]},discardUnknownFields(e){delete e[Eh]},writeUnknownFields(e,t){const n=e[Eh];if(n)for(const o of n)t.tag(o.no,o.wireType).raw(o.data)},onUnknownField(e,t,n,o){const r=e;Array.isArray(r[Eh])||(r[Eh]=[]),r[Eh].push({no:t,wireType:n,data:o})},readMessage(e,t,n,o,r){const a=e.getType(),s=r?t.len:t.pos+n;let i,l;for(;t.pos<s&&([i,l]=t.tag(),!0!==r||l!=Gu.EndGroup);){const n=a.fields.find(i);if(n)Ah(e,t,n,l,o);else{const n=t.skip(l,i);o.readUnknownFields&&this.onUnknownField(e,i,l,n)}}if(r&&(l!=Gu.EndGroup||i!==n))throw new Error("invalid end group tag")},readField:Ah,writeMessage(e,t,n){const o=e.getType();for(const r of o.fields.byNumber())if(ah(r,e))Dh(r,r.oneof?e[r.oneof.localName].value:e[r.localName],t,n);else if(r.req)throw new Error(`cannot encode field ${o.typeName}.${r.name} to binary: required field not set`);return n.writeUnknownFields&&this.writeUnknownFields(e,t),t},writeField(e,t,n,o){void 0!==t&&Dh(e,t,n,o)}},util:Object.assign(Object.assign({},{setEnumType:Nu,initPartial(e,t){if(void 0===e)return;const n=t.getType();for(const o of n.fields.byMember()){const n=o.localName,r=t,a=e;if(null!=a[n])switch(o.kind){case"oneof":const e=a[n].case;if(void 0===e)continue;const t=o.findField(e);let s=a[n].value;t&&"message"==t.kind&&!ih(s,t.T)?s=new t.T(s):t&&"scalar"===t.kind&&t.T===Bu.BYTES&&(s=zh(s)),r[n]={case:e,value:s};break;case"scalar":case"enum":let i=a[n];o.T===Bu.BYTES&&(i=o.repeated?i.map(zh):zh(i)),r[n]=i;break;case"map":switch(o.V.kind){case"scalar":case"enum":if(o.V.T===Bu.BYTES)for(const[t,o]of Object.entries(a[n]))r[n][t]=zh(o);else Object.assign(r[n],a[n]);break;case"message":const e=o.V.T;for(const t of Object.keys(a[n])){let o=a[n][t];e.fieldWrapper||(o=new e(o)),r[n][t]=o}}break;case"message":const l=o.T;if(o.repeated)r[n]=a[n].map((e=>ih(e,l)?e:new l(e)));else{const e=a[n];l.fieldWrapper?"google.protobuf.BytesValue"===l.typeName?r[n]=zh(e):r[n]=e:r[n]=ih(e,l)?e:new l(e)}}}},equals:(e,t,n)=>t===n||!(!t||!n)&&e.fields.byMember().every((e=>{const o=t[e.localName],r=n[e.localName];if(e.repeated){if(o.length!==r.length)return!1;switch(e.kind){case"message":return o.every(((t,n)=>e.T.equals(t,r[n])));case"scalar":return o.every(((t,n)=>Wu(e.T,t,r[n])));case"enum":return o.every(((e,t)=>Wu(Bu.INT32,e,r[t])))}throw new Error(`repeated cannot contain ${e.kind}`)}switch(e.kind){case"message":return e.T.equals(o,r);case"enum":return Wu(Bu.INT32,o,r);case"scalar":return Wu(e.T,o,r);case"oneof":if(o.case!==r.case)return!1;const t=e.findField(o.case);if(void 0===t)return!0;switch(t.kind){case"message":return t.T.equals(o.value,r.value);case"enum":return Wu(Bu.INT32,o.value,r.value);case"scalar":return Wu(t.T,o.value,r.value)}throw new Error(`oneof cannot contain ${t.kind}`);case"map":const n=Object.keys(o).concat(Object.keys(r));switch(e.V.kind){case"message":const t=e.V.T;return n.every((e=>t.equals(o[e],r[e])));case"enum":return n.every((e=>Wu(Bu.INT32,o[e],r[e])));case"scalar":const a=e.V.T;return n.every((e=>Wu(a,o[e],r[e])))}}})),clone(e){const t=e.getType(),n=new t,o=n;for(const r of t.fields.byMember()){const t=e[r.localName];let n;if(r.repeated)n=t.map(Lh);else if("map"==r.kind){n=o[r.localName];for(const[e,o]of Object.entries(t))n[e]=Lh(o)}else n="oneof"==r.kind?r.findField(t.case)?{case:t.case,value:Lh(t.value)}:{case:void 0}:Lh(t);o[r.localName]=n}for(const r of t.runtime.bin.listUnknownFields(e))t.runtime.bin.onUnknownField(o,r.no,r.wireType,r.data);return n}}),{newFieldList:Xh,initFields:Zh}),makeMessageType(e,t,n){return function(e,t,n,o){var r;const a=null!==(r=null==o?void 0:o.localName)&&void 0!==r?r:t.substring(t.lastIndexOf(".")+1),s={[a]:function(t){e.util.initFields(this),e.util.initPartial(t,this)}}[a];return Object.setPrototypeOf(s.prototype,new Su),Object.assign(s,{runtime:e,typeName:t,fields:e.util.newFieldList(n),fromBinary:(e,t)=>(new s).fromBinary(e,t),fromJson:(e,t)=>(new s).fromJson(e,t),fromJsonString:(e,t)=>(new s).fromJsonString(e,t),equals:(t,n)=>e.util.equals(s,t,n)}),s}(this,e,t,n)},makeEnum:Cu,makeEnumType:Eu,getEnumType:ku,makeExtension(e,t,n){return function(e,t,n,o){let r;return{typeName:t,extendee:n,get field(){if(!r){const n="function"==typeof o?o():o;n.name=t.split(".").pop(),n.jsonName=`[${t}]`,r=e.util.newFieldList([n]).list()[0]}return r},runtime:e}}(this,e,t,n)}});var Xh,Zh,Qh,ef,tf,nf,of,rf,af,sf,lf,cf,df,uf,hf,ff;(ef=Qh||(Qh={}))[ef.Unary=0]="Unary",ef[ef.ServerStreaming=1]="ServerStreaming",ef[ef.ClientStreaming=2]="ClientStreaming",ef[ef.BiDiStreaming=3]="BiDiStreaming",(nf=tf||(tf={}))[nf.NoSideEffects=1]="NoSideEffects",nf[nf.Idempotent=2]="Idempotent",(rf=of||(of={}))[rf.UNSPECIFIED=0]="UNSPECIFIED",rf[rf.JUPYTER_FORMAT=77]="JUPYTER_FORMAT",Kh.util.setEnumType(of,"exa.codeium_common_pb.ExperimentKey",[{no:0,name:"UNSPECIFIED"},{no:77,name:"JUPYTER_FORMAT"}]),(sf=af||(af={}))[sf.CODEIUM=0]="CODEIUM",Kh.util.setEnumType(af,"exa.codeium_common_pb.AuthSource",[{no:0,name:"AUTH_SOURCE_CODEIUM"}]),(cf=lf||(lf={}))[cf.UNSPECIFIED=0]="UNSPECIFIED",cf[cf.ENABLE_CODEIUM=1]="ENABLE_CODEIUM",cf[cf.DISABLE_CODEIUM=2]="DISABLE_CODEIUM",cf[cf.SHOW_PREVIOUS_COMPLETION=3]="SHOW_PREVIOUS_COMPLETION",cf[cf.SHOW_NEXT_COMPLETION=4]="SHOW_NEXT_COMPLETION",Kh.util.setEnumType(lf,"exa.codeium_common_pb.EventType",[{no:0,name:"EVENT_TYPE_UNSPECIFIED"},{no:1,name:"EVENT_TYPE_ENABLE_CODEIUM"},{no:2,name:"EVENT_TYPE_DISABLE_CODEIUM"},{no:3,name:"EVENT_TYPE_SHOW_PREVIOUS_COMPLETION"},{no:4,name:"EVENT_TYPE_SHOW_NEXT_COMPLETION"}]),(uf=df||(df={}))[uf.UNSPECIFIED=0]="UNSPECIFIED",uf[uf.TYPING_AS_SUGGESTED=1]="TYPING_AS_SUGGESTED",uf[uf.CACHE=2]="CACHE",uf[uf.NETWORK=3]="NETWORK",Kh.util.setEnumType(df,"exa.codeium_common_pb.CompletionSource",[{no:0,name:"COMPLETION_SOURCE_UNSPECIFIED"},{no:1,name:"COMPLETION_SOURCE_TYPING_AS_SUGGESTED"},{no:2,name:"COMPLETION_SOURCE_CACHE"},{no:3,name:"COMPLETION_SOURCE_NETWORK"}]),(ff=hf||(hf={}))[ff.UNSPECIFIED=0]="UNSPECIFIED",ff[ff.C=1]="C",ff[ff.CLOJURE=2]="CLOJURE",ff[ff.COFFEESCRIPT=3]="COFFEESCRIPT",ff[ff.CPP=4]="CPP",ff[ff.CSHARP=5]="CSHARP",ff[ff.CSS=6]="CSS",ff[ff.CUDACPP=7]="CUDACPP",ff[ff.DOCKERFILE=8]="DOCKERFILE",ff[ff.GO=9]="GO",ff[ff.GROOVY=10]="GROOVY",ff[ff.HANDLEBARS=11]="HANDLEBARS",ff[ff.HASKELL=12]="HASKELL",ff[ff.HCL=13]="HCL",ff[ff.HTML=14]="HTML",ff[ff.INI=15]="INI",ff[ff.JAVA=16]="JAVA",ff[ff.JAVASCRIPT=17]="JAVASCRIPT",ff[ff.JSON=18]="JSON",ff[ff.JULIA=19]="JULIA",ff[ff.KOTLIN=20]="KOTLIN",ff[ff.LATEX=21]="LATEX",ff[ff.LESS=22]="LESS",ff[ff.LUA=23]="LUA",ff[ff.MAKEFILE=24]="MAKEFILE",ff[ff.MARKDOWN=25]="MARKDOWN",ff[ff.OBJECTIVEC=26]="OBJECTIVEC",ff[ff.OBJECTIVECPP=27]="OBJECTIVECPP",ff[ff.PERL=28]="PERL",ff[ff.PHP=29]="PHP",ff[ff.PLAINTEXT=30]="PLAINTEXT",ff[ff.PROTOBUF=31]="PROTOBUF",ff[ff.PBTXT=32]="PBTXT",ff[ff.PYTHON=33]="PYTHON",ff[ff.R=34]="R",ff[ff.RUBY=35]="RUBY",ff[ff.RUST=36]="RUST",ff[ff.SASS=37]="SASS",ff[ff.SCALA=38]="SCALA",ff[ff.SCSS=39]="SCSS",ff[ff.SHELL=40]="SHELL",ff[ff.SQL=41]="SQL",ff[ff.STARLARK=42]="STARLARK",ff[ff.SWIFT=43]="SWIFT",ff[ff.TSX=44]="TSX",ff[ff.TYPESCRIPT=45]="TYPESCRIPT",ff[ff.VISUALBASIC=46]="VISUALBASIC",ff[ff.VUE=47]="VUE",ff[ff.XML=48]="XML",ff[ff.XSL=49]="XSL",ff[ff.YAML=50]="YAML",ff[ff.SVELTE=51]="SVELTE",ff[ff.TOML=52]="TOML",ff[ff.DART=53]="DART",ff[ff.RST=54]="RST",ff[ff.OCAML=55]="OCAML",ff[ff.CMAKE=56]="CMAKE",ff[ff.PASCAL=57]="PASCAL",ff[ff.ELIXIR=58]="ELIXIR",ff[ff.FSHARP=59]="FSHARP",ff[ff.LISP=60]="LISP",ff[ff.MATLAB=61]="MATLAB",ff[ff.POWERSHELL=62]="POWERSHELL",ff[ff.SOLIDITY=63]="SOLIDITY",ff[ff.ADA=64]="ADA",ff[ff.OCAML_INTERFACE=65]="OCAML_INTERFACE",Kh.util.setEnumType(hf,"exa.codeium_common_pb.Language",[{no:0,name:"LANGUAGE_UNSPECIFIED"},{no:1,name:"LANGUAGE_C"},{no:2,name:"LANGUAGE_CLOJURE"},{no:3,name:"LANGUAGE_COFFEESCRIPT"},{no:4,name:"LANGUAGE_CPP"},{no:5,name:"LANGUAGE_CSHARP"},{no:6,name:"LANGUAGE_CSS"},{no:7,name:"LANGUAGE_CUDACPP"},{no:8,name:"LANGUAGE_DOCKERFILE"},{no:9,name:"LANGUAGE_GO"},{no:10,name:"LANGUAGE_GROOVY"},{no:11,name:"LANGUAGE_HANDLEBARS"},{no:12,name:"LANGUAGE_HASKELL"},{no:13,name:"LANGUAGE_HCL"},{no:14,name:"LANGUAGE_HTML"},{no:15,name:"LANGUAGE_INI"},{no:16,name:"LANGUAGE_JAVA"},{no:17,name:"LANGUAGE_JAVASCRIPT"},{no:18,name:"LANGUAGE_JSON"},{no:19,name:"LANGUAGE_JULIA"},{no:20,name:"LANGUAGE_KOTLIN"},{no:21,name:"LANGUAGE_LATEX"},{no:22,name:"LANGUAGE_LESS"},{no:23,name:"LANGUAGE_LUA"},{no:24,name:"LANGUAGE_MAKEFILE"},{no:25,name:"LANGUAGE_MARKDOWN"},{no:26,name:"LANGUAGE_OBJECTIVEC"},{no:27,name:"LANGUAGE_OBJECTIVECPP"},{no:28,name:"LANGUAGE_PERL"},{no:29,name:"LANGUAGE_PHP"},{no:30,name:"LANGUAGE_PLAINTEXT"},{no:31,name:"LANGUAGE_PROTOBUF"},{no:32,name:"LANGUAGE_PBTXT"},{no:33,name:"LANGUAGE_PYTHON"},{no:34,name:"LANGUAGE_R"},{no:35,name:"LANGUAGE_RUBY"},{no:36,name:"LANGUAGE_RUST"},{no:37,name:"LANGUAGE_SASS"},{no:38,name:"LANGUAGE_SCALA"},{no:39,name:"LANGUAGE_SCSS"},{no:40,name:"LANGUAGE_SHELL"},{no:41,name:"LANGUAGE_SQL"},{no:42,name:"LANGUAGE_STARLARK"},{no:43,name:"LANGUAGE_SWIFT"},{no:44,name:"LANGUAGE_TSX"},{no:45,name:"LANGUAGE_TYPESCRIPT"},{no:46,name:"LANGUAGE_VISUALBASIC"},{no:47,name:"LANGUAGE_VUE"},{no:48,name:"LANGUAGE_XML"},{no:49,name:"LANGUAGE_XSL"},{no:50,name:"LANGUAGE_YAML"},{no:51,name:"LANGUAGE_SVELTE"},{no:52,name:"LANGUAGE_TOML"},{no:53,name:"LANGUAGE_DART"},{no:54,name:"LANGUAGE_RST"},{no:55,name:"LANGUAGE_OCAML"},{no:56,name:"LANGUAGE_CMAKE"},{no:57,name:"LANGUAGE_PASCAL"},{no:58,name:"LANGUAGE_ELIXIR"},{no:59,name:"LANGUAGE_FSHARP"},{no:60,name:"LANGUAGE_LISP"},{no:61,name:"LANGUAGE_MATLAB"},{no:62,name:"LANGUAGE_POWERSHELL"},{no:63,name:"LANGUAGE_SOLIDITY"},{no:64,name:"LANGUAGE_ADA"},{no:65,name:"LANGUAGE_OCAML_INTERFACE"}]);const mf=class e extends Su{constructor(e){super(),n(this,"completionId",""),n(this,"text",""),n(this,"prefix",""),n(this,"stop",""),n(this,"score",0),n(this,"tokens",[]),n(this,"decodedTokens",[]),n(this,"probabilities",[]),n(this,"adjustedProbabilities",[]),n(this,"generatedLength",zu.zero),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(mf,"runtime",Kh),n(mf,"typeName","exa.codeium_common_pb.Completion"),n(mf,"fields",Kh.util.newFieldList((()=>[{no:1,name:"completion_id",kind:"scalar",T:9},{no:2,name:"text",kind:"scalar",T:9},{no:3,name:"prefix",kind:"scalar",T:9},{no:4,name:"stop",kind:"scalar",T:9},{no:5,name:"score",kind:"scalar",T:1},{no:6,name:"tokens",kind:"scalar",T:4,repeated:!0},{no:7,name:"decoded_tokens",kind:"scalar",T:9,repeated:!0},{no:8,name:"probabilities",kind:"scalar",T:1,repeated:!0},{no:9,name:"adjusted_probabilities",kind:"scalar",T:1,repeated:!0},{no:10,name:"generated_length",kind:"scalar",T:4}])));let pf=mf;const gf=class e extends Su{constructor(e){super(),n(this,"ideName",""),n(this,"ideVersion",""),n(this,"extensionName",""),n(this,"extensionVersion",""),n(this,"apiKey",""),n(this,"locale",""),n(this,"sessionId",""),n(this,"requestId",zu.zero),n(this,"userAgent",""),n(this,"url",""),n(this,"authSource",af.CODEIUM),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(gf,"runtime",Kh),n(gf,"typeName","exa.codeium_common_pb.Metadata"),n(gf,"fields",Kh.util.newFieldList((()=>[{no:1,name:"ide_name",kind:"scalar",T:9},{no:7,name:"ide_version",kind:"scalar",T:9},{no:12,name:"extension_name",kind:"scalar",T:9},{no:2,name:"extension_version",kind:"scalar",T:9},{no:3,name:"api_key",kind:"scalar",T:9},{no:4,name:"locale",kind:"scalar",T:9},{no:10,name:"session_id",kind:"scalar",T:9},{no:9,name:"request_id",kind:"scalar",T:4},{no:13,name:"user_agent",kind:"scalar",T:9},{no:14,name:"url",kind:"scalar",T:9},{no:15,name:"auth_source",kind:"enum",T:Kh.getEnumType(af)}])));let vf=gf;const xf=class e extends Su{constructor(e){super(),n(this,"tabSize",zu.zero),n(this,"insertSpaces",!1),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(xf,"runtime",Kh),n(xf,"typeName","exa.codeium_common_pb.EditorOptions"),n(xf,"fields",Kh.util.newFieldList((()=>[{no:1,name:"tab_size",kind:"scalar",T:4},{no:2,name:"insert_spaces",kind:"scalar",T:8}])));let yf=xf;e=class extends Su{constructor(e){super(),n(this,"eventType",lf.UNSPECIFIED),n(this,"eventJson",""),n(this,"timestampUnixMs",zu.zero),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}},n(e,"runtime",Kh),n(e,"typeName","exa.codeium_common_pb.Event"),n(e,"fields",Kh.util.newFieldList((()=>[{no:1,name:"event_type",kind:"enum",T:Kh.getEnumType(lf)},{no:2,name:"event_json",kind:"scalar",T:9},{no:3,name:"timestamp_unix_ms",kind:"scalar",T:3}])));class bf extends on{constructor(e,t){super(),n(this,"index"),n(this,"total"),this.index=e,this.total=t}toDOM(){const e=document.createElement("span");e.setAttribute("aria-hidden","true"),e.className="cm-codeium-cycle";const t=e.appendChild(document.createElement("span"));t.className="cm-codeium-cycle-explanation",t.innerText=`${this.index+1}/${this.total}`;const n=e.appendChild(document.createElement("button"));return n.className="cm-codeium-cycle-key",n.innerText="→ (Ctrl ])",n.dataset.action="codeium-cycle",e}ignoreEvent(){return!1}}const wf=rn.define({combine:e=>an(e,{language:hf.TYPESCRIPT,timeout:150,widgetClass:bf,alwaysOn:!0},{})}),kf=rn.define({combine:e=>an(e,{override:()=>[]},{})}),Nf=Rt.mark({class:"cm-ghostText"}),Ef=Pt.define({create:e=>null,update(e,t){var n;const o=t.state.facet(wf);for(const r of t.effects){if(r.is(mu)){const{changeSpecs:e,index:t}=r.value,a=e[t].map((e=>Nf.range(e.absoluteStartPos,e.absoluteEndPos))),s=null==(n=a.at(-1))?void 0:n.to;return{index:t,decorations:Rt.set([...a,...void 0!==s&&e.length>1&&o.widgetClass?[Rt.widget({widget:new o.widgetClass(t,e.length),side:1}).range(s)]:[]]),changeSpecs:e,reverseChangeSet:r.value.reverseChangeSet}}if(r.is(pu))return null;if(r.is(gu))return null}return e?{...e,decorations:e.decorations.map(t.changes),reverseChangeSet:e.reverseChangeSet.map(t.changes)}:e},provide:e=>Dt.decorations.from(e,(e=>(null==e?void 0:e.decorations)||Rt.none))}),Cf=sn.define(),jf=sn.define();var Sf,If;function Af(e){const t=Sf[e];return"string"!=typeof t?e.toString():t[0].toLowerCase()+t.substring(1).replace(/[A-Z]/g,(e=>"_"+e.toLowerCase()))}let Mf;(If=Sf||(Sf={}))[If.Canceled=1]="Canceled",If[If.Unknown=2]="Unknown",If[If.InvalidArgument=3]="InvalidArgument",If[If.DeadlineExceeded=4]="DeadlineExceeded",If[If.NotFound=5]="NotFound",If[If.AlreadyExists=6]="AlreadyExists",If[If.PermissionDenied=7]="PermissionDenied",If[If.ResourceExhausted=8]="ResourceExhausted",If[If.FailedPrecondition=9]="FailedPrecondition",If[If.Aborted=10]="Aborted",If[If.OutOfRange=11]="OutOfRange",If[If.Unimplemented=12]="Unimplemented",If[If.Internal=13]="Internal",If[If.Unavailable=14]="Unavailable",If[If.DataLoss=15]="DataLoss",If[If.Unauthenticated=16]="Unauthenticated";class Tf extends Error{constructor(e,t=Sf.Unknown,n,o,r){super(function(e,t){return e.length?`[${Af(t)}] ${e}`:`[${Af(t)}]`}(e,t)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=t,this.metadata=new Headers(null!=n?n:{}),this.details=null!=o?o:[],this.cause=r}static from(e,t=Sf.Unknown){return e instanceof Tf?e:e instanceof Error?"AbortError"==e.name?new Tf(e.message,Sf.Canceled):new Tf(e.message,t,void 0,void 0,e):new Tf(String(e),t,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error&&(Object.getPrototypeOf(e)===Tf.prototype||"ConnectError"===e.name&&"code"in e&&"number"==typeof e.code&&"metadata"in e&&"details"in e&&Array.isArray(e.details)&&"rawMessage"in e&&"string"==typeof e.rawMessage&&"cause"in e)}findDetails(e){const t="typeName"in e?{findMessage:t=>t===e.typeName?e:void 0}:e,n=[];for(const r of this.details){if("getType"in r){t.findMessage(r.getType().typeName)&&n.push(r);continue}const e=t.findMessage(r.type);if(e)try{n.push(e.fromBinary(r.value))}catch(o){}}return n}}var Of=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(n){t[n]=e[n]&&function(t){return new Promise((function(o,r){(function(e,t,n,o){Promise.resolve(o).then((function(t){e({value:t,done:n})}),t)})(o,r,(t=e[n](t)).done,t.value)}))}}},Df=function(e){return this instanceof Df?(this.v=e,this):new Df(e)},_f=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(e,t||[]),a=[];return o={},s("next"),s("throw"),s("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),o[Symbol.asyncIterator]=function(){return this},o;function s(e,t){r[e]&&(o[e]=function(t){return new Promise((function(n,o){a.push([e,t,n,o])>1||i(e,t)}))},t&&(o[e]=t(o[e])))}function i(e,t){try{(n=r[e](t)).value instanceof Df?Promise.resolve(n.value.v).then(l,c):d(a[0][2],n)}catch(o){d(a[0][3],o)}var n}function l(e){i("next",e)}function c(e){i("throw",e)}function d(e,t){e(t),a.shift(),a.length&&i(a[0][0],a[0][1])}};function Pf(e){return _f(this,arguments,(function*(){yield Df(yield*function(e){var t,n;return t={},o("next"),o("throw",(function(e){throw e})),o("return"),t[Symbol.iterator]=function(){return this},t;function o(o,r){t[o]=e[o]?function(t){return(n=!n)?{value:Df(e[o](t)),done:!1}:r?r(t):t}:r}}(Of(e)))}))}var Rf=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(n){t[n]=e[n]&&function(t){return new Promise((function(o,r){(function(e,t,n,o){Promise.resolve(o).then((function(t){e({value:t,done:n})}),t)})(o,r,(t=e[n](t)).done,t.value)}))}}},Ff=function(e){return this instanceof Ff?(this.v=e,this):new Ff(e)},Lf=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(e,t||[]),a=[];return o={},s("next"),s("throw"),s("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),o[Symbol.asyncIterator]=function(){return this},o;function s(e,t){r[e]&&(o[e]=function(t){return new Promise((function(n,o){a.push([e,t,n,o])>1||i(e,t)}))},t&&(o[e]=t(o[e])))}function i(e,t){try{(n=r[e](t)).value instanceof Ff?Promise.resolve(n.value.v).then(l,c):d(a[0][2],n)}catch(o){d(a[0][3],o)}var n}function l(e){i("next",e)}function c(e){i("throw",e)}function d(e,t){e(t),a.shift(),a.length&&i(a[0][0],a[0][1])}};function zf(e,t){const n=function(){var n,o;return Lf(this,arguments,(function*(){const r=yield Ff(e);null===(n=null==t?void 0:t.onHeader)||void 0===n||n.call(t,r.header),yield Ff(yield*function(e){var t,n;return t={},o("next"),o("throw",(function(e){throw e})),o("return"),t[Symbol.iterator]=function(){return this},t;function o(o,r){t[o]=e[o]?function(t){return(n=!n)?{value:Ff(e[o](t)),done:!1}:r?r(t):t}:r}}(Rf(r.message))),null===(o=null==t?void 0:t.onTrailer)||void 0===o||o.call(t,r.trailer)}))}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>n.next()})}}function Bf(e){if(!e.aborted)return;if(void 0!==e.reason)return e.reason;const t=new Error("This operation was aborted");return t.name="AbortError",t}function Uf(){return{get(e){return e.id in this?this[e.id]:e.defaultValue},set(e,t){return this[e.id]=t,this},delete(e){return delete this[e.id],this}}}function Vf(e,t,n){const o="string"==typeof t?t:t.typeName,r="string"==typeof n?n:n.name;return e.toString().replace(/\/?$/,`/${o}/${r}`)}function $f(e,t){return t instanceof e?t:new e(t)}function Gf(e,t){function n(t){return!0===t.done?t:{done:t.done,value:$f(e,t.value)}}return{[Symbol.asyncIterator](){const e=t[Symbol.asyncIterator](),o={next:()=>e.next().then(n)};return void 0!==e.throw&&(o.throw=t=>e.throw(t).then(n)),void 0!==e.return&&(o.return=t=>e.return(t).then(n)),o}}}function Hf(e,t){var n;return null!==(n=null==t?void 0:t.concat().reverse().reduce(((e,t)=>t(e)),e))&&void 0!==n?n:e}function Wf(e){var t;const n=Object.assign({},e);return null!==(t=n.ignoreUnknownFields)&&void 0!==t||(n.ignoreUnknownFields=!0),n}function qf(e,t,n,o){const r=t?Yf(e.I,o):Jf(e.I,n);return{parse:(t?Yf(e.O,o):Jf(e.O,n)).parse,serialize:r.serialize}}function Yf(e,t){return{parse(n){try{return e.fromBinary(n,t)}catch(o){const e=o instanceof Error?o.message:String(o);throw new Tf(`parse binary: ${e}`,Sf.InvalidArgument)}},serialize(e){try{return e.toBinary(t)}catch(n){const e=n instanceof Error?n.message:String(n);throw new Tf(`serialize binary: ${e}`,Sf.Internal)}}}}function Jf(e,t){var n,o;const r=null!==(n=null==t?void 0:t.textEncoder)&&void 0!==n?n:new TextEncoder,a=null!==(o=null==t?void 0:t.textDecoder)&&void 0!==o?o:new TextDecoder,s=Wf(t);return{parse(t){try{const n=a.decode(t);return e.fromJsonString(n,s)}catch(n){throw Tf.from(n,Sf.InvalidArgument)}},serialize(e){try{const t=e.toJsonString(s);return r.encode(t)}catch(t){throw Tf.from(t,Sf.Internal)}}}}const Kf=/^application\/(connect\+)?(?:(json)(?:; ?charset=utf-?8)?|(proto))$/i;function Xf(e,t,n){if(t&&new Headers(t).forEach(((e,t)=>n.metadata.append(t,e))),"object"!=typeof e||null==e||Array.isArray(e)||!("code"in e)||"string"!=typeof e.code)throw n;const o=function(e){if(!Mf){Mf={};for(const e of Object.values(Sf))"string"!=typeof e&&(Mf[Af(e)]=e)}return Mf[e]}(e.code);if(void 0===o)throw n;const r=e.message;if(null!=r&&"string"!=typeof r)throw n;const a=new Tf(null!=r?r:"",o,t);if("details"in e&&Array.isArray(e.details))for(const i of e.details){if(null===i||"object"!=typeof i||Array.isArray(i)||"string"!=typeof i.type||"string"!=typeof i.value||"debug"in i&&"object"!=typeof i.debug)throw n;try{a.details.push({type:i.type,value:eh.dec(i.value),debug:i.debug})}catch(s){throw n}}return a}function Zf(e){const t=new Tf("invalid end stream",Sf.InvalidArgument);let n;try{n=JSON.parse("string"==typeof e?e:(new TextDecoder).decode(e))}catch(r){throw t}if("object"!=typeof n||null==n||Array.isArray(n))throw t;const o=new Headers;if("metadata"in n){if("object"!=typeof n.metadata||null==n.metadata||Array.isArray(n.metadata))throw t;for(const[e,r]of Object.entries(n.metadata)){if(!Array.isArray(r)||r.some((e=>"string"!=typeof e)))throw t;for(const t of r)o.append(e,t)}}return{metadata:o,error:"error"in n?Xf(n.error,o,t):void 0}}const Qf="Content-Type",em="Content-Length",tm="Content-Encoding",nm="Accept-Encoding",om="Connect-Protocol-Version";function rm(e){const t=new Headers,n=new Headers;return e.forEach(((e,o)=>{o.toLowerCase().startsWith("trailer-")?n.set(o.substring(8),e):t.set(o,e)})),[t,n]}function am(e,t,n,o,r){const a=new Headers(null!=o?o:{});return void 0!==n&&a.set("Connect-Timeout-Ms",`${n}`),a.set(Qf,e==Qh.Unary?t?"application/proto":"application/json":t?"application/connect+proto":"application/connect+json"),a.set(om,"1"),a}function sm(e,t,n){const o=function(e){const t=null==e?void 0:e.match(Kf);if(!t)return;return{stream:!!t[1],binary:!!t[3]}}(n.get("Content-Type"));if(200!==t){const r=new Tf(`HTTP ${t}`,function(e){switch(e){case 400:return Sf.InvalidArgument;case 401:return Sf.Unauthenticated;case 403:return Sf.PermissionDenied;case 404:return Sf.Unimplemented;case 408:return Sf.DeadlineExceeded;case 409:return Sf.Aborted;case 412:return Sf.FailedPrecondition;case 413:case 431:return Sf.ResourceExhausted;case 415:return Sf.Internal;case 429:case 502:case 503:case 504:return Sf.Unavailable;default:return Sf.Unknown}}(t),n);if(e==Qh.Unary&&o&&!o.binary)return{isUnaryError:!0,unaryError:r};throw r}return{isUnaryError:!1}}const im="application/";function lm(e,t,n){let o="?connect=v1";const r=e.header.get(Qf);0===(null==r?void 0:r.indexOf(im))&&(o+="&encoding="+encodeURIComponent(r.slice(12)));const a=e.header.get(tm);null!==a&&"identity"!==a&&(o+="&compression="+encodeURIComponent(a),n=!0),n&&(o+="&base64=1"),o+="&message="+function(e,t){return t?eh.enc(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):encodeURIComponent((new TextDecoder).decode(e))}(t,n);const s=e.url+o,i=new Headers(e.header);return[om,Qf,em,tm,nm].forEach((e=>i.delete(e))),Object.assign(Object.assign({},e),{init:Object.assign(Object.assign({},e.init),{method:"GET"}),url:s,header:i})}function cm(e){const{signal:t,cleanup:n}=function(e){const t=new AbortController,n=()=>{t.abort(new Tf("the operation timed out",Sf.DeadlineExceeded))};let o;return void 0!==e&&(e<=0?n():o=setTimeout(n,e)),{signal:t.signal,cleanup:()=>clearTimeout(o)}}(e.timeoutMs),o=function(...e){const t=new AbortController,n=e.filter((e=>void 0!==e)).concat(t.signal);for(const r of n){if(r.aborted){o.apply(r);break}r.addEventListener("abort",o)}function o(){t.signal.aborted||t.abort(Bf(this));for(const e of n)e.removeEventListener("abort",o)}return t}(e.signal,t);return[o.signal,function(e){const r=Tf.from(t.aborted?Bf(t):e);return o.abort(r),n(),Promise.reject(r)},function(){n(),o.abort()}]}var dm,um,hm,fm,mm,pm;(um=dm||(dm={}))[um.UNSPECIFIED=0]="UNSPECIFIED",um[um.INACTIVE=1]="INACTIVE",um[um.PROCESSING=2]="PROCESSING",um[um.SUCCESS=3]="SUCCESS",um[um.WARNING=4]="WARNING",um[um.ERROR=5]="ERROR",Kh.util.setEnumType(dm,"exa.language_server_pb.CodeiumState",[{no:0,name:"CODEIUM_STATE_UNSPECIFIED"},{no:1,name:"CODEIUM_STATE_INACTIVE"},{no:2,name:"CODEIUM_STATE_PROCESSING"},{no:3,name:"CODEIUM_STATE_SUCCESS"},{no:4,name:"CODEIUM_STATE_WARNING"},{no:5,name:"CODEIUM_STATE_ERROR"}]),(fm=hm||(hm={}))[fm.UNSPECIFIED=0]="UNSPECIFIED",fm[fm.SINGLE=1]="SINGLE",fm[fm.MULTI=2]="MULTI",Kh.util.setEnumType(hm,"exa.language_server_pb.LineType",[{no:0,name:"LINE_TYPE_UNSPECIFIED"},{no:1,name:"LINE_TYPE_SINGLE"},{no:2,name:"LINE_TYPE_MULTI"}]),(pm=mm||(mm={}))[pm.UNSPECIFIED=0]="UNSPECIFIED",pm[pm.INLINE=1]="INLINE",pm[pm.BLOCK=2]="BLOCK",pm[pm.INLINE_MASK=3]="INLINE_MASK",Kh.util.setEnumType(mm,"exa.language_server_pb.CompletionPartType",[{no:0,name:"COMPLETION_PART_TYPE_UNSPECIFIED"},{no:1,name:"COMPLETION_PART_TYPE_INLINE"},{no:2,name:"COMPLETION_PART_TYPE_BLOCK"},{no:3,name:"COMPLETION_PART_TYPE_INLINE_MASK"}]);const gm=class e extends Su{constructor(e){super(),n(this,"threshold",0),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(gm,"runtime",Kh),n(gm,"typeName","exa.language_server_pb.MultilineConfig"),n(gm,"fields",Kh.util.newFieldList((()=>[{no:1,name:"threshold",kind:"scalar",T:2}])));let vm=gm;const xm=class e extends Su{constructor(e){super(),n(this,"metadata"),n(this,"document"),n(this,"editorOptions"),n(this,"otherDocuments",[]),n(this,"experimentConfig"),n(this,"modelName",""),n(this,"multilineConfig"),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(xm,"runtime",Kh),n(xm,"typeName","exa.language_server_pb.GetCompletionsRequest"),n(xm,"fields",Kh.util.newFieldList((()=>[{no:1,name:"metadata",kind:"message",T:vf},{no:2,name:"document",kind:"message",T:Dm},{no:3,name:"editor_options",kind:"message",T:yf},{no:5,name:"other_documents",kind:"message",T:Dm,repeated:!0},{no:7,name:"experiment_config",kind:"message",T:Pm},{no:10,name:"model_name",kind:"scalar",T:9},{no:13,name:"multiline_config",kind:"message",T:vm}])));let ym=xm;const bm=class e extends Su{constructor(e){super(),n(this,"state"),n(this,"completionItems",[]),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(bm,"runtime",Kh),n(bm,"typeName","exa.language_server_pb.GetCompletionsResponse"),n(bm,"fields",Kh.util.newFieldList((()=>[{no:1,name:"state",kind:"message",T:Fm},{no:2,name:"completion_items",kind:"message",T:Hm,repeated:!0}])));let wm=bm;const km=class e extends Su{constructor(e){super(),n(this,"metadata"),n(this,"completionId",""),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(km,"runtime",Kh),n(km,"typeName","exa.language_server_pb.AcceptCompletionRequest"),n(km,"fields",Kh.util.newFieldList((()=>[{no:1,name:"metadata",kind:"message",T:vf},{no:2,name:"completion_id",kind:"scalar",T:9}])));let Nm=km;const Em=class e extends Su{constructor(e){super(),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(Em,"runtime",Kh),n(Em,"typeName","exa.language_server_pb.AcceptCompletionResponse"),n(Em,"fields",Kh.util.newFieldList((()=>[])));let Cm=Em;const jm=class e extends Su{constructor(e){super(),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(jm,"runtime",Kh),n(jm,"typeName","exa.language_server_pb.GetAuthTokenRequest"),n(jm,"fields",Kh.util.newFieldList((()=>[])));let Sm=jm;const Im=class e extends Su{constructor(e){super(),n(this,"authToken",""),n(this,"uuid",""),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(Im,"runtime",Kh),n(Im,"typeName","exa.language_server_pb.GetAuthTokenResponse"),n(Im,"fields",Kh.util.newFieldList((()=>[{no:1,name:"auth_token",kind:"scalar",T:9},{no:2,name:"uuid",kind:"scalar",T:9}])));let Am=Im;const Mm=class e extends Su{constructor(e){super(),n(this,"row",zu.zero),n(this,"col",zu.zero),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(Mm,"runtime",Kh),n(Mm,"typeName","exa.language_server_pb.DocumentPosition"),n(Mm,"fields",Kh.util.newFieldList((()=>[{no:1,name:"row",kind:"scalar",T:4},{no:2,name:"col",kind:"scalar",T:4}])));let Tm=Mm;const Om=class e extends Su{constructor(e){super(),n(this,"absolutePath",""),n(this,"relativePath",""),n(this,"text",""),n(this,"editorLanguage",""),n(this,"language",hf.UNSPECIFIED),n(this,"cursorOffset",zu.zero),n(this,"cursorPosition"),n(this,"lineEnding",""),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(Om,"runtime",Kh),n(Om,"typeName","exa.language_server_pb.Document"),n(Om,"fields",Kh.util.newFieldList((()=>[{no:1,name:"absolute_path",kind:"scalar",T:9},{no:2,name:"relative_path",kind:"scalar",T:9},{no:3,name:"text",kind:"scalar",T:9},{no:4,name:"editor_language",kind:"scalar",T:9},{no:5,name:"language",kind:"enum",T:Kh.getEnumType(hf)},{no:6,name:"cursor_offset",kind:"scalar",T:4},{no:8,name:"cursor_position",kind:"message",T:Tm},{no:7,name:"line_ending",kind:"scalar",T:9}])));let Dm=Om;const _m=class e extends Su{constructor(e){super(),n(this,"forceEnableExperiments",[]),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(_m,"runtime",Kh),n(_m,"typeName","exa.language_server_pb.ExperimentConfig"),n(_m,"fields",Kh.util.newFieldList((()=>[{no:1,name:"force_enable_experiments",kind:"enum",T:Kh.getEnumType(of),repeated:!0}])));let Pm=_m;const Rm=class e extends Su{constructor(e){super(),n(this,"state",dm.UNSPECIFIED),n(this,"message",""),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(Rm,"runtime",Kh),n(Rm,"typeName","exa.language_server_pb.State"),n(Rm,"fields",Kh.util.newFieldList((()=>[{no:1,name:"state",kind:"enum",T:Kh.getEnumType(dm)},{no:2,name:"message",kind:"scalar",T:9}])));let Fm=Rm;const Lm=class e extends Su{constructor(e){super(),n(this,"startOffset",zu.zero),n(this,"endOffset",zu.zero),n(this,"startPosition"),n(this,"endPosition"),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(Lm,"runtime",Kh),n(Lm,"typeName","exa.language_server_pb.Range"),n(Lm,"fields",Kh.util.newFieldList((()=>[{no:1,name:"start_offset",kind:"scalar",T:4},{no:2,name:"end_offset",kind:"scalar",T:4},{no:3,name:"start_position",kind:"message",T:Tm},{no:4,name:"end_position",kind:"message",T:Tm}])));let zm=Lm;const Bm=class e extends Su{constructor(e){super(),n(this,"text",""),n(this,"deltaCursorOffset",zu.zero),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(Bm,"runtime",Kh),n(Bm,"typeName","exa.language_server_pb.Suffix"),n(Bm,"fields",Kh.util.newFieldList((()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"delta_cursor_offset",kind:"scalar",T:3}])));let Um=Bm;const Vm=class e extends Su{constructor(e){super(),n(this,"text",""),n(this,"offset",zu.zero),n(this,"type",mm.UNSPECIFIED),n(this,"prefix",""),n(this,"line",zu.zero),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(Vm,"runtime",Kh),n(Vm,"typeName","exa.language_server_pb.CompletionPart"),n(Vm,"fields",Kh.util.newFieldList((()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"offset",kind:"scalar",T:4},{no:3,name:"type",kind:"enum",T:Kh.getEnumType(mm)},{no:4,name:"prefix",kind:"scalar",T:9},{no:5,name:"line",kind:"scalar",T:4}])));let $m=Vm;const Gm=class e extends Su{constructor(e){super(),n(this,"completion"),n(this,"suffix"),n(this,"range"),n(this,"source",df.UNSPECIFIED),n(this,"completionParts",[]),Kh.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return Kh.util.equals(e,t,n)}};n(Gm,"runtime",Kh),n(Gm,"typeName","exa.language_server_pb.CompletionItem"),n(Gm,"fields",Kh.util.newFieldList((()=>[{no:1,name:"completion",kind:"message",T:pf},{no:5,name:"suffix",kind:"message",T:Um},{no:2,name:"range",kind:"message",T:zm},{no:3,name:"source",kind:"enum",T:Kh.getEnumType(df)},{no:8,name:"completion_parts",kind:"message",T:$m,repeated:!0}])));let Hm=Gm;const Wm={typeName:"exa.language_server_pb.LanguageServerService",methods:{getCompletions:{name:"GetCompletions",I:ym,O:wm,kind:Qh.Unary},acceptCompletion:{name:"AcceptCompletion",I:Nm,O:Cm,kind:Qh.Unary},getAuthToken:{name:"GetAuthToken",I:Sm,O:Am,kind:Qh.Unary}}};var qm=function(e){return this instanceof qm?(this.v=e,this):new qm(e)},Ym=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(e,t||[]),a=[];return o={},s("next"),s("throw"),s("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),o[Symbol.asyncIterator]=function(){return this},o;function s(e,t){r[e]&&(o[e]=function(t){return new Promise((function(n,o){a.push([e,t,n,o])>1||i(e,t)}))},t&&(o[e]=t(o[e])))}function i(e,t){try{(n=r[e](t)).value instanceof qm?Promise.resolve(n.value.v).then(l,c):d(a[0][2],n)}catch(o){d(a[0][3],o)}var n}function l(e){i("next",e)}function c(e){i("throw",e)}function d(e,t){e(t),a.shift(),a.length&&i(a[0][0],a[0][1])}};const Jm=function(e){var t;!function(){try{new Headers}catch(e){throw new Error("connect-web requires the fetch API. Are you running on an old version of Node.js? Node.js is not supported in Connect for Web - please stay tuned for Connect for Node.")}}();const n=null!==(t=e.useBinaryFormat)&&void 0!==t&&t;return{async unary(t,o,r,a,s,i,l){var c;const{serialize:d,parse:u}=qf(o,n,e.jsonOptions,e.binaryOptions);return a=void 0===a?e.defaultTimeoutMs:a<=0?void 0:a,await function(e){const t=Hf(e.next,e.interceptors),[n,o,r]=cm(e);return t(Object.assign(Object.assign({},e.req),{message:$f(e.req.method.I,e.req.message),signal:n})).then((e=>(r(),e)),o)}({interceptors:e.interceptors,signal:r,timeoutMs:a,req:{stream:!1,service:t,method:o,url:Vf(e.baseUrl,t,o),init:{method:"POST",credentials:null!==(c=e.credentials)&&void 0!==c?c:"same-origin",redirect:"error",mode:"cors"},header:am(o.kind,n,a,s),contextValues:null!=l?l:Uf(),message:i},next:async r=>{var a;let s=null;!0===e.useHttpGet&&o.idempotency===tf.NoSideEffects?r=lm(r,d(r.message),n):s=d(r.message);const i=null!==(a=e.fetch)&&void 0!==a?a:globalThis.fetch,l=await i(r.url,Object.assign(Object.assign({},r.init),{headers:r.header,signal:r.signal,body:s})),{isUnaryError:c,unaryError:h}=sm(o.kind,l.status,l.headers);if(c)throw Xf(await l.json(),function(...e){const t=new Headers;for(const n of e)n.forEach(((e,n)=>{t.append(n,e)}));return t}(...rm(l.headers)),h);const[f,m]=rm(l.headers);return{stream:!1,service:t,method:o,header:f,message:n?u(new Uint8Array(await l.arrayBuffer())):o.O.fromJson(await l.json(),Wf(e.jsonOptions)),trailer:m}}})},async stream(t,o,r,a,s,i,l){var c;const{serialize:d,parse:u}=qf(o,n,e.jsonOptions,e.binaryOptions);function h(e,t,n){return Ym(this,arguments,(function*(){const o=function(e){let t,n=new Uint8Array(0);function o(e){const t=new Uint8Array(n.length+e.length);t.set(n),t.set(e,n.length),n=t}return new ReadableStream({start(){t=e.getReader()},async pull(e){let r;for(;;){if(void 0===r&&n.byteLength>=5){let e=0;for(let t=1;t<5;t++)e=(e<<8)+n[t];r={flags:n[0],length:e}}if(void 0!==r&&n.byteLength>=r.length+5)break;const e=await t.read();if(e.done)break;o(e.value)}if(void 0===r)return 0==n.byteLength?void e.close():void e.error(new Tf("premature end of stream",Sf.DataLoss));const a=n.subarray(5,5+r.length);n=n.subarray(5+r.length),e.enqueue({flags:r.flags,data:a})}})}(e).getReader();let r=!1;for(;;){const e=yield qm(o.read());if(e.done)break;const{flags:a,data:s}=e.value;if(2&~a)yield yield qm(u(s));else{r=!0;const e=Zf(s);if(e.error){const t=e.error;throw n.forEach(((e,n)=>{t.metadata.append(n,e)})),t}e.metadata.forEach(((e,n)=>t.set(n,e)))}}if(!r)throw"missing EndStreamResponse"}))}async function f(e){if(o.kind!=Qh.ServerStreaming)throw"The fetch API does not support streaming request bodies";const t=await e[Symbol.asyncIterator]().next();if(1==t.done)throw"missing request message";return function(e,t){const n=new Uint8Array(t.length+5);n.set(t,5);const o=new DataView(n.buffer,n.byteOffset,n.byteLength);return o.setUint8(0,e),o.setUint32(1,t.length),n}(0,d(t.value))}return a=void 0===a?e.defaultTimeoutMs:a<=0?void 0:a,await function(e){const t=Hf(e.next,e.interceptors),[n,o,r]=cm(e),a=Object.assign(Object.assign({},e.req),{message:Gf(e.req.method.I,e.req.message),signal:n});let s=!1;return n.addEventListener("abort",(function(){var t,n;const o=e.req.message[Symbol.asyncIterator]();s||null===(t=o.throw)||void 0===t||t.call(o,this.reason).catch((()=>{})),null===(n=o.return)||void 0===n||n.call(o).catch((()=>{}))})),t(a).then((e=>Object.assign(Object.assign({},e),{message:{[Symbol.asyncIterator](){const t=e.message[Symbol.asyncIterator]();return{next:()=>t.next().then((e=>(1==e.done&&(s=!0,r()),e)),o)}}}})),o)}({interceptors:e.interceptors,timeoutMs:a,signal:r,req:{stream:!0,service:t,method:o,url:Vf(e.baseUrl,t,o),init:{method:"POST",credentials:null!==(c=e.credentials)&&void 0!==c?c:"same-origin",redirect:"error",mode:"cors"},header:am(o.kind,n,a,s),contextValues:null!=l?l:Uf(),message:i},next:async t=>{var n;const r=null!==(n=e.fetch)&&void 0!==n?n:globalThis.fetch,a=await r(t.url,Object.assign(Object.assign({},t.init),{headers:t.header,signal:t.signal,body:await f(t.message)}));if(sm(o.kind,a.status,a.headers),null===a.body)throw"missing response body";const s=new Headers;return Object.assign(Object.assign({},t),{header:a.headers,trailer:s,message:h(a.body,s,a.headers)})}})}}}({baseUrl:"https://web-backend.codeium.com",useBinaryFormat:!0}),Km=(Zm=Jm,function(e,t){const n={};for(const[o,r]of Object.entries(e.methods)){const a=t(Object.assign(Object.assign({},r),{localName:o,service:e}));null!=a&&(n[o]=a)}return n}(Xm=Wm,(e=>{switch(e.kind){case Qh.Unary:return function(e,t,n){return async function(o,r){var a,s;const i=await e.unary(t,n,null==r?void 0:r.signal,null==r?void 0:r.timeoutMs,null==r?void 0:r.headers,o,null==r?void 0:r.contextValues);return null===(a=null==r?void 0:r.onHeader)||void 0===a||a.call(r,i.header),null===(s=null==r?void 0:r.onTrailer)||void 0===s||s.call(r,i.trailer),i.message}}(Zm,Xm,e);case Qh.ServerStreaming:return function(e,t,n){return function(o,r){return zf(e.stream(t,n,null==r?void 0:r.signal,null==r?void 0:r.timeoutMs,null==r?void 0:r.headers,Pf([o]),null==r?void 0:r.contextValues),r)}}(Zm,Xm,e);case Qh.ClientStreaming:return function(e,t,n){return async function(o,r){var a,s,i,l,c,d;const u=await e.stream(t,n,null==r?void 0:r.signal,null==r?void 0:r.timeoutMs,null==r?void 0:r.headers,o,null==r?void 0:r.contextValues);let h;null===(c=null==r?void 0:r.onHeader)||void 0===c||c.call(r,u.header);try{for(var f,m=!0,p=Rf(u.message);!(a=(f=await p.next()).done);m=!0)l=f.value,m=!1,h=l}catch(g){s={error:g}}finally{try{m||a||!(i=p.return)||await i.call(p)}finally{if(s)throw s.error}}if(!h)throw new Tf("protocol error: missing response message",Sf.Internal);return null===(d=null==r?void 0:r.onTrailer)||void 0===d||d.call(r,u.trailer),h}}(Zm,Xm,e);case Qh.BiDiStreaming:return function(e,t,n){return function(o,r){return zf(e.stream(t,n,null==r?void 0:r.signal,null==r?void 0:r.timeoutMs,null==r?void 0:r.headers,o,null==r?void 0:r.contextValues),r)}}(Zm,Xm,e);default:return null}})));var Xm,Zm;let Qm;try{Qm=crypto.randomUUID()}catch{Qm=function(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>(+e^(crypto.getRandomValues(new Uint8Array(1))[0]??0)&15>>+e/4).toString(16)))}()}async function ep(e,t){const n=e.state.facet(wf),{override:o}=e.state.facet(kf),r=await o(),a=e.state,s=a.selection.main.head,i=a.doc.toString();try{const o=await async function({text:e,cursorOffset:t,config:n,otherDocuments:o}){return await Km.getCompletions({metadata:{ideName:"web",ideVersion:"0.0.5",extensionName:"@valtown/codemirror-codeium",extensionVersion:"1.0.0",apiKey:n.apiKey,sessionId:Qm,authSource:n.authSource},document:{text:e,cursorOffset:BigInt(t),language:n.language,editorLanguage:"typescript",lineEnding:"\n"},editorOptions:{tabSize:2n,insertSpaces:!0},otherDocuments:o,multilineConfig:void 0},{headers:{Authorization:`Basic ${n.apiKey}-${Qm}`}})}({text:i,cursorOffset:s,config:n,otherDocuments:r});if(!o||0===o.completionItems.length)return;if(void 0!==t&&s!==t||"active"===ln(e.state)||!e.hasFocus)return;const l=o.completionItems.map((e=>{let t=0;return e.completionParts.filter((e=>3!==e.type)).map((e=>{const n=Number(e.offset),o=2===e.type?`\n${e.text}`:e.text,r={absoluteStartPos:t+n,absoluteEndPos:t+n+o.length,from:n,to:n,insert:o};return t+=o.length,r}))})),c=0,d=l.at(c);if(!d)return;const u=cn.of(d,a.doc.length),h=u.invert(a.doc);e.dispatch({changes:u,effects:mu.of({index:c,reverseChangeSet:h,changeSpecs:l}),annotations:[jf.of(null),Cf.of(null),dn.addToHistory.of(!1)]})}catch(l){console.warn("copilot completion failed",l),await new Promise((e=>setTimeout(e,300)))}}function tp(){let e=null,t=0;return Dt.updateListener.of((n=>{const o=n.view.state.facet(wf);if(!o.alwaysOn)return;if(!function(e){return e.docChanged&&!e.transactions.some((e=>e.effects.some((e=>e.is(pu)||e.is(gu)))))}(n))return;if(e&&clearTimeout(e),function(e){if(!e.view.hasFocus)return!0;if(e.state.field(Ef))return!0;if("active"===ln(e.state))return!0;for(const t of e.transactions)if(void 0!==t.annotation(Cf))return!0}(n))return;const r=n.state.selection.main.head;o.shouldComplete&&!o.shouldComplete(new un(n.view.state,r,!1))||(e=setTimeout((async()=>{r===t&&await ep(n.view,t)}),o.timeout),t=r)}))}function np(e){var t;const n=e.state.field(Ef);if(!n)return!1;const o=null==(t=n.reverseChangeSet)?void 0:t.invert(e.state.doc);e.dispatch({changes:n.reverseChangeSet,effects:pu.of(null),annotations:[jf.of(null),Cf.of(null),dn.addToHistory.of(!1)]});let r=0;return null==o||o.iterChangedRanges(((e,t,n,o)=>{r=o})),e.dispatch({changes:o,selection:Ot.cursor(r),annotations:[Cf.of(null),dn.addToHistory.of(!0)]}),!0}const op=e=>{const{state:t}=e,n=t.field(Ef);if(!n)return!1;const{changeSpecs:o}=n;if(o.length<2)return!1;const r=(n.index+1)%o.length,a=o.at(r);if(!a)return!1;const s=n.reverseChangeSet.apply(t.doc),i=cn.of(n.reverseChangeSet,t.doc.length).compose(cn.of(a,s.length)),l=cn.of(a,s.length).invert(s);return e.dispatch({changes:i,effects:mu.of({index:r,reverseChangeSet:l,changeSpecs:o}),annotations:[jf.of(null),Cf.of(null),dn.addToHistory.of(!1)]}),!0};function rp(e){const t=e.state.field(Ef);return!!t&&(e.dispatch({changes:t.reverseChangeSet,effects:gu.of(null),annotations:[jf.of(null),Cf.of(null),dn.addToHistory.of(!1)]}),!1)}function ap(){return Dt.domEventHandlers({keydown:(e,t)=>("]"!==e.key||!e.ctrlKey)&&("Shift"!==e.key&&"Control"!==e.key&&"Alt"!==e.key&&"Meta"!==e.key&&function(e,t){return!!e.state.field(Ef)&&("Tab"===t?np(e):rp(e))}(t,e.key)),mouseup(e,t){const n=e.target;return"BUTTON"===n.nodeName&&"codeium-cycle"===n.dataset.action?(op(t),e.stopPropagation(),e.preventDefault(),!0):function(e){var t,n;let o=!1;const r=null==(t=e.state.selection.asSingle().ranges.at(0))?void 0:t.head,a=e.state.field(Ef);return!(void 0===r||!a)&&(null==(n=a.decorations)||n.between(r,r,(()=>{o=!0})),o)}(t)?np(t):rp(t)}})}const sp=e=>{const t=[];return"codeium"===e.copilot&&e.codeium_api_key&&t.push(function(e){return[wf.of(e),Ef,nn.highest(Qt.of([{key:"Ctrl-]",run:op}])),nn.highest(Dt.updateListener.of((e=>{e.focusChanged&&rp(e.view)}))),nn.high(ap()),tp()]}({apiKey:e.codeium_api_key,language:hf.PYTHON}),kf.of({override:async()=>[{text:Js(""),language:hf.PYTHON,editorLanguage:"python"}]})),"github"===e.copilot&&t.push(fu({delay:500,fetchFn:async e=>{if(!Xs())return"";if(0===e.doc.length)return"";await new Promise((e=>setTimeout(e,20)));const t=e.doc.toString(),n=function(e,t){const n=e.doc.toString(),o=t.split("\n").length-n.split("\n").length,r=function(e,t){const n=e.lineAt(t);return{line:n.number-1,character:t-n.from}}(e.doc,e.selection.main.head);return r.line+=o,{doc:{source:t,tabSize:e.tabSize,indentSize:1,insertSpaces:!0,path:Qs,version:"replace_me",uri:`file://${Qs}`,relativePath:Qs,languageId:ei,position:r}}}(e,Js(t)),o=function(e,t,n){if(0===e.completions.length)return"";const{displayText:o,position:r}=e.completions[0],a=r.character-t.character,s=a<0?o.slice(-a):o,i=n.doc.sliceString(n.selection.main.head,n.doc.length);for(let l=0;l<s.length;l++){const e=s.slice(l);if(i.startsWith(e))return s.slice(0,l)}return s}(await Zs().getCompletion(n),n.doc.position,e);return o&&U.debug("Copilot suggestion:",o),o}})),[...t,Ks().slice(0,-2)]};const ip=Rt.mark({class:"underline"}),lp=_t.define(),cp=_t.define(),dp=Pt.define({create:()=>Rt.none,update(e,t){let n=e.map(t.changes);for(const o of t.effects)o.is(lp)?n=e.update({add:[ip.range(o.value.from,o.value.to)]}):o.is(cp)&&(n=Rt.none);return n},provide:e=>Dt.decorations.from(e)});class up{constructor(e,t){n(this,"view"),n(this,"commandClickMode"),n(this,"hoveredRange"),n(this,"onClick"),n(this,"keydown",(e=>{"Meta"!==e.key&&"Control"!==e.key||(this.commandClickMode=!0,this.view.dom.addEventListener("mousemove",this.mousemove),this.view.dom.addEventListener("click",this.click))})),n(this,"keyup",(e=>{"Meta"!==e.key&&"Control"!==e.key||this.exitCommandClickMode()})),n(this,"windowBlur",(()=>{this.commandClickMode&&this.exitCommandClickMode()})),n(this,"mousemove",(e=>{if(!e.metaKey&&!e.ctrlKey)return void this.exitCommandClickMode();if(!this.commandClickMode)return void this.clearUnderline();const t=this.view.posAtCoords({x:e.clientX,y:e.clientY});if(null==t)return void this.clearUnderline();const n=hn(this.view.state).cursorAt(t);if("VariableName"===n.name){const{from:e,to:o}=n;if(this.hoveredRange&&this.hoveredRange.from===e&&this.hoveredRange.to===o)return;this.clearUnderline(),this.hoveredRange={from:e,to:o,position:t},this.view.dispatch({effects:lp.of(this.hoveredRange)})}else this.clearUnderline()})),n(this,"click",(e=>{if(this.hoveredRange){const t=this.view.state.doc.sliceString(this.hoveredRange.from,this.hoveredRange.to);e.preventDefault(),e.stopPropagation(),this.onClick(this.view,t),this.view.dispatch({selection:{head:this.hoveredRange.position,anchor:this.hoveredRange.position}})}})),this.view=e,this.commandClickMode=!1,this.hoveredRange=null,this.onClick=t,window.addEventListener("keydown",this.keydown),window.addEventListener("keyup",this.keyup),window.addEventListener("blur",this.windowBlur),window.addEventListener("mouseleave",this.windowBlur)}update(e){}destroy(){window.removeEventListener("keydown",this.keydown),window.removeEventListener("keyup",this.keyup),window.removeEventListener("blur",this.windowBlur),window.removeEventListener("mouseleave",this.windowBlur),this.view.dom.removeEventListener("mousemove",this.mousemove),this.view.dom.removeEventListener("click",this.click)}exitCommandClickMode(){this.commandClickMode=!1,this.view.dom.removeEventListener("mousemove",this.mousemove),this.view.dom.removeEventListener("click",this.click),this.clearUnderline()}clearUnderline(){this.hoveredRange&&(this.view.dispatch({effects:cp.of(null)}),this.hoveredRange=null)}}const hp=({variant:e,settings:t,styles:n})=>{const o=Dt.theme({"&":{backgroundColor:t.background,color:t.foreground},".cm-content":{caretColor:t.caret},".cm-cursor, .cm-dropCursor":{borderLeftColor:t.caret},"&.cm-focused .cm-selectionBackgroundm .cm-selectionBackground, .cm-content ::selection":{backgroundColor:t.selection},".cm-activeLine":{backgroundColor:t.lineHighlight},".cm-gutters":{backgroundColor:t.gutterBackground,color:t.gutterForeground},".cm-activeLineGutter":{backgroundColor:t.lineHighlight}},{dark:"dark"===e}),r=mn.define(n);return[o,pn(r)]};hp({variant:"dark",settings:{background:"#200020",foreground:"#D0D0FF",caret:"#7070FF",selection:"#80000080",gutterBackground:"#200020",gutterForeground:"#C080C0",lineHighlight:"#80000040"},styles:[{tag:gn.comment,color:"#404080"},{tag:[gn.string,gn.regexp],color:"#999999"},{tag:gn.number,color:"#7090B0"},{tag:[gn.bool,gn.null],color:"#8080A0"},{tag:[gn.punctuation,gn.derefOperator],color:"#805080"},{tag:gn.keyword,color:"#60B0FF"},{tag:gn.definitionKeyword,color:"#B0FFF0"},{tag:gn.moduleKeyword,color:"#60B0FF"},{tag:gn.operator,color:"#A0A0FF"},{tag:[gn.variableName,gn.self],color:"#008080"},{tag:gn.operatorKeyword,color:"#A0A0FF"},{tag:gn.controlKeyword,color:"#80A0FF"},{tag:gn.className,color:"#70E080"},{tag:[gn.function(gn.propertyName),gn.propertyName],color:"#50A0A0"},{tag:gn.tagName,color:"#009090"},{tag:gn.modifier,color:"#B0FFF0"},{tag:[gn.squareBracket,gn.attributeName],color:"#D0D0FF"}]}),hp({variant:"light",settings:{background:"#fcfcfc",foreground:"#5c6166",caret:"#ffaa33",selection:"#036dd626",gutterBackground:"#fcfcfc",gutterForeground:"#8a919966",lineHighlight:"#8a91991a"},styles:[{tag:gn.comment,color:"#787b8099"},{tag:gn.string,color:"#86b300"},{tag:gn.regexp,color:"#4cbf99"},{tag:[gn.number,gn.bool,gn.null],color:"#ffaa33"},{tag:gn.variableName,color:"#5c6166"},{tag:[gn.definitionKeyword,gn.modifier],color:"#fa8d3e"},{tag:[gn.keyword,gn.special(gn.brace)],color:"#fa8d3e"},{tag:gn.operator,color:"#ed9366"},{tag:gn.separator,color:"#5c6166b3"},{tag:gn.punctuation,color:"#5c6166"},{tag:[gn.definition(gn.propertyName),gn.function(gn.variableName)],color:"#f2ae49"},{tag:[gn.className,gn.definition(gn.typeName)],color:"#22a4e6"},{tag:[gn.tagName,gn.typeName,gn.self,gn.labelName],color:"#55b4d4"},{tag:gn.angleBracket,color:"#55b4d480"},{tag:gn.attributeName,color:"#f2ae49"}]}),hp({variant:"dark",settings:{background:"#15191EFA",foreground:"#EEF2F7",caret:"#C4C4C4",selection:"#90B2D557",gutterBackground:"#15191EFA",gutterForeground:"#aaaaaa95",lineHighlight:"#57575712"},styles:[{tag:gn.comment,color:"#6E6E6E"},{tag:[gn.string,gn.regexp,gn.special(gn.brace)],color:"#5C81B3"},{tag:gn.number,color:"#C1E1B8"},{tag:gn.bool,color:"#53667D"},{tag:[gn.definitionKeyword,gn.modifier,gn.function(gn.propertyName)],color:"#A3D295",fontWeight:"bold"},{tag:[gn.keyword,gn.moduleKeyword,gn.operatorKeyword,gn.operator],color:"#697A8E",fontWeight:"bold"},{tag:[gn.variableName,gn.attributeName],color:"#708E67"},{tag:[gn.function(gn.variableName),gn.definition(gn.propertyName),gn.derefOperator],color:"#fff"},{tag:gn.tagName,color:"#A3D295"}]}),hp({variant:"dark",settings:{background:"#2e241d",foreground:"#BAAE9E",caret:"#A7A7A7",selection:"#DDF0FF33",gutterBackground:"#28211C",gutterForeground:"#BAAE9E90",lineHighlight:"#FFFFFF08"},styles:[{tag:gn.comment,color:"#666666"},{tag:[gn.string,gn.special(gn.brace)],color:"#54BE0D"},{tag:gn.regexp,color:"#E9C062"},{tag:gn.number,color:"#CF6A4C"},{tag:[gn.keyword,gn.operator],color:"#5EA6EA"},{tag:gn.variableName,color:"#7587A6"},{tag:[gn.definitionKeyword,gn.modifier],color:"#F9EE98"},{tag:[gn.propertyName,gn.function(gn.variableName)],color:"#937121"},{tag:[gn.typeName,gn.angleBracket,gn.tagName],color:"#9B859D"}]}),hp({variant:"dark",settings:{background:"#3b2627",foreground:"#E6E1C4",caret:"#E6E1C4",selection:"#16120E",gutterBackground:"#3b2627",gutterForeground:"#E6E1C490",lineHighlight:"#1F1611"},styles:[{tag:gn.comment,color:"#6B4E32"},{tag:[gn.keyword,gn.operator,gn.derefOperator],color:"#EF5D32"},{tag:gn.className,color:"#EFAC32",fontWeight:"bold"},{tag:[gn.typeName,gn.propertyName,gn.function(gn.variableName),gn.definition(gn.variableName)],color:"#EFAC32"},{tag:gn.definition(gn.typeName),color:"#EFAC32",fontWeight:"bold"},{tag:gn.labelName,color:"#EFAC32",fontWeight:"bold"},{tag:[gn.number,gn.bool],color:"#6C99BB"},{tag:[gn.variableName,gn.self],color:"#7DAF9C"},{tag:[gn.string,gn.special(gn.brace),gn.regexp],color:"#D9D762"},{tag:[gn.angleBracket,gn.tagName,gn.attributeName],color:"#EFCB43"}]}),hp({variant:"dark",settings:{background:"#000205",foreground:"#FFFFFF",caret:"#E60065",selection:"#E60C6559",gutterBackground:"#000205",gutterForeground:"#ffffff90",lineHighlight:"#4DD7FC1A"},styles:[{tag:gn.comment,color:"#404040"},{tag:[gn.string,gn.special(gn.brace),gn.regexp],color:"#00D8FF"},{tag:gn.number,color:"#E62286"},{tag:[gn.variableName,gn.attributeName,gn.self],color:"#E62286",fontWeight:"bold"},{tag:gn.function(gn.variableName),color:"#fff",fontWeight:"bold"}]}),hp({variant:"light",settings:{background:"#fff",foreground:"#000",caret:"#000",selection:"#BDD5FC",gutterBackground:"#fff",gutterForeground:"#00000070",lineHighlight:"#FFFBD1"},styles:[{tag:gn.comment,color:"#BCC8BA"},{tag:[gn.string,gn.special(gn.brace),gn.regexp],color:"#5D90CD"},{tag:[gn.number,gn.bool,gn.null],color:"#46A609"},{tag:gn.keyword,color:"#AF956F"},{tag:[gn.definitionKeyword,gn.modifier],color:"#C52727"},{tag:[gn.angleBracket,gn.tagName,gn.attributeName],color:"#606060"},{tag:gn.self,color:"#000"}]}),hp({variant:"dark",settings:{background:"#00254b",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#B36539BF",gutterBackground:"#00254b",gutterForeground:"#FFFFFF70",lineHighlight:"#00000059"},styles:[{tag:gn.comment,color:"#0088FF"},{tag:gn.string,color:"#3AD900"},{tag:gn.regexp,color:"#80FFC2"},{tag:[gn.number,gn.bool,gn.null],color:"#FF628C"},{tag:[gn.definitionKeyword,gn.modifier],color:"#FFEE80"},{tag:gn.variableName,color:"#CCCCCC"},{tag:gn.self,color:"#FF80E1"},{tag:[gn.className,gn.definition(gn.propertyName),gn.function(gn.variableName),gn.definition(gn.typeName),gn.labelName],color:"#FFDD00"},{tag:[gn.keyword,gn.operator],color:"#FF9D00"},{tag:[gn.propertyName,gn.typeName],color:"#80FFBB"},{tag:gn.special(gn.brace),color:"#EDEF7D"},{tag:gn.attributeName,color:"#9EFFFF"},{tag:gn.derefOperator,color:"#fff"}]}),hp({variant:"dark",settings:{background:"#060521",foreground:"#E0E0E0",caret:"#FFFFFFA6",selection:"#122BBB",gutterBackground:"#060521",gutterForeground:"#E0E0E090",lineHighlight:"#FFFFFF0F"},styles:[{tag:gn.comment,color:"#AEAEAE"},{tag:[gn.string,gn.special(gn.brace),gn.regexp],color:"#8DFF8E"},{tag:[gn.className,gn.definition(gn.propertyName),gn.function(gn.variableName),gn.function(gn.definition(gn.variableName)),gn.definition(gn.typeName)],color:"#A3EBFF"},{tag:[gn.number,gn.bool,gn.null],color:"#62E9BD"},{tag:[gn.keyword,gn.operator],color:"#2BF1DC"},{tag:[gn.definitionKeyword,gn.modifier],color:"#F8FBB1"},{tag:[gn.variableName,gn.self],color:"#B683CA"},{tag:[gn.angleBracket,gn.tagName,gn.typeName,gn.propertyName],color:"#60A4F1"},{tag:gn.derefOperator,color:"#E0E0E0"},{tag:gn.attributeName,color:"#7BACCA"}]}),hp({variant:"dark",settings:{background:"#2d2f3f",foreground:"#f8f8f2",caret:"#f8f8f0",selection:"#44475a",gutterBackground:"#282a36",gutterForeground:"rgb(144, 145, 148)",lineHighlight:"#44475a"},styles:[{tag:gn.comment,color:"#6272a4"},{tag:[gn.string,gn.special(gn.brace)],color:"#f1fa8c"},{tag:[gn.number,gn.self,gn.bool,gn.null],color:"#bd93f9"},{tag:[gn.keyword,gn.operator],color:"#ff79c6"},{tag:[gn.definitionKeyword,gn.typeName],color:"#8be9fd"},{tag:gn.definition(gn.typeName),color:"#f8f8f2"},{tag:[gn.className,gn.definition(gn.propertyName),gn.function(gn.variableName),gn.attributeName],color:"#50fa7b"}]}),hp({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#80C7FF",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#C1E2F8"},styles:[{tag:gn.comment,color:"#AAAAAA"},{tag:[gn.keyword,gn.operator,gn.typeName,gn.tagName,gn.propertyName],color:"#2F6F9F",fontWeight:"bold"},{tag:[gn.attributeName,gn.definition(gn.propertyName)],color:"#4F9FD0"},{tag:[gn.className,gn.string,gn.special(gn.brace)],color:"#CF4F5F"},{tag:gn.number,color:"#CF4F5F",fontWeight:"bold"},{tag:gn.variableName,fontWeight:"bold"}]}),hp({variant:"light",settings:{background:"#f2f1f8",foreground:"#0c006b",caret:"#5c49e9",selection:"#d5d1f2",gutterBackground:"#f2f1f8",gutterForeground:"#0c006b70",lineHighlight:"#e1def3"},styles:[{tag:gn.comment,color:"#9995b7"},{tag:gn.keyword,color:"#ff5792",fontWeight:"bold"},{tag:[gn.definitionKeyword,gn.modifier],color:"#ff5792"},{tag:[gn.className,gn.tagName,gn.definition(gn.typeName)],color:"#0094f0"},{tag:[gn.number,gn.bool,gn.null,gn.special(gn.brace)],color:"#5842ff"},{tag:[gn.definition(gn.propertyName),gn.function(gn.variableName)],color:"#0095a8"},{tag:gn.typeName,color:"#b3694d"},{tag:[gn.propertyName,gn.variableName],color:"#fa8900"},{tag:gn.operator,color:"#ff5792"},{tag:gn.self,color:"#e64100"},{tag:[gn.string,gn.regexp],color:"#00b368"},{tag:[gn.paren,gn.bracket],color:"#0431fa"},{tag:gn.labelName,color:"#00bdd6"},{tag:gn.attributeName,color:"#e64100"},{tag:gn.angleBracket,color:"#9995b7"}]}),hp({variant:"light",settings:{background:"#faf4ed",foreground:"#575279",caret:"#575279",selection:"#6e6a8614",gutterBackground:"#faf4ed",gutterForeground:"#57527970",lineHighlight:"#6e6a860d"},styles:[{tag:gn.comment,color:"#9893a5"},{tag:[gn.bool,gn.null],color:"#286983"},{tag:gn.number,color:"#d7827e"},{tag:gn.className,color:"#d7827e"},{tag:[gn.angleBracket,gn.tagName,gn.typeName],color:"#56949f"},{tag:gn.attributeName,color:"#907aa9"},{tag:gn.punctuation,color:"#797593"},{tag:[gn.keyword,gn.modifier],color:"#286983"},{tag:[gn.string,gn.regexp],color:"#ea9d34"},{tag:gn.variableName,color:"#d7827e"}]}),hp({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#FFFD0054",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#00000008"},styles:[{tag:gn.comment,color:"#CFCFCF"},{tag:[gn.number,gn.bool,gn.null],color:"#E66C29"},{tag:[gn.className,gn.definition(gn.propertyName),gn.function(gn.variableName),gn.labelName,gn.definition(gn.typeName)],color:"#2EB43B"},{tag:gn.keyword,color:"#D8B229"},{tag:gn.operator,color:"#4EA44E",fontWeight:"bold"},{tag:[gn.definitionKeyword,gn.modifier],color:"#925A47"},{tag:gn.string,color:"#704D3D"},{tag:gn.typeName,color:"#2F8996"},{tag:[gn.variableName,gn.propertyName],color:"#77ACB0"},{tag:gn.self,color:"#77ACB0",fontWeight:"bold"},{tag:gn.regexp,color:"#E3965E"},{tag:[gn.tagName,gn.angleBracket],color:"#BAA827"},{tag:gn.attributeName,color:"#B06520"},{tag:gn.derefOperator,color:"#000"}]}),hp({variant:"light",settings:{background:"#fef7e5",foreground:"#586E75",caret:"#000000",selection:"#073642",gutterBackground:"#fef7e5",gutterForeground:"#586E7580",lineHighlight:"#EEE8D5"},styles:[{tag:gn.comment,color:"#93A1A1"},{tag:gn.string,color:"#2AA198"},{tag:gn.regexp,color:"#D30102"},{tag:gn.number,color:"#D33682"},{tag:gn.variableName,color:"#268BD2"},{tag:[gn.keyword,gn.operator,gn.punctuation],color:"#859900"},{tag:[gn.definitionKeyword,gn.modifier],color:"#073642",fontWeight:"bold"},{tag:[gn.className,gn.self,gn.definition(gn.propertyName)],color:"#268BD2"},{tag:gn.function(gn.variableName),color:"#268BD2"},{tag:[gn.bool,gn.null],color:"#B58900"},{tag:gn.tagName,color:"#268BD2",fontWeight:"bold"},{tag:gn.angleBracket,color:"#93A1A1"},{tag:gn.attributeName,color:"#93A1A1"},{tag:gn.typeName,color:"#859900"}]}),hp({variant:"light",settings:{background:"#FFFFFF",foreground:"#4D4D4C",caret:"#AEAFAD",selection:"#D6D6D6",gutterBackground:"#FFFFFF",gutterForeground:"#4D4D4C80",lineHighlight:"#EFEFEF"},styles:[{tag:gn.comment,color:"#8E908C"},{tag:[gn.variableName,gn.self,gn.propertyName,gn.attributeName,gn.regexp],color:"#C82829"},{tag:[gn.number,gn.bool,gn.null],color:"#F5871F"},{tag:[gn.className,gn.typeName,gn.definition(gn.typeName)],color:"#C99E00"},{tag:[gn.string,gn.special(gn.brace)],color:"#718C00"},{tag:gn.operator,color:"#3E999F"},{tag:[gn.definition(gn.propertyName),gn.function(gn.variableName)],color:"#4271AE"},{tag:gn.keyword,color:"#8959A8"},{tag:gn.derefOperator,color:"#4D4D4C"}]});const fp=hp({variant:"light",settings:{background:"#ffffff",foreground:"#000000",caret:"#000000",selection:"#d7d4f0",lineHighlight:"#f7f7f7",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:gn.comment,color:"#708090"},{tag:gn.variableName,color:"#000000"},{tag:[gn.string,gn.special(gn.brace)],color:"#a11"},{tag:gn.number,color:"#164"},{tag:gn.bool,color:"#219"},{tag:gn.null,color:"#219"},{tag:gn.keyword,color:"#708",fontWeight:500},{tag:gn.className,color:"#00f"},{tag:gn.definition(gn.typeName),color:"#00f"},{tag:gn.typeName,color:"#085"},{tag:gn.angleBracket,color:"#000000"},{tag:gn.tagName,color:"#170"},{tag:gn.attributeName,color:"#00c"},{tag:gn.operator,color:"#a2f",fontWeight:500},{tag:[gn.function(gn.variableName)],color:"#00c"},{tag:[gn.propertyName],color:"#05a"}]}),mp=e=>{const{theme:t,hotkeys:n,completionConfig:o}=e;return[Dt.lineWrapping,yn(),bn(),wn(),kn(),Nn(),En(),Cn(),jn({position:"fixed",parent:document.querySelector("#App")??void 0}),Sn(),"dark"===t?In:fp,An(),sp(o),Mn(),Tn(),nn.high(Qt.of(On)),Dn(),_n(),Pn.of(" "),pn(Rn,{fallback:!0}),Qt.of(Fn),Ln(e),zn.of(Bn()),Un.allowMultipleSelections.of(!0),ou(n),Qt.of([{key:"Tab",run:e=>Vn(e)||(e=>{const{from:t,to:n}=e.state.selection.main;if(t!==n)return!1;const o=e.state.doc.lineAt(n);return""!==o.text.slice(0,n-o.from).trim()&&Wn(e)})(e)||$n(e),preventDefault:!0}]),Qt.of([...Gn,Hn])]};function pp(e){const t=e.current;if(null===t)throw new ReferenceError("Attempting to dereference null object.");return t}const gp="ContextMenu",[vp,xp]=qn(gp,[Yn]),yp=Yn(),[bp,wp]=vp(gp),kp=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,disabled:o=!1,...a}=e,s=wp("ContextMenuTrigger",n),i=yp(n),l=r.useRef({x:0,y:0}),c=r.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),d=r.useRef(0),u=r.useCallback((()=>window.clearTimeout(d.current)),[]),h=e=>{l.current={x:e.clientX,y:e.clientY},s.onOpenChange(!0)};return r.useEffect((()=>u),[u]),r.useEffect((()=>{o&&u()}),[o,u]),r.createElement(r.Fragment,null,r.createElement(lo,Kn({},i,{virtualRef:c})),r.createElement(co.span,Kn({"data-state":s.open?"open":"closed","data-disabled":o?"":void 0},a,{ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:o?e.onContextMenu:uo(e.onContextMenu,(e=>{u(),h(e),e.preventDefault()})),onPointerDown:o?e.onPointerDown:uo(e.onPointerDown,Np((e=>{u(),d.current=window.setTimeout((()=>h(e)),700)}))),onPointerMove:o?e.onPointerMove:uo(e.onPointerMove,Np(u)),onPointerCancel:o?e.onPointerCancel:uo(e.onPointerCancel,Np(u)),onPointerUp:o?e.onPointerUp:uo(e.onPointerUp,Np(u))})))}));function Np(e){return t=>"mouse"!==t.pointerType?e(t):void 0}const Ep=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=wp("ContextMenuContent",n),s=yp(n),i=r.useRef(!1);return r.createElement(Xn,Kn({},s,o,{ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:t=>{var n;null===(n=e.onCloseAutoFocus)||void 0===n||n.call(e,t),!t.defaultPrevented&&i.current&&t.preventDefault(),i.current=!1},onInteractOutside:t=>{var n;null===(n=e.onInteractOutside)||void 0===n||n.call(e,t),t.defaultPrevented||a.modal||(i.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))})),Cp=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=yp(n);return r.createElement(Zn,Kn({},a,o,{ref:t}))})),jp=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=yp(n);return r.createElement(Qn,Kn({},a,o,{ref:t}))})),Sp=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=yp(n);return r.createElement(eo,Kn({},a,o,{ref:t}))})),Ip=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=yp(n);return r.createElement(to,Kn({},a,o,{ref:t}))})),Ap=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=yp(n);return r.createElement(no,Kn({},a,o,{ref:t}))})),Mp=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=yp(n);return r.createElement(oo,Kn({},a,o,{ref:t}))})),Tp=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=yp(n);return r.createElement(ro,Kn({},a,o,{ref:t}))})),Op=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=yp(n);return r.createElement(ao,Kn({},a,o,{ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))})),Dp=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:o,dir:a,modal:s=!0}=e,[i,l]=r.useState(!1),c=yp(t),d=so(o),u=r.useCallback((e=>{l(e),d(e)}),[d]);return r.createElement(bp,{scope:t,open:i,onOpenChange:u,modal:s},r.createElement(io,Kn({},c,{dir:a,open:i,onOpenChange:u,modal:s}),n))},_p=kp,Pp=ho((e=>{const{__scopeContextMenu:t,...n}=e,o=yp(t);return r.createElement(Jn,Kn({},o,n))}));r.forwardRef((({className:e,inset:t,children:n,...o},r)=>m.jsxs(Tp,{ref:r,className:fo({className:e,inset:t}),...o,children:[n,m.jsx(mo,{className:"ml-auto h-4 w-4"})]}))).displayName=Tp.displayName;const Rp="data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2";r.forwardRef((({className:e,...t},n)=>m.jsx(Op,{ref:n,className:$t(po({subcontent:!0}),Rp,e),...t}))).displayName=Op.displayName;const Fp=r.forwardRef((({className:e,...t},n)=>m.jsx(Pp,{children:m.jsx(go,{children:m.jsx(Ep,{ref:n,className:$t(po(),Rp,e),...t})})})));Fp.displayName=Ep.displayName;const Lp=r.forwardRef((({className:e,inset:t,variant:n,...o},r)=>m.jsx(jp,{ref:r,className:vo({className:e,inset:t,variant:n}),...o})));Lp.displayName=jp.displayName;r.forwardRef((({className:e,children:t,checked:n,...o},r)=>m.jsxs(Sp,{ref:r,className:xo({className:e}),checked:n,...o,children:[m.jsx("span",{className:xo(),children:m.jsx(Ap,{children:m.jsx(yo,{className:"h-4 w-4"})})}),t]}))).displayName=Sp.displayName;r.forwardRef((({className:e,children:t,...n},o)=>m.jsxs(Ip,{ref:o,className:xo({className:e}),...n,children:[m.jsx("span",{className:xo(),children:m.jsx(Ap,{children:m.jsx(bo,{className:"h-4 w-4 fill-current"})})}),t]}))).displayName=Ip.displayName;r.forwardRef((({className:e,inset:t,...n},o)=>m.jsx(Cp,{ref:o,className:wo({className:e,inset:t}),...n}))).displayName=Cp.displayName;const zp=r.forwardRef((({className:e,...t},n)=>m.jsx(Mp,{ref:n,className:$t(ko({className:e})),...t})));zp.displayName=Mp.displayName;const Bp=({appClosed:e,onClick:t,tooltipContent:n})=>m.jsx(Up,{onClick:t,children:m.jsx(p,{content:n,usePortal:!1,children:m.jsx(_s,{onClick:()=>null==t?void 0:t({code:""}),className:$t("shoulder-button hover-action",e&&" inactive-button"),onMouseDown:$e.preventFocus,shape:"circle",size:"small",color:"hint-green","data-testid":"create-cell-button",children:m.jsx(No,{strokeWidth:1.8})})})}),Up=e=>{const{children:t,onClick:n}=e;return n?m.jsxs(Dp,{children:[m.jsx(_p,{children:t}),m.jsxs(Fp,{children:[m.jsxs(Lp,{onSelect:e=>{e.stopPropagation(),n({code:""})},children:[m.jsx("div",{className:"mr-3",children:m.jsx(zs,{})}),"Python cell"]},"python"),m.jsxs(Lp,{onSelect:e=>{e.stopPropagation(),n({code:(new Eo).defaultCode})},children:[m.jsx("div",{className:"mr-3",children:m.jsx(Ls,{})}),"Markdown cell"]},"markdown"),m.jsxs(Lp,{onSelect:e=>{e.stopPropagation(),n({code:(new Co).defaultCode})},children:[m.jsx("div",{className:"mr-3",children:m.jsx(de,{size:13,strokeWidth:1.5})}),"SQL cell"]},"sql")]})]}):t},Vp=jo("rounded-full shadow-xsSolid border p-[5px] transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 [&>svg]:size-3 active:shadow-none bg-background",{variants:{variant:{default:"hover:bg-accent hover:text-accent-foreground",stale:"bg-[var(--yellow-3)] hover:bg-[var(--yellow-4)] text-[var(--yellow-11)]",green:"hover:bg-[var(--grass-2)] hover:text-[var(--grass-11)] hover:border-[var(--grass-7)],",disabled:"opacity-50 cursor-not-allowed",danger:"hover:bg-[var(--red-3)] hover:text-[var(--red-11)]"}},defaultVariants:{variant:"default"}}),$p=({children:e,tooltip:t,disabled:n=!1,variant:o,...r})=>{const a=m.jsx("button",{disabled:n,...r,onClick:e=>{var t;n||null==(t=r.onClick)||t.call(r,e)},onMouseDown:$e.preventFocus,className:$t(Vp({variant:o}),r.className),children:e});return t?m.jsx(p,{content:t,side:"top",delayDuration:200,usePortal:!1,children:a}):a},Gp=({children:e,className:t})=>m.jsx(zc,{className:$t("flex items-center gap-1 bg-background m-[2px] rounded-full",t),children:e});const Hp=e=>{const{onClick:t,appClosed:n,needsRun:o,status:r,config:a,edited:s}=e,i="disabled-transitively"===r,l="running"===r||"queued"===r,c=n||l||!a.disabled&&i&&!s,d=function(e,t,n,o){return e?"disabled":t&&!n?"stale":n||o?"disabled":"green"}(n,o,l,c);if(a.disabled)return m.jsx($p,{tooltip:"Add code to notebook",disabled:c,onClick:t,variant:d,"data-testid":"run-button",children:m.jsx(Yl,{})});if(!a.disabled&&i&&!s)return m.jsx($p,{disabled:c,tooltip:"This cell can't be run because it has a disabled ancestor",onClick:t,variant:d,"data-testid":"run-button",children:m.jsx(uc,{strokeWidth:1.2})});let u="";return u=n?"App disconnected":"queued"===r?"This cell is already queued to run":"running"===r?"This cell is already running.":Ds("cell.run"),m.jsx($p,{tooltip:u,disabled:c,onClick:t,variant:d,"data-testid":"run-button",children:m.jsx(uc,{strokeWidth:1.2})})},Wp=e=>{const{status:t,appClosed:n,onClick:o}=e,r="running"===t||"queued"===t;let a=null;return a=n?"App disconnected":"running"===t?"A cell can't be deleted when it's running":"queued"===t?"A cell can't be deleted when it's queued to run":"Delete",m.jsx(p,{content:a,usePortal:!1,children:m.jsx(b,{variant:"ghost",size:"icon",onClick:o,"data-testid":"delete-button",onMouseDown:$e.preventFocus,className:$t("hover:bg-transparent text-destructive/60 hover:text-destructive",(n||r)&&"inactive-button"),style:{boxShadow:"none"},children:m.jsx(xe,{size:14})})})};const qp=({editing:e,status:t,disabled:n,staleInputs:o,edited:r,interrupted:a,elapsedTime:s,runStartTimestamp:i,uninstantiated:l})=>{if(!e)return null;if(n&&"running"===t)return U.error("CellStatusComponent: disabled and running"),null;if(n&&o)return m.jsx(p,{content:"This cell is stale, but it's disabled and can't be run",usePortal:!1,children:m.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:m.jsxs(Jc,{children:[m.jsx(jl,{className:"h-5 w-5",strokeWidth:1.5}),m.jsx(Io,{className:"h-3 w-3",strokeWidth:2.5})]})})});if(n)return m.jsx(p,{content:"This cell is disabled",usePortal:!1,children:m.jsx("div",{className:"cell-status-icon cell-status-disabled","data-testid":"cell-status","data-status":"disabled",children:m.jsx(jl,{className:"h-5 w-5",strokeWidth:1.5})})});if(!o&&"disabled-transitively"===t)return m.jsx(p,{content:"An ancestor of this cell is disabled, so it can't be run",usePortal:!1,children:m.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"disabled-transitively",children:m.jsxs(Jc,{layerTop:!0,children:[m.jsx(_c,{className:"h-5 w-5",strokeWidth:1.5}),m.jsx(jl,{className:"h-3 w-3",strokeWidth:2.5})]})})});if(o&&"disabled-transitively"===t)return m.jsx(p,{content:"This cell is stale, but an ancestor is disabled so it can't be run",usePortal:!1,children:m.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:m.jsxs(Jc,{children:[m.jsx(Io,{className:"h-5 w-5",strokeWidth:1}),m.jsx(jl,{className:"h-3 w-3",strokeWidth:2.5})]})})});if("running"===t)return m.jsx(p,{content:"This cell is running",usePortal:!1,children:m.jsx("div",{className:"cell-status-icon elapsed-time running","data-testid":"cell-status","data-status":"running",children:m.jsx(Jp,{startTime:So.fromSeconds(i)||So.now()})})});if("queued"===t)return m.jsx(p,{content:"This cell is queued to run",usePortal:!1,children:m.jsx("div",{className:"cell-status-icon cell-status-queued","data-testid":"cell-status","data-status":"queued",children:m.jsx(Ci,{className:"h-5 w-5",strokeWidth:1.5})})});if(r||a||o||l){const e=Yp(s);let t="",n="";return l?t="This cell has not yet been run":a?(t="This cell was interrupted when it was last run",n=`This cell ran for ${e} before being interrupted`):r?(t="This cell has been modified since it was last run",n=`This cell took ${e} to run`):(t="This cell has not been run with the latest inputs",n=`This cell took ${e} to run`),m.jsxs("div",{className:"cell-status-icon flex items-center gap-2",children:[m.jsx(p,{content:t,usePortal:!1,children:m.jsx("div",{className:"cell-status-stale","data-testid":"cell-status","data-status":"outdated",children:m.jsx(Io,{className:"h-5 w-5",strokeWidth:1.5})})}),e&&m.jsx(p,{content:n,usePortal:!1,children:m.jsx("div",{className:"elapsed-time hover-action","data-testid":"cell-status","data-status":"outdated",children:m.jsx("span",{children:e})})})]})}if(null!==s){const e=Yp(s);return m.jsx(p,{content:`This cell took ${e} to run`,usePortal:!1,children:m.jsx("div",{className:"cell-status-icon elapsed-time hover-action","data-testid":"cell-status","data-status":"idle",children:m.jsx("span",{children:e})})})}return null};function Yp(e){if(null===e)return"";if(e>6e4){const t=(e/6e4).toFixed(0),n=(e%6e4/1e3).toFixed(0);return`${t.toString()}m${n.toString()}s`}return e>1e3?`${(e/1e3).toFixed(2).toString()}s`:`${e.toFixed(0).toString()}ms`}const Jp=e=>{const t=function(e){const t=r.useRef(e),[n,o]=r.useState(e);return r.useEffect((()=>{const e=setInterval((()=>{o(So.now().toMilliseconds())}),17);return()=>clearInterval(e)}),[]),n-t.current}(e.startTime.toMilliseconds());return m.jsx("span",{children:Yp(t)})};function Kp(...e){return t=>{e.forEach((e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)}))}}const Xp={display:"none"};function Zp(e){let{id:t,value:n}=e;return u.createElement("div",{id:t,style:Xp},n)}function Qp(e){let{id:t,announcement:n,ariaLiveType:o="assertive"}=e;return u.createElement("div",{id:t,style:{position:"fixed",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":o,"aria-atomic":!0},n)}const eg=r.createContext(null);const tg={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},ng={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function og(e){let{announcements:t=ng,container:n,hiddenTextDescribedById:o,screenReaderInstructions:a=tg}=e;const{announce:s,announcement:i}=function(){const[e,t]=r.useState("");return{announce:r.useCallback((e=>{null!=e&&t(e)}),[]),announcement:e}}(),l=Ii("DndLiveRegion"),[c,d]=r.useState(!1);if(r.useEffect((()=>{d(!0)}),[]),function(e){const t=r.useContext(eg);r.useEffect((()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)}),[e,t])}(r.useMemo((()=>({onDragStart(e){let{active:n}=e;s(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:o}=e;t.onDragMove&&s(t.onDragMove({active:n,over:o}))},onDragOver(e){let{active:n,over:o}=e;s(t.onDragOver({active:n,over:o}))},onDragEnd(e){let{active:n,over:o}=e;s(t.onDragEnd({active:n,over:o}))},onDragCancel(e){let{active:n,over:o}=e;s(t.onDragCancel({active:n,over:o}))}})),[s,t])),!c)return null;const h=u.createElement(u.Fragment,null,u.createElement(Zp,{id:o,value:a.draggable}),u.createElement(Qp,{id:l,announcement:i}));return n?Ao.createPortal(h,n):h}var rg,ag;function sg(){}function ig(e,t){return r.useMemo((()=>({sensor:e,options:null!=t?t:{}})),[e,t])}(ag=rg||(rg={})).DragStart="dragStart",ag.DragMove="dragMove",ag.DragEnd="dragEnd",ag.DragCancel="dragCancel",ag.DragOver="dragOver",ag.RegisterDroppable="registerDroppable",ag.SetDroppableDisabled="setDroppableDisabled",ag.UnregisterDroppable="unregisterDroppable";const lg=Object.freeze({x:0,y:0});function cg(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function dg(e,t){let{data:{value:n}}=e,{data:{value:o}}=t;return n-o}function ug(e,t){let{data:{value:n}}=e,{data:{value:o}}=t;return o-n}function hg(e){let{left:t,top:n,height:o,width:r}=e;return[{x:t,y:n},{x:t+r,y:n},{x:t,y:n+o},{x:t+r,y:n+o}]}function fg(e,t){if(!e||0===e.length)return null;const[n]=e;return t?n[t]:n}function mg(e,t,n){return void 0===t&&(t=e.left),void 0===n&&(n=e.top),{x:t+.5*e.width,y:n+.5*e.height}}const pg=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:o}=e;const r=mg(t,t.left,t.top),a=[];for(const s of o){const{id:e}=s,t=n.get(e);if(t){const n=cg(mg(t),r);a.push({id:e,data:{droppableContainer:s,value:n}})}}return a.sort(dg)};function gg(e,t){const n=Math.max(t.top,e.top),o=Math.max(t.left,e.left),r=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),s=r-o,i=a-n;if(o<r&&n<a){const n=t.width*t.height,o=e.width*e.height,r=s*i;return Number((r/(n+o-r)).toFixed(4))}return 0}const vg=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:o}=e;const r=[];for(const a of o){const{id:e}=a,o=n.get(e);if(o){const n=gg(o,t);n>0&&r.push({id:e,data:{droppableContainer:a,value:n}})}}return r.sort(ug)};function xg(e,t){const{top:n,left:o,bottom:r,right:a}=t;return n<=e.y&&e.y<=r&&o<=e.x&&e.x<=a}function yg(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:lg}function bg(e){return function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return o.reduce(((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x})),{...t})}}const wg=bg(1);const kg={ignoreTransform:!1};function Ng(e,t){void 0===t&&(t=kg);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:o}=ji(e).getComputedStyle(e);t&&(n=function(e,t,n){const o=function(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}(t);if(!o)return e;const{scaleX:r,scaleY:a,x:s,y:i}=o,l=e.left-s-(1-r)*parseFloat(n),c=e.top-i-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),d=r?e.width/r:e.width,u=a?e.height/a:e.height;return{width:d,height:u,top:c,right:l+d,bottom:c+u,left:l}}(n,t,o))}const{top:o,left:r,width:a,height:s,bottom:i,right:l}=n;return{top:o,left:r,width:a,height:s,bottom:i,right:l}}function Eg(e){return Ng(e,{ignoreTransform:!0})}function Cg(e,t){const n=[];return e?function o(r){if(null!=t&&n.length>=t)return n;if(!r)return n;if(Gi(r)&&null!=r.scrollingElement&&!n.includes(r.scrollingElement))return n.push(r.scrollingElement),n;if(!zi(r)||Wi(r))return n;if(n.includes(r))return n;const a=ji(e).getComputedStyle(r);return r!==e&&function(e,t){void 0===t&&(t=ji(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some((e=>{const o=t[e];return"string"==typeof o&&n.test(o)}))}(r,a)&&n.push(r),function(e,t){return void 0===t&&(t=ji(e).getComputedStyle(e)),"fixed"===t.position}(r,a)?n:o(r.parentNode)}(e):n}function jg(e){const[t]=Cg(e,1);return null!=t?t:null}function Sg(e){return Li&&e?Vi(e)?e:$i(e)?Gi(e)||e===Oi(e).scrollingElement?window:zi(e)?e:null:null:null}function Ig(e){return Vi(e)?e.scrollX:e.scrollLeft}function Ag(e){return Vi(e)?e.scrollY:e.scrollTop}function Mg(e){return{x:Ig(e),y:Ag(e)}}var Tg,Og;function Dg(e){return!(!Li||!e)&&e===document.scrollingElement}function _g(e){const t={x:0,y:0},n=Dg(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=o.y,isRight:e.scrollLeft>=o.x,maxScroll:o,minScroll:t}}(Og=Tg||(Tg={}))[Og.Forward=1]="Forward",Og[Og.Backward=-1]="Backward";const Pg={x:.2,y:.2};function Rg(e,t,n,o,r){let{top:a,left:s,right:i,bottom:l}=n;void 0===o&&(o=10),void 0===r&&(r=Pg);const{isTop:c,isBottom:d,isLeft:u,isRight:h}=_g(e),f={x:0,y:0},m={x:0,y:0},p=t.height*r.y,g=t.width*r.x;return!c&&a<=t.top+p?(f.y=Tg.Backward,m.y=o*Math.abs((t.top+p-a)/p)):!d&&l>=t.bottom-p&&(f.y=Tg.Forward,m.y=o*Math.abs((t.bottom-p-l)/p)),!h&&i>=t.right-g?(f.x=Tg.Forward,m.x=o*Math.abs((t.right-g-i)/g)):!u&&s<=t.left+g&&(f.x=Tg.Backward,m.x=o*Math.abs((t.left+g-s)/g)),{direction:f,speed:m}}function Fg(e){if(e===document.scrollingElement){const{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}const{top:t,left:n,right:o,bottom:r}=e.getBoundingClientRect();return{top:t,left:n,right:o,bottom:r,width:e.clientWidth,height:e.clientHeight}}function Lg(e){return e.reduce(((e,t)=>Mi(e,Mg(t))),lg)}const zg=[["x",["left","right"],function(e){return e.reduce(((e,t)=>e+Ig(t)),0)}],["y",["top","bottom"],function(e){return e.reduce(((e,t)=>e+Ag(t)),0)}]];class Bg{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=Cg(t),o=Lg(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[r,a,s]of zg)for(const e of a)Object.defineProperty(this,e,{get:()=>{const t=s(n),a=o[r]-t;return this.rect[e]+a},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ug{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach((e=>{var t;return null==(t=this.target)?void 0:t.removeEventListener(...e)}))},this.target=e}add(e,t,n){var o;null==(o=this.target)||o.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function Vg(e,t){const n=Math.abs(e.x),o=Math.abs(e.y);return"number"==typeof t?Math.sqrt(n**2+o**2)>t:"x"in t&&"y"in t?n>t.x&&o>t.y:"x"in t?n>t.x:"y"in t&&o>t.y}var $g,Gg,Hg,Wg;function qg(e){e.preventDefault()}function Yg(e){e.stopPropagation()}(Gg=$g||($g={})).Click="click",Gg.DragStart="dragstart",Gg.Keydown="keydown",Gg.ContextMenu="contextmenu",Gg.Resize="resize",Gg.SelectionChange="selectionchange",Gg.VisibilityChange="visibilitychange",(Wg=Hg||(Hg={})).Space="Space",Wg.Down="ArrowDown",Wg.Right="ArrowRight",Wg.Left="ArrowLeft",Wg.Up="ArrowUp",Wg.Esc="Escape",Wg.Enter="Enter";const Jg={start:[Hg.Space,Hg.Enter],cancel:[Hg.Esc],end:[Hg.Space,Hg.Enter]},Kg=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Hg.Right:return{...n,x:n.x+25};case Hg.Left:return{...n,x:n.x-25};case Hg.Down:return{...n,y:n.y+25};case Hg.Up:return{...n,y:n.y-25}}};class Xg{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:t}}=e;this.props=e,this.listeners=new Ug(Oi(t)),this.windowListeners=new Ug(ji(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add($g.Resize,this.handleCancel),this.windowListeners.add($g.VisibilityChange,this.handleCancel),setTimeout((()=>this.listeners.add($g.Keydown,this.handleKeyDown)))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&function(e,t){if(void 0===t&&(t=Ng),!e)return;const{top:n,left:o,bottom:r,right:a}=t(e);jg(e)&&(r<=0||a<=0||n>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}(n),t(lg)}handleKeyDown(e){if(Di(e)){const{active:t,context:n,options:o}=this.props,{keyboardCodes:r=Jg,coordinateGetter:a=Kg,scrollBehavior:s="smooth"}=o,{code:i}=e;if(r.end.includes(i))return void this.handleEnd(e);if(r.cancel.includes(i))return void this.handleCancel(e);const{collisionRect:l}=n.current,c=l?{x:l.left,y:l.top}:lg;this.referenceCoordinates||(this.referenceCoordinates=c);const d=a(e,{active:t,context:n.current,currentCoordinates:c});if(d){const t=_i(d,c),o={x:0,y:0},{scrollableAncestors:r}=n.current;for(const n of r){const r=e.code,{isTop:a,isRight:i,isLeft:l,isBottom:c,maxScroll:u,minScroll:h}=_g(n),f=Fg(n),m={x:Math.min(r===Hg.Right?f.right-f.width/2:f.right,Math.max(r===Hg.Right?f.left:f.left+f.width/2,d.x)),y:Math.min(r===Hg.Down?f.bottom-f.height/2:f.bottom,Math.max(r===Hg.Down?f.top:f.top+f.height/2,d.y))},p=r===Hg.Right&&!i||r===Hg.Left&&!l,g=r===Hg.Down&&!c||r===Hg.Up&&!a;if(p&&m.x!==d.x){const e=n.scrollLeft+t.x,a=r===Hg.Right&&e<=u.x||r===Hg.Left&&e>=h.x;if(a&&!t.y)return void n.scrollTo({left:e,behavior:s});o.x=a?n.scrollLeft-e:r===Hg.Right?n.scrollLeft-u.x:n.scrollLeft-h.x,o.x&&n.scrollBy({left:-o.x,behavior:s});break}if(g&&m.y!==d.y){const e=n.scrollTop+t.y,a=r===Hg.Down&&e<=u.y||r===Hg.Up&&e>=h.y;if(a&&!t.x)return void n.scrollTo({top:e,behavior:s});o.y=a?n.scrollTop-e:r===Hg.Down?n.scrollTop-u.y:n.scrollTop-h.y,o.y&&n.scrollBy({top:-o.y,behavior:s});break}}this.handleMove(e,Mi(_i(d,this.referenceCoordinates),o))}}}handleMove(e,t){const{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){const{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){const{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function Zg(e){return Boolean(e&&"distance"in e)}function Qg(e){return Boolean(e&&"delay"in e)}Xg.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:o=Jg,onActivation:r}=t,{active:a}=n;const{code:s}=e.nativeEvent;if(o.start.includes(s)){const t=a.activatorNode.current;return(!t||e.target===t)&&(e.preventDefault(),null==r||r({event:e.nativeEvent}),!0)}return!1}}];class ev{constructor(e,t,n){var o;void 0===n&&(n=function(e){const{EventTarget:t}=ji(e);return e instanceof t?e:Oi(e)}(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;const{event:r}=e,{target:a}=r;this.props=e,this.events=t,this.document=Oi(a),this.documentListeners=new Ug(this.document),this.listeners=new Ug(n),this.windowListeners=new Ug(ji(a)),this.initialCoordinates=null!=(o=Ai(r))?o:lg,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),this.windowListeners.add($g.Resize,this.handleCancel),this.windowListeners.add($g.DragStart,qg),this.windowListeners.add($g.VisibilityChange,this.handleCancel),this.windowListeners.add($g.ContextMenu,qg),this.documentListeners.add($g.Keydown,this.handleKeydown),t){if(null!=n&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Qg(t))return void(this.timeoutId=setTimeout(this.handleStart,t.delay));if(Zg(t))return}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add($g.Click,Yg,{capture:!0}),this.removeTextSelection(),this.documentListeners.add($g.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:o,props:r}=this,{onMove:a,options:{activationConstraint:s}}=r;if(!o)return;const i=null!=(t=Ai(e))?t:lg,l=_i(o,i);if(!n&&s){if(Zg(s)){if(null!=s.tolerance&&Vg(l,s.tolerance))return this.handleCancel();if(Vg(l,s.distance))return this.handleStart()}return Qg(s)&&Vg(l,s.tolerance)?this.handleCancel():void 0}e.cancelable&&e.preventDefault(),a(i)}handleEnd(){const{onEnd:e}=this.props;this.detach(),e()}handleCancel(){const{onCancel:e}=this.props;this.detach(),e()}handleKeydown(e){e.code===Hg.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const tv={move:{name:"pointermove"},end:{name:"pointerup"}};class nv extends ev{constructor(e){const{event:t}=e,n=Oi(t.target);super(e,tv,n)}}nv.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;return!(!n.isPrimary||0!==n.button)&&(null==o||o({event:n}),!0)}}];const ov={move:{name:"mousemove"},end:{name:"mouseup"}};var rv,av;(av=rv||(rv={}))[av.RightClick=2]="RightClick";(class extends ev{constructor(e){super(e,ov,Oi(e.event.target))}}).activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;return n.button!==rv.RightClick&&(null==o||o({event:n}),!0)}}];const sv={move:{name:"touchmove"},end:{name:"touchend"}};var iv,lv,cv,dv;function uv(e){let{acceleration:t,activator:n=iv.Pointer,canScroll:o,draggingRect:a,enabled:s,interval:i=5,order:l=cv.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:u,delta:h,threshold:f}=e;const m=function(e){let{delta:t,disabled:n}=e;const o=Ri(t);return Fi((e=>{if(n||!o||!e)return hv;const r={x:Math.sign(t.x-o.x),y:Math.sign(t.y-o.y)};return{x:{[Tg.Backward]:e.x[Tg.Backward]||-1===r.x,[Tg.Forward]:e.x[Tg.Forward]||1===r.x},y:{[Tg.Backward]:e.y[Tg.Backward]||-1===r.y,[Tg.Forward]:e.y[Tg.Forward]||1===r.y}}}),[n,t,o])}({delta:h,disabled:!s}),[p,g]=Pi(),v=r.useRef({x:0,y:0}),x=r.useRef({x:0,y:0}),y=r.useMemo((()=>{switch(n){case iv.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case iv.DraggableRect:return a}}),[n,a,c]),b=r.useRef(null),w=r.useCallback((()=>{const e=b.current;if(!e)return;const t=v.current.x*x.current.x,n=v.current.y*x.current.y;e.scrollBy(t,n)}),[]),k=r.useMemo((()=>l===cv.TreeOrder?[...d].reverse():d),[l,d]);r.useEffect((()=>{if(s&&d.length&&y){for(const e of k){if(!1===(null==o?void 0:o(e)))continue;const n=d.indexOf(e),r=u[n];if(!r)continue;const{direction:a,speed:s}=Rg(e,r,y,t,f);for(const e of["x","y"])m[e][a[e]]||(s[e]=0,a[e]=0);if(s.x>0||s.y>0)return g(),b.current=e,p(w,i),v.current=s,void(x.current=a)}v.current={x:0,y:0},x.current={x:0,y:0},g()}else g()}),[t,w,o,g,s,i,JSON.stringify(y),JSON.stringify(m),p,d,k,u,JSON.stringify(f)])}(class extends ev{constructor(e){super(e,sv)}static setup(){return window.addEventListener(sv.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(sv.move.name,e)};function e(){}}}).activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;const{touches:r}=n;return!(r.length>1)&&(null==o||o({event:n}),!0)}}],(lv=iv||(iv={}))[lv.Pointer=0]="Pointer",lv[lv.DraggableRect=1]="DraggableRect",(dv=cv||(cv={}))[dv.TreeOrder=0]="TreeOrder",dv[dv.ReversedTreeOrder=1]="ReversedTreeOrder";const hv={x:{[Tg.Backward]:!1,[Tg.Forward]:!1},y:{[Tg.Backward]:!1,[Tg.Forward]:!1}};var fv,mv,pv;(mv=fv||(fv={}))[mv.Always=0]="Always",mv[mv.BeforeDragging=1]="BeforeDragging",mv[mv.WhileDragging=2]="WhileDragging",(pv||(pv={})).Optimized="optimized";const gv=new Map;function vv(e,t){return Fi((n=>e?n||("function"==typeof t?t(e):e):null),[t,e])}function xv(e){let{callback:t,disabled:n}=e;const o=Hi(t),a=r.useMemo((()=>{if(n||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(o)}),[n]);return r.useEffect((()=>()=>null==a?void 0:a.disconnect()),[a]),a}function yv(e){return new Bg(Ng(e),e)}function bv(e,t,n){void 0===t&&(t=yv);const[o,a]=r.useReducer((function(o){if(!e)return null;var r;if(!1===e.isConnected)return null!=(r=null!=o?o:n)?r:null;const a=t(e);if(JSON.stringify(o)===JSON.stringify(a))return o;return a}),null),s=function(e){let{callback:t,disabled:n}=e;const o=Hi(t),a=r.useMemo((()=>{if(n||"undefined"==typeof window||void 0===window.MutationObserver)return;const{MutationObserver:e}=window;return new e(o)}),[o,n]);return r.useEffect((()=>()=>null==a?void 0:a.disconnect()),[a]),a}({callback(t){if(e)for(const n of t){const{type:t,target:o}=n;if("childList"===t&&o instanceof HTMLElement&&o.contains(e)){a();break}}}}),i=xv({callback:a});return Ti((()=>{a(),e?(null==i||i.observe(e),null==s||s.observe(document.body,{childList:!0,subtree:!0})):(null==i||i.disconnect(),null==s||s.disconnect())}),[e]),o}const wv=[];function kv(e,t){void 0===t&&(t=[]);const n=r.useRef(null);return r.useEffect((()=>{n.current=null}),t),r.useEffect((()=>{const t=e!==lg;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)}),[e]),n.current?_i(e,n.current):lg}function Nv(e){return r.useMemo((()=>e?function(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}(e):null),[e])}const Ev=[];function Cv(e){let{measure:t}=e;const[n,o]=r.useState(null),a=xv({callback:r.useCallback((e=>{for(const{target:n}of e)if(zi(n)){o((e=>{const o=t(n);return e?{...e,width:o.width,height:o.height}:o}));break}}),[t])}),s=r.useCallback((e=>{const n=function(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return zi(t)?t:e}(e);null==a||a.disconnect(),n&&(null==a||a.observe(n)),o(n?t(n):null)}),[t,a]),[i,l]=Bi(s);return r.useMemo((()=>({nodeRef:i,rect:n,setRef:l})),[n,i,l])}const jv=[{sensor:nv,options:{}},{sensor:Xg,options:{}}],Sv={current:{}},Iv={draggable:{measure:Eg},droppable:{measure:Eg,strategy:fv.WhileDragging,frequency:pv.Optimized},dragOverlay:{measure:Ng}};class Av extends Map{get(e){var t;return null!=e&&null!=(t=super.get(e))?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter((e=>{let{disabled:t}=e;return!t}))}getNodeFor(e){var t,n;return null!=(t=null==(n=this.get(e))?void 0:n.node.current)?t:void 0}}const Mv={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Av,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:sg},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Iv,measureDroppableContainers:sg,windowRect:null,measuringScheduled:!1},Tv={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:sg,draggableNodes:new Map,over:null,measureDroppableContainers:sg},Ov=r.createContext(Tv),Dv=r.createContext(Mv);function _v(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Av}}}function Pv(e,t){switch(t.type){case rg.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case rg.DragMove:return e.draggable.active?{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}}:e;case rg.DragEnd:case rg.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case rg.RegisterDroppable:{const{element:n}=t,{id:o}=n,r=new Av(e.droppable.containers);return r.set(o,n),{...e,droppable:{...e.droppable,containers:r}}}case rg.SetDroppableDisabled:{const{id:n,key:o,disabled:r}=t,a=e.droppable.containers.get(n);if(!a||o!==a.key)return e;const s=new Av(e.droppable.containers);return s.set(n,{...a,disabled:r}),{...e,droppable:{...e.droppable,containers:s}}}case rg.UnregisterDroppable:{const{id:n,key:o}=t,r=e.droppable.containers.get(n);if(!r||o!==r.key)return e;const a=new Av(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Rv(e){let{disabled:t}=e;const{active:n,activatorEvent:o,draggableNodes:a}=r.useContext(Ov),s=Ri(o),i=Ri(null==n?void 0:n.id);return r.useEffect((()=>{if(!t&&!o&&s&&null!=i){if(!Di(s))return;if(document.activeElement===s.target)return;const e=a.get(i);if(!e)return;const{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame((()=>{for(const e of[t.current,n.current]){if(!e)continue;const t=Ui(e);if(t){t.focus();break}}}))}}),[o,t,a,i,s]),null}const Fv=r.createContext({...lg,scaleX:1,scaleY:1});var Lv,zv;(zv=Lv||(Lv={}))[zv.Uninitialized=0]="Uninitialized",zv[zv.Initializing=1]="Initializing",zv[zv.Initialized=2]="Initialized";const Bv=r.memo((function(e){var t,n,o,a;let{id:s,accessibility:i,autoScroll:l=!0,children:c,sensors:d=jv,collisionDetection:h=vg,measuring:f,modifiers:m,...p}=e;const g=r.useReducer(Pv,void 0,_v),[v,x]=g,[y,b]=function(){const[e]=r.useState((()=>new Set)),t=r.useCallback((t=>(e.add(t),()=>e.delete(t))),[e]);return[r.useCallback((t=>{let{type:n,event:o}=t;e.forEach((e=>{var t;return null==(t=e[n])?void 0:t.call(e,o)}))}),[e]),t]}(),[w,k]=r.useState(Lv.Uninitialized),N=w===Lv.Initialized,{draggable:{active:E,nodes:C,translate:j},droppable:{containers:S}}=v,I=E?C.get(E):null,A=r.useRef({initial:null,translated:null}),M=r.useMemo((()=>{var e;return null!=E?{id:E,data:null!=(e=null==I?void 0:I.data)?e:Sv,rect:A}:null}),[E,I]),T=r.useRef(null),[O,D]=r.useState(null),[_,P]=r.useState(null),R=Si(p,Object.values(p)),F=Ii("DndDescribedBy",s),L=r.useMemo((()=>S.getEnabled()),[S]),z=(B=f,r.useMemo((()=>({draggable:{...Iv.draggable,...null==B?void 0:B.draggable},droppable:{...Iv.droppable,...null==B?void 0:B.droppable},dragOverlay:{...Iv.dragOverlay,...null==B?void 0:B.dragOverlay}})),[null==B?void 0:B.draggable,null==B?void 0:B.droppable,null==B?void 0:B.dragOverlay]));var B;const{droppableRects:U,measureDroppableContainers:V,measuringScheduled:$}=function(e,t){let{dragging:n,dependencies:o,config:a}=t;const[s,i]=r.useState(null),{frequency:l,measure:c,strategy:d}=a,u=r.useRef(e),h=function(){switch(d){case fv.Always:return!1;case fv.BeforeDragging:return n;default:return!n}}(),f=Si(h),m=r.useCallback((function(e){void 0===e&&(e=[]),f.current||i((t=>null===t?e:t.concat(e.filter((e=>!t.includes(e))))))}),[f]),p=r.useRef(null),g=Fi((t=>{if(h&&!n)return gv;if(!t||t===gv||u.current!==e||null!=s){const t=new Map;for(let n of e){if(!n)continue;if(s&&s.length>0&&!s.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}const e=n.node.current,o=e?new Bg(c(e),e):null;n.rect.current=o,o&&t.set(n.id,o)}return t}return t}),[e,s,n,h,c]);return r.useEffect((()=>{u.current=e}),[e]),r.useEffect((()=>{h||m()}),[n,h]),r.useEffect((()=>{s&&s.length>0&&i(null)}),[JSON.stringify(s)]),r.useEffect((()=>{h||"number"!=typeof l||null!==p.current||(p.current=setTimeout((()=>{m(),p.current=null}),l))}),[l,h,m,...o]),{droppableRects:g,measureDroppableContainers:m,measuringScheduled:null!=s}}(L,{dragging:N,dependencies:[j.x,j.y],config:z.droppable}),G=function(e,t){const n=null!==t?e.get(t):void 0,o=n?n.node.current:null;return Fi((e=>{var n;return null===t?null:null!=(n=null!=o?o:e)?n:null}),[o,t])}(C,E),H=r.useMemo((()=>_?Ai(_):null),[_]),W=function(){const e=!1===(null==O?void 0:O.autoScrollEnabled),t="object"==typeof l?!1===l.enabled:!1===l,n=N&&!e&&!t;if("object"==typeof l)return{...l,enabled:n};return{enabled:n}}(),q=function(e,t){return vv(e,t)}(G,z.draggable.measure);!function(e){let{activeNode:t,measure:n,initialRect:o,config:a=!0}=e;const s=r.useRef(!1),{x:i,y:l}="boolean"==typeof a?{x:a,y:a}:a;Ti((()=>{if(!i&&!l||!t)return void(s.current=!1);if(s.current||!o)return;const e=null==t?void 0:t.node.current;if(!e||!1===e.isConnected)return;const r=yg(n(e),o);if(i||(r.x=0),l||(r.y=0),s.current=!0,Math.abs(r.x)>0||Math.abs(r.y)>0){const t=jg(e);t&&t.scrollBy({top:r.y,left:r.x})}}),[t,i,l,o,n])}({activeNode:E?C.get(E):null,config:W.layoutShiftCompensation,initialRect:q,measure:z.draggable.measure});const Y=bv(G,z.draggable.measure,q),J=bv(G?G.parentElement:null),K=r.useRef({activatorEvent:null,active:null,activeNode:G,collisionRect:null,collisions:null,droppableRects:U,draggableNodes:C,draggingNode:null,draggingNodeRect:null,droppableContainers:S,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),X=S.getNodeFor(null==(t=K.current.over)?void 0:t.id),Z=Cv({measure:z.dragOverlay.measure}),Q=null!=(n=Z.nodeRef.current)?n:G,ee=N?null!=(o=Z.rect)?o:Y:null,te=Boolean(Z.nodeRef.current&&Z.rect),ne=yg(oe=te?null:Y,vv(oe));var oe;const re=Nv(Q?ji(Q):null),ae=function(e){const t=r.useRef(e),n=Fi((n=>e?n&&n!==wv&&e&&t.current&&e.parentNode===t.current.parentNode?n:Cg(e):wv),[e]);return r.useEffect((()=>{t.current=e}),[e]),n}(N?null!=X?X:G:null),se=function(e,t){void 0===t&&(t=Ng);const[n]=e,o=Nv(n?ji(n):null),[a,s]=r.useReducer((function(){return e.length?e.map((e=>Dg(e)?o:new Bg(t(e),e))):Ev}),Ev),i=xv({callback:s});return e.length>0&&a===Ev&&s(),Ti((()=>{e.length?e.forEach((e=>null==i?void 0:i.observe(e))):(null==i||i.disconnect(),s())}),[e]),a}(ae),ie=function(e,t){let{transform:n,...o}=t;return null!=e&&e.length?e.reduce(((e,t)=>t({transform:e,...o})),n):n}(m,{transform:{x:j.x-ne.x,y:j.y-ne.y,scaleX:1,scaleY:1},activatorEvent:_,active:M,activeNodeRect:Y,containerNodeRect:J,draggingNodeRect:ee,over:K.current.over,overlayNodeRect:Z.rect,scrollableAncestors:ae,scrollableAncestorRects:se,windowRect:re}),le=H?Mi(H,j):null,ce=function(e){const[t,n]=r.useState(null),o=r.useRef(e),a=r.useCallback((e=>{const t=Sg(e.target);t&&n((e=>e?(e.set(t,Mg(t)),new Map(e)):null))}),[]);return r.useEffect((()=>{const t=o.current;if(e!==t){r(t);const s=e.map((e=>{const t=Sg(e);return t?(t.addEventListener("scroll",a,{passive:!0}),[t,Mg(t)]):null})).filter((e=>null!=e));n(s.length?new Map(s):null),o.current=e}return()=>{r(e),r(t)};function r(e){e.forEach((e=>{const t=Sg(e);null==t||t.removeEventListener("scroll",a)}))}}),[a,e]),r.useMemo((()=>e.length?t?Array.from(t.values()).reduce(((e,t)=>Mi(e,t)),lg):Lg(e):lg),[e,t])}(ae),de=kv(ce),ue=kv(ce,[Y]),he=Mi(ie,de),fe=ee?wg(ee,ie):null,me=M&&fe?h({active:M,collisionRect:fe,droppableRects:U,droppableContainers:L,pointerCoordinates:le}):null,pe=fg(me,"id"),[ge,ve]=r.useState(null),xe=function(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}(te?ie:Mi(ie,ue),null!=(a=null==ge?void 0:ge.rect)?a:null,Y),ye=r.useCallback(((e,t)=>{let{sensor:n,options:o}=t;if(null==T.current)return;const r=C.get(T.current);if(!r)return;const a=e.nativeEvent,s=new n({active:T.current,activeNode:r,event:a,options:o,context:K,onStart(e){const t=T.current;if(null==t)return;const n=C.get(t);if(!n)return;const{onDragStart:o}=R.current,r={active:{id:t,data:n.data,rect:A}};Ao.unstable_batchedUpdates((()=>{null==o||o(r),k(Lv.Initializing),x({type:rg.DragStart,initialCoordinates:e,active:t}),y({type:"onDragStart",event:r})}))},onMove(e){x({type:rg.DragMove,coordinates:e})},onEnd:i(rg.DragEnd),onCancel:i(rg.DragCancel)});function i(e){return async function(){const{active:t,collisions:n,over:o,scrollAdjustedTranslate:r}=K.current;let s=null;if(t&&r){const{cancelDrop:i}=R.current;if(s={activatorEvent:a,active:t,collisions:n,delta:r,over:o},e===rg.DragEnd&&"function"==typeof i){await Promise.resolve(i(s))&&(e=rg.DragCancel)}}T.current=null,Ao.unstable_batchedUpdates((()=>{x({type:e}),k(Lv.Uninitialized),ve(null),D(null),P(null);const t=e===rg.DragEnd?"onDragEnd":"onDragCancel";if(s){const e=R.current[t];null==e||e(s),y({type:t,event:s})}}))}}Ao.unstable_batchedUpdates((()=>{D(s),P(e.nativeEvent)}))}),[C]),be=function(e,t){return r.useMemo((()=>e.reduce(((e,n)=>{const{sensor:o}=n;return[...e,...o.activators.map((e=>({eventName:e.eventName,handler:t(e.handler,n)})))]}),[])),[e,t])}(d,r.useCallback(((e,t)=>(n,o)=>{const r=n.nativeEvent,a=C.get(o);if(null!==T.current||!a||r.dndKit||r.defaultPrevented)return;const s={active:a};!0===e(n,t.options,s)&&(r.dndKit={capturedBy:t.sensor},T.current=o,ye(n,t))}),[C,ye]));!function(e){r.useEffect((()=>{if(!Li)return;const t=e.map((e=>{let{sensor:t}=e;return null==t.setup?void 0:t.setup()}));return()=>{for(const e of t)null==e||e()}}),e.map((e=>{let{sensor:t}=e;return t})))}(d),Ti((()=>{Y&&w===Lv.Initializing&&k(Lv.Initialized)}),[Y,w]),r.useEffect((()=>{const{onDragMove:e}=R.current,{active:t,activatorEvent:n,collisions:o,over:r}=K.current;if(!t||!n)return;const a={active:t,activatorEvent:n,collisions:o,delta:{x:he.x,y:he.y},over:r};Ao.unstable_batchedUpdates((()=>{null==e||e(a),y({type:"onDragMove",event:a})}))}),[he.x,he.y]),r.useEffect((()=>{const{active:e,activatorEvent:t,collisions:n,droppableContainers:o,scrollAdjustedTranslate:r}=K.current;if(!e||null==T.current||!t||!r)return;const{onDragOver:a}=R.current,s=o.get(pe),i=s&&s.rect.current?{id:s.id,rect:s.rect.current,data:s.data,disabled:s.disabled}:null,l={active:e,activatorEvent:t,collisions:n,delta:{x:r.x,y:r.y},over:i};Ao.unstable_batchedUpdates((()=>{ve(i),null==a||a(l),y({type:"onDragOver",event:l})}))}),[pe]),Ti((()=>{K.current={activatorEvent:_,active:M,activeNode:G,collisionRect:fe,collisions:me,droppableRects:U,draggableNodes:C,draggingNode:Q,draggingNodeRect:ee,droppableContainers:S,over:ge,scrollableAncestors:ae,scrollAdjustedTranslate:he},A.current={initial:ee,translated:fe}}),[M,G,me,fe,C,Q,ee,U,S,ge,ae,he]),uv({...W,delta:j,draggingRect:fe,pointerCoordinates:le,scrollableAncestors:ae,scrollableAncestorRects:se});const we=r.useMemo((()=>({active:M,activeNode:G,activeNodeRect:Y,activatorEvent:_,collisions:me,containerNodeRect:J,dragOverlay:Z,draggableNodes:C,droppableContainers:S,droppableRects:U,over:ge,measureDroppableContainers:V,scrollableAncestors:ae,scrollableAncestorRects:se,measuringConfiguration:z,measuringScheduled:$,windowRect:re})),[M,G,Y,_,me,J,Z,C,S,U,ge,V,ae,se,z,$,re]),ke=r.useMemo((()=>({activatorEvent:_,activators:be,active:M,activeNodeRect:Y,ariaDescribedById:{draggable:F},dispatch:x,draggableNodes:C,over:ge,measureDroppableContainers:V})),[_,be,M,Y,x,F,C,ge,V]);return u.createElement(eg.Provider,{value:b},u.createElement(Ov.Provider,{value:ke},u.createElement(Dv.Provider,{value:we},u.createElement(Fv.Provider,{value:xe},c)),u.createElement(Rv,{disabled:!1===(null==i?void 0:i.restoreFocus)})),u.createElement(og,{...i,hiddenTextDescribedById:F}))})),Uv=r.createContext(null),Vv="button";function $v(e){let{id:t,data:n,disabled:o=!1,attributes:a}=e;const s=Ii("Droppable"),{activators:i,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:u,draggableNodes:h,over:f}=r.useContext(Ov),{role:m=Vv,roleDescription:p="draggable",tabIndex:g=0}=null!=a?a:{},v=(null==c?void 0:c.id)===t,x=r.useContext(v?Fv:Uv),[y,b]=Bi(),[w,k]=Bi(),N=function(e,t){return r.useMemo((()=>e.reduce(((e,n)=>{let{eventName:o,handler:r}=n;return e[o]=e=>{r(e,t)},e}),{})),[e,t])}(i,t),E=Si(n);Ti((()=>(h.set(t,{id:t,key:s,node:y,activatorNode:w,data:E}),()=>{const e=h.get(t);e&&e.key===s&&h.delete(t)})),[h,t]);return{active:c,activatorEvent:l,activeNodeRect:d,attributes:r.useMemo((()=>({role:m,tabIndex:g,"aria-disabled":o,"aria-pressed":!(!v||m!==Vv)||void 0,"aria-roledescription":p,"aria-describedby":u.draggable})),[o,m,g,v,p,u.draggable]),isDragging:v,listeners:o?void 0:N,node:y,over:f,setNodeRef:b,setActivatorNodeRef:k,transform:x}}const Gv={timeout:25};function Hv(e,t,n){const o=e.slice();return o.splice(n<0?o.length+n:n,0,o.splice(t,1)[0]),o}function Wv(e,t){return e.reduce(((e,n,o)=>{const r=t.get(n);return r&&(e[o]=r),e}),Array(e.length))}function qv(e){return null!==e&&e>=0}const Yv={scaleX:1,scaleY:1},Jv=e=>{var t;let{rects:n,activeNodeRect:o,activeIndex:r,overIndex:a,index:s}=e;const i=null!=(t=n[r])?t:o;if(!i)return null;const l=function(e,t,n){const o=e[t],r=e[t-1],a=e[t+1];if(!o||!r&&!a)return 0;if(n<t)return r?o.left-(r.left+r.width):a.left-(o.left+o.width);return a?a.left-(o.left+o.width):o.left-(r.left+r.width)}(n,s,r);if(s===r){const e=n[a];return e?{x:r<a?e.left+e.width-(i.left+i.width):e.left-i.left,y:0,...Yv}:null}return s>r&&s<=a?{x:-i.width-l,y:0,...Yv}:s<r&&s>=a?{x:i.width+l,y:0,...Yv}:{x:0,y:0,...Yv}};const Kv=e=>{let{rects:t,activeIndex:n,overIndex:o,index:r}=e;const a=Hv(t,o,n),s=t[r],i=a[r];return i&&s?{x:i.left-s.left,y:i.top-s.top,scaleX:i.width/s.width,scaleY:i.height/s.height}:null},Xv={scaleX:1,scaleY:1},Zv=e=>{var t;let{activeIndex:n,activeNodeRect:o,index:r,rects:a,overIndex:s}=e;const i=null!=(t=a[n])?t:o;if(!i)return null;if(r===n){const e=a[s];return e?{x:0,y:n<s?e.top+e.height-(i.top+i.height):e.top-i.top,...Xv}:null}const l=function(e,t,n){const o=e[t],r=e[t-1],a=e[t+1];if(!o)return 0;if(n<t)return r?o.top-(r.top+r.height):a?a.top-(o.top+o.height):0;return a?a.top-(o.top+o.height):r?o.top-(r.top+r.height):0}(a,r,n);return r>n&&r<=s?{x:0,y:-i.height-l,...Xv}:r<n&&r>=s?{x:0,y:i.height+l,...Xv}:{x:0,y:0,...Xv}};const Qv="Sortable",ex=u.createContext({activeIndex:-1,containerId:Qv,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Kv,disabled:{draggable:!1,droppable:!1}});function tx(e){let{children:t,id:n,items:o,strategy:a=Kv,disabled:s=!1}=e;const{active:i,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:h}=r.useContext(Dv),f=Ii(Qv,n),m=Boolean(null!==l.rect),p=r.useMemo((()=>o.map((e=>"object"==typeof e&&"id"in e?e.id:e))),[o]),g=null!=i,v=i?p.indexOf(i.id):-1,x=d?p.indexOf(d.id):-1,y=r.useRef(p),b=!function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(p,y.current),w=-1!==x&&-1===v||b,k=function(e){return"boolean"==typeof e?{draggable:e,droppable:e}:e}(s);Ti((()=>{b&&g&&h(p)}),[b,p,g,h]),r.useEffect((()=>{y.current=p}),[p]);const N=r.useMemo((()=>({activeIndex:v,containerId:f,disabled:k,disableTransforms:w,items:p,overIndex:x,useDragOverlay:m,sortedRects:Wv(p,c),strategy:a})),[v,f,k.draggable,k.droppable,w,p,x,c,m,a]);return u.createElement(ex.Provider,{value:N},t)}const nx=e=>{let{id:t,items:n,activeIndex:o,overIndex:r}=e;return Hv(n,o,r).indexOf(t)},ox=e=>{let{containerId:t,isSorting:n,wasDragging:o,index:r,items:a,newIndex:s,previousItems:i,previousContainerId:l,transition:c}=e;return!(!c||!o)&&((i===a||r!==s)&&(!!n||s!==r&&t===l))},rx={duration:200,easing:"ease"},ax="transform",sx=Yi.Transition.toString({property:ax,duration:0,easing:"linear"}),ix={roleDescription:"sortable"};function lx(e){let{animateLayoutChanges:t=ox,attributes:n,disabled:o,data:a,getNewIndex:s=nx,id:i,strategy:l,resizeObserverConfig:c,transition:d=rx}=e;const{items:u,containerId:h,activeIndex:f,disabled:m,disableTransforms:p,sortedRects:g,overIndex:v,useDragOverlay:x,strategy:y}=r.useContext(ex),b=function(e,t){var n,o;if("boolean"==typeof e)return{draggable:e,droppable:!1};return{draggable:null!=(n=null==e?void 0:e.draggable)?n:t.draggable,droppable:null!=(o=null==e?void 0:e.droppable)?o:t.droppable}}(o,m),w=u.indexOf(i),k=r.useMemo((()=>({sortable:{containerId:h,index:w,items:u},...a})),[h,a,w,u]),N=r.useMemo((()=>u.slice(u.indexOf(i))),[u,i]),{rect:E,node:C,isOver:j,setNodeRef:S}=function(e){let{data:t,disabled:n=!1,id:o,resizeObserverConfig:a}=e;const s=Ii("Droppable"),{active:i,dispatch:l,over:c,measureDroppableContainers:d}=r.useContext(Ov),u=r.useRef({disabled:n}),h=r.useRef(!1),f=r.useRef(null),m=r.useRef(null),{disabled:p,updateMeasurementsFor:g,timeout:v}={...Gv,...a},x=Si(null!=g?g:o),y=xv({callback:r.useCallback((()=>{h.current?(null!=m.current&&clearTimeout(m.current),m.current=setTimeout((()=>{d(Array.isArray(x.current)?x.current:[x.current]),m.current=null}),v)):h.current=!0}),[v]),disabled:p||!i}),b=r.useCallback(((e,t)=>{y&&(t&&(y.unobserve(t),h.current=!1),e&&y.observe(e))}),[y]),[w,k]=Bi(b),N=Si(t);return r.useEffect((()=>{y&&w.current&&(y.disconnect(),h.current=!1,y.observe(w.current))}),[w,y]),Ti((()=>(l({type:rg.RegisterDroppable,element:{id:o,key:s,disabled:n,node:w,rect:f,data:N}}),()=>l({type:rg.UnregisterDroppable,key:s,id:o}))),[o]),r.useEffect((()=>{n!==u.current.disabled&&(l({type:rg.SetDroppableDisabled,id:o,key:s,disabled:n}),u.current.disabled=n)}),[o,s,n,l]),{active:i,rect:f,isOver:(null==c?void 0:c.id)===o,node:w,over:c,setNodeRef:k}}({id:i,data:k,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:N,...c}}),{active:I,activatorEvent:A,activeNodeRect:M,attributes:T,setNodeRef:O,listeners:D,isDragging:_,over:P,setActivatorNodeRef:R,transform:F}=$v({id:i,data:k,attributes:{...ix,...n},disabled:b.draggable}),L=qi(S,O),z=Boolean(I),B=z&&!p&&qv(f)&&qv(v),U=!x&&_,V=U&&B?F:null,$=B?null!=V?V:(null!=l?l:y)({rects:g,activeNodeRect:M,activeIndex:f,overIndex:v,index:w}):null,G=qv(f)&&qv(v)?s({id:i,items:u,activeIndex:f,overIndex:v}):w,H=null==I?void 0:I.id,W=r.useRef({activeId:H,items:u,newIndex:G,containerId:h}),q=u!==W.current.items,Y=t({active:I,containerId:h,isDragging:_,isSorting:z,id:i,index:w,items:u,newIndex:W.current.newIndex,previousItems:W.current.items,previousContainerId:W.current.containerId,transition:d,wasDragging:null!=W.current.activeId}),J=function(e){let{disabled:t,index:n,node:o,rect:a}=e;const[s,i]=r.useState(null),l=r.useRef(n);return Ti((()=>{if(!t&&n!==l.current&&o.current){const e=a.current;if(e){const t=Ng(o.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&i(n)}}n!==l.current&&(l.current=n)}),[t,n,o,a]),r.useEffect((()=>{s&&i(null)}),[s]),s}({disabled:!Y,index:w,node:C,rect:E});return r.useEffect((()=>{z&&W.current.newIndex!==G&&(W.current.newIndex=G),h!==W.current.containerId&&(W.current.containerId=h),u!==W.current.items&&(W.current.items=u)}),[z,G,h,u]),r.useEffect((()=>{if(H===W.current.activeId)return;if(H&&!W.current.activeId)return void(W.current.activeId=H);const e=setTimeout((()=>{W.current.activeId=H}),50);return()=>clearTimeout(e)}),[H]),{active:I,activeIndex:f,attributes:T,data:k,rect:E,index:w,newIndex:G,items:u,isOver:j,isSorting:z,isDragging:_,listeners:D,node:C,overIndex:v,over:P,setNodeRef:L,setActivatorNodeRef:R,setDroppableNodeRef:S,setDraggableNodeRef:O,transform:null!=J?J:$,transition:function(){if(J||q&&W.current.newIndex===w)return sx;if(U&&!Di(A)||!d)return;if(z||Y)return Yi.Transition.toString({...d,property:ax});return}()}}function cx(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&"object"==typeof t.sortable&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const dx=[Hg.Down,Hg.Right,Hg.Up,Hg.Left],ux=(e,t)=>{let{context:{active:n,collisionRect:o,droppableRects:r,droppableContainers:a,over:s,scrollableAncestors:i}}=t;if(dx.includes(e.code)){if(e.preventDefault(),!n||!o)return;const t=[];a.getEnabled().forEach((n=>{if(!n||null!=n&&n.disabled)return;const a=r.get(n.id);if(a)switch(e.code){case Hg.Down:o.top<a.top&&t.push(n);break;case Hg.Up:o.top>a.top&&t.push(n);break;case Hg.Left:o.left>a.left&&t.push(n);break;case Hg.Right:o.left<a.left&&t.push(n)}}));const l=(e=>{let{collisionRect:t,droppableRects:n,droppableContainers:o}=e;const r=hg(t),a=[];for(const s of o){const{id:e}=s,t=n.get(e);if(t){const n=hg(t),o=r.reduce(((e,t,o)=>e+cg(n[o],t)),0),i=Number((o/4).toFixed(4));a.push({id:e,data:{droppableContainer:s,value:i}})}}return a.sort(dg)})({active:n,collisionRect:o,droppableRects:r,droppableContainers:t,pointerCoordinates:null});let c=fg(l,"id");if(c===(null==s?void 0:s.id)&&l.length>1&&(c=l[1].id),null!=c){const e=a.get(n.id),t=a.get(c),s=t?r.get(t.id):null,l=null==t?void 0:t.node.current;if(l&&s&&e&&t){const n=Cg(l).some(((e,t)=>i[t]!==e)),r=hx(e,t),a=function(e,t){if(!cx(e)||!cx(t))return!1;if(!hx(e,t))return!1;return e.data.current.sortable.index<t.data.current.sortable.index}(e,t),c=n||!r?{x:0,y:0}:{x:a?o.width-s.width:0,y:a?o.height-s.height:0},d={x:s.left,y:s.top};return c.x&&c.y?d:_i(d,c)}}}};function hx(e,t){return!(!cx(e)||!cx(t))&&e.data.current.sortable.containerId===t.data.current.sortable.containerId}const fx=u.createContext(null),mx=r.memo((()=>r.useContext(fx)));mx.displayName="DragHandle";const px=u.forwardRef((({cellId:e,canMoveX:t,...n},o)=>{const{attributes:r,listeners:a,setNodeRef:s,transform:i,transition:l,isDragging:c}=lx({id:e.toString()}),d={transform:i?Yi.Transform.toString({x:t?i.x:0,y:i.y,scaleX:1,scaleY:1}):void 0,transition:l,zIndex:c?2:void 0,position:"relative"},u=Kp(o,s),h=m.jsx("div",{...r,...a,onMouseDown:$e.preventFocus,"data-testid":"drag-button",className:"py-[1px] cursor-grab opacity-50 hover:opacity-100 hover-action hover:bg-muted rounded border border-transparent hover:border-border active:bg-accent",children:m.jsx(ql,{strokeWidth:1,size:20})}),f=Boolean(i);return m.jsx("div",{tabIndex:-1,ref:u,...n,"data-is-dragging":c,className:$t(n.className,f&&"is-moving"),style:d,children:m.jsx(fx.Provider,{value:h,children:n.children})})}));px.displayName="SortableCell";const gx=r.memo(px),vx=u.memo(u.forwardRef((({children:e,showTooltip:t=!0,...n},o)=>{const[a,s]=r.useState(!1),i=od({cell:n}),l=Mo();r.useImperativeHandle(o,(()=>({toggle:()=>s((e=>!e))})));const c=m.jsx(Xt,{className:"w-[300px] p-0 pt-1",...l,children:m.jsxs(Jt,{children:[m.jsx(Te,{placeholder:"Search actions...",className:"h-6 m-1"}),m.jsxs(To,{children:[m.jsx(De,{children:"No results"}),i.map(((e,t)=>m.jsxs(r.Fragment,{children:[m.jsx(_e,{children:e.map((e=>m.jsx(Fe,{onSelect:()=>{e.disableClick||(e.handle(),s(!1))},variant:e.variant,children:m.jsxs("div",{className:"flex items-center flex-1",children:[e.icon&&m.jsx("div",{className:"mr-2 w-5",children:e.icon}),m.jsx("div",{className:"flex-1",children:e.label}),m.jsxs("div",{className:"flex-shrink-0 text-sm",children:[e.hotkey&&ni(e.hotkey),e.rightElement]})]})},e.label)))},t),t<i.length-1&&m.jsx(Re,{})]},t)))]})]})});if(!t)return m.jsxs(Yt,{open:a,onOpenChange:s,children:[m.jsx(Oo,{asChild:!0,children:e}),c]});const d=m.jsx(Po,{tabIndex:-1,children:Ds("cell.cellActions")});return m.jsxs(Yt,{open:a,onOpenChange:s,children:[m.jsxs(Do,{delayDuration:200,disableHoverableContent:!0,children:[!a&&d,m.jsx(_o,{children:m.jsx(Oo,{className:"flex",children:e})})]}),c]})}))),xx=u.memo((({children:e,cellId:t})=>{const n=X(r.useMemo((()=>function(e){return V((t=>id(e,t(J))))}(t)),[t]));return n?m.jsx(vx,{showTooltip:!1,...n,children:e}):null}));xx.displayName="ConnectionCellActionsDropdown";const yx=({children:e,...t})=>{const n=od({cell:t}),[o,a]=u.useState(),s=[{label:"Copy",icon:m.jsx(Ve,{size:13,strokeWidth:1.5}),handle:()=>{document.execCommand("copy")}},{label:"Cut",icon:m.jsx(vc,{size:13,strokeWidth:1.5}),handle:()=>{document.execCommand("cut")}},{label:"Paste",icon:m.jsx(Pl,{size:13,strokeWidth:1.5}),handle:async()=>{const{getEditorView:e}=t,n=e();if(!n)return;const o=await navigator.clipboard.readText();if(o){const{from:e,to:t}=n.state.selection.main,r=n.state.update({changes:{from:e,to:t,insert:o}});n.dispatch(r)}}},{icon:m.jsx(xi,{size:13,strokeWidth:1.5}),label:"Download image",hidden:!o,handle:()=>{if(o){const e=document.createElement("a");e.download="image.png",e.href=o.src,e.click()}}},{label:"Go to Definition",icon:m.jsx(Ro,{size:13,strokeWidth:1.5}),handle:()=>{const{getEditorView:e}=t,n=e();n&&Fo(n)}}];return m.jsxs(Dp,{children:[m.jsx(_p,{onContextMenu:e=>{e.target instanceof HTMLImageElement?a(e.target):a(void 0)},asChild:!0,children:e}),m.jsx(Fp,{className:"w-[300px]",children:[s,...n].map(((e,t)=>m.jsxs(r.Fragment,{children:[e.map((e=>e.hidden?null:m.jsx(Lp,{onSelect:t=>{e.handle(t)},variant:e.variant,children:m.jsxs("div",{className:"flex items-center flex-1",children:[e.icon&&m.jsx("div",{className:"mr-2 w-5",children:e.icon}),m.jsx("div",{className:"flex-1",children:e.label}),m.jsxs("div",{className:"flex-shrink-0 text-sm",children:[e.hotkey&&ni(e.hotkey),e.rightElement]})]})},e.label))),t<e.length-1&&m.jsx(zp,{})]},t)))})]})},bx=({editorView:e,code:t,currentLanguageAdapter:n,onAfterToggle:o})=>{const a=r.useMemo((()=>(new Eo).isSupported(t)),[t]),s=r.useMemo((()=>(new Co).isSupported(t)),[t]);return m.jsxs("div",{className:"absolute right-2 top-2 z-20 flex hover-action",children:[m.jsx(wx,{editorView:e,currentLanguageAdapter:n,canSwitchToLanguage:s&&"python"===n&&!a,icon:m.jsx(de,{color:"var(--sky-11)",strokeWidth:2.5,className:"w-4 h-4"}),toType:"sql",displayName:"SQL",onAfterToggle:o}),m.jsx(wx,{editorView:e,currentLanguageAdapter:n,canSwitchToLanguage:a&&"python"===n,icon:m.jsx(Ls,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),toType:"markdown",displayName:"Markdown",onAfterToggle:o}),m.jsx(wx,{editorView:e,currentLanguageAdapter:n,canSwitchToLanguage:!0,icon:m.jsx(zs,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),toType:"python",displayName:"Python",onAfterToggle:Gt.NOOP})]})},wx=({editorView:e,currentLanguageAdapter:t,canSwitchToLanguage:n,icon:o,toType:r,displayName:a,onAfterToggle:s})=>n?t===r?null:m.jsx(p,{content:`View as ${a}`,children:m.jsx(b,{"data-testid":"language-toggle-button",variant:"text",size:"xs",className:"opacity-80 px-1",onClick:()=>{e&&(Lo(e,r),s())},children:o})}):null;var kx={modified:{doc:""},original:{doc:""}},Nx=r.createContext(kx);function Ex(e,t){return Kn({},e,t,{modified:Kn({},e.modified,t.modified),original:Kn({},e.original,t.original)})}var Cx=()=>r.useContext(Nx),jx=e=>{var{children:t,theme:n}=e,[o,a]=r.useReducer(Ex,Kn({},kx,{theme:n}));return r.useEffect((()=>a({theme:n})),[n]),m.jsx(Nx.Provider,{value:Kn({},o,{dispatch:a}),children:t})},Sx=["extensions","value","selection","onChange"],Ix=e=>{var{extensions:t=[],value:n,selection:o,onChange:a}=e,s=zo(e,Sx),{theme:i,dispatch:l}=Cx(),c=Bo(Kn({},s,{theme:i}));return r.useEffect((()=>l({original:{doc:n,selection:o,extensions:[...c,...t]},originalExtension:{onChange:a,option:s,extension:[t]}})),[e]),null};Ix.displayName="CodeMirrorMerge.Original";var Ax=["extensions","value","selection","onChange"],Mx=e=>{var{extensions:t=[],value:n,selection:o,onChange:a}=e,s=zo(e,Ax),{theme:i,dispatch:l}=Cx(),c=Bo(Kn({},s,{theme:i}));return r.useEffect((()=>{l({modified:{doc:n,selection:o,extensions:[...c,...t]},modifiedExtension:{onChange:a,option:s,extension:[t]}})}),[e]),null};Mx.displayName="CodeMirrorMerge.Modified";class Tx{constructor(e,t,n,o){this.fromA=e,this.toA=t,this.fromB=n,this.toB=o}offset(e,t){return new Tx(this.fromA+e,this.toA+e,this.fromB+t,this.toB+t)}}function Ox(e,t,n,o,r,a){if(e==o)return[];let s=zx(e,t,n,o,r,a),i=Bx(e,t+s,n,o,r+s,a),l=(n-=i)-(t+=s),c=(a-=i)-(r+=s);if(!l||!c)return[new Tx(t,n,r,a)];if(l>c){let s=e.slice(t,n).indexOf(o.slice(r,a));if(s>-1)return[new Tx(t,t+s,r,r),new Tx(t+s+c,n,a,a)]}else if(c>l){let s=o.slice(r,a).indexOf(e.slice(t,n));if(s>-1)return[new Tx(t,t,r,r+s),new Tx(n,n,r+s+l,a)]}if(1==l||1==c)return[new Tx(t,n,r,a)];let d=Vx(e,t,n,o,r,a);if(d){let[s,i,l]=d;return Ox(e,t,s,o,r,i).concat(Ox(e,s+l,n,o,i+l,a))}return function(e,t,n,o,r,a){let s=n-t,i=a-r;if(Dx<1e9&&Math.min(s,i)>16*Dx)return Math.min(s,i)>64*Dx?[new Tx(t,n,r,a)]:$x(e,t,n,o,r,a);let l=Math.ceil((s+i)/2);Px.reset(l),Rx.reset(l);let c=(n,a)=>e.charCodeAt(t+n)==o.charCodeAt(r+a),d=(t,r)=>e.charCodeAt(n-t-1)==o.charCodeAt(a-r-1),u=(s-i)%2!=0?Rx:null,h=u?null:Px;for(let f=0;f<l;f++){if(f>Dx)return $x(e,t,n,o,r,a);let m=Px.advance(f,s,i,l,u,!1,c)||Rx.advance(f,s,i,l,h,!0,d);if(m)return Fx(e,t,n,t+m[0],o,r,a,r+m[1])}return[new Tx(t,n,r,a)]}(e,t,n,o,r,a)}let Dx=1e9;class _x{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let t=0;t<this.len;t++)this.vec[t]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,n,o,r,a,s){for(let i=-e+this.start;i<=e-this.end;i+=2){let l=o+i,c=i==-e||i!=e&&this.vec[l-1]<this.vec[l+1]?this.vec[l+1]:this.vec[l-1]+1,d=c-i;for(;c<t&&d<n&&s(c,d);)c++,d++;if(this.vec[l]=c,c>t)this.end+=2;else if(d>n)this.start+=2;else if(r){let e=o+(t-n)-i;if(e>=0&&e<this.len&&-1!=r.vec[e])if(a){let n=r.vec[e];if(n>=t-c)return[n,o+n-e]}else{if(c>=t-r.vec[e])return[c,d]}}}return null}}const Px=new _x,Rx=new _x;function Fx(e,t,n,o,r,a,s,i){let l=!1;return ey(e,o)||++o!=n||(l=!0),ey(r,i)||++i!=s||(l=!0),l?[new Tx(t,n,a,s)]:Ox(e,t,o,r,a,i).concat(Ox(e,o,n,r,i,s))}function Lx(e,t){let n=1,o=Math.min(e,t);for(;n<o;)n<<=1;return n}function zx(e,t,n,o,r,a){if(t==n||t==a||e.charCodeAt(t)!=o.charCodeAt(r))return 0;let s=Lx(n-t,a-r);for(let i=t,l=r;;){let r=i+s,c=l+s;if(r>n||c>a||e.slice(i,r)!=o.slice(l,c)){if(1==s)return i-t-(ey(e,i)?0:1);s>>=1}else{if(r==n||c==a)return r-t;i=r,l=c}}}function Bx(e,t,n,o,r,a){if(t==n||r==a||e.charCodeAt(n-1)!=o.charCodeAt(a-1))return 0;let s=Lx(n-t,a-r);for(let i=n,l=a;;){let a=i-s,c=l-s;if(a<t||c<r||e.slice(a,i)!=o.slice(c,l)){if(1==s)return n-i-(ey(e,i)?0:1);s>>=1}else{if(a==t||c==r)return n-a;i=a,l=c}}}function Ux(e,t,n,o,r,a,s,i){let l=o.slice(r,a),c=null;for(;;){if(c||s<i)return c;for(let i=t+s;;){ey(e,i)||i++;let d=i+s;if(ey(e,d)||(d+=d==i+1?1:-1),d>=n)break;let u=e.slice(i,d),h=-1;for(;-1!=(h=l.indexOf(u,h+1));){let s=zx(e,d,n,o,r+h+u.length,a),l=Bx(e,t,i,o,r,r+h),f=u.length+s+l;(!c||c[2]<f)&&(c=[i-l,r+h-l,f])}i=d}if(i<0)return c;s>>=1}}function Vx(e,t,n,o,r,a){let s=n-t,i=a-r;if(s<i){let s=Vx(o,r,a,e,t,n);return s&&[s[1],s[0],s[2]]}return s<4||2*i<s?null:Ux(e,t,n,o,r,a,Math.floor(s/4),-1)}function $x(e,t,n,o,r,a){let s,i=n-t,l=a-r;if(i<l){let l=Ux(o,r,a,e,t,n,Math.floor(i/6),50);s=l&&[l[1],l[0],l[2]]}else s=Ux(e,t,n,o,r,a,Math.floor(l/6),50);if(!s)return[new Tx(t,n,r,a)];let[c,d,u]=s;return Ox(e,t,c,o,r,d).concat(Ox(e,c+u,n,o,d+u,a))}function Gx(e,t){for(let n=1;n<e.length;n++){let o=e[n-1],r=e[n];o.toA>r.fromA-t&&o.toB>r.fromB-t&&(e[n-1]=new Tx(o.fromA,r.toA,o.fromB,r.toB),e.splice(n--,1))}}let Hx;try{Hx=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch(RT){}function Wx(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function qx(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?Wx(n)?1:0:Hx?Zx(n)&&t!=e.length-1?Hx.test(e.slice(t,t+2))?2:0:Hx.test(String.fromCharCode(n))?1:0:0}function Yx(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?Wx(n)?1:0:Hx?Qx(n)&&1!=t?Hx.test(e.slice(t-2,t))?2:0:Hx.test(String.fromCharCode(n))?1:0:0}function Jx(e,t,n){if(t==e.length||!Yx(e,t))return t;for(let o=t,r=t+n;;){let n=qx(e,o);if(!n)return o;if(o+=n,o>r)return t}}function Kx(e,t,n){if(!t||!qx(e,t))return t;for(let o=t,r=t-n;;){let n=Yx(e,o);if(!n)return o;if(o-=n,o<r)return t}}function Xx(e,t,n){for(let o=t,r=t-n;;){let n=o?e.charCodeAt(o-1):10;if(10==n)return o;if(o--,o<r||32!=n&&9!=n)return t}}const Zx=e=>e>=55296&&e<=56319,Qx=e=>e>=56320&&e<=57343;function ey(e,t){return!t||t==e.length||!Zx(e.charCodeAt(t-1))||!Qx(e.charCodeAt(t))}function ty(e,t,n){var o;return Dx=(null!==(o=null==n?void 0:n.scanLimit)&&void 0!==o?o:1e9)>>1,function(e,t,n){for(;;){Gx(n,1);let o=!1;for(let r=0;r<n.length;r++){let a,s,i=n[r];(a=zx(e,i.fromA,i.toA,t,i.fromB,i.toB))&&(i=n[r]=new Tx(i.fromA+a,i.toA,i.fromB+a,i.toB)),(s=Bx(e,i.fromA,i.toA,t,i.fromB,i.toB))&&(i=n[r]=new Tx(i.fromA,i.toA-s,i.fromB,i.toB-s));let l=i.toA-i.fromA,c=i.toB-i.fromB;if(l&&c)continue;let d=i.fromA-(r?n[r-1].toA:0),u=(r<n.length-1?n[r+1].fromA:e.length)-i.toA;if(!d||!u)continue;let h=l?e.slice(i.fromA,i.toA):t.slice(i.fromB,i.toB);d<=h.length&&e.slice(i.fromA-d,i.fromA)==h.slice(h.length-d)?(n[r]=new Tx(i.fromA-d,i.toA-d,i.fromB-d,i.toB-d),o=!0):u<=h.length&&e.slice(i.toA,i.toA+u)==h.slice(0,u)&&(n[r]=new Tx(i.fromA+u,i.toA+u,i.fromB+u,i.toB+u),o=!0)}if(!o)break}return n}(e,t,Ox(e,0,e.length,t,0,t.length))}function ny(e,t,n){return function(e,t,n){for(let o=0,r=0;r<e.length;r++){let a=e[r],s=a.toA-a.fromA,i=a.toB-a.fromB;if(s&&i||s>3||i>3){let l=r==e.length-1?t.length:e[r+1].fromA,c=a.fromA-o,d=l-a.toA,u=Kx(t,a.fromA,Math.min(c,5)),h=Jx(t,a.toA,Math.min(d,5)),f=a.fromA-u,m=h-a.toA;if(!s||!i){let d,p,g=Math.max(s,i),[v,x,y]=s?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];f&&m?(g>f&&t.slice(u,a.fromA)==v.slice(y-f,y)?(a=e[r]=new Tx(u,u+s,a.fromB-f,a.toB-f),u=a.fromA,h=Jx(t,a.toA,Math.min(l-a.toA,5))):g>m&&t.slice(a.toA,h)==v.slice(x,x+m)&&(a=e[r]=new Tx(h-s,h,a.fromB+m,a.toB+m),h=a.toA,u=Kx(t,a.fromA,Math.min(a.fromA-o,5))),f=a.fromA-u,m=h-a.toA):f||m||!(p=a.fromA-(d=Xx(t,a.fromA,c)))||t.slice(d,a.fromA)!=v.slice(y-p,y)||(a=e[r]=new Tx(d,d+s,a.fromB-p,a.toB-p))}(f||m)&&(a=e[r]=new Tx(a.fromA-f,a.toA+m,a.fromB-f,a.toB+m)),o=a.toA}}return Gx(e,3),e}(ty(e,t,n),e,t)}const oy=rn.define({combine:e=>e[0]}),ry=_t.define(),ay=Pt.define({create:e=>null,update(e,t){for(let n of t.effects)n.is(ry)&&(e=n.value);return e}});class sy{constructor(e,t,n,o,r){this.changes=e,this.fromA=t,this.toA=n,this.fromB=o,this.toB=r}offset(e,t){return e||t?new sy(this.changes,this.fromA+e,this.toA+e,this.fromB+t,this.toB+t):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,t,n){return cy(ny(e.toString(),t.toString(),n),e,t,0,0)}static updateA(e,t,n,o,r){return fy(hy(e,o,!0,n.length),e,t,n,r)}static updateB(e,t,n,o,r){return fy(hy(e,o,!1,t.length),e,t,n,r)}}function iy(e,t,n,o){let r=n.lineAt(e),a=o.lineAt(t);return r.to==e&&a.to==t&&e<n.length&&t<o.length?[e+1,t+1]:[r.from,a.from]}function ly(e,t,n,o){let r=n.lineAt(e),a=o.lineAt(t);return r.from==e&&a.from==t?[e,t]:[r.to+1,a.to+1]}function cy(e,t,n,o,r){let a=[];for(let s=0;s<e.length;s++){let i=e[s],[l,c]=iy(i.fromA+o,i.fromB+r,t,n),[d,u]=ly(i.toA+o,i.toB+r,t,n),h=[i.offset(-l+o,-c+r)];for(;s<e.length-1;){let a=e[s+1],[i,f]=iy(a.fromA+o,a.fromB+r,t,n);if(i>d+1&&f>u+1)break;h.push(a.offset(-l+o,-c+r)),[d,u]=ly(a.toA+o,a.toB+r,t,n),s++}a.push(new sy(h,l,Math.max(l,d),c,Math.max(c,u)))}return a}const dy=1e3;function uy(e,t,n,o){let r=0,a=e.length;for(;;){if(r==a){let o=0,a=0;r&&({toA:o,toB:a}=e[r-1]);let s=t-(n?o:a);return[o+s,a+s]}let s=r+a>>1,i=e[s],[l,c]=n?[i.fromA,i.toA]:[i.fromB,i.toB];if(l>t)a=s;else{if(!(c<=t))return o?[i.fromA,i.fromB]:[i.toA,i.toB];r=s+1}}}function hy(e,t,n,o){let r=[];return t.iterChangedRanges(((a,s,i,l)=>{let c=0,d=n?t.length:o,u=0,h=n?o:t.length;a>dy&&([c,u]=uy(e,a-dy,n,!0)),s<t.length-dy&&([d,h]=uy(e,s+dy,n,!1));let f,m=l-i-(s-a),[p,g]=n?[m,0]:[0,m];r.length&&(f=r[r.length-1]).toA>=c?r[r.length-1]={fromA:f.fromA,fromB:f.fromB,toA:d,toB:h,diffA:f.diffA+p,diffB:f.diffB+g}:r.push({fromA:c,toA:d,fromB:u,toB:h,diffA:p,diffB:g})})),r}function fy(e,t,n,o,r){if(!e.length)return t;let a=0,s=0,i=0,l=[];for(let c of e){let e=c.fromA+s,d=c.toA+s+c.diffA,u=c.fromB+i,h=c.toB+i+c.diffB;for(;a<t.length;){let n=t[a];if(n.toA+s<=e&&n.toB+i<=u)l.push(n.offset(s,i));else if(n.fromA+s>d)break;a++}for(let t of cy(ny(n.sliceString(e,d),o.sliceString(u,h),r),n,o,e,u))l.push(t);for(s+=c.diffA,i+=c.diffB;a<t.length;){let e=t[a];if(e.fromA>d+s&&e.fromB>h+i)break;a++}}for(;a<t.length;)l.push(t[a++].offset(s,i));return l}const my=Ft.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=ky(e))}update(e){var t,n;(e.docChanged||e.viewportChanged||(t=e.startState,n=e.state,t.field(ay,!1)!=n.field(ay,!1))||function(e,t){return e.facet(oy)!=t.facet(oy)}(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=ky(e.view))}},{decorations:e=>e.deco}),py=nn.low(Uo({class:"cm-changeGutter",markers:e=>{var t;return(null===(t=e.plugin(my))||void 0===t?void 0:t.gutter)||Vo.empty}}));const gy=Rt.line({class:"cm-changedLine"}),vy=Rt.mark({class:"cm-changedText"}),xy=Rt.mark({tagName:"ins",class:"cm-insertedLine"}),yy=Rt.mark({tagName:"del",class:"cm-deletedLine"}),by=new class extends Ho{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function wy(e,t,n,o,r,a){let s=n?e.fromA:e.fromB,i=n?e.toA:e.toB,l=0;if(s!=i){r.add(s,s,gy),r.add(s,i,n?yy:xy),a&&a.add(s,s,by);for(let c=t.iterRange(s,i-1),d=s;!c.next().done;){if(c.lineBreak){d++,r.add(d,d,gy),a&&a.add(d,d,by);continue}let t=d+c.value.length;if(o)for(;l<e.changes.length;){let o=e.changes[l],a=s+(n?o.fromA:o.fromB),i=s+(n?o.toA:o.toB),c=Math.max(d,a),u=Math.min(t,i);if(c<u&&r.add(c,u,vy),!(i<t))break;l++}d=t}}}function ky(e){let t=e.state.field(ay),{side:n,highlightChanges:o,markGutter:r}=e.state.facet(oy),a="a"==n,s=new Lt,i=r?new Lt:null,{from:l,to:c}=e.viewport;for(let d of t){if((a?d.fromA:d.fromB)>=c)break;(a?d.toA:d.toB)>l&&wy(d,e.state.doc,a,o,s,i)}return{deco:s.finish(),gutter:i&&i.finish()}}class Ny extends on{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement("div");return e.className="cm-mergeSpacer",e.style.height=this.height+"px",e}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}const Ey=_t.define({map:(e,t)=>e.map(t)}),Cy=Pt.define({create:()=>Rt.none,update:(e,t)=>{for(let n of t.effects)if(n.is(Ey))return n.value;return e.map(t.changes)},provide:e=>Dt.decorations.from(e)}),jy=.01;const Sy=_t.define({map:(e,t)=>t.mapPos(e)});class Iy extends on{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement("div");return t.className="cm-collapsedLines",t.textContent="⦚ "+e.state.phrase("$ unchanged lines",this.lines)+" ⦚",t.addEventListener("click",(t=>{let n=e.posAtDOM(t.target);e.dispatch({effects:Sy.of(n)});let{side:o,sibling:r}=e.state.facet(oy);r&&r().dispatch({effects:Sy.of(Ay(n,e.state.field(ay),"a"==o))})})),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}}function Ay(e,t,n){let o=0,r=0;for(let a=0;;a++){let s=a<t.length?t[a]:null;if(!s||(n?s.fromA:s.fromB)>=e)return r+(e-o);[o,r]=n?[s.toA,s.toB]:[s.toB,s.toA]}}const My=Pt.define({create:e=>Rt.none,update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Sy)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>Dt.decorations.from(e)});function Ty({margin:e=3,minSize:t=4}){return My.init((n=>function(e,t,n){let o=new Lt,r="a"==e.facet(oy).side,a=e.field(ay),s=1;for(let i=0;;i++){let l=i<a.length?a[i]:null,c=i?s+t:1,d=l?e.doc.lineAt(r?l.fromA:l.fromB).number-1-t:e.doc.lines,u=d-c+1;if(u>=n&&o.add(e.doc.line(c).from,e.doc.line(d).to,Rt.replace({widget:new Iy(u),block:!0})),!l)break;s=e.doc.lineAt(Math.min(e.doc.length,r?l.toA:l.toB)).number}return o.finish()}(n,e,t)))}const Oy=Dt.styleModule.of(new $o({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}})),Dy=Dt.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb2266, #22bb2266) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff8866, #88ff8866) bottom/100% 2px no-repeat"},".cm-insertedLine, .cm-deletedLine":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer"},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"}}),_y=new Go,Py=new Go;class Ry{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig;let t=[nn.low(my),Dy,Oy,Cy,Dt.updateListener.of((e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some((e=>e.effects.some((e=>e.is(Ey)))))&&this.measure()}))],n=[oy.of({side:"a",sibling:()=>this.b,highlightChanges:!1!==e.highlightChanges,markGutter:!1!==e.gutter})];!1!==e.gutter&&n.push(py);let o=Un.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],Dt.editorAttributes.of({class:"cm-merge-a"}),Py.of(n),t]}),r=[oy.of({side:"b",sibling:()=>this.a,highlightChanges:!1!==e.highlightChanges,markGutter:!1!==e.gutter})];!1!==e.gutter&&r.push(py);let a=Un.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],Dt.editorAttributes.of({class:"cm-merge-b"}),Py.of(r),t]});this.chunks=sy.build(o.doc,a.doc,this.diffConf);let s=[ay.init((()=>this.chunks)),_y.of(e.collapseUnchanged?Ty(e.collapseUnchanged):[])];o=o.update({effects:_t.appendConfig.of(s)}).state,a=a.update({effects:_t.appendConfig.of(s)}).state,this.dom=document.createElement("div"),this.dom.className="cm-mergeView",this.editorDOM=this.dom.appendChild(document.createElement("div")),this.editorDOM.className="cm-mergeViewEditors";let i=e.orientation||"a-b",l=document.createElement("div");l.className="cm-mergeViewEditor";let c=document.createElement("div");c.className="cm-mergeViewEditor",this.editorDOM.appendChild("a-b"==i?l:c),this.editorDOM.appendChild("a-b"==i?c:l),this.a=new Dt({state:o,parent:l,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new Dt({state:a,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.b)}),this.setupRevertControls(!!e.revertControls,"b-to-a"==e.revertControls,e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some((e=>e.docChanged))){let n=e[e.length-1],o=e.reduce(((e,t)=>e.compose(t.changes)),cn.empty(e[0].startState.doc.length));this.chunks=t==this.a?sy.updateA(this.chunks,n.newDoc,this.b.state.doc,o,this.diffConf):sy.updateB(this.chunks,this.a.state.doc,n.newDoc,o,this.diffConf),t.update([...e,n.state.update({effects:ry.of(this.chunks)})]);let r=t==this.a?this.b:this.a;r.update([r.state.update({effects:ry.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let t="b-a"!=e.orientation;if(t!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let e=this.a.dom.parentNode,n=this.b.dom.parentNode;e.remove(),n.remove(),this.editorDOM.insertBefore(t?e:n,this.editorDOM.firstChild),this.editorDOM.appendChild(t?n:e),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let t=!!this.revertDOM,n=this.revertToA,o=this.renderRevert;"revertControls"in e&&(t=!!e.revertControls,n="b-to-a"==e.revertControls),"renderRevertControl"in e&&(o=e.renderRevertControl),this.setupRevertControls(t,n,o)}let t="highlightChanges"in e,n="gutter"in e,o="collapseUnchanged"in e;if(t||n||o){let r=[],a=[];if(t||n){let o=this.a.state.facet(oy),s=n?!1!==e.gutter:o.markGutter,i=t?!1!==e.highlightChanges:o.highlightChanges;r.push(Py.reconfigure([oy.of({side:"a",sibling:()=>this.b,highlightChanges:i,markGutter:s}),s?py:[]])),a.push(Py.reconfigure([oy.of({side:"b",sibling:()=>this.a,highlightChanges:i,markGutter:s}),s?py:[]]))}if(o){let t=_y.reconfigure(e.collapseUnchanged?Ty(e.collapseUnchanged):[]);r.push(t),a.push(t)}this.a.dispatch({effects:r}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,t,n){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=n,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener("mousedown",(e=>this.revertClicked(e))),this.revertDOM.className="cm-merge-revert"):this.revertDOM&&(this.revertDOM.textContent="")}scheduleMeasure(){if(this.measuring<0){let e=this.dom.ownerDocument.defaultView||window;this.measuring=e.requestAnimationFrame((()=>{this.measuring=-1,this.measure()}))}}measure(){!function(e,t,n){let o=new Lt,r=new Lt,a=e.state.field(Cy).iter(),s=t.state.field(Cy).iter(),i=0,l=0,c=0,d=0;for(let m=0;;m++){let u=m<n.length?n[m]:null;if(i<(u?u.fromA:e.state.doc.length)){let n=e.lineBlockAt(i).top+c-(t.lineBlockAt(l).top+d);n<-.01?(c-=n,o.add(i,i,Rt.widget({widget:new Ny(-n),block:!0,side:-1}))):n>jy&&(d+=n,r.add(l,l,Rt.widget({widget:new Ny(n),block:!0,side:-1})))}if(!u)break;for(i=u.toA,l=u.toB;a.value&&a.from<i;)c-=a.value.spec.widget.height,a.next();for(;s.value&&s.from<l;)d-=s.value.spec.widget.height,s.next()}for(;a.value;)c-=a.value.spec.widget.height,a.next();for(;s.value;)d-=s.value.spec.widget.height,s.next();let u=e.contentHeight+c-(t.contentHeight+d);u<jy?o.add(e.state.doc.length,e.state.doc.length,Rt.widget({widget:new Ny(-u),block:!0,side:1})):u>jy&&r.add(t.state.doc.length,t.state.doc.length,Rt.widget({widget:new Ny(u),block:!0,side:1}));let h=o.finish(),f=r.finish();Vo.eq([h],[e.state.field(Cy)])||e.dispatch({effects:Ey.of(h)}),Vo.eq([f],[t.state.field(Cy)])||t.dispatch({effects:Ey.of(f)})}(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,n=this.a.viewport,o=this.b.viewport;for(let r=0;r<this.chunks.length;r++){let a=this.chunks[r];if(a.fromA>n.to||a.fromB>o.to)break;if(a.fromA<n.from||a.fromB<o.from)continue;let s=this.a.lineBlockAt(a.fromA).top+"px";for(;t&&+t.dataset.chunk<r;)t=Fy(t);t&&t.dataset.chunk==String(r)?(t.style.top!=s&&(t.style.top=s),t=t.nextSibling):e.insertBefore(this.renderRevertButton(s,r),t)}for(;t;)t=Fy(t)}renderRevertButton(e,t){let n;if(this.renderRevert)n=this.renderRevert();else{n=document.createElement("button");let e=this.a.state.phrase("Revert this chunk");n.setAttribute("aria-label",e),n.setAttribute("title",e),n.textContent=this.revertToLeft?"⇜":"⇝"}return n.style.top=e,n.setAttribute("data-chunk",String(t)),n}revertClicked(e){let t,n=e.target;for(;n&&n.parentNode!=this.revertDOM;)n=n.parentNode;if(n&&(t=this.chunks[n.dataset.chunk])){let[n,o,r,a,s,i]=this.revertToA?[this.b,this.a,t.fromB,t.toB,t.fromA,t.toA]:[this.a,this.b,t.fromA,t.toA,t.fromB,t.toB],l=n.state.sliceDoc(r,Math.max(r,a-1));r!=a&&i<=o.state.doc.length&&(l+=n.state.lineBreak),o.dispatch({changes:{from:s,to:Math.min(o.state.doc.length,i),insert:l},userEvent:"revert"}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}}function Fy(e){let t=e.nextSibling;return e.remove(),t}var Ly=["className","children","orientation","revertControls","highlightChanges","gutter","collapseUnchanged","destroyRerender","renderRevertControl"],zy=["modified","modifiedExtension","original","originalExtension","theme","dispatch"],By=u.forwardRef(((e,t)=>{var{className:n,children:o,orientation:a,revertControls:s,highlightChanges:i,gutter:l,collapseUnchanged:c,destroyRerender:d=!0,renderRevertControl:u}=e,h=zo(e,Ly),f=Cx(),{modified:p,modifiedExtension:g,original:v,originalExtension:x,theme:y,dispatch:b}=f,w=zo(f,zy),k=r.useRef(null),N=r.useRef(),E={orientation:a,revertControls:s,highlightChanges:i,gutter:l,collapseUnchanged:c,renderRevertControl:u};r.useImperativeHandle(t,(()=>({container:k.current,view:N.current,modified:p,original:v,config:Kn({a:v,b:p,parent:k.current},E)})),[k,N,p,v,E]);var C=Dt.updateListener.of((e=>{if(e.docChanged&&"function"==typeof(null==x?void 0:x.onChange)){var t=e.state.doc.toString();null==x||x.onChange(t,e)}})),j=Dt.updateListener.of((e=>{if(e.docChanged&&"function"==typeof(null==g?void 0:g.onChange)){var t=e.state.doc.toString();null==g||g.onChange(t,e)}}));r.useEffect((()=>{!N.current&&k.current&&x&&g&&(N.current=new Ry(Kn({a:Kn({},v,{extensions:[...(null==x?void 0:x.extension)||[],...Bo(Kn({},null==x?void 0:x.option,{theme:y})),C]}),b:Kn({},p,{extensions:[...(null==g?void 0:g.extension)||[],...Bo(Kn({},null==g?void 0:g.option,{theme:y})),j]}),parent:k.current},E)),b({view:N.current}))}),[N,k,x,g]),r.useEffect((()=>{if(v&&v.doc&&N.current){var e,t,n=null==(e=N.current)?void 0:e.a.state.doc.toString();if(n!==v.doc)null==(t=N.current)||t.a.dispatch({changes:{from:0,to:n.length,insert:v.doc||""}})}if(p&&p.doc&&N.current){var o,r,a=null==(o=N.current)?void 0:o.b.state.doc.toString();if(a!==p.doc)null==(r=N.current)||r.b.dispatch({changes:{from:0,to:a.length,insert:p.doc||""}})}if(d&&N.current){var s=N.current.a.state.selection.ranges[0].from,i=N.current.b.state.selection.ranges[0].from;N.current.destroy(),N.current=new Ry(Kn({a:Kn({},v,{extensions:[...(null==x?void 0:x.extension)||[],...Bo(Kn({},null==x?void 0:x.option,{theme:y}))]}),b:Kn({},p,{extensions:[...(null==g?void 0:g.extension)||[],...Bo(Kn({},null==g?void 0:g.option,{theme:y}))]}),parent:k.current},E)),s&&(N.current.a.focus(),N.current.a.dispatch({selection:{anchor:s,head:s}})),i&&(N.current.b.focus(),N.current.b.dispatch({selection:{anchor:i,head:i}}))}}),[N,y,k.current,v,p,x,g,d]),r.useEffect((()=>()=>N.current&&N.current.destroy()),[]),r.useEffect((()=>{if(N.current){var e={};w.orientation!==a&&(e.orientation=a),w.revertControls!==s&&(e.revertControls=s),w.highlightChanges!==i&&(e.highlightChanges=i),w.gutter!==l&&(e.gutter=l),w.collapseUnchanged!==c&&(e.collapseUnchanged=c),w.renderRevertControl!==u&&(e.collapseUnchanged=c),Object.keys(e).length&&b&&N.current&&(N.current.reconfigure(Kn({},e)),b(Kn({},e)))}}),[b,N,a,s,i,l,c,u]);return m.jsx("div",Kn({ref:k,className:"cm-merge-theme"+(n?" "+n:"")},h,{children:o}))}));By.displayName="CodeMirrorMerge.Internal";var Uy=["theme"],Vy=u.forwardRef(((e,t)=>{var{theme:n}=e,o=zo(e,Uy);return m.jsx(jx,{theme:n,children:m.jsx(By,Kn({},o,{ref:t}))})}));function $y(e){return void 0===e&&(e=[]),Wo({override:[t=>{var n=t.matchBefore(/@(\w+)?/);return n?n&&n.from==n.to&&!t.explicit?null:{from:null==n?void 0:n.from,options:[...e]}:null}]})}function Gy(e){const t=function(e){const t=G.get(qo),n=Yo.keyBy(t,(e=>e.name)),o=e.match(/@([\w.]+)/g)||[];return o.map((e=>e.slice(1))).map((e=>n.get(e))).filter(Boolean)}(e);return U.debug("Included datasets",t),{includeOtherCode:Js(""),context:{schema:t.map((e=>({name:e.name,columns:e.columns.map((e=>({name:e.name,type:e.type})))})))},code:""}}Vy.Original=Ix,Vy.Modified=Mx,Vy.displayName="CodeMirrorMerge",$y();const Hy=[Jo(),Dt.lineWrapping],Wy=[Ko(),Dt.lineWrapping],qy=Xo("marimo:ai-language","python"),Yy=({onClose:e})=>{const{createNewCell:t}=L(),[n,o]=r.useState({}),[a,s]=je(qy),{theme:i}=we(),{completion:l,input:c,stop:d,isLoading:u,setCompletion:h,setInput:f,handleSubmit:p}=Zo({api:Qo("api/ai/completion").toString(),headers:er.headers(),streamMode:"text",body:{...n,language:a},onError:e=>{q({title:"Generate with AI failed",description:tr(e)})}}),g=m.jsxs("div",{className:"flex items-center px-3",children:[m.jsx(bc,{className:"size-4 text-[var(--blue-11)]"}),m.jsxs(xt,{modal:!1,children:[m.jsx(yt,{asChild:!0,children:m.jsxs(b,{variant:"text",className:"ml-2",size:"xs","data-testid":"language-button",children:["python"===a?"Python":"SQL",m.jsx(nr,{className:"ml-1 h-3.5 w-3.5 text-muted-foreground/70"})]})}),m.jsxs(bt,{align:"center",children:[m.jsx(St,{onClick:()=>s("python"),children:"Python"}),m.jsx(St,{onClick:()=>s("sql"),children:"SQL"})]})]}),m.jsx(Jy,{theme:i,onClose:()=>{h(""),e()},value:c,onChange:e=>{f(e),o(Gy(e))},onSubmit:()=>{u||p()}}),u&&m.jsxs(b,{"data-testid":"stop-completion-button",variant:"text",size:"sm",className:"mb-0",onClick:d,children:[m.jsx(or,{className:"animate-spin mr-1",size:14}),"Stop"]}),!u&&l&&m.jsx(b,{"data-testid":"accept-completion-button",variant:"text",size:"sm",className:"mb-0",disabled:u,onClick:()=>{t({cellId:"__end__",before:!1,code:"python"===a?l:Co.fromQuery(l)}),h(""),e()},children:m.jsx("span",{className:"text-[var(--grass-11)] opacity-100",children:"Accept"})}),m.jsx(b,{variant:"text",size:"sm",className:"mb-0",onClick:e,children:m.jsx(Bt,{className:"size-4"})})]});return m.jsxs("div",{className:$t("flex flex-col w-full gap-2 py-2"),children:[g,!l&&m.jsxs("span",{className:"text-xs text-muted-foreground px-3 flex flex-col gap-1",children:[m.jsxs("span",{children:["You can mention"," ",m.jsx("span",{className:"text-[var(--cyan-11)]",children:"@dataframe"})," or"," ",m.jsx("span",{className:"text-[var(--cyan-11)]",children:"@sql_table"})," to pull additional context such as column names."]}),m.jsx("span",{children:"Code from other cells is automatically included."})]}),l&&m.jsx(rr,{value:l,className:"cm border-t",onChange:h,theme:"dark"===i?"dark":"light",extensions:"python"===a?Hy:Wy})]})},Jy=({value:e,inputRef:t,onChange:n,onSubmit:o,onClose:a,theme:s})=>{const i=o,l=a,c=X(qo),d=r.useMemo((()=>[$y(c.map((e=>({label:`@${e.name}`,info:()=>{const t=[null==e.num_rows?void 0:`${e.num_rows} rows`,null==e.num_columns?void 0:`${e.num_columns} columns`].filter(Boolean).join(", "),n=document.createElement("div");if(n.classList.add("prose","prose-sm","dark:prose-invert"),t){const e=document.createElement("div");e.textContent=t,e.style.fontWeight="bold",n.append(e)}if(e.source){const t=document.createElement("figcaption");t.textContent=`Source: ${e.source}`,n.append(t)}if(e.columns){const t=document.createElement("table"),o=t.insertRow(),r=o.insertCell();r.textContent="Column",r.style.fontWeight="bold";const a=o.insertCell();a.textContent="Type",a.style.fontWeight="bold",e.columns.forEach((e=>{const n=t.insertRow();n.insertCell().textContent=e.name;n.insertCell().textContent=e.type})),n.append(t)}return n}})))),Dt.lineWrapping,ar(),nn.highest(Qt.of([{preventDefault:!0,stopPropagation:!0,any:(e,t)=>{const n=t.metaKey||t.ctrlKey||t.shiftKey;if("Enter"===t.key&&!n)return i(),t.preventDefault(),t.stopPropagation(),!0;if("Enter"===t.key&&t.shiftKey){const n=e.state.selection.main.from;return e.dispatch({changes:{from:n,to:n,insert:"\n"},selection:{anchor:n+1,head:n+1}}),t.preventDefault(),t.stopPropagation(),!0}return!1}}])),Qt.of([{key:"Escape",preventDefault:!0,stopPropagation:!0,run:()=>(l(),!0)}])]),[c,i,l]);return m.jsx(rr,{ref:t,className:"flex-1 font-sans overflow-auto my-1",autoFocus:!0,width:"100%",value:e,basicSetup:!1,extensions:d,onChange:n,theme:"dark"===s?"dark":"light",placeholder:"Generate with AI"})},Ky=Vy.Original,Xy=Vy.Modified,Zy=[Jo(),Dt.lineWrapping],Qy=({onChange:e,initialPrompt:t,currentLanguageAdapter:n,currentCode:o,declineChange:a,acceptChange:s,enabled:i,children:l})=>{const[c,d]=r.useState({}),[h,f]=je(Zc),{completion:g,input:v,stop:x,isLoading:y,setCompletion:w,setInput:k,handleSubmit:N}=Zo({api:Qo("api/ai/completion").toString(),headers:er.headers(),initialInput:t,streamMode:"text",body:{...c,includeOtherCode:h?Js(o):"",code:o,language:n},onError:e=>{q({title:"Completion failed",description:tr(e)})}}),E=u.useRef(null);r.useEffect((()=>{var e;i&&E.current&&(null==(e=E.current.view)||e.focus(),sr(E.current.view))}),[i]),r.useEffect((()=>{i&&k(t||"")}),[i,t,k]);const{theme:C}=we();return m.jsxs("div",{className:"flex flex-col w-full rounded-[inherit] overflow-hidden",children:[m.jsx("div",{className:$t("flex items-center gap-2 border-b px-3 transition-all rounded-[inherit] rounded-b-none duration-300 overflow-hidden",i&&"max-h-[400px] min-h-11 visible",!i&&"max-h-0 min-h-0 invisible"),children:i&&m.jsxs(m.Fragment,{children:[m.jsx(bc,{className:"text-[var(--blue-10)] flex-shrink-0",size:16}),m.jsx(Jy,{inputRef:E,theme:C,onClose:()=>{a(),w("")},value:v,onChange:e=>{k(e),d(Gy(e))},onSubmit:()=>{y||N()}}),y&&m.jsxs(b,{"data-testid":"stop-completion-button",variant:"text",size:"xs",className:"mb-0",onClick:x,children:[m.jsx(or,{className:"animate-spin mr-1",size:14}),"Stop"]}),!y&&g&&m.jsx(b,{"data-testid":"accept-completion-button",variant:"text",size:"xs",className:"mb-0",disabled:y,onClick:()=>{s(g),w("")},children:m.jsx("span",{className:"text-[var(--grass-11)] opacity-100",children:"Accept"})}),m.jsx("div",{className:"h-full w-px bg-border mx-2"}),m.jsx(p,{content:"Include code from other cells",children:m.jsxs("div",{className:"flex flex-row items-start gap-1 overflow-hidden",children:[m.jsx(ir,{"data-testid":"include-other-cells-checkbox",id:"include-other-cells",checked:h,onCheckedChange:e=>f(Boolean(e))}),m.jsx(ae,{htmlFor:"include-other-cells",className:"text-muted-foreground text-xs whitespace-nowrap ellipsis",children:"Include all code"})]})}),m.jsx(b,{"data-testid":"decline-completion-button",variant:"text",size:"icon",disabled:y,onClick:()=>{x(),a(),w("")},children:m.jsx(Bt,{className:"text-[var(--red-10)]",size:16})})]})}),g&&i&&m.jsxs(Vy,{className:"cm",theme:C,children:[m.jsx(Ky,{onChange:e,value:o,extensions:Zy}),m.jsx(Xy,{value:g,editable:!1,readOnly:!0,extensions:Zy})]}),(!g||!i)&&l]})};const eb=u.forwardRef(((e,t)=>{const{className:n,editorView:o}=e,a=r.useRef(null);return r.useEffect((()=>{null!==o&&null!==a.current&&0===a.current.children.length&&a.current.append(o.dom)}),[o,a]),m.jsx("div",{className:$t("cm",n),ref:Kp(t,a),"data-testid":"cell-editor"})}));eb.displayName="CellCodeMirrorEditor";const tb=r.memo((({theme:e,showPlaceholder:t,allowFocus:n,id:o,code:a,status:s,serializedEditorState:i,runCell:l,updateCellCode:c,createNewCell:d,deleteCell:u,focusCell:h,moveCell:f,moveToNextCell:p,updateCellConfig:g,clearSerializedEditorState:v,userConfig:x,editorViewRef:y,hidden:b,setTemporarilyVisible:w})=>{var k;const[N,E]=je(Xc),[C,j]=r.useState(),S=function(){const e=Z(rd);return t=>{be!==t&&e(t)}}(),I=r.useRef(null),A="running"===s||"queued"===s,{sendToTop:M,sendToBottom:T}=L(),O=function(){const{splitCell:e,undoSplitCell:t}=L();return R((n=>{const o=lr(n.cellId),r=(null==o?void 0:o.state.doc.toString())??"";e(n);const{dismiss:a}=q({title:"Cell split",action:m.jsx(Qc,{"data-testid":"undo-split-button",size:"sm",variant:"outline",onClick:()=>{t({...n,snapshot:r}),a()},children:"Undo"})})}))}(),D=R((()=>!A&&(u({cellId:o}),!0))),_=r.useCallback((()=>d({cellId:o,before:!1})),[o,d]),P=r.useCallback((()=>d({cellId:o,before:!0})),[o,d]),F=r.useCallback((()=>f({cellId:o,before:!1})),[o,f]),z=r.useCallback((()=>f({cellId:o,before:!0})),[o,f]),B=r.useCallback((()=>h({cellId:o,before:!1})),[o,h]),U=r.useCallback((()=>h({cellId:o,before:!0})),[o,h]),V=R((()=>{const e=!b;return ye({configs:{[o]:{hide_code:e}}}),g({cellId:o,config:{hide_code:e}}),e})),$=X(ee),G=R((()=>{nd($,d)})),H=cr(x),W=r.useMemo((()=>{const n=(e=>{const{cellId:t,cellMovementCallbacks:n,cellCodeCallbacks:o,keymapConfig:r,hotkeys:a}=e;return[ti(r,n),vn(t,n,a),xn(t,o,a),mp(e),[dp,(s=(e,t)=>{fn(e,t)},Ft.define((e=>new up(e,s)))),Dt.baseTheme({".underline":{textDecoration:"underline",cursor:"pointer",color:"var(--link)"}})]];var s})({cellId:o,showPlaceholder:t,enableAI:H,cellCodeCallbacks:{updateCellCode:c,afterToggleMarkdown:G},cellMovementCallbacks:{onRun:l,deleteCell:D,createAbove:P,createBelow:_,moveUp:z,moveDown:F,focusUp:U,focusDown:B,sendToTop:M,sendToBottom:T,splitCell:O,moveToNextCell:p,toggleHideCode:V,aiCellCompletion:()=>{let e=!1;return E((t=>(null==t?void 0:t.cellId)===o?(e=!0,null):{cellId:o})),e}},completionConfig:x.completion,keymapConfig:x.keymap,theme:e,hotkeys:new dr(x.keymap.overrides??{})});return n.push(Ft.define((e=>{const t=e.state.field(ur);return j(t.type),{update(e){const t=e.state.field(ur);j(t.type)}}}))),n}),[o,x.keymap,x.completion,H,e,t,P,_,U,B,z,F,p,M,T,O,V,c,D,l,E,G]);r.useEffect((()=>{let e;null===i?null===y.current?(y.current=new Dt({state:Un.create({doc:a,extensions:W})}),e=!0,Lo(y.current,hr(y.current.state).type)):(y.current.dispatch({effects:[_t.reconfigure.of([W]),fr(y.current,x.completion,new dr(x.keymap.overrides??{}))]}),e=!1):(y.current=new Dt({state:Un.fromJSON(i,{doc:a,extensions:W},{history:mr})}),Lo(y.current,hr(y.current.state).type),e=!0,v({cellId:o})),null!==y.current&&null!==I.current&&I.current.replaceChildren(y.current.dom),e&&n&&requestAnimationFrame((()=>{var e,t;null==(e=y.current)||e.focus(),null==(t=y.current)||t.dom.scrollIntoView({behavior:"smooth",block:"nearest"})}))}),[y,W,x.completion,x.keymap,v,o,i]),r.useEffect((()=>()=>{var e;null==(e=y.current)||e.destroy()}),[y]);const Y=r.useCallback((async()=>{var e,t;if(b&&void 0!==w){w(!0),null==(e=y.current)||e.focus();const n=null==(t=I.current)?void 0:t.parentElement,o=new AbortController;null==n||n.addEventListener("focusout",(()=>{requestAnimationFrame((()=>{var e;const t=document.activeElement;(null==n?void 0:n.contains(t))||(w(!1),null==(e=y.current)||e.dom.blur(),o.abort())}))}),{signal:o.signal})}}),[b,w,y,I]);return m.jsx(Qy,{enabled:(null==N?void 0:N.cellId)===o,initialPrompt:null==N?void 0:N.initialPrompt,currentCode:(null==(k=y.current)?void 0:k.state.doc.toString())??a,currentLanguageAdapter:C,declineChange:()=>{var e;E(null),null==(e=y.current)||e.focus()},onChange:e=>{var t;null==(t=y.current)||t.dispatch({changes:{from:0,to:y.current.state.doc.length,insert:e}})},acceptChange:e=>{var t,n;null==(t=y.current)||t.dispatch({changes:{from:0,to:y.current.state.doc.length,insert:e}}),null==(n=y.current)||n.focus(),E(null)},children:m.jsxs("div",{className:"relative w-full",onFocus:()=>S(o),children:[b&&m.jsx(pr,{onClick:Y}),m.jsx(eb,{className:$t(b&&"opacity-20 h-8 overflow-hidden"),editorView:y.current,ref:I}),!b&&m.jsx("div",{className:"absolute top-1 right-5",children:m.jsx(bx,{code:a,editorView:y.current,currentLanguageAdapter:C,onAfterToggle:G})})]})})})),nb=e=>m.jsxs("div",{className:"flex items-center gap-2 w-full px-3",children:[m.jsx("div",{className:"flex-1 flex item-center gap-2",children:e.left}),m.jsx("div",{className:"flex-1 flex item-center gap-2 justify-center",children:e.center}),m.jsx("div",{className:"flex-1 flex item-center gap-2 justify-end",children:e.right})]}),ob=e=>e.canCollapse||e.isCollapsed?m.jsx(b,{variant:"text",size:"icon",onClick:e.onClick,children:m.jsx(p,{content:e.isCollapsed?"Expand":"Collapse",children:m.jsx(rb,{isCollapsed:e.isCollapsed})})}):null,rb=({isCollapsed:e})=>e?m.jsx(gr,{className:"w-5 h-5 flex-shrink-0"}):m.jsx(ge,{className:"w-5 h-5 flex-shrink-0"}),ab=r.memo((({onClick:e,count:t,cellId:n})=>{const o=P(),r=vr(o,n);return m.jsx("div",{onClick:e,className:$t("flex items-center justify-between w-[calc(100%-2rem)] h-9 bg-muted rounded-b mx-4 opacity-80 hover:opacity-100 cursor-pointer"),children:m.jsx(nb,{center:m.jsxs(m.Fragment,{children:[m.jsx(nr,{className:"w-4 h-4 flex-shrink-0"}),m.jsxs("span",{className:"text-sm text-gray-500",children:[t," ",1===t?"cell":"cells"," collapsed"]})]}),right:m.jsxs(m.Fragment,{children:[r.errored&&m.jsx(p,{content:"Has errors",delayDuration:100,children:m.jsx(ac,{className:"w-4 h-4 flex-shrink-0 text-destructive"})}),r.stale&&m.jsx(p,{content:"Has stale cells",delayDuration:100,children:m.jsx(xr,{className:"w-4 h-4 flex-shrink-0 text-[var(--yellow-11)]"})}),r.runningOrQueued&&m.jsx(p,{content:"Running",delayDuration:100,children:m.jsx(or,{className:"w-4 h-4 flex-shrink-0 animate-spin"})})]})})})}));ab.displayName="CollapsedCellBanner";const sb=e=>{const{appClosed:t,status:n}=e,o=Wd("running"===n);return m.jsx($p,{tooltip:Ds("global.interrupt"),disabled:t||!o,onClick:o?yr:Gt.NOOP,variant:o?"stale":"disabled","data-testid":"run-button",children:m.jsx(N,{strokeWidth:1.5})})},ib=({edited:e,appClosed:t,status:n,cellConfig:o,needsRun:r,hasOutput:a,onRun:s,cellActionDropdownRef:i,cellId:l,getEditorView:c,name:d})=>m.jsxs(Gp,{className:$t(!r&&"hover-action"),children:[m.jsx(Hp,{edited:e,onClick:t?Gt.NOOP:s,appClosed:t,status:n,config:o,needsRun:r}),m.jsx(sb,{status:n,appClosed:t}),m.jsx(vx,{ref:i,cellId:l,status:n,getEditorView:c,name:d,config:o,hasOutput:a,children:m.jsx($p,{variant:"green",tooltip:null,children:m.jsx(Ci,{strokeWidth:1.5})})})]}),lb=r.memo(r.forwardRef((({theme:e,showPlaceholder:t,allowFocus:n,id:o,code:a,output:s,consoleOutputs:i,status:l,runStartTimestamp:c,runElapsedTimeMs:d,edited:u,interrupted:h,errored:f,stopped:p,staleInputs:g,serializedEditorState:v,mode:x,debuggerActive:y,appClosed:b,showDeleteButton:w,updateCellCode:k,prepareForRun:N,createNewCell:E,deleteCell:C,focusCell:j,moveCell:S,setStdinResponse:I,moveToNextCell:A,updateCellConfig:M,clearSerializedEditorState:T,sendToBottom:O,sendToTop:D,collapseCell:_,expandCell:P,userConfig:F,outline:L,isCollapsed:V,collapseCount:$,config:G,canMoveX:H,name:W},q)=>{U.debug("Rendering Cell",o);const Y=r.useRef(null),J=r.useRef(null),K=r.useRef(null),X=Z(Xc),[Q,ee]=r.useState(!1),te=G.disabled||"disabled-transitively"===l,ne=br(F.runtime.auto_instantiate,d,l,f,h,p),oe=ne||u||h||g&&!te,re="running"===l||"queued"===l,ae=wr({status:l,output:s,runStartTimestamp:c,interrupted:h,staleInputs:g},u),se=("queued"===l||u||g)&&!h,ie="edit"===x,ce=r.useCallback((()=>{const e=pp(K),t=z(e);return"markdown"!==le(e)&&kr(e),N({cellId:o}),t}),[o,K,N]);r.useImperativeHandle(q,(()=>({get editorView(){return pp(K)},registerRun:ce})),[K,ce]);const de=r.useCallback((()=>K.current),[K]),ue=R((async()=>{if(re)return;const e=ce();await B({cellIds:[o],codes:[e]}).catch((e=>{U.error("Error running cell",e)}))})),he=r.useCallback(((e={})=>E({cellId:o,before:!1,...e})),[o,E]),fe=r.useCallback(((e={})=>E({cellId:o,before:!0,...e})),[o,E]),me=r.useCallback((e=>{null===Y.current||Y.current.contains(e.relatedTarget)||null===K.current||kr(K.current)}),[]),pe=r.useCallback((e=>{if(Y.current===document.activeElement&&null!==K.current&&"active"===ln(K.current.state)){for(const t of Nr)if(e.key===t.key&&t.run){t.run(K.current),e.preventDefault(),e.stopPropagation();break}K.current.focus()}}),[Y,K]),ge=!Er(s),ve=ge&&m.jsxs("div",{className:"relative",children:[m.jsx("div",{className:"absolute top-5 -left-8 z-10 print:hidden",children:m.jsx(ob,{isCollapsed:V,onClick:()=>{V?P({cellId:o}):_({cellId:o})},canCollapse:Cr(L)})}),m.jsx(jr,{allowExpand:ie,output:s,className:"output-area",cellId:o,stale:ae})]}),xe=Sr("Cell","hover-actions-parent z-10",{published:!ie,interactive:ie,"needs-run":oe,"has-error":f,stopped:p,disabled:G.disabled,stale:"disabled-transitively"===l}),be=Qe.create(o);if(oi(ie?Y.current:null,{"cell.run":ue,"cell.runAndNewBelow":()=>{ue(),A({cellId:o,before:!1})},"cell.runAndNewAbove":()=>{ue(),A({cellId:o,before:!0})},"cell.createAbove":fe,"cell.createBelow":he,"cell.moveUp":()=>S({cellId:o,before:!0}),"cell.moveDown":()=>S({cellId:o,before:!1}),"cell.hideCode":()=>{var e,t,n;const r=!G.hide_code;ye({configs:{[o]:{hide_code:r}}}),M({cellId:o,config:{hide_code:r}}),r?(null==(e=K.current)||e.contentDOM.blur(),null==(t=Y.current)||t.focus()):null==(n=K.current)||n.focus()},"cell.focusDown":()=>A({cellId:o,before:!1}),"cell.focusUp":()=>A({cellId:o,before:!0}),"cell.sendToBottom":()=>O({cellId:o}),"cell.sendToTop":()=>D({cellId:o}),"cell.aiCompletion":()=>{let e=!1;X((t=>(null==t?void 0:t.cellId)===o?(e=!0,null):{cellId:o})),e&&pp(K).focus()},"cell.cellActions":()=>{var e;null==(e=J.current)||e.toggle()}}),ri(ie?Y.current:null,{ArrowDown:()=>(A({cellId:o,before:!1,noCreate:!0}),!0),ArrowUp:()=>(A({cellId:o,before:!0,noCreate:!0}),!0),..."vim"===F.keymap.preset&&G.hide_code?{j:()=>(A({cellId:o,before:!1,noCreate:!0}),!0),k:()=>(A({cellId:o,before:!0,noCreate:!0}),!0)}:{}}),!ie){const e=Ir(null==s?void 0:s.mimetype);return f||h||p||e?null:m.jsx("div",{tabIndex:-1,id:be,ref:Y,className:xe,children:ve})}return m.jsx(yx,{cellId:o,config:G,status:l,getEditorView:de,hasOutput:ge,name:W,children:m.jsxs(gx,{tabIndex:-1,ref:Y,"data-status":l,onBlur:me,onKeyDown:pe,cellId:o,canMoveX:H,title:G.disabled?"This cell is disabled":"disabled-transitively"===l?"This cell has a disabled ancestor":void 0,children:[m.jsxs("div",{className:xe,id:be,children:["above"===F.display.cell_output&&ve,m.jsxs("div",{className:"tray",children:[m.jsx("div",{className:"absolute right-2 -top-4 z-10",children:m.jsx(ib,{edited:u,appClosed:b,status:l,cellConfig:G,needsRun:oe,hasOutput:ge,cellActionDropdownRef:J,cellId:o,name:W,getEditorView:de,onRun:ue})}),m.jsxs("div",{className:"absolute flex flex-col gap-[2px] justify-center h-full left-[-34px] z-20",children:[m.jsx(Bp,{tooltipContent:Ds("cell.createAbove"),appClosed:b,onClick:b?void 0:fe}),m.jsx("div",{className:"flex-1"}),m.jsx(Bp,{tooltipContent:Ds("cell.createBelow"),appClosed:b,onClick:b?void 0:he})]}),m.jsx(tb,{theme:e,showPlaceholder:t,allowFocus:n,id:o,code:a,status:l,serializedEditorState:v,runCell:ue,updateCellCode:k,createNewCell:E,deleteCell:C,focusCell:j,moveCell:S,moveToNextCell:A,updateCellConfig:M,clearSerializedEditorState:T,userConfig:F,editorViewRef:K,hidden:G.hide_code&&!Q,setTemporarilyVisible:ee}),m.jsxs("div",{className:"shoulder-right z-20",children:[m.jsx(qp,{status:l,staleInputs:g,interrupted:h,editing:ie,edited:u,disabled:G.disabled??!1,elapsedTime:d,runStartTimestamp:c,uninstantiated:ne}),m.jsx("div",{className:"flex gap-2 items-end",children:m.jsx(mx,{})})]}),m.jsx("div",{className:"shoulder-bottom hover-action",children:w?m.jsx(Wp,{appClosed:b,status:l,onClick:()=>{re||b||C({cellId:o})}}):null})]}),"below"===F.display.cell_output&&ve,m.jsx(Ji,{consoleOutputs:i,stale:se,cellName:W,onRefactorWithAI:e=>{X({cellId:o,initialPrompt:e.prompt})},onSubmitDebugger:(e,t)=>{I({cellId:o,response:e,outputIndex:t}),Ar({text:e})},cellId:o,debuggerActive:y})]}),V&&m.jsx(ab,{onClick:()=>P({cellId:o}),count:$,cellId:o})]})})}))),cb=({width:e})=>{const{banners:t}=Ki(),{removeBanner:n}=Xi();return 0===t.length?null:m.jsx("div",{className:$t("flex flex-col gap-4 mb-5 print:hidden","columns"===e&&"sticky left-12 w-full max-w-[80vw]"),children:t.map((e=>m.jsxs(Mr,{kind:e.variant||"info",className:"flex flex-col rounded p-3",children:[m.jsxs("div",{className:"flex justify-between",children:[m.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[m.jsx(Tr,{className:"w-5 h-5 inline-block mr-2"}),e.title]}),m.jsx(b,{"data-testid":"remove-banner-button",variant:"text",size:"icon",onClick:()=>n(e.id),children:m.jsx(Bt,{className:"w-5 h-5"})})]}),m.jsxs("div",{className:"flex justify-between items-end",children:[m.jsx("span",{children:Or({html:e.description})}),"restart"===e.action&&m.jsx(db,{})]})]},e.id)))})},db=()=>{const e=md();return m.jsxs(b,{"data-testid":"restart-session-button",variant:"link",size:"xs",onClick:e,children:[m.jsx(mc,{className:"w-3 h-3 mr-2"}),"Restart"]})};const ub=(e,t)=>function(e,t){const n=/^(\d+)\.(\d+)\.(\d+)(?:-([\w.-]+))?(?:\+([\w.-]+))?$/,o=e=>{const t=e.match(n);if(!t)return null;const[,o,r,a,s]=t;return{major:Number.parseInt(o,10),minor:Number.parseInt(r,10),patch:Number.parseInt(a,10),preRelease:s||""}};try{const n=o(e),r=o(t);return n&&r?n.major!==r.major?n.major-r.major:n.minor!==r.minor?n.minor-r.minor:n.patch!==r.patch?n.patch-r.patch:""===n.preRelease&&""!==r.preRelease?1:""!==n.preRelease&&""===r.preRelease?-1:n.preRelease.localeCompare(r.preRelease):e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}catch{return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}}(t,e);const hb=()=>{const{packageAlert:e}=Zi(),{clearPackageAlert:t}=Qi(),[n]=ke(),[o,a]=r.useState({});if(null===e)return null;const s="pixi"!==n.package_management.manager;if(el(e))return m.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-[200] opacity-95",children:m.jsxs(Mr,{kind:"danger",className:"flex flex-col rounded py-3 px-5 animate-in slide-in-from-left",children:[m.jsxs("div",{className:"flex justify-between",children:[m.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[m.jsx(ic,{className:"w-5 h-5 inline-block mr-2"}),"Missing packages"]}),m.jsx(b,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:()=>t(e.id),children:m.jsx(Bt,{className:"w-5 h-5"})})]}),m.jsxs("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:[m.jsxs("div",{children:[m.jsx("p",{children:"The following packages were not found:"}),m.jsx("ul",{className:"list-disc ml-4 mt-1",children:e.packages.map(((e,t)=>m.jsxs("li",{className:"flex items-center gap-1 font-mono text-sm",children:[m.jsx(Al,{size:"1rem"}),e,s&&m.jsx(gb,{value:o[e]??"latest",onChange:t=>a((n=>({...n,[e]:t}))),packageName:e})]},t)))})]}),m.jsx("div",{className:"ml-auto flex flex-row items-baseline",children:e.isolated?m.jsxs(m.Fragment,{children:[m.jsx(mb,{manager:n.package_management.manager,versions:o,clearPackageAlert:()=>t(e.id)}),!C()&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"px-2 text-sm",children:"with"})," ",m.jsx(pb,{})]})]}):m.jsxs("p",{children:["If you set up a"," ",m.jsx("a",{href:"https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments",className:"text-accent-foreground hover:underline",target:"_blank",rel:"noreferrer",children:"virtual environment"}),", marimo can install these packages for you."]})})]})]})});if(tl(e)){const{status:n,title:o,titleIcon:r,description:a}=function(e){const t=new Set(Object.values(e)),n=t.has("queued")||t.has("installing")?"installing":t.has("failed")?"failed":"installed";if("installing"===n)return{status:"installing",title:"Installing packages",titleIcon:m.jsx(Rl,{className:"w-5 h-5 inline-block mr-2"}),description:"Installing packages:"};if("installed"===n)return{status:"installed",title:"All packages installed!",titleIcon:m.jsx(sc,{className:"w-5 h-5 inline-block mr-2"}),description:"Installed packages:"};return{status:"failed",title:"Some packages failed to install",titleIcon:m.jsx(ic,{className:"w-5 h-5 inline-block mr-2"}),description:"See terminal for error logs."}}(e.packages);return"installed"===n&&setTimeout((()=>t(e.id)),1e4),m.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-[200] opacity-95",children:m.jsxs(Mr,{kind:"failed"===n?"danger":"info",className:"flex flex-col rounded pt-3 pb-4 px-5",children:[m.jsxs("div",{className:"flex justify-between",children:[m.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[r,o]}),m.jsx(b,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:()=>t(e.id),children:m.jsx(Bt,{className:"w-5 h-5"})})]}),m.jsx("div",{className:$t("flex flex-col gap-4 justify-between items-start text-muted-foreground text-base","installed"===n&&"text-accent-foreground"),children:m.jsxs("div",{children:[m.jsx("p",{children:a}),m.jsx("ul",{className:"list-disc ml-4 mt-1",children:Object.entries(e.packages).map((([e,t],o)=>m.jsxs("li",{className:$t("flex items-center gap-1 font-mono text-sm","installing"===t&&"font-semibold","failed"===t&&"text-destructive","installed"===t&&"text-accent-foreground","installed"===t&&"failed"===n&&"text-muted-foreground"),children:[m.jsx(fb,{status:t}),e]},o)))})]})})]})})}return k(e),null};const fb=({status:e})=>{switch(e){case"queued":return m.jsx(Al,{size:"1rem"});case"installing":return m.jsx(Rl,{size:"1rem"});case"installed":return m.jsx(pt,{size:"1rem"});case"failed":return m.jsx(Bt,{size:"1rem"});default:return k(e),null}},mb=({manager:e,versions:t,clearPackageAlert:n})=>m.jsxs(b,{variant:"outline","data-testid":"install-packages-button",size:"sm",onClick:async()=>{n(),await Dr({manager:e,versions:t}).catch((e=>{U.error(e)}))},children:[m.jsx(Rl,{className:"w-4 h-4 mr-2"}),m.jsx("span",{className:"font-semibold",children:"Install"})]}),pb=()=>{const[e,t]=ke(),n=_r({resolver:Pr(Rr),defaultValues:e});return m.jsx(Fr,{...n,children:m.jsx("form",{onChange:n.handleSubmit((async e=>{await Ee({config:e}).then((()=>{t(e)}))})),className:"flex flex-col gap-5",children:m.jsx("div",{className:"flex flex-col gap-3",children:m.jsx(Lr,{control:n.control,name:"package_management.manager",render:({field:e})=>m.jsxs(zr,{children:[m.jsx(Br,{children:m.jsx(Ur,{"data-testid":"install-package-manager-select",onChange:t=>e.onChange(t.target.value),value:e.value,disabled:e.disabled,className:"inline-flex mr-2",children:Vr.map((e=>m.jsx("option",{value:e,children:e},e)))})}),m.jsx($r,{})]})})})})})},gb=({value:e,onChange:t,packageName:n})=>{const{data:o=[],loading:r,error:a}=Ht((async()=>{const e=await fetch(`https://pypi.org/pypi/${t=n,t.replaceAll(/\[.*]/g,"").trim()}/json`,{method:"GET",signal:AbortSignal.timeout(5e3)});var t;const o=await e.json();return["latest",...Object.keys(o.releases).sort(ub).slice(0,100)]}),[n]);return a?m.jsx(p,{content:"Failed to fetch package versions",children:m.jsx(Ur,{value:e,onChange:e=>t(e.target.value),disabled:!0,className:"inline-flex ml-2",children:m.jsx("option",{value:"latest",children:"latest"})})}):m.jsx(Ur,{value:e,onChange:e=>t(e.target.value),disabled:r,className:"inline-flex ml-2",children:r?m.jsx("option",{value:"latest",children:"latest"}):o.map((e=>m.jsx("option",{value:e,children:e},e)))})},vb=e=>{let{transform:t}=e;return{...t,x:0}},xb={threshold:{x:0,y:.1}},yb=u.memo((({children:e,multiColumn:t})=>{const{cellIds:n}=P(),{dropCellOverCell:o,dropCellOverColumn:a,moveColumn:s,compactColumns:i}=L(),[l,c]=r.useState(null),[d,u]=r.useState(null),[h]=Ne(),f=r.useMemo((()=>"columns"===h.width?Gr.EMPTY:[vb]),[h.width]),p=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.useMemo((()=>[...t].filter((e=>null!=e))),[...t])}(ig(nv,{activationConstraint:{distance:8}}),ig(Xg,{coordinateGetter:ux})),g=R((e=>{c(e.active.id),u(n)})),v=R((()=>{c(null),u(null)})),x=r.useCallback((e=>{const t=e.droppableContainers.filter((e=>wb(e.id)));if(l&&wb(l))return pg({...e,droppableContainers:t});const o=(e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:o}=e;if(!o)return[];const r=[];for(const a of t){const{id:e}=a,t=n.get(e);if(t&&xg(o,t)){const n=hg(t).reduce(((e,t)=>e+cg(o,t)),0),s=Number((n/4).toFixed(4));r.push({id:e,data:{droppableContainer:a,value:s}})}}return r.sort(dg)})({...e,droppableContainers:t}),r=fg(o.length>0?o:vg({...e,droppableContainers:t}),"id");if(!r)return[];At(wb(r),`Expected column id. Got: ${r}`);const a=n.get(r);if(At(a,`Expected column. Got: ${r}`),a&&0===a.topLevelIds.length)return[{id:r}];const s=new Set(a.topLevelIds),i=pg({...e,droppableContainers:e.droppableContainers.filter((e=>e.id!==r&&s.has(e.id)))});if(i.length>0){const e=i[0].id;return At(bb(e),`Expected cell id. Got: ${e}`),[{id:e}]}return[]}),[l,n]),y=R((({active:e,over:t})=>{const n=null==t?void 0:t.id;if(null!=n&&e.id!==n){if(bb(e.id)){if(wb(n))return void a({cellId:e.id,columnId:n});if(bb(n))return void o({cellId:e.id,overCellId:n})}wb(e.id)&&wb(n)&&s({column:e.id,overColumn:n})}})),b=R((e=>{const{active:t,over:n}=e;null!==n&&t.id!==n.id&&i()}));return m.jsx(Bv,{autoScroll:xb,sensors:p,collisionDetection:t?x:pg,modifiers:f,onDragEnd:b,onDragStart:g,onDragCancel:v,onDragOver:y,children:e})}));function bb(e){return"string"==typeof e&&!e.startsWith("tree_")}function wb(e){return"string"==typeof e&&e.startsWith("tree_")}const kb=u.forwardRef((({columnId:e,canDelete:t,canMoveLeft:n,canMoveRight:o,...r},a)=>{const{attributes:s,listeners:i,setNodeRef:l,transform:c,transition:d,isDragging:u,isOver:h}=lx({id:e}),f={transform:c?Yi.Transform.toString({x:c.x,y:0,scaleX:1,scaleY:1}):void 0,transition:d,zIndex:u?2:void 0,position:"relative","--gutter-width":"50px"},g=Kp(a,l),{deleteColumn:v,moveColumn:x,addColumn:y}=L(),w=$t("h-full hover:bg-muted rounded-none"),k=()=>{const e=document.getElementById("App");e&&e.scrollTo({left:e.scrollLeft+1e3,behavior:"smooth"})},N=m.jsxs("div",{className:"h-6 group flex items-center rounded-t-lg border hover:border-border border-[var(--slate-3)] overflow-hidden bg-[var(--slate-1)]",children:[m.jsx(p,{content:"Move column left",side:"top",delayDuration:300,children:m.jsx(b,{variant:"text",size:"sm",className:w,onClick:()=>x({column:e,overColumn:"_left_"}),disabled:!n,children:m.jsx(Hr,{className:"size-4"})})}),m.jsx(p,{content:"Move column right",side:"top",delayDuration:300,children:m.jsx(b,{variant:"text",size:"sm",className:w,onClick:()=>x({column:e,overColumn:"_right_"}),disabled:!o,children:m.jsx(gr,{className:"size-4"})})}),m.jsx("div",{className:"flex gap-2 h-full flex-grow active:bg-accent cursor-grab",...s,...i,"data-testid":"column-drag-button"}),t&&m.jsx(p,{content:"Delete column",side:"top",delayDuration:300,children:m.jsx(b,{variant:"text",size:"sm",className:"opacity-0 group-hover:opacity-70 group-hover:hover:opacity-100 text-destructive h-full hover:bg-destructive/20 rounded-none",onClick:()=>v({columnId:e}),children:m.jsx(Bt,{className:"size-4"})})}),m.jsx(p,{content:"Add column",side:"top",delayDuration:300,children:m.jsx(b,{variant:"text",size:"sm",className:w,onClick:()=>{y({columnId:e}),requestAnimationFrame(k)},children:m.jsx(No,{className:"size-4"})})})]});return m.jsxs("div",{tabIndex:-1,ref:g,...r,style:f,"data-is-dragging":u,className:$t(u?"":r.className,u?"z-20":"z-1 hover:z-10 focus-within:z-10",h&&"bg-accent/20"),children:[N,r.children]})}));kb.displayName="SortableColumn";const Nb=r.memo(kb),Eb=r.memo((e=>{const t=r.useRef(null),n=m.jsx("div",{className:$t("flex flex-col gap-5","columns"===e.width&&"w-contentWidthMedium min-h-[100px] border border-t-0 border-[var(--slate-3)] rounded-b-lg px-11 py-6 bg-[var(--slate-2)]"),children:e.children});return"columns"===e.width?m.jsxs(Nb,{tabIndex:-1,ref:t,canDelete:e.canDelete,columnId:e.columnId,canMoveLeft:e.canMoveLeft,canMoveRight:e.canMoveRight,className:"group/column",children:[n,e.footer]}):m.jsxs(m.Fragment,{children:[n,e.footer]})}));Eb.displayName="Column";const Cb=({notebook:e,mode:t,userConfig:n,appConfig:o,connStatus:a})=>{const s=L(),{theme:i}=we(),{toggleSidebarPanel:l}=wd(),{invisible:c}=nl(e.cellIds.idLength,t);Os("global.focusTop",s.focusTopCell),Os("global.focusBottom",s.focusBottomCell),Os("global.toggleSidebar",l),Os("global.foldCode",s.foldAll),Os("global.unfoldCode",s.unfoldAll),Os("global.formatAll",(()=>{Wr(s.updateCellCode)})),Os("cell.hideCode",Gt.NOOP),Os("cell.format",Gt.NOOP);const d=ed(),u=s.scrollToTarget;r.useEffect((()=>{null!==e.scrollKey&&u()}),[e.cellIds,e.scrollKey,u]);const h=e.cellIds.getColumns(),f=e.cellIds.hasOnlyOneId();return m.jsxs(ol,{className:"pb-[40vh]",invisible:c,appConfig:o,innerClassName:"pr-4",children:[m.jsx(hb,{}),m.jsx(cb,{width:o.width}),m.jsx(yb,{multiColumn:"columns"===o.width,children:m.jsx(tx,{id:"column-container",items:h.map((e=>e.id)),strategy:Jv,children:m.jsx("div",{className:$t("columns"===o.width&&"grid grid-flow-col auto-cols-min gap-6"),children:h.map(((r,l)=>m.jsx(Eb,{columnId:r.id,canMoveLeft:l>0,canMoveRight:l<h.length-1,width:o.width,canDelete:h.length>1,footer:m.jsx(jb,{columnId:r.id,className:$t("columns"===o.width&&"opacity-0 group-hover/column:opacity-100")}),children:m.jsx(tx,{id:`column-${l+1}`,items:r.topLevelIds,strategy:Zv,children:r.topLevelIds.map((l=>{const u=e.cellData[l],h=e.cellRuntime[l];return m.jsx(lb,{theme:i,showPlaceholder:f,allowFocus:!c&&!e.scrollKey,id:u.id,code:u.code,outline:h.outline,output:h.output,consoleOutputs:h.consoleOutputs,status:h.status,edited:u.edited,interrupted:h.interrupted,errored:h.errored,stopped:h.stopped,staleInputs:h.staleInputs,runStartTimestamp:h.runStartTimestamp,runElapsedTimeMs:h.runElapsedTimeMs??u.lastExecutionTime,serializedEditorState:u.serializedEditorState,showDeleteButton:!f&&!u.config.hide_code,mode:t,appClosed:a.state!==wi.OPEN,ref:e.cellHandles[l],userConfig:n,debuggerActive:h.debuggerActive,config:u.config,name:u.name,isCollapsed:r.isCollapsed(l),collapseCount:r.getCount(l),canMoveX:"columns"===o.width,...s,deleteCell:d},u.id.toString())}))})},r.id)))})})}),m.jsx(rl,{})]})},jb=({columnId:e,className:t})=>{const{createNewCell:n}=L(),o=X(ee),[r,a]=qr(!1),s=X(Q),i=X(Yr).sql,l=$t("mb-0 rounded-none sm:px-4 md:px-5 lg:px-8 tracking-wide no-wrap whitespace-nowrap","hover:bg-accent hover:text-accent-foreground font-semibold uppercase text-xs");return m.jsx("div",{className:"flex justify-center mt-4 pt-6 pb-32 group gap-4 w-full print:hidden",children:m.jsx("div",{className:$t("shadow-sm border border-border rounded transition-all duration-200 overflow-hidden divide-x divide-border flex",!r&&"w-fit",r&&"opacity-100 w-full max-w-4xl shadow-lg shadow-[var(--blue-3)]",t),children:r?m.jsx(Yy,{onClose:a.toggle}):m.jsxs(m.Fragment,{children:[m.jsxs(b,{className:l,variant:"text",size:"sm",onClick:()=>n({cellId:{type:"__end__",columnId:e},before:!1}),children:[m.jsx(wc,{className:"mr-2 size-4 flex-shrink-0"}),"Python"]}),m.jsxs(b,{className:l,variant:"text",size:"sm",onClick:()=>{nd(o,n),n({cellId:{type:"__end__",columnId:e},before:!1,code:(new Eo).defaultCode})},children:[m.jsx(Ec,{className:"mr-2 size-4 flex-shrink-0"}),"Markdown"]}),m.jsx(p,{content:i?null:m.jsxs("div",{className:"flex flex-col",children:[m.jsxs("span",{children:["Additional dependencies required:",m.jsx(ai,{className:"inline",children:"pip install marimo[sql]"}),"."]}),m.jsx("span",{children:"You will need to restart the notebook after installing."})]}),delayDuration:100,asChild:!1,children:m.jsxs(b,{className:l,variant:"text",size:"sm",disabled:!i,onClick:()=>{nd(o,n),n({cellId:{type:"__end__",columnId:e},before:!1,code:(new Co).defaultCode})},children:[m.jsx(de,{className:"mr-2 size-4 flex-shrink-0"}),"SQL"]})}),m.jsx(p,{content:s?null:m.jsx("span",{children:"Enable via settings under AI Assist"}),delayDuration:100,asChild:!1,children:m.jsxs(b,{className:l,variant:"text",size:"sm",disabled:!s,onClick:a.toggle,children:[m.jsx(bc,{className:"mr-2 size-4 flex-shrink-0"}),"Generate with AI"]})})]})})})};const Sb=({userConfig:e,appConfig:t})=>{const n=P();Zr(ha,ua.onCellIdsChange);const{setCells:o,updateCellCode:a,mergeAllColumns:s}=L(),i=X(Ze),[l,c]=rt(),[d,u]=r.useState(),h=mi(),{openModal:p,closeModal:g,openAlert:v}=f(),x="edit"===i.mode,y="present"===i.mode,b=X(Qr),w=X(ne);function k(){v("Failed to save notebook: not connected to a kernel.")}r.useEffect((()=>(al.INSTANCE.start(ea),()=>{al.INSTANCE.stop()})),[]);const{connection:N}=sl({autoInstantiate:e.runtime.auto_instantiate,setCells:(e,t)=>{o(e);const n=e.map((e=>e.name)),r=e.map((e=>e.code)),a=e.map((e=>e.config));u({names:n,codes:r,configs:a,layout:t})},sessionId:ta()}),E=R((async e=>N.state!==wi.OPEN?(k(),null):(na((t=>{null===e?t.delete(oa.filePath):t.set(oa.filePath,e)})),ra({filename:e}).then((()=>(c(e),document.title=t.app_title||nt.basename(e)||"Untitled Notebook",e))).catch((e=>(v(e.message),null))))));r.useEffect((()=>{document.title=t.app_title||nt.basename(l??"")||"Untitled Notebook"}),[t.app_title,l]);const C=n.cellIds.colLength,j=Ri(t.width);r.useEffect((()=>{"columns"===j&&"columns"!==t.width&&s()}),[t.width,j,s,C]);const S=aa(n),I=S.map((e=>e.id)),A=S.map((e=>e.code)),M=S.map((e=>e.name)),T=sa(n),O=ia(n,h,d),D=R(((t,n)=>{w||0!==A.length&&(N.state===wi.OPEN?(U.log("saving to ",t),la({cellIds:I,codes:A,names:M,filename:t,configs:T,layout:il(),persist:!0}).then((()=>{n&&(q({title:"Notebook saved"}),e.save.format_on_save&&Wr(a)),u({names:M,codes:A,configs:T,layout:h})}))):k())})),_=R(((e=!1)=>{null!==l&&N.state===wi.OPEN&&D(l,e)})),z=R((()=>{_(!0),null===l&&N.state!==wi.CLOSED&&p(m.jsx(Ib,{onClose:g,onSave:B}))}));!function(e){const{codes:t,cellConfigs:n,config:o,connStatus:a,cellNames:s,needsSave:i,kioskMode:l,onSave:c}=e,d=r.useRef(null);r.useEffect((()=>{if(!l)return"after_delay"===o.save.autosave&&(null!==d.current&&clearTimeout(d.current),i&&a.state===wi.OPEN&&(d.current=setTimeout(c,o.save.autosave_delay))),()=>{null!==d.current&&clearTimeout(d.current)}}),[t,n,s,o.save,a.state,c,l,i])}({onSave:_,needsSave:O,codes:A,cellConfigs:T,cellNames:M,connStatus:N,config:e,kioskMode:w}),function(){const e=X(Jr),{state:t}=X(bi),n=e.auto_download.includes("markdown"),o=e.auto_download.includes("html"),r=!n||t!==wi.OPEN,a=!o||t!==wi.OPEN;si((async()=>{await Kr({download:!1})}),{delayMs:5e3,whenVisible:!0,disabled:r}),si((async()=>{await Xr({download:!1,includeCode:!0,files:yi.INSTANCE.filenames()})}),{delayMs:5e3,whenVisible:!0,disabled:a})}(),$(window,"beforeunload",(e=>{if(!ca())return O?(e.preventDefault(),e.returnValue="You have unsaved changes. Are you sure you want to quit?"):void 0}));const B=e=>{E(e).then((e=>{null!==e&&D(e,!0)}))},V=function(){const e=P(),t=Kc();return R((()=>t(F(e))))}(),G=Nd();Os("global.runStale",(()=>{V()})),Os("global.save",z),Os("global.interrupt",(()=>{yr()})),Os("global.hideCode",(()=>{G()}));const H=R((()=>JSON.stringify({filename:l,cells:S.map((e=>({name:e.name,code:e.code})))},null,2))),W=m.jsx(Cb,{notebook:n,connStatus:N,mode:i.mode,userConfig:e,appConfig:t});return m.jsxs(m.Fragment,{children:[m.jsxs(ll,{connectionState:N.state,isRunning:b,width:t.width,children:[m.jsx(cl,{connection:N,className:$t("pt-4 sm:pt-12 pb-2 mb-4 print:hidden z-50","sticky left-0"),children:x&&m.jsx("div",{className:"flex items-center justify-center container",children:m.jsx(nu,{filename:l,setFilename:E})})}),S.length>0&&m.jsx(dl,{appConfig:t,mode:i.mode,children:W})]}),m.jsx(Kd,{filename:l,needsSave:O,onSaveNotebook:z,getCellsAsJSON:H,presenting:y,onTogglePresenting:G,onInterrupt:yr,onRun:V,closed:N.state===wi.CLOSED,running:b,needsRun:da(n),undoAvailable:gt(n),appWidth:t.width})]})},Ib=e=>{const{onClose:t,onSave:n}=e,[o,a]=r.useState();return m.jsxs(g,{children:[m.jsx(v,{children:"Save notebook"}),m.jsxs("div",{className:"flex flex-col",children:[m.jsx(ae,{className:"text-md pt-6 px-1",children:"Save as"}),m.jsx(tu,{onNameChange:e=>{a(e),e.trim()&&(n(e),t())},placeholderText:"filename",className:"missing-filename"})]}),m.jsxs(y,{children:[m.jsx(b,{"data-testid":"cancel-save-dialog-button","aria-label":"Cancel",variant:"secondary",onClick:t,children:"Cancel"}),m.jsx(b,{"data-testid":"submit-save-dialog-button","aria-label":"Save",variant:"default",disabled:!o,type:"submit",children:"Save"})]})]})},{createElement:Ab,createContext:Mb,createRef:Tb,forwardRef:Ob,useCallback:Db,useContext:_b,useEffect:Pb,useImperativeHandle:Rb,useLayoutEffect:Fb,useMemo:Lb,useRef:zb,useState:Bb}=fa,Ub=fa["useId".toString()],Vb=Fb,$b=Mb(null);$b.displayName="PanelGroupContext";const Gb=Vb,Hb="function"==typeof Ub?Ub:()=>null;let Wb=0;function qb(e=null){const t=Hb(),n=zb(e||t||null);return null===n.current&&(n.current=""+Wb++),null!=e?e:n.current}function Yb({children:e,className:t="",collapsedSize:n,collapsible:o,defaultSize:r,forwardedRef:a,id:s,maxSize:i,minSize:l,onCollapse:c,onExpand:d,onResize:u,order:h,style:f,tagName:m="div",...p}){const g=_b($b);if(null===g)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:v,expandPanel:x,getPanelSize:y,getPanelStyle:b,groupId:w,isPanelCollapsed:k,reevaluatePanelConstraints:N,registerPanel:E,resizePanel:C,unregisterPanel:j}=g,S=qb(s),I=zb({callbacks:{onCollapse:c,onExpand:d,onResize:u},constraints:{collapsedSize:n,collapsible:o,defaultSize:r,maxSize:i,minSize:l},id:S,idIsFromProps:void 0!==s,order:h});zb({didLogMissingDefaultSizeWarning:!1}),Gb((()=>{const{callbacks:e,constraints:t}=I.current,a={...t};I.current.id=S,I.current.idIsFromProps=void 0!==s,I.current.order=h,e.onCollapse=c,e.onExpand=d,e.onResize=u,t.collapsedSize=n,t.collapsible=o,t.defaultSize=r,t.maxSize=i,t.minSize=l,a.collapsedSize===t.collapsedSize&&a.collapsible===t.collapsible&&a.maxSize===t.maxSize&&a.minSize===t.minSize||N(I.current,a)})),Gb((()=>{const e=I.current;return E(e),()=>{j(e)}}),[h,S,E,j]),Rb(a,(()=>({collapse:()=>{v(I.current)},expand:e=>{x(I.current,e)},getId:()=>S,getSize:()=>y(I.current),isCollapsed:()=>k(I.current),isExpanded:()=>!k(I.current),resize:e=>{C(I.current,e)}})),[v,x,y,k,S,C]);const A=b(I.current,r);return Ab(m,{...p,children:e,className:t,id:s,style:{...A,...f},"data-panel":"","data-panel-collapsible":o||void 0,"data-panel-group-id":w,"data-panel-id":S,"data-panel-size":parseFloat(""+A.flexGrow).toFixed(1)})}const Jb=Ob(((e,t)=>Ab(Yb,{...e,forwardedRef:t})));Yb.displayName="Panel",Jb.displayName="forwardRef(Panel)";let Kb=null,Xb=null;function Zb(e,t){const n=function(e,t){if(t){const e=!!(t&uw),n=!!(t&hw);if(t&cw)return e?"se-resize":n?"ne-resize":"e-resize";if(t&dw)return e?"sw-resize":n?"nw-resize":"w-resize";if(e)return"s-resize";if(n)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}(e,t);Kb!==n&&(Kb=n,null===Xb&&(Xb=document.createElement("style"),document.head.appendChild(Xb)),Xb.innerHTML=`*{cursor: ${n}!important;}`)}function Qb(e){return"keydown"===e.type}function ew(e){return e.type.startsWith("pointer")}function tw(e){return e.type.startsWith("mouse")}function nw(e){if(ew(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(tw(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}const ow=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function rw(e){const t=getComputedStyle(e);return"fixed"===t.position||(!("auto"===t.zIndex||"static"===t.position&&!function(e){var t;const n=getComputedStyle(null!==(t=lw(e))&&void 0!==t?t:e).display;return"flex"===n||"inline-flex"===n}(e))||(+t.opacity<1||("transform"in t&&"none"!==t.transform||("webkitTransform"in t&&"none"!==t.webkitTransform||("mixBlendMode"in t&&"normal"!==t.mixBlendMode||("filter"in t&&"none"!==t.filter||("webkitFilter"in t&&"none"!==t.webkitFilter||("isolation"in t&&"isolate"===t.isolation||(!!ow.test(t.willChange)||"touch"===t.webkitOverflowScrolling)))))))))}function aw(e){let t=e.length;for(;t--;){const n=e[t];if(Sw(n,"Missing node"),rw(n))return n}return null}function sw(e){return e&&Number(getComputedStyle(e).zIndex)||0}function iw(e){const t=[];for(;e;)t.push(e),e=lw(e);return t}function lw(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const cw=1,dw=2,uw=4,hw=8,fw="coarse"===function(){if("function"==typeof matchMedia)return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}();let mw=[],pw=!1,gw=new Map,vw=new Map;const xw=new Set;function yw(e){const{target:t}=e,{x:n,y:o}=nw(e);pw=!0,kw({target:t,x:n,y:o}),Cw(),mw.length>0&&(jw("down",e),e.preventDefault(),e.stopPropagation())}function bw(e){const{x:t,y:n}=nw(e);if(!pw){const{target:o}=e;kw({target:o,x:t,y:n})}jw("move",e),Ew(),mw.length>0&&e.preventDefault()}function ww(e){const{target:t}=e,{x:n,y:o}=nw(e);vw.clear(),pw=!1,mw.length>0&&e.preventDefault(),jw("up",e),kw({target:t,x:n,y:o}),Ew(),Cw()}function kw({target:e,x:t,y:n}){mw.splice(0);let o=null;e instanceof HTMLElement&&(o=e),xw.forEach((e=>{const{element:r,hitAreaMargins:a}=e,s=r.getBoundingClientRect(),{bottom:i,left:l,right:c,top:d}=s,u=fw?a.coarse:a.fine;if(t>=l-u&&t<=c+u&&n>=d-u&&n<=i+u){if(null!==o&&r!==o&&!r.contains(o)&&!o.contains(r)&&function(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:iw(e),b:iw(t)};let o;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),o=e;Sw(o,"Stacking order can only be calculated for elements with a common ancestor");const r=sw(aw(n.a)),a=sw(aw(n.b));if(r===a){const e=o.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)};let r=e.length;for(;r--;){const n=e[r];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(r-a)}(o,r)>0){let e=o,t=!1;for(;e&&!e.contains(r);){if(h=e.getBoundingClientRect(),f=s,h.x<f.x+f.width&&h.x+h.width>f.x&&h.y<f.y+f.height&&h.y+h.height>f.y){t=!0;break}e=e.parentElement}if(t)return}mw.push(e)}var h,f}))}function Nw(e,t){vw.set(e,t)}function Ew(){let e=!1,t=!1;mw.forEach((n=>{const{direction:o}=n;"horizontal"===o?e=!0:t=!0}));let n=0;vw.forEach((e=>{n|=e})),e&&t?Zb("intersection",n):e?Zb("horizontal",n):t?Zb("vertical",n):null!==Xb&&(document.head.removeChild(Xb),Kb=null,Xb=null)}function Cw(){gw.forEach(((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",ww),n.removeEventListener("pointerdown",yw),n.removeEventListener("pointerleave",bw),n.removeEventListener("pointermove",bw)})),window.removeEventListener("pointerup",ww),window.removeEventListener("pointercancel",ww),xw.size>0&&(pw?(mw.length>0&&gw.forEach(((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",ww),n.addEventListener("pointerleave",bw),n.addEventListener("pointermove",bw))})),window.addEventListener("pointerup",ww),window.addEventListener("pointercancel",ww)):gw.forEach(((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",yw,{capture:!0}),n.addEventListener("pointermove",bw))})))}function jw(e,t){xw.forEach((n=>{const{setResizeHandlerState:o}=n,r=mw.includes(n);o(e,r,t)}))}function Sw(e,t){if(!e)throw console.error(t),Error(t)}function Iw(e,t,n=10){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Aw(e,t,n=10){return 0===Iw(e,t,n)}function Mw(e,t,n){return 0===Iw(e,t,n)}function Tw({panelConstraints:e,panelIndex:t,size:n}){const o=e[t];Sw(null!=o,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:a,maxSize:s=100,minSize:i=0}=o;if(Iw(n,i)<0)if(a){n=Iw(n,(r+i)/2)<0?r:i}else n=i;return n=Math.min(s,n),n=parseFloat(n.toFixed(10))}function Ow({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:o,prevLayout:r,trigger:a}){if(Mw(e,0))return t;const s=[...t],[i,l]=o;Sw(null!=i,"Invalid first pivot index"),Sw(null!=l,"Invalid second pivot index");let c=0;if("keyboard"===a){{const o=e<0?l:i,r=n[o];Sw(r,`Panel constraints not found for index ${o}`);const{collapsedSize:a=0,collapsible:s,minSize:c=0}=r;if(s){const n=t[o];if(Sw(null!=n,`Previous layout not found for panel index ${o}`),Mw(n,a)){const t=c-n;Iw(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{const o=e<0?i:l,r=n[o];Sw(r,`No panel constraints found for index ${o}`);const{collapsedSize:a=0,collapsible:s,minSize:c=0}=r;if(s){const n=t[o];if(Sw(null!=n,`Previous layout not found for panel index ${o}`),Mw(n,c)){const t=n-a;Iw(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}}{const o=e<0?1:-1;let r=e<0?l:i,a=0;for(;;){const e=t[r];Sw(null!=e,`Previous layout not found for panel index ${r}`);if(a+=Tw({panelConstraints:n,panelIndex:r,size:100})-e,r+=o,r<0||r>=n.length)break}const s=Math.min(Math.abs(e),Math.abs(a));e=e<0?0-s:s}{let o=e<0?i:l;for(;o>=0&&o<n.length;){const r=Math.abs(e)-Math.abs(c),a=t[o];Sw(null!=a,`Previous layout not found for panel index ${o}`);const i=Tw({panelConstraints:n,panelIndex:o,size:a-r});if(!Mw(a,i)&&(c+=a-i,s[o]=i,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?o--:o++}}if(function(e,t,n){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(!Mw(e[o],t[o],n))return!1;return!0}(r,s))return r;{const o=e<0?l:i,r=t[o];Sw(null!=r,`Previous layout not found for panel index ${o}`);const a=r+c,d=Tw({panelConstraints:n,panelIndex:o,size:a});if(s[o]=d,!Mw(d,a)){let t=a-d;let o=e<0?l:i;for(;o>=0&&o<n.length;){const r=s[o];Sw(null!=r,`Previous layout not found for panel index ${o}`);const a=Tw({panelConstraints:n,panelIndex:o,size:r+t});if(Mw(r,a)||(t-=a-r,s[o]=a),Mw(t,0))break;e>0?o--:o++}}}return Mw(s.reduce(((e,t)=>t+e),0),100)?s:r}function Dw({layout:e,panelsArray:t,pivotIndices:n}){let o=0,r=100,a=0,s=0;const i=n[0];Sw(null!=i,"No pivot index found"),t.forEach(((e,t)=>{const{constraints:n}=e,{maxSize:l=100,minSize:c=0}=n;t===i?(o=c,r=l):(a+=c,s+=l)}));return{valueMax:Math.min(r,100-a),valueMin:Math.max(o,100-s),valueNow:e[i]}}function _w(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function Pw(e,t,n=document){const o=_w(e,n).findIndex((e=>e.getAttribute("data-panel-resize-handle-id")===t));return null!=o?o:null}function Rw(e,t,n){const o=Pw(e,t,n);return null!=o?[o,o+1]:[-1,-1]}function Fw(e,t=document){var n;if(t instanceof HTMLElement&&(null==t||null===(n=t.dataset)||void 0===n?void 0:n.panelGroupId)==e)return t;const o=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return o||null}function Lw(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function zw({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:o,panelDataArray:r,panelGroupElement:a,setLayout:s}){zb({didWarnAboutMissingResizeHandle:!1}),Gb((()=>{if(!a)return;const e=_w(n,a);for(let t=0;t<r.length-1;t++){const{valueMax:n,valueMin:a,valueNow:s}=Dw({layout:o,panelsArray:r,pivotIndices:[t,t+1]}),i=e[t];if(null==i);else{const e=r[t];Sw(e,`No panel data found for index "${t}"`),i.setAttribute("aria-controls",e.id),i.setAttribute("aria-valuemax",""+Math.round(n)),i.setAttribute("aria-valuemin",""+Math.round(a)),i.setAttribute("aria-valuenow",null!=s?""+Math.round(s):"")}}return()=>{e.forEach(((e,t)=>{e.removeAttribute("aria-controls"),e.removeAttribute("aria-valuemax"),e.removeAttribute("aria-valuemin"),e.removeAttribute("aria-valuenow")}))}}),[n,o,r,a]),Pb((()=>{if(!a)return;const e=t.current;Sw(e,"Eager values not found");const{panelDataArray:r}=e;Sw(null!=Fw(n,a),`No group found for id "${n}"`);const i=_w(n,a);Sw(i,`No resize handles found for group id "${n}"`);const l=i.map((e=>{const t=e.getAttribute("data-panel-resize-handle-id");Sw(t,"Resize handle element has no handle id attribute");const[i,l]=function(e,t,n,o=document){var r,a,s,i;const l=Lw(t,o),c=_w(e,o),d=l?c.indexOf(l):-1;return[null!==(r=null===(a=n[d])||void 0===a?void 0:a.id)&&void 0!==r?r:null,null!==(s=null===(i=n[d+1])||void 0===i?void 0:i.id)&&void 0!==s?s:null]}(n,t,r,a);if(null==i||null==l)return()=>{};const c=e=>{if(!e.defaultPrevented)switch(e.key){case"Enter":{e.preventDefault();const l=r.findIndex((e=>e.id===i));if(l>=0){const e=r[l];Sw(e,`No panel data found for index ${l}`);const i=o[l],{collapsedSize:c=0,collapsible:d,minSize:u=0}=e.constraints;if(null!=i&&d){const e=Ow({delta:Mw(i,c)?u-c:c-i,initialLayout:o,panelConstraints:r.map((e=>e.constraints)),pivotIndices:Rw(n,t,a),prevLayout:o,trigger:"keyboard"});o!==e&&s(e)}}break}}};return e.addEventListener("keydown",c),()=>{e.removeEventListener("keydown",c)}}));return()=>{l.forEach((e=>e()))}}),[a,e,t,n,o,r,s])}function Bw(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Uw(e,t){const n="horizontal"===e,{x:o,y:r}=nw(t);return n?o:r}function Vw(e,t,n,o,r,a){if(Qb(e)){const t="horizontal"===n;let o=0;o=e.shiftKey?100:null!=r?r:10;let a=0;switch(e.key){case"ArrowDown":a=t?0:o;break;case"ArrowLeft":a=t?-o:0;break;case"ArrowRight":a=t?o:0;break;case"ArrowUp":a=t?0:-o;break;case"End":a=100;break;case"Home":a=-100}return a}return null==o?0:function(e,t,n,o,r){const a="horizontal"===n,s=Lw(t,r);Sw(s,`No resize handle element found for id "${t}"`);const i=s.getAttribute("data-panel-group-id");Sw(i,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=o;const c=Uw(n,e),d=Fw(i,r);Sw(d,`No group element found for id "${i}"`);const u=d.getBoundingClientRect();return(c-l)/(a?u.width:u.height)*100}(e,t,n,o,a)}function $w(e,t,n){t.forEach(((t,o)=>{const r=e[o];Sw(r,`Panel data not found for index ${o}`);const{callbacks:a,constraints:s,id:i}=r,{collapsedSize:l=0,collapsible:c}=s,d=n[i];if(null==d||t!==d){n[i]=t;const{onCollapse:e,onExpand:o,onResize:r}=a;r&&r(t,d),c&&(e||o)&&(!o||null!=d&&!Aw(d,l)||Aw(t,l)||o(),!e||null!=d&&Aw(d,l)||!Aw(t,l)||e())}}))}function Gw(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Hw(e){try{if("undefined"==typeof localStorage)throw new Error("localStorage not supported in this environment");e.getItem=e=>localStorage.getItem(e),e.setItem=(e,t)=>{localStorage.setItem(e,t)}}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function Ww(e){return`react-resizable-panels:${e}`}function qw(e){return e.map((e=>{const{constraints:t,id:n,idIsFromProps:o,order:r}=e;return o?n:r?`${r}:${JSON.stringify(t)}`:JSON.stringify(t)})).sort(((e,t)=>e.localeCompare(t))).join(",")}function Yw(e,t){try{const n=Ww(e),o=t.getItem(n);if(o){const e=JSON.parse(o);if("object"==typeof e&&null!=e)return e}}catch(n){}return null}function Jw(e,t,n,o,r){var a;const s=Ww(e),i=qw(t),l=null!==(a=Yw(e,r))&&void 0!==a?a:{};l[i]={expandToSizes:Object.fromEntries(n.entries()),layout:o};try{r.setItem(s,JSON.stringify(l))}catch(c){console.error(c)}}function Kw({layout:e,panelConstraints:t}){const n=[...e],o=n.reduce(((e,t)=>e+t),0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map((e=>`${e}%`)).join(", ")}`);if(!Mw(o,100))for(let a=0;a<t.length;a++){const e=n[a];Sw(null!=e,`No layout data found for index ${a}`);const t=100/o*e;n[a]=t}let r=0;for(let a=0;a<t.length;a++){const e=n[a];Sw(null!=e,`No layout data found for index ${a}`);const o=Tw({panelConstraints:t,panelIndex:a,size:e});e!=o&&(r+=e-o,n[a]=o)}if(!Mw(r,0))for(let a=0;a<t.length;a++){const e=n[a];Sw(null!=e,`No layout data found for index ${a}`);const o=Tw({panelConstraints:t,panelIndex:a,size:e+r});if(e!==o&&(r-=o-e,n[a]=o,Mw(r,0)))break}return n}const Xw={getItem:e=>(Hw(Xw),Xw.getItem(e)),setItem:(e,t)=>{Hw(Xw),Xw.setItem(e,t)}},Zw={};function Qw({autoSaveId:e=null,children:t,className:n="",direction:o,forwardedRef:r,id:a=null,onLayout:s=null,keyboardResizeBy:i=null,storage:l=Xw,style:c,tagName:d="div",...u}){const h=qb(a),f=zb(null),[m,p]=Bb(null),[g,v]=Bb([]),x=zb({}),y=zb(new Map),b=zb(0),w=zb({autoSaveId:e,direction:o,dragState:m,id:h,keyboardResizeBy:i,onLayout:s,storage:l}),k=zb({layout:g,panelDataArray:[],panelDataArrayChanged:!1});zb({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),Rb(r,(()=>({getId:()=>w.current.id,getLayout:()=>{const{layout:e}=k.current;return e},setLayout:e=>{const{onLayout:t}=w.current,{layout:n,panelDataArray:o}=k.current,r=Kw({layout:e,panelConstraints:o.map((e=>e.constraints))});Bw(n,r)||(v(r),k.current.layout=r,t&&t(r),$w(o,r,x.current))}})),[]),Gb((()=>{w.current.autoSaveId=e,w.current.direction=o,w.current.dragState=m,w.current.id=h,w.current.onLayout=s,w.current.storage=l})),zw({committedValuesRef:w,eagerValuesRef:k,groupId:h,layout:g,panelDataArray:k.current.panelDataArray,setLayout:v,panelGroupElement:f.current}),Pb((()=>{const{panelDataArray:t}=k.current;if(e){if(0===g.length||g.length!==t.length)return;let n=Zw[e];null==n&&(n=function(e,t=10){let n=null;return(...o)=>{null!==n&&clearTimeout(n),n=setTimeout((()=>{e(...o)}),t)}}(Jw,100),Zw[e]=n);const o=[...t],r=new Map(y.current);n(e,o,r,g,l)}}),[e,g,l]),Pb((()=>{}));const N=Db((e=>{const{onLayout:t}=w.current,{layout:n,panelDataArray:o}=k.current;if(e.constraints.collapsible){const r=o.map((e=>e.constraints)),{collapsedSize:a=0,panelSize:s,pivotIndices:i}=nk(o,e,n);if(Sw(null!=s,`Panel size not found for panel "${e.id}"`),!Aw(s,a)){y.current.set(e.id,s);const l=Ow({delta:tk(o,e)===o.length-1?s-a:a-s,initialLayout:n,panelConstraints:r,pivotIndices:i,prevLayout:n,trigger:"imperative-api"});Gw(n,l)||(v(l),k.current.layout=l,t&&t(l),$w(o,l,x.current))}}}),[]),E=Db(((e,t)=>{const{onLayout:n}=w.current,{layout:o,panelDataArray:r}=k.current;if(e.constraints.collapsible){const a=r.map((e=>e.constraints)),{collapsedSize:s=0,panelSize:i=0,minSize:l=0,pivotIndices:c}=nk(r,e,o),d=null!=t?t:l;if(Aw(i,s)){const t=y.current.get(e.id),s=null!=t&&t>=d?t:d,l=Ow({delta:tk(r,e)===r.length-1?i-s:s-i,initialLayout:o,panelConstraints:a,pivotIndices:c,prevLayout:o,trigger:"imperative-api"});Gw(o,l)||(v(l),k.current.layout=l,n&&n(l),$w(r,l,x.current))}}}),[]),C=Db((e=>{const{layout:t,panelDataArray:n}=k.current,{panelSize:o}=nk(n,e,t);return Sw(null!=o,`Panel size not found for panel "${e.id}"`),o}),[]),j=Db(((e,t)=>{const{panelDataArray:n}=k.current,o=tk(n,e);return function({defaultSize:e,dragState:t,layout:n,panelData:o,panelIndex:r,precision:a=3}){const s=n[r];let i;return i=null==s?null!=e?e.toPrecision(a):"1":1===o.length?"1":s.toPrecision(a),{flexBasis:0,flexGrow:i,flexShrink:1,overflow:"hidden",pointerEvents:null!==t?"none":void 0}}({defaultSize:t,dragState:m,layout:g,panelData:n,panelIndex:o})}),[m,g]),S=Db((e=>{const{layout:t,panelDataArray:n}=k.current,{collapsedSize:o=0,collapsible:r,panelSize:a}=nk(n,e,t);return Sw(null!=a,`Panel size not found for panel "${e.id}"`),!0===r&&Aw(a,o)}),[]),I=Db((e=>{const{layout:t,panelDataArray:n}=k.current,{collapsedSize:o=0,collapsible:r,panelSize:a}=nk(n,e,t);return Sw(null!=a,`Panel size not found for panel "${e.id}"`),!r||Iw(a,o)>0}),[]),A=Db((e=>{const{panelDataArray:t}=k.current;t.push(e),t.sort(((e,t)=>{const n=e.order,o=t.order;return null==n&&null==o?0:null==n?-1:null==o?1:n-o})),k.current.panelDataArrayChanged=!0}),[]);Gb((()=>{if(k.current.panelDataArrayChanged){k.current.panelDataArrayChanged=!1;const{autoSaveId:e,onLayout:t,storage:n}=w.current,{layout:o,panelDataArray:r}=k.current;let a=null;if(e){const t=function(e,t,n){var o,r;return null!==(r=(null!==(o=Yw(e,n))&&void 0!==o?o:{})[qw(t)])&&void 0!==r?r:null}(e,r,n);t&&(y.current=new Map(Object.entries(t.expandToSizes)),a=t.layout)}null==a&&(a=function({panelDataArray:e}){const t=Array(e.length),n=e.map((e=>e.constraints));let o=0,r=100;for(let a=0;a<e.length;a++){const e=n[a];Sw(e,`Panel constraints not found for index ${a}`);const{defaultSize:s}=e;null!=s&&(o++,t[a]=s,r-=s)}for(let a=0;a<e.length;a++){const s=n[a];Sw(s,`Panel constraints not found for index ${a}`);const{defaultSize:i}=s;if(null!=i)continue;const l=r/(e.length-o);o++,t[a]=l,r-=l}return t}({panelDataArray:r}));const s=Kw({layout:a,panelConstraints:r.map((e=>e.constraints))});Bw(o,s)||(v(s),k.current.layout=s,t&&t(s),$w(r,s,x.current))}})),Gb((()=>{const e=k.current;return()=>{e.layout=[]}}),[]);const M=Db((e=>function(t){t.preventDefault();const n=f.current;if(!n)return()=>null;const{direction:o,dragState:r,id:a,keyboardResizeBy:s,onLayout:i}=w.current,{layout:l,panelDataArray:c}=k.current,{initialLayout:d}=null!=r?r:{},u=Rw(a,e,n);let h=Vw(t,e,o,r,s,n);if(0===h)return;const m="horizontal"===o;"rtl"===document.dir&&m&&(h=-h);const p=Ow({delta:h,initialLayout:null!=d?d:l,panelConstraints:c.map((e=>e.constraints)),pivotIndices:u,prevLayout:l,trigger:Qb(t)?"keyboard":"mouse-or-touch"}),g=!Gw(l,p);(ew(t)||tw(t))&&b.current!=h&&(b.current=h,Nw(e,g?0:m?h<0?cw:dw:h<0?uw:hw)),g&&(v(p),k.current.layout=p,i&&i(p),$w(c,p,x.current))}),[]),T=Db(((e,t)=>{const{onLayout:n}=w.current,{layout:o,panelDataArray:r}=k.current,a=r.map((e=>e.constraints)),{panelSize:s,pivotIndices:i}=nk(r,e,o);Sw(null!=s,`Panel size not found for panel "${e.id}"`);const l=Ow({delta:tk(r,e)===r.length-1?s-t:t-s,initialLayout:o,panelConstraints:a,pivotIndices:i,prevLayout:o,trigger:"imperative-api"});Gw(o,l)||(v(l),k.current.layout=l,n&&n(l),$w(r,l,x.current))}),[]),O=Db(((e,t)=>{const{layout:n,panelDataArray:o}=k.current,{collapsedSize:r=0,collapsible:a}=t,{collapsedSize:s=0,collapsible:i,maxSize:l=100,minSize:c=0}=e.constraints,{panelSize:d}=nk(o,e,n);null!=d&&(a&&i&&Aw(d,r)?Aw(r,s)||T(e,s):d<c?T(e,c):d>l&&T(e,l))}),[T]),D=Db(((e,t)=>{const{direction:n}=w.current,{layout:o}=k.current;if(!f.current)return;const r=Lw(e,f.current);Sw(r,`Drag handle element not found for id "${e}"`);const a=Uw(n,t);p({dragHandleId:e,dragHandleRect:r.getBoundingClientRect(),initialCursorPosition:a,initialLayout:o})}),[]),_=Db((()=>{p(null)}),[]),P=Db((e=>{const{panelDataArray:t}=k.current,n=tk(t,e);n>=0&&(t.splice(n,1),delete x.current[e.id],k.current.panelDataArrayChanged=!0)}),[]),R=Lb((()=>({collapsePanel:N,direction:o,dragState:m,expandPanel:E,getPanelSize:C,getPanelStyle:j,groupId:h,isPanelCollapsed:S,isPanelExpanded:I,reevaluatePanelConstraints:O,registerPanel:A,registerResizeHandle:M,resizePanel:T,startDragging:D,stopDragging:_,unregisterPanel:P,panelGroupElement:f.current})),[N,m,o,E,C,j,h,S,I,O,A,M,T,D,_,P]),F={display:"flex",flexDirection:"horizontal"===o?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return Ab($b.Provider,{value:R},Ab(d,{...u,children:t,className:n,id:a,ref:f,style:{...F,...c},"data-panel-group":"","data-panel-group-direction":o,"data-panel-group-id":h}))}const ek=Ob(((e,t)=>Ab(Qw,{...e,forwardedRef:t})));function tk(e,t){return e.findIndex((e=>e===t||e.id===t.id))}function nk(e,t,n){const o=tk(e,t),r=o===e.length-1?[o-1,o]:[o,o+1],a=n[o];return{...t.constraints,panelSize:a,pivotIndices:r}}function ok({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:o,id:r,onDragging:a,style:s={},tabIndex:i=0,tagName:l="div",...c}){var d,u;const h=zb(null),f=zb({onDragging:a});Pb((()=>{f.current.onDragging=a}));const m=_b($b);if(null===m)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:p,groupId:g,registerResizeHandle:v,startDragging:x,stopDragging:y,panelGroupElement:b}=m,w=qb(r),[k,N]=Bb("inactive"),[E,C]=Bb(!1),[j,S]=Bb(null),I=zb({state:k});Gb((()=>{I.current.state=k})),Pb((()=>{if(n)S(null);else{const e=v(w);S((()=>e))}}),[n,w,v]);const A=null!==(d=null==o?void 0:o.coarse)&&void 0!==d?d:15,M=null!==(u=null==o?void 0:o.fine)&&void 0!==u?u:5;Pb((()=>{if(n||null==j)return;const e=h.current;Sw(e,"Element ref not attached");return function(e,t,n,o,r){var a;const{ownerDocument:s}=t,i={direction:n,element:t,hitAreaMargins:o,setResizeHandlerState:r},l=null!==(a=gw.get(s))&&void 0!==a?a:0;return gw.set(s,l+1),xw.add(i),Cw(),function(){var t;vw.delete(e),xw.delete(i);const n=null!==(t=gw.get(s))&&void 0!==t?t:1;gw.set(s,n-1),Cw(),1===n&&gw.delete(s)}}(w,e,p,{coarse:A,fine:M},((e,t,n)=>{if(t)switch(e){case"down":{N("drag"),x(w,n);const{onDragging:e}=f.current;e&&e(!0);break}case"move":{const{state:e}=I.current;"drag"!==e&&N("hover"),j(n);break}case"up":{N("hover"),y();const{onDragging:e}=f.current;e&&e(!1);break}}else N("inactive")}))}),[A,p,n,M,v,w,j,x,y]),function({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:o}){Pb((()=>{if(e||null==n||null==o)return;const r=Lw(t,o);if(null==r)return;const a=e=>{if(!e.defaultPrevented)switch(e.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":e.preventDefault(),n(e);break;case"F6":{e.preventDefault();const n=r.getAttribute("data-panel-group-id");Sw(n,`No group element found for id "${n}"`);const a=_w(n,o),s=Pw(n,t,o);Sw(null!==s,`No resize element found for id "${t}"`),a[e.shiftKey?s>0?s-1:a.length-1:s+1<a.length?s+1:0].focus();break}}};return r.addEventListener("keydown",a),()=>{r.removeEventListener("keydown",a)}}),[o,e,t,n])}({disabled:n,handleId:w,resizeHandler:j,panelGroupElement:b});return Ab(l,{...c,children:e,className:t,id:r,onBlur:()=>C(!1),onFocus:()=>C(!0),ref:h,role:"separator",style:{touchAction:"none",userSelect:"none",...s},tabIndex:i,"data-panel-group-direction":p,"data-panel-group-id":g,"data-resize-handle":"","data-resize-handle-active":"drag"===k?"pointer":E?"keyboard":void 0,"data-resize-handle-state":k,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":w})}Qw.displayName="PanelGroup",ek.displayName="forwardRef(PanelGroup)",ok.displayName="PanelResizeHandle";const rk=e=>m.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1.24em",height:"1em",viewBox:"0 0 256 208",fill:"currentColor",...e,children:m.jsx("path",{d:"M205.28 31.36c14.096 14.88 20.016 35.2 22.512 63.68c6.626 0 12.805 1.47 16.976 7.152l7.792 10.56A17.55 17.55 0 0 1 256 123.2v28.688c-.008 3.704-1.843 7.315-4.832 9.504C215.885 187.222 172.35 208 128 208c-49.066 0-98.19-28.273-123.168-46.608c-2.989-2.189-4.825-5.8-4.832-9.504V123.2c0-3.776 1.2-7.424 3.424-10.464l7.792-10.544c4.173-5.657 10.38-7.152 16.992-7.152c2.496-28.48 8.4-48.8 22.512-63.68C77.331 3.165 112.567.06 127.552 0H128c14.72 0 50.4 2.88 77.28 31.36m-77.264 47.376c-3.04 0-6.544.176-10.272.544c-1.312 4.896-3.248 9.312-6.08 12.128c-11.2 11.2-24.704 12.928-31.936 12.928c-6.802 0-13.927-1.42-19.744-5.088c-5.502 1.808-10.786 4.415-11.136 10.912c-.586 12.28-.637 24.55-.688 36.824c-.026 6.16-.05 12.322-.144 18.488c.024 3.579 2.182 6.903 5.44 8.384C79.936 185.92 104.976 192 128.016 192c23.008 0 48.048-6.08 74.512-18.144c3.258-1.48 5.415-4.805 5.44-8.384c.317-18.418.062-36.912-.816-55.312h.016c-.342-6.534-5.648-9.098-11.168-10.912c-5.82 3.652-12.927 5.088-19.728 5.088c-7.232 0-20.72-1.728-31.936-12.928c-2.832-2.816-4.768-7.232-6.08-12.128a106 106 0 0 0-10.24-.544m-26.941 43.93c5.748 0 10.408 4.66 10.408 10.409v19.183c0 5.749-4.66 10.409-10.408 10.409s-10.408-4.66-10.408-10.409v-19.183c0-5.748 4.66-10.408 10.408-10.408m53.333 0c5.749 0 10.409 4.66 10.409 10.409v19.183c0 5.749-4.66 10.409-10.409 10.409c-5.748 0-10.408-4.66-10.408-10.409v-19.183c0-5.748 4.66-10.408 10.408-10.408M81.44 28.32c-11.2 1.12-20.64 4.8-25.44 9.92c-10.4 11.36-8.16 40.16-2.24 46.24c4.32 4.32 12.48 7.2 21.28 7.2c6.72 0 19.52-1.44 30.08-12.16c4.64-4.48 7.52-15.68 7.2-27.04c-.32-9.12-2.88-16.64-6.72-19.84c-4.16-3.68-13.6-5.28-24.16-4.32m68.96 4.32c-3.84 3.2-6.4 10.72-6.72 19.84c-.32 11.36 2.56 22.56 7.2 27.04c10.56 10.72 23.36 12.16 30.08 12.16c8.8 0 16.96-2.88 21.28-7.2c5.92-6.08 8.16-34.88-2.24-46.24c-4.8-5.12-14.24-8.8-25.44-9.92c-10.56-.96-20 .64-24.16 4.32M128 56c-2.56 0-5.6.16-8.96.48c.32 1.76.48 3.68.64 5.76c0 1.44 0 2.88-.16 4.48c3.2-.32 5.92-.32 8.48-.32s5.28 0 8.48.32c-.16-1.6-.16-3.04-.16-4.48c.16-2.08.32-4 .64-5.76c-3.36-.32-6.4-.48-8.96-.48"})}),ak=({children:e,tooltip:t,selected:n,className:o,...r})=>{const a=m.jsx("div",{className:$t("h-full flex items-center p-2 text-sm shadow-inset font-mono cursor-pointer rounded",!n&&"hover:bg-[var(--sage-3)]",n&&"bg-[var(--sage-4)]",o),...r,children:e});return t?m.jsx(p,{content:t,side:"top",delayDuration:200,children:a}):a},sk=()=>{var e;const t=X(lk),n=X(Q),o=(null==(e=null==t?void 0:t.open_ai)?void 0:e.model)||"gpt-4-turbo",{handleClick:r}=ck();return n?m.jsx(ak,{tooltip:m.jsxs(m.Fragment,{children:[m.jsx("b",{children:"Assist model:"})," ",o]}),onClick:r,selected:!1,children:m.jsx(bc,{className:"h-4 w-4"})}):m.jsx(ak,{tooltip:"Assist is disabled",selected:!1,onClick:r,children:m.jsx(bc,{className:"h-4 w-4 opacity-60"})})},ik=V((e=>e(ma).completion.copilot)),lk=V((e=>e(ma).ai));function ck(){const e=Z(ii),t=Z($s);return{handleClick:()=>{e("ai"),t(!0)}}}const dk=()=>"github"===X(ik)?m.jsx(uk,{}):null,uk=()=>{const e=X(li),t=null!==X(ci),{handleClick:n}=ck(),o=e?"Ready":"Not connected";return m.jsx(ak,{tooltip:m.jsxs(m.Fragment,{children:[m.jsx("b",{children:"GitHub Copilot:"})," ",o]}),selected:!1,onClick:n,children:m.jsx("span",{children:t?m.jsx(pa,{className:"h-4 w-4"}):m.jsx(rk,{className:$t("h-4 w-4",!e&&"opacity-60")})})})},hk=e=>{const[t,n]=r.useState(0),o=X(bi);si((()=>n((e=>e+1))),{delayMs:1e4,whenVisible:!0});const{data:a}=Ht((async()=>C()||o.state!==wi.OPEN?null:ga()),[t,o.state]);return m.jsxs("div",{className:"flex gap-2 items-center",children:[a&&m.jsx(mk,{memory:a.memory,kernel:a.kernel,server:a.server}),a&&m.jsx(pk,{cpu:a.cpu}),m.jsxs("div",{className:"flex items-center",children:[m.jsx(sk,{}),m.jsx(dk,{})]}),m.jsx(fk,{connection:o.state})]})},fk=({connection:e})=>m.jsx(p,{delayDuration:200,content:E(e.toLowerCase()),children:m.jsxs("div",{children:[e===wi.OPEN&&m.jsx(Ol,{className:"w-4 h-4"}),e===wi.CLOSED&&m.jsx(di,{className:"w-4 h-4"}),e===wi.CONNECTING&&m.jsx(pa,{size:"small"}),e===wi.CLOSING&&m.jsx(pa,{className:"text-destructive",size:"small"})]})}),mk=({memory:e,kernel:t,server:n})=>{const{percent:o,total:r,used:a}=e,s=Math.round(o);return m.jsx(p,{delayDuration:200,content:m.jsxs("div",{className:"flex flex-col gap-1",children:[m.jsxs("span",{children:[m.jsx("b",{children:"computer memory:"})," ",xk(a)," / ",xk(r)," GB (",s,"%)"]}),(null==n?void 0:n.memory)&&m.jsxs("span",{children:[m.jsx("b",{children:"marimo server:"})," ",vk(n.memory)]}),(null==t?void 0:t.memory)&&m.jsxs("span",{children:[m.jsx("b",{children:"kernel:"})," ",vk(t.memory)]})]}),children:m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx(tc,{className:"w-4 h-4"}),m.jsx(gk,{percent:s})]})})},pk=({cpu:e})=>{const{percent:t}=e,n=Math.round(t);return m.jsx(p,{delayDuration:200,content:m.jsxs("span",{children:[m.jsx("b",{children:"CPU:"})," ",n,"%"]}),children:m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx(ui,{className:"w-4 h-4"}),m.jsx(gk,{percent:n})]})})},gk=({percent:e})=>m.jsx("div",{className:"h-3 w-20 bg-[var(--slate-4)] rounded-lg overflow-hidden border",children:m.jsx("div",{className:"h-full bg-primary",style:{width:`${e}%`}})});function vk(e){return e>1073741824?`${xk(e)} GB`:`${function(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0}).format(e/1048576)}(e)} MB`}function xk(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:2}).format(e/1073741824)}const yk=e=>X(Yr)[e.capability]?e.children:null,bk=()=>{const{selectedPanel:e,isTerminalOpen:t}=bd(),{openApplication:n,toggleTerminal:o}=wd(),[r,a]=ke(),s=X(va),i=kd.find((e=>"errors"===e.type));return At(i,"Error panel not found"),Os("global.toggleTerminal",(()=>{o()})),m.jsxs("footer",{className:"h-10 py-2 bg-background flex items-center text-muted-foreground text-md pl-1 pr-4 border-t border-border select-none no-print text-sm shadow-[0_0_4px_1px_rgba(0,0,0,0.1)] z-50 print:hidden",children:[m.jsxs(ak,{tooltip:i.tooltip,selected:e===i.type,onClick:()=>n(i.type),children:[(({Icon:e},t)=>m.jsx(e,{className:$t("h-5 w-5",t)}))(i,s>0?"text-destructive":""),m.jsx("span",{className:"ml-1 font-mono mt-[0.125rem]",children:s})]}),m.jsx(yk,{capability:"terminal",children:m.jsx(ak,{tooltip:"Open terminal",selected:t,onClick:()=>o(),children:m.jsx(Ic,{className:"h-5 w-5"})})}),m.jsx(ak,{tooltip:r.runtime.auto_instantiate?"Disable autorun on startup":"Enable autorun on startup",selected:!1,onClick:async()=>{const e={...r,runtime:{...r.runtime,auto_instantiate:!r.runtime.auto_instantiate}};await Ee({config:e}).then((()=>a(e)))},children:m.jsxs("div",{className:"font-prose text-sm flex items-center gap-1",children:[m.jsx("span",{children:"on startup: "}),r.runtime.auto_instantiate?m.jsx(Rc,{size:14}):m.jsx(Pc,{size:14}),m.jsx("span",{children:r.runtime.auto_instantiate?"autorun":"lazy"})]})}),m.jsx("div",{className:"border-r border-border h-6 mx-1"}),m.jsx(ak,{tooltip:"autorun"===r.runtime.on_cell_change?"Disable autorun":"Enable autorun",selected:!1,onClick:async()=>{const e={...r,runtime:{...r.runtime,on_cell_change:"autorun"===r.runtime.on_cell_change?"lazy":"autorun"}};await Ee({config:e}).then((()=>a(e)))},children:m.jsxs("div",{className:"font-prose text-sm flex items-center gap-1",children:[m.jsx("span",{children:"on cell change: "}),"autorun"===r.runtime.on_cell_change?m.jsx(Rc,{size:14}):m.jsx(Pc,{size:14}),m.jsx("span",{children:r.runtime.on_cell_change})]})}),m.jsx("div",{className:"border-r border-border h-6 mx-1"}),!C()&&m.jsx(ak,{tooltip:null,selected:!1,children:m.jsxs(xt,{children:[m.jsxs(yt,{className:"font-prose text-sm flex items-center gap-1",children:[m.jsx("span",{children:"on module change: "}),"off"===r.runtime.auto_reload&&m.jsx(di,{size:14}),"lazy"===r.runtime.auto_reload&&m.jsx(Pc,{size:14}),"autorun"===r.runtime.auto_reload&&m.jsx(Rc,{size:14}),m.jsx("span",{children:r.runtime.auto_reload}),m.jsx(ge,{size:14})]}),m.jsx(bt,{children:["off","lazy","autorun"].map((e=>m.jsxs(St,{onClick:async()=>{const t={...r,runtime:{...r.runtime,auto_reload:e}};await Ee({config:t}).then((()=>a(t)))},children:["off"===e&&m.jsx(di,{size:14,className:"mr-2 text-muted-foreground"}),"lazy"===e&&m.jsx(Pc,{size:14,className:"mr-2 text-muted-foreground"}),"autorun"===e&&m.jsx(Rc,{size:14,className:"mr-2 text-muted-foreground"}),e]},e)))})]})}),m.jsx("div",{className:"mx-auto"}),m.jsx(Jd,{children:m.jsx(p,{content:m.jsx("div",{className:"w-[200px]",children:"Kiosk mode is enabled. This allows you to view the outputs of the cells without the ability to edit them."}),children:m.jsx("span",{className:"text-muted-foreground text-sm mr-4",children:"kiosk mode"})})}),m.jsx(hk,{})]})},wk=({children:e})=>{const{openModal:t,closeModal:n}=f();return m.jsx(xa,{onClick:()=>t(m.jsx(Nk,{onClose:n})),children:e})},kk={"😡":1,"🙁":2,"😐":3,"🙂":4,"😍":5},Nk=({onClose:e})=>m.jsx(g,{className:"w-fit",children:m.jsxs("form",{onSubmit:async t=>{t.preventDefault();const n=new FormData(t.target),o=n.get("rating"),r=n.get("message");fetch("https://marimo.io/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rating:o,message:r})}),e(),q({title:"Feedback sent!",description:"Thank you for your feedback!"})},children:[m.jsxs(re,{children:[m.jsx(v,{children:"Send Feedback"}),m.jsxs(x,{children:["Let us know what you think about marimo! If you have a bug that you would like to report, please use the"," ",m.jsx("a",{href:Be.issuesPage,target:"_blank",rel:"noreferrer",className:"underline",children:"GitHub issue tracker"}),"."]}),m.jsx(x,{children:"Your feedback is anonymous and will help us improve marimo. Thank you!"})]}),m.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[m.jsx("div",{className:"flex gap-5 justify-center",children:Object.entries(kk).map((([e,t])=>m.jsxs("label",{className:"flex flex-col items-center select-none",children:[m.jsx("input",{type:"radio",className:"peer hidden",name:"rating",value:t,"aria-label":e},e),m.jsx("span",{className:"text-4xl peer-checked:opacity-100 opacity-40 cursor-pointer",children:e})]},e)))}),m.jsx(ya,{id:"message",name:"message",autoFocus:!0,placeholder:"Your feedback; if you'd like us to respond, please include your email!",rows:5,required:!0,autoComplete:"off"})]}),m.jsxs(y,{children:[m.jsx(b,{"data-testid":"feedback-cancel-button",variant:"secondary",onClick:e,children:"Cancel"}),m.jsx(b,{"data-testid":"feedback-send-button","aria-label":"Save",variant:"default",type:"submit",children:"Send"})]})]})}),Ek=()=>{const{selectedPanel:e}=bd(),{openApplication:t}=wd(),n=({Icon:e},t)=>m.jsx(e,{className:$t("h-5 w-5",t)}),o=kd.filter((e=>!e.hidden&&"sidebar"===e.position));return m.jsxs("div",{className:"h-full pt-4 pb-1 px-1 flex flex-col items-start text-muted-foreground text-md select-none no-print text-sm z-50 dark:bg-background print:hidden",children:[o.map((o=>m.jsx(jk,{tooltip:o.tooltip,selected:e===o.type,onClick:()=>t(o.type),children:n(o)},o.type))),m.jsx(wk,{children:m.jsx(jk,{tooltip:"Send feedback!",selected:!1,children:m.jsx(nc,{className:"h-5 w-5"})})}),m.jsx("div",{className:"flex-1"}),m.jsx(Ck,{})]})},Ck=()=>{const e=X(ba);return m.jsx(p,{content:e>0?m.jsxs("span",{children:[e," cell",e>1?"s":""," queued or running"]}):"No cells queued or running",side:"right",delayDuration:200,children:m.jsx("div",{className:"flex flex-col-reverse gap-[1px] overflow-hidden",children:Array.from({length:e}).map(((e,t)=>m.jsx("div",{className:"flex-shrink-0 h-1 w-2 bg-[var(--grass-6)] border border-[var(--grass-7)]"},t.toString())))})})},jk=({children:e,tooltip:t,selected:n,className:o,...r})=>m.jsx(p,{content:t,side:"right",delayDuration:200,children:m.jsx("div",{className:$t("flex items-center p-2 text-sm mx-[1px] shadow-inset font-mono cursor-pointer rounded",!n&&"hover:bg-[var(--sage-3)]",n&&"bg-[var(--sage-4)]",o),...r,children:e})});qe.record(qe.tuple([qe.number(),qe.number()]));let Sk=null;const Ik=({title:e,description:t,color:n,icon:o})=>m.jsxs("div",{className:"mx-6 my-6 flex flex-col gap-2",children:[m.jsxs("div",{className:"flex flex-row gap-2 items-center",children:[o&&u.cloneElement(o,{className:"text-accent-foreground"}),m.jsx("span",{className:"mt-1 text-accent-foreground",children:e})]}),m.jsx("span",{className:"text-muted-foreground text-sm",children:t})]}),Ak=()=>{const e=wa();return 0===e.length?m.jsx(Ik,{title:"No errors!",icon:m.jsx(cc,{})}):m.jsx("div",{className:"flex flex-col overflow-auto",children:e.map((e=>m.jsxs("div",{children:[m.jsx("div",{className:"text-xs font-mono font-semibold bg-muted border-y px-2 py-1",children:m.jsx(ka,{cellId:e.cellId})}),m.jsx("div",{className:"px-2",children:m.jsx(Na,{errors:e.output.data},e.cellId)},e.cellId)]},e.cellId)))})},Mk=()=>{const{items:e}=X(Ea),t=r.useMemo((()=>ul(e)),[e]),{activeHeaderId:n}=hl(t);return 0===e.length?m.jsx(Ik,{title:"No outline",description:"Add markdown headings to your notebook to create an outline.",icon:m.jsx(xc,{})}):m.jsx(fl,{items:e,activeHeaderId:n})};function Tk(e){if("string"==typeof e||"number"==typeof e)return""+e;let t="";if(Array.isArray(e))for(let n,o=0;o<e.length;o++)""!==(n=Tk(e[o]))&&(t+=(t&&" ")+n);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}const{useDebugValue:Ok}=u,{useSyncExternalStoreWithSelector:Dk}=Ca,_k=e=>e;function Pk(e,t=_k,n){const o=Dk(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Ok(o),o}const Rk=(e,t)=>{const n=ja(e),o=(e,o=t)=>Pk(n,e,o);return Object.assign(o,n),o};function Fk(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[n,o]of e)if(!Object.is(o,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function Lk(e,t){if(e=function(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,[(o=o.matrixTransform(t.getScreenCTM().inverse())).x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const zk={passive:!1},Bk={capture:!0,passive:!1};function Uk(e){e.stopImmediatePropagation()}function Vk(e){e.preventDefault(),e.stopImmediatePropagation()}function $k(e){var t=e.document.documentElement,n=pl(e).on("dragstart.drag",Vk,Bk);"onselectstart"in t?n.on("selectstart.drag",Vk,Bk):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Gk(e,t){var n=e.document.documentElement,o=pl(e).on("dragstart.drag",null);t&&(o.on("click.drag",Vk,Bk),setTimeout((function(){o.on("click.drag",null)}),0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Hk=e=>()=>e;function Wk(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:a,x:s,y:i,dx:l,dy:c,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:i,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:d}})}function qk(e){return!e.ctrlKey&&!e.button}function Yk(){return this.parentNode}function Jk(e,t){return null==t?{x:e.x,y:e.y}:t}function Kk(){return navigator.maxTouchPoints||"ontouchstart"in this}Wk.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};const Xk=e=>()=>e;function Zk(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function Qk(e){e.stopImmediatePropagation()}function eN(e){e.preventDefault(),e.stopImmediatePropagation()}function tN(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function nN(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function oN(){return this.__zoom||gl}function rN(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function aN(){return navigator.maxTouchPoints||"ontouchstart"in this}function sN(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),s>a?(a+s)/2:Math.min(0,a)||Math.max(0,s))}const iN=r.createContext(null),lN=iN.Provider,cN=e=>`Node type "${e}" not found. Using fallback type "default".`,dN=()=>"The React Flow parent container needs a width and a height to render the graph.",uN=()=>"Only child nodes can use a parent extent.",hN=e=>`Marker type "${e}" doesn't exist.`,fN=(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,mN=()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",pN=e=>`Edge type "${e}" not found. Using fallback type "default".`,gN=e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,vN=(()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001")();function xN(e,t){const n=r.useContext(iN);if(null===n)throw new Error(vN);return Pk(n,e,t)}const yN=()=>{const e=r.useContext(iN);if(null===e)throw new Error(vN);return r.useMemo((()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy})),[e])},bN=e=>e.userSelectionActive?"none":"all";function wN({position:e,children:t,className:n,style:o,...r}){const a=xN(bN),s=`${e}`.split("-");return u.createElement("div",{className:Tk(["react-flow__panel",n,...s]),style:{...o,pointerEvents:a},...r},t)}function kN({proOptions:e,position:t="bottom-right"}){return(null==e?void 0:e.hideAttribution)?null:u.createElement(wN,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},u.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}var NN=r.memo((({x:e,y:t,label:n,labelStyle:o={},labelShowBg:a=!0,labelBgStyle:s={},labelBgPadding:i=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...h})=>{const f=r.useRef(null),[m,p]=r.useState({x:0,y:0,width:0,height:0}),g=Tk(["react-flow__edge-textwrapper",d]);return r.useEffect((()=>{if(f.current){const e=f.current.getBBox();p({x:e.x,y:e.y,width:e.width,height:e.height})}}),[n]),void 0!==n&&n?u.createElement("g",{transform:`translate(${e-m.width/2} ${t-m.height/2})`,className:g,visibility:m.width?"visible":"hidden",...h},a&&u.createElement("rect",{width:m.width+2*i[0],x:-i[0],y:-i[1],height:m.height+2*i[1],className:"react-flow__edge-textbg",style:s,rx:l,ry:l}),u.createElement("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:f,style:o},n),c):null}));const EN=e=>({width:e.offsetWidth,height:e.offsetHeight}),CN=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),jN=(e={x:0,y:0},t)=>({x:CN(e.x,t[0][0],t[1][0]),y:CN(e.y,t[0][1],t[1][1])}),SN=(e,t,n)=>e<t?CN(Math.abs(e-t),1,50)/50:e>n?-CN(Math.abs(e-n),1,50)/50:0,IN=(e,t)=>[20*SN(e.x,35,t.width-35),20*SN(e.y,35,t.height-35)],AN=e=>{var t;return(null==(t=e.getRootNode)?void 0:t.call(e))||(null==window?void 0:window.document)},MN=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),TN=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),ON=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},DN=e=>!isNaN(e)&&isFinite(e),_N=Symbol.for("internals"),PN=["Enter"," ","Escape"];function RN(e){var t,n;const o=(e=>"nativeEvent"in e)(e)?e.nativeEvent:e,r=(null==(n=null==(t=o.composedPath)?void 0:t.call(o))?void 0:n[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(null==r?void 0:r.nodeName)||(null==r?void 0:r.hasAttribute("contenteditable"))||!!(null==r?void 0:r.closest(".nokey"))}const FN=e=>"clientX"in e,LN=(e,t)=>{var n,o;const r=FN(e),a=r?e.clientX:null==(n=e.touches)?void 0:n[0].clientX,s=r?e.clientY:null==(o=e.touches)?void 0:o[0].clientY;return{x:a-((null==t?void 0:t.left)??0),y:s-((null==t?void 0:t.top)??0)}},zN=()=>{var e;return"undefined"!=typeof navigator&&(null==(e=null==navigator?void 0:navigator.userAgent)?void 0:e.indexOf("Mac"))>=0},BN=({id:e,path:t,labelX:n,labelY:o,label:r,labelStyle:a,labelShowBg:s,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f,interactionWidth:m=20})=>u.createElement(u.Fragment,null,u.createElement("path",{id:e,style:d,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:h,markerStart:f}),m&&u.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:m,className:"react-flow__edge-interaction"}),r&&DN(n)&&DN(o)?u.createElement(NN,{x:n,y:o,label:r,labelStyle:a,labelShowBg:s,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c}):null);function UN(e,t,n){return void 0===n?n:o=>{const r=t().edges.find((t=>t.id===e));r&&n(o,{...r})}}function VN({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,a=n<e?n+r:n-r,s=Math.abs(o-t)/2;return[a,o<t?o+s:o-s,r,s]}function $N({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:a,targetControlX:s,targetControlY:i}){const l=.125*e+.375*r+.375*s+.125*n,c=.125*t+.375*a+.375*i+.125*o;return[l,c,Math.abs(l-e),Math.abs(c-t)]}var GN,HN,WN,qN,YN,JN,KN,XN,ZN,QN,eE,tE;function nE({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===eE.Left||e===eE.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function oE({sourceX:e,sourceY:t,sourcePosition:n=eE.Bottom,targetX:o,targetY:r,targetPosition:a=eE.Top}){const[s,i]=nE({pos:n,x1:e,y1:t,x2:o,y2:r}),[l,c]=nE({pos:a,x1:o,y1:r,x2:e,y2:t}),[d,u,h,f]=$N({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:s,sourceControlY:i,targetControlX:l,targetControlY:c});return[`M${e},${t} C${s},${i} ${l},${c} ${o},${r}`,d,u,h,f]}BN.displayName="BaseEdge",(HN=GN||(GN={})).Strict="strict",HN.Loose="loose",(qN=WN||(WN={})).Free="free",qN.Vertical="vertical",qN.Horizontal="horizontal",(JN=YN||(YN={})).Partial="partial",JN.Full="full",(XN=KN||(KN={})).Bezier="default",XN.Straight="straight",XN.Step="step",XN.SmoothStep="smoothstep",XN.SimpleBezier="simplebezier",(QN=ZN||(ZN={})).Arrow="arrow",QN.ArrowClosed="arrowclosed",(tE=eE||(eE={})).Left="left",tE.Top="top",tE.Right="right",tE.Bottom="bottom";const rE=r.memo((({sourceX:e,sourceY:t,targetX:n,targetY:o,sourcePosition:r=eE.Bottom,targetPosition:a=eE.Top,label:s,labelStyle:i,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:p,interactionWidth:g})=>{const[v,x,y]=oE({sourceX:e,sourceY:t,sourcePosition:r,targetX:n,targetY:o,targetPosition:a});return u.createElement(BN,{path:v,labelX:x,labelY:y,label:s,labelStyle:i,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:p,interactionWidth:g})}));rE.displayName="SimpleBezierEdge";const aE={[eE.Left]:{x:-1,y:0},[eE.Right]:{x:1,y:0},[eE.Top]:{x:0,y:-1},[eE.Bottom]:{x:0,y:1}},sE=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function iE({source:e,sourcePosition:t=eE.Bottom,target:n,targetPosition:o=eE.Top,center:r,offset:a}){const s=aE[t],i=aE[o],l={x:e.x+s.x*a,y:e.y+s.y*a},c={x:n.x+i.x*a,y:n.y+i.y*a},d=(({source:e,sourcePosition:t=eE.Bottom,target:n})=>t===eE.Left||t===eE.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1})({source:l,sourcePosition:t,target:c}),u=0!==d.x?"x":"y",h=d[u];let f,m,p=[];const g={x:0,y:0},v={x:0,y:0},[x,y,b,w]=VN({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[u]*i[u]==-1){f=r.x??x,m=r.y??y;const e=[{x:f,y:l.y},{x:f,y:c.y}],t=[{x:l.x,y:m},{x:c.x,y:m}];p=s[u]===h?"x"===u?e:t:"x"===u?t:e}else{const r=[{x:l.x,y:c.y}],d=[{x:c.x,y:l.y}];if(p="x"===u?s.x===h?d:r:s.y===h?r:d,t===o){const t=Math.abs(e[u]-n[u]);if(t<=a){const o=Math.min(a-1,a-t);s[u]===h?g[u]=(l[u]>e[u]?-1:1)*o:v[u]=(c[u]>n[u]?-1:1)*o}}if(t!==o){const e="x"===u?"y":"x",t=s[u]===i[e],n=l[e]>c[e],o=l[e]<c[e];(1===s[u]&&(!t&&n||t&&o)||1!==s[u]&&(!t&&o||t&&n))&&(p="x"===u?r:d)}const x={x:l.x+g.x,y:l.y+g.y},y={x:c.x+v.x,y:c.y+v.y};Math.max(Math.abs(x.x-p[0].x),Math.abs(y.x-p[0].x))>=Math.max(Math.abs(x.y-p[0].y),Math.abs(y.y-p[0].y))?(f=(x.x+y.x)/2,m=p[0].y):(f=p[0].x,m=(x.y+y.y)/2)}return[[e,{x:l.x+g.x,y:l.y+g.y},...p,{x:c.x+v.x,y:c.y+v.y},n],f,m,b,w]}function lE({sourceX:e,sourceY:t,sourcePosition:n=eE.Bottom,targetX:o,targetY:r,targetPosition:a=eE.Top,borderRadius:s=5,centerX:i,centerY:l,offset:c=20}){const[d,u,h,f,m]=iE({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:a,center:{x:i,y:l},offset:c});return[d.reduce(((e,t,n)=>{let o="";return o=n>0&&n<d.length-1?function(e,t,n,o){const r=Math.min(sE(e,t)/2,sE(t,n)/2,o),{x:a,y:s}=t;if(e.x===a&&a===n.x||e.y===s&&s===n.y)return`L${a} ${s}`;if(e.y===s)return`L ${a+r*(e.x<n.x?-1:1)},${s}Q ${a},${s} ${a},${s+r*(e.y<n.y?1:-1)}`;const i=e.x<n.x?1:-1;return`L ${a},${s+r*(e.y<n.y?-1:1)}Q ${a},${s} ${a+r*i},${s}`}(d[n-1],t,d[n+1],s):`${0===n?"M":"L"}${t.x} ${t.y}`,e+=o}),""),u,h,f,m]}const cE=r.memo((({sourceX:e,sourceY:t,targetX:n,targetY:o,label:r,labelStyle:a,labelShowBg:s,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c,style:d,sourcePosition:h=eE.Bottom,targetPosition:f=eE.Top,markerEnd:m,markerStart:p,pathOptions:g,interactionWidth:v})=>{const[x,y,b]=lE({sourceX:e,sourceY:t,sourcePosition:h,targetX:n,targetY:o,targetPosition:f,borderRadius:null==g?void 0:g.borderRadius,offset:null==g?void 0:g.offset});return u.createElement(BN,{path:x,labelX:y,labelY:b,label:r,labelStyle:a,labelShowBg:s,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:m,markerStart:p,interactionWidth:v})}));cE.displayName="SmoothStepEdge";const dE=r.memo((e=>{var t;return u.createElement(cE,{...e,pathOptions:r.useMemo((()=>{var t;return{borderRadius:0,offset:null==(t=e.pathOptions)?void 0:t.offset}}),[null==(t=e.pathOptions)?void 0:t.offset])})}));dE.displayName="StepEdge";const uE=r.memo((({sourceX:e,sourceY:t,targetX:n,targetY:o,label:r,labelStyle:a,labelShowBg:s,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f,interactionWidth:m})=>{const[p,g,v]=function({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,a,s,i]=VN({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,a,s,i]}({sourceX:e,sourceY:t,targetX:n,targetY:o});return u.createElement(BN,{path:p,labelX:g,labelY:v,label:r,labelStyle:a,labelShowBg:s,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f,interactionWidth:m})}));function hE(e,t){return e>=0?.5*e:25*t*Math.sqrt(-e)}function fE({pos:e,x1:t,y1:n,x2:o,y2:r,c:a}){switch(e){case eE.Left:return[t-hE(t-o,a),n];case eE.Right:return[t+hE(o-t,a),n];case eE.Top:return[t,n-hE(n-r,a)];case eE.Bottom:return[t,n+hE(r-n,a)]}}function mE({sourceX:e,sourceY:t,sourcePosition:n=eE.Bottom,targetX:o,targetY:r,targetPosition:a=eE.Top,curvature:s=.25}){const[i,l]=fE({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[c,d]=fE({pos:a,x1:o,y1:r,x2:e,y2:t,c:s}),[u,h,f,m]=$N({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:i,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${i},${l} ${c},${d} ${o},${r}`,u,h,f,m]}uE.displayName="StraightEdge";const pE=r.memo((({sourceX:e,sourceY:t,targetX:n,targetY:o,sourcePosition:r=eE.Bottom,targetPosition:a=eE.Top,label:s,labelStyle:i,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:p,pathOptions:g,interactionWidth:v})=>{const[x,y,b]=mE({sourceX:e,sourceY:t,sourcePosition:r,targetX:n,targetY:o,targetPosition:a,curvature:null==g?void 0:g.curvature});return u.createElement(BN,{path:x,labelX:y,labelY:b,label:s,labelStyle:i,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:p,interactionWidth:v})}));pE.displayName="BezierEdge";const gE=r.createContext(null),vE=gE.Provider;gE.Consumer;const xE=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`reactflow__edge-${e}${t||""}-${n}${o||""}`,yE=(e,t)=>{if(void 0===e)return"";if("string"==typeof e)return e;return`${t?`${t}__`:""}${Object.keys(e).sort().map((t=>`${t}=${e[t]}`)).join("&")}`},bE=({x:e,y:t},[n,o,r],a,[s,i])=>{const l={x:(e-n)/r,y:(t-o)/r};return a?{x:s*Math.round(l.x/s),y:i*Math.round(l.y/i)}:l},wE=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o}),kE=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],o=(e.height??0)*t[1],r={x:e.position.x-n,y:e.position.y-o};return{...r,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-o}:r}},NE=(e,t=[0,0])=>{if(0===e.length)return{x:0,y:0,width:0,height:0};return(({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}))(e.reduce(((e,n)=>{const{x:o,y:r}=kE(n,t).positionAbsolute;return a=e,s=MN({x:o,y:r,width:n.width||0,height:n.height||0}),{x:Math.min(a.x,s.x),y:Math.min(a.y,s.y),x2:Math.max(a.x2,s.x2),y2:Math.max(a.y2,s.y2)};var a,s}),{x:1/0,y:1/0,x2:-1/0,y2:-1/0}))},EE=(e,t,[n,o,r]=[0,0,1],a=!1,s=!1,i=[0,0])=>{const l={x:(t.x-n)/r,y:(t.y-o)/r,width:t.width/r,height:t.height/r},c=[];return e.forEach((e=>{const{width:t,height:n,selectable:o=!0,hidden:r=!1}=e;if(s&&!o||r)return!1;const{positionAbsolute:d}=kE(e,i),u={x:d.x,y:d.y,width:t||0,height:n||0},h=ON(l,u);(void 0===t||void 0===n||null===t||null===n||a&&h>0||h>=(t||0)*(n||0)||e.dragging)&&c.push(e)})),c},CE=(e,t)=>{const n=e.map((e=>e.id));return t.filter((e=>n.includes(e.source)||n.includes(e.target)))},jE=(e,t,n,o,r,a=.1)=>{const s=t/(e.width*(1+a)),i=n/(e.height*(1+a)),l=Math.min(s,i),c=CN(l,o,r);return{x:t/2-(e.x+e.width/2)*c,y:n/2-(e.y+e.height/2)*c,zoom:c}},SE=(e,t=0)=>e.transition().duration(t);function IE(e,t,n,o){return(t[n]||[]).reduce(((t,r)=>{var a,s;return`${e.id}-${r.id}-${n}`!==o&&t.push({id:r.id||null,type:n,nodeId:e.id,x:((null==(a=e.positionAbsolute)?void 0:a.x)??0)+r.x+r.width/2,y:((null==(s=e.positionAbsolute)?void 0:s.y)??0)+r.y+r.height/2}),t}),[])}const AE={source:null,target:null,sourceHandle:null,targetHandle:null},ME=()=>({handleDomNode:null,isValid:!1,connection:AE,endHandle:null});function TE(e,t,n,o,r,a,s){const i="target"===r,l=s.querySelector(`.react-flow__handle[data-id="${null==e?void 0:e.nodeId}-${null==e?void 0:e.id}-${null==e?void 0:e.type}"]`),c={...ME(),handleDomNode:l};if(l){const e=OE(void 0,l),r=l.getAttribute("data-nodeid"),s=l.getAttribute("data-handleid"),d=l.classList.contains("connectable"),u=l.classList.contains("connectableend"),h={source:i?r:n,sourceHandle:i?s:o,target:i?n:r,targetHandle:i?o:s};c.connection=h;d&&u&&(t===GN.Strict?i&&"source"===e||!i&&"target"===e:r!==n||s!==o)&&(c.endHandle={nodeId:r,handleId:s,type:e},c.isValid=a(h))}return c}function OE(e,t){return e||((null==t?void 0:t.classList.contains("target"))?"target":(null==t?void 0:t.classList.contains("source"))?"source":null)}function DE(e){null==e||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function _E(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function PE({event:e,handleId:t,nodeId:n,onConnect:o,isTarget:r,getState:a,setState:s,isValidConnection:i,edgeUpdaterType:l,onReconnectEnd:c}){const d=AN(e.target),{connectionMode:u,domNode:h,autoPanOnConnect:f,connectionRadius:m,onConnectStart:p,panBy:g,getNodes:v,cancelConnection:x}=a();let y,b=0;const{x:w,y:k}=LN(e),N=null==d?void 0:d.elementFromPoint(w,k),E=OE(l,N),C=null==h?void 0:h.getBoundingClientRect();if(!C||!E)return;let j,S=LN(e,C),I=!1,A=null,M=!1,T=null;const O=function({nodes:e,nodeId:t,handleId:n,handleType:o}){return e.reduce(((e,r)=>{if(r[_N]){const{handleBounds:a}=r[_N];let s=[],i=[];a&&(s=IE(r,a,"source",`${t}-${n}-${o}`),i=IE(r,a,"target",`${t}-${n}-${o}`)),e.push(...s,...i)}return e}),[])}({nodes:v(),nodeId:n,handleId:t,handleType:E}),D=()=>{if(!f)return;const[e,t]=IN(S,C);g({x:e,y:t}),b=requestAnimationFrame(D)};function _(e){const{transform:o}=a();S=LN(e,C);const{handle:l,validHandleResult:c}=function(e,t,n,o,r,a){const{x:s,y:i}=LN(e),l=t.elementsFromPoint(s,i).find((e=>e.classList.contains("react-flow__handle")));if(l){const e=l.getAttribute("data-nodeid");if(e){const t=OE(void 0,l),o=l.getAttribute("data-handleid"),s=a({nodeId:e,id:o,type:t});if(s){const a=r.find((n=>n.nodeId===e&&n.type===t&&n.id===o));return{handle:{id:o,type:t,nodeId:e,x:(null==a?void 0:a.x)||n.x,y:(null==a?void 0:a.y)||n.y},validHandleResult:s}}}}let c=[],d=1/0;if(r.forEach((e=>{const t=Math.sqrt((e.x-n.x)**2+(e.y-n.y)**2);if(t<=o){const n=a(e);t<=d&&(t<d?c=[{handle:e,validHandleResult:n}]:t===d&&c.push({handle:e,validHandleResult:n}),d=t)}})),!c.length)return{handle:null,validHandleResult:ME()};if(1===c.length)return c[0];const u=c.some((({validHandleResult:e})=>e.isValid)),h=c.some((({handle:e})=>"target"===e.type));return c.find((({handle:e,validHandleResult:t})=>h?"target"===e.type:!u||t.isValid))||c[0]}(e,d,bE(S,o,!1,[1,1]),m,O,(e=>TE(e,u,n,t,r?"target":"source",i,d)));if(y=l,I||(D(),I=!0),T=c.handleDomNode,A=c.connection,M=c.isValid,s({connectionPosition:y&&M?wE({x:y.x,y:y.y},o):S,connectionStatus:_E(!!y,M),connectionEndHandle:c.endHandle}),!y&&!M&&!T)return DE(j);A.source!==A.target&&T&&(DE(j),j=T,T.classList.add("connecting","react-flow__handle-connecting"),T.classList.toggle("valid",M),T.classList.toggle("react-flow__handle-valid",M))}function P(e){var t,n;(y||T)&&A&&M&&(null==o||o(A)),null==(n=(t=a()).onConnectEnd)||n.call(t,e),l&&(null==c||c(e)),DE(j),x(),cancelAnimationFrame(b),I=!1,M=!1,A=null,T=null,d.removeEventListener("mousemove",_),d.removeEventListener("mouseup",P),d.removeEventListener("touchmove",_),d.removeEventListener("touchend",P)}s({connectionPosition:S,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:E,connectionStartHandle:{nodeId:n,handleId:t,type:E},connectionEndHandle:null}),null==p||p(e,{nodeId:n,handleId:t,handleType:E}),d.addEventListener("mousemove",_),d.addEventListener("mouseup",P),d.addEventListener("touchmove",_),d.addEventListener("touchend",P)}const RE=()=>!0,FE=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),LE=r.forwardRef((({type:e="source",position:t=eE.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:a=!0,isConnectableEnd:s=!0,id:i,onConnect:l,children:c,className:d,onMouseDown:h,onTouchStart:f,...m},p)=>{var g,v;const x=i||null,y="target"===e,b=yN(),w=r.useContext(gE),{connectOnClick:k,noPanClassName:N}=xN(FE,Fk),{connecting:E,clickConnecting:C}=xN(((e,t,n)=>o=>{const{connectionStartHandle:r,connectionEndHandle:a,connectionClickStartHandle:s}=o;return{connecting:(null==r?void 0:r.nodeId)===e&&(null==r?void 0:r.handleId)===t&&(null==r?void 0:r.type)===n||(null==a?void 0:a.nodeId)===e&&(null==a?void 0:a.handleId)===t&&(null==a?void 0:a.type)===n,clickConnecting:(null==s?void 0:s.nodeId)===e&&(null==s?void 0:s.handleId)===t&&(null==s?void 0:s.type)===n}})(w,x,e),Fk);w||null==(v=(g=b.getState()).onError)||v.call(g,"010",mN());const j=e=>{const{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:o}=b.getState(),r={...t,...e};if(o){const{edges:e,setEdges:t}=b.getState();t(((e,t)=>{if(!e.source||!e.target)return t;let n;var o;return n="id"in(o=e)&&"source"in o&&"target"in o?{...e}:{...e,id:xE(e)},((e,t)=>t.some((t=>!(t.source!==e.source||t.target!==e.target||t.sourceHandle!==e.sourceHandle&&(t.sourceHandle||e.sourceHandle)||t.targetHandle!==e.targetHandle&&(t.targetHandle||e.targetHandle)))))(n,t)?t:t.concat(n)})(r,e))}null==n||n(r),null==l||l(r)},S=e=>{if(!w)return;const t=FN(e);a&&(t&&0===e.button||!t)&&PE({event:e,handleId:x,nodeId:w,onConnect:j,isTarget:y,getState:b.getState,setState:b.setState,isValidConnection:n||b.getState().isValidConnection||RE}),t?null==h||h(e):null==f||f(e)};return u.createElement("div",{"data-handleid":x,"data-nodeid":w,"data-handlepos":t,"data-id":`${w}-${x}-${e}`,className:Tk(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",N,d,{source:!y,target:y,connectable:o,connectablestart:a,connectableend:s,connecting:C,connectionindicator:o&&(a&&!E||s&&E)}]),onMouseDown:S,onTouchStart:S,onClick:k?t=>{const{onClickConnectStart:o,onClickConnectEnd:r,connectionClickStartHandle:s,connectionMode:i,isValidConnection:l}=b.getState();if(!w||!s&&!a)return;if(!s)return null==o||o(t,{nodeId:w,handleId:x,handleType:e}),void b.setState({connectionClickStartHandle:{nodeId:w,type:e,handleId:x}});const c=AN(t.target),d=n||l||RE,{connection:u,isValid:h}=TE({nodeId:w,id:x,type:e},i,s.nodeId,s.handleId||null,s.type,d,c);h&&j(u),null==r||r(t),b.setState({connectionClickStartHandle:null})}:void 0,ref:p,...m},c)}));LE.displayName="Handle";var zE=r.memo(LE);const BE=({data:e,isConnectable:t,targetPosition:n=eE.Top,sourcePosition:o=eE.Bottom})=>u.createElement(u.Fragment,null,u.createElement(zE,{type:"target",position:n,isConnectable:t}),null==e?void 0:e.label,u.createElement(zE,{type:"source",position:o,isConnectable:t}));BE.displayName="DefaultNode";var UE=r.memo(BE);const VE=({data:e,isConnectable:t,sourcePosition:n=eE.Bottom})=>u.createElement(u.Fragment,null,null==e?void 0:e.label,u.createElement(zE,{type:"source",position:n,isConnectable:t}));VE.displayName="InputNode";var $E=r.memo(VE);const GE=({data:e,isConnectable:t,targetPosition:n=eE.Top})=>u.createElement(u.Fragment,null,u.createElement(zE,{type:"target",position:n,isConnectable:t}),null==e?void 0:e.label);GE.displayName="OutputNode";var HE=r.memo(GE);const WE=()=>null;WE.displayName="GroupNode";const qE=e=>({selectedNodes:e.getNodes().filter((e=>e.selected)),selectedEdges:e.edges.filter((e=>e.selected)).map((e=>({...e})))}),YE=e=>e.id;function JE(e,t){return Fk(e.selectedNodes.map(YE),t.selectedNodes.map(YE))&&Fk(e.selectedEdges.map(YE),t.selectedEdges.map(YE))}const KE=r.memo((({onSelectionChange:e})=>{const t=yN(),{selectedNodes:n,selectedEdges:o}=xN(qE,JE);return r.useEffect((()=>{const r={nodes:n,edges:o};null==e||e(r),t.getState().onSelectionChange.forEach((e=>e(r)))}),[n,o,e]),null}));KE.displayName="SelectionListener";const XE=e=>!!e.onSelectionChange;function ZE({onSelectionChange:e}){const t=xN(XE);return e||t?u.createElement(KE,{onSelectionChange:e}):null}const QE=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function eC(e,t){r.useEffect((()=>{void 0!==e&&t(e)}),[e])}function tC(e,t,n){r.useEffect((()=>{void 0!==t&&n({[e]:t})}),[t])}const nC=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:a,onConnectStart:s,onConnectEnd:i,onClickConnectStart:l,onClickConnectEnd:c,nodesDraggable:d,nodesConnectable:u,nodesFocusable:h,edgesFocusable:f,edgesUpdatable:m,elevateNodesOnSelect:p,minZoom:g,maxZoom:v,nodeExtent:x,onNodesChange:y,onEdgesChange:b,elementsSelectable:w,connectionMode:k,snapGrid:N,snapToGrid:E,translateExtent:C,connectOnClick:j,defaultEdgeOptions:S,fitView:I,fitViewOptions:A,onNodesDelete:M,onEdgesDelete:T,onNodeDrag:O,onNodeDragStart:D,onNodeDragStop:_,onSelectionDrag:P,onSelectionDragStart:R,onSelectionDragStop:F,noPanClassName:L,nodeOrigin:z,rfId:B,autoPanOnConnect:U,autoPanOnNodeDrag:V,onError:$,connectionRadius:G,isValidConnection:H,nodeDragThreshold:W})=>{const{setNodes:q,setEdges:Y,setDefaultNodesAndEdges:J,setMinZoom:K,setMaxZoom:X,setTranslateExtent:Z,setNodeExtent:Q,reset:ee}=xN(QE,Fk),te=yN();return r.useEffect((()=>{const e=null==o?void 0:o.map((e=>({...e,...S})));return J(n,e),()=>{ee()}}),[]),tC("defaultEdgeOptions",S,te.setState),tC("connectionMode",k,te.setState),tC("onConnect",a,te.setState),tC("onConnectStart",s,te.setState),tC("onConnectEnd",i,te.setState),tC("onClickConnectStart",l,te.setState),tC("onClickConnectEnd",c,te.setState),tC("nodesDraggable",d,te.setState),tC("nodesConnectable",u,te.setState),tC("nodesFocusable",h,te.setState),tC("edgesFocusable",f,te.setState),tC("edgesUpdatable",m,te.setState),tC("elementsSelectable",w,te.setState),tC("elevateNodesOnSelect",p,te.setState),tC("snapToGrid",E,te.setState),tC("snapGrid",N,te.setState),tC("onNodesChange",y,te.setState),tC("onEdgesChange",b,te.setState),tC("connectOnClick",j,te.setState),tC("fitViewOnInit",I,te.setState),tC("fitViewOnInitOptions",A,te.setState),tC("onNodesDelete",M,te.setState),tC("onEdgesDelete",T,te.setState),tC("onNodeDrag",O,te.setState),tC("onNodeDragStart",D,te.setState),tC("onNodeDragStop",_,te.setState),tC("onSelectionDrag",P,te.setState),tC("onSelectionDragStart",R,te.setState),tC("onSelectionDragStop",F,te.setState),tC("noPanClassName",L,te.setState),tC("nodeOrigin",z,te.setState),tC("rfId",B,te.setState),tC("autoPanOnConnect",U,te.setState),tC("autoPanOnNodeDrag",V,te.setState),tC("onError",$,te.setState),tC("connectionRadius",G,te.setState),tC("isValidConnection",H,te.setState),tC("nodeDragThreshold",W,te.setState),eC(e,q),eC(t,Y),eC(g,K),eC(v,X),eC(C,Z),eC(x,Q),null},oC={display:"none"},rC={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},aC="react-flow__node-desc",sC="react-flow__edge-desc",iC=e=>e.ariaLiveMessage;function lC({rfId:e}){const t=xN(iC);return u.createElement("div",{id:`react-flow__aria-live-${e}`,"aria-live":"assertive","aria-atomic":"true",style:rC},t)}function cC({rfId:e,disableKeyboardA11y:t}){return u.createElement(u.Fragment,null,u.createElement("div",{id:`${aC}-${e}`,style:oC},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),u.createElement("div",{id:`${sC}-${e}`,style:oC},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&u.createElement(lC,{rfId:e}))}var dC=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,o]=r.useState(!1),a=r.useRef(!1),s=r.useRef(new Set([])),[i,l]=r.useMemo((()=>{if(null!==e){const t=(Array.isArray(e)?e:[e]).filter((e=>"string"==typeof e)).map((e=>e.split("+"))),n=t.reduce(((e,t)=>e.concat(...t)),[]);return[t,n]}return[[],[]]}),[e]);return r.useEffect((()=>{const n="undefined"!=typeof document?document:null,r=(null==t?void 0:t.target)||n;if(null!==e){const e=e=>{a.current=e.ctrlKey||e.metaKey||e.shiftKey;if((!a.current||a.current&&!t.actInsideInputWithModifier)&&RN(e))return!1;const n=hC(e.code,l);s.current.add(e[n]),uC(i,s.current,!1)&&(e.preventDefault(),o(!0))},n=e=>{if((!a.current||a.current&&!t.actInsideInputWithModifier)&&RN(e))return!1;const n=hC(e.code,l);uC(i,s.current,!0)?(o(!1),s.current.clear()):s.current.delete(e[n]),"Meta"===e.key&&s.current.clear(),a.current=!1},c=()=>{s.current.clear(),o(!1)};return null==r||r.addEventListener("keydown",e),null==r||r.addEventListener("keyup",n),window.addEventListener("blur",c),()=>{null==r||r.removeEventListener("keydown",e),null==r||r.removeEventListener("keyup",n),window.removeEventListener("blur",c)}}}),[e,o]),n};function uC(e,t,n){return e.filter((e=>n||e.length===t.size)).some((e=>e.every((e=>t.has(e)))))}function hC(e,t){return t.includes(e)?"code":"key"}function fC(e,t,n,o){var r,a;const s=e.parentNode||e.parentId;if(!s)return n;const i=t.get(s),l=kE(i,o);return fC(i,t,{x:(n.x??0)+l.x,y:(n.y??0)+l.y,z:((null==(r=i[_N])?void 0:r.z)??0)>(n.z??0)?(null==(a=i[_N])?void 0:a.z)??0:n.z??0},o)}function mC(e,t,n){e.forEach((o=>{var r;const a=o.parentNode||o.parentId;if(a&&!e.has(a))throw new Error(`Parent node ${a} not found`);if(a||(null==n?void 0:n[o.id])){const{x:a,y:s,z:i}=fC(o,e,{...o.position,z:(null==(r=o[_N])?void 0:r.z)??0},t);o.positionAbsolute={x:a,y:s},o[_N].z=i,(null==n?void 0:n[o.id])&&(o[_N].isParent=!0)}}))}function pC(e,t,n,o){const r=new Map,a={},s=o?1e3:0;return e.forEach((e=>{var n;const o=(DN(e.zIndex)?e.zIndex:0)+(e.selected?s:0),i=t.get(e.id),l={...e,positionAbsolute:{x:e.position.x,y:e.position.y}},c=e.parentNode||e.parentId;c&&(a[c]=!0);const d=(null==i?void 0:i.type)&&(null==i?void 0:i.type)!==e.type;Object.defineProperty(l,_N,{enumerable:!1,value:{handleBounds:d||null==(n=null==i?void 0:i[_N])?void 0:n.handleBounds,z:o}}),r.set(e.id,l)})),mC(r,n,a),r}function gC(e,t={}){const{getNodes:n,width:o,height:r,minZoom:a,maxZoom:s,d3Zoom:i,d3Selection:l,fitViewOnInitDone:c,fitViewOnInit:d,nodeOrigin:u}=e(),h=t.initial&&!c&&d;if(i&&l&&(h||!t.initial)){const e=n().filter((e=>{var n;const o=t.includeHiddenNodes?e.width&&e.height:!e.hidden;return(null==(n=t.nodes)?void 0:n.length)?o&&t.nodes.some((t=>t.id===e.id)):o})),c=e.every((e=>e.width&&e.height));if(e.length>0&&c){const n=NE(e,u),{x:c,y:d,zoom:h}=jE(n,o,r,t.minZoom??a,t.maxZoom??s,t.padding??.1),f=gl.translate(c,d).scale(h);return"number"==typeof t.duration&&t.duration>0?i.transform(SE(l,t.duration),f):i.transform(l,f),!0}}return!1}function vC(e,t){return e.forEach((e=>{const n=t.get(e.id);n&&t.set(n.id,{...n,[_N]:n[_N],selected:e.selected})})),new Map(t)}function xC(e,t){return t.map((t=>{const n=e.find((e=>e.id===t.id));return n&&(t.selected=n.selected),t}))}function yC({changedNodes:e,changedEdges:t,get:n,set:o}){const{nodeInternals:r,edges:a,onNodesChange:s,onEdgesChange:i,hasDefaultNodes:l,hasDefaultEdges:c}=n();(null==e?void 0:e.length)&&(l&&o({nodeInternals:vC(e,r)}),null==s||s(e)),(null==t?void 0:t.length)&&(c&&o({edges:xC(t,a)}),null==i||i(t))}const bC=()=>{},wC={zoomIn:bC,zoomOut:bC,zoomTo:bC,getZoom:()=>1,setViewport:bC,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:bC,fitBounds:bC,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},kC=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection});function NC(){const e=(()=>{const e=yN(),{d3Zoom:t,d3Selection:n}=xN(kC,Fk);return r.useMemo((()=>n&&t?{zoomIn:e=>t.scaleBy(SE(n,null==e?void 0:e.duration),1.2),zoomOut:e=>t.scaleBy(SE(n,null==e?void 0:e.duration),1/1.2),zoomTo:(e,o)=>t.scaleTo(SE(n,null==o?void 0:o.duration),e),getZoom:()=>e.getState().transform[2],setViewport:(o,r)=>{const[a,s,i]=e.getState().transform,l=gl.translate(o.x??a,o.y??s).scale(o.zoom??i);t.transform(SE(n,null==r?void 0:r.duration),l)},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},fitView:t=>gC(e.getState,t),setCenter:(o,r,a)=>{const{width:s,height:i,maxZoom:l}=e.getState(),c=void 0!==(null==a?void 0:a.zoom)?a.zoom:l,d=s/2-o*c,u=i/2-r*c,h=gl.translate(d,u).scale(c);t.transform(SE(n,null==a?void 0:a.duration),h)},fitBounds:(o,r)=>{const{width:a,height:s,minZoom:i,maxZoom:l}=e.getState(),{x:c,y:d,zoom:u}=jE(o,a,s,i,l,(null==r?void 0:r.padding)??.1),h=gl.translate(c,d).scale(u);t.transform(SE(n,null==r?void 0:r.duration),h)},project:t=>{const{transform:n,snapToGrid:o,snapGrid:r}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),bE(t,n,o,r)},screenToFlowPosition:t=>{const{transform:n,snapToGrid:o,snapGrid:r,domNode:a}=e.getState();if(!a)return t;const{x:s,y:i}=a.getBoundingClientRect(),l={x:t.x-s,y:t.y-i};return bE(l,n,o,r)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:a}=o.getBoundingClientRect(),s=wE(t,n);return{x:s.x+r,y:s.y+a}},viewportInitialized:!0}:wC),[t,n])})(),t=yN(),n=r.useCallback((()=>t.getState().getNodes().map((e=>({...e})))),[]),o=r.useCallback((e=>t.getState().nodeInternals.get(e)),[]),a=r.useCallback((()=>{const{edges:e=[]}=t.getState();return e.map((e=>({...e})))}),[]),s=r.useCallback((e=>{const{edges:n=[]}=t.getState();return n.find((t=>t.id===e))}),[]),i=r.useCallback((e=>{const{getNodes:n,setNodes:o,hasDefaultNodes:r,onNodesChange:a}=t.getState(),s=n(),i="function"==typeof e?e(s):e;if(r)o(i);else if(a){a(0===i.length?s.map((e=>({type:"remove",id:e.id}))):i.map((e=>({item:e,type:"reset"}))))}}),[]),l=r.useCallback((e=>{const{edges:n=[],setEdges:o,hasDefaultEdges:r,onEdgesChange:a}=t.getState(),s="function"==typeof e?e(n):e;if(r)o(s);else if(a){a(0===s.length?n.map((e=>({type:"remove",id:e.id}))):s.map((e=>({item:e,type:"reset"}))))}}),[]),c=r.useCallback((e=>{const n=Array.isArray(e)?e:[e],{getNodes:o,setNodes:r,hasDefaultNodes:a,onNodesChange:s}=t.getState();if(a){r([...o(),...n])}else if(s){s(n.map((e=>({item:e,type:"add"}))))}}),[]),d=r.useCallback((e=>{const n=Array.isArray(e)?e:[e],{edges:o=[],setEdges:r,hasDefaultEdges:a,onEdgesChange:s}=t.getState();if(a)r([...o,...n]);else if(s){s(n.map((e=>({item:e,type:"add"}))))}}),[]),u=r.useCallback((()=>{const{getNodes:e,edges:n=[],transform:o}=t.getState(),[r,a,s]=o;return{nodes:e().map((e=>({...e}))),edges:n.map((e=>({...e}))),viewport:{x:r,y:a,zoom:s}}}),[]),h=r.useCallback((({nodes:e,edges:n})=>{const{nodeInternals:o,getNodes:r,edges:a,hasDefaultNodes:s,hasDefaultEdges:i,onNodesDelete:l,onEdgesDelete:c,onNodesChange:d,onEdgesChange:u}=t.getState(),h=(e||[]).map((e=>e.id)),f=(n||[]).map((e=>e.id)),m=r().reduce(((e,t)=>{const n=t.parentNode||t.parentId,o=!h.includes(t.id)&&n&&e.find((e=>e.id===n));return("boolean"!=typeof t.deletable||t.deletable)&&(h.includes(t.id)||o)&&e.push(t),e}),[]),p=a.filter((e=>"boolean"!=typeof e.deletable||e.deletable)),g=p.filter((e=>f.includes(e.id)));if(m||g){const e=CE(m,p),n=[...g,...e],r=n.reduce(((e,t)=>(e.includes(t.id)||e.push(t.id),e)),[]);if((i||s)&&(i&&t.setState({edges:a.filter((e=>!r.includes(e.id)))}),s&&(m.forEach((e=>{o.delete(e.id)})),t.setState({nodeInternals:new Map(o)}))),r.length>0&&(null==c||c(n),u&&u(r.map((e=>({id:e,type:"remove"}))))),m.length>0&&(null==l||l(m),d)){d(m.map((e=>({id:e.id,type:"remove"}))))}}}),[]),f=r.useCallback((e=>{const n=DN((o=e).width)&&DN(o.height)&&DN(o.x)&&DN(o.y);var o;const r=n?null:t.getState().nodeInternals.get(e.id);if(!n&&!r)return[null,null,n];return[n?e:TN(r),r,n]}),[]),m=r.useCallback(((e,n=!0,o)=>{const[r,a,s]=f(e);return r?(o||t.getState().getNodes()).filter((e=>{if(!(s||e.id!==a.id&&e.positionAbsolute))return!1;const t=TN(e),o=ON(t,r);return n&&o>0||o>=r.width*r.height})):[]}),[]),p=r.useCallback(((e,t,n=!0)=>{const[o]=f(e);if(!o)return!1;const r=ON(o,t);return n&&r>0||r>=o.width*o.height}),[]);return r.useMemo((()=>({...e,getNodes:n,getNode:o,getEdges:a,getEdge:s,setNodes:i,setEdges:l,addNodes:c,addEdges:d,toObject:u,deleteElements:h,getIntersectingNodes:m,isNodeIntersecting:p})),[e,n,o,a,s,i,l,c,d,u,h,m,p])}const EC={actInsideInputWithModifier:!1};const CC={position:"absolute",width:"100%",height:"100%",top:0,left:0},jC=e=>({x:e.x,y:e.y,zoom:e.k}),SC=(e,t)=>e.target.closest(`.${t}`),IC=(e,t)=>2===t&&Array.isArray(e)&&e.includes(2),AC=e=>{const t=e.ctrlKey&&zN()?10:1;return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*t},MC=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),TC=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:o,zoomOnScroll:a=!0,zoomOnPinch:s=!0,panOnScroll:i=!1,panOnScrollSpeed:l=.5,panOnScrollMode:c=WN.Free,zoomOnDoubleClick:d=!0,elementsSelectable:h,panOnDrag:f=!0,defaultViewport:m,translateExtent:p,minZoom:g,maxZoom:v,zoomActivationKeyCode:x,preventScrolling:y=!0,children:b,noWheelClassName:w,noPanClassName:k})=>{const N=r.useRef(),E=yN(),C=r.useRef(!1),j=r.useRef(!1),S=r.useRef(null),I=r.useRef({x:0,y:0,zoom:0}),{d3Zoom:A,d3Selection:M,d3ZoomHandler:T,userSelectionActive:O}=xN(MC,Fk),D=dC(x),_=r.useRef(0),P=r.useRef(!1),R=r.useRef();return function(e){const t=yN();r.useEffect((()=>{let n;const o=()=>{var n,o;if(!e.current)return;const r=EN(e.current);0!==r.height&&0!==r.width||null==(o=(n=t.getState()).onError)||o.call(n,"004",dN()),t.setState({width:r.width||500,height:r.height||500})};return o(),window.addEventListener("resize",o),e.current&&(n=new ResizeObserver((()=>o())),n.observe(e.current)),()=>{window.removeEventListener("resize",o),n&&e.current&&n.unobserve(e.current)}}),[])}(S),r.useEffect((()=>{if(S.current){const e=S.current.getBoundingClientRect(),t=function(){var e,t,n,o=tN,r=nN,a=sN,s=rN,i=aN,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],d=250,u=bl,h=yl("start","zoom","end"),f=0,m=10;function p(e){e.property("__zoom",oN).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",N).on("dblclick.zoom",E).filter(i).on("touchstart.zoom",C).on("touchmove.zoom",j).on("touchend.zoom touchcancel.zoom",S).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(e,t){return(t=Math.max(l[0],Math.min(l[1],t)))===e.k?e:new vl(t,e.x,e.y)}function v(e,t,n){var o=t[0]-n[0]*e.k,r=t[1]-n[1]*e.k;return o===e.x&&r===e.y?e:new vl(e.k,o,r)}function x(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function y(e,t,n,o){e.on("start.zoom",(function(){b(this,arguments).event(o).start()})).on("interrupt.zoom end.zoom",(function(){b(this,arguments).event(o).end()})).tween("zoom",(function(){var e=this,a=arguments,s=b(e,a).event(o),i=r.apply(e,a),l=null==n?x(i):"function"==typeof n?n.apply(e,a):n,c=Math.max(i[1][0]-i[0][0],i[1][1]-i[0][1]),d=e.__zoom,h="function"==typeof t?t.apply(e,a):t,f=u(d.invert(l).concat(c/d.k),h.invert(l).concat(c/h.k));return function(e){if(1===e)e=h;else{var t=f(e),n=c/t[2];e=new vl(n,l[0]-t[0]*n,l[1]-t[1]*n)}s.zoom(null,e)}}))}function b(e,t,n){return!n&&e.__zooming||new w(e,t)}function w(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=r.apply(e,t),this.taps=0}function k(e,...t){if(o.apply(this,arguments)){var n=b(this,t).event(e),r=this.__zoom,i=Math.max(l[0],Math.min(l[1],r.k*Math.pow(2,s.apply(this,arguments)))),d=Lk(e);if(n.wheel)n.mouse[0][0]===d[0]&&n.mouse[0][1]===d[1]||(n.mouse[1]=r.invert(n.mouse[0]=d)),clearTimeout(n.wheel);else{if(r.k===i)return;n.mouse=[d,r.invert(d)],xl(this),n.start()}eN(e),n.wheel=setTimeout((function(){n.wheel=null,n.end()}),150),n.zoom("mouse",a(v(g(r,i),n.mouse[0],n.mouse[1]),n.extent,c))}}function N(e,...t){if(!n&&o.apply(this,arguments)){var r=e.currentTarget,s=b(this,t,!0).event(e),i=pl(e.view).on("mousemove.zoom",(function(e){if(eN(e),!s.moved){var t=e.clientX-d,n=e.clientY-u;s.moved=t*t+n*n>f}s.event(e).zoom("mouse",a(v(s.that.__zoom,s.mouse[0]=Lk(e,r),s.mouse[1]),s.extent,c))}),!0).on("mouseup.zoom",(function(e){i.on("mousemove.zoom mouseup.zoom",null),Gk(e.view,s.moved),eN(e),s.event(e).end()}),!0),l=Lk(e,r),d=e.clientX,u=e.clientY;$k(e.view),Qk(e),s.mouse=[l,this.__zoom.invert(l)],xl(this),s.start()}}function E(e,...t){if(o.apply(this,arguments)){var n=this.__zoom,s=Lk(e.changedTouches?e.changedTouches[0]:e,this),i=n.invert(s),l=n.k*(e.shiftKey?.5:2),u=a(v(g(n,l),s,i),r.apply(this,t),c);eN(e),d>0?pl(this).transition().duration(d).call(y,u,s,e):pl(this).call(p.transform,u,s,e)}}function C(n,...r){if(o.apply(this,arguments)){var a,s,i,l,c=n.touches,d=c.length,u=b(this,r,n.changedTouches.length===d).event(n);for(Qk(n),s=0;s<d;++s)l=[l=Lk(i=c[s],this),this.__zoom.invert(l),i.identifier],u.touch0?u.touch1||u.touch0[2]===l[2]||(u.touch1=l,u.taps=0):(u.touch0=l,a=!0,u.taps=1+!!e);e&&(e=clearTimeout(e)),a&&(u.taps<2&&(t=l[0],e=setTimeout((function(){e=null}),500)),xl(this),u.start())}}function j(e,...t){if(this.__zooming){var n,o,r,s,i=b(this,t).event(e),l=e.changedTouches,d=l.length;for(eN(e),n=0;n<d;++n)r=Lk(o=l[n],this),i.touch0&&i.touch0[2]===o.identifier?i.touch0[0]=r:i.touch1&&i.touch1[2]===o.identifier&&(i.touch1[0]=r);if(o=i.that.__zoom,i.touch1){var u=i.touch0[0],h=i.touch0[1],f=i.touch1[0],m=i.touch1[1],p=(p=f[0]-u[0])*p+(p=f[1]-u[1])*p,x=(x=m[0]-h[0])*x+(x=m[1]-h[1])*x;o=g(o,Math.sqrt(p/x)),r=[(u[0]+f[0])/2,(u[1]+f[1])/2],s=[(h[0]+m[0])/2,(h[1]+m[1])/2]}else{if(!i.touch0)return;r=i.touch0[0],s=i.touch0[1]}i.zoom("touch",a(v(o,r,s),i.extent,c))}}function S(e,...o){if(this.__zooming){var r,a,s=b(this,o).event(e),i=e.changedTouches,l=i.length;for(Qk(e),n&&clearTimeout(n),n=setTimeout((function(){n=null}),500),r=0;r<l;++r)a=i[r],s.touch0&&s.touch0[2]===a.identifier?delete s.touch0:s.touch1&&s.touch1[2]===a.identifier&&delete s.touch1;if(s.touch1&&!s.touch0&&(s.touch0=s.touch1,delete s.touch1),s.touch0)s.touch0[1]=this.__zoom.invert(s.touch0[0]);else if(s.end(),2===s.taps&&(a=Lk(a,this),Math.hypot(t[0]-a[0],t[1]-a[1])<m)){var c=pl(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return p.transform=function(e,t,n,o){var r=e.selection?e.selection():e;r.property("__zoom",oN),e!==r?y(e,t,n,o):r.interrupt().each((function(){b(this,arguments).event(o).start().zoom(null,"function"==typeof t?t.apply(this,arguments):t).end()}))},p.scaleBy=function(e,t,n,o){p.scaleTo(e,(function(){return this.__zoom.k*("function"==typeof t?t.apply(this,arguments):t)}),n,o)},p.scaleTo=function(e,t,n,o){p.transform(e,(function(){var e=r.apply(this,arguments),o=this.__zoom,s=null==n?x(e):"function"==typeof n?n.apply(this,arguments):n,i=o.invert(s),l="function"==typeof t?t.apply(this,arguments):t;return a(v(g(o,l),s,i),e,c)}),n,o)},p.translateBy=function(e,t,n,o){p.transform(e,(function(){return a(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),r.apply(this,arguments),c)}),null,o)},p.translateTo=function(e,t,n,o,s){p.transform(e,(function(){var e=r.apply(this,arguments),s=this.__zoom,i=null==o?x(e):"function"==typeof o?o.apply(this,arguments):o;return a(gl.translate(i[0],i[1]).scale(s.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,c)}),o,s)},w.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(e,t){return this.mouse&&"mouse"!==e&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&"touch"!==e&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&"touch"!==e&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(e){var t=pl(this.that).datum();h.call(e,this.that,new Zk(e,{sourceEvent:this.sourceEvent,target:p,type:e,transform:this.that.__zoom,dispatch:h}),t)}},p.wheelDelta=function(e){return arguments.length?(s="function"==typeof e?e:Xk(+e),p):s},p.filter=function(e){return arguments.length?(o="function"==typeof e?e:Xk(!!e),p):o},p.touchable=function(e){return arguments.length?(i="function"==typeof e?e:Xk(!!e),p):i},p.extent=function(e){return arguments.length?(r="function"==typeof e?e:Xk([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),p):r},p.scaleExtent=function(e){return arguments.length?(l[0]=+e[0],l[1]=+e[1],p):[l[0],l[1]]},p.translateExtent=function(e){return arguments.length?(c[0][0]=+e[0][0],c[1][0]=+e[1][0],c[0][1]=+e[0][1],c[1][1]=+e[1][1],p):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},p.constrain=function(e){return arguments.length?(a=e,p):a},p.duration=function(e){return arguments.length?(d=+e,p):d},p.interpolate=function(e){return arguments.length?(u=e,p):u},p.on=function(){var e=h.on.apply(h,arguments);return e===h?p:e},p.clickDistance=function(e){return arguments.length?(f=(e=+e)*e,p):Math.sqrt(f)},p.tapDistance=function(e){return arguments.length?(m=+e,p):m},p}().scaleExtent([g,v]).translateExtent(p),n=pl(S.current).call(t),o=gl.translate(m.x,m.y).scale(CN(m.zoom,g,v)),r=[[0,0],[e.width,e.height]],a=t.constrain()(o,r,p);t.transform(n,a),t.wheelDelta(AC),E.setState({d3Zoom:t,d3Selection:n,d3ZoomHandler:n.on("wheel.zoom"),transform:[a.x,a.y,a.k],domNode:S.current.closest(".react-flow")})}}),[]),r.useEffect((()=>{M&&A&&(!i||D||O?void 0!==T&&M.on("wheel.zoom",(function(e,t){if(!y&&"wheel"===e.type&&!e.ctrlKey||SC(e,w))return null;e.preventDefault(),T.call(this,e,t)}),{passive:!1}):M.on("wheel.zoom",(o=>{if(SC(o,w))return!1;o.preventDefault(),o.stopImmediatePropagation();const r=M.property("__zoom").k||1;if(o.ctrlKey&&s){const e=Lk(o),t=AC(o),n=r*Math.pow(2,t);return void A.scaleTo(M,n,e,o)}const a=1===o.deltaMode?20:1;let i=c===WN.Vertical?0:o.deltaX*a,d=c===WN.Horizontal?0:o.deltaY*a;!zN()&&o.shiftKey&&c!==WN.Vertical&&(i=o.deltaY*a,d=0),A.translateBy(M,-i/r*l,-d/r*l,{internal:!0});const u=jC(M.property("__zoom")),{onViewportChangeStart:h,onViewportChange:f,onViewportChangeEnd:m}=E.getState();clearTimeout(R.current),P.current||(P.current=!0,null==t||t(o,u),null==h||h(u)),P.current&&(null==e||e(o,u),null==f||f(u),R.current=setTimeout((()=>{null==n||n(o,u),null==m||m(u),P.current=!1}),150))}),{passive:!1}))}),[O,i,c,M,A,T,D,s,y,w,t,e,n]),r.useEffect((()=>{A&&A.on("start",(e=>{var n,o;if(!e.sourceEvent||e.sourceEvent.internal)return null;_.current=null==(n=e.sourceEvent)?void 0:n.button;const{onViewportChangeStart:r}=E.getState(),a=jC(e.transform);C.current=!0,I.current=a,"mousedown"===(null==(o=e.sourceEvent)?void 0:o.type)&&E.setState({paneDragging:!0}),null==r||r(a),null==t||t(e.sourceEvent,a)}))}),[A,t]),r.useEffect((()=>{A&&(O&&!C.current?A.on("zoom",null):O||A.on("zoom",(t=>{var n;const{onViewportChange:r}=E.getState();if(E.setState({transform:[t.transform.x,t.transform.y,t.transform.k]}),j.current=!(!o||!IC(f,_.current??0)),(e||r)&&!(null==(n=t.sourceEvent)?void 0:n.internal)){const n=jC(t.transform);null==r||r(n),null==e||e(t.sourceEvent,n)}})))}),[O,A,e,f,o]),r.useEffect((()=>{A&&A.on("end",(e=>{if(!e.sourceEvent||e.sourceEvent.internal)return null;const{onViewportChangeEnd:t}=E.getState();if(C.current=!1,E.setState({paneDragging:!1}),o&&IC(f,_.current??0)&&!j.current&&o(e.sourceEvent),j.current=!1,(n||t)&&(r=I.current,a=e.transform,r.x!==a.x||r.y!==a.y||r.zoom!==a.k)){const o=jC(e.transform);I.current=o,clearTimeout(N.current),N.current=setTimeout((()=>{null==t||t(o),null==n||n(e.sourceEvent,o)}),i?150:0)}var r,a}))}),[A,i,f,n,o]),r.useEffect((()=>{A&&A.filter((e=>{const t=D||a,n=s&&e.ctrlKey;if((!0===f||Array.isArray(f)&&f.includes(1))&&1===e.button&&"mousedown"===e.type&&(SC(e,"react-flow__node")||SC(e,"react-flow__edge")))return!0;if(!(f||t||i||d||s))return!1;if(O)return!1;if(!d&&"dblclick"===e.type)return!1;if(SC(e,w)&&"wheel"===e.type)return!1;if(SC(e,k)&&("wheel"!==e.type||i&&"wheel"===e.type&&!D))return!1;if(!s&&e.ctrlKey&&"wheel"===e.type)return!1;if(!t&&!i&&!n&&"wheel"===e.type)return!1;if(!f&&("mousedown"===e.type||"touchstart"===e.type))return!1;if(Array.isArray(f)&&!f.includes(e.button)&&"mousedown"===e.type)return!1;const o=Array.isArray(f)&&f.includes(e.button)||!e.button||e.button<=1;return(!e.ctrlKey||"wheel"===e.type)&&o}))}),[O,A,a,s,i,d,f,h,D]),u.createElement("div",{className:"react-flow__renderer",ref:S,style:CC},b)},OC=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function DC(){const{userSelectionActive:e,userSelectionRect:t}=xN(OC,Fk);return e&&t?u.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function _C(e,t){const n=t.parentNode||t.parentId,o=e.find((e=>e.id===n));if(o){const e=t.position.x+t.width-o.width,n=t.position.y+t.height-o.height;if(e>0||n>0||t.position.x<0||t.position.y<0){if(o.style={...o.style},o.style.width=o.style.width??o.width,o.style.height=o.style.height??o.height,e>0&&(o.style.width+=e),n>0&&(o.style.height+=n),t.position.x<0){const e=Math.abs(t.position.x);o.position.x=o.position.x-e,o.style.width+=e,t.position.x=0}if(t.position.y<0){const e=Math.abs(t.position.y);o.position.y=o.position.y-e,o.style.height+=e,t.position.y=0}o.width=o.style.width,o.height=o.style.height}}}function PC(e,t){if(e.some((e=>"reset"===e.type)))return e.filter((e=>"reset"===e.type)).map((e=>e.item));const n=e.filter((e=>"add"===e.type)).map((e=>e.item));return t.reduce(((t,n)=>{const o=e.filter((e=>e.id===n.id));if(0===o.length)return t.push(n),t;const r={...n};for(const e of o)if(e)switch(e.type){case"select":r.selected=e.selected;break;case"position":void 0!==e.position&&(r.position=e.position),void 0!==e.positionAbsolute&&(r.positionAbsolute=e.positionAbsolute),void 0!==e.dragging&&(r.dragging=e.dragging),r.expandParent&&_C(t,r);break;case"dimensions":void 0!==e.dimensions&&(r.width=e.dimensions.width,r.height=e.dimensions.height),void 0!==e.updateStyle&&(r.style={...r.style||{},...e.dimensions}),"boolean"==typeof e.resizing&&(r.resizing=e.resizing),r.expandParent&&_C(t,r);break;case"remove":return t}return t.push(r),t}),n)}function RC(e,t){return PC(e,t)}const FC=(e,t)=>({id:e,type:"select",selected:t});function LC(e,t){return e.reduce(((e,n)=>{const o=t.includes(n.id);return!n.selected&&o?(n.selected=!0,e.push(FC(n.id,!0))):n.selected&&!o&&(n.selected=!1,e.push(FC(n.id,!1))),e}),[])}const zC=(e,t)=>n=>{n.target===t.current&&(null==e||e(n))},BC=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),UC=r.memo((({isSelecting:e,selectionMode:t=YN.Full,panOnDrag:n,onSelectionStart:o,onSelectionEnd:a,onPaneClick:s,onPaneContextMenu:i,onPaneScroll:l,onPaneMouseEnter:c,onPaneMouseMove:d,onPaneMouseLeave:h,children:f})=>{const m=r.useRef(null),p=yN(),g=r.useRef(0),v=r.useRef(0),x=r.useRef(),{userSelectionActive:y,elementsSelectable:b,dragging:w}=xN(BC,Fk),k=()=>{p.setState({userSelectionActive:!1,userSelectionRect:null}),g.current=0,v.current=0},N=e=>{null==s||s(e),p.getState().resetSelectedElements(),p.setState({nodesSelectionActive:!1})},E=l?e=>l(e):void 0,C=b&&(e||y);return u.createElement("div",{className:Tk(["react-flow__pane",{dragging:w,selection:e}]),onClick:C?void 0:zC(N,m),onContextMenu:zC((e=>{Array.isArray(n)&&(null==n?void 0:n.includes(2))?e.preventDefault():null==i||i(e)}),m),onWheel:zC(E,m),onMouseEnter:C?void 0:c,onMouseDown:C?t=>{const{resetSelectedElements:n,domNode:r}=p.getState();if(x.current=null==r?void 0:r.getBoundingClientRect(),!b||!e||0!==t.button||t.target!==m.current||!x.current)return;const{x:a,y:s}=LN(t,x.current);n(),p.setState({userSelectionRect:{width:0,height:0,startX:a,startY:s,x:a,y:s}}),null==o||o(t)}:void 0,onMouseMove:C?n=>{const{userSelectionRect:o,nodeInternals:r,edges:a,transform:s,onNodesChange:i,onEdgesChange:l,nodeOrigin:c,getNodes:d}=p.getState();if(!e||!x.current||!o)return;p.setState({userSelectionActive:!0,nodesSelectionActive:!1});const u=LN(n,x.current),h=o.startX??0,f=o.startY??0,m={...o,x:u.x<h?u.x:h,y:u.y<f?u.y:f,width:Math.abs(u.x-h),height:Math.abs(u.y-f)},y=d(),b=EE(r,m,s,t===YN.Partial,!0,c),w=CE(b,a).map((e=>e.id)),k=b.map((e=>e.id));if(g.current!==k.length){g.current=k.length;const e=LC(y,k);e.length&&(null==i||i(e))}if(v.current!==w.length){v.current=w.length;const e=LC(a,w);e.length&&(null==l||l(e))}p.setState({userSelectionRect:m})}:d,onMouseUp:C?e=>{if(0!==e.button)return;const{userSelectionRect:t}=p.getState();!y&&t&&e.target===m.current&&(null==N||N(e)),p.setState({nodesSelectionActive:g.current>0}),k(),null==a||a(e)}:void 0,onMouseLeave:C?e=>{y&&(p.setState({nodesSelectionActive:g.current>0}),null==a||a(e)),k()}:h,ref:m,style:CC},f,u.createElement(DC,null))}));function VC(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const o=t.get(n);return!!o&&(!!o.selected||VC(o,t))}function $C(e,t,n){let o=e;do{if(null==o?void 0:o.matches(t))return!0;if(o===n.current)return!1;o=o.parentElement}while(o);return!1}function GC(e,t,n,o){return Array.from(e.values()).filter((n=>(n.selected||n.id===o)&&(!n.parentNode||n.parentId||!VC(n,e))&&(n.draggable||t&&void 0===n.draggable))).map((e=>{var t,o;return{id:e.id,position:e.position||{x:0,y:0},positionAbsolute:e.positionAbsolute||{x:0,y:0},distance:{x:n.x-((null==(t=e.positionAbsolute)?void 0:t.x)??0),y:n.y-((null==(o=e.positionAbsolute)?void 0:o.y)??0)},delta:{x:0,y:0},extent:e.extent,parentNode:e.parentNode||e.parentId,parentId:e.parentNode||e.parentId,width:e.width,height:e.height,expandParent:e.expandParent}}))}function HC(e,t,n,o,r=[0,0],a){const s=function(e,t){return t&&"parent"!==t?[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]:t}(e,e.extent||o);let i=s;const l=e.parentNode||e.parentId;if("parent"!==e.extent||e.expandParent){if(e.extent&&l&&"parent"!==e.extent){const t=n.get(l),{x:o,y:a}=kE(t,r).positionAbsolute;i=[[e.extent[0][0]+o,e.extent[0][1]+a],[e.extent[1][0]+o,e.extent[1][1]+a]]}}else if(l&&e.width&&e.height){const t=n.get(l),{x:o,y:a}=kE(t,r).positionAbsolute;i=t&&DN(o)&&DN(a)&&DN(t.width)&&DN(t.height)?[[o+e.width*r[0],a+e.height*r[1]],[o+t.width-e.width+e.width*r[0],a+t.height-e.height+e.height*r[1]]]:i}else null==a||a("005",uN()),i=s;let c={x:0,y:0};if(l){const e=n.get(l);c=kE(e,r).positionAbsolute}const d=i&&"parent"!==i?jN(t,i):t;return{position:{x:d.x-c.x,y:d.y-c.y},positionAbsolute:d}}function WC({nodeId:e,dragItems:t,nodeInternals:n}){const o=t.map((e=>({...n.get(e.id),position:e.position,positionAbsolute:e.positionAbsolute})));return[e?o.find((t=>t.id===e)):o[0],o]}UC.displayName="Pane";const qC=(e,t,n,o)=>{const r=t.querySelectorAll(e);if(!r||!r.length)return null;const a=Array.from(r),s=t.getBoundingClientRect(),i=s.width*o[0],l=s.height*o[1];return a.map((e=>{const t=e.getBoundingClientRect();return{id:e.getAttribute("data-handleid"),position:e.getAttribute("data-handlepos"),x:(t.left-s.left-i)/n,y:(t.top-s.top-l)/n,...EN(e)}}))};function YC(e,t,n){return void 0===n?n:o=>{const r=t().nodeInternals.get(e);r&&n(o,{...r})}}function JC({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:a,multiSelectionActive:s,nodeInternals:i,onError:l}=t.getState(),c=i.get(e);c?(t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&s)&&(a({nodes:[c],edges:[]}),requestAnimationFrame((()=>{var e;return null==(e=null==o?void 0:o.current)?void 0:e.blur()}))):r([e])):null==l||l("012",gN(e))}function KC(e){return(t,n,o)=>null==e?void 0:e(t,o)}function XC({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:a,isSelectable:s,selectNodesOnDrag:i}){const l=yN(),[c,d]=r.useState(!1),u=r.useRef([]),h=r.useRef({x:null,y:null}),f=r.useRef(0),m=r.useRef(null),p=r.useRef({x:0,y:0}),g=r.useRef(null),v=r.useRef(!1),x=r.useRef(!1),y=r.useRef(!1),b=function(){const e=yN();return r.useCallback((({sourceEvent:t})=>{const{transform:n,snapGrid:o,snapToGrid:r}=e.getState(),a=t.touches?t.touches[0].clientX:t.clientX,s=t.touches?t.touches[0].clientY:t.clientY,i={x:(a-n[0])/n[2],y:(s-n[1])/n[2]};return{xSnapped:r?o[0]*Math.round(i.x/o[0]):i.x,ySnapped:r?o[1]*Math.round(i.y/o[1]):i.y,...i}}),[])}();return r.useEffect((()=>{if(null==e?void 0:e.current){const r=pl(e.current),c=({x:e,y:t})=>{const{nodeInternals:n,onNodeDrag:o,onSelectionDrag:r,updateNodePositions:s,nodeExtent:i,snapGrid:c,snapToGrid:f,nodeOrigin:m,onError:p}=l.getState();h.current={x:e,y:t};let v=!1,x={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&i){const e=NE(u.current,m);x=MN(e)}if(u.current=u.current.map((o=>{const r={x:e-o.distance.x,y:t-o.distance.y};f&&(r.x=c[0]*Math.round(r.x/c[0]),r.y=c[1]*Math.round(r.y/c[1]));const a=[[i[0][0],i[0][1]],[i[1][0],i[1][1]]];u.current.length>1&&i&&!o.extent&&(a[0][0]=o.positionAbsolute.x-x.x+i[0][0],a[1][0]=o.positionAbsolute.x+(o.width??0)-x.x2+i[1][0],a[0][1]=o.positionAbsolute.y-x.y+i[0][1],a[1][1]=o.positionAbsolute.y+(o.height??0)-x.y2+i[1][1]);const s=HC(o,r,n,a,m,p);return v=v||o.position.x!==s.position.x||o.position.y!==s.position.y,o.position=s.position,o.positionAbsolute=s.positionAbsolute,o})),!v)return;s(u.current,!0,!0),d(!0);const y=a?o:KC(r);if(y&&g.current){const[e,t]=WC({nodeId:a,dragItems:u.current,nodeInternals:n});y(g.current,e,t)}},w=()=>{if(!m.current)return;const[e,t]=IN(p.current,m.current);if(0!==e||0!==t){const{transform:n,panBy:o}=l.getState();h.current.x=(h.current.x??0)-e/n[2],h.current.y=(h.current.y??0)-t/n[2],o({x:e,y:t})&&c(h.current)}f.current=requestAnimationFrame(w)},k=t=>{var n;const{nodeInternals:o,multiSelectionActive:r,nodesDraggable:c,unselectNodesAndEdges:d,onNodeDragStart:f,onSelectionDragStart:m}=l.getState();x.current=!0;const p=a?f:KC(m);i&&s||r||!a||(null==(n=o.get(a))?void 0:n.selected)||d(),a&&s&&i&&JC({id:a,store:l,nodeRef:e});const g=b(t);if(h.current=g,u.current=GC(o,c,g,a),p&&u.current){const[e,n]=WC({nodeId:a,dragItems:u.current,nodeInternals:o});p(t.sourceEvent,e,n)}};if(!t){const t=function(){var e,t,n,o,r=qk,a=Yk,s=Jk,i=Kk,l={},c=yl("start","drag","end"),d=0,u=0;function h(e){e.on("mousedown.drag",f).filter(i).on("touchstart.drag",g).on("touchmove.drag",v,zk).on("touchend.drag touchcancel.drag",x).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(s,i){if(!o&&r.call(this,s,i)){var l=y(this,a.call(this,s,i),s,i,"mouse");l&&(pl(s.view).on("mousemove.drag",m,Bk).on("mouseup.drag",p,Bk),$k(s.view),Uk(s),n=!1,e=s.clientX,t=s.clientY,l("start",s))}}function m(o){if(Vk(o),!n){var r=o.clientX-e,a=o.clientY-t;n=r*r+a*a>u}l.mouse("drag",o)}function p(e){pl(e.view).on("mousemove.drag mouseup.drag",null),Gk(e.view,n),Vk(e),l.mouse("end",e)}function g(e,t){if(r.call(this,e,t)){var n,o,s=e.changedTouches,i=a.call(this,e,t),l=s.length;for(n=0;n<l;++n)(o=y(this,i,e,t,s[n].identifier,s[n]))&&(Uk(e),o("start",e,s[n]))}}function v(e){var t,n,o=e.changedTouches,r=o.length;for(t=0;t<r;++t)(n=l[o[t].identifier])&&(Vk(e),n("drag",e,o[t]))}function x(e){var t,n,r=e.changedTouches,a=r.length;for(o&&clearTimeout(o),o=setTimeout((function(){o=null}),500),t=0;t<a;++t)(n=l[r[t].identifier])&&(Uk(e),n("end",e,r[t]))}function y(e,t,n,o,r,a){var i,u,f,m=c.copy(),p=Lk(a||n,t);if(null!=(f=s.call(e,new Wk("beforestart",{sourceEvent:n,target:h,identifier:r,active:d,x:p[0],y:p[1],dx:0,dy:0,dispatch:m}),o)))return i=f.x-p[0]||0,u=f.y-p[1]||0,function n(a,s,c){var g,v=p;switch(a){case"start":l[r]=n,g=d++;break;case"end":delete l[r],--d;case"drag":p=Lk(c||s,t),g=d}m.call(a,e,new Wk(a,{sourceEvent:s,subject:f,target:h,identifier:r,active:g,x:p[0]+i,y:p[1]+u,dx:p[0]-v[0],dy:p[1]-v[1],dispatch:m}),o)}}return h.filter=function(e){return arguments.length?(r="function"==typeof e?e:Hk(!!e),h):r},h.container=function(e){return arguments.length?(a="function"==typeof e?e:Hk(e),h):a},h.subject=function(e){return arguments.length?(s="function"==typeof e?e:Hk(e),h):s},h.touchable=function(e){return arguments.length?(i="function"==typeof e?e:Hk(!!e),h):i},h.on=function(){var e=c.on.apply(c,arguments);return e===c?h:e},h.clickDistance=function(e){return arguments.length?(u=(e=+e)*e,h):Math.sqrt(u)},h}().on("start",(e=>{const{domNode:t,nodeDragThreshold:n}=l.getState();0===n&&k(e),y.current=!1;const o=b(e);h.current=o,m.current=(null==t?void 0:t.getBoundingClientRect())||null,p.current=LN(e.sourceEvent,m.current)})).on("drag",(e=>{var t,n;const o=b(e),{autoPanOnNodeDrag:r,nodeDragThreshold:a}=l.getState();if("touchmove"===e.sourceEvent.type&&e.sourceEvent.touches.length>1&&(y.current=!0),!y.current){if(!v.current&&x.current&&r&&(v.current=!0,w()),!x.current){const r=o.xSnapped-((null==(t=null==h?void 0:h.current)?void 0:t.x)??0),s=o.ySnapped-((null==(n=null==h?void 0:h.current)?void 0:n.y)??0);Math.sqrt(r*r+s*s)>a&&k(e)}(h.current.x!==o.xSnapped||h.current.y!==o.ySnapped)&&u.current&&x.current&&(g.current=e.sourceEvent,p.current=LN(e.sourceEvent,m.current),c(o))}})).on("end",(e=>{if(x.current&&!y.current&&(d(!1),v.current=!1,x.current=!1,cancelAnimationFrame(f.current),u.current)){const{updateNodePositions:t,nodeInternals:n,onNodeDragStop:o,onSelectionDragStop:r}=l.getState(),s=a?o:KC(r);if(t(u.current,!1,!1),s){const[t,o]=WC({nodeId:a,dragItems:u.current,nodeInternals:n});s(e.sourceEvent,t,o)}}})).filter((t=>{const r=t.target;return!t.button&&(!n||!$C(r,`.${n}`,e))&&(!o||$C(r,o,e))}));return r.call(t),()=>{r.on(".drag",null)}}r.on(".drag",null)}}),[e,t,n,o,s,l,a,i,b]),c}function ZC(){const e=yN();return r.useCallback((t=>{const{nodeInternals:n,nodeExtent:o,updateNodePositions:r,getNodes:a,snapToGrid:s,snapGrid:i,onError:l,nodesDraggable:c}=e.getState(),d=a().filter((e=>e.selected&&(e.draggable||c&&void 0===e.draggable))),u=s?i[0]:5,h=s?i[1]:5,f=t.isShiftPressed?4:1,m=t.x*u*f,p=t.y*h*f;r(d.map((e=>{if(e.positionAbsolute){const t={x:e.positionAbsolute.x+m,y:e.positionAbsolute.y+p};s&&(t.x=i[0]*Math.round(t.x/i[0]),t.y=i[1]*Math.round(t.y/i[1]));const{positionAbsolute:r,position:a}=HC(e,t,n,o,void 0,l);e.position=a,e.positionAbsolute=r}return e})),!0,!1)}),[])}const QC={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var ej=e=>{const t=({id:t,type:n,data:o,xPos:a,yPos:s,xPosOrigin:i,yPosOrigin:l,selected:c,onClick:d,onMouseEnter:h,onMouseMove:f,onMouseLeave:m,onContextMenu:p,onDoubleClick:g,style:v,className:x,isDraggable:y,isSelectable:b,isConnectable:w,isFocusable:k,selectNodesOnDrag:N,sourcePosition:E,targetPosition:C,hidden:j,resizeObserver:S,dragHandle:I,zIndex:A,isParent:M,noDragClassName:T,noPanClassName:O,initialized:D,disableKeyboardA11y:_,ariaLabel:P,rfId:R,hasHandleBounds:F})=>{const L=yN(),z=r.useRef(null),B=r.useRef(null),U=r.useRef(E),V=r.useRef(C),$=r.useRef(n),G=b||y||d||h||f||m,H=ZC(),W=YC(t,L.getState,h),q=YC(t,L.getState,f),Y=YC(t,L.getState,m),J=YC(t,L.getState,p),K=YC(t,L.getState,g);r.useEffect((()=>()=>{B.current&&(null==S||S.unobserve(B.current),B.current=null)}),[]),r.useEffect((()=>{if(z.current&&!j){const e=z.current;D&&F&&B.current===e||(B.current&&(null==S||S.unobserve(B.current)),null==S||S.observe(e),B.current=e)}}),[j,D,F]),r.useEffect((()=>{const e=$.current!==n,o=U.current!==E,r=V.current!==C;z.current&&(e||o||r)&&(e&&($.current=n),o&&(U.current=E),r&&(V.current=C),L.getState().updateNodeDimensions([{id:t,nodeElement:z.current,forceUpdate:!0}]))}),[t,n,E,C]);const X=XC({nodeRef:z,disabled:j||!y,noDragClassName:T,handleSelector:I,nodeId:t,isSelectable:b,selectNodesOnDrag:N});return j?null:u.createElement("div",{className:Tk(["react-flow__node",`react-flow__node-${n}`,{[O]:y},x,{selected:c,selectable:b,parent:M,dragging:X}]),ref:z,style:{zIndex:A,transform:`translate(${i}px,${l}px)`,pointerEvents:G?"all":"none",visibility:D?"visible":"hidden",...v},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:W,onMouseMove:q,onMouseLeave:Y,onContextMenu:J,onClick:e=>{const{nodeDragThreshold:n}=L.getState();if(b&&(!N||!y||n>0)&&JC({id:t,store:L,nodeRef:z}),d){const n=L.getState().nodeInternals.get(t);n&&d(e,{...n})}},onDoubleClick:K,onKeyDown:k?e=>{if(!RN(e)&&!_)if(PN.includes(e.key)&&b){const n="Escape"===e.key;JC({id:t,store:L,unselect:n,nodeRef:z})}else y&&c&&Object.prototype.hasOwnProperty.call(QC,e.key)&&(L.setState({ariaLiveMessage:`Moved selected node ${e.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~a}, y: ${~~s}`}),H({x:QC[e.key].x,y:QC[e.key].y,isShiftPressed:e.shiftKey}))}:void 0,tabIndex:k?0:void 0,role:k?"button":void 0,"aria-describedby":_?void 0:`${aC}-${R}`,"aria-label":P},u.createElement(vE,{value:t},u.createElement(e,{id:t,data:o,type:n,xPos:a,yPos:s,selected:c,isConnectable:w,sourcePosition:E,targetPosition:C,dragging:X,dragHandle:I,zIndex:A})))};return t.displayName="NodeWrapper",r.memo(t)};const tj=e=>{const t=e.getNodes().filter((e=>e.selected));return{...NE(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};var nj=r.memo((function({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=yN(),{width:a,height:s,x:i,y:l,transformString:c,userSelectionActive:d}=xN(tj,Fk),h=ZC(),f=r.useRef(null);if(r.useEffect((()=>{var e;n||null==(e=f.current)||e.focus({preventScroll:!0})}),[n]),XC({nodeRef:f}),d||!a||!s)return null;const m=e?t=>{const n=o.getState().getNodes().filter((e=>e.selected));e(t,n)}:void 0;return u.createElement("div",{className:Tk(["react-flow__nodesselection","react-flow__container",t]),style:{transform:c}},u.createElement("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:m,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(QC,e.key)&&h({x:QC[e.key].x,y:QC[e.key].y,isShiftPressed:e.shiftKey})},style:{width:a,height:s,top:l,left:i}}))}));const oj=e=>e.nodesSelectionActive,rj=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:a,onPaneContextMenu:s,onPaneScroll:i,deleteKeyCode:l,onMove:c,onMoveStart:d,onMoveEnd:h,selectionKeyCode:f,selectionOnDrag:m,selectionMode:p,onSelectionStart:g,onSelectionEnd:v,multiSelectionKeyCode:x,panActivationKeyCode:y,zoomActivationKeyCode:b,elementsSelectable:w,zoomOnScroll:k,zoomOnPinch:N,panOnScroll:E,panOnScrollSpeed:C,panOnScrollMode:j,zoomOnDoubleClick:S,panOnDrag:I,defaultViewport:A,translateExtent:M,minZoom:T,maxZoom:O,preventScrolling:D,onSelectionContextMenu:_,noWheelClassName:P,noPanClassName:R,disableKeyboardA11y:F})=>{const L=xN(oj),z=dC(f),B=dC(y),U=B||I,V=B||E,$=z||m&&!0!==U;return(({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=yN(),{deleteElements:o}=NC(),a=dC(e,EC),s=dC(t);r.useEffect((()=>{if(a){const{edges:e,getNodes:t}=n.getState(),r=t().filter((e=>e.selected)),a=e.filter((e=>e.selected));o({nodes:r,edges:a}),n.setState({nodesSelectionActive:!1})}}),[a]),r.useEffect((()=>{n.setState({multiSelectionActive:s})}),[s])})({deleteKeyCode:l,multiSelectionKeyCode:x}),u.createElement(TC,{onMove:c,onMoveStart:d,onMoveEnd:h,onPaneContextMenu:s,elementsSelectable:w,zoomOnScroll:k,zoomOnPinch:N,panOnScroll:V,panOnScrollSpeed:C,panOnScrollMode:j,zoomOnDoubleClick:S,panOnDrag:!z&&U,defaultViewport:A,translateExtent:M,minZoom:T,maxZoom:O,zoomActivationKeyCode:b,preventScrolling:D,noWheelClassName:P,noPanClassName:R},u.createElement(UC,{onSelectionStart:g,onSelectionEnd:v,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:a,onPaneContextMenu:s,onPaneScroll:i,panOnDrag:U,isSelecting:!!$,selectionMode:p},e,L&&u.createElement(nj,{onSelectionContextMenu:_,noPanClassName:R,disableKeyboardA11y:F})))};rj.displayName="FlowRenderer";var aj=r.memo(rj);function sj(e){return{...{input:ej(e.input||$E),default:ej(e.default||UE),output:ej(e.output||HE),group:ej(e.group||WE)},...Object.keys(e).filter((e=>!["input","default","output","group"].includes(e))).reduce(((t,n)=>(t[n]=ej(e[n]||UE),t)),{})}}const ij=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),lj=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:a,updateNodeDimensions:s,onError:i}=xN(ij,Fk),l=(c=e.onlyRenderVisibleElements,xN(r.useCallback((e=>c?EE(e.nodeInternals,{x:0,y:0,width:e.width,height:e.height},e.transform,!0):e.getNodes()),[c])));var c;const d=r.useRef(),h=r.useMemo((()=>{if("undefined"==typeof ResizeObserver)return null;const e=new ResizeObserver((e=>{const t=e.map((e=>({id:e.target.getAttribute("data-id"),nodeElement:e.target,forceUpdate:!0})));s(t)}));return d.current=e,e}),[]);return r.useEffect((()=>()=>{var e;null==(e=null==d?void 0:d.current)||e.disconnect()}),[]),u.createElement("div",{className:"react-flow__nodes",style:CC},l.map((r=>{var s,l,c;let d=r.type||"default";e.nodeTypes[d]||(null==i||i("003",cN(d)),d="default");const f=e.nodeTypes[d]||e.nodeTypes.default,m=!!(r.draggable||t&&void 0===r.draggable),p=!!(r.selectable||a&&void 0===r.selectable),g=!!(r.connectable||n&&void 0===r.connectable),v=!!(r.focusable||o&&void 0===r.focusable),x=e.nodeExtent?jN(r.positionAbsolute,e.nodeExtent):r.positionAbsolute,y=(null==x?void 0:x.x)??0,b=(null==x?void 0:x.y)??0,w=(({x:e,y:t,width:n,height:o,origin:r})=>n&&o?r[0]<0||r[1]<0||r[0]>1||r[1]>1?{x:e,y:t}:{x:e-n*r[0],y:t-o*r[1]}:{x:e,y:t})({x:y,y:b,width:r.width??0,height:r.height??0,origin:e.nodeOrigin});return u.createElement(f,{key:r.id,id:r.id,className:r.className,style:r.style,type:d,data:r.data,sourcePosition:r.sourcePosition||eE.Bottom,targetPosition:r.targetPosition||eE.Top,hidden:r.hidden,xPos:y,yPos:b,xPosOrigin:w.x,yPosOrigin:w.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!r.selected,isDraggable:m,isSelectable:p,isConnectable:g,isFocusable:v,resizeObserver:h,dragHandle:r.dragHandle,zIndex:(null==(s=r[_N])?void 0:s.z)??0,isParent:!!(null==(l=r[_N])?void 0:l.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!r.width&&!!r.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:r.ariaLabel,hasHandleBounds:!!(null==(c=r[_N])?void 0:c.handleBounds)})})))};lj.displayName="NodeRenderer";var cj=r.memo(lj);const dj=(e,t,n)=>n===eE.Left?e-t:n===eE.Right?e+t:e,uj=(e,t,n)=>n===eE.Top?e-t:n===eE.Bottom?e+t:e,hj="react-flow__edgeupdater",fj=({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:a,onMouseOut:s,type:i})=>u.createElement("circle",{onMouseDown:r,onMouseEnter:a,onMouseOut:s,className:Tk([hj,`${hj}-${i}`]),cx:dj(t,o,e),cy:uj(n,o,e),r:o,stroke:"transparent",fill:"transparent"}),mj=()=>!0;var pj=e=>{const t=({id:t,className:n,type:o,data:a,onClick:s,onEdgeDoubleClick:i,selected:l,animated:c,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:m,labelBgPadding:p,labelBgBorderRadius:g,style:v,source:x,target:y,sourceX:b,sourceY:w,targetX:k,targetY:N,sourcePosition:E,targetPosition:C,elementsSelectable:j,hidden:S,sourceHandleId:I,targetHandleId:A,onContextMenu:M,onMouseEnter:T,onMouseMove:O,onMouseLeave:D,reconnectRadius:_,onReconnect:P,onReconnectStart:R,onReconnectEnd:F,markerEnd:L,markerStart:z,rfId:B,ariaLabel:U,isFocusable:V,isReconnectable:$,pathOptions:G,interactionWidth:H,disableKeyboardA11y:W})=>{const q=r.useRef(null),[Y,J]=r.useState(!1),[K,X]=r.useState(!1),Z=yN(),Q=r.useMemo((()=>`url('#${yE(z,B)}')`),[z,B]),ee=r.useMemo((()=>`url('#${yE(L,B)}')`),[L,B]);if(S)return null;const te=UN(t,Z.getState,i),ne=UN(t,Z.getState,M),oe=UN(t,Z.getState,T),re=UN(t,Z.getState,O),ae=UN(t,Z.getState,D),se=(e,n)=>{if(0!==e.button)return;const{edges:o,isValidConnection:r}=Z.getState(),a=n?y:x,s=(n?A:I)||null,i=n?"target":"source",l=r||mj,c=n,d=o.find((e=>e.id===t));X(!0),null==R||R(e,d,i);PE({event:e,handleId:s,nodeId:a,onConnect:e=>null==P?void 0:P(d,e),isTarget:c,getState:Z.getState,setState:Z.setState,isValidConnection:l,edgeUpdaterType:i,onReconnectEnd:e=>{X(!1),null==F||F(e,d,i)}})},ie=()=>J(!0),le=()=>J(!1),ce=!j&&!s;return u.createElement("g",{className:Tk(["react-flow__edge",`react-flow__edge-${o}`,n,{selected:l,animated:c,inactive:ce,updating:Y}]),onClick:e=>{var n;const{edges:o,addSelectedEdges:r,unselectNodesAndEdges:a,multiSelectionActive:i}=Z.getState(),l=o.find((e=>e.id===t));l&&(j&&(Z.setState({nodesSelectionActive:!1}),l.selected&&i?(a({nodes:[],edges:[l]}),null==(n=q.current)||n.blur()):r([t])),s&&s(e,l))},onDoubleClick:te,onContextMenu:ne,onMouseEnter:oe,onMouseMove:re,onMouseLeave:ae,onKeyDown:V?e=>{var n;if(!W&&PN.includes(e.key)&&j){const{unselectNodesAndEdges:o,addSelectedEdges:r,edges:a}=Z.getState();"Escape"===e.key?(null==(n=q.current)||n.blur(),o({edges:[a.find((e=>e.id===t))]})):r([t])}}:void 0,tabIndex:V?0:void 0,role:V?"button":"img","data-testid":`rf__edge-${t}`,"aria-label":null===U?void 0:U||`Edge from ${x} to ${y}`,"aria-describedby":V?`${sC}-${B}`:void 0,ref:q},!K&&u.createElement(e,{id:t,source:x,target:y,selected:l,animated:c,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:m,labelBgPadding:p,labelBgBorderRadius:g,data:a,style:v,sourceX:b,sourceY:w,targetX:k,targetY:N,sourcePosition:E,targetPosition:C,sourceHandleId:I,targetHandleId:A,markerStart:Q,markerEnd:ee,pathOptions:G,interactionWidth:H}),$&&u.createElement(u.Fragment,null,("source"===$||!0===$)&&u.createElement(fj,{position:E,centerX:b,centerY:w,radius:_,onMouseDown:e=>se(e,!0),onMouseEnter:ie,onMouseOut:le,type:"source"}),("target"===$||!0===$)&&u.createElement(fj,{position:C,centerX:k,centerY:N,radius:_,onMouseDown:e=>se(e,!1),onMouseEnter:ie,onMouseOut:le,type:"target"})))};return t.displayName="EdgeWrapper",r.memo(t)};function gj(e){return{...{default:pj(e.default||pE),straight:pj(e.bezier||uE),step:pj(e.step||dE),smoothstep:pj(e.step||cE),simplebezier:pj(e.simplebezier||rE)},...Object.keys(e).filter((e=>!["default","bezier"].includes(e))).reduce(((t,n)=>(t[n]=pj(e[n]||pE),t)),{})}}function vj(e,t,n=null){const o=((null==n?void 0:n.x)||0)+t.x,r=((null==n?void 0:n.y)||0)+t.y,a=(null==n?void 0:n.width)||t.width,s=(null==n?void 0:n.height)||t.height;switch(e){case eE.Top:return{x:o+a/2,y:r};case eE.Right:return{x:o+a,y:r+s/2};case eE.Bottom:return{x:o+a/2,y:r+s};case eE.Left:return{x:o,y:r+s/2}}}function xj(e,t){return e?1!==e.length&&t?t&&e.find((e=>e.id===t))||null:e[0]:null}function yj(e){var t,n,o,r,a;const s=(null==(t=null==e?void 0:e[_N])?void 0:t.handleBounds)||null,i=s&&(null==e?void 0:e.width)&&(null==e?void 0:e.height)&&void 0!==(null==(n=null==e?void 0:e.positionAbsolute)?void 0:n.x)&&void 0!==(null==(o=null==e?void 0:e.positionAbsolute)?void 0:o.y);return[{x:(null==(r=null==e?void 0:e.positionAbsolute)?void 0:r.x)||0,y:(null==(a=null==e?void 0:e.positionAbsolute)?void 0:a.y)||0,width:(null==e?void 0:e.width)||0,height:(null==e?void 0:e.height)||0},s,!!i]}const bj=[{level:0,isMaxLevel:!0,edges:[]}];function wj(e,t,n){return function(e,t,n=!1){let o=-1;const r=e.reduce(((e,r)=>{var a,s;const i=DN(r.zIndex);let l=i?r.zIndex:0;if(n){const e=t.get(r.target),n=t.get(r.source),o=r.selected||(null==e?void 0:e.selected)||(null==n?void 0:n.selected),c=Math.max((null==(a=null==n?void 0:n[_N])?void 0:a.z)||0,(null==(s=null==e?void 0:e[_N])?void 0:s.z)||0,1e3);l=(i?r.zIndex:0)+(o?c:0)}return e[l]?e[l].push(r):e[l]=[r],o=l>o?l:o,e}),{}),a=Object.entries(r).map((([e,t])=>{const n=+e;return{edges:t,level:n,isMaxLevel:n===o}}));return 0===a.length?bj:a}(xN(r.useCallback((n=>e?n.edges.filter((e=>{const o=t.get(e.source),r=t.get(e.target);return(null==o?void 0:o.width)&&(null==o?void 0:o.height)&&(null==r?void 0:r.width)&&(null==r?void 0:r.height)&&function({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:o,targetWidth:r,targetHeight:a,width:s,height:i,transform:l}){const c={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+r),y2:Math.max(e.y+o,t.y+a)};c.x===c.x2&&(c.x2+=1),c.y===c.y2&&(c.y2+=1);const d=MN({x:(0-l[0])/l[2],y:(0-l[1])/l[2],width:s/l[2],height:i/l[2]}),u=Math.max(0,Math.min(d.x2,c.x2)-Math.max(d.x,c.x)),h=Math.max(0,Math.min(d.y2,c.y2)-Math.max(d.y,c.y));return Math.ceil(u*h)>0}({sourcePos:o.positionAbsolute||{x:0,y:0},targetPos:r.positionAbsolute||{x:0,y:0},sourceWidth:o.width,sourceHeight:o.height,targetWidth:r.width,targetHeight:r.height,width:n.width,height:n.height,transform:n.transform})})):n.edges),[e,t])),t,n)}const kj={[ZN.Arrow]:({color:e="none",strokeWidth:t=1})=>u.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),[ZN.ArrowClosed]:({color:e="none",strokeWidth:t=1})=>u.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})};const Nj=({id:e,type:t,color:n,width:o=12.5,height:a=12.5,markerUnits:s="strokeWidth",strokeWidth:i,orient:l="auto-start-reverse"})=>{const c=function(e){const t=yN();return r.useMemo((()=>{var n,o;return Object.prototype.hasOwnProperty.call(kj,e)?kj[e]:(null==(o=(n=t.getState()).onError)||o.call(n,"009",hN(e)),null)}),[e])}(t);return c?u.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:l,refX:"0",refY:"0"},u.createElement(c,{color:n,strokeWidth:i})):null},Ej=({defaultColor:e,rfId:t})=>{const n=xN(r.useCallback((({defaultColor:e,rfId:t})=>n=>{const o=[];return n.edges.reduce(((n,r)=>([r.markerStart,r.markerEnd].forEach((r=>{if(r&&"object"==typeof r){const a=yE(r,t);o.includes(a)||(n.push({id:a,color:r.color||e,...r}),o.push(a))}})),n)),[]).sort(((e,t)=>e.id.localeCompare(t.id)))})({defaultColor:e,rfId:t}),[e,t]),((e,t)=>!(e.length!==t.length||e.some(((e,n)=>e.id!==t[n].id)))));return u.createElement("defs",null,n.map((e=>u.createElement(Nj,{id:e.id,key:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient}))))};Ej.displayName="MarkerDefinitions";var Cj=r.memo(Ej);const jj=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),Sj=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:o,edgeTypes:r,noPanClassName:a,onEdgeContextMenu:s,onEdgeMouseEnter:i,onEdgeMouseMove:l,onEdgeMouseLeave:c,onEdgeClick:d,onEdgeDoubleClick:h,onReconnect:f,onReconnectStart:m,onReconnectEnd:p,reconnectRadius:g,children:v,disableKeyboardA11y:x})=>{const{edgesFocusable:y,edgesUpdatable:b,elementsSelectable:w,width:k,height:N,connectionMode:E,nodeInternals:C,onError:j}=xN(jj,Fk),S=wj(t,C,n);return k?u.createElement(u.Fragment,null,S.map((({level:t,edges:n,isMaxLevel:v})=>u.createElement("svg",{key:t,style:{zIndex:t},width:k,height:N,className:"react-flow__edges react-flow__container"},v&&u.createElement(Cj,{defaultColor:e,rfId:o}),u.createElement("g",null,n.map((e=>{const[t,n,v]=yj(C.get(e.source)),[k,N,S]=yj(C.get(e.target));if(!v||!S)return null;let I=e.type||"default";r[I]||(null==j||j("011",pN(I)),I="default");const A=r[I]||r.default,M=E===GN.Strict?N.target:(N.target??[]).concat(N.source??[]),T=xj(n.source,e.sourceHandle),O=xj(M,e.targetHandle),D=(null==T?void 0:T.position)||eE.Bottom,_=(null==O?void 0:O.position)||eE.Top,P=!!(e.focusable||y&&void 0===e.focusable),R=e.reconnectable||e.updatable,F=void 0!==f&&(R||b&&void 0===R);if(!T||!O)return null==j||j("008",fN(T,e)),null;const{sourceX:L,sourceY:z,targetX:B,targetY:U}=((e,t,n,o,r,a)=>{const s=vj(n,e,t),i=vj(a,o,r);return{sourceX:s.x,sourceY:s.y,targetX:i.x,targetY:i.y}})(t,T,D,k,O,_);return u.createElement(A,{key:e.id,id:e.id,className:Tk([e.className,a]),type:I,data:e.data,selected:!!e.selected,animated:!!e.animated,hidden:!!e.hidden,label:e.label,labelStyle:e.labelStyle,labelShowBg:e.labelShowBg,labelBgStyle:e.labelBgStyle,labelBgPadding:e.labelBgPadding,labelBgBorderRadius:e.labelBgBorderRadius,style:e.style,source:e.source,target:e.target,sourceHandleId:e.sourceHandle,targetHandleId:e.targetHandle,markerEnd:e.markerEnd,markerStart:e.markerStart,sourceX:L,sourceY:z,targetX:B,targetY:U,sourcePosition:D,targetPosition:_,elementsSelectable:w,onContextMenu:s,onMouseEnter:i,onMouseMove:l,onMouseLeave:c,onClick:d,onEdgeDoubleClick:h,onReconnect:f,onReconnectStart:m,onReconnectEnd:p,reconnectRadius:g,rfId:o,ariaLabel:e.ariaLabel,isFocusable:P,isReconnectable:F,pathOptions:"pathOptions"in e?e.pathOptions:void 0,interactionWidth:e.interactionWidth,disableKeyboardA11y:x})})))))),v):null};Sj.displayName="EdgeRenderer";var Ij=r.memo(Sj);const Aj=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Mj({children:e}){const t=xN(Aj);return u.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}const Tj={[eE.Left]:eE.Right,[eE.Right]:eE.Left,[eE.Top]:eE.Bottom,[eE.Bottom]:eE.Top},Oj=({nodeId:e,handleType:t,style:n,type:o=KN.Bezier,CustomComponent:a,connectionStatus:s})=>{var i,l,c;const{fromNode:d,handleId:h,toX:f,toY:m,connectionMode:p}=xN(r.useCallback((t=>({fromNode:t.nodeInternals.get(e),handleId:t.connectionHandleId,toX:(t.connectionPosition.x-t.transform[0])/t.transform[2],toY:(t.connectionPosition.y-t.transform[1])/t.transform[2],connectionMode:t.connectionMode})),[e]),Fk),g=null==(i=null==d?void 0:d[_N])?void 0:i.handleBounds;let v=null==g?void 0:g[t];if(p===GN.Loose&&(v=v||(null==g?void 0:g["source"===t?"target":"source"])),!d||!v)return null;const x=h?v.find((e=>e.id===h)):v[0],y=x?x.x+x.width/2:(d.width??0)/2,b=x?x.y+x.height/2:d.height??0,w=((null==(l=d.positionAbsolute)?void 0:l.x)??0)+y,k=((null==(c=d.positionAbsolute)?void 0:c.y)??0)+b,N=null==x?void 0:x.position,E=N?Tj[N]:null;if(!N||!E)return null;if(a)return u.createElement(a,{connectionLineType:o,connectionLineStyle:n,fromNode:d,fromHandle:x,fromX:w,fromY:k,toX:f,toY:m,fromPosition:N,toPosition:E,connectionStatus:s});let C="";const j={sourceX:w,sourceY:k,sourcePosition:N,targetX:f,targetY:m,targetPosition:E};return o===KN.Bezier?[C]=mE(j):o===KN.Step?[C]=lE({...j,borderRadius:0}):o===KN.SmoothStep?[C]=lE(j):o===KN.SimpleBezier?[C]=oE(j):C=`M${w},${k} ${f},${m}`,u.createElement("path",{d:C,fill:"none",className:"react-flow__connection-path",style:n})};Oj.displayName="ConnectionLine";const Dj=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function _j({containerStyle:e,style:t,type:n,component:o}){const{nodeId:r,handleType:a,nodesConnectable:s,width:i,height:l,connectionStatus:c}=xN(Dj,Fk);return!!(r&&a&&i&&s)?u.createElement("svg",{style:e,width:i,height:l,className:"react-flow__edges react-flow__connectionline react-flow__container"},u.createElement("g",{className:Tk(["react-flow__connection",c])},u.createElement(Oj,{nodeId:r,handleType:a,style:t,type:n,CustomComponent:o,connectionStatus:c}))):null}function Pj(e,t){r.useRef(null),yN();return r.useMemo((()=>t(e)),[e])}const Rj=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:o,onMoveEnd:a,onInit:s,onNodeClick:i,onEdgeClick:l,onNodeDoubleClick:c,onEdgeDoubleClick:d,onNodeMouseEnter:h,onNodeMouseMove:f,onNodeMouseLeave:m,onNodeContextMenu:p,onSelectionContextMenu:g,onSelectionStart:v,onSelectionEnd:x,connectionLineType:y,connectionLineStyle:b,connectionLineComponent:w,connectionLineContainerStyle:k,selectionKeyCode:N,selectionOnDrag:E,selectionMode:C,multiSelectionKeyCode:j,panActivationKeyCode:S,zoomActivationKeyCode:I,deleteKeyCode:A,onlyRenderVisibleElements:M,elementsSelectable:T,selectNodesOnDrag:O,defaultViewport:D,translateExtent:_,minZoom:P,maxZoom:R,preventScrolling:F,defaultMarkerColor:L,zoomOnScroll:z,zoomOnPinch:B,panOnScroll:U,panOnScrollSpeed:V,panOnScrollMode:$,zoomOnDoubleClick:G,panOnDrag:H,onPaneClick:W,onPaneMouseEnter:q,onPaneMouseMove:Y,onPaneMouseLeave:J,onPaneScroll:K,onPaneContextMenu:X,onEdgeContextMenu:Z,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:te,onReconnect:ne,onReconnectStart:oe,onReconnectEnd:re,reconnectRadius:ae,noDragClassName:se,noWheelClassName:ie,noPanClassName:le,elevateEdgesOnSelect:ce,disableKeyboardA11y:de,nodeOrigin:ue,nodeExtent:he,rfId:fe})=>{const me=Pj(e,sj),pe=Pj(t,gj);return function(e){const t=NC(),n=r.useRef(!1);r.useEffect((()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout((()=>e(t)),1),n.current=!0)}),[e,t.viewportInitialized])}(s),u.createElement(aj,{onPaneClick:W,onPaneMouseEnter:q,onPaneMouseMove:Y,onPaneMouseLeave:J,onPaneContextMenu:X,onPaneScroll:K,deleteKeyCode:A,selectionKeyCode:N,selectionOnDrag:E,selectionMode:C,onSelectionStart:v,onSelectionEnd:x,multiSelectionKeyCode:j,panActivationKeyCode:S,zoomActivationKeyCode:I,elementsSelectable:T,onMove:n,onMoveStart:o,onMoveEnd:a,zoomOnScroll:z,zoomOnPinch:B,zoomOnDoubleClick:G,panOnScroll:U,panOnScrollSpeed:V,panOnScrollMode:$,panOnDrag:H,defaultViewport:D,translateExtent:_,minZoom:P,maxZoom:R,onSelectionContextMenu:g,preventScrolling:F,noDragClassName:se,noWheelClassName:ie,noPanClassName:le,disableKeyboardA11y:de},u.createElement(Mj,null,u.createElement(Ij,{edgeTypes:pe,onEdgeClick:l,onEdgeDoubleClick:d,onlyRenderVisibleElements:M,onEdgeContextMenu:Z,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:te,onReconnect:ne,onReconnectStart:oe,onReconnectEnd:re,reconnectRadius:ae,defaultMarkerColor:L,noPanClassName:le,elevateEdgesOnSelect:!!ce,disableKeyboardA11y:de,rfId:fe},u.createElement(_j,{style:b,type:y,component:w,containerStyle:k})),u.createElement("div",{className:"react-flow__edgelabel-renderer"}),u.createElement(cj,{nodeTypes:me,onNodeClick:i,onNodeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:f,onNodeMouseLeave:m,onNodeContextMenu:p,selectNodesOnDrag:O,onlyRenderVisibleElements:M,noPanClassName:le,noDragClassName:se,disableKeyboardA11y:de,nodeOrigin:ue,nodeExtent:he,rfId:fe})))};Rj.displayName="GraphView";var Fj=r.memo(Rj);const Lj=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],zj={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:Lj,nodeExtent:Lj,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:GN.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:(e,t)=>{},isValidConnection:void 0},Bj=()=>{return e=(e,t)=>({...zj,setNodes:n=>{const{nodeInternals:o,nodeOrigin:r,elevateNodesOnSelect:a}=t();e({nodeInternals:pC(n,o,r,a)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:o={}}=t();e({edges:n.map((e=>({...o,...e})))})},setDefaultNodesAndEdges:(n,o)=>{const r=void 0!==n,a=void 0!==o,s=r?pC(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:s,edges:a?o:[],hasDefaultNodes:r,hasDefaultEdges:a})},updateNodeDimensions:n=>{const{onNodesChange:o,nodeInternals:r,fitViewOnInit:a,fitViewOnInitDone:s,fitViewOnInitOptions:i,domNode:l,nodeOrigin:c}=t(),d=null==l?void 0:l.querySelector(".react-flow__viewport");if(!d)return;const u=window.getComputedStyle(d),{m22:h}=new window.DOMMatrixReadOnly(u.transform),f=n.reduce(((e,t)=>{const n=r.get(t.id);if(null==n?void 0:n.hidden)r.set(n.id,{...n,[_N]:{...n[_N],handleBounds:void 0}});else if(n){const o=EN(t.nodeElement);o.width&&o.height&&(n.width!==o.width||n.height!==o.height||t.forceUpdate)&&(r.set(n.id,{...n,[_N]:{...n[_N],handleBounds:{source:qC(".source",t.nodeElement,h,c),target:qC(".target",t.nodeElement,h,c)}},...o}),e.push({id:n.id,type:"dimensions",dimensions:o}))}return e}),[]);mC(r,c);const m=s||a&&!s&&gC(t,{initial:!0,...i});e({nodeInternals:new Map(r),fitViewOnInitDone:m}),(null==f?void 0:f.length)>0&&(null==o||o(f))},updateNodePositions:(e,n=!0,o=!1)=>{const{triggerNodeChanges:r}=t();r(e.map((e=>{const t={id:e.id,type:"position",dragging:o};return n&&(t.positionAbsolute=e.positionAbsolute,t.position=e.position),t})))},triggerNodeChanges:n=>{const{onNodesChange:o,nodeInternals:r,hasDefaultNodes:a,nodeOrigin:s,getNodes:i,elevateNodesOnSelect:l}=t();if(null==n?void 0:n.length){if(a){const t=pC(RC(n,i()),r,s,l);e({nodeInternals:t})}null==o||o(n)}},addSelectedNodes:n=>{const{multiSelectionActive:o,edges:r,getNodes:a}=t();let s,i=null;o?s=n.map((e=>FC(e,!0))):(s=LC(a(),n),i=LC(r,[])),yC({changedNodes:s,changedEdges:i,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:o,edges:r,getNodes:a}=t();let s,i=null;o?s=n.map((e=>FC(e,!0))):(s=LC(r,n),i=LC(a(),[])),yC({changedNodes:i,changedEdges:s,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:o}={})=>{const{edges:r,getNodes:a}=t(),s=o||r;yC({changedNodes:(n||a()).map((e=>(e.selected=!1,FC(e.id,!1)))),changedEdges:s.map((e=>FC(e.id,!1))),get:t,set:e})},setMinZoom:n=>{const{d3Zoom:o,maxZoom:r}=t();null==o||o.scaleExtent([n,r]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:o,minZoom:r}=t();null==o||o.scaleExtent([r,n]),e({maxZoom:n})},setTranslateExtent:n=>{var o;null==(o=t().d3Zoom)||o.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:o}=t();yC({changedNodes:o().filter((e=>e.selected)).map((e=>FC(e.id,!1))),changedEdges:n.filter((e=>e.selected)).map((e=>FC(e.id,!1))),get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:o}=t();o.forEach((e=>{e.positionAbsolute=jN(e.position,n)})),e({nodeExtent:n,nodeInternals:new Map(o)})},panBy:e=>{const{transform:n,width:o,height:r,d3Zoom:a,d3Selection:s,translateExtent:i}=t();if(!a||!s||!e.x&&!e.y)return!1;const l=gl.translate(n[0]+e.x,n[1]+e.y).scale(n[2]),c=[[0,0],[o,r]],d=null==a?void 0:a.constrain()(l,c,i);return a.transform(s,d),n[0]!==d.x||n[1]!==d.y||n[2]!==d.k},cancelConnection:()=>e({connectionNodeId:zj.connectionNodeId,connectionHandleId:zj.connectionHandleId,connectionHandleType:zj.connectionHandleType,connectionStatus:zj.connectionStatus,connectionStartHandle:zj.connectionStartHandle,connectionEndHandle:zj.connectionEndHandle}),reset:()=>e({...zj})}),t=Object.is,e?Rk(e,t):Rk;var e,t},Uj=({children:e})=>{const t=r.useRef(null);return t.current||(t.current=Bj()),u.createElement(lN,{value:t.current},e)};Uj.displayName="ReactFlowProvider";const Vj=({children:e})=>r.useContext(iN)?u.createElement(u.Fragment,null,e):u.createElement(Uj,null,e);Vj.displayName="ReactFlowWrapper";const $j={input:$E,default:UE,output:HE,group:WE},Gj={default:pE,straight:uE,step:dE,smoothstep:cE,simplebezier:rE},Hj=[0,0],Wj=[15,15],qj={x:0,y:0,zoom:1},Yj={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Jj=r.forwardRef((({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:a=$j,edgeTypes:s=Gj,onNodeClick:i,onEdgeClick:l,onInit:c,onMove:d,onMoveStart:h,onMoveEnd:f,onConnect:m,onConnectStart:p,onConnectEnd:g,onClickConnectStart:v,onClickConnectEnd:x,onNodeMouseEnter:y,onNodeMouseMove:b,onNodeMouseLeave:w,onNodeContextMenu:k,onNodeDoubleClick:N,onNodeDragStart:E,onNodeDrag:C,onNodeDragStop:j,onNodesDelete:S,onEdgesDelete:I,onSelectionChange:A,onSelectionDragStart:M,onSelectionDrag:T,onSelectionDragStop:O,onSelectionContextMenu:D,onSelectionStart:_,onSelectionEnd:P,connectionMode:R=GN.Strict,connectionLineType:F=KN.Bezier,connectionLineStyle:L,connectionLineComponent:z,connectionLineContainerStyle:B,deleteKeyCode:U="Backspace",selectionKeyCode:V="Shift",selectionOnDrag:$=!1,selectionMode:G=YN.Full,panActivationKeyCode:H="Space",multiSelectionKeyCode:W=(zN()?"Meta":"Control"),zoomActivationKeyCode:q=(zN()?"Meta":"Control"),snapToGrid:Y=!1,snapGrid:J=Wj,onlyRenderVisibleElements:K=!1,selectNodesOnDrag:X=!0,nodesDraggable:Z,nodesConnectable:Q,nodesFocusable:ee,nodeOrigin:te=Hj,edgesFocusable:ne,edgesUpdatable:oe,elementsSelectable:re,defaultViewport:ae=qj,minZoom:se=.5,maxZoom:ie=2,translateExtent:le=Lj,preventScrolling:ce=!0,nodeExtent:de,defaultMarkerColor:ue="#b1b1b7",zoomOnScroll:he=!0,zoomOnPinch:fe=!0,panOnScroll:me=!1,panOnScrollSpeed:pe=.5,panOnScrollMode:ge=WN.Free,zoomOnDoubleClick:ve=!0,panOnDrag:xe=!0,onPaneClick:ye,onPaneMouseEnter:be,onPaneMouseMove:we,onPaneMouseLeave:ke,onPaneScroll:Ne,onPaneContextMenu:Ee,children:Ce,onEdgeContextMenu:je,onEdgeDoubleClick:Se,onEdgeMouseEnter:Ie,onEdgeMouseMove:Ae,onEdgeMouseLeave:Me,onEdgeUpdate:Te,onEdgeUpdateStart:Oe,onEdgeUpdateEnd:De,onReconnect:_e,onReconnectStart:Pe,onReconnectEnd:Re,reconnectRadius:Fe=10,edgeUpdaterRadius:Le=10,onNodesChange:ze,onEdgesChange:Be,noDragClassName:Ue="nodrag",noWheelClassName:Ve="nowheel",noPanClassName:$e="nopan",fitView:Ge=!1,fitViewOptions:He,connectOnClick:We=!0,attributionPosition:qe,proOptions:Ye,defaultEdgeOptions:Je,elevateNodesOnSelect:Ke=!0,elevateEdgesOnSelect:Xe=!1,disableKeyboardA11y:Ze=!1,autoPanOnConnect:Qe=!0,autoPanOnNodeDrag:et=!0,connectionRadius:tt=20,isValidConnection:nt,onError:ot,style:rt,id:at,nodeDragThreshold:st,...it},lt)=>{const ct=at||"1";return u.createElement("div",{...it,style:{...rt,...Yj},ref:lt,className:Tk(["react-flow",r]),"data-testid":"rf__wrapper",id:at},u.createElement(Vj,null,u.createElement(Fj,{onInit:c,onMove:d,onMoveStart:h,onMoveEnd:f,onNodeClick:i,onEdgeClick:l,onNodeMouseEnter:y,onNodeMouseMove:b,onNodeMouseLeave:w,onNodeContextMenu:k,onNodeDoubleClick:N,nodeTypes:a,edgeTypes:s,connectionLineType:F,connectionLineStyle:L,connectionLineComponent:z,connectionLineContainerStyle:B,selectionKeyCode:V,selectionOnDrag:$,selectionMode:G,deleteKeyCode:U,multiSelectionKeyCode:W,panActivationKeyCode:H,zoomActivationKeyCode:q,onlyRenderVisibleElements:K,selectNodesOnDrag:X,defaultViewport:ae,translateExtent:le,minZoom:se,maxZoom:ie,preventScrolling:ce,zoomOnScroll:he,zoomOnPinch:fe,zoomOnDoubleClick:ve,panOnScroll:me,panOnScrollSpeed:pe,panOnScrollMode:ge,panOnDrag:xe,onPaneClick:ye,onPaneMouseEnter:be,onPaneMouseMove:we,onPaneMouseLeave:ke,onPaneScroll:Ne,onPaneContextMenu:Ee,onSelectionContextMenu:D,onSelectionStart:_,onSelectionEnd:P,onEdgeContextMenu:je,onEdgeDoubleClick:Se,onEdgeMouseEnter:Ie,onEdgeMouseMove:Ae,onEdgeMouseLeave:Me,onReconnect:_e??Te,onReconnectStart:Pe??Oe,onReconnectEnd:Re??De,reconnectRadius:Fe??Le,defaultMarkerColor:ue,noDragClassName:Ue,noWheelClassName:Ve,noPanClassName:$e,elevateEdgesOnSelect:Xe,rfId:ct,disableKeyboardA11y:Ze,nodeOrigin:te,nodeExtent:de}),u.createElement(nC,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:m,onConnectStart:p,onConnectEnd:g,onClickConnectStart:v,onClickConnectEnd:x,nodesDraggable:Z,nodesConnectable:Q,nodesFocusable:ee,edgesFocusable:ne,edgesUpdatable:oe,elementsSelectable:re,elevateNodesOnSelect:Ke,minZoom:se,maxZoom:ie,nodeExtent:de,onNodesChange:ze,onEdgesChange:Be,snapToGrid:Y,snapGrid:J,connectionMode:R,translateExtent:le,connectOnClick:We,defaultEdgeOptions:Je,fitView:Ge,fitViewOptions:He,onNodesDelete:S,onEdgesDelete:I,onNodeDragStart:E,onNodeDrag:C,onNodeDragStop:j,onSelectionDrag:T,onSelectionDragStart:M,onSelectionDragStop:O,noPanClassName:$e,nodeOrigin:te,rfId:ct,autoPanOnConnect:Qe,autoPanOnNodeDrag:et,onError:ot,connectionRadius:tt,isValidConnection:nt,nodeDragThreshold:st}),u.createElement(ZE,{onSelectionChange:A}),Ce,u.createElement(kN,{proOptions:Ye,position:qe}),u.createElement(cC,{rfId:ct,disableKeyboardA11y:Ze})))}));function Kj(e){return t=>{const[n,o]=r.useState(t),a=r.useCallback((t=>o((n=>e(t,n)))),[]);return[n,o,a]}}Jj.displayName="ReactFlow";const Xj=Kj(RC),Zj=Kj((function(e,t){return PC(e,t)}));function Qj(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},u.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function eS(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},u.createElement("path",{d:"M0 0h32v4.2H0z"}))}function tS(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},u.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function nS(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},u.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function oS(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},u.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const rS=({children:e,className:t,...n})=>u.createElement("button",{type:"button",className:Tk(["react-flow__controls-button",t]),...n},e);rS.displayName="ControlButton";const aS=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),sS=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:a,onZoomIn:s,onZoomOut:i,onFitView:l,onInteractiveChange:c,className:d,children:h,position:f="bottom-left"})=>{const m=yN(),[p,g]=r.useState(!1),{isInteractive:v,minZoomReached:x,maxZoomReached:y}=xN(aS,Fk),{zoomIn:b,zoomOut:w,fitView:k}=NC();if(r.useEffect((()=>{g(!0)}),[]),!p)return null;return u.createElement(wN,{className:Tk(["react-flow__controls",d]),position:f,style:e,"data-testid":"rf__controls"},t&&u.createElement(u.Fragment,null,u.createElement(rS,{onClick:()=>{b(),null==s||s()},className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:y},u.createElement(Qj,null)),u.createElement(rS,{onClick:()=>{w(),null==i||i()},className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:x},u.createElement(eS,null))),n&&u.createElement(rS,{className:"react-flow__controls-fitview",onClick:()=>{k(a),null==l||l()},title:"fit view","aria-label":"fit view"},u.createElement(tS,null)),o&&u.createElement(rS,{className:"react-flow__controls-interactive",onClick:()=>{m.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),null==c||c(!v)},title:"toggle interactivity","aria-label":"toggle interactivity"},v?u.createElement(oS,null):u.createElement(nS,null)),h)};sS.displayName="Controls";var iS,lS,cS=r.memo(sS);function dS({color:e,dimensions:t,lineWidth:n}){return u.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function uS({color:e,radius:t}){return u.createElement("circle",{cx:t,cy:t,r:t,fill:e})}(lS=iS||(iS={})).Lines="lines",lS.Dots="dots",lS.Cross="cross";const hS={[iS.Dots]:"#91919a",[iS.Lines]:"#eee",[iS.Cross]:"#e2e2e2"},fS={[iS.Dots]:1,[iS.Lines]:1,[iS.Cross]:6},mS=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function pS({id:e,variant:t=iS.Dots,gap:n=20,size:o,lineWidth:a=1,offset:s=2,color:i,style:l,className:c}){const d=r.useRef(null),{transform:h,patternId:f}=xN(mS,Fk),m=i||hS[t],p=o||fS[t],g=t===iS.Dots,v=t===iS.Cross,x=Array.isArray(n)?n:[n,n],y=[x[0]*h[2]||1,x[1]*h[2]||1],b=p*h[2],w=v?[b,b]:y,k=g?[b/s,b/s]:[w[0]/s,w[1]/s];return u.createElement("svg",{className:Tk(["react-flow__background",c]),style:{...l,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:d,"data-testid":"rf__background"},u.createElement("pattern",{id:f+e,x:h[0]%y[0],y:h[1]%y[1],width:y[0],height:y[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`},g?u.createElement(uS,{color:m,radius:b/s}):u.createElement(dS,{dimensions:w,color:m,lineWidth:a})),u.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${f+e})`}))}pS.displayName="Background";var gS=r.memo(pS);function vS(e){return Math.min(11*e+35,200)}const xS=u.createContext("LR"),yS=r.memo((e=>{const{data:t,selected:n}=e,o=X(t.atom),a=te().inOrderIds.indexOf(o.id),s=n?"var(--gray-9)":"var(--gray-3)",i=xN((({width:e})=>e)),l=r.useContext(xS),c=o.code.split("\n").length;return m.jsxs("div",{children:[m.jsx(zE,{type:"target",id:"inputs",position:"LR"===l?eE.Left:eE.Top,style:{background:s}}),m.jsx(zE,{type:"source",id:"inputs",position:"LR"===l?eE.Left:eE.Top,style:{background:s}}),m.jsxs("div",{className:$t("flex flex-col bg-card border border-input/50 rounded-md mx-[2px] overflow-hidden",n&&"border-primary"),style:{height:vS(c),width:t.forceWidth||(d=i,Math.min(Math.max(d-100,100),400))},children:[m.jsx("div",{className:"text-muted-foreground font-semibold text-xs py-1 px-2 bg-muted border-b",children:Sa(o.name,a)}),m.jsx(ml,{code:o.code})]}),m.jsx(zE,{type:"source",id:"outputs",position:"LR"===l?eE.Right:eE.Bottom,style:{background:s}}),m.jsx(zE,{type:"target",id:"outputs",position:"LR"===l?eE.Right:eE.Bottom,style:{background:s}})]});var d}),((e,t)=>["data","selected","id"].every((n=>e[n]===t[n]))));yS.displayName="CustomNode";const bS={custom:yS},wS=({maxCount:e,cellIds:t,onClick:n,skipScroll:o})=>{const r=te(),a=[...t].sort(((e,t)=>r.inOrderIds.indexOf(e)-r.inOrderIds.indexOf(t)));return 0===t.length?m.jsx("div",{className:"text-muted-foreground",children:"--"}):m.jsxs(m.Fragment,{children:[a.slice(0,e).map(((e,r)=>m.jsxs("span",{className:"truncate",children:[m.jsx(Ia,{variant:"focus",cellId:e,skipScroll:o,className:"whitespace-nowrap",onClick:n?()=>n(e):void 0},e),r<t.length-1&&", "]},e))),t.length>e&&m.jsxs(Yt,{children:[m.jsx(Oo,{asChild:!0,children:m.jsxs("span",{className:"whitespace-nowrap text-muted-foreground text-xs hover:underline cursor-pointer",children:["+",t.length-e," more"]})}),m.jsx(Xt,{className:"w-auto",children:m.jsx("div",{className:"flex flex-col gap-1 py-1",children:a.slice(e).map((e=>m.jsx(Ia,{variant:"focus",cellId:e,className:"whitespace-nowrap",onClick:n?()=>n(e):void 0},e)))})})]})]})},kS=({name:e,declaredBy:t,onClick:n,...o})=>m.jsx("div",{className:"max-w-[130px]",...o,children:m.jsx(Aa,{title:e,variant:t.length>1?"destructive":"outline",className:"rounded-sm text-ellipsis block overflow-hidden max-w-fit cursor-pointer font-medium",onClick:t=>{n?n(t):(navigator.clipboard.writeText(e),q({title:"Copied to clipboard"}))},children:e})}),NS=r.memo((({onChange:e,view:t,settings:n,onSettingsChange:o})=>{const r=m.jsxs(Yt,{children:[m.jsx(Oo,{asChild:!0,children:m.jsx(b,{variant:"text",size:"xs",children:m.jsx(vt,{className:"w-4 h-4"})})}),m.jsxs(Xt,{className:"w-auto p-2 text-muted-foreground",children:[m.jsx("div",{className:"font-semibold pb-4",children:"Settings"}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(ir,{"data-testid":"hide-pure-markdown-checkbox",id:"hide-pure-markdown",checked:n.hidePureMarkdown,onCheckedChange:e=>{return t="hidePureMarkdown",r=Boolean(e),void o({...n,[t]:r});var t,r}}),m.jsx(ae,{htmlFor:"hide-pure-markdown",children:"Hide pure markdown"})]})]})]});return m.jsxs(wN,{position:"top-right",className:"flex flex-col items-end gap-2",children:[m.jsxs("div",{className:"flex gap-2",children:[m.jsxs(b,{variant:"outline",className:"bg-background","aria-selected":"_minimap_"===t,size:"xs",onClick:()=>e("_minimap_"),children:[m.jsx(pc,{className:"w-4 h-4 mr-1"}),"Mini Map"]}),m.jsxs(b,{variant:"outline",className:"bg-background","aria-selected":"TB"===t,size:"xs",onClick:()=>e("TB"),children:[m.jsx(oc,{className:"w-4 h-4 mr-1"}),"Vertical Tree"]}),m.jsxs(b,{variant:"outline",className:"bg-background","aria-selected":"LR"===t,size:"xs",onClick:()=>e("LR"),children:[m.jsx(oc,{className:"w-4 h-4 mr-1 transform -rotate-90"})," ","Horizontal Tree"]})]}),"_minimap_"!==t&&r]})}));NS.displayName="GraphToolbar";const ES=r.memo((({selection:e,edges:t,variables:n})=>{if(!e)return null;const o=(e,t)=>{const n=lr(e);n&&Ma(n,t)};return m.jsx(wN,{position:"bottom-left",className:"max-h-[90%] flex flex-col w-[calc(100%-5rem)]",children:m.jsx("div",{className:"min-h-[100px] shadow-md rounded-md border max-w-[550px] border-primary/40 my-4 min-w-[240px] bg-[var(--slate-1)] text-muted-foreground/80 flex flex-col overflow-y-auto",children:(()=>{if("node"===e.type){const t=Object.values(n).filter((t=>t.usedBy.includes(e.id))),r=Object.values(n).filter((t=>t.declaredBy.includes(e.id))),a=(e,t)=>m.jsxs(m.Fragment,{children:[0===e.length&&m.jsx("div",{className:"text-muted-foreground text-sm text-center",children:"--"}),m.jsx("div",{className:"grid grid-cols-5 gap-3 items-center text-sm py-1 flex-1 empty:hidden",children:e.map((e=>m.jsxs(u.Fragment,{children:[m.jsx(kS,{declaredBy:e.declaredBy,name:e.name}),m.jsxs("div",{className:"truncate col-span-2",title:e.value??"",children:[e.value,m.jsxs("span",{className:"ml-1 truncate text-foreground/60 font-mono",children:["(",e.dataType,")"]})]}),m.jsx("div",{className:"truncate col-span-2 gap-1 items-center",children:m.jsx(wS,{skipScroll:!0,onClick:()=>o("in"===t?e.declaredBy[0]:e.usedBy[0],e.name),maxCount:3,cellIds:e.usedBy})})]},e.name)))})]});return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"font-bold py-2 flex items-center gap-2 border-b px-3",children:[m.jsx(Je,{className:"w-5 h-5"}),m.jsx(Ia,{cellId:e.id}),m.jsx("div",{className:"flex-1"}),m.jsx(xx,{cellId:e.id,children:m.jsx(b,{variant:"ghost",size:"icon",children:m.jsx(Bl,{className:"w-4 h-4"})})})]}),m.jsxs("div",{className:"text-sm flex flex-col py-3 pl-2 pr-4 flex-1 justify-center",children:[m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("span",{className:"flex items-center gap-2 font-semibold",children:[m.jsx(Nl,{className:"w-4 h-4"}),"Outputs"]}),a(r,"out")]}),m.jsx("hr",{className:"border-divider my-3"}),m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("span",{className:"flex items-center gap-2 font-semibold",children:[m.jsx(El,{className:"w-4 h-4"}),"Inputs"]}),a(t,"in")]})]})]})}if("edge"===e.type){const t=Object.values(n).filter((t=>t.declaredBy.includes(e.source)&&t.usedBy.includes(e.target)));return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"font-bold py-2 flex items-center gap-2 border-b px-3",children:[m.jsx(_c,{className:"w-4 h-4"}),m.jsx(Ia,{cellId:e.source}),m.jsx(Cl,{className:"w-4 h-4"}),m.jsx(Ia,{cellId:e.target})]}),m.jsx("div",{className:"grid grid-cols-4 gap-3 max-w-[350px] items-center text-sm p-3 flex-1",children:t.map((e=>m.jsxs(u.Fragment,{children:[m.jsx(kS,{declaredBy:e.declaredBy,name:e.name,onClick:()=>{o(e.declaredBy[0],e.name)}}),m.jsx("div",{className:"truncate text-foreground/60 font-mono",children:e.dataType}),m.jsx("div",{className:"truncate col-span-2",title:e.value??"",children:e.value})]},e.name)))})]})}})()})})}));function CS(){const e=NC(),t=xN((({width:e})=>e)),n=xN((({height:e})=>e)),o=Ta((()=>{e.fitView({duration:100})}),100);r.useEffect((()=>{t&&n&&o()}),[t,n,o])}ES.displayName="GraphSelectionPanel";const jS=new class{createEdge(e,t,n){return{type:"smoothstep",pathOptions:{offset:20,borderRadius:100},data:{direction:n},markerEnd:{type:ZN.Arrow},id:`${e}-${t}-${n}`,source:e,sourceHandle:n,targetHandle:n,target:t}}createNode(e,t,n){return{id:e,data:{atom:t},width:250,type:"custom",height:vS(G.get(t).code.trim().split("\n").length),position:{x:0,y:n+20}}}createElements(e,t,n,o){let r=0;const a=[],s=[];for(const[l,c]of Gr.zip(e,t)){const e=this.createNode(l,c,r);a.push(e),r=e.position.y+(e.height||0)}const i=new Set;for(const l of Object.values(n)){const{declaredBy:e,usedBy:t}=l;for(const n of e)for(const e of t){const t=`${n}-${e}`;i.has(t)||(i.add(t),s.push(this.createEdge(n,e,"inputs"),this.createEdge(n,e,"outputs")))}}return{nodes:a,edges:s}}},SS=({cellIds:e,variables:t,cellAtoms:n,children:o})=>{const{nodes:a,edges:s}=jS.createElements(e,n,t,!1),[i,l]=Zj([]),[c,d]=Xj(a),[u,h]=r.useState(),[f,p]=r.useState(),g=r.useRef(!1);CS();const v=xN((({height:e})=>e)),x=R((e=>{d(e.nodes),l([])}));r.useEffect((()=>{g.current?x(jS.createElements(e,n,t,!1)):g.current=!0}),[e,t,n,x]),r.useEffect((()=>{if(u){const e=s.filter((e=>{const{source:t,target:n,data:o}=e;return t===u&&"outputs"===o.direction||n===u&&"inputs"===o.direction}));l(e)}}),[u,l,s]);const y=function(e,t){const n=10;return r.useMemo((()=>{const o=e.reduce(((e,{position:o})=>Math.min(e,o.y-t/2-n)),Number.POSITIVE_INFINITY),r=e.reduce(((e,{position:o})=>Math.max(e,o.y+t/2+n)),Number.NEGATIVE_INFINITY);return[[Number.NEGATIVE_INFINITY,o],[Number.POSITIVE_INFINITY,r]]}),[e,t])}(c,v);return m.jsxs(Jj,{nodes:c,edges:i,nodeTypes:bS,translateExtent:y,onNodeClick:(e,t)=>{const n=t.id;h(n),p(void 0),l([])},onNodeDoubleClick:(e,t)=>{Oa(t.id,"focus")},onEdgeClick:(e,t)=>{p(t)},snapToGrid:!0,fitView:!0,elementsSelectable:!0,minZoom:1,maxZoom:1,draggable:!1,panOnScrollMode:WN.Vertical,zoomOnDoubleClick:!1,nodesDraggable:!1,nodesConnectable:!1,nodesFocusable:!1,edgesFocusable:!1,selectNodesOnDrag:!1,panOnDrag:!1,preventScrolling:!1,zoomOnPinch:!1,panOnScroll:!0,autoPanOnNodeDrag:!1,autoPanOnConnect:!1,children:[f?m.jsx(ES,{selection:{type:"edge",source:f.source,target:f.target},variables:t,edges:i}):u?m.jsx(ES,{selection:{type:"node",id:u},variables:t,edges:i}):null,o]})};var IS="\0";function AS(e,t){e[t]?e[t]++:e[t]=1}function MS(e,t){--e[t]||delete e[t]}function TS(e,t,n,o){var r=""+t,a=""+n;if(!e&&r>a){var s=r;r=a,a=s}return r+""+a+""+(void 0===o?"\0":o)}function OS(e,t){return TS(e,t.v,t.w,t.name)}var DS=class{constructor(e){n(this,"_isDirected",!0),n(this,"_isMultigraph",!1),n(this,"_isCompound",!1),n(this,"_label"),n(this,"_defaultNodeLabelFn",(()=>{})),n(this,"_defaultEdgeLabelFn",(()=>{})),n(this,"_nodes",{}),n(this,"_in",{}),n(this,"_preds",{}),n(this,"_out",{}),n(this,"_sucs",{}),n(this,"_edgeObjs",{}),n(this,"_edgeLabels",{}),n(this,"_nodeCount",0),n(this,"_edgeCount",0),n(this,"_parent"),n(this,"_children"),e&&(this._isDirected=!Object.hasOwn(e,"directed")||e.directed,this._isMultigraph=!!Object.hasOwn(e,"multigraph")&&e.multigraph,this._isCompound=!!Object.hasOwn(e,"compound")&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[IS]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=e,"function"!=typeof e&&(this._defaultNodeLabelFn=()=>e),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var e=this;return this.nodes().filter((t=>0===Object.keys(e._in[t]).length))}sinks(){var e=this;return this.nodes().filter((t=>0===Object.keys(e._out[t]).length))}setNodes(e,t){var n=arguments,o=this;return e.forEach((function(e){n.length>1?o.setNode(e,t):o.setNode(e)})),this}setNode(e,t){return Object.hasOwn(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=IS,this._children[e]={},this._children[IS][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return Object.hasOwn(this._nodes,e)}removeNode(e){var t=this;if(Object.hasOwn(this._nodes,e)){var n=e=>t.removeEdge(t._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach((function(e){t.setParent(e)})),delete this._children[e]),Object.keys(this._in[e]).forEach(n),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(n),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(void 0===t)t=IS;else{for(var n=t+="";void 0!==n;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var t=this._parent[e];if(t!==IS)return t}}children(e=IS){if(this._isCompound){var t=this._children[e];if(t)return Object.keys(t)}else{if(e===IS)return this.nodes();if(this.hasNode(e))return[]}}predecessors(e){var t=this._preds[e];if(t)return Object.keys(t)}successors(e){var t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){var t=this.predecessors(e);if(t){const o=new Set(t);for(var n of this.successors(e))o.add(n);return Array.from(o.values())}}isLeaf(e){return 0===(this.isDirected()?this.successors(e):this.neighbors(e)).length}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var n=this;Object.entries(this._nodes).forEach((function([n,o]){e(n)&&t.setNode(n,o)})),Object.values(this._edgeObjs).forEach((function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,n.edge(e))}));var o={};function r(e){var a=n.parent(e);return void 0===a||t.hasNode(a)?(o[e]=a,a):a in o?o[a]:r(a)}return this._isCompound&&t.nodes().forEach((e=>t.setParent(e,r(e)))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=e,"function"!=typeof e&&(this._defaultEdgeLabelFn=()=>e),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){var n=this,o=arguments;return e.reduce((function(e,r){return o.length>1?n.setEdge(e,r,t):n.setEdge(e,r),r})),this}setEdge(){var e,t,n,o,r=!1,a=arguments[0];"object"==typeof a&&null!==a&&"v"in a?(e=a.v,t=a.w,n=a.name,2===arguments.length&&(o=arguments[1],r=!0)):(e=a,t=arguments[1],n=arguments[3],arguments.length>2&&(o=arguments[2],r=!0)),e=""+e,t=""+t,void 0!==n&&(n=""+n);var s=TS(this._isDirected,e,t,n);if(Object.hasOwn(this._edgeLabels,s))return r&&(this._edgeLabels[s]=o),this;if(void 0!==n&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(t),this._edgeLabels[s]=r?o:this._defaultEdgeLabelFn(e,t,n);var i=function(e,t,n,o){var r=""+t,a=""+n;if(!e&&r>a){var s=r;r=a,a=s}var i={v:r,w:a};o&&(i.name=o);return i}(this._isDirected,e,t,n);return e=i.v,t=i.w,Object.freeze(i),this._edgeObjs[s]=i,AS(this._preds[t],e),AS(this._sucs[e],t),this._in[t][s]=i,this._out[e][s]=i,this._edgeCount++,this}edge(e,t,n){var o=1===arguments.length?OS(this._isDirected,arguments[0]):TS(this._isDirected,e,t,n);return this._edgeLabels[o]}edgeAsObj(){const e=this.edge(...arguments);return"object"!=typeof e?{label:e}:e}hasEdge(e,t,n){var o=1===arguments.length?OS(this._isDirected,arguments[0]):TS(this._isDirected,e,t,n);return Object.hasOwn(this._edgeLabels,o)}removeEdge(e,t,n){var o=1===arguments.length?OS(this._isDirected,arguments[0]):TS(this._isDirected,e,t,n),r=this._edgeObjs[o];return r&&(e=r.v,t=r.w,delete this._edgeLabels[o],delete this._edgeObjs[o],MS(this._preds[t],e),MS(this._sucs[e],t),delete this._in[t][o],delete this._out[e][o],this._edgeCount--),this}inEdges(e,t){var n=this._in[e];if(n){var o=Object.values(n);return t?o.filter((e=>e.v===t)):o}}outEdges(e,t){var n=this._out[e];if(n){var o=Object.values(n);return t?o.filter((e=>e.w===t)):o}}nodeEdges(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))}},_S={Graph:DS,version:"2.2.4"},PS=DS,RS={write:function(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:FS(e),edges:LS(e)};void 0!==e.graph()&&(t.value=structuredClone(e.graph()));return t},read:function(e){var t=new PS(e.options).setGraph(e.value);return e.nodes.forEach((function(e){t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)})),e.edges.forEach((function(e){t.setEdge({v:e.v,w:e.w,name:e.name},e.value)})),t}};function FS(e){return e.nodes().map((function(t){var n=e.node(t),o=e.parent(t),r={v:t};return void 0!==n&&(r.value=n),void 0!==o&&(r.parent=o),r}))}function LS(e){return e.edges().map((function(t){var n=e.edge(t),o={v:t.v,w:t.w};return void 0!==t.name&&(o.name=t.name),void 0!==n&&(o.value=n),o}))}var zS=function(e){var t,n={},o=[];function r(o){Object.hasOwn(n,o)||(n[o]=!0,t.push(o),e.successors(o).forEach(r),e.predecessors(o).forEach(r))}return e.nodes().forEach((function(e){t=[],r(e),t.length&&o.push(t)})),o};var BS=class{constructor(){n(this,"_arr",[]),n(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map((function(e){return e.key}))}has(e){return Object.hasOwn(this._keyIndices,e)}priority(e){var t=this._keyIndices[e];if(void 0!==t)return this._arr[t].priority}min(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key}add(e,t){var n=this._keyIndices;if(e=String(e),!Object.hasOwn(n,e)){var o=this._arr,r=o.length;return n[e]=r,o.push({key:e,priority:t}),this._decrease(r),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){var n=this._keyIndices[e];if(t>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+e+" Old: "+this._arr[n].priority+" New: "+t);this._arr[n].priority=t,this._decrease(n)}_heapify(e){var t=this._arr,n=2*e,o=n+1,r=e;n<t.length&&(r=t[n].priority<t[r].priority?n:r,o<t.length&&(r=t[o].priority<t[r].priority?o:r),r!==e&&(this._swap(e,r),this._heapify(r)))}_decrease(e){for(var t,n=this._arr,o=n[e].priority;0!==e&&!(n[t=e>>1].priority<o);)this._swap(e,t),e=t}_swap(e,t){var n=this._arr,o=this._keyIndices,r=n[e],a=n[t];n[e]=a,n[t]=r,o[a.key]=e,o[r.key]=t}},US=BS,VS=function(e,t,n,o){return function(e,t,n,o){var r,a,s={},i=new US,l=function(e){var t=e.v!==r?e.v:e.w,o=s[t],l=n(e),c=a.distance+l;if(l<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+e+" Weight: "+l);c<o.distance&&(o.distance=c,o.predecessor=r,i.decrease(t,c))};e.nodes().forEach((function(e){var n=e===t?0:Number.POSITIVE_INFINITY;s[e]={distance:n},i.add(e,n)}));for(;i.size()>0&&(r=i.removeMin(),(a=s[r]).distance!==Number.POSITIVE_INFINITY);)o(r).forEach(l);return s}(e,String(t),n||$S,o||function(t){return e.outEdges(t)})},$S=()=>1;var GS=VS,HS=function(e,t,n){return e.nodes().reduce((function(o,r){return o[r]=GS(e,r,t,n),o}),{})};var WS=function(e){var t=0,n=[],o={},r=[];function a(s){var i=o[s]={onStack:!0,lowlink:t,index:t++};if(n.push(s),e.successors(s).forEach((function(e){Object.hasOwn(o,e)?o[e].onStack&&(i.lowlink=Math.min(i.lowlink,o[e].index)):(a(e),i.lowlink=Math.min(i.lowlink,o[e].lowlink))})),i.lowlink===i.index){var l,c=[];do{l=n.pop(),o[l].onStack=!1,c.push(l)}while(s!==l);r.push(c)}}return e.nodes().forEach((function(e){Object.hasOwn(o,e)||a(e)})),r};var qS=WS,YS=function(e){return qS(e).filter((function(t){return t.length>1||1===t.length&&e.hasEdge(t[0],t[0])}))};var JS=function(e,t,n){return function(e,t,n){var o={},r=e.nodes();return r.forEach((function(e){o[e]={},o[e][e]={distance:0},r.forEach((function(t){e!==t&&(o[e][t]={distance:Number.POSITIVE_INFINITY})})),n(e).forEach((function(n){var r=n.v===e?n.w:n.v,a=t(n);o[e][r]={distance:a,predecessor:e}}))})),r.forEach((function(e){var t=o[e];r.forEach((function(n){var a=o[n];r.forEach((function(n){var o=a[e],r=t[n],s=a[n],i=o.distance+r.distance;i<s.distance&&(s.distance=i,s.predecessor=r.predecessor)}))}))})),o}(e,t||KS,n||function(t){return e.outEdges(t)})},KS=()=>1;function XS(e){var t={},n={},o=[];if(e.sinks().forEach((function r(a){if(Object.hasOwn(n,a))throw new ZS;Object.hasOwn(t,a)||(n[a]=!0,t[a]=!0,e.predecessors(a).forEach(r),delete n[a],o.push(a))})),Object.keys(t).length!==e.nodeCount())throw new ZS;return o}class ZS extends Error{constructor(){super(...arguments)}}var QS=XS;XS.CycleException=ZS;var eI=QS;var tI=function(e,t,n){Array.isArray(t)||(t=[t]);var o=e.isDirected()?t=>e.successors(t):t=>e.neighbors(t),r="post"===n?nI:oI,a=[],s={};return t.forEach((t=>{if(!e.hasNode(t))throw new Error("Graph does not have node: "+t);r(t,o,s,a)})),a};function nI(e,t,n,o){for(var r=[[e,!1]];r.length>0;){var a=r.pop();a[1]?o.push(a[0]):Object.hasOwn(n,a[0])||(n[a[0]]=!0,r.push([a[0],!0]),rI(t(a[0]),(e=>r.push([e,!1]))))}}function oI(e,t,n,o){for(var r=[e];r.length>0;){var a=r.pop();Object.hasOwn(n,a)||(n[a]=!0,o.push(a),rI(t(a),(e=>r.push(e))))}}function rI(e,t){for(var n=e.length;n--;)t(e[n],n,e);return e}var aI=tI;var sI=tI;var iI=DS,lI=BS;var cI={Graph:_S.Graph,json:RS,alg:{components:zS,dijkstra:VS,dijkstraAll:HS,findCycles:YS,floydWarshall:JS,isAcyclic:function(e){try{eI(e)}catch(t){if(t instanceof eI.CycleException)return!1;throw t}return!0},postorder:function(e,t){return aI(e,t,"post")},preorder:function(e,t){return sI(e,t,"pre")},prim:function(e,t){var n,o=new iI,r={},a=new lI;function s(e){var o=e.v===n?e.w:e.v,s=a.priority(o);if(void 0!==s){var i=t(e);i<s&&(r[o]=n,a.decrease(o,i))}}if(0===e.nodeCount())return o;e.nodes().forEach((function(e){a.add(e,Number.POSITIVE_INFINITY),o.setNode(e)})),a.decrease(e.nodes()[0],0);var i=!1;for(;a.size()>0;){if(n=a.removeMin(),Object.hasOwn(r,n))o.setEdge(n,r[n]);else{if(i)throw new Error("Input graph is not connected: "+e);i=!0}e.nodeEdges(n).forEach(s)}return o},tarjan:WS,topsort:QS},version:_S.version};function dI(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function uI(e,t){if("_next"!==e&&"_prev"!==e)return t}let hI=cI.Graph,fI=class{constructor(){let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return dI(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&dI(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,uI)),n=n._prev;return"["+e.join(", ")+"]"}};var mI=function(e,t){if(e.nodeCount()<=1)return[];let n=function(e,t){let n=new hI,o=0,r=0;e.nodes().forEach((e=>{n.setNode(e,{v:e,in:0,out:0})})),e.edges().forEach((e=>{let a=n.edge(e.v,e.w)||0,s=t(e),i=a+s;n.setEdge(e.v,e.w,i),r=Math.max(r,n.node(e.v).out+=s),o=Math.max(o,n.node(e.w).in+=s)}));let a=function(e){const t=[];for(let n=0;n<e;n++)t.push(n);return t}(r+o+3).map((()=>new fI)),s=o+1;return n.nodes().forEach((e=>{vI(a,s,n.node(e))})),{graph:n,buckets:a,zeroIdx:s}}(e,t||pI);return function(e,t,n){let o,r=[],a=t[t.length-1],s=t[0];for(;e.nodeCount();){for(;o=s.dequeue();)gI(e,t,n,o);for(;o=a.dequeue();)gI(e,t,n,o);if(e.nodeCount())for(let a=t.length-2;a>0;--a)if(o=t[a].dequeue(),o){r=r.concat(gI(e,t,n,o,!0));break}}return r}(n.graph,n.buckets,n.zeroIdx).flatMap((t=>e.outEdges(t.v,t.w)))};let pI=()=>1;function gI(e,t,n,o,r){let a=r?[]:void 0;return e.inEdges(o.v).forEach((o=>{let s=e.edge(o),i=e.node(o.v);r&&a.push({v:o.v,w:o.w}),i.out-=s,vI(t,n,i)})),e.outEdges(o.v).forEach((o=>{let r=e.edge(o),a=o.w,s=e.node(a);s.in-=r,vI(t,n,s)})),e.removeNode(o.v),a}function vI(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}let xI=cI.Graph;var yI={addBorderNode:function(e,t,n,o){let r={width:0,height:0};arguments.length>=4&&(r.rank=n,r.order=o);return bI(e,"border",r,t)},addDummyNode:bI,applyWithChunking:kI,asNonCompoundGraph:function(e){let t=new xI({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach((n=>{e.children(n).length||t.setNode(n,e.node(n))})),e.edges().forEach((n=>{t.setEdge(n,e.edge(n))})),t},buildLayerMatrix:function(e){let t=jI(NI(e)+1).map((()=>[]));return e.nodes().forEach((n=>{let o=e.node(n),r=o.rank;void 0!==r&&(t[r][o.order]=n)})),t},intersectRect:function(e,t){let n,o,r=e.x,a=e.y,s=t.x-r,i=t.y-a,l=e.width/2,c=e.height/2;if(!s&&!i)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(i)*l>Math.abs(s)*c?(i<0&&(c=-c),n=c*s/i,o=c):(s<0&&(l=-l),n=l,o=l*i/s);return{x:r+n,y:a+o}},mapValues:function(e,t){let n=t;"string"==typeof t&&(n=e=>e[t]);return Object.entries(e).reduce(((e,[t,o])=>(e[t]=n(o,t),e)),{})},maxRank:NI,normalizeRanks:function(e){let t=e.nodes().map((t=>{let n=e.node(t).rank;return void 0===n?Number.MAX_VALUE:n})),n=kI(Math.min,t);e.nodes().forEach((t=>{let o=e.node(t);Object.hasOwn(o,"rank")&&(o.rank-=n)}))},notime:function(e,t){return t()},partition:function(e,t){let n={lhs:[],rhs:[]};return e.forEach((e=>{t(e)?n.lhs.push(e):n.rhs.push(e)})),n},pick:function(e,t){const n={};for(const o of t)void 0!==e[o]&&(n[o]=e[o]);return n},predecessorWeights:function(e){let t=e.nodes().map((t=>{let n={};return e.inEdges(t).forEach((t=>{n[t.v]=(n[t.v]||0)+e.edge(t).weight})),n}));return SI(e.nodes(),t)},range:jI,removeEmptyRanks:function(e){let t=e.nodes().map((t=>e.node(t).rank)),n=kI(Math.min,t),o=[];e.nodes().forEach((t=>{let r=e.node(t).rank-n;o[r]||(o[r]=[]),o[r].push(t)}));let r=0,a=e.graph().nodeRankFactor;Array.from(o).forEach(((t,n)=>{void 0===t&&n%a!=0?--r:void 0!==t&&r&&t.forEach((t=>e.node(t).rank+=r))}))},simplify:function(e){let t=(new xI).setGraph(e.graph());return e.nodes().forEach((n=>t.setNode(n,e.node(n)))),e.edges().forEach((n=>{let o=t.edge(n.v,n.w)||{weight:0,minlen:1},r=e.edge(n);t.setEdge(n.v,n.w,{weight:o.weight+r.weight,minlen:Math.max(o.minlen,r.minlen)})})),t},successorWeights:function(e){let t=e.nodes().map((t=>{let n={};return e.outEdges(t).forEach((t=>{n[t.w]=(n[t.w]||0)+e.edge(t).weight})),n}));return SI(e.nodes(),t)},time:function(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}},uniqueId:CI,zipObject:SI};function bI(e,t,n,o){let r;do{r=CI(o)}while(e.hasNode(r));return n.dummy=t,e.setNode(r,n),r}const wI=65535;function kI(e,t){if(t.length>wI){const n=function(e,t=wI){const n=[];for(let o=0;o<e.length;o+=t){const r=e.slice(o,o+t);n.push(r)}return n}(t);return e.apply(null,n.map((t=>e.apply(null,t))))}return e.apply(null,t)}function NI(e){const t=e.nodes().map((t=>{let n=e.node(t).rank;return void 0===n?Number.MIN_VALUE:n}));return kI(Math.max,t)}let EI=0;function CI(e){var t=++EI;return toString(e)+t}function jI(e,t,n=1){null==t&&(t=e,e=0);let o=e=>e<t;n<0&&(o=e=>t<e);const r=[];for(let a=e;o(a);a+=n)r.push(a);return r}function SI(e,t){return e.reduce(((e,n,o)=>(e[n]=t[o],e)),{})}let II=mI,AI=yI.uniqueId;var MI={run:function(e){("greedy"===e.graph().acyclicer?II(e,(t=e,e=>t.edge(e).weight)):function(e){let t=[],n={},o={};function r(a){Object.hasOwn(o,a)||(o[a]=!0,n[a]=!0,e.outEdges(a).forEach((e=>{Object.hasOwn(n,e.w)?t.push(e):r(e.w)})),delete n[a])}return e.nodes().forEach(r),t}(e)).forEach((t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,AI("rev"))}));var t},undo:function(e){e.edges().forEach((t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let o=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,o)}}))}};let TI=yI;var OI={run:function(e){e.graph().dummyChains=[],e.edges().forEach((t=>function(e,t){let n,o,r,a=t.v,s=e.node(a).rank,i=t.w,l=e.node(i).rank,c=t.name,d=e.edge(t),u=d.labelRank;if(l===s+1)return;for(e.removeEdge(t),r=0,++s;s<l;++r,++s)d.points=[],o={width:0,height:0,edgeLabel:d,edgeObj:t,rank:s},n=TI.addDummyNode(e,"edge",o,"_d"),s===u&&(o.width=d.width,o.height=d.height,o.dummy="edge-label",o.labelpos=d.labelpos),e.setEdge(a,n,{weight:d.weight},c),0===r&&e.graph().dummyChains.push(n),a=n;e.setEdge(a,i,{weight:d.weight},c)}(e,t)))},undo:function(e){e.graph().dummyChains.forEach((t=>{let n,o=e.node(t),r=o.edgeLabel;for(e.setEdge(o.edgeObj,r);o.dummy;)n=e.successors(t)[0],e.removeNode(t),r.points.push({x:o.x,y:o.y}),"edge-label"===o.dummy&&(r.x=o.x,r.y=o.y,r.width=o.width,r.height=o.height),t=n,o=e.node(t)}))}};const{applyWithChunking:DI}=yI;var _I={longestPath:function(e){var t={};e.sources().forEach((function n(o){var r=e.node(o);if(Object.hasOwn(t,o))return r.rank;t[o]=!0;let a=e.outEdges(o).map((t=>null==t?Number.POSITIVE_INFINITY:n(t.w)-e.edge(t).minlen));var s=DI(Math.min,a);return s===Number.POSITIVE_INFINITY&&(s=0),r.rank=s}))},slack:function(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}};var PI=cI.Graph,RI=_I.slack,FI=function(e){var t,n,o=new PI({directed:!1}),r=e.nodes()[0],a=e.nodeCount();o.setNode(r,{});for(;LI(o,e)<a;)t=zI(o,e),n=o.hasNode(t.v)?RI(e,t):-RI(e,t),BI(o,e,n);return o};function LI(e,t){return e.nodes().forEach((function n(o){t.nodeEdges(o).forEach((r=>{var a=r.v,s=o===a?r.w:a;e.hasNode(s)||RI(t,r)||(e.setNode(s,{}),e.setEdge(o,s,{}),n(s))}))})),e.nodeCount()}function zI(e,t){return t.edges().reduce(((n,o)=>{let r=Number.POSITIVE_INFINITY;return e.hasNode(o.v)!==e.hasNode(o.w)&&(r=RI(t,o)),r<n[0]?[r,o]:n}),[Number.POSITIVE_INFINITY,null])[1]}function BI(e,t,n){e.nodes().forEach((e=>t.node(e).rank+=n))}var UI=FI,VI=_I.slack,$I=_I.longestPath,GI=cI.alg.preorder,HI=cI.alg.postorder,WI=yI.simplify,qI=YI;function YI(e){e=WI(e),$I(e);var t,n=UI(e);for(XI(n),JI(n,e);t=QI(n);)tA(n,e,t,eA(n,e,t))}function JI(e,t){var n=HI(e,e.nodes());(n=n.slice(0,n.length-1)).forEach((n=>function(e,t,n){var o=e.node(n),r=o.parent;e.edge(n,r).cutvalue=KI(e,t,n)}(e,t,n)))}function KI(e,t,n){var o=e.node(n).parent,r=!0,a=t.edge(n,o),s=0;return a||(r=!1,a=t.edge(o,n)),s=a.weight,t.nodeEdges(n).forEach((a=>{var i,l,c=a.v===n,d=c?a.w:a.v;if(d!==o){var u=c===r,h=t.edge(a).weight;if(s+=u?h:-h,i=n,l=d,e.hasEdge(i,l)){var f=e.edge(n,d).cutvalue;s+=u?-f:f}}})),s}function XI(e,t){arguments.length<2&&(t=e.nodes()[0]),ZI(e,{},1,t)}function ZI(e,t,n,o,r){var a=n,s=e.node(o);return t[o]=!0,e.neighbors(o).forEach((r=>{Object.hasOwn(t,r)||(n=ZI(e,t,n,r,o))})),s.low=a,s.lim=n++,r?s.parent=r:delete s.parent,n}function QI(e){return e.edges().find((t=>e.edge(t).cutvalue<0))}function eA(e,t,n){var o=n.v,r=n.w;t.hasEdge(o,r)||(o=n.w,r=n.v);var a=e.node(o),s=e.node(r),i=a,l=!1;return a.lim>s.lim&&(i=s,l=!0),t.edges().filter((t=>l===nA(e,e.node(t.v),i)&&l!==nA(e,e.node(t.w),i))).reduce(((e,n)=>VI(t,n)<VI(t,e)?n:e))}function tA(e,t,n,o){var r=n.v,a=n.w;e.removeEdge(r,a),e.setEdge(o.v,o.w,{}),XI(e),JI(e,t),function(e,t){var n=e.nodes().find((e=>!t.node(e).parent)),o=GI(e,n);(o=o.slice(1)).forEach((n=>{var o=e.node(n).parent,r=t.edge(n,o),a=!1;r||(r=t.edge(o,n),a=!0),t.node(n).rank=t.node(o).rank+(a?r.minlen:-r.minlen)}))}(e,t)}function nA(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}YI.initLowLimValues=XI,YI.initCutValues=JI,YI.calcCutValue=KI,YI.leaveEdge=QI,YI.enterEdge=eA,YI.exchangeEdges=tA;var oA=_I.longestPath,rA=FI,aA=qI,sA=function(e){switch(e.graph().ranker){case"network-simplex":default:lA(e);break;case"tight-tree":!function(e){oA(e),rA(e)}(e);break;case"longest-path":iA(e)}};var iA=oA;function lA(e){aA(e)}let cA=yI;function dA(e,t,n,o,r,a,s){let i=e.children(s);if(!i.length)return void(s!==t&&e.setEdge(t,s,{weight:0,minlen:n}));let l=cA.addBorderNode(e,"_bt"),c=cA.addBorderNode(e,"_bb"),d=e.node(s);e.setParent(l,s),d.borderTop=l,e.setParent(c,s),d.borderBottom=c,i.forEach((i=>{dA(e,t,n,o,r,a,i);let d=e.node(i),u=d.borderTop?d.borderTop:i,h=d.borderBottom?d.borderBottom:i,f=d.borderTop?o:2*o,m=u!==h?1:r-a[s]+1;e.setEdge(l,u,{weight:f,minlen:m,nestingEdge:!0}),e.setEdge(h,c,{weight:f,minlen:m,nestingEdge:!0})})),e.parent(s)||e.setEdge(t,l,{weight:0,minlen:r+a[s]})}let uA=yI;function hA(e,t,n,o,r,a){let s={width:0,height:0,rank:a,borderType:t},i=r[t][a-1],l=uA.addDummyNode(e,"border",s,n);r[t][a]=l,e.setParent(l,o),i&&e.setEdge(i,l,{weight:1})}function fA(e){e.nodes().forEach((t=>mA(e.node(t)))),e.edges().forEach((t=>mA(e.edge(t))))}function mA(e){let t=e.width;e.width=e.height,e.height=t}function pA(e){e.y=-e.y}function gA(e){let t=e.x;e.x=e.y,e.y=t}let vA=yI;let xA=yI.zipObject;function yA(e,t,n){let o=xA(n,n.map(((e,t)=>t))),r=t.flatMap((t=>e.outEdges(t).map((t=>({pos:o[t.w],weight:e.edge(t).weight}))).sort(((e,t)=>e.pos-t.pos)))),a=1;for(;a<n.length;)a<<=1;let s=2*a-1;a-=1;let i=new Array(s).fill(0),l=0;return r.forEach((e=>{let t=e.pos+a;i[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=i[t+1]),t=t-1>>1,i[t]+=e.weight;l+=e.weight*n})),l}let bA=yI;let wA=yI;function kA(e,t,n){let o;for(;t.length&&(o=t[t.length-1]).i<=n;)t.pop(),e.push(o.vs),n++;return n}let NA=function(e,t=[]){return t.map((t=>{let n=e.inEdges(t);if(n.length){let o=n.reduce(((t,n)=>{let o=e.edge(n),r=e.node(n.v);return{sum:t.sum+o.weight*r.order,weight:t.weight+o.weight}}),{sum:0,weight:0});return{v:t,barycenter:o.sum/o.weight,weight:o.weight}}return{v:t}}))},EA=function(e,t){let n={};return e.forEach(((e,t)=>{let o=n[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};void 0!==e.barycenter&&(o.barycenter=e.barycenter,o.weight=e.weight)})),t.edges().forEach((e=>{let t=n[e.v],o=n[e.w];void 0!==t&&void 0!==o&&(o.indegree++,t.out.push(n[e.w]))})),function(e){let t=[];function n(e){return t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&function(e,t){let n=0,o=0;e.weight&&(n+=e.barycenter*e.weight,o+=e.weight);t.weight&&(n+=t.barycenter*t.weight,o+=t.weight);e.vs=t.vs.concat(e.vs),e.barycenter=n/o,e.weight=o,e.i=Math.min(t.i,e.i),t.merged=!0}(e,t)}}function o(t){return n=>{n.in.push(t),0==--n.indegree&&e.push(n)}}for(;e.length;){let r=e.pop();t.push(r),r.in.reverse().forEach(n(r)),r.out.forEach(o(r))}return t.filter((e=>!e.merged)).map((e=>bA.pick(e,["vs","i","barycenter","weight"])))}(Object.values(n).filter((e=>!e.indegree)))},CA=function(e,t){let n=wA.partition(e,(e=>Object.hasOwn(e,"barycenter"))),o=n.lhs,r=n.rhs.sort(((e,t)=>t.i-e.i)),a=[],s=0,i=0,l=0;o.sort((c=!!t,(e,t)=>e.barycenter<t.barycenter?-1:e.barycenter>t.barycenter?1:c?t.i-e.i:e.i-t.i)),l=kA(a,r,l),o.forEach((e=>{l+=e.vs.length,a.push(e.vs),s+=e.barycenter*e.weight,i+=e.weight,l=kA(a,r,l)}));var c;let d={vs:a.flat(!0)};i&&(d.barycenter=s/i,d.weight=i);return d};var jA=function e(t,n,o,r){let a=t.children(n),s=t.node(n),i=s?s.borderLeft:void 0,l=s?s.borderRight:void 0,c={};i&&(a=a.filter((e=>e!==i&&e!==l)));let d=NA(t,a);d.forEach((n=>{if(t.children(n.v).length){let i=e(t,n.v,o,r);c[n.v]=i,Object.hasOwn(i,"barycenter")&&(s=i,void 0!==(a=n).barycenter?(a.barycenter=(a.barycenter*a.weight+s.barycenter*s.weight)/(a.weight+s.weight),a.weight+=s.weight):(a.barycenter=s.barycenter,a.weight=s.weight))}var a,s}));let u=EA(d,o);!function(e,t){e.forEach((e=>{e.vs=e.vs.flatMap((e=>t[e]?t[e].vs:e))}))}(u,c);let h=CA(u,r);if(i&&(h.vs=[i,h.vs,l].flat(!0),t.predecessors(i).length)){let e=t.node(t.predecessors(i)[0]),n=t.node(t.predecessors(l)[0]);Object.hasOwn(h,"barycenter")||(h.barycenter=0,h.weight=0),h.barycenter=(h.barycenter*h.weight+e.order+n.order)/(h.weight+2),h.weight+=2}return h};let SA=cI.Graph,IA=yI;let AA=function(e){let t={},n=e.nodes().filter((t=>!e.children(t).length)),o=n.map((t=>e.node(t).rank)),r=vA.applyWithChunking(Math.max,o),a=vA.range(r+1).map((()=>[]));return n.sort(((t,n)=>e.node(t).rank-e.node(n).rank)).forEach((function n(o){if(t[o])return;t[o]=!0;let r=e.node(o);a[r.rank].push(o),e.successors(o).forEach(n)})),a},MA=function(e,t){let n=0;for(let o=1;o<t.length;++o)n+=yA(e,t[o-1],t[o]);return n},TA=jA,OA=function(e,t,n){let o=function(e){var t;for(;e.hasNode(t=IA.uniqueId("_root")););return t}(e),r=new SA({compound:!0}).setGraph({root:o}).setDefaultNodeLabel((t=>e.node(t)));return e.nodes().forEach((a=>{let s=e.node(a),i=e.parent(a);(s.rank===t||s.minRank<=t&&t<=s.maxRank)&&(r.setNode(a),r.setParent(a,i||o),e[n](a).forEach((t=>{let n=t.v===a?t.w:t.v,o=r.edge(n,a),s=void 0!==o?o.weight:0;r.setEdge(n,a,{weight:e.edge(t).weight+s})})),Object.hasOwn(s,"minRank")&&r.setNode(a,{borderLeft:s.borderLeft[t],borderRight:s.borderRight[t]}))})),r},DA=function(e,t,n){let o,r={};n.forEach((n=>{let a,s,i=e.parent(n);for(;i;){if(a=e.parent(i),a?(s=r[a],r[a]=i):(s=o,o=i),s&&s!==i)return void t.setEdge(s,i);i=a}}))},_A=cI.Graph,PA=yI;var RA=function e(t,n){if(n&&"function"==typeof n.customOrder)return void n.customOrder(t,e);let o=PA.maxRank(t),r=FA(t,PA.range(1,o+1),"inEdges"),a=FA(t,PA.range(o-1,-1,-1),"outEdges"),s=AA(t);if(zA(t,s),n&&n.disableOptimalOrderHeuristic)return;let i,l=Number.POSITIVE_INFINITY;for(let c=0,d=0;d<4;++c,++d){LA(c%2?r:a,c%4>=2),s=PA.buildLayerMatrix(t);let e=MA(t,s);e<l&&(d=0,i=Object.assign({},s),l=e)}zA(t,i)};function FA(e,t,n){return t.map((function(t){return OA(e,t,n)}))}function LA(e,t){let n=new _A;e.forEach((function(e){let o=e.graph().root,r=TA(e,o,n,t);r.vs.forEach(((t,n)=>e.node(t).order=n)),DA(e,n,r.vs)}))}function zA(e,t){Object.values(t).forEach((t=>t.forEach(((t,n)=>e.node(t).order=n))))}let BA=cI.Graph,UA=yI;var VA=function(e){let t,n=UA.buildLayerMatrix(e),o=Object.assign($A(e,n),GA(e,n)),r={};["u","d"].forEach((a=>{t="u"===a?n:Object.values(n).reverse(),["l","r"].forEach((n=>{"r"===n&&(t=t.map((e=>Object.values(e).reverse())));let s=("u"===a?e.predecessors:e.successors).bind(e),i=qA(e,t,o,s),l=YA(e,t,i.root,i.align,"r"===n);"r"===n&&(l=UA.mapValues(l,(e=>-e))),r[a+n]=l}))}));let a=JA(e,r);return KA(r,a),XA(r,e.graph().align)};function $A(e,t){let n={};return t.length&&t.reduce((function(t,o){let r=0,a=0,s=t.length,i=o[o.length-1];return o.forEach(((t,l)=>{let c=function(e,t){if(e.node(t).dummy)return e.predecessors(t).find((t=>e.node(t).dummy))}(e,t),d=c?e.node(c).order:s;(c||t===i)&&(o.slice(a,l+1).forEach((t=>{e.predecessors(t).forEach((o=>{let a=e.node(o),s=a.order;!(s<r||d<s)||a.dummy&&e.node(t).dummy||HA(n,o,t)}))})),a=l+1,r=d)})),o})),n}function GA(e,t){let n={};function o(t,o,r,a,s){let i;UA.range(o,r).forEach((o=>{i=t[o],e.node(i).dummy&&e.predecessors(i).forEach((t=>{let o=e.node(t);o.dummy&&(o.order<a||o.order>s)&&HA(n,t,i)}))}))}return t.length&&t.reduce((function(t,n){let r,a=-1,s=0;return n.forEach(((i,l)=>{if("border"===e.node(i).dummy){let t=e.predecessors(i);t.length&&(r=e.node(t[0]).order,o(n,s,l,a,r),s=l,a=r)}o(n,s,n.length,r,t.length)})),n})),n}function HA(e,t,n){if(t>n){let e=t;t=n,n=e}let o=e[t];o||(e[t]=o={}),o[n]=!0}function WA(e,t,n){if(t>n){let e=t;t=n,n=e}return!!e[t]&&Object.hasOwn(e[t],n)}function qA(e,t,n,o){let r={},a={},s={};return t.forEach((e=>{e.forEach(((e,t)=>{r[e]=e,a[e]=e,s[e]=t}))})),t.forEach((e=>{let t=-1;e.forEach((e=>{let i=o(e);if(i.length){i=i.sort(((e,t)=>s[e]-s[t]));let o=(i.length-1)/2;for(let l=Math.floor(o),c=Math.ceil(o);l<=c;++l){let o=i[l];a[e]===e&&t<s[o]&&!WA(n,e,o)&&(a[o]=e,a[e]=r[e]=r[o],t=s[o])}}}))})),{root:r,align:a}}function YA(e,t,n,o,r){let a={},s=function(e,t,n,o){let r=new BA,a=e.graph(),s=function(e,t,n){return(o,r,a)=>{let s,i=o.node(r),l=o.node(a),c=0;if(c+=i.width/2,Object.hasOwn(i,"labelpos"))switch(i.labelpos.toLowerCase()){case"l":s=-i.width/2;break;case"r":s=i.width/2}if(s&&(c+=n?s:-s),s=0,c+=(i.dummy?t:e)/2,c+=(l.dummy?t:e)/2,c+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":s=l.width/2;break;case"r":s=-l.width/2}return s&&(c+=n?s:-s),s=0,c}}(a.nodesep,a.edgesep,o);return t.forEach((t=>{let o;t.forEach((t=>{let a=n[t];if(r.setNode(a),o){var i=n[o],l=r.edge(i,a);r.setEdge(i,a,Math.max(s(e,t,o),l||0))}o=t}))})),r}(e,t,n,r),i=r?"borderLeft":"borderRight";function l(e,t){let n=s.nodes(),o=n.pop(),r={};for(;o;)r[o]?e(o):(r[o]=!0,n.push(o),n=n.concat(t(o))),o=n.pop()}return l((function(e){a[e]=s.inEdges(e).reduce(((e,t)=>Math.max(e,a[t.v]+s.edge(t))),0)}),s.predecessors.bind(s)),l((function(t){let n=s.outEdges(t).reduce(((e,t)=>Math.min(e,a[t.w]-s.edge(t))),Number.POSITIVE_INFINITY),o=e.node(t);n!==Number.POSITIVE_INFINITY&&o.borderType!==i&&(a[t]=Math.max(a[t],n))}),s.successors.bind(s)),Object.keys(o).forEach((e=>a[e]=a[n[e]])),a}function JA(e,t){return Object.values(t).reduce(((t,n)=>{let o=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;Object.entries(n).forEach((([t,n])=>{let a=function(e,t){return e.node(t).width}(e,t)/2;o=Math.max(n+a,o),r=Math.min(n-a,r)}));const a=o-r;return a<t[0]&&(t=[a,n]),t}),[Number.POSITIVE_INFINITY,null])[1]}function KA(e,t){let n=Object.values(t),o=UA.applyWithChunking(Math.min,n),r=UA.applyWithChunking(Math.max,n);["u","d"].forEach((n=>{["l","r"].forEach((a=>{let s=n+a,i=e[s];if(i===t)return;let l=Object.values(i),c=o-UA.applyWithChunking(Math.min,l);"l"!==a&&(c=r-UA.applyWithChunking(Math.max,l)),c&&(e[s]=UA.mapValues(i,(e=>e+c)))}))}))}function XA(e,t){return UA.mapValues(e.ul,((n,o)=>{if(t)return e[t.toLowerCase()][o];{let t=Object.values(e).map((e=>e[o])).sort(((e,t)=>e-t));return(t[1]+t[2])/2}}))}let ZA=yI,QA=VA;let eM=MI,tM=OI,nM=sA,oM=yI.normalizeRanks,rM=function(e){let t=function(e){let t={},n=0;function o(r){let a=n;e.children(r).forEach(o),t[r]={low:a,lim:n++}}return e.children().forEach(o),t}(e);e.graph().dummyChains.forEach((n=>{let o=e.node(n),r=o.edgeObj,a=function(e,t,n,o){let r,a,s=[],i=[],l=Math.min(t[n].low,t[o].low),c=Math.max(t[n].lim,t[o].lim);r=n;do{r=e.parent(r),s.push(r)}while(r&&(t[r].low>l||c>t[r].lim));a=r,r=o;for(;(r=e.parent(r))!==a;)i.push(r);return{path:s.concat(i.reverse()),lca:a}}(e,t,r.v,r.w),s=a.path,i=a.lca,l=0,c=s[l],d=!0;for(;n!==r.w;){if(o=e.node(n),d){for(;(c=s[l])!==i&&e.node(c).maxRank<o.rank;)l++;c===i&&(d=!1)}if(!d){for(;l<s.length-1&&e.node(c=s[l+1]).minRank<=o.rank;)l++;c=s[l]}e.setParent(n,c),n=e.successors(n)[0]}}))},aM=yI.removeEmptyRanks,sM={run:function(e){let t=cA.addDummyNode(e,"root",{},"_root"),n=function(e){var t={};function n(o,r){var a=e.children(o);a&&a.length&&a.forEach((e=>n(e,r+1))),t[o]=r}return e.children().forEach((e=>n(e,1))),t}(e),o=Object.values(n),r=cA.applyWithChunking(Math.max,o)-1,a=2*r+1;e.graph().nestingRoot=t,e.edges().forEach((t=>e.edge(t).minlen*=a));let s=function(e){return e.edges().reduce(((t,n)=>t+e.edge(n).weight),0)}(e)+1;e.children().forEach((o=>dA(e,t,a,s,r,n,o))),e.graph().nodeRankFactor=a},cleanup:function(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach((t=>{e.edge(t).nestingEdge&&e.removeEdge(t)}))}},iM=function(e){e.children().forEach((function t(n){let o=e.children(n),r=e.node(n);if(o.length&&o.forEach(t),Object.hasOwn(r,"minRank")){r.borderLeft=[],r.borderRight=[];for(let t=r.minRank,o=r.maxRank+1;t<o;++t)hA(e,"borderLeft","_bl",n,r,t),hA(e,"borderRight","_br",n,r,t)}}))},lM={adjust:function(e){let t=e.graph().rankdir.toLowerCase();"lr"!==t&&"rl"!==t||fA(e)},undo:function(e){let t=e.graph().rankdir.toLowerCase();"bt"!==t&&"rl"!==t||function(e){e.nodes().forEach((t=>pA(e.node(t)))),e.edges().forEach((t=>{let n=e.edge(t);n.points.forEach(pA),Object.hasOwn(n,"y")&&pA(n)}))}(e);"lr"!==t&&"rl"!==t||(!function(e){e.nodes().forEach((t=>gA(e.node(t)))),e.edges().forEach((t=>{let n=e.edge(t);n.points.forEach(gA),Object.hasOwn(n,"x")&&gA(n)}))}(e),fA(e))}},cM=RA,dM=function(e){(function(e){let t=ZA.buildLayerMatrix(e),n=e.graph().ranksep,o=0;t.forEach((t=>{const r=t.reduce(((t,n)=>{const o=e.node(n).height;return t>o?t:o}),0);t.forEach((t=>e.node(t).y=o+r/2)),o+=r+n}))})(e=ZA.asNonCompoundGraph(e)),Object.entries(QA(e)).forEach((([t,n])=>e.node(t).x=n))},uM=yI,hM=cI.Graph;var fM=function(e,t){let n=t&&t.debugTiming?uM.time:uM.notime;n("layout",(()=>{let o=n(" buildLayoutGraph",(()=>function(e){let t=new hM({multigraph:!0,compound:!0}),n=NM(e.graph());return t.setGraph(Object.assign({},pM,kM(n,mM),uM.pick(n,gM))),e.nodes().forEach((n=>{const o=kM(NM(e.node(n)),vM);Object.keys(xM).forEach((e=>{void 0===o[e]&&(o[e]=xM[e])})),t.setNode(n,o),t.setParent(n,e.parent(n))})),e.edges().forEach((n=>{let o=NM(e.edge(n));t.setEdge(n,Object.assign({},bM,kM(o,yM),uM.pick(o,wM)))})),t}(e)));n(" runLayout",(()=>function(e,t,n){t(" makeSpaceForEdgeLabels",(()=>function(e){let t=e.graph();t.ranksep/=2,e.edges().forEach((n=>{let o=e.edge(n);o.minlen*=2,"c"!==o.labelpos.toLowerCase()&&("TB"===t.rankdir||"BT"===t.rankdir?o.width+=o.labeloffset:o.height+=o.labeloffset)}))}(e))),t(" removeSelfEdges",(()=>function(e){e.edges().forEach((t=>{if(t.v===t.w){var n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}}))}(e))),t(" acyclic",(()=>eM.run(e))),t(" nestingGraph.run",(()=>sM.run(e))),t(" rank",(()=>nM(uM.asNonCompoundGraph(e)))),t(" injectEdgeLabelProxies",(()=>function(e){e.edges().forEach((t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v),o={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};uM.addDummyNode(e,"edge-proxy",o,"_ep")}}))}(e))),t(" removeEmptyRanks",(()=>aM(e))),t(" nestingGraph.cleanup",(()=>sM.cleanup(e))),t(" normalizeRanks",(()=>oM(e))),t(" assignRankMinMax",(()=>function(e){let t=0;e.nodes().forEach((n=>{let o=e.node(n);o.borderTop&&(o.minRank=e.node(o.borderTop).rank,o.maxRank=e.node(o.borderBottom).rank,t=Math.max(t,o.maxRank))})),e.graph().maxRank=t}(e))),t(" removeEdgeLabelProxies",(()=>function(e){e.nodes().forEach((t=>{let n=e.node(t);"edge-proxy"===n.dummy&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))}))}(e))),t(" normalize.run",(()=>tM.run(e))),t(" parentDummyChains",(()=>rM(e))),t(" addBorderSegments",(()=>iM(e))),t(" order",(()=>cM(e,n))),t(" insertSelfEdges",(()=>function(e){var t=uM.buildLayerMatrix(e);t.forEach((t=>{var n=0;t.forEach(((t,o)=>{var r=e.node(t);r.order=o+n,(r.selfEdges||[]).forEach((t=>{uM.addDummyNode(e,"selfedge",{width:t.label.width,height:t.label.height,rank:r.rank,order:o+ ++n,e:t.e,label:t.label},"_se")})),delete r.selfEdges}))}))}(e))),t(" adjustCoordinateSystem",(()=>lM.adjust(e))),t(" position",(()=>dM(e))),t(" positionSelfEdges",(()=>function(e){e.nodes().forEach((t=>{var n=e.node(t);if("selfedge"===n.dummy){var o=e.node(n.e.v),r=o.x+o.width/2,a=o.y,s=n.x-r,i=o.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:r+2*s/3,y:a-i},{x:r+5*s/6,y:a-i},{x:r+s,y:a},{x:r+5*s/6,y:a+i},{x:r+2*s/3,y:a+i}],n.label.x=n.x,n.label.y=n.y}}))}(e))),t(" removeBorderNodes",(()=>function(e){e.nodes().forEach((t=>{if(e.children(t).length){let n=e.node(t),o=e.node(n.borderTop),r=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),s=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(s.x-a.x),n.height=Math.abs(r.y-o.y),n.x=a.x+n.width/2,n.y=o.y+n.height/2}})),e.nodes().forEach((t=>{"border"===e.node(t).dummy&&e.removeNode(t)}))}(e))),t(" normalize.undo",(()=>tM.undo(e))),t(" fixupEdgeLabelCoords",(()=>function(e){e.edges().forEach((t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch("l"!==n.labelpos&&"r"!==n.labelpos||(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset}}))}(e))),t(" undoCoordinateSystem",(()=>lM.undo(e))),t(" translateGraph",(()=>function(e){let t=Number.POSITIVE_INFINITY,n=0,o=Number.POSITIVE_INFINITY,r=0,a=e.graph(),s=a.marginx||0,i=a.marginy||0;function l(e){let a=e.x,s=e.y,i=e.width,l=e.height;t=Math.min(t,a-i/2),n=Math.max(n,a+i/2),o=Math.min(o,s-l/2),r=Math.max(r,s+l/2)}e.nodes().forEach((t=>l(e.node(t)))),e.edges().forEach((t=>{let n=e.edge(t);Object.hasOwn(n,"x")&&l(n)})),t-=s,o-=i,e.nodes().forEach((n=>{let r=e.node(n);r.x-=t,r.y-=o})),e.edges().forEach((n=>{let r=e.edge(n);r.points.forEach((e=>{e.x-=t,e.y-=o})),Object.hasOwn(r,"x")&&(r.x-=t),Object.hasOwn(r,"y")&&(r.y-=o)})),a.width=n-t+s,a.height=r-o+i}(e))),t(" assignNodeIntersects",(()=>function(e){e.edges().forEach((t=>{let n,o,r=e.edge(t),a=e.node(t.v),s=e.node(t.w);r.points?(n=r.points[0],o=r.points[r.points.length-1]):(r.points=[],n=s,o=a),r.points.unshift(uM.intersectRect(a,n)),r.points.push(uM.intersectRect(s,o))}))}(e))),t(" reversePoints",(()=>function(e){e.edges().forEach((t=>{let n=e.edge(t);n.reversed&&n.points.reverse()}))}(e))),t(" acyclic.undo",(()=>eM.undo(e)))}(o,n,t))),n(" updateInputGraph",(()=>function(e,t){e.nodes().forEach((n=>{let o=e.node(n),r=t.node(n);o&&(o.x=r.x,o.y=r.y,o.rank=r.rank,t.children(n).length&&(o.width=r.width,o.height=r.height))})),e.edges().forEach((n=>{let o=e.edge(n),r=t.edge(n);o.points=r.points,Object.hasOwn(r,"x")&&(o.x=r.x,o.y=r.y)})),e.graph().width=t.graph().width,e.graph().height=t.graph().height}(e,o)))}))};let mM=["nodesep","edgesep","ranksep","marginx","marginy"],pM={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},gM=["acyclicer","ranker","rankdir","align"],vM=["width","height"],xM={width:0,height:0},yM=["minlen","weight","width","height","labeloffset"],bM={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},wM=["labelpos"];function kM(e,t){return uM.mapValues(uM.pick(e,t),Number)}function NM(e){var t={};return e&&Object.entries(e).forEach((([e,n])=>{"string"==typeof e&&(e=e.toLowerCase()),t[e]=n})),t}let EM=yI,CM=cI.Graph;var jM={graphlib:cI,layout:fM,debug:{debugOrdering:function(e){let t=EM.buildLayerMatrix(e),n=new CM({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach((t=>{n.setNode(t,{label:t}),n.setParent(t,"layer"+e.node(t).rank)})),e.edges().forEach((e=>n.setEdge(e.v,e.w,{},e.name))),t.forEach(((e,t)=>{let o="layer"+t;n.setNode(o,{rank:"same"}),e.reduce(((e,t)=>(n.setEdge(e,t,{style:"invis"}),t)))})),n}},util:{time:yI.time,notime:yI.notime},version:"1.1.4"};const SM=(new jM.graphlib.Graph).setDefaultEdgeLabel((()=>({}))),IM=(e,t,n)=>(SM.setGraph({rankdir:n.direction,nodesep:150,ranksep:200,ranker:"longest-path"}),t.forEach((e=>SM.setEdge(e.source,e.target))),e.forEach((e=>SM.setNode(e.id,{...e,width:e.width??0,height:e.height??0}))),jM.layout(SM),{nodes:e.map((e=>{const{x:t,y:n}=SM.node(e.id);return{...e,position:{x:t,y:n}}})),edges:t}),AM=new class{createEdge(e,t){return{animated:!0,markerEnd:{type:ZN.ArrowClosed},id:`${e}-${t}`,style:{strokeWidth:2},source:e,sourceHandle:"outputs",targetHandle:"inputs",target:t}}createNode(e,t){return{id:e,data:{atom:t,forceWidth:300},width:300,type:"custom",height:vS(G.get(t).code.trim().split("\n").length),position:{x:0,y:0}}}createElements(e,t,n,o){const r=[],a=[],s=new Set,i=new Set;for(const l of Object.values(n)){if("marimo"===l.value&&"mo"===l.name)continue;const{declaredBy:e,usedBy:t}=l;for(const n of e)for(const e of t){const t=`${n}-${e}`;i.has(t)||(i.add(t),s.add(n),s.add(e),a.push(this.createEdge(n,e)))}}for(const[l,c]of Gr.zip(e,t)){o||r.push(this.createNode(l,c));const e=s.has(l),t=G.get(c).code.trim().startsWith("mo.md");!e&&t||r.push(this.createNode(l,c))}return{nodes:r,edges:a}}},MM=({cellIds:e,variables:t,cellAtoms:n,children:o,layoutDirection:a,settings:s})=>{const i=r.useMemo((()=>{let o=AM.createElements(e,n,t,s.hidePureMarkdown);return o=IM(o.nodes,o.edges,{direction:a}),o}),[]),[l,c,d]=Xj(i.nodes),[u,h,f]=Zj(i.edges),g=NC(),v=R((e=>{const t=IM(e.nodes,e.edges,{direction:a});c(t.nodes),h(t.edges)}));r.useEffect((()=>{v(AM.createElements(e,n,t,s.hidePureMarkdown))}),[e,t,n,v,s.hidePureMarkdown]);const[x,y]=r.useState();return CS(),m.jsx(xS.Provider,{value:a,children:m.jsxs(Jj,{nodes:l,edges:u,nodeTypes:bS,minZoom:.2,fitViewOptions:{minZoom:.5,maxZoom:1.5},onNodeClick:(e,t)=>{y({type:"node",id:t.id})},onEdgeClick:(e,t)=>{const{source:n,target:o}=t;y({type:"edge",source:n,target:o})},onNodeDoubleClick:(e,t)=>{Oa(t.id,"focus")},fitView:!0,onNodesChange:d,onEdgesChange:f,zoomOnDoubleClick:!1,nodesConnectable:!1,children:[m.jsx(gS,{color:"#ccc",variant:iS.Dots}),m.jsx(cS,{position:"bottom-right",showInteractive:!1,children:m.jsx(p,{content:"Jump to focused cell",usePortal:!1,delayDuration:200,side:"left",asChild:!1,children:m.jsx(rS,{onMouseDown:$e.preventFocus,onClick:()=>{const e=G.get(rd);if(e){const t=l.find((t=>t.id===e));t&&(g.fitView({padding:1,duration:600,nodes:[t]}),y({type:"node",id:e}))}},children:m.jsx(ec,{className:"size-4"})})})}),m.jsx(ES,{selection:x,variables:t,edges:u}),o]})})},TM=V("_minimap_"),OM=V({hidePureMarkdown:!0}),DM=e=>{const[t,n]=je(TM),[o,r]=je(OM);return m.jsx(Uj,{children:"_minimap_"===t?m.jsx(SS,{...e,children:m.jsx(NS,{settings:o,onSettingsChange:r,view:t,onChange:n})}):m.jsx(MM,{...e,settings:o,layoutDirection:t,children:m.jsx(NS,{settings:o,onSettingsChange:r,view:t,onChange:n})})},t)},_M=()=>{const e=Da(),t=te(),[n]=_a();return m.jsx("div",{className:$t("w-full h-full flex-1 mx-auto -mb-4 relative"),children:m.jsx(DM,{cellAtoms:n,variables:e,cellIds:t.inOrderIds})})};const PM="name",RM="type-value",FM="defs-refs",LM=[{id:PM,accessorFn:e=>[e.name,e.declaredBy],enableSorting:!0,sortingFn:"alphanumeric",header:({column:e})=>m.jsx(Ja,{header:"Name",column:e}),cell:({getValue:e})=>{const[t,n]=e();return m.jsx(kS,{name:t,declaredBy:n})}},{id:RM,accessorFn:e=>[e.dataType,e.value],enableSorting:!0,sortingFn:"alphanumeric",header:({column:e})=>m.jsx(Ja,{header:m.jsxs("div",{className:"flex flex-col gap-1",children:[m.jsx("span",{children:"Type"}),m.jsx("span",{children:"Value"})]}),column:e}),cell:({getValue:e})=>{const[t,n]=e();return m.jsxs("div",{className:"max-w-[150px]",children:[m.jsx("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap text-muted-foreground font-mono text-xs",children:t}),m.jsx("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap",title:n??"",children:n})]})}},{id:FM,accessorFn:e=>[e.declaredBy,e.usedBy,e.name,e.declaredByNames,e.usedByNames],enableSorting:!0,sortingFn:"basic",header:({column:e})=>m.jsx(Ja,{header:m.jsxs("div",{className:"flex flex-col gap-1",children:[m.jsx("span",{children:"Declared By"}),m.jsx("span",{children:"Used By"})]}),column:e}),cell:({getValue:e})=>{const[t,n,o]=e(),r=e=>{const t=lr(e);t&&Ma(t,o)};return m.jsxs("div",{className:"flex flex-col gap-1 py-1",children:[m.jsxs("div",{className:"flex flex-row overflow-auto gap-2 items-center",children:[m.jsx("span",{title:"Declared by",children:m.jsx(Nc,{className:"w-3.5 h-3.5 text-muted-foreground"})}),1===t.length?m.jsx(Ia,{variant:"focus",cellId:t[0],skipScroll:!0,onClick:()=>r(t[0])}):m.jsx("div",{className:"text-destructive flex flex-row gap-2",children:t.slice(0,3).map(((e,n)=>m.jsxs("span",{className:"flex",children:[m.jsx(Ia,{variant:"focus",cellId:e,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>r(e)},e),n<t.length-1&&", "]},e)))})]}),m.jsxs("div",{className:"flex flex-row overflow-auto gap-2 items-baseline",children:[m.jsx("span",{title:"Used by",children:m.jsx(_c,{className:"w-3.5 h-3.5 text-muted-foreground"})}),m.jsx(wS,{maxCount:3,cellIds:n,skipScroll:!0,onClick:r})]})]})}}];const zM=r.memo((({className:e,cellIds:t,variables:n})=>{const[o,a]=u.useState([]),[s,i]=u.useState(""),l=Pa(),c=r.useMemo((()=>{const e=e=>{const n=l[e];return n===Ya?`cell-${t.indexOf(e)}`:n??`cell-${t.indexOf(e)}`};return Object.values(n).map((t=>({...t,declaredByNames:t.declaredBy.map(e),usedByNames:t.usedBy.map(e)})))}),[n,l,t]),d=r.useMemo((()=>{const e=new Map;return t.forEach(((t,n)=>e.set(t,n))),function(e,t,n){t||(t={id:FM,desc:!1});let o=[];switch(t.id){case PM:o=wl(e,(e=>e.name));break;case RM:o=wl(e,(e=>e.dataType));break;case FM:o=wl(e,(e=>n.get(e.declaredBy[0])))}return t.desc?o.reverse():o}(c,o[0],e)}),[c,o,t]),h=Ra({data:d,columns:LM,getCoreRowModel:Fa(),onGlobalFilterChange:i,getFilteredRowModel:La(),enableFilters:!0,enableGlobalFilter:!0,getColumnCanGlobalFilter:e=>e.columnDef.enableGlobalFilter??!0,globalFilterFn:"auto",manualSorting:!0,onSortingChange:a,getSortedRowModel:za(),state:{sorting:o,globalFilter:s}});return m.jsxs(m.Fragment,{children:[m.jsx(Ba,{className:"w-full",placeholder:"Search",value:s,onChange:e=>i(e.target.value)}),m.jsxs(Ua,{className:$t("w-full text-sm flex-1 border-separate border-spacing-0",e),children:[m.jsx(Va,{children:m.jsx($a,{className:"whitespace-nowrap text-xs",children:h.getFlatHeaders().map((e=>m.jsx(Ga,{className:"sticky top-0 bg-background border-b",children:Ha(e.column.columnDef.header,e.getContext())},e.id)))})}),m.jsx(Wa,{children:h.getRowModel().rows.map((e=>m.jsx($a,{className:"hover:bg-accent",children:e.getVisibleCells().map((e=>m.jsx(qa,{className:"border-b",children:Ha(e.column.columnDef.cell,e.getContext())},e.id)))},e.id)))})]})]})}));zM.displayName="VariableTable";const BM=()=>{const e=Da(),t=te();return 0===Object.keys(e).length?m.jsx(Ik,{title:"No variables",description:"Global variables will appear here.",icon:m.jsx(Je,{})}):m.jsx(zM,{className:"flex-1",cellIds:t.inOrderIds,variables:e})},UM=()=>{const e=Ka(),{clearLogs:t}=L();return 0===e.length?m.jsx(Ik,{title:"No logs",description:m.jsxs("span",{children:[m.jsx("code",{className:"border rounded px-1",children:"stdout"})," and"," ",m.jsx("code",{className:"border rounded px-1",children:"stderr"})," logs will appear here."]}),icon:m.jsx(Ke,{})}):m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"flex flex-row justify-end px-2 py-1",children:m.jsx("button",{"data-testid":"clear-logs-button",className:"text-xs font-semibold text-accent-foreground",onClick:t,children:"Clear"})}),m.jsx("div",{className:"overflow-auto flex-1",children:m.jsx(VM,{logs:e,className:"min-w-[300px]"})})]})},VM=({logs:e,className:t})=>{const n="opacity-70 group-hover:bg-[var(--gray-3)] group-hover:opacity-100";return m.jsx("div",{className:$t("flex flex-col",t),children:m.jsx("pre",{className:"grid text-xs font-mono gap-1 whitespace-break-spaces font-semibold align-left",children:m.jsx("div",{className:"grid grid-cols-[30px,1fr]",style:{whiteSpace:"pre-wrap"},children:e.map(((e,t)=>m.jsxs("div",{className:"contents group",children:[m.jsx("span",{className:$t(n,"text-right col-span-1 py-1 pr-1"),children:t+1}),m.jsx("span",{className:$t(n,"px-2 flex gap-x-1.5 py-1 flex-wrap"),children:$M(e)})]},t)))})})})};function $M(e){const t=Xa(e.timestamp),n=GM[e.level],o=e.level.toUpperCase();return m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"flex-shrink-0 text-[var(--gray-10)]",children:["[",t,"]"]}),m.jsx("span",{className:$t("flex-shrink-0",n),children:o}),m.jsxs("span",{className:"flex-shrink-0 text-[var(--gray-10)]",children:["(",m.jsx(Ia,{cellId:e.cellId}),")"]}),e.message]})}const GM={stdout:"text-[var(--grass-9)]",stderr:"text-[var(--red-9)]"},HM=()=>{const{documentation:e}=X(Za);return e?m.jsx("div",{className:"p-3 overflow-y-auto overflow-x-hidden h-full docs-documentation flex flex-col gap-4",children:Or({html:e})}):m.jsx(Ik,{title:"View docs as you type",description:"Move your text cursor over a symbol to see its documentation.",icon:m.jsx(Mc,{})})};function WM(e,t,n){return e[t]?e[t][0]?e[t][0][n]:e[t][n]:"contentBoxSize"===t?e.contentRect["inlineSize"===n?"width":"height"]:void 0}function qM(e){void 0===e&&(e={});var t=e.onResize,n=r.useRef(void 0);n.current=t;var o=e.round||Math.round,a=r.useRef(),s=r.useState({width:void 0,height:void 0}),i=s[0],l=s[1],c=r.useRef(!1);r.useEffect((function(){return c.current=!1,function(){c.current=!0}}),[]);var d=r.useRef({width:void 0,height:void 0}),u=function(e,t){var n=r.useRef(null),o=r.useRef(null);o.current=t;var a=r.useRef(null);r.useEffect((function(){s()}));var s=r.useCallback((function(){var t=a.current,r=o.current,s=t||(r?r instanceof Element?r:r.current:null);n.current&&n.current.element===s&&n.current.subscriber===e||(n.current&&n.current.cleanup&&n.current.cleanup(),n.current={element:s,subscriber:e,cleanup:s?e(s):void 0})}),[e]);return r.useEffect((function(){return function(){n.current&&n.current.cleanup&&(n.current.cleanup(),n.current=null)}}),[]),r.useCallback((function(e){a.current=e,s()}),[s])}(r.useCallback((function(t){return a.current&&a.current.box===e.box&&a.current.round===o||(a.current={box:e.box,round:o,instance:new ResizeObserver((function(t){var r=t[0],a="border-box"===e.box?"borderBoxSize":"device-pixel-content-box"===e.box?"devicePixelContentBoxSize":"contentBoxSize",s=WM(r,a,"inlineSize"),i=WM(r,a,"blockSize"),u=s?o(s):void 0,h=i?o(i):void 0;if(d.current.width!==u||d.current.height!==h){var f={width:u,height:h};d.current.width=u,d.current.height=h,n.current?n.current(f):c.current||l(f)}}))}),a.current.instance.observe(t,{box:e.box}),function(){a.current&&a.current.instance.unobserve(t)}}),[e.box,o]),e.ref);return r.useMemo((function(){return{ref:u,width:i.width,height:i.height}}),[u,i.width,i.height])}const YM=new Map,JM=({file:e,onOpenNotebook:t})=>{const{theme:n}=we(),o=X(Se),[a,s]=r.useState(""),{data:i,loading:l,error:c,setData:d}=Ht((async()=>{const t=await Qa({path:e.path}),n=t.contents||"";return s(YM.get(e.path)||n),t}),[e.path]),u=async()=>{a!==(null==i?void 0:i.contents)&&await is({path:e.path,contents:a}).then((e=>{e.success&&(d((e=>e?{...e,contents:a}:void 0)),s(a))}))},h=r.useRef(a);if(h.current=a,r.useEffect((()=>()=>{if(!i)return;const t=h.current;t===i.contents?YM.delete(e.path):YM.set(e.path,t)}),[e.path,null==i?void 0:i.contents]),c)return m.jsx(es,{error:c});if(l||!i)return null;const f=i.mimeType||"text/plain",g=f in XM;if(!i.contents&&!g)return m.jsxs("div",{className:"grid grid-cols-2 gap-2 p-6",children:[m.jsx("div",{className:"font-bold text-muted-foreground",children:"Name"}),m.jsx("div",{children:i.file.name}),m.jsx("div",{className:"font-bold text-muted-foreground",children:"Type"}),m.jsx("div",{children:f})]});const v=m.jsxs("div",{className:"text-xs text-muted-foreground p-1 flex justify-end gap-2 border-b",children:[e.isMarimoFile&&!C()&&m.jsx(p,{content:"Open notebook",children:m.jsx(_s,{size:"small",onClick:e=>t(e),children:m.jsx(ts,{})})}),m.jsx(p,{content:"Download",children:m.jsx(_s,{size:"small",onClick:()=>{if(KM(f)){const e=ls(i.contents,f);cs(e,i.file.name)}else w(new Blob([i.contents||a],{type:f}),i.file.name)},children:m.jsx(dt,{})})}),!KM(f)&&m.jsxs(m.Fragment,{children:[m.jsx(p,{content:"Copy contents to clipboard",children:m.jsx(_s,{size:"small",onClick:()=>{navigator.clipboard.writeText(a)},children:m.jsx(Ve,{})})}),m.jsx(p,{content:Ds("global.save"),children:m.jsx(_s,{size:"small",color:a===i.contents?void 0:"green",onClick:u,disabled:a===i.contents,children:m.jsx(gc,{})})})]})]});return f.startsWith("image/")?m.jsxs(m.Fragment,{children:[v,m.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:m.jsx(ns,{base64:i.contents,mime:f})})]}):"text/csv"===f&&i.contents?m.jsxs(m.Fragment,{children:[v,m.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:m.jsx(os,{contents:i.contents})})]}):f.startsWith("audio/")?m.jsxs(m.Fragment,{children:[v,m.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:m.jsx(rs,{base64:i.contents,mime:f})})]}):f.startsWith("video/")?m.jsxs(m.Fragment,{children:[v,m.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:m.jsx(as,{base64:i.contents,mime:f})})]}):m.jsxs(m.Fragment,{children:[v,m.jsx("div",{className:"flex-1 overflow-auto",children:m.jsx(ss,{theme:"dark"===n?"dark":"light",language:XM[f]||XM.default,className:"border-b",extensions:[Dt.lineWrapping,Qt.of([{key:o.getHotkey("global.save").key,stopPropagation:!0,run:()=>a!==i.contents&&(u(),!0)}])],value:a,onChange:s})})]})},KM=e=>!!e&&(e.startsWith("image/")||e.startsWith("audio/")||e.startsWith("video/")),XM={"application/javascript":"javascript","text/markdown":"markdown","text/html":"html","text/css":"css","text/x-python":"python","application/json":"json","application/xml":"xml","text/x-yaml":"yaml","text/csv":"markdown","text/plain":"markdown",default:"markdown"};const ZM=V(new class{constructor(e){n(this,"delegate",new hi([])),n(this,"rootPath",""),n(this,"onChange",Gt.NOOP),n(this,"path",new tt("/")),n(this,"initialize",(async e=>{if(this.onChange=e,0===this.delegate.data.length)try{const e=await this.callbacks.listFiles({path:this.rootPath});this.delegate=new hi(e.files),this.rootPath=e.root,this.path=tt.guessDeliminator(e.root)}catch(t){q({title:"Failed",description:tr(t)})}this.onChange(this.delegate.data)})),n(this,"refreshAll",(async e=>{const t=[this.rootPath,...e.map((e=>{var t;return null==(t=this.delegate.find(e))?void 0:t.data.path}))].filter(Boolean),n=await Promise.all(t.map((e=>this.callbacks.listFiles({path:e}).catch((()=>({files:[]}))))));for(const[o,r]of t.entries()){const e=n[o];r===this.rootPath?this.delegate=new hi(e.files):this.delegate.update({id:r,changes:{children:e.files}})}this.onChange(this.delegate.data)})),n(this,"relativeFromRoot",(e=>{const t=function(e){return e.endsWith("/")?e:`${e}/`}(this.rootPath);return e.startsWith(t)?e.slice(t.length):e})),n(this,"handleResponse",(e=>e.success?e:(q({title:"Failed",description:e.message}),null))),this.callbacks=e}async expand(e){const t=this.delegate.find(e);if(!t)return!1;if(!t.data.isDirectory)return!1;if(t.children&&t.children.length>0)return!0;const n=await this.callbacks.listFiles({path:t.data.path});return this.delegate.update({id:e,changes:{children:n.files}}),this.onChange(this.delegate.data),!0}async rename(e,t){const n=this.delegate.find(e);if(!n)return;const o=n.data.path,r=this.path.join(this.path.dirname(o),t);await this.callbacks.renameFileOrFolder({path:o,newPath:r}).then(this.handleResponse),this.delegate.update({id:e,changes:{name:t,path:r}}),this.onChange(this.delegate.data),await this.refreshAll([r])}async move(e,t){var n;const o=t?(null==(n=this.delegate.find(t))?void 0:n.data.path)??t:this.rootPath;await Promise.all(e.map((e=>{this.delegate.move({id:e,parentId:t,index:0});const n=this.delegate.find(e);if(!n)return Promise.resolve();const r=this.path.join(o,this.path.basename(n.data.path));return this.delegate.update({id:e,changes:{path:r}}),this.callbacks.renameFileOrFolder({path:n.data.path,newPath:r}).then(this.handleResponse)}))),this.onChange(this.delegate.data),await this.refreshAll([o])}async createFile(e,t){var n;const o=t?(null==(n=this.delegate.find(t))?void 0:n.data.path)??t:this.rootPath,r=await this.callbacks.createFileOrFolder({path:o,type:"file",name:e}).then(this.handleResponse);(null==r?void 0:r.info)&&(this.delegate.create({parentId:t,index:0,data:r.info}),this.onChange(this.delegate.data),await this.refreshAll([o]))}async createFolder(e,t){var n;const o=t?(null==(n=this.delegate.find(t))?void 0:n.data.path)??t:this.rootPath,r=await this.callbacks.createFileOrFolder({path:o,type:"directory",name:e}).then(this.handleResponse);(null==r?void 0:r.info)&&(this.delegate.create({parentId:t,index:0,data:r.info}),this.onChange(this.delegate.data),await this.refreshAll([o]))}async delete(e){const t=this.delegate.find(e);t&&(await this.callbacks.deleteFileOrFolder({path:t.data.path}).then(this.handleResponse),this.delegate.drop({id:e}),this.onChange(this.delegate.data))}}({listFiles:Wt,createFileOrFolder:ds,deleteFileOrFolder:us,renameFileOrFolder:hs})),QM=V({});function eT(e={}){return fs({multiple:!0,maxSize:104857600,onError:e=>{U.error(e),q({title:"File upload failed",description:e.message,variant:"danger"})},onDropRejected:e=>{q({title:"File upload failed",description:m.jsx("div",{className:"flex flex-col gap-1",children:e.map((e=>m.jsxs("div",{children:[e.file.name," (",e.errors.map((e=>e.message)).join(", "),")"]},e.file.name)))}),variant:"danger"})},onDrop:async e=>{for(const t of e){const e=(await ms(t)).split(",")[1];await ds({path:"",type:"file",name:t.name,contents:e})}await async function(){await G.get(ZM).refreshAll([])}()},...e})}const tT=u.createContext(null),nT=({height:e})=>{const t=r.useRef(null),[n]=je(ZM),[o,a]=r.useState([]),[s,i]=r.useState(null),{openPrompt:l}=f(),[c,d]=je(QM),{loading:u,error:h}=Ht((()=>n.initialize(a)),[]),p=R((()=>{n.refreshAll(Object.keys(c).filter((e=>c[e])))})),g=R((async()=>{l({title:"Folder name",onConfirm:async e=>{n.createFolder(e,null)}})})),v=R((async()=>{l({title:"File name",onConfirm:async e=>{n.createFile(e,null)}})})),x=R((()=>{var e;null==(e=t.current)||e.closeAll(),d({})}));return u?m.jsx(pa,{size:"medium",centered:!0}):h?m.jsx(es,{error:h}):s?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex items-center pl-1 pr-3 flex-shrink-0 border-b justify-between",children:[m.jsx(b,{onClick:()=>i(null),"data-testid":"file-explorer-back-button",variant:"text",size:"xs",className:"mb-0",children:m.jsx(kl,{size:16})}),m.jsx("span",{className:"font-bold",children:s.name})]}),m.jsx(r.Suspense,{children:m.jsx(JM,{onOpenNotebook:e=>cT(e,n.relativeFromRoot(s.path)),file:s})})]}):m.jsxs(m.Fragment,{children:[m.jsx(rT,{onRefresh:p,onCreateFile:v,onCreateFolder:g,onCollapseAll:x,tree:n}),m.jsx(tT.Provider,{value:n,children:m.jsx(fi,{width:"100%",ref:t,height:e-33,className:"h-full",data:o,initialOpenState:c,openByDefault:!1,renderCursor:()=>null,disableDrop:({parentNode:e})=>!e.data.isDirectory,onDelete:async({ids:e})=>{for(const t of e)await n.delete(t)},onRename:async({id:e,name:t})=>{await n.rename(e,t)},onMove:async({dragIds:e,parentId:t})=>{await n.move(e,t)},onSelect:e=>{const t=e[0];t&&(t.data.isDirectory||i(t.data))},onToggle:async e=>{if(await n.expand(e)){const t=c[e]??!1;d({...c,[e]:!t})}},padding:15,rowHeight:30,indent:oT,overscanCount:1e3,disableMultiSelection:!0,children:iT})})]})},oT=15,rT=({tree:e,onRefresh:t,onCreateFile:n,onCreateFolder:o,onCollapseAll:r})=>{const{getRootProps:a,getInputProps:s}=eT({noDrag:!0,noDragEventsBubbling:!0});return m.jsxs("div",{className:"flex items-center justify-end px-2 flex-shrink-0 border-b",children:[m.jsx(p,{content:"Add file",children:m.jsx(b,{"data-testid":"file-explorer-add-file-button",onClick:n,variant:"text",size:"xs",children:m.jsx($l,{size:16})})}),m.jsx(p,{content:"Add folder",children:m.jsx(b,{"data-testid":"file-explorer-add-folder-button",onClick:o,variant:"text",size:"xs",children:m.jsx(Hl,{size:16})})}),m.jsx(p,{content:"Upload file",children:m.jsx("button",{"data-testid":"file-explorer-upload-button",...a({}),className:ps({variant:"text",size:"xs"}),children:m.jsx(gs,{size:16})})}),m.jsx("input",{...s({}),type:"file"}),m.jsx(p,{content:"Refresh",children:m.jsx(b,{"data-testid":"file-explorer-refresh-button",onClick:t,variant:"text",size:"xs",children:m.jsx(xr,{size:16})})}),m.jsx(p,{content:"Collapse all folders",children:m.jsx(b,{"data-testid":"file-explorer-collapse-button",onClick:r,variant:"text",size:"xs",children:m.jsx(zl,{size:16})})})]})},aT=({node:e,onOpenMarimoFile:t})=>m.jsxs("span",{className:"flex-1 overflow-hidden text-ellipsis",onClick:t=>{e.data.isDirectory||(t.stopPropagation(),e.select())},children:[e.data.name,e.data.isMarimoFile&&!C()&&m.jsxs("span",{className:"flex-shrink-0 ml-2 text-sm hidden group-hover:inline hover:underline",onClick:t,children:["open ",m.jsx(ts,{className:"inline ml-1",size:12})]})]}),sT=({node:e})=>{const t=r.useRef(null);return r.useEffect((()=>{var n,o;null==(n=t.current)||n.focus(),null==(o=t.current)||o.setSelectionRange(0,e.data.name.lastIndexOf("."))}),[e.data.name]),m.jsx("input",{ref:t,className:"flex-1 bg-transparent border border-border text-muted-foreground",defaultValue:e.data.name,onClick:e=>e.stopPropagation(),onBlur:()=>e.reset(),onKeyDown:t=>{"Escape"===t.key&&e.reset(),"Enter"===t.key&&e.submit(t.currentTarget.value)}})},iT=({node:e,style:t,dragHandle:n})=>{const o=e.data.isDirectory?"directory":qt(e.data.name),a=Zt[o],{openConfirm:s,openPrompt:i}=f(),l=r.useContext(tT),c=async t=>{cT(t,l?l.relativeFromRoot(e.data.path):e.data.path)},d=async t=>{t.stopPropagation(),t.preventDefault(),s({title:"Delete file",description:`Are you sure you want to delete ${e.data.name}?`,confirmAction:m.jsx(Ge,{onClick:async()=>{await e.tree.delete(e.id)},"aria-label":"Confirm",children:"Delete"})})},u=R((async()=>{e.open(),i({title:"Folder name",onConfirm:async t=>{null==l||l.createFolder(t,e.id)}})})),h=R((async()=>{e.open(),i({title:"File name",onConfirm:async t=>{null==l||l.createFile(t,e.id)}})}));return m.jsxs("div",{style:t,ref:n,className:$t("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group"),draggable:!0,onClick:t=>{t.stopPropagation(),e.data.isDirectory&&e.toggle()},children:[m.jsx(lT,{node:e}),m.jsxs("span",{className:$t("flex items-center pl-1 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden group",e.willReceiveDrop&&e.data.isDirectory&&"bg-accent/80 hover:bg-accent/80 text-accent-foreground"),children:[e.data.isMarimoFile?m.jsx("img",{src:"/favicon.ico",className:"w-5 h-5 flex-shrink-0 mr-2 filter grayscale",alt:"Marimo"}):m.jsx(a,{className:"w-5 h-5 flex-shrink-0 mr-2",strokeWidth:1.5}),e.isEditing?m.jsx(sT,{node:e}):m.jsx(aT,{node:e,onOpenMarimoFile:c}),m.jsxs(xt,{modal:!1,children:[m.jsx(yt,{asChild:!0,tabIndex:-1,onClick:e=>e.stopPropagation(),children:m.jsx(b,{"data-testid":"file-explorer-more-button",variant:"text",tabIndex:-1,size:"xs",className:"mb-0","aria-label":"More options",children:m.jsx(Bl,{strokeWidth:2,className:"w-5 h-5 hidden group-hover:block"})})}),(()=>{const t={size:14,strokeWidth:1.5,className:"mr-2"};return m.jsxs(bt,{align:"end",className:"no-print w-[220px]",onClick:e=>e.stopPropagation(),onCloseAutoFocus:e=>e.preventDefault(),children:[!e.data.isDirectory&&m.jsxs(St,{onSelect:()=>e.select(),children:[m.jsx(Oc,{...t}),"Open file"]}),e.data.isDirectory&&m.jsxs(m.Fragment,{children:[m.jsxs(St,{onSelect:()=>h(),children:[m.jsx($l,{...t}),"Create file"]}),m.jsxs(St,{onSelect:()=>u(),children:[m.jsx(Hl,{...t}),"Create folder"]}),m.jsx(Ct,{})]}),m.jsxs(St,{onSelect:()=>e.edit(),children:[m.jsx(dc,{...t}),"Rename"]}),m.jsxs(St,{onSelect:()=>{q({title:"Copied to clipboard"}),navigator.clipboard.writeText(e.data.path)},children:[m.jsx(Ve,{...t}),"Copy path"]}),l&&m.jsxs(St,{onSelect:()=>{q({title:"Copied to clipboard"}),navigator.clipboard.writeText(l.relativeFromRoot(e.data.path))},children:[m.jsx(Ve,{...t}),"Copy relative path"]}),m.jsxs(St,{onSelect:()=>{q({title:"Copied to clipboard",description:"Code to open the file has been copied to your clipboard. You can also drag and drop this file into the editor"});const{path:t}=e.data,n=vs[o](t);navigator.clipboard.writeText(n)},children:[m.jsx(xs,{...t}),"Copy snippet for reading file"]}),e.data.isMarimoFile&&!C()&&m.jsxs(m.Fragment,{children:[m.jsx(Ct,{}),m.jsxs(St,{onSelect:c,children:[m.jsx(Cc,{...t}),"Open notebook"]})]}),m.jsx(Ct,{}),m.jsxs(St,{onSelect:d,variant:"danger",children:[m.jsx(xe,{...t}),"Delete"]})]})})()]})]})]})},lT=({node:e})=>e.data.isDirectory?e.isOpen?m.jsx(ge,{className:"w-5 h-5 flex-shrink-0"}):m.jsx(gr,{className:"w-5 h-5 flex-shrink-0"}):m.jsx("span",{className:"w-5 h-5 flex-shrink-0"});function cT(e,t){e.stopPropagation(),e.preventDefault(),window.open(`/?file=${t}`,"_blank")}const dT=()=>{const{ref:e,height:t=1}=qM(),{getRootProps:n,getInputProps:o,isDragActive:r}=eT({noClick:!0,noKeyboard:!0});return m.jsxs("div",{...n(),className:$t("flex flex-col flex-1 overflow-hidden relative"),children:[m.jsx("input",{...o()}),r&&m.jsx("div",{className:"absolute inset-0 flex items-center uppercase justify-center text-xl font-bold text-primary/90 bg-accent/85 z-10 border-2 border-dashed border-primary/90 rounded-lg pointer-events-none",children:"Drop files here"}),m.jsx("div",{ref:e,className:"flex flex-col flex-1 overflow-hidden",children:m.jsx(nT,{height:t})})]})},uT=({children:e})=>{const{openModal:t,closeModal:n}=f();return m.jsx(xa,{onClick:()=>t(m.jsx(fT,{onClose:n})),children:e})},hT=[Dt.lineWrapping],fT=({onClose:e})=>{const[t,n]=r.useState(""),{theme:o}=we();return m.jsx(g,{className:"w-fit",children:m.jsxs("form",{onSubmit:async t=>{t.preventDefault();const n=new FormData(t.target),o=n.get("title"),r=n.get("description"),a=n.get("code");fetch("https://marimo.io/api/suggest-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:o,description:r,code:a})}),e(),q({title:"Snippet Submitted",description:"Thank you for contributing! We will review your snippet shortly."})},children:[m.jsxs(re,{children:[m.jsx(v,{children:"Contribute a Snippet"}),m.jsxs(x,{children:["Have a useful snippet you want to share with the community? Submit it here or make a pull request"," ",m.jsx("a",{href:Be.githubPage,target:"_blank",rel:"noreferrer",className:"underline",children:"on GitHub"}),"."]})]}),m.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[m.jsx(Ue,{id:"title",name:"title",autoFocus:!0,placeholder:"Title",required:!0,autoComplete:"off"}),m.jsx(ya,{id:"description",name:"description",autoFocus:!0,placeholder:"Description",rows:5,required:!0,autoComplete:"off"}),m.jsx("input",{type:"hidden",name:"code",value:t}),m.jsx(ss,{theme:"dark"===o?"dark":"light",language:"python",className:"cm border rounded overflow-hidden",extensions:hT,value:t,onChange:n})]}),m.jsxs(y,{children:[m.jsx(b,{"data-testid":"snippet-cancel-button",variant:"secondary",onClick:e,children:"Cancel"}),m.jsx(b,{"data-testid":"snippet-send-button","aria-label":"Save",variant:"default",type:"submit",children:"Send"})]})]})})},mT=[Dt.lineWrapping],pT=()=>{const[e,t]=u.useState(),{data:n,error:o,loading:a}=Ht((()=>ys()),[]);return o?m.jsx(es,{error:o}):a||!n?m.jsx(pa,{size:"medium",centered:!0}):m.jsxs("div",{className:"flex-1 overflow-hidden",children:[m.jsxs(Jt,{className:$t("border-b rounded-none",e?"h-1/3":"h-full"),children:[m.jsxs("div",{className:"flex items-center w-full",children:[m.jsx(Te,{placeholder:"Search snippets...",className:"h-6 m-1",rootClassName:"flex-1 border-r"}),m.jsx(uT,{children:m.jsx("button",{className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",children:m.jsx(No,{className:"h-4 w-4"})})})]}),m.jsx(De,{children:"No results"}),m.jsx(vT,{onSelect:e=>t(e),snippets:n.snippets})]}),m.jsx(r.Suspense,{children:m.jsx("div",{className:"h-2/3 snippet-viewer flex flex-col",children:e?m.jsx(gT,{snippet:e},e.title):m.jsx(Ik,{title:"",description:"Click on a snippet to view its content."})})})]})},gT=({snippet:e})=>{const{theme:t}=we(),{createNewCell:n}=L(),o=ad();return m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"text-sm font-semibold bg-muted border-y px-2 py-1",children:e.title}),m.jsxs("div",{className:"px-2 py-2 space-y-4 overflow-auto flex-1",children:[m.jsx("div",{className:"flex justify-end",children:m.jsx(Yd,{children:m.jsxs(b,{className:"float-right",size:"xs",variant:"outline",onClick:()=>{for(const t of[...e.sections].reverse())t.code&&n({code:t.code,before:!1,cellId:o??"__end__"})},children:["Insert snippet",m.jsx(Sl,{className:"ml-2 h-4 w-4"})]})})}),e.sections.map((r=>{const{code:a,html:s,id:i}=r;return s?m.jsx("div",{children:Or({html:s})},`${e.title}-${i}`):a?m.jsxs("div",{className:"relative hover-actions-parent pr-2",children:[m.jsx(Yd,{children:m.jsx(p,{content:"Insert snippet",children:m.jsx(b,{className:"absolute -top-2 -right-1 z-10 hover-action px-2 bg-background",size:"sm",variant:"outline",onClick:()=>{(e=>{n({code:e,before:!1,cellId:o??"__end__"})})(a)},children:m.jsx(Sl,{className:"h-5 w-5"})})})}),m.jsx(ss,{theme:"dark"===t?"dark":"light",language:"python",className:"cm border rounded overflow-hidden",extensions:mT,value:a,readOnly:!0},`${e.title}-${i}`)]},`${e.title}-${i}`):null}))]})]})},vT=({snippets:e,onSelect:t})=>m.jsx(To,{className:"flex flex-col overflow-auto",children:e.map((e=>m.jsx(Fe,{className:"rounded-none",onSelect:()=>t(e),children:m.jsx("div",{className:"flex flex-row gap-2 items-center",children:m.jsx("span",{className:"mt-1 text-accent-foreground",children:e.title})})},e.title)))}),xT=({value:e,className:t,tooltip:n})=>{const[o,a]=r.useState(!1),s=$e.stopPropagation((()=>{navigator.clipboard.writeText(e).then((()=>{a(!0),setTimeout((()=>a(!1)),2e3)}))})),i=m.jsx("span",{onClick:s,children:o?m.jsx(pt,{className:$t(t,"text-[var(--grass-11)]")}):m.jsx(Ve,{className:t})});return!1===n?i:m.jsx(p,{content:o?"Copied!":n??"Copy to clipboard",delayDuration:400,children:i})},yT=V((e=>{const t=e(qo),n=e(Y),o=e(ha);return wl(t,(e=>{if(!e.variable_name)return-1;const t=Object.values(n).find((t=>t.name===e.variable_name));if(!t)return 0;const r=o.inOrderIds.indexOf(t.declaredBy[0]);return-1===r?0:r}))})),bT=()=>{const[e,t]=u.useState(""),n=X(ee),o=ad(),{expandedColumns:r,expandedTables:a,columnsPreviews:s}=bs(),{toggleTable:i,toggleColumn:l,closeAllColumns:c}=ws(),{createNewCell:d}=L(),h=X(yT);if(0===h.length)return m.jsx(Ik,{title:"No tables found",description:"Any datasets/dataframes in the global scope will be shown here.",icon:m.jsx(de,{})});const f=!!e.trim();return m.jsx("div",{className:"flex-1 overflow-hidden",children:m.jsxs(Jt,{className:$t("border-b bg-background rounded-none","h-full"),children:[m.jsxs("div",{className:"flex items-center w-full",children:[m.jsx(Te,{placeholder:"Search tables...",className:"h-6 m-1",value:e,onValueChange:e=>{e.length>0&&c(),t(e)},rootClassName:"flex-1 border-r"}),f&&m.jsx("button",{type:"button",className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",onClick:()=>t(""),children:m.jsx(Bt,{className:"h-4 w-4"})})]}),m.jsx(wT,{onAddColumnChart:e=>{e.includes("alt")&&function(e,t,n){td("altair","alt",(o=>{const r=K.create();t({cellId:n??"__end__",before:!1,code:o,lastCodeRun:e?o:void 0,newCellId:r,autoFocus:!1}),e&&B({cellIds:[r],codes:[o]})}))}(n,d,o),d({code:e,before:!1,cellId:o??"__end__"})},onAddTable:e=>{nd(n,d,o);let t="";switch(e.source_type){case"local":t=`mo.ui.table(${e.name})`;break;case"duckdb":t=`_df = mo.sql(f"SELECT * FROM ${e.name} LIMIT 100")`;break;default:k(e.source_type)}d({code:t,before:!1,cellId:o??"__end__"})},onExpandColumn:(e,t)=>{const n=`${e.name}:${t.name}`;l({table:e.name,column:t.name}),s.has(n)||ks({source:e.source,tableName:e.name,columnName:t.name,sourceType:e.source_type})},onExpandTable:e=>{i(e.name)},columnPreviews:s,tables:h,isSearching:f,isTableExpanded:e=>!!f||a.has(e.name),isColumnExpanded:(e,t)=>{const n=`${e.name}:${t.name}`;return r.has(n)}})]})})},wT=({tables:e,isSearching:t,columnPreviews:n,onAddColumnChart:o,onAddTable:r,onExpandTable:a,onExpandColumn:s,isTableExpanded:i,isColumnExpanded:l})=>{let c=Object.entries(Ie.groupBy(e,(e=>e.source),(e=>e)));c=wl(c,(([e])=>"memory"===e?0:1));const d=e=>{const c=i(e),d=[m.jsx(kT,{table:e,forceMount:t,onExpand:()=>a(e),onAddTable:()=>r(e),isExpanded:c},e.name)];return c&&d.push(...e.columns.map((t=>m.jsxs(u.Fragment,{children:[m.jsx(NT,{table:e,column:t,onExpandColumn:s,isExpanded:l(e,t)},`${e.name}.${t.name}`),l(e,t)&&m.jsx("div",{className:"pl-10 pr-2 py-2 bg-[var(--slate-1)] shadow-inner border-b",children:m.jsx(Es,{children:m.jsx(CT,{table:e,column:t,onAddColumnChart:o,preview:n.get(`${e.name}:${t.name}`)})})})]},`${e.name}.${t.name}`)))),d};return m.jsx(To,{className:"flex flex-col overflow-auto",children:0===c.length?null:1===c.length?c[0][1].flatMap(d):c.flatMap((([e,t],n)=>[m.jsx("div",{className:$t("font-bold px-2 py-1 text-muted-foreground bg-[var(--slate-2)] border-t text-sm",n>0&&"border-t"),children:"memory"===e?"In-Memory":e},e),...t.flatMap(d)]))})},kT=({table:e,onExpand:t,onAddTable:n,isExpanded:o})=>m.jsxs(Fe,{className:"rounded-none py-1 group min-h-9 border-t",value:e.name,"aria-selected":o,forceMount:!0,onSelect:t,children:[m.jsxs("div",{className:"flex gap-1 items-center flex-1",children:[m.jsx(gr,{className:$t("h-3 w-3 transition-transform",o&&"rotate-90")}),m.jsx("span",{className:"text-sm",children:e.name})]}),(()=>{const t=[];return null!=e.num_rows&&t.push(`${e.num_rows} rows`),null!=e.num_columns&&t.push(`${e.num_columns} columns`),0===t.length?null:m.jsx("div",{className:"flex flex-row gap-2 items-center pl-6 group-hover:hidden",children:m.jsx("span",{className:"text-xs text-muted-foreground",children:t.join(", ")})})})(),m.jsx(p,{content:"Add table to notebook",delayDuration:400,children:m.jsx(b,{className:"group-hover:inline-flex hidden",variant:"text",size:"icon",onClick:$e.stopPropagation((()=>n(e))),children:m.jsx(jc,{className:"h-3 w-3"})})})]}),NT=({table:e,column:t,onExpandColumn:n})=>{const o=Cs[t.type];return m.jsxs(Fe,{className:"rounded-none py-1 group",value:`${e.name}.${t.name}`,onSelect:()=>n(e,t),children:[m.jsxs("div",{className:"flex flex-row gap-2 items-center pl-6 flex-1",children:[m.jsx(o,{className:"flex-shrink-0 h-3 w-3",strokeWidth:1.5}),m.jsx("span",{children:t.name})]}),m.jsx(p,{content:"Copy column name",delayDuration:400,children:m.jsx(b,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:m.jsx(xT,{tooltip:!1,value:t.name,className:"h-3 w-3"})})}),m.jsx("span",{className:"text-xs text-muted-foreground",children:t.external_type})]},`${e.name}.${t.name}`)},ET=u.lazy((()=>Ns((()=>import("./index-ES7DDfXY.js")),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]),import.meta.url).then((e=>({default:e.VegaLite}))))),CT=({table:e,column:t,preview:n,onAddColumnChart:o})=>{const{theme:r}=we();if(!n)return m.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading..."});const a=n.error&&m.jsx("span",{className:"text-xs text-muted-foreground",children:n.error}),s=n.summary&&m.jsx("div",{className:"gap-x-16 gap-y-1 grid grid-cols-2-fit border rounded p-2 empty:hidden",children:Object.entries(n.summary).map((([e,t])=>null==t?null:m.jsxs("div",{className:"flex items-center gap-1 group",children:[m.jsx(xT,{className:"h-3 w-3 invisible group-hover:visible",value:String(t)}),m.jsx("span",{className:"text-xs min-w-[60px] uppercase",children:e}),m.jsx("span",{className:"text-xs font-bold text-muted-foreground tracking-wide",children:js(t)})]},e)))}),i=n.chart_spec&&m.jsx(ET,{spec:(l=JSON.parse(n.chart_spec),{...l,config:{...l.config,background:"transparent"}}),width:"container",height:100,actions:!1,theme:"dark"===r?"dark":"vox"});var l;const c=n.chart_code&&"local"===e.source_type&&m.jsx(p,{content:"Add chart to notebook",delayDuration:400,children:m.jsx(b,{variant:"outline",size:"icon",className:"z-10 bg-background absolute right-1 -top-1",onClick:$e.stopPropagation((()=>o(n.chart_code||""))),children:m.jsx(jc,{className:"h-3 w-3"})})}),d="duckdb"===e.source_type&&m.jsx(p,{content:"Add SQL cell",delayDuration:400,children:m.jsx(b,{variant:"outline",size:"icon",className:"z-10 bg-background absolute right-1 -top-1",onClick:$e.stopPropagation((()=>{const n=`_df = mo.sql(f'SELECT "${t.name}" FROM ${e.name} LIMIT 100')`;o(n)})),children:m.jsx(jc,{className:"h-3 w-3"})})}),u=n.chart_max_rows_errors&&m.jsx("span",{className:"text-xs text-muted-foreground",children:"Too many rows to render the chart."});return a||s||i||u?m.jsxs("div",{className:"flex flex-col gap-2 relative",children:[a,c,d,u,i,s]}):m.jsx("span",{className:"text-xs text-muted-foreground",children:"No data"})},jT=({isOpen:e,children:t})=>{const[n,o]=u.useState(!1);return u.useEffect((()=>{e&&!n&&o(!0)}),[e,n]),n?t:null},ST=()=>{const e=P(),[t]=ke(),{theme:n}=we(),o=r.useRef(null),a=ad(),{createNewCell:s,updateCellCode:i}=L(),l=be,c=e.cellRuntime[l],d=null==c?void 0:c.output,u=null==c?void 0:c.status,h=null==c?void 0:c.consoleOutputs,f=e.cellData[l],g=(null==f?void 0:f.code)??"",v=R((()=>{Ss({code:g})})),x=R((()=>{g.trim()&&s({code:g,before:!1,cellId:a??"__end__"})})),y=R((()=>{i({cellId:l,code:"",formattingChange:!1}),Ss({code:""});const e=o.current;e&&e.dispatch({changes:{from:0,to:e.state.doc.length,insert:""}})}));return m.jsxs("div",{className:"flex flex-col h-full overflow-hidden divide-y",id:Qe.create(l),children:[m.jsxs("div",{className:"flex items-center flex-shrink-0",children:[m.jsx(p,{content:Ds("cell.run"),children:m.jsx(b,{"data-testid":"scratchpad-run-button",onClick:v,variant:"text",size:"xs",children:m.jsx(uc,{color:"var(--grass-11)",size:16})})}),m.jsx(p,{content:"Clear code and outputs",children:m.jsx(b,{size:"xs",variant:"text",onClick:y,children:m.jsx(Ul,{size:16})})}),m.jsx(Yd,{children:m.jsx(p,{content:"Insert code",children:m.jsx(b,{size:"xs",variant:"text",onClick:x,children:m.jsx(Sl,{size:16})})})}),("running"===u||"queued"===u)&&m.jsx(pa,{className:"inline",size:"small"})]}),m.jsx("div",{className:"overflow-auto flex-shrink-0 max-h-[40%]",children:m.jsx(tb,{theme:n,allowFocus:!1,showPlaceholder:!1,id:l,code:g,status:"idle",serializedEditorState:null,runCell:v,updateCellCode:i,createNewCell:Gt.NOOP,deleteCell:Gt.NOOP,focusCell:Gt.NOOP,moveCell:Gt.NOOP,moveToNextCell:void 0,updateCellConfig:Gt.NOOP,clearSerializedEditorState:Gt.NOOP,userConfig:t,editorViewRef:o,hidden:!1})}),m.jsx("div",{className:"flex-1 overflow-auto flex-shrink-0",children:m.jsx(jr,{allowExpand:!1,output:d,className:"output-area",cellId:l,stale:!1})}),m.jsx("div",{className:"overflow-auto flex-shrink-0 max-h-[35%]",children:m.jsx(Ji,{consoleOutputs:h,className:"overflow-auto",stale:!1,cellName:Ya,onSubmitDebugger:Gt.NOOP,cellId:l,debuggerActive:!1})})]})},IT=()=>m.jsx(ST,{}),AT=()=>{const[e]=ke(),t=e.package_management.manager,{data:n,loading:o,error:r,reload:a}=Ht((()=>Is()),[t]);if(o&&!n)return m.jsx(pa,{size:"medium",centered:!0});if(r)return m.jsx(es,{error:r});const s=(null==n?void 0:n.packages)||[];return m.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[m.jsx(MT,{packageManager:t,onSuccess:a}),m.jsx(TT,{packages:s,onSuccess:a})]})},MT=({onSuccess:e,packageManager:t})=>{const[n,o]=u.useState(""),[r,a]=u.useState(!1),s=async()=>{try{a(!0);const t=await Ms({package:n});t.success?(e(),q({title:"Package added",description:m.jsxs("span",{children:["The package ",m.jsx(ai,{className:"inline",children:n})," and its dependencies has been added to your environment."]})})):q({title:"Failed to add package",description:t.error,variant:"danger"})}finally{o(""),a(!1)}};return m.jsxs("div",{className:"flex items-center w-full border-b",children:[m.jsx(Ba,{placeholder:`Install packages with ${t}...`,icon:r?m.jsx(pa,{size:"small",className:"mr-2 h-4 w-4 shrink-0 opacity-50"}):m.jsx(Al,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),rootClassName:"flex-1 border-none",value:n,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),s())},onChange:e=>o(e.target.value)}),m.jsx(p,{delayDuration:300,side:"left",align:"start",content:m.jsxs("div",{className:"text-sm flex flex-col w-full max-w-[360px]",children:["Packages are installed using the package manager specified in your user configuration. Depending on your package manager, you can install packages with various formats:",m.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[m.jsxs("div",{children:[m.jsx("span",{className:"font-bold tracking-wide",children:"Package name:"})," A package name; this will install the latest version.",m.jsx("div",{className:"text-muted-foreground",children:"Example: httpx"})]}),m.jsxs("div",{children:[m.jsx("span",{className:"font-bold tracking-wide",children:"Package and version:"})," ","A package with a specific version or version range.",m.jsx("div",{className:"text-muted-foreground",children:"Examples: httpx==0.27.0, httpx>=0.27.0"})]}),m.jsxs("div",{children:[m.jsx("span",{className:"font-bold tracking-wide",children:"Git:"})," A Git repository",m.jsx("div",{className:"text-muted-foreground",children:"Example: git+https://github.com/encode/httpx"})]}),m.jsxs("div",{children:[m.jsx("span",{className:"font-bold tracking-wide",children:"URL:"})," A remote wheel or source distribution.",m.jsx("div",{className:"text-muted-foreground",children:"Example: https://example.com/httpx-0.27.0.tar.gz"})]}),m.jsxs("div",{children:[m.jsx("span",{className:"font-bold tracking-wide",children:"Path:"})," A local wheel, source distribution, or project directory.",m.jsx("div",{className:"text-muted-foreground",children:"Example: /example/foo-0.1.0-py3-none-any.whl"})]})]})]}),children:m.jsx(As,{className:"h-4 w-4 cursor-help text-muted-foreground hover:text-foreground bg-transparent"})}),m.jsx("button",{type:"button",className:$t("float-right px-2 m-0 h-full text-sm text-secondary-foreground ml-2",n&&"bg-accent text-accent-foreground","disabled:cursor-not-allowed disabled:opacity-50"),onClick:s,disabled:!n,children:"Add"})]})},TT=({onSuccess:e,packages:t})=>0===t.length?m.jsx(Ik,{title:"No packages",description:"No packages are installed in this environment.",icon:m.jsx(Al,{})}):m.jsxs(Ua,{className:"overflow-auto flex-1",children:[m.jsx(Va,{children:m.jsxs($a,{children:[m.jsx(Ga,{children:"Name"}),m.jsx(Ga,{children:"Version"}),m.jsx(Ga,{})]})}),m.jsx(Wa,{children:t.map((t=>m.jsxs($a,{className:"group",onClick:()=>{navigator.clipboard.writeText(`${t.name}==${t.version}`),q({title:"Copied to clipboard"})},children:[m.jsx(qa,{children:t.name}),m.jsx(qa,{children:t.version}),m.jsx(qa,{children:m.jsx(OT,{packageName:t.name,onSuccess:e})})]},t.name)))})]}),OT=({packageName:e,onSuccess:t})=>{const[n,o]=u.useState(!1);return n?m.jsx(pa,{size:"small",className:"float-right mr-2 h-4 w-4 shrink-0 opacity-50"}):m.jsx("button",{type:"button",className:$t("float-right px-2 h-full text-xs text-muted-foreground hover:text-foreground","invisible group-hover:visible"),onClick:$e.stopPropagation((async()=>{try{o(!0);const n=await Ts({package:e});n.success?(t(),q({title:"Package removed",description:m.jsxs("span",{children:["The package ",m.jsx(ai,{className:"inline",children:e})," has been removed from your environment."]})})):q({title:"Failed to add package",description:n.error,variant:"danger"})}finally{o(!1)}})),children:"Remove"})},DT=u.lazy((()=>Ns((()=>import("./terminal-DQvARn1F.js")),__vite__mapDeps([15,2,3,16]),import.meta.url))),_T=({children:e})=>{const{isSidebarOpen:t,isTerminalOpen:n,selectedPanel:o}=bd(),{setIsSidebarOpen:a,setIsTerminalOpen:s}=wd(),i=u.useRef(null),l=u.useRef(null);r.useEffect((()=>{if(!i.current)return;const e=i.current.isCollapsed();t&&e&&i.current.expand(),t||e||i.current.collapse(),requestAnimationFrame((()=>{requestAnimationFrame((()=>{window.dispatchEvent(new Event("resize"))}))}))}),[t]),r.useEffect((()=>{if(!l.current)return;const e=l.current.isCollapsed();n&&e&&l.current.expand(),n||e||l.current.collapse(),requestAnimationFrame((()=>{requestAnimationFrame((()=>{window.dispatchEvent(new Event("resize"))}))}))}),[n]);const c=m.jsx(Jb,{id:"app",className:"relative h-full",children:m.jsx(r.Suspense,{children:e})},"app"),d=e=>{e||window.dispatchEvent(new Event("resize"))},h=m.jsx(ok,{onDragging:d,className:$t("border-border no-print z-10",t?"resize-handle":"resize-handle-collapsed","vertical")}),f=m.jsx(ok,{onDragging:d,className:$t("border-border no-print z-20",n?"resize-handle":"resize-handle-collapsed","horizontal")}),p=m.jsx(Es,{children:m.jsx(r.Suspense,{children:m.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden mr-[-4px]",children:[m.jsxs("div",{className:"p-3 border-b flex justify-between items-center",children:[m.jsx("div",{className:"text-sm text-[var(--slate-11)] uppercase tracking-wide font-semibold flex-1",children:o}),m.jsx(b,{"data-testid":"close-helper-pane",className:"m-0",size:"xs",variant:"text",onClick:()=>a(!1),children:m.jsx(Bt,{className:"w-4 h-4"})})]}),"files"===o&&m.jsx(dT,{}),"errors"===o&&m.jsx(Ak,{}),"variables"===o&&m.jsx(BM,{}),"dependencies"===o&&m.jsx(_M,{}),"packages"===o&&m.jsx(AT,{}),"outline"===o&&m.jsx(Mk,{}),"datasources"===o&&m.jsx(bT,{}),"documentation"===o&&m.jsx(HM,{}),"snippets"===o&&m.jsx(pT,{}),"scratchpad"===o&&m.jsx(IT,{}),"logs"===o&&m.jsx(UM,{})]})})}),g=m.jsx(Jb,{ref:i,id:"helper",collapsedSize:0,collapsible:!0,className:$t("dark:bg-[var(--slate-1)] no-print print:hidden",t&&"border-r border-l border-[var(--slate-7)]"),minSize:10,defaultSize:0,maxSize:75,onResize:(e,t)=>{var n;0===t&&10===e&&(null==(n=i.current)||n.resize(30))},onCollapse:()=>a(!1),onExpand:()=>a(!0),children:m.jsxs("span",{className:"flex flex-row h-full",children:[p," ",h]})},"helper"),v=m.jsxs(Jb,{ref:l,id:"terminal",collapsedSize:0,collapsible:!0,className:$t("dark:bg-[var(--slate-1)] no-print print:hidden",n&&"border-[var(--slate-7)]"),minSize:10,defaultSize:0,maxSize:75,onResize:(e,t)=>{var n;0===t&&10===e&&(null==(n=l.current)||n.resize(30))},onCollapse:()=>s(!1),onExpand:()=>s(!0),children:[f,m.jsx(jT,{isOpen:n,children:m.jsx(DT,{visible:n,onClose:()=>s(!1)})})]},"terminal");return m.jsxs("div",{className:"flex flex-col flex-1 overflow-hidden absolute inset-0 print:relative",children:[m.jsxs(ek,{autoSaveId:"marimo:chrome:v1:l2",direction:"horizontal",storage:{getItem:e=>Sk||(Sk??null),setItem(e,t){Sk=t||null}},children:[m.jsx(Ek,{}),g,m.jsx(Jb,{children:m.jsxs(ek,{autoSaveId:"marimo:chrome:v1:l1",direction:"vertical",children:[c,m.jsx(yk,{capability:"terminal",children:v})]})})]}),m.jsx(Es,{children:m.jsx(bk,{})})]})},PT=e=>m.jsxs(_T,{children:[m.jsx(Sb,{...e}),m.jsx(dd,{})]});export{PT as default};
|