@decocms/mesh 2.94.0 → 2.95.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/client/assets/{AlertCircle-j0KzIdIX.js → AlertCircle-CLqpetp3.js} +1 -1
- package/dist/client/assets/{AlertOctagon-BgwSXYuk.js → AlertOctagon-Bm3YQbCK.js} +1 -1
- package/dist/client/assets/{ArrowLeft-6dlMDZD7.js → ArrowLeft-CVJRTp5M.js} +1 -1
- package/dist/client/assets/{ArrowUp-C1DJqgoZ.js → ArrowUp-DOFmnz7E.js} +1 -1
- package/dist/client/assets/{Check-C5QtWx2D.js → Check-BMMJom8I.js} +1 -1
- package/dist/client/assets/{CheckCircle-EHieoMk6.js → CheckCircle-BDM3ZVN9.js} +1 -1
- package/dist/client/assets/{CheckDone01-SCPIkQCe.js → CheckDone01-C3s3Z88L.js} +1 -1
- package/dist/client/assets/{ChevronDown-BLfACJvJ.js → ChevronDown-BL7lzhv9.js} +1 -1
- package/dist/client/assets/{ChevronRight-DnWxHWge.js → ChevronRight-BPxK7G27.js} +1 -1
- package/dist/client/assets/{Clock-BYemExR5.js → Clock-CqiwuDel.js} +1 -1
- package/dist/client/assets/{Code01-DM216x2v.js → Code01-D9KWdh_W.js} +1 -1
- package/dist/client/assets/{Copy01-B0_tEmE3.js → Copy01-CE_3gibw.js} +1 -1
- package/dist/client/assets/{Dataflow03-C_xLhNUT.js → Dataflow03-f3Hpp69e.js} +1 -1
- package/dist/client/assets/{DotsHorizontal-DRvl8_yh.js → DotsHorizontal-C6NHDs3f.js} +1 -1
- package/dist/client/assets/{DotsVertical-G8ImM-fa.js → DotsVertical-DHC0rwqm.js} +1 -1
- package/dist/client/assets/{Download01-ZPaYMSna.js → Download01-CicBjzNH.js} +1 -1
- package/dist/client/assets/{Edit01-Lq8UOkVd.js → Edit01-Byy-AKbB.js} +1 -1
- package/dist/client/assets/{Eye-ByHE2GJe.js → Eye-yf1jJKzI.js} +1 -1
- package/dist/client/assets/{File02-dG5TfZkb.js → File02-DqDh6mSH.js} +1 -1
- package/dist/client/assets/{File06-Cww6dYwi.js → File06-CQanWHVf.js} +1 -1
- package/dist/client/assets/{FilterLines-CadzWYuC.js → FilterLines-BlanbAin.js} +1 -1
- package/dist/client/assets/{Grid01-D_3V4UIT.js → Grid01-DtHFsYOi.js} +1 -1
- package/dist/client/assets/{Home02-BtcHSeDX.js → Home02-CHnEkz3T.js} +1 -1
- package/dist/client/assets/{Image01-CrD1aqdp.js → Image01-B65JuZzZ.js} +1 -1
- package/dist/client/assets/{Inbox01-CU36sLHT.js → Inbox01-RWtif62W.js} +1 -1
- package/dist/client/assets/{InfoCircle-DJLnyVJD.js → InfoCircle-DI5p3V0K.js} +1 -1
- package/dist/client/assets/{Key01-sSzNClAs.js → Key01-3Y-x-x3n.js} +1 -1
- package/dist/client/assets/{LinkExternal01-YszpKCPw.js → LinkExternal01-9W1MDBkK.js} +1 -1
- package/dist/client/assets/{List-BzgZveoS.js → List-11sniaX1.js} +1 -1
- package/dist/client/assets/{Loading01-5hc3T6Gd.js → Loading01-DPtmmmOt.js} +1 -1
- package/dist/client/assets/{Lock01-C9-6HhjA.js → Lock01-BTGNl95c.js} +1 -1
- package/dist/client/assets/{Pin01-HGARLW8T.js → Pin01-CtjhgIzh.js} +1 -1
- package/dist/client/assets/{Play-CwkyX1Lx.js → Play-D5itgCOZ.js} +1 -1
- package/dist/client/assets/{Plus-Dn73MiSM.js → Plus-CN5tbLNe.js} +1 -1
- package/dist/client/assets/{RefreshCcw01-CtqWKAvv.js → RefreshCcw01-DRg8Mk2g.js} +1 -1
- package/dist/client/assets/{RefreshCw01-BqgcQ10A.js → RefreshCw01-2HpMOz8W.js} +1 -1
- package/dist/client/assets/{SearchMd-Czj8XGUX.js → SearchMd-Betk3rBo.js} +1 -1
- package/dist/client/assets/{Settings01-Dk3-DPld.js → Settings01-07fksFG_.js} +1 -1
- package/dist/client/assets/{Settings02-CaNoLwfL.js → Settings02-MDWLfV41.js} +1 -1
- package/dist/client/assets/{Share07-Bt_j0pH2.js → Share07-BfANp82q.js} +1 -1
- package/dist/client/assets/{Terminal-DlCWfDrb.js → Terminal-CuYYxDF4.js} +1 -1
- package/dist/client/assets/{Tool01-Bj8w--YE.js → Tool01-3DW2qy8C.js} +1 -1
- package/dist/client/assets/{Trash01-OGm6m6Nc.js → Trash01-CCqQwydP.js} +1 -1
- package/dist/client/assets/{Upload01-oWeoIlBw.js → Upload01-DwNbrcQ6.js} +1 -1
- package/dist/client/assets/{Users03-CSqNlpDP.js → Users03-CPBUdnD5.js} +1 -1
- package/dist/client/assets/{X-B7oOOayR.js → X-CjwxFw73.js} +1 -1
- package/dist/client/assets/{XClose-BoGXvnQN.js → XClose-CLb1rJTw.js} +1 -1
- package/dist/client/assets/{agent-connections-preview-D0tJithr.js → agent-connections-preview-BES18u3D.js} +1 -1
- package/dist/client/assets/{agent-detail-BAEmFvyw.js → agent-detail-CWbbQyJk.js} +1 -1
- package/dist/client/assets/{agents-8OgY3q49.js → agents-DtFnve8f.js} +1 -1
- package/dist/client/assets/{alert-dialog-DbDLG2bb.js → alert-dialog-BkwvDgw-.js} +1 -1
- package/dist/client/assets/{auth-catchall-CSK2qJvQ.js → auth-catchall-CKWQYOLN.js} +1 -1
- package/dist/client/assets/{avatar-Cmlnx_C9.js → avatar-ORBqoDjU.js} +1 -1
- package/dist/client/assets/{badge-Cx_QA8bK.js → badge-DXtLjyw_.js} +1 -1
- package/dist/client/assets/{binder-Uir9nDQX.js → binder-AxgsrJFT.js} +1 -1
- package/dist/client/assets/{breadcrumb-C3FvNwVA.js → breadcrumb-BcXcumeP.js} +1 -1
- package/dist/client/assets/{button-uGDTfTKe.js → button-C-7_0V7a.js} +1 -1
- package/dist/client/assets/{card-iB3dEEBq.js → card-CeZrPhCk.js} +1 -1
- package/dist/client/assets/{checkbox-DlxK4giK.js → checkbox-BwhVfqxs.js} +1 -1
- package/dist/client/assets/{circle-alert-BfwB-QbZ.js → circle-alert-B-eBjNwv.js} +1 -1
- package/dist/client/assets/{collection-detail-gKM8GfH1.js → collection-detail-L1PjfmwI.js} +1 -1
- package/dist/client/assets/{collection-search-DJnwTt8_.js → collection-search-BVSPmrDZ.js} +1 -1
- package/dist/client/assets/{collection-tab-CL4PGzJi.js → collection-tab-BC_by_4H.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-Dfa5iGyr.js → collection-table-wrapper-G1fUZVLa.js} +1 -1
- package/dist/client/assets/{collection-tabs-DQIxnf5_.js → collection-tabs-BXnzgmA7.js} +1 -1
- package/dist/client/assets/{command-CmjP7-sd.js → command-DoWuu0la.js} +1 -1
- package/dist/client/assets/{connect-Bhbh52h6.js → connect-D0u6psb3.js} +1 -1
- package/dist/client/assets/{connection-card-r6lGrO9Z.js → connection-card-DAIeWDBs.js} +1 -1
- package/dist/client/assets/{connection-detail-BwQb7zY3.js → connection-detail-CN3fbr8d.js} +1 -1
- package/dist/client/assets/{connections-Dzev22uX.js → connections-C4ChPQKJ.js} +1 -1
- package/dist/client/assets/{constants-CIhuTv50.js → constants-adA7cL3b.js} +1 -1
- package/dist/client/assets/constants-igCZQhi8.js +1 -0
- package/dist/client/assets/{create-organization-dialog-BCHRnFB_.js → create-organization-dialog-5hLc_Pao.js} +1 -1
- package/dist/client/assets/{create-project-dialog-BjcXzhvN.js → create-project-dialog-XKAYxmAD.js} +1 -1
- package/dist/client/assets/{dialog-Djkrqbm4.js → dialog-B5zyImrF.js} +1 -1
- package/dist/client/assets/{dropdown-menu-DAtjzZqM.js → dropdown-menu-CSqora6o.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-BX3kUg6t.js → dynamic-plugin-layout-KOkoYrI7.js} +1 -1
- package/dist/client/assets/{empty-state-B4Xs8BbY.js → empty-state-BMPJp53G.js} +1 -1
- package/dist/client/assets/{empty-state-D0gJavvT.js → empty-state-CMzSkRBu.js} +1 -1
- package/dist/client/assets/{env-vars-editor-DSV90YYy.js → env-vars-editor-RI6YtPxT.js} +1 -1
- package/dist/client/assets/{error-boundary-C-Q55BuJ.js → error-boundary-CSrQzXST.js} +1 -1
- package/dist/client/assets/{extract-connection-data-xNwT9mtT.js → extract-connection-data-BvlpRQhA.js} +1 -1
- package/dist/client/assets/{file-browser-K49CpZUF.js → file-browser-yzqA_YCR.js} +2 -2
- package/dist/client/assets/{form-Bk7wyfiz.js → form-DUYVVxjy.js} +1 -1
- package/dist/client/assets/{grid-view-BKVj8VSk.js → grid-view-B2DrnZxG.js} +1 -1
- package/dist/client/assets/{home-by7QPDwa.js → home-CIg0cGrw.js} +1 -1
- package/dist/client/assets/{index-FIsnCxJr.js → index-BJ4kHuEg.js} +1 -1
- package/dist/client/assets/index-BfOIHnQt.css +1 -0
- package/dist/client/assets/{index-B4DGyuZW.js → index-Btd8r7au.js} +1 -1
- package/dist/client/assets/{index-BHw6ELR5.js → index-CS81ntXN.js} +2 -2
- package/dist/client/assets/{index-Bddg6gZB.js → index-CbXJIwEX.js} +1 -1
- package/dist/client/assets/{index-CJhE8yKG.js → index-DELTwqul.js} +1 -1
- package/dist/client/assets/{index-DzHM-DwB.js → index-DUX6M9eU.js} +1 -1
- package/dist/client/assets/{index-CD4iOgE7.js → index-Dbbv7mgY.js} +1 -1
- package/dist/client/assets/{index-C7jtMR1a.js → index-eeT-CIju.js} +4 -4
- package/dist/client/assets/{index-Bur8hacl.js → index-wPpH52C9.js} +1 -1
- package/dist/client/assets/{infiniteQueryObserver-Zdbaiai7.js → infiniteQueryObserver-B-r-Rb8l.js} +1 -1
- package/dist/client/assets/{input-Bb_Is7TQ.js → input-BajunDqf.js} +1 -1
- package/dist/client/assets/{integration-icon-BDbW1I_P.js → integration-icon-f4ZY8s0G.js} +1 -1
- package/dist/client/assets/{label-jQ9Y0bqG.js → label-XO6QbBOg.js} +1 -1
- package/dist/client/assets/{layout-fK9zuUWE.js → layout-Ct3y7T4n.js} +1 -1
- package/dist/client/assets/{localstorage-keys-D2n2DXCy.js → localstorage-keys-73gHaqha.js} +1 -1
- package/dist/client/assets/{login-5ohFFTdJ.js → login-CanEmwZD.js} +1 -1
- package/dist/client/assets/{mcp-oauth-Bd_j2s3F.js → mcp-oauth-ClWEQLqD.js} +1 -1
- package/dist/client/assets/{mcp-server-card-BVKsh68h.js → mcp-server-card-3TY5I2j5.js} +1 -1
- package/dist/client/assets/{mcp-server-detail-DYhvID4P.js → mcp-server-detail-B4alU4_P.js} +2 -2
- package/dist/client/assets/{members-NKjnK3ym.js → members-CugOUarU.js} +1 -1
- package/dist/client/assets/{monitoring-CvMsjZ4V.js → monitoring-C2S3-Mw9.js} +1 -1
- package/dist/client/assets/{monitoring-dashboard-edit-BWTd-7SE.js → monitoring-dashboard-edit-YwRIzIec.js} +1 -1
- package/dist/client/assets/{monitoring-dashboard-view-BBMFO1Hp.js → monitoring-dashboard-view-NNuQaOcr.js} +1 -1
- package/dist/client/assets/{oauth-callback-Cfxs1XX-.js → oauth-callback-APvZzmso.js} +1 -1
- package/dist/client/assets/{page-BNCnlGEL.js → page-CSsXRrAb.js} +1 -1
- package/dist/client/assets/{page-C1pjP9Vh.js → page-CsCk8-VS.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-CBnqo-9I.js → plugin-empty-state-Bthc2x-z.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-C9VZo2uN.js → plugin-empty-state-CWG9gyFs.js} +1 -1
- package/dist/client/assets/{plugin-header-BkNoP5j1.js → plugin-header-Bxfpk_UG.js} +1 -1
- package/dist/client/assets/{plugin-header-_3DibYH3.js → plugin-header-CGqqZnqb.js} +1 -1
- package/dist/client/assets/{popover-DSuia8V-.js → popover-BYcEkar5.js} +1 -1
- package/dist/client/assets/{project-layout-CXN_QDXD.js → project-layout-t_7XabTP.js} +1 -1
- package/dist/client/assets/{project-settings-1nIiogcH.js → project-settings-DaPP16CG.js} +1 -1
- package/dist/client/assets/{projects-list-CxoFKZsZ.js → projects-list-h5ZsCKoX.js} +1 -1
- package/dist/client/assets/{registry-utils-n_q5XbrA.js → registry-utils-BybKuMhJ.js} +1 -1
- package/dist/client/assets/{resizable-PI_rMJEl.js → resizable-BylOVX4A.js} +1 -1
- package/dist/client/assets/{save-actions-DRuBsCtk.js → save-actions-CyLsYHNh.js} +1 -1
- package/dist/client/assets/{scroll-area-DyM_jTU0.js → scroll-area-J1BL0nzT.js} +1 -1
- package/dist/client/assets/{select-e1w6AMgG.js → select-MyJYpY4F.js} +1 -1
- package/dist/client/assets/{shell-layout-Chb28hAj.js → shell-layout-Cpqd9CA1.js} +3 -3
- package/dist/client/assets/{spinner-50t_5sK1.js → spinner-ym9xew5A.js} +1 -1
- package/dist/client/assets/{store-invite-CfusxH-f.js → store-invite-CpNKnfjF.js} +1 -1
- package/dist/client/assets/{switch-DfJWmJbl.js → switch-Ct3ZLSSt.js} +1 -1
- package/dist/client/assets/{table-CjEYCP4J.js → table-CejAgX-C.js} +1 -1
- package/dist/client/assets/{tasks-BFTBHo10.js → tasks-4mHd3v_t.js} +1 -1
- package/dist/client/assets/{textarea-cmxXPWPP.js → textarea-CPdfSrxZ.js} +1 -1
- package/dist/client/assets/{time-range-picker-CgJDmhVP.js → time-range-picker-DSJXNVH8.js} +1 -1
- package/dist/client/assets/{toggle-group-DPJARcjw.js → toggle-group-CMN0_5r8.js} +1 -1
- package/dist/client/assets/{tools-list-BtJ_PE1H.js → tools-list-TRBo24hy.js} +1 -1
- package/dist/client/assets/{tooltip-Cw3XU4NX.js → tooltip-BTwM0JSq.js} +1 -1
- package/dist/client/assets/{topbar-portal-BgbaZUfk.js → topbar-portal-CBAfTf2l.js} +1 -1
- package/dist/client/assets/{typewriter-title-DbWojJan.js → typewriter-title-C7tgOsRH.js} +1 -1
- package/dist/client/assets/{use-binding-BaVHLV4F.js → use-binding-ZsF7Sr1I.js} +1 -1
- package/dist/client/assets/{use-connection-BWwxbNp9.js → use-connection-5z_1hsJa.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-G8uYgZJA.js → use-create-virtual-mcp-C3p9LcqH.js} +1 -1
- package/dist/client/assets/{use-deco-chat-open-BXvSnqAG.js → use-deco-chat-open-C0exN0XE.js} +2 -2
- package/dist/client/assets/{use-install-from-registry-CnpW5eWM.js → use-install-from-registry-DKO6gQcy.js} +1 -1
- package/dist/client/assets/{use-list-state-D2v6Hz5J.js → use-list-state-DKsYJOUU.js} +1 -1
- package/dist/client/assets/{use-llm-DSbhxgKh.js → use-llm-C20fmI29.js} +1 -1
- package/dist/client/assets/{use-mcp-prompts-xMiR4WPu.js → use-mcp-prompts-E785MscJ.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-C8U12OPz.js → use-mcp-tools-DUFx-2Pv.js} +1 -1
- package/dist/client/assets/{use-mobile-XORtk01Y.js → use-mobile-CvSt_qzn.js} +1 -1
- package/dist/client/assets/{use-organization-settings-Ceh3kGcw.js → use-organization-settings-Dt1gkBue.js} +1 -1
- package/dist/client/assets/{use-project-BzX6yA4j.js → use-project-3Ug2XYz8.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-CljEtWT3.js → use-virtual-mcp-D2ugP2Xl.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-DlYGhHQH.js +1 -0
- package/dist/client/assets/{useMutation-6eAmA_sQ.js → useMutation-XZP6xxfW.js} +1 -1
- package/dist/client/assets/useQuery-CJZVZNDm.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-Ce64jVnz.js +1 -0
- package/dist/client/assets/{view-mode-toggle-Cynyu4xY.js → view-mode-toggle-DVFdVU1J.js} +1 -1
- package/dist/client/assets/{workflow-BvStAxqo.js → workflow-BivNC1fl.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/cli.js +2 -2
- package/dist/server/server.js +1 -1
- package/package.json +1 -1
- package/dist/client/assets/constants-C4qr_kek.js +0 -1
- package/dist/client/assets/index-Dtd3eJDL.css +0 -1
- package/dist/client/assets/useInfiniteQuery-BuyPuSfd.js +0 -1
- package/dist/client/assets/useQuery-Dke1OZg8.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-SwWrV--F.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as P,c as te,o as li,h as qx,k as jx,j as T,s as ys,c5 as Gx,c2 as Ww,b4 as mt,c6 as Yw,a4 as Vx,u as ui,t as Sn,aj as Kw,c7 as Xw,b2 as Wx,c8 as Zw,c9 as nn,ca as hl,cb as Qw,cc as ml,cd as Jw,ce as eR,cf as tR,cg as nR,n as rR,K as Jm,ch as iR,ci as aR,cj as sR,ck as oR,z as Yx,m as Kx,O as ss,bp as eg,c1 as Ts,g as lR}from"./index-BHw6ELR5.js";import{B as ze,c as ce}from"./button-uGDTfTKe.js";import{u as vr,S as Hb,c as uR,b as cR,d as dR,i as pR,m as Xx,M as fR,f as Zx,h as Qx,C as Jx,t as ev,e as hR,n as mR}from"./use-deco-chat-open-BXvSnqAG.js";import{b as ci,P as di,a as pi}from"./popover-DSuia8V-.js";import{S as xo}from"./spinner-50t_5sK1.js";import{b as xn,T as vn,a as Cn,c as vo}from"./tooltip-Cw3XU4NX.js";import{d as tv,u as tg,i as Kr,f as gR}from"./constants-CIhuTv50.js";import{u as bR,g as nv,l as $b,a as zb,r as ER}from"./use-mcp-prompts-xMiR4WPu.js";import{E as yR,i as TR}from"./error-boundary-C-Q55BuJ.js";import{c as SR,b as AR,e as kR,a as xR,D as vR}from"./dialog-Djkrqbm4.js";import{a as Kh,F as Co,b as _o,c as CR,d as No,f as Io}from"./form-Bk7wyfiz.js";import{I as rv}from"./input-Bb_Is7TQ.js";import{I as wo}from"./integration-icon-BDbW1I_P.js";import{i as _R}from"./ArrowUp-C1DJqgoZ.js";import{t as Xh}from"./ChevronDown-BLfACJvJ.js";import{i as NR}from"./Edit01-Lq8UOkVd.js";import{t as Xr}from"./Users03-CSqNlpDP.js";import{i as IR}from"./AlertCircle-j0KzIdIX.js";import{i as wR}from"./X-B7oOOayR.js";import{i as RR}from"./ArrowLeft-6dlMDZD7.js";import{B as OR}from"./badge-Cx_QA8bK.js";import{i as fi}from"./Check-C5QtWx2D.js";import{i as LR}from"./Code01-DM216x2v.js";import{b as DR}from"./use-virtual-mcp-CljEtWT3.js";import{i as iv}from"./SearchMd-Czj8XGUX.js";import{u as MR}from"./use-create-virtual-mcp-G8uYgZJA.js";import{c as PR}from"./usage-B8eRkRZY.js";import{i as av}from"./ChevronRight-DnWxHWge.js";import{a as Ro}from"./Copy01-B0_tEmE3.js";import{E as FR}from"./empty-state-D0gJavvT.js";import{g as BR,h as UR}from"./use-connection-BWwxbNp9.js";import{g as HR}from"./generate-id-Dyweu44Y.js";import{s as qb}from"./Clock-BYemExR5.js";import{s as $R}from"./Trash01-OGm6m6Nc.js";const sv=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M5 12h14m0 0-7-7m7 7-7 7"}));sv.displayName="ArrowRight";const ov=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M17.115 15.358c-.27.306-.554.608-.851.905-4.296 4.296-9.678 5.88-12.021 3.536-1.607-1.606-1.368-4.641.325-7.775M6.89 8.725c.281-.32.578-.636.888-.947C12.074 3.482 17.456 1.9 19.8 4.243c1.608 1.607 1.367 4.645-.33 7.781m-3.206-4.246c4.296 4.296 5.88 9.678 3.536 12.021-2.343 2.343-7.725.76-12.02-3.535C3.483 11.968 1.9 6.586 4.244 4.243c2.343-2.343 7.725-.76 12.02 3.535ZM13 12a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}));ov.displayName="Atom02";const lv=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"m21.152 10.9-9.015 9.015a5.25 5.25 0 0 1-7.425-7.425l9.016-9.015a3.5 3.5 0 1 1 4.95 4.95l-8.662 8.662a1.75 1.75 0 1 1-2.475-2.475l7.601-7.602"}));lv.displayName="Attachment01";const uv=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M15.938 15.938A7.001 7.001 0 0 0 15 2a7.001 7.001 0 0 0-6.938 6.062M16 15a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z"}));uv.displayName="Coins01";const ng=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"m18 10-4-4M2.5 21.5l3.384-.376c.414-.046.62-.069.814-.131a2 2 0 0 0 .485-.234c.17-.111.317-.259.61-.553L21 7a2.828 2.828 0 1 0-4-4L3.794 16.206c-.294.294-.442.442-.553.611a2 2 0 0 0-.234.485c-.062.193-.085.4-.131.814L2.5 21.5Z"}));ng.displayName="Edit02";const cv=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M15 16.5V19c0 .932 0 1.398-.152 1.765a2 2 0 0 1-1.083 1.083C13.398 22 12.932 22 12 22c-.932 0-1.398 0-1.765-.152a2 2 0 0 1-1.083-1.083C9 20.398 9 19.932 9 19v-2.5m6 0c2.649-1.157 4.5-3.925 4.5-7a7.5 7.5 0 0 0-15 0c0 3.075 1.851 5.843 4.5 7m6 0H9"}));cv.displayName="Lightbulb01";const rg=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M10.5 9.002a2.248 2.248 0 0 1 4.369.75C14.869 11.25 12.62 12 12.62 12m.028 3h.01m-.16 5a8.5 8.5 0 1 0-8.056-5.783c.108.32.162.481.172.604a.899.899 0 0 1-.028.326c-.03.12-.098.245-.232.494l-1.636 3.027c-.233.432-.35.648-.324.815a.5.5 0 0 0 .234.35c.144.087.388.062.876.011l5.121-.529c.155-.016.233-.024.303-.021.07.002.12.009.187.024.069.016.155.05.329.116A8.478 8.478 0 0 0 12.5 20Z"}));rg.displayName="MessageQuestionCircle";const dv=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M3 7.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h8.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C21 5.28 21 6.12 21 7.8v8.4c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 21 17.88 21 16.2 21H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 18.72 3 17.88 3 16.2V7.8Z"}));dv.displayName="Stop";const pv=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M16 8V5l3-3 1 2 2 1-3 3h-3Zm0 0-4 4m10 0c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2m5 10a5 5 0 1 1-5-5"}));pv.displayName="Target04";const fv=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"m15 9-6 6m0-6 6 6m7-3c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z"}));fv.displayName="XCircle";function zR(t){const e={};for(const n of t.arguments??[])e[n.name]=n.required?ys().min(1,"Required"):ys();return li(e)}function qR(t){const e={};for(const n of t.arguments??[])e[n.name]="";return e}function hv(t){const e=te.c(64),{prompt:n,setPrompt:r,onSubmit:i}=t,a=P.useId();let s;if(e[0]!==n){const H=n?zR(n):li({});s=qx(H),e[0]=n,e[1]=s}else s=e[1];const l=s;let u;e[2]!==n?(u=n?qR(n):{},e[2]=n,e[3]=u):u=e[3];let c;e[4]!==l||e[5]!==u?(c={resolver:l,defaultValues:u,mode:"onChange"},e[4]=l,e[5]=u,e[6]=c):c=e[6];const d=jx(c);let p;e[7]!==n?.arguments?(p=n?.arguments??[],e[7]=n?.arguments,e[8]=p):p=e[8];const f=p;let h;e[9]!==d||e[10]!==i||e[11]!==r?(h=async H=>{await i(H),r(null),d.reset()},e[9]=d,e[10]=i,e[11]=r,e[12]=h):h=e[12];const g=h;let b;e[13]!==d||e[14]!==r?(b=H=>{H||(d.reset(),r(null))},e[13]=d,e[14]=r,e[15]=b):b=e[15];const E=b;if(!n)return null;let y;e[16]!==n.name||e[17]!==n.title?(y=n.title||n.name.replace(/_/g," "),e[16]=n.name,e[17]=n.title,e[18]=y):y=e[18];let S;e[19]!==y?(S=T.jsx(SR,{children:y}),e[19]=y,e[20]=S):S=e[20];let k;e[21]!==n.description?(k=n.description&&T.jsx("p",{className:"text-sm text-muted-foreground",children:n.description}),e[21]=n.description,e[22]=k):k=e[22];let x;e[23]!==k||e[24]!==S?(x=T.jsxs(AR,{children:[S,k]}),e[23]=k,e[24]=S,e[25]=x):x=e[25];let A;e[26]!==d||e[27]!==g?(A=H=>{H.stopPropagation(),d.handleSubmit(g)(H)},e[26]=d,e[27]=g,e[28]=A):A=e[28];let v;if(e[29]!==f||e[30]!==d.control||e[31]!==d.formState.isSubmitting){let H;e[33]!==d.control||e[34]!==d.formState.isSubmitting?(H=J=>T.jsx(Co,{control:d.control,name:J.name,render:I=>{const{field:Z}=I;return T.jsxs(_o,{children:[T.jsxs(CR,{className:"text-xs",children:[J.name,J.required?null:T.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),T.jsx(No,{children:T.jsx(rv,{...Z,value:Z.value??"",required:J.required,placeholder:J.description??"",className:"h-9",disabled:d.formState.isSubmitting})}),T.jsx(Io,{})]})}},J.name),e[33]=d.control,e[34]=d.formState.isSubmitting,e[35]=H):H=e[35],v=f.map(H),e[29]=f,e[30]=d.control,e[31]=d.formState.isSubmitting,e[32]=v}else v=e[32];let w;e[36]!==E?(w=()=>E(!1),e[36]=E,e[37]=w):w=e[37];let N;e[38]!==d.formState.isSubmitting||e[39]!==w?(N=T.jsx(ze,{type:"button",variant:"ghost",onClick:w,disabled:d.formState.isSubmitting,children:"Cancel"}),e[38]=d.formState.isSubmitting,e[39]=w,e[40]=N):N=e[40];const _=!d.formState.isValid||d.formState.isSubmitting;let D;e[41]!==d.formState.isSubmitting?(D=d.formState.isSubmitting?T.jsxs("span",{className:"flex items-center gap-2",children:[T.jsx(xo,{size:"xs"}),"Loading..."]}):"Use prompt",e[41]=d.formState.isSubmitting,e[42]=D):D=e[42];let M;e[43]!==a||e[44]!==_||e[45]!==D?(M=T.jsx(ze,{type:"submit",form:a,disabled:_,children:D}),e[43]=a,e[44]=_,e[45]=D,e[46]=M):M=e[46];let q;e[47]!==N||e[48]!==M?(q=T.jsxs(kR,{children:[N,M]}),e[47]=N,e[48]=M,e[49]=q):q=e[49];let F;e[50]!==a||e[51]!==A||e[52]!==v||e[53]!==q?(F=T.jsxs("form",{id:a,className:"space-y-4 py-4",autoComplete:"off",onSubmit:A,children:[v,q]}),e[50]=a,e[51]=A,e[52]=v,e[53]=q,e[54]=F):F=e[54];let U;e[55]!==d||e[56]!==F?(U=T.jsx(Kh,{...d,children:F}),e[55]=d,e[56]=F,e[57]=U):U=e[57];let $;e[58]!==x||e[59]!==U?($=T.jsxs(xR,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[x,U]}),e[58]=x,e[59]=U,e[60]=$):$=e[60];let G;return e[61]!==E||e[62]!==$?(G=T.jsx(vR,{open:!0,onOpenChange:E,children:$}),e[61]=E,e[62]=$,e[63]=G):G=e[63],G}function Ze(t){this.content=t}Ze.prototype={constructor:Ze,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),a=r.content.slice();return i==-1?a.push(n||t,e):(a[i+1]=e,n&&(a[i]=n)),new Ze(a)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Ze(n)},addToStart:function(t,e){return new Ze([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Ze(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),a=r.find(t);return i.splice(a==-1?i.length:a,0,e,n),new Ze(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Ze.from(t),t.size?new Ze(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Ze.from(t),t.size?new Ze(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Ze.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Ze.from=function(t){if(t instanceof Ze)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Ze(e)};function mv(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),a=e.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let s=0;i.text[s]==a.text[s];s++)n++;return n}if(i.content.size||a.content.size){let s=mv(i.content,a.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function gv(t,e,n,r){for(let i=t.childCount,a=e.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let s=t.child(--i),o=e.child(--a),l=s.nodeSize;if(s==o){n-=l,r-=l;continue}if(!s.sameMarkup(o))return{a:n,b:r};if(s.isText&&s.text!=o.text){let u=0,c=Math.min(s.text.length,o.text.length);for(;u<c&&s.text[s.text.length-u-1]==o.text[o.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(s.content.size||o.content.size){let u=gv(s.content,o.content,n-1,r-1);if(u)return u}n-=l,r-=l}}class W{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,a){for(let s=0,o=0;o<n;s++){let l=this.content[s],u=o+l.nodeSize;if(u>e&&r(l,i+o,a||null,s)!==!1&&l.content.size){let c=o+1;l.nodesBetween(Math.max(0,e-c),Math.min(l.content.size,n-c),r,i+c)}o=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let a="",s=!0;return this.nodesBetween(e,n,(o,l)=>{let u=o.isText?o.text.slice(Math.max(e,l)-l,n-l):o.isLeaf?i?typeof i=="function"?i(o):i:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&r&&(s?s=!1:a+=r),a+=u},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<e.content.length;a++)i.push(e.content[a]);return new W(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let a=0,s=0;s<n;a++){let o=this.content[a],l=s+o.nodeSize;l>e&&((s<e||l>n)&&(o.isText?o=o.cut(Math.max(0,e-s),Math.min(o.text.length,n-s)):o=o.cut(Math.max(0,e-s-1),Math.min(o.content.size,n-s-1))),r.push(o),i+=o.nodeSize),s=l}return new W(r,i)}cutByIndex(e,n){return e==n?W.empty:e==0&&n==this.content.length?this:new W(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new W(i,a)}addToStart(e){return new W([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new W(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return mv(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return gv(this,e,n,r)}findIndex(e){if(e==0)return Ba(0,e);if(e==this.size)return Ba(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),a=r+i.nodeSize;if(a>=e)return a==e?Ba(n+1,a):Ba(n,r);r=a}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return W.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new W(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return W.empty;let n,r=0;for(let i=0;i<e.length;i++){let a=e[i];r+=a.nodeSize,i&&a.isText&&e[i-1].sameMarkup(a)?(n||(n=e.slice(0,i)),n[n.length-1]=a.withText(n[n.length-1].text+a.text)):n&&n.push(a)}return new W(n||e,r)}static from(e){if(!e)return W.empty;if(e instanceof W)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new W([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}W.empty=new W([],0);const gl={index:0,offset:0};function Ba(t,e){return gl.index=t,gl.offset=e,gl}function Ss(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!Ss(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Ss(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let ve=class Zh{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(this.eq(a))return e;if(this.type.excludes(a.type))n||(n=e.slice(0,i));else{if(a.type.excludes(this.type))return e;!r&&a.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(a)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Ss(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Zh.none;if(e instanceof Zh)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};ve.none=[];class As extends Error{}class ee{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Ev(this.content,e+this.openStart,n);return r&&new ee(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ee(bv(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ee.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ee(W.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)r++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)i++;return new ee(e,r,i)}}ee.empty=new ee(W.empty,0,0);function bv(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:s,offset:o}=t.findIndex(n);if(i==e||a.isText){if(o!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,a.copy(bv(a.content,e-i-1,n-i-1)))}function Ev(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),s=t.maybeChild(i);if(a==e||s.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=Ev(s.content,e-a-1,n,s);return o&&t.replaceChild(i,s.copy(o))}function jR(t,e,n){if(n.openStart>t.depth)throw new As("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new As("Inconsistent open depths");return yv(t,e,n,0)}function yv(t,e,n,r){let i=t.index(r),a=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let s=yv(t,e,n,r+1);return a.copy(a.content.replaceChild(i,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,o=s.content;return pr(s,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:s,end:o}=GR(n,t);return pr(a,Sv(t,s,o,e,r))}else return pr(a,ks(t,e,r))}function Tv(t,e){if(!e.type.compatibleContent(t.type))throw new As("Cannot join "+e.type.name+" onto "+t.type.name)}function Qh(t,e,n){let r=t.node(n);return Tv(r,e.node(n)),r}function dr(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function qi(t,e,n,r){let i=(e||t).node(n),a=0,s=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(dr(t.nodeAfter,r),a++));for(let o=a;o<s;o++)dr(i.child(o),r);e&&e.depth==n&&e.textOffset&&dr(e.nodeBefore,r)}function pr(t,e){return t.type.checkContent(e),t.copy(e)}function Sv(t,e,n,r,i){let a=t.depth>i&&Qh(t,e,i+1),s=r.depth>i&&Qh(n,r,i+1),o=[];return qi(null,t,i,o),a&&s&&e.index(i)==n.index(i)?(Tv(a,s),dr(pr(a,Sv(t,e,n,r,i+1)),o)):(a&&dr(pr(a,ks(t,e,i+1)),o),qi(e,n,i,o),s&&dr(pr(s,ks(n,r,i+1)),o)),qi(r,null,i,o),new W(o)}function ks(t,e,n){let r=[];if(qi(null,t,n,r),t.depth>n){let i=Qh(t,e,n+1);dr(pr(i,ks(t,e,n+1)),r)}return qi(e,null,n,r),new W(r)}function GR(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)i=e.node(a).copy(W.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class la{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let a=0;a<e;a++)i+=r.child(a).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return ve.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let o=r;r=i,i=o}let a=r.marks;for(var s=0;s<a.length;s++)a[s].type.spec.inclusive===!1&&(!i||!a[s].isInSet(i.marks))&&(a=a[s--].removeFromSet(a));return a}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var a=0;a<r.length;a++)r[a].type.spec.inclusive===!1&&(!i||!r[a].isInSet(i.marks))&&(r=r[a--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new xs(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,a=n;for(let s=e;;){let{index:o,offset:l}=s.content.findIndex(a),u=a-l;if(r.push(s,o,i+l),!u||(s=s.child(o),s.isText))break;a=u-1,i+=l+1}return new la(n,r,a)}static resolveCached(e,n){let r=jb.get(e);if(r)for(let a=0;a<r.elts.length;a++){let s=r.elts[a];if(s.pos==n)return s}else jb.set(e,r=new VR);let i=r.elts[r.i]=la.resolve(e,n);return r.i=(r.i+1)%WR,i}}class VR{constructor(){this.elts=[],this.i=0}}const WR=12,jb=new WeakMap;class xs{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const YR=Object.create(null);let Gn=class Jh{constructor(e,n,r,i=ve.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||W.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&Ss(this.attrs,n||e.defaultAttrs||YR)&&ve.sameSet(this.marks,r||ve.none)}copy(e=null){return e==this.content?this:new Jh(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Jh(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return ee.empty;let i=this.resolve(e),a=this.resolve(n),s=r?0:i.sharedDepth(n),o=i.start(s),u=i.node(s).content.cut(i.pos-o,a.pos-o);return new ee(u,i.depth-s,a.depth-s)}replace(e,n,r){return jR(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return la.resolveCached(this,e)}resolveNoCache(e){return la.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,a=>(r.isInSet(a.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Av(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=W.empty,i=0,a=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,a),o=s&&s.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let l=i;l<a;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let a=this.contentMatchAt(e).matchType(r),s=a&&a.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=ve.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!ve.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=W.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};Gn.prototype.text=void 0;class vs extends Gn{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Av(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new vs(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new vs(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Av(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Er{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new KR(e,n);if(r.next==null)return Er.empty;let i=kv(r);r.next&&r.err("Unexpected trailing text");let a=nO(tO(i));return rO(a,r),a}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let a=n;i&&a<r;a++)i=i.matchType(e.child(a).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function a(s,o){let l=s.matchFragment(e,r);if(l&&(!n||l.validEnd))return W.from(o.map(u=>u.createAndFill()));for(let u=0;u<s.next.length;u++){let{type:c,next:d}=s.next[u];if(!(c.isText||c.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let p=a(d,o.concat(c));if(p)return p}}return null}return a(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),a=i.match;if(a.matchType(e)){let s=[];for(let o=i;o.type;o=o.via)s.push(o.type);return s.reverse()}for(let s=0;s<a.next.length;s++){let{type:o,next:l}=a.next[s];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!i.type||l.validEnd)&&(r.push({match:o.contentMatch,type:o,via:i}),n[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let a=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)a+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return a}).join(`
|
|
1
|
+
import{r as P,c as te,o as li,h as qx,k as jx,j as T,s as ys,c5 as Gx,c2 as Ww,b4 as mt,c6 as Yw,a4 as Vx,u as ui,t as Sn,aj as Kw,c7 as Xw,b2 as Wx,c8 as Zw,c9 as nn,ca as hl,cb as Qw,cc as ml,cd as Jw,ce as eR,cf as tR,cg as nR,n as rR,K as Jm,ch as iR,ci as aR,cj as sR,ck as oR,z as Yx,m as Kx,O as ss,bp as eg,c1 as Ts,g as lR}from"./index-CS81ntXN.js";import{B as ze,c as ce}from"./button-C-7_0V7a.js";import{u as vr,S as Hb,c as uR,b as cR,d as dR,i as pR,m as Xx,M as fR,f as Zx,h as Qx,C as Jx,t as ev,e as hR,n as mR}from"./use-deco-chat-open-C0exN0XE.js";import{b as ci,P as di,a as pi}from"./popover-BYcEkar5.js";import{S as xo}from"./spinner-ym9xew5A.js";import{b as xn,T as vn,a as Cn,c as vo}from"./tooltip-BTwM0JSq.js";import{d as tv,u as tg,i as Kr,f as gR}from"./constants-adA7cL3b.js";import{u as bR,g as nv,l as $b,a as zb,r as ER}from"./use-mcp-prompts-E785MscJ.js";import{E as yR,i as TR}from"./error-boundary-CSrQzXST.js";import{c as SR,b as AR,e as kR,a as xR,D as vR}from"./dialog-B5zyImrF.js";import{a as Kh,F as Co,b as _o,c as CR,d as No,f as Io}from"./form-DUYVVxjy.js";import{I as rv}from"./input-BajunDqf.js";import{I as wo}from"./integration-icon-f4ZY8s0G.js";import{i as _R}from"./ArrowUp-DOFmnz7E.js";import{t as Xh}from"./ChevronDown-BL7lzhv9.js";import{i as NR}from"./Edit01-Byy-AKbB.js";import{t as Xr}from"./Users03-CPBUdnD5.js";import{i as IR}from"./AlertCircle-CLqpetp3.js";import{i as wR}from"./X-CjwxFw73.js";import{i as RR}from"./ArrowLeft-CVJRTp5M.js";import{B as OR}from"./badge-DXtLjyw_.js";import{i as fi}from"./Check-BMMJom8I.js";import{i as LR}from"./Code01-D9KWdh_W.js";import{b as DR}from"./use-virtual-mcp-D2ugP2Xl.js";import{i as iv}from"./SearchMd-Betk3rBo.js";import{u as MR}from"./use-create-virtual-mcp-C3p9LcqH.js";import{c as PR}from"./usage-B8eRkRZY.js";import{i as av}from"./ChevronRight-BPxK7G27.js";import{a as Ro}from"./Copy01-CE_3gibw.js";import{E as FR}from"./empty-state-CMzSkRBu.js";import{g as BR,h as UR}from"./use-connection-5z_1hsJa.js";import{g as HR}from"./generate-id-Dyweu44Y.js";import{s as qb}from"./Clock-CqiwuDel.js";import{s as $R}from"./Trash01-CCqQwydP.js";const sv=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M5 12h14m0 0-7-7m7 7-7 7"}));sv.displayName="ArrowRight";const ov=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M17.115 15.358c-.27.306-.554.608-.851.905-4.296 4.296-9.678 5.88-12.021 3.536-1.607-1.606-1.368-4.641.325-7.775M6.89 8.725c.281-.32.578-.636.888-.947C12.074 3.482 17.456 1.9 19.8 4.243c1.608 1.607 1.367 4.645-.33 7.781m-3.206-4.246c4.296 4.296 5.88 9.678 3.536 12.021-2.343 2.343-7.725.76-12.02-3.535C3.483 11.968 1.9 6.586 4.244 4.243c2.343-2.343 7.725-.76 12.02 3.535ZM13 12a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}));ov.displayName="Atom02";const lv=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"m21.152 10.9-9.015 9.015a5.25 5.25 0 0 1-7.425-7.425l9.016-9.015a3.5 3.5 0 1 1 4.95 4.95l-8.662 8.662a1.75 1.75 0 1 1-2.475-2.475l7.601-7.602"}));lv.displayName="Attachment01";const uv=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M15.938 15.938A7.001 7.001 0 0 0 15 2a7.001 7.001 0 0 0-6.938 6.062M16 15a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z"}));uv.displayName="Coins01";const ng=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"m18 10-4-4M2.5 21.5l3.384-.376c.414-.046.62-.069.814-.131a2 2 0 0 0 .485-.234c.17-.111.317-.259.61-.553L21 7a2.828 2.828 0 1 0-4-4L3.794 16.206c-.294.294-.442.442-.553.611a2 2 0 0 0-.234.485c-.062.193-.085.4-.131.814L2.5 21.5Z"}));ng.displayName="Edit02";const cv=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M15 16.5V19c0 .932 0 1.398-.152 1.765a2 2 0 0 1-1.083 1.083C13.398 22 12.932 22 12 22c-.932 0-1.398 0-1.765-.152a2 2 0 0 1-1.083-1.083C9 20.398 9 19.932 9 19v-2.5m6 0c2.649-1.157 4.5-3.925 4.5-7a7.5 7.5 0 0 0-15 0c0 3.075 1.851 5.843 4.5 7m6 0H9"}));cv.displayName="Lightbulb01";const rg=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M10.5 9.002a2.248 2.248 0 0 1 4.369.75C14.869 11.25 12.62 12 12.62 12m.028 3h.01m-.16 5a8.5 8.5 0 1 0-8.056-5.783c.108.32.162.481.172.604a.899.899 0 0 1-.028.326c-.03.12-.098.245-.232.494l-1.636 3.027c-.233.432-.35.648-.324.815a.5.5 0 0 0 .234.35c.144.087.388.062.876.011l5.121-.529c.155-.016.233-.024.303-.021.07.002.12.009.187.024.069.016.155.05.329.116A8.478 8.478 0 0 0 12.5 20Z"}));rg.displayName="MessageQuestionCircle";const dv=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M3 7.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h8.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C21 5.28 21 6.12 21 7.8v8.4c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 21 17.88 21 16.2 21H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 18.72 3 17.88 3 16.2V7.8Z"}));dv.displayName="Stop";const pv=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"M16 8V5l3-3 1 2 2 1-3 3h-3Zm0 0-4 4m10 0c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2m5 10a5 5 0 1 1-5-5"}));pv.displayName="Target04";const fv=({size:t=24,color:e="currentColor",...n})=>P.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},P.createElement("path",{d:"m15 9-6 6m0-6 6 6m7-3c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z"}));fv.displayName="XCircle";function zR(t){const e={};for(const n of t.arguments??[])e[n.name]=n.required?ys().min(1,"Required"):ys();return li(e)}function qR(t){const e={};for(const n of t.arguments??[])e[n.name]="";return e}function hv(t){const e=te.c(64),{prompt:n,setPrompt:r,onSubmit:i}=t,a=P.useId();let s;if(e[0]!==n){const H=n?zR(n):li({});s=qx(H),e[0]=n,e[1]=s}else s=e[1];const l=s;let u;e[2]!==n?(u=n?qR(n):{},e[2]=n,e[3]=u):u=e[3];let c;e[4]!==l||e[5]!==u?(c={resolver:l,defaultValues:u,mode:"onChange"},e[4]=l,e[5]=u,e[6]=c):c=e[6];const d=jx(c);let p;e[7]!==n?.arguments?(p=n?.arguments??[],e[7]=n?.arguments,e[8]=p):p=e[8];const f=p;let h;e[9]!==d||e[10]!==i||e[11]!==r?(h=async H=>{await i(H),r(null),d.reset()},e[9]=d,e[10]=i,e[11]=r,e[12]=h):h=e[12];const g=h;let b;e[13]!==d||e[14]!==r?(b=H=>{H||(d.reset(),r(null))},e[13]=d,e[14]=r,e[15]=b):b=e[15];const E=b;if(!n)return null;let y;e[16]!==n.name||e[17]!==n.title?(y=n.title||n.name.replace(/_/g," "),e[16]=n.name,e[17]=n.title,e[18]=y):y=e[18];let S;e[19]!==y?(S=T.jsx(SR,{children:y}),e[19]=y,e[20]=S):S=e[20];let k;e[21]!==n.description?(k=n.description&&T.jsx("p",{className:"text-sm text-muted-foreground",children:n.description}),e[21]=n.description,e[22]=k):k=e[22];let x;e[23]!==k||e[24]!==S?(x=T.jsxs(AR,{children:[S,k]}),e[23]=k,e[24]=S,e[25]=x):x=e[25];let A;e[26]!==d||e[27]!==g?(A=H=>{H.stopPropagation(),d.handleSubmit(g)(H)},e[26]=d,e[27]=g,e[28]=A):A=e[28];let v;if(e[29]!==f||e[30]!==d.control||e[31]!==d.formState.isSubmitting){let H;e[33]!==d.control||e[34]!==d.formState.isSubmitting?(H=J=>T.jsx(Co,{control:d.control,name:J.name,render:I=>{const{field:Z}=I;return T.jsxs(_o,{children:[T.jsxs(CR,{className:"text-xs",children:[J.name,J.required?null:T.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),T.jsx(No,{children:T.jsx(rv,{...Z,value:Z.value??"",required:J.required,placeholder:J.description??"",className:"h-9",disabled:d.formState.isSubmitting})}),T.jsx(Io,{})]})}},J.name),e[33]=d.control,e[34]=d.formState.isSubmitting,e[35]=H):H=e[35],v=f.map(H),e[29]=f,e[30]=d.control,e[31]=d.formState.isSubmitting,e[32]=v}else v=e[32];let w;e[36]!==E?(w=()=>E(!1),e[36]=E,e[37]=w):w=e[37];let N;e[38]!==d.formState.isSubmitting||e[39]!==w?(N=T.jsx(ze,{type:"button",variant:"ghost",onClick:w,disabled:d.formState.isSubmitting,children:"Cancel"}),e[38]=d.formState.isSubmitting,e[39]=w,e[40]=N):N=e[40];const _=!d.formState.isValid||d.formState.isSubmitting;let D;e[41]!==d.formState.isSubmitting?(D=d.formState.isSubmitting?T.jsxs("span",{className:"flex items-center gap-2",children:[T.jsx(xo,{size:"xs"}),"Loading..."]}):"Use prompt",e[41]=d.formState.isSubmitting,e[42]=D):D=e[42];let M;e[43]!==a||e[44]!==_||e[45]!==D?(M=T.jsx(ze,{type:"submit",form:a,disabled:_,children:D}),e[43]=a,e[44]=_,e[45]=D,e[46]=M):M=e[46];let q;e[47]!==N||e[48]!==M?(q=T.jsxs(kR,{children:[N,M]}),e[47]=N,e[48]=M,e[49]=q):q=e[49];let F;e[50]!==a||e[51]!==A||e[52]!==v||e[53]!==q?(F=T.jsxs("form",{id:a,className:"space-y-4 py-4",autoComplete:"off",onSubmit:A,children:[v,q]}),e[50]=a,e[51]=A,e[52]=v,e[53]=q,e[54]=F):F=e[54];let U;e[55]!==d||e[56]!==F?(U=T.jsx(Kh,{...d,children:F}),e[55]=d,e[56]=F,e[57]=U):U=e[57];let $;e[58]!==x||e[59]!==U?($=T.jsxs(xR,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[x,U]}),e[58]=x,e[59]=U,e[60]=$):$=e[60];let G;return e[61]!==E||e[62]!==$?(G=T.jsx(vR,{open:!0,onOpenChange:E,children:$}),e[61]=E,e[62]=$,e[63]=G):G=e[63],G}function Ze(t){this.content=t}Ze.prototype={constructor:Ze,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),a=r.content.slice();return i==-1?a.push(n||t,e):(a[i+1]=e,n&&(a[i]=n)),new Ze(a)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Ze(n)},addToStart:function(t,e){return new Ze([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Ze(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),a=r.find(t);return i.splice(a==-1?i.length:a,0,e,n),new Ze(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Ze.from(t),t.size?new Ze(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Ze.from(t),t.size?new Ze(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Ze.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Ze.from=function(t){if(t instanceof Ze)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Ze(e)};function mv(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),a=e.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let s=0;i.text[s]==a.text[s];s++)n++;return n}if(i.content.size||a.content.size){let s=mv(i.content,a.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function gv(t,e,n,r){for(let i=t.childCount,a=e.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let s=t.child(--i),o=e.child(--a),l=s.nodeSize;if(s==o){n-=l,r-=l;continue}if(!s.sameMarkup(o))return{a:n,b:r};if(s.isText&&s.text!=o.text){let u=0,c=Math.min(s.text.length,o.text.length);for(;u<c&&s.text[s.text.length-u-1]==o.text[o.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(s.content.size||o.content.size){let u=gv(s.content,o.content,n-1,r-1);if(u)return u}n-=l,r-=l}}class W{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,a){for(let s=0,o=0;o<n;s++){let l=this.content[s],u=o+l.nodeSize;if(u>e&&r(l,i+o,a||null,s)!==!1&&l.content.size){let c=o+1;l.nodesBetween(Math.max(0,e-c),Math.min(l.content.size,n-c),r,i+c)}o=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let a="",s=!0;return this.nodesBetween(e,n,(o,l)=>{let u=o.isText?o.text.slice(Math.max(e,l)-l,n-l):o.isLeaf?i?typeof i=="function"?i(o):i:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&r&&(s?s=!1:a+=r),a+=u},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<e.content.length;a++)i.push(e.content[a]);return new W(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let a=0,s=0;s<n;a++){let o=this.content[a],l=s+o.nodeSize;l>e&&((s<e||l>n)&&(o.isText?o=o.cut(Math.max(0,e-s),Math.min(o.text.length,n-s)):o=o.cut(Math.max(0,e-s-1),Math.min(o.content.size,n-s-1))),r.push(o),i+=o.nodeSize),s=l}return new W(r,i)}cutByIndex(e,n){return e==n?W.empty:e==0&&n==this.content.length?this:new W(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new W(i,a)}addToStart(e){return new W([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new W(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return mv(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return gv(this,e,n,r)}findIndex(e){if(e==0)return Ba(0,e);if(e==this.size)return Ba(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),a=r+i.nodeSize;if(a>=e)return a==e?Ba(n+1,a):Ba(n,r);r=a}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return W.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new W(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return W.empty;let n,r=0;for(let i=0;i<e.length;i++){let a=e[i];r+=a.nodeSize,i&&a.isText&&e[i-1].sameMarkup(a)?(n||(n=e.slice(0,i)),n[n.length-1]=a.withText(n[n.length-1].text+a.text)):n&&n.push(a)}return new W(n||e,r)}static from(e){if(!e)return W.empty;if(e instanceof W)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new W([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}W.empty=new W([],0);const gl={index:0,offset:0};function Ba(t,e){return gl.index=t,gl.offset=e,gl}function Ss(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!Ss(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Ss(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let ve=class Zh{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(this.eq(a))return e;if(this.type.excludes(a.type))n||(n=e.slice(0,i));else{if(a.type.excludes(this.type))return e;!r&&a.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(a)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Ss(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Zh.none;if(e instanceof Zh)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};ve.none=[];class As extends Error{}class ee{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Ev(this.content,e+this.openStart,n);return r&&new ee(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ee(bv(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ee.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ee(W.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)r++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)i++;return new ee(e,r,i)}}ee.empty=new ee(W.empty,0,0);function bv(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:s,offset:o}=t.findIndex(n);if(i==e||a.isText){if(o!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,a.copy(bv(a.content,e-i-1,n-i-1)))}function Ev(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),s=t.maybeChild(i);if(a==e||s.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=Ev(s.content,e-a-1,n,s);return o&&t.replaceChild(i,s.copy(o))}function jR(t,e,n){if(n.openStart>t.depth)throw new As("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new As("Inconsistent open depths");return yv(t,e,n,0)}function yv(t,e,n,r){let i=t.index(r),a=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let s=yv(t,e,n,r+1);return a.copy(a.content.replaceChild(i,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,o=s.content;return pr(s,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:s,end:o}=GR(n,t);return pr(a,Sv(t,s,o,e,r))}else return pr(a,ks(t,e,r))}function Tv(t,e){if(!e.type.compatibleContent(t.type))throw new As("Cannot join "+e.type.name+" onto "+t.type.name)}function Qh(t,e,n){let r=t.node(n);return Tv(r,e.node(n)),r}function dr(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function qi(t,e,n,r){let i=(e||t).node(n),a=0,s=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(dr(t.nodeAfter,r),a++));for(let o=a;o<s;o++)dr(i.child(o),r);e&&e.depth==n&&e.textOffset&&dr(e.nodeBefore,r)}function pr(t,e){return t.type.checkContent(e),t.copy(e)}function Sv(t,e,n,r,i){let a=t.depth>i&&Qh(t,e,i+1),s=r.depth>i&&Qh(n,r,i+1),o=[];return qi(null,t,i,o),a&&s&&e.index(i)==n.index(i)?(Tv(a,s),dr(pr(a,Sv(t,e,n,r,i+1)),o)):(a&&dr(pr(a,ks(t,e,i+1)),o),qi(e,n,i,o),s&&dr(pr(s,ks(n,r,i+1)),o)),qi(r,null,i,o),new W(o)}function ks(t,e,n){let r=[];if(qi(null,t,n,r),t.depth>n){let i=Qh(t,e,n+1);dr(pr(i,ks(t,e,n+1)),r)}return qi(e,null,n,r),new W(r)}function GR(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)i=e.node(a).copy(W.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class la{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let a=0;a<e;a++)i+=r.child(a).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return ve.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let o=r;r=i,i=o}let a=r.marks;for(var s=0;s<a.length;s++)a[s].type.spec.inclusive===!1&&(!i||!a[s].isInSet(i.marks))&&(a=a[s--].removeFromSet(a));return a}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var a=0;a<r.length;a++)r[a].type.spec.inclusive===!1&&(!i||!r[a].isInSet(i.marks))&&(r=r[a--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new xs(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,a=n;for(let s=e;;){let{index:o,offset:l}=s.content.findIndex(a),u=a-l;if(r.push(s,o,i+l),!u||(s=s.child(o),s.isText))break;a=u-1,i+=l+1}return new la(n,r,a)}static resolveCached(e,n){let r=jb.get(e);if(r)for(let a=0;a<r.elts.length;a++){let s=r.elts[a];if(s.pos==n)return s}else jb.set(e,r=new VR);let i=r.elts[r.i]=la.resolve(e,n);return r.i=(r.i+1)%WR,i}}class VR{constructor(){this.elts=[],this.i=0}}const WR=12,jb=new WeakMap;class xs{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const YR=Object.create(null);let Gn=class Jh{constructor(e,n,r,i=ve.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||W.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&Ss(this.attrs,n||e.defaultAttrs||YR)&&ve.sameSet(this.marks,r||ve.none)}copy(e=null){return e==this.content?this:new Jh(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Jh(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return ee.empty;let i=this.resolve(e),a=this.resolve(n),s=r?0:i.sharedDepth(n),o=i.start(s),u=i.node(s).content.cut(i.pos-o,a.pos-o);return new ee(u,i.depth-s,a.depth-s)}replace(e,n,r){return jR(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return la.resolveCached(this,e)}resolveNoCache(e){return la.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,a=>(r.isInSet(a.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Av(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=W.empty,i=0,a=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,a),o=s&&s.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let l=i;l<a;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let a=this.contentMatchAt(e).matchType(r),s=a&&a.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=ve.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!ve.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=W.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};Gn.prototype.text=void 0;class vs extends Gn{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Av(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new vs(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new vs(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Av(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Er{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new KR(e,n);if(r.next==null)return Er.empty;let i=kv(r);r.next&&r.err("Unexpected trailing text");let a=nO(tO(i));return rO(a,r),a}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let a=n;i&&a<r;a++)i=i.matchType(e.child(a).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function a(s,o){let l=s.matchFragment(e,r);if(l&&(!n||l.validEnd))return W.from(o.map(u=>u.createAndFill()));for(let u=0;u<s.next.length;u++){let{type:c,next:d}=s.next[u];if(!(c.isText||c.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let p=a(d,o.concat(c));if(p)return p}}return null}return a(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),a=i.match;if(a.matchType(e)){let s=[];for(let o=i;o.type;o=o.via)s.push(o.type);return s.reverse()}for(let s=0;s<a.next.length;s++){let{type:o,next:l}=a.next[s];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!i.type||l.validEnd)&&(r.push({match:o.contentMatch,type:o,via:i}),n[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let a=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)a+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return a}).join(`
|
|
2
2
|
`)}}Er.empty=new Er(!0);class KR{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function kv(t){let e=[];do e.push(XR(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function XR(t){let e=[];do e.push(ZR(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function ZR(t){let e=eO(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=QR(t,e);else break;return e}function Gb(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function QR(t,e){let n=Gb(t),r=n;return t.eat(",")&&(t.next!="}"?r=Gb(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function JR(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let a in n){let s=n[a];s.isInGroup(e)&&i.push(s)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function eO(t){if(t.eat("(")){let e=kv(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=JR(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function tO(t){let e=[[]];return i(a(t,0),n()),e;function n(){return e.push([])-1}function r(s,o,l){let u={term:l,to:o};return e[s].push(u),u}function i(s,o){s.forEach(l=>l.to=o)}function a(s,o){if(s.type=="choice")return s.exprs.reduce((l,u)=>l.concat(a(u,o)),[]);if(s.type=="seq")for(let l=0;;l++){let u=a(s.exprs[l],o);if(l==s.exprs.length-1)return u;i(u,o=n())}else if(s.type=="star"){let l=n();return r(o,l),i(a(s.expr,l),l),[r(l)]}else if(s.type=="plus"){let l=n();return i(a(s.expr,o),l),i(a(s.expr,l),l),[r(l)]}else{if(s.type=="opt")return[r(o)].concat(a(s.expr,o));if(s.type=="range"){let l=o;for(let u=0;u<s.min;u++){let c=n();i(a(s.expr,l),c),l=c}if(s.max==-1)i(a(s.expr,l),l);else for(let u=s.min;u<s.max;u++){let c=n();r(l,c),i(a(s.expr,l),c),l=c}return[r(l)]}else{if(s.type=="name")return[r(o,void 0,s.value)];throw new Error("Unknown expr type")}}}}function xv(t,e){return e-t}function Vb(t,e){let n=[];return r(e),n.sort(xv);function r(i){let a=t[i];if(a.length==1&&!a[0].term)return r(a[0].to);n.push(i);for(let s=0;s<a.length;s++){let{term:o,to:l}=a[s];!o&&n.indexOf(l)==-1&&r(l)}}}function nO(t){let e=Object.create(null);return n(Vb(t,0));function n(r){let i=[];r.forEach(s=>{t[s].forEach(({term:o,to:l})=>{if(!o)return;let u;for(let c=0;c<i.length;c++)i[c][0]==o&&(u=i[c][1]);Vb(t,l).forEach(c=>{u||i.push([o,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let a=e[r.join(",")]=new Er(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let o=i[s][1].sort(xv);a.next.push({type:i[s][0],next:e[o.join(",")]||n(o)})}return a}}function rO(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],a=!i.validEnd,s=[];for(let o=0;o<i.next.length;o++){let{type:l,next:u}=i.next[o];s.push(l.name),a&&!(l.isText||l.hasRequiredAttrs())&&(a=!1),r.indexOf(u)==-1&&r.push(u)}a&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function vv(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Cv(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let a=t[r];if(a.hasDefault)i=a.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function _v(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let a=t[i];a.validate&&a.validate(e[i])}}function Nv(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new aO(t,r,e[r]);return n}let Wb=class Iv{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Nv(e,r.attrs),this.defaultAttrs=vv(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Er.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Cv(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Gn(this,this.computeAttrs(e),W.from(n),ve.setFrom(r))}createChecked(e=null,n,r){return n=W.from(n),this.checkContent(n),new Gn(this,this.computeAttrs(e),n,ve.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=W.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let i=this.contentMatch.matchFragment(n),a=i&&i.fillBefore(W.empty,!0);return a?new Gn(this,e,n.append(a),ve.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){_v(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:ve.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,s)=>r[a]=new Iv(a,n,s));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let a in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function iO(t,e,n){let r=n.split("|");return i=>{let a=i===null?"null":typeof i;if(r.indexOf(a)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${a}`)}}class aO{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?iO(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Oo{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Nv(e,i.attrs),this.excluded=null;let a=vv(this.attrs);this.instance=a?new ve(this,a):null}create(e=null){return!e&&this.instance?this.instance:new ve(this,Cv(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,s)=>r[a]=new Oo(a,i++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){_v(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}let wv=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=Ze.from(e.nodes),n.marks=Ze.from(e.marks||{}),this.nodes=Wb.compile(this.spec.nodes,this),this.marks=Oo.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let a=this.nodes[i],s=a.spec.content||"",o=a.spec.marks;if(a.contentMatch=r[s]||(r[s]=Er.parse(s,this.nodes)),a.inlineContent=a.contentMatch.inlineContent,a.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!a.isInline||!a.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=a}a.markSet=o=="_"?null:o?Yb(this,o.split(" ")):o==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],s=a.spec.excludes;a.excluded=s==null?[a]:s==""?[]:Yb(this,s.split(" "))}this.nodeFromJSON=i=>Gn.fromJSON(this,i),this.markFromJSON=i=>ve.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Wb){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new vs(r,r.defaultAttrs,e,ve.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function Yb(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t.marks[i],s=a;if(a)n.push(a);else for(let o in t.marks){let l=t.marks[o];(i=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function sO(t){return t.tag!=null}function oO(t){return t.style!=null}class Vn{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(sO(i))this.tags.push(i);else if(oO(i)){let a=/[^=]*/.exec(i.style)[0];r.indexOf(a)<0&&r.push(a),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let a=e.nodes[i.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let r=new Xb(this,n,!1);return r.addAll(e,ve.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Xb(this,n,!0);return r.addAll(e,ve.none,n.from,n.to),ee.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let a=this.tags[i];if(cO(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let s=a.getAttrs(e);if(s===!1)continue;a.attrs=s||void 0}return a}}}matchStyle(e,n,r,i){for(let a=i?this.styles.indexOf(i)+1:0;a<this.styles.length;a++){let s=this.styles[a],o=s.style;if(!(o.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||o.length>e.length&&(o.charCodeAt(e.length)!=61||o.slice(e.length+1)!=n))){if(s.getAttrs){let l=s.getAttrs(n);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(e){let n=[];function r(i){let a=i.priority==null?50:i.priority,s=0;for(;s<n.length;s++){let o=n[s];if((o.priority==null?50:o.priority)<a)break}n.splice(s,0,i)}for(let i in e.marks){let a=e.marks[i].spec.parseDOM;a&&a.forEach(s=>{r(s=Zb(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let a=e.nodes[i].spec.parseDOM;a&&a.forEach(s=>{r(s=Zb(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Vn(e,Vn.schemaRules(e)))}}const Rv={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},lO={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ov={ol:!0,ul:!0},ua=1,em=2,ji=4;function Kb(t,e,n){return e!=null?(e?ua:0)|(e==="full"?em:0):t&&t.whitespace=="pre"?ua|em:n&~ji}class Ua{constructor(e,n,r,i,a,s){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=ve.none,this.match=a||(s&ji?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(W.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ua)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let a=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-i[0].length))}}let n=W.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(W.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Rv.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Xb{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,a,s=Kb(null,n.preserveWhitespace,0)|(r?ji:0);i?a=new Ua(i.type,i.attrs,ve.none,!0,n.topMatch||i.type.contentMatch,s):r?a=new Ua(null,null,ve.none,!0,null,s):a=new Ua(e.schema.topNodeType,null,ve.none,!0,null,s),this.nodes=[a],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,a=i.options&em?"full":this.localPreserveWS||(i.options&ua)>0,{schema:s}=this.parser;if(a==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(a)if(a==="full")r=r.replace(/\r\n?/g,`
|
|
3
3
|
`);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let o=r.split(/\r?\n|\r/);for(let l=0;l<o.length;l++)l&&this.insertNode(s.linebreakReplacement.create(),n,!0),o[l]&&this.insertNode(s.text(o[l]),n,!/\S/.test(o[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=i.content[i.content.length-1],l=e.previousSibling;(!o||l&&l.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,a=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),o;Ov.hasOwnProperty(s)&&this.parser.normalizeLists&&uO(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));e:if(l?l.ignore:lO.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let u,c=this.needsBlock;if(Rv.hasOwnProperty(s))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),u=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=l&&l.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),u&&this.sync(a),this.needsBlock=c}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,l,u,l.consuming===!1?o:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
4
4
|
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let a=this.parser.matchedStyles[i],s=r.getPropertyValue(a);if(s)for(let o=void 0;;){let l=this.parser.matchStyle(a,s,this,o);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(u=>!l.clearMark(u)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)o=l;else break}}return n}addElementByRule(e,n,r,i){let a,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(s,n.attrs||null,r,n.preserveWhitespace);l&&(a=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let o=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}a&&this.sync(o)&&this.open--}addAll(e,n,r,i){let a=r||0;for(let s=r?e.childNodes[r]:e.firstChild,o=i==null?null:e.childNodes[i];s!=o;s=s.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(s,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;for(let s=this.open,o=0;s>=0;s--){let l=this.nodes[s],u=l.findWrapping(e);if(u&&(!i||i.length>u.length+o)&&(i=u,a=l,!u.length))break;if(l.solid){if(r)break;o+=2}}if(!i)return null;this.sync(a);for(let s=0;s<i.length;s++)n=this.enterInner(i[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(n=this.enterInner(a,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let a=this.top;a.match&&(a.match=a.match.matchType(e.type));let s=ve.none;for(let o of i.concat(e.marks))(a.type?a.type.allowsMarkType(o.type):Qb(o.type,e.type))&&(s=o.addToSet(s));return a.content.push(e.mark(s)),!0}return!1}enter(e,n,r,i){let a=this.findPlace(e.create(n),r,!1);return a&&(a=this.enterInner(e,n,r,!0,i)),a}enterInner(e,n,r,i=!1,a){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let o=Kb(e,a,s.options);s.options&ji&&s.content.length==0&&(o|=ji);let l=ve.none;return r=r.filter(u=>(s.type?s.type.allowsMarkType(u.type):Qb(u.type,e))?(l=u.addToSet(l),!1):!0),this.nodes.push(new Ua(e,n,l,i,null,o)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=ua)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),a=-(r?r.depth+1:0)+(i?0:1),s=(o,l)=>{for(;o>=0;o--){let u=n[o];if(u==""){if(o==n.length-1||o==0)continue;for(;l>=a;l--)if(s(o-1,l))return!0;return!1}else{let c=l>0||l==0&&i?this.nodes[l].type:r&&l>=a?r.node(l-a).type:null;if(!c||c.name!=u&&!c.isInGroup(u))return!1;l--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function uO(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ov.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function cO(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Zb(t){let e={};for(let n in t)e[n]=t[n];return e}function Qb(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],s=o=>{a.push(o);for(let l=0;l<o.edgeCount;l++){let{type:u,next:c}=o.edge(l);if(u==e||a.indexOf(c)<0&&s(c))return!0}};if(s(i.contentMatch))return!0}}class Cr{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=bl(n).createDocumentFragment());let i=r,a=[];return e.forEach(s=>{if(a.length||s.marks.length){let o=0,l=0;for(;o<a.length&&l<s.marks.length;){let u=s.marks[l];if(!this.marks[u.type.name]){l++;continue}if(!u.eq(a[o][0])||u.type.spec.spanning===!1)break;o++,l++}for(;o<a.length;)i=a.pop()[1];for(;l<s.marks.length;){let u=s.marks[l++],c=this.serializeMark(u,s.isInline,n);c&&(a.push([u,i]),i.appendChild(c.dom),i=c.contentDOM||c.dom)}}i.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=ls(bl(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let a=this.serializeMark(e.marks[i],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(r),r=a.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&ls(bl(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return ls(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Cr(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Jb(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Jb(e.marks)}}function Jb(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function bl(t){return t.document||window.document}const eE=new WeakMap;function dO(t){let e=eE.get(t);return e===void 0&&eE.set(t,e=pO(t)),e}function pO(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function ls(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],a;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(a=dO(r))&&a.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let o,l=n?t.createElementNS(n,i):t.createElement(i),u=e[1],c=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){c=2;for(let d in u)if(u[d]!=null){let p=d.indexOf(" ");p>0?l.setAttributeNS(d.slice(0,p),d.slice(p+1),u[d]):d=="style"&&l.style?l.style.cssText=u[d]:l.setAttribute(d,u[d])}}for(let d=c;d<e.length;d++){let p=e[d];if(p===0){if(d<e.length-1||d>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:f,contentDOM:h}=ls(t,p,n,r);if(l.appendChild(f),h){if(o)throw new RangeError("Multiple content holes");o=h}}}return{dom:l,contentDOM:o}}const Lv=65535,Dv=Math.pow(2,16);function fO(t,e){return t+e*Dv}function tE(t){return t&Lv}function hO(t){return(t-(t&Lv))/Dv}const Mv=1,Pv=2,us=4,Fv=8;class tm{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Fv)>0}get deletedBefore(){return(this.delInfo&(Mv|us))>0}get deletedAfter(){return(this.delInfo&(Pv|us))>0}get deletedAcross(){return(this.delInfo&us)>0}}class Rt{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Rt.empty)return Rt.empty}recover(e){let n=0,r=tE(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+hO(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,a=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?i:0);if(l>e)break;let u=this.ranges[o+a],c=this.ranges[o+s],d=l+u;if(e<=d){let p=u?e==l?-1:e==d?1:n:n,f=l+i+(p<0?0:c);if(r)return f;let h=e==(n<0?l:d)?null:fO(o/3,e-l),g=e==l?Pv:e==d?Mv:us;return(n<0?e!=l:e!=d)&&(g|=Fv),new tm(f,g,h)}i+=c-u}return r?e+i:new tm(e+i,0,null)}touches(e,n){let r=0,i=tE(n),a=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?r:0);if(l>e)break;let u=this.ranges[o+a],c=l+u;if(e<=c&&o==i*3)return!0;r+=this.ranges[o+s]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,a=0;i<this.ranges.length;i+=3){let s=this.ranges[i],o=s-(this.inverted?a:0),l=s+(this.inverted?0:a),u=this.ranges[i+n],c=this.ranges[i+r];e(o,o+u,l,l+c),a+=c-u}}invert(){return new Rt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Rt.empty:new Rt(e<0?[0,-e,0]:[0,0,e])}}Rt.empty=new Rt([]);class ca{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new ca(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new ca;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let a=this.from;a<this.to;a++){let s=this._maps[a],o=s.mapResult(e,n);if(o.recover!=null){let l=this.getMirror(a);if(l!=null&&l>a&&l<this.to){a=l,e=this._maps[l].recover(o.recover);continue}}i|=o.delInfo,e=o.pos}return r?e:new tm(e,i,null)}}const El=Object.create(null);class ot{getMap(){return Rt.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=El[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in El)throw new RangeError("Duplicate use of step JSON ID "+e);return El[e]=n,n.prototype.jsonID=e,n}}class $e{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new $e(e,null)}static fail(e){return new $e(null,e)}static fromReplace(e,n,r,i){try{return $e.ok(e.replace(n,r,i))}catch(a){if(a instanceof As)return $e.fail(a.message);throw a}}}function ig(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(ig(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return W.fromArray(r)}class Hn extends ot{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),a=new ee(ig(n.content,(s,o)=>!s.isAtom||!o.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return $e.fromReplace(e,this.from,this.to,a)}invert(){return new Vt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Hn(n.pos,r.pos,this.mark)}merge(e){return e instanceof Hn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Hn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Hn(n.from,n.to,e.markFromJSON(n.mark))}}ot.jsonID("addMark",Hn);class Vt extends ot{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new ee(ig(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return $e.fromReplace(e,this.from,this.to,r)}invert(){return new Hn(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Vt(n.pos,r.pos,this.mark)}merge(e){return e instanceof Vt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Vt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Vt(n.from,n.to,e.markFromJSON(n.mark))}}ot.jsonID("removeMark",Vt);class $n extends ot{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return $e.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return $e.fromReplace(e,this.pos,this.pos+1,new ee(W.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new $n(this.pos,n.marks[i]);return new $n(this.pos,this.mark)}}return new yr(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new $n(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new $n(n.pos,e.markFromJSON(n.mark))}}ot.jsonID("addNodeMark",$n);class yr extends ot{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return $e.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return $e.fromReplace(e,this.pos,this.pos+1,new ee(W.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new $n(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new yr(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new yr(n.pos,e.markFromJSON(n.mark))}}ot.jsonID("removeNodeMark",yr);class We extends ot{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&nm(e,this.from,this.to)?$e.fail("Structure replace would overwrite content"):$e.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Rt([this.from,this.to-this.from,this.slice.size])}invert(e){return new We(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new We(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof We)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?ee.empty:new ee(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new We(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?ee.empty:new ee(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new We(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new We(n.from,n.to,ee.fromJSON(e,n.slice),!!n.structure)}}ot.jsonID("replace",We);class Ke extends ot{constructor(e,n,r,i,a,s,o=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=a,this.insert=s,this.structure=o}apply(e){if(this.structure&&(nm(e,this.from,this.gapFrom)||nm(e,this.gapTo,this.to)))return $e.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return $e.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?$e.fromReplace(e,this.from,this.to,r):$e.fail("Content does not fit in gap")}getMap(){return new Rt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Ke(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new Ke(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ke(n.from,n.to,n.gapFrom,n.gapTo,ee.fromJSON(e,n.slice),n.insert,!!n.structure)}}ot.jsonID("replaceAround",Ke);function nm(t,e,n){let r=t.resolve(e),i=n-e,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let s=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function mO(t,e,n,r){let i=[],a=[],s,o;t.doc.nodesBetween(e,n,(l,u,c)=>{if(!l.isInline)return;let d=l.marks;if(!r.isInSet(d)&&c.type.allowsMarkType(r.type)){let p=Math.max(u,e),f=Math.min(u+l.nodeSize,n),h=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(h)||(s&&s.to==p&&s.mark.eq(d[g])?s.to=f:i.push(s=new Vt(p,f,d[g])));o&&o.to==p?o.to=f:a.push(o=new Hn(p,f,r))}}),i.forEach(l=>t.step(l)),a.forEach(l=>t.step(l))}function gO(t,e,n,r){let i=[],a=0;t.doc.nodesBetween(e,n,(s,o)=>{if(!s.isInline)return;a++;let l=null;if(r instanceof Oo){let u=s.marks,c;for(;c=r.isInSet(u);)(l||(l=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(s.marks)&&(l=[r]):l=s.marks;if(l&&l.length){let u=Math.min(o+s.nodeSize,n);for(let c=0;c<l.length;c++){let d=l[c],p;for(let f=0;f<i.length;f++){let h=i[f];h.step==a-1&&d.eq(i[f].style)&&(p=h)}p?(p.to=u,p.step=a):i.push({style:d,from:Math.max(o,e),to:u,step:a})}}}),i.forEach(s=>t.step(new Vt(s.from,s.to,s.style)))}function ag(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),s=[],o=e+1;for(let l=0;l<a.childCount;l++){let u=a.child(l),c=o+u.nodeSize,d=r.matchType(u.type);if(!d)s.push(new We(o,c,ee.empty));else{r=d;for(let p=0;p<u.marks.length;p++)n.allowsMarkType(u.marks[p].type)||t.step(new Vt(o,c,u.marks[p]));if(i&&u.isText&&n.whitespace!="pre"){let p,f=/\r?\n|\r/g,h;for(;p=f.exec(u.text);)h||(h=new ee(W.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),s.push(new We(o+p.index,o+p.index+p[0].length,h))}}o=c}if(!r.validEnd){let l=r.fillBefore(W.empty,!0);t.replace(o,o,new ee(l,0,0))}for(let l=s.length-1;l>=0;l--)t.step(s[l])}function bO(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function hi(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,a=0;;--r){let s=t.$from.node(r),o=t.$from.index(r)+i,l=t.$to.indexAfter(r)-a;if(r<t.depth&&s.canReplace(o,l,n))return r;if(r==0||s.type.spec.isolating||!bO(s,o,l))break;o&&(i=1),l<s.childCount&&(a=1)}return null}function EO(t,e,n){let{$from:r,$to:i,depth:a}=e,s=r.before(a+1),o=i.after(a+1),l=s,u=o,c=W.empty,d=0;for(let h=a,g=!1;h>n;h--)g||r.index(h)>0?(g=!0,c=W.from(r.node(h).copy(c)),d++):l--;let p=W.empty,f=0;for(let h=a,g=!1;h>n;h--)g||i.after(h+1)<i.end(h)?(g=!0,p=W.from(i.node(h).copy(p)),f++):u++;t.step(new Ke(l,u,s,o,new ee(c.append(p),d,f),c.size-d,!0))}function sg(t,e,n=null,r=t){let i=yO(t,e),a=i&&TO(r,e);return a?i.map(nE).concat({type:e,attrs:n}).concat(a.map(nE)):null}function nE(t){return{type:t,attrs:null}}function yO(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.contentMatchAt(r).findWrapping(e);if(!a)return null;let s=a.length?a[0]:e;return n.canReplaceWith(r,i,s)?a:null}function TO(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.child(r),s=e.contentMatch.findWrapping(a.type);if(!s)return null;let l=(s.length?s[s.length-1]:e).contentMatch;for(let u=r;l&&u<i;u++)l=l.matchType(n.child(u).type);return!l||!l.validEnd?null:s}function SO(t,e,n){let r=W.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let o=n[s].type.contentMatch.matchFragment(r);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=W.from(n[s].type.create(n[s].attrs,r))}let i=e.start,a=e.end;t.step(new Ke(i,a,i,a,new ee(r,0,0),n.length,!0))}function AO(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let a=t.steps.length;t.doc.nodesBetween(e,n,(s,o)=>{let l=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,l)&&kO(t.doc,t.mapping.slice(a).map(o),r)){let u=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!h?u=!1:!f&&h&&(u=!0)}u===!1&&Uv(t,s,o,a),ag(t,t.mapping.slice(a).map(o,1),r,void 0,u===null);let c=t.mapping.slice(a),d=c.map(o,1),p=c.map(o+s.nodeSize,1);return t.step(new Ke(d,p,d+1,p-1,new ee(W.from(r.create(l,null,s.marks)),0,0),1,!0)),u===!0&&Bv(t,s,o,a),!1}})}function Bv(t,e,n,r){e.forEach((i,a)=>{if(i.isText){let s,o=/\r?\n|\r/g;for(;s=o.exec(i.text);){let l=t.mapping.slice(r).map(n+1+a+s.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function Uv(t,e,n,r){e.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+a);t.replaceWith(s,s+1,e.type.schema.text(`
|
|
@@ -97,7 +97,7 @@ ${b}
|
|
|
97
97
|
`);x.trim()&&(e.customNestedParser?y=e.customNestedParser(x):y=n.blockTokens(x))}const k=e.createToken(h,y);l.push(k)}if(l.length!==0)return{items:l,raw:u}}function Rg(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...s]=t.content,o=e.renderChildren([a]),l=[`${i}${o}`];return s&&s.length>0&&s.forEach(u=>{const c=e.renderChildren([u]);if(c){const d=c.split(`
|
|
98
98
|
`).map(p=>p?e.indent(p):"").join(`
|
|
99
99
|
`);l.push(d)}}),l.join(`
|
|
100
|
-
`)}function KM(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,s=t;i.descendants((o,l)=>{const u=a.mapping.map(l),c=a.mapping.map(l)+o.nodeSize;let d=null;if(o.marks.forEach(f=>{if(f!==s)return!1;d=f}),!d)return;let p=!1;if(Object.keys(n).forEach(f=>{n[f]!==d.attrs[f]&&(p=!0)}),p){const f=t.type.create({...t.attrs,...n});a.removeMark(u,c,t.type),a.addMark(u,c,f)}}),a.docChanged&&e.view.dispatch(a)}var Tt=class S_ extends Ng{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new S_(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},XM=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,i,a,s,o;const{view:l}=this.editor,u=t.target,c=u.nodeType===3?(e=u.parentElement)==null?void 0:e.closest("[data-drag-handle]"):u.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(u)||!c)return;let d=0,p=0;if(this.dom!==c){const y=this.dom.getBoundingClientRect(),S=c.getBoundingClientRect(),k=(i=t.offsetX)!=null?i:(r=t.nativeEvent)==null?void 0:r.offsetX,x=(s=t.offsetY)!=null?s:(a=t.nativeEvent)==null?void 0:a.offsetY;d=S.x-y.x+k,p=S.y-y.y+x}const f=this.dom.cloneNode(!0);try{const y=this.dom.getBoundingClientRect();f.style.width=`${Math.round(y.width)}px`,f.style.height=`${Math.round(y.height)}px`,f.style.boxSizing="border-box",f.style.pointerEvents="none"}catch{}let h=null;try{h=document.createElement("div"),h.style.position="absolute",h.style.top="-9999px",h.style.left="-9999px",h.style.pointerEvents="none",h.appendChild(f),document.body.appendChild(h),(o=t.dataTransfer)==null||o.setDragImage(f,d,p)}finally{h&&setTimeout(()=>{try{h?.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const b=le.create(l.state.doc,g),E=l.state.tr.setSelection(b);l.dispatch(E)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const i=t.type.startsWith("drag"),a=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!a&&!i)return!0;const{isEditable:o}=this.editor,{isDragging:l}=this,u=!!this.node.type.spec.draggable,c=le.isSelectable(this.node),d=t.type==="copy",p=t.type==="paste",f=t.type==="cut",h=t.type==="mousedown";if(!u&&c&&i&&t.target===this.dom&&t.preventDefault(),u&&i&&!l&&t.target===this.dom)return t.preventDefault(),!1;if(u&&o&&!l&&h){const g=n.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(l||a||d||p||f||h&&c)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(ma()||fm())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function Ar(t){return new wM({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=Ae(t.getAttributes,void 0,r,i);if(a===!1||a===null)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];let u=n.to;if(o){const c=l.search(/\S/),d=n.from+l.indexOf(o),p=d+o.length;if(_g(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(b=>b===t.type&&b!==h.mark.type)).filter(h=>h.to>d).length)return null;p<n.to&&s.delete(p,n.to),d>n.from&&s.delete(n.from+c,d),u=n.from+c+o.length,s.addMark(n.from+c,u,t.type.create(a||{})),s.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:ZM,getOwnPropertySymbols:QM}=Object,{hasOwnProperty:JM}=Object.prototype;function Ll(t,e){return function(r,i,a){return t(r,i,a)&&e(r,i,a)}}function Va(t){return function(n,r,i){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,i);const{cache:a}=i,s=a.get(n),o=a.get(r);if(s&&o)return s===r&&o===n;a.set(n,r),a.set(r,n);const l=t(n,r,i);return a.delete(n),a.delete(r),l}}function e3(t){return t?.[Symbol.toStringTag]}function ZE(t){return ZM(t).concat(QM(t))}const t3=Object.hasOwn||((t,e)=>JM.call(t,e));function Nr(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const n3="__v",r3="__o",i3="_owner",{getOwnPropertyDescriptor:QE,keys:JE}=Object;function a3(t,e){return t.byteLength===e.byteLength&&Ds(new Uint8Array(t),new Uint8Array(e))}function s3(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function o3(t,e){return t.byteLength===e.byteLength&&Ds(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function l3(t,e){return Nr(t.getTime(),e.getTime())}function u3(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function c3(t,e){return t===e}function e0(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),a=t.entries();let s,o,l=0;for(;(s=a.next())&&!s.done;){const u=e.entries();let c=!1,d=0;for(;(o=u.next())&&!o.done;){if(i[d]){d++;continue}const p=s.value,f=o.value;if(n.equals(p[0],f[0],l,d,t,e,n)&&n.equals(p[1],f[1],p[0],f[0],t,e,n)){c=i[d]=!0;break}d++}if(!c)return!1;l++}return!0}const d3=Nr;function p3(t,e,n){const r=JE(t);let i=r.length;if(JE(e).length!==i)return!1;for(;i-- >0;)if(!A_(t,e,n,r[i]))return!1;return!0}function Ci(t,e,n){const r=ZE(t);let i=r.length;if(ZE(e).length!==i)return!1;let a,s,o;for(;i-- >0;)if(a=r[i],!A_(t,e,n,a)||(s=QE(t,a),o=QE(e,a),(s||o)&&(!s||!o||s.configurable!==o.configurable||s.enumerable!==o.enumerable||s.writable!==o.writable)))return!1;return!0}function f3(t,e){return Nr(t.valueOf(),e.valueOf())}function h3(t,e){return t.source===e.source&&t.flags===e.flags}function t0(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),a=t.values();let s,o;for(;(s=a.next())&&!s.done;){const l=e.values();let u=!1,c=0;for(;(o=l.next())&&!o.done;){if(!i[c]&&n.equals(s.value,o.value,s.value,o.value,t,e,n)){u=i[c]=!0;break}c++}if(!u)return!1}return!0}function Ds(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function m3(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function A_(t,e,n,r){return(r===i3||r===r3||r===n3)&&(t.$$typeof||e.$$typeof)?!0:t3(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const g3="[object ArrayBuffer]",b3="[object Arguments]",E3="[object Boolean]",y3="[object DataView]",T3="[object Date]",S3="[object Error]",A3="[object Map]",k3="[object Number]",x3="[object Object]",v3="[object RegExp]",C3="[object Set]",_3="[object String]",N3={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},I3="[object URL]",w3=Object.prototype.toString;function R3({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:s,areNumbersEqual:o,areObjectsEqual:l,arePrimitiveWrappersEqual:u,areRegExpsEqual:c,areSetsEqual:d,areTypedArraysEqual:p,areUrlsEqual:f,unknownTagComparators:h}){return function(b,E,y){if(b===E)return!0;if(b==null||E==null)return!1;const S=typeof b;if(S!==typeof E)return!1;if(S!=="object")return S==="number"?o(b,E,y):S==="function"?a(b,E,y):!1;const k=b.constructor;if(k!==E.constructor)return!1;if(k===Object)return l(b,E,y);if(Array.isArray(b))return e(b,E,y);if(k===Date)return r(b,E,y);if(k===RegExp)return c(b,E,y);if(k===Map)return s(b,E,y);if(k===Set)return d(b,E,y);const x=w3.call(b);if(x===T3)return r(b,E,y);if(x===v3)return c(b,E,y);if(x===A3)return s(b,E,y);if(x===C3)return d(b,E,y);if(x===x3)return typeof b.then!="function"&&typeof E.then!="function"&&l(b,E,y);if(x===I3)return f(b,E,y);if(x===S3)return i(b,E,y);if(x===b3)return l(b,E,y);if(N3[x])return p(b,E,y);if(x===g3)return t(b,E,y);if(x===y3)return n(b,E,y);if(x===E3||x===k3||x===_3)return u(b,E,y);if(h){let A=h[x];if(!A){const v=e3(b);v&&(A=h[v])}if(A)return A(b,E,y)}return!1}}function O3({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:a3,areArraysEqual:n?Ci:s3,areDataViewsEqual:o3,areDatesEqual:l3,areErrorsEqual:u3,areFunctionsEqual:c3,areMapsEqual:n?Ll(e0,Ci):e0,areNumbersEqual:d3,areObjectsEqual:n?Ci:p3,arePrimitiveWrappersEqual:f3,areRegExpsEqual:h3,areSetsEqual:n?Ll(t0,Ci):t0,areTypedArraysEqual:n?Ll(Ds,Ci):Ds,areUrlsEqual:m3,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const i=Va(r.areArraysEqual),a=Va(r.areMapsEqual),s=Va(r.areObjectsEqual),o=Va(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:i,areMapsEqual:a,areObjectsEqual:s,areSetsEqual:o})}return r}function L3(t){return function(e,n,r,i,a,s,o){return t(e,n,o)}}function D3({circular:t,comparator:e,createState:n,equals:r,strict:i}){if(n)return function(o,l){const{cache:u=t?new WeakMap:void 0,meta:c}=n();return e(o,l,{cache:u,equals:r,meta:c,strict:i})};if(t)return function(o,l){return e(o,l,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};const a={cache:void 0,equals:r,meta:void 0,strict:i};return function(o,l){return e(o,l,a)}}const M3=er();er({strict:!0});er({circular:!0});er({circular:!0,strict:!0});er({createInternalComparator:()=>Nr});er({strict:!0,createInternalComparator:()=>Nr});er({circular:!0,createInternalComparator:()=>Nr});er({circular:!0,createInternalComparator:()=>Nr,strict:!0});function er(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:i=!1}=t,a=O3(t),s=R3(a),o=n?n(s):L3(s);return D3({circular:e,comparator:s,createState:r,equals:o,strict:i})}var P3=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},F3=({contentComponent:t})=>{const e=Gx.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return T.jsx(T.Fragment,{children:Object.values(e)})};function B3(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:Yw.createPortal(r.reactElement,r.element,n)},t.forEach(i=>i())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(i=>i())}}}var U3=class extends mt.Component{constructor(t){var e;super(t),this.editorContentRef=mt.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=B3(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return T.jsxs(T.Fragment,{children:[T.jsx("div",{ref:P3(e,this.editorContentRef),...n}),t?.contentComponent&&T.jsx(F3,{contentComponent:t.contentComponent})]})}},H3=P.forwardRef((t,e)=>{const n=mt.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return mt.createElement(U3,{key:n,innerRef:e,...t})}),Og=mt.memo(H3),$3=typeof window<"u"?P.useLayoutEffect:P.useEffect,z3=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function q3(t){var e;const[n]=P.useState(()=>new z3(t.editor)),r=Ww.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:M3);return $3(()=>n.watch(t.editor),[t.editor,n]),P.useDebugValue(r),r}var j3=!1,Em=typeof window>"u",G3=Em||!!(typeof window<"u"&&window.next),V3=class k_{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?Em||G3?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onBeforeCreate)==null?void 0:a.call(i,...r)},onBlur:(...r)=>{var i,a;return(a=(i=this.options.current).onBlur)==null?void 0:a.call(i,...r)},onCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onCreate)==null?void 0:a.call(i,...r)},onDestroy:(...r)=>{var i,a;return(a=(i=this.options.current).onDestroy)==null?void 0:a.call(i,...r)},onFocus:(...r)=>{var i,a;return(a=(i=this.options.current).onFocus)==null?void 0:a.call(i,...r)},onSelectionUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onSelectionUpdate)==null?void 0:a.call(i,...r)},onTransaction:(...r)=>{var i,a;return(a=(i=this.options.current).onTransaction)==null?void 0:a.call(i,...r)},onUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onUpdate)==null?void 0:a.call(i,...r)},onContentError:(...r)=>{var i,a;return(a=(i=this.options.current).onContentError)==null?void 0:a.call(i,...r)},onDrop:(...r)=>{var i,a;return(a=(i=this.options.current).onDrop)==null?void 0:a.call(i,...r)},onPaste:(...r)=>{var i,a;return(a=(i=this.options.current).onPaste)==null?void 0:a.call(i,...r)},onDelete:(...r)=>{var i,a;return(a=(i=this.options.current).onDelete)==null?void 0:a.call(i,...r)}};return new UM(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,a)=>{var s;return i===((s=n.extensions)==null?void 0:s[a])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?k_.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,i)=>r===e[i]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function x_(t={},e=[]){const n=P.useRef(t);n.current=t;const[r]=P.useState(()=>new V3(n)),i=Gx.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return P.useDebugValue(i),P.useEffect(r.onRender(e)),q3({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var Vo=P.createContext({editor:null});Vo.Consumer;var v_=()=>P.useContext(Vo),C_=P.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),W3=()=>P.useContext(C_),__=mt.forwardRef((t,e)=>{const{onDragStart:n}=W3(),r=t.as||"div";return T.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function n0(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function r0(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function Y3(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function K3(t){if(n0(t)||r0(t))return!0;if(Y3(t)){const e=t.type;if(e)return n0(e)||r0(e)}return!1}function X3(){try{if(P.version)return parseInt(P.version.split(".")[0],10)>=19}catch{}return!1}var Z3=class{constructor(t,{editor:e,props:n={},as:r="div",className:i=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isInitialized?Vx.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var t;if(this.destroyed)return;const e=this.component,n=this.props,r=this.editor,i=X3(),a=K3(e),s={...n};s.ref&&!(i||a)&&delete s.ref,!s.ref&&(i||a)&&(s.ref=o=>{this.ref=o}),this.reactElement=T.jsx(e,{...s}),(t=r?.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){this.destroyed||(this.props={...this.props,...t},this.render())}destroy(){var t;this.destroyed=!0;const e=this.editor;(t=e?.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};mt.createContext({markViewContentRef:()=>{}});var Q3=class extends XM{constructor(t,e,n){if(super(t,e,n),this.selectionRafId=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){const t=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(n,r,i){var a;return r==="storage"?(a=t.storage[e.name])!=null?a:{}:Reflect.get(n,r,i)}})}return this.cachedExtensionWithSyncedStorage}mount(){const t={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(l={})=>this.updateAttributes(l),deleteNode:()=>this.deleteNode(),ref:P.createRef()};if(!this.component.displayName){const l=u=>u.charAt(0).toUpperCase()+u.substring(1);this.component.displayName=l(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:l=>{l&&this.contentDOMElement&&l.firstChild!==this.contentDOMElement&&(l.hasAttribute("data-node-view-wrapper")&&l.removeAttribute("data-node-view-wrapper"),l.appendChild(this.contentDOMElement))}},i=this.component,a=P.memo(l=>T.jsx(C_.Provider,{value:r,children:P.createElement(i,l)}));a.displayName="ReactNodeView";let s=this.node.isInline?"span":"div";this.options.as&&(s=this.options.as);const{className:o=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Z3(a,{editor:this.editor,props:t,as:s,className:`node-${this.node.type.name} ${o}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:t,to:e}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(t<=n&&e>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(t,e,n){const r=i=>{this.renderer.updateProps(i),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const i=this.node,a=this.decorations,s=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.options.update({oldNode:i,oldDecorations:a,newNode:t,newDecorations:e,oldInnerDecorations:s,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}return t===this.node&&this.decorations===e&&this.innerDecorations===n||(this.node=t,this.decorations=e,this.innerDecorations=n,r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=ni(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function N_(t,e){return n=>n.editor.contentComponent?new Q3(t,n,e):{}}var Lg=P.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});Lg.displayName="TiptapContext";var J3=()=>P.useContext(Lg);function I_({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const i=P.useMemo(()=>({editor:r}),[r]),a=P.useMemo(()=>({editor:r}),[r]);return T.jsx(Vo.Provider,{value:a,children:T.jsx(Lg.Provider,{value:i,children:n})})}I_.displayName="Tiptap";function w_({...t}){const{editor:e}=J3();return T.jsx(Og,{editor:e,...t})}w_.displayName="Tiptap.Content";Object.assign(I_,{Content:w_});function R_(t,e,n){t.chain().focus().insertContentAt(e,[O_(n),{type:"text",text:" "}]).run()}function O_(t){return{type:"mention",attrs:t}}function eP(t){const e=te.c(7),{node:n,selected:r,view:i}=t,{name:a,char:s}=n.attrs,o=r&&i.editable,u=s==="@"?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400":"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300",c=o&&"outline-2 outline-blue-300 outline-offset-0";let d;e[0]!==u||e[1]!==c?(d=ce("px-1 py-1 rounded","inline-flex items-center gap-1","cursor-default select-none","text-xs font-light",u,c),e[0]=u,e[1]=c,e[2]=d):d=e[2];let p;return e[3]!==s||e[4]!==a||e[5]!==d?(p=T.jsxs(__,{className:d,children:[s,a]}),e[3]=s,e[4]=a,e[5]=d,e[6]=p):p=e[6],p}const L_=Tt.create({name:"mention",group:"inline",inline:!0,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id")||null,renderHTML:t=>t.id?{"data-id":t.id}:{}},name:{default:null,parseHTML:t=>t.getAttribute("data-name")||null,renderHTML:t=>t.name?{"data-name":t.name}:{}},char:{default:"/",parseHTML:t=>t.getAttribute("data-char")||"/",renderHTML:t=>t.char?{"data-char":t.char}:{}},metadata:{default:null,parseHTML:t=>{try{return JSON.parse(t.getAttribute("data-metadata")||"null")}catch{return null}},renderHTML:t=>t.metadata?{"data-metadata":JSON.stringify(t.metadata)}:{}}}},parseHTML(){return[{tag:'span[data-type="mention"]'}]},renderHTML({node:t,HTMLAttributes:e}){const n={"data-type":"mention"};return t.attrs.id&&(n["data-id"]=t.attrs.id),t.attrs.name&&(n["data-name"]=t.attrs.name),t.attrs.char&&(n["data-char"]=t.attrs.char),t.attrs.metadata&&(n["data-metadata"]=JSON.stringify(t.attrs.metadata)),["span",{...e,...n}]},renderText({node:t}){const e=t.attrs.char??"@",n=t.attrs.name??"";return`${e}${n}`},addNodeView(){return N_(eP)}});function tP(t){return!t||!t.content||t.content.length===0?!0:t.content.every(e=>e.type==="paragraph"?!e.content||e.content.length===0?!0:e.content.every(n=>n.type==="hardBreak"||n.type==="text"&&(!n.text||n.text.trim()==="")):!1)}function nP(t,e){return{type:"doc",content:[...t?.content??[],e].filter(Boolean)}}const i0=3;function rP(t){const e=te.c(23),{prompt:n,onSelect:r,isSelected:i,isDisabled:a,isLoading:s}=t,o=n.description??n.name;let l;e[0]!==r||e[1]!==n?(l=()=>r(n),e[0]=r,e[1]=n,e[2]=l):l=e[2];const u=a||s,c=i&&"bg-accent/50 text-foreground",d=s&&"bg-accent/50 text-foreground",p=(a||s)&&"cursor-not-allowed hover:bg-accent/50";let f;e[3]!==c||e[4]!==d||e[5]!==p?(f=ce("px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground border border-border rounded-full hover:bg-accent/50 transition-colors cursor-pointer flex items-center gap-1.5",c,d,p),e[3]=c,e[4]=d,e[5]=p,e[6]=f):f=e[6];const h=n.title??n.name;let g;if(e[7]!==h){let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=/_/g,e[9]=k):k=e[9],g=h.replace(k," "),e[7]=h,e[8]=g}else g=e[8];let b;e[10]!==s?(b=s&&T.jsx(xo,{size:"xs"}),e[10]=s,e[11]=b):b=e[11];let E;e[12]!==l||e[13]!==u||e[14]!==f||e[15]!==g||e[16]!==b?(E=T.jsx(vn,{asChild:!0,children:T.jsxs("button",{type:"button",onClick:l,disabled:u,className:f,children:[g,b]})}),e[12]=l,e[13]=u,e[14]=f,e[15]=g,e[16]=b,e[17]=E):E=e[17];let y;e[18]!==o?(y=T.jsx(Cn,{side:"bottom",className:"max-w-xs",children:T.jsx("p",{className:"text-xs",children:o})}),e[18]=o,e[19]=y):y=e[19];let S;return e[20]!==E||e[21]!==y?(S=T.jsxs(xn,{children:[E,y]}),e[20]=E,e[21]=y,e[22]=S):S=e[22],S}function iP(t){const e=te.c(23),{prompts:n,onSelect:r,loadingPrompt:i,className:a}=t;if(n.length===0)return null;let s,o,l,u,c;if(e[0]!==a||e[1]!==i||e[2]!==r||e[3]!==n){const f=n.slice(0,i0),h=n.slice(i0),g=h.length>0,b=!!i;s=vo,c=300,e[9]!==a?(o=ce("flex flex-wrap items-center justify-center gap-2",a),e[9]=a,e[10]=o):o=e[10];let E;e[11]!==b||e[12]!==i?.name||e[13]!==r?(E=y=>T.jsx(rP,{prompt:y,onSelect:r,isLoading:i?.name===y.name,isDisabled:b&&i?.name!==y.name},y.name),e[11]=b,e[12]=i?.name,e[13]=r,e[14]=E):E=e[14],l=f.map(E),u=g&&T.jsxs(ci,{children:[T.jsx(di,{asChild:!0,children:T.jsxs("button",{type:"button",disabled:b,className:ce("size-7 flex items-center justify-center text-xs text-muted-foreground hover:text-foreground border border-border rounded-full hover:bg-accent/50 transition-colors cursor-pointer",b&&"opacity-60 cursor-not-allowed"),children:["+",h.length]})}),T.jsx(pi,{side:"bottom",align:"center",className:"w-auto p-2",children:T.jsx("div",{className:"flex flex-col gap-1",children:h.map(y=>{const S=y.description??y.name,k=i?.name===y.name;return T.jsxs(xn,{children:[T.jsx(vn,{asChild:!0,children:T.jsxs("button",{type:"button",onClick:()=>r(y),disabled:b&&!k,className:ce("px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-accent/50 rounded-md transition-colors cursor-pointer text-left flex items-center gap-1.5",k&&"bg-accent/50 text-foreground",b&&!k&&"opacity-60 cursor-not-allowed"),children:[(y.title??y.name).replace(/_/g," "),k&&T.jsx(xo,{size:"xs"})]})}),T.jsx(Cn,{side:"right",className:"max-w-xs",children:T.jsx("p",{className:"text-xs",children:S})})]},y.name)})})})]}),e[0]=a,e[1]=i,e[2]=r,e[3]=n,e[4]=s,e[5]=o,e[6]=l,e[7]=u,e[8]=c}else s=e[4],o=e[5],l=e[6],u=e[7],c=e[8];let d;e[15]!==o||e[16]!==l||e[17]!==u?(d=T.jsxs("div",{className:o,children:[l,u]}),e[15]=o,e[16]=l,e[17]=u,e[18]=d):d=e[18];let p;return e[19]!==s||e[20]!==c||e[21]!==d?(p=T.jsx(s,{delayDuration:c,children:d}),e[19]=s,e[20]=c,e[21]=d,e[22]=p):p=e[22],p}function aP(){const t=te.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=T.jsxs(T.Fragment,{children:[T.jsx(Hb,{className:"h-6 w-20 rounded-full border border-border"}),T.jsx(Hb,{className:"h-6 w-24 rounded-full border border-border"})]}),t[0]=e):e=t[0],e}function sP(t,e){switch(e.type){case"SELECT_PROMPT":return!e.prompt.arguments||e.prompt.arguments.length===0?{stage:"loading",prompt:e.prompt}:{stage:"idle"};case"START_LOADING":return{stage:"loading",prompt:e.prompt,arguments:e.arguments};case"RESET":return{stage:"idle"};default:return t}}function oP(t){const e=te.c(28),{connectionId:n}=t,{tiptapDoc:r,sendMessage:i}=vr(),{org:a}=ui();let s;e[0]!==n||e[1]!==a.id?(s={connectionId:n,orgId:a.id},e[0]=n,e[1]=a.id,e[2]=s):s=e[2];const o=tg(s);let l;e[3]!==o?(l={client:o,staleTime:6e4},e[3]=o,e[4]=l):l=e[4];const{data:u}=bR(l);let c;e[5]!==u?.prompts?(c=u?.prompts??[],e[5]=u?.prompts,e[6]=c):c=e[6];const d=c;let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p={stage:"idle"},e[7]=p):p=e[7];const[f,h]=P.useReducer(sP,p),[g,b]=P.useState(null);let E;e[8]!==o||e[9]!==i||e[10]!==r?(E=async(M,q)=>{if(!o){Sn.error("MCP client not available"),h({type:"RESET"});return}try{const F=await nv(o,M.name,q);h({type:"RESET"});const U=nP(r,{type:"paragraph",content:[O_({id:M.name,name:M.name,metadata:F.messages,char:"/"})]});await i(U)}catch(F){console.error("[ice-breakers] Failed to fetch prompt:",F),Sn.error("Failed to load prompt. Please try again."),h({type:"RESET"})}},e[8]=o,e[9]=i,e[10]=r,e[11]=E):E=e[11];const y=E;let S;e[12]!==y?(S=async M=>{if(M.arguments&&M.arguments.length>0){h({type:"SELECT_PROMPT",prompt:M}),b(M);return}h({type:"START_LOADING",prompt:M}),await y(M)},e[12]=y,e[13]=S):S=e[13];const k=S;let x;e[14]!==g||e[15]!==y?(x=async M=>{g&&(h({type:"START_LOADING",prompt:g,arguments:M}),b(null),await y(g,M))},e[14]=g,e[15]=y,e[16]=x):x=e[16];const A=x;if(d.length===0)return null;const v=f.stage==="loading"?f.prompt:null;let w;e[17]!==k||e[18]!==d||e[19]!==v?(w=T.jsx(iP,{prompts:d,onSelect:k,loadingPrompt:v}),e[17]=k,e[18]=d,e[19]=v,e[20]=w):w=e[20];let N;e[21]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{b(null),h({type:"RESET"})},e[21]=N):N=e[21];let _;e[22]!==g||e[23]!==A?(_=T.jsx(hv,{prompt:g,setPrompt:N,onSubmit:A}),e[22]=g,e[23]=A,e[24]=_):_=e[24];let D;return e[25]!==_||e[26]!==w?(D=T.jsxs("div",{className:"relative w-full",children:[w,_]}),e[25]=_,e[26]=w,e[27]=D):D=e[27],D}function lP(t){const e=te.c(14),{className:n}=t,{selectedVirtualMcp:r}=vr(),{org:i}=ui();let a;e[0]!==i.id?(a=tv(i.id),e[0]=i.id,e[1]=a):a=e[1];const s=a.id,o=r?.id??s;let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l={minHeight:"32px"},e[2]=l):l=e[2];let u;e[3]!==n?(u=ce("flex flex-wrap items-center justify-center gap-2",n),e[3]=n,e[4]=u):u=e[4];const c=o??"default";let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=T.jsx(aP,{}),e[5]=d):d=e[5];let p;e[6]!==o?(p=T.jsx(oP,{connectionId:o}),e[6]=o,e[7]=p):p=e[7];let f;e[8]!==c||e[9]!==p?(f=T.jsx(yR,{fallback:null,children:T.jsx(P.Suspense,{fallback:d,children:p},c)}),e[8]=c,e[9]=p,e[10]=f):f=e[10];let h;return e[11]!==u||e[12]!==f?(h=T.jsx("div",{style:l,className:u,children:f}),e[11]=u,e[12]=f,e[13]=h):h=e[13],h}const a0=[{border:"border-purple-400",bg:"bg-purple-400",text:"text-white",bgLight:"bg-purple-400/10"},{border:"border-blue-400",bg:"bg-blue-400",text:"text-white",bgLight:"bg-blue-400/10"},{border:"border-indigo-400",bg:"bg-indigo-400",text:"text-white",bgLight:"bg-indigo-400/10"},{border:"border-violet-400",bg:"bg-violet-400",text:"text-white",bgLight:"bg-violet-400/10"},{border:"border-pink-400",bg:"bg-pink-400",text:"text-white",bgLight:"bg-pink-400/10"},{border:"border-fuchsia-400",bg:"bg-fuchsia-400",text:"text-white",bgLight:"bg-fuchsia-400/10"},{border:"border-emerald-400",bg:"bg-emerald-400",text:"text-white",bgLight:"bg-emerald-400/10"},{border:"border-teal-400",bg:"bg-teal-400",text:"text-white",bgLight:"bg-teal-400/10"},{border:"border-cyan-400",bg:"bg-cyan-400",text:"text-white",bgLight:"bg-cyan-400/10"},{border:"border-sky-400",bg:"bg-sky-400",text:"text-white",bgLight:"bg-sky-400/10"},{border:"border-orange-400",bg:"bg-orange-400",text:"text-white",bgLight:"bg-orange-400/10"},{border:"border-amber-400",bg:"bg-amber-400",text:"text-white",bgLight:"bg-amber-400/10"},{border:"border-rose-400",bg:"bg-rose-400",text:"text-white",bgLight:"bg-rose-400/10"},{border:"border-lime-400",bg:"bg-lime-400",text:"text-white",bgLight:"bg-lime-400/10"}];function uP(t){let e=0;for(let n=0;n<t.length;n++)e=t.charCodeAt(n)+((e<<5)-e);return Math.abs(e)}function D_(t){if(t==null)return null;const n=uP(t)%a0.length;return a0[n]}const s0=li({response:ys().min(1,"Response is required")}),cP=li({response:ys().min(1,"Please select or enter an option")}),dP=li({response:Kw(["yes","no"])});function pP(t){switch(t.type){case"text":return s0;case"choice":return cP;case"confirm":return dP;default:return s0}}function fP(t){const e={};for(const n of t)e[n.toolCallId]=pP(n.input);return li(e)}function hP(t){const e=te.c(6),{control:n,name:r,placeholder:i}=t;let a;e[0]!==i?(a=o=>{const{field:l}=o;return T.jsxs(_o,{children:[T.jsx(No,{children:T.jsx("div",{className:"px-2",children:T.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[T.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:T.jsx(ng,{size:16,className:"text-muted-foreground"})}),T.jsx("input",{...l,type:"text",placeholder:i||"Type your response...",autoFocus:!0,"aria-label":"Text response input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"})]})})}),T.jsx(Io,{})]})},e[0]=i,e[1]=a):a=e[1];let s;return e[2]!==n||e[3]!==r||e[4]!==a?(s=T.jsx(Co,{control:n,name:r,render:a}),e[2]=n,e[3]=r,e[4]=a,e[5]=s):s=e[5],s}function mP(t){const e=te.c(10),{control:n,name:r,options:i}=t,[a,s]=P.useState(!1),o=P.useRef(null),l=P.useRef(null);let u,c;if(e[0]!==i?(u=()=>{const f=h=>{const g=h.target.tagName;if(g==="INPUT"||g==="TEXTAREA")return;const b=Number.parseInt(h.key,10);b>=1&&b<=i.length&&l.current&&(h.preventDefault(),l.current.onChange(i[b-1]??""),s(!1))};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},c=[i],e[0]=i,e[1]=u,e[2]=c):(u=e[1],c=e[2]),P.useEffect(u,c),i.length===0)return null;let d;e[3]!==a||e[4]!==i?(d=f=>{const{field:h}=f;l.current=h;const g=a||!!h.value&&!i.includes(h.value);return T.jsxs(_o,{children:[T.jsx(No,{children:T.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[i.map((b,E)=>{const y=h.value===b;return T.jsxs("button",{type:"button",onClick:()=>{h.onChange(b??""),s(!1)},className:ce("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",y&&"bg-accent/50",!y&&"hover:bg-accent/30"),"aria-label":`Select ${b}`,children:[T.jsx("span",{className:ce("flex items-center justify-center size-6 rounded-md text-sm shrink-0",y?"bg-chart-1 text-white":"bg-muted text-foreground"),children:E+1}),T.jsx("span",{className:"text-sm text-foreground truncate",children:b})]},`${E}-${b}`)}),T.jsxs("div",{className:ce("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",g&&"bg-accent/50",!g&&"hover:bg-accent/30"),onClick:()=>{s(!0),i.includes(h.value)&&h.onChange(""),setTimeout(()=>o.current?.focus(),0)},children:[T.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:T.jsx(ng,{size:16,className:"text-muted-foreground"})}),g?T.jsx("input",{ref:o,type:"text",value:h.value,onChange:b=>h.onChange(b.target.value),placeholder:"Something else...",autoFocus:!0,"aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}):T.jsx("span",{className:"text-sm text-foreground/25",children:"Something else..."})]})]})}),T.jsx(Io,{})]})},e[3]=a,e[4]=i,e[5]=d):d=e[5];let p;return e[6]!==n||e[7]!==r||e[8]!==d?(p=T.jsx(Co,{control:n,name:r,render:d}),e[6]=n,e[7]=r,e[8]=d,e[9]=p):p=e[9],p}function gP(t){const e=te.c(7),{control:n,name:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=["yes","no"],e[0]=i):i=e[0];const a=i,s=P.useRef(null);let o,l;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{const d=p=>{const f=p.target.tagName;f==="INPUT"||f==="TEXTAREA"||(p.key==="1"&&s.current?(p.preventDefault(),s.current.onChange("yes")):p.key==="2"&&s.current&&(p.preventDefault(),s.current.onChange("no")))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},l=[],e[1]=o,e[2]=l):(o=e[1],l=e[2]),P.useEffect(o,l);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=d=>{const{field:p}=d;return s.current=p,T.jsxs(_o,{children:[T.jsx(No,{children:T.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:a.map(f=>{const h=p.value===f;return T.jsxs("button",{type:"button",onClick:()=>p.onChange(f),className:ce("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",h&&"bg-accent/50",!h&&"hover:bg-accent/30"),"aria-label":`Confirm ${f}`,children:[T.jsx("span",{className:ce("flex items-center justify-center size-6 rounded-md text-sm shrink-0",h?"bg-chart-1 text-white":"bg-muted text-foreground"),children:f==="yes"?1:2}),T.jsx("span",{className:"text-sm text-foreground capitalize",children:f})]},f)})})}),T.jsx(Io,{})]})},e[3]=u):u=e[3];let c;return e[4]!==n||e[5]!==r?(c=T.jsx(Co,{control:n,name:r,render:u}),e[4]=n,e[5]=r,e[6]=c):c=e[6],c}function o0(t){const e=te.c(13),{input:n,control:r,name:i}=t;switch(n.type){case"text":{let a;return e[0]!==r||e[1]!==n.default||e[2]!==i?(a=T.jsx(hP,{control:r,name:i,placeholder:n.default}),e[0]=r,e[1]=n.default,e[2]=i,e[3]=a):a=e[3],a}case"choice":{let a;e[4]!==n.options?(a=n.options?.filter(Boolean)??[],e[4]=n.options,e[5]=a):a=e[5];const s=a;let o;return e[6]!==r||e[7]!==i||e[8]!==s?(o=T.jsx(mP,{control:r,name:i,options:s}),e[6]=r,e[7]=i,e[8]=s,e[9]=o):o=e[9],o}case"confirm":{let a;return e[10]!==r||e[11]!==i?(a=T.jsx(gP,{control:r,name:i}),e[10]=r,e[11]=i,e[12]=a):a=e[12],a}default:return null}}function bP(t){const e=te.c(21),{current:n,total:r,onPrev:i,onNext:a}=t;if(r<=1)return null;const s=n===0,o=n===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let l;e[0]!==o?(l=ce("p-0.5 rounded transition-colors",o),e[0]=o,e[1]=l):l=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=T.jsx(RR,{size:14}),e[2]=u):u=e[2];let c;e[3]!==i||e[4]!==s||e[5]!==l?(c=T.jsx("button",{type:"button",onClick:i,disabled:s,className:l,"aria-label":"Previous question",children:u}),e[3]=i,e[4]=s,e[5]=l,e[6]=c):c=e[6];const d=n+1;let p;e[7]!==d||e[8]!==r?(p=T.jsxs("span",{className:"tabular-nums text-xs",children:[d," of ",r]}),e[7]=d,e[8]=r,e[9]=p):p=e[9];const f=n===r-1,h=n===r-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==h?(g=ce("p-0.5 rounded transition-colors",h),e[10]=h,e[11]=g):g=e[11];let b;e[12]===Symbol.for("react.memo_cache_sentinel")?(b=T.jsx(sv,{size:14}),e[12]=b):b=e[12];let E;e[13]!==a||e[14]!==g||e[15]!==f?(E=T.jsx("button",{type:"button",onClick:a,disabled:f,className:g,"aria-label":"Next question",children:b}),e[13]=a,e[14]=g,e[15]=f,e[16]=E):E=e[16];let y;return e[17]!==E||e[18]!==c||e[19]!==p?(y=T.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[c,p,E]}),e[17]=E,e[18]=c,e[19]=p,e[20]=y):y=e[20],y}function l0(t){const e=te.c(15),{title:n,children:r,footerLeft:i,footerRight:a}=t;let s;e[0]!==n?(s=T.jsx("div",{className:"flex items-center gap-2 p-4",children:T.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:n})}),e[0]=n,e[1]=s):s=e[1];let o;e[2]!==r?(o=T.jsx("div",{className:"overflow-clip pb-4",children:r}),e[2]=r,e[3]=o):o=e[3];let l;e[4]!==i?(l=T.jsx("div",{children:i}),e[4]=i,e[5]=l):l=e[5];let u;e[6]!==a?(u=T.jsx("div",{className:"flex items-center gap-2",children:a}),e[6]=a,e[7]=u):u=e[7];let c;e[8]!==l||e[9]!==u?(c=T.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:T.jsxs("div",{className:"flex items-center justify-between",children:[l,u]})}),e[8]=l,e[9]=u,e[10]=c):c=e[10];let d;return e[11]!==s||e[12]!==o||e[13]!==c?(d=T.jsxs("div",{className:"flex flex-col rounded-xl bg-background border border-border shadow-md w-[calc(100%-16px)] max-w-[584px] mx-auto mb-[-16px]",children:[s,o,c]}),e[11]=s,e[12]=o,e[13]=c,e[14]=d):d=e[14],d}function EP({parts:t,onSubmit:e}){const[n,r]=P.useState(t[0]?.toolCallId??""),i=fP(t.map(y=>({toolCallId:y.toolCallId,input:y.input}))),a=jx({resolver:qx(i),defaultValues:Object.fromEntries(t.map(y=>[y.toolCallId,{response:""}]))}),s=a.watch(),o=t.findIndex(y=>y.toolCallId===n),l=!!s[n]?.response,u=t.every(y=>!!s[y.toolCallId]?.response),c=y=>{for(const S of t){const k=y[S.toolCallId]?.response;k&&e(S,k)}},d=y=>t.find(S=>!y[S.toolCallId]?.response&&S.toolCallId!==n)??null,p=()=>{const y=a.getValues();if(t.every(k=>!!y[k.toolCallId]?.response))a.handleSubmit(c)();else{const k=d(y);k&&r(k.toolCallId)}},f=()=>{a.setValue(`${n}.response`,"user has skip this question"),p()},h=()=>{if(o>0){const y=t[o-1];y&&r(y.toolCallId)}},g=()=>{if(o<t.length-1){const y=t[o+1];y&&r(y.toolCallId)}},b=T.jsxs(T.Fragment,{children:[T.jsx(ze,{type:"button",variant:"outline",size:"sm",onClick:f,className:"h-7",children:"Skip"}),T.jsx(ze,{type:"button",size:"sm",disabled:!l,onClick:p,className:ce("h-7",l?"":"opacity-50"),children:u?"Submit":"Next"})]}),E=T.jsx(bP,{current:o,total:t.length,onPrev:h,onNext:g});if(t.length===1){const y=t[0];return y?.input?T.jsx(Kh,{...a,children:T.jsx("form",{onSubmit:a.handleSubmit(c),autoComplete:"off",children:T.jsx(l0,{title:y.input?.prompt??"Question",footerRight:b,children:T.jsx(o0,{input:y.input,control:a.control,name:`${y.toolCallId}.response`})})})}):null}return T.jsx(Kh,{...a,children:T.jsx("form",{onSubmit:a.handleSubmit(c),autoComplete:"off",children:T.jsx(uR,{value:n,onValueChange:r,children:t.map(y=>T.jsx(cR,{value:y.toolCallId,className:"mt-0",children:T.jsx(l0,{title:y.input?.prompt??"Question",footerLeft:E,footerRight:b,children:T.jsx(o0,{input:y.input,control:a.control,name:`${y.toolCallId}.response`})})},y.toolCallId))})})})}function yP(){const t=te.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=T.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[T.jsx(rg,{className:"size-5 text-muted-foreground shimmer"}),T.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function M_(t){const e=te.c(6),{userAskParts:n,isStreaming:r,onSubmit:i}=t;let a;e[0]!==n?(a=n.filter(TP),e[0]=n,e[1]=a):a=e[1];const s=a;if(r){let l;return e[2]===Symbol.for("react.memo_cache_sentinel")?(l=T.jsx(yP,{}),e[2]=l):l=e[2],l}if(s.length===0)return null;let o;return e[3]!==i||e[4]!==s?(o=T.jsx(EP,{parts:s,onSubmit:i}),e[3]=i,e[4]=s,e[5]=o):o=e[5],o}function TP(t){return t.state==="input-available"}const SP={length:"Response reached the model's output limit. Different models have different limits. Try switching models or asking it to continue.","content-filter":"Response was filtered due to content policy.","tool-calls":"Response paused after tool execution to prevent infinite loops and save costs. Click continue to keep working."};function Ms(t){const e=te.c(32),{variant:n,onDismiss:r}=t,i=n==="error",a=i?"Error occurred":"Response incomplete",s=i?t.error.message:SP[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`,o=i?"border-destructive/30 bg-destructive/5":"border-amber-500/30 bg-amber-500/5",l=i?"text-destructive":"text-amber-600 dark:text-amber-500",u=i?IR:TR;let c;e[0]!==o?(c=ce("flex items-start gap-2 px-3 py-2.5 rounded-lg border border-dashed text-sm w-full mb-2",o),e[0]=o,e[1]=c):c=e[1];let d;e[2]!==l?(d=ce("mt-0.5 shrink-0",l),e[2]=l,e[3]=d):d=e[3];let p;e[4]!==u?(p=T.jsx(u,{size:16}),e[4]=u,e[5]=p):p=e[5];let f;e[6]!==d||e[7]!==p?(f=T.jsx("div",{className:d,children:p}),e[6]=d,e[7]=p,e[8]=f):f=e[8];let h;e[9]!==l?(h=ce("text-xs mb-1 font-medium",l),e[9]=l,e[10]=h):h=e[10];let g;e[11]!==h||e[12]!==a?(g=T.jsx("div",{className:h,children:a}),e[11]=h,e[12]=a,e[13]=g):g=e[13];let b;e[14]!==s?(b=T.jsx("div",{className:"text-xs line-clamp-2 text-muted-foreground mb-2",children:s}),e[14]=s,e[15]=b):b=e[15];let E;e[16]!==i||e[17]!==t.onContinue||e[18]!==t.onFixInChat?(E=T.jsx("div",{className:"flex gap-2",children:i?T.jsxs(T.Fragment,{children:[T.jsx(ze,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}),T.jsx(ze,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}):T.jsx(ze,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"})}),e[16]=i,e[17]=t.onContinue,e[18]=t.onFixInChat,e[19]=E):E=e[19];let y;e[20]!==g||e[21]!==b||e[22]!==E?(y=T.jsxs("div",{className:"flex-1 min-w-0",children:[g,b,E]}),e[20]=g,e[21]=b,e[22]=E,e[23]=y):y=e[23];let S;e[24]===Symbol.for("react.memo_cache_sentinel")?(S=T.jsx(wR,{size:14}),e[24]=S):S=e[24];let k;e[25]!==r?(k=T.jsx("button",{type:"button",onClick:r,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0",title:"Dismiss",children:S}),e[25]=r,e[26]=k):k=e[26];let x;return e[27]!==c||e[28]!==k||e[29]!==f||e[30]!==y?(x=T.jsxs("div",{className:c,children:[f,y,k]}),e[27]=c,e[28]=k,e[29]=f,e[30]=y,e[31]=x):x=e[31],x}function Wo(){const t=te.c(23),{error:e,clearError:n,finishReason:r,clearFinishReason:i,messages:a,isStreaming:s,addToolOutput:o,sendMessage:l}=vr();let u,c;if(t[0]!==a){const k=a.at(-1);c=k?.role==="assistant"?k.parts.filter(kP):null,u=c?.filter(AP)?.length,t[0]=a,t[1]=u,t[2]=c}else u=t[1],c=t[2];const d=u;let p;t[3]!==e||t[4]!==l?(p=()=>{if(e){const x={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};l(x)}},t[3]=e,t[4]=l,t[5]=p):p=t[5];const f=p;let h;t[6]!==l?(h=()=>{l({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[6]=l,t[7]=h):h=t[7];const g=h;let b;t[8]!==o?(b=(k,x)=>{o({tool:"user_ask",toolCallId:k.toolCallId,output:{response:x}})},t[8]=o,t[9]=b):b=t[9];const E=b;let y;t[10]!==n||t[11]!==i||t[12]!==e||t[13]!==r||t[14]!==g||t[15]!==f||t[16]!==E||t[17]!==s||t[18]!==d||t[19]!==c?(y=d?T.jsx(M_,{userAskParts:c,isStreaming:s,onSubmit:E}):s?null:e?T.jsx(Ms,{variant:"error",error:e,onDismiss:n,onFixInChat:f}):r&&r!=="stop"?T.jsx(Ms,{variant:"warning",finishReason:r,onDismiss:i,onContinue:g}):null,t[10]=n,t[11]=i,t[12]=e,t[13]=r,t[14]=g,t[15]=f,t[16]=E,t[17]=s,t[18]=d,t[19]=c,t[20]=y):y=t[20];let S;return t[21]!==y?(S=T.jsx("div",{className:"flex flex-col w-full",children:y}),t[21]=y,t[22]=S):S=t[22],S}function AP(t){return t.state!=="output-available"}function kP(t){return t.type==="tool-user_ask"}Wo.Error=function(e){return T.jsx(Ms,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};Wo.Warning=function(e){return T.jsx(Ms,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};Wo.UserAskQuestion=M_;const Ps={passthrough:{label:"Direct access",description:"Best for small teams or when you need predictable behavior",icon:pR},smart_tool_selection:{label:"Smart discovery",description:"Ideal for large teams with many tools - AI finds what it needs",icon:dR},code_execution:{label:"Smart execution",description:"Maximum flexibility - AI can write code to orchestrate tools",icon:LR,recommended:!0}};function xP(t){const e=te.c(24),{mode:n,isSelected:r,onSelect:i}=t,a=Ps[n],s=a.icon,o=r&&"bg-accent";let l;e[0]!==o?(l=ce("flex items-start gap-3 py-3 px-3 hover:bg-accent cursor-pointer rounded-lg transition-colors",o),e[0]=o,e[1]=l):l=e[1];let u;e[2]!==s?(u=T.jsx("div",{className:"p-1.5 shrink-0 rounded-md bg-muted",children:T.jsx(s,{className:"size-4 text-muted-foreground"})}),e[2]=s,e[3]=u):u=e[3];let c;e[4]!==a.label?(c=T.jsx("span",{className:"text-sm font-medium text-foreground",children:a.label}),e[4]=a.label,e[5]=c):c=e[5];let d;e[6]!==a.recommended?(d=a.recommended&&T.jsx(OR,{variant:"outline",className:"text-xs",children:"Recommended"}),e[6]=a.recommended,e[7]=d):d=e[7];let p;e[8]!==r?(p=r&&T.jsx(fi,{size:16,className:"text-foreground shrink-0 ml-auto"}),e[8]=r,e[9]=p):p=e[9];let f;e[10]!==c||e[11]!==d||e[12]!==p?(f=T.jsxs("div",{className:"flex items-center gap-2",children:[c,d,p]}),e[10]=c,e[11]=d,e[12]=p,e[13]=f):f=e[13];let h;e[14]!==a.description?(h=T.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 leading-relaxed",children:a.description}),e[14]=a.description,e[15]=h):h=e[15];let g;e[16]!==f||e[17]!==h?(g=T.jsxs("div",{className:"flex flex-col flex-1 min-w-0 gap-0.5",children:[f,h]}),e[16]=f,e[17]=h,e[18]=g):g=e[18];let b;return e[19]!==i||e[20]!==l||e[21]!==u||e[22]!==g?(b=T.jsxs("div",{onClick:i,className:l,children:[u,g]}),e[19]=i,e[20]=l,e[21]=u,e[22]=g,e[23]=b):b=e[23],b}function vP(t){const e=te.c(13),{mode:n,placeholder:r}=t,i=r===void 0?"Select mode":r;if(!n){let d;e[0]!==i?(d=T.jsx("span",{className:"text-sm text-muted-foreground",children:i}),e[0]=i,e[1]=d):d=e[1];let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=T.jsx(Xh,{size:14,className:"text-muted-foreground opacity-50 shrink-0"}),e[2]=p):p=e[2];let f;return e[3]!==d?(f=T.jsxs("div",{className:"flex items-center gap-1.5",children:[d,p]}),e[3]=d,e[4]=f):f=e[4],f}const a=Ps[n],s=a.icon;let o;e[5]!==s?(o=T.jsx(s,{className:"size-4 text-muted-foreground shrink-0"}),e[5]=s,e[6]=o):o=e[6];let l;e[7]!==a.label?(l=T.jsx("span",{className:"text-sm text-muted-foreground group-hover:text-foreground group-data-[state=open]:text-foreground truncate whitespace-nowrap max-w-0 opacity-0 group-hover:max-w-[150px] group-hover:opacity-100 group-data-[state=open]:max-w-[150px] group-data-[state=open]:opacity-100 transition-all duration-200 ease-in-out overflow-hidden",children:a.label}),e[7]=a.label,e[8]=l):l=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=T.jsx(Xh,{size:14,className:"text-muted-foreground opacity-0 max-w-0 group-hover:opacity-50 group-hover:max-w-[14px] group-data-[state=open]:opacity-50 group-data-[state=open]:max-w-[14px] shrink-0 transition-all duration-200 ease-in-out overflow-hidden"}),e[9]=u):u=e[9];let c;return e[10]!==o||e[11]!==l?(c=T.jsxs("div",{className:"flex items-center gap-0 group-hover:gap-2 group-data-[state=open]:gap-2 min-w-0 overflow-hidden transition-all duration-200",children:[o,l,u]}),e[10]=o,e[11]=l,e[12]=c):c=e[12],c}function CP(t){const e=te.c(28),{selectedMode:n,onModeChange:r,variant:i,className:a,placeholder:s,disabled:o}=t,l=i===void 0?"borderless":i,u=s===void 0?"Mode":s,c=o===void 0?!1:o,[d,p]=P.useState(!1);let f;e[0]!==r?(f=q=>{r(q),p(!1)},e[0]=r,e[1]=f):f=e[1];const h=f,g=c?!1:d,b=l==="borderless"?"ghost":"outline",E=l==="borderless"&&"md:border-none",y=c&&"cursor-not-allowed opacity-50";let S;e[2]!==a||e[3]!==E||e[4]!==y?(S=ce("text-sm hover:bg-accent rounded-lg py-0.5 px-1 gap-1 shadow-none cursor-pointer border-0 group focus-visible:ring-0 focus-visible:ring-offset-0 min-w-0 shrink justify-start overflow-hidden",E,y,a),e[2]=a,e[3]=E,e[4]=y,e[5]=S):S=e[5];const k=d?"open":"closed";let x;e[6]!==u||e[7]!==n?(x=T.jsx(vP,{mode:n,placeholder:u}),e[6]=u,e[7]=n,e[8]=x):x=e[8];let A;e[9]!==c||e[10]!==k||e[11]!==x||e[12]!==b||e[13]!==S?(A=T.jsx(vn,{asChild:!0,children:T.jsx(di,{asChild:!0,children:T.jsx(ze,{variant:b,size:"sm",className:S,disabled:c,"data-state":k,children:x})})}),e[9]=c,e[10]=k,e[11]=x,e[12]=b,e[13]=S,e[14]=A):A=e[14];const v=Ps[n]?.description??"Choose agent mode";let w;e[15]!==v?(w=T.jsx(Cn,{side:"top",className:"text-xs",children:v}),e[15]=v,e[16]=w):w=e[16];let N;e[17]!==A||e[18]!==w?(N=T.jsx(vo,{children:T.jsxs(xn,{children:[A,w]})}),e[17]=A,e[18]=w,e[19]=N):N=e[19];let _;e[20]===Symbol.for("react.memo_cache_sentinel")?(_=Object.keys(Ps),e[20]=_):_=e[20];let D;e[21]!==h||e[22]!==n?(D=T.jsx(pi,{className:"w-[350px] p-0 overflow-hidden",align:"start",side:"top",sideOffset:8,children:T.jsx("div",{className:"flex flex-col p-1",children:_.map(q=>T.jsx(xP,{mode:q,isSelected:q===n,onSelect:()=>h(q)},q))})}),e[21]=h,e[22]=n,e[23]=D):D=e[23];let M;return e[24]!==N||e[25]!==D||e[26]!==g?(M=T.jsxs(ci,{open:g,onOpenChange:p,children:[N,D]}),e[24]=N,e[25]=D,e[26]=g,e[27]=M):M=e[27],M}function _P(t){const e=te.c(24),{virtualMcp:n,isSelected:r}=t,i=r&&"bg-accent";let a;e[0]!==i?(a=ce("flex items-start gap-3 py-3 px-3 hover:bg-accent cursor-pointer rounded-xl transition-colors",i),e[0]=i,e[1]=a):a=e[1];let s;e[2]!==n.fallbackIcon?(s=n.fallbackIcon??T.jsx(Xr,{}),e[2]=n.fallbackIcon,e[3]=s):s=e[3];let o;e[4]!==s||e[5]!==n.icon||e[6]!==n.title?(o=T.jsx(wo,{icon:n.icon,name:n.title,size:"sm",fallbackIcon:s,className:"rounded-xl border border-border shadow-sm shrink-0 aspect-square"}),e[4]=s,e[5]=n.icon,e[6]=n.title,e[7]=o):o=e[7];let l;e[8]!==n.title?(l=T.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:n.title}),e[8]=n.title,e[9]=l):l=e[9];let u;e[10]!==r?(u=r&&T.jsx(fi,{size:16,className:"text-foreground shrink-0"}),e[10]=r,e[11]=u):u=e[11];let c;e[12]!==l||e[13]!==u?(c=T.jsxs("div",{className:"flex items-center justify-between",children:[l,u]}),e[12]=l,e[13]=u,e[14]=c):c=e[14];let d;e[15]!==n.description?(d=n.description&&T.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1 leading-relaxed",children:n.description}),e[15]=n.description,e[16]=d):d=e[16];let p;e[17]!==c||e[18]!==d?(p=T.jsxs("div",{className:"flex flex-col flex-1 min-w-0 gap-0.5",children:[c,d]}),e[17]=c,e[18]=d,e[19]=p):p=e[19];let f;return e[20]!==a||e[21]!==o||e[22]!==p?(f=T.jsxs("div",{className:a,children:[o,p]}),e[20]=a,e[21]=o,e[22]=p,e[23]=f):f=e[23],f}function Dg(t){const e=te.c(33),{virtualMcps:n,selectedVirtualMcpId:r,onVirtualMcpChange:i,searchInputRef:a}=t,[s,o]=P.useState(""),l=P.useRef(null),u=a??l;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={navigateOnCreate:!0},e[0]=c):c=e[0];const{createVirtualMCP:d,isCreating:p}=MR(c);let f,h,g,b;if(e[1]!==d||e[2]!==u||e[3]!==p||e[4]!==i||e[5]!==s||e[6]!==r||e[7]!==n){let S;e:{const M=n.filter(NP);if(!s.trim()){S=M;break e}const q=s.toLowerCase();S=M.filter(F=>F.title.toLowerCase().includes(q)||F.description?.toLowerCase().includes(q))}const k=S;let x;e[12]!==i?(x=M=>{i(M),o("")},e[12]=i,e[13]=x):x=e[13];const A=x;g="flex flex-col max-h-[400px]";let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=T.jsx(iv,{size:16,className:"text-muted-foreground pointer-events-none shrink-0"}),e[14]=v):v=e[14];let w;e[15]===Symbol.for("react.memo_cache_sentinel")?(w=M=>o(M.target.value),e[15]=w):w=e[15];let N;e[16]!==u||e[17]!==s?(N=T.jsx(rv,{ref:u,type:"text",placeholder:"Search for an agent...",value:s,onChange:w,className:"flex-1 h-8 text-sm border-0 focus-visible:ring-0 focus-visible:ring-offset-0 shadow-none p-0"}),e[16]=u,e[17]=s,e[18]=N):N=e[18];const _=p?"Creating...":"Create Agent";let D;e[19]!==d||e[20]!==p||e[21]!==_?(D=T.jsx(ze,{onClick:d,variant:"outline",size:"sm",className:"h-8 px-3 rounded-lg text-sm font-medium shrink-0",disabled:p,children:_}),e[19]=d,e[20]=p,e[21]=_,e[22]=D):D=e[22],e[23]!==N||e[24]!==D?(b=T.jsx("div",{className:"border-b px-4 py-3 bg-background/95 backdrop-blur sticky top-0 z-10",children:T.jsxs("div",{className:"relative flex items-center gap-2",children:[v,N,D]})}),e[23]=N,e[24]=D,e[25]=b):b=e[25],f="overflow-y-auto p-1.5",h=k.length>0?T.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:k.map(M=>T.jsx("div",{role:"button",tabIndex:0,onClick:()=>A(M.id),onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),A(M.id))},className:"outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 rounded-xl",children:T.jsx(_P,{virtualMcp:M,isSelected:M.id===r})},M.id))}):T.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No agents found"}),e[1]=d,e[2]=u,e[3]=p,e[4]=i,e[5]=s,e[6]=r,e[7]=n,e[8]=f,e[9]=h,e[10]=g,e[11]=b}else f=e[8],h=e[9],g=e[10],b=e[11];let E;e[26]!==f||e[27]!==h?(E=T.jsx("div",{className:f,children:h}),e[26]=f,e[27]=h,e[28]=E):E=e[28];let y;return e[29]!==g||e[30]!==b||e[31]!==E?(y=T.jsxs("div",{className:g,children:[b,E]}),e[29]=g,e[30]=b,e[31]=E,e[32]=y):y=e[32],y}function NP(t){return!t.id||!Kr(t.id)}function IP(t){const e=te.c(37),{selectedVirtualMcpId:n,onVirtualMcpChange:r,virtualMcps:i,className:a,placeholder:s,showTooltip:o,disabled:l}=t,u=s===void 0?"Select Agent":s,c=o===void 0?!0:o,d=l===void 0?!1:l,[p,f]=P.useState(!1),h=P.useRef(null),g=DR(),b=i??g;let E;e[0]!==b?(E=b.filter(wP),e[0]=b,e[1]=E):E=e[1];const y=E;let S;e[2]!==b||e[3]!==n?(S=n?b.find(Z=>Z.id===n):null,e[2]=b,e[3]=n,e[4]=S):S=e[4];const k=S;let x;e[5]!==r?(x=Z=>{r(Z),f(!1)},e[5]=r,e[6]=x):x=e[6];const A=x;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=Z=>{f(Z)},e[7]=v):v=e[7];const w=v;let N,_;e[8]!==p?(N=()=>{p&&setTimeout(()=>{h.current?.focus()},0)},_=[p],e[8]=p,e[9]=N,e[10]=_):(N=e[9],_=e[10]),P.useEffect(N,_);const D=d?!1:p,M=d?void 0:w,q=d?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-accent";let F;e[11]!==a||e[12]!==q?(F=ce("flex items-center justify-center size-8 rounded-full transition-colors shrink-0",q,a),e[11]=a,e[12]=q,e[13]=F):F=e[13];let U;e[14]!==k?(U=k?T.jsx(wo,{icon:k.icon,name:k.title,size:"xs",fallbackIcon:T.jsx(Xr,{size:16}),className:"rounded-md shrink-0 aspect-square"}):T.jsx(Xr,{size:16}),e[14]=k,e[15]=U):U=e[15];let $;e[16]!==d||e[17]!==u||e[18]!==F||e[19]!==U?($=T.jsx(vn,{asChild:!0,children:T.jsx(di,{asChild:!0,children:T.jsx("button",{type:"button",disabled:d,className:F,"aria-label":u,children:U})})}),e[16]=d,e[17]=u,e[18]=F,e[19]=U,e[20]=$):$=e[20];let G;e[21]!==p||e[22]!==k?.title||e[23]!==c?(G=c&&!p&&T.jsx(Cn,{side:"top",className:"text-xs",children:k?.title??"Choose an agent to chat with"}),e[21]=p,e[22]=k?.title,e[23]=c,e[24]=G):G=e[24];let H;e[25]!==$||e[26]!==G?(H=T.jsx(vo,{children:T.jsxs(xn,{children:[$,G]})}),e[25]=$,e[26]=G,e[27]=H):H=e[27];let J;e[28]!==A||e[29]!==n||e[30]!==y?(J=T.jsx(pi,{className:"w-[550px] p-0 overflow-hidden",align:"start",side:"top",sideOffset:8,children:T.jsx(Dg,{virtualMcps:y,selectedVirtualMcpId:n,onVirtualMcpChange:A,searchInputRef:h})}),e[28]=A,e[29]=n,e[30]=y,e[31]=J):J=e[31];let I;return e[32]!==D||e[33]!==M||e[34]!==H||e[35]!==J?(I=T.jsxs(ci,{open:D,onOpenChange:M,children:[H,J]}),e[32]=D,e[33]=M,e[34]=H,e[35]=J,e[36]=I):I=e[36],I}function wP(t){return!t.id||!Kr(t.id)}function RP(t,e,n){t.chain().focus().insertContentAt(e,[OP(n),{type:"text",text:" "}]).run()}function OP(t){return{type:"file",attrs:t}}function LP(t){const e=te.c(17),{node:n,selected:r,view:i}=t,{name:a,mimeType:s,data:o}=n.attrs,l=r&&i.editable;let u;e[0]!==s?(u=s.startsWith("image/"),e[0]=s,e[1]=u):u=e[1];const c=u,d=l&&"outline-2 outline-blue-300 outline-offset-0";let p;e[2]!==d?(p=ce("px-1 py-1 rounded","inline-flex items-center gap-1","cursor-default select-none","text-xs font-light","bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300",d),e[2]=d,e[3]=p):p=e[3];let f;e[4]!==a?(f=T.jsx(vn,{asChild:!0,children:T.jsx("span",{children:a})}),e[4]=a,e[5]=f):f=e[5];let h;e[6]!==o||e[7]!==c||e[8]!==s||e[9]!==a?(h=T.jsx(Cn,{side:"top",className:"max-w-sm",children:c?T.jsx("img",{src:`data:${s};base64,${o}`,alt:a,className:"max-w-full max-h-64 object-contain rounded"}):T.jsxs("div",{className:"text-xs",children:[T.jsx("div",{className:"font-medium",children:a}),T.jsx("div",{className:"text-muted-foreground mt-1",children:s})]})}),e[6]=o,e[7]=c,e[8]=s,e[9]=a,e[10]=h):h=e[10];let g;e[11]!==f||e[12]!==h?(g=T.jsxs(xn,{children:[f,h]}),e[11]=f,e[12]=h,e[13]=g):g=e[13];let b;return e[14]!==p||e[15]!==g?(b=T.jsx(__,{className:p,children:g}),e[14]=p,e[15]=g,e[16]=b):b=e[16],b}const P_=Tt.create({name:"file",group:"inline",inline:!0,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id")||null,renderHTML:t=>t.id?{"data-id":t.id}:{}},name:{default:null,parseHTML:t=>t.getAttribute("data-name")||null,renderHTML:t=>t.name?{"data-name":t.name}:{}},mimeType:{default:null,parseHTML:t=>t.getAttribute("data-mime-type")||null,renderHTML:t=>t.mimeType?{"data-mime-type":t.mimeType}:{}},size:{default:0,parseHTML:t=>{const e=t.getAttribute("data-size");return e?Number.parseInt(e,10):0},renderHTML:t=>t.size?{"data-size":String(t.size)}:{}},data:{default:null,parseHTML:t=>t.getAttribute("data-data")||null,renderHTML:t=>t.data?{"data-data":t.data}:{}}}},parseHTML(){return[{tag:'span[data-type="file"]'}]},renderHTML({node:t,HTMLAttributes:e}){const n={"data-type":"file"};return t.attrs.id&&(n["data-id"]=t.attrs.id),t.attrs.name&&(n["data-name"]=t.attrs.name),t.attrs.mimeType&&(n["data-mime-type"]=t.attrs.mimeType),t.attrs.size&&(n["data-size"]=String(t.attrs.size)),t.attrs.data&&(n["data-data"]=t.attrs.data),["span",{...e,...n}]},renderText({node:t}){return`[${t.attrs.name??""}]`},addNodeView(){return N_(LP)}});async function F_(t,e,n,r){if(!Xx(e)){Sn.error("Selected model does not support file uploads");return}const i=10*1024*1024;if(n.size>i){Sn.error(`File "${n.name}" exceeds 10MB limit`);return}try{const a=new FileReader,s=new Promise((u,c)=>{a.onload=()=>{const d=a.result;if(typeof d!="string"){c(new Error("Failed to read file as data URL"));return}const p=d.includes(",")?d.split(",")[1]??d:d;u(p)},a.onerror=c});a.readAsDataURL(n);const o=await s,l={id:crypto.randomUUID(),name:n.name,mimeType:n.type||"application/octet-stream",size:n.size,data:o};RP(t,{from:r,to:r},l)}catch(a){console.error("Failed to process file:",a),Sn.error(`Failed to load file "${n.name}"`)}}function DP(t){const e=te.c(7),{editor:n,selectedModel:r}=t,i=P.useRef(MP);let a,s;e[0]!==n||e[1]!==r?(a=()=>{i.current=async(u,c)=>{await F_(n,r,u,c)}},s=[n,r],e[0]=n,e[1]=r,e[2]=a,e[3]=s):(a=e[2],s=e[3]),P.useEffect(a,s);let o,l;return e[4]!==n?(o=()=>{if(n?.isDestroyed)return;const u=new De("fileDropHandler");n.state.plugins.find(p=>p.spec.key===u)&&n.unregisterPlugin(u);const d=new Ie({key:u,props:{handleDrop:(p,f,h,g)=>{if(g)return!1;const b=f.dataTransfer?.files;if(!b||b.length===0)return!1;f.preventDefault();const E=p.posAtCoords({left:f.clientX,top:f.clientY});if(!E)return!1;const y=Array.from(b),S=E.pos;for(const k of y)i.current?.(k,S);return!0}}});return n.registerPlugin(d),()=>{n?.isDestroyed||n.unregisterPlugin(u)}},l=[n],e[4]=n,e[5]=o,e[6]=l):(o=e[5],l=e[6]),P.useEffect(o,l),null}function MP(){return Promise.resolve()}function PP(t){const e=te.c(20),{selectedModel:n,isStreaming:r}=t,{editor:i}=v_(),a=P.useRef(null);let s;e[0]!==n?(s=Xx(n),e[0]=n,e[1]=s):s=e[1];const o=s;let l;e[2]!==i||e[3]!==n?(l=async k=>{const x=k.target.files;if(!x||x.length===0||!i)return;const A=Array.from(x),{from:v}=i.state.selection,w=v;for(const N of A)await F_(i,n,N,w);a.current&&(a.current.value="")},e[2]=i,e[3]=n,e[4]=l):l=e[4];const u=l;if(!i)return null;const c=r||!o;let d;e[5]!==u||e[6]!==c?(d=T.jsx("input",{ref:a,type:"file",multiple:!0,className:"hidden",onChange:u,disabled:c}),e[5]=u,e[6]=c,e[7]=d):d=e[7];const p=r||!o;let f,h;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=()=>a.current?.click(),h=T.jsx(lv,{size:16}),e[8]=f,e[9]=h):(f=e[8],h=e[9]);let g;e[10]!==p?(g=T.jsx(vn,{asChild:!0,children:T.jsx(ze,{type:"button",variant:"ghost",size:"icon",className:"size-8 rounded-full",disabled:p,onClick:f,children:h})}),e[10]=p,e[11]=g):g=e[11];const b=o?"Add file":"Selected model does not support files";let E;e[12]!==b?(E=T.jsx(Cn,{side:"top",children:b}),e[12]=b,e[13]=E):E=e[13];let y;e[14]!==E||e[15]!==g?(y=T.jsxs(xn,{children:[g,E]}),e[14]=E,e[15]=g,e[16]=y):y=e[16];let S;return e[17]!==y||e[18]!==d?(S=T.jsxs(T.Fragment,{children:[d,y]}),e[17]=y,e[18]=d,e[19]=S):S=e[19],S}function FP(t={}){return new Ie({view(e){return new BP(e,t)}})}class BP{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let a=s=>{this[i](s)};return e.dom.addEventListener(i,a),{name:i,handler:a}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,a=i.getBoundingClientRect(),s=a.width/i.offsetWidth,o=a.height/i.offsetHeight;if(n){let d=e.nodeBefore,p=e.nodeAfter;if(d||p){let f=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(f){let h=f.getBoundingClientRect(),g=d?h.bottom:h.top;d&&p&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let b=this.width/2*o;r={left:h.left,right:h.right,top:g-b,bottom:g+b}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*s;r={left:d.left-p,right:d.left+p,top:d.top,bottom:d.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,c;if(!l||l==document.body&&getComputedStyle(l).position=="static")u=-pageXOffset,c=-pageYOffset;else{let d=l.getBoundingClientRect(),p=d.width/l.offsetWidth,f=d.height/l.offsetHeight;u=d.left-l.scrollLeft*p,c=d.top-l.scrollTop*f}this.element.style.left=(r.left-u)/s+"px",this.element.style.top=(r.top-c)/o+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/o+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,a=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!a){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let o=$v(this.editorView.state.doc,s,this.editorView.dragging.slice);o!=null&&(s=o)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Fe extends ge{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Fe.valid(r)?new Fe(r):ge.near(r)}content(){return ee.empty}eq(e){return e instanceof Fe&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Fe(e.resolve(n.pos))}getBookmark(){return new Mg(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!UP(e)||!HP(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Fe.valid(e))return e;let i=e.pos,a=null;for(let s=e.depth;;s--){let o=e.node(s);if(n>0?e.indexAfter(s)<o.childCount:e.index(s)>0){a=o.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=n;let l=e.doc.resolve(i);if(Fe.valid(l))return l}for(;;){let s=n>0?a.firstChild:a.lastChild;if(!s){if(a.isAtom&&!a.isText&&!le.isSelectable(a)){e=e.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=s,i+=n;let o=e.doc.resolve(i);if(Fe.valid(o))return o}return null}}}Fe.prototype.visible=!1;Fe.findFrom=Fe.findGapCursorFrom;ge.jsonID("gapcursor",Fe);class Mg{constructor(e){this.pos=e}map(e){return new Mg(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Fe.valid(n)?new Fe(n):ge.near(n)}}function B_(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function UP(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||B_(i.type))return!0;if(i.inlineContent)return!1}}return!0}function HP(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||B_(i.type))return!0;if(i.inlineContent)return!1}}return!0}function $P(){return new Ie({props:{decorations:GP,createSelectionBetween(t,e,n){return e.pos==n.pos&&Fe.valid(n)?new Fe(n):null},handleClick:qP,handleKeyDown:zP,handleDOMEvents:{beforeinput:jP}}})}const zP=zC({ArrowLeft:Wa("horiz",-1),ArrowRight:Wa("horiz",1),ArrowUp:Wa("vert",-1),ArrowDown:Wa("vert",1)});function Wa(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,a){let s=r.selection,o=e>0?s.$to:s.$from,l=s.empty;if(s instanceof pe){if(!a.endOfTextblock(n)||o.depth==0)return!1;l=!1,o=r.doc.resolve(e>0?o.after():o.before())}let u=Fe.findGapCursorFrom(o,e,l);return u?(i&&i(r.tr.setSelection(new Fe(u))),!0):!1}}function qP(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Fe.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&le.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Fe(r))),!0)}function jP(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Fe))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=W.empty;for(let s=r.length-1;s>=0;s--)i=W.from(r[s].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new ee(i,0,0));return a.setSelection(pe.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function GP(t){if(!(t.selection instanceof Fe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Re.create(t.doc,[it.widget(t.selection.head,e,{key:"gapcursor"})])}var Fs=200,Xe=function(){};Xe.prototype.append=function(e){return e.length?(e=Xe.from(e),!this.length&&e||e.length<Fs&&this.leafAppend(e)||this.length<Fs&&e.leafPrepend(this)||this.appendInner(e)):this};Xe.prototype.prepend=function(e){return e.length?Xe.from(e).append(this):this};Xe.prototype.appendInner=function(e){return new VP(this,e)};Xe.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Xe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Xe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Xe.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};Xe.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(a,s){return i.push(e(a,s))},n,r),i};Xe.from=function(e){return e instanceof Xe?e:e&&e.length?new U_(e):Xe.empty};var U_=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,a){return i==0&&a==this.length?this:new e(this.values.slice(i,a))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,a,s,o){for(var l=a;l<s;l++)if(i(this.values[l],o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,a,s,o){for(var l=a-1;l>=s;l--)if(i(this.values[l],o+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Fs)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Fs)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Xe);Xe.empty=new U_([]);var VP=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,a,s){var o=this.left.length;if(i<o&&this.left.forEachInner(r,i,Math.min(a,o),s)===!1||a>o&&this.right.forEachInner(r,Math.max(i-o,0),Math.min(this.length,a)-o,s+o)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,s){var o=this.left.length;if(i>o&&this.right.forEachInvertedInner(r,i-o,Math.max(a,o)-o,s+o)===!1||a<o&&this.left.forEachInvertedInner(r,Math.min(i,o),a,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var a=this.left.length;return i<=a?this.left.slice(r,i):r>=a?this.right.slice(r-a,i-a):this.left.slice(r,a).append(this.right.slice(0,i-a))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Xe);const WP=500;class Gt{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let s=e.tr,o,l,u=[],c=[];return this.items.forEach((d,p)=>{if(!d.step){i||(i=this.remapping(r,p+1),a=i.maps.length),a--,c.push(d);return}if(i){c.push(new Qt(d.map));let f=d.step.map(i.slice(a)),h;f&&s.maybeStep(f).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],u.push(new Qt(h,void 0,void 0,u.length+c.length))),a--,h&&i.appendMap(h,a)}else s.maybeStep(d.step);if(d.selection)return o=i?d.selection.map(i.slice(a)):d.selection,l=new Gt(this.items.slice(0,r).append(c.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:s,selection:o}}addTransform(e,n,r,i){let a=[],s=this.eventCount,o=this.items,l=!i&&o.length?o.get(o.length-1):null;for(let c=0;c<e.steps.length;c++){let d=e.steps[c].invert(e.docs[c]),p=new Qt(e.mapping.maps[c],d,n),f;(f=l&&l.merge(p))&&(p=f,c?a.pop():o=o.slice(0,o.length-1)),a.push(p),n&&(s++,n=void 0),i||(l=p)}let u=s-r.depth;return u>KP&&(o=YP(o,u),s-=u),new Gt(o.append(a),s)}remapping(e,n){let r=new ca;return this.items.forEach((i,a)=>{let s=i.mirrorOffset!=null&&a-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new Gt(this.items.append(e.map(n=>new Qt(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=e.mapping,s=e.steps.length,o=this.eventCount;this.items.forEach(p=>{p.selection&&o--},i);let l=n;this.items.forEach(p=>{let f=a.getMirror(--l);if(f==null)return;s=Math.min(s,f);let h=a.maps[f];if(p.step){let g=e.steps[f].invert(e.docs[f]),b=p.selection&&p.selection.map(a.slice(l+1,f));b&&o++,r.push(new Qt(h,g,b))}else r.push(new Qt(h))},i);let u=[];for(let p=n;p<s;p++)u.push(new Qt(a.maps[p]));let c=this.items.slice(0,i).append(u).append(r),d=new Gt(c,o);return d.emptyItemCount()>WP&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],a=0;return this.items.forEach((s,o)=>{if(o>=e)i.push(s),s.selection&&a++;else if(s.step){let l=s.step.map(n.slice(r)),u=l&&l.getMap();if(r--,u&&n.appendMap(u,r),l){let c=s.selection&&s.selection.map(n.slice(r));c&&a++;let d=new Qt(u.invert(),l,c),p,f=i.length-1;(p=i.length&&i[f].merge(d))?i[f]=p:i.push(d)}}else s.map&&r--},this.items.length,0),new Gt(Xe.from(i.reverse()),a)}}Gt.empty=new Gt(Xe.empty,0);function YP(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Qt{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Qt(n.getMap().invert(),n,this.selection)}}}class Pn{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const KP=20;function XP(t,e,n,r){let i=n.getMeta(mr),a;if(i)return i.historyState;n.getMeta(JP)&&(t=new Pn(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(mr))return s.getMeta(mr).redo?new Pn(t.done.addTransform(n,void 0,r,ds(e)),t.undone,u0(n.mapping.maps),t.prevTime,t.prevComposition):new Pn(t.done,t.undone.addTransform(n,void 0,r,ds(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let o=n.getMeta("composition"),l=t.prevTime==0||!s&&t.prevComposition!=o&&(t.prevTime<(n.time||0)-r.newGroupDelay||!ZP(n,t.prevRanges)),u=s?Dl(t.prevRanges,n.mapping):u0(n.mapping.maps);return new Pn(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,ds(e)),Gt.empty,u,n.time,o??t.prevComposition)}else return(a=n.getMeta("rebased"))?new Pn(t.done.rebased(n,a),t.undone.rebased(n,a),Dl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Pn(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Dl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function ZP(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let a=0;a<e.length;a+=2)r<=e[a+1]&&i>=e[a]&&(n=!0)}),n}function u0(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,a,s)=>e.push(a,s));return e}function Dl(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),a=e.map(t[r+1],-1);i<=a&&n.push(i,a)}return n}function QP(t,e,n){let r=ds(e),i=mr.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,r);if(!a)return null;let s=a.selection.resolve(a.transform.doc),o=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),i,r),l=new Pn(n?o:a.remaining,n?a.remaining:o,null,0,-1);return a.transform.setSelection(s).setMeta(mr,{redo:n,historyState:l})}let Ml=!1,c0=null;function ds(t){let e=t.plugins;if(c0!=e){Ml=!1,c0=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Ml=!0;break}}return Ml}const mr=new De("history"),JP=new De("closeHistory");function eF(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Ie({key:mr,state:{init(){return new Pn(Gt.empty,Gt.empty,null,0,-1)},apply(e,n,r){return XP(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?$_:r=="historyRedo"?z_:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function H_(t,e){return(n,r)=>{let i=mr.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=QP(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const $_=H_(!1,!0),z_=H_(!0,!0);Ue.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Ie({key:new De("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const a=this.storage.characters({node:r.doc});if(a>i){const s=a-i,o=0,l=s;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(o,l);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),a=this.storage.characters({node:e.doc});if(a<=r||i>r&&a>r&&a<=i)return!0;if(i>r&&a>r&&a>i||!e.getMeta("paste"))return!1;const o=e.selection.$head.pos,l=a-r,u=o-l,c=o;return e.deleteRange(u,c),!(this.storage.characters({node:e.doc})>r)}})]}});var tF=Ue.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[FP(this.options)]}});Ue.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Ie({key:new De("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return Re.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((l,u)=>{if(l.isText)return;if(!(i>=u&&i<=u+l.nodeSize-1))return!1;s+=1});let o=0;return t.descendants((l,u)=>{if(l.isText||!(i>=u&&i<=u+l.nodeSize-1))return!1;if(o+=1,this.options.mode==="deepest"&&s-o>0||this.options.mode==="shallowest"&&o>1)return this.options.mode==="deepest";a.push(it.node(u,u+l.nodeSize,{class:this.options.className}))}),Re.create(t,a)}}})]}});var nF=Ue.create({name:"gapCursor",addProseMirrorPlugins(){return[$P()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Ae(oe(t,"allowGapCursor",n)))!=null?e:null}}}),d0="placeholder";function rF(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var iF=Ue.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:d0,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${rF(this.options.dataAttribute)}`:`data-${d0}`;return[new Ie({key:new De("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,a=[];if(!r)return null;const s=this.editor.isEmpty;return e.descendants((o,l)=>{const u=i>=l&&i<=l+o.nodeSize,c=!o.isLeaf&&qo(o);if((u||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];s&&d.push(this.options.emptyEditorClass);const p=it.node(l,l+o.nodeSize,{class:d.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:u}):this.options.placeholder});a.push(p)}return this.options.includeChildren}),Re.create(e,a)}}})]}});Ue.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Ie({key:new De("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||i_(n.selection)||t.view.dragging?null:Re.create(n.doc,[it.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function p0({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var aF=Ue.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new De(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new Ie({key:e,appendTransaction:(i,a,s)=>{const{doc:o,tr:l,schema:u}=s,c=e.getState(s),d=o.content.size,p=u.nodes[n];if(c)return l.insert(d,p.create())},state:{init:(i,a)=>{const s=a.tr.doc.lastChild;return!p0({node:s,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const s=i.doc.lastChild;return!p0({node:s,types:r})}}})]}}),sF=Ue.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>$_(t,e),redo:()=>({state:t,dispatch:e})=>z_(t,e)}},addProseMirrorPlugins(){return[eF(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),oF=iF,Bs=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},lF=/^\s*>\s$/,uF=Tt.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Bs("blockquote",{...je(this.options.HTMLAttributes,t),children:Bs("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const o=e.renderChildren([i]).split(`
|
|
100
|
+
`)}function KM(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,s=t;i.descendants((o,l)=>{const u=a.mapping.map(l),c=a.mapping.map(l)+o.nodeSize;let d=null;if(o.marks.forEach(f=>{if(f!==s)return!1;d=f}),!d)return;let p=!1;if(Object.keys(n).forEach(f=>{n[f]!==d.attrs[f]&&(p=!0)}),p){const f=t.type.create({...t.attrs,...n});a.removeMark(u,c,t.type),a.addMark(u,c,f)}}),a.docChanged&&e.view.dispatch(a)}var Tt=class S_ extends Ng{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new S_(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},XM=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,i,a,s,o;const{view:l}=this.editor,u=t.target,c=u.nodeType===3?(e=u.parentElement)==null?void 0:e.closest("[data-drag-handle]"):u.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(u)||!c)return;let d=0,p=0;if(this.dom!==c){const y=this.dom.getBoundingClientRect(),S=c.getBoundingClientRect(),k=(i=t.offsetX)!=null?i:(r=t.nativeEvent)==null?void 0:r.offsetX,x=(s=t.offsetY)!=null?s:(a=t.nativeEvent)==null?void 0:a.offsetY;d=S.x-y.x+k,p=S.y-y.y+x}const f=this.dom.cloneNode(!0);try{const y=this.dom.getBoundingClientRect();f.style.width=`${Math.round(y.width)}px`,f.style.height=`${Math.round(y.height)}px`,f.style.boxSizing="border-box",f.style.pointerEvents="none"}catch{}let h=null;try{h=document.createElement("div"),h.style.position="absolute",h.style.top="-9999px",h.style.left="-9999px",h.style.pointerEvents="none",h.appendChild(f),document.body.appendChild(h),(o=t.dataTransfer)==null||o.setDragImage(f,d,p)}finally{h&&setTimeout(()=>{try{h?.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const b=le.create(l.state.doc,g),E=l.state.tr.setSelection(b);l.dispatch(E)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const i=t.type.startsWith("drag"),a=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!a&&!i)return!0;const{isEditable:o}=this.editor,{isDragging:l}=this,u=!!this.node.type.spec.draggable,c=le.isSelectable(this.node),d=t.type==="copy",p=t.type==="paste",f=t.type==="cut",h=t.type==="mousedown";if(!u&&c&&i&&t.target===this.dom&&t.preventDefault(),u&&i&&!l&&t.target===this.dom)return t.preventDefault(),!1;if(u&&o&&!l&&h){const g=n.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(l||a||d||p||f||h&&c)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(ma()||fm())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function Ar(t){return new wM({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=Ae(t.getAttributes,void 0,r,i);if(a===!1||a===null)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];let u=n.to;if(o){const c=l.search(/\S/),d=n.from+l.indexOf(o),p=d+o.length;if(_g(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(b=>b===t.type&&b!==h.mark.type)).filter(h=>h.to>d).length)return null;p<n.to&&s.delete(p,n.to),d>n.from&&s.delete(n.from+c,d),u=n.from+c+o.length,s.addMark(n.from+c,u,t.type.create(a||{})),s.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:ZM,getOwnPropertySymbols:QM}=Object,{hasOwnProperty:JM}=Object.prototype;function Ll(t,e){return function(r,i,a){return t(r,i,a)&&e(r,i,a)}}function Va(t){return function(n,r,i){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,i);const{cache:a}=i,s=a.get(n),o=a.get(r);if(s&&o)return s===r&&o===n;a.set(n,r),a.set(r,n);const l=t(n,r,i);return a.delete(n),a.delete(r),l}}function e3(t){return t?.[Symbol.toStringTag]}function ZE(t){return ZM(t).concat(QM(t))}const t3=Object.hasOwn||((t,e)=>JM.call(t,e));function Nr(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const n3="__v",r3="__o",i3="_owner",{getOwnPropertyDescriptor:QE,keys:JE}=Object;function a3(t,e){return t.byteLength===e.byteLength&&Ds(new Uint8Array(t),new Uint8Array(e))}function s3(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function o3(t,e){return t.byteLength===e.byteLength&&Ds(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function l3(t,e){return Nr(t.getTime(),e.getTime())}function u3(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function c3(t,e){return t===e}function e0(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),a=t.entries();let s,o,l=0;for(;(s=a.next())&&!s.done;){const u=e.entries();let c=!1,d=0;for(;(o=u.next())&&!o.done;){if(i[d]){d++;continue}const p=s.value,f=o.value;if(n.equals(p[0],f[0],l,d,t,e,n)&&n.equals(p[1],f[1],p[0],f[0],t,e,n)){c=i[d]=!0;break}d++}if(!c)return!1;l++}return!0}const d3=Nr;function p3(t,e,n){const r=JE(t);let i=r.length;if(JE(e).length!==i)return!1;for(;i-- >0;)if(!A_(t,e,n,r[i]))return!1;return!0}function Ci(t,e,n){const r=ZE(t);let i=r.length;if(ZE(e).length!==i)return!1;let a,s,o;for(;i-- >0;)if(a=r[i],!A_(t,e,n,a)||(s=QE(t,a),o=QE(e,a),(s||o)&&(!s||!o||s.configurable!==o.configurable||s.enumerable!==o.enumerable||s.writable!==o.writable)))return!1;return!0}function f3(t,e){return Nr(t.valueOf(),e.valueOf())}function h3(t,e){return t.source===e.source&&t.flags===e.flags}function t0(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),a=t.values();let s,o;for(;(s=a.next())&&!s.done;){const l=e.values();let u=!1,c=0;for(;(o=l.next())&&!o.done;){if(!i[c]&&n.equals(s.value,o.value,s.value,o.value,t,e,n)){u=i[c]=!0;break}c++}if(!u)return!1}return!0}function Ds(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function m3(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function A_(t,e,n,r){return(r===i3||r===r3||r===n3)&&(t.$$typeof||e.$$typeof)?!0:t3(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const g3="[object ArrayBuffer]",b3="[object Arguments]",E3="[object Boolean]",y3="[object DataView]",T3="[object Date]",S3="[object Error]",A3="[object Map]",k3="[object Number]",x3="[object Object]",v3="[object RegExp]",C3="[object Set]",_3="[object String]",N3={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},I3="[object URL]",w3=Object.prototype.toString;function R3({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:s,areNumbersEqual:o,areObjectsEqual:l,arePrimitiveWrappersEqual:u,areRegExpsEqual:c,areSetsEqual:d,areTypedArraysEqual:p,areUrlsEqual:f,unknownTagComparators:h}){return function(b,E,y){if(b===E)return!0;if(b==null||E==null)return!1;const S=typeof b;if(S!==typeof E)return!1;if(S!=="object")return S==="number"?o(b,E,y):S==="function"?a(b,E,y):!1;const k=b.constructor;if(k!==E.constructor)return!1;if(k===Object)return l(b,E,y);if(Array.isArray(b))return e(b,E,y);if(k===Date)return r(b,E,y);if(k===RegExp)return c(b,E,y);if(k===Map)return s(b,E,y);if(k===Set)return d(b,E,y);const x=w3.call(b);if(x===T3)return r(b,E,y);if(x===v3)return c(b,E,y);if(x===A3)return s(b,E,y);if(x===C3)return d(b,E,y);if(x===x3)return typeof b.then!="function"&&typeof E.then!="function"&&l(b,E,y);if(x===I3)return f(b,E,y);if(x===S3)return i(b,E,y);if(x===b3)return l(b,E,y);if(N3[x])return p(b,E,y);if(x===g3)return t(b,E,y);if(x===y3)return n(b,E,y);if(x===E3||x===k3||x===_3)return u(b,E,y);if(h){let A=h[x];if(!A){const v=e3(b);v&&(A=h[v])}if(A)return A(b,E,y)}return!1}}function O3({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:a3,areArraysEqual:n?Ci:s3,areDataViewsEqual:o3,areDatesEqual:l3,areErrorsEqual:u3,areFunctionsEqual:c3,areMapsEqual:n?Ll(e0,Ci):e0,areNumbersEqual:d3,areObjectsEqual:n?Ci:p3,arePrimitiveWrappersEqual:f3,areRegExpsEqual:h3,areSetsEqual:n?Ll(t0,Ci):t0,areTypedArraysEqual:n?Ll(Ds,Ci):Ds,areUrlsEqual:m3,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const i=Va(r.areArraysEqual),a=Va(r.areMapsEqual),s=Va(r.areObjectsEqual),o=Va(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:i,areMapsEqual:a,areObjectsEqual:s,areSetsEqual:o})}return r}function L3(t){return function(e,n,r,i,a,s,o){return t(e,n,o)}}function D3({circular:t,comparator:e,createState:n,equals:r,strict:i}){if(n)return function(o,l){const{cache:u=t?new WeakMap:void 0,meta:c}=n();return e(o,l,{cache:u,equals:r,meta:c,strict:i})};if(t)return function(o,l){return e(o,l,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};const a={cache:void 0,equals:r,meta:void 0,strict:i};return function(o,l){return e(o,l,a)}}const M3=er();er({strict:!0});er({circular:!0});er({circular:!0,strict:!0});er({createInternalComparator:()=>Nr});er({strict:!0,createInternalComparator:()=>Nr});er({circular:!0,createInternalComparator:()=>Nr});er({circular:!0,createInternalComparator:()=>Nr,strict:!0});function er(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:i=!1}=t,a=O3(t),s=R3(a),o=n?n(s):L3(s);return D3({circular:e,comparator:s,createState:r,equals:o,strict:i})}var P3=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},F3=({contentComponent:t})=>{const e=Gx.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return T.jsx(T.Fragment,{children:Object.values(e)})};function B3(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:Yw.createPortal(r.reactElement,r.element,n)},t.forEach(i=>i())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(i=>i())}}}var U3=class extends mt.Component{constructor(t){var e;super(t),this.editorContentRef=mt.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=B3(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return T.jsxs(T.Fragment,{children:[T.jsx("div",{ref:P3(e,this.editorContentRef),...n}),t?.contentComponent&&T.jsx(F3,{contentComponent:t.contentComponent})]})}},H3=P.forwardRef((t,e)=>{const n=mt.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return mt.createElement(U3,{key:n,innerRef:e,...t})}),Og=mt.memo(H3),$3=typeof window<"u"?P.useLayoutEffect:P.useEffect,z3=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function q3(t){var e;const[n]=P.useState(()=>new z3(t.editor)),r=Ww.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:M3);return $3(()=>n.watch(t.editor),[t.editor,n]),P.useDebugValue(r),r}var j3=!1,Em=typeof window>"u",G3=Em||!!(typeof window<"u"&&window.next),V3=class k_{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?Em||G3?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onBeforeCreate)==null?void 0:a.call(i,...r)},onBlur:(...r)=>{var i,a;return(a=(i=this.options.current).onBlur)==null?void 0:a.call(i,...r)},onCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onCreate)==null?void 0:a.call(i,...r)},onDestroy:(...r)=>{var i,a;return(a=(i=this.options.current).onDestroy)==null?void 0:a.call(i,...r)},onFocus:(...r)=>{var i,a;return(a=(i=this.options.current).onFocus)==null?void 0:a.call(i,...r)},onSelectionUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onSelectionUpdate)==null?void 0:a.call(i,...r)},onTransaction:(...r)=>{var i,a;return(a=(i=this.options.current).onTransaction)==null?void 0:a.call(i,...r)},onUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onUpdate)==null?void 0:a.call(i,...r)},onContentError:(...r)=>{var i,a;return(a=(i=this.options.current).onContentError)==null?void 0:a.call(i,...r)},onDrop:(...r)=>{var i,a;return(a=(i=this.options.current).onDrop)==null?void 0:a.call(i,...r)},onPaste:(...r)=>{var i,a;return(a=(i=this.options.current).onPaste)==null?void 0:a.call(i,...r)},onDelete:(...r)=>{var i,a;return(a=(i=this.options.current).onDelete)==null?void 0:a.call(i,...r)}};return new UM(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,a)=>{var s;return i===((s=n.extensions)==null?void 0:s[a])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?k_.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,i)=>r===e[i]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function x_(t={},e=[]){const n=P.useRef(t);n.current=t;const[r]=P.useState(()=>new V3(n)),i=Gx.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return P.useDebugValue(i),P.useEffect(r.onRender(e)),q3({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var Vo=P.createContext({editor:null});Vo.Consumer;var v_=()=>P.useContext(Vo),C_=P.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),W3=()=>P.useContext(C_),__=mt.forwardRef((t,e)=>{const{onDragStart:n}=W3(),r=t.as||"div";return T.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function n0(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function r0(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function Y3(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function K3(t){if(n0(t)||r0(t))return!0;if(Y3(t)){const e=t.type;if(e)return n0(e)||r0(e)}return!1}function X3(){try{if(P.version)return parseInt(P.version.split(".")[0],10)>=19}catch{}return!1}var Z3=class{constructor(t,{editor:e,props:n={},as:r="div",className:i=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isInitialized?Vx.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var t;if(this.destroyed)return;const e=this.component,n=this.props,r=this.editor,i=X3(),a=K3(e),s={...n};s.ref&&!(i||a)&&delete s.ref,!s.ref&&(i||a)&&(s.ref=o=>{this.ref=o}),this.reactElement=T.jsx(e,{...s}),(t=r?.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){this.destroyed||(this.props={...this.props,...t},this.render())}destroy(){var t;this.destroyed=!0;const e=this.editor;(t=e?.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};mt.createContext({markViewContentRef:()=>{}});var Q3=class extends XM{constructor(t,e,n){if(super(t,e,n),this.selectionRafId=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){const t=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(n,r,i){var a;return r==="storage"?(a=t.storage[e.name])!=null?a:{}:Reflect.get(n,r,i)}})}return this.cachedExtensionWithSyncedStorage}mount(){const t={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(l={})=>this.updateAttributes(l),deleteNode:()=>this.deleteNode(),ref:P.createRef()};if(!this.component.displayName){const l=u=>u.charAt(0).toUpperCase()+u.substring(1);this.component.displayName=l(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:l=>{l&&this.contentDOMElement&&l.firstChild!==this.contentDOMElement&&(l.hasAttribute("data-node-view-wrapper")&&l.removeAttribute("data-node-view-wrapper"),l.appendChild(this.contentDOMElement))}},i=this.component,a=P.memo(l=>T.jsx(C_.Provider,{value:r,children:P.createElement(i,l)}));a.displayName="ReactNodeView";let s=this.node.isInline?"span":"div";this.options.as&&(s=this.options.as);const{className:o=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Z3(a,{editor:this.editor,props:t,as:s,className:`node-${this.node.type.name} ${o}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:t,to:e}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(t<=n&&e>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(t,e,n){const r=i=>{this.renderer.updateProps(i),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const i=this.node,a=this.decorations,s=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.options.update({oldNode:i,oldDecorations:a,newNode:t,newDecorations:e,oldInnerDecorations:s,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}return t===this.node&&this.decorations===e&&this.innerDecorations===n||(this.node=t,this.decorations=e,this.innerDecorations=n,r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=ni(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function N_(t,e){return n=>n.editor.contentComponent?new Q3(t,n,e):{}}var Lg=P.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});Lg.displayName="TiptapContext";var J3=()=>P.useContext(Lg);function I_({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const i=P.useMemo(()=>({editor:r}),[r]),a=P.useMemo(()=>({editor:r}),[r]);return T.jsx(Vo.Provider,{value:a,children:T.jsx(Lg.Provider,{value:i,children:n})})}I_.displayName="Tiptap";function w_({...t}){const{editor:e}=J3();return T.jsx(Og,{editor:e,...t})}w_.displayName="Tiptap.Content";Object.assign(I_,{Content:w_});function R_(t,e,n){t.chain().focus().insertContentAt(e,[O_(n),{type:"text",text:" "}]).run()}function O_(t){return{type:"mention",attrs:t}}function eP(t){const e=te.c(7),{node:n,selected:r,view:i}=t,{name:a,char:s}=n.attrs,o=r&&i.editable,u=s==="@"?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400":"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300",c=o&&"outline-2 outline-blue-300 outline-offset-0";let d;e[0]!==u||e[1]!==c?(d=ce("px-1 py-1 rounded","inline-flex items-center gap-1","cursor-default select-none","text-xs font-light",u,c),e[0]=u,e[1]=c,e[2]=d):d=e[2];let p;return e[3]!==s||e[4]!==a||e[5]!==d?(p=T.jsxs(__,{className:d,children:[s,a]}),e[3]=s,e[4]=a,e[5]=d,e[6]=p):p=e[6],p}const L_=Tt.create({name:"mention",group:"inline",inline:!0,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id")||null,renderHTML:t=>t.id?{"data-id":t.id}:{}},name:{default:null,parseHTML:t=>t.getAttribute("data-name")||null,renderHTML:t=>t.name?{"data-name":t.name}:{}},char:{default:"/",parseHTML:t=>t.getAttribute("data-char")||"/",renderHTML:t=>t.char?{"data-char":t.char}:{}},metadata:{default:null,parseHTML:t=>{try{return JSON.parse(t.getAttribute("data-metadata")||"null")}catch{return null}},renderHTML:t=>t.metadata?{"data-metadata":JSON.stringify(t.metadata)}:{}}}},parseHTML(){return[{tag:'span[data-type="mention"]'}]},renderHTML({node:t,HTMLAttributes:e}){const n={"data-type":"mention"};return t.attrs.id&&(n["data-id"]=t.attrs.id),t.attrs.name&&(n["data-name"]=t.attrs.name),t.attrs.char&&(n["data-char"]=t.attrs.char),t.attrs.metadata&&(n["data-metadata"]=JSON.stringify(t.attrs.metadata)),["span",{...e,...n}]},renderText({node:t}){const e=t.attrs.char??"@",n=t.attrs.name??"";return`${e}${n}`},addNodeView(){return N_(eP)}});function tP(t){return!t||!t.content||t.content.length===0?!0:t.content.every(e=>e.type==="paragraph"?!e.content||e.content.length===0?!0:e.content.every(n=>n.type==="hardBreak"||n.type==="text"&&(!n.text||n.text.trim()==="")):!1)}function nP(t,e){return{type:"doc",content:[...t?.content??[],e].filter(Boolean)}}const i0=3;function rP(t){const e=te.c(23),{prompt:n,onSelect:r,isSelected:i,isDisabled:a,isLoading:s}=t,o=n.description??n.name;let l;e[0]!==r||e[1]!==n?(l=()=>r(n),e[0]=r,e[1]=n,e[2]=l):l=e[2];const u=a||s,c=i&&"bg-accent/50 text-foreground",d=s&&"bg-accent/50 text-foreground",p=(a||s)&&"cursor-not-allowed hover:bg-accent/50";let f;e[3]!==c||e[4]!==d||e[5]!==p?(f=ce("px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground border border-border rounded-full hover:bg-accent/50 transition-colors cursor-pointer flex items-center gap-1.5",c,d,p),e[3]=c,e[4]=d,e[5]=p,e[6]=f):f=e[6];const h=n.title??n.name;let g;if(e[7]!==h){let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=/_/g,e[9]=k):k=e[9],g=h.replace(k," "),e[7]=h,e[8]=g}else g=e[8];let b;e[10]!==s?(b=s&&T.jsx(xo,{size:"xs"}),e[10]=s,e[11]=b):b=e[11];let E;e[12]!==l||e[13]!==u||e[14]!==f||e[15]!==g||e[16]!==b?(E=T.jsx(vn,{asChild:!0,children:T.jsxs("button",{type:"button",onClick:l,disabled:u,className:f,children:[g,b]})}),e[12]=l,e[13]=u,e[14]=f,e[15]=g,e[16]=b,e[17]=E):E=e[17];let y;e[18]!==o?(y=T.jsx(Cn,{side:"bottom",className:"max-w-xs",children:T.jsx("p",{className:"text-xs",children:o})}),e[18]=o,e[19]=y):y=e[19];let S;return e[20]!==E||e[21]!==y?(S=T.jsxs(xn,{children:[E,y]}),e[20]=E,e[21]=y,e[22]=S):S=e[22],S}function iP(t){const e=te.c(23),{prompts:n,onSelect:r,loadingPrompt:i,className:a}=t;if(n.length===0)return null;let s,o,l,u,c;if(e[0]!==a||e[1]!==i||e[2]!==r||e[3]!==n){const f=n.slice(0,i0),h=n.slice(i0),g=h.length>0,b=!!i;s=vo,c=300,e[9]!==a?(o=ce("flex flex-wrap items-center justify-center gap-2",a),e[9]=a,e[10]=o):o=e[10];let E;e[11]!==b||e[12]!==i?.name||e[13]!==r?(E=y=>T.jsx(rP,{prompt:y,onSelect:r,isLoading:i?.name===y.name,isDisabled:b&&i?.name!==y.name},y.name),e[11]=b,e[12]=i?.name,e[13]=r,e[14]=E):E=e[14],l=f.map(E),u=g&&T.jsxs(ci,{children:[T.jsx(di,{asChild:!0,children:T.jsxs("button",{type:"button",disabled:b,className:ce("size-7 flex items-center justify-center text-xs text-muted-foreground hover:text-foreground border border-border rounded-full hover:bg-accent/50 transition-colors cursor-pointer",b&&"opacity-60 cursor-not-allowed"),children:["+",h.length]})}),T.jsx(pi,{side:"bottom",align:"center",className:"w-auto p-2",children:T.jsx("div",{className:"flex flex-col gap-1",children:h.map(y=>{const S=y.description??y.name,k=i?.name===y.name;return T.jsxs(xn,{children:[T.jsx(vn,{asChild:!0,children:T.jsxs("button",{type:"button",onClick:()=>r(y),disabled:b&&!k,className:ce("px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-accent/50 rounded-md transition-colors cursor-pointer text-left flex items-center gap-1.5",k&&"bg-accent/50 text-foreground",b&&!k&&"opacity-60 cursor-not-allowed"),children:[(y.title??y.name).replace(/_/g," "),k&&T.jsx(xo,{size:"xs"})]})}),T.jsx(Cn,{side:"right",className:"max-w-xs",children:T.jsx("p",{className:"text-xs",children:S})})]},y.name)})})})]}),e[0]=a,e[1]=i,e[2]=r,e[3]=n,e[4]=s,e[5]=o,e[6]=l,e[7]=u,e[8]=c}else s=e[4],o=e[5],l=e[6],u=e[7],c=e[8];let d;e[15]!==o||e[16]!==l||e[17]!==u?(d=T.jsxs("div",{className:o,children:[l,u]}),e[15]=o,e[16]=l,e[17]=u,e[18]=d):d=e[18];let p;return e[19]!==s||e[20]!==c||e[21]!==d?(p=T.jsx(s,{delayDuration:c,children:d}),e[19]=s,e[20]=c,e[21]=d,e[22]=p):p=e[22],p}function aP(){const t=te.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=T.jsxs(T.Fragment,{children:[T.jsx(Hb,{className:"h-6 w-20 rounded-full border border-border"}),T.jsx(Hb,{className:"h-6 w-24 rounded-full border border-border"})]}),t[0]=e):e=t[0],e}function sP(t,e){switch(e.type){case"SELECT_PROMPT":return!e.prompt.arguments||e.prompt.arguments.length===0?{stage:"loading",prompt:e.prompt}:{stage:"idle"};case"START_LOADING":return{stage:"loading",prompt:e.prompt,arguments:e.arguments};case"RESET":return{stage:"idle"};default:return t}}function oP(t){const e=te.c(28),{connectionId:n}=t,{tiptapDoc:r,sendMessage:i}=vr(),{org:a}=ui();let s;e[0]!==n||e[1]!==a.id?(s={connectionId:n,orgId:a.id},e[0]=n,e[1]=a.id,e[2]=s):s=e[2];const o=tg(s);let l;e[3]!==o?(l={client:o,staleTime:6e4},e[3]=o,e[4]=l):l=e[4];const{data:u}=bR(l);let c;e[5]!==u?.prompts?(c=u?.prompts??[],e[5]=u?.prompts,e[6]=c):c=e[6];const d=c;let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p={stage:"idle"},e[7]=p):p=e[7];const[f,h]=P.useReducer(sP,p),[g,b]=P.useState(null);let E;e[8]!==o||e[9]!==i||e[10]!==r?(E=async(M,q)=>{if(!o){Sn.error("MCP client not available"),h({type:"RESET"});return}try{const F=await nv(o,M.name,q);h({type:"RESET"});const U=nP(r,{type:"paragraph",content:[O_({id:M.name,name:M.name,metadata:F.messages,char:"/"})]});await i(U)}catch(F){console.error("[ice-breakers] Failed to fetch prompt:",F),Sn.error("Failed to load prompt. Please try again."),h({type:"RESET"})}},e[8]=o,e[9]=i,e[10]=r,e[11]=E):E=e[11];const y=E;let S;e[12]!==y?(S=async M=>{if(M.arguments&&M.arguments.length>0){h({type:"SELECT_PROMPT",prompt:M}),b(M);return}h({type:"START_LOADING",prompt:M}),await y(M)},e[12]=y,e[13]=S):S=e[13];const k=S;let x;e[14]!==g||e[15]!==y?(x=async M=>{g&&(h({type:"START_LOADING",prompt:g,arguments:M}),b(null),await y(g,M))},e[14]=g,e[15]=y,e[16]=x):x=e[16];const A=x;if(d.length===0)return null;const v=f.stage==="loading"?f.prompt:null;let w;e[17]!==k||e[18]!==d||e[19]!==v?(w=T.jsx(iP,{prompts:d,onSelect:k,loadingPrompt:v}),e[17]=k,e[18]=d,e[19]=v,e[20]=w):w=e[20];let N;e[21]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{b(null),h({type:"RESET"})},e[21]=N):N=e[21];let _;e[22]!==g||e[23]!==A?(_=T.jsx(hv,{prompt:g,setPrompt:N,onSubmit:A}),e[22]=g,e[23]=A,e[24]=_):_=e[24];let D;return e[25]!==_||e[26]!==w?(D=T.jsxs("div",{className:"relative w-full",children:[w,_]}),e[25]=_,e[26]=w,e[27]=D):D=e[27],D}function lP(t){const e=te.c(14),{className:n}=t,{selectedVirtualMcp:r}=vr(),{org:i}=ui();let a;e[0]!==i.id?(a=tv(i.id),e[0]=i.id,e[1]=a):a=e[1];const s=a.id,o=r?.id??s;let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l={minHeight:"32px"},e[2]=l):l=e[2];let u;e[3]!==n?(u=ce("flex flex-wrap items-center justify-center gap-2",n),e[3]=n,e[4]=u):u=e[4];const c=o??"default";let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=T.jsx(aP,{}),e[5]=d):d=e[5];let p;e[6]!==o?(p=T.jsx(oP,{connectionId:o}),e[6]=o,e[7]=p):p=e[7];let f;e[8]!==c||e[9]!==p?(f=T.jsx(yR,{fallback:null,children:T.jsx(P.Suspense,{fallback:d,children:p},c)}),e[8]=c,e[9]=p,e[10]=f):f=e[10];let h;return e[11]!==u||e[12]!==f?(h=T.jsx("div",{style:l,className:u,children:f}),e[11]=u,e[12]=f,e[13]=h):h=e[13],h}const a0=[{border:"border-purple-400",bg:"bg-purple-400",text:"text-white",bgLight:"bg-purple-400/10"},{border:"border-blue-400",bg:"bg-blue-400",text:"text-white",bgLight:"bg-blue-400/10"},{border:"border-indigo-400",bg:"bg-indigo-400",text:"text-white",bgLight:"bg-indigo-400/10"},{border:"border-violet-400",bg:"bg-violet-400",text:"text-white",bgLight:"bg-violet-400/10"},{border:"border-pink-400",bg:"bg-pink-400",text:"text-white",bgLight:"bg-pink-400/10"},{border:"border-fuchsia-400",bg:"bg-fuchsia-400",text:"text-white",bgLight:"bg-fuchsia-400/10"},{border:"border-emerald-400",bg:"bg-emerald-400",text:"text-white",bgLight:"bg-emerald-400/10"},{border:"border-teal-400",bg:"bg-teal-400",text:"text-white",bgLight:"bg-teal-400/10"},{border:"border-cyan-400",bg:"bg-cyan-400",text:"text-white",bgLight:"bg-cyan-400/10"},{border:"border-sky-400",bg:"bg-sky-400",text:"text-white",bgLight:"bg-sky-400/10"},{border:"border-orange-400",bg:"bg-orange-400",text:"text-white",bgLight:"bg-orange-400/10"},{border:"border-amber-400",bg:"bg-amber-400",text:"text-white",bgLight:"bg-amber-400/10"},{border:"border-rose-400",bg:"bg-rose-400",text:"text-white",bgLight:"bg-rose-400/10"},{border:"border-lime-400",bg:"bg-lime-400",text:"text-white",bgLight:"bg-lime-400/10"}];function uP(t){let e=0;for(let n=0;n<t.length;n++)e=t.charCodeAt(n)+((e<<5)-e);return Math.abs(e)}function D_(t){if(t==null)return null;const n=uP(t)%a0.length;return a0[n]}const s0=li({response:ys().min(1,"Response is required")}),cP=li({response:ys().min(1,"Please select or enter an option")}),dP=li({response:Kw(["yes","no"])});function pP(t){switch(t.type){case"text":return s0;case"choice":return cP;case"confirm":return dP;default:return s0}}function fP(t){const e={};for(const n of t)e[n.toolCallId]=pP(n.input);return li(e)}function hP(t){const e=te.c(6),{control:n,name:r,placeholder:i}=t;let a;e[0]!==i?(a=o=>{const{field:l}=o;return T.jsxs(_o,{children:[T.jsx(No,{children:T.jsx("div",{className:"px-2",children:T.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[T.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:T.jsx(ng,{size:16,className:"text-muted-foreground"})}),T.jsx("input",{...l,type:"text",placeholder:i||"Type your response...",autoFocus:!0,"aria-label":"Text response input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"})]})})}),T.jsx(Io,{})]})},e[0]=i,e[1]=a):a=e[1];let s;return e[2]!==n||e[3]!==r||e[4]!==a?(s=T.jsx(Co,{control:n,name:r,render:a}),e[2]=n,e[3]=r,e[4]=a,e[5]=s):s=e[5],s}function mP(t){const e=te.c(10),{control:n,name:r,options:i}=t,[a,s]=P.useState(!1),o=P.useRef(null),l=P.useRef(null);let u,c;if(e[0]!==i?(u=()=>{const f=h=>{const g=h.target.tagName;if(g==="INPUT"||g==="TEXTAREA")return;const b=Number.parseInt(h.key,10);b>=1&&b<=i.length&&l.current&&(h.preventDefault(),l.current.onChange(i[b-1]??""),s(!1))};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},c=[i],e[0]=i,e[1]=u,e[2]=c):(u=e[1],c=e[2]),P.useEffect(u,c),i.length===0)return null;let d;e[3]!==a||e[4]!==i?(d=f=>{const{field:h}=f;l.current=h;const g=a||!!h.value&&!i.includes(h.value);return T.jsxs(_o,{children:[T.jsx(No,{children:T.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[i.map((b,E)=>{const y=h.value===b;return T.jsxs("button",{type:"button",onClick:()=>{h.onChange(b??""),s(!1)},className:ce("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",y&&"bg-accent/50",!y&&"hover:bg-accent/30"),"aria-label":`Select ${b}`,children:[T.jsx("span",{className:ce("flex items-center justify-center size-6 rounded-md text-sm shrink-0",y?"bg-chart-1 text-white":"bg-muted text-foreground"),children:E+1}),T.jsx("span",{className:"text-sm text-foreground truncate",children:b})]},`${E}-${b}`)}),T.jsxs("div",{className:ce("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",g&&"bg-accent/50",!g&&"hover:bg-accent/30"),onClick:()=>{s(!0),i.includes(h.value)&&h.onChange(""),setTimeout(()=>o.current?.focus(),0)},children:[T.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:T.jsx(ng,{size:16,className:"text-muted-foreground"})}),g?T.jsx("input",{ref:o,type:"text",value:h.value,onChange:b=>h.onChange(b.target.value),placeholder:"Something else...",autoFocus:!0,"aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}):T.jsx("span",{className:"text-sm text-foreground/25",children:"Something else..."})]})]})}),T.jsx(Io,{})]})},e[3]=a,e[4]=i,e[5]=d):d=e[5];let p;return e[6]!==n||e[7]!==r||e[8]!==d?(p=T.jsx(Co,{control:n,name:r,render:d}),e[6]=n,e[7]=r,e[8]=d,e[9]=p):p=e[9],p}function gP(t){const e=te.c(7),{control:n,name:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=["yes","no"],e[0]=i):i=e[0];const a=i,s=P.useRef(null);let o,l;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{const d=p=>{const f=p.target.tagName;f==="INPUT"||f==="TEXTAREA"||(p.key==="1"&&s.current?(p.preventDefault(),s.current.onChange("yes")):p.key==="2"&&s.current&&(p.preventDefault(),s.current.onChange("no")))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},l=[],e[1]=o,e[2]=l):(o=e[1],l=e[2]),P.useEffect(o,l);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=d=>{const{field:p}=d;return s.current=p,T.jsxs(_o,{children:[T.jsx(No,{children:T.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:a.map(f=>{const h=p.value===f;return T.jsxs("button",{type:"button",onClick:()=>p.onChange(f),className:ce("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",h&&"bg-accent/50",!h&&"hover:bg-accent/30"),"aria-label":`Confirm ${f}`,children:[T.jsx("span",{className:ce("flex items-center justify-center size-6 rounded-md text-sm shrink-0",h?"bg-chart-1 text-white":"bg-muted text-foreground"),children:f==="yes"?1:2}),T.jsx("span",{className:"text-sm text-foreground capitalize",children:f})]},f)})})}),T.jsx(Io,{})]})},e[3]=u):u=e[3];let c;return e[4]!==n||e[5]!==r?(c=T.jsx(Co,{control:n,name:r,render:u}),e[4]=n,e[5]=r,e[6]=c):c=e[6],c}function o0(t){const e=te.c(13),{input:n,control:r,name:i}=t;switch(n.type){case"text":{let a;return e[0]!==r||e[1]!==n.default||e[2]!==i?(a=T.jsx(hP,{control:r,name:i,placeholder:n.default}),e[0]=r,e[1]=n.default,e[2]=i,e[3]=a):a=e[3],a}case"choice":{let a;e[4]!==n.options?(a=n.options?.filter(Boolean)??[],e[4]=n.options,e[5]=a):a=e[5];const s=a;let o;return e[6]!==r||e[7]!==i||e[8]!==s?(o=T.jsx(mP,{control:r,name:i,options:s}),e[6]=r,e[7]=i,e[8]=s,e[9]=o):o=e[9],o}case"confirm":{let a;return e[10]!==r||e[11]!==i?(a=T.jsx(gP,{control:r,name:i}),e[10]=r,e[11]=i,e[12]=a):a=e[12],a}default:return null}}function bP(t){const e=te.c(21),{current:n,total:r,onPrev:i,onNext:a}=t;if(r<=1)return null;const s=n===0,o=n===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let l;e[0]!==o?(l=ce("p-0.5 rounded transition-colors",o),e[0]=o,e[1]=l):l=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=T.jsx(RR,{size:14}),e[2]=u):u=e[2];let c;e[3]!==i||e[4]!==s||e[5]!==l?(c=T.jsx("button",{type:"button",onClick:i,disabled:s,className:l,"aria-label":"Previous question",children:u}),e[3]=i,e[4]=s,e[5]=l,e[6]=c):c=e[6];const d=n+1;let p;e[7]!==d||e[8]!==r?(p=T.jsxs("span",{className:"tabular-nums text-xs",children:[d," of ",r]}),e[7]=d,e[8]=r,e[9]=p):p=e[9];const f=n===r-1,h=n===r-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==h?(g=ce("p-0.5 rounded transition-colors",h),e[10]=h,e[11]=g):g=e[11];let b;e[12]===Symbol.for("react.memo_cache_sentinel")?(b=T.jsx(sv,{size:14}),e[12]=b):b=e[12];let E;e[13]!==a||e[14]!==g||e[15]!==f?(E=T.jsx("button",{type:"button",onClick:a,disabled:f,className:g,"aria-label":"Next question",children:b}),e[13]=a,e[14]=g,e[15]=f,e[16]=E):E=e[16];let y;return e[17]!==E||e[18]!==c||e[19]!==p?(y=T.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[c,p,E]}),e[17]=E,e[18]=c,e[19]=p,e[20]=y):y=e[20],y}function l0(t){const e=te.c(15),{title:n,children:r,footerLeft:i,footerRight:a}=t;let s;e[0]!==n?(s=T.jsx("div",{className:"flex items-center gap-2 p-4",children:T.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:n})}),e[0]=n,e[1]=s):s=e[1];let o;e[2]!==r?(o=T.jsx("div",{className:"overflow-clip pb-4",children:r}),e[2]=r,e[3]=o):o=e[3];let l;e[4]!==i?(l=T.jsx("div",{children:i}),e[4]=i,e[5]=l):l=e[5];let u;e[6]!==a?(u=T.jsx("div",{className:"flex items-center gap-2",children:a}),e[6]=a,e[7]=u):u=e[7];let c;e[8]!==l||e[9]!==u?(c=T.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:T.jsxs("div",{className:"flex items-center justify-between",children:[l,u]})}),e[8]=l,e[9]=u,e[10]=c):c=e[10];let d;return e[11]!==s||e[12]!==o||e[13]!==c?(d=T.jsxs("div",{className:"flex flex-col rounded-xl bg-background border border-border shadow-md w-[calc(100%-16px)] max-w-[584px] mx-auto mb-[-16px]",children:[s,o,c]}),e[11]=s,e[12]=o,e[13]=c,e[14]=d):d=e[14],d}function EP({parts:t,onSubmit:e}){const[n,r]=P.useState(t[0]?.toolCallId??""),i=fP(t.map(y=>({toolCallId:y.toolCallId,input:y.input}))),a=jx({resolver:qx(i),defaultValues:Object.fromEntries(t.map(y=>[y.toolCallId,{response:""}]))}),s=a.watch(),o=t.findIndex(y=>y.toolCallId===n),l=!!s[n]?.response,u=t.every(y=>!!s[y.toolCallId]?.response),c=y=>{for(const S of t){const k=y[S.toolCallId]?.response;k&&e(S,k)}},d=y=>t.find(S=>!y[S.toolCallId]?.response&&S.toolCallId!==n)??null,p=()=>{const y=a.getValues();if(t.every(k=>!!y[k.toolCallId]?.response))a.handleSubmit(c)();else{const k=d(y);k&&r(k.toolCallId)}},f=()=>{a.setValue(`${n}.response`,"user has skip this question"),p()},h=()=>{if(o>0){const y=t[o-1];y&&r(y.toolCallId)}},g=()=>{if(o<t.length-1){const y=t[o+1];y&&r(y.toolCallId)}},b=T.jsxs(T.Fragment,{children:[T.jsx(ze,{type:"button",variant:"outline",size:"sm",onClick:f,className:"h-7",children:"Skip"}),T.jsx(ze,{type:"button",size:"sm",disabled:!l,onClick:p,className:ce("h-7",l?"":"opacity-50"),children:u?"Submit":"Next"})]}),E=T.jsx(bP,{current:o,total:t.length,onPrev:h,onNext:g});if(t.length===1){const y=t[0];return y?.input?T.jsx(Kh,{...a,children:T.jsx("form",{onSubmit:a.handleSubmit(c),autoComplete:"off",children:T.jsx(l0,{title:y.input?.prompt??"Question",footerRight:b,children:T.jsx(o0,{input:y.input,control:a.control,name:`${y.toolCallId}.response`})})})}):null}return T.jsx(Kh,{...a,children:T.jsx("form",{onSubmit:a.handleSubmit(c),autoComplete:"off",children:T.jsx(uR,{value:n,onValueChange:r,children:t.map(y=>T.jsx(cR,{value:y.toolCallId,className:"mt-0",children:T.jsx(l0,{title:y.input?.prompt??"Question",footerLeft:E,footerRight:b,children:T.jsx(o0,{input:y.input,control:a.control,name:`${y.toolCallId}.response`})})},y.toolCallId))})})})}function yP(){const t=te.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=T.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[T.jsx(rg,{className:"size-5 text-muted-foreground shimmer"}),T.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function M_(t){const e=te.c(6),{userAskParts:n,isStreaming:r,onSubmit:i}=t;let a;e[0]!==n?(a=n.filter(TP),e[0]=n,e[1]=a):a=e[1];const s=a;if(r){let l;return e[2]===Symbol.for("react.memo_cache_sentinel")?(l=T.jsx(yP,{}),e[2]=l):l=e[2],l}if(s.length===0)return null;let o;return e[3]!==i||e[4]!==s?(o=T.jsx(EP,{parts:s,onSubmit:i}),e[3]=i,e[4]=s,e[5]=o):o=e[5],o}function TP(t){return t.state==="input-available"}const SP={length:"Response reached the model's output limit. Different models have different limits. Try switching models or asking it to continue.","content-filter":"Response was filtered due to content policy.","tool-calls":"Response paused after tool execution to prevent infinite loops and save costs. Click continue to keep working."};function Ms(t){const e=te.c(32),{variant:n,onDismiss:r}=t,i=n==="error",a=i?"Error occurred":"Response incomplete",s=i?t.error.message:SP[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`,o=i?"border-destructive/30 bg-destructive/5":"border-amber-500/30 bg-amber-500/5",l=i?"text-destructive":"text-amber-600 dark:text-amber-500",u=i?IR:TR;let c;e[0]!==o?(c=ce("flex items-start gap-2 px-3 py-2.5 rounded-lg border border-dashed text-sm w-full mb-2 shadow",o),e[0]=o,e[1]=c):c=e[1];let d;e[2]!==l?(d=ce("mt-0.5 shrink-0",l),e[2]=l,e[3]=d):d=e[3];let p;e[4]!==u?(p=T.jsx(u,{size:16}),e[4]=u,e[5]=p):p=e[5];let f;e[6]!==d||e[7]!==p?(f=T.jsx("div",{className:d,children:p}),e[6]=d,e[7]=p,e[8]=f):f=e[8];let h;e[9]!==l?(h=ce("text-xs mb-1 font-medium",l),e[9]=l,e[10]=h):h=e[10];let g;e[11]!==h||e[12]!==a?(g=T.jsx("div",{className:h,children:a}),e[11]=h,e[12]=a,e[13]=g):g=e[13];let b;e[14]!==s?(b=T.jsx("div",{className:"text-xs line-clamp-2 text-muted-foreground mb-2",children:s}),e[14]=s,e[15]=b):b=e[15];let E;e[16]!==i||e[17]!==t.onContinue||e[18]!==t.onFixInChat?(E=T.jsx("div",{className:"flex gap-2",children:i?T.jsxs(T.Fragment,{children:[T.jsx(ze,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}),T.jsx(ze,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}):T.jsx(ze,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"})}),e[16]=i,e[17]=t.onContinue,e[18]=t.onFixInChat,e[19]=E):E=e[19];let y;e[20]!==g||e[21]!==b||e[22]!==E?(y=T.jsxs("div",{className:"flex-1 min-w-0",children:[g,b,E]}),e[20]=g,e[21]=b,e[22]=E,e[23]=y):y=e[23];let S;e[24]===Symbol.for("react.memo_cache_sentinel")?(S=T.jsx(wR,{size:14}),e[24]=S):S=e[24];let k;e[25]!==r?(k=T.jsx("button",{type:"button",onClick:r,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0",title:"Dismiss",children:S}),e[25]=r,e[26]=k):k=e[26];let x;return e[27]!==c||e[28]!==k||e[29]!==f||e[30]!==y?(x=T.jsx("div",{className:"px-0.5",children:T.jsxs("div",{className:c,children:[f,y,k]})}),e[27]=c,e[28]=k,e[29]=f,e[30]=y,e[31]=x):x=e[31],x}function Wo(){const t=te.c(22),{error:e,clearError:n,finishReason:r,clearFinishReason:i,messages:a,isStreaming:s,addToolOutput:o,sendMessage:l}=vr();let u,c;if(t[0]!==a){const y=a.at(-1);c=y?.role==="assistant"?y.parts.filter(kP):null,u=c?.filter(AP)?.length,t[0]=a,t[1]=u,t[2]=c}else u=t[1],c=t[2];const d=u;let p;t[3]!==e||t[4]!==l?(p=()=>{if(e){const S={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};l(S)}},t[3]=e,t[4]=l,t[5]=p):p=t[5];const f=p;let h;t[6]!==l?(h=()=>{l({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[6]=l,t[7]=h):h=t[7];const g=h;let b;t[8]!==o?(b=(y,S)=>{o({tool:"user_ask",toolCallId:y.toolCallId,output:{response:S}})},t[8]=o,t[9]=b):b=t[9];const E=b;if(d){let y;return t[10]!==E||t[11]!==s||t[12]!==c?(y=T.jsx("div",{className:"absolute bottom-full left-0 right-0",children:T.jsx(M_,{userAskParts:c,isStreaming:s,onSubmit:E})}),t[10]=E,t[11]=s,t[12]=c,t[13]=y):y=t[13],y}if(!s&&e){let y;return t[14]!==n||t[15]!==e||t[16]!==f?(y=T.jsx(Ms,{variant:"error",error:e,onDismiss:n,onFixInChat:f}),t[14]=n,t[15]=e,t[16]=f,t[17]=y):y=t[17],y}if(!s&&r&&r!=="stop"){let y;return t[18]!==i||t[19]!==r||t[20]!==g?(y=T.jsx(Ms,{variant:"warning",finishReason:r,onDismiss:i,onContinue:g}),t[18]=i,t[19]=r,t[20]=g,t[21]=y):y=t[21],y}return null}function AP(t){return t.state!=="output-available"}function kP(t){return t.type==="tool-user_ask"}Wo.Error=function(e){return T.jsx(Ms,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};Wo.Warning=function(e){return T.jsx(Ms,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};Wo.UserAskQuestion=M_;const Ps={passthrough:{label:"Direct access",description:"Best for small teams or when you need predictable behavior",icon:pR},smart_tool_selection:{label:"Smart discovery",description:"Ideal for large teams with many tools - AI finds what it needs",icon:dR},code_execution:{label:"Smart execution",description:"Maximum flexibility - AI can write code to orchestrate tools",icon:LR,recommended:!0}};function xP(t){const e=te.c(24),{mode:n,isSelected:r,onSelect:i}=t,a=Ps[n],s=a.icon,o=r&&"bg-accent";let l;e[0]!==o?(l=ce("flex items-start gap-3 py-3 px-3 hover:bg-accent cursor-pointer rounded-lg transition-colors",o),e[0]=o,e[1]=l):l=e[1];let u;e[2]!==s?(u=T.jsx("div",{className:"p-1.5 shrink-0 rounded-md bg-muted",children:T.jsx(s,{className:"size-4 text-muted-foreground"})}),e[2]=s,e[3]=u):u=e[3];let c;e[4]!==a.label?(c=T.jsx("span",{className:"text-sm font-medium text-foreground",children:a.label}),e[4]=a.label,e[5]=c):c=e[5];let d;e[6]!==a.recommended?(d=a.recommended&&T.jsx(OR,{variant:"outline",className:"text-xs",children:"Recommended"}),e[6]=a.recommended,e[7]=d):d=e[7];let p;e[8]!==r?(p=r&&T.jsx(fi,{size:16,className:"text-foreground shrink-0 ml-auto"}),e[8]=r,e[9]=p):p=e[9];let f;e[10]!==c||e[11]!==d||e[12]!==p?(f=T.jsxs("div",{className:"flex items-center gap-2",children:[c,d,p]}),e[10]=c,e[11]=d,e[12]=p,e[13]=f):f=e[13];let h;e[14]!==a.description?(h=T.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 leading-relaxed",children:a.description}),e[14]=a.description,e[15]=h):h=e[15];let g;e[16]!==f||e[17]!==h?(g=T.jsxs("div",{className:"flex flex-col flex-1 min-w-0 gap-0.5",children:[f,h]}),e[16]=f,e[17]=h,e[18]=g):g=e[18];let b;return e[19]!==i||e[20]!==l||e[21]!==u||e[22]!==g?(b=T.jsxs("div",{onClick:i,className:l,children:[u,g]}),e[19]=i,e[20]=l,e[21]=u,e[22]=g,e[23]=b):b=e[23],b}function vP(t){const e=te.c(13),{mode:n,placeholder:r}=t,i=r===void 0?"Select mode":r;if(!n){let d;e[0]!==i?(d=T.jsx("span",{className:"text-sm text-muted-foreground",children:i}),e[0]=i,e[1]=d):d=e[1];let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=T.jsx(Xh,{size:14,className:"text-muted-foreground opacity-50 shrink-0"}),e[2]=p):p=e[2];let f;return e[3]!==d?(f=T.jsxs("div",{className:"flex items-center gap-1.5",children:[d,p]}),e[3]=d,e[4]=f):f=e[4],f}const a=Ps[n],s=a.icon;let o;e[5]!==s?(o=T.jsx(s,{className:"size-4 text-muted-foreground shrink-0"}),e[5]=s,e[6]=o):o=e[6];let l;e[7]!==a.label?(l=T.jsx("span",{className:"text-sm text-muted-foreground group-hover:text-foreground group-data-[state=open]:text-foreground truncate whitespace-nowrap max-w-0 opacity-0 group-hover:max-w-[150px] group-hover:opacity-100 group-data-[state=open]:max-w-[150px] group-data-[state=open]:opacity-100 transition-all duration-200 ease-in-out overflow-hidden",children:a.label}),e[7]=a.label,e[8]=l):l=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=T.jsx(Xh,{size:14,className:"text-muted-foreground opacity-0 max-w-0 group-hover:opacity-50 group-hover:max-w-[14px] group-data-[state=open]:opacity-50 group-data-[state=open]:max-w-[14px] shrink-0 transition-all duration-200 ease-in-out overflow-hidden"}),e[9]=u):u=e[9];let c;return e[10]!==o||e[11]!==l?(c=T.jsxs("div",{className:"flex items-center gap-0 group-hover:gap-2 group-data-[state=open]:gap-2 min-w-0 overflow-hidden transition-all duration-200",children:[o,l,u]}),e[10]=o,e[11]=l,e[12]=c):c=e[12],c}function CP(t){const e=te.c(28),{selectedMode:n,onModeChange:r,variant:i,className:a,placeholder:s,disabled:o}=t,l=i===void 0?"borderless":i,u=s===void 0?"Mode":s,c=o===void 0?!1:o,[d,p]=P.useState(!1);let f;e[0]!==r?(f=q=>{r(q),p(!1)},e[0]=r,e[1]=f):f=e[1];const h=f,g=c?!1:d,b=l==="borderless"?"ghost":"outline",E=l==="borderless"&&"md:border-none",y=c&&"cursor-not-allowed opacity-50";let S;e[2]!==a||e[3]!==E||e[4]!==y?(S=ce("text-sm hover:bg-accent rounded-lg py-0.5 px-1 gap-1 shadow-none cursor-pointer border-0 group focus-visible:ring-0 focus-visible:ring-offset-0 min-w-0 shrink justify-start overflow-hidden",E,y,a),e[2]=a,e[3]=E,e[4]=y,e[5]=S):S=e[5];const k=d?"open":"closed";let x;e[6]!==u||e[7]!==n?(x=T.jsx(vP,{mode:n,placeholder:u}),e[6]=u,e[7]=n,e[8]=x):x=e[8];let A;e[9]!==c||e[10]!==k||e[11]!==x||e[12]!==b||e[13]!==S?(A=T.jsx(vn,{asChild:!0,children:T.jsx(di,{asChild:!0,children:T.jsx(ze,{variant:b,size:"sm",className:S,disabled:c,"data-state":k,children:x})})}),e[9]=c,e[10]=k,e[11]=x,e[12]=b,e[13]=S,e[14]=A):A=e[14];const v=Ps[n]?.description??"Choose agent mode";let w;e[15]!==v?(w=T.jsx(Cn,{side:"top",className:"text-xs",children:v}),e[15]=v,e[16]=w):w=e[16];let N;e[17]!==A||e[18]!==w?(N=T.jsx(vo,{children:T.jsxs(xn,{children:[A,w]})}),e[17]=A,e[18]=w,e[19]=N):N=e[19];let _;e[20]===Symbol.for("react.memo_cache_sentinel")?(_=Object.keys(Ps),e[20]=_):_=e[20];let D;e[21]!==h||e[22]!==n?(D=T.jsx(pi,{className:"w-[350px] p-0 overflow-hidden",align:"start",side:"top",sideOffset:8,children:T.jsx("div",{className:"flex flex-col p-1",children:_.map(q=>T.jsx(xP,{mode:q,isSelected:q===n,onSelect:()=>h(q)},q))})}),e[21]=h,e[22]=n,e[23]=D):D=e[23];let M;return e[24]!==N||e[25]!==D||e[26]!==g?(M=T.jsxs(ci,{open:g,onOpenChange:p,children:[N,D]}),e[24]=N,e[25]=D,e[26]=g,e[27]=M):M=e[27],M}function _P(t){const e=te.c(24),{virtualMcp:n,isSelected:r}=t,i=r&&"bg-accent";let a;e[0]!==i?(a=ce("flex items-start gap-3 py-3 px-3 hover:bg-accent cursor-pointer rounded-xl transition-colors",i),e[0]=i,e[1]=a):a=e[1];let s;e[2]!==n.fallbackIcon?(s=n.fallbackIcon??T.jsx(Xr,{}),e[2]=n.fallbackIcon,e[3]=s):s=e[3];let o;e[4]!==s||e[5]!==n.icon||e[6]!==n.title?(o=T.jsx(wo,{icon:n.icon,name:n.title,size:"sm",fallbackIcon:s,className:"rounded-xl border border-border shadow-sm shrink-0 aspect-square"}),e[4]=s,e[5]=n.icon,e[6]=n.title,e[7]=o):o=e[7];let l;e[8]!==n.title?(l=T.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:n.title}),e[8]=n.title,e[9]=l):l=e[9];let u;e[10]!==r?(u=r&&T.jsx(fi,{size:16,className:"text-foreground shrink-0"}),e[10]=r,e[11]=u):u=e[11];let c;e[12]!==l||e[13]!==u?(c=T.jsxs("div",{className:"flex items-center justify-between",children:[l,u]}),e[12]=l,e[13]=u,e[14]=c):c=e[14];let d;e[15]!==n.description?(d=n.description&&T.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1 leading-relaxed",children:n.description}),e[15]=n.description,e[16]=d):d=e[16];let p;e[17]!==c||e[18]!==d?(p=T.jsxs("div",{className:"flex flex-col flex-1 min-w-0 gap-0.5",children:[c,d]}),e[17]=c,e[18]=d,e[19]=p):p=e[19];let f;return e[20]!==a||e[21]!==o||e[22]!==p?(f=T.jsxs("div",{className:a,children:[o,p]}),e[20]=a,e[21]=o,e[22]=p,e[23]=f):f=e[23],f}function Dg(t){const e=te.c(33),{virtualMcps:n,selectedVirtualMcpId:r,onVirtualMcpChange:i,searchInputRef:a}=t,[s,o]=P.useState(""),l=P.useRef(null),u=a??l;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={navigateOnCreate:!0},e[0]=c):c=e[0];const{createVirtualMCP:d,isCreating:p}=MR(c);let f,h,g,b;if(e[1]!==d||e[2]!==u||e[3]!==p||e[4]!==i||e[5]!==s||e[6]!==r||e[7]!==n){let S;e:{const M=n.filter(NP);if(!s.trim()){S=M;break e}const q=s.toLowerCase();S=M.filter(F=>F.title.toLowerCase().includes(q)||F.description?.toLowerCase().includes(q))}const k=S;let x;e[12]!==i?(x=M=>{i(M),o("")},e[12]=i,e[13]=x):x=e[13];const A=x;g="flex flex-col max-h-[400px]";let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=T.jsx(iv,{size:16,className:"text-muted-foreground pointer-events-none shrink-0"}),e[14]=v):v=e[14];let w;e[15]===Symbol.for("react.memo_cache_sentinel")?(w=M=>o(M.target.value),e[15]=w):w=e[15];let N;e[16]!==u||e[17]!==s?(N=T.jsx(rv,{ref:u,type:"text",placeholder:"Search for an agent...",value:s,onChange:w,className:"flex-1 h-8 text-sm border-0 focus-visible:ring-0 focus-visible:ring-offset-0 shadow-none p-0"}),e[16]=u,e[17]=s,e[18]=N):N=e[18];const _=p?"Creating...":"Create Agent";let D;e[19]!==d||e[20]!==p||e[21]!==_?(D=T.jsx(ze,{onClick:d,variant:"outline",size:"sm",className:"h-8 px-3 rounded-lg text-sm font-medium shrink-0",disabled:p,children:_}),e[19]=d,e[20]=p,e[21]=_,e[22]=D):D=e[22],e[23]!==N||e[24]!==D?(b=T.jsx("div",{className:"border-b px-4 py-3 bg-background/95 backdrop-blur sticky top-0 z-10",children:T.jsxs("div",{className:"relative flex items-center gap-2",children:[v,N,D]})}),e[23]=N,e[24]=D,e[25]=b):b=e[25],f="overflow-y-auto p-1.5",h=k.length>0?T.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:k.map(M=>T.jsx("div",{role:"button",tabIndex:0,onClick:()=>A(M.id),onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),A(M.id))},className:"outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 rounded-xl",children:T.jsx(_P,{virtualMcp:M,isSelected:M.id===r})},M.id))}):T.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No agents found"}),e[1]=d,e[2]=u,e[3]=p,e[4]=i,e[5]=s,e[6]=r,e[7]=n,e[8]=f,e[9]=h,e[10]=g,e[11]=b}else f=e[8],h=e[9],g=e[10],b=e[11];let E;e[26]!==f||e[27]!==h?(E=T.jsx("div",{className:f,children:h}),e[26]=f,e[27]=h,e[28]=E):E=e[28];let y;return e[29]!==g||e[30]!==b||e[31]!==E?(y=T.jsxs("div",{className:g,children:[b,E]}),e[29]=g,e[30]=b,e[31]=E,e[32]=y):y=e[32],y}function NP(t){return!t.id||!Kr(t.id)}function IP(t){const e=te.c(37),{selectedVirtualMcpId:n,onVirtualMcpChange:r,virtualMcps:i,className:a,placeholder:s,showTooltip:o,disabled:l}=t,u=s===void 0?"Select Agent":s,c=o===void 0?!0:o,d=l===void 0?!1:l,[p,f]=P.useState(!1),h=P.useRef(null),g=DR(),b=i??g;let E;e[0]!==b?(E=b.filter(wP),e[0]=b,e[1]=E):E=e[1];const y=E;let S;e[2]!==b||e[3]!==n?(S=n?b.find(Z=>Z.id===n):null,e[2]=b,e[3]=n,e[4]=S):S=e[4];const k=S;let x;e[5]!==r?(x=Z=>{r(Z),f(!1)},e[5]=r,e[6]=x):x=e[6];const A=x;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=Z=>{f(Z)},e[7]=v):v=e[7];const w=v;let N,_;e[8]!==p?(N=()=>{p&&setTimeout(()=>{h.current?.focus()},0)},_=[p],e[8]=p,e[9]=N,e[10]=_):(N=e[9],_=e[10]),P.useEffect(N,_);const D=d?!1:p,M=d?void 0:w,q=d?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-accent";let F;e[11]!==a||e[12]!==q?(F=ce("flex items-center justify-center size-8 rounded-full transition-colors shrink-0",q,a),e[11]=a,e[12]=q,e[13]=F):F=e[13];let U;e[14]!==k?(U=k?T.jsx(wo,{icon:k.icon,name:k.title,size:"xs",fallbackIcon:T.jsx(Xr,{size:16}),className:"rounded-md shrink-0 aspect-square"}):T.jsx(Xr,{size:16}),e[14]=k,e[15]=U):U=e[15];let $;e[16]!==d||e[17]!==u||e[18]!==F||e[19]!==U?($=T.jsx(vn,{asChild:!0,children:T.jsx(di,{asChild:!0,children:T.jsx("button",{type:"button",disabled:d,className:F,"aria-label":u,children:U})})}),e[16]=d,e[17]=u,e[18]=F,e[19]=U,e[20]=$):$=e[20];let G;e[21]!==p||e[22]!==k?.title||e[23]!==c?(G=c&&!p&&T.jsx(Cn,{side:"top",className:"text-xs",children:k?.title??"Choose an agent to chat with"}),e[21]=p,e[22]=k?.title,e[23]=c,e[24]=G):G=e[24];let H;e[25]!==$||e[26]!==G?(H=T.jsx(vo,{children:T.jsxs(xn,{children:[$,G]})}),e[25]=$,e[26]=G,e[27]=H):H=e[27];let J;e[28]!==A||e[29]!==n||e[30]!==y?(J=T.jsx(pi,{className:"w-[550px] p-0 overflow-hidden",align:"start",side:"top",sideOffset:8,children:T.jsx(Dg,{virtualMcps:y,selectedVirtualMcpId:n,onVirtualMcpChange:A,searchInputRef:h})}),e[28]=A,e[29]=n,e[30]=y,e[31]=J):J=e[31];let I;return e[32]!==D||e[33]!==M||e[34]!==H||e[35]!==J?(I=T.jsxs(ci,{open:D,onOpenChange:M,children:[H,J]}),e[32]=D,e[33]=M,e[34]=H,e[35]=J,e[36]=I):I=e[36],I}function wP(t){return!t.id||!Kr(t.id)}function RP(t,e,n){t.chain().focus().insertContentAt(e,[OP(n),{type:"text",text:" "}]).run()}function OP(t){return{type:"file",attrs:t}}function LP(t){const e=te.c(17),{node:n,selected:r,view:i}=t,{name:a,mimeType:s,data:o}=n.attrs,l=r&&i.editable;let u;e[0]!==s?(u=s.startsWith("image/"),e[0]=s,e[1]=u):u=e[1];const c=u,d=l&&"outline-2 outline-blue-300 outline-offset-0";let p;e[2]!==d?(p=ce("px-1 py-1 rounded","inline-flex items-center gap-1","cursor-default select-none","text-xs font-light","bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300",d),e[2]=d,e[3]=p):p=e[3];let f;e[4]!==a?(f=T.jsx(vn,{asChild:!0,children:T.jsx("span",{children:a})}),e[4]=a,e[5]=f):f=e[5];let h;e[6]!==o||e[7]!==c||e[8]!==s||e[9]!==a?(h=T.jsx(Cn,{side:"top",className:"max-w-sm",children:c?T.jsx("img",{src:`data:${s};base64,${o}`,alt:a,className:"max-w-full max-h-64 object-contain rounded"}):T.jsxs("div",{className:"text-xs",children:[T.jsx("div",{className:"font-medium",children:a}),T.jsx("div",{className:"text-muted-foreground mt-1",children:s})]})}),e[6]=o,e[7]=c,e[8]=s,e[9]=a,e[10]=h):h=e[10];let g;e[11]!==f||e[12]!==h?(g=T.jsxs(xn,{children:[f,h]}),e[11]=f,e[12]=h,e[13]=g):g=e[13];let b;return e[14]!==p||e[15]!==g?(b=T.jsx(__,{className:p,children:g}),e[14]=p,e[15]=g,e[16]=b):b=e[16],b}const P_=Tt.create({name:"file",group:"inline",inline:!0,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id")||null,renderHTML:t=>t.id?{"data-id":t.id}:{}},name:{default:null,parseHTML:t=>t.getAttribute("data-name")||null,renderHTML:t=>t.name?{"data-name":t.name}:{}},mimeType:{default:null,parseHTML:t=>t.getAttribute("data-mime-type")||null,renderHTML:t=>t.mimeType?{"data-mime-type":t.mimeType}:{}},size:{default:0,parseHTML:t=>{const e=t.getAttribute("data-size");return e?Number.parseInt(e,10):0},renderHTML:t=>t.size?{"data-size":String(t.size)}:{}},data:{default:null,parseHTML:t=>t.getAttribute("data-data")||null,renderHTML:t=>t.data?{"data-data":t.data}:{}}}},parseHTML(){return[{tag:'span[data-type="file"]'}]},renderHTML({node:t,HTMLAttributes:e}){const n={"data-type":"file"};return t.attrs.id&&(n["data-id"]=t.attrs.id),t.attrs.name&&(n["data-name"]=t.attrs.name),t.attrs.mimeType&&(n["data-mime-type"]=t.attrs.mimeType),t.attrs.size&&(n["data-size"]=String(t.attrs.size)),t.attrs.data&&(n["data-data"]=t.attrs.data),["span",{...e,...n}]},renderText({node:t}){return`[${t.attrs.name??""}]`},addNodeView(){return N_(LP)}});async function F_(t,e,n,r){if(!Xx(e)){Sn.error("Selected model does not support file uploads");return}const i=10*1024*1024;if(n.size>i){Sn.error(`File "${n.name}" exceeds 10MB limit`);return}try{const a=new FileReader,s=new Promise((u,c)=>{a.onload=()=>{const d=a.result;if(typeof d!="string"){c(new Error("Failed to read file as data URL"));return}const p=d.includes(",")?d.split(",")[1]??d:d;u(p)},a.onerror=c});a.readAsDataURL(n);const o=await s,l={id:crypto.randomUUID(),name:n.name,mimeType:n.type||"application/octet-stream",size:n.size,data:o};RP(t,{from:r,to:r},l)}catch(a){console.error("Failed to process file:",a),Sn.error(`Failed to load file "${n.name}"`)}}function DP(t){const e=te.c(7),{editor:n,selectedModel:r}=t,i=P.useRef(MP);let a,s;e[0]!==n||e[1]!==r?(a=()=>{i.current=async(u,c)=>{await F_(n,r,u,c)}},s=[n,r],e[0]=n,e[1]=r,e[2]=a,e[3]=s):(a=e[2],s=e[3]),P.useEffect(a,s);let o,l;return e[4]!==n?(o=()=>{if(n?.isDestroyed)return;const u=new De("fileDropHandler");n.state.plugins.find(p=>p.spec.key===u)&&n.unregisterPlugin(u);const d=new Ie({key:u,props:{handleDrop:(p,f,h,g)=>{if(g)return!1;const b=f.dataTransfer?.files;if(!b||b.length===0)return!1;f.preventDefault();const E=p.posAtCoords({left:f.clientX,top:f.clientY});if(!E)return!1;const y=Array.from(b),S=E.pos;for(const k of y)i.current?.(k,S);return!0}}});return n.registerPlugin(d),()=>{n?.isDestroyed||n.unregisterPlugin(u)}},l=[n],e[4]=n,e[5]=o,e[6]=l):(o=e[5],l=e[6]),P.useEffect(o,l),null}function MP(){return Promise.resolve()}function PP(t){const e=te.c(20),{selectedModel:n,isStreaming:r}=t,{editor:i}=v_(),a=P.useRef(null);let s;e[0]!==n?(s=Xx(n),e[0]=n,e[1]=s):s=e[1];const o=s;let l;e[2]!==i||e[3]!==n?(l=async k=>{const x=k.target.files;if(!x||x.length===0||!i)return;const A=Array.from(x),{from:v}=i.state.selection,w=v;for(const N of A)await F_(i,n,N,w);a.current&&(a.current.value="")},e[2]=i,e[3]=n,e[4]=l):l=e[4];const u=l;if(!i)return null;const c=r||!o;let d;e[5]!==u||e[6]!==c?(d=T.jsx("input",{ref:a,type:"file",multiple:!0,className:"hidden",onChange:u,disabled:c}),e[5]=u,e[6]=c,e[7]=d):d=e[7];const p=r||!o;let f,h;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=()=>a.current?.click(),h=T.jsx(lv,{size:16}),e[8]=f,e[9]=h):(f=e[8],h=e[9]);let g;e[10]!==p?(g=T.jsx(vn,{asChild:!0,children:T.jsx(ze,{type:"button",variant:"ghost",size:"icon",className:"size-8 rounded-full",disabled:p,onClick:f,children:h})}),e[10]=p,e[11]=g):g=e[11];const b=o?"Add file":"Selected model does not support files";let E;e[12]!==b?(E=T.jsx(Cn,{side:"top",children:b}),e[12]=b,e[13]=E):E=e[13];let y;e[14]!==E||e[15]!==g?(y=T.jsxs(xn,{children:[g,E]}),e[14]=E,e[15]=g,e[16]=y):y=e[16];let S;return e[17]!==y||e[18]!==d?(S=T.jsxs(T.Fragment,{children:[d,y]}),e[17]=y,e[18]=d,e[19]=S):S=e[19],S}function FP(t={}){return new Ie({view(e){return new BP(e,t)}})}class BP{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let a=s=>{this[i](s)};return e.dom.addEventListener(i,a),{name:i,handler:a}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,a=i.getBoundingClientRect(),s=a.width/i.offsetWidth,o=a.height/i.offsetHeight;if(n){let d=e.nodeBefore,p=e.nodeAfter;if(d||p){let f=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(f){let h=f.getBoundingClientRect(),g=d?h.bottom:h.top;d&&p&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let b=this.width/2*o;r={left:h.left,right:h.right,top:g-b,bottom:g+b}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*s;r={left:d.left-p,right:d.left+p,top:d.top,bottom:d.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,c;if(!l||l==document.body&&getComputedStyle(l).position=="static")u=-pageXOffset,c=-pageYOffset;else{let d=l.getBoundingClientRect(),p=d.width/l.offsetWidth,f=d.height/l.offsetHeight;u=d.left-l.scrollLeft*p,c=d.top-l.scrollTop*f}this.element.style.left=(r.left-u)/s+"px",this.element.style.top=(r.top-c)/o+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/o+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,a=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!a){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let o=$v(this.editorView.state.doc,s,this.editorView.dragging.slice);o!=null&&(s=o)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Fe extends ge{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Fe.valid(r)?new Fe(r):ge.near(r)}content(){return ee.empty}eq(e){return e instanceof Fe&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Fe(e.resolve(n.pos))}getBookmark(){return new Mg(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!UP(e)||!HP(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Fe.valid(e))return e;let i=e.pos,a=null;for(let s=e.depth;;s--){let o=e.node(s);if(n>0?e.indexAfter(s)<o.childCount:e.index(s)>0){a=o.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=n;let l=e.doc.resolve(i);if(Fe.valid(l))return l}for(;;){let s=n>0?a.firstChild:a.lastChild;if(!s){if(a.isAtom&&!a.isText&&!le.isSelectable(a)){e=e.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=s,i+=n;let o=e.doc.resolve(i);if(Fe.valid(o))return o}return null}}}Fe.prototype.visible=!1;Fe.findFrom=Fe.findGapCursorFrom;ge.jsonID("gapcursor",Fe);class Mg{constructor(e){this.pos=e}map(e){return new Mg(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Fe.valid(n)?new Fe(n):ge.near(n)}}function B_(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function UP(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||B_(i.type))return!0;if(i.inlineContent)return!1}}return!0}function HP(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||B_(i.type))return!0;if(i.inlineContent)return!1}}return!0}function $P(){return new Ie({props:{decorations:GP,createSelectionBetween(t,e,n){return e.pos==n.pos&&Fe.valid(n)?new Fe(n):null},handleClick:qP,handleKeyDown:zP,handleDOMEvents:{beforeinput:jP}}})}const zP=zC({ArrowLeft:Wa("horiz",-1),ArrowRight:Wa("horiz",1),ArrowUp:Wa("vert",-1),ArrowDown:Wa("vert",1)});function Wa(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,a){let s=r.selection,o=e>0?s.$to:s.$from,l=s.empty;if(s instanceof pe){if(!a.endOfTextblock(n)||o.depth==0)return!1;l=!1,o=r.doc.resolve(e>0?o.after():o.before())}let u=Fe.findGapCursorFrom(o,e,l);return u?(i&&i(r.tr.setSelection(new Fe(u))),!0):!1}}function qP(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Fe.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&le.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Fe(r))),!0)}function jP(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Fe))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=W.empty;for(let s=r.length-1;s>=0;s--)i=W.from(r[s].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new ee(i,0,0));return a.setSelection(pe.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function GP(t){if(!(t.selection instanceof Fe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Re.create(t.doc,[it.widget(t.selection.head,e,{key:"gapcursor"})])}var Fs=200,Xe=function(){};Xe.prototype.append=function(e){return e.length?(e=Xe.from(e),!this.length&&e||e.length<Fs&&this.leafAppend(e)||this.length<Fs&&e.leafPrepend(this)||this.appendInner(e)):this};Xe.prototype.prepend=function(e){return e.length?Xe.from(e).append(this):this};Xe.prototype.appendInner=function(e){return new VP(this,e)};Xe.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Xe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Xe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Xe.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};Xe.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(a,s){return i.push(e(a,s))},n,r),i};Xe.from=function(e){return e instanceof Xe?e:e&&e.length?new U_(e):Xe.empty};var U_=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,a){return i==0&&a==this.length?this:new e(this.values.slice(i,a))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,a,s,o){for(var l=a;l<s;l++)if(i(this.values[l],o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,a,s,o){for(var l=a-1;l>=s;l--)if(i(this.values[l],o+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Fs)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Fs)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Xe);Xe.empty=new U_([]);var VP=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,a,s){var o=this.left.length;if(i<o&&this.left.forEachInner(r,i,Math.min(a,o),s)===!1||a>o&&this.right.forEachInner(r,Math.max(i-o,0),Math.min(this.length,a)-o,s+o)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,s){var o=this.left.length;if(i>o&&this.right.forEachInvertedInner(r,i-o,Math.max(a,o)-o,s+o)===!1||a<o&&this.left.forEachInvertedInner(r,Math.min(i,o),a,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var a=this.left.length;return i<=a?this.left.slice(r,i):r>=a?this.right.slice(r-a,i-a):this.left.slice(r,a).append(this.right.slice(0,i-a))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Xe);const WP=500;class Gt{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let s=e.tr,o,l,u=[],c=[];return this.items.forEach((d,p)=>{if(!d.step){i||(i=this.remapping(r,p+1),a=i.maps.length),a--,c.push(d);return}if(i){c.push(new Qt(d.map));let f=d.step.map(i.slice(a)),h;f&&s.maybeStep(f).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],u.push(new Qt(h,void 0,void 0,u.length+c.length))),a--,h&&i.appendMap(h,a)}else s.maybeStep(d.step);if(d.selection)return o=i?d.selection.map(i.slice(a)):d.selection,l=new Gt(this.items.slice(0,r).append(c.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:s,selection:o}}addTransform(e,n,r,i){let a=[],s=this.eventCount,o=this.items,l=!i&&o.length?o.get(o.length-1):null;for(let c=0;c<e.steps.length;c++){let d=e.steps[c].invert(e.docs[c]),p=new Qt(e.mapping.maps[c],d,n),f;(f=l&&l.merge(p))&&(p=f,c?a.pop():o=o.slice(0,o.length-1)),a.push(p),n&&(s++,n=void 0),i||(l=p)}let u=s-r.depth;return u>KP&&(o=YP(o,u),s-=u),new Gt(o.append(a),s)}remapping(e,n){let r=new ca;return this.items.forEach((i,a)=>{let s=i.mirrorOffset!=null&&a-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new Gt(this.items.append(e.map(n=>new Qt(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=e.mapping,s=e.steps.length,o=this.eventCount;this.items.forEach(p=>{p.selection&&o--},i);let l=n;this.items.forEach(p=>{let f=a.getMirror(--l);if(f==null)return;s=Math.min(s,f);let h=a.maps[f];if(p.step){let g=e.steps[f].invert(e.docs[f]),b=p.selection&&p.selection.map(a.slice(l+1,f));b&&o++,r.push(new Qt(h,g,b))}else r.push(new Qt(h))},i);let u=[];for(let p=n;p<s;p++)u.push(new Qt(a.maps[p]));let c=this.items.slice(0,i).append(u).append(r),d=new Gt(c,o);return d.emptyItemCount()>WP&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],a=0;return this.items.forEach((s,o)=>{if(o>=e)i.push(s),s.selection&&a++;else if(s.step){let l=s.step.map(n.slice(r)),u=l&&l.getMap();if(r--,u&&n.appendMap(u,r),l){let c=s.selection&&s.selection.map(n.slice(r));c&&a++;let d=new Qt(u.invert(),l,c),p,f=i.length-1;(p=i.length&&i[f].merge(d))?i[f]=p:i.push(d)}}else s.map&&r--},this.items.length,0),new Gt(Xe.from(i.reverse()),a)}}Gt.empty=new Gt(Xe.empty,0);function YP(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Qt{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Qt(n.getMap().invert(),n,this.selection)}}}class Pn{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const KP=20;function XP(t,e,n,r){let i=n.getMeta(mr),a;if(i)return i.historyState;n.getMeta(JP)&&(t=new Pn(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(mr))return s.getMeta(mr).redo?new Pn(t.done.addTransform(n,void 0,r,ds(e)),t.undone,u0(n.mapping.maps),t.prevTime,t.prevComposition):new Pn(t.done,t.undone.addTransform(n,void 0,r,ds(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let o=n.getMeta("composition"),l=t.prevTime==0||!s&&t.prevComposition!=o&&(t.prevTime<(n.time||0)-r.newGroupDelay||!ZP(n,t.prevRanges)),u=s?Dl(t.prevRanges,n.mapping):u0(n.mapping.maps);return new Pn(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,ds(e)),Gt.empty,u,n.time,o??t.prevComposition)}else return(a=n.getMeta("rebased"))?new Pn(t.done.rebased(n,a),t.undone.rebased(n,a),Dl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Pn(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Dl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function ZP(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let a=0;a<e.length;a+=2)r<=e[a+1]&&i>=e[a]&&(n=!0)}),n}function u0(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,a,s)=>e.push(a,s));return e}function Dl(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),a=e.map(t[r+1],-1);i<=a&&n.push(i,a)}return n}function QP(t,e,n){let r=ds(e),i=mr.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,r);if(!a)return null;let s=a.selection.resolve(a.transform.doc),o=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),i,r),l=new Pn(n?o:a.remaining,n?a.remaining:o,null,0,-1);return a.transform.setSelection(s).setMeta(mr,{redo:n,historyState:l})}let Ml=!1,c0=null;function ds(t){let e=t.plugins;if(c0!=e){Ml=!1,c0=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Ml=!0;break}}return Ml}const mr=new De("history"),JP=new De("closeHistory");function eF(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Ie({key:mr,state:{init(){return new Pn(Gt.empty,Gt.empty,null,0,-1)},apply(e,n,r){return XP(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?$_:r=="historyRedo"?z_:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function H_(t,e){return(n,r)=>{let i=mr.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=QP(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const $_=H_(!1,!0),z_=H_(!0,!0);Ue.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Ie({key:new De("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const a=this.storage.characters({node:r.doc});if(a>i){const s=a-i,o=0,l=s;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(o,l);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),a=this.storage.characters({node:e.doc});if(a<=r||i>r&&a>r&&a<=i)return!0;if(i>r&&a>r&&a>i||!e.getMeta("paste"))return!1;const o=e.selection.$head.pos,l=a-r,u=o-l,c=o;return e.deleteRange(u,c),!(this.storage.characters({node:e.doc})>r)}})]}});var tF=Ue.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[FP(this.options)]}});Ue.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Ie({key:new De("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return Re.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((l,u)=>{if(l.isText)return;if(!(i>=u&&i<=u+l.nodeSize-1))return!1;s+=1});let o=0;return t.descendants((l,u)=>{if(l.isText||!(i>=u&&i<=u+l.nodeSize-1))return!1;if(o+=1,this.options.mode==="deepest"&&s-o>0||this.options.mode==="shallowest"&&o>1)return this.options.mode==="deepest";a.push(it.node(u,u+l.nodeSize,{class:this.options.className}))}),Re.create(t,a)}}})]}});var nF=Ue.create({name:"gapCursor",addProseMirrorPlugins(){return[$P()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Ae(oe(t,"allowGapCursor",n)))!=null?e:null}}}),d0="placeholder";function rF(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var iF=Ue.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:d0,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${rF(this.options.dataAttribute)}`:`data-${d0}`;return[new Ie({key:new De("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,a=[];if(!r)return null;const s=this.editor.isEmpty;return e.descendants((o,l)=>{const u=i>=l&&i<=l+o.nodeSize,c=!o.isLeaf&&qo(o);if((u||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];s&&d.push(this.options.emptyEditorClass);const p=it.node(l,l+o.nodeSize,{class:d.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:u}):this.options.placeholder});a.push(p)}return this.options.includeChildren}),Re.create(e,a)}}})]}});Ue.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Ie({key:new De("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||i_(n.selection)||t.view.dragging?null:Re.create(n.doc,[it.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function p0({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var aF=Ue.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new De(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new Ie({key:e,appendTransaction:(i,a,s)=>{const{doc:o,tr:l,schema:u}=s,c=e.getState(s),d=o.content.size,p=u.nodes[n];if(c)return l.insert(d,p.create())},state:{init:(i,a)=>{const s=a.tr.doc.lastChild;return!p0({node:s,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const s=i.doc.lastChild;return!p0({node:s,types:r})}}})]}}),sF=Ue.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>$_(t,e),redo:()=>({state:t,dispatch:e})=>z_(t,e)}},addProseMirrorPlugins(){return[eF(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),oF=iF,Bs=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},lF=/^\s*>\s$/,uF=Tt.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Bs("blockquote",{...je(this.options.HTMLAttributes,t),children:Bs("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const o=e.renderChildren([i]).split(`
|
|
101
101
|
`).map(l=>l.trim()===""?n:`${n} ${l}`);r.push(o.join(`
|
|
102
102
|
`))}),r.join(`
|
|
103
103
|
${n}
|
|
@@ -137,7 +137,7 @@ ${f.slice(u+2)}`,d+=1;else break}e.push({indent:u,number:parseInt(o,10),content:
|
|
|
137
137
|
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split(`
|
|
138
138
|
`),[a,s]=oB(i);if(a.length===0)return;const o=sN(a,0,n);return o.length===0?void 0:{type:"list",ordered:!0,start:((r=a[0])==null?void 0:r.number)||1,items:o,raw:i.slice(0,s).join(`
|
|
139
139
|
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(uB,this.editor.getAttributes(k0)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=ii({find:x0,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ii({find:x0,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(k0)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),cB=/^\s*(\[([( |x])?\])\s$/,dB=Tt.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",je(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const i=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Rg(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),a=document.createElement("label"),s=document.createElement("span"),o=document.createElement("input"),l=document.createElement("div"),u=d=>{var p,f;o.ariaLabel=((f=(p=this.options.a11y)==null?void 0:p.checkboxLabel)==null?void 0:f.call(p,d,o.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};u(t),a.contentEditable="false",o.type="checkbox",o.addEventListener("mousedown",d=>d.preventDefault()),o.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){o.checked=!o.checked;return}const{checked:p}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const h=n();if(typeof h!="number")return!1;const g=f.doc.nodeAt(h);return f.setNodeMarkup(h,void 0,{...g?.attrs,checked:p}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,p)||(o.checked=!o.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,p])=>{i.setAttribute(d,p)}),i.dataset.checked=t.attrs.checked,o.checked=t.attrs.checked,a.append(o,s),i.append(a,l),Object.entries(e).forEach(([d,p])=>{i.setAttribute(d,p)});let c=new Set(Object.keys(e));return{dom:i,contentDOM:l,update:d=>{if(d.type!==this.type)return!1;i.dataset.checked=d.attrs.checked,o.checked=d.attrs.checked,u(d);const p=r.extensionManager.attributes,f=ni(d,p),h=new Set(Object.keys(f)),g=this.options.HTMLAttributes;return c.forEach(b=>{h.has(b)||(b in g?i.setAttribute(b,g[b]):i.removeAttribute(b))}),Object.entries(f).forEach(([b,E])=>{E==null?b in g?i.setAttribute(b,g[b]):i.removeAttribute(b):i.setAttribute(b,E)}),c=h,!0}}}},addInputRules(){return[ii({find:cB,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),pB=Tt.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",je(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
140
|
-
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=a=>{const s=bm(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,l)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:l}),customNestedParser:r},n);return s?[{type:"taskList",raw:s.raw,items:s.items}]:n.blockTokens(a)},i=bm(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,s)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:s}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Ue.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Q_.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(J_.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(aN.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(oN.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(dB.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(pB.configure(this.options.taskList)),t}});var v0=" ",fB=" ",hB=Tt.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",je(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===v0||r[0].text===fB)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?v0:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),mB=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,gB=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,bB=_r.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",je(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ri({find:mB,type:this.type})]},addPasteRules(){return[Ar({find:gB,type:this.type})]}}),EB=Tt.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),yB=_r.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",je(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const a=i[2].trim();return{type:"underline",raw:i[0],text:a,tokens:n.inlineTokens(a)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),TB=Ue.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(hF.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(uF.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Q_.configure(this.options.bulletList)),this.options.code!==!1&&i.push(bF.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(TF.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(SF.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(tF.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(nF.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(AF.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(kF.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(sF.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(xF.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(IF.configure(this.options.italic)),this.options.listItem!==!1&&i.push(J_.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(aN.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(eB.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(oN.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(hB.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(bB.configure(this.options.strike)),this.options.text!==!1&&i.push(EB.configure(this.options.text)),this.options.underline!==!1&&i.push(yB.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(aF.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),lN=TB;var SB=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],Im=SB.join(","),uN=typeof Element>"u",ya=uN?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,fo=!uN&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t?.ownerDocument},ho=function(e,n){var r;n===void 0&&(n=!0);var i=e==null||(r=e.getAttribute)===null||r===void 0?void 0:r.call(e,"inert"),a=i===""||i==="true",s=a||n&&e&&(typeof e.closest=="function"?e.closest("[inert]"):ho(e.parentNode));return s},AB=function(e){var n,r=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"contenteditable");return r===""||r==="true"},kB=function(e,n,r){if(ho(e))return[];var i=Array.prototype.slice.apply(e.querySelectorAll(Im));return n&&ya.call(e,Im)&&i.unshift(e),i=i.filter(r),i},wm=function(e,n,r){for(var i=[],a=Array.from(e);a.length;){var s=a.shift();if(!ho(s,!1))if(s.tagName==="SLOT"){var o=s.assignedElements(),l=o.length?o:s.children,u=wm(l,!0,r);r.flatten?i.push.apply(i,u):i.push({scopeParent:s,candidates:u})}else{var c=ya.call(s,Im);c&&r.filter(s)&&(n||!e.includes(s))&&i.push(s);var d=s.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(s),p=!ho(d,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(s));if(d&&p){var f=wm(d===!0?s.children:d.children,!0,r);r.flatten?i.push.apply(i,f):i.push({scopeParent:s,candidates:f})}else a.unshift.apply(a,s.children)}}return i},cN=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},dN=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||AB(e))&&!cN(e)?0:e.tabIndex},xB=function(e,n){var r=dN(e);return r<0&&n&&!cN(e)?0:r},vB=function(e,n){return e.tabIndex===n.tabIndex?e.documentOrder-n.documentOrder:e.tabIndex-n.tabIndex},pN=function(e){return e.tagName==="INPUT"},CB=function(e){return pN(e)&&e.type==="hidden"},_B=function(e){var n=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(r){return r.tagName==="SUMMARY"});return n},NB=function(e,n){for(var r=0;r<e.length;r++)if(e[r].checked&&e[r].form===n)return e[r]},IB=function(e){if(!e.name)return!0;var n=e.form||fo(e),r=function(o){return n.querySelectorAll('input[type="radio"][name="'+o+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=r(window.CSS.escape(e.name));else try{i=r(e.name)}catch(s){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",s.message),!1}var a=NB(i,e.form);return!a||a===e},wB=function(e){return pN(e)&&e.type==="radio"},RB=function(e){return wB(e)&&!IB(e)},OB=function(e){var n,r=e&&fo(e),i=(n=r)===null||n===void 0?void 0:n.host,a=!1;if(r&&r!==e){var s,o,l;for(a=!!((s=i)!==null&&s!==void 0&&(o=s.ownerDocument)!==null&&o!==void 0&&o.contains(i)||e!=null&&(l=e.ownerDocument)!==null&&l!==void 0&&l.contains(e));!a&&i;){var u,c,d;r=fo(i),i=(u=r)===null||u===void 0?void 0:u.host,a=!!((c=i)!==null&&c!==void 0&&(d=c.ownerDocument)!==null&&d!==void 0&&d.contains(i))}}return a},C0=function(e){var n=e.getBoundingClientRect(),r=n.width,i=n.height;return r===0&&i===0},LB=function(e,n){var r=n.displayCheck,i=n.getShadowRoot;if(r==="full-native"&&"checkVisibility"in e){var a=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!a}if(getComputedStyle(e).visibility==="hidden")return!0;var s=ya.call(e,"details>summary:first-of-type"),o=s?e.parentElement:e;if(ya.call(o,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof i=="function"){for(var l=e;e;){var u=e.parentElement,c=fo(e);if(u&&!u.shadowRoot&&i(u)===!0)return C0(e);e.assignedSlot?e=e.assignedSlot:!u&&c!==e.ownerDocument?e=c.host:e=u}e=l}if(OB(e))return!e.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return C0(e);return!1},DB=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var n=e.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var i=n.children.item(r);if(i.tagName==="LEGEND")return ya.call(n,"fieldset[disabled] *")?!0:!i.contains(e)}return!0}n=n.parentElement}return!1},MB=function(e,n){return!(n.disabled||CB(n)||LB(n,e)||_B(n)||DB(n))},_0=function(e,n){return!(RB(n)||dN(n)<0||!MB(e,n))},PB=function(e){var n=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},fN=function(e){var n=[],r=[];return e.forEach(function(i,a){var s=!!i.scopeParent,o=s?i.scopeParent:i,l=xB(o,s),u=s?fN(i.candidates):o;l===0?s?n.push.apply(n,u):n.push(o):r.push({documentOrder:a,tabIndex:l,item:i,isScope:s,content:u})}),r.sort(vB).reduce(function(i,a){return a.isScope?i.push.apply(i,a.content):i.push(a.content),i},[]).concat(n)},hN=function(e,n){n=n||{};var r;return n.getShadowRoot?r=wm([e],n.includeContainer,{filter:_0.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:PB}):r=kB(e,n.includeContainer,_0.bind(null,n)),fN(r)};function FB(){return/apple/i.test(navigator.vendor)}const N0="data-floating-ui-focusable";function BB(t){let e=t.activeElement;for(;((n=e)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;e=e.shadowRoot.activeElement}return e}function Rm(t,e){if(!t||!e)return!1;const n=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(n&&Xw(n)){let r=e;for(;r;){if(t===r)return!0;r=r.parentNode||r.host}}return!1}function Ni(t){return"composedPath"in t?t.composedPath()[0]:t.target}function ql(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const n=t;return n.target!=null&&e.contains(n.target)}function UB(t){return t.matches("html,body")}function Ta(t){return t?.ownerDocument||document}function HB(t){return t?t.hasAttribute(N0)?t:t.querySelector("["+N0+"]")||t:null}function fs(t,e,n){return n===void 0&&(n=!0),t.filter(i=>{var a;return i.parentId===e&&(!n||((a=i.context)==null?void 0:a.open))}).flatMap(i=>[i,...fs(t,i.id,n)])}function $B(t){return"nativeEvent"in t}var zB=typeof document<"u",qB=function(){},gr=zB?P.useLayoutEffect:qB;const jB={...Wx},GB=jB.useInsertionEffect,VB=GB||(t=>t());function $r(t){const e=P.useRef(()=>{});return VB(()=>{e.current=t}),P.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}const mN=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function gN(t,e){const n=hN(t,mN()),r=n.length;if(r===0)return;const i=BB(Ta(t)),a=n.indexOf(i),s=a===-1?e===1?0:r-1:a+e;return n[s]}function WB(t){return gN(Ta(t).body,1)||t}function YB(t){return gN(Ta(t).body,-1)||t}function jl(t,e){const n=e||t.currentTarget,r=t.relatedTarget;return!r||!Rm(n,r)}function KB(t){hN(t,mN()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function I0(t){t.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}const XB="data-floating-ui-focusable",w0="active",R0="selected",ZB={...Wx};let O0=!1,QB=0;const L0=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+QB++;function JB(){const[t,e]=P.useState(()=>O0?L0():void 0);return gr(()=>{t==null&&e(L0())},[]),P.useEffect(()=>{O0=!0},[]),t}const e4=ZB.useId,Vg=e4||JB;function t4(){const t=new Map;return{emit(e,n){var r;(r=t.get(e))==null||r.forEach(i=>i(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var r;(r=t.get(e))==null||r.delete(n)}}}const n4=P.createContext(null),r4=P.createContext(null),bN=()=>{var t;return((t=P.useContext(n4))==null?void 0:t.id)||null},EN=()=>P.useContext(r4);function Wg(t){return"data-floating-ui-"+t}const i4={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},D0=P.forwardRef(function(e,n){const[r,i]=P.useState();gr(()=>{FB()&&i("button")},[]);const a={ref:n,tabIndex:0,role:r,"aria-hidden":r?void 0:!0,[Wg("focus-guard")]:"",style:i4};return T.jsx("span",{...e,...a})}),a4={clipPath:"inset(50%)",position:"fixed",top:0,left:0},yN=P.createContext(null),M0=Wg("portal");function s4(t){t===void 0&&(t={});const{id:e,root:n}=t,r=Vg(),i=l4(),[a,s]=P.useState(null),o=P.useRef(null);return gr(()=>()=>{a?.remove(),queueMicrotask(()=>{o.current=null})},[a]),gr(()=>{if(!r||o.current)return;const l=e?document.getElementById(e):null;if(!l)return;const u=document.createElement("div");u.id=r,u.setAttribute(M0,""),l.appendChild(u),o.current=u,s(u)},[e,r]),gr(()=>{if(n===null||!r||o.current)return;let l=n||i?.portalNode;l&&!nR(l)&&(l=l.current),l=l||document.body;let u=null;e&&(u=document.createElement("div"),u.id=e,l.appendChild(u));const c=document.createElement("div");c.id=r,c.setAttribute(M0,""),l=u||l,l.appendChild(c),o.current=c,s(c)},[e,n,r,i]),a}function o4(t){const{children:e,id:n,root:r,preserveTabOrder:i=!0}=t,a=s4({id:n,root:r}),[s,o]=P.useState(null),l=P.useRef(null),u=P.useRef(null),c=P.useRef(null),d=P.useRef(null),p=s?.modal,f=s?.open,h=!!s&&!s.modal&&s.open&&i&&!!(r||a);return P.useEffect(()=>{if(!a||!i||p)return;function g(b){a&&jl(b)&&(b.type==="focusin"?I0:KB)(a)}return a.addEventListener("focusin",g,!0),a.addEventListener("focusout",g,!0),()=>{a.removeEventListener("focusin",g,!0),a.removeEventListener("focusout",g,!0)}},[a,i,p]),P.useEffect(()=>{a&&(f||I0(a))},[f,a]),T.jsxs(yN.Provider,{value:P.useMemo(()=>({preserveTabOrder:i,beforeOutsideRef:l,afterOutsideRef:u,beforeInsideRef:c,afterInsideRef:d,portalNode:a,setFocusManagerState:o}),[i,a]),children:[h&&a&&T.jsx(D0,{"data-type":"outside",ref:l,onFocus:g=>{if(jl(g,a)){var b;(b=c.current)==null||b.focus()}else{const E=s?s.domReference:null,y=YB(E);y?.focus()}}}),h&&a&&T.jsx("span",{"aria-owns":a.id,style:a4}),a&&Vx.createPortal(e,a),h&&a&&T.jsx(D0,{"data-type":"outside",ref:u,onFocus:g=>{if(jl(g,a)){var b;(b=d.current)==null||b.focus()}else{const E=s?s.domReference:null,y=WB(E);y?.focus(),s?.closeOnFocusOut&&s?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const l4=()=>P.useContext(yN),u4={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},c4={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},P0=t=>{var e,n;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(n=t?.outsidePress)!=null?n:!0}};function d4(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,elements:i,dataRef:a}=t,{enabled:s=!0,escapeKey:o=!0,outsidePress:l=!0,outsidePressEvent:u="pointerdown",referencePress:c=!1,referencePressEvent:d="pointerdown",ancestorScroll:p=!1,bubbles:f,capture:h}=e,g=EN(),b=$r(typeof l=="function"?l:()=>!1),E=typeof l=="function"?b:l,y=P.useRef(!1),{escapeKey:S,outsidePress:k}=P0(f),{escapeKey:x,outsidePress:A}=P0(h),v=P.useRef(!1),w=$r(F=>{var U;if(!n||!s||!o||F.key!=="Escape"||v.current)return;const $=(U=a.current.floatingContext)==null?void 0:U.nodeId,G=g?fs(g.nodesRef.current,$):[];if(!S&&(F.stopPropagation(),G.length>0)){let H=!0;if(G.forEach(J=>{var I;if((I=J.context)!=null&&I.open&&!J.context.dataRef.current.__escapeKeyBubbles){H=!1;return}}),!H)return}r(!1,$B(F)?F.nativeEvent:F,"escape-key")}),N=$r(F=>{var U;const $=()=>{var G;w(F),(G=Ni(F))==null||G.removeEventListener("keydown",$)};(U=Ni(F))==null||U.addEventListener("keydown",$)}),_=$r(F=>{var U;const $=a.current.insideReactTree;a.current.insideReactTree=!1;const G=y.current;if(y.current=!1,u==="click"&&G||$||typeof E=="function"&&!E(F))return;const H=Ni(F),J="["+Wg("inert")+"]",I=Ta(i.floating).querySelectorAll(J);let Z=nn(H)?H:null;for(;Z&&!ml(Z);){const ne=Jw(Z);if(ml(ne)||!nn(ne))break;Z=ne}if(I.length&&nn(H)&&!UB(H)&&!Rm(H,i.floating)&&Array.from(I).every(ne=>!Rm(Z,ne)))return;if(eR(H)&&q){const ne=ml(H),se=tR(H),fe=/auto|scroll/,xe=ne||fe.test(se.overflowX),Oe=ne||fe.test(se.overflowY),Le=xe&&H.clientWidth>0&&H.scrollWidth>H.clientWidth,Me=Oe&&H.clientHeight>0&&H.scrollHeight>H.clientHeight,St=se.direction==="rtl",tt=Me&&(St?F.offsetX<=H.offsetWidth-H.clientWidth:F.offsetX>H.clientWidth),Dt=Le&&F.offsetY>H.clientHeight;if(tt||Dt)return}const ae=(U=a.current.floatingContext)==null?void 0:U.nodeId,O=g&&fs(g.nodesRef.current,ae).some(ne=>{var se;return ql(F,(se=ne.context)==null?void 0:se.elements.floating)});if(ql(F,i.floating)||ql(F,i.domReference)||O)return;const re=g?fs(g.nodesRef.current,ae):[];if(re.length>0){let ne=!0;if(re.forEach(se=>{var fe;if((fe=se.context)!=null&&fe.open&&!se.context.dataRef.current.__outsidePressBubbles){ne=!1;return}}),!ne)return}r(!1,F,"outside-press")}),D=$r(F=>{var U;const $=()=>{var G;_(F),(G=Ni(F))==null||G.removeEventListener(u,$)};(U=Ni(F))==null||U.addEventListener(u,$)});P.useEffect(()=>{if(!n||!s)return;a.current.__escapeKeyBubbles=S,a.current.__outsidePressBubbles=k;let F=-1;function U(I){r(!1,I,"ancestor-scroll")}function $(){window.clearTimeout(F),v.current=!0}function G(){F=window.setTimeout(()=>{v.current=!1},Qw()?5:0)}const H=Ta(i.floating);o&&(H.addEventListener("keydown",x?N:w,x),H.addEventListener("compositionstart",$),H.addEventListener("compositionend",G)),E&&H.addEventListener(u,A?D:_,A);let J=[];return p&&(nn(i.domReference)&&(J=hl(i.domReference)),nn(i.floating)&&(J=J.concat(hl(i.floating))),!nn(i.reference)&&i.reference&&i.reference.contextElement&&(J=J.concat(hl(i.reference.contextElement)))),J=J.filter(I=>{var Z;return I!==((Z=H.defaultView)==null?void 0:Z.visualViewport)}),J.forEach(I=>{I.addEventListener("scroll",U,{passive:!0})}),()=>{o&&(H.removeEventListener("keydown",x?N:w,x),H.removeEventListener("compositionstart",$),H.removeEventListener("compositionend",G)),E&&H.removeEventListener(u,A?D:_,A),J.forEach(I=>{I.removeEventListener("scroll",U)}),window.clearTimeout(F)}},[a,i,o,E,u,n,r,p,s,S,k,w,x,N,_,A,D]),P.useEffect(()=>{a.current.insideReactTree=!1},[a,E,u]);const M=P.useMemo(()=>({onKeyDown:w,...c&&{[u4[d]]:F=>{r(!1,F.nativeEvent,"reference-press")},...d!=="click"&&{onClick(F){r(!1,F.nativeEvent,"reference-press")}}}}),[w,r,c,d]),q=P.useMemo(()=>({onKeyDown:w,onMouseDown(){y.current=!0},onMouseUp(){y.current=!0},[c4[u]]:()=>{a.current.insideReactTree=!0}}),[w,u,a]);return P.useMemo(()=>s?{reference:M,floating:q}:{},[s,M,q])}function p4(t){const{open:e=!1,onOpenChange:n,elements:r}=t,i=Vg(),a=P.useRef({}),[s]=P.useState(()=>t4()),o=bN()!=null,[l,u]=P.useState(r.reference),c=$r((f,h,g)=>{a.current.openEvent=f?h:void 0,s.emit("openchange",{open:f,event:h,reason:g,nested:o}),n?.(f,h,g)}),d=P.useMemo(()=>({setPositionReference:u}),[]),p=P.useMemo(()=>({reference:l||r.reference||null,floating:r.floating||null,domReference:r.reference}),[l,r.reference,r.floating]);return P.useMemo(()=>({dataRef:a,open:e,onOpenChange:c,elements:p,events:s,floatingId:i,refs:d}),[e,c,p,s,i,d])}function f4(t){t===void 0&&(t={});const{nodeId:e}=t,n=p4({...t,elements:{reference:null,floating:null,...t.elements}}),r=t.rootContext||n,i=r.elements,[a,s]=P.useState(null),[o,l]=P.useState(null),c=i?.domReference||a,d=P.useRef(null),p=EN();gr(()=>{c&&(d.current=c)},[c]);const f=Zw({...t,elements:{...i,...o&&{reference:o}}}),h=P.useCallback(S=>{const k=nn(S)?{getBoundingClientRect:()=>S.getBoundingClientRect(),getClientRects:()=>S.getClientRects(),contextElement:S}:S;l(k),f.refs.setReference(k)},[f.refs]),g=P.useCallback(S=>{(nn(S)||S===null)&&(d.current=S,s(S)),(nn(f.refs.reference.current)||f.refs.reference.current===null||S!==null&&!nn(S))&&f.refs.setReference(S)},[f.refs]),b=P.useMemo(()=>({...f.refs,setReference:g,setPositionReference:h,domReference:d}),[f.refs,g,h]),E=P.useMemo(()=>({...f.elements,domReference:c}),[f.elements,c]),y=P.useMemo(()=>({...f,...r,refs:b,elements:E,nodeId:e}),[f,b,E,e,r]);return gr(()=>{r.dataRef.current.floatingContext=y;const S=p?.nodesRef.current.find(k=>k.id===e);S&&(S.context=y)}),P.useMemo(()=>({...f,context:y,refs:b,elements:E}),[f,b,E,y])}function Gl(t,e,n){const r=new Map,i=n==="item";let a=t;if(i&&t){const{[w0]:s,[R0]:o,...l}=t;a=l}return{...n==="floating"&&{tabIndex:-1,[XB]:""},...a,...e.map(s=>{const o=s?s[n]:null;return typeof o=="function"?t?o(t):null:o}).concat(t).reduce((s,o)=>(o&&Object.entries(o).forEach(l=>{let[u,c]=l;if(!(i&&[w0,R0].includes(u)))if(u.indexOf("on")===0){if(r.has(u)||r.set(u,[]),typeof c=="function"){var d;(d=r.get(u))==null||d.push(c),s[u]=function(){for(var p,f=arguments.length,h=new Array(f),g=0;g<f;g++)h[g]=arguments[g];return(p=r.get(u))==null?void 0:p.map(b=>b(...h)).find(b=>b!==void 0)}}}else s[u]=c}),s),{})}}function h4(t){t===void 0&&(t=[]);const e=t.map(o=>o?.reference),n=t.map(o=>o?.floating),r=t.map(o=>o?.item),i=P.useCallback(o=>Gl(o,t,"reference"),e),a=P.useCallback(o=>Gl(o,t,"floating"),n),s=P.useCallback(o=>Gl(o,t,"item"),r);return P.useMemo(()=>({getReferenceProps:i,getFloatingProps:a,getItemProps:s}),[i,a,s])}const m4=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function g4(t,e){var n,r;e===void 0&&(e={});const{open:i,elements:a,floatingId:s}=t,{enabled:o=!0,role:l="dialog"}=e,u=Vg(),c=((n=a.domReference)==null?void 0:n.id)||u,d=P.useMemo(()=>{var y;return((y=HB(a.floating))==null?void 0:y.id)||s},[a.floating,s]),p=(r=m4.get(l))!=null?r:l,h=bN()!=null,g=P.useMemo(()=>p==="tooltip"||l==="label"?{["aria-"+(l==="label"?"labelledby":"describedby")]:i?d:void 0}:{"aria-expanded":i?"true":"false","aria-haspopup":p==="alertdialog"?"dialog":p,"aria-controls":i?d:void 0,...p==="listbox"&&{role:"combobox"},...p==="menu"&&{id:c},...p==="menu"&&h&&{role:"menuitem"},...l==="select"&&{"aria-autocomplete":"none"},...l==="combobox"&&{"aria-autocomplete":"list"}},[p,d,h,i,c,l]),b=P.useMemo(()=>{const y={id:d,...p&&{role:p}};return p==="tooltip"||l==="label"?y:{...y,...p==="menu"&&{"aria-labelledby":c}}},[p,d,c,l]),E=P.useCallback(y=>{let{active:S,selected:k}=y;const x={role:"option",...S&&{id:d+"-fui-option"}};switch(l){case"select":case"combobox":return{...x,"aria-selected":k}}return{}},[d,l]);return P.useMemo(()=>o?{reference:g,floating:b,item:E}:{},[o,g,b,E])}function b4(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:s,$position:o}=t,l=r&&!i,u=zM(n),c=new RegExp(`\\s${u}$`),d=s?"^":"",p=i?"":u,f=l?new RegExp(`${d}${u}.*?(?=\\s${p}|$)`,"gm"):new RegExp(`${d}(?:^)?${u}[^\\s${p}]*`,"gm"),h=((e=o.nodeBefore)==null?void 0:e.isText)&&o.nodeBefore.text;if(!h)return null;const g=o.pos-h.length,b=Array.from(h.matchAll(f)).pop();if(!b||b.input===void 0||b.index===void 0)return null;const E=b.input.slice(Math.max(0,b.index-1),b.index),y=new RegExp(`^[${a?.join("")}\0]?$`).test(E);if(a!==null&&!y)return null;const S=g+b.index;let k=S+b[0].length;return l&&c.test(h.slice(k-1,k+1))&&(b[0]+=" ",k+=1),S<o.pos&&k>=o.pos?{range:{from:S,to:k},query:b[0].slice(n.length),text:b[0]}:null}var E4=new De("suggestion");function y4({pluginKey:t=E4,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[" "],startOfLine:s=!1,decorationTag:o="span",decorationClass:l="suggestion",decorationContent:u="",decorationEmptyClass:c="is-empty",command:d=()=>null,items:p=()=>[],render:f=()=>({}),allow:h=()=>!0,findSuggestionMatch:g=b4,shouldShow:b}){let E;const y=f?.(),S=()=>{const v=e.state.selection.$anchor.pos,w=e.view.coordsAtPos(v),{top:N,right:_,bottom:D,left:M}=w;try{return new DOMRect(M,N,_-M,D-N)}catch{return null}},k=(v,w)=>w?()=>{const N=t.getState(e.state),_=N?.decorationId,D=v.dom.querySelector(`[data-decoration-id="${_}"]`);return D?.getBoundingClientRect()||null}:S;function x(v,w){var N;try{const D=t.getState(v.state),M=D?.decorationId?v.dom.querySelector(`[data-decoration-id="${D.decorationId}"]`):null,q={editor:e,range:D?.range||{from:0,to:0},query:D?.query||null,text:D?.text||null,items:[],command:F=>d({editor:e,range:D?.range||{from:0,to:0},props:F}),decorationNode:M,clientRect:k(v,M)};(N=y?.onExit)==null||N.call(y,q)}catch{}const _=v.state.tr.setMeta(w,{exit:!0});v.dispatch(_)}const A=new Ie({key:t,view(){return{update:async(v,w)=>{var N,_,D,M,q,F,U;const $=(N=this.key)==null?void 0:N.getState(w),G=(_=this.key)==null?void 0:_.getState(v.state),H=$.active&&G.active&&$.range.from!==G.range.from,J=!$.active&&G.active,I=$.active&&!G.active,Z=!J&&!I&&$.query!==G.query,ae=J||H&&Z,O=Z||H,re=I||H&&Z;if(!ae&&!O&&!re)return;const ne=re&&!ae?$:G,se=v.dom.querySelector(`[data-decoration-id="${ne.decorationId}"]`);E={editor:e,range:ne.range,query:ne.query,text:ne.text,items:[],command:fe=>d({editor:e,range:ne.range,props:fe}),decorationNode:se,clientRect:k(v,se)},ae&&((D=y?.onBeforeStart)==null||D.call(y,E)),O&&((M=y?.onBeforeUpdate)==null||M.call(y,E)),(O||ae)&&(E.items=await p({editor:e,query:ne.query})),re&&((q=y?.onExit)==null||q.call(y,E)),O&&((F=y?.onUpdate)==null||F.call(y,E)),ae&&((U=y?.onStart)==null||U.call(y,E))},destroy:()=>{var v;E&&((v=y?.onExit)==null||v.call(y,E))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(v,w,N,_){const{isEditable:D}=e,{composing:M}=e.view,{selection:q}=v,{empty:F,from:U}=q,$={...w},G=v.getMeta(t);if(G&&G.exit)return $.active=!1,$.decorationId=null,$.range={from:0,to:0},$.query=null,$.text=null,$;if($.composing=M,D&&(F||e.view.composing)){(U<w.range.from||U>w.range.to)&&!M&&!w.composing&&($.active=!1);const H=g({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:s,$position:q.$from}),J=`id_${Math.floor(Math.random()*4294967295)}`;H&&h({editor:e,state:_,range:H.range,isActive:w.active})&&(!b||b({editor:e,range:H.range,query:H.query,text:H.text,transaction:v}))?($.active=!0,$.decorationId=w.decorationId?w.decorationId:J,$.range=H.range,$.query=H.query,$.text=H.text):$.active=!1}else $.active=!1;return $.active||($.decorationId=null,$.range={from:0,to:0},$.query=null,$.text=null),$}},props:{handleKeyDown(v,w){var N,_,D,M;const{active:q,range:F}=A.getState(v.state);if(!q)return!1;if(w.key==="Escape"||w.key==="Esc"){const $=A.getState(v.state),G=(N=E?.decorationNode)!=null?N:null,H=G??($?.decorationId?v.dom.querySelector(`[data-decoration-id="${$.decorationId}"]`):null);if(((_=y?.onKeyDown)==null?void 0:_.call(y,{view:v,event:w,range:$.range}))||!1)return!0;const I={editor:e,range:$.range,query:$.query,text:$.text,items:[],command:Z=>d({editor:e,range:$.range,props:Z}),decorationNode:H,clientRect:H?()=>H.getBoundingClientRect()||null:null};return(D=y?.onExit)==null||D.call(y,I),x(v,t),!0}return((M=y?.onKeyDown)==null?void 0:M.call(y,{view:v,event:w,range:F}))||!1},decorations(v){const{active:w,range:N,decorationId:_,query:D}=A.getState(v);if(!w)return null;const M=!D?.length,q=[l];return M&&q.push(c),Re.create(v.doc,[it.inline(N.from,N.to,{nodeName:o,class:q.join(" "),"data-decoration-id":_,"data-decoration-content":u})])}}});return A}function T4(t){const e=te.c(26),{editor:n,query:r,items:i,onSelect:a,onClose:s}=t,[o,l]=P.useState(0),u=P.useRef(i),c=P.useRef(o),d=P.useRef(a),p=P.useRef(s),f=P.useDeferredValue(r);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{l(0)},e[0]=h):h=e[0];let g;e[1]!==f?(g=[f],e[1]=f,e[2]=g):g=e[2],P.useEffect(h,g);let b,E;e[3]!==i.length||e[4]!==o?(b=()=>{o>=i.length&&i.length>0&&l(0)},E=[i.length,o],e[3]=i.length,e[4]=o,e[5]=b,e[6]=E):(b=e[5],E=e[6]),P.useEffect(b,E);let y,S;e[7]!==i?(y=()=>{u.current=i},S=[i],e[7]=i,e[8]=y,e[9]=S):(y=e[8],S=e[9]),P.useEffect(y,S);let k,x;e[10]!==o?(k=()=>{c.current=o},x=[o],e[10]=o,e[11]=k,e[12]=x):(k=e[11],x=e[12]),P.useEffect(k,x);let A,v;e[13]!==a?(v=()=>{d.current=a},A=[a],e[13]=a,e[14]=A,e[15]=v):(A=e[14],v=e[15]),P.useEffect(v,A);let w,N;e[16]!==s?(w=()=>{p.current=s},N=[s],e[16]=s,e[17]=w,e[18]=N):(w=e[17],N=e[18]),P.useEffect(w,N);let _;e[19]!==n.isDestroyed||e[20]!==n.view.dom?(_=()=>{const F=n.view.dom;if(n?.isDestroyed||!F)return;const U=G=>{const H=u.current;if(!H.length)return!1;const J=()=>l(Z=>(Z+1)%H.length),I=()=>l(Z=>(Z-1+H.length)%H.length);switch(G.key){case"ArrowUp":return G.preventDefault(),I(),!0;case"ArrowDown":return G.preventDefault(),J(),!0;case"Tab":return G.preventDefault(),G.shiftKey?I():J(),!0;case"Home":return G.preventDefault(),l(0),!0;case"End":return G.preventDefault(),l(H.length-1),!0;case"Enter":{if(G.isComposing)return!1;G.preventDefault();const Z=c.current;return Z!==-1&&H[Z]&&d.current?.(H[Z],Z),!0}case"Escape":return G.preventDefault(),p.current?.(),!0;default:return!1}},$=G=>{U(G)};return F.addEventListener("keydown",$,!0),()=>{F?.removeEventListener("keydown",$,!0)}},e[19]=n.isDestroyed,e[20]=n.view.dom,e[21]=_):_=e[21];let D;e[22]!==n?(D=[n],e[22]=n,e[23]=D):D=e[23],P.useEffect(_,D);const M=i.length?o:void 0;let q;return e[24]!==M?(q={selectedIndex:M,setSelectedIndex:l},e[24]=M,e[25]=q):q=e[25],q}function S4(t,e){switch(e.type){case"SET_SELECTED_ITEM":return{...t,selectedItem:e.payload};case"ON_START":return{...t,open:!0,selectedItem:null,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_UPDATE":return{...t,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_EXIT":return{open:!1,element:null,query:"",range:null,selectedItem:null};default:return t}}const TN=P.createContext(void 0);function SN(){const t=P.useContext(TN);if(!t)throw new Error("useSuggestionContext must be used within a SuggestionContext.Provider");return t}function A4(t){const e=te.c(8),{editor:n,char:r,pluginKey:i}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={open:!1,element:null,query:"",range:null,selectedItem:null},e[0]=a):a=e[0];const[s,o]=P.useReducer(S4,a);let l,u;e[1]!==r||e[2]!==n||e[3]!==i?(l=()=>{if(n?.isDestroyed)return;const d=i instanceof De?i:new De(i);n.state.plugins.find(h=>h.spec.key===d)&&n.unregisterPlugin(d);const f=y4({pluginKey:d,editor:n,char:r,allow(h){const g=n.state.doc.resolve(h.range.from);for(let b=g.depth;b>0;b--)if(g.node(b).type.name==="image")return!1;return!0},command(){},render:()=>({onStart:h=>{o({type:"ON_START",payload:{element:h.decorationNode??null,query:h.query,range:h.range}})},onUpdate:h=>{o({type:"ON_UPDATE",payload:{element:h.decorationNode??null,query:h.query,range:h.range}})},onKeyDown:h=>h.event.key==="Escape"?(o({type:"ON_EXIT"}),!0):!1,onExit:()=>{o({type:"ON_EXIT"})}}),items:k4});return n.registerPlugin(f),()=>{n?.isDestroyed||n.unregisterPlugin(d)}},u=[n,i,r,o],e[1]=r,e[2]=n,e[3]=i,e[4]=l,e[5]=u):(l=e[4],u=e[5]),P.useEffect(l,u);let c;return e[6]!==s?(c={state:s,dispatch:o},e[6]=s,e[7]=c):c=e[7],c}function k4(){return[]}function x4({editor:t,queryKey:e,queryFn:n,onSelect:r}){const{state:i,dispatch:a}=SN(),s=P.useDeferredValue(i.query),{data:o}=rR({queryKey:Jm.suggestionItems(e,i.open,s),queryFn:()=>i.open?n({query:s}):[]}),l=()=>{a({type:"ON_EXIT"})},u=async(d,p)=>{if(!(i.selectedItem!==null||!i.range)){a({type:"SET_SELECTED_ITEM",payload:d});try{const{view:f}=t,g=f.state.selection.$to.nodeAfter?.text?.startsWith(" "),b=i.range?{...i.range}:{from:0,to:0};g&&i.range&&(b.to+=1),await r({range:b,item:d})}finally{l()}}},{selectedIndex:c}=T4({editor:t,query:s,items:o,onSelect:u,onClose:l});return{selectedItem:i.selectedItem,items:o,selectedIndex:c,close:l,onSelect:u}}function v4({children:t}){const{state:e,dispatch:n}=SN(),{open:r,element:i}=e,a=()=>{n({type:"ON_EXIT"})},{refs:s,floatingStyles:o,context:l}=f4({placement:"bottom-start",open:r,onOpenChange:p=>{p||a()},elements:{reference:i},middleware:[iR(10),aR(),sR()],whileElementsMounted:oR}),u=d4(l,{outsidePress:p=>!(p.target instanceof Element&&p.target.closest(".ProseMirror"))}),c=g4(l,{role:"listbox"}),{getFloatingProps:d}=h4([u,c]);return r?T.jsx(o4,{children:T.jsx("div",{ref:s.setFloating,style:o,...d(),className:"z-50 w-auto min-w-[280px] max-w-[400px] rounded-lg border bg-popover p-0 text-popover-foreground shadow-md outline-hidden overflow-hidden",children:t})}):null}const C4=t=>{const e=te.c(23),{item:n,isSelected:r,onSelect:i,isLoading:a,ref:s}=t,o=r&&"bg-accent text-accent-foreground",l=a&&"pointer-events-none opacity-50";let u;e[0]!==o||e[1]!==l?(u=ce("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","hover:bg-accent hover:text-accent-foreground","focus:bg-accent focus:text-accent-foreground",o,l),e[0]=o,e[1]=l,e[2]=u):u=e[2];let c;e[3]!==n.name||e[4]!==n.title?(c=n.title||n.name.replace(/_/g," "),e[3]=n.name,e[4]=n.title,e[5]=c):c=e[5];let d;e[6]!==c?(d=T.jsx("span",{className:"font-medium flex items-center truncate",children:c}),e[6]=c,e[7]=d):d=e[7];let p;e[8]!==a?(p=a&&T.jsx(xo,{size:"xs"}),e[8]=a,e[9]=p):p=e[9];let f;e[10]!==d||e[11]!==p?(f=T.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d,p]}),e[10]=d,e[11]=p,e[12]=f):f=e[12];let h;e[13]!==n.description?(h=n.description&&T.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:n.description}),e[13]=n.description,e[14]=h):h=e[14];let g;e[15]!==f||e[16]!==h?(g=T.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[f,h]}),e[15]=f,e[16]=h,e[17]=g):g=e[17];let b;return e[18]!==i||e[19]!==s||e[20]!==u||e[21]!==g?(b=T.jsx("div",{ref:s,onClick:i,className:u,children:g}),e[18]=i,e[19]=s,e[20]=u,e[21]=g,e[22]=b):b=e[22],b},_4=t=>{const e=te.c(18),{editor:n,queryKey:r,queryFn:i,onSelect:a}=t;let s;e[0]!==n||e[1]!==a||e[2]!==i||e[3]!==r?(s={editor:n,queryKey:r,queryFn:i,onSelect:a},e[0]=n,e[1]=a,e[2]=i,e[3]=r,e[4]=s):s=e[4];const{items:o,selectedIndex:l,onSelect:u,selectedItem:c}=x4(s);if(!o.length){let h;return e[5]===Symbol.for("react.memo_cache_sentinel")?(h=T.jsx("div",{className:"min-w-[280px] max-w-[400px] bg-popover text-popover-foreground rounded-md border shadow-md p-3 text-sm",children:"No items found"}),e[5]=h):h=e[5],h}let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d={maxHeight:"min(217px, var(--radix-popover-content-available-height, 217px))"},e[6]=d):d=e[6];let p;if(e[7]!==u||e[8]!==o||e[9]!==l||e[10]!==c?.name){let h;e[12]!==u||e[13]!==l||e[14]!==c?.name?(h=(g,b)=>T.jsx(C4,{item:g,isSelected:b===l,ref:b===l?w4:void 0,onSelect:()=>u(g,b),isLoading:c?.name===g.name},g.name),e[12]=u,e[13]=l,e[14]=c?.name,e[15]=h):h=e[15],p=o.map(h),e[7]=u,e[8]=o,e[9]=l,e[10]=c?.name,e[11]=p}else p=e[11];let f;return e[16]!==p?(f=T.jsx("div",{className:"min-w-[280px] max-w-[400px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:d,children:T.jsx("div",{className:"p-1",children:p})}),e[16]=p,e[17]=f):f=e[17],f};function N4(){const t=te.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=T.jsx("div",{className:"p-1",children:[...Array(3)].map(I4)}),t[0]=e):e=t[0],e}function I4(t,e){return T.jsxs("div",{className:"px-2 py-1.5 h-[44px] animate-pulse",children:[T.jsx("div",{className:"h-4 w-24 bg-muted rounded mb-1"}),T.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function AN(t){const e=te.c(16),{editor:n,char:r,pluginKey:i,queryKey:a,queryFn:s,onSelect:o}=t;let l;e[0]!==r||e[1]!==n||e[2]!==i?(l={editor:n,char:r,pluginKey:i},e[0]=r,e[1]=n,e[2]=i,e[3]=l):l=e[3];const{state:u,dispatch:c}=A4(l);let d;e[4]!==c||e[5]!==u?(d={state:u,dispatch:c},e[4]=c,e[5]=u,e[6]=d):d=e[6];let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=T.jsx(N4,{}),e[7]=p):p=e[7];let f;e[8]!==n||e[9]!==o||e[10]!==s||e[11]!==a?(f=T.jsx(v4,{children:T.jsx(P.Suspense,{fallback:p,children:T.jsx(_4,{editor:n,queryKey:a,queryFn:s,onSelect:o})})}),e[8]=n,e[9]=o,e[10]=s,e[11]=a,e[12]=f):f=e[12];let h;return e[13]!==d||e[14]!==f?(h=T.jsx(TN.Provider,{value:d,children:f}),e[13]=d,e[14]=f,e[15]=h):h=e[15],h}function w4(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}async function F0(t,e,n,r,i){try{const a=await nv(n,r,i);R_(t,e,{id:r,name:r,metadata:a.messages,char:"/"})}catch(a){console.error("[prompt] Failed to fetch prompt:",a),Sn.error("Failed to load prompt. Please try again.")}}const R4=t=>{const e=te.c(29),{editor:n,virtualMcpId:r}=t,i=Yx(),{org:a}=ui();let s;e[0]!==a.id||e[1]!==r?(s={connectionId:r,orgId:a.id},e[0]=a.id,e[1]=r,e[2]=s):s=e[2];const o=tg(s);let l;e[3]!==a.id||e[4]!==r?(l=Jm.virtualMcpPrompts(r,a.id),e[3]=a.id,e[4]=r,e[5]=l):l=e[5];const u=l,[c,d]=P.useState(null);let p;e[6]!==o||e[7]!==n?(p=async v=>{const{item:w,range:N}=v;if(w.arguments&&w.arguments.length>0){d({range:N,item:w});return}o&&await F0(n,N,o,w.name)},e[6]=o,e[7]=n,e[8]=p):p=e[8];const f=p;let h;e[9]!==c||e[10]!==o||e[11]!==n?(h=async v=>{if(!c||!o)return;const{range:w,item:N}=c;await F0(n,w,o,N.name,v),d(null)},e[9]=c,e[10]=o,e[11]=n,e[12]=h):h=e[12];const g=h;let b;e[13]!==o||e[14]!==i||e[15]!==u?(b=async v=>{const{query:w}=v;if(!o)return[];let N=i.getQueryData(u);if(N?i.fetchQuery({queryKey:u,queryFn:()=>$b(o),staleTime:6e4}).catch(O4):N=await i.fetchQuery({queryKey:u,queryFn:()=>$b(o),staleTime:6e4}),!N.prompts)return[];let _=N.prompts;if(w.trim()){const D=w.toLowerCase();_=N.prompts.filter(M=>M.name.toLowerCase().includes(D)||M.title?.toLowerCase().includes(D)||M.description?.toLowerCase().includes(D))}return _},e[13]=o,e[14]=i,e[15]=u,e[16]=b):b=e[16];const E=b;let y;e[17]!==n||e[18]!==E||e[19]!==f||e[20]!==u?(y=T.jsx(AN,{editor:n,char:"/",pluginKey:"promptsDropdownMenu",queryKey:u,queryFn:E,onSelect:f}),e[17]=n,e[18]=E,e[19]=f,e[20]=u,e[21]=y):y=e[21];const S=c?.item??null;let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=()=>d(null),e[22]=k):k=e[22];let x;e[23]!==g||e[24]!==S?(x=T.jsx(hv,{prompt:S,setPrompt:k,onSubmit:g}),e[23]=g,e[24]=S,e[25]=x):x=e[25];let A;return e[26]!==y||e[27]!==x?(A=T.jsxs(T.Fragment,{children:[y,x]}),e[26]=y,e[27]=x,e[28]=A):A=e[28],A};function O4(){}async function L4(t,e,n,r){try{const i=await ER(n,r);R_(t,e,{id:r,name:r,metadata:i.contents,char:"@"})}catch(i){console.error("[resource] Failed to fetch resource:",i),Sn.error("Failed to load resource. Please try again.")}}const D4=t=>{const e=te.c(18),{editor:n,virtualMcpId:r}=t,i=Yx(),{org:a}=ui();let s;e[0]!==a.id||e[1]!==r?(s={connectionId:r,orgId:a.id},e[0]=a.id,e[1]=r,e[2]=s):s=e[2];const o=tg(s);let l;e[3]!==a.id||e[4]!==r?(l=Jm.virtualMcpResources(r,a.id),e[3]=a.id,e[4]=r,e[5]=l):l=e[5];const u=l;let c;e[6]!==o||e[7]!==n?(c=async g=>{const{item:b,range:E}=g;o&&await L4(n,E,o,b.uri)},e[6]=o,e[7]=n,e[8]=c):c=e[8];const d=c;let p;e[9]!==o||e[10]!==i||e[11]!==u?(p=async g=>{const{query:b}=g;if(!o)return[];let E=i.getQueryData(u);if(E?i.fetchQuery({queryKey:u,queryFn:()=>zb(o),staleTime:6e4}).catch(M4):E=await i.fetchQuery({queryKey:u,queryFn:()=>zb(o),staleTime:6e4}),!E.resources)return[];let y=E.resources;if(b.trim()){const S=b.toLowerCase();y=E.resources.filter(k=>k.uri.toLowerCase().includes(S)||k.name?.toLowerCase().includes(S)||k.description?.toLowerCase().includes(S))}return y.map(P4)},e[9]=o,e[10]=i,e[11]=u,e[12]=p):p=e[12];const f=p;let h;return e[13]!==n||e[14]!==f||e[15]!==d||e[16]!==u?(h=T.jsx(AN,{editor:n,char:"@",pluginKey:"resourcesDropdownMenu",queryKey:u,queryFn:f,onSelect:d}),e[13]=n,e[14]=f,e[15]=d,e[16]=u,e[17]=h):h=e[17],h};function M4(){}function P4(t){return{name:t.name??t.uri,title:t.name,description:t.description,uri:t.uri}}const F4=[lN.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1}),oF.configure({placeholder:"Ask anything, / for prompts, @ for resources...",showOnlyWhenEditable:!1}),L_,P_];function B4(t){const e=te.c(22),{tiptapDoc:n,setTiptapDoc:r,selectedModel:i,isStreaming:a,onSubmit:s,children:o}=t,l=a||!i,u=P.useRef(s),c=P.useRef(r),d=n||"",p=!l;let f,h;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={attributes:{class:"prose prose-sm max-w-none focus:outline-none w-full h-full text-[15px] p-[18px]"},handleKeyDown:(_,D)=>D.key==="Enter"&&!D.shiftKey?(D.preventDefault(),u.current?.(),!0):!1},h=_=>{const{editor:D}=_;c.current(D?.getJSON())},e[0]=f,e[1]=h):(f=e[0],h=e[1]);let g;e[2]!==d||e[3]!==p?(g={extensions:F4,content:d,editable:p,editorProps:f,onUpdate:h},e[2]=d,e[3]=p,e[4]=g):g=e[4];let b;e[5]!==l?(b=[l],e[5]=l,e[6]=b):b=e[6];const E=x_(g,b);let y,S;e[7]!==s?(y=()=>{u.current=s},S=[s],e[7]=s,e[8]=y,e[9]=S):(y=e[8],S=e[9]),P.useEffect(y,S);let k,x;e[10]!==r?(x=()=>{c.current=r},k=[r],e[10]=r,e[11]=k,e[12]=x):(k=e[11],x=e[12]),P.useEffect(x,k);let A,v;e[13]!==E||e[14]!==n?(A=()=>{if(E?.isDestroyed)return;const _=JSON.stringify(E?.getJSON()),D=JSON.stringify(n||{type:"doc",content:[]});_!==D&&E.commands.setContent(n||{type:"doc",content:[]})},v=[E,n],e[13]=E,e[14]=n,e[15]=A,e[16]=v):(A=e[15],v=e[16]),P.useEffect(A,v);let w;e[17]!==E?(w={editor:E},e[17]=E,e[18]=w):w=e[18];let N;return e[19]!==o||e[20]!==w?(N=T.jsx(Vo.Provider,{value:w,children:o}),e[19]=o,e[20]=w,e[21]=N):N=e[21],N}function U4(t){const e=te.c(24),{selectedModel:n,isStreaming:r,selectedVirtualMcp:i,ref:a}=t,{editor:s}=v_(),o=i?.id??null,l=r||!n;let u;e[0]!==s?.commands?(u=()=>({focus:()=>{s?.commands.focus()},clear:()=>{s?.commands.clearContent(!0)}}),e[0]=s?.commands,e[1]=u):u=e[1];let c;if(e[2]!==s?(c=[s],e[2]=s,e[3]=c):c=e[3],P.useImperativeHandle(a??null,u,c),!s)return null;const d=l&&"cursor-not-allowed opacity-70",p=l&&"[&_.ProseMirror]:cursor-not-allowed";let f;e[4]!==d||e[5]!==p?(f=ce("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col","[&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[20px] [&_.ProseMirror]:flex-1","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:opacity-50","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0",d,p),e[4]=d,e[5]=p,e[6]=f):f=e[6];let h;e[7]!==s||e[8]!==f?(h=T.jsx(Og,{editor:s,className:f}),e[7]=s,e[8]=f,e[9]=h):h=e[9];let g;e[10]!==s||e[11]!==o?(g=T.jsx(P.Suspense,{fallback:null,children:T.jsx(R4,{editor:s,virtualMcpId:o})}),e[10]=s,e[11]=o,e[12]=g):g=e[12];let b;e[13]!==s||e[14]!==o?(b=T.jsx(P.Suspense,{fallback:null,children:T.jsx(D4,{editor:s,virtualMcpId:o})}),e[13]=s,e[14]=o,e[15]=b):b=e[15];let E;e[16]!==s||e[17]!==n?(E=T.jsx(DP,{editor:s,selectedModel:n}),e[16]=s,e[17]=n,e[18]=E):E=e[18];let y;return e[19]!==h||e[20]!==g||e[21]!==b||e[22]!==E?(y=T.jsxs(T.Fragment,{children:[h,g,b,E]}),e[19]=h,e[20]=g,e[21]=b,e[22]=E,e[23]=y):y=e[23],y}function kN(t){const e=te.c(38),{messages:n}=t;let r,i,a,s,o,l,u,c,d,p,f,h;if(e[0]!==n){h=Symbol.for("react.early_return_sentinel");e:{const k=PR(n);if(!k){h=null;break e}const{totalTokens:x,inputTokens:A,outputTokens:v,cost:w}=k;if(a=w,!x&&!A&&!v){h=null;break e}i=xn;let N;e[13]===Symbol.for("react.memo_cache_sentinel")?(N=T.jsx(uv,{size:12}),e[13]=N):N=e[13];const _=T.jsxs(ze,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground pl-1! h-6 gap-1 whitespace-nowrap shrink-0",children:[N,T.jsx("span",{className:"text-[10px] font-mono tabular-nums",children:x.toLocaleString()})]});e[14]!==_?(f=T.jsx(vn,{asChild:!0,children:_}),e[14]=_,e[15]=f):f=e[15],r=Cn,d="top",p="font-mono text-[11px]",o="grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",e[16]===Symbol.for("react.memo_cache_sentinel")?(l=T.jsx("span",{className:"text-muted",children:"in"}),e[16]=l):l=e[16],u=T.jsx("span",{children:A.toLocaleString()}),e[17]===Symbol.for("react.memo_cache_sentinel")?(c=T.jsx("span",{className:"text-muted",children:"out"}),e[17]=c):c=e[17],s=v.toLocaleString()}e[0]=n,e[1]=r,e[2]=i,e[3]=a,e[4]=s,e[5]=o,e[6]=l,e[7]=u,e[8]=c,e[9]=d,e[10]=p,e[11]=f,e[12]=h}else r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],u=e[7],c=e[8],d=e[9],p=e[10],f=e[11],h=e[12];if(h!==Symbol.for("react.early_return_sentinel"))return h;let g;e[18]!==s?(g=T.jsx("span",{children:s}),e[18]=s,e[19]=g):g=e[19];let b;e[20]!==a?(b=a>0&&T.jsxs(T.Fragment,{children:[T.jsx("span",{className:"text-muted",children:"cost"}),T.jsxs("span",{children:["$",a.toFixed(4)]})]}),e[20]=a,e[21]=b):b=e[21];let E;e[22]!==g||e[23]!==b||e[24]!==o||e[25]!==l||e[26]!==u||e[27]!==c?(E=T.jsxs("div",{className:o,children:[l,u,c,g,b]}),e[22]=g,e[23]=b,e[24]=o,e[25]=l,e[26]=u,e[27]=c,e[28]=E):E=e[28];let y;e[29]!==r||e[30]!==E||e[31]!==d||e[32]!==p?(y=T.jsx(r,{side:d,className:p,children:E}),e[29]=r,e[30]=E,e[31]=d,e[32]=p,e[33]=y):y=e[33];let S;return e[34]!==i||e[35]!==y||e[36]!==f?(S=T.jsxs(i,{children:[f,y]}),e[34]=i,e[35]=y,e[36]=f,e[37]=S):S=e[37],S}function H4(t){const e=te.c(25),{onVirtualMcpChange:n,virtualMcps:r,disabled:i}=t,a=i===void 0?!1:i,[s,o]=P.useState(!1),l=P.useRef(null),{org:u}=ui();let c;e[0]!==u.id?(c=tv(u.id),e[0]=u.id,e[1]=c):c=e[1];const d=c;let p;e[2]!==r?(p=r.filter($4),e[2]=r,e[3]=p):p=e[3];const f=p;let h,g;e[4]!==s?(h=()=>{s&&setTimeout(()=>{l.current?.focus()},0)},g=[s],e[4]=s,e[5]=h,e[6]=g):(h=e[5],g=e[6]),P.useEffect(h,g);let b;e[7]!==n?(b=w=>{n(w),o(!1)},e[7]=n,e[8]=b):b=e[8];const E=b;let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=T.jsx(Xr,{size:16}),e[9]=y):y=e[9];let S;e[10]!==a?(S=T.jsx(vn,{asChild:!0,children:T.jsx(di,{asChild:!0,children:T.jsx(ze,{type:"button",variant:"ghost",size:"icon",className:"size-8 rounded-full",disabled:a,children:y})})}),e[10]=a,e[11]=S):S=e[11];let k;e[12]!==s?(k=!s&&T.jsx(Cn,{side:"top",children:"Decopilot"}),e[12]=s,e[13]=k):k=e[13];let x;e[14]!==S||e[15]!==k?(x=T.jsxs(xn,{children:[S,k]}),e[14]=S,e[15]=k,e[16]=x):x=e[16];let A;e[17]!==d.id||e[18]!==f||e[19]!==E?(A=T.jsx(pi,{className:"w-[550px] p-0 overflow-hidden",align:"start",side:"top",sideOffset:8,children:T.jsx(Dg,{virtualMcps:f,selectedVirtualMcpId:d.id,onVirtualMcpChange:E,searchInputRef:l})}),e[17]=d.id,e[18]=f,e[19]=E,e[20]=A):A=e[20];let v;return e[21]!==s||e[22]!==x||e[23]!==A?(v=T.jsxs(ci,{open:s,onOpenChange:o,children:[x,A]}),e[21]=s,e[22]=x,e[23]=A,e[24]=v):v=e[24],v}function $4(t){return!t.id||!Kr(t.id)}function z4({virtualMcpId:t,virtualMcps:e,onVirtualMcpChange:n,disabled:r=!1}){const[i,a]=P.useState(!1),s=P.useRef(null),o=Kx(),{org:l}=ui(),u=e.find(h=>h.id===t);if(!u||Kr(t))return null;P.useEffect(()=>{i&&setTimeout(()=>{s.current?.focus()},0)},[i]);const c=D_(t),d=h=>{h.stopPropagation(),n(null)},p=h=>{h.stopPropagation(),o({to:"/$org/$project/agents/$agentId",params:{org:l.slug,project:ss,agentId:t}})},f=h=>{n(h),a(!1)};return T.jsxs("div",{className:ce("flex items-center justify-between px-3 py-1.5 rounded-t-xl",c?.bg),children:[T.jsxs(ci,{open:i,onOpenChange:a,children:[T.jsx(di,{asChild:!0,children:T.jsxs("button",{type:"button",disabled:r,className:ce("flex items-center gap-1.5 hover:opacity-80 transition-opacity",r?"cursor-not-allowed opacity-50":"cursor-pointer"),children:[T.jsx(wo,{icon:u.icon,name:u.title,size:"2xs",className:"bg-background rounded-sm",fallbackIcon:u.fallbackIcon??T.jsx(Xr,{size:10})}),T.jsx("span",{className:"text-xs text-white font-normal",children:u.title}),T.jsx(Xh,{size:14,className:"text-white/50"})]})}),T.jsx(pi,{className:"w-[550px] p-0 overflow-hidden",align:"start",side:"top",sideOffset:8,children:T.jsx(Dg,{virtualMcps:e,selectedVirtualMcpId:t,onVirtualMcpChange:f,searchInputRef:s})})]}),T.jsxs("div",{className:"flex items-center gap-1",children:[T.jsx("button",{type:"button",onClick:p,disabled:r,className:ce("flex items-center justify-center p-1 rounded-full transition-colors",r?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-white/10"),"aria-label":"Edit agent",children:T.jsx(NR,{size:14,className:"text-white"})}),T.jsx("button",{type:"button",onClick:d,disabled:r,className:ce("flex items-center justify-center p-1 rounded-full transition-colors",r?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-white/10"),"aria-label":"Reset to default",children:T.jsx(fv,{size:14,className:"text-white"})})]})]})}function q4(){const t=te.c(91),{activeThreadId:e,tiptapDoc:n,setTiptapDoc:r,virtualMcps:i,selectedVirtualMcp:a,setVirtualMcpId:s,modelsConnections:o,selectedModel:l,setSelectedModel:u,selectedMode:c,setSelectedMode:d,messages:p,isStreaming:f,sendMessage:h,stop:g}=vr(),b=P.useRef(null);let E;t[0]!==f||t[1]!==l||t[2]!==n?(E=!f&&!!l&&!tP(n),t[0]=f,t[1]=l,t[2]=n,t[3]=E):E=t[3];const y=E;let S;t[4]!==y||t[5]!==f||t[6]!==h||t[7]!==g||t[8]!==n?(S=Dt=>{Dt?.preventDefault(),f?g():y&&n&&h(n)},t[4]=y,t[5]=f,t[6]=h,t[7]=g,t[8]=n,t[9]=S):S=t[9];const k=S;let x,A,v;if(t[10]!==a){const Dt=a?D_(a.id):null;A="flex flex-col w-full min-h-42 justify-end",t[14]===Symbol.for("react.memo_cache_sentinel")?(v=T.jsx(Wo,{}),t[14]=v):v=t[14],x=ce("relative rounded-xl w-full flex flex-col",a&&"shadow-sm",Dt?.bg),t[10]=a,t[11]=x,t[12]=A,t[13]=v}else x=t[11],A=t[12],v=t[13];let w;t[15]!==f||t[16]!==a||t[17]!==s||t[18]!==i?(w=a?.id&&!Kr(a.id)&&T.jsx(z4,{onVirtualMcpChange:s,virtualMcpId:a.id,virtualMcps:i,disabled:f}),t[15]=f,t[16]=a,t[17]=s,t[18]=i,t[19]=w):w=t[19];const N=!a&&"shadow-sm";let _;t[20]!==N?(_=ce("w-full relative rounded-xl min-h-[130px] flex flex-col border border-border bg-background",N),t[20]=N,t[21]=_):_=t[21];let D;t[22]!==f||t[23]!==l||t[24]!==a?(D=T.jsx("div",{className:"relative flex flex-col gap-2 flex-1",children:T.jsx(U4,{ref:b,selectedModel:l,isStreaming:f,selectedVirtualMcp:a})}),t[22]=f,t[23]=l,t[24]=a,t[25]=D):D=t[25];let M;t[26]!==f||t[27]!==a||t[28]!==s||t[29]!==i?(M=a&&Kr(a.id)?T.jsx(H4,{onVirtualMcpChange:s,virtualMcps:i,disabled:f}):T.jsx(IP,{selectedVirtualMcpId:a?.id??null,onVirtualMcpChange:s,virtualMcps:i,placeholder:"Agent",disabled:f}),t[26]=f,t[27]=a,t[28]=s,t[29]=i,t[30]=M):M=t[30];let q;t[31]!==p?(q=T.jsx(kN,{messages:p}),t[31]=p,t[32]=q):q=t[32];let F;t[33]!==q||t[34]!==M?(F=T.jsxs("div",{className:"flex items-center gap-2 min-w-0 overflow-hidden",children:[M,q]}),t[33]=q,t[34]=M,t[35]=F):F=t[35];const U=l??void 0;let $;t[36]!==o||t[37]!==u||t[38]!==U?($=T.jsx(fR,{selectedModel:U,onModelChange:u,modelsConnections:o,placeholder:"Model",variant:"borderless"}),t[36]=o,t[37]=u,t[38]=U,t[39]=$):$=t[39];let G;t[40]!==f||t[41]!==c||t[42]!==d?(G=T.jsx(CP,{selectedMode:c,onModeChange:d,placeholder:"Mode",variant:"borderless",disabled:f}),t[40]=f,t[41]=c,t[42]=d,t[43]=G):G=t[43];let H;t[44]!==f||t[45]!==l?(H=T.jsx(PP,{selectedModel:l,isStreaming:f}),t[44]=f,t[45]=l,t[46]=H):H=t[46];const J=f?"button":"submit";let I;t[47]!==f||t[48]!==g?(I=Dt=>{f&&(Dt.preventDefault(),Dt.stopPropagation(),g())},t[47]=f,t[48]=g,t[49]=I):I=t[49];const Z=y||f?"default":"ghost",ae=!y&&!f,O=!y&&!f&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed";let re;t[50]!==O?(re=ce("size-8 rounded-full transition-all",O),t[50]=O,t[51]=re):re=t[51];const ne=f?"Stop generating":"Send message (Enter)";let se;t[52]!==f?(se=f?T.jsx(dv,{size:20}):T.jsx(_R,{size:20}),t[52]=f,t[53]=se):se=t[53];let fe;t[54]!==J||t[55]!==I||t[56]!==Z||t[57]!==ae||t[58]!==re||t[59]!==ne||t[60]!==se?(fe=T.jsx(ze,{type:J,onClick:I,variant:Z,size:"icon",disabled:ae,className:re,title:ne,children:se}),t[54]=J,t[55]=I,t[56]=Z,t[57]=ae,t[58]=re,t[59]=ne,t[60]=se,t[61]=fe):fe=t[61];let xe;t[62]!==$||t[63]!==G||t[64]!==H||t[65]!==fe?(xe=T.jsxs("div",{className:"flex items-center gap-1",children:[$,G,H,fe]}),t[62]=$,t[63]=G,t[64]=H,t[65]=fe,t[66]=xe):xe=t[66];let Oe;t[67]!==F||t[68]!==xe?(Oe=T.jsxs("div",{className:"flex items-center justify-between p-2.5",children:[F,xe]}),t[67]=F,t[68]=xe,t[69]=Oe):Oe=t[69];let Le;t[70]!==k||t[71]!==Oe||t[72]!==_||t[73]!==D?(Le=T.jsxs("form",{onSubmit:k,className:_,children:[D,Oe]}),t[70]=k,t[71]=Oe,t[72]=_,t[73]=D,t[74]=Le):Le=t[74];let Me;t[75]!==e||t[76]!==k||t[77]!==f||t[78]!==l||t[79]!==r||t[80]!==Le||t[81]!==n?(Me=T.jsx("div",{className:"p-0.5",children:T.jsx(B4,{tiptapDoc:n,setTiptapDoc:r,selectedModel:l,isStreaming:f,onSubmit:k,children:Le},e)}),t[75]=e,t[76]=k,t[77]=f,t[78]=l,t[79]=r,t[80]=Le,t[81]=n,t[82]=Me):Me=t[82];let St;t[83]!==x||t[84]!==Me||t[85]!==w?(St=T.jsxs("div",{className:x,children:[w,Me]}),t[83]=x,t[84]=Me,t[85]=w,t[86]=St):St=t[86];let tt;return t[87]!==St||t[88]!==A||t[89]!==v?(tt=T.jsxs("div",{className:A,children:[v,St]}),t[87]=St,t[88]=A,t[89]=v,t[90]=tt):tt=t[90],tt}function Yg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ir=Yg();function xN(t){Ir=t}var Ji={exec:()=>null};function Se(t,e=""){let n=typeof t=="string"?t:t.source;const r={replace:(i,a)=>{let s=typeof a=="string"?a:a.source;return s=s.replace(bt.caret,"$1"),n=n.replace(i,s),r},getRegex:()=>new RegExp(n,e)};return r}var bt={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},j4=/^(?:[ \t]*(?:\n|$))+/,G4=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,V4=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,wa=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,W4=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Kg=/(?:[*+-]|\d{1,9}[.)])/,vN=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,CN=Se(vN).replace(/bull/g,Kg).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Y4=Se(vN).replace(/bull/g,Kg).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Xg=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,K4=/^[^\n]+/,Zg=/(?!\s*\])(?:\\.|[^\[\]\\])+/,X4=Se(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Zg).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Z4=Se(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Kg).getRegex(),Ko="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Qg=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Q4=Se("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Qg).replace("tag",Ko).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),_N=Se(Xg).replace("hr",wa).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ko).getRegex(),J4=Se(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",_N).getRegex(),Jg={blockquote:J4,code:G4,def:X4,fences:V4,heading:W4,hr:wa,html:Q4,lheading:CN,list:Z4,newline:j4,paragraph:_N,table:Ji,text:K4},B0=Se("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",wa).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ko).getRegex(),e6={...Jg,lheading:Y4,table:B0,paragraph:Se(Xg).replace("hr",wa).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",B0).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ko).getRegex()},t6={...Jg,html:Se(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Qg).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ji,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Se(Xg).replace("hr",wa).replace("heading",` *#{1,6} *[^
|
|
140
|
+
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=a=>{const s=bm(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,l)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:l}),customNestedParser:r},n);return s?[{type:"taskList",raw:s.raw,items:s.items}]:n.blockTokens(a)},i=bm(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,s)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:s}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Ue.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Q_.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(J_.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(aN.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(oN.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(dB.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(pB.configure(this.options.taskList)),t}});var v0=" ",fB=" ",hB=Tt.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",je(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===v0||r[0].text===fB)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?v0:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),mB=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,gB=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,bB=_r.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",je(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ri({find:mB,type:this.type})]},addPasteRules(){return[Ar({find:gB,type:this.type})]}}),EB=Tt.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),yB=_r.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",je(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const a=i[2].trim();return{type:"underline",raw:i[0],text:a,tokens:n.inlineTokens(a)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),TB=Ue.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(hF.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(uF.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Q_.configure(this.options.bulletList)),this.options.code!==!1&&i.push(bF.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(TF.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(SF.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(tF.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(nF.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(AF.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(kF.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(sF.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(xF.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(IF.configure(this.options.italic)),this.options.listItem!==!1&&i.push(J_.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(aN.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(eB.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(oN.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(hB.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(bB.configure(this.options.strike)),this.options.text!==!1&&i.push(EB.configure(this.options.text)),this.options.underline!==!1&&i.push(yB.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(aF.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),lN=TB;var SB=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],Im=SB.join(","),uN=typeof Element>"u",ya=uN?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,fo=!uN&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t?.ownerDocument},ho=function(e,n){var r;n===void 0&&(n=!0);var i=e==null||(r=e.getAttribute)===null||r===void 0?void 0:r.call(e,"inert"),a=i===""||i==="true",s=a||n&&e&&(typeof e.closest=="function"?e.closest("[inert]"):ho(e.parentNode));return s},AB=function(e){var n,r=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"contenteditable");return r===""||r==="true"},kB=function(e,n,r){if(ho(e))return[];var i=Array.prototype.slice.apply(e.querySelectorAll(Im));return n&&ya.call(e,Im)&&i.unshift(e),i=i.filter(r),i},wm=function(e,n,r){for(var i=[],a=Array.from(e);a.length;){var s=a.shift();if(!ho(s,!1))if(s.tagName==="SLOT"){var o=s.assignedElements(),l=o.length?o:s.children,u=wm(l,!0,r);r.flatten?i.push.apply(i,u):i.push({scopeParent:s,candidates:u})}else{var c=ya.call(s,Im);c&&r.filter(s)&&(n||!e.includes(s))&&i.push(s);var d=s.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(s),p=!ho(d,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(s));if(d&&p){var f=wm(d===!0?s.children:d.children,!0,r);r.flatten?i.push.apply(i,f):i.push({scopeParent:s,candidates:f})}else a.unshift.apply(a,s.children)}}return i},cN=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},dN=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||AB(e))&&!cN(e)?0:e.tabIndex},xB=function(e,n){var r=dN(e);return r<0&&n&&!cN(e)?0:r},vB=function(e,n){return e.tabIndex===n.tabIndex?e.documentOrder-n.documentOrder:e.tabIndex-n.tabIndex},pN=function(e){return e.tagName==="INPUT"},CB=function(e){return pN(e)&&e.type==="hidden"},_B=function(e){var n=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(r){return r.tagName==="SUMMARY"});return n},NB=function(e,n){for(var r=0;r<e.length;r++)if(e[r].checked&&e[r].form===n)return e[r]},IB=function(e){if(!e.name)return!0;var n=e.form||fo(e),r=function(o){return n.querySelectorAll('input[type="radio"][name="'+o+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=r(window.CSS.escape(e.name));else try{i=r(e.name)}catch(s){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",s.message),!1}var a=NB(i,e.form);return!a||a===e},wB=function(e){return pN(e)&&e.type==="radio"},RB=function(e){return wB(e)&&!IB(e)},OB=function(e){var n,r=e&&fo(e),i=(n=r)===null||n===void 0?void 0:n.host,a=!1;if(r&&r!==e){var s,o,l;for(a=!!((s=i)!==null&&s!==void 0&&(o=s.ownerDocument)!==null&&o!==void 0&&o.contains(i)||e!=null&&(l=e.ownerDocument)!==null&&l!==void 0&&l.contains(e));!a&&i;){var u,c,d;r=fo(i),i=(u=r)===null||u===void 0?void 0:u.host,a=!!((c=i)!==null&&c!==void 0&&(d=c.ownerDocument)!==null&&d!==void 0&&d.contains(i))}}return a},C0=function(e){var n=e.getBoundingClientRect(),r=n.width,i=n.height;return r===0&&i===0},LB=function(e,n){var r=n.displayCheck,i=n.getShadowRoot;if(r==="full-native"&&"checkVisibility"in e){var a=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!a}if(getComputedStyle(e).visibility==="hidden")return!0;var s=ya.call(e,"details>summary:first-of-type"),o=s?e.parentElement:e;if(ya.call(o,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof i=="function"){for(var l=e;e;){var u=e.parentElement,c=fo(e);if(u&&!u.shadowRoot&&i(u)===!0)return C0(e);e.assignedSlot?e=e.assignedSlot:!u&&c!==e.ownerDocument?e=c.host:e=u}e=l}if(OB(e))return!e.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return C0(e);return!1},DB=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var n=e.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var i=n.children.item(r);if(i.tagName==="LEGEND")return ya.call(n,"fieldset[disabled] *")?!0:!i.contains(e)}return!0}n=n.parentElement}return!1},MB=function(e,n){return!(n.disabled||CB(n)||LB(n,e)||_B(n)||DB(n))},_0=function(e,n){return!(RB(n)||dN(n)<0||!MB(e,n))},PB=function(e){var n=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},fN=function(e){var n=[],r=[];return e.forEach(function(i,a){var s=!!i.scopeParent,o=s?i.scopeParent:i,l=xB(o,s),u=s?fN(i.candidates):o;l===0?s?n.push.apply(n,u):n.push(o):r.push({documentOrder:a,tabIndex:l,item:i,isScope:s,content:u})}),r.sort(vB).reduce(function(i,a){return a.isScope?i.push.apply(i,a.content):i.push(a.content),i},[]).concat(n)},hN=function(e,n){n=n||{};var r;return n.getShadowRoot?r=wm([e],n.includeContainer,{filter:_0.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:PB}):r=kB(e,n.includeContainer,_0.bind(null,n)),fN(r)};function FB(){return/apple/i.test(navigator.vendor)}const N0="data-floating-ui-focusable";function BB(t){let e=t.activeElement;for(;((n=e)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;e=e.shadowRoot.activeElement}return e}function Rm(t,e){if(!t||!e)return!1;const n=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(n&&Xw(n)){let r=e;for(;r;){if(t===r)return!0;r=r.parentNode||r.host}}return!1}function Ni(t){return"composedPath"in t?t.composedPath()[0]:t.target}function ql(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const n=t;return n.target!=null&&e.contains(n.target)}function UB(t){return t.matches("html,body")}function Ta(t){return t?.ownerDocument||document}function HB(t){return t?t.hasAttribute(N0)?t:t.querySelector("["+N0+"]")||t:null}function fs(t,e,n){return n===void 0&&(n=!0),t.filter(i=>{var a;return i.parentId===e&&(!n||((a=i.context)==null?void 0:a.open))}).flatMap(i=>[i,...fs(t,i.id,n)])}function $B(t){return"nativeEvent"in t}var zB=typeof document<"u",qB=function(){},gr=zB?P.useLayoutEffect:qB;const jB={...Wx},GB=jB.useInsertionEffect,VB=GB||(t=>t());function $r(t){const e=P.useRef(()=>{});return VB(()=>{e.current=t}),P.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}const mN=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function gN(t,e){const n=hN(t,mN()),r=n.length;if(r===0)return;const i=BB(Ta(t)),a=n.indexOf(i),s=a===-1?e===1?0:r-1:a+e;return n[s]}function WB(t){return gN(Ta(t).body,1)||t}function YB(t){return gN(Ta(t).body,-1)||t}function jl(t,e){const n=e||t.currentTarget,r=t.relatedTarget;return!r||!Rm(n,r)}function KB(t){hN(t,mN()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function I0(t){t.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}const XB="data-floating-ui-focusable",w0="active",R0="selected",ZB={...Wx};let O0=!1,QB=0;const L0=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+QB++;function JB(){const[t,e]=P.useState(()=>O0?L0():void 0);return gr(()=>{t==null&&e(L0())},[]),P.useEffect(()=>{O0=!0},[]),t}const e4=ZB.useId,Vg=e4||JB;function t4(){const t=new Map;return{emit(e,n){var r;(r=t.get(e))==null||r.forEach(i=>i(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var r;(r=t.get(e))==null||r.delete(n)}}}const n4=P.createContext(null),r4=P.createContext(null),bN=()=>{var t;return((t=P.useContext(n4))==null?void 0:t.id)||null},EN=()=>P.useContext(r4);function Wg(t){return"data-floating-ui-"+t}const i4={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},D0=P.forwardRef(function(e,n){const[r,i]=P.useState();gr(()=>{FB()&&i("button")},[]);const a={ref:n,tabIndex:0,role:r,"aria-hidden":r?void 0:!0,[Wg("focus-guard")]:"",style:i4};return T.jsx("span",{...e,...a})}),a4={clipPath:"inset(50%)",position:"fixed",top:0,left:0},yN=P.createContext(null),M0=Wg("portal");function s4(t){t===void 0&&(t={});const{id:e,root:n}=t,r=Vg(),i=l4(),[a,s]=P.useState(null),o=P.useRef(null);return gr(()=>()=>{a?.remove(),queueMicrotask(()=>{o.current=null})},[a]),gr(()=>{if(!r||o.current)return;const l=e?document.getElementById(e):null;if(!l)return;const u=document.createElement("div");u.id=r,u.setAttribute(M0,""),l.appendChild(u),o.current=u,s(u)},[e,r]),gr(()=>{if(n===null||!r||o.current)return;let l=n||i?.portalNode;l&&!nR(l)&&(l=l.current),l=l||document.body;let u=null;e&&(u=document.createElement("div"),u.id=e,l.appendChild(u));const c=document.createElement("div");c.id=r,c.setAttribute(M0,""),l=u||l,l.appendChild(c),o.current=c,s(c)},[e,n,r,i]),a}function o4(t){const{children:e,id:n,root:r,preserveTabOrder:i=!0}=t,a=s4({id:n,root:r}),[s,o]=P.useState(null),l=P.useRef(null),u=P.useRef(null),c=P.useRef(null),d=P.useRef(null),p=s?.modal,f=s?.open,h=!!s&&!s.modal&&s.open&&i&&!!(r||a);return P.useEffect(()=>{if(!a||!i||p)return;function g(b){a&&jl(b)&&(b.type==="focusin"?I0:KB)(a)}return a.addEventListener("focusin",g,!0),a.addEventListener("focusout",g,!0),()=>{a.removeEventListener("focusin",g,!0),a.removeEventListener("focusout",g,!0)}},[a,i,p]),P.useEffect(()=>{a&&(f||I0(a))},[f,a]),T.jsxs(yN.Provider,{value:P.useMemo(()=>({preserveTabOrder:i,beforeOutsideRef:l,afterOutsideRef:u,beforeInsideRef:c,afterInsideRef:d,portalNode:a,setFocusManagerState:o}),[i,a]),children:[h&&a&&T.jsx(D0,{"data-type":"outside",ref:l,onFocus:g=>{if(jl(g,a)){var b;(b=c.current)==null||b.focus()}else{const E=s?s.domReference:null,y=YB(E);y?.focus()}}}),h&&a&&T.jsx("span",{"aria-owns":a.id,style:a4}),a&&Vx.createPortal(e,a),h&&a&&T.jsx(D0,{"data-type":"outside",ref:u,onFocus:g=>{if(jl(g,a)){var b;(b=d.current)==null||b.focus()}else{const E=s?s.domReference:null,y=WB(E);y?.focus(),s?.closeOnFocusOut&&s?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const l4=()=>P.useContext(yN),u4={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},c4={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},P0=t=>{var e,n;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(n=t?.outsidePress)!=null?n:!0}};function d4(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,elements:i,dataRef:a}=t,{enabled:s=!0,escapeKey:o=!0,outsidePress:l=!0,outsidePressEvent:u="pointerdown",referencePress:c=!1,referencePressEvent:d="pointerdown",ancestorScroll:p=!1,bubbles:f,capture:h}=e,g=EN(),b=$r(typeof l=="function"?l:()=>!1),E=typeof l=="function"?b:l,y=P.useRef(!1),{escapeKey:S,outsidePress:k}=P0(f),{escapeKey:x,outsidePress:A}=P0(h),v=P.useRef(!1),w=$r(F=>{var U;if(!n||!s||!o||F.key!=="Escape"||v.current)return;const $=(U=a.current.floatingContext)==null?void 0:U.nodeId,G=g?fs(g.nodesRef.current,$):[];if(!S&&(F.stopPropagation(),G.length>0)){let H=!0;if(G.forEach(J=>{var I;if((I=J.context)!=null&&I.open&&!J.context.dataRef.current.__escapeKeyBubbles){H=!1;return}}),!H)return}r(!1,$B(F)?F.nativeEvent:F,"escape-key")}),N=$r(F=>{var U;const $=()=>{var G;w(F),(G=Ni(F))==null||G.removeEventListener("keydown",$)};(U=Ni(F))==null||U.addEventListener("keydown",$)}),_=$r(F=>{var U;const $=a.current.insideReactTree;a.current.insideReactTree=!1;const G=y.current;if(y.current=!1,u==="click"&&G||$||typeof E=="function"&&!E(F))return;const H=Ni(F),J="["+Wg("inert")+"]",I=Ta(i.floating).querySelectorAll(J);let Z=nn(H)?H:null;for(;Z&&!ml(Z);){const ne=Jw(Z);if(ml(ne)||!nn(ne))break;Z=ne}if(I.length&&nn(H)&&!UB(H)&&!Rm(H,i.floating)&&Array.from(I).every(ne=>!Rm(Z,ne)))return;if(eR(H)&&q){const ne=ml(H),se=tR(H),fe=/auto|scroll/,xe=ne||fe.test(se.overflowX),Oe=ne||fe.test(se.overflowY),Le=xe&&H.clientWidth>0&&H.scrollWidth>H.clientWidth,Me=Oe&&H.clientHeight>0&&H.scrollHeight>H.clientHeight,St=se.direction==="rtl",tt=Me&&(St?F.offsetX<=H.offsetWidth-H.clientWidth:F.offsetX>H.clientWidth),Dt=Le&&F.offsetY>H.clientHeight;if(tt||Dt)return}const ae=(U=a.current.floatingContext)==null?void 0:U.nodeId,O=g&&fs(g.nodesRef.current,ae).some(ne=>{var se;return ql(F,(se=ne.context)==null?void 0:se.elements.floating)});if(ql(F,i.floating)||ql(F,i.domReference)||O)return;const re=g?fs(g.nodesRef.current,ae):[];if(re.length>0){let ne=!0;if(re.forEach(se=>{var fe;if((fe=se.context)!=null&&fe.open&&!se.context.dataRef.current.__outsidePressBubbles){ne=!1;return}}),!ne)return}r(!1,F,"outside-press")}),D=$r(F=>{var U;const $=()=>{var G;_(F),(G=Ni(F))==null||G.removeEventListener(u,$)};(U=Ni(F))==null||U.addEventListener(u,$)});P.useEffect(()=>{if(!n||!s)return;a.current.__escapeKeyBubbles=S,a.current.__outsidePressBubbles=k;let F=-1;function U(I){r(!1,I,"ancestor-scroll")}function $(){window.clearTimeout(F),v.current=!0}function G(){F=window.setTimeout(()=>{v.current=!1},Qw()?5:0)}const H=Ta(i.floating);o&&(H.addEventListener("keydown",x?N:w,x),H.addEventListener("compositionstart",$),H.addEventListener("compositionend",G)),E&&H.addEventListener(u,A?D:_,A);let J=[];return p&&(nn(i.domReference)&&(J=hl(i.domReference)),nn(i.floating)&&(J=J.concat(hl(i.floating))),!nn(i.reference)&&i.reference&&i.reference.contextElement&&(J=J.concat(hl(i.reference.contextElement)))),J=J.filter(I=>{var Z;return I!==((Z=H.defaultView)==null?void 0:Z.visualViewport)}),J.forEach(I=>{I.addEventListener("scroll",U,{passive:!0})}),()=>{o&&(H.removeEventListener("keydown",x?N:w,x),H.removeEventListener("compositionstart",$),H.removeEventListener("compositionend",G)),E&&H.removeEventListener(u,A?D:_,A),J.forEach(I=>{I.removeEventListener("scroll",U)}),window.clearTimeout(F)}},[a,i,o,E,u,n,r,p,s,S,k,w,x,N,_,A,D]),P.useEffect(()=>{a.current.insideReactTree=!1},[a,E,u]);const M=P.useMemo(()=>({onKeyDown:w,...c&&{[u4[d]]:F=>{r(!1,F.nativeEvent,"reference-press")},...d!=="click"&&{onClick(F){r(!1,F.nativeEvent,"reference-press")}}}}),[w,r,c,d]),q=P.useMemo(()=>({onKeyDown:w,onMouseDown(){y.current=!0},onMouseUp(){y.current=!0},[c4[u]]:()=>{a.current.insideReactTree=!0}}),[w,u,a]);return P.useMemo(()=>s?{reference:M,floating:q}:{},[s,M,q])}function p4(t){const{open:e=!1,onOpenChange:n,elements:r}=t,i=Vg(),a=P.useRef({}),[s]=P.useState(()=>t4()),o=bN()!=null,[l,u]=P.useState(r.reference),c=$r((f,h,g)=>{a.current.openEvent=f?h:void 0,s.emit("openchange",{open:f,event:h,reason:g,nested:o}),n?.(f,h,g)}),d=P.useMemo(()=>({setPositionReference:u}),[]),p=P.useMemo(()=>({reference:l||r.reference||null,floating:r.floating||null,domReference:r.reference}),[l,r.reference,r.floating]);return P.useMemo(()=>({dataRef:a,open:e,onOpenChange:c,elements:p,events:s,floatingId:i,refs:d}),[e,c,p,s,i,d])}function f4(t){t===void 0&&(t={});const{nodeId:e}=t,n=p4({...t,elements:{reference:null,floating:null,...t.elements}}),r=t.rootContext||n,i=r.elements,[a,s]=P.useState(null),[o,l]=P.useState(null),c=i?.domReference||a,d=P.useRef(null),p=EN();gr(()=>{c&&(d.current=c)},[c]);const f=Zw({...t,elements:{...i,...o&&{reference:o}}}),h=P.useCallback(S=>{const k=nn(S)?{getBoundingClientRect:()=>S.getBoundingClientRect(),getClientRects:()=>S.getClientRects(),contextElement:S}:S;l(k),f.refs.setReference(k)},[f.refs]),g=P.useCallback(S=>{(nn(S)||S===null)&&(d.current=S,s(S)),(nn(f.refs.reference.current)||f.refs.reference.current===null||S!==null&&!nn(S))&&f.refs.setReference(S)},[f.refs]),b=P.useMemo(()=>({...f.refs,setReference:g,setPositionReference:h,domReference:d}),[f.refs,g,h]),E=P.useMemo(()=>({...f.elements,domReference:c}),[f.elements,c]),y=P.useMemo(()=>({...f,...r,refs:b,elements:E,nodeId:e}),[f,b,E,e,r]);return gr(()=>{r.dataRef.current.floatingContext=y;const S=p?.nodesRef.current.find(k=>k.id===e);S&&(S.context=y)}),P.useMemo(()=>({...f,context:y,refs:b,elements:E}),[f,b,E,y])}function Gl(t,e,n){const r=new Map,i=n==="item";let a=t;if(i&&t){const{[w0]:s,[R0]:o,...l}=t;a=l}return{...n==="floating"&&{tabIndex:-1,[XB]:""},...a,...e.map(s=>{const o=s?s[n]:null;return typeof o=="function"?t?o(t):null:o}).concat(t).reduce((s,o)=>(o&&Object.entries(o).forEach(l=>{let[u,c]=l;if(!(i&&[w0,R0].includes(u)))if(u.indexOf("on")===0){if(r.has(u)||r.set(u,[]),typeof c=="function"){var d;(d=r.get(u))==null||d.push(c),s[u]=function(){for(var p,f=arguments.length,h=new Array(f),g=0;g<f;g++)h[g]=arguments[g];return(p=r.get(u))==null?void 0:p.map(b=>b(...h)).find(b=>b!==void 0)}}}else s[u]=c}),s),{})}}function h4(t){t===void 0&&(t=[]);const e=t.map(o=>o?.reference),n=t.map(o=>o?.floating),r=t.map(o=>o?.item),i=P.useCallback(o=>Gl(o,t,"reference"),e),a=P.useCallback(o=>Gl(o,t,"floating"),n),s=P.useCallback(o=>Gl(o,t,"item"),r);return P.useMemo(()=>({getReferenceProps:i,getFloatingProps:a,getItemProps:s}),[i,a,s])}const m4=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function g4(t,e){var n,r;e===void 0&&(e={});const{open:i,elements:a,floatingId:s}=t,{enabled:o=!0,role:l="dialog"}=e,u=Vg(),c=((n=a.domReference)==null?void 0:n.id)||u,d=P.useMemo(()=>{var y;return((y=HB(a.floating))==null?void 0:y.id)||s},[a.floating,s]),p=(r=m4.get(l))!=null?r:l,h=bN()!=null,g=P.useMemo(()=>p==="tooltip"||l==="label"?{["aria-"+(l==="label"?"labelledby":"describedby")]:i?d:void 0}:{"aria-expanded":i?"true":"false","aria-haspopup":p==="alertdialog"?"dialog":p,"aria-controls":i?d:void 0,...p==="listbox"&&{role:"combobox"},...p==="menu"&&{id:c},...p==="menu"&&h&&{role:"menuitem"},...l==="select"&&{"aria-autocomplete":"none"},...l==="combobox"&&{"aria-autocomplete":"list"}},[p,d,h,i,c,l]),b=P.useMemo(()=>{const y={id:d,...p&&{role:p}};return p==="tooltip"||l==="label"?y:{...y,...p==="menu"&&{"aria-labelledby":c}}},[p,d,c,l]),E=P.useCallback(y=>{let{active:S,selected:k}=y;const x={role:"option",...S&&{id:d+"-fui-option"}};switch(l){case"select":case"combobox":return{...x,"aria-selected":k}}return{}},[d,l]);return P.useMemo(()=>o?{reference:g,floating:b,item:E}:{},[o,g,b,E])}function b4(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:s,$position:o}=t,l=r&&!i,u=zM(n),c=new RegExp(`\\s${u}$`),d=s?"^":"",p=i?"":u,f=l?new RegExp(`${d}${u}.*?(?=\\s${p}|$)`,"gm"):new RegExp(`${d}(?:^)?${u}[^\\s${p}]*`,"gm"),h=((e=o.nodeBefore)==null?void 0:e.isText)&&o.nodeBefore.text;if(!h)return null;const g=o.pos-h.length,b=Array.from(h.matchAll(f)).pop();if(!b||b.input===void 0||b.index===void 0)return null;const E=b.input.slice(Math.max(0,b.index-1),b.index),y=new RegExp(`^[${a?.join("")}\0]?$`).test(E);if(a!==null&&!y)return null;const S=g+b.index;let k=S+b[0].length;return l&&c.test(h.slice(k-1,k+1))&&(b[0]+=" ",k+=1),S<o.pos&&k>=o.pos?{range:{from:S,to:k},query:b[0].slice(n.length),text:b[0]}:null}var E4=new De("suggestion");function y4({pluginKey:t=E4,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[" "],startOfLine:s=!1,decorationTag:o="span",decorationClass:l="suggestion",decorationContent:u="",decorationEmptyClass:c="is-empty",command:d=()=>null,items:p=()=>[],render:f=()=>({}),allow:h=()=>!0,findSuggestionMatch:g=b4,shouldShow:b}){let E;const y=f?.(),S=()=>{const v=e.state.selection.$anchor.pos,w=e.view.coordsAtPos(v),{top:N,right:_,bottom:D,left:M}=w;try{return new DOMRect(M,N,_-M,D-N)}catch{return null}},k=(v,w)=>w?()=>{const N=t.getState(e.state),_=N?.decorationId,D=v.dom.querySelector(`[data-decoration-id="${_}"]`);return D?.getBoundingClientRect()||null}:S;function x(v,w){var N;try{const D=t.getState(v.state),M=D?.decorationId?v.dom.querySelector(`[data-decoration-id="${D.decorationId}"]`):null,q={editor:e,range:D?.range||{from:0,to:0},query:D?.query||null,text:D?.text||null,items:[],command:F=>d({editor:e,range:D?.range||{from:0,to:0},props:F}),decorationNode:M,clientRect:k(v,M)};(N=y?.onExit)==null||N.call(y,q)}catch{}const _=v.state.tr.setMeta(w,{exit:!0});v.dispatch(_)}const A=new Ie({key:t,view(){return{update:async(v,w)=>{var N,_,D,M,q,F,U;const $=(N=this.key)==null?void 0:N.getState(w),G=(_=this.key)==null?void 0:_.getState(v.state),H=$.active&&G.active&&$.range.from!==G.range.from,J=!$.active&&G.active,I=$.active&&!G.active,Z=!J&&!I&&$.query!==G.query,ae=J||H&&Z,O=Z||H,re=I||H&&Z;if(!ae&&!O&&!re)return;const ne=re&&!ae?$:G,se=v.dom.querySelector(`[data-decoration-id="${ne.decorationId}"]`);E={editor:e,range:ne.range,query:ne.query,text:ne.text,items:[],command:fe=>d({editor:e,range:ne.range,props:fe}),decorationNode:se,clientRect:k(v,se)},ae&&((D=y?.onBeforeStart)==null||D.call(y,E)),O&&((M=y?.onBeforeUpdate)==null||M.call(y,E)),(O||ae)&&(E.items=await p({editor:e,query:ne.query})),re&&((q=y?.onExit)==null||q.call(y,E)),O&&((F=y?.onUpdate)==null||F.call(y,E)),ae&&((U=y?.onStart)==null||U.call(y,E))},destroy:()=>{var v;E&&((v=y?.onExit)==null||v.call(y,E))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(v,w,N,_){const{isEditable:D}=e,{composing:M}=e.view,{selection:q}=v,{empty:F,from:U}=q,$={...w},G=v.getMeta(t);if(G&&G.exit)return $.active=!1,$.decorationId=null,$.range={from:0,to:0},$.query=null,$.text=null,$;if($.composing=M,D&&(F||e.view.composing)){(U<w.range.from||U>w.range.to)&&!M&&!w.composing&&($.active=!1);const H=g({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:s,$position:q.$from}),J=`id_${Math.floor(Math.random()*4294967295)}`;H&&h({editor:e,state:_,range:H.range,isActive:w.active})&&(!b||b({editor:e,range:H.range,query:H.query,text:H.text,transaction:v}))?($.active=!0,$.decorationId=w.decorationId?w.decorationId:J,$.range=H.range,$.query=H.query,$.text=H.text):$.active=!1}else $.active=!1;return $.active||($.decorationId=null,$.range={from:0,to:0},$.query=null,$.text=null),$}},props:{handleKeyDown(v,w){var N,_,D,M;const{active:q,range:F}=A.getState(v.state);if(!q)return!1;if(w.key==="Escape"||w.key==="Esc"){const $=A.getState(v.state),G=(N=E?.decorationNode)!=null?N:null,H=G??($?.decorationId?v.dom.querySelector(`[data-decoration-id="${$.decorationId}"]`):null);if(((_=y?.onKeyDown)==null?void 0:_.call(y,{view:v,event:w,range:$.range}))||!1)return!0;const I={editor:e,range:$.range,query:$.query,text:$.text,items:[],command:Z=>d({editor:e,range:$.range,props:Z}),decorationNode:H,clientRect:H?()=>H.getBoundingClientRect()||null:null};return(D=y?.onExit)==null||D.call(y,I),x(v,t),!0}return((M=y?.onKeyDown)==null?void 0:M.call(y,{view:v,event:w,range:F}))||!1},decorations(v){const{active:w,range:N,decorationId:_,query:D}=A.getState(v);if(!w)return null;const M=!D?.length,q=[l];return M&&q.push(c),Re.create(v.doc,[it.inline(N.from,N.to,{nodeName:o,class:q.join(" "),"data-decoration-id":_,"data-decoration-content":u})])}}});return A}function T4(t){const e=te.c(26),{editor:n,query:r,items:i,onSelect:a,onClose:s}=t,[o,l]=P.useState(0),u=P.useRef(i),c=P.useRef(o),d=P.useRef(a),p=P.useRef(s),f=P.useDeferredValue(r);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{l(0)},e[0]=h):h=e[0];let g;e[1]!==f?(g=[f],e[1]=f,e[2]=g):g=e[2],P.useEffect(h,g);let b,E;e[3]!==i.length||e[4]!==o?(b=()=>{o>=i.length&&i.length>0&&l(0)},E=[i.length,o],e[3]=i.length,e[4]=o,e[5]=b,e[6]=E):(b=e[5],E=e[6]),P.useEffect(b,E);let y,S;e[7]!==i?(y=()=>{u.current=i},S=[i],e[7]=i,e[8]=y,e[9]=S):(y=e[8],S=e[9]),P.useEffect(y,S);let k,x;e[10]!==o?(k=()=>{c.current=o},x=[o],e[10]=o,e[11]=k,e[12]=x):(k=e[11],x=e[12]),P.useEffect(k,x);let A,v;e[13]!==a?(v=()=>{d.current=a},A=[a],e[13]=a,e[14]=A,e[15]=v):(A=e[14],v=e[15]),P.useEffect(v,A);let w,N;e[16]!==s?(w=()=>{p.current=s},N=[s],e[16]=s,e[17]=w,e[18]=N):(w=e[17],N=e[18]),P.useEffect(w,N);let _;e[19]!==n.isDestroyed||e[20]!==n.view.dom?(_=()=>{const F=n.view.dom;if(n?.isDestroyed||!F)return;const U=G=>{const H=u.current;if(!H.length)return!1;const J=()=>l(Z=>(Z+1)%H.length),I=()=>l(Z=>(Z-1+H.length)%H.length);switch(G.key){case"ArrowUp":return G.preventDefault(),I(),!0;case"ArrowDown":return G.preventDefault(),J(),!0;case"Tab":return G.preventDefault(),G.shiftKey?I():J(),!0;case"Home":return G.preventDefault(),l(0),!0;case"End":return G.preventDefault(),l(H.length-1),!0;case"Enter":{if(G.isComposing)return!1;G.preventDefault();const Z=c.current;return Z!==-1&&H[Z]&&d.current?.(H[Z],Z),!0}case"Escape":return G.preventDefault(),p.current?.(),!0;default:return!1}},$=G=>{U(G)};return F.addEventListener("keydown",$,!0),()=>{F?.removeEventListener("keydown",$,!0)}},e[19]=n.isDestroyed,e[20]=n.view.dom,e[21]=_):_=e[21];let D;e[22]!==n?(D=[n],e[22]=n,e[23]=D):D=e[23],P.useEffect(_,D);const M=i.length?o:void 0;let q;return e[24]!==M?(q={selectedIndex:M,setSelectedIndex:l},e[24]=M,e[25]=q):q=e[25],q}function S4(t,e){switch(e.type){case"SET_SELECTED_ITEM":return{...t,selectedItem:e.payload};case"ON_START":return{...t,open:!0,selectedItem:null,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_UPDATE":return{...t,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_EXIT":return{open:!1,element:null,query:"",range:null,selectedItem:null};default:return t}}const TN=P.createContext(void 0);function SN(){const t=P.useContext(TN);if(!t)throw new Error("useSuggestionContext must be used within a SuggestionContext.Provider");return t}function A4(t){const e=te.c(8),{editor:n,char:r,pluginKey:i}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={open:!1,element:null,query:"",range:null,selectedItem:null},e[0]=a):a=e[0];const[s,o]=P.useReducer(S4,a);let l,u;e[1]!==r||e[2]!==n||e[3]!==i?(l=()=>{if(n?.isDestroyed)return;const d=i instanceof De?i:new De(i);n.state.plugins.find(h=>h.spec.key===d)&&n.unregisterPlugin(d);const f=y4({pluginKey:d,editor:n,char:r,allow(h){const g=n.state.doc.resolve(h.range.from);for(let b=g.depth;b>0;b--)if(g.node(b).type.name==="image")return!1;return!0},command(){},render:()=>({onStart:h=>{o({type:"ON_START",payload:{element:h.decorationNode??null,query:h.query,range:h.range}})},onUpdate:h=>{o({type:"ON_UPDATE",payload:{element:h.decorationNode??null,query:h.query,range:h.range}})},onKeyDown:h=>h.event.key==="Escape"?(o({type:"ON_EXIT"}),!0):!1,onExit:()=>{o({type:"ON_EXIT"})}}),items:k4});return n.registerPlugin(f),()=>{n?.isDestroyed||n.unregisterPlugin(d)}},u=[n,i,r,o],e[1]=r,e[2]=n,e[3]=i,e[4]=l,e[5]=u):(l=e[4],u=e[5]),P.useEffect(l,u);let c;return e[6]!==s?(c={state:s,dispatch:o},e[6]=s,e[7]=c):c=e[7],c}function k4(){return[]}function x4({editor:t,queryKey:e,queryFn:n,onSelect:r}){const{state:i,dispatch:a}=SN(),s=P.useDeferredValue(i.query),{data:o}=rR({queryKey:Jm.suggestionItems(e,i.open,s),queryFn:()=>i.open?n({query:s}):[]}),l=()=>{a({type:"ON_EXIT"})},u=async(d,p)=>{if(!(i.selectedItem!==null||!i.range)){a({type:"SET_SELECTED_ITEM",payload:d});try{const{view:f}=t,g=f.state.selection.$to.nodeAfter?.text?.startsWith(" "),b=i.range?{...i.range}:{from:0,to:0};g&&i.range&&(b.to+=1),await r({range:b,item:d})}finally{l()}}},{selectedIndex:c}=T4({editor:t,query:s,items:o,onSelect:u,onClose:l});return{selectedItem:i.selectedItem,items:o,selectedIndex:c,close:l,onSelect:u}}function v4({children:t}){const{state:e,dispatch:n}=SN(),{open:r,element:i}=e,a=()=>{n({type:"ON_EXIT"})},{refs:s,floatingStyles:o,context:l}=f4({placement:"bottom-start",open:r,onOpenChange:p=>{p||a()},elements:{reference:i},middleware:[iR(10),aR(),sR()],whileElementsMounted:oR}),u=d4(l,{outsidePress:p=>!(p.target instanceof Element&&p.target.closest(".ProseMirror"))}),c=g4(l,{role:"listbox"}),{getFloatingProps:d}=h4([u,c]);return r?T.jsx(o4,{children:T.jsx("div",{ref:s.setFloating,style:o,...d(),className:"z-50 w-auto min-w-[280px] max-w-[400px] rounded-lg border bg-popover p-0 text-popover-foreground shadow-md outline-hidden overflow-hidden",children:t})}):null}const C4=t=>{const e=te.c(23),{item:n,isSelected:r,onSelect:i,isLoading:a,ref:s}=t,o=r&&"bg-accent text-accent-foreground",l=a&&"pointer-events-none opacity-50";let u;e[0]!==o||e[1]!==l?(u=ce("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","hover:bg-accent hover:text-accent-foreground","focus:bg-accent focus:text-accent-foreground",o,l),e[0]=o,e[1]=l,e[2]=u):u=e[2];let c;e[3]!==n.name||e[4]!==n.title?(c=n.title||n.name.replace(/_/g," "),e[3]=n.name,e[4]=n.title,e[5]=c):c=e[5];let d;e[6]!==c?(d=T.jsx("span",{className:"font-medium flex items-center truncate",children:c}),e[6]=c,e[7]=d):d=e[7];let p;e[8]!==a?(p=a&&T.jsx(xo,{size:"xs"}),e[8]=a,e[9]=p):p=e[9];let f;e[10]!==d||e[11]!==p?(f=T.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d,p]}),e[10]=d,e[11]=p,e[12]=f):f=e[12];let h;e[13]!==n.description?(h=n.description&&T.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:n.description}),e[13]=n.description,e[14]=h):h=e[14];let g;e[15]!==f||e[16]!==h?(g=T.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[f,h]}),e[15]=f,e[16]=h,e[17]=g):g=e[17];let b;return e[18]!==i||e[19]!==s||e[20]!==u||e[21]!==g?(b=T.jsx("div",{ref:s,onClick:i,className:u,children:g}),e[18]=i,e[19]=s,e[20]=u,e[21]=g,e[22]=b):b=e[22],b},_4=t=>{const e=te.c(18),{editor:n,queryKey:r,queryFn:i,onSelect:a}=t;let s;e[0]!==n||e[1]!==a||e[2]!==i||e[3]!==r?(s={editor:n,queryKey:r,queryFn:i,onSelect:a},e[0]=n,e[1]=a,e[2]=i,e[3]=r,e[4]=s):s=e[4];const{items:o,selectedIndex:l,onSelect:u,selectedItem:c}=x4(s);if(!o.length){let h;return e[5]===Symbol.for("react.memo_cache_sentinel")?(h=T.jsx("div",{className:"min-w-[280px] max-w-[400px] bg-popover text-popover-foreground rounded-md border shadow-md p-3 text-sm",children:"No items found"}),e[5]=h):h=e[5],h}let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d={maxHeight:"min(217px, var(--radix-popover-content-available-height, 217px))"},e[6]=d):d=e[6];let p;if(e[7]!==u||e[8]!==o||e[9]!==l||e[10]!==c?.name){let h;e[12]!==u||e[13]!==l||e[14]!==c?.name?(h=(g,b)=>T.jsx(C4,{item:g,isSelected:b===l,ref:b===l?w4:void 0,onSelect:()=>u(g,b),isLoading:c?.name===g.name},g.name),e[12]=u,e[13]=l,e[14]=c?.name,e[15]=h):h=e[15],p=o.map(h),e[7]=u,e[8]=o,e[9]=l,e[10]=c?.name,e[11]=p}else p=e[11];let f;return e[16]!==p?(f=T.jsx("div",{className:"min-w-[280px] max-w-[400px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:d,children:T.jsx("div",{className:"p-1",children:p})}),e[16]=p,e[17]=f):f=e[17],f};function N4(){const t=te.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=T.jsx("div",{className:"p-1",children:[...Array(3)].map(I4)}),t[0]=e):e=t[0],e}function I4(t,e){return T.jsxs("div",{className:"px-2 py-1.5 h-[44px] animate-pulse",children:[T.jsx("div",{className:"h-4 w-24 bg-muted rounded mb-1"}),T.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function AN(t){const e=te.c(16),{editor:n,char:r,pluginKey:i,queryKey:a,queryFn:s,onSelect:o}=t;let l;e[0]!==r||e[1]!==n||e[2]!==i?(l={editor:n,char:r,pluginKey:i},e[0]=r,e[1]=n,e[2]=i,e[3]=l):l=e[3];const{state:u,dispatch:c}=A4(l);let d;e[4]!==c||e[5]!==u?(d={state:u,dispatch:c},e[4]=c,e[5]=u,e[6]=d):d=e[6];let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=T.jsx(N4,{}),e[7]=p):p=e[7];let f;e[8]!==n||e[9]!==o||e[10]!==s||e[11]!==a?(f=T.jsx(v4,{children:T.jsx(P.Suspense,{fallback:p,children:T.jsx(_4,{editor:n,queryKey:a,queryFn:s,onSelect:o})})}),e[8]=n,e[9]=o,e[10]=s,e[11]=a,e[12]=f):f=e[12];let h;return e[13]!==d||e[14]!==f?(h=T.jsx(TN.Provider,{value:d,children:f}),e[13]=d,e[14]=f,e[15]=h):h=e[15],h}function w4(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}async function F0(t,e,n,r,i){try{const a=await nv(n,r,i);R_(t,e,{id:r,name:r,metadata:a.messages,char:"/"})}catch(a){console.error("[prompt] Failed to fetch prompt:",a),Sn.error("Failed to load prompt. Please try again.")}}const R4=t=>{const e=te.c(29),{editor:n,virtualMcpId:r}=t,i=Yx(),{org:a}=ui();let s;e[0]!==a.id||e[1]!==r?(s={connectionId:r,orgId:a.id},e[0]=a.id,e[1]=r,e[2]=s):s=e[2];const o=tg(s);let l;e[3]!==a.id||e[4]!==r?(l=Jm.virtualMcpPrompts(r,a.id),e[3]=a.id,e[4]=r,e[5]=l):l=e[5];const u=l,[c,d]=P.useState(null);let p;e[6]!==o||e[7]!==n?(p=async v=>{const{item:w,range:N}=v;if(w.arguments&&w.arguments.length>0){d({range:N,item:w});return}o&&await F0(n,N,o,w.name)},e[6]=o,e[7]=n,e[8]=p):p=e[8];const f=p;let h;e[9]!==c||e[10]!==o||e[11]!==n?(h=async v=>{if(!c||!o)return;const{range:w,item:N}=c;await F0(n,w,o,N.name,v),d(null)},e[9]=c,e[10]=o,e[11]=n,e[12]=h):h=e[12];const g=h;let b;e[13]!==o||e[14]!==i||e[15]!==u?(b=async v=>{const{query:w}=v;if(!o)return[];let N=i.getQueryData(u);if(N?i.fetchQuery({queryKey:u,queryFn:()=>$b(o),staleTime:6e4}).catch(O4):N=await i.fetchQuery({queryKey:u,queryFn:()=>$b(o),staleTime:6e4}),!N.prompts)return[];let _=N.prompts;if(w.trim()){const D=w.toLowerCase();_=N.prompts.filter(M=>M.name.toLowerCase().includes(D)||M.title?.toLowerCase().includes(D)||M.description?.toLowerCase().includes(D))}return _},e[13]=o,e[14]=i,e[15]=u,e[16]=b):b=e[16];const E=b;let y;e[17]!==n||e[18]!==E||e[19]!==f||e[20]!==u?(y=T.jsx(AN,{editor:n,char:"/",pluginKey:"promptsDropdownMenu",queryKey:u,queryFn:E,onSelect:f}),e[17]=n,e[18]=E,e[19]=f,e[20]=u,e[21]=y):y=e[21];const S=c?.item??null;let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=()=>d(null),e[22]=k):k=e[22];let x;e[23]!==g||e[24]!==S?(x=T.jsx(hv,{prompt:S,setPrompt:k,onSubmit:g}),e[23]=g,e[24]=S,e[25]=x):x=e[25];let A;return e[26]!==y||e[27]!==x?(A=T.jsxs(T.Fragment,{children:[y,x]}),e[26]=y,e[27]=x,e[28]=A):A=e[28],A};function O4(){}async function L4(t,e,n,r){try{const i=await ER(n,r);R_(t,e,{id:r,name:r,metadata:i.contents,char:"@"})}catch(i){console.error("[resource] Failed to fetch resource:",i),Sn.error("Failed to load resource. Please try again.")}}const D4=t=>{const e=te.c(18),{editor:n,virtualMcpId:r}=t,i=Yx(),{org:a}=ui();let s;e[0]!==a.id||e[1]!==r?(s={connectionId:r,orgId:a.id},e[0]=a.id,e[1]=r,e[2]=s):s=e[2];const o=tg(s);let l;e[3]!==a.id||e[4]!==r?(l=Jm.virtualMcpResources(r,a.id),e[3]=a.id,e[4]=r,e[5]=l):l=e[5];const u=l;let c;e[6]!==o||e[7]!==n?(c=async g=>{const{item:b,range:E}=g;o&&await L4(n,E,o,b.uri)},e[6]=o,e[7]=n,e[8]=c):c=e[8];const d=c;let p;e[9]!==o||e[10]!==i||e[11]!==u?(p=async g=>{const{query:b}=g;if(!o)return[];let E=i.getQueryData(u);if(E?i.fetchQuery({queryKey:u,queryFn:()=>zb(o),staleTime:6e4}).catch(M4):E=await i.fetchQuery({queryKey:u,queryFn:()=>zb(o),staleTime:6e4}),!E.resources)return[];let y=E.resources;if(b.trim()){const S=b.toLowerCase();y=E.resources.filter(k=>k.uri.toLowerCase().includes(S)||k.name?.toLowerCase().includes(S)||k.description?.toLowerCase().includes(S))}return y.map(P4)},e[9]=o,e[10]=i,e[11]=u,e[12]=p):p=e[12];const f=p;let h;return e[13]!==n||e[14]!==f||e[15]!==d||e[16]!==u?(h=T.jsx(AN,{editor:n,char:"@",pluginKey:"resourcesDropdownMenu",queryKey:u,queryFn:f,onSelect:d}),e[13]=n,e[14]=f,e[15]=d,e[16]=u,e[17]=h):h=e[17],h};function M4(){}function P4(t){return{name:t.name??t.uri,title:t.name,description:t.description,uri:t.uri}}const F4=[lN.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1}),oF.configure({placeholder:"Ask anything, / for prompts, @ for resources...",showOnlyWhenEditable:!1}),L_,P_];function B4(t){const e=te.c(22),{tiptapDoc:n,setTiptapDoc:r,selectedModel:i,isStreaming:a,onSubmit:s,children:o}=t,l=a||!i,u=P.useRef(s),c=P.useRef(r),d=n||"",p=!l;let f,h;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={attributes:{class:"prose prose-sm max-w-none focus:outline-none w-full h-full text-[15px] p-[18px]"},handleKeyDown:(_,D)=>D.key==="Enter"&&!D.shiftKey?(D.preventDefault(),u.current?.(),!0):!1},h=_=>{const{editor:D}=_;c.current(D?.getJSON())},e[0]=f,e[1]=h):(f=e[0],h=e[1]);let g;e[2]!==d||e[3]!==p?(g={extensions:F4,content:d,editable:p,editorProps:f,onUpdate:h},e[2]=d,e[3]=p,e[4]=g):g=e[4];let b;e[5]!==l?(b=[l],e[5]=l,e[6]=b):b=e[6];const E=x_(g,b);let y,S;e[7]!==s?(y=()=>{u.current=s},S=[s],e[7]=s,e[8]=y,e[9]=S):(y=e[8],S=e[9]),P.useEffect(y,S);let k,x;e[10]!==r?(x=()=>{c.current=r},k=[r],e[10]=r,e[11]=k,e[12]=x):(k=e[11],x=e[12]),P.useEffect(x,k);let A,v;e[13]!==E||e[14]!==n?(A=()=>{if(E?.isDestroyed)return;const _=JSON.stringify(E?.getJSON()),D=JSON.stringify(n||{type:"doc",content:[]});_!==D&&E.commands.setContent(n||{type:"doc",content:[]})},v=[E,n],e[13]=E,e[14]=n,e[15]=A,e[16]=v):(A=e[15],v=e[16]),P.useEffect(A,v);let w;e[17]!==E?(w={editor:E},e[17]=E,e[18]=w):w=e[18];let N;return e[19]!==o||e[20]!==w?(N=T.jsx(Vo.Provider,{value:w,children:o}),e[19]=o,e[20]=w,e[21]=N):N=e[21],N}function U4(t){const e=te.c(24),{selectedModel:n,isStreaming:r,selectedVirtualMcp:i,ref:a}=t,{editor:s}=v_(),o=i?.id??null,l=r||!n;let u;e[0]!==s?.commands?(u=()=>({focus:()=>{s?.commands.focus()},clear:()=>{s?.commands.clearContent(!0)}}),e[0]=s?.commands,e[1]=u):u=e[1];let c;if(e[2]!==s?(c=[s],e[2]=s,e[3]=c):c=e[3],P.useImperativeHandle(a??null,u,c),!s)return null;const d=l&&"cursor-not-allowed opacity-70",p=l&&"[&_.ProseMirror]:cursor-not-allowed";let f;e[4]!==d||e[5]!==p?(f=ce("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col","[&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[20px] [&_.ProseMirror]:flex-1","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:opacity-50","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0",d,p),e[4]=d,e[5]=p,e[6]=f):f=e[6];let h;e[7]!==s||e[8]!==f?(h=T.jsx(Og,{editor:s,className:f}),e[7]=s,e[8]=f,e[9]=h):h=e[9];let g;e[10]!==s||e[11]!==o?(g=T.jsx(P.Suspense,{fallback:null,children:T.jsx(R4,{editor:s,virtualMcpId:o})}),e[10]=s,e[11]=o,e[12]=g):g=e[12];let b;e[13]!==s||e[14]!==o?(b=T.jsx(P.Suspense,{fallback:null,children:T.jsx(D4,{editor:s,virtualMcpId:o})}),e[13]=s,e[14]=o,e[15]=b):b=e[15];let E;e[16]!==s||e[17]!==n?(E=T.jsx(DP,{editor:s,selectedModel:n}),e[16]=s,e[17]=n,e[18]=E):E=e[18];let y;return e[19]!==h||e[20]!==g||e[21]!==b||e[22]!==E?(y=T.jsxs(T.Fragment,{children:[h,g,b,E]}),e[19]=h,e[20]=g,e[21]=b,e[22]=E,e[23]=y):y=e[23],y}function kN(t){const e=te.c(38),{messages:n}=t;let r,i,a,s,o,l,u,c,d,p,f,h;if(e[0]!==n){h=Symbol.for("react.early_return_sentinel");e:{const k=PR(n);if(!k){h=null;break e}const{totalTokens:x,inputTokens:A,outputTokens:v,cost:w}=k;if(a=w,!x&&!A&&!v){h=null;break e}i=xn;let N;e[13]===Symbol.for("react.memo_cache_sentinel")?(N=T.jsx(uv,{size:12}),e[13]=N):N=e[13];const _=T.jsxs(ze,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground pl-1! h-6 gap-1 whitespace-nowrap shrink-0",children:[N,T.jsx("span",{className:"text-[10px] font-mono tabular-nums",children:x.toLocaleString()})]});e[14]!==_?(f=T.jsx(vn,{asChild:!0,children:_}),e[14]=_,e[15]=f):f=e[15],r=Cn,d="top",p="font-mono text-[11px]",o="grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",e[16]===Symbol.for("react.memo_cache_sentinel")?(l=T.jsx("span",{className:"text-muted",children:"in"}),e[16]=l):l=e[16],u=T.jsx("span",{children:A.toLocaleString()}),e[17]===Symbol.for("react.memo_cache_sentinel")?(c=T.jsx("span",{className:"text-muted",children:"out"}),e[17]=c):c=e[17],s=v.toLocaleString()}e[0]=n,e[1]=r,e[2]=i,e[3]=a,e[4]=s,e[5]=o,e[6]=l,e[7]=u,e[8]=c,e[9]=d,e[10]=p,e[11]=f,e[12]=h}else r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],u=e[7],c=e[8],d=e[9],p=e[10],f=e[11],h=e[12];if(h!==Symbol.for("react.early_return_sentinel"))return h;let g;e[18]!==s?(g=T.jsx("span",{children:s}),e[18]=s,e[19]=g):g=e[19];let b;e[20]!==a?(b=a>0&&T.jsxs(T.Fragment,{children:[T.jsx("span",{className:"text-muted",children:"cost"}),T.jsxs("span",{children:["$",a.toFixed(4)]})]}),e[20]=a,e[21]=b):b=e[21];let E;e[22]!==g||e[23]!==b||e[24]!==o||e[25]!==l||e[26]!==u||e[27]!==c?(E=T.jsxs("div",{className:o,children:[l,u,c,g,b]}),e[22]=g,e[23]=b,e[24]=o,e[25]=l,e[26]=u,e[27]=c,e[28]=E):E=e[28];let y;e[29]!==r||e[30]!==E||e[31]!==d||e[32]!==p?(y=T.jsx(r,{side:d,className:p,children:E}),e[29]=r,e[30]=E,e[31]=d,e[32]=p,e[33]=y):y=e[33];let S;return e[34]!==i||e[35]!==y||e[36]!==f?(S=T.jsxs(i,{children:[f,y]}),e[34]=i,e[35]=y,e[36]=f,e[37]=S):S=e[37],S}function H4(t){const e=te.c(25),{onVirtualMcpChange:n,virtualMcps:r,disabled:i}=t,a=i===void 0?!1:i,[s,o]=P.useState(!1),l=P.useRef(null),{org:u}=ui();let c;e[0]!==u.id?(c=tv(u.id),e[0]=u.id,e[1]=c):c=e[1];const d=c;let p;e[2]!==r?(p=r.filter($4),e[2]=r,e[3]=p):p=e[3];const f=p;let h,g;e[4]!==s?(h=()=>{s&&setTimeout(()=>{l.current?.focus()},0)},g=[s],e[4]=s,e[5]=h,e[6]=g):(h=e[5],g=e[6]),P.useEffect(h,g);let b;e[7]!==n?(b=w=>{n(w),o(!1)},e[7]=n,e[8]=b):b=e[8];const E=b;let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=T.jsx(Xr,{size:16}),e[9]=y):y=e[9];let S;e[10]!==a?(S=T.jsx(vn,{asChild:!0,children:T.jsx(di,{asChild:!0,children:T.jsx(ze,{type:"button",variant:"ghost",size:"icon",className:"size-8 rounded-full",disabled:a,children:y})})}),e[10]=a,e[11]=S):S=e[11];let k;e[12]!==s?(k=!s&&T.jsx(Cn,{side:"top",children:"Decopilot"}),e[12]=s,e[13]=k):k=e[13];let x;e[14]!==S||e[15]!==k?(x=T.jsxs(xn,{children:[S,k]}),e[14]=S,e[15]=k,e[16]=x):x=e[16];let A;e[17]!==d.id||e[18]!==f||e[19]!==E?(A=T.jsx(pi,{className:"w-[550px] p-0 overflow-hidden",align:"start",side:"top",sideOffset:8,children:T.jsx(Dg,{virtualMcps:f,selectedVirtualMcpId:d.id,onVirtualMcpChange:E,searchInputRef:l})}),e[17]=d.id,e[18]=f,e[19]=E,e[20]=A):A=e[20];let v;return e[21]!==s||e[22]!==x||e[23]!==A?(v=T.jsxs(ci,{open:s,onOpenChange:o,children:[x,A]}),e[21]=s,e[22]=x,e[23]=A,e[24]=v):v=e[24],v}function $4(t){return!t.id||!Kr(t.id)}function z4({virtualMcpId:t,virtualMcps:e,onVirtualMcpChange:n,disabled:r=!1}){const[i,a]=P.useState(!1),s=P.useRef(null),o=Kx(),{org:l}=ui(),u=e.find(h=>h.id===t);if(!u||Kr(t))return null;P.useEffect(()=>{i&&setTimeout(()=>{s.current?.focus()},0)},[i]);const c=D_(t),d=h=>{h.stopPropagation(),n(null)},p=h=>{h.stopPropagation(),o({to:"/$org/$project/agents/$agentId",params:{org:l.slug,project:ss,agentId:t}})},f=h=>{n(h),a(!1)};return T.jsxs("div",{className:ce("flex items-center justify-between px-3 py-1.5 rounded-t-xl z-10",c?.bg),children:[T.jsxs(ci,{open:i,onOpenChange:a,children:[T.jsx(di,{asChild:!0,children:T.jsxs("button",{type:"button",disabled:r,className:ce("flex items-center gap-1.5 hover:opacity-80 transition-opacity",r?"cursor-not-allowed opacity-50":"cursor-pointer"),children:[T.jsx(wo,{icon:u.icon,name:u.title,size:"2xs",className:"bg-background rounded-sm",fallbackIcon:u.fallbackIcon??T.jsx(Xr,{size:10})}),T.jsx("span",{className:"text-xs text-white font-normal",children:u.title}),T.jsx(Xh,{size:14,className:"text-white/50"})]})}),T.jsx(pi,{className:"w-[550px] p-0 overflow-hidden",align:"start",side:"top",sideOffset:8,children:T.jsx(Dg,{virtualMcps:e,selectedVirtualMcpId:t,onVirtualMcpChange:f,searchInputRef:s})})]}),T.jsxs("div",{className:"flex items-center gap-1",children:[T.jsx("button",{type:"button",onClick:p,disabled:r,className:ce("flex items-center justify-center p-1 rounded-full transition-colors",r?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-white/10"),"aria-label":"Edit agent",children:T.jsx(NR,{size:14,className:"text-white"})}),T.jsx("button",{type:"button",onClick:d,disabled:r,className:ce("flex items-center justify-center p-1 rounded-full transition-colors",r?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-white/10"),"aria-label":"Reset to default",children:T.jsx(fv,{size:14,className:"text-white"})})]})]})}function q4(){const t=te.c(89),{activeThreadId:e,tiptapDoc:n,setTiptapDoc:r,virtualMcps:i,selectedVirtualMcp:a,setVirtualMcpId:s,modelsConnections:o,selectedModel:l,setSelectedModel:u,selectedMode:c,setSelectedMode:d,messages:p,isStreaming:f,sendMessage:h,stop:g}=vr(),b=P.useRef(null);let E;t[0]!==f||t[1]!==l||t[2]!==n?(E=!f&&!!l&&!tP(n),t[0]=f,t[1]=l,t[2]=n,t[3]=E):E=t[3];const y=E;let S;t[4]!==y||t[5]!==f||t[6]!==h||t[7]!==g||t[8]!==n?(S=Dt=>{Dt?.preventDefault(),f?g():y&&n&&h(n)},t[4]=y,t[5]=f,t[6]=h,t[7]=g,t[8]=n,t[9]=S):S=t[9];const k=S;let x,A;if(t[10]!==a){const Dt=a?D_(a.id):null;A="flex flex-col w-full min-h-42 justify-end",x=ce("relative rounded-xl w-full flex flex-col",a&&"shadow-sm",Dt?.bg),t[10]=a,t[11]=x,t[12]=A}else x=t[11],A=t[12];let v;t[13]===Symbol.for("react.memo_cache_sentinel")?(v=T.jsx(Wo,{}),t[13]=v):v=t[13];let w;t[14]!==f||t[15]!==a||t[16]!==s||t[17]!==i?(w=a?.id&&!Kr(a.id)&&T.jsx(z4,{onVirtualMcpChange:s,virtualMcpId:a.id,virtualMcps:i,disabled:f}),t[14]=f,t[15]=a,t[16]=s,t[17]=i,t[18]=w):w=t[18];const N=!a&&"shadow-sm";let _;t[19]!==N?(_=ce("w-full relative rounded-xl min-h-[130px] flex flex-col border border-border bg-background",N),t[19]=N,t[20]=_):_=t[20];let D;t[21]!==f||t[22]!==l||t[23]!==a?(D=T.jsx("div",{className:"relative flex flex-col gap-2 flex-1",children:T.jsx(U4,{ref:b,selectedModel:l,isStreaming:f,selectedVirtualMcp:a})}),t[21]=f,t[22]=l,t[23]=a,t[24]=D):D=t[24];let M;t[25]!==f||t[26]!==a||t[27]!==s||t[28]!==i?(M=a&&Kr(a.id)?T.jsx(H4,{onVirtualMcpChange:s,virtualMcps:i,disabled:f}):T.jsx(IP,{selectedVirtualMcpId:a?.id??null,onVirtualMcpChange:s,virtualMcps:i,placeholder:"Agent",disabled:f}),t[25]=f,t[26]=a,t[27]=s,t[28]=i,t[29]=M):M=t[29];let q;t[30]!==p?(q=T.jsx(kN,{messages:p}),t[30]=p,t[31]=q):q=t[31];let F;t[32]!==q||t[33]!==M?(F=T.jsxs("div",{className:"flex items-center gap-2 min-w-0 overflow-hidden",children:[M,q]}),t[32]=q,t[33]=M,t[34]=F):F=t[34];const U=l??void 0;let $;t[35]!==o||t[36]!==u||t[37]!==U?($=T.jsx(fR,{selectedModel:U,onModelChange:u,modelsConnections:o,placeholder:"Model",variant:"borderless"}),t[35]=o,t[36]=u,t[37]=U,t[38]=$):$=t[38];let G;t[39]!==f||t[40]!==c||t[41]!==d?(G=T.jsx(CP,{selectedMode:c,onModeChange:d,placeholder:"Mode",variant:"borderless",disabled:f}),t[39]=f,t[40]=c,t[41]=d,t[42]=G):G=t[42];let H;t[43]!==f||t[44]!==l?(H=T.jsx(PP,{selectedModel:l,isStreaming:f}),t[43]=f,t[44]=l,t[45]=H):H=t[45];const J=f?"button":"submit";let I;t[46]!==f||t[47]!==g?(I=Dt=>{f&&(Dt.preventDefault(),Dt.stopPropagation(),g())},t[46]=f,t[47]=g,t[48]=I):I=t[48];const Z=y||f?"default":"ghost",ae=!y&&!f,O=!y&&!f&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed";let re;t[49]!==O?(re=ce("size-8 rounded-full transition-all",O),t[49]=O,t[50]=re):re=t[50];const ne=f?"Stop generating":"Send message (Enter)";let se;t[51]!==f?(se=f?T.jsx(dv,{size:20}):T.jsx(_R,{size:20}),t[51]=f,t[52]=se):se=t[52];let fe;t[53]!==J||t[54]!==I||t[55]!==Z||t[56]!==ae||t[57]!==re||t[58]!==ne||t[59]!==se?(fe=T.jsx(ze,{type:J,onClick:I,variant:Z,size:"icon",disabled:ae,className:re,title:ne,children:se}),t[53]=J,t[54]=I,t[55]=Z,t[56]=ae,t[57]=re,t[58]=ne,t[59]=se,t[60]=fe):fe=t[60];let xe;t[61]!==$||t[62]!==G||t[63]!==H||t[64]!==fe?(xe=T.jsxs("div",{className:"flex items-center gap-1",children:[$,G,H,fe]}),t[61]=$,t[62]=G,t[63]=H,t[64]=fe,t[65]=xe):xe=t[65];let Oe;t[66]!==F||t[67]!==xe?(Oe=T.jsxs("div",{className:"flex items-center justify-between p-2.5",children:[F,xe]}),t[66]=F,t[67]=xe,t[68]=Oe):Oe=t[68];let Le;t[69]!==k||t[70]!==Oe||t[71]!==_||t[72]!==D?(Le=T.jsxs("form",{onSubmit:k,className:_,children:[D,Oe]}),t[69]=k,t[70]=Oe,t[71]=_,t[72]=D,t[73]=Le):Le=t[73];let Me;t[74]!==e||t[75]!==k||t[76]!==f||t[77]!==l||t[78]!==r||t[79]!==Le||t[80]!==n?(Me=T.jsx("div",{className:"p-0.5",children:T.jsx(B4,{tiptapDoc:n,setTiptapDoc:r,selectedModel:l,isStreaming:f,onSubmit:k,children:Le},e)}),t[74]=e,t[75]=k,t[76]=f,t[77]=l,t[78]=r,t[79]=Le,t[80]=n,t[81]=Me):Me=t[81];let St;t[82]!==x||t[83]!==Me||t[84]!==w?(St=T.jsxs("div",{className:x,children:[v,w,Me]}),t[82]=x,t[83]=Me,t[84]=w,t[85]=St):St=t[85];let tt;return t[86]!==St||t[87]!==A?(tt=T.jsx("div",{className:A,children:St}),t[86]=St,t[87]=A,t[88]=tt):tt=t[88],tt}function Yg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ir=Yg();function xN(t){Ir=t}var Ji={exec:()=>null};function Se(t,e=""){let n=typeof t=="string"?t:t.source;const r={replace:(i,a)=>{let s=typeof a=="string"?a:a.source;return s=s.replace(bt.caret,"$1"),n=n.replace(i,s),r},getRegex:()=>new RegExp(n,e)};return r}var bt={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},j4=/^(?:[ \t]*(?:\n|$))+/,G4=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,V4=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,wa=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,W4=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Kg=/(?:[*+-]|\d{1,9}[.)])/,vN=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,CN=Se(vN).replace(/bull/g,Kg).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Y4=Se(vN).replace(/bull/g,Kg).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Xg=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,K4=/^[^\n]+/,Zg=/(?!\s*\])(?:\\.|[^\[\]\\])+/,X4=Se(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Zg).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Z4=Se(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Kg).getRegex(),Ko="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Qg=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Q4=Se("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Qg).replace("tag",Ko).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),_N=Se(Xg).replace("hr",wa).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ko).getRegex(),J4=Se(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",_N).getRegex(),Jg={blockquote:J4,code:G4,def:X4,fences:V4,heading:W4,hr:wa,html:Q4,lheading:CN,list:Z4,newline:j4,paragraph:_N,table:Ji,text:K4},B0=Se("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",wa).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ko).getRegex(),e6={...Jg,lheading:Y4,table:B0,paragraph:Se(Xg).replace("hr",wa).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",B0).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ko).getRegex()},t6={...Jg,html:Se(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Qg).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ji,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Se(Xg).replace("hr",wa).replace("heading",` *#{1,6} *[^
|
|
141
141
|
]`).replace("lheading",CN).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},n6=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,r6=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,NN=/^( {2,}|\\)\n(?!\s*$)/,i6=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Xo=/[\p{P}\p{S}]/u,eb=/[\s\p{P}\p{S}]/u,IN=/[^\s\p{P}\p{S}]/u,a6=Se(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,eb).getRegex(),wN=/(?!~)[\p{P}\p{S}]/u,s6=/(?!~)[\s\p{P}\p{S}]/u,o6=/(?:[^\s\p{P}\p{S}]|~)/u,l6=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,RN=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,u6=Se(RN,"u").replace(/punct/g,Xo).getRegex(),c6=Se(RN,"u").replace(/punct/g,wN).getRegex(),ON="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",d6=Se(ON,"gu").replace(/notPunctSpace/g,IN).replace(/punctSpace/g,eb).replace(/punct/g,Xo).getRegex(),p6=Se(ON,"gu").replace(/notPunctSpace/g,o6).replace(/punctSpace/g,s6).replace(/punct/g,wN).getRegex(),f6=Se("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,IN).replace(/punctSpace/g,eb).replace(/punct/g,Xo).getRegex(),h6=Se(/\\(punct)/,"gu").replace(/punct/g,Xo).getRegex(),m6=Se(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),g6=Se(Qg).replace("(?:-->|$)","-->").getRegex(),b6=Se("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",g6).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),mo=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,E6=Se(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",mo).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),LN=Se(/^!?\[(label)\]\[(ref)\]/).replace("label",mo).replace("ref",Zg).getRegex(),DN=Se(/^!?\[(ref)\](?:\[\])?/).replace("ref",Zg).getRegex(),y6=Se("reflink|nolink(?!\\()","g").replace("reflink",LN).replace("nolink",DN).getRegex(),tb={_backpedal:Ji,anyPunctuation:h6,autolink:m6,blockSkip:l6,br:NN,code:r6,del:Ji,emStrongLDelim:u6,emStrongRDelimAst:d6,emStrongRDelimUnd:f6,escape:n6,link:E6,nolink:DN,punctuation:a6,reflink:LN,reflinkSearch:y6,tag:b6,text:i6,url:Ji},T6={...tb,link:Se(/^!?\[(label)\]\((.*?)\)/).replace("label",mo).getRegex(),reflink:Se(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",mo).getRegex()},Om={...tb,emStrongRDelimAst:p6,emStrongLDelim:c6,url:Se(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},S6={...Om,br:Se(NN).replace("{2,}","*").getRegex(),text:Se(Om.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Za={normal:Jg,gfm:e6,pedantic:t6},Ii={normal:tb,gfm:Om,breaks:S6,pedantic:T6},A6={"&":"&","<":"<",">":">",'"':""","'":"'"},U0=t=>A6[t];function Zt(t,e){if(e){if(bt.escapeTest.test(t))return t.replace(bt.escapeReplace,U0)}else if(bt.escapeTestNoEncode.test(t))return t.replace(bt.escapeReplaceNoEncode,U0);return t}function H0(t){try{t=encodeURI(t).replace(bt.percentDecode,"%")}catch{return null}return t}function $0(t,e){const n=t.replace(bt.findPipe,(a,s,o)=>{let l=!1,u=s;for(;--u>=0&&o[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(bt.splitPipe);let i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(bt.slashPipe,"|");return r}function wi(t,e,n){const r=t.length;if(r===0)return"";let i=0;for(;i<r&&t.charAt(r-i-1)===e;)i++;return t.slice(0,r-i)}function k6(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function z0(t,e,n,r,i){const a=e.href,s=e.title||null,o=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;const l={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:a,title:s,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,l}function x6(t,e,n){const r=t.match(n.other.indentCodeCompensation);if(r===null)return e;const i=r[1];return e.split(`
|
|
142
142
|
`).map(a=>{const s=a.match(n.other.beginningSpace);if(s===null)return a;const[o]=s;return o.length>=i.length?a.slice(i.length):a}).join(`
|
|
143
143
|
`)}var go=class{options;rules;lexer;constructor(t){this.options=t||Ir}space(t){const e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){const e=this.rules.block.code.exec(t);if(e){const n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:wi(n,`
|
|
@@ -247,4 +247,4 @@ ${s}`;let c;return e[5]!==o||e[6]!==s||e[7]!==u||e[8]!==i?(c=T.jsx("div",{classN
|
|
|
247
247
|
${n.input?.prompt??"No prompt provided"}
|
|
248
248
|
|
|
249
249
|
# ${o?"Error":"Execution"}
|
|
250
|
-
${y}`,k=d?.icon,x=d?.title??"Subtask";let A;e[6]===Symbol.for("react.memo_cache_sentinel")?(A=T.jsx(Xr,{}),e[6]=A):A=e[6];let v;e[7]!==k||e[8]!==x?(v=T.jsx(wo,{icon:k,name:x,size:"2xs",fallbackIcon:A}),e[7]=k,e[8]=x,e[9]=v):v=e[9];const w=v;let N;e[10]!==h?(N=h?{tokens:h}:void 0,e[10]=h,e[11]=N):N=e[11];let _;return e[12]!==S||e[13]!==l||e[14]!==w||e[15]!==b||e[16]!==N||e[17]!==g?(_=T.jsx("div",{className:"my-2",children:T.jsx(Mb,{icon:w,title:g,usage:N,summary:b,state:l,detail:S})}),e[12]=S,e[13]=l,e[14]=w,e[15]=b,e[16]=N,e[17]=g,e[18]=_):_=e[18],_}function iQ(t){const e=te.c(5),{parts:n}=t,r=n?.length,i=n?.[n.length-1];let a;e[0]!==i||e[1]!==r?(a={enabled:!0,contentDeps:[r,i]},e[0]=i,e[1]=r,e[2]=a):a=e[2];const{sentinelRef:s}=Gw(a);let o;return e[3]!==s?(o=T.jsx("div",{ref:s,className:"h-0"}),e[3]=s,e[4]=o):o=e[4],o}const aQ={planning:{icon:T.jsx(pv,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Planning next moves"},thinking:{icon:T.jsx(ev,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Thinking"}},sQ=1200;function oQ(){const t=te.c(7),[e,n]=P.useState("planning");let r,i;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{const l=setTimeout(()=>{n("thinking")},sQ);return()=>{clearTimeout(l)}},i=[],t[0]=r,t[1]=i):(r=t[0],i=t[1]),P.useEffect(r,i);const a=aQ[e];let s;t[2]!==a.label?(s=T.jsxs("span",{className:"text-[15px] text-muted-foreground shimmer",children:[a.label,"..."]}),t[2]=a.label,t[3]=s):s=t[3];let o;return t[4]!==a.icon||t[5]!==s?(o=T.jsx("div",{className:"flex items-center gap-1.5 py-2 opacity-60",children:T.jsxs("span",{className:"flex items-center gap-1.5",children:[a.icon,s]})}),t[4]=a.icon,t[5]=s,t[6]=o):o=t[6],o}function lQ(t){const e=te.c(42),{duration:n,parts:r,id:i,isStreaming:a}=t,[s,o]=P.useState(!1),l=P.useRef(null);let u;e[0]!==a?(u=()=>{a&&l.current&&(l.current.scrollTop=l.current.scrollHeight)},e[0]=a,e[1]=u):u=e[1];let c;e[2]!==a||e[3]!==r?(c=[r,a],e[2]=a,e[3]=r,e[4]=c):c=e[4],P.useEffect(u,c);const d=a||s,p=a?void 0:o,f=!a&&"cursor-pointer hover:opacity-100",h=a&&"cursor-default";let g;e[5]!==f||e[6]!==h?(g=ce("group/thought-summary flex items-center gap-1.5 py-2 opacity-60 transition-opacity",f,h),e[5]=f,e[6]=h,e[7]=g):g=e[7];let b;e[8]!==s||e[9]!==a?(b=a?T.jsx(ev,{className:"text-muted-foreground shrink-0 shimmer",size:14}):T.jsxs("span",{className:"relative w-[14px] h-[14px] shrink-0",children:[T.jsx(av,{className:ce("absolute inset-0 text-muted-foreground transition-transform",s&&"rotate-90","opacity-0 group-hover/thought-summary:opacity-100"),size:14}),T.jsx(cv,{className:"absolute inset-0 text-muted-foreground shrink-0 opacity-100 group-hover/thought-summary:opacity-0 transition-opacity",size:14})]}),e[8]=s,e[9]=a,e[10]=b):b=e[10];const E=a&&"shimmer";let y;e[11]!==E?(y=ce("text-[15px] text-muted-foreground",E),e[11]=E,e[12]=y):y=e[12];let S;e[13]!==n||e[14]!==a?(S=a?"Thinking...":n!==null?`Thought for ${(n/1e3).toFixed(1)}s`:"Thought",e[13]=n,e[14]=a,e[15]=S):S=e[15];let k;e[16]!==y||e[17]!==S?(k=T.jsx("span",{className:y,children:S}),e[16]=y,e[17]=S,e[18]=k):k=e[18];let x;e[19]!==k||e[20]!==b?(x=T.jsxs("span",{className:"flex items-center gap-1.5",children:[b,k]}),e[19]=k,e[20]=b,e[21]=x):x=e[21];let A;e[22]!==x||e[23]!==g?(A=T.jsx(Zx,{asChild:!0,children:T.jsx("button",{type:"button",className:g,children:x})}),e[22]=x,e[23]=g,e[24]=A):A=e[24];let v;e[25]!==a?(v=a&&T.jsx("div",{className:"absolute top-0 left-0 right-0 h-16 bg-linear-to-b from-background to-transparent pointer-events-none z-10"}),e[25]=a,e[26]=v):v=e[26];let w;if(e[27]!==i||e[28]!==r){let M;e[30]!==i?(M=(q,F)=>T.jsx("div",{className:"text-muted-foreground markdown-sm pb-2",children:T.jsx(Db,{id:`${i}-reasoning-${F}`,text:q.text})},`${i}-reasoning-${F}`),e[30]=i,e[31]=M):M=e[31],w=r.map(M),e[27]=i,e[28]=r,e[29]=w}else w=e[29];let N;e[32]!==w?(N=T.jsx("div",{ref:l,className:"ml-[6px] border-l-2 pl-4 mt-1 mb-2 h-[100px] overflow-y-auto",children:w}),e[32]=w,e[33]=N):N=e[33];let _;e[34]!==v||e[35]!==N?(_=T.jsx(Qx,{className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden",children:T.jsxs("div",{className:"relative",children:[v,N]})}),e[34]=v,e[35]=N,e[36]=_):_=e[36];let D;return e[37]!==A||e[38]!==_||e[39]!==d||e[40]!==p?(D=T.jsx("div",{className:"flex flex-col mb-2",children:T.jsxs(Jx,{open:d,onOpenChange:p,children:[A,_]})}),e[37]=A,e[38]=_,e[39]=d,e[40]=p,e[41]=D):D=e[41],D}function uQ(t){return t.type==="reasoning"}function cQ(t){const e=te.c(12),{part:n,id:r,usageStats:i}=t;switch(n.type){case"dynamic-tool":{let a;return e[0]!==n?(a=T.jsx($x,{part:n}),e[0]=n,e[1]=a):a=e[1],a}case"tool-user_ask":{let a;return e[2]!==n?(a=T.jsx(nQ,{part:n}),e[2]=n,e[3]=a):a=e[3],a}case"tool-subtask":{let a;return e[4]!==n?(a=T.jsx(rQ,{part:n}),e[4]=n,e[5]=a):a=e[5],a}case"text":{let a;return e[6]!==r||e[7]!==n||e[8]!==i?(a=T.jsx(jw,{id:r,part:n,extraActions:i,copyable:!0}),e[6]=r,e[7]=n,e[8]=i,e[9]=a):a=e[9],a}case"reasoning":return null;case"step-start":case"file":case"source-url":case"source-document":return null;default:{const a=n;if(a.type.startsWith("tool-")){let s;return e[10]!==a?(s=T.jsx($x,{part:a}),e[10]=a,e[11]=s):s=e[11],s}throw new Error(`Unknown part type: ${a.type}`)}}}function dQ(){const t=te.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=T.jsx("div",{className:"text-[15px] text-muted-foreground/60 py-2",children:"No response was generated"}),t[0]=e):e=t[0],e}function pQ(t){const e=te.c(7),{className:n,children:r}=t;let i;e[0]!==n?(i=ce("w-full min-w-0 group relative flex items-start gap-4 px-4 z-20 text-foreground flex-row",n),e[0]=n,e[1]=i):i=e[1];let a;e[2]!==r?(a=T.jsx("div",{className:"flex flex-col min-w-0 w-full items-start",children:T.jsx("div",{className:"w-full min-w-0 not-only:rounded-2xl text-[15px] wrap-break-word overflow-wrap-anywhere bg-transparent",children:r})}),e[2]=r,e[3]=a):a=e[3];let s;return e[4]!==i||e[5]!==a?(s=T.jsx("div",{className:i,children:a}),e[4]=i,e[5]=a,e[6]=s):s=e[6],s}function fQ(t){const e=te.c(20),{message:n,status:r,className:i,isLast:a}=t,s=a===void 0?!1:a,o=r==="streaming",u=o||r==="submitted",c=n!==null&&n.parts.length>0;let d;e[0]!==n?.parts?(d=n?.parts?.filter(uQ)??[],e[0]=n?.parts,e[1]=d):d=e[1];const p=d,f=p.length>0;let h;if(e[2]!==n){const S=n?.metadata?.reasoning_start_at?new Date(n.metadata.reasoning_start_at):null,k=n?.metadata?.reasoning_end_at?new Date(n.metadata.reasoning_end_at):new Date;h=S!==null?k.getTime()-S.getTime():null,e[2]=n,e[3]=h}else h=e[3];const g=h;let b;e[4]!==g||e[5]!==c||e[6]!==f||e[7]!==u||e[8]!==o||e[9]!==n||e[10]!==p?(b=c?T.jsxs(T.Fragment,{children:[f&&T.jsx(lQ,{duration:g,parts:p,id:n.id,isStreaming:o}),n.parts.map((S,k)=>{const x=k===n.parts.length-1;return T.jsx(cQ,{part:S,id:n.id,usageStats:x&&T.jsx(kN,{messages:[n]})},`${n.id}-${k}`)})]}):u?T.jsx(oQ,{}):T.jsx(dQ,{}),e[4]=g,e[5]=c,e[6]=f,e[7]=u,e[8]=o,e[9]=n,e[10]=p,e[11]=b):b=e[11];let E;e[12]!==s||e[13]!==o||e[14]!==n?.parts?(E=s&&o&&T.jsx(iQ,{parts:n?.parts}),e[12]=s,e[13]=o,e[14]=n?.parts,e[15]=E):E=e[15];let y;return e[16]!==i||e[17]!==b||e[18]!==E?(y=T.jsxs(pQ,{className:i,children:[b,E]}),e[16]=i,e[17]=b,e[18]=E,e[19]=y):y=e[19],y}const hQ=[lN.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1}),L_,P_];function mQ(t){const e=te.c(5),{tiptapDoc:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={attributes:{class:"prose prose-sm max-w-none focus:outline-none"}},e[0]=r):r=e[0];let i;e[1]!==n?(i={extensions:hQ,content:n,editable:!1,editorProps:r},e[1]=n,e[2]=i):i=e[2];const a=x_(i);if(!a)return null;let s;return e[3]!==a?(s=T.jsx(Og,{editor:a,className:"[&_.ProseMirror]:outline-none [&_.ProseMirror]:cursor-text"}),e[3]=a,e[4]=s):s=e[4],s}function gQ(t){const e=te.c(24),{message:n,className:r,onScrollToPair:i}=t,{id:a,parts:s,metadata:o}=n,[l,u]=P.useState(!1);if(!s||s.length===0)return null;let c;e[0]!==i?(c=()=>{u(!0),i?.()},e[0]=i,e[1]=c):c=e[1];const d=c,p=o?.tiptapDoc;let f;e[2]!==r?(f=ce("message-block w-full min-w-0 relative flex items-start gap-4 px-2.5 text-foreground flex-row-reverse",r),e[2]=r,e[3]=f):f=e[3];let h,g;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=()=>u(!0),g=()=>u(!1),e[4]=h,e[5]=g):(h=e[4],g=e[5]);const b=l?"overflow-auto opacity-100":"overflow-hidden opacity-99 mask-b-from-1%";let E;e[6]!==b?(E=ce("z-10 px-4 py-2 transition-opacity max-h-[120px] flex-1",b),e[6]=b,e[7]=E):E=e[7];let y;e[8]!==p||e[9]!==a||e[10]!==o||e[11]!==s?(y=p?T.jsx(mQ,{tiptapDoc:o.tiptapDoc}):s.map((v,w)=>v.type==="text"?T.jsx(jw,{id:a,part:v},`${a}-${w}`):null),e[8]=p,e[9]=a,e[10]=o,e[11]=s,e[12]=y):y=e[12];let S;e[13]!==y?(S=T.jsx("div",{children:y}),e[13]=y,e[14]=S):S=e[14];let k;e[15]!==E||e[16]!==S?(k=T.jsx("div",{className:E,children:S}),e[15]=E,e[16]=S,e[17]=k):k=e[17];let x;e[18]!==d||e[19]!==k?(x=T.jsx("div",{tabIndex:0,onClick:d,onFocus:h,onBlur:g,className:"w-full border min-w-0 shadow-xs rounded-lg text-[0.9375rem] wrap-break-word overflow-wrap-anywhere bg-background cursor-pointer transition-colors relative flex outline-none",children:k}),e[18]=d,e[19]=k,e[20]=x):x=e[20];let A;return e[21]!==x||e[22]!==f?(A=T.jsx(T.Fragment,{children:T.jsx("div",{className:f,children:x})}),e[21]=x,e[22]=f,e[23]=A):A=e[23],A}function bQ(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(r&&r.role==="user"){const i=t[n+1];i&&i.role==="assistant"?(e.push({user:r,assistant:i}),n++):e.push({user:r,assistant:null})}}return e}function zx(t){const e=te.c(14),{pair:n,isLastPair:r,status:i}=t,a=P.useRef(null);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{a.current&&a.current.scrollIntoView({behavior:"smooth",block:"start"})},e[0]=s):s=e[0];const o=s;let l;e[1]!==r?(l=h=>{a.current=h,r&&h?.scrollIntoView({behavior:"smooth",block:"start"})},e[1]=r,e[2]=l):l=e[2];const u=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=T.jsx("div",{className:"sticky top-0 z-50 w-full h-4",style:{backgroundColor:"var(--chat-surface)"}}),e[3]=c):c=e[3];let d;e[4]!==n.user?(d=T.jsx("div",{className:"sticky mb-3 top-4 z-50",children:T.jsx(gQ,{message:n.user,onScrollToPair:o})}),e[4]=n.user,e[5]=d):d=e[5];let p;e[6]!==r||e[7]!==n.assistant||e[8]!==i?(p=T.jsx(fQ,{message:n.assistant,status:i,isLast:r}),e[6]=r,e[7]=n.assistant,e[8]=i,e[9]=p):p=e[9];let f;return e[10]!==u||e[11]!==d||e[12]!==p?(f=T.jsxs("div",{ref:u,className:"flex flex-col pb-2",children:[c,d,p]}),e[10]=u,e[11]=d,e[12]=p,e[13]=f):f=e[13],f}const EQ="https://sites-openrouter.decocache.com/mcp",yQ="https://assets.decocache.com/decocms/b2e2f64f-6025-45f7-9e8c-3b3ebdd073d8/openrouter_logojpg.jpg";function TQ({title:t="No model provider connected",description:e="Connect to a model provider to unlock AI-powered features.",org:n}){const r=BR(),[,i]=hR(),a=Kx(),{data:s}=lR.useSession(),o=UR(),l=s?.user?.id??"",u=()=>{a({to:"/$org/$project/mcps",params:{org:n.slug,project:ss},search:{action:"create"}})},c=async()=>{if(!n.id||!l){Sn.error("Not authenticated");return}try{const d=o?.find(h=>h.connection_url===EQ);if(d){i(!1),a({to:"/$org/$project/mcps/$connectionId",params:{org:n.slug,project:ss,connectionId:d.id}});return}const p=gR({id:HR("conn")}),f=await r.create.mutateAsync(p);i(!1),a({to:"/$org/$project/mcps/$connectionId",params:{org:n.slug,project:ss,connectionId:f.id}})}catch(d){Sn.error(`Failed to connect OpenRouter: ${d instanceof Error?d.message:String(d)}`)}};return T.jsx(FR,{image:T.jsx("img",{src:"/empty-state-openrouter.svg",alt:"",width:336,height:320,"aria-hidden":"true",className:"w-xs h-auto mask-radial-[100%_100%] mask-radial-from-20% mask-radial-to-50% mask-radial-at-center"}),title:t,description:e,actions:T.jsxs(T.Fragment,{children:[T.jsxs(ze,{variant:"outline",onClick:c,disabled:r.create.isPending,children:[T.jsx("img",{src:yQ,alt:"OpenRouter",className:"size-4"}),r.create.isPending?"Installing...":"Install OpenRouter"]}),T.jsx(ze,{variant:"outline",onClick:u,children:"Install Connection"})]})})}function SQ(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),a=Math.floor(r/36e5);return i<1?"now":i<60?`${i}m`:`${a}h`}function AQ(t){const e=new Date,n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date(n.getTime()-864e5),i=new Date(n.getTime()-7*864e5),a=new Date(n.getTime()-30*864e5),s=[],o=[],l=[],u=[],c=[];for(const p of t){const f=new Date(p.updated_at);f>=n?s.push(p):f>=r?o.push(p):f>=i?l.push(p):f>=a?u.push(p):c.push(p)}const d=[];return s.length>0&&d.push({label:"Today",threads:s,showRelativeTime:!0}),o.length>0&&d.push({label:"Yesterday",threads:o,showRelativeTime:!1}),l.length>0&&d.push({label:"7 days ago",threads:l,showRelativeTime:!1}),u.length>0&&d.push({label:"30 days ago",threads:u,showRelativeTime:!1}),c.length>0&&d.push({label:"Older",threads:c,showRelativeTime:!1}),d}function kQ(t){const e=te.c(51),{variant:n}=t,r=n===void 0?"icon":n,[i,a]=P.useState(""),{activeThreadId:s,switchToThread:o,threads:l,hasNextPage:u,isFetchingNextPage:c,fetchNextPage:d,hideThread:p}=vr(),f=P.useRef(null),h=P.useRef(null);let g;e[0]!==d||e[1]!==u||e[2]!==c?(g=G=>{h.current&&h.current.disconnect(),G&&u&&!c&&d&&(h.current=new IntersectionObserver(H=>{H[0]?.isIntersecting&&u&&!c&&d&&d()},{rootMargin:"100px"}),h.current.observe(G)),f.current=G},e[0]=d,e[1]=u,e[2]=c,e[3]=g):g=e[3];const b=g;let E,y,S,k,x,A,v,w,N,_,D;if(e[4]!==s||e[5]!==u||e[6]!==p||e[7]!==c||e[8]!==i||e[9]!==b||e[10]!==o||e[11]!==l||e[12]!==r){const G=i.trim()?l.filter(Z=>Z.title.toLowerCase().includes(i.toLowerCase())):l,H=AQ(G);k=vo,S=xn,y=ci,e[24]!==r?(_=T.jsx(vn,{asChild:!0,children:T.jsx(di,{asChild:!0,children:r==="outline"?T.jsx(ze,{type:"button",variant:"outline",size:"icon",className:"size-7 border border-input","aria-label":"Chat history",children:T.jsx(qb,{size:16})}):T.jsx(ze,{type:"button",variant:"ghost",size:"icon",className:"size-6 p-1 hover:bg-transparent","aria-label":"Chat history",children:T.jsx(qb,{size:16,className:"text-muted-foreground hover:text-foreground transition-colors"})})})}),e[24]=r,e[25]=_):_=e[25],e[26]===Symbol.for("react.memo_cache_sentinel")?(D=T.jsx(Cn,{children:"Chat history"}),e[26]=D):D=e[26],E=pi,v="end",w="w-80 p-0";let J;e[27]===Symbol.for("react.memo_cache_sentinel")?(J=T.jsx(iv,{size:16,className:"text-muted-foreground shrink-0"}),e[27]=J):J=e[27];let I;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=Z=>a(Z.target.value),e[28]=I):I=e[28],e[29]!==i?(N=T.jsx("div",{className:"border-b",children:T.jsxs("label",{className:"flex items-center gap-2.5 h-12 px-4 cursor-text",children:[J,T.jsx("input",{type:"text",placeholder:"Search chats...",value:i,onChange:I,className:"flex-1 border-0 shadow-none focus:outline-none px-0 h-full text-sm placeholder:text-muted-foreground/50 bg-transparent"})]})}),e[29]=i,e[30]=N):N=e[30],x="max-h-[300px] overflow-y-auto",A=G.length===0?T.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:i.trim()?"No chats found":"No chats yet"}):T.jsxs(T.Fragment,{children:[H.map((Z,ae)=>T.jsxs("div",{children:[ae>0&&T.jsx("div",{className:"border-t mx-3"}),T.jsx("div",{className:"px-3 py-1",children:T.jsx("span",{className:"text-xs font-medium text-muted-foreground tracking-wide",children:Z.label})}),Z.threads.map(O=>{const re=O.id===s;return T.jsxs("div",{className:ce("flex items-center gap-2 px-3 py-2 hover:bg-accent cursor-pointer group",re&&"bg-accent/50"),onClick:()=>o(O.id),children:[T.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[T.jsx("span",{className:"text-sm truncate",children:O.title||"New chat"}),T.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:re?"current":Z.showRelativeTime?SQ(O.updated_at):null})]}),T.jsx("button",{type:"button",onClick:ne=>{ne.stopPropagation(),p(O.id)},className:"opacity-0 cursor-pointer group/trash group-hover:opacity-100 p-1 hover:bg-destructive/10 rounded transition-opacity",title:"Remove chat",children:T.jsx($R,{size:14,className:"text-muted-foreground group-hover/trash:text-destructive"})})]},O.id)})]},Z.label)),!i.trim()&&u&&T.jsx("div",{ref:b,className:"h-4"}),c&&T.jsx("div",{className:"p-3 text-center text-xs text-muted-foreground",children:"Loading more chats..."})]}),e[4]=s,e[5]=u,e[6]=p,e[7]=c,e[8]=i,e[9]=b,e[10]=o,e[11]=l,e[12]=r,e[13]=E,e[14]=y,e[15]=S,e[16]=k,e[17]=x,e[18]=A,e[19]=v,e[20]=w,e[21]=N,e[22]=_,e[23]=D}else E=e[13],y=e[14],S=e[15],k=e[16],x=e[17],A=e[18],v=e[19],w=e[20],N=e[21],_=e[22],D=e[23];let M;e[31]!==x||e[32]!==A?(M=T.jsx("div",{className:x,children:A}),e[31]=x,e[32]=A,e[33]=M):M=e[33];let q;e[34]!==E||e[35]!==M||e[36]!==v||e[37]!==w||e[38]!==N?(q=T.jsxs(E,{align:v,className:w,children:[N,M]}),e[34]=E,e[35]=M,e[36]=v,e[37]=w,e[38]=N,e[39]=q):q=e[39];let F;e[40]!==y||e[41]!==q||e[42]!==_||e[43]!==D?(F=T.jsxs(y,{children:[_,D,q]}),e[40]=y,e[41]=q,e[42]=_,e[43]=D,e[44]=F):F=e[44];let U;e[45]!==S||e[46]!==F?(U=T.jsx(S,{children:F}),e[45]=S,e[46]=F,e[47]=U):U=e[47];let $;return e[48]!==k||e[49]!==U?($=T.jsx(k,{children:U}),e[48]=k,e[49]=U,e[50]=$):$=e[50],$}function xQ(t){const e=te.c(11),{className:n}=t;let r;e[0]!==n?(r=ce("flex h-full w-full flex-col bg-muted",n),e[0]=n,e[1]=r):r=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=T.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),e[2]=i):i=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=T.jsxs("div",{className:"flex items-center gap-3",children:[i,T.jsxs("div",{className:"flex flex-col gap-2",children:[T.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),T.jsx("div",{className:"h-3 w-40 rounded bg-muted/60 animate-pulse"})]})]}),e[3]=a):a=e[3];let s;e[4]===Symbol.for("react.memo_cache_sentinel")?(s=T.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:T.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[a,T.jsxs("div",{className:"flex items-end gap-2",children:[T.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),T.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),e[4]=s):s=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=T.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:T.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[T.jsx(as,{align:"right",width:"w-3/4"}),T.jsx(as,{align:"left",width:"w-full",lines:3}),T.jsx(as,{align:"right",width:"w-2/3"}),T.jsx(as,{align:"left",width:"w-5/6",lines:2})]})}),e[5]=o):o=e[5];let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l=T.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:T.jsx("div",{className:"relative flex-1",children:T.jsxs("div",{className:"space-y-2 p-2",children:[T.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),T.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),e[6]=l):l=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=T.jsx("div",{className:"flex items-center gap-1",children:T.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),e[7]=u):u=e[7];let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=T.jsx("div",{className:"px-4 py-4",children:T.jsx("div",{className:"mx-auto w-full max-w-2xl",children:T.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl border border-border bg-background shadow-sm",children:[l,T.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[u,T.jsxs("div",{className:"flex items-center gap-1",children:[T.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),T.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})}),e[8]=c):c=e[8];let d;return e[9]!==r?(d=T.jsxs("div",{className:r,children:[s,o,c]}),e[9]=r,e[10]=d):d=e[10],d}function as(t){const e=te.c(22),{align:n,width:r,lines:i}=t,a=r===void 0?"w-full":r,s=i===void 0?1:i,o=n==="right"?"flex-row-reverse":"flex-row";let l;e[0]!==o?(l=ce("flex w-full gap-4 px-4 py-2",o),e[0]=o,e[1]=l):l=e[1];const u=n==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let c;e[2]!==u?(c=ce("flex min-w-0 flex-col gap-2",u),e[2]=u,e[3]=c):c=e[3];let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=T.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=d):d=e[4];const p=n==="right"?"bg-muted":"bg-transparent border border-border/40";let f;e[5]!==p||e[6]!==a?(f=ce("min-w-0 rounded-2xl p-4",p,a),e[5]=p,e[6]=a,e[7]=f):f=e[7];let h;e[8]!==s?(h=Array.from({length:s}),e[8]=s,e[9]=h):h=e[9];let g;e[10]!==s||e[11]!==h?(g=T.jsx("div",{className:"space-y-2",children:h.map((S,k)=>T.jsx("div",{className:ce("h-3 rounded bg-muted-foreground/20 animate-pulse",k===s-1?"w-3/4":"w-full"),style:{animationDelay:`${k*.1}s`}},k))}),e[10]=s,e[11]=h,e[12]=g):g=e[12];let b;e[13]!==g||e[14]!==f?(b=T.jsx("div",{className:f,children:g}),e[13]=g,e[14]=f,e[15]=b):b=e[15];let E;e[16]!==b||e[17]!==c?(E=T.jsxs("div",{className:c,children:[d,b]}),e[16]=b,e[17]=c,e[18]=E):E=e[18];let y;return e[19]!==E||e[20]!==l?(y=T.jsx("div",{className:l,children:E}),e[19]=E,e[20]=l,e[21]=y):y=e[21],y}function vQ(t){const e=te.c(8),{className:n,children:r}=t,a=n?.includes("bg-background")?"var(--background)":"var(--muted)";let s;e[0]!==n?(s=ce("flex flex-col h-full w-full bg-muted transform-[translateZ(0)]",n),e[0]=n,e[1]=s):s=e[1];let o;e[2]!==a?(o={"--chat-surface":a},e[2]=a,e[3]=o):o=e[3];const l=o;let u;return e[4]!==r||e[5]!==s||e[6]!==l?(u=T.jsx("div",{className:s,style:l,children:r}),e[4]=r,e[5]=s,e[6]=l,e[7]=u):u=e[7],u}function CQ(t){const e=te.c(5),{children:n,className:r}=t;let i;e[0]!==r?(i=ce("flex-1 min-h-0 overflow-y-auto",r),e[0]=r,e[1]=i):i=e[1];let a;return e[2]!==n||e[3]!==i?(a=T.jsx("div",{className:i,children:n}),e[2]=n,e[3]=i,e[4]=a):a=e[4],a}function _Q(t){const e=te.c(2),{children:n}=t;let r;return e[0]!==n?(r=T.jsx("div",{className:"h-full w-full flex items-center justify-center max-w-2xl mx-auto",children:n}),e[0]=n,e[1]=r):r=e[1],r}function NQ(){const t=te.c(16),{messages:e,status:n}=vr(),r=bQ(e);let i;t[0]!==r?(i=r.at(-1),t[0]=r,t[1]=i):i=t[1];const a=i;let s;if(t[2]!==r||t[3]!==n){let c;t[5]!==r.length||t[6]!==n?(c=(d,p)=>T.jsx(zx,{pair:d,isLastPair:!1,status:p===r.length-1?n:void 0},`pair-${d.user.id}`),t[5]=r.length,t[6]=n,t[7]=c):c=t[7],s=r.slice(0,-1).map(c),t[2]=r,t[3]=n,t[4]=s}else s=t[4];let o;t[8]!==s?(o=T.jsx("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:s}),t[8]=s,t[9]=o):o=t[9];let l;t[10]!==a||t[11]!==n?(l=a&&T.jsx("div",{className:"min-h-full min-w-0 max-w-2xl mx-auto w-full",children:T.jsx(zx,{pair:a,isLastPair:!0,status:n},`pair-${a?.user.id}`)}),t[10]=a,t[11]=n,t[12]=l):l=t[12];let u;return t[13]!==o||t[14]!==l?(u=T.jsxs("div",{className:"w-full min-w-0 max-w-full overflow-y-auto h-full overflow-x-hidden",children:[o,l]}),t[13]=o,t[14]=l,t[15]=u):u=t[15],u}function IQ(t){const e=te.c(5),{children:n,className:r}=t;let i;e[0]!==r?(i=ce("flex-none w-full mx-auto p-2","max-w-2xl min-w-0",r),e[0]=r,e[1]=i):i=e[1];let a;return e[2]!==n||e[3]!==i?(a=T.jsx("div",{className:i,children:n}),e[2]=n,e[3]=i,e[4]=a):a=e[4],a}const dJ=Object.assign(vQ,{Main:CQ,Messages:NQ,EmptyState:_Q,Footer:IQ,Input:q4,Provider:mR,Skeleton:xQ,IceBreakers:lP,NoLlmBindingEmptyState:TQ,ThreadHistoryPopover:kQ});export{dJ as C,Og as E,Tt as N,De as P,N_ as R,y4 as S,Dg as V,Gn as a,lN as b,YM as c,Z3 as d,__ as e,dv as f,IP as g,pv as i,je as m,x_ as u};
|
|
250
|
+
${y}`,k=d?.icon,x=d?.title??"Subtask";let A;e[6]===Symbol.for("react.memo_cache_sentinel")?(A=T.jsx(Xr,{}),e[6]=A):A=e[6];let v;e[7]!==k||e[8]!==x?(v=T.jsx(wo,{icon:k,name:x,size:"2xs",fallbackIcon:A}),e[7]=k,e[8]=x,e[9]=v):v=e[9];const w=v;let N;e[10]!==h?(N=h?{tokens:h}:void 0,e[10]=h,e[11]=N):N=e[11];let _;return e[12]!==S||e[13]!==l||e[14]!==w||e[15]!==b||e[16]!==N||e[17]!==g?(_=T.jsx("div",{className:"my-2",children:T.jsx(Mb,{icon:w,title:g,usage:N,summary:b,state:l,detail:S})}),e[12]=S,e[13]=l,e[14]=w,e[15]=b,e[16]=N,e[17]=g,e[18]=_):_=e[18],_}function iQ(t){const e=te.c(5),{parts:n}=t,r=n?.length,i=n?.[n.length-1];let a;e[0]!==i||e[1]!==r?(a={enabled:!0,contentDeps:[r,i]},e[0]=i,e[1]=r,e[2]=a):a=e[2];const{sentinelRef:s}=Gw(a);let o;return e[3]!==s?(o=T.jsx("div",{ref:s,className:"h-0"}),e[3]=s,e[4]=o):o=e[4],o}const aQ={planning:{icon:T.jsx(pv,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Planning next moves"},thinking:{icon:T.jsx(ev,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Thinking"}},sQ=1200;function oQ(){const t=te.c(7),[e,n]=P.useState("planning");let r,i;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{const l=setTimeout(()=>{n("thinking")},sQ);return()=>{clearTimeout(l)}},i=[],t[0]=r,t[1]=i):(r=t[0],i=t[1]),P.useEffect(r,i);const a=aQ[e];let s;t[2]!==a.label?(s=T.jsxs("span",{className:"text-[15px] text-muted-foreground shimmer",children:[a.label,"..."]}),t[2]=a.label,t[3]=s):s=t[3];let o;return t[4]!==a.icon||t[5]!==s?(o=T.jsx("div",{className:"flex items-center gap-1.5 py-2 opacity-60",children:T.jsxs("span",{className:"flex items-center gap-1.5",children:[a.icon,s]})}),t[4]=a.icon,t[5]=s,t[6]=o):o=t[6],o}function lQ(t){const e=te.c(42),{duration:n,parts:r,id:i,isStreaming:a}=t,[s,o]=P.useState(!1),l=P.useRef(null);let u;e[0]!==a?(u=()=>{a&&l.current&&(l.current.scrollTop=l.current.scrollHeight)},e[0]=a,e[1]=u):u=e[1];let c;e[2]!==a||e[3]!==r?(c=[r,a],e[2]=a,e[3]=r,e[4]=c):c=e[4],P.useEffect(u,c);const d=a||s,p=a?void 0:o,f=!a&&"cursor-pointer hover:opacity-100",h=a&&"cursor-default";let g;e[5]!==f||e[6]!==h?(g=ce("group/thought-summary flex items-center gap-1.5 py-2 opacity-60 transition-opacity",f,h),e[5]=f,e[6]=h,e[7]=g):g=e[7];let b;e[8]!==s||e[9]!==a?(b=a?T.jsx(ev,{className:"text-muted-foreground shrink-0 shimmer",size:14}):T.jsxs("span",{className:"relative w-[14px] h-[14px] shrink-0",children:[T.jsx(av,{className:ce("absolute inset-0 text-muted-foreground transition-transform",s&&"rotate-90","opacity-0 group-hover/thought-summary:opacity-100"),size:14}),T.jsx(cv,{className:"absolute inset-0 text-muted-foreground shrink-0 opacity-100 group-hover/thought-summary:opacity-0 transition-opacity",size:14})]}),e[8]=s,e[9]=a,e[10]=b):b=e[10];const E=a&&"shimmer";let y;e[11]!==E?(y=ce("text-[15px] text-muted-foreground",E),e[11]=E,e[12]=y):y=e[12];let S;e[13]!==n||e[14]!==a?(S=a?"Thinking...":n!==null?`Thought for ${(n/1e3).toFixed(1)}s`:"Thought",e[13]=n,e[14]=a,e[15]=S):S=e[15];let k;e[16]!==y||e[17]!==S?(k=T.jsx("span",{className:y,children:S}),e[16]=y,e[17]=S,e[18]=k):k=e[18];let x;e[19]!==k||e[20]!==b?(x=T.jsxs("span",{className:"flex items-center gap-1.5",children:[b,k]}),e[19]=k,e[20]=b,e[21]=x):x=e[21];let A;e[22]!==x||e[23]!==g?(A=T.jsx(Zx,{asChild:!0,children:T.jsx("button",{type:"button",className:g,children:x})}),e[22]=x,e[23]=g,e[24]=A):A=e[24];let v;e[25]!==a?(v=a&&T.jsx("div",{className:"absolute top-0 left-0 right-0 h-16 bg-linear-to-b from-background to-transparent pointer-events-none z-10"}),e[25]=a,e[26]=v):v=e[26];let w;if(e[27]!==i||e[28]!==r){let M;e[30]!==i?(M=(q,F)=>T.jsx("div",{className:"text-muted-foreground markdown-sm pb-2",children:T.jsx(Db,{id:`${i}-reasoning-${F}`,text:q.text})},`${i}-reasoning-${F}`),e[30]=i,e[31]=M):M=e[31],w=r.map(M),e[27]=i,e[28]=r,e[29]=w}else w=e[29];let N;e[32]!==w?(N=T.jsx("div",{ref:l,className:"ml-[6px] border-l-2 pl-4 mt-1 mb-2 h-[100px] overflow-y-auto",children:w}),e[32]=w,e[33]=N):N=e[33];let _;e[34]!==v||e[35]!==N?(_=T.jsx(Qx,{className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden",children:T.jsxs("div",{className:"relative",children:[v,N]})}),e[34]=v,e[35]=N,e[36]=_):_=e[36];let D;return e[37]!==A||e[38]!==_||e[39]!==d||e[40]!==p?(D=T.jsx("div",{className:"flex flex-col mb-2",children:T.jsxs(Jx,{open:d,onOpenChange:p,children:[A,_]})}),e[37]=A,e[38]=_,e[39]=d,e[40]=p,e[41]=D):D=e[41],D}function uQ(t){return t.type==="reasoning"}function cQ(t){const e=te.c(12),{part:n,id:r,usageStats:i}=t;switch(n.type){case"dynamic-tool":{let a;return e[0]!==n?(a=T.jsx($x,{part:n}),e[0]=n,e[1]=a):a=e[1],a}case"tool-user_ask":{let a;return e[2]!==n?(a=T.jsx(nQ,{part:n}),e[2]=n,e[3]=a):a=e[3],a}case"tool-subtask":{let a;return e[4]!==n?(a=T.jsx(rQ,{part:n}),e[4]=n,e[5]=a):a=e[5],a}case"text":{let a;return e[6]!==r||e[7]!==n||e[8]!==i?(a=T.jsx(jw,{id:r,part:n,extraActions:i,copyable:!0}),e[6]=r,e[7]=n,e[8]=i,e[9]=a):a=e[9],a}case"reasoning":return null;case"step-start":case"file":case"source-url":case"source-document":return null;default:{const a=n;if(a.type.startsWith("tool-")){let s;return e[10]!==a?(s=T.jsx($x,{part:a}),e[10]=a,e[11]=s):s=e[11],s}throw new Error(`Unknown part type: ${a.type}`)}}}function dQ(){const t=te.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=T.jsx("div",{className:"text-[15px] text-muted-foreground/60 py-2",children:"No response was generated"}),t[0]=e):e=t[0],e}function pQ(t){const e=te.c(7),{className:n,children:r}=t;let i;e[0]!==n?(i=ce("w-full min-w-0 group relative flex items-start gap-4 px-4 z-20 text-foreground flex-row",n),e[0]=n,e[1]=i):i=e[1];let a;e[2]!==r?(a=T.jsx("div",{className:"flex flex-col min-w-0 w-full items-start",children:T.jsx("div",{className:"w-full min-w-0 not-only:rounded-2xl text-[15px] wrap-break-word overflow-wrap-anywhere bg-transparent",children:r})}),e[2]=r,e[3]=a):a=e[3];let s;return e[4]!==i||e[5]!==a?(s=T.jsx("div",{className:i,children:a}),e[4]=i,e[5]=a,e[6]=s):s=e[6],s}function fQ(t){const e=te.c(20),{message:n,status:r,className:i,isLast:a}=t,s=a===void 0?!1:a,o=r==="streaming",u=o||r==="submitted",c=n!==null&&n.parts.length>0;let d;e[0]!==n?.parts?(d=n?.parts?.filter(uQ)??[],e[0]=n?.parts,e[1]=d):d=e[1];const p=d,f=p.length>0;let h;if(e[2]!==n){const S=n?.metadata?.reasoning_start_at?new Date(n.metadata.reasoning_start_at):null,k=n?.metadata?.reasoning_end_at?new Date(n.metadata.reasoning_end_at):new Date;h=S!==null?k.getTime()-S.getTime():null,e[2]=n,e[3]=h}else h=e[3];const g=h;let b;e[4]!==g||e[5]!==c||e[6]!==f||e[7]!==u||e[8]!==o||e[9]!==n||e[10]!==p?(b=c?T.jsxs(T.Fragment,{children:[f&&T.jsx(lQ,{duration:g,parts:p,id:n.id,isStreaming:o}),n.parts.map((S,k)=>{const x=k===n.parts.length-1;return T.jsx(cQ,{part:S,id:n.id,usageStats:x&&T.jsx(kN,{messages:[n]})},`${n.id}-${k}`)})]}):u?T.jsx(oQ,{}):T.jsx(dQ,{}),e[4]=g,e[5]=c,e[6]=f,e[7]=u,e[8]=o,e[9]=n,e[10]=p,e[11]=b):b=e[11];let E;e[12]!==s||e[13]!==o||e[14]!==n?.parts?(E=s&&o&&T.jsx(iQ,{parts:n?.parts}),e[12]=s,e[13]=o,e[14]=n?.parts,e[15]=E):E=e[15];let y;return e[16]!==i||e[17]!==b||e[18]!==E?(y=T.jsxs(pQ,{className:i,children:[b,E]}),e[16]=i,e[17]=b,e[18]=E,e[19]=y):y=e[19],y}const hQ=[lN.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1}),L_,P_];function mQ(t){const e=te.c(5),{tiptapDoc:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={attributes:{class:"prose prose-sm max-w-none focus:outline-none"}},e[0]=r):r=e[0];let i;e[1]!==n?(i={extensions:hQ,content:n,editable:!1,editorProps:r},e[1]=n,e[2]=i):i=e[2];const a=x_(i);if(!a)return null;let s;return e[3]!==a?(s=T.jsx(Og,{editor:a,className:"[&_.ProseMirror]:outline-none [&_.ProseMirror]:cursor-text"}),e[3]=a,e[4]=s):s=e[4],s}function gQ(t){const e=te.c(24),{message:n,className:r,onScrollToPair:i}=t,{id:a,parts:s,metadata:o}=n,[l,u]=P.useState(!1);if(!s||s.length===0)return null;let c;e[0]!==i?(c=()=>{u(!0),i?.()},e[0]=i,e[1]=c):c=e[1];const d=c,p=o?.tiptapDoc;let f;e[2]!==r?(f=ce("message-block w-full min-w-0 relative flex items-start gap-4 px-2.5 text-foreground flex-row-reverse",r),e[2]=r,e[3]=f):f=e[3];let h,g;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=()=>u(!0),g=()=>u(!1),e[4]=h,e[5]=g):(h=e[4],g=e[5]);const b=l?"overflow-auto opacity-100":"overflow-hidden opacity-99 mask-b-from-1%";let E;e[6]!==b?(E=ce("z-10 px-4 py-2 transition-opacity max-h-[120px] flex-1",b),e[6]=b,e[7]=E):E=e[7];let y;e[8]!==p||e[9]!==a||e[10]!==o||e[11]!==s?(y=p?T.jsx(mQ,{tiptapDoc:o.tiptapDoc}):s.map((v,w)=>v.type==="text"?T.jsx(jw,{id:a,part:v},`${a}-${w}`):null),e[8]=p,e[9]=a,e[10]=o,e[11]=s,e[12]=y):y=e[12];let S;e[13]!==y?(S=T.jsx("div",{children:y}),e[13]=y,e[14]=S):S=e[14];let k;e[15]!==E||e[16]!==S?(k=T.jsx("div",{className:E,children:S}),e[15]=E,e[16]=S,e[17]=k):k=e[17];let x;e[18]!==d||e[19]!==k?(x=T.jsx("div",{tabIndex:0,onClick:d,onFocus:h,onBlur:g,className:"w-full border min-w-0 shadow-xs rounded-lg text-[0.9375rem] wrap-break-word overflow-wrap-anywhere bg-background cursor-pointer transition-colors relative flex outline-none",children:k}),e[18]=d,e[19]=k,e[20]=x):x=e[20];let A;return e[21]!==x||e[22]!==f?(A=T.jsx(T.Fragment,{children:T.jsx("div",{className:f,children:x})}),e[21]=x,e[22]=f,e[23]=A):A=e[23],A}function bQ(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(r&&r.role==="user"){const i=t[n+1];i&&i.role==="assistant"?(e.push({user:r,assistant:i}),n++):e.push({user:r,assistant:null})}}return e}function zx(t){const e=te.c(14),{pair:n,isLastPair:r,status:i}=t,a=P.useRef(null);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{a.current&&a.current.scrollIntoView({behavior:"smooth",block:"start"})},e[0]=s):s=e[0];const o=s;let l;e[1]!==r?(l=h=>{a.current=h,r&&h?.scrollIntoView({behavior:"smooth",block:"start"})},e[1]=r,e[2]=l):l=e[2];const u=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=T.jsx("div",{className:"sticky top-0 z-50 w-full h-4",style:{backgroundColor:"var(--chat-surface)"}}),e[3]=c):c=e[3];let d;e[4]!==n.user?(d=T.jsx("div",{className:"sticky mb-3 top-4 z-50",children:T.jsx(gQ,{message:n.user,onScrollToPair:o})}),e[4]=n.user,e[5]=d):d=e[5];let p;e[6]!==r||e[7]!==n.assistant||e[8]!==i?(p=T.jsx(fQ,{message:n.assistant,status:i,isLast:r}),e[6]=r,e[7]=n.assistant,e[8]=i,e[9]=p):p=e[9];let f;return e[10]!==u||e[11]!==d||e[12]!==p?(f=T.jsxs("div",{ref:u,className:"flex flex-col pb-2",children:[c,d,p]}),e[10]=u,e[11]=d,e[12]=p,e[13]=f):f=e[13],f}const EQ="https://sites-openrouter.decocache.com/mcp",yQ="https://assets.decocache.com/decocms/b2e2f64f-6025-45f7-9e8c-3b3ebdd073d8/openrouter_logojpg.jpg";function TQ({title:t="No model provider connected",description:e="Connect to a model provider to unlock AI-powered features.",org:n}){const r=BR(),[,i]=hR(),a=Kx(),{data:s}=lR.useSession(),o=UR(),l=s?.user?.id??"",u=()=>{a({to:"/$org/$project/mcps",params:{org:n.slug,project:ss},search:{action:"create"}})},c=async()=>{if(!n.id||!l){Sn.error("Not authenticated");return}try{const d=o?.find(h=>h.connection_url===EQ);if(d){i(!1),a({to:"/$org/$project/mcps/$connectionId",params:{org:n.slug,project:ss,connectionId:d.id}});return}const p=gR({id:HR("conn")}),f=await r.create.mutateAsync(p);i(!1),a({to:"/$org/$project/mcps/$connectionId",params:{org:n.slug,project:ss,connectionId:f.id}})}catch(d){Sn.error(`Failed to connect OpenRouter: ${d instanceof Error?d.message:String(d)}`)}};return T.jsx(FR,{image:T.jsx("img",{src:"/empty-state-openrouter.svg",alt:"",width:336,height:320,"aria-hidden":"true",className:"w-xs h-auto mask-radial-[100%_100%] mask-radial-from-20% mask-radial-to-50% mask-radial-at-center"}),title:t,description:e,actions:T.jsxs(T.Fragment,{children:[T.jsxs(ze,{variant:"outline",onClick:c,disabled:r.create.isPending,children:[T.jsx("img",{src:yQ,alt:"OpenRouter",className:"size-4"}),r.create.isPending?"Installing...":"Install OpenRouter"]}),T.jsx(ze,{variant:"outline",onClick:u,children:"Install Connection"})]})})}function SQ(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),a=Math.floor(r/36e5);return i<1?"now":i<60?`${i}m`:`${a}h`}function AQ(t){const e=new Date,n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date(n.getTime()-864e5),i=new Date(n.getTime()-7*864e5),a=new Date(n.getTime()-30*864e5),s=[],o=[],l=[],u=[],c=[];for(const p of t){const f=new Date(p.updated_at);f>=n?s.push(p):f>=r?o.push(p):f>=i?l.push(p):f>=a?u.push(p):c.push(p)}const d=[];return s.length>0&&d.push({label:"Today",threads:s,showRelativeTime:!0}),o.length>0&&d.push({label:"Yesterday",threads:o,showRelativeTime:!1}),l.length>0&&d.push({label:"7 days ago",threads:l,showRelativeTime:!1}),u.length>0&&d.push({label:"30 days ago",threads:u,showRelativeTime:!1}),c.length>0&&d.push({label:"Older",threads:c,showRelativeTime:!1}),d}function kQ(t){const e=te.c(51),{variant:n}=t,r=n===void 0?"icon":n,[i,a]=P.useState(""),{activeThreadId:s,switchToThread:o,threads:l,hasNextPage:u,isFetchingNextPage:c,fetchNextPage:d,hideThread:p}=vr(),f=P.useRef(null),h=P.useRef(null);let g;e[0]!==d||e[1]!==u||e[2]!==c?(g=G=>{h.current&&h.current.disconnect(),G&&u&&!c&&d&&(h.current=new IntersectionObserver(H=>{H[0]?.isIntersecting&&u&&!c&&d&&d()},{rootMargin:"100px"}),h.current.observe(G)),f.current=G},e[0]=d,e[1]=u,e[2]=c,e[3]=g):g=e[3];const b=g;let E,y,S,k,x,A,v,w,N,_,D;if(e[4]!==s||e[5]!==u||e[6]!==p||e[7]!==c||e[8]!==i||e[9]!==b||e[10]!==o||e[11]!==l||e[12]!==r){const G=i.trim()?l.filter(Z=>Z.title.toLowerCase().includes(i.toLowerCase())):l,H=AQ(G);k=vo,S=xn,y=ci,e[24]!==r?(_=T.jsx(vn,{asChild:!0,children:T.jsx(di,{asChild:!0,children:r==="outline"?T.jsx(ze,{type:"button",variant:"outline",size:"icon",className:"size-7 border border-input","aria-label":"Chat history",children:T.jsx(qb,{size:16})}):T.jsx(ze,{type:"button",variant:"ghost",size:"icon",className:"size-6 p-1 hover:bg-transparent","aria-label":"Chat history",children:T.jsx(qb,{size:16,className:"text-muted-foreground hover:text-foreground transition-colors"})})})}),e[24]=r,e[25]=_):_=e[25],e[26]===Symbol.for("react.memo_cache_sentinel")?(D=T.jsx(Cn,{children:"Chat history"}),e[26]=D):D=e[26],E=pi,v="end",w="w-80 p-0";let J;e[27]===Symbol.for("react.memo_cache_sentinel")?(J=T.jsx(iv,{size:16,className:"text-muted-foreground shrink-0"}),e[27]=J):J=e[27];let I;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=Z=>a(Z.target.value),e[28]=I):I=e[28],e[29]!==i?(N=T.jsx("div",{className:"border-b",children:T.jsxs("label",{className:"flex items-center gap-2.5 h-12 px-4 cursor-text",children:[J,T.jsx("input",{type:"text",placeholder:"Search chats...",value:i,onChange:I,className:"flex-1 border-0 shadow-none focus:outline-none px-0 h-full text-sm placeholder:text-muted-foreground/50 bg-transparent"})]})}),e[29]=i,e[30]=N):N=e[30],x="max-h-[300px] overflow-y-auto",A=G.length===0?T.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:i.trim()?"No chats found":"No chats yet"}):T.jsxs(T.Fragment,{children:[H.map((Z,ae)=>T.jsxs("div",{children:[ae>0&&T.jsx("div",{className:"border-t mx-3"}),T.jsx("div",{className:"px-3 py-1",children:T.jsx("span",{className:"text-xs font-medium text-muted-foreground tracking-wide",children:Z.label})}),Z.threads.map(O=>{const re=O.id===s;return T.jsxs("div",{className:ce("flex items-center gap-2 px-3 py-2 hover:bg-accent cursor-pointer group",re&&"bg-accent/50"),onClick:()=>o(O.id),children:[T.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[T.jsx("span",{className:"text-sm truncate",children:O.title||"New chat"}),T.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:re?"current":Z.showRelativeTime?SQ(O.updated_at):null})]}),T.jsx("button",{type:"button",onClick:ne=>{ne.stopPropagation(),p(O.id)},className:"opacity-0 cursor-pointer group/trash group-hover:opacity-100 p-1 hover:bg-destructive/10 rounded transition-opacity",title:"Remove chat",children:T.jsx($R,{size:14,className:"text-muted-foreground group-hover/trash:text-destructive"})})]},O.id)})]},Z.label)),!i.trim()&&u&&T.jsx("div",{ref:b,className:"h-4"}),c&&T.jsx("div",{className:"p-3 text-center text-xs text-muted-foreground",children:"Loading more chats..."})]}),e[4]=s,e[5]=u,e[6]=p,e[7]=c,e[8]=i,e[9]=b,e[10]=o,e[11]=l,e[12]=r,e[13]=E,e[14]=y,e[15]=S,e[16]=k,e[17]=x,e[18]=A,e[19]=v,e[20]=w,e[21]=N,e[22]=_,e[23]=D}else E=e[13],y=e[14],S=e[15],k=e[16],x=e[17],A=e[18],v=e[19],w=e[20],N=e[21],_=e[22],D=e[23];let M;e[31]!==x||e[32]!==A?(M=T.jsx("div",{className:x,children:A}),e[31]=x,e[32]=A,e[33]=M):M=e[33];let q;e[34]!==E||e[35]!==M||e[36]!==v||e[37]!==w||e[38]!==N?(q=T.jsxs(E,{align:v,className:w,children:[N,M]}),e[34]=E,e[35]=M,e[36]=v,e[37]=w,e[38]=N,e[39]=q):q=e[39];let F;e[40]!==y||e[41]!==q||e[42]!==_||e[43]!==D?(F=T.jsxs(y,{children:[_,D,q]}),e[40]=y,e[41]=q,e[42]=_,e[43]=D,e[44]=F):F=e[44];let U;e[45]!==S||e[46]!==F?(U=T.jsx(S,{children:F}),e[45]=S,e[46]=F,e[47]=U):U=e[47];let $;return e[48]!==k||e[49]!==U?($=T.jsx(k,{children:U}),e[48]=k,e[49]=U,e[50]=$):$=e[50],$}function xQ(t){const e=te.c(11),{className:n}=t;let r;e[0]!==n?(r=ce("flex h-full w-full flex-col bg-muted",n),e[0]=n,e[1]=r):r=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=T.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),e[2]=i):i=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=T.jsxs("div",{className:"flex items-center gap-3",children:[i,T.jsxs("div",{className:"flex flex-col gap-2",children:[T.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),T.jsx("div",{className:"h-3 w-40 rounded bg-muted/60 animate-pulse"})]})]}),e[3]=a):a=e[3];let s;e[4]===Symbol.for("react.memo_cache_sentinel")?(s=T.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:T.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[a,T.jsxs("div",{className:"flex items-end gap-2",children:[T.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),T.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),e[4]=s):s=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=T.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:T.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[T.jsx(as,{align:"right",width:"w-3/4"}),T.jsx(as,{align:"left",width:"w-full",lines:3}),T.jsx(as,{align:"right",width:"w-2/3"}),T.jsx(as,{align:"left",width:"w-5/6",lines:2})]})}),e[5]=o):o=e[5];let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l=T.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:T.jsx("div",{className:"relative flex-1",children:T.jsxs("div",{className:"space-y-2 p-2",children:[T.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),T.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),e[6]=l):l=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=T.jsx("div",{className:"flex items-center gap-1",children:T.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),e[7]=u):u=e[7];let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=T.jsx("div",{className:"px-4 py-4",children:T.jsx("div",{className:"mx-auto w-full max-w-2xl",children:T.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl border border-border bg-background shadow-sm",children:[l,T.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[u,T.jsxs("div",{className:"flex items-center gap-1",children:[T.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),T.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})}),e[8]=c):c=e[8];let d;return e[9]!==r?(d=T.jsxs("div",{className:r,children:[s,o,c]}),e[9]=r,e[10]=d):d=e[10],d}function as(t){const e=te.c(22),{align:n,width:r,lines:i}=t,a=r===void 0?"w-full":r,s=i===void 0?1:i,o=n==="right"?"flex-row-reverse":"flex-row";let l;e[0]!==o?(l=ce("flex w-full gap-4 px-4 py-2",o),e[0]=o,e[1]=l):l=e[1];const u=n==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let c;e[2]!==u?(c=ce("flex min-w-0 flex-col gap-2",u),e[2]=u,e[3]=c):c=e[3];let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=T.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=d):d=e[4];const p=n==="right"?"bg-muted":"bg-transparent border border-border/40";let f;e[5]!==p||e[6]!==a?(f=ce("min-w-0 rounded-2xl p-4",p,a),e[5]=p,e[6]=a,e[7]=f):f=e[7];let h;e[8]!==s?(h=Array.from({length:s}),e[8]=s,e[9]=h):h=e[9];let g;e[10]!==s||e[11]!==h?(g=T.jsx("div",{className:"space-y-2",children:h.map((S,k)=>T.jsx("div",{className:ce("h-3 rounded bg-muted-foreground/20 animate-pulse",k===s-1?"w-3/4":"w-full"),style:{animationDelay:`${k*.1}s`}},k))}),e[10]=s,e[11]=h,e[12]=g):g=e[12];let b;e[13]!==g||e[14]!==f?(b=T.jsx("div",{className:f,children:g}),e[13]=g,e[14]=f,e[15]=b):b=e[15];let E;e[16]!==b||e[17]!==c?(E=T.jsxs("div",{className:c,children:[d,b]}),e[16]=b,e[17]=c,e[18]=E):E=e[18];let y;return e[19]!==E||e[20]!==l?(y=T.jsx("div",{className:l,children:E}),e[19]=E,e[20]=l,e[21]=y):y=e[21],y}function vQ(t){const e=te.c(8),{className:n,children:r}=t,a=n?.includes("bg-background")?"var(--background)":"var(--muted)";let s;e[0]!==n?(s=ce("flex flex-col h-full w-full bg-muted transform-[translateZ(0)]",n),e[0]=n,e[1]=s):s=e[1];let o;e[2]!==a?(o={"--chat-surface":a},e[2]=a,e[3]=o):o=e[3];const l=o;let u;return e[4]!==r||e[5]!==s||e[6]!==l?(u=T.jsx("div",{className:s,style:l,children:r}),e[4]=r,e[5]=s,e[6]=l,e[7]=u):u=e[7],u}function CQ(t){const e=te.c(5),{children:n,className:r}=t;let i;e[0]!==r?(i=ce("flex-1 min-h-0 overflow-y-auto isolate",r),e[0]=r,e[1]=i):i=e[1];let a;return e[2]!==n||e[3]!==i?(a=T.jsx("div",{className:i,children:n}),e[2]=n,e[3]=i,e[4]=a):a=e[4],a}function _Q(t){const e=te.c(2),{children:n}=t;let r;return e[0]!==n?(r=T.jsx("div",{className:"h-full w-full flex items-center justify-center max-w-2xl mx-auto",children:n}),e[0]=n,e[1]=r):r=e[1],r}function NQ(){const t=te.c(16),{messages:e,status:n}=vr(),r=bQ(e);let i;t[0]!==r?(i=r.at(-1),t[0]=r,t[1]=i):i=t[1];const a=i,s=n==="submitted"||n==="streaming";let o;if(t[2]!==s||t[3]!==a||t[4]!==r||t[5]!==e||t[6]!==n){const l=e.at(-1),u=!s&&l?.role==="assistant"&&l.parts.filter(wQ).some(IQ);let c;if(t[8]!==r||t[9]!==n){let p;t[11]!==r.length||t[12]!==n?(p=(f,h)=>T.jsx(zx,{pair:f,isLastPair:!1,status:h===r.length-1?n:void 0},`pair-${f.user.id}`),t[11]=r.length,t[12]=n,t[13]=p):p=t[13],c=r.slice(0,-1).map(p),t[8]=r,t[9]=n,t[10]=c}else c=t[10];let d;t[14]!==c?(d=T.jsx("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:c}),t[14]=c,t[15]=d):d=t[15],o=T.jsxs("div",{className:"w-full min-w-0 max-w-full overflow-y-auto h-full overflow-x-hidden",children:[d,a&&T.jsx("div",{className:ce("min-h-full min-w-0 max-w-2xl mx-auto w-full",u&&"pb-60"),children:T.jsx(zx,{pair:a,isLastPair:!0,status:n},`pair-${a?.user.id}`)})]}),t[2]=s,t[3]=a,t[4]=r,t[5]=e,t[6]=n,t[7]=o}else o=t[7];return o}function IQ(t){return t.state==="input-available"}function wQ(t){return t.type==="tool-user_ask"}function RQ(t){const e=te.c(5),{children:n,className:r}=t;let i;e[0]!==r?(i=ce("flex-none w-full mx-auto p-2","max-w-2xl min-w-0",r),e[0]=r,e[1]=i):i=e[1];let a;return e[2]!==n||e[3]!==i?(a=T.jsx("div",{className:i,children:n}),e[2]=n,e[3]=i,e[4]=a):a=e[4],a}const fJ=Object.assign(vQ,{Main:CQ,Messages:NQ,EmptyState:_Q,Footer:RQ,Input:q4,Provider:mR,Skeleton:xQ,IceBreakers:lP,NoLlmBindingEmptyState:TQ,ThreadHistoryPopover:kQ});export{fJ as C,Og as E,Tt as N,De as P,N_ as R,y4 as S,Dg as V,Gn as a,lN as b,YM as c,Z3 as d,__ as e,dv as f,IP as g,pv as i,je as m,x_ as u};
|