ryugi-artifacts 1.120.6 → 1.121.0
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/cli.cjs +9 -9
- package/dist/document-engine.cjs +227 -227
- package/dist/viewer/{AgentDock-DIfCUHgZ.js → AgentDock-BNyBNlSy.js} +2 -2
- package/dist/viewer/ArtboardLayout-6tJS23QW.js +14 -0
- package/dist/viewer/ArtifactList-C3N4BjKx.js +2 -0
- package/dist/viewer/{ArtifactModal-Fp67aW8M.js → ArtifactModal-CH9BY3RJ.js} +1 -1
- package/dist/viewer/{BottomSheet-SYC_8Y6k.js → BottomSheet-BFtfrr58.js} +1 -1
- package/dist/viewer/{BrandingMark-D8kdL9jc.js → BrandingMark-QZsHgEQs.js} +1 -1
- package/dist/viewer/{Canvas-CMN5apcj.js → Canvas-C4NA77Id.js} +1 -1
- package/dist/viewer/{CommentPopover-CxFndD1f.js → CommentPopover-BoOuSWYS.js} +1 -1
- package/dist/viewer/{DocumentExportMenu-DyhweUFo.js → DocumentExportMenu-DrN19D4m.js} +1 -1
- package/dist/viewer/DocumentLayout-BjURocqM.js +2 -0
- package/dist/viewer/DocumentPage-H6a9SW4D.js +5 -0
- package/dist/viewer/DraftTray-JF38Iwzo.js +1 -0
- package/dist/viewer/{DraggablePanel-h7D7Tgnv.js → DraggablePanel-fUJe7paG.js} +1 -1
- package/dist/viewer/DropdownMenu-DrocGAAh.js +1 -0
- package/dist/viewer/{GroupVerdict-CSoZ7xIi.js → GroupVerdict-BCr6Cy0G.js} +1 -1
- package/dist/viewer/{HtmlLayout-DursBclJ.js → HtmlLayout-CeRlKG6z.js} +1 -1
- package/dist/viewer/{Input-CkHOfbQE.js → Input-BMZZLY98.js} +1 -1
- package/dist/viewer/MenuSubmenuTrigger-CPcD7vNW.js +1 -0
- package/dist/viewer/{PhoneArtboardBar-DOanenAY.js → PhoneArtboardBar-Dq5U0hhz.js} +1 -1
- package/dist/viewer/{Popover-HS6yjzxl.js → Popover-DxR9Dpf_.js} +1 -1
- package/dist/viewer/PreviewArtifactLayout-CDoR32LC.js +1 -0
- package/dist/viewer/PreviewLayout-C-sly_jL.js +2 -0
- package/dist/viewer/ReportLayout-CXSxsjVb.js +6 -0
- package/dist/viewer/{Segmented-D5ApsVJJ.js → Segmented-DoorRFgs.js} +1 -1
- package/dist/viewer/SelectScrollUpArrow-bXyfVgGf.js +1 -0
- package/dist/viewer/SlidesLayout-BDTPyuCv.js +12 -0
- package/dist/viewer/{SnapshotDocument-C7mV8NQn.js → SnapshotDocument-TKnFyGcv.js} +1 -1
- package/dist/viewer/{SplitFrame-zVgYFiT_.js → SplitFrame-CLquf6QT.js} +1 -1
- package/dist/viewer/StoryboardLayout-DB9qGegh.js +1 -0
- package/dist/viewer/{StoryboardRender-CjFlWvlf.js → StoryboardRender-CX00jo8v.js} +1 -1
- package/dist/viewer/ThreadView-D_g4kidg.js +1 -0
- package/dist/viewer/{Tooltip-Bi4V2FVJ.js → Tooltip-CZKrDYnF.js} +1 -1
- package/dist/viewer/VerifyLayout-DgokULV2.js +1 -0
- package/dist/viewer/{VirtualizedEditor-uWe43zaI-CgOwRELB.js → VirtualizedEditor-uWe43zaI-BlOdeG0b.js} +1 -1
- package/dist/viewer/{VirtualizedRenderer-C_d95FXi-DiZVcTAc.js → VirtualizedRenderer-C_d95FXi-Bb6aPJaZ.js} +1 -1
- package/dist/viewer/{WarningsBadge-CyQbVl6h.js → WarningsBadge-D4Oo4UxO.js} +1 -1
- package/dist/viewer/WhiteboardEditor-DrHOvXez-DTa-K6Xu.js +22 -0
- package/dist/viewer/WhiteboardLayout-F1J1rwTl.js +4 -0
- package/dist/viewer/{WritingCursor-CLEFH9bN.js → WritingCursor-6VjqhSXi.js} +1 -1
- package/dist/viewer/agentLook-60JQrptF.js +1 -0
- package/dist/viewer/{artifact-list-CuXyveqX.js → artifact-list-BuB3wom1.js} +1 -1
- package/dist/viewer/auto-publish-BfutdvfM.js +1 -0
- package/dist/viewer/channel-DST3ZfoT.js +4 -0
- package/dist/viewer/comments-CASb0ByE.js +1 -0
- package/dist/viewer/context-Dt460deL.js +1 -0
- package/dist/viewer/{crop-encode-7FeBhORX.js → crop-encode-BnAM7iWo.js} +1 -1
- package/dist/viewer/{dist-DknksWkX.js → dist-2resm9Wy.js} +1 -1
- package/dist/viewer/{dist-f8YElrUw.js → dist-462HZ4sr.js} +1 -1
- package/dist/viewer/{dist-BKkO1Omj.js → dist-B7GHMwWJ.js} +1 -1
- package/dist/viewer/{dist-Ci8SGeFw.js → dist-B9cyrbzi.js} +1 -1
- package/dist/viewer/{dist-SwdVvEpO.js → dist-Bost_p8b.js} +1 -1
- package/dist/viewer/{dist-i1Gf9O6b.js → dist-Bw8MOHnL.js} +1 -1
- package/dist/viewer/{dist-DQI2slI5.js → dist-CAQYce5C.js} +1 -1
- package/dist/viewer/{dist-DW1-cTNS.js → dist-CEyDZYnP.js} +1 -1
- package/dist/viewer/{dist-CskHZfMU.js → dist-CJicYh3N.js} +1 -1
- package/dist/viewer/{dist-BD6XPyPx.js → dist-CLdHiTLp.js} +1 -1
- package/dist/viewer/{dist-1y-5eBAw.js → dist-CNry8POH.js} +1 -1
- package/dist/viewer/{dist-h__DIjgw.js → dist-CXJ-dwdV.js} +1 -1
- package/dist/viewer/{dist-D0fC7ysz.js → dist-Cfyg-ZFz.js} +1 -1
- package/dist/viewer/dist-CkWqj1vB.js +1 -0
- package/dist/viewer/{dist-Do_0jRES.js → dist-CrYVEXMn.js} +1 -1
- package/dist/viewer/{dist-D8T-VMuH.js → dist-D26TaXjP.js} +1 -1
- package/dist/viewer/{dist-h2T27ekx.js → dist-D32zdSlG.js} +1 -1
- package/dist/viewer/{dist-BI0qFRAy.js → dist-DUysbnVD.js} +1 -1
- package/dist/viewer/{dist-BQ22B1dL.js → dist-DV8S7O88.js} +1 -1
- package/dist/viewer/{dist-DqZiUlRF.js → dist-DlFC92UU.js} +1 -1
- package/dist/viewer/{dist-IhKVX0N7.js → dist-Dr8Mok4z.js} +1 -1
- package/dist/viewer/{dist-CvSBK4r1.js → dist-Dz80ecx_.js} +1 -1
- package/dist/viewer/{dist-Bo1t4X-Z.js → dist-N6Hpo5Ed.js} +1 -1
- package/dist/viewer/{dist-3kOakO1C.js → dist-gLcMD1Nm.js} +1 -1
- package/dist/viewer/{dist-V7e95zqk.js → dist-opUfcW4x.js} +1 -1
- package/dist/viewer/{editor-CLF22MpT.js → editor-rLQcZykK.js} +13 -13
- package/dist/viewer/{fit-BQe9RV4E.js → fit-C4QfFtXk.js} +1 -1
- package/dist/viewer/{icons-CCSPm9SD.js → icons-CDVhjQMS.js} +1 -1
- package/dist/viewer/{imperative-BeC0q_ho.js → imperative-CXmLprLo.js} +1 -1
- package/dist/viewer/index.html +11 -12
- package/dist/viewer/index.js +2 -2
- package/dist/viewer/index4.css +1 -1
- package/dist/viewer/index5.css +13 -0
- package/dist/viewer/{jump-history-B-4GHf3_.js → jump-history-Dyva9tQM.js} +1 -1
- package/dist/viewer/{local-DjzZ1b9A.js → local-B-SW6cqA.js} +1 -1
- package/dist/viewer/local-split-host-BGpkEBjP.js +1 -0
- package/dist/viewer/{plugin-_bGVeqI0-D20LzbhT.js → plugin-_bGVeqI0-C4RRMCGb.js} +2 -2
- package/dist/viewer/preview.html +3 -3
- package/dist/viewer/preview.js +1 -1
- package/dist/viewer/{printDocument-DmnjWjBu.js → printDocument-BhGNF0gC.js} +1 -1
- package/dist/viewer/{ref-DjRYiP25.js → ref-BrUHq8E2.js} +1 -1
- package/dist/viewer/{ref-problem-DkSEcIQm.js → ref-problem-Cvl83U9T.js} +1 -1
- package/dist/viewer/{route-BEA0O_Ry.js → route-i3jkzu-i.js} +2 -2
- package/dist/viewer/{route-messages-o8lg2hOP.js → route-messages-MxWI01S2.js} +1 -1
- package/dist/viewer/settings-BSB6g2PC.js +1 -0
- package/dist/viewer/snap-iBOqhRtA.js +1 -0
- package/dist/viewer/split-CxmPPvad.js +2 -0
- package/dist/viewer/{stable-DP74aChD.js → stable-CK-LXZNI.js} +1 -1
- package/dist/viewer/{styles-BtwjIslZ.js → styles-Dtxz8FDa.js} +1 -1
- package/dist/viewer/transport-ork1P0iQ.js +1 -0
- package/dist/viewer/url-Buh8E05T.js +29 -0
- package/dist/viewer/{useArtifactFeed-CYcXA6yE.js → useArtifactFeed-lKf4zuoV.js} +1 -1
- package/dist/viewer/useCommentPrimary-YlizG1nk.js +1 -0
- package/dist/viewer/useDrafts-WX84YtG1.js +1 -0
- package/dist/viewer/{useLayerZIndex-C1JpT09z.js → useLayerZIndex-C75Wfz8T.js} +1 -1
- package/dist/viewer/useRefBoard-0QUs4dWN.js +1 -0
- package/dist/viewer/{useStoryboardData-CbleqK_E.js → useStoryboardData-BYHJhILA.js} +1 -1
- package/dist/viewer/{view-Bw41z8XN.js → view-BOFvn2hm.js} +1 -1
- package/dist/viewer/view-drafts-DXKEb89H.js +1 -0
- package/dist/viewer/{viewport-CFJHn_Y6-GTpeksto.js → viewport-CFJHn_Y6-B_DJWWd0.js} +1 -1
- package/package.json +2 -2
- package/dist/viewer/ArtboardLayout-BNViVZgT.js +0 -14
- package/dist/viewer/ArtifactList-3kGz4_Vv.js +0 -2
- package/dist/viewer/DocumentLayout-BxFYyKFq.js +0 -2
- package/dist/viewer/DocumentPage-CP8Qy9Ae.js +0 -5
- package/dist/viewer/DropdownMenu-Dza6-jeN.js +0 -1
- package/dist/viewer/MenuSubmenuTrigger-CLeiXsan.js +0 -1
- package/dist/viewer/PreviewArtifactLayout-NXoiF_BV.js +0 -1
- package/dist/viewer/PreviewLayout-eg8-py8p.js +0 -2
- package/dist/viewer/ReportLayout-w7Tkbjp6.js +0 -6
- package/dist/viewer/SelectScrollUpArrow-BFRXZrFq.js +0 -1
- package/dist/viewer/SlidesLayout-B1mwiNJH.js +0 -12
- package/dist/viewer/StoryboardLayout-CWuqD7XK.js +0 -1
- package/dist/viewer/ThreadView-DTGR5uqU.js +0 -1
- package/dist/viewer/VerifyLayout-DtRz6K2y.js +0 -1
- package/dist/viewer/WhiteboardEditor-DrHOvXez-Bd1MyHmC.js +0 -22
- package/dist/viewer/WhiteboardLayout-D-gmpAvD.js +0 -4
- package/dist/viewer/agentLook-BPPrbQJ3.js +0 -1
- package/dist/viewer/auto-publish-DK402eHG.js +0 -1
- package/dist/viewer/channel-RZcAq9dq.js +0 -4
- package/dist/viewer/comments-DUAz1Q9X.js +0 -1
- package/dist/viewer/dist-BjB8i81Z.js +0 -1
- package/dist/viewer/local-split-host-CeKHc_JX.js +0 -1
- package/dist/viewer/settings-BQ3tJuXQ.js +0 -1
- package/dist/viewer/snap-Dh3ZoMla.js +0 -1
- package/dist/viewer/split-BZPaH4G4.js +0 -2
- package/dist/viewer/transport-7BF3TWU4.js +0 -1
- package/dist/viewer/url-BaZreTXB.js +0 -29
- package/dist/viewer/useArtifactSocket-CZwBSmOD.js +0 -1
- package/dist/viewer/useRefBoard-Cj5dzC4F.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./VirtualizedEditor-uWe43zaI-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{A as t,C as n,E as r,S as i,f as a,j as o}from"./route-BEA0O_Ry.js";/* empty css */import{t as s}from"./react-DlmbjZJV.js";import{Er as c,F as l,Gn as u,Jn as d,Kn as f,P as p,Tr as m,Yn as h,_r as g,br as _,dr as v,hr as y,lt as b,pr as x,qn as S,sr as C,ur as w,vr as T,xr as E,yr as D}from"./url-BaZreTXB.js";import{t as O}from"./jsx-runtime-LKYXHABd.js";import{En as k}from"./useLayerZIndex-C1JpT09z.js";import{Dt as A,m as j}from"./MotionConfigContext-BqjwrGj9.js";import{$ as M,$i as N,$n as P,$r as F,$t as I,Aa as L,An as R,Ar as z,At as B,B as V,Ba as H,Bi as U,Bn as ee,Br as te,Bt as ne,Ca as re,Ci as ie,Cn as ae,Cr as W,Ct as oe,Da as se,Di as ce,Dn as le,Dr as ue,Dt as de,Ea as fe,Ei as pe,En as me,Er as he,Et as ge,F as _e,Fa as ve,Fi as ye,Fn as be,Fr as xe,Ft as Se,G as Ce,Ga as we,Gi as Te,Gn as Ee,Gr as De,Gt as Oe,H as ke,Ha as Ae,Hi as je,Hn as Me,Hr as Ne,Ht as Pe,I as Fe,Ia as Ie,Ii as Le,In as Re,Ir as ze,It as Be,J as Ve,Jn as He,Jr as Ue,Jt as We,K as Ge,Ki as Ke,Kn as qe,Kr as Je,Kt as Ye,L as Xe,La as eee,Li as tee,Ln as nee,Lr as Ze,Lt as ree,Ma as Qe,Mi as $e,Mn as iee,Mr as et,Mt as tt,Na as nt,Ni as rt,Nn as aee,Nr as it,Nt as at,Oa as oee,Oi as ot,On as st,Or as see,Ot as ct,P as cee,Pa as lt,Pi as ut,Pn as lee,Pr as dt,Pt as uee,Q as dee,Qi as fee,Qn as ft,Qr as pt,Qt as mt,Ra as ht,Ri as gt,Rn as _t,Rr as pee,Rt as mee,Sa as vt,Si as hee,Sn as yt,Sr as bt,St as xt,Ta as St,Ti as gee,Tn as _ee,Tr as Ct,Tt as vee,U as yee,Ua as bee,Ui as xee,Un as wt,Ur as Tt,Ut as Et,V as See,Va as Dt,Vi as Ot,Vn as kt,Vr as Cee,Vt as At,W as wee,Wa as jt,Wi as Mt,Wn as Nt,Wr as Pt,Wt as Tee,X as Eee,Xi as Ft,Xn as Dee,Xr as It,Xt as Lt,Y as Rt,Yi as zt,Yn as Bt,Yr as Vt,Yt as Ht,Z as Ut,Zi as Wt,Zn as Gt,Zr as Kt,Zt as qt,_ as Oee,_a as kee,_i as Jt,_n as Yt,_r as Xt,_t as Aee,aa as jee,ai as Mee,an as Zt,ar as Nee,at as Pee,ba as Fee,bi as Qt,bn as $t,br as Iee,bt as en,ca as tn,ci as nn,cn as rn,cr as an,ct as Lee,d as Ree,da as on,di as sn,dn as zee,dr as cn,dt as Bee,ea as ln,ei as un,en as dn,er as fn,et as pn,f as Vee,fa as Hee,fi as mn,fn as hn,ft as gn,g as Uee,ga as Wee,gi as _n,gn as Gee,gr as vn,gt as yn,h as bn,ha as xn,hi as Sn,hn as Cn,hr as Kee,ht as wn,ia as qee,ii as Tn,in as En,ir as Dn,it as On,ja as kn,ji as An,jn as Jee,jr as jn,jt as Mn,ka as Nn,ki as Yee,kn as Xee,kr as Pn,kt as Fn,la as Zee,li as Qee,ln as $ee,lr as In,lt as ete,ma as Ln,mi as Rn,mn as zn,mr as tte,mt as Bn,n as nte,na as Vn,ni as Hn,nn as rte,nr as Un,nt as ite,o as ate,oa as ote,oi as Wn,on as Gn,or as ste,ot as Kn,p as cte,pa as qn,pi as Jn,pn as Yn,pr as lte,pt as Xn,q as Zn,qi as Qn,qn as ute,qr as $n,qt as dte,r as fte,ra as er,ri as tr,rn as nr,rr as pte,rt as mte,s as hte,sa as rr,si as gte,sn as ir,sr as _te,st as ar,ta as or,ti as sr,tn as cr,tr as lr,tt as ur,ua as vte,ui as yte,un as dr,ur as bte,ut as xte,v as Ste,va as fr,vi as pr,vn as mr,vr as hr,vt as Cte,wa as gr,wn as _r,wr as vr,wt as wte,x as Tte,xa as yr,xi as br,xn as xr,xr as Sr,xt as Ete,y as Cr,ya as wr,yi as Tr,yn as Er,yr as Dte,yt as Ote,z as kte,za as Dr,zn as Or,zr as kr,zt as Ate}from"./WhiteboardEditor-DrHOvXez-Bd1MyHmC.js";import{a as jte}from"./Tooltip-Bi4V2FVJ.js";import{P as Mte,j as Nte,t as Pte}from"./Popover-HS6yjzxl.js";import{n as Fte,r as Ar,t as jr}from"./pen-tool-B7HWrrcR.js";import{t as Ite}from"./chevron-right-DBC0wrKu.js";import{n as Mr,r as Nr}from"./stringifyLocale-VcrwrbQl.js";import{t as Pr}from"./code-CTMZ5SpG.js";import{a as Lte,i as Rte,n as zte,o as Bte,r as Fr,s as Vte,t as Hte}from"./underline-AY5gu1iN.js";import{F as Ir,P as Ute}from"./SelectScrollUpArrow-BFRXZrFq.js";import{a as Wte,n as Gte,o as Kte,r as qte,s as Jte,t as Yte}from"./text-align-start-CO9CK_EW.js";import{s as Xte}from"./route-messages-o8lg2hOP.js";import{n as Zte,t as Qte}from"./table-2-F7QzFSYG.js";import{a as $te,r as ene}from"./ruler-DmQbsUQf.js";import{n as Lr,t as tne}from"./video-tvDNJEhe.js";import{t as nne}from"./maximize-2-Deo2WY_L.js";import{t as Rr}from"./message-square-BQbestX7.js";import{n as rne}from"./undo-2-BH3P-I_n.js";import{t as zr}from"./plus-C3ivaMGn.js";import{t as ine}from"./presentation-qzIErT_u.js";import{c as ane,l as one,o as Br,r as sne,t as cne}from"./ThreadView-DTGR5uqU.js";import{t as lne}from"./search-EBZOryv1.js";import{t as une}from"./shield-check-TdIPOf4j.js";import{t as dne}from"./sliders-horizontal-DZKoxRty.js";import{t as fne}from"./upload-D0s2oA1h.js";import{r as Vr,t as pne}from"./agentLook-BPPrbQJ3.js";import{t as Hr}from"./DotGrid-DKKr_PyM.js";import{a as mne,o as hne,r as gne,s as _ne,t as vne}from"./rounds-DC6Dulo5.js";import{t as Ur}from"./comments-DUAz1Q9X.js";import{n as yne}from"./useMedia-CFebB4XU.js";import{t as bne}from"./BottomSheet-SYC_8Y6k.js";import{a as Wr,i as Gr,n as xne,o as Kr}from"./motion-Cy65kd7X.js";import{n as Sne}from"./preference-oNdcNeml.js";import{a as qr,n as Jr,t as Yr}from"./ref-DjRYiP25.js";import{n as Cne,t as wne}from"./useSandboxFrame-CJmSnwgG.js";var Xr={name:`align-center-vertical`,size:24,node:[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4`,key:`14d6g8`}],[`path`,{d:`M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4`,key:`1e2lrw`}],[`path`,{d:`M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1`,key:`1fkdwx`}],[`path`,{d:`M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1`,key:`1euafb`}]]};Xr.node;var Tne=A(Xr),Zr={name:`align-end-vertical`,size:24,node:[[`rect`,{width:`16`,height:`6`,x:`2`,y:`4`,rx:`2`,key:`10wcwx`}],[`rect`,{width:`9`,height:`6`,x:`9`,y:`14`,rx:`2`,key:`4p5bwg`}],[`path`,{d:`M22 22V2`,key:`12ipfv`}]]};Zr.node;var Ene=A(Zr),Qr={name:`align-start-vertical`,size:24,node:[[`rect`,{width:`9`,height:`6`,x:`6`,y:`14`,rx:`2`,key:`lpm2y7`}],[`rect`,{width:`16`,height:`6`,x:`6`,y:`4`,rx:`2`,key:`rdj6ps`}],[`path`,{d:`M2 2v20`,key:`1ivd8o`}]]};Qr.node;var Dne=A(Qr),$r={name:`app-window`,size:24,node:[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]};$r.node;var One=A($r),ei={name:`arrow-left-to-line`,size:24,node:[[`path`,{d:`M3 19V5`,key:`rwsyhb`}],[`path`,{d:`m13 6-6 6 6 6`,key:`1yhaz7`}],[`path`,{d:`M7 12h14`,key:`uoisry`}]]};ei.node;var kne=A(ei),ti={name:`at-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]};ti.node;var Ane=A(ti),ni={name:`boxes`,size:24,node:[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]};ni.node;var jne=A(ni),ri={name:`chart-column-big`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`rect`,{x:`15`,y:`5`,width:`4`,height:`12`,rx:`1`,key:`q8uenq`}],[`rect`,{x:`7`,y:`8`,width:`4`,height:`9`,rx:`1`,key:`sr5ea`}]],aliases:[`bar-chart-big`]};ri.node;var ii=A(ri),ai={name:`chevrons-down-up`,size:24,node:[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]};ai.node;var Mne=A(ai),oi={name:`clipboard`,size:24,node:[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}]]};oi.node;var Nne=A(oi),si={name:`flag`,size:24,node:[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]};si.node;var ci=A(si),li={name:`footprints`,size:24,node:[[`path`,{d:`M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 1 1-4 0Z`,key:`1dudjm`}],[`path`,{d:`M20 20v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C14.63 6 14 7.8 14 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 1 0 4 0Z`,key:`l2t8xc`}],[`path`,{d:`M16 17h4`,key:`1dejxt`}],[`path`,{d:`M4 13h4`,key:`1bwh8b`}]]};li.node;var Pne=A(li),ui={name:`heading-1`,size:24,node:[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`m17 12 3-2v8`,key:`1hhhft`}]]};ui.node;var Fne=A(ui),di={name:`heading-2`,size:24,node:[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1`,key:`9jr5yi`}]]};di.node;var Ine=A(di),fi={name:`heading-3`,size:24,node:[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2`,key:`68ncm8`}],[`path`,{d:`M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2`,key:`1ejuhz`}]]};fi.node;var Lne=A(fi),pi={name:`languages`,size:24,node:[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]};pi.node;var mi=A(pi),hi={name:`lightbulb`,size:24,node:[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]};hi.node;var gi=A(hi),_i={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};_i.node;var Rne=A(_i),vi={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};vi.node;var zne=A(vi),yi={name:`message-square-code`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`m10 8-3 3 3 3`,key:`fp6dz7`}],[`path`,{d:`m14 14 3-3-3-3`,key:`1yrceu`}]]};yi.node;var Bne=A(yi),bi={name:`message-square-exclamation-point`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 15h.01`,key:`q59x07`}],[`path`,{d:`M12 7v4`,key:`xawao1`}]],aliases:[`message-square-warning`,`message-square-alert`]};bi.node;var xi=A(bi),Si={name:`message-square-quote`,size:24,node:[[`path`,{d:`M14 14a2 2 0 0 0 2-2V8h-2`,key:`1r06pg`}],[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M8 14a2 2 0 0 0 2-2V8H8`,key:`1jzu5j`}]]};Si.node;var Vne=A(Si),Ci={name:`octagon-exclamation-point`,size:24,node:[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]],aliases:[`alert-octagon`,`octagon-alert`]};Ci.node;var wi=A(Ci),Ti={name:`paperclip`,size:24,node:[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]};Ti.node;var Ei=A(Ti),Di={name:`rectangle-horizontal`,size:24,node:[[`rect`,{x:`2`,y:`5`,width:`20`,height:`14`,rx:`2`,key:`qneu4z`}]]};Di.node;var Hne=A(Di),Oi={name:`redo`,size:24,node:[[`path`,{d:`M21 7v6h-6`,key:`3ptur4`}],[`path`,{d:`M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7`,key:`1kgawr`}]]};Oi.node;var Une=A(Oi),ki={name:`remove-formatting`,size:24,node:[[`path`,{d:`M4 7V4h16v3`,key:`9msm58`}],[`path`,{d:`M5 20h6`,key:`1h6pxn`}],[`path`,{d:`M13 4 8 20`,key:`kqq6aj`}],[`path`,{d:`m15 15 5 5`,key:`me55sn`}],[`path`,{d:`m20 15-5 5`,key:`11p7ol`}]]};ki.node;var Wne=A(ki),Ai={name:`replace`,size:24,node:[[`path`,{d:`M14 4a1 1 0 0 1 1-1`,key:`dhj8ez`}],[`path`,{d:`M15 10a1 1 0 0 1-1-1`,key:`1mnyi5`}],[`path`,{d:`M21 4a1 1 0 0 0-1-1`,key:`sfs9ap`}],[`path`,{d:`M21 9a1 1 0 0 1-1 1`,key:`mp6qeo`}],[`path`,{d:`m3 7 3 3 3-3`,key:`x25e72`}],[`path`,{d:`M6 10V5a2 2 0 0 1 2-2h2`,key:`15xut4`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}]]};Ai.node;var Gne=A(Ai),ji={name:`sigma`,size:24,node:[[`path`,{d:`M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2`,key:`wuwx1p`}]]};ji.node;var Mi=A(ji),Ni={name:`subscript`,size:24,node:[[`path`,{d:`m4 5 8 8`,key:`1eunvl`}],[`path`,{d:`m12 5-8 8`,key:`1ah0jp`}],[`path`,{d:`M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07`,key:`e8ta8j`}]]};Ni.node;var Kne=A(Ni),Pi={name:`superscript`,size:24,node:[[`path`,{d:`m4 19 8-8`,key:`hr47gm`}],[`path`,{d:`m12 19-8-8`,key:`1dhhmo`}],[`path`,{d:`M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06`,key:`1dfcux`}]]};Pi.node;var qne=A(Pi),Fi={name:`table`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]};Fi.node;var Jne=A(Fi),Ii={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};Ii.node;var Li=A(Ii),Ri={name:`text-quote`,size:24,node:[[`path`,{d:`M17 5H3`,key:`1cn7zz`}],[`path`,{d:`M21 12H8`,key:`scolzb`}],[`path`,{d:`M21 19H8`,key:`13qgcb`}],[`path`,{d:`M3 12v7`,key:`1ri8j3`}]]};Ri.node;var Yne=A(Ri),zi={name:`undo`,size:24,node:[[`path`,{d:`M3 7v6h6`,key:`1v2h90`}],[`path`,{d:`M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13`,key:`1r6uu6`}]]};zi.node;var Xne=A(zi),Bi={name:`unlink`,size:24,node:[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]};Bi.node;var Vi=A(Bi),Hi={name:`vote`,size:24,node:[[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}],[`path`,{d:`M5 7c0-1.1.9-2 2-2h10a2 2 0 0 1 2 2v12H5V7Z`,key:`1ezoue`}],[`path`,{d:`M22 19H2`,key:`nuriw5`}]]};Hi.node;var Zne=A(Hi),Ui={name:`workflow`,size:24,node:[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]};Ui.node;var Wi=A(Ui),G=e(s(),1),K=O(),Gi=e(t(),1),Qne=[[`flowchart`,`flowchart-elk`,/^\s*flowchart-elk/],[`mindmap`,`mindmap`,/^\s*mindmap/],[`architecture`,`architecture`,/^\s*architecture/],[`agentflow`,`agentflow`,/^\s*agentflow-beta\b/],[`c4`,`c4`,/^\s*(?:C4Context|C4Container|C4Component|C4Dynamic|C4Deployment)/],[`kanban`,`kanban`,/^\s*kanban/],[`class`,`classDiagram`,/^\s*classDiagram/],[`er`,`er`,/^\s*erDiagram/],[`gantt`,`gantt`,/^\s*gantt/],[`info`,`info`,/^\s*info/],[`pie`,`pie`,/^\s*pie/],[`requirement`,`requirement`,/^\s*requirement(Diagram)?/],[`sequence`,`sequence`,/^\s*sequenceDiagram/],[`swimlane`,`swimlane`,/^\s*swimlane-beta\b/],[`flowchart`,`flowchart-v2`,/^\s*(graph|flowchart)/],[`timeline`,`timeline`,/^\s*timeline/],[`gitGraph`,`gitGraph`,/^\s*gitGraph/],[`state`,`stateDiagram`,/^\s*stateDiagram/],[`journey`,`journey`,/^\s*journey/],[`quadrantChart`,`quadrantChart`,/^\s*quadrantChart/],[`sankey`,`sankey`,/^\s*sankey(-beta)?/],[`packet`,`packet`,/^\s*packet(-beta)?/],[`xychart`,`xychart`,/^\s*xychart(-beta)?/],[`block`,`block`,/^\s*block(-beta)?/],[`eventmodeling`,`eventmodeling`,/^\s*eventmodeling/],[`treeView`,`treeView`,/^\s*treeView-beta/],[`radar`,`radar`,/^\s*radar-beta/],[`ishikawa`,`ishikawa`,/^\s*ishikawa(-beta)?\b/i],[`treemap`,`treemap`,/^\s*treemap/],[`railroad`,`railroad`,/^\s*railroad-beta/i],[`railroad`,`railroadEbnf`,/^\s*railroad-ebnf-beta/i],[`railroad`,`railroadAbnf`,/^\s*railroad-abnf-beta/i],[`railroad`,`railroadPeg`,/^\s*railroad-peg-beta/i],[`venn`,`venn`,/^\s*venn-beta/],[`wardley`,`wardley`,/^\s*wardley-beta/i],[`cynefin`,`cynefin`,/^\s*cynefin-beta(?:[\s:]|$)/],[`usecase`,`usecase`,/^\s*usecase-beta(?:\s|$)/]];function $ne(e){for(let[t,n,r]of Qne)if(r.test(e))return{type:t,mermaidType:n};return null}var Ki=class extends Error{code;type;mermaidType;line;column;snippet;constructor(e,t=`syntax`,n={}){super(e),this.name=`PeleError`,this.code=t,this.type=n.type??null,this.mermaidType=n.mermaidType??null,this.line=n.line??0,this.column=n.column??0,this.snippet=n.snippet??``}};function qi(e,t,n){return Array.from(e.matchAll(t),e=>[e.index,e.index+e[0].length,n])}function ere(e,t){let n=0;for(let[r,i,a]of e){let e=r-n;if(t<e)break;if(t<e+a)return r+Math.min(t-e,i-r-1);n+=i-r-a}return t+n}function Ji(e,t){for(let n=e.length-1;n>=0;n--)t=ere(e[n],t);return t}var Yi;function tre(e,t){let n=Yi;Yi=e;try{return t()}finally{Yi=n}}function Xi(e,t){return Yi!==void 0&&e===Yi.parsed?Yi.find(t):[e,t]}function Zi(e,t){let n=e.trimEnd().length;n>0&&t>=n?([e,t]=Xi(e,n-1),t++):[e,t]=Xi(e,t);let r=1,i=0;for(let n=e.indexOf(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./VirtualizedEditor-uWe43zaI-BlOdeG0b.js","./rolldown-runtime-XKyaHtl9.js","./viewport-CFJHn_Y6-B_DJWWd0.js","./WhiteboardEditor-DrHOvXez-DTa-K6Xu.js","./route-i3jkzu-i.js","./bem-vbke-3KC.js","./react-DlmbjZJV.js","./jsx-runtime-LKYXHABd.js","./types-BCsOeYI6.js","./index2.css","./url-Buh8E05T.js","./useLayerZIndex-C75Wfz8T.js","./MotionConfigContext-BqjwrGj9.js","./is-html-element-DvgHo_1h.js","./Popover-DxR9Dpf_.js","./chevron-right-DBC0wrKu.js","./stringifyLocale-VcrwrbQl.js","./code-CTMZ5SpG.js","./SelectScrollUpArrow-bXyfVgGf.js","./zoom-out-Cz3087-F.js","./text-align-start-CO9CK_EW.js","./ruler-DmQbsUQf.js","./maximize-2-Deo2WY_L.js","./mouse-pointer-2-naHRayvu.js","./undo-2-BH3P-I_n.js","./plus-C3ivaMGn.js","./MenuSubmenuTrigger-CPcD7vNW.js","./index3.css","./katex-DuZJ-tFh.js","./dist-D26TaXjP.js","./dist-DV8S7O88.js","./dist-CLdHiTLp.js","./dist-2resm9Wy.js","./dist-Bost_p8b.js","./dist-462HZ4sr.js","./dist-Dr8Mok4z.js","./dist-B7GHMwWJ.js","./dist-CrYVEXMn.js","./dist-Bw8MOHnL.js","./dist-B9cyrbzi.js","./dist-CAQYce5C.js","./dist-opUfcW4x.js","./dist-CEyDZYnP.js","./dist-Dz80ecx_.js","./dist-N6Hpo5Ed.js","./dist-CJicYh3N.js","./dist-DUysbnVD.js","./dist-DlFC92UU.js","./dist-Cfyg-ZFz.js","./dist-D32zdSlG.js","./dockerfile-DJkHQgkl.js","./simple-mode-DXiLM1-G.js","./factor-LKH5gN8L.js","./nsis-viPvXFiq.js","./pug-BqCHZ5xT.js","./javascript-lS2r2ifg.js","./dist-gLcMD1Nm.js","./dist-CNry8POH.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{A as t,C as n,E as r,S as i,f as a,j as o}from"./route-i3jkzu-i.js";/* empty css */import{t as s}from"./react-DlmbjZJV.js";import{$n as c,Ar as l,B as u,Cr as d,Er as f,Qn as p,Sr as m,Tr as h,Xn as g,Zn as _,br as v,er as y,fr as b,gr as x,hr as S,jr as C,mt as w,vr as T,wr as E,z as D}from"./url-Buh8E05T.js";import{t as O}from"./jsx-runtime-LKYXHABd.js";import{En as k}from"./useLayerZIndex-C75Wfz8T.js";import{Dt as A,m as j}from"./MotionConfigContext-BqjwrGj9.js";import{$ as M,$i as N,$n as P,$r as F,$t as I,Aa as L,An as R,Ar as z,At as B,B as V,Ba as H,Bi as U,Bn as ee,Br as te,Bt as ne,Ca as re,Ci as ie,Cn as ae,Cr as W,Ct as oe,Da as se,Di as ce,Dn as le,Dr as ue,Dt as de,Ea as fe,Ei as pe,En as me,Er as he,Et as ge,F as _e,Fa as ve,Fi as ye,Fn as be,Fr as xe,Ft as Se,G as Ce,Ga as we,Gi as Te,Gn as Ee,Gr as De,Gt as Oe,H as ke,Ha as Ae,Hi as je,Hn as Me,Hr as Ne,Ht as Pe,I as Fe,Ia as Ie,Ii as Le,In as Re,Ir as ze,It as Be,J as Ve,Jn as He,Jr as Ue,Jt as We,K as Ge,Ki as Ke,Kn as qe,Kr as Je,Kt as Ye,L as Xe,La as eee,Li as tee,Ln as nee,Lr as Ze,Lt as ree,Ma as Qe,Mi as $e,Mn as iee,Mr as et,Mt as tt,Na as nt,Ni as rt,Nn as aee,Nr as it,Nt as at,Oa as oee,Oi as ot,On as st,Or as see,Ot as ct,P as cee,Pa as lt,Pi as ut,Pn as lee,Pr as dt,Pt as uee,Q as dee,Qi as fee,Qn as ft,Qr as pt,Qt as mt,Ra as ht,Ri as gt,Rn as _t,Rr as pee,Rt as mee,Sa as vt,Si as hee,Sn as yt,Sr as bt,St as xt,Ta as St,Ti as gee,Tn as _ee,Tr as Ct,Tt as vee,U as yee,Ua as bee,Ui as xee,Un as wt,Ur as Tt,Ut as Et,V as See,Va as Dt,Vi as Ot,Vn as kt,Vr as Cee,Vt as At,W as wee,Wa as jt,Wi as Mt,Wn as Nt,Wr as Pt,Wt as Tee,X as Eee,Xi as Ft,Xn as Dee,Xr as It,Xt as Lt,Y as Rt,Yi as zt,Yn as Bt,Yr as Vt,Yt as Ht,Z as Ut,Zi as Wt,Zn as Gt,Zr as Kt,Zt as qt,_ as Oee,_a as kee,_i as Jt,_n as Yt,_r as Xt,_t as Aee,aa as jee,ai as Mee,an as Zt,ar as Nee,at as Pee,ba as Fee,bi as Qt,bn as $t,br as Iee,bt as en,ca as tn,ci as nn,cn as rn,cr as an,ct as Lee,d as Ree,da as on,di as sn,dn as zee,dr as cn,dt as Bee,ea as ln,ei as un,en as dn,er as fn,et as pn,f as Vee,fa as Hee,fi as mn,fn as hn,ft as gn,g as Uee,ga as Wee,gi as _n,gn as Gee,gr as vn,gt as yn,h as bn,ha as xn,hi as Sn,hn as Cn,hr as Kee,ht as wn,ia as qee,ii as Tn,in as En,ir as Dn,it as On,ja as kn,ji as An,jn as Jee,jr as jn,jt as Mn,ka as Nn,ki as Yee,kn as Xee,kr as Pn,kt as Fn,la as Zee,li as Qee,ln as $ee,lr as In,lt as ete,ma as Ln,mi as Rn,mn as zn,mr as tte,mt as Bn,n as nte,na as Vn,ni as Hn,nn as rte,nr as Un,nt as ite,o as ate,oa as ote,oi as Wn,on as Gn,or as ste,ot as Kn,p as cte,pa as qn,pi as Jn,pn as Yn,pr as lte,pt as Xn,q as Zn,qi as Qn,qn as ute,qr as $n,qt as dte,r as fte,ra as er,ri as tr,rn as nr,rr as pte,rt as mte,s as hte,sa as rr,si as gte,sn as ir,sr as _te,st as ar,ta as or,ti as sr,tn as cr,tr as lr,tt as ur,ua as vte,ui as yte,un as dr,ur as bte,ut as xte,v as Ste,va as fr,vi as pr,vn as mr,vr as hr,vt as Cte,wa as gr,wn as _r,wr as vr,wt as wte,x as Tte,xa as yr,xi as br,xn as xr,xr as Sr,xt as Ete,y as Cr,ya as wr,yi as Tr,yn as Er,yr as Dte,yt as Ote,z as kte,za as Dr,zn as Or,zr as kr,zt as Ate}from"./WhiteboardEditor-DrHOvXez-DTa-K6Xu.js";import{a as jte}from"./Tooltip-CZKrDYnF.js";import{P as Mte,j as Nte,t as Pte}from"./Popover-DxR9Dpf_.js";import{n as Fte,r as Ar,t as jr}from"./pen-tool-B7HWrrcR.js";import{t as Ite}from"./chevron-right-DBC0wrKu.js";import{n as Mr,r as Nr}from"./stringifyLocale-VcrwrbQl.js";import{t as Pr}from"./code-CTMZ5SpG.js";import{a as Lte,i as Rte,n as zte,o as Bte,r as Fr,s as Vte,t as Hte}from"./underline-AY5gu1iN.js";import{F as Ir,P as Ute}from"./SelectScrollUpArrow-bXyfVgGf.js";import{a as Wte,n as Gte,o as Kte,r as qte,s as Jte,t as Yte}from"./text-align-start-CO9CK_EW.js";import{s as Xte}from"./route-messages-MxWI01S2.js";import{n as Zte,t as Qte}from"./table-2-F7QzFSYG.js";import{a as $te,r as ene}from"./ruler-DmQbsUQf.js";import{n as Lr,t as tne}from"./video-tvDNJEhe.js";import{t as nne}from"./maximize-2-Deo2WY_L.js";import{t as Rr}from"./message-square-BQbestX7.js";import{n as rne}from"./undo-2-BH3P-I_n.js";import{t as zr}from"./plus-C3ivaMGn.js";import{t as ine}from"./presentation-qzIErT_u.js";import{d as ane,o as Br,r as one,t as sne,u as cne}from"./ThreadView-D_g4kidg.js";import{t as lne}from"./search-EBZOryv1.js";import{t as une}from"./shield-check-TdIPOf4j.js";import{t as dne}from"./sliders-horizontal-DZKoxRty.js";import{t as fne}from"./upload-D0s2oA1h.js";import{r as Vr,t as pne}from"./agentLook-60JQrptF.js";import{t as Hr}from"./DotGrid-DKKr_PyM.js";import{t as Ur}from"./comments-CASb0ByE.js";import{a as mne,o as hne,r as gne,s as _ne,t as vne}from"./rounds-DC6Dulo5.js";import{n as yne}from"./useMedia-CFebB4XU.js";import{t as bne}from"./BottomSheet-BFtfrr58.js";import{a as Wr,i as Gr,n as xne,o as Kr}from"./motion-Cy65kd7X.js";import{n as Sne}from"./preference-oNdcNeml.js";import{a as qr,n as Jr,t as Yr}from"./ref-BrUHq8E2.js";import{n as Cne,t as wne}from"./useSandboxFrame-CJmSnwgG.js";var Xr={name:`align-center-vertical`,size:24,node:[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4`,key:`14d6g8`}],[`path`,{d:`M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4`,key:`1e2lrw`}],[`path`,{d:`M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1`,key:`1fkdwx`}],[`path`,{d:`M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1`,key:`1euafb`}]]};Xr.node;var Tne=A(Xr),Zr={name:`align-end-vertical`,size:24,node:[[`rect`,{width:`16`,height:`6`,x:`2`,y:`4`,rx:`2`,key:`10wcwx`}],[`rect`,{width:`9`,height:`6`,x:`9`,y:`14`,rx:`2`,key:`4p5bwg`}],[`path`,{d:`M22 22V2`,key:`12ipfv`}]]};Zr.node;var Ene=A(Zr),Qr={name:`align-start-vertical`,size:24,node:[[`rect`,{width:`9`,height:`6`,x:`6`,y:`14`,rx:`2`,key:`lpm2y7`}],[`rect`,{width:`16`,height:`6`,x:`6`,y:`4`,rx:`2`,key:`rdj6ps`}],[`path`,{d:`M2 2v20`,key:`1ivd8o`}]]};Qr.node;var Dne=A(Qr),$r={name:`app-window`,size:24,node:[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]};$r.node;var One=A($r),ei={name:`arrow-left-to-line`,size:24,node:[[`path`,{d:`M3 19V5`,key:`rwsyhb`}],[`path`,{d:`m13 6-6 6 6 6`,key:`1yhaz7`}],[`path`,{d:`M7 12h14`,key:`uoisry`}]]};ei.node;var kne=A(ei),ti={name:`at-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]};ti.node;var Ane=A(ti),ni={name:`boxes`,size:24,node:[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]};ni.node;var jne=A(ni),ri={name:`chart-column-big`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`rect`,{x:`15`,y:`5`,width:`4`,height:`12`,rx:`1`,key:`q8uenq`}],[`rect`,{x:`7`,y:`8`,width:`4`,height:`9`,rx:`1`,key:`sr5ea`}]],aliases:[`bar-chart-big`]};ri.node;var ii=A(ri),ai={name:`chevrons-down-up`,size:24,node:[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]};ai.node;var Mne=A(ai),oi={name:`clipboard`,size:24,node:[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}]]};oi.node;var Nne=A(oi),si={name:`flag`,size:24,node:[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]};si.node;var ci=A(si),li={name:`footprints`,size:24,node:[[`path`,{d:`M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 1 1-4 0Z`,key:`1dudjm`}],[`path`,{d:`M20 20v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C14.63 6 14 7.8 14 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 1 0 4 0Z`,key:`l2t8xc`}],[`path`,{d:`M16 17h4`,key:`1dejxt`}],[`path`,{d:`M4 13h4`,key:`1bwh8b`}]]};li.node;var Pne=A(li),ui={name:`heading-1`,size:24,node:[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`m17 12 3-2v8`,key:`1hhhft`}]]};ui.node;var Fne=A(ui),di={name:`heading-2`,size:24,node:[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1`,key:`9jr5yi`}]]};di.node;var Ine=A(di),fi={name:`heading-3`,size:24,node:[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2`,key:`68ncm8`}],[`path`,{d:`M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2`,key:`1ejuhz`}]]};fi.node;var Lne=A(fi),pi={name:`languages`,size:24,node:[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]};pi.node;var mi=A(pi),hi={name:`lightbulb`,size:24,node:[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]};hi.node;var gi=A(hi),_i={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};_i.node;var Rne=A(_i),vi={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};vi.node;var zne=A(vi),yi={name:`message-square-code`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`m10 8-3 3 3 3`,key:`fp6dz7`}],[`path`,{d:`m14 14 3-3-3-3`,key:`1yrceu`}]]};yi.node;var Bne=A(yi),bi={name:`message-square-exclamation-point`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 15h.01`,key:`q59x07`}],[`path`,{d:`M12 7v4`,key:`xawao1`}]],aliases:[`message-square-warning`,`message-square-alert`]};bi.node;var xi=A(bi),Si={name:`message-square-quote`,size:24,node:[[`path`,{d:`M14 14a2 2 0 0 0 2-2V8h-2`,key:`1r06pg`}],[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M8 14a2 2 0 0 0 2-2V8H8`,key:`1jzu5j`}]]};Si.node;var Vne=A(Si),Ci={name:`octagon-exclamation-point`,size:24,node:[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]],aliases:[`alert-octagon`,`octagon-alert`]};Ci.node;var wi=A(Ci),Ti={name:`paperclip`,size:24,node:[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]};Ti.node;var Ei=A(Ti),Di={name:`rectangle-horizontal`,size:24,node:[[`rect`,{x:`2`,y:`5`,width:`20`,height:`14`,rx:`2`,key:`qneu4z`}]]};Di.node;var Hne=A(Di),Oi={name:`redo`,size:24,node:[[`path`,{d:`M21 7v6h-6`,key:`3ptur4`}],[`path`,{d:`M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7`,key:`1kgawr`}]]};Oi.node;var Une=A(Oi),ki={name:`remove-formatting`,size:24,node:[[`path`,{d:`M4 7V4h16v3`,key:`9msm58`}],[`path`,{d:`M5 20h6`,key:`1h6pxn`}],[`path`,{d:`M13 4 8 20`,key:`kqq6aj`}],[`path`,{d:`m15 15 5 5`,key:`me55sn`}],[`path`,{d:`m20 15-5 5`,key:`11p7ol`}]]};ki.node;var Wne=A(ki),Ai={name:`replace`,size:24,node:[[`path`,{d:`M14 4a1 1 0 0 1 1-1`,key:`dhj8ez`}],[`path`,{d:`M15 10a1 1 0 0 1-1-1`,key:`1mnyi5`}],[`path`,{d:`M21 4a1 1 0 0 0-1-1`,key:`sfs9ap`}],[`path`,{d:`M21 9a1 1 0 0 1-1 1`,key:`mp6qeo`}],[`path`,{d:`m3 7 3 3 3-3`,key:`x25e72`}],[`path`,{d:`M6 10V5a2 2 0 0 1 2-2h2`,key:`15xut4`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}]]};Ai.node;var Gne=A(Ai),ji={name:`sigma`,size:24,node:[[`path`,{d:`M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2`,key:`wuwx1p`}]]};ji.node;var Mi=A(ji),Ni={name:`subscript`,size:24,node:[[`path`,{d:`m4 5 8 8`,key:`1eunvl`}],[`path`,{d:`m12 5-8 8`,key:`1ah0jp`}],[`path`,{d:`M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07`,key:`e8ta8j`}]]};Ni.node;var Kne=A(Ni),Pi={name:`superscript`,size:24,node:[[`path`,{d:`m4 19 8-8`,key:`hr47gm`}],[`path`,{d:`m12 19-8-8`,key:`1dhhmo`}],[`path`,{d:`M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06`,key:`1dfcux`}]]};Pi.node;var qne=A(Pi),Fi={name:`table`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]};Fi.node;var Jne=A(Fi),Ii={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};Ii.node;var Li=A(Ii),Ri={name:`text-quote`,size:24,node:[[`path`,{d:`M17 5H3`,key:`1cn7zz`}],[`path`,{d:`M21 12H8`,key:`scolzb`}],[`path`,{d:`M21 19H8`,key:`13qgcb`}],[`path`,{d:`M3 12v7`,key:`1ri8j3`}]]};Ri.node;var Yne=A(Ri),zi={name:`undo`,size:24,node:[[`path`,{d:`M3 7v6h6`,key:`1v2h90`}],[`path`,{d:`M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13`,key:`1r6uu6`}]]};zi.node;var Xne=A(zi),Bi={name:`unlink`,size:24,node:[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]};Bi.node;var Vi=A(Bi),Hi={name:`vote`,size:24,node:[[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}],[`path`,{d:`M5 7c0-1.1.9-2 2-2h10a2 2 0 0 1 2 2v12H5V7Z`,key:`1ezoue`}],[`path`,{d:`M22 19H2`,key:`nuriw5`}]]};Hi.node;var Zne=A(Hi),Ui={name:`workflow`,size:24,node:[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]};Ui.node;var Wi=A(Ui),G=e(s(),1),K=O(),Gi=e(t(),1),Qne=[[`flowchart`,`flowchart-elk`,/^\s*flowchart-elk/],[`mindmap`,`mindmap`,/^\s*mindmap/],[`architecture`,`architecture`,/^\s*architecture/],[`agentflow`,`agentflow`,/^\s*agentflow-beta\b/],[`c4`,`c4`,/^\s*(?:C4Context|C4Container|C4Component|C4Dynamic|C4Deployment)/],[`kanban`,`kanban`,/^\s*kanban/],[`class`,`classDiagram`,/^\s*classDiagram/],[`er`,`er`,/^\s*erDiagram/],[`gantt`,`gantt`,/^\s*gantt/],[`info`,`info`,/^\s*info/],[`pie`,`pie`,/^\s*pie/],[`requirement`,`requirement`,/^\s*requirement(Diagram)?/],[`sequence`,`sequence`,/^\s*sequenceDiagram/],[`swimlane`,`swimlane`,/^\s*swimlane-beta\b/],[`flowchart`,`flowchart-v2`,/^\s*(graph|flowchart)/],[`timeline`,`timeline`,/^\s*timeline/],[`gitGraph`,`gitGraph`,/^\s*gitGraph/],[`state`,`stateDiagram`,/^\s*stateDiagram/],[`journey`,`journey`,/^\s*journey/],[`quadrantChart`,`quadrantChart`,/^\s*quadrantChart/],[`sankey`,`sankey`,/^\s*sankey(-beta)?/],[`packet`,`packet`,/^\s*packet(-beta)?/],[`xychart`,`xychart`,/^\s*xychart(-beta)?/],[`block`,`block`,/^\s*block(-beta)?/],[`eventmodeling`,`eventmodeling`,/^\s*eventmodeling/],[`treeView`,`treeView`,/^\s*treeView-beta/],[`radar`,`radar`,/^\s*radar-beta/],[`ishikawa`,`ishikawa`,/^\s*ishikawa(-beta)?\b/i],[`treemap`,`treemap`,/^\s*treemap/],[`railroad`,`railroad`,/^\s*railroad-beta/i],[`railroad`,`railroadEbnf`,/^\s*railroad-ebnf-beta/i],[`railroad`,`railroadAbnf`,/^\s*railroad-abnf-beta/i],[`railroad`,`railroadPeg`,/^\s*railroad-peg-beta/i],[`venn`,`venn`,/^\s*venn-beta/],[`wardley`,`wardley`,/^\s*wardley-beta/i],[`cynefin`,`cynefin`,/^\s*cynefin-beta(?:[\s:]|$)/],[`usecase`,`usecase`,/^\s*usecase-beta(?:\s|$)/]];function $ne(e){for(let[t,n,r]of Qne)if(r.test(e))return{type:t,mermaidType:n};return null}var Ki=class extends Error{code;type;mermaidType;line;column;snippet;constructor(e,t=`syntax`,n={}){super(e),this.name=`PeleError`,this.code=t,this.type=n.type??null,this.mermaidType=n.mermaidType??null,this.line=n.line??0,this.column=n.column??0,this.snippet=n.snippet??``}};function qi(e,t,n){return Array.from(e.matchAll(t),e=>[e.index,e.index+e[0].length,n])}function ere(e,t){let n=0;for(let[r,i,a]of e){let e=r-n;if(t<e)break;if(t<e+a)return r+Math.min(t-e,i-r-1);n+=i-r-a}return t+n}function Ji(e,t){for(let n=e.length-1;n>=0;n--)t=ere(e[n],t);return t}var Yi;function tre(e,t){let n=Yi;Yi=e;try{return t()}finally{Yi=n}}function Xi(e,t){return Yi!==void 0&&e===Yi.parsed?Yi.find(t):[e,t]}function Zi(e,t){let n=e.trimEnd().length;n>0&&t>=n?([e,t]=Xi(e,n-1),t++):[e,t]=Xi(e,t);let r=1,i=0;for(let n=e.indexOf(`
|
|
3
3
|
`);n!==-1&&n<t;n=e.indexOf(`
|
|
4
4
|
`,n+1))r++,i=n+1;let a=e.indexOf(`
|
|
5
5
|
`,t);a===-1&&(a=e.length);let o=t-i+1,s=e.slice(i,a);return{line:r,column:o,snippet:s+`
|
|
@@ -164,12 +164,12 @@ but found: '${Qb(Jb)}'`);(Hb[Gb[Jb]]&zb)!==0;)Jb++;return Wb.slice(Kb[e],qb[Jb-1
|
|
|
164
164
|
`)?e.slice(0,-1):e).split(`
|
|
165
165
|
`).map(e=>e.split(` `)),n=fN();for(let e of t){let t=fM();for(let n of e){let e=sM(rM.NO_STATUS),r=on();n&&r.append(te(n)),e.append(r),t.append(e)}n.append(t)}let{anchorCell:r}=wM(this);CM(n,r.select(0,r.getChildrenSize()))}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(cM).forEach(e=>{let n=e.getFirstChild();yr(n)&&(t|=n.getTextFormat())});let n=lt[e];return(t&n)!==0}insertNodes(e){let t=this.focus.getNode();rr(t)||uM(151),_n(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){let{anchorCell:e,focusCell:t}=wM(this),n=SM(e);n===null&&uM(153);let r=SM(t);r===null&&uM(155);let i=Math.min(n.columnIndex,r.columnIndex),a=Math.max(n.columnIndex+n.colSpan-1,r.columnIndex+r.colSpan-1),o=Math.min(n.rowIndex,r.rowIndex),s=Math.max(n.rowIndex+n.rowSpan-1,r.rowIndex+r.rowSpan-1);return{fromX:Math.min(i,a),fromY:Math.min(o,s),toX:Math.max(i,a),toY:Math.max(o,s)}}getNodes(){if(!this.isValid())return[];let e=this._cachedNodes;if(e!==null)return e;let{anchorTable:t,anchorCell:n,focusCell:r}=wM(this),i=r.getParents()[1];if(i!==t){if(t.isParentOf(r)){let e=i.getParent();e??uM(159),this.set(this.tableKey,r.getKey(),e.getKey())}else{let e=t.getParent();e??uM(158),this.set(this.tableKey,e.getKey(),r.getKey())}return this.getNodes()}let[a,o,s]=_M(t,n,r),{minColumn:c,maxColumn:l,minRow:u,maxRow:d}=xM(a,o,s),f=new Map([[t.getKey(),t]]),p=null;for(let e=u;e<=d;e++)for(let t=c;t<=l;t++){let{cell:n}=a[e][t],r=n.getParent();pM(r)||uM(160),r!==p&&(f.set(r.getKey(),r),p=r),f.has(n.getKey())||xDe(n,e=>{f.set(e.getKey(),e)})}let m=Array.from(f.values());return jee()||(this._cachedNodes=m),m}getTextContent(){let e=this.getNodes().filter(e=>cM(e)),t=``;for(let n=0;n<e.length;n++){let r=e[n],i=r.__parent,a=(e[n+1]||{}).__parent;t+=r.getTextContent()+(a===i?` `:`
|
|
166
166
|
`)}return t}};function EM(e){return e instanceof TM}function DM(e,t,n){e.getKey(),t.getKey(),n.getKey();let r=kr(),i=EM(r)?r.clone():new TM(`root`,Mt(`root`,0,`element`),Mt(`root`,0,`element`));return i.set(e.getKey(),t.getKey(),n.getKey()),i}function xDe(e,t){let n=[[e]];for(let e=n.at(-1);e!==void 0&&n.length>0;e=n.at(-1)){let r=e.pop();r===void 0?n.pop():!1!==t(r)&&rr(r)&&n.push(r.getChildren())}}function OM(e,t=Vn()){let n=Dn(e);pN(n)||uM(231,e);let r=PM(n,t.getElementByKey(e));return r===null&&uM(232,e),{tableElement:r,tableNode:n}}var SDe=class{observers;nextFocus;shouldCheckSelectionForTable;touchTapCellKey;constructor(){this.observers=new Map,this.nextFocus=null,this.shouldCheckSelectionForTable=null,this.touchTapCellKey=null}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){let{nextFocus:e}=this;return e!==null&&(this.nextFocus=null),e}setShouldCheckSelectionForTable(e){this.shouldCheckSelectionForTable=e}getAndClearShouldCheckSelectionForTable(){let{shouldCheckSelectionForTable:e}=this;return e?(this.shouldCheckSelectionForTable=null,e):null}removeObserver(e){let t=this.observers.get(e);return t!==void 0&&(t[0].removeListeners(),this.observers.delete(e),!0)}removeAllObservers(){for(let e of Array.from(this.observers.keys()))this.removeObserver(e)}$getTableNodesAndObservers(){let e=[];for(let[t,[n]]of Array.from(this.observers.entries())){let r=Dn(t);pN(r)?e.push([r,n]):this.removeObserver(t)}return e}},CDe=class{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;isPointerDrag;pointerStartCell;pointerType;abortController;listenerOptions;constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.isPointerDrag=!1,this.pointerStartCell=null,this.pointerType=null,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort(`removeListeners`),Array.from(this.listenersToRemove).forEach(e=>e()),this.listenersToRemove.clear()}$lookup(){return OM(this.tableNodeKey,this.editor)}trackTable(){let e=new MutationObserver(e=>{this.editor.read(`latest`,()=>{let t=!1;for(let n=0;n<e.length;n++){let r=e[n].target.nodeName;if(r===`TABLE`||r===`TBODY`||r===`THEAD`||r===`TR`){t=!0;break}}if(!t)return;let{tableNode:n,tableElement:r}=this.$lookup();this.table=BM(n,r)})});this.listenersToRemove.add(()=>e.disconnect()),this.editor.read(`latest`,()=>{let{tableNode:t,tableElement:n}=this.$lookup();this.table=BM(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})})}$clearHighlight(e=!0){let t=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();let{tableNode:n,tableElement:r}=this.$lookup();VM(t,BM(n,r),null),e&&kr()!==null&&(Jt(null),t.dispatchCommand(mn))}$enableHighlightStyle(){let e=this.editor,{tableElement:t}=this.$lookup();Ln(t,e._config.theme.tableSelection),t.classList.remove(`disable-selection`),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){let{tableElement:e}=this.$lookup();Tr(e,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(e!==null){e.tableKey!==this.tableNodeKey&&uM(233,e.tableKey,this.tableNodeKey);let t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),VM(t,this.table,this.tableSelection)}else this.$clearHighlight()}updateDOMSelection(){if(this.anchorCell!==null&&this.focusCell!==null){let e=Te(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,t=!1){let n=this.editor,{tableNode:r}=this.$lookup(),i=e.x,a=e.y;if(this.focusCell=e,this.isHighlightingCells||(t||this.anchorX!==i||this.anchorY!==a||this.tableSelection!=null&&this.anchorCellNodeKey!=null)&&(this.isHighlightingCells=!0,this.$disableHighlightStyle()),this.focusX!==-1&&this.focusY!==-1&&i===this.focusX&&a===this.focusY)return!1;if(this.focusX=i,this.focusY=a,this.isHighlightingCells){let o=iN(r,e.elem);if(this.tableSelection!=null&&this.anchorCellNodeKey!=null){let e=o;if(e===null&&t&&(e=r.getCellNodeFromCords(i,a,this.table)),e!==null){let t=this.$getAnchorTableCellOrThrow();return this.focusCellNodeKey=e.getKey(),this.tableSelection=DM(r,t,e),Jt(this.tableSelection),n.dispatchCommand(mn),VM(n,this.table,this.tableSelection),!0}}}return!1}$getAnchorTableCell(){let e=this.anchorCellNodeKey?Dn(this.anchorCellNodeKey):null;return cM(e)?e:null}$getAnchorTableCellOrThrow(){let e=this.$getAnchorTableCell();return e===null&&uM(234),e}$getFocusTableCell(){let e=this.focusCellNodeKey?Dn(this.focusCellNodeKey):null;return cM(e)?e:null}$getFocusTableCellOrThrow(){let e=this.$getFocusTableCell();return e===null&&uM(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y,this.focusX=-1,this.focusY=-1,this.focusCell=null,this.focusCellNodeKey=null;let{tableNode:t}=this.$lookup(),n=iN(t,e.elem);if(n!==null){let e=n.getKey();this.tableSelection==null?this.tableSelection=DM(t,n,n):(this.tableSelection=this.tableSelection.clone(),this.tableSelection.set(t.getKey(),e,e)),this.anchorCellNodeKey=e}}$formatCells(e){let t=kr();EM(t)||uM(236);let n=zt(),r=n.anchor,i=n.focus,a=t.getNodes().filter(cM);a.length>0||uM(237);let o=a[0].getFirstChild(),s=yr(o)?o.getFormatFlags(e,null):null;a.forEach(t=>{r.set(t.getKey(),0,`element`),i.set(t.getKey(),t.getChildrenSize(),`element`),n.formatText(e,s)}),Jt(t),this.editor.dispatchCommand(mn)}$clearText(){let{editor:e}=this,t=Dn(this.tableNodeKey);if(!pN(t))throw Error(`Expected TableNode.`);let n=kr();EM(n)||uM(253);let r=n.getNodes().filter(cM),i=t.getFirstChild(),a=t.getLastChild();if(r.length>0&&i!==null&&a!==null&&pM(i)&&pM(a)&&r[0]===i.getFirstChild()&&r[r.length-1]===a.getLastChild()){t.selectPrevious();let n=t.getParent();t.remove(),ce(n)&&n.isEmpty()&&e.dispatchCommand(xee)}else r.forEach(e=>{if(rr(e)){let t=e.getFirstChild(),n=yr(t)?see(t):on(),r=te();n.append(r),e.append(n),e.getChildren().forEach(e=>{e!==n&&e.remove()})}}),VM(e,this.table,null),Jt(null),e.dispatchCommand(mn)}},kM=`__lexicalTableSelection`;function AM(e){let t=pte(e);return pN(t)||uM(386,e),t}var jM=40;function MM(e,t,n,r=1e3/60){let i=e=>Math.max(1,Math.round(Math.max(1,Math.ceil(Math.min(jM,e)/jM*18))*r*60/1e3));return e<=t+jM?-i(t+jM-e):e>=n-jM?i(e-(n-jM)):0}function NM(e){return fe(e)&&e.nodeName===`TABLE`}function PM(e,t){if(!t)return t;let n=NM(t)?t:t.querySelector(`table`);return NM(n)||uM(341,e.constructor.name,e.getType(),e.getKey(),t.nodeName),n}function FM(e){return e._window}function IM(e,t){for(let n=t,r=null;n!==null;n=n.getParent()){if(e.is(n))return r;cM(n)&&(r=n)}return null}var wDe=[[F,`down`],[Nn,`up`],[qee,`backward`],[Wee,`forward`]],TDe=[ie,oee,Hee],EDe=[Wt,Ze];function DDe(e,t){return e.registerRootListener(n=>{if(n===null)return;let r=e._window;if(r===null)return;let i=()=>{t.touchTapCellKey=null};return Qn(Gt(r,`pointerdown`,r=>{t.touchTapCellKey=null;let i=Ot(r);if(r.button!==0||!ut(i)||!n.contains(i))return;let a=function(e){let t=RM(e);if(t===null)return null;let n=t.elem;for(;n!=null;){if(n.nodeName===`TABLE`&&kM in n&&n[kM])return{cellElement:t,tableElement:n,tableObserver:n[kM]};n=n.parentNode}return null}(i),o=a!==null&&a.tableObserver.editor===e?a:null;e.update(()=>{if(EM(kr())){for(let[e]of t.observers.values())e.$clearHighlight(!1);Jt(null),e.dispatchCommand(mn)}if(!o)return;let{tableObserver:n,tableElement:i,cellElement:a}=o;(function(e,t,n,r,i,a){let o=e._window;if(!o)return;if(i.pointerType=t.pointerType,t.pointerType===`touch`&&!t.shiftKey&&!i.isSelecting){let e=Bt(n.elem);a.touchTapCellKey=e?e.getKey():null}let s=AM(i.tableNodeKey),c=et(),l=Jn(c)||EM(c)?ZM(c.anchor.getNode()):null,u=l!==null&&l.isParentOf(s);if(St&&t.shiftKey&&(Jn(c)||EM(c))&&(qM(c,s)||u)){let e=c.anchor.getNode(),r=IM(s,c.anchor.getNode());if(r){let e=rN(i,r);e.elem===n.elem?t.pointerType!==`touch`&&i.$setAnchorCellForSelection(n):(i.$setAnchorCellForSelection(e),i.$setFocusCellForSelection(n),eN(t))}else(s.isBefore(e)?s.selectStart():s.selectEnd()).anchor.set(c.anchor.key,c.anchor.offset,c.anchor.type),eN(t)}else t.pointerType!==`touch`&&i.$setAnchorCellForSelection(n);(n=>{if(i.isSelecting)return;i.isSelecting=!0,i.isPointerDrag=!1,i.pointerStartCell=n;let s=t.pointerType===`touch`,c=t.pointerId,l=t.clientX,u=t.clientY,d=!s;s||i.anchorCell!==null||e.update(()=>{i.$setAnchorCellForSelection(n)});let f,p=t.clientX,m=t.clientY,h=null,g=null,_=e=>e.pointerId===c,v=(e,t)=>!(Math.abs(e-l)<=10&&Math.abs(t-u)<=10),y=()=>{i.isSelecting=!1,i.isPointerDrag=!1,i.pointerStartCell=null,h!==null&&(o.cancelAnimationFrame(h),h=null),g!==null&&(g(),g=null)},b=(e,t)=>{let n=r.getRootNode();if(!lte(n)&&!Wn(n))return null;for(let i of n.elementsFromPoint(e,t)){let e=zM(r,i);if(e)return e}return null},x=(t,r)=>{if(d||i.isPointerDrag&&t.elem!==n.elem){if(i.anchorCell===null||!d){let r=d?t:n;e.update(()=>{i.$setAnchorCellForSelection(r)})}d=!0,i.focusCell!==null&&t.elem===i.focusCell.elem||(a.setNextFocus({focusCell:t,override:r,tableKey:i.tableNodeKey}),e.dispatchCommand(mn))}},S=e=>{for(let t=r.parentElement;t;t=t.parentElement)if(e===`x`?t.scrollWidth>t.clientWidth:t.scrollHeight>t.clientHeight){let n=o.getComputedStyle(t),r=e===`x`?n.overflowX:n.overflowY;if(r===`auto`||r===`scroll`)return t}return null},C=(e,t,n,r)=>{let i,a;if(e===null)i=0,a=n===`x`?o.innerWidth:o.innerHeight;else{let t=e.getBoundingClientRect();i=n===`x`?t.left:t.top,a=n===`x`?t.right:t.bottom}let s=MM(t,i,a,r);if(s===0)return!1;if(e===null){let e=n===`x`?o.scrollX:o.scrollY;return o.scrollBy(n===`x`?s:0,n===`x`?0:s),(n===`x`?o.scrollX:o.scrollY)!==e}if(n===`x`){let t=e.scrollLeft;return e.scrollLeft+=s,e.scrollLeft!==t}let c=e.scrollTop;return e.scrollTop+=s,e.scrollTop!==c},w=e=>{if(h=null,!i.isSelecting)return;let t=e>f?Math.min(e-f,100):1e3/60;f=e;let n=S(`x`),r=S(`y`),a=n!==null&&C(n,p,`x`,t),s=C(r,m,`y`,t);if(a||s){let[e,t]=((e,t)=>{let n=p,r=m;if(e===null)n=Math.min(Math.max(n,1),o.innerWidth-1);else{let t=e.getBoundingClientRect();n=Math.min(Math.max(n,t.left+1),t.right-1)}if(t===null)r=Math.min(Math.max(r,1),o.innerHeight-1);else{let e=t.getBoundingClientRect();r=Math.min(Math.max(r,e.top+1),e.bottom-1)}return[n,r]})(n,r),i=b(e,t);i&&x(i,!1),h=o.requestAnimationFrame(w)}},T=()=>{h!==null||s&&!i.isPointerDrag||!(()=>{let e=S(`x`);if(e!==null){let t=e.getBoundingClientRect();if(MM(p,t.left,t.right)!==0)return!0}let t=S(`y`),n=t===null?0:t.getBoundingClientRect().top,r=t===null?o.innerHeight:t.getBoundingClientRect().bottom;return MM(m,n,r)!==0})()||(f=1/0,h=o.requestAnimationFrame(w))},E=e=>{_(e)&&(a.touchTapCellKey=null,y())};g=nn(o,{lostpointercapture:E,pointercancel:E,pointermove:e=>{if(!_(e))return;if(!(e=>!(1&~e.buttons))(e)&&i.isSelecting)return a.touchTapCellKey=null,void y();let t=Ot(e);if(!ut(t))return;p=e.clientX,m=e.clientY,!i.isPointerDrag&&v(p,m)&&(i.isPointerDrag=!0,a.touchTapCellKey=null);let n=null,o=!(St||r.contains(t));n=o?zM(r,t):b(e.clientX,e.clientY),n&&x(n,o),T()},pointerup:e=>{_(e)&&(v(e.clientX,e.clientY)&&(a.touchTapCellKey=null),y())}},i.listenerOptions)})(n)})(e,r,a,i,n,t)})}),nn(r,{blur:i,keydown:i},{capture:!0}),i)})}function ODe(e,t,n,r,i){let a=n.getRootElement(),o=FM(n);a!==null&&o!==null||uM(246);let s=new CDe(n,e.getKey()),c=PM(e,t);(function(e,t){LM(e)!==null&&uM(205),e[kM]=t})(c,s),s.listenersToRemove.add(()=>function(e,t){LM(e)===t&&delete e[kM]}(c,s)),s.listenersToRemove.add(Gt(c,`mousedown`,e=>{let t=Ot(e);e.detail>=3&&ut(t)&&RM(t)!==null&&e.preventDefault()},s.listenerOptions));for(let[t,r]of wDe)s.listenersToRemove.add(n.registerCommand(t,t=>$M(n,t,r,e,s,i),3));s.listenersToRemove.add(n.registerCommand(tr,t=>{let n=kr();if(EM(n)){let r=IM(e,n.focus.getNode());if(r!==null)return eN(t),r.selectEnd(),!0}return!1},3));let l=()=>{let t=kr();return!!qM(t,e)&&!!EM(t)&&(s.$clearText(),!0)};for(let e of TDe)s.listenersToRemove.add(n.registerCommand(e,l,3));let u=t=>{let n=kr();if(!EM(n)&&!Jn(n))return!1;let r=e.isParentOf(n.anchor.getNode());if(r!==e.isParentOf(n.focus.getNode())){let t=r?`anchor`:`focus`,i=r?`focus`:`anchor`,{key:a,offset:o,type:s}=n[i];return e[n[t].isBefore(n[i])?`selectPrevious`:`selectNext`]()[i].set(a,o,s),!1}return!!qM(n,e)&&!!EM(n)&&(t&&(t.preventDefault(),t.stopPropagation()),s.$clearText(),!0)};for(let e of EDe)s.listenersToRemove.add(n.registerCommand(e,u,3));s.listenersToRemove.add(n.registerCommand(he,e=>{let t=kr();if(t){if(!EM(t)&&!Jn(t))return!1;_ee(n,Jee(e,ClipboardEvent)?e:null,me(t));let r=u(e);return Jn(t)?(t.removeText(),!0):r}return!1},3));let d=a.ownerDocument;return s.listenersToRemove.add(Gt(d,`paste`,t=>{t.defaultPrevented||n.read(`latest`,()=>{let t=kr();return a.contains(d.activeElement)&&EM(t)&&qM(t,e)})&&(t.preventDefault(),n.dispatchCommand(or,t))})),s.listenersToRemove.add(Gt(d,`copy`,t=>{if(t.defaultPrevented)return;let r=Ot(t);r===a||ut(r)&&a.contains(r)||n.read(`latest`,()=>{let t=kr();return a.contains(Zee(a))&&EM(t)&&qM(t,e)})&&(t.preventDefault(),n.dispatchCommand(Pn,t))})),s.listenersToRemove.add(n.registerCommand(ye,t=>{let n=kr();return!!qM(n,e)&&!!EM(n)&&(s.$formatCells(t),!0)},3)),s.listenersToRemove.add(n.registerCommand(cn,t=>{let n=kr();if(!EM(n)||!qM(n,e))return!1;let r=n.anchor.getNode(),i=n.focus.getNode();if(!cM(r)||!cM(i))return!1;let[a,o,s]=_M(e,r,i),{minColumn:c,maxColumn:l,minRow:u,maxRow:d}=xM(a,o,s);if(u===0&&c===0&&d===a.length-1&&l===a[0].length-1)return e.setFormat(t),!0;let f=new Set;for(let e=u;e<=d;e++)for(let n=c;n<=l;n++){let r=a[e][n].cell;if(f.has(r))continue;f.add(r),r.setFormat(t);let i=r.getChildren();for(let e=0;e<i.length;e++){let n=i[e];rr(n)&&!n.isInline()&&n.setFormat(t)}}return!0},3)),s.listenersToRemove.add(n.registerCommand(re,t=>{let r=kr();if(!qM(r,e))return!1;if(EM(r))return s.$clearHighlight(),!1;if(Jn(r)){if(!cM(pr(r.anchor.getNode(),e=>cM(e))))return!1;if(typeof t==`string`){let i=nN(n,r,e);if(i)return tN(i,e,[te(t)]),!0}}return!1},3)),r&&s.listenersToRemove.add(n.registerCommand(Qe,t=>{let n=kr();if(!Jn(n)||!n.isCollapsed()||!qM(n,e))return!1;let r=ZM(n.anchor.getNode());return!(r===null||!e.is(QM(r))||(eN(t),function(e,t){let n=t===`next`?`getNextSibling`:`getPreviousSibling`,r=t===`next`?`getFirstChild`:`getLastChild`,i=e[n]();if(rr(i))return i.selectEnd();let a=pr(e,pM);a===null&&uM(247);for(let e=a[n]();pM(e);e=e[n]()){let t=e[r]();if(rr(t))return t.selectEnd()}let o=pr(a,pN);o===null&&uM(248),t===`next`?o.selectNext():o.selectPrevious()}(r,t.shiftKey?`previous`:`next`),0))},3)),s.listenersToRemove.add(n.registerCommand(Dee,t=>e.isSelected(),3)),s.listenersToRemove.add(n.registerCommand(xee,()=>{let t=kr();if(!Jn(t)||!t.isCollapsed()||!qM(t,e))return!1;let r=nN(n,t,e);return!!r&&(tN(r,e),!0)},3)),s}function kDe(e,t,n){let r=kr(),i=t.isSelected();if(!(EM(r)&&r.tableKey===t.getKey()||n.isHighlightingCells||n.hasHijackedSelectionStyles||i))return;let{tableElement:a}=n.$lookup();if(n.table=BM(t,a),EM(r)&&r.tableKey===t.getKey()){let e=Dn(r.anchor.key),t=Dn(r.focus.key);if(cM(e)&&cM(t)){let r=rN(n,e),i=rN(n,t);n.anchorCell=r,n.anchorCellNodeKey=e.getKey(),n.anchorX=r.x,n.anchorY=r.y,n.focusCell=i,n.focusCellNodeKey=t.getKey(),n.focusX=i.x,n.focusY=i.y}n.$updateTableTableSelection(r)}else n.isHighlightingCells&&n.$clearHighlight(!1);n.hasHijackedSelectionStyles&&!i?function(e,t){t.$enableHighlightStyle(),HM(t.table,t=>{let n=t.elem;t.highlighted=!1,XM(e,t),n.getAttribute(`style`)||n.removeAttribute(`style`)})}(e,n):!n.hasHijackedSelectionStyles&&i&&function(e,t){t.$disableHighlightStyle(),HM(t.table,t=>{t.highlighted=!0,YM(e,t)})}(e,n)}function LM(e){return e[kM]||null}function RM(e){let t=e;for(;t!=null;){let e=t.nodeName;if(e===`TD`||e===`TH`){let e=t._cell;return e===void 0?null:e}t=t.parentNode}return null}function zM(e,t){if(!e.contains(t))return null;let n=null;for(let r=t;r!=null;r=r.parentNode){if(r===e)return n;let t=r.nodeName;t!==`TD`&&t!==`TH`||(n=r._cell||null)}return null}function BM(e,t){let n=[],r={columns:0,domRows:n,rows:0},i=PM(e,t).querySelector(`tr`),a=0,o=0;for(n.length=0;i!=null;){let e=i.nodeName;if(e===`TD`||e===`TH`){let e={elem:i,hasBackgroundColor:i.style.backgroundColor!==``,highlighted:!1,x:a,y:o};i._cell=e;let t=n[o];t===void 0&&(t=n[o]=[]),t[a]=e}else{let e=i.firstChild;if(e!=null){i=e;continue}}let t=i.nextSibling;if(t!=null){a++,i=t;continue}let r=i.parentNode;if(r!=null){let e=r.nextSibling;if(e==null)break;o++,a=0,i=e}}return r.columns=a+1,r.rows=o+1,r}function VM(e,t,n){let r=new Set(n?n.getNodes():[]);HM(t,(t,n)=>{let i=t.elem;r.has(n)?(t.highlighted=!0,YM(e,t)):(t.highlighted=!1,XM(e,t),i.getAttribute(`style`)||i.removeAttribute(`style`))})}function HM(e,t){let{domRows:n}=e;for(let e=0;e<n.length;e++){let r=n[e];if(r)for(let n=0;n<r.length;n++){let i=r[n];if(!i)continue;let a=Bt(i.elem);a!==null&&t(i,a,{x:n,y:e})}}}var ADe=(e,t,n,r,i)=>{let a=i===`forward`;switch(i){case`backward`:case`forward`:return n===(a?e.table.columns-1:0)?r===(a?e.table.rows-1:0)?a?t.selectNext():t.selectPrevious():JM(t.getCellNodeFromCordsOrThrow(a?0:e.table.columns-1,r+(a?1:-1),e.table),a):JM(t.getCellNodeFromCordsOrThrow(n+(a?1:-1),r,e.table),a),!0;case`up`:return r===0?t.selectPrevious():JM(t.getCellNodeFromCordsOrThrow(n,r-1,e.table),!1),!0;case`down`:return r===e.table.rows-1?t.selectNext():JM(t.getCellNodeFromCordsOrThrow(n,r+1,e.table),!0),!0;default:return!1}};function UM(e,t){let n,r;if(t.startColumn===e.minColumn)n=`minColumn`;else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n=`maxColumn`}if(t.startRow===e.minRow)r=`minRow`;else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;r=`maxRow`}return[n,r]}function WM(e,t,n){let r=UM(e,t);if(r)return r;let i=UM(e,n);return i?GM(i):[`minColumn`,`minRow`]}function GM([e,t]){return[e===`minColumn`?`maxColumn`:`minColumn`,t===`minRow`?`maxRow`:`minRow`]}function KM(e,t,[n,r]){let i=t[r],a=e[i];a===void 0&&uM(250,r,String(i));let o=t[n],s=a[o];return s===void 0&&uM(250,n,String(o)),s}function qM(e,t){if(Jn(e)||EM(e)){let n=t.isParentOf(e.anchor.getNode()),r=t.isParentOf(e.focus.getNode());return n&&r}return!1}function JM(e,t){t?e.selectStart():e.selectEnd()}function YM(e,t){let n=t.elem,r=e._config.theme;cM(Bt(n))||uM(131),Tr(n,r.tableCellSelected)}function XM(e,t){let n=t.elem;cM(Bt(n))||uM(131);let r=e._config.theme;Ln(n,r.tableCellSelected)}function ZM(e){let t=pr(e,cM);return cM(t)?t:null}function QM(e){let t=pr(e,pN);return pN(t)?t:null}function $M(e,t,n,r,i,a){if((n===`up`||n===`down`)&&function(e){let t=e.getRootElement();return!!t&&t.hasAttribute(`aria-controls`)&&t.getAttribute(`aria-controls`)===`typeahead-menu`}(e))return!1;let o=kr();if(!qM(o,r)){if(Jn(o)){if(n===`backward`){if(o.focus.offset>0)return!1;let e=function(e){for(let t=e,n=e;n!==null;t=n,n=n.getParent())if(rr(n)){if(n!==t&&n.getFirstChild()!==t)return null;if(!n.isInline())return n}return null}(o.focus.getNode());if(!e)return!1;let n=e.getPreviousSibling();return!!pN(n)&&(eN(t),t.shiftKey?o.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),`element`):n.selectEnd(),!0)}if(t.shiftKey&&(n===`up`||n===`down`)){let e=o.focus.getNode();if(!o.isCollapsed()&&(n===`up`&&!o.isBackward()||n===`down`&&o.isBackward())){let i=pr(e,e=>pN(e));if(cM(i)&&(i=pr(i,pN)),i!==r||!i)return!1;let a=n===`down`?i.getNextSibling():i.getPreviousSibling();if(!a)return!1;let s=0;n===`up`&&rr(a)&&(s=a.getChildrenSize());let c=a;n===`up`&&rr(a)&&(c=a.getLastChild()||a,s=it(c)?c.getTextContentSize():0);let l=o.clone();return l.focus.set(c.getKey(),s,it(c)?`text`:`element`),Jt(l),eN(t),!0}if(vr(e)){let e=n===`up`?o.getNodes()[o.getNodes().length-1]:o.getNodes()[0];if(e&&IM(r,e)!==null){let e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;let[n]=bM(e),[a]=bM(t),o=r.getCordsFromCellNode(n,i.table),s=r.getCordsFromCellNode(a,i.table),c=r.getDOMCellFromCordsOrThrow(o.x,o.y,i.table),l=r.getDOMCellFromCordsOrThrow(s.x,s.y,i.table);return i.$setAnchorCellForSelection(c),i.$setFocusCellForSelection(l,!0),!0}return!1}{let r=pr(e,e=>rr(e)&&!e.isInline());if(cM(r)&&(r=pr(r,pN)),!r)return!1;let a=n===`down`?r.getNextSibling():r.getPreviousSibling();if(pN(a)&&i.tableNodeKey===a.getKey()){let e=a.getFirstDescendant(),r=a.getLastDescendant();if(!e||!r)return!1;let[i]=bM(e),[s]=bM(r),c=o.clone();return c.focus.set((n===`up`?i:s).getKey(),n===`up`?0:s.getChildrenSize(),`element`),eN(t),Jt(c),!0}}}}return n===`down`&&lN(e)&&function(e,t){if(!Jn(e))return!1;let n=De(e.focus,`next`),r=Tn(t,`next`);return pe(n.origin,r.origin)!==null&&ote(n,r)<0}(o,r)&&a.setShouldCheckSelectionForTable(r.getKey()),!1}if(Jn(o)){if(n===`backward`||n===`forward`)return function(e,t,n,r,i,a,o){let s=De(n.focus,i?`previous`:`next`);if(Mee(s))return!1;let c=s;for(let e of Vt(s).iterNodeCarets(`shadowRoot`)){if(!W(e)||!rr(e.origin))return!1;c=e}let l=c.getParentAtCaret();if(!cM(l))return!1;let u=l,d=function(e){for(let t of Vt(e).iterNodeCarets(`root`)){let{origin:n}=t;if(cM(n)){if(ue(t))return Tn(n,e.direction)}else if(!pM(n))break}return null}(Kt(u,c.direction)),f=pr(u,pN);if(!f||!f.is(a))return!1;let p=e.getElementByKey(u.getKey()),m=RM(p);if(!p||!m)return!1;if(o.table=NDe(e,f),d){if(r===`extend`){let t=RM(e.getElementByKey(d.origin.getKey()));if(!t)return!1;o.$setAnchorCellForSelection(m),o.$setFocusCellForSelection(t,!0)}else{let e=He(d);Xt(n.anchor,e),Xt(n.focus,e)}}else if(r===`extend`)o.$setAnchorCellForSelection(m),o.$setFocusCellForSelection(m,!0);else{let e=function(e){let t=Qee(e);return ue(t)?He(t):e}(Kt(f,s.direction));Xt(n.anchor,e),Xt(n.focus,e)}return eN(t),!0}(e,t,o,t.shiftKey?`extend`:`move`,n===`backward`,r,i);if(o.isCollapsed()){let{anchor:s,focus:c}=o,l=pr(s.getNode(),cM),u=pr(c.getNode(),cM);if(!cM(l)||!l.is(u))return!1;let d=QM(l);if(d!==r&&d!=null){let r=PM(d,e.getElementByKey(d.getKey()));if(r!=null)return i.table=BM(d,r),$M(e,t,n,d,i,a)}let f=e.getElementByKey(l.__key),p=e.getElementByKey(s.key);if(p==null||f==null)return!1;let m;if(s.type===`element`)m=p.getBoundingClientRect();else{let t=Te(FM(e));if(t===null||t.rangeCount===0)return!1;let n=Iee(t,e.getRootElement());if(n===null)return!1;m=n.getBoundingClientRect()}let h=n===`up`?l.getFirstChild():l.getLastChild();if(h==null)return!1;let g=e.getElementByKey(h.__key);if(g==null)return!1;let _=g.getBoundingClientRect();if(n===`up`?_.top>m.top-m.height:m.bottom+m.height>_.bottom){eN(t);let e=r.getCordsFromCellNode(l,i.table);if(!t.shiftKey)return ADe(i,r,e.x,e.y,n);{let t=r.getDOMCellFromCordsOrThrow(e.x,e.y,i.table);i.$setAnchorCellForSelection(t),i.$setFocusCellForSelection(t,!0)}return!0}}}else if(EM(o)){let{anchor:a,focus:s,tableKey:c}=o;if(c!==r.getKey())return!1;let l=pr(a.getNode(),cM),u=pr(s.getNode(),cM),[d]=o.getNodes();pN(d)||uM(251);let f=PM(d,e.getElementByKey(d.getKey()));if(!cM(l)||!cM(u)||!pN(d)||f==null)return!1;i.$updateTableTableSelection(o);let p=BM(d,f),m=r.getCordsFromCellNode(l,p),h=r.getDOMCellFromCordsOrThrow(m.x,m.y,p);if(i.$setAnchorCellForSelection(h),eN(t),t.shiftKey){let[e,t,a]=_M(r,l,u);return function(e,t,n,r,i){let a=xM(t,n,r),{topSpan:o,leftSpan:s,bottomSpan:c,rightSpan:l}=function(e,t){let{minColumn:n,maxColumn:r,minRow:i,maxRow:a}=t,o=1,s=1,c=1,l=1,u=e[i],d=e[a];for(let e=n;e<=r;e++)o=Math.max(o,u[e].cell.__rowSpan),l=Math.max(l,d[e].cell.__rowSpan);for(let t=i;t<=a;t++)s=Math.max(s,e[t][n].cell.__colSpan),c=Math.max(c,e[t][r].cell.__colSpan);return{bottomSpan:l,leftSpan:s,rightSpan:c,topSpan:o}}(t,a),[u,d]=GM(WM(a,n,r)),f=a[u],p=a[d];i===`forward`?f+=u===`maxColumn`?1:s:i===`backward`?f-=u===`minColumn`?1:l:i===`down`?p+=d===`maxRow`?1:o:i===`up`&&(p-=d===`minRow`?1:c);let m=t[p];if(m===void 0)return!1;let h=m[f];if(h===void 0)return!1;let[g,_]=function(e,t,n){let r=xM(e,t,n),i=WM(r,t,n);return[KM(e,r,i),KM(e,r,GM(i))]}(t,n,h),v=rN(e,g.cell),y=rN(e,_.cell);return e.$setAnchorCellForSelection(v),e.$setFocusCellForSelection(y,!0),!0}(i,e,t,a,n)}return u.selectEnd(),!0}return!1}function eN(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function tN(e,t,n){let r=on();e===`first`?t.insertBefore(r):t.insertAfter(r),r.append(...n||[]),r.selectEnd()}function nN(e,t,n){let r=n.getParent();if(!r)return;let i=Te(FM(e));if(!i)return;let a=It(i,e.getRootElement()).anchorNode,o=e.getElementByKey(r.getKey()),s=PM(n,e.getElementByKey(n.getKey()));if(!a||!o||!s||!o.contains(a)||s.contains(a))return;let c=pr(t.anchor.getNode(),e=>cM(e));if(!c)return;let l=pr(c,e=>pN(e));if(!pN(l)||!l.is(n))return;let[u,d]=_M(n,c,c),f=u[0][0],p=u[u.length-1][u[0].length-1],{startRow:m,startColumn:h}=d,g=m===f.startRow&&h===f.startColumn,_=m===p.startRow&&h===p.startColumn;return g?`first`:_?`last`:void 0}function rN(e,t){let{tableNode:n}=e.$lookup(),r=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(r.x,r.y,e.table)}function iN(e,t,n){return IM(e,Bt(t,n))}function aN(e){return fe(e)&&e.nodeName===`DIV`}var jDe=se()({colWidths:nt(N(tee(tn())),{getter:{field:`__colWidths`}}),frozenColumnCount:nt(tn(),{getter:`getSerializedFrozenColumnCount`,setter:{field:`__frozenColumnCount`,method:`setFrozenColumns`}}),frozenRowCount:nt(tn(),{getter:`getSerializedFrozenRowCount`,setter:{field:`__frozenRowCount`,method:`setFrozenRows`}}),rowStriping:nt(vte(),{getter:`getSerializedRowStriping`,setter:{field:`__rowStriping`}})});function oN(e,t,n){let r=e.querySelector(`:scope > colgroup`);if(!n)return void(r&&r.remove());r||(r=Sn().createElement(`colgroup`),Tt(r),e.insertBefore(r,e.firstChild));let i=[];for(let e=0;e<t;e++){let t=Sn().createElement(`col`),r=n[e];r&&(t.style.width=`${r}px`),i.push(t)}r.replaceChildren(...i)}function sN(e,t,n){if(!t.theme.tableAlignment)return;let r=[],i=[];for(let e of[`center`,`right`]){let a=t.theme.tableAlignment[e];a&&(e===n?i:r).push(a)}Ln(e,...r),Tr(e,...i)}var cN=new WeakSet;function lN(e=Vn()){return cN.has(e)}function uN(e=Vn()){let t=kt(e,`@lexical/table/Table`);return!!t&&t.output.hasStickyScrollbar.peek()&&t.output.hasHorizontalScroll.peek()}function MDe(e,t){t?cN.add(e):cN.delete(e)}var dN=class extends $e{__rowStriping=!1;__frozenColumnCount=0;__frozenRowCount=0;__colWidths=void 0;$config(){return this.config(`table`,{extends:$e,generated:aDe,importDOM:{table:()=>({conversion:PDe,priority:1})},json:jDe})}getSerializedFrozenColumnCount(){return this.getLatest().__frozenColumnCount||void 0}getSerializedFrozenRowCount(){return this.getLatest().__frozenRowCount||void 0}getSerializedRowStriping(){return this.getLatest().__rowStriping||void 0}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){let t=this.getWritable();return t.__colWidths=e,t}extractWithChild(e,t,n){return n===`html`}getDOMSlot(e){let t=NM(e)?e:e.querySelector(`table`);return NM(t)||uM(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector(`:scope > colgroup`))}createDOM(e,t){let n=Sn().createElement(`table`);if(this.__style&&An(n.style,this.__style),this.getColWidths()){let e=Sn().createElement(`colgroup`);n.appendChild(e),Tt(e)}if(Tr(n,e.theme.table),this.updateTableElement(null,n,e),lN(t)){let r=uN(t),i=function(e,t,n){let r=Sn().createElement(`div`),i=t.theme.tableScrollableWrapper;return i?Tr(r,i):r.style.overflowX=`auto`,n&&(r.style.scrollbarWidth=`none`),r.appendChild(e),r}(n,e,r);if(this.updateTableWrapper(null,i,n,e),r){let t=function(e){let t=Sn(),n=t.createElement(`div`),r=e.theme.tableStickyScrollbar;r?Tr(n,r):(n.style.position=`sticky`,n.style.bottom=`0`,n.style.overflowX=`scroll`,n.style.overflowY=`hidden`),n.style.display=`none`,n.setAttribute(`aria-hidden`,`true`),n.tabIndex=-1;let i=t.createElement(`div`);return i.style.height=`1px`,i.style.width=`0px`,n.appendChild(i),n}(e),n=Sn().createElement(`div`);return n.setAttribute(`data-lexical-sticky-scrollbar`,`true`),n.appendChild(i),n.appendChild(t),Tt(t),n}return i}return n}updateTableWrapper(e,t,n,r){this.__frozenColumnCount!==(e?e.__frozenColumnCount:0)&&function(e,t,n,r){r>0?(Tr(e,n.theme.tableFrozenColumn),t.setAttribute(`data-lexical-frozen-column`,`true`)):(Ln(e,n.theme.tableFrozenColumn),t.removeAttribute(`data-lexical-frozen-column`))}(t,n,r,this.__frozenColumnCount),this.__frozenRowCount!==(e?e.__frozenRowCount:0)&&function(e,t,n,r){r>0?(Tr(e,n.theme.tableFrozenRow),t.setAttribute(`data-lexical-frozen-row`,`true`)):(Ln(e,n.theme.tableFrozenRow),t.removeAttribute(`data-lexical-frozen-row`))}(t,n,r,this.__frozenRowCount)}updateTableElement(e,t,n){this.__style!==(e?e.__style:``)&&An(t.style,this.__style,e?e.__style:``),this.__rowStriping!==(!!e&&e.__rowStriping)&&function(e,t,n){n?(Tr(e,t.theme.tableRowStriping),e.setAttribute(`data-lexical-row-striping`,`true`)):(Ln(e,t.theme.tableRowStriping),e.removeAttribute(`data-lexical-row-striping`))}(t,n,this.__rowStriping);let r=e?e.getColumnCount():0,i=e?e.__colWidths:void 0;this.getColumnCount()===r&&this.getColWidths()===i||oN(t,this.getColumnCount(),this.getColWidths()),sN(t,n,this.getFormatType())}updateDOM(e,t,n){let r=PM(this,t);if(t===r===lN())return!0;if(aN(t)){if(t.hasAttribute(`data-lexical-sticky-scrollbar`)!==uN())return!0;let i=r.parentElement;aN(i)&&this.updateTableWrapper(e,i,r,n)}return this.updateTableElement(e,r,n),!1}scaleDOMColWidths(e,t){let n=this.getColWidths();n&&oN(PM(this,e),this.getColumnCount(),n.map(e=>e*t))}exportDOM(e){let t=super.exportDOM(e),{element:n}=t,r=!NM(n)&&fe(n)?n.querySelector(`table`):n;if(fe(n)&&NM(r)&&r!==n){n.dir&&(r.dir=n.dir);let{paddingInlineStart:e}=n.style;e&&(r.style.paddingInlineStart=e);let t=n.getAttribute(`data-lexical-indent`);t!==null&&r.setAttribute(`data-lexical-indent`,t)}return{after:n=>{if(t.after&&(n=t.after(n)),!NM(n)&&fe(n)&&(n=n.querySelector(`table`)),!NM(n))return null;sN(n,e._config,this.getFormatType());let[r]=vM(this,null,null),i=new Map;for(let e of r)for(let t of e){let e=t.cell.getKey();i.has(e)||i.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}let a=new Set;for(let e of n.querySelectorAll(`:scope > tr > [data-temporary-table-cell-lexical-key]`)){let t=e.getAttribute(`data-temporary-table-cell-lexical-key`);if(t){let n=i.get(t);if(e.removeAttribute(`data-temporary-table-cell-lexical-key`),n){i.delete(t);for(let e=0;e<n.colSpan;e++)a.add(e+n.startColumn)}}}let o=n.querySelector(`:scope > colgroup`);if(o){let e=Array.from(n.querySelectorAll(`:scope > colgroup > col`)).filter((e,t)=>a.has(t));o.replaceChildren(...e)}let s=n.querySelectorAll(`:scope > tr`);if(s.length>0){let e=Sn().createElement(`tbody`);for(let t of s)e.appendChild(t);n.append(e)}return n},element:r}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){let{rows:n,domRows:r}=t;for(let t=0;t<n;t++){let n=r[t];if(n!=null)for(let r=0;r<n.length;r++){let i=n[r];if(i==null)continue;let{elem:a}=i,o=iN(this,a);if(o!==null&&e.is(o))return{x:r,y:t}}}throw Error(`Cell not found in table.`)}getDOMCellFromCords(e,t,n){let{domRows:r}=n,i=r[t];return i==null?null:i[e<i.length?e:i.length-1]??null}getDOMCellFromCordsOrThrow(e,t,n){let r=this.getDOMCellFromCords(e,t,n);if(!r)throw Error(`Cell not found at cords.`);return r}getCellNodeFromCords(e,t,n){let r=this.getDOMCellFromCords(e,t,n);if(r==null)return null;let i=Bt(r.elem);return cM(i)?i:null}getCellNodeFromCordsOrThrow(e,t,n){let r=this.getCellNodeFromCords(e,t,n);if(!r)throw Error(`Node at cords not TableCellNode.`);return r}getRowStriping(){return!!this.getLatest().__rowStriping}setRowStriping(e){let t=this.getWritable();return t.__rowStriping=e,t}setFrozenColumns(e){let t=this.getWritable();return t.__frozenColumnCount=e,t}getFrozenColumns(){return this.getLatest().__frozenColumnCount}setFrozenRows(e){let t=this.getWritable();return t.__frozenRowCount=e,t}getFrozenRows(){return this.getLatest().__frozenRowCount}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){let e=this.getFirstChild();if(!pM(e))return 0;let t=0;return e.getChildren().forEach(e=>{cM(e)&&(t+=e.getColSpan())}),t}};function NDe(e,t){let n=e.getElementByKey(t.getKey());return n===null&&uM(230),BM(t,n)}function PDe(e){let t=fN();e.hasAttribute(`data-lexical-row-striping`)&&t.setRowStriping(!0),e.hasAttribute(`data-lexical-frozen-column`)&&t.setFrozenColumns(1),e.hasAttribute(`data-lexical-frozen-row`)&&t.setFrozenRows(1);let n=e.querySelector(`:scope > colgroup`);if(n){let e=[];for(let t of n.querySelectorAll(`:scope > col`)){let n=t.style.width||``;if(!eM.test(n)&&(n=t.getAttribute(`width`)||``,!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&t.setColWidths(e)}return jn(t,e),{after:e=>Re(e,pM),node:t}}function fN(){return Ct(new dN)}function pN(e){return e instanceof dN}function FDe(e){pM(e.getParent())?e.isEmpty()&&e.append(on()):e.remove()}function IDe(e){pN(e.getParent())?R(e,cM):e.remove()}function LDe(e){R(e,pM),yM(e);let t=e.getColWidths(),n=e.getColumnCount();if(t&&t.length!==n){let r;if(n<t.length)r=t.slice(0,n);else if(t.length>0){let e=t[t.length-1];r=[...t,...Array(n-t.length).fill(e)]}e.setColWidths(r)}}function RDe(e){if(e.detail<3||!ut(e.target))return!1;let t=Bt(e.target);if(t===null)return!1;let n=pr(t,e=>rr(e)&&!e.isInline());return n!==null&&!!cM(n.getParent())&&(_n(n.select(0)),!0)}function zDe(){let e=kr();if(!Jn(e))return!1;let t=QM(e.anchor.getNode());if(t===null)return!1;let n=Sr();if(!n.is(t.getParent())||n.getChildrenSize()!==1)return!1;let[r]=vM(t,null,null);if(r.length===0||r[0].length===0)return!1;let i=r[0][0];if(!i||!i.cell)return!1;let a=r[r.length-1],o=a[a.length-1];if(!o||!o.cell)return!1;let s=DM(t,i.cell,o.cell);return Jt(s),!0}function BDe(e){return e.registerNodeTransform(iM,e=>{if(e.getColSpan()>1||e.getRowSpan()>1){let[,,t]=bM(e),[n]=_M(t,e,e),r=n.length,i=n[0].length,a=t.getFirstChild();pM(a)||uM(175);let o=[];for(let e=0;e<r;e++){e!==0&&(a=a.getNextSibling(),pM(a)||uM(175));let t=null;for(let r=0;r<i;r++){let i=n[e][r],s=i.cell;if(i.startRow===e&&i.startColumn===r)t=s,o.push(s);else if(s.getColSpan()>1||s.getRowSpan()>1){cM(s)||uM(176);let e=sM(s.__headerState);t===null?Xee(a,e):t.insertAfter(e)}}}for(let e of o)e.setColSpan(1),e.setRowSpan(1)}})}function VDe(e,t=!0){let n=new SDe,r=!1,i=(r,i,a)=>{let o=PM(r,a),s=ODe(r,o,e,t,n);n.observers.set(i,[s,o])};return Qn(DDe(e,n),e.registerCommand(mn,()=>e.getRootElement()!==null&&(r=!0,function(e,t){let n=kr(),r=et(),i=e.getAndClearNextFocus();if(i!==null&&pN(Dn(i.tableKey))){let{tableKey:t,focusCell:r}=i,a=e.observers.get(t);a||uM(335,t);let[o]=a;if(EM(n)&&n.tableKey===o.tableNodeKey)return(r.x!==o.focusX||r.y!==o.focusY)&&(o.$setFocusCellForSelection(r),!0);if(o.anchorCell!==null&&o.anchorCellNodeKey!==null&&r.elem!==o.anchorCell.elem&&o.tableSelection!==null)return o.$setFocusCellForSelection(r,!0),!0}let a=e.getAndClearShouldCheckSelectionForTable();if(a&&Jn(r)&&Jn(n)&&n.isCollapsed()){let e=Dn(a);if(pN(e)){let t=n.anchor.getNode(),r=e.getFirstChild(),i=ZM(t);if(i!==null&&pM(r)){let t=r.getFirstChild();if(cM(t)&&e.is(pr(i,n=>n.is(e)||n.is(t))))return t.selectStart(),!0}}}return EM(n)&&function(e,t){let n=FM(e),r=et();if(!t.is(r))return;let i=AM(t.tableKey),a=Te(n),o=a&&It(a,e.getRootElement());if(a&&o&&o.anchorNode&&o.focusNode){let n=Bt(o.focusNode),r=n&&!i.isParentOf(n),s=Bt(o.anchorNode),c=s&&i.isParentOf(s);if(r&&c&&a.rangeCount>0){let n=ze(a,e);n&&(n.anchor.set(i.getKey(),t.isBackward()?i.getChildrenSize():0,`element`),a.removeAllRanges(),Jt(n))}}}(t,n),Jn(n)&&function(e,t){let n=et(),{anchor:r,focus:i}=e,a=r.getNode(),o=i.getNode(),s=ZM(a),c=ZM(o),l=s?QM(s):null,u=c?QM(c):null;if(t.touchTapCellKey!==null&&!e.dirty&&!e.isCollapsed()&&Jn(n)&&n.isCollapsed()&&(!s||!s.is(c))){let e=Dn(n.anchor.key),a=e&&e.getParent();if(rr(e)&&e.isEmpty()&&cM(a)&&a.getKey()===t.touchTapCellKey&&a.getChildren().every(e=>rr(e)&&e.isEmpty())&&(r.is(n.anchor)||i.is(n.anchor)))return void Jt(n.clone())}let d=e.isBackward(),f=s&&c&&l&&u&&l.is(u),p=u&&(!l||l.isParentOf(u)),m=l&&(!u||u.isParentOf(l));if(p){let t=e.clone(),[n]=_M(u,c,c),r=n[0][0].cell,i=n[n.length-1].at(-1).cell;t.focus.set(d?r.getKey():i.getKey(),d?0:i.getChildrenSize(),`element`),Jt(t)}else if(m){let t=e.clone(),[n]=_M(l,s,s),r=n[0][0].cell,i=n[n.length-1].at(-1).cell;t.anchor.set(d?i.getKey():r.getKey(),d?i.getChildrenSize():0,`element`),Jt(t)}else if(f){if(!s.is(c))return void Jt(DM(l,s,c));let r=t.observers.get(l.getKey());if(r===void 0)return;let[i]=r;if(i.pointerType===`touch`&&i.isSelecting&&i.isPointerDrag&&e.isCollapsed()&&Jn(n)&&n.isCollapsed()){let e=Dn(n.anchor.key),t=e&&ZM(e),{pointerStartCell:r}=i,a=r&&Bt(r.elem);a!==null&&!a.is(c)&&t&&l.is(QM(t))&&!t.is(c)&&(Jt(DM(l,t,c)),i.pointerType=null)}}}(n,e),!1}(n,e)),3),e.registerUpdateListener(({dirtyElements:t})=>{if(!r){for(let e of t.keys())if(n.observers.has(e)){r=!0;break}}r&&(r=!1,e.getRootElement()!==null&&e.read(`latest`,()=>{(function(e,t){for(let[n,r]of e.$getTableNodesAndObservers())kDe(t,n,r)})(n,e)}))}),e.registerMutationListener(dN,t=>{r=!0,e.read(`latest`,()=>{for(let[e,r]of t){let t=n.observers.get(e);if(r===`created`||r===`updated`){let{tableNode:r,tableElement:a}=OM(e);t===void 0?i(r,e,a):a!==t[1]&&(n.removeObserver(e),i(r,e,a))}else r===`destroyed`&&n.removeObserver(e)}})},{skipInitialization:!1}),()=>{n.removeAllObservers()})}function HDe(e,t){e.hasNodes([dN])||uM(255);let{hasNestedTables:n=Me(!1)}=t??{};return Qn(e.registerCommand(lM,e=>function({rows:e,columns:t,includeHeaders:n},r){let i=kr()||et();if(!i||!Jn(i)||!r&&QM(i.anchor.getNode()))return!1;let a=pDe(Number(e),Number(t),n);iee(a);let o=a.getFirstDescendant();return it(o)&&o.select(),!0}(e,n.peek()),0),e.registerCommand(Dte,(t,r)=>e===r&&function(e,t){let{nodes:n,selection:r}=e;if(!n.some(e=>pN(e)||be(e).some(e=>pN(e.node)))){if(EM(r)){let e=``,t=!1;for(let r of n){let n=rr(r)&&!r.isInline();e.length>0&&(n||t)&&(e+=`
|
|
167
|
-
`),e+=r.getTextContent(),t=n}return r.insertRawText(e),!0}return!1}let i=EM(r),a=Jn(r);return!!(a&&pr(r.anchor.getNode(),e=>cM(e))!==null&&pr(r.focus.getNode(),e=>cM(e))!==null||i)&&(n.length===1&&pN(n[0])?CM(n[0],r):!(a&&t.peek()&&!function(e){return!(!EM(e)||e.focus.getNode().is(e.anchor.getNode()))||!(!Jn(e)||!cM(e.anchor.getNode())||e.anchor.getNode().is(e.focus.getNode()))}(r)))}(t,n),0),e.registerCommand(eee,zDe,1),e.registerCommand($n,RDe,0),e.registerNodeTransform(dN,LDe),e.registerNodeTransform(dM,IDe),e.registerNodeTransform(iM,FDe))}var mN=`data-inline-drag`,UDe=`application/x-haklex-inline-node`;function hN(e,t){e.draggable=!0,e.setAttribute(mN,t)}var gN=(0,G.createContext)(null),WDe=gN.Provider;function _N(){return(0,G.use)(gN)}function vN(){let e=(0,G.use)(gN);if(!e)throw Error(`useNestedContentRenderer must be used within a NestedContentRendererProvider`);return e}var GDe={note:()=>(0,K.jsx)(g,{size:16}),tip:()=>(0,K.jsx)(gi,{size:16}),important:()=>(0,K.jsx)(xi,{size:16}),warning:()=>(0,K.jsx)(v,{size:16}),caution:()=>(0,K.jsx)(wi,{size:16})},yN=({type:e})=>{let t=GDe[e];return(0,K.jsxs)(`div`,{className:`rich-alert-header rich-alert-header-${e}`,children:[(0,K.jsx)(`span`,{className:`rich-alert-icon`,children:(0,K.jsx)(t,{})}),(0,K.jsx)(`span`,{className:`rich-alert-label`,children:qDe[e]})]})};function KDe({alertType:e,contentState:t}){let n=vN();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Kj,{defaultRenderer:yN,props:{type:e},rendererKey:Lj}),(0,K.jsx)(`div`,{className:`rich-alert-content`,children:n(t)})]})}function bN(e){function t(e){return e.text?e.text:e.children?e.children.map(t).join(``):e.root?t(e.root):``}return t(e)}var qDe={note:`Note`,tip:`Tip`,important:`Important`,warning:`Warning`,caution:`Caution`},xN=class e extends wr{static getType(){return`alert-quote`}static clone(t){return new e(t.__alertType,t.__contentState,t.__key)}constructor(e,t,n){super(n),tA(this,`__alertType`,void 0),tA(this,`__contentState`,void 0),this.__alertType=e,this.__contentState=t||{root:{children:[{type:`paragraph`,children:[],direction:null,format:``,indent:0,textFormat:0,textStyle:``,version:1}],direction:null,format:``,indent:0,type:`root`,version:1}}}createDOM(e){let t=document.createElement(`div`);return t.className=`${Nj.alert} ${Pj.alert} rich-alert-${this.__alertType}`,t}updateDOM(e,t){return e.__alertType!==this.__alertType&&(t.className=`${Nj.alert} ${Pj.alert} rich-alert-${this.__alertType}`),!1}isInline(){return!1}getAlertType(){return this.__alertType}setAlertType(e){let t=this.getWritable();t.__alertType=e}getContentState(){return this.getLatest().__contentState}setContentState(e){let t=this.getWritable();t.__contentState=e}getTextContent(){return bN(this.__contentState)}static importJSON(t){let n=t;return new e(n.alertType,n.content).updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),type:`alert-quote`,alertType:this.__alertType,content:this.__contentState,version:1}}decorate(e,t){return(0,G.createElement)(KDe,{alertType:this.__alertType,contentState:this.__contentState})}};function JDe(e){return e instanceof xN}var SN=Rn(`OPEN_FILE_PICKER_COMMAND`),CN=class e extends wr{static getType(){return`footnote`}static clone(t){return new e(t.__identifier,t.__key)}constructor(e,t){super(t),tA(this,`__identifier`,void 0),this.__identifier=e}createDOM(e){let t=document.createElement(`sup`);return t.className=`${Nj.footnote} ${Pj.footnote}`,t}updateDOM(){return!1}isInline(){return!0}static importJSON(e){return wN(e.identifier).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`footnote`,identifier:this.__identifier,version:1}}getIdentifier(){return this.getLatest().__identifier}setIdentifier(e){let t=this.getWritable();t.__identifier=e}decorate(e,t){return qj(WEe,$Ee,{identifier:this.__identifier})}};function wN(e){return new CN(e)}function TN(e){if(typeof e==`number`&&Number.isFinite(e))return Math.round(Math.min(100,Math.max(10,e)))}function EN(e){if(!(typeof e!=`number`||!Number.isFinite(e)||e<=0))return Math.round(e)}function DN(e){let t=TN(e.displayWidth);if(t!==void 0)return{mode:`percent`,value:t};let n=EN(e.fixedWidth);if(n!==void 0)return{mode:`fixed-width`,px:n};let r=EN(e.fixedHeight);return r===void 0?{mode:`auto`}:{mode:`fixed-height`,px:r}}function ON(e){switch(e.mode){case`percent`:return{displayWidth:e.value};case`fixed-width`:return{fixedWidth:e.px};case`fixed-height`:return{fixedHeight:e.px};default:return{}}}function kN(e){let t=e.intrinsicWidth,n=e.intrinsicHeight;if(!(!t||!n||t<=0||n<=0))return t/n}function AN(e,t){switch(e.mode){case`percent`:return t.containerWidth>0?t.containerWidth*e.value/100:void 0;case`fixed-width`:return e.px;case`fixed-height`:{let n=kN(t);return n?e.px*n:void 0}case`auto`:return t.intrinsicWidth}}function jN(e,t){if(e.mode===`fixed-height`)return e.px;let n=AN(e,t),r=kN(t);if(n&&r)return n/r}function MN(e,t){let n=e.mode===`auto`;return{widthPx:EN(n?t.renderedWidth??AN(e,t):AN(e,t)),heightPx:EN(n?t.renderedHeight??jN(e,t):jN(e,t))}}function NN(e,t,n){if(t===`auto`)return{mode:`auto`};if(e.mode===t)return e;let r=MN(e,n);if(t===`percent`){if(!r.widthPx||n.containerWidth<=0)return e;let t=TN(r.widthPx/n.containerWidth*100);return t===void 0?e:{mode:`percent`,value:t}}if(t===`fixed-width`){let t=EN(r.widthPx);return t===void 0?e:{mode:`fixed-width`,px:t}}let i=EN(r.heightPx);return i===void 0?e:{mode:`fixed-height`,px:i}}function PN(e){switch(e.mode){case`percent`:return{"--rich-image-display-width":`${e.value}%`};case`fixed-width`:return{"--rich-image-display-width":`${e.px}px`};case`fixed-height`:return{"--rich-image-display-height":`${e.px}px`};default:return}}function FN(e){return e.mode===`auto`?void 0:e.mode}function IN(e,t,n,r){if(e===`fixed-width`){let e=EN(t);return e===void 0?{mode:`auto`}:{mode:`fixed-width`,px:e}}if(e===`fixed-height`){let e=EN(n);return e===void 0?{mode:`auto`}:{mode:`fixed-height`,px:e}}return{mode:`percent`,value:TN(t/r*100)??100}}function YDe({src:e,altText:t,width:n,height:r,caption:i,thumbhash:a,accent:o,displayWidth:s,fixedWidth:c,fixedHeight:l,layout:u}){let[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(!1),h=(0,G.useCallback)(()=>f(!0),[]),g=(0,G.useCallback)(()=>{d&&m(!0)},[d]),_=(0,G.useCallback)(()=>m(!1),[]);(0,G.useEffect)(()=>{if(!p)return;let e=e=>{e.key===`Escape`&&m(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[p]),(0,G.useEffect)(()=>{if(!p)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[p]);let v=(0,G.useCallback)(e=>{(e.key===`Enter`||e.key===` `)&&d&&(e.preventDefault(),m(!0))},[d]),y=(0,G.useMemo)(()=>a?$j(a):void 0,[a]),b=DN({displayWidth:s,fixedWidth:c,fixedHeight:l}),x=b.mode===`percent`||b.mode===`fixed-width`,S={...n&&r?{aspectRatio:`${n} / ${r}`}:{},maxWidth:`100%`,maxHeight:b.mode===`fixed-height`?`${b.px}px`:void 0,width:x?`100%`:n&&r?n:void 0},C=PN(b);return(0,K.jsxs)(`figure`,{className:`rich-image`,"data-display":FN(b),"data-layout":u,style:C,children:[(0,K.jsx)(`div`,{"aria-label":d?`Zoom image: ${t}`:void 0,className:`rich-image-container${d?` rich-image-loaded`:``}`,role:`button`,tabIndex:d?0:-1,style:{...S,backgroundColor:!d&&!y?o:void 0,backgroundImage:!d&&y?`url(${y})`:void 0,backgroundSize:`cover`,cursor:d?`zoom-in`:void 0},onClick:g,onKeyDown:v,children:(0,K.jsx)(`img`,{alt:t,className:d?`rich-image-visible`:`rich-image-hidden`,height:r,loading:`lazy`,src:e,width:n,style:b.mode===`fixed-height`?{width:`auto`,height:`auto`,maxWidth:`100%`,maxHeight:`100%`}:{maxWidth:`100%`,height:`auto`},onLoad:h})}),i&&(0,K.jsx)(`figcaption`,{children:i}),p&&(0,K.jsx)(`div`,{"aria-label":`Zoomed image: ${t}`,"aria-modal":`true`,className:`rich-image-zoom-overlay`,role:`dialog`,tabIndex:0,onClick:_,children:(0,K.jsx)(`img`,{alt:t,className:`rich-image-zoom-img`,src:e})})]})}var LN=Rn(`OPEN_IMAGE_UPLOAD_DIALOG_COMMAND`);function XDe(){let e=kr();return Jn(e)?e.anchor.getNode():Ue(e)?e.getNodes()[0]??null:null}function ZDe(){let e=XDe();return e?mDe(e)!==null:!1}function QDe(){return Vn()._parentEditor!==null}function RN(e){return e.displayWidth!==void 0||!ZDe()&&!QDe()?e:{...e,displayWidth:100}}function zN(e){let t=e.trim();return/^(?:javascript\s*:|vbscript\s*:|data\s*:(?!image\/))/i.test(t)?``:t}function BN(e){if(!e)return;let t=e.trim();if(/^#[\da-f]{3,8}$/i.test(t)||/^(?:rgb|hsl)a?\([^)]+\)$/i.test(t)||/^[a-z]{3,20}$/i.test(t))return t}var $De=[`align-left`,`align-right`,`float-left`,`float-right`];function VN(e){return $De.includes(e)?e:void 0}function HN(e,t,n){t?e.dataset.layout=t:delete e.dataset.layout,n.mode===`auto`?delete e.dataset.display:e.dataset.display=n.mode;let r=t===`float-left`||t===`float-right`;r&&n.mode===`percent`?(e.style.width=`${n.value}%`,e.style.maxWidth=``):r&&n.mode===`fixed-width`?(e.style.width=`${n.px}px`,e.style.maxWidth=`100%`):r&&n.mode===`fixed-height`?(e.style.width=`auto`,e.style.maxWidth=`100%`):(e.style.width=``,e.style.maxWidth=``)}var UN=class e extends wr{static getType(){return`image`}static clone(t){return new e({src:t.__src,altText:t.__altText,width:t.__width,height:t.__height,caption:t.__caption,thumbhash:t.__thumbhash,accent:t.__accent,displayWidth:t.__displayWidth,fixedWidth:t.__fixedWidth,fixedHeight:t.__fixedHeight,layout:t.__layout},t.__key)}constructor(e,t){super(t),tA(this,`__src`,void 0),tA(this,`__altText`,void 0),tA(this,`__width`,void 0),tA(this,`__height`,void 0),tA(this,`__caption`,void 0),tA(this,`__thumbhash`,void 0),tA(this,`__accent`,void 0),tA(this,`__displayWidth`,void 0),tA(this,`__fixedHeight`,void 0),tA(this,`__fixedWidth`,void 0),tA(this,`__layout`,void 0),tA(this,`__autoOpenOnMount`,!1),this.__src=zN(e.src),this.__altText=e.altText,this.__width=e.width,this.__height=e.height,this.__caption=e.caption,this.__thumbhash=e.thumbhash,this.__accent=BN(e.accent);let n=ON(DN(e));this.__displayWidth=n.displayWidth,this.__fixedWidth=n.fixedWidth,this.__fixedHeight=n.fixedHeight,this.__layout=VN(e.layout)}afterCloneFrom(e){super.afterCloneFrom(e),this.__autoOpenOnMount=e.__autoOpenOnMount}createDOM(e){let t=document.createElement(`div`);return t.className=`rich-image-wrapper`,HN(t,this.__layout,this.getDisplaySize()),t}updateDOM(e,t){return(e.__layout!==this.__layout||e.__displayWidth!==this.__displayWidth||e.__fixedWidth!==this.__fixedWidth||e.__fixedHeight!==this.__fixedHeight)&&HN(t,this.__layout,this.getDisplaySize()),!1}isInline(){return!1}static importJSON(e){let t=e;return WN({src:t.src,altText:t.altText,width:t.width,height:t.height,caption:t.caption,thumbhash:t.thumbhash,accent:t.accent,displayWidth:t.displayWidth,fixedWidth:t.fixedWidth,fixedHeight:t.fixedHeight,layout:t.layout}).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`image`,src:this.__src,altText:this.__altText,width:this.__width,height:this.__height,caption:this.__caption,thumbhash:this.__thumbhash,accent:this.__accent,displayWidth:this.__displayWidth,fixedWidth:this.__fixedWidth,fixedHeight:this.__fixedHeight,layout:this.__layout,version:1}}setSrc(e){let t=this.getWritable();t.__src=zN(e)}setAltText(e){let t=this.getWritable();t.__altText=e}setCaption(e){let t=this.getWritable();t.__caption=e}setDimensions(e,t){let n=this.getWritable();n.__width=e,n.__height=t}setThumbhash(e){let t=this.getWritable();t.__thumbhash=e}setAccent(e){let t=this.getWritable();t.__accent=BN(e)}applyDisplaySize(e){let t=this.getWritable(),n=ON(e);t.__displayWidth=n.displayWidth,t.__fixedWidth=n.fixedWidth,t.__fixedHeight=n.fixedHeight}setDisplayWidth(e){let t=TN(e);this.applyDisplaySize(t===void 0?{mode:`auto`}:{mode:`percent`,value:t})}setFixedWidth(e){let t=EN(e);this.applyDisplaySize(t===void 0?{mode:`auto`}:{mode:`fixed-width`,px:t})}setFixedHeight(e){let t=EN(e);this.applyDisplaySize(t===void 0?{mode:`auto`}:{mode:`fixed-height`,px:t})}setLayout(e){let t=this.getWritable();t.__layout=VN(e)}getSrc(){return this.__src}getAltText(){return this.__altText}getCaption(){return this.__caption}getWidth(){return this.__width}getHeight(){return this.__height}getThumbhash(){return this.__thumbhash}getAccent(){return this.__accent}getDisplayWidth(){return this.__displayWidth}getFixedWidth(){return this.__fixedWidth}getFixedHeight(){return this.__fixedHeight}getDisplaySize(){return DN({displayWidth:this.__displayWidth,fixedWidth:this.__fixedWidth,fixedHeight:this.__fixedHeight})}getLayout(){return this.__layout}getShouldAutoOpenOnMount(){return this.getLatest().__autoOpenOnMount}setShouldAutoOpenOnMount(e){let t=this.getWritable();t.__autoOpenOnMount=e}decorate(e,t){return qj(Bj,YDe,{src:this.__src,altText:this.__altText,width:this.__width,height:this.__height,caption:this.__caption,thumbhash:this.__thumbhash,accent:this.__accent,displayWidth:this.__displayWidth,fixedWidth:this.__fixedWidth,fixedHeight:this.__fixedHeight,layout:this.__layout,...this.__autoOpenOnMount?{autoOpenOnMount:!0}:{}})}};tA(UN,`commandItems`,[{title:`Image`,icon:(0,G.createElement)(T,{size:20}),description:`Upload or embed an image`,keywords:[`image`,`picture`,`photo`],section:`MEDIA`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.dispatchCommand(LN,void 0)||e.update(()=>{Un([WN(RN({src:``,altText:``}),{autoOpenOnMount:!0})])})}}]);function WN(e,t){let n=new UN(e);return t?.autoOpenOnMount&&n.setShouldAutoOpenOnMount(!0),n}function GN(e){return e instanceof UN}function eOe(e){return e instanceof Error&&e.message.includes(`Unable to find an active editor`)}function KN(e,t){try{let n=Qt(Vn(),e)?.klass;if(n&&(n===t||n.prototype instanceof t))return n}catch(e){if(!eOe(e))throw e}return t}var tOe=`x^2 + y^2 = z^2`;function qN(e,t){return t?.autoOpenOnMount&&!e.trim()?tOe:e}var JN=class e extends wr{static getType(){return`katex-block`}static clone(t){return new e(t.__equation,t.__key,t.__autoOpenOnMount)}constructor(e,t,n=!1){super(t),tA(this,`__equation`,void 0),tA(this,`__autoOpenOnMount`,void 0),this.__equation=e,this.__autoOpenOnMount=n}createDOM(e){let t=document.createElement(`div`);return t.className=`rich-katex-block-wrapper`,t}updateDOM(){return!1}isInline(){return!1}static importJSON(e){return YN(e.equation).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`katex-block`,equation:this.__equation,version:1}}getEquation(){return this.__equation}setEquation(e){let t=this.getWritable();t.__equation=e}getShouldAutoOpenOnMount(){return this.getLatest().__autoOpenOnMount}setShouldAutoOpenOnMount(e){let t=this.getWritable();t.__autoOpenOnMount=e}decorate(e,t){return qj(Vj,void 0,{equation:this.__equation,displayMode:!0})}};tA(JN,`slashMenuItems`,[{title:`Math Equation`,icon:(0,G.createElement)(Mi,{size:20}),description:`KaTeX block formula`,keywords:[`math`,`equation`,`latex`,`katex`],section:`ADVANCED`,onSelect:e=>{e.update(()=>{Un([YN(``,{autoOpenOnMount:!0})])})}}]);function YN(e,t){let n=new(KN(JN.getType(),JN))(qN(e,t));return t?.autoOpenOnMount&&n.setShouldAutoOpenOnMount(!0),n}function XN(e){return e instanceof JN}var ZN=class e extends wr{static getType(){return`katex-inline`}static clone(t){return new e(t.__equation,t.__key,t.__autoOpenOnMount,t.__color)}constructor(e,t,n=!1,r=null){super(t),tA(this,`__equation`,void 0),tA(this,`__autoOpenOnMount`,void 0),tA(this,`__color`,void 0),this.__equation=e,this.__autoOpenOnMount=n,this.__color=r}createDOM(e){let t=document.createElement(`span`);return hN(t,this.getKey()),t}updateDOM(){return!1}isInline(){return!0}static importJSON(e){let t=e,n=QN(t.equation);return t.color&&n.setColor(t.color),n.updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`katex-inline`,equation:this.__equation,color:this.__color,version:1}}getEquation(){return this.__equation}setEquation(e){let t=this.getWritable();t.__equation=e}getShouldAutoOpenOnMount(){return this.getLatest().__autoOpenOnMount}setShouldAutoOpenOnMount(e){let t=this.getWritable();t.__autoOpenOnMount=e}getColor(){return this.getLatest().__color}setColor(e){let t=this.getWritable();t.__color=e}decorate(e,t){let n=qj(Vj,void 0,{equation:this.__equation,displayMode:!1});return this.__color?(0,G.createElement)(`span`,{style:{color:this.__color}},n):n}};function QN(e,t){let n=new(KN(ZN.getType(),ZN))(qN(e,t));return t?.autoOpenOnMount&&n.setShouldAutoOpenOnMount(!0),n}function $N(e){return e instanceof ZN}function nOe({handle:e,displayName:t}){let n=e.replace(/^@+/,``);return(0,K.jsx)(`span`,{className:`rich-mention rich-mention-plain`,children:(0,K.jsxs)(`span`,{className:`rich-mention-handle`,children:[`@`,t||n]})})}var eP=class e extends wr{static getType(){return`mention`}static clone(t){return new e(t.__platform,t.__handle,t.__displayName,t.__key)}constructor(e,t,n,r){super(r),tA(this,`__platform`,void 0),tA(this,`__handle`,void 0),tA(this,`__displayName`,void 0),this.__platform=e,this.__handle=t,this.__displayName=n}createDOM(e){let t=document.createElement(`span`);return t.style.display=`inline-flex`,t.style.alignItems=`center`,t.style.height=`1lh`,hN(t,this.getKey()),t}updateDOM(){return!1}isInline(){return!0}getPlatform(){return this.getLatest().__platform}getHandle(){return this.getLatest().__handle}getDisplayName(){return this.getLatest().__displayName}static importJSON(e){let t=e;return tP(t.platform,t.handle,t.displayName).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`mention`,platform:this.__platform,handle:this.__handle,...this.__displayName?{displayName:this.__displayName}:{},version:1}}decorate(e,t){return qj(qEe,nOe,{platform:this.__platform,handle:this.__handle,displayName:this.__displayName})}};tA(eP,`slashMenuItems`,[{title:`Mention`,icon:(0,G.createElement)(`span`,{style:{fontSize:16,fontWeight:700}},`@`),description:`Mention a social account`,keywords:[`mention`,`at`,`@`,`github`,`twitter`],section:`INLINE`,onSelect:e=>{e.update(()=>{let e=kr();Jn(e)&&e.insertText(`@`)})}}]);function tP(e,t,n){return new eP(e,t,n)}function rOe({content:e}){return(0,K.jsx)(`div`,{className:`rich-mermaid-block`,children:(0,K.jsx)(`pre`,{children:(0,K.jsx)(`code`,{children:e})})})}var nP=class e extends wr{static getType(){return`mermaid`}static clone(t){return new e(t.__diagram,t.__key)}constructor(e,t){super(t),tA(this,`__diagram`,void 0),this.__diagram=e}createDOM(e){let t=document.createElement(`div`);return t.className=`rich-mermaid-wrapper`,t}updateDOM(){return!1}isInline(){return!1}static importJSON(e){return rP(e.diagram).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`mermaid`,diagram:this.__diagram,version:1}}getDiagram(){return this.__diagram}setDiagram(e){let t=this.getWritable();t.__diagram=e}decorate(e,t){let n=this.__key;return qj(Hj,rOe,{content:this.__diagram,onContentChange:t=>{e.update(()=>{let e=Dn(n);e&&e.setDiagram(t)})}})}};tA(nP,`commandItems`,[{title:`Mermaid Diagram`,icon:(0,G.createElement)(Wi,{size:20}),description:`Flowchart, sequence diagram`,keywords:[`mermaid`,`diagram`,`chart`,`flowchart`],section:`MEDIA`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([rP(`graph TD
|
|
167
|
+
`),e+=r.getTextContent(),t=n}return r.insertRawText(e),!0}return!1}let i=EM(r),a=Jn(r);return!!(a&&pr(r.anchor.getNode(),e=>cM(e))!==null&&pr(r.focus.getNode(),e=>cM(e))!==null||i)&&(n.length===1&&pN(n[0])?CM(n[0],r):!(a&&t.peek()&&!function(e){return!(!EM(e)||e.focus.getNode().is(e.anchor.getNode()))||!(!Jn(e)||!cM(e.anchor.getNode())||e.anchor.getNode().is(e.focus.getNode()))}(r)))}(t,n),0),e.registerCommand(eee,zDe,1),e.registerCommand($n,RDe,0),e.registerNodeTransform(dN,LDe),e.registerNodeTransform(dM,IDe),e.registerNodeTransform(iM,FDe))}var mN=`data-inline-drag`,UDe=`application/x-haklex-inline-node`;function hN(e,t){e.draggable=!0,e.setAttribute(mN,t)}var gN=(0,G.createContext)(null),WDe=gN.Provider;function _N(){return(0,G.use)(gN)}function vN(){let e=(0,G.use)(gN);if(!e)throw Error(`useNestedContentRenderer must be used within a NestedContentRendererProvider`);return e}var GDe={note:()=>(0,K.jsx)(m,{size:16}),tip:()=>(0,K.jsx)(gi,{size:16}),important:()=>(0,K.jsx)(xi,{size:16}),warning:()=>(0,K.jsx)(x,{size:16}),caution:()=>(0,K.jsx)(wi,{size:16})},yN=({type:e})=>{let t=GDe[e];return(0,K.jsxs)(`div`,{className:`rich-alert-header rich-alert-header-${e}`,children:[(0,K.jsx)(`span`,{className:`rich-alert-icon`,children:(0,K.jsx)(t,{})}),(0,K.jsx)(`span`,{className:`rich-alert-label`,children:qDe[e]})]})};function KDe({alertType:e,contentState:t}){let n=vN();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Kj,{defaultRenderer:yN,props:{type:e},rendererKey:Lj}),(0,K.jsx)(`div`,{className:`rich-alert-content`,children:n(t)})]})}function bN(e){function t(e){return e.text?e.text:e.children?e.children.map(t).join(``):e.root?t(e.root):``}return t(e)}var qDe={note:`Note`,tip:`Tip`,important:`Important`,warning:`Warning`,caution:`Caution`},xN=class e extends wr{static getType(){return`alert-quote`}static clone(t){return new e(t.__alertType,t.__contentState,t.__key)}constructor(e,t,n){super(n),tA(this,`__alertType`,void 0),tA(this,`__contentState`,void 0),this.__alertType=e,this.__contentState=t||{root:{children:[{type:`paragraph`,children:[],direction:null,format:``,indent:0,textFormat:0,textStyle:``,version:1}],direction:null,format:``,indent:0,type:`root`,version:1}}}createDOM(e){let t=document.createElement(`div`);return t.className=`${Nj.alert} ${Pj.alert} rich-alert-${this.__alertType}`,t}updateDOM(e,t){return e.__alertType!==this.__alertType&&(t.className=`${Nj.alert} ${Pj.alert} rich-alert-${this.__alertType}`),!1}isInline(){return!1}getAlertType(){return this.__alertType}setAlertType(e){let t=this.getWritable();t.__alertType=e}getContentState(){return this.getLatest().__contentState}setContentState(e){let t=this.getWritable();t.__contentState=e}getTextContent(){return bN(this.__contentState)}static importJSON(t){let n=t;return new e(n.alertType,n.content).updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),type:`alert-quote`,alertType:this.__alertType,content:this.__contentState,version:1}}decorate(e,t){return(0,G.createElement)(KDe,{alertType:this.__alertType,contentState:this.__contentState})}};function JDe(e){return e instanceof xN}var SN=Rn(`OPEN_FILE_PICKER_COMMAND`),CN=class e extends wr{static getType(){return`footnote`}static clone(t){return new e(t.__identifier,t.__key)}constructor(e,t){super(t),tA(this,`__identifier`,void 0),this.__identifier=e}createDOM(e){let t=document.createElement(`sup`);return t.className=`${Nj.footnote} ${Pj.footnote}`,t}updateDOM(){return!1}isInline(){return!0}static importJSON(e){return wN(e.identifier).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`footnote`,identifier:this.__identifier,version:1}}getIdentifier(){return this.getLatest().__identifier}setIdentifier(e){let t=this.getWritable();t.__identifier=e}decorate(e,t){return qj(WEe,$Ee,{identifier:this.__identifier})}};function wN(e){return new CN(e)}function TN(e){if(typeof e==`number`&&Number.isFinite(e))return Math.round(Math.min(100,Math.max(10,e)))}function EN(e){if(!(typeof e!=`number`||!Number.isFinite(e)||e<=0))return Math.round(e)}function DN(e){let t=TN(e.displayWidth);if(t!==void 0)return{mode:`percent`,value:t};let n=EN(e.fixedWidth);if(n!==void 0)return{mode:`fixed-width`,px:n};let r=EN(e.fixedHeight);return r===void 0?{mode:`auto`}:{mode:`fixed-height`,px:r}}function ON(e){switch(e.mode){case`percent`:return{displayWidth:e.value};case`fixed-width`:return{fixedWidth:e.px};case`fixed-height`:return{fixedHeight:e.px};default:return{}}}function kN(e){let t=e.intrinsicWidth,n=e.intrinsicHeight;if(!(!t||!n||t<=0||n<=0))return t/n}function AN(e,t){switch(e.mode){case`percent`:return t.containerWidth>0?t.containerWidth*e.value/100:void 0;case`fixed-width`:return e.px;case`fixed-height`:{let n=kN(t);return n?e.px*n:void 0}case`auto`:return t.intrinsicWidth}}function jN(e,t){if(e.mode===`fixed-height`)return e.px;let n=AN(e,t),r=kN(t);if(n&&r)return n/r}function MN(e,t){let n=e.mode===`auto`;return{widthPx:EN(n?t.renderedWidth??AN(e,t):AN(e,t)),heightPx:EN(n?t.renderedHeight??jN(e,t):jN(e,t))}}function NN(e,t,n){if(t===`auto`)return{mode:`auto`};if(e.mode===t)return e;let r=MN(e,n);if(t===`percent`){if(!r.widthPx||n.containerWidth<=0)return e;let t=TN(r.widthPx/n.containerWidth*100);return t===void 0?e:{mode:`percent`,value:t}}if(t===`fixed-width`){let t=EN(r.widthPx);return t===void 0?e:{mode:`fixed-width`,px:t}}let i=EN(r.heightPx);return i===void 0?e:{mode:`fixed-height`,px:i}}function PN(e){switch(e.mode){case`percent`:return{"--rich-image-display-width":`${e.value}%`};case`fixed-width`:return{"--rich-image-display-width":`${e.px}px`};case`fixed-height`:return{"--rich-image-display-height":`${e.px}px`};default:return}}function FN(e){return e.mode===`auto`?void 0:e.mode}function IN(e,t,n,r){if(e===`fixed-width`){let e=EN(t);return e===void 0?{mode:`auto`}:{mode:`fixed-width`,px:e}}if(e===`fixed-height`){let e=EN(n);return e===void 0?{mode:`auto`}:{mode:`fixed-height`,px:e}}return{mode:`percent`,value:TN(t/r*100)??100}}function YDe({src:e,altText:t,width:n,height:r,caption:i,thumbhash:a,accent:o,displayWidth:s,fixedWidth:c,fixedHeight:l,layout:u}){let[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(!1),h=(0,G.useCallback)(()=>f(!0),[]),g=(0,G.useCallback)(()=>{d&&m(!0)},[d]),_=(0,G.useCallback)(()=>m(!1),[]);(0,G.useEffect)(()=>{if(!p)return;let e=e=>{e.key===`Escape`&&m(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[p]),(0,G.useEffect)(()=>{if(!p)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[p]);let v=(0,G.useCallback)(e=>{(e.key===`Enter`||e.key===` `)&&d&&(e.preventDefault(),m(!0))},[d]),y=(0,G.useMemo)(()=>a?$j(a):void 0,[a]),b=DN({displayWidth:s,fixedWidth:c,fixedHeight:l}),x=b.mode===`percent`||b.mode===`fixed-width`,S={...n&&r?{aspectRatio:`${n} / ${r}`}:{},maxWidth:`100%`,maxHeight:b.mode===`fixed-height`?`${b.px}px`:void 0,width:x?`100%`:n&&r?n:void 0},C=PN(b);return(0,K.jsxs)(`figure`,{className:`rich-image`,"data-display":FN(b),"data-layout":u,style:C,children:[(0,K.jsx)(`div`,{"aria-label":d?`Zoom image: ${t}`:void 0,className:`rich-image-container${d?` rich-image-loaded`:``}`,role:`button`,tabIndex:d?0:-1,style:{...S,backgroundColor:!d&&!y?o:void 0,backgroundImage:!d&&y?`url(${y})`:void 0,backgroundSize:`cover`,cursor:d?`zoom-in`:void 0},onClick:g,onKeyDown:v,children:(0,K.jsx)(`img`,{alt:t,className:d?`rich-image-visible`:`rich-image-hidden`,height:r,loading:`lazy`,src:e,width:n,style:b.mode===`fixed-height`?{width:`auto`,height:`auto`,maxWidth:`100%`,maxHeight:`100%`}:{maxWidth:`100%`,height:`auto`},onLoad:h})}),i&&(0,K.jsx)(`figcaption`,{children:i}),p&&(0,K.jsx)(`div`,{"aria-label":`Zoomed image: ${t}`,"aria-modal":`true`,className:`rich-image-zoom-overlay`,role:`dialog`,tabIndex:0,onClick:_,children:(0,K.jsx)(`img`,{alt:t,className:`rich-image-zoom-img`,src:e})})]})}var LN=Rn(`OPEN_IMAGE_UPLOAD_DIALOG_COMMAND`);function XDe(){let e=kr();return Jn(e)?e.anchor.getNode():Ue(e)?e.getNodes()[0]??null:null}function ZDe(){let e=XDe();return e?mDe(e)!==null:!1}function QDe(){return Vn()._parentEditor!==null}function RN(e){return e.displayWidth!==void 0||!ZDe()&&!QDe()?e:{...e,displayWidth:100}}function zN(e){let t=e.trim();return/^(?:javascript\s*:|vbscript\s*:|data\s*:(?!image\/))/i.test(t)?``:t}function BN(e){if(!e)return;let t=e.trim();if(/^#[\da-f]{3,8}$/i.test(t)||/^(?:rgb|hsl)a?\([^)]+\)$/i.test(t)||/^[a-z]{3,20}$/i.test(t))return t}var $De=[`align-left`,`align-right`,`float-left`,`float-right`];function VN(e){return $De.includes(e)?e:void 0}function HN(e,t,n){t?e.dataset.layout=t:delete e.dataset.layout,n.mode===`auto`?delete e.dataset.display:e.dataset.display=n.mode;let r=t===`float-left`||t===`float-right`;r&&n.mode===`percent`?(e.style.width=`${n.value}%`,e.style.maxWidth=``):r&&n.mode===`fixed-width`?(e.style.width=`${n.px}px`,e.style.maxWidth=`100%`):r&&n.mode===`fixed-height`?(e.style.width=`auto`,e.style.maxWidth=`100%`):(e.style.width=``,e.style.maxWidth=``)}var UN=class e extends wr{static getType(){return`image`}static clone(t){return new e({src:t.__src,altText:t.__altText,width:t.__width,height:t.__height,caption:t.__caption,thumbhash:t.__thumbhash,accent:t.__accent,displayWidth:t.__displayWidth,fixedWidth:t.__fixedWidth,fixedHeight:t.__fixedHeight,layout:t.__layout},t.__key)}constructor(e,t){super(t),tA(this,`__src`,void 0),tA(this,`__altText`,void 0),tA(this,`__width`,void 0),tA(this,`__height`,void 0),tA(this,`__caption`,void 0),tA(this,`__thumbhash`,void 0),tA(this,`__accent`,void 0),tA(this,`__displayWidth`,void 0),tA(this,`__fixedHeight`,void 0),tA(this,`__fixedWidth`,void 0),tA(this,`__layout`,void 0),tA(this,`__autoOpenOnMount`,!1),this.__src=zN(e.src),this.__altText=e.altText,this.__width=e.width,this.__height=e.height,this.__caption=e.caption,this.__thumbhash=e.thumbhash,this.__accent=BN(e.accent);let n=ON(DN(e));this.__displayWidth=n.displayWidth,this.__fixedWidth=n.fixedWidth,this.__fixedHeight=n.fixedHeight,this.__layout=VN(e.layout)}afterCloneFrom(e){super.afterCloneFrom(e),this.__autoOpenOnMount=e.__autoOpenOnMount}createDOM(e){let t=document.createElement(`div`);return t.className=`rich-image-wrapper`,HN(t,this.__layout,this.getDisplaySize()),t}updateDOM(e,t){return(e.__layout!==this.__layout||e.__displayWidth!==this.__displayWidth||e.__fixedWidth!==this.__fixedWidth||e.__fixedHeight!==this.__fixedHeight)&&HN(t,this.__layout,this.getDisplaySize()),!1}isInline(){return!1}static importJSON(e){let t=e;return WN({src:t.src,altText:t.altText,width:t.width,height:t.height,caption:t.caption,thumbhash:t.thumbhash,accent:t.accent,displayWidth:t.displayWidth,fixedWidth:t.fixedWidth,fixedHeight:t.fixedHeight,layout:t.layout}).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`image`,src:this.__src,altText:this.__altText,width:this.__width,height:this.__height,caption:this.__caption,thumbhash:this.__thumbhash,accent:this.__accent,displayWidth:this.__displayWidth,fixedWidth:this.__fixedWidth,fixedHeight:this.__fixedHeight,layout:this.__layout,version:1}}setSrc(e){let t=this.getWritable();t.__src=zN(e)}setAltText(e){let t=this.getWritable();t.__altText=e}setCaption(e){let t=this.getWritable();t.__caption=e}setDimensions(e,t){let n=this.getWritable();n.__width=e,n.__height=t}setThumbhash(e){let t=this.getWritable();t.__thumbhash=e}setAccent(e){let t=this.getWritable();t.__accent=BN(e)}applyDisplaySize(e){let t=this.getWritable(),n=ON(e);t.__displayWidth=n.displayWidth,t.__fixedWidth=n.fixedWidth,t.__fixedHeight=n.fixedHeight}setDisplayWidth(e){let t=TN(e);this.applyDisplaySize(t===void 0?{mode:`auto`}:{mode:`percent`,value:t})}setFixedWidth(e){let t=EN(e);this.applyDisplaySize(t===void 0?{mode:`auto`}:{mode:`fixed-width`,px:t})}setFixedHeight(e){let t=EN(e);this.applyDisplaySize(t===void 0?{mode:`auto`}:{mode:`fixed-height`,px:t})}setLayout(e){let t=this.getWritable();t.__layout=VN(e)}getSrc(){return this.__src}getAltText(){return this.__altText}getCaption(){return this.__caption}getWidth(){return this.__width}getHeight(){return this.__height}getThumbhash(){return this.__thumbhash}getAccent(){return this.__accent}getDisplayWidth(){return this.__displayWidth}getFixedWidth(){return this.__fixedWidth}getFixedHeight(){return this.__fixedHeight}getDisplaySize(){return DN({displayWidth:this.__displayWidth,fixedWidth:this.__fixedWidth,fixedHeight:this.__fixedHeight})}getLayout(){return this.__layout}getShouldAutoOpenOnMount(){return this.getLatest().__autoOpenOnMount}setShouldAutoOpenOnMount(e){let t=this.getWritable();t.__autoOpenOnMount=e}decorate(e,t){return qj(Bj,YDe,{src:this.__src,altText:this.__altText,width:this.__width,height:this.__height,caption:this.__caption,thumbhash:this.__thumbhash,accent:this.__accent,displayWidth:this.__displayWidth,fixedWidth:this.__fixedWidth,fixedHeight:this.__fixedHeight,layout:this.__layout,...this.__autoOpenOnMount?{autoOpenOnMount:!0}:{}})}};tA(UN,`commandItems`,[{title:`Image`,icon:(0,G.createElement)(d,{size:20}),description:`Upload or embed an image`,keywords:[`image`,`picture`,`photo`],section:`MEDIA`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.dispatchCommand(LN,void 0)||e.update(()=>{Un([WN(RN({src:``,altText:``}),{autoOpenOnMount:!0})])})}}]);function WN(e,t){let n=new UN(e);return t?.autoOpenOnMount&&n.setShouldAutoOpenOnMount(!0),n}function GN(e){return e instanceof UN}function eOe(e){return e instanceof Error&&e.message.includes(`Unable to find an active editor`)}function KN(e,t){try{let n=Qt(Vn(),e)?.klass;if(n&&(n===t||n.prototype instanceof t))return n}catch(e){if(!eOe(e))throw e}return t}var tOe=`x^2 + y^2 = z^2`;function qN(e,t){return t?.autoOpenOnMount&&!e.trim()?tOe:e}var JN=class e extends wr{static getType(){return`katex-block`}static clone(t){return new e(t.__equation,t.__key,t.__autoOpenOnMount)}constructor(e,t,n=!1){super(t),tA(this,`__equation`,void 0),tA(this,`__autoOpenOnMount`,void 0),this.__equation=e,this.__autoOpenOnMount=n}createDOM(e){let t=document.createElement(`div`);return t.className=`rich-katex-block-wrapper`,t}updateDOM(){return!1}isInline(){return!1}static importJSON(e){return YN(e.equation).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`katex-block`,equation:this.__equation,version:1}}getEquation(){return this.__equation}setEquation(e){let t=this.getWritable();t.__equation=e}getShouldAutoOpenOnMount(){return this.getLatest().__autoOpenOnMount}setShouldAutoOpenOnMount(e){let t=this.getWritable();t.__autoOpenOnMount=e}decorate(e,t){return qj(Vj,void 0,{equation:this.__equation,displayMode:!0})}};tA(JN,`slashMenuItems`,[{title:`Math Equation`,icon:(0,G.createElement)(Mi,{size:20}),description:`KaTeX block formula`,keywords:[`math`,`equation`,`latex`,`katex`],section:`ADVANCED`,onSelect:e=>{e.update(()=>{Un([YN(``,{autoOpenOnMount:!0})])})}}]);function YN(e,t){let n=new(KN(JN.getType(),JN))(qN(e,t));return t?.autoOpenOnMount&&n.setShouldAutoOpenOnMount(!0),n}function XN(e){return e instanceof JN}var ZN=class e extends wr{static getType(){return`katex-inline`}static clone(t){return new e(t.__equation,t.__key,t.__autoOpenOnMount,t.__color)}constructor(e,t,n=!1,r=null){super(t),tA(this,`__equation`,void 0),tA(this,`__autoOpenOnMount`,void 0),tA(this,`__color`,void 0),this.__equation=e,this.__autoOpenOnMount=n,this.__color=r}createDOM(e){let t=document.createElement(`span`);return hN(t,this.getKey()),t}updateDOM(){return!1}isInline(){return!0}static importJSON(e){let t=e,n=QN(t.equation);return t.color&&n.setColor(t.color),n.updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`katex-inline`,equation:this.__equation,color:this.__color,version:1}}getEquation(){return this.__equation}setEquation(e){let t=this.getWritable();t.__equation=e}getShouldAutoOpenOnMount(){return this.getLatest().__autoOpenOnMount}setShouldAutoOpenOnMount(e){let t=this.getWritable();t.__autoOpenOnMount=e}getColor(){return this.getLatest().__color}setColor(e){let t=this.getWritable();t.__color=e}decorate(e,t){let n=qj(Vj,void 0,{equation:this.__equation,displayMode:!1});return this.__color?(0,G.createElement)(`span`,{style:{color:this.__color}},n):n}};function QN(e,t){let n=new(KN(ZN.getType(),ZN))(qN(e,t));return t?.autoOpenOnMount&&n.setShouldAutoOpenOnMount(!0),n}function $N(e){return e instanceof ZN}function nOe({handle:e,displayName:t}){let n=e.replace(/^@+/,``);return(0,K.jsx)(`span`,{className:`rich-mention rich-mention-plain`,children:(0,K.jsxs)(`span`,{className:`rich-mention-handle`,children:[`@`,t||n]})})}var eP=class e extends wr{static getType(){return`mention`}static clone(t){return new e(t.__platform,t.__handle,t.__displayName,t.__key)}constructor(e,t,n,r){super(r),tA(this,`__platform`,void 0),tA(this,`__handle`,void 0),tA(this,`__displayName`,void 0),this.__platform=e,this.__handle=t,this.__displayName=n}createDOM(e){let t=document.createElement(`span`);return t.style.display=`inline-flex`,t.style.alignItems=`center`,t.style.height=`1lh`,hN(t,this.getKey()),t}updateDOM(){return!1}isInline(){return!0}getPlatform(){return this.getLatest().__platform}getHandle(){return this.getLatest().__handle}getDisplayName(){return this.getLatest().__displayName}static importJSON(e){let t=e;return tP(t.platform,t.handle,t.displayName).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`mention`,platform:this.__platform,handle:this.__handle,...this.__displayName?{displayName:this.__displayName}:{},version:1}}decorate(e,t){return qj(qEe,nOe,{platform:this.__platform,handle:this.__handle,displayName:this.__displayName})}};tA(eP,`slashMenuItems`,[{title:`Mention`,icon:(0,G.createElement)(`span`,{style:{fontSize:16,fontWeight:700}},`@`),description:`Mention a social account`,keywords:[`mention`,`at`,`@`,`github`,`twitter`],section:`INLINE`,onSelect:e=>{e.update(()=>{let e=kr();Jn(e)&&e.insertText(`@`)})}}]);function tP(e,t,n){return new eP(e,t,n)}function rOe({content:e}){return(0,K.jsx)(`div`,{className:`rich-mermaid-block`,children:(0,K.jsx)(`pre`,{children:(0,K.jsx)(`code`,{children:e})})})}var nP=class e extends wr{static getType(){return`mermaid`}static clone(t){return new e(t.__diagram,t.__key)}constructor(e,t){super(t),tA(this,`__diagram`,void 0),this.__diagram=e}createDOM(e){let t=document.createElement(`div`);return t.className=`rich-mermaid-wrapper`,t}updateDOM(){return!1}isInline(){return!1}static importJSON(e){return rP(e.diagram).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`mermaid`,diagram:this.__diagram,version:1}}getDiagram(){return this.__diagram}setDiagram(e){let t=this.getWritable();t.__diagram=e}decorate(e,t){let n=this.__key;return qj(Hj,rOe,{content:this.__diagram,onContentChange:t=>{e.update(()=>{let e=Dn(n);e&&e.setDiagram(t)})}})}};tA(nP,`commandItems`,[{title:`Mermaid Diagram`,icon:(0,G.createElement)(Wi,{size:20}),description:`Flowchart, sequence diagram`,keywords:[`mermaid`,`diagram`,`chart`,`flowchart`],section:`MEDIA`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([rP(`graph TD
|
|
168
168
|
A[Start] --> B[End]`)])})}}]);function rP(e){return new nP(e)}var iP=`data-quote-attribution-slot`;function aP(e){for(let t of e.children)if(t.hasAttribute(iP))return t;return null}function oP(e){return e==null?null:e.trim()||null}var sP=class e extends mr{constructor(e=null,t){super(t),tA(this,`__attribution`,void 0),this.__attribution=oP(e)}static getType(){return`rich-quote`}static clone(t){return new e(t.__attribution,t.__key)}static importJSON(e){let t=e;return iOe(t.attribution??null).updateFromJSON(t)}createDOM(e){let t=super.createDOM(e),n=document.createElement(`div`);return n.setAttribute(iP,``),n.contentEditable=`false`,Tt(n,{captureSelection:!0}),t.append(n),t}getDOMSlot(e){return super.getDOMSlot(e).withBefore(aP(e))}exportDOM(e){let t=super.exportDOM(e),{element:n}=t;if(!fe(n))return t;aP(n)?.remove();let r=this.getAttribution();return r?{...t,after:e=>{let n=t.after?t.after(e):e;if(fe(n)){let e=document.createElement(`footer`);e.textContent=`— ${r}`,n.append(e)}return n}}:t}exportJSON(){return{...super.exportJSON(),type:`rich-quote`,attribution:this.__attribution}}getAttribution(){return this.getLatest().__attribution}setAttribution(e){let t=this.getWritable();return t.__attribution=oP(e),t}};function iOe(e=null){return new sP(e)}var cP=class e extends $e{static getType(){return`spoiler`}static clone(t){return new e(t.__key)}constructor(e){super(e)}createDOM(e){let t=document.createElement(`span`);t.className=`${Nj.spoiler} ${Pj.spoiler}`,t.setAttribute(`role`,`button`),t.setAttribute(`tabindex`,`0`),t.setAttribute(`aria-label`,`Spoiler (click to reveal)`);let n=()=>{if(t.isContentEditable)return;t.classList.toggle(Nj.spoilerRevealed);let e=t.classList.toggle(Pj.spoilerRevealed);t.setAttribute(`aria-label`,e?`Spoiler (revealed)`:`Spoiler (click to reveal)`)};return t.addEventListener(`click`,n),t.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())}),t}updateDOM(){return!1}static importJSON(e){return lP().updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`spoiler`,version:1}}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!0}};function lP(){return new cP}function aOe(e){return e instanceof cP}function oOe(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);let n=t%360;return n<0?n+360:n}function uP(e){let t=oOe(e),n=70+t%21,r=40+t%31;return`hsla(${t}, ${n>30?n-30:0}%, ${r<80?r+20:100}%, 0.7)`}var sOe=`${Nj.tag} ${Pj.tag}`,dP=class e extends pt{static getType(){return`tag`}static clone(t){return new e(t.__text,t.__key)}static importDOM(){return{span:()=>({conversion:e=>!(e instanceof HTMLElement)||!e.classList.contains(Nj.tag)?null:{node:fP(e.textContent??``)},priority:2})}}constructor(e,t){super(e,t)}createDOM(e){let t=super.createDOM(e);return t.classList.add(Nj.tag,Pj.tag),t.style.backgroundColor=uP(this.getTextContent()),t}updateDOM(e,t,n){let r=super.updateDOM(e,t,n);return t.classList.add(Nj.tag,Pj.tag),e.__text!==this.__text&&(t.style.backgroundColor=uP(this.__text)),r}exportDOM(e){let t=document.createElement(`span`);return t.className=sOe,t.style.backgroundColor=uP(this.getTextContent()),t.textContent=this.getTextContent(),{element:t}}getText(){return this.getTextContent()}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}isTextEntity(){return!0}static importJSON(e){let t=e,n=fP(t.text??``);return n.setFormat(t.format??0),n.setDetail(t.detail??0),n.setMode(t.mode??`normal`),n.setStyle(t.style??``),n}exportJSON(){return{...super.exportJSON(),type:`tag`,version:1}}};tA(dP,`commandItems`,[{title:`Tag`,icon:(0,G.createElement)(Li,{size:20}),description:`Insert a tag`,keywords:[`tag`,`label`,`badge`],section:`INLINE`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:(e,t)=>{e.update(()=>{Un([fP(t||`tag`)])})}}]);function fP(e){return new dP(e)}var pP=e=>`${Nj[e]} ${Pj[e]}`,mP={text:{bold:pP(`textBold`),italic:pP(`textItalic`),underline:pP(`textUnderline`),strikethrough:pP(`textStrikethrough`),superscript:pP(`textSuperscript`),subscript:pP(`textSubscript`),code:pP(`textCode`),highlight:pP(`textHighlight`)},heading:{h1:pP(`headingH1`),h2:pP(`headingH2`),h3:pP(`headingH3`),h4:pP(`headingH4`),h5:pP(`headingH5`),h6:pP(`headingH6`)},list:{ol:pP(`listOl`),ul:pP(`listUl`),listitem:pP(`listItem`),listitemChecked:pP(`listItemChecked`),listitemUnchecked:pP(`listItemUnchecked`),checklist:pP(`checklist`),nested:{listitem:pP(`listNestedItem`)}},quote:pP(`quote`),link:pP(`link`),paragraph:pP(`paragraph`),code:`rich-code-block`,table:pP(`table`),tableCell:pP(`tableCell`),tableCellHeader:pP(`tableCellHeader`),tableScrollableWrapper:pP(`tableScrollableWrapper`),hr:pP(`hr`)},hP={details:`rich-details`,summary:`rich-details-summary`,summaryText:`rich-details-summary-text`,chevron:`rich-details-chevron`,content:`rich-details-content`},gP={details:`_1o2d5g50`,summary:`_1o2d5g51`,summaryText:`_1o2d5g52`,chevron:`_1o2d5g53`,content:`_1o2d5g54`},_P={container:`rich-grid-container`,toolbar:`rich-grid-toolbar`,toolbarIcon:`rich-grid-toolbar-icon`,colButton:`rich-grid-col-btn`,colButtonActive:`rich-grid-col-btn-active`,toolbarDivider:`rich-grid-toolbar-divider`,actionButton:`rich-grid-action-btn`,inner:`rich-grid-inner`,cell:`rich-grid-cell`,cellEditable:`rich-grid-cell-editable`},vP={container:`_17ihk870`,toolbar:`_17ihk871`,toolbarIcon:`_17ihk872`,colButton:`_17ihk873`,colButtonActive:`_17ihk874`,toolbarDivider:`_17ihk875`,actionButton:`_17ihk876`,inner:`_17ihk877`,cell:`_17ihk878`,cellEditable:`_17ihk879`};function cOe(e){if(e==null||!Number.isFinite(e)||e<0)return null;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e,r=``;for(let e of t)if(n/=1024,r=e,n<1024)break;return`${n>=100?Math.round(n):n.toFixed(1)} ${r}`}function lOe(e,t){if(t)return t.toUpperCase();let n=e.lastIndexOf(`.`);if(n<=0||n===e.length-1)return null;let r=e.slice(n+1);return r.length>8?null:r.toUpperCase()}function uOe(e,t,n){return[cOe(t),lOe(e,n)].filter(Boolean).join(` · `)}function dOe({src:e,name:t,size:n,ext:r,display:i}){if(i===`inline`)return(0,K.jsx)(`a`,{className:`rich-file-chip`,download:t,href:e||void 0,rel:`noopener noreferrer`,target:`_blank`,children:t});let a=uOe(t,n,r);return(0,K.jsxs)(`a`,{className:`rich-file-card`,download:t,href:e||void 0,rel:`noopener noreferrer`,target:`_blank`,children:[(0,K.jsx)(`span`,{className:`rich-file-card-name`,children:t}),a&&(0,K.jsx)(`span`,{className:`rich-file-card-meta`,children:a})]})}function fOe({url:e,title:t,description:n,favicon:r,image:i}){return(0,K.jsxs)(`a`,{className:`rich-link-card`,href:e,rel:`noopener noreferrer`,target:`_blank`,children:[i&&(0,K.jsx)(`span`,{className:`rich-link-card-image`,children:(0,K.jsx)(`img`,{alt:``,loading:`lazy`,src:i})}),(0,K.jsxs)(`span`,{className:`rich-link-card-content`,children:[(0,K.jsxs)(`span`,{className:`rich-link-card-title`,children:[r&&(0,K.jsx)(`img`,{alt:``,className:`rich-link-card-favicon`,height:16,src:r,width:16,onError:e=>{e.target.style.display=`none`}}),t||e]}),n&&(0,K.jsx)(`span`,{className:`rich-link-card-description`,children:n}),(0,K.jsx)(`span`,{className:`rich-link-card-url`,children:e})]})]})}function pOe(e){return e.canIndent()}function mOe(e,t,n=pOe){return Qn(e.registerCommand(Qe,t=>{let n=kr();if(!Jn(n))return!1;t.preventDefault();let r=function(e){if(e.getNodes().filter(e=>Nee(e)&&e.canIndent()).length>0)return!0;let t=e.anchor,n=e.focus,r=n.isBefore(t)?n:t,i=r.getNode(),a=aee(i);if(a.canIndent()){let e=a.getKey(),t=zt();if(t.anchor.set(e,0,`element`),t.focus.set(e,0,`element`),t=_n(t),t.anchor.is(r))return!0}return!1}(n)?t.shiftKey?Cee:fn:tte;return e.dispatchCommand(r)},0),e.registerCommand(fn,()=>{let e=typeof t==`number`?t:t?t.peek():null,r=kr();if(!Jn(r))return!1;let i=typeof n==`function`?n:n.peek();return lee(t=>{if(i(t)){let n=t.getIndent()+1;(!e||n<e)&&t.setIndent(n)}})},4))}function hOe(e){return()=>{}}function gOe(e,t){let n=e;for(let r=Kt(e,t);r&&(NP(r.origin)||ot(r.origin));r=r.getAdjacentCaret())n=r.origin;return n}function _Oe(e){return gOe(e,`previous`)}var vOe=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function yP(e,t){if(typeof e==`number`)return Number.isFinite(e)?e:t;if(typeof e!=`string`||!vOe.test(e))return t;let n=Number(e);return Number.isFinite(n)?n:t}var yOe=e=>{let t=In(e,`format`),n=Pt(e,`format`),r=bt(e,`format`);return{exportJSON:function(e){let n=e.__textFormat,r=e.__textStyle,i=(n!==0||r!==``)&&e.shouldSerializeTextStyles();return{children:[],language:e.__language,theme:e.__theme,direction:e.__dir,format:t[e.__format],indent:e.__indent,textFormat:n!==0&&i?n:void 0,textStyle:r!==``&&i?r:void 0,type:e.__type,version:1}},exportCompactJSON:function(e){let n=e.__textFormat,r=e.__textStyle,i=(n!==0||r!==``)&&e.shouldSerializeTextStyles(),a={type:e.__type,children:[]},o=e.__language;o!==void 0&&(a.language=o);let s=e.__theme;s!==void 0&&(a.theme=s);let c=e.__dir;c!=null&&(a.direction=c);let l=t[e.__format];l!==void 0&&l!==``&&(a.format=l);let u=e.__indent;return u!==void 0&&u!==0&&(a.indent=u),n!==void 0&&n!==0&&i&&(a.textFormat=n),r!==void 0&&r!==``&&i&&(a.textStyle=r),a},updateFromJSON:function(e,t){let i=t.direction;e.__dir=i===null||i===`ltr`||i===`rtl`?i:null;let a=t.format;e.__format=typeof a==`string`&&a in n?n[a]:r,e.__indent=function(e){let t=yP(e,0);return t>=0&&t<=1/0&&Number.isInteger(t)?t:0}(t.indent),e.__textFormat=yP(t.textFormat,0);let o=t.textStyle;e.__textStyle=typeof o==`string`?o:``;let s=t.language;e.setLanguage(s==null||typeof s==`string`?s:``);let c=t.theme;return e.setTheme(c===void 0?void 0:typeof c==`string`?c:``),e}}};function bOe(e,t){e.__highlightType=t.__highlightType}var xOe=e=>{let t=In(e,`mode`),n=vn(e,`detail`,0),r=vn(e,`format`,0),i=Pt(e,`mode`),a=bt(e,`mode`);return{exportJSON:function(e){return{highlightType:e.__highlightType,detail:e.__detail,format:e.__format,mode:t[e.__mode],style:e.__style,text:e.__text,type:e.__type,version:1}},exportCompactJSON:function(e){let n={type:e.__type},r=e.__highlightType;r!==void 0&&(n.highlightType=r);let i=e.__detail;i!==void 0&&i!==0&&(n.detail=i);let a=e.__format;a!==void 0&&a!==0&&(n.format=a);let o=t[e.__mode];o!==void 0&&o!==`normal`&&(n.mode=o);let s=e.__style;s!==void 0&&s!==``&&(n.style=s);let c=e.__text;return c!==void 0&&c!==``&&(n.text=c),n},updateFromJSON:function(e,t){let o=t.detail;e.__detail=typeof o==`string`&&o in n?n[o]:yP(o,0);let s=t.format;e.setFormat(typeof s==`string`&&s in r?r[s]:yP(s,0));let c=t.mode;e.__mode=typeof c==`string`&&c in i?i[c]:a;let l=t.style;e.__style=typeof l==`string`?l:``;let u=t.text;e.__text=typeof u==`string`?u:``;let d=t.highlightType;return e.setHighlightType(d==null||typeof d==`string`?d:``),e},afterCloneFrom:bOe}},SOe=se()({language:nt(N(vt(gr())),{getter:{field:`__language`}}),theme:nt(N(gr()),{getter:{field:`__theme`}})});function bP(e,t){for(let n of e.childNodes)if(fe(n)&&n.tagName===t||bP(n,t))return!0;return!1}var xP=`data-language`,SP=`data-highlight-language`,CP=`data-theme`,COe=hOe(),wP=class extends $e{__language;__theme;__isSyntaxHighlightSupported;$config(){return this.config(`code`,{children:`inline`,extends:$e,generated:yOe,importDOM:{code:e=>e.textContent!=null&&(/\r?\n/.test(e.textContent)||bP(e,`BR`))?{conversion:DP,priority:1}:null,div:()=>({conversion:wOe,priority:1}),pre:()=>({conversion:DP,priority:0}),table:e=>AP(e)?{conversion:TOe,priority:3}:null,td:e=>{let t=e,n=t.closest(`table`);return t.classList.contains(`js-file-line`)||n&&AP(n)?{conversion:OP,priority:3}:null},tr:e=>{let t=e.closest(`table`);return t&&AP(t)?{conversion:OP,priority:3}:null}},json:SOe})}constructor(e=void 0,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),function(e,t){e.__language=t.__language,e.__theme=t.__theme}(this,e),this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(e){let t=Sn().createElement(`code`);Tr(t,e.theme.code),t.setAttribute(`spellcheck`,`false`);let n=this.getLanguage();n&&(t.setAttribute(xP,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(SP,n));let r=this.getTheme();r&&t.setAttribute(CP,r);let i=this.getStyle();return i&&An(t.style,i),t}updateDOM(e,t,n){let r=this.__language,i=e.__language;r?r!==i&&t.setAttribute(xP,r):i&&t.removeAttribute(xP);let a=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&i?a&&r?r!==i&&t.setAttribute(SP,r):t.removeAttribute(SP):a&&r&&t.setAttribute(SP,r);let o=this.__theme,s=e.__theme;o?o!==s&&t.setAttribute(CP,o):s&&t.removeAttribute(CP);let c=this.__style,l=e.__style;return c!==l&&An(t.style,c,l),!1}exportDOM(e){let t=Sn().createElement(`pre`);Tr(t,e._config.theme.code),t.setAttribute(`spellcheck`,`false`);let n=this.getLanguage();n&&(t.setAttribute(xP,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(SP,n));let r=this.getTheme();r&&t.setAttribute(CP,r);let i=this.getStyle();return i&&An(t.style,i),{element:t}}insertNewAfter(e,t=!0){if(!kt(Vn(),`@lexical/code`)){COe();let t=EOe(e);if(t)return t}let{anchor:n,focus:r}=e,i=(n.isBefore(r)?n:r).getNode();if(it(i)){let e=_Oe(i),t=[];for(;;)if(ot(e))t.push(ln()),e=e.getNextSibling();else{if(!NP(e))break;{let n=0,r=e.getTextContent(),i=e.getTextContentSize();for(;n<i&&r[n]===` `;)n++;if(n!==0&&t.push(OOe(` `.repeat(n))),n!==i)break;e=e.getNextSibling()}}let r=i.splitText(n.offset)[0],a=n.offset===0?0:1,o=r.getIndexWithinParent()+a,s=i.getParentOrThrow(),c=[ve(),...t];s.splice(o,0,c);let l=t[t.length-1];l?l.select():n.offset===0?r.selectPrevious():r.getNextSibling().selectNext(0,0)}if(EP(i)){let{offset:t}=e.anchor;i.splice(t,0,[ve()]),i.select(t+1,t+1)}return null}canIndent(){return!1}collapseAtStart(){let e=on();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}setLanguage(e){let t=this.getWritable();return t.__language=e||void 0,t}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(e){let t=this.getWritable();return t.__isSyntaxHighlightSupported=e,t}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(e){let t=this.getWritable();return t.__theme=e||void 0,t}getTheme(){return this.getLatest().__theme}};function TP(e,t){return Le(wP).setLanguage(e).setTheme(t)}function EP(e){return e instanceof wP}function DP(e){return{node:TP(e.getAttribute(xP),e.getAttribute(CP))}}function wOe(e){let t=e,n=kP(t);return n||function(e){let t=e.parentElement;for(;t!==null;){if(kP(t))return!0;t=t.parentElement}return!1}(t)?{node:n?TP():null}:{node:null}}function TOe(){return{node:TP()}}function OP(){return{node:null}}function kP(e){return e.style.fontFamily.match(`monospace`)!==null}function AP(e){return e.classList.contains(`js-file-line-container`)}function EOe(e){let{anchor:t}=e;if(e.isCollapsed()&&t.type===`element`){let e=t.getNode();if(EP(e)){let n=e.getChildrenSize();if(n>=2&&t.offset===n){let t=e.getLastChild();if(lr(t)&&lr(t.getPreviousSibling())){let t=on();return e.splice(n-2,2,[]).insertAfter(t,!1),t.select(),t}}}}return null}var DOe=se()({highlightType:nt(N(vt(gr())),{getter:{field:`__highlightType`}})}),jP=class extends pt{__highlightType;constructor(e=``,t,n){super(e,n),this.__highlightType=t}$config(){return this.config(`code-highlight`,{extends:pt,generated:xOe,json:DOe})}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){let t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(e){let t=super.createDOM(e),n=MP(e.theme,this.__highlightType);return Tr(t,n),t}updateDOM(e,t,n){let r=super.updateDOM(e,t,n),i=MP(n.theme,e.__highlightType),a=MP(n.theme,this.__highlightType);return i!==a&&(i&&Ln(t,i),a&&Tr(t,a)),r}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return TP()}};function MP(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function OOe(e=``,t){return Ct(new jP(e,t))}function NP(e){return e instanceof jP}var PP=({type:e})=>(0,K.jsx)(`span`,{className:`rich-banner-icon rich-banner-icon-${e}`});function kOe({bannerType:e,contentState:t}){let n=vN();return(0,K.jsxs)(`div`,{className:`rich-banner-inner`,children:[(0,K.jsx)(Kj,{defaultRenderer:PP,props:{type:e},rendererKey:Rj}),(0,K.jsx)(`div`,{className:`rich-banner-content`,children:n(t)})]})}var FP={info:`note`,success:`tip`,error:`caution`};function IP(e){return e in FP?FP[e]:e||`note`}var LP=class e extends wr{static getType(){return`banner`}static clone(t){return new e(t.__bannerType,t.__contentState,t.__key)}constructor(e,t,n){super(n),tA(this,`__bannerType`,void 0),tA(this,`__contentState`,void 0),this.__bannerType=e,this.__contentState=t||{root:{children:[{type:`paragraph`,children:[],direction:null,format:``,indent:0,textFormat:0,textStyle:``,version:1}],direction:null,format:``,indent:0,type:`root`,version:1}}}createDOM(e){let t=document.createElement(`div`);return t.className=`rich-banner rich-banner-${this.__bannerType}`,t}updateDOM(e,t){return e.__bannerType!==this.__bannerType&&(t.className=`rich-banner rich-banner-${this.__bannerType}`),!1}isInline(){return!1}getBannerType(){return this.__bannerType}setBannerType(e){let t=this.getWritable();t.__bannerType=e}getContentState(){return this.getLatest().__contentState}setContentState(e){let t=this.getWritable();t.__contentState=e}getTextContent(){return bN(this.__contentState)}static importJSON(t){let n=t,r=n,i=IP(n.bannerType);if(n.content)return new e(i,n.content).updateFromJSON(t);if(r.children){let n={root:{children:r.children,direction:null,format:``,indent:0,type:`root`,version:1}};return new e(i,n).updateFromJSON(t)}return new e(i).updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),type:`banner`,bannerType:this.__bannerType,content:this.__contentState,version:1}}decorate(e,t){return(0,G.createElement)(kOe,{bannerType:this.__bannerType,contentState:this.__contentState})}};function AOe(e){return e instanceof LP}var RP=class e extends wr{static getType(){return`code-block`}static clone(t){return new e(t.__code,t.__language,t.__key)}constructor(e,t,n){super(n),tA(this,`__code`,void 0),tA(this,`__language`,void 0),this.__code=e,this.__language=t}createDOM(e){let t=document.createElement(`div`);return t.className=`rich-code-block-wrapper`,t}updateDOM(){return!1}isInline(){return!1}isKeyboardSelectable(){return!0}static importJSON(e){let t=e;return zP(t.code,t.language).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`code-block`,code:this.__code,language:this.__language,version:1}}getCode(){return this.__code}setCode(e){let t=this.getWritable();t.__code=e}getLanguage(){return this.__language}setLanguage(e){let t=this.getWritable();t.__language=e}decorate(e,t){return qj(zj,void 0,{code:this.__code,language:this.__language})}};tA(RP,`commandItems`,[{title:`Code Block`,icon:(0,G.createElement)(Pr,{size:20}),description:`Syntax-highlighted code`,keywords:[`code`,`snippet`,`codeblock`],section:`MEDIA`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([zP(``,`text`)])})}}]);function zP(e,t){return new RP(e,t)}function BP(e){return e instanceof RP}var VP=`comment`,HP=class e extends pt{static getType(){return`comment`}static clone(t){return new e(t.__text,t.__key)}static importDOM(){return{"#comment":()=>({conversion:e=>e instanceof Comment?{node:UP(e.data)}:null,priority:4}),span:()=>({conversion:e=>!(e instanceof HTMLElement)||!e.classList.contains(Nj.comment)?null:{node:UP(e.dataset.comment??e.textContent??``)},priority:2})}}constructor(e,t){super(e,t)}createDOM(e){let t=super.createDOM(e);return t.classList.add(Nj.comment,Pj.comment),t.dataset.comment=this.__text,t}updateDOM(e,t,n){let r=super.updateDOM(e,t,n);return t.classList.add(Nj.comment,Pj.comment),e.__text!==this.__text&&(t.dataset.comment=this.__text),r}exportDOM(e){return{element:document.createComment(this.getTextContent())}}static importJSON(e){let t=e,n=UP(t.text??``);return n.setFormat(t.format??0),n.setDetail(t.detail??0),n.setMode(t.mode??`normal`),n.setStyle(t.style??``),n}exportJSON(){return{...super.exportJSON(),type:`comment`,version:1}}};tA(HP,`commandItems`,[{title:`HTML Comment`,icon:(0,G.createElement)(Vne,{size:20}),description:`Insert an HTML comment node`,keywords:[`comment`,`html`,`annotation`,`hidden`,`<!-- -->`],section:`INLINE`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:(e,t)=>{e.update(()=>{let e=UP(VP);Un([e]),e.select(0,e.getTextContentSize())})}}]);function UP(e){return new HP(e)}function jOe(){return UP(VP)}var WP=`http://www.w3.org/2000/svg`,MOe={xmlns:WP,width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`};function NOe(e,t={}){let n=document.createElementNS(WP,`svg`),r={...MOe,...t};for(let[e,t]of Object.entries(r))n.setAttribute(e,t);for(let[t,r]of e){let e=document.createElementNS(WP,t);for(let[t,n]of Object.entries(r))t!==`key`&&e.setAttribute(t,n);n.append(e)}return n}var POe=[[`path`,{d:`M8 6L12 10L8 14`}]],GP=class e extends $e{static getType(){return`details`}static clone(t){return new e(t.__summary,t.__open,t.__key)}constructor(e,t=!1,n){super(n),tA(this,`__summary`,void 0),tA(this,`__open`,void 0),this.__summary=e,this.__open=t}createDOM(e){let t=document.createElement(`details`);t.className=`${hP.details} ${gP.details}`,this.__open&&(t.open=!0);let n=document.createElement(`summary`);n.className=`${hP.summary} ${gP.summary}`;let r=document.createElement(`span`);r.className=`${hP.chevron} ${gP.chevron}`,r.setAttribute(`aria-hidden`,`true`),r.append(NOe(POe,{width:`20`,height:`20`,viewBox:`0 0 20 20`,"stroke-width":`1.5`})),n.append(r);let i=document.createElement(`span`);i.className=`${hP.summaryText} ${gP.summaryText}`,i.textContent=this.__summary,n.append(i);let a=document.createElement(`div`);return a.className=`${hP.content} ${gP.content}`,t.append(n,a),t}updateDOM(e,t){let n=t;if(e.__open!==this.__open&&(n.open=this.__open),e.__summary!==this.__summary){let e=t.querySelector(`.${hP.summaryText}`);e&&(e.textContent=this.__summary)}return!1}static importJSON(e){let t=e;return KP(t.summary,t.open).updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),type:`details`,summary:this.__summary,open:this.__open,version:1}}getSummary(){return this.getLatest().__summary}setSummary(e){let t=this.getWritable();t.__summary=e}getOpen(){return this.getLatest().__open}setOpen(e){let t=this.getWritable();t.__open=e}toggleOpen(){this.setOpen(!this.getOpen())}getDOMSlot(e){let t=e.querySelector(`.${hP.content}`);return super.getDOMSlot(e).withElement(t)}isInline(){return!1}};tA(GP,`slashMenuItems`,[{title:`Details`,icon:(0,G.createElement)(Ite,{size:20}),description:`Collapsible content block`,keywords:[`details`,`toggle`,`collapse`,`accordion`],section:`ADVANCED`,onSelect:e=>{e.update(()=>{let e=KP(`Details`,!0),t=on();e.append(t),Un([e]),t.selectStart()})}}]);function KP(e,t=!1){return new GP(e,t)}function FOe(e){let t=e.lastIndexOf(`.`);if(t<=0||t===e.length-1)return;let n=e.slice(t+1).toLowerCase();return n.length>8?void 0:n}var qP=class e extends wr{static getType(){return`file`}static clone(t){return new e({src:t.__src,name:t.__name,size:t.__size,mimeType:t.__mimeType,ext:t.__ext,display:t.__display},t.__key)}constructor(e,t){super(t),tA(this,`__src`,void 0),tA(this,`__name`,void 0),tA(this,`__size`,void 0),tA(this,`__mimeType`,void 0),tA(this,`__ext`,void 0),tA(this,`__display`,void 0),this.__src=e.src,this.__name=e.name,this.__size=e.size,this.__mimeType=e.mimeType,this.__ext=e.ext,this.__display=e.display??`block`}createDOM(e){let t=document.createElement(this.__display===`inline`?`span`:`div`);return t.className=`rich-file-wrapper`,this.__display===`inline`&&hN(t,this.getKey()),t}updateDOM(){return!1}isInline(){return this.__display===`inline`}static importJSON(e){let t=e;return JP({src:t.src,name:t.name,size:t.size,mimeType:t.mimeType,ext:t.ext,display:t.display}).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`file`,src:this.__src,name:this.__name,size:this.__size,mimeType:this.__mimeType,ext:this.__ext,display:this.__display,version:1}}getSrc(){return this.getLatest().__src}setSrc(e){this.getWritable().__src=e}getName(){return this.getLatest().__name}setName(e){this.getWritable().__name=e}getDisplay(){return this.getLatest().__display}getPayload(){let e=this.getLatest();return{src:e.__src,name:e.__name,size:e.__size,mimeType:e.__mimeType,ext:e.__ext,display:e.__display}}setFilePayload(e){let t=this.getWritable();e.src!==void 0&&(t.__src=e.src),e.name!==void 0&&(t.__name=e.name),t.__size=e.size,t.__mimeType=e.mimeType,t.__ext=e.ext}decorate(e,t){return qj(UEe,dOe,{src:this.__src,name:this.__name,size:this.__size,mimeType:this.__mimeType,ext:this.__ext,display:this.__display,nodeKey:this.getKey()})}};tA(qP,`commandItems`,[{title:`File`,icon:(0,G.createElement)(Ei,{size:20}),description:`Attach a file`,keywords:[`file`,`attachment`,`upload`,`wenjian`,`fujian`],section:`MEDIA`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.dispatchCommand(SN,void 0)}}]);function JP(e){return new qP(e)}function IOe(e){return e instanceof qP}function LOe({definitions:e}){let{displayNumberMap:t}=Xj(),n=Object.entries(e).sort(([e],[n])=>(t[e]??0)-(t[n]??0));return n.length===0?null:(0,K.jsxs)(`div`,{role:`doc-endnotes`,className:Fj(`rich-footnote-section-content`,Nj.footnoteSection,Pj.footnoteSection),children:[(0,K.jsx)(`hr`,{className:Fj(Nj.footnoteSectionDivider,Pj.footnoteSectionDivider)}),(0,K.jsx)(`ol`,{className:Fj(Nj.footnoteSectionList,Pj.footnoteSectionList),children:n.map(([e,n])=>{let r=t[e]??e;return(0,K.jsx)(ROe,{content:n,displayNum:r,identifier:e},e)})})]})}function ROe({identifier:e,content:t,displayNum:n}){let r=`footnote-${e}`,i=`footnote-ref-${e}`,a=(0,G.useCallback)(e=>{e.preventDefault();let t=document.getElementById(i);t&&(t.scrollIntoView({behavior:`smooth`,block:`center`}),t.classList.add(Nj.footnoteHighlight,Pj.footnoteHighlight),window.setTimeout(()=>{t.classList.remove(Nj.footnoteHighlight,Pj.footnoteHighlight)},1200))},[i]);return(0,K.jsxs)(`li`,{className:Fj(Nj.footnoteSectionItem,Pj.footnoteSectionItem),id:r,value:typeof n==`number`?n:void 0,children:[(0,K.jsx)(`span`,{className:`rich-footnote-section-item-content`,children:t}),(0,K.jsx)(`a`,{"aria-label":`Back to reference ${n}`,className:Fj(Nj.footnoteBackRef,Pj.footnoteBackRef),href:`#${i}`,role:`doc-backlink`,onClick:a,children:`↩`})]})}var YP=class e extends wr{static getType(){return`footnote-section`}static clone(t){return new e({...t.__definitions},t.__key)}constructor(e,t){super(t),tA(this,`__definitions`,void 0),this.__definitions=e}createDOM(e){let t=document.createElement(`div`);return t.className=`${Nj.footnoteSection} ${Pj.footnoteSection}`,t}updateDOM(){return!1}isInline(){return!1}static importJSON(e){return XP(e.definitions).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`footnote-section`,definitions:this.__definitions,version:1}}getDefinitions(){return this.getLatest().__definitions}setDefinitions(e){let t=this.getWritable();t.__definitions=e}getDefinition(e){return this.getLatest().__definitions[e]}setDefinition(e,t){let n=this.getWritable();n.__definitions={...n.__definitions,[e]:t}}removeDefinition(e){let t=this.getWritable(),{[e]:n,...r}=t.__definitions;t.__definitions=r}decorate(e,t){return qj(GEe,LOe,{definitions:this.__definitions,nodeKey:this.__key})}};function XP(e={}){return new YP(e)}function zOe(e){return e instanceof YP}function BOe({cols:e,gap:t,cellStates:n}){let r=vN();return(0,K.jsx)(`div`,{className:Fj(_P.inner,vP.inner),style:{display:`grid`,gridTemplateColumns:`repeat(${e}, 1fr)`,gap:t},children:n.map((e,t)=>(0,K.jsx)(`div`,{className:Fj(_P.cell,vP.cell),children:r(e)},t))})}var ZP=class e extends wr{static getType(){return`grid-container`}static clone(t){return new e(t.__cols,t.__gap,[...t.__cellStates],t.__key)}constructor(e=2,t,n,r){if(super(r),tA(this,`__cols`,void 0),tA(this,`__gap`,void 0),tA(this,`__cellStates`,void 0),this.__cols=e,this.__gap=t||`16px`,n)this.__cellStates=n;else{let t={root:{children:[{type:`paragraph`,children:[],direction:null,format:``,indent:0,textFormat:0,textStyle:``,version:1}],direction:null,format:``,indent:0,type:`root`,version:1}};this.__cellStates=Array.from({length:e},()=>t)}}createDOM(e){let t=document.createElement(`div`);return t.className=`${_P.container} ${vP.container}`,t}updateDOM(){return!1}isInline(){return!1}getCols(){return this.getLatest().__cols}setCols(e){let t=this.getWritable(),n=t.__cellStates.length;if(t.__cols=e,e>n){let r={root:{children:[{type:`paragraph`,children:[],direction:null,format:``,indent:0,textFormat:0,textStyle:``,version:1}],direction:null,format:``,indent:0,type:`root`,version:1}};for(let i=n;i<e;i++)t.__cellStates.push(r)}}getGap(){return this.getLatest().__gap}setGap(e){let t=this.getWritable();t.__gap=e}getCellStates(){return this.getLatest().__cellStates}addCells(e){let t=this.getWritable(),n={root:{children:[{type:`paragraph`,children:[],direction:null,format:``,indent:0,textFormat:0,textStyle:``,version:1}],direction:null,format:``,indent:0,type:`root`,version:1}};for(let r=0;r<e;r++)t.__cellStates.push(n)}removeCells(e){let t=this.getWritable().__cellStates,n=Math.min(e,t.length);for(let e=0;e<n;e++){let e=t.at(-1);if(!e||bN(e).trim()!==``)break;t.pop()}}getTextContent(){return this.__cellStates.map(e=>bN(e)).join(`
|
|
169
|
-
`)}static importJSON(t){let n=t,r=n.cols||2,i=n.gap,a=typeof i==`number`?`${i}px`:i;if(n.cells&&n.cells.length>0)return new e(r,a,n.cells).updateFromJSON(t);if(n.children){let i=n.children.map(e=>({root:{children:[e],direction:null,format:``,indent:0,type:`root`,version:1}}));return new e(r,a,i).updateFromJSON(t)}return new e(r,a).updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),type:`grid-container`,cols:this.__cols,gap:this.__gap,cells:this.__cellStates,version:1}}decorate(e,t){return(0,G.createElement)(BOe,{cols:this.__cols,gap:this.__gap,cellStates:this.__cellStates})}};function QP(e){return e instanceof ZP}var $P=class e extends wr{static getType(){return`link-card`}static clone(t){return new e({url:t.__url,source:t.__source,id:t.__id,title:t.__title,description:t.__description,favicon:t.__favicon,image:t.__image},t.__key)}constructor(e,t){super(t),tA(this,`__url`,void 0),tA(this,`__source`,void 0),tA(this,`__id`,void 0),tA(this,`__title`,void 0),tA(this,`__description`,void 0),tA(this,`__favicon`,void 0),tA(this,`__image`,void 0),this.__url=e.url,this.__source=e.source,this.__id=e.id,this.__title=e.title,this.__description=e.description,this.__favicon=e.favicon,this.__image=e.image}createDOM(e){let t=document.createElement(`div`);return t.className=`rich-link-card-wrapper`,t}updateDOM(){return!1}isInline(){return!1}static importJSON(e){let t=e;return eF({url:t.url,source:t.source,id:t.id,title:t.title,description:t.description,favicon:t.favicon,image:t.image}).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`link-card`,url:this.__url,source:this.__source,id:this.__id,title:this.__title,description:this.__description,favicon:this.__favicon,image:this.__image,version:1}}getUrl(){return this.getLatest().__url}setUrl(e){let t=this.getWritable();t.__url=e}getSource(){return this.getLatest().__source}setSource(e){let t=this.getWritable();t.__source=e}getId(){return this.getLatest().__id}setId(e){let t=this.getWritable();t.__id=e}decorate(e,t){return qj(KEe,fOe,{url:this.__url,source:this.__source,id:this.__id,title:this.__title,description:this.__description,favicon:this.__favicon,image:this.__image})}};tA($P,`commandItems`,[{title:`Link Card`,icon:(0,G.createElement)(y,{size:20}),description:`Link preview card`,keywords:[`link`,`card`,`bookmark`,`embed`],section:`MEDIA`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([eF({url:``})])})}}]);function eF(e){return new $P(e)}function VOe(e){let t=``;for(let n of Array.from(e.childNodes)){if(n.nodeType===Node.TEXT_NODE){t+=n.textContent??``;continue}if(n.nodeType!==Node.ELEMENT_NODE)continue;let e=n,r=e.tagName.toLowerCase();r!==`rt`&&r!==`rp`&&(t+=e.textContent??``)}return t}var tF=class e extends $e{static getType(){return`ruby`}static clone(t){return new e(t.__reading,t.__key)}constructor(e,t){super(t),tA(this,`__reading`,void 0),this.__reading=e}static importJSON(e){let t=e;return nF(t.reading??``).updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),type:`ruby`,reading:this.__reading,version:1}}static importDOM(){return{ruby:()=>({conversion:e=>{if(!(e instanceof HTMLElement))return null;let t=e.querySelector(`rt`)?.textContent??``,n=VOe(e),r=nF(t);return n&&r.append(te(n)),{node:r}},priority:2})}}exportDOM(){let e=document.createElement(`ruby`);e.className=`${Nj.ruby} ${Pj.ruby}`;let t=this.getTextContent();if(t&&e.append(t),this.__reading){let t=document.createElement(`rt`);t.className=`${Nj.rubyRt} ${Pj.rubyRt}`,t.textContent=this.__reading,e.append(t)}return{element:e}}createDOM(e){let t=document.createElement(`span`);return t.className=`${Nj.ruby} ${Pj.ruby}`,this.__reading&&(t.dataset.ruby=this.__reading),t}updateDOM(e,t){return e.__reading!==this.__reading&&(this.__reading?t.dataset.ruby=this.__reading:delete t.dataset.ruby),!1}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!0}getReading(){return this.getLatest().__reading}setReading(e){let t=this.getWritable();t.__reading=e}};function nF(e){return new tF(e)}function rF(e){return e instanceof tF}function HOe({src:e,poster:t,width:n,height:r}){return(0,K.jsx)(`figure`,{className:`rich-video`,children:(0,K.jsx)(`video`,{controls:!0,height:r,poster:t,preload:`metadata`,src:e,style:{maxWidth:`100%`,height:`auto`},width:n})})}var iF=class e extends wr{static getType(){return`video`}static clone(t){return new e({src:t.__src,poster:t.__poster,width:t.__width,height:t.__height},t.__key)}constructor(e,t){super(t),tA(this,`__src`,void 0),tA(this,`__poster`,void 0),tA(this,`__width`,void 0),tA(this,`__height`,void 0),this.__src=e.src,this.__poster=e.poster,this.__width=e.width,this.__height=e.height}createDOM(e){let t=document.createElement(`div`);return t.className=`rich-video-wrapper`,t}updateDOM(){return!1}isInline(){return!1}static importJSON(e){let t=e;return aF({src:t.src,poster:t.poster,width:t.width,height:t.height}).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`video`,src:this.__src,poster:this.__poster,width:this.__width,height:this.__height,version:1}}getSrc(){return this.getLatest().__src}setSrc(e){let t=this.getWritable();t.__src=e}decorate(e,t){return qj(JEe,HOe,{src:this.__src,poster:this.__poster,width:this.__width,height:this.__height})}};tA(iF,`commandItems`,[{title:`Video`,icon:(0,G.createElement)(tne,{size:20}),description:`Embed a video`,keywords:[`video`,`media`,`mp4`],section:`MEDIA`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([aF({src:``})])})}}]);function aF(e){return new iF(e)}var oF=[$t,mr,sP,{replace:mr,with:()=>new sP},Gn,En,dr,Cn,hA,dN,iM,dM,wP],UOe=[cP,eP,ZN,JN,UN,xN,RP,CN,YP,iF,qP,$P,HP,GP,ZP,LP,nP,tF,dP],WOe=[...oF,...UOe],sF=(0,G.createContext)(`light`);function cF({colorScheme:e,children:t}){return(0,K.jsx)(sF.Provider,{value:e,children:t})}function lF(){return(0,G.use)(sF)}function uF({hasCellMerge:e=!0,hasCellBackgroundColor:t=!0,hasTabHandler:n=!0,hasHorizontalScroll:r=!1,hasNestedTables:i=!1}){let[a]=ht();(0,G.useEffect)(()=>{lN(a)!==r&&(MDe(a,r),a.update(fee))},[a,r]);let o=function(e){let[t]=(0,G.useState)(()=>Me(e));return t.peek()!==e&&(t.value=e),t}(i);return(0,G.useEffect)(()=>HDe(a,{hasNestedTables:o}),[a,o]),(0,G.useEffect)(()=>VDe(a,n),[a,n]),(0,G.useEffect)(()=>{if(!e)return BDe(a)},[a,e]),(0,G.useEffect)(()=>{if(!t)return a.registerNodeTransform(iM,e=>{e.getBackgroundColor()!==null&&e.setBackgroundColor(null)})},[a,t,e]),null}var GOe=new Set([`http:`,`https:`,`mailto:`,`tel:`]);function KOe(e){let t=e?.trim();if(!t||/\s/.test(t))return null;try{return GOe.has(new URL(t).protocol)?t:null}catch{return null}}function dF(){let[e]=ht();return(0,G.useEffect)(()=>e.registerCommand(or,t=>{if(!(t instanceof ClipboardEvent))return!1;let n=kr();if(!Jn(n)||n.isCollapsed())return!1;let r=KOe(t.clipboardData?.getData(`text/plain`));if(!r)return!1;let i=n.getNodes().filter(it);if(i.length===0||i.some(e=>!e.isSimpleText()))return!1;let a=i[0].getTopLevelElement();return!a||i.some(e=>e.getTopLevelElement()!==a)?!1:(t.preventDefault(),e.dispatchCommand(hn,r),!0)},3),[e]),null}function fF(){let[e]=ht(),t=nA(),n=e.hasNodes([dN,dM,iM]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Lt,{}),(0,K.jsx)(qt,{}),(0,K.jsx)(dF,{}),n&&(0,K.jsx)(uF,{hasHorizontalScroll:!0}),t]})}function qOe(e,t,n){let r=JSON.stringify(t.getEditorState().toJSON());return t.registerUpdateListener(({dirtyElements:t,dirtyLeaves:i,editorState:a})=>{if(t.size===0&&i.size===0)return;let o=JSON.stringify(a.toJSON());o!==r&&(r=o,e.update(()=>{let e=Dn(n);e&&(L(un),L(z),e.markDirty())}))})}function pF(e,t){let[n]=ht();(0,G.useEffect)(()=>{let r=e.map(e=>qOe(n,e,t));return()=>r.forEach(e=>e())},[n,e,t])}function JOe({parentEditor:e,nodeKey:t}){let[n]=ht();return(0,G.useEffect)(()=>{let r=()=>{e.focus(()=>{e.update(()=>{let e=Dn(t);if(e){let t=e.getNextSibling();t&&t.selectStart()}})})},i=n=>{let i=Sr(),a=i.getLastChild(),o=n&&i.getChildrenSize()<=1;n&&a&&a.remove(),o?e.update(()=>{let e=Dn(t);if(e){let t=on();e.insertAfter(t),e.remove(),t.selectStart()}},{onUpdate:r}):e.update(()=>{let e=Dn(t);if(e){let t=e.getNextSibling();t&&yr(t)||(t=on(),e.insertAfter(t)),t.selectStart()}},{onUpdate:r})},a=()=>{let e=kr();if(!Jn(e)||!e.isCollapsed())return!1;let t=e.anchor.getNode().getTopLevelElement();return t&&yr(t)&&t.getTextContent()===``&&t.getNextSibling()===null},o=n.registerCommand(an,e=>e?.metaKey||e?.ctrlKey?(e.preventDefault(),i(!1),!0):a()?(e?.preventDefault(),i(!0),!0):!1,4),s=n.registerCommand(F,e=>a()?(e?.preventDefault(),i(!1),!0):!1,3);return()=>{o(),s()}},[n,e,t]),null}function YOe({nodeKey:e,alertType:t,contentEditor:n}){let[r]=ht();pF((0,G.useMemo)(()=>[n],[n]),e);let i=r.isEditable(),a=(0,G.useCallback)(t=>{r.update(()=>{let n=Dn(e);JDe(n)&&n.setAlertType(t)})},[r,e]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Kj,{defaultRenderer:yN,rendererKey:Lj,props:{type:t,editable:i,onTypeChange:i?a:void 0}}),(0,K.jsx)(`div`,{className:`rich-alert-content`,children:(0,K.jsxs)(pA,{initialEditor:n,children:[(0,K.jsx)(Yt,{ErrorBoundary:Nt,contentEditable:(0,K.jsx)(Ee,{"aria-placeholder":``,className:`rich-alert-content-editable`,placeholder:(0,K.jsx)(`span`,{style:{display:`none`}}),style:{outline:`none`}})}),(0,K.jsx)(fF,{}),(0,K.jsx)(JOe,{nodeKey:e,parentEditor:r})]})})]})}var XOe=[$t,mr,sP,{replace:mr,with:()=>new sP},Gn,En,dr,Cn,hA,wP,dN,iM,dM,cP,eP,CN,ZN,dP];function ZOe(){try{return Vn()}catch{return null}}function mF(e){return ZOe()?qn():qn({namespace:e,nodes:XOe,theme:mP,onError:t=>console.error(`[${e}]`,t)})}function QOe(){return mF(`AlertContent`)}var hF=class e extends xN{static clone(t){let n=new e(t.__alertType,t.__contentState,t.__key);return n.__contentEditor=t.__contentEditor,n}constructor(e,t,n){if(super(e,t,n),tA(this,`__contentEditor`,void 0),this.__contentEditor=QOe(),t){let e=this.__contentEditor.parseEditorState(t);this.__contentEditor.setEditorState(e)}}getContentEditor(){return this.__contentEditor}static importJSON(t){let n=t;return new e(n.alertType,n.content).updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),type:`alert-quote`,alertType:this.__alertType,content:this.__contentEditor.getEditorState().toJSON(),version:1}}decorate(e,t){return(0,G.createElement)(YOe,{nodeKey:this.__key,alertType:this.__alertType,contentEditor:this.__contentEditor})}};tA(hF,`commandItems`,[{title:`Callout`,icon:(0,G.createElement)(g,{size:20}),description:`Info callout block`,keywords:[`alert`,`note`,`info`,`callout`],section:`ADVANCED`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([gF(`note`)])})}},{title:`Tip`,icon:(0,G.createElement)(gi,{size:20}),description:`Highlight a useful tip`,keywords:[`alert`,`tip`,`hint`],section:`ADVANCED`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([gF(`tip`)])})}},{title:`Warning`,icon:(0,G.createElement)(v,{size:20}),description:`Warn about something`,keywords:[`alert`,`warning`,`caution`],section:`ADVANCED`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([gF(`warning`)])})}}]);function gF(e,t){return new hF(e,t)}function _F(e,t){return e.read(`latest`,()=>{let e=Dn(t);return e!==null&&e.isSelected()})}function vF(e){let[t]=ht(),[n,r]=(0,G.useState)(()=>_F(t,e));return(0,G.useEffect)(()=>{let n=!0,i=t.registerUpdateListener(()=>{n&&r(_F(t,e))});return()=>{n=!1,i()}},[t,e]),[n,(0,G.useCallback)(n=>{t.update(()=>{let t=kr();if(!Ue(t)){let r=n?null:Dn(e);if(r!==null&&!r.isSelected())return;t=sr(),Jt(t)}Ue(t)&&(n?t.add(e):t.delete(e))})},[t,e]),(0,G.useCallback)(()=>{t.update(()=>{let e=kr();Ue(e)&&e.clear()})},[t])]}var yF=new Map;function bF(e,t){yF.set(e,t)}function $Oe(e){let t=yF.get(e);return t?(yF.delete(e),t):null}function eke({nodeKey:e,bannerType:t,contentEditor:n}){let[r]=ht();pF((0,G.useMemo)(()=>[n],[n]),e);let i=r.isEditable(),a=(0,G.useCallback)(t=>{r.update(()=>{let n=Dn(e);AOe(n)&&n.setBannerType(t)})},[r,e]);return(0,K.jsxs)(`div`,{className:`rich-banner-inner`,children:[(0,K.jsx)(Kj,{defaultRenderer:PP,rendererKey:Rj,props:{type:t,editable:i,onTypeChange:i?a:void 0}}),(0,K.jsx)(`div`,{className:`rich-banner-content`,children:(0,K.jsxs)(pA,{initialEditor:n,children:[(0,K.jsx)(Yt,{ErrorBoundary:Nt,contentEditable:(0,K.jsx)(Ee,{"aria-placeholder":``,className:`rich-banner-content-editable`,placeholder:(0,K.jsx)(`span`,{style:{display:`none`}}),style:{outline:`none`}})}),(0,K.jsx)(fF,{})]})})]})}function tke(){return mF(`BannerContent`)}var xF=class e extends LP{static clone(t){let n=new e(t.__bannerType,t.__contentState,t.__key);return n.__contentEditor=t.__contentEditor,n}constructor(e,t,n){if(super(e,t,n),tA(this,`__contentEditor`,void 0),this.__contentEditor=tke(),t){let e=this.__contentEditor.parseEditorState(t);this.__contentEditor.setEditorState(e)}}getContentEditor(){return this.__contentEditor}static importJSON(t){let n=t,r=n,i=IP(n.bannerType);if(n.content)return new e(i,n.content).updateFromJSON(t);if(r.children){let n={root:{children:r.children,direction:null,format:``,indent:0,type:`root`,version:1}};return new e(i,n).updateFromJSON(t)}return new e(i).updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),type:`banner`,bannerType:this.__bannerType,content:this.__contentEditor.getEditorState().toJSON(),version:1}}decorate(e,t){return(0,G.createElement)(eke,{nodeKey:this.__key,bannerType:this.__bannerType,contentEditor:this.__contentEditor})}};tA(xF,`commandItems`,[{title:`Banner`,icon:(0,G.createElement)(ci,{size:20}),description:`Highlighted banner block`,keywords:[`banner`,`notice`,`announcement`],section:`ADVANCED`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([SF(`note`)])})}}]);function SF(e,t){return new xF(e,t)}function nke({code:e,language:t,showLineNumbers:n}){let r=Gj(),i=n??(r!==`comment`&&r!==`chat`),a=lF(),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1),u=(0,G.useRef)(void 0);(0,G.useEffect)(()=>{let n=!1;return s(null),ne(e,t,a===`dark`?`dark`:`light`).then(e=>{n||s(e)}).catch(()=>{n||s(null)}),()=>{n=!0}},[e,t,a]),(0,G.useEffect)(()=>()=>clearTimeout(u.current),[]);let d=(0,G.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{l(!0),clearTimeout(u.current),u.current=setTimeout(()=>l(!1),2e3)}).catch(()=>{})},[e]),f=t?(0,K.jsxs)(`div`,{className:`rich-code-block-header`,children:[(0,K.jsx)(`span`,{className:`rich-code-block-lang`,children:t}),(0,K.jsx)(`button`,{"aria-label":c?`Copied to clipboard`:`Copy code`,className:`rich-code-block-copy`,type:`button`,onClick:d,children:c?`Copied`:`Copy`})]}):null,p=(0,G.useMemo)(()=>({"--rc-ln-digits":Math.max(2,String(e.split(`
|
|
169
|
+
`)}static importJSON(t){let n=t,r=n.cols||2,i=n.gap,a=typeof i==`number`?`${i}px`:i;if(n.cells&&n.cells.length>0)return new e(r,a,n.cells).updateFromJSON(t);if(n.children){let i=n.children.map(e=>({root:{children:[e],direction:null,format:``,indent:0,type:`root`,version:1}}));return new e(r,a,i).updateFromJSON(t)}return new e(r,a).updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),type:`grid-container`,cols:this.__cols,gap:this.__gap,cells:this.__cellStates,version:1}}decorate(e,t){return(0,G.createElement)(BOe,{cols:this.__cols,gap:this.__gap,cellStates:this.__cellStates})}};function QP(e){return e instanceof ZP}var $P=class e extends wr{static getType(){return`link-card`}static clone(t){return new e({url:t.__url,source:t.__source,id:t.__id,title:t.__title,description:t.__description,favicon:t.__favicon,image:t.__image},t.__key)}constructor(e,t){super(t),tA(this,`__url`,void 0),tA(this,`__source`,void 0),tA(this,`__id`,void 0),tA(this,`__title`,void 0),tA(this,`__description`,void 0),tA(this,`__favicon`,void 0),tA(this,`__image`,void 0),this.__url=e.url,this.__source=e.source,this.__id=e.id,this.__title=e.title,this.__description=e.description,this.__favicon=e.favicon,this.__image=e.image}createDOM(e){let t=document.createElement(`div`);return t.className=`rich-link-card-wrapper`,t}updateDOM(){return!1}isInline(){return!1}static importJSON(e){let t=e;return eF({url:t.url,source:t.source,id:t.id,title:t.title,description:t.description,favicon:t.favicon,image:t.image}).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`link-card`,url:this.__url,source:this.__source,id:this.__id,title:this.__title,description:this.__description,favicon:this.__favicon,image:this.__image,version:1}}getUrl(){return this.getLatest().__url}setUrl(e){let t=this.getWritable();t.__url=e}getSource(){return this.getLatest().__source}setSource(e){let t=this.getWritable();t.__source=e}getId(){return this.getLatest().__id}setId(e){let t=this.getWritable();t.__id=e}decorate(e,t){return qj(KEe,fOe,{url:this.__url,source:this.__source,id:this.__id,title:this.__title,description:this.__description,favicon:this.__favicon,image:this.__image})}};tA($P,`commandItems`,[{title:`Link Card`,icon:(0,G.createElement)(v,{size:20}),description:`Link preview card`,keywords:[`link`,`card`,`bookmark`,`embed`],section:`MEDIA`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([eF({url:``})])})}}]);function eF(e){return new $P(e)}function VOe(e){let t=``;for(let n of Array.from(e.childNodes)){if(n.nodeType===Node.TEXT_NODE){t+=n.textContent??``;continue}if(n.nodeType!==Node.ELEMENT_NODE)continue;let e=n,r=e.tagName.toLowerCase();r!==`rt`&&r!==`rp`&&(t+=e.textContent??``)}return t}var tF=class e extends $e{static getType(){return`ruby`}static clone(t){return new e(t.__reading,t.__key)}constructor(e,t){super(t),tA(this,`__reading`,void 0),this.__reading=e}static importJSON(e){let t=e;return nF(t.reading??``).updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),type:`ruby`,reading:this.__reading,version:1}}static importDOM(){return{ruby:()=>({conversion:e=>{if(!(e instanceof HTMLElement))return null;let t=e.querySelector(`rt`)?.textContent??``,n=VOe(e),r=nF(t);return n&&r.append(te(n)),{node:r}},priority:2})}}exportDOM(){let e=document.createElement(`ruby`);e.className=`${Nj.ruby} ${Pj.ruby}`;let t=this.getTextContent();if(t&&e.append(t),this.__reading){let t=document.createElement(`rt`);t.className=`${Nj.rubyRt} ${Pj.rubyRt}`,t.textContent=this.__reading,e.append(t)}return{element:e}}createDOM(e){let t=document.createElement(`span`);return t.className=`${Nj.ruby} ${Pj.ruby}`,this.__reading&&(t.dataset.ruby=this.__reading),t}updateDOM(e,t){return e.__reading!==this.__reading&&(this.__reading?t.dataset.ruby=this.__reading:delete t.dataset.ruby),!1}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!0}getReading(){return this.getLatest().__reading}setReading(e){let t=this.getWritable();t.__reading=e}};function nF(e){return new tF(e)}function rF(e){return e instanceof tF}function HOe({src:e,poster:t,width:n,height:r}){return(0,K.jsx)(`figure`,{className:`rich-video`,children:(0,K.jsx)(`video`,{controls:!0,height:r,poster:t,preload:`metadata`,src:e,style:{maxWidth:`100%`,height:`auto`},width:n})})}var iF=class e extends wr{static getType(){return`video`}static clone(t){return new e({src:t.__src,poster:t.__poster,width:t.__width,height:t.__height},t.__key)}constructor(e,t){super(t),tA(this,`__src`,void 0),tA(this,`__poster`,void 0),tA(this,`__width`,void 0),tA(this,`__height`,void 0),this.__src=e.src,this.__poster=e.poster,this.__width=e.width,this.__height=e.height}createDOM(e){let t=document.createElement(`div`);return t.className=`rich-video-wrapper`,t}updateDOM(){return!1}isInline(){return!1}static importJSON(e){let t=e;return aF({src:t.src,poster:t.poster,width:t.width,height:t.height}).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`video`,src:this.__src,poster:this.__poster,width:this.__width,height:this.__height,version:1}}getSrc(){return this.getLatest().__src}setSrc(e){let t=this.getWritable();t.__src=e}decorate(e,t){return qj(JEe,HOe,{src:this.__src,poster:this.__poster,width:this.__width,height:this.__height})}};tA(iF,`commandItems`,[{title:`Video`,icon:(0,G.createElement)(tne,{size:20}),description:`Embed a video`,keywords:[`video`,`media`,`mp4`],section:`MEDIA`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([aF({src:``})])})}}]);function aF(e){return new iF(e)}var oF=[$t,mr,sP,{replace:mr,with:()=>new sP},Gn,En,dr,Cn,hA,dN,iM,dM,wP],UOe=[cP,eP,ZN,JN,UN,xN,RP,CN,YP,iF,qP,$P,HP,GP,ZP,LP,nP,tF,dP],WOe=[...oF,...UOe],sF=(0,G.createContext)(`light`);function cF({colorScheme:e,children:t}){return(0,K.jsx)(sF.Provider,{value:e,children:t})}function lF(){return(0,G.use)(sF)}function uF({hasCellMerge:e=!0,hasCellBackgroundColor:t=!0,hasTabHandler:n=!0,hasHorizontalScroll:r=!1,hasNestedTables:i=!1}){let[a]=ht();(0,G.useEffect)(()=>{lN(a)!==r&&(MDe(a,r),a.update(fee))},[a,r]);let o=function(e){let[t]=(0,G.useState)(()=>Me(e));return t.peek()!==e&&(t.value=e),t}(i);return(0,G.useEffect)(()=>HDe(a,{hasNestedTables:o}),[a,o]),(0,G.useEffect)(()=>VDe(a,n),[a,n]),(0,G.useEffect)(()=>{if(!e)return BDe(a)},[a,e]),(0,G.useEffect)(()=>{if(!t)return a.registerNodeTransform(iM,e=>{e.getBackgroundColor()!==null&&e.setBackgroundColor(null)})},[a,t,e]),null}var GOe=new Set([`http:`,`https:`,`mailto:`,`tel:`]);function KOe(e){let t=e?.trim();if(!t||/\s/.test(t))return null;try{return GOe.has(new URL(t).protocol)?t:null}catch{return null}}function dF(){let[e]=ht();return(0,G.useEffect)(()=>e.registerCommand(or,t=>{if(!(t instanceof ClipboardEvent))return!1;let n=kr();if(!Jn(n)||n.isCollapsed())return!1;let r=KOe(t.clipboardData?.getData(`text/plain`));if(!r)return!1;let i=n.getNodes().filter(it);if(i.length===0||i.some(e=>!e.isSimpleText()))return!1;let a=i[0].getTopLevelElement();return!a||i.some(e=>e.getTopLevelElement()!==a)?!1:(t.preventDefault(),e.dispatchCommand(hn,r),!0)},3),[e]),null}function fF(){let[e]=ht(),t=nA(),n=e.hasNodes([dN,dM,iM]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Lt,{}),(0,K.jsx)(qt,{}),(0,K.jsx)(dF,{}),n&&(0,K.jsx)(uF,{hasHorizontalScroll:!0}),t]})}function qOe(e,t,n){let r=JSON.stringify(t.getEditorState().toJSON());return t.registerUpdateListener(({dirtyElements:t,dirtyLeaves:i,editorState:a})=>{if(t.size===0&&i.size===0)return;let o=JSON.stringify(a.toJSON());o!==r&&(r=o,e.update(()=>{let e=Dn(n);e&&(L(un),L(z),e.markDirty())}))})}function pF(e,t){let[n]=ht();(0,G.useEffect)(()=>{let r=e.map(e=>qOe(n,e,t));return()=>r.forEach(e=>e())},[n,e,t])}function JOe({parentEditor:e,nodeKey:t}){let[n]=ht();return(0,G.useEffect)(()=>{let r=()=>{e.focus(()=>{e.update(()=>{let e=Dn(t);if(e){let t=e.getNextSibling();t&&t.selectStart()}})})},i=n=>{let i=Sr(),a=i.getLastChild(),o=n&&i.getChildrenSize()<=1;n&&a&&a.remove(),o?e.update(()=>{let e=Dn(t);if(e){let t=on();e.insertAfter(t),e.remove(),t.selectStart()}},{onUpdate:r}):e.update(()=>{let e=Dn(t);if(e){let t=e.getNextSibling();t&&yr(t)||(t=on(),e.insertAfter(t)),t.selectStart()}},{onUpdate:r})},a=()=>{let e=kr();if(!Jn(e)||!e.isCollapsed())return!1;let t=e.anchor.getNode().getTopLevelElement();return t&&yr(t)&&t.getTextContent()===``&&t.getNextSibling()===null},o=n.registerCommand(an,e=>e?.metaKey||e?.ctrlKey?(e.preventDefault(),i(!1),!0):a()?(e?.preventDefault(),i(!0),!0):!1,4),s=n.registerCommand(F,e=>a()?(e?.preventDefault(),i(!1),!0):!1,3);return()=>{o(),s()}},[n,e,t]),null}function YOe({nodeKey:e,alertType:t,contentEditor:n}){let[r]=ht();pF((0,G.useMemo)(()=>[n],[n]),e);let i=r.isEditable(),a=(0,G.useCallback)(t=>{r.update(()=>{let n=Dn(e);JDe(n)&&n.setAlertType(t)})},[r,e]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Kj,{defaultRenderer:yN,rendererKey:Lj,props:{type:t,editable:i,onTypeChange:i?a:void 0}}),(0,K.jsx)(`div`,{className:`rich-alert-content`,children:(0,K.jsxs)(pA,{initialEditor:n,children:[(0,K.jsx)(Yt,{ErrorBoundary:Nt,contentEditable:(0,K.jsx)(Ee,{"aria-placeholder":``,className:`rich-alert-content-editable`,placeholder:(0,K.jsx)(`span`,{style:{display:`none`}}),style:{outline:`none`}})}),(0,K.jsx)(fF,{}),(0,K.jsx)(JOe,{nodeKey:e,parentEditor:r})]})})]})}var XOe=[$t,mr,sP,{replace:mr,with:()=>new sP},Gn,En,dr,Cn,hA,wP,dN,iM,dM,cP,eP,CN,ZN,dP];function ZOe(){try{return Vn()}catch{return null}}function mF(e){return ZOe()?qn():qn({namespace:e,nodes:XOe,theme:mP,onError:t=>console.error(`[${e}]`,t)})}function QOe(){return mF(`AlertContent`)}var hF=class e extends xN{static clone(t){let n=new e(t.__alertType,t.__contentState,t.__key);return n.__contentEditor=t.__contentEditor,n}constructor(e,t,n){if(super(e,t,n),tA(this,`__contentEditor`,void 0),this.__contentEditor=QOe(),t){let e=this.__contentEditor.parseEditorState(t);this.__contentEditor.setEditorState(e)}}getContentEditor(){return this.__contentEditor}static importJSON(t){let n=t;return new e(n.alertType,n.content).updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),type:`alert-quote`,alertType:this.__alertType,content:this.__contentEditor.getEditorState().toJSON(),version:1}}decorate(e,t){return(0,G.createElement)(YOe,{nodeKey:this.__key,alertType:this.__alertType,contentEditor:this.__contentEditor})}};tA(hF,`commandItems`,[{title:`Callout`,icon:(0,G.createElement)(m,{size:20}),description:`Info callout block`,keywords:[`alert`,`note`,`info`,`callout`],section:`ADVANCED`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([gF(`note`)])})}},{title:`Tip`,icon:(0,G.createElement)(gi,{size:20}),description:`Highlight a useful tip`,keywords:[`alert`,`tip`,`hint`],section:`ADVANCED`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([gF(`tip`)])})}},{title:`Warning`,icon:(0,G.createElement)(x,{size:20}),description:`Warn about something`,keywords:[`alert`,`warning`,`caution`],section:`ADVANCED`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([gF(`warning`)])})}}]);function gF(e,t){return new hF(e,t)}function _F(e,t){return e.read(`latest`,()=>{let e=Dn(t);return e!==null&&e.isSelected()})}function vF(e){let[t]=ht(),[n,r]=(0,G.useState)(()=>_F(t,e));return(0,G.useEffect)(()=>{let n=!0,i=t.registerUpdateListener(()=>{n&&r(_F(t,e))});return()=>{n=!1,i()}},[t,e]),[n,(0,G.useCallback)(n=>{t.update(()=>{let t=kr();if(!Ue(t)){let r=n?null:Dn(e);if(r!==null&&!r.isSelected())return;t=sr(),Jt(t)}Ue(t)&&(n?t.add(e):t.delete(e))})},[t,e]),(0,G.useCallback)(()=>{t.update(()=>{let e=kr();Ue(e)&&e.clear()})},[t])]}var yF=new Map;function bF(e,t){yF.set(e,t)}function $Oe(e){let t=yF.get(e);return t?(yF.delete(e),t):null}function eke({nodeKey:e,bannerType:t,contentEditor:n}){let[r]=ht();pF((0,G.useMemo)(()=>[n],[n]),e);let i=r.isEditable(),a=(0,G.useCallback)(t=>{r.update(()=>{let n=Dn(e);AOe(n)&&n.setBannerType(t)})},[r,e]);return(0,K.jsxs)(`div`,{className:`rich-banner-inner`,children:[(0,K.jsx)(Kj,{defaultRenderer:PP,rendererKey:Rj,props:{type:t,editable:i,onTypeChange:i?a:void 0}}),(0,K.jsx)(`div`,{className:`rich-banner-content`,children:(0,K.jsxs)(pA,{initialEditor:n,children:[(0,K.jsx)(Yt,{ErrorBoundary:Nt,contentEditable:(0,K.jsx)(Ee,{"aria-placeholder":``,className:`rich-banner-content-editable`,placeholder:(0,K.jsx)(`span`,{style:{display:`none`}}),style:{outline:`none`}})}),(0,K.jsx)(fF,{})]})})]})}function tke(){return mF(`BannerContent`)}var xF=class e extends LP{static clone(t){let n=new e(t.__bannerType,t.__contentState,t.__key);return n.__contentEditor=t.__contentEditor,n}constructor(e,t,n){if(super(e,t,n),tA(this,`__contentEditor`,void 0),this.__contentEditor=tke(),t){let e=this.__contentEditor.parseEditorState(t);this.__contentEditor.setEditorState(e)}}getContentEditor(){return this.__contentEditor}static importJSON(t){let n=t,r=n,i=IP(n.bannerType);if(n.content)return new e(i,n.content).updateFromJSON(t);if(r.children){let n={root:{children:r.children,direction:null,format:``,indent:0,type:`root`,version:1}};return new e(i,n).updateFromJSON(t)}return new e(i).updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),type:`banner`,bannerType:this.__bannerType,content:this.__contentEditor.getEditorState().toJSON(),version:1}}decorate(e,t){return(0,G.createElement)(eke,{nodeKey:this.__key,bannerType:this.__bannerType,contentEditor:this.__contentEditor})}};tA(xF,`commandItems`,[{title:`Banner`,icon:(0,G.createElement)(ci,{size:20}),description:`Highlighted banner block`,keywords:[`banner`,`notice`,`announcement`],section:`ADVANCED`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([SF(`note`)])})}}]);function SF(e,t){return new xF(e,t)}function nke({code:e,language:t,showLineNumbers:n}){let r=Gj(),i=n??(r!==`comment`&&r!==`chat`),a=lF(),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1),u=(0,G.useRef)(void 0);(0,G.useEffect)(()=>{let n=!1;return s(null),ne(e,t,a===`dark`?`dark`:`light`).then(e=>{n||s(e)}).catch(()=>{n||s(null)}),()=>{n=!0}},[e,t,a]),(0,G.useEffect)(()=>()=>clearTimeout(u.current),[]);let d=(0,G.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{l(!0),clearTimeout(u.current),u.current=setTimeout(()=>l(!1),2e3)}).catch(()=>{})},[e]),f=t?(0,K.jsxs)(`div`,{className:`rich-code-block-header`,children:[(0,K.jsx)(`span`,{className:`rich-code-block-lang`,children:t}),(0,K.jsx)(`button`,{"aria-label":c?`Copied to clipboard`:`Copy code`,className:`rich-code-block-copy`,type:`button`,onClick:d,children:c?`Copied`:`Copy`})]}):null,p=(0,G.useMemo)(()=>({"--rc-ln-digits":Math.max(2,String(e.split(`
|
|
170
170
|
`).length).length)}),[e]),m=i?`rich-code-block rich-code-block-numbered`:`rich-code-block`;if(o)return(0,K.jsxs)(`div`,{className:m,style:p,children:[f,(0,K.jsx)(`div`,{dangerouslySetInnerHTML:{__html:o}})]});let h=e.split(`
|
|
171
171
|
`);return(0,K.jsxs)(`div`,{className:m,style:p,children:[f,(0,K.jsx)(`pre`,{children:(0,K.jsx)(`code`,{children:h.map((e,t)=>(0,K.jsxs)(`span`,{className:`line`,children:[e,t<h.length-1?`
|
|
172
|
-
`:``]},t))})})]})}function rke({nodeKey:e,code:t,language:n}){let[r]=ht(),[i]=vF(e),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(`start`),l=r.isEditable();(0,G.useEffect)(()=>{if(!l||!i){o(!1);return}let t=!1,n=`start`;r.getEditorState().read(()=>{let r=kr(),i=Ue(r)?r.getNodes():null;t=i!==null&&i.length===1&&i[0]?.getKey()===e,t&&(n=$Oe(e)??`start`)}),o(t),t&&c(n)},[l,r,i,e]),(0,G.useEffect)(()=>{if(l&&i)return r.registerCommand(br,t=>(t.key.length!==1||t.metaKey||t.ctrlKey||t.altKey||t.isComposing||!r.getEditorState().read(()=>{let t=kr();if(!Ue(t))return!1;let n=t.getNodes();return n.length===1&&n[0]?.getKey()===e})||r.getElementByKey(e)?.querySelector(`[contenteditable="true"]`)?.focus(),!1),3)},[l,r,i,e]);let u=(0,G.useCallback)(t=>{r.update(()=>{let n=Dn(e);BP(n)&&n.setCode(t)})},[r,e]),d=(0,G.useCallback)(t=>{r.update(()=>{let n=Dn(e);BP(n)&&n.setLanguage(t)})},[r,e]),f=(0,G.useCallback)(()=>{r.getRootElement()?.focus({preventScroll:!0}),r.update(()=>{let t=Dn(e);if(!t)return;let n=t.getPreviousSibling(),r=t.getNextSibling(),i=t.getParent();if(t.remove(),n){if(rr(n))n.selectEnd();else{je(n)&&n.getType()===`code-block`&&bF(n.getKey(),`end`);let e=sr();e.add(n.getKey()),Jt(e)}}else if(r){if(rr(r))r.selectStart();else{je(r)&&r.getType()===`code-block`&&bF(r.getKey(),`start`);let e=sr();e.add(r.getKey()),Jt(e)}}else if(i){let e=on();i.append(e),e.selectStart()}})},[r,e]),p=(0,G.useCallback)(t=>{r.getRootElement()?.focus({preventScroll:!0}),r.update(()=>{let n=Dn(e);if(!n)return;if(t===`before`){let e=n.getPreviousSibling();if(!e)return;if(rr(e))e.selectEnd();else{je(e)&&e.getType()===`code-block`&&bF(e.getKey(),`end`);let t=sr();t.add(e.getKey()),Jt(t)}return}let r=n.getNextSibling();if(!r){let e=on();n.insertAfter(e),r=e}if(rr(r))r.selectStart();else{je(r)&&r.getType()===`code-block`&&bF(r.getKey(),`start`);let e=sr();e.add(r.getKey()),Jt(e)}})},[r,e]);return(0,K.jsx)(Kj,{defaultRenderer:nke,rendererKey:zj,props:{code:t,language:n,editable:l,onCodeChange:l?u:void 0,onLanguageChange:l?d:void 0,onDelete:l?f:void 0,onExitBlock:l?p:void 0,selected:l?a:!1,cursorPlacement:l?s:`start`}})}var CF,wF=class e extends RP{static clone(t){return new e(t.__code,t.__language,t.__key)}static importJSON(t){let n=t;return new e(n.code,n.language).updateFromJSON(t)}decorate(e,t){return(0,G.createElement)(rke,{nodeKey:this.__key,code:this.__code,language:this.__language})}};CF=wF,tA(wF,`commandItems`,RP.commandItems.map(e=>({...e,onSelect:e=>{e.update(()=>{Un([new CF(``,`text`)])})}})));function ike(e,t){return new wF(e,t)}function ake({definitions:e}){let[t]=ht(),{displayNumberMap:n}=Xj(),r=Object.entries(e).sort(([e],[t])=>(n[e]??0)-(n[t]??0)),i=(0,G.useCallback)((e,n)=>{t.update(()=>{let t=xn(YP);t.length>0&&t[0].setDefinition(e,n)})},[t]),a=(0,G.useCallback)(e=>{t.update(()=>{let t=xn(YP);t.length>0&&t[0].removeDefinition(e)})},[t]);return r.length===0?null:(0,K.jsxs)(`div`,{role:`doc-endnotes`,className:Fj(`rich-footnote-section-content`,`rich-footnote-section-edit`,Nj.footnoteSection,Pj.footnoteSection),children:[(0,K.jsx)(`hr`,{className:Fj(Nj.footnoteSectionDivider,Pj.footnoteSectionDivider)}),(0,K.jsx)(`ol`,{className:Fj(Nj.footnoteSectionList,Pj.footnoteSectionList),children:r.map(([e,t])=>{let r=n[e]??e;return(0,K.jsxs)(`li`,{id:`footnote-${e}`,className:Fj(Nj.footnoteSectionItem,Pj.footnoteSectionItem,Nj.footnoteSectionItemEdit,Pj.footnoteSectionItemEdit),children:[(0,K.jsxs)(`span`,{className:Fj(Nj.footnoteSectionItemNum,Pj.footnoteSectionItemNum),children:[r,`.`]}),(0,K.jsx)(`input`,{placeholder:`Footnote content for [^${e}]`,type:`text`,value:t,className:Fj(Nj.footnoteSectionItemInput,Pj.footnoteSectionItemInput),onChange:t=>i(e,t.target.value)}),(0,K.jsx)(`button`,{"aria-label":`Remove footnote ${e}`,type:`button`,className:Fj(Nj.footnoteSectionItemRemove,Pj.footnoteSectionItemRemove),onClick:()=>a(e),children:`×`})]},e)})})]})}var oke=class e extends YP{static getType(){return`footnote-section`}static clone(t){return new e({...t.__definitions},t.__key)}static importJSON(t){return new e(t.definitions).updateFromJSON(t)}decorate(e,t){return(0,G.createElement)(ake,{definitions:this.__definitions,nodeKey:this.__key})}},ske=30;function cke(){let e=Sr().getFirstChild();rr(e)?e.selectStart():Sr().selectStart()}function lke({cellEditors:e,clearAutoFocusIntent:t,requestFrame:n=window.requestAnimationFrame.bind(window),cancelFrame:r=window.cancelAnimationFrame.bind(window),maxRootLookupAttempts:i=ske}){let a=!1,o=null,s=r=>{o=n(()=>{if(o=null,a)return;let n=e[0];n?!n.getRootElement()&&r<i?s(r+1):(t(),n.update(cke,{discrete:!0}),n.focus()):t()})};return s(0),()=>{a=!0,o!==null&&r(o)}}var uke=[1,2,3,4];function TF({children:e,className:t,label:n,pressed:r,onClick:i}){return(0,K.jsxs)(Mn,{children:[(0,K.jsx)(tt,{render:(0,K.jsx)(`button`,{"aria-label":n,"aria-pressed":r,className:t,type:`button`,onClick:i}),children:e}),(0,K.jsx)(Fn,{side:`top`,children:n})]})}function dke({nodeKey:e,autoFocusOnMount:t,cols:n,gap:r,cellEditors:i}){let[a]=ht(),[o,s]=(0,G.useState)(n);pF(i,e),(0,G.useEffect)(()=>a.registerUpdateListener(({editorState:t})=>{t.read(()=>{let t=Dn(e);QP(t)&&s(t.getCols())})}),[a,e]),(0,G.useEffect)(()=>{if(t)return lke({cellEditors:i,clearAutoFocusIntent:()=>{a.update(()=>{let t=Dn(e);OF(t)&&t.setShouldAutoFocusOnMount(!1)},{discrete:!0})}})},[t,i,a,e]);let c=(0,G.useCallback)(t=>{a.update(()=>{let n=Dn(e);QP(n)&&n.setCols(t)})},[a,e]),l=(0,G.useCallback)(()=>{a.update(()=>{let t=Dn(e);QP(t)&&t.addCells(t.getCols())})},[a,e]),u=(0,G.useCallback)(()=>{a.update(()=>{let t=Dn(e);if(!OF(t))return;let n=t.getCols(),r=t.getCellEditors();r.length<=n||r.slice(-n).every(e=>e.getEditorState().read(()=>Sr().getTextContentSize()===0))&&t.removeCells(n)})},[a,e]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{"aria-label":`Grid`,className:Fj(_P.toolbar,vP.toolbar),role:`toolbar`,onMouseDown:e=>e.preventDefault(),children:[(0,K.jsx)(`span`,{className:Fj(_P.toolbarIcon,vP.toolbarIcon),children:(0,K.jsx)(Lr,{size:16})}),uke.map(e=>(0,K.jsx)(TF,{label:`${e} columns`,pressed:e===o,className:Fj(_P.colButton,vP.colButton,e===o&&_P.colButtonActive,e===o&&vP.colButtonActive),onClick:()=>c(e),children:e},e)),(0,K.jsx)(`div`,{className:Fj(_P.toolbarDivider,vP.toolbarDivider)}),(0,K.jsx)(TF,{className:Fj(_P.actionButton,vP.actionButton),label:`Add row`,onClick:l,children:(0,K.jsx)(zr,{size:16})}),(0,K.jsx)(TF,{className:Fj(_P.actionButton,vP.actionButton),label:`Remove last row`,onClick:u,children:(0,K.jsx)(x,{size:16})})]}),(0,K.jsx)(`div`,{className:Fj(_P.inner,vP.inner),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,gap:r},children:i.map((e,t)=>(0,K.jsx)(`div`,{className:Fj(_P.cell,vP.cell),children:(0,K.jsxs)(pA,{initialEditor:e,children:[(0,K.jsx)(Yt,{ErrorBoundary:Nt,contentEditable:(0,K.jsx)(Ee,{"aria-placeholder":``,className:Fj(_P.cellEditable,vP.cellEditable),placeholder:(0,K.jsx)(`span`,{style:{display:`none`}})})}),(0,K.jsx)(fF,{})]})},t))})]})}function EF(){return mF(`GridCell`)}var DF=class e extends ZP{static clone(t){let n=new e(t.__cols,t.__gap,t.__cellStates,t.__key,{autoFocusOnMount:t.__autoFocusOnMount});return n.__cellEditors=[...t.__cellEditors],n}constructor(e=2,t,n,r,i){super(e,t,n,r),tA(this,`__cellEditors`,void 0),tA(this,`__autoFocusOnMount`,void 0),this.__autoFocusOnMount=i?.autoFocusOnMount??!1,this.__cellEditors=this.__cellStates.map(e=>{let t=EF(),n=t.parseEditorState(e);return t.setEditorState(n),t})}getCellEditors(){return this.getLatest().__cellEditors}getShouldAutoFocusOnMount(){return this.getLatest().__autoFocusOnMount}setShouldAutoFocusOnMount(e){let t=this.getWritable();t.__autoFocusOnMount=e}setCols(e){let t=this.getWritable(),n=t.__cellEditors.length;if(t.__cols=e,e>n)for(let r=n;r<e;r++){let e=EF();t.__cellEditors.push(e),t.__cellStates.push({root:{children:[{type:`paragraph`,children:[],direction:null,format:``,indent:0,textFormat:0,textStyle:``,version:1}],direction:null,format:``,indent:0,type:`root`,version:1}})}}addCells(e){let t=this.getWritable();for(let n=0;n<e;n++){let e=EF();t.__cellEditors.push(e),t.__cellStates.push({root:{children:[{type:`paragraph`,children:[],direction:null,format:``,indent:0,textFormat:0,textStyle:``,version:1}],direction:null,format:``,indent:0,type:`root`,version:1}})}}removeCells(e){let t=this.getWritable(),n=t.__cellEditors,r=t.__cellStates,i=Math.min(e,n.length);for(let e=0;e<i;e++){let e=n.at(-1);if(!e||!e.getEditorState().read(()=>Sr().getTextContentSize()===0))break;n.pop(),r.pop()}}static importJSON(t){let n=t,r=n.cols||2,i=n.gap,a=typeof i==`number`?`${i}px`:i;if(n.cells&&n.cells.length>0)return new e(r,a,n.cells).updateFromJSON(t);if(n.children){let i=n.children.map(e=>({root:{children:[e],direction:null,format:``,indent:0,type:`root`,version:1}}));return new e(r,a,i).updateFromJSON(t)}return new e(r,a).updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),type:`grid-container`,cols:this.__cols,gap:this.__gap,cells:this.__cellEditors.map(e=>e.getEditorState().toJSON()),version:1}}decorate(e,t){return(0,G.createElement)(dke,{nodeKey:this.__key,cols:this.__cols,gap:this.__gap,cellEditors:this.__cellEditors,autoFocusOnMount:this.__autoFocusOnMount})}};tA(DF,`slashMenuItems`,[{title:`Grid`,icon:(0,G.createElement)(Lr,{size:20}),description:`Grid layout container`,keywords:[`grid`,`columns`,`layout`],nested:!1,section:`LAYOUT`,onSelect:e=>{e.update(()=>{Un([fke(2,void 0,{autoFocusOnMount:!0})])})}}]);function fke(e=2,t,n){return new DF(e,t,void 0,void 0,n)}function OF(e){return e instanceof DF}var pke=[cP,eP,ZN,JN,UN,hF,wF,CN,oke,iF,qP,$P,HP,GP,DF,xF,nP,tF,dP],kF=[...oF,...pke],AF=null;function mke(e){AF=e}function jF(){return AF??kF}var hke=[`/favicon.ico`,`/favicon.png`,`/favicon.svg`,`/apple-touch-icon.png`,`/apple-touch-icon-precomposed.png`],MF=new Map;function NF(e){try{let t=new URL(e);return t.protocol!==`http:`&&t.protocol!==`https:`?null:t.hostname}catch{return null}}function gke(e){return new Promise(t=>{let n=new Image;n.onload=()=>t(e),n.onerror=()=>t(null),n.src=e})}async function PF(e){let t=MF.get(e);if(t!==void 0)return t;for(let t of hke){let n=await gke(`https://${e}${t}`);if(n)return MF.set(e,n),n}return MF.set(e,null),null}var FF=()=>({children:[],direction:null,format:``,indent:0,textFormat:0,textStyle:``,type:`paragraph`,version:1}),_ke=new Set([`root`,`quote`]);function IF(e){return typeof e==`object`&&!!e}function LF(e){return!IF(e)||e.type!==`text`||typeof e.text!=`string`?!1:e.text.trim()===``&&/[\n\r]/.test(e.text)}function vke(e){let t=0,n=e.length;for(;t<n&&LF(e[t]);)t+=1;for(;n>t&&LF(e[n-1]);)--n;return t===0&&n===e.length?e:e.slice(t,n)}function RF(e){if(!IF(e)||!Array.isArray(e.children))return e;let t=!1,n=e.children.map(e=>{let n=RF(e);return n!==e&&(t=!0),n});if(_ke.has(String(e.type))){let e=vke(n);e!==n&&(t=!0,n=e)}return t?{...e,children:n}:e}function zF(e){let t=e?.root,n=Array.isArray(t?.children)?[...t.children]:[];if(t?.type===`root`&&n.length>0){let n=RF(t);return n===t?e:{...e,root:n}}return e?{...e,root:RF({...t,children:n.length>0?n:[FF()],direction:t?.direction??null,format:typeof t?.format==`string`?t.format:``,indent:typeof t?.indent==`number`?t.indent:0,type:`root`,version:typeof t?.version==`number`?t.version:1})}:{root:{children:[FF()],direction:null,format:``,indent:0,type:`root`,version:1}}}var BF=(0,G.createContext)(null);function yke({children:e}){let[t]=ht(),[n,r]=(0,G.useState)(t),i=(0,G.useRef)(n);i.current=n;let a=(0,G.useRef)({undo:!1,redo:!1});(0,G.useEffect)(()=>{let e=(e,n)=>t.registerCommand(e,(r,o)=>{if(o!==t)return!1;a.current[n]=r;let s=i.current;return s&&s!==t&&s.dispatchCommand(e,r),!1},1),n=[e(Ke,`undo`),e(sn,`redo`)];return()=>n.forEach(e=>e())},[t]),(0,G.useEffect)(()=>{n&&n!==t&&(n.dispatchCommand(Ke,a.current.undo),n.dispatchCommand(sn,a.current.redo))},[n,t]);let[o,s]=(0,G.useState)(()=>new Map),[c,l]=(0,G.useState)(()=>new Map),u=(0,G.useCallback)((e,t,n)=>(s(r=>new Map(r).set(e,{surface:t,priority:n})),()=>s(t=>{let n=new Map(t);return n.delete(e),n})),[]),d=(0,G.useCallback)((e,t)=>(l(n=>new Map(n).set(e,t)),()=>l(t=>{let n=new Map(t);return n.delete(e),n})),[]),f=(0,G.useMemo)(()=>{let e;for(let t of o.values())(!e||t.priority>=e.priority)&&(e=t);return e?.surface??null},[o]),[p,m]=(0,G.useState)(0),h=(0,G.useRef)(0),g=(0,G.useRef)(null),_=p>0?g.current:f,v=(0,G.useRef)(_);v.current=_;let y=(0,G.useCallback)(()=>{h.current++===0&&(g.current=v.current),m(h.current);let e=!1;return()=>{e||(e=!0,m(--h.current))}},[]),b=(0,G.useMemo)(()=>[...c].map(([e,t])=>(0,K.jsx)(G.Fragment,{children:t},e)),[c]);(0,G.useLayoutEffect)(()=>r(_?null:t),[t,_]);let x=(0,G.useMemo)(()=>({surface:_,activeEditor:n,setActiveEditor:r,plugins:b,registerSurface:u,registerPlugins:d,retainSurface:y}),[_,n,b,u,d,y]);return(0,K.jsx)(BF,{value:x,children:e})}function VF(){let e=(0,G.use)(BF);if(!e)throw Error(`Editor surface extensions must be mounted inside RichEditor`);return e}function HF({surface:e,priority:t=0}){let n=(0,G.useId)(),{registerSurface:r}=VF();return(0,G.useLayoutEffect)(()=>r(n,e,t),[n,t,r,e]),null}function UF({children:e}){let t=(0,G.useId)(),{registerPlugins:n}=VF(),[r]=(0,G.useState)(()=>bke(e));return(0,G.useLayoutEffect)(()=>n(t,(0,K.jsx)(xke,{slot:r})),[t,n,r]),(0,G.useLayoutEffect)(()=>r.set(e),[e,r]),null}function bke(e){let t=e,n=new Set;return{get:()=>t,set:e=>{e!==t&&(t=e,n.forEach(e=>e()))},subscribe:e=>(n.add(e),()=>n.delete(e))}}function xke({slot:e}){return(0,G.useSyncExternalStore)(e.subscribe,e.get,e.get)}function Ske(){return VF().activeEditor}function WF({children:e}){let[t,n]=ht(),r=Ske(),i=(0,G.useMemo)(()=>[r??t,n],[r,n,t]);return(0,K.jsx)(Dr,{value:i,children:e})}var Cke=(0,G.lazy)(()=>r(()=>import(`./VirtualizedEditor-uWe43zaI-CgOwRELB.js`).then(e=>({default:e.VirtualizedEditor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]),import.meta.url));function wke({scrollContainer:e,overscan:t,estimateBlockHeight:n,preserveCapacity:r,selectionMergeLimit:i,priority:a=0}){let o=(0,G.useMemo)(()=>{let a={scrollContainer:e,overscan:t,estimateBlockHeight:n,preserveCapacity:r,selectionMergeLimit:i};return function(e){return(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(`p`,{role:`status`,children:`Loading editor…`}),children:(0,K.jsx)(Cke,{...e,options:a})})}},[e,t,n,r,i]);return(0,K.jsx)(HF,{priority:a,surface:o})}function Tke({disableTakeFocusOnClick:e=!1}){let[t]=ht();return(0,G.useEffect)(()=>rte(t,{disableTakeFocusOnClick:e}),[t,e]),null}function Eke({maxIndent:e,$canIndent:t}){let[n]=ht();return(0,G.useEffect)(()=>mOe(n,e,t),[n,e,t]),null}function GF(e,t){let n={};for(let r of e){let e=t(r);e&&(n[e]?n[e].push(r):n[e]=[r])}return n}function KF(e){let t=GF(e,e=>e.type);return{element:t.element||[],multilineElement:t[`multiline-element`]||[],textFormat:t[`text-format`]||[],textMatch:t[`text-match`]||[]}}var qF=/[!-/:-@[-`{-~\s]/,JF=/\s/,YF=/[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~]/,Dke=/^\s{0,3}$/;function XF(e){if(!yr(e))return!1;let t=e.getFirstChild();return t==null||e.getChildrenSize()===1&&it(t)&&Dke.test(t.getTextContent())}function ZF(e){return e.replace(/\\([!-/:-@[-`{-~])|&#(?:(\d{1,7})|[xX]([\da-fA-F]{1,6}));/g,(e,t,n,r)=>t??function(e,t){let n=e===void 0?parseInt(t,16):Number(e);return n===0||n>=55296&&n<=57343||n>1114111?`�`:String.fromCodePoint(n)}(n,r))}function QF(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;r--)n++;return n%2==1}function $F(e){let t=t=>{let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;r--)n++;return n%2==1},n=[],r=0;for(;r<e.length;)if(e[r]==="`"){let t=1;for(;r+t<e.length&&e[r+t]==="`";)t++;n.push({index:r,length:t}),r+=t}else r++;let i=[],a=0;for(;a<n.length;){let r=n[a];if(t(r.index)){a++;continue}let o=-1;for(let e=a+1;e<n.length;e++)if(n[e].length===r.length){o=e;break}if(o===-1){a++;continue}let s=n[o],c=e.slice(r.index+r.length,s.index);c.length>=2&&c.startsWith(` `)&&c.endsWith(` `)&&/[^ ]/.test(c)&&(c=c.slice(1,-1)),i.push({content:c,endIndex:s.index+s.length,startIndex:r.index}),a=o+1}return i}function eI(e,t,n,r,i){if(!tI(t,n,r,i))return!1;if(e===`*`)return!0;if(e===`_`){if(!tI(t,n,r,!i))return!0;let e=i?t[n-1]:t[n+r];return e!==void 0&&YF.test(e)}return!0}function tI(e,t,n,r){let i=e[t-1],a=e[t+n],[o,s]=r?[a,i]:[i,a];return o!==void 0&&!JF.test(o)&&(!YF.test(o)||s===void 0||JF.test(s)||YF.test(s))}var nI=/^(\s*)(\d{1,})\.\s/,rI=/^(\s*)[-*+]\s/,iI=/^(\s*)(?:[-*+]\s)?\s?(\[(\s|x)?\])\s/i,aI=/^(#{1,6})\s/,oI=/^>\s/,sI=/^([ \t]*`{3,})([\w-]+)?[ \t]?/,cI=/^[ \t]*`{3,}$/,Oke=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,kke=/^(?:\|)(.+)(?:\|)\s?$/;function Ake(e){if(e[0]!==`|`)return!1;let{length:t}=e,n=1,r=0;for(;n<t;){let t=n;for(e[t]===` `&&t++,e[t]===`:`&&t++;e[t]===`-`;)t++;if(e[t]===`:`&&t++,e[t]===` `&&t++,e[t]!==`|`)break;r++,n=t+1}return r>0&&(n===t||n===t-1&&/\s/.test(e[n]))}var lI=/^<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,uI=/^<\/[a-z_][\w-]*\s*>/i,dI=e=>RegExp(`(?:${e.source})$`,e.flags),fI=Ft(`mdListMarker`,{parse:e=>typeof e==`string`&&/^[-*+]$/.test(e)?e:`-`,resetOnCopyNode:!0}),pI=Ft(`mdCodeFence`,{parse:e=>typeof e==`string`&&/^`{3,}$/.test(e)?e:"```",resetOnCopyNode:!0}),mI=Ft(`mdCodeMeta`,{parse:e=>typeof e==`string`?e:``,resetOnCopyNode:!0}),jke=Ft(`mdHardLineBreak`,{parse:e=>typeof e==`string`&&/^(\\| {2,})$/.test(e)?e:``,resetOnCopyNode:!0});function hI(e){if(e.endsWith(`\\`)){let t=0;for(let n=e.length-1;n>=0&&e[n]===`\\`;n--)t++;return t%2==1?[e.slice(0,-1),`\\`]:null}let t=e.match(/^(.*?\S)( {2,})$/);return t?[t[1],t[2]]:null}function gI(e){let t=ve(),n=function(e){let t=e.getChildren(),n=t.length-1,r=t[n];if(!it(r))return null;let i=r.getTextContent(),a=hI(i);if(a!==null){let[e,t]=a;return r.setTextContent(e),t}return/^ {2,}$/.test(i)&&function(e,t){for(let n=t-1;n>=0;n--){if(lr(e[n]))return!1;if(/\S/.test(e[n].getTextContent()))return!0}return!1}(t,n)?(r.setTextContent(``),i):null}(e);return n!==null&&kn(t,jke,n),t}function _I(e){return Er(e)}function vI(e,t){let n=0;for(;n<t&&(e[n]===` `||e[n]===` `);)n++;return e.slice(n)}function Mke(e,t){let n=e.getLastChild();t&&EP(n)&&kn(n,mI,t)}var yI=e=>(t,n,r,i)=>{let a=e(r);a.append(...n),t.replace(a),i||a.select(0,0)};function bI(e){let t=0;for(let n of e)t+=n===` `?4-t%4:1;return t}var xI=null,SI=!1,CI=e=>(t,n,r,i)=>{if(_r(t)||!i&&_I(t))return!1;let a=t.getPreviousSibling(),o=t.getNextSibling(),s=ir(e===`check`?/^x$/i.test(r[3]||``):void 0),c=r[0].trim()[0],l=e!==`bullet`&&e!==`check`||c!==fI.parse(c)?void 0:c,u=xI,d=a;if(u!==null){if(SI)for(;d!==null&&XF(d);)d=d.getPreviousSibling();nr(d)||(u.length=0)}let f=u===null||u.length===0?function(e){let t=e.match(/\t/g),n=e.match(/ /g),r=0;return t&&(r+=t.length),n&&(r+=Math.floor(n.length/4)),r}(r[1]):function(e,t){let n=bI(t);for(let t=e.length-1;t>=0;t--)if(n>=e[t])return t+1;return 0}(u,r[1]);if(nr(o)&&o.getListType()===e){let n=o.getFirstChild();n===null?o.append(s):n.insertBefore(s),e===`number`&&f===0&&o.setStart(Number(r[2])),t.remove()}else if(nr(d)&&(d.getListType()===e||f>0))d.append(s),t.remove();else{let n=Zt(e,e===`number`?Number(r[2]):void 0);n.append(s),t.replace(n)}s.append(...n),i||s.select(0,0),f&&(s.setIndent(f),function(e,t,n){let r=e.getParent();if(!nr(r)||r.getListType()===t)return;let i=r.getParent();if(!cr(i))return;let a=Zt(t,t===`number`?Number(n[2]):void 0),o=e.getPreviousSibling()===null;a.append(e);let s=ir();s.append(a),o?i.insertBefore(s):i.insertAfter(s),r.getChildrenSize()===0&&i.remove()}(s,e,r));let p=s.getParent();l&&nr(p)&&kn(p,fI,l),u!==null&&function(e,t,n,r){for(let n=e.length;n<t;n++)e[n]=4*(n+1);e.length=t,e[t]=function(e,t){let n=e[0];if(t===`check`){let t=n.slice(e[1].length).match(/^[-*+]\s/);t&&(n=e[1]+t[0])}return Math.min(bI(n),bI(e[1])+4)}(n,r)}(u,f,r,e)},wI=(e,t,n,r)=>{let i=[],a=e.getChildren(),o=0;for(let s of a)if(cr(s)){if(s.getChildrenSize()===1){let e=s.getFirstChild();if(nr(e)){let a=wI(e,t,n+1,r);a&&i.push(a);continue}}if(r&&!s.getChildren().some(e=>e.isSelected(r)))continue;let a=` `.repeat(4*n),c=e.getListType(),l=Hn(e,fI),u=c===`number`?`${e.getStart()+o}. `:c===`check`?`${l} [${s.getChecked()?`x`:` `}] `:l+` `,d=t(s);c!==`number`&&(d=d.replace(/^(\s{0,3}\d+)(\.\s)/,`$1\\$2`)),i.push(a+u+d),o++}return i.join(`
|
|
172
|
+
`:``]},t))})})]})}function rke({nodeKey:e,code:t,language:n}){let[r]=ht(),[i]=vF(e),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(`start`),l=r.isEditable();(0,G.useEffect)(()=>{if(!l||!i){o(!1);return}let t=!1,n=`start`;r.getEditorState().read(()=>{let r=kr(),i=Ue(r)?r.getNodes():null;t=i!==null&&i.length===1&&i[0]?.getKey()===e,t&&(n=$Oe(e)??`start`)}),o(t),t&&c(n)},[l,r,i,e]),(0,G.useEffect)(()=>{if(l&&i)return r.registerCommand(br,t=>(t.key.length!==1||t.metaKey||t.ctrlKey||t.altKey||t.isComposing||!r.getEditorState().read(()=>{let t=kr();if(!Ue(t))return!1;let n=t.getNodes();return n.length===1&&n[0]?.getKey()===e})||r.getElementByKey(e)?.querySelector(`[contenteditable="true"]`)?.focus(),!1),3)},[l,r,i,e]);let u=(0,G.useCallback)(t=>{r.update(()=>{let n=Dn(e);BP(n)&&n.setCode(t)})},[r,e]),d=(0,G.useCallback)(t=>{r.update(()=>{let n=Dn(e);BP(n)&&n.setLanguage(t)})},[r,e]),f=(0,G.useCallback)(()=>{r.getRootElement()?.focus({preventScroll:!0}),r.update(()=>{let t=Dn(e);if(!t)return;let n=t.getPreviousSibling(),r=t.getNextSibling(),i=t.getParent();if(t.remove(),n){if(rr(n))n.selectEnd();else{je(n)&&n.getType()===`code-block`&&bF(n.getKey(),`end`);let e=sr();e.add(n.getKey()),Jt(e)}}else if(r){if(rr(r))r.selectStart();else{je(r)&&r.getType()===`code-block`&&bF(r.getKey(),`start`);let e=sr();e.add(r.getKey()),Jt(e)}}else if(i){let e=on();i.append(e),e.selectStart()}})},[r,e]),p=(0,G.useCallback)(t=>{r.getRootElement()?.focus({preventScroll:!0}),r.update(()=>{let n=Dn(e);if(!n)return;if(t===`before`){let e=n.getPreviousSibling();if(!e)return;if(rr(e))e.selectEnd();else{je(e)&&e.getType()===`code-block`&&bF(e.getKey(),`end`);let t=sr();t.add(e.getKey()),Jt(t)}return}let r=n.getNextSibling();if(!r){let e=on();n.insertAfter(e),r=e}if(rr(r))r.selectStart();else{je(r)&&r.getType()===`code-block`&&bF(r.getKey(),`start`);let e=sr();e.add(r.getKey()),Jt(e)}})},[r,e]);return(0,K.jsx)(Kj,{defaultRenderer:nke,rendererKey:zj,props:{code:t,language:n,editable:l,onCodeChange:l?u:void 0,onLanguageChange:l?d:void 0,onDelete:l?f:void 0,onExitBlock:l?p:void 0,selected:l?a:!1,cursorPlacement:l?s:`start`}})}var CF,wF=class e extends RP{static clone(t){return new e(t.__code,t.__language,t.__key)}static importJSON(t){let n=t;return new e(n.code,n.language).updateFromJSON(t)}decorate(e,t){return(0,G.createElement)(rke,{nodeKey:this.__key,code:this.__code,language:this.__language})}};CF=wF,tA(wF,`commandItems`,RP.commandItems.map(e=>({...e,onSelect:e=>{e.update(()=>{Un([new CF(``,`text`)])})}})));function ike(e,t){return new wF(e,t)}function ake({definitions:e}){let[t]=ht(),{displayNumberMap:n}=Xj(),r=Object.entries(e).sort(([e],[t])=>(n[e]??0)-(n[t]??0)),i=(0,G.useCallback)((e,n)=>{t.update(()=>{let t=xn(YP);t.length>0&&t[0].setDefinition(e,n)})},[t]),a=(0,G.useCallback)(e=>{t.update(()=>{let t=xn(YP);t.length>0&&t[0].removeDefinition(e)})},[t]);return r.length===0?null:(0,K.jsxs)(`div`,{role:`doc-endnotes`,className:Fj(`rich-footnote-section-content`,`rich-footnote-section-edit`,Nj.footnoteSection,Pj.footnoteSection),children:[(0,K.jsx)(`hr`,{className:Fj(Nj.footnoteSectionDivider,Pj.footnoteSectionDivider)}),(0,K.jsx)(`ol`,{className:Fj(Nj.footnoteSectionList,Pj.footnoteSectionList),children:r.map(([e,t])=>{let r=n[e]??e;return(0,K.jsxs)(`li`,{id:`footnote-${e}`,className:Fj(Nj.footnoteSectionItem,Pj.footnoteSectionItem,Nj.footnoteSectionItemEdit,Pj.footnoteSectionItemEdit),children:[(0,K.jsxs)(`span`,{className:Fj(Nj.footnoteSectionItemNum,Pj.footnoteSectionItemNum),children:[r,`.`]}),(0,K.jsx)(`input`,{placeholder:`Footnote content for [^${e}]`,type:`text`,value:t,className:Fj(Nj.footnoteSectionItemInput,Pj.footnoteSectionItemInput),onChange:t=>i(e,t.target.value)}),(0,K.jsx)(`button`,{"aria-label":`Remove footnote ${e}`,type:`button`,className:Fj(Nj.footnoteSectionItemRemove,Pj.footnoteSectionItemRemove),onClick:()=>a(e),children:`×`})]},e)})})]})}var oke=class e extends YP{static getType(){return`footnote-section`}static clone(t){return new e({...t.__definitions},t.__key)}static importJSON(t){return new e(t.definitions).updateFromJSON(t)}decorate(e,t){return(0,G.createElement)(ake,{definitions:this.__definitions,nodeKey:this.__key})}},ske=30;function cke(){let e=Sr().getFirstChild();rr(e)?e.selectStart():Sr().selectStart()}function lke({cellEditors:e,clearAutoFocusIntent:t,requestFrame:n=window.requestAnimationFrame.bind(window),cancelFrame:r=window.cancelAnimationFrame.bind(window),maxRootLookupAttempts:i=ske}){let a=!1,o=null,s=r=>{o=n(()=>{if(o=null,a)return;let n=e[0];n?!n.getRootElement()&&r<i?s(r+1):(t(),n.update(cke,{discrete:!0}),n.focus()):t()})};return s(0),()=>{a=!0,o!==null&&r(o)}}var uke=[1,2,3,4];function TF({children:e,className:t,label:n,pressed:r,onClick:i}){return(0,K.jsxs)(Mn,{children:[(0,K.jsx)(tt,{render:(0,K.jsx)(`button`,{"aria-label":n,"aria-pressed":r,className:t,type:`button`,onClick:i}),children:e}),(0,K.jsx)(Fn,{side:`top`,children:n})]})}function dke({nodeKey:e,autoFocusOnMount:t,cols:n,gap:r,cellEditors:i}){let[a]=ht(),[o,s]=(0,G.useState)(n);pF(i,e),(0,G.useEffect)(()=>a.registerUpdateListener(({editorState:t})=>{t.read(()=>{let t=Dn(e);QP(t)&&s(t.getCols())})}),[a,e]),(0,G.useEffect)(()=>{if(t)return lke({cellEditors:i,clearAutoFocusIntent:()=>{a.update(()=>{let t=Dn(e);OF(t)&&t.setShouldAutoFocusOnMount(!1)},{discrete:!0})}})},[t,i,a,e]);let c=(0,G.useCallback)(t=>{a.update(()=>{let n=Dn(e);QP(n)&&n.setCols(t)})},[a,e]),l=(0,G.useCallback)(()=>{a.update(()=>{let t=Dn(e);QP(t)&&t.addCells(t.getCols())})},[a,e]),u=(0,G.useCallback)(()=>{a.update(()=>{let t=Dn(e);if(!OF(t))return;let n=t.getCols(),r=t.getCellEditors();r.length<=n||r.slice(-n).every(e=>e.getEditorState().read(()=>Sr().getTextContentSize()===0))&&t.removeCells(n)})},[a,e]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{"aria-label":`Grid`,className:Fj(_P.toolbar,vP.toolbar),role:`toolbar`,onMouseDown:e=>e.preventDefault(),children:[(0,K.jsx)(`span`,{className:Fj(_P.toolbarIcon,vP.toolbarIcon),children:(0,K.jsx)(Lr,{size:16})}),uke.map(e=>(0,K.jsx)(TF,{label:`${e} columns`,pressed:e===o,className:Fj(_P.colButton,vP.colButton,e===o&&_P.colButtonActive,e===o&&vP.colButtonActive),onClick:()=>c(e),children:e},e)),(0,K.jsx)(`div`,{className:Fj(_P.toolbarDivider,vP.toolbarDivider)}),(0,K.jsx)(TF,{className:Fj(_P.actionButton,vP.actionButton),label:`Add row`,onClick:l,children:(0,K.jsx)(zr,{size:16})}),(0,K.jsx)(TF,{className:Fj(_P.actionButton,vP.actionButton),label:`Remove last row`,onClick:u,children:(0,K.jsx)(T,{size:16})})]}),(0,K.jsx)(`div`,{className:Fj(_P.inner,vP.inner),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,gap:r},children:i.map((e,t)=>(0,K.jsx)(`div`,{className:Fj(_P.cell,vP.cell),children:(0,K.jsxs)(pA,{initialEditor:e,children:[(0,K.jsx)(Yt,{ErrorBoundary:Nt,contentEditable:(0,K.jsx)(Ee,{"aria-placeholder":``,className:Fj(_P.cellEditable,vP.cellEditable),placeholder:(0,K.jsx)(`span`,{style:{display:`none`}})})}),(0,K.jsx)(fF,{})]})},t))})]})}function EF(){return mF(`GridCell`)}var DF=class e extends ZP{static clone(t){let n=new e(t.__cols,t.__gap,t.__cellStates,t.__key,{autoFocusOnMount:t.__autoFocusOnMount});return n.__cellEditors=[...t.__cellEditors],n}constructor(e=2,t,n,r,i){super(e,t,n,r),tA(this,`__cellEditors`,void 0),tA(this,`__autoFocusOnMount`,void 0),this.__autoFocusOnMount=i?.autoFocusOnMount??!1,this.__cellEditors=this.__cellStates.map(e=>{let t=EF(),n=t.parseEditorState(e);return t.setEditorState(n),t})}getCellEditors(){return this.getLatest().__cellEditors}getShouldAutoFocusOnMount(){return this.getLatest().__autoFocusOnMount}setShouldAutoFocusOnMount(e){let t=this.getWritable();t.__autoFocusOnMount=e}setCols(e){let t=this.getWritable(),n=t.__cellEditors.length;if(t.__cols=e,e>n)for(let r=n;r<e;r++){let e=EF();t.__cellEditors.push(e),t.__cellStates.push({root:{children:[{type:`paragraph`,children:[],direction:null,format:``,indent:0,textFormat:0,textStyle:``,version:1}],direction:null,format:``,indent:0,type:`root`,version:1}})}}addCells(e){let t=this.getWritable();for(let n=0;n<e;n++){let e=EF();t.__cellEditors.push(e),t.__cellStates.push({root:{children:[{type:`paragraph`,children:[],direction:null,format:``,indent:0,textFormat:0,textStyle:``,version:1}],direction:null,format:``,indent:0,type:`root`,version:1}})}}removeCells(e){let t=this.getWritable(),n=t.__cellEditors,r=t.__cellStates,i=Math.min(e,n.length);for(let e=0;e<i;e++){let e=n.at(-1);if(!e||!e.getEditorState().read(()=>Sr().getTextContentSize()===0))break;n.pop(),r.pop()}}static importJSON(t){let n=t,r=n.cols||2,i=n.gap,a=typeof i==`number`?`${i}px`:i;if(n.cells&&n.cells.length>0)return new e(r,a,n.cells).updateFromJSON(t);if(n.children){let i=n.children.map(e=>({root:{children:[e],direction:null,format:``,indent:0,type:`root`,version:1}}));return new e(r,a,i).updateFromJSON(t)}return new e(r,a).updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),type:`grid-container`,cols:this.__cols,gap:this.__gap,cells:this.__cellEditors.map(e=>e.getEditorState().toJSON()),version:1}}decorate(e,t){return(0,G.createElement)(dke,{nodeKey:this.__key,cols:this.__cols,gap:this.__gap,cellEditors:this.__cellEditors,autoFocusOnMount:this.__autoFocusOnMount})}};tA(DF,`slashMenuItems`,[{title:`Grid`,icon:(0,G.createElement)(Lr,{size:20}),description:`Grid layout container`,keywords:[`grid`,`columns`,`layout`],nested:!1,section:`LAYOUT`,onSelect:e=>{e.update(()=>{Un([fke(2,void 0,{autoFocusOnMount:!0})])})}}]);function fke(e=2,t,n){return new DF(e,t,void 0,void 0,n)}function OF(e){return e instanceof DF}var pke=[cP,eP,ZN,JN,UN,hF,wF,CN,oke,iF,qP,$P,HP,GP,DF,xF,nP,tF,dP],kF=[...oF,...pke],AF=null;function mke(e){AF=e}function jF(){return AF??kF}var hke=[`/favicon.ico`,`/favicon.png`,`/favicon.svg`,`/apple-touch-icon.png`,`/apple-touch-icon-precomposed.png`],MF=new Map;function NF(e){try{let t=new URL(e);return t.protocol!==`http:`&&t.protocol!==`https:`?null:t.hostname}catch{return null}}function gke(e){return new Promise(t=>{let n=new Image;n.onload=()=>t(e),n.onerror=()=>t(null),n.src=e})}async function PF(e){let t=MF.get(e);if(t!==void 0)return t;for(let t of hke){let n=await gke(`https://${e}${t}`);if(n)return MF.set(e,n),n}return MF.set(e,null),null}var FF=()=>({children:[],direction:null,format:``,indent:0,textFormat:0,textStyle:``,type:`paragraph`,version:1}),_ke=new Set([`root`,`quote`]);function IF(e){return typeof e==`object`&&!!e}function LF(e){return!IF(e)||e.type!==`text`||typeof e.text!=`string`?!1:e.text.trim()===``&&/[\n\r]/.test(e.text)}function vke(e){let t=0,n=e.length;for(;t<n&&LF(e[t]);)t+=1;for(;n>t&&LF(e[n-1]);)--n;return t===0&&n===e.length?e:e.slice(t,n)}function RF(e){if(!IF(e)||!Array.isArray(e.children))return e;let t=!1,n=e.children.map(e=>{let n=RF(e);return n!==e&&(t=!0),n});if(_ke.has(String(e.type))){let e=vke(n);e!==n&&(t=!0,n=e)}return t?{...e,children:n}:e}function zF(e){let t=e?.root,n=Array.isArray(t?.children)?[...t.children]:[];if(t?.type===`root`&&n.length>0){let n=RF(t);return n===t?e:{...e,root:n}}return e?{...e,root:RF({...t,children:n.length>0?n:[FF()],direction:t?.direction??null,format:typeof t?.format==`string`?t.format:``,indent:typeof t?.indent==`number`?t.indent:0,type:`root`,version:typeof t?.version==`number`?t.version:1})}:{root:{children:[FF()],direction:null,format:``,indent:0,type:`root`,version:1}}}var BF=(0,G.createContext)(null);function yke({children:e}){let[t]=ht(),[n,r]=(0,G.useState)(t),i=(0,G.useRef)(n);i.current=n;let a=(0,G.useRef)({undo:!1,redo:!1});(0,G.useEffect)(()=>{let e=(e,n)=>t.registerCommand(e,(r,o)=>{if(o!==t)return!1;a.current[n]=r;let s=i.current;return s&&s!==t&&s.dispatchCommand(e,r),!1},1),n=[e(Ke,`undo`),e(sn,`redo`)];return()=>n.forEach(e=>e())},[t]),(0,G.useEffect)(()=>{n&&n!==t&&(n.dispatchCommand(Ke,a.current.undo),n.dispatchCommand(sn,a.current.redo))},[n,t]);let[o,s]=(0,G.useState)(()=>new Map),[c,l]=(0,G.useState)(()=>new Map),u=(0,G.useCallback)((e,t,n)=>(s(r=>new Map(r).set(e,{surface:t,priority:n})),()=>s(t=>{let n=new Map(t);return n.delete(e),n})),[]),d=(0,G.useCallback)((e,t)=>(l(n=>new Map(n).set(e,t)),()=>l(t=>{let n=new Map(t);return n.delete(e),n})),[]),f=(0,G.useMemo)(()=>{let e;for(let t of o.values())(!e||t.priority>=e.priority)&&(e=t);return e?.surface??null},[o]),[p,m]=(0,G.useState)(0),h=(0,G.useRef)(0),g=(0,G.useRef)(null),_=p>0?g.current:f,v=(0,G.useRef)(_);v.current=_;let y=(0,G.useCallback)(()=>{h.current++===0&&(g.current=v.current),m(h.current);let e=!1;return()=>{e||(e=!0,m(--h.current))}},[]),b=(0,G.useMemo)(()=>[...c].map(([e,t])=>(0,K.jsx)(G.Fragment,{children:t},e)),[c]);(0,G.useLayoutEffect)(()=>r(_?null:t),[t,_]);let x=(0,G.useMemo)(()=>({surface:_,activeEditor:n,setActiveEditor:r,plugins:b,registerSurface:u,registerPlugins:d,retainSurface:y}),[_,n,b,u,d,y]);return(0,K.jsx)(BF,{value:x,children:e})}function VF(){let e=(0,G.use)(BF);if(!e)throw Error(`Editor surface extensions must be mounted inside RichEditor`);return e}function HF({surface:e,priority:t=0}){let n=(0,G.useId)(),{registerSurface:r}=VF();return(0,G.useLayoutEffect)(()=>r(n,e,t),[n,t,r,e]),null}function UF({children:e}){let t=(0,G.useId)(),{registerPlugins:n}=VF(),[r]=(0,G.useState)(()=>bke(e));return(0,G.useLayoutEffect)(()=>n(t,(0,K.jsx)(xke,{slot:r})),[t,n,r]),(0,G.useLayoutEffect)(()=>r.set(e),[e,r]),null}function bke(e){let t=e,n=new Set;return{get:()=>t,set:e=>{e!==t&&(t=e,n.forEach(e=>e()))},subscribe:e=>(n.add(e),()=>n.delete(e))}}function xke({slot:e}){return(0,G.useSyncExternalStore)(e.subscribe,e.get,e.get)}function Ske(){return VF().activeEditor}function WF({children:e}){let[t,n]=ht(),r=Ske(),i=(0,G.useMemo)(()=>[r??t,n],[r,n,t]);return(0,K.jsx)(Dr,{value:i,children:e})}var Cke=(0,G.lazy)(()=>r(()=>import(`./VirtualizedEditor-uWe43zaI-BlOdeG0b.js`).then(e=>({default:e.VirtualizedEditor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]),import.meta.url));function wke({scrollContainer:e,overscan:t,estimateBlockHeight:n,preserveCapacity:r,selectionMergeLimit:i,priority:a=0}){let o=(0,G.useMemo)(()=>{let a={scrollContainer:e,overscan:t,estimateBlockHeight:n,preserveCapacity:r,selectionMergeLimit:i};return function(e){return(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(`p`,{role:`status`,children:`Loading editor…`}),children:(0,K.jsx)(Cke,{...e,options:a})})}},[e,t,n,r,i]);return(0,K.jsx)(HF,{priority:a,surface:o})}function Tke({disableTakeFocusOnClick:e=!1}){let[t]=ht();return(0,G.useEffect)(()=>rte(t,{disableTakeFocusOnClick:e}),[t,e]),null}function Eke({maxIndent:e,$canIndent:t}){let[n]=ht();return(0,G.useEffect)(()=>mOe(n,e,t),[n,e,t]),null}function GF(e,t){let n={};for(let r of e){let e=t(r);e&&(n[e]?n[e].push(r):n[e]=[r])}return n}function KF(e){let t=GF(e,e=>e.type);return{element:t.element||[],multilineElement:t[`multiline-element`]||[],textFormat:t[`text-format`]||[],textMatch:t[`text-match`]||[]}}var qF=/[!-/:-@[-`{-~\s]/,JF=/\s/,YF=/[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~]/,Dke=/^\s{0,3}$/;function XF(e){if(!yr(e))return!1;let t=e.getFirstChild();return t==null||e.getChildrenSize()===1&&it(t)&&Dke.test(t.getTextContent())}function ZF(e){return e.replace(/\\([!-/:-@[-`{-~])|&#(?:(\d{1,7})|[xX]([\da-fA-F]{1,6}));/g,(e,t,n,r)=>t??function(e,t){let n=e===void 0?parseInt(t,16):Number(e);return n===0||n>=55296&&n<=57343||n>1114111?`�`:String.fromCodePoint(n)}(n,r))}function QF(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;r--)n++;return n%2==1}function $F(e){let t=t=>{let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;r--)n++;return n%2==1},n=[],r=0;for(;r<e.length;)if(e[r]==="`"){let t=1;for(;r+t<e.length&&e[r+t]==="`";)t++;n.push({index:r,length:t}),r+=t}else r++;let i=[],a=0;for(;a<n.length;){let r=n[a];if(t(r.index)){a++;continue}let o=-1;for(let e=a+1;e<n.length;e++)if(n[e].length===r.length){o=e;break}if(o===-1){a++;continue}let s=n[o],c=e.slice(r.index+r.length,s.index);c.length>=2&&c.startsWith(` `)&&c.endsWith(` `)&&/[^ ]/.test(c)&&(c=c.slice(1,-1)),i.push({content:c,endIndex:s.index+s.length,startIndex:r.index}),a=o+1}return i}function eI(e,t,n,r,i){if(!tI(t,n,r,i))return!1;if(e===`*`)return!0;if(e===`_`){if(!tI(t,n,r,!i))return!0;let e=i?t[n-1]:t[n+r];return e!==void 0&&YF.test(e)}return!0}function tI(e,t,n,r){let i=e[t-1],a=e[t+n],[o,s]=r?[a,i]:[i,a];return o!==void 0&&!JF.test(o)&&(!YF.test(o)||s===void 0||JF.test(s)||YF.test(s))}var nI=/^(\s*)(\d{1,})\.\s/,rI=/^(\s*)[-*+]\s/,iI=/^(\s*)(?:[-*+]\s)?\s?(\[(\s|x)?\])\s/i,aI=/^(#{1,6})\s/,oI=/^>\s/,sI=/^([ \t]*`{3,})([\w-]+)?[ \t]?/,cI=/^[ \t]*`{3,}$/,Oke=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,kke=/^(?:\|)(.+)(?:\|)\s?$/;function Ake(e){if(e[0]!==`|`)return!1;let{length:t}=e,n=1,r=0;for(;n<t;){let t=n;for(e[t]===` `&&t++,e[t]===`:`&&t++;e[t]===`-`;)t++;if(e[t]===`:`&&t++,e[t]===` `&&t++,e[t]!==`|`)break;r++,n=t+1}return r>0&&(n===t||n===t-1&&/\s/.test(e[n]))}var lI=/^<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,uI=/^<\/[a-z_][\w-]*\s*>/i,dI=e=>RegExp(`(?:${e.source})$`,e.flags),fI=Ft(`mdListMarker`,{parse:e=>typeof e==`string`&&/^[-*+]$/.test(e)?e:`-`,resetOnCopyNode:!0}),pI=Ft(`mdCodeFence`,{parse:e=>typeof e==`string`&&/^`{3,}$/.test(e)?e:"```",resetOnCopyNode:!0}),mI=Ft(`mdCodeMeta`,{parse:e=>typeof e==`string`?e:``,resetOnCopyNode:!0}),jke=Ft(`mdHardLineBreak`,{parse:e=>typeof e==`string`&&/^(\\| {2,})$/.test(e)?e:``,resetOnCopyNode:!0});function hI(e){if(e.endsWith(`\\`)){let t=0;for(let n=e.length-1;n>=0&&e[n]===`\\`;n--)t++;return t%2==1?[e.slice(0,-1),`\\`]:null}let t=e.match(/^(.*?\S)( {2,})$/);return t?[t[1],t[2]]:null}function gI(e){let t=ve(),n=function(e){let t=e.getChildren(),n=t.length-1,r=t[n];if(!it(r))return null;let i=r.getTextContent(),a=hI(i);if(a!==null){let[e,t]=a;return r.setTextContent(e),t}return/^ {2,}$/.test(i)&&function(e,t){for(let n=t-1;n>=0;n--){if(lr(e[n]))return!1;if(/\S/.test(e[n].getTextContent()))return!0}return!1}(t,n)?(r.setTextContent(``),i):null}(e);return n!==null&&kn(t,jke,n),t}function _I(e){return Er(e)}function vI(e,t){let n=0;for(;n<t&&(e[n]===` `||e[n]===` `);)n++;return e.slice(n)}function Mke(e,t){let n=e.getLastChild();t&&EP(n)&&kn(n,mI,t)}var yI=e=>(t,n,r,i)=>{let a=e(r);a.append(...n),t.replace(a),i||a.select(0,0)};function bI(e){let t=0;for(let n of e)t+=n===` `?4-t%4:1;return t}var xI=null,SI=!1,CI=e=>(t,n,r,i)=>{if(_r(t)||!i&&_I(t))return!1;let a=t.getPreviousSibling(),o=t.getNextSibling(),s=ir(e===`check`?/^x$/i.test(r[3]||``):void 0),c=r[0].trim()[0],l=e!==`bullet`&&e!==`check`||c!==fI.parse(c)?void 0:c,u=xI,d=a;if(u!==null){if(SI)for(;d!==null&&XF(d);)d=d.getPreviousSibling();nr(d)||(u.length=0)}let f=u===null||u.length===0?function(e){let t=e.match(/\t/g),n=e.match(/ /g),r=0;return t&&(r+=t.length),n&&(r+=Math.floor(n.length/4)),r}(r[1]):function(e,t){let n=bI(t);for(let t=e.length-1;t>=0;t--)if(n>=e[t])return t+1;return 0}(u,r[1]);if(nr(o)&&o.getListType()===e){let n=o.getFirstChild();n===null?o.append(s):n.insertBefore(s),e===`number`&&f===0&&o.setStart(Number(r[2])),t.remove()}else if(nr(d)&&(d.getListType()===e||f>0))d.append(s),t.remove();else{let n=Zt(e,e===`number`?Number(r[2]):void 0);n.append(s),t.replace(n)}s.append(...n),i||s.select(0,0),f&&(s.setIndent(f),function(e,t,n){let r=e.getParent();if(!nr(r)||r.getListType()===t)return;let i=r.getParent();if(!cr(i))return;let a=Zt(t,t===`number`?Number(n[2]):void 0),o=e.getPreviousSibling()===null;a.append(e);let s=ir();s.append(a),o?i.insertBefore(s):i.insertAfter(s),r.getChildrenSize()===0&&i.remove()}(s,e,r));let p=s.getParent();l&&nr(p)&&kn(p,fI,l),u!==null&&function(e,t,n,r){for(let n=e.length;n<t;n++)e[n]=4*(n+1);e.length=t,e[t]=function(e,t){let n=e[0];if(t===`check`){let t=n.slice(e[1].length).match(/^[-*+]\s/);t&&(n=e[1]+t[0])}return Math.min(bI(n),bI(e[1])+4)}(n,r)}(u,f,r,e)},wI=(e,t,n,r)=>{let i=[],a=e.getChildren(),o=0;for(let s of a)if(cr(s)){if(s.getChildrenSize()===1){let e=s.getFirstChild();if(nr(e)){let a=wI(e,t,n+1,r);a&&i.push(a);continue}}if(r&&!s.getChildren().some(e=>e.isSelected(r)))continue;let a=` `.repeat(4*n),c=e.getListType(),l=Hn(e,fI),u=c===`number`?`${e.getStart()+o}. `:c===`check`?`${l} [${s.getChecked()?`x`:` `}] `:l+` `,d=t(s);c!==`number`&&(d=d.replace(/^(\s{0,3}\d+)(\.\s)/,`$1\\$2`)),i.push(a+u+d),o++}return i.join(`
|
|
173
173
|
`)},Nke=yI(e=>{let t=`h`+e[1].length;return ae(t)}),Pke={dependencies:[$t],export:(e,t)=>{if(!_r(e))return null;let n=Number(e.getTag().slice(1));return`#`.repeat(n)+` `+t(e)},regExp:aI,replace:(e,t,n,r)=>!(!r&&_I(e))&&Nke(e,t,n,r),triggerOnEnter:!0,type:`element`},TI={dependencies:[mr],export:(e,t)=>{if(!Er(e))return null;let n=t(e).split(`
|
|
174
174
|
`),r=[];for(let e of n)r.push(`> `+e);return r.join(`
|
|
175
175
|
`)},regExp:oI,replace:(e,t,n,r)=>{if(r){let n=e.getPreviousSibling();if(Er(n))return n.splice(n.getChildrenSize(),0,[gI(n),...t]),void e.remove()}let i=xr();i.append(...t),e.replace(i),r||i.select(0,0)},triggerOnEnter:!0,type:`element`},EI={dependencies:[wP],export:e=>{if(!EP(e))return null;let t=e.getTextContent(),n=Hn(e,pI);if(t.indexOf(n)>-1){let e=t.match(/`{3,}/g);if(e){let t=Math.max(...e.map(e=>e.length));n="`".repeat(t+1)}}let r=e.getLanguage()||``,i=r?Hn(e,mI):``;return n+r+(i?` `+i:``)+(t?`
|
|
@@ -190,14 +190,14 @@ but found: '${Qb(Jb)}'`);(Hb[Gb[Jb]]&zb)!==0;)Jb++;return Wb.slice(Kb[e],qb[Jb-1
|
|
|
190
190
|
`).map(e=>`> ${e}`).join(`
|
|
191
191
|
`):null,regExp:/^>\s/,replace:(e,t,n,r)=>{if(r){let n=e.getPreviousSibling();if(Er(n)){n.splice(n.getChildrenSize(),0,[ve(),...t]),e.remove();return}}let i=xr(),a=on();a.append(...t),i.append(a),e.replace(i),r||a.select(0,0)},type:`element`};function cje(e){return e.replaceAll(`"`,`\\"`)}var lje={dependencies:[],export:e=>{if(!QP(e))return null;let t=e.getCellStates().map(e=>bN(e)).map(e=>`::: cell\n${e}\n:::`).join(`
|
|
192
192
|
`);return`::: grid{cols=${e.getCols()} gap="${cje(e.getGap())}"}\n${t}\n:::`},regExp:/\b\B/,replace:()=>{},type:`element`},uje={...pAe,dependencies:[tF],replace:(e,t)=>{let n=nF(t[2]??``),r=t[1]??``;r&&n.append(te(r)),e.replace(n)}},dje={...lAe,dependencies:[cP],replace:(e,t)=>{let n=lP();n.append(te(t[1])),e.replace(n)}},eL=/^\|(.+)\|\s*$/,fje=/^\|(?:\s*:?-+:?\s*\|)+\s*$/;function tL(e){let t=e.match(eL);return t?t[1].split(`|`).map(e=>e.trim()):[]}var nL=[dje,oje,nje,mAe,hAe,gAe,uje,$Ae,eje,ije,rje,tje,XAe,Ike,aje,CAe,wAe,TAe,QAe,EAe,DAe,lje,VAe,{dependencies:[],export:()=>null,handleImportAfterStartMatch({lines:e,rootNode:t,startLineIndex:n}){if(n+1>=e.length)return null;let r=e[n+1];if(!fje.test(r))return null;let i=tL(e[n]);if(i.length===0)return null;let a=n+1,o=[];for(let t=n+2;t<e.length&&eL.test(e[t]);t++)o.push(tL(e[t])),a=t;let s=fN(),c=fM();for(let e of i){let t=sM(rM.ROW),n=on();n.append(te(e)),t.append(n),c.append(t)}s.append(c);for(let e of o){let t=fM();for(let n=0;n<i.length;n++){let r=sM(rM.NO_STATUS),i=on();i.append(te(e[n]??``)),r.append(i),t.append(r)}s.append(t)}return t.append(s),[!0,a]},regExpEnd:{optional:!0,regExp:eL},regExpStart:eL,replace:()=>{},type:`multiline-element`},kAe,sje,...kI.filter(e=>e!==TI&&e!==EI)];function pje(e){let t=e.getData(`vscode-editor-data`);if(!t)return null;try{return{language:JSON.parse(t).mode||`text`}}catch{return null}}function mje(e){let t=e.getData(`text/html`);return!t||/data-vscode|vscode-/i.test(t)?!1:new DOMParser().parseFromString(t,`text/html`).body.querySelectorAll(`strong,em,b,i,h1,h2,h3,h4,h5,h6,ul,ol,table,img,blockquote,pre>code,a[href]`).length>0}function hje(e){let t=0;return/^#{1,6}\s+\S/m.test(e)&&(t+=5),/^```[\w-]*$/m.test(e)&&(t+=5),/\[[^\]]+\]\([^)]+\)/.test(e)&&(t+=4),/!\[[^\]]*\]\([^)]+\)/.test(e)&&(t+=5),/^\|.+\|$/m.test(e)&&/^\|[\s:|-]+\|$/m.test(e)&&(t+=5),/^>\s*\[!(?:note|tip|warning|caution|important)\]/im.test(e)&&(t+=5),/^[*-]\s+\[[ x]\]/m.test(e)&&(t+=4),/\*\*.+?\*\*/.test(e)&&(t+=2),/(?<!\*)\*(?!\*)(?!\s).+?(?<!\s)(?<!\*)\*(?!\*)/.test(e)&&(t+=1),/^[*+-]\s+\S/m.test(e)&&(t+=1),/^\d+\.\s+\S/m.test(e)&&(t+=1),/^>\s+\S/m.test(e)&&(t+=1),/`.+?`/.test(e)&&(t+=1),/^[*_-]{3,}$/m.test(e)&&(t+=2),e.split(/\n{2,}/).filter(Boolean).length>=2&&(t+=5),e.length<20&&(t-=3),e.includes(`
|
|
193
|
-
`)||(t-=2),t>=5}function gje(e){let t=null,n=qn({namespace:`markdown-paste-temp`,nodes:jF(),onError:e=>{t=e}});if(n.update(()=>{sAe(e,nL)},{discrete:!0}),t)return console.error(`MarkdownPastePlugin: convertAndInsert error`,t),!1;let r=n.getEditorState().toJSON().root.children;if(!r.length)return!1;let i=r.map(e=>Ne(e));return Un(i),!0}function _je(){let[e]=ht();return(0,G.useEffect)(()=>e.registerCommand(or,e=>{let t=`clipboardData`in e?e.clipboardData:null;if(!t||t.getData(`application/x-lexical-editor`)||Array.from(t.files).some(e=>e.type.startsWith(`image/`)))return!1;let n=pje(t);if(n){let r=t.getData(`text/plain`);if(r){let t=r.split(/\r?\n{3,}/).filter(Boolean).map(e=>ike(e.replace(/^\s*\n/,``).replace(/\n\s*$/,``),n.language));return Un(t),e.preventDefault(),!0}}if(mje(t))return!1;let r=t.getData(`text/plain`);if(!r||!hje(r))return!1;try{return gje(r)?(e.preventDefault(),!0):!1}catch(e){return console.error(`MarkdownPastePlugin: paste error`,e),!1}},3),[e]),null}function vje(){return(0,K.jsx)(NAe,{transformers:nL})}function yje(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Lt,{}),(0,K.jsx)(qt,{}),(0,K.jsx)(dF,{}),(0,K.jsx)(Eke,{}),(0,K.jsx)(uF,{hasHorizontalScroll:!0}),(0,K.jsx)(Tke,{}),(0,K.jsx)(vje,{}),(0,K.jsx)(JAe,{}),(0,K.jsx)(_je,{}),(0,K.jsx)(LAe,{}),(0,K.jsx)(zAe,{}),(0,K.jsx)(HAe,{}),(0,K.jsx)(FAe,{})]})}var bje=(0,G.createContext)(null);function xje({upload:e,children:t}){return(0,K.jsx)(bje.Provider,{value:e,children:t})}var rL=(0,G.createContext)(null);function Sje({children:e}){let t=(0,G.useRef)(null),n=(0,G.useMemo)(()=>({ref:t,register:e=>(t.current=e,()=>{t.current===e&&(t.current=null)})}),[]);return(0,K.jsx)(rL.Provider,{value:n,children:e})}function iL(){return(0,G.use)(rL)}var aL=(0,G.createContext)(null);function Cje({upload:e,children:t}){return(0,K.jsx)(aL.Provider,{value:e,children:t})}function wje(){return(0,G.use)(aL)}var Tje=(0,G.createContext)(null);function Eje({upload:e,children:t}){return(0,K.jsx)(Tje.Provider,{value:e,children:t})}var oL=new WeakMap;function Dje(e){let t=oL.get(e);return t||(t={entries:new Map,listeners:new Set},oL.set(e,t)),t}function sL(e,t,n){let r=Dje(e);n?r.entries.set(t,n):r.entries.delete(t);for(let e of r.listeners)e()}function cL(e){return e.type.startsWith(`image/`)||e.type.startsWith(`video/`)}function Oje({onUpload:e}){let t=$k(),n=(0,G.useRef)(t);n.current=t;let[r]=ht(),i=(0,G.useRef)(e);i.current=e;let a=(0,G.useRef)(r),o=(0,G.useRef)(null),s=(0,G.useCallback)((e,t)=>{let r=``;t.update(()=>{let t=JP({src:``,name:e.name,size:e.size,mimeType:e.type||void 0,ext:FOe(e.name)});Un([t]),r=t.getKey()});let a=()=>{sL(t,r,null),t.update(()=>{let e=Dn(r);e&&e.remove()})},o=async()=>{let s=n.current?.retain(),c={percent:0,retry:()=>void o(),remove:a};sL(t,r,{...c,status:`uploading`});try{let n=await i.current(e,{onProgress:e=>{sL(t,r,{...c,status:`uploading`,percent:Math.round(e)})}});t.update(()=>{let e=Dn(r);IOe(e)&&e.setSrc(n.src)}),sL(t,r,null)}catch(e){console.error(`[FileUploadPlugin]`,e),sL(t,r,{...c,status:`error`,error:`Upload failed`})}finally{queueMicrotask(()=>s?.())}};o()},[]),c=(0,G.useCallback)((e,t)=>{let n=e.filter(e=>!cL(e));if(n.length===0)return!1;for(let e of n)s(e,t);return n.length===e.length},[s]);return(0,G.useEffect)(()=>{let e=r.registerCommand(yt,(e,t)=>c(e,t),1),t=r.registerCommand(or,(e,t)=>{let n=`clipboardData`in e?e.clipboardData:null;if(!n)return!1;let r=[...n.files];return r.some(e=>!cL(e))?c(r,t):!1},1),n=r.registerCommand(SN,(e,t)=>(a.current=t,o.current?.click(),!0),0);return()=>{e(),t(),n()}},[r,c]),(0,K.jsx)(`input`,{multiple:!0,ref:o,style:{display:`none`},type:`file`,onChange:e=>{let t=[...e.currentTarget.files??[]];for(let e of t)s(e,a.current);e.currentTarget.value=``}})}async function lL(e,t,n){if(!n||e.length===0)return e;try{return await n(e,{source:t})??[]}catch(t){return console.error(`[ImageUploadPlugin] preprocess failed, uploading originals`,t),e}}var kje=`PNG, JPG, GIF, WebP, AVIF`,Aje=/^(?:javascript\s*:|vbscript\s*:|data\s*:(?!image\/))/i,jje=new Set([`image/gif`,`image/svg+xml`]);function uL(e){return e.type.startsWith(`image/`)}function Mje(e){return!Aje.test(e)}function dL(e){return!jje.has(e.type)}function Nje(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Pje(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>{t({width:r.naturalWidth||r.width,height:r.naturalHeight||r.height})},r.onerror=()=>n(Error(`Failed to load image`)),r.src=e})}function fL(e){try{let{pathname:t}=new URL(e);return decodeURIComponent(t.split(`/`).pop()||``)||e}catch{return e}}function pL(e,t){if(e===`replace`)return{action:`Replace`,title:`Replace image`};let n=t>1?`Insert ${t} images`:`Insert image`;return{action:n,title:n}}async function Fje(e,t){let n=[];return{entries:(await Promise.all(e.map(async e=>{if(e.kind===`url`)return{height:e.height,kind:`url`,src:e.src,width:e.width};if(e.current!==e.original||!e.removeGps||!e.gps)return{file:e.current,kind:`file`};try{if(!t)throw Error(`No GPS stripper configured`);return{file:await t(e.original),kind:`file`}}catch{return n.push(e.id),null}}))).filter(e=>e!==null),failedIds:n}}var mL=new WeakSet;function Ije(e){return mL.add(e),e}function Lje(e){return mL.has(e)}var Rje=new WeakMap;function hL(e){return(e&&Rje.get(e))??null}var gL=`rich-image-upload-dragging`,zje=6e3;function _L(e,t,n){return e>1?n.replace(`#`,String(e)):t}async function Bje(e,t){let n=async e=>{let r=Pe({title:_L(e.length,`Uploading image…`,`Uploading # images…`),tone:`loading`}),i=await t(e);i.length===0?Et(r,{title:_L(e.length,`Image inserted`,`Inserted # images`),tone:`success`}):Et(r,{action:{label:`Retry`,onClick:()=>void n(i)},duration:zje,title:_L(i.length,`Image upload failed`,`# images failed to upload`),tone:`error`})};await n(e)}function Vje(e){if(Jn(e)){let t=e.isBackward()?e.anchor:e.focus;return{kind:`point`,key:t.key,offset:t.offset,type:t.type}}if(Ue(e)){let t=e.getNodes().at(-1);if(t)return{kind:`after`,key:t.getKey()}}return null}function vL(){let e=kr();return{callerMoved:!1,expected:e?.clone()??null,point:Vje(e)}}function yL(e,t){return e===t?vL():t.getEditorState().read(vL)}function bL(e,t){let n=Dn(e);return n?.isAttached()?t===`text`?it(n)?n.getTextContentSize():null:rr(n)?n.getChildrenSize():null:null}function Hje(e){if(!e)return null;let t=e.key,n,r=`element`;if(e.kind===`after`){let r=Dn(e.key),i=r?.isAttached()?r.getParent():null;if(!r||!i)return null;t=i.getKey(),n=r.getIndexWithinParent()+1}else{let t=bL(e.key,e.type);if(t===null)return null;n=Math.min(e.offset,t),r=e.type}let i=zt();return i.anchor.set(t,n,r),i.focus.set(t,n,r),i}function xL(e){let t=bL(e.key,e.type);return t!==null&&e.offset<=t}function Uje(e){return Jn(e)?xL(e.anchor)&&xL(e.focus):e.getNodes().every(e=>e.isAttached())}function SL(e,t){if(t.length===0)return;let n=Hje(e.point),r=kr(),i=(e.callerMoved||(r===null?e.expected!==null:!r.is(e.expected)))&&r?r.clone():null;n&&Jt(n),Un(t),i&&Uje(i)&&(Jt(i),e.callerMoved=!0),e.expected=kr()?.clone()??null,e.point={kind:`after`,key:t.at(-1).getKey()}}var Wje=`dtt1x70`,Gje=`dtt1x71`,Kje=`dtt1x72`,qje=`dtt1x73`,CL=`dtt1x75 dtt1x74`,Jje=`dtt1x76 dtt1x75 dtt1x74`,Yje=`dtt1x77`,Xje=`dtt1x78`,Zje=`dtt1x79`,Qje=`dtt1x7a`,$je=`dtt1x7b dtt1x74`,eMe=`dtt1x7g`,wL=`dtt1x7h`,tMe=`dtt1x7i`,TL=`dtt1x7j`,EL=`dtt1x7k`,nMe=`dtt1x7l`,DL=`dtt1x7m`,OL=`dtt1x7o dtt1x74`;function rMe(e){let[t,n]=(0,G.useState)(null),[r,i]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{if(typeof URL.createObjectURL!=`function`)return;let t=URL.createObjectURL(e),r=!0;i(!1);let a=new Image;return a.onload=()=>{r&&n({height:a.naturalHeight,url:t,width:a.naturalWidth})},a.onerror=()=>{r&&i(!0)},a.src=t,()=>{r=!1,URL.revokeObjectURL(t)}},[e]),{failed:r,info:t}}function kL({editLabel:e=`Edit`,name:t,onEdit:n,onRemove:r}){return(0,K.jsxs)(K.Fragment,{children:[n&&(0,K.jsxs)(Fe,{size:`sm`,variant:`outline`,onClick:n,children:[(0,K.jsx)(Ae,{"aria-hidden":!0,size:14}),e]}),(0,K.jsx)(Fe,{icon:!0,"aria-label":`Remove ${t}`,size:`sm`,title:`Remove`,onClick:r,children:(0,K.jsx)(k,{"aria-hidden":!0,size:16})})]})}function iMe({canEdit:e,failed:t,onEdit:n,onRemove:r,onToggleGps:i,row:a}){let{failed:o,info:s}=rMe(a.current),c=a.current!==a.original,l=e&&dL(a.current)&&!o,u=a.current.type.replace(`image/`,``).toUpperCase(),d=[c&&a.summary||null,s?`${s.width} × ${s.height}`:null,Nje(a.current.size),c?null:u||null].filter(Boolean).join(` · `);return(0,K.jsxs)(`div`,{className:t?`${wL} ${tMe}`:wL,"data-image-dialog-row":``,children:[s?(0,K.jsx)(`img`,{alt:``,className:TL,src:s.url}):(0,K.jsx)(`div`,{className:TL}),(0,K.jsxs)(`div`,{className:EL,children:[(0,K.jsxs)(`div`,{className:nMe,children:[(0,K.jsx)(`span`,{className:DL,title:a.original.name,children:a.original.name}),c&&(0,K.jsx)(`span`,{className:`dtt1x7n`,children:`Edited`})]}),(0,K.jsx)(`span`,{className:OL,children:d}),e&&!dL(a.current)&&(0,K.jsx)(`span`,{className:`dtt1x7o dtt1x74`,children:`Animated or vector — editing would flatten it`}),!c&&a.gps&&(0,K.jsx)(`div`,{className:`dtt1x7p`,children:(0,K.jsx)(Xe,{checked:a.removeGps,label:`Remove GPS before upload`,onChange:i})}),t&&(0,K.jsx)(`span`,{className:`dtt1x7q dtt1x74`,children:`Could not remove location from this image`})]}),(0,K.jsx)(kL,{editLabel:c?`Re-edit`:`Edit`,name:a.original.name,onEdit:l?n:void 0,onRemove:r})]})}function aMe({canAddMore:e,canEdit:t,failedIds:n,onAddMore:r,onEdit:i,onRemove:a,onToggleGps:o,rows:s}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:eMe,children:s.map(e=>e.kind===`file`?(0,K.jsx)(iMe,{canEdit:t,failed:e.removeGps&&n.includes(e.id),row:e,onEdit:()=>i(e),onRemove:()=>a(e.id),onToggleGps:t=>o(e.id,t)},e.id):(0,K.jsxs)(`div`,{className:wL,"data-image-dialog-row":``,children:[(0,K.jsx)(`img`,{alt:``,className:TL,src:e.src}),(0,K.jsxs)(`div`,{className:EL,children:[(0,K.jsx)(`span`,{className:DL,title:e.src,children:fL(e.src)}),(0,K.jsxs)(`span`,{className:OL,children:[e.width,` × `,e.height,` · from link`]})]}),(0,K.jsx)(kL,{name:fL(e.src),onRemove:()=>a(e.id)})]},e.id))}),e&&(0,K.jsxs)(Fe,{className:`dtt1x7r`,size:`md`,variant:`ghost`,onClick:r,children:[(0,K.jsx)(zr,{"aria-hidden":!0,size:14}),`Add more`]})]})}var oMe=300;function sMe(e){return e?[...e.files].some(uL)?!0:[...e.items].some(e=>e.type.startsWith(`image/`)):!1}function cMe(e){let[t,n]=(0,G.useState)({status:`idle`});return(0,G.useEffect)(()=>{let t=e.trim();if(!t){n({status:`idle`});return}if(!Mje(t)){n({message:`Unsupported URL scheme`,status:`error`});return}n({status:`loading`});let r=!0,i=setTimeout(()=>{Pje(t).then(({height:e,width:t})=>{r&&n({height:e,status:`loaded`,width:t})},()=>{r&&n({message:`Could not load this image URL`,status:`error`})})},oMe);return()=>{r=!1,clearTimeout(i)}},[e]),t}function lMe({allowUrl:e,onAddUrl:t,onPickFiles:n,onReceiveFiles:r}){let i=(0,G.useId)(),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``),l=cMe(s),u=s.trim(),d=()=>{l.status===`loaded`&&(t({height:l.height,src:u,width:l.width}),c(``))},f=e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},p=e=>{sMe(e.dataTransfer)&&(e.preventDefault(),o(!0))},m=e=>{e.preventDefault(),o(!1);let t=[...e.dataTransfer.files].filter(uL);t.length>0&&r(t)},h=l.status===`loaded`?`Loaded · ${l.width} × ${l.height}`:l.status===`loading`?`Loading preview…`:void 0;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{"aria-label":`Drop images here or choose files`,className:Xje,"data-drag-active":a||void 0,role:`button`,tabIndex:0,onDragEnter:p,onDragLeave:()=>o(!1),onDragOver:p,onDrop:m,onKeyDown:f,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:Zje,children:(0,K.jsx)(fne,{size:18})}),(0,K.jsx)(`span`,{className:Qje,children:`Drop images here`}),(0,K.jsx)(Fe,{size:`md`,tabIndex:-1,variant:`outline`,onClick:n,children:`Choose files`}),(0,K.jsxs)(`span`,{className:$je,children:[`or press `,(0,K.jsx)(ar,{keys:[`mod`,`v`],size:`sm`}),` to paste`]})]}),e&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`dtt1x7c dtt1x74`,children:`or from a link`}),(0,K.jsx)(Kn,{error:l.status===`error`?l.message:void 0,hint:h,id:i,label:`Image URL`,children:(0,K.jsxs)(`div`,{className:`dtt1x7d`,children:[(0,K.jsx)(ct,{className:`dtt1x7e`,id:i,invalid:l.status===`error`,placeholder:`https://example.com/image.jpg`,type:`url`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d())}}),l.status===`loaded`&&(0,K.jsx)(`img`,{alt:``,className:`dtt1x7f`,src:u}),(0,K.jsx)(Fe,{disabled:l.status!==`loaded`,size:`md`,variant:`solid`,onClick:d,children:`Add`})]})})]})]})}var AL=0;function jL(e){return{current:e,gps:null,id:`image-row-${++AL}`,kind:`file`,original:e,removeGps:!0,summary:``}}function uMe(e,t){let n=(e??[]).filter(uL);return(t===`replace`?n.slice(0,1):n).map(jL)}function ML(e,t){return e.map(e=>e.kind===`file`&&t.has(e.id)?{...e,gps:t.get(e.id)??null}:e)}function dMe({allowUrl:e=!0,editor:t=null,initialFiles:n,mode:r=`insert`,onCancel:i,onDirtyChange:a,onSubmit:o,onTitleChange:s}){let c=!!n?.some(uL),[l,u]=(0,G.useState)(()=>uMe(n,r)),[d,f]=(0,G.useState)(c?`review`:`source`),[p,m]=(0,G.useState)([]),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(!1),y=(0,G.useRef)(null),b=(0,G.useRef)(new Map),x=t?.privacy,S=pL(r,d===`review`?l.length:1),C=l.some(e=>e.kind===`file`&&e.current!==e.original)||!c&&l.length>0;(0,G.useEffect)(()=>{s?.(S.title)},[S.title,s]),(0,G.useEffect)(()=>{a?.(C)},[C,a]),(0,G.useEffect)(()=>{if(x)for(let e of l){if(e.kind!==`file`||b.current.has(e.id))continue;let t=x.detectGps(e.original).catch(()=>null);b.current.set(e.id,t),t.then(t=>{u(n=>ML(n,new Map([[e.id,t]])))})}},[x,l]);let w=e=>{let t=e.filter(uL);t.length!==0&&(m([]),u(e=>r===`replace`?[jL(t[0])]:[...e,...t.map(jL)]),f(`review`))},T=e=>{let t={...e,id:`image-row-${++AL}`,kind:`url`};u(e=>r===`replace`?[t]:[...e,t]),f(`review`)},E=e=>{let t=l.filter(t=>t.id!==e);u(t),t.length>0||(c?i():f(`source`))},D=async e=>{if(!t)return;let n=await t.edit(e.current);n&&n.file!==e.current&&u(t=>t.map(t=>t.id===e.id&&t.kind===`file`?{...t,current:n.file,summary:[t.summary,n.summary].filter(Boolean).join(` · `)}:t))},O=(e,t)=>{u(n=>n.map(n=>n.id===e&&n.kind===`file`?{...n,removeGps:t}:n))},k=p.some(e=>l.some(t=>t.id===e&&t.kind===`file`&&t.removeGps&&t.gps&&t.current===t.original)),A=async()=>{if(h||k||l.length===0)return;g(!0);let e=[...b.current.keys()],t=await Promise.all(e.map(e=>b.current.get(e))),n=ML(l,new Map(e.map((e,n)=>[e,t[n]]))),r=await Fje(n,x?.stripGps);if(g(!1),r.failedIds.length>0)u(n),m(r.failedIds);else{if(_)for(let e of r.entries)e.kind===`file`&&Ije(e.file);o(r.entries)}},j=e=>{d===`review`&&e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),A())},M=e=>{let t=[...e.clipboardData?.files??[]].filter(uL);t.length!==0&&(e.preventDefault(),w(t))},N=()=>y.current?.click();return(0,K.jsxs)(`div`,{className:Gje,onKeyDown:j,onPaste:M,children:[(0,K.jsx)(`input`,{accept:`image/*`,className:Yje,multiple:r!==`replace`,ref:y,type:`file`,onChange:e=>{w([...e.currentTarget.files??[]]),e.currentTarget.value=``}}),(0,K.jsxs)(`div`,{className:Kje,children:[d===`source`?(0,K.jsx)(lMe,{allowUrl:e,onAddUrl:T,onPickFiles:N,onReceiveFiles:w}):(0,K.jsx)(aMe,{canAddMore:r!==`replace`,canEdit:!!t,failedIds:p,rows:l,onAddMore:N,onEdit:e=>void D(e),onRemove:E,onToggleGps:O}),d===`review`&&t?.allowKeepOriginal&&l.some(e=>e.kind===`file`)&&(0,K.jsx)(`div`,{className:`dtt1x7s`,children:(0,K.jsx)(Xe,{checked:_,label:`Keep original (skip compression)`,onChange:v})})]}),(0,K.jsx)(`div`,{className:qje,children:d===`source`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:CL,children:kje}),l.length>0&&(0,K.jsx)(Fe,{size:`md`,variant:`outline`,onClick:()=>f(`review`),children:`Continue`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:k?Jje:CL,children:k?`Keep the location or remove the flagged images to continue`:`Nothing is uploaded until you insert`}),c?(0,K.jsx)(Fe,{size:`md`,variant:`outline`,onClick:i,children:`Cancel`}):(0,K.jsx)(Fe,{size:`md`,variant:`outline`,onClick:()=>f(`source`),children:`Back`}),(0,K.jsxs)(Fe,{autoFocus:!0,disabled:h||k,size:`md`,variant:`solid`,onClick:()=>void A(),children:[S.action,(0,K.jsx)(ar,{keys:[`mod`,`enter`],size:`sm`,tone:`inverted`})]})]})})]})}function fMe(e){let t=e,n=new Set;return{get:()=>t,set:e=>{if(e!==t){t=e;for(let e of n)e()}},subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function pMe({store:e}){return(0,G.useSyncExternalStore)(e.subscribe,e.get,e.get)}function NL({allowUrl:e=!0,editor:t=null,files:n,mode:r=`insert`,portalClassName:i,theme:a}={}){return new Promise(o=>{let s=!1,c=e=>{s||(s=!0,o(e))},l=!1,u=e=>{l=e},d=fMe(pL(r,n?.length??1).title);At({className:Wje,confirmDismiss:()=>!l||Se(),onClose:()=>c(null),portalClassName:i,sheet:`auto`,theme:a,title:(0,K.jsx)(pMe,{store:d}),width:520,content:({dismiss:i,requestDismiss:a})=>(0,K.jsx)(dMe,{allowUrl:e,editor:t,initialFiles:n,mode:r,onCancel:()=>void a(),onDirtyChange:u,onTitleChange:d.set,onSubmit:e=>{c(e),i()}})})})}function PL(e,t){return Lje(t)?e(t,{keepOriginal:!0}):e(t)}function FL(e){return e?[...e.files].some(uL)?!0:[...e.items].some(e=>e.type.startsWith(`image/`)):!1}function mMe(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error??Error(`File read failed`)),r.readAsDataURL(e)})}async function IL(e){return{src:await mMe(e),altText:e.name}}function hMe({onUpload:e}){let t=$k(),n=(0,G.useRef)(t);n.current=t;let[r]=ht(),i=(0,G.useRef)(e);i.current=e;let a=iL(),o=(0,G.useRef)(a);o.current=a;let s=We(),c=(0,G.useRef)(s);c.current=s;let l=(0,G.useCallback)(async(e,t,r,a)=>{let o=n.current?.retain();try{let[n,o]=await Promise.all([PL(i.current,e),Qj(e)]);await a,t.update(()=>{SL(r,[WN(RN({src:n.src,altText:n.altText??e.name,width:n.width??o.width,height:n.height??o.height,thumbhash:n.thumbhash??o.thumbhash}))])})}finally{queueMicrotask(()=>o?.())}},[]),u=(0,G.useCallback)((e,t,n)=>Bje(e,async e=>{let r=Promise.resolve(),i=e.map(e=>{let i=l(e,t,n,r.catch(()=>{}));return r=i,i}),a=await Promise.allSettled(i);return e.filter((e,t)=>{let n=a[t];return n.status!==`fulfilled`&&(console.error(`[ImageUploadPlugin]`,n.reason),!0)})}),[l]),d=(0,G.useCallback)((e,t,i)=>{let a=e.filter(uL);if(a.length===0)return!1;let s=yL(r,i);return(async()=>{let e=n.current?.retain();try{let e=o.current?.ref.current??null,n=await lL(a,t,e);n.length>0&&await u(n,i,s)}finally{queueMicrotask(()=>e?.())}})(),!0},[r,u]),f=(0,G.useCallback)(async(e,t)=>{let r=n.current?.retain();try{let n=o.current,r=hL(n),i=await NL({editor:r,portalClassName:c.current.className,theme:c.current.theme});if(!i)return;let a=i.flatMap(e=>e.kind===`url`?[e]:[]);a.length>0&&e.update(()=>{SL(t,a.map(e=>WN(RN({src:e.src,altText:``,width:e.width,height:e.height}))))});let s=i.flatMap(e=>e.kind===`file`?[e.file]:[]),l=r?s:await lL(s,`dialog`,n?.ref.current??null);l.length>0&&await u(l,e,t)}finally{queueMicrotask(()=>r?.())}},[u]);return(0,G.useEffect)(()=>{let e=r.registerCommand(yt,(e,t)=>d(e,`drop`,t),3),t=r.registerCommand(or,(e,t)=>{let n=`clipboardData`in e?e.clipboardData:null;if(!n)return!1;let r=[...n.files];return r.some(uL)?d(r,`paste`,t):!1},3),n=r.registerCommand(LN,(e,t)=>(f(t,yL(r,t)),!0),0),i=r.getRootElement(),a=i?.parentElement??null;if(!i||!a)return()=>{e(),t(),n()};let o=0,s=e=>{FL(e.dataTransfer)&&(o+=1,a.classList.add(gL))},c=e=>{FL(e.dataTransfer)&&e.preventDefault()},l=()=>{o=Math.max(o-1,0),o===0&&a.classList.remove(gL)},u=()=>{o=0,a.classList.remove(gL)};return i.addEventListener(`dragenter`,s),i.addEventListener(`dragover`,c),i.addEventListener(`dragleave`,l),i.addEventListener(`drop`,u),()=>{e(),t(),n(),a.classList.remove(gL),i.removeEventListener(`dragenter`,s),i.removeEventListener(`dragover`,c),i.removeEventListener(`dragleave`,l),i.removeEventListener(`drop`,u)}},[r,d,f]),null}function gMe(e,t){if(e.dataset.faviconHref===t)return;e.dataset.faviconHref=t;let n=NF(t);n&&PF(n).then(t=>{t&&(e.style.setProperty(`--rc-link-favicon`,`url(${t})`),e.dataset.favicon=`loaded`)})}function _Me(){let[e]=ht();return(0,G.useEffect)(()=>{let t=t=>{for(let[n,r]of t){if(r===`destroyed`)continue;let t=e.getElementByKey(n);if(!t)continue;let i=t.getAttribute(`href`);i&&gMe(t,i)}},n=e.registerMutationListener(dr,t),r=e.registerMutationListener(Cn,t);return()=>{n(),r()}},[e]),null}function vMe(e,t){return e===t?!0:!e||!t?!1:e.text===t.text&&e.anchorBlockId===t.anchorBlockId&&e.anchorOffset===t.anchorOffset&&e.focusBlockId===t.focusBlockId&&e.focusOffset===t.focusOffset}function yMe(e={snapshot:null}){let t=e,n=new Set,r=()=>{for(let e of n)e()};return{getState:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)}),setSnapshot:e=>{vMe(t.snapshot,e)||(t={...t,snapshot:e},r())},clearSnapshot:()=>{t.snapshot!==null&&(t={...t,snapshot:null},r())}}}var LL=(0,G.createContext)(null);function bMe({children:e}){let t=(0,G.useRef)(null);return t.current||=yMe(),(0,K.jsx)(LL.Provider,{value:t.current,children:e})}function RL(){let e=(0,G.use)(LL);if(!e)throw Error(`useTextSelectionStore must be used within TextSelectionStoreProvider`);return e}function zL(){let e=RL();return(0,G.useSyncExternalStore)(e.subscribe,()=>e.getState().snapshot,()=>e.getState().snapshot)}function BL(e){let t=Sr(),n=e;for(;n;){let e=n.getParent();if(e===t&&`getChildren`in n)return n;n=e}return null}function VL(e,t){let n=e[t],r=n.getNode();if(rr(r)){let e=r.getChildren();if(n.offset<e.length)return{node:e[n.offset],offset:0};let t=e.at(-1);return t&&it(t)?{node:t,offset:t.getTextContentSize()}:{node:r,offset:0}}return{node:r,offset:n.offset}}function HL(e,t,n){let r=0;function i(e){if(e.is(t))return r+=n,!0;if(it(e))r+=e.getTextContentSize();else if(lr(e))r+=1;else if(rr(e)){for(let t of e.getChildren())if(i(t))return!0}return!1}for(let t of e.getChildren())if(i(t))break;return r}var UL=`rich-editor-text-selection`,WL=`rich-editor-text-selection-inactive`;function xMe(e,t){return Math.max(0,Math.min(e,t))}function GL(e){return e.tagName===`SUMMARY`&&e.parentElement?.tagName===`DETAILS`||e.getAttribute(`contenteditable`)===`false`}function KL(e){if(e.nodeType===Node.TEXT_NODE)return e.textContent?.length??0;if(e.nodeType!==Node.ELEMENT_NODE)return 0;let t=e;if(GL(t))return 0;if(t.tagName===`BR`)return 1;let n=0;for(let t of e.childNodes)n+=KL(t);return n}function SMe(e,t){if(e===t)return 0;let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0}function CMe(e){if(!e.length)return null;let t=e[0].left,n=e[0].top,r=e[0].right,i=e[0].bottom;for(let a of e.slice(1))t=Math.min(t,a.left),n=Math.min(n,a.top),r=Math.max(r,a.right),i=Math.max(i,a.bottom);return new DOMRect(t,n,r-t,i-n)}function wMe(e){if(e.isCollapsed())return null;let t=BL(e.anchor.getNode()),n=BL(e.focus.getNode());if(!t||!n)return null;let r=Hn(t,rA),i=Hn(n,rA);if(!r||!i)return null;let a=VL(e,`anchor`),o=VL(e,`focus`);return{text:e.getTextContent(),anchorBlockId:r,anchorOffset:HL(t,a.node,a.offset),focusBlockId:i,focusOffset:HL(n,o.node,o.offset)}}function TMe(){let e=kr();return Jn(e)?wMe(e):null}function qL(e,t,n=`backward`){let r=xMe(t,KL(e)),i=0;function a(e){if(e.nodeType===Node.TEXT_NODE){let t=e.textContent?.length??0;return(n===`forward`?r<i+t:r<=i+t)?{node:e,offset:r-i}:(i+=t,null)}if(e.nodeType!==Node.ELEMENT_NODE)return null;let t=e;if(GL(t))return null;if(t.tagName===`BR`){let e=t.parentNode;if(!e)return null;let n=Array.from(e.childNodes).indexOf(t);return r===i?{node:e,offset:n}:r===i+1?{node:e,offset:n+1}:(i+=1,null)}for(let t of e.childNodes){let e=a(t);if(e)return e}return null}return a(e)??{node:e,offset:e.childNodes.length}}function JL(e,t){return e.querySelector(`[data-block-id="${t}"]`)}function YL(e,t){let n=JL(e,t.anchorBlockId),r=JL(e,t.focusBlockId);if(!n||!r)return null;let i=n===r?t.anchorOffset<=t.focusOffset:SMe(n,r)<=0,a=i?qL(n,t.anchorOffset,`forward`):qL(r,t.focusOffset,`forward`),o=i?qL(r,t.focusOffset):qL(n,t.anchorOffset);if(!a||!o)return null;try{let e=document.createRange();return e.setStart(a.node,a.offset),e.setEnd(o.node,o.offset),e}catch{return null}}function EMe(e,t){let n=YL(e,t);if(!n)return null;let r=n.getBoundingClientRect();return r.width>0||r.height>0?r:CMe(Array.from(n.getClientRects()))}var XL=`gr1ebt0`,ZL=`gr1ebt1`,QL=`gr1ebt2`,$L=null,eR=[XL,ZL,QL];function tR(){return typeof CSS>`u`||!(`highlights`in CSS)||typeof Highlight>`u`?null:CSS.highlights}function nR(e){if(e&&e!==$L){e.classList.remove(...eR);return}let t=tR();t?.delete(UL),t?.delete(WL),$L?.classList.remove(...eR),$L=null}function DMe(){let[e]=ht(),t=RL(),n=zL(),[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(!1),s=(0,G.useRef)(null),c=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let n=()=>{if(!e.getRootElement()){t.clearSnapshot();return}let n=e.getEditorState().read(()=>TMe());t.setSnapshot(n)},r=()=>{let t=e.getRootElement(),n=t?.ownerDocument.activeElement;i(!!(t&&n&&t.contains(n))),o(!!(t&&n===t))},a=()=>{c.current!==null&&cancelAnimationFrame(c.current),c.current=requestAnimationFrame(()=>{c.current=null,r()})},s=e.registerCommand(mn,()=>(n(),!1),1),l=e.registerUpdateListener(()=>{n()}),u=e.getRootElement();if(u){let e=e=>{let r=e.target;if(!r)return;let i=r.closest(`[contenteditable="true"]`);i&&i!==u?(t.clearSnapshot(),a()):(a(),n())},i=()=>{a(),n()};return u.addEventListener(`focusin`,e),u.addEventListener(`focusout`,i),r(),n(),()=>{s(),l(),c.current!==null&&(cancelAnimationFrame(c.current),c.current=null),u.removeEventListener(`focusin`,e),u.removeEventListener(`focusout`,i),t.clearSnapshot()}}return r(),n(),()=>{s(),l(),c.current!==null&&(cancelAnimationFrame(c.current),c.current=null),t.clearSnapshot()}},[e,t]),(0,G.useEffect)(()=>{let t=tR(),i=()=>{s.current!==null&&(cancelAnimationFrame(s.current),s.current=null)};return i(),s.current=requestAnimationFrame(()=>{s.current=null;let i=e.getRootElement();if(!i){nR();return}if(!n){let e=i.ownerDocument.getSelection();if(a&&(!e||e.isCollapsed)){$L===i&&(t?.delete(UL),t?.delete(WL));return}nR(i);return}$L&&$L!==i&&$L.classList.remove(...eR);let o=t?YL(i,n):null;if(t&&!o){nR(i);return}let c=o?QL:r?XL:ZL;if(i.classList.remove(...eR.filter(e=>e!==c)),i.classList.add(c),$L=i,!t||!o)return;let l=r?UL:WL,u=r?WL:UL;t.delete(u),t.set(l,new Highlight(o))}),i},[e,r,a,n]),(0,G.useEffect)(()=>()=>nR(e.getRootElement()),[e]),null}function rR(e){return e.type.startsWith(`video/`)}function iR(e){return e?[...e.files].some(rR)?!0:[...e.items].some(e=>e.type.startsWith(`video/`)):!1}var OMe=6e3;function kMe({onUpload:e}){let t=$k(),n=(0,G.useRef)(t);n.current=t;let[r]=ht(),i=(0,G.useRef)(e);i.current=e;let a=(0,G.useCallback)(async(e,t)=>{let o=n.current?.retain(),s=Pe({title:`Uploading video…`,tone:`loading`});try{let n=await i.current(e,{onProgress:e=>{Et(s,{title:`Uploading video… ${Math.round(e)}%`})}});r.update(()=>{SL(t,[aF({src:n.src})])}),Et(s,{title:`Video uploaded`,tone:`success`})}catch(n){console.error(`[VideoUploadPlugin]`,n),Et(s,{action:{label:`Retry`,onClick:()=>void a(e,t)},duration:OMe,title:`Video upload failed`,tone:`error`})}finally{queueMicrotask(()=>o?.())}},[r]),o=(0,G.useCallback)(e=>{let t=e.filter(rR);if(t.length===0)return!1;let n=vL();for(let e of t)a(e,n);return t.length===e.length},[a]);return(0,G.useEffect)(()=>{let e=r.registerCommand(yt,e=>o(e),4),t=r.registerCommand(or,e=>{let t=`clipboardData`in e?e.clipboardData:null;if(!t)return!1;let n=[...t.files];return n.some(rR)?o(n):!1},4),n=r.getRootElement(),i=n?.parentElement??null;if(!n||!i)return()=>{e(),t()};let a=0,s=e=>{iR(e.dataTransfer)&&(a+=1,i.classList.add(gL))},c=e=>{iR(e.dataTransfer)&&e.preventDefault()},l=()=>{a=Math.max(a-1,0),a===0&&i.classList.remove(gL)},u=()=>{a=0,i.classList.remove(gL)};return n.addEventListener(`dragenter`,s),n.addEventListener(`dragover`,c),n.addEventListener(`dragleave`,l),n.addEventListener(`drop`,u),()=>{e(),t(),i.classList.remove(gL),n.removeEventListener(`dragenter`,s),n.removeEventListener(`dragover`,c),n.removeEventListener(`dragleave`,l),n.removeEventListener(`drop`,u)}},[r,o]),null}function AMe({onEditorReady:e}){let[t]=ht(),n=(0,G.useRef)(e);return n.current=e,(0,G.useEffect)(()=>(n.current?.(t),()=>n.current?.(null)),[t]),null}function aR(e,t){if(e===t)return!0;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>n in t&&e[n]===t[n])}function jMe({children:e}){let[t]=ht(),[n,r]=(0,G.useState)({}),[i,a]=(0,G.useState)({}),o=(0,G.useRef)(!1);return(0,G.useEffect)(()=>t.registerUpdateListener(({editorState:e})=>{e.read(()=>{let e=xn(CN),n=new Set,i={},s=1;for(let t of e){let e=t.getIdentifier();n.has(e)||(n.add(e),i[e]=s++)}a(e=>aR(e,i)?e:i);let c=xn(YP),l=c.length>0?c[0].getDefinitions():{};if(r(e=>aR(e,l)?e:l),t.isEditable()&&!o.current){if(e.length===0&&c.length>0)o.current=!0,queueMicrotask(()=>{t.update(()=>{let e=xn(YP);for(let t of e)t.remove()}),o.current=!1});else if(e.length>0&&c.length===0){let e=[...n];o.current=!0,queueMicrotask(()=>{t.update(()=>{let t=Sr(),n={};for(let t of e)n[t]=``;let r=Ne({type:`footnote-section`,definitions:n,version:1});t.append(r)}),o.current=!1})}else if(c.length>0){let e=c[0].getDefinitions(),r=[...n].filter(t=>!(t in e)),i=Object.keys(e).filter(e=>!n.has(e));(r.length>0||i.length>0)&&(o.current=!0,queueMicrotask(()=>{t.update(()=>{let e=xn(YP);if(e.length>0){for(let t of r)e[0].setDefinition(t,``);for(let t of i)e[0].removeDefinition(t)}}),o.current=!1}))}}})}),[t]),(0,K.jsx)(Yj,{definitions:n,displayNumberMap:i,children:e})}function MMe({onChange:e,debounceMs:t}){let[n]=ht(),r=(0,G.useRef)(void 0),i=(0,G.useRef)(e);return i.current=e,(0,G.useEffect)(()=>{let e=n.registerUpdateListener(({editorState:e})=>{let n=i.current;if(!n)return;let a=zF(e.toJSON());t&&t>0?(clearTimeout(r.current),r.current=setTimeout(()=>{n(a)},t)):n(a)});return()=>{clearTimeout(r.current),e()}},[n,t]),null}function NMe({onSubmit:e}){let[t]=ht();return(0,G.useEffect)(()=>{if(e)return t.registerCommand(an,t=>t&&(t.metaKey||t.ctrlKey)?(t.preventDefault(),e(),!0):!1,3)},[t,e]),null}function PMe(){let[e]=ht();return(0,G.useEffect)(()=>{let t=e.getRootElement();t?t.focus({preventScroll:!0}):e.focus()},[e]),null}function FMe({href:e,source:t,noIcon:n=!1,className:r,platformIconMap:i,getPlatformFromUrl:a}){let o=Fj(Nj.linkFavicon,Pj.linkFavicon,r),[s,c]=(0,G.useState)(null);if((0,G.useEffect)(()=>{if(!e)return;let t=NF(e);if(!t)return;let n=!1;return PF(t).then(e=>{n||c(e)}),()=>{n=!0}},[e]),n||!e&&!t)return null;let l=t;if(!l&&e&&a)try{l=a(new URL(e))??void 0}catch{}if(l&&i?.[l])return(0,K.jsx)(`span`,{className:o,children:i[l]});if(s)return(0,K.jsx)(`span`,{className:o,children:(0,K.jsx)(`img`,{alt:``,"aria-hidden":`true`,height:14,src:s,width:14})});let u=e?.toLowerCase().startsWith(`mailto:`);return(0,K.jsx)(`span`,{className:o,children:u?(0,K.jsx)(zne,{"aria-hidden":!0,size:14}):(0,K.jsx)(D,{"aria-hidden":!0,size:14})})}var IMe=(0,G.createContext)(void 0);function LMe({children:e,extraNodes:t}){let n=(0,G.useMemo)(()=>t,[t]);return(0,K.jsx)(IMe.Provider,{value:n,children:e})}var RMe=Rn(`INSERT_ALERT`);function zMe(){let[e]=ht();return(0,G.useEffect)(()=>e.registerCommand(RMe,e=>(Un([gF(e)]),!0),0),[e]),null}var BMe=Rn(`INSERT_IMAGE_COMMAND`);function VMe(){let[e]=ht();return(0,G.useEffect)(()=>e.registerCommand(BMe,e=>{let t=WN(RN(e),{autoOpenOnMount:!e.src});return Un([t]),!0},0),[e]),null}var HMe=Rn(`INSERT_KATEX_INLINE`),UMe=Rn(`INSERT_KATEX_BLOCK`);function WMe(){let[e]=ht();return(0,G.useEffect)(()=>{let t=e.registerCommand(HMe,e=>{let t=QN(e,{autoOpenOnMount:!e.trim()});return Un([t]),!0},0),n=e.registerCommand(UMe,e=>{let t=YN(e,{autoOpenOnMount:!e.trim()});return Un([t]),!0},0);return()=>{t(),n()}},[e]),null}var GMe=Rn(`INSERT_MERMAID`);function KMe(){let[e]=ht();return(0,G.useEffect)(()=>e.registerCommand(GMe,e=>{let t=rP(e);return Un([t]),!0},0),[e]),null}var oR={inline:`rich-katex-inline`,block:`rich-katex-block`,fallback:`rich-katex-fallback`},sR={inline:`egstxq0`,block:`egstxq1`,fallback:`egstxq2`};function qMe({className:e,placeholder:t,hasHeader:n}){let r=n?40:12;return(0,K.jsx)(`div`,{className:Fj(`rich-editor__content-wrapper`,lA),style:{"--ce-padding-top":`${r}px`},children:(0,K.jsx)(Ee,{"aria-placeholder":t??``,className:Fj(`rich-editor__content`,uA,e),placeholder:(0,K.jsx)(`div`,{className:Fj(`rich-editor__placeholder`,bCe),style:{display:t?void 0:`none`},children:t})})})}function JMe({className:e,hasHeader:t,placeholder:n,plugins:r,autoFocus:i,onActiveEditorChange:a}){let[o]=ht();return(0,G.useLayoutEffect)(()=>(a(o),()=>a(null)),[o,a]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Yt,{ErrorBoundary:Nt,contentEditable:(0,K.jsx)(qMe,{className:e,hasHeader:t,placeholder:n})}),r,i&&(0,K.jsx)(PMe,{})]})}function YMe(e){let{surface:t,plugins:n,setActiveEditor:r,retainSurface:i}=VF(),a=(0,G.useRef)(t);a.current=t;let o=(0,G.useCallback)(e=>{a.current===t&&r(e)},[r,t]),[s,c]=(0,G.useState)(!1);return(0,G.useLayoutEffect)(()=>c(!0),[]),s?(0,K.jsx)(t??JMe,{...e,plugins:n,retainSurface:i,onActiveEditorChange:o}):null}function XMe({value:e}){return e===void 0?null:e===!1?(0,K.jsx)(HF,{priority:1,surface:null}):(0,K.jsx)(wke,{...e===!0?{}:e,priority:1})}function ZMe({nodes:e,initialValue:t,onChange:n,variant:r=`article`,theme:i=`light`,placeholder:a=`Write something...`,onSubmit:o,autoFocus:s=!1,className:c,contentClassName:l,style:u,actions:d,header:f,onEditorReady:p,rendererConfig:m,debounceMs:h,children:g,virtualization:_}){mke(e);let v=(0,G.useMemo)(()=>t?zF(t):void 0,[t]),y={namespace:`RichEditor`,theme:mP,nodes:e,editable:!0,onError:e=>{console.error(`[RichEditor]`,e)},...v?{editorState:JSON.stringify(v)}:{}},b=Ij(r);return(0,K.jsx)(Oe,{className:b,theme:i,children:(0,K.jsx)(cF,{colorScheme:i,children:(0,K.jsx)(Wj,{config:m,mode:`editor`,variant:r,children:(0,K.jsx)(_e,{initialConfig:y,children:(0,K.jsxs)(yke,{children:[(0,K.jsx)(XMe,{value:_}),(0,K.jsx)(bMe,{children:(0,K.jsx)(jMe,{children:(0,K.jsxs)(`div`,{suppressHydrationWarning:!0,className:Fj(`rich-editor`,b,c),"data-theme":i,style:{...u,maxWidth:`none`},children:[(0,K.jsx)(WF,{children:f}),(0,K.jsx)(YMe,{autoFocus:s,className:l,hasHeader:!!f,placeholder:a}),(0,K.jsx)(cee,{}),(0,K.jsx)(MMe,{debounceMs:h,onChange:n}),(0,K.jsx)(NMe,{onSubmit:o}),(0,K.jsx)(AMe,{onEditorReady:p}),(0,K.jsx)(UF,{children:(0,K.jsx)(Ete,{})}),g,d&&(0,K.jsx)(`div`,{className:`rich-editor__actions`,children:(0,K.jsx)(WF,{children:d})})]})})})]})})})})})}function cR({extraNodes:e,imageUpload:t,videoUpload:n,fileUpload:r,children:i,...a}){let o=e?[...kF,...e]:kF,s=t??IL;return(0,K.jsx)(Sje,{children:(0,K.jsx)(Cje,{upload:s,children:(0,K.jsx)(Eje,{upload:n??null,children:(0,K.jsx)(xje,{upload:r??null,children:(0,K.jsx)(LMe,{extraNodes:e,children:(0,K.jsxs)(ZMe,{nodes:o,...a,children:[(0,K.jsxs)(UF,{children:[(0,K.jsx)(yje,{}),(0,K.jsx)(VMe,{}),(0,K.jsx)(hMe,{onUpload:s}),n?(0,K.jsx)(kMe,{onUpload:n}):null,r?(0,K.jsx)(Oje,{onUpload:r}):null,(0,K.jsx)(WMe,{}),(0,K.jsx)(zMe,{}),(0,K.jsx)(KMe,{}),(0,K.jsx)(_Me,{}),(0,K.jsx)(DMe,{})]}),(0,K.jsx)(yCe,{}),i]})})})})})})}var QMe=(e,t)=>e.kind===`node`?t.kind===`node`&&e.id===t.id:t.kind===`edge`&&e.from===t.from&&e.to===t.to&&e.index===t.index;function lR(e,t,n){let r=e.find(e=>QMe(e.target,t));return!r||t.kind===`edge`&&n&&r.label!==n?null:r}function uR(e,t){return e.kind===`node`?t||e.id:`${e.from} → ${e.to}${t?` · ${t}`:``}`}var dR=18,$Me=new Set([`P`,`LI`,`DIV`,`BR`,`PRE`,`BLOCKQUOTE`,`TR`,`TD`,`TH`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`UL`,`OL`,`TABLE`,`FIGCAPTION`]);function eNe(e){let t=``,n=e=>{if(e.nodeType===Node.TEXT_NODE){t+=e.textContent??``;return}if(!(e instanceof Element))return;let r=$Me.has(e.tagName);r&&(t+=` `),e.childNodes.forEach(n),r&&(t+=` `)};return n(e),t}var tNe=e=>e.replaceAll(/\s+/g,` `).trim(),nNe=e=>e.length>dR?`${e.slice(0,dR).trimEnd()}…`:e;function fR(e){let t=e.map(tNe);if(t.length===1)return t[0]||null;let n=[t.find(Boolean),[...t].reverse().find(Boolean)].filter((e,t,n)=>!!e&&n.indexOf(e)===t);return n.length?`${i(`composer.blocks`,{count:t.length})} · ${n.map(nNe).join(` → `)}`:null}function pR(e,t){if(e.diagram)return uR(e.diagram,e.quote);if(e.quote)return e.quote;let n=t?fR(t):null;if(n)return n;let r=Ur(e).length;return r>1?i(`document.wholeBlocks`,{count:r}):i(`document.wholeBlock`)}function rNe(e,t,n){if(!t)return`block`;let r=n!==void 0&&e.slice(n,n+t.length)===t?n:e.indexOf(t);return r===-1?`block`:{start:r,end:r+t.length}}function mR(e,t){return new Set(e.filter(e=>e.status===`open`||e.id===t).map(e=>e.id))}var hR=`g.pele-node, g.pele-edge, g.pele-edge-label`,gR=`ryugi-edge-hit`,iNe=`ryugi-edge-mark`,_R=e=>`${e.classList.contains(`pele-node`)?`node`:`edge`}:${e.getAttribute(`data-id`)}`,vR=e=>`${e.kind}:${e.domId}`,yR=e=>e.classList.contains(`pele-edge-label`)||e.classList.contains(`pele-actor-footer`);function bR(e,t,n){n==null?e.removeAttribute(t):e.setAttribute(t,n)}function aNe(e){if(e.querySelector(`.${gR}`))return;let t=e.querySelector(`path:not(.pele-marker)`);if(t)for(let n of[gR,iNe]){let r=t.cloneNode(!1);r.setAttribute(`class`,n),e.prepend(r)}}function xR(e,t,n,r,i){let a=new Map(t.map(e=>[vR(e),e]));for(let t of e.querySelectorAll(hR)){let e=a.get(_R(t)),o=e?n.get(e):void 0,s=r&&e&&!yR(t);bR(t,`data-pick`,r&&e?``:null),bR(t,`tabindex`,s?`0`:null),bR(t,`role`,s?`button`:null),bR(t,`aria-label`,s?i(e):null),bR(t,`data-comment`,o?.state),bR(t,`data-comment-thread`,o?.threadIds.length&&!yR(t)?o.threadIds.join(` `):null),e?.kind===`edge`&&t.classList.contains(`pele-edge`)&&aNe(t)}}function SR(e,t,n){let r=e instanceof Element?e.closest(hR):null;if(!r||!t.contains(r))return null;let i=_R(r),a=n.find(e=>vR(e)===i);return a?{element:a,node:[...t.querySelectorAll(hR)].find(e=>!yR(e)&&_R(e)===i)??r}:null}function CR(e,t){let n=t?vR(t):null;for(let t of e.querySelectorAll(hR))bR(t,`data-hover`,n!==null&&_R(t)===n?``:null)}function oNe(e,t){for(let n of e.querySelectorAll(`[data-comment-thread]`))if(n.getAttribute(`data-comment-thread`).split(` `).includes(t))return n;return null}function sNe(e){let t=e.getBoundingClientRect(),n=e.querySelector(`.${gR}`),r=n?.getScreenCTM?.();if(n&&r&&typeof n.getTotalLength==`function`){let e=n.getPointAtLength(n.getTotalLength()/2).matrixTransform(r);return{x:e.x,y:e.y}}return n?{x:t.left+t.width/2,y:t.top+t.height/2}:{x:t.right,y:t.top+t.height/2}}var wR=`ryugi:read-resolutions`,cNe=500;function TR(){try{let e=JSON.parse(globalThis.localStorage?.getItem(wR)??`null`);return e&&typeof e==`object`?e:{}}catch{return{}}}var ER=e=>e.status===`resolved`&&e.statusBy===`agent`&&TR()[e.id]!==e.statusAt;function DR(e){let t=TR();delete t[e.id],t[e.id]=e.statusAt;let n=Object.keys(t);for(let e of n.slice(0,Math.max(0,n.length-cNe)))delete t[e];try{globalThis.localStorage?.setItem(wR,JSON.stringify(t))}catch{return}}var OR=420,lNe=`cubic-bezier(.32, .72, 0, 1)`,uNe=Kr(420,26),kR=e=>e?.querySelector(`[data-panel]`)??null,AR=e=>[...e.querySelectorAll(`[data-morph]`)].map(e=>[e.getAttribute(`data-morph`),e]);function jR(e,t,n){for(let r of e.children){let e=r.getAttribute(`data-morph`);e&&t.has(e)||([...r.querySelectorAll(`[data-morph]`)].some(e=>t.has(e.getAttribute(`data-morph`)))?jR(r,t,n):n.push(r.animate([{opacity:0},{opacity:1}],{duration:OR*.5,delay:OR*.2,easing:`ease-out`,fill:`backwards`})))}}var dNe=class extends G.Component{frame=(0,G.createRef)();running=[];ghost=null;panel=null;getSnapshotBeforeUpdate(e){if(e.folded===this.props.folded||Wr())return null;this.stop();let t=kR(this.frame.current);if(!t)return null;let n=getComputedStyle(t),r=document.createElement(`div`);return r.append(...[...t.childNodes].map(e=>e.cloneNode(!0))),{background:n.backgroundColor,shadow:n.boxShadow,height:t.offsetHeight,ghost:r,shared:new Map(AR(t).map(([e,t])=>[e,t.getBoundingClientRect()]))}}componentDidUpdate(e,t,n){let r=kR(this.frame.current);n&&r&&this.morph(r,n)}componentWillUnmount(){this.stop()}stop(){for(let e of this.running)e.cancel();this.running=[],this.ghost?.remove(),this.ghost=null,this.panel?.style.removeProperty(`display`),this.panel=null}morph(e,t){let n=getComputedStyle(e),r={height:e.offsetHeight,background:n.backgroundColor,shadow:n.boxShadow},i=AR(e).flatMap(([e,n])=>{let r=t.shared.get(e);return r?[{el:n,before:r,after:n.getBoundingClientRect()}]:[]}),a={duration:OR,easing:lNe},{ghost:o}=t;o.setAttribute(`aria-hidden`,`true`),Object.assign(o.style,{position:`absolute`,top:`0`,left:`0`,right:`0`,pointerEvents:`none`});for(let[,e]of AR(o))e.style.visibility=`hidden`;jR(e,new Set(i.map(({el:e})=>e.getAttribute(`data-morph`))),this.running),e.style.display=`block`,this.panel=e,e.append(o),this.ghost=o,this.running.push(e.animate([{height:`${t.height}px`,backgroundColor:t.background,boxShadow:t.shadow},{height:`${r.height}px`,backgroundColor:r.background,boxShadow:r.shadow}],a),o.animate([{opacity:1},{opacity:0}],{duration:OR*.4,easing:`ease-out`,fill:`forwards`}),...i.map(({el:e,before:t,after:n})=>e.animate([{transform:`translate(${t.left-n.left}px, ${t.top-n.top}px)`},{transform:`none`}],e.getAttribute(`data-morph`)===`check`?uNe:a)));let s=this.running;Promise.all(s.map(e=>e.finished)).then(()=>s===this.running&&this.stop(),()=>{})}render(){return(0,K.jsx)(`div`,{ref:this.frame,children:this.props.children})}},MR=100,NR=96,fNe=`calc(100vh - 196px)`;function pNe(e,t){let n=t-MR-NR;return e.top<MR||e.top+Math.min(e.height,n)>t-NR}var PR=Kr(260,28);function mNe(e){let[t,n]=(0,G.useState)(e),r=(0,G.useRef)(null),i=(0,G.useRef)(null);return e&&!t&&n(!0),(0,G.useLayoutEffect)(()=>{let t=r.current,a=i.current;if(!t||!a){e||n(!1);return}let o=!1,s=t.offsetHeight;return e?(Gr(t,[{height:`0px`},{height:`${s}px`}],PR),Gr(a,[{opacity:0,transform:`translateY(8px)`},{opacity:1,transform:`none`}],PR)):Promise.all([Gr(t,[{height:`${s}px`},{height:`0px`}],{duration:140,easing:xne}),Gr(a,[{opacity:1},{opacity:0}],{duration:100,easing:`linear`})]).then(()=>{o||n(!1)}),()=>{o=!0}},[e,t]),{shown:t,outer:r,inner:i}}function FR({active:e,capped:t,children:n}){return(0,K.jsx)(`div`,{"data-panel":!0,...{0:{className:`x1n2onr6 xh8yej3 x9f619 xb3r6kr xixl9f9 x2fo67v xqfszdh xfifm61 x1dbl2gt xo2rkog xt0e3qv`},2:{className:`x1n2onr6 xh8yej3 x9f619 xb3r6kr xixl9f9 xqfszdh xfifm61 x1dbl2gt xo2rkog xt0e3qv x12ilycc x1d5q07e`},1:{className:`x1n2onr6 xh8yej3 x9f619 xb3r6kr xixl9f9 x2fo67v xqfszdh xfifm61 x1dbl2gt xo2rkog xt0e3qv x78zum5 xdt5ytf`},3:{className:`x1n2onr6 xh8yej3 x9f619 xb3r6kr xixl9f9 xqfszdh xfifm61 x1dbl2gt xo2rkog xt0e3qv x12ilycc x1d5q07e x78zum5 xdt5ytf`}}[!!e<<1|!!t],style:t?{maxHeight:fNe}:void 0,children:n})}function IR({thread:e,active:t,actions:n,onActivate:r,agent:a=`Agent`,label:o}){let[s,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)(0),g=(0,G.useRef)(null),_=e.status===`resolved`,v=(0,G.useMemo)(()=>!!n&&f!==e.statusAt&&ER(e),[n,f,e]),y=(_&&!v||u)&&!s,b=o??pR(e.anchor),x=mNe(!!n&&t&&!_&&!u),S=(0,G.useRef)(null),C=e.messages.length,[w,T]=(0,G.useState)(null),E=e.messages.some(e=>e.id===w&&!e.deleted);(0,G.useLayoutEffect)(()=>{let e=S.current;t&&e&&(e.scrollTop=e.scrollHeight)},[t,C]),(0,G.useEffect)(()=>{let e=S.current;if(!t||!e)return;let n=!0,r=()=>{n=e.scrollHeight-e.scrollTop-e.clientHeight<8},i=new ResizeObserver(()=>{n&&(e.scrollTop=e.scrollHeight)});return e.addEventListener(`scroll`,r,{passive:!0}),i.observe(e),()=>{e.removeEventListener(`scroll`,r),i.disconnect()}},[t]),(0,G.useEffect)(()=>{e.status===`open`&&(l(!1),d(!1))},[e.status]);let D=()=>{d(!0),l(!1),n?.resolve?.(e.id)},O=()=>{DR(e),p(e.statusAt),l(!1)};return(0,K.jsx)(dNe,{folded:y,children:y?(0,K.jsx)(FR,{children:(0,K.jsxs)(`div`,{onClick:()=>{r(),l(!0)},className:`x78zum5 x6s0dn4 x167g77z x1vvogim xaope02 xddlp02 x1ypdohk`,children:[(0,K.jsx)(c,{"data-morph":`check`,size:13,strokeWidth:2.2}),(0,K.jsxs)(`span`,{children:[i(`common.resolved`),` ·`]}),(0,K.jsx)(`span`,{"data-morph":`quote`,className:`x98rzlu xeuugli xb3r6kr xuxw1ft xlyipyv x7zghnd`,children:b})]})}):(0,K.jsx)(`div`,{ref:g,onClick:e=>{r(),!e.target.closest(`button, textarea, input, a`)&&window.getSelection()?.isCollapsed!==!1&&h(e=>e+1)},children:(0,K.jsxs)(FR,{active:t,capped:t,children:[(0,K.jsxs)(`div`,{className:`x78zum5 x6s0dn4 x167g77z x889kno xqin4a2 x1j6dyjg x2lah0s`,children:[(0,K.jsx)(`span`,{"data-morph":`quote`,className:`x98rzlu xeuugli xb3r6kr xuxw1ft xlyipyv x7zghnd`,children:b}),v?(0,K.jsxs)(`span`,{className:`x2lah0s x3nfvp2 x6s0dn4 x1jnr06f xsplgde xv2tywg x1e6avla xsf6uxt xh0clw4 xuxw1ft`,children:[(0,K.jsx)(c,{size:10,strokeWidth:2.6}),e.statusName?i(`document.resolvedBy`,{agent:e.statusName}):i(`common.resolved`)]}):n?(0,K.jsx)(sne,{agent:a,thread:e}):null,!n?.resolve||!n.reopen?null:_?(0,K.jsx)(`button`,{title:i(`common.reopen`),type:`button`,onClick:()=>n.reopen(e.id),className:`x2lah0s x17z2i9w x17rw0jw xrvj5dj x1ku5rj1 x1717udv xc342km x1kogg8i xjbqb8w xj0l527 xddlp02 xytdrwj xfifm61 x1ypdohk`,children:(0,K.jsx)(one,{size:13,strokeWidth:2.2})}):(0,K.jsx)(`button`,{title:i(`common.markResolved`),type:`button`,onClick:e=>(e.stopPropagation(),D()),className:`x2lah0s x17z2i9w x17rw0jw xrvj5dj x1ku5rj1 x1717udv xc342km x1kogg8i xjbqb8w xj0l527 xddlp02 xytdrwj xfifm61 x1ypdohk`,children:(0,K.jsx)(c,{"data-morph":`check`,size:14,strokeWidth:2.4})}),v?(0,K.jsx)(`button`,{title:i(`document.doneReading`),type:`button`,onClick:e=>(e.stopPropagation(),O()),className:`x2lah0s x17z2i9w x17rw0jw xrvj5dj x1ku5rj1 x1717udv xc342km x1kogg8i xjbqb8w xj0l527 xddlp02 xytdrwj xfifm61 x1ypdohk`,children:(0,K.jsx)(Mne,{"data-morph":`check`,size:13,strokeWidth:2.2})}):null]}),(0,K.jsx)(`div`,{ref:S,className:`x98rzlu x2lwn1j x1odjw0f xish69e`,children:(0,K.jsx)(cne,{actions:n,expandable:t,lines:t?8:3,thread:e,collapse:t||E?void 0:e=>(0,K.jsx)(`button`,{type:`button`,onClick:e=>(e.stopPropagation(),r()),className:`x78zum5 x6s0dn4 x167g77z xh8yej3 x1uuky47 xj8oexa xnjsko4 xc342km xjbqb8w xddlp02 xytdrwj xjb2p0i x1j6dyjg x1ypdohk x1cpjm7i xl5i350 xm4vf9w xpl44qm x5r1i06 x1s928wv xkbqsiu xoiy6we x13fydu1 xy7mlml`,children:i(`document.earlierReplies`,{count:e})}),onEditing:(e,t)=>T(n=>t?e:n===e?null:n)})}),n&&x.shown?(0,K.jsx)(`div`,{ref:x.outer,className:`xb3r6kr x2lah0s`,children:(0,K.jsx)(`div`,{ref:x.inner,children:(0,K.jsx)(Br,{focusKey:m,placeholder:i(`common.reply`),submitLabel:i(`composer.reply`),variant:`inline`,onSubmit:t=>n.reply(e.id,t)})})}):null]})})})}var LR=(e,t,n,r,i)=>`${JSON.stringify([n??[e],r??null,i??null])}\n${t}`;function hNe(){let e=new Map;return{save(t,n){n.trim()?e.set(t,n):e.delete(t)},take(t){return e.get(t)??``}}}function gNe(){let e=null,t=new Set;return{get:()=>e,set(n){if(n!==e){e=n;for(let e of t)e()}},subscribe(e){return t.add(e),()=>t.delete(e)}}}var RR=(0,G.createContext)(null);function zR(e,t,n){let r=new Map;if(!n)return r;let i=mR(t.threads,t.activeId);for(let a of t.threads){let{anchor:o}=a;if(o.blockId!==n||!o.diagram||!i.has(a.id))continue;let s=lR(e,o.diagram,o.quote);if(!s)continue;let c=r.get(s)??{state:`open`,threadIds:[]};a.id===t.activeId?(c.state=`active`,c.threadIds.unshift(a.id)):c.threadIds.push(a.id),r.set(s,c)}let{draft:a}=t;if(a?.diagram&&a.blockId===n){let t=lR(e,a.diagram,a.quote);t&&r.set(t,{state:`draft`,threadIds:r.get(t)?.threadIds??[]})}return r}var _Ne=e=>[...e].map(([e,t])=>`${e.kind}:${e.domId}:${t.state}:${t.threadIds.join(`,`)}`).join(`|`);function BR(e){let t=[],n=e._nodes;for(let{klass:e}of n.values()){let n=e.commandItems??e.slashMenuItems;if(n)for(let e of n)t.push(e)}return t}function VR(e){let t=e;for(;t;){if(aOe(t))return t;t=t.getParent()}return null}function HR(e){let t=new Map;for(let n of e){let e=VR(n);e&&t.set(e.getKey(),e)}return Array.from(t.values())}function UR(e){return HR(e.getNodes()).length>0}function WR(e){let t=e.getChildren();for(let n of t)e.insertBefore(n);e.remove()}function GR(){let e=kr();if(!Jn(e))return;if(e.isCollapsed()){let t=VR(e.anchor.getNode());t&&WR(t);return}let t=HR(e.getNodes());if(t.length>0){for(let e of t)WR(e);return}let n=e.getTextContent();if(!n.trim())return;e.removeText();let r=lP();r.append(te(n));let i=kr();Jn(i)&&i.insertNodes([r])}var vNe={isBold:!1,isItalic:!1,isUnderline:!1,isStrikethrough:!1,isSuperscript:!1,isSubscript:!1,isCode:!1,isHighlight:!1,isLink:!1,isRuby:!1,isSpoiler:!1,fontColor:``,backgroundColor:``};function KR(e){return Yn(e)?!zn(e)||!e.getIsUnlinked():!1}function qR(e){return Yn(e)&&!zn(e)}function JR(e){return e.getNodes().some(e=>KR(e.getParent())||KR(e))}function yNe(e){let t=e.anchor.getNode();for(;t;){if(Yn(t))return t.getURL();t=t.getParent()}return``}function bNe(e){let t=new Map;for(let n of e.getNodes()){zn(n)&&!n.getIsUnlinked()&&t.set(n.getKey(),n);let e=n.getParent();zn(e)&&!e.getIsUnlinked()&&t.set(e.getKey(),e)}return Array.from(t.values())}function YR(e){let t=e;for(;t;){if(rF(t))return t;t=t.getParent()}return null}function XR(e){let t=new Map;for(let n of e){let e=YR(n);e&&t.set(e.getKey(),e)}return Array.from(t.values())}function xNe(e){let t=e.getNodes(),n=Or(e,`color`,``);if(!n){let e=t.find(e=>$N(e));e&&(n=e.getColor()??``)}return{isBold:e.hasFormat(`bold`),isItalic:e.hasFormat(`italic`),isUnderline:e.hasFormat(`underline`),isStrikethrough:e.hasFormat(`strikethrough`),isSuperscript:e.hasFormat(`superscript`),isSubscript:e.hasFormat(`subscript`),isCode:e.hasFormat(`code`),isHighlight:e.hasFormat(`highlight`),isLink:JR(e),isRuby:XR(t).length>0,isSpoiler:UR(e),fontColor:n,backgroundColor:Or(e,`background-color`,``)}}var SNe=/^[a-z][\d+.a-z-]*:/i,CNe=/^(?:https?:\/\/|www\.)\S+$|^[\w-]+(?:\.[\w-]+)+(?:[#/?]\S*)?$/i;function wNe(e){let t=e.trim();return t?SNe.test(t)||t.startsWith(`/`)||t.startsWith(`#`)?t:`https://${t}`:``}function ZR(e){return CNe.test(e.trim())}async function TNe(){try{if((await navigator.permissions?.query({name:`clipboard-read`}))?.state!==`granted`)return``;let e=(await navigator.clipboard?.readText())?.trim()??``;return ZR(e)?e:``}catch{return``}}function ENe(e,t){for(let e of bNe(t))e.setIsUnlinked(!0),e.markDirty();t.getNodes().some(e=>qR(e.getParent())||qR(e))&&e.dispatchCommand(hn,null)}function DNe(){let e=kr();if(Jn(e))for(let t of e.extract())it(t)?(t.setFormat(0),t.setStyle(``)):$N(t)&&t.setColor(null)}function ONe(){let e=kr();if(!Jn(e))return null;let t=e.getTextContent();if(!t.trim())return null;e.removeText();let n=nF(``);n.append(te(t));let r=kr();return Jn(r)&&r.insertNodes([n]),{nodeKey:n.getKey(),reading:``,isNew:!0}}function QR(e){let t=Dn(e);if(rF(t)){for(let e of t.getChildren())t.insertBefore(e);t.remove()}}function kNe(e,t){let n=Dn(e);rF(n)&&n.setReading(t)}var ANe=`_1m6axz71`,jNe=`_1m6axz74`,MNe=`_1m6axz75`,NNe=`_1m6axz76`,PNe=`_1m6axz77`,FNe=`_1m6axz78`,INe=`_1m6axz79`;function LNe(){return Be()}function $R({active:e,children:t,handle:n,label:r,onClick:i,render:a,shortcut:o}){return(0,K.jsx)(tt,{"aria-label":r,"data-shortcut":o,"data-tooltip":r,handle:n,payload:{label:r,shortcut:o},render:a??(0,K.jsx)(`button`,{"aria-pressed":e,className:`_1m6axz74`,type:`button`,onClick:i,onMouseDown:e=>e.preventDefault()}),children:t})}var ez={size:16,strokeWidth:2},RNe=[{format:`bold`,label:`Bold`,shortcut:`Mod+B`,icon:(0,K.jsx)(Kte,{...ez})},{format:`italic`,label:`Italic`,shortcut:`Mod+I`,icon:(0,K.jsx)(Jte,{...ez})},{format:`underline`,label:`Underline`,shortcut:`Mod+U`,icon:(0,K.jsx)(Hte,{...ez})},{format:`strikethrough`,label:`Strikethrough`,icon:(0,K.jsx)(Dt,{...ez})}],zNe={bold:`isBold`,italic:`isItalic`,underline:`isUnderline`,strikethrough:`isStrikethrough`};function tz(){return(0,K.jsx)(`span`,{"aria-hidden":!0,className:NNe})}function BNe({actions:e,handle:t,onBackgroundColor:n,onClearFormatting:r,onColor:i,onFormat:a,onLink:o,onRuby:s,onSpoiler:c,state:l}){return(0,K.jsxs)(K.Fragment,{children:[RNe.map(e=>(0,K.jsx)($R,{active:!!l[zNe[e.format]],handle:t,label:e.label,shortcut:e.shortcut,onClick:()=>a(e.format),children:e.icon},e.format)),(0,K.jsx)(tz,{}),(0,K.jsx)($R,{active:l.isCode,handle:t,label:`Inline code`,onClick:()=>a(`code`),children:(0,K.jsx)(Pr,{...ez})}),(0,K.jsx)($R,{active:l.isHighlight,handle:t,label:`Highlight`,onClick:()=>a(`highlight`),children:(0,K.jsx)(jt,{...ez})}),(0,K.jsx)($R,{active:l.isSpoiler,handle:t,label:`Spoiler`,onClick:c,children:(0,K.jsx)(Bte,{...ez})}),(0,K.jsx)(tz,{}),(0,K.jsx)($R,{active:l.isLink,handle:t,label:`Link`,shortcut:`Mod+K`,onClick:o,children:(0,K.jsx)(y,{...ez})}),(0,K.jsx)($R,{active:l.isRuby,handle:t,label:`Ruby`,onClick:s,children:(0,K.jsx)(mi,{...ez})}),(0,K.jsx)(tz,{}),(0,K.jsx)(kte,{className:MNe,currentBackground:l.backgroundColor,currentColor:l.fontColor||`inherit`,tooltip:`Text color`,onSelect:i,onSelectBackground:n}),(0,K.jsxs)(Zn,{modal:!1,children:[(0,K.jsx)($R,{handle:t,label:`More formatting`,render:(0,K.jsx)(On,{render:(0,K.jsx)(`button`,{className:jNe,type:`button`,onMouseDown:e=>e.preventDefault()})}),onClick:()=>{},children:(0,K.jsx)(Nr,{...ez})}),(0,K.jsxs)(Rt,{align:`end`,positionMethod:`fixed`,sideOffset:8,children:[(0,K.jsxs)(Ve,{checked:l.isSuperscript,onCheckedChange:()=>a(`superscript`),children:[(0,K.jsx)(qne,{...ez}),`Superscript`]}),(0,K.jsxs)(Ve,{checked:l.isSubscript,onCheckedChange:()=>a(`subscript`),children:[(0,K.jsx)(Kne,{...ez}),`Subscript`]}),(0,K.jsx)(ur,{}),(0,K.jsxs)(Ut,{onClick:r,children:[(0,K.jsx)(Wne,{...ez}),`Clear formatting`]})]})]}),e&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(tz,{}),e]})]})}function nz({handle:e,icon:t,label:n,onCancel:r,onChange:i,onSubmit:a,placeholder:o,secondary:s,type:c=`text`,value:l}){let u=(0,G.useRef)(null);return(0,G.useEffect)(()=>{u.current?.focus({preventScroll:!0})},[]),(0,K.jsxs)(`div`,{className:PNe,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:FNe,children:t}),(0,K.jsx)(ct,{"aria-label":n,autoComplete:`off`,className:INe,placeholder:o,ref:u,spellCheck:!1,type:c,value:l,onChange:e=>i(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Enter`?(e.preventDefault(),a()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),r()))}}),(0,K.jsxs)(Fe,{"aria-label":`Save`,size:`md`,variant:`solid`,onClick:a,onMouseDown:e=>e.preventDefault(),children:[`Save`,(0,K.jsx)(ar,{keys:`enter`,size:`sm`,tone:`inverted`})]}),(0,K.jsx)(tt,{handle:e,payload:{label:s.label,shortcut:s.shortcut},render:(0,K.jsx)(Fe,{icon:!0,"aria-label":s.label,danger:s.danger,size:`md`,onClick:s.onClick,onMouseDown:e=>e.preventDefault()}),children:s.icon})]})}function rz(e){return Array.from(e.querySelectorAll(`button:not(:disabled)`))}function VNe(e,t){let n=rz(e);if(n.includes(t))for(let e of n)e.tabIndex=e===t?0:-1}function HNe(e){if(!e)return!1;let t=rz(e)[0];return t?.focus(),!!t}function UNe(e){let t=rz(e.currentTarget),n=t.indexOf(document.activeElement);if(n===-1)return!1;let r=t.length-1,i=e.key===`ArrowRight`?n===r?0:n+1:e.key===`ArrowLeft`?n===0?r:n-1:e.key===`Home`?0:e.key===`End`?r:-1;return i!==-1&&(e.preventDefault(),t[i]?.focus(),!0)}function WNe({editor:e,editRuby:t,modeRef:n,openLink:r,toolbarRef:i,updateToolbar:a}){(0,G.useEffect)(()=>{let o=n=>{let r=n.target;if(!r||!e.isEditable()||window.getSelection()?.isCollapsed===!1)return;let i=e.read(()=>{let e=YR(Bt(r));return e?{key:e.getKey(),reading:e.getReading()}:null});i&&t(i.key,i.reading)},s=null;return GNe(e.registerCommand(mn,()=>(a(),!1),1),e.registerUpdateListener(({editorState:e})=>{e.read(a)}),e.registerCommand(br,t=>{let a=t.key.toLowerCase()===`k`&&(t.metaKey||t.ctrlKey)&&!t.altKey&&!t.shiftKey,o=t.key===`F10`&&t.altKey;if(!a&&!o||n.current.kind!==`format`||a&&!e.isEditable())return!1;let s=kr();return!Jn(s)||s.isCollapsed()||o&&!i.current?!1:(t.preventDefault(),o?(queueMicrotask(()=>HNe(i.current)),!0):(queueMicrotask(()=>r(`editor`)),!0))},1),e.registerRootListener(e=>{s?.removeEventListener(`click`,o),s=e,e?.addEventListener(`click`,o)}),()=>s?.removeEventListener(`click`,o))},[t,e,n,r,i,a])}function GNe(...e){return()=>{for(let t of e)t()}}var iz={kind:`format`};function KNe(e,t){let[n,r]=(0,G.useState)(iz),i=(0,G.useRef)(n),a=(0,G.useRef)(null),o=(0,G.useCallback)(e=>{let t=typeof e==`function`?e(i.current):e;i.current=t,r(t)},[]),s=(0,G.useCallback)(e=>{let n=i.current;o(iz),!e||n.kind===`format`?t(null):n.origin===`editor`?t(`editor`):t(n.kind===`link`?`Link`:`Ruby`)},[t,o]),c=(0,G.useCallback)(t=>{let n=e.read(()=>{let e=kr();if(!Jn(e)||e.isCollapsed())return null;let t=JR(e),n=t?yNe(e):``,r=e.getTextContent().trim();return{hasLink:t,initial:n||(ZR(r)?r:``),selection:e.clone()}});n&&(a.current=n.selection,o({kind:`link`,draft:n.initial,dirty:!1,existing:n.hasLink,origin:t}),n.initial||TNe().then(e=>{e&&o(t=>t.kind===`link`&&!t.dirty&&!t.draft?{...t,draft:e}:t)}))},[e,o]),l=(0,G.useCallback)(e=>{o(t=>t.kind===`link`?{...t,draft:e,dirty:!0}:t)},[o]),u=(0,G.useCallback)((t=!0)=>{let n=i.current;if(n.kind!==`link`)return;let r=wNe(n.draft);r&&e.update(()=>{let t=a.current,n=kr();t&&(!Jn(n)||n.isCollapsed())&&Jt(t.clone()),e.dispatchCommand(hn,r)}),a.current=null,s(t)},[s,e]),d=(0,G.useCallback)(()=>{i.current.kind===`link`&&(e.update(()=>{let t=a.current,n=kr();t&&(!Jn(n)||n.isCollapsed())&&Jt(t.clone());let r=kr();Jn(r)&&ENe(e,r)}),a.current=null,s(!0))},[s,e]),f=(0,G.useCallback)(t=>{let n=e.read(()=>{let e=kr();if(!Jn(e))return;let t=XR(e.getNodes())[0];return t?{nodeKey:t.getKey(),reading:t.getReading(),isNew:!1}:null});if(n===void 0)return;if(n){o({kind:`ruby`,draft:n,origin:t});return}let r=null;e.update(()=>{r=ONe()},{discrete:!0}),r&&o({kind:`ruby`,draft:r,origin:t})},[e,o]),p=(0,G.useCallback)((e,t)=>{o({kind:`ruby`,draft:{nodeKey:e,reading:t,isNew:!1},origin:`editor`})},[o]),m=(0,G.useCallback)(e=>{o(t=>t.kind===`ruby`?{...t,draft:{...t.draft,reading:e}}:t)},[o]),h=(0,G.useCallback)((t=!0)=>{let n=i.current;if(n.kind!==`ruby`)return;let r=n.draft.reading.trim();e.update(()=>{r?kNe(n.draft.nodeKey,r):QR(n.draft.nodeKey)}),s(t)},[s,e]),g=(0,G.useCallback)(()=>{let t=i.current;t.kind===`ruby`&&(t.draft.isNew&&e.update(()=>QR(t.draft.nodeKey)),s(!0))},[s,e]),_=(0,G.useCallback)(()=>{let t=i.current;t.kind===`ruby`&&(e.update(()=>QR(t.draft.nodeKey)),s(!0))},[s,e]);return{mode:n,modeRef:i,cancel:s,cancelRuby:g,commitOnOutsideClick:(0,G.useCallback)(()=>{let e=i.current;e.kind===`link`?e.dirty&&e.draft.trim()?u(!1):s(!1):e.kind===`ruby`&&h(!1)},[s,u,h]),editRuby:p,openLink:c,openRuby:f,removeLink:d,removeRuby:_,saveLink:u,saveRuby:h,setLinkDraft:l,setRubyDraft:m}}var az=8,oz=8;function qNe({anchor:e,size:t,bounds:n}){let r=e.top-az-t.height,i=e.bottom+az,a=r>=n.top,o=i+t.height<=n.bottom,s=a||!o?`top`:`bottom`,c=s===`top`?Math.max(r,n.top):i,l=(e.left+e.right)/2,u=n.left+oz,d=n.right-t.width-oz;return{top:c,left:Math.max(u,Math.min(l-t.width/2,d)),placement:s}}function JNe(e){let{position:t}=window.getComputedStyle(e);return t===`sticky`||t===`fixed`}function YNe(e){let t=e?.parentElement??null;for(;t;){let{overflowY:e}=window.getComputedStyle(t);if(e===`auto`||e===`scroll`)return t;t=t.parentElement}return null}function XNe(e,t,n){let r={top:0,left:0,right:window.innerWidth,bottom:window.innerHeight},i=YNe(e);if(i){let e=i.getBoundingClientRect();r.top=Math.max(r.top,e.top),r.bottom=Math.min(r.bottom,e.bottom)}let a=e.getBoundingClientRect();for(let e of document.querySelectorAll(`[role="toolbar"]`)){if(e===t||t?.contains(e)||!JNe(e))continue;let i=e.getBoundingClientRect();i.right>a.left&&i.left<a.right&&i.top<n&&i.bottom>r.top&&(r.top=Math.min(i.bottom,n))}return r}function ZNe(e){return e.match(/^var\((--[^\s),]+)(?:,[^)]+)?\)$/)?.[1]??null}function sz(e,t){if(typeof e==`string`){let n=ZNe(e);return n&&t.add(n),t}if(e&&typeof e==`object`)for(let n of Object.values(e))sz(n,t);return t}var QNe=Array.from(sz(Ht,new Set));function $Ne(e,t){let n=e.getRootElement();if(!n)return;let r=window.getComputedStyle(n);for(let e of QNe){let n=r.getPropertyValue(e).trim();n&&t.style.setProperty(e,n)}}function ePe({active:e,editor:t,getAnchor:n,portalContainer:r,toolbarRef:i,trigger:a}){(0,G.useLayoutEffect)(()=>{if(!e)return;let a=()=>{let e=i.current,a=t.getRootElement();if(!e||!a)return;$Ne(t,e);let o=n();if(!o)return;let s=qNe({anchor:o,size:{width:e.offsetWidth,height:e.offsetHeight},bounds:XNe(a,e,o.top)}),c=r===document.body?null:r.getBoundingClientRect();e.style.top=`${s.top-(c?.top??0)}px`,e.style.left=`${s.left-(c?.left??0)}px`,e.dataset.placement=s.placement};a();let o=requestAnimationFrame(a),s=()=>requestAnimationFrame(a);return window.addEventListener(`scroll`,s,{capture:!0,passive:!0}),window.addEventListener(`resize`,s),()=>{cancelAnimationFrame(o),window.removeEventListener(`scroll`,s,{capture:!0}),window.removeEventListener(`resize`,s)}},[e,t,n,r,i,a])}var cz={size:16,strokeWidth:2};function lz(e){return e.width===0&&e.height===0?null:{top:e.top,bottom:e.bottom,left:e.left,right:e.right}}function tPe({actions:e}={}){let[t]=ht(),n=wt(),{className:r,theme:i}=We(),a=dte(),o=zL(),s=(0,G.useRef)(null),[c]=(0,G.useState)(LNe),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(vNe),[p,m]=(0,G.useState)(null),h=(0,G.useRef)(null),g=KNe(t,(0,G.useCallback)(e=>{m(e?{target:e}:null)},[])),{mode:_,modeRef:v,openLink:b,openRuby:x,editRuby:S,commitOnOutsideClick:C,cancel:w}=g;WNe({editor:t,editRuby:S,modeRef:v,openLink:b,toolbarRef:s,updateToolbar:(0,G.useCallback)(()=>{let e=kr();!Jn(e)||e.isCollapsed()?u(!1):(f(xNe(e)),u(!0))},[])}),(0,G.useEffect)(()=>{o||u(!1)},[o]),(0,G.useEffect)(()=>{n||w(!1)},[w,n]),(0,G.useEffect)(()=>{if(!p)return;let e=p.target===`editor`?null:s.current?.querySelector(`[aria-label="${p.target}"]`);e?e.focus():t.focus(),m(null)},[t,p]),(0,G.useEffect)(()=>{if(_.kind===`format`)return;let e=e=>{let t=e.target;s.current?.contains(t)||C()},t=setTimeout(()=>document.addEventListener(`mousedown`,e),0);return()=>{clearTimeout(t),document.removeEventListener(`mousedown`,e)}},[C,_.kind]);let T=_.kind===`ruby`?_.draft.nodeKey:null,E=(0,G.useCallback)(()=>{let e=t.getRootElement(),n=null;if(T){let e=t.getElementByKey(T);n=e?lz(e.getBoundingClientRect()):null}else if(e&&o){let t=EMe(e,o);n=t?lz(t):null}return n&&(h.current=n),n??h.current},[t,T,o]),D=n?l||_.kind!==`format`:l&&e!=null;ePe({active:D,editor:t,getAnchor:E,portalContainer:a,toolbarRef:s,trigger:`${_.kind}:${JSON.stringify(d)}`});let O=(0,G.useCallback)(e=>t.dispatchCommand(ye,e),[t]),A=(0,G.useCallback)((e,n)=>{t.update(()=>{let t=kr();if(Jn(t)&&(_t(t,e),n!==void 0))for(let e of t.getNodes())$N(e)&&e.setColor(n)})},[t]),j=(0,G.useCallback)(e=>{let t=e===`inherit`?null:e;A({color:t},t)},[A]),M=(0,G.useCallback)(e=>{A({"background-color":e===`inherit`?null:e})},[A]);if(!D)return null;let N=[ANe,_.kind===`link`&&`_1m6axz72`,_.kind===`ruby`&&`_1m6axz73`,r].filter(Boolean).join(` `);return(0,K.jsxs)(B,{delay:400,children:[(0,K.jsx)(Mn,{disableHoverablePopup:!0,handle:c,children:(e=>e.payload?(0,K.jsx)(Fn,{"data-slot":`toolbar-tooltip`,shortcut:e.payload.shortcut,children:e.payload.label}):null)}),(0,Gi.createPortal)((0,K.jsxs)(`div`,{className:N,"data-theme":r?i:void 0,ref:s,role:_.kind===`format`?`toolbar`:`group`,style:{position:`fixed`,zIndex:50},"aria-label":_.kind===`format`?n?`Text formatting`:`Selection actions`:void 0,onFocus:e=>VNe(e.currentTarget,e.target),onKeyDown:e=>{_.kind===`format`&&(UNe(e)||(e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),t.focus()))},children:[_.kind===`format`&&!n&&e,_.kind===`format`&&n&&(0,K.jsx)(BNe,{actions:e,handle:c,state:d,onBackgroundColor:M,onClearFormatting:()=>t.update(DNe),onColor:j,onFormat:O,onLink:()=>b(`toolbar`),onRuby:()=>x(`toolbar`),onSpoiler:()=>t.update(GR)}),_.kind===`link`&&(0,K.jsx)(nz,{handle:c,icon:(0,K.jsx)(y,{...cz}),label:`URL`,placeholder:`Paste or type a link`,type:`url`,value:_.draft,secondary:_.existing?{danger:!0,icon:(0,K.jsx)(Vi,{...cz}),label:`Remove link`,onClick:g.removeLink}:{icon:(0,K.jsx)(k,{...cz}),label:`Back to formatting`,shortcut:`Escape`,onClick:()=>g.cancel(!0)},onCancel:()=>g.cancel(!0),onChange:g.setLinkDraft,onSubmit:()=>g.saveLink()}),_.kind===`ruby`&&(0,K.jsx)(nz,{handle:c,icon:(0,K.jsx)(mi,{...cz}),label:`Reading`,placeholder:`Reading`,value:_.draft.reading,secondary:{danger:!0,icon:(0,K.jsx)(Mr,{...cz}),label:`Remove ruby`,onClick:g.removeRuby},onCancel:g.cancelRuby,onChange:g.setRubyDraft,onSubmit:()=>g.saveRuby()})]}),a)]})}function nPe({left:e,top:t,onComment:n,ref:r}){return(0,K.jsx)(`div`,{ref:r,className:`x10l6tqk x1u8a7rm xqcmdr3 x12l1aco xa3vuyk`,style:{left:e,top:t},children:(0,K.jsx)(`button`,{"aria-label":i(`common.comment`),title:i(`common.comment`),type:`button`,className:`x10l6tqk x1u8a7rm xrvj5dj x1ku5rj1 x1td3qas x10w6t97 x1717udv xmkeg23 x1y0btm7 xgcsv5v xur7f20 x12ilycc xj0l527 x1cge3fn x1d5q07e x1ypdohk xbx70qg x1hl8ikr`,onClick:n,onPointerDown:e=>e.preventDefault(),children:(0,K.jsx)(Rr,{"aria-hidden":`true`,size:16})})})}function rPe({left:e,top:t,children:n,ref:r}){return(0,K.jsx)(`div`,{ref:r,className:`x10l6tqk x1u8a7rm x78zum5 x6s0dn4 xfawy5m xmkeg23 x1y0btm7 xgcsv5v x1q4ynmn x12ilycc x1d5q07e`,style:{left:e,top:t},children:n})}function iPe(){let e=(0,G.use)(Mj);return e?(0,K.jsx)(tPe,{actions:e.selectionActions}):null}function aPe({onComment:e,onCopy:t}){return(0,K.jsxs)(`div`,{className:`xjp7ctv`,onMouseDown:e=>e.preventDefault(),children:[e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{"aria-label":i(`common.comment`),type:`button`,onClick:e,className:`x78zum5 x6s0dn4 x17d4w8g x1fgtraw xt970qd x1awh872 xc342km xu4hgxq xjbqb8w xj0l527 x2230gt xo2rkog xqfszdh xfifm61 xk50ysn x1ypdohk x1de99jn xaatb59 x1y3gkto x1uczgqu x60py1w`,children:[(0,K.jsx)(Rr,{size:14,className:`x2lah0s x1cge3fn`}),i(`common.comment`)]}),(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`x2lah0s x1i1rx1s xlup9mm xj3msbq xcn5yip`})]}):null,(0,K.jsx)(`button`,{"aria-label":i(`document.copy`),type:`button`,onClick:t,className:`x78zum5 x6s0dn4 x17d4w8g x1fgtraw xt970qd x1awh872 xc342km xu4hgxq xjbqb8w xj0l527 x2230gt xqfszdh xfifm61 xk50ysn x1ypdohk x1de99jn xaatb59 x1y3gkto x1uczgqu x60py1w x1bo0w0s`,children:i(`document.copy`)})]})}function oPe({by:e,text:t}){let{t:r}=n();return(0,K.jsxs)(`span`,{"data-ask-note":!0,className:`x78zum5 x17d4w8g xg9jes1 xfifm61 x1dbl2gt xddlp02 xeaf4i8 x1hx0egp`,children:[(0,K.jsxs)(`span`,{className:`x2lah0s x1yz8712`,children:[`↳ `,e??r(`asks.agent`)]}),(0,K.jsx)(`span`,{children:t})]})}function uz(e){let[t,n]=(0,G.useState)(e);return e&&!t&&n(!0),[e||t,()=>n(!1)]}function dz(e,t){let n=(0,G.useEffectEvent)(t);(0,G.useEffect)(()=>{let t=e.current;if(!t)return;let r=e=>{e.stopPropagation(),e.isComposing||e.keyCode===229||n(e)},i=e=>e.stopPropagation();return t.addEventListener(`keydown`,r),t.addEventListener(`compositionstart`,i),()=>{t.removeEventListener(`keydown`,r),t.removeEventListener(`compositionstart`,i)}},[e])}var fz={option:{k1xSpc:`x78zum5`,kGNEyG:`x1cy8zhl`,kOIVth:`x167g77z`,kzqmXN:`xh8yej3`,kAzted:`x21xpn4`,k8WAf4:`x1t0vds8`,kg3NbH:`xaope02`,kMzoRj:`xc342km`,kaIpWk:`x1kogg8i`,kWkggS:`xjbqb8w xj0l527`,kMwMTN:`xo2rkog`,kMv6JI:`xjb2p0i`,kGuDYH:`x1qlqyl8`,kLWn49:`x1fc57z9`,k9WMMc:`x1yc453h`,kkrTdU:`x1ypdohk`,$$css:!0},chosenAgent:{kWkggS:`xacg9sr x1k58n2o`,$$css:!0},chosenHuman:{kWkggS:`x1cfontt xcd1bmh`,$$css:!0}},sPe={padding:0,fontSize:`inherit`,lineHeight:`20px`};function cPe({draft:e,label:t,onChoose:r,onClose:i,onDraft:a,phone:s,view:l}){let{t:u}=n(),d=(0,G.useRef)(null),f=l.options.length>0,[p,m]=(0,G.useState)(l.text!==null||!f),h=()=>{e.trim()&&r(null,e.trim())};dz(d,t=>{let n=t.target.tagName===`TEXTAREA`;t.key===`Escape`&&(n&&f?m(!1):i()),n&&t.key===`Enter`&&(t.metaKey||t.ctrlKey)&&e.trim()&&(t.preventDefault(),h())});let g=l.options.find(e=>e.value===l.recommend),_=g?l.options.filter(e=>e!==g):l.options,v=l.changed?`human`:`agent`,y=e=>{let t=l.text===null&&l.choice===e.value;return(0,K.jsxs)(`button`,{"aria-checked":t,"data-ask-option":e.value,role:`radio`,type:`button`,onClick:()=>r(e.value,null),...o(fz.option,t&&(v===`human`?fz.chosenHuman:fz.chosenAgent)),children:[(0,K.jsx)(`span`,{className:`x1iyjqo2 xeuugli xj0a0fe`,children:e.label}),(0,K.jsx)(`span`,{...{0:{className:`x78zum5 x6s0dn4 x2lah0s x6jxa94 x1qx5ct2 x1yz8712`},1:{className:`x78zum5 x6s0dn4 x2lah0s x6jxa94 x1qx5ct2 xr46axq`}}[v===`human`|0],children:t&&(0,K.jsx)(c,{size:14})})]},e.value)};return(0,K.jsxs)(`div`,{"data-ask-menu":!0,ref:d,...{0:{className:`x78zum5 xdt5ytf x195vfkc`},1:{className:`x78zum5 xdt5ytf x195vfkc xezivpi x1u2d2a2 x1lr1uin x4z9k3i x1evy7pa`}}[!s|0],children:[f&&(0,K.jsxs)(`div`,{"aria-label":t,role:`radiogroup`,className:`x78zum5 xdt5ytf x195vfkc`,children:[g&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{"data-ask-recommended":!0,className:`x1yrsyyn x1120s5i xaope02 xfifm61 xd4r4e8 x1yz8712`,children:u(`asks.recommended`)}),y(g),(0,K.jsx)(`div`,{className:`x1yrsyyn x1120s5i xaope02 xddlp02 xfifm61 xd4r4e8`,children:u(`asks.otherOptions`)})]}),_.map(y)]}),p?(0,K.jsxs)(`div`,{className:`x41o525 x78zum5 xdt5ytf x1jnr06f x1t0vds8 xaope02 x1kogg8i xahzvm9 x1pb8m1d`,children:[(0,K.jsx)(ane,{autoFocus:!0,autoSize:{minRows:1,maxRows:6},placeholder:l.placeholder??u(`asks.other`),style:sPe,value:e,variant:`borderless`,onChange:e=>a(e.target.value)}),(0,K.jsxs)(`div`,{className:`x78zum5 x6s0dn4 x1qughib x167g77z xddlp02 xfifm61`,children:[(0,K.jsx)(`span`,{children:f&&u(`asks.cancel`)}),(0,K.jsxs)(C,{"data-ask-confirm":!0,disabled:!e.trim(),size:`small`,type:`primary`,onClick:h,children:[u(`asks.ok`),!s&&(0,K.jsx)(`span`,{className:`xdzw4kq xfn1xvj x12oqio5 xhnm4ek xfifm61 x1d3mw78`,children:`⌘↩`})]})]})]}):(0,K.jsxs)(`button`,{"data-ask-other":!0,type:`button`,onClick:()=>m(!0),className:`x78zum5 x1cy8zhl x167g77z xh8yej3 x21xpn4 x1t0vds8 xaope02 xc342km x1kogg8i xjbqb8w xj0l527 xjb2p0i x1qlqyl8 x1fc57z9 x1yc453h x1ypdohk xddlp02`,children:[(0,K.jsx)(`span`,{className:`x1iyjqo2 xeuugli xj0a0fe`,children:l.placeholder??u(`asks.otherRow`)}),(0,K.jsx)(`span`,{className:`x78zum5 x6s0dn4 x2lah0s x6jxa94 x1qx5ct2 xc7n51q`,children:(0,K.jsx)(Fr,{size:13})})]})]})}var pz={tag:{k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kOIVth:`x1jnr06f`,kB7OPa:`x9f619`,ks0D6T:`x1hvl878`,kZKoxP:`x17rw0jw`,kUOVxO:`xjgtzcg`,kg3NbH:`xdqyycr`,kMzoRj:`xmkeg23`,ksu8eU:`x1y0btm7`,kVAM5u:`x9r1u3d`,kaIpWk:`x1kogg8i`,kWkggS:`xahzvm9`,kMwMTN:`x1bo0w0s`,kMv6JI:`xjb2p0i`,kGuDYH:`xfifm61`,kLWn49:`x37zpob`,kXLuUW:`x11njtxf`,khDVqt:`xuxw1ft`,kkrTdU:`xt0e3qv`,kfSwDN:`x87ps6o`,$$css:!0},wide:{kB7OPa:`x9f619`,k7Eaqz:`xt7fyls`,kVQacm:`xb3r6kr`,k1xSpc:`x78zum5`,kzqmXN:`xh8yej3`,ks0D6T:`x193iq5w`,kZKoxP:`x1fgtraw`,kUOVxO:`xrxpjvj`,kjj79g:`x1qughib`,$$css:!0},open:{kkrTdU:`x1ypdohk`,$$css:!0},changed:{kWkggS:`x235pk4`,kMwMTN:`xr46axq`,$$css:!0},todo:{kWkggS:`xjbqb8w`,ksu8eU:`xbsl7fq`,kVAM5u:`xgcsv5v`,kMwMTN:`xddlp02`,$$css:!0},quiet:{kSiTet:`xf9vgkq`,$$css:!0}},lPe={content:{"--lobe-popover-viewport-inline-padding":`4px`,paddingBlock:4}};function uPe(e){let{t}=n(),r=e.options.find(t=>t.value===e.choice)?.label,i=e.text??r??null,a=i??t(`asks.noAnswer`);return e.state===`submitted`?{label:a,title:t(`asks.submitted`,{label:a})}:e.state===`settled`?{label:a,title:t(`asks.settled`,{label:a})}:i===null?{label:e.options.length?t(`asks.toChoose`):t(`asks.toFill`)}:e.changed?{label:i,title:e.recommend||e.text?t(`asks.changed`,{label:i}):t(`asks.chosen`,{label:i})}:{label:i}}function dPe({view:e,canAnswer:t,onAnswer:n,wide:r,phone:i}){let{label:a,title:s}=uPe(e),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(e.text??``),f=(0,G.useRef)(null),p=t&&e.state===`draft`,h=!!(p&&i&&c),[g,_]=uz(h),v=e.choice===null&&e.text===null,y=(e,t)=>{n(e,t),l(!1)};dz(f,e=>{e.target.dataset.askTag!==void 0&&p&&(e.key===`Escape`&&l(!1),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l(e=>!e)))});let b=(0,K.jsx)(cPe,{draft:u,label:a,phone:i,view:e,onChoose:y,onClose:()=>l(!1),onDraft:d}),x=(0,K.jsxs)(`span`,{"data-ask-tag":e.id,"data-changed":e.changed?`true`:`false`,"data-state":e.state,"data-wide":r?`true`:void 0,role:p?`button`:void 0,tabIndex:p?0:void 0,title:s,onClick:i&&p?()=>l(e=>!e):void 0,...o(pz.tag,r&&pz.wide,p&&pz.open,e.changed&&pz.changed,e.state===`draft`&&v&&pz.todo,(e.state===`submitted`||e.state===`settled`)&&pz.quiet),children:[(0,K.jsxs)(`span`,{...{0:{className:`xeuugli xb3r6kr xlyipyv`},1:{className:`xeuugli xb3r6kr xlyipyv x1iyjqo2 xnalus7`}}[!!r|0],children:[e.state===`settled`&&(0,K.jsx)(Ute,{size:11,className:`x2fvf9 x19693qn`}),a]}),p&&(0,K.jsx)(m,{size:11})]});return(0,K.jsxs)(`span`,{ref:f,...{0:{className:`x1rg5ohu x193iq5w x11njtxf`},1:{className:`x193iq5w x11njtxf x1lliihq xh8yej3 xeuugli`}}[!!r|0],contentEditable:!1,children:[p&&!i?(0,K.jsx)(Pte,{content:b,nativeButton:!1,open:c,placement:`bottomLeft`,styles:lPe,trigger:`click`,onOpenChange:l,children:x}):x,g&&(0,Gi.createPortal)((0,K.jsx)(`div`,{"data-ask-sheet":!0,className:`xixxii4 x10a8y8t xf5e64p`,children:(0,K.jsx)(bne,{header:(0,K.jsx)(`div`,{className:`x17qtykl xwib8y2 x1jvydc1 x1s688f`,children:a}),open:h,snap:.5,snaps:[0,.5],onExited:_,onScrim:()=>l(!1),onSnap:e=>e===0&&l(!1),children:(0,K.jsx)(`div`,{className:`xaope02 xwxc41k x1jvydc1`,children:b})})}),document.body)]})}var fPe=e=>{let t=e.closest(`td, th`);return!!t&&(t.textContent??``).trim()===(e.textContent??``).trim()};function pPe({ask:e}){let t=(0,G.useContext)(Aj),n=t?.threads,r=(0,G.useMemo)(()=>bA([_A(e,``)],n??[])[0],[e,n]),i=(0,G.useRef)(null),[a,o]=(0,G.useState)(!1);return(0,G.useLayoutEffect)(()=>{i.current&&o(fPe(i.current))}),(0,K.jsxs)(`span`,{"data-ask-slot":e.askId,ref:i,style:a?{display:`block`}:void 0,children:[(0,K.jsx)(dPe,{canAnswer:!!t?.canAnswer,phone:t?.phone,view:r,wide:a,onAnswer:(n,r)=>t?.send({op:`create`,blockId:`*`,quote:``,ask:e.askId,choice:n,answer:r,text:r??n??``})}),r.state===`settled`&&r.note&&(0,K.jsx)(oPe,{by:r.noteBy,text:r.note})]})}var mz=class e extends wr{__ask;static getType(){return`ask`}static clone(t){return new e(t.__ask,t.__key)}static importJSON(t){let{type:n,version:r,...i}=t;return new e(i).updateFromJSON(t)}constructor(e={askId:``,options:[]},t){super(t),this.__ask=e}exportJSON(){return{...super.exportJSON(),...this.__ask,type:`ask`,version:1}}createDOM(){return document.createElement(`span`)}updateDOM(){return!1}isInline(){return!0}isKeyboardSelectable(){return!1}getTextContent(){return``}decorate(){return(0,K.jsx)(pPe,{ask:this.exportJSON()})}};function mPe({reading:e,children:t}){return e?(0,K.jsxs)(`ruby`,{className:Fj(Nj.ruby,Pj.ruby),children:[t,(0,K.jsx)(`rt`,{className:Fj(Nj.rubyRt,Pj.rubyRt),children:e})]}):(0,K.jsx)(K.Fragment,{children:t})}function hz(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function hPe(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function gz(e){let t,n,r;e.length===2?(t=e===hz||e===hPe?e:gPe,n=e,r=e):(t=hz,n=(t,n)=>hz(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<0?i=t+1:a=t}while(i<a)}return i}function a(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<=0?i=t+1:a=t}while(i<a)}return i}function o(e,t,n=0,a=e.length){let o=i(e,t,n,a-1);return o>n&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function gPe(){return 0}function _Pe(e){return e===null?NaN:+e}var _z=gz(hz),vPe=_z.right;_z.left,gz(_Pe).center;var vz=class extends Map{constructor(e,t=xPe){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let[t,n]of e)this.set(t,n)}get(e){return super.get(yz(this,e))}has(e){return super.has(yz(this,e))}set(e,t){return super.set(yPe(this,e),t)}delete(e){return super.delete(bPe(this,e))}};function yz({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function yPe({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function bPe({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function xPe(e){return typeof e==`object`&&e?e.valueOf():e}Array.prototype.slice;var SPe=Math.sqrt(50),CPe=Math.sqrt(10),wPe=Math.sqrt(2);function bz(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=SPe?10:a>=CPe?5:a>=wPe?2:1,s,c,l;return i<0?(l=10**-i/o,s=Math.round(e*l),c=Math.round(t*l),s/l<e&&++s,c/l>t&&--c,l=-l):(l=10**i*o,s=Math.round(e/l),c=Math.round(t/l),s*l<e&&++s,c*l>t&&--c),c<s&&.5<=n&&n<2?bz(e,t,n*2):[s,c,l]}function TPe(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];let r=t<e,[i,a,o]=r?bz(t,e,n):bz(e,t,n);if(!(a>=i))return[];let s=a-i+1,c=Array(s);if(r){if(o<0)for(let e=0;e<s;++e)c[e]=(a-e)/-o;else for(let e=0;e<s;++e)c[e]=(a-e)*o}else if(o<0)for(let e=0;e<s;++e)c[e]=(i+e)/-o;else for(let e=0;e<s;++e)c[e]=(i+e)*o;return c}function xz(e,t,n){return t=+t,e=+e,n=+n,bz(e,t,n)[2]}function EPe(e,t,n){t=+t,e=+e,n=+n;let r=t<e,i=r?xz(t,e,n):xz(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}function DPe(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r<i;)a[r]=e+r*n;return a}function Sz(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e)}return this}var Cz=Symbol(`implicit`);function wz(){var e=new vz,t=[],n=[],r=Cz;function i(i){let a=e.get(i);if(a===void 0){if(r!==Cz)return r;e.set(i,a=t.push(i)-1)}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new vz;for(let r of n)e.has(r)||e.set(r,t.push(r)-1);return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return wz(t,n).unknown(r)},Sz.apply(i,arguments),i}function Tz(){var e=wz().unknown(void 0),t=e.domain,n=e.range,r=0,i=1,a,o,s=!1,c=0,l=0,u=.5;delete e.unknown;function d(){var e=t().length,d=i<r,f=d?i:r,p=d?r:i;a=(p-f)/Math.max(1,e-c+l*2),s&&(a=Math.floor(a)),f+=(p-f-a*(e-c))*u,o=a*(1-c),s&&(f=Math.round(f),o=Math.round(o));var m=DPe(e).map(function(e){return f+a*e});return n(d?m.reverse():m)}return e.domain=function(e){return arguments.length?(t(e),d()):t()},e.range=function(e){return arguments.length?([r,i]=e,r=+r,i=+i,d()):[r,i]},e.rangeRound=function(e){return[r,i]=e,r=+r,i=+i,s=!0,d()},e.bandwidth=function(){return o},e.step=function(){return a},e.round=function(e){return arguments.length?(s=!!e,d()):s},e.padding=function(e){return arguments.length?(c=Math.min(1,l=+e),d()):c},e.paddingInner=function(e){return arguments.length?(c=Math.min(1,e),d()):c},e.paddingOuter=function(e){return arguments.length?(l=+e,d()):l},e.align=function(e){return arguments.length?(u=Math.max(0,Math.min(1,e)),d()):u},e.copy=function(){return Tz(t(),[r,i]).round(s).paddingInner(c).paddingOuter(l).align(u)},Sz.apply(d(),arguments)}function Ez(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Dz(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Oz(){}var kz=.7,Az=1/kz,jz=`\\s*([+-]?\\d+)\\s*`,Mz=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,Nz=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,OPe=/^#([0-9a-f]{3,8})$/,kPe=RegExp(`^rgb\\(${jz},${jz},${jz}\\)$`),APe=RegExp(`^rgb\\(${Nz},${Nz},${Nz}\\)$`),jPe=RegExp(`^rgba\\(${jz},${jz},${jz},${Mz}\\)$`),MPe=RegExp(`^rgba\\(${Nz},${Nz},${Nz},${Mz}\\)$`),NPe=RegExp(`^hsl\\(${Mz},${Nz},${Nz}\\)$`),PPe=RegExp(`^hsla\\(${Mz},${Nz},${Nz},${Mz}\\)$`),Pz={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Ez(Oz,Lz,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Fz,formatHex:Fz,formatHex8:FPe,formatHsl:IPe,formatRgb:Iz,toString:Iz});function Fz(){return this.rgb().formatHex()}function FPe(){return this.rgb().formatHex8()}function IPe(){return Yz(this).formatHsl()}function Iz(){return this.rgb().formatRgb()}function Lz(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=OPe.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Rz(t):n===3?new Hz(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?zz(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?zz(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=kPe.exec(e))?new Hz(t[1],t[2],t[3],1):(t=APe.exec(e))?new Hz(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=jPe.exec(e))?zz(t[1],t[2],t[3],t[4]):(t=MPe.exec(e))?zz(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=NPe.exec(e))?Jz(t[1],t[2]/100,t[3]/100,1):(t=PPe.exec(e))?Jz(t[1],t[2]/100,t[3]/100,t[4]):Pz.hasOwnProperty(e)?Rz(Pz[e]):e===`transparent`?new Hz(NaN,NaN,NaN,0):null}function Rz(e){return new Hz(e>>16&255,e>>8&255,e&255,1)}function zz(e,t,n,r){return r<=0&&(e=t=n=NaN),new Hz(e,t,n,r)}function Bz(e){return e instanceof Oz||(e=Lz(e)),e?(e=e.rgb(),new Hz(e.r,e.g,e.b,e.opacity)):new Hz}function Vz(e,t,n,r){return arguments.length===1?Bz(e):new Hz(e,t,n,r??1)}function Hz(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Ez(Hz,Vz,Dz(Oz,{brighter(e){return e=e==null?Az:Az**+e,new Hz(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?kz:kz**+e,new Hz(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Hz(Kz(this.r),Kz(this.g),Kz(this.b),Gz(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Uz,formatHex:Uz,formatHex8:LPe,formatRgb:Wz,toString:Wz}));function Uz(){return`#${qz(this.r)}${qz(this.g)}${qz(this.b)}`}function LPe(){return`#${qz(this.r)}${qz(this.g)}${qz(this.b)}${qz((isNaN(this.opacity)?1:this.opacity)*255)}`}function Wz(){let e=Gz(this.opacity);return`${e===1?`rgb(`:`rgba(`}${Kz(this.r)}, ${Kz(this.g)}, ${Kz(this.b)}${e===1?`)`:`, ${e})`}`}function Gz(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Kz(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function qz(e){return e=Kz(e),(e<16?`0`:``)+e.toString(16)}function Jz(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Zz(e,t,n,r)}function Yz(e){if(e instanceof Zz)return new Zz(e.h,e.s,e.l,e.opacity);if(e instanceof Oz||(e=Lz(e)),!e)return new Zz;if(e instanceof Zz)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new Zz(o,s,c,e.opacity)}function Xz(e,t,n,r){return arguments.length===1?Yz(e):new Zz(e,t,n,r??1)}function Zz(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Ez(Zz,Xz,Dz(Oz,{brighter(e){return e=e==null?Az:Az**+e,new Zz(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?kz:kz**+e,new Zz(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new Hz(eB(e>=240?e-240:e+120,i,r),eB(e,i,r),eB(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Zz(Qz(this.h),$z(this.s),$z(this.l),Gz(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=Gz(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Qz(this.h)}, ${$z(this.s)*100}%, ${$z(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Qz(e){return e=(e||0)%360,e<0?e+360:e}function $z(e){return Math.max(0,Math.min(1,e||0))}function eB(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var tB=Math.PI/180,nB=180/Math.PI,rB=18,iB=.96422,aB=1,oB=.82521,sB=4/29,cB=6/29,lB=3*cB*cB,RPe=cB*cB*cB;function uB(e){if(e instanceof fB)return new fB(e.l,e.a,e.b,e.opacity);if(e instanceof vB)return yB(e);e instanceof Hz||(e=Bz(e));var t=gB(e.r),n=gB(e.g),r=gB(e.b),i=pB((.2225045*t+.7168786*n+.0606169*r)/aB),a,o;return t===n&&n===r?a=o=i:(a=pB((.4360747*t+.3850649*n+.1430804*r)/iB),o=pB((.0139322*t+.0971045*n+.7141733*r)/oB)),new fB(116*i-16,500*(a-i),200*(i-o),e.opacity)}function dB(e,t,n,r){return arguments.length===1?uB(e):new fB(e,t,n,r??1)}function fB(e,t,n,r){this.l=+e,this.a=+t,this.b=+n,this.opacity=+r}Ez(fB,dB,Dz(Oz,{brighter(e){return new fB(this.l+rB*(e??1),this.a,this.b,this.opacity)},darker(e){return new fB(this.l-rB*(e??1),this.a,this.b,this.opacity)},rgb(){var e=(this.l+16)/116,t=isNaN(this.a)?e:e+this.a/500,n=isNaN(this.b)?e:e-this.b/200;return t=iB*mB(t),e=aB*mB(e),n=oB*mB(n),new Hz(hB(3.1338561*t-1.6168667*e-.4906146*n),hB(-.9787684*t+1.9161415*e+.033454*n),hB(.0719453*t-.2289914*e+1.4052427*n),this.opacity)}}));function pB(e){return e>RPe?e**(1/3):e/lB+sB}function mB(e){return e>cB?e*e*e:lB*(e-sB)}function hB(e){return 255*(e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055)}function gB(e){return(e/=255)<=.04045?e/12.92:((e+.055)/1.055)**2.4}function zPe(e){if(e instanceof vB)return new vB(e.h,e.c,e.l,e.opacity);if(e instanceof fB||(e=uB(e)),e.a===0&&e.b===0)return new vB(NaN,0<e.l&&e.l<100?0:NaN,e.l,e.opacity);var t=Math.atan2(e.b,e.a)*nB;return new vB(t<0?t+360:t,Math.sqrt(e.a*e.a+e.b*e.b),e.l,e.opacity)}function _B(e,t,n,r){return arguments.length===1?zPe(e):new vB(e,t,n,r??1)}function vB(e,t,n,r){this.h=+e,this.c=+t,this.l=+n,this.opacity=+r}function yB(e){if(isNaN(e.h))return new fB(e.l,0,0,e.opacity);var t=e.h*tB;return new fB(e.l,Math.cos(t)*e.c,Math.sin(t)*e.c,e.opacity)}Ez(vB,_B,Dz(Oz,{brighter(e){return new vB(this.h,this.c,this.l+rB*(e??1),this.opacity)},darker(e){return new vB(this.h,this.c,this.l-rB*(e??1),this.opacity)},rgb(){return yB(this).rgb()}}));var bB=-.14861,xB=1.78277,SB=-.29227,CB=-.90649,wB=1.97294,TB=wB*CB,EB=wB*xB,DB=xB*SB-CB*bB;function BPe(e){if(e instanceof kB)return new kB(e.h,e.s,e.l,e.opacity);e instanceof Hz||(e=Bz(e));var t=e.r/255,n=e.g/255,r=e.b/255,i=(DB*r+TB*t-EB*n)/(DB+TB-EB),a=r-i,o=(wB*(n-i)-SB*a)/CB,s=Math.sqrt(o*o+a*a)/(wB*i*(1-i)),c=s?Math.atan2(o,a)*nB-120:NaN;return new kB(c<0?c+360:c,s,i,e.opacity)}function OB(e,t,n,r){return arguments.length===1?BPe(e):new kB(e,t,n,r??1)}function kB(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Ez(kB,OB,Dz(Oz,{brighter(e){return e=e==null?Az:Az**+e,new kB(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?kz:kz**+e,new kB(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=isNaN(this.h)?0:(this.h+120)*tB,t=+this.l,n=isNaN(this.s)?0:this.s*t*(1-t),r=Math.cos(e),i=Math.sin(e);return new Hz(255*(t+n*(bB*r+xB*i)),255*(t+n*(SB*r+CB*i)),255*(t+wB*r*n),this.opacity)}}));var AB=e=>()=>e;function jB(e,t){return function(n){return e+n*t}}function VPe(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function HPe(e,t){var n=t-e;return n?jB(e,n>180||n<-180?n-360*Math.round(n/360):n):AB(isNaN(e)?t:e)}function UPe(e){return(e=+e)==1?MB:function(t,n){return n-t?VPe(t,n,e):AB(isNaN(t)?n:t)}}function MB(e,t){var n=t-e;return n?jB(e,n):AB(isNaN(e)?t:e)}var NB=(function e(t){var n=UPe(t);function r(e,t){var r=n((e=Vz(e)).r,(t=Vz(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=MB(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function WPe(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function GPe(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function KPe(e,t){for(var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o=0;o<r;++o)i[o]=LB(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function qPe(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function PB(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function JPe(e,t){var n={},r={},i;for(i in typeof e==`object`&&e||(e={}),typeof t==`object`&&t||(t={}),t)i in e?n[i]=LB(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var FB=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,IB=new RegExp(FB.source,`g`);function YPe(e){return function(){return e}}function XPe(e){return function(t){return e(t)+``}}function ZPe(e,t){var n=FB.lastIndex=IB.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=FB.exec(e))&&(i=IB.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:PB(r,i)})),n=IB.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?XPe(c[0].x):YPe(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function LB(e,t){var n=typeof t,r;return t==null||n===`boolean`?AB(t):(n===`number`?PB:n===`string`?(r=Lz(t))?(t=r,NB):ZPe:t instanceof Lz?NB:t instanceof Date?qPe:GPe(t)?WPe:Array.isArray(t)?KPe:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?JPe:PB)(e,t)}function QPe(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var $Pe=1e-12;function RB(e){return((e=Math.exp(e))+1/e)/2}function eFe(e){return((e=Math.exp(e))-1/e)/2}function tFe(e){return((e=Math.exp(2*e))-1)/(e+1)}(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<$Pe)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=RB(y),c=s/(n*g)*(i*tFe(t*r+y)-eFe(y));return[a+c*d,o+c*f,s*i/RB(t*r+y)]}}return m.duration=Math.abs(h)*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4);function zB(e){return(function t(n){n=+n;function r(t,r){var i=e((t=OB(t)).h,(r=OB(r)).h),a=MB(t.s,r.s),o=MB(t.l,r.l),s=MB(t.opacity,r.opacity);return function(e){return t.h=i(e),t.s=a(e),t.l=o(e**+n),t.opacity=s(e),t+``}}return r.gamma=t,r})(1)}zB(HPe),zB(MB);function nFe(e){return function(){return e}}function rFe(e){return+e}var BB=[0,1];function VB(e){return e}function HB(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:nFe(isNaN(t)?NaN:.5)}function iFe(e,t){var n;return e>t&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function aFe(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i<r?(r=HB(i,r),a=n(o,a)):(r=HB(r,i),a=n(a,o)),function(e){return a(r(e))}}function oFe(e,t,n){var r=Math.min(e.length,t.length)-1,i=Array(r),a=Array(r),o=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<r;)i[o]=HB(e[o],e[o+1]),a[o]=n(t[o],t[o+1]);return function(t){var n=vPe(e,t,1,r)-1;return a[n](i[n](t))}}function sFe(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function cFe(){var e=BB,t=BB,n=LB,r,i,a,o=VB,s,c,l;function u(){var n=Math.min(e.length,t.length);return o!==VB&&(o=iFe(e[0],e[n-1])),s=n>2?oFe:aFe,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),PB))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,rFe),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=QPe,u()},d.clamp=function(e){return arguments.length?(o=e?!0:VB,u()):o!==VB},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function lFe(){return cFe()(VB,VB)}function uFe(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function UB(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function WB(e){return e=UB(Math.abs(e)),e?e[1]:NaN}function dFe(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function fFe(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var pFe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function GB(e){if(!(t=pFe.exec(e)))throw Error(`invalid format: `+e);var t;return new KB({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}GB.prototype=KB.prototype;function KB(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}KB.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type};function mFe(e){out:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case`.`:r=i=n;break;case`0`:r===0&&(r=n),i=n;break;default:if(!+e[n])break out;r>0&&(r=0)}return r>0?e.slice(0,r)+e.slice(i+1):e}var qB;function hFe(e,t){var n=UB(e,t);if(!n)return qB=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(qB=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+UB(e,Math.max(0,t+a-1))[0]}function JB(e,t){var n=UB(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var YB={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:uFe,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>JB(e*100,t),r:JB,s:hFe,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function XB(e){return e}var ZB=Array.prototype.map,QB=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function gFe(e){var t=e.grouping===void 0||e.thousands===void 0?XB:dFe(ZB.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?XB:fFe(ZB.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=GB(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):YB[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=YB[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=mFe(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&qB!==void 0?QB[8+qB/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++o<l;)if(p=e.charCodeAt(o),48>p||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T<h?Array(h-T+1).join(u):``;switch(g&&m&&(e=t(E+e,E.length?h-r.length:1/0),E=``),d){case`<`:e=n+e+r+E;break;case`=`:e=n+E+e+r;break;case`^`:e=E.slice(0,T=E.length>>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(WB(t)/3)))*3,r=10**-n,i=l((e=GB(e),e.type=`f`,e),{suffix:QB[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var $B,eV,tV;_Fe({thousands:`,`,grouping:[3],currency:[`$`,``]});function _Fe(e){return $B=gFe(e),eV=$B.format,tV=$B.formatPrefix,$B}function vFe(e){return Math.max(0,-WB(Math.abs(e)))}function yFe(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(WB(t)/3)))*3-WB(Math.abs(e)))}function bFe(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,WB(t)-WB(e))+1}function xFe(e,t,n,r){var i=EPe(e,t,n),a;switch(r=GB(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=yFe(i,o))&&(r.precision=a),tV(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=bFe(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=vFe(i))&&(r.precision=a-(r.type===`%`)*2)}return eV(r)}function SFe(e){var t=e.domain;return e.ticks=function(e){var n=t();return TPe(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return xFe(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s<o&&(l=o,o=s,s=l,l=i,i=a,a=l);u-->0;){if(l=xz(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function nV(){var e=lFe();return e.copy=function(){return sFe(e,nV())},Sz.apply(e,arguments),SFe(e)}function CFe(e,t){t.domain&&(`nice`in e||`quantiles`in e||`padding`in e,e.domain(t.domain))}function wFe(e,t){t.range&&(`padding`in e,e.range(t.range))}function TFe(e,t){`align`in e&&`align`in t&&t.align!==void 0&&e.align(t.align)}function EFe(e,t){`base`in e&&`base`in t&&t.base!==void 0&&e.base(t.base)}function DFe(e,t){`clamp`in e&&`clamp`in t&&t.clamp!==void 0&&e.clamp(t.clamp)}function OFe(e,t){`constant`in e&&`constant`in t&&t.constant!==void 0&&e.constant(t.constant)}function kFe(e,t){`exponent`in e&&`exponent`in t&&t.exponent!==void 0&&e.exponent(t.exponent)}var rV=e=>()=>e;function iV(e,t){return function(n){return e+n*t}}function AFe(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function aV(e,t){var n=t-e;return n?iV(e,n>180||n<-180?n-360*Math.round(n/360):n):rV(isNaN(e)?t:e)}function jFe(e){return(e=+e)==1?oV:function(t,n){return n-t?AFe(t,n,e):rV(isNaN(t)?n:t)}}function oV(e,t){var n=t-e;return n?iV(e,n):rV(isNaN(e)?t:e)}var MFe=(function e(t){var n=jFe(t);function r(e,t){var r=n((e=Vz(e)).r,(t=Vz(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=oV(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function NFe(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}function sV(e){return function(t,n){var r=e((t=Xz(t)).h,(n=Xz(n)).h),i=oV(t.s,n.s),a=oV(t.l,n.l),o=oV(t.opacity,n.opacity);return function(e){return t.h=r(e),t.s=i(e),t.l=a(e),t.opacity=o(e),t+``}}}var PFe=sV(aV),FFe=sV(oV);function IFe(e,t){var n=oV((e=dB(e)).l,(t=dB(t)).l),r=oV(e.a,t.a),i=oV(e.b,t.b),a=oV(e.opacity,t.opacity);return function(t){return e.l=n(t),e.a=r(t),e.b=i(t),e.opacity=a(t),e+``}}function cV(e){return function(t,n){var r=e((t=_B(t)).h,(n=_B(n)).h),i=oV(t.c,n.c),a=oV(t.l,n.l),o=oV(t.opacity,n.opacity);return function(e){return t.h=r(e),t.c=i(e),t.l=a(e),t.opacity=o(e),t+``}}}var LFe=cV(aV),RFe=cV(oV);function lV(e){return(function t(n){n=+n;function r(t,r){var i=e((t=OB(t)).h,(r=OB(r)).h),a=oV(t.s,r.s),o=oV(t.l,r.l),s=oV(t.opacity,r.opacity);return function(e){return t.h=i(e),t.s=a(e),t.l=o(e**+n),t.opacity=s(e),t+``}}return r.gamma=t,r})(1)}var uV={lab:IFe,hcl:LFe,"hcl-long":RFe,hsl:PFe,"hsl-long":FFe,cubehelix:lV(aV),"cubehelix-long":lV(oV),rgb:MFe};function zFe(e){switch(e){case`lab`:case`hcl`:case`hcl-long`:case`hsl`:case`hsl-long`:case`cubehelix`:case`cubehelix-long`:case`rgb`:return uV[e]}let{type:t,gamma:n}=e,r=uV[t];return n===void 0?r:r.gamma(n)}function BFe(e,t){if(`interpolate`in t&&`interpolate`in e&&t.interpolate!==void 0){let n=zFe(t.interpolate);e.interpolate(n)}}var dV=new Date,fV=new Date;function pV(e,t,n,r){function i(t){return e(t=arguments.length===0?new Date:new Date(+t)),t}return i.floor=t=>(e(t=new Date(+t)),t),i.ceil=n=>(e(n=new Date(n-1)),t(n,1),e(n),n),i.round=e=>{let t=i(e),n=i.ceil(e);return e-t<n-e?t:n},i.offset=(e,n)=>(t(e=new Date(+e),n==null?1:Math.floor(n)),e),i.range=(n,r,a)=>{let o=[];if(n=i.ceil(n),a=a==null?1:Math.floor(a),!(n<r)||!(a>0))return o;let s;do o.push(s=new Date(+n)),t(n,a),e(n);while(s<n&&n<r);return o},i.filter=n=>pV(t=>{if(t>=t)for(;e(t),!n(t);)t.setTime(t-1)},(e,r)=>{if(e>=e){if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););}}),n&&(i.count=(t,r)=>(dV.setTime(+t),fV.setTime(+r),e(dV),e(fV),Math.floor(n(dV,fV))),i.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?i.filter(r?t=>r(t)%e===0:t=>i.count(0,t)%e===0):i)),i}var mV=1e3,hV=mV*60,gV=hV*60,_V=gV*24,vV=_V*7,yV=pV(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*mV)},(e,t)=>(t-e)/mV,e=>e.getUTCSeconds());yV.range;var bV=pV(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*mV)},(e,t)=>{e.setTime(+e+t*hV)},(e,t)=>(t-e)/hV,e=>e.getMinutes());bV.range;var xV=pV(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*hV)},(e,t)=>(t-e)/hV,e=>e.getUTCMinutes());xV.range;var SV=pV(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*mV-e.getMinutes()*hV)},(e,t)=>{e.setTime(+e+t*gV)},(e,t)=>(t-e)/gV,e=>e.getHours());SV.range;var CV=pV(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*gV)},(e,t)=>(t-e)/gV,e=>e.getUTCHours());CV.range;var wV=pV(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*hV)/_V,e=>e.getDate()-1);wV.range;var TV=pV(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/_V,e=>e.getUTCDate()-1);TV.range,pV(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/_V,e=>Math.floor(e/_V)).range;function EV(e){return pV(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(e,t)=>{e.setDate(e.getDate()+t*7)},(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*hV)/vV)}var DV=EV(0),VFe=EV(1),HFe=EV(2),UFe=EV(3),WFe=EV(4),GFe=EV(5),KFe=EV(6);DV.range,VFe.range,HFe.range,UFe.range,WFe.range,GFe.range,KFe.range;function OV(e){return pV(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t*7)},(e,t)=>(t-e)/vV)}var kV=OV(0),qFe=OV(1),JFe=OV(2),YFe=OV(3),XFe=OV(4),ZFe=OV(5),QFe=OV(6);kV.range,qFe.range,JFe.range,YFe.range,XFe.range,ZFe.range,QFe.range;var AV=pV(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());AV.range;var jV=pV(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());jV.range;var MV=pV(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());MV.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:pV(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)}),MV.range;var NV=pV(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());NV.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:pV(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)}),NV.range;var $Fe=new Date(Date.UTC(2020,1,2,3,4,5)),eIe=`%Y-%m-%d %H:%M`;function tIe(e){return e.tickFormat(1,eIe)($Fe)===`2020-02-02 03:04`}var PV={day:wV,hour:SV,minute:bV,month:AV,second:yV,week:DV,year:MV},FV={day:TV,hour:CV,minute:xV,month:jV,second:yV,week:kV,year:NV};function nIe(e,t){if(`nice`in t&&t.nice!==void 0&&`nice`in e){let{nice:n}=t;if(typeof n==`boolean`)n&&e.nice();else if(typeof n==`number`)e.nice(n);else{let t=e,r=tIe(t);if(typeof n==`string`)t.nice(r?FV[n]:PV[n]);else{let{interval:e,step:i}=n,a=(r?FV[e]:PV[e]).every(i);a!=null&&t.nice(a)}}}}function rIe(e,t){`padding`in e&&`padding`in t&&t.padding!==void 0&&e.padding(t.padding),`paddingInner`in e&&`paddingInner`in t&&t.paddingInner!==void 0&&e.paddingInner(t.paddingInner),`paddingOuter`in e&&`paddingOuter`in t&&t.paddingOuter!==void 0&&e.paddingOuter(t.paddingOuter)}function iIe(e,t){if(t.reverse){let t=e.range().slice().reverse();`padding`in e,e.range(t)}}function aIe(e,t){`round`in t&&t.round!==void 0&&(t.round&&`interpolate`in t&&t.interpolate!==void 0?console.warn(`[visx/scale/applyRound] ignoring round: scale config contains round and interpolate. only applying interpolate. config:`,t):`round`in e?e.round(t.round):`interpolate`in e&&t.round&&e.interpolate(NFe))}function oIe(e,t){`unknown`in e&&`unknown`in t&&t.unknown!==void 0&&e.unknown(t.unknown)}function sIe(e,t){if(`zero`in t&&t.zero===!0){let[t,n]=e.domain(),r=n<t,[i,a]=r?[n,t]:[t,n],o=[Math.min(0,i),Math.max(0,a)];e.domain(r?o.reverse():o)}}var cIe=[`domain`,`nice`,`zero`,`interpolate`,`round`,`range`,`reverse`,`align`,`base`,`clamp`,`constant`,`exponent`,`padding`,`unknown`],lIe={domain:CFe,nice:nIe,zero:sIe,interpolate:BFe,round:aIe,align:TFe,base:EFe,clamp:DFe,constant:OFe,exponent:kFe,padding:rIe,range:wFe,reverse:iIe,unknown:oIe};function IV(){let e=new Set([...arguments]),t=cIe.filter(t=>e.has(t));return function(e,n){return n!==void 0&&t.forEach(t=>{lIe[t](e,n)}),e}}var uIe=IV(`domain`,`range`,`reverse`,`align`,`padding`,`round`);function dIe(e){return uIe(Tz(),e)}var fIe=IV(`domain`,`range`,`reverse`,`clamp`,`interpolate`,`nice`,`round`,`zero`);function LV(e){return fIe(nV(),e)}function RV(e){return function(){return e}}var zV=Math.abs,BV=Math.atan2,VV=Math.cos,pIe=Math.max,HV=Math.min,UV=Math.sin,WV=Math.sqrt,GV=Math.PI,KV=GV/2,qV=2*GV;function mIe(e){return e>1?0:e<-1?GV:Math.acos(e)}function JV(e){return e>=1?KV:e<=-1?-KV:Math.asin(e)}var YV=Math.PI,XV=2*YV,ZV=1e-6,hIe=XV-ZV;function QV(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function gIe(e){let t=Math.floor(e);if(!(t>=0))throw Error(`invalid digits: ${e}`);if(t>15)return QV;let n=10**t;return function(e){this._+=e[0];for(let t=1,r=e.length;t<r;++t)this._+=Math.round(arguments[t]*n)/n+e[t]}}function $V(e,t,n,r){return e===n&&t===r}function _Ie(e){let t=Math.floor(e);if(!(t<=15))return $V;let n=10**t,r=function(e){return Math.round(e*n)};return function(e,t,n,i){return r(e)===r(n)&&r(t)===r(i)}}var eH=class{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._=``,this._append=e==null?QV:gIe(e),this._equal=e==null?$V:_Ie(e)}moveTo(e,t){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,t){this._append`L${this._x1=+e},${this._y1=+t}`}quadraticCurveTo(e,t,n,r){this._append`Q${+e},${+t},${this._x1=+n},${this._y1=+r}`}bezierCurveTo(e,t,n,r,i,a){this._append`C${+e},${+t},${+n},${+r},${this._x1=+i},${this._y1=+a}`}arcTo(e,t,n,r,i){if(e=+e,t=+t,n=+n,r=+r,i=+i,i<0)throw Error(`negative radius: ${i}`);let a=this._x1,o=this._y1,s=n-e,c=r-t,l=a-e,u=o-t,d=l*l+u*u;if(this._x1===null)this._append`M${this._x1=e},${this._y1=t}`;else if(d>ZV){if(!(Math.abs(u*s-c*l)>ZV)||!i)this._append`L${this._x1=e},${this._y1=t}`;else{let f=n-a,p=r-o,m=s*s+c*c,h=f*f+p*p,g=Math.sqrt(m),_=Math.sqrt(d),v=i*Math.tan((YV-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>ZV&&this._append`L${e+y*l},${t+y*u}`,this._append`A${i},${i},0,0,${+(u*f>l*p)},${this._x1=e+b*s},${this._y1=t+b*c}`}}}arc(e,t,n,r,i,a){if(e=+e,t=+t,n=+n,a=!!a,n<0)throw Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,d=a?r-i:i-r;if(this._x1===null?this._append`M${c},${l}`:(Math.abs(this._x1-c)>ZV||Math.abs(this._y1-l)>ZV)&&this._append`L${c},${l}`,n){if(d<0&&(d=d%XV+XV),d>hIe)this._append`A${n},${n},0,1,${u},${e-o},${t-s}A${n},${n},0,1,${u},${this._x1=c},${this._y1=l}`;else if(d>ZV){let a=e+n*Math.cos(i),o=t+n*Math.sin(i);if(d>=YV&&this._equal(c,l,a,o)){d/=2;let i=r+d;this._append`A${n},${n},0,${+(d>=YV)},${u},${e+n*Math.cos(i)},${t+n*Math.sin(i)}`}this._append`A${n},${n},0,${+(d>=YV)},${u},${this._x1=a},${this._y1=o}`}}}rect(e,t,n,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}};eH.prototype;function tH(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{let e=Math.floor(n);if(!(e>=0))throw RangeError(`invalid digits: ${n}`);t=e}return e},()=>new eH(t)}function vIe(e){return e.innerRadius}function yIe(e){return e.outerRadius}function bIe(e){return e.startAngle}function xIe(e){return e.endAngle}function SIe(e){return e&&e.padAngle}function CIe(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function nH(e,t,n,r,i,a,o){var s=e-n,c=t-r,l=(o?a:-a)/WV(s*s+c*c),u=l*c,d=-l*s,f=e+u,p=t+d,m=n+u,h=r+d,g=(f+m)/2,_=(p+h)/2,v=m-f,y=h-p,b=v*v+y*y,x=i-a,S=f*h-m*p,C=(y<0?-1:1)*WV(pIe(0,x*x*b-S*S)),w=(S*y-v*C)/b,T=(-S*v-y*C)/b,E=(S*y+v*C)/b,D=(-S*v+y*C)/b,O=w-g,k=T-_,A=E-g,j=D-_;return O*O+k*k>A*A+j*j&&(w=E,T=D),{cx:w,cy:T,x01:-u,y01:-d,x11:w*(i/x-1),y11:T*(i/x-1)}}function wIe(){var e=vIe,t=yIe,n=RV(0),r=null,i=bIe,a=xIe,o=SIe,s=null,c=tH(l);function l(){var l,u,d=+e.apply(this,arguments),f=+t.apply(this,arguments),p=i.apply(this,arguments)-KV,m=a.apply(this,arguments)-KV,h=zV(m-p),g=m>p;if(s||=l=c(),f<d&&(u=f,f=d,d=u),!(f>1e-12))s.moveTo(0,0);else if(h>qV-1e-12)s.moveTo(f*VV(p),f*UV(p)),s.arc(0,0,f,p,m,!g),d>1e-12&&(s.moveTo(d*VV(m),d*UV(m)),s.arc(0,0,d,m,p,g));else{var _=p,v=m,y=p,b=m,x=h,S=h,C=o.apply(this,arguments)/2,w=C>1e-12&&(r?+r.apply(this,arguments):WV(d*d+f*f)),T=HV(zV(f-d)/2,+n.apply(this,arguments)),E=T,D=T,O,k;if(w>1e-12){var A=JV(w/d*UV(C)),j=JV(w/f*UV(C));(x-=A*2)>1e-12?(A*=g?1:-1,y+=A,b-=A):(x=0,y=b=(p+m)/2),(S-=j*2)>1e-12?(j*=g?1:-1,_+=j,v-=j):(S=0,_=v=(p+m)/2)}var M=f*VV(_),N=f*UV(_),P=d*VV(b),F=d*UV(b);if(T>1e-12){var I=f*VV(v),L=f*UV(v),R=d*VV(y),z=d*UV(y),B;if(h<GV){if(B=CIe(M,N,R,z,I,L,P,F)){var V=M-B[0],H=N-B[1],U=I-B[0],ee=L-B[1],te=1/UV(mIe((V*U+H*ee)/(WV(V*V+H*H)*WV(U*U+ee*ee)))/2),ne=WV(B[0]*B[0]+B[1]*B[1]);E=HV(T,(d-ne)/(te-1)),D=HV(T,(f-ne)/(te+1))}else E=D=0}}S>1e-12?D>1e-12?(O=nH(R,z,M,N,f,D,g),k=nH(I,L,P,F,f,D,g),s.moveTo(O.cx+O.x01,O.cy+O.y01),D<T?s.arc(O.cx,O.cy,D,BV(O.y01,O.x01),BV(k.y01,k.x01),!g):(s.arc(O.cx,O.cy,D,BV(O.y01,O.x01),BV(O.y11,O.x11),!g),s.arc(0,0,f,BV(O.cy+O.y11,O.cx+O.x11),BV(k.cy+k.y11,k.cx+k.x11),!g),s.arc(k.cx,k.cy,D,BV(k.y11,k.x11),BV(k.y01,k.x01),!g))):(s.moveTo(M,N),s.arc(0,0,f,_,v,!g)):s.moveTo(M,N),!(d>1e-12)||!(x>1e-12)?s.lineTo(P,F):E>1e-12?(O=nH(P,F,I,L,d,-E,g),k=nH(M,N,R,z,d,-E,g),s.lineTo(O.cx+O.x01,O.cy+O.y01),E<T?s.arc(O.cx,O.cy,E,BV(O.y01,O.x01),BV(k.y01,k.x01),!g):(s.arc(O.cx,O.cy,E,BV(O.y01,O.x01),BV(O.y11,O.x11),!g),s.arc(0,0,d,BV(O.cy+O.y11,O.cx+O.x11),BV(k.cy+k.y11,k.cx+k.x11),g),s.arc(k.cx,k.cy,E,BV(k.y11,k.x11),BV(k.y01,k.x01),!g))):s.arc(0,0,d,b,y,g)}if(s.closePath(),l)return s=null,l+``||null}return l.centroid=function(){var n=(+e.apply(this,arguments)+ +t.apply(this,arguments))/2,r=(+i.apply(this,arguments)+ +a.apply(this,arguments))/2-GV/2;return[VV(r)*n,UV(r)*n]},l.innerRadius=function(t){return arguments.length?(e=typeof t==`function`?t:RV(+t),l):e},l.outerRadius=function(e){return arguments.length?(t=typeof e==`function`?e:RV(+e),l):t},l.cornerRadius=function(e){return arguments.length?(n=typeof e==`function`?e:RV(+e),l):n},l.padRadius=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:RV(+e),l):r},l.startAngle=function(e){return arguments.length?(i=typeof e==`function`?e:RV(+e),l):i},l.endAngle=function(e){return arguments.length?(a=typeof e==`function`?e:RV(+e),l):a},l.padAngle=function(e){return arguments.length?(o=typeof e==`function`?e:RV(+e),l):o},l.context=function(e){return arguments.length?(s=e??null,l):s},l}Array.prototype.slice;function rH(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function iH(e){this._context=e}iH.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t)}}};function aH(e){return new iH(e)}function oH(e){return e[0]}function sH(e){return e[1]}function cH(e,t){var n=RV(!0),r=null,i=aH,a=null,o=tH(s);e=typeof e==`function`?e:e===void 0?oH:RV(e),t=typeof t==`function`?t:t===void 0?sH:RV(t);function s(s){var c,l=(s=rH(s)).length,u,d=!1,f;for(r??(a=i(f=o())),c=0;c<=l;++c)!(c<l&&n(u=s[c],c,s))===d&&((d=!d)?a.lineStart():a.lineEnd()),d&&a.point(+e(u,c,s),+t(u,c,s));if(f)return a=null,f+``||null}return s.x=function(t){return arguments.length?(e=typeof t==`function`?t:RV(+t),s):e},s.y=function(e){return arguments.length?(t=typeof e==`function`?e:RV(+e),s):t},s.defined=function(e){return arguments.length?(n=typeof e==`function`?e:RV(!!e),s):n},s.curve=function(e){return arguments.length?(i=e,r!=null&&(a=i(r)),s):i},s.context=function(e){return arguments.length?(e==null?r=a=null:a=i(r=e),s):r},s}function TIe(e,t,n){var r=null,i=RV(!0),a=null,o=aH,s=null,c=tH(l);e=typeof e==`function`?e:e===void 0?oH:RV(+e),t=typeof t==`function`?t:RV(t===void 0?0:+t),n=typeof n==`function`?n:n===void 0?sH:RV(+n);function l(l){var u,d,f,p=(l=rH(l)).length,m,h=!1,g,_=Array(p),v=Array(p);for(a??(s=o(g=c())),u=0;u<=p;++u){if(!(u<p&&i(m=l[u],u,l))===h){if(h=!h)d=u,s.areaStart(),s.lineStart();else{for(s.lineEnd(),s.lineStart(),f=u-1;f>=d;--f)s.point(_[f],v[f]);s.lineEnd(),s.areaEnd()}}h&&(_[u]=+e(m,u,l),v[u]=+t(m,u,l),s.point(r?+r(m,u,l):_[u],n?+n(m,u,l):v[u]))}if(g)return s=null,g+``||null}function u(){return cH().defined(i).curve(o).context(a)}return l.x=function(t){return arguments.length?(e=typeof t==`function`?t:RV(+t),r=null,l):e},l.x0=function(t){return arguments.length?(e=typeof t==`function`?t:RV(+t),l):e},l.x1=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:RV(+e),l):r},l.y=function(e){return arguments.length?(t=typeof e==`function`?e:RV(+e),n=null,l):t},l.y0=function(e){return arguments.length?(t=typeof e==`function`?e:RV(+e),l):t},l.y1=function(e){return arguments.length?(n=e==null?null:typeof e==`function`?e:RV(+e),l):n},l.lineX0=l.lineY0=function(){return u().x(e).y(t)},l.lineY1=function(){return u().x(e).y(n)},l.lineX1=function(){return u().x(r).y(t)},l.defined=function(e){return arguments.length?(i=typeof e==`function`?e:RV(!!e),l):i},l.curve=function(e){return arguments.length?(o=e,a!=null&&(s=o(a)),l):o},l.context=function(e){return arguments.length?(e==null?a=s=null:s=o(a=e),l):a},l}function EIe(e,t){return t<e?-1:t>e?1:t>=e?0:NaN}function DIe(e){return e}function OIe(){var e=DIe,t=EIe,n=null,r=RV(0),i=RV(qV),a=RV(0);function o(o){var s,c=(o=rH(o)).length,l,u,d=0,f=Array(c),p=Array(c),m=+r.apply(this,arguments),h=Math.min(qV,Math.max(-qV,i.apply(this,arguments)-m)),g,_=Math.min(Math.abs(h)/c,a.apply(this,arguments)),v=_*(h<0?-1:1),y;for(s=0;s<c;++s)(y=p[f[s]=s]=+e(o[s],s,o))>0&&(d+=y);for(t==null?n!=null&&f.sort(function(e,t){return n(o[e],o[t])}):f.sort(function(e,n){return t(p[e],p[n])}),s=0,u=d?(h-c*v)/d:0;s<c;++s,m=g)l=f[s],y=p[l],g=m+(y>0?y*u:0)+v,p[l]={data:o[l],index:s,value:y,startAngle:m,endAngle:g,padAngle:_};return p}return o.value=function(t){return arguments.length?(e=typeof t==`function`?t:RV(+t),o):e},o.sortValues=function(e){return arguments.length?(t=e,n=null,o):t},o.sort=function(e){return arguments.length?(n=e,t=null,o):n},o.startAngle=function(e){return arguments.length?(r=typeof e==`function`?e:RV(+e),o):r},o.endAngle=function(e){return arguments.length?(i=typeof e==`function`?e:RV(+e),o):i},o.padAngle=function(e){return arguments.length?(a=typeof e==`function`?e:RV(+e),o):a},o}function lH(e,t){if((o=e.length)>1)for(var n=1,r,i,a=e[t[0]],o,s=a.length;n<o;++n)for(i=a,a=e[t[n]],r=0;r<s;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function uH(e){for(var t=e.length,n=Array(t);--t>=0;)n[t]=t;return n}function kIe(e,t){return e[t]}function AIe(e){let t=[];return t.key=e,t}function jIe(){var e=RV([]),t=uH,n=lH,r=kIe;function i(i){var a=Array.from(e.apply(this,arguments),AIe),o,s=a.length,c=-1,l;for(let e of i)for(o=0,++c;o<s;++o)(a[o][c]=[0,+r(e,a[o].key,c,i)]).data=e;for(o=0,l=rH(t(a));o<s;++o)a[l[o]].index=o;return n(a,l),a}return i.keys=function(t){return arguments.length?(e=typeof t==`function`?t:RV(Array.from(t)),i):e},i.value=function(e){return arguments.length?(r=typeof e==`function`?e:RV(+e),i):r},i.order=function(e){return arguments.length?(t=e==null?uH:typeof e==`function`?e:RV(Array.from(e)),i):t},i.offset=function(e){return arguments.length?(n=e??lH,i):n},i}function MIe(e,t){if((r=e.length)>0){for(var n,r,i=0,a=e[0].length,o;i<a;++i){for(o=n=0;n<r;++n)o+=e[n][i][1]||0;if(o)for(n=0;n<r;++n)e[n][i][1]/=o}lH(e,t)}}function NIe(e,t){if((c=e.length)>0)for(var n,r=0,i,a,o,s,c,l=e[t[0]].length;r<l;++r)for(o=s=0,n=0;n<c;++n)(a=(i=e[t[n]][r])[1]-i[0])>0?(i[0]=o,i[1]=o+=a):a<0?(i[1]=s,i[0]=s+=a):(i[0]=0,i[1]=a)}function PIe(e,t){if((i=e.length)>0){for(var n=0,r=e[t[0]],i,a=r.length;n<a;++n){for(var o=0,s=0;o<i;++o)s+=e[o][n][1]||0;r[n][1]+=r[n][0]=-s/2}lH(e,t)}}function FIe(e,t){if((o=e.length)>0&&(a=(i=e[t[0]]).length)>0){for(var n=0,r=1,i,a,o;r<a;++r){for(var s=0,c=0,l=0;s<o;++s){for(var u=e[t[s]],d=u[r][1]||0,f=(d-(u[r-1][1]||0))/2,p=0;p<s;++p){var m=e[t[p]],h=m[r][1]||0,g=m[r-1][1]||0;f+=h-g}c+=d,l+=f*d}i[r-1][1]+=i[r-1][0]=n,c&&(n-=l/c)}i[r-1][1]+=i[r-1][0]=n,lH(e,t)}}function IIe(e){var t=e.map(LIe);return uH(e).sort(function(e,n){return t[e]-t[n]})}function LIe(e){for(var t=-1,n=0,r=e.length,i,a=-1/0;++t<r;)(i=+e[t][1])>a&&(a=i,n=t);return n}function dH(e){var t=e.map(fH);return uH(e).sort(function(e,n){return t[e]-t[n]})}function fH(e){for(var t=0,n=-1,r=e.length,i;++n<r;)(i=+e[n][1])&&(t+=i);return t}function RIe(e){return dH(e).reverse()}function zIe(e){var t=e.length,n,r,i=e.map(fH),a=IIe(e),o=0,s=0,c=[],l=[];for(n=0;n<t;++n)r=a[n],o<s?(o+=i[r],c.push(r)):(s+=i[r],l.push(r));return l.reverse().concat(c)}function BIe(e){return uH(e).reverse()}function pH(e,t){e(t)}var mH={ascending:dH,descending:RIe,insideout:zIe,none:uH,reverse:BIe};Object.keys(mH);function VIe(e){return e&&mH[e]||mH.none}var hH={expand:MIe,diverging:NIe,none:lH,silhouette:PIe,wiggle:FIe};Object.keys(hH);function HIe(e){return e&&hH[e]||hH.none}function UIe(){let{innerRadius:e,outerRadius:t,cornerRadius:n,startAngle:r,endAngle:i,padAngle:a,padRadius:o}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=wIe();return e!=null&&pH(s.innerRadius,e),t!=null&&pH(s.outerRadius,t),n!=null&&pH(s.cornerRadius,n),r!=null&&pH(s.startAngle,r),i!=null&&pH(s.endAngle,i),a!=null&&pH(s.padAngle,a),o!=null&&pH(s.padRadius,o),s}function WIe(){let{x:e,x0:t,x1:n,y:r,y0:i,y1:a,defined:o,curve:s}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},c=TIe();return e&&pH(c.x,e),t&&pH(c.x0,t),n&&pH(c.x1,n),r&&pH(c.y,r),i&&pH(c.y0,i),a&&pH(c.y1,a),o&&c.defined(o),s&&c.curve(s),c}function GIe(){let{x:e,y:t,defined:n,curve:r}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},i=cH();return e&&pH(i.x,e),t&&pH(i.y,t),n&&i.defined(n),r&&i.curve(r),i}function KIe(){let{startAngle:e,endAngle:t,padAngle:n,value:r,sort:i,sortValues:a}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=OIe();return a===void 0?i===void 0?o.sortValues(null):i===null?o.sort(null):o.sort(i):o.sortValues(a),r!=null&&o.value(r),n!=null&&pH(o.padAngle,n),e!=null&&pH(o.startAngle,e),t!=null&&pH(o.endAngle,t),o}function qIe(e){let{keys:t,value:n,order:r,offset:i}=e,a=jIe();return t&&a.keys(t),n&&pH(a.value,n),r&&a.order(VIe(r)),i&&a.offset(HIe(i)),a}var JIe=[[1e9,`B`],[1e6,`M`],[1e3,`k`]],YIe=new Set([`$`,`¥`,`€`,`£`]),XIe=new Set([`%`,`×`,`x`]);function gH(e,t={}){if(e==null||Number.isNaN(e))return`—`;let n=Math.abs(e),r,i=t.compact===!1?void 0:JIe.find(([e])=>n>=e);if(i){let e=n/i[0];r=(e<10?e.toFixed(1):String(Math.round(e))).replace(/\.0$/,``)+i[1]}else r=t.decimals==null?String(+n.toFixed(2)):n.toFixed(t.decimals);let a=e<0?`−`:t.signed&&e>0?`+`:``,{unit:o}=t;return o?YIe.has(o)?a+o+r:XIe.has(o)?a+r+o:`${a}${r} ${o}`:a+r}function _H(e,t={},n=!1){return gH(e,{...t,signed:!1,unit:n?t.unit:void 0})}function vH(e,t){let n=0;for(let r of e)n+=r.charCodeAt(0)>11904?t:t*.58;return n}var yH={series1:`var(--rc-chart-1)`,series2:`var(--rc-chart-2)`,series3:`var(--rc-chart-3)`,series4:`var(--rc-chart-4)`,series5:`var(--rc-chart-5)`,series6:`var(--rc-chart-6)`,muted:`var(--rc-chart-muted)`,grid:`var(--rc-chart-grid)`,axis:`var(--rc-chart-axis)`,reference:`var(--rc-chart-reference)`,crosshair:`var(--rc-chart-crosshair)`,areaOpacity:`var(--rc-chart-area-opacity)`,hoverWash:`var(--rc-chart-hover-wash)`},bH=[`var(--rc-chart-1)`,`var(--rc-chart-2)`,`var(--rc-chart-3)`,`var(--rc-chart-4)`,`var(--rc-chart-5)`,`var(--rc-chart-6)`],ZIe={width:720,height:300,compact:!1},QIe={width:340,height:240,compact:!0};function xH(e,t,n,r,i){let a=Math.min(0,i?.min??e),o=Math.max(0,i?.max??t),s=LV({domain:[a,o===a?a+1:o],nice:r?3:4}),c=s.ticks(r?3:4),l=s.domain(),u=c.map((e,t)=>_H(e,n,t===c.length-1));return{ticks:c,domain:l,width:Math.max(...u.map(e=>vH(e,11)))+12,labels:u}}function SH(e,t){let n=e[t];return typeof n==`number`?n:null}function CH(e,t){let n=e[t];return n==null?``:String(n)}function wH(e,t){let n=e.series[t];return e.highlight&&e.type!==`pie`&&n.key!==e.highlight?yH.muted:bH[((n.color==null?t:n.color-1)%bH.length+bH.length)%bH.length]}function TH(e,t){let n=e.series[t];return n.label||n.key}function EH(e,t,n,r,i){let a=Math.abs(r-n),o=Math.min(i,t/2,a);return r<=n?`M${e},${n}V${r+o}Q${e},${r} ${e+o},${r}H${e+t-o}Q${e+t},${r} ${e+t},${r+o}V${n}Z`:`M${e},${n}V${r-o}Q${e},${r} ${e+o},${r}H${e+t-o}Q${e+t},${r} ${e+t},${r-o}V${n}Z`}function $Ie(e){let t={area:`Area chart`,bar:e.stacked?`Stacked bar chart`:`Bar chart`,line:`Line chart`,pie:e.donut?`Donut chart`:`Pie chart`,scatter:`Scatter chart`}[e.type],n=e.series.map(e=>e.label||e.key).join(`, `);return`${e.title?`${e.title}. `:``}${t} with ${e.data.length} ${e.type===`pie`?`slices`:e.type===`scatter`?`points`:`categories`}; series: ${n}.`}var eLe=`appgph0`,tLe=`appgph1`,nLe=`appgph5`,rLe=`appgph6`,iLe=`appgph7`,aLe=`appgph8`,oLe=`appgph9`,sLe=`appgpha`,DH=`appgphb`,OH=`appgphc`,kH=`appgphd`,AH=`appgphe`,cLe=`appgphh`,lLe=`appgphi`,uLe=`appgphj`,dLe=`appgphk`,fLe=`appgphm`,pLe=`appgphn`,mLe=`appgpho`,hLe=`appgphp`,gLe=`appgphs`,_Le=`appgpht`,vLe=`appgphu`,yLe=`appgphv`,bLe=`appgphw`,xLe=`appgphx`;function jH({state:e,width:t,height:n}){let r=`${e.x/t*100}%`,i=`${e.y/n*100}%`,a=e.side===`left`?`translateX(calc(-100% - 14px))`:`translateX(14px)`;return(0,K.jsxs)(`div`,{"aria-hidden":!0,className:dLe,style:{left:r,top:i,transform:a},children:[e.title&&(0,K.jsx)(`div`,{className:`appgphl`,children:e.title}),e.rows.map(e=>(0,K.jsxs)(`div`,{className:fLe,children:[(0,K.jsx)(`i`,{className:pLe,style:{background:e.color}}),(0,K.jsx)(`span`,{className:mLe,children:e.value}),(0,K.jsx)(`span`,{className:hLe,children:e.label})]},e.label))]})}function MH({axis:e,y:t,left:n,right:r}){return(0,K.jsx)(`g`,{children:e.ticks.map((i,a)=>(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`line`,{className:i===0?uLe:lLe,x1:n,x2:r,y1:t(i),y2:t(i)}),(0,K.jsx)(`text`,{className:kH,textAnchor:`end`,x:n-8,y:t(i)+4,children:e.labels[a]})]},i))})}function NH({labels:e,centers:t,y:n,rotate:r}){let i=-1/0;return(0,K.jsx)(`g`,{children:e.map((e,a)=>{if(r)return(0,K.jsx)(`text`,{className:AH,textAnchor:`end`,transform:`rotate(-38 ${t[a]} ${n-4})`,x:t[a],y:n,children:e},a);let o=vH(e,12)/2;return t[a]-o<i+14?null:(i=t[a]+o,(0,K.jsx)(`text`,{className:AH,textAnchor:`middle`,x:t[a],y:n,children:e},a))})})}function SLe(e,t){let n=(e.currentTarget.ownerSVGElement??e.currentTarget).getBoundingClientRect();return(e.clientX-n.left)*t/n.width}function PH(e,t,n){let r=e.series[t].key,i=e.data[n],a=i[r];return{series:r,x:i[e.x]??null,value:typeof a==`number`?a:null,index:n}}function FH(e,t,n){return{"data-point":`${t.series}:${t.index}`,style:e.onPointClick?{cursor:`pointer`}:void 0,onClick:()=>e.onPointClick?.(t),onPointerEnter:()=>{n?.enter(),e.onPointHover?.(t)},onPointerLeave:()=>{n?.leave(),e.onPointHover?.(null)}}}var IH=24,LH=28,RH=2;function CLe(e){let t=e.series.map(e=>e.key),n=qIe({keys:t,offset:`diverging`})(e.data.map(e=>Object.fromEntries(t.map(t=>[t,SH(e,t)??0]))));return e.data.map((r,i)=>{let a=n.map((n,r)=>({series:r,value:SH(e.data[i],t[r])??0,y0:n[i][0],y1:n[i][1],rounded:!1})),o=a.filter(e=>e.value>0).sort((e,t)=>t.y1-e.y1)[0],s=a.filter(e=>e.value<0).sort((e,t)=>e.y0-t.y0)[0];return o&&(o.rounded=!0),s&&(s.rounded=!0),a})}function wLe({spec:e,layout:t,events:n={}}){let{width:r,height:i,compact:a}=t,[o,s]=(0,G.useState)(null),{axis:c,labels:l,ml:u,mb:d,rotate:f,y:p,band:m,centers:h,segments:g}=(0,G.useMemo)(()=>{let t=e.data.length,n=e.stacked?CLe(e):null,o=0,s=0;for(let[t,r]of e.data.entries())if(n)for(let e of n[t])o=Math.min(o,e.y0,e.y1),s=Math.max(s,e.y0,e.y1);else for(let t of e.series){let e=SH(r,t.key)??0;o=Math.min(o,e),s=Math.max(s,e)}let c=xH(o,s,e.format,a,e.y),l=e.data.map(t=>CH(t,e.x)),u=c.width,d=r-u-8,f=Math.max(...l.map(e=>vH(e,12))),p=f>d/t-8,m=p?Math.min(f,120)*.62+20:28,h=dIe({domain:[...Array.from({length:t}).keys()],range:[u,r-8]}),g=LV({domain:c.domain,range:[i-m,12]}),_=h.bandwidth();return{axis:c,labels:l,ml:u,mb:m,rotate:p,x:h,y:g,band:_,centers:l.map((e,t)=>(h(t)??0)+_/2),segments:n}},[e,r,i,a]),_=e=>p(e)??0,v=_(0),y=e.series.length,b=!g&&y<=2&&(!a||!!e.highlight),x=i-d,S=t=>{let n=(g?[...e.series.keys()].reverse():[...e.series.keys()]).map(n=>({color:wH(e,n),value:gH(SH(e.data[t],e.series[n].key),e.format),label:TH(e,n)}));if(g&&y>1){let r=g[t].reduce((e,t)=>e+t.value,0);n.push({color:`transparent`,value:gH(r,e.format),label:`Total`})}return n},C=(e,t)=>{let n=h[e]>u+(r-u)/2;s({x:t,y:12,title:l[e],rows:S(e),side:n?`left`:`right`,band:e})};return(0,K.jsxs)(`div`,{className:DH,children:[(0,K.jsxs)(`svg`,{"aria-hidden":!0,className:OH,viewBox:`0 0 ${r} ${i}`,children:[o&&(0,K.jsx)(`rect`,{fill:yH.hoverWash,height:x-12,rx:4,width:m-8,x:h[o.band]-m/2+4,y:12}),(0,K.jsx)(MH,{axis:c,left:u,right:r-8,y:_}),e.data.map((t,n)=>{if(g){let t=Math.min(LH,m*.56),r=h[n]-t/2,i=g[n].reduce((e,t)=>e+Math.max(0,t.value),0);return(0,K.jsxs)(`g`,{children:[g[n].map(n=>{if(n.value===0)return null;let i=n.value>0,a=_(i?n.y0:n.y1)+(n.y0===0||n.y1===0?0:i?-1:RH/2),o=_(i?n.y1:n.y0)+(n.rounded?0:i?RH/2:-1);return(0,K.jsx)(`path`,{d:EH(r,t,a,o,n.rounded?4:0),fill:wH(e,n.series)},n.series)}),!a&&i>0&&(0,K.jsx)(`text`,{className:`appgphf`,textAnchor:`middle`,x:h[n],y:_(i)-7,children:gH(i,e.format)})]},n)}let r=Math.min(IH,(m*.72-(y-1)*RH)/y),i=y*r+(y-1)*RH;return(0,K.jsx)(`g`,{children:e.series.map((a,o)=>{let s=SH(t,a.key);if(s==null)return null;let c=h[n]-i/2+o*(r+RH),l=_(s),u=e.highlight===a.key;return(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`path`,{d:EH(c,r,v,l,4),fill:wH(e,o)}),b&&(!e.highlight||u)&&(0,K.jsx)(`text`,{className:u?`appgphg`:`appgphf`,textAnchor:`middle`,x:c+r/2,y:s>=0?l-6:l+14,children:gH(s,e.format)})]},a.key)})},n)}),(0,K.jsx)(NH,{centers:h,labels:l,rotate:f,y:i-d+18}),h.map((e,t)=>(0,K.jsx)(`rect`,{fill:`transparent`,height:x-12,width:m,x:e-m/2,y:12,onPointerEnter:()=>C(t,e+(e>u+(r-u)/2?-m/4:m/4)),onPointerLeave:()=>s(null)},t)),e.data.map((t,i)=>{let a=h[i]+(h[i]>u+(r-u)/2?-m/4:m/4),o={enter:()=>C(i,a),leave:()=>s(null)};if(g){let t=Math.min(LH,m*.56);return g[i].map(r=>r.value===0?null:(0,K.jsx)(`path`,{fill:`transparent`,d:EH(h[i]-t/2,t,_(r.value>0?r.y0:r.y1),_(r.value>0?r.y1:r.y0),0),...FH(n,PH(e,r.series,i),o)},`h-${i}-${r.series}`))}let c=Math.min(IH,(m*.72-(y-1)*RH)/y),l=y*c+(y-1)*RH;return e.series.map((r,a)=>{let s=SH(t,r.key);return s==null?null:(0,K.jsx)(`path`,{d:EH(h[i]-l/2+a*(c+RH),c,v,_(s),4),fill:`transparent`,...FH(n,PH(e,a,i),o)},`h-${i}-${r.key}`)})})]}),o&&(0,K.jsx)(jH,{height:i,state:o,width:r})]})}var TLe=`_3n881z0`,ELe=`_3n881z1`,DLe=`_3n881z2`,OLe=`_3n881z3`,kLe=`_3n881z4`,ALe=`_3n881z6`,jLe=`_3n881z7`,MLe=`_3n881z8`;function NLe({issues:e,title:t,type:n,rows:r}){let i=e.length,a=[`chart`,n,r==null?void 0:`${r} rows`].filter(Boolean).join(` · `);return(0,K.jsxs)(`div`,{className:TLe,role:`alert`,children:[(0,K.jsxs)(`div`,{className:ELe,children:[(0,K.jsxs)(`svg`,{className:DLe,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:1.5,viewBox:`0 0 16 16`,children:[(0,K.jsx)(`circle`,{cx:8,cy:8,r:6.5}),(0,K.jsx)(`path`,{d:`M8 4.8v3.6M8 11h.01`})]}),(0,K.jsx)(`span`,{className:OLe,children:i===1?`Chart data has 1 problem`:`Chart data has ${i} problems`}),(0,K.jsx)(`span`,{className:kLe,children:a})]}),t&&(0,K.jsx)(`div`,{className:`_3n881z5`,children:t}),(0,K.jsx)(`ol`,{className:ALe,children:e.map(e=>(0,K.jsxs)(`li`,{className:jLe,children:[(0,K.jsx)(`code`,{className:MLe,children:e.path}),` `,e.message,e.hint&&(0,K.jsx)(`span`,{className:`_3n881z9`,children:e.hint})]},`${e.path}:${e.message}`))})]})}var zH=16;function PLe({spec:e,layout:t,events:n={}}){let{width:r,height:i,compact:a}=t,[o,s]=(0,G.useState)(null),c=e.type===`area`,l=c&&!!e.stacked,{n:u,layers:d,axis:f,direct:p,ml:m,mb:h,plotW:g,x:_,y:v}=(0,G.useMemo)(()=>{let t=e.data.length,n=e.data.map(()=>0),o=e.series.map(t=>e.data.map((e,r)=>{let i=SH(e,t.key),a=i??0;return{i:r,value:i,lo:l?n[r]:0,hi:l?n[r]+=a:a}})),s=0,c=0;for(let e of o)for(let t of e)t.value!=null&&(s=Math.min(s,t.lo,t.hi),c=Math.max(c,t.hi));for(let t of e.refs??[])c=Math.max(c,t.y);let u=xH(s,c,e.format,a,e.y),d=!a&&e.series.length<=3,f=t-1,p=d?Math.max(...e.series.map((t,n)=>vH(TH(e,n),12)+vH(gH(o[n][f]?.value,e.format),12)))+24:8,m=u.width,h=r-m-p;return{n:t,layers:o,axis:u,direct:d,ml:m,mb:28,plotW:h,x:e=>m+(t===1?h/2:e*h/(t-1)),y:LV({domain:u.domain,range:[i-28,12]})}},[e,r,i,a,l]),y=e=>v(e)??0,b=e.data.map(t=>CH(t,e.x)),x=[...e.series.keys()].sort((t,n)=>Number(e.series[t].key===e.highlight)-Number(e.series[n].key===e.highlight)),S=e=>e.value!=null,C=GIe({x:e=>_(e.i),y:e=>y(e.hi),defined:S}),w=WIe({x:e=>_(e.i),y0:e=>y(e.lo),y1:e=>y(e.hi),defined:S}),T=p?x.map(e=>({j:e,y:y(d[e][u-1].hi)})).filter(({j:e})=>d[e][u-1].value!=null).sort((e,t)=>e.y-t.y):[];for(let e=1;e<T.length;e++)T[e].y-T[e-1].y<zH&&(T[e].y=T[e-1].y+zH);let E=null;if(o!=null){let t=(l?[...e.series.keys()].reverse():[...e.series.keys()].sort((e,t)=>(d[t][o].value??-1/0)-(d[e][o].value??-1/0))).map(t=>({color:wH(e,t),value:gH(d[t][o].value,e.format),label:TH(e,t)}));l&&e.series.length>1&&t.push({color:`transparent`,value:gH(d.at(-1)[o].hi,e.format),label:`Total`}),E={x:_(o),y:12,title:b[o],rows:t,side:_(o)>m+g/2?`left`:`right`}}return(0,K.jsxs)(`div`,{className:DH,children:[(0,K.jsxs)(`svg`,{"aria-hidden":!0,className:OH,viewBox:`0 0 ${r} ${i}`,children:[(0,K.jsx)(MH,{axis:f,left:m,right:m+g,y}),e.refs?.map(t=>(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`line`,{shapeRendering:`crispEdges`,stroke:yH.reference,strokeDasharray:`4 3`,x1:m,x2:m+g,y1:y(t.y),y2:y(t.y)}),(0,K.jsx)(`text`,{className:kH,x:m+4,y:y(t.y)-6,children:`${t.label} ${gH(t.y,e.format)}`})]},`${t.label}-${t.y}`)),c&&(l?[...x].reverse():x).map(t=>(0,K.jsx)(`path`,{d:w(d[t])??``,fill:wH(e,t),style:{fillOpacity:l?yH.areaOpacity:.1}},`a-${t}`)),x.map(t=>(0,K.jsxs)(`g`,{children:[l&&t>0&&(0,K.jsx)(`path`,{d:C(d[t])??``,fill:`none`,stroke:Ht.color.bg,strokeWidth:4}),(0,K.jsx)(`path`,{d:C(d[t])??``,fill:`none`,stroke:wH(e,t),strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2})]},`l-${t}`)),T.map(({j:t,y:n})=>{let r=!!e.highlight&&e.series[t].key!==e.highlight;return(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`circle`,{cx:_(u-1),cy:y(d[t][u-1].hi),fill:wH(e,t),r:4,stroke:Ht.color.bg,strokeWidth:2}),(0,K.jsxs)(`text`,{className:cLe,x:_(u-1)+10,y:n+4,children:[(0,K.jsx)(`tspan`,{fill:r?Ht.color.textTertiary:Ht.color.text,fontWeight:r?400:600,children:gH(d[t][u-1].value,e.format)}),(0,K.jsx)(`tspan`,{dx:5,fill:Ht.color.textTertiary,children:TH(e,t)})]})]},`e-${t}`)}),(0,K.jsx)(NH,{centers:b.map((e,t)=>_(t)),labels:b,rotate:!1,y:i-h+18}),o!=null&&(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`line`,{shapeRendering:`crispEdges`,stroke:yH.crosshair,x1:_(o),x2:_(o),y1:12,y2:i-h}),e.series.map((t,n)=>d[n][o].value==null?null:(0,K.jsx)(`circle`,{cx:_(o),cy:y(d[n][o].hi),fill:wH(e,n),r:4,stroke:Ht.color.bg,strokeWidth:2},t.key))]}),(0,K.jsx)(`rect`,{fill:`transparent`,height:i-h-12,width:g,x:m,y:12,onPointerLeave:()=>s(null),onPointerMove:e=>{let t=SLe(e,r),n=u===1?0:Math.round((t-m)/g*(u-1));s(Math.max(0,Math.min(u-1,n)))}}),d.map((t,r)=>t.map(t=>t.value==null?null:(0,K.jsx)(`circle`,{cx:_(t.i),cy:y(t.hi),fill:`transparent`,r:7,...FH(n,PH(e,r,t.i),{enter:()=>s(t.i),leave:()=>s(null)})},`h-${r}-${t.i}`)))]}),E&&(0,K.jsx)(jH,{height:i,state:E,width:r})]})}var BH=28;function VH(e,t){return t.compact?216+e.data.length*BH:260}function FLe({spec:e,layout:t,events:n={}}){let{width:r,compact:i}=t,a=VH(e,t),[o,s]=(0,G.useState)(null),c=e.series[0].key,l=e.data.map((t,n)=>({i:n,label:CH(t,e.x),value:Math.max(0,SH(t,c)??0)})),u=l.reduce((e,t)=>e+t.value,0),d=i?96:a/2-10,f=i?r/2:d+10,p=i?d+4:a/2,m=e.donut?d*.62:0,h=KIe({value:e=>e.value,sort:null,sortValues:null})(l),g=UIe({innerRadius:m,outerRadius:d}),_=t=>e.highlight&&e.highlight!==l[t].label?yH.muted:bH[t%bH.length],v=e=>u?`${Math.round(e/u*100)}%`:`—`,y=Math.max(...l.map(e=>vH(e.label,13))),b=i?8:f+d+56,x=i?r-52:b+18+y+80,S=i?r-4:x+44,C=i?p+d+30:p-l.length*BH/2+BH/2,w=o==null?u:l[o].value,T=o==null?`Total`:`${l[o].label} · ${v(l[o].value)}`;return(0,K.jsx)(`div`,{className:DH,children:(0,K.jsxs)(`svg`,{"aria-hidden":!0,className:OH,viewBox:`0 0 ${r} ${a}`,children:[(0,K.jsxs)(`g`,{transform:`translate(${f} ${p})`,children:[h.map(t=>(0,K.jsx)(`path`,{d:g(t)??``,fill:_(t.index),stroke:Ht.color.bg,strokeLinejoin:`round`,strokeWidth:2,...FH(n,PH(e,0,t.index),{enter:()=>s(t.index),leave:()=>s(null)}),style:{opacity:o==null||o===t.index?1:.3,...n.onPointClick?{cursor:`pointer`}:{}}},t.index)),m>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`text`,{fill:Ht.color.text,fontSize:22,fontWeight:600,textAnchor:`middle`,y:2,children:gH(w,e.format)}),(0,K.jsx)(`text`,{className:`appgphd`,textAnchor:`middle`,y:22,children:T})]})]}),l.map((t,n)=>{let r=C+n*BH;return(0,K.jsxs)(`g`,{style:{opacity:o==null||o===n?1:.4},onPointerEnter:()=>s(n),onPointerLeave:()=>s(null),children:[(0,K.jsx)(`rect`,{fill:`transparent`,height:BH,width:S-b,x:b,y:r-BH/2}),(0,K.jsx)(`rect`,{fill:_(n),height:10,rx:2,width:10,x:b,y:r-5}),(0,K.jsx)(`text`,{fill:Ht.color.textSecondary,fontSize:13,x:b+18,y:r+4,children:t.label}),(0,K.jsx)(`text`,{fill:Ht.color.text,fontSize:13,fontWeight:600,textAnchor:`end`,x,y:r+4,children:gH(t.value,e.format)}),(0,K.jsx)(`text`,{className:kH,textAnchor:`end`,x:S,y:r+4,children:v(t.value)})]},n)})]})})}function ILe({spec:e,layout:t,events:n={}}){let{width:r,height:i,compact:a}=t,[o,s]=(0,G.useState)(null),{axis:c,ml:l,mb:u,x:d,y:f,ticks:p}=(0,G.useMemo)(()=>{let t=e.data.map(t=>SH(t,e.x)).filter(e=>e!=null),n=0,o=0;for(let t of e.data)for(let r of e.series){let e=SH(t,r.key);e!=null&&(n=Math.min(n,e),o=Math.max(o,e))}let s=xH(n,o,e.format,a,e.y),c=s.width,l=Math.min(...t,0),u=LV({domain:[l,Math.max(...t,l+1)],range:[c+8,r-8-8],nice:a?3:5});return{axis:s,ml:c,mb:28,x:u,y:LV({domain:s.domain,range:[i-28,12]}),ticks:u.ticks(a?3:5)}},[e,r,i,a]),m=e=>f(e)??0,h=e=>d(e)??0,g=null;if(o){let t=e.data[o.i],n=SH(t,e.x)??0;g={x:h(n),y:m(SH(t,e.series[o.j].key)??0),title:`${e.xLabel||e.x} ${gH(n,{...e.format,unit:void 0})}`,rows:[{color:wH(e,o.j),label:TH(e,o.j),value:gH(SH(t,e.series[o.j].key),e.format)}],side:h(n)>l+(r-l)/2?`left`:`right`}}return(0,K.jsxs)(`div`,{className:DH,children:[(0,K.jsxs)(`svg`,{"aria-hidden":!0,className:OH,viewBox:`0 0 ${r} ${i}`,children:[(0,K.jsx)(MH,{axis:c,left:l,right:r-8,y:m}),(0,K.jsx)(NH,{centers:p.map(h),labels:p.map((e,t)=>_H(e,void 0,t===p.length-1)),rotate:!1,y:i-u+18}),e.series.map((t,r)=>e.data.map((i,a)=>{let c=SH(i,e.x),l=SH(i,t.key);if(c==null||l==null)return null;let u=o?.i===a&&o.j===r;return(0,K.jsx)(`circle`,{cx:h(c),cy:m(l),fill:wH(e,r),fillOpacity:u?1:.75,r:u?6:4.5,stroke:Ht.color.bg,strokeWidth:1.5,...FH(n,PH(e,r,a),{enter:()=>s({i:a,j:r}),leave:()=>s(null)})},`${t.key}-${a}`)}))]}),g&&(0,K.jsx)(jH,{height:i,state:g,width:r})]})}var HH=[`bar`,`line`,`area`,`pie`,`scatter`],UH=e=>typeof e==`object`&&!!e&&!Array.isArray(e),WH=e=>typeof e==`string`?`"${e}"`:JSON.stringify(e);function GH(e){let t;try{t=JSON.parse(e)}catch(e){return{ok:!1,issues:[{path:`(root)`,message:`is not valid JSON: ${e.message}`,hint:`The <chart> body must be one JSON object inside CDATA`}]}}return KH(t)}function KH(e){let t=[];if(!UH(e))return{ok:!1,issues:[{path:`(root)`,message:`must be an object`}]};let{type:n,x:r,series:i,data:a}=e;if(HH.includes(n)||t.push({path:`type`,message:`is ${WH(n)}, which is not supported`,hint:`Use one of: ${HH.join(`, `)}`}),typeof r==`string`&&r||t.push({path:`x`,message:`must name the field used for categories`}),Array.isArray(i)&&i.length!==0||t.push({path:`series`,message:`must be a non-empty array of { key, label? }`}),Array.isArray(a)||t.push({path:`data`,message:`must be an array of rows`}),t.some(e=>e.path!==`type`))return{ok:!1,issues:t};let o=a,s=i,c=new Set;o.forEach((e,n)=>{if(!UH(e))t.push({path:`data[${n}]`,message:`must be an object`});else for(let t of Object.keys(e))c.add(t)}),s.length>6&&t.push({path:`series`,message:`has ${s.length} entries; at most 6 are allowed`,hint:`Merge the smallest series into one named "Other", or split into several charts`}),n===`pie`&&o.length>6&&t.push({path:`data`,message:`has ${o.length} slices; a pie allows at most 6`,hint:`Merge the smallest slices into one row named "Other"`});let l=[...c].map(e=>`"${e}"`).join(`, `)||`(none)`;o.length>0&&!c.has(r)&&t.push({path:`x`,message:`is ${WH(r)}, but no row has that field`,hint:`Fields present in data: ${l}`});let u=[];if(s.forEach((e,n)=>{!UH(e)||typeof e.key!=`string`||!e.key?t.push({path:`series[${n}]`,message:`must be { key: string, label?: string }`}):(u.push(e.key),o.length>0&&!c.has(e.key)&&t.push({path:`series[${n}].key`,message:`is ${WH(e.key)}, but no row has that field`,hint:`Fields present in data: ${l}`}))}),o.forEach((e,n)=>{if(UH(e))for(let r of u){let i=e[r];i!=null&&(typeof i==`number`&&Number.isFinite(i)||t.push({path:`data[${n}].${r}`,message:`must be a number, got ${WH(i)}`,hint:typeof i==`string`&&/\d/.test(i)?`Write the bare number and put the unit in format.unit`:void 0}))}}),n===`scatter`&&o.forEach((e,n)=>{if(!UH(e))return;let i=e[r];i!=null&&(typeof i==`number`&&Number.isFinite(i)||t.push({path:`data[${n}].${r}`,message:`must be a number on a scatter x axis, got ${WH(i)}`}))}),n===`pie`){let e=u[0];o.forEach((n,r)=>{UH(n)&&typeof n[e]==`number`&&n[e]<0&&t.push({path:`data[${r}].${e}`,message:`is negative; pie slices must be ≥ 0`})})}return e.highlight!==void 0&&typeof e.highlight!=`string`?t.push({path:`highlight`,message:`must be a string`}):typeof e.highlight==`string`&&n!==`pie`&&!u.includes(e.highlight)&&t.push({path:`highlight`,message:`is ${WH(e.highlight)}, which is not a series key`,hint:`Series keys: ${u.map(e=>`"${e}"`).join(`, `)}`}),t.length>0?{ok:!1,issues:t}:{ok:!0,spec:{...e,version:1}}}function qH({spec:e,layout:t,events:n}){return e.type===`bar`?(0,K.jsx)(wLe,{events:n,layout:t,spec:e}):e.type===`scatter`?(0,K.jsx)(ILe,{events:n,layout:t,spec:e}):e.type===`pie`?(0,K.jsx)(FLe,{events:n,layout:{...t,height:VH(e,t)},spec:e}):(0,K.jsx)(PLe,{events:n,layout:t,spec:e})}function JH({spec:e,compact:t}){if(e.type===`pie`||e.series.length<2||!(e.type===`bar`||e.type===`scatter`||e.stacked||t||e.series.length>3))return null;let n=e.type===`line`;return(0,K.jsx)(`div`,{className:nLe,children:e.series.map((t,r)=>(0,K.jsxs)(`span`,{className:rLe,children:[(0,K.jsx)(`i`,{className:n?aLe:iLe,style:{background:wH(e,r)}}),TH(e,r)]},t.key))})}function LLe({spec:e}){let t={...e.format,compact:!1};return(0,K.jsxs)(`table`,{className:gLe,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{scope:`col`,children:e.xLabel||e.x}),e.series.map((t,n)=>(0,K.jsx)(`th`,{scope:`col`,children:TH(e,n)},t.key))]})}),(0,K.jsx)(`tbody`,{children:e.data.map((n,r)=>(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`td`,{children:CH(n,e.x)}),e.series.map(e=>(0,K.jsx)(`td`,{children:gH(SH(n,e.key),t)},e.key))]},r))})]})}var RLe=(0,K.jsxs)(`svg`,{fill:`none`,height:14,stroke:`currentColor`,strokeWidth:1.4,viewBox:`0 0 16 16`,width:14,children:[(0,K.jsx)(`rect`,{height:10,rx:1.5,width:12,x:2,y:3}),(0,K.jsx)(`path`,{d:`M2 6.5h12M6.5 6.5V13`})]}),zLe=(0,K.jsx)(`svg`,{fill:`none`,height:14,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:1.4,viewBox:`0 0 16 16`,width:14,children:(0,K.jsx)(`path`,{d:`M3 13V8M6.5 13V4M10 13V9.5M13.5 13V6`})});function BLe({spec:e,defaultView:t=`chart`,hideToggle:n,onPointClick:r,onPointHover:i}){let a={onPointClick:r,onPointHover:i},[o,s]=(0,G.useState)(t),c=e.data.length===0,l=o===`table`&&!c;return(0,K.jsxs)(`figure`,{className:eLe,children:[(0,K.jsxs)(`div`,{className:tLe,children:[(0,K.jsxs)(`div`,{children:[e.title&&(0,K.jsx)(`div`,{className:`appgph2`,children:e.title}),e.subtitle&&(0,K.jsx)(`div`,{className:`appgph3`,children:e.subtitle})]}),!n&&!c&&(0,K.jsxs)(`button`,{"aria-pressed":l,className:`appgph4`,type:`button`,onClick:()=>s(l?`chart`:`table`),children:[l?zLe:RLe,l?`View chart`:`View data`]})]}),c?(0,K.jsxs)(`div`,{className:_Le,children:[(0,K.jsx)(`div`,{className:vLe,children:[0,1,2,3].map(e=>(0,K.jsx)(`div`,{className:yLe},e))}),(0,K.jsxs)(`div`,{className:bLe,children:[`No data yet`,(0,K.jsx)(`code`,{className:xLe,children:`data: []`})]})]}):l?(0,K.jsx)(LLe,{spec:e}):(0,K.jsxs)(`div`,{"aria-label":$Ie(e),role:`img`,children:[(0,K.jsxs)(`div`,{className:oLe,children:[(0,K.jsx)(JH,{compact:!1,spec:e}),(0,K.jsx)(qH,{events:a,layout:ZIe,spec:e})]}),(0,K.jsxs)(`div`,{className:sLe,children:[(0,K.jsx)(JH,{compact:!0,spec:e}),(0,K.jsx)(qH,{events:a,layout:QIe,spec:e})]})]}),(e.note||e.source)&&(0,K.jsxs)(`figcaption`,{className:`appgphq`,children:[e.note,e.note&&e.source&&` · `,e.source&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`appgphr`,children:`Source `}),e.source]})]})]})}function VLe(e){let t=e;if(typeof t==`string`)try{t=JSON.parse(t)}catch{return{}}return typeof t==`object`&&t?t:{}}function YH({value:e,...t}){let n=(0,G.useMemo)(()=>typeof e==`string`?GH(e):KH(e),[e]);if(!n.ok){let t=VLe(e);return(0,K.jsx)(NLe,{issues:n.issues,rows:Array.isArray(t.data)?t.data.length:void 0,title:typeof t.title==`string`?t.title:void 0,type:typeof t.type==`string`?t.type:void 0})}return(0,K.jsx)(BLe,{spec:n.spec,...t})}function XH({spec:e}){return(0,K.jsx)(YH,{value:e})}var ZH=`Chart`;function QH(e){"@babel/helpers - typeof";return QH=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},QH(e)}function HLe(e,t){if(QH(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(QH(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ULe(e){var t=HLe(e,`string`);return QH(t)==`symbol`?t:t+``}function $H(e,t,n){return(t=ULe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eU(e){return typeof e==`string`?e:e==null?``:JSON.stringify(e)}var tU=class e extends wr{static getType(){return`chart`}static clone(t){return new e(t.__spec,t.__key)}constructor(e=``,t){super(t),$H(this,`__spec`,void 0),this.__spec=e}createDOM(e){let t=document.createElement(`div`);return t.className=`rich-chart-wrapper`,t}updateDOM(){return!1}isInline(){return!1}static importJSON(e){return WLe(eU(e.spec)).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`chart`,spec:this.__spec,version:1}}getSpec(){return this.getLatest().__spec}setSpec(e){let t=this.getWritable();t.__spec=e}decorate(e,t){return qj(ZH,XH,{spec:this.__spec})}};function WLe(e=``){return new tU(e)}function GLe(e){return e instanceof tU}var nU={root:`rich-steps`,item:`rich-steps-item`,marker:`rich-steps-marker`,title:`rich-steps-title`,content:`rich-steps-content`},rU=`_1m3xa5x0`,iU=`_1m3xa5x1`,aU=`_1m3xa5x2`,KLe=({steps:e})=>{let t=_N(),n=Gj();return e.length===0?null:(0,K.jsx)(`ol`,{className:`${rU} ${nU.root}`,children:e.map((e,r)=>(0,K.jsxs)(`li`,{className:`${iU} ${nU.item}`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`${aU} ${nU.marker}`,children:r+1}),e.title&&(0,K.jsx)(`div`,{className:`_1m3xa5x3 ${nU.title}`,children:e.title}),t&&(0,K.jsx)(`div`,{className:`_1m3xa5x4 ${nU.content}`,children:t(e.content,n)})]},e.id))})},oU=null,sU=null;function qLe(){return oU?Promise.resolve(oU):(sU||=r(()=>import(`./katex-DuZJ-tFh.js`).then(e=>e.n).then(e=>(oU=e,oU)),__vite__mapDeps([28,1]),import.meta.url),sU)}function cU({equation:e,displayMode:t}){let[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)(null);return(0,G.useEffect)(()=>{let n=!1;return qLe().then(i=>{if(n)return;let o=i.default.renderToString(e,{displayMode:t,throwOnError:!1});r(o),a(null)}).catch(()=>{n||(r(null),a(`KaTeX is not available`))}),()=>{n=!0}},[e,t]),i?(0,K.jsx)(`code`,{className:Fj(oR.fallback,sR.fallback),children:e}):n?(0,K.jsx)(`span`,{dangerouslySetInnerHTML:{__html:n},className:t?Fj(oR.block,sR.block):Fj(oR.inline,sR.inline)}):(0,K.jsx)(`code`,{className:Fj(oR.fallback,sR.fallback),children:e})}var JLe=qe(`abcdefghijklmnopqrstuvwxyz0123456789`,8);function lU(){return`s_${JLe()}`}function uU(){return{root:{children:[{type:`paragraph`,children:[],direction:null,format:``,indent:0,textFormat:0,textStyle:``,version:1}],direction:null,format:``,indent:0,type:`root`,version:1}}}function dU(e=``){return{id:lU(),title:e,content:uU()}}function fU(e){return Array.isArray(e)?e.map(e=>{let t=e&&typeof e==`object`?e:{};return{...t,id:typeof t.id==`string`&&t.id?t.id:lU(),title:typeof t.title==`string`?t.title:``,content:t.content?.root?t.content:uU()}}):[]}var YLe=`Steps`;function pU(e){"@babel/helpers - typeof";return pU=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},pU(e)}function XLe(e,t){if(pU(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(pU(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ZLe(e){var t=XLe(e,`string`);return pU(t)==`symbol`?t:t+``}function mU(e,t,n){return(t=ZLe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var hU=class e extends wr{static getType(){return`steps`}static clone(t){return new e(t.__steps,t.__key)}constructor(e,t){super(t),mU(this,`__steps`,void 0),this.__steps=e??[dU()]}createDOM(e){let t=document.createElement(`div`);return t.className=`rich-steps-block`,t}updateDOM(){return!1}isInline(){return!1}getSteps(){return this.getLatest().__steps}setSteps(e){let t=this.getWritable();t.__steps=e}getTextContent(){return this.__steps.map(e=>[e.title,bN(e.content)].filter(Boolean).join(`
|
|
193
|
+
`)||(t-=2),t>=5}function gje(e){let t=null,n=qn({namespace:`markdown-paste-temp`,nodes:jF(),onError:e=>{t=e}});if(n.update(()=>{sAe(e,nL)},{discrete:!0}),t)return console.error(`MarkdownPastePlugin: convertAndInsert error`,t),!1;let r=n.getEditorState().toJSON().root.children;if(!r.length)return!1;let i=r.map(e=>Ne(e));return Un(i),!0}function _je(){let[e]=ht();return(0,G.useEffect)(()=>e.registerCommand(or,e=>{let t=`clipboardData`in e?e.clipboardData:null;if(!t||t.getData(`application/x-lexical-editor`)||Array.from(t.files).some(e=>e.type.startsWith(`image/`)))return!1;let n=pje(t);if(n){let r=t.getData(`text/plain`);if(r){let t=r.split(/\r?\n{3,}/).filter(Boolean).map(e=>ike(e.replace(/^\s*\n/,``).replace(/\n\s*$/,``),n.language));return Un(t),e.preventDefault(),!0}}if(mje(t))return!1;let r=t.getData(`text/plain`);if(!r||!hje(r))return!1;try{return gje(r)?(e.preventDefault(),!0):!1}catch(e){return console.error(`MarkdownPastePlugin: paste error`,e),!1}},3),[e]),null}function vje(){return(0,K.jsx)(NAe,{transformers:nL})}function yje(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Lt,{}),(0,K.jsx)(qt,{}),(0,K.jsx)(dF,{}),(0,K.jsx)(Eke,{}),(0,K.jsx)(uF,{hasHorizontalScroll:!0}),(0,K.jsx)(Tke,{}),(0,K.jsx)(vje,{}),(0,K.jsx)(JAe,{}),(0,K.jsx)(_je,{}),(0,K.jsx)(LAe,{}),(0,K.jsx)(zAe,{}),(0,K.jsx)(HAe,{}),(0,K.jsx)(FAe,{})]})}var bje=(0,G.createContext)(null);function xje({upload:e,children:t}){return(0,K.jsx)(bje.Provider,{value:e,children:t})}var rL=(0,G.createContext)(null);function Sje({children:e}){let t=(0,G.useRef)(null),n=(0,G.useMemo)(()=>({ref:t,register:e=>(t.current=e,()=>{t.current===e&&(t.current=null)})}),[]);return(0,K.jsx)(rL.Provider,{value:n,children:e})}function iL(){return(0,G.use)(rL)}var aL=(0,G.createContext)(null);function Cje({upload:e,children:t}){return(0,K.jsx)(aL.Provider,{value:e,children:t})}function wje(){return(0,G.use)(aL)}var Tje=(0,G.createContext)(null);function Eje({upload:e,children:t}){return(0,K.jsx)(Tje.Provider,{value:e,children:t})}var oL=new WeakMap;function Dje(e){let t=oL.get(e);return t||(t={entries:new Map,listeners:new Set},oL.set(e,t)),t}function sL(e,t,n){let r=Dje(e);n?r.entries.set(t,n):r.entries.delete(t);for(let e of r.listeners)e()}function cL(e){return e.type.startsWith(`image/`)||e.type.startsWith(`video/`)}function Oje({onUpload:e}){let t=$k(),n=(0,G.useRef)(t);n.current=t;let[r]=ht(),i=(0,G.useRef)(e);i.current=e;let a=(0,G.useRef)(r),o=(0,G.useRef)(null),s=(0,G.useCallback)((e,t)=>{let r=``;t.update(()=>{let t=JP({src:``,name:e.name,size:e.size,mimeType:e.type||void 0,ext:FOe(e.name)});Un([t]),r=t.getKey()});let a=()=>{sL(t,r,null),t.update(()=>{let e=Dn(r);e&&e.remove()})},o=async()=>{let s=n.current?.retain(),c={percent:0,retry:()=>void o(),remove:a};sL(t,r,{...c,status:`uploading`});try{let n=await i.current(e,{onProgress:e=>{sL(t,r,{...c,status:`uploading`,percent:Math.round(e)})}});t.update(()=>{let e=Dn(r);IOe(e)&&e.setSrc(n.src)}),sL(t,r,null)}catch(e){console.error(`[FileUploadPlugin]`,e),sL(t,r,{...c,status:`error`,error:`Upload failed`})}finally{queueMicrotask(()=>s?.())}};o()},[]),c=(0,G.useCallback)((e,t)=>{let n=e.filter(e=>!cL(e));if(n.length===0)return!1;for(let e of n)s(e,t);return n.length===e.length},[s]);return(0,G.useEffect)(()=>{let e=r.registerCommand(yt,(e,t)=>c(e,t),1),t=r.registerCommand(or,(e,t)=>{let n=`clipboardData`in e?e.clipboardData:null;if(!n)return!1;let r=[...n.files];return r.some(e=>!cL(e))?c(r,t):!1},1),n=r.registerCommand(SN,(e,t)=>(a.current=t,o.current?.click(),!0),0);return()=>{e(),t(),n()}},[r,c]),(0,K.jsx)(`input`,{multiple:!0,ref:o,style:{display:`none`},type:`file`,onChange:e=>{let t=[...e.currentTarget.files??[]];for(let e of t)s(e,a.current);e.currentTarget.value=``}})}async function lL(e,t,n){if(!n||e.length===0)return e;try{return await n(e,{source:t})??[]}catch(t){return console.error(`[ImageUploadPlugin] preprocess failed, uploading originals`,t),e}}var kje=`PNG, JPG, GIF, WebP, AVIF`,Aje=/^(?:javascript\s*:|vbscript\s*:|data\s*:(?!image\/))/i,jje=new Set([`image/gif`,`image/svg+xml`]);function uL(e){return e.type.startsWith(`image/`)}function Mje(e){return!Aje.test(e)}function dL(e){return!jje.has(e.type)}function Nje(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Pje(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>{t({width:r.naturalWidth||r.width,height:r.naturalHeight||r.height})},r.onerror=()=>n(Error(`Failed to load image`)),r.src=e})}function fL(e){try{let{pathname:t}=new URL(e);return decodeURIComponent(t.split(`/`).pop()||``)||e}catch{return e}}function pL(e,t){if(e===`replace`)return{action:`Replace`,title:`Replace image`};let n=t>1?`Insert ${t} images`:`Insert image`;return{action:n,title:n}}async function Fje(e,t){let n=[];return{entries:(await Promise.all(e.map(async e=>{if(e.kind===`url`)return{height:e.height,kind:`url`,src:e.src,width:e.width};if(e.current!==e.original||!e.removeGps||!e.gps)return{file:e.current,kind:`file`};try{if(!t)throw Error(`No GPS stripper configured`);return{file:await t(e.original),kind:`file`}}catch{return n.push(e.id),null}}))).filter(e=>e!==null),failedIds:n}}var mL=new WeakSet;function Ije(e){return mL.add(e),e}function Lje(e){return mL.has(e)}var Rje=new WeakMap;function hL(e){return(e&&Rje.get(e))??null}var gL=`rich-image-upload-dragging`,zje=6e3;function _L(e,t,n){return e>1?n.replace(`#`,String(e)):t}async function Bje(e,t){let n=async e=>{let r=Pe({title:_L(e.length,`Uploading image…`,`Uploading # images…`),tone:`loading`}),i=await t(e);i.length===0?Et(r,{title:_L(e.length,`Image inserted`,`Inserted # images`),tone:`success`}):Et(r,{action:{label:`Retry`,onClick:()=>void n(i)},duration:zje,title:_L(i.length,`Image upload failed`,`# images failed to upload`),tone:`error`})};await n(e)}function Vje(e){if(Jn(e)){let t=e.isBackward()?e.anchor:e.focus;return{kind:`point`,key:t.key,offset:t.offset,type:t.type}}if(Ue(e)){let t=e.getNodes().at(-1);if(t)return{kind:`after`,key:t.getKey()}}return null}function vL(){let e=kr();return{callerMoved:!1,expected:e?.clone()??null,point:Vje(e)}}function yL(e,t){return e===t?vL():t.getEditorState().read(vL)}function bL(e,t){let n=Dn(e);return n?.isAttached()?t===`text`?it(n)?n.getTextContentSize():null:rr(n)?n.getChildrenSize():null:null}function Hje(e){if(!e)return null;let t=e.key,n,r=`element`;if(e.kind===`after`){let r=Dn(e.key),i=r?.isAttached()?r.getParent():null;if(!r||!i)return null;t=i.getKey(),n=r.getIndexWithinParent()+1}else{let t=bL(e.key,e.type);if(t===null)return null;n=Math.min(e.offset,t),r=e.type}let i=zt();return i.anchor.set(t,n,r),i.focus.set(t,n,r),i}function xL(e){let t=bL(e.key,e.type);return t!==null&&e.offset<=t}function Uje(e){return Jn(e)?xL(e.anchor)&&xL(e.focus):e.getNodes().every(e=>e.isAttached())}function SL(e,t){if(t.length===0)return;let n=Hje(e.point),r=kr(),i=(e.callerMoved||(r===null?e.expected!==null:!r.is(e.expected)))&&r?r.clone():null;n&&Jt(n),Un(t),i&&Uje(i)&&(Jt(i),e.callerMoved=!0),e.expected=kr()?.clone()??null,e.point={kind:`after`,key:t.at(-1).getKey()}}var Wje=`dtt1x70`,Gje=`dtt1x71`,Kje=`dtt1x72`,qje=`dtt1x73`,CL=`dtt1x75 dtt1x74`,Jje=`dtt1x76 dtt1x75 dtt1x74`,Yje=`dtt1x77`,Xje=`dtt1x78`,Zje=`dtt1x79`,Qje=`dtt1x7a`,$je=`dtt1x7b dtt1x74`,eMe=`dtt1x7g`,wL=`dtt1x7h`,tMe=`dtt1x7i`,TL=`dtt1x7j`,EL=`dtt1x7k`,nMe=`dtt1x7l`,DL=`dtt1x7m`,OL=`dtt1x7o dtt1x74`;function rMe(e){let[t,n]=(0,G.useState)(null),[r,i]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{if(typeof URL.createObjectURL!=`function`)return;let t=URL.createObjectURL(e),r=!0;i(!1);let a=new Image;return a.onload=()=>{r&&n({height:a.naturalHeight,url:t,width:a.naturalWidth})},a.onerror=()=>{r&&i(!0)},a.src=t,()=>{r=!1,URL.revokeObjectURL(t)}},[e]),{failed:r,info:t}}function kL({editLabel:e=`Edit`,name:t,onEdit:n,onRemove:r}){return(0,K.jsxs)(K.Fragment,{children:[n&&(0,K.jsxs)(Fe,{size:`sm`,variant:`outline`,onClick:n,children:[(0,K.jsx)(Ae,{"aria-hidden":!0,size:14}),e]}),(0,K.jsx)(Fe,{icon:!0,"aria-label":`Remove ${t}`,size:`sm`,title:`Remove`,onClick:r,children:(0,K.jsx)(k,{"aria-hidden":!0,size:16})})]})}function iMe({canEdit:e,failed:t,onEdit:n,onRemove:r,onToggleGps:i,row:a}){let{failed:o,info:s}=rMe(a.current),c=a.current!==a.original,l=e&&dL(a.current)&&!o,u=a.current.type.replace(`image/`,``).toUpperCase(),d=[c&&a.summary||null,s?`${s.width} × ${s.height}`:null,Nje(a.current.size),c?null:u||null].filter(Boolean).join(` · `);return(0,K.jsxs)(`div`,{className:t?`${wL} ${tMe}`:wL,"data-image-dialog-row":``,children:[s?(0,K.jsx)(`img`,{alt:``,className:TL,src:s.url}):(0,K.jsx)(`div`,{className:TL}),(0,K.jsxs)(`div`,{className:EL,children:[(0,K.jsxs)(`div`,{className:nMe,children:[(0,K.jsx)(`span`,{className:DL,title:a.original.name,children:a.original.name}),c&&(0,K.jsx)(`span`,{className:`dtt1x7n`,children:`Edited`})]}),(0,K.jsx)(`span`,{className:OL,children:d}),e&&!dL(a.current)&&(0,K.jsx)(`span`,{className:`dtt1x7o dtt1x74`,children:`Animated or vector — editing would flatten it`}),!c&&a.gps&&(0,K.jsx)(`div`,{className:`dtt1x7p`,children:(0,K.jsx)(Xe,{checked:a.removeGps,label:`Remove GPS before upload`,onChange:i})}),t&&(0,K.jsx)(`span`,{className:`dtt1x7q dtt1x74`,children:`Could not remove location from this image`})]}),(0,K.jsx)(kL,{editLabel:c?`Re-edit`:`Edit`,name:a.original.name,onEdit:l?n:void 0,onRemove:r})]})}function aMe({canAddMore:e,canEdit:t,failedIds:n,onAddMore:r,onEdit:i,onRemove:a,onToggleGps:o,rows:s}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:eMe,children:s.map(e=>e.kind===`file`?(0,K.jsx)(iMe,{canEdit:t,failed:e.removeGps&&n.includes(e.id),row:e,onEdit:()=>i(e),onRemove:()=>a(e.id),onToggleGps:t=>o(e.id,t)},e.id):(0,K.jsxs)(`div`,{className:wL,"data-image-dialog-row":``,children:[(0,K.jsx)(`img`,{alt:``,className:TL,src:e.src}),(0,K.jsxs)(`div`,{className:EL,children:[(0,K.jsx)(`span`,{className:DL,title:e.src,children:fL(e.src)}),(0,K.jsxs)(`span`,{className:OL,children:[e.width,` × `,e.height,` · from link`]})]}),(0,K.jsx)(kL,{name:fL(e.src),onRemove:()=>a(e.id)})]},e.id))}),e&&(0,K.jsxs)(Fe,{className:`dtt1x7r`,size:`md`,variant:`ghost`,onClick:r,children:[(0,K.jsx)(zr,{"aria-hidden":!0,size:14}),`Add more`]})]})}var oMe=300;function sMe(e){return e?[...e.files].some(uL)?!0:[...e.items].some(e=>e.type.startsWith(`image/`)):!1}function cMe(e){let[t,n]=(0,G.useState)({status:`idle`});return(0,G.useEffect)(()=>{let t=e.trim();if(!t){n({status:`idle`});return}if(!Mje(t)){n({message:`Unsupported URL scheme`,status:`error`});return}n({status:`loading`});let r=!0,i=setTimeout(()=>{Pje(t).then(({height:e,width:t})=>{r&&n({height:e,status:`loaded`,width:t})},()=>{r&&n({message:`Could not load this image URL`,status:`error`})})},oMe);return()=>{r=!1,clearTimeout(i)}},[e]),t}function lMe({allowUrl:e,onAddUrl:t,onPickFiles:n,onReceiveFiles:r}){let i=(0,G.useId)(),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``),l=cMe(s),u=s.trim(),d=()=>{l.status===`loaded`&&(t({height:l.height,src:u,width:l.width}),c(``))},f=e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},p=e=>{sMe(e.dataTransfer)&&(e.preventDefault(),o(!0))},m=e=>{e.preventDefault(),o(!1);let t=[...e.dataTransfer.files].filter(uL);t.length>0&&r(t)},h=l.status===`loaded`?`Loaded · ${l.width} × ${l.height}`:l.status===`loading`?`Loading preview…`:void 0;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{"aria-label":`Drop images here or choose files`,className:Xje,"data-drag-active":a||void 0,role:`button`,tabIndex:0,onDragEnter:p,onDragLeave:()=>o(!1),onDragOver:p,onDrop:m,onKeyDown:f,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:Zje,children:(0,K.jsx)(fne,{size:18})}),(0,K.jsx)(`span`,{className:Qje,children:`Drop images here`}),(0,K.jsx)(Fe,{size:`md`,tabIndex:-1,variant:`outline`,onClick:n,children:`Choose files`}),(0,K.jsxs)(`span`,{className:$je,children:[`or press `,(0,K.jsx)(ar,{keys:[`mod`,`v`],size:`sm`}),` to paste`]})]}),e&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`dtt1x7c dtt1x74`,children:`or from a link`}),(0,K.jsx)(Kn,{error:l.status===`error`?l.message:void 0,hint:h,id:i,label:`Image URL`,children:(0,K.jsxs)(`div`,{className:`dtt1x7d`,children:[(0,K.jsx)(ct,{className:`dtt1x7e`,id:i,invalid:l.status===`error`,placeholder:`https://example.com/image.jpg`,type:`url`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d())}}),l.status===`loaded`&&(0,K.jsx)(`img`,{alt:``,className:`dtt1x7f`,src:u}),(0,K.jsx)(Fe,{disabled:l.status!==`loaded`,size:`md`,variant:`solid`,onClick:d,children:`Add`})]})})]})]})}var AL=0;function jL(e){return{current:e,gps:null,id:`image-row-${++AL}`,kind:`file`,original:e,removeGps:!0,summary:``}}function uMe(e,t){let n=(e??[]).filter(uL);return(t===`replace`?n.slice(0,1):n).map(jL)}function ML(e,t){return e.map(e=>e.kind===`file`&&t.has(e.id)?{...e,gps:t.get(e.id)??null}:e)}function dMe({allowUrl:e=!0,editor:t=null,initialFiles:n,mode:r=`insert`,onCancel:i,onDirtyChange:a,onSubmit:o,onTitleChange:s}){let c=!!n?.some(uL),[l,u]=(0,G.useState)(()=>uMe(n,r)),[d,f]=(0,G.useState)(c?`review`:`source`),[p,m]=(0,G.useState)([]),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(!1),y=(0,G.useRef)(null),b=(0,G.useRef)(new Map),x=t?.privacy,S=pL(r,d===`review`?l.length:1),C=l.some(e=>e.kind===`file`&&e.current!==e.original)||!c&&l.length>0;(0,G.useEffect)(()=>{s?.(S.title)},[S.title,s]),(0,G.useEffect)(()=>{a?.(C)},[C,a]),(0,G.useEffect)(()=>{if(x)for(let e of l){if(e.kind!==`file`||b.current.has(e.id))continue;let t=x.detectGps(e.original).catch(()=>null);b.current.set(e.id,t),t.then(t=>{u(n=>ML(n,new Map([[e.id,t]])))})}},[x,l]);let w=e=>{let t=e.filter(uL);t.length!==0&&(m([]),u(e=>r===`replace`?[jL(t[0])]:[...e,...t.map(jL)]),f(`review`))},T=e=>{let t={...e,id:`image-row-${++AL}`,kind:`url`};u(e=>r===`replace`?[t]:[...e,t]),f(`review`)},E=e=>{let t=l.filter(t=>t.id!==e);u(t),t.length>0||(c?i():f(`source`))},D=async e=>{if(!t)return;let n=await t.edit(e.current);n&&n.file!==e.current&&u(t=>t.map(t=>t.id===e.id&&t.kind===`file`?{...t,current:n.file,summary:[t.summary,n.summary].filter(Boolean).join(` · `)}:t))},O=(e,t)=>{u(n=>n.map(n=>n.id===e&&n.kind===`file`?{...n,removeGps:t}:n))},k=p.some(e=>l.some(t=>t.id===e&&t.kind===`file`&&t.removeGps&&t.gps&&t.current===t.original)),A=async()=>{if(h||k||l.length===0)return;g(!0);let e=[...b.current.keys()],t=await Promise.all(e.map(e=>b.current.get(e))),n=ML(l,new Map(e.map((e,n)=>[e,t[n]]))),r=await Fje(n,x?.stripGps);if(g(!1),r.failedIds.length>0)u(n),m(r.failedIds);else{if(_)for(let e of r.entries)e.kind===`file`&&Ije(e.file);o(r.entries)}},j=e=>{d===`review`&&e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),A())},M=e=>{let t=[...e.clipboardData?.files??[]].filter(uL);t.length!==0&&(e.preventDefault(),w(t))},N=()=>y.current?.click();return(0,K.jsxs)(`div`,{className:Gje,onKeyDown:j,onPaste:M,children:[(0,K.jsx)(`input`,{accept:`image/*`,className:Yje,multiple:r!==`replace`,ref:y,type:`file`,onChange:e=>{w([...e.currentTarget.files??[]]),e.currentTarget.value=``}}),(0,K.jsxs)(`div`,{className:Kje,children:[d===`source`?(0,K.jsx)(lMe,{allowUrl:e,onAddUrl:T,onPickFiles:N,onReceiveFiles:w}):(0,K.jsx)(aMe,{canAddMore:r!==`replace`,canEdit:!!t,failedIds:p,rows:l,onAddMore:N,onEdit:e=>void D(e),onRemove:E,onToggleGps:O}),d===`review`&&t?.allowKeepOriginal&&l.some(e=>e.kind===`file`)&&(0,K.jsx)(`div`,{className:`dtt1x7s`,children:(0,K.jsx)(Xe,{checked:_,label:`Keep original (skip compression)`,onChange:v})})]}),(0,K.jsx)(`div`,{className:qje,children:d===`source`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:CL,children:kje}),l.length>0&&(0,K.jsx)(Fe,{size:`md`,variant:`outline`,onClick:()=>f(`review`),children:`Continue`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:k?Jje:CL,children:k?`Keep the location or remove the flagged images to continue`:`Nothing is uploaded until you insert`}),c?(0,K.jsx)(Fe,{size:`md`,variant:`outline`,onClick:i,children:`Cancel`}):(0,K.jsx)(Fe,{size:`md`,variant:`outline`,onClick:()=>f(`source`),children:`Back`}),(0,K.jsxs)(Fe,{autoFocus:!0,disabled:h||k,size:`md`,variant:`solid`,onClick:()=>void A(),children:[S.action,(0,K.jsx)(ar,{keys:[`mod`,`enter`],size:`sm`,tone:`inverted`})]})]})})]})}function fMe(e){let t=e,n=new Set;return{get:()=>t,set:e=>{if(e!==t){t=e;for(let e of n)e()}},subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function pMe({store:e}){return(0,G.useSyncExternalStore)(e.subscribe,e.get,e.get)}function NL({allowUrl:e=!0,editor:t=null,files:n,mode:r=`insert`,portalClassName:i,theme:a}={}){return new Promise(o=>{let s=!1,c=e=>{s||(s=!0,o(e))},l=!1,u=e=>{l=e},d=fMe(pL(r,n?.length??1).title);At({className:Wje,confirmDismiss:()=>!l||Se(),onClose:()=>c(null),portalClassName:i,sheet:`auto`,theme:a,title:(0,K.jsx)(pMe,{store:d}),width:520,content:({dismiss:i,requestDismiss:a})=>(0,K.jsx)(dMe,{allowUrl:e,editor:t,initialFiles:n,mode:r,onCancel:()=>void a(),onDirtyChange:u,onTitleChange:d.set,onSubmit:e=>{c(e),i()}})})})}function PL(e,t){return Lje(t)?e(t,{keepOriginal:!0}):e(t)}function FL(e){return e?[...e.files].some(uL)?!0:[...e.items].some(e=>e.type.startsWith(`image/`)):!1}function mMe(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error??Error(`File read failed`)),r.readAsDataURL(e)})}async function IL(e){return{src:await mMe(e),altText:e.name}}function hMe({onUpload:e}){let t=$k(),n=(0,G.useRef)(t);n.current=t;let[r]=ht(),i=(0,G.useRef)(e);i.current=e;let a=iL(),o=(0,G.useRef)(a);o.current=a;let s=We(),c=(0,G.useRef)(s);c.current=s;let l=(0,G.useCallback)(async(e,t,r,a)=>{let o=n.current?.retain();try{let[n,o]=await Promise.all([PL(i.current,e),Qj(e)]);await a,t.update(()=>{SL(r,[WN(RN({src:n.src,altText:n.altText??e.name,width:n.width??o.width,height:n.height??o.height,thumbhash:n.thumbhash??o.thumbhash}))])})}finally{queueMicrotask(()=>o?.())}},[]),u=(0,G.useCallback)((e,t,n)=>Bje(e,async e=>{let r=Promise.resolve(),i=e.map(e=>{let i=l(e,t,n,r.catch(()=>{}));return r=i,i}),a=await Promise.allSettled(i);return e.filter((e,t)=>{let n=a[t];return n.status!==`fulfilled`&&(console.error(`[ImageUploadPlugin]`,n.reason),!0)})}),[l]),d=(0,G.useCallback)((e,t,i)=>{let a=e.filter(uL);if(a.length===0)return!1;let s=yL(r,i);return(async()=>{let e=n.current?.retain();try{let e=o.current?.ref.current??null,n=await lL(a,t,e);n.length>0&&await u(n,i,s)}finally{queueMicrotask(()=>e?.())}})(),!0},[r,u]),f=(0,G.useCallback)(async(e,t)=>{let r=n.current?.retain();try{let n=o.current,r=hL(n),i=await NL({editor:r,portalClassName:c.current.className,theme:c.current.theme});if(!i)return;let a=i.flatMap(e=>e.kind===`url`?[e]:[]);a.length>0&&e.update(()=>{SL(t,a.map(e=>WN(RN({src:e.src,altText:``,width:e.width,height:e.height}))))});let s=i.flatMap(e=>e.kind===`file`?[e.file]:[]),l=r?s:await lL(s,`dialog`,n?.ref.current??null);l.length>0&&await u(l,e,t)}finally{queueMicrotask(()=>r?.())}},[u]);return(0,G.useEffect)(()=>{let e=r.registerCommand(yt,(e,t)=>d(e,`drop`,t),3),t=r.registerCommand(or,(e,t)=>{let n=`clipboardData`in e?e.clipboardData:null;if(!n)return!1;let r=[...n.files];return r.some(uL)?d(r,`paste`,t):!1},3),n=r.registerCommand(LN,(e,t)=>(f(t,yL(r,t)),!0),0),i=r.getRootElement(),a=i?.parentElement??null;if(!i||!a)return()=>{e(),t(),n()};let o=0,s=e=>{FL(e.dataTransfer)&&(o+=1,a.classList.add(gL))},c=e=>{FL(e.dataTransfer)&&e.preventDefault()},l=()=>{o=Math.max(o-1,0),o===0&&a.classList.remove(gL)},u=()=>{o=0,a.classList.remove(gL)};return i.addEventListener(`dragenter`,s),i.addEventListener(`dragover`,c),i.addEventListener(`dragleave`,l),i.addEventListener(`drop`,u),()=>{e(),t(),n(),a.classList.remove(gL),i.removeEventListener(`dragenter`,s),i.removeEventListener(`dragover`,c),i.removeEventListener(`dragleave`,l),i.removeEventListener(`drop`,u)}},[r,d,f]),null}function gMe(e,t){if(e.dataset.faviconHref===t)return;e.dataset.faviconHref=t;let n=NF(t);n&&PF(n).then(t=>{t&&(e.style.setProperty(`--rc-link-favicon`,`url(${t})`),e.dataset.favicon=`loaded`)})}function _Me(){let[e]=ht();return(0,G.useEffect)(()=>{let t=t=>{for(let[n,r]of t){if(r===`destroyed`)continue;let t=e.getElementByKey(n);if(!t)continue;let i=t.getAttribute(`href`);i&&gMe(t,i)}},n=e.registerMutationListener(dr,t),r=e.registerMutationListener(Cn,t);return()=>{n(),r()}},[e]),null}function vMe(e,t){return e===t?!0:!e||!t?!1:e.text===t.text&&e.anchorBlockId===t.anchorBlockId&&e.anchorOffset===t.anchorOffset&&e.focusBlockId===t.focusBlockId&&e.focusOffset===t.focusOffset}function yMe(e={snapshot:null}){let t=e,n=new Set,r=()=>{for(let e of n)e()};return{getState:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)}),setSnapshot:e=>{vMe(t.snapshot,e)||(t={...t,snapshot:e},r())},clearSnapshot:()=>{t.snapshot!==null&&(t={...t,snapshot:null},r())}}}var LL=(0,G.createContext)(null);function bMe({children:e}){let t=(0,G.useRef)(null);return t.current||=yMe(),(0,K.jsx)(LL.Provider,{value:t.current,children:e})}function RL(){let e=(0,G.use)(LL);if(!e)throw Error(`useTextSelectionStore must be used within TextSelectionStoreProvider`);return e}function zL(){let e=RL();return(0,G.useSyncExternalStore)(e.subscribe,()=>e.getState().snapshot,()=>e.getState().snapshot)}function BL(e){let t=Sr(),n=e;for(;n;){let e=n.getParent();if(e===t&&`getChildren`in n)return n;n=e}return null}function VL(e,t){let n=e[t],r=n.getNode();if(rr(r)){let e=r.getChildren();if(n.offset<e.length)return{node:e[n.offset],offset:0};let t=e.at(-1);return t&&it(t)?{node:t,offset:t.getTextContentSize()}:{node:r,offset:0}}return{node:r,offset:n.offset}}function HL(e,t,n){let r=0;function i(e){if(e.is(t))return r+=n,!0;if(it(e))r+=e.getTextContentSize();else if(lr(e))r+=1;else if(rr(e)){for(let t of e.getChildren())if(i(t))return!0}return!1}for(let t of e.getChildren())if(i(t))break;return r}var UL=`rich-editor-text-selection`,WL=`rich-editor-text-selection-inactive`;function xMe(e,t){return Math.max(0,Math.min(e,t))}function GL(e){return e.tagName===`SUMMARY`&&e.parentElement?.tagName===`DETAILS`||e.getAttribute(`contenteditable`)===`false`}function KL(e){if(e.nodeType===Node.TEXT_NODE)return e.textContent?.length??0;if(e.nodeType!==Node.ELEMENT_NODE)return 0;let t=e;if(GL(t))return 0;if(t.tagName===`BR`)return 1;let n=0;for(let t of e.childNodes)n+=KL(t);return n}function SMe(e,t){if(e===t)return 0;let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0}function CMe(e){if(!e.length)return null;let t=e[0].left,n=e[0].top,r=e[0].right,i=e[0].bottom;for(let a of e.slice(1))t=Math.min(t,a.left),n=Math.min(n,a.top),r=Math.max(r,a.right),i=Math.max(i,a.bottom);return new DOMRect(t,n,r-t,i-n)}function wMe(e){if(e.isCollapsed())return null;let t=BL(e.anchor.getNode()),n=BL(e.focus.getNode());if(!t||!n)return null;let r=Hn(t,rA),i=Hn(n,rA);if(!r||!i)return null;let a=VL(e,`anchor`),o=VL(e,`focus`);return{text:e.getTextContent(),anchorBlockId:r,anchorOffset:HL(t,a.node,a.offset),focusBlockId:i,focusOffset:HL(n,o.node,o.offset)}}function TMe(){let e=kr();return Jn(e)?wMe(e):null}function qL(e,t,n=`backward`){let r=xMe(t,KL(e)),i=0;function a(e){if(e.nodeType===Node.TEXT_NODE){let t=e.textContent?.length??0;return(n===`forward`?r<i+t:r<=i+t)?{node:e,offset:r-i}:(i+=t,null)}if(e.nodeType!==Node.ELEMENT_NODE)return null;let t=e;if(GL(t))return null;if(t.tagName===`BR`){let e=t.parentNode;if(!e)return null;let n=Array.from(e.childNodes).indexOf(t);return r===i?{node:e,offset:n}:r===i+1?{node:e,offset:n+1}:(i+=1,null)}for(let t of e.childNodes){let e=a(t);if(e)return e}return null}return a(e)??{node:e,offset:e.childNodes.length}}function JL(e,t){return e.querySelector(`[data-block-id="${t}"]`)}function YL(e,t){let n=JL(e,t.anchorBlockId),r=JL(e,t.focusBlockId);if(!n||!r)return null;let i=n===r?t.anchorOffset<=t.focusOffset:SMe(n,r)<=0,a=i?qL(n,t.anchorOffset,`forward`):qL(r,t.focusOffset,`forward`),o=i?qL(r,t.focusOffset):qL(n,t.anchorOffset);if(!a||!o)return null;try{let e=document.createRange();return e.setStart(a.node,a.offset),e.setEnd(o.node,o.offset),e}catch{return null}}function EMe(e,t){let n=YL(e,t);if(!n)return null;let r=n.getBoundingClientRect();return r.width>0||r.height>0?r:CMe(Array.from(n.getClientRects()))}var XL=`gr1ebt0`,ZL=`gr1ebt1`,QL=`gr1ebt2`,$L=null,eR=[XL,ZL,QL];function tR(){return typeof CSS>`u`||!(`highlights`in CSS)||typeof Highlight>`u`?null:CSS.highlights}function nR(e){if(e&&e!==$L){e.classList.remove(...eR);return}let t=tR();t?.delete(UL),t?.delete(WL),$L?.classList.remove(...eR),$L=null}function DMe(){let[e]=ht(),t=RL(),n=zL(),[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(!1),s=(0,G.useRef)(null),c=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let n=()=>{if(!e.getRootElement()){t.clearSnapshot();return}let n=e.getEditorState().read(()=>TMe());t.setSnapshot(n)},r=()=>{let t=e.getRootElement(),n=t?.ownerDocument.activeElement;i(!!(t&&n&&t.contains(n))),o(!!(t&&n===t))},a=()=>{c.current!==null&&cancelAnimationFrame(c.current),c.current=requestAnimationFrame(()=>{c.current=null,r()})},s=e.registerCommand(mn,()=>(n(),!1),1),l=e.registerUpdateListener(()=>{n()}),u=e.getRootElement();if(u){let e=e=>{let r=e.target;if(!r)return;let i=r.closest(`[contenteditable="true"]`);i&&i!==u?(t.clearSnapshot(),a()):(a(),n())},i=()=>{a(),n()};return u.addEventListener(`focusin`,e),u.addEventListener(`focusout`,i),r(),n(),()=>{s(),l(),c.current!==null&&(cancelAnimationFrame(c.current),c.current=null),u.removeEventListener(`focusin`,e),u.removeEventListener(`focusout`,i),t.clearSnapshot()}}return r(),n(),()=>{s(),l(),c.current!==null&&(cancelAnimationFrame(c.current),c.current=null),t.clearSnapshot()}},[e,t]),(0,G.useEffect)(()=>{let t=tR(),i=()=>{s.current!==null&&(cancelAnimationFrame(s.current),s.current=null)};return i(),s.current=requestAnimationFrame(()=>{s.current=null;let i=e.getRootElement();if(!i){nR();return}if(!n){let e=i.ownerDocument.getSelection();if(a&&(!e||e.isCollapsed)){$L===i&&(t?.delete(UL),t?.delete(WL));return}nR(i);return}$L&&$L!==i&&$L.classList.remove(...eR);let o=t?YL(i,n):null;if(t&&!o){nR(i);return}let c=o?QL:r?XL:ZL;if(i.classList.remove(...eR.filter(e=>e!==c)),i.classList.add(c),$L=i,!t||!o)return;let l=r?UL:WL,u=r?WL:UL;t.delete(u),t.set(l,new Highlight(o))}),i},[e,r,a,n]),(0,G.useEffect)(()=>()=>nR(e.getRootElement()),[e]),null}function rR(e){return e.type.startsWith(`video/`)}function iR(e){return e?[...e.files].some(rR)?!0:[...e.items].some(e=>e.type.startsWith(`video/`)):!1}var OMe=6e3;function kMe({onUpload:e}){let t=$k(),n=(0,G.useRef)(t);n.current=t;let[r]=ht(),i=(0,G.useRef)(e);i.current=e;let a=(0,G.useCallback)(async(e,t)=>{let o=n.current?.retain(),s=Pe({title:`Uploading video…`,tone:`loading`});try{let n=await i.current(e,{onProgress:e=>{Et(s,{title:`Uploading video… ${Math.round(e)}%`})}});r.update(()=>{SL(t,[aF({src:n.src})])}),Et(s,{title:`Video uploaded`,tone:`success`})}catch(n){console.error(`[VideoUploadPlugin]`,n),Et(s,{action:{label:`Retry`,onClick:()=>void a(e,t)},duration:OMe,title:`Video upload failed`,tone:`error`})}finally{queueMicrotask(()=>o?.())}},[r]),o=(0,G.useCallback)(e=>{let t=e.filter(rR);if(t.length===0)return!1;let n=vL();for(let e of t)a(e,n);return t.length===e.length},[a]);return(0,G.useEffect)(()=>{let e=r.registerCommand(yt,e=>o(e),4),t=r.registerCommand(or,e=>{let t=`clipboardData`in e?e.clipboardData:null;if(!t)return!1;let n=[...t.files];return n.some(rR)?o(n):!1},4),n=r.getRootElement(),i=n?.parentElement??null;if(!n||!i)return()=>{e(),t()};let a=0,s=e=>{iR(e.dataTransfer)&&(a+=1,i.classList.add(gL))},c=e=>{iR(e.dataTransfer)&&e.preventDefault()},l=()=>{a=Math.max(a-1,0),a===0&&i.classList.remove(gL)},u=()=>{a=0,i.classList.remove(gL)};return n.addEventListener(`dragenter`,s),n.addEventListener(`dragover`,c),n.addEventListener(`dragleave`,l),n.addEventListener(`drop`,u),()=>{e(),t(),i.classList.remove(gL),n.removeEventListener(`dragenter`,s),n.removeEventListener(`dragover`,c),n.removeEventListener(`dragleave`,l),n.removeEventListener(`drop`,u)}},[r,o]),null}function AMe({onEditorReady:e}){let[t]=ht(),n=(0,G.useRef)(e);return n.current=e,(0,G.useEffect)(()=>(n.current?.(t),()=>n.current?.(null)),[t]),null}function aR(e,t){if(e===t)return!0;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>n in t&&e[n]===t[n])}function jMe({children:e}){let[t]=ht(),[n,r]=(0,G.useState)({}),[i,a]=(0,G.useState)({}),o=(0,G.useRef)(!1);return(0,G.useEffect)(()=>t.registerUpdateListener(({editorState:e})=>{e.read(()=>{let e=xn(CN),n=new Set,i={},s=1;for(let t of e){let e=t.getIdentifier();n.has(e)||(n.add(e),i[e]=s++)}a(e=>aR(e,i)?e:i);let c=xn(YP),l=c.length>0?c[0].getDefinitions():{};if(r(e=>aR(e,l)?e:l),t.isEditable()&&!o.current){if(e.length===0&&c.length>0)o.current=!0,queueMicrotask(()=>{t.update(()=>{let e=xn(YP);for(let t of e)t.remove()}),o.current=!1});else if(e.length>0&&c.length===0){let e=[...n];o.current=!0,queueMicrotask(()=>{t.update(()=>{let t=Sr(),n={};for(let t of e)n[t]=``;let r=Ne({type:`footnote-section`,definitions:n,version:1});t.append(r)}),o.current=!1})}else if(c.length>0){let e=c[0].getDefinitions(),r=[...n].filter(t=>!(t in e)),i=Object.keys(e).filter(e=>!n.has(e));(r.length>0||i.length>0)&&(o.current=!0,queueMicrotask(()=>{t.update(()=>{let e=xn(YP);if(e.length>0){for(let t of r)e[0].setDefinition(t,``);for(let t of i)e[0].removeDefinition(t)}}),o.current=!1}))}}})}),[t]),(0,K.jsx)(Yj,{definitions:n,displayNumberMap:i,children:e})}function MMe({onChange:e,debounceMs:t}){let[n]=ht(),r=(0,G.useRef)(void 0),i=(0,G.useRef)(e);return i.current=e,(0,G.useEffect)(()=>{let e=n.registerUpdateListener(({editorState:e})=>{let n=i.current;if(!n)return;let a=zF(e.toJSON());t&&t>0?(clearTimeout(r.current),r.current=setTimeout(()=>{n(a)},t)):n(a)});return()=>{clearTimeout(r.current),e()}},[n,t]),null}function NMe({onSubmit:e}){let[t]=ht();return(0,G.useEffect)(()=>{if(e)return t.registerCommand(an,t=>t&&(t.metaKey||t.ctrlKey)?(t.preventDefault(),e(),!0):!1,3)},[t,e]),null}function PMe(){let[e]=ht();return(0,G.useEffect)(()=>{let t=e.getRootElement();t?t.focus({preventScroll:!0}):e.focus()},[e]),null}function FMe({href:e,source:t,noIcon:n=!1,className:r,platformIconMap:i,getPlatformFromUrl:a}){let o=Fj(Nj.linkFavicon,Pj.linkFavicon,r),[s,c]=(0,G.useState)(null);if((0,G.useEffect)(()=>{if(!e)return;let t=NF(e);if(!t)return;let n=!1;return PF(t).then(e=>{n||c(e)}),()=>{n=!0}},[e]),n||!e&&!t)return null;let l=t;if(!l&&e&&a)try{l=a(new URL(e))??void 0}catch{}if(l&&i?.[l])return(0,K.jsx)(`span`,{className:o,children:i[l]});if(s)return(0,K.jsx)(`span`,{className:o,children:(0,K.jsx)(`img`,{alt:``,"aria-hidden":`true`,height:14,src:s,width:14})});let u=e?.toLowerCase().startsWith(`mailto:`);return(0,K.jsx)(`span`,{className:o,children:u?(0,K.jsx)(zne,{"aria-hidden":!0,size:14}):(0,K.jsx)(E,{"aria-hidden":!0,size:14})})}var IMe=(0,G.createContext)(void 0);function LMe({children:e,extraNodes:t}){let n=(0,G.useMemo)(()=>t,[t]);return(0,K.jsx)(IMe.Provider,{value:n,children:e})}var RMe=Rn(`INSERT_ALERT`);function zMe(){let[e]=ht();return(0,G.useEffect)(()=>e.registerCommand(RMe,e=>(Un([gF(e)]),!0),0),[e]),null}var BMe=Rn(`INSERT_IMAGE_COMMAND`);function VMe(){let[e]=ht();return(0,G.useEffect)(()=>e.registerCommand(BMe,e=>{let t=WN(RN(e),{autoOpenOnMount:!e.src});return Un([t]),!0},0),[e]),null}var HMe=Rn(`INSERT_KATEX_INLINE`),UMe=Rn(`INSERT_KATEX_BLOCK`);function WMe(){let[e]=ht();return(0,G.useEffect)(()=>{let t=e.registerCommand(HMe,e=>{let t=QN(e,{autoOpenOnMount:!e.trim()});return Un([t]),!0},0),n=e.registerCommand(UMe,e=>{let t=YN(e,{autoOpenOnMount:!e.trim()});return Un([t]),!0},0);return()=>{t(),n()}},[e]),null}var GMe=Rn(`INSERT_MERMAID`);function KMe(){let[e]=ht();return(0,G.useEffect)(()=>e.registerCommand(GMe,e=>{let t=rP(e);return Un([t]),!0},0),[e]),null}var oR={inline:`rich-katex-inline`,block:`rich-katex-block`,fallback:`rich-katex-fallback`},sR={inline:`egstxq0`,block:`egstxq1`,fallback:`egstxq2`};function qMe({className:e,placeholder:t,hasHeader:n}){let r=n?40:12;return(0,K.jsx)(`div`,{className:Fj(`rich-editor__content-wrapper`,lA),style:{"--ce-padding-top":`${r}px`},children:(0,K.jsx)(Ee,{"aria-placeholder":t??``,className:Fj(`rich-editor__content`,uA,e),placeholder:(0,K.jsx)(`div`,{className:Fj(`rich-editor__placeholder`,bCe),style:{display:t?void 0:`none`},children:t})})})}function JMe({className:e,hasHeader:t,placeholder:n,plugins:r,autoFocus:i,onActiveEditorChange:a}){let[o]=ht();return(0,G.useLayoutEffect)(()=>(a(o),()=>a(null)),[o,a]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Yt,{ErrorBoundary:Nt,contentEditable:(0,K.jsx)(qMe,{className:e,hasHeader:t,placeholder:n})}),r,i&&(0,K.jsx)(PMe,{})]})}function YMe(e){let{surface:t,plugins:n,setActiveEditor:r,retainSurface:i}=VF(),a=(0,G.useRef)(t);a.current=t;let o=(0,G.useCallback)(e=>{a.current===t&&r(e)},[r,t]),[s,c]=(0,G.useState)(!1);return(0,G.useLayoutEffect)(()=>c(!0),[]),s?(0,K.jsx)(t??JMe,{...e,plugins:n,retainSurface:i,onActiveEditorChange:o}):null}function XMe({value:e}){return e===void 0?null:e===!1?(0,K.jsx)(HF,{priority:1,surface:null}):(0,K.jsx)(wke,{...e===!0?{}:e,priority:1})}function ZMe({nodes:e,initialValue:t,onChange:n,variant:r=`article`,theme:i=`light`,placeholder:a=`Write something...`,onSubmit:o,autoFocus:s=!1,className:c,contentClassName:l,style:u,actions:d,header:f,onEditorReady:p,rendererConfig:m,debounceMs:h,children:g,virtualization:_}){mke(e);let v=(0,G.useMemo)(()=>t?zF(t):void 0,[t]),y={namespace:`RichEditor`,theme:mP,nodes:e,editable:!0,onError:e=>{console.error(`[RichEditor]`,e)},...v?{editorState:JSON.stringify(v)}:{}},b=Ij(r);return(0,K.jsx)(Oe,{className:b,theme:i,children:(0,K.jsx)(cF,{colorScheme:i,children:(0,K.jsx)(Wj,{config:m,mode:`editor`,variant:r,children:(0,K.jsx)(_e,{initialConfig:y,children:(0,K.jsxs)(yke,{children:[(0,K.jsx)(XMe,{value:_}),(0,K.jsx)(bMe,{children:(0,K.jsx)(jMe,{children:(0,K.jsxs)(`div`,{suppressHydrationWarning:!0,className:Fj(`rich-editor`,b,c),"data-theme":i,style:{...u,maxWidth:`none`},children:[(0,K.jsx)(WF,{children:f}),(0,K.jsx)(YMe,{autoFocus:s,className:l,hasHeader:!!f,placeholder:a}),(0,K.jsx)(cee,{}),(0,K.jsx)(MMe,{debounceMs:h,onChange:n}),(0,K.jsx)(NMe,{onSubmit:o}),(0,K.jsx)(AMe,{onEditorReady:p}),(0,K.jsx)(UF,{children:(0,K.jsx)(Ete,{})}),g,d&&(0,K.jsx)(`div`,{className:`rich-editor__actions`,children:(0,K.jsx)(WF,{children:d})})]})})})]})})})})})}function cR({extraNodes:e,imageUpload:t,videoUpload:n,fileUpload:r,children:i,...a}){let o=e?[...kF,...e]:kF,s=t??IL;return(0,K.jsx)(Sje,{children:(0,K.jsx)(Cje,{upload:s,children:(0,K.jsx)(Eje,{upload:n??null,children:(0,K.jsx)(xje,{upload:r??null,children:(0,K.jsx)(LMe,{extraNodes:e,children:(0,K.jsxs)(ZMe,{nodes:o,...a,children:[(0,K.jsxs)(UF,{children:[(0,K.jsx)(yje,{}),(0,K.jsx)(VMe,{}),(0,K.jsx)(hMe,{onUpload:s}),n?(0,K.jsx)(kMe,{onUpload:n}):null,r?(0,K.jsx)(Oje,{onUpload:r}):null,(0,K.jsx)(WMe,{}),(0,K.jsx)(zMe,{}),(0,K.jsx)(KMe,{}),(0,K.jsx)(_Me,{}),(0,K.jsx)(DMe,{})]}),(0,K.jsx)(yCe,{}),i]})})})})})})}var QMe=(e,t)=>e.kind===`node`?t.kind===`node`&&e.id===t.id:t.kind===`edge`&&e.from===t.from&&e.to===t.to&&e.index===t.index;function lR(e,t,n){let r=e.find(e=>QMe(e.target,t));return!r||t.kind===`edge`&&n&&r.label!==n?null:r}function uR(e,t){return e.kind===`node`?t||e.id:`${e.from} → ${e.to}${t?` · ${t}`:``}`}var dR=18,$Me=new Set([`P`,`LI`,`DIV`,`BR`,`PRE`,`BLOCKQUOTE`,`TR`,`TD`,`TH`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`UL`,`OL`,`TABLE`,`FIGCAPTION`]);function eNe(e){let t=``,n=e=>{if(e.nodeType===Node.TEXT_NODE){t+=e.textContent??``;return}if(!(e instanceof Element))return;let r=$Me.has(e.tagName);r&&(t+=` `),e.childNodes.forEach(n),r&&(t+=` `)};return n(e),t}var tNe=e=>e.replaceAll(/\s+/g,` `).trim(),nNe=e=>e.length>dR?`${e.slice(0,dR).trimEnd()}…`:e;function fR(e){let t=e.map(tNe);if(t.length===1)return t[0]||null;let n=[t.find(Boolean),[...t].reverse().find(Boolean)].filter((e,t,n)=>!!e&&n.indexOf(e)===t);return n.length?`${i(`composer.blocks`,{count:t.length})} · ${n.map(nNe).join(` → `)}`:null}function pR(e,t){if(e.diagram)return uR(e.diagram,e.quote);if(e.quote)return e.quote;let n=t?fR(t):null;if(n)return n;let r=Ur(e).length;return r>1?i(`document.wholeBlocks`,{count:r}):i(`document.wholeBlock`)}function rNe(e,t,n){if(!t)return`block`;let r=n!==void 0&&e.slice(n,n+t.length)===t?n:e.indexOf(t);return r===-1?`block`:{start:r,end:r+t.length}}function mR(e,t){return new Set(e.filter(e=>e.status===`open`||e.id===t).map(e=>e.id))}var hR=`g.pele-node, g.pele-edge, g.pele-edge-label`,gR=`ryugi-edge-hit`,iNe=`ryugi-edge-mark`,_R=e=>`${e.classList.contains(`pele-node`)?`node`:`edge`}:${e.getAttribute(`data-id`)}`,vR=e=>`${e.kind}:${e.domId}`,yR=e=>e.classList.contains(`pele-edge-label`)||e.classList.contains(`pele-actor-footer`);function bR(e,t,n){n==null?e.removeAttribute(t):e.setAttribute(t,n)}function aNe(e){if(e.querySelector(`.${gR}`))return;let t=e.querySelector(`path:not(.pele-marker)`);if(t)for(let n of[gR,iNe]){let r=t.cloneNode(!1);r.setAttribute(`class`,n),e.prepend(r)}}function xR(e,t,n,r,i){let a=new Map(t.map(e=>[vR(e),e]));for(let t of e.querySelectorAll(hR)){let e=a.get(_R(t)),o=e?n.get(e):void 0,s=r&&e&&!yR(t);bR(t,`data-pick`,r&&e?``:null),bR(t,`tabindex`,s?`0`:null),bR(t,`role`,s?`button`:null),bR(t,`aria-label`,s?i(e):null),bR(t,`data-comment`,o?.state),bR(t,`data-comment-thread`,o?.threadIds.length&&!yR(t)?o.threadIds.join(` `):null),e?.kind===`edge`&&t.classList.contains(`pele-edge`)&&aNe(t)}}function SR(e,t,n){let r=e instanceof Element?e.closest(hR):null;if(!r||!t.contains(r))return null;let i=_R(r),a=n.find(e=>vR(e)===i);return a?{element:a,node:[...t.querySelectorAll(hR)].find(e=>!yR(e)&&_R(e)===i)??r}:null}function CR(e,t){let n=t?vR(t):null;for(let t of e.querySelectorAll(hR))bR(t,`data-hover`,n!==null&&_R(t)===n?``:null)}function oNe(e,t){for(let n of e.querySelectorAll(`[data-comment-thread]`))if(n.getAttribute(`data-comment-thread`).split(` `).includes(t))return n;return null}function sNe(e){let t=e.getBoundingClientRect(),n=e.querySelector(`.${gR}`),r=n?.getScreenCTM?.();if(n&&r&&typeof n.getTotalLength==`function`){let e=n.getPointAtLength(n.getTotalLength()/2).matrixTransform(r);return{x:e.x,y:e.y}}return n?{x:t.left+t.width/2,y:t.top+t.height/2}:{x:t.right,y:t.top+t.height/2}}var wR=`ryugi:read-resolutions`,cNe=500;function TR(){try{let e=JSON.parse(globalThis.localStorage?.getItem(wR)??`null`);return e&&typeof e==`object`?e:{}}catch{return{}}}var ER=e=>e.status===`resolved`&&e.statusBy===`agent`&&TR()[e.id]!==e.statusAt;function DR(e){let t=TR();delete t[e.id],t[e.id]=e.statusAt;let n=Object.keys(t);for(let e of n.slice(0,Math.max(0,n.length-cNe)))delete t[e];try{globalThis.localStorage?.setItem(wR,JSON.stringify(t))}catch{return}}var OR=420,lNe=`cubic-bezier(.32, .72, 0, 1)`,uNe=Kr(420,26),kR=e=>e?.querySelector(`[data-panel]`)??null,AR=e=>[...e.querySelectorAll(`[data-morph]`)].map(e=>[e.getAttribute(`data-morph`),e]);function jR(e,t,n){for(let r of e.children){let e=r.getAttribute(`data-morph`);e&&t.has(e)||([...r.querySelectorAll(`[data-morph]`)].some(e=>t.has(e.getAttribute(`data-morph`)))?jR(r,t,n):n.push(r.animate([{opacity:0},{opacity:1}],{duration:OR*.5,delay:OR*.2,easing:`ease-out`,fill:`backwards`})))}}var dNe=class extends G.Component{frame=(0,G.createRef)();running=[];ghost=null;panel=null;getSnapshotBeforeUpdate(e){if(e.folded===this.props.folded||Wr())return null;this.stop();let t=kR(this.frame.current);if(!t)return null;let n=getComputedStyle(t),r=document.createElement(`div`);return r.append(...[...t.childNodes].map(e=>e.cloneNode(!0))),{background:n.backgroundColor,shadow:n.boxShadow,height:t.offsetHeight,ghost:r,shared:new Map(AR(t).map(([e,t])=>[e,t.getBoundingClientRect()]))}}componentDidUpdate(e,t,n){let r=kR(this.frame.current);n&&r&&this.morph(r,n)}componentWillUnmount(){this.stop()}stop(){for(let e of this.running)e.cancel();this.running=[],this.ghost?.remove(),this.ghost=null,this.panel?.style.removeProperty(`display`),this.panel=null}morph(e,t){let n=getComputedStyle(e),r={height:e.offsetHeight,background:n.backgroundColor,shadow:n.boxShadow},i=AR(e).flatMap(([e,n])=>{let r=t.shared.get(e);return r?[{el:n,before:r,after:n.getBoundingClientRect()}]:[]}),a={duration:OR,easing:lNe},{ghost:o}=t;o.setAttribute(`aria-hidden`,`true`),Object.assign(o.style,{position:`absolute`,top:`0`,left:`0`,right:`0`,pointerEvents:`none`});for(let[,e]of AR(o))e.style.visibility=`hidden`;jR(e,new Set(i.map(({el:e})=>e.getAttribute(`data-morph`))),this.running),e.style.display=`block`,this.panel=e,e.append(o),this.ghost=o,this.running.push(e.animate([{height:`${t.height}px`,backgroundColor:t.background,boxShadow:t.shadow},{height:`${r.height}px`,backgroundColor:r.background,boxShadow:r.shadow}],a),o.animate([{opacity:1},{opacity:0}],{duration:OR*.4,easing:`ease-out`,fill:`forwards`}),...i.map(({el:e,before:t,after:n})=>e.animate([{transform:`translate(${t.left-n.left}px, ${t.top-n.top}px)`},{transform:`none`}],e.getAttribute(`data-morph`)===`check`?uNe:a)));let s=this.running;Promise.all(s.map(e=>e.finished)).then(()=>s===this.running&&this.stop(),()=>{})}render(){return(0,K.jsx)(`div`,{ref:this.frame,children:this.props.children})}},MR=100,NR=96,fNe=`calc(100vh - 196px)`;function pNe(e,t){let n=t-MR-NR;return e.top<MR||e.top+Math.min(e.height,n)>t-NR}var PR=Kr(260,28);function mNe(e){let[t,n]=(0,G.useState)(e),r=(0,G.useRef)(null),i=(0,G.useRef)(null);return e&&!t&&n(!0),(0,G.useLayoutEffect)(()=>{let t=r.current,a=i.current;if(!t||!a){e||n(!1);return}let o=!1,s=t.offsetHeight;return e?(Gr(t,[{height:`0px`},{height:`${s}px`}],PR),Gr(a,[{opacity:0,transform:`translateY(8px)`},{opacity:1,transform:`none`}],PR)):Promise.all([Gr(t,[{height:`${s}px`},{height:`0px`}],{duration:140,easing:xne}),Gr(a,[{opacity:1},{opacity:0}],{duration:100,easing:`linear`})]).then(()=>{o||n(!1)}),()=>{o=!0}},[e,t]),{shown:t,outer:r,inner:i}}function FR({active:e,capped:t,children:n}){return(0,K.jsx)(`div`,{"data-panel":!0,...{0:{className:`x1n2onr6 xh8yej3 x9f619 xb3r6kr xixl9f9 x2fo67v xqfszdh xfifm61 x1dbl2gt xo2rkog xt0e3qv`},2:{className:`x1n2onr6 xh8yej3 x9f619 xb3r6kr xixl9f9 xqfszdh xfifm61 x1dbl2gt xo2rkog xt0e3qv x12ilycc x1d5q07e`},1:{className:`x1n2onr6 xh8yej3 x9f619 xb3r6kr xixl9f9 x2fo67v xqfszdh xfifm61 x1dbl2gt xo2rkog xt0e3qv x78zum5 xdt5ytf`},3:{className:`x1n2onr6 xh8yej3 x9f619 xb3r6kr xixl9f9 xqfszdh xfifm61 x1dbl2gt xo2rkog xt0e3qv x12ilycc x1d5q07e x78zum5 xdt5ytf`}}[!!e<<1|!!t],style:t?{maxHeight:fNe}:void 0,children:n})}function IR({thread:e,active:t,actions:n,onActivate:r,agent:a=`Agent`,label:o}){let[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(null),[p,m]=(0,G.useState)(0),h=(0,G.useRef)(null),g=e.status===`resolved`,_=(0,G.useMemo)(()=>!!n&&d!==e.statusAt&&ER(e),[n,d,e]),v=(g&&!_||l)&&!s,y=o??pR(e.anchor),b=mNe(!!n&&t&&!g&&!l),x=(0,G.useRef)(null),S=e.messages.length,[w,T]=(0,G.useState)(null),E=e.messages.some(e=>e.id===w&&!e.deleted);(0,G.useLayoutEffect)(()=>{let e=x.current;t&&e&&(e.scrollTop=e.scrollHeight)},[t,S]),(0,G.useEffect)(()=>{let e=x.current;if(!t||!e)return;let n=!0,r=()=>{n=e.scrollHeight-e.scrollTop-e.clientHeight<8},i=new ResizeObserver(()=>{n&&(e.scrollTop=e.scrollHeight)});return e.addEventListener(`scroll`,r,{passive:!0}),i.observe(e),()=>{e.removeEventListener(`scroll`,r),i.disconnect()}},[t]),(0,G.useEffect)(()=>{e.status===`open`&&(c(!1),u(!1))},[e.status]);let D=()=>{u(!0),c(!1),n?.resolve?.(e.id)},O=()=>{DR(e),f(e.statusAt),c(!1)};return(0,K.jsx)(dNe,{folded:v,children:v?(0,K.jsx)(FR,{children:(0,K.jsxs)(`div`,{onClick:()=>{r(),c(!0)},className:`x78zum5 x6s0dn4 x167g77z x1vvogim xaope02 xddlp02 x1ypdohk`,children:[(0,K.jsx)(C,{"data-morph":`check`,size:13,strokeWidth:2.2}),(0,K.jsxs)(`span`,{children:[i(`common.resolved`),` ·`]}),(0,K.jsx)(`span`,{"data-morph":`quote`,className:`x98rzlu xeuugli xb3r6kr xuxw1ft xlyipyv x7zghnd`,children:y})]})}):(0,K.jsx)(`div`,{ref:h,onClick:e=>{r(),!e.target.closest(`button, textarea, input, a`)&&window.getSelection()?.isCollapsed!==!1&&m(e=>e+1)},children:(0,K.jsxs)(FR,{active:t,capped:t,children:[(0,K.jsxs)(`div`,{className:`x78zum5 x6s0dn4 x167g77z x889kno xqin4a2 x1j6dyjg x2lah0s`,children:[(0,K.jsx)(`span`,{"data-morph":`quote`,className:`x98rzlu xeuugli xb3r6kr xuxw1ft xlyipyv x7zghnd`,children:y}),_?(0,K.jsxs)(`span`,{className:`x2lah0s x3nfvp2 x6s0dn4 x1jnr06f xsplgde xv2tywg x1e6avla xsf6uxt xh0clw4 xuxw1ft`,children:[(0,K.jsx)(C,{size:10,strokeWidth:2.6}),e.statusName?i(`document.resolvedBy`,{agent:e.statusName}):i(`common.resolved`)]}):n?(0,K.jsx)(one,{agent:a,thread:e}):null,!n?.resolve||!n.reopen?null:g?(0,K.jsx)(`button`,{title:i(`common.reopen`),type:`button`,onClick:()=>n.reopen(e.id),className:`x2lah0s x17z2i9w x17rw0jw xrvj5dj x1ku5rj1 x1717udv xc342km x1kogg8i xjbqb8w xj0l527 xddlp02 xytdrwj xfifm61 x1ypdohk`,children:(0,K.jsx)(ane,{size:13,strokeWidth:2.2})}):(0,K.jsx)(`button`,{title:i(`common.markResolved`),type:`button`,onClick:e=>(e.stopPropagation(),D()),className:`x2lah0s x17z2i9w x17rw0jw xrvj5dj x1ku5rj1 x1717udv xc342km x1kogg8i xjbqb8w xj0l527 xddlp02 xytdrwj xfifm61 x1ypdohk`,children:(0,K.jsx)(C,{"data-morph":`check`,size:14,strokeWidth:2.4})}),_?(0,K.jsx)(`button`,{title:i(`document.doneReading`),type:`button`,onClick:e=>(e.stopPropagation(),O()),className:`x2lah0s x17z2i9w x17rw0jw xrvj5dj x1ku5rj1 x1717udv xc342km x1kogg8i xjbqb8w xj0l527 xddlp02 xytdrwj xfifm61 x1ypdohk`,children:(0,K.jsx)(Mne,{"data-morph":`check`,size:13,strokeWidth:2.2})}):null]}),(0,K.jsx)(`div`,{ref:x,className:`x98rzlu x2lwn1j x1odjw0f xish69e`,children:(0,K.jsx)(sne,{actions:n,expandable:t,lines:t?8:3,thread:e,collapse:t||E?void 0:e=>(0,K.jsx)(`button`,{type:`button`,onClick:e=>(e.stopPropagation(),r()),className:`x78zum5 x6s0dn4 x167g77z xh8yej3 x1uuky47 xj8oexa xnjsko4 xc342km xjbqb8w xddlp02 xytdrwj xjb2p0i x1j6dyjg x1ypdohk x1cpjm7i xl5i350 xm4vf9w xpl44qm x5r1i06 x1s928wv xkbqsiu xoiy6we x13fydu1 xy7mlml`,children:i(`document.earlierReplies`,{count:e})}),onEditing:(e,t)=>T(n=>t?e:n===e?null:n)})}),n&&b.shown?(0,K.jsx)(`div`,{ref:b.outer,className:`xb3r6kr x2lah0s`,children:(0,K.jsx)(`div`,{ref:b.inner,children:(0,K.jsx)(Br,{delivery:n.delivery,focusKey:p,placeholder:i(`common.reply`),submitLabel:i(`composer.reply`),variant:`inline`,onSubmit:(t,r)=>r?n.reply(e.id,t,r):n.reply(e.id,t)})})}):null]})})})}var LR=(e,t,n,r,i)=>`${JSON.stringify([n??[e],r??null,i??null])}\n${t}`;function hNe(){let e=new Map;return{save(t,n){n.trim()?e.set(t,n):e.delete(t)},take(t){return e.get(t)??``}}}function gNe(){let e=null,t=new Set;return{get:()=>e,set(n){if(n!==e){e=n;for(let e of t)e()}},subscribe(e){return t.add(e),()=>t.delete(e)}}}var RR=(0,G.createContext)(null);function zR(e,t,n){let r=new Map;if(!n)return r;let i=mR(t.threads,t.activeId);for(let a of t.threads){let{anchor:o}=a;if(o.blockId!==n||!o.diagram||!i.has(a.id))continue;let s=lR(e,o.diagram,o.quote);if(!s)continue;let c=r.get(s)??{state:`open`,threadIds:[]};a.id===t.activeId?(c.state=`active`,c.threadIds.unshift(a.id)):c.threadIds.push(a.id),r.set(s,c)}let{draft:a}=t;if(a?.diagram&&a.blockId===n){let t=lR(e,a.diagram,a.quote);t&&r.set(t,{state:`draft`,threadIds:r.get(t)?.threadIds??[]})}return r}var _Ne=e=>[...e].map(([e,t])=>`${e.kind}:${e.domId}:${t.state}:${t.threadIds.join(`,`)}`).join(`|`);function BR(e){let t=[],n=e._nodes;for(let{klass:e}of n.values()){let n=e.commandItems??e.slashMenuItems;if(n)for(let e of n)t.push(e)}return t}function VR(e){let t=e;for(;t;){if(aOe(t))return t;t=t.getParent()}return null}function HR(e){let t=new Map;for(let n of e){let e=VR(n);e&&t.set(e.getKey(),e)}return Array.from(t.values())}function UR(e){return HR(e.getNodes()).length>0}function WR(e){let t=e.getChildren();for(let n of t)e.insertBefore(n);e.remove()}function GR(){let e=kr();if(!Jn(e))return;if(e.isCollapsed()){let t=VR(e.anchor.getNode());t&&WR(t);return}let t=HR(e.getNodes());if(t.length>0){for(let e of t)WR(e);return}let n=e.getTextContent();if(!n.trim())return;e.removeText();let r=lP();r.append(te(n));let i=kr();Jn(i)&&i.insertNodes([r])}var vNe={isBold:!1,isItalic:!1,isUnderline:!1,isStrikethrough:!1,isSuperscript:!1,isSubscript:!1,isCode:!1,isHighlight:!1,isLink:!1,isRuby:!1,isSpoiler:!1,fontColor:``,backgroundColor:``};function KR(e){return Yn(e)?!zn(e)||!e.getIsUnlinked():!1}function qR(e){return Yn(e)&&!zn(e)}function JR(e){return e.getNodes().some(e=>KR(e.getParent())||KR(e))}function yNe(e){let t=e.anchor.getNode();for(;t;){if(Yn(t))return t.getURL();t=t.getParent()}return``}function bNe(e){let t=new Map;for(let n of e.getNodes()){zn(n)&&!n.getIsUnlinked()&&t.set(n.getKey(),n);let e=n.getParent();zn(e)&&!e.getIsUnlinked()&&t.set(e.getKey(),e)}return Array.from(t.values())}function YR(e){let t=e;for(;t;){if(rF(t))return t;t=t.getParent()}return null}function XR(e){let t=new Map;for(let n of e){let e=YR(n);e&&t.set(e.getKey(),e)}return Array.from(t.values())}function xNe(e){let t=e.getNodes(),n=Or(e,`color`,``);if(!n){let e=t.find(e=>$N(e));e&&(n=e.getColor()??``)}return{isBold:e.hasFormat(`bold`),isItalic:e.hasFormat(`italic`),isUnderline:e.hasFormat(`underline`),isStrikethrough:e.hasFormat(`strikethrough`),isSuperscript:e.hasFormat(`superscript`),isSubscript:e.hasFormat(`subscript`),isCode:e.hasFormat(`code`),isHighlight:e.hasFormat(`highlight`),isLink:JR(e),isRuby:XR(t).length>0,isSpoiler:UR(e),fontColor:n,backgroundColor:Or(e,`background-color`,``)}}var SNe=/^[a-z][\d+.a-z-]*:/i,CNe=/^(?:https?:\/\/|www\.)\S+$|^[\w-]+(?:\.[\w-]+)+(?:[#/?]\S*)?$/i;function wNe(e){let t=e.trim();return t?SNe.test(t)||t.startsWith(`/`)||t.startsWith(`#`)?t:`https://${t}`:``}function ZR(e){return CNe.test(e.trim())}async function TNe(){try{if((await navigator.permissions?.query({name:`clipboard-read`}))?.state!==`granted`)return``;let e=(await navigator.clipboard?.readText())?.trim()??``;return ZR(e)?e:``}catch{return``}}function ENe(e,t){for(let e of bNe(t))e.setIsUnlinked(!0),e.markDirty();t.getNodes().some(e=>qR(e.getParent())||qR(e))&&e.dispatchCommand(hn,null)}function DNe(){let e=kr();if(Jn(e))for(let t of e.extract())it(t)?(t.setFormat(0),t.setStyle(``)):$N(t)&&t.setColor(null)}function ONe(){let e=kr();if(!Jn(e))return null;let t=e.getTextContent();if(!t.trim())return null;e.removeText();let n=nF(``);n.append(te(t));let r=kr();return Jn(r)&&r.insertNodes([n]),{nodeKey:n.getKey(),reading:``,isNew:!0}}function QR(e){let t=Dn(e);if(rF(t)){for(let e of t.getChildren())t.insertBefore(e);t.remove()}}function kNe(e,t){let n=Dn(e);rF(n)&&n.setReading(t)}var ANe=`_1m6axz71`,jNe=`_1m6axz74`,MNe=`_1m6axz75`,NNe=`_1m6axz76`,PNe=`_1m6axz77`,FNe=`_1m6axz78`,INe=`_1m6axz79`;function LNe(){return Be()}function $R({active:e,children:t,handle:n,label:r,onClick:i,render:a,shortcut:o}){return(0,K.jsx)(tt,{"aria-label":r,"data-shortcut":o,"data-tooltip":r,handle:n,payload:{label:r,shortcut:o},render:a??(0,K.jsx)(`button`,{"aria-pressed":e,className:`_1m6axz74`,type:`button`,onClick:i,onMouseDown:e=>e.preventDefault()}),children:t})}var ez={size:16,strokeWidth:2},RNe=[{format:`bold`,label:`Bold`,shortcut:`Mod+B`,icon:(0,K.jsx)(Kte,{...ez})},{format:`italic`,label:`Italic`,shortcut:`Mod+I`,icon:(0,K.jsx)(Jte,{...ez})},{format:`underline`,label:`Underline`,shortcut:`Mod+U`,icon:(0,K.jsx)(Hte,{...ez})},{format:`strikethrough`,label:`Strikethrough`,icon:(0,K.jsx)(Dt,{...ez})}],zNe={bold:`isBold`,italic:`isItalic`,underline:`isUnderline`,strikethrough:`isStrikethrough`};function tz(){return(0,K.jsx)(`span`,{"aria-hidden":!0,className:NNe})}function BNe({actions:e,handle:t,onBackgroundColor:n,onClearFormatting:r,onColor:i,onFormat:a,onLink:o,onRuby:s,onSpoiler:c,state:l}){return(0,K.jsxs)(K.Fragment,{children:[RNe.map(e=>(0,K.jsx)($R,{active:!!l[zNe[e.format]],handle:t,label:e.label,shortcut:e.shortcut,onClick:()=>a(e.format),children:e.icon},e.format)),(0,K.jsx)(tz,{}),(0,K.jsx)($R,{active:l.isCode,handle:t,label:`Inline code`,onClick:()=>a(`code`),children:(0,K.jsx)(Pr,{...ez})}),(0,K.jsx)($R,{active:l.isHighlight,handle:t,label:`Highlight`,onClick:()=>a(`highlight`),children:(0,K.jsx)(jt,{...ez})}),(0,K.jsx)($R,{active:l.isSpoiler,handle:t,label:`Spoiler`,onClick:c,children:(0,K.jsx)(Bte,{...ez})}),(0,K.jsx)(tz,{}),(0,K.jsx)($R,{active:l.isLink,handle:t,label:`Link`,shortcut:`Mod+K`,onClick:o,children:(0,K.jsx)(v,{...ez})}),(0,K.jsx)($R,{active:l.isRuby,handle:t,label:`Ruby`,onClick:s,children:(0,K.jsx)(mi,{...ez})}),(0,K.jsx)(tz,{}),(0,K.jsx)(kte,{className:MNe,currentBackground:l.backgroundColor,currentColor:l.fontColor||`inherit`,tooltip:`Text color`,onSelect:i,onSelectBackground:n}),(0,K.jsxs)(Zn,{modal:!1,children:[(0,K.jsx)($R,{handle:t,label:`More formatting`,render:(0,K.jsx)(On,{render:(0,K.jsx)(`button`,{className:jNe,type:`button`,onMouseDown:e=>e.preventDefault()})}),onClick:()=>{},children:(0,K.jsx)(Nr,{...ez})}),(0,K.jsxs)(Rt,{align:`end`,positionMethod:`fixed`,sideOffset:8,children:[(0,K.jsxs)(Ve,{checked:l.isSuperscript,onCheckedChange:()=>a(`superscript`),children:[(0,K.jsx)(qne,{...ez}),`Superscript`]}),(0,K.jsxs)(Ve,{checked:l.isSubscript,onCheckedChange:()=>a(`subscript`),children:[(0,K.jsx)(Kne,{...ez}),`Subscript`]}),(0,K.jsx)(ur,{}),(0,K.jsxs)(Ut,{onClick:r,children:[(0,K.jsx)(Wne,{...ez}),`Clear formatting`]})]})]}),e&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(tz,{}),e]})]})}function nz({handle:e,icon:t,label:n,onCancel:r,onChange:i,onSubmit:a,placeholder:o,secondary:s,type:c=`text`,value:l}){let u=(0,G.useRef)(null);return(0,G.useEffect)(()=>{u.current?.focus({preventScroll:!0})},[]),(0,K.jsxs)(`div`,{className:PNe,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:FNe,children:t}),(0,K.jsx)(ct,{"aria-label":n,autoComplete:`off`,className:INe,placeholder:o,ref:u,spellCheck:!1,type:c,value:l,onChange:e=>i(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Enter`?(e.preventDefault(),a()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),r()))}}),(0,K.jsxs)(Fe,{"aria-label":`Save`,size:`md`,variant:`solid`,onClick:a,onMouseDown:e=>e.preventDefault(),children:[`Save`,(0,K.jsx)(ar,{keys:`enter`,size:`sm`,tone:`inverted`})]}),(0,K.jsx)(tt,{handle:e,payload:{label:s.label,shortcut:s.shortcut},render:(0,K.jsx)(Fe,{icon:!0,"aria-label":s.label,danger:s.danger,size:`md`,onClick:s.onClick,onMouseDown:e=>e.preventDefault()}),children:s.icon})]})}function rz(e){return Array.from(e.querySelectorAll(`button:not(:disabled)`))}function VNe(e,t){let n=rz(e);if(n.includes(t))for(let e of n)e.tabIndex=e===t?0:-1}function HNe(e){if(!e)return!1;let t=rz(e)[0];return t?.focus(),!!t}function UNe(e){let t=rz(e.currentTarget),n=t.indexOf(document.activeElement);if(n===-1)return!1;let r=t.length-1,i=e.key===`ArrowRight`?n===r?0:n+1:e.key===`ArrowLeft`?n===0?r:n-1:e.key===`Home`?0:e.key===`End`?r:-1;return i!==-1&&(e.preventDefault(),t[i]?.focus(),!0)}function WNe({editor:e,editRuby:t,modeRef:n,openLink:r,toolbarRef:i,updateToolbar:a}){(0,G.useEffect)(()=>{let o=n=>{let r=n.target;if(!r||!e.isEditable()||window.getSelection()?.isCollapsed===!1)return;let i=e.read(()=>{let e=YR(Bt(r));return e?{key:e.getKey(),reading:e.getReading()}:null});i&&t(i.key,i.reading)},s=null;return GNe(e.registerCommand(mn,()=>(a(),!1),1),e.registerUpdateListener(({editorState:e})=>{e.read(a)}),e.registerCommand(br,t=>{let a=t.key.toLowerCase()===`k`&&(t.metaKey||t.ctrlKey)&&!t.altKey&&!t.shiftKey,o=t.key===`F10`&&t.altKey;if(!a&&!o||n.current.kind!==`format`||a&&!e.isEditable())return!1;let s=kr();return!Jn(s)||s.isCollapsed()||o&&!i.current?!1:(t.preventDefault(),o?(queueMicrotask(()=>HNe(i.current)),!0):(queueMicrotask(()=>r(`editor`)),!0))},1),e.registerRootListener(e=>{s?.removeEventListener(`click`,o),s=e,e?.addEventListener(`click`,o)}),()=>s?.removeEventListener(`click`,o))},[t,e,n,r,i,a])}function GNe(...e){return()=>{for(let t of e)t()}}var iz={kind:`format`};function KNe(e,t){let[n,r]=(0,G.useState)(iz),i=(0,G.useRef)(n),a=(0,G.useRef)(null),o=(0,G.useCallback)(e=>{let t=typeof e==`function`?e(i.current):e;i.current=t,r(t)},[]),s=(0,G.useCallback)(e=>{let n=i.current;o(iz),!e||n.kind===`format`?t(null):n.origin===`editor`?t(`editor`):t(n.kind===`link`?`Link`:`Ruby`)},[t,o]),c=(0,G.useCallback)(t=>{let n=e.read(()=>{let e=kr();if(!Jn(e)||e.isCollapsed())return null;let t=JR(e),n=t?yNe(e):``,r=e.getTextContent().trim();return{hasLink:t,initial:n||(ZR(r)?r:``),selection:e.clone()}});n&&(a.current=n.selection,o({kind:`link`,draft:n.initial,dirty:!1,existing:n.hasLink,origin:t}),n.initial||TNe().then(e=>{e&&o(t=>t.kind===`link`&&!t.dirty&&!t.draft?{...t,draft:e}:t)}))},[e,o]),l=(0,G.useCallback)(e=>{o(t=>t.kind===`link`?{...t,draft:e,dirty:!0}:t)},[o]),u=(0,G.useCallback)((t=!0)=>{let n=i.current;if(n.kind!==`link`)return;let r=wNe(n.draft);r&&e.update(()=>{let t=a.current,n=kr();t&&(!Jn(n)||n.isCollapsed())&&Jt(t.clone()),e.dispatchCommand(hn,r)}),a.current=null,s(t)},[s,e]),d=(0,G.useCallback)(()=>{i.current.kind===`link`&&(e.update(()=>{let t=a.current,n=kr();t&&(!Jn(n)||n.isCollapsed())&&Jt(t.clone());let r=kr();Jn(r)&&ENe(e,r)}),a.current=null,s(!0))},[s,e]),f=(0,G.useCallback)(t=>{let n=e.read(()=>{let e=kr();if(!Jn(e))return;let t=XR(e.getNodes())[0];return t?{nodeKey:t.getKey(),reading:t.getReading(),isNew:!1}:null});if(n===void 0)return;if(n){o({kind:`ruby`,draft:n,origin:t});return}let r=null;e.update(()=>{r=ONe()},{discrete:!0}),r&&o({kind:`ruby`,draft:r,origin:t})},[e,o]),p=(0,G.useCallback)((e,t)=>{o({kind:`ruby`,draft:{nodeKey:e,reading:t,isNew:!1},origin:`editor`})},[o]),m=(0,G.useCallback)(e=>{o(t=>t.kind===`ruby`?{...t,draft:{...t.draft,reading:e}}:t)},[o]),h=(0,G.useCallback)((t=!0)=>{let n=i.current;if(n.kind!==`ruby`)return;let r=n.draft.reading.trim();e.update(()=>{r?kNe(n.draft.nodeKey,r):QR(n.draft.nodeKey)}),s(t)},[s,e]),g=(0,G.useCallback)(()=>{let t=i.current;t.kind===`ruby`&&(t.draft.isNew&&e.update(()=>QR(t.draft.nodeKey)),s(!0))},[s,e]),_=(0,G.useCallback)(()=>{let t=i.current;t.kind===`ruby`&&(e.update(()=>QR(t.draft.nodeKey)),s(!0))},[s,e]);return{mode:n,modeRef:i,cancel:s,cancelRuby:g,commitOnOutsideClick:(0,G.useCallback)(()=>{let e=i.current;e.kind===`link`?e.dirty&&e.draft.trim()?u(!1):s(!1):e.kind===`ruby`&&h(!1)},[s,u,h]),editRuby:p,openLink:c,openRuby:f,removeLink:d,removeRuby:_,saveLink:u,saveRuby:h,setLinkDraft:l,setRubyDraft:m}}var az=8,oz=8;function qNe({anchor:e,size:t,bounds:n}){let r=e.top-az-t.height,i=e.bottom+az,a=r>=n.top,o=i+t.height<=n.bottom,s=a||!o?`top`:`bottom`,c=s===`top`?Math.max(r,n.top):i,l=(e.left+e.right)/2,u=n.left+oz,d=n.right-t.width-oz;return{top:c,left:Math.max(u,Math.min(l-t.width/2,d)),placement:s}}function JNe(e){let{position:t}=window.getComputedStyle(e);return t===`sticky`||t===`fixed`}function YNe(e){let t=e?.parentElement??null;for(;t;){let{overflowY:e}=window.getComputedStyle(t);if(e===`auto`||e===`scroll`)return t;t=t.parentElement}return null}function XNe(e,t,n){let r={top:0,left:0,right:window.innerWidth,bottom:window.innerHeight},i=YNe(e);if(i){let e=i.getBoundingClientRect();r.top=Math.max(r.top,e.top),r.bottom=Math.min(r.bottom,e.bottom)}let a=e.getBoundingClientRect();for(let e of document.querySelectorAll(`[role="toolbar"]`)){if(e===t||t?.contains(e)||!JNe(e))continue;let i=e.getBoundingClientRect();i.right>a.left&&i.left<a.right&&i.top<n&&i.bottom>r.top&&(r.top=Math.min(i.bottom,n))}return r}function ZNe(e){return e.match(/^var\((--[^\s),]+)(?:,[^)]+)?\)$/)?.[1]??null}function sz(e,t){if(typeof e==`string`){let n=ZNe(e);return n&&t.add(n),t}if(e&&typeof e==`object`)for(let n of Object.values(e))sz(n,t);return t}var QNe=Array.from(sz(Ht,new Set));function $Ne(e,t){let n=e.getRootElement();if(!n)return;let r=window.getComputedStyle(n);for(let e of QNe){let n=r.getPropertyValue(e).trim();n&&t.style.setProperty(e,n)}}function ePe({active:e,editor:t,getAnchor:n,portalContainer:r,toolbarRef:i,trigger:a}){(0,G.useLayoutEffect)(()=>{if(!e)return;let a=()=>{let e=i.current,a=t.getRootElement();if(!e||!a)return;$Ne(t,e);let o=n();if(!o)return;let s=qNe({anchor:o,size:{width:e.offsetWidth,height:e.offsetHeight},bounds:XNe(a,e,o.top)}),c=r===document.body?null:r.getBoundingClientRect();e.style.top=`${s.top-(c?.top??0)}px`,e.style.left=`${s.left-(c?.left??0)}px`,e.dataset.placement=s.placement};a();let o=requestAnimationFrame(a),s=()=>requestAnimationFrame(a);return window.addEventListener(`scroll`,s,{capture:!0,passive:!0}),window.addEventListener(`resize`,s),()=>{cancelAnimationFrame(o),window.removeEventListener(`scroll`,s,{capture:!0}),window.removeEventListener(`resize`,s)}},[e,t,n,r,i,a])}var cz={size:16,strokeWidth:2};function lz(e){return e.width===0&&e.height===0?null:{top:e.top,bottom:e.bottom,left:e.left,right:e.right}}function tPe({actions:e}={}){let[t]=ht(),n=wt(),{className:r,theme:i}=We(),a=dte(),o=zL(),s=(0,G.useRef)(null),[c]=(0,G.useState)(LNe),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(vNe),[p,m]=(0,G.useState)(null),h=(0,G.useRef)(null),g=KNe(t,(0,G.useCallback)(e=>{m(e?{target:e}:null)},[])),{mode:_,modeRef:y,openLink:b,openRuby:x,editRuby:S,commitOnOutsideClick:C,cancel:w}=g;WNe({editor:t,editRuby:S,modeRef:y,openLink:b,toolbarRef:s,updateToolbar:(0,G.useCallback)(()=>{let e=kr();!Jn(e)||e.isCollapsed()?u(!1):(f(xNe(e)),u(!0))},[])}),(0,G.useEffect)(()=>{o||u(!1)},[o]),(0,G.useEffect)(()=>{n||w(!1)},[w,n]),(0,G.useEffect)(()=>{if(!p)return;let e=p.target===`editor`?null:s.current?.querySelector(`[aria-label="${p.target}"]`);e?e.focus():t.focus(),m(null)},[t,p]),(0,G.useEffect)(()=>{if(_.kind===`format`)return;let e=e=>{let t=e.target;s.current?.contains(t)||C()},t=setTimeout(()=>document.addEventListener(`mousedown`,e),0);return()=>{clearTimeout(t),document.removeEventListener(`mousedown`,e)}},[C,_.kind]);let T=_.kind===`ruby`?_.draft.nodeKey:null,E=(0,G.useCallback)(()=>{let e=t.getRootElement(),n=null;if(T){let e=t.getElementByKey(T);n=e?lz(e.getBoundingClientRect()):null}else if(e&&o){let t=EMe(e,o);n=t?lz(t):null}return n&&(h.current=n),n??h.current},[t,T,o]),D=n?l||_.kind!==`format`:l&&e!=null;ePe({active:D,editor:t,getAnchor:E,portalContainer:a,toolbarRef:s,trigger:`${_.kind}:${JSON.stringify(d)}`});let O=(0,G.useCallback)(e=>t.dispatchCommand(ye,e),[t]),A=(0,G.useCallback)((e,n)=>{t.update(()=>{let t=kr();if(Jn(t)&&(_t(t,e),n!==void 0))for(let e of t.getNodes())$N(e)&&e.setColor(n)})},[t]),j=(0,G.useCallback)(e=>{let t=e===`inherit`?null:e;A({color:t},t)},[A]),M=(0,G.useCallback)(e=>{A({"background-color":e===`inherit`?null:e})},[A]);if(!D)return null;let N=[ANe,_.kind===`link`&&`_1m6axz72`,_.kind===`ruby`&&`_1m6axz73`,r].filter(Boolean).join(` `);return(0,K.jsxs)(B,{delay:400,children:[(0,K.jsx)(Mn,{disableHoverablePopup:!0,handle:c,children:(e=>e.payload?(0,K.jsx)(Fn,{"data-slot":`toolbar-tooltip`,shortcut:e.payload.shortcut,children:e.payload.label}):null)}),(0,Gi.createPortal)((0,K.jsxs)(`div`,{className:N,"data-theme":r?i:void 0,ref:s,role:_.kind===`format`?`toolbar`:`group`,style:{position:`fixed`,zIndex:50},"aria-label":_.kind===`format`?n?`Text formatting`:`Selection actions`:void 0,onFocus:e=>VNe(e.currentTarget,e.target),onKeyDown:e=>{_.kind===`format`&&(UNe(e)||(e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),t.focus()))},children:[_.kind===`format`&&!n&&e,_.kind===`format`&&n&&(0,K.jsx)(BNe,{actions:e,handle:c,state:d,onBackgroundColor:M,onClearFormatting:()=>t.update(DNe),onColor:j,onFormat:O,onLink:()=>b(`toolbar`),onRuby:()=>x(`toolbar`),onSpoiler:()=>t.update(GR)}),_.kind===`link`&&(0,K.jsx)(nz,{handle:c,icon:(0,K.jsx)(v,{...cz}),label:`URL`,placeholder:`Paste or type a link`,type:`url`,value:_.draft,secondary:_.existing?{danger:!0,icon:(0,K.jsx)(Vi,{...cz}),label:`Remove link`,onClick:g.removeLink}:{icon:(0,K.jsx)(k,{...cz}),label:`Back to formatting`,shortcut:`Escape`,onClick:()=>g.cancel(!0)},onCancel:()=>g.cancel(!0),onChange:g.setLinkDraft,onSubmit:()=>g.saveLink()}),_.kind===`ruby`&&(0,K.jsx)(nz,{handle:c,icon:(0,K.jsx)(mi,{...cz}),label:`Reading`,placeholder:`Reading`,value:_.draft.reading,secondary:{danger:!0,icon:(0,K.jsx)(Mr,{...cz}),label:`Remove ruby`,onClick:g.removeRuby},onCancel:g.cancelRuby,onChange:g.setRubyDraft,onSubmit:()=>g.saveRuby()})]}),a)]})}function nPe({left:e,top:t,onComment:n,ref:r}){return(0,K.jsx)(`div`,{ref:r,className:`x10l6tqk x1u8a7rm xqcmdr3 x12l1aco xa3vuyk`,style:{left:e,top:t},children:(0,K.jsx)(`button`,{"aria-label":i(`common.comment`),title:i(`common.comment`),type:`button`,className:`x10l6tqk x1u8a7rm xrvj5dj x1ku5rj1 x1td3qas x10w6t97 x1717udv xmkeg23 x1y0btm7 xgcsv5v xur7f20 x12ilycc xj0l527 x1cge3fn x1d5q07e x1ypdohk xbx70qg x1hl8ikr`,onClick:n,onPointerDown:e=>e.preventDefault(),children:(0,K.jsx)(Rr,{"aria-hidden":`true`,size:16})})})}function rPe({left:e,top:t,children:n,ref:r}){return(0,K.jsx)(`div`,{ref:r,className:`x10l6tqk x1u8a7rm x78zum5 x6s0dn4 xfawy5m xmkeg23 x1y0btm7 xgcsv5v x1q4ynmn x12ilycc x1d5q07e`,style:{left:e,top:t},children:n})}function iPe(){let e=(0,G.use)(Mj);return e?(0,K.jsx)(tPe,{actions:e.selectionActions}):null}function aPe({onComment:e,onCopy:t}){return(0,K.jsxs)(`div`,{className:`xjp7ctv`,onMouseDown:e=>e.preventDefault(),children:[e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{"aria-label":i(`common.comment`),type:`button`,onClick:e,className:`x78zum5 x6s0dn4 x17d4w8g x1fgtraw xt970qd x1awh872 xc342km xu4hgxq xjbqb8w xj0l527 x2230gt xo2rkog xqfszdh xfifm61 xk50ysn x1ypdohk x1de99jn xaatb59 x1y3gkto x1uczgqu x60py1w`,children:[(0,K.jsx)(Rr,{size:14,className:`x2lah0s x1cge3fn`}),i(`common.comment`)]}),(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`x2lah0s x1i1rx1s xlup9mm xj3msbq xcn5yip`})]}):null,(0,K.jsx)(`button`,{"aria-label":i(`document.copy`),type:`button`,onClick:t,className:`x78zum5 x6s0dn4 x17d4w8g x1fgtraw xt970qd x1awh872 xc342km xu4hgxq xjbqb8w xj0l527 x2230gt xqfszdh xfifm61 xk50ysn x1ypdohk x1de99jn xaatb59 x1y3gkto x1uczgqu x60py1w x1bo0w0s`,children:i(`document.copy`)})]})}function oPe({by:e,text:t}){let{t:r}=n();return(0,K.jsxs)(`span`,{"data-ask-note":!0,className:`x78zum5 x17d4w8g xg9jes1 xfifm61 x1dbl2gt xddlp02 xeaf4i8 x1hx0egp`,children:[(0,K.jsxs)(`span`,{className:`x2lah0s x1yz8712`,children:[`↳ `,e??r(`asks.agent`)]}),(0,K.jsx)(`span`,{children:t})]})}function uz(e){let[t,n]=(0,G.useState)(e);return e&&!t&&n(!0),[e||t,()=>n(!1)]}function dz(e,t){let n=(0,G.useEffectEvent)(t);(0,G.useEffect)(()=>{let t=e.current;if(!t)return;let r=e=>{e.stopPropagation(),e.isComposing||e.keyCode===229||n(e)},i=e=>e.stopPropagation();return t.addEventListener(`keydown`,r),t.addEventListener(`compositionstart`,i),()=>{t.removeEventListener(`keydown`,r),t.removeEventListener(`compositionstart`,i)}},[e])}var fz={option:{k1xSpc:`x78zum5`,kGNEyG:`x1cy8zhl`,kOIVth:`x167g77z`,kzqmXN:`xh8yej3`,kAzted:`x21xpn4`,k8WAf4:`x1t0vds8`,kg3NbH:`xaope02`,kMzoRj:`xc342km`,kaIpWk:`x1kogg8i`,kWkggS:`xjbqb8w xj0l527`,kMwMTN:`xo2rkog`,kMv6JI:`xjb2p0i`,kGuDYH:`x1qlqyl8`,kLWn49:`x1fc57z9`,k9WMMc:`x1yc453h`,kkrTdU:`x1ypdohk`,$$css:!0},chosenAgent:{kWkggS:`xacg9sr x1k58n2o`,$$css:!0},chosenHuman:{kWkggS:`x1cfontt xcd1bmh`,$$css:!0}},sPe={padding:0,fontSize:`inherit`,lineHeight:`20px`};function cPe({draft:e,label:t,onChoose:r,onClose:i,onDraft:a,phone:s,view:c}){let{t:l}=n(),u=(0,G.useRef)(null),d=c.options.length>0,[f,p]=(0,G.useState)(c.text!==null||!d),m=()=>{e.trim()&&r(null,e.trim())};dz(u,t=>{let n=t.target.tagName===`TEXTAREA`;t.key===`Escape`&&(n&&d?p(!1):i()),n&&t.key===`Enter`&&(t.metaKey||t.ctrlKey)&&e.trim()&&(t.preventDefault(),m())});let h=c.options.find(e=>e.value===c.recommend),g=h?c.options.filter(e=>e!==h):c.options,_=c.changed?`human`:`agent`,v=e=>{let t=c.text===null&&c.choice===e.value;return(0,K.jsxs)(`button`,{"aria-checked":t,"data-ask-option":e.value,role:`radio`,type:`button`,onClick:()=>r(e.value,null),...o(fz.option,t&&(_===`human`?fz.chosenHuman:fz.chosenAgent)),children:[(0,K.jsx)(`span`,{className:`x1iyjqo2 xeuugli xj0a0fe`,children:e.label}),(0,K.jsx)(`span`,{...{0:{className:`x78zum5 x6s0dn4 x2lah0s x6jxa94 x1qx5ct2 x1yz8712`},1:{className:`x78zum5 x6s0dn4 x2lah0s x6jxa94 x1qx5ct2 xr46axq`}}[_===`human`|0],children:t&&(0,K.jsx)(C,{size:14})})]},e.value)};return(0,K.jsxs)(`div`,{"data-ask-menu":!0,ref:u,...{0:{className:`x78zum5 xdt5ytf x195vfkc`},1:{className:`x78zum5 xdt5ytf x195vfkc xezivpi x1u2d2a2 x1lr1uin x4z9k3i x1evy7pa`}}[!s|0],children:[d&&(0,K.jsxs)(`div`,{"aria-label":t,role:`radiogroup`,className:`x78zum5 xdt5ytf x195vfkc`,children:[h&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{"data-ask-recommended":!0,className:`x1yrsyyn x1120s5i xaope02 xfifm61 xd4r4e8 x1yz8712`,children:l(`asks.recommended`)}),v(h),(0,K.jsx)(`div`,{className:`x1yrsyyn x1120s5i xaope02 xddlp02 xfifm61 xd4r4e8`,children:l(`asks.otherOptions`)})]}),g.map(v)]}),f?(0,K.jsxs)(`div`,{className:`x41o525 x78zum5 xdt5ytf x1jnr06f x1t0vds8 xaope02 x1kogg8i xahzvm9 x1pb8m1d`,children:[(0,K.jsx)(cne,{autoFocus:!0,autoSize:{minRows:1,maxRows:6},placeholder:c.placeholder??l(`asks.other`),style:sPe,value:e,variant:`borderless`,onChange:e=>a(e.target.value)}),(0,K.jsxs)(`div`,{className:`x78zum5 x6s0dn4 x1qughib x167g77z xddlp02 xfifm61`,children:[(0,K.jsx)(`span`,{children:d&&l(`asks.cancel`)}),(0,K.jsxs)(b,{"data-ask-confirm":!0,disabled:!e.trim(),size:`small`,type:`primary`,onClick:m,children:[l(`asks.ok`),!s&&(0,K.jsx)(`span`,{className:`xdzw4kq xfn1xvj x12oqio5 xhnm4ek xfifm61 x1d3mw78`,children:`⌘↩`})]})]})]}):(0,K.jsxs)(`button`,{"data-ask-other":!0,type:`button`,onClick:()=>p(!0),className:`x78zum5 x1cy8zhl x167g77z xh8yej3 x21xpn4 x1t0vds8 xaope02 xc342km x1kogg8i xjbqb8w xj0l527 xjb2p0i x1qlqyl8 x1fc57z9 x1yc453h x1ypdohk xddlp02`,children:[(0,K.jsx)(`span`,{className:`x1iyjqo2 xeuugli xj0a0fe`,children:c.placeholder??l(`asks.otherRow`)}),(0,K.jsx)(`span`,{className:`x78zum5 x6s0dn4 x2lah0s x6jxa94 x1qx5ct2 xc7n51q`,children:(0,K.jsx)(Fr,{size:13})})]})]})}var pz={tag:{k1xSpc:`x3nfvp2`,kGNEyG:`x6s0dn4`,kOIVth:`x1jnr06f`,kB7OPa:`x9f619`,ks0D6T:`x1hvl878`,kZKoxP:`x17rw0jw`,kUOVxO:`xjgtzcg`,kg3NbH:`xdqyycr`,kMzoRj:`xmkeg23`,ksu8eU:`x1y0btm7`,kVAM5u:`x9r1u3d`,kaIpWk:`x1kogg8i`,kWkggS:`xahzvm9`,kMwMTN:`x1bo0w0s`,kMv6JI:`xjb2p0i`,kGuDYH:`xfifm61`,kLWn49:`x37zpob`,kXLuUW:`x11njtxf`,khDVqt:`xuxw1ft`,kkrTdU:`xt0e3qv`,kfSwDN:`x87ps6o`,$$css:!0},wide:{kB7OPa:`x9f619`,k7Eaqz:`xt7fyls`,kVQacm:`xb3r6kr`,k1xSpc:`x78zum5`,kzqmXN:`xh8yej3`,ks0D6T:`x193iq5w`,kZKoxP:`x1fgtraw`,kUOVxO:`xrxpjvj`,kjj79g:`x1qughib`,$$css:!0},open:{kkrTdU:`x1ypdohk`,$$css:!0},changed:{kWkggS:`x235pk4`,kMwMTN:`xr46axq`,$$css:!0},todo:{kWkggS:`xjbqb8w`,ksu8eU:`xbsl7fq`,kVAM5u:`xgcsv5v`,kMwMTN:`xddlp02`,$$css:!0},quiet:{kSiTet:`xf9vgkq`,$$css:!0}},lPe={content:{"--lobe-popover-viewport-inline-padding":`4px`,paddingBlock:4}};function uPe(e){let{t}=n(),r=e.options.find(t=>t.value===e.choice)?.label,i=e.text??r??null,a=i??t(`asks.noAnswer`);return e.state===`submitted`?{label:a,title:t(`asks.submitted`,{label:a})}:e.state===`settled`?{label:a,title:t(`asks.settled`,{label:a})}:i===null?{label:e.options.length?t(`asks.toChoose`):t(`asks.toFill`)}:e.changed?{label:i,title:e.recommend||e.text?t(`asks.changed`,{label:i}):t(`asks.chosen`,{label:i})}:{label:i}}function dPe({view:e,canAnswer:t,onAnswer:n,wide:r,phone:i}){let{label:a,title:s}=uPe(e),[c,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(e.text??``),p=(0,G.useRef)(null),m=t&&e.state===`draft`,h=!!(m&&i&&c),[g,_]=uz(h),v=e.choice===null&&e.text===null,y=(e,t)=>{n(e,t),u(!1)};dz(p,e=>{e.target.dataset.askTag!==void 0&&m&&(e.key===`Escape`&&u(!1),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u(e=>!e)))});let b=(0,K.jsx)(cPe,{draft:d,label:a,phone:i,view:e,onChoose:y,onClose:()=>u(!1),onDraft:f}),x=(0,K.jsxs)(`span`,{"data-ask-tag":e.id,"data-changed":e.changed?`true`:`false`,"data-state":e.state,"data-wide":r?`true`:void 0,role:m?`button`:void 0,tabIndex:m?0:void 0,title:s,onClick:i&&m?()=>u(e=>!e):void 0,...o(pz.tag,r&&pz.wide,m&&pz.open,e.changed&&pz.changed,e.state===`draft`&&v&&pz.todo,(e.state===`submitted`||e.state===`settled`)&&pz.quiet),children:[(0,K.jsxs)(`span`,{...{0:{className:`xeuugli xb3r6kr xlyipyv`},1:{className:`xeuugli xb3r6kr xlyipyv x1iyjqo2 xnalus7`}}[!!r|0],children:[e.state===`settled`&&(0,K.jsx)(Ute,{size:11,className:`x2fvf9 x19693qn`}),a]}),m&&(0,K.jsx)(l,{size:11})]});return(0,K.jsxs)(`span`,{ref:p,...{0:{className:`x1rg5ohu x193iq5w x11njtxf`},1:{className:`x193iq5w x11njtxf x1lliihq xh8yej3 xeuugli`}}[!!r|0],contentEditable:!1,children:[m&&!i?(0,K.jsx)(Pte,{content:b,nativeButton:!1,open:c,placement:`bottomLeft`,styles:lPe,trigger:`click`,onOpenChange:u,children:x}):x,g&&(0,Gi.createPortal)((0,K.jsx)(`div`,{"data-ask-sheet":!0,className:`xixxii4 x10a8y8t xf5e64p`,children:(0,K.jsx)(bne,{header:(0,K.jsx)(`div`,{className:`x17qtykl xwib8y2 x1jvydc1 x1s688f`,children:a}),open:h,snap:.5,snaps:[0,.5],onExited:_,onScrim:()=>u(!1),onSnap:e=>e===0&&u(!1),children:(0,K.jsx)(`div`,{className:`xaope02 xwxc41k x1jvydc1`,children:b})})}),document.body)]})}var fPe=e=>{let t=e.closest(`td, th`);return!!t&&(t.textContent??``).trim()===(e.textContent??``).trim()};function pPe({ask:e}){let t=(0,G.useContext)(Aj),n=t?.threads,r=(0,G.useMemo)(()=>bA([_A(e,``)],n??[])[0],[e,n]),i=(0,G.useRef)(null),[a,o]=(0,G.useState)(!1);return(0,G.useLayoutEffect)(()=>{i.current&&o(fPe(i.current))}),(0,K.jsxs)(`span`,{"data-ask-slot":e.askId,ref:i,style:a?{display:`block`}:void 0,children:[(0,K.jsx)(dPe,{canAnswer:!!t?.canAnswer,phone:t?.phone,view:r,wide:a,onAnswer:(n,r)=>t?.send({op:`create`,blockId:`*`,quote:``,ask:e.askId,choice:n,answer:r,text:r??n??``})}),r.state===`settled`&&r.note&&(0,K.jsx)(oPe,{by:r.noteBy,text:r.note})]})}var mz=class e extends wr{__ask;static getType(){return`ask`}static clone(t){return new e(t.__ask,t.__key)}static importJSON(t){let{type:n,version:r,...i}=t;return new e(i).updateFromJSON(t)}constructor(e={askId:``,options:[]},t){super(t),this.__ask=e}exportJSON(){return{...super.exportJSON(),...this.__ask,type:`ask`,version:1}}createDOM(){return document.createElement(`span`)}updateDOM(){return!1}isInline(){return!0}isKeyboardSelectable(){return!1}getTextContent(){return``}decorate(){return(0,K.jsx)(pPe,{ask:this.exportJSON()})}};function mPe({reading:e,children:t}){return e?(0,K.jsxs)(`ruby`,{className:Fj(Nj.ruby,Pj.ruby),children:[t,(0,K.jsx)(`rt`,{className:Fj(Nj.rubyRt,Pj.rubyRt),children:e})]}):(0,K.jsx)(K.Fragment,{children:t})}function hz(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function hPe(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function gz(e){let t,n,r;e.length===2?(t=e===hz||e===hPe?e:gPe,n=e,r=e):(t=hz,n=(t,n)=>hz(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<0?i=t+1:a=t}while(i<a)}return i}function a(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<=0?i=t+1:a=t}while(i<a)}return i}function o(e,t,n=0,a=e.length){let o=i(e,t,n,a-1);return o>n&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function gPe(){return 0}function _Pe(e){return e===null?NaN:+e}var _z=gz(hz),vPe=_z.right;_z.left,gz(_Pe).center;var vz=class extends Map{constructor(e,t=xPe){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let[t,n]of e)this.set(t,n)}get(e){return super.get(yz(this,e))}has(e){return super.has(yz(this,e))}set(e,t){return super.set(yPe(this,e),t)}delete(e){return super.delete(bPe(this,e))}};function yz({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function yPe({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function bPe({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function xPe(e){return typeof e==`object`&&e?e.valueOf():e}Array.prototype.slice;var SPe=Math.sqrt(50),CPe=Math.sqrt(10),wPe=Math.sqrt(2);function bz(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=SPe?10:a>=CPe?5:a>=wPe?2:1,s,c,l;return i<0?(l=10**-i/o,s=Math.round(e*l),c=Math.round(t*l),s/l<e&&++s,c/l>t&&--c,l=-l):(l=10**i*o,s=Math.round(e/l),c=Math.round(t/l),s*l<e&&++s,c*l>t&&--c),c<s&&.5<=n&&n<2?bz(e,t,n*2):[s,c,l]}function TPe(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];let r=t<e,[i,a,o]=r?bz(t,e,n):bz(e,t,n);if(!(a>=i))return[];let s=a-i+1,c=Array(s);if(r){if(o<0)for(let e=0;e<s;++e)c[e]=(a-e)/-o;else for(let e=0;e<s;++e)c[e]=(a-e)*o}else if(o<0)for(let e=0;e<s;++e)c[e]=(i+e)/-o;else for(let e=0;e<s;++e)c[e]=(i+e)*o;return c}function xz(e,t,n){return t=+t,e=+e,n=+n,bz(e,t,n)[2]}function EPe(e,t,n){t=+t,e=+e,n=+n;let r=t<e,i=r?xz(t,e,n):xz(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}function DPe(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r<i;)a[r]=e+r*n;return a}function Sz(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e)}return this}var Cz=Symbol(`implicit`);function wz(){var e=new vz,t=[],n=[],r=Cz;function i(i){let a=e.get(i);if(a===void 0){if(r!==Cz)return r;e.set(i,a=t.push(i)-1)}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new vz;for(let r of n)e.has(r)||e.set(r,t.push(r)-1);return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return wz(t,n).unknown(r)},Sz.apply(i,arguments),i}function Tz(){var e=wz().unknown(void 0),t=e.domain,n=e.range,r=0,i=1,a,o,s=!1,c=0,l=0,u=.5;delete e.unknown;function d(){var e=t().length,d=i<r,f=d?i:r,p=d?r:i;a=(p-f)/Math.max(1,e-c+l*2),s&&(a=Math.floor(a)),f+=(p-f-a*(e-c))*u,o=a*(1-c),s&&(f=Math.round(f),o=Math.round(o));var m=DPe(e).map(function(e){return f+a*e});return n(d?m.reverse():m)}return e.domain=function(e){return arguments.length?(t(e),d()):t()},e.range=function(e){return arguments.length?([r,i]=e,r=+r,i=+i,d()):[r,i]},e.rangeRound=function(e){return[r,i]=e,r=+r,i=+i,s=!0,d()},e.bandwidth=function(){return o},e.step=function(){return a},e.round=function(e){return arguments.length?(s=!!e,d()):s},e.padding=function(e){return arguments.length?(c=Math.min(1,l=+e),d()):c},e.paddingInner=function(e){return arguments.length?(c=Math.min(1,e),d()):c},e.paddingOuter=function(e){return arguments.length?(l=+e,d()):l},e.align=function(e){return arguments.length?(u=Math.max(0,Math.min(1,e)),d()):u},e.copy=function(){return Tz(t(),[r,i]).round(s).paddingInner(c).paddingOuter(l).align(u)},Sz.apply(d(),arguments)}function Ez(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Dz(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Oz(){}var kz=.7,Az=1/kz,jz=`\\s*([+-]?\\d+)\\s*`,Mz=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,Nz=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,OPe=/^#([0-9a-f]{3,8})$/,kPe=RegExp(`^rgb\\(${jz},${jz},${jz}\\)$`),APe=RegExp(`^rgb\\(${Nz},${Nz},${Nz}\\)$`),jPe=RegExp(`^rgba\\(${jz},${jz},${jz},${Mz}\\)$`),MPe=RegExp(`^rgba\\(${Nz},${Nz},${Nz},${Mz}\\)$`),NPe=RegExp(`^hsl\\(${Mz},${Nz},${Nz}\\)$`),PPe=RegExp(`^hsla\\(${Mz},${Nz},${Nz},${Mz}\\)$`),Pz={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Ez(Oz,Lz,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Fz,formatHex:Fz,formatHex8:FPe,formatHsl:IPe,formatRgb:Iz,toString:Iz});function Fz(){return this.rgb().formatHex()}function FPe(){return this.rgb().formatHex8()}function IPe(){return Yz(this).formatHsl()}function Iz(){return this.rgb().formatRgb()}function Lz(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=OPe.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Rz(t):n===3?new Hz(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?zz(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?zz(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=kPe.exec(e))?new Hz(t[1],t[2],t[3],1):(t=APe.exec(e))?new Hz(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=jPe.exec(e))?zz(t[1],t[2],t[3],t[4]):(t=MPe.exec(e))?zz(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=NPe.exec(e))?Jz(t[1],t[2]/100,t[3]/100,1):(t=PPe.exec(e))?Jz(t[1],t[2]/100,t[3]/100,t[4]):Pz.hasOwnProperty(e)?Rz(Pz[e]):e===`transparent`?new Hz(NaN,NaN,NaN,0):null}function Rz(e){return new Hz(e>>16&255,e>>8&255,e&255,1)}function zz(e,t,n,r){return r<=0&&(e=t=n=NaN),new Hz(e,t,n,r)}function Bz(e){return e instanceof Oz||(e=Lz(e)),e?(e=e.rgb(),new Hz(e.r,e.g,e.b,e.opacity)):new Hz}function Vz(e,t,n,r){return arguments.length===1?Bz(e):new Hz(e,t,n,r??1)}function Hz(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Ez(Hz,Vz,Dz(Oz,{brighter(e){return e=e==null?Az:Az**+e,new Hz(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?kz:kz**+e,new Hz(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Hz(Kz(this.r),Kz(this.g),Kz(this.b),Gz(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Uz,formatHex:Uz,formatHex8:LPe,formatRgb:Wz,toString:Wz}));function Uz(){return`#${qz(this.r)}${qz(this.g)}${qz(this.b)}`}function LPe(){return`#${qz(this.r)}${qz(this.g)}${qz(this.b)}${qz((isNaN(this.opacity)?1:this.opacity)*255)}`}function Wz(){let e=Gz(this.opacity);return`${e===1?`rgb(`:`rgba(`}${Kz(this.r)}, ${Kz(this.g)}, ${Kz(this.b)}${e===1?`)`:`, ${e})`}`}function Gz(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Kz(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function qz(e){return e=Kz(e),(e<16?`0`:``)+e.toString(16)}function Jz(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Zz(e,t,n,r)}function Yz(e){if(e instanceof Zz)return new Zz(e.h,e.s,e.l,e.opacity);if(e instanceof Oz||(e=Lz(e)),!e)return new Zz;if(e instanceof Zz)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new Zz(o,s,c,e.opacity)}function Xz(e,t,n,r){return arguments.length===1?Yz(e):new Zz(e,t,n,r??1)}function Zz(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Ez(Zz,Xz,Dz(Oz,{brighter(e){return e=e==null?Az:Az**+e,new Zz(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?kz:kz**+e,new Zz(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new Hz(eB(e>=240?e-240:e+120,i,r),eB(e,i,r),eB(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Zz(Qz(this.h),$z(this.s),$z(this.l),Gz(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=Gz(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Qz(this.h)}, ${$z(this.s)*100}%, ${$z(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Qz(e){return e=(e||0)%360,e<0?e+360:e}function $z(e){return Math.max(0,Math.min(1,e||0))}function eB(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var tB=Math.PI/180,nB=180/Math.PI,rB=18,iB=.96422,aB=1,oB=.82521,sB=4/29,cB=6/29,lB=3*cB*cB,RPe=cB*cB*cB;function uB(e){if(e instanceof fB)return new fB(e.l,e.a,e.b,e.opacity);if(e instanceof vB)return yB(e);e instanceof Hz||(e=Bz(e));var t=gB(e.r),n=gB(e.g),r=gB(e.b),i=pB((.2225045*t+.7168786*n+.0606169*r)/aB),a,o;return t===n&&n===r?a=o=i:(a=pB((.4360747*t+.3850649*n+.1430804*r)/iB),o=pB((.0139322*t+.0971045*n+.7141733*r)/oB)),new fB(116*i-16,500*(a-i),200*(i-o),e.opacity)}function dB(e,t,n,r){return arguments.length===1?uB(e):new fB(e,t,n,r??1)}function fB(e,t,n,r){this.l=+e,this.a=+t,this.b=+n,this.opacity=+r}Ez(fB,dB,Dz(Oz,{brighter(e){return new fB(this.l+rB*(e??1),this.a,this.b,this.opacity)},darker(e){return new fB(this.l-rB*(e??1),this.a,this.b,this.opacity)},rgb(){var e=(this.l+16)/116,t=isNaN(this.a)?e:e+this.a/500,n=isNaN(this.b)?e:e-this.b/200;return t=iB*mB(t),e=aB*mB(e),n=oB*mB(n),new Hz(hB(3.1338561*t-1.6168667*e-.4906146*n),hB(-.9787684*t+1.9161415*e+.033454*n),hB(.0719453*t-.2289914*e+1.4052427*n),this.opacity)}}));function pB(e){return e>RPe?e**(1/3):e/lB+sB}function mB(e){return e>cB?e*e*e:lB*(e-sB)}function hB(e){return 255*(e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055)}function gB(e){return(e/=255)<=.04045?e/12.92:((e+.055)/1.055)**2.4}function zPe(e){if(e instanceof vB)return new vB(e.h,e.c,e.l,e.opacity);if(e instanceof fB||(e=uB(e)),e.a===0&&e.b===0)return new vB(NaN,0<e.l&&e.l<100?0:NaN,e.l,e.opacity);var t=Math.atan2(e.b,e.a)*nB;return new vB(t<0?t+360:t,Math.sqrt(e.a*e.a+e.b*e.b),e.l,e.opacity)}function _B(e,t,n,r){return arguments.length===1?zPe(e):new vB(e,t,n,r??1)}function vB(e,t,n,r){this.h=+e,this.c=+t,this.l=+n,this.opacity=+r}function yB(e){if(isNaN(e.h))return new fB(e.l,0,0,e.opacity);var t=e.h*tB;return new fB(e.l,Math.cos(t)*e.c,Math.sin(t)*e.c,e.opacity)}Ez(vB,_B,Dz(Oz,{brighter(e){return new vB(this.h,this.c,this.l+rB*(e??1),this.opacity)},darker(e){return new vB(this.h,this.c,this.l-rB*(e??1),this.opacity)},rgb(){return yB(this).rgb()}}));var bB=-.14861,xB=1.78277,SB=-.29227,CB=-.90649,wB=1.97294,TB=wB*CB,EB=wB*xB,DB=xB*SB-CB*bB;function BPe(e){if(e instanceof kB)return new kB(e.h,e.s,e.l,e.opacity);e instanceof Hz||(e=Bz(e));var t=e.r/255,n=e.g/255,r=e.b/255,i=(DB*r+TB*t-EB*n)/(DB+TB-EB),a=r-i,o=(wB*(n-i)-SB*a)/CB,s=Math.sqrt(o*o+a*a)/(wB*i*(1-i)),c=s?Math.atan2(o,a)*nB-120:NaN;return new kB(c<0?c+360:c,s,i,e.opacity)}function OB(e,t,n,r){return arguments.length===1?BPe(e):new kB(e,t,n,r??1)}function kB(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Ez(kB,OB,Dz(Oz,{brighter(e){return e=e==null?Az:Az**+e,new kB(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?kz:kz**+e,new kB(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=isNaN(this.h)?0:(this.h+120)*tB,t=+this.l,n=isNaN(this.s)?0:this.s*t*(1-t),r=Math.cos(e),i=Math.sin(e);return new Hz(255*(t+n*(bB*r+xB*i)),255*(t+n*(SB*r+CB*i)),255*(t+wB*r*n),this.opacity)}}));var AB=e=>()=>e;function jB(e,t){return function(n){return e+n*t}}function VPe(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function HPe(e,t){var n=t-e;return n?jB(e,n>180||n<-180?n-360*Math.round(n/360):n):AB(isNaN(e)?t:e)}function UPe(e){return(e=+e)==1?MB:function(t,n){return n-t?VPe(t,n,e):AB(isNaN(t)?n:t)}}function MB(e,t){var n=t-e;return n?jB(e,n):AB(isNaN(e)?t:e)}var NB=(function e(t){var n=UPe(t);function r(e,t){var r=n((e=Vz(e)).r,(t=Vz(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=MB(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function WPe(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function GPe(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function KPe(e,t){for(var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o=0;o<r;++o)i[o]=LB(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function qPe(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function PB(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function JPe(e,t){var n={},r={},i;for(i in typeof e==`object`&&e||(e={}),typeof t==`object`&&t||(t={}),t)i in e?n[i]=LB(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var FB=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,IB=new RegExp(FB.source,`g`);function YPe(e){return function(){return e}}function XPe(e){return function(t){return e(t)+``}}function ZPe(e,t){var n=FB.lastIndex=IB.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=FB.exec(e))&&(i=IB.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:PB(r,i)})),n=IB.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?XPe(c[0].x):YPe(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function LB(e,t){var n=typeof t,r;return t==null||n===`boolean`?AB(t):(n===`number`?PB:n===`string`?(r=Lz(t))?(t=r,NB):ZPe:t instanceof Lz?NB:t instanceof Date?qPe:GPe(t)?WPe:Array.isArray(t)?KPe:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?JPe:PB)(e,t)}function QPe(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var $Pe=1e-12;function RB(e){return((e=Math.exp(e))+1/e)/2}function eFe(e){return((e=Math.exp(e))-1/e)/2}function tFe(e){return((e=Math.exp(2*e))-1)/(e+1)}(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<$Pe)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=RB(y),c=s/(n*g)*(i*tFe(t*r+y)-eFe(y));return[a+c*d,o+c*f,s*i/RB(t*r+y)]}}return m.duration=Math.abs(h)*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4);function zB(e){return(function t(n){n=+n;function r(t,r){var i=e((t=OB(t)).h,(r=OB(r)).h),a=MB(t.s,r.s),o=MB(t.l,r.l),s=MB(t.opacity,r.opacity);return function(e){return t.h=i(e),t.s=a(e),t.l=o(e**+n),t.opacity=s(e),t+``}}return r.gamma=t,r})(1)}zB(HPe),zB(MB);function nFe(e){return function(){return e}}function rFe(e){return+e}var BB=[0,1];function VB(e){return e}function HB(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:nFe(isNaN(t)?NaN:.5)}function iFe(e,t){var n;return e>t&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function aFe(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i<r?(r=HB(i,r),a=n(o,a)):(r=HB(r,i),a=n(a,o)),function(e){return a(r(e))}}function oFe(e,t,n){var r=Math.min(e.length,t.length)-1,i=Array(r),a=Array(r),o=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<r;)i[o]=HB(e[o],e[o+1]),a[o]=n(t[o],t[o+1]);return function(t){var n=vPe(e,t,1,r)-1;return a[n](i[n](t))}}function sFe(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function cFe(){var e=BB,t=BB,n=LB,r,i,a,o=VB,s,c,l;function u(){var n=Math.min(e.length,t.length);return o!==VB&&(o=iFe(e[0],e[n-1])),s=n>2?oFe:aFe,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),PB))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,rFe),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=QPe,u()},d.clamp=function(e){return arguments.length?(o=e?!0:VB,u()):o!==VB},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function lFe(){return cFe()(VB,VB)}function uFe(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function UB(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function WB(e){return e=UB(Math.abs(e)),e?e[1]:NaN}function dFe(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function fFe(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var pFe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function GB(e){if(!(t=pFe.exec(e)))throw Error(`invalid format: `+e);var t;return new KB({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}GB.prototype=KB.prototype;function KB(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}KB.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type};function mFe(e){out:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case`.`:r=i=n;break;case`0`:r===0&&(r=n),i=n;break;default:if(!+e[n])break out;r>0&&(r=0)}return r>0?e.slice(0,r)+e.slice(i+1):e}var qB;function hFe(e,t){var n=UB(e,t);if(!n)return qB=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(qB=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+UB(e,Math.max(0,t+a-1))[0]}function JB(e,t){var n=UB(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var YB={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:uFe,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>JB(e*100,t),r:JB,s:hFe,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function XB(e){return e}var ZB=Array.prototype.map,QB=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function gFe(e){var t=e.grouping===void 0||e.thousands===void 0?XB:dFe(ZB.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?XB:fFe(ZB.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=GB(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):YB[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=YB[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=mFe(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&qB!==void 0?QB[8+qB/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++o<l;)if(p=e.charCodeAt(o),48>p||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T<h?Array(h-T+1).join(u):``;switch(g&&m&&(e=t(E+e,E.length?h-r.length:1/0),E=``),d){case`<`:e=n+e+r+E;break;case`=`:e=n+E+e+r;break;case`^`:e=E.slice(0,T=E.length>>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(WB(t)/3)))*3,r=10**-n,i=l((e=GB(e),e.type=`f`,e),{suffix:QB[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var $B,eV,tV;_Fe({thousands:`,`,grouping:[3],currency:[`$`,``]});function _Fe(e){return $B=gFe(e),eV=$B.format,tV=$B.formatPrefix,$B}function vFe(e){return Math.max(0,-WB(Math.abs(e)))}function yFe(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(WB(t)/3)))*3-WB(Math.abs(e)))}function bFe(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,WB(t)-WB(e))+1}function xFe(e,t,n,r){var i=EPe(e,t,n),a;switch(r=GB(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=yFe(i,o))&&(r.precision=a),tV(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=bFe(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=vFe(i))&&(r.precision=a-(r.type===`%`)*2)}return eV(r)}function SFe(e){var t=e.domain;return e.ticks=function(e){var n=t();return TPe(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return xFe(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s<o&&(l=o,o=s,s=l,l=i,i=a,a=l);u-->0;){if(l=xz(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function nV(){var e=lFe();return e.copy=function(){return sFe(e,nV())},Sz.apply(e,arguments),SFe(e)}function CFe(e,t){t.domain&&(`nice`in e||`quantiles`in e||`padding`in e,e.domain(t.domain))}function wFe(e,t){t.range&&(`padding`in e,e.range(t.range))}function TFe(e,t){`align`in e&&`align`in t&&t.align!==void 0&&e.align(t.align)}function EFe(e,t){`base`in e&&`base`in t&&t.base!==void 0&&e.base(t.base)}function DFe(e,t){`clamp`in e&&`clamp`in t&&t.clamp!==void 0&&e.clamp(t.clamp)}function OFe(e,t){`constant`in e&&`constant`in t&&t.constant!==void 0&&e.constant(t.constant)}function kFe(e,t){`exponent`in e&&`exponent`in t&&t.exponent!==void 0&&e.exponent(t.exponent)}var rV=e=>()=>e;function iV(e,t){return function(n){return e+n*t}}function AFe(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function aV(e,t){var n=t-e;return n?iV(e,n>180||n<-180?n-360*Math.round(n/360):n):rV(isNaN(e)?t:e)}function jFe(e){return(e=+e)==1?oV:function(t,n){return n-t?AFe(t,n,e):rV(isNaN(t)?n:t)}}function oV(e,t){var n=t-e;return n?iV(e,n):rV(isNaN(e)?t:e)}var MFe=(function e(t){var n=jFe(t);function r(e,t){var r=n((e=Vz(e)).r,(t=Vz(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=oV(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function NFe(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}function sV(e){return function(t,n){var r=e((t=Xz(t)).h,(n=Xz(n)).h),i=oV(t.s,n.s),a=oV(t.l,n.l),o=oV(t.opacity,n.opacity);return function(e){return t.h=r(e),t.s=i(e),t.l=a(e),t.opacity=o(e),t+``}}}var PFe=sV(aV),FFe=sV(oV);function IFe(e,t){var n=oV((e=dB(e)).l,(t=dB(t)).l),r=oV(e.a,t.a),i=oV(e.b,t.b),a=oV(e.opacity,t.opacity);return function(t){return e.l=n(t),e.a=r(t),e.b=i(t),e.opacity=a(t),e+``}}function cV(e){return function(t,n){var r=e((t=_B(t)).h,(n=_B(n)).h),i=oV(t.c,n.c),a=oV(t.l,n.l),o=oV(t.opacity,n.opacity);return function(e){return t.h=r(e),t.c=i(e),t.l=a(e),t.opacity=o(e),t+``}}}var LFe=cV(aV),RFe=cV(oV);function lV(e){return(function t(n){n=+n;function r(t,r){var i=e((t=OB(t)).h,(r=OB(r)).h),a=oV(t.s,r.s),o=oV(t.l,r.l),s=oV(t.opacity,r.opacity);return function(e){return t.h=i(e),t.s=a(e),t.l=o(e**+n),t.opacity=s(e),t+``}}return r.gamma=t,r})(1)}var uV={lab:IFe,hcl:LFe,"hcl-long":RFe,hsl:PFe,"hsl-long":FFe,cubehelix:lV(aV),"cubehelix-long":lV(oV),rgb:MFe};function zFe(e){switch(e){case`lab`:case`hcl`:case`hcl-long`:case`hsl`:case`hsl-long`:case`cubehelix`:case`cubehelix-long`:case`rgb`:return uV[e]}let{type:t,gamma:n}=e,r=uV[t];return n===void 0?r:r.gamma(n)}function BFe(e,t){if(`interpolate`in t&&`interpolate`in e&&t.interpolate!==void 0){let n=zFe(t.interpolate);e.interpolate(n)}}var dV=new Date,fV=new Date;function pV(e,t,n,r){function i(t){return e(t=arguments.length===0?new Date:new Date(+t)),t}return i.floor=t=>(e(t=new Date(+t)),t),i.ceil=n=>(e(n=new Date(n-1)),t(n,1),e(n),n),i.round=e=>{let t=i(e),n=i.ceil(e);return e-t<n-e?t:n},i.offset=(e,n)=>(t(e=new Date(+e),n==null?1:Math.floor(n)),e),i.range=(n,r,a)=>{let o=[];if(n=i.ceil(n),a=a==null?1:Math.floor(a),!(n<r)||!(a>0))return o;let s;do o.push(s=new Date(+n)),t(n,a),e(n);while(s<n&&n<r);return o},i.filter=n=>pV(t=>{if(t>=t)for(;e(t),!n(t);)t.setTime(t-1)},(e,r)=>{if(e>=e){if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););}}),n&&(i.count=(t,r)=>(dV.setTime(+t),fV.setTime(+r),e(dV),e(fV),Math.floor(n(dV,fV))),i.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?i.filter(r?t=>r(t)%e===0:t=>i.count(0,t)%e===0):i)),i}var mV=1e3,hV=mV*60,gV=hV*60,_V=gV*24,vV=_V*7,yV=pV(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*mV)},(e,t)=>(t-e)/mV,e=>e.getUTCSeconds());yV.range;var bV=pV(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*mV)},(e,t)=>{e.setTime(+e+t*hV)},(e,t)=>(t-e)/hV,e=>e.getMinutes());bV.range;var xV=pV(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*hV)},(e,t)=>(t-e)/hV,e=>e.getUTCMinutes());xV.range;var SV=pV(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*mV-e.getMinutes()*hV)},(e,t)=>{e.setTime(+e+t*gV)},(e,t)=>(t-e)/gV,e=>e.getHours());SV.range;var CV=pV(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*gV)},(e,t)=>(t-e)/gV,e=>e.getUTCHours());CV.range;var wV=pV(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*hV)/_V,e=>e.getDate()-1);wV.range;var TV=pV(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/_V,e=>e.getUTCDate()-1);TV.range,pV(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/_V,e=>Math.floor(e/_V)).range;function EV(e){return pV(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(e,t)=>{e.setDate(e.getDate()+t*7)},(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*hV)/vV)}var DV=EV(0),VFe=EV(1),HFe=EV(2),UFe=EV(3),WFe=EV(4),GFe=EV(5),KFe=EV(6);DV.range,VFe.range,HFe.range,UFe.range,WFe.range,GFe.range,KFe.range;function OV(e){return pV(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t*7)},(e,t)=>(t-e)/vV)}var kV=OV(0),qFe=OV(1),JFe=OV(2),YFe=OV(3),XFe=OV(4),ZFe=OV(5),QFe=OV(6);kV.range,qFe.range,JFe.range,YFe.range,XFe.range,ZFe.range,QFe.range;var AV=pV(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());AV.range;var jV=pV(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());jV.range;var MV=pV(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());MV.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:pV(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)}),MV.range;var NV=pV(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());NV.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:pV(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)}),NV.range;var $Fe=new Date(Date.UTC(2020,1,2,3,4,5)),eIe=`%Y-%m-%d %H:%M`;function tIe(e){return e.tickFormat(1,eIe)($Fe)===`2020-02-02 03:04`}var PV={day:wV,hour:SV,minute:bV,month:AV,second:yV,week:DV,year:MV},FV={day:TV,hour:CV,minute:xV,month:jV,second:yV,week:kV,year:NV};function nIe(e,t){if(`nice`in t&&t.nice!==void 0&&`nice`in e){let{nice:n}=t;if(typeof n==`boolean`)n&&e.nice();else if(typeof n==`number`)e.nice(n);else{let t=e,r=tIe(t);if(typeof n==`string`)t.nice(r?FV[n]:PV[n]);else{let{interval:e,step:i}=n,a=(r?FV[e]:PV[e]).every(i);a!=null&&t.nice(a)}}}}function rIe(e,t){`padding`in e&&`padding`in t&&t.padding!==void 0&&e.padding(t.padding),`paddingInner`in e&&`paddingInner`in t&&t.paddingInner!==void 0&&e.paddingInner(t.paddingInner),`paddingOuter`in e&&`paddingOuter`in t&&t.paddingOuter!==void 0&&e.paddingOuter(t.paddingOuter)}function iIe(e,t){if(t.reverse){let t=e.range().slice().reverse();`padding`in e,e.range(t)}}function aIe(e,t){`round`in t&&t.round!==void 0&&(t.round&&`interpolate`in t&&t.interpolate!==void 0?console.warn(`[visx/scale/applyRound] ignoring round: scale config contains round and interpolate. only applying interpolate. config:`,t):`round`in e?e.round(t.round):`interpolate`in e&&t.round&&e.interpolate(NFe))}function oIe(e,t){`unknown`in e&&`unknown`in t&&t.unknown!==void 0&&e.unknown(t.unknown)}function sIe(e,t){if(`zero`in t&&t.zero===!0){let[t,n]=e.domain(),r=n<t,[i,a]=r?[n,t]:[t,n],o=[Math.min(0,i),Math.max(0,a)];e.domain(r?o.reverse():o)}}var cIe=[`domain`,`nice`,`zero`,`interpolate`,`round`,`range`,`reverse`,`align`,`base`,`clamp`,`constant`,`exponent`,`padding`,`unknown`],lIe={domain:CFe,nice:nIe,zero:sIe,interpolate:BFe,round:aIe,align:TFe,base:EFe,clamp:DFe,constant:OFe,exponent:kFe,padding:rIe,range:wFe,reverse:iIe,unknown:oIe};function IV(){let e=new Set([...arguments]),t=cIe.filter(t=>e.has(t));return function(e,n){return n!==void 0&&t.forEach(t=>{lIe[t](e,n)}),e}}var uIe=IV(`domain`,`range`,`reverse`,`align`,`padding`,`round`);function dIe(e){return uIe(Tz(),e)}var fIe=IV(`domain`,`range`,`reverse`,`clamp`,`interpolate`,`nice`,`round`,`zero`);function LV(e){return fIe(nV(),e)}function RV(e){return function(){return e}}var zV=Math.abs,BV=Math.atan2,VV=Math.cos,pIe=Math.max,HV=Math.min,UV=Math.sin,WV=Math.sqrt,GV=Math.PI,KV=GV/2,qV=2*GV;function mIe(e){return e>1?0:e<-1?GV:Math.acos(e)}function JV(e){return e>=1?KV:e<=-1?-KV:Math.asin(e)}var YV=Math.PI,XV=2*YV,ZV=1e-6,hIe=XV-ZV;function QV(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function gIe(e){let t=Math.floor(e);if(!(t>=0))throw Error(`invalid digits: ${e}`);if(t>15)return QV;let n=10**t;return function(e){this._+=e[0];for(let t=1,r=e.length;t<r;++t)this._+=Math.round(arguments[t]*n)/n+e[t]}}function $V(e,t,n,r){return e===n&&t===r}function _Ie(e){let t=Math.floor(e);if(!(t<=15))return $V;let n=10**t,r=function(e){return Math.round(e*n)};return function(e,t,n,i){return r(e)===r(n)&&r(t)===r(i)}}var eH=class{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._=``,this._append=e==null?QV:gIe(e),this._equal=e==null?$V:_Ie(e)}moveTo(e,t){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,t){this._append`L${this._x1=+e},${this._y1=+t}`}quadraticCurveTo(e,t,n,r){this._append`Q${+e},${+t},${this._x1=+n},${this._y1=+r}`}bezierCurveTo(e,t,n,r,i,a){this._append`C${+e},${+t},${+n},${+r},${this._x1=+i},${this._y1=+a}`}arcTo(e,t,n,r,i){if(e=+e,t=+t,n=+n,r=+r,i=+i,i<0)throw Error(`negative radius: ${i}`);let a=this._x1,o=this._y1,s=n-e,c=r-t,l=a-e,u=o-t,d=l*l+u*u;if(this._x1===null)this._append`M${this._x1=e},${this._y1=t}`;else if(d>ZV){if(!(Math.abs(u*s-c*l)>ZV)||!i)this._append`L${this._x1=e},${this._y1=t}`;else{let f=n-a,p=r-o,m=s*s+c*c,h=f*f+p*p,g=Math.sqrt(m),_=Math.sqrt(d),v=i*Math.tan((YV-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>ZV&&this._append`L${e+y*l},${t+y*u}`,this._append`A${i},${i},0,0,${+(u*f>l*p)},${this._x1=e+b*s},${this._y1=t+b*c}`}}}arc(e,t,n,r,i,a){if(e=+e,t=+t,n=+n,a=!!a,n<0)throw Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,d=a?r-i:i-r;if(this._x1===null?this._append`M${c},${l}`:(Math.abs(this._x1-c)>ZV||Math.abs(this._y1-l)>ZV)&&this._append`L${c},${l}`,n){if(d<0&&(d=d%XV+XV),d>hIe)this._append`A${n},${n},0,1,${u},${e-o},${t-s}A${n},${n},0,1,${u},${this._x1=c},${this._y1=l}`;else if(d>ZV){let a=e+n*Math.cos(i),o=t+n*Math.sin(i);if(d>=YV&&this._equal(c,l,a,o)){d/=2;let i=r+d;this._append`A${n},${n},0,${+(d>=YV)},${u},${e+n*Math.cos(i)},${t+n*Math.sin(i)}`}this._append`A${n},${n},0,${+(d>=YV)},${u},${this._x1=a},${this._y1=o}`}}}rect(e,t,n,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}};eH.prototype;function tH(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{let e=Math.floor(n);if(!(e>=0))throw RangeError(`invalid digits: ${n}`);t=e}return e},()=>new eH(t)}function vIe(e){return e.innerRadius}function yIe(e){return e.outerRadius}function bIe(e){return e.startAngle}function xIe(e){return e.endAngle}function SIe(e){return e&&e.padAngle}function CIe(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function nH(e,t,n,r,i,a,o){var s=e-n,c=t-r,l=(o?a:-a)/WV(s*s+c*c),u=l*c,d=-l*s,f=e+u,p=t+d,m=n+u,h=r+d,g=(f+m)/2,_=(p+h)/2,v=m-f,y=h-p,b=v*v+y*y,x=i-a,S=f*h-m*p,C=(y<0?-1:1)*WV(pIe(0,x*x*b-S*S)),w=(S*y-v*C)/b,T=(-S*v-y*C)/b,E=(S*y+v*C)/b,D=(-S*v+y*C)/b,O=w-g,k=T-_,A=E-g,j=D-_;return O*O+k*k>A*A+j*j&&(w=E,T=D),{cx:w,cy:T,x01:-u,y01:-d,x11:w*(i/x-1),y11:T*(i/x-1)}}function wIe(){var e=vIe,t=yIe,n=RV(0),r=null,i=bIe,a=xIe,o=SIe,s=null,c=tH(l);function l(){var l,u,d=+e.apply(this,arguments),f=+t.apply(this,arguments),p=i.apply(this,arguments)-KV,m=a.apply(this,arguments)-KV,h=zV(m-p),g=m>p;if(s||=l=c(),f<d&&(u=f,f=d,d=u),!(f>1e-12))s.moveTo(0,0);else if(h>qV-1e-12)s.moveTo(f*VV(p),f*UV(p)),s.arc(0,0,f,p,m,!g),d>1e-12&&(s.moveTo(d*VV(m),d*UV(m)),s.arc(0,0,d,m,p,g));else{var _=p,v=m,y=p,b=m,x=h,S=h,C=o.apply(this,arguments)/2,w=C>1e-12&&(r?+r.apply(this,arguments):WV(d*d+f*f)),T=HV(zV(f-d)/2,+n.apply(this,arguments)),E=T,D=T,O,k;if(w>1e-12){var A=JV(w/d*UV(C)),j=JV(w/f*UV(C));(x-=A*2)>1e-12?(A*=g?1:-1,y+=A,b-=A):(x=0,y=b=(p+m)/2),(S-=j*2)>1e-12?(j*=g?1:-1,_+=j,v-=j):(S=0,_=v=(p+m)/2)}var M=f*VV(_),N=f*UV(_),P=d*VV(b),F=d*UV(b);if(T>1e-12){var I=f*VV(v),L=f*UV(v),R=d*VV(y),z=d*UV(y),B;if(h<GV){if(B=CIe(M,N,R,z,I,L,P,F)){var V=M-B[0],H=N-B[1],U=I-B[0],ee=L-B[1],te=1/UV(mIe((V*U+H*ee)/(WV(V*V+H*H)*WV(U*U+ee*ee)))/2),ne=WV(B[0]*B[0]+B[1]*B[1]);E=HV(T,(d-ne)/(te-1)),D=HV(T,(f-ne)/(te+1))}else E=D=0}}S>1e-12?D>1e-12?(O=nH(R,z,M,N,f,D,g),k=nH(I,L,P,F,f,D,g),s.moveTo(O.cx+O.x01,O.cy+O.y01),D<T?s.arc(O.cx,O.cy,D,BV(O.y01,O.x01),BV(k.y01,k.x01),!g):(s.arc(O.cx,O.cy,D,BV(O.y01,O.x01),BV(O.y11,O.x11),!g),s.arc(0,0,f,BV(O.cy+O.y11,O.cx+O.x11),BV(k.cy+k.y11,k.cx+k.x11),!g),s.arc(k.cx,k.cy,D,BV(k.y11,k.x11),BV(k.y01,k.x01),!g))):(s.moveTo(M,N),s.arc(0,0,f,_,v,!g)):s.moveTo(M,N),!(d>1e-12)||!(x>1e-12)?s.lineTo(P,F):E>1e-12?(O=nH(P,F,I,L,d,-E,g),k=nH(M,N,R,z,d,-E,g),s.lineTo(O.cx+O.x01,O.cy+O.y01),E<T?s.arc(O.cx,O.cy,E,BV(O.y01,O.x01),BV(k.y01,k.x01),!g):(s.arc(O.cx,O.cy,E,BV(O.y01,O.x01),BV(O.y11,O.x11),!g),s.arc(0,0,d,BV(O.cy+O.y11,O.cx+O.x11),BV(k.cy+k.y11,k.cx+k.x11),g),s.arc(k.cx,k.cy,E,BV(k.y11,k.x11),BV(k.y01,k.x01),!g))):s.arc(0,0,d,b,y,g)}if(s.closePath(),l)return s=null,l+``||null}return l.centroid=function(){var n=(+e.apply(this,arguments)+ +t.apply(this,arguments))/2,r=(+i.apply(this,arguments)+ +a.apply(this,arguments))/2-GV/2;return[VV(r)*n,UV(r)*n]},l.innerRadius=function(t){return arguments.length?(e=typeof t==`function`?t:RV(+t),l):e},l.outerRadius=function(e){return arguments.length?(t=typeof e==`function`?e:RV(+e),l):t},l.cornerRadius=function(e){return arguments.length?(n=typeof e==`function`?e:RV(+e),l):n},l.padRadius=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:RV(+e),l):r},l.startAngle=function(e){return arguments.length?(i=typeof e==`function`?e:RV(+e),l):i},l.endAngle=function(e){return arguments.length?(a=typeof e==`function`?e:RV(+e),l):a},l.padAngle=function(e){return arguments.length?(o=typeof e==`function`?e:RV(+e),l):o},l.context=function(e){return arguments.length?(s=e??null,l):s},l}Array.prototype.slice;function rH(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function iH(e){this._context=e}iH.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t)}}};function aH(e){return new iH(e)}function oH(e){return e[0]}function sH(e){return e[1]}function cH(e,t){var n=RV(!0),r=null,i=aH,a=null,o=tH(s);e=typeof e==`function`?e:e===void 0?oH:RV(e),t=typeof t==`function`?t:t===void 0?sH:RV(t);function s(s){var c,l=(s=rH(s)).length,u,d=!1,f;for(r??(a=i(f=o())),c=0;c<=l;++c)!(c<l&&n(u=s[c],c,s))===d&&((d=!d)?a.lineStart():a.lineEnd()),d&&a.point(+e(u,c,s),+t(u,c,s));if(f)return a=null,f+``||null}return s.x=function(t){return arguments.length?(e=typeof t==`function`?t:RV(+t),s):e},s.y=function(e){return arguments.length?(t=typeof e==`function`?e:RV(+e),s):t},s.defined=function(e){return arguments.length?(n=typeof e==`function`?e:RV(!!e),s):n},s.curve=function(e){return arguments.length?(i=e,r!=null&&(a=i(r)),s):i},s.context=function(e){return arguments.length?(e==null?r=a=null:a=i(r=e),s):r},s}function TIe(e,t,n){var r=null,i=RV(!0),a=null,o=aH,s=null,c=tH(l);e=typeof e==`function`?e:e===void 0?oH:RV(+e),t=typeof t==`function`?t:RV(t===void 0?0:+t),n=typeof n==`function`?n:n===void 0?sH:RV(+n);function l(l){var u,d,f,p=(l=rH(l)).length,m,h=!1,g,_=Array(p),v=Array(p);for(a??(s=o(g=c())),u=0;u<=p;++u){if(!(u<p&&i(m=l[u],u,l))===h){if(h=!h)d=u,s.areaStart(),s.lineStart();else{for(s.lineEnd(),s.lineStart(),f=u-1;f>=d;--f)s.point(_[f],v[f]);s.lineEnd(),s.areaEnd()}}h&&(_[u]=+e(m,u,l),v[u]=+t(m,u,l),s.point(r?+r(m,u,l):_[u],n?+n(m,u,l):v[u]))}if(g)return s=null,g+``||null}function u(){return cH().defined(i).curve(o).context(a)}return l.x=function(t){return arguments.length?(e=typeof t==`function`?t:RV(+t),r=null,l):e},l.x0=function(t){return arguments.length?(e=typeof t==`function`?t:RV(+t),l):e},l.x1=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:RV(+e),l):r},l.y=function(e){return arguments.length?(t=typeof e==`function`?e:RV(+e),n=null,l):t},l.y0=function(e){return arguments.length?(t=typeof e==`function`?e:RV(+e),l):t},l.y1=function(e){return arguments.length?(n=e==null?null:typeof e==`function`?e:RV(+e),l):n},l.lineX0=l.lineY0=function(){return u().x(e).y(t)},l.lineY1=function(){return u().x(e).y(n)},l.lineX1=function(){return u().x(r).y(t)},l.defined=function(e){return arguments.length?(i=typeof e==`function`?e:RV(!!e),l):i},l.curve=function(e){return arguments.length?(o=e,a!=null&&(s=o(a)),l):o},l.context=function(e){return arguments.length?(e==null?a=s=null:s=o(a=e),l):a},l}function EIe(e,t){return t<e?-1:t>e?1:t>=e?0:NaN}function DIe(e){return e}function OIe(){var e=DIe,t=EIe,n=null,r=RV(0),i=RV(qV),a=RV(0);function o(o){var s,c=(o=rH(o)).length,l,u,d=0,f=Array(c),p=Array(c),m=+r.apply(this,arguments),h=Math.min(qV,Math.max(-qV,i.apply(this,arguments)-m)),g,_=Math.min(Math.abs(h)/c,a.apply(this,arguments)),v=_*(h<0?-1:1),y;for(s=0;s<c;++s)(y=p[f[s]=s]=+e(o[s],s,o))>0&&(d+=y);for(t==null?n!=null&&f.sort(function(e,t){return n(o[e],o[t])}):f.sort(function(e,n){return t(p[e],p[n])}),s=0,u=d?(h-c*v)/d:0;s<c;++s,m=g)l=f[s],y=p[l],g=m+(y>0?y*u:0)+v,p[l]={data:o[l],index:s,value:y,startAngle:m,endAngle:g,padAngle:_};return p}return o.value=function(t){return arguments.length?(e=typeof t==`function`?t:RV(+t),o):e},o.sortValues=function(e){return arguments.length?(t=e,n=null,o):t},o.sort=function(e){return arguments.length?(n=e,t=null,o):n},o.startAngle=function(e){return arguments.length?(r=typeof e==`function`?e:RV(+e),o):r},o.endAngle=function(e){return arguments.length?(i=typeof e==`function`?e:RV(+e),o):i},o.padAngle=function(e){return arguments.length?(a=typeof e==`function`?e:RV(+e),o):a},o}function lH(e,t){if((o=e.length)>1)for(var n=1,r,i,a=e[t[0]],o,s=a.length;n<o;++n)for(i=a,a=e[t[n]],r=0;r<s;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function uH(e){for(var t=e.length,n=Array(t);--t>=0;)n[t]=t;return n}function kIe(e,t){return e[t]}function AIe(e){let t=[];return t.key=e,t}function jIe(){var e=RV([]),t=uH,n=lH,r=kIe;function i(i){var a=Array.from(e.apply(this,arguments),AIe),o,s=a.length,c=-1,l;for(let e of i)for(o=0,++c;o<s;++o)(a[o][c]=[0,+r(e,a[o].key,c,i)]).data=e;for(o=0,l=rH(t(a));o<s;++o)a[l[o]].index=o;return n(a,l),a}return i.keys=function(t){return arguments.length?(e=typeof t==`function`?t:RV(Array.from(t)),i):e},i.value=function(e){return arguments.length?(r=typeof e==`function`?e:RV(+e),i):r},i.order=function(e){return arguments.length?(t=e==null?uH:typeof e==`function`?e:RV(Array.from(e)),i):t},i.offset=function(e){return arguments.length?(n=e??lH,i):n},i}function MIe(e,t){if((r=e.length)>0){for(var n,r,i=0,a=e[0].length,o;i<a;++i){for(o=n=0;n<r;++n)o+=e[n][i][1]||0;if(o)for(n=0;n<r;++n)e[n][i][1]/=o}lH(e,t)}}function NIe(e,t){if((c=e.length)>0)for(var n,r=0,i,a,o,s,c,l=e[t[0]].length;r<l;++r)for(o=s=0,n=0;n<c;++n)(a=(i=e[t[n]][r])[1]-i[0])>0?(i[0]=o,i[1]=o+=a):a<0?(i[1]=s,i[0]=s+=a):(i[0]=0,i[1]=a)}function PIe(e,t){if((i=e.length)>0){for(var n=0,r=e[t[0]],i,a=r.length;n<a;++n){for(var o=0,s=0;o<i;++o)s+=e[o][n][1]||0;r[n][1]+=r[n][0]=-s/2}lH(e,t)}}function FIe(e,t){if((o=e.length)>0&&(a=(i=e[t[0]]).length)>0){for(var n=0,r=1,i,a,o;r<a;++r){for(var s=0,c=0,l=0;s<o;++s){for(var u=e[t[s]],d=u[r][1]||0,f=(d-(u[r-1][1]||0))/2,p=0;p<s;++p){var m=e[t[p]],h=m[r][1]||0,g=m[r-1][1]||0;f+=h-g}c+=d,l+=f*d}i[r-1][1]+=i[r-1][0]=n,c&&(n-=l/c)}i[r-1][1]+=i[r-1][0]=n,lH(e,t)}}function IIe(e){var t=e.map(LIe);return uH(e).sort(function(e,n){return t[e]-t[n]})}function LIe(e){for(var t=-1,n=0,r=e.length,i,a=-1/0;++t<r;)(i=+e[t][1])>a&&(a=i,n=t);return n}function dH(e){var t=e.map(fH);return uH(e).sort(function(e,n){return t[e]-t[n]})}function fH(e){for(var t=0,n=-1,r=e.length,i;++n<r;)(i=+e[n][1])&&(t+=i);return t}function RIe(e){return dH(e).reverse()}function zIe(e){var t=e.length,n,r,i=e.map(fH),a=IIe(e),o=0,s=0,c=[],l=[];for(n=0;n<t;++n)r=a[n],o<s?(o+=i[r],c.push(r)):(s+=i[r],l.push(r));return l.reverse().concat(c)}function BIe(e){return uH(e).reverse()}function pH(e,t){e(t)}var mH={ascending:dH,descending:RIe,insideout:zIe,none:uH,reverse:BIe};Object.keys(mH);function VIe(e){return e&&mH[e]||mH.none}var hH={expand:MIe,diverging:NIe,none:lH,silhouette:PIe,wiggle:FIe};Object.keys(hH);function HIe(e){return e&&hH[e]||hH.none}function UIe(){let{innerRadius:e,outerRadius:t,cornerRadius:n,startAngle:r,endAngle:i,padAngle:a,padRadius:o}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=wIe();return e!=null&&pH(s.innerRadius,e),t!=null&&pH(s.outerRadius,t),n!=null&&pH(s.cornerRadius,n),r!=null&&pH(s.startAngle,r),i!=null&&pH(s.endAngle,i),a!=null&&pH(s.padAngle,a),o!=null&&pH(s.padRadius,o),s}function WIe(){let{x:e,x0:t,x1:n,y:r,y0:i,y1:a,defined:o,curve:s}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},c=TIe();return e&&pH(c.x,e),t&&pH(c.x0,t),n&&pH(c.x1,n),r&&pH(c.y,r),i&&pH(c.y0,i),a&&pH(c.y1,a),o&&c.defined(o),s&&c.curve(s),c}function GIe(){let{x:e,y:t,defined:n,curve:r}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},i=cH();return e&&pH(i.x,e),t&&pH(i.y,t),n&&i.defined(n),r&&i.curve(r),i}function KIe(){let{startAngle:e,endAngle:t,padAngle:n,value:r,sort:i,sortValues:a}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=OIe();return a===void 0?i===void 0?o.sortValues(null):i===null?o.sort(null):o.sort(i):o.sortValues(a),r!=null&&o.value(r),n!=null&&pH(o.padAngle,n),e!=null&&pH(o.startAngle,e),t!=null&&pH(o.endAngle,t),o}function qIe(e){let{keys:t,value:n,order:r,offset:i}=e,a=jIe();return t&&a.keys(t),n&&pH(a.value,n),r&&a.order(VIe(r)),i&&a.offset(HIe(i)),a}var JIe=[[1e9,`B`],[1e6,`M`],[1e3,`k`]],YIe=new Set([`$`,`¥`,`€`,`£`]),XIe=new Set([`%`,`×`,`x`]);function gH(e,t={}){if(e==null||Number.isNaN(e))return`—`;let n=Math.abs(e),r,i=t.compact===!1?void 0:JIe.find(([e])=>n>=e);if(i){let e=n/i[0];r=(e<10?e.toFixed(1):String(Math.round(e))).replace(/\.0$/,``)+i[1]}else r=t.decimals==null?String(+n.toFixed(2)):n.toFixed(t.decimals);let a=e<0?`−`:t.signed&&e>0?`+`:``,{unit:o}=t;return o?YIe.has(o)?a+o+r:XIe.has(o)?a+r+o:`${a}${r} ${o}`:a+r}function _H(e,t={},n=!1){return gH(e,{...t,signed:!1,unit:n?t.unit:void 0})}function vH(e,t){let n=0;for(let r of e)n+=r.charCodeAt(0)>11904?t:t*.58;return n}var yH={series1:`var(--rc-chart-1)`,series2:`var(--rc-chart-2)`,series3:`var(--rc-chart-3)`,series4:`var(--rc-chart-4)`,series5:`var(--rc-chart-5)`,series6:`var(--rc-chart-6)`,muted:`var(--rc-chart-muted)`,grid:`var(--rc-chart-grid)`,axis:`var(--rc-chart-axis)`,reference:`var(--rc-chart-reference)`,crosshair:`var(--rc-chart-crosshair)`,areaOpacity:`var(--rc-chart-area-opacity)`,hoverWash:`var(--rc-chart-hover-wash)`},bH=[`var(--rc-chart-1)`,`var(--rc-chart-2)`,`var(--rc-chart-3)`,`var(--rc-chart-4)`,`var(--rc-chart-5)`,`var(--rc-chart-6)`],ZIe={width:720,height:300,compact:!1},QIe={width:340,height:240,compact:!0};function xH(e,t,n,r,i){let a=Math.min(0,i?.min??e),o=Math.max(0,i?.max??t),s=LV({domain:[a,o===a?a+1:o],nice:r?3:4}),c=s.ticks(r?3:4),l=s.domain(),u=c.map((e,t)=>_H(e,n,t===c.length-1));return{ticks:c,domain:l,width:Math.max(...u.map(e=>vH(e,11)))+12,labels:u}}function SH(e,t){let n=e[t];return typeof n==`number`?n:null}function CH(e,t){let n=e[t];return n==null?``:String(n)}function wH(e,t){let n=e.series[t];return e.highlight&&e.type!==`pie`&&n.key!==e.highlight?yH.muted:bH[((n.color==null?t:n.color-1)%bH.length+bH.length)%bH.length]}function TH(e,t){let n=e.series[t];return n.label||n.key}function EH(e,t,n,r,i){let a=Math.abs(r-n),o=Math.min(i,t/2,a);return r<=n?`M${e},${n}V${r+o}Q${e},${r} ${e+o},${r}H${e+t-o}Q${e+t},${r} ${e+t},${r+o}V${n}Z`:`M${e},${n}V${r-o}Q${e},${r} ${e+o},${r}H${e+t-o}Q${e+t},${r} ${e+t},${r-o}V${n}Z`}function $Ie(e){let t={area:`Area chart`,bar:e.stacked?`Stacked bar chart`:`Bar chart`,line:`Line chart`,pie:e.donut?`Donut chart`:`Pie chart`,scatter:`Scatter chart`}[e.type],n=e.series.map(e=>e.label||e.key).join(`, `);return`${e.title?`${e.title}. `:``}${t} with ${e.data.length} ${e.type===`pie`?`slices`:e.type===`scatter`?`points`:`categories`}; series: ${n}.`}var eLe=`appgph0`,tLe=`appgph1`,nLe=`appgph5`,rLe=`appgph6`,iLe=`appgph7`,aLe=`appgph8`,oLe=`appgph9`,sLe=`appgpha`,DH=`appgphb`,OH=`appgphc`,kH=`appgphd`,AH=`appgphe`,cLe=`appgphh`,lLe=`appgphi`,uLe=`appgphj`,dLe=`appgphk`,fLe=`appgphm`,pLe=`appgphn`,mLe=`appgpho`,hLe=`appgphp`,gLe=`appgphs`,_Le=`appgpht`,vLe=`appgphu`,yLe=`appgphv`,bLe=`appgphw`,xLe=`appgphx`;function jH({state:e,width:t,height:n}){let r=`${e.x/t*100}%`,i=`${e.y/n*100}%`,a=e.side===`left`?`translateX(calc(-100% - 14px))`:`translateX(14px)`;return(0,K.jsxs)(`div`,{"aria-hidden":!0,className:dLe,style:{left:r,top:i,transform:a},children:[e.title&&(0,K.jsx)(`div`,{className:`appgphl`,children:e.title}),e.rows.map(e=>(0,K.jsxs)(`div`,{className:fLe,children:[(0,K.jsx)(`i`,{className:pLe,style:{background:e.color}}),(0,K.jsx)(`span`,{className:mLe,children:e.value}),(0,K.jsx)(`span`,{className:hLe,children:e.label})]},e.label))]})}function MH({axis:e,y:t,left:n,right:r}){return(0,K.jsx)(`g`,{children:e.ticks.map((i,a)=>(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`line`,{className:i===0?uLe:lLe,x1:n,x2:r,y1:t(i),y2:t(i)}),(0,K.jsx)(`text`,{className:kH,textAnchor:`end`,x:n-8,y:t(i)+4,children:e.labels[a]})]},i))})}function NH({labels:e,centers:t,y:n,rotate:r}){let i=-1/0;return(0,K.jsx)(`g`,{children:e.map((e,a)=>{if(r)return(0,K.jsx)(`text`,{className:AH,textAnchor:`end`,transform:`rotate(-38 ${t[a]} ${n-4})`,x:t[a],y:n,children:e},a);let o=vH(e,12)/2;return t[a]-o<i+14?null:(i=t[a]+o,(0,K.jsx)(`text`,{className:AH,textAnchor:`middle`,x:t[a],y:n,children:e},a))})})}function SLe(e,t){let n=(e.currentTarget.ownerSVGElement??e.currentTarget).getBoundingClientRect();return(e.clientX-n.left)*t/n.width}function PH(e,t,n){let r=e.series[t].key,i=e.data[n],a=i[r];return{series:r,x:i[e.x]??null,value:typeof a==`number`?a:null,index:n}}function FH(e,t,n){return{"data-point":`${t.series}:${t.index}`,style:e.onPointClick?{cursor:`pointer`}:void 0,onClick:()=>e.onPointClick?.(t),onPointerEnter:()=>{n?.enter(),e.onPointHover?.(t)},onPointerLeave:()=>{n?.leave(),e.onPointHover?.(null)}}}var IH=24,LH=28,RH=2;function CLe(e){let t=e.series.map(e=>e.key),n=qIe({keys:t,offset:`diverging`})(e.data.map(e=>Object.fromEntries(t.map(t=>[t,SH(e,t)??0]))));return e.data.map((r,i)=>{let a=n.map((n,r)=>({series:r,value:SH(e.data[i],t[r])??0,y0:n[i][0],y1:n[i][1],rounded:!1})),o=a.filter(e=>e.value>0).sort((e,t)=>t.y1-e.y1)[0],s=a.filter(e=>e.value<0).sort((e,t)=>e.y0-t.y0)[0];return o&&(o.rounded=!0),s&&(s.rounded=!0),a})}function wLe({spec:e,layout:t,events:n={}}){let{width:r,height:i,compact:a}=t,[o,s]=(0,G.useState)(null),{axis:c,labels:l,ml:u,mb:d,rotate:f,y:p,band:m,centers:h,segments:g}=(0,G.useMemo)(()=>{let t=e.data.length,n=e.stacked?CLe(e):null,o=0,s=0;for(let[t,r]of e.data.entries())if(n)for(let e of n[t])o=Math.min(o,e.y0,e.y1),s=Math.max(s,e.y0,e.y1);else for(let t of e.series){let e=SH(r,t.key)??0;o=Math.min(o,e),s=Math.max(s,e)}let c=xH(o,s,e.format,a,e.y),l=e.data.map(t=>CH(t,e.x)),u=c.width,d=r-u-8,f=Math.max(...l.map(e=>vH(e,12))),p=f>d/t-8,m=p?Math.min(f,120)*.62+20:28,h=dIe({domain:[...Array.from({length:t}).keys()],range:[u,r-8]}),g=LV({domain:c.domain,range:[i-m,12]}),_=h.bandwidth();return{axis:c,labels:l,ml:u,mb:m,rotate:p,x:h,y:g,band:_,centers:l.map((e,t)=>(h(t)??0)+_/2),segments:n}},[e,r,i,a]),_=e=>p(e)??0,v=_(0),y=e.series.length,b=!g&&y<=2&&(!a||!!e.highlight),x=i-d,S=t=>{let n=(g?[...e.series.keys()].reverse():[...e.series.keys()]).map(n=>({color:wH(e,n),value:gH(SH(e.data[t],e.series[n].key),e.format),label:TH(e,n)}));if(g&&y>1){let r=g[t].reduce((e,t)=>e+t.value,0);n.push({color:`transparent`,value:gH(r,e.format),label:`Total`})}return n},C=(e,t)=>{let n=h[e]>u+(r-u)/2;s({x:t,y:12,title:l[e],rows:S(e),side:n?`left`:`right`,band:e})};return(0,K.jsxs)(`div`,{className:DH,children:[(0,K.jsxs)(`svg`,{"aria-hidden":!0,className:OH,viewBox:`0 0 ${r} ${i}`,children:[o&&(0,K.jsx)(`rect`,{fill:yH.hoverWash,height:x-12,rx:4,width:m-8,x:h[o.band]-m/2+4,y:12}),(0,K.jsx)(MH,{axis:c,left:u,right:r-8,y:_}),e.data.map((t,n)=>{if(g){let t=Math.min(LH,m*.56),r=h[n]-t/2,i=g[n].reduce((e,t)=>e+Math.max(0,t.value),0);return(0,K.jsxs)(`g`,{children:[g[n].map(n=>{if(n.value===0)return null;let i=n.value>0,a=_(i?n.y0:n.y1)+(n.y0===0||n.y1===0?0:i?-1:RH/2),o=_(i?n.y1:n.y0)+(n.rounded?0:i?RH/2:-1);return(0,K.jsx)(`path`,{d:EH(r,t,a,o,n.rounded?4:0),fill:wH(e,n.series)},n.series)}),!a&&i>0&&(0,K.jsx)(`text`,{className:`appgphf`,textAnchor:`middle`,x:h[n],y:_(i)-7,children:gH(i,e.format)})]},n)}let r=Math.min(IH,(m*.72-(y-1)*RH)/y),i=y*r+(y-1)*RH;return(0,K.jsx)(`g`,{children:e.series.map((a,o)=>{let s=SH(t,a.key);if(s==null)return null;let c=h[n]-i/2+o*(r+RH),l=_(s),u=e.highlight===a.key;return(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`path`,{d:EH(c,r,v,l,4),fill:wH(e,o)}),b&&(!e.highlight||u)&&(0,K.jsx)(`text`,{className:u?`appgphg`:`appgphf`,textAnchor:`middle`,x:c+r/2,y:s>=0?l-6:l+14,children:gH(s,e.format)})]},a.key)})},n)}),(0,K.jsx)(NH,{centers:h,labels:l,rotate:f,y:i-d+18}),h.map((e,t)=>(0,K.jsx)(`rect`,{fill:`transparent`,height:x-12,width:m,x:e-m/2,y:12,onPointerEnter:()=>C(t,e+(e>u+(r-u)/2?-m/4:m/4)),onPointerLeave:()=>s(null)},t)),e.data.map((t,i)=>{let a=h[i]+(h[i]>u+(r-u)/2?-m/4:m/4),o={enter:()=>C(i,a),leave:()=>s(null)};if(g){let t=Math.min(LH,m*.56);return g[i].map(r=>r.value===0?null:(0,K.jsx)(`path`,{fill:`transparent`,d:EH(h[i]-t/2,t,_(r.value>0?r.y0:r.y1),_(r.value>0?r.y1:r.y0),0),...FH(n,PH(e,r.series,i),o)},`h-${i}-${r.series}`))}let c=Math.min(IH,(m*.72-(y-1)*RH)/y),l=y*c+(y-1)*RH;return e.series.map((r,a)=>{let s=SH(t,r.key);return s==null?null:(0,K.jsx)(`path`,{d:EH(h[i]-l/2+a*(c+RH),c,v,_(s),4),fill:`transparent`,...FH(n,PH(e,a,i),o)},`h-${i}-${r.key}`)})})]}),o&&(0,K.jsx)(jH,{height:i,state:o,width:r})]})}var TLe=`_3n881z0`,ELe=`_3n881z1`,DLe=`_3n881z2`,OLe=`_3n881z3`,kLe=`_3n881z4`,ALe=`_3n881z6`,jLe=`_3n881z7`,MLe=`_3n881z8`;function NLe({issues:e,title:t,type:n,rows:r}){let i=e.length,a=[`chart`,n,r==null?void 0:`${r} rows`].filter(Boolean).join(` · `);return(0,K.jsxs)(`div`,{className:TLe,role:`alert`,children:[(0,K.jsxs)(`div`,{className:ELe,children:[(0,K.jsxs)(`svg`,{className:DLe,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:1.5,viewBox:`0 0 16 16`,children:[(0,K.jsx)(`circle`,{cx:8,cy:8,r:6.5}),(0,K.jsx)(`path`,{d:`M8 4.8v3.6M8 11h.01`})]}),(0,K.jsx)(`span`,{className:OLe,children:i===1?`Chart data has 1 problem`:`Chart data has ${i} problems`}),(0,K.jsx)(`span`,{className:kLe,children:a})]}),t&&(0,K.jsx)(`div`,{className:`_3n881z5`,children:t}),(0,K.jsx)(`ol`,{className:ALe,children:e.map(e=>(0,K.jsxs)(`li`,{className:jLe,children:[(0,K.jsx)(`code`,{className:MLe,children:e.path}),` `,e.message,e.hint&&(0,K.jsx)(`span`,{className:`_3n881z9`,children:e.hint})]},`${e.path}:${e.message}`))})]})}var zH=16;function PLe({spec:e,layout:t,events:n={}}){let{width:r,height:i,compact:a}=t,[o,s]=(0,G.useState)(null),c=e.type===`area`,l=c&&!!e.stacked,{n:u,layers:d,axis:f,direct:p,ml:m,mb:h,plotW:g,x:_,y:v}=(0,G.useMemo)(()=>{let t=e.data.length,n=e.data.map(()=>0),o=e.series.map(t=>e.data.map((e,r)=>{let i=SH(e,t.key),a=i??0;return{i:r,value:i,lo:l?n[r]:0,hi:l?n[r]+=a:a}})),s=0,c=0;for(let e of o)for(let t of e)t.value!=null&&(s=Math.min(s,t.lo,t.hi),c=Math.max(c,t.hi));for(let t of e.refs??[])c=Math.max(c,t.y);let u=xH(s,c,e.format,a,e.y),d=!a&&e.series.length<=3,f=t-1,p=d?Math.max(...e.series.map((t,n)=>vH(TH(e,n),12)+vH(gH(o[n][f]?.value,e.format),12)))+24:8,m=u.width,h=r-m-p;return{n:t,layers:o,axis:u,direct:d,ml:m,mb:28,plotW:h,x:e=>m+(t===1?h/2:e*h/(t-1)),y:LV({domain:u.domain,range:[i-28,12]})}},[e,r,i,a,l]),y=e=>v(e)??0,b=e.data.map(t=>CH(t,e.x)),x=[...e.series.keys()].sort((t,n)=>Number(e.series[t].key===e.highlight)-Number(e.series[n].key===e.highlight)),S=e=>e.value!=null,C=GIe({x:e=>_(e.i),y:e=>y(e.hi),defined:S}),w=WIe({x:e=>_(e.i),y0:e=>y(e.lo),y1:e=>y(e.hi),defined:S}),T=p?x.map(e=>({j:e,y:y(d[e][u-1].hi)})).filter(({j:e})=>d[e][u-1].value!=null).sort((e,t)=>e.y-t.y):[];for(let e=1;e<T.length;e++)T[e].y-T[e-1].y<zH&&(T[e].y=T[e-1].y+zH);let E=null;if(o!=null){let t=(l?[...e.series.keys()].reverse():[...e.series.keys()].sort((e,t)=>(d[t][o].value??-1/0)-(d[e][o].value??-1/0))).map(t=>({color:wH(e,t),value:gH(d[t][o].value,e.format),label:TH(e,t)}));l&&e.series.length>1&&t.push({color:`transparent`,value:gH(d.at(-1)[o].hi,e.format),label:`Total`}),E={x:_(o),y:12,title:b[o],rows:t,side:_(o)>m+g/2?`left`:`right`}}return(0,K.jsxs)(`div`,{className:DH,children:[(0,K.jsxs)(`svg`,{"aria-hidden":!0,className:OH,viewBox:`0 0 ${r} ${i}`,children:[(0,K.jsx)(MH,{axis:f,left:m,right:m+g,y}),e.refs?.map(t=>(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`line`,{shapeRendering:`crispEdges`,stroke:yH.reference,strokeDasharray:`4 3`,x1:m,x2:m+g,y1:y(t.y),y2:y(t.y)}),(0,K.jsx)(`text`,{className:kH,x:m+4,y:y(t.y)-6,children:`${t.label} ${gH(t.y,e.format)}`})]},`${t.label}-${t.y}`)),c&&(l?[...x].reverse():x).map(t=>(0,K.jsx)(`path`,{d:w(d[t])??``,fill:wH(e,t),style:{fillOpacity:l?yH.areaOpacity:.1}},`a-${t}`)),x.map(t=>(0,K.jsxs)(`g`,{children:[l&&t>0&&(0,K.jsx)(`path`,{d:C(d[t])??``,fill:`none`,stroke:Ht.color.bg,strokeWidth:4}),(0,K.jsx)(`path`,{d:C(d[t])??``,fill:`none`,stroke:wH(e,t),strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2})]},`l-${t}`)),T.map(({j:t,y:n})=>{let r=!!e.highlight&&e.series[t].key!==e.highlight;return(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`circle`,{cx:_(u-1),cy:y(d[t][u-1].hi),fill:wH(e,t),r:4,stroke:Ht.color.bg,strokeWidth:2}),(0,K.jsxs)(`text`,{className:cLe,x:_(u-1)+10,y:n+4,children:[(0,K.jsx)(`tspan`,{fill:r?Ht.color.textTertiary:Ht.color.text,fontWeight:r?400:600,children:gH(d[t][u-1].value,e.format)}),(0,K.jsx)(`tspan`,{dx:5,fill:Ht.color.textTertiary,children:TH(e,t)})]})]},`e-${t}`)}),(0,K.jsx)(NH,{centers:b.map((e,t)=>_(t)),labels:b,rotate:!1,y:i-h+18}),o!=null&&(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`line`,{shapeRendering:`crispEdges`,stroke:yH.crosshair,x1:_(o),x2:_(o),y1:12,y2:i-h}),e.series.map((t,n)=>d[n][o].value==null?null:(0,K.jsx)(`circle`,{cx:_(o),cy:y(d[n][o].hi),fill:wH(e,n),r:4,stroke:Ht.color.bg,strokeWidth:2},t.key))]}),(0,K.jsx)(`rect`,{fill:`transparent`,height:i-h-12,width:g,x:m,y:12,onPointerLeave:()=>s(null),onPointerMove:e=>{let t=SLe(e,r),n=u===1?0:Math.round((t-m)/g*(u-1));s(Math.max(0,Math.min(u-1,n)))}}),d.map((t,r)=>t.map(t=>t.value==null?null:(0,K.jsx)(`circle`,{cx:_(t.i),cy:y(t.hi),fill:`transparent`,r:7,...FH(n,PH(e,r,t.i),{enter:()=>s(t.i),leave:()=>s(null)})},`h-${r}-${t.i}`)))]}),E&&(0,K.jsx)(jH,{height:i,state:E,width:r})]})}var BH=28;function VH(e,t){return t.compact?216+e.data.length*BH:260}function FLe({spec:e,layout:t,events:n={}}){let{width:r,compact:i}=t,a=VH(e,t),[o,s]=(0,G.useState)(null),c=e.series[0].key,l=e.data.map((t,n)=>({i:n,label:CH(t,e.x),value:Math.max(0,SH(t,c)??0)})),u=l.reduce((e,t)=>e+t.value,0),d=i?96:a/2-10,f=i?r/2:d+10,p=i?d+4:a/2,m=e.donut?d*.62:0,h=KIe({value:e=>e.value,sort:null,sortValues:null})(l),g=UIe({innerRadius:m,outerRadius:d}),_=t=>e.highlight&&e.highlight!==l[t].label?yH.muted:bH[t%bH.length],v=e=>u?`${Math.round(e/u*100)}%`:`—`,y=Math.max(...l.map(e=>vH(e.label,13))),b=i?8:f+d+56,x=i?r-52:b+18+y+80,S=i?r-4:x+44,C=i?p+d+30:p-l.length*BH/2+BH/2,w=o==null?u:l[o].value,T=o==null?`Total`:`${l[o].label} · ${v(l[o].value)}`;return(0,K.jsx)(`div`,{className:DH,children:(0,K.jsxs)(`svg`,{"aria-hidden":!0,className:OH,viewBox:`0 0 ${r} ${a}`,children:[(0,K.jsxs)(`g`,{transform:`translate(${f} ${p})`,children:[h.map(t=>(0,K.jsx)(`path`,{d:g(t)??``,fill:_(t.index),stroke:Ht.color.bg,strokeLinejoin:`round`,strokeWidth:2,...FH(n,PH(e,0,t.index),{enter:()=>s(t.index),leave:()=>s(null)}),style:{opacity:o==null||o===t.index?1:.3,...n.onPointClick?{cursor:`pointer`}:{}}},t.index)),m>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`text`,{fill:Ht.color.text,fontSize:22,fontWeight:600,textAnchor:`middle`,y:2,children:gH(w,e.format)}),(0,K.jsx)(`text`,{className:`appgphd`,textAnchor:`middle`,y:22,children:T})]})]}),l.map((t,n)=>{let r=C+n*BH;return(0,K.jsxs)(`g`,{style:{opacity:o==null||o===n?1:.4},onPointerEnter:()=>s(n),onPointerLeave:()=>s(null),children:[(0,K.jsx)(`rect`,{fill:`transparent`,height:BH,width:S-b,x:b,y:r-BH/2}),(0,K.jsx)(`rect`,{fill:_(n),height:10,rx:2,width:10,x:b,y:r-5}),(0,K.jsx)(`text`,{fill:Ht.color.textSecondary,fontSize:13,x:b+18,y:r+4,children:t.label}),(0,K.jsx)(`text`,{fill:Ht.color.text,fontSize:13,fontWeight:600,textAnchor:`end`,x,y:r+4,children:gH(t.value,e.format)}),(0,K.jsx)(`text`,{className:kH,textAnchor:`end`,x:S,y:r+4,children:v(t.value)})]},n)})]})})}function ILe({spec:e,layout:t,events:n={}}){let{width:r,height:i,compact:a}=t,[o,s]=(0,G.useState)(null),{axis:c,ml:l,mb:u,x:d,y:f,ticks:p}=(0,G.useMemo)(()=>{let t=e.data.map(t=>SH(t,e.x)).filter(e=>e!=null),n=0,o=0;for(let t of e.data)for(let r of e.series){let e=SH(t,r.key);e!=null&&(n=Math.min(n,e),o=Math.max(o,e))}let s=xH(n,o,e.format,a,e.y),c=s.width,l=Math.min(...t,0),u=LV({domain:[l,Math.max(...t,l+1)],range:[c+8,r-8-8],nice:a?3:5});return{axis:s,ml:c,mb:28,x:u,y:LV({domain:s.domain,range:[i-28,12]}),ticks:u.ticks(a?3:5)}},[e,r,i,a]),m=e=>f(e)??0,h=e=>d(e)??0,g=null;if(o){let t=e.data[o.i],n=SH(t,e.x)??0;g={x:h(n),y:m(SH(t,e.series[o.j].key)??0),title:`${e.xLabel||e.x} ${gH(n,{...e.format,unit:void 0})}`,rows:[{color:wH(e,o.j),label:TH(e,o.j),value:gH(SH(t,e.series[o.j].key),e.format)}],side:h(n)>l+(r-l)/2?`left`:`right`}}return(0,K.jsxs)(`div`,{className:DH,children:[(0,K.jsxs)(`svg`,{"aria-hidden":!0,className:OH,viewBox:`0 0 ${r} ${i}`,children:[(0,K.jsx)(MH,{axis:c,left:l,right:r-8,y:m}),(0,K.jsx)(NH,{centers:p.map(h),labels:p.map((e,t)=>_H(e,void 0,t===p.length-1)),rotate:!1,y:i-u+18}),e.series.map((t,r)=>e.data.map((i,a)=>{let c=SH(i,e.x),l=SH(i,t.key);if(c==null||l==null)return null;let u=o?.i===a&&o.j===r;return(0,K.jsx)(`circle`,{cx:h(c),cy:m(l),fill:wH(e,r),fillOpacity:u?1:.75,r:u?6:4.5,stroke:Ht.color.bg,strokeWidth:1.5,...FH(n,PH(e,r,a),{enter:()=>s({i:a,j:r}),leave:()=>s(null)})},`${t.key}-${a}`)}))]}),g&&(0,K.jsx)(jH,{height:i,state:g,width:r})]})}var HH=[`bar`,`line`,`area`,`pie`,`scatter`],UH=e=>typeof e==`object`&&!!e&&!Array.isArray(e),WH=e=>typeof e==`string`?`"${e}"`:JSON.stringify(e);function GH(e){let t;try{t=JSON.parse(e)}catch(e){return{ok:!1,issues:[{path:`(root)`,message:`is not valid JSON: ${e.message}`,hint:`The <chart> body must be one JSON object inside CDATA`}]}}return KH(t)}function KH(e){let t=[];if(!UH(e))return{ok:!1,issues:[{path:`(root)`,message:`must be an object`}]};let{type:n,x:r,series:i,data:a}=e;if(HH.includes(n)||t.push({path:`type`,message:`is ${WH(n)}, which is not supported`,hint:`Use one of: ${HH.join(`, `)}`}),typeof r==`string`&&r||t.push({path:`x`,message:`must name the field used for categories`}),Array.isArray(i)&&i.length!==0||t.push({path:`series`,message:`must be a non-empty array of { key, label? }`}),Array.isArray(a)||t.push({path:`data`,message:`must be an array of rows`}),t.some(e=>e.path!==`type`))return{ok:!1,issues:t};let o=a,s=i,c=new Set;o.forEach((e,n)=>{if(!UH(e))t.push({path:`data[${n}]`,message:`must be an object`});else for(let t of Object.keys(e))c.add(t)}),s.length>6&&t.push({path:`series`,message:`has ${s.length} entries; at most 6 are allowed`,hint:`Merge the smallest series into one named "Other", or split into several charts`}),n===`pie`&&o.length>6&&t.push({path:`data`,message:`has ${o.length} slices; a pie allows at most 6`,hint:`Merge the smallest slices into one row named "Other"`});let l=[...c].map(e=>`"${e}"`).join(`, `)||`(none)`;o.length>0&&!c.has(r)&&t.push({path:`x`,message:`is ${WH(r)}, but no row has that field`,hint:`Fields present in data: ${l}`});let u=[];if(s.forEach((e,n)=>{!UH(e)||typeof e.key!=`string`||!e.key?t.push({path:`series[${n}]`,message:`must be { key: string, label?: string }`}):(u.push(e.key),o.length>0&&!c.has(e.key)&&t.push({path:`series[${n}].key`,message:`is ${WH(e.key)}, but no row has that field`,hint:`Fields present in data: ${l}`}))}),o.forEach((e,n)=>{if(UH(e))for(let r of u){let i=e[r];i!=null&&(typeof i==`number`&&Number.isFinite(i)||t.push({path:`data[${n}].${r}`,message:`must be a number, got ${WH(i)}`,hint:typeof i==`string`&&/\d/.test(i)?`Write the bare number and put the unit in format.unit`:void 0}))}}),n===`scatter`&&o.forEach((e,n)=>{if(!UH(e))return;let i=e[r];i!=null&&(typeof i==`number`&&Number.isFinite(i)||t.push({path:`data[${n}].${r}`,message:`must be a number on a scatter x axis, got ${WH(i)}`}))}),n===`pie`){let e=u[0];o.forEach((n,r)=>{UH(n)&&typeof n[e]==`number`&&n[e]<0&&t.push({path:`data[${r}].${e}`,message:`is negative; pie slices must be ≥ 0`})})}return e.highlight!==void 0&&typeof e.highlight!=`string`?t.push({path:`highlight`,message:`must be a string`}):typeof e.highlight==`string`&&n!==`pie`&&!u.includes(e.highlight)&&t.push({path:`highlight`,message:`is ${WH(e.highlight)}, which is not a series key`,hint:`Series keys: ${u.map(e=>`"${e}"`).join(`, `)}`}),t.length>0?{ok:!1,issues:t}:{ok:!0,spec:{...e,version:1}}}function qH({spec:e,layout:t,events:n}){return e.type===`bar`?(0,K.jsx)(wLe,{events:n,layout:t,spec:e}):e.type===`scatter`?(0,K.jsx)(ILe,{events:n,layout:t,spec:e}):e.type===`pie`?(0,K.jsx)(FLe,{events:n,layout:{...t,height:VH(e,t)},spec:e}):(0,K.jsx)(PLe,{events:n,layout:t,spec:e})}function JH({spec:e,compact:t}){if(e.type===`pie`||e.series.length<2||!(e.type===`bar`||e.type===`scatter`||e.stacked||t||e.series.length>3))return null;let n=e.type===`line`;return(0,K.jsx)(`div`,{className:nLe,children:e.series.map((t,r)=>(0,K.jsxs)(`span`,{className:rLe,children:[(0,K.jsx)(`i`,{className:n?aLe:iLe,style:{background:wH(e,r)}}),TH(e,r)]},t.key))})}function LLe({spec:e}){let t={...e.format,compact:!1};return(0,K.jsxs)(`table`,{className:gLe,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{scope:`col`,children:e.xLabel||e.x}),e.series.map((t,n)=>(0,K.jsx)(`th`,{scope:`col`,children:TH(e,n)},t.key))]})}),(0,K.jsx)(`tbody`,{children:e.data.map((n,r)=>(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`td`,{children:CH(n,e.x)}),e.series.map(e=>(0,K.jsx)(`td`,{children:gH(SH(n,e.key),t)},e.key))]},r))})]})}var RLe=(0,K.jsxs)(`svg`,{fill:`none`,height:14,stroke:`currentColor`,strokeWidth:1.4,viewBox:`0 0 16 16`,width:14,children:[(0,K.jsx)(`rect`,{height:10,rx:1.5,width:12,x:2,y:3}),(0,K.jsx)(`path`,{d:`M2 6.5h12M6.5 6.5V13`})]}),zLe=(0,K.jsx)(`svg`,{fill:`none`,height:14,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:1.4,viewBox:`0 0 16 16`,width:14,children:(0,K.jsx)(`path`,{d:`M3 13V8M6.5 13V4M10 13V9.5M13.5 13V6`})});function BLe({spec:e,defaultView:t=`chart`,hideToggle:n,onPointClick:r,onPointHover:i}){let a={onPointClick:r,onPointHover:i},[o,s]=(0,G.useState)(t),c=e.data.length===0,l=o===`table`&&!c;return(0,K.jsxs)(`figure`,{className:eLe,children:[(0,K.jsxs)(`div`,{className:tLe,children:[(0,K.jsxs)(`div`,{children:[e.title&&(0,K.jsx)(`div`,{className:`appgph2`,children:e.title}),e.subtitle&&(0,K.jsx)(`div`,{className:`appgph3`,children:e.subtitle})]}),!n&&!c&&(0,K.jsxs)(`button`,{"aria-pressed":l,className:`appgph4`,type:`button`,onClick:()=>s(l?`chart`:`table`),children:[l?zLe:RLe,l?`View chart`:`View data`]})]}),c?(0,K.jsxs)(`div`,{className:_Le,children:[(0,K.jsx)(`div`,{className:vLe,children:[0,1,2,3].map(e=>(0,K.jsx)(`div`,{className:yLe},e))}),(0,K.jsxs)(`div`,{className:bLe,children:[`No data yet`,(0,K.jsx)(`code`,{className:xLe,children:`data: []`})]})]}):l?(0,K.jsx)(LLe,{spec:e}):(0,K.jsxs)(`div`,{"aria-label":$Ie(e),role:`img`,children:[(0,K.jsxs)(`div`,{className:oLe,children:[(0,K.jsx)(JH,{compact:!1,spec:e}),(0,K.jsx)(qH,{events:a,layout:ZIe,spec:e})]}),(0,K.jsxs)(`div`,{className:sLe,children:[(0,K.jsx)(JH,{compact:!0,spec:e}),(0,K.jsx)(qH,{events:a,layout:QIe,spec:e})]})]}),(e.note||e.source)&&(0,K.jsxs)(`figcaption`,{className:`appgphq`,children:[e.note,e.note&&e.source&&` · `,e.source&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`appgphr`,children:`Source `}),e.source]})]})]})}function VLe(e){let t=e;if(typeof t==`string`)try{t=JSON.parse(t)}catch{return{}}return typeof t==`object`&&t?t:{}}function YH({value:e,...t}){let n=(0,G.useMemo)(()=>typeof e==`string`?GH(e):KH(e),[e]);if(!n.ok){let t=VLe(e);return(0,K.jsx)(NLe,{issues:n.issues,rows:Array.isArray(t.data)?t.data.length:void 0,title:typeof t.title==`string`?t.title:void 0,type:typeof t.type==`string`?t.type:void 0})}return(0,K.jsx)(BLe,{spec:n.spec,...t})}function XH({spec:e}){return(0,K.jsx)(YH,{value:e})}var ZH=`Chart`;function QH(e){"@babel/helpers - typeof";return QH=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},QH(e)}function HLe(e,t){if(QH(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(QH(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ULe(e){var t=HLe(e,`string`);return QH(t)==`symbol`?t:t+``}function $H(e,t,n){return(t=ULe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eU(e){return typeof e==`string`?e:e==null?``:JSON.stringify(e)}var tU=class e extends wr{static getType(){return`chart`}static clone(t){return new e(t.__spec,t.__key)}constructor(e=``,t){super(t),$H(this,`__spec`,void 0),this.__spec=e}createDOM(e){let t=document.createElement(`div`);return t.className=`rich-chart-wrapper`,t}updateDOM(){return!1}isInline(){return!1}static importJSON(e){return WLe(eU(e.spec)).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`chart`,spec:this.__spec,version:1}}getSpec(){return this.getLatest().__spec}setSpec(e){let t=this.getWritable();t.__spec=e}decorate(e,t){return qj(ZH,XH,{spec:this.__spec})}};function WLe(e=``){return new tU(e)}function GLe(e){return e instanceof tU}var nU={root:`rich-steps`,item:`rich-steps-item`,marker:`rich-steps-marker`,title:`rich-steps-title`,content:`rich-steps-content`},rU=`_1m3xa5x0`,iU=`_1m3xa5x1`,aU=`_1m3xa5x2`,KLe=({steps:e})=>{let t=_N(),n=Gj();return e.length===0?null:(0,K.jsx)(`ol`,{className:`${rU} ${nU.root}`,children:e.map((e,r)=>(0,K.jsxs)(`li`,{className:`${iU} ${nU.item}`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`${aU} ${nU.marker}`,children:r+1}),e.title&&(0,K.jsx)(`div`,{className:`_1m3xa5x3 ${nU.title}`,children:e.title}),t&&(0,K.jsx)(`div`,{className:`_1m3xa5x4 ${nU.content}`,children:t(e.content,n)})]},e.id))})},oU=null,sU=null;function qLe(){return oU?Promise.resolve(oU):(sU||=r(()=>import(`./katex-DuZJ-tFh.js`).then(e=>e.n).then(e=>(oU=e,oU)),__vite__mapDeps([28,1]),import.meta.url),sU)}function cU({equation:e,displayMode:t}){let[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)(null);return(0,G.useEffect)(()=>{let n=!1;return qLe().then(i=>{if(n)return;let o=i.default.renderToString(e,{displayMode:t,throwOnError:!1});r(o),a(null)}).catch(()=>{n||(r(null),a(`KaTeX is not available`))}),()=>{n=!0}},[e,t]),i?(0,K.jsx)(`code`,{className:Fj(oR.fallback,sR.fallback),children:e}):n?(0,K.jsx)(`span`,{dangerouslySetInnerHTML:{__html:n},className:t?Fj(oR.block,sR.block):Fj(oR.inline,sR.inline)}):(0,K.jsx)(`code`,{className:Fj(oR.fallback,sR.fallback),children:e})}var JLe=qe(`abcdefghijklmnopqrstuvwxyz0123456789`,8);function lU(){return`s_${JLe()}`}function uU(){return{root:{children:[{type:`paragraph`,children:[],direction:null,format:``,indent:0,textFormat:0,textStyle:``,version:1}],direction:null,format:``,indent:0,type:`root`,version:1}}}function dU(e=``){return{id:lU(),title:e,content:uU()}}function fU(e){return Array.isArray(e)?e.map(e=>{let t=e&&typeof e==`object`?e:{};return{...t,id:typeof t.id==`string`&&t.id?t.id:lU(),title:typeof t.title==`string`?t.title:``,content:t.content?.root?t.content:uU()}}):[]}var YLe=`Steps`;function pU(e){"@babel/helpers - typeof";return pU=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},pU(e)}function XLe(e,t){if(pU(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(pU(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ZLe(e){var t=XLe(e,`string`);return pU(t)==`symbol`?t:t+``}function mU(e,t,n){return(t=ZLe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var hU=class e extends wr{static getType(){return`steps`}static clone(t){return new e(t.__steps,t.__key)}constructor(e,t){super(t),mU(this,`__steps`,void 0),this.__steps=e??[dU()]}createDOM(e){let t=document.createElement(`div`);return t.className=`rich-steps-block`,t}updateDOM(){return!1}isInline(){return!1}getSteps(){return this.getLatest().__steps}setSteps(e){let t=this.getWritable();t.__steps=e}getTextContent(){return this.__steps.map(e=>[e.title,bN(e.content)].filter(Boolean).join(`
|
|
194
194
|
`)).join(`
|
|
195
195
|
`)}static importJSON(t){return new e(fU(t.steps)).updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),type:`steps`,steps:this.__steps,version:1}}decorate(e,t){return qj(YLe,KLe,{steps:this.__steps})}},gU={titleRow:`rich-steps-edit-title-row`,titleInput:`rich-steps-edit-title-input`,actions:`rich-steps-edit-actions`,action:`rich-steps-edit-action`,editable:`rich-steps-edit-content`},QLe=`_4rdxj50`,$Le=`_4rdxj51`,eRe=`_4rdxj52`,_U=`_4rdxj53`,vU=[`keydown`,`keyup`,`beforeinput`,`input`,`compositionstart`,`compositionend`,`paste`,`cut`,`copy`];function tRe({value:e,autoFocus:t,onValueChange:n,onEnter:r}){let[i,a]=(0,G.useState)(e),o=(0,G.useRef)(!1),s=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let e=s.current;if(e){for(let t of vU)e.addEventListener(t,Ie);return()=>{for(let t of vU)e.removeEventListener(t,Ie)}}},[]),(0,G.useEffect)(()=>{o.current||a(e)},[e]),(0,K.jsx)(`input`,{"aria-label":`Step title`,autoFocus:t,className:`${$Le} ${gU.titleInput}`,placeholder:`Step title`,ref:s,value:i,onChange:e=>{a(e.target.value),o.current||n(e.target.value)},onCompositionEnd:e=>{o.current=!1,n(e.currentTarget.value)},onCompositionStart:()=>{o.current=!0},onKeyDown:e=>{let t=o.current||e.nativeEvent.isComposing||e.keyCode===229;e.key===`Enter`&&!t&&(e.preventDefault(),r())}})}function nRe({nodeKey:e,steps:t,stepEditors:n}){let[r]=ht(),[i,a]=(0,G.useState)(null);pF(n,e);let o=(0,G.useCallback)(t=>{r.update(()=>{let n=Dn(e);xU(n)&&t(n)})},[r,e]),s=(0,G.useCallback)(t=>{let n=null;r.update(()=>{let r=Dn(e);xU(r)&&(n=r.addStepAfter(t).id)},{discrete:!0}),a(n)},[r,e]);return(0,K.jsx)(`ol`,{className:`${rU} ${nU.root}`,children:t.map((e,r)=>{let a=n[r];return(0,K.jsxs)(`li`,{className:`${iU} ${nU.item}`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`${aU} ${nU.marker}`,children:r+1}),(0,K.jsxs)(`div`,{className:`${QLe} ${gU.titleRow}`,children:[(0,K.jsx)(tRe,{autoFocus:i===e.id,value:e.title,onEnter:()=>a?.focus(),onValueChange:t=>o(n=>n.setStepTitle(e.id,t))}),(0,K.jsxs)(`div`,{className:`${eRe} ${gU.actions}`,onMouseDown:e=>e.preventDefault(),children:[(0,K.jsx)(`button`,{"aria-label":`Move step up`,className:_U,disabled:r===0,type:`button`,onClick:()=>o(t=>t.moveStep(e.id,-1)),children:(0,K.jsx)(Nte,{size:14})}),(0,K.jsx)(`button`,{"aria-label":`Move step down`,className:_U,disabled:r===t.length-1,type:`button`,onClick:()=>o(t=>t.moveStep(e.id,1)),children:(0,K.jsx)(Mte,{size:14})}),(0,K.jsx)(`button`,{"aria-label":`Add step below`,className:_U,type:`button`,onClick:()=>s(e.id),children:(0,K.jsx)(zr,{size:14})}),(0,K.jsx)(`button`,{"aria-label":`Delete step`,className:_U,type:`button`,onClick:()=>o(t=>t.removeStep(e.id)),children:(0,K.jsx)(Mr,{size:14})})]})]}),a&&(0,K.jsx)(`div`,{className:`_1m3xa5x4 ${nU.content}`,children:(0,K.jsxs)(pA,{initialEditor:a,children:[(0,K.jsx)(Yt,{ErrorBoundary:Nt,contentEditable:(0,K.jsx)(Ee,{"aria-placeholder":``,className:`_4rdxj54 ${gU.editable}`,placeholder:(0,K.jsx)(`span`,{style:{display:`none`}})})}),(0,K.jsx)(fF,{})]})})]},e.id)})})}function yU(e){let t=mF(`StepContent`);return t.setEditorState(t.parseEditorState(e.content)),t}var bU=class e extends hU{static clone(t){return new e(t.__steps,t.__key,t.__stepEditors)}constructor(e,t,n){super(e?.length?e:void 0,t),mU(this,`__stepEditors`,void 0),this.__stepEditors=n??this.__steps.map(yU)}getStepEditors(){return this.getLatest().__stepEditors}setSteps(e){let t=this.getWritable(),n=e.length?e:[dU()],r=new Map(t.__steps.map((e,n)=>[e.id,t.__stepEditors[n]]));t.__steps=n,t.__stepEditors=n.map(e=>r.get(e.id)??yU(e))}setStepTitle(e,t){let n=this.getWritable();n.__steps=n.__steps.map(n=>n.id===e?{...n,title:t}:n)}addStepAfter(e){let t=this.getWritable(),n=t.__steps.findIndex(t=>t.id===e),r=n===-1?t.__steps.length:n+1,i=dU();return t.__steps=[...t.__steps.slice(0,r),i,...t.__steps.slice(r)],t.__stepEditors=[...t.__stepEditors.slice(0,r),yU(i),...t.__stepEditors.slice(r)],i}removeStep(e){let t=this.getWritable(),n=t.__steps.findIndex(t=>t.id===e);if(n!==-1){if(t.__steps.length===1){let e=dU();t.__steps=[e],t.__stepEditors=[yU(e)]}else t.__steps=t.__steps.filter((e,t)=>t!==n),t.__stepEditors=t.__stepEditors.filter((e,t)=>t!==n)}}moveStep(e,t){let n=this.getLatest().__steps.findIndex(t=>t.id===e),r=n+t;if(n===-1||r<0||r>=this.getLatest().__steps.length)return;let i=this.getWritable(),a=[...i.__steps],o=[...i.__stepEditors];[a[n],a[r]]=[a[r],a[n]],[o[n],o[r]]=[o[r],o[n]],i.__steps=a,i.__stepEditors=o}static importJSON(t){return new e(fU(t.steps)).updateFromJSON(t)}exportJSON(){let e=this.__stepEditors;return{...super.exportJSON(),steps:this.__steps.map((t,n)=>({...t,content:e[n]?.getEditorState().toJSON()??t.content}))}}decorate(e,t){return(0,G.createElement)(nRe,{nodeKey:this.__key,steps:this.__steps,stepEditors:this.__stepEditors})}};mU(bU,`commandItems`,[{title:`Steps`,icon:(0,G.createElement)(bee,{size:20}),description:`Numbered steps with a title and content each`,keywords:[`steps`,`step`,`tutorial`,`guide`,`howto`],nested:!1,section:`LAYOUT`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([rRe()])})}}]);function rRe(e){return new bU(e)}function xU(e){return e instanceof bU}var iRe=[bU],SU=Object.defineProperty,CU=(e,t)=>{let n={};for(var r in e)SU(n,r,{get:e[r],enumerable:!0});return t||SU(n,Symbol.toStringTag,{value:`Module`}),n},aRe=`Whiteboard`,oRe=`_1xd3mo40`,wU=`_1xd3mo41`,sRe=`_1xd3mo42`,cRe=`_1xd3mo43`,lRe=`_1xd3mo44`,uRe=`_1xd3mo46`,dRe=`_1xd3mo47`,fRe=`_1xd3mo48`,pRe=`_1xd3mo49`,mRe=`_1xd3mo4b`,hRe=`_1xd3mo4h`,gRe=`_1xd3mo4i`,_Re=`_1xd3mo4j`,vRe=`_1xd3mo4l`,yRe=`_1xd3mo4q`,bRe=`_1xd3mo4r`,xRe=/^(?:\.{1,2}\/)?[\w-][\w./-]*\.excalidraw$/;function TU(e){return xRe.test(e)}function EU(e){if(!e||!e.trim())return null;try{let t=JSON.parse(e);if(t&&typeof t==`object`)return{type:`inline`,data:t}}catch{}let t=e.split(`
|
|
196
196
|
`),n=t[0].trim();if(!n.startsWith(`http`)&&!n.startsWith(`blob:`)&&!n.startsWith(`ref:`)&&!TU(n))return null;let r=t.slice(1).join(`
|
|
197
197
|
`).trim();if(r)try{let e=JSON.parse(r);if(e&&typeof e==`object`)return{type:`delta`,baseUrl:n,delta:e}}catch{}return{type:`remote`,url:n}}function SRe(e){switch(e.type){case`inline`:return JSON.stringify(e.data);case`remote`:return e.url;case`delta`:return[e.baseUrl,JSON.stringify(e.delta)].join(`
|
|
198
|
-
`)}}var DU=(0,G.createContext)({});function CRe({apiUrl:e,fontCssHref:t,saveSnapshot:n,uploadFile:r,children:i}){let a=(0,G.useMemo)(()=>({apiUrl:e,fontCssHref:t,saveSnapshot:n,uploadFile:r}),[e,t,n,r]);return(0,K.jsx)(DU.Provider,{value:a,children:i})}function OU(){return(0,G.use)(DU)}function kU(e){return!e||typeof e!=`object`?null:!Array.isArray(e.elements)&&e.data!==void 0?kU(e.data):{type:`excalidraw`,elements:Array.isArray(e.elements)?e.elements:[],appState:e.appState??{},files:e.files??{}}}function AU(e){return e.elements.filter(e=>!e.isDeleted).length}function jU(e,t){let n=e;return e.startsWith(`http`)||e.startsWith(`blob:`)||TU(e)?{fetchUrl:e,refLine:n}:e.startsWith(`ref:`)&&t?{fetchUrl:`${t}/objects/${e.slice(4)}`,refLine:n}:{error:e.startsWith(`ref:`)?`Missing apiUrl for ref resolution`:`Unrecognized snapshot format`}}function MU(e,t){switch(e.type){case`inline`:return{type:`inline`,snapshot:e.data};case`remote`:{let n=jU(e.url,t);return`error`in n?{type:`error`,error:n.error}:{type:`remote`,fetchUrl:n.fetchUrl,refLine:n.refLine}}case`delta`:{let n=jU(e.baseUrl,t);return`error`in n?{type:`error`,error:n.error}:{type:`incremental`,fetchUrl:n.fetchUrl,refLine:n.refLine,delta:e.delta}}}}function wRe(e,t){if(!e.trim())return{type:`empty`};let n=EU(e);return n?MU(n,t):{type:`error`,error:`Unrecognized snapshot format`}}function NU(e){let{apiUrl:t}=OU(),n=(0,G.useMemo)(()=>e==null?{type:`empty`}:typeof e==`string`?wRe(e,t):MU(e,t),[e,t]),[i,a]=(0,G.useState)(),[o,s]=(0,G.useState)(),[c,l]=(0,G.useState)(n.type===`remote`||n.type===`incremental`),[u,d]=(0,G.useState)(``),[f,p]=(0,G.useState)(0),m=(0,G.useCallback)(()=>p(e=>e+1),[]);return(0,G.useEffect)(()=>{if(n.type!==`remote`&&n.type!==`incremental`)return;let{fetchUrl:e}=n,t=n.type===`incremental`?n.delta:void 0,i=!1;return l(!0),d(``),fetch(e).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(async e=>{if(!i){if(s(e),(t?Object.keys(t):[]).length>0){let{patch:n}=await r(async()=>{let{patch:e}=await import(`./lib-DJrc3aG3.js`);return{patch:e}},[],import.meta.url);if(i)return;let o=n(structuredClone(e),t);a(o)}else a(e);l(!1)}}).catch(e=>{i||(d(e instanceof Error?e.message:`Failed to load`),l(!1))}),()=>{i=!0}},[n,f]),n.type===`inline`?{snapshot:n.snapshot,loading:!1,error:``,retry:m,retryable:!1}:n.type===`remote`||n.type===`incremental`?{snapshot:i,loading:c,error:u,retry:m,retryable:!!u,baseRef:n.refLine,baseData:o}:n.type===`error`?{snapshot:void 0,loading:!1,error:n.error,retry:m,retryable:!1}:{snapshot:void 0,loading:!1,error:``,retry:m,retryable:!1}}var TRe=`https://cdn.jsdelivr.net/npm/lxgw-wenkai-screen-webfont/style.css`;function PU(){let{fontCssHref:e=TRe}=OU();(0,G.useEffect)(()=>{if(!e||typeof document>`u`||document.head.querySelector(`link[href="${CSS.escape(e)}"]`))return;let t=document.createElement(`link`);t.rel=`stylesheet`,t.href=e,document.head.append(t)},[e])}var ERe=({elementCount:e})=>{let t=e?`Whiteboard · ${e} elements`:`Whiteboard`;return(0,K.jsxs)(`div`,{"aria-label":t,className:cRe,children:[(0,K.jsx)(Fr,{"aria-hidden":!0,className:lRe}),(0,K.jsx)(`span`,{children:t})]})},FU=()=>(0,K.jsx)(`div`,{"aria-busy":!0,className:uRe,children:(0,K.jsx)(`span`,{children:`Loading whiteboard…`})}),IU=()=>(0,K.jsx)(`div`,{className:dRe,children:(0,K.jsx)(`span`,{children:`Empty whiteboard`})}),LU=({message:e,onRetry:t})=>(0,K.jsxs)(`div`,{className:fRe,role:`alert`,children:[(0,K.jsx)(v,{"aria-hidden":!0,className:pRe}),(0,K.jsx)(`span`,{children:e}),t&&(0,K.jsx)(`button`,{className:`_1xd3mo4a`,type:`button`,onClick:t,children:`Retry`})]}),DRe=CU({WhiteboardDisplayRenderer:()=>RU}),RU=({onExpand:e,snapshot:t})=>{let n=lF(),{snapshot:r,loading:i,error:a,retry:o,retryable:s}=NU(t),c=(0,G.useMemo)(()=>kU(r),[r]);PU();let l=(0,G.useCallback)(t=>{e&&c&&e({content:(0,K.jsx)(bn,{mode:`fullscreen`,scene:c,theme:n}),elementCount:AU(c),target:t,theme:n})},[e,c,n]),u;return u=i?(0,K.jsx)(FU,{}):a?(0,K.jsx)(LU,{message:a,onRetry:s?o:void 0}):r?c?AU(c)===0?(0,K.jsx)(IU,{}):(0,K.jsx)(ORe,{fallback:(0,K.jsx)(LU,{message:`Failed to render whiteboard`}),children:(0,K.jsx)(bn,{scene:c,theme:n,onExpand:e?l:void 0})}):(0,K.jsx)(LU,{message:`Invalid whiteboard data`}):(0,K.jsx)(IU,{}),(0,K.jsx)(`div`,{className:oRe,"data-theme":n,children:u})},ORe=class extends G.Component{constructor(...e){super(...e),Cr(this,`state`,{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}},kRe=(0,G.lazy)(()=>Promise.resolve().then(()=>DRe).then(e=>({default:e.WhiteboardDisplayRenderer})));function ARe(e){try{let t=JSON.parse(e);if(t&&typeof t==`object`&&Array.isArray(t.elements))return t.elements.filter(e=>!e?.isDeleted).length}catch{}}var zU=({snapshot:e})=>(0,K.jsx)(`div`,{className:sRe,children:(0,K.jsx)(ERe,{elementCount:ARe(e)})}),jRe=({onExpand:e,snapshot:t})=>(0,K.jsx)(at,{fallback:(0,K.jsx)(zU,{snapshot:t}),children:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(zU,{snapshot:t}),children:(0,K.jsx)(kRe,{snapshot:t,onExpand:e})})}),BU=class e extends wr{static getType(){return`excalidraw`}static clone(t){return new e(t.__snapshot,t.__key)}constructor(e,t){super(t),Cr(this,`__snapshot`,void 0),this.__snapshot=e}createDOM(e){let t=document.createElement(`div`);return t.className=`rich-excalidraw-wrapper`,t}updateDOM(){return!1}isInline(){return!1}static importJSON(e){return MRe(e.snapshot).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`excalidraw`,snapshot:this.__snapshot,version:1}}getSnapshot(){return this.__snapshot}setSnapshot(e){let t=this.getWritable();t.__snapshot=e}decorate(e,t){return qj(aRe,jRe,{snapshot:this.__snapshot})}};function MRe(e){return new BU(e)}function NRe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function PRe(e){var t=NRe(e,`string`);return typeof t==`symbol`?t:String(t)}function FRe(e,t,n){return t=PRe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function VU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function HU(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?VU(Object(n),!0).forEach(function(t){FRe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):VU(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function UU(e,t){var n={};for(var r in e)n[r]=t(e[r],r);return n}var IRe=(e,t,n)=>{for(var r of Object.keys(e))if(e[r]!==(t[r]??n[r]))return!1;return!0},LRe=e=>{var t=t=>{var n=e.defaultClassName,r=HU(HU({},e.defaultVariants),t);for(var i in r){var a=r[i]??e.defaultVariants[i];if(a!=null){var o=a;typeof o==`boolean`&&(o=o===!0?`true`:`false`);var s=e.variantClassNames[i][o];s&&(n+=` `+s)}}for(var[c,l]of e.compoundVariants)IRe(c,r,e.defaultVariants)&&(n+=` `+l);return n};return t.variants=()=>Object.keys(e.variantClassNames),t.classNames={get base(){return e.defaultClassName.split(` `)[0]},get variants(){return UU(e.variantClassNames,e=>UU(e,e=>e.split(` `)[0]))}},t},WU={root:`rich-alert`,header:`rich-alert-header`,icon:`rich-alert-icon`,label:`rich-alert-label`,content:`rich-alert-content`,contentEditable:`rich-alert-content-editable`},GU={root:{note:`rich-alert-note`,tip:`rich-alert-tip`,important:`rich-alert-important`,warning:`rich-alert-warning`,caution:`rich-alert-caution`},header:{note:`rich-alert-header-note`,tip:`rich-alert-header-tip`,important:`rich-alert-header-important`,warning:`rich-alert-header-warning`,caution:`rich-alert-header-caution`}},KU=LRe({defaultClassName:`pq4lod1`,variantClassNames:{type:{note:`pq4lod2`,tip:`pq4lod3`,important:`pq4lod4`,warning:`pq4lod5`,caution:`pq4lod6`}},defaultVariants:{},compoundVariants:[]}),qU=`pq4lod7`,RRe=`pq4lod8`,zRe=`pq4lod9`,JU=`pq4loda`,YU=`pq4lodb`,BRe=`pq4lodc`,XU={note:g,tip:gi,important:xi,warning:v,caution:wi},ZU={note:`Note`,tip:`Tip`,important:`Important`,warning:`Warning`,caution:`Caution`},VRe=[`note`,`tip`,`important`,`warning`,`caution`],QU=({type:e})=>{let t=XU[e],n=ZU[e];return(0,K.jsxs)(`div`,{className:`${qU} ${KU({type:e})} ${WU.header} ${GU.header[e]}`,children:[(0,K.jsx)(t,{className:`${JU} ${WU.icon}`}),(0,K.jsx)(`span`,{className:`${YU} ${WU.label}`,children:n})]})},HRe=({type:e,editable:t,onTypeChange:n})=>{if(!t||!n)return(0,K.jsx)(QU,{type:e});let r=XU[e],i=ZU[e];return(0,K.jsx)(`div`,{className:`${qU} ${KU({type:e})} ${WU.header} ${GU.header[e]}`,children:(0,K.jsxs)(Zn,{children:[(0,K.jsxs)(On,{"aria-label":`Alert type: ${i}`,className:RRe,children:[(0,K.jsx)(r,{className:`${JU} ${WU.icon}`}),(0,K.jsx)(`span`,{className:`${YU} ${WU.label}`,children:i}),(0,K.jsx)(m,{className:zRe})]}),(0,K.jsx)(Rt,{align:`start`,sideOffset:8,children:(0,K.jsx)(M,{value:e,onValueChange:t=>{t!==e&&n(t)},children:VRe.map(e=>{let t=XU[e];return(0,K.jsxs)(pn,{value:e,children:[(0,K.jsx)(t,{className:`${BRe} ${KU({type:e})}`}),(0,K.jsx)(`span`,{children:ZU[e]})]},e)})})})]})})},$U={root:`rr-image-root`,frame:`rr-image-frame`,frameLoading:`rr-image-loading`,frameLoaded:`rr-image-loaded`,frameError:`rr-image-error`,image:`rr-image-img`,loader:`rr-image-loader`,errorBadge:`rr-image-error`,caption:`rr-image-caption`,editTrigger:`rr-image-edit-trigger`,editPlaceholder:`rr-image-edit-placeholder`,editToolbar:`rr-image-edit-toolbar`,editToolbarVisible:`rr-image-edit-toolbar-visible`,resizeHandle:`rr-image-resize-handle`,inspector:`rr-image-inspector`},eW=`_1n94osf0`,tW=`_1n94osf1`,nW=`_1n94osf3`,rW={loading:`_1n94osf4`,loaded:`_1n94osf5`,error:`_1n94osf6`},iW=`_1n94osf7`,aW=`_1n94osf8`,URe=`_1n94osf9`,WRe=`_1n94osfa`,GRe=`_1n94osfm`,KRe=`_1n94osfn`,qRe=`_1n94osfo`,JRe=`_1n94osfp`,oW=`_1n94osfq`,YRe=`_1n94osfr`,XRe=`_1n94osfs`,ZRe=`_1n94osft`,QRe=`_1n94osfv`,$Re=`_1n94osfw`,eze=`_1n94osfx`,tze=`_1n94osfy`,nze=`_1n94osfz`,rze=`_1n94osf10`,ize=`_1n94osf11`,aze=`_1n94osf12`,oze=`_1n94osf13`,sze=`_1n94osf14`,cze={loading:$U.frameLoading,loaded:$U.frameLoaded,error:$U.frameError};function lze(e,t){if(t)return t;if(e&&(e.startsWith(`!`)||e.startsWith(`¡`)))return e.slice(1)}function sW({src:e,altText:t,width:n,height:r,caption:i,thumbhash:a,accent:o,displayWidth:s,fixedWidth:c,fixedHeight:l,layout:u,onActivate:d,ref:f}){let[p,m]=(0,G.useState)(`loading`),h=(0,G.useRef)(null),g=(0,G.useMemo)(()=>lze(t,i),[t,i]),_=(0,G.useMemo)(()=>a?$j(a):void 0,[a]);if(!e)return null;let v=!!d,y=DN({displayWidth:s,fixedWidth:c,fixedHeight:l}),b=y.mode===`percent`||y.mode===`fixed-width`,x={backgroundColor:p!==`loaded`&&!_?o||Ht.color.bgTertiary:`transparent`,backgroundImage:_&&p!==`loaded`?`url(${_})`:void 0,backgroundSize:`cover`,width:b?`100%`:n?Math.min(n,1200):void 0,maxWidth:`100%`,maxHeight:y.mode===`fixed-height`?`${y.px}px`:void 0,...n&&r?{aspectRatio:`${n} / ${r}`}:{}},S=()=>{h.current&&d?.(h.current)},C=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),S())},w=PN(y);return(0,K.jsxs)(`figure`,{className:`${eW} ${$U.root}`,"data-display":FN(y),"data-layout":u,ref:f,style:w,children:[(0,K.jsxs)(`div`,{"aria-label":v?`Open image: ${t||`image`}`:void 0,className:`${aW} ${v?``:WRe} ${$U.frame} ${rW[p]} ${cze[p]}`.trim(),role:v?`button`:void 0,style:x,tabIndex:v?0:void 0,onClick:v?S:void 0,onKeyDown:v?C:void 0,children:[(0,K.jsx)(`img`,{alt:t,className:`${nW} ${p===`loaded`?iW:``} ${$U.image}`,"data-state":p,height:r,loading:`lazy`,ref:h,src:e,width:n,style:y.mode===`fixed-height`?{width:`auto`,height:`auto`,maxWidth:`100%`,maxHeight:`100%`}:n&&r?{height:`100%`,objectFit:`cover`}:void 0,onError:()=>m(`error`),onLoad:()=>m(`loaded`)}),p===`loading`&&(0,K.jsx)(`span`,{className:`_1n94osfc ${$U.loader}`}),p===`error`&&(0,K.jsx)(`span`,{className:`_1n94osfd ${$U.errorBadge}`,children:`Image failed to load`})]}),g&&(0,K.jsx)(`figcaption`,{className:`_1n94osfe ${$U.caption}`,children:g})]})}var uze=0;function cW(e,t){let n=`atom${++uze}`,r={toString(){return n}};return typeof e==`function`?r.read=e:(r.init=e,r.read=dze,r.write=fze),t&&(r.write=t),r}function dze(e){return e(this)}function fze(e,t,n){return t(this,typeof n==`function`?n(e(this)):n)}function lW(e){return`init`in e}function pze(e){return typeof e.write==`function`}function mze(e){return!!e.onMount}function uW(e){return`v`in e||`e`in e}function dW(e){if(`e`in e)throw e.e;return e.v}function fW(e){return typeof e?.then==`function`}function hze(e){if(!(e instanceof Error))return!1;let t=e.name,n=e.message.toLowerCase();return(t===`RangeError`||t===`InternalError`)&&(n.includes(`call stack`)||n.includes(`too much recursion`)||n.includes(`stack overflow`))}function pW(e,t,n){if(!n.p.has(e)){n.p.add(e);let r=()=>n.p.delete(e);t.then(r,r)}}function mW(e,t,n){let r=n.get(e)?.t,i=t.p;if(!r?.size)return i;if(!i.size)return r;let a=new Set(r);for(let e of i)a.add(e);return a}function gze(e){return!!e.INTERNAL_onInit}var _ze=(e,t,n,...r)=>n.read(...r),vze=(e,t,n,...r)=>n.write(...r),yze=(e,t,n)=>n.INTERNAL_onInit(t),bze=(e,t,n,r)=>n.onMount?.(r),xze=(e,t,n)=>{let r=e.a,i=r.get(n);if(!i){let a=e.h,o=e.I;i={d:new Map,p:new Set,n:0},r.set(n,i),a.i?.(n),gze(n)&&o(e,t,n)}return i},Sze=(e,t)=>{let n=e.m,r=e.c,i=e.q,a=e.Q,o=e.h,s=e.C;if(!o.f&&!r.size&&!i.size&&!a.size)return;let c=[],l=e=>{try{e()}catch(e){c.push(e)}};do{o.f&&l(o.f);let c=new Set;for(let e of r){let t=n.get(e)?.l;if(t)for(let e of t)c.add(e)}r.clear();for(let e of a)c.add(e);a.clear();for(let e of i)c.add(e);i.clear();for(let e of c)l(e);r.size&&s(e,t)}while(r.size||a.size||i.size);if(c.length)throw typeof AggregateError==`function`?AggregateError(c):Object.assign(Error(),{errors:c})},Cze=(e,t)=>{let n=e.m,r=e.i,i=e.c,a=e.e,o=e.r,s=e.D;if(!i.size)return;let c=[],l=[],u=new WeakSet,d=new WeakSet,f=[],p=[];for(let n of i)f.push(n),p.push(a(e,t,n));for(;f.length;){let i=f.length-1,o=f[i],s=p[i];if(d.has(o))f.pop(),p.pop();else if(u.has(o))r.get(o)===s.n&&(c.push(o),l.push(s)),d.add(o),f.pop(),p.pop();else{u.add(o);for(let r of mW(o,s,n))u.has(r)||(f.push(r),p.push(a(e,t,r)))}}for(let n=c.length-1;n>=0;--n){let a=c[n],u=l[n],d=!1;for(let e of u.d.keys())if(e!==a&&i.has(e)){d=!0;break}d&&(r.set(a,u.n),o(e,t,a),s(e,t,a)),r.delete(a)}},wze=(e,t,n)=>{let r=e.m,i=e.i,a=e.c,o=e.h,s=e.R,c=e.e,l=e.f,u=e.C,d=e.r,f=e.D,p=e.v,m=e.H,h=e.E,g=c(e,t,n),_=h[0];if(uW(g)){if(r.has(n)&&i.get(n)!==g.n||g.m===_)return g.m=_,g;let a=!1;for(let[n,r]of g.d)if(d(e,t,n).n!==r){a=!0;break}if(!a)return g.m=_,g}let v=!0,y=new Set(g.d.keys()),b=()=>{for(let e of y)g.d.delete(e)},x=()=>{if(r.has(n)){let r=!a.size;f(e,t,n),r&&(u(e,t),l(e,t))}},S=i=>{if(i===n){let n=c(e,t,i);if(!uW(n)){if(lW(i))p(e,t,i,i.init);else throw Error(`no atom init`)}return dW(n)}let a=d(e,t,i);try{return dW(a)}finally{y.delete(i),g.d.set(i,a.n),fW(g.v)&&pW(n,g.v,a),r.has(n)&&r.get(i)?.t.add(n),v||x()}},C,w={get signal(){return C||=new AbortController,C.signal}},T=g.n,E=i.get(n)===T;try{let r=s(e,t,n,S,w);if(p(e,t,n,r),fW(r)){m(e,t,r,()=>C?.abort());let n=()=>{b(),x()};r.then(n,n)}else b();return o.r?.(n),g.m=_,g}catch(e){if(hze(e))throw e;return delete g.v,g.e=e,++g.n,g.m=_,g}finally{v=!1,g.n!==T&&E&&(i.set(n,g.n),a.add(n),o.c?.(n))}},Tze=(e,t,n)=>{let r=e.m,i=e.i,a=e.e,o=[n];for(;o.length;){let n=o.pop(),s=a(e,t,n);for(let c of mW(n,s,r)){let n=a(e,t,c);i.get(c)!==n.n&&(i.set(c,n.n),o.push(c))}}},Eze=(e,t,n,r)=>{let i=e.c,a=e.h,o=e.W,s=e.e,c=e.f,l=e.C,u=e.r,d=e.d,f=e.w,p=e.D,m=e.v,h=e.E,g=!0,_=n=>dW(u(e,t,n)),v=(r,...o)=>{let u=s(e,t,r);try{if(r===n){if(!lW(r))throw Error(`atom not writable`);let n=u.n,s=o[0];m(e,t,r,s),p(e,t,r),n!==u.n&&(++h[0],i.add(r),d(e,t,r),a.c?.(r));return}return f(e,t,r,o)}finally{g||(l(e,t),c(e,t))}};try{return o(e,t,n,_,v,...r)}finally{g=!1}},Dze=(e,t,n)=>{let r=e.m,i=e.c,a=e.h,o=e.e,s=e.d,c=e.t,l=e.T,u=o(e,t,n),d=r.get(n);if(d){for(let[r,l]of u.d)if(!d.d.has(r)){let u=o(e,t,r);c(e,t,r).t.add(n),d.d.add(r),l!==u.n&&(i.add(r),s(e,t,r),a.c?.(r))}for(let r of d.d)u.d.has(r)||(d.d.delete(r),l(e,t,r)?.t.delete(n))}},Oze=(e,t,n)=>{let r=e.m,i=e.q,a=e.h,o=e.M,s=e.e,c=e.f,l=e.C,u=e.r,d=e.w,f=e.t,p=s(e,t,n),m=r.get(n);if(!m){u(e,t,n);for(let r of p.d.keys())f(e,t,r).t.add(n);m={l:new Set,d:new Set(p.d.keys()),t:new Set},r.set(n,m),pze(n)&&mze(n)&&i.add(()=>{let r=!0,i=(...i)=>{try{return d(e,t,n,i)}finally{r||(l(e,t),c(e,t))}};try{let a=o(e,t,n,i);a&&(m.u=()=>{r=!0;try{a()}finally{r=!1}})}finally{r=!1}}),a.m?.(n)}return m},kze=(e,t,n)=>{let r=e.m,i=e.Q,a=e.h,o=e.e,s=e.T,c=o(e,t,n),l=r.get(n);if(!l||l.l.size)return l;let u=!1;for(let e of l.t)if(r.get(e)?.d.has(n)){u=!0;break}if(u)return l;l.u&&i.add(l.u),l=void 0,r.delete(n);for(let r of c.d.keys())s(e,t,r)?.t.delete(n);a.u?.(n)},Aze=(e,t,n,r)=>{let i=e.e,a=e.A,o=i(e,t,n),s=`v`in o,c=o.v;if(fW(r))for(let a of o.d.keys())pW(n,r,i(e,t,a));o.v=r,delete o.e,s&&Object.is(c,o.v)||(++o.n,fW(c)&&a(e,t,c))},jze=(e,t,n)=>{let r=e.r;return dW(r(e,t,n))},Mze=(e,t,n,...r)=>{let i=e.c,a=e.f,o=e.C,s=e.w,c=i.size;try{return s(e,t,n,r)}finally{i.size!==c&&(o(e,t),a(e,t))}},Nze=(e,t,n,r)=>{let i=e.f,a=e.C,o=e.t,s=e.T,c=o(e,t,n).l;return c.add(r),a(e,t),i(e,t),()=>{c.delete(r),s(e,t,n),a(e,t),i(e,t)}},Pze=(e,t,n,r)=>{let i=e.p,a=i.get(n);if(!a){a=new Set,i.set(n,a);let e=()=>i.delete(n);n.then(e,e)}a.add(r)},Fze=(e,t,n)=>{e.p.get(n)?.forEach(e=>e())},hW=new WeakMap;function Ize(e){let t=hW.get(e),n=t.B;return n?n(t,e):t}function Lze(e){let t={get(e){return r(n,t,e)},set(e,...r){return i(n,t,e,...r)},sub(e,r){return a(n,t,e,r)}},n=Object.freeze({a:new WeakMap,m:new WeakMap,i:new WeakMap,c:new Set,q:new Set,Q:new Set,h:{},R:_ze,W:vze,I:yze,M:bze,e:xze,f:Sze,C:Cze,r:wze,d:Tze,w:Eze,D:Dze,t:Oze,T:kze,v:Aze,g:jze,s:Mze,b:Nze,B:void 0,p:new WeakMap,H:Pze,A:Fze,E:[0],...e});hW.set(t,n);let r=n.g,i=n.s,a=n.b;return t}function gW(){return Lze()}var _W;function Rze(){return _W||=gW(),_W}var vW=(0,G.createContext)(void 0);function yW(e){let t=(0,G.useContext)(vW);return e?.store||t||Rze()}function zze({children:e,store:t}){let n=(0,G.useRef)(null);return t?(0,G.createElement)(vW.Provider,{value:t},e):(n.current===null&&(n.current=gW()),(0,G.createElement)(vW.Provider,{value:n.current},e))}var bW=e=>typeof e?.then==`function`,xW=new WeakMap,Bze=(e,t,n)=>{let r=Ize(e),i=r.H,a=xW.get(t);return a||(a=new Promise((o,s)=>{let c=t,l=e=>t=>{c===e&&o(t)},u=e=>t=>{c===e&&s(t)},d=()=>{try{let t=n();bW(t)?(xW.set(t,a),c=t,t.then(l(t),u(t)),i(r,e,t,d)):o(t)}catch(e){s(e)}};t.then(l(t),u(t)),i(r,e,t,d)}),xW.set(t,a)),a},SW=(e,t,n)=>[n,e,t,r=>{let i=e.sub(t,r),a=!0;try{a=!Object.is(n,e.get(t))}catch{}return a&&r(),i}];function Vze(e,t){let n=yW(t),[[r,i,a,o],s]=(0,G.useReducer)(t=>{let r=n.get(e);return t[1]===n&&t[2]===e?Object.is(t[0],r)?t:[r,n,e,t[3]]:SW(n,e,r)},void 0,()=>SW(n,e,n.get(e))),c=r;return(i!==n||a!==e)&&(s(),c=n.get(e)),(0,G.useEffect)(()=>o(s),[o]),(0,G.useDebugValue)(c),bW(c)?Bze(n,c,()=>n.get(e)):c}var CW=e=>{e.status||(e.status=`pending`,e.then(t=>{e.status=`fulfilled`,e.value=t},t=>{e.status=`rejected`,e.reason=t}))},Hze=G.use||(e=>{if(e.status===`pending`)throw e;if(e.status===`fulfilled`)return e.value;throw e.status===`rejected`?e.reason:(CW(e),e)});function wW(e,t){let{unstable_promiseStatus:n=!G.use}=t||{},r=Vze(e,t);return bW(r)?(n&&CW(r),Hze(r)):r}function TW(e,t){let n=yW(t);return(0,G.useCallback)((...t)=>n.set(e,...t),[n,e])}function EW(e,t){return[wW(e,t),TW(e,t)]}function Uze(e,t){if(t)return t;if(e&&(e.startsWith(`!`)||e.startsWith(`¡`)))return e.slice(1)}var DW=cW(``),OW=cW(``),kW=cW(),AW=cW(),jW=cW(),MW=cW(),NW=cW(),PW=cW(),FW=cW(),IW=cW(),LW=cW(),RW=cW(`loading`),zW=cW(!1),BW=cW(!1),VW=cW(!1),Wze=cW(!1),Gze=cW(!1),HW=cW(!1),UW=cW(e=>e(zW)||e(BW)||e(VW)||e(Wze)||e(Gze)||e(HW)),WW=cW(!1),GW=cW({current:null}),Kze=cW({current:null}),qze=cW(e=>{let t=e(MW);return t?$j(t):void 0}),Jze=cW(e=>Uze(e(OW),e(jW))),Yze=cW(e=>{let t=e(qze),n=e(NW),r=e(RW),i=e(kW),a=e(AW),o=e(PW),s=e(FW),c=e(IW),l=o!==void 0||s!==void 0;return{backgroundColor:r!==`loaded`&&!t?n||`#f5f5f5`:`transparent`,backgroundImage:t&&r!==`loaded`?`url(${t})`:void 0,backgroundSize:`cover`,width:l?`100%`:i?Math.min(i,1200):void 0,maxWidth:`100%`,maxHeight:c===void 0?void 0:`${c}px`,...i&&a?{aspectRatio:`${i} / ${a}`}:{}}});function Xze({props:e,children:t}){let[n]=ht(),r=(0,G.useRef)(null),i=(0,G.useRef)(null),[a]=(0,G.useState)(()=>{let t=gW();return t.set(DW,e.src),t.set(OW,e.altText),t.set(kW,e.width),t.set(AW,e.height),t.set(jW,e.caption),t.set(MW,e.thumbhash),t.set(NW,e.accent),t.set(PW,e.displayWidth),t.set(FW,e.fixedWidth),t.set(IW,e.fixedHeight),t.set(LW,e.layout),t.set(GW,r),t.set(Kze,i),t.set(RW,e.src?`loading`:`error`),t.set(VW,!e.src&&!!e.autoOpenOnMount),t});return(0,G.useEffect)(()=>{a.set(DW,e.src),a.set(OW,e.altText),a.set(kW,e.width),a.set(AW,e.height),a.set(jW,e.caption),a.set(MW,e.thumbhash),a.set(NW,e.accent),a.set(PW,e.displayWidth),a.set(FW,e.fixedWidth),a.set(IW,e.fixedHeight),a.set(LW,e.layout)},[a,e.src,e.altText,e.width,e.height,e.caption,e.thumbhash,e.accent,e.displayWidth,e.fixedWidth,e.fixedHeight,e.layout]),(0,G.useEffect)(()=>{a.set(RW,e.src?`loading`:`error`)},[a,e.src]),(0,G.useEffect)(()=>{if(!e.autoOpenOnMount)return;let t=r.current;t&&n.update(()=>{let e=Bt(t);GN(e)&&e.setShouldAutoOpenOnMount(!1)},{tag:[un,pee]})},[n,e.autoOpenOnMount]),(0,K.jsx)(zze,{store:a,children:t})}var KW=e=>{e.preventDefault(),e.stopPropagation()};function qW({children:e,label:t,icon:n=!0,...r}){return(0,K.jsxs)(Mn,{children:[(0,K.jsx)(tt,{render:(0,K.jsx)(Fe,{"aria-label":t,icon:n,size:`md`,onMouseDown:KW,...r}),children:e}),(0,K.jsx)(Fn,{side:`top`,children:t})]})}function JW(){let e=yW(),[t]=ht(),n=(0,G.useCallback)(n=>{let r=e.get(GW);r.current&&t.update(()=>{let e=Bt(r.current);GN(e)&&n(e)},{tag:`skip-scroll-into-view`})},[t,e]),r=(0,G.useCallback)(()=>{e.set(VW,!1)},[e]),i=(0,G.useCallback)(()=>{let n=e.get(GW);n.current&&(t.update(()=>{let e=Bt(n.current);e&&e.remove()}),e.set(BW,!1),r())},[r,t,e]),a=(0,G.useCallback)(()=>{let t=e.get(DW);t&&window.open(t,`_blank`,`noopener,noreferrer`)},[e]),o=(0,G.useCallback)(()=>{let t=e.get(DW);if(!t)return;let n=document.createElement(`a`);n.href=t,n.download=e.get(OW)||`image`,n.click()},[e]),s=(0,G.useCallback)(()=>{n(e=>{let t=WN({src:e.getSrc(),altText:e.getAltText(),width:e.getWidth(),height:e.getHeight(),caption:e.getCaption(),thumbhash:e.getThumbhash(),accent:e.getAccent(),displayWidth:e.getDisplayWidth(),fixedWidth:e.getFixedWidth(),fixedHeight:e.getFixedHeight(),layout:e.getLayout()});e.insertAfter(t)})},[n]),c=(0,G.useCallback)(e=>{n(t=>{t.applyDisplaySize(e)})},[n]),l=(0,G.useCallback)(e=>{n(t=>{t.setLayout(e)})},[n]);return{closeReplacePanel:r,handleReplaceOpenChange:(0,G.useCallback)(t=>{e.set(VW,t),t||r()},[r,e]),handleOpen:a,handleDuplicate:s,handleDownload:o,handleDelete:i,handleSetDisplaySize:c,handleSetLayout:l}}function YW({onOpenChange:e}){let[t]=ht(),{handleDuplicate:n,handleOpen:r,handleDownload:i,handleDelete:a}=JW();return(0,K.jsxs)(Zn,{onOpenChange:t=>e?.(t),children:[(0,K.jsx)(On,{render:(0,K.jsx)(Fe,{icon:!0,"aria-label":`More actions`,size:`md`,onMouseDown:KW}),children:(0,K.jsx)(Nr,{})}),(0,K.jsxs)(Rt,{align:`end`,children:[(0,K.jsxs)(Ut,{onClick:n,children:[(0,K.jsx)(Vte,{}),`Duplicate`]}),(0,K.jsxs)(Ut,{onClick:r,children:[(0,K.jsx)(Xte,{}),`Open original`]}),(0,K.jsxs)(Ut,{onClick:i,children:[(0,K.jsx)(E,{}),`Download`]}),(0,K.jsx)(ur,{}),(0,K.jsxs)(Ut,{shortcut:`Backspace`,variant:`destructive`,onClick:()=>{a(),Pe({title:`Image deleted`,action:{label:`Undo`,onClick:()=>t.dispatchCommand(U,void 0)}})},children:[(0,K.jsx)(Mr,{}),`Delete`]})]})]})}var Zze=/^(?:javascript\s*:|vbscript\s*:|data\s*:(?!image\/))/i;function XW(e){return e.trim()!==``&&!Zze.test(e.trim())}function Qze({focus:e,menu:t,onApply:n,onKeyDown:r,onOpenChange:i,open:a,renderWidth:o,trigger:s,values:c}){let l=(0,G.useId)(),u=(0,G.useRef)(null),d=(0,G.useRef)(null),[f,p]=(0,G.useState)(c.altText),[m,h]=(0,G.useState)(c.caption),[g,_]=(0,G.useState)(c.src),{apply:v,revert:y}=Tee(c,a,n);(0,G.useEffect)(()=>{a&&(p(c.altText),h(c.caption),_(c.src))},[a]);let b=!XW(g),x=e===`caption`?d:e===`alt`?u:void 0;return(0,K.jsxs)(gn,{open:a,onOpenChange:(e,t)=>{!e&&t?.reason===`escape-key`&&y(),i(e)},children:[(0,K.jsx)(en,{render:s}),(0,K.jsxs)(yn,{flush:!0,className:`${QRe} ${$U.inspector}`,initialFocus:x,side:`bottom`,size:`md`,onKeyDown:r,children:[(0,K.jsx)(wn,{actions:t,icon:(0,K.jsx)(T,{}),title:`Image`}),(0,K.jsxs)(Xn,{children:[o?.(e=>v({size:e})),(0,K.jsx)(Kn,{id:`${l}-alt`,label:`Alt text`,children:(0,K.jsx)(ct,{id:`${l}-alt`,placeholder:`Describe the image`,ref:u,value:f,onChange:e=>{p(e.target.value),v({altText:e.target.value})}})}),(0,K.jsx)(Kn,{hint:`Optional`,id:`${l}-caption`,label:`Caption`,children:(0,K.jsx)(ct,{id:`${l}-caption`,ref:d,value:m,onChange:e=>{h(e.target.value),v({caption:e.target.value})}})}),(0,K.jsx)(Kn,{error:b?`Enter an image URL`:void 0,id:`${l}-src`,label:`Source URL`,children:(0,K.jsx)(ct,{"aria-describedby":b?`${l}-src-error`:void 0,id:`${l}-src`,invalid:b,type:`url`,value:g,onChange:e=>{_(e.target.value),XW(e.target.value)&&v({src:e.target.value.trim()})}})})]}),(0,K.jsxs)(Bn,{hint:`Changes apply as you type`,children:[(0,K.jsx)(ar,{keys:`Esc`,size:`sm`,tone:`muted`}),(0,K.jsx)(`span`,{className:$Re,children:`revert`})]})]})]})}function ZW(e){let t=e.closest(`.rich-image-wrapper`)?.parentElement??e.parentElement;if(!t)return;let n=getComputedStyle(t),r=t.clientWidth-Number.parseFloat(n.paddingLeft)-Number.parseFloat(n.paddingRight);return r>0?r:void 0}function $ze(e,t,n){if(!e)return;let r=ZW(e);if(!r)return;let i=e.querySelector(`.${$U.frame}`)?.getBoundingClientRect();return{containerWidth:r,intrinsicWidth:t,intrinsicHeight:n,renderedWidth:i?.width,renderedHeight:i?.height}}function eBe(e,t,n){let r=e.querySelector(`figure`),i=t===`float-left`||t===`float-right`,a=e.closest(`.rich-image-wrapper`);r?.style.removeProperty(`--rich-image-display-width`),r?.style.removeProperty(`--rich-image-display-height`);let o=PN(n);if(r&&o)for(let[e,t]of Object.entries(o))r.style.setProperty(e,t);i&&a&&(n.mode===`percent`?(a.style.width=`${n.value}%`,a.style.maxWidth=``):n.mode===`fixed-width`?(a.style.width=`${n.px}px`,a.style.maxWidth=`100%`):n.mode===`fixed-height`?(a.style.width=`auto`,a.style.maxWidth=`100%`):(a.style.width=``,a.style.maxWidth=``))}var QW=cW(null),tBe=[25,50,75,100],$W=10,eG=100,nBe=3,rBe=[{value:`auto`,label:`Auto`},{value:`percent`,label:`%`},{value:`px`,label:`px`}];function iBe(e){for(let t of tBe)if(Math.abs(e-t)<=nBe)return t;return e}function tG(e){switch(e.mode){case`percent`:return`${e.value}%`;case`fixed-width`:case`fixed-height`:return`${e.px}px`;default:return`Auto`}}function aBe(){let e=wW(PW),t=wW(FW),n=wW(IW);return(0,G.useMemo)(()=>DN({displayWidth:e,fixedWidth:t,fixedHeight:n}),[e,t,n])}function oBe(){let[e]=ht(),t=yW();return(0,G.useCallback)((n,r)=>{let i=t.get(GW).current;i&&e.update(()=>{let e=Bt(i);GN(e)&&(n.src!==void 0&&e.setSrc(n.src),n.altText!==void 0&&e.setAltText(n.altText),n.caption!==void 0&&e.setCaption(n.caption||void 0),n.size&&e.applyDisplaySize(n.size))},{tag:r?[un,`skip-scroll-into-view`]:`skip-scroll-into-view`})},[e,t])}function sBe({size:e,onChange:t}){let n=(0,G.useId)(),r=yW(),i=wW(kW),a=wW(AW),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null);(0,G.useEffect)(()=>{s(null),l(null)},[e]);let u=()=>$ze(r.get(GW).current,i,a),d=e.mode===`auto`?`auto`:e.mode===`percent`?`percent`:`px`,f=n=>{if(n===d)return;if(n===`auto`){t({mode:`auto`});return}let r=u();if(n===`percent`){t(r?NN(e,`percent`,r):{mode:`percent`,value:100});return}if(r){t(NN(e,`fixed-width`,r));return}let a=EN(i);a&&t({mode:`fixed-width`,px:a})},p=e=>{let t=r.get(GW).current;t&&eBe(t,r.get(LW),e)},m=(()=>{if(e.mode===`percent`)return e.value;let t=u();if(!t)return;let{widthPx:n}=MN(e,t);return n?TN(n/t.containerWidth*100):void 0})(),h=o??m??eG,g=`${(h-$W)/90*100}%`,_=()=>{o!==null&&o!==m&&t({mode:`percent`,value:o})},v=e.mode===`fixed-width`||e.mode===`fixed-height`?e.px:void 0,y=e.mode===`fixed-height`?`Height in pixels`:`Width in pixels`;return(0,K.jsxs)(`div`,{className:aze,children:[(0,K.jsx)(`span`,{className:oze,id:`${n}-label`,children:`Width`}),(0,K.jsxs)(`div`,{"aria-labelledby":`${n}-label`,className:sze,role:`group`,children:[(0,K.jsx)(xt,{items:rBe,value:d,onChange:f}),d===`percent`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`input`,{"aria-label":`Width, percent of content width`,className:`_1n94osfu`,max:eG,min:$W,step:1,style:{"--fill":g},type:`range`,value:h,onBlur:_,onKeyUp:_,onPointerUp:_,onChange:e=>{let t=iBe(Number(e.target.value));s(t),p({mode:`percent`,value:t})}}),(0,K.jsx)(`span`,{className:`_1n94osf15`,children:`${h}%`})]}),d===`px`&&(0,K.jsxs)(`span`,{className:`_1n94osf17`,children:[(0,K.jsx)(ct,{"aria-label":y,autoComplete:`off`,inputMode:`numeric`,invalid:c!==null&&EN(Number(c))===void 0,spellCheck:!1,value:c??String(v??``),onChange:n=>{l(n.target.value);let r=EN(Number(n.target.value));r&&(e.mode===`fixed-width`||e.mode===`fixed-height`)&&t({mode:e.mode,px:r})}}),(0,K.jsx)(`span`,{className:`_1n94osf18`,children:`px`})]}),d===`auto`&&(0,K.jsx)(`span`,{className:`_1n94osf16`,children:`Natural size`})]})]})}function cBe(){let[e,t]=EW(BW),[n,r]=EW(QW),[i,a]=EW(WW),o=wW(DW),s=wW(OW),c=wW(jW),l=aBe(),u=oBe(),d=(0,G.useMemo)(()=>({src:o,altText:s,caption:c??``,size:l}),[o,s,c,l]);return(0,K.jsx)(Qze,{focus:i?`caption`:n,menu:(0,K.jsx)(YW,{}),open:e,renderWidth:e=>(0,K.jsx)(sBe,{size:l,onChange:e}),values:d,trigger:(0,K.jsxs)(Fe,{"aria-label":`Image size, ${tG(l)}`,className:rze,size:`md`,onClick:()=>r(null),onMouseDown:KW,children:[(0,K.jsx)(`span`,{children:tG(l)}),(0,K.jsx)(m,{className:ize})]}),onApply:u,onOpenChange:e=>{t(e),e||(r(null),a(!1))}})}var lBe=[{value:void 0,label:`Center`,Icon:Tne},{value:`align-left`,label:`Align left`,Icon:Dne},{value:`align-right`,label:`Align right`,Icon:Ene},{value:`float-left`,label:`Wrap left`,Icon:kne},{value:`float-right`,label:`Wrap right`,Icon:jte}];function uBe(){let e=wW(LW),{handleSetLayout:t}=JW();return(0,K.jsx)(`div`,{"aria-label":`Image layout`,className:eze,role:`group`,children:lBe.map(({value:n,label:r,Icon:i})=>(0,K.jsx)(qW,{"aria-pressed":e===n,label:r,onClick:()=>{e!==n&&t(n)},children:(0,K.jsx)(i,{})},n??`center`))})}var dBe=6e3;function nG(){let[e]=ht(),t=yW(),n=wje(),r=iL(),i=We(),a=(0,G.useRef)(!1);return(0,G.useCallback)(async()=>{if(a.current)return;a.current=!0;let o=t.get(GW).current,s=t=>{o&&e.update(()=>{let e=Bt(o);GN(e)&&t(e)},{tag:`skip-scroll-into-view`})};try{let e=hL(r),t=(await NL({editor:e,mode:`replace`,portalClassName:i.className,theme:i.theme}))?.[0];if(!t)return;if(t.kind===`url`){s(e=>{e.setSrc(t.src),e.setDimensions(t.width,t.height),e.setThumbhash(void 0)});return}let[a]=e?[t.file]:await lL([t.file],`replace`,r?.ref.current??null);if(!a)return;let o=async()=>{let e=Pe({title:`Uploading image…`,tone:`loading`});try{let t=n??IL,[r,i]=await Promise.all([PL(t,a),Qj(a)]);s(e=>{e.setSrc(r.src),e.setAltText(r.altText??a.name),e.setDimensions(r.width??i.width,r.height??i.height),e.setThumbhash(r.thumbhash??i.thumbhash)}),Et(e,{title:`Image replaced`,tone:`success`})}catch(t){console.error(`[ImageReplace]`,t),Et(e,{action:{label:`Retry`,onClick:()=>void o()},duration:dBe,title:`Image replace failed`,tone:`error`})}};await o()}finally{a.current=!1}},[e,i,r,t,n])}function fBe(){let[e]=ht(),t=yW(),[n,r]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{let n=t.get(GW).current;if(!n)return;let i=()=>e.read(()=>{let e=kr();if(!Ue(e))return!1;let t=Bt(n);return t!==null&&e.has(t.getKey())}),a=()=>{let e=i();r(e),e?n.dataset.selected=``:delete n.dataset.selected},o=t=>{t.target?.closest(`.${$U.editToolbar}`)||e.update(()=>{let e=Bt(n);if(!e)return;let t=sr();t.add(e.getKey()),Jt(t)},{tag:`skip-scroll-into-view`})};a(),n.addEventListener(`click`,o);let s=e.registerUpdateListener(a);return()=>{n.removeEventListener(`click`,o),s(),delete n.dataset.selected}},[e,t]),n}function rG(){return(0,K.jsx)(`span`,{"aria-hidden":!0,className:tze})}function pBe(){let e=wW(UW),t=fBe(),[n,r]=(0,G.useState)(!1),i=TW(BW),a=TW(QW),o=nG(),s=e||t||n;return(0,K.jsxs)(`div`,{"aria-label":`Image`,className:`${qRe} ${$U.editToolbar} ${s?`${JRe} ${$U.editToolbarVisible}`:``}`,role:`toolbar`,children:[(0,K.jsx)(cBe,{}),(0,K.jsx)(rG,{}),(0,K.jsx)(uBe,{}),(0,K.jsx)(rG,{}),(0,K.jsx)(qW,{className:nze,icon:!1,label:`Alt text`,onClick:()=>{a(`alt`),i(!0)},children:`Alt`}),(0,K.jsx)(qW,{label:`Replace image`,onClick:()=>void o(),children:(0,K.jsx)(Gne,{})}),(0,K.jsx)(rG,{}),(0,K.jsx)(YW,{onOpenChange:r})]})}function mBe(){let[e,t]=EW(VW),n=nG();return(0,G.useEffect)(()=>{e&&(t(!1),n())},[n,e,t]),(0,K.jsxs)(`button`,{className:`${KRe} ${$U.editPlaceholder}`,type:`button`,onClick:()=>void n(),onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},children:[(0,K.jsx)(T,{size:24}),(0,K.jsx)(`span`,{children:`Click to add image`})]})}var hBe=3;function gBe(){let e=yW(),[t]=ht(),n=(0,G.useRef)(null);return(0,G.useEffect)(()=>()=>n.current?.(!1),[]),{handlePointerDown:(0,G.useCallback)((r,i)=>{let a=e.get(GW).current;if(!a)return;let o=a.querySelector(`.${$U.frame}`),s=a.querySelector(`figure`),c=a.closest(`.rich-image-wrapper`);if(!o||!s)return;let l=ZW(a),u=o.getBoundingClientRect().width;if(!l||l<=0||!u)return;r.preventDefault(),r.stopPropagation();let d=e.get(LW),f=d===void 0?2:1,p=d===`float-left`||d===`float-right`,m=r.clientX,h=r.currentTarget;try{h.setPointerCapture(r.pointerId)}catch{}e.set(HW,!0);let g=document.body.style.userSelect;document.body.style.userSelect=`none`;let _=o.getBoundingClientRect().height,v=u>0&&_>0?_/u:void 0,y=DN({displayWidth:e.get(PW),fixedWidth:e.get(FW),fixedHeight:e.get(IW)}).mode,b=IN(y,u,_,l),x=!1,S=e=>{let t=PN(e);if(s.style.removeProperty(`--rich-image-display-width`),s.style.removeProperty(`--rich-image-display-height`),t)for(let[e,n]of Object.entries(t))s.style.setProperty(e,n);p&&c&&(e.mode===`percent`?(c.style.width=`${e.value}%`,c.style.maxWidth=``):e.mode===`fixed-width`?(c.style.width=`${e.px}px`,c.style.maxWidth=`100%`):e.mode===`fixed-height`&&(c.style.width=`auto`,c.style.maxWidth=`100%`))},C=e=>{let t=e.clientX-m;if(!x&&Math.abs(t)<hBe)return;x=!0;let n=i===`left`?-t:t,r=u+n*f,a=v?r*v:_;b=IN(y,r,a,l),S(b)},w=r=>{n.current===w&&(n.current=null,h.removeEventListener(`pointermove`,C),h.removeEventListener(`pointerup`,T),h.removeEventListener(`pointercancel`,T),document.body.style.userSelect=g,e.set(HW,!1),r&&x&&t.update(()=>{let e=Bt(a);GN(e)&&e.applyDisplaySize(b)},{tag:`skip-scroll-into-view`}))},T=()=>w(!0);n.current=w,h.addEventListener(`pointermove`,C),h.addEventListener(`pointerup`,T),h.addEventListener(`pointercancel`,T)},[t,e])}}function _Be(){let e=wW(UW),{handlePointerDown:t}=gBe(),n=e?ZRe:``;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`${oW} ${YRe} ${n} ${$U.resizeHandle}`.trim(),onPointerDown:e=>t(e,`left`)}),(0,K.jsx)(`span`,{className:`${oW} ${XRe} ${n} ${$U.resizeHandle}`.trim(),onPointerDown:e=>t(e,`right`)})]})}var iG=`application/x-haklex-image-drag`;function aG(e,t){return t<e.left+e.width/2?`left`:`right`}function vBe(e){return e===`left`?`float-left`:`float-right`}function oG(e){return!!e?.types.includes(iG)}function sG(e,t){let n=e.getRootElement();if(!n)return null;let r=t;for(;r&&r!==n;){if(r.parentElement===n)return r;r=r.parentElement}return null}function yBe(e,t){let n=[...e.children].filter(e=>e instanceof HTMLElement);if(!n.length)return null;let r=null,i=1/0;for(let e of n){let n=e.getBoundingClientRect();if(n.height<=0)continue;if(t>=n.top&&t<=n.bottom)return e;let a=t<n.top?n.top-t:t-n.bottom;a<i&&(i=a,r=e)}return r}function cG(e,t,n){let r=t.getBoundingClientRect();if(r.width<=0||r.height<=0||n.clientY<r.top||n.clientY>r.bottom)return null;let i=[{x:n.clientX,y:n.clientY}],a=Math.min(r.right-1,Math.max(r.left+1,n.clientX));a!==n.clientX&&i.unshift({x:a,y:n.clientY});for(let t of i){let n=document.elementFromPoint(t.x,t.y);if(!(n instanceof HTMLElement))continue;let r=sG(e,n);if(r)return r}if(n.target instanceof HTMLElement){let t=sG(e,n.target);if(t)return t}return yBe(t,n.clientY)}var lG=new WeakMap;function bBe(e,t){let n=aG(e.getBoundingClientRect(),t.clientX);e.dataset.richImageDropSide=n}function uG(e){delete e.dataset.richImageDropSide}function xBe(e){let t=lG.get(e);if(t)return t.count+=1,()=>{--t.count,t.count>0||(t.unregister(),lG.delete(e))};let n=e.getRootElement();if(!n)return()=>{};let r=()=>uG(n),i=e.registerCommand(hr,t=>oG(t.dataTransfer)?(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect=`move`),cG(e,n,t)?(bBe(n,t),!0):(uG(n),!0)):!1,3),a=e.registerCommand(dt,t=>{let r=t.dataTransfer?.getData(iG);if(!r)return!1;t.preventDefault(),uG(n);let i=cG(e,n,t);if(!i)return!0;let a=i.getBoundingClientRect(),o=e.getEditorState().read(()=>Bt(i)?.getKey()??null,{editor:e});if(!o)return!0;let s=vBe(aG(n.getBoundingClientRect(),t.clientX)),c=t.clientY<a.top+a.height/2;return e.update(()=>{let e=Dn(r);if(!GN(e)||(e.setLayout(s),r===o))return;e.remove();let t=Dn(o);t&&(c?t.insertBefore(e):t.insertAfter(e))},{tag:`skip-scroll-into-view`}),!0},3),o=e.registerCommand(Je,e=>oG(e.dataTransfer),3);window.addEventListener(`dragend`,r),window.addEventListener(`drop`,r);let s={count:1,unregister:()=>{i(),a(),o(),window.removeEventListener(`dragend`,r),window.removeEventListener(`drop`,r),uG(n)}};return lG.set(e,s),()=>{--s.count,s.count>0||(s.unregister(),lG.delete(e))}}function SBe(){let[e]=ht(),t=yW();(0,G.useEffect)(()=>xBe(e),[e]);let n=(0,G.useCallback)(n=>{let r=t.get(GW).current,i=r?.closest(`.rich-image-wrapper`);if(!r||!n.dataTransfer){n.preventDefault();return}let a=e.getEditorState().read(()=>{let e=Bt(r);return GN(e)?e.getKey():null},{editor:e});a?(n.dataTransfer.setData(iG,a),n.dataTransfer.effectAllowed=`move`,i?.classList.add(tW)):n.preventDefault()},[e,t]);return{draggable:!0,onDragEnd:(0,G.useCallback)(()=>{t.get(GW).current?.closest(`.rich-image-wrapper`)?.classList.remove(tW)},[t]),onDragStart:n}}var CBe={loading:$U.frameLoading,loaded:$U.frameLoaded,error:$U.frameError};function wBe(e){return XEe()===`editor`?(0,K.jsx)(TBe,{...e}):(0,K.jsx)(sW,{...e})}function TBe(e){let[t]=ht();return t.isEditable()?(0,K.jsx)(Xze,{props:e,children:(0,K.jsx)(EBe,{})}):(0,K.jsx)(sW,{...e})}function EBe(){let e=wW(GW),t=TW(zW),n=wW(DW),r=wW(RW),i=TW(RW),a=wW(Yze),o=wW(OW),s=wW(kW),c=wW(AW),l=wW(Jze),u=TW(BW),d=TW(VW),f=TW(WW),p=wW(PW),m=wW(FW),h=wW(IW),g=wW(LW),_=DN({displayWidth:p,fixedWidth:m,fixedHeight:h}),v=SBe(),y=(0,G.useCallback)(e=>{e.stopPropagation();let t=window.scrollY;d(!1),u(!0),f(!0),requestAnimationFrame(()=>{window.scrollTo({top:t})})},[u,d,f]),b=PN(_);return(0,K.jsxs)(`div`,{className:`${GRe} ${$U.editTrigger}`,ref:e,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[n?(0,K.jsxs)(`figure`,{className:`${eW} ${$U.root}`,"data-display":FN(_),"data-layout":g,style:b,...v,children:[(0,K.jsxs)(`div`,{className:`${aW} ${$U.frame} ${URe} ${rW[r]} ${CBe[r]}`.trim(),style:a,children:[(0,K.jsx)(`img`,{alt:o,className:`${nW} ${r===`loaded`?iW:``} ${$U.image}`,height:c,loading:`lazy`,src:n,width:s,style:_.mode===`fixed-height`?{width:`auto`,height:`auto`,maxWidth:`100%`,maxHeight:`100%`}:void 0,onError:()=>i(`error`),onLoad:()=>i(`loaded`)}),r===`loading`&&(0,K.jsx)(`span`,{className:`_1n94osfc ${$U.loader}`}),r===`error`&&(0,K.jsx)(`span`,{className:`_1n94osfd ${$U.errorBadge}`,children:`Image failed to load`}),(0,K.jsx)(_Be,{})]}),l&&(0,K.jsx)(`figcaption`,{className:`_1n94osfe ${$U.caption}`,onClick:y,children:l})]}):(0,K.jsx)(mBe,{}),n&&(0,K.jsx)(pBe,{})]})}function dG({children:e}){return(0,K.jsx)(CRe,{fontCssHref:``,children:e})}var DBe=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=pG(e.state,n.from);return r.line?OBe(e):r.block?ABe(e):!1};function fG(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var OBe=fG(NBe,0),kBe=fG(hG,0),ABe=fG((e,t)=>hG(e,t,MBe(t)),0);function pG(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var mG=50;function jBe(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-mG,r),o=e.sliceDoc(i,i+mG),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+mG),d=e.sliceDoc(i-mG,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function MBe(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function hG(e,t,n=t.selection.ranges){let r=n.map(e=>pG(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>jBe(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function NBe(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=pG(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var gG=dw.define(),PBe=dw.define(),FBe=HC.define(),_G=HC.define({combine(e){return xw(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),vG=JC.define({create(){return OG.empty},update(e,t){let n=t.state.facet(_G),r=t.annotation(gG);if(r){let i=SG.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?CG(o,o.length,n.minDepth,i):EG(o,t.startState.selection),new OG(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(PBe);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(pw.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=SG.fromTransaction(t),o=t.annotation(pw.time),s=t.annotation(pw.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new OG(e.done.map(SG.fromJSON),e.undone.map(SG.fromJSON))}});function IBe(e={}){return[vG,_G.of(e),vO.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?bG:e.inputType==`historyRedo`?xG:null;return n?(e.preventDefault(),n(t)):!1}})]}function yG(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(vG,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var bG=yG(0,!1),xG=yG(1,!1),LBe=yG(0,!0),RBe=yG(1,!0),SG=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&jC.fromJSON(t.changes),[],t.mapped&&AC.fromJSON(t.mapped),t.startSelection&&zC.fromJSON(t.startSelection),t.selectionsAfter.map(zC.fromJSON))}static fromTransaction(t,n){let r=TG;for(let e of t.startState.facet(FBe)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,TG)}static selection(t){return new e(void 0,TG,void 0,void 0,t)}};function CG(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function zBe(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function BBe(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function wG(e,t){return e.length?t.length?e.concat(t):e:t}var TG=[],VBe=200;function EG(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-VBe));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),CG(e,e.length-1,1e9,n.setSelAfter(r)))}return[SG.selection([t])]}function HBe(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function DG(e,t){if(!e.length)return e;let n=e.length,r=TG;for(;n;){let i=UBe(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[SG.selection(r)]:TG}function UBe(e,t,n){let r=wG(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):TG,n);if(!e.changes)return SG.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new SG(i,fw.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var WBe=/^(input\.type|delete)($|\.)/,OG=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||WBe.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,zBe(s.changes,t.changes))||r==`input.type.compose`)?CG(o,o.length-1,i.minDepth,new SG(t.changes.compose(s.changes),wG(fw.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,TG)):CG(o,o.length,i.minDepth,t),new e(o,TG,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:TG;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&BBe(a[a.length-1],t)?this:new e(EG(this.done,t),this.undone,n,r)}addMapping(t){return new e(DG(this.done,t),DG(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:gG.of({side:e,rest:HBe(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?TG:r.slice(0,r.length-1);return i.mapped&&(n=DG(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:gG.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}return null}};OG.empty=new OG(TG,TG);var GBe=[{key:`Mod-z`,run:bG,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:xG,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:xG,preventDefault:!0},{key:`Mod-u`,run:LBe,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:RBe,preventDefault:!0}];function kG(e,t){return zC.create(e.ranges.map(t),e.mainIndex)}function AG(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function jG({state:e,dispatch:t},n){let r=kG(e.selection,n);return!r.eq(e.selection,!0)&&(t(AG(e,r)),!0)}function MG(e,t){return zC.cursor(t?e.to:e.from)}function NG(e,t){return jG(e,n=>n.empty?e.moveByChar(n,t):MG(n,t))}function PG(e){return e.textDirectionAt(e.state.selection.main.head)==qT.LTR}var FG=e=>NG(e,!PG(e)),IG=e=>NG(e,PG(e));function LG(e,t){return jG(e,n=>n.empty?e.moveByGroup(n,t):MG(n,t))}var KBe=e=>LG(e,!PG(e)),qBe=e=>LG(e,PG(e));typeof Intl<`u`&&Intl.Segmenter;function JBe(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function RG(e,t,n){let r=gk(e).resolveInner(t.head),i=n?jS.closedBy:jS.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;JBe(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?zk(e,r.from,1):zk(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,zC.cursor(s,n?-1:1)}var YBe=e=>jG(e,t=>RG(e.state,t,!PG(e))),XBe=e=>jG(e,t=>RG(e.state,t,PG(e)));function zG(e,t){return jG(e,n=>{if(!n.empty)return MG(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var BG=e=>zG(e,!1),VG=e=>zG(e,!0);function HG(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(vO.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function UG(e,t){let n=HG(e),{state:r}=e,i=kG(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):MG(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=vO.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(AG(r,i),{effects:a}),!0}var WG=e=>UG(e,!1),GG=e=>UG(e,!0);function KG(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=zC.cursor(r.from+n))}return i}var ZBe=e=>jG(e,t=>KG(e,t,!0)),QBe=e=>jG(e,t=>KG(e,t,!1)),$Be=e=>jG(e,t=>KG(e,t,!PG(e))),eVe=e=>jG(e,t=>KG(e,t,PG(e))),tVe=e=>jG(e,t=>e.moveToLineBoundary(t,!1,!1)),nVe=e=>jG(e,t=>e.moveToLineBoundary(t,!0,!1));function rVe(e,t,n){let r=!1,i=kG(e.selection,t=>{let i=zk(e,t.head,-1)||zk(e,t.head,1)||t.head>0&&zk(e,t.head-1,1)||t.head<e.doc.length&&zk(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?zC.range(t.anchor,a):zC.cursor(a)});return r?(t(AG(e,i)),!0):!1}var iVe=({state:e,dispatch:t})=>rVe(e,t,!1);function qG(e,t,n){let r=kG(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=zC.range(e.head,e.anchor));let r=n(e);return zC.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(AG(e.state,r)),!0)}function JG(e,t){return qG(e,t,n=>e.moveByChar(n,t))}var YG=e=>JG(e,!PG(e)),XG=e=>JG(e,PG(e));function ZG(e,t){return qG(e,t,n=>e.moveByGroup(n,t))}var aVe=e=>ZG(e,!PG(e)),oVe=e=>ZG(e,PG(e)),sVe=e=>{let t=!PG(e);return qG(e,t,n=>RG(e.state,n,t))},cVe=e=>{let t=PG(e);return qG(e,t,n=>RG(e.state,n,t))};function QG(e,t){return qG(e,t,n=>e.moveVertically(n,t))}var $G=e=>QG(e,!1),eK=e=>QG(e,!0);function tK(e,t){return qG(e,t,n=>e.moveVertically(n,t,HG(e).height))}var nK=e=>tK(e,!1),rK=e=>tK(e,!0),lVe=e=>qG(e,!0,t=>KG(e,t,!0)),uVe=e=>qG(e,!1,t=>KG(e,t,!1)),dVe=e=>{let t=!PG(e);return qG(e,t,n=>KG(e,n,t))},fVe=e=>{let t=PG(e);return qG(e,t,n=>KG(e,n,t))},pVe=e=>qG(e,!1,t=>zC.cursor(e.lineBlockAt(t.head).from)),mVe=e=>qG(e,!0,t=>zC.cursor(e.lineBlockAt(t.head).to)),iK=({state:e,dispatch:t})=>(t(AG(e,{anchor:0})),!0),aK=({state:e,dispatch:t})=>(t(AG(e,{anchor:e.doc.length})),!0),oK=({state:e,dispatch:t})=>(t(AG(e,{anchor:e.selection.main.anchor,head:0})),!0),sK=({state:e,dispatch:t})=>(t(AG(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),hVe=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),gVe=({state:e,dispatch:t})=>{let n=gK(e).map(({from:t,to:n})=>zC.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:zC.create(n),userEvent:`select`})),!0},_Ve=({state:e,dispatch:t})=>{let n=kG(e.selection,t=>{let n=gk(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return zC.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(AG(e,n)),!0)};function cK(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(AG(n,zC.create(i,i.length-1))),!0)}var vVe=e=>cK(e,!1),yVe=e=>cK(e,!0),bVe=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=zC.create([n.main]):n.main.empty||(r=zC.create([zC.cursor(n.main.head)])),r?(t(AG(e,r)),!0):!1};function lK(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=uK(e,o,!1)):o>i&&(n=`delete.forward`,o=uK(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=uK(e,i,!1),a=uK(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:zC.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?vO.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function uK(e,t,n){if(e instanceof vO)for(let r of e.state.facet(vO.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var dK=(e,t,n)=>lK(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=zw(s,a.tabSize)%Ek(a)||Ek(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=DC(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=DC(o.text,c-o.from,!1,!1)+o.from);return c}),fK=e=>dK(e,!1,!0),pK=e=>dK(e,!0,!1),mK=(e,t)=>lK(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=DC(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),hK=e=>mK(e,!1),xVe=e=>mK(e,!0),SVe=e=>lK(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),CVe=e=>lK(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),wVe=e=>lK(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),TVe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:vC.of([``,``])},range:zC.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},EVe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:DC(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:DC(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:zC.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function gK(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function _K(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of gK(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(zC.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(zC.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:zC.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var DVe=({state:e,dispatch:t})=>_K(e,t,!1),OVe=({state:e,dispatch:t})=>_K(e,t,!0);function vK(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of gK(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var kVe=({state:e,dispatch:t})=>vK(e,t,!1),AVe=({state:e,dispatch:t})=>vK(e,t,!0),jVe=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(gK(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=kG(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function MVe(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=gk(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(jS.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var yK=bK(!1),NVe=bK(!0);function bK(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&MVe(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new kk(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=Ok(s,r);for(c??=zw(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,Dk(t,c)];return o&&l.push(Dk(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:vC.of(l)},range:zC.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function xK(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:zC.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var PVe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new kk(e,{overrideIndentation:e=>n[e]??-1}),i=xK(e,(t,i,a)=>{let o=Ok(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=Dk(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},SK=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(xK(e,(t,n)=>{n.push({from:t.from,insert:e.facet(Tk)})}),{userEvent:`input.indent`})),!0),CK=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(xK(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=zw(r,e.tabSize),a=0,o=Dk(e,Math.max(0,i-Ek(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),FVe=e=>(e.setTabFocusMode(),!0),IVe=[{key:`Ctrl-b`,run:FG,shift:YG,preventDefault:!0},{key:`Ctrl-f`,run:IG,shift:XG},{key:`Ctrl-p`,run:BG,shift:$G},{key:`Ctrl-n`,run:VG,shift:eK},{key:`Ctrl-a`,run:tVe,shift:pVe},{key:`Ctrl-e`,run:nVe,shift:mVe},{key:`Ctrl-d`,run:pK},{key:`Ctrl-h`,run:fK},{key:`Ctrl-k`,run:SVe},{key:`Ctrl-Alt-h`,run:hK},{key:`Ctrl-o`,run:TVe},{key:`Ctrl-t`,run:EVe},{key:`Ctrl-v`,run:GG}],LVe=[{key:`ArrowLeft`,run:FG,shift:YG,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:KBe,shift:aVe,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:$Be,shift:dVe,preventDefault:!0},{key:`ArrowRight`,run:IG,shift:XG,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:qBe,shift:oVe,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:eVe,shift:fVe,preventDefault:!0},{key:`ArrowUp`,run:BG,shift:$G,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:iK,shift:oK},{mac:`Ctrl-ArrowUp`,run:WG,shift:nK},{key:`ArrowDown`,run:VG,shift:eK,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:aK,shift:sK},{mac:`Ctrl-ArrowDown`,run:GG,shift:rK},{key:`PageUp`,run:WG,shift:nK},{key:`PageDown`,run:GG,shift:rK},{key:`Home`,run:QBe,shift:uVe,preventDefault:!0},{key:`Mod-Home`,run:iK,shift:oK},{key:`End`,run:ZBe,shift:lVe,preventDefault:!0},{key:`Mod-End`,run:aK,shift:sK},{key:`Enter`,run:yK,shift:yK},{key:`Mod-a`,run:hVe},{key:`Backspace`,run:fK,shift:fK,preventDefault:!0},{key:`Delete`,run:pK,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:hK,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:xVe,preventDefault:!0},{mac:`Mod-Backspace`,run:CVe,preventDefault:!0},{mac:`Mod-Delete`,run:wVe,preventDefault:!0}].concat(IVe.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),RVe=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:YBe,shift:sVe},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:XBe,shift:cVe},{key:`Alt-ArrowUp`,run:DVe},{key:`Shift-Alt-ArrowUp`,run:kVe},{key:`Alt-ArrowDown`,run:OVe},{key:`Shift-Alt-ArrowDown`,run:AVe},{key:`Mod-Alt-ArrowUp`,run:vVe},{key:`Mod-Alt-ArrowDown`,run:yVe},{key:`Escape`,run:bVe},{key:`Mod-Enter`,run:NVe},{key:`Alt-l`,mac:`Ctrl-l`,run:gVe},{key:`Mod-i`,run:_Ve,preventDefault:!0},{key:`Mod-[`,run:CK},{key:`Mod-]`,run:SK},{key:`Mod-Alt-\\`,run:PVe},{key:`Shift-Mod-k`,run:jVe},{key:`Shift-Mod-\\`,run:iVe},{key:`Mod-/`,run:DBe},{key:`Alt-A`,mac:`Ctrl-A`,run:kBe},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:FVe}].concat(LVe),zVe={key:`Tab`,run:SK,shift:CK};function wK(e){return new wk(sCe.define(e))}function TK(e){return r(()=>import(`./dist-D8T-VMuH.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([29,30,31]),import.meta.url)}var BVe=[J.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return r(()=>import(`./dist-DknksWkX.js`).then(e=>e.cpp()),__vite__mapDeps([32,30]),import.meta.url)}}),J.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return r(()=>import(`./dist-DknksWkX.js`).then(e=>e.cpp()),__vite__mapDeps([32,30]),import.meta.url)}}),J.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return TK(`Cassandra`)}}),J.of({name:`CSS`,extensions:[`css`],load(){return r(()=>import(`./dist-SwdVvEpO.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([33,1,30]),import.meta.url)}}),J.of({name:`Go`,extensions:[`go`],load(){return r(()=>import(`./dist-f8YElrUw.js`).then(e=>e.go()),__vite__mapDeps([34,30,31]),import.meta.url)}}),J.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return r(()=>import(`./dist-IhKVX0N7.js`).then(e=>e.html()),__vite__mapDeps([35,30,33,1,36,31]),import.meta.url)}}),J.of({name:`Java`,extensions:[`java`],load(){return r(()=>import(`./dist-Do_0jRES.js`).then(e=>e.java()),__vite__mapDeps([37,30]),import.meta.url)}}),J.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return r(()=>import(`./dist-BKkO1Omj.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([36,1,30,31]),import.meta.url)}}),J.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return r(()=>import(`./dist-i1Gf9O6b.js`).then(e=>e.jinja()),__vite__mapDeps([38,35,30,33,1,36,31]),import.meta.url)}}),J.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return r(()=>import(`./dist-Ci8SGeFw.js`).then(e=>e.json()),__vite__mapDeps([39,30]),import.meta.url)}}),J.of({name:`JSX`,extensions:[`jsx`],load(){return r(()=>import(`./dist-BKkO1Omj.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([36,1,30,31]),import.meta.url)}}),J.of({name:`LESS`,extensions:[`less`],load(){return r(()=>import(`./dist-DQI2slI5.js`).then(e=>e.less()),__vite__mapDeps([40,33,1,30]),import.meta.url)}}),J.of({name:`Liquid`,extensions:[`liquid`],load(){return r(()=>import(`./dist-V7e95zqk.js`).then(e=>e.liquid()),__vite__mapDeps([41,35,30,33,1,36,31]),import.meta.url)}}),J.of({name:`MariaDB SQL`,load(){return TK(`MariaSQL`)}}),J.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return r(()=>import(`./dist-DW1-cTNS.js`).then(e=>e.markdown()),__vite__mapDeps([42,31,35,30,33,1,36]),import.meta.url)}}),J.of({name:`MS SQL`,load(){return TK(`MSSQL`)}}),J.of({name:`MySQL`,load(){return TK(`MySQL`)}}),J.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return r(()=>import(`./dist-CvSBK4r1.js`).then(e=>e.php()),__vite__mapDeps([43,30,35,33,1,36,31]),import.meta.url)}}),J.of({name:`PLSQL`,extensions:[`pls`],load(){return TK(`PLSQL`)}}),J.of({name:`PostgreSQL`,load(){return TK(`PostgreSQL`)}}),J.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return r(()=>import(`./dist-Bo1t4X-Z.js`).then(e=>e.python()),__vite__mapDeps([44,30,31]),import.meta.url)}}),J.of({name:`Rust`,extensions:[`rs`],load(){return r(()=>import(`./dist-CskHZfMU.js`).then(e=>e.rust()),__vite__mapDeps([45,30]),import.meta.url)}}),J.of({name:`Sass`,extensions:[`sass`],load(){return r(()=>import(`./dist-BI0qFRAy.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([46,30,33,1]),import.meta.url)}}),J.of({name:`SCSS`,extensions:[`scss`],load(){return r(()=>import(`./dist-BI0qFRAy.js`).then(e=>e.sass()),__vite__mapDeps([46,30,33,1]),import.meta.url)}}),J.of({name:`SQL`,extensions:[`sql`],load(){return TK(`StandardSQL`)}}),J.of({name:`SQLite`,load(){return TK(`SQLite`)}}),J.of({name:`TSX`,extensions:[`tsx`],load(){return r(()=>import(`./dist-BKkO1Omj.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([36,1,30,31]),import.meta.url)}}),J.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return r(()=>import(`./dist-BKkO1Omj.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([36,1,30,31]),import.meta.url)}}),J.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return r(()=>import(`./dist-DqZiUlRF.js`).then(e=>e.wast()),__vite__mapDeps([47,30]),import.meta.url)}}),J.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return r(()=>import(`./dist-D0fC7ysz.js`).then(e=>e.xml()),__vite__mapDeps([48,30]),import.meta.url)}}),J.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return r(()=>import(`./dist-h2T27ekx.js`).then(e=>e.yaml()),__vite__mapDeps([49,30]),import.meta.url)}}),J.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return r(()=>import(`./apl-gfMMiTNf.js`).then(e=>wK(e.apl)),[],import.meta.url)}}),J.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return r(()=>import(`./asciiarmor-C_eisQCp.js`).then(e=>wK(e.asciiArmor)),[],import.meta.url)}}),J.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return r(()=>import(`./asn1-DCl_8MCW.js`).then(e=>wK(e.asn1({}))),[],import.meta.url)}}),J.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return r(()=>import(`./asterisk-BEn0Cwpx.js`).then(e=>wK(e.asterisk)),[],import.meta.url)}}),J.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return r(()=>import(`./brainfuck-D5EjA2JK.js`).then(e=>wK(e.brainfuck)),[],import.meta.url)}}),J.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return r(()=>import(`./cobol-DHLQUbN7.js`).then(e=>wK(e.cobol)),[],import.meta.url)}}),J.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return r(()=>import(`./clike-xvONpD0Z.js`).then(e=>wK(e.csharp)),[],import.meta.url)}}),J.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return r(()=>import(`./clojure-BflJGmDX.js`).then(e=>wK(e.clojure)),[],import.meta.url)}}),J.of({name:`ClojureScript`,extensions:[`cljs`],load(){return r(()=>import(`./clojure-BflJGmDX.js`).then(e=>wK(e.clojure)),[],import.meta.url)}}),J.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return r(()=>import(`./css-CnaYoQib.js`).then(e=>wK(e.gss)),[],import.meta.url)}}),J.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return r(()=>import(`./cmake-84nbDH0I.js`).then(e=>wK(e.cmake)),[],import.meta.url)}}),J.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return r(()=>import(`./coffeescript-De_zI4J0.js`).then(e=>wK(e.coffeeScript)),[],import.meta.url)}}),J.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return r(()=>import(`./commonlisp-DgAKBe0r.js`).then(e=>wK(e.commonLisp)),[],import.meta.url)}}),J.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return r(()=>import(`./cypher-p9eYesGn.js`).then(e=>wK(e.cypher)),[],import.meta.url)}}),J.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return r(()=>import(`./python-B_1Jd8HM.js`).then(e=>wK(e.cython)),[],import.meta.url)}}),J.of({name:`Crystal`,extensions:[`cr`],load(){return r(()=>import(`./crystal-Bl6YKCG_.js`).then(e=>wK(e.crystal)),[],import.meta.url)}}),J.of({name:`D`,extensions:[`d`],load(){return r(()=>import(`./d-DWkQyNnU.js`).then(e=>wK(e.d)),[],import.meta.url)}}),J.of({name:`Dart`,extensions:[`dart`],load(){return r(()=>import(`./clike-xvONpD0Z.js`).then(e=>wK(e.dart)),[],import.meta.url)}}),J.of({name:`diff`,extensions:[`diff`,`patch`],load(){return r(()=>import(`./diff-ChtP43wD.js`).then(e=>wK(e.diff)),[],import.meta.url)}}),J.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return r(()=>import(`./dockerfile-DJkHQgkl.js`).then(e=>wK(e.dockerFile)),__vite__mapDeps([50,51]),import.meta.url)}}),J.of({name:`DTD`,extensions:[`dtd`],load(){return r(()=>import(`./dtd-DTF72YNO.js`).then(e=>wK(e.dtd)),[],import.meta.url)}}),J.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return r(()=>import(`./dylan-S7ucR4pR.js`).then(e=>wK(e.dylan)),[],import.meta.url)}}),J.of({name:`EBNF`,load(){return r(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>wK(e.ebnf)),[],import.meta.url)}}),J.of({name:`ECL`,extensions:[`ecl`],load(){return r(()=>import(`./ecl-BVIeWmwY.js`).then(e=>wK(e.ecl)),[],import.meta.url)}}),J.of({name:`edn`,extensions:[`edn`],load(){return r(()=>import(`./clojure-BflJGmDX.js`).then(e=>wK(e.clojure)),[],import.meta.url)}}),J.of({name:`Eiffel`,extensions:[`e`],load(){return r(()=>import(`./eiffel-BEjRio4Q.js`).then(e=>wK(e.eiffel)),[],import.meta.url)}}),J.of({name:`Elm`,extensions:[`elm`],load(){return r(()=>import(`./elm-Cshzl8qu.js`).then(e=>wK(e.elm)),[],import.meta.url)}}),J.of({name:`Erlang`,extensions:[`erl`],load(){return r(()=>import(`./erlang-BV0c4Hdn.js`).then(e=>wK(e.erlang)),[],import.meta.url)}}),J.of({name:`Esper`,load(){return r(()=>import(`./sql-DuQMFDvy.js`).then(e=>wK(e.esper)),[],import.meta.url)}}),J.of({name:`Factor`,extensions:[`factor`],load(){return r(()=>import(`./factor-LKH5gN8L.js`).then(e=>wK(e.factor)),__vite__mapDeps([52,51]),import.meta.url)}}),J.of({name:`FCL`,load(){return r(()=>import(`./fcl-ClOhbFR7.js`).then(e=>wK(e.fcl)),[],import.meta.url)}}),J.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return r(()=>import(`./forth-D6RzAl64.js`).then(e=>wK(e.forth)),[],import.meta.url)}}),J.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return r(()=>import(`./fortran-Bt6PBEDR.js`).then(e=>wK(e.fortran)),[],import.meta.url)}}),J.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return r(()=>import(`./mllike-B45xgp2S.js`).then(e=>wK(e.fSharp)),[],import.meta.url)}}),J.of({name:`Gas`,extensions:[`s`],load(){return r(()=>import(`./gas-BHEdbvp9.js`).then(e=>wK(e.gas)),[],import.meta.url)}}),J.of({name:`Gherkin`,extensions:[`feature`],load(){return r(()=>import(`./gherkin-oBAE_ms0.js`).then(e=>wK(e.gherkin)),[],import.meta.url)}}),J.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return r(()=>import(`./groovy-CUrWKPia.js`).then(e=>wK(e.groovy)),[],import.meta.url)}}),J.of({name:`Haskell`,extensions:[`hs`],load(){return r(()=>import(`./haskell-BRsoo5mP.js`).then(e=>wK(e.haskell)),[],import.meta.url)}}),J.of({name:`Haxe`,extensions:[`hx`],load(){return r(()=>import(`./haxe-DjVOVvNP.js`).then(e=>wK(e.haxe)),[],import.meta.url)}}),J.of({name:`HXML`,extensions:[`hxml`],load(){return r(()=>import(`./haxe-DjVOVvNP.js`).then(e=>wK(e.hxml)),[],import.meta.url)}}),J.of({name:`HTTP`,load(){return r(()=>import(`./http-CLVgA2GD.js`).then(e=>wK(e.http)),[],import.meta.url)}}),J.of({name:`IDL`,extensions:[`pro`],load(){return r(()=>import(`./idl-BUZw3wgd.js`).then(e=>wK(e.idl)),[],import.meta.url)}}),J.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return r(()=>import(`./javascript-lS2r2ifg.js`).then(e=>wK(e.jsonld)),[],import.meta.url)}}),J.of({name:`Julia`,extensions:[`jl`],load(){return r(()=>import(`./julia-CQfgDRfP.js`).then(e=>wK(e.julia)),[],import.meta.url)}}),J.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return r(()=>import(`./clike-xvONpD0Z.js`).then(e=>wK(e.kotlin)),[],import.meta.url)}}),J.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return r(()=>import(`./livescript-BXxG0Yva.js`).then(e=>wK(e.liveScript)),[],import.meta.url)}}),J.of({name:`Lua`,extensions:[`lua`],load(){return r(()=>import(`./lua-DPCEkfD_.js`).then(e=>wK(e.lua)),[],import.meta.url)}}),J.of({name:`mIRC`,extensions:[`mrc`],load(){return r(()=>import(`./mirc-C9zpzAZU.js`).then(e=>wK(e.mirc)),[],import.meta.url)}}),J.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return r(()=>import(`./mathematica-u8YMmbU0.js`).then(e=>wK(e.mathematica)),[],import.meta.url)}}),J.of({name:`Modelica`,extensions:[`mo`],load(){return r(()=>import(`./modelica-CqHI_q-D.js`).then(e=>wK(e.modelica)),[],import.meta.url)}}),J.of({name:`MUMPS`,extensions:[`mps`],load(){return r(()=>import(`./mumps-BSzj6Xyz.js`).then(e=>wK(e.mumps)),[],import.meta.url)}}),J.of({name:`Mbox`,extensions:[`mbox`],load(){return r(()=>import(`./mbox-BEMVcqjs.js`).then(e=>wK(e.mbox)),[],import.meta.url)}}),J.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return r(()=>import(`./nginx-C-ORUuei.js`).then(e=>wK(e.nginx)),[],import.meta.url)}}),J.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return r(()=>import(`./nsis-viPvXFiq.js`).then(e=>wK(e.nsis)),__vite__mapDeps([53,51]),import.meta.url)}}),J.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return r(()=>import(`./ntriples-CzMBulkp.js`).then(e=>wK(e.ntriples)),[],import.meta.url)}}),J.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return r(()=>import(`./clike-xvONpD0Z.js`).then(e=>wK(e.objectiveC)),[],import.meta.url)}}),J.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return r(()=>import(`./clike-xvONpD0Z.js`).then(e=>wK(e.objectiveCpp)),[],import.meta.url)}}),J.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return r(()=>import(`./mllike-B45xgp2S.js`).then(e=>wK(e.oCaml)),[],import.meta.url)}}),J.of({name:`Octave`,extensions:[`m`],load(){return r(()=>import(`./octave-D2Q8cUp1.js`).then(e=>wK(e.octave)),[],import.meta.url)}}),J.of({name:`Oz`,extensions:[`oz`],load(){return r(()=>import(`./oz-BwTct_5T.js`).then(e=>wK(e.oz)),[],import.meta.url)}}),J.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return r(()=>import(`./pascal-Dp_KdFgX.js`).then(e=>wK(e.pascal)),[],import.meta.url)}}),J.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return r(()=>import(`./perl-BkSkiI9m.js`).then(e=>wK(e.perl)),[],import.meta.url)}}),J.of({name:`Pig`,extensions:[`pig`],load(){return r(()=>import(`./pig-AF4Hwhju.js`).then(e=>wK(e.pig)),[],import.meta.url)}}),J.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return r(()=>import(`./powershell-D8WpQPaX.js`).then(e=>wK(e.powerShell)),[],import.meta.url)}}),J.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return r(()=>import(`./properties-C357ku5U.js`).then(e=>wK(e.properties)),[],import.meta.url)}}),J.of({name:`ProtoBuf`,extensions:[`proto`],load(){return r(()=>import(`./protobuf-D1ij_kNL.js`).then(e=>wK(e.protobuf)),[],import.meta.url)}}),J.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return r(()=>import(`./pug-BqCHZ5xT.js`).then(e=>wK(e.pug)),__vite__mapDeps([54,55]),import.meta.url)}}),J.of({name:`Puppet`,extensions:[`pp`],load(){return r(()=>import(`./puppet-BZyAS7I4.js`).then(e=>wK(e.puppet)),[],import.meta.url)}}),J.of({name:`Q`,extensions:[`q`],load(){return r(()=>import(`./q-B9NhS7L_.js`).then(e=>wK(e.q)),[],import.meta.url)}}),J.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return r(()=>import(`./r-CxDmU1I4.js`).then(e=>wK(e.r)),[],import.meta.url)}}),J.of({name:`RPM Changes`,load(){return r(()=>import(`./rpm-gpDK5sbt.js`).then(e=>wK(e.rpmChanges)),[],import.meta.url)}}),J.of({name:`RPM Spec`,extensions:[`spec`],load(){return r(()=>import(`./rpm-gpDK5sbt.js`).then(e=>wK(e.rpmSpec)),[],import.meta.url)}}),J.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return r(()=>import(`./ruby-ChfNwlCY.js`).then(e=>wK(e.ruby)),[],import.meta.url)}}),J.of({name:`SAS`,extensions:[`sas`],load(){return r(()=>import(`./sas-C2OyD2Y6.js`).then(e=>wK(e.sas)),[],import.meta.url)}}),J.of({name:`Scala`,extensions:[`scala`],load(){return r(()=>import(`./clike-xvONpD0Z.js`).then(e=>wK(e.scala)),[],import.meta.url)}}),J.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return r(()=>import(`./scheme-D9qYN0V5.js`).then(e=>wK(e.scheme)),[],import.meta.url)}}),J.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return r(()=>import(`./shell-DwuoZtxw.js`).then(e=>wK(e.shell)),[],import.meta.url)}}),J.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return r(()=>import(`./sieve-tLWDfEkZ.js`).then(e=>wK(e.sieve)),[],import.meta.url)}}),J.of({name:`Smalltalk`,extensions:[`st`],load(){return r(()=>import(`./smalltalk-BLp5-jwC.js`).then(e=>wK(e.smalltalk)),[],import.meta.url)}}),J.of({name:`Solr`,load(){return r(()=>import(`./solr-B78wSQJQ.js`).then(e=>wK(e.solr)),[],import.meta.url)}}),J.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return r(()=>import(`./mllike-B45xgp2S.js`).then(e=>wK(e.sml)),[],import.meta.url)}}),J.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return r(()=>import(`./sparql-Dz-mlCAC.js`).then(e=>wK(e.sparql)),[],import.meta.url)}}),J.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return r(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>wK(e.spreadsheet)),[],import.meta.url)}}),J.of({name:`Squirrel`,extensions:[`nut`],load(){return r(()=>import(`./clike-xvONpD0Z.js`).then(e=>wK(e.squirrel)),[],import.meta.url)}}),J.of({name:`Stylus`,extensions:[`styl`],load(){return r(()=>import(`./stylus-BOVgKnng.js`).then(e=>wK(e.stylus)),[],import.meta.url)}}),J.of({name:`Swift`,extensions:[`swift`],load(){return r(()=>import(`./swift-DKB6_1j6.js`).then(e=>wK(e.swift)),[],import.meta.url)}}),J.of({name:`sTeX`,load(){return r(()=>import(`./stex-DNzd62Q_.js`).then(e=>wK(e.stex)),[],import.meta.url)}}),J.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return r(()=>import(`./stex-DNzd62Q_.js`).then(e=>wK(e.stex)),[],import.meta.url)}}),J.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return r(()=>import(`./verilog-CjI9Y6RI.js`).then(e=>wK(e.verilog)),[],import.meta.url)}}),J.of({name:`Tcl`,extensions:[`tcl`],load(){return r(()=>import(`./tcl-BGfruO1u.js`).then(e=>wK(e.tcl)),[],import.meta.url)}}),J.of({name:`Textile`,extensions:[`textile`],load(){return r(()=>import(`./textile-C4jVoHG1.js`).then(e=>wK(e.textile)),[],import.meta.url)}}),J.of({name:`TiddlyWiki`,load(){return r(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>wK(e.tiddlyWiki)),[],import.meta.url)}}),J.of({name:`Tiki wiki`,load(){return r(()=>import(`./tiki-CvUEFusT.js`).then(e=>wK(e.tiki)),[],import.meta.url)}}),J.of({name:`TOML`,extensions:[`toml`],load(){return r(()=>import(`./toml-BPTmHmyx.js`).then(e=>wK(e.toml)),[],import.meta.url)}}),J.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return r(()=>import(`./troff-C2dAgh7P.js`).then(e=>wK(e.troff)),[],import.meta.url)}}),J.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return r(()=>import(`./ttcn-PPSTk1ow.js`).then(e=>wK(e.ttcn)),[],import.meta.url)}}),J.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return r(()=>import(`./ttcn-cfg-2b4Gb5sE.js`).then(e=>wK(e.ttcnCfg)),[],import.meta.url)}}),J.of({name:`Turtle`,extensions:[`ttl`],load(){return r(()=>import(`./turtle-Cx3rYX2g.js`).then(e=>wK(e.turtle)),[],import.meta.url)}}),J.of({name:`Web IDL`,extensions:[`webidl`],load(){return r(()=>import(`./webidl-D5jiJvOU.js`).then(e=>wK(e.webIDL)),[],import.meta.url)}}),J.of({name:`VB.NET`,extensions:[`vb`],load(){return r(()=>import(`./vb-BthdM_4N.js`).then(e=>wK(e.vb)),[],import.meta.url)}}),J.of({name:`VBScript`,extensions:[`vbs`],load(){return r(()=>import(`./vbscript-D9f6rSsU.js`).then(e=>wK(e.vbScript)),[],import.meta.url)}}),J.of({name:`Velocity`,extensions:[`vtl`],load(){return r(()=>import(`./velocity-CqftRsjg.js`).then(e=>wK(e.velocity)),[],import.meta.url)}}),J.of({name:`Verilog`,extensions:[`v`],load(){return r(()=>import(`./verilog-CjI9Y6RI.js`).then(e=>wK(e.verilog)),[],import.meta.url)}}),J.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return r(()=>import(`./vhdl-kS471soi.js`).then(e=>wK(e.vhdl)),[],import.meta.url)}}),J.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return r(()=>import(`./xquery-BKJx4mf9.js`).then(e=>wK(e.xQuery)),[],import.meta.url)}}),J.of({name:`Yacas`,extensions:[`ys`],load(){return r(()=>import(`./yacas-CXXgtw0p.js`).then(e=>wK(e.yacas)),[],import.meta.url)}}),J.of({name:`Z80`,extensions:[`z80`],load(){return r(()=>import(`./z80-Co3PbHdE.js`).then(e=>wK(e.z80)),[],import.meta.url)}}),J.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return r(()=>import(`./mscgen-qgSLujhx.js`).then(e=>wK(e.mscgen)),[],import.meta.url)}}),J.of({name:`Xù`,extensions:[`xu`],load(){return r(()=>import(`./mscgen-qgSLujhx.js`).then(e=>wK(e.xu)),[],import.meta.url)}}),J.of({name:`MsGenny`,extensions:[`msgenny`],load(){return r(()=>import(`./mscgen-qgSLujhx.js`).then(e=>wK(e.msgenny)),[],import.meta.url)}}),J.of({name:`Vue`,extensions:[`vue`],load(){return r(()=>import(`./dist-3kOakO1C.js`).then(e=>e.vue()),__vite__mapDeps([56,35,30,33,1,36,31]),import.meta.url)}}),J.of({name:`Angular Template`,load(){return r(()=>import(`./dist-1y-5eBAw.js`).then(e=>e.angular()),__vite__mapDeps([57,35,30,33,1,36,31]),import.meta.url)}})],VVe={c:[`c`],cpp:[`c++`,`cpp`],cs:[`c#`,`csharp`],js:[`javascript`],jsx:[`javascript jsx`,`jsx`],md:[`markdown`],py:[`python`],sh:[`shell`,`bash`],ts:[`typescript`],tsx:[`typescript jsx`,`tsx`],yml:[`yaml`],zsh:[`shell`,`bash`]};function HVe(e){let t=e===`plaintext`?`text`:e;return[t,...VVe[t]??[]]}async function UVe(e){if(e===`text`)return[];let t=HVe(e);for(let e of t){let t=J.matchLanguageName(BVe,e,!0);if(t)try{return await t.load()}catch{}}return[]}function WVe(e){let{main:t}=e.state.selection;return t.empty?e.state.doc.lineAt(t.head).number===1:!1}function GVe(e){let{main:t}=e.state.selection;return t.empty?e.state.doc.lineAt(t.head).number===e.state.doc.lines:!1}var KVe=vO.theme({"&":{backgroundColor:`transparent`},"&.cm-editor":{outline:`none`},"&.cm-editor.cm-focused":{outline:`none`},"&.cm-editor .cm-gutters":{backgroundColor:`var(--cm-gutter-bg, transparent)`,border:`none`},".cm-scroller":{overflow:`auto`,fontFamily:`inherit`},".cm-content":{minHeight:`1.5em`},".cm-selectionBackground":{backgroundColor:`rgba(125, 125, 125, 0.26) !important`}});function qVe(e){return e&&e.trim().toLowerCase()||`text`}var JVe={"":!0,text:!0,plaintext:!0,plain:!0,txt:!0},YVe={sh:!0,bash:!0,shell:!0,zsh:!0,console:!0};function XVe(e,t){let n=e.trim().toLowerCase();return Object.hasOwn(JVe,n)?`text`:Object.hasOwn(YVe,n)&&!t.trimEnd().includes(`
|
|
199
|
-
`)?`shell-line`:`code`}var ZVe=QSe(KO([{tag:[ck.keyword,ck.bool,ck.null,ck.atom],class:`ryugi-tok-kw`},{tag:ck.number,class:`ryugi-tok-num`},{tag:[ck.string,ck.regexp,ck.character],class:`ryugi-tok-str`},{tag:ck.comment,class:`ryugi-tok-cm`},{tag:[ck.punctuation,ck.operator],class:`ryugi-tok-punc`}])),EK=uee.map(({id:e,name:t})=>({id:e,name:t})),QVe=()=>`$`;function DK(e,t){return t||e===`text`?[]:e===`shell-line`?zO({formatNumber:QVe}):zO()}function $Ve({language:e,onChange:t}){let[n,r]=(0,G.useState)(``),a=(0,G.useMemo)(()=>EK.find(t=>t.id===e)??(e===`text`?null:{id:e,name:e}),[e]),o=(0,G.useMemo)(()=>{let e=a&&!EK.includes(a)?[...EK,a]:EK,t=n.trim().toLowerCase();return!t||e.some(e=>e.id===t)?e:[...e,{id:t,name:t}]},[n,a]);return(0,K.jsxs)(V,{autoHighlight:!0,itemToStringLabel:e=>e.id,itemToStringValue:e=>e.id,items:o,value:a,onInputValueChange:r,onValueChange:e=>e&&t?.(e.id),children:[(0,K.jsx)(yee,{"aria-label":i(`codeblock.language`),className:`ryugi-codeblock-picker`,placeholder:i(`codeblock.language`),onKeyDown:e=>e.stopPropagation()}),(0,K.jsxs)(See,{align:`start`,side:`bottom`,sideOffset:6,children:[(0,K.jsx)(ke,{children:i(`codeblock.noLanguage`)}),(0,K.jsx)(Ce,{children:e=>(0,K.jsx)(wee,{value:e,children:e.name},e.id)})]})]})}function OK({code:e,language:t,editable:n=!1,selected:r=!1,cursorPlacement:a=`start`,onCodeChange:o,onLanguageChange:s,onDelete:
|
|
200
|
-
`).length,
|
|
198
|
+
`)}}var DU=(0,G.createContext)({});function CRe({apiUrl:e,fontCssHref:t,saveSnapshot:n,uploadFile:r,children:i}){let a=(0,G.useMemo)(()=>({apiUrl:e,fontCssHref:t,saveSnapshot:n,uploadFile:r}),[e,t,n,r]);return(0,K.jsx)(DU.Provider,{value:a,children:i})}function OU(){return(0,G.use)(DU)}function kU(e){return!e||typeof e!=`object`?null:!Array.isArray(e.elements)&&e.data!==void 0?kU(e.data):{type:`excalidraw`,elements:Array.isArray(e.elements)?e.elements:[],appState:e.appState??{},files:e.files??{}}}function AU(e){return e.elements.filter(e=>!e.isDeleted).length}function jU(e,t){let n=e;return e.startsWith(`http`)||e.startsWith(`blob:`)||TU(e)?{fetchUrl:e,refLine:n}:e.startsWith(`ref:`)&&t?{fetchUrl:`${t}/objects/${e.slice(4)}`,refLine:n}:{error:e.startsWith(`ref:`)?`Missing apiUrl for ref resolution`:`Unrecognized snapshot format`}}function MU(e,t){switch(e.type){case`inline`:return{type:`inline`,snapshot:e.data};case`remote`:{let n=jU(e.url,t);return`error`in n?{type:`error`,error:n.error}:{type:`remote`,fetchUrl:n.fetchUrl,refLine:n.refLine}}case`delta`:{let n=jU(e.baseUrl,t);return`error`in n?{type:`error`,error:n.error}:{type:`incremental`,fetchUrl:n.fetchUrl,refLine:n.refLine,delta:e.delta}}}}function wRe(e,t){if(!e.trim())return{type:`empty`};let n=EU(e);return n?MU(n,t):{type:`error`,error:`Unrecognized snapshot format`}}function NU(e){let{apiUrl:t}=OU(),n=(0,G.useMemo)(()=>e==null?{type:`empty`}:typeof e==`string`?wRe(e,t):MU(e,t),[e,t]),[i,a]=(0,G.useState)(),[o,s]=(0,G.useState)(),[c,l]=(0,G.useState)(n.type===`remote`||n.type===`incremental`),[u,d]=(0,G.useState)(``),[f,p]=(0,G.useState)(0),m=(0,G.useCallback)(()=>p(e=>e+1),[]);return(0,G.useEffect)(()=>{if(n.type!==`remote`&&n.type!==`incremental`)return;let{fetchUrl:e}=n,t=n.type===`incremental`?n.delta:void 0,i=!1;return l(!0),d(``),fetch(e).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(async e=>{if(!i){if(s(e),(t?Object.keys(t):[]).length>0){let{patch:n}=await r(async()=>{let{patch:e}=await import(`./lib-DJrc3aG3.js`);return{patch:e}},[],import.meta.url);if(i)return;let o=n(structuredClone(e),t);a(o)}else a(e);l(!1)}}).catch(e=>{i||(d(e instanceof Error?e.message:`Failed to load`),l(!1))}),()=>{i=!0}},[n,f]),n.type===`inline`?{snapshot:n.snapshot,loading:!1,error:``,retry:m,retryable:!1}:n.type===`remote`||n.type===`incremental`?{snapshot:i,loading:c,error:u,retry:m,retryable:!!u,baseRef:n.refLine,baseData:o}:n.type===`error`?{snapshot:void 0,loading:!1,error:n.error,retry:m,retryable:!1}:{snapshot:void 0,loading:!1,error:``,retry:m,retryable:!1}}var TRe=`https://cdn.jsdelivr.net/npm/lxgw-wenkai-screen-webfont/style.css`;function PU(){let{fontCssHref:e=TRe}=OU();(0,G.useEffect)(()=>{if(!e||typeof document>`u`||document.head.querySelector(`link[href="${CSS.escape(e)}"]`))return;let t=document.createElement(`link`);t.rel=`stylesheet`,t.href=e,document.head.append(t)},[e])}var ERe=({elementCount:e})=>{let t=e?`Whiteboard · ${e} elements`:`Whiteboard`;return(0,K.jsxs)(`div`,{"aria-label":t,className:cRe,children:[(0,K.jsx)(Fr,{"aria-hidden":!0,className:lRe}),(0,K.jsx)(`span`,{children:t})]})},FU=()=>(0,K.jsx)(`div`,{"aria-busy":!0,className:uRe,children:(0,K.jsx)(`span`,{children:`Loading whiteboard…`})}),IU=()=>(0,K.jsx)(`div`,{className:dRe,children:(0,K.jsx)(`span`,{children:`Empty whiteboard`})}),LU=({message:e,onRetry:t})=>(0,K.jsxs)(`div`,{className:fRe,role:`alert`,children:[(0,K.jsx)(x,{"aria-hidden":!0,className:pRe}),(0,K.jsx)(`span`,{children:e}),t&&(0,K.jsx)(`button`,{className:`_1xd3mo4a`,type:`button`,onClick:t,children:`Retry`})]}),DRe=CU({WhiteboardDisplayRenderer:()=>RU}),RU=({onExpand:e,snapshot:t})=>{let n=lF(),{snapshot:r,loading:i,error:a,retry:o,retryable:s}=NU(t),c=(0,G.useMemo)(()=>kU(r),[r]);PU();let l=(0,G.useCallback)(t=>{e&&c&&e({content:(0,K.jsx)(bn,{mode:`fullscreen`,scene:c,theme:n}),elementCount:AU(c),target:t,theme:n})},[e,c,n]),u;return u=i?(0,K.jsx)(FU,{}):a?(0,K.jsx)(LU,{message:a,onRetry:s?o:void 0}):r?c?AU(c)===0?(0,K.jsx)(IU,{}):(0,K.jsx)(ORe,{fallback:(0,K.jsx)(LU,{message:`Failed to render whiteboard`}),children:(0,K.jsx)(bn,{scene:c,theme:n,onExpand:e?l:void 0})}):(0,K.jsx)(LU,{message:`Invalid whiteboard data`}):(0,K.jsx)(IU,{}),(0,K.jsx)(`div`,{className:oRe,"data-theme":n,children:u})},ORe=class extends G.Component{constructor(...e){super(...e),Cr(this,`state`,{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}},kRe=(0,G.lazy)(()=>Promise.resolve().then(()=>DRe).then(e=>({default:e.WhiteboardDisplayRenderer})));function ARe(e){try{let t=JSON.parse(e);if(t&&typeof t==`object`&&Array.isArray(t.elements))return t.elements.filter(e=>!e?.isDeleted).length}catch{}}var zU=({snapshot:e})=>(0,K.jsx)(`div`,{className:sRe,children:(0,K.jsx)(ERe,{elementCount:ARe(e)})}),jRe=({onExpand:e,snapshot:t})=>(0,K.jsx)(at,{fallback:(0,K.jsx)(zU,{snapshot:t}),children:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(zU,{snapshot:t}),children:(0,K.jsx)(kRe,{snapshot:t,onExpand:e})})}),BU=class e extends wr{static getType(){return`excalidraw`}static clone(t){return new e(t.__snapshot,t.__key)}constructor(e,t){super(t),Cr(this,`__snapshot`,void 0),this.__snapshot=e}createDOM(e){let t=document.createElement(`div`);return t.className=`rich-excalidraw-wrapper`,t}updateDOM(){return!1}isInline(){return!1}static importJSON(e){return MRe(e.snapshot).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:`excalidraw`,snapshot:this.__snapshot,version:1}}getSnapshot(){return this.__snapshot}setSnapshot(e){let t=this.getWritable();t.__snapshot=e}decorate(e,t){return qj(aRe,jRe,{snapshot:this.__snapshot})}};function MRe(e){return new BU(e)}function NRe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function PRe(e){var t=NRe(e,`string`);return typeof t==`symbol`?t:String(t)}function FRe(e,t,n){return t=PRe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function VU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function HU(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?VU(Object(n),!0).forEach(function(t){FRe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):VU(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function UU(e,t){var n={};for(var r in e)n[r]=t(e[r],r);return n}var IRe=(e,t,n)=>{for(var r of Object.keys(e))if(e[r]!==(t[r]??n[r]))return!1;return!0},LRe=e=>{var t=t=>{var n=e.defaultClassName,r=HU(HU({},e.defaultVariants),t);for(var i in r){var a=r[i]??e.defaultVariants[i];if(a!=null){var o=a;typeof o==`boolean`&&(o=o===!0?`true`:`false`);var s=e.variantClassNames[i][o];s&&(n+=` `+s)}}for(var[c,l]of e.compoundVariants)IRe(c,r,e.defaultVariants)&&(n+=` `+l);return n};return t.variants=()=>Object.keys(e.variantClassNames),t.classNames={get base(){return e.defaultClassName.split(` `)[0]},get variants(){return UU(e.variantClassNames,e=>UU(e,e=>e.split(` `)[0]))}},t},WU={root:`rich-alert`,header:`rich-alert-header`,icon:`rich-alert-icon`,label:`rich-alert-label`,content:`rich-alert-content`,contentEditable:`rich-alert-content-editable`},GU={root:{note:`rich-alert-note`,tip:`rich-alert-tip`,important:`rich-alert-important`,warning:`rich-alert-warning`,caution:`rich-alert-caution`},header:{note:`rich-alert-header-note`,tip:`rich-alert-header-tip`,important:`rich-alert-header-important`,warning:`rich-alert-header-warning`,caution:`rich-alert-header-caution`}},KU=LRe({defaultClassName:`pq4lod1`,variantClassNames:{type:{note:`pq4lod2`,tip:`pq4lod3`,important:`pq4lod4`,warning:`pq4lod5`,caution:`pq4lod6`}},defaultVariants:{},compoundVariants:[]}),qU=`pq4lod7`,RRe=`pq4lod8`,zRe=`pq4lod9`,JU=`pq4loda`,YU=`pq4lodb`,BRe=`pq4lodc`,XU={note:m,tip:gi,important:xi,warning:x,caution:wi},ZU={note:`Note`,tip:`Tip`,important:`Important`,warning:`Warning`,caution:`Caution`},VRe=[`note`,`tip`,`important`,`warning`,`caution`],QU=({type:e})=>{let t=XU[e],n=ZU[e];return(0,K.jsxs)(`div`,{className:`${qU} ${KU({type:e})} ${WU.header} ${GU.header[e]}`,children:[(0,K.jsx)(t,{className:`${JU} ${WU.icon}`}),(0,K.jsx)(`span`,{className:`${YU} ${WU.label}`,children:n})]})},HRe=({type:e,editable:t,onTypeChange:n})=>{if(!t||!n)return(0,K.jsx)(QU,{type:e});let r=XU[e],i=ZU[e];return(0,K.jsx)(`div`,{className:`${qU} ${KU({type:e})} ${WU.header} ${GU.header[e]}`,children:(0,K.jsxs)(Zn,{children:[(0,K.jsxs)(On,{"aria-label":`Alert type: ${i}`,className:RRe,children:[(0,K.jsx)(r,{className:`${JU} ${WU.icon}`}),(0,K.jsx)(`span`,{className:`${YU} ${WU.label}`,children:i}),(0,K.jsx)(l,{className:zRe})]}),(0,K.jsx)(Rt,{align:`start`,sideOffset:8,children:(0,K.jsx)(M,{value:e,onValueChange:t=>{t!==e&&n(t)},children:VRe.map(e=>{let t=XU[e];return(0,K.jsxs)(pn,{value:e,children:[(0,K.jsx)(t,{className:`${BRe} ${KU({type:e})}`}),(0,K.jsx)(`span`,{children:ZU[e]})]},e)})})})]})})},$U={root:`rr-image-root`,frame:`rr-image-frame`,frameLoading:`rr-image-loading`,frameLoaded:`rr-image-loaded`,frameError:`rr-image-error`,image:`rr-image-img`,loader:`rr-image-loader`,errorBadge:`rr-image-error`,caption:`rr-image-caption`,editTrigger:`rr-image-edit-trigger`,editPlaceholder:`rr-image-edit-placeholder`,editToolbar:`rr-image-edit-toolbar`,editToolbarVisible:`rr-image-edit-toolbar-visible`,resizeHandle:`rr-image-resize-handle`,inspector:`rr-image-inspector`},eW=`_1n94osf0`,tW=`_1n94osf1`,nW=`_1n94osf3`,rW={loading:`_1n94osf4`,loaded:`_1n94osf5`,error:`_1n94osf6`},iW=`_1n94osf7`,aW=`_1n94osf8`,URe=`_1n94osf9`,WRe=`_1n94osfa`,GRe=`_1n94osfm`,KRe=`_1n94osfn`,qRe=`_1n94osfo`,JRe=`_1n94osfp`,oW=`_1n94osfq`,YRe=`_1n94osfr`,XRe=`_1n94osfs`,ZRe=`_1n94osft`,QRe=`_1n94osfv`,$Re=`_1n94osfw`,eze=`_1n94osfx`,tze=`_1n94osfy`,nze=`_1n94osfz`,rze=`_1n94osf10`,ize=`_1n94osf11`,aze=`_1n94osf12`,oze=`_1n94osf13`,sze=`_1n94osf14`,cze={loading:$U.frameLoading,loaded:$U.frameLoaded,error:$U.frameError};function lze(e,t){if(t)return t;if(e&&(e.startsWith(`!`)||e.startsWith(`¡`)))return e.slice(1)}function sW({src:e,altText:t,width:n,height:r,caption:i,thumbhash:a,accent:o,displayWidth:s,fixedWidth:c,fixedHeight:l,layout:u,onActivate:d,ref:f}){let[p,m]=(0,G.useState)(`loading`),h=(0,G.useRef)(null),g=(0,G.useMemo)(()=>lze(t,i),[t,i]),_=(0,G.useMemo)(()=>a?$j(a):void 0,[a]);if(!e)return null;let v=!!d,y=DN({displayWidth:s,fixedWidth:c,fixedHeight:l}),b=y.mode===`percent`||y.mode===`fixed-width`,x={backgroundColor:p!==`loaded`&&!_?o||Ht.color.bgTertiary:`transparent`,backgroundImage:_&&p!==`loaded`?`url(${_})`:void 0,backgroundSize:`cover`,width:b?`100%`:n?Math.min(n,1200):void 0,maxWidth:`100%`,maxHeight:y.mode===`fixed-height`?`${y.px}px`:void 0,...n&&r?{aspectRatio:`${n} / ${r}`}:{}},S=()=>{h.current&&d?.(h.current)},C=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),S())},w=PN(y);return(0,K.jsxs)(`figure`,{className:`${eW} ${$U.root}`,"data-display":FN(y),"data-layout":u,ref:f,style:w,children:[(0,K.jsxs)(`div`,{"aria-label":v?`Open image: ${t||`image`}`:void 0,className:`${aW} ${v?``:WRe} ${$U.frame} ${rW[p]} ${cze[p]}`.trim(),role:v?`button`:void 0,style:x,tabIndex:v?0:void 0,onClick:v?S:void 0,onKeyDown:v?C:void 0,children:[(0,K.jsx)(`img`,{alt:t,className:`${nW} ${p===`loaded`?iW:``} ${$U.image}`,"data-state":p,height:r,loading:`lazy`,ref:h,src:e,width:n,style:y.mode===`fixed-height`?{width:`auto`,height:`auto`,maxWidth:`100%`,maxHeight:`100%`}:n&&r?{height:`100%`,objectFit:`cover`}:void 0,onError:()=>m(`error`),onLoad:()=>m(`loaded`)}),p===`loading`&&(0,K.jsx)(`span`,{className:`_1n94osfc ${$U.loader}`}),p===`error`&&(0,K.jsx)(`span`,{className:`_1n94osfd ${$U.errorBadge}`,children:`Image failed to load`})]}),g&&(0,K.jsx)(`figcaption`,{className:`_1n94osfe ${$U.caption}`,children:g})]})}var uze=0;function cW(e,t){let n=`atom${++uze}`,r={toString(){return n}};return typeof e==`function`?r.read=e:(r.init=e,r.read=dze,r.write=fze),t&&(r.write=t),r}function dze(e){return e(this)}function fze(e,t,n){return t(this,typeof n==`function`?n(e(this)):n)}function lW(e){return`init`in e}function pze(e){return typeof e.write==`function`}function mze(e){return!!e.onMount}function uW(e){return`v`in e||`e`in e}function dW(e){if(`e`in e)throw e.e;return e.v}function fW(e){return typeof e?.then==`function`}function hze(e){if(!(e instanceof Error))return!1;let t=e.name,n=e.message.toLowerCase();return(t===`RangeError`||t===`InternalError`)&&(n.includes(`call stack`)||n.includes(`too much recursion`)||n.includes(`stack overflow`))}function pW(e,t,n){if(!n.p.has(e)){n.p.add(e);let r=()=>n.p.delete(e);t.then(r,r)}}function mW(e,t,n){let r=n.get(e)?.t,i=t.p;if(!r?.size)return i;if(!i.size)return r;let a=new Set(r);for(let e of i)a.add(e);return a}function gze(e){return!!e.INTERNAL_onInit}var _ze=(e,t,n,...r)=>n.read(...r),vze=(e,t,n,...r)=>n.write(...r),yze=(e,t,n)=>n.INTERNAL_onInit(t),bze=(e,t,n,r)=>n.onMount?.(r),xze=(e,t,n)=>{let r=e.a,i=r.get(n);if(!i){let a=e.h,o=e.I;i={d:new Map,p:new Set,n:0},r.set(n,i),a.i?.(n),gze(n)&&o(e,t,n)}return i},Sze=(e,t)=>{let n=e.m,r=e.c,i=e.q,a=e.Q,o=e.h,s=e.C;if(!o.f&&!r.size&&!i.size&&!a.size)return;let c=[],l=e=>{try{e()}catch(e){c.push(e)}};do{o.f&&l(o.f);let c=new Set;for(let e of r){let t=n.get(e)?.l;if(t)for(let e of t)c.add(e)}r.clear();for(let e of a)c.add(e);a.clear();for(let e of i)c.add(e);i.clear();for(let e of c)l(e);r.size&&s(e,t)}while(r.size||a.size||i.size);if(c.length)throw typeof AggregateError==`function`?AggregateError(c):Object.assign(Error(),{errors:c})},Cze=(e,t)=>{let n=e.m,r=e.i,i=e.c,a=e.e,o=e.r,s=e.D;if(!i.size)return;let c=[],l=[],u=new WeakSet,d=new WeakSet,f=[],p=[];for(let n of i)f.push(n),p.push(a(e,t,n));for(;f.length;){let i=f.length-1,o=f[i],s=p[i];if(d.has(o))f.pop(),p.pop();else if(u.has(o))r.get(o)===s.n&&(c.push(o),l.push(s)),d.add(o),f.pop(),p.pop();else{u.add(o);for(let r of mW(o,s,n))u.has(r)||(f.push(r),p.push(a(e,t,r)))}}for(let n=c.length-1;n>=0;--n){let a=c[n],u=l[n],d=!1;for(let e of u.d.keys())if(e!==a&&i.has(e)){d=!0;break}d&&(r.set(a,u.n),o(e,t,a),s(e,t,a)),r.delete(a)}},wze=(e,t,n)=>{let r=e.m,i=e.i,a=e.c,o=e.h,s=e.R,c=e.e,l=e.f,u=e.C,d=e.r,f=e.D,p=e.v,m=e.H,h=e.E,g=c(e,t,n),_=h[0];if(uW(g)){if(r.has(n)&&i.get(n)!==g.n||g.m===_)return g.m=_,g;let a=!1;for(let[n,r]of g.d)if(d(e,t,n).n!==r){a=!0;break}if(!a)return g.m=_,g}let v=!0,y=new Set(g.d.keys()),b=()=>{for(let e of y)g.d.delete(e)},x=()=>{if(r.has(n)){let r=!a.size;f(e,t,n),r&&(u(e,t),l(e,t))}},S=i=>{if(i===n){let n=c(e,t,i);if(!uW(n)){if(lW(i))p(e,t,i,i.init);else throw Error(`no atom init`)}return dW(n)}let a=d(e,t,i);try{return dW(a)}finally{y.delete(i),g.d.set(i,a.n),fW(g.v)&&pW(n,g.v,a),r.has(n)&&r.get(i)?.t.add(n),v||x()}},C,w={get signal(){return C||=new AbortController,C.signal}},T=g.n,E=i.get(n)===T;try{let r=s(e,t,n,S,w);if(p(e,t,n,r),fW(r)){m(e,t,r,()=>C?.abort());let n=()=>{b(),x()};r.then(n,n)}else b();return o.r?.(n),g.m=_,g}catch(e){if(hze(e))throw e;return delete g.v,g.e=e,++g.n,g.m=_,g}finally{v=!1,g.n!==T&&E&&(i.set(n,g.n),a.add(n),o.c?.(n))}},Tze=(e,t,n)=>{let r=e.m,i=e.i,a=e.e,o=[n];for(;o.length;){let n=o.pop(),s=a(e,t,n);for(let c of mW(n,s,r)){let n=a(e,t,c);i.get(c)!==n.n&&(i.set(c,n.n),o.push(c))}}},Eze=(e,t,n,r)=>{let i=e.c,a=e.h,o=e.W,s=e.e,c=e.f,l=e.C,u=e.r,d=e.d,f=e.w,p=e.D,m=e.v,h=e.E,g=!0,_=n=>dW(u(e,t,n)),v=(r,...o)=>{let u=s(e,t,r);try{if(r===n){if(!lW(r))throw Error(`atom not writable`);let n=u.n,s=o[0];m(e,t,r,s),p(e,t,r),n!==u.n&&(++h[0],i.add(r),d(e,t,r),a.c?.(r));return}return f(e,t,r,o)}finally{g||(l(e,t),c(e,t))}};try{return o(e,t,n,_,v,...r)}finally{g=!1}},Dze=(e,t,n)=>{let r=e.m,i=e.c,a=e.h,o=e.e,s=e.d,c=e.t,l=e.T,u=o(e,t,n),d=r.get(n);if(d){for(let[r,l]of u.d)if(!d.d.has(r)){let u=o(e,t,r);c(e,t,r).t.add(n),d.d.add(r),l!==u.n&&(i.add(r),s(e,t,r),a.c?.(r))}for(let r of d.d)u.d.has(r)||(d.d.delete(r),l(e,t,r)?.t.delete(n))}},Oze=(e,t,n)=>{let r=e.m,i=e.q,a=e.h,o=e.M,s=e.e,c=e.f,l=e.C,u=e.r,d=e.w,f=e.t,p=s(e,t,n),m=r.get(n);if(!m){u(e,t,n);for(let r of p.d.keys())f(e,t,r).t.add(n);m={l:new Set,d:new Set(p.d.keys()),t:new Set},r.set(n,m),pze(n)&&mze(n)&&i.add(()=>{let r=!0,i=(...i)=>{try{return d(e,t,n,i)}finally{r||(l(e,t),c(e,t))}};try{let a=o(e,t,n,i);a&&(m.u=()=>{r=!0;try{a()}finally{r=!1}})}finally{r=!1}}),a.m?.(n)}return m},kze=(e,t,n)=>{let r=e.m,i=e.Q,a=e.h,o=e.e,s=e.T,c=o(e,t,n),l=r.get(n);if(!l||l.l.size)return l;let u=!1;for(let e of l.t)if(r.get(e)?.d.has(n)){u=!0;break}if(u)return l;l.u&&i.add(l.u),l=void 0,r.delete(n);for(let r of c.d.keys())s(e,t,r)?.t.delete(n);a.u?.(n)},Aze=(e,t,n,r)=>{let i=e.e,a=e.A,o=i(e,t,n),s=`v`in o,c=o.v;if(fW(r))for(let a of o.d.keys())pW(n,r,i(e,t,a));o.v=r,delete o.e,s&&Object.is(c,o.v)||(++o.n,fW(c)&&a(e,t,c))},jze=(e,t,n)=>{let r=e.r;return dW(r(e,t,n))},Mze=(e,t,n,...r)=>{let i=e.c,a=e.f,o=e.C,s=e.w,c=i.size;try{return s(e,t,n,r)}finally{i.size!==c&&(o(e,t),a(e,t))}},Nze=(e,t,n,r)=>{let i=e.f,a=e.C,o=e.t,s=e.T,c=o(e,t,n).l;return c.add(r),a(e,t),i(e,t),()=>{c.delete(r),s(e,t,n),a(e,t),i(e,t)}},Pze=(e,t,n,r)=>{let i=e.p,a=i.get(n);if(!a){a=new Set,i.set(n,a);let e=()=>i.delete(n);n.then(e,e)}a.add(r)},Fze=(e,t,n)=>{e.p.get(n)?.forEach(e=>e())},hW=new WeakMap;function Ize(e){let t=hW.get(e),n=t.B;return n?n(t,e):t}function Lze(e){let t={get(e){return r(n,t,e)},set(e,...r){return i(n,t,e,...r)},sub(e,r){return a(n,t,e,r)}},n=Object.freeze({a:new WeakMap,m:new WeakMap,i:new WeakMap,c:new Set,q:new Set,Q:new Set,h:{},R:_ze,W:vze,I:yze,M:bze,e:xze,f:Sze,C:Cze,r:wze,d:Tze,w:Eze,D:Dze,t:Oze,T:kze,v:Aze,g:jze,s:Mze,b:Nze,B:void 0,p:new WeakMap,H:Pze,A:Fze,E:[0],...e});hW.set(t,n);let r=n.g,i=n.s,a=n.b;return t}function gW(){return Lze()}var _W;function Rze(){return _W||=gW(),_W}var vW=(0,G.createContext)(void 0);function yW(e){let t=(0,G.useContext)(vW);return e?.store||t||Rze()}function zze({children:e,store:t}){let n=(0,G.useRef)(null);return t?(0,G.createElement)(vW.Provider,{value:t},e):(n.current===null&&(n.current=gW()),(0,G.createElement)(vW.Provider,{value:n.current},e))}var bW=e=>typeof e?.then==`function`,xW=new WeakMap,Bze=(e,t,n)=>{let r=Ize(e),i=r.H,a=xW.get(t);return a||(a=new Promise((o,s)=>{let c=t,l=e=>t=>{c===e&&o(t)},u=e=>t=>{c===e&&s(t)},d=()=>{try{let t=n();bW(t)?(xW.set(t,a),c=t,t.then(l(t),u(t)),i(r,e,t,d)):o(t)}catch(e){s(e)}};t.then(l(t),u(t)),i(r,e,t,d)}),xW.set(t,a)),a},SW=(e,t,n)=>[n,e,t,r=>{let i=e.sub(t,r),a=!0;try{a=!Object.is(n,e.get(t))}catch{}return a&&r(),i}];function Vze(e,t){let n=yW(t),[[r,i,a,o],s]=(0,G.useReducer)(t=>{let r=n.get(e);return t[1]===n&&t[2]===e?Object.is(t[0],r)?t:[r,n,e,t[3]]:SW(n,e,r)},void 0,()=>SW(n,e,n.get(e))),c=r;return(i!==n||a!==e)&&(s(),c=n.get(e)),(0,G.useEffect)(()=>o(s),[o]),(0,G.useDebugValue)(c),bW(c)?Bze(n,c,()=>n.get(e)):c}var CW=e=>{e.status||(e.status=`pending`,e.then(t=>{e.status=`fulfilled`,e.value=t},t=>{e.status=`rejected`,e.reason=t}))},Hze=G.use||(e=>{if(e.status===`pending`)throw e;if(e.status===`fulfilled`)return e.value;throw e.status===`rejected`?e.reason:(CW(e),e)});function wW(e,t){let{unstable_promiseStatus:n=!G.use}=t||{},r=Vze(e,t);return bW(r)?(n&&CW(r),Hze(r)):r}function TW(e,t){let n=yW(t);return(0,G.useCallback)((...t)=>n.set(e,...t),[n,e])}function EW(e,t){return[wW(e,t),TW(e,t)]}function Uze(e,t){if(t)return t;if(e&&(e.startsWith(`!`)||e.startsWith(`¡`)))return e.slice(1)}var DW=cW(``),OW=cW(``),kW=cW(),AW=cW(),jW=cW(),MW=cW(),NW=cW(),PW=cW(),FW=cW(),IW=cW(),LW=cW(),RW=cW(`loading`),zW=cW(!1),BW=cW(!1),VW=cW(!1),Wze=cW(!1),Gze=cW(!1),HW=cW(!1),UW=cW(e=>e(zW)||e(BW)||e(VW)||e(Wze)||e(Gze)||e(HW)),WW=cW(!1),GW=cW({current:null}),Kze=cW({current:null}),qze=cW(e=>{let t=e(MW);return t?$j(t):void 0}),Jze=cW(e=>Uze(e(OW),e(jW))),Yze=cW(e=>{let t=e(qze),n=e(NW),r=e(RW),i=e(kW),a=e(AW),o=e(PW),s=e(FW),c=e(IW),l=o!==void 0||s!==void 0;return{backgroundColor:r!==`loaded`&&!t?n||`#f5f5f5`:`transparent`,backgroundImage:t&&r!==`loaded`?`url(${t})`:void 0,backgroundSize:`cover`,width:l?`100%`:i?Math.min(i,1200):void 0,maxWidth:`100%`,maxHeight:c===void 0?void 0:`${c}px`,...i&&a?{aspectRatio:`${i} / ${a}`}:{}}});function Xze({props:e,children:t}){let[n]=ht(),r=(0,G.useRef)(null),i=(0,G.useRef)(null),[a]=(0,G.useState)(()=>{let t=gW();return t.set(DW,e.src),t.set(OW,e.altText),t.set(kW,e.width),t.set(AW,e.height),t.set(jW,e.caption),t.set(MW,e.thumbhash),t.set(NW,e.accent),t.set(PW,e.displayWidth),t.set(FW,e.fixedWidth),t.set(IW,e.fixedHeight),t.set(LW,e.layout),t.set(GW,r),t.set(Kze,i),t.set(RW,e.src?`loading`:`error`),t.set(VW,!e.src&&!!e.autoOpenOnMount),t});return(0,G.useEffect)(()=>{a.set(DW,e.src),a.set(OW,e.altText),a.set(kW,e.width),a.set(AW,e.height),a.set(jW,e.caption),a.set(MW,e.thumbhash),a.set(NW,e.accent),a.set(PW,e.displayWidth),a.set(FW,e.fixedWidth),a.set(IW,e.fixedHeight),a.set(LW,e.layout)},[a,e.src,e.altText,e.width,e.height,e.caption,e.thumbhash,e.accent,e.displayWidth,e.fixedWidth,e.fixedHeight,e.layout]),(0,G.useEffect)(()=>{a.set(RW,e.src?`loading`:`error`)},[a,e.src]),(0,G.useEffect)(()=>{if(!e.autoOpenOnMount)return;let t=r.current;t&&n.update(()=>{let e=Bt(t);GN(e)&&e.setShouldAutoOpenOnMount(!1)},{tag:[un,pee]})},[n,e.autoOpenOnMount]),(0,K.jsx)(zze,{store:a,children:t})}var KW=e=>{e.preventDefault(),e.stopPropagation()};function qW({children:e,label:t,icon:n=!0,...r}){return(0,K.jsxs)(Mn,{children:[(0,K.jsx)(tt,{render:(0,K.jsx)(Fe,{"aria-label":t,icon:n,size:`md`,onMouseDown:KW,...r}),children:e}),(0,K.jsx)(Fn,{side:`top`,children:t})]})}function JW(){let e=yW(),[t]=ht(),n=(0,G.useCallback)(n=>{let r=e.get(GW);r.current&&t.update(()=>{let e=Bt(r.current);GN(e)&&n(e)},{tag:`skip-scroll-into-view`})},[t,e]),r=(0,G.useCallback)(()=>{e.set(VW,!1)},[e]),i=(0,G.useCallback)(()=>{let n=e.get(GW);n.current&&(t.update(()=>{let e=Bt(n.current);e&&e.remove()}),e.set(BW,!1),r())},[r,t,e]),a=(0,G.useCallback)(()=>{let t=e.get(DW);t&&window.open(t,`_blank`,`noopener,noreferrer`)},[e]),o=(0,G.useCallback)(()=>{let t=e.get(DW);if(!t)return;let n=document.createElement(`a`);n.href=t,n.download=e.get(OW)||`image`,n.click()},[e]),s=(0,G.useCallback)(()=>{n(e=>{let t=WN({src:e.getSrc(),altText:e.getAltText(),width:e.getWidth(),height:e.getHeight(),caption:e.getCaption(),thumbhash:e.getThumbhash(),accent:e.getAccent(),displayWidth:e.getDisplayWidth(),fixedWidth:e.getFixedWidth(),fixedHeight:e.getFixedHeight(),layout:e.getLayout()});e.insertAfter(t)})},[n]),c=(0,G.useCallback)(e=>{n(t=>{t.applyDisplaySize(e)})},[n]),l=(0,G.useCallback)(e=>{n(t=>{t.setLayout(e)})},[n]);return{closeReplacePanel:r,handleReplaceOpenChange:(0,G.useCallback)(t=>{e.set(VW,t),t||r()},[r,e]),handleOpen:a,handleDuplicate:s,handleDownload:o,handleDelete:i,handleSetDisplaySize:c,handleSetLayout:l}}function YW({onOpenChange:e}){let[t]=ht(),{handleDuplicate:n,handleOpen:r,handleDownload:i,handleDelete:a}=JW();return(0,K.jsxs)(Zn,{onOpenChange:t=>e?.(t),children:[(0,K.jsx)(On,{render:(0,K.jsx)(Fe,{icon:!0,"aria-label":`More actions`,size:`md`,onMouseDown:KW}),children:(0,K.jsx)(Nr,{})}),(0,K.jsxs)(Rt,{align:`end`,children:[(0,K.jsxs)(Ut,{onClick:n,children:[(0,K.jsx)(Vte,{}),`Duplicate`]}),(0,K.jsxs)(Ut,{onClick:r,children:[(0,K.jsx)(Xte,{}),`Open original`]}),(0,K.jsxs)(Ut,{onClick:i,children:[(0,K.jsx)(f,{}),`Download`]}),(0,K.jsx)(ur,{}),(0,K.jsxs)(Ut,{shortcut:`Backspace`,variant:`destructive`,onClick:()=>{a(),Pe({title:`Image deleted`,action:{label:`Undo`,onClick:()=>t.dispatchCommand(U,void 0)}})},children:[(0,K.jsx)(Mr,{}),`Delete`]})]})]})}var Zze=/^(?:javascript\s*:|vbscript\s*:|data\s*:(?!image\/))/i;function XW(e){return e.trim()!==``&&!Zze.test(e.trim())}function Qze({focus:e,menu:t,onApply:n,onKeyDown:r,onOpenChange:i,open:a,renderWidth:o,trigger:s,values:c}){let l=(0,G.useId)(),u=(0,G.useRef)(null),f=(0,G.useRef)(null),[p,m]=(0,G.useState)(c.altText),[h,g]=(0,G.useState)(c.caption),[_,v]=(0,G.useState)(c.src),{apply:y,revert:b}=Tee(c,a,n);(0,G.useEffect)(()=>{a&&(m(c.altText),g(c.caption),v(c.src))},[a]);let x=!XW(_),S=e===`caption`?f:e===`alt`?u:void 0;return(0,K.jsxs)(gn,{open:a,onOpenChange:(e,t)=>{!e&&t?.reason===`escape-key`&&b(),i(e)},children:[(0,K.jsx)(en,{render:s}),(0,K.jsxs)(yn,{flush:!0,className:`${QRe} ${$U.inspector}`,initialFocus:S,side:`bottom`,size:`md`,onKeyDown:r,children:[(0,K.jsx)(wn,{actions:t,icon:(0,K.jsx)(d,{}),title:`Image`}),(0,K.jsxs)(Xn,{children:[o?.(e=>y({size:e})),(0,K.jsx)(Kn,{id:`${l}-alt`,label:`Alt text`,children:(0,K.jsx)(ct,{id:`${l}-alt`,placeholder:`Describe the image`,ref:u,value:p,onChange:e=>{m(e.target.value),y({altText:e.target.value})}})}),(0,K.jsx)(Kn,{hint:`Optional`,id:`${l}-caption`,label:`Caption`,children:(0,K.jsx)(ct,{id:`${l}-caption`,ref:f,value:h,onChange:e=>{g(e.target.value),y({caption:e.target.value})}})}),(0,K.jsx)(Kn,{error:x?`Enter an image URL`:void 0,id:`${l}-src`,label:`Source URL`,children:(0,K.jsx)(ct,{"aria-describedby":x?`${l}-src-error`:void 0,id:`${l}-src`,invalid:x,type:`url`,value:_,onChange:e=>{v(e.target.value),XW(e.target.value)&&y({src:e.target.value.trim()})}})})]}),(0,K.jsxs)(Bn,{hint:`Changes apply as you type`,children:[(0,K.jsx)(ar,{keys:`Esc`,size:`sm`,tone:`muted`}),(0,K.jsx)(`span`,{className:$Re,children:`revert`})]})]})]})}function ZW(e){let t=e.closest(`.rich-image-wrapper`)?.parentElement??e.parentElement;if(!t)return;let n=getComputedStyle(t),r=t.clientWidth-Number.parseFloat(n.paddingLeft)-Number.parseFloat(n.paddingRight);return r>0?r:void 0}function $ze(e,t,n){if(!e)return;let r=ZW(e);if(!r)return;let i=e.querySelector(`.${$U.frame}`)?.getBoundingClientRect();return{containerWidth:r,intrinsicWidth:t,intrinsicHeight:n,renderedWidth:i?.width,renderedHeight:i?.height}}function eBe(e,t,n){let r=e.querySelector(`figure`),i=t===`float-left`||t===`float-right`,a=e.closest(`.rich-image-wrapper`);r?.style.removeProperty(`--rich-image-display-width`),r?.style.removeProperty(`--rich-image-display-height`);let o=PN(n);if(r&&o)for(let[e,t]of Object.entries(o))r.style.setProperty(e,t);i&&a&&(n.mode===`percent`?(a.style.width=`${n.value}%`,a.style.maxWidth=``):n.mode===`fixed-width`?(a.style.width=`${n.px}px`,a.style.maxWidth=`100%`):n.mode===`fixed-height`?(a.style.width=`auto`,a.style.maxWidth=`100%`):(a.style.width=``,a.style.maxWidth=``))}var QW=cW(null),tBe=[25,50,75,100],$W=10,eG=100,nBe=3,rBe=[{value:`auto`,label:`Auto`},{value:`percent`,label:`%`},{value:`px`,label:`px`}];function iBe(e){for(let t of tBe)if(Math.abs(e-t)<=nBe)return t;return e}function tG(e){switch(e.mode){case`percent`:return`${e.value}%`;case`fixed-width`:case`fixed-height`:return`${e.px}px`;default:return`Auto`}}function aBe(){let e=wW(PW),t=wW(FW),n=wW(IW);return(0,G.useMemo)(()=>DN({displayWidth:e,fixedWidth:t,fixedHeight:n}),[e,t,n])}function oBe(){let[e]=ht(),t=yW();return(0,G.useCallback)((n,r)=>{let i=t.get(GW).current;i&&e.update(()=>{let e=Bt(i);GN(e)&&(n.src!==void 0&&e.setSrc(n.src),n.altText!==void 0&&e.setAltText(n.altText),n.caption!==void 0&&e.setCaption(n.caption||void 0),n.size&&e.applyDisplaySize(n.size))},{tag:r?[un,`skip-scroll-into-view`]:`skip-scroll-into-view`})},[e,t])}function sBe({size:e,onChange:t}){let n=(0,G.useId)(),r=yW(),i=wW(kW),a=wW(AW),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null);(0,G.useEffect)(()=>{s(null),l(null)},[e]);let u=()=>$ze(r.get(GW).current,i,a),d=e.mode===`auto`?`auto`:e.mode===`percent`?`percent`:`px`,f=n=>{if(n===d)return;if(n===`auto`){t({mode:`auto`});return}let r=u();if(n===`percent`){t(r?NN(e,`percent`,r):{mode:`percent`,value:100});return}if(r){t(NN(e,`fixed-width`,r));return}let a=EN(i);a&&t({mode:`fixed-width`,px:a})},p=e=>{let t=r.get(GW).current;t&&eBe(t,r.get(LW),e)},m=(()=>{if(e.mode===`percent`)return e.value;let t=u();if(!t)return;let{widthPx:n}=MN(e,t);return n?TN(n/t.containerWidth*100):void 0})(),h=o??m??eG,g=`${(h-$W)/90*100}%`,_=()=>{o!==null&&o!==m&&t({mode:`percent`,value:o})},v=e.mode===`fixed-width`||e.mode===`fixed-height`?e.px:void 0,y=e.mode===`fixed-height`?`Height in pixels`:`Width in pixels`;return(0,K.jsxs)(`div`,{className:aze,children:[(0,K.jsx)(`span`,{className:oze,id:`${n}-label`,children:`Width`}),(0,K.jsxs)(`div`,{"aria-labelledby":`${n}-label`,className:sze,role:`group`,children:[(0,K.jsx)(xt,{items:rBe,value:d,onChange:f}),d===`percent`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`input`,{"aria-label":`Width, percent of content width`,className:`_1n94osfu`,max:eG,min:$W,step:1,style:{"--fill":g},type:`range`,value:h,onBlur:_,onKeyUp:_,onPointerUp:_,onChange:e=>{let t=iBe(Number(e.target.value));s(t),p({mode:`percent`,value:t})}}),(0,K.jsx)(`span`,{className:`_1n94osf15`,children:`${h}%`})]}),d===`px`&&(0,K.jsxs)(`span`,{className:`_1n94osf17`,children:[(0,K.jsx)(ct,{"aria-label":y,autoComplete:`off`,inputMode:`numeric`,invalid:c!==null&&EN(Number(c))===void 0,spellCheck:!1,value:c??String(v??``),onChange:n=>{l(n.target.value);let r=EN(Number(n.target.value));r&&(e.mode===`fixed-width`||e.mode===`fixed-height`)&&t({mode:e.mode,px:r})}}),(0,K.jsx)(`span`,{className:`_1n94osf18`,children:`px`})]}),d===`auto`&&(0,K.jsx)(`span`,{className:`_1n94osf16`,children:`Natural size`})]})]})}function cBe(){let[e,t]=EW(BW),[n,r]=EW(QW),[i,a]=EW(WW),o=wW(DW),s=wW(OW),c=wW(jW),u=aBe(),d=oBe(),f=(0,G.useMemo)(()=>({src:o,altText:s,caption:c??``,size:u}),[o,s,c,u]);return(0,K.jsx)(Qze,{focus:i?`caption`:n,menu:(0,K.jsx)(YW,{}),open:e,renderWidth:e=>(0,K.jsx)(sBe,{size:u,onChange:e}),values:f,trigger:(0,K.jsxs)(Fe,{"aria-label":`Image size, ${tG(u)}`,className:rze,size:`md`,onClick:()=>r(null),onMouseDown:KW,children:[(0,K.jsx)(`span`,{children:tG(u)}),(0,K.jsx)(l,{className:ize})]}),onApply:d,onOpenChange:e=>{t(e),e||(r(null),a(!1))}})}var lBe=[{value:void 0,label:`Center`,Icon:Tne},{value:`align-left`,label:`Align left`,Icon:Dne},{value:`align-right`,label:`Align right`,Icon:Ene},{value:`float-left`,label:`Wrap left`,Icon:kne},{value:`float-right`,label:`Wrap right`,Icon:jte}];function uBe(){let e=wW(LW),{handleSetLayout:t}=JW();return(0,K.jsx)(`div`,{"aria-label":`Image layout`,className:eze,role:`group`,children:lBe.map(({value:n,label:r,Icon:i})=>(0,K.jsx)(qW,{"aria-pressed":e===n,label:r,onClick:()=>{e!==n&&t(n)},children:(0,K.jsx)(i,{})},n??`center`))})}var dBe=6e3;function nG(){let[e]=ht(),t=yW(),n=wje(),r=iL(),i=We(),a=(0,G.useRef)(!1);return(0,G.useCallback)(async()=>{if(a.current)return;a.current=!0;let o=t.get(GW).current,s=t=>{o&&e.update(()=>{let e=Bt(o);GN(e)&&t(e)},{tag:`skip-scroll-into-view`})};try{let e=hL(r),t=(await NL({editor:e,mode:`replace`,portalClassName:i.className,theme:i.theme}))?.[0];if(!t)return;if(t.kind===`url`){s(e=>{e.setSrc(t.src),e.setDimensions(t.width,t.height),e.setThumbhash(void 0)});return}let[a]=e?[t.file]:await lL([t.file],`replace`,r?.ref.current??null);if(!a)return;let o=async()=>{let e=Pe({title:`Uploading image…`,tone:`loading`});try{let t=n??IL,[r,i]=await Promise.all([PL(t,a),Qj(a)]);s(e=>{e.setSrc(r.src),e.setAltText(r.altText??a.name),e.setDimensions(r.width??i.width,r.height??i.height),e.setThumbhash(r.thumbhash??i.thumbhash)}),Et(e,{title:`Image replaced`,tone:`success`})}catch(t){console.error(`[ImageReplace]`,t),Et(e,{action:{label:`Retry`,onClick:()=>void o()},duration:dBe,title:`Image replace failed`,tone:`error`})}};await o()}finally{a.current=!1}},[e,i,r,t,n])}function fBe(){let[e]=ht(),t=yW(),[n,r]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{let n=t.get(GW).current;if(!n)return;let i=()=>e.read(()=>{let e=kr();if(!Ue(e))return!1;let t=Bt(n);return t!==null&&e.has(t.getKey())}),a=()=>{let e=i();r(e),e?n.dataset.selected=``:delete n.dataset.selected},o=t=>{t.target?.closest(`.${$U.editToolbar}`)||e.update(()=>{let e=Bt(n);if(!e)return;let t=sr();t.add(e.getKey()),Jt(t)},{tag:`skip-scroll-into-view`})};a(),n.addEventListener(`click`,o);let s=e.registerUpdateListener(a);return()=>{n.removeEventListener(`click`,o),s(),delete n.dataset.selected}},[e,t]),n}function rG(){return(0,K.jsx)(`span`,{"aria-hidden":!0,className:tze})}function pBe(){let e=wW(UW),t=fBe(),[n,r]=(0,G.useState)(!1),i=TW(BW),a=TW(QW),o=nG(),s=e||t||n;return(0,K.jsxs)(`div`,{"aria-label":`Image`,className:`${qRe} ${$U.editToolbar} ${s?`${JRe} ${$U.editToolbarVisible}`:``}`,role:`toolbar`,children:[(0,K.jsx)(cBe,{}),(0,K.jsx)(rG,{}),(0,K.jsx)(uBe,{}),(0,K.jsx)(rG,{}),(0,K.jsx)(qW,{className:nze,icon:!1,label:`Alt text`,onClick:()=>{a(`alt`),i(!0)},children:`Alt`}),(0,K.jsx)(qW,{label:`Replace image`,onClick:()=>void o(),children:(0,K.jsx)(Gne,{})}),(0,K.jsx)(rG,{}),(0,K.jsx)(YW,{onOpenChange:r})]})}function mBe(){let[e,t]=EW(VW),n=nG();return(0,G.useEffect)(()=>{e&&(t(!1),n())},[n,e,t]),(0,K.jsxs)(`button`,{className:`${KRe} ${$U.editPlaceholder}`,type:`button`,onClick:()=>void n(),onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},children:[(0,K.jsx)(d,{size:24}),(0,K.jsx)(`span`,{children:`Click to add image`})]})}var hBe=3;function gBe(){let e=yW(),[t]=ht(),n=(0,G.useRef)(null);return(0,G.useEffect)(()=>()=>n.current?.(!1),[]),{handlePointerDown:(0,G.useCallback)((r,i)=>{let a=e.get(GW).current;if(!a)return;let o=a.querySelector(`.${$U.frame}`),s=a.querySelector(`figure`),c=a.closest(`.rich-image-wrapper`);if(!o||!s)return;let l=ZW(a),u=o.getBoundingClientRect().width;if(!l||l<=0||!u)return;r.preventDefault(),r.stopPropagation();let d=e.get(LW),f=d===void 0?2:1,p=d===`float-left`||d===`float-right`,m=r.clientX,h=r.currentTarget;try{h.setPointerCapture(r.pointerId)}catch{}e.set(HW,!0);let g=document.body.style.userSelect;document.body.style.userSelect=`none`;let _=o.getBoundingClientRect().height,v=u>0&&_>0?_/u:void 0,y=DN({displayWidth:e.get(PW),fixedWidth:e.get(FW),fixedHeight:e.get(IW)}).mode,b=IN(y,u,_,l),x=!1,S=e=>{let t=PN(e);if(s.style.removeProperty(`--rich-image-display-width`),s.style.removeProperty(`--rich-image-display-height`),t)for(let[e,n]of Object.entries(t))s.style.setProperty(e,n);p&&c&&(e.mode===`percent`?(c.style.width=`${e.value}%`,c.style.maxWidth=``):e.mode===`fixed-width`?(c.style.width=`${e.px}px`,c.style.maxWidth=`100%`):e.mode===`fixed-height`&&(c.style.width=`auto`,c.style.maxWidth=`100%`))},C=e=>{let t=e.clientX-m;if(!x&&Math.abs(t)<hBe)return;x=!0;let n=i===`left`?-t:t,r=u+n*f,a=v?r*v:_;b=IN(y,r,a,l),S(b)},w=r=>{n.current===w&&(n.current=null,h.removeEventListener(`pointermove`,C),h.removeEventListener(`pointerup`,T),h.removeEventListener(`pointercancel`,T),document.body.style.userSelect=g,e.set(HW,!1),r&&x&&t.update(()=>{let e=Bt(a);GN(e)&&e.applyDisplaySize(b)},{tag:`skip-scroll-into-view`}))},T=()=>w(!0);n.current=w,h.addEventListener(`pointermove`,C),h.addEventListener(`pointerup`,T),h.addEventListener(`pointercancel`,T)},[t,e])}}function _Be(){let e=wW(UW),{handlePointerDown:t}=gBe(),n=e?ZRe:``;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`${oW} ${YRe} ${n} ${$U.resizeHandle}`.trim(),onPointerDown:e=>t(e,`left`)}),(0,K.jsx)(`span`,{className:`${oW} ${XRe} ${n} ${$U.resizeHandle}`.trim(),onPointerDown:e=>t(e,`right`)})]})}var iG=`application/x-haklex-image-drag`;function aG(e,t){return t<e.left+e.width/2?`left`:`right`}function vBe(e){return e===`left`?`float-left`:`float-right`}function oG(e){return!!e?.types.includes(iG)}function sG(e,t){let n=e.getRootElement();if(!n)return null;let r=t;for(;r&&r!==n;){if(r.parentElement===n)return r;r=r.parentElement}return null}function yBe(e,t){let n=[...e.children].filter(e=>e instanceof HTMLElement);if(!n.length)return null;let r=null,i=1/0;for(let e of n){let n=e.getBoundingClientRect();if(n.height<=0)continue;if(t>=n.top&&t<=n.bottom)return e;let a=t<n.top?n.top-t:t-n.bottom;a<i&&(i=a,r=e)}return r}function cG(e,t,n){let r=t.getBoundingClientRect();if(r.width<=0||r.height<=0||n.clientY<r.top||n.clientY>r.bottom)return null;let i=[{x:n.clientX,y:n.clientY}],a=Math.min(r.right-1,Math.max(r.left+1,n.clientX));a!==n.clientX&&i.unshift({x:a,y:n.clientY});for(let t of i){let n=document.elementFromPoint(t.x,t.y);if(!(n instanceof HTMLElement))continue;let r=sG(e,n);if(r)return r}if(n.target instanceof HTMLElement){let t=sG(e,n.target);if(t)return t}return yBe(t,n.clientY)}var lG=new WeakMap;function bBe(e,t){let n=aG(e.getBoundingClientRect(),t.clientX);e.dataset.richImageDropSide=n}function uG(e){delete e.dataset.richImageDropSide}function xBe(e){let t=lG.get(e);if(t)return t.count+=1,()=>{--t.count,t.count>0||(t.unregister(),lG.delete(e))};let n=e.getRootElement();if(!n)return()=>{};let r=()=>uG(n),i=e.registerCommand(hr,t=>oG(t.dataTransfer)?(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect=`move`),cG(e,n,t)?(bBe(n,t),!0):(uG(n),!0)):!1,3),a=e.registerCommand(dt,t=>{let r=t.dataTransfer?.getData(iG);if(!r)return!1;t.preventDefault(),uG(n);let i=cG(e,n,t);if(!i)return!0;let a=i.getBoundingClientRect(),o=e.getEditorState().read(()=>Bt(i)?.getKey()??null,{editor:e});if(!o)return!0;let s=vBe(aG(n.getBoundingClientRect(),t.clientX)),c=t.clientY<a.top+a.height/2;return e.update(()=>{let e=Dn(r);if(!GN(e)||(e.setLayout(s),r===o))return;e.remove();let t=Dn(o);t&&(c?t.insertBefore(e):t.insertAfter(e))},{tag:`skip-scroll-into-view`}),!0},3),o=e.registerCommand(Je,e=>oG(e.dataTransfer),3);window.addEventListener(`dragend`,r),window.addEventListener(`drop`,r);let s={count:1,unregister:()=>{i(),a(),o(),window.removeEventListener(`dragend`,r),window.removeEventListener(`drop`,r),uG(n)}};return lG.set(e,s),()=>{--s.count,s.count>0||(s.unregister(),lG.delete(e))}}function SBe(){let[e]=ht(),t=yW();(0,G.useEffect)(()=>xBe(e),[e]);let n=(0,G.useCallback)(n=>{let r=t.get(GW).current,i=r?.closest(`.rich-image-wrapper`);if(!r||!n.dataTransfer){n.preventDefault();return}let a=e.getEditorState().read(()=>{let e=Bt(r);return GN(e)?e.getKey():null},{editor:e});a?(n.dataTransfer.setData(iG,a),n.dataTransfer.effectAllowed=`move`,i?.classList.add(tW)):n.preventDefault()},[e,t]);return{draggable:!0,onDragEnd:(0,G.useCallback)(()=>{t.get(GW).current?.closest(`.rich-image-wrapper`)?.classList.remove(tW)},[t]),onDragStart:n}}var CBe={loading:$U.frameLoading,loaded:$U.frameLoaded,error:$U.frameError};function wBe(e){return XEe()===`editor`?(0,K.jsx)(TBe,{...e}):(0,K.jsx)(sW,{...e})}function TBe(e){let[t]=ht();return t.isEditable()?(0,K.jsx)(Xze,{props:e,children:(0,K.jsx)(EBe,{})}):(0,K.jsx)(sW,{...e})}function EBe(){let e=wW(GW),t=TW(zW),n=wW(DW),r=wW(RW),i=TW(RW),a=wW(Yze),o=wW(OW),s=wW(kW),c=wW(AW),l=wW(Jze),u=TW(BW),d=TW(VW),f=TW(WW),p=wW(PW),m=wW(FW),h=wW(IW),g=wW(LW),_=DN({displayWidth:p,fixedWidth:m,fixedHeight:h}),v=SBe(),y=(0,G.useCallback)(e=>{e.stopPropagation();let t=window.scrollY;d(!1),u(!0),f(!0),requestAnimationFrame(()=>{window.scrollTo({top:t})})},[u,d,f]),b=PN(_);return(0,K.jsxs)(`div`,{className:`${GRe} ${$U.editTrigger}`,ref:e,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[n?(0,K.jsxs)(`figure`,{className:`${eW} ${$U.root}`,"data-display":FN(_),"data-layout":g,style:b,...v,children:[(0,K.jsxs)(`div`,{className:`${aW} ${$U.frame} ${URe} ${rW[r]} ${CBe[r]}`.trim(),style:a,children:[(0,K.jsx)(`img`,{alt:o,className:`${nW} ${r===`loaded`?iW:``} ${$U.image}`,height:c,loading:`lazy`,src:n,width:s,style:_.mode===`fixed-height`?{width:`auto`,height:`auto`,maxWidth:`100%`,maxHeight:`100%`}:void 0,onError:()=>i(`error`),onLoad:()=>i(`loaded`)}),r===`loading`&&(0,K.jsx)(`span`,{className:`_1n94osfc ${$U.loader}`}),r===`error`&&(0,K.jsx)(`span`,{className:`_1n94osfd ${$U.errorBadge}`,children:`Image failed to load`}),(0,K.jsx)(_Be,{})]}),l&&(0,K.jsx)(`figcaption`,{className:`_1n94osfe ${$U.caption}`,onClick:y,children:l})]}):(0,K.jsx)(mBe,{}),n&&(0,K.jsx)(pBe,{})]})}function dG({children:e}){return(0,K.jsx)(CRe,{fontCssHref:``,children:e})}var DBe=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=pG(e.state,n.from);return r.line?OBe(e):r.block?ABe(e):!1};function fG(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var OBe=fG(NBe,0),kBe=fG(hG,0),ABe=fG((e,t)=>hG(e,t,MBe(t)),0);function pG(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var mG=50;function jBe(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-mG,r),o=e.sliceDoc(i,i+mG),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+mG),d=e.sliceDoc(i-mG,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function MBe(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function hG(e,t,n=t.selection.ranges){let r=n.map(e=>pG(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>jBe(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function NBe(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=pG(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var gG=dw.define(),PBe=dw.define(),FBe=HC.define(),_G=HC.define({combine(e){return xw(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),vG=JC.define({create(){return OG.empty},update(e,t){let n=t.state.facet(_G),r=t.annotation(gG);if(r){let i=SG.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?CG(o,o.length,n.minDepth,i):EG(o,t.startState.selection),new OG(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(PBe);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(pw.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=SG.fromTransaction(t),o=t.annotation(pw.time),s=t.annotation(pw.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new OG(e.done.map(SG.fromJSON),e.undone.map(SG.fromJSON))}});function IBe(e={}){return[vG,_G.of(e),vO.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?bG:e.inputType==`historyRedo`?xG:null;return n?(e.preventDefault(),n(t)):!1}})]}function yG(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(vG,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var bG=yG(0,!1),xG=yG(1,!1),LBe=yG(0,!0),RBe=yG(1,!0),SG=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&jC.fromJSON(t.changes),[],t.mapped&&AC.fromJSON(t.mapped),t.startSelection&&zC.fromJSON(t.startSelection),t.selectionsAfter.map(zC.fromJSON))}static fromTransaction(t,n){let r=TG;for(let e of t.startState.facet(FBe)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,TG)}static selection(t){return new e(void 0,TG,void 0,void 0,t)}};function CG(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function zBe(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function BBe(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function wG(e,t){return e.length?t.length?e.concat(t):e:t}var TG=[],VBe=200;function EG(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-VBe));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),CG(e,e.length-1,1e9,n.setSelAfter(r)))}return[SG.selection([t])]}function HBe(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function DG(e,t){if(!e.length)return e;let n=e.length,r=TG;for(;n;){let i=UBe(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[SG.selection(r)]:TG}function UBe(e,t,n){let r=wG(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):TG,n);if(!e.changes)return SG.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new SG(i,fw.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var WBe=/^(input\.type|delete)($|\.)/,OG=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||WBe.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,zBe(s.changes,t.changes))||r==`input.type.compose`)?CG(o,o.length-1,i.minDepth,new SG(t.changes.compose(s.changes),wG(fw.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,TG)):CG(o,o.length,i.minDepth,t),new e(o,TG,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:TG;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&BBe(a[a.length-1],t)?this:new e(EG(this.done,t),this.undone,n,r)}addMapping(t){return new e(DG(this.done,t),DG(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:gG.of({side:e,rest:HBe(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?TG:r.slice(0,r.length-1);return i.mapped&&(n=DG(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:gG.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}return null}};OG.empty=new OG(TG,TG);var GBe=[{key:`Mod-z`,run:bG,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:xG,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:xG,preventDefault:!0},{key:`Mod-u`,run:LBe,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:RBe,preventDefault:!0}];function kG(e,t){return zC.create(e.ranges.map(t),e.mainIndex)}function AG(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function jG({state:e,dispatch:t},n){let r=kG(e.selection,n);return!r.eq(e.selection,!0)&&(t(AG(e,r)),!0)}function MG(e,t){return zC.cursor(t?e.to:e.from)}function NG(e,t){return jG(e,n=>n.empty?e.moveByChar(n,t):MG(n,t))}function PG(e){return e.textDirectionAt(e.state.selection.main.head)==qT.LTR}var FG=e=>NG(e,!PG(e)),IG=e=>NG(e,PG(e));function LG(e,t){return jG(e,n=>n.empty?e.moveByGroup(n,t):MG(n,t))}var KBe=e=>LG(e,!PG(e)),qBe=e=>LG(e,PG(e));typeof Intl<`u`&&Intl.Segmenter;function JBe(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function RG(e,t,n){let r=gk(e).resolveInner(t.head),i=n?jS.closedBy:jS.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;JBe(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?zk(e,r.from,1):zk(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,zC.cursor(s,n?-1:1)}var YBe=e=>jG(e,t=>RG(e.state,t,!PG(e))),XBe=e=>jG(e,t=>RG(e.state,t,PG(e)));function zG(e,t){return jG(e,n=>{if(!n.empty)return MG(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var BG=e=>zG(e,!1),VG=e=>zG(e,!0);function HG(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(vO.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function UG(e,t){let n=HG(e),{state:r}=e,i=kG(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):MG(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=vO.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(AG(r,i),{effects:a}),!0}var WG=e=>UG(e,!1),GG=e=>UG(e,!0);function KG(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=zC.cursor(r.from+n))}return i}var ZBe=e=>jG(e,t=>KG(e,t,!0)),QBe=e=>jG(e,t=>KG(e,t,!1)),$Be=e=>jG(e,t=>KG(e,t,!PG(e))),eVe=e=>jG(e,t=>KG(e,t,PG(e))),tVe=e=>jG(e,t=>e.moveToLineBoundary(t,!1,!1)),nVe=e=>jG(e,t=>e.moveToLineBoundary(t,!0,!1));function rVe(e,t,n){let r=!1,i=kG(e.selection,t=>{let i=zk(e,t.head,-1)||zk(e,t.head,1)||t.head>0&&zk(e,t.head-1,1)||t.head<e.doc.length&&zk(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?zC.range(t.anchor,a):zC.cursor(a)});return r?(t(AG(e,i)),!0):!1}var iVe=({state:e,dispatch:t})=>rVe(e,t,!1);function qG(e,t,n){let r=kG(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=zC.range(e.head,e.anchor));let r=n(e);return zC.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(AG(e.state,r)),!0)}function JG(e,t){return qG(e,t,n=>e.moveByChar(n,t))}var YG=e=>JG(e,!PG(e)),XG=e=>JG(e,PG(e));function ZG(e,t){return qG(e,t,n=>e.moveByGroup(n,t))}var aVe=e=>ZG(e,!PG(e)),oVe=e=>ZG(e,PG(e)),sVe=e=>{let t=!PG(e);return qG(e,t,n=>RG(e.state,n,t))},cVe=e=>{let t=PG(e);return qG(e,t,n=>RG(e.state,n,t))};function QG(e,t){return qG(e,t,n=>e.moveVertically(n,t))}var $G=e=>QG(e,!1),eK=e=>QG(e,!0);function tK(e,t){return qG(e,t,n=>e.moveVertically(n,t,HG(e).height))}var nK=e=>tK(e,!1),rK=e=>tK(e,!0),lVe=e=>qG(e,!0,t=>KG(e,t,!0)),uVe=e=>qG(e,!1,t=>KG(e,t,!1)),dVe=e=>{let t=!PG(e);return qG(e,t,n=>KG(e,n,t))},fVe=e=>{let t=PG(e);return qG(e,t,n=>KG(e,n,t))},pVe=e=>qG(e,!1,t=>zC.cursor(e.lineBlockAt(t.head).from)),mVe=e=>qG(e,!0,t=>zC.cursor(e.lineBlockAt(t.head).to)),iK=({state:e,dispatch:t})=>(t(AG(e,{anchor:0})),!0),aK=({state:e,dispatch:t})=>(t(AG(e,{anchor:e.doc.length})),!0),oK=({state:e,dispatch:t})=>(t(AG(e,{anchor:e.selection.main.anchor,head:0})),!0),sK=({state:e,dispatch:t})=>(t(AG(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),hVe=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),gVe=({state:e,dispatch:t})=>{let n=gK(e).map(({from:t,to:n})=>zC.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:zC.create(n),userEvent:`select`})),!0},_Ve=({state:e,dispatch:t})=>{let n=kG(e.selection,t=>{let n=gk(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return zC.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(AG(e,n)),!0)};function cK(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(AG(n,zC.create(i,i.length-1))),!0)}var vVe=e=>cK(e,!1),yVe=e=>cK(e,!0),bVe=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=zC.create([n.main]):n.main.empty||(r=zC.create([zC.cursor(n.main.head)])),r?(t(AG(e,r)),!0):!1};function lK(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=uK(e,o,!1)):o>i&&(n=`delete.forward`,o=uK(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=uK(e,i,!1),a=uK(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:zC.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?vO.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function uK(e,t,n){if(e instanceof vO)for(let r of e.state.facet(vO.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var dK=(e,t,n)=>lK(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=zw(s,a.tabSize)%Ek(a)||Ek(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=DC(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=DC(o.text,c-o.from,!1,!1)+o.from);return c}),fK=e=>dK(e,!1,!0),pK=e=>dK(e,!0,!1),mK=(e,t)=>lK(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=DC(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),hK=e=>mK(e,!1),xVe=e=>mK(e,!0),SVe=e=>lK(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),CVe=e=>lK(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),wVe=e=>lK(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),TVe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:vC.of([``,``])},range:zC.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},EVe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:DC(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:DC(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:zC.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function gK(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function _K(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of gK(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(zC.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(zC.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:zC.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var DVe=({state:e,dispatch:t})=>_K(e,t,!1),OVe=({state:e,dispatch:t})=>_K(e,t,!0);function vK(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of gK(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var kVe=({state:e,dispatch:t})=>vK(e,t,!1),AVe=({state:e,dispatch:t})=>vK(e,t,!0),jVe=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(gK(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=kG(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function MVe(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=gk(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(jS.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var yK=bK(!1),NVe=bK(!0);function bK(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&MVe(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new kk(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=Ok(s,r);for(c??=zw(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,Dk(t,c)];return o&&l.push(Dk(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:vC.of(l)},range:zC.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function xK(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:zC.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var PVe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new kk(e,{overrideIndentation:e=>n[e]??-1}),i=xK(e,(t,i,a)=>{let o=Ok(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=Dk(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},SK=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(xK(e,(t,n)=>{n.push({from:t.from,insert:e.facet(Tk)})}),{userEvent:`input.indent`})),!0),CK=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(xK(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=zw(r,e.tabSize),a=0,o=Dk(e,Math.max(0,i-Ek(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),FVe=e=>(e.setTabFocusMode(),!0),IVe=[{key:`Ctrl-b`,run:FG,shift:YG,preventDefault:!0},{key:`Ctrl-f`,run:IG,shift:XG},{key:`Ctrl-p`,run:BG,shift:$G},{key:`Ctrl-n`,run:VG,shift:eK},{key:`Ctrl-a`,run:tVe,shift:pVe},{key:`Ctrl-e`,run:nVe,shift:mVe},{key:`Ctrl-d`,run:pK},{key:`Ctrl-h`,run:fK},{key:`Ctrl-k`,run:SVe},{key:`Ctrl-Alt-h`,run:hK},{key:`Ctrl-o`,run:TVe},{key:`Ctrl-t`,run:EVe},{key:`Ctrl-v`,run:GG}],LVe=[{key:`ArrowLeft`,run:FG,shift:YG,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:KBe,shift:aVe,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:$Be,shift:dVe,preventDefault:!0},{key:`ArrowRight`,run:IG,shift:XG,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:qBe,shift:oVe,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:eVe,shift:fVe,preventDefault:!0},{key:`ArrowUp`,run:BG,shift:$G,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:iK,shift:oK},{mac:`Ctrl-ArrowUp`,run:WG,shift:nK},{key:`ArrowDown`,run:VG,shift:eK,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:aK,shift:sK},{mac:`Ctrl-ArrowDown`,run:GG,shift:rK},{key:`PageUp`,run:WG,shift:nK},{key:`PageDown`,run:GG,shift:rK},{key:`Home`,run:QBe,shift:uVe,preventDefault:!0},{key:`Mod-Home`,run:iK,shift:oK},{key:`End`,run:ZBe,shift:lVe,preventDefault:!0},{key:`Mod-End`,run:aK,shift:sK},{key:`Enter`,run:yK,shift:yK},{key:`Mod-a`,run:hVe},{key:`Backspace`,run:fK,shift:fK,preventDefault:!0},{key:`Delete`,run:pK,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:hK,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:xVe,preventDefault:!0},{mac:`Mod-Backspace`,run:CVe,preventDefault:!0},{mac:`Mod-Delete`,run:wVe,preventDefault:!0}].concat(IVe.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),RVe=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:YBe,shift:sVe},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:XBe,shift:cVe},{key:`Alt-ArrowUp`,run:DVe},{key:`Shift-Alt-ArrowUp`,run:kVe},{key:`Alt-ArrowDown`,run:OVe},{key:`Shift-Alt-ArrowDown`,run:AVe},{key:`Mod-Alt-ArrowUp`,run:vVe},{key:`Mod-Alt-ArrowDown`,run:yVe},{key:`Escape`,run:bVe},{key:`Mod-Enter`,run:NVe},{key:`Alt-l`,mac:`Ctrl-l`,run:gVe},{key:`Mod-i`,run:_Ve,preventDefault:!0},{key:`Mod-[`,run:CK},{key:`Mod-]`,run:SK},{key:`Mod-Alt-\\`,run:PVe},{key:`Shift-Mod-k`,run:jVe},{key:`Shift-Mod-\\`,run:iVe},{key:`Mod-/`,run:DBe},{key:`Alt-A`,mac:`Ctrl-A`,run:kBe},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:FVe}].concat(LVe),zVe={key:`Tab`,run:SK,shift:CK};function wK(e){return new wk(sCe.define(e))}function TK(e){return r(()=>import(`./dist-D26TaXjP.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([29,30,31]),import.meta.url)}var BVe=[J.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return r(()=>import(`./dist-2resm9Wy.js`).then(e=>e.cpp()),__vite__mapDeps([32,30]),import.meta.url)}}),J.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return r(()=>import(`./dist-2resm9Wy.js`).then(e=>e.cpp()),__vite__mapDeps([32,30]),import.meta.url)}}),J.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return TK(`Cassandra`)}}),J.of({name:`CSS`,extensions:[`css`],load(){return r(()=>import(`./dist-Bost_p8b.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([33,1,30]),import.meta.url)}}),J.of({name:`Go`,extensions:[`go`],load(){return r(()=>import(`./dist-462HZ4sr.js`).then(e=>e.go()),__vite__mapDeps([34,30,31]),import.meta.url)}}),J.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return r(()=>import(`./dist-Dr8Mok4z.js`).then(e=>e.html()),__vite__mapDeps([35,30,33,1,36,31]),import.meta.url)}}),J.of({name:`Java`,extensions:[`java`],load(){return r(()=>import(`./dist-CrYVEXMn.js`).then(e=>e.java()),__vite__mapDeps([37,30]),import.meta.url)}}),J.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return r(()=>import(`./dist-B7GHMwWJ.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([36,1,30,31]),import.meta.url)}}),J.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return r(()=>import(`./dist-Bw8MOHnL.js`).then(e=>e.jinja()),__vite__mapDeps([38,35,30,33,1,36,31]),import.meta.url)}}),J.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return r(()=>import(`./dist-B9cyrbzi.js`).then(e=>e.json()),__vite__mapDeps([39,30]),import.meta.url)}}),J.of({name:`JSX`,extensions:[`jsx`],load(){return r(()=>import(`./dist-B7GHMwWJ.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([36,1,30,31]),import.meta.url)}}),J.of({name:`LESS`,extensions:[`less`],load(){return r(()=>import(`./dist-CAQYce5C.js`).then(e=>e.less()),__vite__mapDeps([40,33,1,30]),import.meta.url)}}),J.of({name:`Liquid`,extensions:[`liquid`],load(){return r(()=>import(`./dist-opUfcW4x.js`).then(e=>e.liquid()),__vite__mapDeps([41,35,30,33,1,36,31]),import.meta.url)}}),J.of({name:`MariaDB SQL`,load(){return TK(`MariaSQL`)}}),J.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return r(()=>import(`./dist-CEyDZYnP.js`).then(e=>e.markdown()),__vite__mapDeps([42,31,35,30,33,1,36]),import.meta.url)}}),J.of({name:`MS SQL`,load(){return TK(`MSSQL`)}}),J.of({name:`MySQL`,load(){return TK(`MySQL`)}}),J.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return r(()=>import(`./dist-Dz80ecx_.js`).then(e=>e.php()),__vite__mapDeps([43,30,35,33,1,36,31]),import.meta.url)}}),J.of({name:`PLSQL`,extensions:[`pls`],load(){return TK(`PLSQL`)}}),J.of({name:`PostgreSQL`,load(){return TK(`PostgreSQL`)}}),J.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return r(()=>import(`./dist-N6Hpo5Ed.js`).then(e=>e.python()),__vite__mapDeps([44,30,31]),import.meta.url)}}),J.of({name:`Rust`,extensions:[`rs`],load(){return r(()=>import(`./dist-CJicYh3N.js`).then(e=>e.rust()),__vite__mapDeps([45,30]),import.meta.url)}}),J.of({name:`Sass`,extensions:[`sass`],load(){return r(()=>import(`./dist-DUysbnVD.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([46,30,33,1]),import.meta.url)}}),J.of({name:`SCSS`,extensions:[`scss`],load(){return r(()=>import(`./dist-DUysbnVD.js`).then(e=>e.sass()),__vite__mapDeps([46,30,33,1]),import.meta.url)}}),J.of({name:`SQL`,extensions:[`sql`],load(){return TK(`StandardSQL`)}}),J.of({name:`SQLite`,load(){return TK(`SQLite`)}}),J.of({name:`TSX`,extensions:[`tsx`],load(){return r(()=>import(`./dist-B7GHMwWJ.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([36,1,30,31]),import.meta.url)}}),J.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return r(()=>import(`./dist-B7GHMwWJ.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([36,1,30,31]),import.meta.url)}}),J.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return r(()=>import(`./dist-DlFC92UU.js`).then(e=>e.wast()),__vite__mapDeps([47,30]),import.meta.url)}}),J.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return r(()=>import(`./dist-Cfyg-ZFz.js`).then(e=>e.xml()),__vite__mapDeps([48,30]),import.meta.url)}}),J.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return r(()=>import(`./dist-D32zdSlG.js`).then(e=>e.yaml()),__vite__mapDeps([49,30]),import.meta.url)}}),J.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return r(()=>import(`./apl-gfMMiTNf.js`).then(e=>wK(e.apl)),[],import.meta.url)}}),J.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return r(()=>import(`./asciiarmor-C_eisQCp.js`).then(e=>wK(e.asciiArmor)),[],import.meta.url)}}),J.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return r(()=>import(`./asn1-DCl_8MCW.js`).then(e=>wK(e.asn1({}))),[],import.meta.url)}}),J.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return r(()=>import(`./asterisk-BEn0Cwpx.js`).then(e=>wK(e.asterisk)),[],import.meta.url)}}),J.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return r(()=>import(`./brainfuck-D5EjA2JK.js`).then(e=>wK(e.brainfuck)),[],import.meta.url)}}),J.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return r(()=>import(`./cobol-DHLQUbN7.js`).then(e=>wK(e.cobol)),[],import.meta.url)}}),J.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return r(()=>import(`./clike-xvONpD0Z.js`).then(e=>wK(e.csharp)),[],import.meta.url)}}),J.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return r(()=>import(`./clojure-BflJGmDX.js`).then(e=>wK(e.clojure)),[],import.meta.url)}}),J.of({name:`ClojureScript`,extensions:[`cljs`],load(){return r(()=>import(`./clojure-BflJGmDX.js`).then(e=>wK(e.clojure)),[],import.meta.url)}}),J.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return r(()=>import(`./css-CnaYoQib.js`).then(e=>wK(e.gss)),[],import.meta.url)}}),J.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return r(()=>import(`./cmake-84nbDH0I.js`).then(e=>wK(e.cmake)),[],import.meta.url)}}),J.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return r(()=>import(`./coffeescript-De_zI4J0.js`).then(e=>wK(e.coffeeScript)),[],import.meta.url)}}),J.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return r(()=>import(`./commonlisp-DgAKBe0r.js`).then(e=>wK(e.commonLisp)),[],import.meta.url)}}),J.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return r(()=>import(`./cypher-p9eYesGn.js`).then(e=>wK(e.cypher)),[],import.meta.url)}}),J.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return r(()=>import(`./python-B_1Jd8HM.js`).then(e=>wK(e.cython)),[],import.meta.url)}}),J.of({name:`Crystal`,extensions:[`cr`],load(){return r(()=>import(`./crystal-Bl6YKCG_.js`).then(e=>wK(e.crystal)),[],import.meta.url)}}),J.of({name:`D`,extensions:[`d`],load(){return r(()=>import(`./d-DWkQyNnU.js`).then(e=>wK(e.d)),[],import.meta.url)}}),J.of({name:`Dart`,extensions:[`dart`],load(){return r(()=>import(`./clike-xvONpD0Z.js`).then(e=>wK(e.dart)),[],import.meta.url)}}),J.of({name:`diff`,extensions:[`diff`,`patch`],load(){return r(()=>import(`./diff-ChtP43wD.js`).then(e=>wK(e.diff)),[],import.meta.url)}}),J.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return r(()=>import(`./dockerfile-DJkHQgkl.js`).then(e=>wK(e.dockerFile)),__vite__mapDeps([50,51]),import.meta.url)}}),J.of({name:`DTD`,extensions:[`dtd`],load(){return r(()=>import(`./dtd-DTF72YNO.js`).then(e=>wK(e.dtd)),[],import.meta.url)}}),J.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return r(()=>import(`./dylan-S7ucR4pR.js`).then(e=>wK(e.dylan)),[],import.meta.url)}}),J.of({name:`EBNF`,load(){return r(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>wK(e.ebnf)),[],import.meta.url)}}),J.of({name:`ECL`,extensions:[`ecl`],load(){return r(()=>import(`./ecl-BVIeWmwY.js`).then(e=>wK(e.ecl)),[],import.meta.url)}}),J.of({name:`edn`,extensions:[`edn`],load(){return r(()=>import(`./clojure-BflJGmDX.js`).then(e=>wK(e.clojure)),[],import.meta.url)}}),J.of({name:`Eiffel`,extensions:[`e`],load(){return r(()=>import(`./eiffel-BEjRio4Q.js`).then(e=>wK(e.eiffel)),[],import.meta.url)}}),J.of({name:`Elm`,extensions:[`elm`],load(){return r(()=>import(`./elm-Cshzl8qu.js`).then(e=>wK(e.elm)),[],import.meta.url)}}),J.of({name:`Erlang`,extensions:[`erl`],load(){return r(()=>import(`./erlang-BV0c4Hdn.js`).then(e=>wK(e.erlang)),[],import.meta.url)}}),J.of({name:`Esper`,load(){return r(()=>import(`./sql-DuQMFDvy.js`).then(e=>wK(e.esper)),[],import.meta.url)}}),J.of({name:`Factor`,extensions:[`factor`],load(){return r(()=>import(`./factor-LKH5gN8L.js`).then(e=>wK(e.factor)),__vite__mapDeps([52,51]),import.meta.url)}}),J.of({name:`FCL`,load(){return r(()=>import(`./fcl-ClOhbFR7.js`).then(e=>wK(e.fcl)),[],import.meta.url)}}),J.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return r(()=>import(`./forth-D6RzAl64.js`).then(e=>wK(e.forth)),[],import.meta.url)}}),J.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return r(()=>import(`./fortran-Bt6PBEDR.js`).then(e=>wK(e.fortran)),[],import.meta.url)}}),J.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return r(()=>import(`./mllike-B45xgp2S.js`).then(e=>wK(e.fSharp)),[],import.meta.url)}}),J.of({name:`Gas`,extensions:[`s`],load(){return r(()=>import(`./gas-BHEdbvp9.js`).then(e=>wK(e.gas)),[],import.meta.url)}}),J.of({name:`Gherkin`,extensions:[`feature`],load(){return r(()=>import(`./gherkin-oBAE_ms0.js`).then(e=>wK(e.gherkin)),[],import.meta.url)}}),J.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return r(()=>import(`./groovy-CUrWKPia.js`).then(e=>wK(e.groovy)),[],import.meta.url)}}),J.of({name:`Haskell`,extensions:[`hs`],load(){return r(()=>import(`./haskell-BRsoo5mP.js`).then(e=>wK(e.haskell)),[],import.meta.url)}}),J.of({name:`Haxe`,extensions:[`hx`],load(){return r(()=>import(`./haxe-DjVOVvNP.js`).then(e=>wK(e.haxe)),[],import.meta.url)}}),J.of({name:`HXML`,extensions:[`hxml`],load(){return r(()=>import(`./haxe-DjVOVvNP.js`).then(e=>wK(e.hxml)),[],import.meta.url)}}),J.of({name:`HTTP`,load(){return r(()=>import(`./http-CLVgA2GD.js`).then(e=>wK(e.http)),[],import.meta.url)}}),J.of({name:`IDL`,extensions:[`pro`],load(){return r(()=>import(`./idl-BUZw3wgd.js`).then(e=>wK(e.idl)),[],import.meta.url)}}),J.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return r(()=>import(`./javascript-lS2r2ifg.js`).then(e=>wK(e.jsonld)),[],import.meta.url)}}),J.of({name:`Julia`,extensions:[`jl`],load(){return r(()=>import(`./julia-CQfgDRfP.js`).then(e=>wK(e.julia)),[],import.meta.url)}}),J.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return r(()=>import(`./clike-xvONpD0Z.js`).then(e=>wK(e.kotlin)),[],import.meta.url)}}),J.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return r(()=>import(`./livescript-BXxG0Yva.js`).then(e=>wK(e.liveScript)),[],import.meta.url)}}),J.of({name:`Lua`,extensions:[`lua`],load(){return r(()=>import(`./lua-DPCEkfD_.js`).then(e=>wK(e.lua)),[],import.meta.url)}}),J.of({name:`mIRC`,extensions:[`mrc`],load(){return r(()=>import(`./mirc-C9zpzAZU.js`).then(e=>wK(e.mirc)),[],import.meta.url)}}),J.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return r(()=>import(`./mathematica-u8YMmbU0.js`).then(e=>wK(e.mathematica)),[],import.meta.url)}}),J.of({name:`Modelica`,extensions:[`mo`],load(){return r(()=>import(`./modelica-CqHI_q-D.js`).then(e=>wK(e.modelica)),[],import.meta.url)}}),J.of({name:`MUMPS`,extensions:[`mps`],load(){return r(()=>import(`./mumps-BSzj6Xyz.js`).then(e=>wK(e.mumps)),[],import.meta.url)}}),J.of({name:`Mbox`,extensions:[`mbox`],load(){return r(()=>import(`./mbox-BEMVcqjs.js`).then(e=>wK(e.mbox)),[],import.meta.url)}}),J.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return r(()=>import(`./nginx-C-ORUuei.js`).then(e=>wK(e.nginx)),[],import.meta.url)}}),J.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return r(()=>import(`./nsis-viPvXFiq.js`).then(e=>wK(e.nsis)),__vite__mapDeps([53,51]),import.meta.url)}}),J.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return r(()=>import(`./ntriples-CzMBulkp.js`).then(e=>wK(e.ntriples)),[],import.meta.url)}}),J.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return r(()=>import(`./clike-xvONpD0Z.js`).then(e=>wK(e.objectiveC)),[],import.meta.url)}}),J.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return r(()=>import(`./clike-xvONpD0Z.js`).then(e=>wK(e.objectiveCpp)),[],import.meta.url)}}),J.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return r(()=>import(`./mllike-B45xgp2S.js`).then(e=>wK(e.oCaml)),[],import.meta.url)}}),J.of({name:`Octave`,extensions:[`m`],load(){return r(()=>import(`./octave-D2Q8cUp1.js`).then(e=>wK(e.octave)),[],import.meta.url)}}),J.of({name:`Oz`,extensions:[`oz`],load(){return r(()=>import(`./oz-BwTct_5T.js`).then(e=>wK(e.oz)),[],import.meta.url)}}),J.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return r(()=>import(`./pascal-Dp_KdFgX.js`).then(e=>wK(e.pascal)),[],import.meta.url)}}),J.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return r(()=>import(`./perl-BkSkiI9m.js`).then(e=>wK(e.perl)),[],import.meta.url)}}),J.of({name:`Pig`,extensions:[`pig`],load(){return r(()=>import(`./pig-AF4Hwhju.js`).then(e=>wK(e.pig)),[],import.meta.url)}}),J.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return r(()=>import(`./powershell-D8WpQPaX.js`).then(e=>wK(e.powerShell)),[],import.meta.url)}}),J.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return r(()=>import(`./properties-C357ku5U.js`).then(e=>wK(e.properties)),[],import.meta.url)}}),J.of({name:`ProtoBuf`,extensions:[`proto`],load(){return r(()=>import(`./protobuf-D1ij_kNL.js`).then(e=>wK(e.protobuf)),[],import.meta.url)}}),J.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return r(()=>import(`./pug-BqCHZ5xT.js`).then(e=>wK(e.pug)),__vite__mapDeps([54,55]),import.meta.url)}}),J.of({name:`Puppet`,extensions:[`pp`],load(){return r(()=>import(`./puppet-BZyAS7I4.js`).then(e=>wK(e.puppet)),[],import.meta.url)}}),J.of({name:`Q`,extensions:[`q`],load(){return r(()=>import(`./q-B9NhS7L_.js`).then(e=>wK(e.q)),[],import.meta.url)}}),J.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return r(()=>import(`./r-CxDmU1I4.js`).then(e=>wK(e.r)),[],import.meta.url)}}),J.of({name:`RPM Changes`,load(){return r(()=>import(`./rpm-gpDK5sbt.js`).then(e=>wK(e.rpmChanges)),[],import.meta.url)}}),J.of({name:`RPM Spec`,extensions:[`spec`],load(){return r(()=>import(`./rpm-gpDK5sbt.js`).then(e=>wK(e.rpmSpec)),[],import.meta.url)}}),J.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return r(()=>import(`./ruby-ChfNwlCY.js`).then(e=>wK(e.ruby)),[],import.meta.url)}}),J.of({name:`SAS`,extensions:[`sas`],load(){return r(()=>import(`./sas-C2OyD2Y6.js`).then(e=>wK(e.sas)),[],import.meta.url)}}),J.of({name:`Scala`,extensions:[`scala`],load(){return r(()=>import(`./clike-xvONpD0Z.js`).then(e=>wK(e.scala)),[],import.meta.url)}}),J.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return r(()=>import(`./scheme-D9qYN0V5.js`).then(e=>wK(e.scheme)),[],import.meta.url)}}),J.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return r(()=>import(`./shell-DwuoZtxw.js`).then(e=>wK(e.shell)),[],import.meta.url)}}),J.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return r(()=>import(`./sieve-tLWDfEkZ.js`).then(e=>wK(e.sieve)),[],import.meta.url)}}),J.of({name:`Smalltalk`,extensions:[`st`],load(){return r(()=>import(`./smalltalk-BLp5-jwC.js`).then(e=>wK(e.smalltalk)),[],import.meta.url)}}),J.of({name:`Solr`,load(){return r(()=>import(`./solr-B78wSQJQ.js`).then(e=>wK(e.solr)),[],import.meta.url)}}),J.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return r(()=>import(`./mllike-B45xgp2S.js`).then(e=>wK(e.sml)),[],import.meta.url)}}),J.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return r(()=>import(`./sparql-Dz-mlCAC.js`).then(e=>wK(e.sparql)),[],import.meta.url)}}),J.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return r(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>wK(e.spreadsheet)),[],import.meta.url)}}),J.of({name:`Squirrel`,extensions:[`nut`],load(){return r(()=>import(`./clike-xvONpD0Z.js`).then(e=>wK(e.squirrel)),[],import.meta.url)}}),J.of({name:`Stylus`,extensions:[`styl`],load(){return r(()=>import(`./stylus-BOVgKnng.js`).then(e=>wK(e.stylus)),[],import.meta.url)}}),J.of({name:`Swift`,extensions:[`swift`],load(){return r(()=>import(`./swift-DKB6_1j6.js`).then(e=>wK(e.swift)),[],import.meta.url)}}),J.of({name:`sTeX`,load(){return r(()=>import(`./stex-DNzd62Q_.js`).then(e=>wK(e.stex)),[],import.meta.url)}}),J.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return r(()=>import(`./stex-DNzd62Q_.js`).then(e=>wK(e.stex)),[],import.meta.url)}}),J.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return r(()=>import(`./verilog-CjI9Y6RI.js`).then(e=>wK(e.verilog)),[],import.meta.url)}}),J.of({name:`Tcl`,extensions:[`tcl`],load(){return r(()=>import(`./tcl-BGfruO1u.js`).then(e=>wK(e.tcl)),[],import.meta.url)}}),J.of({name:`Textile`,extensions:[`textile`],load(){return r(()=>import(`./textile-C4jVoHG1.js`).then(e=>wK(e.textile)),[],import.meta.url)}}),J.of({name:`TiddlyWiki`,load(){return r(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>wK(e.tiddlyWiki)),[],import.meta.url)}}),J.of({name:`Tiki wiki`,load(){return r(()=>import(`./tiki-CvUEFusT.js`).then(e=>wK(e.tiki)),[],import.meta.url)}}),J.of({name:`TOML`,extensions:[`toml`],load(){return r(()=>import(`./toml-BPTmHmyx.js`).then(e=>wK(e.toml)),[],import.meta.url)}}),J.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return r(()=>import(`./troff-C2dAgh7P.js`).then(e=>wK(e.troff)),[],import.meta.url)}}),J.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return r(()=>import(`./ttcn-PPSTk1ow.js`).then(e=>wK(e.ttcn)),[],import.meta.url)}}),J.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return r(()=>import(`./ttcn-cfg-2b4Gb5sE.js`).then(e=>wK(e.ttcnCfg)),[],import.meta.url)}}),J.of({name:`Turtle`,extensions:[`ttl`],load(){return r(()=>import(`./turtle-Cx3rYX2g.js`).then(e=>wK(e.turtle)),[],import.meta.url)}}),J.of({name:`Web IDL`,extensions:[`webidl`],load(){return r(()=>import(`./webidl-D5jiJvOU.js`).then(e=>wK(e.webIDL)),[],import.meta.url)}}),J.of({name:`VB.NET`,extensions:[`vb`],load(){return r(()=>import(`./vb-BthdM_4N.js`).then(e=>wK(e.vb)),[],import.meta.url)}}),J.of({name:`VBScript`,extensions:[`vbs`],load(){return r(()=>import(`./vbscript-D9f6rSsU.js`).then(e=>wK(e.vbScript)),[],import.meta.url)}}),J.of({name:`Velocity`,extensions:[`vtl`],load(){return r(()=>import(`./velocity-CqftRsjg.js`).then(e=>wK(e.velocity)),[],import.meta.url)}}),J.of({name:`Verilog`,extensions:[`v`],load(){return r(()=>import(`./verilog-CjI9Y6RI.js`).then(e=>wK(e.verilog)),[],import.meta.url)}}),J.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return r(()=>import(`./vhdl-kS471soi.js`).then(e=>wK(e.vhdl)),[],import.meta.url)}}),J.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return r(()=>import(`./xquery-BKJx4mf9.js`).then(e=>wK(e.xQuery)),[],import.meta.url)}}),J.of({name:`Yacas`,extensions:[`ys`],load(){return r(()=>import(`./yacas-CXXgtw0p.js`).then(e=>wK(e.yacas)),[],import.meta.url)}}),J.of({name:`Z80`,extensions:[`z80`],load(){return r(()=>import(`./z80-Co3PbHdE.js`).then(e=>wK(e.z80)),[],import.meta.url)}}),J.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return r(()=>import(`./mscgen-qgSLujhx.js`).then(e=>wK(e.mscgen)),[],import.meta.url)}}),J.of({name:`Xù`,extensions:[`xu`],load(){return r(()=>import(`./mscgen-qgSLujhx.js`).then(e=>wK(e.xu)),[],import.meta.url)}}),J.of({name:`MsGenny`,extensions:[`msgenny`],load(){return r(()=>import(`./mscgen-qgSLujhx.js`).then(e=>wK(e.msgenny)),[],import.meta.url)}}),J.of({name:`Vue`,extensions:[`vue`],load(){return r(()=>import(`./dist-gLcMD1Nm.js`).then(e=>e.vue()),__vite__mapDeps([56,35,30,33,1,36,31]),import.meta.url)}}),J.of({name:`Angular Template`,load(){return r(()=>import(`./dist-CNry8POH.js`).then(e=>e.angular()),__vite__mapDeps([57,35,30,33,1,36,31]),import.meta.url)}})],VVe={c:[`c`],cpp:[`c++`,`cpp`],cs:[`c#`,`csharp`],js:[`javascript`],jsx:[`javascript jsx`,`jsx`],md:[`markdown`],py:[`python`],sh:[`shell`,`bash`],ts:[`typescript`],tsx:[`typescript jsx`,`tsx`],yml:[`yaml`],zsh:[`shell`,`bash`]};function HVe(e){let t=e===`plaintext`?`text`:e;return[t,...VVe[t]??[]]}async function UVe(e){if(e===`text`)return[];let t=HVe(e);for(let e of t){let t=J.matchLanguageName(BVe,e,!0);if(t)try{return await t.load()}catch{}}return[]}function WVe(e){let{main:t}=e.state.selection;return t.empty?e.state.doc.lineAt(t.head).number===1:!1}function GVe(e){let{main:t}=e.state.selection;return t.empty?e.state.doc.lineAt(t.head).number===e.state.doc.lines:!1}var KVe=vO.theme({"&":{backgroundColor:`transparent`},"&.cm-editor":{outline:`none`},"&.cm-editor.cm-focused":{outline:`none`},"&.cm-editor .cm-gutters":{backgroundColor:`var(--cm-gutter-bg, transparent)`,border:`none`},".cm-scroller":{overflow:`auto`,fontFamily:`inherit`},".cm-content":{minHeight:`1.5em`},".cm-selectionBackground":{backgroundColor:`rgba(125, 125, 125, 0.26) !important`}});function qVe(e){return e&&e.trim().toLowerCase()||`text`}var JVe={"":!0,text:!0,plaintext:!0,plain:!0,txt:!0},YVe={sh:!0,bash:!0,shell:!0,zsh:!0,console:!0};function XVe(e,t){let n=e.trim().toLowerCase();return Object.hasOwn(JVe,n)?`text`:Object.hasOwn(YVe,n)&&!t.trimEnd().includes(`
|
|
199
|
+
`)?`shell-line`:`code`}var ZVe=QSe(KO([{tag:[ck.keyword,ck.bool,ck.null,ck.atom],class:`ryugi-tok-kw`},{tag:ck.number,class:`ryugi-tok-num`},{tag:[ck.string,ck.regexp,ck.character],class:`ryugi-tok-str`},{tag:ck.comment,class:`ryugi-tok-cm`},{tag:[ck.punctuation,ck.operator],class:`ryugi-tok-punc`}])),EK=uee.map(({id:e,name:t})=>({id:e,name:t})),QVe=()=>`$`;function DK(e,t){return t||e===`text`?[]:e===`shell-line`?zO({formatNumber:QVe}):zO()}function $Ve({language:e,onChange:t}){let[n,r]=(0,G.useState)(``),a=(0,G.useMemo)(()=>EK.find(t=>t.id===e)??(e===`text`?null:{id:e,name:e}),[e]),o=(0,G.useMemo)(()=>{let e=a&&!EK.includes(a)?[...EK,a]:EK,t=n.trim().toLowerCase();return!t||e.some(e=>e.id===t)?e:[...e,{id:t,name:t}]},[n,a]);return(0,K.jsxs)(V,{autoHighlight:!0,itemToStringLabel:e=>e.id,itemToStringValue:e=>e.id,items:o,value:a,onInputValueChange:r,onValueChange:e=>e&&t?.(e.id),children:[(0,K.jsx)(yee,{"aria-label":i(`codeblock.language`),className:`ryugi-codeblock-picker`,placeholder:i(`codeblock.language`),onKeyDown:e=>e.stopPropagation()}),(0,K.jsxs)(See,{align:`start`,side:`bottom`,sideOffset:6,children:[(0,K.jsx)(ke,{children:i(`codeblock.noLanguage`)}),(0,K.jsx)(Ce,{children:e=>(0,K.jsx)(wee,{value:e,children:e.name},e.id)})]})]})}function OK({code:e,language:t,editable:n=!1,selected:r=!1,cursorPlacement:a=`start`,onCodeChange:o,onLanguageChange:s,onDelete:c,onExitBlock:u}){let d=Gj(),f=d===`comment`||d===`chat`,p=lF()===`dark`,m=qVe(t),h=XVe(m,e),g=e.split(`
|
|
200
|
+
`).length,_=(0,G.useRef)(null),v=(0,G.useRef)(null),y=(0,G.useRef)(null),[b,x]=(0,G.useState)(!1),[S,w]=(0,G.useState)(!1),[T,E]=(0,G.useState)(!1),[D,O]=(0,G.useState)(!1),k=(0,G.useRef)({editable:n,onCodeChange:o,onDelete:c,onExitBlock:u,suppress:!1});(0,G.useLayoutEffect)(()=>{k.current={...k.current,editable:n,onCodeChange:o,onDelete:c,onExitBlock:u}});let A=(0,G.useMemo)(()=>({dark:new $C,editable:new $C,gutter:new $C,language:new $C}),[]);(0,G.useEffect)(()=>{let t=ZC.high(vO.domEventHandlers({keydown:(e,t)=>{let n=k.current;if(!n.editable)return!1;e.stopPropagation();let r=t=>(e.preventDefault(),n.onExitBlock?.(t),!0);return(e.metaKey||e.ctrlKey)&&e.key===`Enter`?r(`after`):e.key===`ArrowUp`&&WVe(t)?r(`before`):e.key===`ArrowDown`&&GVe(t)?r(`after`):e.key===`Backspace`&&t.state.doc.length===0&&(e.preventDefault(),n.onDelete?.(),!0)}})),r=new vO({parent:_.current,state:bw.create({doc:e,extensions:[IBe(),CO.of([...RVe,...GBe,zVe]),vO.updateListener.of(e=>{e.docChanged&&!k.current.suppress&&k.current.onCodeChange?.(e.state.doc.toString())}),t,A.editable.of([vO.editable.of(n),bw.readOnly.of(!n)]),A.gutter.of(DK(h,f)),A.language.of([]),A.dark.of(vO.darkTheme.of(p)),KVe,ZVe]})});return y.current=r,x(!0),()=>{r.destroy(),y.current=null,x(!1)}},[]),(0,G.useEffect)(()=>{y.current?.dispatch({effects:A.editable.reconfigure([vO.editable.of(n),bw.readOnly.of(!n)])})},[A,n]),(0,G.useEffect)(()=>{y.current?.dispatch({effects:A.gutter.reconfigure(DK(h,f))})},[A,h,f]),(0,G.useEffect)(()=>{y.current?.dispatch({effects:A.dark.reconfigure(vO.darkTheme.of(p))})},[A,p]),(0,G.useEffect)(()=>{let t=y.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(k.current.suppress=!0,t.dispatch({changes:{from:0,to:n.length,insert:e}}),k.current.suppress=!1)},[e]),(0,G.useEffect)(()=>{let e=!1;return UVe(m).then(t=>{e||y.current?.dispatch({effects:A.language.reconfigure(t)})}),()=>{e=!0}},[A,m]),(0,G.useEffect)(()=>{let e=y.current;if(!n||!r||!e)return;let t=requestAnimationFrame(()=>{e.hasFocus||(e.focus(),e.dispatch({selection:zC.cursor(a===`end`?e.state.doc.length:0),scrollIntoView:!0}))});return()=>cancelAnimationFrame(t)},[a,n,b,r]);let j=h!==`shell-line`,M=n&&r;(0,G.useEffect)(()=>{M&&O(!0)},[M]),(0,G.useLayoutEffect)(()=>{E(j&&(v.current?.scrollHeight??0)>=window.innerHeight/2)},[e,j,b]);let N=j&&T&&!D&&!M;return(0,K.jsxs)(`div`,{className:`ryugi-codeblock`,"data-compact":f?``:void 0,"data-editable":n?``:void 0,"data-folded":N?``:void 0,"data-kind":h,onFocusCapture:n?e=>{v.current?.contains(e.target)&&O(!0)}:void 0,children:[(0,K.jsxs)(`div`,{className:`ryugi-codeblock-head`,children:[n?(0,K.jsx)($Ve,{language:m,onChange:s}):h===`code`&&(0,K.jsx)(`span`,{className:`ryugi-codeblock-lang`,children:m}),(0,K.jsx)(`span`,{className:`ryugi-codeblock-spacer`}),(0,K.jsxs)(`button`,{"aria-label":i(S?`common.copied`:`codeblock.copy`),className:`ryugi-codeblock-copy`,type:`button`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>{w(!0),setTimeout(()=>w(!1),2e3)})},children:[S?(0,K.jsx)(C,{size:14}):(0,K.jsx)(Ir,{size:14}),(0,K.jsx)(`span`,{children:i(S?`common.copied`:`codeblock.copyShort`)})]})]}),(0,K.jsxs)(`div`,{className:`ryugi-codeblock-body`,ref:v,children:[!b&&(0,K.jsx)(`pre`,{className:`ryugi-codeblock-fallback`,children:(0,K.jsx)(`code`,{children:e})}),(0,K.jsx)(`div`,{ref:_})]}),N&&(0,K.jsxs)(`button`,{className:`ryugi-codeblock-expand`,type:`button`,onClick:()=>O(!0),children:[(0,K.jsx)(`span`,{children:i(`codeblock.expand`,{count:g})}),(0,K.jsx)(l,{size:14})]})]})}var eHe=[[`flowchart`,`flowchart-elk`,/^\s*flowchart-elk/],[`mindmap`,`mindmap`,/^\s*mindmap/],[`architecture`,`architecture`,/^\s*architecture/],[`agentflow`,`agentflow`,/^\s*agentflow-beta\b/],[`c4`,`c4`,/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/],[`kanban`,`kanban`,/^\s*kanban/],[`class`,`classDiagram`,/^\s*classDiagram/],[`er`,`er`,/^\s*erDiagram/],[`gantt`,`gantt`,/^\s*gantt/],[`info`,`info`,/^\s*info/],[`pie`,`pie`,/^\s*pie/],[`requirement`,`requirement`,/^\s*requirement(Diagram)?/],[`sequence`,`sequence`,/^\s*sequenceDiagram/],[`swimlane`,`swimlane`,/^\s*swimlane-beta\b/],[`flowchart`,`flowchart-v2`,/^\s*(graph|flowchart)/],[`timeline`,`timeline`,/^\s*timeline/],[`gitGraph`,`gitGraph`,/^\s*gitGraph/],[`state`,`stateDiagram`,/^\s*stateDiagram/],[`journey`,`journey`,/^\s*journey/],[`quadrantChart`,`quadrantChart`,/^\s*quadrantChart/],[`sankey`,`sankey`,/^\s*sankey(-beta)?/],[`packet`,`packet`,/^\s*packet(-beta)?/],[`xychart`,`xychart`,/^\s*xychart(-beta)?/],[`block`,`block`,/^\s*block(-beta)?/],[`eventmodeling`,`eventmodeling`,/^\s*eventmodeling/],[`treeView`,`treeView`,/^\s*treeView-beta/],[`radar`,`radar`,/^\s*radar-beta/],[`ishikawa`,`ishikawa`,/^\s*ishikawa(-beta)?\b/i],[`treemap`,`treemap`,/^\s*treemap/],[`railroad`,`railroad`,/^\s*railroad-beta/i],[`railroad`,`railroadEbnf`,/^\s*railroad-ebnf-beta/i],[`railroad`,`railroadAbnf`,/^\s*railroad-abnf-beta/i],[`railroad`,`railroadPeg`,/^\s*railroad-peg-beta/i],[`venn`,`venn`,/^\s*venn-beta/],[`wardley`,`wardley`,/^\s*wardley-beta/i],[`cynefin`,`cynefin`,/^\s*cynefin-beta(?:[\s:]|$)/],[`usecase`,`usecase`,/^\s*usecase-beta(?:\s|$)/]];function tHe(e){for(let[t,n,r]of eHe)if(r.test(e))return{type:t,mermaidType:n};return null}var kK=class extends Error{code;type;mermaidType;line;column;snippet;constructor(e,t=`syntax`,n={}){super(e),this.name=`PeleError`,this.code=t,this.type=n.type??null,this.mermaidType=n.mermaidType??null,this.line=n.line??0,this.column=n.column??0,this.snippet=n.snippet??``}};function AK(e,t){let n=1,r=0;for(let i=e.indexOf(`
|
|
201
201
|
`);i!==-1&&i<t;i=e.indexOf(`
|
|
202
202
|
`,i+1))n++,r=i+1;let i=e.indexOf(`
|
|
203
203
|
`,t);i===-1&&(i=e.length);let a=t-r+1,o=e.slice(r,i);return{line:n,column:a,snippet:o+`
|
|
@@ -385,13 +385,13 @@ but found: '${K8(H8)}'`);(I8[z8[H8]]&N8)!==0;)H8++;return R8.slice(B8[e],V8[H8-1
|
|
|
385
385
|
}
|
|
386
386
|
`,L7=h8e,_8e=g8e,v8e=function(e){var t=e.children,n=e.wrapperClass,r=n===void 0?``:n,i=e.contentClass,a=i===void 0?``:i,o=e.wrapperStyle,s=e.contentStyle,c=e.wrapperProps,l=c===void 0?{}:c,u=e.contentProps,d=u===void 0?{}:u,f=e.infinite,p=f!==void 0&&f,m=e.nonce,h=e.disableStyleInjection,g=h!==void 0&&h,_=(0,G.useContext)(I7),v=_.init,y=_.cleanupWindowEvents,b=(0,G.useRef)(null),x=(0,G.useRef)(null),S=(0,G.useRef)(null);N7(function(){var e=b.current,t=x.current;return e!==null&&!g&&x6e(e,_8e,m),e!==null&&t!==null&&v&&v?.(e,t),function(){y?.()}},[]),(0,G.useEffect)(function(){if(p){var e=S.current;if(e){var t=function(){var t=_.state,n=t.positionX,r=t.positionY;e.style.backgroundPosition=`${n}px ${r}px`};return t(),_.onChange(t)}}},[p,_]);var C=!_.setup.keyboard?.disabled;return(0,K.jsxs)(`div`,g7({tabIndex:C?0:void 0},l,{ref:b,className:`${y7.wrapperClass} ${L7.wrapper} ${r}`,style:o},{children:[p&&(0,K.jsx)(`div`,{ref:S,className:L7.infiniteGrid,"aria-hidden":!0}),(0,K.jsx)(`div`,g7({},d,{ref:x,className:`${y7.contentClass} ${L7.content} ${a}`,style:g7(g7({transformOrigin:`0 0`},s),{transform:S6e(_.state.positionX,_.state.positionY,_.state.scale)})},{children:t}))]}))};function y8e(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function b8e(e){var t=e.elementX,n=e.elementY,r=e.elementWidth,i=e.elementHeight,a=e.scale,o=e.positionX,s=e.positionY,c=e.viewportWidth,l=e.viewportHeight,u=e.margin,d=u===void 0?0:u,f=e.threshold,p=f===void 0?0:f,m={x:-d,y:-d,width:c+2*d,height:l+2*d},h={x:t*a+o,y:n*a+s,width:r*a,height:i*a};if(p<=0){var g=h.x<m.x+m.width&&h.x+h.width>m.x,_=h.y<m.y+m.height&&h.y+h.height>m.y;return g&&_}var v=h.width*h.height;return v<=0?!1:y8e(m,h)/v>=p}G.forwardRef(function(e,t){var n=e.x,r=e.y,i=e.width,a=e.height,o=e.margin,s=o===void 0?0:o,c=e.threshold,l=c===void 0?0:c,u=e.placeholder,d=u===void 0?null:u,f=e.onShow,p=e.onHide,m=e.children,h=e.className,g=e.style,_=(0,G.useContext)(I7),v=function(){var e=_.wrapperComponent;return e?b8e({elementX:n,elementY:r,elementWidth:i,elementHeight:a,scale:_.state.scale,positionX:_.state.positionX,positionY:_.state.positionY,viewportWidth:e.clientWidth,viewportHeight:e.clientHeight,margin:s,threshold:l}):!1},y=(0,G.useState)(v),b=y[0],x=y[1],S=(0,G.useRef)(!1),C=(0,G.useRef)(f),w=(0,G.useRef)(p);return C.current=f,w.current=p,N7(function(){var e=function(){var e,t;if(_.wrapperComponent){var n=v();n!==S.current&&(S.current=n,x(n),n?(e=C.current)==null||e.call(C):(t=w.current)==null||t.call(w))}};e();var t=_.onChange(e),n;return _.wrapperComponent||(n=_.onInit(function(){return e()})),function(){t(),n?.()}},[_,n,r,i,a,s,l]),b?(0,K.jsx)(`div`,g7({ref:t,className:h,style:g},{children:m})):d?(0,K.jsx)(K.Fragment,{children:d}):null}),[{value:`code`,label:`Code`},{value:`split`,label:`Split`},{value:`preview`,label:`Preview`}].filter(e=>e.value!==`split`);var x8e=()=>()=>{};function S8e(){let e=(0,G.use)(Dr)?.[0]??null;return(0,G.useSyncExternalStore)(e?t=>e.registerEditableListener(t):x8e,()=>e?.isEditable()??!1)}var C8e=e=>({bg:e?`#222222`:`#ffffff`,fg:e?`#ededed`:`#171717`,muted:e?`#8a8a8a`:`#737373`,line:e?`#a3a3a3`:`#525252`,surface:e?`#222222`:`#ffffff`,"surface-alt":e?`#2a2a2a`:`#f4f4f5`,border:e?`rgba(255,255,255,0.16)`:`rgba(0,0,0,0.14)`,radius:`8px`,font:`var(--lobe-font-family, sans-serif)`}),w8e={light:`#c65d3b`,dark:`#e0714c`},T8e=/<g class="pele-edge" data-id="([^"]*)"><path d="([^"]+)"\/>(.*?)<\/g>/g,E8e=/<path class="pele-marker" d="M(-?[\d.]+),(-?[\d.]+)L(-?[\d.]+),(-?[\d.]+)L(-?[\d.]+),(-?[\d.]+)Z"[^>]*\/>/g,R7=/^M(-?[\d.]+),(-?[\d.]+)/,z7=/(-?[\d.]+),(-?[\d.]+)$/,B7=e=>+e.toFixed(2),V7=e=>[Number(e[1]),Number(e[2])],D8e=0;function O8e(e,t,n){let r=[],i=e.replaceAll(T8e,(e,i,a,o)=>{let s=a,c=V7(R7.exec(s)),l=V7(z7.exec(s)),u={start:!1,end:!1},d=o.replaceAll(E8e,(e,...t)=>{let[r,i,a,o,d,f]=t.slice(0,6).map(Number),p=Math.hypot(r-(a+d)/2,i-(o+f)/2),m=(r-(a+d)/2)/p,h=(i-(o+f)/2)/p,g=B7(r-.9*m),_=B7(i-.9*h);Math.hypot(r-c[0],i-c[1])<Math.hypot(r-l[0],i-l[1])?(u.start=!0,s=s.replace(R7,`M${g},${_}`)):(u.end=!0,s=s.replace(z7,`${g},${_}`));let v=e=>`${B7(g-7.5*m-e*4.6*h)},${B7(_-7.5*h+e*4.6*m)}`;return`<path class="pele-marker ryugi-chevron" d="M${v(1)}L${g},${_}L${v(-1)}" fill="none" stroke="${n}" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>`});if(!u.start&&!u.end)return e;let f=`ryugi-edge-${++D8e}`,[p,m]=V7(R7.exec(s)),[h,g]=V7(z7.exec(s)),_=[...u.start?[[0,n],[.45,t]]:[[0,t]],...u.end?[[.55,t],[1,n]]:[[1,t]]];return r.push(`<linearGradient id="${f}" gradientUnits="userSpaceOnUse" x1="${p}" y1="${m}" x2="${h}" y2="${g}">${_.map(([e,t])=>`<stop offset="${e}" stop-color="${t}"/>`).join(``)}</linearGradient>`),`<g class="pele-edge" data-id="${i}"><path d="${s}" stroke="url(#${f})"/>${d}</g>`});return r.length?i.replace(/(<svg\b[^>]*>)/,e=>`${e}<defs>${r.join(``)}</defs>`):i}var k8e=/<g class="([^"]*)"[^>]*?\sdata-id="([^"]*)"/g,A8e={amp:`&`,lt:`<`,gt:`>`,quot:`"`,apos:`'`},j8e=e=>e.replaceAll(/&(amp|lt|gt|quot|apos|#39);/g,(e,t)=>A8e[t]??`'`);function M8e(e){let t={nodes:new Set,edges:new Set,terminals:new Set};for(let[,n,r]of e.matchAll(k8e)){let e=n.split(/\s+/),i=j8e(r);e.includes(`pele-state-start`)||e.includes(`pele-state-end`)?t.terminals.add(i):e.includes(`pele-node`)?t.nodes.add(i):e.includes(`pele-edge`)&&t.edges.add(i)}return t}function H7(e,t,n){let r=[];for(let[t,i]of e)n.nodes.has(t)&&r.push({kind:`node`,domId:t,label:i,target:{kind:`node`,id:t}});let i=new Map,a=e=>n.terminals.has(e)?`[*]`:e;for(let e of t){if(e.from===void 0||e.to===void 0)continue;let t=a(e.from),o=a(e.to),s=`${t}\u0000${o}`,c=i.get(s)??0;i.set(s,c+1),n.edges.has(e.domId)&&r.push({kind:`edge`,domId:e.domId,label:e.label,target:{kind:`edge`,from:t,to:o,index:c}})}return r}var N8e=e=>Array.isArray(e)?e.join(` `):e;function P8e(e,t){return e.type===`flowchart`?H7([...e.nodes.values()].map(e=>[e.id,e.text??e.id]),e.edges.map(e=>({domId:e.id??``,from:e.start,to:e.end,label:e.text})),t):e.type===`sequence`?H7([...e.actors].map(([e,t])=>[e,t.description||t.name]),e.messages.filter(e=>t.edges.has(`i${e.id}`)).map(e=>({domId:`i${e.id}`,from:e.from,to:e.to,label:typeof e.message==`string`?e.message:``})),t):e.type===`state`?H7([...e.states].map(([e,t])=>[e,N8e(t.description)||N8e(t.descriptions)||e]),t.edges.size===e.relations.length?e.relations.map((e,t)=>({domId:`edge${t}`,from:e.id1,to:e.id2,label:e.relationTitle??``})):[],t):[]}function F8e(e,t){let n=C8e(t===`dark`),r=Tie(e,{links:!1,images:!1}),i=Object.entries(n).map(([e,t])=>`--pele-${e}:${t};`).join(``),a=O8e(r.svg.replace(`style="`,()=>`style="${i}`),n.line,w8e[t]),o=[];try{o=P8e(Po(e),M8e(r.svg))}catch{o=[]}return{svg:a,width:r.width,height:r.height,type:String(r.mermaidType),elements:o}}var I8e=e=>{let t=``;for(let n of new TextEncoder().encode(e))t+=String.fromCodePoint(n);return`data:image/svg+xml;base64,${btoa(t)}`};function L8e(e,t){return(0,G.useMemo)(()=>{if(!e.trim())return null;try{let n=F8e(e,t);return{...n,src:I8e(n.svg)}}catch{return null}},[e,t])}function R8e(e){let t=e;for(;t?.parentElement&&!t.parentElement.hasAttribute(`data-lexical-editor`);)t=t.parentElement;if(!t?.parentElement)return null;for(let e=t.previousElementSibling;e;e=e.previousElementSibling)if(/^H[1-6]$/.test(e.tagName))return e.textContent?.trim()||null;return null}var z8e=[[`(((`,[`)))`]],[`([`,[`])`]],[`((`,[`))`]],[`[[`,[`]]`]],[`[(`,[`)]`]],[`[/`,[`/]`,`\\]`]],[`[\\`,[`\\]`,`/]`]],[`{{`,[`}}`]],[`[`,[`]`]],[`(`,[`)`]],[`{`,[`}`]],[`>`,[`]`]]],B8e=/^\s*(?:%%|flowchart\b|graph\b|subgraph\b|end\b|style\b|classDef\b|class\b|click\b|linkStyle\b|direction\b)/,U7=/[\p{L}\p{N}_]/u,V8e=/^[<ox]?(?:-{2,}|={2,}|-\.+-)(?:>|[ox](?![\p{L}\p{N}_]))?/u,H8e=/^(?:--|==|-\.)(?=\s)/,U8e=/\s(-{2,}>?|={2,}>?|\.-+>?)/,W8e=/["[\](){}<>|#;]/;function G8e(e,t,n){let r=t;if(e[t]===`"`){let n=e.indexOf(`"`,t+1);if(n<0)return null;r=n+1}let i=null;for(let t of n){let n=e.indexOf(t,r);n>=0&&(!i||n<i.at)&&(i={at:n,size:t.length})}return i?{label:{start:t,end:i.at},end:i.at+i.size}:null}function K8e(e,t,n){let r=0,i=e=>({start:e.start+t,end:e.end+t});for(;r<e.length;){let a=e[r],o=e.slice(r);if(/\s/.test(a))r+=1;else if(a===`;`)n.push({t:`sep`}),r+=1;else if(a===`&`)n.push({t:`amp`}),r+=1;else if(o.startsWith(`@{`)){let t=e.indexOf(`}`,r);r=t<0?e.length:t+1}else if(H8e.test(o)&&U8e.test(o.slice(2))){let a=U8e.exec(o.slice(2)),s=r+2,c=s+a.index,l=e.slice(s,c),u=s+l.length-l.trimStart().length,d=c-(l.length-l.trimEnd().length)+1,f={...i({start:u,end:Math.max(u,d-1)}),kind:`inline`};r=c+1+a[1].length,n.push({t:`link`,end:r+t,label:f})}else if(V8e.test(o)){r+=V8e.exec(o)[0].length;let a=null,s=r;for(;e[s]===` `;)s+=1;if(e[s]===`|`){let o=s+1;e[o]===`"`&&(o=e.indexOf(`"`,o+1)+1||e.length);let c=e.indexOf(`|`,o);if(c>=0){a={...i({start:r,end:c+1}),kind:`pipe`},n.push({t:`link`,end:r+t,label:a}),r=c+1;continue}}n.push({t:`link`,end:r+t,label:a})}else if(U7.test(a)){let a=r;for(;a<e.length&&U7.test(e[a]);)a+=1;let o=e.slice(r,a),s=null,c=a,l=z8e.find(([t])=>e.startsWith(t,a));if(l){let t=G8e(e,a+l[0].length,l[1]);t&&(s=i(t.label),c=t.end)}if(e.startsWith(`:::`,c))for(c+=3;c<e.length&&U7.test(e[c]);)c+=1;n.push({t:`node`,id:o,end:a+t,label:s}),r=c}else r+=1}}function q8e(e){let t=[],n=0;for(let r of e.split(`
|
|
387
387
|
`))B8e.test(r)||K8e(r,n,t),t.push({t:`sep`}),n+=r.length+1;return t}function J8e(e){let t=[],n=[],r=null,i=!1,a=()=>{if(r&&n.length){let e=r.from.length*n.length>1;for(let i of r.from)for(let a of n)t.push({from:i,to:a,link:r.link,shared:e})}};for(let t of e)t.t===`node`?(!i&&n.length&&!r&&(n=[]),n.push(t.id),i=!1):t.t===`amp`?i=!0:t.t===`link`?(a(),r={from:n,link:t},n=[]):(a(),r=null,n=[]);return t}var W7=e=>W8e.test(e)?`"${e.replaceAll(`"`,`#quot;`)}"`:e;function G7(e){let t=Po(e);return t.type===`flowchart`?t:null}function Y8e(e,t){let n=G7(e);return n?[...n.nodes.values()].find(e=>e.id===t)?.text:void 0}function X8e(e,t,n,r){return G7(e)?.edges.filter(e=>e.start===t&&e.end===n)[r]?.text}function Z8e(e){let t=G7(e);return t?`${t.nodes.size}:${t.edges.length}`:null}function Q8e(e,t,n){let r=n.trim(),i;try{i=Z8e(e)}catch{return null}if(!i)return null;let a=q8e(e),o=[];if(t.kind===`node`){if(!r)return null;let e=a.filter(e=>e.t===`node`&&e.id===t.id),n=e.filter(e=>e.label);if(n.length)for(let e of n)o.push({...e.label,text:W7(r)});else if(e[0])o.push({start:e[0].end,end:e[0].end,text:`[${W7(r)}]`});else return null}else{let n=J8e(a).filter(e=>e.from===t.from&&e.to===t.to)[t.index];if(!n||n.shared)return null;let i=n.link.label;if(i?.kind===`inline`){if(!r)return null;o.push({...i,text:W7(r)})}else if(i)o.push({...i,text:r?`|${W7(r)}|`:``});else if(r)o.push({start:n.link.end,end:n.link.end,text:`|${W7(r)}|`});else return e}let s=e;for(let e of[...o].sort((e,t)=>t.start-e.start))s=s.slice(0,e.start)+e.text+s.slice(e.end);try{if(Z8e(s)!==i)return null;let e=t.kind===`node`?Y8e(`flowchart LR\n X[${W7(r)}]`,`X`):X8e(`flowchart LR\n X -->${r?`|${W7(r)}|`:``} Y`,`X`,`Y`,0);return(t.kind===`node`?Y8e(s,t.id):X8e(s,t.from,t.to,t.index))===e?s:null}catch{return null}}function $8e(e){let t=typeof e?.line==`number`?e.line:null,n=e instanceof Error?e.message:String(e);return{line:t,message:n.split(`
|
|
388
|
-
`).map(e=>e.trim()).filter(Boolean).at(-1)??n}}function e5e(e,t){let n=(0,G.useRef)(null);return(0,G.useMemo)(()=>{try{let r=F8e(e,t);return n.current=r,{view:r,error:null}}catch(e){return{view:n.current,error:$8e(e)}}},[e,t])}var t5e={scrollX:0,scrollY:0,zoom:1},n5e=()=>()=>{};function r5e(e,t){let n=(0,G.useSyncExternalStore)(e?.store.subscribe??n5e,()=>e?.store.get()??null);return(0,G.useMemo)(()=>!e||!n||!t?[]:n.threads.filter(n=>n.status===`open`&&n.anchor.diagram&&Ur(n.anchor).includes(e.blockId)&&!lR(t,n.anchor.diagram,n.anchor.quote)).map(e=>uR(e.anchor.diagram,e.anchor.quote)),[e,n,t])}function i5e({comments:e,edit:t,initial:n,onCancel:r,onSaved:a,title:o}){let s=lF(),[c,l]=(0,G.useState)(n),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1),{view:m,error:h}=e5e(c,s),g=r5e(e,h?null:m?.elements??null),_=(0,G.useMemo)(()=>({__html:m?.svg??``}),[m?.svg]),y=c!==n,b=()=>{if(y&&!u)return d(!0);r()},x=()=>{if(!h){if(!f&&t.current()!==n)return p(!0);y&&t.save(c),a()}},S=null;return f?S=i(`mermaid.changedMeanwhile`):g.length&&(S=i(`mermaid.lostComments`,{labels:g.join(`、`)})),(0,K.jsxs)(`div`,{className:`x78zum5 xdt5ytf x5yr21d xqfszdh`,onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),b()):e.key===`s`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),x())},children:[(0,K.jsxs)(`div`,{className:`x78zum5 x6s0dn4 x167g77z x2lah0s xdd8jsf x1lgesdg xso031l x1q0q8m5 xtrfj0v`,children:[(0,K.jsx)(`span`,{"data-morph":`title`,className:`xif65rj x1s688f xo2rkog xuxw1ft`,children:o}),(0,K.jsx)(`span`,{className:`x1fao0z8 xfifm61 xddlp02`,children:i(`mermaid.editSource`)}),(0,K.jsx)(`span`,{className:`x98rzlu`}),S&&(0,K.jsxs)(`span`,{role:`status`,className:`x78zum5 x6s0dn4 x17d4w8g xeuugli xfifm61 x7zghnd xuxw1ft xb3r6kr xlyipyv`,children:[(0,K.jsx)(Rr,{"aria-hidden":`true`,size:13}),S]}),(0,K.jsx)(`button`,{type:`button`,onClick:b,className:`x1gnnpzl xaope02 xc342km xur7f20 xjbqb8w xj0l527 x1bo0w0s xjb2p0i xfifm61 xk50ysn x1ypdohk xtgyt42 x1hc1fzr x1lfpgzf`,children:i(u?`mermaid.discard`:`common.cancel`)}),(0,K.jsx)(`button`,{disabled:!!h,type:`button`,onClick:x,className:`x1gnnpzl xaope02 xc342km xur7f20 xjb2p0i xfifm61 xk50ysn x1ypdohk xtgyt42 x1hc1fzr x1lfpgzf x19ckca5 x1et1poy xs0jrwl`,children:i(f?`mermaid.saveAnyway`:`mermaid.save`)})]}),(0,K.jsxs)(`div`,{className:`x78zum5 x98rzlu x2lwn1j`,children:[(0,K.jsxs)(`div`,{"data-morph":`source`,className:`x78zum5 xdt5ytf x3p9ev8 x2lah0s xs1s249 x32b0ac x1vnv1x x2fo67v`,children:[(0,K.jsx)(`div`,{className:`xnlhpfx x1j6dyjg xddlp02`,children:i(`mermaid.source`)}),(0,K.jsx)(`textarea`,{"aria-label":i(`mermaid.source`),spellCheck:!1,value:c,onChange:e=>{l(e.target.value),d(!1)},onKeyDown:e=>{if(e.key!==`Tab`)return;e.preventDefault();let t=e.currentTarget;t.setRangeText(` `,t.selectionStart,t.selectionEnd,`end`),l(t.value)},className:`x98rzlu x15x03d9 xc342km x1a2a7pz xtt52l0 xjbqb8w xo2rkog x1fao0z8 x4z9k3i xa7kkou x1sdyfia xeq4nuv`}),h&&(0,K.jsxs)(`div`,{role:`alert`,className:`x78zum5 x1cy8zhl x167g77z xbnpv00 xfifm61 x1evy7pa xpt3syw x8yy6z1`,children:[(0,K.jsx)(v,{"aria-hidden":`true`,size:13}),(0,K.jsx)(`span`,{children:h.line===null?h.message:i(`mermaid.errorAt`,{line:h.line,message:h.message})})]})]}),(0,K.jsxs)(`div`,{className:`x1n2onr6 x98rzlu xeuugli xysyzu8`,className:`ryugi-diagram-canvas ${{className:`x1n2onr6 x98rzlu xeuugli xysyzu8`}.className??``}`,children:[(0,K.jsx)(Hr,{color:`var(--ryugi-diagram-dot)`,viewport:t5e}),(0,K.jsx)(`div`,{className:`x1n2onr6 x78zum5 x6s0dn4 xl56j7k x9f619 x1us19tq x15fnm84`,children:(0,K.jsx)(`div`,{...{0:{},1:{className:`xyd83as`}}[!!h|0],"aria-label":i(`mermaid.diagram`),className:`ryugi-diagram ryugi-mermaid-source-preview ${{0:{},1:{className:`xyd83as`}}[!!h|0].className??``}`,dangerouslySetInnerHTML:_,"data-morph":`drawing`,role:`img`,style:{width:m?.width,maxWidth:`100%`}})})]})]})]})}function a5e({comments:e}){let t=e.threads.filter(e=>e.status===`open`).length;return e.open||!t?null:(0,K.jsxs)(`button`,{"aria-label":i(`mermaid.showComments`,{count:t}),"data-diagram-comment-count":``,title:i(`mermaid.showComments`,{count:t}),type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),e.show()},className:`x10l6tqk x191j7n5 x1qpfodn xhtitgo x3nfvp2 x6s0dn4 x17d4w8g x1fgtraw x1awh872 xmkeg23 x1y0btm7 xkoleu3 xixl9f9 x12ilycc xo2rkog x1d5q07e xjb2p0i xfifm61 xss6m8b x1ypdohk`,children:[(0,K.jsx)(Rr,{"aria-hidden":`true`,size:14}),t]})}function o5e({comments:e}){let{draft:t}=e;return e.open?(0,K.jsxs)(`aside`,{"data-diagram-panel":``,className:`x10l6tqk x1imwcls xn5hqff xzkaem6 x78zum5 xdt5ytf x883omv x1m258z3 x4d2062 x1nk49em xc7ga6q x1odjw0f xmkeg23 x1y0btm7 x12xov25 x4pepcl x184qs1t xf6gj6t x1jl7r6f xllfotl xatqbsq`,children:[t?(0,K.jsx)(FR,{active:!0,children:(0,K.jsx)(Br,{autoFocus:!0,excerpt:{kind:`anchor`,icon:Wi,label:t.label},initial:t.initial,placeholder:i(`composer.placeholder`),onCancel:t.onCancel,onChange:t.onChange,onSubmit:t.onSubmit},t.key)}):null,e.threads.map(t=>(0,K.jsx)(IR,{actions:e.actions,active:t.id===e.activeId,agent:e.agent,thread:t,onActivate:()=>e.activate(t.id)},t.id))]}):null}var K7={type:`spring`,stiffness:380,damping:36},s5e={duration:.18,ease:[.4,0,1,1]},c5e=e=>new Map([...e.querySelectorAll(`[data-morph]`)].map(e=>[e.dataset.morph,e]));function l5e(e,t,n){let r=t.cloneNode(!0);r.removeAttribute(`data-morph`),r.dataset.morphGhost=e,Object.assign(r.style,{position:`fixed`,left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,margin:`0`,transformOrigin:`0 0`,pointerEvents:`none`,zIndex:`2000`});for(let e of r.querySelectorAll(`svg`))e.style.width=`100%`,e.style.height=`100%`,e.style.maxWidth=`none`;return document.body.append(r),r}function q7(e,t){let n=()=>{e.style.transform=`translate(${t.x.get()}px, ${t.y.get()}px) scale(${t.sx.get()}, ${t.sy.get()})`,e.style.opacity=String(t.opacity.get())};for(let e of Object.values(t))e.on(`change`,n);n()}function J7(e=0,t=1){return{x:j(e),y:j(0),sx:j(1),sy:j(1),opacity:j(t)}}async function u5e(e,t,n){let r=J7();q7(e,r),await Promise.all([b(r.x,n.left-t.left,K7),b(r.y,n.top-t.top,K7),b(r.sx,t.width?n.width/t.width:1,K7),b(r.sy,t.height?n.height/t.height:1,K7)])}async function d5e(e){let t=J7();q7(e,t),await Promise.all([b(t.x,-32,K7),b(t.opacity,0,s5e)])}async function f5e(e){let t=J7(-32,0);q7(e,t),e.style.visibility=``,await Promise.all([b(t.x,0,K7),b(t.opacity,1,K7)]),e.style.transform=``,e.style.opacity=``}function p5e(e,t){let n=(0,G.useRef)(null);return(0,G.useLayoutEffect)(()=>{let t=n.current;if(n.current=null,!t||!e.current)return;let r=c5e(e.current);for(let e of r.values())e.style.visibility=`hidden`;requestAnimationFrame(()=>{let e=[];for(let[n,{ghost:i,rect:a}]of t){let t=r.get(n),o=t?u5e(i,a,t.getBoundingClientRect()):d5e(i);e.push(o.then(()=>{i.remove(),t&&(t.style.visibility=``)}))}for(let[n,i]of r)t.has(n)||e.push(f5e(i));Promise.all(e)})},[e,t]),t=>{if(!e.current||Wr())return t();let r=new Map;for(let[t,n]of c5e(e.current)){let e=n.getBoundingClientRect();r.set(t,{ghost:l5e(t,n,e),rect:e})}n.current=r,t()}}var m5e=4,h5e=()=>()=>{};function g5e(e,t){let n=(0,G.useSyncExternalStore)(t?.store.subscribe??h5e,()=>t?t.store.get():null),r=t?.blockId??null,a=!!n?.viewer&&!n?.readOnly,[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(null),u=(0,G.useRef)(null),d=(0,G.useRef)(null),f=(0,G.useRef)(``),p=(0,G.useRef)(null),m=(0,G.useMemo)(()=>c&&r?{blockId:r,quote:c.label,diagram:c.target}:null,[c,r]),h=(0,G.useMemo)(()=>zR(e.elements,{threads:n?.threads??[],activeId:n?.activeId??null,draft:m},r),[e,n,m,r]),g=(0,G.useMemo)(()=>(n?.threads??[]).filter(e=>r!==null&&Ur(e.anchor).includes(r)&&(e.status===`open`||e.id===n?.activeId)),[n,r]);(0,G.useLayoutEffect)(()=>{u.current&&xR(u.current,e.elements,h,a,e=>i(`mermaid.commentOn`,{label:uR(e.target,e.label)}))},[e,h,a]);let _=e=>LR(r??``,e.label,void 0,void 0,e.target),v=()=>{p.current&&p.current.save(p.current.key,f.current),p.current=null};(0,G.useEffect)(()=>v,[]);let y=e=>{let t=n?.viewer?.drafts;if(!t)return;v();let r=_(e);f.current=t.take(r),p.current={key:r,save:t.save},l(e),s(!0)},b=()=>{v(),l(null),s(!1),n?.activeId&&n.activate(null)},x=t=>{let r=u.current?SR(t,u.current,e.elements):null;if(!r||!n)return!1;let i=h.get(r.element)?.threadIds[0];if(i)v(),l(null),n.activate(i),s(!0);else if(a)y(r.element);else return!1;return!0};return{drawing:u,open:o,threads:g,activeId:n?.activeId??null,actions:n?.viewer?.actions,agent:n?.viewer?.agent,activate:e=>n?.activate(e),show:()=>s(!0),draft:c?{key:_(c),label:uR(c.target,c.label),initial:f.current,onChange:e=>{f.current=e},onCancel:()=>{v(),l(null),g.length||s(!1)},onSubmit:async e=>!n?.viewer||!m||!await n.viewer.create(m,e)?!1:(f.current=``,v(),l(null),!0)}:null,canPick:a,stage:{onPointerDown:e=>{d.current={x:e.clientX,y:e.clientY}},onClick:e=>{let t=d.current;d.current=null,t&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>m5e||x(e.target)||b()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&x(e.target)&&e.preventDefault()},onPointerOver:t=>{if(!u.current||!n)return;let r=SR(t.target,u.current,e.elements)?.element??null;CR(u.current,r&&(a||h.has(r))?r:null)}}}}function Y7({label:e,onClick:t,children:n}){return(0,K.jsx)(`button`,{"aria-label":e,title:e,type:`button`,onClick:t,className:`x3nfvp2 x6s0dn4 x17d4w8g x1gnnpzl xdqyycr xc342km xur7f20 xjbqb8w xj0l527 x1bo0w0s xytdrwj xjb2p0i xfifm61 x1ypdohk`,children:n})}function _5e(e){let{close:t}=l(),n=(0,G.useRef)(null),[r,i]=(0,G.useState)(!!(e.editing&&e.edit)),a=p5e(n,r);return(0,K.jsx)(`div`,{ref:n,style:{height:`100%`},children:r&&e.edit?(0,K.jsx)(i5e,{comments:e.comments,edit:e.edit,initial:e.edit.current(),title:e.title,onCancel:()=>a(()=>i(!1)),onSaved:t}):(0,K.jsx)(v5e,{...e,onEdit:e.edit?()=>a(()=>i(!0)):void 0})})}function v5e({title:e,source:t,diagram:n,comments:r,onEdit:a}){let{close:o}=l(),s=g5e(n,r),u=(0,G.useMemo)(()=>({__html:n.svg}),[n.svg]),[d,f]=(0,G.useState)({scrollX:0,scrollY:0,zoom:1}),[p,m]=(0,G.useState)(!1),h=async()=>{await navigator.clipboard?.writeText(t),m(!0),setTimeout(()=>m(!1),1500)};return(0,K.jsx)(m8e,{limitToBounds:!1,maxScale:4,minScale:.05,wheel:{step:.002},onInit:e=>void e.fitToView({maxScale:1,animationTime:0}),onTransform:(e,{positionX:t,positionY:n,scale:r})=>f({scrollX:t/r,scrollY:n/r,zoom:r}),children:({zoomIn:t,zoomOut:r,fitToView:l,centerView:f})=>(0,K.jsxs)(`div`,{className:`x1n2onr6 x5yr21d xb3r6kr xqfszdh`,className:`ryugi-diagram-canvas ${{className:`x1n2onr6 x5yr21d xb3r6kr xqfszdh`}.className??``}`,children:[(0,K.jsxs)(`div`,{className:`x10l6tqk x10a8y8t`,...s.stage,children:[(0,K.jsx)(Hr,{color:`var(--ryugi-diagram-dot)`,viewport:d}),(0,K.jsx)(v8e,{wrapperClass:{className:`x1jm3nie xch2mbi`}.className,wrapperStyle:{width:`100%`,height:`100%`},children:(0,K.jsx)(`div`,{"aria-label":i(`mermaid.diagram`),className:`ryugi-diagram`,dangerouslySetInnerHTML:u,"data-morph":`drawing`,ref:s.drawing,role:s.canPick?`group`:`img`,style:{width:n.width,height:n.height}})}),(0,K.jsx)(a5e,{comments:s})]}),(0,K.jsxs)(`div`,{className:`x10l6tqk xhtitgo x78zum5 x6s0dn4 xfawy5m xmkeg23 x1y0btm7 x12xov25 x4pepcl x1rozbrz x1dpygf6 xomnu4r x1qpfodn x883omv x1vqgdyp x1sy7ncu xaope02`,children:[(0,K.jsx)(`span`,{"data-morph":`title`,className:`x2lah0s xh9uqaf xif65rj x1s688f xo2rkog xuxw1ft xb3r6kr xlyipyv`,children:e}),(0,K.jsx)(`span`,{className:`xeuugli x1fao0z8 xfifm61 xddlp02 xuxw1ft xb3r6kr xlyipyv`,children:`${n.type} · ${Math.round(n.width)} × ${Math.round(n.height)}`})]}),(0,K.jsxs)(`div`,{className:`x10l6tqk xhtitgo x78zum5 x6s0dn4 x195vfkc xfawy5m xmkeg23 x1y0btm7 x12xov25 x4pepcl x1rozbrz x1dpygf6 xomnu4r xn5hqff`,children:[a&&(0,K.jsxs)(`button`,{type:`button`,onClick:a,className:`x3nfvp2 x6s0dn4 x17d4w8g x1gnnpzl xdqyycr xc342km xur7f20 xjbqb8w xj0l527 x1bo0w0s xytdrwj xjb2p0i xfifm61 x1ypdohk`,children:[(0,K.jsx)(Pr,{"aria-hidden":`true`,size:14}),(0,K.jsx)(`span`,{children:i(`mermaid.editSource`)})]}),(0,K.jsxs)(`button`,{"aria-label":i(`mermaid.copySource`),type:`button`,onClick:()=>void h(),className:`x3nfvp2 x6s0dn4 x17d4w8g x1gnnpzl xdqyycr xc342km xur7f20 xjbqb8w xj0l527 x1bo0w0s xytdrwj xjb2p0i xfifm61 x1ypdohk`,children:[p?(0,K.jsx)(c,{size:14}):(0,K.jsx)(Ir,{size:14}),(0,K.jsx)(`span`,{className:`xkaaz9w`,children:i(p?`common.copied`:`mermaid.copySource`)})]}),(0,K.jsx)(Y7,{label:i(`common.close`),onClick:o,children:(0,K.jsx)(k,{size:16})})]}),(0,K.jsxs)(`div`,{className:`x10l6tqk xhtitgo x78zum5 x6s0dn4 x195vfkc xfawy5m xmkeg23 x1y0btm7 x12xov25 x4pepcl x1rozbrz x1dpygf6 x191j7n5 x1nrll8i xuuh30`,children:[(0,K.jsx)(Y7,{label:i(`mermaid.zoomOut`),onClick:()=>r(),children:(0,K.jsx)(x,{size:16})}),(0,K.jsx)(`span`,{className:`x1nb6za0 x2b8uid x1fao0z8 xfifm61 xss6m8b x1bo0w0s`,children:`${Math.round(d.zoom*100)}%`}),(0,K.jsx)(Y7,{label:i(`mermaid.zoomIn`),onClick:()=>t(),children:(0,K.jsx)(zr,{size:16})}),(0,K.jsx)(`span`,{className:`x1i1rx1s xmix8c7 xjgtzcg xh6qj2i xkaaz9w`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void l({maxScale:1}),className:`x6s0dn4 x17d4w8g x1gnnpzl xdqyycr xc342km xur7f20 xjbqb8w xj0l527 x1bo0w0s xytdrwj xjb2p0i xfifm61 x1ypdohk xkaaz9w`,children:i(`mermaid.fit`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void f(1),className:`x6s0dn4 x17d4w8g x1gnnpzl xdqyycr xc342km xur7f20 xjbqb8w xj0l527 x1bo0w0s xytdrwj xjb2p0i xfifm61 x1ypdohk xkaaz9w`,children:i(`mermaid.actualSize`)})]}),(0,K.jsx)(o5e,{comments:s})]})})}function y5e(e){p({content:(0,K.jsx)(_5e,{...e}),width:`calc(100vw - 2 * var(--ryugi-viewer-inset))`,classNames:{popup:`ryugi-mermaid-viewer`},styles:{content:{height:`100%`,padding:0,overflow:`hidden`}}})}var X7=8,Z7=280;function b5e({anchor:e,element:t,onCancel:n,onEditSource:r,onSave:a}){let o=(0,G.useRef)(null),s=(0,G.useRef)(null),c=(0,G.useRef)(!1),[l,u]=(0,G.useState)(t.label),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)({left:0,top:0});(0,G.useLayoutEffect)(()=>{let t=e.getBoundingClientRect(),n=o.current?.offsetHeight??0,r=t.top-n-X7;m({left:Math.max(X7,Math.min(t.left+t.width/2-Z7/2,innerWidth-Z7-X7)),top:r>=X7?r:t.bottom+X7}),s.current?.focus(),s.current?.select()},[e]);let h=e=>{c.current||(!e||l.trim()===t.label?(c.current=!0,n()):a(l)?c.current=!0:f(!0))},g=t.target.kind===`node`?i(`mermaid.renameNode`,{id:t.target.id}):i(`mermaid.renameEdge`,{label:uR(t.target,``)});return(0,Gi.createPortal)((0,K.jsxs)(`div`,{className:`ryugi-mermaid-rename`,ref:o,style:{left:p.left,top:p.top,width:Z7},onMouseDown:e=>e.stopPropagation(),children:[(0,K.jsx)(`div`,{className:`ryugi-mermaid-rename-caption`,children:g}),(0,K.jsx)(`input`,{"aria-label":g,ref:s,value:l,onBlur:e=>{o.current?.contains(e.relatedTarget)||h(!d)},onChange:e=>{u(e.target.value),f(!1)},onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),h(!0)):e.key===`Escape`&&(e.preventDefault(),h(!1))}}),d?(0,K.jsxs)(`div`,{className:`ryugi-mermaid-rename-note`,"data-failed":``,children:[i(`mermaid.cannotRename`),r&&(0,K.jsx)(`button`,{type:`button`,onClick:r,children:i(`mermaid.editSource`)})]}):(0,K.jsx)(`div`,{className:`ryugi-mermaid-rename-note`,children:i(`mermaid.renameKeys`)})]}),document.body)}var x5e={scrollX:0,scrollY:0,zoom:1},S5e=250;function C5e({content:e,onContentChange:t}){let n=lF(),r=L8e(e,n),a=(0,G.use)(RR),o=yne(`(hover: none)`),s=!!a&&!a?.readOnly&&!o,c=S8e()&&!o&&!!t,l=(0,G.useRef)(e),u=(0,G.useRef)(void 0);(0,G.useLayoutEffect)(()=>{l.current=e},[e]);let[d,f]=(0,G.useState)(null);(0,G.useEffect)(()=>()=>clearTimeout(u.current),[]);let p=(0,G.useMemo)(()=>gNe(),[]);(0,G.useEffect)(()=>p.set(a),[p,a]);let m=(0,G.useRef)(null),h=(0,G.useRef)(null),g=(0,G.useRef)(``),_=(0,G.useRef)(``),v=(0,G.useMemo)(()=>({__html:r?.svg??``}),[r?.svg]),[y,b]=(0,G.useState)(null);if((0,G.useLayoutEffect)(()=>b(R8e(m.current))),(0,G.useLayoutEffect)(()=>{if(!r||!h.current||!m.current)return;let e=zR(r.elements,a??{threads:[],activeId:null,draft:null},a?.blockIdOf(m.current)??null);xR(h.current,r.elements,e,s,e=>i(`mermaid.commentOn`,{label:uR(e.target,e.label)}));let t=_Ne(e);(t!==g.current||_.current!==r.svg)&&(g.current=t,_.current=r.svg,a?.marked())},[r,a,s]),!r)return(0,K.jsx)(o3e,{colorScheme:n,content:e});let x=(n=!1)=>{let s=m.current?a?.blockIdOf(m.current):null;f(null),y5e({source:e,diagram:r,title:R8e(m.current)??i(`mermaid.diagram`),comments:s&&!o?{blockId:s,store:p}:void 0,edit:c&&t?{current:()=>l.current,save:t}:void 0,editing:n})},S=t=>{if(!c||!h.current)return;let n=SR(t,h.current,r.elements);n&&Q8e(e,n.element.target,n.element.label)!==null&&f(n)},C=e=>{if(!a||!s||!h.current||!m.current)return!1;let t=SR(e,h.current,r.elements),n=a.blockIdOf(m.current);if(!t||!n)return!1;let i=zR(r.elements,a,n).get(t.element)?.threadIds[0];return i?a.activate(i):a.pick({blockId:n,element:t.element,node:t.node,host:m.current}),!0};return(0,K.jsxs)(`div`,{className:`ryugi-mermaid-preview ryugi-diagram ryugi-diagram-canvas`,"data-block-action":a?.blockAction?``:void 0,ref:m,onPointerLeave:()=>h.current&&CR(h.current,null),onClick:e=>{if(e.target instanceof Element&&e.target.closest(`button`))return;if(o)return x();if(!c){C(e.target)&&e.stopPropagation();return}if(clearTimeout(u.current),e.detail>1)return;let{target:t}=e;u.current=window.setTimeout(()=>C(t),S5e)},onDoubleClick:e=>{clearTimeout(u.current),S(e.target)},onKeyDownCapture:e=>{if(e.key===`Enter`||e.key===` `){if(e.target instanceof HTMLButtonElement)return e.stopPropagation();C(e.target)&&(e.preventDefault(),e.stopPropagation())}},onPointerOver:e=>{s&&h.current&&CR(h.current,SR(e.target,h.current,r.elements)?.element??null)},children:[(0,K.jsx)(Hr,{color:`var(--ryugi-diagram-dot)`,viewport:x5e}),y&&(0,K.jsx)(`span`,{className:`ryugi-mermaid-title`,children:y}),(0,K.jsx)(`div`,{"aria-label":i(`mermaid.diagram`),className:`ryugi-mermaid-drawing`,dangerouslySetInnerHTML:v,ref:h,role:s?`group`:`img`}),(0,K.jsx)(`div`,{className:`ryugi-mermaid-zoom`,children:(0,K.jsx)(`button`,{"aria-label":i(`mermaid.open`),title:i(`mermaid.open`),type:`button`,onClick:()=>x(),children:(0,K.jsx)(nne,{"aria-hidden":`true`,size:14})})}),c&&(0,K.jsx)(`span`,{className:`ryugi-mermaid-hint`,children:i(`mermaid.hint`)}),d&&(0,K.jsx)(b5e,{anchor:d.node,element:d.element,onCancel:()=>f(null),onEditSource:()=>x(!0),onSave:e=>{let n=Q8e(l.current,d.element.target,e);return n!==null&&(n!==l.current&&t?.(n),f(null),!0)}})]})}function w5e(e,t,n){let r=e.layout?gne(vne(e.canvas,e.layout),t):void 0;if(!r||!hne(e.threads,r.id).submitted)return{state:`unchosen`};let{choice:i}=mne(e.threads,t,n);return i?{state:`chosen`,choice:i}:{state:`unchosen`}}function Q7(e,t){if(!t)return{kind:`gone`};if(`unavailable`in t)return{kind:t.unavailable};if(`artifact`in t)return{kind:`artifact`,title:t.artifact.title||qr(e)};if(`verify`in t)return{kind:`verify`,title:t.verify.title||qr(e),state:t.verify.state};if(`document`in t){let{blocks:n,title:r}=t.document,i=r||qr(e);if(!e.block)return{kind:`artifact`,title:i};let a=Object.hasOwn(n,e.block)?n[e.block]:void 0;return a===void 0?{kind:`sectionGone`,document:i}:{kind:`section`,title:a||e.block,document:i}}if(`report`in t){let{blocks:n,title:r}=t.report;if(!e.block)return{kind:`report`,title:r||qr(e)};let i=Object.hasOwn(n,e.block)?n[e.block]:void 0;return i===void 0?{kind:`gone`}:{kind:`block`,title:i||e.block}}if(`slides`in t){let{slides:n,title:r}=t.slides;if(!e.slide)return{kind:`slides`,title:r||qr(e)};let i=Object.hasOwn(n,e.slide)?n[e.slide]:void 0;return i===void 0?{kind:`gone`}:{kind:`slide`,title:i||e.slide}}if(`whiteboard`in t){let{frames:n,title:r,pages:i}=t.whiteboard;if(e.page){let t=i?.[e.page];return t===void 0?{kind:`gone`}:{kind:`page`,title:t||e.page}}if(!e.frame)return{kind:`whiteboard`,title:r||qr(e)};let a=n[e.frame];return a===void 0?{kind:`gone`}:{kind:`frame`,title:a||e.frame}}let{canvas:n}=t;if(e.board){let t=n.boards[e.board];return t?{kind:`board`,title:t.title||e.board}:{kind:`gone`}}if(e.group){let r=n.groups?.[e.group];if(!r)return{kind:`gone`};let i=r.title||e.group;if(t.stateless)return{kind:`group`,title:i,state:`none`};if(r.choose)return{kind:`group`,title:i,...w5e(t,e.group,r.recommend)};if(r.verify){let{state:n}=_ne(t.threads,e.group,new Set(t.stale));return{kind:`group`,title:i,state:n===`pending`?`awaiting`:n}}return{kind:`group`,title:i,state:`none`}}return{kind:`artboard`,title:n.title||qr(e)}}var $7=(0,G.createContext)(null),T5e=e=>{let t=Jr(e);return e.to?[`${qr(e)}:${t}`,`${e.to}:${t}`]:[`${qr(e)}:${t}`]},E5e={artboard:Fte,document:_,html:Pr,board:rne,group:we,whiteboard:jr,frame:$te,page:ene,slides:ine,slide:Hne,report:Ar,block:rne,verify:une},D5e=e=>e.verify===void 0?e.document===void 0?e.html===void 0?e.slides===void 0?e.report===void 0?O5e(e):e.block?`block`:`report`:e.slide?`slide`:`slides`:`html`:`document`:`verify`,O5e=e=>e.whiteboard?e.frame?`frame`:e.page?`page`:`whiteboard`:e.board?`board`:e.group?`group`:`artboard`;function k5e({target:e,status:t,active:r=!1,self:i=!1,onOpen:a}){let{t:o}=n(),s=D5e(e),c=E5e[s],l=t?.kind===`locked`,u=t?.kind===`gone`||t?.kind===`unpublished`,d=l||u,f=t?.kind===`section`?t:null,p=t?.kind===`sectionGone`?t:null,m=t&&`title`in t?t.title:void 0,h=e.board??e.group??e.frame??e.page??e.slide??e.block,g=l?o(`refs.locked`):e.label??(f?i?`§ ${f.title}`:`${f.document} › ${f.title}`:p?p.document:s===`group`?m:m??h)??qr(e),_=t?.kind===`group`||t?.kind===`verify`?t.state:d?t.kind:p?`sectionGone`:void 0,v=t?.kind===`group`&&t.state!==`none`?o(`refs.${t.state}`,{choice:t.choice??``}):t?.kind===`verify`?o(`refs.verify_${t.state}`):u?o(`refs.${t.kind}`):p?o(`refs.sectionGone`):void 0,y=l?o(`refs.lockedHint`):u?o(`refs.${t.kind}`):e.whiteboard?o(`refs.openWhiteboard`):o(s===`document`||s===`html`||s===`slides`||s===`slide`||s===`report`||s===`block`||s===`verify`?`refs.openArtifact`:`refs.open`),b=l?Ute:c;return(0,K.jsxs)(`button`,{"data-ref-chip":qr(e),"data-ref-key":Jr(e),"data-ref-to":e.to,"data-state":_,disabled:d,title:y,type:`button`,onClick:t=>{if(t.preventDefault(),t.stopPropagation(),d)return;if(!p)return a(e);let{block:n,...r}=e;a(r)},...{0:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1y0btm7 x12xov25 x1kogg8i x2fo67v xo2rkog xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x1ypdohk x87ps6o xj0l527`},8:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1y0btm7 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x1ypdohk x87ps6o xj0l527 x11cp7ww x1mzvsll xqqczys`},4:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x12xov25 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x87ps6o xbsl7fq xjbqb8w xc7n51q x1h6gzvc x1n5bzlp`},12:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x87ps6o x11cp7ww xbsl7fq xjbqb8w xc7n51q x1h6gzvc x1n5bzlp`},2:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x12xov25 x1kogg8i x2fo67v xo2rkog xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x1ypdohk x87ps6o xj0l527 xbsl7fq`},10:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x1ypdohk x87ps6o xj0l527 x11cp7ww x1mzvsll xqqczys xbsl7fq`},6:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x12xov25 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x87ps6o xjbqb8w xc7n51q x1h6gzvc x1n5bzlp xbsl7fq`},14:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x87ps6o x11cp7ww xjbqb8w xc7n51q x1h6gzvc x1n5bzlp xbsl7fq`},1:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1y0btm7 x12xov25 x1kogg8i x2fo67v xo2rkog xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x1ypdohk x87ps6o xj0l527 xmqliwb`},9:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1y0btm7 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x1ypdohk x87ps6o xj0l527 x11cp7ww x1mzvsll xqqczys xmqliwb`},5:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x12xov25 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x87ps6o xbsl7fq xjbqb8w xc7n51q x1h6gzvc x1n5bzlp xmqliwb`},13:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x87ps6o x11cp7ww xbsl7fq xjbqb8w xc7n51q x1h6gzvc x1n5bzlp xmqliwb`},3:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x12xov25 x1kogg8i x2fo67v xo2rkog xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x1ypdohk x87ps6o xj0l527 xbsl7fq xmqliwb`},11:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x1ypdohk x87ps6o xj0l527 x11cp7ww x1mzvsll xqqczys xbsl7fq xmqliwb`},7:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x12xov25 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x87ps6o xjbqb8w xc7n51q x1h6gzvc x1n5bzlp xbsl7fq xmqliwb`},15:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x87ps6o x11cp7ww xjbqb8w xc7n51q x1h6gzvc x1n5bzlp xbsl7fq xmqliwb`}}[!!r<<3|!!d<<2|!!p<<1|t?.kind===`gone`],children:[(0,K.jsx)(b,{size:12}),!l&&s===`group`&&h&&(0,K.jsx)(`span`,{className:`x1fao0z8 x1j6dyjg xddlp02`,children:h}),(0,K.jsx)(`span`,{className:`xeuugli xb3r6kr xlyipyv`,children:g}),!l&&(s===`board`||(s===`slide`||s===`block`)&&g!==h)&&h&&(0,K.jsx)(`span`,{className:`x1fao0z8 x1j6dyjg xddlp02`,children:h}),!l&&!i&&(s===`artboard`||s===`whiteboard`||s===`document`||s===`html`||s===`slides`||s===`report`||s===`verify`)&&(0,K.jsx)(`span`,{className:`x1fao0z8 x1j6dyjg xddlp02`,children:o(`refs.${s}`)}),v&&(0,K.jsxs)(`span`,{className:`xddlp02`,children:[`· `,v]})]})}function A5e(e,t,n){let r=e.filter(e=>!e.isDeleted);if(t){let e=r.find(e=>e.id===t&&e.type===`frame`);if(!e)return{missing:`frame`};let n=new Set(r.filter(e=>e.frameId===t).map(e=>e.id));return{elements:r.filter(e=>n.has(e.id)||!!e.containerId&&n.has(e.containerId)),box:{x:e.x??0,y:e.y??0,w:e.width??0,h:e.height??0}}}if(!r.length)return{missing:`empty`};let i=n(r);return{elements:r,box:{x:i.minX,y:i.minY,w:i.width,h:i.height}}}var j5e=(e,t)=>A5e(e,t,e=>Tte(e)),M5e=`16 / 9`;function N5e(e,t){return e===void 0?`loading`:`unavailable`in e?e.unavailable:t&&`missing`in t?t.missing:`ready`}function P5e({view:e,files:t,label:n,light:r=!1}){let i=cte()&&!r,a=Sne(),{x:o,y:s,w:c,h:l}=e.box;return(0,K.jsx)(`svg`,{"aria-label":n,preserveAspectRatio:`xMidYMid meet`,role:`img`,viewBox:`${o} ${s} ${c} ${l}`,xmlns:`http://www.w3.org/2000/svg`,className:`x1lliihq xh8yej3 x5yr21d`,style:i?{filter:Uee}:void 0,children:(0,K.jsx)(Ste,{dark:i,files:t,handFontOverride:a?Gee:void 0,scene:{type:`excalidraw`,elements:e.elements,files:t}})})}function F5e({host:e,useScene:t,target:r}){let{t:i}=n(),o=e.useBoard(r),s=t(r),c=qr(r),l=o===void 0?void 0:Q7({whiteboard:c},o),u=l&&`title`in l&&l.title||c,d=s&&`scene`in s?j5e(s.scene.elements,r.frame):null,f=N5e(s,d),p={"data-whiteboard-embed":c,"data-ref-key":Jr(r),"data-state":f};if(f===`loading`)return(0,K.jsx)(`div`,{...p,className:`x78zum5 x6s0dn4 xl56j7k xh8yej3 x159tps6 x1jp4ehj xur7f20 x2fo67v`,style:{aspectRatio:M5e},children:(0,K.jsx)(a,{stack:!0,label:i(`embed.loading`),size:24})});if(!d||!(`box`in d)||!s||!(`scene`in s))return(0,K.jsxs)(`div`,{...p,className:`x78zum5 x6s0dn4 x883omv x1jp4ehj xxlmvz2 x1hr3lfm xmkeg23 xbsl7fq xgcsv5v xur7f20 x1bo0w0s x4z9k3i`,children:[(0,K.jsx)(jr,{size:16}),(0,K.jsx)(`span`,{className:`xo2rkog xk50ysn`,children:u}),(0,K.jsx)(`span`,{children:i(`embed.${f}`,{frame:r.frame??``})})]});let m=()=>e.openEmbed?.(s.page&&r.frame?{...r,page:s.page}:r);return(0,K.jsx)(`figure`,{...p,role:`button`,tabIndex:0,title:i(`embed.open`),onClick:e=>{e.preventDefault(),e.stopPropagation(),m()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),m())},className:`x1n2onr6 xh8yej3 x159tps6 x1jp4ehj xrxpjvj xb3r6kr xmkeg23 x1y0btm7 x12xov25 xur7f20 x1rozbrz x1huxd7x x1qj25k6 x784prv x9v5kkp xv8siiq`,style:{aspectRatio:`${d.box.w} / ${d.box.h}`},children:(0,K.jsx)(P5e,{files:s.scene.files??{},label:u,view:d})})}function I5e({target:e}){let t=(0,G.useContext)($7);return t?.useScene?(0,K.jsx)(F5e,{host:t,target:e,useScene:t.useScene}):(0,K.jsx)(R5e,{target:e})}var L5e=()=>void 0;function R5e({target:e}){let t=(0,G.useContext)($7),n=(t?.useBoard??L5e)(e),r=n===void 0?void 0:Q7(e,n);return(0,K.jsx)(k5e,{active:!!t?.active&&T5e(e).includes(t.active),self:!!t?.isSelf(e),status:r,target:e,onOpen:e=>t?.open(e)})}var z5e=class e extends wr{__ref;static getType(){return`ref`}static clone(t){return new e(t.__ref,t.__key)}static importJSON(t){let{type:n,version:r,...i}=t;return new e(i).updateFromJSON(t)}constructor(e={artboard:``},t){super(t),this.__ref=e}exportJSON(){return{...super.exportJSON(),...this.__ref,type:`ref`,version:1}}createDOM(){return document.createElement(Yr(this.__ref)?`div`:`span`)}updateDOM(){return!1}isInline(){return!Yr(this.__ref)}isKeyboardSelectable(){return!1}getTextContent(){return this.__ref.label??``}decorate(){return Yr(this.__ref)?(0,K.jsx)(I5e,{target:this.__ref}):(0,K.jsx)(R5e,{target:this.__ref})}};function B5e(e,t){let n=typeof t==`string`?{name:t}:t;return n?.name?e+`
|
|
388
|
+
`).map(e=>e.trim()).filter(Boolean).at(-1)??n}}function e5e(e,t){let n=(0,G.useRef)(null);return(0,G.useMemo)(()=>{try{let r=F8e(e,t);return n.current=r,{view:r,error:null}}catch(e){return{view:n.current,error:$8e(e)}}},[e,t])}var t5e={scrollX:0,scrollY:0,zoom:1},n5e=()=>()=>{};function r5e(e,t){let n=(0,G.useSyncExternalStore)(e?.store.subscribe??n5e,()=>e?.store.get()??null);return(0,G.useMemo)(()=>!e||!n||!t?[]:n.threads.filter(n=>n.status===`open`&&n.anchor.diagram&&Ur(n.anchor).includes(e.blockId)&&!lR(t,n.anchor.diagram,n.anchor.quote)).map(e=>uR(e.anchor.diagram,e.anchor.quote)),[e,n,t])}function i5e({comments:e,edit:t,initial:n,onCancel:r,onSaved:a,title:o}){let s=lF(),[c,l]=(0,G.useState)(n),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1),{view:m,error:h}=e5e(c,s),g=r5e(e,h?null:m?.elements??null),_=(0,G.useMemo)(()=>({__html:m?.svg??``}),[m?.svg]),v=c!==n,y=()=>{if(v&&!u)return d(!0);r()},b=()=>{if(!h){if(!f&&t.current()!==n)return p(!0);v&&t.save(c),a()}},S=null;return f?S=i(`mermaid.changedMeanwhile`):g.length&&(S=i(`mermaid.lostComments`,{labels:g.join(`、`)})),(0,K.jsxs)(`div`,{className:`x78zum5 xdt5ytf x5yr21d xqfszdh`,onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),y()):e.key===`s`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),b())},children:[(0,K.jsxs)(`div`,{className:`x78zum5 x6s0dn4 x167g77z x2lah0s xdd8jsf x1lgesdg xso031l x1q0q8m5 xtrfj0v`,children:[(0,K.jsx)(`span`,{"data-morph":`title`,className:`xif65rj x1s688f xo2rkog xuxw1ft`,children:o}),(0,K.jsx)(`span`,{className:`x1fao0z8 xfifm61 xddlp02`,children:i(`mermaid.editSource`)}),(0,K.jsx)(`span`,{className:`x98rzlu`}),S&&(0,K.jsxs)(`span`,{role:`status`,className:`x78zum5 x6s0dn4 x17d4w8g xeuugli xfifm61 x7zghnd xuxw1ft xb3r6kr xlyipyv`,children:[(0,K.jsx)(Rr,{"aria-hidden":`true`,size:13}),S]}),(0,K.jsx)(`button`,{type:`button`,onClick:y,className:`x1gnnpzl xaope02 xc342km xur7f20 xjbqb8w xj0l527 x1bo0w0s xjb2p0i xfifm61 xk50ysn x1ypdohk xtgyt42 x1hc1fzr x1lfpgzf`,children:i(u?`mermaid.discard`:`common.cancel`)}),(0,K.jsx)(`button`,{disabled:!!h,type:`button`,onClick:b,className:`x1gnnpzl xaope02 xc342km xur7f20 xjb2p0i xfifm61 xk50ysn x1ypdohk xtgyt42 x1hc1fzr x1lfpgzf x19ckca5 x1et1poy xs0jrwl`,children:i(f?`mermaid.saveAnyway`:`mermaid.save`)})]}),(0,K.jsxs)(`div`,{className:`x78zum5 x98rzlu x2lwn1j`,children:[(0,K.jsxs)(`div`,{"data-morph":`source`,className:`x78zum5 xdt5ytf x3p9ev8 x2lah0s xs1s249 x32b0ac x1vnv1x x2fo67v`,children:[(0,K.jsx)(`div`,{className:`xnlhpfx x1j6dyjg xddlp02`,children:i(`mermaid.source`)}),(0,K.jsx)(`textarea`,{"aria-label":i(`mermaid.source`),spellCheck:!1,value:c,onChange:e=>{l(e.target.value),d(!1)},onKeyDown:e=>{if(e.key!==`Tab`)return;e.preventDefault();let t=e.currentTarget;t.setRangeText(` `,t.selectionStart,t.selectionEnd,`end`),l(t.value)},className:`x98rzlu x15x03d9 xc342km x1a2a7pz xtt52l0 xjbqb8w xo2rkog x1fao0z8 x4z9k3i xa7kkou x1sdyfia xeq4nuv`}),h&&(0,K.jsxs)(`div`,{role:`alert`,className:`x78zum5 x1cy8zhl x167g77z xbnpv00 xfifm61 x1evy7pa xpt3syw x8yy6z1`,children:[(0,K.jsx)(x,{"aria-hidden":`true`,size:13}),(0,K.jsx)(`span`,{children:h.line===null?h.message:i(`mermaid.errorAt`,{line:h.line,message:h.message})})]})]}),(0,K.jsxs)(`div`,{className:`x1n2onr6 x98rzlu xeuugli xysyzu8`,className:`ryugi-diagram-canvas ${{className:`x1n2onr6 x98rzlu xeuugli xysyzu8`}.className??``}`,children:[(0,K.jsx)(Hr,{color:`var(--ryugi-diagram-dot)`,viewport:t5e}),(0,K.jsx)(`div`,{className:`x1n2onr6 x78zum5 x6s0dn4 xl56j7k x9f619 x1us19tq x15fnm84`,children:(0,K.jsx)(`div`,{...{0:{},1:{className:`xyd83as`}}[!!h|0],"aria-label":i(`mermaid.diagram`),className:`ryugi-diagram ryugi-mermaid-source-preview ${{0:{},1:{className:`xyd83as`}}[!!h|0].className??``}`,dangerouslySetInnerHTML:_,"data-morph":`drawing`,role:`img`,style:{width:m?.width,maxWidth:`100%`}})})]})]})]})}function a5e({comments:e}){let t=e.threads.filter(e=>e.status===`open`).length;return e.open||!t?null:(0,K.jsxs)(`button`,{"aria-label":i(`mermaid.showComments`,{count:t}),"data-diagram-comment-count":``,title:i(`mermaid.showComments`,{count:t}),type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),e.show()},className:`x10l6tqk x191j7n5 x1qpfodn xhtitgo x3nfvp2 x6s0dn4 x17d4w8g x1fgtraw x1awh872 xmkeg23 x1y0btm7 xkoleu3 xixl9f9 x12ilycc xo2rkog x1d5q07e xjb2p0i xfifm61 xss6m8b x1ypdohk`,children:[(0,K.jsx)(Rr,{"aria-hidden":`true`,size:14}),t]})}function o5e({comments:e}){let{draft:t}=e;return e.open?(0,K.jsxs)(`aside`,{"data-diagram-panel":``,className:`x10l6tqk x1imwcls xn5hqff xzkaem6 x78zum5 xdt5ytf x883omv x1m258z3 x4d2062 x1nk49em xc7ga6q x1odjw0f xmkeg23 x1y0btm7 x12xov25 x4pepcl x184qs1t xf6gj6t x1jl7r6f xllfotl xatqbsq`,children:[t?(0,K.jsx)(FR,{active:!0,children:(0,K.jsx)(Br,{autoFocus:!0,excerpt:{kind:`anchor`,icon:Wi,label:t.label},initial:t.initial,placeholder:i(`composer.placeholder`),onCancel:t.onCancel,onChange:t.onChange,onSubmit:t.onSubmit},t.key)}):null,e.threads.map(t=>(0,K.jsx)(IR,{actions:e.actions,active:t.id===e.activeId,agent:e.agent,thread:t,onActivate:()=>e.activate(t.id)},t.id))]}):null}var K7={type:`spring`,stiffness:380,damping:36},s5e={duration:.18,ease:[.4,0,1,1]},c5e=e=>new Map([...e.querySelectorAll(`[data-morph]`)].map(e=>[e.dataset.morph,e]));function l5e(e,t,n){let r=t.cloneNode(!0);r.removeAttribute(`data-morph`),r.dataset.morphGhost=e,Object.assign(r.style,{position:`fixed`,left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,margin:`0`,transformOrigin:`0 0`,pointerEvents:`none`,zIndex:`2000`});for(let e of r.querySelectorAll(`svg`))e.style.width=`100%`,e.style.height=`100%`,e.style.maxWidth=`none`;return document.body.append(r),r}function q7(e,t){let n=()=>{e.style.transform=`translate(${t.x.get()}px, ${t.y.get()}px) scale(${t.sx.get()}, ${t.sy.get()})`,e.style.opacity=String(t.opacity.get())};for(let e of Object.values(t))e.on(`change`,n);n()}function J7(e=0,t=1){return{x:j(e),y:j(0),sx:j(1),sy:j(1),opacity:j(t)}}async function u5e(e,t,n){let r=J7();q7(e,r),await Promise.all([w(r.x,n.left-t.left,K7),w(r.y,n.top-t.top,K7),w(r.sx,t.width?n.width/t.width:1,K7),w(r.sy,t.height?n.height/t.height:1,K7)])}async function d5e(e){let t=J7();q7(e,t),await Promise.all([w(t.x,-32,K7),w(t.opacity,0,s5e)])}async function f5e(e){let t=J7(-32,0);q7(e,t),e.style.visibility=``,await Promise.all([w(t.x,0,K7),w(t.opacity,1,K7)]),e.style.transform=``,e.style.opacity=``}function p5e(e,t){let n=(0,G.useRef)(null);return(0,G.useLayoutEffect)(()=>{let t=n.current;if(n.current=null,!t||!e.current)return;let r=c5e(e.current);for(let e of r.values())e.style.visibility=`hidden`;requestAnimationFrame(()=>{let e=[];for(let[n,{ghost:i,rect:a}]of t){let t=r.get(n),o=t?u5e(i,a,t.getBoundingClientRect()):d5e(i);e.push(o.then(()=>{i.remove(),t&&(t.style.visibility=``)}))}for(let[n,i]of r)t.has(n)||e.push(f5e(i));Promise.all(e)})},[e,t]),t=>{if(!e.current||Wr())return t();let r=new Map;for(let[t,n]of c5e(e.current)){let e=n.getBoundingClientRect();r.set(t,{ghost:l5e(t,n,e),rect:e})}n.current=r,t()}}var m5e=4,h5e=()=>()=>{};function g5e(e,t){let n=(0,G.useSyncExternalStore)(t?.store.subscribe??h5e,()=>t?t.store.get():null),r=t?.blockId??null,a=!!n?.viewer&&!n?.readOnly,[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(null),u=(0,G.useRef)(null),d=(0,G.useRef)(null),f=(0,G.useRef)(``),p=(0,G.useRef)(null),m=(0,G.useMemo)(()=>c&&r?{blockId:r,quote:c.label,diagram:c.target}:null,[c,r]),h=(0,G.useMemo)(()=>zR(e.elements,{threads:n?.threads??[],activeId:n?.activeId??null,draft:m},r),[e,n,m,r]),g=(0,G.useMemo)(()=>(n?.threads??[]).filter(e=>r!==null&&Ur(e.anchor).includes(r)&&(e.status===`open`||e.id===n?.activeId)),[n,r]);(0,G.useLayoutEffect)(()=>{u.current&&xR(u.current,e.elements,h,a,e=>i(`mermaid.commentOn`,{label:uR(e.target,e.label)}))},[e,h,a]);let _=e=>LR(r??``,e.label,void 0,void 0,e.target),v=()=>{p.current&&p.current.save(p.current.key,f.current),p.current=null};(0,G.useEffect)(()=>v,[]);let y=e=>{let t=n?.viewer?.drafts;if(!t)return;v();let r=_(e);f.current=t.take(r),p.current={key:r,save:t.save},l(e),s(!0)},b=()=>{v(),l(null),s(!1),n?.activeId&&n.activate(null)},x=t=>{let r=u.current?SR(t,u.current,e.elements):null;if(!r||!n)return!1;let i=h.get(r.element)?.threadIds[0];if(i)v(),l(null),n.activate(i),s(!0);else if(a)y(r.element);else return!1;return!0};return{drawing:u,open:o,threads:g,activeId:n?.activeId??null,actions:n?.viewer?.actions,agent:n?.viewer?.agent,activate:e=>n?.activate(e),show:()=>s(!0),draft:c?{key:_(c),label:uR(c.target,c.label),initial:f.current,onChange:e=>{f.current=e},onCancel:()=>{v(),l(null),g.length||s(!1)},onSubmit:async e=>!n?.viewer||!m||!await n.viewer.create(m,e)?!1:(f.current=``,v(),l(null),!0)}:null,canPick:a,stage:{onPointerDown:e=>{d.current={x:e.clientX,y:e.clientY}},onClick:e=>{let t=d.current;d.current=null,t&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>m5e||x(e.target)||b()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&x(e.target)&&e.preventDefault()},onPointerOver:t=>{if(!u.current||!n)return;let r=SR(t.target,u.current,e.elements)?.element??null;CR(u.current,r&&(a||h.has(r))?r:null)}}}}function Y7({label:e,onClick:t,children:n}){return(0,K.jsx)(`button`,{"aria-label":e,title:e,type:`button`,onClick:t,className:`x3nfvp2 x6s0dn4 x17d4w8g x1gnnpzl xdqyycr xc342km xur7f20 xjbqb8w xj0l527 x1bo0w0s xytdrwj xjb2p0i xfifm61 x1ypdohk`,children:n})}function _5e(e){let{close:t}=u(),n=(0,G.useRef)(null),[r,i]=(0,G.useState)(!!(e.editing&&e.edit)),a=p5e(n,r);return(0,K.jsx)(`div`,{ref:n,style:{height:`100%`},children:r&&e.edit?(0,K.jsx)(i5e,{comments:e.comments,edit:e.edit,initial:e.edit.current(),title:e.title,onCancel:()=>a(()=>i(!1)),onSaved:t}):(0,K.jsx)(v5e,{...e,onEdit:e.edit?()=>a(()=>i(!0)):void 0})})}function v5e({title:e,source:t,diagram:n,comments:r,onEdit:a}){let{close:o}=u(),s=g5e(n,r),c=(0,G.useMemo)(()=>({__html:n.svg}),[n.svg]),[l,d]=(0,G.useState)({scrollX:0,scrollY:0,zoom:1}),[f,p]=(0,G.useState)(!1),m=async()=>{await navigator.clipboard?.writeText(t),p(!0),setTimeout(()=>p(!1),1500)};return(0,K.jsx)(m8e,{limitToBounds:!1,maxScale:4,minScale:.05,wheel:{step:.002},onInit:e=>void e.fitToView({maxScale:1,animationTime:0}),onTransform:(e,{positionX:t,positionY:n,scale:r})=>d({scrollX:t/r,scrollY:n/r,zoom:r}),children:({zoomIn:t,zoomOut:r,fitToView:u,centerView:d})=>(0,K.jsxs)(`div`,{className:`x1n2onr6 x5yr21d xb3r6kr xqfszdh`,className:`ryugi-diagram-canvas ${{className:`x1n2onr6 x5yr21d xb3r6kr xqfszdh`}.className??``}`,children:[(0,K.jsxs)(`div`,{className:`x10l6tqk x10a8y8t`,...s.stage,children:[(0,K.jsx)(Hr,{color:`var(--ryugi-diagram-dot)`,viewport:l}),(0,K.jsx)(v8e,{wrapperClass:{className:`x1jm3nie xch2mbi`}.className,wrapperStyle:{width:`100%`,height:`100%`},children:(0,K.jsx)(`div`,{"aria-label":i(`mermaid.diagram`),className:`ryugi-diagram`,dangerouslySetInnerHTML:c,"data-morph":`drawing`,ref:s.drawing,role:s.canPick?`group`:`img`,style:{width:n.width,height:n.height}})}),(0,K.jsx)(a5e,{comments:s})]}),(0,K.jsxs)(`div`,{className:`x10l6tqk xhtitgo x78zum5 x6s0dn4 xfawy5m xmkeg23 x1y0btm7 x12xov25 x4pepcl x1rozbrz x1dpygf6 xomnu4r x1qpfodn x883omv x1vqgdyp x1sy7ncu xaope02`,children:[(0,K.jsx)(`span`,{"data-morph":`title`,className:`x2lah0s xh9uqaf xif65rj x1s688f xo2rkog xuxw1ft xb3r6kr xlyipyv`,children:e}),(0,K.jsx)(`span`,{className:`xeuugli x1fao0z8 xfifm61 xddlp02 xuxw1ft xb3r6kr xlyipyv`,children:`${n.type} · ${Math.round(n.width)} × ${Math.round(n.height)}`})]}),(0,K.jsxs)(`div`,{className:`x10l6tqk xhtitgo x78zum5 x6s0dn4 x195vfkc xfawy5m xmkeg23 x1y0btm7 x12xov25 x4pepcl x1rozbrz x1dpygf6 xomnu4r xn5hqff`,children:[a&&(0,K.jsxs)(`button`,{type:`button`,onClick:a,className:`x3nfvp2 x6s0dn4 x17d4w8g x1gnnpzl xdqyycr xc342km xur7f20 xjbqb8w xj0l527 x1bo0w0s xytdrwj xjb2p0i xfifm61 x1ypdohk`,children:[(0,K.jsx)(Pr,{"aria-hidden":`true`,size:14}),(0,K.jsx)(`span`,{children:i(`mermaid.editSource`)})]}),(0,K.jsxs)(`button`,{"aria-label":i(`mermaid.copySource`),type:`button`,onClick:()=>void m(),className:`x3nfvp2 x6s0dn4 x17d4w8g x1gnnpzl xdqyycr xc342km xur7f20 xjbqb8w xj0l527 x1bo0w0s xytdrwj xjb2p0i xfifm61 x1ypdohk`,children:[f?(0,K.jsx)(C,{size:14}):(0,K.jsx)(Ir,{size:14}),(0,K.jsx)(`span`,{className:`xkaaz9w`,children:i(f?`common.copied`:`mermaid.copySource`)})]}),(0,K.jsx)(Y7,{label:i(`common.close`),onClick:o,children:(0,K.jsx)(k,{size:16})})]}),(0,K.jsxs)(`div`,{className:`x10l6tqk xhtitgo x78zum5 x6s0dn4 x195vfkc xfawy5m xmkeg23 x1y0btm7 x12xov25 x4pepcl x1rozbrz x1dpygf6 x191j7n5 x1nrll8i xuuh30`,children:[(0,K.jsx)(Y7,{label:i(`mermaid.zoomOut`),onClick:()=>r(),children:(0,K.jsx)(T,{size:16})}),(0,K.jsx)(`span`,{className:`x1nb6za0 x2b8uid x1fao0z8 xfifm61 xss6m8b x1bo0w0s`,children:`${Math.round(l.zoom*100)}%`}),(0,K.jsx)(Y7,{label:i(`mermaid.zoomIn`),onClick:()=>t(),children:(0,K.jsx)(zr,{size:16})}),(0,K.jsx)(`span`,{className:`x1i1rx1s xmix8c7 xjgtzcg xh6qj2i xkaaz9w`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void u({maxScale:1}),className:`x6s0dn4 x17d4w8g x1gnnpzl xdqyycr xc342km xur7f20 xjbqb8w xj0l527 x1bo0w0s xytdrwj xjb2p0i xfifm61 x1ypdohk xkaaz9w`,children:i(`mermaid.fit`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void d(1),className:`x6s0dn4 x17d4w8g x1gnnpzl xdqyycr xc342km xur7f20 xjbqb8w xj0l527 x1bo0w0s xytdrwj xjb2p0i xfifm61 x1ypdohk xkaaz9w`,children:i(`mermaid.actualSize`)})]}),(0,K.jsx)(o5e,{comments:s})]})})}function y5e(e){D({content:(0,K.jsx)(_5e,{...e}),width:`calc(100vw - 2 * var(--ryugi-viewer-inset))`,classNames:{popup:`ryugi-mermaid-viewer`},styles:{content:{height:`100%`,padding:0,overflow:`hidden`}}})}var X7=8,Z7=280;function b5e({anchor:e,element:t,onCancel:n,onEditSource:r,onSave:a}){let o=(0,G.useRef)(null),s=(0,G.useRef)(null),c=(0,G.useRef)(!1),[l,u]=(0,G.useState)(t.label),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)({left:0,top:0});(0,G.useLayoutEffect)(()=>{let t=e.getBoundingClientRect(),n=o.current?.offsetHeight??0,r=t.top-n-X7;m({left:Math.max(X7,Math.min(t.left+t.width/2-Z7/2,innerWidth-Z7-X7)),top:r>=X7?r:t.bottom+X7}),s.current?.focus(),s.current?.select()},[e]);let h=e=>{c.current||(!e||l.trim()===t.label?(c.current=!0,n()):a(l)?c.current=!0:f(!0))},g=t.target.kind===`node`?i(`mermaid.renameNode`,{id:t.target.id}):i(`mermaid.renameEdge`,{label:uR(t.target,``)});return(0,Gi.createPortal)((0,K.jsxs)(`div`,{className:`ryugi-mermaid-rename`,ref:o,style:{left:p.left,top:p.top,width:Z7},onMouseDown:e=>e.stopPropagation(),children:[(0,K.jsx)(`div`,{className:`ryugi-mermaid-rename-caption`,children:g}),(0,K.jsx)(`input`,{"aria-label":g,ref:s,value:l,onBlur:e=>{o.current?.contains(e.relatedTarget)||h(!d)},onChange:e=>{u(e.target.value),f(!1)},onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),h(!0)):e.key===`Escape`&&(e.preventDefault(),h(!1))}}),d?(0,K.jsxs)(`div`,{className:`ryugi-mermaid-rename-note`,"data-failed":``,children:[i(`mermaid.cannotRename`),r&&(0,K.jsx)(`button`,{type:`button`,onClick:r,children:i(`mermaid.editSource`)})]}):(0,K.jsx)(`div`,{className:`ryugi-mermaid-rename-note`,children:i(`mermaid.renameKeys`)})]}),document.body)}var x5e={scrollX:0,scrollY:0,zoom:1},S5e=250;function C5e({content:e,onContentChange:t}){let n=lF(),r=L8e(e,n),a=(0,G.use)(RR),o=yne(`(hover: none)`),s=!!a&&!a?.readOnly&&!o,c=S8e()&&!o&&!!t,l=(0,G.useRef)(e),u=(0,G.useRef)(void 0);(0,G.useLayoutEffect)(()=>{l.current=e},[e]);let[d,f]=(0,G.useState)(null);(0,G.useEffect)(()=>()=>clearTimeout(u.current),[]);let p=(0,G.useMemo)(()=>gNe(),[]);(0,G.useEffect)(()=>p.set(a),[p,a]);let m=(0,G.useRef)(null),h=(0,G.useRef)(null),g=(0,G.useRef)(``),_=(0,G.useRef)(``),v=(0,G.useMemo)(()=>({__html:r?.svg??``}),[r?.svg]),[y,b]=(0,G.useState)(null);if((0,G.useLayoutEffect)(()=>b(R8e(m.current))),(0,G.useLayoutEffect)(()=>{if(!r||!h.current||!m.current)return;let e=zR(r.elements,a??{threads:[],activeId:null,draft:null},a?.blockIdOf(m.current)??null);xR(h.current,r.elements,e,s,e=>i(`mermaid.commentOn`,{label:uR(e.target,e.label)}));let t=_Ne(e);(t!==g.current||_.current!==r.svg)&&(g.current=t,_.current=r.svg,a?.marked())},[r,a,s]),!r)return(0,K.jsx)(o3e,{colorScheme:n,content:e});let x=(n=!1)=>{let s=m.current?a?.blockIdOf(m.current):null;f(null),y5e({source:e,diagram:r,title:R8e(m.current)??i(`mermaid.diagram`),comments:s&&!o?{blockId:s,store:p}:void 0,edit:c&&t?{current:()=>l.current,save:t}:void 0,editing:n})},S=t=>{if(!c||!h.current)return;let n=SR(t,h.current,r.elements);n&&Q8e(e,n.element.target,n.element.label)!==null&&f(n)},C=e=>{if(!a||!s||!h.current||!m.current)return!1;let t=SR(e,h.current,r.elements),n=a.blockIdOf(m.current);if(!t||!n)return!1;let i=zR(r.elements,a,n).get(t.element)?.threadIds[0];return i?a.activate(i):a.pick({blockId:n,element:t.element,node:t.node,host:m.current}),!0};return(0,K.jsxs)(`div`,{className:`ryugi-mermaid-preview ryugi-diagram ryugi-diagram-canvas`,"data-block-action":a?.blockAction?``:void 0,ref:m,onPointerLeave:()=>h.current&&CR(h.current,null),onClick:e=>{if(e.target instanceof Element&&e.target.closest(`button`))return;if(o)return x();if(!c){C(e.target)&&e.stopPropagation();return}if(clearTimeout(u.current),e.detail>1)return;let{target:t}=e;u.current=window.setTimeout(()=>C(t),S5e)},onDoubleClick:e=>{clearTimeout(u.current),S(e.target)},onKeyDownCapture:e=>{if(e.key===`Enter`||e.key===` `){if(e.target instanceof HTMLButtonElement)return e.stopPropagation();C(e.target)&&(e.preventDefault(),e.stopPropagation())}},onPointerOver:e=>{s&&h.current&&CR(h.current,SR(e.target,h.current,r.elements)?.element??null)},children:[(0,K.jsx)(Hr,{color:`var(--ryugi-diagram-dot)`,viewport:x5e}),y&&(0,K.jsx)(`span`,{className:`ryugi-mermaid-title`,children:y}),(0,K.jsx)(`div`,{"aria-label":i(`mermaid.diagram`),className:`ryugi-mermaid-drawing`,dangerouslySetInnerHTML:v,ref:h,role:s?`group`:`img`}),(0,K.jsx)(`div`,{className:`ryugi-mermaid-zoom`,children:(0,K.jsx)(`button`,{"aria-label":i(`mermaid.open`),title:i(`mermaid.open`),type:`button`,onClick:()=>x(),children:(0,K.jsx)(nne,{"aria-hidden":`true`,size:14})})}),c&&(0,K.jsx)(`span`,{className:`ryugi-mermaid-hint`,children:i(`mermaid.hint`)}),d&&(0,K.jsx)(b5e,{anchor:d.node,element:d.element,onCancel:()=>f(null),onEditSource:()=>x(!0),onSave:e=>{let n=Q8e(l.current,d.element.target,e);return n!==null&&(n!==l.current&&t?.(n),f(null),!0)}})]})}function w5e(e,t,n){let r=e.layout?gne(vne(e.canvas,e.layout),t):void 0;if(!r||!hne(e.threads,r.id).submitted)return{state:`unchosen`};let{choice:i}=mne(e.threads,t,n);return i?{state:`chosen`,choice:i}:{state:`unchosen`}}function Q7(e,t){if(!t)return{kind:`gone`};if(`unavailable`in t)return{kind:t.unavailable};if(`artifact`in t)return{kind:`artifact`,title:t.artifact.title||qr(e)};if(`verify`in t)return{kind:`verify`,title:t.verify.title||qr(e),state:t.verify.state};if(`document`in t){let{blocks:n,title:r}=t.document,i=r||qr(e);if(!e.block)return{kind:`artifact`,title:i};let a=Object.hasOwn(n,e.block)?n[e.block]:void 0;return a===void 0?{kind:`sectionGone`,document:i}:{kind:`section`,title:a||e.block,document:i}}if(`report`in t){let{blocks:n,title:r}=t.report;if(!e.block)return{kind:`report`,title:r||qr(e)};let i=Object.hasOwn(n,e.block)?n[e.block]:void 0;return i===void 0?{kind:`gone`}:{kind:`block`,title:i||e.block}}if(`slides`in t){let{slides:n,title:r}=t.slides;if(!e.slide)return{kind:`slides`,title:r||qr(e)};let i=Object.hasOwn(n,e.slide)?n[e.slide]:void 0;return i===void 0?{kind:`gone`}:{kind:`slide`,title:i||e.slide}}if(`whiteboard`in t){let{frames:n,title:r,pages:i}=t.whiteboard;if(e.page){let t=i?.[e.page];return t===void 0?{kind:`gone`}:{kind:`page`,title:t||e.page}}if(!e.frame)return{kind:`whiteboard`,title:r||qr(e)};let a=n[e.frame];return a===void 0?{kind:`gone`}:{kind:`frame`,title:a||e.frame}}let{canvas:n}=t;if(e.board){let t=n.boards[e.board];return t?{kind:`board`,title:t.title||e.board}:{kind:`gone`}}if(e.group){let r=n.groups?.[e.group];if(!r)return{kind:`gone`};let i=r.title||e.group;if(t.stateless)return{kind:`group`,title:i,state:`none`};if(r.choose)return{kind:`group`,title:i,...w5e(t,e.group,r.recommend)};if(r.verify){let{state:n}=_ne(t.threads,e.group,new Set(t.stale));return{kind:`group`,title:i,state:n===`pending`?`awaiting`:n}}return{kind:`group`,title:i,state:`none`}}return{kind:`artboard`,title:n.title||qr(e)}}var $7=(0,G.createContext)(null),T5e=e=>{let t=Jr(e);return e.to?[`${qr(e)}:${t}`,`${e.to}:${t}`]:[`${qr(e)}:${t}`]},E5e={artboard:Fte,document:h,html:Pr,board:rne,group:we,whiteboard:jr,frame:$te,page:ene,slides:ine,slide:Hne,report:Ar,block:rne,verify:une},D5e=e=>e.verify===void 0?e.document===void 0?e.html===void 0?e.slides===void 0?e.report===void 0?O5e(e):e.block?`block`:`report`:e.slide?`slide`:`slides`:`html`:`document`:`verify`,O5e=e=>e.whiteboard?e.frame?`frame`:e.page?`page`:`whiteboard`:e.board?`board`:e.group?`group`:`artboard`;function k5e({target:e,status:t,active:r=!1,self:i=!1,onOpen:a}){let{t:o}=n(),s=D5e(e),c=E5e[s],l=t?.kind===`locked`,u=t?.kind===`gone`||t?.kind===`unpublished`,d=l||u,f=t?.kind===`section`?t:null,p=t?.kind===`sectionGone`?t:null,m=t&&`title`in t?t.title:void 0,h=e.board??e.group??e.frame??e.page??e.slide??e.block,g=l?o(`refs.locked`):e.label??(f?i?`§ ${f.title}`:`${f.document} › ${f.title}`:p?p.document:s===`group`?m:m??h)??qr(e),_=t?.kind===`group`||t?.kind===`verify`?t.state:d?t.kind:p?`sectionGone`:void 0,v=t?.kind===`group`&&t.state!==`none`?o(`refs.${t.state}`,{choice:t.choice??``}):t?.kind===`verify`?o(`refs.verify_${t.state}`):u?o(`refs.${t.kind}`):p?o(`refs.sectionGone`):void 0,y=l?o(`refs.lockedHint`):u?o(`refs.${t.kind}`):e.whiteboard?o(`refs.openWhiteboard`):o(s===`document`||s===`html`||s===`slides`||s===`slide`||s===`report`||s===`block`||s===`verify`?`refs.openArtifact`:`refs.open`),b=l?Ute:c;return(0,K.jsxs)(`button`,{"data-ref-chip":qr(e),"data-ref-key":Jr(e),"data-ref-to":e.to,"data-state":_,disabled:d,title:y,type:`button`,onClick:t=>{if(t.preventDefault(),t.stopPropagation(),d)return;if(!p)return a(e);let{block:n,...r}=e;a(r)},...{0:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1y0btm7 x12xov25 x1kogg8i x2fo67v xo2rkog xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x1ypdohk x87ps6o xj0l527`},8:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1y0btm7 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x1ypdohk x87ps6o xj0l527 x11cp7ww x1mzvsll xqqczys`},4:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x12xov25 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x87ps6o xbsl7fq xjbqb8w xc7n51q x1h6gzvc x1n5bzlp`},12:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x87ps6o x11cp7ww xbsl7fq xjbqb8w xc7n51q x1h6gzvc x1n5bzlp`},2:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x12xov25 x1kogg8i x2fo67v xo2rkog xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x1ypdohk x87ps6o xj0l527 xbsl7fq`},10:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x1ypdohk x87ps6o xj0l527 x11cp7ww x1mzvsll xqqczys xbsl7fq`},6:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x12xov25 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x87ps6o xjbqb8w xc7n51q x1h6gzvc x1n5bzlp xbsl7fq`},14:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x87ps6o x11cp7ww xjbqb8w xc7n51q x1h6gzvc x1n5bzlp xbsl7fq`},1:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1y0btm7 x12xov25 x1kogg8i x2fo67v xo2rkog xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x1ypdohk x87ps6o xj0l527 xmqliwb`},9:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1y0btm7 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x1ypdohk x87ps6o xj0l527 x11cp7ww x1mzvsll xqqczys xmqliwb`},5:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x12xov25 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x87ps6o xbsl7fq xjbqb8w xc7n51q x1h6gzvc x1n5bzlp xmqliwb`},13:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x87ps6o x11cp7ww xbsl7fq xjbqb8w xc7n51q x1h6gzvc x1n5bzlp xmqliwb`},3:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x12xov25 x1kogg8i x2fo67v xo2rkog xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x1ypdohk x87ps6o xj0l527 xbsl7fq xmqliwb`},11:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x1ypdohk x87ps6o xj0l527 x11cp7ww x1mzvsll xqqczys xbsl7fq xmqliwb`},7:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x12xov25 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x87ps6o xjbqb8w xc7n51q x1h6gzvc x1n5bzlp xbsl7fq xmqliwb`},15:{className:`x3nfvp2 x6s0dn4 x1nejdyq x193iq5w x17rw0jw x1dhlr3c xlkn9b3 xmkeg23 x1kogg8i xjb2p0i x1ct8sxb x37zpob x11njtxf xuxw1ft x87ps6o x11cp7ww xjbqb8w xc7n51q x1h6gzvc x1n5bzlp xbsl7fq xmqliwb`}}[!!r<<3|!!d<<2|!!p<<1|t?.kind===`gone`],children:[(0,K.jsx)(b,{size:12}),!l&&s===`group`&&h&&(0,K.jsx)(`span`,{className:`x1fao0z8 x1j6dyjg xddlp02`,children:h}),(0,K.jsx)(`span`,{className:`xeuugli xb3r6kr xlyipyv`,children:g}),!l&&(s===`board`||(s===`slide`||s===`block`)&&g!==h)&&h&&(0,K.jsx)(`span`,{className:`x1fao0z8 x1j6dyjg xddlp02`,children:h}),!l&&!i&&(s===`artboard`||s===`whiteboard`||s===`document`||s===`html`||s===`slides`||s===`report`||s===`verify`)&&(0,K.jsx)(`span`,{className:`x1fao0z8 x1j6dyjg xddlp02`,children:o(`refs.${s}`)}),v&&(0,K.jsxs)(`span`,{className:`xddlp02`,children:[`· `,v]})]})}function A5e(e,t,n){let r=e.filter(e=>!e.isDeleted);if(t){let e=r.find(e=>e.id===t&&e.type===`frame`);if(!e)return{missing:`frame`};let n=new Set(r.filter(e=>e.frameId===t).map(e=>e.id));return{elements:r.filter(e=>n.has(e.id)||!!e.containerId&&n.has(e.containerId)),box:{x:e.x??0,y:e.y??0,w:e.width??0,h:e.height??0}}}if(!r.length)return{missing:`empty`};let i=n(r);return{elements:r,box:{x:i.minX,y:i.minY,w:i.width,h:i.height}}}var j5e=(e,t)=>A5e(e,t,e=>Tte(e)),M5e=`16 / 9`;function N5e(e,t){return e===void 0?`loading`:`unavailable`in e?e.unavailable:t&&`missing`in t?t.missing:`ready`}function P5e({view:e,files:t,label:n,light:r=!1}){let i=cte()&&!r,a=Sne(),{x:o,y:s,w:c,h:l}=e.box;return(0,K.jsx)(`svg`,{"aria-label":n,preserveAspectRatio:`xMidYMid meet`,role:`img`,viewBox:`${o} ${s} ${c} ${l}`,xmlns:`http://www.w3.org/2000/svg`,className:`x1lliihq xh8yej3 x5yr21d`,style:i?{filter:Uee}:void 0,children:(0,K.jsx)(Ste,{dark:i,files:t,handFontOverride:a?Gee:void 0,scene:{type:`excalidraw`,elements:e.elements,files:t}})})}function F5e({host:e,useScene:t,target:r}){let{t:i}=n(),o=e.useBoard(r),s=t(r),c=qr(r),l=o===void 0?void 0:Q7({whiteboard:c},o),u=l&&`title`in l&&l.title||c,d=s&&`scene`in s?j5e(s.scene.elements,r.frame):null,f=N5e(s,d),p={"data-whiteboard-embed":c,"data-ref-key":Jr(r),"data-state":f};if(f===`loading`)return(0,K.jsx)(`div`,{...p,className:`x78zum5 x6s0dn4 xl56j7k xh8yej3 x159tps6 x1jp4ehj xur7f20 x2fo67v`,style:{aspectRatio:M5e},children:(0,K.jsx)(a,{stack:!0,label:i(`embed.loading`),size:24})});if(!d||!(`box`in d)||!s||!(`scene`in s))return(0,K.jsxs)(`div`,{...p,className:`x78zum5 x6s0dn4 x883omv x1jp4ehj xxlmvz2 x1hr3lfm xmkeg23 xbsl7fq xgcsv5v xur7f20 x1bo0w0s x4z9k3i`,children:[(0,K.jsx)(jr,{size:16}),(0,K.jsx)(`span`,{className:`xo2rkog xk50ysn`,children:u}),(0,K.jsx)(`span`,{children:i(`embed.${f}`,{frame:r.frame??``})})]});let m=()=>e.openEmbed?.(s.page&&r.frame?{...r,page:s.page}:r);return(0,K.jsx)(`figure`,{...p,role:`button`,tabIndex:0,title:i(`embed.open`),onClick:e=>{e.preventDefault(),e.stopPropagation(),m()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),m())},className:`x1n2onr6 xh8yej3 x159tps6 x1jp4ehj xrxpjvj xb3r6kr xmkeg23 x1y0btm7 x12xov25 xur7f20 x1rozbrz x1huxd7x x1qj25k6 x784prv x9v5kkp xv8siiq`,style:{aspectRatio:`${d.box.w} / ${d.box.h}`},children:(0,K.jsx)(P5e,{files:s.scene.files??{},label:u,view:d})})}function I5e({target:e}){let t=(0,G.useContext)($7);return t?.useScene?(0,K.jsx)(F5e,{host:t,target:e,useScene:t.useScene}):(0,K.jsx)(R5e,{target:e})}var L5e=()=>void 0;function R5e({target:e}){let t=(0,G.useContext)($7),n=(t?.useBoard??L5e)(e),r=n===void 0?void 0:Q7(e,n);return(0,K.jsx)(k5e,{active:!!t?.active&&T5e(e).includes(t.active),self:!!t?.isSelf(e),status:r,target:e,onOpen:e=>t?.open(e)})}var z5e=class e extends wr{__ref;static getType(){return`ref`}static clone(t){return new e(t.__ref,t.__key)}static importJSON(t){let{type:n,version:r,...i}=t;return new e(i).updateFromJSON(t)}constructor(e={artboard:``},t){super(t),this.__ref=e}exportJSON(){return{...super.exportJSON(),...this.__ref,type:`ref`,version:1}}createDOM(){return document.createElement(Yr(this.__ref)?`div`:`span`)}updateDOM(){return!1}isInline(){return!Yr(this.__ref)}isKeyboardSelectable(){return!1}getTextContent(){return this.__ref.label??``}decorate(){return Yr(this.__ref)?(0,K.jsx)(I5e,{target:this.__ref}):(0,K.jsx)(R5e,{target:this.__ref})}};function B5e(e,t){let n=typeof t==`string`?{name:t}:t;return n?.name?e+`
|
|
389
389
|
`+JSON.stringify({author:n.name,...n.model&&{model:n.model},...n.avatar&&{avatar:n.avatar}}):e}function V5e(e){let t=e?.split(`
|
|
390
390
|
`,1)[0];return t===`human`?`human`:t?.startsWith(`agent:`)?`agent`:t?.startsWith(`session `)?`session`:`unknown`}function H5e(e){if(!e||V5e(e)===`unknown`)return;let t=e.indexOf(`
|
|
391
|
-
`);if(!(t<0))try{let{author:n,model:r,avatar:i}=JSON.parse(e.slice(t+1));return typeof n!=`string`||!n.trim()?void 0:{name:n,...typeof r==`string`&&r&&{model:r},...typeof i==`string`&&i&&{avatar:i}}}catch{}}var U5e=e=>H5e(e)?.name;function W5e(e,t,n){let r=Math.min(e.length,t.length),i=0;for(;i<r&&e[i]===t[i];)i++;let a=0;for(;a<r-i&&e[e.length-1-a]===t[t.length-1-a];)a++;return n<=i?n:n>=e.length-a?n+t.length-e.length:t.length-a}function e9(e){return Array.isArray(e)?`[${e.map(e9).join(`,`)}]`:e&&typeof e==`object`?`{${Object.keys(e).filter(t=>e[t]!==void 0).sort().map(t=>`${JSON.stringify(t)}:${e9(e[t])}`).join(`,`)}}`:JSON.stringify(e)}var G5e={listitem:[`value`]};function K5e(e){let{children:t,text:n,...r}=e;for(let t of G5e[e.type]??[])delete r[t];return r}function q5e(e){return e9(K5e(e))}function J5e(e,t){let n=K5e(t);return q5e(e.updateFromJSON(n).exportJSON())===q5e(t)}var Y5e=`collab`,X5e=`agent-write`,Z5e=`agent:`,Q5e=15,$5e=`lexical`,t9=`#text`,e7e=[`textFormat`,`textStyle`];function n9(e,t){return e===t||e9(e)===e9(t)}function r9(e){let{children:t,...n}=e.getLatest().exportJSON();if(it(e)&&delete n.text,rr(e))for(let e of e7e)delete n[e];return n}function i9(e){let{[t9]:t,...n}=e.data.toJSON();for(let e of e7e)delete n[e];return n}function t7e(e,t,n={}){let r=t.getTree($5e);r.enableFractionalIndex(0);let i=new Map,a=new Map,o=(e,t)=>{let n=i.get(e);n!==void 0&&a.delete(n);let r=a.get(t);r!==void 0&&i.delete(r),i.set(e,t),a.set(t,e)},s=e=>e!==void 0&&r.has(e)&&!r.isNodeDeleted(e),c=new Map,l=new Map,u=new Set,d=(e,t)=>{t.add(e.id);for(let n of e.children()??[])d(n,t)},f=(e,t)=>{let n=t.data,r=r9(e),i=c.get(e.getKey())??{},a=!1;for(let e of new Set([...Object.keys(i),...Object.keys(r)])){let t=r[e];(!n9(i[e],t)||t!==void 0&&n.get(e)===void 0)&&(t===void 0?n.get(e)!==void 0&&(n.delete(e),a=!0):n9(n.get(e),t)||(n.set(e,t),a=!0))}if(c.set(e.getKey(),r),a&&l.set(t.id,e9(i9(t))),it(e)){let t=n.getOrCreateContainer(t9,new pj),r=e.getTextContent();t.toString()!==r&&t.update(r)}},p=(e,t,n)=>{let a=e.getChildren(),c=new Set(a.map(e=>i.get(e.getKey()))),l=new Map,m=null;for(let e of r.getNodeByID(t)?.children()??[])u.has(e.id)?(l.set(m,[...l.get(m)??[],e.id]),d(e,n)):c.has(e.id)&&(m=e.id);let h=0,g=e=>{let n=r.getNodeByID(e);(n.parent()?.id!==t||n.index()!==h)&&r.move(e,t,h),h+=1};l.get(null)?.forEach(g);for(let e of a){let a=i.get(e.getKey());s(a)?g(a):(a=r.createNode(t,h).id,o(e.getKey(),a),h+=1),n.add(a),f(e,r.getNodeByID(a)),rr(e)&&p(e,a,n),l.get(a)?.forEach(g)}},m=()=>{e.getEditorState().read(()=>{let e=i.get(`root`);s(e)||(e=r.roots()[0]?.id??r.createNode().id,o(`root`,e));let t=new Set([e]);f(Sr(),r.getNodeByID(e)),p(Sr(),e,t);for(let e of r.nodes())if(!t.has(e.id)&&s(e.id)){r.delete(e.id);let t=a.get(e.id);t!==void 0&&i.delete(t),a.delete(e.id)}}),t.commit({message:n.commitMessage})},h=(e,t)=>{let n=e.getTextContent();if(n===t)return;let r=kr(),i=Jn(r)?[r.anchor,r.focus].filter(t=>t.type===`text`&&t.key===e.getKey()):[],a=i.map(e=>W5e(n,t,e.offset));e.setTextContent(t),i.forEach((t,n)=>t.set(e.getKey(),a[n],`text`))},g=e=>{let t=_(e);return c.set(t.getKey(),r9(t)),t},_=e=>{let t=i9(e),n=n7e(t)?String(e.data.get(t9)??``):void 0,r=a.get(e.id),i=r===void 0?null:Dn(r);if(i&&i.getType()===t.type){if(it(i))return n9(r9(i),t)||i.updateFromJSON({...t,text:i.getTextContent()}),h(i,n??``),i;let r=e9(t);if(l.get(e.id)===r||n9(r9(i),t)||J5e(i,t))return l.set(e.id,r),i;l.set(e.id,r);let a=Ne({...t,children:[]});return i.replace(a,rr(i)&&rr(a)),o(a.getKey(),e.id),a}let s=Ne({...t,...n===void 0?{}:{text:n},children:[]});return l.set(e.id,e9(t)),o(s.getKey(),e.id),s},v=(e,t,n)=>{let r=0;for(let i of t.children()??[]){let t;try{t=g(i)}catch{u.add(i.id);continue}u.delete(i.id),n.add(t.getKey());let a=e.getChildAtIndex(r);if(!a||!a.is(t)){if(r===0){let n=e.getFirstChild();n?n.insertBefore(t):e.append(t)}else e.getChildAtIndex(r-1).insertAfter(t)}rr(t)&&v(t,i,n),r+=1}},y=(e,t)=>{for(let n of e.getChildren())t.push(n),rr(n)&&y(n,t)},b=(t=!1)=>{e.update(()=>{let e=r.roots()[0];if(!e)return;o(`root`,e.id);let t=i9(e);t.type===`root`&&!n9(r9(Sr()),t)&&Sr().updateFromJSON(t),c.set(`root`,r9(Sr()));let n=new Set([`root`]);v(Sr(),e,n);let i=[];y(Sr(),i);for(let e of i)!n.has(e.getKey())&&e.isAttached()&&e.remove()},{discrete:!0,tag:t?[Y5e,X5e]:Y5e})};return r.roots().length>0?b():m(),{dispose:e.registerUpdateListener(({dirtyElements:e,dirtyLeaves:t})=>{(e.size!==0||t.size!==0)&&m()}),idOf:e=>i.get(e),keyOf:e=>a.get(e),import:e=>{b(r7e(t,t.import(e),n.agentLiveWindowSeconds??Q5e))}}}function n7e(e){return typeof e.format==`number`&&typeof e.detail==`number`&&`mode`in e}function r7e(e,t,n){let r=Date.now()/1e3-n;for(let[n,i]of t.success){let t=i.start;for(;t<i.end;){let i=e.getChangeAt({peer:n,counter:t});if(i.message?.startsWith(Z5e)&&i.timestamp>=r)return!0;t=i.counter+i.length}}return!1}var i7e=/^assets\/[\w-][\w.-]*\.html$/,a7e=80,o7e=2e3;function s7e(e,t,n,r){if(!i7e.test(t))return null;let i=`${e}${t}?v=${n}`;return Object.keys(r).length===0?i:`${i}#ryugi-props=${encodeURIComponent(JSON.stringify(r))}`}function c7e(e){return Number.isFinite(e)?Math.min(o7e,Math.max(a7e,Math.ceil(e))):null}var l7e=(0,G.createContext)(null);function u7e({url:e,componentProps:t,initialHeight:n}){let r=(0,G.useContext)(l7e),[i,a]=(0,G.useState)(0),[o,s]=(0,G.useState)(()=>c7e(n)??320);(0,G.useEffect)(()=>r?.channel.subscribe(t=>{t.type===`change`&&t.artifact===r.artifact&&t.files.includes(e)&&a(e=>e+1)}),[r,e]);let c=r?.contentBase?s7e(r.contentBase,e,i,t):null,{frameRef:l,src:u,onLoad:d}=Cne(c,{onError:t=>r?.send({type:`runtime-error`,artifact:r.artifact,file:e,message:t}),onLoaded:()=>r?.send({type:`loaded`,artifact:r.artifact,file:e}),onMessage:e=>{if(e.type!==`ryugi:height`)return;let t=c7e(Number(e.height));t!==null&&s(t)}});return(0,K.jsx)(`div`,{className:`ryugi-dynamic`,contentEditable:!1,style:{height:o},children:u?(0,K.jsx)(`iframe`,{allow:`clipboard-write`,ref:l,sandbox:wne,src:u,style:{display:`block`,width:`100%`,height:`100%`,border:0},title:e,onLoad:d}):null})}var d7e=`tzkflr1`,f7e=`tzkflr2`,p7e=`tzkflr3`,m7e=`tzkflr4`,h7e=`tzkflr5`,g7e=`tzkflr6`,_7e=`tzkflr7`,v7e=`tzkflr8`,y7e=`tzkflr9`,b7e=`tzkflra`,x7e=`tzkflrb`,S7e=`tzkflrc`,C7e=`tzkflrd`,w7e=`tzkflrg`,T7e=`tzkflrh`,E7e=`tzkflri`,a9=`tzkflrj`,D7e=`tzkflrk`,O7e=`tzkflrl`;function o9({value:e,onCommit:t,onKeyDown:n,plain:r,mono:i,...a}){let[o,s]=(0,G.useState)(null),c=()=>{o!==null&&o!==e&&t(o),s(null)},l=e=>{n?.(e),e.key===`Enter`&&e.currentTarget.blur()},u={type:`text`,...a,value:o??e,onBlur:c,onChange:e=>s(e.target.value),onFocus:()=>s(e),onKeyDown:l};return r?(0,K.jsx)(`input`,{...u}):(0,K.jsx)(ct,{mono:i,...u})}var s9=e=>typeof e==`object`&&!!e&&!Array.isArray(e),k7e=e=>e===void 0||e===``;function A7e(e){let t;try{t=JSON.parse(e)}catch{return null}if(!s9(t))return null;let n=Array.isArray(t.series)?t.series:[],r=Array.isArray(t.data)?t.data:[];return{...t,series:n.flatMap(e=>typeof e==`string`?[{key:e}]:s9(e)&&typeof e.key==`string`?[e]:[]),data:r.filter(s9)}}function j7e(e){return JSON.stringify(e)}function c9(e,t){let n={...e};for(let[e,r]of Object.entries(t))k7e(r)?delete n[e]:n[e]=r;return n}function M7e(e,t,n){let r=s9(e[t])?{...e[t]}:{};for(let[e,t]of Object.entries(n))k7e(t)?delete r[e]:r[e]=t;let i={...e};return Object.keys(r).length===0?delete i[t]:i[t]=r,i}function N7e(e){let t=new Set;for(let n of e.data)if(s9(n))for(let e of Object.keys(n))t.add(e);return[...t]}function P7e(e){let t=new Set(N7e(e));e.x&&t.add(e.x);for(let n of e.series)t.add(n.key);return t}function F7e(e,t,n){let r=n.trim();if(!r||r===t||P7e(e).has(r))return e;let i=e=>e===t?r:e,a={...e,series:e.series.map(e=>e.key===t?{...e,key:r}:e),data:e.data.map(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[i(e),t])))};return e.x===t&&(a.x=r),e.highlight===t&&(a.highlight=r),a}function I7e(e){if(e.series.length>=6)return e;let t=P7e(e),n=e.series.length+1;for(;t.has(`series${n}`);)n++;let r=`series${n}`,i=new Set(e.series.map((e,t)=>e.color??t+1)),a=1;for(;i.has(a)&&a<6;)a++;return{...e,series:[...e.series,{key:r,label:`Series ${n}`,color:a}],data:e.data.map(e=>({...e,[r]:null}))}}function L7e(e,t){let n={...e,series:e.series.filter(e=>e.key!==t),data:e.data.map(e=>{let{[t]:n,...r}=e;return r})};return n.highlight===t&&delete n.highlight,n}function R7e(e){let t={[e.x??``]:``};for(let n of e.series)t[n.key]=null;return{...e,data:[...e.data,t]}}function z7e(e,t){return{...e,data:e.data.filter((e,n)=>n!==t)}}function B7e(e){let t=e.trim().replaceAll(`,`,``);if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:void 0}function V7e(e,t,n,r){let i;if(n===e.x)i=r;else{let t=B7e(r);if(t===void 0)return e;i=t}return{...e,data:e.data.map((e,r)=>r===t?{...e,[n]:i}:e)}}var H7e=e=>e==null?``:String(e);function U7e({draft:e,onChange:t}){let n=e.x??``,r=[n,...e.series.map(e=>e.key)];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:T7e,children:(0,K.jsxs)(`table`,{className:E7e,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[r.map(n=>(0,K.jsx)(`th`,{scope:`col`,children:(0,K.jsx)(o9,{plain:!0,"aria-label":`Rename ${n}`,className:`${a9} ${O7e}`,value:n,onCommit:r=>t(F7e(e,n,r))})},n)),(0,K.jsx)(`th`,{"aria-label":`Row actions`,scope:`col`})]})}),(0,K.jsx)(`tbody`,{children:e.data.map((i,a)=>(0,K.jsxs)(`tr`,{children:[r.map(r=>(0,K.jsx)(`td`,{children:(0,K.jsx)(o9,{plain:!0,"aria-label":`Row ${a+1} ${r}`,className:r===n?a9:`${a9} ${D7e}`,inputMode:r===n?void 0:`decimal`,value:H7e(i[r]),onCommit:n=>t(V7e(e,a,r,n))})},r)),(0,K.jsx)(`td`,{children:(0,K.jsx)(Fe,{icon:!0,"aria-label":`Remove row ${a+1}`,size:`sm`,onClick:()=>t(z7e(e,a)),children:(0,K.jsx)(k,{})})})]},a))})]})}),(0,K.jsxs)(`div`,{className:w7e,children:[(0,K.jsxs)(Fe,{size:`md`,variant:`outline`,onClick:()=>t(R7e(e)),children:[(0,K.jsx)(zr,{}),`Add row`]}),(0,K.jsxs)(Fe,{disabled:e.series.length>=6,size:`md`,variant:`outline`,onClick:()=>t(I7e(e)),children:[(0,K.jsx)(zr,{}),`Add series`]})]})]})}var W7e=[{value:`bar`,label:`Bar`},{value:`line`,label:`Line`},{value:`area`,label:`Area`},{value:`pie`,label:`Pie`}];function G7e({draft:e,onChange:t}){let n=(0,G.useId)(),r=new Set(e.series.map(e=>e.key)),i=N7e(e).filter(t=>t===e.x||!r.has(t)),a=e.x&&!i.includes(e.x)?[e.x,...i]:i;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:h7e,children:[(0,K.jsx)(`span`,{className:g7e,id:`${n}-type`,children:`Type`}),(0,K.jsx)(`div`,{"aria-labelledby":`${n}-type`,role:`group`,children:(0,K.jsx)(xt,{fullWidth:!0,items:W7e,value:e.type??`bar`,onChange:n=>t(c9(e,{type:n}))})})]}),(0,K.jsx)(Kn,{id:`${n}-title`,label:`Title`,children:(0,K.jsx)(o9,{id:`${n}-title`,value:e.title??``,onCommit:n=>t(c9(e,{title:n}))})}),(0,K.jsx)(Kn,{id:`${n}-x`,label:`Category field (x)`,children:(0,K.jsxs)(oe,{disabled:a.length===0,value:e.x??null,onValueChange:n=>{typeof n==`string`&&t(c9(e,{x:n}))},children:[(0,K.jsx)(ge,{className:_7e,id:`${n}-x`,children:(0,K.jsx)(de,{placeholder:`No data`})}),(0,K.jsx)(wte,{children:a.map(e=>(0,K.jsx)(vee,{value:e,children:e},e))})]})}),(0,K.jsxs)(`div`,{className:h7e,children:[(0,K.jsx)(`span`,{className:g7e,children:`Series`}),e.series.map((n,r)=>(0,K.jsx)(K7e,{draft:e,index:r,series:n,onChange:t},r)),(0,K.jsxs)(Fe,{disabled:e.series.length>=6,size:`md`,variant:`outline`,onClick:()=>t(I7e(e)),children:[(0,K.jsx)(zr,{}),`Add series`]})]})]})}function K7e({draft:e,index:t,series:n,onChange:r}){let[i,a]=(0,G.useState)(!1),o=t+1,s=n.color??o,c=n=>{r({...e,series:e.series.map((e,r)=>r===t?{...e,...n}:e)})};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:x7e,children:[(0,K.jsx)(`button`,{"aria-expanded":i,"aria-label":`Series ${o} color`,className:S7e,type:`button`,onClick:()=>a(!i),children:(0,K.jsx)(`span`,{className:C7e,style:{background:bH[(s-1+6)%6]}})}),(0,K.jsx)(o9,{mono:!0,"aria-label":`Series ${o} key`,className:v7e,value:n.key,onCommit:t=>r(F7e(e,n.key,t))}),(0,K.jsx)(o9,{"aria-label":`Series ${o} label`,className:y7e,placeholder:n.key,value:n.label??``,onCommit:e=>c({label:e||void 0})}),(0,K.jsx)(Fe,{icon:!0,"aria-label":`Remove series ${o}`,disabled:e.series.length<=1,size:`md`,onClick:()=>r(L7e(e,n.key)),children:(0,K.jsx)(k,{})})]}),i&&(0,K.jsx)(`div`,{className:`tzkflre`,children:bH.map((e,t)=>(0,K.jsx)(`button`,{"aria-label":`Color ${t+1}`,"aria-pressed":s===t+1,className:`tzkflrf`,type:`button`,onClick:()=>{c({color:t+1}),a(!1)},children:(0,K.jsx)(`span`,{className:`tzkflrd`,style:{background:e}})},e))})]})}var q7e=[{key:`subtitle`,label:`Subtitle`},{key:`source`,label:`Source`},{key:`xLabel`,label:`X axis label`},{key:`note`,label:`Note`}],J7e=10,Y7e=e=>Number.isInteger(e)&&e>=0&&e<=J7e,l9=e=>typeof e==`number`?String(e):``;function X7e(e,t){let n=e[t];return typeof n==`object`&&n?n:{}}function Z7e({draft:e,onChange:t}){let n=(0,G.useId)(),r=X7e(e,`y`),i=X7e(e,`format`),a=(e.type===`bar`||e.type===`area`)&&e.series.length>1,o=(n,r,i,a=Number.isFinite)=>{let o=B7e(i);o===void 0||o!==null&&!a(o)||t(M7e(e,n,{[r]:o??void 0}))};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:b7e,children:q7e.map(({key:r,label:i})=>(0,K.jsx)(Kn,{id:`${n}-${r}`,label:i,children:(0,K.jsx)(o9,{id:`${n}-${r}`,placeholder:`Optional`,value:typeof e[r]==`string`?e[r]:``,onCommit:n=>t(c9(e,{[r]:n}))})},r))}),e.type!==`pie`&&(0,K.jsxs)(`div`,{className:`tzkflra`,children:[(0,K.jsx)(Kn,{id:`${n}-ymin`,label:`Y min`,children:(0,K.jsx)(o9,{id:`${n}-ymin`,inputMode:`decimal`,placeholder:`Auto`,value:l9(r.min),onCommit:e=>o(`y`,`min`,e)})}),(0,K.jsx)(Kn,{id:`${n}-ymax`,label:`Y max`,children:(0,K.jsx)(o9,{id:`${n}-ymax`,inputMode:`decimal`,placeholder:`Auto`,value:l9(r.max),onCommit:e=>o(`y`,`max`,e)})})]}),(0,K.jsxs)(`div`,{className:b7e,children:[(0,K.jsx)(Kn,{id:`${n}-unit`,label:`Unit`,children:(0,K.jsx)(o9,{id:`${n}-unit`,placeholder:`e.g. %`,value:typeof i.unit==`string`?i.unit:``,onCommit:n=>t(M7e(e,`format`,{unit:n}))})}),(0,K.jsx)(Kn,{id:`${n}-decimals`,label:`Decimals`,children:(0,K.jsx)(o9,{id:`${n}-decimals`,inputMode:`numeric`,placeholder:`Auto`,value:l9(i.decimals),onCommit:e=>o(`format`,`decimals`,e,Y7e)})})]}),a&&(0,K.jsx)(Xe,{checked:e.stacked===!0,label:`Stacked`,onChange:n=>t(c9(e,{stacked:n||void 0}))}),e.type===`pie`&&(0,K.jsx)(Xe,{checked:e.donut===!0,label:`Donut`,onChange:n=>t(c9(e,{donut:n||void 0}))})]})}var Q7e=[{value:`setup`,label:`Setup`},{value:`data`,label:`Data`},{value:`style`,label:`Style`}];function $7e({spec:e,onChange:t}){let[n,r]=(0,G.useState)(`setup`),i=(0,G.useMemo)(()=>A7e(e),[e]);return i?(0,K.jsxs)(`div`,{className:d7e,children:[(0,K.jsx)(`div`,{className:f7e,children:(0,K.jsx)(xt,{fullWidth:!0,items:Q7e,value:n,onChange:r})}),(0,K.jsx)(`div`,{className:p7e,children:(0,K.jsx)(n===`setup`?G7e:n===`data`?U7e:Z7e,{draft:i,onChange:e=>t(j7e(e))})})]}):(0,K.jsx)(`div`,{className:d7e,children:(0,K.jsx)(`p`,{className:m7e,children:`Chart spec is not valid JSON, so it can't be edited here. Check it under Raw data.`})})}var e9e=`_1vsdskt0`,t9e=`_1vsdskt1`;function n9e(e){return wt()?(0,K.jsx)(a9e,{...e}):(0,K.jsx)(Kj,{defaultRenderer:XH,props:{spec:e.spec},rendererKey:ZH})}function r9e(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}var i9e=e=>e.stopPropagation();function a9e({spec:e,nodeKey:t}){let[n]=ht(),[r,i,a]=vF(t),[o,s]=(0,G.useState)(`chart`),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),f=(0,G.useMemo)(()=>GH(e).ok,[e]),p=(0,G.useMemo)(()=>r9e(e),[e]),m=(0,G.useCallback)(e=>{e.shiftKey||a(),i(!0)},[a,i]),h=(0,G.useCallback)(()=>{navigator.clipboard&&navigator.clipboard.writeText(e).then(()=>Pe({title:`Chart spec copied`,tone:`success`}),()=>Pe({title:`Could not copy chart spec`,tone:`error`}))},[e]),g=(0,G.useCallback)(e=>{n.update(()=>{let n=Dn(t);GLe(n)&&n.setSpec(e)})},[n,t]),_=r||c||u;return(0,K.jsxs)(`div`,{className:`${e9e}${r?` ${t9e}`:``}`,onClick:m,children:[(0,K.jsx)(YH,{hideToggle:!0,defaultView:o,value:e},o),_&&(0,K.jsxs)(`div`,{"aria-label":`Chart`,className:`_1vsdskt2`,role:`toolbar`,onClick:i9e,children:[(0,K.jsxs)(gn,{open:u,onOpenChange:d,children:[(0,K.jsxs)(en,{render:(0,K.jsx)(Fe,{size:`md`}),children:[(0,K.jsx)(dne,{}),`Edit chart`]}),(0,K.jsxs)(yn,{flush:!0,align:`end`,className:`tzkflr0`,side:`bottom`,size:`lg`,children:[(0,K.jsx)(wn,{icon:(0,K.jsx)(Ar,{}),title:`Chart`}),(0,K.jsx)($7e,{spec:e,onChange:g})]})]}),f&&(0,K.jsxs)(Fe,{"aria-pressed":o===`table`,size:`md`,onClick:()=>s(o===`table`?`chart`:`table`),children:[o===`table`?(0,K.jsx)(Ar,{}):(0,K.jsx)(Qte,{}),o===`table`?`View chart`:`View data`]}),(0,K.jsxs)(gn,{open:c,onOpenChange:l,children:[(0,K.jsxs)(en,{render:(0,K.jsx)(Fe,{size:`md`}),children:[(0,K.jsx)(Pr,{}),`Raw data`]}),(0,K.jsxs)(yn,{flush:!0,align:`end`,className:`_1vsdskt3`,side:`bottom`,size:`lg`,children:[(0,K.jsx)(wn,{icon:(0,K.jsx)(Pr,{}),title:`Chart spec`,actions:(0,K.jsxs)(Fe,{size:`md`,onClick:h,children:[(0,K.jsx)(Ir,{}),`Copy`]})}),(0,K.jsx)(`pre`,{className:`_1vsdskt4`,children:p||(0,K.jsx)(`span`,{className:`_1vsdskt5`,children:`(empty)`})})]})]})]})]})}var o9e=JSON.stringify({version:1,type:`bar`,title:`Monthly visits`,x:`month`,series:[{key:`visits`,label:`Visits`}],data:[{month:`Jan`,visits:120},{month:`Feb`,visits:160},{month:`Mar`,visits:140},{month:`Apr`,visits:200}]}),u9=class e extends tU{static clone(t){return new e(t.__spec,t.__key)}constructor(e=``,t){super(e,t)}static importJSON(t){return new e(eU(t.spec)).updateFromJSON(t)}decorate(e,t){return(0,G.createElement)(n9e,{spec:this.__spec,nodeKey:this.__key})}};$H(u9,`commandItems`,[{title:`Chart`,icon:(0,G.createElement)(ii,{size:20}),description:`Bar, line, area or pie chart`,keywords:[`chart`,`graph`,`bar`,`line`,`pie`,`data`],section:`ADVANCED`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([s9e(o9e)])})}}]);function s9e(e=``){return new u9(e)}var c9e=(0,G.lazy)(()=>Promise.resolve().then(()=>b9e).then(e=>({default:e.WhiteboardEditRenderer}))),d9=class e extends BU{static clone(t){return new e(t.__snapshot,t.__key)}constructor(e,t){super(e,t)}static importJSON(t){return new e(t.snapshot).updateFromJSON(t)}decorate(e,t){let n=this.__key,r=(0,G.createElement)(`div`,{className:`rich-excalidraw-loading`,style:{position:`relative`,width:`100%`,aspectRatio:`16 / 10`,margin:`1rem 0`}}),i=(0,G.createElement)(at,{fallback:r,children:(0,G.createElement)(G.Suspense,{fallback:r},(0,G.createElement)(c9e,{snapshot:EU(this.__snapshot),onSnapshotChange:t=>{e.update(()=>{let e=Dn(n);e&&e.setSnapshot(SRe(t))})}}))});return(0,G.createElement)(Pee,{editor:e,editable:i,readOnly:super.decorate(e,t)})}};Cr(d9,`commandItems`,[{title:`Whiteboard`,icon:(0,G.createElement)(jr,{size:20}),description:`Whiteboard canvas`,keywords:[`excalidraw`,`whiteboard`,`draw`,`canvas`],nested:!1,section:`MEDIA`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([l9e(`{}`)])})}}]);function l9e(e){return new d9(e)}var u9e=`[data-whiteboard-editor]`;function d9e(e){return e instanceof Element&&!!e.closest(u9e)}function f9e(e){let t=e.getState();return!!(t.editingTextId||t.editingRichTextId||t.editingFrameId||e.isTransient()||t.tool!==`selection`&&!t.toolLocked)}function p9e(e,t){let n=e.getState();n.editingTextId?hte(e):n.editingRichTextId?e.setState({editingRichTextId:null}):n.editingFrameId?e.setState({editingFrameId:null}):t?.dispatchEvent(new KeyboardEvent(`keydown`,{key:`Escape`,bubbles:!0,cancelable:!0}))}var m9e=[{value:`inline`,label:`Inline`},{value:`remote`,label:`Remote`},{value:`delta`,label:`Delta`}],h9e=({onCopy:e,onExport:t,onOpenChange:n,open:r,storage:i})=>{let a=(0,G.useId)(),o=`${a}-storage`,s=`${a}-ref`;return(0,K.jsxs)(gn,{open:r,onOpenChange:n,children:[(0,K.jsx)(en,{render:(0,K.jsx)(Fe,{icon:!0,"aria-label":`More options`,size:`md`,title:`More options`,children:(0,K.jsx)(Nr,{})})}),(0,K.jsxs)(yn,{flush:!0,align:`end`,side:`bottom`,size:`md`,children:[(0,K.jsx)(Xn,{children:(0,K.jsxs)(`div`,{className:vRe,children:[(0,K.jsxs)(Fe,{size:`md`,variant:`outline`,onClick:e,children:[(0,K.jsx)(Nne,{}),`Copy JSON`]}),(0,K.jsxs)(Fe,{size:`md`,variant:`outline`,onClick:t,children:[(0,K.jsx)(E,{}),`Export JSON`]})]})}),i&&(0,K.jsxs)(Xn,{className:`_1xd3mo4m`,children:[(0,K.jsx)(`span`,{className:`_1xd3mo4n`,children:`Advanced`}),(0,K.jsxs)(`div`,{"aria-labelledby":o,className:`_1xd3mo4o`,role:`group`,children:[(0,K.jsx)(`span`,{className:`_1xd3mo4p`,id:o,children:`Storage`}),(0,K.jsx)(xt,{fullWidth:!0,items:m9e,value:i.mode,onChange:i.onModeChange})]}),i.mode!==`inline`&&(0,K.jsx)(Kn,{id:s,label:`Base URL or ref`,children:(0,K.jsx)(ct,{mono:!0,id:s,placeholder:`https://… or ref:file/…`,spellCheck:!1,value:i.refValue,onChange:e=>i.onRefChange(e.target.value)})})]})]})]})},g9e=()=>Pe({title:`Couldn’t upload the image; it is kept inside the whiteboard`,tone:`error`});function _9e(e,t){return!e||!t?`inline`:t.type===`delta`?`delta`:t.type===`remote`?`remote`:`inline`}function v9e(e,t){return!e||!t?``:t.type===`remote`?t.url:t.type===`delta`?t.baseUrl:``}var y9e=({baseData:e,baseRef:t,dismiss:n,holdEscapeDismiss:i,initialData:a,initialSnapshot:o,isConfirming:s,onClose:c,onDirtyChange:l,onSave:u,onUploadError:d=g9e,requestDismiss:f,saveSnapshot:p,theme:m,uploadFile:h})=>{let[g]=(0,G.useState)(()=>ate(a)),_=(0,G.useRef)(null),v=(0,G.useRef)(t),y=(0,G.useRef)(e),b=Ree(g),[x,S]=(0,G.useState)(!1),[C,w]=(0,G.useState)(!1),[T,E]=(0,G.useState)(!1),D=!T&&(x||C),[O,k]=(0,G.useState)(!1),[A,j]=(0,G.useState)(!1),[M,N]=(0,G.useState)(()=>_9e(p,o)),[P,F]=(0,G.useState)(()=>v9e(p,o));(0,G.useEffect)(()=>{l(D)},[D,l]),(0,G.useEffect)(()=>g.subscribe(()=>S(g.isDirty())),[g]);let I=(0,G.useCallback)(()=>{queueMicrotask(()=>_.current?.querySelector(`[data-whiteboard-canvas]`)?.focus({preventScroll:!0}))},[]),L=(0,G.useCallback)(()=>g.getScene(),[g]),R=(0,G.useCallback)(async e=>{if(!p||M===`inline`||M===`delta`&&v.current&&y.current||M===`remote`&&v.current&&y.current&&JSON.stringify(e)===JSON.stringify(y.current))return;let t=await p(e,v.current||void 0);v.current=t,y.current=e,F(t)},[p,M]),z=(0,G.useCallback)(async e=>{if(M===`inline`||!p)return{type:`inline`,data:e};let t=v.current;if(t){if(M===`delta`&&y.current){let{diff:n}=await r(async()=>{let{diff:e}=await import(`./lib-DJrc3aG3.js`);return{diff:e}},[],import.meta.url),i=n(y.current,structuredClone(e));return i?{type:`delta`,baseUrl:t,delta:i}:{type:`remote`,url:t}}return{type:`remote`,url:t}}},[p,M]),B=Vee(g,e=>e.elements.some(e=>e.type===`image`&&!e.isDeleted&&e.status===`pending`)),V=(0,G.useCallback)(async()=>{if(O||B)return;let e=L();if(e){k(!0);try{await R(e);let t=await z(e);if(!t)return;u(t),c(e),E(!0),n()}catch{Pe({title:`Couldn’t save the whiteboard`,tone:`error`})}finally{k(!1)}}},[O,B,L,R,z,u,c,n]),H=(0,G.useRef)(A);H.current=A,(0,G.useEffect)(()=>{let e=e=>{if(!(e.key!==`Escape`||H.current)){if(!s()&&f9e(g)){if(i?.(),d9e(e.target))return;e.preventDefault(),e.stopImmediatePropagation(),p9e(g,_.current?.querySelector(`[data-whiteboard-canvas]`)??null)}else e.preventDefault(),e.stopImmediatePropagation(),s()?mee():f()}};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[i,s,f,g]);let U=(0,G.useCallback)(()=>{let e=L(),t=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`excalidraw-snapshot.json`,r.click(),URL.revokeObjectURL(n)},[L]),ee=(0,G.useCallback)(()=>{let e=L();navigator.clipboard.writeText(JSON.stringify(e)).then(()=>Pe({title:`Copied`,tone:`success`}),()=>Pe({title:`Couldn’t copy`,tone:`error`}))},[L]),te=(0,G.useCallback)(e=>{F(e),v.current=e,y.current=void 0,w(!0)},[]),ne=(0,G.useCallback)(e=>{N(e),e===`inline`&&F(``),w(!0)},[]);return(0,K.jsxs)(Lee,{className:_Re,onSave:V,children:[(0,K.jsx)(Bee,{center:b?void 0:(0,K.jsx)(fte,{store:g,onToolSelect:I}),icon:(0,K.jsx)(Fr,{}),title:`Whiteboard`,actions:(0,K.jsx)(h9e,{open:A,storage:p?{mode:M,onModeChange:ne,onRefChange:te,refValue:P}:void 0,onCopy:ee,onExport:U,onOpenChange:j}),onClose:f}),(0,K.jsx)(ete,{className:hRe,children:(0,K.jsx)(`div`,{className:gRe,ref:_,children:(0,K.jsx)(nte,{store:g,theme:m,toolbar:`none`,uploadFile:h,onUploadError:d})})}),(0,K.jsx)(xte,{dirty:D,saveDisabled:O||B,status:(0,K.jsxs)(K.Fragment,{children:[!D&&!O&&(0,K.jsx)(`span`,{"aria-hidden":!0,className:`_1xd3mo4k`}),O?`Saving…`:B?`Uploading image…`:D?`Unsaved changes`:`Saved`]}),onCancel:f,onSave:V})]})},b9e=CU({WhiteboardEditRenderer:()=>x9e}),x9e=({snapshot:e,onSnapshotChange:t})=>{let n=lF(),{saveSnapshot:r,uploadFile:i}=OU(),{snapshot:a,loading:o,error:s,retry:c,retryable:l,baseRef:u,baseData:d}=NU(e),[f,p]=(0,G.useState)(),m=(0,G.useRef)(t);m.current=t;let h=(0,G.useRef)(r);h.current=r;let g=(0,G.useRef)(i);g.current=i;let _=(0,G.useRef)(e);_.current=e;let{className:v}=We();PU();let y=f??a,b=(0,G.useRef)(y);b.current=y;let x=(0,G.useMemo)(()=>kU(y),[y]),S=(0,G.useRef)(u),C=(0,G.useRef)(d);(0,G.useEffect)(()=>{u&&(S.current=u)},[u]),(0,G.useEffect)(()=>{d&&(C.current=d)},[d]);let w=(0,G.useCallback)(()=>{if(o)return;let e={dirty:!1,confirming:!1,escapeHeld:!1},t=()=>{e.escapeHeld=!0,setTimeout(()=>{e.escapeHeld=!1},0)};At({content:({dismiss:r,requestDismiss:i})=>(0,K.jsx)(y9e,{baseData:C.current,baseRef:S.current,dismiss:r,holdEscapeDismiss:t,initialData:b.current,initialSnapshot:_.current,isConfirming:()=>e.confirming,requestDismiss:i,saveSnapshot:h.current,theme:n,uploadFile:g.current,onSave:e=>m.current(e),onClose:e=>{e&&p(e)},onDirtyChange:t=>{e.dirty=t}}),className:mRe,portalClassName:v,theme:n,showCloseButton:!1,clickOutsideToDismiss:!1,confirmDismiss:async()=>{if(e.escapeHeld)return!1;if(!e.dirty)return!0;if(e.confirming)return!1;e.confirming=!0;try{return await Se()}finally{e.confirming=!1}}})},[o,n,v]);return o?(0,K.jsx)(`div`,{className:wU,children:(0,K.jsx)(FU,{})}):s?(0,K.jsx)(`div`,{className:wU,children:(0,K.jsx)(LU,{message:s,onRetry:l?c:void 0})}):(0,K.jsxs)(`div`,{className:wU,children:[x&&AU(x)>0?(0,K.jsx)(Oee,{scene:x,theme:n}):(0,K.jsx)(IU,{}),(0,K.jsx)(`button`,{"aria-label":`Edit whiteboard`,className:yRe,type:`button`,onClick:w,children:(0,K.jsxs)(`span`,{className:bRe,children:[(0,K.jsx)(Ae,{size:14}),`Edit`]})})]})},S9e=Rn(`INSERT_WHITEBOARD`);function C9e(){let[e]=ht();return(0,G.useEffect)(()=>e.registerCommand(S9e,e=>{let t=l9e(e);return Un([t]),!0},0),[e]),null}var f9=[{id:`basic`,label:`Basic blocks`},{id:`lists`,label:`Lists`},{id:`media`,label:`Media`},{id:`rich`,label:`Rich blocks`},{id:`layout`,label:`Layout`},{id:`embed`,label:`Embed`},{id:`inline`,label:`Inline`}],p9=[{id:`paragraph`,title:`Text`,icon:w,group:`basic`,description:`Plain text block`},{id:`h1`,title:`Heading 1`,icon:Fne,group:`basic`,description:`Large section heading`},{id:`h2`,title:`Heading 2`,icon:Ine,group:`basic`,description:`Medium section heading`},{id:`h3`,title:`Heading 3`,icon:Lne,group:`basic`,description:`Small section heading`},{id:`quote`,title:`Quote`,icon:Yne,group:`basic`,description:`Capture a quote`},{id:`callout`,title:`Callout`,icon:g,group:`basic`},{id:`tip`,title:`Tip`,icon:gi,group:`basic`},{id:`warning`,title:`Warning`,icon:v,group:`basic`},{id:`divider`,title:`Divider`,icon:x,group:`basic`,description:`Visual separator`},{id:`bullet`,title:`Bulleted list`,icon:Wte,group:`lists`,aliases:[`bullet list`],description:`Unordered list`},{id:`number`,title:`Numbered list`,icon:bee,group:`lists`,aliases:[`numbered`],description:`Ordered list with numbers`},{id:`check`,title:`To-do list`,icon:Rne,group:`lists`,aliases:[`to-do`,`todo`,`checklist`],description:`Track tasks with checkboxes`},{id:`image`,title:`Image`,icon:T,group:`media`},{id:`video`,title:`Video`,icon:tne,group:`media`},{id:`file`,title:`File`,icon:Ei,group:`media`},{id:`gallery`,title:`Gallery`,icon:Rte,group:`media`},{id:`whiteboard`,title:`Whiteboard`,icon:jr,group:`media`},{id:`code`,title:`Code block`,icon:Pr,group:`rich`,description:`Syntax-highlighted code`},{id:`math`,title:`Math block`,icon:Mi,group:`rich`,aliases:[`math equation`]},{id:`mermaid`,title:`Mermaid diagram`,icon:Wi,group:`rich`},{id:`code-snippet`,title:`Code snippet`,icon:Zte,group:`rich`},{id:`chart`,title:`Chart`,icon:ii,group:`rich`},{id:`poll`,title:`Poll`,icon:Zne,group:`rich`},{id:`chat`,title:`Chat`,icon:Rr,group:`rich`},{id:`dynamic`,title:`Dynamic component`,icon:jne,group:`rich`},{id:`nested-doc`,title:`Nested document`,icon:_,group:`rich`},{id:`banner`,title:`Banner`,icon:ci,group:`rich`},{id:`details`,title:`Details`,icon:Ite,group:`rich`},{id:`table`,title:`Table`,icon:Jne,group:`layout`,description:`Add a table`},{id:`grid`,title:`Grid`,icon:Lr,group:`layout`},{id:`steps`,title:`Steps`,icon:Pne,group:`layout`},{id:`embed`,title:`Embed`,icon:One,group:`embed`},{id:`link-card`,title:`Link card`,icon:y,group:`embed`},{id:`mention`,title:`Mention`,icon:Ane,group:`inline`},{id:`tag`,title:`Tag`,icon:Li,group:`inline`},{id:`comment`,title:`HTML comment`,icon:Bne,group:`inline`}],w9e=[`paragraph`,`h1`,`h2`,`h3`,`bullet`,`number`,`check`,`quote`,`code`],T9e={"basic blocks":`basic`,basic:`basic`,lists:`lists`,list:`lists`,media:`media`,advanced:`rich`,"rich blocks":`rich`,layout:`layout`,embed:`embed`,inline:`inline`},m9=e=>e.trim().toLowerCase(),E9e=new Map;for(let e of p9)for(let t of[e.id,e.title,...e.aliases??[]])E9e.set(m9(t),e);var h9=new Map(f9.map(e=>[e.id,e]));function g9(e){return E9e.get(m9(e))}function D9e(e){if(!e)return f9[0].label;let t=m9(e),n=T9e[t]??(h9.has(t)?t:null);return n?h9.get(n).label:e===e.toUpperCase()?e.charAt(0)+e.slice(1).toLowerCase():e}function O9e(e){let t=f9.findIndex(t=>t.label===e);return t===-1?f9.length:t}function _9(e,t={}){let n=t.iconSize??20,r=new Set,i=[];return e.forEach((e,t)=>{let a=g9(e.title),o=a?.title??e.title;if(r.has(o))return;r.add(o);let s=a?h9.get(a.group).label:D9e(e.section);i.push({item:{...e,title:o,section:s,description:e.description??a?.description,icon:a?(0,G.createElement)(a.icon,{size:n}):e.icon},rank:O9e(s),order:a?p9.indexOf(a):p9.length,position:t})}),i.sort((e,t)=>e.rank-t.rank||e.order-t.order||e.position-t.position).map(e=>e.item)}var k9e=w9e.map(e=>g9(e));function A9e({currentType:e,onDelete:t,onDuplicate:n,onMoveDown:r,onMoveUp:i,onTurnInto:a}){let o=e?g9(e):void 0,s=(o??k9e[0]).icon;return(0,K.jsxs)(Rt,{align:`start`,side:`bottom`,sideOffset:4,children:[e!==null&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(ite,{children:[(0,K.jsxs)(mte,{value:o?.title,children:[(0,K.jsx)(s,{}),`Turn into`]}),(0,K.jsx)(Rt,{align:`start`,side:`right`,sideOffset:4,children:(0,K.jsx)(M,{value:o?.id??null,children:k9e.map(e=>(0,K.jsxs)(pn,{closeOnClick:!0,value:e.id,onClick:()=>a(e.id),children:[(0,K.jsx)(e.icon,{}),e.title]},e.id))})})]}),(0,K.jsx)(ur,{})]}),(0,K.jsxs)(Ut,{shortcut:`Mod+D`,onClick:n,children:[(0,K.jsx)(Ir,{}),`Duplicate`]}),(0,K.jsxs)(Ut,{shortcut:`Mod+Shift+Up`,onClick:i,children:[(0,K.jsx)(Nte,{}),`Move up`]}),(0,K.jsxs)(Ut,{shortcut:`Mod+Shift+Down`,onClick:r,children:[(0,K.jsx)(Mte,{}),`Move down`]}),(0,K.jsx)(ur,{}),(0,K.jsxs)(Ut,{shortcut:`Backspace`,variant:`destructive`,onClick:t,children:[(0,K.jsx)(Mr,{}),`Delete`]})]})}function j9e(e){return e.getTopLevelElement()?.getKey()??null}function M9e(){let e=kr();if(!Jn(e))return[];let t=new Set;for(let n of[e.anchor.getNode(),e.focus.getNode(),...e.getNodes()]){let e=j9e(n);e&&t.add(e)}return Sr().getChildren().map(e=>e.getKey()).filter(e=>t.has(e))}function v9(e,t){let n=new Set(e),r=Sr().getChildren().filter(e=>n.has(e.getKey()));if(r.length===0)return!1;let i=r[0],a=r.at(-1);if(t===`up`){let e=i.getPreviousSibling();return!e||n.has(e.getKey())?!1:(e.remove(),a.insertAfter(e),!0)}let o=a.getNextSibling();return!o||n.has(o.getKey())?!1:(o.remove(),i.insertBefore(o),!0)}function N9e(e){let t=e.constructor.importJSON(e.exportJSON());if(rr(e)&&rr(t))for(let n of e.getChildren())t.append(N9e(n));return t}function P9e(e){let t=new Set(e),n=Sr().getChildren().filter(e=>t.has(e.getKey()));if(n.length===0)return!1;let r=n.at(-1);for(let e of n){let t=N9e(e);r.insertAfter(t),r=t}return!0}function F9e(e,t,n){let r=new Set(e);if(r.has(t))return!1;let i=Sr().getChildren(),a=i.find(e=>e.getKey()===t),o=i.filter(e=>r.has(e.getKey()));if(!a||!o.length)return!1;for(let e of o)e.remove();if(n){for(let e of o)a.insertBefore(e);return!0}let s=a;for(let e of o)s.insertAfter(e),s=e;return!0}function I9e(e,t,n,r){if(!t){e.update(()=>{v9(n,r)});return}let i=t.documentKeys(e,n);i.length&&t.editor.update(()=>{v9(i,r)})}var L9e={bullet:mt,number:I,check:dn},R9e={paragraph:()=>on(),h1:()=>ae(`h1`),h2:()=>ae(`h2`),h3:()=>ae(`h3`),quote:()=>xr()};function z9e(e){if(!e)return null;if(yr(e))return`paragraph`;if(_r(e)){let t=e.getTag();return t===`h1`||t===`h2`||t===`h3`?t:null}if(Er(e))return`quote`;if(nr(e)){let t=e.getListType();return t===`bullet`||t===`number`||t===`check`?t:null}return e.getType()===`code`?`code`:null}function B9e(e){return e._nodes.get(`code-block`)?.klass??null}function V9e(e,t,n){let r=L9e[n];r?(e.update(()=>{let e=Dn(t);rr(e)&&e.selectStart()}),e.dispatchCommand(r,void 0)):e.update(()=>{let r=Dn(t);if(!rr(r))return;if(n===`code`){let t=B9e(e);if(t){r.replace(new t(r.getTextContent(),`text`));return}}r.selectStart();let i=kr();if(!Jn(i))return;let a=n===`code`?()=>TP():R9e[n];a&&ee(i,a)})}var y9=12;function H9e(e,t){if(e.length===0)return null;let n=e[0],r=e.at(-1);if(t<n.top)return t>=n.top-y9?{index:0,y:n.top-y9/2}:null;if(t>r.bottom)return t<=r.bottom+y9?{index:e.length,y:r.bottom+y9/2}:null;for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];if(t>r.bottom&&t<i.top)return{index:n,y:(r.bottom+i.top)/2}}return null}function U9e(e,t){return e.top+e.paddingTop+(e.lineHeight-t)/2}function W9e(e,t){let n=Number.parseFloat(e);return e.endsWith(`px`)&&Number.isFinite(n)?n:Number.parseFloat(t)*1.2}var G9e=`iihqkc0`,K9e=`iihqkc1`,q9e=`iihqkc2`,b9=`iihqkc5`,J9e=`iihqkc6`,x9=`iihqkc8`,Y9e=`iihqkc9`,X9e={ArrowUp:`up`,ArrowDown:`down`};function Z9e(e,t,n,r){return(i,a)=>{if(a!==e||i.altKey||(n?!i.metaKey||i.ctrlKey:!i.ctrlKey||i.metaKey))return!1;let o=X9e[i.key],s=!i.shiftKey&&i.key.toLowerCase()===`d`;if(!s&&(!o||!i.shiftKey))return!1;let c=t(),l=c.length>0?c:M9e();return l.length!==0&&(i.preventDefault(),s?P9e(l):r?I9e(e,r,l,o):v9(l,o),!0)}}function Q9e(e,t){let n=$k()?.documentBlocks;(0,G.useEffect)(()=>{let r=ree(typeof navigator>`u`?void 0:navigator)===`mac`;return e.registerCommand(br,Z9e(e,t,r,n),4)},[n,e,t])}var $9e=[`application/x-lexical-editor`,`text/html`,`text/plain`,`text/uri-list`];function eet(e){let t=e.exportJSON();return rr(e)&&(t.children=e.getChildren().map(eet)),t}function tet(e,t,n){let r=t.map(t=>e.getElementByKey(t.getKey())?.outerHTML??``).filter(Boolean).join(`
|
|
391
|
+
`);if(!(t<0))try{let{author:n,model:r,avatar:i}=JSON.parse(e.slice(t+1));return typeof n!=`string`||!n.trim()?void 0:{name:n,...typeof r==`string`&&r&&{model:r},...typeof i==`string`&&i&&{avatar:i}}}catch{}}var U5e=e=>H5e(e)?.name;function W5e(e,t,n){let r=Math.min(e.length,t.length),i=0;for(;i<r&&e[i]===t[i];)i++;let a=0;for(;a<r-i&&e[e.length-1-a]===t[t.length-1-a];)a++;return n<=i?n:n>=e.length-a?n+t.length-e.length:t.length-a}function e9(e){return Array.isArray(e)?`[${e.map(e9).join(`,`)}]`:e&&typeof e==`object`?`{${Object.keys(e).filter(t=>e[t]!==void 0).sort().map(t=>`${JSON.stringify(t)}:${e9(e[t])}`).join(`,`)}}`:JSON.stringify(e)}var G5e={listitem:[`value`]};function K5e(e){let{children:t,text:n,...r}=e;for(let t of G5e[e.type]??[])delete r[t];return r}function q5e(e){return e9(K5e(e))}function J5e(e,t){let n=K5e(t);return q5e(e.updateFromJSON(n).exportJSON())===q5e(t)}var Y5e=`collab`,X5e=`agent-write`,Z5e=`agent:`,Q5e=15,$5e=`lexical`,t9=`#text`,e7e=[`textFormat`,`textStyle`];function n9(e,t){return e===t||e9(e)===e9(t)}function r9(e){let{children:t,...n}=e.getLatest().exportJSON();if(it(e)&&delete n.text,rr(e))for(let e of e7e)delete n[e];return n}function i9(e){let{[t9]:t,...n}=e.data.toJSON();for(let e of e7e)delete n[e];return n}function t7e(e,t,n={}){let r=t.getTree($5e);r.enableFractionalIndex(0);let i=new Map,a=new Map,o=(e,t)=>{let n=i.get(e);n!==void 0&&a.delete(n);let r=a.get(t);r!==void 0&&i.delete(r),i.set(e,t),a.set(t,e)},s=e=>e!==void 0&&r.has(e)&&!r.isNodeDeleted(e),c=new Map,l=new Map,u=new Set,d=(e,t)=>{t.add(e.id);for(let n of e.children()??[])d(n,t)},f=(e,t)=>{let n=t.data,r=r9(e),i=c.get(e.getKey())??{},a=!1;for(let e of new Set([...Object.keys(i),...Object.keys(r)])){let t=r[e];(!n9(i[e],t)||t!==void 0&&n.get(e)===void 0)&&(t===void 0?n.get(e)!==void 0&&(n.delete(e),a=!0):n9(n.get(e),t)||(n.set(e,t),a=!0))}if(c.set(e.getKey(),r),a&&l.set(t.id,e9(i9(t))),it(e)){let t=n.getOrCreateContainer(t9,new pj),r=e.getTextContent();t.toString()!==r&&t.update(r)}},p=(e,t,n)=>{let a=e.getChildren(),c=new Set(a.map(e=>i.get(e.getKey()))),l=new Map,m=null;for(let e of r.getNodeByID(t)?.children()??[])u.has(e.id)?(l.set(m,[...l.get(m)??[],e.id]),d(e,n)):c.has(e.id)&&(m=e.id);let h=0,g=e=>{let n=r.getNodeByID(e);(n.parent()?.id!==t||n.index()!==h)&&r.move(e,t,h),h+=1};l.get(null)?.forEach(g);for(let e of a){let a=i.get(e.getKey());s(a)?g(a):(a=r.createNode(t,h).id,o(e.getKey(),a),h+=1),n.add(a),f(e,r.getNodeByID(a)),rr(e)&&p(e,a,n),l.get(a)?.forEach(g)}},m=()=>{e.getEditorState().read(()=>{let e=i.get(`root`);s(e)||(e=r.roots()[0]?.id??r.createNode().id,o(`root`,e));let t=new Set([e]);f(Sr(),r.getNodeByID(e)),p(Sr(),e,t);for(let e of r.nodes())if(!t.has(e.id)&&s(e.id)){r.delete(e.id);let t=a.get(e.id);t!==void 0&&i.delete(t),a.delete(e.id)}}),t.commit({message:n.commitMessage})},h=(e,t)=>{let n=e.getTextContent();if(n===t)return;let r=kr(),i=Jn(r)?[r.anchor,r.focus].filter(t=>t.type===`text`&&t.key===e.getKey()):[],a=i.map(e=>W5e(n,t,e.offset));e.setTextContent(t),i.forEach((t,n)=>t.set(e.getKey(),a[n],`text`))},g=e=>{let t=_(e);return c.set(t.getKey(),r9(t)),t},_=e=>{let t=i9(e),n=n7e(t)?String(e.data.get(t9)??``):void 0,r=a.get(e.id),i=r===void 0?null:Dn(r);if(i&&i.getType()===t.type){if(it(i))return n9(r9(i),t)||i.updateFromJSON({...t,text:i.getTextContent()}),h(i,n??``),i;let r=e9(t);if(l.get(e.id)===r||n9(r9(i),t)||J5e(i,t))return l.set(e.id,r),i;l.set(e.id,r);let a=Ne({...t,children:[]});return i.replace(a,rr(i)&&rr(a)),o(a.getKey(),e.id),a}let s=Ne({...t,...n===void 0?{}:{text:n},children:[]});return l.set(e.id,e9(t)),o(s.getKey(),e.id),s},v=(e,t,n)=>{let r=0;for(let i of t.children()??[]){let t;try{t=g(i)}catch{u.add(i.id);continue}u.delete(i.id),n.add(t.getKey());let a=e.getChildAtIndex(r);if(!a||!a.is(t)){if(r===0){let n=e.getFirstChild();n?n.insertBefore(t):e.append(t)}else e.getChildAtIndex(r-1).insertAfter(t)}rr(t)&&v(t,i,n),r+=1}},y=(e,t)=>{for(let n of e.getChildren())t.push(n),rr(n)&&y(n,t)},b=(t=!1)=>{e.update(()=>{let e=r.roots()[0];if(!e)return;o(`root`,e.id);let t=i9(e);t.type===`root`&&!n9(r9(Sr()),t)&&Sr().updateFromJSON(t),c.set(`root`,r9(Sr()));let n=new Set([`root`]);v(Sr(),e,n);let i=[];y(Sr(),i);for(let e of i)!n.has(e.getKey())&&e.isAttached()&&e.remove()},{discrete:!0,tag:t?[Y5e,X5e]:Y5e})};return r.roots().length>0?b():m(),{dispose:e.registerUpdateListener(({dirtyElements:e,dirtyLeaves:t})=>{(e.size!==0||t.size!==0)&&m()}),idOf:e=>i.get(e),keyOf:e=>a.get(e),import:e=>{b(r7e(t,t.import(e),n.agentLiveWindowSeconds??Q5e))}}}function n7e(e){return typeof e.format==`number`&&typeof e.detail==`number`&&`mode`in e}function r7e(e,t,n){let r=Date.now()/1e3-n;for(let[n,i]of t.success){let t=i.start;for(;t<i.end;){let i=e.getChangeAt({peer:n,counter:t});if(i.message?.startsWith(Z5e)&&i.timestamp>=r)return!0;t=i.counter+i.length}}return!1}var i7e=/^assets\/[\w-][\w.-]*\.html$/,a7e=80,o7e=2e3;function s7e(e,t,n,r){if(!i7e.test(t))return null;let i=`${e}${t}?v=${n}`;return Object.keys(r).length===0?i:`${i}#ryugi-props=${encodeURIComponent(JSON.stringify(r))}`}function c7e(e){return Number.isFinite(e)?Math.min(o7e,Math.max(a7e,Math.ceil(e))):null}var l7e=(0,G.createContext)(null);function u7e({url:e,componentProps:t,initialHeight:n}){let r=(0,G.useContext)(l7e),[i,a]=(0,G.useState)(0),[o,s]=(0,G.useState)(()=>c7e(n)??320);(0,G.useEffect)(()=>r?.channel.subscribe(t=>{t.type===`change`&&t.artifact===r.artifact&&t.files.includes(e)&&a(e=>e+1)}),[r,e]);let c=r?.contentBase?s7e(r.contentBase,e,i,t):null,{frameRef:l,src:u,onLoad:d}=Cne(c,{onError:t=>r?.send({type:`runtime-error`,artifact:r.artifact,file:e,message:t}),onLoaded:()=>r?.send({type:`loaded`,artifact:r.artifact,file:e}),onMessage:e=>{if(e.type!==`ryugi:height`)return;let t=c7e(Number(e.height));t!==null&&s(t)}});return(0,K.jsx)(`div`,{className:`ryugi-dynamic`,contentEditable:!1,style:{height:o},children:u?(0,K.jsx)(`iframe`,{allow:`clipboard-write`,ref:l,sandbox:wne,src:u,style:{display:`block`,width:`100%`,height:`100%`,border:0},title:e,onLoad:d}):null})}var d7e=`tzkflr1`,f7e=`tzkflr2`,p7e=`tzkflr3`,m7e=`tzkflr4`,h7e=`tzkflr5`,g7e=`tzkflr6`,_7e=`tzkflr7`,v7e=`tzkflr8`,y7e=`tzkflr9`,b7e=`tzkflra`,x7e=`tzkflrb`,S7e=`tzkflrc`,C7e=`tzkflrd`,w7e=`tzkflrg`,T7e=`tzkflrh`,E7e=`tzkflri`,a9=`tzkflrj`,D7e=`tzkflrk`,O7e=`tzkflrl`;function o9({value:e,onCommit:t,onKeyDown:n,plain:r,mono:i,...a}){let[o,s]=(0,G.useState)(null),c=()=>{o!==null&&o!==e&&t(o),s(null)},l=e=>{n?.(e),e.key===`Enter`&&e.currentTarget.blur()},u={type:`text`,...a,value:o??e,onBlur:c,onChange:e=>s(e.target.value),onFocus:()=>s(e),onKeyDown:l};return r?(0,K.jsx)(`input`,{...u}):(0,K.jsx)(ct,{mono:i,...u})}var s9=e=>typeof e==`object`&&!!e&&!Array.isArray(e),k7e=e=>e===void 0||e===``;function A7e(e){let t;try{t=JSON.parse(e)}catch{return null}if(!s9(t))return null;let n=Array.isArray(t.series)?t.series:[],r=Array.isArray(t.data)?t.data:[];return{...t,series:n.flatMap(e=>typeof e==`string`?[{key:e}]:s9(e)&&typeof e.key==`string`?[e]:[]),data:r.filter(s9)}}function j7e(e){return JSON.stringify(e)}function c9(e,t){let n={...e};for(let[e,r]of Object.entries(t))k7e(r)?delete n[e]:n[e]=r;return n}function M7e(e,t,n){let r=s9(e[t])?{...e[t]}:{};for(let[e,t]of Object.entries(n))k7e(t)?delete r[e]:r[e]=t;let i={...e};return Object.keys(r).length===0?delete i[t]:i[t]=r,i}function N7e(e){let t=new Set;for(let n of e.data)if(s9(n))for(let e of Object.keys(n))t.add(e);return[...t]}function P7e(e){let t=new Set(N7e(e));e.x&&t.add(e.x);for(let n of e.series)t.add(n.key);return t}function F7e(e,t,n){let r=n.trim();if(!r||r===t||P7e(e).has(r))return e;let i=e=>e===t?r:e,a={...e,series:e.series.map(e=>e.key===t?{...e,key:r}:e),data:e.data.map(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[i(e),t])))};return e.x===t&&(a.x=r),e.highlight===t&&(a.highlight=r),a}function I7e(e){if(e.series.length>=6)return e;let t=P7e(e),n=e.series.length+1;for(;t.has(`series${n}`);)n++;let r=`series${n}`,i=new Set(e.series.map((e,t)=>e.color??t+1)),a=1;for(;i.has(a)&&a<6;)a++;return{...e,series:[...e.series,{key:r,label:`Series ${n}`,color:a}],data:e.data.map(e=>({...e,[r]:null}))}}function L7e(e,t){let n={...e,series:e.series.filter(e=>e.key!==t),data:e.data.map(e=>{let{[t]:n,...r}=e;return r})};return n.highlight===t&&delete n.highlight,n}function R7e(e){let t={[e.x??``]:``};for(let n of e.series)t[n.key]=null;return{...e,data:[...e.data,t]}}function z7e(e,t){return{...e,data:e.data.filter((e,n)=>n!==t)}}function B7e(e){let t=e.trim().replaceAll(`,`,``);if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:void 0}function V7e(e,t,n,r){let i;if(n===e.x)i=r;else{let t=B7e(r);if(t===void 0)return e;i=t}return{...e,data:e.data.map((e,r)=>r===t?{...e,[n]:i}:e)}}var H7e=e=>e==null?``:String(e);function U7e({draft:e,onChange:t}){let n=e.x??``,r=[n,...e.series.map(e=>e.key)];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:T7e,children:(0,K.jsxs)(`table`,{className:E7e,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[r.map(n=>(0,K.jsx)(`th`,{scope:`col`,children:(0,K.jsx)(o9,{plain:!0,"aria-label":`Rename ${n}`,className:`${a9} ${O7e}`,value:n,onCommit:r=>t(F7e(e,n,r))})},n)),(0,K.jsx)(`th`,{"aria-label":`Row actions`,scope:`col`})]})}),(0,K.jsx)(`tbody`,{children:e.data.map((i,a)=>(0,K.jsxs)(`tr`,{children:[r.map(r=>(0,K.jsx)(`td`,{children:(0,K.jsx)(o9,{plain:!0,"aria-label":`Row ${a+1} ${r}`,className:r===n?a9:`${a9} ${D7e}`,inputMode:r===n?void 0:`decimal`,value:H7e(i[r]),onCommit:n=>t(V7e(e,a,r,n))})},r)),(0,K.jsx)(`td`,{children:(0,K.jsx)(Fe,{icon:!0,"aria-label":`Remove row ${a+1}`,size:`sm`,onClick:()=>t(z7e(e,a)),children:(0,K.jsx)(k,{})})})]},a))})]})}),(0,K.jsxs)(`div`,{className:w7e,children:[(0,K.jsxs)(Fe,{size:`md`,variant:`outline`,onClick:()=>t(R7e(e)),children:[(0,K.jsx)(zr,{}),`Add row`]}),(0,K.jsxs)(Fe,{disabled:e.series.length>=6,size:`md`,variant:`outline`,onClick:()=>t(I7e(e)),children:[(0,K.jsx)(zr,{}),`Add series`]})]})]})}var W7e=[{value:`bar`,label:`Bar`},{value:`line`,label:`Line`},{value:`area`,label:`Area`},{value:`pie`,label:`Pie`}];function G7e({draft:e,onChange:t}){let n=(0,G.useId)(),r=new Set(e.series.map(e=>e.key)),i=N7e(e).filter(t=>t===e.x||!r.has(t)),a=e.x&&!i.includes(e.x)?[e.x,...i]:i;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:h7e,children:[(0,K.jsx)(`span`,{className:g7e,id:`${n}-type`,children:`Type`}),(0,K.jsx)(`div`,{"aria-labelledby":`${n}-type`,role:`group`,children:(0,K.jsx)(xt,{fullWidth:!0,items:W7e,value:e.type??`bar`,onChange:n=>t(c9(e,{type:n}))})})]}),(0,K.jsx)(Kn,{id:`${n}-title`,label:`Title`,children:(0,K.jsx)(o9,{id:`${n}-title`,value:e.title??``,onCommit:n=>t(c9(e,{title:n}))})}),(0,K.jsx)(Kn,{id:`${n}-x`,label:`Category field (x)`,children:(0,K.jsxs)(oe,{disabled:a.length===0,value:e.x??null,onValueChange:n=>{typeof n==`string`&&t(c9(e,{x:n}))},children:[(0,K.jsx)(ge,{className:_7e,id:`${n}-x`,children:(0,K.jsx)(de,{placeholder:`No data`})}),(0,K.jsx)(wte,{children:a.map(e=>(0,K.jsx)(vee,{value:e,children:e},e))})]})}),(0,K.jsxs)(`div`,{className:h7e,children:[(0,K.jsx)(`span`,{className:g7e,children:`Series`}),e.series.map((n,r)=>(0,K.jsx)(K7e,{draft:e,index:r,series:n,onChange:t},r)),(0,K.jsxs)(Fe,{disabled:e.series.length>=6,size:`md`,variant:`outline`,onClick:()=>t(I7e(e)),children:[(0,K.jsx)(zr,{}),`Add series`]})]})]})}function K7e({draft:e,index:t,series:n,onChange:r}){let[i,a]=(0,G.useState)(!1),o=t+1,s=n.color??o,c=n=>{r({...e,series:e.series.map((e,r)=>r===t?{...e,...n}:e)})};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:x7e,children:[(0,K.jsx)(`button`,{"aria-expanded":i,"aria-label":`Series ${o} color`,className:S7e,type:`button`,onClick:()=>a(!i),children:(0,K.jsx)(`span`,{className:C7e,style:{background:bH[(s-1+6)%6]}})}),(0,K.jsx)(o9,{mono:!0,"aria-label":`Series ${o} key`,className:v7e,value:n.key,onCommit:t=>r(F7e(e,n.key,t))}),(0,K.jsx)(o9,{"aria-label":`Series ${o} label`,className:y7e,placeholder:n.key,value:n.label??``,onCommit:e=>c({label:e||void 0})}),(0,K.jsx)(Fe,{icon:!0,"aria-label":`Remove series ${o}`,disabled:e.series.length<=1,size:`md`,onClick:()=>r(L7e(e,n.key)),children:(0,K.jsx)(k,{})})]}),i&&(0,K.jsx)(`div`,{className:`tzkflre`,children:bH.map((e,t)=>(0,K.jsx)(`button`,{"aria-label":`Color ${t+1}`,"aria-pressed":s===t+1,className:`tzkflrf`,type:`button`,onClick:()=>{c({color:t+1}),a(!1)},children:(0,K.jsx)(`span`,{className:`tzkflrd`,style:{background:e}})},e))})]})}var q7e=[{key:`subtitle`,label:`Subtitle`},{key:`source`,label:`Source`},{key:`xLabel`,label:`X axis label`},{key:`note`,label:`Note`}],J7e=10,Y7e=e=>Number.isInteger(e)&&e>=0&&e<=J7e,l9=e=>typeof e==`number`?String(e):``;function X7e(e,t){let n=e[t];return typeof n==`object`&&n?n:{}}function Z7e({draft:e,onChange:t}){let n=(0,G.useId)(),r=X7e(e,`y`),i=X7e(e,`format`),a=(e.type===`bar`||e.type===`area`)&&e.series.length>1,o=(n,r,i,a=Number.isFinite)=>{let o=B7e(i);o===void 0||o!==null&&!a(o)||t(M7e(e,n,{[r]:o??void 0}))};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:b7e,children:q7e.map(({key:r,label:i})=>(0,K.jsx)(Kn,{id:`${n}-${r}`,label:i,children:(0,K.jsx)(o9,{id:`${n}-${r}`,placeholder:`Optional`,value:typeof e[r]==`string`?e[r]:``,onCommit:n=>t(c9(e,{[r]:n}))})},r))}),e.type!==`pie`&&(0,K.jsxs)(`div`,{className:`tzkflra`,children:[(0,K.jsx)(Kn,{id:`${n}-ymin`,label:`Y min`,children:(0,K.jsx)(o9,{id:`${n}-ymin`,inputMode:`decimal`,placeholder:`Auto`,value:l9(r.min),onCommit:e=>o(`y`,`min`,e)})}),(0,K.jsx)(Kn,{id:`${n}-ymax`,label:`Y max`,children:(0,K.jsx)(o9,{id:`${n}-ymax`,inputMode:`decimal`,placeholder:`Auto`,value:l9(r.max),onCommit:e=>o(`y`,`max`,e)})})]}),(0,K.jsxs)(`div`,{className:b7e,children:[(0,K.jsx)(Kn,{id:`${n}-unit`,label:`Unit`,children:(0,K.jsx)(o9,{id:`${n}-unit`,placeholder:`e.g. %`,value:typeof i.unit==`string`?i.unit:``,onCommit:n=>t(M7e(e,`format`,{unit:n}))})}),(0,K.jsx)(Kn,{id:`${n}-decimals`,label:`Decimals`,children:(0,K.jsx)(o9,{id:`${n}-decimals`,inputMode:`numeric`,placeholder:`Auto`,value:l9(i.decimals),onCommit:e=>o(`format`,`decimals`,e,Y7e)})})]}),a&&(0,K.jsx)(Xe,{checked:e.stacked===!0,label:`Stacked`,onChange:n=>t(c9(e,{stacked:n||void 0}))}),e.type===`pie`&&(0,K.jsx)(Xe,{checked:e.donut===!0,label:`Donut`,onChange:n=>t(c9(e,{donut:n||void 0}))})]})}var Q7e=[{value:`setup`,label:`Setup`},{value:`data`,label:`Data`},{value:`style`,label:`Style`}];function $7e({spec:e,onChange:t}){let[n,r]=(0,G.useState)(`setup`),i=(0,G.useMemo)(()=>A7e(e),[e]);return i?(0,K.jsxs)(`div`,{className:d7e,children:[(0,K.jsx)(`div`,{className:f7e,children:(0,K.jsx)(xt,{fullWidth:!0,items:Q7e,value:n,onChange:r})}),(0,K.jsx)(`div`,{className:p7e,children:(0,K.jsx)(n===`setup`?G7e:n===`data`?U7e:Z7e,{draft:i,onChange:e=>t(j7e(e))})})]}):(0,K.jsx)(`div`,{className:d7e,children:(0,K.jsx)(`p`,{className:m7e,children:`Chart spec is not valid JSON, so it can't be edited here. Check it under Raw data.`})})}var e9e=`_1vsdskt0`,t9e=`_1vsdskt1`;function n9e(e){return wt()?(0,K.jsx)(a9e,{...e}):(0,K.jsx)(Kj,{defaultRenderer:XH,props:{spec:e.spec},rendererKey:ZH})}function r9e(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}var i9e=e=>e.stopPropagation();function a9e({spec:e,nodeKey:t}){let[n]=ht(),[r,i,a]=vF(t),[o,s]=(0,G.useState)(`chart`),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),f=(0,G.useMemo)(()=>GH(e).ok,[e]),p=(0,G.useMemo)(()=>r9e(e),[e]),m=(0,G.useCallback)(e=>{e.shiftKey||a(),i(!0)},[a,i]),h=(0,G.useCallback)(()=>{navigator.clipboard&&navigator.clipboard.writeText(e).then(()=>Pe({title:`Chart spec copied`,tone:`success`}),()=>Pe({title:`Could not copy chart spec`,tone:`error`}))},[e]),g=(0,G.useCallback)(e=>{n.update(()=>{let n=Dn(t);GLe(n)&&n.setSpec(e)})},[n,t]),_=r||c||u;return(0,K.jsxs)(`div`,{className:`${e9e}${r?` ${t9e}`:``}`,onClick:m,children:[(0,K.jsx)(YH,{hideToggle:!0,defaultView:o,value:e},o),_&&(0,K.jsxs)(`div`,{"aria-label":`Chart`,className:`_1vsdskt2`,role:`toolbar`,onClick:i9e,children:[(0,K.jsxs)(gn,{open:u,onOpenChange:d,children:[(0,K.jsxs)(en,{render:(0,K.jsx)(Fe,{size:`md`}),children:[(0,K.jsx)(dne,{}),`Edit chart`]}),(0,K.jsxs)(yn,{flush:!0,align:`end`,className:`tzkflr0`,side:`bottom`,size:`lg`,children:[(0,K.jsx)(wn,{icon:(0,K.jsx)(Ar,{}),title:`Chart`}),(0,K.jsx)($7e,{spec:e,onChange:g})]})]}),f&&(0,K.jsxs)(Fe,{"aria-pressed":o===`table`,size:`md`,onClick:()=>s(o===`table`?`chart`:`table`),children:[o===`table`?(0,K.jsx)(Ar,{}):(0,K.jsx)(Qte,{}),o===`table`?`View chart`:`View data`]}),(0,K.jsxs)(gn,{open:c,onOpenChange:l,children:[(0,K.jsxs)(en,{render:(0,K.jsx)(Fe,{size:`md`}),children:[(0,K.jsx)(Pr,{}),`Raw data`]}),(0,K.jsxs)(yn,{flush:!0,align:`end`,className:`_1vsdskt3`,side:`bottom`,size:`lg`,children:[(0,K.jsx)(wn,{icon:(0,K.jsx)(Pr,{}),title:`Chart spec`,actions:(0,K.jsxs)(Fe,{size:`md`,onClick:h,children:[(0,K.jsx)(Ir,{}),`Copy`]})}),(0,K.jsx)(`pre`,{className:`_1vsdskt4`,children:p||(0,K.jsx)(`span`,{className:`_1vsdskt5`,children:`(empty)`})})]})]})]})]})}var o9e=JSON.stringify({version:1,type:`bar`,title:`Monthly visits`,x:`month`,series:[{key:`visits`,label:`Visits`}],data:[{month:`Jan`,visits:120},{month:`Feb`,visits:160},{month:`Mar`,visits:140},{month:`Apr`,visits:200}]}),u9=class e extends tU{static clone(t){return new e(t.__spec,t.__key)}constructor(e=``,t){super(e,t)}static importJSON(t){return new e(eU(t.spec)).updateFromJSON(t)}decorate(e,t){return(0,G.createElement)(n9e,{spec:this.__spec,nodeKey:this.__key})}};$H(u9,`commandItems`,[{title:`Chart`,icon:(0,G.createElement)(ii,{size:20}),description:`Bar, line, area or pie chart`,keywords:[`chart`,`graph`,`bar`,`line`,`pie`,`data`],section:`ADVANCED`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([s9e(o9e)])})}}]);function s9e(e=``){return new u9(e)}var c9e=(0,G.lazy)(()=>Promise.resolve().then(()=>b9e).then(e=>({default:e.WhiteboardEditRenderer}))),d9=class e extends BU{static clone(t){return new e(t.__snapshot,t.__key)}constructor(e,t){super(e,t)}static importJSON(t){return new e(t.snapshot).updateFromJSON(t)}decorate(e,t){let n=this.__key,r=(0,G.createElement)(`div`,{className:`rich-excalidraw-loading`,style:{position:`relative`,width:`100%`,aspectRatio:`16 / 10`,margin:`1rem 0`}}),i=(0,G.createElement)(at,{fallback:r,children:(0,G.createElement)(G.Suspense,{fallback:r},(0,G.createElement)(c9e,{snapshot:EU(this.__snapshot),onSnapshotChange:t=>{e.update(()=>{let e=Dn(n);e&&e.setSnapshot(SRe(t))})}}))});return(0,G.createElement)(Pee,{editor:e,editable:i,readOnly:super.decorate(e,t)})}};Cr(d9,`commandItems`,[{title:`Whiteboard`,icon:(0,G.createElement)(jr,{size:20}),description:`Whiteboard canvas`,keywords:[`excalidraw`,`whiteboard`,`draw`,`canvas`],nested:!1,section:`MEDIA`,placement:[`slash`,`toolbar`],group:`insert`,onSelect:e=>{e.update(()=>{Un([l9e(`{}`)])})}}]);function l9e(e){return new d9(e)}var u9e=`[data-whiteboard-editor]`;function d9e(e){return e instanceof Element&&!!e.closest(u9e)}function f9e(e){let t=e.getState();return!!(t.editingTextId||t.editingRichTextId||t.editingFrameId||e.isTransient()||t.tool!==`selection`&&!t.toolLocked)}function p9e(e,t){let n=e.getState();n.editingTextId?hte(e):n.editingRichTextId?e.setState({editingRichTextId:null}):n.editingFrameId?e.setState({editingFrameId:null}):t?.dispatchEvent(new KeyboardEvent(`keydown`,{key:`Escape`,bubbles:!0,cancelable:!0}))}var m9e=[{value:`inline`,label:`Inline`},{value:`remote`,label:`Remote`},{value:`delta`,label:`Delta`}],h9e=({onCopy:e,onExport:t,onOpenChange:n,open:r,storage:i})=>{let a=(0,G.useId)(),o=`${a}-storage`,s=`${a}-ref`;return(0,K.jsxs)(gn,{open:r,onOpenChange:n,children:[(0,K.jsx)(en,{render:(0,K.jsx)(Fe,{icon:!0,"aria-label":`More options`,size:`md`,title:`More options`,children:(0,K.jsx)(Nr,{})})}),(0,K.jsxs)(yn,{flush:!0,align:`end`,side:`bottom`,size:`md`,children:[(0,K.jsx)(Xn,{children:(0,K.jsxs)(`div`,{className:vRe,children:[(0,K.jsxs)(Fe,{size:`md`,variant:`outline`,onClick:e,children:[(0,K.jsx)(Nne,{}),`Copy JSON`]}),(0,K.jsxs)(Fe,{size:`md`,variant:`outline`,onClick:t,children:[(0,K.jsx)(f,{}),`Export JSON`]})]})}),i&&(0,K.jsxs)(Xn,{className:`_1xd3mo4m`,children:[(0,K.jsx)(`span`,{className:`_1xd3mo4n`,children:`Advanced`}),(0,K.jsxs)(`div`,{"aria-labelledby":o,className:`_1xd3mo4o`,role:`group`,children:[(0,K.jsx)(`span`,{className:`_1xd3mo4p`,id:o,children:`Storage`}),(0,K.jsx)(xt,{fullWidth:!0,items:m9e,value:i.mode,onChange:i.onModeChange})]}),i.mode!==`inline`&&(0,K.jsx)(Kn,{id:s,label:`Base URL or ref`,children:(0,K.jsx)(ct,{mono:!0,id:s,placeholder:`https://… or ref:file/…`,spellCheck:!1,value:i.refValue,onChange:e=>i.onRefChange(e.target.value)})})]})]})]})},g9e=()=>Pe({title:`Couldn’t upload the image; it is kept inside the whiteboard`,tone:`error`});function _9e(e,t){return!e||!t?`inline`:t.type===`delta`?`delta`:t.type===`remote`?`remote`:`inline`}function v9e(e,t){return!e||!t?``:t.type===`remote`?t.url:t.type===`delta`?t.baseUrl:``}var y9e=({baseData:e,baseRef:t,dismiss:n,holdEscapeDismiss:i,initialData:a,initialSnapshot:o,isConfirming:s,onClose:c,onDirtyChange:l,onSave:u,onUploadError:d=g9e,requestDismiss:f,saveSnapshot:p,theme:m,uploadFile:h})=>{let[g]=(0,G.useState)(()=>ate(a)),_=(0,G.useRef)(null),v=(0,G.useRef)(t),y=(0,G.useRef)(e),b=Ree(g),[x,S]=(0,G.useState)(!1),[C,w]=(0,G.useState)(!1),[T,E]=(0,G.useState)(!1),D=!T&&(x||C),[O,k]=(0,G.useState)(!1),[A,j]=(0,G.useState)(!1),[M,N]=(0,G.useState)(()=>_9e(p,o)),[P,F]=(0,G.useState)(()=>v9e(p,o));(0,G.useEffect)(()=>{l(D)},[D,l]),(0,G.useEffect)(()=>g.subscribe(()=>S(g.isDirty())),[g]);let I=(0,G.useCallback)(()=>{queueMicrotask(()=>_.current?.querySelector(`[data-whiteboard-canvas]`)?.focus({preventScroll:!0}))},[]),L=(0,G.useCallback)(()=>g.getScene(),[g]),R=(0,G.useCallback)(async e=>{if(!p||M===`inline`||M===`delta`&&v.current&&y.current||M===`remote`&&v.current&&y.current&&JSON.stringify(e)===JSON.stringify(y.current))return;let t=await p(e,v.current||void 0);v.current=t,y.current=e,F(t)},[p,M]),z=(0,G.useCallback)(async e=>{if(M===`inline`||!p)return{type:`inline`,data:e};let t=v.current;if(t){if(M===`delta`&&y.current){let{diff:n}=await r(async()=>{let{diff:e}=await import(`./lib-DJrc3aG3.js`);return{diff:e}},[],import.meta.url),i=n(y.current,structuredClone(e));return i?{type:`delta`,baseUrl:t,delta:i}:{type:`remote`,url:t}}return{type:`remote`,url:t}}},[p,M]),B=Vee(g,e=>e.elements.some(e=>e.type===`image`&&!e.isDeleted&&e.status===`pending`)),V=(0,G.useCallback)(async()=>{if(O||B)return;let e=L();if(e){k(!0);try{await R(e);let t=await z(e);if(!t)return;u(t),c(e),E(!0),n()}catch{Pe({title:`Couldn’t save the whiteboard`,tone:`error`})}finally{k(!1)}}},[O,B,L,R,z,u,c,n]),H=(0,G.useRef)(A);H.current=A,(0,G.useEffect)(()=>{let e=e=>{if(!(e.key!==`Escape`||H.current)){if(!s()&&f9e(g)){if(i?.(),d9e(e.target))return;e.preventDefault(),e.stopImmediatePropagation(),p9e(g,_.current?.querySelector(`[data-whiteboard-canvas]`)??null)}else e.preventDefault(),e.stopImmediatePropagation(),s()?mee():f()}};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[i,s,f,g]);let U=(0,G.useCallback)(()=>{let e=L(),t=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`excalidraw-snapshot.json`,r.click(),URL.revokeObjectURL(n)},[L]),ee=(0,G.useCallback)(()=>{let e=L();navigator.clipboard.writeText(JSON.stringify(e)).then(()=>Pe({title:`Copied`,tone:`success`}),()=>Pe({title:`Couldn’t copy`,tone:`error`}))},[L]),te=(0,G.useCallback)(e=>{F(e),v.current=e,y.current=void 0,w(!0)},[]),ne=(0,G.useCallback)(e=>{N(e),e===`inline`&&F(``),w(!0)},[]);return(0,K.jsxs)(Lee,{className:_Re,onSave:V,children:[(0,K.jsx)(Bee,{center:b?void 0:(0,K.jsx)(fte,{store:g,onToolSelect:I}),icon:(0,K.jsx)(Fr,{}),title:`Whiteboard`,actions:(0,K.jsx)(h9e,{open:A,storage:p?{mode:M,onModeChange:ne,onRefChange:te,refValue:P}:void 0,onCopy:ee,onExport:U,onOpenChange:j}),onClose:f}),(0,K.jsx)(ete,{className:hRe,children:(0,K.jsx)(`div`,{className:gRe,ref:_,children:(0,K.jsx)(nte,{store:g,theme:m,toolbar:`none`,uploadFile:h,onUploadError:d})})}),(0,K.jsx)(xte,{dirty:D,saveDisabled:O||B,status:(0,K.jsxs)(K.Fragment,{children:[!D&&!O&&(0,K.jsx)(`span`,{"aria-hidden":!0,className:`_1xd3mo4k`}),O?`Saving…`:B?`Uploading image…`:D?`Unsaved changes`:`Saved`]}),onCancel:f,onSave:V})]})},b9e=CU({WhiteboardEditRenderer:()=>x9e}),x9e=({snapshot:e,onSnapshotChange:t})=>{let n=lF(),{saveSnapshot:r,uploadFile:i}=OU(),{snapshot:a,loading:o,error:s,retry:c,retryable:l,baseRef:u,baseData:d}=NU(e),[f,p]=(0,G.useState)(),m=(0,G.useRef)(t);m.current=t;let h=(0,G.useRef)(r);h.current=r;let g=(0,G.useRef)(i);g.current=i;let _=(0,G.useRef)(e);_.current=e;let{className:v}=We();PU();let y=f??a,b=(0,G.useRef)(y);b.current=y;let x=(0,G.useMemo)(()=>kU(y),[y]),S=(0,G.useRef)(u),C=(0,G.useRef)(d);(0,G.useEffect)(()=>{u&&(S.current=u)},[u]),(0,G.useEffect)(()=>{d&&(C.current=d)},[d]);let w=(0,G.useCallback)(()=>{if(o)return;let e={dirty:!1,confirming:!1,escapeHeld:!1},t=()=>{e.escapeHeld=!0,setTimeout(()=>{e.escapeHeld=!1},0)};At({content:({dismiss:r,requestDismiss:i})=>(0,K.jsx)(y9e,{baseData:C.current,baseRef:S.current,dismiss:r,holdEscapeDismiss:t,initialData:b.current,initialSnapshot:_.current,isConfirming:()=>e.confirming,requestDismiss:i,saveSnapshot:h.current,theme:n,uploadFile:g.current,onSave:e=>m.current(e),onClose:e=>{e&&p(e)},onDirtyChange:t=>{e.dirty=t}}),className:mRe,portalClassName:v,theme:n,showCloseButton:!1,clickOutsideToDismiss:!1,confirmDismiss:async()=>{if(e.escapeHeld)return!1;if(!e.dirty)return!0;if(e.confirming)return!1;e.confirming=!0;try{return await Se()}finally{e.confirming=!1}}})},[o,n,v]);return o?(0,K.jsx)(`div`,{className:wU,children:(0,K.jsx)(FU,{})}):s?(0,K.jsx)(`div`,{className:wU,children:(0,K.jsx)(LU,{message:s,onRetry:l?c:void 0})}):(0,K.jsxs)(`div`,{className:wU,children:[x&&AU(x)>0?(0,K.jsx)(Oee,{scene:x,theme:n}):(0,K.jsx)(IU,{}),(0,K.jsx)(`button`,{"aria-label":`Edit whiteboard`,className:yRe,type:`button`,onClick:w,children:(0,K.jsxs)(`span`,{className:bRe,children:[(0,K.jsx)(Ae,{size:14}),`Edit`]})})]})},S9e=Rn(`INSERT_WHITEBOARD`);function C9e(){let[e]=ht();return(0,G.useEffect)(()=>e.registerCommand(S9e,e=>{let t=l9e(e);return Un([t]),!0},0),[e]),null}var f9=[{id:`basic`,label:`Basic blocks`},{id:`lists`,label:`Lists`},{id:`media`,label:`Media`},{id:`rich`,label:`Rich blocks`},{id:`layout`,label:`Layout`},{id:`embed`,label:`Embed`},{id:`inline`,label:`Inline`}],p9=[{id:`paragraph`,title:`Text`,icon:S,group:`basic`,description:`Plain text block`},{id:`h1`,title:`Heading 1`,icon:Fne,group:`basic`,description:`Large section heading`},{id:`h2`,title:`Heading 2`,icon:Ine,group:`basic`,description:`Medium section heading`},{id:`h3`,title:`Heading 3`,icon:Lne,group:`basic`,description:`Small section heading`},{id:`quote`,title:`Quote`,icon:Yne,group:`basic`,description:`Capture a quote`},{id:`callout`,title:`Callout`,icon:m,group:`basic`},{id:`tip`,title:`Tip`,icon:gi,group:`basic`},{id:`warning`,title:`Warning`,icon:x,group:`basic`},{id:`divider`,title:`Divider`,icon:T,group:`basic`,description:`Visual separator`},{id:`bullet`,title:`Bulleted list`,icon:Wte,group:`lists`,aliases:[`bullet list`],description:`Unordered list`},{id:`number`,title:`Numbered list`,icon:bee,group:`lists`,aliases:[`numbered`],description:`Ordered list with numbers`},{id:`check`,title:`To-do list`,icon:Rne,group:`lists`,aliases:[`to-do`,`todo`,`checklist`],description:`Track tasks with checkboxes`},{id:`image`,title:`Image`,icon:d,group:`media`},{id:`video`,title:`Video`,icon:tne,group:`media`},{id:`file`,title:`File`,icon:Ei,group:`media`},{id:`gallery`,title:`Gallery`,icon:Rte,group:`media`},{id:`whiteboard`,title:`Whiteboard`,icon:jr,group:`media`},{id:`code`,title:`Code block`,icon:Pr,group:`rich`,description:`Syntax-highlighted code`},{id:`math`,title:`Math block`,icon:Mi,group:`rich`,aliases:[`math equation`]},{id:`mermaid`,title:`Mermaid diagram`,icon:Wi,group:`rich`},{id:`code-snippet`,title:`Code snippet`,icon:Zte,group:`rich`},{id:`chart`,title:`Chart`,icon:ii,group:`rich`},{id:`poll`,title:`Poll`,icon:Zne,group:`rich`},{id:`chat`,title:`Chat`,icon:Rr,group:`rich`},{id:`dynamic`,title:`Dynamic component`,icon:jne,group:`rich`},{id:`nested-doc`,title:`Nested document`,icon:h,group:`rich`},{id:`banner`,title:`Banner`,icon:ci,group:`rich`},{id:`details`,title:`Details`,icon:Ite,group:`rich`},{id:`table`,title:`Table`,icon:Jne,group:`layout`,description:`Add a table`},{id:`grid`,title:`Grid`,icon:Lr,group:`layout`},{id:`steps`,title:`Steps`,icon:Pne,group:`layout`},{id:`embed`,title:`Embed`,icon:One,group:`embed`},{id:`link-card`,title:`Link card`,icon:v,group:`embed`},{id:`mention`,title:`Mention`,icon:Ane,group:`inline`},{id:`tag`,title:`Tag`,icon:Li,group:`inline`},{id:`comment`,title:`HTML comment`,icon:Bne,group:`inline`}],w9e=[`paragraph`,`h1`,`h2`,`h3`,`bullet`,`number`,`check`,`quote`,`code`],T9e={"basic blocks":`basic`,basic:`basic`,lists:`lists`,list:`lists`,media:`media`,advanced:`rich`,"rich blocks":`rich`,layout:`layout`,embed:`embed`,inline:`inline`},m9=e=>e.trim().toLowerCase(),E9e=new Map;for(let e of p9)for(let t of[e.id,e.title,...e.aliases??[]])E9e.set(m9(t),e);var h9=new Map(f9.map(e=>[e.id,e]));function g9(e){return E9e.get(m9(e))}function D9e(e){if(!e)return f9[0].label;let t=m9(e),n=T9e[t]??(h9.has(t)?t:null);return n?h9.get(n).label:e===e.toUpperCase()?e.charAt(0)+e.slice(1).toLowerCase():e}function O9e(e){let t=f9.findIndex(t=>t.label===e);return t===-1?f9.length:t}function _9(e,t={}){let n=t.iconSize??20,r=new Set,i=[];return e.forEach((e,t)=>{let a=g9(e.title),o=a?.title??e.title;if(r.has(o))return;r.add(o);let s=a?h9.get(a.group).label:D9e(e.section);i.push({item:{...e,title:o,section:s,description:e.description??a?.description,icon:a?(0,G.createElement)(a.icon,{size:n}):e.icon},rank:O9e(s),order:a?p9.indexOf(a):p9.length,position:t})}),i.sort((e,t)=>e.rank-t.rank||e.order-t.order||e.position-t.position).map(e=>e.item)}var k9e=w9e.map(e=>g9(e));function A9e({currentType:e,onDelete:t,onDuplicate:n,onMoveDown:r,onMoveUp:i,onTurnInto:a}){let o=e?g9(e):void 0,s=(o??k9e[0]).icon;return(0,K.jsxs)(Rt,{align:`start`,side:`bottom`,sideOffset:4,children:[e!==null&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(ite,{children:[(0,K.jsxs)(mte,{value:o?.title,children:[(0,K.jsx)(s,{}),`Turn into`]}),(0,K.jsx)(Rt,{align:`start`,side:`right`,sideOffset:4,children:(0,K.jsx)(M,{value:o?.id??null,children:k9e.map(e=>(0,K.jsxs)(pn,{closeOnClick:!0,value:e.id,onClick:()=>a(e.id),children:[(0,K.jsx)(e.icon,{}),e.title]},e.id))})})]}),(0,K.jsx)(ur,{})]}),(0,K.jsxs)(Ut,{shortcut:`Mod+D`,onClick:n,children:[(0,K.jsx)(Ir,{}),`Duplicate`]}),(0,K.jsxs)(Ut,{shortcut:`Mod+Shift+Up`,onClick:i,children:[(0,K.jsx)(Nte,{}),`Move up`]}),(0,K.jsxs)(Ut,{shortcut:`Mod+Shift+Down`,onClick:r,children:[(0,K.jsx)(Mte,{}),`Move down`]}),(0,K.jsx)(ur,{}),(0,K.jsxs)(Ut,{shortcut:`Backspace`,variant:`destructive`,onClick:t,children:[(0,K.jsx)(Mr,{}),`Delete`]})]})}function j9e(e){return e.getTopLevelElement()?.getKey()??null}function M9e(){let e=kr();if(!Jn(e))return[];let t=new Set;for(let n of[e.anchor.getNode(),e.focus.getNode(),...e.getNodes()]){let e=j9e(n);e&&t.add(e)}return Sr().getChildren().map(e=>e.getKey()).filter(e=>t.has(e))}function v9(e,t){let n=new Set(e),r=Sr().getChildren().filter(e=>n.has(e.getKey()));if(r.length===0)return!1;let i=r[0],a=r.at(-1);if(t===`up`){let e=i.getPreviousSibling();return!e||n.has(e.getKey())?!1:(e.remove(),a.insertAfter(e),!0)}let o=a.getNextSibling();return!o||n.has(o.getKey())?!1:(o.remove(),i.insertBefore(o),!0)}function N9e(e){let t=e.constructor.importJSON(e.exportJSON());if(rr(e)&&rr(t))for(let n of e.getChildren())t.append(N9e(n));return t}function P9e(e){let t=new Set(e),n=Sr().getChildren().filter(e=>t.has(e.getKey()));if(n.length===0)return!1;let r=n.at(-1);for(let e of n){let t=N9e(e);r.insertAfter(t),r=t}return!0}function F9e(e,t,n){let r=new Set(e);if(r.has(t))return!1;let i=Sr().getChildren(),a=i.find(e=>e.getKey()===t),o=i.filter(e=>r.has(e.getKey()));if(!a||!o.length)return!1;for(let e of o)e.remove();if(n){for(let e of o)a.insertBefore(e);return!0}let s=a;for(let e of o)s.insertAfter(e),s=e;return!0}function I9e(e,t,n,r){if(!t){e.update(()=>{v9(n,r)});return}let i=t.documentKeys(e,n);i.length&&t.editor.update(()=>{v9(i,r)})}var L9e={bullet:mt,number:I,check:dn},R9e={paragraph:()=>on(),h1:()=>ae(`h1`),h2:()=>ae(`h2`),h3:()=>ae(`h3`),quote:()=>xr()};function z9e(e){if(!e)return null;if(yr(e))return`paragraph`;if(_r(e)){let t=e.getTag();return t===`h1`||t===`h2`||t===`h3`?t:null}if(Er(e))return`quote`;if(nr(e)){let t=e.getListType();return t===`bullet`||t===`number`||t===`check`?t:null}return e.getType()===`code`?`code`:null}function B9e(e){return e._nodes.get(`code-block`)?.klass??null}function V9e(e,t,n){let r=L9e[n];r?(e.update(()=>{let e=Dn(t);rr(e)&&e.selectStart()}),e.dispatchCommand(r,void 0)):e.update(()=>{let r=Dn(t);if(!rr(r))return;if(n===`code`){let t=B9e(e);if(t){r.replace(new t(r.getTextContent(),`text`));return}}r.selectStart();let i=kr();if(!Jn(i))return;let a=n===`code`?()=>TP():R9e[n];a&&ee(i,a)})}var y9=12;function H9e(e,t){if(e.length===0)return null;let n=e[0],r=e.at(-1);if(t<n.top)return t>=n.top-y9?{index:0,y:n.top-y9/2}:null;if(t>r.bottom)return t<=r.bottom+y9?{index:e.length,y:r.bottom+y9/2}:null;for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];if(t>r.bottom&&t<i.top)return{index:n,y:(r.bottom+i.top)/2}}return null}function U9e(e,t){return e.top+e.paddingTop+(e.lineHeight-t)/2}function W9e(e,t){let n=Number.parseFloat(e);return e.endsWith(`px`)&&Number.isFinite(n)?n:Number.parseFloat(t)*1.2}var G9e=`iihqkc0`,K9e=`iihqkc1`,q9e=`iihqkc2`,b9=`iihqkc5`,J9e=`iihqkc6`,x9=`iihqkc8`,Y9e=`iihqkc9`,X9e={ArrowUp:`up`,ArrowDown:`down`};function Z9e(e,t,n,r){return(i,a)=>{if(a!==e||i.altKey||(n?!i.metaKey||i.ctrlKey:!i.ctrlKey||i.metaKey))return!1;let o=X9e[i.key],s=!i.shiftKey&&i.key.toLowerCase()===`d`;if(!s&&(!o||!i.shiftKey))return!1;let c=t(),l=c.length>0?c:M9e();return l.length!==0&&(i.preventDefault(),s?P9e(l):r?I9e(e,r,l,o):v9(l,o),!0)}}function Q9e(e,t){let n=$k()?.documentBlocks;(0,G.useEffect)(()=>{let r=ree(typeof navigator>`u`?void 0:navigator)===`mac`;return e.registerCommand(br,Z9e(e,t,r,n),4)},[n,e,t])}var $9e=[`application/x-lexical-editor`,`text/html`,`text/plain`,`text/uri-list`];function eet(e){let t=e.exportJSON();return rr(e)&&(t.children=e.getChildren().map(eet)),t}function tet(e,t,n){let r=t.map(t=>e.getElementByKey(t.getKey())?.outerHTML??``).filter(Boolean).join(`
|
|
392
392
|
`);if(r||t.length===0)return r;if(t.length===Sr().getChildrenSize())return st(e,null);let i=e,a=qn({html:i._config.html,namespace:i._config.namespace,nodes:[...i._nodes.values()].map(({klass:e})=>e),onError:e=>{throw e},theme:i._config.theme});return a.update(()=>Sr().append(...n.map(Ne)),{discrete:!0}),a.getEditorState().read(()=>st(a,null))}function S9(e,t){for(let[n,r]of Object.entries(t))e.setData(n,r)}function net(e){return{files:{length:0},get types(){return Object.keys(e)},getData(t){return e[t]??``},setData(t,n){e[t]=n}}}async function ret(){let e=globalThis.navigator?.clipboard;if(!e)return null;let t={};if(typeof e.read==`function`)try{let n=await e.read();for(let e of n)for(let n of $9e)e.types.includes(n)&&(t[n]=await(await e.getType(n)).text())}catch{}if(!t[`text/plain`]&&typeof e.readText==`function`)try{let n=await e.readText();n&&(t[`text/plain`]=n)}catch{}let n=net(t);return T9(n)?n:null}function iet(e,t){let n=e.getRootElement()?.ownerDocument??globalThis.document;if(!n?.execCommand)return!1;let r=!1,i=e=>{e.clipboardData&&(e.preventDefault(),e.stopImmediatePropagation(),S9(e.clipboardData,t),r=!0)};n.addEventListener(`copy`,i,!0);try{return n.execCommand(`copy`)&&r}finally{n.removeEventListener(`copy`,i,!0)}}function C9(e,t){if(rr(e)){t===`end`?e.selectEnd():e.selectStart();return}let n=sr();n.add(e.getKey()),Jt(n)}function w9(e,t){let n=e._config.namespace,r=t.map(eet),i=tet(e,t,r);return{"application/x-lexical-editor":JSON.stringify({namespace:n,nodes:r}),"text/html":i,"text/plain":t.map(e=>e.getTextContent()).join(`
|
|
393
393
|
|
|
394
394
|
`)}}function aet(e){if(e.length===0)return;let t=e[0],n=e.at(-1),r=t.getPreviousSibling(),i=n.getNextSibling();for(let t of e)t.remove();let a=Sr();if(a.getChildrenSize()===0){let e=on();a.append(e),e.selectStart();return}if(i){C9(i,`start`);return}if(r){C9(r,`end`);return}let o=a.getFirstChild();o&&C9(o,`start`)}function oet(e){if(e.length===0)return;let t=on();e[0].insertBefore(t);for(let t of e)t.remove();t.selectStart()}function set(e){if(!e||typeof e!=`object`)return null;let t=e;return t.clipboardData??t.dataTransfer??null}function cet(e){return e.files.length>0||T9(e)}function T9(e){return $9e.some(t=>e.getData(t).length>0)}function uet(e){if(!e||typeof e!=`object`)return!1;let t=e;return!t.clipboardData&&!!t.dataTransfer}function det(e){let t=kr();if(!t)return!1;if(!Jn(t))return t.insertRawText(e),!0;let n=e.split(/(\r?\n|\t)/);n.at(-1)===``&&n.pop();for(let e of n){let t=kr();Jn(t)&&(e===`
|
|
395
395
|
`||e===`\r
|
|
396
|
-
`?t.insertParagraph():e===` `?t.insertNodes([ln()]):t.insertText(e))}return!0}function fet(e,t){let n=t.getData(`application/x-lexical-editor`);if(n)try{let t=JSON.parse(n),r=e;if(t.namespace===r._config.namespace&&Array.isArray(t.nodes)){let e=kr();return e?(e.insertNodes(t.nodes.map(Ne)),!0):!1}}catch{}let r=t.getData(`text/html`),i=t.getData(`text/plain`);if(r&&i!==r)try{let t=kr();if(!t)return!1;let n=new DOMParser().parseFromString(r,`text/html`);return t.insertNodes(le(e,n)),!0}catch{}let a=i||t.getData(`text/uri-list`);return a?det(a):!1}function pet(e,t,n){return t.length===0||!T9(n)?!1:(oet(t),fet(e,n))}function met(e){return e.inputType===`insertFromPaste`||e.inputType===`insertFromPasteAsQuotation`}function het(){return Sr().getChildren().map(e=>e.getKey())}function get(e){let t=e;for(;t&&t.getParent()&&t.getParent()!==Sr();)t=t.getParent();return t?.getParent()===Sr()?t.getKey():null}function _et(e,t){if(t.getChildrenSize()===0)return!1;let[n,r]=e.isBackward()?[e.focus,e.anchor]:[e.anchor,e.focus],i=t.getKey(),a=t.getFirstDescendant();if(!(n.type===`element`&&n.key===i&&n.offset===0||n.type===`text`&&a!==null&&a.getKey()===n.key&&n.offset===0))return!1;let o=t.getLastDescendant();return r.type===`element`&&r.key===i&&r.offset===t.getChildrenSize()||r.type===`text`&&it(o)&&o.getKey()===r.key&&r.offset===o.getTextContentSize()}function E9(e,t){let n=Sr().getChildren(),r=n.findIndex(t=>t.getKey()===e),i=n.findIndex(e=>e.getKey()===t);if(r===-1||i===-1)return;let a=Math.min(r,i),o=Math.max(r,i),s=sr();for(let e=a;e<=o;e++)s.add(n[e].getKey());Jt(s)}function vet(e){let t=(0,G.useRef)(null),n=(0,G.useRef)(null),r=(0,G.useRef)(new Set),i=(0,G.useRef)(null),a=$k()?.documentBlocks,o=(0,G.useCallback)(()=>{r.current=new Set,t.current=null,n.current=null,a?.clear()},[a]),s=(0,G.useCallback)(()=>(a?.keys().length??0)>0,[a]),c=(0,G.useCallback)(()=>(a?.keys()??[]).flatMap(e=>Dn(e)??[]),[a]),l=(0,G.useCallback)(()=>{a&&(a.editor.update(()=>aet(c()),{discrete:!0}),o(),a.focusSelection())},[c,o,a]),u=(0,G.useCallback)(e=>e.size===0?[]:Sr().getChildren().filter(t=>e.has(t.getKey())),[]),d=(0,G.useCallback)(()=>{let e=r.current;if(e.size===0){let e=kr();if(!Ue(e))return[];let t=e.getNodes(),n=t.filter(e=>e.getParent()===Sr());return n.length>1&&n.length===t.length?u(new Set(n.map(e=>e.getKey()))):[]}let t=kr();return Ue(t),u(e)},[u]),f=(0,G.useCallback)(t=>{if(!T9(t))return!1;let n=!1;if(a&&s()){let e=a.editor;return e.update(()=>{n=pet(e,c(),t)},{discrete:!0,tag:xe}),n&&(o(),a.focusSelection()),n}return e.update(()=>{let r=d();r.length!==0&&(n=pet(e,r,t),n&&o())},{discrete:!0,tag:xe}),n},[c,o,a,e,d,s]),p=(0,G.useCallback)(()=>{let t=null;if(a&&s()){let e=a.editor;return e.getEditorState().read(()=>w9(e,c()))}return e.getEditorState().read(()=>{let n=d();n.length!==0&&(t=w9(e,n))}),t},[c,a,e,d,s]),m=(0,G.useCallback)(t=>{e.update(()=>{let e=u(new Set(t));e.length!==0&&(aet(e),o())},{discrete:!0})},[o,e,u]);(0,G.useEffect)(()=>{let i=new Set,s=t=>{let n=new Set(t),o=new Set([...r.current,...a?.islandKeys(e)??[]].filter(e=>n.has(e)));for(let t of i)o.has(t)||e.getElementByKey(t)?.classList.remove(x9);for(let t of o)i.has(t)||e.getElementByKey(t)?.classList.add(x9);i=o},c=()=>s(e.getEditorState().read(het)),l=a?.subscribe(c);c();let u=e.registerUpdateListener(({editorState:i})=>{if(!e.getRootElement())return;let a=new Set,c=!1,l=[],u=[];if(i.read(()=>{let e=kr();if(Ue(e)){c=!0;for(let t of e.getNodes())a.add(t.getKey())}else if(Jn(e)){let t=get(e.anchor.getNode()),n=get(e.focus.getNode());t&&l.push(t),n&&n!==t&&l.push(n)}u=het()}),r.current.size>0){if(c){let e=r.current;if(!(a.size===e.size&&[...a].every(t=>e.has(t)))){let e=new Set(u),i=[...a].filter(t=>e.has(t));if(i.length>1){let e=i.map(e=>u.indexOf(e)).sort((e,t)=>e-t);t.current=u[e[0]],n.current=u[e.at(-1)],r.current=new Set(i)}else o()}}else{let e=r.current;l.length>0&&l.every(t=>e.has(t))||o()}}s(u)});return()=>{l?.(),u();for(let t of i)e.getElementByKey(t)?.classList.remove(x9)}},[o,a,e]),(0,G.useEffect)(()=>{let t=e.getRootElement();if(!t)return;let n=e=>{r.current.size!==0&&e.target instanceof Node&&t.contains(e.target)&&o()};return t.addEventListener(`pointerdown`,n,!0),()=>t.removeEventListener(`pointerdown`,n,!0)},[o,e]),(0,G.useEffect)(()=>{let t=e.getRootElement();if(!t)return;let n=n=>{if(r.current.size===0)return;let i=n.target;if(!i)return;let a=i.closest(`[contenteditable="true"]`);a&&a!==t&&(o(),e.update(()=>{let e=kr();Ue(e)&&Jt(null)}))};return t.addEventListener(`focusin`,n),()=>t.removeEventListener(`focusin`,n)},[o,e]),(0,G.useEffect)(()=>{let t=e.getRootElement();if(!t)return;let n=e=>{met(e)&&r.current.size!==0&&e.dataTransfer&&f(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation())};return t.addEventListener(`beforeinput`,n,!0),()=>t.removeEventListener(`beforeinput`,n,!0)},[e,f]),(0,G.useEffect)(()=>{let c=e.registerCommand(br,e=>{let t=e.key.toLowerCase();if(!e.metaKey&&!e.ctrlKey&&t!==`escape`||![`a`,`c`,`v`,`x`,`escape`].includes(t))return!1;if((e.metaKey||e.ctrlKey)&&t===`v`&&r.current.size>0){e.preventDefault();let t=i.current?{...i.current}:null;return(async()=>{let e=t?net(t):await ret();e&&r.current.size!==0&&f(e)})(),!0}return!1},4),u=e.registerCommand(F,i=>{if(!i?.shiftKey||r.current.size===0||!n.current)return!1;let o=kr();if(!Ue(o))return!1;let c=Sr().getChildren(),l=c.findIndex(e=>e.getKey()===n.current);if(l===-1)return!1;if(a&&(s()||l>=c.length-1))return i.preventDefault(),s()||a.select(e,t.current,n.current),a.extend(1),!0;if(l>=c.length-1)return!1;i.preventDefault(),n.current=c[l+1].getKey(),E9(t.current,n.current);let u=Math.min(c.findIndex(e=>e.getKey()===t.current),l+1),d=Math.max(c.findIndex(e=>e.getKey()===t.current),l+1);return r.current=new Set(c.slice(u,d+1).map(e=>e.getKey())),!0},4),h=e.registerCommand(Nn,i=>{if(!i?.shiftKey||r.current.size===0||!n.current)return!1;let o=kr();if(!Ue(o))return!1;let c=Sr().getChildren(),l=c.findIndex(e=>e.getKey()===n.current);if(l===-1)return!1;if(a&&(s()||l<=0))return i.preventDefault(),s()||a.select(e,t.current,n.current),a.extend(-1),!0;if(l<=0)return!1;i.preventDefault(),n.current=c[l-1].getKey(),E9(t.current,n.current);let u=c.findIndex(e=>e.getKey()===t.current),d=Math.min(u,l-1),f=Math.max(u,l-1);return r.current=new Set(c.slice(d,f+1).map(e=>e.getKey())),!0},4),g=e.registerCommand(eee,()=>{if(r.current.size>0){let e=Sr().getChildren().map(e=>e.getKey());if(r.current.size>=e.length)return a?.selectAll(),!0;t.current=e[0],n.current=e.at(-1),r.current=new Set(e);let i=sr();for(let t of e)i.add(t);return Jt(i),!0}let e=kr(),i=null,o=null;if(Jn(e)){let t=e.anchor.getNode();for(;t&&t.getParent()&&t.getParent()!==Sr();)t=t.getParent();t&&t.getParent()===Sr()&&(i=t.getKey(),o=t)}else if(Ue(e)){let t=e.getNodes();if(t.length>0){let e=t[0];for(;e&&e.getParent()&&e.getParent()!==Sr();)e=e.getParent();e&&e.getParent()===Sr()&&(i=e.getKey(),o=e)}}if(o&&rr(o)){let t=o.getChildrenSize(),n=Jn(e)&&_et(e,o);if(t>0&&!n)return o.select(0,t),!0}if(i){t.current=i,n.current=i,r.current=new Set([i]);let e=sr();return e.add(i),Jt(e),!0}return!1},3),_=e.registerCommand(tr,()=>r.current.size!==0&&(o(),Jt(null),!0),3),v=e.registerCommand(Pn,t=>{let n=t&&typeof t==`object`&&`clipboardData`in t?t:null,r=p();return r?(i.current=r,n?.clipboardData?(n.preventDefault(),S9(n.clipboardData,r),!0):(t&&typeof t==`object`&&`preventDefault`in t&&typeof t.preventDefault==`function`&&t.preventDefault(),iet(e,r),!0)):!1},4),y=e.registerCommand(he,t=>{let n=t&&typeof t==`object`&&`clipboardData`in t?t:null,r=s(),a=[],o=r?p():null;return r||e.getEditorState().read(()=>{let t=d();t.length!==0&&(o=w9(e,t),a=t.map(e=>e.getKey()))}),!r&&a.length===0||!o?!1:(i.current=o,n?.clipboardData?(n.preventDefault(),S9(n.clipboardData,o)):(t&&typeof t==`object`&&`preventDefault`in t&&typeof t.preventDefault==`function`&&t.preventDefault(),iet(e,o)),r?l():m(a),!0)},4),b=e.registerCommand(or,t=>{let n=set(t);if(!n)return!1;let r=uet(t);if(!(r?T9(n):cet(n)))return!1;if(s())return f(n)?(t&&typeof t==`object`&&`preventDefault`in t&&typeof t.preventDefault==`function`&&t.preventDefault(),!0):!1;let i=d();return i.length!==0&&(oet(i),o(),r?(t&&typeof t==`object`&&`preventDefault`in t&&typeof t.preventDefault==`function`&&t.preventDefault(),fet(e,n)):!1)},4),x=t=>{if(s())return t&&typeof t!=`boolean`&&`preventDefault`in t&&typeof t.preventDefault==`function`&&t.preventDefault(),l(),!0;let n=[];return e.getEditorState().read(()=>{n=d().map(e=>e.getKey())}),n.length!==0&&(t&&typeof t!=`boolean`&&`preventDefault`in t&&typeof t.preventDefault==`function`&&t.preventDefault(),m(n),!0)},S=e.registerCommand(Wt,x,4),C=e.registerCommand(Ze,x,4),w=e.registerCommand(Yee,x,4),T=e.registerCommand(Hee,x,4);return()=>{c(),u(),h(),g(),_(),v(),y(),b(),S(),C(),w(),T()}},[o,m,l,a,e,p,d,s,f]);let h=(0,G.useCallback)((i,o)=>{a?.clear(),e.update(()=>{if(o&&t.current){n.current=i,E9(t.current,i);let e=Sr().getChildren(),a=e.findIndex(e=>e.getKey()===t.current),o=e.findIndex(e=>e.getKey()===i);if(a!==-1&&o!==-1){let t=Math.min(a,o),n=Math.max(a,o);r.current=new Set(e.slice(t,n+1).map(e=>e.getKey()))}}else{t.current=i,n.current=i,r.current=new Set([i]);let e=sr();e.add(i),Jt(e)}})},[a,e]),g=(0,G.useCallback)(()=>{if(r.current.size===0)return[];let t=[];return e.getEditorState().read(()=>{t=u(r.current).map(e=>e.getKey())}),t},[e,u]),_=(0,G.useCallback)(e=>{let t=g(),n=t.length>0?t:e?[e]:[];n.length!==0&&m(n)},[m,g]);return{selectBlock:h,getSelectedKeys:g,isBlockSelectionActive:(0,G.useCallback)(()=>r.current.size>0,[]),deleteSelectedBlocks:_}}var yet=150,bet=300,xet=32;function Cet(e){return[...e.children].filter(e=>e instanceof HTMLElement)}function wet(e){return[...e.querySelectorAll(`[data-virtual-editor-content]`)].flatMap(Cet).filter(e=>e.getBoundingClientRect().height>0).sort((e,t)=>e.getBoundingClientRect().top-t.getBoundingClientRect().top)}function Tet(e){return[...e.querySelectorAll(`[data-virtual-editor-content]`)].find(e=>e.getBoundingClientRect().height>0)}function Eet(e,t){let n=_te(e);if(!n)return;let r=n.read(()=>Bt(e)?.getKey());return r?t.documentKeys(n,[r])[0]:void 0}function Det(e,t){let n=on(),r=te(`/`);n.append(r),e?t?e.insertBefore(n):e.insertAfter(n):Sr().append(n),r.select(1,1)}function Oet(e,t){let[n,r]=(0,G.useState)(null),i=(0,G.useRef)(null),a=(0,G.useRef)(null),o=(0,G.useRef)(null),s=(0,G.useRef)(!1),c=$k()?.documentBlocks,l=(0,G.useCallback)(()=>{a.current&&clearTimeout(a.current),a.current=null},[]),u=(0,G.useCallback)(()=>{o.current&&clearTimeout(o.current),o.current=null},[]),d=(0,G.useCallback)(()=>{l(),i.current=null,s.current||r(null)},[l]);(0,G.useEffect)(()=>{let n=e.getRootElement();if(!n)return;let s=n.closest(`.rich-editor`)??n.parentElement;if(!s)return;let f=c?n.closest(`[data-virtual-editor]`):null,p=null,m=e=>{let o=e.target;if(f&&Tet(f)!==n){d();return}let s=(f??n).getBoundingClientRect();if(!(e.clientX>=s.left-xet&&e.clientX<=s.right)||t(o)||o.closest(`[role="toolbar"]`)){d();return}let c=f?wet(f):Cet(n),u=H9e(c.map(e=>e.getBoundingClientRect()),e.clientY);u?i.current!==u.index&&(l(),i.current=u.index,a.current=setTimeout(()=>{r({index:u.index,top:u.y+window.scrollY,left:s.left+window.scrollX,width:s.width,next:c[u.index]??null,previous:c[u.index-1]??null})},yet)):d()},h=e=>{u(),p===null&&(p=requestAnimationFrame(()=>{p=null,m(e)}))},g=()=>{u(),o.current=setTimeout(d,bet)};return s.addEventListener(`mousemove`,h),s.addEventListener(`mouseleave`,g),window.addEventListener(`scroll`,d,!0),()=>{p!==null&&cancelAnimationFrame(p),s.removeEventListener(`mousemove`,h),s.removeEventListener(`mouseleave`,g),window.removeEventListener(`scroll`,d,!0),l(),u()}},[u,l,d,c,e,t]);let f=(0,G.useCallback)(()=>{s.current=!0,l(),u()},[u,l]),p=(0,G.useCallback)(()=>{s.current=!1,d()},[d]);return{gap:n,insertAtGap:(0,G.useCallback)(()=>{if(!n)return;let{index:t,next:i,previous:a}=n;s.current=!1,d(),r(null);let o=i??a;if(c&&o){let e=Eet(o,c);if(!e)return;c.editor.update(()=>Det(Dn(e),o===i),{discrete:!0}),c.focusSelection()}else e.update(()=>Det(Sr().getChildAtIndex(t),!0)),e.focus()},[d,c,e,n]),onPlusEnter:f,onPlusLeave:p}}var ket=8;function Aet(e){let t=(0,G.useRef)(null),n=(0,G.useRef)(null),r=(0,G.useRef)(e);(0,G.useEffect)(()=>{r.current=e},[e]);let i=(0,G.useCallback)(()=>{t.current&&clearTimeout(t.current),t.current=null,n.current=null},[]);return(0,G.useEffect)(()=>i,[i]),(0,G.useMemo)(()=>({onPointerDown:e=>{i(),e.pointerType===`touch`&&(n.current={x:e.clientX,y:e.clientY},t.current=setTimeout(()=>{t.current=null,n.current=null,r.current()},450))},onPointerMove:e=>{let t=n.current;t&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>ket&&i()},onPointerUp:i,onPointerCancel:i}),[i])}var D9=`application/x-rich-editor-drag`,jet=300,Met=26,Net=24;function O9(e,t){let n=e.getRootElement();if(!n)return null;let r=t;for(;r&&r!==n;){if(r.parentElement===n)return r;r=r.parentElement}return null}function Pet(e,t){let n=[...e.children].filter(e=>e instanceof HTMLElement);if(!n.length)return null;let r=null,i=1/0;for(let e of n){let n=e.getBoundingClientRect();if(n.height<=0)continue;if(t>=n.top&&t<=n.bottom)return e;let a=t<n.top?n.top-t:t-n.bottom;a<i&&(i=a,r=e)}return r}function Fet(e,t,n){let r=t.getBoundingClientRect();if(r.width<=0||r.height<=0||n.clientY<r.top||n.clientY>r.bottom)return null;let i=[{x:n.clientX,y:n.clientY}],a=Math.min(r.right-1,Math.max(r.left+1,n.clientX));a!==n.clientX&&i.unshift({x:a,y:n.clientY});for(let t of i){let n=document.elementFromPoint(t.x,t.y);if(!(n instanceof HTMLElement))continue;let r=O9(e,n);if(r)return r}let{target:o}=n;if(o instanceof HTMLElement){let t=O9(e,o);if(t)return t}return Pet(t,n.clientY)}function Iet(e){return{top:e.top+window.scrollY,left:e.left+window.scrollX}}function Let({editor:e}){let{className:t,theme:n}=We(),[r,i]=(0,G.useState)({visible:!1,top:0,left:0,nodeKey:null}),[a,o]=(0,G.useState)({visible:!1,top:0,left:0,width:0}),s=(0,G.useRef)(null),c=(0,G.useRef)(null),l=(0,G.useRef)(!1),u=(0,G.useRef)(0),d=(0,G.useRef)(null),f=(0,G.useRef)(null),p=(0,G.useRef)(null),{selectBlock:m,getSelectedKeys:h,deleteSelectedBlocks:g}=vet(e),_=$k()?.documentBlocks,v=(0,G.useCallback)(()=>{c.current&&=(clearTimeout(c.current),null)},[]),y=(0,G.useCallback)(()=>{v(),c.current=setTimeout(()=>{!l.current&&u.current===0&&(s.current=null,i(e=>({...e,visible:!1,nodeKey:null})))},jet)},[v]),b=(0,G.useCallback)(()=>{l.current=!0,v()},[v]),x=(0,G.useCallback)(()=>{l.current=!1,y()},[y]),S=(0,G.useCallback)(e=>{u.current+=e?1:-1,e?v():y()},[v,y]),C=(0,G.useCallback)(t=>{t!==void 0&&(s.current=t);let n=s.current;if(!n||!n.isConnected){s.current=null,i(e=>e.visible?{...e,visible:!1,nodeKey:null}:e);return}let r=e.getRootElement();if(!r)return;let a=n.getBoundingClientRect(),o=r.getBoundingClientRect(),c=Iet(a),l=getComputedStyle(n),u=null;e.read(()=>{let e=Bt(n);e&&(u=e.getKey())});let d=U9e({top:c.top,paddingTop:Number.parseFloat(l.paddingTop)||0,lineHeight:W9e(l.lineHeight,l.fontSize)},Net),f=Iet(o).left-Met;i(e=>e.visible&&e.top===d&&e.left===f&&e.nodeKey===u?e:{visible:!0,top:d,left:f,nodeKey:u})},[e]);(0,G.useEffect)(()=>{let t=e.getRootElement();if(!t)return;let n=null,r=t=>{n===null&&(n=requestAnimationFrame(()=>{n=null;let r=t.target,i=O9(e,r);i&&(v(),C(i))}))},i=()=>{!l.current&&u.current===0&&y()};return t.addEventListener(`mousemove`,r),t.addEventListener(`mouseleave`,i),()=>{n!==null&&cancelAnimationFrame(n),t.removeEventListener(`mousemove`,r),t.removeEventListener(`mouseleave`,i),v()}},[v,e,y,C]),(0,G.useEffect)(()=>{let e=()=>C();return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[C]),(0,G.useEffect)(()=>e.registerUpdateListener(()=>C()),[e,C]),Q9e(e,h);let{gap:w,insertAtGap:T,onPlusEnter:E,onPlusLeave:D}=Oet(e,(0,G.useCallback)(t=>O9(e,t)!==null,[e]));(0,G.useEffect)(()=>{!w||u.current>0||(v(),s.current=null,i(e=>e.visible?{...e,visible:!1,nodeKey:null}:e))},[v,w]);let O=(0,G.useCallback)(t=>{r.nodeKey&&V9e(e,r.nodeKey,t)},[e,r.nodeKey]),k=(0,G.useCallback)(()=>{g(r.nodeKey),i(e=>({...e,visible:!1,nodeKey:null}))},[g,r.nodeKey]),A=(0,G.useCallback)(()=>{let t=h(),n=t.length>0?t:r.nodeKey?[r.nodeKey]:[];n.length&&e.update(()=>{P9e(n)})},[e,h,r.nodeKey]),j=(0,G.useCallback)(t=>{let n=h(),i=n.length>0?n:r.nodeKey?[r.nodeKey]:[];i.length&&I9e(e,_,i,t)},[_,e,h,r.nodeKey]),[M,N]=(0,G.useState)(!1),P=(0,G.useRef)(!1),F=(0,G.useCallback)(()=>{let t=d.current;t&&(t.remove(),d.current=null);let n=f.current;n&&(n.classList.remove(b9),f.current=null);let r=p.current;if(r){for(let t of r)e.getElementByKey(t)?.classList.remove(b9);p.current=null}},[e]),I=(0,G.useCallback)(i=>{if(P.current=!0,!i.dataTransfer||!r.nodeKey)return;let a=h(),o=a.length>0&&a.includes(r.nodeKey)?a:[r.nodeKey],c=_?_.documentKeys(e,o):o;i.dataTransfer.setData(D9,JSON.stringify(c)),i.dataTransfer.effectAllowed=`move`;let l=s.current;if(!l)return;F();let u=l.getBoundingClientRect(),m=l.cloneNode(!0);if(m.classList.add(J9e),m.style.width=`${u.width}px`,m.style.position=`relative`,o.length>1){let e=document.createElement(`div`);e.className=Y9e,e.textContent=String(o.length),m.appendChild(e)}if(t){let e=document.createElement(`div`);e.className=t,e.setAttribute(`data-theme`,n),e.style.cssText=`position:fixed;top:-10000px;left:-10000px;pointer-events:none`,e.appendChild(m),document.body.append(e),d.current=e}else document.body.append(m),d.current=m;if(o.length>1){for(let t of o)e.getElementByKey(t)?.classList.add(b9);p.current=o}else f.current=l,l.classList.add(b9);let g=Math.max(12,Math.min(u.width-12,i.clientX-u.left)),v=Math.max(8,Math.min(u.height-8,i.clientY-u.top));i.dataTransfer.setDragImage(m,g,v)},[F,_,e,h,r.nodeKey,t,n]),L=(0,G.useCallback)(e=>{N(t=>t===e?t:(S(e),e))},[S]),R=Aet(()=>{r.nodeKey&&(m(r.nodeKey,!1),L(!0))}),z=M&&r.nodeKey?e.getEditorState().read(()=>z9e(Dn(r.nodeKey))):null,B=(0,G.useCallback)(e=>{P.current=!1,e.button===0&&e.stopPropagation()},[]),V=(0,G.useCallback)(t=>{if(t.detail===0)return;if(t.preventDefault(),t.stopPropagation(),P.current){P.current=!1;return}if(!r.nodeKey)return;let{nodeKey:n}=r,{shiftKey:i}=t;e.focus(()=>m(n,i)),i||L(!0)},[e,r.nodeKey,L,m]),H=(0,G.useCallback)(e=>{e.preventDefault(),r.nodeKey&&(h().includes(r.nodeKey)||m(r.nodeKey,!1)),L(!0)},[h,r.nodeKey,L,m]);return(0,G.useEffect)(()=>{let t=e.getRootElement();if(!t)return;let n=e.registerCommand(hr,n=>{if(!n.dataTransfer?.types.includes(D9))return!1;n.preventDefault(),n.dataTransfer.dropEffect=`move`;let r=Fet(e,t,n);if(!r)return o(e=>e.visible?{...e,visible:!1}:e),!0;let i=r.getBoundingClientRect(),a=t.getBoundingClientRect(),s=i.top+i.height/2,c=n.clientY<s?i.top:i.bottom;return o({visible:!0,top:c+window.scrollY,left:a.left+window.scrollX,width:a.width}),!0},3),r=e.registerCommand(dt,n=>{let r=n.dataTransfer?.getData(D9);if(!r)return!1;n.preventDefault(),o(e=>({...e,visible:!1})),F();let i;try{let e=JSON.parse(r);i=Array.isArray(e)&&e.every(e=>typeof e==`string`)?e:[r]}catch{i=[r]}if(!i.length)return!1;let a=Fet(e,t,n);if(!a)return!1;let s=e.read(()=>Bt(a)?.getKey());if(!s)return!0;let c=_?_.documentKeys(e,[s])[0]:s;if(!c)return!0;let l=a.getBoundingClientRect(),u=n.clientY<l.top+l.height/2;return(_?.editor??e).update(()=>{F9e(i,c,u)}),!0},3),i=e.registerCommand(Je,e=>!!e.dataTransfer?.types.includes(D9),3),a=()=>{o(e=>e.visible?{...e,visible:!1}:e)},s=()=>{a(),F()},c=e=>{e.relatedTarget!==null&&t.contains(e.relatedTarget)||a()};return window.addEventListener(`dragend`,s),window.addEventListener(`drop`,s),t.addEventListener(`dragleave`,c),()=>{n(),r(),i(),window.removeEventListener(`dragend`,s),window.removeEventListener(`drop`,s),t.removeEventListener(`dragleave`,c),s()}},[F,_,e]),(0,G.useEffect)(()=>{let t=e.getRootElement();if(!t)return;let n=t.closest(`.rich-editor`);if(!n)return;let r=!1,i=null,a=n=>{let r=Pet(t,n);if(!r)return null;let i=null;return e.read(()=>{i=Bt(r)?.getKey()??null}),i},o=n=>{if(n.button!==0)return;let o=n.target;if(t.contains(o)||o.closest(`button, input, textarea, select, [role="toolbar"], [role="menu"]`))return;let s=t.getBoundingClientRect();if(n.clientY<s.top||n.clientY>s.bottom)return;let c=a(n.clientY);c&&(n.preventDefault(),e.focus(()=>m(c,n.shiftKey)),r=!0,i=c)},s=e=>{if(!r)return;let t=a(e.clientY);t&&t!==i&&(m(t,!0),i=t)},c=()=>{r=!1,i=null};return n.addEventListener(`mousedown`,o),window.addEventListener(`mousemove`,s),window.addEventListener(`mouseup`,c),()=>{n.removeEventListener(`mousedown`,o),window.removeEventListener(`mousemove`,s),window.removeEventListener(`mouseup`,c)}},[e,m]),(0,K.jsxs)(`div`,{...t?{className:t,"data-theme":n,style:{display:`contents`}}:{},children:[(0,K.jsx)(`div`,{className:`${G9e} ${r.visible?K9e:``}`,style:{top:r.top,left:r.left},onMouseEnter:b,onMouseLeave:x,children:(0,K.jsxs)(Zn,{open:M,onOpenChange:L,children:[(0,K.jsx)(On,{draggable:!0,"aria-label":`Block actions`,className:q9e,onClick:V,onContextMenu:H,onDragStart:I,onMouseDownCapture:B,...R,children:(0,K.jsx)(Lte,{size:16})}),(0,K.jsx)(A9e,{currentType:z,onDelete:k,onDuplicate:A,onMoveDown:()=>j(`down`),onMoveUp:()=>j(`up`),onTurnInto:O})]})}),w&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`iihqkc3`,style:{top:w.top,left:w.left,width:w.width}}),(0,K.jsx)(`button`,{"aria-label":`Insert block`,className:`iihqkc4`,style:{top:w.top,left:w.left-Met},type:`button`,onClick:T,onMouseDown:e=>e.preventDefault(),onMouseEnter:E,onMouseLeave:D,children:(0,K.jsx)(zr,{size:14})})]}),a.visible&&(0,K.jsx)(`div`,{className:`iihqkc7`,style:{top:a.top,left:a.left,width:a.width}})]})}function Ret(){let[e]=ht();return(0,Gi.createPortal)((0,K.jsx)(Let,{editor:e}),document.body)}function k9(e){let t=e.trim();return t===``||/^https?:\/\/$/.test(t)}function zet(e){return e.trim().replace(/^https?:\/\//i,``).replace(/\/$/,``)}function A9({action:e,children:t,danger:n,disabled:r,label:i,onClick:a}){return(0,K.jsxs)(Mn,{children:[(0,K.jsx)(tt,{render:(0,K.jsx)(Fe,{icon:!0,"aria-label":i,danger:n,"data-link-action":e,disabled:r,size:`md`,onClick:a}),children:t}),(0,K.jsx)(Fn,{side:`top`,children:i})]})}var j9={panel:`rich-link-edit-panel`,preview:`rich-link-edit-preview`,actions:`rich-link-edit-actions`,cmdHover:`rich-link-edit-cmd-hover`},Bet=`_1uegwri0`,Vet=`_1uegwri1`,Het=`_1uegwri2`,Uet=`_1uegwri3`,Wet=`_1uegwri4`,Get=`_1uegwri5`,Ket=`_1uegwri7`,qet=`_1uegwri8`,Jet=`_1uegwri9`,Yet=`_1uegwria`,Xet=`_1uegwrib`;function Zet(e){return e.mode===`edit`?(0,K.jsx)($et,{...e}):(0,K.jsx)(Qet,{...e})}function Qet({extraActions:e,text:t,url:n,onCopy:r,onEdit:i,onOpen:a,onUnlink:o}){let s=k9(n),c=zet(n);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`${Vet} ${j9.preview}`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:Het,children:(0,K.jsx)(D,{})}),(0,K.jsxs)(`div`,{className:Uet,children:[(0,K.jsx)(`div`,{className:`${Wet}${s?` ${Get}`:``}`,children:s?`No link yet`:t.trim()||c}),!s&&(0,K.jsx)(`div`,{className:`_1uegwri6`,title:n,children:c})]})]}),(0,K.jsxs)(`div`,{className:`${Ket} ${j9.actions}`,children:[e,(0,K.jsx)(`span`,{className:qet}),(0,K.jsx)(A9,{disabled:s,label:`Open link`,onClick:a,children:(0,K.jsx)(Xte,{})}),(0,K.jsx)(A9,{disabled:s,label:`Copy link`,onClick:r,children:(0,K.jsx)(Ir,{})}),(0,K.jsx)(A9,{action:`edit`,label:`Edit link`,onClick:i,children:(0,K.jsx)(Ae,{})}),(0,K.jsx)(A9,{danger:!0,label:`Remove link`,onClick:o,children:(0,K.jsx)(Vi,{})})]})]})}function $et({draft:e,urlInputRef:t,onCancel:n,onDraftChange:r,onKeyDown:i,onSave:a}){let o=(0,G.useId)(),s=`${o}-text`,c=`${o}-url`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Xn,{children:[(0,K.jsx)(Kn,{id:s,label:`Text`,children:(0,K.jsx)(ct,{id:s,placeholder:`Link text`,value:e.text,onChange:t=>r({...e,text:t.target.value}),onKeyDown:i})}),(0,K.jsx)(Kn,{id:c,label:`URL`,children:(0,K.jsx)(ct,{id:c,placeholder:`Paste or type a link`,ref:t,type:`url`,value:e.url,onChange:t=>r({...e,url:t.target.value}),onKeyDown:i})})]}),(0,K.jsxs)(`div`,{className:Jet,children:[(0,K.jsx)(Fe,{size:`md`,variant:`outline`,onClick:n,children:`Cancel`}),(0,K.jsxs)(Fe,{disabled:k9(e.url),size:`md`,variant:`solid`,onClick:a,children:[`Save`,(0,K.jsx)(ar,{className:Yet,keys:`enter`,size:`sm`,tone:`inverted`})]})]})]})}var ett=[Xet,j9.cmdHover];function ttt(e){let t=t=>{for(let n of ett)e.classList.toggle(n,t)},n=e=>{(e.key===`Meta`||e.key===`Control`)&&t(!0)},r=e=>{(e.key===`Meta`||e.key===`Control`)&&t(!1)},i=()=>t(!1),a=e=>{if(!(e.metaKey||e.ctrlKey))return;let t=e.target.closest(`a`);if(!t)return;let n=t.getAttribute(`href`);n&&(e.preventDefault(),window.open(n,`_blank`,`noopener,noreferrer`))};return e.addEventListener(`keydown`,n),e.addEventListener(`keyup`,r),e.addEventListener(`blur`,i),e.addEventListener(`click`,a),()=>{e.removeEventListener(`keydown`,n),e.removeEventListener(`keyup`,r),e.removeEventListener(`blur`,i),e.removeEventListener(`click`,a);for(let t of ett)e.classList.remove(t)}}function ntt(e){(0,G.useEffect)(()=>{let t=null,n=e.registerRootListener(e=>{t?.(),t=e?ttt(e):null});return()=>{n(),t?.()}},[e])}function rtt(e){let t=e;for(;t;){if(Yn(t))return t;t=t.getParent()}return null}function itt(e,t){if(e.getTextContent()===t)return;let n=e.getFirstDescendant(),r=te(t);it(n)&&(r.setFormat(n.getFormat()),r.setStyle(n.getStyle()));let i=e.getChildren();e.append(r);for(let e of i)e.remove()}function att({renderExtraActions:e}={}){let[t]=ht(),n=(0,G.useRef)(null),r=(0,G.useRef)(null),i=(0,G.useRef)(!1),a=(0,G.useRef)(!1),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)({url:``,text:``,linkKey:``,linkDom:null}),[u,d]=(0,G.useState)({text:``,url:``}),f=(0,G.useRef)(u),[p,m]=(0,G.useState)(`view`),h=(0,G.useRef)(`view`),g=(0,G.useRef)(``),_=(0,G.useCallback)(e=>{f.current=e,d(e)},[]),v=(0,G.useCallback)(e=>{h.current=e,m(e)},[]),y=(0,G.useCallback)(()=>{if(a.current)return;let e=kr();if(!Jn(e)||!e.isCollapsed()){s(!1);return}let n=rtt(e.anchor.getNode());if(!n||zn(n)&&n.getIsUnlinked()){g.current=``,s(!1);return}let r=n.getURL(),i=n.getTextContent(),o=n.getKey(),c=t.getElementByKey(o);g.current!==o&&(g.current=o,v(k9(r)?`edit`:`view`)),l({url:r,text:i,linkKey:o,linkDom:c}),h.current!==`view`&&a.current||_({text:i,url:r}),s(!0)},[t,_,v]);(0,G.useEffect)(()=>{let e=t.registerCommand(mn,()=>(y(),!1),1),n=t.registerUpdateListener(({editorState:e})=>{e.read(()=>{y()})});return()=>{e(),n()}},[t,y]),ntt(t),(0,G.useEffect)(()=>{o&&p===`edit`&&n.current?.focus()},[o,p,c.linkKey]),(0,G.useEffect)(()=>{p===`view`&&i.current&&(i.current=!1,r.current?.querySelector(`[data-link-action="edit"]`)?.focus())},[p]);let b=(0,G.useCallback)(()=>{let{text:e,url:n}=f.current,r=n.trim();if(k9(r))return!1;let i=e.trim();return t.update(()=>{let t=Dn(c.linkKey);Yn(t)&&(t.getURL()!==r&&t.setURL(r),i&&itt(t,e))}),!0},[t,c.linkKey]),x=(0,G.useCallback)(()=>{a.current=!1,v(`view`),t.focus()},[t,v]),S=(0,G.useCallback)(()=>{b()&&x()},[b,x]),C=(0,G.useCallback)(()=>{_({text:c.text,url:c.url}),k9(c.url)?x():(i.current=!0,v(`view`))},[c.text,c.url,x,_,v]),w=(0,G.useCallback)(e=>{e.key===`Enter`?(e.preventDefault(),S()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),C())},[C,S]),T=(0,G.useCallback)(()=>{_({text:c.text,url:c.url}),v(`edit`)},[c.text,c.url,_,v]),E=(0,G.useCallback)(()=>{window.open(c.url,`_blank`,`noopener`)},[c.url]),D=(0,G.useCallback)(()=>{navigator.clipboard?.writeText(c.url).then(()=>{Pe({title:`Link copied`,tone:`success`})})},[c.url]),O=(0,G.useCallback)(()=>{t.update(()=>{let e=Dn(c.linkKey);if(Yn(e)){if(zn(e)){e.setIsUnlinked(!0),e.markDirty();return}let t=e.getChildren();for(let n of t)e.insertBefore(n);e.remove()}}),a.current=!1,s(!1)},[t,c.linkKey]),k=(0,G.useCallback)(()=>{a.current=!0},[]),A=(0,G.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||(a.current=!1,h.current===`edit`&&b()&&v(`view`))},[b,v]);return t.isEditable()?(0,K.jsx)(gn,{open:o,children:(0,K.jsx)(Cte,{children:(0,K.jsx)(Ote,{align:`center`,anchor:c.linkDom,collisionAvoidance:{side:`flip`,align:`shift`},collisionPadding:8,side:`bottom`,sideOffset:8,children:(0,K.jsx)(Aee,{flush:!0,className:`${Bet} ${j9.panel}`,ref:r,size:`md`,onBlur:A,onFocus:k,children:(0,K.jsx)(Zet,{draft:u,mode:p,text:c.text,url:c.url,urlInputRef:n,extraActions:e?.({url:c.url,linkKey:c.linkKey,actionButtonClassName:Ate({size:`md`})}),onCancel:C,onCopy:D,onDraftChange:_,onEdit:T,onKeyDown:w,onOpen:E,onSave:S,onUnlink:O})})})})}):null}var ott=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`,stt=Rn(`SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND`);function ctt(e,{minLength:t=1,maxLength:n=75,punctuation:r=ott,allowWhitespace:i=!1}){return(0,G.useCallback)(a=>{let o=RegExp(`(^|\\s|\\()([`+e+`]((?:[^`+e+r+(i?``:`\\s`)+`]){0,`+n+`}))$`).exec(a);if(o!==null){let e=o[1],n=o[3];if(n.length>=t)return{leadOffset:o.index+e.length,matchingString:n,replaceableString:o[2]}}return null},[i,e,r,n,t])}var ltt=class{key;ref;icon;title;constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}},utt=fr?G.useLayoutEffect:G.useEffect,dtt=e=>{let t=e.closest(`#typeahead-menu`);if(!t)return;let n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:`center`}),n.top<0&&t.scrollIntoView({block:`center`}),e.scrollIntoView({block:`nearest`})};function ftt(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top>=r.top-6&&n.top<=r.bottom+6}function ptt(e,t,n,r){let[i]=ht();(0,G.useEffect)(()=>{if(t!=null&&e!=null){let e=i.getRootElement(),a=e==null?document.body:nee(e,!1),o=!1,s=ftt(t,a),c=function(){o||=(window.requestAnimationFrame(function(){n(),o=!1}),!0);let e=ftt(t,a);e!==s&&(s=e,r?.(e))},l=new ResizeObserver(n),u=yte(e??t);return l.observe(t),Qn(Gt(window,`resize`,n),Gt(document,`scroll`,c,{capture:!0,passive:!0}),...u.map(e=>Gt(e,`scroll`,c,{capture:!0,passive:!0})),()=>l.unobserve(t))}},[t,i,r,n,e])}function mtt({index:e,isSelected:t,onClick:n,onMouseEnter:r,option:i}){let a=`item`;return t&&(a+=` selected`),(0,K.jsxs)(`li`,{tabIndex:-1,className:a,ref:i.setRefElement,role:`option`,"aria-selected":t,id:`typeahead-item-`+e,onMouseEnter:r,onClick:n,children:[i.icon,(0,K.jsx)(`span`,{className:`text`,children:i.title})]},i.key)}function htt({close:e,editor:t,anchorElementRef:n,resolution:r,options:i,menuRenderFn:a,onSelectOption:o,shouldSplitNodeWithQuery:s=!1,commandPriority:c=1,preselectFirstItem:l=!0}){let[u,d]=(0,G.useState)(null),f=u===null?null:Math.min(i.length-1,u),p=r.match&&r.match.matchingString;(0,G.useEffect)(()=>{l&&d(0)},[p,l]);let m=(0,G.useCallback)(n=>{t.update(()=>{o(n,r.match!=null&&s?function(e){let t=kr();if(!Jn(t)||!t.isCollapsed())return null;let n=t.anchor;if(n.type!==`text`)return null;let r=n.getNode();if(!r.isSimpleText())return null;let i=n.offset,a=r.getTextContent().slice(0,i),o=e.replaceableString.length,s=i-function(e,t,n){let r=n;for(let n=r;n<=t.length;n++)e.slice(-n)===t.substring(0,n)&&(r=n);return r}(a,e.matchingString,o);if(s<0)return null;let c;return s===0?[c]=r.splitText(i):[,c]=r.splitText(s,i),c}(r.match):null,e,r.match?r.match.matchingString:``)})},[t,s,r.match,o,e]),h=(0,G.useCallback)(e=>{let n=t.getRootElement();n!==null&&(n.setAttribute(`aria-activedescendant`,`typeahead-item-`+e),d(e))},[t]),g=(0,G.useCallback)(()=>n.current&&i.length?Gi.createPortal((0,K.jsx)(`div`,{className:`typeahead-popover mentions-menu`,children:(0,K.jsx)(`ul`,{children:i.map((e,t)=>(0,K.jsx)(mtt,{index:t,isSelected:f===t,onClick:()=>{d(t),m(e)},onMouseEnter:()=>{d(t)},option:e},e.key))})}),n.current):null,[n,i,f,m,d]);(0,G.useEffect)(()=>()=>{let e=t.getRootElement();e!==null&&e.removeAttribute(`aria-activedescendant`)},[t]),utt(()=>{i===null?d(null):f===null&&l&&h(0)},[i,f,h,l]);let _=a==null&&(i===null||!i.length);(0,G.useEffect)(()=>Qn(t.registerCommand(stt,({option:e})=>!(!e.ref||e.ref.current==null||(dtt(e.ref.current),0)),c)),[t,h,c]),(0,G.useEffect)(()=>Qn(t.registerCommand(F,e=>{let n=e;if(_)return!1;let r=f===null||f===i.length-1?0:f+1;h(r);let a=i[r];return a?(a.ref&&a.ref.current&&t.dispatchCommand(stt,{index:r,option:a}),n.preventDefault(),n.stopImmediatePropagation(),!0):(h(-1),n.preventDefault(),n.stopImmediatePropagation(),!0)},c),t.registerCommand(Nn,e=>{let t=e;if(_)return!1;let n=f===null||f===0?i.length-1:f-1;h(n);let r=i[n];return r?(r.ref&&r.ref.current&&dtt(r.ref.current),t.preventDefault(),t.stopImmediatePropagation(),!0):(h(-1),t.preventDefault(),t.stopImmediatePropagation(),!0)},c),t.registerCommand(tr,t=>{let n=t;return!_&&(n.preventDefault(),n.stopImmediatePropagation(),e(),!0)},c),t.registerCommand(Qe,e=>{let t=e;return i!==null&&f!==null&&i[f]!=null&&(t.preventDefault(),t.stopImmediatePropagation(),m(i[f]),!0)},c),t.registerCommand(an,e=>!(i===null||f===null||i[f]==null||e&&e.shiftKey||(e!==null&&(e.preventDefault(),e.stopImmediatePropagation()),m(i[f]),0)),c)),[m,e,t,i,_,f,h,c]);let v=(0,G.useMemo)(()=>({options:i,selectOptionAndCleanUp:m,selectedIndex:f,setHighlightedIndex:d}),[m,f,i]);return a==null?g():a(n,v,r.match?r.match.matchingString:``)}function gtt(e,t){t!=null&&(e.className=t),e.setAttribute(`aria-label`,`Typeahead menu`),e.setAttribute(`role`,`listbox`),e.style.display=`block`,e.style.position=`absolute`}function _tt(e){if(e.position!==`static`)return!0;let t=e.willChange;return e.transform!==`none`||e.perspective!==`none`||e.filter!==`none`||e.backdropFilter!==`none`||e.contain.includes(`paint`)||e.contain.includes(`layout`)||e.contain.includes(`strict`)||e.contain.includes(`content`)||t.includes(`transform`)||t.includes(`perspective`)||t.includes(`filter`)||t.includes(`contain`)}function vtt({options:e,onQueryChange:t,onSelectOption:n,onOpen:r,onClose:i,menuRenderFn:a,triggerFn:o,anchorClassName:s,commandPriority:c=1,parent:l,preselectFirstItem:u=!0,ignoreEntityBoundary:d=!1}){let[f]=ht(),[p,m]=(0,G.useState)(null),h=(0,G.useRef)(0),g=(0,G.useRef)(!1),_=(0,G.useCallback)(()=>{if(!g.current)return;g.current=!1;let e=h.current,t=()=>{h.current===e&&m(null)},n;try{n=i&&i()}finally{n?n.then(t,t):t()}},[i]),v=(0,G.useCallback)(e=>{h.current++,m(e),g.current||(g.current=!0,r?.(e))},[r]),y=function(e,t,n,r,i=!0){let[a]=ht(),o=r??function(e){if(!fr)return;let t=e.getRootElement();if(t!==null){let e=t.getRootNode();return Wn(e)?e:t.ownerDocument.body}return document.body}(a),s=fr?kee(a.getRootElement()).createElement(`div`):null,c=(0,G.useRef)(s),l=(0,G.useCallback)(()=>{if(c.current===null||o===void 0)return;c.current.style.top=c.current.style.bottom;let t=a.getRootElement(),r=c.current,s=r.firstChild;if(t!==null&&e!==null){let{left:a,top:l,width:u,height:d}=e.getRect(),f=c.current.offsetHeight,p=function(e){let t=Wn(e)?e.host:e;for(let e=fe(t)?t:null;e!==null;e=ste(e)){let t=e.ownerDocument.defaultView;if(t===null)break;if(_tt(t.getComputedStyle(e))){let t=e.getBoundingClientRect();return{left:t.left+e.clientLeft-e.scrollLeft,top:t.top+e.clientTop-e.scrollTop}}}return null}(o),m=e=>p===null?e+window.pageXOffset:e-p.left,h=e=>p===null?e+(i?window.pageYOffset:0):e-p.top;if(r.style.top=`${h(l+f+3)}px`,r.style.left=`${m(a)}px`,r.style.height=`${d}px`,r.style.width=`${u}px`,s!==null){s.style.top=`${l}`;let e=s.getBoundingClientRect(),n=e.height,i=e.width,o=t.getBoundingClientRect();a+i>o.right&&(r.style.left=`${m(o.right-i)}px`),(l+n>window.innerHeight||l+n>o.bottom)&&l-o.top>n+d&&(r.style.top=`${h(l-n-d)}px`)}r.isConnected||(gtt(r,n),o.append(r)),r.setAttribute(`id`,`typeahead-menu`),t.setAttribute(`aria-controls`,`typeahead-menu`)}},[a,e,i,n,o]);(0,G.useEffect)(()=>{let t=a.getRootElement();return e!==null&&l(),()=>{t!==null&&t.removeAttribute(`aria-controls`);let e=c.current;e!==null&&e.isConnected&&(e.remove(),e.removeAttribute(`id`))}},[a,l,e]);let u=(0,G.useCallback)(n=>{e!==null&&(n||t(null))},[e,t]);return ptt(e,c.current,l,u),s!=null&&s===c.current&&(gtt(s,n),o?.append(s)),c}(p,(0,G.useCallback)(e=>{e===null?_():m(e)},[_]),s,l);return(0,G.useEffect)(()=>{let e=f.registerUpdateListener(()=>{f.read(`latest`,()=>{if(!f.isEditable())return void _();let e=()=>{f.isComposing()||_()},n=f._window||window,r=n.document.createRange(),i=kr(),a=function(e){let t=null;return e.read(`latest`,()=>{let e=kr();Jn(e)&&(t=function(e){let t=e.anchor;if(t.type!==`text`)return null;let n=t.getNode();if(!n.isSimpleText())return null;let r=t.offset;return n.getTextContent().slice(0,r)}(e))}),t}(f);if(!Jn(i)||!i.isCollapsed()||a===null||r===null)return void e();let s=o(a,f);if(t(s?s.matchingString:null),s!==null&&(d||!function(e,t){return t===0&&e.read(`latest`,()=>{let e=kr();if(Jn(e)){let t=e.anchor.getNode().getPreviousSibling();return it(t)&&t.isTextEntity()}return!1})}(f,s.leadOffset))&&function(e,t,n,r){let i=Te(n);if(i===null||!i.isCollapsed)return!1;let a=It(i,r),o=a.anchorNode,s=e,c=a.anchorOffset;if(o==null||c==null)return!1;try{t.setStart(o,s),t.setEnd(o,c)}catch{return!1}return!0}(s.leadOffset,r,n,f.getRootElement()))return void(0,G.startTransition)(()=>v({getRect:()=>r.getBoundingClientRect(),match:s}));e()})});return()=>{e()}},[f,o,t,p,_,v,d]),(0,G.useEffect)(()=>f.registerEditableListener(e=>{e||_()}),[f,_]),p===null||f===null||y.current===null?null:(0,K.jsx)(htt,{close:_,resolution:p,editor:f,anchorElementRef:y,options:e,menuRenderFn:a,shouldSplitNodeWithQuery:!0,onSelectOption:n,commandPriority:c,preselectFirstItem:u})}function M9(e){"@babel/helpers - typeof";return M9=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},M9(e)}function ytt(e,t){if(M9(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(M9(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function btt(e){var t=ytt(e,`string`);return M9(t)==`symbol`?t:t+``}function N9(e,t,n){return(t=btt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var xtt=class extends ltt{constructor(e,t){super(e),N9(this,`title`,void 0),N9(this,`icon`,void 0),N9(this,`description`,void 0),N9(this,`keywords`,void 0),N9(this,`section`,void 0),N9(this,`nested`,void 0),N9(this,`onSelect`,void 0),this.title=e,this.icon=t.icon,this.description=t.description??``,this.keywords=t.keywords??[],this.section=t.section??`Basic blocks`,this.nested=t.nested??!0,this.onSelect=t.onSelect}},Stt=20;function P9(e,t){let n=g9(e);return new xtt(n.title,{...t,icon:(0,G.createElement)(n.icon,{size:Stt}),description:t.description??n.description,section:D9e(n.group)})}function Ctt(){return[P9(`paragraph`,{keywords:[`paragraph`,`text`,`plain`],onSelect:e=>{e.update(()=>{let e=kr();Jn(e)&&ee(e,()=>on())})}}),P9(`h1`,{keywords:[`heading`,`h1`,`title`],onSelect:e=>{e.update(()=>{let e=kr();Jn(e)&&ee(e,()=>ae(`h1`))})}}),P9(`h2`,{keywords:[`heading`,`h2`,`subtitle`],onSelect:e=>{e.update(()=>{let e=kr();Jn(e)&&ee(e,()=>ae(`h2`))})}}),P9(`h3`,{keywords:[`heading`,`h3`],onSelect:e=>{e.update(()=>{let e=kr();Jn(e)&&ee(e,()=>ae(`h3`))})}}),P9(`quote`,{keywords:[`quote`,`blockquote`],onSelect:e=>{e.update(()=>{let e=kr();if(!Jn(e))return;let t=e.anchor.getNode().getTopLevelElementOrThrow(),n=xr(),r=on();r.append(...t.getChildren()),n.append(r),t.replace(n),r.selectEnd()})}}),P9(`divider`,{keywords:[`divider`,`hr`,`rule`,`separator`],onSelect:e=>{e.dispatchCommand(mA,void 0)}}),P9(`table`,{keywords:[`table`,`grid`],nested:!1,onSelect:e=>{e.dispatchCommand(lM,{columns:`3`,rows:`3`,includeHeaders:!0})}}),P9(`bullet`,{keywords:[`list`,`bullet`,`unordered`],onSelect:e=>{e.dispatchCommand(mt,void 0)}}),P9(`number`,{keywords:[`list`,`ordered`,`number`],onSelect:e=>{e.dispatchCommand(I,void 0)}}),P9(`check`,{keywords:[`task`,`todo`,`checkbox`,`checklist`],onSelect:e=>{e.dispatchCommand(dn,void 0)}})]}var wtt=`qolrkf0`,Ttt=`qolrkf1`,Ett=`qolrkf2`,Dtt=`qolrkf3`,Ott=`qolrkf5`,ktt=`qolrkf6`,Att=`qolrkf7`,jtt=`qolrkf8`,Mtt=`qolrkf9`,Ntt=`qolrkfa`,Ptt=`qolrkfc`;function Ftt(e){let t=[],n=new Map;return e.forEach((e,r)=>{let i=n.get(e.section);i||(i={label:e.section,items:[]},n.set(e.section,i),t.push(i)),i.items.push({item:e,globalIndex:r})}),t}function Itt(e,t){return`${e}-option-${t}`}function Ltt({className:e,escapeHint:t,id:n,items:r,onHighlight:i,onSelect:a,query:o,ref:s,selectedIndex:c,style:l,variant:u=`floating`}){let d=(0,G.useMemo)(()=>Ftt(r),[r]),f=[wtt,u===`embedded`?Ttt:``,e].filter(Boolean).join(` `);return(0,K.jsx)(`div`,{className:f,ref:s,style:l,children:r.length===0?(0,K.jsxs)(`div`,{className:Ptt,"data-slot":`slash-menu-empty`,role:`status`,children:[(0,K.jsx)(`span`,{children:o?`No blocks match “${o}”`:`No blocks`}),t&&(0,K.jsxs)(`span`,{className:`qolrkfd`,children:[(0,K.jsx)(ar,{keys:`Esc`,size:`sm`,tone:`muted`}),`keep as text`]})]}):(0,K.jsx)(`ul`,{className:Ett,id:n,role:`listbox`,children:d.map((e,t)=>(0,K.jsxs)(`li`,{className:Dtt,role:`presentation`,children:[t>0&&(0,K.jsx)(`div`,{className:`qolrkf4`}),(0,K.jsx)(`div`,{className:Ott,"data-slot":`slash-menu-section`,children:e.label}),(0,K.jsx)(`ul`,{"aria-label":e.label,className:ktt,role:`group`,children:e.items.map(({item:e,globalIndex:t})=>(0,K.jsxs)(`li`,{"aria-selected":t===c,className:Att,id:n?Itt(n,t):void 0,ref:e.setRefElement,role:`option`,tabIndex:-1,onClick:()=>a(e),onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>i(t),children:[(0,K.jsx)(`span`,{className:jtt,children:e.icon}),(0,K.jsxs)(`span`,{className:Mtt,children:[(0,K.jsx)(`span`,{className:Ntt,children:e.title}),e.description&&(0,K.jsx)(`span`,{className:`qolrkfb`,children:e.description})]})]},e.key))})]},e.label))})})}function Rtt({anchorElement:e,options:t,query:n=``,selectedIndex:r,selectOptionAndCleanUp:i,setHighlightedIndex:a}){let{refs:o,floatingStyles:s}=d({placement:`bottom-start`,strategy:`absolute`,middleware:[f(8),u({fallbackPlacements:[`top-start`],padding:8}),S({padding:8})],whileElementsMounted:h});return(0,G.useEffect)(()=>{o.setReference(e)},[e,o]),(0,K.jsx)(Ltt,{escapeHint:!0,items:t,query:n,ref:o.setFloating,selectedIndex:r,style:s,onHighlight:a,onSelect:i})}function ztt(e){return new xtt(e.title,{description:e.description,icon:(0,G.isValidElement)(e.icon)?e.icon:void 0,keywords:e.keywords,nested:e.nested,section:e.section,onSelect:e.onSelect})}function Btt(e){return _9(e.map(e=>({title:e.title,description:e.description||void 0,icon:e.icon,keywords:e.keywords,nested:e.nested,section:e.section,onSelect:e.onSelect}))).map(ztt)}function Vtt(e){return _9(BR(e).filter(e=>!e.placement||e.placement.includes(`slash`))).map(ztt)}function Htt(e,t){return Btt([...Ctt(),...Vtt(e),...t??[]])}function Utt(e,t){if(!e)return t;let n=e.toLowerCase();return t.filter(e=>e.title.toLowerCase().includes(n)?!0:e.keywords.some(e=>e.toLowerCase().includes(n)))}function Wtt({items:e,extraItems:t,nested:n,triggerChar:r=`/`}){let[i]=ht(),[a,o]=(0,G.useState)(null),s=(0,G.useMemo)(()=>{let r=e??Htt(i,t);return n?r.filter(e=>e.nested!==!1):r},[e,t,n,i]),c=(0,G.useMemo)(()=>Utt(a??``,s),[a,s]),l=ctt(r,{minLength:0}),u=(0,G.useCallback)((e,t,n,r)=>{i.update(()=>{if(t){let e=kr();Jn(e)&&t.remove()}}),n(),e.onSelect(i,r)},[i]);return(0,K.jsx)(vtt,{options:c,triggerFn:l,menuRenderFn:(e,{selectedIndex:t,selectOptionAndCleanUp:n,setHighlightedIndex:r},i)=>{let a=e.current;return a?(0,Gi.createPortal)((0,K.jsx)(Ye,{children:(0,K.jsx)(Rtt,{anchorElement:a,options:c,query:i,selectOptionAndCleanUp:n,selectedIndex:t,setHighlightedIndex:r})}),a):null},onQueryChange:o,onSelectOption:u})}var F9={editWrapper:`rich-katex-edit-wrapper`,panel:`rich-katex-editor-panel`,header:`rich-katex-editor-header`,tabs:`rich-katex-editor-tabs`,bodyScrollArea:`rich-katex-editor-body-scroll-area`,body:`rich-katex-editor-body`,textarea:`rich-katex-editor-textarea`,preview:`rich-katex-editor-preview`,previewEmpty:`rich-katex-editor-preview-empty`,snippetGroups:`rich-katex-editor-snippet-groups`,snippetGroup:`rich-katex-editor-snippet-group`,snippetGroupLabel:`rich-katex-editor-snippet-group-label`,snippetList:`rich-katex-editor-snippet-list`,snippetButton:`rich-katex-editor-snippet-button`,snippetMeta:`rich-katex-editor-snippet-meta`,snippetName:`rich-katex-editor-snippet-name`,snippetHint:`rich-katex-editor-snippet-hint`,snippetPreview:`rich-katex-editor-snippet-preview`,snippetsPlaceholder:`rich-katex-editor-snippets-placeholder`,footer:`rich-katex-editor-footer`,charCount:`rich-katex-editor-charcount`},Gtt=`mkenhu0`,Ktt=`mkenhu1`,qtt=`mkenhu2`,Jtt=`mkenhu3`;function Ytt(e,t={}){if(t.isDirty||e.altKey||!e.metaKey&&!e.ctrlKey)return null;let n=e.key.toLowerCase();return n===`z`?e.shiftKey?`redo`:`undo`:n===`y`&&e.ctrlKey&&!e.metaKey&&!e.shiftKey?`redo`:null}var I9=`__cursor__`,Xtt=[{id:`frac`,title:`Fraction`,template:`\\frac{1}{${I9}}`,previewEquation:`\\frac{a}{b}`,category:`Basic`,keywords:[`fraction`,`divide`,`ratio`]},{id:`sqrt`,title:`Square Root`,template:`\\sqrt{${I9}}`,previewEquation:`\\sqrt{x}`,category:`Basic`,keywords:[`root`,`radical`]},{id:`alpha`,title:`Alpha`,template:`\\alpha${I9}`,previewEquation:`\\alpha`,category:`Greek`,keywords:[`greek`,`letter`]},{id:`theta`,title:`Theta`,template:`\\theta${I9}`,previewEquation:`\\theta`,category:`Greek`,keywords:[`greek`,`angle`,`letter`]},{id:`sum`,title:`Summation`,template:`\\sum_{i=1}^{n} ${I9}`,previewEquation:`\\sum_{i=1}^{n} x_i`,category:`Operators`,keywords:[`series`,`sigma`,`total`]},{id:`int`,title:`Integral`,template:`\\int_{a}^{b} ${I9} \\, dx`,previewEquation:`\\int_{a}^{b} f(x) \\, dx`,category:`Operators`,keywords:[`integral`,`calculus`]},{id:`matrix`,title:`Matrix`,template:`\\begin{bmatrix}${I9}\\end{bmatrix}`,previewEquation:`\\begin{bmatrix} a & b \\\\ c & d \\end{bmatrix}`,category:`Structures`,keywords:[`array`,`linear algebra`]},{id:`cases`,title:`Cases`,template:`\\begin{cases}${I9}\\end{cases}`,previewEquation:`\\begin{cases} x & x > 0 \\\\ 0 & x = 0 \\end{cases}`,category:`Structures`,keywords:[`piecewise`,`conditional`]}];function Ztt(e){let t=e.trim().toLowerCase();return t?Xtt.filter(e=>[e.id,e.title,e.category,e.previewEquation,...e.keywords].join(` `).toLowerCase().includes(t)):Xtt}function Qtt(e,t,n,r){let i=n??e.length,a=r??i,o=t.indexOf(I9),s=t.replace(I9,``),c=e.slice(0,i)+s+e.slice(Math.max(i,a)),l=i+(o>=0?o:s.length);return{value:c,selectionStart:l,selectionEnd:l}}var $tt=[`Basic`,`Greek`,`Operators`,`Structures`],ent=[{value:`edit`,label:`Edit`},{value:`snippets`,label:`Snippets`}];function tnt({nodeKey:e,equation:t,displayMode:n,autoOpenOnMount:r,children:i}){let[a]=ht(),o=a.isEditable(),s=(0,G.useId)(),[c,l]=(0,G.useState)(r),[u,d]=(0,G.useState)(t),[f,p]=(0,G.useState)(`edit`),[m,h]=(0,G.useState)(``),g=(0,G.useRef)(null),_=(0,G.useRef)({start:null,end:null}),v=u!==t,y=(0,G.useCallback)(e=>{e&&(_.current={start:e.selectionStart,end:e.selectionEnd})},[]);(0,G.useEffect)(()=>{r&&a.update(()=>{let t=Dn(e);($N(t)||XN(t))&&t.setShouldAutoOpenOnMount(!1)})},[r,a,e]),(0,G.useEffect)(()=>{d(t)},[t]),(0,G.useEffect)(()=>{c&&g.current&&(g.current.focus(),g.current.select(),y(g.current))},[c,y]);let b=(0,G.useCallback)(()=>{d(t),p(`edit`),h(``),l(!1)},[t]),x=(0,G.useRef)(!1),S=(0,G.useCallback)(async()=>{if(!v)b();else if(!x.current){x.current=!0;try{await Se()&&b()}finally{x.current=!1}}},[b,v]),C=(0,G.useCallback)(()=>{let t=u.trim();t&&(a.update(()=>{let n=Dn(e);($N(n)||XN(n))&&n.getEquation()!==t&&n.setEquation(t)}),p(`edit`),h(``),l(!1))},[a,e,u]),w=(0,G.useCallback)(()=>{a.update(()=>{Dn(e)?.remove()}),Pe({title:n?`Math block deleted`:`Math deleted`,action:{label:`Undo`,onClick:()=>a.dispatchCommand(U,void 0)}})},[n,a,e]),T=(0,G.useCallback)(()=>{navigator.clipboard?.writeText(u).then(()=>Pe({title:`LaTeX copied`,tone:`success`}),()=>Pe({title:`Could not copy LaTeX`,tone:`error`}))},[u]),E=(0,G.useCallback)(e=>{let t=Qtt(u,e,_.current.start,_.current.end);d(t.value),p(`edit`),requestAnimationFrame(()=>{let e=g.current;e&&(e.focus(),e.setSelectionRange(t.selectionStart,t.selectionEnd),_.current={start:t.selectionStart,end:t.selectionEnd})})},[u]),D=(0,G.useMemo)(()=>Ztt(m),[m]),O=(0,G.useMemo)(()=>$tt.map(e=>({category:e,items:D.filter(t=>t.category===e)})).filter(e=>e.items.length>0),[D]),k=(0,G.useCallback)(e=>{e.key===`Escape`?(e.preventDefault(),S()):(n&&e.key===`Enter`&&(e.metaKey||e.ctrlKey)||!n&&e.key===`Enter`&&!e.shiftKey)&&(e.preventDefault(),C())},[S,C,n]),A=(0,G.useCallback)(e=>{let t=Ytt(e,{isDirty:v||m!==``});t&&(e.preventDefault(),e.stopPropagation(),a.dispatchCommand(t===`undo`?U:gt,void 0))},[v,a,m]);if(!o)return i;let j=(0,K.jsxs)(Zn,{children:[(0,K.jsx)(On,{render:(0,K.jsx)(Fe,{icon:!0,"aria-label":`More actions`,size:`md`}),children:(0,K.jsx)(Nr,{})}),(0,K.jsxs)(Rt,{align:`end`,children:[(0,K.jsxs)(Ut,{disabled:!u.trim(),onClick:T,children:[(0,K.jsx)(Ir,{}),`Copy LaTeX`]}),(0,K.jsx)(ur,{}),(0,K.jsxs)(Ut,{variant:`destructive`,onClick:w,children:[(0,K.jsx)(Mr,{}),`Delete`]})]})]});return(0,K.jsxs)(gn,{open:c,onOpenChange:(e,t)=>{e?l(!0):(t?.reason!==`outside-press`&&t?.reason!==`focus-out`||!v)&&(t?.reason===`escape-key`?S():b())},children:[(0,K.jsx)(en,{nativeButton:!1,render:(0,K.jsx)(`span`,{className:`${Gtt} ${F9.editWrapper}`,title:`Click to edit`}),children:i}),(0,K.jsxs)(yn,{flush:!0,className:`${Ktt} ${F9.panel}`,initialFocus:g,side:`bottom`,size:`lg`,onKeyDown:A,children:[(0,K.jsx)(wn,{className:F9.header,icon:(0,K.jsx)(Mi,{}),title:n?`Math block`:`Inline math`,actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(xt,{className:`${qtt} ${F9.tabs}`,items:ent,value:f,onChange:p}),j]})}),(0,K.jsxs)(`div`,{className:`${Jtt} ${F9.bodyScrollArea}`,children:[f===`edit`&&(0,K.jsxs)(Xn,{className:F9.body,children:[(0,K.jsx)(Kn,{id:s,label:`LaTeX`,children:(0,K.jsx)(`textarea`,{autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,className:`mkenhu4 ${F9.textarea}`,id:s,placeholder:`e.g. \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}`,ref:g,rows:n?4:2,spellCheck:!1,value:u,onClick:e=>y(e.currentTarget),onKeyDown:k,onKeyUp:e=>y(e.currentTarget),onSelect:e=>y(e.currentTarget),onChange:e=>{d(e.target.value),y(e.target)}})}),(0,K.jsx)(`div`,{"aria-label":`Preview`,className:`mkenhu5 ${F9.preview}`,role:`img`,children:u.trim()?(0,K.jsx)(cU,{displayMode:n,equation:u}):(0,K.jsx)(`span`,{className:`mkenhu6 ${F9.previewEmpty}`,children:`Preview appears as you type`})})]}),f===`snippets`&&(0,K.jsxs)(Xn,{className:F9.body,children:[(0,K.jsx)(ct,{"aria-label":`Search snippets`,autoComplete:`off`,placeholder:`Search snippets: frac, matrix, sum…`,value:m,onChange:e=>h(e.target.value)}),O.length>0?(0,K.jsx)(`div`,{className:`mkenhu7 ${F9.snippetGroups}`,children:O.map(e=>(0,K.jsxs)(`section`,{className:`mkenhu8 ${F9.snippetGroup}`,children:[(0,K.jsx)(`div`,{className:`mkenhu9 ${F9.snippetGroupLabel}`,children:e.category}),(0,K.jsx)(`div`,{className:`mkenhua ${F9.snippetList}`,children:e.items.map(e=>(0,K.jsxs)(`button`,{className:`mkenhub ${F9.snippetButton}`,type:`button`,onClick:()=>E(e.template),children:[(0,K.jsxs)(`span`,{className:`mkenhuc ${F9.snippetMeta}`,children:[(0,K.jsx)(`span`,{className:`mkenhud ${F9.snippetName}`,children:e.title}),(0,K.jsx)(`span`,{className:`mkenhue ${F9.snippetHint}`,children:e.template.replace(`__cursor__`,``)})]}),(0,K.jsx)(`span`,{className:`mkenhuf ${F9.snippetPreview}`,children:(0,K.jsx)(cU,{displayMode:!1,equation:e.previewEquation})})]},e.id))})]},e.category))}):(0,K.jsxs)(`div`,{className:`mkenhug ${F9.snippetsPlaceholder}`,children:[`No snippets match “`,m.trim(),`”`]})]})]}),(0,K.jsxs)(Bn,{className:F9.footer,hint:(0,K.jsx)(`span`,{className:F9.charCount,children:`${u.length} ${u.length===1?`character`:`characters`}`}),children:[(0,K.jsx)(Fe,{size:`md`,variant:`outline`,onClick:b,children:`Cancel`}),(0,K.jsxs)(Fe,{disabled:!u.trim(),size:`md`,variant:`solid`,onClick:C,children:[`Save`,(0,K.jsx)(ar,{keys:n?[`mod`,`enter`]:[`enter`],size:`sm`,tone:`inverted`})]})]})]})]})}var nnt=[class e extends JN{static clone(t){return new e(t.__equation,t.__key,t.getShouldAutoOpenOnMount())}static importJSON(t){return new e(t.equation).updateFromJSON(t)}decorate(e,t){let n=qj(`KaTeX`,cU,{equation:this.__equation,displayMode:!0});return(0,G.createElement)(tnt,{nodeKey:this.__key,equation:this.__equation,displayMode:!0,autoOpenOnMount:this.getShouldAutoOpenOnMount(),children:n})}},class e extends ZN{static clone(t){return new e(t.__equation,t.__key,t.getShouldAutoOpenOnMount(),t.__color)}static importJSON(t){let n=t,r=new e(n.equation);return n.color&&r.setColor(n.color),r.updateFromJSON(t)}decorate(e,t){let n=qj(`KaTeX`,cU,{equation:this.__equation,displayMode:!1}),r=(0,G.createElement)(tnt,{nodeKey:this.__key,equation:this.__equation,displayMode:!1,autoOpenOnMount:this.getShouldAutoOpenOnMount(),children:n});return this.__color?(0,G.createElement)(`span`,{style:{color:this.__color}},r):r}}],rnt=`agent-stream-hidden`,L9=[`agent-stream-fade-1`,`agent-stream-fade-2`,`agent-stream-fade-3`],int=22,ant=()=>typeof Highlight<`u`&&typeof CSS<`u`&&!!CSS.highlights,ont=e=>e?document.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode():null;function R9(e,t,n,r){return e.getEditorState().read(()=>{let i=Dn(t);if(!rr(i))return null;let a=document.createRange(),o=0,s=!1;for(let t of i.getAllTextNodes()){let i=t.getTextContentSize(),c=ont(e.getElementByKey(t.getKey()));if(!s&&n<=o+i){if(!c)return null;a.setStart(c,Math.min(n-o,c.length)),s=!0}if(s&&r<=o+i)return c?(a.setEnd(c,Math.min(r-o,c.length)),a):null;o+=i}return null})}var snt=e=>{let t=e?.getClientRects?.();return t?Array.from(t).at(-1)??null:null};function cnt(e,t){if(t.kind===`block`){let n=e.getElementByKey(t.blockKey)?.getBoundingClientRect();return n?{left:n.left,top:n.bottom-int,height:int}:null}if(t.offset>0){let n=snt(R9(e,t.blockKey,t.offset-1,t.offset));if(n)return{left:n.right,top:n.top,height:n.height}}let n=R9(e,t.blockKey,t.offset,t.offset+1)?.getClientRects?.()[0];return n?{left:n.left,top:n.top,height:n.height}:null}var z9=new Map;function B9(e,t,n){let r=z9.get(t)??new Map;z9.set(t,r),n.length>0?r.set(e,n):r.delete(e);let i=[...r.values()].flat();i.length>0?CSS.highlights.set(t,new Highlight(...i)):CSS.highlights.delete(t)}function lnt(e){for(let t of z9.keys())B9(e,t,[])}function unt(e){for(let t=e.parentElement;t;t=t.parentElement){let{overflowY:e}=getComputedStyle(t);if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t}return document.scrollingElement??document.documentElement}var dnt=e=>yr(e)||_r(e)||Er(e),V9=e=>rr(e)?e.getAllTextNodes().map(e=>e.getTextContent()).join(``):``;function fnt(e){return e.read(()=>{let e=new Map;for(let t of Sr().getChildren())e.set(t.getKey(),{isText:dnt(t),text:V9(t)});return e})}function pnt(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;let i=0;for(;i<n-r&&e[e.length-1-i]===t[t.length-1-i];)i++;return{from:r,to:t.length-i}}function mnt(e,t){let n=fnt(e);return t.read(()=>{let e=[];for(let t of Sr().getChildren()){let r=t.getKey(),i=n.get(r);if(!dnt(t)){i||e.push({kind:`block`,blockKey:r});continue}let a=V9(t),o=i?.isText?i.text:``;if(a===o)continue;let{from:s,to:c}=pnt(o,a);c>s&&e.push({kind:`text`,blockKey:r,from:s,to:c,text:a})}return e})}var H9=1e-9,hnt=e=>e.kind===`text`?e.to-e.from:1,gnt=e=>e.segment.kind===`text`?{kind:`text`,blockKey:e.segment.blockKey,offset:e.segment.from+Math.floor(e.progress)}:{kind:`block`,blockKey:e.segment.blockKey};function _nt(e){let t=[],n=null,r=e=>{e.progress=e.size,n=gnt(e)},i=()=>{t=t.filter(e=>e.progress<e.size-H9)},a=e=>{if(e.kind!==`text`)return!1;let n=t.filter(t=>t.segment.blockKey===e.blockKey),i=n.length===1?n[0]:void 0;if(i?.segment.kind!==`text`){for(let e of n)r(e);return!1}let a=i.segment,o=a.from+Math.floor(i.progress);if(e.from<o)return r(i),!1;if(e.from>a.to)return!1;let s=a.to+e.text.length-a.text.length,c=Math.max(e.to,s);return i.segment={...a,to:c,text:e.text},i.size=c-a.from,!0},o=()=>t.reduce((e,t)=>e+(t.size-t.progress)/t.rate,0);return{enqueue(n){if(n.length===0)return;let{backlogSeconds:s,charsPerSecond:c,maxSeconds:l}=e(),u=n.reduce((e,t)=>e+hnt(t),0),d=Math.max(c,u/l);if(o()+u/d>s+H9){for(let e of t)r(e);t=[]}for(let e of n)a(e)||t.push({progress:0,rate:d,segment:e,size:hnt(e)});i()},advance(e){let a=e;for(let e of t){if(a<=0)break;let t=(e.size-e.progress)/e.rate;a+H9>=t?(a-=t,r(e)):(e.progress+=e.rate*a,a=0,e.progress>=1&&(n=gnt(e)))}i()},finish(){t=[],n=null},invalidate(e){for(let n of t)n.segment.blockKey===e&&r(n);i()},snapshot(){return{caret:n,idle:t.length===0,pending:t.map(e=>({revealed:Math.floor(e.progress+H9),segment:e.segment}))}}}}var vnt=2,ynt=48,bnt=.1,xnt=e=>{if(!e)return null;let{segment:t}=e;return t.kind===`text`?{kind:`text`,blockKey:t.blockKey,offset:t.to}:{kind:`block`,blockKey:t.blockKey}},Snt=(e,t)=>e===t||!!e&&!!t&&e.kind===t.kind&&e.blockKey===t.blockKey&&(e.kind===`block`||e.offset===t.offset);function Cnt(e,t){if(!ant())return{dispose:()=>{}};let n={},r=_nt(t),i=new Set,a=0,o=0,s=!0,c=!1,l=null,u=null,d=e=>t().onPlaybackChange?.(e),f=e=>{e&&!Snt(e,u)&&(u=e,t().onCaret?.(e))},p=(t,n)=>{let r=e.getElementByKey(t);r&&(r.style.visibility=n?`hidden`:``),n?i.add(t):i.delete(t)},m=n=>{let r=e.getRootElement();if(!s||!r)return;let i=t().scrollContainer??unt(r),a=i===document.scrollingElement?window.innerHeight:i.getBoundingClientRect().bottom,o=n.top+n.height+ynt-a;o>0&&(i.scrollTop+=o)},h=()=>{let{pending:t,caret:a}=r.snapshot(),o=[],s=L9.map(()=>[]),u=new Set;t.forEach(({segment:t,revealed:n},r)=>{if(t.kind===`block`){n<1&&u.add(t.blockKey);return}let i=t.from+n,a=R9(e,t.blockKey,i,t.to);a&&o.push(a),r===0&&n!==0&&L9.forEach((n,r)=>{let a=i-r*vnt,o=Math.max(t.from,a-vnt),c=a>o?R9(e,t.blockKey,o,a):null;c&&s[r].push(c)})});for(let e of i)u.has(e)||p(e,!1);for(let e of u)p(e,!0);B9(n,rnt,o),L9.forEach((e,t)=>B9(n,e,s[t]));let h=a?.blockKey??t[0]?.segment.blockKey??null;h!==l&&c&&(l=h,d({playing:!0,blockKey:h})),f(a);let g=a?cnt(e,a):null;g&&m(g)},g=()=>{cancelAnimationFrame(a),a=0;let e=xnt(r.snapshot().pending.at(-1))??r.snapshot().caret;r.finish();let t=c;c=!1,l=null,h(),lnt(n),f(e),t&&d({playing:!1,blockKey:null})},_=e=>{r.advance(Math.min(bnt,(e-o)/1e3)),o=e,h(),r.snapshot().idle?g():a=requestAnimationFrame(_)},v=()=>{let{pending:t}=r.snapshot();e.getEditorState().read(()=>{for(let{segment:e}of t){if(e.kind!==`text`)continue;let t=Dn(e.blockKey);t&&V9(t)===e.text||r.invalidate(e.blockKey)}})},y=e.registerUpdateListener(({tags:e,prevEditorState:t,editorState:n,dirtyElements:i,dirtyLeaves:u})=>{let d=i.size>0||u.size>0,f=e.has(X5e);f&&r.enqueue(mnt(t,n)),d&&(c||f)&&v(),f&&!r.snapshot().idle?(s=!0,c||(c=!0,l=null),h(),a||=(o=performance.now(),requestAnimationFrame(_))):c&&(r.snapshot().idle?g():h())}),b=()=>{s=!1},x=e.registerRootListener((e,t)=>{for(let n of[`keydown`,`paste`,`pointerdown`])t?.removeEventListener(n,g),e?.addEventListener(n,g)}),S=()=>{document.visibilityState===`hidden`&&c&&g()};return window.addEventListener(`wheel`,b,{passive:!0}),window.addEventListener(`touchmove`,b,{passive:!0}),document.addEventListener(`visibilitychange`,S),{dispose(){c&&d({playing:!1,blockKey:null}),c=!1,cancelAnimationFrame(a);for(let e of i)p(e,!1);lnt(n),y(),x(),window.removeEventListener(`wheel`,b),window.removeEventListener(`touchmove`,b),document.removeEventListener(`visibilitychange`,S)}}}var wnt=1e4,Tnt=3e5,Ent=3,Dnt=26,U9={closed:!1,eyeShift:0,legs:`stand`,lift:0,scaleX:1,scaleY:1},W9={blink:130,double:320,look:1100,lookAway:900,hop:360,tap:660,stretch:640},Ont=[[`blink`,3],[`double`,1],[`look`,2],[`lookAway`,1],[`hop`,2],[`tap`,1],[`stretch`,1]],knt=[[`blink`,3],[`look`,1],[`lookAway`,1]],Ant=[800,2400],jnt=[2200,4600],Mnt=e=>e>=30;function Nnt(e,t){if(e===null)return`writing`;let n=t-e;return n<wnt?`fresh`:n<Tnt?`quiet`:`resting`}function Pnt({fromBottom:e,toBottom:t,hidden:n}){return Math.abs(t-e)<=Ent?`none`:n?`drop`:`arc`}function Fnt(e,t,n){if(e.x<=t)return{x:t,v:0};let r=Dnt,i=1+2*n*r,a=n*r*r,o=1/(i+n*a);return{x:(i*e.x+n*e.v+n*a*t)*o,v:(e.v+a*(t-e.x))*o}}function Int(e,t){let n=e===`resting`,r=n?knt:Ont,i=r.reduce((e,[,t])=>e+t,0),a=t()*i,o=r.at(-1)[0];for(let[e,t]of r)if(a-=t,a<0){o=e;break}let[s,c]=n?jnt:Ant;return{action:o,waitMs:W9[o]+s+(c-s)*t()}}function Lnt(e,t){if(t<0||t>=W9[e])return U9;let n=t/W9[e];switch(e){case`blink`:return{...U9,closed:!0};case`double`:return{...U9,closed:t<100||t>200&&t<300};case`look`:return{...U9,eyeShift:t>80&&t<1020?-1:0};case`lookAway`:return{...U9,eyeShift:+(t>80&&t<820)};case`tap`:return{...U9,legs:Math.floor(t/110)%2?`stepA`:`stepB`};case`stretch`:{let e=Math.sin(Math.PI*n);return{...U9,scaleX:1-.07*e,scaleY:1+.12*e}}case`hop`:return n<.18?{...U9,scaleX:1.12,scaleY:.86}:{...U9,legs:`tucked`,lift:9*Math.sin(Math.PI*(n-.18)/.82),scaleX:.95,scaleY:1.07}}}var Rnt={stand:[2,2,2,2],tucked:[1,1,1,1],stepA:[2,1,2,1],stepB:[1,2,1,2]},znt=[3,5,10,12],Bnt=[4,11],Vnt=e=>Rnt[e].map((e,t)=>`M${znt[t]} 8h1v${e}h-1z`).join(``),Hnt=new WeakMap;function Unt(e){let t=Hnt.get(e);if(t)return t;let n=e.querySelector(`[data-part="bob"]`),r=e.querySelector(`[data-part="shadow"]`),i=e.querySelector(`[data-part="legs"]`),a=[...e.querySelectorAll(`[data-part="eye"]`)];if(!n||!r||!i||a.length!==2)return null;let o={bob:n,shadow:r,legs:i,eyes:a};return Hnt.set(e,o),o}function Wnt(e,{x:t,bottom:n,appear:r,sink:i,pose:a}){let o=Unt(e);if(!o)return;let s=.55+.45*r;e.style.opacity=r.toFixed(3),e.style.transform=`translate(${t.toFixed(2)}px, ${(n-15).toFixed(2)}px)`,o.bob.style.transform=`translateY(${(i-a.lift).toFixed(2)}px) scale(${(a.scaleX*s).toFixed(3)}, ${(a.scaleY*s).toFixed(3)})`;let c=1-Math.min(a.lift,16)/26;o.shadow.style.transform=`scaleX(${c.toFixed(3)})`,o.shadow.style.opacity=(.12*c).toFixed(3);let l=Vnt(a.legs);o.legs.getAttribute(`d`)!==l&&o.legs.setAttribute(`d`,l),o.eyes.forEach((e,t)=>{e.setAttribute(`x`,String(Bnt[t]+a.eyeShift)),e.setAttribute(`y`,a.closed?`3`:`2`),e.setAttribute(`height`,a.closed?`1`:`2`)})}var Gnt=`M2 0h12v2h-12zM2 2h12v2h-12zM0 4h16v2h-16zM2 6h12v1h-12z`,Knt=`M2 7h12v1h-12z`;function qnt({fill:e,ref:t}){let n=`color-mix(in srgb, ${e} 86%, ${Vr.black})`;return(0,K.jsxs)(`div`,{"aria-hidden":`true`,"data-agent-pet":``,ref:t,className:`x10l6tqk xu96u03 x13vifvy xvy4d1p xx3o462 x47corl xg01cxk`,children:[(0,K.jsx)(`span`,{"data-part":`shadow`,className:`x10l6tqk xcqyyxr x1pzoy33 x1t1qrwb xuoj239 x16rqkct x1t58bn5 xuo7x8y`}),(0,K.jsx)(`div`,{"data-part":`bob`,className:`x10l6tqk x10a8y8t xqlk7fu x1so62im`,children:(0,K.jsxs)(`svg`,{height:15,shapeRendering:`crispEdges`,viewBox:`0 0 16 10`,width:24,className:`x1lliihq x1rea2x4`,children:[(0,K.jsx)(`path`,{d:Gnt,style:{fill:e}}),(0,K.jsx)(`path`,{d:Knt,style:{fill:n}}),(0,K.jsx)(`path`,{d:Vnt(`stand`),"data-part":`legs`,style:{fill:n}}),(0,K.jsx)(`rect`,{"data-part":`eye`,fill:Vr.black,height:`2`,width:`1`,x:`4`,y:`2`}),(0,K.jsx)(`rect`,{"data-part":`eye`,fill:Vr.black,height:`2`,width:`1`,x:`11`,y:`2`})]})})]})}var Jnt=2,Ynt=300,Xnt=2.4,Znt=16,Qnt=300,$nt=150,ert=e=>e*e*(3-2*e);function trt({agent:e,caret:t,editor:n,stoppedAt:r}){let i=pne(e),a=i.mascot===`clawd`,[o,s]=(0,G.useState)(()=>Nnt(r,performance.now())),c=(0,G.useRef)(null),l=(0,G.useRef)(null),u=(0,G.useRef)(null),d=(0,G.useRef)(null),f=(0,G.useRef)({caret:t,stoppedAt:r,withPet:a});return(0,G.useLayoutEffect)(()=>{f.current={caret:t,stoppedAt:r,withPet:a}},[t,r,a]),(0,G.useEffect)(()=>{let e=matchMedia(`(prefers-reduced-motion: reduce)`),t=0,r=null,i=a=>{t=requestAnimationFrame(i);let o=c.current,p=f.current,m=l.current,h=u.current,g=cnt(n,p.caret),_=n.getElementByKey(p.caret.blockKey);if(!o||!m||!g||!_){m&&(m.style.opacity=`0`),h&&(h.style.opacity=`0`);return}let v=o.getBoundingClientRect(),y=g.left-v.left,b=g.top-v.top;m.style.opacity=``,m.style.transform=`translate(${y}px, ${b}px)`,m.style.height=`${g.height}px`;let x=Nnt(p.stoppedAt,a);if(x!==r&&(r=x,s(x)),!p.withPet||!h)return;let S=Mnt(_.getBoundingClientRect().right-(Number.parseFloat(getComputedStyle(_).paddingRight)||0)-(g.left+Jnt)),C=y+Jnt+6,w=b+g.height,T=e.matches,E=d.current??={appear:0,bottom:w,hidden:!S,idle:null,jump:null,landAt:-1/0,last:a,movedAt:-1/0,nextIdleAt:a+700,phase:0,targetX:C,v:0,x:C},D=Math.min(.05,(a-E.last)/1e3);E.last=a,Math.abs(C-E.targetX)>.5&&(E.movedAt=a),E.targetX=C;let O=U9,k=E.jump?`none`:Pnt({fromBottom:E.bottom,toBottom:w,hidden:E.hidden});if(T)E.x=C,E.v=0,E.bottom=w;else if(k===`drop`)E.x=C,E.v=0,E.appear=0,E.jump={at:a,drop:!0,duration:Qnt,fromBottom:E.bottom,fromX:C};else if(k===`arc`){let e=Math.hypot(C-E.x,w-E.bottom);E.jump={at:a,drop:!1,duration:Math.min(560,320+e*.4),fromBottom:E.bottom,fromX:E.x}}if(!T&&E.jump){let e=E.jump,t=Math.min(1,(a-e.at)/e.duration);if(e.drop)({x:E.x,v:E.v}=Fnt(E,C,D)),E.bottom=e.fromBottom+(w-e.fromBottom)*t*t,O={...U9,legs:`tucked`,scaleX:.94,scaleY:1.08};else{let n=ert(t);E.x=e.fromX+(C-e.fromX)*n,E.bottom=e.fromBottom+(w-e.fromBottom)*n,O={...U9,legs:`tucked`,lift:Znt*Math.sin(Math.PI*t),scaleX:.94,scaleY:1.08}}t>=1&&(E.jump=null,E.landAt=a)}else T||({x:E.x,v:E.v}=Fnt(E,C,D),E.bottom=w);E.hidden=!S,E.appear=T?+!!S:E.appear+(+!!S-E.appear)*(1-Math.exp(-D/.06));let A=x===`writing`;if(!T&&!E.jump){if(A&&(a-E.movedAt<240||Math.abs(E.v)>25)){E.phase+=D*Math.PI*2*1e3/Ynt;let e=Math.sin(E.phase),t=Math.abs(e)<.3;O={...U9,legs:e>0?`stepA`:`stepB`,lift:Xnt*Math.abs(e),scaleX:t?1.06:1,scaleY:t?.92:1}}else E.phase=0;if(!A&&S){if(a>=E.nextIdleAt){let e=Int(x,Math.random);E.idle={action:e.action,at:a},E.nextIdleAt=a+e.waitMs}if(E.idle){let e=a-E.idle.at;O=Lnt(E.idle.action,e),e>=W9[E.idle.action]&&(E.idle.action===`hop`&&(E.landAt=a),E.idle=null)}let e=.5-.5*Math.cos(a/(x===`resting`?3400:2600)*Math.PI*2);O={...O,scaleX:O.scaleX*(1+.02*e),scaleY:O.scaleY*(1-.035*e)}}}A&&(O={...O,eyeShift:-1});let j=(a-E.landAt)/$nt;if(!T&&j<1){let e=1-j;O={...O,scaleX:O.scaleX*(1+.14*e),scaleY:O.scaleY*(1-.18*e)}}let M=x===`resting`&&!E.jump;M&&(O={...O,legs:`tucked`}),T&&(O={...U9,legs:M?`tucked`:`stand`}),Wnt(h,{x:E.x,bottom:E.bottom,appear:E.appear,sink:M?1.5:0,pose:O})};return t=requestAnimationFrame(i),()=>cancelAnimationFrame(t)},[n]),(0,K.jsxs)(`div`,{"data-agent-caret":``,ref:c,className:`x10l6tqk x10a8y8t x1u8a7rm x47corl`,children:[(0,K.jsx)(`div`,{ref:l,...{0:{className:`x10l6tqk xu96u03 x13vifvy xfo62xy x1nj7uno xqz5vs7`},2:{className:`x10l6tqk xu96u03 x13vifvy xfo62xy x1nj7uno xqz5vs7 x1vrnivm x7tkt5m x1htlvfj xa4qsjk x1aquc0h`},1:{className:`x10l6tqk xu96u03 x13vifvy xfo62xy x1nj7uno xqz5vs7 x18km98s`},3:{className:`x10l6tqk xu96u03 x13vifvy xfo62xy x1nj7uno xqz5vs7 x1vrnivm x7tkt5m x1htlvfj xa4qsjk x1aquc0h x18km98s`}}[(o===`writing`||o===`fresh`)<<1|(o===`quiet`||o===`resting`)],style:{backgroundColor:i.color}}),a?(0,K.jsx)(qnt,{fill:i.color,ref:u}):null]})}var nrt=/^\s*(\d+(?:\.\d+)*)[.、)\s]/;function rrt(e,t){for(let n=Math.min(t,e.length-1);n>=0;n--){let t=e[n];if(!t.heading)continue;let r=nrt.exec(t.text)?.[1];return r?`§${r}`:`「${t.text.trim()}」`}return null}function irt(e,t){return e.getEditorState().read(()=>{let e=Dn(t)?.getTopLevelElement(),n=Sr().getChildren().map(e=>({heading:e.getType()===`heading`,text:rr(e)?e.getTextContent():``}));return e?rrt(n,e.getIndexWithinParent()):null})}function art({agent:e=`Agent`,onPlayback:t}){let[n]=ht(),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(null),l=(0,G.useRef)(t),u=(0,G.useRef)(null);return(0,G.useLayoutEffect)(()=>{l.current=t,u.current=r?.blockKey??null},[t,r]),(0,G.useEffect)(()=>n.registerRootListener(e=>c(e?.parentElement??null)),[n]),(0,G.useEffect)(()=>Cnt(n,()=>({backlogSeconds:6,charsPerSecond:80,maxSeconds:3,scrollContainer:null,onCaret:i,onPlaybackChange:({playing:e,blockKey:t})=>{o(e?null:performance.now()),l.current({playing:e,section:e&&t?irt(n,t):null})}})).dispose,[n]),(0,G.useEffect)(()=>n.registerUpdateListener(({tags:e,dirtyElements:t})=>{let n=u.current;!n||e.has(`agent-write`)||e.has(`collab`)||t.has(n)&&i(null)}),[n]),!r||!s?null:(0,Gi.createPortal)((0,K.jsx)(trt,{agent:e,caret:r,editor:n,stoppedAt:a}),s)}var ort=class e extends wr{__url;__props;__initialHeight;static getType(){return`dynamic`}static clone(t){return new e(t.__url,t.__props,t.__initialHeight,t.__key)}static importJSON(t){return new e(t.url,t.props,t.initialHeight).updateFromJSON(t)}constructor(e=``,t={},n=320,r){super(r),this.__url=e,this.__props=t,this.__initialHeight=n}exportJSON(){return{...super.exportJSON(),type:`dynamic`,version:1,url:this.__url,props:this.__props,initialHeight:this.__initialHeight}}createDOM(){return document.createElement(`div`)}updateDOM(){return!1}isInline(){return!1}decorate(){return(0,K.jsx)(u7e,{componentProps:this.__props,initialHeight:this.__initialHeight,url:this.__url})}},srt=(0,G.createContext)(null);function crt({nodeKey:e,intent:t}){let n=(0,G.useContext)(srt),r=n?.activity,a=n?.nextKey===e&&r===`working`;return(0,K.jsx)(`div`,{"data-next":a?`true`:void 0,"data-pending":``,title:i(`document.pending`),className:`x78zum5 x167g77z x1jp4ehj x87ps6o x1jvydc1 xa7kkou`,children:(0,K.jsxs)(`p`,{style:{margin:0},children:[(0,K.jsx)(`span`,{...{0:{className:`xddlp02`},1:{className:`x1t0mqxc xphioz4 x19hqrfe x1ta4xzc x1t23j8t x19co3pv xo64yqm x1ajuw05 x1aquc0h xius3t x1esw782 xa4qsjk`}}[!!a|0],children:t||i(`document.pending`)}),a?(0,K.jsxs)(`span`,{"aria-hidden":!0,"data-caret":``,className:`x1n2onr6 x1rg5ohu xfo62xy x1q3kd3q x1swdo50 x1pv9cyz`,children:[(0,K.jsx)(`span`,{className:`x10l6tqk x10a8y8t x1nj7uno x15az74h x1vrnivm x1aquc0h xr7ufhj x1htlvfj xa4qsjk`}),(0,K.jsx)(`span`,{className:`x10l6tqk x10w3d4m xu96u03 xjpr12u xfn1xvj x18zih8k xhbn7t3 x6l8oc8 x1k6wstc x1s688f x37zpob xuxw1ft`,children:n.agent})]}):null]})})}var lrt=class e extends wr{__intent;static getType(){return`pending`}static clone(t){return new e(t.__intent,t.__key)}static importJSON(t){return new e(t.intent).updateFromJSON(t)}constructor(e=``,t){super(t),this.__intent=e}exportJSON(){return{...super.exportJSON(),type:`pending`,version:1,intent:this.__intent}}createDOM(){return document.createElement(`div`)}updateDOM(){return!1}isInline(){return!1}decorate(){return(0,K.jsx)(crt,{intent:this.__intent,nodeKey:this.getKey()})}};function urt(e){if(_r(e)){let t=e.getTag();return t===`h1`||t===`h2`||t===`h3`?t:`other`}if(nr(e)){let t=e.getListType();return t===`bullet`?`bullet`:t===`number`?`number`:t===`check`?`check`:`other`}if(Er(e))return`quote`;let t=e.getType();return t===`paragraph`?`paragraph`:t===`code`?`code`:`other`}function drt(e,t){t===`bullet`?e.dispatchCommand(mt,void 0):t===`number`?e.dispatchCommand(I,void 0):t===`check`?e.dispatchCommand(dn,void 0):e.update(()=>{let n=kr();Jn(n)&&(t===`paragraph`||t===`other`?ee(n,()=>on()):t===`h1`||t===`h2`||t===`h3`?ee(n,()=>ae(t)):t===`quote`?ee(n,()=>xr()):t===`code`&&prt(e,n))})}function frt(e){return e._nodes.get(`code-block`)?.klass??null}function prt(e,t){let n=frt(e);if(!n)return;let r=[...new Set(t.getNodes().concat(t.anchor.getNode()).map(e=>e.getTopLevelElement()).filter(e=>e!==null))];if(r.length===0)return;let i=r.map(e=>e.getTextContent()).join(`
|
|
397
|
-
`);r[0].replace(new n(i,`text`));for(let e of r.slice(1))e.remove()}function mrt(e,t){e.update(()=>{let e=kr();Jn(e)&&_t(e,{"font-family":t||``})})}var G9=[{label:`默认`,value:``},{label:`宋体`,value:`"Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif`},{label:`黑体`,value:`"Noto Sans CJK SC", "Source Han Sans SC", SimHei, sans-serif`},{label:`楷体`,value:`KaiTi, STKaiti, serif`},{label:`Sans`,value:`system-ui, -apple-system, sans-serif`},{label:`Serif`,value:`Georgia, "Times New Roman", serif`},{label:`Mono`,value:`ui-monospace, "SF Mono", "Fira Code", monospace`}];function hrt(e){if(!e)return`默认`;let t=G9.find(t=>t.value===e);if(t)return t.label;for(let t of G9)if(t.value&&e.startsWith(t.value.split(`,`)[0]))return t.label;return`默认`}var grt=w9e,_rt=Object.fromEntries([...grt.map(e=>[e,g9(e).title]),[`other`,`Other`]]),vrt=`_1e1ersc0`,yrt=`_1e1ersc1`,K9=`_1e1ersc2`,brt=`_1e1ersc3`,xrt=`_1e1ersc4`,Srt=`_1e1ersc5`,Crt=`_1e1ersc6`,wrt=`_1e1ersc7`,Trt=`_1e1ersc8`,Ert=`_1e1ersc9`;function Drt({icon:e,title:t,shortcut:n,active:r,disabled:i,onClick:a,tooltipHandle:o}){let s=(0,K.jsx)(`button`,{"aria-label":t,"aria-pressed":r,className:`${K9}${r?` ${brt}`:``}`,disabled:i,type:`button`,onClick:a,onMouseDown:e=>e.preventDefault()});return o?(0,K.jsx)(tt,{handle:o,payload:{title:t,shortcut:n},render:s,children:e}):(0,K.jsxs)(Mn,{children:[(0,K.jsx)(tt,{render:s,children:e}),(0,K.jsx)(Fn,{shortcut:n,side:`bottom`,sideOffset:4,children:t})]})}function Ort({label:e,title:t,items:n,triggerWidth:r,tooltipHandle:i}){let a=(0,K.jsx)(On,{className:xrt,render:(0,K.jsx)(`button`,{type:`button`}),style:r?{width:r}:void 0}),o=(0,K.jsxs)(K.Fragment,{children:[e,(0,K.jsx)(`span`,{className:Srt,children:(0,K.jsx)(m,{size:14})})]}),s=n.find(e=>e.active)?.label??null,c=(0,K.jsx)(Rt,{sideOffset:4,children:(0,K.jsx)(M,{value:s,children:n.map(e=>(0,K.jsxs)(pn,{closeOnClick:!0,style:e.style,value:e.label,onClick:e.onSelect,children:[e.icon,e.label]},e.label))})});return i?(0,K.jsxs)(Zn,{children:[(0,K.jsx)(tt,{handle:i,payload:{title:t},render:a,children:o}),c]}):(0,K.jsxs)(Zn,{children:[(0,K.jsxs)(Mn,{children:[(0,K.jsx)(tt,{render:a,children:o}),(0,K.jsx)(Fn,{side:`bottom`,sideOffset:4,children:t})]}),c]})}function krt(e,t){let n=frt(e)!==null;return grt.filter(e=>e!==`code`||n||t===`code`).map(n=>{let r=g9(n);return{label:r.title,icon:(0,G.createElement)(r.icon,{size:16}),active:t===n,onSelect:()=>drt(e,n)}})}function Art(){return(0,K.jsx)(`div`,{className:Crt})}var jrt=13;function q9(e){return{key:e,node:(0,K.jsx)(Art,{},e),separator:!0,width:jrt}}function Mrt(e,t){return{key:e.key,width:28,menu:{items:[e]},node:(0,K.jsx)(Drt,{active:e.active,disabled:e.disabled,icon:e.icon,shortcut:e.shortcut,title:e.label,tooltipHandle:t,onClick:e.onSelect},e.key)}}function Nrt(e,t,n){return{key:e,width:t.width,menu:{label:t.title,items:t.items.map(e=>({...e,onSelect:e.onSelect}))},node:(0,K.jsx)(Ort,{items:t.items,label:t.label,title:t.title,tooltipHandle:n,triggerWidth:t.width},e)}}var J9=e=>(0,K.jsx)(e,{size:16,strokeWidth:2});function Prt(e,t){let n=t=>()=>e.dispatchCommand(ye,t),r=t=>()=>e.dispatchCommand(cn,t);return[[{key:`undo`,label:`Undo`,icon:J9(Xne),shortcut:`Mod+Z`,disabled:!t.canUndo,onSelect:()=>e.dispatchCommand(U,void 0)},{key:`redo`,label:`Redo`,icon:J9(Une),shortcut:`Mod+Shift+Z`,disabled:!t.canRedo,onSelect:()=>e.dispatchCommand(gt,void 0)}],[{key:`bold`,label:`Bold`,icon:J9(Kte),shortcut:`Mod+B`,active:t.isBold,onSelect:n(`bold`)},{key:`italic`,label:`Italic`,icon:J9(Jte),shortcut:`Mod+I`,active:t.isItalic,onSelect:n(`italic`)},{key:`underline`,label:`Underline`,icon:J9(Hte),shortcut:`Mod+U`,active:t.isUnderline,onSelect:n(`underline`)},{key:`strikethrough`,label:`Strikethrough`,icon:J9(Dt),active:t.isStrikethrough,onSelect:n(`strikethrough`)},{key:`code`,label:`Inline code`,icon:J9(Pr),active:t.isCode,onSelect:n(`code`)}],[{key:`highlight`,label:`Highlight`,icon:J9(jt),active:t.isHighlight,onSelect:n(`highlight`)},{key:`spoiler`,label:`Spoiler`,icon:J9(Bte),active:t.isSpoiler,onSelect:()=>e.update(GR)}],[{key:`bullet`,label:g9(`bullet`).title,icon:J9(g9(`bullet`).icon),active:t.blockType===`bullet`,onSelect:()=>e.dispatchCommand(mt,void 0)},{key:`number`,label:g9(`number`).title,icon:J9(g9(`number`).icon),active:t.blockType===`number`,onSelect:()=>e.dispatchCommand(I,void 0)},{key:`check`,label:g9(`check`).title,icon:J9(g9(`check`).icon),active:t.blockType===`check`,onSelect:()=>e.dispatchCommand(dn,void 0)}],[{key:`align-left`,label:`Align left`,icon:J9(Yte),active:t.elementFormat===`left`||t.elementFormat===``,onSelect:r(`left`)},{key:`align-center`,label:`Align center`,icon:J9(qte),active:t.elementFormat===`center`,onSelect:r(`center`)},{key:`align-right`,label:`Align right`,icon:J9(Gte),active:t.elementFormat===`right`,onSelect:r(`right`)},{key:`align-justify`,label:`Justify`,icon:J9(zte),active:t.elementFormat===`justify`,onSelect:r(`justify`)}]]}var Y9=`Insert`;function Frt({handle:e,items:t,onSelect:n}){let[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(0),l=(0,G.useId)(),u=(0,G.useMemo)(()=>Utt(a,t),[a,t]),d=u.length===0?null:Math.min(s,u.length-1);(0,G.useEffect)(()=>{d!==null&&u[d]?.ref?.current?.scrollIntoView?.({block:`nearest`})},[d,u]);let f=e=>{i(e),e||(o(``),c(0))},p=e=>{f(!1),n(e)};return(0,K.jsxs)(gn,{open:r,onOpenChange:f,children:[e?(0,K.jsx)(tt,{handle:e,payload:{title:Y9},render:(0,K.jsx)(en,{"aria-label":Y9,className:K9,render:(0,K.jsx)(`button`,{type:`button`})}),children:(0,K.jsx)(zr,{size:16})}):(0,K.jsx)(en,{"aria-label":Y9,className:K9,render:(0,K.jsx)(`button`,{type:`button`}),children:(0,K.jsx)(zr,{size:16})}),(0,K.jsxs)(yn,{flush:!0,align:`start`,side:`bottom`,size:`md`,children:[(0,K.jsxs)(`div`,{className:wrt,children:[(0,K.jsx)(lne,{"aria-hidden":!0,className:Trt,size:14}),(0,K.jsx)(ct,{"aria-controls":l,"aria-label":`Search blocks`,className:Ert,placeholder:`Search blocks`,type:`search`,value:a,"aria-activedescendant":d===null?void 0:Itt(l,d),onKeyDown:e=>{if(u.length===0)return;let t=d??0;e.key===`ArrowDown`?(e.preventDefault(),c((t+1)%u.length)):e.key===`ArrowUp`?(e.preventDefault(),c((t-1+u.length)%u.length)):e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),p(u[t]))},onChange:e=>{o(e.target.value),c(0)}})]}),(0,K.jsx)(Ltt,{id:l,items:u,query:a,selectedIndex:d,variant:`embedded`,onHighlight:c,onSelect:p})]})]})}function Irt(e,t,n){let r=0;for(let i=0;i<t;i++)r+=e[i].width+(i>0?n:0);return r}function Lrt(e,{available:t,gap:n,reserve:r}){if(t===null||Irt(e,e.length,n)<=t)return e.length;let i=0;for(;i<e.length&&Irt(e,i+1,n)+n+r<=t;)i++;for(;i>0&&e[i-1].separator;)i--;return i}function Rrt({children:e,handle:t,title:n}){return(0,K.jsx)(tt,{handle:t,payload:{title:n},render:(0,K.jsx)(On,{"aria-label":n,className:K9,render:(0,K.jsx)(`button`,{type:`button`})}),children:e})}function zrt({items:e}){return(0,K.jsx)(K.Fragment,{children:e.map(e=>e.active===void 0?(0,K.jsxs)(Ut,{disabled:e.disabled,shortcut:e.shortcut,onClick:e.onSelect,children:[e.icon,e.label]},e.label):(0,K.jsxs)(Ve,{closeOnClick:!0,checked:e.active,disabled:e.disabled,onClick:e.onSelect,children:[e.icon,e.label]},e.label))})}function Brt({entries:e,handle:t,icon:n}){let r=e.filter(e=>e.separator||e.menu);return(0,K.jsxs)(Zn,{modal:!1,children:[(0,K.jsx)(Rrt,{handle:t,title:`More tools`,children:n}),(0,K.jsx)(Rt,{align:`end`,positionMethod:`fixed`,sideOffset:4,children:r.map((e,t)=>{if(e.separator){let n=r[t-1];return n&&!n.separator&&t<r.length-1?(0,K.jsx)(ur,{},e.key):null}let n=e.menu;return n.label?(0,K.jsxs)(Eee,{children:[(0,K.jsx)(dee,{children:n.label}),(0,K.jsx)(zrt,{items:n.items})]},e.key):(0,K.jsx)(zrt,{items:n.items},e.key)})})]})}var Vrt={canUndo:!1,canRedo:!1,blockType:`paragraph`,fontFamily:``,elementFormat:`left`,isBold:!1,isItalic:!1,isUnderline:!1,isStrikethrough:!1,isCode:!1,isHighlight:!1,isSpoiler:!1};function X9(e,t){for(let n in t)if(t[n]!==e[n])return{...e,...t};return e}function Hrt(){let[e]=ht(),[t,n]=(0,G.useState)(Vrt),r=(0,G.useCallback)(()=>{let e=kr();if(!Jn(e))return;let t=e.anchor.getNode(),r=t.getKey()===`root`?t:pr(t,e=>{let t=e.getParent();return t!==null&&vr(t)})??t.getTopLevelElementOrThrow();if(nr(r)){let e=pr(t,e=>nr(e));e&&(r=e)}let i=urt(r),a=Or(e,`font-family`,``),o=rr(r)?r.getFormatType():`left`,s=e.hasFormat(`bold`),c=e.hasFormat(`italic`),l=e.hasFormat(`underline`),u=e.hasFormat(`strikethrough`),d=e.hasFormat(`code`),f=e.hasFormat(`highlight`),p=UR(e);n(e=>X9(e,{blockType:i,fontFamily:a,elementFormat:o,isBold:s,isItalic:c,isUnderline:l,isStrikethrough:u,isCode:d,isHighlight:f,isSpoiler:p}))},[]);return(0,G.useEffect)(()=>{let t=e.registerCommand(Ke,e=>(n(t=>X9(t,{canUndo:e})),!1),1),i=e.registerCommand(sn,e=>(n(t=>X9(t,{canRedo:e})),!1),1),a=e.registerUpdateListener(({editorState:e})=>{e.read(()=>{r()})});return()=>{t(),i(),a()}},[e,r]),t}var Urt=5;function Wrt(){let e=(0,G.useRef)(null),[t,n]=(0,G.useState)(null);return(0,G.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=new ResizeObserver(([e])=>n(e.contentRect.width));return r.observe(t),()=>r.disconnect()},[]),[e,t]}function Grt({className:e,maxVisibleInsertItems:t=Urt,insertItemOrder:n}){let[r]=ht(),i=Hrt(),[a]=(0,G.useState)(()=>Be()),[o,s]=Wrt(),c=(0,G.useMemo)(()=>{let e=_9(BR(r).filter(e=>e.placement?.includes(`toolbar`)&&e.group===`insert`));if(!n||n.length===0)return e;let t=n.map(e=>g9(e)?.title??e);return e.sort((e,n)=>{let r=t.indexOf(e.title),i=t.indexOf(n.title);return(r===-1?1/0:r)-(i===-1?1/0:i)})},[r,n]),l=(0,G.useMemo)(()=>Htt(r),[r]),u=(0,G.useMemo)(()=>{let e=[Nrt(`font`,{title:`Font family`,label:hrt(i.fontFamily),width:76,items:G9.map(e=>({label:e.label,active:i.fontFamily===e.value,style:e.value?{fontFamily:e.value}:void 0,onSelect:()=>mrt(r,e.value)}))},a),q9(`sep-font`),Nrt(`block`,{title:`Block type`,label:_rt[i.blockType]??`Text`,width:112,items:krt(r,i.blockType)},a)];for(let[t,n]of Prt(r,i).entries()){e.push(q9(`sep-${t}`));for(let t of n)e.push(Mrt(t,a))}e.push(q9(`sep-insert`));for(let n of c.slice(0,t))e.push(Mrt({key:`insert-${n.title}`,label:n.title,icon:n.icon,shortcut:n.shortcut,onSelect:()=>n.onSelect(r,``)},a));let n=c.slice(t).map(e=>({label:e.title,icon:e.icon,shortcut:e.shortcut,onSelect:()=>e.onSelect(r,``)}));return e.push({key:`insert-menu`,width:28,menu:n.length>0?{label:`Insert`,items:n}:void 0,node:(0,K.jsx)(Frt,{handle:a,items:l,onSelect:e=>e.onSelect(r,``)},`insert-menu`)}),e},[r,i,a,c,t,l]),d=Lrt(u,{available:s,gap:2,reserve:28}),f=u.slice(d);return(0,K.jsxs)(B,{delay:300,children:[(0,K.jsx)(Mn,{disableHoverablePopup:!0,handle:a,children:(e=>e.payload===void 0?null:(0,K.jsx)(Fn,{shortcut:e.payload.shortcut,side:`bottom`,sideOffset:4,children:e.payload.title}))}),(0,K.jsx)(`div`,{"aria-label":`Editor toolbar`,className:e?`${vrt} ${e}`:vrt,role:`toolbar`,children:(0,K.jsxs)(`div`,{className:yrt,ref:o,children:[u.slice(0,d).map(e=>e.node),f.length>0&&(0,K.jsx)(Brt,{entries:f,handle:a,icon:(0,K.jsx)(Nr,{size:16})})]})})]})}function Krt(){let e=(0,G.use)(Mj),t=wt();return e?.toolbarSlot&&t?(0,Gi.createPortal)((0,K.jsx)(Grt,{className:`ryugi-editor-toolbar`}),e.toolbarSlot):null}var qrt=100,Z9=1e3,Jrt=3e4,Q9=e=>Uint8Array.from(atob(e),e=>e.charCodeAt(0));function Yrt({transport:e,doc:t,human:n,onOffline:r,onState:i}){let[a]=ht(),o=(0,G.useRef)({commitMessage:`human`}),s=(0,G.useRef)(!1);return(0,G.useEffect)(()=>{let e=()=>{o.current.commitMessage=s.current&&n?.name?B5e(`human`,n):`human`};e();let t=a.getRootElement()?.ownerDocument??document,r=()=>{s.current=!0,e()},i=[`keydown`,`pointerdown`,`paste`,`drop`];for(let e of i)t.addEventListener(e,r,{capture:!0});return()=>{for(let e of i)t.removeEventListener(e,r,{capture:!0})}},[a,n]),(0,G.useEffect)(()=>{let n=t7e(a,t,o.current),s=t.oplogVersion(),c,l,u=Z9,d=!1,f=!1,p=!1,m=0,h=!1,g=e=>!h&&e===m,_=()=>{clearTimeout(c),l===void 0&&(l=setTimeout(()=>{l=void 0,x(!0)},u),u=Math.min(u*2,Jrt))},v=async()=>{if(c=void 0,h||f||d||l!==void 0)return;let n=m,i=t.export({mode:`update`,from:s}),a=t.oplogVersion();p=!1,d=!0;try{if(await e.update(i),!g(n))return;s=a,u=Z9,r(!1)}catch{if(!g(n))return;r(!0),_()}finally{g(n)&&(d=!1,p&&y())}},y=()=>{p=!0,h||f||d||l!==void 0||(clearTimeout(c),c=setTimeout(v,qrt))},b=t.subscribeLocalUpdates(y);async function x(a){if(h)return;let o=++m;clearTimeout(c),clearTimeout(l),l=void 0,d=!1,f=!0;try{let r=await e.state();if(!g(o))return;if(r.lineage!==t.getTree(`lexical`).roots()[0]?.id){location.reload();return}n.import(Q9(r.snapshot)),i?.(r),a&&(s=void 0,p=!0),f=!1,p&&y()}catch{if(!g(o))return;f=!1,r(!0),_()}}let{artifact:S}=e,C=e.channel.subscribe(e=>{e.type===`open`?(u=Z9,x(!0)):e.type===`doc-update`&&e.artifact===S&&n.import(Q9(e.bytes))});return x(!1),()=>{h=!0,clearTimeout(c),clearTimeout(l),C(),b(),n.dispose()}},[a,t,e,r,i]),null}var Xrt=[u9,d9,...iRe,ort,lrt,mz,z5e,...nnt],$9={[Lj]:HRe,[zj]:OK,[Bj]:wBe,[Hj]:C5e};function Zrt(){return wt()?(0,K.jsx)(Ret,{}):null}function Qrt(){return wt()?(0,K.jsx)(Wtt,{}):null}function $rt({transport:e,doc:t,theme:n,onAgentPlayback:r,onOffline:i,onState:a,onEditorReady:o,children:s,agent:c,human:l}){return(0,K.jsx)(Ge,{children:(0,K.jsx)(`div`,{style:{position:`relative`},children:(0,K.jsx)(dG,{children:(0,K.jsxs)(cR,{extraNodes:Xrt,header:(0,K.jsx)(Krt,{}),rendererConfig:$9,theme:n,variant:`article`,onEditorReady:o,children:[(0,K.jsx)(Yrt,{doc:t,human:l,transport:e,onOffline:i,onState:a}),(0,K.jsx)(C9e,{}),(0,K.jsx)(att,{}),(0,K.jsx)(iPe,{}),(0,K.jsx)(Qrt,{}),(0,K.jsx)(UF,{children:(0,K.jsx)(Zrt,{})}),(0,K.jsx)(art,{agent:c,onPlayback:r}),s]})})})})}export{cR as $,dk as $t,hU as A,Wi as An,ECe as At,LR as B,J as Bt,L8e as C,jS as Cn,Aj as Ct,QU as D,eC as Dn,bA as Dt,sW as E,Hye as En,aj as Et,nPe as F,nA as Ft,DR as G,fk as Gt,FR as H,vk as Ht,aPe as I,tA as It,pR as J,XSe as Jt,sNe as K,GSe as Kt,rPe as L,Qk as Lt,mPe as M,uA as Mt,mz as N,lA as Nt,RU as O,RS as On,jCe as Ot,uz as P,rA as Pt,mR as Q,Tk as Qt,RR as R,PSe as Rt,C5e as S,LS as Sn,Mj as St,dG as T,NS as Tn,NEe as Tt,pNe as U,Ik as Ut,IR as V,wk as Vt,ER as W,qSe as Wt,eNe as X,JSe as Xt,fR as Y,YSe as Yt,rNe as Z,Ak as Zt,z5e as _,JC as _n,Wj as _t,lrt as a,hT as an,gP as at,$7 as b,zw as bn,Nj as bt,C9e as c,CO as cn,WDe as ct,$5e as d,bw as dn,_N as dt,pk as en,FMe as et,t7e as f,HC as fn,Lj as ft,H5e as g,fw as gn,Hj as gt,V5e as h,Sw as hn,Bj as ht,Q9 as i,ck as in,hP as it,tU as j,pA as jt,BU as k,Wye as kn,_A as kt,u7e as l,dw as ln,mP as lt,B5e as m,ZC as mn,Yj as mt,Xrt as n,VO as nn,cF as nt,srt as o,vO as on,_P as ot,U5e as p,kC as pn,zj as pt,oNe as q,KSe as qt,$9 as r,UO as rn,WOe as rt,ort as s,pT as sn,vP as st,$rt as t,gk as tn,zF as tt,l7e as u,zC as un,uP as ut,P5e as v,vC as vn,Kj as vt,OK as w,PS as wn,jj as wt,Q7 as x,kS as xn,Pj as xt,j5e as y,pw as yn,Ij as yt,hNe as z,mk as zt};
|
|
396
|
+
`?t.insertParagraph():e===` `?t.insertNodes([ln()]):t.insertText(e))}return!0}function fet(e,t){let n=t.getData(`application/x-lexical-editor`);if(n)try{let t=JSON.parse(n),r=e;if(t.namespace===r._config.namespace&&Array.isArray(t.nodes)){let e=kr();return e?(e.insertNodes(t.nodes.map(Ne)),!0):!1}}catch{}let r=t.getData(`text/html`),i=t.getData(`text/plain`);if(r&&i!==r)try{let t=kr();if(!t)return!1;let n=new DOMParser().parseFromString(r,`text/html`);return t.insertNodes(le(e,n)),!0}catch{}let a=i||t.getData(`text/uri-list`);return a?det(a):!1}function pet(e,t,n){return t.length===0||!T9(n)?!1:(oet(t),fet(e,n))}function met(e){return e.inputType===`insertFromPaste`||e.inputType===`insertFromPasteAsQuotation`}function het(){return Sr().getChildren().map(e=>e.getKey())}function get(e){let t=e;for(;t&&t.getParent()&&t.getParent()!==Sr();)t=t.getParent();return t?.getParent()===Sr()?t.getKey():null}function _et(e,t){if(t.getChildrenSize()===0)return!1;let[n,r]=e.isBackward()?[e.focus,e.anchor]:[e.anchor,e.focus],i=t.getKey(),a=t.getFirstDescendant();if(!(n.type===`element`&&n.key===i&&n.offset===0||n.type===`text`&&a!==null&&a.getKey()===n.key&&n.offset===0))return!1;let o=t.getLastDescendant();return r.type===`element`&&r.key===i&&r.offset===t.getChildrenSize()||r.type===`text`&&it(o)&&o.getKey()===r.key&&r.offset===o.getTextContentSize()}function E9(e,t){let n=Sr().getChildren(),r=n.findIndex(t=>t.getKey()===e),i=n.findIndex(e=>e.getKey()===t);if(r===-1||i===-1)return;let a=Math.min(r,i),o=Math.max(r,i),s=sr();for(let e=a;e<=o;e++)s.add(n[e].getKey());Jt(s)}function vet(e){let t=(0,G.useRef)(null),n=(0,G.useRef)(null),r=(0,G.useRef)(new Set),i=(0,G.useRef)(null),a=$k()?.documentBlocks,o=(0,G.useCallback)(()=>{r.current=new Set,t.current=null,n.current=null,a?.clear()},[a]),s=(0,G.useCallback)(()=>(a?.keys().length??0)>0,[a]),c=(0,G.useCallback)(()=>(a?.keys()??[]).flatMap(e=>Dn(e)??[]),[a]),l=(0,G.useCallback)(()=>{a&&(a.editor.update(()=>aet(c()),{discrete:!0}),o(),a.focusSelection())},[c,o,a]),u=(0,G.useCallback)(e=>e.size===0?[]:Sr().getChildren().filter(t=>e.has(t.getKey())),[]),d=(0,G.useCallback)(()=>{let e=r.current;if(e.size===0){let e=kr();if(!Ue(e))return[];let t=e.getNodes(),n=t.filter(e=>e.getParent()===Sr());return n.length>1&&n.length===t.length?u(new Set(n.map(e=>e.getKey()))):[]}let t=kr();return Ue(t),u(e)},[u]),f=(0,G.useCallback)(t=>{if(!T9(t))return!1;let n=!1;if(a&&s()){let e=a.editor;return e.update(()=>{n=pet(e,c(),t)},{discrete:!0,tag:xe}),n&&(o(),a.focusSelection()),n}return e.update(()=>{let r=d();r.length!==0&&(n=pet(e,r,t),n&&o())},{discrete:!0,tag:xe}),n},[c,o,a,e,d,s]),p=(0,G.useCallback)(()=>{let t=null;if(a&&s()){let e=a.editor;return e.getEditorState().read(()=>w9(e,c()))}return e.getEditorState().read(()=>{let n=d();n.length!==0&&(t=w9(e,n))}),t},[c,a,e,d,s]),m=(0,G.useCallback)(t=>{e.update(()=>{let e=u(new Set(t));e.length!==0&&(aet(e),o())},{discrete:!0})},[o,e,u]);(0,G.useEffect)(()=>{let i=new Set,s=t=>{let n=new Set(t),o=new Set([...r.current,...a?.islandKeys(e)??[]].filter(e=>n.has(e)));for(let t of i)o.has(t)||e.getElementByKey(t)?.classList.remove(x9);for(let t of o)i.has(t)||e.getElementByKey(t)?.classList.add(x9);i=o},c=()=>s(e.getEditorState().read(het)),l=a?.subscribe(c);c();let u=e.registerUpdateListener(({editorState:i})=>{if(!e.getRootElement())return;let a=new Set,c=!1,l=[],u=[];if(i.read(()=>{let e=kr();if(Ue(e)){c=!0;for(let t of e.getNodes())a.add(t.getKey())}else if(Jn(e)){let t=get(e.anchor.getNode()),n=get(e.focus.getNode());t&&l.push(t),n&&n!==t&&l.push(n)}u=het()}),r.current.size>0){if(c){let e=r.current;if(!(a.size===e.size&&[...a].every(t=>e.has(t)))){let e=new Set(u),i=[...a].filter(t=>e.has(t));if(i.length>1){let e=i.map(e=>u.indexOf(e)).sort((e,t)=>e-t);t.current=u[e[0]],n.current=u[e.at(-1)],r.current=new Set(i)}else o()}}else{let e=r.current;l.length>0&&l.every(t=>e.has(t))||o()}}s(u)});return()=>{l?.(),u();for(let t of i)e.getElementByKey(t)?.classList.remove(x9)}},[o,a,e]),(0,G.useEffect)(()=>{let t=e.getRootElement();if(!t)return;let n=e=>{r.current.size!==0&&e.target instanceof Node&&t.contains(e.target)&&o()};return t.addEventListener(`pointerdown`,n,!0),()=>t.removeEventListener(`pointerdown`,n,!0)},[o,e]),(0,G.useEffect)(()=>{let t=e.getRootElement();if(!t)return;let n=n=>{if(r.current.size===0)return;let i=n.target;if(!i)return;let a=i.closest(`[contenteditable="true"]`);a&&a!==t&&(o(),e.update(()=>{let e=kr();Ue(e)&&Jt(null)}))};return t.addEventListener(`focusin`,n),()=>t.removeEventListener(`focusin`,n)},[o,e]),(0,G.useEffect)(()=>{let t=e.getRootElement();if(!t)return;let n=e=>{met(e)&&r.current.size!==0&&e.dataTransfer&&f(e.dataTransfer)&&(e.preventDefault(),e.stopPropagation())};return t.addEventListener(`beforeinput`,n,!0),()=>t.removeEventListener(`beforeinput`,n,!0)},[e,f]),(0,G.useEffect)(()=>{let c=e.registerCommand(br,e=>{let t=e.key.toLowerCase();if(!e.metaKey&&!e.ctrlKey&&t!==`escape`||![`a`,`c`,`v`,`x`,`escape`].includes(t))return!1;if((e.metaKey||e.ctrlKey)&&t===`v`&&r.current.size>0){e.preventDefault();let t=i.current?{...i.current}:null;return(async()=>{let e=t?net(t):await ret();e&&r.current.size!==0&&f(e)})(),!0}return!1},4),u=e.registerCommand(F,i=>{if(!i?.shiftKey||r.current.size===0||!n.current)return!1;let o=kr();if(!Ue(o))return!1;let c=Sr().getChildren(),l=c.findIndex(e=>e.getKey()===n.current);if(l===-1)return!1;if(a&&(s()||l>=c.length-1))return i.preventDefault(),s()||a.select(e,t.current,n.current),a.extend(1),!0;if(l>=c.length-1)return!1;i.preventDefault(),n.current=c[l+1].getKey(),E9(t.current,n.current);let u=Math.min(c.findIndex(e=>e.getKey()===t.current),l+1),d=Math.max(c.findIndex(e=>e.getKey()===t.current),l+1);return r.current=new Set(c.slice(u,d+1).map(e=>e.getKey())),!0},4),h=e.registerCommand(Nn,i=>{if(!i?.shiftKey||r.current.size===0||!n.current)return!1;let o=kr();if(!Ue(o))return!1;let c=Sr().getChildren(),l=c.findIndex(e=>e.getKey()===n.current);if(l===-1)return!1;if(a&&(s()||l<=0))return i.preventDefault(),s()||a.select(e,t.current,n.current),a.extend(-1),!0;if(l<=0)return!1;i.preventDefault(),n.current=c[l-1].getKey(),E9(t.current,n.current);let u=c.findIndex(e=>e.getKey()===t.current),d=Math.min(u,l-1),f=Math.max(u,l-1);return r.current=new Set(c.slice(d,f+1).map(e=>e.getKey())),!0},4),g=e.registerCommand(eee,()=>{if(r.current.size>0){let e=Sr().getChildren().map(e=>e.getKey());if(r.current.size>=e.length)return a?.selectAll(),!0;t.current=e[0],n.current=e.at(-1),r.current=new Set(e);let i=sr();for(let t of e)i.add(t);return Jt(i),!0}let e=kr(),i=null,o=null;if(Jn(e)){let t=e.anchor.getNode();for(;t&&t.getParent()&&t.getParent()!==Sr();)t=t.getParent();t&&t.getParent()===Sr()&&(i=t.getKey(),o=t)}else if(Ue(e)){let t=e.getNodes();if(t.length>0){let e=t[0];for(;e&&e.getParent()&&e.getParent()!==Sr();)e=e.getParent();e&&e.getParent()===Sr()&&(i=e.getKey(),o=e)}}if(o&&rr(o)){let t=o.getChildrenSize(),n=Jn(e)&&_et(e,o);if(t>0&&!n)return o.select(0,t),!0}if(i){t.current=i,n.current=i,r.current=new Set([i]);let e=sr();return e.add(i),Jt(e),!0}return!1},3),_=e.registerCommand(tr,()=>r.current.size!==0&&(o(),Jt(null),!0),3),v=e.registerCommand(Pn,t=>{let n=t&&typeof t==`object`&&`clipboardData`in t?t:null,r=p();return r?(i.current=r,n?.clipboardData?(n.preventDefault(),S9(n.clipboardData,r),!0):(t&&typeof t==`object`&&`preventDefault`in t&&typeof t.preventDefault==`function`&&t.preventDefault(),iet(e,r),!0)):!1},4),y=e.registerCommand(he,t=>{let n=t&&typeof t==`object`&&`clipboardData`in t?t:null,r=s(),a=[],o=r?p():null;return r||e.getEditorState().read(()=>{let t=d();t.length!==0&&(o=w9(e,t),a=t.map(e=>e.getKey()))}),!r&&a.length===0||!o?!1:(i.current=o,n?.clipboardData?(n.preventDefault(),S9(n.clipboardData,o)):(t&&typeof t==`object`&&`preventDefault`in t&&typeof t.preventDefault==`function`&&t.preventDefault(),iet(e,o)),r?l():m(a),!0)},4),b=e.registerCommand(or,t=>{let n=set(t);if(!n)return!1;let r=uet(t);if(!(r?T9(n):cet(n)))return!1;if(s())return f(n)?(t&&typeof t==`object`&&`preventDefault`in t&&typeof t.preventDefault==`function`&&t.preventDefault(),!0):!1;let i=d();return i.length!==0&&(oet(i),o(),r?(t&&typeof t==`object`&&`preventDefault`in t&&typeof t.preventDefault==`function`&&t.preventDefault(),fet(e,n)):!1)},4),x=t=>{if(s())return t&&typeof t!=`boolean`&&`preventDefault`in t&&typeof t.preventDefault==`function`&&t.preventDefault(),l(),!0;let n=[];return e.getEditorState().read(()=>{n=d().map(e=>e.getKey())}),n.length!==0&&(t&&typeof t!=`boolean`&&`preventDefault`in t&&typeof t.preventDefault==`function`&&t.preventDefault(),m(n),!0)},S=e.registerCommand(Wt,x,4),C=e.registerCommand(Ze,x,4),w=e.registerCommand(Yee,x,4),T=e.registerCommand(Hee,x,4);return()=>{c(),u(),h(),g(),_(),v(),y(),b(),S(),C(),w(),T()}},[o,m,l,a,e,p,d,s,f]);let h=(0,G.useCallback)((i,o)=>{a?.clear(),e.update(()=>{if(o&&t.current){n.current=i,E9(t.current,i);let e=Sr().getChildren(),a=e.findIndex(e=>e.getKey()===t.current),o=e.findIndex(e=>e.getKey()===i);if(a!==-1&&o!==-1){let t=Math.min(a,o),n=Math.max(a,o);r.current=new Set(e.slice(t,n+1).map(e=>e.getKey()))}}else{t.current=i,n.current=i,r.current=new Set([i]);let e=sr();e.add(i),Jt(e)}})},[a,e]),g=(0,G.useCallback)(()=>{if(r.current.size===0)return[];let t=[];return e.getEditorState().read(()=>{t=u(r.current).map(e=>e.getKey())}),t},[e,u]),_=(0,G.useCallback)(e=>{let t=g(),n=t.length>0?t:e?[e]:[];n.length!==0&&m(n)},[m,g]);return{selectBlock:h,getSelectedKeys:g,isBlockSelectionActive:(0,G.useCallback)(()=>r.current.size>0,[]),deleteSelectedBlocks:_}}var yet=150,bet=300,xet=32;function Cet(e){return[...e.children].filter(e=>e instanceof HTMLElement)}function wet(e){return[...e.querySelectorAll(`[data-virtual-editor-content]`)].flatMap(Cet).filter(e=>e.getBoundingClientRect().height>0).sort((e,t)=>e.getBoundingClientRect().top-t.getBoundingClientRect().top)}function Tet(e){return[...e.querySelectorAll(`[data-virtual-editor-content]`)].find(e=>e.getBoundingClientRect().height>0)}function Eet(e,t){let n=_te(e);if(!n)return;let r=n.read(()=>Bt(e)?.getKey());return r?t.documentKeys(n,[r])[0]:void 0}function Det(e,t){let n=on(),r=te(`/`);n.append(r),e?t?e.insertBefore(n):e.insertAfter(n):Sr().append(n),r.select(1,1)}function Oet(e,t){let[n,r]=(0,G.useState)(null),i=(0,G.useRef)(null),a=(0,G.useRef)(null),o=(0,G.useRef)(null),s=(0,G.useRef)(!1),c=$k()?.documentBlocks,l=(0,G.useCallback)(()=>{a.current&&clearTimeout(a.current),a.current=null},[]),u=(0,G.useCallback)(()=>{o.current&&clearTimeout(o.current),o.current=null},[]),d=(0,G.useCallback)(()=>{l(),i.current=null,s.current||r(null)},[l]);(0,G.useEffect)(()=>{let n=e.getRootElement();if(!n)return;let s=n.closest(`.rich-editor`)??n.parentElement;if(!s)return;let f=c?n.closest(`[data-virtual-editor]`):null,p=null,m=e=>{let o=e.target;if(f&&Tet(f)!==n){d();return}let s=(f??n).getBoundingClientRect();if(!(e.clientX>=s.left-xet&&e.clientX<=s.right)||t(o)||o.closest(`[role="toolbar"]`)){d();return}let c=f?wet(f):Cet(n),u=H9e(c.map(e=>e.getBoundingClientRect()),e.clientY);u?i.current!==u.index&&(l(),i.current=u.index,a.current=setTimeout(()=>{r({index:u.index,top:u.y+window.scrollY,left:s.left+window.scrollX,width:s.width,next:c[u.index]??null,previous:c[u.index-1]??null})},yet)):d()},h=e=>{u(),p===null&&(p=requestAnimationFrame(()=>{p=null,m(e)}))},g=()=>{u(),o.current=setTimeout(d,bet)};return s.addEventListener(`mousemove`,h),s.addEventListener(`mouseleave`,g),window.addEventListener(`scroll`,d,!0),()=>{p!==null&&cancelAnimationFrame(p),s.removeEventListener(`mousemove`,h),s.removeEventListener(`mouseleave`,g),window.removeEventListener(`scroll`,d,!0),l(),u()}},[u,l,d,c,e,t]);let f=(0,G.useCallback)(()=>{s.current=!0,l(),u()},[u,l]),p=(0,G.useCallback)(()=>{s.current=!1,d()},[d]);return{gap:n,insertAtGap:(0,G.useCallback)(()=>{if(!n)return;let{index:t,next:i,previous:a}=n;s.current=!1,d(),r(null);let o=i??a;if(c&&o){let e=Eet(o,c);if(!e)return;c.editor.update(()=>Det(Dn(e),o===i),{discrete:!0}),c.focusSelection()}else e.update(()=>Det(Sr().getChildAtIndex(t),!0)),e.focus()},[d,c,e,n]),onPlusEnter:f,onPlusLeave:p}}var ket=8;function Aet(e){let t=(0,G.useRef)(null),n=(0,G.useRef)(null),r=(0,G.useRef)(e);(0,G.useEffect)(()=>{r.current=e},[e]);let i=(0,G.useCallback)(()=>{t.current&&clearTimeout(t.current),t.current=null,n.current=null},[]);return(0,G.useEffect)(()=>i,[i]),(0,G.useMemo)(()=>({onPointerDown:e=>{i(),e.pointerType===`touch`&&(n.current={x:e.clientX,y:e.clientY},t.current=setTimeout(()=>{t.current=null,n.current=null,r.current()},450))},onPointerMove:e=>{let t=n.current;t&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>ket&&i()},onPointerUp:i,onPointerCancel:i}),[i])}var D9=`application/x-rich-editor-drag`,jet=300,Met=26,Net=24;function O9(e,t){let n=e.getRootElement();if(!n)return null;let r=t;for(;r&&r!==n;){if(r.parentElement===n)return r;r=r.parentElement}return null}function Pet(e,t){let n=[...e.children].filter(e=>e instanceof HTMLElement);if(!n.length)return null;let r=null,i=1/0;for(let e of n){let n=e.getBoundingClientRect();if(n.height<=0)continue;if(t>=n.top&&t<=n.bottom)return e;let a=t<n.top?n.top-t:t-n.bottom;a<i&&(i=a,r=e)}return r}function Fet(e,t,n){let r=t.getBoundingClientRect();if(r.width<=0||r.height<=0||n.clientY<r.top||n.clientY>r.bottom)return null;let i=[{x:n.clientX,y:n.clientY}],a=Math.min(r.right-1,Math.max(r.left+1,n.clientX));a!==n.clientX&&i.unshift({x:a,y:n.clientY});for(let t of i){let n=document.elementFromPoint(t.x,t.y);if(!(n instanceof HTMLElement))continue;let r=O9(e,n);if(r)return r}let{target:o}=n;if(o instanceof HTMLElement){let t=O9(e,o);if(t)return t}return Pet(t,n.clientY)}function Iet(e){return{top:e.top+window.scrollY,left:e.left+window.scrollX}}function Let({editor:e}){let{className:t,theme:n}=We(),[r,i]=(0,G.useState)({visible:!1,top:0,left:0,nodeKey:null}),[a,o]=(0,G.useState)({visible:!1,top:0,left:0,width:0}),s=(0,G.useRef)(null),c=(0,G.useRef)(null),l=(0,G.useRef)(!1),u=(0,G.useRef)(0),d=(0,G.useRef)(null),f=(0,G.useRef)(null),p=(0,G.useRef)(null),{selectBlock:m,getSelectedKeys:h,deleteSelectedBlocks:g}=vet(e),_=$k()?.documentBlocks,v=(0,G.useCallback)(()=>{c.current&&=(clearTimeout(c.current),null)},[]),y=(0,G.useCallback)(()=>{v(),c.current=setTimeout(()=>{!l.current&&u.current===0&&(s.current=null,i(e=>({...e,visible:!1,nodeKey:null})))},jet)},[v]),b=(0,G.useCallback)(()=>{l.current=!0,v()},[v]),x=(0,G.useCallback)(()=>{l.current=!1,y()},[y]),S=(0,G.useCallback)(e=>{u.current+=e?1:-1,e?v():y()},[v,y]),C=(0,G.useCallback)(t=>{t!==void 0&&(s.current=t);let n=s.current;if(!n||!n.isConnected){s.current=null,i(e=>e.visible?{...e,visible:!1,nodeKey:null}:e);return}let r=e.getRootElement();if(!r)return;let a=n.getBoundingClientRect(),o=r.getBoundingClientRect(),c=Iet(a),l=getComputedStyle(n),u=null;e.read(()=>{let e=Bt(n);e&&(u=e.getKey())});let d=U9e({top:c.top,paddingTop:Number.parseFloat(l.paddingTop)||0,lineHeight:W9e(l.lineHeight,l.fontSize)},Net),f=Iet(o).left-Met;i(e=>e.visible&&e.top===d&&e.left===f&&e.nodeKey===u?e:{visible:!0,top:d,left:f,nodeKey:u})},[e]);(0,G.useEffect)(()=>{let t=e.getRootElement();if(!t)return;let n=null,r=t=>{n===null&&(n=requestAnimationFrame(()=>{n=null;let r=t.target,i=O9(e,r);i&&(v(),C(i))}))},i=()=>{!l.current&&u.current===0&&y()};return t.addEventListener(`mousemove`,r),t.addEventListener(`mouseleave`,i),()=>{n!==null&&cancelAnimationFrame(n),t.removeEventListener(`mousemove`,r),t.removeEventListener(`mouseleave`,i),v()}},[v,e,y,C]),(0,G.useEffect)(()=>{let e=()=>C();return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[C]),(0,G.useEffect)(()=>e.registerUpdateListener(()=>C()),[e,C]),Q9e(e,h);let{gap:w,insertAtGap:T,onPlusEnter:E,onPlusLeave:D}=Oet(e,(0,G.useCallback)(t=>O9(e,t)!==null,[e]));(0,G.useEffect)(()=>{!w||u.current>0||(v(),s.current=null,i(e=>e.visible?{...e,visible:!1,nodeKey:null}:e))},[v,w]);let O=(0,G.useCallback)(t=>{r.nodeKey&&V9e(e,r.nodeKey,t)},[e,r.nodeKey]),k=(0,G.useCallback)(()=>{g(r.nodeKey),i(e=>({...e,visible:!1,nodeKey:null}))},[g,r.nodeKey]),A=(0,G.useCallback)(()=>{let t=h(),n=t.length>0?t:r.nodeKey?[r.nodeKey]:[];n.length&&e.update(()=>{P9e(n)})},[e,h,r.nodeKey]),j=(0,G.useCallback)(t=>{let n=h(),i=n.length>0?n:r.nodeKey?[r.nodeKey]:[];i.length&&I9e(e,_,i,t)},[_,e,h,r.nodeKey]),[M,N]=(0,G.useState)(!1),P=(0,G.useRef)(!1),F=(0,G.useCallback)(()=>{let t=d.current;t&&(t.remove(),d.current=null);let n=f.current;n&&(n.classList.remove(b9),f.current=null);let r=p.current;if(r){for(let t of r)e.getElementByKey(t)?.classList.remove(b9);p.current=null}},[e]),I=(0,G.useCallback)(i=>{if(P.current=!0,!i.dataTransfer||!r.nodeKey)return;let a=h(),o=a.length>0&&a.includes(r.nodeKey)?a:[r.nodeKey],c=_?_.documentKeys(e,o):o;i.dataTransfer.setData(D9,JSON.stringify(c)),i.dataTransfer.effectAllowed=`move`;let l=s.current;if(!l)return;F();let u=l.getBoundingClientRect(),m=l.cloneNode(!0);if(m.classList.add(J9e),m.style.width=`${u.width}px`,m.style.position=`relative`,o.length>1){let e=document.createElement(`div`);e.className=Y9e,e.textContent=String(o.length),m.appendChild(e)}if(t){let e=document.createElement(`div`);e.className=t,e.setAttribute(`data-theme`,n),e.style.cssText=`position:fixed;top:-10000px;left:-10000px;pointer-events:none`,e.appendChild(m),document.body.append(e),d.current=e}else document.body.append(m),d.current=m;if(o.length>1){for(let t of o)e.getElementByKey(t)?.classList.add(b9);p.current=o}else f.current=l,l.classList.add(b9);let g=Math.max(12,Math.min(u.width-12,i.clientX-u.left)),v=Math.max(8,Math.min(u.height-8,i.clientY-u.top));i.dataTransfer.setDragImage(m,g,v)},[F,_,e,h,r.nodeKey,t,n]),L=(0,G.useCallback)(e=>{N(t=>t===e?t:(S(e),e))},[S]),R=Aet(()=>{r.nodeKey&&(m(r.nodeKey,!1),L(!0))}),z=M&&r.nodeKey?e.getEditorState().read(()=>z9e(Dn(r.nodeKey))):null,B=(0,G.useCallback)(e=>{P.current=!1,e.button===0&&e.stopPropagation()},[]),V=(0,G.useCallback)(t=>{if(t.detail===0)return;if(t.preventDefault(),t.stopPropagation(),P.current){P.current=!1;return}if(!r.nodeKey)return;let{nodeKey:n}=r,{shiftKey:i}=t;e.focus(()=>m(n,i)),i||L(!0)},[e,r.nodeKey,L,m]),H=(0,G.useCallback)(e=>{e.preventDefault(),r.nodeKey&&(h().includes(r.nodeKey)||m(r.nodeKey,!1)),L(!0)},[h,r.nodeKey,L,m]);return(0,G.useEffect)(()=>{let t=e.getRootElement();if(!t)return;let n=e.registerCommand(hr,n=>{if(!n.dataTransfer?.types.includes(D9))return!1;n.preventDefault(),n.dataTransfer.dropEffect=`move`;let r=Fet(e,t,n);if(!r)return o(e=>e.visible?{...e,visible:!1}:e),!0;let i=r.getBoundingClientRect(),a=t.getBoundingClientRect(),s=i.top+i.height/2,c=n.clientY<s?i.top:i.bottom;return o({visible:!0,top:c+window.scrollY,left:a.left+window.scrollX,width:a.width}),!0},3),r=e.registerCommand(dt,n=>{let r=n.dataTransfer?.getData(D9);if(!r)return!1;n.preventDefault(),o(e=>({...e,visible:!1})),F();let i;try{let e=JSON.parse(r);i=Array.isArray(e)&&e.every(e=>typeof e==`string`)?e:[r]}catch{i=[r]}if(!i.length)return!1;let a=Fet(e,t,n);if(!a)return!1;let s=e.read(()=>Bt(a)?.getKey());if(!s)return!0;let c=_?_.documentKeys(e,[s])[0]:s;if(!c)return!0;let l=a.getBoundingClientRect(),u=n.clientY<l.top+l.height/2;return(_?.editor??e).update(()=>{F9e(i,c,u)}),!0},3),i=e.registerCommand(Je,e=>!!e.dataTransfer?.types.includes(D9),3),a=()=>{o(e=>e.visible?{...e,visible:!1}:e)},s=()=>{a(),F()},c=e=>{e.relatedTarget!==null&&t.contains(e.relatedTarget)||a()};return window.addEventListener(`dragend`,s),window.addEventListener(`drop`,s),t.addEventListener(`dragleave`,c),()=>{n(),r(),i(),window.removeEventListener(`dragend`,s),window.removeEventListener(`drop`,s),t.removeEventListener(`dragleave`,c),s()}},[F,_,e]),(0,G.useEffect)(()=>{let t=e.getRootElement();if(!t)return;let n=t.closest(`.rich-editor`);if(!n)return;let r=!1,i=null,a=n=>{let r=Pet(t,n);if(!r)return null;let i=null;return e.read(()=>{i=Bt(r)?.getKey()??null}),i},o=n=>{if(n.button!==0)return;let o=n.target;if(t.contains(o)||o.closest(`button, input, textarea, select, [role="toolbar"], [role="menu"]`))return;let s=t.getBoundingClientRect();if(n.clientY<s.top||n.clientY>s.bottom)return;let c=a(n.clientY);c&&(n.preventDefault(),e.focus(()=>m(c,n.shiftKey)),r=!0,i=c)},s=e=>{if(!r)return;let t=a(e.clientY);t&&t!==i&&(m(t,!0),i=t)},c=()=>{r=!1,i=null};return n.addEventListener(`mousedown`,o),window.addEventListener(`mousemove`,s),window.addEventListener(`mouseup`,c),()=>{n.removeEventListener(`mousedown`,o),window.removeEventListener(`mousemove`,s),window.removeEventListener(`mouseup`,c)}},[e,m]),(0,K.jsxs)(`div`,{...t?{className:t,"data-theme":n,style:{display:`contents`}}:{},children:[(0,K.jsx)(`div`,{className:`${G9e} ${r.visible?K9e:``}`,style:{top:r.top,left:r.left},onMouseEnter:b,onMouseLeave:x,children:(0,K.jsxs)(Zn,{open:M,onOpenChange:L,children:[(0,K.jsx)(On,{draggable:!0,"aria-label":`Block actions`,className:q9e,onClick:V,onContextMenu:H,onDragStart:I,onMouseDownCapture:B,...R,children:(0,K.jsx)(Lte,{size:16})}),(0,K.jsx)(A9e,{currentType:z,onDelete:k,onDuplicate:A,onMoveDown:()=>j(`down`),onMoveUp:()=>j(`up`),onTurnInto:O})]})}),w&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`iihqkc3`,style:{top:w.top,left:w.left,width:w.width}}),(0,K.jsx)(`button`,{"aria-label":`Insert block`,className:`iihqkc4`,style:{top:w.top,left:w.left-Met},type:`button`,onClick:T,onMouseDown:e=>e.preventDefault(),onMouseEnter:E,onMouseLeave:D,children:(0,K.jsx)(zr,{size:14})})]}),a.visible&&(0,K.jsx)(`div`,{className:`iihqkc7`,style:{top:a.top,left:a.left,width:a.width}})]})}function Ret(){let[e]=ht();return(0,Gi.createPortal)((0,K.jsx)(Let,{editor:e}),document.body)}function k9(e){let t=e.trim();return t===``||/^https?:\/\/$/.test(t)}function zet(e){return e.trim().replace(/^https?:\/\//i,``).replace(/\/$/,``)}function A9({action:e,children:t,danger:n,disabled:r,label:i,onClick:a}){return(0,K.jsxs)(Mn,{children:[(0,K.jsx)(tt,{render:(0,K.jsx)(Fe,{icon:!0,"aria-label":i,danger:n,"data-link-action":e,disabled:r,size:`md`,onClick:a}),children:t}),(0,K.jsx)(Fn,{side:`top`,children:i})]})}var j9={panel:`rich-link-edit-panel`,preview:`rich-link-edit-preview`,actions:`rich-link-edit-actions`,cmdHover:`rich-link-edit-cmd-hover`},Bet=`_1uegwri0`,Vet=`_1uegwri1`,Het=`_1uegwri2`,Uet=`_1uegwri3`,Wet=`_1uegwri4`,Get=`_1uegwri5`,Ket=`_1uegwri7`,qet=`_1uegwri8`,Jet=`_1uegwri9`,Yet=`_1uegwria`,Xet=`_1uegwrib`;function Zet(e){return e.mode===`edit`?(0,K.jsx)($et,{...e}):(0,K.jsx)(Qet,{...e})}function Qet({extraActions:e,text:t,url:n,onCopy:r,onEdit:i,onOpen:a,onUnlink:o}){let s=k9(n),c=zet(n);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`${Vet} ${j9.preview}`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:Het,children:(0,K.jsx)(E,{})}),(0,K.jsxs)(`div`,{className:Uet,children:[(0,K.jsx)(`div`,{className:`${Wet}${s?` ${Get}`:``}`,children:s?`No link yet`:t.trim()||c}),!s&&(0,K.jsx)(`div`,{className:`_1uegwri6`,title:n,children:c})]})]}),(0,K.jsxs)(`div`,{className:`${Ket} ${j9.actions}`,children:[e,(0,K.jsx)(`span`,{className:qet}),(0,K.jsx)(A9,{disabled:s,label:`Open link`,onClick:a,children:(0,K.jsx)(Xte,{})}),(0,K.jsx)(A9,{disabled:s,label:`Copy link`,onClick:r,children:(0,K.jsx)(Ir,{})}),(0,K.jsx)(A9,{action:`edit`,label:`Edit link`,onClick:i,children:(0,K.jsx)(Ae,{})}),(0,K.jsx)(A9,{danger:!0,label:`Remove link`,onClick:o,children:(0,K.jsx)(Vi,{})})]})]})}function $et({draft:e,urlInputRef:t,onCancel:n,onDraftChange:r,onKeyDown:i,onSave:a}){let o=(0,G.useId)(),s=`${o}-text`,c=`${o}-url`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Xn,{children:[(0,K.jsx)(Kn,{id:s,label:`Text`,children:(0,K.jsx)(ct,{id:s,placeholder:`Link text`,value:e.text,onChange:t=>r({...e,text:t.target.value}),onKeyDown:i})}),(0,K.jsx)(Kn,{id:c,label:`URL`,children:(0,K.jsx)(ct,{id:c,placeholder:`Paste or type a link`,ref:t,type:`url`,value:e.url,onChange:t=>r({...e,url:t.target.value}),onKeyDown:i})})]}),(0,K.jsxs)(`div`,{className:Jet,children:[(0,K.jsx)(Fe,{size:`md`,variant:`outline`,onClick:n,children:`Cancel`}),(0,K.jsxs)(Fe,{disabled:k9(e.url),size:`md`,variant:`solid`,onClick:a,children:[`Save`,(0,K.jsx)(ar,{className:Yet,keys:`enter`,size:`sm`,tone:`inverted`})]})]})]})}var ett=[Xet,j9.cmdHover];function ttt(e){let t=t=>{for(let n of ett)e.classList.toggle(n,t)},n=e=>{(e.key===`Meta`||e.key===`Control`)&&t(!0)},r=e=>{(e.key===`Meta`||e.key===`Control`)&&t(!1)},i=()=>t(!1),a=e=>{if(!(e.metaKey||e.ctrlKey))return;let t=e.target.closest(`a`);if(!t)return;let n=t.getAttribute(`href`);n&&(e.preventDefault(),window.open(n,`_blank`,`noopener,noreferrer`))};return e.addEventListener(`keydown`,n),e.addEventListener(`keyup`,r),e.addEventListener(`blur`,i),e.addEventListener(`click`,a),()=>{e.removeEventListener(`keydown`,n),e.removeEventListener(`keyup`,r),e.removeEventListener(`blur`,i),e.removeEventListener(`click`,a);for(let t of ett)e.classList.remove(t)}}function ntt(e){(0,G.useEffect)(()=>{let t=null,n=e.registerRootListener(e=>{t?.(),t=e?ttt(e):null});return()=>{n(),t?.()}},[e])}function rtt(e){let t=e;for(;t;){if(Yn(t))return t;t=t.getParent()}return null}function itt(e,t){if(e.getTextContent()===t)return;let n=e.getFirstDescendant(),r=te(t);it(n)&&(r.setFormat(n.getFormat()),r.setStyle(n.getStyle()));let i=e.getChildren();e.append(r);for(let e of i)e.remove()}function att({renderExtraActions:e}={}){let[t]=ht(),n=(0,G.useRef)(null),r=(0,G.useRef)(null),i=(0,G.useRef)(!1),a=(0,G.useRef)(!1),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)({url:``,text:``,linkKey:``,linkDom:null}),[u,d]=(0,G.useState)({text:``,url:``}),f=(0,G.useRef)(u),[p,m]=(0,G.useState)(`view`),h=(0,G.useRef)(`view`),g=(0,G.useRef)(``),_=(0,G.useCallback)(e=>{f.current=e,d(e)},[]),v=(0,G.useCallback)(e=>{h.current=e,m(e)},[]),y=(0,G.useCallback)(()=>{if(a.current)return;let e=kr();if(!Jn(e)||!e.isCollapsed()){s(!1);return}let n=rtt(e.anchor.getNode());if(!n||zn(n)&&n.getIsUnlinked()){g.current=``,s(!1);return}let r=n.getURL(),i=n.getTextContent(),o=n.getKey(),c=t.getElementByKey(o);g.current!==o&&(g.current=o,v(k9(r)?`edit`:`view`)),l({url:r,text:i,linkKey:o,linkDom:c}),h.current!==`view`&&a.current||_({text:i,url:r}),s(!0)},[t,_,v]);(0,G.useEffect)(()=>{let e=t.registerCommand(mn,()=>(y(),!1),1),n=t.registerUpdateListener(({editorState:e})=>{e.read(()=>{y()})});return()=>{e(),n()}},[t,y]),ntt(t),(0,G.useEffect)(()=>{o&&p===`edit`&&n.current?.focus()},[o,p,c.linkKey]),(0,G.useEffect)(()=>{p===`view`&&i.current&&(i.current=!1,r.current?.querySelector(`[data-link-action="edit"]`)?.focus())},[p]);let b=(0,G.useCallback)(()=>{let{text:e,url:n}=f.current,r=n.trim();if(k9(r))return!1;let i=e.trim();return t.update(()=>{let t=Dn(c.linkKey);Yn(t)&&(t.getURL()!==r&&t.setURL(r),i&&itt(t,e))}),!0},[t,c.linkKey]),x=(0,G.useCallback)(()=>{a.current=!1,v(`view`),t.focus()},[t,v]),S=(0,G.useCallback)(()=>{b()&&x()},[b,x]),C=(0,G.useCallback)(()=>{_({text:c.text,url:c.url}),k9(c.url)?x():(i.current=!0,v(`view`))},[c.text,c.url,x,_,v]),w=(0,G.useCallback)(e=>{e.key===`Enter`?(e.preventDefault(),S()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),C())},[C,S]),T=(0,G.useCallback)(()=>{_({text:c.text,url:c.url}),v(`edit`)},[c.text,c.url,_,v]),E=(0,G.useCallback)(()=>{window.open(c.url,`_blank`,`noopener`)},[c.url]),D=(0,G.useCallback)(()=>{navigator.clipboard?.writeText(c.url).then(()=>{Pe({title:`Link copied`,tone:`success`})})},[c.url]),O=(0,G.useCallback)(()=>{t.update(()=>{let e=Dn(c.linkKey);if(Yn(e)){if(zn(e)){e.setIsUnlinked(!0),e.markDirty();return}let t=e.getChildren();for(let n of t)e.insertBefore(n);e.remove()}}),a.current=!1,s(!1)},[t,c.linkKey]),k=(0,G.useCallback)(()=>{a.current=!0},[]),A=(0,G.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||(a.current=!1,h.current===`edit`&&b()&&v(`view`))},[b,v]);return t.isEditable()?(0,K.jsx)(gn,{open:o,children:(0,K.jsx)(Cte,{children:(0,K.jsx)(Ote,{align:`center`,anchor:c.linkDom,collisionAvoidance:{side:`flip`,align:`shift`},collisionPadding:8,side:`bottom`,sideOffset:8,children:(0,K.jsx)(Aee,{flush:!0,className:`${Bet} ${j9.panel}`,ref:r,size:`md`,onBlur:A,onFocus:k,children:(0,K.jsx)(Zet,{draft:u,mode:p,text:c.text,url:c.url,urlInputRef:n,extraActions:e?.({url:c.url,linkKey:c.linkKey,actionButtonClassName:Ate({size:`md`})}),onCancel:C,onCopy:D,onDraftChange:_,onEdit:T,onKeyDown:w,onOpen:E,onSave:S,onUnlink:O})})})})}):null}var ott=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`,stt=Rn(`SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND`);function ctt(e,{minLength:t=1,maxLength:n=75,punctuation:r=ott,allowWhitespace:i=!1}){return(0,G.useCallback)(a=>{let o=RegExp(`(^|\\s|\\()([`+e+`]((?:[^`+e+r+(i?``:`\\s`)+`]){0,`+n+`}))$`).exec(a);if(o!==null){let e=o[1],n=o[3];if(n.length>=t)return{leadOffset:o.index+e.length,matchingString:n,replaceableString:o[2]}}return null},[i,e,r,n,t])}var ltt=class{key;ref;icon;title;constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}},utt=fr?G.useLayoutEffect:G.useEffect,dtt=e=>{let t=e.closest(`#typeahead-menu`);if(!t)return;let n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:`center`}),n.top<0&&t.scrollIntoView({block:`center`}),e.scrollIntoView({block:`nearest`})};function ftt(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top>=r.top-6&&n.top<=r.bottom+6}function ptt(e,t,n,r){let[i]=ht();(0,G.useEffect)(()=>{if(t!=null&&e!=null){let e=i.getRootElement(),a=e==null?document.body:nee(e,!1),o=!1,s=ftt(t,a),c=function(){o||=(window.requestAnimationFrame(function(){n(),o=!1}),!0);let e=ftt(t,a);e!==s&&(s=e,r?.(e))},l=new ResizeObserver(n),u=yte(e??t);return l.observe(t),Qn(Gt(window,`resize`,n),Gt(document,`scroll`,c,{capture:!0,passive:!0}),...u.map(e=>Gt(e,`scroll`,c,{capture:!0,passive:!0})),()=>l.unobserve(t))}},[t,i,r,n,e])}function mtt({index:e,isSelected:t,onClick:n,onMouseEnter:r,option:i}){let a=`item`;return t&&(a+=` selected`),(0,K.jsxs)(`li`,{tabIndex:-1,className:a,ref:i.setRefElement,role:`option`,"aria-selected":t,id:`typeahead-item-`+e,onMouseEnter:r,onClick:n,children:[i.icon,(0,K.jsx)(`span`,{className:`text`,children:i.title})]},i.key)}function htt({close:e,editor:t,anchorElementRef:n,resolution:r,options:i,menuRenderFn:a,onSelectOption:o,shouldSplitNodeWithQuery:s=!1,commandPriority:c=1,preselectFirstItem:l=!0}){let[u,d]=(0,G.useState)(null),f=u===null?null:Math.min(i.length-1,u),p=r.match&&r.match.matchingString;(0,G.useEffect)(()=>{l&&d(0)},[p,l]);let m=(0,G.useCallback)(n=>{t.update(()=>{o(n,r.match!=null&&s?function(e){let t=kr();if(!Jn(t)||!t.isCollapsed())return null;let n=t.anchor;if(n.type!==`text`)return null;let r=n.getNode();if(!r.isSimpleText())return null;let i=n.offset,a=r.getTextContent().slice(0,i),o=e.replaceableString.length,s=i-function(e,t,n){let r=n;for(let n=r;n<=t.length;n++)e.slice(-n)===t.substring(0,n)&&(r=n);return r}(a,e.matchingString,o);if(s<0)return null;let c;return s===0?[c]=r.splitText(i):[,c]=r.splitText(s,i),c}(r.match):null,e,r.match?r.match.matchingString:``)})},[t,s,r.match,o,e]),h=(0,G.useCallback)(e=>{let n=t.getRootElement();n!==null&&(n.setAttribute(`aria-activedescendant`,`typeahead-item-`+e),d(e))},[t]),g=(0,G.useCallback)(()=>n.current&&i.length?Gi.createPortal((0,K.jsx)(`div`,{className:`typeahead-popover mentions-menu`,children:(0,K.jsx)(`ul`,{children:i.map((e,t)=>(0,K.jsx)(mtt,{index:t,isSelected:f===t,onClick:()=>{d(t),m(e)},onMouseEnter:()=>{d(t)},option:e},e.key))})}),n.current):null,[n,i,f,m,d]);(0,G.useEffect)(()=>()=>{let e=t.getRootElement();e!==null&&e.removeAttribute(`aria-activedescendant`)},[t]),utt(()=>{i===null?d(null):f===null&&l&&h(0)},[i,f,h,l]);let _=a==null&&(i===null||!i.length);(0,G.useEffect)(()=>Qn(t.registerCommand(stt,({option:e})=>!(!e.ref||e.ref.current==null||(dtt(e.ref.current),0)),c)),[t,h,c]),(0,G.useEffect)(()=>Qn(t.registerCommand(F,e=>{let n=e;if(_)return!1;let r=f===null||f===i.length-1?0:f+1;h(r);let a=i[r];return a?(a.ref&&a.ref.current&&t.dispatchCommand(stt,{index:r,option:a}),n.preventDefault(),n.stopImmediatePropagation(),!0):(h(-1),n.preventDefault(),n.stopImmediatePropagation(),!0)},c),t.registerCommand(Nn,e=>{let t=e;if(_)return!1;let n=f===null||f===0?i.length-1:f-1;h(n);let r=i[n];return r?(r.ref&&r.ref.current&&dtt(r.ref.current),t.preventDefault(),t.stopImmediatePropagation(),!0):(h(-1),t.preventDefault(),t.stopImmediatePropagation(),!0)},c),t.registerCommand(tr,t=>{let n=t;return!_&&(n.preventDefault(),n.stopImmediatePropagation(),e(),!0)},c),t.registerCommand(Qe,e=>{let t=e;return i!==null&&f!==null&&i[f]!=null&&(t.preventDefault(),t.stopImmediatePropagation(),m(i[f]),!0)},c),t.registerCommand(an,e=>!(i===null||f===null||i[f]==null||e&&e.shiftKey||(e!==null&&(e.preventDefault(),e.stopImmediatePropagation()),m(i[f]),0)),c)),[m,e,t,i,_,f,h,c]);let v=(0,G.useMemo)(()=>({options:i,selectOptionAndCleanUp:m,selectedIndex:f,setHighlightedIndex:d}),[m,f,i]);return a==null?g():a(n,v,r.match?r.match.matchingString:``)}function gtt(e,t){t!=null&&(e.className=t),e.setAttribute(`aria-label`,`Typeahead menu`),e.setAttribute(`role`,`listbox`),e.style.display=`block`,e.style.position=`absolute`}function _tt(e){if(e.position!==`static`)return!0;let t=e.willChange;return e.transform!==`none`||e.perspective!==`none`||e.filter!==`none`||e.backdropFilter!==`none`||e.contain.includes(`paint`)||e.contain.includes(`layout`)||e.contain.includes(`strict`)||e.contain.includes(`content`)||t.includes(`transform`)||t.includes(`perspective`)||t.includes(`filter`)||t.includes(`contain`)}function vtt({options:e,onQueryChange:t,onSelectOption:n,onOpen:r,onClose:i,menuRenderFn:a,triggerFn:o,anchorClassName:s,commandPriority:c=1,parent:l,preselectFirstItem:u=!0,ignoreEntityBoundary:d=!1}){let[f]=ht(),[p,m]=(0,G.useState)(null),h=(0,G.useRef)(0),g=(0,G.useRef)(!1),_=(0,G.useCallback)(()=>{if(!g.current)return;g.current=!1;let e=h.current,t=()=>{h.current===e&&m(null)},n;try{n=i&&i()}finally{n?n.then(t,t):t()}},[i]),v=(0,G.useCallback)(e=>{h.current++,m(e),g.current||(g.current=!0,r?.(e))},[r]),y=function(e,t,n,r,i=!0){let[a]=ht(),o=r??function(e){if(!fr)return;let t=e.getRootElement();if(t!==null){let e=t.getRootNode();return Wn(e)?e:t.ownerDocument.body}return document.body}(a),s=fr?kee(a.getRootElement()).createElement(`div`):null,c=(0,G.useRef)(s),l=(0,G.useCallback)(()=>{if(c.current===null||o===void 0)return;c.current.style.top=c.current.style.bottom;let t=a.getRootElement(),r=c.current,s=r.firstChild;if(t!==null&&e!==null){let{left:a,top:l,width:u,height:d}=e.getRect(),f=c.current.offsetHeight,p=function(e){let t=Wn(e)?e.host:e;for(let e=fe(t)?t:null;e!==null;e=ste(e)){let t=e.ownerDocument.defaultView;if(t===null)break;if(_tt(t.getComputedStyle(e))){let t=e.getBoundingClientRect();return{left:t.left+e.clientLeft-e.scrollLeft,top:t.top+e.clientTop-e.scrollTop}}}return null}(o),m=e=>p===null?e+window.pageXOffset:e-p.left,h=e=>p===null?e+(i?window.pageYOffset:0):e-p.top;if(r.style.top=`${h(l+f+3)}px`,r.style.left=`${m(a)}px`,r.style.height=`${d}px`,r.style.width=`${u}px`,s!==null){s.style.top=`${l}`;let e=s.getBoundingClientRect(),n=e.height,i=e.width,o=t.getBoundingClientRect();a+i>o.right&&(r.style.left=`${m(o.right-i)}px`),(l+n>window.innerHeight||l+n>o.bottom)&&l-o.top>n+d&&(r.style.top=`${h(l-n-d)}px`)}r.isConnected||(gtt(r,n),o.append(r)),r.setAttribute(`id`,`typeahead-menu`),t.setAttribute(`aria-controls`,`typeahead-menu`)}},[a,e,i,n,o]);(0,G.useEffect)(()=>{let t=a.getRootElement();return e!==null&&l(),()=>{t!==null&&t.removeAttribute(`aria-controls`);let e=c.current;e!==null&&e.isConnected&&(e.remove(),e.removeAttribute(`id`))}},[a,l,e]);let u=(0,G.useCallback)(n=>{e!==null&&(n||t(null))},[e,t]);return ptt(e,c.current,l,u),s!=null&&s===c.current&&(gtt(s,n),o?.append(s)),c}(p,(0,G.useCallback)(e=>{e===null?_():m(e)},[_]),s,l);return(0,G.useEffect)(()=>{let e=f.registerUpdateListener(()=>{f.read(`latest`,()=>{if(!f.isEditable())return void _();let e=()=>{f.isComposing()||_()},n=f._window||window,r=n.document.createRange(),i=kr(),a=function(e){let t=null;return e.read(`latest`,()=>{let e=kr();Jn(e)&&(t=function(e){let t=e.anchor;if(t.type!==`text`)return null;let n=t.getNode();if(!n.isSimpleText())return null;let r=t.offset;return n.getTextContent().slice(0,r)}(e))}),t}(f);if(!Jn(i)||!i.isCollapsed()||a===null||r===null)return void e();let s=o(a,f);if(t(s?s.matchingString:null),s!==null&&(d||!function(e,t){return t===0&&e.read(`latest`,()=>{let e=kr();if(Jn(e)){let t=e.anchor.getNode().getPreviousSibling();return it(t)&&t.isTextEntity()}return!1})}(f,s.leadOffset))&&function(e,t,n,r){let i=Te(n);if(i===null||!i.isCollapsed)return!1;let a=It(i,r),o=a.anchorNode,s=e,c=a.anchorOffset;if(o==null||c==null)return!1;try{t.setStart(o,s),t.setEnd(o,c)}catch{return!1}return!0}(s.leadOffset,r,n,f.getRootElement()))return void(0,G.startTransition)(()=>v({getRect:()=>r.getBoundingClientRect(),match:s}));e()})});return()=>{e()}},[f,o,t,p,_,v,d]),(0,G.useEffect)(()=>f.registerEditableListener(e=>{e||_()}),[f,_]),p===null||f===null||y.current===null?null:(0,K.jsx)(htt,{close:_,resolution:p,editor:f,anchorElementRef:y,options:e,menuRenderFn:a,shouldSplitNodeWithQuery:!0,onSelectOption:n,commandPriority:c,preselectFirstItem:u})}function M9(e){"@babel/helpers - typeof";return M9=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},M9(e)}function ytt(e,t){if(M9(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(M9(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function btt(e){var t=ytt(e,`string`);return M9(t)==`symbol`?t:t+``}function N9(e,t,n){return(t=btt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var xtt=class extends ltt{constructor(e,t){super(e),N9(this,`title`,void 0),N9(this,`icon`,void 0),N9(this,`description`,void 0),N9(this,`keywords`,void 0),N9(this,`section`,void 0),N9(this,`nested`,void 0),N9(this,`onSelect`,void 0),this.title=e,this.icon=t.icon,this.description=t.description??``,this.keywords=t.keywords??[],this.section=t.section??`Basic blocks`,this.nested=t.nested??!0,this.onSelect=t.onSelect}},Stt=20;function P9(e,t){let n=g9(e);return new xtt(n.title,{...t,icon:(0,G.createElement)(n.icon,{size:Stt}),description:t.description??n.description,section:D9e(n.group)})}function Ctt(){return[P9(`paragraph`,{keywords:[`paragraph`,`text`,`plain`],onSelect:e=>{e.update(()=>{let e=kr();Jn(e)&&ee(e,()=>on())})}}),P9(`h1`,{keywords:[`heading`,`h1`,`title`],onSelect:e=>{e.update(()=>{let e=kr();Jn(e)&&ee(e,()=>ae(`h1`))})}}),P9(`h2`,{keywords:[`heading`,`h2`,`subtitle`],onSelect:e=>{e.update(()=>{let e=kr();Jn(e)&&ee(e,()=>ae(`h2`))})}}),P9(`h3`,{keywords:[`heading`,`h3`],onSelect:e=>{e.update(()=>{let e=kr();Jn(e)&&ee(e,()=>ae(`h3`))})}}),P9(`quote`,{keywords:[`quote`,`blockquote`],onSelect:e=>{e.update(()=>{let e=kr();if(!Jn(e))return;let t=e.anchor.getNode().getTopLevelElementOrThrow(),n=xr(),r=on();r.append(...t.getChildren()),n.append(r),t.replace(n),r.selectEnd()})}}),P9(`divider`,{keywords:[`divider`,`hr`,`rule`,`separator`],onSelect:e=>{e.dispatchCommand(mA,void 0)}}),P9(`table`,{keywords:[`table`,`grid`],nested:!1,onSelect:e=>{e.dispatchCommand(lM,{columns:`3`,rows:`3`,includeHeaders:!0})}}),P9(`bullet`,{keywords:[`list`,`bullet`,`unordered`],onSelect:e=>{e.dispatchCommand(mt,void 0)}}),P9(`number`,{keywords:[`list`,`ordered`,`number`],onSelect:e=>{e.dispatchCommand(I,void 0)}}),P9(`check`,{keywords:[`task`,`todo`,`checkbox`,`checklist`],onSelect:e=>{e.dispatchCommand(dn,void 0)}})]}var wtt=`qolrkf0`,Ttt=`qolrkf1`,Ett=`qolrkf2`,Dtt=`qolrkf3`,Ott=`qolrkf5`,ktt=`qolrkf6`,Att=`qolrkf7`,jtt=`qolrkf8`,Mtt=`qolrkf9`,Ntt=`qolrkfa`,Ptt=`qolrkfc`;function Ftt(e){let t=[],n=new Map;return e.forEach((e,r)=>{let i=n.get(e.section);i||(i={label:e.section,items:[]},n.set(e.section,i),t.push(i)),i.items.push({item:e,globalIndex:r})}),t}function Itt(e,t){return`${e}-option-${t}`}function Ltt({className:e,escapeHint:t,id:n,items:r,onHighlight:i,onSelect:a,query:o,ref:s,selectedIndex:c,style:l,variant:u=`floating`}){let d=(0,G.useMemo)(()=>Ftt(r),[r]),f=[wtt,u===`embedded`?Ttt:``,e].filter(Boolean).join(` `);return(0,K.jsx)(`div`,{className:f,ref:s,style:l,children:r.length===0?(0,K.jsxs)(`div`,{className:Ptt,"data-slot":`slash-menu-empty`,role:`status`,children:[(0,K.jsx)(`span`,{children:o?`No blocks match “${o}”`:`No blocks`}),t&&(0,K.jsxs)(`span`,{className:`qolrkfd`,children:[(0,K.jsx)(ar,{keys:`Esc`,size:`sm`,tone:`muted`}),`keep as text`]})]}):(0,K.jsx)(`ul`,{className:Ett,id:n,role:`listbox`,children:d.map((e,t)=>(0,K.jsxs)(`li`,{className:Dtt,role:`presentation`,children:[t>0&&(0,K.jsx)(`div`,{className:`qolrkf4`}),(0,K.jsx)(`div`,{className:Ott,"data-slot":`slash-menu-section`,children:e.label}),(0,K.jsx)(`ul`,{"aria-label":e.label,className:ktt,role:`group`,children:e.items.map(({item:e,globalIndex:t})=>(0,K.jsxs)(`li`,{"aria-selected":t===c,className:Att,id:n?Itt(n,t):void 0,ref:e.setRefElement,role:`option`,tabIndex:-1,onClick:()=>a(e),onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>i(t),children:[(0,K.jsx)(`span`,{className:jtt,children:e.icon}),(0,K.jsxs)(`span`,{className:Mtt,children:[(0,K.jsx)(`span`,{className:Ntt,children:e.title}),e.description&&(0,K.jsx)(`span`,{className:`qolrkfb`,children:e.description})]})]},e.key))})]},e.label))})})}function Rtt({anchorElement:e,options:t,query:n=``,selectedIndex:r,selectOptionAndCleanUp:i,setHighlightedIndex:a}){let{refs:o,floatingStyles:s}=c({placement:`bottom-start`,strategy:`absolute`,middleware:[_(8),g({fallbackPlacements:[`top-start`],padding:8}),p({padding:8})],whileElementsMounted:y});return(0,G.useEffect)(()=>{o.setReference(e)},[e,o]),(0,K.jsx)(Ltt,{escapeHint:!0,items:t,query:n,ref:o.setFloating,selectedIndex:r,style:s,onHighlight:a,onSelect:i})}function ztt(e){return new xtt(e.title,{description:e.description,icon:(0,G.isValidElement)(e.icon)?e.icon:void 0,keywords:e.keywords,nested:e.nested,section:e.section,onSelect:e.onSelect})}function Btt(e){return _9(e.map(e=>({title:e.title,description:e.description||void 0,icon:e.icon,keywords:e.keywords,nested:e.nested,section:e.section,onSelect:e.onSelect}))).map(ztt)}function Vtt(e){return _9(BR(e).filter(e=>!e.placement||e.placement.includes(`slash`))).map(ztt)}function Htt(e,t){return Btt([...Ctt(),...Vtt(e),...t??[]])}function Utt(e,t){if(!e)return t;let n=e.toLowerCase();return t.filter(e=>e.title.toLowerCase().includes(n)?!0:e.keywords.some(e=>e.toLowerCase().includes(n)))}function Wtt({items:e,extraItems:t,nested:n,triggerChar:r=`/`}){let[i]=ht(),[a,o]=(0,G.useState)(null),s=(0,G.useMemo)(()=>{let r=e??Htt(i,t);return n?r.filter(e=>e.nested!==!1):r},[e,t,n,i]),c=(0,G.useMemo)(()=>Utt(a??``,s),[a,s]),l=ctt(r,{minLength:0}),u=(0,G.useCallback)((e,t,n,r)=>{i.update(()=>{if(t){let e=kr();Jn(e)&&t.remove()}}),n(),e.onSelect(i,r)},[i]);return(0,K.jsx)(vtt,{options:c,triggerFn:l,menuRenderFn:(e,{selectedIndex:t,selectOptionAndCleanUp:n,setHighlightedIndex:r},i)=>{let a=e.current;return a?(0,Gi.createPortal)((0,K.jsx)(Ye,{children:(0,K.jsx)(Rtt,{anchorElement:a,options:c,query:i,selectOptionAndCleanUp:n,selectedIndex:t,setHighlightedIndex:r})}),a):null},onQueryChange:o,onSelectOption:u})}var F9={editWrapper:`rich-katex-edit-wrapper`,panel:`rich-katex-editor-panel`,header:`rich-katex-editor-header`,tabs:`rich-katex-editor-tabs`,bodyScrollArea:`rich-katex-editor-body-scroll-area`,body:`rich-katex-editor-body`,textarea:`rich-katex-editor-textarea`,preview:`rich-katex-editor-preview`,previewEmpty:`rich-katex-editor-preview-empty`,snippetGroups:`rich-katex-editor-snippet-groups`,snippetGroup:`rich-katex-editor-snippet-group`,snippetGroupLabel:`rich-katex-editor-snippet-group-label`,snippetList:`rich-katex-editor-snippet-list`,snippetButton:`rich-katex-editor-snippet-button`,snippetMeta:`rich-katex-editor-snippet-meta`,snippetName:`rich-katex-editor-snippet-name`,snippetHint:`rich-katex-editor-snippet-hint`,snippetPreview:`rich-katex-editor-snippet-preview`,snippetsPlaceholder:`rich-katex-editor-snippets-placeholder`,footer:`rich-katex-editor-footer`,charCount:`rich-katex-editor-charcount`},Gtt=`mkenhu0`,Ktt=`mkenhu1`,qtt=`mkenhu2`,Jtt=`mkenhu3`;function Ytt(e,t={}){if(t.isDirty||e.altKey||!e.metaKey&&!e.ctrlKey)return null;let n=e.key.toLowerCase();return n===`z`?e.shiftKey?`redo`:`undo`:n===`y`&&e.ctrlKey&&!e.metaKey&&!e.shiftKey?`redo`:null}var I9=`__cursor__`,Xtt=[{id:`frac`,title:`Fraction`,template:`\\frac{1}{${I9}}`,previewEquation:`\\frac{a}{b}`,category:`Basic`,keywords:[`fraction`,`divide`,`ratio`]},{id:`sqrt`,title:`Square Root`,template:`\\sqrt{${I9}}`,previewEquation:`\\sqrt{x}`,category:`Basic`,keywords:[`root`,`radical`]},{id:`alpha`,title:`Alpha`,template:`\\alpha${I9}`,previewEquation:`\\alpha`,category:`Greek`,keywords:[`greek`,`letter`]},{id:`theta`,title:`Theta`,template:`\\theta${I9}`,previewEquation:`\\theta`,category:`Greek`,keywords:[`greek`,`angle`,`letter`]},{id:`sum`,title:`Summation`,template:`\\sum_{i=1}^{n} ${I9}`,previewEquation:`\\sum_{i=1}^{n} x_i`,category:`Operators`,keywords:[`series`,`sigma`,`total`]},{id:`int`,title:`Integral`,template:`\\int_{a}^{b} ${I9} \\, dx`,previewEquation:`\\int_{a}^{b} f(x) \\, dx`,category:`Operators`,keywords:[`integral`,`calculus`]},{id:`matrix`,title:`Matrix`,template:`\\begin{bmatrix}${I9}\\end{bmatrix}`,previewEquation:`\\begin{bmatrix} a & b \\\\ c & d \\end{bmatrix}`,category:`Structures`,keywords:[`array`,`linear algebra`]},{id:`cases`,title:`Cases`,template:`\\begin{cases}${I9}\\end{cases}`,previewEquation:`\\begin{cases} x & x > 0 \\\\ 0 & x = 0 \\end{cases}`,category:`Structures`,keywords:[`piecewise`,`conditional`]}];function Ztt(e){let t=e.trim().toLowerCase();return t?Xtt.filter(e=>[e.id,e.title,e.category,e.previewEquation,...e.keywords].join(` `).toLowerCase().includes(t)):Xtt}function Qtt(e,t,n,r){let i=n??e.length,a=r??i,o=t.indexOf(I9),s=t.replace(I9,``),c=e.slice(0,i)+s+e.slice(Math.max(i,a)),l=i+(o>=0?o:s.length);return{value:c,selectionStart:l,selectionEnd:l}}var $tt=[`Basic`,`Greek`,`Operators`,`Structures`],ent=[{value:`edit`,label:`Edit`},{value:`snippets`,label:`Snippets`}];function tnt({nodeKey:e,equation:t,displayMode:n,autoOpenOnMount:r,children:i}){let[a]=ht(),o=a.isEditable(),s=(0,G.useId)(),[c,l]=(0,G.useState)(r),[u,d]=(0,G.useState)(t),[f,p]=(0,G.useState)(`edit`),[m,h]=(0,G.useState)(``),g=(0,G.useRef)(null),_=(0,G.useRef)({start:null,end:null}),v=u!==t,y=(0,G.useCallback)(e=>{e&&(_.current={start:e.selectionStart,end:e.selectionEnd})},[]);(0,G.useEffect)(()=>{r&&a.update(()=>{let t=Dn(e);($N(t)||XN(t))&&t.setShouldAutoOpenOnMount(!1)})},[r,a,e]),(0,G.useEffect)(()=>{d(t)},[t]),(0,G.useEffect)(()=>{c&&g.current&&(g.current.focus(),g.current.select(),y(g.current))},[c,y]);let b=(0,G.useCallback)(()=>{d(t),p(`edit`),h(``),l(!1)},[t]),x=(0,G.useRef)(!1),S=(0,G.useCallback)(async()=>{if(!v)b();else if(!x.current){x.current=!0;try{await Se()&&b()}finally{x.current=!1}}},[b,v]),C=(0,G.useCallback)(()=>{let t=u.trim();t&&(a.update(()=>{let n=Dn(e);($N(n)||XN(n))&&n.getEquation()!==t&&n.setEquation(t)}),p(`edit`),h(``),l(!1))},[a,e,u]),w=(0,G.useCallback)(()=>{a.update(()=>{Dn(e)?.remove()}),Pe({title:n?`Math block deleted`:`Math deleted`,action:{label:`Undo`,onClick:()=>a.dispatchCommand(U,void 0)}})},[n,a,e]),T=(0,G.useCallback)(()=>{navigator.clipboard?.writeText(u).then(()=>Pe({title:`LaTeX copied`,tone:`success`}),()=>Pe({title:`Could not copy LaTeX`,tone:`error`}))},[u]),E=(0,G.useCallback)(e=>{let t=Qtt(u,e,_.current.start,_.current.end);d(t.value),p(`edit`),requestAnimationFrame(()=>{let e=g.current;e&&(e.focus(),e.setSelectionRange(t.selectionStart,t.selectionEnd),_.current={start:t.selectionStart,end:t.selectionEnd})})},[u]),D=(0,G.useMemo)(()=>Ztt(m),[m]),O=(0,G.useMemo)(()=>$tt.map(e=>({category:e,items:D.filter(t=>t.category===e)})).filter(e=>e.items.length>0),[D]),k=(0,G.useCallback)(e=>{e.key===`Escape`?(e.preventDefault(),S()):(n&&e.key===`Enter`&&(e.metaKey||e.ctrlKey)||!n&&e.key===`Enter`&&!e.shiftKey)&&(e.preventDefault(),C())},[S,C,n]),A=(0,G.useCallback)(e=>{let t=Ytt(e,{isDirty:v||m!==``});t&&(e.preventDefault(),e.stopPropagation(),a.dispatchCommand(t===`undo`?U:gt,void 0))},[v,a,m]);if(!o)return i;let j=(0,K.jsxs)(Zn,{children:[(0,K.jsx)(On,{render:(0,K.jsx)(Fe,{icon:!0,"aria-label":`More actions`,size:`md`}),children:(0,K.jsx)(Nr,{})}),(0,K.jsxs)(Rt,{align:`end`,children:[(0,K.jsxs)(Ut,{disabled:!u.trim(),onClick:T,children:[(0,K.jsx)(Ir,{}),`Copy LaTeX`]}),(0,K.jsx)(ur,{}),(0,K.jsxs)(Ut,{variant:`destructive`,onClick:w,children:[(0,K.jsx)(Mr,{}),`Delete`]})]})]});return(0,K.jsxs)(gn,{open:c,onOpenChange:(e,t)=>{e?l(!0):(t?.reason!==`outside-press`&&t?.reason!==`focus-out`||!v)&&(t?.reason===`escape-key`?S():b())},children:[(0,K.jsx)(en,{nativeButton:!1,render:(0,K.jsx)(`span`,{className:`${Gtt} ${F9.editWrapper}`,title:`Click to edit`}),children:i}),(0,K.jsxs)(yn,{flush:!0,className:`${Ktt} ${F9.panel}`,initialFocus:g,side:`bottom`,size:`lg`,onKeyDown:A,children:[(0,K.jsx)(wn,{className:F9.header,icon:(0,K.jsx)(Mi,{}),title:n?`Math block`:`Inline math`,actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(xt,{className:`${qtt} ${F9.tabs}`,items:ent,value:f,onChange:p}),j]})}),(0,K.jsxs)(`div`,{className:`${Jtt} ${F9.bodyScrollArea}`,children:[f===`edit`&&(0,K.jsxs)(Xn,{className:F9.body,children:[(0,K.jsx)(Kn,{id:s,label:`LaTeX`,children:(0,K.jsx)(`textarea`,{autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,className:`mkenhu4 ${F9.textarea}`,id:s,placeholder:`e.g. \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}`,ref:g,rows:n?4:2,spellCheck:!1,value:u,onClick:e=>y(e.currentTarget),onKeyDown:k,onKeyUp:e=>y(e.currentTarget),onSelect:e=>y(e.currentTarget),onChange:e=>{d(e.target.value),y(e.target)}})}),(0,K.jsx)(`div`,{"aria-label":`Preview`,className:`mkenhu5 ${F9.preview}`,role:`img`,children:u.trim()?(0,K.jsx)(cU,{displayMode:n,equation:u}):(0,K.jsx)(`span`,{className:`mkenhu6 ${F9.previewEmpty}`,children:`Preview appears as you type`})})]}),f===`snippets`&&(0,K.jsxs)(Xn,{className:F9.body,children:[(0,K.jsx)(ct,{"aria-label":`Search snippets`,autoComplete:`off`,placeholder:`Search snippets: frac, matrix, sum…`,value:m,onChange:e=>h(e.target.value)}),O.length>0?(0,K.jsx)(`div`,{className:`mkenhu7 ${F9.snippetGroups}`,children:O.map(e=>(0,K.jsxs)(`section`,{className:`mkenhu8 ${F9.snippetGroup}`,children:[(0,K.jsx)(`div`,{className:`mkenhu9 ${F9.snippetGroupLabel}`,children:e.category}),(0,K.jsx)(`div`,{className:`mkenhua ${F9.snippetList}`,children:e.items.map(e=>(0,K.jsxs)(`button`,{className:`mkenhub ${F9.snippetButton}`,type:`button`,onClick:()=>E(e.template),children:[(0,K.jsxs)(`span`,{className:`mkenhuc ${F9.snippetMeta}`,children:[(0,K.jsx)(`span`,{className:`mkenhud ${F9.snippetName}`,children:e.title}),(0,K.jsx)(`span`,{className:`mkenhue ${F9.snippetHint}`,children:e.template.replace(`__cursor__`,``)})]}),(0,K.jsx)(`span`,{className:`mkenhuf ${F9.snippetPreview}`,children:(0,K.jsx)(cU,{displayMode:!1,equation:e.previewEquation})})]},e.id))})]},e.category))}):(0,K.jsxs)(`div`,{className:`mkenhug ${F9.snippetsPlaceholder}`,children:[`No snippets match “`,m.trim(),`”`]})]})]}),(0,K.jsxs)(Bn,{className:F9.footer,hint:(0,K.jsx)(`span`,{className:F9.charCount,children:`${u.length} ${u.length===1?`character`:`characters`}`}),children:[(0,K.jsx)(Fe,{size:`md`,variant:`outline`,onClick:b,children:`Cancel`}),(0,K.jsxs)(Fe,{disabled:!u.trim(),size:`md`,variant:`solid`,onClick:C,children:[`Save`,(0,K.jsx)(ar,{keys:n?[`mod`,`enter`]:[`enter`],size:`sm`,tone:`inverted`})]})]})]})]})}var nnt=[class e extends JN{static clone(t){return new e(t.__equation,t.__key,t.getShouldAutoOpenOnMount())}static importJSON(t){return new e(t.equation).updateFromJSON(t)}decorate(e,t){let n=qj(`KaTeX`,cU,{equation:this.__equation,displayMode:!0});return(0,G.createElement)(tnt,{nodeKey:this.__key,equation:this.__equation,displayMode:!0,autoOpenOnMount:this.getShouldAutoOpenOnMount(),children:n})}},class e extends ZN{static clone(t){return new e(t.__equation,t.__key,t.getShouldAutoOpenOnMount(),t.__color)}static importJSON(t){let n=t,r=new e(n.equation);return n.color&&r.setColor(n.color),r.updateFromJSON(t)}decorate(e,t){let n=qj(`KaTeX`,cU,{equation:this.__equation,displayMode:!1}),r=(0,G.createElement)(tnt,{nodeKey:this.__key,equation:this.__equation,displayMode:!1,autoOpenOnMount:this.getShouldAutoOpenOnMount(),children:n});return this.__color?(0,G.createElement)(`span`,{style:{color:this.__color}},r):r}}],rnt=`agent-stream-hidden`,L9=[`agent-stream-fade-1`,`agent-stream-fade-2`,`agent-stream-fade-3`],int=22,ant=()=>typeof Highlight<`u`&&typeof CSS<`u`&&!!CSS.highlights,ont=e=>e?document.createTreeWalker(e,NodeFilter.SHOW_TEXT).nextNode():null;function R9(e,t,n,r){return e.getEditorState().read(()=>{let i=Dn(t);if(!rr(i))return null;let a=document.createRange(),o=0,s=!1;for(let t of i.getAllTextNodes()){let i=t.getTextContentSize(),c=ont(e.getElementByKey(t.getKey()));if(!s&&n<=o+i){if(!c)return null;a.setStart(c,Math.min(n-o,c.length)),s=!0}if(s&&r<=o+i)return c?(a.setEnd(c,Math.min(r-o,c.length)),a):null;o+=i}return null})}var snt=e=>{let t=e?.getClientRects?.();return t?Array.from(t).at(-1)??null:null};function cnt(e,t){if(t.kind===`block`){let n=e.getElementByKey(t.blockKey)?.getBoundingClientRect();return n?{left:n.left,top:n.bottom-int,height:int}:null}if(t.offset>0){let n=snt(R9(e,t.blockKey,t.offset-1,t.offset));if(n)return{left:n.right,top:n.top,height:n.height}}let n=R9(e,t.blockKey,t.offset,t.offset+1)?.getClientRects?.()[0];return n?{left:n.left,top:n.top,height:n.height}:null}var z9=new Map;function B9(e,t,n){let r=z9.get(t)??new Map;z9.set(t,r),n.length>0?r.set(e,n):r.delete(e);let i=[...r.values()].flat();i.length>0?CSS.highlights.set(t,new Highlight(...i)):CSS.highlights.delete(t)}function lnt(e){for(let t of z9.keys())B9(e,t,[])}function unt(e){for(let t=e.parentElement;t;t=t.parentElement){let{overflowY:e}=getComputedStyle(t);if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t}return document.scrollingElement??document.documentElement}var dnt=e=>yr(e)||_r(e)||Er(e),V9=e=>rr(e)?e.getAllTextNodes().map(e=>e.getTextContent()).join(``):``;function fnt(e){return e.read(()=>{let e=new Map;for(let t of Sr().getChildren())e.set(t.getKey(),{isText:dnt(t),text:V9(t)});return e})}function pnt(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;let i=0;for(;i<n-r&&e[e.length-1-i]===t[t.length-1-i];)i++;return{from:r,to:t.length-i}}function mnt(e,t){let n=fnt(e);return t.read(()=>{let e=[];for(let t of Sr().getChildren()){let r=t.getKey(),i=n.get(r);if(!dnt(t)){i||e.push({kind:`block`,blockKey:r});continue}let a=V9(t),o=i?.isText?i.text:``;if(a===o)continue;let{from:s,to:c}=pnt(o,a);c>s&&e.push({kind:`text`,blockKey:r,from:s,to:c,text:a})}return e})}var H9=1e-9,hnt=e=>e.kind===`text`?e.to-e.from:1,gnt=e=>e.segment.kind===`text`?{kind:`text`,blockKey:e.segment.blockKey,offset:e.segment.from+Math.floor(e.progress)}:{kind:`block`,blockKey:e.segment.blockKey};function _nt(e){let t=[],n=null,r=e=>{e.progress=e.size,n=gnt(e)},i=()=>{t=t.filter(e=>e.progress<e.size-H9)},a=e=>{if(e.kind!==`text`)return!1;let n=t.filter(t=>t.segment.blockKey===e.blockKey),i=n.length===1?n[0]:void 0;if(i?.segment.kind!==`text`){for(let e of n)r(e);return!1}let a=i.segment,o=a.from+Math.floor(i.progress);if(e.from<o)return r(i),!1;if(e.from>a.to)return!1;let s=a.to+e.text.length-a.text.length,c=Math.max(e.to,s);return i.segment={...a,to:c,text:e.text},i.size=c-a.from,!0},o=()=>t.reduce((e,t)=>e+(t.size-t.progress)/t.rate,0);return{enqueue(n){if(n.length===0)return;let{backlogSeconds:s,charsPerSecond:c,maxSeconds:l}=e(),u=n.reduce((e,t)=>e+hnt(t),0),d=Math.max(c,u/l);if(o()+u/d>s+H9){for(let e of t)r(e);t=[]}for(let e of n)a(e)||t.push({progress:0,rate:d,segment:e,size:hnt(e)});i()},advance(e){let a=e;for(let e of t){if(a<=0)break;let t=(e.size-e.progress)/e.rate;a+H9>=t?(a-=t,r(e)):(e.progress+=e.rate*a,a=0,e.progress>=1&&(n=gnt(e)))}i()},finish(){t=[],n=null},invalidate(e){for(let n of t)n.segment.blockKey===e&&r(n);i()},snapshot(){return{caret:n,idle:t.length===0,pending:t.map(e=>({revealed:Math.floor(e.progress+H9),segment:e.segment}))}}}}var vnt=2,ynt=48,bnt=.1,xnt=e=>{if(!e)return null;let{segment:t}=e;return t.kind===`text`?{kind:`text`,blockKey:t.blockKey,offset:t.to}:{kind:`block`,blockKey:t.blockKey}},Snt=(e,t)=>e===t||!!e&&!!t&&e.kind===t.kind&&e.blockKey===t.blockKey&&(e.kind===`block`||e.offset===t.offset);function Cnt(e,t){if(!ant())return{dispose:()=>{}};let n={},r=_nt(t),i=new Set,a=0,o=0,s=!0,c=!1,l=null,u=null,d=e=>t().onPlaybackChange?.(e),f=e=>{e&&!Snt(e,u)&&(u=e,t().onCaret?.(e))},p=(t,n)=>{let r=e.getElementByKey(t);r&&(r.style.visibility=n?`hidden`:``),n?i.add(t):i.delete(t)},m=n=>{let r=e.getRootElement();if(!s||!r)return;let i=t().scrollContainer??unt(r),a=i===document.scrollingElement?window.innerHeight:i.getBoundingClientRect().bottom,o=n.top+n.height+ynt-a;o>0&&(i.scrollTop+=o)},h=()=>{let{pending:t,caret:a}=r.snapshot(),o=[],s=L9.map(()=>[]),u=new Set;t.forEach(({segment:t,revealed:n},r)=>{if(t.kind===`block`){n<1&&u.add(t.blockKey);return}let i=t.from+n,a=R9(e,t.blockKey,i,t.to);a&&o.push(a),r===0&&n!==0&&L9.forEach((n,r)=>{let a=i-r*vnt,o=Math.max(t.from,a-vnt),c=a>o?R9(e,t.blockKey,o,a):null;c&&s[r].push(c)})});for(let e of i)u.has(e)||p(e,!1);for(let e of u)p(e,!0);B9(n,rnt,o),L9.forEach((e,t)=>B9(n,e,s[t]));let h=a?.blockKey??t[0]?.segment.blockKey??null;h!==l&&c&&(l=h,d({playing:!0,blockKey:h})),f(a);let g=a?cnt(e,a):null;g&&m(g)},g=()=>{cancelAnimationFrame(a),a=0;let e=xnt(r.snapshot().pending.at(-1))??r.snapshot().caret;r.finish();let t=c;c=!1,l=null,h(),lnt(n),f(e),t&&d({playing:!1,blockKey:null})},_=e=>{r.advance(Math.min(bnt,(e-o)/1e3)),o=e,h(),r.snapshot().idle?g():a=requestAnimationFrame(_)},v=()=>{let{pending:t}=r.snapshot();e.getEditorState().read(()=>{for(let{segment:e}of t){if(e.kind!==`text`)continue;let t=Dn(e.blockKey);t&&V9(t)===e.text||r.invalidate(e.blockKey)}})},y=e.registerUpdateListener(({tags:e,prevEditorState:t,editorState:n,dirtyElements:i,dirtyLeaves:u})=>{let d=i.size>0||u.size>0,f=e.has(X5e);f&&r.enqueue(mnt(t,n)),d&&(c||f)&&v(),f&&!r.snapshot().idle?(s=!0,c||(c=!0,l=null),h(),a||=(o=performance.now(),requestAnimationFrame(_))):c&&(r.snapshot().idle?g():h())}),b=()=>{s=!1},x=e.registerRootListener((e,t)=>{for(let n of[`keydown`,`paste`,`pointerdown`])t?.removeEventListener(n,g),e?.addEventListener(n,g)}),S=()=>{document.visibilityState===`hidden`&&c&&g()};return window.addEventListener(`wheel`,b,{passive:!0}),window.addEventListener(`touchmove`,b,{passive:!0}),document.addEventListener(`visibilitychange`,S),{dispose(){c&&d({playing:!1,blockKey:null}),c=!1,cancelAnimationFrame(a);for(let e of i)p(e,!1);lnt(n),y(),x(),window.removeEventListener(`wheel`,b),window.removeEventListener(`touchmove`,b),document.removeEventListener(`visibilitychange`,S)}}}var wnt=1e4,Tnt=3e5,Ent=3,Dnt=26,U9={closed:!1,eyeShift:0,legs:`stand`,lift:0,scaleX:1,scaleY:1},W9={blink:130,double:320,look:1100,lookAway:900,hop:360,tap:660,stretch:640},Ont=[[`blink`,3],[`double`,1],[`look`,2],[`lookAway`,1],[`hop`,2],[`tap`,1],[`stretch`,1]],knt=[[`blink`,3],[`look`,1],[`lookAway`,1]],Ant=[800,2400],jnt=[2200,4600],Mnt=e=>e>=30;function Nnt(e,t){if(e===null)return`writing`;let n=t-e;return n<wnt?`fresh`:n<Tnt?`quiet`:`resting`}function Pnt({fromBottom:e,toBottom:t,hidden:n}){return Math.abs(t-e)<=Ent?`none`:n?`drop`:`arc`}function Fnt(e,t,n){if(e.x<=t)return{x:t,v:0};let r=Dnt,i=1+2*n*r,a=n*r*r,o=1/(i+n*a);return{x:(i*e.x+n*e.v+n*a*t)*o,v:(e.v+a*(t-e.x))*o}}function Int(e,t){let n=e===`resting`,r=n?knt:Ont,i=r.reduce((e,[,t])=>e+t,0),a=t()*i,o=r.at(-1)[0];for(let[e,t]of r)if(a-=t,a<0){o=e;break}let[s,c]=n?jnt:Ant;return{action:o,waitMs:W9[o]+s+(c-s)*t()}}function Lnt(e,t){if(t<0||t>=W9[e])return U9;let n=t/W9[e];switch(e){case`blink`:return{...U9,closed:!0};case`double`:return{...U9,closed:t<100||t>200&&t<300};case`look`:return{...U9,eyeShift:t>80&&t<1020?-1:0};case`lookAway`:return{...U9,eyeShift:+(t>80&&t<820)};case`tap`:return{...U9,legs:Math.floor(t/110)%2?`stepA`:`stepB`};case`stretch`:{let e=Math.sin(Math.PI*n);return{...U9,scaleX:1-.07*e,scaleY:1+.12*e}}case`hop`:return n<.18?{...U9,scaleX:1.12,scaleY:.86}:{...U9,legs:`tucked`,lift:9*Math.sin(Math.PI*(n-.18)/.82),scaleX:.95,scaleY:1.07}}}var Rnt={stand:[2,2,2,2],tucked:[1,1,1,1],stepA:[2,1,2,1],stepB:[1,2,1,2]},znt=[3,5,10,12],Bnt=[4,11],Vnt=e=>Rnt[e].map((e,t)=>`M${znt[t]} 8h1v${e}h-1z`).join(``),Hnt=new WeakMap;function Unt(e){let t=Hnt.get(e);if(t)return t;let n=e.querySelector(`[data-part="bob"]`),r=e.querySelector(`[data-part="shadow"]`),i=e.querySelector(`[data-part="legs"]`),a=[...e.querySelectorAll(`[data-part="eye"]`)];if(!n||!r||!i||a.length!==2)return null;let o={bob:n,shadow:r,legs:i,eyes:a};return Hnt.set(e,o),o}function Wnt(e,{x:t,bottom:n,appear:r,sink:i,pose:a}){let o=Unt(e);if(!o)return;let s=.55+.45*r;e.style.opacity=r.toFixed(3),e.style.transform=`translate(${t.toFixed(2)}px, ${(n-15).toFixed(2)}px)`,o.bob.style.transform=`translateY(${(i-a.lift).toFixed(2)}px) scale(${(a.scaleX*s).toFixed(3)}, ${(a.scaleY*s).toFixed(3)})`;let c=1-Math.min(a.lift,16)/26;o.shadow.style.transform=`scaleX(${c.toFixed(3)})`,o.shadow.style.opacity=(.12*c).toFixed(3);let l=Vnt(a.legs);o.legs.getAttribute(`d`)!==l&&o.legs.setAttribute(`d`,l),o.eyes.forEach((e,t)=>{e.setAttribute(`x`,String(Bnt[t]+a.eyeShift)),e.setAttribute(`y`,a.closed?`3`:`2`),e.setAttribute(`height`,a.closed?`1`:`2`)})}var Gnt=`M2 0h12v2h-12zM2 2h12v2h-12zM0 4h16v2h-16zM2 6h12v1h-12z`,Knt=`M2 7h12v1h-12z`;function qnt({fill:e,ref:t}){let n=`color-mix(in srgb, ${e} 86%, ${Vr.black})`;return(0,K.jsxs)(`div`,{"aria-hidden":`true`,"data-agent-pet":``,ref:t,className:`x10l6tqk xu96u03 x13vifvy xvy4d1p xx3o462 x47corl xg01cxk`,children:[(0,K.jsx)(`span`,{"data-part":`shadow`,className:`x10l6tqk xcqyyxr x1pzoy33 x1t1qrwb xuoj239 x16rqkct x1t58bn5 xuo7x8y`}),(0,K.jsx)(`div`,{"data-part":`bob`,className:`x10l6tqk x10a8y8t xqlk7fu x1so62im`,children:(0,K.jsxs)(`svg`,{height:15,shapeRendering:`crispEdges`,viewBox:`0 0 16 10`,width:24,className:`x1lliihq x1rea2x4`,children:[(0,K.jsx)(`path`,{d:Gnt,style:{fill:e}}),(0,K.jsx)(`path`,{d:Knt,style:{fill:n}}),(0,K.jsx)(`path`,{d:Vnt(`stand`),"data-part":`legs`,style:{fill:n}}),(0,K.jsx)(`rect`,{"data-part":`eye`,fill:Vr.black,height:`2`,width:`1`,x:`4`,y:`2`}),(0,K.jsx)(`rect`,{"data-part":`eye`,fill:Vr.black,height:`2`,width:`1`,x:`11`,y:`2`})]})})]})}var Jnt=2,Ynt=300,Xnt=2.4,Znt=16,Qnt=300,$nt=150,ert=e=>e*e*(3-2*e);function trt({agent:e,caret:t,editor:n,stoppedAt:r}){let i=pne(e),a=i.mascot===`clawd`,[o,s]=(0,G.useState)(()=>Nnt(r,performance.now())),c=(0,G.useRef)(null),l=(0,G.useRef)(null),u=(0,G.useRef)(null),d=(0,G.useRef)(null),f=(0,G.useRef)({caret:t,stoppedAt:r,withPet:a});return(0,G.useLayoutEffect)(()=>{f.current={caret:t,stoppedAt:r,withPet:a}},[t,r,a]),(0,G.useEffect)(()=>{let e=matchMedia(`(prefers-reduced-motion: reduce)`),t=0,r=null,i=a=>{t=requestAnimationFrame(i);let o=c.current,p=f.current,m=l.current,h=u.current,g=cnt(n,p.caret),_=n.getElementByKey(p.caret.blockKey);if(!o||!m||!g||!_){m&&(m.style.opacity=`0`),h&&(h.style.opacity=`0`);return}let v=o.getBoundingClientRect(),y=g.left-v.left,b=g.top-v.top;m.style.opacity=``,m.style.transform=`translate(${y}px, ${b}px)`,m.style.height=`${g.height}px`;let x=Nnt(p.stoppedAt,a);if(x!==r&&(r=x,s(x)),!p.withPet||!h)return;let S=Mnt(_.getBoundingClientRect().right-(Number.parseFloat(getComputedStyle(_).paddingRight)||0)-(g.left+Jnt)),C=y+Jnt+6,w=b+g.height,T=e.matches,E=d.current??={appear:0,bottom:w,hidden:!S,idle:null,jump:null,landAt:-1/0,last:a,movedAt:-1/0,nextIdleAt:a+700,phase:0,targetX:C,v:0,x:C},D=Math.min(.05,(a-E.last)/1e3);E.last=a,Math.abs(C-E.targetX)>.5&&(E.movedAt=a),E.targetX=C;let O=U9,k=E.jump?`none`:Pnt({fromBottom:E.bottom,toBottom:w,hidden:E.hidden});if(T)E.x=C,E.v=0,E.bottom=w;else if(k===`drop`)E.x=C,E.v=0,E.appear=0,E.jump={at:a,drop:!0,duration:Qnt,fromBottom:E.bottom,fromX:C};else if(k===`arc`){let e=Math.hypot(C-E.x,w-E.bottom);E.jump={at:a,drop:!1,duration:Math.min(560,320+e*.4),fromBottom:E.bottom,fromX:E.x}}if(!T&&E.jump){let e=E.jump,t=Math.min(1,(a-e.at)/e.duration);if(e.drop)({x:E.x,v:E.v}=Fnt(E,C,D)),E.bottom=e.fromBottom+(w-e.fromBottom)*t*t,O={...U9,legs:`tucked`,scaleX:.94,scaleY:1.08};else{let n=ert(t);E.x=e.fromX+(C-e.fromX)*n,E.bottom=e.fromBottom+(w-e.fromBottom)*n,O={...U9,legs:`tucked`,lift:Znt*Math.sin(Math.PI*t),scaleX:.94,scaleY:1.08}}t>=1&&(E.jump=null,E.landAt=a)}else T||({x:E.x,v:E.v}=Fnt(E,C,D),E.bottom=w);E.hidden=!S,E.appear=T?+!!S:E.appear+(+!!S-E.appear)*(1-Math.exp(-D/.06));let A=x===`writing`;if(!T&&!E.jump){if(A&&(a-E.movedAt<240||Math.abs(E.v)>25)){E.phase+=D*Math.PI*2*1e3/Ynt;let e=Math.sin(E.phase),t=Math.abs(e)<.3;O={...U9,legs:e>0?`stepA`:`stepB`,lift:Xnt*Math.abs(e),scaleX:t?1.06:1,scaleY:t?.92:1}}else E.phase=0;if(!A&&S){if(a>=E.nextIdleAt){let e=Int(x,Math.random);E.idle={action:e.action,at:a},E.nextIdleAt=a+e.waitMs}if(E.idle){let e=a-E.idle.at;O=Lnt(E.idle.action,e),e>=W9[E.idle.action]&&(E.idle.action===`hop`&&(E.landAt=a),E.idle=null)}let e=.5-.5*Math.cos(a/(x===`resting`?3400:2600)*Math.PI*2);O={...O,scaleX:O.scaleX*(1+.02*e),scaleY:O.scaleY*(1-.035*e)}}}A&&(O={...O,eyeShift:-1});let j=(a-E.landAt)/$nt;if(!T&&j<1){let e=1-j;O={...O,scaleX:O.scaleX*(1+.14*e),scaleY:O.scaleY*(1-.18*e)}}let M=x===`resting`&&!E.jump;M&&(O={...O,legs:`tucked`}),T&&(O={...U9,legs:M?`tucked`:`stand`}),Wnt(h,{x:E.x,bottom:E.bottom,appear:E.appear,sink:M?1.5:0,pose:O})};return t=requestAnimationFrame(i),()=>cancelAnimationFrame(t)},[n]),(0,K.jsxs)(`div`,{"data-agent-caret":``,ref:c,className:`x10l6tqk x10a8y8t x1u8a7rm x47corl`,children:[(0,K.jsx)(`div`,{ref:l,...{0:{className:`x10l6tqk xu96u03 x13vifvy xfo62xy x1nj7uno xqz5vs7`},2:{className:`x10l6tqk xu96u03 x13vifvy xfo62xy x1nj7uno xqz5vs7 x1vrnivm x7tkt5m x1htlvfj xa4qsjk x1aquc0h`},1:{className:`x10l6tqk xu96u03 x13vifvy xfo62xy x1nj7uno xqz5vs7 x18km98s`},3:{className:`x10l6tqk xu96u03 x13vifvy xfo62xy x1nj7uno xqz5vs7 x1vrnivm x7tkt5m x1htlvfj xa4qsjk x1aquc0h x18km98s`}}[(o===`writing`||o===`fresh`)<<1|(o===`quiet`||o===`resting`)],style:{backgroundColor:i.color}}),a?(0,K.jsx)(qnt,{fill:i.color,ref:u}):null]})}var nrt=/^\s*(\d+(?:\.\d+)*)[.、)\s]/;function rrt(e,t){for(let n=Math.min(t,e.length-1);n>=0;n--){let t=e[n];if(!t.heading)continue;let r=nrt.exec(t.text)?.[1];return r?`§${r}`:`「${t.text.trim()}」`}return null}function irt(e,t){return e.getEditorState().read(()=>{let e=Dn(t)?.getTopLevelElement(),n=Sr().getChildren().map(e=>({heading:e.getType()===`heading`,text:rr(e)?e.getTextContent():``}));return e?rrt(n,e.getIndexWithinParent()):null})}function art({agent:e=`Agent`,onPlayback:t}){let[n]=ht(),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(null),l=(0,G.useRef)(t),u=(0,G.useRef)(null);return(0,G.useLayoutEffect)(()=>{l.current=t,u.current=r?.blockKey??null},[t,r]),(0,G.useEffect)(()=>n.registerRootListener(e=>c(e?.parentElement??null)),[n]),(0,G.useEffect)(()=>Cnt(n,()=>({backlogSeconds:6,charsPerSecond:80,maxSeconds:3,scrollContainer:null,onCaret:i,onPlaybackChange:({playing:e,blockKey:t})=>{o(e?null:performance.now()),l.current({playing:e,section:e&&t?irt(n,t):null})}})).dispose,[n]),(0,G.useEffect)(()=>n.registerUpdateListener(({tags:e,dirtyElements:t})=>{let n=u.current;!n||e.has(`agent-write`)||e.has(`collab`)||t.has(n)&&i(null)}),[n]),!r||!s?null:(0,Gi.createPortal)((0,K.jsx)(trt,{agent:e,caret:r,editor:n,stoppedAt:a}),s)}var ort=class e extends wr{__url;__props;__initialHeight;static getType(){return`dynamic`}static clone(t){return new e(t.__url,t.__props,t.__initialHeight,t.__key)}static importJSON(t){return new e(t.url,t.props,t.initialHeight).updateFromJSON(t)}constructor(e=``,t={},n=320,r){super(r),this.__url=e,this.__props=t,this.__initialHeight=n}exportJSON(){return{...super.exportJSON(),type:`dynamic`,version:1,url:this.__url,props:this.__props,initialHeight:this.__initialHeight}}createDOM(){return document.createElement(`div`)}updateDOM(){return!1}isInline(){return!1}decorate(){return(0,K.jsx)(u7e,{componentProps:this.__props,initialHeight:this.__initialHeight,url:this.__url})}},srt=(0,G.createContext)(null);function crt({nodeKey:e,intent:t}){let n=(0,G.useContext)(srt),r=n?.activity,a=n?.nextKey===e&&r===`working`;return(0,K.jsx)(`div`,{"data-next":a?`true`:void 0,"data-pending":``,title:i(`document.pending`),className:`x78zum5 x167g77z x1jp4ehj x87ps6o x1jvydc1 xa7kkou`,children:(0,K.jsxs)(`p`,{style:{margin:0},children:[(0,K.jsx)(`span`,{...{0:{className:`xddlp02`},1:{className:`x1t0mqxc xphioz4 x19hqrfe x1ta4xzc x1t23j8t x19co3pv xo64yqm x1ajuw05 x1aquc0h xius3t x1esw782 xa4qsjk`}}[!!a|0],children:t||i(`document.pending`)}),a?(0,K.jsxs)(`span`,{"aria-hidden":!0,"data-caret":``,className:`x1n2onr6 x1rg5ohu xfo62xy x1q3kd3q x1swdo50 x1pv9cyz`,children:[(0,K.jsx)(`span`,{className:`x10l6tqk x10a8y8t x1nj7uno x15az74h x1vrnivm x1aquc0h xr7ufhj x1htlvfj xa4qsjk`}),(0,K.jsx)(`span`,{className:`x10l6tqk x10w3d4m xu96u03 xjpr12u xfn1xvj x18zih8k xhbn7t3 x6l8oc8 x1k6wstc x1s688f x37zpob xuxw1ft`,children:n.agent})]}):null]})})}var lrt=class e extends wr{__intent;static getType(){return`pending`}static clone(t){return new e(t.__intent,t.__key)}static importJSON(t){return new e(t.intent).updateFromJSON(t)}constructor(e=``,t){super(t),this.__intent=e}exportJSON(){return{...super.exportJSON(),type:`pending`,version:1,intent:this.__intent}}createDOM(){return document.createElement(`div`)}updateDOM(){return!1}isInline(){return!1}decorate(){return(0,K.jsx)(crt,{intent:this.__intent,nodeKey:this.getKey()})}};function urt(e){if(_r(e)){let t=e.getTag();return t===`h1`||t===`h2`||t===`h3`?t:`other`}if(nr(e)){let t=e.getListType();return t===`bullet`?`bullet`:t===`number`?`number`:t===`check`?`check`:`other`}if(Er(e))return`quote`;let t=e.getType();return t===`paragraph`?`paragraph`:t===`code`?`code`:`other`}function drt(e,t){t===`bullet`?e.dispatchCommand(mt,void 0):t===`number`?e.dispatchCommand(I,void 0):t===`check`?e.dispatchCommand(dn,void 0):e.update(()=>{let n=kr();Jn(n)&&(t===`paragraph`||t===`other`?ee(n,()=>on()):t===`h1`||t===`h2`||t===`h3`?ee(n,()=>ae(t)):t===`quote`?ee(n,()=>xr()):t===`code`&&prt(e,n))})}function frt(e){return e._nodes.get(`code-block`)?.klass??null}function prt(e,t){let n=frt(e);if(!n)return;let r=[...new Set(t.getNodes().concat(t.anchor.getNode()).map(e=>e.getTopLevelElement()).filter(e=>e!==null))];if(r.length===0)return;let i=r.map(e=>e.getTextContent()).join(`
|
|
397
|
+
`);r[0].replace(new n(i,`text`));for(let e of r.slice(1))e.remove()}function mrt(e,t){e.update(()=>{let e=kr();Jn(e)&&_t(e,{"font-family":t||``})})}var G9=[{label:`默认`,value:``},{label:`宋体`,value:`"Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif`},{label:`黑体`,value:`"Noto Sans CJK SC", "Source Han Sans SC", SimHei, sans-serif`},{label:`楷体`,value:`KaiTi, STKaiti, serif`},{label:`Sans`,value:`system-ui, -apple-system, sans-serif`},{label:`Serif`,value:`Georgia, "Times New Roman", serif`},{label:`Mono`,value:`ui-monospace, "SF Mono", "Fira Code", monospace`}];function hrt(e){if(!e)return`默认`;let t=G9.find(t=>t.value===e);if(t)return t.label;for(let t of G9)if(t.value&&e.startsWith(t.value.split(`,`)[0]))return t.label;return`默认`}var grt=w9e,_rt=Object.fromEntries([...grt.map(e=>[e,g9(e).title]),[`other`,`Other`]]),vrt=`_1e1ersc0`,yrt=`_1e1ersc1`,K9=`_1e1ersc2`,brt=`_1e1ersc3`,xrt=`_1e1ersc4`,Srt=`_1e1ersc5`,Crt=`_1e1ersc6`,wrt=`_1e1ersc7`,Trt=`_1e1ersc8`,Ert=`_1e1ersc9`;function Drt({icon:e,title:t,shortcut:n,active:r,disabled:i,onClick:a,tooltipHandle:o}){let s=(0,K.jsx)(`button`,{"aria-label":t,"aria-pressed":r,className:`${K9}${r?` ${brt}`:``}`,disabled:i,type:`button`,onClick:a,onMouseDown:e=>e.preventDefault()});return o?(0,K.jsx)(tt,{handle:o,payload:{title:t,shortcut:n},render:s,children:e}):(0,K.jsxs)(Mn,{children:[(0,K.jsx)(tt,{render:s,children:e}),(0,K.jsx)(Fn,{shortcut:n,side:`bottom`,sideOffset:4,children:t})]})}function Ort({label:e,title:t,items:n,triggerWidth:r,tooltipHandle:i}){let a=(0,K.jsx)(On,{className:xrt,render:(0,K.jsx)(`button`,{type:`button`}),style:r?{width:r}:void 0}),o=(0,K.jsxs)(K.Fragment,{children:[e,(0,K.jsx)(`span`,{className:Srt,children:(0,K.jsx)(l,{size:14})})]}),s=n.find(e=>e.active)?.label??null,c=(0,K.jsx)(Rt,{sideOffset:4,children:(0,K.jsx)(M,{value:s,children:n.map(e=>(0,K.jsxs)(pn,{closeOnClick:!0,style:e.style,value:e.label,onClick:e.onSelect,children:[e.icon,e.label]},e.label))})});return i?(0,K.jsxs)(Zn,{children:[(0,K.jsx)(tt,{handle:i,payload:{title:t},render:a,children:o}),c]}):(0,K.jsxs)(Zn,{children:[(0,K.jsxs)(Mn,{children:[(0,K.jsx)(tt,{render:a,children:o}),(0,K.jsx)(Fn,{side:`bottom`,sideOffset:4,children:t})]}),c]})}function krt(e,t){let n=frt(e)!==null;return grt.filter(e=>e!==`code`||n||t===`code`).map(n=>{let r=g9(n);return{label:r.title,icon:(0,G.createElement)(r.icon,{size:16}),active:t===n,onSelect:()=>drt(e,n)}})}function Art(){return(0,K.jsx)(`div`,{className:Crt})}var jrt=13;function q9(e){return{key:e,node:(0,K.jsx)(Art,{},e),separator:!0,width:jrt}}function Mrt(e,t){return{key:e.key,width:28,menu:{items:[e]},node:(0,K.jsx)(Drt,{active:e.active,disabled:e.disabled,icon:e.icon,shortcut:e.shortcut,title:e.label,tooltipHandle:t,onClick:e.onSelect},e.key)}}function Nrt(e,t,n){return{key:e,width:t.width,menu:{label:t.title,items:t.items.map(e=>({...e,onSelect:e.onSelect}))},node:(0,K.jsx)(Ort,{items:t.items,label:t.label,title:t.title,tooltipHandle:n,triggerWidth:t.width},e)}}var J9=e=>(0,K.jsx)(e,{size:16,strokeWidth:2});function Prt(e,t){let n=t=>()=>e.dispatchCommand(ye,t),r=t=>()=>e.dispatchCommand(cn,t);return[[{key:`undo`,label:`Undo`,icon:J9(Xne),shortcut:`Mod+Z`,disabled:!t.canUndo,onSelect:()=>e.dispatchCommand(U,void 0)},{key:`redo`,label:`Redo`,icon:J9(Une),shortcut:`Mod+Shift+Z`,disabled:!t.canRedo,onSelect:()=>e.dispatchCommand(gt,void 0)}],[{key:`bold`,label:`Bold`,icon:J9(Kte),shortcut:`Mod+B`,active:t.isBold,onSelect:n(`bold`)},{key:`italic`,label:`Italic`,icon:J9(Jte),shortcut:`Mod+I`,active:t.isItalic,onSelect:n(`italic`)},{key:`underline`,label:`Underline`,icon:J9(Hte),shortcut:`Mod+U`,active:t.isUnderline,onSelect:n(`underline`)},{key:`strikethrough`,label:`Strikethrough`,icon:J9(Dt),active:t.isStrikethrough,onSelect:n(`strikethrough`)},{key:`code`,label:`Inline code`,icon:J9(Pr),active:t.isCode,onSelect:n(`code`)}],[{key:`highlight`,label:`Highlight`,icon:J9(jt),active:t.isHighlight,onSelect:n(`highlight`)},{key:`spoiler`,label:`Spoiler`,icon:J9(Bte),active:t.isSpoiler,onSelect:()=>e.update(GR)}],[{key:`bullet`,label:g9(`bullet`).title,icon:J9(g9(`bullet`).icon),active:t.blockType===`bullet`,onSelect:()=>e.dispatchCommand(mt,void 0)},{key:`number`,label:g9(`number`).title,icon:J9(g9(`number`).icon),active:t.blockType===`number`,onSelect:()=>e.dispatchCommand(I,void 0)},{key:`check`,label:g9(`check`).title,icon:J9(g9(`check`).icon),active:t.blockType===`check`,onSelect:()=>e.dispatchCommand(dn,void 0)}],[{key:`align-left`,label:`Align left`,icon:J9(Yte),active:t.elementFormat===`left`||t.elementFormat===``,onSelect:r(`left`)},{key:`align-center`,label:`Align center`,icon:J9(qte),active:t.elementFormat===`center`,onSelect:r(`center`)},{key:`align-right`,label:`Align right`,icon:J9(Gte),active:t.elementFormat===`right`,onSelect:r(`right`)},{key:`align-justify`,label:`Justify`,icon:J9(zte),active:t.elementFormat===`justify`,onSelect:r(`justify`)}]]}var Y9=`Insert`;function Frt({handle:e,items:t,onSelect:n}){let[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(0),l=(0,G.useId)(),u=(0,G.useMemo)(()=>Utt(a,t),[a,t]),d=u.length===0?null:Math.min(s,u.length-1);(0,G.useEffect)(()=>{d!==null&&u[d]?.ref?.current?.scrollIntoView?.({block:`nearest`})},[d,u]);let f=e=>{i(e),e||(o(``),c(0))},p=e=>{f(!1),n(e)};return(0,K.jsxs)(gn,{open:r,onOpenChange:f,children:[e?(0,K.jsx)(tt,{handle:e,payload:{title:Y9},render:(0,K.jsx)(en,{"aria-label":Y9,className:K9,render:(0,K.jsx)(`button`,{type:`button`})}),children:(0,K.jsx)(zr,{size:16})}):(0,K.jsx)(en,{"aria-label":Y9,className:K9,render:(0,K.jsx)(`button`,{type:`button`}),children:(0,K.jsx)(zr,{size:16})}),(0,K.jsxs)(yn,{flush:!0,align:`start`,side:`bottom`,size:`md`,children:[(0,K.jsxs)(`div`,{className:wrt,children:[(0,K.jsx)(lne,{"aria-hidden":!0,className:Trt,size:14}),(0,K.jsx)(ct,{"aria-controls":l,"aria-label":`Search blocks`,className:Ert,placeholder:`Search blocks`,type:`search`,value:a,"aria-activedescendant":d===null?void 0:Itt(l,d),onKeyDown:e=>{if(u.length===0)return;let t=d??0;e.key===`ArrowDown`?(e.preventDefault(),c((t+1)%u.length)):e.key===`ArrowUp`?(e.preventDefault(),c((t-1+u.length)%u.length)):e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),p(u[t]))},onChange:e=>{o(e.target.value),c(0)}})]}),(0,K.jsx)(Ltt,{id:l,items:u,query:a,selectedIndex:d,variant:`embedded`,onHighlight:c,onSelect:p})]})]})}function Irt(e,t,n){let r=0;for(let i=0;i<t;i++)r+=e[i].width+(i>0?n:0);return r}function Lrt(e,{available:t,gap:n,reserve:r}){if(t===null||Irt(e,e.length,n)<=t)return e.length;let i=0;for(;i<e.length&&Irt(e,i+1,n)+n+r<=t;)i++;for(;i>0&&e[i-1].separator;)i--;return i}function Rrt({children:e,handle:t,title:n}){return(0,K.jsx)(tt,{handle:t,payload:{title:n},render:(0,K.jsx)(On,{"aria-label":n,className:K9,render:(0,K.jsx)(`button`,{type:`button`})}),children:e})}function zrt({items:e}){return(0,K.jsx)(K.Fragment,{children:e.map(e=>e.active===void 0?(0,K.jsxs)(Ut,{disabled:e.disabled,shortcut:e.shortcut,onClick:e.onSelect,children:[e.icon,e.label]},e.label):(0,K.jsxs)(Ve,{closeOnClick:!0,checked:e.active,disabled:e.disabled,onClick:e.onSelect,children:[e.icon,e.label]},e.label))})}function Brt({entries:e,handle:t,icon:n}){let r=e.filter(e=>e.separator||e.menu);return(0,K.jsxs)(Zn,{modal:!1,children:[(0,K.jsx)(Rrt,{handle:t,title:`More tools`,children:n}),(0,K.jsx)(Rt,{align:`end`,positionMethod:`fixed`,sideOffset:4,children:r.map((e,t)=>{if(e.separator){let n=r[t-1];return n&&!n.separator&&t<r.length-1?(0,K.jsx)(ur,{},e.key):null}let n=e.menu;return n.label?(0,K.jsxs)(Eee,{children:[(0,K.jsx)(dee,{children:n.label}),(0,K.jsx)(zrt,{items:n.items})]},e.key):(0,K.jsx)(zrt,{items:n.items},e.key)})})]})}var Vrt={canUndo:!1,canRedo:!1,blockType:`paragraph`,fontFamily:``,elementFormat:`left`,isBold:!1,isItalic:!1,isUnderline:!1,isStrikethrough:!1,isCode:!1,isHighlight:!1,isSpoiler:!1};function X9(e,t){for(let n in t)if(t[n]!==e[n])return{...e,...t};return e}function Hrt(){let[e]=ht(),[t,n]=(0,G.useState)(Vrt),r=(0,G.useCallback)(()=>{let e=kr();if(!Jn(e))return;let t=e.anchor.getNode(),r=t.getKey()===`root`?t:pr(t,e=>{let t=e.getParent();return t!==null&&vr(t)})??t.getTopLevelElementOrThrow();if(nr(r)){let e=pr(t,e=>nr(e));e&&(r=e)}let i=urt(r),a=Or(e,`font-family`,``),o=rr(r)?r.getFormatType():`left`,s=e.hasFormat(`bold`),c=e.hasFormat(`italic`),l=e.hasFormat(`underline`),u=e.hasFormat(`strikethrough`),d=e.hasFormat(`code`),f=e.hasFormat(`highlight`),p=UR(e);n(e=>X9(e,{blockType:i,fontFamily:a,elementFormat:o,isBold:s,isItalic:c,isUnderline:l,isStrikethrough:u,isCode:d,isHighlight:f,isSpoiler:p}))},[]);return(0,G.useEffect)(()=>{let t=e.registerCommand(Ke,e=>(n(t=>X9(t,{canUndo:e})),!1),1),i=e.registerCommand(sn,e=>(n(t=>X9(t,{canRedo:e})),!1),1),a=e.registerUpdateListener(({editorState:e})=>{e.read(()=>{r()})});return()=>{t(),i(),a()}},[e,r]),t}var Urt=5;function Wrt(){let e=(0,G.useRef)(null),[t,n]=(0,G.useState)(null);return(0,G.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=new ResizeObserver(([e])=>n(e.contentRect.width));return r.observe(t),()=>r.disconnect()},[]),[e,t]}function Grt({className:e,maxVisibleInsertItems:t=Urt,insertItemOrder:n}){let[r]=ht(),i=Hrt(),[a]=(0,G.useState)(()=>Be()),[o,s]=Wrt(),c=(0,G.useMemo)(()=>{let e=_9(BR(r).filter(e=>e.placement?.includes(`toolbar`)&&e.group===`insert`));if(!n||n.length===0)return e;let t=n.map(e=>g9(e)?.title??e);return e.sort((e,n)=>{let r=t.indexOf(e.title),i=t.indexOf(n.title);return(r===-1?1/0:r)-(i===-1?1/0:i)})},[r,n]),l=(0,G.useMemo)(()=>Htt(r),[r]),u=(0,G.useMemo)(()=>{let e=[Nrt(`font`,{title:`Font family`,label:hrt(i.fontFamily),width:76,items:G9.map(e=>({label:e.label,active:i.fontFamily===e.value,style:e.value?{fontFamily:e.value}:void 0,onSelect:()=>mrt(r,e.value)}))},a),q9(`sep-font`),Nrt(`block`,{title:`Block type`,label:_rt[i.blockType]??`Text`,width:112,items:krt(r,i.blockType)},a)];for(let[t,n]of Prt(r,i).entries()){e.push(q9(`sep-${t}`));for(let t of n)e.push(Mrt(t,a))}e.push(q9(`sep-insert`));for(let n of c.slice(0,t))e.push(Mrt({key:`insert-${n.title}`,label:n.title,icon:n.icon,shortcut:n.shortcut,onSelect:()=>n.onSelect(r,``)},a));let n=c.slice(t).map(e=>({label:e.title,icon:e.icon,shortcut:e.shortcut,onSelect:()=>e.onSelect(r,``)}));return e.push({key:`insert-menu`,width:28,menu:n.length>0?{label:`Insert`,items:n}:void 0,node:(0,K.jsx)(Frt,{handle:a,items:l,onSelect:e=>e.onSelect(r,``)},`insert-menu`)}),e},[r,i,a,c,t,l]),d=Lrt(u,{available:s,gap:2,reserve:28}),f=u.slice(d);return(0,K.jsxs)(B,{delay:300,children:[(0,K.jsx)(Mn,{disableHoverablePopup:!0,handle:a,children:(e=>e.payload===void 0?null:(0,K.jsx)(Fn,{shortcut:e.payload.shortcut,side:`bottom`,sideOffset:4,children:e.payload.title}))}),(0,K.jsx)(`div`,{"aria-label":`Editor toolbar`,className:e?`${vrt} ${e}`:vrt,role:`toolbar`,children:(0,K.jsxs)(`div`,{className:yrt,ref:o,children:[u.slice(0,d).map(e=>e.node),f.length>0&&(0,K.jsx)(Brt,{entries:f,handle:a,icon:(0,K.jsx)(Nr,{size:16})})]})})]})}function Krt(){let e=(0,G.use)(Mj),t=wt();return e?.toolbarSlot&&t?(0,Gi.createPortal)((0,K.jsx)(Grt,{className:`ryugi-editor-toolbar`}),e.toolbarSlot):null}var qrt=100,Z9=1e3,Jrt=3e4,Q9=e=>Uint8Array.from(atob(e),e=>e.charCodeAt(0));function Yrt({transport:e,doc:t,human:n,onOffline:r,onState:i}){let[a]=ht(),o=(0,G.useRef)({commitMessage:`human`}),s=(0,G.useRef)(!1);return(0,G.useEffect)(()=>{let e=()=>{o.current.commitMessage=s.current&&n?.name?B5e(`human`,n):`human`};e();let t=a.getRootElement()?.ownerDocument??document,r=()=>{s.current=!0,e()},i=[`keydown`,`pointerdown`,`paste`,`drop`];for(let e of i)t.addEventListener(e,r,{capture:!0});return()=>{for(let e of i)t.removeEventListener(e,r,{capture:!0})}},[a,n]),(0,G.useEffect)(()=>{let n=t7e(a,t,o.current),s=t.oplogVersion(),c,l,u=Z9,d=!1,f=!1,p=!1,m=0,h=!1,g=e=>!h&&e===m,_=()=>{clearTimeout(c),l===void 0&&(l=setTimeout(()=>{l=void 0,x(!0)},u),u=Math.min(u*2,Jrt))},v=async()=>{if(c=void 0,h||f||d||l!==void 0)return;let n=m,i=t.export({mode:`update`,from:s}),a=t.oplogVersion();p=!1,d=!0;try{if(await e.update(i),!g(n))return;s=a,u=Z9,r(!1)}catch{if(!g(n))return;r(!0),_()}finally{g(n)&&(d=!1,p&&y())}},y=()=>{p=!0,h||f||d||l!==void 0||(clearTimeout(c),c=setTimeout(v,qrt))},b=t.subscribeLocalUpdates(y);async function x(a){if(h)return;let o=++m;clearTimeout(c),clearTimeout(l),l=void 0,d=!1,f=!0;try{let r=await e.state();if(!g(o))return;if(r.lineage!==t.getTree(`lexical`).roots()[0]?.id){location.reload();return}n.import(Q9(r.snapshot)),i?.(r),a&&(s=void 0,p=!0),f=!1,p&&y()}catch{if(!g(o))return;f=!1,r(!0),_()}}let{artifact:S}=e,C=e.channel.subscribe(e=>{e.type===`open`?(u=Z9,x(!0)):e.type===`doc-update`&&e.artifact===S&&n.import(Q9(e.bytes))});return x(!1),()=>{h=!0,clearTimeout(c),clearTimeout(l),C(),b(),n.dispose()}},[a,t,e,r,i]),null}var Xrt=[u9,d9,...iRe,ort,lrt,mz,z5e,...nnt],$9={[Lj]:HRe,[zj]:OK,[Bj]:wBe,[Hj]:C5e};function Zrt(){return wt()?(0,K.jsx)(Ret,{}):null}function Qrt(){return wt()?(0,K.jsx)(Wtt,{}):null}function $rt({transport:e,doc:t,theme:n,onAgentPlayback:r,onOffline:i,onState:a,onEditorReady:o,children:s,agent:c,human:l}){return(0,K.jsx)(Ge,{children:(0,K.jsx)(`div`,{style:{position:`relative`},children:(0,K.jsx)(dG,{children:(0,K.jsxs)(cR,{extraNodes:Xrt,header:(0,K.jsx)(Krt,{}),rendererConfig:$9,theme:n,variant:`article`,onEditorReady:o,children:[(0,K.jsx)(Yrt,{doc:t,human:l,transport:e,onOffline:i,onState:a}),(0,K.jsx)(C9e,{}),(0,K.jsx)(att,{}),(0,K.jsx)(iPe,{}),(0,K.jsx)(Qrt,{}),(0,K.jsx)(UF,{children:(0,K.jsx)(Zrt,{})}),(0,K.jsx)(art,{agent:c,onPlayback:r}),s]})})})})}export{cR as $,dk as $t,hU as A,Wi as An,ECe as At,LR as B,J as Bt,L8e as C,jS as Cn,Aj as Ct,QU as D,eC as Dn,bA as Dt,sW as E,Hye as En,aj as Et,nPe as F,nA as Ft,DR as G,fk as Gt,FR as H,vk as Ht,aPe as I,tA as It,pR as J,XSe as Jt,sNe as K,GSe as Kt,rPe as L,Qk as Lt,mPe as M,uA as Mt,mz as N,lA as Nt,RU as O,RS as On,jCe as Ot,uz as P,rA as Pt,mR as Q,Tk as Qt,RR as R,PSe as Rt,C5e as S,LS as Sn,Mj as St,dG as T,NS as Tn,NEe as Tt,pNe as U,Ik as Ut,IR as V,wk as Vt,ER as W,qSe as Wt,eNe as X,JSe as Xt,fR as Y,YSe as Yt,rNe as Z,Ak as Zt,z5e as _,JC as _n,Wj as _t,lrt as a,hT as an,gP as at,$7 as b,zw as bn,Nj as bt,C9e as c,CO as cn,WDe as ct,$5e as d,bw as dn,_N as dt,pk as en,FMe as et,t7e as f,HC as fn,Lj as ft,H5e as g,fw as gn,Hj as gt,V5e as h,Sw as hn,Bj as ht,Q9 as i,ck as in,hP as it,tU as j,pA as jt,BU as k,Wye as kn,_A as kt,u7e as l,dw as ln,mP as lt,B5e as m,ZC as mn,Yj as mt,Xrt as n,VO as nn,cF as nt,srt as o,vO as on,_P as ot,U5e as p,kC as pn,zj as pt,oNe as q,KSe as qt,$9 as r,UO as rn,WOe as rt,ort as s,pT as sn,vP as st,$rt as t,gk as tn,zF as tt,l7e as u,zC as un,uP as ut,P5e as v,vC as vn,Kj as vt,OK as w,PS as wn,jj as wt,Q7 as x,kS as xn,Pj as xt,j5e as y,pw as yn,Ij as yt,hNe as z,mk as zt};
|