@decocms/mesh 2.10.0 → 2.12.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-BI-lv-P2.js → AlertCircle-Cso_Xxvk.js} +1 -1
- package/dist/client/assets/{ArrowLeft-WX776rGw.js → ArrowLeft-BrsZ2N_5.js} +1 -1
- package/dist/client/assets/{Check-Dh23dmDM.js → Check-JFkjTCfG.js} +1 -1
- package/dist/client/assets/{ChevronDown-CQl6wdMq.js → ChevronDown-HtFMO0lw.js} +1 -1
- package/dist/client/assets/{Clock-C2L66fjj.js → Clock-CW5u1cfj.js} +1 -1
- package/dist/client/assets/{Code01-BvYrq72o.js → Code01-CgNchnl3.js} +1 -1
- package/dist/client/assets/{Copy01-BX4_oHqx.js → Copy01-Dadp_RDG.js} +1 -1
- package/dist/client/assets/{DotsHorizontal-9lU8MC-X.js → DotsHorizontal-B0A7sUYv.js} +1 -1
- package/dist/client/assets/{DotsVertical-BBtotCm7.js → DotsVertical-BHUUUCDx.js} +1 -1
- package/dist/client/assets/Edit01-CxRkZTQ1.js +1 -0
- package/dist/client/assets/{File06-lv7rH_v1.js → File06-D0TXCuMx.js} +1 -1
- package/dist/client/assets/{FilterLines-WZSp93Oe.js → FilterLines-_uykt7r4.js} +1 -1
- package/dist/client/assets/{FlipBackward-CqqvNJYu.js → FlipBackward-GGMv99yc.js} +1 -1
- package/dist/client/assets/{GitBranch01-DN-LFsG4.js → GitBranch01-BUTuezlq.js} +1 -1
- package/dist/client/assets/{Grid01-bigl9l-5.js → Grid01-BbdtRdR8.js} +1 -1
- package/dist/client/assets/{Inbox01-BIZdM9VF.js → Inbox01-CgwXLK3n.js} +1 -1
- package/dist/client/assets/{InfoCircle-FggQ2WMl.js → InfoCircle-D6qJG9Nl.js} +1 -1
- package/dist/client/assets/{Key01-BHIpjeh2.js → Key01-8ewaPBuD.js} +1 -1
- package/dist/client/assets/{LinkExternal01-YcVnQhq1.js → LinkExternal01-D0Wjfr3t.js} +1 -1
- package/dist/client/assets/{Loading01-nz4zkIiQ.js → Loading01-NW_f44Lz.js} +1 -1
- package/dist/client/assets/{Lock01-DJbaRRVq.js → Lock01-BTPtPjN4.js} +1 -1
- package/dist/client/assets/{Play-Dy3YBriV.js → Play-CIMfsFF1.js} +1 -1
- package/dist/client/assets/{Plus-DRzcJPy4.js → Plus-DaP4KLuJ.js} +1 -1
- package/dist/client/assets/{SearchMd-CGgWiIHk.js → SearchMd-tOSOFUes.js} +1 -1
- package/dist/client/assets/{Terminal-DDxodu0O.js → Terminal-ANRX3jJ8.js} +1 -1
- package/dist/client/assets/{Trash01-Nn4emH5w.js → Trash01-CjDzx3jP.js} +1 -1
- package/dist/client/assets/{X-CSDtf13Z.js → X-D3ljCSd1.js} +1 -1
- package/dist/client/assets/{XClose-Da4Q_9Br.js → XClose-Ba3zyI0J.js} +1 -1
- package/dist/client/assets/{alert-dialog-BrdP9Xiy.js → alert-dialog-_Gzpv9vf.js} +1 -1
- package/dist/client/assets/{auth-BkX07Kdp.js → auth-C9dSkS_x.js} +1 -1
- package/dist/client/assets/{auth-catchall-CgZMKj4U.js → auth-catchall-DRL5ZGJM.js} +1 -1
- package/dist/client/assets/{avatar-DVkpHhcq.js → avatar-D1o5pnzU.js} +1 -1
- package/dist/client/assets/{badge-DZOpuutl.js → badge-0b6sJe4S.js} +1 -1
- package/dist/client/assets/{card-VaGCmdRN.js → card-B3fsloDi.js} +1 -1
- package/dist/client/assets/{checkbox-B6_pb64c.js → checkbox-2xIaHvS4.js} +1 -1
- package/dist/client/assets/{collection-detail-BZTq36Jq.js → collection-detail-Bu5gtjud.js} +31 -31
- package/dist/client/assets/{collection-display-button-0kCgwjcX.js → collection-display-button-BGIcja12.js} +1 -1
- package/dist/client/assets/{collection-header-C5jLEW4T.js → collection-header-DhWbmVkk.js} +1 -1
- package/dist/client/assets/{collection-page-BxN-pfZ4.js → collection-page-B4ZjGX9V.js} +1 -1
- package/dist/client/assets/{collection-search-DCk3URyd.js → collection-search-CYZk6T6Z.js} +1 -1
- package/dist/client/assets/collection-tab-IeT0mJ-2.js +1 -0
- package/dist/client/assets/{collection-table-wrapper-DbtYisXO.js → collection-table-wrapper-D2niE2Ci.js} +1 -1
- package/dist/client/assets/connection-card-D0c_wvmz.js +1 -0
- package/dist/client/assets/connection-detail-BmNPUV8x.js +1 -0
- package/dist/client/assets/connections-U2y3agtD.js +1 -0
- package/dist/client/assets/constants-Cy709IUA.js +1 -0
- package/dist/client/assets/{create-organization-dialog-BcohdvN6.js → create-organization-dialog-D0WQQsLG.js} +1 -1
- package/dist/client/assets/{dialog-rGW8NOdv.js → dialog-BXeLl5mO.js} +1 -1
- package/dist/client/assets/{dropdown-menu-DEdU2p2E.js → dropdown-menu-CnL8UM0z.js} +1 -1
- package/dist/client/assets/{empty-state-C6fFQCSt.js → empty-state-BmkZOMzL.js} +1 -1
- package/dist/client/assets/empty-state-DzS1Zp7m.js +2 -0
- package/dist/client/assets/{env-vars-editor-DtIOMaFz.js → env-vars-editor-B_mIaT86.js} +1 -1
- package/dist/client/assets/{error-boundary-B28JvE1I.js → error-boundary-BQnJ9S9E.js} +1 -1
- package/dist/client/assets/{extract-connection-data-fJTZE6Hc.js → extract-connection-data-DPoJQhk8.js} +1 -1
- package/dist/client/assets/{form-CE1tfcze.js → form-DrOt6d2d.js} +1 -1
- package/dist/client/assets/gateway-detail-CniDbJPb.js +1 -0
- package/dist/client/assets/gateways-DmEpJOpx.js +1 -0
- package/dist/client/assets/{home-lONkAboE.js → home-HrkEcREJ.js} +1 -1
- package/dist/client/assets/{index-CJEYCkTv.js → index-Bb8rHnPb.js} +1 -1
- package/dist/client/assets/index-CBIrwxtj.js +88 -0
- package/dist/client/assets/index-ChrSnaFS.css +1 -0
- package/dist/client/assets/{index-Dc4mPG7D.js → index-DMNk-OUX.js} +3 -3
- package/dist/client/assets/index-GoXtajA4.js +25 -0
- package/dist/client/assets/{index-CGbuv4sL.js → index-XOpbMEap.js} +1 -1
- package/dist/client/assets/{input-CLQFaB_P.js → input-68J17rBp.js} +1 -1
- package/dist/client/assets/{layout-D-qTqL0P.js → layout-Olb4shdE.js} +1 -1
- package/dist/client/assets/{lazy-highlighter-CM_r6Qg6.js → lazy-highlighter-Ccgc_fxj.js} +1 -1
- package/dist/client/assets/localstorage-keys-C62ZbWuB.js +1 -0
- package/dist/client/assets/{login-CY0fBMtA.js → login-UTKAAaeX.js} +1 -1
- package/dist/client/assets/{mcp-oauth-DwoWo555.js → mcp-oauth-Db8WtQ8u.js} +1 -1
- package/dist/client/assets/mcp-server-detail-BvVQovUz.js +1 -0
- package/dist/client/assets/members-V-vtwMYY.js +3 -0
- package/dist/client/assets/{monaco-editor-CGmVJ7Sz.js → monaco-editor-B_MycISs.js} +1 -1
- package/dist/client/assets/{monitoring-8m7n1ABH.js → monitoring-CBmCnQ7i.js} +20 -20
- package/dist/client/assets/{oauth-callback-C3UTt1IM.js → oauth-callback-BYBqbF1w.js} +1 -1
- package/dist/client/assets/page-DYF0Qz3l.js +1 -0
- package/dist/client/assets/page-DrIZd1pO.js +35 -0
- package/dist/client/assets/{pin-to-sidebar-button-DmlmCu_p.js → pin-to-sidebar-button-B1xHHS9n.js} +1 -1
- package/dist/client/assets/{popover-Bt6Irkfs.js → popover-DC9U4d6e.js} +1 -1
- package/dist/client/assets/{project-context-provider-jIErvTKU.js → project-context-provider-BJIP5a-U.js} +1 -1
- package/dist/client/assets/{resizable-BDACILOB.js → resizable-CW5_SPIS.js} +1 -1
- package/dist/client/assets/{resource-tabs-B9UXtdu9.js → resource-tabs-BKSlcL1W.js} +1 -1
- package/dist/client/assets/{select-CXOQrDyU.js → select-B9KJyTZZ.js} +1 -1
- package/dist/client/assets/{settings-Cml1v0xs.js → settings-CYg4YPRI.js} +1 -1
- package/dist/client/assets/shell-layout-KIN6fL5j.js +3 -0
- package/dist/client/assets/{spinner-C-rDsJGC.js → spinner-B0sczm1j.js} +1 -1
- package/dist/client/assets/{switch-C2oVrx7C.js → switch-BuVvmF04.js} +1 -1
- package/dist/client/assets/{textarea-DxDFaLzd.js → textarea-BAUX8Qgd.js} +1 -1
- package/dist/client/assets/thread-history-popover-Dv63nk6L.js +20 -0
- package/dist/client/assets/tool-set-selector-DMsE0yRo.js +1 -0
- package/dist/client/assets/tools-list-Dgf0oqyC.js +1 -0
- package/dist/client/assets/{use-binding-C_WCv3Kw.js → use-binding-Dj4lal1A.js} +1 -1
- package/dist/client/assets/use-connection-DoWszS3j.js +1 -0
- package/dist/client/assets/{use-connection-resources-DAy5w-Ms.js → use-connection-resources-BywYCfzc.js} +1 -1
- package/dist/client/assets/use-create-gateway-Ca5SEa8I.js +1 -0
- package/dist/client/assets/use-gateway-CRpsitbG.js +1 -0
- package/dist/client/assets/{use-gateway-system-prompt-B0FWJC8i.js → use-gateway-system-prompt-B4ia2QxW.js} +1 -1
- package/dist/client/assets/{use-list-state-D9IMsf4Z.js → use-list-state-CPUcOhR_.js} +1 -1
- package/dist/client/assets/use-mcp-L2lisTXg.js +1 -0
- package/dist/client/assets/{use-members-BrVgN1Nv.js → use-members-7eRdYOTr.js} +1 -1
- package/dist/client/assets/{use-mobile-BmTi-FB3.js → use-mobile--ytA5LT5.js} +1 -1
- package/dist/client/assets/use-organization-settings-D6rXW2c_.js +1 -0
- package/dist/client/assets/use-tool-call-BBonHr6l.js +1 -0
- package/dist/client/assets/{value-Duay7dd7.js → value-Bd2XBV_y.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-Q_4Hio7O.js → view-mode-toggle-BpjQ6V4P.js} +1 -1
- package/dist/client/assets/well-known-mcp-D13f-8h2.js +1 -0
- package/dist/client/assets/workflow-CjynHD6b.js +1 -0
- package/dist/client/index.html +2 -2
- package/dist/server/cli.js +161 -133
- package/dist/server/migrate.js +2 -2
- package/dist/server/server.js +162 -134
- package/package.json +1 -1
- package/dist/client/assets/collection-tab-BK4lXf-5.js +0 -1
- package/dist/client/assets/connection-card-CtcQXchE.js +0 -1
- package/dist/client/assets/connection-detail-Dtnc6jAX.js +0 -1
- package/dist/client/assets/connections-BkTTX2-6.js +0 -1
- package/dist/client/assets/constants-D7HtiX2k.js +0 -1
- package/dist/client/assets/gateway-detail-DpvUxeca.js +0 -1
- package/dist/client/assets/gateways-DPTsKKk2.js +0 -1
- package/dist/client/assets/index-B-_GLG4a.js +0 -25
- package/dist/client/assets/index-DjBifmxL.js +0 -88
- package/dist/client/assets/index-KJvlasGf.css +0 -1
- package/dist/client/assets/localstorage-keys-Csxol0-8.js +0 -1
- package/dist/client/assets/mcp-server-detail-BfkMNCXA.js +0 -1
- package/dist/client/assets/members-DlfrW4qm.js +0 -3
- package/dist/client/assets/page-CjTfwiJs.js +0 -1
- package/dist/client/assets/page-Cm8i9onu.js +0 -35
- package/dist/client/assets/shell-layout-BC-hIRVP.js +0 -3
- package/dist/client/assets/thread-history-popover-D_x2TXEl.js +0 -72
- package/dist/client/assets/tool-set-selector-B03cDU_f.js +0 -1
- package/dist/client/assets/tools-list-CCvCpz3e.js +0 -1
- package/dist/client/assets/use-connection-D1oWmd80.js +0 -2
- package/dist/client/assets/use-gateway-DEBoqh3W.js +0 -1
- package/dist/client/assets/use-mcp-BSK2ddKq.js +0 -1
- package/dist/client/assets/use-organization-settings-DPGpmRIO.js +0 -1
- package/dist/client/assets/use-tool-call-B5UsmKnA.js +0 -1
- package/dist/client/assets/useQuery-CjN7yze9.js +0 -1
- package/dist/client/assets/well-known-mcp-7PcWXInp.js +0 -1
- package/dist/client/assets/workflow-C6xPZGlX.js +0 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import{aF as We,r as O,v as mh,w as lo,c as I,j as m,k as Ci,y as gh,h as yh,d as Et,b as xh,t as Ec,B as ee,z as bh,aG as Tc,a6 as kh,a5 as Sh,aH as wh,ac as Mc,ar as Ac,au as vh,ad as Ni,af as Ge,ae as Oc,av as Ch,ai as Ei,as as Nh,aa as Ic,aB as Eh,aC as Th,aD as Mh,aI as Ti,aJ as Ah,at as Oh,aK as Ih,ab as Rh,aL as jh,aE as Rc}from"./index-Dc4mPG7D.js";import{U as qt,E as jc,d as Mi,e as Ai,c as qe,b as Oi,I as js,u as Dh,n as Ph}from"./use-connection-D1oWmd80.js";import{E as Dc}from"./error-boundary-B28JvE1I.js";import{P as Ii}from"./pin-to-sidebar-button-DmlmCu_p.js";import{B as me,I as Ri,c as J}from"./input-CLQFaB_P.js";import{F as ao,a as Lh,b as ji,d as Di}from"./form-CE1tfcze.js";import{T as Ho}from"./textarea-DxDFaLzd.js";import{b as Lt,T as $t,a as zt,c as _t}from"./project-context-provider-jIErvTKU.js";import{i as Pc}from"./FlipBackward-CqqvNJYu.js";import{a as Lc,V as Pi,b as Sn}from"./layout-D-qTqL0P.js";import{i as $h}from"./AlertCircle-BI-lv-P2.js";import{s as zh}from"./Clock-C2L66fjj.js";import{i as _h}from"./Code01-BvYrq72o.js";import{a as Bh}from"./Copy01-BX4_oHqx.js";import{i as tr}from"./Loading01-nz4zkIiQ.js";import{i as Li,n as Fh}from"./Play-Dy3YBriV.js";import{s as $i}from"./XClose-Da4Q_9Br.js";import{u as Vh,O as Hh,M as Wh,F as qh,v as Uh}from"./index-B-_GLG4a.js";import{u as zi}from"./use-mcp-BSK2ddKq.js";import{M as On}from"./monaco-editor-CGmVJ7Sz.js";import{E as _i}from"./empty-state-C6fFQCSt.js";import{D as Kh,u as Jh}from"./use-binding-C_WCv3Kw.js";import{u as Gh}from"./use-gateway-DEBoqh3W.js";import{b as Xh,R as Bl,a as Yh}from"./resizable-BDACILOB.js";import{G as Qh,p as Zh,q as $c,R as ep,r as tp,T as np}from"./index-DjBifmxL.js";import{S as Ds}from"./spinner-C-rDsJGC.js";import{V as rp}from"./view-mode-toggle-Q_4Hio7O.js";import{i as sp}from"./GitBranch01-DN-LFsG4.js";import{a as Bi,b as Fi}from"./use-tool-call-B5UsmKnA.js";import{a as op,D as ip,g as lp,f as ap,c as cp,d as dp}from"./dialog-rGW8NOdv.js";import"./index-CGbuv4sL.js";import{s as zc}from"./Plus-DRzcJPy4.js";import{i as Vi}from"./Check-Dh23dmDM.js";import{i as up}from"./DotsHorizontal-9lU8MC-X.js";import{b as fp,D as hp,a as pp,c as Fl}from"./dropdown-menu-DEdU2p2E.js";import{i as mp}from"./Grid01-bigl9l-5.js";import{B as un}from"./badge-DZOpuutl.js";import{i as _c}from"./X-CSDtf13Z.js";import"./use-organization-settings-DPGpmRIO.js";import"./ArrowLeft-WX776rGw.js";import"./mcp-oauth-DwoWo555.js";import"./auth-BkX07Kdp.js";import"./env-vars-editor-DtIOMaFz.js";import"./Trash01-Nn4emH5w.js";import"./File06-lv7rH_v1.js";import"./Key01-BHIpjeh2.js";import"./select-CXOQrDyU.js";import"./ChevronDown-CQl6wdMq.js";import"./Terminal-DDxodu0O.js";import"./index-CJEYCkTv.js";import"./constants-D7HtiX2k.js";import"./registry-utils-B7t_ZBUi.js";import"./extract-connection-data-fJTZE6Hc.js";import"./github-icon-Dp3wHhYE.js";import"./generate-id-Dyweu44Y.js";import"./useQuery-CjN7yze9.js";import"./well-known-mcp-7PcWXInp.js";import"./SearchMd-CGgWiIHk.js";import"./localstorage-keys-Csxol0-8.js";import"./alert-dialog-BrdP9Xiy.js";import"./use-mobile-BmTi-FB3.js";import"./InfoCircle-FggQ2WMl.js";const Bc=We("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);const Fc=We("Braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);const Hi=We("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Wi=We("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const gp=We("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const yp=We("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Vc=We("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const Hc=We("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);const Wc=We("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);const qc=We("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);const Uc=We("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]),qi=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M12 8v4m0 4h.01M2 8.523v6.954c0 .245 0 .367.028.482a1 1 0 0 0 .12.29c.061.1.148.187.32.36l4.923 4.922c.173.173.26.26.36.322.09.054.188.095.29.12.115.027.237.027.482.027h6.954c.245 0 .367 0 .482-.028a.998.998 0 0 0 .29-.12c.1-.061.187-.148.36-.32l4.922-4.923c.173-.173.26-.26.322-.36a.998.998 0 0 0 .12-.29c.027-.115.027-.237.027-.482V8.523c0-.245 0-.367-.028-.482a.998.998 0 0 0-.12-.29c-.061-.1-.148-.187-.32-.36L16.608 2.47c-.173-.173-.26-.26-.36-.322a1 1 0 0 0-.29-.12C15.844 2 15.722 2 15.477 2H8.523c-.245 0-.367 0-.482.028a1 1 0 0 0-.29.12c-.1.061-.187.148-.36.32L2.47 7.392c-.173.173-.26.26-.322.36a1 1 0 0 0-.12.29C2 8.156 2 8.278 2 8.523Z"}));qi.displayName="AlertOctagon";const Kc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M20.5 8v8.2c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.22 21 17.38 21 15.7 21H8.3c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3.5 18.72 3.5 17.88 3.5 16.2V8m.1-5h16.8c.56 0 .84 0 1.054.109a1 1 0 0 1 .437.437C22 3.76 22 4.04 22 4.6v1.8c0 .56 0 .84-.109 1.054a1 1 0 0 1-.437.437C21.24 8 20.96 8 20.4 8H3.6c-.56 0-.84 0-1.054-.109a1 1 0 0 1-.437-.437C2 7.24 2 6.96 2 6.4V4.6c0-.56 0-.84.109-1.054a1 1 0 0 1 .437-.437C2.76 3 3.04 3 3.6 3Zm6 8.5h4.8c.56 0 .84 0 1.054.109a1 1 0 0 1 .437.437C16 12.26 16 12.54 16 13.1v.8c0 .56 0 .84-.109 1.054a1 1 0 0 1-.437.437c-.214.109-.494.109-1.054.109H9.6c-.56 0-.84 0-1.054-.109a1 1 0 0 1-.437-.437C8 14.74 8 14.46 8 13.9v-.8c0-.56 0-.84.109-1.054a1 1 0 0 1 .437-.437C8.76 11.5 9.04 11.5 9.6 11.5Z"}));Kc.displayName="Box";const Jc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"m22.7 11.5-2 2-2-2m2.245 1.5A9 9 0 1 0 19 17.657M12 7v5l3 2"}));Jc.displayName="ClockFastForward";const Gc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"m17 17 5-5-5-5M7 7l-5 5 5 5m7-14-4 18"}));Gc.displayName="Code02";const jr=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M6.8 3h-.6c-1.12 0-1.68 0-2.108.218a2 2 0 0 0-.874.874C3 4.52 3 5.08 3 6.2v11.6c0 1.12 0 1.68.218 2.108a2 2 0 0 0 .874.874C4.52 21 5.08 21 6.2 21h.6c1.12 0 1.68 0 2.108-.218a2 2 0 0 0 .874-.874C10 19.48 10 18.92 10 17.8V6.2c0-1.12 0-1.68-.218-2.108a2 2 0 0 0-.874-.874C8.48 3 7.92 3 6.8 3Zm11 0h-.6c-1.12 0-1.68 0-2.108.218a2 2 0 0 0-.874.874C14 4.52 14 5.08 14 6.2v11.6c0 1.12 0 1.68.218 2.108a2 2 0 0 0 .874.874C15.52 21 16.08 21 17.2 21h.6c1.12 0 1.68 0 2.108-.218a2 2 0 0 0 .874-.874C21 19.48 21 18.92 21 17.8V6.2c0-1.12 0-1.68-.218-2.108a2 2 0 0 0-.874-.874C19.48 3 18.92 3 17.8 3Z"}));jr.displayName="Columns01";const Xc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M4 4v1.4c0 3.36 0 5.04.654 6.324a6 6 0 0 0 2.622 2.622C8.56 15 10.24 15 13.6 15H20m0 0-5-5m5 5-5 5"}));Xc.displayName="CornerDownRight";const Yc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M21 5c0 1.657-4.03 3-9 3S3 6.657 3 5m18 0c0-1.657-4.03-3-9-3S3 3.343 3 5m18 0v14c0 1.66-4 3-9 3s-9-1.34-9-3V5m18 7c0 1.66-4 3-9 3s-9-1.34-9-3"}));Yc.displayName="Database01";const Qc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"m13 22-3-3m0 0 3-3m-3 3h5a7 7 0 0 0 3-13.326M6 18.326A7 7 0 0 1 9 5h5m0 0-3-3m3 3-3 3"}));Qc.displayName="Repeat03";const Ui=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M15 8H8.6c-.56 0-.84 0-1.054-.109a1 1 0 0 1-.437-.437C7 7.24 7 6.96 7 6.4V3m10 18v-6.4c0-.56 0-.84-.109-1.054a1 1 0 0 0-.437-.437C16.24 13 15.96 13 15.4 13H8.6c-.56 0-.84 0-1.054.109a1 1 0 0 0-.437.437C7 13.76 7 14.04 7 14.6V21M21 9.325V16.2c0 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.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h6.875c.489 0 .733 0 .963.055.204.05.4.13.579.24.201.123.374.296.72.642l3.126 3.126c.346.346.519.519.642.72.11.18.19.374.24.579.055.23.055.474.055.963Z"}));Ui.displayName="Save02";const Zc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M15.631 7.631c-.396-.396-.594-.594-.668-.822a1 1 0 0 1 0-.618c.074-.228.272-.426.668-.822L18.47 2.53a6 6 0 0 0-8.3 6.895c.12.49.179.734.168.888a.849.849 0 0 1-.11.392c-.07.138-.207.274-.48.547L3.5 17.5a2.121 2.121 0 0 0 3 3l6.248-6.248c.273-.273.41-.41.547-.48a.849.849 0 0 1 .392-.11c.154-.011.399.049.888.168a6 6 0 0 0 6.895-8.3l-2.84 2.84c-.396.396-.594.594-.822.668a1 1 0 0 1-.618 0c-.228-.074-.426-.272-.822-.668l-.738-.738Z"}));Zc.displayName="Tool01";const{getOwnPropertyNames:xp,getOwnPropertySymbols:bp}=Object,{hasOwnProperty:kp}=Object.prototype;function co(n,e){return function(r,s,o){return n(r,s,o)&&e(r,s,o)}}function kr(n){return function(t,r,s){if(!t||!r||typeof t!="object"||typeof r!="object")return n(t,r,s);const{cache:o}=s,i=o.get(t),l=o.get(r);if(i&&l)return i===r&&l===t;o.set(t,r),o.set(r,t);const a=n(t,r,s);return o.delete(t),o.delete(r),a}}function Sp(n){return n?.[Symbol.toStringTag]}function Vl(n){return xp(n).concat(bp(n))}const wp=Object.hasOwn||((n,e)=>kp.call(n,e));function Yt(n,e){return n===e||!n&&!e&&n!==n&&e!==e}const vp="__v",Cp="__o",Np="_owner",{getOwnPropertyDescriptor:Hl,keys:Wl}=Object;function Ep(n,e){return n.byteLength===e.byteLength&&Br(new Uint8Array(n),new Uint8Array(e))}function Tp(n,e,t){let r=n.length;if(e.length!==r)return!1;for(;r-- >0;)if(!t.equals(n[r],e[r],r,r,n,e,t))return!1;return!0}function Mp(n,e){return n.byteLength===e.byteLength&&Br(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Ap(n,e){return Yt(n.getTime(),e.getTime())}function Op(n,e){return n.name===e.name&&n.message===e.message&&n.cause===e.cause&&n.stack===e.stack}function Ip(n,e){return n===e}function ql(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.entries();let i,l,a=0;for(;(i=o.next())&&!i.done;){const c=e.entries();let d=!1,u=0;for(;(l=c.next())&&!l.done;){if(s[u]){u++;continue}const f=i.value,h=l.value;if(t.equals(f[0],h[0],a,u,n,e,t)&&t.equals(f[1],h[1],f[0],h[0],n,e,t)){d=s[u]=!0;break}u++}if(!d)return!1;a++}return!0}const Rp=Yt;function jp(n,e,t){const r=Wl(n);let s=r.length;if(Wl(e).length!==s)return!1;for(;s-- >0;)if(!ed(n,e,t,r[s]))return!1;return!0}function zn(n,e,t){const r=Vl(n);let s=r.length;if(Vl(e).length!==s)return!1;let o,i,l;for(;s-- >0;)if(o=r[s],!ed(n,e,t,o)||(i=Hl(n,o),l=Hl(e,o),(i||l)&&(!i||!l||i.configurable!==l.configurable||i.enumerable!==l.enumerable||i.writable!==l.writable)))return!1;return!0}function Dp(n,e){return Yt(n.valueOf(),e.valueOf())}function Pp(n,e){return n.source===e.source&&n.flags===e.flags}function Ul(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.values();let i,l;for(;(i=o.next())&&!i.done;){const a=e.values();let c=!1,d=0;for(;(l=a.next())&&!l.done;){if(!s[d]&&t.equals(i.value,l.value,i.value,l.value,n,e,t)){c=s[d]=!0;break}d++}if(!c)return!1}return!0}function Br(n,e){let t=n.byteLength;if(e.byteLength!==t||n.byteOffset!==e.byteOffset)return!1;for(;t-- >0;)if(n[t]!==e[t])return!1;return!0}function Lp(n,e){return n.hostname===e.hostname&&n.pathname===e.pathname&&n.protocol===e.protocol&&n.port===e.port&&n.hash===e.hash&&n.username===e.username&&n.password===e.password}function ed(n,e,t,r){return(r===Np||r===Cp||r===vp)&&(n.$$typeof||e.$$typeof)?!0:wp(e,r)&&t.equals(n[r],e[r],r,r,n,e,t)}const $p="[object ArrayBuffer]",zp="[object Arguments]",_p="[object Boolean]",Bp="[object DataView]",Fp="[object Date]",Vp="[object Error]",Hp="[object Map]",Wp="[object Number]",qp="[object Object]",Up="[object RegExp]",Kp="[object Set]",Jp="[object String]",Gp={"[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},Xp="[object URL]",Yp=Object.prototype.toString;function Qp({areArrayBuffersEqual:n,areArraysEqual:e,areDataViewsEqual:t,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:o,areMapsEqual:i,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:c,areRegExpsEqual:d,areSetsEqual:u,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:p}){return function(g,x,b){if(g===x)return!0;if(g==null||x==null)return!1;const S=typeof g;if(S!==typeof x)return!1;if(S!=="object")return S==="number"?l(g,x,b):S==="function"?o(g,x,b):!1;const v=g.constructor;if(v!==x.constructor)return!1;if(v===Object)return a(g,x,b);if(Array.isArray(g))return e(g,x,b);if(v===Date)return r(g,x,b);if(v===RegExp)return d(g,x,b);if(v===Map)return i(g,x,b);if(v===Set)return u(g,x,b);const k=Yp.call(g);if(k===Fp)return r(g,x,b);if(k===Up)return d(g,x,b);if(k===Hp)return i(g,x,b);if(k===Kp)return u(g,x,b);if(k===qp)return typeof g.then!="function"&&typeof x.then!="function"&&a(g,x,b);if(k===Xp)return h(g,x,b);if(k===Vp)return s(g,x,b);if(k===zp)return a(g,x,b);if(Gp[k])return f(g,x,b);if(k===$p)return n(g,x,b);if(k===Bp)return t(g,x,b);if(k===_p||k===Wp||k===Jp)return c(g,x,b);if(p){let w=p[k];if(!w){const C=Sp(g);C&&(w=p[C])}if(w)return w(g,x,b)}return!1}}function Zp({circular:n,createCustomConfig:e,strict:t}){let r={areArrayBuffersEqual:Ep,areArraysEqual:t?zn:Tp,areDataViewsEqual:Mp,areDatesEqual:Ap,areErrorsEqual:Op,areFunctionsEqual:Ip,areMapsEqual:t?co(ql,zn):ql,areNumbersEqual:Rp,areObjectsEqual:t?zn:jp,arePrimitiveWrappersEqual:Dp,areRegExpsEqual:Pp,areSetsEqual:t?co(Ul,zn):Ul,areTypedArraysEqual:t?co(Br,zn):Br,areUrlsEqual:Lp,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),n){const s=kr(r.areArraysEqual),o=kr(r.areMapsEqual),i=kr(r.areObjectsEqual),l=kr(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:o,areObjectsEqual:i,areSetsEqual:l})}return r}function em(n){return function(e,t,r,s,o,i,l){return n(e,t,l)}}function tm({circular:n,comparator:e,createState:t,equals:r,strict:s}){if(t)return function(l,a){const{cache:c=n?new WeakMap:void 0,meta:d}=t();return e(l,a,{cache:c,equals:r,meta:d,strict:s})};if(n)return function(l,a){return e(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const o={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,a){return e(l,a,o)}}const nm=Tt();Tt({strict:!0});Tt({circular:!0});Tt({circular:!0,strict:!0});Tt({createInternalComparator:()=>Yt});Tt({strict:!0,createInternalComparator:()=>Yt});Tt({circular:!0,createInternalComparator:()=>Yt});Tt({circular:!0,createInternalComparator:()=>Yt,strict:!0});function Tt(n={}){const{circular:e=!1,createInternalComparator:t,createState:r,strict:s=!1}=n,o=Zp(n),i=Qp(o),l=t?t(i):em(i);return tm({circular:e,comparator:i,createState:r,equals:l,strict:s})}mh({title:lo().min(1),description:lo().nullable(),body:lo()});function uo(n){for(const e of n.messages??[])if(e.role==="user"&&e.content?.type==="text")return e.content.text??"";return""}function rm(){const n=window.location.pathname.split("/").filter(Boolean),e=n.findIndex(r=>r==="mcps"),t=e>=0?n[e+1]:void 0;return t?decodeURIComponent(t):void 0}function sm(n){const e=I.c(13),{form:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"text-sm font-medium text-foreground",children:"Details"}),e[0]=r):r=e[0];let s;e[1]!==t.control?(s=m.jsxs("div",{className:"flex flex-col gap-4",children:[r,m.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[m.jsx(ao,{control:t.control,name:"title",render:lm}),m.jsx(ao,{control:t.control,name:"description",render:im})]})]}),e[1]=t.control,e[2]=s):s=e[2];let o,i;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=m.jsx("div",{className:"text-sm font-medium text-foreground",children:"Message"}),i=m.jsx("div",{className:"text-xs text-muted-foreground",children:"This becomes the user message in the prompt."}),e[3]=o,e[4]=i):(o=e[3],i=e[4]);let l;e[5]!==t.control?(l=m.jsxs("div",{className:"flex flex-col gap-2",children:[o,i,m.jsx(ao,{control:t.control,name:"body",render:om})]}),e[5]=t.control,e[6]=l):l=e[6];let a;e[7]!==s||e[8]!==l?(a=m.jsxs("div",{className:"h-full py-6 flex flex-col max-w-3xl mx-auto w-full min-w-0 gap-8 overflow-y-auto px-4",children:[s,l]}),e[7]=s,e[8]=l,e[9]=a):a=e[9];let c;return e[10]!==t||e[11]!==a?(c=m.jsx(Lh,{...t,children:a}),e[10]=t,e[11]=a,e[12]=c):c=e[12],c}function om(n){const{field:e}=n;return m.jsx(ji,{children:m.jsx(Di,{children:m.jsx(Ho,{...e,value:e.value??"",placeholder:"Write the prompt message…",className:"min-h-[240px] resize-none text-base leading-relaxed font-normal rounded-xl border border-border bg-muted/20 px-4 py-3 shadow-none focus-visible:ring-0"})})})}function im(n){const{field:e}=n;return m.jsxs(ji,{children:[m.jsx("div",{className:"text-xs text-muted-foreground",children:"Description"}),m.jsx(Di,{children:m.jsx(Ri,{...e,value:e.value??"",placeholder:"Add a description…",className:"h-9 rounded-lg border border-border bg-muted/20 shadow-none focus-visible:ring-0"})})]})}function lm(n){const{field:e}=n;return m.jsxs(ji,{children:[m.jsx("div",{className:"text-xs text-muted-foreground",children:"Title"}),m.jsx(Di,{children:m.jsx(Ri,{...e,placeholder:"Untitled prompt",className:"h-9 rounded-lg border border-border bg-muted/20 shadow-none focus-visible:ring-0"})})]})}function am(n){const e=I.c(51),{providerId:t,promptId:r,onBack:s}=n,i=Ci().location.href,l=t||qt;let a;e[0]!==l?(a=qe(l),e[0]=l,e[1]=a):a=e[1];const c=a,d=Mi(t,"PROMPT",r,c),u=Ai(t,"PROMPT",c),f=u.update.isPending;let h;e[2]!==d?(h=d?{title:d.title,description:d.description??null,body:uo(d)}:void 0,e[2]=d,e[3]=h):h=e[3];let p;e[4]!==h?(p={values:h},e[4]=h,e[5]=p):p=e[5];const y=gh(p);let g;e[6]!==y||e[7]!==d?(g=()=>{d&&y.reset({title:d.title,description:d.description??null,body:uo(d)})},e[6]=y,e[7]=d,e[8]=g):g=e[8];const x=g;let b;e[9]!==u.update||e[10]!==y||e[11]!==r?(b=y.handleSubmit(async X=>{const fe=await u.update.mutateAsync({id:r,data:{title:X.title,description:X.description,arguments:[],icons:[],messages:[{role:"user",content:{type:"text",text:X.body}}]}});y.reset({title:fe.title,description:fe.description??null,body:uo(fe)})}),e[9]=u.update,e[10]=y,e[11]=r,e[12]=b):b=e[12];const S=b;if(!d){let X;return e[13]===Symbol.for("react.memo_cache_sentinel")?(X=m.jsx("div",{className:"flex h-full w-full bg-background",children:m.jsx(jc,{title:"Prompt not found",description:"This prompt may have been deleted or you may not have access to it."})}),e[13]=X):X=e[13],X}let v;e[14]!==d.title?(v=m.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:d.title}),e[14]=d.title,e[15]=v):v=e[15];let k;e[16]!==d.description?(k=d.description?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"•"}),m.jsx("span",{className:"text-xs text-muted-foreground font-normal truncate min-w-0 max-w-[20ch]",children:d.description})]}):null,e[16]=d.description,e[17]=k):k=e[17];let w;e[18]!==v||e[19]!==k?(w=m.jsx(Lc,{children:m.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[v,k]})}),e[18]=v,e[19]=k,e[20]=w):w=e[20];let C;e[21]!==d.title||e[22]!==i?(C=m.jsx(Ii,{title:d.title,url:i,icon:"description"}),e[21]=d.title,e[22]=i,e[23]=C):C=e[23];const T=!y.formState.isDirty||f;let A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=m.jsx(Pc,{size:14}),e[24]=A):A=e[24];let D;e[25]!==x||e[26]!==T?(D=m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:T,onClick:x,"aria-label":"Cancel",children:A})})}),e[25]=x,e[26]=T,e[27]=D):D=e[27];let j;e[28]===Symbol.for("react.memo_cache_sentinel")?(j=m.jsx($t,{side:"bottom",children:"Cancel"}),e[28]=j):j=e[28];let _;e[29]!==D?(_=m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[D,j]})}),e[29]=D,e[30]=_):_=e[30];const V=!y.formState.isDirty||f;let B;e[31]!==S?(B=()=>{S()},e[31]=S,e[32]=B):B=e[32];let H;e[33]===Symbol.for("react.memo_cache_sentinel")?(H=m.jsx(Ui,{size:14}),e[33]=H):H=e[33];let N;e[34]!==V||e[35]!==B?(N=m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:V,onClick:B,"aria-label":"Save",children:H})})}),e[34]=V,e[35]=B,e[36]=N):N=e[36];let z;e[37]===Symbol.for("react.memo_cache_sentinel")?(z=m.jsx($t,{side:"bottom",children:"Save"}),e[37]=z):z=e[37];let P;e[38]!==N?(P=m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[N,z]})}),e[38]=N,e[39]=P):P=e[39];let U;e[40]!==C||e[41]!==_||e[42]!==P?(U=m.jsxs(Pi,{children:[C,_,P]}),e[40]=C,e[41]=_,e[42]=P,e[43]=U):U=e[43];let Q;e[44]!==y?(Q=m.jsx("div",{className:"h-full",children:m.jsx(sm,{form:y})}),e[44]=y,e[45]=Q):Q=e[45];let le;return e[46]!==s||e[47]!==U||e[48]!==Q||e[49]!==w?(le=m.jsxs(Sn,{onBack:s,children:[w,U,Q]}),e[46]=s,e[47]=U,e[48]=Q,e[49]=w,e[50]=le):le=e[50],le}function cm(n){const e=I.c(5),{itemId:t,onBack:r}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=rm()??qt,e[0]=s):s=e[0];const o=s;if(!o||o===qt){let l;return e[1]===Symbol.for("react.memo_cache_sentinel")?(l=m.jsx("div",{className:"flex h-full w-full bg-background",children:m.jsx(jc,{title:"Prompt not found",description:"Missing connection information in the current route."})}),e[1]=l):l=e[1],l}let i;return e[2]!==t||e[3]!==r?(i=m.jsx(Dc,{children:m.jsx(O.Suspense,{fallback:null,children:m.jsx(am,{providerId:o,promptId:t,onBack:r})})}),e[2]=t,e[3]=r,e[4]=i):i=e[4],i}const dm=yh("relative w-full rounded-lg border px-4 py-3 text-sm flex items-start gap-3 [&>svg]:size-4 [&>svg]:flex-shrink-0 [&>svg]:mt-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-destructive/5 text-destructive border-destructive/25 [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90",warning:"bg-warning/10 text-warning-foreground border-warning [&>svg]:text-current *:data-[slot=alert-description]:text-warning-foreground/90",success:"bg-success/10 text-success-foreground border-success [&>svg]:text-current *:data-[slot=alert-description]:text-success-foreground/90",info:"bg-card text-card-foreground border-border [&>svg]:text-current *:data-[slot=alert-description]:text-muted-foreground/90"}},defaultVariants:{variant:"default"}});function um(n){const e=I.c(10);let t,r,s;e[0]!==n?({className:t,variant:s,...r}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s):(t=e[1],r=e[2],s=e[3]);let o;e[4]!==t||e[5]!==s?(o=J(dm({variant:s}),t),e[4]=t,e[5]=s,e[6]=o):o=e[6];let i;return e[7]!==r||e[8]!==o?(i=m.jsx("div",{"data-slot":"alert",role:"alert",className:o,...r}),e[7]=r,e[8]=o,e[9]=i):i=e[9],i}function fm(n){const e=I.c(8);let t,r;e[0]!==n?({className:t,...r}=n,e[0]=n,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let s;e[3]!==t?(s=J("line-clamp-1 min-h-4 font-medium tracking-tight",t),e[3]=t,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=m.jsx("div",{"data-slot":"alert-title",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}function hm(n){const e=I.c(8);let t,r;e[0]!==n?({className:t,...r}=n,e[0]=n,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let s;e[3]!==t?(s=J("text-muted-foreground leading-relaxed",t),e[3]=t,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=m.jsx("div",{"data-slot":"alert-description",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}const pm=n=>n.replace(/_/g," ").replace(/\b\w/g,e=>e.toLocaleLowerCase());function mm(n){const e=I.c(13),{toolName:t,connectionId:r,onBack:s}=n,o=`/mcp/${r}`;let i;e[0]!==o?(i=new URL(o,window.location.origin),e[0]=o,e[1]=i):i=e[1];const l=i;let a;e[2]!==r?(a={connectionId:r},e[2]=r,e[3]=a):a=e[3];const c=Vh(a);if(!c.isAuthenticated){let f;return e[4]!==c.supportsOAuth||e[5]!==s?(f=m.jsx("div",{className:"flex h-full items-center justify-center",children:c.supportsOAuth?m.jsx(Hh,{onAuthenticate:()=>s(),buttonText:"Go back to authenticate"}):m.jsx(Wh,{hasReadme:!1})}),e[4]=c.supportsOAuth,e[5]=s,e[6]=f):f=e[6],f}const d=`${r}:${t}`;let u;return e[7]!==r||e[8]!==l||e[9]!==s||e[10]!==d||e[11]!==t?(u=m.jsx(gm,{toolName:t,connectionId:r,mcpProxyUrl:l,onBack:s},d),e[7]=r,e[8]=l,e[9]=s,e[10]=d,e[11]=t,e[12]=u):u=e[12],u}function gm({toolName:n,connectionId:e,mcpProxyUrl:t,onBack:r}){const o=Ci().location.href,{replayId:i}=xh({strict:!1}),l=(()=>{if(!i)return null;const N=`replay-${i}`,z=sessionStorage.getItem(N);if(!z)return null;sessionStorage.removeItem(N);try{return JSON.parse(z)}catch{return null}})(),a=(()=>{if(!l)return null;const N={};for(const[z,P]of Object.entries(l))P!==null&&typeof P=="object"?N[z]=JSON.stringify(P,null,2):N[z]=P;return N})(),[c,d]=O.useState(a??{}),[u,f]=O.useState(l?JSON.stringify(l,null,2):"{}"),[h,p]=O.useState(null),[y,g]=O.useState(null),[x,b]=O.useState(!1),[S,v]=O.useState(null),k=Oi(e),w=zi({url:t.href});O.useEffect(()=>{w.error&&console.error("MCP Error:",w.error)},[w.error]);const C=w.tools?.find(N=>N.name===n),T=C?.inputSchema?.properties,A=T?Object.keys(T):[],D=A.length>0,j={};if(D&&C?.inputSchema?.properties)for(const N of A)j[N]=C.inputSchema.required?.includes(N)?"":void 0;const _=N=>Object.prototype.hasOwnProperty.call(c,N),V=async()=>{b(!0),g(null),p(null),v(null);const N=performance.now(),z=qe(e);try{const P=D?{...j,...c}:(()=>{const se=u.trim();if(!se)return{};const K=JSON.parse(se);if(K&&typeof K=="object")return K;throw new Error("Raw JSON input must be an object.")})();D&&C?.inputSchema?.properties&&Object.entries(C.inputSchema.properties).forEach(([se,K])=>{if((K.type==="object"||K.type==="array")&&typeof P[se]=="string")try{P[se]=JSON.parse(P[se])}catch{}});const U=await z(n,P),Q=performance.now(),le=Math.round(Q-N);p(U);const X=JSON.stringify(U),fe=new TextEncoder().encode(X).length;v({duration:`${le}ms`,bytes:`${fe} bytes`,tokens:`~${Math.ceil(fe/4)} tokens`,cost:"$0.0000"})}catch(P){const U=P instanceof Error?P.message:String(P);g(U||"Unknown error occurred");const Q=performance.now();v({duration:`${Math.round(Q-N)}ms`})}finally{b(!1)}},B=(N,z)=>{d(P=>({...P,[N]:z}))},H=()=>{p(null),g(null),v(null)};return m.jsxs(Sn,{onBack:r,children:[m.jsx(Pi,{children:m.jsx(Ii,{title:C?.name??pm(n),url:o,icon:"build"})}),m.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 h-full",children:[m.jsx("div",{className:"flex flex-col border-r border-border overflow-hidden",children:m.jsxs("div",{className:"flex-1 overflow-auto",children:[m.jsx("div",{className:"flex flex-col gap-4 p-6 border-b border-border min-h-28",children:m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx(js,{icon:k?.icon||null,name:k?.title||n,size:"sm",className:"shadow-sm shrink-0"}),m.jsx("h1",{className:"text-lg font-medium text-foreground leading-none",children:n}),m.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1 bg-muted/50 rounded-md h-fit",children:[w.state==="ready"?m.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500 animate-pulse shrink-0"}):w.state==="connecting"?m.jsx(tr,{size:10,className:"animate-spin text-yellow-500 shrink-0"}):m.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-red-500 shrink-0"}),m.jsx("span",{className:"font-mono text-xs capitalize text-muted-foreground leading-none",children:w.state.replace("_"," ")})]})]}),m.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:C?.description||"No description available"})]})}),m.jsxs("div",{className:"flex flex-col p-6 gap-4",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("h2",{className:"text-sm font-semibold text-foreground uppercase tracking-wide",children:"Parameters"}),C?.inputSchema?.required&&C.inputSchema.required.length>0&&m.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.jsx("span",{className:"text-red-500",children:"*"})," Required"]})]}),m.jsx("div",{className:"space-y-4",children:D&&C?.inputSchema?.properties?Object.entries(C.inputSchema.properties).map(([N,z])=>m.jsxs("div",{className:"space-y-2",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("label",{className:"text-sm font-medium leading-none flex items-center gap-1.5",children:[N,C.inputSchema?.required?.includes(N)&&m.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),m.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:z.type})]}),z.description&&m.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:z.description}),z.type==="object"||z.type==="array"?m.jsx(Ho,{className:"font-mono text-xs",value:_(N)?c[N]??"":j[N]??"",onChange:P=>B(N,P.target.value),placeholder:`Enter ${N} as JSON...`,rows:3}):m.jsx(Ri,{value:_(N)?c[N]??"":j[N]??"",onChange:P=>B(N,P.target.value),placeholder:`Enter ${N}...`})]},N)):C?.inputSchema&&!D?m.jsxs("div",{className:"space-y-2",children:[m.jsx("label",{className:"text-sm font-medium",children:"Raw JSON Input"}),m.jsx(Ho,{className:"font-mono text-xs min-h-[120px]",value:u,onChange:N=>f(N.target.value),placeholder:'e.g. { "foo": "bar" }'})]}):m.jsx("div",{className:"flex items-center justify-center p-8 bg-muted/30 rounded-lg border border-dashed border-border",children:m.jsx("p",{className:"text-sm text-muted-foreground",children:"No parameters required"})})})]})]})}),m.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[m.jsxs("div",{className:"flex items-center justify-between px-4 h-14 border-t lg:border-t-0 border-b border-border bg-background",children:[m.jsx("h2",{className:"text-sm font-medium text-foreground uppercase tracking-wide",children:"Result"}),S&&m.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(zh,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"font-mono text-foreground",children:S.duration})]}),S.tokens&&m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Kc,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"font-mono text-foreground",children:S.tokens})]}),S.bytes&&m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Yc,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"font-mono text-foreground",children:S.bytes})]}),S.cost&&m.jsx("div",{className:"flex items-center gap-1.5",children:m.jsx("span",{className:"font-mono text-foreground",children:S.cost})})]})]}),m.jsx("div",{className:"flex items-center justify-end lg:justify-between px-4 h-14 border-b border-border bg-background",children:m.jsxs("div",{className:"flex items-center gap-2 w-full lg:w-auto",children:[m.jsx(me,{size:"sm",variant:"default",className:"h-8 gap-2 flex-1 lg:flex-none",onClick:V,disabled:x,children:x?m.jsxs(m.Fragment,{children:[m.jsx(tr,{size:14,className:"animate-spin"}),"Executing..."]}):m.jsxs(m.Fragment,{children:[m.jsx(Li,{className:"h-3.5 w-3.5 fill-current"}),"Execute Tool"]})}),m.jsx(zt,{children:m.jsxs(_t,{children:[m.jsx(Lt,{asChild:!0,children:m.jsx(me,{size:"icon",variant:"outline",className:"h-8 w-8 shrink-0",onClick:H,disabled:!h&&!y,children:m.jsx($i,{size:14})})}),m.jsx($t,{children:m.jsx("p",{children:"Clear results"})})]})})]})}),y&&m.jsx("div",{className:"px-6 py-4 bg-background",children:m.jsx(um,{variant:"destructive",children:m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx($h,{className:"h-4 w-4"}),m.jsx(fm,{className:"mb-0",children:"Execution Failed"})]}),m.jsx(hm,{className:"text-xs text-destructive",children:y})]})})}),m.jsx("div",{className:"relative flex-1 overflow-auto bg-muted/50",children:h?m.jsxs(m.Fragment,{children:[m.jsx(On,{code:JSON.stringify(h,null,2),language:"json",height:"100%",readOnly:!0}),m.jsx(me,{size:"icon",variant:"ghost",className:"absolute top-4 right-4 h-8 w-8 bg-background/80 hover:bg-background border border-border shadow-sm",onClick:()=>{navigator.clipboard.writeText(JSON.stringify(h,null,2)),Ec.success("Copied to clipboard")},children:m.jsx(Bh,{className:"h-3.5 w-3.5"})})]}):m.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-muted-foreground",children:[m.jsx(_h,{className:"h-12 w-12 mb-3 opacity-40"}),m.jsx("p",{className:"text-sm",children:"Run the tool to see results"})]})})]})]})]})}function ym(n){const e=I.c(7),{itemId:t,onBack:r}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={strict:!1},e[0]=s):s=e[0];const i=Et(s).connectionId??qt;if(!Oi(i)){let d;return e[1]===Symbol.for("react.memo_cache_sentinel")?(d=m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[m.jsx("h3",{className:"text-lg font-semibold",children:"Connection not found"}),m.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection may have been deleted or you may not have access."})]})}),e[1]=d):d=e[1],d}let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsx(tr,{size:32,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let c;return e[3]!==i||e[4]!==r||e[5]!==t?(c=m.jsx(O.Suspense,{fallback:a,children:m.jsx(mm,{toolName:t,connectionId:i,onBack:r})}),e[3]=i,e[4]=r,e[5]=t,e[6]=c):c=e[6],c}const Kl=n=>{let e;const t=new Set,r=(c,d)=>{const u=typeof c=="function"?c(e):c;if(!Object.is(u,e)){const f=e;e=d??(typeof u!="object"||u===null)?u:Object.assign({},e,u),t.forEach(h=>h(e,f))}},s=()=>e,l={setState:r,getState:s,getInitialState:()=>a,subscribe:c=>(t.add(c),()=>t.delete(c))},a=e=n(r,s,l);return l},Ki=(n=>n?Kl(n):Kl),xm=n=>n;function Wo(n,e=xm){const t=ee.useSyncExternalStore(n.subscribe,ee.useCallback(()=>e(n.getState()),[n,e]),ee.useCallback(()=>e(n.getInitialState()),[n,e]));return ee.useDebugValue(t),t}const bm=n=>{const e=Ki(n),t=r=>Wo(e,r);return Object.assign(t,e),t},km=(n=>bm);function td(n,e){let t;try{t=n()}catch{return}return{getItem:s=>{var o;const i=a=>a===null?null:JSON.parse(a,void 0),l=(o=t.getItem(s))!=null?o:null;return l instanceof Promise?l.then(i):i(l)},setItem:(s,o)=>t.setItem(s,JSON.stringify(o,void 0)),removeItem:s=>t.removeItem(s)}}const qo=n=>e=>{try{const t=n(e);return t instanceof Promise?t:{then(r){return qo(r)(t)},catch(r){return this}}}catch(t){return{then(r){return this},catch(r){return qo(r)(t)}}}},Sm=(n,e)=>(t,r,s)=>{let o={storage:td(()=>localStorage),partialize:g=>g,version:0,merge:(g,x)=>({...x,...g}),...e},i=!1,l=0;const a=new Set,c=new Set;let d=o.storage;if(!d)return n((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),t(...g)},r,s);const u=()=>{const g=o.partialize({...r()});return d.setItem(o.name,{state:g,version:o.version})},f=s.setState;s.setState=(g,x)=>(f(g,x),u());const h=n((...g)=>(t(...g),u()),r,s);s.getInitialState=()=>h;let p;const y=()=>{var g,x;if(!d)return;const b=++l;i=!1,a.forEach(v=>{var k;return v((k=r())!=null?k:h)});const S=((x=o.onRehydrateStorage)==null?void 0:x.call(o,(g=r())!=null?g:h))||void 0;return qo(d.getItem.bind(d))(o.name).then(v=>{if(v)if(typeof v.version=="number"&&v.version!==o.version){if(o.migrate){const k=o.migrate(v.state,v.version);return k instanceof Promise?k.then(w=>[!0,w]):[!0,k]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,v.state];return[!1,void 0]}).then(v=>{var k;if(b!==l)return;const[w,C]=v;if(p=o.merge(C,(k=r())!=null?k:h),t(p,!0),w)return u()}).then(()=>{b===l&&(S?.(p,void 0),p=r(),i=!0,c.forEach(v=>v(p)))}).catch(v=>{b===l&&S?.(void 0,v)})};return s.persist={setOptions:g=>{o={...o,...g},g.storage&&(d=g.storage)},clearStorage:()=>{d?.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>y(),hasHydrated:()=>i,onHydrate:g=>(a.add(g),()=>{a.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},o.skipHydration||y(),p||h},nd=Sm,{useSyncExternalStoreWithSelector:wm}=bh,vm=n=>n;function Cm(n,e=vm,t){const r=wm(n.subscribe,n.getState,n.getInitialState,e,t);return ee.useDebugValue(r),r}const Jl=n=>Symbol.iterator in n,Gl=n=>"entries"in n,Xl=(n,e)=>{const t=n instanceof Map?n:new Map(n.entries()),r=e instanceof Map?e:new Map(e.entries());if(t.size!==r.size)return!1;for(const[s,o]of t)if(!r.has(s)||!Object.is(o,r.get(s)))return!1;return!0},Nm=(n,e)=>{const t=n[Symbol.iterator](),r=e[Symbol.iterator]();let s=t.next(),o=r.next();for(;!s.done&&!o.done;){if(!Object.is(s.value,o.value))return!1;s=t.next(),o=r.next()}return!!s.done&&!!o.done};function Em(n,e){return Object.is(n,e)?!0:typeof n!="object"||n===null||typeof e!="object"||e===null||Object.getPrototypeOf(n)!==Object.getPrototypeOf(e)?!1:Jl(n)&&Jl(e)?Gl(n)&&Gl(e)?Xl(n,e):Nm(n,e):Xl({entries:()=>Object.entries(n)},{entries:()=>Object.entries(e)})}function Tm(n,e="Output"){if(!n)return`interface ${e} {}`;function t(o){if(!o||typeof o!="object")return"unknown";const i=o.type;if(Array.isArray(i))return i.map(l=>r(l)).join(" | ");switch(i){case"string":return o.enum?o.enum.map(l=>`"${l}"`).join(" | "):"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"null":return"null";case"array":{const l=o.items;return l?`${t(l)}[]`:"unknown[]"}case"object":return s(o);default:return o.anyOf?o.anyOf.map(t).join(" | "):o.oneOf?o.oneOf.map(t).join(" | "):o.allOf?o.allOf.map(t).join(" & "):"unknown"}}function r(o){switch(o){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"null":return"null";default:return"unknown"}}function s(o){const i=o.properties;if(!i)return"Record<string, unknown>";const l=new Set(o.required||[]);return`{
|
|
1
|
+
import{as as We,r as O,v as mh,w as lo,c as I,j as m,k as Ci,y as gh,h as yh,d as Et,b as xh,t as Ec,B as ee,z as bh,at as Tc,a6 as kh,a5 as Sh,au as wh,ac as Mc,av as Ac,aw as vh,ad as Ni,af as Ge,ae as Oc,ax as Ch,ai as Ei,ay as Nh,aa as Ic,az as Eh,aA as Th,aB as Mh,aC as Ti,aD as Ah,aE as Oh,aF as Ih,ab as Rh,aG as jh,ar as Rc}from"./index-DMNk-OUX.js";import{U as qt,E as jc,u as Mi,a as Ai,c as qe,I as js,n as Dh}from"./empty-state-DzS1Zp7m.js";import{E as Dc}from"./error-boundary-BQnJ9S9E.js";import{P as Oi}from"./pin-to-sidebar-button-B1xHHS9n.js";import{B as me,I as Ii,c as U}from"./input-68J17rBp.js";import{F as ao,a as Ph,b as Ri,d as ji}from"./form-DrOt6d2d.js";import{T as Ho}from"./textarea-BAUX8Qgd.js";import{b as Lt,T as $t,a as zt,c as _t}from"./project-context-provider-BJIP5a-U.js";import{i as Pc}from"./FlipBackward-GGMv99yc.js";import{a as Lc,V as Di,b as Sn}from"./layout-Olb4shdE.js";import{c as Pi,u as Lh}from"./use-connection-DoWszS3j.js";import{i as $h}from"./AlertCircle-Cso_Xxvk.js";import{s as zh}from"./Clock-CW5u1cfj.js";import{i as _h}from"./Code01-CgNchnl3.js";import{a as Bh}from"./Copy01-Dadp_RDG.js";import{i as tr}from"./Loading01-NW_f44Lz.js";import{i as Li,n as Fh}from"./Play-CIMfsFF1.js";import{s as $i}from"./XClose-Ba3zyI0J.js";import{u as Vh,O as Hh,M as Wh,F as qh,v as Uh}from"./index-GoXtajA4.js";import{u as zi}from"./use-mcp-L2lisTXg.js";import{M as On}from"./monaco-editor-B_MycISs.js";import{E as _i}from"./empty-state-BmkZOMzL.js";import{D as Kh,u as Jh}from"./use-binding-Dj4lal1A.js";import{u as Gh}from"./use-gateway-CRpsitbG.js";import{b as Xh,R as Bl,a as Yh}from"./resizable-CW5_SPIS.js";import{h as Qh,q as Zh,r as $c,R as ep,s as tp,T as np}from"./index-CBIrwxtj.js";import{d as rp,b as sp,a as op,c as ip,S as lp}from"./select-B9KJyTZZ.js";import{S as Ds}from"./spinner-B0sczm1j.js";import{V as ap}from"./view-mode-toggle-BpjQ6V4P.js";import{i as cp}from"./GitBranch01-BUTuezlq.js";import{a as Bi,b as Fi}from"./use-tool-call-BBonHr6l.js";import{a as dp,D as up,g as fp,f as hp,c as pp,d as mp}from"./dialog-BXeLl5mO.js";import"./index-XOpbMEap.js";import{s as zc}from"./Plus-DaP4KLuJ.js";import{i as Vi}from"./Check-JFkjTCfG.js";import{i as gp}from"./DotsHorizontal-B0A7sUYv.js";import{b as yp,D as xp,a as bp,c as Fl}from"./dropdown-menu-CnL8UM0z.js";import{i as kp}from"./Grid01-BbdtRdR8.js";import{B as un}from"./badge-0b6sJe4S.js";import{i as _c}from"./X-D3ljCSd1.js";import"./use-organization-settings-D6rXW2c_.js";import"./ArrowLeft-BrsZ2N_5.js";import"./mcp-oauth-Db8WtQ8u.js";import"./auth-C9dSkS_x.js";import"./env-vars-editor-B_mIaT86.js";import"./Trash01-CjDzx3jP.js";import"./File06-D0TXCuMx.js";import"./Key01-8ewaPBuD.js";import"./Terminal-ANRX3jJ8.js";import"./index-Bb8rHnPb.js";import"./constants-Cy709IUA.js";import"./registry-utils-B7t_ZBUi.js";import"./extract-connection-data-DPoJQhk8.js";import"./github-icon-Dp3wHhYE.js";import"./generate-id-Dyweu44Y.js";import"./popover-DC9U4d6e.js";import"./SearchMd-tOSOFUes.js";import"./use-create-gateway-Ca5SEa8I.js";import"./localstorage-keys-C62ZbWuB.js";import"./alert-dialog-_Gzpv9vf.js";import"./use-mobile--ytA5LT5.js";import"./InfoCircle-D6qJG9Nl.js";import"./ChevronDown-HtFMO0lw.js";const Bc=We("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);const Fc=We("Braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);const Hi=We("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Wi=We("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const Sp=We("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const wp=We("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Vc=We("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const Hc=We("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);const Wc=We("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);const qc=We("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);const Uc=We("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]),qi=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M12 8v4m0 4h.01M2 8.523v6.954c0 .245 0 .367.028.482a1 1 0 0 0 .12.29c.061.1.148.187.32.36l4.923 4.922c.173.173.26.26.36.322.09.054.188.095.29.12.115.027.237.027.482.027h6.954c.245 0 .367 0 .482-.028a.998.998 0 0 0 .29-.12c.1-.061.187-.148.36-.32l4.922-4.923c.173-.173.26-.26.322-.36a.998.998 0 0 0 .12-.29c.027-.115.027-.237.027-.482V8.523c0-.245 0-.367-.028-.482a.998.998 0 0 0-.12-.29c-.061-.1-.148-.187-.32-.36L16.608 2.47c-.173-.173-.26-.26-.36-.322a1 1 0 0 0-.29-.12C15.844 2 15.722 2 15.477 2H8.523c-.245 0-.367 0-.482.028a1 1 0 0 0-.29.12c-.1.061-.187.148-.36.32L2.47 7.392c-.173.173-.26.26-.322.36a1 1 0 0 0-.12.29C2 8.156 2 8.278 2 8.523Z"}));qi.displayName="AlertOctagon";const Kc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M20.5 8v8.2c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.22 21 17.38 21 15.7 21H8.3c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3.5 18.72 3.5 17.88 3.5 16.2V8m.1-5h16.8c.56 0 .84 0 1.054.109a1 1 0 0 1 .437.437C22 3.76 22 4.04 22 4.6v1.8c0 .56 0 .84-.109 1.054a1 1 0 0 1-.437.437C21.24 8 20.96 8 20.4 8H3.6c-.56 0-.84 0-1.054-.109a1 1 0 0 1-.437-.437C2 7.24 2 6.96 2 6.4V4.6c0-.56 0-.84.109-1.054a1 1 0 0 1 .437-.437C2.76 3 3.04 3 3.6 3Zm6 8.5h4.8c.56 0 .84 0 1.054.109a1 1 0 0 1 .437.437C16 12.26 16 12.54 16 13.1v.8c0 .56 0 .84-.109 1.054a1 1 0 0 1-.437.437c-.214.109-.494.109-1.054.109H9.6c-.56 0-.84 0-1.054-.109a1 1 0 0 1-.437-.437C8 14.74 8 14.46 8 13.9v-.8c0-.56 0-.84.109-1.054a1 1 0 0 1 .437-.437C8.76 11.5 9.04 11.5 9.6 11.5Z"}));Kc.displayName="Box";const Jc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"m22.7 11.5-2 2-2-2m2.245 1.5A9 9 0 1 0 19 17.657M12 7v5l3 2"}));Jc.displayName="ClockFastForward";const Gc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"m17 17 5-5-5-5M7 7l-5 5 5 5m7-14-4 18"}));Gc.displayName="Code02";const jr=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M6.8 3h-.6c-1.12 0-1.68 0-2.108.218a2 2 0 0 0-.874.874C3 4.52 3 5.08 3 6.2v11.6c0 1.12 0 1.68.218 2.108a2 2 0 0 0 .874.874C4.52 21 5.08 21 6.2 21h.6c1.12 0 1.68 0 2.108-.218a2 2 0 0 0 .874-.874C10 19.48 10 18.92 10 17.8V6.2c0-1.12 0-1.68-.218-2.108a2 2 0 0 0-.874-.874C8.48 3 7.92 3 6.8 3Zm11 0h-.6c-1.12 0-1.68 0-2.108.218a2 2 0 0 0-.874.874C14 4.52 14 5.08 14 6.2v11.6c0 1.12 0 1.68.218 2.108a2 2 0 0 0 .874.874C15.52 21 16.08 21 17.2 21h.6c1.12 0 1.68 0 2.108-.218a2 2 0 0 0 .874-.874C21 19.48 21 18.92 21 17.8V6.2c0-1.12 0-1.68-.218-2.108a2 2 0 0 0-.874-.874C19.48 3 18.92 3 17.8 3Z"}));jr.displayName="Columns01";const Xc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M4 4v1.4c0 3.36 0 5.04.654 6.324a6 6 0 0 0 2.622 2.622C8.56 15 10.24 15 13.6 15H20m0 0-5-5m5 5-5 5"}));Xc.displayName="CornerDownRight";const Yc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M21 5c0 1.657-4.03 3-9 3S3 6.657 3 5m18 0c0-1.657-4.03-3-9-3S3 3.343 3 5m18 0v14c0 1.66-4 3-9 3s-9-1.34-9-3V5m18 7c0 1.66-4 3-9 3s-9-1.34-9-3"}));Yc.displayName="Database01";const Qc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"m13 22-3-3m0 0 3-3m-3 3h5a7 7 0 0 0 3-13.326M6 18.326A7 7 0 0 1 9 5h5m0 0-3-3m3 3-3 3"}));Qc.displayName="Repeat03";const Ui=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M15 8H8.6c-.56 0-.84 0-1.054-.109a1 1 0 0 1-.437-.437C7 7.24 7 6.96 7 6.4V3m10 18v-6.4c0-.56 0-.84-.109-1.054a1 1 0 0 0-.437-.437C16.24 13 15.96 13 15.4 13H8.6c-.56 0-.84 0-1.054.109a1 1 0 0 0-.437.437C7 13.76 7 14.04 7 14.6V21M21 9.325V16.2c0 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.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h6.875c.489 0 .733 0 .963.055.204.05.4.13.579.24.201.123.374.296.72.642l3.126 3.126c.346.346.519.519.642.72.11.18.19.374.24.579.055.23.055.474.055.963Z"}));Ui.displayName="Save02";const Zc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M15.631 7.631c-.396-.396-.594-.594-.668-.822a1 1 0 0 1 0-.618c.074-.228.272-.426.668-.822L18.47 2.53a6 6 0 0 0-8.3 6.895c.12.49.179.734.168.888a.849.849 0 0 1-.11.392c-.07.138-.207.274-.48.547L3.5 17.5a2.121 2.121 0 0 0 3 3l6.248-6.248c.273-.273.41-.41.547-.48a.849.849 0 0 1 .392-.11c.154-.011.399.049.888.168a6 6 0 0 0 6.895-8.3l-2.84 2.84c-.396.396-.594.594-.822.668a1 1 0 0 1-.618 0c-.228-.074-.426-.272-.822-.668l-.738-.738Z"}));Zc.displayName="Tool01";const{getOwnPropertyNames:vp,getOwnPropertySymbols:Cp}=Object,{hasOwnProperty:Np}=Object.prototype;function co(n,e){return function(r,s,o){return n(r,s,o)&&e(r,s,o)}}function kr(n){return function(t,r,s){if(!t||!r||typeof t!="object"||typeof r!="object")return n(t,r,s);const{cache:o}=s,i=o.get(t),l=o.get(r);if(i&&l)return i===r&&l===t;o.set(t,r),o.set(r,t);const a=n(t,r,s);return o.delete(t),o.delete(r),a}}function Ep(n){return n?.[Symbol.toStringTag]}function Vl(n){return vp(n).concat(Cp(n))}const Tp=Object.hasOwn||((n,e)=>Np.call(n,e));function Yt(n,e){return n===e||!n&&!e&&n!==n&&e!==e}const Mp="__v",Ap="__o",Op="_owner",{getOwnPropertyDescriptor:Hl,keys:Wl}=Object;function Ip(n,e){return n.byteLength===e.byteLength&&Br(new Uint8Array(n),new Uint8Array(e))}function Rp(n,e,t){let r=n.length;if(e.length!==r)return!1;for(;r-- >0;)if(!t.equals(n[r],e[r],r,r,n,e,t))return!1;return!0}function jp(n,e){return n.byteLength===e.byteLength&&Br(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Dp(n,e){return Yt(n.getTime(),e.getTime())}function Pp(n,e){return n.name===e.name&&n.message===e.message&&n.cause===e.cause&&n.stack===e.stack}function Lp(n,e){return n===e}function ql(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.entries();let i,l,a=0;for(;(i=o.next())&&!i.done;){const c=e.entries();let d=!1,u=0;for(;(l=c.next())&&!l.done;){if(s[u]){u++;continue}const f=i.value,h=l.value;if(t.equals(f[0],h[0],a,u,n,e,t)&&t.equals(f[1],h[1],f[0],h[0],n,e,t)){d=s[u]=!0;break}u++}if(!d)return!1;a++}return!0}const $p=Yt;function zp(n,e,t){const r=Wl(n);let s=r.length;if(Wl(e).length!==s)return!1;for(;s-- >0;)if(!ed(n,e,t,r[s]))return!1;return!0}function zn(n,e,t){const r=Vl(n);let s=r.length;if(Vl(e).length!==s)return!1;let o,i,l;for(;s-- >0;)if(o=r[s],!ed(n,e,t,o)||(i=Hl(n,o),l=Hl(e,o),(i||l)&&(!i||!l||i.configurable!==l.configurable||i.enumerable!==l.enumerable||i.writable!==l.writable)))return!1;return!0}function _p(n,e){return Yt(n.valueOf(),e.valueOf())}function Bp(n,e){return n.source===e.source&&n.flags===e.flags}function Ul(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.values();let i,l;for(;(i=o.next())&&!i.done;){const a=e.values();let c=!1,d=0;for(;(l=a.next())&&!l.done;){if(!s[d]&&t.equals(i.value,l.value,i.value,l.value,n,e,t)){c=s[d]=!0;break}d++}if(!c)return!1}return!0}function Br(n,e){let t=n.byteLength;if(e.byteLength!==t||n.byteOffset!==e.byteOffset)return!1;for(;t-- >0;)if(n[t]!==e[t])return!1;return!0}function Fp(n,e){return n.hostname===e.hostname&&n.pathname===e.pathname&&n.protocol===e.protocol&&n.port===e.port&&n.hash===e.hash&&n.username===e.username&&n.password===e.password}function ed(n,e,t,r){return(r===Op||r===Ap||r===Mp)&&(n.$$typeof||e.$$typeof)?!0:Tp(e,r)&&t.equals(n[r],e[r],r,r,n,e,t)}const Vp="[object ArrayBuffer]",Hp="[object Arguments]",Wp="[object Boolean]",qp="[object DataView]",Up="[object Date]",Kp="[object Error]",Jp="[object Map]",Gp="[object Number]",Xp="[object Object]",Yp="[object RegExp]",Qp="[object Set]",Zp="[object String]",em={"[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},tm="[object URL]",nm=Object.prototype.toString;function rm({areArrayBuffersEqual:n,areArraysEqual:e,areDataViewsEqual:t,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:o,areMapsEqual:i,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:c,areRegExpsEqual:d,areSetsEqual:u,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:p}){return function(g,x,b){if(g===x)return!0;if(g==null||x==null)return!1;const S=typeof g;if(S!==typeof x)return!1;if(S!=="object")return S==="number"?l(g,x,b):S==="function"?o(g,x,b):!1;const v=g.constructor;if(v!==x.constructor)return!1;if(v===Object)return a(g,x,b);if(Array.isArray(g))return e(g,x,b);if(v===Date)return r(g,x,b);if(v===RegExp)return d(g,x,b);if(v===Map)return i(g,x,b);if(v===Set)return u(g,x,b);const k=nm.call(g);if(k===Up)return r(g,x,b);if(k===Yp)return d(g,x,b);if(k===Jp)return i(g,x,b);if(k===Qp)return u(g,x,b);if(k===Xp)return typeof g.then!="function"&&typeof x.then!="function"&&a(g,x,b);if(k===tm)return h(g,x,b);if(k===Kp)return s(g,x,b);if(k===Hp)return a(g,x,b);if(em[k])return f(g,x,b);if(k===Vp)return n(g,x,b);if(k===qp)return t(g,x,b);if(k===Wp||k===Gp||k===Zp)return c(g,x,b);if(p){let w=p[k];if(!w){const C=Ep(g);C&&(w=p[C])}if(w)return w(g,x,b)}return!1}}function sm({circular:n,createCustomConfig:e,strict:t}){let r={areArrayBuffersEqual:Ip,areArraysEqual:t?zn:Rp,areDataViewsEqual:jp,areDatesEqual:Dp,areErrorsEqual:Pp,areFunctionsEqual:Lp,areMapsEqual:t?co(ql,zn):ql,areNumbersEqual:$p,areObjectsEqual:t?zn:zp,arePrimitiveWrappersEqual:_p,areRegExpsEqual:Bp,areSetsEqual:t?co(Ul,zn):Ul,areTypedArraysEqual:t?co(Br,zn):Br,areUrlsEqual:Fp,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),n){const s=kr(r.areArraysEqual),o=kr(r.areMapsEqual),i=kr(r.areObjectsEqual),l=kr(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:o,areObjectsEqual:i,areSetsEqual:l})}return r}function om(n){return function(e,t,r,s,o,i,l){return n(e,t,l)}}function im({circular:n,comparator:e,createState:t,equals:r,strict:s}){if(t)return function(l,a){const{cache:c=n?new WeakMap:void 0,meta:d}=t();return e(l,a,{cache:c,equals:r,meta:d,strict:s})};if(n)return function(l,a){return e(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const o={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,a){return e(l,a,o)}}const lm=Tt();Tt({strict:!0});Tt({circular:!0});Tt({circular:!0,strict:!0});Tt({createInternalComparator:()=>Yt});Tt({strict:!0,createInternalComparator:()=>Yt});Tt({circular:!0,createInternalComparator:()=>Yt});Tt({circular:!0,createInternalComparator:()=>Yt,strict:!0});function Tt(n={}){const{circular:e=!1,createInternalComparator:t,createState:r,strict:s=!1}=n,o=sm(n),i=rm(o),l=t?t(i):om(i);return im({circular:e,comparator:i,createState:r,equals:l,strict:s})}mh({title:lo().min(1),description:lo().nullable(),body:lo()});function uo(n){for(const e of n.messages??[])if(e.role==="user"&&e.content?.type==="text")return e.content.text??"";return""}function am(){const n=window.location.pathname.split("/").filter(Boolean),e=n.findIndex(r=>r==="mcps"),t=e>=0?n[e+1]:void 0;return t?decodeURIComponent(t):void 0}function cm(n){const e=I.c(13),{form:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"text-sm font-medium text-foreground",children:"Details"}),e[0]=r):r=e[0];let s;e[1]!==t.control?(s=m.jsxs("div",{className:"flex flex-col gap-4",children:[r,m.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[m.jsx(ao,{control:t.control,name:"title",render:fm}),m.jsx(ao,{control:t.control,name:"description",render:um})]})]}),e[1]=t.control,e[2]=s):s=e[2];let o,i;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=m.jsx("div",{className:"text-sm font-medium text-foreground",children:"Message"}),i=m.jsx("div",{className:"text-xs text-muted-foreground",children:"This becomes the user message in the prompt."}),e[3]=o,e[4]=i):(o=e[3],i=e[4]);let l;e[5]!==t.control?(l=m.jsxs("div",{className:"flex flex-col gap-2",children:[o,i,m.jsx(ao,{control:t.control,name:"body",render:dm})]}),e[5]=t.control,e[6]=l):l=e[6];let a;e[7]!==s||e[8]!==l?(a=m.jsxs("div",{className:"h-full py-6 flex flex-col max-w-3xl mx-auto w-full min-w-0 gap-8 overflow-y-auto px-4",children:[s,l]}),e[7]=s,e[8]=l,e[9]=a):a=e[9];let c;return e[10]!==t||e[11]!==a?(c=m.jsx(Ph,{...t,children:a}),e[10]=t,e[11]=a,e[12]=c):c=e[12],c}function dm(n){const{field:e}=n;return m.jsx(Ri,{children:m.jsx(ji,{children:m.jsx(Ho,{...e,value:e.value??"",placeholder:"Write the prompt message…",className:"min-h-[240px] resize-none text-base leading-relaxed font-normal rounded-xl border border-border bg-muted/20 px-4 py-3 shadow-none focus-visible:ring-0"})})})}function um(n){const{field:e}=n;return m.jsxs(Ri,{children:[m.jsx("div",{className:"text-xs text-muted-foreground",children:"Description"}),m.jsx(ji,{children:m.jsx(Ii,{...e,value:e.value??"",placeholder:"Add a description…",className:"h-9 rounded-lg border border-border bg-muted/20 shadow-none focus-visible:ring-0"})})]})}function fm(n){const{field:e}=n;return m.jsxs(Ri,{children:[m.jsx("div",{className:"text-xs text-muted-foreground",children:"Title"}),m.jsx(ji,{children:m.jsx(Ii,{...e,placeholder:"Untitled prompt",className:"h-9 rounded-lg border border-border bg-muted/20 shadow-none focus-visible:ring-0"})})]})}function hm(n){const e=I.c(51),{providerId:t,promptId:r,onBack:s}=n,i=Ci().location.href,l=t||qt;let a;e[0]!==l?(a=qe(l),e[0]=l,e[1]=a):a=e[1];const c=a,d=Mi(t,"PROMPT",r,c),u=Ai(t,"PROMPT",c),f=u.update.isPending;let h;e[2]!==d?(h=d?{title:d.title,description:d.description??null,body:uo(d)}:void 0,e[2]=d,e[3]=h):h=e[3];let p;e[4]!==h?(p={values:h},e[4]=h,e[5]=p):p=e[5];const y=gh(p);let g;e[6]!==y||e[7]!==d?(g=()=>{d&&y.reset({title:d.title,description:d.description??null,body:uo(d)})},e[6]=y,e[7]=d,e[8]=g):g=e[8];const x=g;let b;e[9]!==u.update||e[10]!==y||e[11]!==r?(b=y.handleSubmit(async X=>{const fe=await u.update.mutateAsync({id:r,data:{title:X.title,description:X.description,arguments:[],icons:[],messages:[{role:"user",content:{type:"text",text:X.body}}]}});y.reset({title:fe.title,description:fe.description??null,body:uo(fe)})}),e[9]=u.update,e[10]=y,e[11]=r,e[12]=b):b=e[12];const S=b;if(!d){let X;return e[13]===Symbol.for("react.memo_cache_sentinel")?(X=m.jsx("div",{className:"flex h-full w-full bg-background",children:m.jsx(jc,{title:"Prompt not found",description:"This prompt may have been deleted or you may not have access to it."})}),e[13]=X):X=e[13],X}let v;e[14]!==d.title?(v=m.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:d.title}),e[14]=d.title,e[15]=v):v=e[15];let k;e[16]!==d.description?(k=d.description?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"•"}),m.jsx("span",{className:"text-xs text-muted-foreground font-normal truncate min-w-0 max-w-[20ch]",children:d.description})]}):null,e[16]=d.description,e[17]=k):k=e[17];let w;e[18]!==v||e[19]!==k?(w=m.jsx(Lc,{children:m.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[v,k]})}),e[18]=v,e[19]=k,e[20]=w):w=e[20];let C;e[21]!==d.title||e[22]!==i?(C=m.jsx(Oi,{title:d.title,url:i,icon:"description"}),e[21]=d.title,e[22]=i,e[23]=C):C=e[23];const T=!y.formState.isDirty||f;let A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=m.jsx(Pc,{size:14}),e[24]=A):A=e[24];let D;e[25]!==x||e[26]!==T?(D=m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:T,onClick:x,"aria-label":"Cancel",children:A})})}),e[25]=x,e[26]=T,e[27]=D):D=e[27];let j;e[28]===Symbol.for("react.memo_cache_sentinel")?(j=m.jsx($t,{side:"bottom",children:"Cancel"}),e[28]=j):j=e[28];let _;e[29]!==D?(_=m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[D,j]})}),e[29]=D,e[30]=_):_=e[30];const V=!y.formState.isDirty||f;let B;e[31]!==S?(B=()=>{S()},e[31]=S,e[32]=B):B=e[32];let H;e[33]===Symbol.for("react.memo_cache_sentinel")?(H=m.jsx(Ui,{size:14}),e[33]=H):H=e[33];let N;e[34]!==V||e[35]!==B?(N=m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:V,onClick:B,"aria-label":"Save",children:H})})}),e[34]=V,e[35]=B,e[36]=N):N=e[36];let z;e[37]===Symbol.for("react.memo_cache_sentinel")?(z=m.jsx($t,{side:"bottom",children:"Save"}),e[37]=z):z=e[37];let P;e[38]!==N?(P=m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[N,z]})}),e[38]=N,e[39]=P):P=e[39];let K;e[40]!==C||e[41]!==_||e[42]!==P?(K=m.jsxs(Di,{children:[C,_,P]}),e[40]=C,e[41]=_,e[42]=P,e[43]=K):K=e[43];let Q;e[44]!==y?(Q=m.jsx("div",{className:"h-full",children:m.jsx(cm,{form:y})}),e[44]=y,e[45]=Q):Q=e[45];let le;return e[46]!==s||e[47]!==K||e[48]!==Q||e[49]!==w?(le=m.jsxs(Sn,{onBack:s,children:[w,K,Q]}),e[46]=s,e[47]=K,e[48]=Q,e[49]=w,e[50]=le):le=e[50],le}function pm(n){const e=I.c(5),{itemId:t,onBack:r}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=am()??qt,e[0]=s):s=e[0];const o=s;if(!o||o===qt){let l;return e[1]===Symbol.for("react.memo_cache_sentinel")?(l=m.jsx("div",{className:"flex h-full w-full bg-background",children:m.jsx(jc,{title:"Prompt not found",description:"Missing connection information in the current route."})}),e[1]=l):l=e[1],l}let i;return e[2]!==t||e[3]!==r?(i=m.jsx(Dc,{children:m.jsx(O.Suspense,{fallback:null,children:m.jsx(hm,{providerId:o,promptId:t,onBack:r})})}),e[2]=t,e[3]=r,e[4]=i):i=e[4],i}const mm=yh("relative w-full rounded-lg border px-4 py-3 text-sm flex items-start gap-3 [&>svg]:size-4 [&>svg]:flex-shrink-0 [&>svg]:mt-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-destructive/5 text-destructive border-destructive/25 [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90",warning:"bg-warning/10 text-warning-foreground border-warning [&>svg]:text-current *:data-[slot=alert-description]:text-warning-foreground/90",success:"bg-success/10 text-success-foreground border-success [&>svg]:text-current *:data-[slot=alert-description]:text-success-foreground/90",info:"bg-card text-card-foreground border-border [&>svg]:text-current *:data-[slot=alert-description]:text-muted-foreground/90"}},defaultVariants:{variant:"default"}});function gm(n){const e=I.c(10);let t,r,s;e[0]!==n?({className:t,variant:s,...r}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s):(t=e[1],r=e[2],s=e[3]);let o;e[4]!==t||e[5]!==s?(o=U(mm({variant:s}),t),e[4]=t,e[5]=s,e[6]=o):o=e[6];let i;return e[7]!==r||e[8]!==o?(i=m.jsx("div",{"data-slot":"alert",role:"alert",className:o,...r}),e[7]=r,e[8]=o,e[9]=i):i=e[9],i}function ym(n){const e=I.c(8);let t,r;e[0]!==n?({className:t,...r}=n,e[0]=n,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let s;e[3]!==t?(s=U("line-clamp-1 min-h-4 font-medium tracking-tight",t),e[3]=t,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=m.jsx("div",{"data-slot":"alert-title",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}function xm(n){const e=I.c(8);let t,r;e[0]!==n?({className:t,...r}=n,e[0]=n,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let s;e[3]!==t?(s=U("text-muted-foreground leading-relaxed",t),e[3]=t,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=m.jsx("div",{"data-slot":"alert-description",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}const bm=n=>n.replace(/_/g," ").replace(/\b\w/g,e=>e.toLocaleLowerCase());function km(n){const e=I.c(13),{toolName:t,connectionId:r,onBack:s}=n,o=`/mcp/${r}`;let i;e[0]!==o?(i=new URL(o,window.location.origin),e[0]=o,e[1]=i):i=e[1];const l=i;let a;e[2]!==r?(a={connectionId:r},e[2]=r,e[3]=a):a=e[3];const c=Vh(a);if(!c.isAuthenticated){let f;return e[4]!==c.supportsOAuth||e[5]!==s?(f=m.jsx("div",{className:"flex h-full items-center justify-center",children:c.supportsOAuth?m.jsx(Hh,{onAuthenticate:()=>s(),buttonText:"Go back to authenticate"}):m.jsx(Wh,{hasReadme:!1})}),e[4]=c.supportsOAuth,e[5]=s,e[6]=f):f=e[6],f}const d=`${r}:${t}`;let u;return e[7]!==r||e[8]!==l||e[9]!==s||e[10]!==d||e[11]!==t?(u=m.jsx(Sm,{toolName:t,connectionId:r,mcpProxyUrl:l,onBack:s},d),e[7]=r,e[8]=l,e[9]=s,e[10]=d,e[11]=t,e[12]=u):u=e[12],u}function Sm({toolName:n,connectionId:e,mcpProxyUrl:t,onBack:r}){const o=Ci().location.href,{replayId:i}=xh({strict:!1}),l=(()=>{if(!i)return null;const N=`replay-${i}`,z=sessionStorage.getItem(N);if(!z)return null;sessionStorage.removeItem(N);try{return JSON.parse(z)}catch{return null}})(),a=(()=>{if(!l)return null;const N={};for(const[z,P]of Object.entries(l))P!==null&&typeof P=="object"?N[z]=JSON.stringify(P,null,2):N[z]=P;return N})(),[c,d]=O.useState(a??{}),[u,f]=O.useState(l?JSON.stringify(l,null,2):"{}"),[h,p]=O.useState(null),[y,g]=O.useState(null),[x,b]=O.useState(!1),[S,v]=O.useState(null),k=Pi(e),w=zi({url:t.href});O.useEffect(()=>{w.error&&console.error("MCP Error:",w.error)},[w.error]);const C=w.tools?.find(N=>N.name===n),T=C?.inputSchema?.properties,A=T?Object.keys(T):[],D=A.length>0,j={};if(D&&C?.inputSchema?.properties)for(const N of A)j[N]=C.inputSchema.required?.includes(N)?"":void 0;const _=N=>Object.prototype.hasOwnProperty.call(c,N),V=async()=>{b(!0),g(null),p(null),v(null);const N=performance.now(),z=qe(e);try{const P=D?{...j,...c}:(()=>{const se=u.trim();if(!se)return{};const J=JSON.parse(se);if(J&&typeof J=="object")return J;throw new Error("Raw JSON input must be an object.")})();D&&C?.inputSchema?.properties&&Object.entries(C.inputSchema.properties).forEach(([se,J])=>{if((J.type==="object"||J.type==="array")&&typeof P[se]=="string")try{P[se]=JSON.parse(P[se])}catch{}});const K=await z(n,P),Q=performance.now(),le=Math.round(Q-N);p(K);const X=JSON.stringify(K),fe=new TextEncoder().encode(X).length;v({duration:`${le}ms`,bytes:`${fe} bytes`,tokens:`~${Math.ceil(fe/4)} tokens`,cost:"$0.0000"})}catch(P){const K=P instanceof Error?P.message:String(P);g(K||"Unknown error occurred");const Q=performance.now();v({duration:`${Math.round(Q-N)}ms`})}finally{b(!1)}},B=(N,z)=>{d(P=>({...P,[N]:z}))},H=()=>{p(null),g(null),v(null)};return m.jsxs(Sn,{onBack:r,children:[m.jsx(Di,{children:m.jsx(Oi,{title:C?.name??bm(n),url:o,icon:"build"})}),m.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 h-full",children:[m.jsx("div",{className:"flex flex-col border-r border-border overflow-hidden",children:m.jsxs("div",{className:"flex-1 overflow-auto",children:[m.jsx("div",{className:"flex flex-col gap-4 p-6 border-b border-border min-h-28",children:m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx(js,{icon:k?.icon||null,name:k?.title||n,size:"sm",className:"shadow-sm shrink-0"}),m.jsx("h1",{className:"text-lg font-medium text-foreground leading-none",children:n}),m.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1 bg-muted/50 rounded-md h-fit",children:[w.state==="ready"?m.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500 animate-pulse shrink-0"}):w.state==="connecting"?m.jsx(tr,{size:10,className:"animate-spin text-yellow-500 shrink-0"}):m.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-red-500 shrink-0"}),m.jsx("span",{className:"font-mono text-xs capitalize text-muted-foreground leading-none",children:w.state.replace("_"," ")})]})]}),m.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:C?.description||"No description available"})]})}),m.jsxs("div",{className:"flex flex-col p-6 gap-4",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("h2",{className:"text-sm font-semibold text-foreground uppercase tracking-wide",children:"Parameters"}),C?.inputSchema?.required&&C.inputSchema.required.length>0&&m.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.jsx("span",{className:"text-red-500",children:"*"})," Required"]})]}),m.jsx("div",{className:"space-y-4",children:D&&C?.inputSchema?.properties?Object.entries(C.inputSchema.properties).map(([N,z])=>m.jsxs("div",{className:"space-y-2",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("label",{className:"text-sm font-medium leading-none flex items-center gap-1.5",children:[N,C.inputSchema?.required?.includes(N)&&m.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),m.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:z.type})]}),z.description&&m.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:z.description}),z.type==="object"||z.type==="array"?m.jsx(Ho,{className:"font-mono text-xs",value:_(N)?c[N]??"":j[N]??"",onChange:P=>B(N,P.target.value),placeholder:`Enter ${N} as JSON...`,rows:3}):m.jsx(Ii,{value:_(N)?c[N]??"":j[N]??"",onChange:P=>B(N,P.target.value),placeholder:`Enter ${N}...`})]},N)):C?.inputSchema&&!D?m.jsxs("div",{className:"space-y-2",children:[m.jsx("label",{className:"text-sm font-medium",children:"Raw JSON Input"}),m.jsx(Ho,{className:"font-mono text-xs min-h-[120px]",value:u,onChange:N=>f(N.target.value),placeholder:'e.g. { "foo": "bar" }'})]}):m.jsx("div",{className:"flex items-center justify-center p-8 bg-muted/30 rounded-lg border border-dashed border-border",children:m.jsx("p",{className:"text-sm text-muted-foreground",children:"No parameters required"})})})]})]})}),m.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[m.jsxs("div",{className:"flex items-center justify-between px-4 h-14 border-t lg:border-t-0 border-b border-border bg-background",children:[m.jsx("h2",{className:"text-sm font-medium text-foreground uppercase tracking-wide",children:"Result"}),S&&m.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(zh,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"font-mono text-foreground",children:S.duration})]}),S.tokens&&m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Kc,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"font-mono text-foreground",children:S.tokens})]}),S.bytes&&m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Yc,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"font-mono text-foreground",children:S.bytes})]}),S.cost&&m.jsx("div",{className:"flex items-center gap-1.5",children:m.jsx("span",{className:"font-mono text-foreground",children:S.cost})})]})]}),m.jsx("div",{className:"flex items-center justify-end lg:justify-between px-4 h-14 border-b border-border bg-background",children:m.jsxs("div",{className:"flex items-center gap-2 w-full lg:w-auto",children:[m.jsx(me,{size:"sm",variant:"default",className:"h-8 gap-2 flex-1 lg:flex-none",onClick:V,disabled:x,children:x?m.jsxs(m.Fragment,{children:[m.jsx(tr,{size:14,className:"animate-spin"}),"Executing..."]}):m.jsxs(m.Fragment,{children:[m.jsx(Li,{className:"h-3.5 w-3.5 fill-current"}),"Execute Tool"]})}),m.jsx(zt,{children:m.jsxs(_t,{children:[m.jsx(Lt,{asChild:!0,children:m.jsx(me,{size:"icon",variant:"outline",className:"h-8 w-8 shrink-0",onClick:H,disabled:!h&&!y,children:m.jsx($i,{size:14})})}),m.jsx($t,{children:m.jsx("p",{children:"Clear results"})})]})})]})}),y&&m.jsx("div",{className:"px-6 py-4 bg-background",children:m.jsx(gm,{variant:"destructive",children:m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx($h,{className:"h-4 w-4"}),m.jsx(ym,{className:"mb-0",children:"Execution Failed"})]}),m.jsx(xm,{className:"text-xs text-destructive",children:y})]})})}),m.jsx("div",{className:"relative flex-1 overflow-auto bg-muted/50",children:h?m.jsxs(m.Fragment,{children:[m.jsx(On,{code:JSON.stringify(h,null,2),language:"json",height:"100%",readOnly:!0}),m.jsx(me,{size:"icon",variant:"ghost",className:"absolute top-4 right-4 h-8 w-8 bg-background/80 hover:bg-background border border-border shadow-sm",onClick:()=>{navigator.clipboard.writeText(JSON.stringify(h,null,2)),Ec.success("Copied to clipboard")},children:m.jsx(Bh,{className:"h-3.5 w-3.5"})})]}):m.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-muted-foreground",children:[m.jsx(_h,{className:"h-12 w-12 mb-3 opacity-40"}),m.jsx("p",{className:"text-sm",children:"Run the tool to see results"})]})})]})]})]})}function wm(n){const e=I.c(7),{itemId:t,onBack:r}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={strict:!1},e[0]=s):s=e[0];const i=Et(s).connectionId??qt;if(!Pi(i)){let d;return e[1]===Symbol.for("react.memo_cache_sentinel")?(d=m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[m.jsx("h3",{className:"text-lg font-semibold",children:"Connection not found"}),m.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection may have been deleted or you may not have access."})]})}),e[1]=d):d=e[1],d}let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsx(tr,{size:32,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let c;return e[3]!==i||e[4]!==r||e[5]!==t?(c=m.jsx(O.Suspense,{fallback:a,children:m.jsx(km,{toolName:t,connectionId:i,onBack:r})}),e[3]=i,e[4]=r,e[5]=t,e[6]=c):c=e[6],c}const Kl=n=>{let e;const t=new Set,r=(c,d)=>{const u=typeof c=="function"?c(e):c;if(!Object.is(u,e)){const f=e;e=d??(typeof u!="object"||u===null)?u:Object.assign({},e,u),t.forEach(h=>h(e,f))}},s=()=>e,l={setState:r,getState:s,getInitialState:()=>a,subscribe:c=>(t.add(c),()=>t.delete(c))},a=e=n(r,s,l);return l},Ki=(n=>n?Kl(n):Kl),vm=n=>n;function Wo(n,e=vm){const t=ee.useSyncExternalStore(n.subscribe,ee.useCallback(()=>e(n.getState()),[n,e]),ee.useCallback(()=>e(n.getInitialState()),[n,e]));return ee.useDebugValue(t),t}const Cm=n=>{const e=Ki(n),t=r=>Wo(e,r);return Object.assign(t,e),t},Nm=(n=>Cm);function td(n,e){let t;try{t=n()}catch{return}return{getItem:s=>{var o;const i=a=>a===null?null:JSON.parse(a,void 0),l=(o=t.getItem(s))!=null?o:null;return l instanceof Promise?l.then(i):i(l)},setItem:(s,o)=>t.setItem(s,JSON.stringify(o,void 0)),removeItem:s=>t.removeItem(s)}}const qo=n=>e=>{try{const t=n(e);return t instanceof Promise?t:{then(r){return qo(r)(t)},catch(r){return this}}}catch(t){return{then(r){return this},catch(r){return qo(r)(t)}}}},Em=(n,e)=>(t,r,s)=>{let o={storage:td(()=>localStorage),partialize:g=>g,version:0,merge:(g,x)=>({...x,...g}),...e},i=!1,l=0;const a=new Set,c=new Set;let d=o.storage;if(!d)return n((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),t(...g)},r,s);const u=()=>{const g=o.partialize({...r()});return d.setItem(o.name,{state:g,version:o.version})},f=s.setState;s.setState=(g,x)=>(f(g,x),u());const h=n((...g)=>(t(...g),u()),r,s);s.getInitialState=()=>h;let p;const y=()=>{var g,x;if(!d)return;const b=++l;i=!1,a.forEach(v=>{var k;return v((k=r())!=null?k:h)});const S=((x=o.onRehydrateStorage)==null?void 0:x.call(o,(g=r())!=null?g:h))||void 0;return qo(d.getItem.bind(d))(o.name).then(v=>{if(v)if(typeof v.version=="number"&&v.version!==o.version){if(o.migrate){const k=o.migrate(v.state,v.version);return k instanceof Promise?k.then(w=>[!0,w]):[!0,k]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,v.state];return[!1,void 0]}).then(v=>{var k;if(b!==l)return;const[w,C]=v;if(p=o.merge(C,(k=r())!=null?k:h),t(p,!0),w)return u()}).then(()=>{b===l&&(S?.(p,void 0),p=r(),i=!0,c.forEach(v=>v(p)))}).catch(v=>{b===l&&S?.(void 0,v)})};return s.persist={setOptions:g=>{o={...o,...g},g.storage&&(d=g.storage)},clearStorage:()=>{d?.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>y(),hasHydrated:()=>i,onHydrate:g=>(a.add(g),()=>{a.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},o.skipHydration||y(),p||h},nd=Em,{useSyncExternalStoreWithSelector:Tm}=bh,Mm=n=>n;function Am(n,e=Mm,t){const r=Tm(n.subscribe,n.getState,n.getInitialState,e,t);return ee.useDebugValue(r),r}const Jl=n=>Symbol.iterator in n,Gl=n=>"entries"in n,Xl=(n,e)=>{const t=n instanceof Map?n:new Map(n.entries()),r=e instanceof Map?e:new Map(e.entries());if(t.size!==r.size)return!1;for(const[s,o]of t)if(!r.has(s)||!Object.is(o,r.get(s)))return!1;return!0},Om=(n,e)=>{const t=n[Symbol.iterator](),r=e[Symbol.iterator]();let s=t.next(),o=r.next();for(;!s.done&&!o.done;){if(!Object.is(s.value,o.value))return!1;s=t.next(),o=r.next()}return!!s.done&&!!o.done};function Im(n,e){return Object.is(n,e)?!0:typeof n!="object"||n===null||typeof e!="object"||e===null||Object.getPrototypeOf(n)!==Object.getPrototypeOf(e)?!1:Jl(n)&&Jl(e)?Gl(n)&&Gl(e)?Xl(n,e):Om(n,e):Xl({entries:()=>Object.entries(n)},{entries:()=>Object.entries(e)})}function Rm(n,e="Output"){if(!n)return`interface ${e} {}`;function t(o){if(!o||typeof o!="object")return"unknown";const i=o.type;if(Array.isArray(i))return i.map(l=>r(l)).join(" | ");switch(i){case"string":return o.enum?o.enum.map(l=>`"${l}"`).join(" | "):"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"null":return"null";case"array":{const l=o.items;return l?`${t(l)}[]`:"unknown[]"}case"object":return s(o);default:return o.anyOf?o.anyOf.map(t).join(" | "):o.oneOf?o.oneOf.map(t).join(" | "):o.allOf?o.allOf.map(t).join(" & "):"unknown"}}function r(o){switch(o){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"null":return"null";default:return"unknown"}}function s(o){const i=o.properties;if(!i)return"Record<string, unknown>";const l=new Set(o.required||[]);return`{
|
|
2
2
|
${Object.entries(i).map(([c,d])=>{const u=l.has(c)?"":"?";return`${d.description?` /** ${d.description} */
|
|
3
3
|
`:""} ${c}${u}: ${t(d)};`}).join(`
|
|
4
4
|
`)}
|
|
5
|
-
}`}return`interface ${e} ${t(n)}`}function fo(n,e){const t=n.trim();return e.some(s=>s.name.toLowerCase()===t.toLowerCase())?`${t}_${Math.random().toString(36).substring(2,6)}`:t}function
|
|
5
|
+
}`}return`interface ${e} ${t(n)}`}function fo(n,e){const t=n.trim();return e.some(s=>s.name.toLowerCase()===t.toLowerCase())?`${t}_${Math.random().toString(36).substring(2,6)}`:t}function jm(n,e){const t=n.match(/interface\s+Input\s*\{/);if(!t||t.index===void 0)return`${e}
|
|
6
6
|
|
|
7
|
-
${n.trimStart()}`;const r=t.index,s=r+t[0].length-1;let o=1,i=s+1;for(;i<n.length&&o>0;)n[i]==="{"?o++:n[i]==="}"&&o--,i++;return n.slice(0,r)+e+n.slice(i)}function ho(n,e){switch(n){case"tool":return{input:{},action:{toolName:""},outputSchema:{},name:`Step_${e+1}`};case"code":return{...Kh,name:`Step_${e+1}`};default:throw new Error(`Invalid step type: ${n}`)}}const rd=O.createContext(null),Am=n=>Ki()(nd(e=>({...n,actions:{setIsAddingStep:t=>e(r=>({...r,isAddingStep:t})),setCurrentStepTab:t=>e(r=>({...r,currentStepTab:t})),setToolAction:t=>e(r=>({workflow:{...r.workflow,steps:r.workflow.steps.map(s=>"toolName"in s.action&&s.action.toolName===t.toolName?{...s,action:t}:s)}})),appendStep:({step:t,type:r})=>e(s=>{const o=t??ho(r,s.workflow.steps.length),i=s.workflow.steps.find(a=>a.name===o.name),l=i?`${o.name} ${parseInt(i.name.split(" ").pop()??Math.random().toString(36).substring(2,15))+1}`:o.name;return{workflow:{...s.workflow,steps:[...s.workflow.steps,{...o,name:l}]}}}),deleteStep:t=>e(r=>({workflow:{...r.workflow,steps:r.workflow.steps.filter(s=>s.name!==t)}})),duplicateStep:t=>e(r=>{const s=r.workflow.steps.findIndex(a=>a.name===t);if(s===-1)return r;const o=r.workflow.steps[s];if(!o)return r;const i={...o,name:fo(o.name,r.workflow.steps)},l=[...r.workflow.steps];return l.splice(s+1,0,i),{workflow:{...r.workflow,steps:l},currentStepName:i.name}}),setCurrentStepName:t=>e(r=>({...r,currentStepName:t})),updateStep:(t,r)=>e(s=>({...s,workflow:{...s.workflow,steps:s.workflow.steps.map(o=>o.name===t?{...o,...r}:o)}})),setTrackingExecutionId:t=>e(r=>({...r,trackingExecutionId:t})),resetToOriginalWorkflow:()=>e(t=>({...t,workflow:t.localWorkflow})),startAddingStep:t=>e(r=>({...r,isAddingStep:!0,addingStepType:t})),cancelAddingStep:()=>e(t=>({...t,isAddingStep:!1,addingStepType:null,selectedParentSteps:[]})),toggleParentStepSelection:t=>e(r=>{const s=r.selectedParentSteps.includes(t);return{...r,selectedParentSteps:s?r.selectedParentSteps.filter(o=>o!==t):[...r.selectedParentSteps,t]}}),confirmAddCodeStep:()=>e(t=>{const{selectedParentSteps:r,addingStepType:s,workflow:o}=t;if(s!=="code"||r.length===0)return t;const i={};for(const u of r)i[u]=`@${u}`;const l={};for(const u of r){const f=o.steps.find(h=>h.name===u);f?.outputSchema&&(l[u]=f.outputSchema)}const a=Object.keys(l).length>0?{type:"object",properties:l,required:Object.keys(l)}:void 0;let c=ho("code",Number((Math.random()*1e6).toFixed(0)));if(c={...c,input:i},a){const u=Tm(a,"Input"),f=c.action,h=Mm(f.code,u);c={...c,action:{...f,code:h}}}const d=fo(c.name,o.steps);return{...t,isAddingStep:!1,addingStepType:null,selectedParentSteps:[],workflow:{...o,steps:[...o.steps,{...c,name:d}]},currentStepName:d}}),addToolStep:()=>e(t=>{let r=ho("tool",Number((Math.random()*1e6).toFixed(0)));const s=fo(r.name,t.workflow.steps);return{...t,isAddingStep:!1,addingStepType:null,workflow:{...t.workflow,steps:[...t.workflow.steps,{...r,name:s}]},currentStepName:s}}),setOriginalWorkflow:t=>e(r=>({...r,localWorkflow:t})),setWorkflow:t=>e(r=>({...r,workflow:t})),startReplacingTool:t=>e(r=>({...r,replacingToolInfo:{toolName:t}})),cancelReplacingTool:()=>e(t=>({...t,replacingToolInfo:null})),setSelectedGatewayId:t=>e(r=>({...r,selectedGatewayId:t}))}}),{name:`workflow-store-${encodeURIComponent(n.workflow.id)}`,storage:td(()=>localStorage),version:1,partialize:e=>({trackingExecutionId:e.trackingExecutionId,currentStepName:e.currentStepName,currentStepTab:e.currentStepTab,localWorkflow:e.localWorkflow,isAddingStep:e.isAddingStep,addingStepType:e.addingStepType,selectedParentSteps:e.selectedParentSteps,replacingToolInfo:e.replacingToolInfo,selectedGatewayId:e.selectedGatewayId})}));function Om(n){const e=I.c(8),{children:t,initialState:r}=n,s=Gh();let o;e[0]!==s?.[0]?.id||e[1]!==r.currentStepTab||e[2]!==r.trackingExecutionId||e[3]!==r.workflow?(o=()=>Am({workflow:r.workflow,localWorkflow:r.workflow,selectedGatewayId:s?.[0]?.id,isAddingStep:!1,selectedParentSteps:[],trackingExecutionId:r.trackingExecutionId,currentStepName:r.workflow.steps[0]?.name,currentStepTab:r.currentStepTab??"input"}),e[0]=s?.[0]?.id,e[1]=r.currentStepTab,e[2]=r.trackingExecutionId,e[3]=r.workflow,e[4]=o):o=e[4];const[i]=O.useState(o);let l;return e[5]!==t||e[6]!==i?(l=m.jsx(rd.Provider,{value:i,children:t}),e[5]=t,e[6]=i,e[7]=l):l=e[7],l}function In(n,e){const t=O.useContext(rd);if(!t)throw new Error("Missing WorkflowStoreProvider - refresh the page. If the error persists, please contact support.");return Cm(t,n,Em)}function Rn(){return In(Im)}function Im(n){return n.workflow}function Me(){return In(Rm)}function Rm(n){return n.actions}function sd(){const n=pr();return In(jm)??n[0]?.name}function jm(n){return n.currentStepName}function hr(){const n=I.c(5),e=sd(),t=pr();let r;if(n[0]!==e||n[1]!==t){let o;n[3]!==e?(o=i=>i.name===e,n[3]=e,n[4]=o):o=n[4],r=t.find(o),n[0]=e,n[1]=t,n[2]=r}else r=n[2];const s=r;return s||t[0]}function pr(){return Rn().steps}function od(){const n=I.c(8),e=Rn(),t=In(Lm);let r,s;if(n[0]!==t.description||n[1]!==t.steps||n[2]!==t.title||n[3]!==e.description||n[4]!==e.steps||n[5]!==e.title){const o={title:e.title,description:e.description,steps:e.steps.map(Pm)},i={title:t.title,description:t.description,steps:t.steps.map(Dm)};r=JSON.stringify(o),s=JSON.stringify(i),n[0]=t.description,n[1]=t.steps,n[2]=t.title,n[3]=e.description,n[4]=e.steps,n[5]=e.title,n[6]=r,n[7]=s}else r=n[6],s=n[7];return r!==s}function Dm(n){return{...n,outputSchema:void 0}}function Pm(n){return{...n,outputSchema:void 0}}function Lm(n){return n.localWorkflow}function Se(){return In($m)}function $m(n){return n.trackingExecutionId}function jn(){return In(zm)}function zm(n){return n.selectedGatewayId}function Dn(){const n=I.c(2),e=Dh();let t;n[0]!==e?(t={connections:e,binding:"WORKFLOW"},n[0]=e,n[1]=t):t=n[1];const r=Jh(t);if(!r||r.length===0||!r[0])throw new Error("No workflow connection found");return r[0]}const Yl=[100,1e3,2e3];function Pn(n){const e=I.c(15),t=Dn();let r;e[0]!==t.id?(r=qe(t.id),e[0]=t.id,e[1]=r):r=e[1];const s=r,o=O.useRef(0);let i;e[2]!==n?(i={id:n},e[2]=n,e[3]=i):i=e[3];const l=!!n;let a;e[4]!==n?(a=n?p=>{const y=p.state?.data?.item?.status;if(y==="running"||y==="enqueued"){const g=Yl[o.current]??1;return o.current=(o.current+1)%Yl.length,g}return o.current=0,!1}:!1,e[4]=n,e[5]=a):a=e[5];let c;e[6]!==t.id||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==s?(c={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_GET",toolInputParams:i,scope:t.id,staleTime:0,gcTime:0,enabled:l,refetchInterval:a},e[6]=t.id,e[7]=i,e[8]=l,e[9]=a,e[10]=s,e[11]=c):c=e[11];const{data:d,isLoading:u}=Bi(c),f=d?.item;let h;return e[12]!==u||e[13]!==f?(h={item:f,isLoading:u},e[12]=u,e[13]=f,e[14]=h):h=e[14],h}function _m(n,e){const t=I.c(14),r=Dn();let s;t[0]!==r.id?(s=qe(r.id),t[0]=r.id,t[1]=s):s=t[1];const o=s;let i;t[2]!==n||t[3]!==e?(i={executionId:n,stepId:e},t[2]=n,t[3]=e,t[4]=i):i=t[4];const l=!!n&&!!e;let a;t[5]!==r.id||t[6]!==i||t[7]!==l||t[8]!==o?(a={toolCaller:o,toolName:"COLLECTION_WORKFLOW_EXECUTION_GET_STEP_RESULT",toolInputParams:i,scope:r.id,enabled:l},t[5]=r.id,t[6]=i,t[7]=l,t[8]=o,t[9]=a):a=t[9];const{data:c,isLoading:d}=Bi(a),u=c?.output,f=c?.error;let h;return t[10]!==d||t[11]!==u||t[12]!==f?(h={output:u,error:f,isLoading:d},t[10]=d,t[11]=u,t[12]=f,t[13]=h):h=t[13],h}function Bm(){const n=I.c(19),e=Dn(),t=Rn();let r;n[0]!==e.id?(r=qe(e.id),n[0]=e.id,n[1]=r):r=n[1];const s=r;let o;n[2]===Symbol.for("react.memo_cache_sentinel")?(o=["workflow"],n[2]=o):o=n[2];let i;n[3]!==t.id?(i={field:o,operator:"eq",value:t.id},n[3]=t.id,n[4]=i):i=n[4];let l;n[5]===Symbol.for("react.memo_cache_sentinel")?(l=[{field:["created_at"],direction:"desc"}],n[5]=l):l=n[5];let a;n[6]!==i?(a={where:i,orderBy:l,limit:100},n[6]=i,n[7]=a):a=n[7];const c=`${e.id}-executions-${t.id}`,d=!!t.id;let u;n[8]!==a||n[9]!==c||n[10]!==d||n[11]!==s?(u={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_LIST",toolInputParams:a,scope:c,enabled:d,staleTime:5e3},n[8]=a,n[9]=c,n[10]=d,n[11]=s,n[12]=u):u=n[12];const{data:f,isLoading:h,refetch:p}=Bi(u),y=f;let g;n[13]!==y?.items?(g=y?.items??[],n[13]=y?.items,n[14]=g):g=n[14];let x;return n[15]!==h||n[16]!==p||n[17]!==g?(x={executions:g,isLoading:h,refetch:p},n[15]=h,n[16]=p,n[17]=g,n[18]=x):x=n[18],x}function id(n){const e=[];function t(r){if(typeof r=="string"){const s=r.match(/@input(?:\.(\w+(?:\.\w+)*))?/g);if(s)for(const o of s)if(o==="@input")e.push("__entire_input__");else{const i=o.replace("@input.","");e.push(i)}}else Array.isArray(r)?r.forEach(t):typeof r=="object"&&r!==null&&Object.values(r).forEach(t)}return t(n),[...new Set(e)]}function Fm(n){const e=[];for(const t of n){const r=id(t.input);e.push(...r)}return[...new Set(e)].filter(t=>t!=="__entire_input__")}function Vm(n){for(const e of n)if(id(e.input).includes("__entire_input__"))return!0;return!1}function Hm(n){const e=Fm(n);if(e.length===0)return Vm(n)?{type:"object",additionalProperties:!0,description:"Workflow input data"}:null;const t={},r=[];for(const s of e){const o=s.split(".");if(o.length===1)t[s]={type:"string",description:`Input field: ${s}`},r.push(s);else{const i=o[0];i&&!t[i]&&(t[i]={type:"object",description:`Input object: ${i}`,additionalProperties:!0},r.push(i))}}return{type:"object",properties:t,required:r,description:"Workflow execution input"}}function Wm(){const n=I.c(2),e=Rn();let t;return n[0]!==e.steps?(t=Hm(e.steps),n[0]=e.steps,n[1]=t):t=n[1],t}function qm(){const n=I.c(14),{id:e}=Dn(),{setTrackingExecutionId:t}=Me();let r;n[0]!==e?(r=qe(e),n[0]=e,n[1]=r):r=n[1];const s=r,o=Rn(),i=jn(),l=Wm();let a;n[2]!==s?(a={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_CREATE"},n[2]=s,n[3]=a):a=n[3];const{mutateAsync:c,isPending:d}=Fi(a);let u;n[4]!==i||n[5]!==t||n[6]!==c||n[7]!==o?(u=async y=>{const g=y===void 0?{}:y;if(!i)throw new Error("Please select an Agent before running the workflow");const x=Date.now(),b=await c({input:g,gateway_id:i,start_at_epoch_ms:x,workflow_collection_id:o.id}),S=b?.item?.id??b?.structuredContent?.item?.id;return t(S),S},n[4]=i,n[5]=t,n[6]=c,n[7]=o,n[8]=u):u=n[8];const f=u,h=l!==null;let p;return n[9]!==f||n[10]!==l||n[11]!==d||n[12]!==h?(p={handleRunWorkflow:f,isPending:d,requiresInput:h,inputSchema:l},n[9]=f,n[10]=l,n[11]=d,n[12]=h,n[13]=p):p=n[13],p}function Um(){const n=I.c(9),{id:e}=Dn();let t;n[0]!==e?(t=qe(e),n[0]=e,n[1]=t):t=n[1];const r=t;let s;n[2]!==r?(s={toolCaller:r,toolName:"CANCEL_EXECUTION"},n[2]=r,n[3]=s):s=n[3];const{mutateAsync:o,isPending:i}=Fi(s);let l;n[4]!==o?(l=async d=>await o({executionId:d}),n[4]=o,n[5]=l):l=n[5];const a=l;let c;return n[6]!==a||n[7]!==i?(c={handleCancelWorkflow:a,isCancelling:i},n[6]=a,n[7]=i,n[8]=c):c=n[8],c}function Km(){const n=I.c(9),{id:e}=Dn();let t;n[0]!==e?(t=qe(e),n[0]=e,n[1]=t):t=n[1];const r=t;let s;n[2]!==r?(s={toolCaller:r,toolName:"RESUME_EXECUTION"},n[2]=r,n[3]=s):s=n[3];const{mutateAsync:o,isPending:i}=Fi(s);let l;n[4]!==o?(l=async d=>(await o({executionId:d})).success,n[4]=o,n[5]=l):l=n[5];const a=l;let c;return n[6]!==a||n[7]!==i?(c={handleResumeWorkflow:a,isResuming:i},n[6]=a,n[7]=i,n[8]=c):c=n[8],c}function Jm(){const n=I.c(3),e=Se(),{item:t}=Pn(e);let r;return n[0]!==t||n[1]!==e?(r=e&&t?(()=>{const o={};return t?.input&&(o.input=t.input),o})():void 0,n[0]=t,n[1]=e,n[2]=r):r=n[2],r}function Gm(n,e,t,r){if(!e)return[...n].sort(r);const s=t(e);return[...n].sort((o,i)=>{const l=t(o),a=t(i);return l===s?-1:a===s?1:r?r(o,i):0})}const Ji=km()(nd(n=>({viewMode:"visual",setViewMode:e=>n({viewMode:e}),showExecutionsList:!1,setShowExecutionsList:e=>n({showExecutionsList:e}),toggleExecutionsList:()=>n(e=>({showExecutionsList:!e.showExecutionsList}))}),{name:"workflow-view-mode"})),ld=O.createContext([]);function ad(){return O.useContext(ld)}function xe(n){this.content=n}xe.prototype={constructor:xe,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),o=r.content.slice();return s==-1?o.push(t||n,e):(o[s+1]=e,t&&(o[s]=t)),new xe(o)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new xe(t)},addToStart:function(n,e){return new xe([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new xe(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),o=r.find(n);return s.splice(o==-1?s.length:o,0,e,t),new xe(s)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=xe.from(n),n.size?new xe(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=xe.from(n),n.size?new xe(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=xe.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};xe.from=function(n){if(n instanceof xe)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new xe(e)};function cd(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),o=e.child(r);if(s==o){t+=s.nodeSize;continue}if(!s.sameMarkup(o))return t;if(s.isText&&s.text!=o.text){for(let i=0;s.text[i]==o.text[i];i++)t++;return t}if(s.content.size||o.content.size){let i=cd(s.content,o.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function dd(n,e,t,r){for(let s=n.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:t,b:r};let i=n.child(--s),l=e.child(--o),a=i.nodeSize;if(i==l){t-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:t,b:r};if(i.isText&&i.text!=l.text){let c=0,d=Math.min(i.text.length,l.text.length);for(;c<d&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||l.content.size){let c=dd(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class E{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,o){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,s+l,o||null,i)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),r,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let o="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),o=1);o<e.content.length;o++)s.push(e.content[o]);return new E(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let o=0,i=0;i<t;o++){let l=this.content[o],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),r.push(l),s+=l.nodeSize),i=a}return new E(r,s)}cutByIndex(e,t){return e==t?E.empty:e==0&&t==this.content.length?this:new E(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new E(s,o)}addToStart(e){return new E([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new E(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))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 t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return cd(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return dd(this,e,t,r)}findIndex(e){if(e==0)return Sr(0,e);if(e==this.size)return Sr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let s=this.child(t),o=r+s.nodeSize;if(o>=e)return o==e?Sr(t+1,o):Sr(t,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return E.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new E(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return E.empty;let t,r=0;for(let s=0;s<e.length;s++){let o=e[s];r+=o.nodeSize,s&&o.isText&&e[s-1].sameMarkup(o)?(t||(t=e.slice(0,s)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new E(t||e,r)}static from(e){if(!e)return E.empty;if(e instanceof E)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new E([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}E.empty=new E([],0);const po={index:0,offset:0};function Sr(n,e){return po.index=n,po.offset=e,po}function Fr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Fr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Fr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Y=class Uo{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let o=e[s];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,s));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Fr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Uo.none;if(e instanceof Uo)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};Y.none=[];class Vr extends Error{}class R{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=fd(this.content,e+this.openStart,t);return r&&new R(r,this.openStart,this.openEnd)}removeBetween(e,t){return new R(ud(this.content,e+this.openStart,t+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,t){if(!t)return R.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new R(E.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)s++;return new R(e,r,s)}}R.empty=new R(E.empty,0,0);function ud(n,e,t){let{index:r,offset:s}=n.findIndex(e),o=n.maybeChild(r),{index:i,offset:l}=n.findIndex(t);if(s==e||o.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(ud(o.content,e-s-1,t-s-1)))}function fd(n,e,t,r){let{index:s,offset:o}=n.findIndex(e),i=n.maybeChild(s);if(o==e||i.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=fd(i.content,e-o-1,t,i);return l&&n.replaceChild(s,i.copy(l))}function Xm(n,e,t){if(t.openStart>n.depth)throw new Vr("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Vr("Inconsistent open depths");return hd(n,e,t,0)}function hd(n,e,t,r){let s=n.index(r),o=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let i=hd(n,e,t,r+1);return o.copy(o.content.replaceChild(s,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let i=n.parent,l=i.content;return Ft(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=Ym(t,n);return Ft(o,md(n,i,l,e,r))}else return Ft(o,Hr(n,e,r))}function pd(n,e){if(!e.type.compatibleContent(n.type))throw new Vr("Cannot join "+e.type.name+" onto "+n.type.name)}function Ko(n,e,t){let r=n.node(t);return pd(r,e.node(t)),r}function Bt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function qn(n,e,t,r){let s=(e||n).node(t),o=0,i=e?e.index(t):s.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(Bt(n.nodeAfter,r),o++));for(let l=o;l<i;l++)Bt(s.child(l),r);e&&e.depth==t&&e.textOffset&&Bt(e.nodeBefore,r)}function Ft(n,e){return n.type.checkContent(e),n.copy(e)}function md(n,e,t,r,s){let o=n.depth>s&&Ko(n,e,s+1),i=r.depth>s&&Ko(t,r,s+1),l=[];return qn(null,n,s,l),o&&i&&e.index(s)==t.index(s)?(pd(o,i),Bt(Ft(o,md(n,e,t,r,s+1)),l)):(o&&Bt(Ft(o,Hr(n,e,s+1)),l),qn(e,t,s,l),i&&Bt(Ft(i,Hr(t,r,s+1)),l)),qn(r,null,s,l),new E(l)}function Hr(n,e,t){let r=[];if(qn(null,n,t,r),n.depth>t){let s=Ko(n,e,t+1);Bt(Ft(s,Hr(n,e,t+1)),r)}return qn(e,null,t,r),new E(r)}function Ym(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)s=e.node(o).copy(E.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class nr{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.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,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)s+=r.child(o).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return Y.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let l=r;r=s,s=l}let o=r.marks;for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!s||!o[i].isInSet(s.marks))&&(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,s=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!s||!r[o].isInSet(s.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){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)&&(!t||t(this.node(r))))return new Wr(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 t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,o=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(o),c=o-a;if(r.push(i,l,s+a),!c||(i=i.child(l),i.isText))break;o=c-1,s+=a+1}return new nr(t,r,o)}static resolveCached(e,t){let r=Ql.get(e);if(r)for(let o=0;o<r.elts.length;o++){let i=r.elts[o];if(i.pos==t)return i}else Ql.set(e,r=new Qm);let s=r.elts[r.i]=nr.resolve(e,t);return r.i=(r.i+1)%Zm,s}}class Qm{constructor(){this.elts=[],this.i=0}}const Zm=12,Ql=new WeakMap;class Wr{constructor(e,t,r){this.$from=e,this.$to=t,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 eg=Object.create(null);class ze{constructor(e,t,r,s=Y.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||E.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,t,r,s=0){this.content.nodesBetween(e,t,r,s,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,t,r,s){return this.content.textBetween(e,t,r,s)}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,t,r){return this.type==e&&Fr(this.attrs,t||e.defaultAttrs||eg)&&Y.sameSet(this.marks,r||Y.none)}copy(e=null){return e==this.content?this:new ze(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ze(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return R.empty;let s=this.resolve(e),o=this.resolve(t),i=r?0:s.sharedDepth(t),l=s.start(i),c=s.node(i).content.cut(s.pos-l,o.pos-l);return new R(c,s.depth-i,o.depth-i)}replace(e,t,r){return Xm(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return nr.resolveCached(this,e)}resolveNoCache(e){return nr.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(s=!0),!s)),s}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()+")"),gd(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=E.empty,s=0,o=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,s,o),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<o;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let o=this.contentMatchAt(e).matchType(r),i=o&&o.matchFragment(this.content,t);return i?i.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=Y.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Y.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t 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(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=E.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,s,r);return o.type.checkAttrs(o.attrs),o}}ze.prototype.text=void 0;class qr extends ze{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):gd(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new qr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new qr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function gd(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Ut{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new tg(e,t);if(r.next==null)return Ut.empty;let s=yd(r);r.next&&r.err("Unexpected trailing text");let o=ag(lg(s));return cg(o,r),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let s=this;for(let o=t;s&&o<r;o++)s=s.matchType(e.child(o).type);return s}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:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function o(i,l){let a=i.matchFragment(e,r);if(a&&(!t||a.validEnd))return E.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:d,next:u}=i.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(u)==-1){s.push(u);let f=o(u,l.concat(d));if(f)return f}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),o=s.match;if(o.matchType(e)){let i=[];for(let l=s;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<o.next.length;i++){let{type:l,next:a}=o.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),t[l.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 t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(this),e.map((r,s)=>{let o=s+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)o+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return o}).join(`
|
|
8
|
-
`)}}Ut.empty=new Ut(!0);class tg{constructor(e,t){this.string=e,this.nodeTypes=t,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 yd(n){let e=[];do e.push(ng(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function ng(n){let e=[];do e.push(rg(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function rg(n){let e=ig(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=sg(n,e);else break;return e}function Zl(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function sg(n,e){let t=Zl(n),r=t;return n.eat(",")&&(n.next!="}"?r=Zl(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function og(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let s=[];for(let o in t){let i=t[o];i.isInGroup(e)&&s.push(i)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function ig(n){if(n.eat("(")){let e=yd(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=og(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function lg(n){let e=[[]];return s(o(n,0),t()),e;function t(){return e.push([])-1}function r(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function s(i,l){i.forEach(a=>a.to=l)}function o(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=o(i.exprs[a],l);if(a==i.exprs.length-1)return c;s(c,l=t())}else if(i.type=="star"){let a=t();return r(l,a),s(o(i.expr,a),a),[r(a)]}else if(i.type=="plus"){let a=t();return s(o(i.expr,l),a),s(o(i.expr,a),a),[r(a)]}else{if(i.type=="opt")return[r(l)].concat(o(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let d=t();s(o(i.expr,a),d),a=d}if(i.max==-1)s(o(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let d=t();r(a,d),s(o(i.expr,a),d),a=d}return[r(a)]}else{if(i.type=="name")return[r(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function xd(n,e){return e-n}function ea(n,e){let t=[];return r(e),t.sort(xd);function r(s){let o=n[s];if(o.length==1&&!o[0].term)return r(o[0].to);t.push(s);for(let i=0;i<o.length;i++){let{term:l,to:a}=o[i];!l&&t.indexOf(a)==-1&&r(a)}}}function ag(n){let e=Object.create(null);return t(ea(n,0));function t(r){let s=[];r.forEach(i=>{n[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<s.length;d++)s[d][0]==l&&(c=s[d][1]);ea(n,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let o=e[r.join(",")]=new Ut(r.indexOf(n.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(xd);o.next.push({type:s[i][0],next:e[l.join(",")]||t(l)})}return o}}function cg(n,e){for(let t=0,r=[n];t<r.length;t++){let s=r[t],o=!s.validEnd,i=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];i.push(a.name),o&&!(a.isText||a.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function bd(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function kd(n,e){let t=Object.create(null);for(let r in n){let s=e&&e[r];if(s===void 0){let o=n[r];if(o.hasDefault)s=o.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=s}return t}function Sd(n,e,t,r){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let o=n[s];o.validate&&o.validate(e[s])}}function wd(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new ug(n,r,e[r]);return t}let ta=class vd{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=wd(e,r.attrs),this.defaultAttrs=bd(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==Ut.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:kd(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ze(this,this.computeAttrs(e),E.from(t),Y.setFrom(r))}createChecked(e=null,t,r){return t=E.from(t),this.checkContent(t),new ze(this,this.computeAttrs(e),t,Y.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=E.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let s=this.contentMatch.matchFragment(t),o=s&&s.fillBefore(E.empty,!0);return o?new ze(this,e,t.append(o),Y.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.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){Sd(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 t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:Y.none:e}static compile(e,t){let r=Object.create(null);e.forEach((o,i)=>r[o]=new vd(o,t,i));let s=t.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function dg(n,e,t){let r=t.split("|");return s=>{let o=s===null?"null":typeof s;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${o}`)}}class ug{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?dg(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Ps{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=wd(e,s.attrs),this.excluded=null;let o=bd(this.attrs);this.instance=o?new Y(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Y(this,kd(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((o,i)=>r[o]=new Ps(o,s++,t,i)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Sd(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Cd{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=xe.from(e.nodes),t.marks=xe.from(e.marks||{}),this.nodes=ta.compile(this.spec.nodes,this),this.marks=Ps.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let o=this.nodes[s],i=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[i]||(r[i]=Ut.parse(i,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?na(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let s in this.marks){let o=this.marks[s],i=o.spec.excludes;o.excluded=i==null?[o]:i==""?[]:na(this,i.split(" "))}this.nodeFromJSON=s=>ze.fromJSON(this,s),this.markFromJSON=s=>Y.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ta){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(t,r,s)}text(e,t){let r=this.nodes.text;return new qr(r,r.defaultAttrs,e,Y.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function na(n,e){let t=[];for(let r=0;r<e.length;r++){let s=e[r],o=n.marks[s],i=o;if(o)t.push(o);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function fg(n){return n.tag!=null}function hg(n){return n.style!=null}class kt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(fg(s))this.tags.push(s);else if(hg(s)){let o=/[^=]*/.exec(s.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let o=e.nodes[s.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new sa(this,t,!1);return r.addAll(e,Y.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new sa(this,t,!0);return r.addAll(e,Y.none,t.from,t.to),R.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let o=this.tags[s];if(gg(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let i=o.getAttrs(e);if(i===!1)continue;o.attrs=i||void 0}return o}}}matchStyle(e,t,r,s){for(let o=s?this.styles.indexOf(s)+1:0;o<this.styles.length;o++){let i=this.styles[o],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function r(s){let o=s.priority==null?50:s.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<o)break}t.splice(i,0,s)}for(let s in e.marks){let o=e.marks[s].spec.parseDOM;o&&o.forEach(i=>{r(i=oa(i)),i.mark||i.ignore||i.clearMark||(i.mark=s)})}for(let s in e.nodes){let o=e.nodes[s].spec.parseDOM;o&&o.forEach(i=>{r(i=oa(i)),i.node||i.ignore||i.mark||(i.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new kt(e,kt.schemaRules(e)))}}const Nd={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},pg={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ed={ol:!0,ul:!0},rr=1,Jo=2,Un=4;function ra(n,e,t){return e!=null?(e?rr:0)|(e==="full"?Jo:0):n&&n.whitespace=="pre"?rr|Jo:t&~Un}class wr{constructor(e,t,r,s,o,i){this.type=e,this.attrs=t,this.marks=r,this.solid=s,this.options=i,this.content=[],this.activeMarks=Y.none,this.match=o||(i&Un?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(E.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&rr)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-s[0].length))}}let t=E.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(E.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Nd.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class sa{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=t.topNode,o,i=ra(null,t.preserveWhitespace,0)|(r?Un:0);s?o=new wr(s.type,s.attrs,Y.none,!0,t.topMatch||s.type.contentMatch,i):r?o=new wr(null,null,Y.none,!0,null,i):o=new wr(e.schema.topNodeType,null,Y.none,!0,null,i),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,s=this.top,o=s.options&Jo?"full":this.localPreserveWS||(s.options&rr)>0,{schema:i}=this.parser;if(o==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,`
|
|
9
|
-
`);else if(i.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(i.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(i.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(i.text(l[a]),t,!/\S/.test(l[a]));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 l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(i.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let s=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),l;Ed.hasOwnProperty(i)&&this.parser.normalizeLists&&
|
|
10
|
-
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let o=this.parser.matchedStyles[s],i=r.getPropertyValue(o);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(o,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,s){let o,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(i,t.attrs||null,r,t.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,t,r,s){let o=r||0;for(let i=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];i!=l;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}findPlace(e,t,r){let s,o;for(let i=this.open,l=0;i>=0;i--){let a=this.nodes[i],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,o=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(o);for(let i=0;i<s.length;i++)t=this.enterInner(s[i],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let s=this.findPlace(e,t,r);if(s){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let i=Y.none;for(let l of s.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):ia(l.type,e.type))&&(i=l.addToSet(i));return o.content.push(e.mark(i)),!0}return!1}enter(e,t,r,s){let o=this.findPlace(e.create(t),r,!1);return o&&(o=this.enterInner(e,t,r,!0,s)),o}enterInner(e,t,r,s=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=ra(e,o,i.options);i.options&Un&&i.content.length==0&&(l|=Un);let a=Y.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):ia(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new wr(e,t,a,s,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].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 t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=rr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(s?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(i(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function mg(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ed.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function gg(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function oa(n){let e={};for(let t in n)e[t]=n[t];return e}function ia(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let o=[],i=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||o.indexOf(d)<0&&i(d))return!0}};if(i(s.contentMatch))return!0}}class Qt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=mo(t).createDocumentFragment());let s=r,o=[];return e.forEach(i=>{if(o.length||i.marks.length){let l=0,a=0;for(;l<o.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(o[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)s=o.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],d=this.serializeMark(c,i.isInline,t);d&&(o.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:s}=Dr(mo(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let o=this.serializeMark(e.marks[s],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&Dr(mo(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return Dr(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Qt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=la(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return la(e.marks)}}function la(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function mo(n){return n.document||window.document}const aa=new WeakMap;function yg(n){let e=aa.get(n);return e===void 0&&aa.set(n,e=xg(n)),e}function xg(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)t(r[s]);else for(let s in r)t(r[s])}return t(n),e}function Dr(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],o;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=yg(r))&&o.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 i=s.indexOf(" ");i>0&&(t=s.slice(0,i),s=s.slice(i+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=Dr(n,f,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Td=65535,Md=Math.pow(2,16);function bg(n,e){return n+e*Md}function ca(n){return n&Td}function kg(n){return(n-(n&Td))/Md}const Ad=1,Od=2,Pr=4,Id=8;class Go{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Id)>0}get deletedBefore(){return(this.delInfo&(Ad|Pr))>0}get deletedAfter(){return(this.delInfo&(Od|Pr))>0}get deletedAcross(){return(this.delInfo&Pr)>0}}class Re{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Re.empty)return Re.empty}recover(e){let t=0,r=ca(e);if(!this.inverted)for(let s=0;s<r;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+t+kg(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let s=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+o],d=this.ranges[l+i],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,h=a+s+(f<0?0:d);if(r)return h;let p=e==(t<0?a:u)?null:bg(l/3,e-a),y=e==a?Od:e==u?Ad:Pr;return(t<0?e!=a:e!=u)&&(y|=Id),new Go(h,y,p)}s+=d-c}return r?e+s:new Go(e+s,0,null)}touches(e,t){let r=0,s=ca(t),o=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+o],d=a+c;if(e<=d&&l==s*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,o=0;s<this.ranges.length;s+=3){let i=this.ranges[s],l=i-(this.inverted?o:0),a=i+(this.inverted?0:o),c=this.ranges[s+t],d=this.ranges[s+r];e(l,l+c,a,a+d),o+=d-c}}invert(){return new Re(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Re.empty:new Re(e<0?[0,-e,0]:[0,0,e])}}Re.empty=new Re([]);class sr{constructor(e,t,r=0,s=e?e.length:0){this.mirror=t,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new sr(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let s=e.getMirror(t);this.appendMap(e._maps[t],s!=null&&s<t?r+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e._maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new sr;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let s=0;for(let o=this.from;o<this.to;o++){let i=this._maps[o],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new Go(e,s,null)}}const go=Object.create(null);class Ne{getMap(){return Re.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=go[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in go)throw new RangeError("Duplicate use of step JSON ID "+e);return go[e]=t,t.prototype.jsonID=e,t}}class de{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new de(e,null)}static fail(e){return new de(null,e)}static fromReplace(e,t,r,s){try{return de.ok(e.replace(t,r,s))}catch(o){if(o instanceof Vr)return de.fail(o.message);throw o}}}function Gi(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let o=n.child(s);o.content.size&&(o=o.copy(Gi(o.content,e,o))),o.isInline&&(o=e(o,t,s)),r.push(o)}return E.fromArray(r)}class yt extends Ne{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),o=new R(Gi(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),t.openStart,t.openEnd);return de.fromReplace(e,this.from,this.to,o)}invert(){return new He(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new yt(t.pos,r.pos,this.mark)}merge(e){return e instanceof yt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new yt(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,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new yt(t.from,t.to,e.markFromJSON(t.mark))}}Ne.jsonID("addMark",yt);class He extends Ne{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new R(Gi(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return de.fromReplace(e,this.from,this.to,r)}invert(){return new yt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new He(t.pos,r.pos,this.mark)}merge(e){return e instanceof He&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new He(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,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new He(t.from,t.to,e.markFromJSON(t.mark))}}Ne.jsonID("removeMark",He);class xt extends Ne{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return de.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return de.fromReplace(e,this.pos,this.pos+1,new R(E.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(r))return new xt(this.pos,t.marks[s]);return new xt(this.pos,this.mark)}}return new Kt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new xt(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new xt(t.pos,e.markFromJSON(t.mark))}}Ne.jsonID("addNodeMark",xt);class Kt extends Ne{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return de.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return de.fromReplace(e,this.pos,this.pos+1,new R(E.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new xt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Kt(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Kt(t.pos,e.markFromJSON(t.mark))}}Ne.jsonID("removeNodeMark",Kt);class he extends Ne{constructor(e,t,r,s=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=s}apply(e){return this.structure&&Xo(e,this.from,this.to)?de.fail("Structure replace would overwrite content"):de.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Re([this.from,this.to-this.from,this.slice.size])}invert(e){return new he(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new he(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof he)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?R.empty:new R(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new he(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?R.empty:new R(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new he(e.from,this.to,t,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,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new he(t.from,t.to,R.fromJSON(e,t.slice),!!t.structure)}}Ne.jsonID("replace",he);class ge extends Ne{constructor(e,t,r,s,o,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=s,this.slice=o,this.insert=i,this.structure=l}apply(e){if(this.structure&&(Xo(e,this.from,this.gapFrom)||Xo(e,this.gapTo,this.to)))return de.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return de.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?de.fromReplace(e,this.from,this.to,r):de.fail("Content does not fit in gap")}getMap(){return new Re([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ge(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||s<t.pos||o>r.pos?null:new ge(t.pos,r.pos,s,o,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,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ge(t.from,t.to,t.gapFrom,t.gapTo,R.fromJSON(e,t.slice),t.insert,!!t.structure)}}Ne.jsonID("replaceAround",ge);function Xo(n,e,t){let r=n.resolve(e),s=t-e,o=r.depth;for(;s>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,s--;if(s>0){let i=r.node(o).maybeChild(r.indexAfter(o));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function Sg(n,e,t,r){let s=[],o=[],i,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(u);for(let y=0;y<u.length;y++)u[y].isInSet(p)||(i&&i.to==f&&i.mark.eq(u[y])?i.to=h:s.push(i=new He(f,h,u[y])));l&&l.to==f?l.to=h:o.push(l=new yt(f,h,r))}}),s.forEach(a=>n.step(a)),o.forEach(a=>n.step(a))}function wg(n,e,t,r){let s=[],o=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;o++;let a=null;if(r instanceof Ps){let c=i.marks,d;for(;d=r.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(i.marks)&&(a=[r]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],f;for(let h=0;h<s.length;h++){let p=s[h];p.step==o-1&&u.eq(s[h].style)&&(f=p)}f?(f.to=c,f.step=o):s.push({style:u,from:Math.max(l,e),to:c,step:o})}}}),s.forEach(i=>n.step(new He(i.from,i.to,i.style)))}function Xi(n,e,t,r=t.contentMatch,s=!0){let o=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),d=l+c.nodeSize,u=r.matchType(c.type);if(!u)i.push(new he(l,d,R.empty));else{r=u;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new He(l,d,c.marks[f]));if(s&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new R(E.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new he(l+f.index,l+f.index+f[0].length,p))}}l=d}if(!r.validEnd){let a=r.fillBefore(E.empty,!0);n.replace(l,l,new R(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function vg(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Ln(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,s=0,o=0;;--r){let i=n.$from.node(r),l=n.$from.index(r)+s,a=n.$to.indexAfter(r)-o;if(r<n.depth&&i.canReplace(l,a,t))return r;if(r==0||i.type.spec.isolating||!vg(i,l,a))break;l&&(s=1),a<i.childCount&&(o=1)}return null}function Cg(n,e,t){let{$from:r,$to:s,depth:o}=e,i=r.before(o+1),l=s.after(o+1),a=i,c=l,d=E.empty,u=0;for(let p=o,y=!1;p>t;p--)y||r.index(p)>0?(y=!0,d=E.from(r.node(p).copy(d)),u++):a--;let f=E.empty,h=0;for(let p=o,y=!1;p>t;p--)y||s.after(p+1)<s.end(p)?(y=!0,f=E.from(s.node(p).copy(f)),h++):c++;n.step(new ge(a,c,i,l,new R(d.append(f),u,h),d.size-u,!0))}function Yi(n,e,t=null,r=n){let s=Ng(n,e),o=s&&Eg(r,e);return o?s.map(da).concat({type:e,attrs:t}).concat(o.map(da)):null}function da(n){return{type:n,attrs:null}}function Ng(n,e){let{parent:t,startIndex:r,endIndex:s}=n,o=t.contentMatchAt(r).findWrapping(e);if(!o)return null;let i=o.length?o[0]:e;return t.canReplaceWith(r,s,i)?o:null}function Eg(n,e){let{parent:t,startIndex:r,endIndex:s}=n,o=t.child(r),i=e.contentMatch.findWrapping(o.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function Tg(n,e,t){let r=E.empty;for(let i=t.length-1;i>=0;i--){if(r.size){let l=t[i].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=E.from(t[i].type.create(t[i].attrs,r))}let s=e.start,o=e.end;n.step(new ge(s,o,s,o,new R(r,0,0),t.length,!0))}function Mg(n,e,t,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let a=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(r,a)&&Ag(n.doc,n.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&jd(n,i,l,o),Xi(n,n.mapping.slice(o).map(l,1),r,void 0,c===null);let d=n.mapping.slice(o),u=d.map(l,1),f=d.map(l+i.nodeSize,1);return n.step(new ge(u,f,u+1,f-1,new R(E.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&Rd(n,i,l,o),!1}})}function Rd(n,e,t,r){e.forEach((s,o)=>{if(s.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(s.text);){let a=n.mapping.slice(r).map(t+1+o+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function jd(n,e,t,r){e.forEach((s,o)=>{if(s.type==s.type.schema.linebreakReplacement){let i=n.mapping.slice(r).map(t+1+o);n.replaceWith(i,i+1,e.type.schema.text(`
|
|
11
|
-
`))}})}function Ag(n,e,t){let r=n.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,t)}function Og(n,e,t,r,s){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let i=t.create(r,null,s||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,i);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ge(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new R(E.from(i),0,0),1,!0))}function ot(n,e,t=1,r){let s=n.resolve(e),o=s.depth-t,i=r&&r[r.length-1]||s.parent;if(o<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=t-2;c>o;c--,d--){let u=s.node(c),f=s.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),p=r&&r[d+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let y=r&&r[d]||u;if(!u.canReplace(f+1,u.childCount)||!y.type.validContent(h))return!1}let l=s.indexAfter(o),a=r&&r[0];return s.node(o).canReplaceWith(l,l,a?a.type:s.node(o+1).type)}function Ig(n,e,t=1,r){let s=n.doc.resolve(e),o=E.empty,i=E.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){o=E.from(s.node(l).copy(o));let d=r&&r[c];i=E.from(d?d.type.create(d.attrs,i):s.node(l).copy(i))}n.step(new he(e,e,new R(o.append(i),t,t),!0))}function Mt(n,e){let t=n.resolve(e),r=t.index();return Dd(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Rg(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let s=0;s<e.childCount;s++){let o=e.child(s),i=o.type==r?n.type.schema.nodes.text:o.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(o.marks))return!1}return t.validEnd}function Dd(n,e){return!!(n&&e&&!n.isLeaf&&Rg(n,e))}function Ls(n,e,t=-1){let r=n.resolve(e);for(let s=r.depth;;s--){let o,i,l=r.index(s);if(s==r.depth?(o=r.nodeBefore,i=r.nodeAfter):t>0?(o=r.node(s+1),l++,i=r.node(s).maybeChild(l)):(o=r.node(s).maybeChild(l-1),i=r.node(s+1)),o&&!o.isTextblock&&Dd(o,i)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=t<0?r.before(s):r.after(s)}}function jg(n,e,t){let r=null,{linebreakReplacement:s}=n.doc.type.schema,o=n.doc.resolve(e-t),i=o.node().type;if(s&&i.inlineContent){let d=i.whitespace=="pre",u=!!i.contentMatch.matchType(s);d&&!u?r=!1:!d&&u&&(r=!0)}let l=n.steps.length;if(r===!1){let d=n.doc.resolve(e+t);jd(n,d.node(),d.before(),l)}i.inlineContent&&Xi(n,e+t-1,i,o.node().contentMatchAt(o.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new he(c,a.map(e+t,-1),R.empty,!0)),r===!0){let d=n.doc.resolve(c);Rd(n,d.node(),d.before(),n.steps.length)}return n}function Dg(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let o=r.index(s);if(r.node(s).canReplaceWith(o,o,t))return r.before(s+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let o=r.indexAfter(s);if(r.node(s).canReplaceWith(o,o,t))return r.after(s+1);if(o<r.node(s).childCount)return null}return null}function Pd(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let o=0;o<t.openStart;o++)s=s.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let i=r.depth;i>=0;i--){let l=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,a=r.index(i)+(l>0?1:0),c=r.node(i),d=!1;if(o==1)d=c.canReplace(a,a,s);else{let u=c.contentMatchAt(a).findWrapping(s.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(i+1):r.after(i+1)}return null}function $s(n,e,t=e,r=R.empty){if(e==t&&!r.size)return null;let s=n.resolve(e),o=n.resolve(t);return Ld(s,o,r)?new he(e,t,r):new Pg(s,o,r).fit()}function Ld(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Pg{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=E.empty;for(let s=0;s<=e.depth;s++){let o=e.node(s);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=E.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let o=this.placed,i=r.depth,l=s.depth;for(;i&&l&&o.childCount==1;)o=o.firstChild.content,i--,l--;let a=new R(o,i,l);return e>-1?new ge(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new he(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let o=t.firstChild;if(t.childCount>1&&(s=0),o.type.spec.isolating&&s<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let s,o=null;r?(o=yo(this.unplaced.content,r-1).firstChild,s=o.content):s=this.unplaced.content;let i=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(i?c.matchType(i.type)||(u=c.fillBefore(E.from(i),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:u};if(t==2&&i&&(d=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:d};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=yo(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new R(e,t+1,Math.max(r,s.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=yo(e,t);if(s.childCount<=1&&t>0){let o=e.size-t<=t+s.size;this.unplaced=new R(Fn(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new R(Fn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:s,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let y=0;y<o.length;y++)this.openFrontierNode(o[y]);let i=this.unplaced,l=r?r.content:i.content,a=i.openStart-e,c=0,d=[],{match:u,type:f}=this.frontier[t];if(s){for(let y=0;y<s.childCount;y++)d.push(s.child(y));u=u.matchFragment(s)}let h=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let y=l.child(c),g=u.matchType(y.type);if(!g)break;c++,(c>1||a==0||y.content.size)&&(u=g,d.push($d(y.mark(f.allowedMarks(y.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=Vn(this.placed,t,E.from(d)),this.frontier[t].match=u,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,g=l;y<h;y++){let x=g.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),g=x.content}this.unplaced=p?e==0?R.empty:new R(Fn(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new R(Fn(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!xo(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:s}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=xo(e,t,s,r,o);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=xo(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:i,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Vn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let s=e.node(r),o=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,o)}return e}openFrontierNode(e,t=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Vn(this.placed,this.depth,E.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(E.empty,!0);t.childCount&&(this.placed=Vn(this.placed,this.frontier.length,t))}}function Fn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Fn(n.firstChild.content,e-1,t)))}function Vn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Vn(n.lastChild.content,e-1,t)))}function yo(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function $d(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,$d(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(E.empty,!0)))),n.copy(r)}function xo(n,e,t,r,s){let o=n.node(e),i=s?n.indexAfter(e):n.index(e);if(i==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,i);return l&&!Lg(t,o.content,i)?l:null}function Lg(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function $g(n){return n.spec.defining||n.spec.definingForContent}function zg(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),o=n.doc.resolve(t);if(Ld(s,o,r))return n.step(new he(e,t,r));let i=_d(s,o);i[i.length-1]==0&&i.pop();let l=-(s.depth+1);i.unshift(l);for(let f=s.depth,h=s.pos-1;f>0;f--,h--){let p=s.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;i.indexOf(f)>-1?l=f:s.before(f)==h&&i.splice(1,0,-f)}let a=i.indexOf(l),c=[],d=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=d-1;f>=0;f--){let h=c[f],p=$g(h.type);if(p&&!h.sameMarkup(s.node(Math.abs(l)-1)))d=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+d+1)%(r.openStart+1),p=c[h];if(p)for(let y=0;y<i.length;y++){let g=i[(y+a)%i.length],x=!0;g<0&&(x=!1,g=-g);let b=s.node(g-1),S=s.index(g-1);if(b.canReplaceWith(S,S,p.type,p.marks))return n.replace(s.before(g),x?o.after(g):t,new R(zd(r.content,0,r.openStart,h),h,r.openEnd))}}let u=n.steps.length;for(let f=i.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>u));f--){let h=i[f];h<0||(e=s.before(h),t=o.after(h))}}function zd(n,e,t,r,s){if(e<t){let o=n.firstChild;n=n.replaceChild(0,o.copy(zd(o.content,e+1,t,r,o)))}if(e>r){let o=s.contentMatchAt(0),i=o.fillBefore(n).append(n);n=i.append(o.matchFragment(i).fillBefore(E.empty,!0))}return n}function _g(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=Dg(n.doc,e,r.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new R(E.from(r),0,0))}function Bg(n,e,t){let r=n.doc.resolve(e),s=n.doc.resolve(t),o=_d(r,s);for(let i=0;i<o.length;i++){let l=o[i],a=i==o.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return n.delete(r.before(l),s.after(l))}for(let i=1;i<=r.depth&&i<=s.depth;i++)if(e-r.start(i)==r.depth-i&&t>r.end(i)&&s.end(i)-t!=s.depth-i&&r.start(i-1)==s.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),s.index(i-1)))return n.delete(r.before(i),t);n.delete(e,t)}function _d(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let s=r;s>=0;s--){let o=n.start(s);if(o<n.pos-(n.depth-s)||e.end(s)>e.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(o==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==o-1)&&t.push(s)}return t}class bn extends Ne{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return de.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let s=t.type.create(r,null,t.marks);return de.fromReplace(e,this.pos,this.pos+1,new R(E.from(s),0,t.isLeaf?0:1))}getMap(){return Re.empty}invert(e){return new bn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new bn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new bn(t.pos,t.attr,t.value)}}Ne.jsonID("attr",bn);class or extends Ne{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return de.ok(r)}getMap(){return Re.empty}invert(e){return new or(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new or(t.attr,t.value)}}Ne.jsonID("docAttr",or);let wn=class extends Error{};wn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};wn.prototype=Object.create(Error.prototype);wn.prototype.constructor=wn;wn.prototype.name="TransformError";class Bd{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new sr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new wn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=R.empty){let s=$s(this.doc,e,t,r);return s&&this.step(s),this}replaceWith(e,t,r){return this.replace(e,t,new R(E.from(r),0,0))}delete(e,t){return this.replace(e,t,R.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return zg(this,e,t,r),this}replaceRangeWith(e,t,r){return _g(this,e,t,r),this}deleteRange(e,t){return Bg(this,e,t),this}lift(e,t){return Cg(this,e,t),this}join(e,t=1){return jg(this,e,t),this}wrap(e,t){return Tg(this,e,t),this}setBlockType(e,t=e,r,s=null){return Mg(this,e,t,r,s),this}setNodeMarkup(e,t,r=null,s){return Og(this,e,t,r,s),this}setNodeAttribute(e,t,r){return this.step(new bn(e,t,r)),this}setDocAttribute(e,t){return this.step(new or(e,t)),this}addNodeMark(e,t){return this.step(new xt(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof Y)t.isInSet(r.marks)&&this.step(new Kt(e,t));else{let s=r.marks,o,i=[];for(;o=t.isInSet(s);)i.push(new Kt(e,o)),s=o.removeFromSet(s);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,t=1,r){return Ig(this,e,t,r),this}addMark(e,t,r){return Sg(this,e,t,r),this}removeMark(e,t,r){return wg(this,e,t,r),this}clearIncompatible(e,t,r){return Xi(this,e,t,r),this}}const bo=Object.create(null);class q{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Fg(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=R.empty){let r=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=r,r=r.lastChild;let o=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],d=e.mapping.slice(o);e.replaceRange(d.map(a.pos),d.map(c.pos),l?R.empty:t),l==0&&ha(e,o,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:i,$to:l}=s[o],a=e.mapping.slice(r),c=a.map(i.pos),d=a.map(l.pos);o?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),ha(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let s=e.parent.inlineContent?new F(e):pn(e.node(0),e.parent,e.pos,e.index(),t,r);if(s)return s;for(let o=e.depth-1;o>=0;o--){let i=t<0?pn(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):pn(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new je(e.node(0))}static atStart(e){return pn(e,e,0,0,1)||new je(e)}static atEnd(e){return pn(e,e,e.content.size,e.childCount,-1)||new je(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=bo[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in bo)throw new RangeError("Duplicate use of selection JSON ID "+e);return bo[e]=t,t.prototype.jsonID=e,t}getBookmark(){return F.between(this.$anchor,this.$head).getBookmark()}}q.prototype.visible=!0;class Fg{constructor(e,t){this.$from=e,this.$to=t}}let ua=!1;function fa(n){!ua&&!n.parent.inlineContent&&(ua=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class F extends q{constructor(e,t=e){fa(e),fa(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return q.near(r);let s=e.resolve(t.map(this.anchor));return new F(s.parent.inlineContent?s:r,r)}replace(e,t=R.empty){if(super.replace(e,t),t==R.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof F&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new zs(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new F(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let s=e.resolve(t);return new this(s,r==t?s:e.resolve(r))}static between(e,t,r){let s=e.pos-t.pos;if((!r||s)&&(r=s>=0?1:-1),!t.parent.inlineContent){let o=q.findFrom(t,r,!0)||q.findFrom(t,-r,!0);if(o)t=o.$head;else return q.near(t,r)}return e.parent.inlineContent||(s==0?e=t:(e=(q.findFrom(e,-r,!0)||q.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new F(e,t)}}q.jsonID("text",F);class zs{constructor(e,t){this.anchor=e,this.head=t}map(e){return new zs(e.map(this.anchor),e.map(this.head))}resolve(e){return F.between(e.resolve(this.anchor),e.resolve(this.head))}}class $ extends q{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:s}=t.mapResult(this.anchor),o=e.resolve(s);return r?q.near(o):new $(o)}content(){return new R(E.from(this.node),0,0)}eq(e){return e instanceof $&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Qi(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new $(e.resolve(t.anchor))}static create(e,t){return new $(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}$.prototype.visible=!1;q.jsonID("node",$);class Qi{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new zs(r,r):new Qi(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&$.isSelectable(r)?new $(t):q.near(t)}}class je extends q{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=R.empty){if(t==R.empty){e.delete(0,e.doc.content.size);let r=q.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new je(e)}map(e){return new je(e)}eq(e){return e instanceof je}getBookmark(){return Vg}}q.jsonID("all",je);const Vg={map(){return this},resolve(n){return new je(n)}};function pn(n,e,t,r,s,o=!1){if(e.inlineContent)return F.create(n,t);for(let i=r-(s>0?0:1);s>0?i<e.childCount:i>=0;i+=s){let l=e.child(i);if(l.isAtom){if(!o&&$.isSelectable(l))return $.create(n,t-(s<0?l.nodeSize:0))}else{let a=pn(n,l,t+s,s<0?l.childCount:0,s,o);if(a)return a}t+=l.nodeSize*s}return null}function ha(n,e,t){let r=n.steps.length-1;if(r<e)return;let s=n.steps[r];if(!(s instanceof he||s instanceof ge))return;let o=n.mapping.maps[r],i;o.forEach((l,a,c,d)=>{i==null&&(i=d)}),n.setSelection(q.near(n.doc.resolve(i),t))}const pa=1,vr=2,ma=4;class Hg extends Bd{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|pa)&~vr,this.storedMarks=null,this}get selectionSet(){return(this.updated&pa)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=vr,this}ensureMarks(e){return Y.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&vr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~vr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Y.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let i=this.doc.resolve(t);o=r==t?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,s.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(q.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=ma,this}get scrolledIntoView(){return(this.updated&ma)>0}}function ga(n,e){return!e||!n?n:n.bind(e)}class Hn{constructor(e,t,r){this.name=e,this.init=ga(t.init,r),this.apply=ga(t.apply,r)}}const Wg=[new Hn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Hn("selection",{init(n,e){return n.selection||q.atStart(e.doc)},apply(n){return n.selection}}),new Hn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Hn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class ko{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Wg.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Hn(r.key,r.spec.state,r))})}}class xn{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),s=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=s?s[i].n:0,c=s?s[i].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(d&&r.filterTransaction(d,i)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<i?{state:r,n:t.length}:{state:this,n:0})}t.push(d),r=r.applyInner(d),o=!0}s&&(s[i]={state:r,n:t.length})}}if(!o)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new xn(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let o=r[s];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new Hg(this)}static create(e){let t=new ko(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new xn(t);for(let s=0;s<t.fields.length;s++)r[t.fields[s].name]=t.fields[s].init(e,r);return r}reconfigure(e){let t=new ko(this.schema,e.plugins),r=t.fields,s=new xn(t);for(let o=0;o<r.length;o++){let i=r[o].name;s[i]=this.hasOwnProperty(i)?this[i]:r[o].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],o=s.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new ko(e.schema,e.plugins),o=new xn(s);return s.fields.forEach(i=>{if(i.name=="doc")o.doc=ze.fromJSON(e.schema,t.doc);else if(i.name=="selection")o.selection=q.fromJSON(o.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[i.name]=c.fromJSON.call(a,e,t[l],o);return}}o[i.name]=i.init(e,o)}}),o}}function Fd(n,e,t){for(let r in n){let s=n[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Fd(s,e,{})),t[r]=s}return t}class re{constructor(e){this.spec=e,this.props={},e.props&&Fd(e.props,this,this.props),this.key=e.key?e.key.key:Vd("plugin")}getState(e){return e[this.key]}}const So=Object.create(null);function Vd(n){return n in So?n+"$"+ ++So[n]:(So[n]=0,n+"$")}class ae{constructor(e="key"){this.key=Vd(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Zi=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Hd(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Wd=(n,e,t)=>{let r=Hd(n,t);if(!r)return!1;let s=el(r);if(!s){let i=r.blockRange(),l=i&&Ln(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let o=s.nodeBefore;if(Zd(n,s,e,-1))return!0;if(r.parent.content.size==0&&(vn(o,"end")||$.isSelectable(o)))for(let i=r.depth;;i--){let l=$s(n.doc,r.before(i),r.after(i),R.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(vn(o,"end")?q.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):$.create(a.doc,s.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}return o.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos-o.nodeSize,s.pos).scrollIntoView()),!0):!1},qg=(n,e,t)=>{let r=Hd(n,t);if(!r)return!1;let s=el(r);return s?qd(n,s,e):!1},Ug=(n,e,t)=>{let r=Kd(n,t);if(!r)return!1;let s=tl(r);return s?qd(n,s,e):!1};function qd(n,e,t){let r=e.nodeBefore,s=r,o=e.pos-1;for(;!s.isTextblock;o--){if(s.type.spec.isolating)return!1;let d=s.lastChild;if(!d)return!1;s=d}let i=e.nodeAfter,l=i,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=$s(n.doc,o,a,R.empty);if(!c||c.from!=o||c instanceof he&&c.slice.size>=a-o)return!1;if(t){let d=n.tr.step(c);d.setSelection(F.create(d.doc,o)),t(d.scrollIntoView())}return!0}function vn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Ud=(n,e,t)=>{let{$head:r,empty:s}=n.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;o=el(r)}let i=o&&o.nodeBefore;return!i||!$.isSelectable(i)?!1:(e&&e(n.tr.setSelection($.create(n.doc,o.pos-i.nodeSize)).scrollIntoView()),!0)};function el(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Kd(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Jd=(n,e,t)=>{let r=Kd(n,t);if(!r)return!1;let s=tl(r);if(!s)return!1;let o=s.nodeAfter;if(Zd(n,s,e,1))return!0;if(r.parent.content.size==0&&(vn(o,"start")||$.isSelectable(o))){let i=$s(n.doc,r.before(),r.after(),R.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(vn(o,"start")?q.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):$.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+o.nodeSize).scrollIntoView()),!0):!1},Gd=(n,e,t)=>{let{$head:r,empty:s}=n.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;o=tl(r)}let i=o&&o.nodeAfter;return!i||!$.isSelectable(i)?!1:(e&&e(n.tr.setSelection($.create(n.doc,o.pos)).scrollIntoView()),!0)};function tl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Kg=(n,e)=>{let t=n.selection,r=t instanceof $,s;if(r){if(t.node.isTextblock||!Mt(n.doc,t.from))return!1;s=t.from}else if(s=Ls(n.doc,t.from,-1),s==null)return!1;if(e){let o=n.tr.join(s);r&&o.setSelection($.create(o.doc,s-n.doc.resolve(s).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},Jg=(n,e)=>{let t=n.selection,r;if(t instanceof $){if(t.node.isTextblock||!Mt(n.doc,t.to))return!1;r=t.to}else if(r=Ls(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Gg=(n,e)=>{let{$from:t,$to:r}=n.selection,s=t.blockRange(r),o=s&&Ln(s);return o==null?!1:(e&&e(n.tr.lift(s,o).scrollIntoView()),!0)},Xd=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
12
|
-
`).scrollIntoView()),!0)};function nl(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Xg=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let s=t.node(-1),o=t.indexAfter(-1),i=nl(s.contentMatchAt(o));if(!i||!s.canReplaceWith(o,o,i))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,i.createAndFill());a.setSelection(q.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Yd=(n,e)=>{let t=n.selection,{$from:r,$to:s}=t;if(t instanceof je||r.parent.inlineContent||s.parent.inlineContent)return!1;let o=nl(s.parent.contentMatchAt(s.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let i=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=n.tr.insert(i,o.createAndFill());l.setSelection(F.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},Qd=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(ot(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),s=r&&Ln(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)};function Yg(n){return(e,t)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof $&&e.selection.node.isBlock)return!r.parentOffset||!ot(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],i,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=nl(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),o.unshift(a&&l?{type:l}:null),i=h;break}else{if(h==1)return!1;o.unshift(null)}let d=e.tr;(e.selection instanceof F||e.selection instanceof je)&&d.deleteSelection();let u=d.mapping.map(r.pos),f=ot(d.doc,u,o.length,o);if(f||(o[0]=l?{type:l}:null,f=ot(d.doc,u,o.length,o)),!f)return!1;if(d.split(u,o.length,o),!a&&c&&r.node(i).type!=l){let h=d.mapping.map(r.before(i)),p=d.doc.resolve(h);l&&r.node(i-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(i)),l)}return t&&t(d.scrollIntoView()),!0}}const Qg=Yg(),Zg=(n,e)=>{let{$from:t,to:r}=n.selection,s,o=t.sharedDepth(r);return o==0?!1:(s=t.before(o),e&&e(n.tr.setSelection($.create(n.doc,s))),!0)};function e1(n,e,t){let r=e.nodeBefore,s=e.nodeAfter,o=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(s.isTextblock||Mt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Zd(n,e,t,r){let s=e.nodeBefore,o=e.nodeAfter,i,l,a=s.type.spec.isolating||o.type.spec.isolating;if(!a&&e1(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&l.matchType(i[0]||o.type).validEnd){if(t){let h=e.pos+o.nodeSize,p=E.empty;for(let x=i.length-1;x>=0;x--)p=E.from(i[x].create(null,p));p=E.from(s.copy(p));let y=n.tr.step(new ge(e.pos-1,h,e.pos,h,new R(p,1,0),i.length,!0)),g=y.doc.resolve(h+2*i.length);g.nodeAfter&&g.nodeAfter.type==s.type&&Mt(y.doc,g.pos)&&y.join(g.pos),t(y.scrollIntoView())}return!0}let d=o.type.spec.isolating||r>0&&a?null:q.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),f=u&&Ln(u);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(u,f).scrollIntoView()),!0;if(c&&vn(o,"start",!0)&&vn(s,"end")){let h=s,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let y=o,g=1;for(;!y.isTextblock;y=y.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,y.content)){if(t){let x=E.empty;for(let S=p.length-1;S>=0;S--)x=E.from(p[S].copy(x));let b=n.tr.step(new ge(e.pos-p.length,e.pos+o.nodeSize,e.pos+g,e.pos+o.nodeSize-g,new R(x,p.length,0),0,!0));t(b.scrollIntoView())}return!0}}return!1}function eu(n){return function(e,t){let r=e.selection,s=n<0?r.$from:r.$to,o=s.depth;for(;s.node(o).isInline;){if(!o)return!1;o--}return s.node(o).isTextblock?(t&&t(e.tr.setSelection(F.create(e.doc,n<0?s.start(o):s.end(o)))),!0):!1}}const t1=eu(-1),n1=eu(1);function r1(n,e=null){return function(t,r){let{$from:s,$to:o}=t.selection,i=s.blockRange(o),l=i&&Yi(i,n,e);return l?(r&&r(t.tr.wrap(i,l).scrollIntoView()),!0):!1}}function ya(n,e=null){return function(t,r){let s=!1;for(let o=0;o<t.selection.ranges.length&&!s;o++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[o];t.doc.nodesBetween(i,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)s=!0;else{let d=t.doc.resolve(c),u=d.index();s=d.parent.canReplaceWith(u,u+1,n)}})}if(!s)return!1;if(r){let o=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];o.setBlockType(l,a,n,e)}r(o.scrollIntoView())}return!0}}function rl(...n){return function(e,t,r){for(let s=0;s<n.length;s++)if(n[s](e,t,r))return!0;return!1}}rl(Zi,Wd,Ud);rl(Zi,Jd,Gd);rl(Xd,Yd,Qd,Qg);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function s1(n,e=null){return function(t,r){let{$from:s,$to:o}=t.selection,i=s.blockRange(o);if(!i)return!1;let l=r?t.tr:null;return o1(l,i,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function o1(n,e,t,r=null){let s=!1,o=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=i.resolve(e.start-2);o=new Wr(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Wr(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=Yi(o,t,r,e);return l?(n&&i1(n,e,l,s,t),!0):!1}function i1(n,e,t,r,s){let o=E.empty;for(let d=t.length-1;d>=0;d--)o=E.from(t[d].type.create(t[d].attrs,o));n.step(new ge(e.start-(r?2:0),e.end,e.start,e.end,new R(o,0,0),t.length,!0));let i=0;for(let d=0;d<t.length;d++)t[d].type==s&&(i=d+1);let l=t.length-i,a=e.start+t.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,f=!0;d<u;d++,f=!1)!f&&ot(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function l1(n){return function(e,t){let{$from:r,$to:s}=e.selection,o=r.blockRange(s,i=>i.childCount>0&&i.firstChild.type==n);return o?t?r.node(o.depth-1).type==n?a1(e,t,n,o):c1(e,t,o):!0:!1}}function a1(n,e,t,r){let s=n.tr,o=r.end,i=r.$to.end(r.depth);o<i&&(s.step(new ge(o-1,i,o,i,new R(E.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new Wr(s.doc.resolve(r.$from.pos),s.doc.resolve(i),r.depth));const l=Ln(r);if(l==null)return!1;s.lift(r,l);let a=s.doc.resolve(s.mapping.map(o,-1)-1);return Mt(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function c1(n,e,t){let r=n.tr,s=t.parent;for(let h=t.end,p=t.endIndex-1,y=t.startIndex;p>y;p--)h-=s.child(p).nodeSize,r.delete(h-1,h+1);let o=r.doc.resolve(t.start),i=o.nodeAfter;if(r.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=o.node(-1),d=o.index(-1);if(!c.canReplace(d+(l?0:1),d+1,i.content.append(a?E.empty:E.from(s))))return!1;let u=o.pos,f=u+i.nodeSize;return r.step(new ge(u-(l?1:0),f+(a?1:0),u+1,f-1,new R((l?E.empty:E.from(s.copy(E.empty))).append(a?E.empty:E.from(s.copy(E.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function d1(n){return function(e,t){let{$from:r,$to:s}=e.selection,o=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!o)return!1;let i=o.startIndex;if(i==0)return!1;let l=o.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=E.from(c?n.create():null),u=new R(E.from(n.create(null,E.from(l.type.create(null,d)))),c?3:1,0),f=o.start,h=o.end;t(e.tr.step(new ge(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}const be=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Cn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Yo=null;const rt=function(n,e,t){let r=Yo||(Yo=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},u1=function(){Yo=null},Jt=function(n,e,t,r){return t&&(xa(n,e,t,r,-1)||xa(n,e,t,r,1))},f1=/^(img|br|input|textarea|hr)$/i;function xa(n,e,t,r,s){for(var o;;){if(n==t&&e==r)return!0;if(e==(s<0?0:$e(n))){let i=n.parentNode;if(!i||i.nodeType!=1||mr(n)||f1.test(n.nodeName)||n.contentEditable=="false")return!1;e=be(n)+(s<0?0:1),n=i}else if(n.nodeType==1){let i=n.childNodes[e+(s<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((o=i.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=s;else return!1;else n=i,e=s<0?$e(n):0}else return!1}}function $e(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function h1(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=$e(n)}else if(n.parentNode&&!mr(n))e=be(n),n=n.parentNode;else return null}}function p1(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!mr(n))e=be(n)+1,n=n.parentNode;else return null}}function m1(n,e,t){for(let r=e==0,s=e==$e(n);r||s;){if(n==t)return!0;let o=be(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,s=s&&o==$e(n)}}function mr(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const _s=function(n){return n.focusNode&&Jt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function It(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function g1(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function y1(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min($e(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min($e(r.startContainer),r.startOffset)}}}const Ye=typeof navigator<"u"?navigator:null,ba=typeof document<"u"?document:null,At=Ye&&Ye.userAgent||"",Qo=/Edge\/(\d+)/.exec(At),tu=/MSIE \d/.exec(At),Zo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(At),Oe=!!(tu||Zo||Qo),St=tu?document.documentMode:Zo?+Zo[1]:Qo?+Qo[1]:0,_e=!Oe&&/gecko\/(\d+)/i.test(At);_e&&+(/Firefox\/(\d+)/.exec(At)||[0,0])[1];const ei=!Oe&&/Chrome\/(\d+)/.exec(At),pe=!!ei,nu=ei?+ei[1]:0,Ce=!Oe&&!!Ye&&/Apple Computer/.test(Ye.vendor),Nn=Ce&&(/Mobile\/\w+/.test(At)||!!Ye&&Ye.maxTouchPoints>2),Le=Nn||(Ye?/Mac/.test(Ye.platform):!1),ru=Ye?/Win/.test(Ye.platform):!1,st=/Android \d/.test(At),gr=!!ba&&"webkitFontSmoothing"in ba.documentElement.style,x1=gr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function b1(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Ze(n,e){return typeof n=="number"?n:n[e]}function k1(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function ka(n,e,t){let r=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let i=t||n.dom;i;){if(i.nodeType!=1){i=Cn(i);continue}let l=i,a=l==o.body,c=a?b1(o):k1(l),d=0,u=0;if(e.top<c.top+Ze(r,"top")?u=-(c.top-e.top+Ze(s,"top")):e.bottom>c.bottom-Ze(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+Ze(s,"top")-c.top:e.bottom-c.bottom+Ze(s,"bottom")),e.left<c.left+Ze(r,"left")?d=-(c.left-e.left+Ze(s,"left")):e.right>c.right-Ze(r,"right")&&(d=e.right-c.right+Ze(s,"right")),d||u)if(a)o.defaultView.scrollBy(d,u);else{let h=l.scrollLeft,p=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let y=l.scrollLeft-h,g=l.scrollTop-p;e={left:e.left-y,top:e.top-g,right:e.right-y,bottom:e.bottom-g}}let f=a?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(f))break;i=f=="absolute"?i.offsetParent:Cn(i)}}function S1(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,s;for(let o=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(o,i);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:su(n.dom)}}function su(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Cn(r));return e}function w1({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;ou(t,r==0?0:r-e)}function ou(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:s,left:o}=n[t];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let fn=null;function v1(n){if(n.setActive)return n.setActive();if(fn)return n.focus(fn);let e=su(n);n.focus(fn==null?{get preventScroll(){return fn={preventScroll:!0},!0}}:void 0),fn||(fn=!1,ou(e,0))}function iu(n,e){let t,r=2e8,s,o=0,i=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let f;if(d.nodeType==1)f=d.getClientRects();else if(d.nodeType==3)f=rt(d).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=i&&p.bottom>=l){i=Math.max(p.bottom,i),l=Math.min(p.top,l);let y=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(y<r){t=d,r=y,s=y&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&y&&(o=u+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(o=u+1)}}return!t&&a&&(t=a,s=c,r=0),t&&t.nodeType==3?C1(t,s):!t||r&&t.nodeType==1?{node:n,offset:o}:iu(t,s)}function C1(n,e){let t=n.nodeValue.length,r=document.createRange(),s;for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let i=ut(r,1);if(i.top!=i.bottom&&sl(e,i)){s={node:n,offset:o+(e.left>=(i.left+i.right)/2?1:0)};break}}return r.detach(),s||{node:n,offset:0}}function sl(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function N1(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function E1(n,e,t){let{node:r,offset:s}=iu(e,t),o=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();o=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(r,s,o)}function T1(n,e,t,r){let s=-1;for(let o=e,i=!1;o!=n.dom;){let l=n.docView.nearestDesc(o,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!i&&a.left>r.left||a.top>r.top?s=l.posBefore:(!i&&a.right<r.left||a.bottom<r.top)&&(s=l.posAfter),i=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function lu(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),o=s;;){let i=n.childNodes[o];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(sl(e,c))return lu(i,e,c)}}if((o=(o+1)%r)==s)break}return n}function M1(n,e){let t=n.dom.ownerDocument,r,s=0,o=y1(t,e.left,e.top);o&&({node:r,offset:s}=o);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!sl(e,c)||(i=lu(n.dom,e,c),!i))return null}if(Ce)for(let c=i;r&&c;c=Cn(c))c.draggable&&(r=void 0);if(i=N1(i,e),r){if(_e&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let d=r.childNodes[s],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&s++}let c;gr&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==n.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=T1(n,r,s,e))}l==null&&(l=E1(n,i,e));let a=n.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Sa(n){return n.top<n.bottom||n.left<n.right}function ut(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Sa(r))return r}return Array.prototype.find.call(t,Sa)||n.getBoundingClientRect()}const A1=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function au(n,e,t){let{node:r,offset:s,atom:o}=n.docView.domFromPos(e,t<0?-1:1),i=gr||_e;if(r.nodeType==3)if(i&&(A1.test(r.nodeValue)||(t<0?!s:s==r.nodeValue.length))){let a=ut(rt(r,s,s),t);if(_e&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=ut(rt(r,s-1,s-1),-1);if(c.top==a.top){let d=ut(rt(r,s,s+1),-1);if(d.top!=a.top)return _n(d,d.left<c.left)}}return a}else{let a=s,c=s,d=t<0?1:-1;return t<0&&!s?(c++,d=-1):t>=0&&s==r.nodeValue.length?(a--,d=1):t<0?a--:c++,_n(ut(rt(r,a,c),d),d<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&s&&(t<0||s==$e(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return wo(a.getBoundingClientRect(),!1)}if(o==null&&s<$e(r)){let a=r.childNodes[s];if(a.nodeType==1)return wo(a.getBoundingClientRect(),!0)}return wo(r.getBoundingClientRect(),t>=0)}if(o==null&&s&&(t<0||s==$e(r))){let a=r.childNodes[s-1],c=a.nodeType==3?rt(a,$e(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return _n(ut(c,1),!1)}if(o==null&&s<$e(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?rt(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return _n(ut(c,-1),!0)}return _n(ut(r.nodeType==3?rt(r):r,-t),t>=0)}function _n(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function wo(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function cu(n,e,t){let r=n.state,s=n.root.activeElement;r!=e&&n.updateState(e),s!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),s!=n.dom&&s&&s.focus()}}function O1(n,e,t){let r=e.selection,s=t=="up"?r.$from:r.$to;return cu(n,e,()=>{let{node:o}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let i=au(n,s.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=rt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?i.top-d.top>(d.bottom-i.top)*2:d.bottom-i.bottom>(i.bottom-d.top)*2))return!1}}return!0})}const I1=/[\u0590-\u08ac]/;function R1(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,o=!s,i=s==r.parent.content.size,l=n.domSelection();return l?!I1.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:i:cu(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:y}=n.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==y;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}let wa=null,va=null,Ca=!1;function j1(n,e,t){return wa==e&&va==t?Ca:(wa=e,va=t,Ca=t=="up"||t=="down"?O1(n,e,t):R1(n,e,t))}const Be=0,Na=1,Rt=2,Qe=3;class yr{constructor(e,t,r,s){this.parent=e,this.children=t,this.dom=r,this.contentDOM=s,this.dirty=Be,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let s=this.children[t];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let o,i;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(i)+i.size:this.posAtStart}else{let o,i;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(i):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>be(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!1;break}if(o.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!0;break}if(o.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,s=e;s;s=s.parentNode){let o=this.getDesc(s),i;if(o&&(!t||o.node))if(r&&(i=o.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let s=e;s;s=s.parentNode){let o=this.getDesc(s);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let s=this.children[t],o=r+s.size;if(r==e&&o!=r){for(;!s.border&&s.children.length;)for(let i=0;i<s.children.length;i++){let l=s.children[i];if(l.size){s=l;break}}return s}if(e<o)return s.descAt(e-r-s.border);r=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let o=0;r<this.children.length;r++){let i=this.children[r],l=o+i.size;if(l>e||i instanceof uu){s=e-o;break}o=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof du&&o.side>=0;r--);if(t<=0){let o,i=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,i=!1);return o&&t&&i&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?be(o.dom)+1:0}}else{let o,i=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,i=!1);return o&&i&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?be(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,o=-1;for(let i=r,l=0;;l++){let a=this.children[l],c=i+a.size;if(s==-1&&e<=c){let d=i+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=i;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=be(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){o=be(u.dom);break}t+=u.size}o==-1&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,s=!1){let o=Math.min(e,t),i=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let y=this.children[h],g=p+y.size;if(o>p&&i<g)return y.setSelection(e-p-y.border,t-p-y.border,r,s);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if((_e||Ce)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(u=!!(p&&h.nodeValue[p-1]==`
|
|
13
|
-
`),u&&p==h.nodeValue.length)for(let y=h,g;y;y=y.parentNode){if(g=y.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:be(g)+1});break}let x=y.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let y=h.childNodes[p-1];u=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(_e&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||u&&Ce)&&Jt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Jt(a.node,a.offset,d.focusNode,d.focusOffset))return;let f=!1;if((c.extend||e==t)&&!(u&&_e)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,s=0;s<this.children.length;s++){let o=this.children[s],i=r+o.size;if(r==i?e<=i&&t>=r:e<i&&t>r){let l=r+o.border,a=i-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==i?Rt:Na,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Qe:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Rt:Qe}r=i}this.dirty=Rt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Rt:Na;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class du extends yr{constructor(e,t,r,s){let o,i=t.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==Be&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class D1 extends yr{constructor(e,t,r,s){super(e,[],t,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Gt extends yr{constructor(e,t,r,s,o){super(e,[],r,s),this.mark=t,this.spec=o}static create(e,t,r,s){let o=s.nodeViews[t.type.name],i=o&&o(t,s,r);return(!i||!i.dom)&&(i=Qt.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Gt(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&Qe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Qe&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Be){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Be}}slice(e,t,r){let s=Gt.create(this.parent,this.mark,!0,r),o=this.children,i=this.size;t<i&&(o=ni(o,t,i,r)),e>0&&(o=ni(o,0,e,r));for(let l=0;l<o.length;l++)o[l].parent=s;return s.children=o,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class wt extends yr{constructor(e,t,r,s,o,i,l,a,c){super(e,[],o,i),this.node=t,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,t,r,s,o,i){let l=o.nodeViews[t.type.name],a,c=l&&l(t,o,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},r,s),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Qt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=pu(d,r,t),c?a=new P1(e,t,r,s,d,u||null,f,c,o,i+1):t.isText?new Bs(e,t,r,s,d,f,o):new wt(e,t,r,s,d,u||null,f,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>E.empty)}return e}matchesNode(e,t,r){return this.dirty==Be&&e.eq(this.node)&&Ur(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,s=t,o=e.composing?this.localCompositionInfo(e,t):null,i=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new $1(this,i&&i.node,e);B1(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?Y.none:this.node.child(d).marks,r,e),a.placeWidget(c,e,s)},(c,d,u,f)=>{a.syncToMarks(c.marks,r,e);let h;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,f,s)||a.addNode(c,d,u,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Rt)&&(i&&this.protectLocalComposition(e,i),fu(this.contentDOM,this.children,e),Nn&&F1(this.dom))}localCompositionInfo(e,t){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof F)||r<t||s>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let i=o.nodeValue,l=V1(this.node.content,i,r-t,s-t);return l<0?null:{node:o,pos:l,text:i}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:s}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new D1(this,o,t,s);e.input.compositionNodes.push(i),this.children=ni(this.children,r,r+s.length,e,i)}update(e,t,r,s){return this.dirty==Qe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,s),!0)}updateInner(e,t,r,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=Be}updateOuterDeco(e){if(Ur(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=hu(this.dom,this.nodeDOM,ti(this.outerDeco,this.node,t),ti(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Ea(n,e,t,r,s){pu(r,e,n);let o=new wt(void 0,n,e,t,r,r,r,s,0);return o.contentDOM&&o.updateChildren(s,0),o}class Bs extends wt{constructor(e,t,r,s,o,i,l){super(e,t,r,s,o,null,i,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,s){return this.dirty==Qe||this.dirty!=Be&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Be||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=Be,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let s=this.node.cut(e,t),o=document.createTextNode(s.text);return new Bs(this.parent,s,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Qe)}get domAtom(){return!1}isText(e){return this.node.text==e}}class uu extends yr{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Be&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class P1 extends wt{constructor(e,t,r,s,o,i,l,a,c,d){super(e,t,r,s,o,i,l,c,d),this.spec=a}update(e,t,r,s){if(this.dirty==Qe)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,s),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,s){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function fu(n,e,t){let r=n.firstChild,s=!1;for(let o=0;o<e.length;o++){let i=e[o],l=i.dom;if(l.parentNode==n){for(;l!=r;)r=Ta(r),s=!0;r=r.nextSibling}else s=!0,n.insertBefore(l,r);if(i instanceof Gt){let a=r?r.previousSibling:n.lastChild;fu(i.contentDOM,i.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Ta(r),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const Kn=function(n){n&&(this.nodeName=n)};Kn.prototype=Object.create(null);const jt=[new Kn];function ti(n,e,t){if(n.length==0)return jt;let r=t?jt[0]:new Kn,s=[r];for(let o=0;o<n.length;o++){let i=n[o].type.attrs;if(i){i.nodeName&&s.push(r=new Kn(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&s.length==1&&s.push(r=new Kn(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return s}function hu(n,e,t,r){if(t==jt&&r==jt)return e;let s=e;for(let o=0;o<r.length;o++){let i=r[o],l=t[o];if(o){let a;l&&l.nodeName==i.nodeName&&s!=n&&(a=s.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=jt[0]),s=a}L1(s,l||jt[0],i)}return s}function L1(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)s.indexOf(r[o])==-1&&n.classList.remove(r[o]);for(let o=0;o<s.length;o++)r.indexOf(s[o])==-1&&n.classList.add(s[o]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function pu(n,e,t){return hu(n,n,jt,ti(e,t,n.nodeType!=1))}function Ur(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Ta(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class $1{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=z1(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let s=0,o=this.stack.length>>1,i=Math.min(o,e.length);for(;s<i&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=Be,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[o])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Gt.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,s){let o=-1,i;if(s>=this.preMatch.index&&(i=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,r))o=this.top.children.indexOf(i,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,r,s,o){let i=this.top.children[s];return i.dirty==Qe&&i.dom==i.contentDOM&&(i.dirty=Rt),i.update(e,t,r,o)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=t}}updateNextNode(e,t,r,s,o,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof wt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let d=a.dom,u,f=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Qe&&Ur(t,a.outerDeco));if(!f&&a.update(e,t,r,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(u=this.recreateWrapper(a,e,t,r,s,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=Rt,u.updateChildren(s,i+1),u.dirty=Be),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,s,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Ur(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=wt.create(this.top,t,r,s,o,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,s,o){let i=wt.create(this.top,e,t,r,s,o);i.contentDOM&&i.updateChildren(s,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let o=new du(this.top,e,t,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Gt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Bs)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ce||pe)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new uu(this.top,[],r,null);t!=this.top?t.children.push(s):t.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function z1(n,e){let t=e,r=t.children.length,s=n.childCount,o=new Map,i=[];e:for(;s>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof Gt)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(s-1))break;--s,o.set(l,s),i.push(l)}}return{index:s,matched:o,matches:i.reverse()}}function _1(n,e){return n.type.side-e.type.side}function B1(n,e,t,r){let s=e.locals(n),o=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);r(d,s,e.forChild(o,d),c),o+=d.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let d,u;for(;i<s.length&&s[i].to==o;){let g=s[i++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(_1);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<n.childCount)h=c,f=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=o&&l.splice(g--,1);for(;i<s.length&&s[i].from<=o&&s[i].to>o;)l.push(s[i++]);let p=o+f.nodeSize;if(f.isText){let g=p;i<s.length&&s[i].from<g&&(g=s[i].from);for(let x=0;x<l.length;x++)l[x].to<g&&(g=l[x].to);g<p&&(a=f.cut(g-o),f=f.cut(0,g-o),p=g,h=-1)}else for(;i<s.length&&s[i].to<p;)i++;let y=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();r(f,y,e.forChild(o,f),h),o=p}}function F1(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function V1(n,e,t,r){for(let s=0,o=0;s<n.childCount&&o<=r;){let i=n.child(s++),l=o;if(o+=i.nodeSize,!i.isText)continue;let a=i.text;for(;s<n.childCount;){let c=n.child(s++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=t){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function ni(n,e,t,r,s){let o=[];for(let i=0,l=0;i<n.length;i++){let a=n[i],c=l,d=l+=a.size;c>=t||d<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,r)),s&&(o.push(s),s=void 0),d>t&&o.push(a.slice(t-c,a.size,r)))}return o}function ol(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),o=s&&s.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(_s(t)){for(a=i;s&&!s.node;)s=s.parent;let u=s.node;if(s&&u.isAtom&&$.isSelectable(u)&&s.parent&&!(u.isInline&&m1(t.focusNode,t.focusOffset,s.dom))){let f=s.posBefore;c=new $(i==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=i,f=i;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);u=Math.min(u,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,i]=f==n.state.selection.anchor?[f,u]:[u,f],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!o?1:-1;c=il(n,d,l,u)}return c}function mu(n){return n.editable?n.hasFocus():yu(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function it(n,e=!1){let t=n.state.selection;if(gu(n,t),!!mu(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&pe){let r=n.domSelectionRange(),s=n.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Jt(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)W1(n);else{let{anchor:r,head:s}=t,o,i;Ma&&!(t instanceof F)&&(t.$from.parent.inlineContent||(o=Aa(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=Aa(n,t.to))),n.docView.setSelection(r,s,n,e),Ma&&(o&&Oa(o),i&&Oa(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&H1(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Ma=Ce||pe&&nu<63;function Aa(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),s=r<t.childNodes.length?t.childNodes[r]:null,o=r?t.childNodes[r-1]:null;if(Ce&&s&&s.contentEditable=="false")return vo(s);if((!s||s.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(s)return vo(s);if(o)return vo(o)}}function vo(n){return n.contentEditable="true",Ce&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Oa(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function H1(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!mu(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function W1(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,be(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&Oe&&St<=11&&(t.disabled=!0,t.disabled=!1)}function gu(n,e){if(e instanceof $){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Ia(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Ia(n)}function Ia(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function il(n,e,t,r){return n.someProp("createSelectionBetween",s=>s(n,e,t))||F.between(e,t,r)}function Ra(n){return n.editable&&!n.hasFocus()?!1:yu(n)}function yu(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function q1(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Jt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function ri(n,e){let{$anchor:t,$head:r}=n.selection,s=e>0?t.max(r):t.min(r),o=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return o&&q.findFrom(o,e)}function ft(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function ja(n,e,t){let r=n.state.selection;if(r instanceof F)if(t.indexOf("s")>-1){let{$head:s}=r,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=n.state.doc.resolve(s.pos+o.nodeSize*(e<0?-1:1));return ft(n,new F(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=ri(n.state,e);return s&&s instanceof $?ft(n,s):!1}else if(!(Le&&t.indexOf("m")>-1)){let s=r.$head,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,i;if(!o||o.isText)return!1;let l=e<0?s.pos-o.nodeSize:s.pos;return o.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?$.isSelectable(o)?ft(n,new $(e<0?n.state.doc.resolve(s.pos-o.nodeSize):s)):gr?ft(n,new F(n.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof $&&r.node.isInline)return ft(n,new F(e>0?r.$to:r.$from));{let s=ri(n.state,e);return s?ft(n,s):!1}}}function Kr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Jn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function hn(n,e){return e<0?U1(n):K1(n)}function U1(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s,o,i=!1;for(_e&&t.nodeType==1&&r<Kr(t)&&Jn(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Jn(l,-1))s=t,o=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(xu(t))break;{let l=t.previousSibling;for(;l&&Jn(l,-1);)s=t.parentNode,o=be(l),l=l.previousSibling;if(l)t=l,r=Kr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?si(n,t,r):s&&si(n,s,o)}function K1(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s=Kr(t),o,i;for(;;)if(r<s){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Jn(l,1))o=t,i=++r;else break}else{if(xu(t))break;{let l=t.nextSibling;for(;l&&Jn(l,1);)o=l.parentNode,i=be(l)+1,l=l.nextSibling;if(l)t=l,r=0,s=Kr(t);else{if(t=t.parentNode,t==n.dom)break;r=s=0}}}o&&si(n,o,i)}function xu(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function J1(n,e){for(;n&&e==n.childNodes.length&&!mr(n);)e=be(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function G1(n,e){for(;n&&!e&&!mr(n);)e=be(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function si(n,e,t){if(e.nodeType!=3){let o,i;(i=J1(e,t))?(e=i,t=0):(o=G1(e,t))&&(e=o,t=o.nodeValue.length)}let r=n.domSelection();if(!r)return;if(_s(r)){let o=document.createRange();o.setEnd(e,t),o.setStart(e,t),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&it(n)},50)}function Da(n,e){let t=n.state.doc.resolve(e);if(!(pe||ru)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left<s.left?"ltr":"rtl"}if(e<t.end()){let o=n.coordsAtPos(e+1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Pa(n,e,t){let r=n.state.selection;if(r instanceof F&&!r.empty||t.indexOf("s")>-1||Le&&t.indexOf("m")>-1)return!1;let{$from:s,$to:o}=r;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=ri(n.state,e);if(i&&i instanceof $)return ft(n,i)}if(!s.parent.inlineContent){let i=e<0?s:o,l=r instanceof je?q.near(i,e):q.findFrom(i,e);return l?ft(n,l):!1}return!1}function La(n,e){if(!(n.state.selection instanceof F))return!0;let{$head:t,$anchor:r,empty:s}=n.state.selection;if(!t.sameParent(r))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let i=n.state.tr;return e<0?i.delete(t.pos-o.nodeSize,t.pos):i.delete(t.pos,t.pos+o.nodeSize),n.dispatch(i),!0}return!1}function $a(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function X1(n){if(!Ce||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;$a(n,r,"true"),setTimeout(()=>$a(n,r,"false"),20)}return!1}function Y1(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Q1(n,e){let t=e.keyCode,r=Y1(e);if(t==8||Le&&t==72&&r=="c")return La(n,-1)||hn(n,-1);if(t==46&&!e.shiftKey||Le&&t==68&&r=="c")return La(n,1)||hn(n,1);if(t==13||t==27)return!0;if(t==37||Le&&t==66&&r=="c"){let s=t==37?Da(n,n.state.selection.from)=="ltr"?-1:1:-1;return ja(n,s,r)||hn(n,s)}else if(t==39||Le&&t==70&&r=="c"){let s=t==39?Da(n,n.state.selection.from)=="ltr"?1:-1:1;return ja(n,s,r)||hn(n,s)}else{if(t==38||Le&&t==80&&r=="c")return Pa(n,-1,r)||hn(n,-1);if(t==40||Le&&t==78&&r=="c")return X1(n)||Pa(n,1,r)||hn(n,1);if(r==(Le?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function ll(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:s,openEnd:o}=e;for(;s>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,o--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=n.someProp("clipboardSerializer")||Qt.fromSchema(n.state.schema),l=Cu(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=vu[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let p=l.createElement(d[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${o}${u?` -${u}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
7
|
+
${n.trimStart()}`;const r=t.index,s=r+t[0].length-1;let o=1,i=s+1;for(;i<n.length&&o>0;)n[i]==="{"?o++:n[i]==="}"&&o--,i++;return n.slice(0,r)+e+n.slice(i)}function ho(n,e){switch(n){case"tool":return{input:{},action:{toolName:""},outputSchema:{},name:`Step_${e+1}`};case"code":return{...Kh,name:`Step_${e+1}`};default:throw new Error(`Invalid step type: ${n}`)}}const rd=O.createContext(null),Dm=n=>Ki()(nd(e=>({...n,actions:{setIsAddingStep:t=>e(r=>({...r,isAddingStep:t})),setCurrentStepTab:t=>e(r=>({...r,currentStepTab:t})),setToolAction:t=>e(r=>({workflow:{...r.workflow,steps:r.workflow.steps.map(s=>"toolName"in s.action&&s.action.toolName===t.toolName?{...s,action:t}:s)}})),appendStep:({step:t,type:r})=>e(s=>{const o=t??ho(r,s.workflow.steps.length),i=s.workflow.steps.find(a=>a.name===o.name),l=i?`${o.name} ${parseInt(i.name.split(" ").pop()??Math.random().toString(36).substring(2,15))+1}`:o.name;return{workflow:{...s.workflow,steps:[...s.workflow.steps,{...o,name:l}]}}}),deleteStep:t=>e(r=>({workflow:{...r.workflow,steps:r.workflow.steps.filter(s=>s.name!==t)}})),duplicateStep:t=>e(r=>{const s=r.workflow.steps.findIndex(a=>a.name===t);if(s===-1)return r;const o=r.workflow.steps[s];if(!o)return r;const i={...o,name:fo(o.name,r.workflow.steps)},l=[...r.workflow.steps];return l.splice(s+1,0,i),{workflow:{...r.workflow,steps:l},currentStepName:i.name}}),setCurrentStepName:t=>e(r=>({...r,currentStepName:t})),updateStep:(t,r)=>e(s=>({...s,workflow:{...s.workflow,steps:s.workflow.steps.map(o=>o.name===t?{...o,...r}:o)}})),setTrackingExecutionId:t=>e(r=>({...r,trackingExecutionId:t})),resetToOriginalWorkflow:()=>e(t=>({...t,workflow:t.localWorkflow})),startAddingStep:t=>e(r=>({...r,isAddingStep:!0,addingStepType:t})),cancelAddingStep:()=>e(t=>({...t,isAddingStep:!1,addingStepType:null,selectedParentSteps:[]})),toggleParentStepSelection:t=>e(r=>{const s=r.selectedParentSteps.includes(t);return{...r,selectedParentSteps:s?r.selectedParentSteps.filter(o=>o!==t):[...r.selectedParentSteps,t]}}),confirmAddCodeStep:()=>e(t=>{const{selectedParentSteps:r,addingStepType:s,workflow:o}=t;if(s!=="code"||r.length===0)return t;const i={};for(const u of r)i[u]=`@${u}`;const l={};for(const u of r){const f=o.steps.find(h=>h.name===u);f?.outputSchema&&(l[u]=f.outputSchema)}const a=Object.keys(l).length>0?{type:"object",properties:l,required:Object.keys(l)}:void 0;let c=ho("code",Number((Math.random()*1e6).toFixed(0)));if(c={...c,input:i},a){const u=Rm(a,"Input"),f=c.action,h=jm(f.code,u);c={...c,action:{...f,code:h}}}const d=fo(c.name,o.steps);return{...t,isAddingStep:!1,addingStepType:null,selectedParentSteps:[],workflow:{...o,steps:[...o.steps,{...c,name:d}]},currentStepName:d}}),addToolStep:()=>e(t=>{let r=ho("tool",Number((Math.random()*1e6).toFixed(0)));const s=fo(r.name,t.workflow.steps);return{...t,isAddingStep:!1,addingStepType:null,workflow:{...t.workflow,steps:[...t.workflow.steps,{...r,name:s}]},currentStepName:s}}),setOriginalWorkflow:t=>e(r=>({...r,localWorkflow:t})),setWorkflow:t=>e(r=>({...r,workflow:t})),startReplacingTool:t=>e(r=>({...r,replacingToolInfo:{toolName:t}})),cancelReplacingTool:()=>e(t=>({...t,replacingToolInfo:null})),setSelectedGatewayId:t=>e(r=>({...r,selectedGatewayId:t}))}}),{name:`workflow-store-${encodeURIComponent(n.workflow.id)}`,storage:td(()=>localStorage),version:1,partialize:e=>({trackingExecutionId:e.trackingExecutionId,currentStepName:e.currentStepName,currentStepTab:e.currentStepTab,localWorkflow:e.localWorkflow,isAddingStep:e.isAddingStep,addingStepType:e.addingStepType,selectedParentSteps:e.selectedParentSteps,replacingToolInfo:e.replacingToolInfo,selectedGatewayId:e.selectedGatewayId})}));function Pm(n){const e=I.c(8),{children:t,initialState:r}=n,s=Gh();let o;e[0]!==s?.[0]?.id||e[1]!==r.currentStepTab||e[2]!==r.trackingExecutionId||e[3]!==r.workflow?(o=()=>Dm({workflow:r.workflow,localWorkflow:r.workflow,selectedGatewayId:s?.[0]?.id,isAddingStep:!1,selectedParentSteps:[],trackingExecutionId:r.trackingExecutionId,currentStepName:r.workflow.steps[0]?.name,currentStepTab:r.currentStepTab??"input"}),e[0]=s?.[0]?.id,e[1]=r.currentStepTab,e[2]=r.trackingExecutionId,e[3]=r.workflow,e[4]=o):o=e[4];const[i]=O.useState(o);let l;return e[5]!==t||e[6]!==i?(l=m.jsx(rd.Provider,{value:i,children:t}),e[5]=t,e[6]=i,e[7]=l):l=e[7],l}function In(n,e){const t=O.useContext(rd);if(!t)throw new Error("Missing WorkflowStoreProvider - refresh the page. If the error persists, please contact support.");return Am(t,n,Im)}function Rn(){return In(Lm)}function Lm(n){return n.workflow}function Me(){return In($m)}function $m(n){return n.actions}function sd(){const n=pr();return In(zm)??n[0]?.name}function zm(n){return n.currentStepName}function hr(){const n=I.c(5),e=sd(),t=pr();let r;if(n[0]!==e||n[1]!==t){let o;n[3]!==e?(o=i=>i.name===e,n[3]=e,n[4]=o):o=n[4],r=t.find(o),n[0]=e,n[1]=t,n[2]=r}else r=n[2];const s=r;return s||t[0]}function pr(){return Rn().steps}function od(){const n=I.c(8),e=Rn(),t=In(Fm);let r,s;if(n[0]!==t.description||n[1]!==t.steps||n[2]!==t.title||n[3]!==e.description||n[4]!==e.steps||n[5]!==e.title){const o={title:e.title,description:e.description,steps:e.steps.map(Bm)},i={title:t.title,description:t.description,steps:t.steps.map(_m)};r=JSON.stringify(o),s=JSON.stringify(i),n[0]=t.description,n[1]=t.steps,n[2]=t.title,n[3]=e.description,n[4]=e.steps,n[5]=e.title,n[6]=r,n[7]=s}else r=n[6],s=n[7];return r!==s}function _m(n){return{...n,outputSchema:void 0}}function Bm(n){return{...n,outputSchema:void 0}}function Fm(n){return n.localWorkflow}function we(){return In(Vm)}function Vm(n){return n.trackingExecutionId}function jn(){return In(Hm)}function Hm(n){return n.selectedGatewayId}function Wm(n){const e=I.c(18),{selectedGatewayId:t,onGatewayChange:r,className:s,placeholder:o}=n,i=o===void 0?"Select Agent":o,l=Qh(),a=t??void 0;let c;e[0]!==r?(c=g=>r(g===""?void 0:g),e[0]=r,e[1]=c):c=e[1];let d;e[2]!==s?(d=U("text-xs",s),e[2]=s,e[3]=d):d=e[3];let u;e[4]!==i?(u=m.jsx(sp,{placeholder:i}),e[4]=i,e[5]=u):u=e[5];let f;e[6]!==d||e[7]!==u?(f=m.jsx(op,{size:"sm",className:d,children:u}),e[6]=d,e[7]=u,e[8]=f):f=e[8];let h;e[9]!==l?(h=l.map(qm),e[9]=l,e[10]=h):h=e[10];let p;e[11]!==h?(p=m.jsx(ip,{children:h}),e[11]=h,e[12]=p):p=e[12];let y;return e[13]!==a||e[14]!==c||e[15]!==f||e[16]!==p?(y=m.jsxs(lp,{value:a,onValueChange:c,children:[f,p]}),e[13]=a,e[14]=c,e[15]=f,e[16]=p,e[17]=y):y=e[17],y}function qm(n){return m.jsx(rp,{value:n.id,children:n.title},n.id)}function Dn(){const n=I.c(2),e=Lh();let t;n[0]!==e?(t={connections:e,binding:"WORKFLOW"},n[0]=e,n[1]=t):t=n[1];const r=Jh(t);if(!r||r.length===0||!r[0])throw new Error("No workflow connection found");return r[0]}const Yl=[100,1e3,2e3];function Pn(n){const e=I.c(15),t=Dn();let r;e[0]!==t.id?(r=qe(t.id),e[0]=t.id,e[1]=r):r=e[1];const s=r,o=O.useRef(0);let i;e[2]!==n?(i={id:n},e[2]=n,e[3]=i):i=e[3];const l=!!n;let a;e[4]!==n?(a=n?p=>{const y=p.state?.data?.item?.status;if(y==="running"||y==="enqueued"){const g=Yl[o.current]??1;return o.current=(o.current+1)%Yl.length,g}return o.current=0,!1}:!1,e[4]=n,e[5]=a):a=e[5];let c;e[6]!==t.id||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==s?(c={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_GET",toolInputParams:i,scope:t.id,staleTime:0,gcTime:0,enabled:l,refetchInterval:a},e[6]=t.id,e[7]=i,e[8]=l,e[9]=a,e[10]=s,e[11]=c):c=e[11];const{data:d,isLoading:u}=Bi(c),f=d?.item;let h;return e[12]!==u||e[13]!==f?(h={item:f,isLoading:u},e[12]=u,e[13]=f,e[14]=h):h=e[14],h}function Um(n,e){const t=I.c(14),r=Dn();let s;t[0]!==r.id?(s=qe(r.id),t[0]=r.id,t[1]=s):s=t[1];const o=s;let i;t[2]!==n||t[3]!==e?(i={executionId:n,stepId:e},t[2]=n,t[3]=e,t[4]=i):i=t[4];const l=!!n&&!!e;let a;t[5]!==r.id||t[6]!==i||t[7]!==l||t[8]!==o?(a={toolCaller:o,toolName:"COLLECTION_WORKFLOW_EXECUTION_GET_STEP_RESULT",toolInputParams:i,scope:r.id,enabled:l},t[5]=r.id,t[6]=i,t[7]=l,t[8]=o,t[9]=a):a=t[9];const{data:c,isLoading:d}=Bi(a),u=c?.output,f=c?.error;let h;return t[10]!==d||t[11]!==u||t[12]!==f?(h={output:u,error:f,isLoading:d},t[10]=d,t[11]=u,t[12]=f,t[13]=h):h=t[13],h}function Km(){const n=I.c(19),e=Dn(),t=Rn();let r;n[0]!==e.id?(r=qe(e.id),n[0]=e.id,n[1]=r):r=n[1];const s=r;let o;n[2]===Symbol.for("react.memo_cache_sentinel")?(o=["workflow"],n[2]=o):o=n[2];let i;n[3]!==t.id?(i={field:o,operator:"eq",value:t.id},n[3]=t.id,n[4]=i):i=n[4];let l;n[5]===Symbol.for("react.memo_cache_sentinel")?(l=[{field:["created_at"],direction:"desc"}],n[5]=l):l=n[5];let a;n[6]!==i?(a={where:i,orderBy:l,limit:100},n[6]=i,n[7]=a):a=n[7];const c=`${e.id}-executions-${t.id}`,d=!!t.id;let u;n[8]!==a||n[9]!==c||n[10]!==d||n[11]!==s?(u={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_LIST",toolInputParams:a,scope:c,enabled:d,staleTime:5e3},n[8]=a,n[9]=c,n[10]=d,n[11]=s,n[12]=u):u=n[12];const{data:f,isLoading:h,refetch:p}=Bi(u),y=f;let g;n[13]!==y?.items?(g=y?.items??[],n[13]=y?.items,n[14]=g):g=n[14];let x;return n[15]!==h||n[16]!==p||n[17]!==g?(x={executions:g,isLoading:h,refetch:p},n[15]=h,n[16]=p,n[17]=g,n[18]=x):x=n[18],x}function id(n){const e=[];function t(r){if(typeof r=="string"){const s=r.match(/@input(?:\.(\w+(?:\.\w+)*))?/g);if(s)for(const o of s)if(o==="@input")e.push("__entire_input__");else{const i=o.replace("@input.","");e.push(i)}}else Array.isArray(r)?r.forEach(t):typeof r=="object"&&r!==null&&Object.values(r).forEach(t)}return t(n),[...new Set(e)]}function Jm(n){const e=[];for(const t of n){const r=id(t.input);e.push(...r)}return[...new Set(e)].filter(t=>t!=="__entire_input__")}function Gm(n){for(const e of n)if(id(e.input).includes("__entire_input__"))return!0;return!1}function Xm(n){const e=Jm(n);if(e.length===0)return Gm(n)?{type:"object",additionalProperties:!0,description:"Workflow input data"}:null;const t={},r=[];for(const s of e){const o=s.split(".");if(o.length===1)t[s]={type:"string",description:`Input field: ${s}`},r.push(s);else{const i=o[0];i&&!t[i]&&(t[i]={type:"object",description:`Input object: ${i}`,additionalProperties:!0},r.push(i))}}return{type:"object",properties:t,required:r,description:"Workflow execution input"}}function Ym(){const n=I.c(2),e=Rn();let t;return n[0]!==e.steps?(t=Xm(e.steps),n[0]=e.steps,n[1]=t):t=n[1],t}function Qm(){const n=I.c(14),{id:e}=Dn(),{setTrackingExecutionId:t}=Me();let r;n[0]!==e?(r=qe(e),n[0]=e,n[1]=r):r=n[1];const s=r,o=Rn(),i=jn(),l=Ym();let a;n[2]!==s?(a={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_CREATE"},n[2]=s,n[3]=a):a=n[3];const{mutateAsync:c,isPending:d}=Fi(a);let u;n[4]!==i||n[5]!==t||n[6]!==c||n[7]!==o?(u=async y=>{const g=y===void 0?{}:y;if(!i)throw new Error("Please select an Agent before running the workflow");const x=Date.now(),b=await c({input:g,gateway_id:i,start_at_epoch_ms:x,workflow_collection_id:o.id}),S=b?.item?.id??b?.structuredContent?.item?.id;return t(S),S},n[4]=i,n[5]=t,n[6]=c,n[7]=o,n[8]=u):u=n[8];const f=u,h=l!==null;let p;return n[9]!==f||n[10]!==l||n[11]!==d||n[12]!==h?(p={handleRunWorkflow:f,isPending:d,requiresInput:h,inputSchema:l},n[9]=f,n[10]=l,n[11]=d,n[12]=h,n[13]=p):p=n[13],p}function Zm(){const n=I.c(9),{id:e}=Dn();let t;n[0]!==e?(t=qe(e),n[0]=e,n[1]=t):t=n[1];const r=t;let s;n[2]!==r?(s={toolCaller:r,toolName:"CANCEL_EXECUTION"},n[2]=r,n[3]=s):s=n[3];const{mutateAsync:o,isPending:i}=Fi(s);let l;n[4]!==o?(l=async d=>await o({executionId:d}),n[4]=o,n[5]=l):l=n[5];const a=l;let c;return n[6]!==a||n[7]!==i?(c={handleCancelWorkflow:a,isCancelling:i},n[6]=a,n[7]=i,n[8]=c):c=n[8],c}function eg(){const n=I.c(9),{id:e}=Dn();let t;n[0]!==e?(t=qe(e),n[0]=e,n[1]=t):t=n[1];const r=t;let s;n[2]!==r?(s={toolCaller:r,toolName:"RESUME_EXECUTION"},n[2]=r,n[3]=s):s=n[3];const{mutateAsync:o,isPending:i}=Fi(s);let l;n[4]!==o?(l=async d=>(await o({executionId:d})).success,n[4]=o,n[5]=l):l=n[5];const a=l;let c;return n[6]!==a||n[7]!==i?(c={handleResumeWorkflow:a,isResuming:i},n[6]=a,n[7]=i,n[8]=c):c=n[8],c}function tg(){const n=I.c(3),e=we(),{item:t}=Pn(e);let r;return n[0]!==t||n[1]!==e?(r=e&&t?(()=>{const o={};return t?.input&&(o.input=t.input),o})():void 0,n[0]=t,n[1]=e,n[2]=r):r=n[2],r}function ng(n,e,t,r){if(!e)return[...n].sort(r);const s=t(e);return[...n].sort((o,i)=>{const l=t(o),a=t(i);return l===s?-1:a===s?1:r?r(o,i):0})}const Ji=Nm()(nd(n=>({viewMode:"visual",setViewMode:e=>n({viewMode:e}),showExecutionsList:!1,setShowExecutionsList:e=>n({showExecutionsList:e}),toggleExecutionsList:()=>n(e=>({showExecutionsList:!e.showExecutionsList}))}),{name:"workflow-view-mode"})),ld=O.createContext([]);function ad(){return O.useContext(ld)}function xe(n){this.content=n}xe.prototype={constructor:xe,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),o=r.content.slice();return s==-1?o.push(t||n,e):(o[s+1]=e,t&&(o[s]=t)),new xe(o)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new xe(t)},addToStart:function(n,e){return new xe([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new xe(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),o=r.find(n);return s.splice(o==-1?s.length:o,0,e,t),new xe(s)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=xe.from(n),n.size?new xe(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=xe.from(n),n.size?new xe(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=xe.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};xe.from=function(n){if(n instanceof xe)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new xe(e)};function cd(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),o=e.child(r);if(s==o){t+=s.nodeSize;continue}if(!s.sameMarkup(o))return t;if(s.isText&&s.text!=o.text){for(let i=0;s.text[i]==o.text[i];i++)t++;return t}if(s.content.size||o.content.size){let i=cd(s.content,o.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function dd(n,e,t,r){for(let s=n.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:t,b:r};let i=n.child(--s),l=e.child(--o),a=i.nodeSize;if(i==l){t-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:t,b:r};if(i.isText&&i.text!=l.text){let c=0,d=Math.min(i.text.length,l.text.length);for(;c<d&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||l.content.size){let c=dd(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class E{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,o){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,s+l,o||null,i)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),r,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let o="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),o=1);o<e.content.length;o++)s.push(e.content[o]);return new E(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let o=0,i=0;i<t;o++){let l=this.content[o],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),r.push(l),s+=l.nodeSize),i=a}return new E(r,s)}cutByIndex(e,t){return e==t?E.empty:e==0&&t==this.content.length?this:new E(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new E(s,o)}addToStart(e){return new E([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new E(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))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 t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return cd(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return dd(this,e,t,r)}findIndex(e){if(e==0)return Sr(0,e);if(e==this.size)return Sr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let s=this.child(t),o=r+s.nodeSize;if(o>=e)return o==e?Sr(t+1,o):Sr(t,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return E.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new E(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return E.empty;let t,r=0;for(let s=0;s<e.length;s++){let o=e[s];r+=o.nodeSize,s&&o.isText&&e[s-1].sameMarkup(o)?(t||(t=e.slice(0,s)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new E(t||e,r)}static from(e){if(!e)return E.empty;if(e instanceof E)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new E([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}E.empty=new E([],0);const po={index:0,offset:0};function Sr(n,e){return po.index=n,po.offset=e,po}function Fr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Fr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Fr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Y=class Uo{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let o=e[s];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,s));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Fr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Uo.none;if(e instanceof Uo)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};Y.none=[];class Vr extends Error{}class R{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=fd(this.content,e+this.openStart,t);return r&&new R(r,this.openStart,this.openEnd)}removeBetween(e,t){return new R(ud(this.content,e+this.openStart,t+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,t){if(!t)return R.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new R(E.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)s++;return new R(e,r,s)}}R.empty=new R(E.empty,0,0);function ud(n,e,t){let{index:r,offset:s}=n.findIndex(e),o=n.maybeChild(r),{index:i,offset:l}=n.findIndex(t);if(s==e||o.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(ud(o.content,e-s-1,t-s-1)))}function fd(n,e,t,r){let{index:s,offset:o}=n.findIndex(e),i=n.maybeChild(s);if(o==e||i.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=fd(i.content,e-o-1,t,i);return l&&n.replaceChild(s,i.copy(l))}function rg(n,e,t){if(t.openStart>n.depth)throw new Vr("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Vr("Inconsistent open depths");return hd(n,e,t,0)}function hd(n,e,t,r){let s=n.index(r),o=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let i=hd(n,e,t,r+1);return o.copy(o.content.replaceChild(s,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let i=n.parent,l=i.content;return Ft(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=sg(t,n);return Ft(o,md(n,i,l,e,r))}else return Ft(o,Hr(n,e,r))}function pd(n,e){if(!e.type.compatibleContent(n.type))throw new Vr("Cannot join "+e.type.name+" onto "+n.type.name)}function Ko(n,e,t){let r=n.node(t);return pd(r,e.node(t)),r}function Bt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function qn(n,e,t,r){let s=(e||n).node(t),o=0,i=e?e.index(t):s.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(Bt(n.nodeAfter,r),o++));for(let l=o;l<i;l++)Bt(s.child(l),r);e&&e.depth==t&&e.textOffset&&Bt(e.nodeBefore,r)}function Ft(n,e){return n.type.checkContent(e),n.copy(e)}function md(n,e,t,r,s){let o=n.depth>s&&Ko(n,e,s+1),i=r.depth>s&&Ko(t,r,s+1),l=[];return qn(null,n,s,l),o&&i&&e.index(s)==t.index(s)?(pd(o,i),Bt(Ft(o,md(n,e,t,r,s+1)),l)):(o&&Bt(Ft(o,Hr(n,e,s+1)),l),qn(e,t,s,l),i&&Bt(Ft(i,Hr(t,r,s+1)),l)),qn(r,null,s,l),new E(l)}function Hr(n,e,t){let r=[];if(qn(null,n,t,r),n.depth>t){let s=Ko(n,e,t+1);Bt(Ft(s,Hr(n,e,t+1)),r)}return qn(e,null,t,r),new E(r)}function sg(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)s=e.node(o).copy(E.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class nr{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.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,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)s+=r.child(o).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return Y.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let l=r;r=s,s=l}let o=r.marks;for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!s||!o[i].isInSet(s.marks))&&(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,s=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!s||!r[o].isInSet(s.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){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)&&(!t||t(this.node(r))))return new Wr(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 t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,o=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(o),c=o-a;if(r.push(i,l,s+a),!c||(i=i.child(l),i.isText))break;o=c-1,s+=a+1}return new nr(t,r,o)}static resolveCached(e,t){let r=Ql.get(e);if(r)for(let o=0;o<r.elts.length;o++){let i=r.elts[o];if(i.pos==t)return i}else Ql.set(e,r=new og);let s=r.elts[r.i]=nr.resolve(e,t);return r.i=(r.i+1)%ig,s}}class og{constructor(){this.elts=[],this.i=0}}const ig=12,Ql=new WeakMap;class Wr{constructor(e,t,r){this.$from=e,this.$to=t,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 lg=Object.create(null);class ze{constructor(e,t,r,s=Y.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||E.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,t,r,s=0){this.content.nodesBetween(e,t,r,s,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,t,r,s){return this.content.textBetween(e,t,r,s)}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,t,r){return this.type==e&&Fr(this.attrs,t||e.defaultAttrs||lg)&&Y.sameSet(this.marks,r||Y.none)}copy(e=null){return e==this.content?this:new ze(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ze(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return R.empty;let s=this.resolve(e),o=this.resolve(t),i=r?0:s.sharedDepth(t),l=s.start(i),c=s.node(i).content.cut(s.pos-l,o.pos-l);return new R(c,s.depth-i,o.depth-i)}replace(e,t,r){return rg(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return nr.resolveCached(this,e)}resolveNoCache(e){return nr.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(s=!0),!s)),s}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()+")"),gd(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=E.empty,s=0,o=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,s,o),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<o;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let o=this.contentMatchAt(e).matchType(r),i=o&&o.matchFragment(this.content,t);return i?i.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=Y.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Y.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t 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(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=E.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,s,r);return o.type.checkAttrs(o.attrs),o}}ze.prototype.text=void 0;class qr extends ze{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):gd(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new qr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new qr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function gd(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Ut{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new ag(e,t);if(r.next==null)return Ut.empty;let s=yd(r);r.next&&r.err("Unexpected trailing text");let o=mg(pg(s));return gg(o,r),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let s=this;for(let o=t;s&&o<r;o++)s=s.matchType(e.child(o).type);return s}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:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function o(i,l){let a=i.matchFragment(e,r);if(a&&(!t||a.validEnd))return E.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:d,next:u}=i.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(u)==-1){s.push(u);let f=o(u,l.concat(d));if(f)return f}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),o=s.match;if(o.matchType(e)){let i=[];for(let l=s;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<o.next.length;i++){let{type:l,next:a}=o.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),t[l.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 t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(this),e.map((r,s)=>{let o=s+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)o+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return o}).join(`
|
|
8
|
+
`)}}Ut.empty=new Ut(!0);class ag{constructor(e,t){this.string=e,this.nodeTypes=t,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 yd(n){let e=[];do e.push(cg(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function cg(n){let e=[];do e.push(dg(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function dg(n){let e=hg(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=ug(n,e);else break;return e}function Zl(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function ug(n,e){let t=Zl(n),r=t;return n.eat(",")&&(n.next!="}"?r=Zl(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function fg(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let s=[];for(let o in t){let i=t[o];i.isInGroup(e)&&s.push(i)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function hg(n){if(n.eat("(")){let e=yd(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=fg(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function pg(n){let e=[[]];return s(o(n,0),t()),e;function t(){return e.push([])-1}function r(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function s(i,l){i.forEach(a=>a.to=l)}function o(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=o(i.exprs[a],l);if(a==i.exprs.length-1)return c;s(c,l=t())}else if(i.type=="star"){let a=t();return r(l,a),s(o(i.expr,a),a),[r(a)]}else if(i.type=="plus"){let a=t();return s(o(i.expr,l),a),s(o(i.expr,a),a),[r(a)]}else{if(i.type=="opt")return[r(l)].concat(o(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let d=t();s(o(i.expr,a),d),a=d}if(i.max==-1)s(o(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let d=t();r(a,d),s(o(i.expr,a),d),a=d}return[r(a)]}else{if(i.type=="name")return[r(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function xd(n,e){return e-n}function ea(n,e){let t=[];return r(e),t.sort(xd);function r(s){let o=n[s];if(o.length==1&&!o[0].term)return r(o[0].to);t.push(s);for(let i=0;i<o.length;i++){let{term:l,to:a}=o[i];!l&&t.indexOf(a)==-1&&r(a)}}}function mg(n){let e=Object.create(null);return t(ea(n,0));function t(r){let s=[];r.forEach(i=>{n[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<s.length;d++)s[d][0]==l&&(c=s[d][1]);ea(n,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let o=e[r.join(",")]=new Ut(r.indexOf(n.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(xd);o.next.push({type:s[i][0],next:e[l.join(",")]||t(l)})}return o}}function gg(n,e){for(let t=0,r=[n];t<r.length;t++){let s=r[t],o=!s.validEnd,i=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];i.push(a.name),o&&!(a.isText||a.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function bd(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function kd(n,e){let t=Object.create(null);for(let r in n){let s=e&&e[r];if(s===void 0){let o=n[r];if(o.hasDefault)s=o.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=s}return t}function Sd(n,e,t,r){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let o=n[s];o.validate&&o.validate(e[s])}}function wd(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new xg(n,r,e[r]);return t}let ta=class vd{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=wd(e,r.attrs),this.defaultAttrs=bd(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==Ut.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:kd(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ze(this,this.computeAttrs(e),E.from(t),Y.setFrom(r))}createChecked(e=null,t,r){return t=E.from(t),this.checkContent(t),new ze(this,this.computeAttrs(e),t,Y.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=E.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let s=this.contentMatch.matchFragment(t),o=s&&s.fillBefore(E.empty,!0);return o?new ze(this,e,t.append(o),Y.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.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){Sd(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 t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:Y.none:e}static compile(e,t){let r=Object.create(null);e.forEach((o,i)=>r[o]=new vd(o,t,i));let s=t.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function yg(n,e,t){let r=t.split("|");return s=>{let o=s===null?"null":typeof s;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${o}`)}}class xg{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?yg(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Ps{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=wd(e,s.attrs),this.excluded=null;let o=bd(this.attrs);this.instance=o?new Y(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Y(this,kd(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((o,i)=>r[o]=new Ps(o,s++,t,i)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Sd(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Cd{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=xe.from(e.nodes),t.marks=xe.from(e.marks||{}),this.nodes=ta.compile(this.spec.nodes,this),this.marks=Ps.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let o=this.nodes[s],i=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[i]||(r[i]=Ut.parse(i,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?na(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let s in this.marks){let o=this.marks[s],i=o.spec.excludes;o.excluded=i==null?[o]:i==""?[]:na(this,i.split(" "))}this.nodeFromJSON=s=>ze.fromJSON(this,s),this.markFromJSON=s=>Y.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ta){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(t,r,s)}text(e,t){let r=this.nodes.text;return new qr(r,r.defaultAttrs,e,Y.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function na(n,e){let t=[];for(let r=0;r<e.length;r++){let s=e[r],o=n.marks[s],i=o;if(o)t.push(o);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function bg(n){return n.tag!=null}function kg(n){return n.style!=null}class kt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(bg(s))this.tags.push(s);else if(kg(s)){let o=/[^=]*/.exec(s.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let o=e.nodes[s.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new sa(this,t,!1);return r.addAll(e,Y.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new sa(this,t,!0);return r.addAll(e,Y.none,t.from,t.to),R.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let o=this.tags[s];if(vg(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let i=o.getAttrs(e);if(i===!1)continue;o.attrs=i||void 0}return o}}}matchStyle(e,t,r,s){for(let o=s?this.styles.indexOf(s)+1:0;o<this.styles.length;o++){let i=this.styles[o],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function r(s){let o=s.priority==null?50:s.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<o)break}t.splice(i,0,s)}for(let s in e.marks){let o=e.marks[s].spec.parseDOM;o&&o.forEach(i=>{r(i=oa(i)),i.mark||i.ignore||i.clearMark||(i.mark=s)})}for(let s in e.nodes){let o=e.nodes[s].spec.parseDOM;o&&o.forEach(i=>{r(i=oa(i)),i.node||i.ignore||i.mark||(i.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new kt(e,kt.schemaRules(e)))}}const Nd={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},Sg={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ed={ol:!0,ul:!0},rr=1,Jo=2,Un=4;function ra(n,e,t){return e!=null?(e?rr:0)|(e==="full"?Jo:0):n&&n.whitespace=="pre"?rr|Jo:t&~Un}class wr{constructor(e,t,r,s,o,i){this.type=e,this.attrs=t,this.marks=r,this.solid=s,this.options=i,this.content=[],this.activeMarks=Y.none,this.match=o||(i&Un?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(E.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&rr)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-s[0].length))}}let t=E.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(E.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Nd.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class sa{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=t.topNode,o,i=ra(null,t.preserveWhitespace,0)|(r?Un:0);s?o=new wr(s.type,s.attrs,Y.none,!0,t.topMatch||s.type.contentMatch,i):r?o=new wr(null,null,Y.none,!0,null,i):o=new wr(e.schema.topNodeType,null,Y.none,!0,null,i),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,s=this.top,o=s.options&Jo?"full":this.localPreserveWS||(s.options&rr)>0,{schema:i}=this.parser;if(o==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,`
|
|
9
|
+
`);else if(i.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(i.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(i.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(i.text(l[a]),t,!/\S/.test(l[a]));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 l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(i.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let s=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),l;Ed.hasOwnProperty(i)&&this.parser.normalizeLists&&wg(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Sg.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,d=this.needsBlock;if(Nd.hasOwnProperty(i))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(o),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
10
|
+
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let o=this.parser.matchedStyles[s],i=r.getPropertyValue(o);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(o,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,s){let o,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(i,t.attrs||null,r,t.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,t,r,s){let o=r||0;for(let i=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];i!=l;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}findPlace(e,t,r){let s,o;for(let i=this.open,l=0;i>=0;i--){let a=this.nodes[i],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,o=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(o);for(let i=0;i<s.length;i++)t=this.enterInner(s[i],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let s=this.findPlace(e,t,r);if(s){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let i=Y.none;for(let l of s.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):ia(l.type,e.type))&&(i=l.addToSet(i));return o.content.push(e.mark(i)),!0}return!1}enter(e,t,r,s){let o=this.findPlace(e.create(t),r,!1);return o&&(o=this.enterInner(e,t,r,!0,s)),o}enterInner(e,t,r,s=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=ra(e,o,i.options);i.options&Un&&i.content.length==0&&(l|=Un);let a=Y.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):ia(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new wr(e,t,a,s,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].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 t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=rr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(s?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(i(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function wg(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ed.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function vg(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function oa(n){let e={};for(let t in n)e[t]=n[t];return e}function ia(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let o=[],i=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||o.indexOf(d)<0&&i(d))return!0}};if(i(s.contentMatch))return!0}}class Qt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=mo(t).createDocumentFragment());let s=r,o=[];return e.forEach(i=>{if(o.length||i.marks.length){let l=0,a=0;for(;l<o.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(o[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)s=o.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],d=this.serializeMark(c,i.isInline,t);d&&(o.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:s}=Dr(mo(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let o=this.serializeMark(e.marks[s],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&Dr(mo(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return Dr(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Qt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=la(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return la(e.marks)}}function la(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function mo(n){return n.document||window.document}const aa=new WeakMap;function Cg(n){let e=aa.get(n);return e===void 0&&aa.set(n,e=Ng(n)),e}function Ng(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)t(r[s]);else for(let s in r)t(r[s])}return t(n),e}function Dr(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],o;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=Cg(r))&&o.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 i=s.indexOf(" ");i>0&&(t=s.slice(0,i),s=s.slice(i+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=Dr(n,f,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Td=65535,Md=Math.pow(2,16);function Eg(n,e){return n+e*Md}function ca(n){return n&Td}function Tg(n){return(n-(n&Td))/Md}const Ad=1,Od=2,Pr=4,Id=8;class Go{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Id)>0}get deletedBefore(){return(this.delInfo&(Ad|Pr))>0}get deletedAfter(){return(this.delInfo&(Od|Pr))>0}get deletedAcross(){return(this.delInfo&Pr)>0}}class Re{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Re.empty)return Re.empty}recover(e){let t=0,r=ca(e);if(!this.inverted)for(let s=0;s<r;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+t+Tg(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let s=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+o],d=this.ranges[l+i],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,h=a+s+(f<0?0:d);if(r)return h;let p=e==(t<0?a:u)?null:Eg(l/3,e-a),y=e==a?Od:e==u?Ad:Pr;return(t<0?e!=a:e!=u)&&(y|=Id),new Go(h,y,p)}s+=d-c}return r?e+s:new Go(e+s,0,null)}touches(e,t){let r=0,s=ca(t),o=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+o],d=a+c;if(e<=d&&l==s*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,o=0;s<this.ranges.length;s+=3){let i=this.ranges[s],l=i-(this.inverted?o:0),a=i+(this.inverted?0:o),c=this.ranges[s+t],d=this.ranges[s+r];e(l,l+c,a,a+d),o+=d-c}}invert(){return new Re(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Re.empty:new Re(e<0?[0,-e,0]:[0,0,e])}}Re.empty=new Re([]);class sr{constructor(e,t,r=0,s=e?e.length:0){this.mirror=t,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new sr(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let s=e.getMirror(t);this.appendMap(e._maps[t],s!=null&&s<t?r+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e._maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new sr;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let s=0;for(let o=this.from;o<this.to;o++){let i=this._maps[o],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new Go(e,s,null)}}const go=Object.create(null);class Ne{getMap(){return Re.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=go[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in go)throw new RangeError("Duplicate use of step JSON ID "+e);return go[e]=t,t.prototype.jsonID=e,t}}class de{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new de(e,null)}static fail(e){return new de(null,e)}static fromReplace(e,t,r,s){try{return de.ok(e.replace(t,r,s))}catch(o){if(o instanceof Vr)return de.fail(o.message);throw o}}}function Gi(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let o=n.child(s);o.content.size&&(o=o.copy(Gi(o.content,e,o))),o.isInline&&(o=e(o,t,s)),r.push(o)}return E.fromArray(r)}class yt extends Ne{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),o=new R(Gi(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),t.openStart,t.openEnd);return de.fromReplace(e,this.from,this.to,o)}invert(){return new He(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new yt(t.pos,r.pos,this.mark)}merge(e){return e instanceof yt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new yt(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,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new yt(t.from,t.to,e.markFromJSON(t.mark))}}Ne.jsonID("addMark",yt);class He extends Ne{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new R(Gi(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return de.fromReplace(e,this.from,this.to,r)}invert(){return new yt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new He(t.pos,r.pos,this.mark)}merge(e){return e instanceof He&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new He(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,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new He(t.from,t.to,e.markFromJSON(t.mark))}}Ne.jsonID("removeMark",He);class xt extends Ne{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return de.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return de.fromReplace(e,this.pos,this.pos+1,new R(E.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(r))return new xt(this.pos,t.marks[s]);return new xt(this.pos,this.mark)}}return new Kt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new xt(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new xt(t.pos,e.markFromJSON(t.mark))}}Ne.jsonID("addNodeMark",xt);class Kt extends Ne{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return de.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return de.fromReplace(e,this.pos,this.pos+1,new R(E.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new xt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Kt(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Kt(t.pos,e.markFromJSON(t.mark))}}Ne.jsonID("removeNodeMark",Kt);class he extends Ne{constructor(e,t,r,s=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=s}apply(e){return this.structure&&Xo(e,this.from,this.to)?de.fail("Structure replace would overwrite content"):de.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Re([this.from,this.to-this.from,this.slice.size])}invert(e){return new he(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new he(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof he)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?R.empty:new R(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new he(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?R.empty:new R(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new he(e.from,this.to,t,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,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new he(t.from,t.to,R.fromJSON(e,t.slice),!!t.structure)}}Ne.jsonID("replace",he);class ge extends Ne{constructor(e,t,r,s,o,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=s,this.slice=o,this.insert=i,this.structure=l}apply(e){if(this.structure&&(Xo(e,this.from,this.gapFrom)||Xo(e,this.gapTo,this.to)))return de.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return de.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?de.fromReplace(e,this.from,this.to,r):de.fail("Content does not fit in gap")}getMap(){return new Re([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ge(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||s<t.pos||o>r.pos?null:new ge(t.pos,r.pos,s,o,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,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ge(t.from,t.to,t.gapFrom,t.gapTo,R.fromJSON(e,t.slice),t.insert,!!t.structure)}}Ne.jsonID("replaceAround",ge);function Xo(n,e,t){let r=n.resolve(e),s=t-e,o=r.depth;for(;s>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,s--;if(s>0){let i=r.node(o).maybeChild(r.indexAfter(o));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function Mg(n,e,t,r){let s=[],o=[],i,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(u);for(let y=0;y<u.length;y++)u[y].isInSet(p)||(i&&i.to==f&&i.mark.eq(u[y])?i.to=h:s.push(i=new He(f,h,u[y])));l&&l.to==f?l.to=h:o.push(l=new yt(f,h,r))}}),s.forEach(a=>n.step(a)),o.forEach(a=>n.step(a))}function Ag(n,e,t,r){let s=[],o=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;o++;let a=null;if(r instanceof Ps){let c=i.marks,d;for(;d=r.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(i.marks)&&(a=[r]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],f;for(let h=0;h<s.length;h++){let p=s[h];p.step==o-1&&u.eq(s[h].style)&&(f=p)}f?(f.to=c,f.step=o):s.push({style:u,from:Math.max(l,e),to:c,step:o})}}}),s.forEach(i=>n.step(new He(i.from,i.to,i.style)))}function Xi(n,e,t,r=t.contentMatch,s=!0){let o=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),d=l+c.nodeSize,u=r.matchType(c.type);if(!u)i.push(new he(l,d,R.empty));else{r=u;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new He(l,d,c.marks[f]));if(s&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new R(E.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new he(l+f.index,l+f.index+f[0].length,p))}}l=d}if(!r.validEnd){let a=r.fillBefore(E.empty,!0);n.replace(l,l,new R(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function Og(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Ln(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,s=0,o=0;;--r){let i=n.$from.node(r),l=n.$from.index(r)+s,a=n.$to.indexAfter(r)-o;if(r<n.depth&&i.canReplace(l,a,t))return r;if(r==0||i.type.spec.isolating||!Og(i,l,a))break;l&&(s=1),a<i.childCount&&(o=1)}return null}function Ig(n,e,t){let{$from:r,$to:s,depth:o}=e,i=r.before(o+1),l=s.after(o+1),a=i,c=l,d=E.empty,u=0;for(let p=o,y=!1;p>t;p--)y||r.index(p)>0?(y=!0,d=E.from(r.node(p).copy(d)),u++):a--;let f=E.empty,h=0;for(let p=o,y=!1;p>t;p--)y||s.after(p+1)<s.end(p)?(y=!0,f=E.from(s.node(p).copy(f)),h++):c++;n.step(new ge(a,c,i,l,new R(d.append(f),u,h),d.size-u,!0))}function Yi(n,e,t=null,r=n){let s=Rg(n,e),o=s&&jg(r,e);return o?s.map(da).concat({type:e,attrs:t}).concat(o.map(da)):null}function da(n){return{type:n,attrs:null}}function Rg(n,e){let{parent:t,startIndex:r,endIndex:s}=n,o=t.contentMatchAt(r).findWrapping(e);if(!o)return null;let i=o.length?o[0]:e;return t.canReplaceWith(r,s,i)?o:null}function jg(n,e){let{parent:t,startIndex:r,endIndex:s}=n,o=t.child(r),i=e.contentMatch.findWrapping(o.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function Dg(n,e,t){let r=E.empty;for(let i=t.length-1;i>=0;i--){if(r.size){let l=t[i].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=E.from(t[i].type.create(t[i].attrs,r))}let s=e.start,o=e.end;n.step(new ge(s,o,s,o,new R(r,0,0),t.length,!0))}function Pg(n,e,t,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let a=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(r,a)&&Lg(n.doc,n.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&jd(n,i,l,o),Xi(n,n.mapping.slice(o).map(l,1),r,void 0,c===null);let d=n.mapping.slice(o),u=d.map(l,1),f=d.map(l+i.nodeSize,1);return n.step(new ge(u,f,u+1,f-1,new R(E.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&Rd(n,i,l,o),!1}})}function Rd(n,e,t,r){e.forEach((s,o)=>{if(s.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(s.text);){let a=n.mapping.slice(r).map(t+1+o+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function jd(n,e,t,r){e.forEach((s,o)=>{if(s.type==s.type.schema.linebreakReplacement){let i=n.mapping.slice(r).map(t+1+o);n.replaceWith(i,i+1,e.type.schema.text(`
|
|
11
|
+
`))}})}function Lg(n,e,t){let r=n.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,t)}function $g(n,e,t,r,s){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let i=t.create(r,null,s||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,i);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ge(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new R(E.from(i),0,0),1,!0))}function ot(n,e,t=1,r){let s=n.resolve(e),o=s.depth-t,i=r&&r[r.length-1]||s.parent;if(o<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=t-2;c>o;c--,d--){let u=s.node(c),f=s.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),p=r&&r[d+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let y=r&&r[d]||u;if(!u.canReplace(f+1,u.childCount)||!y.type.validContent(h))return!1}let l=s.indexAfter(o),a=r&&r[0];return s.node(o).canReplaceWith(l,l,a?a.type:s.node(o+1).type)}function zg(n,e,t=1,r){let s=n.doc.resolve(e),o=E.empty,i=E.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){o=E.from(s.node(l).copy(o));let d=r&&r[c];i=E.from(d?d.type.create(d.attrs,i):s.node(l).copy(i))}n.step(new he(e,e,new R(o.append(i),t,t),!0))}function Mt(n,e){let t=n.resolve(e),r=t.index();return Dd(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function _g(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let s=0;s<e.childCount;s++){let o=e.child(s),i=o.type==r?n.type.schema.nodes.text:o.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(o.marks))return!1}return t.validEnd}function Dd(n,e){return!!(n&&e&&!n.isLeaf&&_g(n,e))}function Ls(n,e,t=-1){let r=n.resolve(e);for(let s=r.depth;;s--){let o,i,l=r.index(s);if(s==r.depth?(o=r.nodeBefore,i=r.nodeAfter):t>0?(o=r.node(s+1),l++,i=r.node(s).maybeChild(l)):(o=r.node(s).maybeChild(l-1),i=r.node(s+1)),o&&!o.isTextblock&&Dd(o,i)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=t<0?r.before(s):r.after(s)}}function Bg(n,e,t){let r=null,{linebreakReplacement:s}=n.doc.type.schema,o=n.doc.resolve(e-t),i=o.node().type;if(s&&i.inlineContent){let d=i.whitespace=="pre",u=!!i.contentMatch.matchType(s);d&&!u?r=!1:!d&&u&&(r=!0)}let l=n.steps.length;if(r===!1){let d=n.doc.resolve(e+t);jd(n,d.node(),d.before(),l)}i.inlineContent&&Xi(n,e+t-1,i,o.node().contentMatchAt(o.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new he(c,a.map(e+t,-1),R.empty,!0)),r===!0){let d=n.doc.resolve(c);Rd(n,d.node(),d.before(),n.steps.length)}return n}function Fg(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let o=r.index(s);if(r.node(s).canReplaceWith(o,o,t))return r.before(s+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let o=r.indexAfter(s);if(r.node(s).canReplaceWith(o,o,t))return r.after(s+1);if(o<r.node(s).childCount)return null}return null}function Pd(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let o=0;o<t.openStart;o++)s=s.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let i=r.depth;i>=0;i--){let l=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,a=r.index(i)+(l>0?1:0),c=r.node(i),d=!1;if(o==1)d=c.canReplace(a,a,s);else{let u=c.contentMatchAt(a).findWrapping(s.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(i+1):r.after(i+1)}return null}function $s(n,e,t=e,r=R.empty){if(e==t&&!r.size)return null;let s=n.resolve(e),o=n.resolve(t);return Ld(s,o,r)?new he(e,t,r):new Vg(s,o,r).fit()}function Ld(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Vg{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=E.empty;for(let s=0;s<=e.depth;s++){let o=e.node(s);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=E.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let o=this.placed,i=r.depth,l=s.depth;for(;i&&l&&o.childCount==1;)o=o.firstChild.content,i--,l--;let a=new R(o,i,l);return e>-1?new ge(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new he(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let o=t.firstChild;if(t.childCount>1&&(s=0),o.type.spec.isolating&&s<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let s,o=null;r?(o=yo(this.unplaced.content,r-1).firstChild,s=o.content):s=this.unplaced.content;let i=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(i?c.matchType(i.type)||(u=c.fillBefore(E.from(i),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:u};if(t==2&&i&&(d=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:d};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=yo(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new R(e,t+1,Math.max(r,s.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=yo(e,t);if(s.childCount<=1&&t>0){let o=e.size-t<=t+s.size;this.unplaced=new R(Fn(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new R(Fn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:s,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let y=0;y<o.length;y++)this.openFrontierNode(o[y]);let i=this.unplaced,l=r?r.content:i.content,a=i.openStart-e,c=0,d=[],{match:u,type:f}=this.frontier[t];if(s){for(let y=0;y<s.childCount;y++)d.push(s.child(y));u=u.matchFragment(s)}let h=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let y=l.child(c),g=u.matchType(y.type);if(!g)break;c++,(c>1||a==0||y.content.size)&&(u=g,d.push($d(y.mark(f.allowedMarks(y.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=Vn(this.placed,t,E.from(d)),this.frontier[t].match=u,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,g=l;y<h;y++){let x=g.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),g=x.content}this.unplaced=p?e==0?R.empty:new R(Fn(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new R(Fn(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!xo(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:s}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=xo(e,t,s,r,o);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=xo(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:i,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Vn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let s=e.node(r),o=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,o)}return e}openFrontierNode(e,t=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Vn(this.placed,this.depth,E.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(E.empty,!0);t.childCount&&(this.placed=Vn(this.placed,this.frontier.length,t))}}function Fn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Fn(n.firstChild.content,e-1,t)))}function Vn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Vn(n.lastChild.content,e-1,t)))}function yo(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function $d(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,$d(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(E.empty,!0)))),n.copy(r)}function xo(n,e,t,r,s){let o=n.node(e),i=s?n.indexAfter(e):n.index(e);if(i==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,i);return l&&!Hg(t,o.content,i)?l:null}function Hg(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Wg(n){return n.spec.defining||n.spec.definingForContent}function qg(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),o=n.doc.resolve(t);if(Ld(s,o,r))return n.step(new he(e,t,r));let i=_d(s,o);i[i.length-1]==0&&i.pop();let l=-(s.depth+1);i.unshift(l);for(let f=s.depth,h=s.pos-1;f>0;f--,h--){let p=s.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;i.indexOf(f)>-1?l=f:s.before(f)==h&&i.splice(1,0,-f)}let a=i.indexOf(l),c=[],d=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=d-1;f>=0;f--){let h=c[f],p=Wg(h.type);if(p&&!h.sameMarkup(s.node(Math.abs(l)-1)))d=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+d+1)%(r.openStart+1),p=c[h];if(p)for(let y=0;y<i.length;y++){let g=i[(y+a)%i.length],x=!0;g<0&&(x=!1,g=-g);let b=s.node(g-1),S=s.index(g-1);if(b.canReplaceWith(S,S,p.type,p.marks))return n.replace(s.before(g),x?o.after(g):t,new R(zd(r.content,0,r.openStart,h),h,r.openEnd))}}let u=n.steps.length;for(let f=i.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>u));f--){let h=i[f];h<0||(e=s.before(h),t=o.after(h))}}function zd(n,e,t,r,s){if(e<t){let o=n.firstChild;n=n.replaceChild(0,o.copy(zd(o.content,e+1,t,r,o)))}if(e>r){let o=s.contentMatchAt(0),i=o.fillBefore(n).append(n);n=i.append(o.matchFragment(i).fillBefore(E.empty,!0))}return n}function Ug(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=Fg(n.doc,e,r.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new R(E.from(r),0,0))}function Kg(n,e,t){let r=n.doc.resolve(e),s=n.doc.resolve(t),o=_d(r,s);for(let i=0;i<o.length;i++){let l=o[i],a=i==o.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return n.delete(r.before(l),s.after(l))}for(let i=1;i<=r.depth&&i<=s.depth;i++)if(e-r.start(i)==r.depth-i&&t>r.end(i)&&s.end(i)-t!=s.depth-i&&r.start(i-1)==s.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),s.index(i-1)))return n.delete(r.before(i),t);n.delete(e,t)}function _d(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let s=r;s>=0;s--){let o=n.start(s);if(o<n.pos-(n.depth-s)||e.end(s)>e.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(o==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==o-1)&&t.push(s)}return t}class bn extends Ne{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return de.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let s=t.type.create(r,null,t.marks);return de.fromReplace(e,this.pos,this.pos+1,new R(E.from(s),0,t.isLeaf?0:1))}getMap(){return Re.empty}invert(e){return new bn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new bn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new bn(t.pos,t.attr,t.value)}}Ne.jsonID("attr",bn);class or extends Ne{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return de.ok(r)}getMap(){return Re.empty}invert(e){return new or(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new or(t.attr,t.value)}}Ne.jsonID("docAttr",or);let wn=class extends Error{};wn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};wn.prototype=Object.create(Error.prototype);wn.prototype.constructor=wn;wn.prototype.name="TransformError";class Bd{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new sr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new wn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=R.empty){let s=$s(this.doc,e,t,r);return s&&this.step(s),this}replaceWith(e,t,r){return this.replace(e,t,new R(E.from(r),0,0))}delete(e,t){return this.replace(e,t,R.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return qg(this,e,t,r),this}replaceRangeWith(e,t,r){return Ug(this,e,t,r),this}deleteRange(e,t){return Kg(this,e,t),this}lift(e,t){return Ig(this,e,t),this}join(e,t=1){return Bg(this,e,t),this}wrap(e,t){return Dg(this,e,t),this}setBlockType(e,t=e,r,s=null){return Pg(this,e,t,r,s),this}setNodeMarkup(e,t,r=null,s){return $g(this,e,t,r,s),this}setNodeAttribute(e,t,r){return this.step(new bn(e,t,r)),this}setDocAttribute(e,t){return this.step(new or(e,t)),this}addNodeMark(e,t){return this.step(new xt(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof Y)t.isInSet(r.marks)&&this.step(new Kt(e,t));else{let s=r.marks,o,i=[];for(;o=t.isInSet(s);)i.push(new Kt(e,o)),s=o.removeFromSet(s);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,t=1,r){return zg(this,e,t,r),this}addMark(e,t,r){return Mg(this,e,t,r),this}removeMark(e,t,r){return Ag(this,e,t,r),this}clearIncompatible(e,t,r){return Xi(this,e,t,r),this}}const bo=Object.create(null);class q{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Jg(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=R.empty){let r=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=r,r=r.lastChild;let o=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],d=e.mapping.slice(o);e.replaceRange(d.map(a.pos),d.map(c.pos),l?R.empty:t),l==0&&ha(e,o,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:i,$to:l}=s[o],a=e.mapping.slice(r),c=a.map(i.pos),d=a.map(l.pos);o?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),ha(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let s=e.parent.inlineContent?new F(e):pn(e.node(0),e.parent,e.pos,e.index(),t,r);if(s)return s;for(let o=e.depth-1;o>=0;o--){let i=t<0?pn(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):pn(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new je(e.node(0))}static atStart(e){return pn(e,e,0,0,1)||new je(e)}static atEnd(e){return pn(e,e,e.content.size,e.childCount,-1)||new je(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=bo[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in bo)throw new RangeError("Duplicate use of selection JSON ID "+e);return bo[e]=t,t.prototype.jsonID=e,t}getBookmark(){return F.between(this.$anchor,this.$head).getBookmark()}}q.prototype.visible=!0;class Jg{constructor(e,t){this.$from=e,this.$to=t}}let ua=!1;function fa(n){!ua&&!n.parent.inlineContent&&(ua=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class F extends q{constructor(e,t=e){fa(e),fa(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return q.near(r);let s=e.resolve(t.map(this.anchor));return new F(s.parent.inlineContent?s:r,r)}replace(e,t=R.empty){if(super.replace(e,t),t==R.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof F&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new zs(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new F(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let s=e.resolve(t);return new this(s,r==t?s:e.resolve(r))}static between(e,t,r){let s=e.pos-t.pos;if((!r||s)&&(r=s>=0?1:-1),!t.parent.inlineContent){let o=q.findFrom(t,r,!0)||q.findFrom(t,-r,!0);if(o)t=o.$head;else return q.near(t,r)}return e.parent.inlineContent||(s==0?e=t:(e=(q.findFrom(e,-r,!0)||q.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new F(e,t)}}q.jsonID("text",F);class zs{constructor(e,t){this.anchor=e,this.head=t}map(e){return new zs(e.map(this.anchor),e.map(this.head))}resolve(e){return F.between(e.resolve(this.anchor),e.resolve(this.head))}}class $ extends q{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:s}=t.mapResult(this.anchor),o=e.resolve(s);return r?q.near(o):new $(o)}content(){return new R(E.from(this.node),0,0)}eq(e){return e instanceof $&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Qi(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new $(e.resolve(t.anchor))}static create(e,t){return new $(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}$.prototype.visible=!1;q.jsonID("node",$);class Qi{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new zs(r,r):new Qi(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&$.isSelectable(r)?new $(t):q.near(t)}}class je extends q{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=R.empty){if(t==R.empty){e.delete(0,e.doc.content.size);let r=q.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new je(e)}map(e){return new je(e)}eq(e){return e instanceof je}getBookmark(){return Gg}}q.jsonID("all",je);const Gg={map(){return this},resolve(n){return new je(n)}};function pn(n,e,t,r,s,o=!1){if(e.inlineContent)return F.create(n,t);for(let i=r-(s>0?0:1);s>0?i<e.childCount:i>=0;i+=s){let l=e.child(i);if(l.isAtom){if(!o&&$.isSelectable(l))return $.create(n,t-(s<0?l.nodeSize:0))}else{let a=pn(n,l,t+s,s<0?l.childCount:0,s,o);if(a)return a}t+=l.nodeSize*s}return null}function ha(n,e,t){let r=n.steps.length-1;if(r<e)return;let s=n.steps[r];if(!(s instanceof he||s instanceof ge))return;let o=n.mapping.maps[r],i;o.forEach((l,a,c,d)=>{i==null&&(i=d)}),n.setSelection(q.near(n.doc.resolve(i),t))}const pa=1,vr=2,ma=4;class Xg extends Bd{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|pa)&~vr,this.storedMarks=null,this}get selectionSet(){return(this.updated&pa)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=vr,this}ensureMarks(e){return Y.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&vr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~vr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Y.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let i=this.doc.resolve(t);o=r==t?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,s.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(q.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=ma,this}get scrolledIntoView(){return(this.updated&ma)>0}}function ga(n,e){return!e||!n?n:n.bind(e)}class Hn{constructor(e,t,r){this.name=e,this.init=ga(t.init,r),this.apply=ga(t.apply,r)}}const Yg=[new Hn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Hn("selection",{init(n,e){return n.selection||q.atStart(e.doc)},apply(n){return n.selection}}),new Hn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Hn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class ko{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Yg.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Hn(r.key,r.spec.state,r))})}}class xn{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),s=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=s?s[i].n:0,c=s?s[i].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(d&&r.filterTransaction(d,i)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<i?{state:r,n:t.length}:{state:this,n:0})}t.push(d),r=r.applyInner(d),o=!0}s&&(s[i]={state:r,n:t.length})}}if(!o)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new xn(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let o=r[s];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new Xg(this)}static create(e){let t=new ko(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new xn(t);for(let s=0;s<t.fields.length;s++)r[t.fields[s].name]=t.fields[s].init(e,r);return r}reconfigure(e){let t=new ko(this.schema,e.plugins),r=t.fields,s=new xn(t);for(let o=0;o<r.length;o++){let i=r[o].name;s[i]=this.hasOwnProperty(i)?this[i]:r[o].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],o=s.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new ko(e.schema,e.plugins),o=new xn(s);return s.fields.forEach(i=>{if(i.name=="doc")o.doc=ze.fromJSON(e.schema,t.doc);else if(i.name=="selection")o.selection=q.fromJSON(o.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[i.name]=c.fromJSON.call(a,e,t[l],o);return}}o[i.name]=i.init(e,o)}}),o}}function Fd(n,e,t){for(let r in n){let s=n[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Fd(s,e,{})),t[r]=s}return t}class re{constructor(e){this.spec=e,this.props={},e.props&&Fd(e.props,this,this.props),this.key=e.key?e.key.key:Vd("plugin")}getState(e){return e[this.key]}}const So=Object.create(null);function Vd(n){return n in So?n+"$"+ ++So[n]:(So[n]=0,n+"$")}class ae{constructor(e="key"){this.key=Vd(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Zi=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Hd(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Wd=(n,e,t)=>{let r=Hd(n,t);if(!r)return!1;let s=el(r);if(!s){let i=r.blockRange(),l=i&&Ln(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let o=s.nodeBefore;if(Zd(n,s,e,-1))return!0;if(r.parent.content.size==0&&(vn(o,"end")||$.isSelectable(o)))for(let i=r.depth;;i--){let l=$s(n.doc,r.before(i),r.after(i),R.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(vn(o,"end")?q.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):$.create(a.doc,s.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}return o.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos-o.nodeSize,s.pos).scrollIntoView()),!0):!1},Qg=(n,e,t)=>{let r=Hd(n,t);if(!r)return!1;let s=el(r);return s?qd(n,s,e):!1},Zg=(n,e,t)=>{let r=Kd(n,t);if(!r)return!1;let s=tl(r);return s?qd(n,s,e):!1};function qd(n,e,t){let r=e.nodeBefore,s=r,o=e.pos-1;for(;!s.isTextblock;o--){if(s.type.spec.isolating)return!1;let d=s.lastChild;if(!d)return!1;s=d}let i=e.nodeAfter,l=i,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=$s(n.doc,o,a,R.empty);if(!c||c.from!=o||c instanceof he&&c.slice.size>=a-o)return!1;if(t){let d=n.tr.step(c);d.setSelection(F.create(d.doc,o)),t(d.scrollIntoView())}return!0}function vn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Ud=(n,e,t)=>{let{$head:r,empty:s}=n.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;o=el(r)}let i=o&&o.nodeBefore;return!i||!$.isSelectable(i)?!1:(e&&e(n.tr.setSelection($.create(n.doc,o.pos-i.nodeSize)).scrollIntoView()),!0)};function el(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Kd(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Jd=(n,e,t)=>{let r=Kd(n,t);if(!r)return!1;let s=tl(r);if(!s)return!1;let o=s.nodeAfter;if(Zd(n,s,e,1))return!0;if(r.parent.content.size==0&&(vn(o,"start")||$.isSelectable(o))){let i=$s(n.doc,r.before(),r.after(),R.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(vn(o,"start")?q.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):$.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+o.nodeSize).scrollIntoView()),!0):!1},Gd=(n,e,t)=>{let{$head:r,empty:s}=n.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;o=tl(r)}let i=o&&o.nodeAfter;return!i||!$.isSelectable(i)?!1:(e&&e(n.tr.setSelection($.create(n.doc,o.pos)).scrollIntoView()),!0)};function tl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const e1=(n,e)=>{let t=n.selection,r=t instanceof $,s;if(r){if(t.node.isTextblock||!Mt(n.doc,t.from))return!1;s=t.from}else if(s=Ls(n.doc,t.from,-1),s==null)return!1;if(e){let o=n.tr.join(s);r&&o.setSelection($.create(o.doc,s-n.doc.resolve(s).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},t1=(n,e)=>{let t=n.selection,r;if(t instanceof $){if(t.node.isTextblock||!Mt(n.doc,t.to))return!1;r=t.to}else if(r=Ls(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},n1=(n,e)=>{let{$from:t,$to:r}=n.selection,s=t.blockRange(r),o=s&&Ln(s);return o==null?!1:(e&&e(n.tr.lift(s,o).scrollIntoView()),!0)},Xd=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
12
|
+
`).scrollIntoView()),!0)};function nl(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const r1=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let s=t.node(-1),o=t.indexAfter(-1),i=nl(s.contentMatchAt(o));if(!i||!s.canReplaceWith(o,o,i))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,i.createAndFill());a.setSelection(q.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Yd=(n,e)=>{let t=n.selection,{$from:r,$to:s}=t;if(t instanceof je||r.parent.inlineContent||s.parent.inlineContent)return!1;let o=nl(s.parent.contentMatchAt(s.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let i=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=n.tr.insert(i,o.createAndFill());l.setSelection(F.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},Qd=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(ot(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),s=r&&Ln(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)};function s1(n){return(e,t)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof $&&e.selection.node.isBlock)return!r.parentOffset||!ot(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],i,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=nl(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),o.unshift(a&&l?{type:l}:null),i=h;break}else{if(h==1)return!1;o.unshift(null)}let d=e.tr;(e.selection instanceof F||e.selection instanceof je)&&d.deleteSelection();let u=d.mapping.map(r.pos),f=ot(d.doc,u,o.length,o);if(f||(o[0]=l?{type:l}:null,f=ot(d.doc,u,o.length,o)),!f)return!1;if(d.split(u,o.length,o),!a&&c&&r.node(i).type!=l){let h=d.mapping.map(r.before(i)),p=d.doc.resolve(h);l&&r.node(i-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(i)),l)}return t&&t(d.scrollIntoView()),!0}}const o1=s1(),i1=(n,e)=>{let{$from:t,to:r}=n.selection,s,o=t.sharedDepth(r);return o==0?!1:(s=t.before(o),e&&e(n.tr.setSelection($.create(n.doc,s))),!0)};function l1(n,e,t){let r=e.nodeBefore,s=e.nodeAfter,o=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(s.isTextblock||Mt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Zd(n,e,t,r){let s=e.nodeBefore,o=e.nodeAfter,i,l,a=s.type.spec.isolating||o.type.spec.isolating;if(!a&&l1(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&l.matchType(i[0]||o.type).validEnd){if(t){let h=e.pos+o.nodeSize,p=E.empty;for(let x=i.length-1;x>=0;x--)p=E.from(i[x].create(null,p));p=E.from(s.copy(p));let y=n.tr.step(new ge(e.pos-1,h,e.pos,h,new R(p,1,0),i.length,!0)),g=y.doc.resolve(h+2*i.length);g.nodeAfter&&g.nodeAfter.type==s.type&&Mt(y.doc,g.pos)&&y.join(g.pos),t(y.scrollIntoView())}return!0}let d=o.type.spec.isolating||r>0&&a?null:q.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),f=u&&Ln(u);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(u,f).scrollIntoView()),!0;if(c&&vn(o,"start",!0)&&vn(s,"end")){let h=s,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let y=o,g=1;for(;!y.isTextblock;y=y.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,y.content)){if(t){let x=E.empty;for(let S=p.length-1;S>=0;S--)x=E.from(p[S].copy(x));let b=n.tr.step(new ge(e.pos-p.length,e.pos+o.nodeSize,e.pos+g,e.pos+o.nodeSize-g,new R(x,p.length,0),0,!0));t(b.scrollIntoView())}return!0}}return!1}function eu(n){return function(e,t){let r=e.selection,s=n<0?r.$from:r.$to,o=s.depth;for(;s.node(o).isInline;){if(!o)return!1;o--}return s.node(o).isTextblock?(t&&t(e.tr.setSelection(F.create(e.doc,n<0?s.start(o):s.end(o)))),!0):!1}}const a1=eu(-1),c1=eu(1);function d1(n,e=null){return function(t,r){let{$from:s,$to:o}=t.selection,i=s.blockRange(o),l=i&&Yi(i,n,e);return l?(r&&r(t.tr.wrap(i,l).scrollIntoView()),!0):!1}}function ya(n,e=null){return function(t,r){let s=!1;for(let o=0;o<t.selection.ranges.length&&!s;o++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[o];t.doc.nodesBetween(i,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)s=!0;else{let d=t.doc.resolve(c),u=d.index();s=d.parent.canReplaceWith(u,u+1,n)}})}if(!s)return!1;if(r){let o=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];o.setBlockType(l,a,n,e)}r(o.scrollIntoView())}return!0}}function rl(...n){return function(e,t,r){for(let s=0;s<n.length;s++)if(n[s](e,t,r))return!0;return!1}}rl(Zi,Wd,Ud);rl(Zi,Jd,Gd);rl(Xd,Yd,Qd,o1);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function u1(n,e=null){return function(t,r){let{$from:s,$to:o}=t.selection,i=s.blockRange(o);if(!i)return!1;let l=r?t.tr:null;return f1(l,i,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function f1(n,e,t,r=null){let s=!1,o=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=i.resolve(e.start-2);o=new Wr(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Wr(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=Yi(o,t,r,e);return l?(n&&h1(n,e,l,s,t),!0):!1}function h1(n,e,t,r,s){let o=E.empty;for(let d=t.length-1;d>=0;d--)o=E.from(t[d].type.create(t[d].attrs,o));n.step(new ge(e.start-(r?2:0),e.end,e.start,e.end,new R(o,0,0),t.length,!0));let i=0;for(let d=0;d<t.length;d++)t[d].type==s&&(i=d+1);let l=t.length-i,a=e.start+t.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,f=!0;d<u;d++,f=!1)!f&&ot(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function p1(n){return function(e,t){let{$from:r,$to:s}=e.selection,o=r.blockRange(s,i=>i.childCount>0&&i.firstChild.type==n);return o?t?r.node(o.depth-1).type==n?m1(e,t,n,o):g1(e,t,o):!0:!1}}function m1(n,e,t,r){let s=n.tr,o=r.end,i=r.$to.end(r.depth);o<i&&(s.step(new ge(o-1,i,o,i,new R(E.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new Wr(s.doc.resolve(r.$from.pos),s.doc.resolve(i),r.depth));const l=Ln(r);if(l==null)return!1;s.lift(r,l);let a=s.doc.resolve(s.mapping.map(o,-1)-1);return Mt(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function g1(n,e,t){let r=n.tr,s=t.parent;for(let h=t.end,p=t.endIndex-1,y=t.startIndex;p>y;p--)h-=s.child(p).nodeSize,r.delete(h-1,h+1);let o=r.doc.resolve(t.start),i=o.nodeAfter;if(r.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=o.node(-1),d=o.index(-1);if(!c.canReplace(d+(l?0:1),d+1,i.content.append(a?E.empty:E.from(s))))return!1;let u=o.pos,f=u+i.nodeSize;return r.step(new ge(u-(l?1:0),f+(a?1:0),u+1,f-1,new R((l?E.empty:E.from(s.copy(E.empty))).append(a?E.empty:E.from(s.copy(E.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function y1(n){return function(e,t){let{$from:r,$to:s}=e.selection,o=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!o)return!1;let i=o.startIndex;if(i==0)return!1;let l=o.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=E.from(c?n.create():null),u=new R(E.from(n.create(null,E.from(l.type.create(null,d)))),c?3:1,0),f=o.start,h=o.end;t(e.tr.step(new ge(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}const be=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Cn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Yo=null;const rt=function(n,e,t){let r=Yo||(Yo=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},x1=function(){Yo=null},Jt=function(n,e,t,r){return t&&(xa(n,e,t,r,-1)||xa(n,e,t,r,1))},b1=/^(img|br|input|textarea|hr)$/i;function xa(n,e,t,r,s){for(var o;;){if(n==t&&e==r)return!0;if(e==(s<0?0:$e(n))){let i=n.parentNode;if(!i||i.nodeType!=1||mr(n)||b1.test(n.nodeName)||n.contentEditable=="false")return!1;e=be(n)+(s<0?0:1),n=i}else if(n.nodeType==1){let i=n.childNodes[e+(s<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((o=i.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=s;else return!1;else n=i,e=s<0?$e(n):0}else return!1}}function $e(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function k1(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=$e(n)}else if(n.parentNode&&!mr(n))e=be(n),n=n.parentNode;else return null}}function S1(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!mr(n))e=be(n)+1,n=n.parentNode;else return null}}function w1(n,e,t){for(let r=e==0,s=e==$e(n);r||s;){if(n==t)return!0;let o=be(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,s=s&&o==$e(n)}}function mr(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const _s=function(n){return n.focusNode&&Jt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function It(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function v1(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function C1(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min($e(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min($e(r.startContainer),r.startOffset)}}}const Ye=typeof navigator<"u"?navigator:null,ba=typeof document<"u"?document:null,At=Ye&&Ye.userAgent||"",Qo=/Edge\/(\d+)/.exec(At),tu=/MSIE \d/.exec(At),Zo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(At),Oe=!!(tu||Zo||Qo),St=tu?document.documentMode:Zo?+Zo[1]:Qo?+Qo[1]:0,_e=!Oe&&/gecko\/(\d+)/i.test(At);_e&&+(/Firefox\/(\d+)/.exec(At)||[0,0])[1];const ei=!Oe&&/Chrome\/(\d+)/.exec(At),pe=!!ei,nu=ei?+ei[1]:0,Se=!Oe&&!!Ye&&/Apple Computer/.test(Ye.vendor),Nn=Se&&(/Mobile\/\w+/.test(At)||!!Ye&&Ye.maxTouchPoints>2),Le=Nn||(Ye?/Mac/.test(Ye.platform):!1),ru=Ye?/Win/.test(Ye.platform):!1,st=/Android \d/.test(At),gr=!!ba&&"webkitFontSmoothing"in ba.documentElement.style,N1=gr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function E1(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Ze(n,e){return typeof n=="number"?n:n[e]}function T1(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function ka(n,e,t){let r=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let i=t||n.dom;i;){if(i.nodeType!=1){i=Cn(i);continue}let l=i,a=l==o.body,c=a?E1(o):T1(l),d=0,u=0;if(e.top<c.top+Ze(r,"top")?u=-(c.top-e.top+Ze(s,"top")):e.bottom>c.bottom-Ze(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+Ze(s,"top")-c.top:e.bottom-c.bottom+Ze(s,"bottom")),e.left<c.left+Ze(r,"left")?d=-(c.left-e.left+Ze(s,"left")):e.right>c.right-Ze(r,"right")&&(d=e.right-c.right+Ze(s,"right")),d||u)if(a)o.defaultView.scrollBy(d,u);else{let h=l.scrollLeft,p=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let y=l.scrollLeft-h,g=l.scrollTop-p;e={left:e.left-y,top:e.top-g,right:e.right-y,bottom:e.bottom-g}}let f=a?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(f))break;i=f=="absolute"?i.offsetParent:Cn(i)}}function M1(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,s;for(let o=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(o,i);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:su(n.dom)}}function su(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Cn(r));return e}function A1({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;ou(t,r==0?0:r-e)}function ou(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:s,left:o}=n[t];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let fn=null;function O1(n){if(n.setActive)return n.setActive();if(fn)return n.focus(fn);let e=su(n);n.focus(fn==null?{get preventScroll(){return fn={preventScroll:!0},!0}}:void 0),fn||(fn=!1,ou(e,0))}function iu(n,e){let t,r=2e8,s,o=0,i=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let f;if(d.nodeType==1)f=d.getClientRects();else if(d.nodeType==3)f=rt(d).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=i&&p.bottom>=l){i=Math.max(p.bottom,i),l=Math.min(p.top,l);let y=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(y<r){t=d,r=y,s=y&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&y&&(o=u+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(o=u+1)}}return!t&&a&&(t=a,s=c,r=0),t&&t.nodeType==3?I1(t,s):!t||r&&t.nodeType==1?{node:n,offset:o}:iu(t,s)}function I1(n,e){let t=n.nodeValue.length,r=document.createRange(),s;for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let i=ut(r,1);if(i.top!=i.bottom&&sl(e,i)){s={node:n,offset:o+(e.left>=(i.left+i.right)/2?1:0)};break}}return r.detach(),s||{node:n,offset:0}}function sl(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function R1(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function j1(n,e,t){let{node:r,offset:s}=iu(e,t),o=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();o=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(r,s,o)}function D1(n,e,t,r){let s=-1;for(let o=e,i=!1;o!=n.dom;){let l=n.docView.nearestDesc(o,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!i&&a.left>r.left||a.top>r.top?s=l.posBefore:(!i&&a.right<r.left||a.bottom<r.top)&&(s=l.posAfter),i=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function lu(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),o=s;;){let i=n.childNodes[o];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(sl(e,c))return lu(i,e,c)}}if((o=(o+1)%r)==s)break}return n}function P1(n,e){let t=n.dom.ownerDocument,r,s=0,o=C1(t,e.left,e.top);o&&({node:r,offset:s}=o);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!sl(e,c)||(i=lu(n.dom,e,c),!i))return null}if(Se)for(let c=i;r&&c;c=Cn(c))c.draggable&&(r=void 0);if(i=R1(i,e),r){if(_e&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let d=r.childNodes[s],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&s++}let c;gr&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==n.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=D1(n,r,s,e))}l==null&&(l=j1(n,i,e));let a=n.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Sa(n){return n.top<n.bottom||n.left<n.right}function ut(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Sa(r))return r}return Array.prototype.find.call(t,Sa)||n.getBoundingClientRect()}const L1=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function au(n,e,t){let{node:r,offset:s,atom:o}=n.docView.domFromPos(e,t<0?-1:1),i=gr||_e;if(r.nodeType==3)if(i&&(L1.test(r.nodeValue)||(t<0?!s:s==r.nodeValue.length))){let a=ut(rt(r,s,s),t);if(_e&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=ut(rt(r,s-1,s-1),-1);if(c.top==a.top){let d=ut(rt(r,s,s+1),-1);if(d.top!=a.top)return _n(d,d.left<c.left)}}return a}else{let a=s,c=s,d=t<0?1:-1;return t<0&&!s?(c++,d=-1):t>=0&&s==r.nodeValue.length?(a--,d=1):t<0?a--:c++,_n(ut(rt(r,a,c),d),d<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&s&&(t<0||s==$e(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return wo(a.getBoundingClientRect(),!1)}if(o==null&&s<$e(r)){let a=r.childNodes[s];if(a.nodeType==1)return wo(a.getBoundingClientRect(),!0)}return wo(r.getBoundingClientRect(),t>=0)}if(o==null&&s&&(t<0||s==$e(r))){let a=r.childNodes[s-1],c=a.nodeType==3?rt(a,$e(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return _n(ut(c,1),!1)}if(o==null&&s<$e(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?rt(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return _n(ut(c,-1),!0)}return _n(ut(r.nodeType==3?rt(r):r,-t),t>=0)}function _n(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function wo(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function cu(n,e,t){let r=n.state,s=n.root.activeElement;r!=e&&n.updateState(e),s!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),s!=n.dom&&s&&s.focus()}}function $1(n,e,t){let r=e.selection,s=t=="up"?r.$from:r.$to;return cu(n,e,()=>{let{node:o}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let i=au(n,s.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=rt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?i.top-d.top>(d.bottom-i.top)*2:d.bottom-i.bottom>(i.bottom-d.top)*2))return!1}}return!0})}const z1=/[\u0590-\u08ac]/;function _1(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,o=!s,i=s==r.parent.content.size,l=n.domSelection();return l?!z1.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:i:cu(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:y}=n.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==y;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}let wa=null,va=null,Ca=!1;function B1(n,e,t){return wa==e&&va==t?Ca:(wa=e,va=t,Ca=t=="up"||t=="down"?$1(n,e,t):_1(n,e,t))}const Be=0,Na=1,Rt=2,Qe=3;class yr{constructor(e,t,r,s){this.parent=e,this.children=t,this.dom=r,this.contentDOM=s,this.dirty=Be,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let s=this.children[t];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let o,i;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(i)+i.size:this.posAtStart}else{let o,i;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(i):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>be(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!1;break}if(o.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!0;break}if(o.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,s=e;s;s=s.parentNode){let o=this.getDesc(s),i;if(o&&(!t||o.node))if(r&&(i=o.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let s=e;s;s=s.parentNode){let o=this.getDesc(s);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let s=this.children[t],o=r+s.size;if(r==e&&o!=r){for(;!s.border&&s.children.length;)for(let i=0;i<s.children.length;i++){let l=s.children[i];if(l.size){s=l;break}}return s}if(e<o)return s.descAt(e-r-s.border);r=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let o=0;r<this.children.length;r++){let i=this.children[r],l=o+i.size;if(l>e||i instanceof uu){s=e-o;break}o=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof du&&o.side>=0;r--);if(t<=0){let o,i=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,i=!1);return o&&t&&i&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?be(o.dom)+1:0}}else{let o,i=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,i=!1);return o&&i&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?be(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,o=-1;for(let i=r,l=0;;l++){let a=this.children[l],c=i+a.size;if(s==-1&&e<=c){let d=i+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=i;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=be(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){o=be(u.dom);break}t+=u.size}o==-1&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,s=!1){let o=Math.min(e,t),i=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let y=this.children[h],g=p+y.size;if(o>p&&i<g)return y.setSelection(e-p-y.border,t-p-y.border,r,s);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if((_e||Se)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(u=!!(p&&h.nodeValue[p-1]==`
|
|
13
|
+
`),u&&p==h.nodeValue.length)for(let y=h,g;y;y=y.parentNode){if(g=y.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:be(g)+1});break}let x=y.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let y=h.childNodes[p-1];u=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(_e&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||u&&Se)&&Jt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Jt(a.node,a.offset,d.focusNode,d.focusOffset))return;let f=!1;if((c.extend||e==t)&&!(u&&_e)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,s=0;s<this.children.length;s++){let o=this.children[s],i=r+o.size;if(r==i?e<=i&&t>=r:e<i&&t>r){let l=r+o.border,a=i-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==i?Rt:Na,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Qe:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Rt:Qe}r=i}this.dirty=Rt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Rt:Na;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class du extends yr{constructor(e,t,r,s){let o,i=t.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==Be&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class F1 extends yr{constructor(e,t,r,s){super(e,[],t,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Gt extends yr{constructor(e,t,r,s,o){super(e,[],r,s),this.mark=t,this.spec=o}static create(e,t,r,s){let o=s.nodeViews[t.type.name],i=o&&o(t,s,r);return(!i||!i.dom)&&(i=Qt.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Gt(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&Qe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Qe&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Be){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Be}}slice(e,t,r){let s=Gt.create(this.parent,this.mark,!0,r),o=this.children,i=this.size;t<i&&(o=ni(o,t,i,r)),e>0&&(o=ni(o,0,e,r));for(let l=0;l<o.length;l++)o[l].parent=s;return s.children=o,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class wt extends yr{constructor(e,t,r,s,o,i,l,a,c){super(e,[],o,i),this.node=t,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,t,r,s,o,i){let l=o.nodeViews[t.type.name],a,c=l&&l(t,o,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},r,s),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Qt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=pu(d,r,t),c?a=new V1(e,t,r,s,d,u||null,f,c,o,i+1):t.isText?new Bs(e,t,r,s,d,f,o):new wt(e,t,r,s,d,u||null,f,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>E.empty)}return e}matchesNode(e,t,r){return this.dirty==Be&&e.eq(this.node)&&Ur(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,s=t,o=e.composing?this.localCompositionInfo(e,t):null,i=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new W1(this,i&&i.node,e);K1(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e,d):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?Y.none:this.node.child(d).marks,r,e,d),a.placeWidget(c,e,s)},(c,d,u,f)=>{a.syncToMarks(c.marks,r,e,f);let h;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,f,s)||a.addNode(c,d,u,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Rt)&&(i&&this.protectLocalComposition(e,i),fu(this.contentDOM,this.children,e),Nn&&J1(this.dom))}localCompositionInfo(e,t){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof F)||r<t||s>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let i=o.nodeValue,l=G1(this.node.content,i,r-t,s-t);return l<0?null:{node:o,pos:l,text:i}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:s}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new F1(this,o,t,s);e.input.compositionNodes.push(i),this.children=ni(this.children,r,r+s.length,e,i)}update(e,t,r,s){return this.dirty==Qe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,s),!0)}updateInner(e,t,r,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=Be}updateOuterDeco(e){if(Ur(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=hu(this.dom,this.nodeDOM,ti(this.outerDeco,this.node,t),ti(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Ea(n,e,t,r,s){pu(r,e,n);let o=new wt(void 0,n,e,t,r,r,r,s,0);return o.contentDOM&&o.updateChildren(s,0),o}class Bs extends wt{constructor(e,t,r,s,o,i,l){super(e,t,r,s,o,null,i,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,s){return this.dirty==Qe||this.dirty!=Be&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Be||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=Be,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let s=this.node.cut(e,t),o=document.createTextNode(s.text);return new Bs(this.parent,s,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Qe)}get domAtom(){return!1}isText(e){return this.node.text==e}}class uu extends yr{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Be&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class V1 extends wt{constructor(e,t,r,s,o,i,l,a,c,d){super(e,t,r,s,o,i,l,c,d),this.spec=a}update(e,t,r,s){if(this.dirty==Qe)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,s),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,s){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function fu(n,e,t){let r=n.firstChild,s=!1;for(let o=0;o<e.length;o++){let i=e[o],l=i.dom;if(l.parentNode==n){for(;l!=r;)r=Ta(r),s=!0;r=r.nextSibling}else s=!0,n.insertBefore(l,r);if(i instanceof Gt){let a=r?r.previousSibling:n.lastChild;fu(i.contentDOM,i.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Ta(r),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const Kn=function(n){n&&(this.nodeName=n)};Kn.prototype=Object.create(null);const jt=[new Kn];function ti(n,e,t){if(n.length==0)return jt;let r=t?jt[0]:new Kn,s=[r];for(let o=0;o<n.length;o++){let i=n[o].type.attrs;if(i){i.nodeName&&s.push(r=new Kn(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&s.length==1&&s.push(r=new Kn(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return s}function hu(n,e,t,r){if(t==jt&&r==jt)return e;let s=e;for(let o=0;o<r.length;o++){let i=r[o],l=t[o];if(o){let a;l&&l.nodeName==i.nodeName&&s!=n&&(a=s.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=jt[0]),s=a}H1(s,l||jt[0],i)}return s}function H1(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)s.indexOf(r[o])==-1&&n.classList.remove(r[o]);for(let o=0;o<s.length;o++)r.indexOf(s[o])==-1&&n.classList.add(s[o]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function pu(n,e,t){return hu(n,n,jt,ti(e,t,n.nodeType!=1))}function Ur(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Ta(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class W1{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=q1(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,s){let o=0,i=this.stack.length>>1,l=Math.min(i,e.length);for(;o<l&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<i;)this.destroyRest(),this.top.dirty=Be,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;s<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let d=this.index;d<c;d++){let u=this.top.children[d];if(u.matchesMark(e[i])&&!this.isLocked(u.dom)){a=d;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let d=Gt.create(this.top,e[i],t,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,r,s){let o=-1,i;if(s>=this.preMatch.index&&(i=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,r))o=this.top.children.indexOf(i,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,r,s,o){let i=this.top.children[s];return i.dirty==Qe&&i.dom==i.contentDOM&&(i.dirty=Rt),i.update(e,t,r,o)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=t}}updateNextNode(e,t,r,s,o,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof wt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let d=a.dom,u,f=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Qe&&Ur(t,a.outerDeco));if(!f&&a.update(e,t,r,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(u=this.recreateWrapper(a,e,t,r,s,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=Rt,u.updateChildren(s,i+1),u.dirty=Be),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,s,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Ur(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=wt.create(this.top,t,r,s,o,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,s,o){let i=wt.create(this.top,e,t,r,s,o);i.contentDOM&&i.updateChildren(s,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let o=new du(this.top,e,t,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Gt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Bs)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Se||pe)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new uu(this.top,[],r,null);t!=this.top?t.children.push(s):t.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function q1(n,e){let t=e,r=t.children.length,s=n.childCount,o=new Map,i=[];e:for(;s>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof Gt)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(s-1))break;--s,o.set(l,s),i.push(l)}}return{index:s,matched:o,matches:i.reverse()}}function U1(n,e){return n.type.side-e.type.side}function K1(n,e,t,r){let s=e.locals(n),o=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);r(d,s,e.forChild(o,d),c),o+=d.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let d,u;for(;i<s.length&&s[i].to==o;){let g=s[i++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(U1);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<n.childCount)h=c,f=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=o&&l.splice(g--,1);for(;i<s.length&&s[i].from<=o&&s[i].to>o;)l.push(s[i++]);let p=o+f.nodeSize;if(f.isText){let g=p;i<s.length&&s[i].from<g&&(g=s[i].from);for(let x=0;x<l.length;x++)l[x].to<g&&(g=l[x].to);g<p&&(a=f.cut(g-o),f=f.cut(0,g-o),p=g,h=-1)}else for(;i<s.length&&s[i].to<p;)i++;let y=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();r(f,y,e.forChild(o,f),h),o=p}}function J1(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function G1(n,e,t,r){for(let s=0,o=0;s<n.childCount&&o<=r;){let i=n.child(s++),l=o;if(o+=i.nodeSize,!i.isText)continue;let a=i.text;for(;s<n.childCount;){let c=n.child(s++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=t){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function ni(n,e,t,r,s){let o=[];for(let i=0,l=0;i<n.length;i++){let a=n[i],c=l,d=l+=a.size;c>=t||d<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,r)),s&&(o.push(s),s=void 0),d>t&&o.push(a.slice(t-c,a.size,r)))}return o}function ol(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),o=s&&s.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(_s(t)){for(a=i;s&&!s.node;)s=s.parent;let u=s.node;if(s&&u.isAtom&&$.isSelectable(u)&&s.parent&&!(u.isInline&&w1(t.focusNode,t.focusOffset,s.dom))){let f=s.posBefore;c=new $(i==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=i,f=i;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);u=Math.min(u,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,i]=f==n.state.selection.anchor?[f,u]:[u,f],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!o?1:-1;c=il(n,d,l,u)}return c}function mu(n){return n.editable?n.hasFocus():yu(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function it(n,e=!1){let t=n.state.selection;if(gu(n,t),!!mu(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&pe){let r=n.domSelectionRange(),s=n.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Jt(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Y1(n);else{let{anchor:r,head:s}=t,o,i;Ma&&!(t instanceof F)&&(t.$from.parent.inlineContent||(o=Aa(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=Aa(n,t.to))),n.docView.setSelection(r,s,n,e),Ma&&(o&&Oa(o),i&&Oa(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&X1(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Ma=Se||pe&&nu<63;function Aa(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),s=r<t.childNodes.length?t.childNodes[r]:null,o=r?t.childNodes[r-1]:null;if(Se&&s&&s.contentEditable=="false")return vo(s);if((!s||s.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(s)return vo(s);if(o)return vo(o)}}function vo(n){return n.contentEditable="true",Se&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Oa(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function X1(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!mu(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Y1(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,be(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&Oe&&St<=11&&(t.disabled=!0,t.disabled=!1)}function gu(n,e){if(e instanceof $){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Ia(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Ia(n)}function Ia(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function il(n,e,t,r){return n.someProp("createSelectionBetween",s=>s(n,e,t))||F.between(e,t,r)}function Ra(n){return n.editable&&!n.hasFocus()?!1:yu(n)}function yu(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Q1(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Jt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function ri(n,e){let{$anchor:t,$head:r}=n.selection,s=e>0?t.max(r):t.min(r),o=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return o&&q.findFrom(o,e)}function ft(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function ja(n,e,t){let r=n.state.selection;if(r instanceof F)if(t.indexOf("s")>-1){let{$head:s}=r,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=n.state.doc.resolve(s.pos+o.nodeSize*(e<0?-1:1));return ft(n,new F(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=ri(n.state,e);return s&&s instanceof $?ft(n,s):!1}else if(!(Le&&t.indexOf("m")>-1)){let s=r.$head,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,i;if(!o||o.isText)return!1;let l=e<0?s.pos-o.nodeSize:s.pos;return o.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?$.isSelectable(o)?ft(n,new $(e<0?n.state.doc.resolve(s.pos-o.nodeSize):s)):gr?ft(n,new F(n.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof $&&r.node.isInline)return ft(n,new F(e>0?r.$to:r.$from));{let s=ri(n.state,e);return s?ft(n,s):!1}}}function Kr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Jn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function hn(n,e){return e<0?Z1(n):e0(n)}function Z1(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s,o,i=!1;for(_e&&t.nodeType==1&&r<Kr(t)&&Jn(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Jn(l,-1))s=t,o=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(xu(t))break;{let l=t.previousSibling;for(;l&&Jn(l,-1);)s=t.parentNode,o=be(l),l=l.previousSibling;if(l)t=l,r=Kr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?si(n,t,r):s&&si(n,s,o)}function e0(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s=Kr(t),o,i;for(;;)if(r<s){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Jn(l,1))o=t,i=++r;else break}else{if(xu(t))break;{let l=t.nextSibling;for(;l&&Jn(l,1);)o=l.parentNode,i=be(l)+1,l=l.nextSibling;if(l)t=l,r=0,s=Kr(t);else{if(t=t.parentNode,t==n.dom)break;r=s=0}}}o&&si(n,o,i)}function xu(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function t0(n,e){for(;n&&e==n.childNodes.length&&!mr(n);)e=be(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function n0(n,e){for(;n&&!e&&!mr(n);)e=be(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function si(n,e,t){if(e.nodeType!=3){let o,i;(i=t0(e,t))?(e=i,t=0):(o=n0(e,t))&&(e=o,t=o.nodeValue.length)}let r=n.domSelection();if(!r)return;if(_s(r)){let o=document.createRange();o.setEnd(e,t),o.setStart(e,t),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&it(n)},50)}function Da(n,e){let t=n.state.doc.resolve(e);if(!(pe||ru)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left<s.left?"ltr":"rtl"}if(e<t.end()){let o=n.coordsAtPos(e+1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Pa(n,e,t){let r=n.state.selection;if(r instanceof F&&!r.empty||t.indexOf("s")>-1||Le&&t.indexOf("m")>-1)return!1;let{$from:s,$to:o}=r;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=ri(n.state,e);if(i&&i instanceof $)return ft(n,i)}if(!s.parent.inlineContent){let i=e<0?s:o,l=r instanceof je?q.near(i,e):q.findFrom(i,e);return l?ft(n,l):!1}return!1}function La(n,e){if(!(n.state.selection instanceof F))return!0;let{$head:t,$anchor:r,empty:s}=n.state.selection;if(!t.sameParent(r))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let i=n.state.tr;return e<0?i.delete(t.pos-o.nodeSize,t.pos):i.delete(t.pos,t.pos+o.nodeSize),n.dispatch(i),!0}return!1}function $a(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function r0(n){if(!Se||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;$a(n,r,"true"),setTimeout(()=>$a(n,r,"false"),20)}return!1}function s0(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function o0(n,e){let t=e.keyCode,r=s0(e);if(t==8||Le&&t==72&&r=="c")return La(n,-1)||hn(n,-1);if(t==46&&!e.shiftKey||Le&&t==68&&r=="c")return La(n,1)||hn(n,1);if(t==13||t==27)return!0;if(t==37||Le&&t==66&&r=="c"){let s=t==37?Da(n,n.state.selection.from)=="ltr"?-1:1:-1;return ja(n,s,r)||hn(n,s)}else if(t==39||Le&&t==70&&r=="c"){let s=t==39?Da(n,n.state.selection.from)=="ltr"?1:-1:1;return ja(n,s,r)||hn(n,s)}else{if(t==38||Le&&t==80&&r=="c")return Pa(n,-1,r)||hn(n,-1);if(t==40||Le&&t==78&&r=="c")return r0(n)||Pa(n,1,r)||hn(n,1);if(r==(Le?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function ll(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:s,openEnd:o}=e;for(;s>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,o--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=n.someProp("clipboardSerializer")||Qt.fromSchema(n.state.schema),l=Cu(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=vu[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let p=l.createElement(d[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${o}${u?` -${u}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
14
14
|
|
|
15
15
|
`);return{dom:a,text:f,slice:e}}function bu(n,e,t,r,s){let o=s.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=!!e&&(r||o||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,o||r,n)}),o)return l=new R(E.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
16
|
-
`))),0,0),n.someProp("transformPasted",f=>{l=f(l,n,!0)}),l;let u=n.someProp("clipboardTextParser",f=>f(e,s,r,n));if(u)l=u;else{let f=s.marks(),{schema:h}=n.state,p=Qt.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let g=i.appendChild(document.createElement("p"));y&&g.appendChild(p.serializeNode(h.text(y,f)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),i=n0(t),gr&&r0(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||kt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Z1.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=s0(za(l,+d[1],+d[2]),d[4]);else if(l=R.maxOpen(e0(l.content,s),!0),l.openStart||l.openEnd){let u=0,f=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=za(l,u,f)}return n.someProp("transformPasted",u=>{l=u(l,n,a)}),l}const Z1=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function e0(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),o,i=[];if(n.forEach(l=>{if(!i)return;let a=s.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&o.length&&Su(a,o,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=wu(i[i.length-1],o.length));let d=ku(l,a);i.push(d),s=s.matchType(d.type),o=a}}),i)return E.from(i)}return n}function ku(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,E.from(n));return n}function Su(n,e,t,r,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let o=Su(n,e,t,r.lastChild,s+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(s==n.length-1?t.type:n[s+1]))return r.copy(r.content.append(E.from(ku(t,n,s+1))))}}function wu(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,wu(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(E.empty,!0);return n.copy(t.append(r))}function oi(n,e,t,r,s,o){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(o=0),s<r-1&&(l=oi(l,e,t,r,s+1,o)),s>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,o<=s).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(E.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function za(n,e,t){return e<n.openStart&&(n=new R(oi(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new R(oi(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const vu={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let _a=null;function Cu(){return _a||(_a=document.implementation.createHTMLDocument("title"))}let Co=null;function t0(n){let e=window.trustedTypes;return e?(Co||(Co=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Co.createHTML(n)):n}function n0(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Cu().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),s;if((s=r&&vu[r[1].toLowerCase()])&&(n=s.map(o=>"<"+o+">").join("")+n+s.map(o=>"</"+o+">").reverse().join("")),t.innerHTML=t0(n),s)for(let o=0;o<s.length;o++)t=t.querySelector(s[o])||t;return t}function r0(n){let e=n.querySelectorAll(pe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function s0(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:s,openStart:o,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=E.from(a.create(r[l+1],s)),o++,i++}return new R(s,o,i)}const Ee={},Te={},o0={touchstart:!0,touchmove:!0};class i0{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function l0(n){for(let e in Ee){let t=Ee[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{c0(n,r)&&!al(n,r)&&(n.editable||!(r.type in Te))&&t(n,r)},o0[e]?{passive:!0}:void 0)}Ce&&n.dom.addEventListener("input",()=>null),ii(n)}function bt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function a0(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function ii(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>al(n,r))})}function al(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function c0(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function d0(n,e){!al(n,e)&&Ee[e.type]&&(n.editable||!(e.type in Te))&&Ee[e.type](n,e)}Te.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Eu(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(st&&pe&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Nn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",s=>s(n,It(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Q1(n,t)?t.preventDefault():bt(n,"key")};Te.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Te.keypress=(n,e)=>{let t=e;if(Eu(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Le&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof F)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(t.charCode),o=()=>n.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",i=>i(n,r.$from.pos,r.$to.pos,s,o))&&n.dispatch(o()),t.preventDefault()}};function Fs(n){return{left:n.clientX,top:n.clientY}}function u0(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function cl(n,e,t,r,s){if(r==-1)return!1;let o=n.state.doc.resolve(r);for(let i=o.depth+1;i>0;i--)if(n.someProp(e,l=>i>o.depth?l(n,t,o.nodeAfter,o.before(i),s,!0):l(n,t,o.node(i),o.before(i),s,!1)))return!0;return!1}function kn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function f0(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&$.isSelectable(r)?(kn(n,new $(t)),!0):!1}function h0(n,e){if(e==-1)return!1;let t=n.state.selection,r,s;t instanceof $&&(r=t.node);let o=n.state.doc.resolve(e);for(let i=o.depth+1;i>0;i--){let l=i>o.depth?o.nodeAfter:o.node(i);if($.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?s=o.before(t.$from.depth):s=o.before(i);break}}return s!=null?(kn(n,$.create(n.state.doc,s)),!0):!1}function p0(n,e,t,r,s){return cl(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(s?h0(n,t):f0(n,t))}function m0(n,e,t,r){return cl(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",s=>s(n,e,r))}function g0(n,e,t,r){return cl(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",s=>s(n,e,r))||y0(n,t,r)}function y0(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(kn(n,F.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let o=s.depth+1;o>0;o--){let i=o>s.depth?s.nodeAfter:s.node(o),l=s.before(o);if(i.inlineContent)kn(n,F.create(r,l+1,l+1+i.content.size));else if($.isSelectable(i))kn(n,$.create(r,l));else continue;return!0}}function dl(n){return Jr(n)}const Nu=Le?"metaKey":"ctrlKey";Ee.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=dl(n),s=Date.now(),o="singleClick";s-n.input.lastClick.time<500&&u0(t,n.input.lastClick)&&!t[Nu]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:o,button:t.button};let i=n.posAtCoords(Fs(t));i&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new x0(n,i,t,!!r)):(o=="doubleClick"?m0:g0)(n,i.pos,i.inside,t)?t.preventDefault():bt(n,"pointer"))};class x0{constructor(e,t,r,s){this.view=e,this.pos=t,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Nu],this.allowDefault=r.shiftKey;let o,i;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),i=t.inside;else{let d=e.state.doc.resolve(t.pos);o=d.parent,i=d.depth?d.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof $&&c.from<=i&&c.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&_e&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),bt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>it(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Fs(e))),this.updateAllowDefault(e),this.allowDefault||!t?bt(this.view,"pointer"):p0(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ce&&this.mightDrag&&!this.mightDrag.node.isAtom||pe&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(kn(this.view,q.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):bt(this.view,"pointer")}move(e){this.updateAllowDefault(e),bt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Ee.touchstart=n=>{n.input.lastTouch=Date.now(),dl(n),bt(n,"pointer")};Ee.touchmove=n=>{n.input.lastTouch=Date.now(),bt(n,"pointer")};Ee.contextmenu=n=>dl(n);function Eu(n,e){return n.composing?!0:Ce&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const b0=st?5e3:-1;Te.compositionstart=Te.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof F&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||pe&&ru&&k0(n)))n.markCursor=n.state.storedMarks||t.marks(),Jr(n,!0),n.markCursor=null;else if(Jr(n,!e.selection.empty),_e&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let s=r.focusNode,o=r.focusOffset;s&&s.nodeType==1&&o!=0;){let i=o<0?s.lastChild:s.childNodes[o-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else s=i,o=-1}}n.input.composing=!0}Tu(n,b0)};function k0(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}Te.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Tu(n,20))};function Tu(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Jr(n),e))}function Mu(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=w0());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function S0(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=h1(e.focusNode,e.focusOffset),r=p1(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let s=r.pmViewDesc,o=n.domObserver.lastChangedTextNode;if(t==o||r==o)return o;if(!s||!s.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return r}}return t||r}function w0(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Jr(n,e=!1){if(!(st&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Mu(n),e||n.docView&&n.docView.dirty){let t=ol(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function v0(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const ir=Oe&&St<15||Nn&&x1<604;Ee.copy=Te.cut=(n,e)=>{let t=e,r=n.state.selection,s=t.type=="cut";if(r.empty)return;let o=ir?null:t.clipboardData,i=r.content(),{dom:l,text:a}=ll(n,i);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):v0(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function C0(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function N0(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?lr(n,r.value,null,s,e):lr(n,r.textContent,r.innerHTML,s,e)},50)}function lr(n,e,t,r,s){let o=bu(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,o||R.empty)))return!0;if(!o)return!1;let i=C0(o),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(o);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Au(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Te.paste=(n,e)=>{let t=e;if(n.composing&&!st)return;let r=ir?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&lr(n,Au(r),r.getData("text/html"),s,t)?t.preventDefault():N0(n,t)};class Ou{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const E0=Le?"altKey":"ctrlKey";function Iu(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[E0]}Ee.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let s=n.state.selection,o=s.empty?null:n.posAtCoords(Fs(t)),i;if(!(o&&o.pos>=s.from&&o.pos<=(s instanceof $?s.to-1:s.to))){if(r&&r.mightDrag)i=$.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(i=$.create(n.state.doc,u.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:d}=ll(n,l);(!t.dataTransfer.files.length||!pe||nu>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(ir?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",ir||t.dataTransfer.setData("text/plain",c),n.dragging=new Ou(d,Iu(n,t),i)};Ee.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Te.dragover=Te.dragenter=(n,e)=>e.preventDefault();Te.drop=(n,e)=>{try{T0(n,e,n.dragging)}finally{n.dragging=null}};function T0(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(Fs(e));if(!r)return;let s=n.state.doc.resolve(r.pos),o=t&&t.slice;o?n.someProp("transformPasted",h=>{o=h(o,n,!1)}):o=bu(n,Au(e.dataTransfer),ir?null:e.dataTransfer.getData("text/html"),!1,s);let i=!!(t&&Iu(n,e));if(n.someProp("handleDrop",h=>h(n,e,o||R.empty,i))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?Pd(n.state.doc,s.pos,o):s.pos;l==null&&(l=s.pos);let a=n.state.tr;if(i){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,u=a.doc;if(d?a.replaceRangeWith(c,c,o.content.firstChild):a.replaceRange(c,c,o),a.doc.eq(u))return;let f=a.doc.resolve(c);if(d&&$.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new $(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,y,g,x)=>h=x),a.setSelection(il(n,f,a.doc.resolve(h)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}Ee.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&it(n)},20))};Ee.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Ee.beforeinput=(n,e)=>{if(pe&&st&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,It(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in Te)Ee[n]=Te[n];function ar(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Gr{constructor(e,t){this.toDOM=e,this.spec=t||Vt,this.side=this.spec.side||0}map(e,t,r,s){let{pos:o,deleted:i}=e.mapResult(t.from+s,this.side<0?-1:1);return i?null:new ve(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Gr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ar(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class vt{constructor(e,t){this.attrs=e,this.spec=t||Vt}map(e,t,r,s){let o=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-r;return o>=i?null:new ve(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof vt&&ar(this.attrs,e.attrs)&&ar(this.spec,e.spec)}static is(e){return e.type instanceof vt}destroy(){}}class ul{constructor(e,t){this.attrs=e,this.spec=t||Vt}map(e,t,r,s){let o=e.mapResult(t.from+s,1);if(o.deleted)return null;let i=e.mapResult(t.to+s,-1);return i.deleted||i.pos<=o.pos?null:new ve(o.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:s}=e.content.findIndex(t.from),o;return s==t.from&&!(o=e.child(r)).isText&&s+o.nodeSize==t.to}eq(e){return this==e||e instanceof ul&&ar(this.attrs,e.attrs)&&ar(this.spec,e.spec)}destroy(){}}class ve{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new ve(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new ve(e,e,new Gr(t,r))}static inline(e,t,r,s){return new ve(e,t,new vt(r,s))}static node(e,t,r,s){return new ve(e,t,new ul(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof vt}get widget(){return this.type instanceof Gr}}const mn=[],Vt={};class te{constructor(e,t){this.local=e.length?e:mn,this.children=t.length?t:mn}static create(e,t){return t.length?Xr(t,e,0,Vt):we}find(e,t,r){let s=[];return this.findInner(e??0,t??1e9,s,0,r),s}findInner(e,t,r,s,o){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,r,s+l,o)}}map(e,t,r){return this==we||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Vt)}mapInner(e,t,r,s,o){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(t,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?M0(this.children,i||[],e,t,r,s,o):i?new te(i.sort(Ht),mn):we}add(e,t){return t.length?this==we?te.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let s,o=0;e.forEach((l,a)=>{let c=a+r,d;if(d=ju(t,l,c)){for(s||(s=this.children.slice());o<s.length&&s[o]<a;)o+=3;s[o]==a?s[o+2]=s[o+2].addInner(l,d,c+1):s.splice(o,0,a,a+l.nodeSize,Xr(d,l,c+1,Vt)),o+=3}});let i=Ru(o?Du(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new te(i.length?this.local.concat(i).sort(Ht):this.local,s||this.children)}remove(e){return e.length==0||this==we?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,s=this.local;for(let o=0;o<r.length;o+=3){let i,l=r[o]+t,a=r[o+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(i||(i=[])).push(u));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(i,l+1);c!=we?r[o+2]=c:(r.splice(o,3),o-=3)}if(s.length){for(let o=0,i;o<e.length;o++)if(i=e[o])for(let l=0;l<s.length;l++)s[l].eq(i,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new te(s,r):we}forChild(e,t){if(this==we)return this;if(t.isLeaf)return te.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,i=o+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>o&&a.type instanceof vt){let c=Math.max(o,a.from)-o,d=Math.min(i,a.to)-o;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new te(s.sort(Ht),mn);return r?new mt([l,r]):l}return r||we}eq(e){if(this==e)return!0;if(!(e instanceof te)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return fl(this.localsInner(e))}localsInner(e){if(this==we)return mn;if(e.inlineContent||!this.local.some(vt.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof vt||t.push(this.local[r]);return t}forEachSet(e){e(this)}}te.empty=new te([],[]);te.removeOverlap=fl;const we=te.empty;class mt{constructor(e){this.members=e}map(e,t){const r=this.members.map(s=>s.map(e,t,Vt));return mt.from(r)}forChild(e,t){if(t.isLeaf)return te.empty;let r=[];for(let s=0;s<this.members.length;s++){let o=this.members[s].forChild(e,t);o!=we&&(o instanceof mt?r=r.concat(o.members):r.push(o))}return mt.from(r)}eq(e){if(!(e instanceof mt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let s=0;s<this.members.length;s++){let o=this.members[s].localsInner(e);if(o.length)if(!t)t=o;else{r&&(t=t.slice(),r=!1);for(let i=0;i<o.length;i++)t.push(o[i])}}return t?fl(r?t:t.sort(Ht)):mn}static from(e){switch(e.length){case 0:return we;case 1:return e[0];default:return new mt(e.every(t=>t instanceof te)?e:e.reduce((t,r)=>t.concat(r instanceof te?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function M0(n,e,t,r,s,o,i){let l=n.slice();for(let c=0,d=o;c<t.maps.length;c++){let u=0;t.maps[c].forEach((f,h,p,y)=>{let g=y-p-(h-f);for(let x=0;x<l.length;x+=3){let b=l[x+1];if(b<0||f>b+d-u)continue;let S=l[x]+d-u;h>=S?l[x+1]=f<=S?-2:-1:f>=d&&g&&(l[x]+=g,l[x+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(n[c]+o),u=d-s;if(u<0||u>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+o,-1),h=f-s,{index:p,offset:y}=r.content.findIndex(u),g=r.maybeChild(p);if(g&&y==u&&y+g.nodeSize==h){let x=l[c+2].mapInner(t,g,d+1,n[c]+o+1,i);x!=we?(l[c]=u,l[c+1]=h,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=A0(l,n,e,t,s,o,i),d=Xr(c,r,0,i);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,f=0;u<d.children.length;u+=3){let h=d.children[u];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,d.children[u],d.children[u+1],d.children[u+2])}}return new te(e.sort(Ht),l)}function Ru(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let s=n[r];t.push(new ve(s.from+e,s.to+e,s.type))}return t}function A0(n,e,t,r,s,o,i){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(r,s,c);u?t.push(u):i.onRemove&&i.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+o+1);return t}function ju(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,s=null;for(let o=0,i;o<n.length;o++)(i=n[o])&&i.from>t&&i.to<r&&((s||(s=[])).push(i),n[o]=null);return s}function Du(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Xr(n,e,t,r){let s=[],o=!1;e.forEach((l,a)=>{let c=ju(n,l,a+t);if(c){o=!0;let d=Xr(c,l,t+a+1,r);d!=we&&s.push(a,a+l.nodeSize,d)}});let i=Ru(o?Du(n):n,-t).sort(Ht);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||s.length?new te(i,s):we}function Ht(n,e){return n.from-e.from||n.to-e.to}function fl(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let s=t+1;s<e.length;s++){let o=e[s];if(o.from==r.from){o.to!=r.to&&(e==n&&(e=n.slice()),e[s]=o.copy(o.from,r.to),Ba(e,s+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,o.from),Ba(e,s,r.copy(o.from,r.to)));break}}}return e}function Ba(n,e,t){for(;e<n.length&&Ht(t,n[e])>0;)e++;n.splice(e,0,t)}function No(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=we&&e.push(r)}),n.cursorWrapper&&e.push(te.create(n.state.doc,[n.cursorWrapper.deco])),mt.from(e)}const O0={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},I0=Oe&&St<=11;class R0{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class j0{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new R0,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);Oe&&St<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),I0&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,O0)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Ra(this.view)){if(this.suppressingSelectionUpdates)return it(this.view);if(Oe&&St<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Jt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let o=e.focusNode;o;o=Cn(o))t.add(o);for(let o=e.anchorNode;o;o=Cn(o))if(t.has(o)){r=o;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Ra(e)&&!this.ignoreSelectionChange(r),o=-1,i=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(o=o<0?u.from:Math.min(u.from,o),i=i<0?u.to:Math.max(u.to,i),u.typeOver&&(l=!0))}if(_e&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let h=f.parentNode;h&&h.nodeName=="LI"&&(!u||L0(e,u)!=h)&&f.remove()}}}else if((pe||Ce)&&a.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let d of a)if(d.nodeName=="BR"&&d.parentNode){let u=d.nextSibling;u&&u.nodeType==1&&u.contentEditable=="false"&&d.parentNode.removeChild(d)}}let c=null;o<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&_s(r)&&(c=ol(e))&&c.eq(q.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,it(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||s)&&(o>-1&&(e.docView.markDirty(o,i),D0(e)),this.handleDOMChange(o,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||it(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,o=e.nextSibling;if(Oe&&St<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:f}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(o=f)}let i=s&&s.parentNode==e.target?be(s)+1:0,l=r.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?be(o):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Fa=new WeakMap,Va=!1;function D0(n){if(!Fa.has(n)&&(Fa.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=_e,Va)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Va=!0}}function Ha(n,e){let t=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return Jt(i.node,i.offset,s,o)&&([t,r,s,o]=[s,o,t,r]),{anchorNode:t,anchorOffset:r,focusNode:s,focusOffset:o}}function P0(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return Ha(n,s)}let t;function r(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Ha(n,t):null}function L0(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function $0(n,e,t){let{node:r,fromOffset:s,toOffset:o,from:i,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],_s(a)||c.push({node:a.focusNode,offset:a.focusOffset})),pe&&n.input.lastKeyCode===8)for(let g=o;g>s;g--){let x=r.childNodes[g-1],b=x.pmViewDesc;if(x.nodeName=="BR"&&!b){o=g;break}if(!b||b.size)break}let u=n.state.doc,f=n.someProp("domParser")||kt.fromSchema(n.state.schema),h=u.resolve(i),p=null,y=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:o,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:z0,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=g),p={anchor:g+i,head:x+i}}return{doc:y,sel:p,from:i,to:l}}function z0(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Ce&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Ce&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const _0=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function B0(n,e,t,r,s){let o=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let C=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,T=ol(n,C);if(T&&!n.state.selection.eq(T)){if(pe&&st&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",D=>D(n,It(13,"Enter"))))return;let A=n.state.tr.setSelection(T);C=="pointer"?A.setMeta("pointer",!0):C=="key"&&A.scrollIntoView(),o&&A.setMeta("composition",o),n.dispatch(A)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=$0(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=H0(u.content,c.doc.content,c.from,f,h);if(p&&n.input.domChangeCount++,(Nn&&n.input.lastIOSEnter>Date.now()-225||st)&&s.some(C=>C.nodeType==1&&!_0.test(C.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",C=>C(n,It(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof F&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let C=Wa(n,n.state.doc,c.sel);if(C&&!C.eq(n.state.selection)){let T=n.state.tr.setSelection(C);o&&T.setMeta("composition",o),n.dispatch(T)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof F&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),Oe&&St<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let y=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),x=d.resolve(p.start),b=y.sameParent(g)&&y.parent.inlineContent&&x.end()>=p.endA;if((Nn&&n.input.lastIOSEnter>Date.now()-225&&(!b||s.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!b&&y.pos<c.doc.content.size&&(!y.sameParent(g)||!y.parent.inlineContent)&&y.pos<g.pos&&!/\S/.test(c.doc.textBetween(y.pos,g.pos,"","")))&&n.someProp("handleKeyDown",C=>C(n,It(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&V0(d,p.start,p.endA,y,g)&&n.someProp("handleKeyDown",C=>C(n,It(8,"Backspace")))){st&&pe&&n.domObserver.suppressSelectionUpdates();return}pe&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),st&&!b&&y.start()!=g.start()&&g.parentOffset==0&&y.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(C){return C(n,It(13,"Enter"))})},20));let S=p.start,v=p.endA,k=C=>{let T=C||n.state.tr.replace(S,v,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let A=Wa(n,T.doc,c.sel);A&&!(pe&&n.composing&&A.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(A.head==S||A.head==T.mapping.map(v)-1)||Oe&&A.empty&&A.head==S)&&T.setSelection(A)}return o&&T.setMeta("composition",o),T.scrollIntoView()},w;if(b)if(y.pos==g.pos){Oe&&St<=11&&y.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>it(n),20));let C=k(n.state.tr.delete(S,v)),T=d.resolve(p.start).marksAcross(d.resolve(p.endA));T&&C.ensureMarks(T),n.dispatch(C)}else if(p.endA==p.endB&&(w=F0(y.parent.content.cut(y.parentOffset,g.parentOffset),x.parent.content.cut(x.parentOffset,p.endA-x.start())))){let C=k(n.state.tr);w.type=="add"?C.addMark(S,v,w.mark):C.removeMark(S,v,w.mark),n.dispatch(C)}else if(y.parent.child(y.index()).isText&&y.index()==g.index()-(g.textOffset?0:1)){let C=y.parent.textBetween(y.parentOffset,g.parentOffset),T=()=>k(n.state.tr.insertText(C,S,v));n.someProp("handleTextInput",A=>A(n,S,v,C,T))||n.dispatch(T())}else n.dispatch(k());else n.dispatch(k())}function Wa(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:il(n,e.resolve(t.anchor),e.resolve(t.head))}function F0(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,s=t,o=r,i,l,a;for(let d=0;d<r.length;d++)s=r[d].removeFromSet(s);for(let d=0;d<t.length;d++)o=t[d].removeFromSet(o);if(s.length==1&&o.length==0)l=s[0],i="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&o.length==1)l=o[0],i="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(E.from(c).eq(n))return{mark:l,type:i}}function V0(n,e,t,r,s){if(t-e<=s.pos-r.pos||Eo(r,!0,!1)<s.pos)return!1;let o=n.resolve(e);if(!r.parent.isTextblock){let l=o.nodeAfter;return l!=null&&t==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let i=n.resolve(Eo(o,!0,!0));return!i.parent.isTextblock||i.pos>t||Eo(i,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function Eo(n,e,t){let r=n.depth,s=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,s++,e=!1;if(t){let o=n.node(r).maybeChild(n.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,s++}return s}function H0(n,e,t,r,s){let o=n.findDiffStart(e,t);if(o==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,o-Math.min(i,l));r-=i+a-o}if(i<o&&n.size<e.size){let a=r<=o&&r>=i?o-r:0;o-=a,o&&o<e.size&&qa(e.textBetween(o-1,o+1))&&(o+=a?1:-1),l=o+(l-i),i=o}else if(l<o){let a=r<=o&&r>=l?o-r:0;o-=a,o&&o<n.size&&qa(n.textBetween(o-1,o+1))&&(o+=a?1:-1),i=o+(i-l),l=o}return{start:o,endA:i,endB:l}}function qa(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Pu{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new i0,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Xa),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Ja(this),Ka(this),this.nodeViews=Ga(this),this.docView=Ea(this.state.doc,Ua(this),No(this),this.dom,this),this.domObserver=new j0(this,(r,s,o,i)=>B0(this,r,s,o,i)),this.domObserver.start(),l0(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ii(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Xa),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let s=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(Mu(this),i=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Ga(this);q0(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ii(this),this.editable=Ja(this),Ka(this);let a=No(this),c=Ua(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=o||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(s.selection))&&(i=!0);let f=d=="preserve"&&i&&this.dom.style.overflowAnchor==null&&S1(this);if(i){this.domObserver.stop();let h=u&&(Oe||pe)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&W0(s.selection,e.selection);if(u){let p=pe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=S0(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ea(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&q1(this))?it(this,h):(gu(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&w1(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof $){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ka(this,t.getBoundingClientRect(),e)}else ka(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let o=r.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&this.state.doc.nodeAt(o))==r.node&&(s=o)}this.dragging=new Ou(e.slice,e.move,s<0?void 0:$.create(this.state.doc,s))}someProp(e,t){let r=this._props&&this._props[e],s;if(r!=null&&(s=t?t(r):r))return s;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(s=t?t(l):l))return s}let o=this.state.plugins;if(o)for(let i=0;i<o.length;i++){let l=o[i].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(Oe){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&v1(this.dom),it(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return M1(this,e)}coordsAtPos(e,t=1){return au(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let s=this.docView.posFromDOM(e,t,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return j1(this,t||this.state,e)}pasteHTML(e,t){return lr(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return lr(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return ll(this,e)}destroy(){this.docView&&(a0(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],No(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,u1())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return d0(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ce&&this.root.nodeType===11&&g1(this.dom.ownerDocument)==this.dom&&P0(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Pu.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Ua(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[ve.node(0,n.state.doc.content.size,e)]}function Ka(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ve.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Ja(n){return!n.someProp("editable",e=>e(n.state)===!1)}function W0(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Ga(n){let e=Object.create(null);function t(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function q0(n,e){let t=0,r=0;for(let s in n){if(n[s]!=e[s])return!0;t++}for(let s in e)r++;return t!=r}function Xa(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Ct={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Yr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},U0=typeof navigator<"u"&&/Mac/.test(navigator.platform),K0=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ke=0;ke<10;ke++)Ct[48+ke]=Ct[96+ke]=String(ke);for(var ke=1;ke<=24;ke++)Ct[ke+111]="F"+ke;for(var ke=65;ke<=90;ke++)Ct[ke]=String.fromCharCode(ke+32),Yr[ke]=String.fromCharCode(ke);for(var To in Ct)Yr.hasOwnProperty(To)||(Yr[To]=Ct[To]);function J0(n){var e=U0&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||K0&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Yr:Ct)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const G0=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),X0=typeof navigator<"u"&&/Win/.test(navigator.platform);function Y0(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,s,o,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))G0?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),s&&(t="Ctrl-"+t),i&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function Q0(n){let e=Object.create(null);for(let t in n)e[Y0(t)]=n[t];return e}function Mo(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Z0(n){return new re({props:{handleKeyDown:Lu(n)}})}function Lu(n){let e=Q0(n);return function(t,r){let s=J0(r),o,i=e[Mo(s,r)];if(i&&i(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Mo(s,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(X0&&r.ctrlKey&&r.altKey)&&(o=Ct[r.keyCode])&&o!=s){let l=e[Mo(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var ey=Object.defineProperty,hl=(n,e)=>{for(var t in e)ey(n,t,{get:e[t],enumerable:!0})};function Vs(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:s}=t,{storedMarks:o}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return s},get tr(){return r=t.selection,s=t.doc,o=t.storedMarks,t}}}var Hs=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:n,editor:e,state:t}=this,{view:r}=e,{tr:s}=t,o=this.buildProps(s);return Object.fromEntries(Object.entries(n).map(([i,l])=>[i,(...c)=>{const d=l(...c)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){const{rawCommands:t,editor:r,state:s}=this,{view:o}=r,i=[],l=!!n,a=n||s.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(a),i.every(u=>u===!0)),d={...Object.fromEntries(Object.entries(t).map(([u,f])=>[u,(...p)=>{const y=this.buildProps(a,e),g=f(...p)(y);return i.push(g),d}])),run:c};return d}createCan(n){const{rawCommands:e,state:t}=this,r=!1,s=n||t.tr,o=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(n,e=!0){const{rawCommands:t,editor:r,state:s}=this,{view:o}=r,i={tr:n,editor:r,view:o,state:Vs({state:s,transaction:n}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(n,e),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...c)=>a(...c)(i)]))}};return i}},$u={};hl($u,{blur:()=>ty,clearContent:()=>ny,clearNodes:()=>ry,command:()=>sy,createParagraphNear:()=>oy,cut:()=>iy,deleteCurrentNode:()=>ly,deleteNode:()=>ay,deleteRange:()=>cy,deleteSelection:()=>dy,enter:()=>uy,exitCode:()=>fy,extendMarkRange:()=>hy,first:()=>py,focus:()=>gy,forEach:()=>yy,insertContent:()=>xy,insertContentAt:()=>Sy,joinBackward:()=>Cy,joinDown:()=>vy,joinForward:()=>Ny,joinItemBackward:()=>Ey,joinItemForward:()=>Ty,joinTextblockBackward:()=>My,joinTextblockForward:()=>Ay,joinUp:()=>wy,keyboardShortcut:()=>Iy,lift:()=>Ry,liftEmptyBlock:()=>jy,liftListItem:()=>Dy,newlineInCode:()=>Py,resetAttributes:()=>Ly,scrollIntoView:()=>$y,selectAll:()=>zy,selectNodeBackward:()=>_y,selectNodeForward:()=>By,selectParentNode:()=>Fy,selectTextblockEnd:()=>Vy,selectTextblockStart:()=>Hy,setContent:()=>Wy,setMark:()=>dx,setMeta:()=>ux,setNode:()=>fx,setNodeSelection:()=>hx,setTextDirection:()=>px,setTextSelection:()=>mx,sinkListItem:()=>gx,splitBlock:()=>yx,splitListItem:()=>xx,toggleList:()=>bx,toggleMark:()=>kx,toggleNode:()=>Sx,toggleWrap:()=>wx,undoInputRule:()=>vx,unsetAllMarks:()=>Cx,unsetMark:()=>Nx,unsetTextDirection:()=>Ex,updateAttributes:()=>Tx,wrapIn:()=>Mx,wrapInList:()=>Ax});var ty=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())==null||t.removeAllRanges())}),!0),ny=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),ry=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:s}=r;return t&&s.forEach(({$from:o,$to:i})=>{n.doc.nodesBetween(o.pos,i.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(a)),f=c.resolve(d.map(a+l.nodeSize)),h=u.blockRange(f);if(!h)return;const p=Ln(h);if(l.type.isTextblock){const{defaultType:y}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,y)}(p||p===0)&&e.lift(h,p)})}),!0},sy=n=>e=>n(e),oy=()=>({state:n,dispatch:e})=>Yd(n,e),iy=(n,e)=>({editor:t,tr:r})=>{const{state:s}=t,o=s.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const i=r.mapping.map(e);return r.insert(i,o.content),r.setSelection(new F(r.doc.resolve(Math.max(i-1,0)))),!0},ly=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const s=n.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===r.type){if(e){const l=s.before(o),a=s.after(o);n.delete(l,a).scrollIntoView()}return!0}return!1};function ue(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}var ay=n=>({tr:e,state:t,dispatch:r})=>{const s=ue(n,t.schema),o=e.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===s){if(r){const a=o.before(i),c=o.after(i);e.delete(a,c).scrollIntoView()}return!0}return!1},cy=n=>({tr:e,dispatch:t})=>{const{from:r,to:s}=n;return t&&e.delete(r,s),!0},dy=()=>({state:n,dispatch:e})=>Zi(n,e),uy=()=>({commands:n})=>n.keyboardShortcut("Enter"),fy=()=>({state:n,dispatch:e})=>Xg(n,e);function pl(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function Qr(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>t.strict?e[s]===n[s]:pl(e[s])?e[s].test(n[s]):e[s]===n[s]):!0}function zu(n,e,t={}){return n.find(r=>r.type===e&&Qr(Object.fromEntries(Object.keys(t).map(s=>[s,r.attrs[s]])),t))}function Ya(n,e,t={}){return!!zu(n,e,t)}function ml(n,e,t){var r;if(!n||!e)return;let s=n.parent.childAfter(n.parentOffset);if((!s.node||!s.node.marks.some(d=>d.type===e))&&(s=n.parent.childBefore(n.parentOffset)),!s.node||!s.node.marks.some(d=>d.type===e)||(t=t||((r=s.node.marks[0])==null?void 0:r.attrs),!zu([...s.node.marks],e,t)))return;let i=s.index,l=n.start()+s.offset,a=i+1,c=l+s.node.nodeSize;for(;i>0&&Ya([...n.parent.child(i-1).marks],e,t);)i-=1,l-=n.parent.child(i).nodeSize;for(;a<n.parent.childCount&&Ya([...n.parent.child(a).marks],e,t);)c+=n.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function lt(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}var hy=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const o=lt(n,r.schema),{doc:i,selection:l}=t,{$from:a,from:c,to:d}=l;if(s){const u=ml(a,o,e);if(u&&u.from<=c&&u.to>=d){const f=F.create(i,u.from,u.to);t.setSelection(f)}}return!0},py=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function _u(n){return n instanceof F}function Dt(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function Bu(n,e=null){if(!e)return null;const t=q.atStart(n),r=q.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const s=t.from,o=r.to;return e==="all"?F.create(n,Dt(0,s,o),Dt(n.content.size,s,o)):F.create(n,Dt(e,s,o),Dt(e,s,o))}function li(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function cr(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function my(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var gy=(n=null,e={})=>({editor:t,view:r,tr:s,dispatch:o})=>{e={scrollIntoView:!0,...e};const i=()=>{(cr()||li())&&r.dom.focus(),my()&&!cr()&&!li()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(o&&n===null&&!_u(t.state.selection))return i(),!0;const l=Bu(s.doc,n)||t.state.selection,a=t.state.selection.eq(l);return o&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),i()),!0},yy=(n,e)=>t=>n.every((r,s)=>e(r,{...t,index:s})),xy=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),Fu=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&Fu(r)}return n};function Cr(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return Fu(t)}function dr(n,e,t){if(n instanceof ze||n instanceof E)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,s=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return E.fromArray(n.map(l=>e.nodeFromJSON(l)));const i=e.nodeFromJSON(n);return t.errorOnInvalidContent&&i.check(),i}catch(o){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",o),dr("",e,t)}if(s){if(t.errorOnInvalidContent){let i=!1,l="";const a=new Cd({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(i=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?kt.fromSchema(a).parseSlice(Cr(n),t.parseOptions):kt.fromSchema(a).parse(Cr(n),t.parseOptions),t.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const o=kt.fromSchema(e);return t.slice?o.parseSlice(Cr(n),t.parseOptions).content:o.parse(Cr(n),t.parseOptions)}return dr("",e,t)}function by(n,e,t){const r=n.steps.length-1;if(r<e)return;const s=n.steps[r];if(!(s instanceof he||s instanceof ge))return;const o=n.mapping.maps[r];let i=0;o.forEach((l,a,c,d)=>{i===0&&(i=d)}),n.setSelection(q.near(n.doc.resolve(i),t))}var ky=n=>!("type"in n),Sy=(n,e,t)=>({tr:r,dispatch:s,editor:o})=>{var i;if(s){t={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=g=>{o.emit("contentError",{editor:o,error:g,disableCollaboration:()=>{"collaboration"in o.storage&&typeof o.storage.collaboration=="object"&&o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{dr(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=dr(e,o.schema,{parseOptions:c,errorOnInvalidContent:(i=t.errorOnInvalidContent)!=null?i:o.options.enableContentCheck})}catch(g){return a(g),!1}let{from:d,to:u}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},f=!0,h=!0;if((ky(l)?l:[l]).forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),d===u&&h){const{parent:g}=r.doc.resolve(d);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(d-=1,u+=1)}let y;if(f){if(Array.isArray(e))y=e.map(g=>g.text||"").join("");else if(e instanceof E){let g="";e.forEach(x=>{x.text&&(g+=x.text)}),y=g}else typeof e=="object"&&e&&e.text?y=e.text:y=e;r.insertText(y,d,u)}else{y=l;const g=r.doc.resolve(d),x=g.node(),b=g.parentOffset===0,S=x.isText||x.isTextblock,v=x.content.size>0;b&&S&&v&&(d=Math.max(0,d-1)),r.replaceWith(d,u,y)}t.updateSelection&&by(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:y}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:y})}return!0},wy=()=>({state:n,dispatch:e})=>Kg(n,e),vy=()=>({state:n,dispatch:e})=>Jg(n,e),Cy=()=>({state:n,dispatch:e})=>Wd(n,e),Ny=()=>({state:n,dispatch:e})=>Jd(n,e),Ey=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Ls(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Ty=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Ls(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},My=()=>({state:n,dispatch:e})=>qg(n,e),Ay=()=>({state:n,dispatch:e})=>Ug(n,e);function Vu(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Oy(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,s,o,i;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))cr()||Vu()?i=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),s&&(t=`Ctrl-${t}`),i&&(t=`Meta-${t}`),o&&(t=`Shift-${t}`),t}var Iy=n=>({editor:e,view:t,tr:r,dispatch:s})=>{const o=Oy(n).split(/-(?!$)/),i=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a?.steps.forEach(c=>{const d=c.map(r.mapping);d&&s&&r.maybeStep(d)}),!0};function Nt(n,e,t={}){const{from:r,to:s,empty:o}=n.selection,i=e?ue(e,n.schema):null,l=[];n.doc.nodesBetween(r,s,(u,f)=>{if(u.isText)return;const h=Math.max(r,f),p=Math.min(s,f+u.nodeSize);l.push({node:u,from:h,to:p})});const a=s-r,c=l.filter(u=>i?i.name===u.node.type.name:!0).filter(u=>Qr(u.node.attrs,t,{strict:!1}));return o?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=a}var Ry=(n,e={})=>({state:t,dispatch:r})=>{const s=ue(n,t.schema);return Nt(t,s,e)?Gg(t,r):!1},jy=()=>({state:n,dispatch:e})=>Qd(n,e),Dy=n=>({state:e,dispatch:t})=>{const r=ue(n,e.schema);return l1(r)(e,t)},Py=()=>({state:n,dispatch:e})=>Xd(n,e);function Ws(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Qa(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,s)=>(t.includes(s)||(r[s]=n[s]),r),{})}var Ly=(n,e)=>({tr:t,state:r,dispatch:s})=>{let o=null,i=null;const l=Ws(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(o=ue(n,r.schema)),l==="mark"&&(i=lt(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(d,u)=>{o&&o===d.type&&(a=!0,s&&t.setNodeMarkup(u,void 0,Qa(d.attrs,e))),i&&d.marks.length&&d.marks.forEach(f=>{i===f.type&&(a=!0,s&&t.addMark(u,u+d.nodeSize,i.create(Qa(f.attrs,e))))})})}),a},$y=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),zy=()=>({tr:n,dispatch:e})=>{if(e){const t=new je(n.doc);n.setSelection(t)}return!0},_y=()=>({state:n,dispatch:e})=>Ud(n,e),By=()=>({state:n,dispatch:e})=>Gd(n,e),Fy=()=>({state:n,dispatch:e})=>Zg(n,e),Vy=()=>({state:n,dispatch:e})=>n1(n,e),Hy=()=>({state:n,dispatch:e})=>t1(n,e);function ai(n,e,t={},r={}){return dr(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var Wy=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:r={}}={})=>({editor:s,tr:o,dispatch:i,commands:l})=>{const{doc:a}=o;if(r.preserveWhitespace!=="full"){const c=ai(n,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return i&&o.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!t),!0}return i&&o.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:a.content.size},n,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function Hu(n,e){const t=lt(e,n.schema),{from:r,to:s,empty:o}=n.selection,i=[];o?(n.storedMarks&&i.push(...n.storedMarks),i.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,s,a=>{i.push(...a.marks)});const l=i.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function Wu(n,e){const t=new Bd(n);return e.forEach(r=>{r.steps.forEach(s=>{t.step(s)})}),t}function qy(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function Uy(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(s,o)=>{t(s)&&r.push({node:s,pos:o})}),r}function Ky(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function qs(n){return e=>Ky(e.$from,n)}function L(n,e,t){return n.config[e]===void 0&&n.parent?L(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?L(n.parent,e,t):null}):n.config[e]}function gl(n){return n.map(e=>{const t={name:e.name,options:e.options,storage:e.storage},r=L(e,"addExtensions",t);return r?[e,...gl(r())]:e}).flat(10)}function yl(n,e){const t=Qt.fromSchema(e).serializeFragment(n),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(t),s.innerHTML}function qu(n){return typeof n=="function"}function G(n,e=void 0,...t){return qu(n)?e?n.bind(e)(...t):n(...t):n}function Jy(n={}){return Object.keys(n).length===0&&n.constructor===Object}function En(n){const e=n.filter(s=>s.type==="extension"),t=n.filter(s=>s.type==="node"),r=n.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Uu(n){const e=[],{nodeExtensions:t,markExtensions:r}=En(n),s=[...t,...r],o={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(i=>{const l={name:i.name,options:i.options,storage:i.storage,extensions:s},a=L(i,"addGlobalAttributes",l);if(!a)return;a().forEach(d=>{d.types.forEach(u=>{Object.entries(d.attributes).forEach(([f,h])=>{e.push({type:u,name:f,attribute:{...o,...h}})})})})}),s.forEach(i=>{const l={name:i.name,options:i.options,storage:i.storage},a=L(i,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([d,u])=>{const f={...o,...u};typeof f?.default=="function"&&(f.default=f.default()),f?.isRequired&&f?.default===void 0&&delete f.default,e.push({type:i.name,name:d,attribute:f})})}),e}function ne(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([s,o])=>{if(!r[s]){r[s]=o;return}if(s==="class"){const l=o?String(o).split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(d=>!a.includes(d));r[s]=[...a,...c].join(" ")}else if(s==="style"){const l=o?o.split(";").map(d=>d.trim()).filter(Boolean):[],a=r[s]?r[s].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;a.forEach(d=>{const[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),l.forEach(d=>{const[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),r[s]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else r[s]=o}),r},{})}function Tn(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>ne(t,r),{})}function Gy(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Za(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const s=e.reduce((o,i)=>{const l=i.attribute.parseHTML?i.attribute.parseHTML(t):Gy(t.getAttribute(i.name));return l==null?o:{...o,[i.name]:l}},{});return{...r,...s}}}}function ec(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&Jy(t)?!1:t!=null))}function tc(n){var e,t;const r={};return!((e=n?.attribute)!=null&&e.isRequired)&&"default"in(n?.attribute||{})&&(r.default=n.attribute.default),((t=n?.attribute)==null?void 0:t.validate)!==void 0&&(r.validate=n.attribute.validate),[n.name,r]}function Xy(n,e){var t;const r=Uu(n),{nodeExtensions:s,markExtensions:o}=En(n),i=(t=s.find(c=>L(c,"topNode")))==null?void 0:t.name,l=Object.fromEntries(s.map(c=>{const d=r.filter(x=>x.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((x,b)=>{const S=L(b,"extendNodeSchema",u);return{...x,...S?S(c):{}}},{}),h=ec({...f,content:G(L(c,"content",u)),marks:G(L(c,"marks",u)),group:G(L(c,"group",u)),inline:G(L(c,"inline",u)),atom:G(L(c,"atom",u)),selectable:G(L(c,"selectable",u)),draggable:G(L(c,"draggable",u)),code:G(L(c,"code",u)),whitespace:G(L(c,"whitespace",u)),linebreakReplacement:G(L(c,"linebreakReplacement",u)),defining:G(L(c,"defining",u)),isolating:G(L(c,"isolating",u)),attrs:Object.fromEntries(d.map(tc))}),p=G(L(c,"parseHTML",u));p&&(h.parseDOM=p.map(x=>Za(x,d)));const y=L(c,"renderHTML",u);y&&(h.toDOM=x=>y({node:x,HTMLAttributes:Tn(x,d)}));const g=L(c,"renderText",u);return g&&(h.toText=g),[c.name,h]})),a=Object.fromEntries(o.map(c=>{const d=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((g,x)=>{const b=L(x,"extendMarkSchema",u);return{...g,...b?b(c):{}}},{}),h=ec({...f,inclusive:G(L(c,"inclusive",u)),excludes:G(L(c,"excludes",u)),group:G(L(c,"group",u)),spanning:G(L(c,"spanning",u)),code:G(L(c,"code",u)),attrs:Object.fromEntries(d.map(tc))}),p=G(L(c,"parseHTML",u));p&&(h.parseDOM=p.map(g=>Za(g,d)));const y=L(c,"renderHTML",u);return y&&(h.toDOM=g=>y({mark:g,HTMLAttributes:Tn(g,d)})),[c.name,h]}));return new Cd({topNode:i,nodes:l,marks:a})}function Yy(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}function Zr(n){return n.sort((t,r)=>{const s=L(t,"priority")||100,o=L(r,"priority")||100;return s>o?-1:s<o?1:0})}function Ku(n){const e=Zr(gl(n)),t=Yy(e.map(r=>r.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Ju(n,e,t){const{from:r,to:s}=e,{blockSeparator:o=`
|
|
16
|
+
`))),0,0),n.someProp("transformPasted",f=>{l=f(l,n,!0)}),l;let u=n.someProp("clipboardTextParser",f=>f(e,s,r,n));if(u)l=u;else{let f=s.marks(),{schema:h}=n.state,p=Qt.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let g=i.appendChild(document.createElement("p"));y&&g.appendChild(p.serializeNode(h.text(y,f)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),i=c0(t),gr&&d0(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||kt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!i0.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=u0(za(l,+d[1],+d[2]),d[4]);else if(l=R.maxOpen(l0(l.content,s),!0),l.openStart||l.openEnd){let u=0,f=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=za(l,u,f)}return n.someProp("transformPasted",u=>{l=u(l,n,a)}),l}const i0=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function l0(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),o,i=[];if(n.forEach(l=>{if(!i)return;let a=s.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&o.length&&Su(a,o,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=wu(i[i.length-1],o.length));let d=ku(l,a);i.push(d),s=s.matchType(d.type),o=a}}),i)return E.from(i)}return n}function ku(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,E.from(n));return n}function Su(n,e,t,r,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let o=Su(n,e,t,r.lastChild,s+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(s==n.length-1?t.type:n[s+1]))return r.copy(r.content.append(E.from(ku(t,n,s+1))))}}function wu(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,wu(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(E.empty,!0);return n.copy(t.append(r))}function oi(n,e,t,r,s,o){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(o=0),s<r-1&&(l=oi(l,e,t,r,s+1,o)),s>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,o<=s).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(E.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function za(n,e,t){return e<n.openStart&&(n=new R(oi(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new R(oi(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const vu={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let _a=null;function Cu(){return _a||(_a=document.implementation.createHTMLDocument("title"))}let Co=null;function a0(n){let e=window.trustedTypes;return e?(Co||(Co=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Co.createHTML(n)):n}function c0(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Cu().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),s;if((s=r&&vu[r[1].toLowerCase()])&&(n=s.map(o=>"<"+o+">").join("")+n+s.map(o=>"</"+o+">").reverse().join("")),t.innerHTML=a0(n),s)for(let o=0;o<s.length;o++)t=t.querySelector(s[o])||t;return t}function d0(n){let e=n.querySelectorAll(pe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function u0(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:s,openStart:o,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=E.from(a.create(r[l+1],s)),o++,i++}return new R(s,o,i)}const Ee={},Te={},f0={touchstart:!0,touchmove:!0};class h0{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function p0(n){for(let e in Ee){let t=Ee[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{g0(n,r)&&!al(n,r)&&(n.editable||!(r.type in Te))&&t(n,r)},f0[e]?{passive:!0}:void 0)}Se&&n.dom.addEventListener("input",()=>null),ii(n)}function bt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function m0(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function ii(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>al(n,r))})}function al(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function g0(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function y0(n,e){!al(n,e)&&Ee[e.type]&&(n.editable||!(e.type in Te))&&Ee[e.type](n,e)}Te.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Eu(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(st&&pe&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Nn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",s=>s(n,It(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||o0(n,t)?t.preventDefault():bt(n,"key")};Te.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Te.keypress=(n,e)=>{let t=e;if(Eu(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Le&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof F)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(t.charCode),o=()=>n.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",i=>i(n,r.$from.pos,r.$to.pos,s,o))&&n.dispatch(o()),t.preventDefault()}};function Fs(n){return{left:n.clientX,top:n.clientY}}function x0(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function cl(n,e,t,r,s){if(r==-1)return!1;let o=n.state.doc.resolve(r);for(let i=o.depth+1;i>0;i--)if(n.someProp(e,l=>i>o.depth?l(n,t,o.nodeAfter,o.before(i),s,!0):l(n,t,o.node(i),o.before(i),s,!1)))return!0;return!1}function kn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function b0(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&$.isSelectable(r)?(kn(n,new $(t)),!0):!1}function k0(n,e){if(e==-1)return!1;let t=n.state.selection,r,s;t instanceof $&&(r=t.node);let o=n.state.doc.resolve(e);for(let i=o.depth+1;i>0;i--){let l=i>o.depth?o.nodeAfter:o.node(i);if($.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?s=o.before(t.$from.depth):s=o.before(i);break}}return s!=null?(kn(n,$.create(n.state.doc,s)),!0):!1}function S0(n,e,t,r,s){return cl(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(s?k0(n,t):b0(n,t))}function w0(n,e,t,r){return cl(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",s=>s(n,e,r))}function v0(n,e,t,r){return cl(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",s=>s(n,e,r))||C0(n,t,r)}function C0(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(kn(n,F.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let o=s.depth+1;o>0;o--){let i=o>s.depth?s.nodeAfter:s.node(o),l=s.before(o);if(i.inlineContent)kn(n,F.create(r,l+1,l+1+i.content.size));else if($.isSelectable(i))kn(n,$.create(r,l));else continue;return!0}}function dl(n){return Jr(n)}const Nu=Le?"metaKey":"ctrlKey";Ee.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=dl(n),s=Date.now(),o="singleClick";s-n.input.lastClick.time<500&&x0(t,n.input.lastClick)&&!t[Nu]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:o,button:t.button};let i=n.posAtCoords(Fs(t));i&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new N0(n,i,t,!!r)):(o=="doubleClick"?w0:v0)(n,i.pos,i.inside,t)?t.preventDefault():bt(n,"pointer"))};class N0{constructor(e,t,r,s){this.view=e,this.pos=t,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Nu],this.allowDefault=r.shiftKey;let o,i;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),i=t.inside;else{let d=e.state.doc.resolve(t.pos);o=d.parent,i=d.depth?d.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof $&&c.from<=i&&c.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&_e&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),bt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>it(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Fs(e))),this.updateAllowDefault(e),this.allowDefault||!t?bt(this.view,"pointer"):S0(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Se&&this.mightDrag&&!this.mightDrag.node.isAtom||pe&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(kn(this.view,q.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):bt(this.view,"pointer")}move(e){this.updateAllowDefault(e),bt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Ee.touchstart=n=>{n.input.lastTouch=Date.now(),dl(n),bt(n,"pointer")};Ee.touchmove=n=>{n.input.lastTouch=Date.now(),bt(n,"pointer")};Ee.contextmenu=n=>dl(n);function Eu(n,e){return n.composing?!0:Se&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const E0=st?5e3:-1;Te.compositionstart=Te.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof F&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||pe&&ru&&T0(n)))n.markCursor=n.state.storedMarks||t.marks(),Jr(n,!0),n.markCursor=null;else if(Jr(n,!e.selection.empty),_e&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let s=r.focusNode,o=r.focusOffset;s&&s.nodeType==1&&o!=0;){let i=o<0?s.lastChild:s.childNodes[o-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else s=i,o=-1}}n.input.composing=!0}Tu(n,E0)};function T0(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}Te.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Tu(n,20))};function Tu(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Jr(n),e))}function Mu(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=A0());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function M0(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=k1(e.focusNode,e.focusOffset),r=S1(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let s=r.pmViewDesc,o=n.domObserver.lastChangedTextNode;if(t==o||r==o)return o;if(!s||!s.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return r}}return t||r}function A0(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Jr(n,e=!1){if(!(st&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Mu(n),e||n.docView&&n.docView.dirty){let t=ol(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function O0(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const ir=Oe&&St<15||Nn&&N1<604;Ee.copy=Te.cut=(n,e)=>{let t=e,r=n.state.selection,s=t.type=="cut";if(r.empty)return;let o=ir?null:t.clipboardData,i=r.content(),{dom:l,text:a}=ll(n,i);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):O0(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function I0(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function R0(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?lr(n,r.value,null,s,e):lr(n,r.textContent,r.innerHTML,s,e)},50)}function lr(n,e,t,r,s){let o=bu(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,o||R.empty)))return!0;if(!o)return!1;let i=I0(o),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(o);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Au(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Te.paste=(n,e)=>{let t=e;if(n.composing&&!st)return;let r=ir?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&lr(n,Au(r),r.getData("text/html"),s,t)?t.preventDefault():R0(n,t)};class Ou{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const j0=Le?"altKey":"ctrlKey";function Iu(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[j0]}Ee.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let s=n.state.selection,o=s.empty?null:n.posAtCoords(Fs(t)),i;if(!(o&&o.pos>=s.from&&o.pos<=(s instanceof $?s.to-1:s.to))){if(r&&r.mightDrag)i=$.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(i=$.create(n.state.doc,u.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:d}=ll(n,l);(!t.dataTransfer.files.length||!pe||nu>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(ir?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",ir||t.dataTransfer.setData("text/plain",c),n.dragging=new Ou(d,Iu(n,t),i)};Ee.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Te.dragover=Te.dragenter=(n,e)=>e.preventDefault();Te.drop=(n,e)=>{try{D0(n,e,n.dragging)}finally{n.dragging=null}};function D0(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(Fs(e));if(!r)return;let s=n.state.doc.resolve(r.pos),o=t&&t.slice;o?n.someProp("transformPasted",h=>{o=h(o,n,!1)}):o=bu(n,Au(e.dataTransfer),ir?null:e.dataTransfer.getData("text/html"),!1,s);let i=!!(t&&Iu(n,e));if(n.someProp("handleDrop",h=>h(n,e,o||R.empty,i))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?Pd(n.state.doc,s.pos,o):s.pos;l==null&&(l=s.pos);let a=n.state.tr;if(i){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,u=a.doc;if(d?a.replaceRangeWith(c,c,o.content.firstChild):a.replaceRange(c,c,o),a.doc.eq(u))return;let f=a.doc.resolve(c);if(d&&$.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new $(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,y,g,x)=>h=x),a.setSelection(il(n,f,a.doc.resolve(h)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}Ee.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&it(n)},20))};Ee.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Ee.beforeinput=(n,e)=>{if(pe&&st&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,It(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in Te)Ee[n]=Te[n];function ar(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Gr{constructor(e,t){this.toDOM=e,this.spec=t||Vt,this.side=this.spec.side||0}map(e,t,r,s){let{pos:o,deleted:i}=e.mapResult(t.from+s,this.side<0?-1:1);return i?null:new Ce(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Gr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ar(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class vt{constructor(e,t){this.attrs=e,this.spec=t||Vt}map(e,t,r,s){let o=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-r;return o>=i?null:new Ce(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof vt&&ar(this.attrs,e.attrs)&&ar(this.spec,e.spec)}static is(e){return e.type instanceof vt}destroy(){}}class ul{constructor(e,t){this.attrs=e,this.spec=t||Vt}map(e,t,r,s){let o=e.mapResult(t.from+s,1);if(o.deleted)return null;let i=e.mapResult(t.to+s,-1);return i.deleted||i.pos<=o.pos?null:new Ce(o.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:s}=e.content.findIndex(t.from),o;return s==t.from&&!(o=e.child(r)).isText&&s+o.nodeSize==t.to}eq(e){return this==e||e instanceof ul&&ar(this.attrs,e.attrs)&&ar(this.spec,e.spec)}destroy(){}}class Ce{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new Ce(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new Ce(e,e,new Gr(t,r))}static inline(e,t,r,s){return new Ce(e,t,new vt(r,s))}static node(e,t,r,s){return new Ce(e,t,new ul(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof vt}get widget(){return this.type instanceof Gr}}const mn=[],Vt={};class te{constructor(e,t){this.local=e.length?e:mn,this.children=t.length?t:mn}static create(e,t){return t.length?Xr(t,e,0,Vt):ve}find(e,t,r){let s=[];return this.findInner(e??0,t??1e9,s,0,r),s}findInner(e,t,r,s,o){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,r,s+l,o)}}map(e,t,r){return this==ve||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Vt)}mapInner(e,t,r,s,o){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(t,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?P0(this.children,i||[],e,t,r,s,o):i?new te(i.sort(Ht),mn):ve}add(e,t){return t.length?this==ve?te.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let s,o=0;e.forEach((l,a)=>{let c=a+r,d;if(d=ju(t,l,c)){for(s||(s=this.children.slice());o<s.length&&s[o]<a;)o+=3;s[o]==a?s[o+2]=s[o+2].addInner(l,d,c+1):s.splice(o,0,a,a+l.nodeSize,Xr(d,l,c+1,Vt)),o+=3}});let i=Ru(o?Du(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new te(i.length?this.local.concat(i).sort(Ht):this.local,s||this.children)}remove(e){return e.length==0||this==ve?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,s=this.local;for(let o=0;o<r.length;o+=3){let i,l=r[o]+t,a=r[o+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(i||(i=[])).push(u));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(i,l+1);c!=ve?r[o+2]=c:(r.splice(o,3),o-=3)}if(s.length){for(let o=0,i;o<e.length;o++)if(i=e[o])for(let l=0;l<s.length;l++)s[l].eq(i,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new te(s,r):ve}forChild(e,t){if(this==ve)return this;if(t.isLeaf)return te.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,i=o+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>o&&a.type instanceof vt){let c=Math.max(o,a.from)-o,d=Math.min(i,a.to)-o;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new te(s.sort(Ht),mn);return r?new mt([l,r]):l}return r||ve}eq(e){if(this==e)return!0;if(!(e instanceof te)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return fl(this.localsInner(e))}localsInner(e){if(this==ve)return mn;if(e.inlineContent||!this.local.some(vt.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof vt||t.push(this.local[r]);return t}forEachSet(e){e(this)}}te.empty=new te([],[]);te.removeOverlap=fl;const ve=te.empty;class mt{constructor(e){this.members=e}map(e,t){const r=this.members.map(s=>s.map(e,t,Vt));return mt.from(r)}forChild(e,t){if(t.isLeaf)return te.empty;let r=[];for(let s=0;s<this.members.length;s++){let o=this.members[s].forChild(e,t);o!=ve&&(o instanceof mt?r=r.concat(o.members):r.push(o))}return mt.from(r)}eq(e){if(!(e instanceof mt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let s=0;s<this.members.length;s++){let o=this.members[s].localsInner(e);if(o.length)if(!t)t=o;else{r&&(t=t.slice(),r=!1);for(let i=0;i<o.length;i++)t.push(o[i])}}return t?fl(r?t:t.sort(Ht)):mn}static from(e){switch(e.length){case 0:return ve;case 1:return e[0];default:return new mt(e.every(t=>t instanceof te)?e:e.reduce((t,r)=>t.concat(r instanceof te?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function P0(n,e,t,r,s,o,i){let l=n.slice();for(let c=0,d=o;c<t.maps.length;c++){let u=0;t.maps[c].forEach((f,h,p,y)=>{let g=y-p-(h-f);for(let x=0;x<l.length;x+=3){let b=l[x+1];if(b<0||f>b+d-u)continue;let S=l[x]+d-u;h>=S?l[x+1]=f<=S?-2:-1:f>=d&&g&&(l[x]+=g,l[x+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(n[c]+o),u=d-s;if(u<0||u>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+o,-1),h=f-s,{index:p,offset:y}=r.content.findIndex(u),g=r.maybeChild(p);if(g&&y==u&&y+g.nodeSize==h){let x=l[c+2].mapInner(t,g,d+1,n[c]+o+1,i);x!=ve?(l[c]=u,l[c+1]=h,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=L0(l,n,e,t,s,o,i),d=Xr(c,r,0,i);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,f=0;u<d.children.length;u+=3){let h=d.children[u];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,d.children[u],d.children[u+1],d.children[u+2])}}return new te(e.sort(Ht),l)}function Ru(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let s=n[r];t.push(new Ce(s.from+e,s.to+e,s.type))}return t}function L0(n,e,t,r,s,o,i){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(r,s,c);u?t.push(u):i.onRemove&&i.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+o+1);return t}function ju(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,s=null;for(let o=0,i;o<n.length;o++)(i=n[o])&&i.from>t&&i.to<r&&((s||(s=[])).push(i),n[o]=null);return s}function Du(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Xr(n,e,t,r){let s=[],o=!1;e.forEach((l,a)=>{let c=ju(n,l,a+t);if(c){o=!0;let d=Xr(c,l,t+a+1,r);d!=ve&&s.push(a,a+l.nodeSize,d)}});let i=Ru(o?Du(n):n,-t).sort(Ht);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||s.length?new te(i,s):ve}function Ht(n,e){return n.from-e.from||n.to-e.to}function fl(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let s=t+1;s<e.length;s++){let o=e[s];if(o.from==r.from){o.to!=r.to&&(e==n&&(e=n.slice()),e[s]=o.copy(o.from,r.to),Ba(e,s+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,o.from),Ba(e,s,r.copy(o.from,r.to)));break}}}return e}function Ba(n,e,t){for(;e<n.length&&Ht(t,n[e])>0;)e++;n.splice(e,0,t)}function No(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=ve&&e.push(r)}),n.cursorWrapper&&e.push(te.create(n.state.doc,[n.cursorWrapper.deco])),mt.from(e)}const $0={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},z0=Oe&&St<=11;class _0{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class B0{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new _0,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);Oe&&St<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():Se&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),z0&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,$0)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Ra(this.view)){if(this.suppressingSelectionUpdates)return it(this.view);if(Oe&&St<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Jt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let o=e.focusNode;o;o=Cn(o))t.add(o);for(let o=e.anchorNode;o;o=Cn(o))if(t.has(o)){r=o;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Ra(e)&&!this.ignoreSelectionChange(r),o=-1,i=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(o=o<0?u.from:Math.min(u.from,o),i=i<0?u.to:Math.max(u.to,i),u.typeOver&&(l=!0))}if(_e&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let h=f.parentNode;h&&h.nodeName=="LI"&&(!u||H0(e,u)!=h)&&f.remove()}}}else if((pe||Se)&&a.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let d of a)if(d.nodeName=="BR"&&d.parentNode){let u=d.nextSibling;u&&u.nodeType==1&&u.contentEditable=="false"&&d.parentNode.removeChild(d)}}let c=null;o<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&_s(r)&&(c=ol(e))&&c.eq(q.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,it(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||s)&&(o>-1&&(e.docView.markDirty(o,i),F0(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,W0(e,a)),this.handleDOMChange(o,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||it(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,o=e.nextSibling;if(Oe&&St<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:f}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(o=f)}let i=s&&s.parentNode==e.target?be(s)+1:0,l=r.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?be(o):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Fa=new WeakMap,Va=!1;function F0(n){if(!Fa.has(n)&&(Fa.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=_e,Va)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Va=!0}}function Ha(n,e){let t=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return Jt(i.node,i.offset,s,o)&&([t,r,s,o]=[s,o,t,r]),{anchorNode:t,anchorOffset:r,focusNode:s,focusOffset:o}}function V0(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return Ha(n,s)}let t;function r(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Ha(n,t):null}function H0(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function W0(n,e){var t;let{focusNode:r,focusOffset:s}=n.domSelectionRange();for(let o of e)if(((t=o.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let i=o.nextSibling;for(;i&&i.nodeName!="TD"&&i.nodeName!="TH";)i=i.nextSibling;if(i){let l=i;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(o,l.firstChild),r==o&&n.domSelection().collapse(o,s)}else o.parentNode.removeChild(o)}}function q0(n,e,t){let{node:r,fromOffset:s,toOffset:o,from:i,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],_s(a)||c.push({node:a.focusNode,offset:a.focusOffset})),pe&&n.input.lastKeyCode===8)for(let g=o;g>s;g--){let x=r.childNodes[g-1],b=x.pmViewDesc;if(x.nodeName=="BR"&&!b){o=g;break}if(!b||b.size)break}let u=n.state.doc,f=n.someProp("domParser")||kt.fromSchema(n.state.schema),h=u.resolve(i),p=null,y=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:o,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:U0,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=g),p={anchor:g+i,head:x+i}}return{doc:y,sel:p,from:i,to:l}}function U0(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Se&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Se&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const K0=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function J0(n,e,t,r,s){let o=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let C=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,T=ol(n,C);if(T&&!n.state.selection.eq(T)){if(pe&&st&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",D=>D(n,It(13,"Enter"))))return;let A=n.state.tr.setSelection(T);C=="pointer"?A.setMeta("pointer",!0):C=="key"&&A.scrollIntoView(),o&&A.setMeta("composition",o),n.dispatch(A)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=q0(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=Y0(u.content,c.doc.content,c.from,f,h);if(p&&n.input.domChangeCount++,(Nn&&n.input.lastIOSEnter>Date.now()-225||st)&&s.some(C=>C.nodeType==1&&!K0.test(C.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",C=>C(n,It(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof F&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let C=Wa(n,n.state.doc,c.sel);if(C&&!C.eq(n.state.selection)){let T=n.state.tr.setSelection(C);o&&T.setMeta("composition",o),n.dispatch(T)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof F&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),Oe&&St<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let y=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),x=d.resolve(p.start),b=y.sameParent(g)&&y.parent.inlineContent&&x.end()>=p.endA;if((Nn&&n.input.lastIOSEnter>Date.now()-225&&(!b||s.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!b&&y.pos<c.doc.content.size&&(!y.sameParent(g)||!y.parent.inlineContent)&&y.pos<g.pos&&!/\S/.test(c.doc.textBetween(y.pos,g.pos,"","")))&&n.someProp("handleKeyDown",C=>C(n,It(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&X0(d,p.start,p.endA,y,g)&&n.someProp("handleKeyDown",C=>C(n,It(8,"Backspace")))){st&&pe&&n.domObserver.suppressSelectionUpdates();return}pe&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),st&&!b&&y.start()!=g.start()&&g.parentOffset==0&&y.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(C){return C(n,It(13,"Enter"))})},20));let S=p.start,v=p.endA,k=C=>{let T=C||n.state.tr.replace(S,v,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let A=Wa(n,T.doc,c.sel);A&&!(pe&&n.composing&&A.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(A.head==S||A.head==T.mapping.map(v)-1)||Oe&&A.empty&&A.head==S)&&T.setSelection(A)}return o&&T.setMeta("composition",o),T.scrollIntoView()},w;if(b)if(y.pos==g.pos){Oe&&St<=11&&y.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>it(n),20));let C=k(n.state.tr.delete(S,v)),T=d.resolve(p.start).marksAcross(d.resolve(p.endA));T&&C.ensureMarks(T),n.dispatch(C)}else if(p.endA==p.endB&&(w=G0(y.parent.content.cut(y.parentOffset,g.parentOffset),x.parent.content.cut(x.parentOffset,p.endA-x.start())))){let C=k(n.state.tr);w.type=="add"?C.addMark(S,v,w.mark):C.removeMark(S,v,w.mark),n.dispatch(C)}else if(y.parent.child(y.index()).isText&&y.index()==g.index()-(g.textOffset?0:1)){let C=y.parent.textBetween(y.parentOffset,g.parentOffset),T=()=>k(n.state.tr.insertText(C,S,v));n.someProp("handleTextInput",A=>A(n,S,v,C,T))||n.dispatch(T())}else n.dispatch(k());else n.dispatch(k())}function Wa(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:il(n,e.resolve(t.anchor),e.resolve(t.head))}function G0(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,s=t,o=r,i,l,a;for(let d=0;d<r.length;d++)s=r[d].removeFromSet(s);for(let d=0;d<t.length;d++)o=t[d].removeFromSet(o);if(s.length==1&&o.length==0)l=s[0],i="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&o.length==1)l=o[0],i="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(E.from(c).eq(n))return{mark:l,type:i}}function X0(n,e,t,r,s){if(t-e<=s.pos-r.pos||Eo(r,!0,!1)<s.pos)return!1;let o=n.resolve(e);if(!r.parent.isTextblock){let l=o.nodeAfter;return l!=null&&t==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let i=n.resolve(Eo(o,!0,!0));return!i.parent.isTextblock||i.pos>t||Eo(i,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function Eo(n,e,t){let r=n.depth,s=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,s++,e=!1;if(t){let o=n.node(r).maybeChild(n.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,s++}return s}function Y0(n,e,t,r,s){let o=n.findDiffStart(e,t);if(o==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,o-Math.min(i,l));r-=i+a-o}if(i<o&&n.size<e.size){let a=r<=o&&r>=i?o-r:0;o-=a,o&&o<e.size&&qa(e.textBetween(o-1,o+1))&&(o+=a?1:-1),l=o+(l-i),i=o}else if(l<o){let a=r<=o&&r>=l?o-r:0;o-=a,o&&o<n.size&&qa(n.textBetween(o-1,o+1))&&(o+=a?1:-1),i=o+(i-l),l=o}return{start:o,endA:i,endB:l}}function qa(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Pu{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new h0,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Xa),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Ja(this),Ka(this),this.nodeViews=Ga(this),this.docView=Ea(this.state.doc,Ua(this),No(this),this.dom,this),this.domObserver=new B0(this,(r,s,o,i)=>J0(this,r,s,o,i)),this.domObserver.start(),p0(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ii(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Xa),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let s=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(Mu(this),i=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Ga(this);Z0(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ii(this),this.editable=Ja(this),Ka(this);let a=No(this),c=Ua(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=o||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(s.selection))&&(i=!0);let f=d=="preserve"&&i&&this.dom.style.overflowAnchor==null&&M1(this);if(i){this.domObserver.stop();let h=u&&(Oe||pe)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&Q0(s.selection,e.selection);if(u){let p=pe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=M0(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ea(e.doc,c,a,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Q1(this))?it(this,h):(gu(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&A1(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof $){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ka(this,t.getBoundingClientRect(),e)}else ka(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let o=r.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&this.state.doc.nodeAt(o))==r.node&&(s=o)}this.dragging=new Ou(e.slice,e.move,s<0?void 0:$.create(this.state.doc,s))}someProp(e,t){let r=this._props&&this._props[e],s;if(r!=null&&(s=t?t(r):r))return s;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(s=t?t(l):l))return s}let o=this.state.plugins;if(o)for(let i=0;i<o.length;i++){let l=o[i].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(Oe){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&O1(this.dom),it(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return P1(this,e)}coordsAtPos(e,t=1){return au(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let s=this.docView.posFromDOM(e,t,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return B1(this,t||this.state,e)}pasteHTML(e,t){return lr(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return lr(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return ll(this,e)}destroy(){this.docView&&(m0(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],No(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,x1())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return y0(this,e)}domSelectionRange(){let e=this.domSelection();return e?Se&&this.root.nodeType===11&&v1(this.dom.ownerDocument)==this.dom&&V0(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Pu.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Ua(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Ce.node(0,n.state.doc.content.size,e)]}function Ka(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Ce.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Ja(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Q0(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Ga(n){let e=Object.create(null);function t(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Z0(n,e){let t=0,r=0;for(let s in n){if(n[s]!=e[s])return!0;t++}for(let s in e)r++;return t!=r}function Xa(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Ct={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Yr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ey=typeof navigator<"u"&&/Mac/.test(navigator.platform),ty=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ke=0;ke<10;ke++)Ct[48+ke]=Ct[96+ke]=String(ke);for(var ke=1;ke<=24;ke++)Ct[ke+111]="F"+ke;for(var ke=65;ke<=90;ke++)Ct[ke]=String.fromCharCode(ke+32),Yr[ke]=String.fromCharCode(ke);for(var To in Ct)Yr.hasOwnProperty(To)||(Yr[To]=Ct[To]);function ny(n){var e=ey&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||ty&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Yr:Ct)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const ry=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),sy=typeof navigator<"u"&&/Win/.test(navigator.platform);function oy(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,s,o,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))ry?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),s&&(t="Ctrl-"+t),i&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function iy(n){let e=Object.create(null);for(let t in n)e[oy(t)]=n[t];return e}function Mo(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function ly(n){return new re({props:{handleKeyDown:Lu(n)}})}function Lu(n){let e=iy(n);return function(t,r){let s=ny(r),o,i=e[Mo(s,r)];if(i&&i(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Mo(s,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(sy&&r.ctrlKey&&r.altKey)&&(o=Ct[r.keyCode])&&o!=s){let l=e[Mo(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var ay=Object.defineProperty,hl=(n,e)=>{for(var t in e)ay(n,t,{get:e[t],enumerable:!0})};function Vs(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:s}=t,{storedMarks:o}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return s},get tr(){return r=t.selection,s=t.doc,o=t.storedMarks,t}}}var Hs=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:n,editor:e,state:t}=this,{view:r}=e,{tr:s}=t,o=this.buildProps(s);return Object.fromEntries(Object.entries(n).map(([i,l])=>[i,(...c)=>{const d=l(...c)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){const{rawCommands:t,editor:r,state:s}=this,{view:o}=r,i=[],l=!!n,a=n||s.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(a),i.every(u=>u===!0)),d={...Object.fromEntries(Object.entries(t).map(([u,f])=>[u,(...p)=>{const y=this.buildProps(a,e),g=f(...p)(y);return i.push(g),d}])),run:c};return d}createCan(n){const{rawCommands:e,state:t}=this,r=!1,s=n||t.tr,o=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(n,e=!0){const{rawCommands:t,editor:r,state:s}=this,{view:o}=r,i={tr:n,editor:r,view:o,state:Vs({state:s,transaction:n}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(n,e),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...c)=>a(...c)(i)]))}};return i}},$u={};hl($u,{blur:()=>cy,clearContent:()=>dy,clearNodes:()=>uy,command:()=>fy,createParagraphNear:()=>hy,cut:()=>py,deleteCurrentNode:()=>my,deleteNode:()=>gy,deleteRange:()=>yy,deleteSelection:()=>xy,enter:()=>by,exitCode:()=>ky,extendMarkRange:()=>Sy,first:()=>wy,focus:()=>Cy,forEach:()=>Ny,insertContent:()=>Ey,insertContentAt:()=>Ay,joinBackward:()=>Ry,joinDown:()=>Iy,joinForward:()=>jy,joinItemBackward:()=>Dy,joinItemForward:()=>Py,joinTextblockBackward:()=>Ly,joinTextblockForward:()=>$y,joinUp:()=>Oy,keyboardShortcut:()=>_y,lift:()=>By,liftEmptyBlock:()=>Fy,liftListItem:()=>Vy,newlineInCode:()=>Hy,resetAttributes:()=>Wy,scrollIntoView:()=>qy,selectAll:()=>Uy,selectNodeBackward:()=>Ky,selectNodeForward:()=>Jy,selectParentNode:()=>Gy,selectTextblockEnd:()=>Xy,selectTextblockStart:()=>Yy,setContent:()=>Qy,setMark:()=>xx,setMeta:()=>bx,setNode:()=>kx,setNodeSelection:()=>Sx,setTextDirection:()=>wx,setTextSelection:()=>vx,sinkListItem:()=>Cx,splitBlock:()=>Nx,splitListItem:()=>Ex,toggleList:()=>Tx,toggleMark:()=>Mx,toggleNode:()=>Ax,toggleWrap:()=>Ox,undoInputRule:()=>Ix,unsetAllMarks:()=>Rx,unsetMark:()=>jx,unsetTextDirection:()=>Dx,updateAttributes:()=>Px,wrapIn:()=>Lx,wrapInList:()=>$x});var cy=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())==null||t.removeAllRanges())}),!0),dy=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),uy=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:s}=r;return t&&s.forEach(({$from:o,$to:i})=>{n.doc.nodesBetween(o.pos,i.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(a)),f=c.resolve(d.map(a+l.nodeSize)),h=u.blockRange(f);if(!h)return;const p=Ln(h);if(l.type.isTextblock){const{defaultType:y}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,y)}(p||p===0)&&e.lift(h,p)})}),!0},fy=n=>e=>n(e),hy=()=>({state:n,dispatch:e})=>Yd(n,e),py=(n,e)=>({editor:t,tr:r})=>{const{state:s}=t,o=s.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const i=r.mapping.map(e);return r.insert(i,o.content),r.setSelection(new F(r.doc.resolve(Math.max(i-1,0)))),!0},my=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const s=n.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===r.type){if(e){const l=s.before(o),a=s.after(o);n.delete(l,a).scrollIntoView()}return!0}return!1};function ue(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}var gy=n=>({tr:e,state:t,dispatch:r})=>{const s=ue(n,t.schema),o=e.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===s){if(r){const a=o.before(i),c=o.after(i);e.delete(a,c).scrollIntoView()}return!0}return!1},yy=n=>({tr:e,dispatch:t})=>{const{from:r,to:s}=n;return t&&e.delete(r,s),!0},xy=()=>({state:n,dispatch:e})=>Zi(n,e),by=()=>({commands:n})=>n.keyboardShortcut("Enter"),ky=()=>({state:n,dispatch:e})=>r1(n,e);function pl(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function Qr(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>t.strict?e[s]===n[s]:pl(e[s])?e[s].test(n[s]):e[s]===n[s]):!0}function zu(n,e,t={}){return n.find(r=>r.type===e&&Qr(Object.fromEntries(Object.keys(t).map(s=>[s,r.attrs[s]])),t))}function Ya(n,e,t={}){return!!zu(n,e,t)}function ml(n,e,t){var r;if(!n||!e)return;let s=n.parent.childAfter(n.parentOffset);if((!s.node||!s.node.marks.some(d=>d.type===e))&&(s=n.parent.childBefore(n.parentOffset)),!s.node||!s.node.marks.some(d=>d.type===e)||(t=t||((r=s.node.marks[0])==null?void 0:r.attrs),!zu([...s.node.marks],e,t)))return;let i=s.index,l=n.start()+s.offset,a=i+1,c=l+s.node.nodeSize;for(;i>0&&Ya([...n.parent.child(i-1).marks],e,t);)i-=1,l-=n.parent.child(i).nodeSize;for(;a<n.parent.childCount&&Ya([...n.parent.child(a).marks],e,t);)c+=n.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function lt(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}var Sy=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const o=lt(n,r.schema),{doc:i,selection:l}=t,{$from:a,from:c,to:d}=l;if(s){const u=ml(a,o,e);if(u&&u.from<=c&&u.to>=d){const f=F.create(i,u.from,u.to);t.setSelection(f)}}return!0},wy=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function _u(n){return n instanceof F}function Dt(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function Bu(n,e=null){if(!e)return null;const t=q.atStart(n),r=q.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const s=t.from,o=r.to;return e==="all"?F.create(n,Dt(0,s,o),Dt(n.content.size,s,o)):F.create(n,Dt(e,s,o),Dt(e,s,o))}function li(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function cr(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function vy(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var Cy=(n=null,e={})=>({editor:t,view:r,tr:s,dispatch:o})=>{e={scrollIntoView:!0,...e};const i=()=>{(cr()||li())&&r.dom.focus(),vy()&&!cr()&&!li()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(o&&n===null&&!_u(t.state.selection))return i(),!0;const l=Bu(s.doc,n)||t.state.selection,a=t.state.selection.eq(l);return o&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),i()),!0},Ny=(n,e)=>t=>n.every((r,s)=>e(r,{...t,index:s})),Ey=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),Fu=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&Fu(r)}return n};function Cr(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return Fu(t)}function dr(n,e,t){if(n instanceof ze||n instanceof E)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,s=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return E.fromArray(n.map(l=>e.nodeFromJSON(l)));const i=e.nodeFromJSON(n);return t.errorOnInvalidContent&&i.check(),i}catch(o){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",o),dr("",e,t)}if(s){if(t.errorOnInvalidContent){let i=!1,l="";const a=new Cd({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(i=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?kt.fromSchema(a).parseSlice(Cr(n),t.parseOptions):kt.fromSchema(a).parse(Cr(n),t.parseOptions),t.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const o=kt.fromSchema(e);return t.slice?o.parseSlice(Cr(n),t.parseOptions).content:o.parse(Cr(n),t.parseOptions)}return dr("",e,t)}function Ty(n,e,t){const r=n.steps.length-1;if(r<e)return;const s=n.steps[r];if(!(s instanceof he||s instanceof ge))return;const o=n.mapping.maps[r];let i=0;o.forEach((l,a,c,d)=>{i===0&&(i=d)}),n.setSelection(q.near(n.doc.resolve(i),t))}var My=n=>!("type"in n),Ay=(n,e,t)=>({tr:r,dispatch:s,editor:o})=>{var i;if(s){t={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=g=>{o.emit("contentError",{editor:o,error:g,disableCollaboration:()=>{"collaboration"in o.storage&&typeof o.storage.collaboration=="object"&&o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{dr(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=dr(e,o.schema,{parseOptions:c,errorOnInvalidContent:(i=t.errorOnInvalidContent)!=null?i:o.options.enableContentCheck})}catch(g){return a(g),!1}let{from:d,to:u}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},f=!0,h=!0;if((My(l)?l:[l]).forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),d===u&&h){const{parent:g}=r.doc.resolve(d);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(d-=1,u+=1)}let y;if(f){if(Array.isArray(e))y=e.map(g=>g.text||"").join("");else if(e instanceof E){let g="";e.forEach(x=>{x.text&&(g+=x.text)}),y=g}else typeof e=="object"&&e&&e.text?y=e.text:y=e;r.insertText(y,d,u)}else{y=l;const g=r.doc.resolve(d),x=g.node(),b=g.parentOffset===0,S=x.isText||x.isTextblock,v=x.content.size>0;b&&S&&v&&(d=Math.max(0,d-1)),r.replaceWith(d,u,y)}t.updateSelection&&Ty(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:y}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:y})}return!0},Oy=()=>({state:n,dispatch:e})=>e1(n,e),Iy=()=>({state:n,dispatch:e})=>t1(n,e),Ry=()=>({state:n,dispatch:e})=>Wd(n,e),jy=()=>({state:n,dispatch:e})=>Jd(n,e),Dy=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Ls(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Py=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Ls(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Ly=()=>({state:n,dispatch:e})=>Qg(n,e),$y=()=>({state:n,dispatch:e})=>Zg(n,e);function Vu(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function zy(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,s,o,i;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))cr()||Vu()?i=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),s&&(t=`Ctrl-${t}`),i&&(t=`Meta-${t}`),o&&(t=`Shift-${t}`),t}var _y=n=>({editor:e,view:t,tr:r,dispatch:s})=>{const o=zy(n).split(/-(?!$)/),i=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a?.steps.forEach(c=>{const d=c.map(r.mapping);d&&s&&r.maybeStep(d)}),!0};function Nt(n,e,t={}){const{from:r,to:s,empty:o}=n.selection,i=e?ue(e,n.schema):null,l=[];n.doc.nodesBetween(r,s,(u,f)=>{if(u.isText)return;const h=Math.max(r,f),p=Math.min(s,f+u.nodeSize);l.push({node:u,from:h,to:p})});const a=s-r,c=l.filter(u=>i?i.name===u.node.type.name:!0).filter(u=>Qr(u.node.attrs,t,{strict:!1}));return o?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=a}var By=(n,e={})=>({state:t,dispatch:r})=>{const s=ue(n,t.schema);return Nt(t,s,e)?n1(t,r):!1},Fy=()=>({state:n,dispatch:e})=>Qd(n,e),Vy=n=>({state:e,dispatch:t})=>{const r=ue(n,e.schema);return p1(r)(e,t)},Hy=()=>({state:n,dispatch:e})=>Xd(n,e);function Ws(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Qa(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,s)=>(t.includes(s)||(r[s]=n[s]),r),{})}var Wy=(n,e)=>({tr:t,state:r,dispatch:s})=>{let o=null,i=null;const l=Ws(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(o=ue(n,r.schema)),l==="mark"&&(i=lt(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(d,u)=>{o&&o===d.type&&(a=!0,s&&t.setNodeMarkup(u,void 0,Qa(d.attrs,e))),i&&d.marks.length&&d.marks.forEach(f=>{i===f.type&&(a=!0,s&&t.addMark(u,u+d.nodeSize,i.create(Qa(f.attrs,e))))})})}),a},qy=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Uy=()=>({tr:n,dispatch:e})=>{if(e){const t=new je(n.doc);n.setSelection(t)}return!0},Ky=()=>({state:n,dispatch:e})=>Ud(n,e),Jy=()=>({state:n,dispatch:e})=>Gd(n,e),Gy=()=>({state:n,dispatch:e})=>i1(n,e),Xy=()=>({state:n,dispatch:e})=>c1(n,e),Yy=()=>({state:n,dispatch:e})=>a1(n,e);function ai(n,e,t={},r={}){return dr(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var Qy=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:r={}}={})=>({editor:s,tr:o,dispatch:i,commands:l})=>{const{doc:a}=o;if(r.preserveWhitespace!=="full"){const c=ai(n,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return i&&o.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!t),!0}return i&&o.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:a.content.size},n,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function Hu(n,e){const t=lt(e,n.schema),{from:r,to:s,empty:o}=n.selection,i=[];o?(n.storedMarks&&i.push(...n.storedMarks),i.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,s,a=>{i.push(...a.marks)});const l=i.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function Wu(n,e){const t=new Bd(n);return e.forEach(r=>{r.steps.forEach(s=>{t.step(s)})}),t}function Zy(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function ex(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(s,o)=>{t(s)&&r.push({node:s,pos:o})}),r}function tx(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function qs(n){return e=>tx(e.$from,n)}function L(n,e,t){return n.config[e]===void 0&&n.parent?L(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?L(n.parent,e,t):null}):n.config[e]}function gl(n){return n.map(e=>{const t={name:e.name,options:e.options,storage:e.storage},r=L(e,"addExtensions",t);return r?[e,...gl(r())]:e}).flat(10)}function yl(n,e){const t=Qt.fromSchema(e).serializeFragment(n),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(t),s.innerHTML}function qu(n){return typeof n=="function"}function G(n,e=void 0,...t){return qu(n)?e?n.bind(e)(...t):n(...t):n}function nx(n={}){return Object.keys(n).length===0&&n.constructor===Object}function En(n){const e=n.filter(s=>s.type==="extension"),t=n.filter(s=>s.type==="node"),r=n.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Uu(n){const e=[],{nodeExtensions:t,markExtensions:r}=En(n),s=[...t,...r],o={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(i=>{const l={name:i.name,options:i.options,storage:i.storage,extensions:s},a=L(i,"addGlobalAttributes",l);if(!a)return;a().forEach(d=>{d.types.forEach(u=>{Object.entries(d.attributes).forEach(([f,h])=>{e.push({type:u,name:f,attribute:{...o,...h}})})})})}),s.forEach(i=>{const l={name:i.name,options:i.options,storage:i.storage},a=L(i,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([d,u])=>{const f={...o,...u};typeof f?.default=="function"&&(f.default=f.default()),f?.isRequired&&f?.default===void 0&&delete f.default,e.push({type:i.name,name:d,attribute:f})})}),e}function ne(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([s,o])=>{if(!r[s]){r[s]=o;return}if(s==="class"){const l=o?String(o).split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(d=>!a.includes(d));r[s]=[...a,...c].join(" ")}else if(s==="style"){const l=o?o.split(";").map(d=>d.trim()).filter(Boolean):[],a=r[s]?r[s].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;a.forEach(d=>{const[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),l.forEach(d=>{const[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),r[s]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else r[s]=o}),r},{})}function Tn(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>ne(t,r),{})}function rx(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Za(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const s=e.reduce((o,i)=>{const l=i.attribute.parseHTML?i.attribute.parseHTML(t):rx(t.getAttribute(i.name));return l==null?o:{...o,[i.name]:l}},{});return{...r,...s}}}}function ec(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&nx(t)?!1:t!=null))}function tc(n){var e,t;const r={};return!((e=n?.attribute)!=null&&e.isRequired)&&"default"in(n?.attribute||{})&&(r.default=n.attribute.default),((t=n?.attribute)==null?void 0:t.validate)!==void 0&&(r.validate=n.attribute.validate),[n.name,r]}function sx(n,e){var t;const r=Uu(n),{nodeExtensions:s,markExtensions:o}=En(n),i=(t=s.find(c=>L(c,"topNode")))==null?void 0:t.name,l=Object.fromEntries(s.map(c=>{const d=r.filter(x=>x.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((x,b)=>{const S=L(b,"extendNodeSchema",u);return{...x,...S?S(c):{}}},{}),h=ec({...f,content:G(L(c,"content",u)),marks:G(L(c,"marks",u)),group:G(L(c,"group",u)),inline:G(L(c,"inline",u)),atom:G(L(c,"atom",u)),selectable:G(L(c,"selectable",u)),draggable:G(L(c,"draggable",u)),code:G(L(c,"code",u)),whitespace:G(L(c,"whitespace",u)),linebreakReplacement:G(L(c,"linebreakReplacement",u)),defining:G(L(c,"defining",u)),isolating:G(L(c,"isolating",u)),attrs:Object.fromEntries(d.map(tc))}),p=G(L(c,"parseHTML",u));p&&(h.parseDOM=p.map(x=>Za(x,d)));const y=L(c,"renderHTML",u);y&&(h.toDOM=x=>y({node:x,HTMLAttributes:Tn(x,d)}));const g=L(c,"renderText",u);return g&&(h.toText=g),[c.name,h]})),a=Object.fromEntries(o.map(c=>{const d=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((g,x)=>{const b=L(x,"extendMarkSchema",u);return{...g,...b?b(c):{}}},{}),h=ec({...f,inclusive:G(L(c,"inclusive",u)),excludes:G(L(c,"excludes",u)),group:G(L(c,"group",u)),spanning:G(L(c,"spanning",u)),code:G(L(c,"code",u)),attrs:Object.fromEntries(d.map(tc))}),p=G(L(c,"parseHTML",u));p&&(h.parseDOM=p.map(g=>Za(g,d)));const y=L(c,"renderHTML",u);return y&&(h.toDOM=g=>y({mark:g,HTMLAttributes:Tn(g,d)})),[c.name,h]}));return new Cd({topNode:i,nodes:l,marks:a})}function ox(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}function Zr(n){return n.sort((t,r)=>{const s=L(t,"priority")||100,o=L(r,"priority")||100;return s>o?-1:s<o?1:0})}function Ku(n){const e=Zr(gl(n)),t=ox(e.map(r=>r.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Ju(n,e,t){const{from:r,to:s}=e,{blockSeparator:o=`
|
|
17
17
|
|
|
18
|
-
`,textSerializers:i={}}=t||{};let l="";return n.nodesBetween(r,s,(a,c,d,u)=>{var f;a.isBlock&&c>r&&(l+=o);const h=i?.[a.type.name];if(h)return d&&(l+=h({node:a,pos:c,parent:d,index:u,range:e})),!1;a.isText&&(l+=(f=a?.text)==null?void 0:f.slice(Math.max(r,c)-c,s-c))}),l}function Qy(n,e){const t={from:0,to:n.content.size};return Ju(n,t,e)}function Gu(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Zy(n,e){const t=ue(e,n.schema),{from:r,to:s}=n.selection,o=[];n.doc.nodesBetween(r,s,l=>{o.push(l)});const i=o.reverse().find(l=>l.type.name===t.name);return i?{...i.attrs}:{}}function Xu(n,e){const t=Ws(typeof e=="string"?e:e.name,n.schema);return t==="node"?Zy(n,e):t==="mark"?Hu(n,e):{}}function ex(n,e=JSON.stringify){const t={};return n.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(t,s)?!1:t[s]=!0})}function tx(n){const e=ex(n);return e.length===1?e:e.filter((t,r)=>!e.filter((o,i)=>i!==r).some(o=>t.oldRange.from>=o.oldRange.from&&t.oldRange.to<=o.oldRange.to&&t.newRange.from>=o.newRange.from&&t.newRange.to<=o.newRange.to))}function Yu(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((s,o)=>{const i=[];if(s.ranges.length)s.forEach((l,a)=>{i.push({from:l,to:a})});else{const{from:l,to:a}=t[o];if(l===void 0||a===void 0)return;i.push({from:l,to:a})}i.forEach(({from:l,to:a})=>{const c=e.slice(o).map(l,-1),d=e.slice(o).map(a),u=e.invert().map(c,-1),f=e.invert().map(d);r.push({oldRange:{from:u,to:f},newRange:{from:c,to:d}})})}),tx(r)}function xl(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(s=>{const o=t.resolve(n),i=ml(o,s.type);i&&r.push({mark:s,...i})}):t.nodesBetween(n,e,(s,o)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(i=>({from:o,to:o+s.nodeSize,mark:i})))}),r}var nx=(n,e,t,r=20)=>{const s=n.doc.resolve(t);let o=r,i=null;for(;o>0&&i===null;){const l=s.node(o);l?.type.name===e?i=l:o-=1}return[i,o]};function Nr(n,e){return e.nodes[n]||e.marks[n]||null}function Lr(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const s=n.find(o=>o.type===e&&o.name===r);return s?s.attribute.keepOnSplit:!1}))}var rx=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(s,o,i,l)=>{var a,c;const d=((c=(a=s.type.spec).toText)==null?void 0:c.call(a,{node:s,pos:o,parent:i,index:l}))||s.textContent||"%leaf%";t+=s.isAtom&&!s.isText?d:d.slice(0,Math.max(0,r-o))}),t};function ci(n,e,t={}){const{empty:r,ranges:s}=n.selection,o=e?lt(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>o?o.name===u.type.name:!0).find(u=>Qr(u.attrs,t,{strict:!1}));let i=0;const l=[];if(s.forEach(({$from:u,$to:f})=>{const h=u.pos,p=f.pos;n.doc.nodesBetween(h,p,(y,g)=>{if(!y.isText&&!y.marks.length)return;const x=Math.max(h,g),b=Math.min(p,g+y.nodeSize),S=b-x;i+=S,l.push(...y.marks.map(v=>({mark:v,from:x,to:b})))})}),i===0)return!1;const a=l.filter(u=>o?o.name===u.mark.type.name:!0).filter(u=>Qr(u.mark.attrs,t,{strict:!1})).reduce((u,f)=>u+f.to-f.from,0),c=l.filter(u=>o?u.mark.type!==o&&u.mark.type.excludes(o):!0).reduce((u,f)=>u+f.to-f.from,0);return(a>0?a+c:a)>=i}function sx(n,e,t={}){if(!e)return Nt(n,null,t)||ci(n,null,t);const r=Ws(e,n.schema);return r==="node"?Nt(n,e,t):r==="mark"?ci(n,e,t):!1}var ox=(n,e)=>{const{$from:t,$to:r,$anchor:s}=n.selection;if(e){const o=qs(l=>l.type.name===e)(n.selection);if(!o)return!1;const i=n.doc.resolve(o.pos+1);return s.pos+1===i.end()}return!(r.parentOffset<r.parent.nodeSize-2||t.pos!==r.pos)},ix=n=>{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function nc(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function rc(n,e){const{nodeExtensions:t}=En(e),r=t.find(i=>i.name===n);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},o=G(L(r,"group",s));return typeof o!="string"?!1:o.split(" ").includes("list")}function Us(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!=null?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let s=!0;return n.content.forEach(o=>{s!==!1&&(Us(o,{ignoreWhitespace:t,checkChildren:e})||(s=!1))}),s}return!1}function Qu(n){return n instanceof $}var Zu=class ef{constructor(e){this.position=e}static fromJSON(e){return new ef(e.position)}toJSON(){return{position:this.position}}};function lx(n,e){const t=e.mapping.mapResult(n.position);return{position:new Zu(t.pos),mapResult:t}}function ax(n){return new Zu(n)}function cx(n,e,t){var r;const{selection:s}=e;let o=null;if(_u(s)&&(o=s.$cursor),o){const l=(r=n.storedMarks)!=null?r:o.marks();return o.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(c=>c.type.excludes(t)))}const{ranges:i}=s;return i.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(d,u,f)=>{if(c)return!1;if(d.isInline){const h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(d.marks)||!d.marks.some(y=>y.type.excludes(t));c=h&&p}return!c}),c})}var dx=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const{selection:o}=t,{empty:i,ranges:l}=o,a=lt(n,r.schema);if(s)if(i){const c=Hu(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(f,h)=>{const p=Math.max(h,d),y=Math.min(h+f.nodeSize,u);f.marks.find(x=>x.type===a)?f.marks.forEach(x=>{a===x.type&&t.addMark(p,y,a.create({...x.attrs,...e}))}):t.addMark(p,y,a.create(e))})});return cx(r,t,a)},ux=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),fx=(n,e={})=>({state:t,dispatch:r,chain:s})=>{const o=ue(n,t.schema);let i;return t.selection.$anchor.sameParent(t.selection.$head)&&(i=t.selection.$anchor.parent.attrs),o.isTextblock?s().command(({commands:l})=>ya(o,{...i,...e})(t)?!0:l.clearNodes()).command(({state:l})=>ya(o,{...i,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},hx=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,s=Dt(n,0,r.content.size),o=$.create(r,s);e.setSelection(o)}return!0},px=(n,e)=>({tr:t,state:r,dispatch:s})=>{const{selection:o}=r;let i,l;return typeof e=="number"?(i=e,l=e):e&&"from"in e&&"to"in e?(i=e.from,l=e.to):(i=o.from,l=o.to),s&&t.doc.nodesBetween(i,l,(a,c)=>{a.isText||t.setNodeMarkup(c,void 0,{...a.attrs,dir:n})}),!0},mx=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:s,to:o}=typeof n=="number"?{from:n,to:n}:n,i=F.atStart(r).from,l=F.atEnd(r).to,a=Dt(s,i,l),c=Dt(o,i,l),d=F.create(r,a,c);e.setSelection(d)}return!0},gx=n=>({state:e,dispatch:t})=>{const r=ue(n,e.schema);return d1(r)(e,t)};function sc(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(s=>e?.includes(s.type.name));n.tr.ensureMarks(r)}}var yx=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:s})=>{const{selection:o,doc:i}=e,{$from:l,$to:a}=o,c=s.extensionManager.attributes,d=Lr(c,l.node().type.name,l.node().attrs);if(o instanceof $&&o.node.isBlock)return!l.parentOffset||!ot(i,l.pos)?!1:(r&&(n&&sc(t,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const u=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:qy(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=u&&f?[{type:f,attrs:d}]:void 0,p=ot(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&ot(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:d}]:void 0),r){if(p&&(o instanceof F&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!u&&!l.parentOffset&&l.parent.type!==f)){const y=e.mapping.map(l.before()),g=e.doc.resolve(y);l.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&sc(t,s.extensionManager.splittableMarks),e.scrollIntoView()}return p},xx=(n,e={})=>({tr:t,state:r,dispatch:s,editor:o})=>{var i;const l=ue(n,r.schema),{$from:a,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||a.depth<2||!a.sameParent(c))return!1;const u=a.node(-1);if(u.type!==l)return!1;const f=o.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(s){let x=E.empty;const b=a.index(-1)?1:a.index(-2)?2:3;for(let T=a.depth-b;T>=a.depth-3;T-=1)x=E.from(a.node(T).copy(x));const S=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,v={...Lr(f,a.node().type.name,a.node().attrs),...e},k=((i=l.contentMatch.defaultType)==null?void 0:i.createAndFill(v))||void 0;x=x.append(E.from(l.createAndFill(null,k)||void 0));const w=a.before(a.depth-(b-1));t.replace(w,a.after(-S),new R(x,4-b,0));let C=-1;t.doc.nodesBetween(w,t.doc.content.size,(T,A)=>{if(C>-1)return!1;T.isTextblock&&T.content.size===0&&(C=A+1)}),C>-1&&t.setSelection(F.near(t.doc.resolve(C))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,p={...Lr(f,u.type.name,u.attrs),...e},y={...Lr(f,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const g=h?[{type:l,attrs:p},{type:h,attrs:y}]:[{type:l,attrs:p}];if(!ot(t.doc,a.pos,2))return!1;if(s){const{selection:x,storedMarks:b}=r,{splittableMarks:S}=o.extensionManager,v=b||x.$to.parentOffset&&x.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!v||!s)return!0;const k=v.filter(w=>S.includes(w.type.name));t.ensureMarks(k)}return!0},Ao=(n,e)=>{const t=qs(i=>i.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===s?.type&&Mt(n.doc,t.pos)&&n.join(t.pos),!0},Oo=(n,e)=>{const t=qs(i=>i.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===s?.type&&Mt(n.doc,r)&&n.join(r),!0},bx=(n,e,t,r={})=>({editor:s,tr:o,state:i,dispatch:l,chain:a,commands:c,can:d})=>{const{extensions:u,splittableMarks:f}=s.extensionManager,h=ue(n,i.schema),p=ue(e,i.schema),{selection:y,storedMarks:g}=i,{$from:x,$to:b}=y,S=x.blockRange(b),v=g||y.$to.parentOffset&&y.$from.marks();if(!S)return!1;const k=qs(w=>rc(w.type.name,u))(y);if(S.depth>=1&&k&&S.depth-k.depth<=1){if(k.node.type===h)return c.liftListItem(p);if(rc(k.node.type.name,u)&&h.validContent(k.node.content)&&l)return a().command(()=>(o.setNodeMarkup(k.pos,h),!0)).command(()=>Ao(o,h)).command(()=>Oo(o,h)).run()}return!t||!v||!l?a().command(()=>d().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Ao(o,h)).command(()=>Oo(o,h)).run():a().command(()=>{const w=d().wrapInList(h,r),C=v.filter(T=>f.includes(T.type.name));return o.ensureMarks(C),w?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Ao(o,h)).command(()=>Oo(o,h)).run()},kx=(n,e={},t={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:o=!1}=t,i=lt(n,r.schema);return ci(r,i,e)?s.unsetMark(i,{extendEmptyMarkRange:o}):s.setMark(i,e)},Sx=(n,e,t={})=>({state:r,commands:s})=>{const o=ue(n,r.schema),i=ue(e,r.schema),l=Nt(r,o,t);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(i,a):s.setNode(o,{...a,...t})},wx=(n,e={})=>({state:t,commands:r})=>{const s=ue(n,t.schema);return Nt(t,s,e)?r.lift(s):r.wrapIn(s,e)},vx=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const s=t[r];let o;if(s.spec.isInputRules&&(o=s.getState(n))){if(e){const i=n.tr,l=o.transform;for(let a=l.steps.length-1;a>=0;a-=1)i.step(l.steps[a].invert(l.docs[a]));if(o.text){const a=i.doc.resolve(o.from).marks();i.replaceWith(o.from,o.to,n.schema.text(o.text,a))}else i.delete(o.from,o.to)}return!0}}return!1},Cx=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:s}=t;return r||e&&s.forEach(o=>{n.removeMark(o.$from.pos,o.$to.pos)}),!0},Nx=(n,e={})=>({tr:t,state:r,dispatch:s})=>{var o;const{extendEmptyMarkRange:i=!1}=e,{selection:l}=t,a=lt(n,r.schema),{$from:c,empty:d,ranges:u}=l;if(!s)return!0;if(d&&i){let{from:f,to:h}=l;const p=(o=c.marks().find(g=>g.type===a))==null?void 0:o.attrs,y=ml(c,a,p);y&&(f=y.from,h=y.to),t.removeMark(f,h,a)}else u.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},Ex=n=>({tr:e,state:t,dispatch:r})=>{const{selection:s}=t;let o,i;return typeof n=="number"?(o=n,i=n):n&&"from"in n&&"to"in n?(o=n.from,i=n.to):(o=s.from,i=s.to),r&&e.doc.nodesBetween(o,i,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},Tx=(n,e={})=>({tr:t,state:r,dispatch:s})=>{let o=null,i=null;const l=Ws(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(o=ue(n,r.schema)),l==="mark"&&(i=lt(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;let f,h,p,y;t.selection.empty?r.doc.nodesBetween(d,u,(g,x)=>{o&&o===g.type&&(a=!0,p=Math.max(x,d),y=Math.min(x+g.nodeSize,u),f=x,h=g)}):r.doc.nodesBetween(d,u,(g,x)=>{x<d&&o&&o===g.type&&(a=!0,p=Math.max(x,d),y=Math.min(x+g.nodeSize,u),f=x,h=g),x>=d&&x<=u&&(o&&o===g.type&&(a=!0,s&&t.setNodeMarkup(x,void 0,{...g.attrs,...e})),i&&g.marks.length&&g.marks.forEach(b=>{if(i===b.type&&(a=!0,s)){const S=Math.max(x,d),v=Math.min(x+g.nodeSize,u);t.addMark(S,v,i.create({...b.attrs,...e}))}}))}),h&&(f!==void 0&&s&&t.setNodeMarkup(f,void 0,{...h.attrs,...e}),i&&h.marks.length&&h.marks.forEach(g=>{i===g.type&&s&&t.addMark(p,y,i.create({...g.attrs,...e}))}))}),a},Mx=(n,e={})=>({state:t,dispatch:r})=>{const s=ue(n,t.schema);return r1(s,e)(t,r)},Ax=(n,e={})=>({state:t,dispatch:r})=>{const s=ue(n,t.schema);return s1(s,e)(t,r)},Ox=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){const t=this.callbacks[n];return t&&t.forEach(r=>r.apply(this,e)),this}off(n,e){const t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(r=>r!==e):delete this.callbacks[n]),this}once(n,e){const t=(...r)=>{this.off(n,t),e.apply(this,r)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}},Ks=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!=null?e:!0}},Ix=(n,e)=>{if(pl(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function Er(n){var e;const{editor:t,from:r,to:s,text:o,rules:i,plugin:l}=n,{view:a}=t;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(f=>f.type.spec.code))return!1;let d=!1;const u=rx(c)+o;return i.forEach(f=>{if(d)return;const h=Ix(u,f.find);if(!h)return;const p=a.state.tr,y=Vs({state:a.state,transaction:p}),g={from:r-(h[0].length-o.length),to:s},{commands:x,chain:b,can:S}=new Hs({editor:t,state:y});f.handler({state:y,range:g,match:h,commands:x,chain:b,can:S})===null||!p.steps.length||(f.undoable&&p.setMeta(l,{transform:p,from:r,to:s,text:o}),a.dispatch(p),d=!0)}),d}function Rx(n){const{editor:e,rules:t}=n,r=new re({state:{init(){return null},apply(s,o,i){const l=s.getMeta(r);if(l)return l;const a=s.getMeta("applyInputRules");return a&&setTimeout(()=>{let{text:d}=a;typeof d=="string"?d=d:d=yl(E.from(d),i.schema);const{from:u}=a,f=u+d.length;Er({editor:e,from:u,to:f,text:d,rules:t,plugin:r})}),s.selectionSet||s.docChanged?null:o}},props:{handleTextInput(s,o,i,l){return Er({editor:e,from:o,to:i,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:o}=s.state.selection;o&&Er({editor:e,from:o.pos,to:o.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(s,o){if(o.key!=="Enter")return!1;const{$cursor:i}=s.state.selection;return i?Er({editor:e,from:i.pos,to:i.pos,text:`
|
|
19
|
-
`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function jx(n){return Object.prototype.toString.call(n).slice(8,-1)}function Tr(n){return jx(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function tf(n,e){const t={...n};return Tr(n)&&Tr(e)&&Object.keys(e).forEach(r=>{Tr(e[r])&&Tr(n[r])?t[r]=tf(n[r],e[r]):t[r]=e[r]}),t}var bl=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...G(L(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...G(L(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>tf(this.options,n)});return e.name=this.name,e.parent=this.parent,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},Zt=class nf extends bl{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new nf(t)}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const i=s.marks();if(!!!i.find(c=>c?.type.name===t.name))return!1;const a=i.find(c=>c?.type.name===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function Dx(n){return typeof n=="number"}var Px=class{constructor(n){this.find=n.find,this.handler=n.handler}},Lx=(n,e,t)=>{if(pl(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(s=>{const o=[s.text];return o.index=s.index,o.input=n,o.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(s.replaceWith)),o}):[]};function $x(n){const{editor:e,state:t,from:r,to:s,rule:o,pasteEvent:i,dropEvent:l}=n,{commands:a,chain:c,can:d}=new Hs({editor:e,state:t}),u=[];return t.doc.nodesBetween(r,s,(h,p)=>{var y,g,x,b,S;if((g=(y=h.type)==null?void 0:y.spec)!=null&&g.code||!(h.isText||h.isTextblock||h.isInline))return;const v=(S=(b=(x=h.content)==null?void 0:x.size)!=null?b:h.nodeSize)!=null?S:0,k=Math.max(r,p),w=Math.min(s,p+v);if(k>=w)return;const C=h.isText?h.text||"":h.textBetween(k-p,w-p,void 0,"");Lx(C,o.find,i).forEach(A=>{if(A.index===void 0)return;const D=k+A.index+1,j=D+A[0].length,_={from:t.tr.mapping.map(D),to:t.tr.mapping.map(j)},V=o.handler({state:t,range:_,match:A,commands:a,chain:c,can:d,pasteEvent:i,dropEvent:l});u.push(V)})}),u.every(h=>h!==null)}var Mr=null,zx=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",n),t};function _x(n){const{editor:e,rules:t}=n;let r=null,s=!1,o=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:d,from:u,to:f,rule:h,pasteEvt:p})=>{const y=d.tr,g=Vs({state:d,transaction:y});if(!(!$x({editor:e,state:g,from:Math.max(u-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:l})||!y.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,y}};return t.map(d=>new re({view(u){const f=p=>{var y;r=(y=u.dom.parentElement)!=null&&y.contains(p.target)?u.dom.parentElement:null,r&&(Mr=e)},h=()=>{Mr&&(Mr=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(u,f)=>{if(o=r===u.dom.parentElement,l=f,!o){const h=Mr;h?.isEditable&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(u,f)=>{var h;const p=(h=f.clipboardData)==null?void 0:h.getData("text/html");return i=f,s=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(u,f,h)=>{const p=u[0],y=p.getMeta("uiEvent")==="paste"&&!s,g=p.getMeta("uiEvent")==="drop"&&!o,x=p.getMeta("applyPasteRules"),b=!!x;if(!y&&!g&&!b)return;if(b){let{text:k}=x;typeof k=="string"?k=k:k=yl(E.from(k),h.schema);const{from:w}=x,C=w+k.length,T=zx(k);return a({rule:d,state:h,from:w,to:{b:C},pasteEvt:T})}const S=f.doc.content.findDiffStart(h.doc.content),v=f.doc.content.findDiffEnd(h.doc.content);if(!(!Dx(S)||!v||S===v.b))return a({rule:d,state:h,from:S,to:v,pasteEvt:i})}}))}var Js=class{constructor(n,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=n,this.extensions=Ku(n),this.schema=Xy(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Nr(e.name,this.schema)},r=L(e,"addCommands",t);return r?{...n,...r()}:n},{})}get plugins(){const{editor:n}=this;return Zr([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:n,type:Nr(r.name,this.schema)},o=[],i=L(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&L(r,"exitable",s)&&(l.ArrowRight=()=>Zt.handleExit({editor:n,mark:r})),i){const f=Object.fromEntries(Object.entries(i()).map(([h,p])=>[h,()=>p({editor:n})]));l={...l,...f}}const a=Z0(l);o.push(a);const c=L(r,"addInputRules",s);if(nc(r,n.options.enableInputRules)&&c){const f=c();if(f&&f.length){const h=Rx({editor:n,rules:f}),p=Array.isArray(h)?h:[h];o.push(...p)}}const d=L(r,"addPasteRules",s);if(nc(r,n.options.enablePasteRules)&&d){const f=d();if(f&&f.length){const h=_x({editor:n,rules:f});o.push(...h)}}const u=L(r,"addProseMirrorPlugins",s);if(u){const f=u();o.push(...f)}return o})}get attributes(){return Uu(this.extensions)}get nodeViews(){const{editor:n}=this,{nodeExtensions:e}=En(this.extensions);return Object.fromEntries(e.filter(t=>!!L(t,"addNodeView")).map(t=>{const r=this.attributes.filter(a=>a.type===t.name),s={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:ue(t.name,this.schema)},o=L(t,"addNodeView",s);if(!o)return[];const i=o();if(!i)return[];const l=(a,c,d,u,f)=>{const h=Tn(a,r);return i({node:a,view:c,getPos:d,decorations:u,innerDecorations:f,editor:n,extension:t,HTMLAttributes:h})};return[t.name,l]}))}dispatchTransaction(n){const{editor:e}=this;return Zr([...this.extensions].reverse()).reduceRight((r,s)=>{const o={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Nr(s.name,this.schema)},i=L(s,"dispatchTransaction",o);return i?l=>{i.call(o,{transaction:l,next:r})}:r},n)}get markViews(){const{editor:n}=this,{markExtensions:e}=En(this.extensions);return Object.fromEntries(e.filter(t=>!!L(t,"addMarkView")).map(t=>{const r=this.attributes.filter(l=>l.type===t.name),s={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:lt(t.name,this.schema)},o=L(t,"addMarkView",s);if(!o)return[];const i=(l,a,c)=>{const d=Tn(l,r);return o()({mark:l,view:a,inline:c,editor:n,extension:t,HTMLAttributes:d,updateAttributes:u=>{Zx(l,n,u)}})};return[t.name,i]}))}setupExtensions(){const n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{var t;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Nr(e.name,this.schema)};e.type==="mark"&&((t=G(L(e,"keepOnSplit",r)))==null||t)&&this.splittableMarks.push(e.name);const s=L(e,"onBeforeCreate",r),o=L(e,"onCreate",r),i=L(e,"onUpdate",r),l=L(e,"onSelectionUpdate",r),a=L(e,"onTransaction",r),c=L(e,"onFocus",r),d=L(e,"onBlur",r),u=L(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),o&&this.editor.on("create",o),i&&this.editor.on("update",i),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}};Js.resolve=Ku;Js.sort=Zr;Js.flatten=gl;var Bx={};hl(Bx,{ClipboardTextSerializer:()=>sf,Commands:()=>of,Delete:()=>lf,Drop:()=>af,Editable:()=>cf,FocusEvents:()=>uf,Keymap:()=>ff,Paste:()=>hf,Tabindex:()=>pf,TextDirection:()=>mf,focusEventsPluginKey:()=>df});var ce=class rf extends bl{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new rf(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},sf=ce.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new re({key:new ae("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:s}=e,{ranges:o}=s,i=Math.min(...o.map(d=>d.$from.pos)),l=Math.max(...o.map(d=>d.$to.pos)),a=Gu(t);return Ju(r,{from:i,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),of=ce.create({name:"commands",addCommands(){return{...$u}}}),lf=ce.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,r,s;const o=()=>{var i,l,a,c;if((c=(a=(l=(i=this.editor.options.coreExtensionOptions)==null?void 0:i.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,n))!=null?c:n.getMeta("y-sync$"))return;const d=Wu(n.before,[n,...e]);Yu(d).forEach(h=>{d.mapping.mapResult(h.oldRange.from).deletedAfter&&d.mapping.mapResult(h.oldRange.to).deletedBefore&&d.before.nodesBetween(h.oldRange.from,h.oldRange.to,(p,y)=>{const g=y+p.nodeSize-2,x=h.oldRange.from<=y&&g<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:y,to:g,newFrom:d.mapping.map(y),newTo:d.mapping.map(g),deletedRange:h.oldRange,newRange:h.newRange,partial:!x,editor:this.editor,transaction:n,combinedTransform:d})})});const f=d.mapping;d.steps.forEach((h,p)=>{var y,g;if(h instanceof He){const x=f.slice(p).map(h.from,-1),b=f.slice(p).map(h.to),S=f.invert().map(x,-1),v=f.invert().map(b),k=(y=d.doc.nodeAt(x-1))==null?void 0:y.marks.some(C=>C.eq(h.mark)),w=(g=d.doc.nodeAt(b))==null?void 0:g.marks.some(C=>C.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:S,to:v},newRange:{from:x,to:b},partial:!!(w||k),editor:this.editor,transaction:n,combinedTransform:d})}})};(s=(r=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:r.async)==null||s?setTimeout(o,0):o()}}),af=ce.create({name:"drop",addProseMirrorPlugins(){return[new re({key:new ae("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),cf=ce.create({name:"editable",addProseMirrorPlugins(){return[new re({key:new ae("editable"),props:{editable:()=>this.editor.options.editable}})]}}),df=new ae("focusEvents"),uf=ce.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new re({key:df,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),ff=ce.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:f,parent:h}=u,p=u.parent.isTextblock&&f>0?l.doc.resolve(f-1):u,y=p.parent.type.spec.isolating,g=u.pos-u.parentOffset,x=y&&p.parent.childCount===1?g===u.pos:q.atStart(c).from===f;return!d||!h.type.isTextblock||h.textContent.length||!x||x&&u.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},o={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return cr()||Vu()?o:s},addProseMirrorPlugins(){return[new re({key:new ae("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(y=>y.getMeta("composition")))return;const r=n.some(y=>y.docChanged)&&!e.doc.eq(t.doc),s=n.some(y=>y.getMeta("preventClearDocument"));if(!r||s)return;const{empty:o,from:i,to:l}=e.selection,a=q.atStart(e.doc).from,c=q.atEnd(e.doc).to;if(o||!(i===a&&l===c)||!Us(t.doc))return;const f=t.tr,h=Vs({state:t,transaction:f}),{commands:p}=new Hs({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),hf=ce.create({name:"paste",addProseMirrorPlugins(){return[new re({key:new ae("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),pf=ce.create({name:"tabindex",addProseMirrorPlugins(){return[new re({key:new ae("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),mf=ce.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:n}=En(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new re({key:new ae("textDirection"),props:{attributes:()=>{const n=this.options.direction;return n?{dir:n}:{}}}})]}}),Fx=class gn{constructor(e,t,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new gn(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new gn(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new gn(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const s=t.isBlock&&!t.isTextblock,o=t.isAtom&&!t.isText,i=this.pos+r+(o?0:1);if(i<0||i>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(i);if(!s&&l.depth<=this.depth)return;const a=new gn(l,this.editor,s,s?t:null);s&&(a.actualDepth=this.depth+1),e.push(new gn(l,this.editor,s,s?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(t).length>0){const o=s.node.attrs,i=Object.keys(t);for(let l=0;l<i.length;l+=1){const a=i[l];if(o[a]!==t[a])break}}else r=s;s=s.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const o=Object.keys(t);return this.children.forEach(i=>{r&&s.length>0||(i.node.type.name===e&&o.every(a=>t[a]===i.node.attrs[a])&&s.push(i),!(r&&s.length>0)&&(s=s.concat(i.querySelectorAll(e,t,r))))}),s}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},Vx=`.ProseMirror {
|
|
18
|
+
`,textSerializers:i={}}=t||{};let l="";return n.nodesBetween(r,s,(a,c,d,u)=>{var f;a.isBlock&&c>r&&(l+=o);const h=i?.[a.type.name];if(h)return d&&(l+=h({node:a,pos:c,parent:d,index:u,range:e})),!1;a.isText&&(l+=(f=a?.text)==null?void 0:f.slice(Math.max(r,c)-c,s-c))}),l}function ix(n,e){const t={from:0,to:n.content.size};return Ju(n,t,e)}function Gu(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function lx(n,e){const t=ue(e,n.schema),{from:r,to:s}=n.selection,o=[];n.doc.nodesBetween(r,s,l=>{o.push(l)});const i=o.reverse().find(l=>l.type.name===t.name);return i?{...i.attrs}:{}}function Xu(n,e){const t=Ws(typeof e=="string"?e:e.name,n.schema);return t==="node"?lx(n,e):t==="mark"?Hu(n,e):{}}function ax(n,e=JSON.stringify){const t={};return n.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(t,s)?!1:t[s]=!0})}function cx(n){const e=ax(n);return e.length===1?e:e.filter((t,r)=>!e.filter((o,i)=>i!==r).some(o=>t.oldRange.from>=o.oldRange.from&&t.oldRange.to<=o.oldRange.to&&t.newRange.from>=o.newRange.from&&t.newRange.to<=o.newRange.to))}function Yu(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((s,o)=>{const i=[];if(s.ranges.length)s.forEach((l,a)=>{i.push({from:l,to:a})});else{const{from:l,to:a}=t[o];if(l===void 0||a===void 0)return;i.push({from:l,to:a})}i.forEach(({from:l,to:a})=>{const c=e.slice(o).map(l,-1),d=e.slice(o).map(a),u=e.invert().map(c,-1),f=e.invert().map(d);r.push({oldRange:{from:u,to:f},newRange:{from:c,to:d}})})}),cx(r)}function xl(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(s=>{const o=t.resolve(n),i=ml(o,s.type);i&&r.push({mark:s,...i})}):t.nodesBetween(n,e,(s,o)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(i=>({from:o,to:o+s.nodeSize,mark:i})))}),r}var dx=(n,e,t,r=20)=>{const s=n.doc.resolve(t);let o=r,i=null;for(;o>0&&i===null;){const l=s.node(o);l?.type.name===e?i=l:o-=1}return[i,o]};function Nr(n,e){return e.nodes[n]||e.marks[n]||null}function Lr(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const s=n.find(o=>o.type===e&&o.name===r);return s?s.attribute.keepOnSplit:!1}))}var ux=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(s,o,i,l)=>{var a,c;const d=((c=(a=s.type.spec).toText)==null?void 0:c.call(a,{node:s,pos:o,parent:i,index:l}))||s.textContent||"%leaf%";t+=s.isAtom&&!s.isText?d:d.slice(0,Math.max(0,r-o))}),t};function ci(n,e,t={}){const{empty:r,ranges:s}=n.selection,o=e?lt(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>o?o.name===u.type.name:!0).find(u=>Qr(u.attrs,t,{strict:!1}));let i=0;const l=[];if(s.forEach(({$from:u,$to:f})=>{const h=u.pos,p=f.pos;n.doc.nodesBetween(h,p,(y,g)=>{if(!y.isText&&!y.marks.length)return;const x=Math.max(h,g),b=Math.min(p,g+y.nodeSize),S=b-x;i+=S,l.push(...y.marks.map(v=>({mark:v,from:x,to:b})))})}),i===0)return!1;const a=l.filter(u=>o?o.name===u.mark.type.name:!0).filter(u=>Qr(u.mark.attrs,t,{strict:!1})).reduce((u,f)=>u+f.to-f.from,0),c=l.filter(u=>o?u.mark.type!==o&&u.mark.type.excludes(o):!0).reduce((u,f)=>u+f.to-f.from,0);return(a>0?a+c:a)>=i}function fx(n,e,t={}){if(!e)return Nt(n,null,t)||ci(n,null,t);const r=Ws(e,n.schema);return r==="node"?Nt(n,e,t):r==="mark"?ci(n,e,t):!1}var hx=(n,e)=>{const{$from:t,$to:r,$anchor:s}=n.selection;if(e){const o=qs(l=>l.type.name===e)(n.selection);if(!o)return!1;const i=n.doc.resolve(o.pos+1);return s.pos+1===i.end()}return!(r.parentOffset<r.parent.nodeSize-2||t.pos!==r.pos)},px=n=>{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function nc(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function rc(n,e){const{nodeExtensions:t}=En(e),r=t.find(i=>i.name===n);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},o=G(L(r,"group",s));return typeof o!="string"?!1:o.split(" ").includes("list")}function Us(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!=null?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let s=!0;return n.content.forEach(o=>{s!==!1&&(Us(o,{ignoreWhitespace:t,checkChildren:e})||(s=!1))}),s}return!1}function Qu(n){return n instanceof $}var Zu=class ef{constructor(e){this.position=e}static fromJSON(e){return new ef(e.position)}toJSON(){return{position:this.position}}};function mx(n,e){const t=e.mapping.mapResult(n.position);return{position:new Zu(t.pos),mapResult:t}}function gx(n){return new Zu(n)}function yx(n,e,t){var r;const{selection:s}=e;let o=null;if(_u(s)&&(o=s.$cursor),o){const l=(r=n.storedMarks)!=null?r:o.marks();return o.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(c=>c.type.excludes(t)))}const{ranges:i}=s;return i.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(d,u,f)=>{if(c)return!1;if(d.isInline){const h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(d.marks)||!d.marks.some(y=>y.type.excludes(t));c=h&&p}return!c}),c})}var xx=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const{selection:o}=t,{empty:i,ranges:l}=o,a=lt(n,r.schema);if(s)if(i){const c=Hu(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(f,h)=>{const p=Math.max(h,d),y=Math.min(h+f.nodeSize,u);f.marks.find(x=>x.type===a)?f.marks.forEach(x=>{a===x.type&&t.addMark(p,y,a.create({...x.attrs,...e}))}):t.addMark(p,y,a.create(e))})});return yx(r,t,a)},bx=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),kx=(n,e={})=>({state:t,dispatch:r,chain:s})=>{const o=ue(n,t.schema);let i;return t.selection.$anchor.sameParent(t.selection.$head)&&(i=t.selection.$anchor.parent.attrs),o.isTextblock?s().command(({commands:l})=>ya(o,{...i,...e})(t)?!0:l.clearNodes()).command(({state:l})=>ya(o,{...i,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Sx=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,s=Dt(n,0,r.content.size),o=$.create(r,s);e.setSelection(o)}return!0},wx=(n,e)=>({tr:t,state:r,dispatch:s})=>{const{selection:o}=r;let i,l;return typeof e=="number"?(i=e,l=e):e&&"from"in e&&"to"in e?(i=e.from,l=e.to):(i=o.from,l=o.to),s&&t.doc.nodesBetween(i,l,(a,c)=>{a.isText||t.setNodeMarkup(c,void 0,{...a.attrs,dir:n})}),!0},vx=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:s,to:o}=typeof n=="number"?{from:n,to:n}:n,i=F.atStart(r).from,l=F.atEnd(r).to,a=Dt(s,i,l),c=Dt(o,i,l),d=F.create(r,a,c);e.setSelection(d)}return!0},Cx=n=>({state:e,dispatch:t})=>{const r=ue(n,e.schema);return y1(r)(e,t)};function sc(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(s=>e?.includes(s.type.name));n.tr.ensureMarks(r)}}var Nx=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:s})=>{const{selection:o,doc:i}=e,{$from:l,$to:a}=o,c=s.extensionManager.attributes,d=Lr(c,l.node().type.name,l.node().attrs);if(o instanceof $&&o.node.isBlock)return!l.parentOffset||!ot(i,l.pos)?!1:(r&&(n&&sc(t,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const u=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:Zy(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=u&&f?[{type:f,attrs:d}]:void 0,p=ot(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&ot(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:d}]:void 0),r){if(p&&(o instanceof F&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!u&&!l.parentOffset&&l.parent.type!==f)){const y=e.mapping.map(l.before()),g=e.doc.resolve(y);l.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&sc(t,s.extensionManager.splittableMarks),e.scrollIntoView()}return p},Ex=(n,e={})=>({tr:t,state:r,dispatch:s,editor:o})=>{var i;const l=ue(n,r.schema),{$from:a,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||a.depth<2||!a.sameParent(c))return!1;const u=a.node(-1);if(u.type!==l)return!1;const f=o.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(s){let x=E.empty;const b=a.index(-1)?1:a.index(-2)?2:3;for(let T=a.depth-b;T>=a.depth-3;T-=1)x=E.from(a.node(T).copy(x));const S=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,v={...Lr(f,a.node().type.name,a.node().attrs),...e},k=((i=l.contentMatch.defaultType)==null?void 0:i.createAndFill(v))||void 0;x=x.append(E.from(l.createAndFill(null,k)||void 0));const w=a.before(a.depth-(b-1));t.replace(w,a.after(-S),new R(x,4-b,0));let C=-1;t.doc.nodesBetween(w,t.doc.content.size,(T,A)=>{if(C>-1)return!1;T.isTextblock&&T.content.size===0&&(C=A+1)}),C>-1&&t.setSelection(F.near(t.doc.resolve(C))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,p={...Lr(f,u.type.name,u.attrs),...e},y={...Lr(f,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const g=h?[{type:l,attrs:p},{type:h,attrs:y}]:[{type:l,attrs:p}];if(!ot(t.doc,a.pos,2))return!1;if(s){const{selection:x,storedMarks:b}=r,{splittableMarks:S}=o.extensionManager,v=b||x.$to.parentOffset&&x.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!v||!s)return!0;const k=v.filter(w=>S.includes(w.type.name));t.ensureMarks(k)}return!0},Ao=(n,e)=>{const t=qs(i=>i.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===s?.type&&Mt(n.doc,t.pos)&&n.join(t.pos),!0},Oo=(n,e)=>{const t=qs(i=>i.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===s?.type&&Mt(n.doc,r)&&n.join(r),!0},Tx=(n,e,t,r={})=>({editor:s,tr:o,state:i,dispatch:l,chain:a,commands:c,can:d})=>{const{extensions:u,splittableMarks:f}=s.extensionManager,h=ue(n,i.schema),p=ue(e,i.schema),{selection:y,storedMarks:g}=i,{$from:x,$to:b}=y,S=x.blockRange(b),v=g||y.$to.parentOffset&&y.$from.marks();if(!S)return!1;const k=qs(w=>rc(w.type.name,u))(y);if(S.depth>=1&&k&&S.depth-k.depth<=1){if(k.node.type===h)return c.liftListItem(p);if(rc(k.node.type.name,u)&&h.validContent(k.node.content)&&l)return a().command(()=>(o.setNodeMarkup(k.pos,h),!0)).command(()=>Ao(o,h)).command(()=>Oo(o,h)).run()}return!t||!v||!l?a().command(()=>d().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Ao(o,h)).command(()=>Oo(o,h)).run():a().command(()=>{const w=d().wrapInList(h,r),C=v.filter(T=>f.includes(T.type.name));return o.ensureMarks(C),w?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Ao(o,h)).command(()=>Oo(o,h)).run()},Mx=(n,e={},t={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:o=!1}=t,i=lt(n,r.schema);return ci(r,i,e)?s.unsetMark(i,{extendEmptyMarkRange:o}):s.setMark(i,e)},Ax=(n,e,t={})=>({state:r,commands:s})=>{const o=ue(n,r.schema),i=ue(e,r.schema),l=Nt(r,o,t);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(i,a):s.setNode(o,{...a,...t})},Ox=(n,e={})=>({state:t,commands:r})=>{const s=ue(n,t.schema);return Nt(t,s,e)?r.lift(s):r.wrapIn(s,e)},Ix=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const s=t[r];let o;if(s.spec.isInputRules&&(o=s.getState(n))){if(e){const i=n.tr,l=o.transform;for(let a=l.steps.length-1;a>=0;a-=1)i.step(l.steps[a].invert(l.docs[a]));if(o.text){const a=i.doc.resolve(o.from).marks();i.replaceWith(o.from,o.to,n.schema.text(o.text,a))}else i.delete(o.from,o.to)}return!0}}return!1},Rx=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:s}=t;return r||e&&s.forEach(o=>{n.removeMark(o.$from.pos,o.$to.pos)}),!0},jx=(n,e={})=>({tr:t,state:r,dispatch:s})=>{var o;const{extendEmptyMarkRange:i=!1}=e,{selection:l}=t,a=lt(n,r.schema),{$from:c,empty:d,ranges:u}=l;if(!s)return!0;if(d&&i){let{from:f,to:h}=l;const p=(o=c.marks().find(g=>g.type===a))==null?void 0:o.attrs,y=ml(c,a,p);y&&(f=y.from,h=y.to),t.removeMark(f,h,a)}else u.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},Dx=n=>({tr:e,state:t,dispatch:r})=>{const{selection:s}=t;let o,i;return typeof n=="number"?(o=n,i=n):n&&"from"in n&&"to"in n?(o=n.from,i=n.to):(o=s.from,i=s.to),r&&e.doc.nodesBetween(o,i,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},Px=(n,e={})=>({tr:t,state:r,dispatch:s})=>{let o=null,i=null;const l=Ws(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(o=ue(n,r.schema)),l==="mark"&&(i=lt(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;let f,h,p,y;t.selection.empty?r.doc.nodesBetween(d,u,(g,x)=>{o&&o===g.type&&(a=!0,p=Math.max(x,d),y=Math.min(x+g.nodeSize,u),f=x,h=g)}):r.doc.nodesBetween(d,u,(g,x)=>{x<d&&o&&o===g.type&&(a=!0,p=Math.max(x,d),y=Math.min(x+g.nodeSize,u),f=x,h=g),x>=d&&x<=u&&(o&&o===g.type&&(a=!0,s&&t.setNodeMarkup(x,void 0,{...g.attrs,...e})),i&&g.marks.length&&g.marks.forEach(b=>{if(i===b.type&&(a=!0,s)){const S=Math.max(x,d),v=Math.min(x+g.nodeSize,u);t.addMark(S,v,i.create({...b.attrs,...e}))}}))}),h&&(f!==void 0&&s&&t.setNodeMarkup(f,void 0,{...h.attrs,...e}),i&&h.marks.length&&h.marks.forEach(g=>{i===g.type&&s&&t.addMark(p,y,i.create({...g.attrs,...e}))}))}),a},Lx=(n,e={})=>({state:t,dispatch:r})=>{const s=ue(n,t.schema);return d1(s,e)(t,r)},$x=(n,e={})=>({state:t,dispatch:r})=>{const s=ue(n,t.schema);return u1(s,e)(t,r)},zx=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){const t=this.callbacks[n];return t&&t.forEach(r=>r.apply(this,e)),this}off(n,e){const t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(r=>r!==e):delete this.callbacks[n]),this}once(n,e){const t=(...r)=>{this.off(n,t),e.apply(this,r)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}},Ks=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!=null?e:!0}},_x=(n,e)=>{if(pl(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function Er(n){var e;const{editor:t,from:r,to:s,text:o,rules:i,plugin:l}=n,{view:a}=t;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(f=>f.type.spec.code))return!1;let d=!1;const u=ux(c)+o;return i.forEach(f=>{if(d)return;const h=_x(u,f.find);if(!h)return;const p=a.state.tr,y=Vs({state:a.state,transaction:p}),g={from:r-(h[0].length-o.length),to:s},{commands:x,chain:b,can:S}=new Hs({editor:t,state:y});f.handler({state:y,range:g,match:h,commands:x,chain:b,can:S})===null||!p.steps.length||(f.undoable&&p.setMeta(l,{transform:p,from:r,to:s,text:o}),a.dispatch(p),d=!0)}),d}function Bx(n){const{editor:e,rules:t}=n,r=new re({state:{init(){return null},apply(s,o,i){const l=s.getMeta(r);if(l)return l;const a=s.getMeta("applyInputRules");return a&&setTimeout(()=>{let{text:d}=a;typeof d=="string"?d=d:d=yl(E.from(d),i.schema);const{from:u}=a,f=u+d.length;Er({editor:e,from:u,to:f,text:d,rules:t,plugin:r})}),s.selectionSet||s.docChanged?null:o}},props:{handleTextInput(s,o,i,l){return Er({editor:e,from:o,to:i,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:o}=s.state.selection;o&&Er({editor:e,from:o.pos,to:o.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(s,o){if(o.key!=="Enter")return!1;const{$cursor:i}=s.state.selection;return i?Er({editor:e,from:i.pos,to:i.pos,text:`
|
|
19
|
+
`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function Fx(n){return Object.prototype.toString.call(n).slice(8,-1)}function Tr(n){return Fx(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function tf(n,e){const t={...n};return Tr(n)&&Tr(e)&&Object.keys(e).forEach(r=>{Tr(e[r])&&Tr(n[r])?t[r]=tf(n[r],e[r]):t[r]=e[r]}),t}var bl=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...G(L(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...G(L(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>tf(this.options,n)});return e.name=this.name,e.parent=this.parent,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},Zt=class nf extends bl{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new nf(t)}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const i=s.marks();if(!!!i.find(c=>c?.type.name===t.name))return!1;const a=i.find(c=>c?.type.name===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function Vx(n){return typeof n=="number"}var Hx=class{constructor(n){this.find=n.find,this.handler=n.handler}},Wx=(n,e,t)=>{if(pl(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(s=>{const o=[s.text];return o.index=s.index,o.input=n,o.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(s.replaceWith)),o}):[]};function qx(n){const{editor:e,state:t,from:r,to:s,rule:o,pasteEvent:i,dropEvent:l}=n,{commands:a,chain:c,can:d}=new Hs({editor:e,state:t}),u=[];return t.doc.nodesBetween(r,s,(h,p)=>{var y,g,x,b,S;if((g=(y=h.type)==null?void 0:y.spec)!=null&&g.code||!(h.isText||h.isTextblock||h.isInline))return;const v=(S=(b=(x=h.content)==null?void 0:x.size)!=null?b:h.nodeSize)!=null?S:0,k=Math.max(r,p),w=Math.min(s,p+v);if(k>=w)return;const C=h.isText?h.text||"":h.textBetween(k-p,w-p,void 0,"");Wx(C,o.find,i).forEach(A=>{if(A.index===void 0)return;const D=k+A.index+1,j=D+A[0].length,_={from:t.tr.mapping.map(D),to:t.tr.mapping.map(j)},V=o.handler({state:t,range:_,match:A,commands:a,chain:c,can:d,pasteEvent:i,dropEvent:l});u.push(V)})}),u.every(h=>h!==null)}var Mr=null,Ux=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",n),t};function Kx(n){const{editor:e,rules:t}=n;let r=null,s=!1,o=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:d,from:u,to:f,rule:h,pasteEvt:p})=>{const y=d.tr,g=Vs({state:d,transaction:y});if(!(!qx({editor:e,state:g,from:Math.max(u-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:l})||!y.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,y}};return t.map(d=>new re({view(u){const f=p=>{var y;r=(y=u.dom.parentElement)!=null&&y.contains(p.target)?u.dom.parentElement:null,r&&(Mr=e)},h=()=>{Mr&&(Mr=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(u,f)=>{if(o=r===u.dom.parentElement,l=f,!o){const h=Mr;h?.isEditable&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(u,f)=>{var h;const p=(h=f.clipboardData)==null?void 0:h.getData("text/html");return i=f,s=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(u,f,h)=>{const p=u[0],y=p.getMeta("uiEvent")==="paste"&&!s,g=p.getMeta("uiEvent")==="drop"&&!o,x=p.getMeta("applyPasteRules"),b=!!x;if(!y&&!g&&!b)return;if(b){let{text:k}=x;typeof k=="string"?k=k:k=yl(E.from(k),h.schema);const{from:w}=x,C=w+k.length,T=Ux(k);return a({rule:d,state:h,from:w,to:{b:C},pasteEvt:T})}const S=f.doc.content.findDiffStart(h.doc.content),v=f.doc.content.findDiffEnd(h.doc.content);if(!(!Vx(S)||!v||S===v.b))return a({rule:d,state:h,from:S,to:v,pasteEvt:i})}}))}var Js=class{constructor(n,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=n,this.extensions=Ku(n),this.schema=sx(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Nr(e.name,this.schema)},r=L(e,"addCommands",t);return r?{...n,...r()}:n},{})}get plugins(){const{editor:n}=this;return Zr([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:n,type:Nr(r.name,this.schema)},o=[],i=L(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&L(r,"exitable",s)&&(l.ArrowRight=()=>Zt.handleExit({editor:n,mark:r})),i){const f=Object.fromEntries(Object.entries(i()).map(([h,p])=>[h,()=>p({editor:n})]));l={...l,...f}}const a=ly(l);o.push(a);const c=L(r,"addInputRules",s);if(nc(r,n.options.enableInputRules)&&c){const f=c();if(f&&f.length){const h=Bx({editor:n,rules:f}),p=Array.isArray(h)?h:[h];o.push(...p)}}const d=L(r,"addPasteRules",s);if(nc(r,n.options.enablePasteRules)&&d){const f=d();if(f&&f.length){const h=Kx({editor:n,rules:f});o.push(...h)}}const u=L(r,"addProseMirrorPlugins",s);if(u){const f=u();o.push(...f)}return o})}get attributes(){return Uu(this.extensions)}get nodeViews(){const{editor:n}=this,{nodeExtensions:e}=En(this.extensions);return Object.fromEntries(e.filter(t=>!!L(t,"addNodeView")).map(t=>{const r=this.attributes.filter(a=>a.type===t.name),s={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:ue(t.name,this.schema)},o=L(t,"addNodeView",s);if(!o)return[];const i=o();if(!i)return[];const l=(a,c,d,u,f)=>{const h=Tn(a,r);return i({node:a,view:c,getPos:d,decorations:u,innerDecorations:f,editor:n,extension:t,HTMLAttributes:h})};return[t.name,l]}))}dispatchTransaction(n){const{editor:e}=this;return Zr([...this.extensions].reverse()).reduceRight((r,s)=>{const o={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Nr(s.name,this.schema)},i=L(s,"dispatchTransaction",o);return i?l=>{i.call(o,{transaction:l,next:r})}:r},n)}get markViews(){const{editor:n}=this,{markExtensions:e}=En(this.extensions);return Object.fromEntries(e.filter(t=>!!L(t,"addMarkView")).map(t=>{const r=this.attributes.filter(l=>l.type===t.name),s={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:lt(t.name,this.schema)},o=L(t,"addMarkView",s);if(!o)return[];const i=(l,a,c)=>{const d=Tn(l,r);return o()({mark:l,view:a,inline:c,editor:n,extension:t,HTMLAttributes:d,updateAttributes:u=>{lb(l,n,u)}})};return[t.name,i]}))}setupExtensions(){const n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{var t;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Nr(e.name,this.schema)};e.type==="mark"&&((t=G(L(e,"keepOnSplit",r)))==null||t)&&this.splittableMarks.push(e.name);const s=L(e,"onBeforeCreate",r),o=L(e,"onCreate",r),i=L(e,"onUpdate",r),l=L(e,"onSelectionUpdate",r),a=L(e,"onTransaction",r),c=L(e,"onFocus",r),d=L(e,"onBlur",r),u=L(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),o&&this.editor.on("create",o),i&&this.editor.on("update",i),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}};Js.resolve=Ku;Js.sort=Zr;Js.flatten=gl;var Jx={};hl(Jx,{ClipboardTextSerializer:()=>sf,Commands:()=>of,Delete:()=>lf,Drop:()=>af,Editable:()=>cf,FocusEvents:()=>uf,Keymap:()=>ff,Paste:()=>hf,Tabindex:()=>pf,TextDirection:()=>mf,focusEventsPluginKey:()=>df});var ce=class rf extends bl{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new rf(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},sf=ce.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new re({key:new ae("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:s}=e,{ranges:o}=s,i=Math.min(...o.map(d=>d.$from.pos)),l=Math.max(...o.map(d=>d.$to.pos)),a=Gu(t);return Ju(r,{from:i,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),of=ce.create({name:"commands",addCommands(){return{...$u}}}),lf=ce.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,r,s;const o=()=>{var i,l,a,c;if((c=(a=(l=(i=this.editor.options.coreExtensionOptions)==null?void 0:i.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,n))!=null?c:n.getMeta("y-sync$"))return;const d=Wu(n.before,[n,...e]);Yu(d).forEach(h=>{d.mapping.mapResult(h.oldRange.from).deletedAfter&&d.mapping.mapResult(h.oldRange.to).deletedBefore&&d.before.nodesBetween(h.oldRange.from,h.oldRange.to,(p,y)=>{const g=y+p.nodeSize-2,x=h.oldRange.from<=y&&g<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:y,to:g,newFrom:d.mapping.map(y),newTo:d.mapping.map(g),deletedRange:h.oldRange,newRange:h.newRange,partial:!x,editor:this.editor,transaction:n,combinedTransform:d})})});const f=d.mapping;d.steps.forEach((h,p)=>{var y,g;if(h instanceof He){const x=f.slice(p).map(h.from,-1),b=f.slice(p).map(h.to),S=f.invert().map(x,-1),v=f.invert().map(b),k=(y=d.doc.nodeAt(x-1))==null?void 0:y.marks.some(C=>C.eq(h.mark)),w=(g=d.doc.nodeAt(b))==null?void 0:g.marks.some(C=>C.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:S,to:v},newRange:{from:x,to:b},partial:!!(w||k),editor:this.editor,transaction:n,combinedTransform:d})}})};(s=(r=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:r.async)==null||s?setTimeout(o,0):o()}}),af=ce.create({name:"drop",addProseMirrorPlugins(){return[new re({key:new ae("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),cf=ce.create({name:"editable",addProseMirrorPlugins(){return[new re({key:new ae("editable"),props:{editable:()=>this.editor.options.editable}})]}}),df=new ae("focusEvents"),uf=ce.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new re({key:df,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),ff=ce.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:f,parent:h}=u,p=u.parent.isTextblock&&f>0?l.doc.resolve(f-1):u,y=p.parent.type.spec.isolating,g=u.pos-u.parentOffset,x=y&&p.parent.childCount===1?g===u.pos:q.atStart(c).from===f;return!d||!h.type.isTextblock||h.textContent.length||!x||x&&u.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},o={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return cr()||Vu()?o:s},addProseMirrorPlugins(){return[new re({key:new ae("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(y=>y.getMeta("composition")))return;const r=n.some(y=>y.docChanged)&&!e.doc.eq(t.doc),s=n.some(y=>y.getMeta("preventClearDocument"));if(!r||s)return;const{empty:o,from:i,to:l}=e.selection,a=q.atStart(e.doc).from,c=q.atEnd(e.doc).to;if(o||!(i===a&&l===c)||!Us(t.doc))return;const f=t.tr,h=Vs({state:t,transaction:f}),{commands:p}=new Hs({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),hf=ce.create({name:"paste",addProseMirrorPlugins(){return[new re({key:new ae("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),pf=ce.create({name:"tabindex",addProseMirrorPlugins(){return[new re({key:new ae("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),mf=ce.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:n}=En(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new re({key:new ae("textDirection"),props:{attributes:()=>{const n=this.options.direction;return n?{dir:n}:{}}}})]}}),Gx=class gn{constructor(e,t,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new gn(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new gn(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new gn(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const s=t.isBlock&&!t.isTextblock,o=t.isAtom&&!t.isText,i=this.pos+r+(o?0:1);if(i<0||i>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(i);if(!s&&l.depth<=this.depth)return;const a=new gn(l,this.editor,s,s?t:null);s&&(a.actualDepth=this.depth+1),e.push(new gn(l,this.editor,s,s?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(t).length>0){const o=s.node.attrs,i=Object.keys(t);for(let l=0;l<i.length;l+=1){const a=i[l];if(o[a]!==t[a])break}}else r=s;s=s.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const o=Object.keys(t);return this.children.forEach(i=>{r&&s.length>0||(i.node.type.name===e&&o.every(a=>t[a]===i.node.attrs[a])&&s.push(i),!(r&&s.length>0)&&(s=s.concat(i.querySelectorAll(e,t,r))))}),s}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},Xx=`.ProseMirror {
|
|
20
20
|
position: relative;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -86,15 +86,15 @@ img.ProseMirror-separator {
|
|
|
86
86
|
|
|
87
87
|
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
88
88
|
display: block;
|
|
89
|
-
}`;function
|
|
89
|
+
}`;function Yx(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(s),s}var Qx=class extends zx{constructor(n={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:mx,createMappablePosition:gx},this.setOptions(n),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:s,moved:o})=>this.options.onDrop(r,s,o)),this.on("paste",({event:r,slice:s})=>this.options.onPaste(r,s)),this.on("delete",this.options.onDelete);const e=this.createDoc(),t=Bu(e,this.options.autofocus);this.editorState=xn.create({doc:e,schema:this.schema,selection:t||void 0}),this.options.element&&this.mount(this.options.element)}mount(n){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(n),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const n=this.editorView.dom;n?.editor&&delete n.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(n){console.warn("Failed to remove CSS element:",n)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=Yx(Xx,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(n,e=!0){this.setOptions({editable:n}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:n=>{this.editorState=n},dispatch:n=>{this.dispatchTransaction(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in n)return Reflect.get(n,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(n,e){const t=qu(e)?e(n,[...this.state.plugins]):[...this.state.plugins,n],r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}unregisterPlugin(n){if(this.isDestroyed)return;const e=this.state.plugins;let t=e;if([].concat(n).forEach(s=>{const o=typeof s=="string"?`${s}$`:s.key;t=t.filter(i=>!i.key.startsWith(o))}),e.length===t.length)return;const r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}createExtensionManager(){var n,e;const r=[...this.options.enableCoreExtensions?[cf,sf.configure({blockSeparator:(e=(n=this.options.coreExtensionOptions)==null?void 0:n.clipboardTextSerializer)==null?void 0:e.blockSeparator}),of,uf,ff,pf,af,hf,lf,mf.configure({direction:this.options.textDirection})].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s?.type));this.extensionManager=new Js(r,this)}createCommandManager(){this.commandManager=new Hs({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=ai(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(t=>t.name!=="collaboration"),this.createExtensionManager()}}),n=ai(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return n}createView(n){const{editorProps:e,enableExtensionDispatchTransaction:t}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=t?this.extensionManager.dispatchTransaction(r):r;this.editorView=new Pu(n,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const o=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(o),this.prependClass(),this.injectCSS();const i=this.view.dom;i.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(c=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(c)});return}const{state:e,transactions:t}=this.state.applyTransaction(n),r=!this.state.selection.eq(e.selection),s=t.includes(n),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:t.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:n});const i=t.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=i?.getMeta("focus"),a=i?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:i}),a&&this.emit("blur",{editor:this,event:a.event,transaction:i}),!(n.getMeta("preventUpdate")||!t.some(c=>c.docChanged)||o.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:t.slice(1)})}getAttributes(n){return Xu(this.state,n)}isActive(n,e){const t=typeof n=="string"?n:null,r=typeof n=="string"?e:n;return fx(this.state,t,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return yl(this.state.doc.content,this.schema)}getText(n){const{blockSeparator:e=`
|
|
90
90
|
|
|
91
|
-
`,textSerializers:t={}}=n||{};return
|
|
91
|
+
`,textSerializers:t={}}=n||{};return ix(this.state.doc,{blockSeparator:e,textSerializers:{...Gu(this.schema),...t}})}get isEmpty(){return Us(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var n,e;return(e=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?e:!0}$node(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelectorAll(n,e))||null}$pos(n){const e=this.state.doc.resolve(n);return new Gx(e,this)}get $doc(){return this.$pos(0)}};function Mn(n){return new Ks({find:n.find,handler:({state:e,range:t,match:r})=>{const s=G(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:o}=e,i=r[r.length-1],l=r[0];if(i){const a=l.search(/\S/),c=t.from+l.indexOf(i),d=c+i.length;if(xl(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(y=>y===n.type&&y!==h.mark.type)).filter(h=>h.to>c).length)return null;d<t.to&&o.delete(d,t.to),c>t.from&&o.delete(t.from+a,c);const f=t.from+a+i.length;o.addMark(t.from+a,f,n.type.create(s||{})),o.removeStoredMark(n.type)}},undoable:n.undoable})}function Zx(n){return new Ks({find:n.find,handler:({state:e,range:t,match:r})=>{const s=G(n.getAttributes,void 0,r)||{},{tr:o}=e,i=t.from;let l=t.to;const a=n.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let d=i+c;d>l?d=l:l=d+r[1].length;const u=r[0][r[0].length-1];o.insertText(u,i+r[0].length-1),o.replaceWith(d,l,a)}else if(r[0]){const c=n.type.isInline?i:i-1;o.insert(c,n.type.create(s)).delete(o.mapping.map(i),o.mapping.map(l))}o.scrollIntoView()},undoable:n.undoable})}function di(n){return new Ks({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),o=G(n.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,o)},undoable:n.undoable})}function An(n){return new Ks({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const o=G(n.getAttributes,void 0,r)||{},i=e.tr.delete(t.from,t.to),a=i.doc.resolve(t.from).blockRange(),c=a&&Yi(a,n.type,o);if(!c)return null;if(i.wrap(a,c),n.keepMarks&&n.editor){const{selection:u,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,p=f||u.$to.parentOffset&&u.$from.marks();if(p){const y=p.filter(g=>h.includes(g.type.name));i.ensureMarks(y)}}if(n.keepAttributes){const u=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(u,o).run()}const d=i.doc.resolve(t.from-1).nodeBefore;d&&d.type===n.type&&Mt(i.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,d))&&i.join(t.from-1)},undoable:n.undoable})}function eb(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof $){const o=r.index();return r.parent.canReplaceWith(o,o+1,e)}let s=r.depth;for(;s>=0;){const o=r.index(s);if(r.node(s).contentMatchAt(o).matchType(e))return!0;s-=1}return!1}function tb(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var nb={};hl(nb,{createAtomBlockMarkdownSpec:()=>rb,createBlockMarkdownSpec:()=>sb,createInlineMarkdownSpec:()=>gf,parseAttributes:()=>kl,parseIndentedBlocks:()=>ui,renderNestedMarkdownContent:()=>wl,serializeAttributes:()=>Sl});function kl(n){if(!n?.trim())return{};const e={},t=[],r=n.replace(/["']([^"']*)["']/g,c=>(t.push(c),`__QUOTED_${t.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const c=s.map(d=>d.trim().slice(1));e.class=c.join(" ")}const o=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);o&&(e.id=o[1]);const i=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(i)).forEach(([,c,d])=>{var u;const f=parseInt(((u=d.match(/__QUOTED_(\d+)__/))==null?void 0:u[1])||"0",10),h=t[f];h&&(e[c]=h.slice(1,-1))});const a=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function Sl(n){if(!n||Object.keys(n).length===0)return"";const e=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),n.id&&e.push(`#${n.id}`),Object.entries(n).forEach(([t,r])=>{t==="class"||t==="id"||(r===!0?e.push(t):r!==!1&&r!=null&&e.push(`${t}="${String(r)}"`))}),e.join(" ")}function rb(n){const{nodeName:e,name:t,parseAttributes:r=kl,serializeAttributes:s=Sl,defaultAttributes:o={},requiredAttributes:i=[],allowedAttributes:l}=n,a=t||e,c=d=>{if(!l)return d;const u={};return l.forEach(f=>{f in d&&(u[f]=d[f])}),u};return{parseMarkdown:(d,u)=>{const f={...o,...d.attributes};return u.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(d){var u;const f=new RegExp(`^:::${a}(?:\\s|$)`,"m"),h=(u=d.match(f))==null?void 0:u.index;return h!==void 0?h:-1},tokenize(d,u,f){const h=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=d.match(h);if(!p)return;const y=p[1]||"",g=r(y);if(!i.find(b=>!(b in g)))return{type:e,raw:p[0],attributes:g}}},renderMarkdown:d=>{const u=c(d.attrs||{}),f=s(u),h=f?` {${f}}`:"";return`:::${a}${h} :::`}}}function sb(n){const{nodeName:e,name:t,getContent:r,parseAttributes:s=kl,serializeAttributes:o=Sl,defaultAttributes:i={},content:l="block",allowedAttributes:a}=n,c=t||e,d=u=>{if(!a)return u;const f={};return a.forEach(h=>{h in u&&(f[h]=u[h])}),f};return{parseMarkdown:(u,f)=>{let h;if(r){const y=r(u);h=typeof y=="string"?[{type:"text",text:y}]:y}else l==="block"?h=f.parseChildren(u.tokens||[]):h=f.parseInline(u.tokens||[]);const p={...i,...u.attributes};return f.createNode(e,p,h)},markdownTokenizer:{name:e,level:"block",start(u){var f;const h=new RegExp(`^:::${c}`,"m"),p=(f=u.match(h))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(u,f,h){var p;const y=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=u.match(y);if(!g)return;const[x,b=""]=g,S=s(b);let v=1;const k=x.length;let w="";const C=/^:::([\w-]*)(\s.*)?/gm,T=u.slice(k);for(C.lastIndex=0;;){const A=C.exec(T);if(A===null)break;const D=A.index,j=A[1];if(!((p=A[2])!=null&&p.endsWith(":::"))){if(j)v+=1;else if(v-=1,v===0){const _=T.slice(0,D);w=_.trim();const V=u.slice(0,k+D+A[0].length);let B=[];if(w)if(l==="block")for(B=h.blockTokens(_),B.forEach(H=>{H.text&&(!H.tokens||H.tokens.length===0)&&(H.tokens=h.inlineTokens(H.text))});B.length>0;){const H=B[B.length-1];if(H.type==="paragraph"&&(!H.text||H.text.trim()===""))B.pop();else break}else B=h.inlineTokens(w);return{type:e,raw:V,attributes:S,content:w,tokens:B}}}}}},renderMarkdown:(u,f)=>{const h=d(u.attrs||{}),p=o(h),y=p?` {${p}}`:"",g=f.renderChildren(u.content||[],`
|
|
92
92
|
|
|
93
93
|
`);return`:::${c}${y}
|
|
94
94
|
|
|
95
95
|
${g}
|
|
96
96
|
|
|
97
|
-
:::`}}}function
|
|
97
|
+
:::`}}}function ob(n){if(!n.trim())return{};const e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=t.exec(n);for(;r!==null;){const[,s,o,i]=r;e[s]=o||i,r=t.exec(n)}return e}function ib(n){return Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(" ")}function gf(n){const{nodeName:e,name:t,getContent:r,parseAttributes:s=ob,serializeAttributes:o=ib,defaultAttributes:i={},selfClosing:l=!1,allowedAttributes:a}=n,c=t||e,d=f=>{if(!a)return f;const h={};return a.forEach(p=>{const y=typeof p=="string"?p:p.name,g=typeof p=="string"?void 0:p.skipIfDefault;if(y in f){const x=f[y];if(g!==void 0&&x===g)return;h[y]=x}}),h},u=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(f,h)=>{const p={...i,...f.attributes};if(l)return h.createNode(e,p);const y=r?r(f):f.content||"";return y?h.createNode(e,p,[h.createTextNode(y)]):h.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(f){const h=l?new RegExp(`\\[${u}\\s*[^\\]]*\\]`):new RegExp(`\\[${u}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${u}\\]`),p=f.match(h),y=p?.index;return y!==void 0?y:-1},tokenize(f,h,p){const y=l?new RegExp(`^\\[${u}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${u}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${u}\\]`),g=f.match(y);if(!g)return;let x="",b="";if(l){const[,v]=g;b=v}else{const[,v,k]=g;b=v,x=k||""}const S=s(b.trim());return{type:e,raw:g[0],content:x.trim(),attributes:S}}},renderMarkdown:f=>{let h="";r?h=r(f):f.content&&f.content.length>0&&(h=f.content.filter(x=>x.type==="text").map(x=>x.text).join(""));const p=d(f.attrs||{}),y=o(p),g=y?` ${y}`:"";return l?`[${c}${g}]`:`[${c}${g}]${h}[/${c}]`}}}function ui(n,e,t){var r,s,o,i;const l=n.split(`
|
|
98
98
|
`),a=[];let c="",d=0;const u=e.baseIndentSize||2;for(;d<l.length;){const f=l[d],h=f.match(e.itemPattern);if(!h){if(a.length>0)break;if(f.trim()===""){d+=1,c=`${c}${f}
|
|
99
99
|
`;continue}else return}const p=e.extractItemData(h),{indentLevel:y,mainContent:g}=p;c=`${c}${f}
|
|
100
100
|
`;const x=[g];for(d+=1;d<l.length;){const k=l[d];if(k.trim()===""){const C=l.slice(d+1).findIndex(D=>D.trim()!=="");if(C===-1)break;if((((s=(r=l[d+1+C].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>y){x.push(k),c=`${c}${k}
|
|
@@ -103,11 +103,11 @@ ${g}
|
|
|
103
103
|
`);k.trim()&&(e.customNestedParser?b=e.customNestedParser(k):b=t.blockTokens(k))}const v=e.createToken(p,b);a.push(v)}if(a.length!==0)return{items:a,raw:c}}function wl(n,e,t,r){if(!n||!Array.isArray(n.content))return"";const s=typeof t=="function"?t(r):t,[o,...i]=n.content,l=e.renderChildren([o]),a=[`${s}${l}`];return i&&i.length>0&&i.forEach(c=>{const d=e.renderChildren([c]);if(d){const u=d.split(`
|
|
104
104
|
`).map(f=>f?e.indent(f):"").join(`
|
|
105
105
|
`);a.push(u)}}),a.join(`
|
|
106
|
-
`)}function Zx(n,e,t={}){const{state:r}=e,{doc:s,tr:o}=r,i=n;s.descendants((l,a)=>{const c=o.mapping.map(a),d=o.mapping.map(a)+l.nodeSize;let u=null;if(l.marks.forEach(h=>{if(h!==i)return!1;u=h}),!u)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==u.attrs[h]&&(f=!0)}),f){const h=n.type.create({...n.attrs,...t});o.removeMark(c,d,n.type),o.addMark(c,d,h)}}),o.docChanged&&e.view.dispatch(o)}var Ie=class yf extends bl{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new yf(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},eb=class{constructor(n,e,t){this.isDragging=!1,this.component=n,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...t},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(n){var e,t,r,s,o,i,l;const{view:a}=this.editor,c=n.target,d=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(t=this.contentDOM)!=null&&t.contains(c)||!d)return;let u=0,f=0;if(this.dom!==d){const b=this.dom.getBoundingClientRect(),S=d.getBoundingClientRect(),v=(s=n.offsetX)!=null?s:(r=n.nativeEvent)==null?void 0:r.offsetX,k=(i=n.offsetY)!=null?i:(o=n.nativeEvent)==null?void 0:o.offsetY;u=S.x-b.x+v,f=S.y-b.y+k}const h=this.dom.cloneNode(!0);try{const b=this.dom.getBoundingClientRect();h.style.width=`${Math.round(b.width)}px`,h.style.height=`${Math.round(b.height)}px`,h.style.boxSizing="border-box",h.style.pointerEvents="none"}catch{}let p=null;try{p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(h),document.body.appendChild(p),(l=n.dataTransfer)==null||l.setDragImage(h,u,f)}finally{p&&setTimeout(()=>{try{p?.remove()}catch{}},0)}const y=this.getPos();if(typeof y!="number")return;const g=$.create(a.state.doc,y),x=a.state.tr.setSelection(g);a.dispatch(x)}stopEvent(n){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:n});const t=n.target;if(!(this.dom.contains(t)&&!((e=this.contentDOM)!=null&&e.contains(t))))return!1;const s=n.type.startsWith("drag"),o=n.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(t.tagName)||t.isContentEditable)&&!o&&!s)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,d=$.isSelectable(this.node),u=n.type==="copy",f=n.type==="paste",h=n.type==="cut",p=n.type==="mousedown";if(!c&&d&&s&&n.target===this.dom&&n.preventDefault(),c&&s&&!a&&n.target===this.dom)return n.preventDefault(),!1;if(c&&l&&!a&&p){const y=t.closest("[data-drag-handle]");y&&(this.dom===y||this.dom.contains(y))&&(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!(a||o||u||f||h||p&&d)}ignoreMutation(n){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:n}):this.node.isLeaf||this.node.isAtom?!0:n.type==="selection"||this.dom.contains(n.target)&&n.type==="childList"&&(cr()||li())&&this.editor.isFocused&&[...Array.from(n.addedNodes),...Array.from(n.removedNodes)].every(t=>t.isContentEditable)?!1:this.contentDOM===n.target&&n.type==="attributes"?!0:!this.contentDOM.contains(n.target)}updateAttributes(n){this.editor.commands.command(({tr:e})=>{const t=this.getPos();return typeof t!="number"?!1:(e.setNodeMarkup(t,void 0,{...this.node.attrs,...n}),!0)})}deleteNode(){const n=this.getPos();if(typeof n!="number")return;const e=n+this.node.nodeSize;this.editor.commands.deleteRange({from:n,to:e})}};function Xt(n){return new Px({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const o=G(n.getAttributes,void 0,r,s);if(o===!1||o===null)return null;const{tr:i}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const d=a.search(/\S/),u=t.from+a.indexOf(l),f=u+l.length;if(xl(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===n.type&&g!==p.mark.type)).filter(p=>p.to>u).length)return null;f<t.to&&i.delete(f,t.to),u>t.from&&i.delete(t.from+d,u),c=t.from+d+l.length,i.addMark(t.from+d,c,n.type.create(o||{})),i.removeStoredMark(n.type)}}})}var tb=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},nb=({contentComponent:n})=>{const e=Tc.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return m.jsx(m.Fragment,{children:Object.values(e)})};function rb(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:wh.createPortal(r.reactElement,r.element,t)},n.forEach(s=>s())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(s=>s())}}}var sb=class extends ee.Component{constructor(n){var e;super(n),this.editorContentRef=ee.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=n.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var n;const e=this.props.editor;if(e&&!e.isDestroyed&&((n=e.view.dom)!=null&&n.parentNode)){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=rb(),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 n;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(!((n=e.view.dom)!=null&&n.parentNode))return;const t=document.createElement("div");t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){const{editor:n,innerRef:e,...t}=this.props;return m.jsxs(m.Fragment,{children:[m.jsx("div",{ref:tb(e,this.editorContentRef),...t}),n?.contentComponent&&m.jsx(nb,{contentComponent:n.contentComponent})]})}},ob=O.forwardRef((n,e)=>{const t=ee.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return ee.createElement(sb,{key:t,innerRef:e,...n})}),ib=ee.memo(ob),lb=typeof window<"u"?O.useLayoutEffect:O.useEffect,ab=class{constructor(n){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=n,this.lastSnapshot={editor:n,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(n){return this.subscribers.add(n),()=>{this.subscribers.delete(n)}}watch(n){if(this.editor=n,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};function cb(n){var e;const[t]=O.useState(()=>new ab(n.editor)),r=Sh.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!=null?e:nm);return lb(()=>t.watch(n.editor),[n.editor,t]),O.useDebugValue(r),r}var db=!1,fi=typeof window>"u",ub=fi||!!(typeof window<"u"&&window.next),fb=class xf{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(t=>t())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?fi||ub?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onBeforeCreate)==null?void 0:o.call(s,...r)},onBlur:(...r)=>{var s,o;return(o=(s=this.options.current).onBlur)==null?void 0:o.call(s,...r)},onCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onCreate)==null?void 0:o.call(s,...r)},onDestroy:(...r)=>{var s,o;return(o=(s=this.options.current).onDestroy)==null?void 0:o.call(s,...r)},onFocus:(...r)=>{var s,o;return(o=(s=this.options.current).onFocus)==null?void 0:o.call(s,...r)},onSelectionUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onSelectionUpdate)==null?void 0:o.call(s,...r)},onTransaction:(...r)=>{var s,o;return(o=(s=this.options.current).onTransaction)==null?void 0:o.call(s,...r)},onUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onUpdate)==null?void 0:o.call(s,...r)},onContentError:(...r)=>{var s,o;return(o=(s=this.options.current).onContentError)==null?void 0:o.call(s,...r)},onDrop:(...r)=>{var s,o;return(o=(s=this.options.current).onDrop)==null?void 0:o.call(s,...r)},onPaste:(...r)=>{var s,o;return(o=(s=this.options.current).onPaste)==null?void 0:o.call(s,...r)},onDelete:(...r)=>{var s,o;return(o=(s=this.options.current).onDelete)==null?void 0:o.call(s,...r)}};return new Wx(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((s,o)=>{var i;return s===((i=t.extensions)==null?void 0:i[o])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?xf.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,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function hb(n={},e=[]){const t=O.useRef(n);t.current=n;const[r]=O.useState(()=>new fb(t)),s=Tc.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return O.useDebugValue(s),O.useEffect(r.onRender(e)),cb({editor:s,selector:({transactionNumber:o})=>n.shouldRerenderOnTransaction===!1||n.shouldRerenderOnTransaction===void 0?null:n.immediatelyRender&&o===0?0:o+1}),s}var pb=O.createContext({editor:null});pb.Consumer;var bf=O.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),mb=()=>O.useContext(bf),oc=ee.forwardRef((n,e)=>{const{onDragStart:t}=mb(),r=n.as||"div";return m.jsx(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function ic(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function lc(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.forward_ref)"||n.$$typeof.description==="react.forward_ref"))}function gb(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.memo)"||n.$$typeof.description==="react.memo"))}function yb(n){if(ic(n)||lc(n))return!0;if(gb(n)){const e=n.type;if(e)return ic(e)||lc(e)}return!1}function xb(){try{if(O.version)return parseInt(O.version.split(".")[0],10)>=19}catch{}return!1}var kf=class{constructor(n,{editor:e,props:t={},as:r="div",className:s=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=n,this.editor=e,this.props=t,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?kh.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var n;if(this.destroyed)return;const e=this.component,t=this.props,r=this.editor,s=xb(),o=yb(e),i={...t};i.ref&&!(s||o)&&delete i.ref,!i.ref&&(s||o)&&(i.ref=l=>{this.ref=l}),this.reactElement=m.jsx(e,{...i}),(n=r?.contentComponent)==null||n.setRenderer(this.id,this)}updateProps(n={}){this.destroyed||(this.props={...this.props,...n},this.render())}destroy(){var n;this.destroyed=!0;const e=this.editor;(n=e?.contentComponent)==null||n.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(n){Object.keys(n).forEach(e=>{this.element.setAttribute(e,n[e])})}};ee.createContext({markViewContentRef:()=>{}});var bb=class extends eb{constructor(n,e,t){if(super(n,e,t),this.selectionRafId=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)}}mount(){const n={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:O.createRef()};if(!this.component.displayName){const a=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=a(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement&&(a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper"),a.appendChild(this.contentDOMElement))}},s=this.component,o=O.memo(a=>m.jsx(bf.Provider,{value:r,children:O.createElement(s,a)}));o.displayName="ReactNodeView";let i=this.node.isInline?"span":"div";this.options.as&&(i=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new kf(o,{editor:this.editor,props:n,as:i,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var n;if(this.renderer.element.firstElementChild&&!((n=this.renderer.element.firstElementChild)!=null&&n.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:n,to:e}=this.editor.state.selection,t=this.getPos();if(typeof t=="number")if(n<=t&&e>=t+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(n,e,t){const r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(n.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const s=this.node,o=this.decorations,i=this.innerDecorations;return this.node=n,this.decorations=e,this.innerDecorations=t,this.options.update({oldNode:s,oldDecorations:o,newNode:n,newDecorations:e,oldInnerDecorations:i,innerDecorations:t,updateProps:()=>r({node:n,decorations:e,innerDecorations:t})})}return n===this.node&&this.decorations===e&&this.innerDecorations===t||(this.node=n,this.decorations=e,this.innerDecorations=t,r({node:n,decorations:e,innerDecorations:t})),!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 n={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,t=Tn(this.node,e);n=this.options.attrs({node:this.node,HTMLAttributes:t})}else n=this.options.attrs;this.renderer.updateAttributes(n)}}};function kb(n,e){return t=>t.editor.contentComponent?new bb(n,t,e):{}}var es=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]},Sb=/^\s*>\s$/,wb=Ie.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return es("blockquote",{...ne(this.options.HTMLAttributes,n),children:es("slot",{})})},parseMarkdown:(n,e)=>e.createNode("blockquote",void 0,e.parseChildren(n.tokens||[])),renderMarkdown:(n,e)=>{if(!n.content)return"";const t=">",r=[];return n.content.forEach(s=>{const l=e.renderChildren([s]).split(`
|
|
106
|
+
`)}function lb(n,e,t={}){const{state:r}=e,{doc:s,tr:o}=r,i=n;s.descendants((l,a)=>{const c=o.mapping.map(a),d=o.mapping.map(a)+l.nodeSize;let u=null;if(l.marks.forEach(h=>{if(h!==i)return!1;u=h}),!u)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==u.attrs[h]&&(f=!0)}),f){const h=n.type.create({...n.attrs,...t});o.removeMark(c,d,n.type),o.addMark(c,d,h)}}),o.docChanged&&e.view.dispatch(o)}var Ie=class yf extends bl{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new yf(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},ab=class{constructor(n,e,t){this.isDragging=!1,this.component=n,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...t},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(n){var e,t,r,s,o,i,l;const{view:a}=this.editor,c=n.target,d=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(t=this.contentDOM)!=null&&t.contains(c)||!d)return;let u=0,f=0;if(this.dom!==d){const b=this.dom.getBoundingClientRect(),S=d.getBoundingClientRect(),v=(s=n.offsetX)!=null?s:(r=n.nativeEvent)==null?void 0:r.offsetX,k=(i=n.offsetY)!=null?i:(o=n.nativeEvent)==null?void 0:o.offsetY;u=S.x-b.x+v,f=S.y-b.y+k}const h=this.dom.cloneNode(!0);try{const b=this.dom.getBoundingClientRect();h.style.width=`${Math.round(b.width)}px`,h.style.height=`${Math.round(b.height)}px`,h.style.boxSizing="border-box",h.style.pointerEvents="none"}catch{}let p=null;try{p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(h),document.body.appendChild(p),(l=n.dataTransfer)==null||l.setDragImage(h,u,f)}finally{p&&setTimeout(()=>{try{p?.remove()}catch{}},0)}const y=this.getPos();if(typeof y!="number")return;const g=$.create(a.state.doc,y),x=a.state.tr.setSelection(g);a.dispatch(x)}stopEvent(n){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:n});const t=n.target;if(!(this.dom.contains(t)&&!((e=this.contentDOM)!=null&&e.contains(t))))return!1;const s=n.type.startsWith("drag"),o=n.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(t.tagName)||t.isContentEditable)&&!o&&!s)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,d=$.isSelectable(this.node),u=n.type==="copy",f=n.type==="paste",h=n.type==="cut",p=n.type==="mousedown";if(!c&&d&&s&&n.target===this.dom&&n.preventDefault(),c&&s&&!a&&n.target===this.dom)return n.preventDefault(),!1;if(c&&l&&!a&&p){const y=t.closest("[data-drag-handle]");y&&(this.dom===y||this.dom.contains(y))&&(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!(a||o||u||f||h||p&&d)}ignoreMutation(n){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:n}):this.node.isLeaf||this.node.isAtom?!0:n.type==="selection"||this.dom.contains(n.target)&&n.type==="childList"&&(cr()||li())&&this.editor.isFocused&&[...Array.from(n.addedNodes),...Array.from(n.removedNodes)].every(t=>t.isContentEditable)?!1:this.contentDOM===n.target&&n.type==="attributes"?!0:!this.contentDOM.contains(n.target)}updateAttributes(n){this.editor.commands.command(({tr:e})=>{const t=this.getPos();return typeof t!="number"?!1:(e.setNodeMarkup(t,void 0,{...this.node.attrs,...n}),!0)})}deleteNode(){const n=this.getPos();if(typeof n!="number")return;const e=n+this.node.nodeSize;this.editor.commands.deleteRange({from:n,to:e})}};function Xt(n){return new Hx({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const o=G(n.getAttributes,void 0,r,s);if(o===!1||o===null)return null;const{tr:i}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const d=a.search(/\S/),u=t.from+a.indexOf(l),f=u+l.length;if(xl(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===n.type&&g!==p.mark.type)).filter(p=>p.to>u).length)return null;f<t.to&&i.delete(f,t.to),u>t.from&&i.delete(t.from+d,u),c=t.from+d+l.length,i.addMark(t.from+d,c,n.type.create(o||{})),i.removeStoredMark(n.type)}}})}var cb=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},db=({contentComponent:n})=>{const e=Tc.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return m.jsx(m.Fragment,{children:Object.values(e)})};function ub(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:wh.createPortal(r.reactElement,r.element,t)},n.forEach(s=>s())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(s=>s())}}}var fb=class extends ee.Component{constructor(n){var e;super(n),this.editorContentRef=ee.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=n.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var n;const e=this.props.editor;if(e&&!e.isDestroyed&&((n=e.view.dom)!=null&&n.parentNode)){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=ub(),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 n;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(!((n=e.view.dom)!=null&&n.parentNode))return;const t=document.createElement("div");t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){const{editor:n,innerRef:e,...t}=this.props;return m.jsxs(m.Fragment,{children:[m.jsx("div",{ref:cb(e,this.editorContentRef),...t}),n?.contentComponent&&m.jsx(db,{contentComponent:n.contentComponent})]})}},hb=O.forwardRef((n,e)=>{const t=ee.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return ee.createElement(fb,{key:t,innerRef:e,...n})}),pb=ee.memo(hb),mb=typeof window<"u"?O.useLayoutEffect:O.useEffect,gb=class{constructor(n){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=n,this.lastSnapshot={editor:n,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(n){return this.subscribers.add(n),()=>{this.subscribers.delete(n)}}watch(n){if(this.editor=n,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};function yb(n){var e;const[t]=O.useState(()=>new gb(n.editor)),r=Sh.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!=null?e:lm);return mb(()=>t.watch(n.editor),[n.editor,t]),O.useDebugValue(r),r}var xb=!1,fi=typeof window>"u",bb=fi||!!(typeof window<"u"&&window.next),kb=class xf{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(t=>t())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?fi||bb?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onBeforeCreate)==null?void 0:o.call(s,...r)},onBlur:(...r)=>{var s,o;return(o=(s=this.options.current).onBlur)==null?void 0:o.call(s,...r)},onCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onCreate)==null?void 0:o.call(s,...r)},onDestroy:(...r)=>{var s,o;return(o=(s=this.options.current).onDestroy)==null?void 0:o.call(s,...r)},onFocus:(...r)=>{var s,o;return(o=(s=this.options.current).onFocus)==null?void 0:o.call(s,...r)},onSelectionUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onSelectionUpdate)==null?void 0:o.call(s,...r)},onTransaction:(...r)=>{var s,o;return(o=(s=this.options.current).onTransaction)==null?void 0:o.call(s,...r)},onUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onUpdate)==null?void 0:o.call(s,...r)},onContentError:(...r)=>{var s,o;return(o=(s=this.options.current).onContentError)==null?void 0:o.call(s,...r)},onDrop:(...r)=>{var s,o;return(o=(s=this.options.current).onDrop)==null?void 0:o.call(s,...r)},onPaste:(...r)=>{var s,o;return(o=(s=this.options.current).onPaste)==null?void 0:o.call(s,...r)},onDelete:(...r)=>{var s,o;return(o=(s=this.options.current).onDelete)==null?void 0:o.call(s,...r)}};return new Qx(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((s,o)=>{var i;return s===((i=t.extensions)==null?void 0:i[o])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?xf.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,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function Sb(n={},e=[]){const t=O.useRef(n);t.current=n;const[r]=O.useState(()=>new kb(t)),s=Tc.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return O.useDebugValue(s),O.useEffect(r.onRender(e)),yb({editor:s,selector:({transactionNumber:o})=>n.shouldRerenderOnTransaction===!1||n.shouldRerenderOnTransaction===void 0?null:n.immediatelyRender&&o===0?0:o+1}),s}var wb=O.createContext({editor:null});wb.Consumer;var bf=O.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),vb=()=>O.useContext(bf),oc=ee.forwardRef((n,e)=>{const{onDragStart:t}=vb(),r=n.as||"div";return m.jsx(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function ic(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function lc(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.forward_ref)"||n.$$typeof.description==="react.forward_ref"))}function Cb(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.memo)"||n.$$typeof.description==="react.memo"))}function Nb(n){if(ic(n)||lc(n))return!0;if(Cb(n)){const e=n.type;if(e)return ic(e)||lc(e)}return!1}function Eb(){try{if(O.version)return parseInt(O.version.split(".")[0],10)>=19}catch{}return!1}var kf=class{constructor(n,{editor:e,props:t={},as:r="div",className:s=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=n,this.editor=e,this.props=t,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?kh.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var n;if(this.destroyed)return;const e=this.component,t=this.props,r=this.editor,s=Eb(),o=Nb(e),i={...t};i.ref&&!(s||o)&&delete i.ref,!i.ref&&(s||o)&&(i.ref=l=>{this.ref=l}),this.reactElement=m.jsx(e,{...i}),(n=r?.contentComponent)==null||n.setRenderer(this.id,this)}updateProps(n={}){this.destroyed||(this.props={...this.props,...n},this.render())}destroy(){var n;this.destroyed=!0;const e=this.editor;(n=e?.contentComponent)==null||n.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(n){Object.keys(n).forEach(e=>{this.element.setAttribute(e,n[e])})}};ee.createContext({markViewContentRef:()=>{}});var Tb=class extends ab{constructor(n,e,t){if(super(n,e,t),this.selectionRafId=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)}}mount(){const n={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:O.createRef()};if(!this.component.displayName){const a=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=a(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement&&(a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper"),a.appendChild(this.contentDOMElement))}},s=this.component,o=O.memo(a=>m.jsx(bf.Provider,{value:r,children:O.createElement(s,a)}));o.displayName="ReactNodeView";let i=this.node.isInline?"span":"div";this.options.as&&(i=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new kf(o,{editor:this.editor,props:n,as:i,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var n;if(this.renderer.element.firstElementChild&&!((n=this.renderer.element.firstElementChild)!=null&&n.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:n,to:e}=this.editor.state.selection,t=this.getPos();if(typeof t=="number")if(n<=t&&e>=t+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(n,e,t){const r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(n.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const s=this.node,o=this.decorations,i=this.innerDecorations;return this.node=n,this.decorations=e,this.innerDecorations=t,this.options.update({oldNode:s,oldDecorations:o,newNode:n,newDecorations:e,oldInnerDecorations:i,innerDecorations:t,updateProps:()=>r({node:n,decorations:e,innerDecorations:t})})}return n===this.node&&this.decorations===e&&this.innerDecorations===t||(this.node=n,this.decorations=e,this.innerDecorations=t,r({node:n,decorations:e,innerDecorations:t})),!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 n={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,t=Tn(this.node,e);n=this.options.attrs({node:this.node,HTMLAttributes:t})}else n=this.options.attrs;this.renderer.updateAttributes(n)}}};function Mb(n,e){return t=>t.editor.contentComponent?new Tb(n,t,e):{}}var es=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]},Ab=/^\s*>\s$/,Ob=Ie.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return es("blockquote",{...ne(this.options.HTMLAttributes,n),children:es("slot",{})})},parseMarkdown:(n,e)=>e.createNode("blockquote",void 0,e.parseChildren(n.tokens||[])),renderMarkdown:(n,e)=>{if(!n.content)return"";const t=">",r=[];return n.content.forEach(s=>{const l=e.renderChildren([s]).split(`
|
|
107
107
|
`).map(a=>a.trim()===""?t:`${t} ${a}`);r.push(l.join(`
|
|
108
108
|
`))}),r.join(`
|
|
109
109
|
${t}
|
|
110
|
-
`)},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[An({find:
|
|
110
|
+
`)},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[An({find:Ab,type:this.type})]}}),Ib=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Rb=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,jb=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Db=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Pb=Zt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return es("strong",{...ne(this.options.HTMLAttributes,n),children:es("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Mn({find:Ib,type:this.type}),Mn({find:jb,type:this.type})]},addPasteRules(){return[Xt({find:Rb,type:this.type}),Xt({find:Db,type:this.type})]}}),Lb=/(^|[^`])`([^`]+)`(?!`)$/,$b=/(^|[^`])`([^`]+)`(?!`)/g,zb=Zt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",ne(this.options.HTMLAttributes,n),0]},markdownTokenName:"codespan",parseMarkdown:(n,e)=>e.applyMark("code",[{type:"text",text:n.text||""}]),renderMarkdown:(n,e)=>n.content?`\`${e.renderChildren(n.content)}\``:"",addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Mn({find:Lb,type:this.type})]},addPasteRules(){return[Xt({find:$b,type:this.type})]}}),Io=4,_b=/^```([a-z]+)?[\s\n]$/,Bb=/^~~~([a-z]+)?[\s\n]$/,Fb=Ie.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Io,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options;if(!t)return null;const o=[...((e=n.firstElementChild)==null?void 0:e.classList)||[]].filter(i=>i.startsWith(t)).map(i=>i.replace(t,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",ne(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(n,e)=>{var t;return((t=n.raw)==null?void 0:t.startsWith("```"))===!1&&n.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:n.lang||null},n.text?[e.createTextNode(n.text)]:[])},renderMarkdown:(n,e)=>{var t;let r="";const s=((t=n.attrs)==null?void 0:t.language)||"";return n.content?r=[`\`\`\`${s}`,e.renderChildren(n.content),"```"].join(`
|
|
111
111
|
`):r=`\`\`\`${s}
|
|
112
112
|
|
|
113
113
|
\`\`\``,r},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;const t=(e=this.options.tabSize)!=null?e:Io,{state:r}=n,{selection:s}=r,{$from:o,empty:i}=s;if(o.parent.type!==this.type)return!1;const l=" ".repeat(t);return i?n.commands.insertContent(l):n.commands.command(({tr:a})=>{const{from:c,to:d}=s,h=r.doc.textBetween(c,d,`
|
|
@@ -123,34 +123,34 @@ ${t}
|
|
|
123
123
|
`).map(h=>{var p;const y=((p=h.match(/^ */))==null?void 0:p[0])||"",g=Math.min(y.length,t);return h.slice(g)}).join(`
|
|
124
124
|
`);return l.replaceWith(a,c,r.schema.text(f)),!0})},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:s}=t;if(!s||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,i=r.parent.textContent.endsWith(`
|
|
125
125
|
|
|
126
|
-
`);return!o||!i?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:s,empty:o}=t;if(!o||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(q.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[di({find:
|
|
127
|
-
`));return i.replaceSelectionWith(this.type.create({language:o},a)),i.selection.$from.parent.type!==this.type&&i.setSelection(F.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),n.dispatch(i),!0}}})]}}),
|
|
126
|
+
`);return!o||!i?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:s,empty:o}=t;if(!o||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(q.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[di({find:_b,type:this.type,getAttributes:n=>({language:n[1]})}),di({find:Bb,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new re({key:new ae("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,o=s?.mode;if(!t||!o)return!1;const{tr:i,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,`
|
|
127
|
+
`));return i.replaceSelectionWith(this.type.create({language:o},a)),i.selection.$from.parent.type!==this.type&&i.setSelection(F.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),n.dispatch(i),!0}}})]}}),Vb=Ie.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
|
|
128
128
|
|
|
129
|
-
`):""}),
|
|
129
|
+
`):""}),Hb=Ie.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",ne(this.options.HTMLAttributes,n)]},renderText(){return`
|
|
130
130
|
`},renderMarkdown:()=>`
|
|
131
|
-
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:s,storedMarks:o}=t;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:l}=r.extensionManager,a=o||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&i){const u=a.filter(f=>l.includes(f.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Lb=Ie.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,ne(this.options.HTMLAttributes,e),0]},parseMarkdown:(n,e)=>e.createNode("heading",{level:n.depth||1},e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>{var t;const r=(t=n.attrs)!=null&&t.level?parseInt(n.attrs.level,10):1,s="#".repeat(r);return n.content?`${s} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>di({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),$b=Ie.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",ne(this.options.HTMLAttributes,n)]},markdownTokenName:"hr",parseMarkdown:(n,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!Ux(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$to:r}=t,s=n();return Qu(t)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:o,tr:i,dispatch:l})=>{if(l){const{$to:a}=i.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?i.setSelection(F.create(i.doc,a.pos+1)):a.nodeAfter.isBlock?i.setSelection($.create(i.doc,a.pos)):i.setSelection(F.create(i.doc,a.pos));else{const d=o.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,u=d?.create();u&&(i.insert(c,u),i.setSelection(F.create(i.doc,c+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[qx({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),zb=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,_b=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Bb=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Fb=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Vb=Zt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",ne(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Mn({find:zb,type:this.type}),Mn({find:Bb,type:this.type})]},addPasteRules(){return[Xt({find:_b,type:this.type}),Xt({find:Fb,type:this.type})]}});const Hb="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Wb="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",hi="numeric",pi="ascii",mi="alpha",Gn="asciinumeric",Wn="alphanumeric",gi="domain",Sf="emoji",qb="scheme",Ub="slashscheme",Ro="whitespace";function Kb(n,e){return n in e||(e[n]=[]),e[n]}function Pt(n,e,t){e[hi]&&(e[Gn]=!0,e[Wn]=!0),e[pi]&&(e[Gn]=!0,e[mi]=!0),e[Gn]&&(e[Wn]=!0),e[mi]&&(e[Wn]=!0),e[Wn]&&(e[gi]=!0),e[Sf]&&(e[gi]=!0);for(const r in e){const s=Kb(r,t);s.indexOf(n)<0&&s.push(n)}}function Jb(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Ae(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}Ae.groups={};Ae.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],o=e.jr[r][1];if(o&&s.test(n))return o}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let s=0;s<n.length;s++)this.tt(n[s],e,t,r)},tr(n,e,t,r){r=r||Ae.groups;let s;return e&&e.j?s=e:(s=new Ae(e),t&&r&&Pt(e,t,r)),this.jr.push([n,s]),s},ts(n,e,t,r){let s=this;const o=n.length;if(!o)return s;for(let i=0;i<o-1;i++)s=s.tt(n[i]);return s.tt(n[o-1],e,t,r)},tt(n,e,t,r){r=r||Ae.groups;const s=this;if(e&&e.j)return s.j[n]=e,e;const o=e;let i,l=s.go(n);if(l?(i=new Ae,Object.assign(i.j,l.j),i.jr.push.apply(i.jr,l.jr),i.jd=l.jd,i.t=l.t):i=new Ae,o){if(r)if(i.t&&typeof i.t=="string"){const a=Object.assign(Jb(i.t,r),t);Pt(o,a,r)}else t&&Pt(o,t,r);i.t=o}return s.j[n]=i,i}};const W=(n,e,t,r,s)=>n.ta(e,t,r,s),oe=(n,e,t,r,s)=>n.tr(e,t,r,s),ac=(n,e,t,r,s)=>n.ts(e,t,r,s),M=(n,e,t,r,s)=>n.tt(e,t,r,s),nt="WORD",yi="UWORD",wf="ASCIINUMERICAL",vf="ALPHANUMERICAL",ur="LOCALHOST",xi="TLD",bi="UTLD",$r="SCHEME",yn="SLASH_SCHEME",vl="NUM",ki="WS",Cl="NL",Xn="OPENBRACE",Yn="CLOSEBRACE",ts="OPENBRACKET",ns="CLOSEBRACKET",rs="OPENPAREN",ss="CLOSEPAREN",is="OPENANGLEBRACKET",ls="CLOSEANGLEBRACKET",as="FULLWIDTHLEFTPAREN",cs="FULLWIDTHRIGHTPAREN",ds="LEFTCORNERBRACKET",us="RIGHTCORNERBRACKET",fs="LEFTWHITECORNERBRACKET",hs="RIGHTWHITECORNERBRACKET",ps="FULLWIDTHLESSTHAN",ms="FULLWIDTHGREATERTHAN",gs="AMPERSAND",ys="APOSTROPHE",xs="ASTERISK",ht="AT",bs="BACKSLASH",ks="BACKTICK",Ss="CARET",gt="COLON",Nl="COMMA",ws="DOLLAR",Ke="DOT",vs="EQUALS",El="EXCLAMATION",Pe="HYPHEN",Qn="PERCENT",Cs="PIPE",Ns="PLUS",Es="POUND",Zn="QUERY",Tl="QUOTE",Cf="FULLWIDTHMIDDLEDOT",Ml="SEMI",Je="SLASH",er="TILDE",Ts="UNDERSCORE",Nf="EMOJI",Ms="SYM";var Ef=Object.freeze({__proto__:null,ALPHANUMERICAL:vf,AMPERSAND:gs,APOSTROPHE:ys,ASCIINUMERICAL:wf,ASTERISK:xs,AT:ht,BACKSLASH:bs,BACKTICK:ks,CARET:Ss,CLOSEANGLEBRACKET:ls,CLOSEBRACE:Yn,CLOSEBRACKET:ns,CLOSEPAREN:ss,COLON:gt,COMMA:Nl,DOLLAR:ws,DOT:Ke,EMOJI:Nf,EQUALS:vs,EXCLAMATION:El,FULLWIDTHGREATERTHAN:ms,FULLWIDTHLEFTPAREN:as,FULLWIDTHLESSTHAN:ps,FULLWIDTHMIDDLEDOT:Cf,FULLWIDTHRIGHTPAREN:cs,HYPHEN:Pe,LEFTCORNERBRACKET:ds,LEFTWHITECORNERBRACKET:fs,LOCALHOST:ur,NL:Cl,NUM:vl,OPENANGLEBRACKET:is,OPENBRACE:Xn,OPENBRACKET:ts,OPENPAREN:rs,PERCENT:Qn,PIPE:Cs,PLUS:Ns,POUND:Es,QUERY:Zn,QUOTE:Tl,RIGHTCORNERBRACKET:us,RIGHTWHITECORNERBRACKET:hs,SCHEME:$r,SEMI:Ml,SLASH:Je,SLASH_SCHEME:yn,SYM:Ms,TILDE:er,TLD:xi,UNDERSCORE:Ts,UTLD:bi,UWORD:yi,WORD:nt,WS:ki});const et=/[a-z]/,Bn=new RegExp("\\p{L}","u"),jo=new RegExp("\\p{Emoji}","u"),tt=/\d/,Do=/\s/,cc="\r",Po=`
|
|
132
|
-
`,
|
|
131
|
+
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:s,storedMarks:o}=t;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:l}=r.extensionManager,a=o||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&i){const u=a.filter(f=>l.includes(f.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Wb=Ie.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,ne(this.options.HTMLAttributes,e),0]},parseMarkdown:(n,e)=>e.createNode("heading",{level:n.depth||1},e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>{var t;const r=(t=n.attrs)!=null&&t.level?parseInt(n.attrs.level,10):1,s="#".repeat(r);return n.content?`${s} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>di({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),qb=Ie.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",ne(this.options.HTMLAttributes,n)]},markdownTokenName:"hr",parseMarkdown:(n,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!eb(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$to:r}=t,s=n();return Qu(t)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:o,tr:i,dispatch:l})=>{if(l){const{$to:a}=i.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?i.setSelection(F.create(i.doc,a.pos+1)):a.nodeAfter.isBlock?i.setSelection($.create(i.doc,a.pos)):i.setSelection(F.create(i.doc,a.pos));else{const d=o.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,u=d?.create();u&&(i.insert(c,u),i.setSelection(F.create(i.doc,c+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Zx({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Ub=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Kb=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Jb=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Gb=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Xb=Zt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",ne(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Mn({find:Ub,type:this.type}),Mn({find:Jb,type:this.type})]},addPasteRules(){return[Xt({find:Kb,type:this.type}),Xt({find:Gb,type:this.type})]}});const Yb="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Qb="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",hi="numeric",pi="ascii",mi="alpha",Gn="asciinumeric",Wn="alphanumeric",gi="domain",Sf="emoji",Zb="scheme",ek="slashscheme",Ro="whitespace";function tk(n,e){return n in e||(e[n]=[]),e[n]}function Pt(n,e,t){e[hi]&&(e[Gn]=!0,e[Wn]=!0),e[pi]&&(e[Gn]=!0,e[mi]=!0),e[Gn]&&(e[Wn]=!0),e[mi]&&(e[Wn]=!0),e[Wn]&&(e[gi]=!0),e[Sf]&&(e[gi]=!0);for(const r in e){const s=tk(r,t);s.indexOf(n)<0&&s.push(n)}}function nk(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Ae(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}Ae.groups={};Ae.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],o=e.jr[r][1];if(o&&s.test(n))return o}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let s=0;s<n.length;s++)this.tt(n[s],e,t,r)},tr(n,e,t,r){r=r||Ae.groups;let s;return e&&e.j?s=e:(s=new Ae(e),t&&r&&Pt(e,t,r)),this.jr.push([n,s]),s},ts(n,e,t,r){let s=this;const o=n.length;if(!o)return s;for(let i=0;i<o-1;i++)s=s.tt(n[i]);return s.tt(n[o-1],e,t,r)},tt(n,e,t,r){r=r||Ae.groups;const s=this;if(e&&e.j)return s.j[n]=e,e;const o=e;let i,l=s.go(n);if(l?(i=new Ae,Object.assign(i.j,l.j),i.jr.push.apply(i.jr,l.jr),i.jd=l.jd,i.t=l.t):i=new Ae,o){if(r)if(i.t&&typeof i.t=="string"){const a=Object.assign(nk(i.t,r),t);Pt(o,a,r)}else t&&Pt(o,t,r);i.t=o}return s.j[n]=i,i}};const W=(n,e,t,r,s)=>n.ta(e,t,r,s),oe=(n,e,t,r,s)=>n.tr(e,t,r,s),ac=(n,e,t,r,s)=>n.ts(e,t,r,s),M=(n,e,t,r,s)=>n.tt(e,t,r,s),nt="WORD",yi="UWORD",wf="ASCIINUMERICAL",vf="ALPHANUMERICAL",ur="LOCALHOST",xi="TLD",bi="UTLD",$r="SCHEME",yn="SLASH_SCHEME",vl="NUM",ki="WS",Cl="NL",Xn="OPENBRACE",Yn="CLOSEBRACE",ts="OPENBRACKET",ns="CLOSEBRACKET",rs="OPENPAREN",ss="CLOSEPAREN",is="OPENANGLEBRACKET",ls="CLOSEANGLEBRACKET",as="FULLWIDTHLEFTPAREN",cs="FULLWIDTHRIGHTPAREN",ds="LEFTCORNERBRACKET",us="RIGHTCORNERBRACKET",fs="LEFTWHITECORNERBRACKET",hs="RIGHTWHITECORNERBRACKET",ps="FULLWIDTHLESSTHAN",ms="FULLWIDTHGREATERTHAN",gs="AMPERSAND",ys="APOSTROPHE",xs="ASTERISK",ht="AT",bs="BACKSLASH",ks="BACKTICK",Ss="CARET",gt="COLON",Nl="COMMA",ws="DOLLAR",Ke="DOT",vs="EQUALS",El="EXCLAMATION",Pe="HYPHEN",Qn="PERCENT",Cs="PIPE",Ns="PLUS",Es="POUND",Zn="QUERY",Tl="QUOTE",Cf="FULLWIDTHMIDDLEDOT",Ml="SEMI",Je="SLASH",er="TILDE",Ts="UNDERSCORE",Nf="EMOJI",Ms="SYM";var Ef=Object.freeze({__proto__:null,ALPHANUMERICAL:vf,AMPERSAND:gs,APOSTROPHE:ys,ASCIINUMERICAL:wf,ASTERISK:xs,AT:ht,BACKSLASH:bs,BACKTICK:ks,CARET:Ss,CLOSEANGLEBRACKET:ls,CLOSEBRACE:Yn,CLOSEBRACKET:ns,CLOSEPAREN:ss,COLON:gt,COMMA:Nl,DOLLAR:ws,DOT:Ke,EMOJI:Nf,EQUALS:vs,EXCLAMATION:El,FULLWIDTHGREATERTHAN:ms,FULLWIDTHLEFTPAREN:as,FULLWIDTHLESSTHAN:ps,FULLWIDTHMIDDLEDOT:Cf,FULLWIDTHRIGHTPAREN:cs,HYPHEN:Pe,LEFTCORNERBRACKET:ds,LEFTWHITECORNERBRACKET:fs,LOCALHOST:ur,NL:Cl,NUM:vl,OPENANGLEBRACKET:is,OPENBRACE:Xn,OPENBRACKET:ts,OPENPAREN:rs,PERCENT:Qn,PIPE:Cs,PLUS:Ns,POUND:Es,QUERY:Zn,QUOTE:Tl,RIGHTCORNERBRACKET:us,RIGHTWHITECORNERBRACKET:hs,SCHEME:$r,SEMI:Ml,SLASH:Je,SLASH_SCHEME:yn,SYM:Ms,TILDE:er,TLD:xi,UNDERSCORE:Ts,UTLD:bi,UWORD:yi,WORD:nt,WS:ki});const et=/[a-z]/,Bn=new RegExp("\\p{L}","u"),jo=new RegExp("\\p{Emoji}","u"),tt=/\d/,Do=/\s/,cc="\r",Po=`
|
|
132
|
+
`,rk="️",sk="",Lo="";let Ar=null,Or=null;function ok(n=[]){const e={};Ae.groups=e;const t=new Ae;Ar==null&&(Ar=dc(Yb)),Or==null&&(Or=dc(Qb)),M(t,"'",ys),M(t,"{",Xn),M(t,"}",Yn),M(t,"[",ts),M(t,"]",ns),M(t,"(",rs),M(t,")",ss),M(t,"<",is),M(t,">",ls),M(t,"(",as),M(t,")",cs),M(t,"「",ds),M(t,"」",us),M(t,"『",fs),M(t,"』",hs),M(t,"<",ps),M(t,">",ms),M(t,"&",gs),M(t,"*",xs),M(t,"@",ht),M(t,"`",ks),M(t,"^",Ss),M(t,":",gt),M(t,",",Nl),M(t,"$",ws),M(t,".",Ke),M(t,"=",vs),M(t,"!",El),M(t,"-",Pe),M(t,"%",Qn),M(t,"|",Cs),M(t,"+",Ns),M(t,"#",Es),M(t,"?",Zn),M(t,'"',Tl),M(t,"/",Je),M(t,";",Ml),M(t,"~",er),M(t,"_",Ts),M(t,"\\",bs),M(t,"・",Cf);const r=oe(t,tt,vl,{[hi]:!0});oe(r,tt,r);const s=oe(r,et,wf,{[Gn]:!0}),o=oe(r,Bn,vf,{[Wn]:!0}),i=oe(t,et,nt,{[pi]:!0});oe(i,tt,s),oe(i,et,i),oe(s,tt,s),oe(s,et,s);const l=oe(t,Bn,yi,{[mi]:!0});oe(l,et),oe(l,tt,o),oe(l,Bn,l),oe(o,tt,o),oe(o,et),oe(o,Bn,o);const a=M(t,Po,Cl,{[Ro]:!0}),c=M(t,cc,ki,{[Ro]:!0}),d=oe(t,Do,ki,{[Ro]:!0});M(t,Lo,d),M(c,Po,a),M(c,Lo,d),oe(c,Do,d),M(d,cc),M(d,Po),oe(d,Do,d),M(d,Lo,d);const u=oe(t,jo,Nf,{[Sf]:!0});M(u,"#"),oe(u,jo,u),M(u,rk,u);const f=M(u,sk);M(f,"#"),oe(f,jo,u);const h=[[et,i],[tt,s]],p=[[et,null],[Bn,l],[tt,o]];for(let y=0;y<Ar.length;y++)ct(t,Ar[y],xi,nt,h);for(let y=0;y<Or.length;y++)ct(t,Or[y],bi,yi,p);Pt(xi,{tld:!0,ascii:!0},e),Pt(bi,{utld:!0,alpha:!0},e),ct(t,"file",$r,nt,h),ct(t,"mailto",$r,nt,h),ct(t,"http",yn,nt,h),ct(t,"https",yn,nt,h),ct(t,"ftp",yn,nt,h),ct(t,"ftps",yn,nt,h),Pt($r,{scheme:!0,ascii:!0},e),Pt(yn,{slashscheme:!0,ascii:!0},e),n=n.sort((y,g)=>y[0]>g[0]?1:-1);for(let y=0;y<n.length;y++){const g=n[y][0],b=n[y][1]?{[Zb]:!0}:{[ek]:!0};g.indexOf("-")>=0?b[gi]=!0:et.test(g)?tt.test(g)?b[Gn]=!0:b[pi]=!0:b[hi]=!0,ac(t,g,g,b)}return ac(t,"localhost",ur,{ascii:!0}),t.jd=new Ae(Ms),{start:t,tokens:Object.assign({groups:e},Ef)}}function Tf(n,e){const t=ik(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,s=[];let o=0,i=0;for(;i<r;){let l=n,a=null,c=0,d=null,u=-1,f=-1;for(;i<r&&(a=l.go(t[i]));)l=a,l.accepts()?(u=0,f=0,d=l):u>=0&&(u+=t[i].length,f++),c+=t[i].length,o+=t[i].length,i++;o-=u,i-=f,c-=u,s.push({t:d.t,v:e.slice(o-c,o),s:o-c,e:o})}return s}function ik(n){const e=[],t=n.length;let r=0;for(;r<t;){let s=n.charCodeAt(r),o,i=s<55296||s>56319||r+1===t||(o=n.charCodeAt(r+1))<56320||o>57343?n[r]:n.slice(r,r+2);e.push(i),r+=i.length}return e}function ct(n,e,t,r,s){let o;const i=e.length;for(let l=0;l<i-1;l++){const a=e[l];n.j[a]?o=n.j[a]:(o=new Ae(r),o.jr=s.slice(),n.j[a]=o),n=o}return o=new Ae(t),o.jr=s.slice(),n.j[e[i-1]]=o,o}function dc(n){const e=[],t=[];let r=0,s="0123456789";for(;r<n.length;){let o=0;for(;s.indexOf(n[r+o])>=0;)o++;if(o>0){e.push(t.join(""));for(let i=parseInt(n.substring(r,r+o),10);i>0;i--)t.pop();r+=o}else t.push(n[r]),r++}return e}const fr={defaultProtocol:"http",events:null,format:uc,formatHref:uc,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Al(n,e=null){let t=Object.assign({},fr);n&&(t=Object.assign(t,n instanceof Al?n.o:n));const r=t.ignoreTags,s=[];for(let o=0;o<r.length;o++)s.push(r[o].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=s}Al.prototype={o:fr,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let s=this.o[n];return s&&(typeof s=="object"?(s=t.t in s?s[t.t]:fr[n],typeof s=="function"&&r&&(s=s(e,t))):typeof s=="function"&&r&&(s=s(e,t.t,t)),s)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function uc(n){return n}function Mf(n,e){this.t="token",this.v=n,this.tk=e}Mf.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=fr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),s=n.get("tagName",t,e),o=this.toFormattedString(n),i={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),d=n.getObj("attributes",t,e),u=n.getObj("events",t,e);return i.href=r,l&&(i.class=l),a&&(i.target=a),c&&(i.rel=c),d&&Object.assign(i,d),{tagName:s,attributes:i,content:o,eventListeners:u}}};function Gs(n,e){class t extends Mf{constructor(s,o){super(s,o),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const fc=Gs("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),hc=Gs("text"),lk=Gs("nl"),Ir=Gs("url",{isLink:!0,toHref(n=fr.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==ur&&n[1].t===gt}}),De=n=>new Ae(n);function ak({groups:n}){const e=n.domain.concat([gs,xs,ht,bs,ks,Ss,ws,vs,Pe,vl,Qn,Cs,Ns,Es,Je,Ms,er,Ts]),t=[ys,gt,Nl,Ke,El,Qn,Zn,Tl,Ml,is,ls,Xn,Yn,ns,ts,rs,ss,as,cs,ds,us,fs,hs,ps,ms],r=[gs,ys,xs,bs,ks,Ss,ws,vs,Pe,Xn,Yn,Qn,Cs,Ns,Es,Zn,Je,Ms,er,Ts],s=De(),o=M(s,er);W(o,r,o),W(o,n.domain,o);const i=De(),l=De(),a=De();W(s,n.domain,i),W(s,n.scheme,l),W(s,n.slashscheme,a),W(i,r,o),W(i,n.domain,i);const c=M(i,ht);M(o,ht,c),M(l,ht,c),M(a,ht,c);const d=M(o,Ke);W(d,r,o),W(d,n.domain,o);const u=De();W(c,n.domain,u),W(u,n.domain,u);const f=M(u,Ke);W(f,n.domain,u);const h=De(fc);W(f,n.tld,h),W(f,n.utld,h),M(c,ur,h);const p=M(u,Pe);M(p,Pe,p),W(p,n.domain,u),W(h,n.domain,u),M(h,Ke,f),M(h,Pe,p);const y=M(h,gt);W(y,n.numeric,fc);const g=M(i,Pe),x=M(i,Ke);M(g,Pe,g),W(g,n.domain,i),W(x,r,o),W(x,n.domain,i);const b=De(Ir);W(x,n.tld,b),W(x,n.utld,b),W(b,n.domain,i),W(b,r,o),M(b,Ke,x),M(b,Pe,g),M(b,ht,c);const S=M(b,gt),v=De(Ir);W(S,n.numeric,v);const k=De(Ir),w=De();W(k,e,k),W(k,t,w),W(w,e,k),W(w,t,w),M(b,Je,k),M(v,Je,k);const C=M(l,gt),T=M(a,gt),A=M(T,Je),D=M(A,Je);W(l,n.domain,i),M(l,Ke,x),M(l,Pe,g),W(a,n.domain,i),M(a,Ke,x),M(a,Pe,g),W(C,n.domain,k),M(C,Je,k),M(C,Zn,k),W(D,n.domain,k),W(D,e,k),M(D,Je,k);const j=[[Xn,Yn],[ts,ns],[rs,ss],[is,ls],[as,cs],[ds,us],[fs,hs],[ps,ms]];for(let _=0;_<j.length;_++){const[V,B]=j[_],H=M(k,V);M(w,V,H),M(H,B,k);const N=De(Ir);W(H,e,N);const z=De();W(H,t),W(N,e,N),W(N,t,z),W(z,e,N),W(z,t,z),M(N,B,k),M(z,B,k)}return M(s,ur,b),M(s,Cl,lk),{start:s,tokens:Ef}}function ck(n,e,t){let r=t.length,s=0,o=[],i=[];for(;s<r;){let l=n,a=null,c=null,d=0,u=null,f=-1;for(;s<r&&!(a=l.go(t[s].t));)i.push(t[s++]);for(;s<r&&(c=a||l.go(t[s].t));)a=null,l=c,l.accepts()?(f=0,u=l):f>=0&&f++,s++,d++;if(f<0)s-=d,s<r&&(i.push(t[s]),s++);else{i.length>0&&(o.push($o(hc,e,i)),i=[]),s-=f,d-=f;const h=u.t,p=t.slice(s-d,s);o.push($o(h,e,p))}}return i.length>0&&o.push($o(hc,e,i)),o}function $o(n,e,t){const r=t[0].s,s=t[t.length-1].e,o=e.slice(r,s);return new n(o,t)}const dk=typeof console<"u"&&console&&console.warn||(()=>{}),uk="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Z={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function fk(){return Ae.groups={},Z.scanner=null,Z.parser=null,Z.tokenQueue=[],Z.pluginQueue=[],Z.customSchemes=[],Z.initialized=!1,Z}function pc(n,e=!1){if(Z.initialized&&dk(`linkifyjs: already initialized - will not register custom scheme "${n}" ${uk}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
|
|
133
133
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
134
134
|
2. Cannot start or end with "-"
|
|
135
|
-
3. "-" cannot repeat`);Z.customSchemes.push([n,e])}function
|
|
136
|
-
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(
|
|
137
|
-
`,u+=1;else if(h.match(
|
|
135
|
+
3. "-" cannot repeat`);Z.customSchemes.push([n,e])}function hk(){Z.scanner=ok(Z.customSchemes);for(let n=0;n<Z.tokenQueue.length;n++)Z.tokenQueue[n][1]({scanner:Z.scanner});Z.parser=ak(Z.scanner.tokens);for(let n=0;n<Z.pluginQueue.length;n++)Z.pluginQueue[n][1]({scanner:Z.scanner,parser:Z.parser});return Z.initialized=!0,Z}function Ol(n){return Z.initialized||hk(),ck(Z.parser.start,n,Tf(Z.scanner.start,n))}Ol.scan=Tf;function Af(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new Al(t),s=Ol(n),o=[];for(let i=0;i<s.length;i++){const l=s[i];l.isLink&&(!e||l.t===e)&&r.check(l)&&o.push(l.toFormattedObject(r))}return o}var Il="[\0- -\u2029 ]",pk=new RegExp(Il),mk=new RegExp(`${Il}$`),gk=new RegExp(Il,"g");function yk(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function xk(n){return new re({key:new ae("autolink"),appendTransaction:(e,t,r)=>{const s=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),o=e.some(c=>c.getMeta("preventAutolink"));if(!s||o)return;const{tr:i}=r,l=Wu(t.doc,[...e]);if(Yu(l).forEach(({newRange:c})=>{const d=ex(r.doc,c,h=>h.isTextblock);let u,f;if(d.length>1)u=d[0],f=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){const h=r.doc.textBetween(c.from,c.to," "," ");if(!mk.test(h))return;u=d[0],f=r.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&f){const h=f.split(pk).filter(Boolean);if(h.length<=0)return!1;const p=h[h.length-1],y=u.pos+f.lastIndexOf(p);if(!p)return!1;const g=Ol(p).map(x=>x.toObject(n.defaultProtocol));if(!yk(g))return!1;g.filter(x=>x.isLink).map(x=>({...x,from:y+x.start+1,to:y+x.end+1})).filter(x=>r.schema.marks.code?!r.doc.rangeHasMark(x.from,x.to,r.schema.marks.code):!0).filter(x=>n.validate(x.value)).filter(x=>n.shouldAutoLink(x.value)).forEach(x=>{xl(x.from,x.to,r.doc).some(b=>b.mark.type===n.type)||i.addMark(x.from,x.to,n.type.create({href:x.href}))})}}),!!i.steps.length)return i}})}function bk(n){return new re({key:new ae("handleClickLink"),props:{handleClick:(e,t,r)=>{var s,o;if(r.button!==0||!e.editable)return!1;let i=!1;if(n.enableClickSelection&&(i=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){let l=null;if(r.target instanceof HTMLAnchorElement)l=r.target;else{let u=r.target;const f=[];for(;u.nodeName!=="DIV";)f.push(u),u=u.parentNode;l=f.find(h=>h.nodeName==="A")}if(!l)return i;const a=Xu(e.state,n.type.name),c=(s=l?.href)!=null?s:a.href,d=(o=l?.target)!=null?o:a.target;l&&c&&(window.open(c,d),i=!0)}return i}}})}function kk(n){return new re({key:new ae("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{shouldAutoLink:s}=n,{state:o}=e,{selection:i}=o,{empty:l}=i;if(l)return!1;let a="";r.content.forEach(d=>{a+=d.textContent});const c=Af(a,{defaultProtocol:n.defaultProtocol}).find(d=>d.isLink&&d.value===a);return!a||!c||s!==void 0&&!s(c.value)?!1:n.editor.commands.setMark(n.type,{href:c.href})}}})}function Ot(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&t.push(s)}),!n||n.replace(gk,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Sk=Zt.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){pc(n);return}pc(n.scheme,n.optionalSlashes)})},onDestroy(){fk()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!Ot(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),t=/^[a-z][a-z0-9+.-]*:/i.test(n);if(e||t&&!n.includes("@"))return!0;const s=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!Ot(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!Ot(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",ne(this.options.HTMLAttributes,n),0]:["a",ne(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t;const r=((t=n.attrs)==null?void 0:t.href)||"";return`[${e.renderChildren(n)}](${r})`},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Ot(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:r=>!!Ot(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Xt({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,s=Af(n).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:i=>!!Ot(i,t),protocols:t,defaultProtocol:r}));s.length&&s.forEach(o=>{this.options.shouldAutoLink(o.value)&&e.push({text:o.value,data:{href:o.href},index:o.start})})}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(xk({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!Ot(s,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(bk({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(kk({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),wk=Object.defineProperty,vk=(n,e)=>{for(var t in e)wk(n,t,{get:e[t],enumerable:!0})},Ck="listItem",mc="textStyle",gc=/^\s*([-+*])\s$/,Of=Ie.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",ne(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?e.parseChildren(n.items):[]},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
|
|
136
|
+
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Ck,this.editor.getAttributes(mc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=An({find:gc,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=An({find:gc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(mc),editor:this.editor})),[n]}}),If=Ie.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",ne(this.options.HTMLAttributes,n),0]},markdownTokenName:"list_item",parseMarkdown:(n,e)=>{if(n.type!=="list_item")return[];let t=[];if(n.tokens&&n.tokens.length>0)if(n.tokens.some(s=>s.type==="paragraph"))t=e.parseChildren(n.tokens);else{const s=n.tokens[0];if(s&&s.type==="text"&&s.tokens&&s.tokens.length>0){if(t=[{type:"paragraph",content:e.parseInline(s.tokens)}],n.tokens.length>1){const i=n.tokens.slice(1),l=e.parseChildren(i);t.push(...l)}}else t=e.parseChildren(n.tokens)}return t.length===0&&(t=[{type:"paragraph",content:[]}]),{type:"listItem",content:t}},renderMarkdown:(n,e,t)=>wl(n,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",t),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Nk={};vk(Nk,{findListItemPos:()=>xr,getNextListDepth:()=>Rl,handleBackspace:()=>Si,handleDelete:()=>wi,hasListBefore:()=>Rf,hasListItemAfter:()=>Ek,hasListItemBefore:()=>jf,listItemHasSubList:()=>Df,nextListIsDeeper:()=>Pf,nextListIsHigher:()=>Lf});var xr=(n,e)=>{const{$from:t}=e.selection,r=ue(n,e.schema);let s=null,o=t.depth,i=t.pos,l=null;for(;o>0&&l===null;)s=t.node(o),s.type===r?l=o:(o-=1,i-=1);return l===null?null:{$pos:e.doc.resolve(i),depth:l}},Rl=(n,e)=>{const t=xr(n,e);if(!t)return!1;const[,r]=dx(e,n,t.$pos.pos+4);return r},Rf=(n,e,t)=>{const{$anchor:r}=n.selection,s=Math.max(0,r.pos-2),o=n.doc.resolve(s).node();return!(!o||!t.includes(o.type.name))},jf=(n,e)=>{var t;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((t=s.nodeBefore)==null?void 0:t.type.name)!==n)},Df=(n,e,t)=>{if(!t)return!1;const r=ue(n,e.schema);let s=!1;return t.descendants(o=>{o.type===r&&(s=!0)}),s},Si=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!Nt(n.state,e)&&Rf(n.state,e,t)){const{$anchor:l}=n.state.selection,a=n.state.doc.resolve(l.before()-1),c=[];a.node().descendants((f,h)=>{f.type.name===e&&c.push({node:f,pos:h})});const d=c.at(-1);if(!d)return!1;const u=n.state.doc.resolve(a.start()+d.pos+1);return n.chain().cut({from:l.start()-1,to:l.end()+1},u.end()).joinForward().run()}if(!Nt(n.state,e)||!px(n.state))return!1;const r=xr(e,n.state);if(!r)return!1;const o=n.state.doc.resolve(r.$pos.pos-2).node(r.depth),i=Df(e,n.state,o);return jf(e,n.state)&&!i?n.commands.joinItemBackward():n.chain().liftListItem(e).run()},Pf=(n,e)=>{const t=Rl(n,e),r=xr(n,e);return!r||!t?!1:t>r.depth},Lf=(n,e)=>{const t=Rl(n,e),r=xr(n,e);return!r||!t?!1:t<r.depth},wi=(n,e)=>{if(!Nt(n.state,e)||!hx(n.state,e))return!1;const{selection:t}=n.state,{$from:r,$to:s}=t;return!t.empty&&r.sameParent(s)?!1:Pf(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():Lf(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},Ek=(n,e)=>{var t;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((t=s.nodeAfter)==null?void 0:t.type.name)!==n)},$f=ce.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&wi(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&wi(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Si(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Si(n,t,r)&&(e=!0)}),e}}}}),yc=/^(\s*)(\d+)\.\s+(.*)$/,Tk=/^\s/;function Mk(n){const e=[];let t=0,r=0;for(;t<n.length;){const s=n[t],o=s.match(yc);if(!o)break;const[,i,l,a]=o,c=i.length;let d=a,u=t+1;const f=[s];for(;u<n.length;){const h=n[u];if(h.match(yc))break;if(h.trim()==="")f.push(h),d+=`
|
|
137
|
+
`,u+=1;else if(h.match(Tk))f.push(h),d+=`
|
|
138
138
|
${h.slice(c+2)}`,u+=1;else break}e.push({indent:c,number:parseInt(l,10),content:d.trim(),raw:f.join(`
|
|
139
139
|
`)}),r=u,t=u}return[e,r]}function zf(n,e,t){var r;const s=[];let o=0;for(;o<n.length;){const i=n[o];if(i.indent===e){const l=i.content.split(`
|
|
140
140
|
`),a=((r=l[0])==null?void 0:r.trim())||"",c=[];a&&c.push({type:"paragraph",raw:a,tokens:t.inlineTokens(a)});const d=l.slice(1).join(`
|
|
141
141
|
`).trim();if(d){const h=t.blockTokens(d);c.push(...h)}let u=o+1;const f=[];for(;u<n.length&&n[u].indent>e;)f.push(n[u]),u+=1;if(f.length>0){const h=Math.min(...f.map(y=>y.indent)),p=zf(f,h,t);c.push({type:"list",ordered:!0,start:f[0].number,items:p,raw:f.map(y=>y.raw).join(`
|
|
142
|
-
`)})}s.push({type:"list_item",raw:i.raw,tokens:c}),o=u}else o+=1}return s}function
|
|
142
|
+
`)})}s.push({type:"list_item",raw:i.raw,tokens:c}),o=u}else o+=1}return s}function Ak(n,e){return n.map(t=>{if(t.type!=="list_item")return e.parseChildren([t])[0];const r=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const o=e.parseChildren([s]);r.push({type:"paragraph",content:o})}else{const o=e.parseChildren([s]);o.length>0&&r.push(...o)}}),{type:"listItem",content:r}})}var Ok="listItem",xc="textStyle",bc=/^(\d+)\.\s$/,_f=Ie.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",ne(this.options.HTMLAttributes,t),0]:["ol",ne(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>{if(n.type!=="list"||!n.ordered)return[];const t=n.start||1,r=n.items?Ak(n.items,e):[];return t!==1?{type:"orderedList",attrs:{start:t},content:r}:{type:"orderedList",content:r}},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
|
|
143
143
|
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:n=>{const e=n.match(/^(\s*)(\d+)\.\s+/),t=e?.index;return t!==void 0?t:-1},tokenize:(n,e,t)=>{var r;const s=n.split(`
|
|
144
|
-
`),[o,i]=
|
|
145
|
-
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(
|
|
146
|
-
`):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const r=o=>{const i=ui(o,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},t);return i?[{type:"taskList",raw:i.raw,items:i.items}]:t.blockTokens(o)},s=ui(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,i)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:t.inlineTokens(o.mainContent),nestedTokens:i}),customNestedParser:r},t);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ce.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(Of.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(If.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push($f.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(_f.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(Ck.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(Nk.configure(this.options.taskList)),n}});var Ek=Ie.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",ne(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];return t.length===1&&t[0].type==="image"?e.parseChildren([t[0]]):e.createNode("paragraph",void 0,e.parseInline(t))},renderMarkdown:(n,e)=>!n||!Array.isArray(n.content)?"":e.renderChildren(n.content),addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Tk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Mk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Ak=Zt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",ne(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Mn({find:Tk,type:this.type})]},addPasteRules(){return[Xt({find:Mk,type:this.type})]}}),Ok=Ie.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),Ik=Zt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",ne(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!s)return;const o=s[2].trim();return{type:"underline",raw:s[0],text:o,tokens:t.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function Rk(n={}){return new re({view(e){return new jk(e,n)}})}class jk{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let o=i=>{this[s](i)};return e.dom.addEventListener(s,o),{name:s,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.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),t=!e.parent.inlineContent,r,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(t){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let h=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(h){let p=h.getBoundingClientRect(),y=u?p.bottom:p.top;u&&f&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:y-g,bottom:y+g}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;r={left:u.left-f,right:u.left+f,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.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",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),f=u.width/a.offsetWidth,h=u.height/a.offsetHeight;c=u.left-a.scrollLeft*f,d=u.top-a.scrollTop*h}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!o){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Pd(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class ie extends q{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return ie.valid(r)?new ie(r):q.near(r)}content(){return R.empty}eq(e){return e instanceof ie&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ie(e.resolve(t.pos))}getBookmark(){return new jl(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Dk(e)||!Pk(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&ie.valid(e))return e;let s=e.pos,o=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){o=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;s+=t;let a=e.doc.resolve(s);if(ie.valid(a))return a}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!$.isSelectable(o)){e=e.doc.resolve(s+o.nodeSize*t),r=!1;continue e}break}o=i,s+=t;let l=e.doc.resolve(s);if(ie.valid(l))return l}return null}}}ie.prototype.visible=!1;ie.findFrom=ie.findGapCursorFrom;q.jsonID("gapcursor",ie);class jl{constructor(e){this.pos=e}map(e){return new jl(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ie.valid(t)?new ie(t):q.near(t)}}function Bf(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function Dk(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Bf(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Pk(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Bf(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Lk(){return new re({props:{decorations:Bk,createSelectionBetween(n,e,t){return e.pos==t.pos&&ie.valid(t)?new ie(t):null},handleClick:zk,handleKeyDown:$k,handleDOMEvents:{beforeinput:_k}}})}const $k=Lu({ArrowLeft:Rr("horiz",-1),ArrowRight:Rr("horiz",1),ArrowUp:Rr("vert",-1),ArrowDown:Rr("vert",1)});function Rr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,o){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof F){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ie.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new ie(c))),!0):!1}}function zk(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!ie.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&$.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ie(r))),!0)}function _k(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ie))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=E.empty;for(let i=r.length-1;i>=0;i--)s=E.from(r[i].createAndFill(null,s));let o=n.state.tr.replace(t.pos,t.pos,new R(s,0,0));return o.setSelection(F.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function Bk(n){if(!(n.selection instanceof ie))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",te.create(n.doc,[ve.widget(n.selection.head,e,{key:"gapcursor"})])}var As=200,ye=function(){};ye.prototype.append=function(e){return e.length?(e=ye.from(e),!this.length&&e||e.length<As&&this.leafAppend(e)||this.length<As&&e.leafPrepend(this)||this.appendInner(e)):this};ye.prototype.prepend=function(e){return e.length?ye.from(e).append(this):this};ye.prototype.appendInner=function(e){return new Fk(this,e)};ye.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?ye.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};ye.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ye.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};ye.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(o,i){return s.push(e(o,i))},t,r),s};ye.from=function(e){return e instanceof ye?e:e&&e.length?new Ff(e):ye.empty};var Ff=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,o){return s==0&&o==this.length?this:new e(this.values.slice(s,o))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,o,i,l){for(var a=o;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,l){for(var a=o-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=As)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=As)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(ye);ye.empty=new Ff([]);var Fk=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.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,s,o,i){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(o,l),i)===!1||o>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,o)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(o,l)-l,i+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(s,l),o,i)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var o=this.left.length;return s<=o?this.left.slice(r,s):r>=o?this.right.slice(r-o,s-o):this.left.slice(r,o).append(this.right.slice(0,s-o))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,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})(ye);const Vk=500;class Ve{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,o;t&&(s=this.remapping(r,this.items.length),o=s.maps.length);let i=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){s||(s=this.remapping(r,f+1),o=s.maps.length),o--,d.push(u);return}if(s){d.push(new dt(u.map));let h=u.step.map(s.slice(o)),p;h&&i.maybeStep(h).doc&&(p=i.mapping.maps[i.mapping.maps.length-1],c.push(new dt(p,void 0,void 0,c.length+d.length))),o--,p&&s.appendMap(p,o)}else i.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(o)):u.selection,a=new Ve(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,r,s){let o=[],i=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),f=new dt(e.mapping.maps[d],u,t),h;(h=a&&a.merge(f))&&(f=h,d?o.pop():l=l.slice(0,l.length-1)),o.push(f),t&&(i++,t=void 0),s||(a=f)}let c=i-r.depth;return c>Wk&&(l=Hk(l,c),i-=c),new Ve(l.append(o),i)}remapping(e,t){let r=new sr;return this.items.forEach((s,o)=>{let i=s.mirrorOffset!=null&&o-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,i)},e,t),r}addMaps(e){return this.eventCount==0?this:new Ve(this.items.append(e.map(t=>new dt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=o.getMirror(--a);if(h==null)return;i=Math.min(i,h);let p=o.maps[h];if(f.step){let y=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(o.slice(a+1,h));g&&l++,r.push(new dt(p,y,g))}else r.push(new dt(p))},s);let c=[];for(let f=t;f<i;f++)c.push(new dt(o.maps[f]));let d=this.items.slice(0,s).append(c).append(r),u=new Ve(d,l);return u.emptyItemCount()>Vk&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],o=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&o++;else if(i.step){let a=i.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let d=i.selection&&i.selection.map(t.slice(r));d&&o++;let u=new dt(c.invert(),a,d),f,h=s.length-1;(f=s.length&&s[h].merge(u))?s[h]=f:s.push(u)}}else i.map&&r--},this.items.length,0),new Ve(ye.from(s.reverse()),o)}}Ve.empty=new Ve(ye.empty,0);function Hk(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}let dt=class Vf{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Vf(t.getMap().invert(),t,this.selection)}}};class pt{constructor(e,t,r,s,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=o}}const Wk=20;function qk(n,e,t,r){let s=t.getMeta(Wt),o;if(s)return s.historyState;t.getMeta(Jk)&&(n=new pt(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(Wt))return i.getMeta(Wt).redo?new pt(n.done.addTransform(t,void 0,r,zr(e)),n.undone,kc(t.mapping.maps),n.prevTime,n.prevComposition):new pt(n.done,n.undone.addTransform(t,void 0,r,zr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!Uk(t,n.prevRanges)),c=i?zo(n.prevRanges,t.mapping):kc(t.mapping.maps);return new pt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,zr(e)),Ve.empty,c,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new pt(n.done.rebased(t,o),n.undone.rebased(t,o),zo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new pt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),zo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Uk(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&s>=e[o]&&(t=!0)}),t}function kc(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,o,i)=>e.push(o,i));return e}function zo(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),o=e.map(n[r+1],-1);s<=o&&t.push(s,o)}return t}function Kk(n,e,t){let r=zr(e),s=Wt.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let i=o.selection.resolve(o.transform.doc),l=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),s,r),a=new pt(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta(Wt,{redo:t,historyState:a})}let _o=!1,Sc=null;function zr(n){let e=n.plugins;if(Sc!=e){_o=!1,Sc=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){_o=!0;break}}return _o}const Wt=new ae("history"),Jk=new ae("closeHistory");function Gk(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new re({key:Wt,state:{init(){return new pt(Ve.empty,Ve.empty,null,0,-1)},apply(e,t,r){return qk(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?Wf:r=="historyRedo"?qf:null;return!s||!e.editable?!1:(t.preventDefault(),s(e.state,e.dispatch))}}}})}function Hf(n,e){return(t,r)=>{let s=Wt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let o=Kk(s,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}const Wf=Hf(!1,!0),qf=Hf(!0,!0);ce.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.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=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new re({key:new ae("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const s=this.options.limit;if(s==null||s===0){n=!0;return}const o=this.storage.characters({node:r.doc});if(o>s){const i=o-s,l=0,a=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:t.doc}),o=this.storage.characters({node:e.doc});if(o<=r||s>r&&o>r&&o<=s)return!0;if(s>r&&o>r&&o>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=o-r,c=l-a,d=l;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>r)}})]}});var Xk=ce.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Rk(this.options)]}});ce.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new re({key:new ae("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:s}=e,o=[];if(!t||!r)return te.create(n,[]);let i=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;i+=1});let l=0;return n.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&i-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";o.push(ve.node(c,c+a.nodeSize,{class:this.options.className}))}),te.create(n,o)}}})]}});var Yk=ce.create({name:"gapCursor",addProseMirrorPlugins(){return[Lk()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=G(L(n,"allowGapCursor",t)))!=null?e:null}}});ce.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new re({key:new ae("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(!t)return null;const o=this.editor.isEmpty;return n.descendants((i,l)=>{const a=r>=l&&r<=l+i.nodeSize,c=!i.isLeaf&&Us(i);if((a||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);const u=ve.node(l,l+i.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:i,pos:l,hasAnchor:a}):this.options.placeholder});s.push(u)}return this.options.includeChildren}),te.create(n,s)}}})]}});ce.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new re({key:new ae("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||Qu(t.selection)||n.view.dragging?null:te.create(t.doc,[ve.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function wc({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var Qk=ce.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new ae(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(t).includes(s.name));return[new re({key:e,appendTransaction:(s,o,i)=>{const{doc:l,tr:a,schema:c}=i,d=e.getState(i),u=l.content.size,f=c.nodes[t];if(d)return a.insert(u,f.create())},state:{init:(s,o)=>{const i=o.tr.doc.lastChild;return!wc({node:i,types:r})},apply:(s,o)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return o;const i=s.doc.lastChild;return!wc({node:i,types:r})}}})]}}),Zk=ce.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Wf(n,e),redo:()=>({state:n,dispatch:e})=>qf(n,e)}},addProseMirrorPlugins(){return[Gk(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()}}}),eS=ce.create({name:"starterKit",addExtensions(){var n,e,t,r;const s=[];return this.options.bold!==!1&&s.push(Tb.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(wb.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(Of.configure(this.options.bulletList)),this.options.code!==!1&&s.push(Ob.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(jb.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(Db.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(Xk.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(Yk.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(Pb.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(Lb.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(Zk.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push($b.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(Vb.configure(this.options.italic)),this.options.listItem!==!1&&s.push(If.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push($f.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&s.push(hk.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(_f.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(Ek.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(Ak.configure(this.options.strike)),this.options.text!==!1&&s.push(Ok.configure(this.options.text)),this.options.underline!==!1&&s.push(Ik.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&s.push(Qk.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),tS=eS;function nS(n){var e;const{char:t,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:l}=n,a=r&&!s,c=Kx(t),d=new RegExp(`\\s${c}$`),u=i?"^":"",f=s?"":c,h=a?new RegExp(`${u}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${u}(?:^)?${c}[^\\s${f}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const y=l.pos-p.length,g=Array.from(p.matchAll(h)).pop();if(!g||g.input===void 0||g.index===void 0)return null;const x=g.input.slice(Math.max(0,g.index-1),g.index),b=new RegExp(`^[${o?.join("")}\0]?$`).test(x);if(o!==null&&!b)return null;const S=y+g.index;let v=S+g[0].length;return a&&d.test(p.slice(v-1,v+1))&&(g[0]+=" ",v+=1),S<l.pos&&v>=l.pos?{range:{from:S,to:v},query:g[0].slice(t.length),text:g[0]}:null}var rS=new ae("suggestion");function sS({pluginKey:n=rS,editor:e,char:t="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:o=[" "],startOfLine:i=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:d="is-empty",command:u=()=>null,items:f=()=>[],render:h=()=>({}),allow:p=()=>!0,findSuggestionMatch:y=nS,shouldShow:g}){let x;const b=h?.(),S=()=>{const C=e.state.selection.$anchor.pos,T=e.view.coordsAtPos(C),{top:A,right:D,bottom:j,left:_}=T;try{return new DOMRect(_,A,D-_,j-A)}catch{return null}},v=(C,T)=>T?()=>{const A=n.getState(e.state),D=A?.decorationId,j=C.dom.querySelector(`[data-decoration-id="${D}"]`);return j?.getBoundingClientRect()||null}:S;function k(C,T){var A;try{const j=n.getState(C.state),_=j?.decorationId?C.dom.querySelector(`[data-decoration-id="${j.decorationId}"]`):null,V={editor:e,range:j?.range||{from:0,to:0},query:j?.query||null,text:j?.text||null,items:[],command:B=>u({editor:e,range:j?.range||{from:0,to:0},props:B}),decorationNode:_,clientRect:v(C,_)};(A=b?.onExit)==null||A.call(b,V)}catch{}const D=C.state.tr.setMeta(T,{exit:!0});C.dispatch(D)}const w=new re({key:n,view(){return{update:async(C,T)=>{var A,D,j,_,V,B,H;const N=(A=this.key)==null?void 0:A.getState(T),z=(D=this.key)==null?void 0:D.getState(C.state),P=N.active&&z.active&&N.range.from!==z.range.from,U=!N.active&&z.active,Q=N.active&&!z.active,le=!U&&!Q&&N.query!==z.query,X=U||P&&le,fe=le||P,se=Q||P&≤if(!X&&!fe&&!se)return;const K=se&&!X?N:z,Fe=C.dom.querySelector(`[data-decoration-id="${K.decorationId}"]`);x={editor:e,range:K.range,query:K.query,text:K.text,items:[],command:at=>u({editor:e,range:K.range,props:at}),decorationNode:Fe,clientRect:v(C,Fe)},X&&((j=b?.onBeforeStart)==null||j.call(b,x)),fe&&((_=b?.onBeforeUpdate)==null||_.call(b,x)),(fe||X)&&(x.items=await f({editor:e,query:K.query})),se&&((V=b?.onExit)==null||V.call(b,x)),fe&&((B=b?.onUpdate)==null||B.call(b,x)),X&&((H=b?.onStart)==null||H.call(b,x))},destroy:()=>{var C;x&&((C=b?.onExit)==null||C.call(b,x))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(C,T,A,D){const{isEditable:j}=e,{composing:_}=e.view,{selection:V}=C,{empty:B,from:H}=V,N={...T},z=C.getMeta(n);if(z&&z.exit)return N.active=!1,N.decorationId=null,N.range={from:0,to:0},N.query=null,N.text=null,N;if(N.composing=_,j&&(B||e.view.composing)){(H<T.range.from||H>T.range.to)&&!_&&!T.composing&&(N.active=!1);const P=y({char:t,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:V.$from}),U=`id_${Math.floor(Math.random()*4294967295)}`;P&&p({editor:e,state:D,range:P.range,isActive:T.active})&&(!g||g({editor:e,range:P.range,query:P.query,text:P.text,transaction:C}))?(N.active=!0,N.decorationId=T.decorationId?T.decorationId:U,N.range=P.range,N.query=P.query,N.text=P.text):N.active=!1}else N.active=!1;return N.active||(N.decorationId=null,N.range={from:0,to:0},N.query=null,N.text=null),N}},props:{handleKeyDown(C,T){var A,D,j,_;const{active:V,range:B}=w.getState(C.state);if(!V)return!1;if(T.key==="Escape"||T.key==="Esc"){const N=w.getState(C.state),z=(A=x?.decorationNode)!=null?A:null,P=z??(N?.decorationId?C.dom.querySelector(`[data-decoration-id="${N.decorationId}"]`):null);if(((D=b?.onKeyDown)==null?void 0:D.call(b,{view:C,event:T,range:N.range}))||!1)return!0;const Q={editor:e,range:N.range,query:N.query,text:N.text,items:[],command:le=>u({editor:e,range:N.range,props:le}),decorationNode:P,clientRect:P?()=>P.getBoundingClientRect()||null:null};return(j=b?.onExit)==null||j.call(b,Q),k(C,n),!0}return((_=b?.onKeyDown)==null?void 0:_.call(b,{view:C,event:T,range:B}))||!1},decorations(C){const{active:T,range:A,decorationId:D,query:j}=w.getState(C);if(!T)return null;const _=!j?.length,V=[a];return _&&V.push(d),te.create(C.doc,[ve.inline(A.from,A.to,{nodeName:l,class:V.join(" "),"data-decoration-id":D,"data-decoration-content":c})])}}});return w}function oS({editor:n,overrideSuggestionOptions:e,extensionName:t,char:r="@"}){const s=new ae;return{editor:n,char:r,pluginKey:s,command:({editor:o,range:i,props:l})=>{var a,c,d;const u=o.view.state.selection.$to.nodeAfter;(a=u?.text)!=null&&a.startsWith(" ")&&(i.to+=1),o.chain().focus().insertContentAt(i,[{type:t,attrs:{...l,mentionSuggestionChar:r}},{type:"text",text:" "}]).run(),(d=(c=o.view.dom.ownerDocument.defaultView)==null?void 0:c.getSelection())==null||d.collapseToEnd()},allow:({state:o,range:i})=>{const l=o.doc.resolve(i.from),a=o.schema.nodes[t];return!!l.parent.type.contentMatch.matchType(a)},...e}}function Uf(n){return(n.options.suggestions.length?n.options.suggestions:[n.options.suggestion]).map(e=>oS({editor:n.editor,overrideSuggestionOptions:e,extensionName:n.name,char:e.char}))}function vc(n,e){const t=Uf(n),r=t.find(s=>s.char===e);return r||(t.length?t[0]:null)}var iS=Ie.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:n,suggestion:e}){var t,r;return`${(t=e?.char)!=null?t:"@"}${(r=n.attrs.label)!=null?r:n.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:n,node:e,suggestion:t}){var r,s;return["span",ne(this.HTMLAttributes,n.HTMLAttributes),`${(r=t?.char)!=null?r:"@"}${(s=e.attrs.label)!=null?s:e.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id"),renderHTML:n=>n.id?{"data-id":n.id}:{}},label:{default:null,parseHTML:n=>n.getAttribute("data-label"),renderHTML:n=>n.label?{"data-label":n.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:n=>n.getAttribute("data-mention-suggestion-char"),renderHTML:n=>({"data-mention-suggestion-char":n.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:n,HTMLAttributes:e}){const t=vc(this,n.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",ne({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:n,suggestion:t})];const r={...this.options};r.HTMLAttributes=ne({"data-type":this.name},this.options.HTMLAttributes,e);const s=this.options.renderHTML({options:r,node:n,suggestion:t});return typeof s=="string"?["span",ne({"data-type":this.name},this.options.HTMLAttributes,e),s]:s},...gf({nodeName:"mention",name:"@",selfClosing:!0,allowedAttributes:["id","label",{name:"mentionSuggestionChar",skipIfDefault:"@"}],parseAttributes:n=>{const e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=t.exec(n);for(;r!==null;){const[,s,o,i]=r,l=o??i;e[s==="char"?"mentionSuggestionChar":s]=l,r=t.exec(n)}return e},serializeAttributes:n=>Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${e==="mentionSuggestionChar"?"char":e}="${t}"`).join(" ")}),renderText({node:n}){const e={options:this.options,node:n,suggestion:vc(this,n.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel(e)):this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:n,state:e})=>{let t=!1;const{selection:r}=e,{empty:s,anchor:o}=r;if(!s)return!1;let i=new ze,l=0;return e.doc.nodesBetween(o-1,o,(a,c)=>{if(a.type.name===this.name)return t=!0,i=a,l=c,!1}),t&&n.insertText(this.options.deleteTriggerWithBackspace?"":i.attrs.mentionSuggestionChar,l,l+i.nodeSize),t})}},addProseMirrorPlugins(){return Uf(this).map(sS)}}),lS=iS,Bo,Xs="HoverCard",[Kf]=Mc(Xs,[Ac]),Ys=Ac(),[aS,Qs]=Kf(Xs),Jf=n=>{const{__scopeHoverCard:e,children:t,open:r,defaultOpen:s,onOpenChange:o,openDelay:i=700,closeDelay:l=300}=n,a=Ys(e),c=O.useRef(0),d=O.useRef(0),u=O.useRef(!1),f=O.useRef(!1),[h,p]=Ei({prop:r,defaultProp:s??!1,onChange:o,caller:Xs}),y=O.useCallback(()=>{clearTimeout(d.current),c.current=window.setTimeout(()=>p(!0),i)},[i,p]),g=O.useCallback(()=>{clearTimeout(c.current),!u.current&&!f.current&&(d.current=window.setTimeout(()=>p(!1),l))},[l,p]),x=O.useCallback(()=>p(!1),[p]);return O.useEffect(()=>()=>{clearTimeout(c.current),clearTimeout(d.current)},[]),m.jsx(aS,{scope:e,open:h,onOpenChange:p,onOpen:y,onClose:g,onDismiss:x,hasSelectionRef:u,isPointerDownOnContentRef:f,children:m.jsx(Nh,{...a,children:t})})};Jf.displayName=Xs;var Gf="HoverCardTrigger",Xf=O.forwardRef((n,e)=>{const{__scopeHoverCard:t,...r}=n,s=Qs(Gf,t),o=Ys(t);return m.jsx(vh,{asChild:!0,...o,children:m.jsx(Ni.a,{"data-state":s.open?"open":"closed",...r,ref:e,onPointerEnter:Ge(n.onPointerEnter,Is(s.onOpen)),onPointerLeave:Ge(n.onPointerLeave,Is(s.onClose)),onFocus:Ge(n.onFocus,s.onOpen),onBlur:Ge(n.onBlur,s.onClose),onTouchStart:Ge(n.onTouchStart,i=>i.preventDefault())})})});Xf.displayName=Gf;var Dl="HoverCardPortal",[cS,dS]=Kf(Dl,{forceMount:void 0}),Yf=n=>{const{__scopeHoverCard:e,forceMount:t,children:r,container:s}=n,o=Qs(Dl,e);return m.jsx(cS,{scope:e,forceMount:t,children:m.jsx(Oc,{present:t||o.open,children:m.jsx(Ch,{asChild:!0,container:s,children:r})})})};Yf.displayName=Dl;var Os="HoverCardContent",Qf=O.forwardRef((n,e)=>{const t=dS(Os,n.__scopeHoverCard),{forceMount:r=t.forceMount,...s}=n,o=Qs(Os,n.__scopeHoverCard);return m.jsx(Oc,{present:r||o.open,children:m.jsx(uS,{"data-state":o.open?"open":"closed",...s,onPointerEnter:Ge(n.onPointerEnter,Is(o.onOpen)),onPointerLeave:Ge(n.onPointerLeave,Is(o.onClose)),ref:e})})});Qf.displayName=Os;var uS=O.forwardRef((n,e)=>{const{__scopeHoverCard:t,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:i,...l}=n,a=Qs(Os,t),c=Ys(t),d=O.useRef(null),u=Ic(e,d),[f,h]=O.useState(!1);return O.useEffect(()=>{if(f){const p=document.body;return Bo=p.style.userSelect||p.style.webkitUserSelect,p.style.userSelect="none",p.style.webkitUserSelect="none",()=>{p.style.userSelect=Bo,p.style.webkitUserSelect=Bo}}},[f]),O.useEffect(()=>{if(d.current){const p=()=>{h(!1),a.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(a.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",p),()=>{document.removeEventListener("pointerup",p),a.hasSelectionRef.current=!1,a.isPointerDownOnContentRef.current=!1}}},[a.isPointerDownOnContentRef,a.hasSelectionRef]),O.useEffect(()=>{d.current&&pS(d.current).forEach(y=>y.setAttribute("tabindex","-1"))}),m.jsx(Eh,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:i,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:Ge(o,p=>{p.preventDefault()}),onDismiss:a.onDismiss,children:m.jsx(Th,{...c,...l,onPointerDown:Ge(l.onPointerDown,p=>{p.currentTarget.contains(p.target)&&h(!0),a.hasSelectionRef.current=!1,a.isPointerDownOnContentRef.current=!0}),ref:u,style:{...l.style,userSelect:f?"text":void 0,WebkitUserSelect:f?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})}),fS="HoverCardArrow",hS=O.forwardRef((n,e)=>{const{__scopeHoverCard:t,...r}=n,s=Ys(t);return m.jsx(Mh,{...s,...r,ref:e})});hS.displayName=fS;function Is(n){return e=>e.pointerType==="touch"?void 0:n()}function pS(n){const e=[],t=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;t.nextNode();)e.push(t.currentNode);return e}var mS=Jf,gS=Xf,yS=Yf,xS=Qf;function bS(n){const e=I.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=m.jsx(mS,{"data-slot":"hover-card",...t}),e[2]=t,e[3]=r):r=e[3],r}function kS(n){const e=I.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=m.jsx(gS,{"data-slot":"hover-card-trigger",...t}),e[2]=t,e[3]=r):r=e[3],r}function SS(n){const e=I.c(12);let t,r,s,o;e[0]!==n?({className:t,align:s,sideOffset:o,...r}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=o):(t=e[1],r=e[2],s=e[3],o=e[4]);const i=s===void 0?"center":s,l=o===void 0?4:o;let a;e[5]!==t?(a=J("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),e[5]=t,e[6]=a):a=e[6];let c;return e[7]!==i||e[8]!==r||e[9]!==l||e[10]!==a?(c=m.jsx(yS,{"data-slot":"hover-card-portal",children:m.jsx(xS,{"data-slot":"hover-card-content",align:i,sideOffset:l,className:a,...r})}),e[7]=i,e[8]=r,e[9]=l,e[10]=a,e[11]=c):c=e[11],c}const Zf=O.createContext(void 0);function wS(n,e){const t=e.split("."),r=t[0];if(!r)return;let s=n[r];for(let o=1;o<t.length&&s!==void 0;o++){const i=t[o];if(i)if(typeof s=="object"&&s!==null)s=s[i];else return}return s}function vS(n){const e=I.c(20),{node:t}=n,r=O.useContext(Zf),s=t.attrs.id??"",o=r!==void 0;let i;if(e[0]!==o||e[1]!==s||e[2]!==r){const y=o?wS(r,s):void 0;i=y!==void 0?typeof y=="object"?JSON.stringify(y,null,2):String(y):void 0,e[0]=o,e[1]=s,e[2]=r,e[3]=i}else i=e[3];const l=i;let a;e[4]!==s?(a=m.jsxs("span",{className:"bg-primary/20 text-primary px-1 rounded font-medium cursor-pointer",children:["@",s]}),e[4]=s,e[5]=a):a=e[5];const c=a;if(!o||l===void 0){let y;return e[6]!==c?(y=m.jsx(oc,{as:"span",children:c}),e[6]=c,e[7]=y):y=e[7],y}let d;e[8]!==c?(d=m.jsx(kS,{asChild:!0,children:c}),e[8]=c,e[9]=d):d=e[9];let u;e[10]!==s?(u=m.jsxs("div",{className:"text-xs font-medium text-muted-foreground",children:["@",s]}),e[10]=s,e[11]=u):u=e[11];let f;e[12]!==l?(f=m.jsx("pre",{className:"text-xs font-mono bg-muted/50 p-2 rounded overflow-auto max-h-[200px] whitespace-pre-wrap break-all",children:l}),e[12]=l,e[13]=f):f=e[13];let h;e[14]!==u||e[15]!==f?(h=m.jsx(SS,{className:"w-auto max-w-[400px] p-3",side:"top",align:"start",children:m.jsxs("div",{className:"space-y-1.5",children:[u,f]})}),e[14]=u,e[15]=f,e[16]=h):h=e[16];let p;return e[17]!==d||e[18]!==h?(p=m.jsx(oc,{as:"span",children:m.jsxs(bS,{openDelay:200,children:[d,h]})}),e[17]=d,e[18]=h,e[19]=p):p=e[19],p}function eh(n){const e=[];function t(r){for(const s of r)s.children?.length||e.push(s),s.children&&t(s.children)}return t(n),e}let Xe=th();function th(){return Ki(()=>({items:[],selectedIndex:0,command:null}))}function Cc(n,e){Xe.setState({items:n,command:e,selectedIndex:0})}function CS(){const{items:n,selectedIndex:e}=Xe.getState();n.length&&Xe.setState({selectedIndex:(e-1+n.length)%n.length})}function NS(){const{items:n,selectedIndex:e}=Xe.getState();n.length&&Xe.setState({selectedIndex:(e+1)%n.length})}function nh(){const{items:n,selectedIndex:e,command:t}=Xe.getState(),r=n[e];return r?(t?.(r),!0):!1}function Nc(){Xe=th()}function ES(){const n=I.c(7),e=Wo(Xe,MS),t=Wo(Xe,TS);if(!e.length)return null;let r;if(n[0]!==e||n[1]!==t){let o;n[3]!==t?(o=(i,l)=>m.jsx("button",{type:"button",onClick:()=>{Xe.setState({selectedIndex:l}),nh()},className:J("flex items-center w-full text-left px-3 py-1.5 text-sm rounded-md transition-colors",l===t?"bg-accent text-accent-foreground":"hover:bg-muted"),children:i.label},i.id),n[3]=t,n[4]=o):o=n[4],r=e.map(o),n[0]=e,n[1]=t,n[2]=r}else r=n[2];let s;return n[5]!==r?(s=m.jsx("div",{className:"bg-popover border border-border rounded-lg shadow-lg overflow-hidden min-w-[180px]",children:m.jsx("div",{className:"p-1",children:r})}),n[5]=r,n[6]=s):s=n[6],s}function TS(n){return n.selectedIndex}function MS(n){return n.items}function AS(){let n=null,e=null;return{onStart:t=>{Cc(t.items,t.command),n=new kf(ES,{editor:t.editor}),e=document.createElement("div"),e.style.cssText="position:absolute;z-index:9999";const r=t.clientRect?.();r&&(e.style.top=`${r.bottom+window.scrollY+4}px`,e.style.left=`${r.left+window.scrollX}px`),e.appendChild(n.element),document.body.appendChild(e)},onUpdate:t=>{Cc(t.items,t.command);const r=t.clientRect?.();r&&e&&(e.style.top=`${r.bottom+window.scrollY+4}px`,e.style.left=`${r.left+window.scrollX}px`)},onKeyDown:({event:t})=>t.key==="Escape"?(e?.remove(),n?.destroy(),Nc(),!0):t.key==="ArrowUp"?(CS(),!0):t.key==="ArrowDown"?(NS(),!0):t.key==="Enter"?nh():!1,onExit:()=>{e?.remove(),n?.destroy(),Nc()}}}const Fo=/@([\w.]+)/g;function OS(n,e){if(!n)return null;const t=eh(e),r=new Map(t.map(a=>[a.id,a]));if(!Fo.test(n))return n;Fo.lastIndex=0;const o=[];let i=0,l;for(;(l=Fo.exec(n))!==null;){const a=l[1]??"",c=l.index;c>i&&o.push({type:"text",text:n.slice(i,c)});const d=r.get(a);d?o.push({type:"mention",attrs:{id:d.id,label:d.label}}):o.push({type:"text",text:l[0]}),i=c+l[0].length}return i<n.length&&o.push({type:"text",text:n.slice(i)}),{type:"doc",content:[{type:"paragraph",content:o.length>0?o:void 0}]}}function Pl(n){const e=I.c(31),{mentions:t,value:r,onChange:s,placeholder:o,className:i,readOnly:l}=n,a=Jm();let c;e[0]!==t||e[1]!==r?(c=OS(r,t),e[0]=t,e[1]=r,e[2]=c):c=e[2];const d=c,u=a!==void 0,f=!l;let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=tS.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,hardBreak:!1}),e[3]=h):h=e[3];let p;if(e[4]!==t||e[5]!==u){let A;e[7]!==t?(A=D=>{const{query:j}=D;return eh(t).filter(V=>V.label.toLowerCase().includes(j.toLowerCase())||V.id.toLowerCase().includes(j.toLowerCase()))},e[7]=t,e[8]=A):A=e[8],p=lS.configure({HTMLAttributes:{class:"bg-primary/20 text-primary px-1 rounded font-medium"},renderText:DS,renderHTML:jS,suggestion:{items:A,render:AS,command:RS}}).extend(u?{addNodeView(){return kb(vS)}}:{}),e[4]=t,e[5]=u,e[6]=p}else p=e[6];let y;e[9]!==p?(y=[h,p],e[9]=p,e[10]=y):y=e[10];const g=o??"";let x;e[11]!==g?(x={attributes:{class:"prose prose-sm max-w-none focus:outline-none w-full min-h-[20px]","data-placeholder":g},handleKeyDown:IS},e[11]=g,e[12]=x):x=e[12];let b;e[13]!==s?(b=A=>{const{editor:D}=A;return s?.(D.getText().trim())},e[13]=s,e[14]=b):b=e[14];let S;e[15]!==d||e[16]!==f||e[17]!==y||e[18]!==x||e[19]!==b?(S={content:d,editable:f,extensions:y,editorProps:x,onUpdate:b},e[15]=d,e[16]=f,e[17]=y,e[18]=x,e[19]=b,e[20]=S):S=e[20];const v=hb(S);let k;e[21]!==i?(k=J("rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",i),e[21]=i,e[22]=k):k=e[22];let w;e[23]!==v?(w=m.jsx(ib,{editor:v}),e[23]=v,e[24]=w):w=e[24];let C;e[25]!==k||e[26]!==w?(C=m.jsx("div",{className:k,children:w}),e[25]=k,e[26]=w,e[27]=C):C=e[27];const T=C;if(a!==void 0){let A;return e[28]!==T||e[29]!==a?(A=m.jsx(Zf.Provider,{value:a,children:T}),e[28]=T,e[29]=a,e[30]=A):A=e[30],A}return T}function IS(n,e){return e.key==="Enter"?(e.preventDefault(),!0):!1}function RS(n){const{editor:e,range:t,props:r}=n;e.chain().focus().insertContentAt(t,[{type:"mention",attrs:r}]).run()}function jS(n){const{options:e,node:t}=n;return["span",e.HTMLAttributes,`@${t.attrs.id}`]}function DS(n){const{node:e}=n;return`@${e.attrs.id}`}function PS(n){const e=I.c(8),{value:t,onChange:r,placeholder:s,readonly:o}=n,i=ad(),l=t??"";let a;e[0]!==r?(a=u=>r(u),e[0]=r,e[1]=a):a=e[1];const c=s||"Enter value...";let d;return e[2]!==i||e[3]!==o||e[4]!==l||e[5]!==a||e[6]!==c?(d=m.jsx(Pl,{mentions:i,value:l,onChange:a,placeholder:c,readOnly:o}),e[2]=i,e[3]=o,e[4]=l,e[5]=a,e[6]=c,e[7]=d):d=e[7],d}function LS(n){const e=I.c(8),{value:t,onChange:r,placeholder:s,readonly:o}=n,i=ad(),l=t??"";let a;e[0]!==r?(a=u=>r(u),e[0]=r,e[1]=a):a=e[1];const c=s||"Enter value...";let d;return e[2]!==i||e[3]!==o||e[4]!==l||e[5]!==a||e[6]!==c?(d=m.jsx(Pl,{mentions:i,value:l,onChange:a,placeholder:c,readOnly:o,className:"min-h-[80px]"}),e[2]=i,e[3]=o,e[4]=l,e[5]=a,e[6]=c,e[7]=d):d=e[7],d}function $S(n){const e=I.c(8),{value:t,onChange:r,readonly:s,id:o}=n,i=t??"";let l;e[0]!==r?(l=d=>r(d.target.value===""?void 0:Number(d.target.value)),e[0]=r,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=J("w-full rounded-md border border-input bg-background px-3 py-2 text-sm","ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50"),e[2]=a):a=e[2];let c;return e[3]!==o||e[4]!==s||e[5]!==i||e[6]!==l?(c=m.jsx("input",{id:o,type:"number",value:i,onChange:l,disabled:s,className:a}),e[3]=o,e[4]=s,e[5]=i,e[6]=l,e[7]=c):c=e[7],c}function zS(n){const e=I.c(13),{value:t,onChange:r,readonly:s,id:o,label:i}=n,l=t??!1;let a;e[0]!==r?(a=f=>r(f.target.checked),e[0]=r,e[1]=a):a=e[1];let c;e[2]!==o||e[3]!==s||e[4]!==l||e[5]!==a?(c=m.jsx("input",{id:o,type:"checkbox",checked:l,onChange:a,disabled:s,className:"h-4 w-4 rounded border-input"}),e[2]=o,e[3]=s,e[4]=l,e[5]=a,e[6]=c):c=e[6];let d;e[7]!==i?(d=m.jsx("span",{className:"text-sm",children:i}),e[7]=i,e[8]=d):d=e[8];let u;return e[9]!==o||e[10]!==c||e[11]!==d?(u=m.jsxs("label",{htmlFor:o,className:"flex items-center gap-2 cursor-pointer",children:[c,d]}),e[9]=o,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function _S(n){const e=I.c(14),{value:t,onChange:r,readonly:s,id:o,options:i}=n;let l;e[0]!==i.enumOptions?(l=i.enumOptions??[],e[0]=i.enumOptions,e[1]=l):l=e[1];const a=l,c=t??"";let d;e[2]!==r?(d=y=>r(y.target.value),e[2]=r,e[3]=d):d=e[3];let u,f;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=J("w-full rounded-md border border-input bg-background px-3 py-2 text-sm","ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50"),f=m.jsx("option",{value:"",children:"Select..."}),e[4]=u,e[5]=f):(u=e[4],f=e[5]);let h;e[6]!==a?(h=a.map(BS),e[6]=a,e[7]=h):h=e[7];let p;return e[8]!==o||e[9]!==s||e[10]!==c||e[11]!==d||e[12]!==h?(p=m.jsxs("select",{id:o,value:c,onChange:d,disabled:s,className:u,children:[f,h]}),e[8]=o,e[9]=s,e[10]=c,e[11]=d,e[12]=h,e[13]=p):p=e[13],p}function BS(n){return m.jsx("option",{value:String(n.value),children:String(n.label)},String(n.value))}const FS={TextWidget:PS,TextareaWidget:LS,NumberWidget:$S,CheckboxWidget:zS,SelectWidget:_S};function VS(n){switch(Array.isArray(n)?n[0]:n??"unknown"){case"string":return{Icon:Uc,color:"text-blue-500"};case"number":case"integer":return{Icon:Wc,color:"text-blue-500"};case"array":return{Icon:Fc,color:"text-purple-500"};case"object":return{Icon:Bc,color:"text-orange-500"};case"boolean":return{Icon:qc,color:"text-pink-500"};case"null":return{Icon:Ti,color:"text-gray-500"};default:return{Icon:Vc,color:"text-muted-foreground"}}}function HS(n){const e=I.c(36),{id:t,label:r,required:s,description:o,children:i,schema:l,hidden:a}=n;if(a){let k;return e[0]!==i?(k=m.jsx("div",{className:"hidden",children:i}),e[0]=i,e[1]=k):k=e[1],k}if(t==="root"){let k;return e[2]!==i?(k=m.jsx("div",{className:"space-y-4",children:i}),e[2]=i,e[3]=k):k=e[3],k}const c=Array.isArray(l.type)?l.type[0]:l.type??"string";let d,u,f,h,p,y,g;if(e[4]!==t||e[5]!==r||e[6]!==s||e[7]!==c){const{Icon:k,color:w}=VS(c);g="space-y-2",h="flex items-center gap-2",e[15]!==t||e[16]!==r?(p=m.jsx("label",{htmlFor:t,className:"text-sm font-medium leading-none",children:r}),e[15]=t,e[16]=r,e[17]=p):p=e[17],e[18]!==s?(y=s&&m.jsx("span",{className:"text-red-500 text-xs",children:"*"}),e[18]=s,e[19]=y):y=e[19],d=k,u=14,f=J(w,"ml-auto"),e[4]=t,e[5]=r,e[6]=s,e[7]=c,e[8]=d,e[9]=u,e[10]=f,e[11]=h,e[12]=p,e[13]=y,e[14]=g}else d=e[8],u=e[9],f=e[10],h=e[11],p=e[12],y=e[13],g=e[14];let x;e[20]!==d||e[21]!==u||e[22]!==f?(x=m.jsx(d,{size:u,className:f}),e[20]=d,e[21]=u,e[22]=f,e[23]=x):x=e[23];let b;e[24]!==h||e[25]!==p||e[26]!==y||e[27]!==x?(b=m.jsxs("div",{className:h,children:[p,y,x]}),e[24]=h,e[25]=p,e[26]=y,e[27]=x,e[28]=b):b=e[28];let S;e[29]!==o?(S=o&&m.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:o}),e[29]=o,e[30]=S):S=e[30];let v;return e[31]!==i||e[32]!==g||e[33]!==b||e[34]!==S?(v=m.jsxs("div",{className:g,children:[b,S,i]}),e[31]=i,e[32]=g,e[33]=b,e[34]=S,e[35]=v):v=e[35],v}function WS(n){const e=I.c(8),{properties:t,title:r}=n;if(!r||r==="Root"){let l;e[0]!==t?(l=t.map(US),e[0]=t,e[1]=l):l=e[1];let a;return e[2]!==l?(a=m.jsx("div",{className:"space-y-4",children:l}),e[2]=l,e[3]=a):a=e[3],a}let o;e[4]!==t?(o=t.map(qS),e[4]=t,e[5]=o):o=e[5];let i;return e[6]!==o?(i=m.jsx("div",{className:"pl-4 border-l-2 border-border/50 space-y-4",children:o}),e[6]=o,e[7]=i):i=e[7],i}function qS(n){return m.jsx("div",{children:n.content},n.name)}function US(n){return m.jsx("div",{children:n.content},n.name)}function KS(n){const e=I.c(11),{items:t,canAdd:r,onAddClick:s,title:o}=n;let i;e[0]!==t?(i=t.map(JS),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==i?(l=m.jsx("div",{className:"space-y-2",children:i}),e[2]=i,e[3]=l):l=e[3];let a;e[4]!==r||e[5]!==s||e[6]!==o?(a=r&&m.jsxs(me,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:s,children:["+ Add ",o||"item"]}),e[4]=r,e[5]=s,e[6]=o,e[7]=a):a=e[7];let c;return e[8]!==l||e[9]!==a?(c=m.jsxs("div",{className:"space-y-2",children:[l,a]}),e[8]=l,e[9]=a,e[10]=c):c=e[10],c}function JS(n){return m.jsx("div",{className:"flex gap-2 items-start",children:m.jsx("div",{className:"flex-1",children:n})},n.key||n.index)}function GS(){return null}function XS(){return null}const YS={FieldTemplate:HS,ObjectFieldTemplate:WS,ArrayFieldTemplate:KS,UnsupportedFieldTemplate:GS,ErrorListTemplate:XS};function QS(n){const e=I.c(6),{inputSchema:t,inputParams:r,mentions:s}=n;if(!t?.properties||!r)return null;let o;e[0]!==s?(o=(a,c,d)=>{const u=typeof c=="object"&&c!==null?JSON.stringify(c,null,2):String(c??""),f=Array.isArray(d.type)?d.type.join(" | "):d.type??"string";return m.jsxs("div",{className:"space-y-1.5",children:[m.jsxs("div",{className:"flex items-baseline gap-2",children:[m.jsx("span",{className:"text-sm font-medium text-foreground",children:a}),m.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:f})]}),d.description&&m.jsx("div",{className:"text-xs text-muted-foreground",children:d.description}),m.jsx("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2 text-sm",children:m.jsx(Pl,{mentions:s,value:u,readOnly:!0,className:"border-0 bg-transparent p-0"})})]},a)},e[0]=s,e[1]=o):o=e[1];const i=o;let l;return e[2]!==r||e[3]!==t.properties||e[4]!==i?(l=m.jsx("div",{className:"space-y-4",children:Object.entries(t.properties).map(a=>{const[c,d]=a,u=r[c];return i(c,u,d)})}),e[2]=r,e[3]=t.properties,e[4]=i,e[5]=l):l=e[5],l}function rh({inputSchema:n,inputParams:e,setInputParams:t,handleInputChange:r,mentions:s,readOnly:o}){const i=s??[];if(!n)return m.jsx("div",{className:"text-sm text-muted-foreground italic",children:"No arguments defined in schema."});if(o)return m.jsx(QS,{inputSchema:n,inputParams:e,mentions:i});const l=n,a=O.useRef(e??{}),c=d=>{const u=d.formData??{},f=a.current;if(t?.(u),r){for(const[h,p]of Object.entries(u))f[h]!==p&&r(h,p);for(const h of Object.keys(f))h in u||r(h,void 0)}a.current=u};return m.jsx(ld.Provider,{value:i,children:m.jsx(qh,{schema:l,formData:e,onChange:c,validator:Uh,widgets:FS,templates:YS,readonly:o,uiSchema:{"ui:submitButtonOptions":{norender:!0}},liveValidate:!1,className:"rjsf-form",omitExtraData:!0,liveOmit:!0,children:m.jsx(m.Fragment,{})})})}function ZS(n){const e=I.c(33),{open:t,onOpenChange:r,inputSchema:s,onSubmit:o,isPending:i}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];const[a,c]=O.useState(l);let d;e[1]!==a||e[2]!==r||e[3]!==o?(d=async()=>{await o(a),r(!1),c({})},e[1]=a,e[2]=r,e[3]=o,e[4]=d):d=e[4];const u=d;let f;e[5]!==r?(f=T=>{T||c({}),r(T)},e[5]=r,e[6]=f):f=e[6];const h=f;let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsxs(op,{children:[m.jsx(ip,{children:"Workflow Input"}),m.jsx(lp,{children:"This workflow requires input values to run. Fill in the fields below to start the execution."})]}),e[7]=p):p=e[7];let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[8]=y):y=e[8];let g;e[9]!==a||e[10]!==s?(g=m.jsx("div",{className:"py-4",children:m.jsx(rh,{inputSchema:s,inputParams:a,setInputParams:c,mentions:y})}),e[9]=a,e[10]=s,e[11]=g):g=e[11];let x;e[12]!==h?(x=()=>h(!1),e[12]=h,e[13]=x):x=e[13];let b;e[14]!==i||e[15]!==x?(b=m.jsx(me,{variant:"outline",onClick:x,disabled:i,children:"Cancel"}),e[14]=i,e[15]=x,e[16]=b):b=e[16];let S;e[17]!==i?(S=i?m.jsx(Ds,{size:"xs"}):m.jsx(Li,{size:14}),e[17]=i,e[18]=S):S=e[18];let v;e[19]!==u||e[20]!==i||e[21]!==S?(v=m.jsxs(me,{onClick:u,disabled:i,className:"gap-2",children:[S,"Run Workflow"]}),e[19]=u,e[20]=i,e[21]=S,e[22]=v):v=e[22];let k;e[23]!==v||e[24]!==b?(k=m.jsxs(ap,{children:[b,v]}),e[23]=v,e[24]=b,e[25]=k):k=e[25];let w;e[26]!==k||e[27]!==g?(w=m.jsxs(cp,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[p,g,k]}),e[26]=k,e[27]=g,e[28]=w):w=e[28];let C;return e[29]!==h||e[30]!==t||e[31]!==w?(C=m.jsx(dp,{open:t,onOpenChange:h,children:w}),e[29]=h,e[30]=t,e[31]=w,e[32]=C):C=e[32],C}function ew(n){const e=I.c(26),{title:t,description:r,onSave:s}=n,i=Ci().location.href,{viewMode:l,setViewMode:a,showExecutionsList:c,toggleExecutionsList:d}=Ji(),{resetToOriginalWorkflow:u,setSelectedGatewayId:f}=Me(),h=od(),p=jn(),y=Se();let g;e[0]!==t?(g=m.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:t}),e[0]=t,e[1]=g):g=e[1];let x;e[2]!==r?(x=r?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"•"}),m.jsx("span",{className:"text-xs text-muted-foreground font-normal truncate min-w-0 max-w-[20ch]",children:r})]}):null,e[2]=r,e[3]=x):x=e[3];let b;e[4]!==g||e[5]!==x?(b=m.jsx(Lc,{children:m.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[g,x]})}),e[4]=g,e[5]=x,e[6]=b):b=e[6];let S;e[7]!==h||e[8]!==s||e[9]!==u||e[10]!==p||e[11]!==f||e[12]!==a||e[13]!==c||e[14]!==t||e[15]!==d||e[16]!==y||e[17]!==i||e[18]!==l?(S=!y&&m.jsxs(m.Fragment,{children:[m.jsx(Ii,{title:t,url:i,icon:"workflow"}),m.jsx(O.Suspense,{fallback:m.jsx(Ds,{size:"xs"}),children:m.jsx(Qh,{selectedGatewayId:p??void 0,onGatewayChange:f,variant:"bordered",placeholder:"Select Agent"})}),m.jsx(rp,{value:l,onValueChange:a,size:"sm",options:[{value:"visual",icon:m.jsx(sp,{})},{value:"code",icon:m.jsx(Gc,{})}]}),m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:u,disabled:!h,"aria-label":"Reset changes",children:m.jsx(Pc,{size:14})})})}),m.jsx($t,{side:"bottom",children:"Reset changes"})]})}),m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:s,disabled:!h,"aria-label":"Save workflow",children:m.jsx(Ui,{size:14})})})}),m.jsx($t,{side:"bottom",children:"Save workflow"})]})}),m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:c?"secondary":"outline",size:"icon",className:"size-7 border border-input",onClick:d,"aria-label":c?"Hide runs":"Show runs",children:m.jsx(Jc,{size:14})})})}),m.jsx($t,{side:"bottom",children:c?"Hide runs":"Show runs"})]})})]}),e[7]=h,e[8]=s,e[9]=u,e[10]=p,e[11]=f,e[12]=a,e[13]=c,e[14]=t,e[15]=d,e[16]=y,e[17]=i,e[18]=l,e[19]=S):S=e[19];let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=m.jsx(rw,{}),e[20]=v):v=e[20];let k;e[21]!==S?(k=m.jsxs(Pi,{children:[S,v]}),e[21]=S,e[22]=k):k=e[22];let w;return e[23]!==b||e[24]!==k?(w=m.jsxs(m.Fragment,{children:[b,k]}),e[23]=b,e[24]=k,e[25]=w):w=e[25],w}function tw(){const n=Se(),{item:e}=Pn(n);return e?.completed_at_epoch_ms!=null}function nw(){const n=Se(),{item:e}=Pn(n);return e?.status==="cancelled"}function rw(){const n=I.c(57),e=od(),t=tw(),r=nw(),s=Se(),o=jn(),{handleRunWorkflow:i,isPending:l,requiresInput:a,inputSchema:c}=qm(),d=pr(),[u,f]=O.useState(!1),{handleCancelWorkflow:h,isCancelling:p}=Um(),{handleResumeWorkflow:y,isResuming:g}=Km(),x=s&&!t;let b;n[0]!==d?(b=d.some(sw),n[0]=d,n[1]=b):b=n[1];const S=b,v=!o,k=e||S||v||l||p,w=x||l;let C;n[2]!==S||n[3]!==v||n[4]!==e||n[5]!==r||n[6]!==w?(C=()=>r?"Workflow is currently cancelled":w?"Workflow is currently running":e?"Save your changes before running":v?"Select an Agent first":S?"Add at least one step to the workflow":null,n[2]=S,n[3]=v,n[4]=e,n[5]=r,n[6]=w,n[7]=C):C=n[7];const A=C();let D;n[8]!==h||n[9]!==y||n[10]!==i||n[11]!==c||n[12]!==r||n[13]!==w||n[14]!==a||n[15]!==s?(D=async()=>{if(a&&c){f(!0);return}if(r&&s){await y(s);return}if(w&&s){await h(s);return}await i({})},n[8]=h,n[9]=y,n[10]=i,n[11]=c,n[12]=r,n[13]=w,n[14]=a,n[15]=s,n[16]=D):D=n[16];const j=D;let _;n[17]!==i?(_=async Fe=>{await i(Fe)},n[17]=i,n[18]=_):_=n[18];const V=_,B=r?"Resume":s?t?"Replay":"Running...":a?"Run with input...":"Run workflow",H=!x&&"bg-primary text-primary-foreground hover:bg-primary/90";let N;n[19]!==H?(N=J("gap-2 h-7 px-3",H),n[19]=H,n[20]=N):N=n[20];let z;n[21]!==p||n[22]!==r||n[23]!==l||n[24]!==g||n[25]!==x?(z=(!x&&!l&&!p&&!g||r)&&m.jsx(Li,{size:14}),n[21]=p,n[22]=r,n[23]=l,n[24]=g,n[25]=x,n[26]=z):z=n[26];let P;n[27]!==p||n[28]!==r||n[29]!==l||n[30]!==g||n[31]!==x?(P=x&&!l&&!p&&!g&&!r&&m.jsx(Zh,{size:14}),n[27]=p,n[28]=r,n[29]=l,n[30]=g,n[31]=x,n[32]=P):P=n[32];let U;n[33]!==p||n[34]!==l||n[35]!==g?(U=(l||p||g)&&m.jsx(Ds,{size:"xs"}),n[33]=p,n[34]=l,n[35]=g,n[36]=U):U=n[36];let Q;n[37]!==B||n[38]!==j||n[39]!==k||n[40]!==N||n[41]!==z||n[42]!==P||n[43]!==U?(Q=m.jsxs(me,{variant:"default",size:"sm",className:N,disabled:k,onClick:j,children:[z,P,U,B]}),n[37]=B,n[38]=j,n[39]=k,n[40]=N,n[41]=z,n[42]=P,n[43]=U,n[44]=Q):Q=n[44];const le=Q;let X;n[45]!==le||n[46]!==A?(X=A?m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:le})}),m.jsx($t,{side:"bottom",children:A})]})}):le,n[45]=le,n[46]=A,n[47]=X):X=n[47];const fe=X;let se;n[48]!==V||n[49]!==c||n[50]!==l||n[51]!==a||n[52]!==u?(se=a&&c&&m.jsx(ZS,{open:u,onOpenChange:f,inputSchema:c,onSubmit:V,isPending:l}),n[48]=V,n[49]=c,n[50]=l,n[51]=a,n[52]=u,n[53]=se):se=n[53];let K;return n[54]!==fe||n[55]!==se?(K=m.jsxs(m.Fragment,{children:[fe,se]}),n[54]=fe,n[55]=se,n[56]=K):K=n[56],K}function sw(n){return"toolName"in n.action&&(!n.action.toolName||n.action.toolName==="")}function ow(){const n=I.c(17),e=Se(),t=pr(),{item:r}=Pn(e);if(!e||!r)return;let s;if(n[0]!==r.completed_steps?.error||n[1]!==r.completed_steps?.success||n[2]!==r.status||n[3]!==t){s={};let o;n[5]!==r.completed_steps?.success?(o=r.completed_steps?.success??[],n[5]=r.completed_steps?.success,n[6]=o):o=n[6];let i;n[7]!==o?(i=new Set(o),n[7]=o,n[8]=i):i=n[8];const l=i;let a;n[9]!==r.completed_steps?.error?(a=r.completed_steps?.error??[],n[9]=r.completed_steps?.error,n[10]=a):a=n[10];let c;n[11]!==a?(c=new Set(a),n[11]=a,n[12]=c):c=n[12];const d=c;let u;n[13]!==d||n[14]!==t||n[15]!==l?(u=-1,t.forEach((f,h)=>{(l.has(f.name)||d.has(f.name))&&(u=h)}),n[13]=d,n[14]=t,n[15]=l,n[16]=u):u=n[16],t.forEach((f,h)=>{let p="pending";d.has(f.name)?p="error":l.has(f.name)?p="success":r.status==="running"&&h===u+1&&(p="running"),s[f.name]={status:p,output:void 0,error:void 0,stepIndex:h}}),n[0]=r.completed_steps?.error,n[1]=r.completed_steps?.success,n[2]=r.status,n[3]=t,n[4]=s}else s=n[4];return s}function iw(n){const e=I.c(119),{step:t,index:r,isSelected:s,executionStatus:o,isSkipped:i,isLastStep:l,onSelect:a,onDelete:c,onDuplicate:d}=n,u=Se(),{item:f}=Pn(u),h=f?.completed_at_epoch_ms;let p;e[0]!==f?.completed_steps?.success||e[1]!==t.name?(p=f?.completed_steps?.success?.includes(t.name)??!1,e[0]=f?.completed_steps?.success,e[1]=t.name,e[2]=p):p=e[2];const y=p;let g;e[3]!==f?.completed_steps?.error||e[4]!==t.name?(g=f?.completed_steps?.error?.includes(t.name)??!1,e[3]=f?.completed_steps?.error,e[4]=t.name,e[5]=g):g=e[5];const x=g,b="toolName"in t.action,S=b&&"connectionId"in t.action?t.action.connectionId:null,k=!!(b&&"toolName"in t.action?t.action.toolName:null);let w,C,T,A,D,j,_,V,B,H,N;if(e[6]!==S||e[7]!==o||e[8]!==k||e[9]!==r||e[10]!==y||e[11]!==x||e[12]!==l||e[13]!==s||e[14]!==i||e[15]!==b||e[16]!==c||e[17]!==d||e[18]!==a||e[19]!==t||e[20]!==u){const le=yw(t);w=y?"success":x?"error":o?.status;const X=o!==void 0,fe=w==="success"||w==="error";let se=le.length>0?60:12;(w==="success"||w==="error")&&(se=se+32);let K,Fe,at;if(e[32]!==s||e[33]!==i||e[34]!==a||e[35]!==w){const $n=cw(w);let br;e[44]!==w?(br=dw(w),e[44]=w,e[45]=br):br=e[45],K=br;const ro=s&&"bg-background border-1 border-border outline outline-offset-3 outline-border/25",so=w==="running"&&"bg-accent/50",oo=i&&"opacity-50";e[46]!==ro||e[47]!==so||e[48]!==oo?(V=J("flex gap-2 items-start border-1 border-transparent px-4 w-full rounded-lg cursor-pointer group hover:bg-accent/30",ro,so,oo),e[46]=ro,e[47]=so,e[48]=oo,e[49]=V):V=e[49],B=a,H="button",N=0,e[50]!==a?(C=io=>{(io.key==="Enter"||io.key===" ")&&(io.preventDefault(),a())},e[50]=a,e[51]=C):C=e[51],at="w-5 flex flex-col items-center justify-center shrink-0 pt-3",Fe=J("text-xs font-mono opacity-75 h-8 flex items-center",$n),e[32]=s,e[33]=i,e[34]=a,e[35]=w,e[36]=K,e[37]=C,e[38]=Fe,e[39]=at,e[40]=V,e[41]=B,e[42]=H,e[43]=N}else K=e[36],C=e[37],Fe=e[38],at=e[39],V=e[40],B=e[41],H=e[42],N=e[43];const to=r+1;let en;e[52]!==Fe||e[53]!==to?(en=m.jsxs("span",{className:Fe,children:[to,"."]}),e[52]=Fe,e[53]=to,e[54]=en):en=e[54],e[55]!==at||e[56]!==en?(T=m.jsx("div",{className:at,children:en}),e[55]=at,e[56]=en,e[57]=T):T=e[57];let tn;e[58]!==K||e[59]!==r?(tn=r>0?m.jsx(Vo,{height:12,color:K}):m.jsx("div",{className:"h-3"}),e[58]=K,e[59]=r,e[60]=tn):tn=e[60];let nn;e[61]!==S||e[62]!==k||e[63]!==b||e[64]!==t.name?(nn=m.jsx(mw,{connectionId:S,isToolStep:b,hasToolSelected:k,stepName:t.name}),e[61]=S,e[62]=k,e[63]=b,e[64]=t.name,e[65]=nn):nn=e[65];let rn;e[66]!==K||e[67]!==fe||e[68]!==w?(rn=fe&&m.jsxs(m.Fragment,{children:[m.jsx(Vo,{height:8,color:K}),m.jsx(uw,{status:w})]}),e[66]=K,e[67]=fe,e[68]=w,e[69]=rn):rn=e[69];let sn;e[70]!==K||e[71]!==se||e[72]!==l||e[73]!==u?(sn=l&&u?null:m.jsx(Vo,{height:se,color:K}),e[70]=K,e[71]=se,e[72]=l,e[73]=u,e[74]=sn):sn=e[74],e[75]!==tn||e[76]!==nn||e[77]!==rn||e[78]!==sn?(A=m.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[tn,nn,rn,sn]}),e[75]=tn,e[76]=nn,e[77]=rn,e[78]=sn,e[79]=A):A=e[79],D="flex-1 flex flex-col gap-3 min-w-0 pt-3 pb-3";const no=k?"font-medium text-foreground":"text-foreground";let on;e[80]!==no?(on=J("text-sm truncate flex-1",no),e[80]=no,e[81]=on):on=e[81];let ln;e[82]!==t?(ln=gw(t),e[82]=t,e[83]=ln):ln=e[83];let an;e[84]!==on||e[85]!==ln?(an=m.jsx("span",{className:on,children:ln}),e[84]=on,e[85]=ln,e[86]=an):an=e[86];let cn;e[87]!==X||e[88]!==w?(cn=X&&m.jsx(fw,{status:w}),e[87]=X,e[88]=w,e[89]=cn):cn=e[89];let dn;e[90]!==X||e[91]!==c||e[92]!==d?(dn=!X&&m.jsxs(fp,{children:[m.jsx(hp,{asChild:!0,children:m.jsx(me,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity",onClick:aw,children:m.jsx(up,{size:14})})}),m.jsxs(pp,{align:"end",children:[m.jsxs(Fl,{onClick:$n=>{$n.stopPropagation(),d()},children:[m.jsx(yp,{size:14}),"Duplicate"]}),m.jsxs(Fl,{className:"text-destructive hover:bg-destructive/10! focus:text-destructive",onClick:$n=>{$n.stopPropagation(),c()},children:[m.jsx(Ah,{size:14,className:"text-destructive"}),"Delete"]})]})]}),e[90]=X,e[91]=c,e[92]=d,e[93]=dn):dn=e[93],e[94]!==an||e[95]!==cn||e[96]!==dn?(j=m.jsxs("div",{className:"flex items-center h-8",children:[an,cn,dn]}),e[94]=an,e[95]=cn,e[96]=dn,e[97]=j):j=e[97],_=le.length>0&&m.jsx("div",{className:"flex flex-wrap gap-1.5",children:le.map(lw)}),e[6]=S,e[7]=o,e[8]=k,e[9]=r,e[10]=y,e[11]=x,e[12]=l,e[13]=s,e[14]=i,e[15]=b,e[16]=c,e[17]=d,e[18]=a,e[19]=t,e[20]=u,e[21]=w,e[22]=C,e[23]=T,e[24]=A,e[25]=D,e[26]=j,e[27]=_,e[28]=V,e[29]=B,e[30]=H,e[31]=N}else w=e[21],C=e[22],T=e[23],A=e[24],D=e[25],j=e[26],_=e[27],V=e[28],B=e[29],H=e[30],N=e[31];let z;e[98]!==h||e[99]!==w?(z=w==="success"&&m.jsx(hw,{completedAtEpochMs:h}),e[98]=h,e[99]=w,e[100]=z):z=e[100];let P;e[101]!==o?.error||e[102]!==w?(P=w==="error"&&m.jsx(pw,{error:o?.error}),e[101]=o?.error,e[102]=w,e[103]=P):P=e[103];let U;e[104]!==z||e[105]!==P||e[106]!==D||e[107]!==j||e[108]!==_?(U=m.jsxs("div",{className:D,children:[j,_,z,P]}),e[104]=z,e[105]=P,e[106]=D,e[107]=j,e[108]=_,e[109]=U):U=e[109];let Q;return e[110]!==C||e[111]!==T||e[112]!==A||e[113]!==U||e[114]!==V||e[115]!==B||e[116]!==H||e[117]!==N?(Q=m.jsxs("div",{className:V,onClick:B,role:H,tabIndex:N,onKeyDown:C,children:[T,A,U]}),e[110]=C,e[111]=T,e[112]=A,e[113]=U,e[114]=V,e[115]=B,e[116]=H,e[117]=N,e[118]=Q):Q=e[118],Q}function lw(n){return m.jsx("span",{className:"px-1.5 py-1 text-xs text-muted-foreground bg-background border border-border rounded-lg",children:n},n)}function aw(n){return n.stopPropagation()}function cw(n){switch(n){case"success":return"text-success";case"error":return"text-destructive";default:return"text-muted-foreground"}}function dw(n){switch(n){case"success":return"bg-success";case"error":return"bg-destructive";default:return"bg-border"}}function uw(n){const e=I.c(2),{status:t}=n;if(t==="success"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-4 rounded bg-success flex items-center justify-center",children:m.jsx(Vi,{size:8,className:"text-success-foreground"})}),e[0]=r):r=e[0],r}if(t==="error"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-4 rounded bg-destructive flex items-center justify-center",children:m.jsx($i,{size:8,className:"text-destructive-foreground"})}),e[1]=r):r=e[1],r}return null}function fw(n){const e=I.c(3),{status:t}=n;if(t==="success"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-7 flex items-center justify-center",children:m.jsx(Vi,{size:11,className:"text-success"})}),e[0]=r):r=e[0],r}if(t==="error"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-7 flex items-center justify-center",children:m.jsx($i,{size:11,className:"text-destructive"})}),e[1]=r):r=e[1],r}if(t==="running"){let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-7 flex items-center justify-center",children:m.jsx(tr,{size:11,className:"text-muted-foreground animate-spin"})}),e[2]=r):r=e[2],r}return null}function hw(n){const e=I.c(8),{completedAtEpochMs:t}=n;let r,s;if(e[0]!==t){const a=t!=null?new Date(t):null;r=a?a.toISOString().split("T")[0]:null,s=a?a.toTimeString().split(" ")[0]:null,e[0]=t,e[1]=r,e[2]=s}else r=e[1],s=e[2];const o=s;let i;e[3]!==r||e[4]!==o?(i=r&&o&&m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Fh,{size:16,className:"text-success"}),m.jsx("span",{className:"text-xs text-success",children:r}),m.jsx("span",{className:"text-xs text-success",children:o})]}),e[3]=r,e[4]=o,e[5]=i):i=e[5];let l;return e[6]!==i?(l=m.jsx("div",{className:"inline-flex items-center gap-3 px-1.5 py-1 bg-success-foreground rounded-lg w-fit",children:i}),e[6]=i,e[7]=l):l=e[7],l}function pw(n){const e=I.c(3),{error:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx(qi,{size:16,className:"text-destructive"}),e[0]=r):r=e[0];const s=t||"Execution failed";let o;return e[1]!==s?(o=m.jsxs("div",{className:"inline-flex items-center gap-1.5 px-1.5 py-1 bg-destructive-foreground rounded-lg w-fit",children:[r,m.jsx("span",{className:"text-xs text-destructive",children:s})]}),e[1]=s,e[2]=o):o=e[2],o}function mw(n){const e=I.c(5),{connectionId:t,isToolStep:r,hasToolSelected:s,stepName:o}=n,i=Oi(t??"");if(r&&s&&i?.icon){let a;return e[0]!==i.icon||e[1]!==o?(a=m.jsx("div",{className:"size-8 rounded-lg border border-border/10 bg-background shadow-sm flex items-center justify-center overflow-hidden",children:m.jsx(js,{icon:i.icon,name:o,size:"xs",className:"border-0 rounded-none"})}),e[0]=i.icon,e[1]=o,e[2]=a):a=e[2],a}let l;return e[3]!==r?(l=m.jsx("div",{className:"size-8 rounded-lg border border-border/10 bg-background shadow-sm flex items-center justify-center",children:r?m.jsx(Zc,{size:16,className:"text-muted-foreground"}):m.jsx(gp,{size:16,className:"text-muted-foreground"})}),e[3]=r,e[4]=l):l=e[4],l}function Vo(n){const e=I.c(7),{height:t,color:r}=n,s=r===void 0?"bg-border":r;let o;e[0]!==s?(o=J("w-px",s),e[0]=s,e[1]=o):o=e[1];let i;e[2]!==t?(i={height:t},e[2]=t,e[3]=i):i=e[3];let l;return e[4]!==o||e[5]!==i?(l=m.jsx("div",{className:o,style:i}),e[4]=o,e[5]=i,e[6]=l):l=e[6],l}function gw(n){return n.name?n.name:"toolName"in n.action&&n.action.toolName?n.action.toolName:"code"in n.action?n.name||"Code Step":"Select tool..."}function yw(n){const e=n.outputSchema;if(!e||typeof e!="object")return[];const t=e.properties;return!t||typeof t!="object"?[]:Object.keys(t).slice(0,5)}function xw(n){const e=I.c(32),{className:t}=n,r=pr(),s=sd(),o=ow(),{setCurrentStepName:i,deleteStep:l,duplicateStep:a}=Me(),c=Se();let d;e[0]!==o||e[1]!==r?(d=o?r.findIndex(S=>o[S.name]?.status==="error"):-1,e[0]=o,e[1]=r,e[2]=d):d=e[2];const u=d;let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=m.jsx("div",{children:"Loading..."}),e[3]=f):f=e[3];let h;e[4]!==t?(h=J("h-full flex flex-col p-8 overflow-auto",t),e[4]=t,e[5]=h):h=e[5];let p;if(e[6]!==s||e[7]!==l||e[8]!==a||e[9]!==u||e[10]!==i||e[11]!==o||e[12]!==r){let S;e[14]!==s||e[15]!==l||e[16]!==a||e[17]!==u||e[18]!==i||e[19]!==o||e[20]!==r.length?(S=(v,k)=>{const w=o?.[v.name],C=u!==-1&&k>u&&w?.status==="pending",T=k===r.length-1;return m.jsx(iw,{step:v,index:k,isSelected:v.name===s,executionStatus:w,isSkipped:C,isLastStep:T,onSelect:()=>i(v.name),onDelete:()=>l(v.name),onDuplicate:()=>a(v.name)},v.name)},e[14]=s,e[15]=l,e[16]=a,e[17]=u,e[18]=i,e[19]=o,e[20]=r.length,e[21]=S):S=e[21],p=r.map(S),e[6]=s,e[7]=l,e[8]=a,e[9]=u,e[10]=i,e[11]=o,e[12]=r,e[13]=p}else p=e[13];let y;e[22]!==p?(y=m.jsx("div",{className:"pt-3 -space-y-1",children:p}),e[22]=p,e[23]=y):y=e[23];let g;e[24]!==c?(g=c?null:m.jsx(bw,{}),e[24]=c,e[25]=g):g=e[25];let x;e[26]!==y||e[27]!==g?(x=m.jsxs("div",{className:"w-full -space-y-1",children:[y,g]}),e[26]=y,e[27]=g,e[28]=x):x=e[28];let b;return e[29]!==h||e[30]!==x?(b=m.jsx(O.Suspense,{fallback:f,children:m.jsx("div",{className:h,children:x})}),e[29]=h,e[30]=x,e[31]=b):b=e[31],b}function bw(){const n=I.c(8),{addToolStep:e}=Me();let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=m.jsx("div",{className:"w-5 shrink-0"}),n[0]=t):t=n[0];let r;n[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"w-px h-3 bg-border"}),n[1]=r):r=n[1];let s;n[2]===Symbol.for("react.memo_cache_sentinel")?(s=m.jsx(zc,{size:14}),n[2]=s):s=n[2];let o;n[3]!==e?(o=m.jsx(me,{variant:"outline",size:"icon",className:"size-8 rounded-lg",onClick:e,children:s}),n[3]=e,n[4]=o):o=n[4];let i;n[5]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx("div",{className:"w-px h-8",style:{backgroundImage:"repeating-linear-gradient(180deg, var(--border), var(--border) 4px, transparent 4px, transparent 8px)",backgroundPosition:"left top",backgroundRepeat:"repeat-y",backgroundSize:"2px 100%"}}),n[5]=i):i=n[5];let l;return n[6]!==o?(l=m.jsxs("div",{className:"flex gap-2 items-start px-4 pb-3",children:[t,m.jsxs("div",{className:"flex flex-col border-1 border-transparent items-center shrink-0",children:[r,o,i]})]}),n[6]=o,n[7]=l):l=n[7],l}function kw(){const n=I.c(5),e=jn();let t;n[0]!==e?(t=e?new URL(`/mcp/gateway/${e}`,window.location.origin).href:"",n[0]=e,n[1]=t):t=n[1];const r=t,s=!!e;let o;return n[2]!==r||n[3]!==s?(o={url:r,enabled:s},n[2]=r,n[3]=s,n[4]=o):o=n[4],zi(o)}function Sw(n){const e=I.c(7),{className:t}=n;if(!jn()){let o;e[0]!==t?(o=J("flex flex-col h-full bg-sidebar",t),e[0]=t,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground p-4 text-center",children:"Select a gateway to see available tools"}),e[2]=i):i=e[2];let l;return e[3]!==o?(l=m.jsx("div",{className:o,children:i}),e[3]=o,e[4]=l):l=e[4],l}let s;return e[5]!==t?(s=m.jsx(ww,{className:t}),e[5]=t,e[6]=s):s=e[6],s}function ww(n){const e=I.c(38),{className:t}=n,{tools:r,isLoading:s,error:o}=kw(),i=hr(),{updateStep:l}=Me(),c=i&&"toolName"in i.action&&"toolName"in i.action?i.action.toolName:null;let d;if(e[0]!==c||e[1]!==r){let k;e[3]!==c?(k=w=>w.name===c,e[3]=c,e[4]=k):k=e[4],d=r.find(k),e[0]=c,e[1]=r,e[2]=d}else d=e[2];const f=Gm(r,d??null,Cw,vw);let h;e[5]!==i||e[6]!==l?(h=k=>{i&&l(i.name,{action:{...i.action,toolName:k.name},outputSchema:k.outputSchema??{}})},e[5]=i,e[6]=l,e[7]=h):h=e[7];const p=h;if(s){let k;e[8]!==t?(k=J("flex flex-col h-full bg-sidebar",t),e[8]=t,e[9]=k):k=e[9];let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=m.jsx("div",{className:"flex-1 flex items-center justify-center",children:m.jsx(Ds,{size:"sm"})}),e[10]=w):w=e[10];let C;return e[11]!==k?(C=m.jsx("div",{className:k,children:w}),e[11]=k,e[12]=C):C=e[12],C}if(o){let k;e[13]!==t?(k=J("flex flex-col h-full bg-sidebar",t),e[13]=t,e[14]=k):k=e[14];let w;e[15]!==o.message?(w=m.jsxs("div",{className:"flex-1 flex items-center justify-center text-sm text-destructive p-4 text-center",children:["Failed to load tools: ",o.message]}),e[15]=o.message,e[16]=w):w=e[16];let C;return e[17]!==k||e[18]!==w?(C=m.jsx("div",{className:k,children:w}),e[17]=k,e[18]=w,e[19]=C):C=e[19],C}let y;e[20]!==t?(y=J("flex flex-col h-full bg-sidebar",t),e[20]=t,e[21]=y):y=e[21];let g;e[22]===Symbol.for("react.memo_cache_sentinel")?(g=m.jsx("span",{className:"text-base font-medium text-foreground",children:"Select tool"}),e[22]=g):g=e[22];let x;e[23]!==r.length?(x=m.jsx("div",{className:"flex items-start border-b border-border",children:m.jsxs("div",{className:"flex-1 flex items-center h-12 px-5",children:[g,m.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:["(",r.length,")"]})]})}),e[23]=r.length,e[24]=x):x=e[24];let b;if(e[25]!==p||e[26]!==f||e[27]!==c){let k;e[29]!==p||e[30]!==c?(k=w=>m.jsx(Nw,{icon:null,title:w.name,description:w.description,isSelected:w.name===c,onClick:()=>p(w)},w.name),e[29]=p,e[30]=c,e[31]=k):k=e[31],b=f.map(k),e[25]=p,e[26]=f,e[27]=c,e[28]=b}else b=e[28];let S;e[32]!==b?(S=m.jsx("div",{className:"flex-1 overflow-auto",children:b}),e[32]=b,e[33]=S):S=e[33];let v;return e[34]!==y||e[35]!==x||e[36]!==S?(v=m.jsxs("div",{className:y,children:[x,S]}),e[34]=y,e[35]=x,e[36]=S,e[37]=v):v=e[37],v}function vw(n,e){return n.name.localeCompare(e.name)}function Cw(n){return n.name}function Nw(n){const e=I.c(20),{icon:t,title:r,description:s,isSelected:o,onClick:i}=n,l=o&&"bg-muted/50";let a;e[0]!==l?(a=J("flex items-start gap-2.5 min-h-14 px-5 py-4 cursor-pointer transition-colors","hover:bg-muted/50",l),e[0]=l,e[1]=a):a=e[1];let c;e[2]!==i?(c=y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),i())},e[2]=i,e[3]=c):c=e[3];let d;e[4]!==t||e[5]!==r?(d=m.jsx(js,{icon:t,name:r,size:"xs",className:"shadow-sm mt-0.5"}),e[4]=t,e[5]=r,e[6]=d):d=e[6];let u;e[7]!==r?(u=m.jsx("span",{className:"text-sm font-medium text-foreground truncate block",children:r}),e[7]=r,e[8]=u):u=e[8];let f;e[9]!==s?(f=s&&m.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:s}),e[9]=s,e[10]=f):f=e[10];let h;e[11]!==u||e[12]!==f?(h=m.jsxs("div",{className:"flex-1 min-w-0",children:[u,f]}),e[11]=u,e[12]=f,e[13]=h):h=e[13];let p;return e[14]!==i||e[15]!==a||e[16]!==c||e[17]!==d||e[18]!==h?(p=m.jsxs("div",{className:a,onClick:i,role:"button",tabIndex:0,onKeyDown:c,children:[d,h]}),e[14]=i,e[15]=a,e[16]=c,e[17]=d,e[18]=h,e[19]=p):p=e[19],p}var Ue="Accordion",Ew=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Ll,Tw,Mw]=Ih(Ue),[Zs]=Mc(Ue,[Mw,$c]),$l=$c(),sh=ee.forwardRef((n,e)=>{const{type:t,...r}=n,s=r,o=r;return m.jsx(Ll.Provider,{scope:n.__scopeAccordion,children:t==="multiple"?m.jsx(Rw,{...o,ref:e}):m.jsx(Iw,{...s,ref:e})})});sh.displayName=Ue;var[oh,Aw]=Zs(Ue),[ih,Ow]=Zs(Ue,{collapsible:!1}),Iw=ee.forwardRef((n,e)=>{const{value:t,defaultValue:r,onValueChange:s=()=>{},collapsible:o=!1,...i}=n,[l,a]=Ei({prop:t,defaultProp:r??"",onChange:s,caller:Ue});return m.jsx(oh,{scope:n.__scopeAccordion,value:ee.useMemo(()=>l?[l]:[],[l]),onItemOpen:a,onItemClose:ee.useCallback(()=>o&&a(""),[o,a]),children:m.jsx(ih,{scope:n.__scopeAccordion,collapsible:o,children:m.jsx(lh,{...i,ref:e})})})}),Rw=ee.forwardRef((n,e)=>{const{value:t,defaultValue:r,onValueChange:s=()=>{},...o}=n,[i,l]=Ei({prop:t,defaultProp:r??[],onChange:s,caller:Ue}),a=ee.useCallback(d=>l((u=[])=>[...u,d]),[l]),c=ee.useCallback(d=>l((u=[])=>u.filter(f=>f!==d)),[l]);return m.jsx(oh,{scope:n.__scopeAccordion,value:i,onItemOpen:a,onItemClose:c,children:m.jsx(ih,{scope:n.__scopeAccordion,collapsible:!0,children:m.jsx(lh,{...o,ref:e})})})}),[jw,eo]=Zs(Ue),lh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,disabled:r,dir:s,orientation:o="vertical",...i}=n,l=ee.useRef(null),a=Ic(l,e),c=Tw(t),u=Rh(s)==="ltr",f=Ge(n.onKeyDown,h=>{if(!Ew.includes(h.key))return;const p=h.target,y=c().filter(T=>!T.ref.current?.disabled),g=y.findIndex(T=>T.ref.current===p),x=y.length;if(g===-1)return;h.preventDefault();let b=g;const S=0,v=x-1,k=()=>{b=g+1,b>v&&(b=S)},w=()=>{b=g-1,b<S&&(b=v)};switch(h.key){case"Home":b=S;break;case"End":b=v;break;case"ArrowRight":o==="horizontal"&&(u?k():w());break;case"ArrowDown":o==="vertical"&&k();break;case"ArrowLeft":o==="horizontal"&&(u?w():k());break;case"ArrowUp":o==="vertical"&&w();break}const C=b%x;y[C].ref.current?.focus()});return m.jsx(jw,{scope:t,disabled:r,direction:s,orientation:o,children:m.jsx(Ll.Slot,{scope:t,children:m.jsx(Ni.div,{...i,"data-orientation":o,ref:a,onKeyDown:r?void 0:f})})})}),Rs="AccordionItem",[Dw,zl]=Zs(Rs),ah=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,value:r,...s}=n,o=eo(Rs,t),i=Aw(Rs,t),l=$l(t),a=Oh(),c=r&&i.value.includes(r)||!1,d=o.disabled||n.disabled;return m.jsx(Dw,{scope:t,open:c,disabled:d,triggerId:a,children:m.jsx(ep,{"data-orientation":o.orientation,"data-state":ph(c),...l,...s,ref:e,disabled:d,open:c,onOpenChange:u=>{u?i.onItemOpen(r):i.onItemClose(r)}})})});ah.displayName=Rs;var ch="AccordionHeader",dh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,...r}=n,s=eo(Ue,t),o=zl(ch,t);return m.jsx(Ni.h3,{"data-orientation":s.orientation,"data-state":ph(o.open),"data-disabled":o.disabled?"":void 0,...r,ref:e})});dh.displayName=ch;var vi="AccordionTrigger",uh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,...r}=n,s=eo(Ue,t),o=zl(vi,t),i=Ow(vi,t),l=$l(t);return m.jsx(Ll.ItemSlot,{scope:t,children:m.jsx(np,{"aria-disabled":o.open&&!i.collapsible||void 0,"data-orientation":s.orientation,id:o.triggerId,...l,...r,ref:e})})});uh.displayName=vi;var fh="AccordionContent",hh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,...r}=n,s=eo(Ue,t),o=zl(fh,t),i=$l(t);return m.jsx(tp,{role:"region","aria-labelledby":o.triggerId,"data-orientation":s.orientation,...i,...r,ref:e,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...n.style}})});hh.displayName=fh;function ph(n){return n?"open":"closed"}var Pw=sh,Lw=ah,$w=dh,zw=uh,_w=hh;function Bw(n){const e=I.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=m.jsx(Pw,{"data-slot":"accordion",...t}),e[2]=t,e[3]=r):r=e[3],r}function Fw(n){const e=I.c(8);let t,r;e[0]!==n?({className:t,...r}=n,e[0]=n,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let s;e[3]!==t?(s=J("border-b last:border-b-0",t),e[3]=t,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=m.jsx(Lw,{"data-slot":"accordion-item",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}function Vw(n){const e=I.c(11);let t,r,s;e[0]!==n?({className:r,children:t,...s}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s):(t=e[1],r=e[2],s=e[3]);let o;e[4]!==r?(o=J("focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-center justify-between gap-4 py-4 text-left text-sm font-medium transition-all outline-none hover:bg-accent/50 focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-90",r),e[4]=r,e[5]=o):o=e[5];let i;e[6]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx(mp,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 transition-transform duration-200"}),e[6]=i):i=e[6];let l;return e[7]!==t||e[8]!==s||e[9]!==o?(l=m.jsx($w,{className:"flex",children:m.jsxs(zw,{"data-slot":"accordion-trigger",className:o,...s,children:[t,i]})}),e[7]=t,e[8]=s,e[9]=o,e[10]=l):l=e[10],l}function Hw(n){const e=I.c(12);let t,r,s;e[0]!==n?({className:r,children:t,...s}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s):(t=e[1],r=e[2],s=e[3]);let o;e[4]!==r?(o=J("pt-0 pb-4",r),e[4]=r,e[5]=o):o=e[5];let i;e[6]!==t||e[7]!==o?(i=m.jsx("div",{className:o,children:t}),e[6]=t,e[7]=o,e[8]=i):i=e[8];let l;return e[9]!==s||e[10]!==i?(l=m.jsx(_w,{"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",...s,children:i}),e[9]=s,e[10]=i,e[11]=l):l=e[11],l}var Ww=(n,e,t,r,s,o,i,l)=>{let a=document.documentElement,c=["light","dark"];function d(h){(Array.isArray(n)?n:[n]).forEach(p=>{let y=p==="class",g=y&&o?s.map(x=>o[x]||x):s;y?(a.classList.remove(...g),a.classList.add(o&&o[h]?o[h]:h)):a.setAttribute(p,h)}),u(h)}function u(h){l&&c.includes(h)&&(a.style.colorScheme=h)}function f(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let h=localStorage.getItem(e)||t,p=i&&h==="system"?f():h;d(p)}catch{}};O.createContext(void 0);O.memo(({forcedTheme:n,storageKey:e,attribute:t,enableSystem:r,enableColorScheme:s,defaultTheme:o,value:i,themes:l,nonce:a,scriptProps:c})=>{let d=JSON.stringify([t,e,o,n,l,i,r,s]).slice(1,-1);return O.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?a:"",dangerouslySetInnerHTML:{__html:`(${Ww.toString()})(${d})`}})});function qw(n){const{updateStep:e}=Me(),r=n&&"toolName"in n.action&&"toolName"in n.action?n.action.toolName:null,{tool:s}=_l(r??"");n&&r&&s?.outputSchema&&(!n.outputSchema||Object.keys(n.outputSchema).length===0)&&queueMicrotask(()=>{e(n.name,{outputSchema:s.outputSchema})})}function Uw(n){const e=I.c(25),{className:t}=n,r=hr(),{appendStep:s}=Me();if(qw(r),!r){let f;e[0]!==t?(f=J("flex flex-col h-full bg-sidebar",t),e[0]=t,e[1]=f):f=e[1];let h;e[2]!==s?(h=()=>{s({type:"tool"})},e[2]=s,e[3]=h):h=e[3];let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsx(zc,{size:14}),e[4]=p):p=e[4];let y;e[5]!==h?(y=m.jsxs("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground gap-2 flex-col",children:["Select or create a step to configure",m.jsx(me,{variant:"ghost",size:"icon",className:"size-7",onClick:h,children:p})]}),e[5]=h,e[6]=y):y=e[6];let g;return e[7]!==f||e[8]!==y?(g=m.jsx("div",{className:f,children:y}),e[7]=f,e[8]=y,e[9]=g):g=e[9],g}let o;e[10]!==t?(o=J("flex flex-col h-full bg-sidebar overflow-scroll",t),e[10]=t,e[11]=o):o=e[11];let i,l,a,c,d;e[12]!==r?(i=m.jsx(Kw,{step:r}),l=m.jsx(Gw,{step:r}),a=m.jsx(Xw,{step:r}),c=m.jsx(ev,{step:r}),d=m.jsx(rv,{step:r}),e[12]=r,e[13]=i,e[14]=l,e[15]=a,e[16]=c,e[17]=d):(i=e[13],l=e[14],a=e[15],c=e[16],d=e[17]);let u;return e[18]!==o||e[19]!==i||e[20]!==l||e[21]!==a||e[22]!==c||e[23]!==d?(u=m.jsxs("div",{className:o,children:[i,l,a,c,d]}),e[18]=o,e[19]=i,e[20]=l,e[21]=a,e[22]=c,e[23]=d,e[24]=u):u=e[24],u}function Kw(n){const e=I.c(15),{step:t}=n,s="toolName"in t.action&&"toolName"in t.action?t.action.toolName:null,o=Se(),i=s??"";let l;e[0]!==i?(l=m.jsx(js,{icon:null,name:i,size:"xs",className:"shadow-sm"}),e[0]=i,e[1]=l):l=e[1];let a;e[2]!==s?(a=m.jsx("span",{className:"text-base font-medium text-foreground truncate flex-1",children:s}),e[2]=s,e[3]=a):a=e[3];let c;e[4]!==o?(c=o?null:m.jsx(Jw,{}),e[4]=o,e[5]=c):c=e[5];let d;e[6]!==l||e[7]!==a||e[8]!==c?(d=m.jsxs("div",{className:"flex items-center gap-2",children:[l,a,c]}),e[6]=l,e[7]=a,e[8]=c,e[9]=d):d=e[9];let u;e[10]!==t.description?(u=t.description&&m.jsx("p",{className:"text-sm text-muted-foreground",children:t.description}),e[10]=t.description,e[11]=u):u=e[11];let f;return e[12]!==d||e[13]!==u?(f=m.jsxs("div",{className:"border-b border-border p-5 shrink-0 flex flex-col gap-2",children:[d,u]}),e[12]=d,e[13]=u,e[14]=f):f=e[14],f}function Jw(){const n=I.c(9),e=hr(),{updateStep:t,startReplacingTool:r}=Me(),s=Se(),i=e&&"toolName"in e.action?e.action.toolName:null;let l;n[0]!==e||n[1]!==r||n[2]!==i||n[3]!==s||n[4]!==t?(l=()=>{if(e){if(s){Ec.error("You cannot replace a tool while a workflow is executing.");return}i&&r(i),t(e.name,{action:{...e.action,toolName:""}})}},n[0]=e,n[1]=r,n[2]=i,n[3]=s,n[4]=t,n[5]=l):l=n[5];const a=l;let c;n[6]===Symbol.for("react.memo_cache_sentinel")?(c=m.jsx(Qc,{size:14}),n[6]=c):c=n[6];let d;return n[7]!==a?(d=m.jsx(me,{variant:"ghost",size:"icon",className:"size-7",onClick:a,title:"Replace tool",children:c}),n[7]=a,n[8]=d):d=n[8],d}function _l(n){const e=I.c(13),t=jn();let r;e[0]!==t?(r=t?new URL(`/mcp/gateway/${t}`,window.location.origin).href:"",e[0]=t,e[1]=r):r=e[1];const s=r,o=!!t;let i;e[2]!==s||e[3]!==o?(i={url:s,enabled:o},e[2]=s,e[3]=o,e[4]=i):i=e[4];const l=zi(i);let a;e[5]!==l.tools||e[6]!==n?(a=l.tools?.find(h=>h.name===n),e[5]=l.tools,e[6]=n,e[7]=a):a=e[7];const c=a,d=l.state==="connecting",u=l.state==="ready";let f;return e[8]!==l.error||e[9]!==d||e[10]!==u||e[11]!==c?(f={tool:c,isLoading:d,isReady:u,error:l.error},e[8]=l.error,e[9]=d,e[10]=u,e[11]=c,e[12]=f):f=e[12],f}function Gw(n){const e=I.c(13),{step:t}=n,{updateStep:r}=Me(),o="toolName"in t.action&&"toolName"in t.action?t.action.toolName:null,i=Se(),{tool:l}=_l(o??"");if(!l||!l.inputSchema)return null;let a;e[0]!==t.name||e[1]!==r?(a=x=>{r(t.name,{input:x})},e[0]=t.name,e[1]=r,e[2]=a):a=e[2];const c=a,d=i?"output":"input";let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=m.jsx(Vw,{className:"px-5 py-5",children:m.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Input"})}),e[3]=u):u=e[3];const f=l.inputSchema,h=t.input;let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=[],e[4]=p):p=e[4];let y;e[5]!==c||e[6]!==t.name||e[7]!==f||e[8]!==h?(y=m.jsxs(Fw,{value:"input",className:"border-b-0",children:[u,m.jsx(Hw,{className:"px-5 pt-2",children:m.jsx(rh,{inputSchema:f,inputParams:h,setInputParams:c,mentions:p},t.name)})]}),e[5]=c,e[6]=t.name,e[7]=f,e[8]=h,e[9]=y):y=e[9];let g;return e[10]!==d||e[11]!==y?(g=m.jsx(Bw,{type:"single",collapsible:!0,defaultValue:d,className:"border-b border-border shrink-0",children:y}),e[10]=d,e[11]=y,e[12]=g):g=e[12],g}function Xw(n){const e=I.c(24),{step:t}=n,r=t.outputSchema,[s,o]=O.useState(!1),i=Se(),{item:l}=Pn(i),a=!!(l?.completed_steps?.success?.includes(t.name)||l?.completed_steps?.error?.includes(t.name)),{output:c,error:d}=_m(i,a?t.name:void 0);let u;e[0]!==d||e[1]!==c?(u=c||(d?{error:d}:void 0),e[0]=d,e[1]=c,e[2]=u):u=e[2];const f=u,h=r&&typeof r=="object"?r.properties:void 0;let p;e[3]!==h?(p=h?Object.entries(h):[],e[3]=h,e[4]=p):p=e[4];const y=p,g=s?"flex-1 min-h-0 overflow-hidden":"shrink-0";let x;e[5]!==g?(x=J("flex flex-col border-b border-border",g),e[5]=g,e[6]=x):x=e[6];let b;e[7]!==s?(b=()=>o(!s),e[7]=s,e[8]=b):b=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=m.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Output"}),e[9]=S):S=e[9];let v;e[10]!==s?(v=m.jsxs("div",{className:"flex items-center justify-between",children:[S,s?m.jsx(Wi,{size:14,className:"text-muted-foreground"}):m.jsx(Hi,{size:14,className:"text-muted-foreground"})]}),e[10]=s,e[11]=v):v=e[11];let k;e[12]!==b||e[13]!==v?(k=m.jsx("div",{className:"p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:b,children:v}),e[12]=b,e[13]=v,e[14]=k):k=e[14];let w;e[15]!==f||e[16]!==s||e[17]!==y||e[18]!==i?(w=s&&m.jsxs("div",{className:"flex-1 min-h-0 overflow-auto px-5",children:[i&&f?m.jsx(On,{code:JSON.stringify(f,null,2),language:"json",height:"100%",readOnly:!0}):null,!i&&y.map(Yw)]}),e[15]=f,e[16]=s,e[17]=y,e[18]=i,e[19]=w):w=e[19];let C;return e[20]!==x||e[21]!==k||e[22]!==w?(C=m.jsxs("div",{className:x,children:[k,w]}),e[20]=x,e[21]=k,e[22]=w,e[23]=C):C=e[23],C}function Yw(n){const[e,t]=n;return m.jsx(Zw,{name:e,schema:t},e)}function Qw(n){switch(n){case"string":return{Icon:Uc,color:"text-blue-500"};case"number":case"integer":return{Icon:Wc,color:"text-blue-500"};case"array":return{Icon:Fc,color:"text-purple-500"};case"object":return{Icon:Bc,color:"text-orange-500"};case"boolean":return{Icon:qc,color:"text-pink-500"};case"null":return{Icon:Ti,color:"text-gray-500"};default:return{Icon:Vc,color:"text-muted-foreground"}}}function Zw(n){const e=I.c(28),{name:t,schema:r}=n,s=hr(),o=r.type??"unknown";let i,l,a,c,d;if(e[0]!==o){const{Icon:v,color:k}=Qw(o);d="flex items-center gap-2",c="flex-1 flex items-center gap-2",i=v,l=14,a=J(k),e[0]=o,e[1]=i,e[2]=l,e[3]=a,e[4]=c,e[5]=d}else i=e[1],l=e[2],a=e[3],c=e[4],d=e[5];let u;e[6]!==i||e[7]!==l||e[8]!==a?(u=m.jsx(i,{size:l,className:a}),e[6]=i,e[7]=l,e[8]=a,e[9]=u):u=e[9];let f;e[10]!==t?(f=m.jsx("span",{className:"text-sm font-medium text-foreground",children:t}),e[10]=t,e[11]=f):f=e[11];let h;e[12]!==c||e[13]!==u||e[14]!==f?(h=m.jsxs("div",{className:c,children:[u,f]}),e[12]=c,e[13]=u,e[14]=f,e[15]=h):h=e[15];let p;e[16]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsx(Xc,{size:14,className:"opacity-50"}),e[16]=p):p=e[16];const y=s?.name;let g;e[17]!==y?(g=m.jsxs("span",{className:"text-muted-foreground",children:[y,"."]}),e[17]=y,e[18]=g):g=e[18];let x;e[19]!==t?(x=m.jsx("div",{className:"bg-blue-500/10 text-blue-500 px-1 py-0.5 rounded",children:t}),e[19]=t,e[20]=x):x=e[20];let b;e[21]!==g||e[22]!==x?(b=m.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[p,g,x]}),e[21]=g,e[22]=x,e[23]=b):b=e[23];let S;return e[24]!==b||e[25]!==d||e[26]!==h?(S=m.jsxs("div",{className:d,children:[h,b]}),e[24]=b,e[25]=d,e[26]=h,e[27]=S):S=e[27],S}function ev(n){const e=I.c(29),{step:t}=n,{updateStep:r}=Me(),s=Se(),[o,i]=O.useState(!1),l="toolName"in t.action,a=l&&"toolName"in t.action?t.action.toolName:null,{tool:c}=_l(a??""),d=l&&"transformCode"in t.action?t.action.transformCode??null:null;let u;e[0]!==c?(u=()=>{if(!c?.outputSchema)return`interface Input {
|
|
144
|
+
`),[o,i]=Mk(s);if(o.length===0)return;const l=zf(o,0,t);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=o[0])==null?void 0:r.number)||1,items:l,raw:s.slice(0,i).join(`
|
|
145
|
+
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Ok,this.editor.getAttributes(xc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=An({find:bc,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=An({find:bc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(xc)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),Ik=/^\s*(\[([( |x])?\])\s$/,Rk=Ie.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:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",ne(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{const t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){const r=e.parseChildren(n.nestedTokens);t.push(...r)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;const s=`- [${(t=n.attrs)!=null&&t.checked?"x":" "}] `;return wl(n,e,s)},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const s=document.createElement("li"),o=document.createElement("label"),i=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=u=>{var f,h;l.ariaLabel=((h=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:h.call(f,u,l.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};c(n),o.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",u=>u.preventDefault()),l.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=u.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const p=t();if(typeof p!="number")return!1;const y=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...y?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,f])=>{s.setAttribute(u,f)}),s.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,o.append(l,i),s.append(o,a),Object.entries(e).forEach(([u,f])=>{s.setAttribute(u,f)});let d=new Set(Object.keys(e));return{dom:s,contentDOM:a,update:u=>{if(u.type!==this.type)return!1;s.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(u);const f=r.extensionManager.attributes,h=Tn(u,f),p=new Set(Object.keys(h)),y=this.options.HTMLAttributes;return d.forEach(g=>{p.has(g)||(g in y?s.setAttribute(g,y[g]):s.removeAttribute(g))}),Object.entries(h).forEach(([g,x])=>{x==null?g in y?s.setAttribute(g,y[g]):s.removeAttribute(g):s.setAttribute(g,x)}),d=p,!0}}}},addInputRules(){return[An({find:Ik,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),jk=Ie.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:n}){return["ul",ne(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
|
|
146
|
+
`):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const r=o=>{const i=ui(o,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},t);return i?[{type:"taskList",raw:i.raw,items:i.items}]:t.blockTokens(o)},s=ui(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,i)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:t.inlineTokens(o.mainContent),nestedTokens:i}),customNestedParser:r},t);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ce.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(Of.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(If.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push($f.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(_f.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(Rk.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(jk.configure(this.options.taskList)),n}});var Dk=Ie.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",ne(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];return t.length===1&&t[0].type==="image"?e.parseChildren([t[0]]):e.createNode("paragraph",void 0,e.parseInline(t))},renderMarkdown:(n,e)=>!n||!Array.isArray(n.content)?"":e.renderChildren(n.content),addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Pk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Lk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,$k=Zt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",ne(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Mn({find:Pk,type:this.type})]},addPasteRules(){return[Xt({find:Lk,type:this.type})]}}),zk=Ie.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),_k=Zt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",ne(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!s)return;const o=s[2].trim();return{type:"underline",raw:s[0],text:o,tokens:t.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function Bk(n={}){return new re({view(e){return new Fk(e,n)}})}class Fk{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let o=i=>{this[s](i)};return e.dom.addEventListener(s,o),{name:s,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.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),t=!e.parent.inlineContent,r,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(t){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let h=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(h){let p=h.getBoundingClientRect(),y=u?p.bottom:p.top;u&&f&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:y-g,bottom:y+g}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;r={left:u.left-f,right:u.left+f,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.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",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),f=u.width/a.offsetWidth,h=u.height/a.offsetHeight;c=u.left-a.scrollLeft*f,d=u.top-a.scrollTop*h}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!o){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Pd(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class ie extends q{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return ie.valid(r)?new ie(r):q.near(r)}content(){return R.empty}eq(e){return e instanceof ie&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ie(e.resolve(t.pos))}getBookmark(){return new jl(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Vk(e)||!Hk(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&ie.valid(e))return e;let s=e.pos,o=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){o=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;s+=t;let a=e.doc.resolve(s);if(ie.valid(a))return a}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!$.isSelectable(o)){e=e.doc.resolve(s+o.nodeSize*t),r=!1;continue e}break}o=i,s+=t;let l=e.doc.resolve(s);if(ie.valid(l))return l}return null}}}ie.prototype.visible=!1;ie.findFrom=ie.findGapCursorFrom;q.jsonID("gapcursor",ie);class jl{constructor(e){this.pos=e}map(e){return new jl(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ie.valid(t)?new ie(t):q.near(t)}}function Bf(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function Vk(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Bf(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Hk(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Bf(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Wk(){return new re({props:{decorations:Jk,createSelectionBetween(n,e,t){return e.pos==t.pos&&ie.valid(t)?new ie(t):null},handleClick:Uk,handleKeyDown:qk,handleDOMEvents:{beforeinput:Kk}}})}const qk=Lu({ArrowLeft:Rr("horiz",-1),ArrowRight:Rr("horiz",1),ArrowUp:Rr("vert",-1),ArrowDown:Rr("vert",1)});function Rr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,o){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof F){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ie.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new ie(c))),!0):!1}}function Uk(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!ie.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&$.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ie(r))),!0)}function Kk(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ie))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=E.empty;for(let i=r.length-1;i>=0;i--)s=E.from(r[i].createAndFill(null,s));let o=n.state.tr.replace(t.pos,t.pos,new R(s,0,0));return o.setSelection(F.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function Jk(n){if(!(n.selection instanceof ie))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",te.create(n.doc,[Ce.widget(n.selection.head,e,{key:"gapcursor"})])}var As=200,ye=function(){};ye.prototype.append=function(e){return e.length?(e=ye.from(e),!this.length&&e||e.length<As&&this.leafAppend(e)||this.length<As&&e.leafPrepend(this)||this.appendInner(e)):this};ye.prototype.prepend=function(e){return e.length?ye.from(e).append(this):this};ye.prototype.appendInner=function(e){return new Gk(this,e)};ye.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?ye.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};ye.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ye.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};ye.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(o,i){return s.push(e(o,i))},t,r),s};ye.from=function(e){return e instanceof ye?e:e&&e.length?new Ff(e):ye.empty};var Ff=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,o){return s==0&&o==this.length?this:new e(this.values.slice(s,o))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,o,i,l){for(var a=o;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,l){for(var a=o-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=As)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=As)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(ye);ye.empty=new Ff([]);var Gk=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.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,s,o,i){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(o,l),i)===!1||o>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,o)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(o,l)-l,i+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(s,l),o,i)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var o=this.left.length;return s<=o?this.left.slice(r,s):r>=o?this.right.slice(r-o,s-o):this.left.slice(r,o).append(this.right.slice(0,s-o))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,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})(ye);const Xk=500;class Ve{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,o;t&&(s=this.remapping(r,this.items.length),o=s.maps.length);let i=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){s||(s=this.remapping(r,f+1),o=s.maps.length),o--,d.push(u);return}if(s){d.push(new dt(u.map));let h=u.step.map(s.slice(o)),p;h&&i.maybeStep(h).doc&&(p=i.mapping.maps[i.mapping.maps.length-1],c.push(new dt(p,void 0,void 0,c.length+d.length))),o--,p&&s.appendMap(p,o)}else i.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(o)):u.selection,a=new Ve(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,r,s){let o=[],i=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),f=new dt(e.mapping.maps[d],u,t),h;(h=a&&a.merge(f))&&(f=h,d?o.pop():l=l.slice(0,l.length-1)),o.push(f),t&&(i++,t=void 0),s||(a=f)}let c=i-r.depth;return c>Qk&&(l=Yk(l,c),i-=c),new Ve(l.append(o),i)}remapping(e,t){let r=new sr;return this.items.forEach((s,o)=>{let i=s.mirrorOffset!=null&&o-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,i)},e,t),r}addMaps(e){return this.eventCount==0?this:new Ve(this.items.append(e.map(t=>new dt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=o.getMirror(--a);if(h==null)return;i=Math.min(i,h);let p=o.maps[h];if(f.step){let y=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(o.slice(a+1,h));g&&l++,r.push(new dt(p,y,g))}else r.push(new dt(p))},s);let c=[];for(let f=t;f<i;f++)c.push(new dt(o.maps[f]));let d=this.items.slice(0,s).append(c).append(r),u=new Ve(d,l);return u.emptyItemCount()>Xk&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],o=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&o++;else if(i.step){let a=i.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let d=i.selection&&i.selection.map(t.slice(r));d&&o++;let u=new dt(c.invert(),a,d),f,h=s.length-1;(f=s.length&&s[h].merge(u))?s[h]=f:s.push(u)}}else i.map&&r--},this.items.length,0),new Ve(ye.from(s.reverse()),o)}}Ve.empty=new Ve(ye.empty,0);function Yk(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}let dt=class Vf{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Vf(t.getMap().invert(),t,this.selection)}}};class pt{constructor(e,t,r,s,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=o}}const Qk=20;function Zk(n,e,t,r){let s=t.getMeta(Wt),o;if(s)return s.historyState;t.getMeta(nS)&&(n=new pt(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(Wt))return i.getMeta(Wt).redo?new pt(n.done.addTransform(t,void 0,r,zr(e)),n.undone,kc(t.mapping.maps),n.prevTime,n.prevComposition):new pt(n.done,n.undone.addTransform(t,void 0,r,zr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!eS(t,n.prevRanges)),c=i?zo(n.prevRanges,t.mapping):kc(t.mapping.maps);return new pt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,zr(e)),Ve.empty,c,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new pt(n.done.rebased(t,o),n.undone.rebased(t,o),zo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new pt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),zo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function eS(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&s>=e[o]&&(t=!0)}),t}function kc(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,o,i)=>e.push(o,i));return e}function zo(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),o=e.map(n[r+1],-1);s<=o&&t.push(s,o)}return t}function tS(n,e,t){let r=zr(e),s=Wt.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let i=o.selection.resolve(o.transform.doc),l=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),s,r),a=new pt(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta(Wt,{redo:t,historyState:a})}let _o=!1,Sc=null;function zr(n){let e=n.plugins;if(Sc!=e){_o=!1,Sc=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){_o=!0;break}}return _o}const Wt=new ae("history"),nS=new ae("closeHistory");function rS(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new re({key:Wt,state:{init(){return new pt(Ve.empty,Ve.empty,null,0,-1)},apply(e,t,r){return Zk(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?Wf:r=="historyRedo"?qf:null;return!s||!e.editable?!1:(t.preventDefault(),s(e.state,e.dispatch))}}}})}function Hf(n,e){return(t,r)=>{let s=Wt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let o=tS(s,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}const Wf=Hf(!1,!0),qf=Hf(!0,!0);ce.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.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=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new re({key:new ae("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const s=this.options.limit;if(s==null||s===0){n=!0;return}const o=this.storage.characters({node:r.doc});if(o>s){const i=o-s,l=0,a=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:t.doc}),o=this.storage.characters({node:e.doc});if(o<=r||s>r&&o>r&&o<=s)return!0;if(s>r&&o>r&&o>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=o-r,c=l-a,d=l;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>r)}})]}});var sS=ce.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Bk(this.options)]}});ce.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new re({key:new ae("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:s}=e,o=[];if(!t||!r)return te.create(n,[]);let i=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;i+=1});let l=0;return n.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&i-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";o.push(Ce.node(c,c+a.nodeSize,{class:this.options.className}))}),te.create(n,o)}}})]}});var oS=ce.create({name:"gapCursor",addProseMirrorPlugins(){return[Wk()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=G(L(n,"allowGapCursor",t)))!=null?e:null}}});ce.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new re({key:new ae("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(!t)return null;const o=this.editor.isEmpty;return n.descendants((i,l)=>{const a=r>=l&&r<=l+i.nodeSize,c=!i.isLeaf&&Us(i);if((a||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);const u=Ce.node(l,l+i.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:i,pos:l,hasAnchor:a}):this.options.placeholder});s.push(u)}return this.options.includeChildren}),te.create(n,s)}}})]}});ce.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new re({key:new ae("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||Qu(t.selection)||n.view.dragging?null:te.create(t.doc,[Ce.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function wc({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var iS=ce.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new ae(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(t).includes(s.name));return[new re({key:e,appendTransaction:(s,o,i)=>{const{doc:l,tr:a,schema:c}=i,d=e.getState(i),u=l.content.size,f=c.nodes[t];if(d)return a.insert(u,f.create())},state:{init:(s,o)=>{const i=o.tr.doc.lastChild;return!wc({node:i,types:r})},apply:(s,o)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return o;const i=s.doc.lastChild;return!wc({node:i,types:r})}}})]}}),lS=ce.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Wf(n,e),redo:()=>({state:n,dispatch:e})=>qf(n,e)}},addProseMirrorPlugins(){return[rS(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()}}}),aS=ce.create({name:"starterKit",addExtensions(){var n,e,t,r;const s=[];return this.options.bold!==!1&&s.push(Pb.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(Ob.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(Of.configure(this.options.bulletList)),this.options.code!==!1&&s.push(zb.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(Fb.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(Vb.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(sS.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(oS.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(Hb.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(Wb.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(lS.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(qb.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(Xb.configure(this.options.italic)),this.options.listItem!==!1&&s.push(If.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push($f.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&s.push(Sk.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(_f.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(Dk.configure(this.options.paragraph)),this.options.strike!==!1&&s.push($k.configure(this.options.strike)),this.options.text!==!1&&s.push(zk.configure(this.options.text)),this.options.underline!==!1&&s.push(_k.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&s.push(iS.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),cS=aS;function dS(n){var e;const{char:t,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:l}=n,a=r&&!s,c=tb(t),d=new RegExp(`\\s${c}$`),u=i?"^":"",f=s?"":c,h=a?new RegExp(`${u}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${u}(?:^)?${c}[^\\s${f}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const y=l.pos-p.length,g=Array.from(p.matchAll(h)).pop();if(!g||g.input===void 0||g.index===void 0)return null;const x=g.input.slice(Math.max(0,g.index-1),g.index),b=new RegExp(`^[${o?.join("")}\0]?$`).test(x);if(o!==null&&!b)return null;const S=y+g.index;let v=S+g[0].length;return a&&d.test(p.slice(v-1,v+1))&&(g[0]+=" ",v+=1),S<l.pos&&v>=l.pos?{range:{from:S,to:v},query:g[0].slice(t.length),text:g[0]}:null}var uS=new ae("suggestion");function fS({pluginKey:n=uS,editor:e,char:t="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:o=[" "],startOfLine:i=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:d="is-empty",command:u=()=>null,items:f=()=>[],render:h=()=>({}),allow:p=()=>!0,findSuggestionMatch:y=dS,shouldShow:g}){let x;const b=h?.(),S=()=>{const C=e.state.selection.$anchor.pos,T=e.view.coordsAtPos(C),{top:A,right:D,bottom:j,left:_}=T;try{return new DOMRect(_,A,D-_,j-A)}catch{return null}},v=(C,T)=>T?()=>{const A=n.getState(e.state),D=A?.decorationId,j=C.dom.querySelector(`[data-decoration-id="${D}"]`);return j?.getBoundingClientRect()||null}:S;function k(C,T){var A;try{const j=n.getState(C.state),_=j?.decorationId?C.dom.querySelector(`[data-decoration-id="${j.decorationId}"]`):null,V={editor:e,range:j?.range||{from:0,to:0},query:j?.query||null,text:j?.text||null,items:[],command:B=>u({editor:e,range:j?.range||{from:0,to:0},props:B}),decorationNode:_,clientRect:v(C,_)};(A=b?.onExit)==null||A.call(b,V)}catch{}const D=C.state.tr.setMeta(T,{exit:!0});C.dispatch(D)}const w=new re({key:n,view(){return{update:async(C,T)=>{var A,D,j,_,V,B,H;const N=(A=this.key)==null?void 0:A.getState(T),z=(D=this.key)==null?void 0:D.getState(C.state),P=N.active&&z.active&&N.range.from!==z.range.from,K=!N.active&&z.active,Q=N.active&&!z.active,le=!K&&!Q&&N.query!==z.query,X=K||P&&le,fe=le||P,se=Q||P&≤if(!X&&!fe&&!se)return;const J=se&&!X?N:z,Fe=C.dom.querySelector(`[data-decoration-id="${J.decorationId}"]`);x={editor:e,range:J.range,query:J.query,text:J.text,items:[],command:at=>u({editor:e,range:J.range,props:at}),decorationNode:Fe,clientRect:v(C,Fe)},X&&((j=b?.onBeforeStart)==null||j.call(b,x)),fe&&((_=b?.onBeforeUpdate)==null||_.call(b,x)),(fe||X)&&(x.items=await f({editor:e,query:J.query})),se&&((V=b?.onExit)==null||V.call(b,x)),fe&&((B=b?.onUpdate)==null||B.call(b,x)),X&&((H=b?.onStart)==null||H.call(b,x))},destroy:()=>{var C;x&&((C=b?.onExit)==null||C.call(b,x))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(C,T,A,D){const{isEditable:j}=e,{composing:_}=e.view,{selection:V}=C,{empty:B,from:H}=V,N={...T},z=C.getMeta(n);if(z&&z.exit)return N.active=!1,N.decorationId=null,N.range={from:0,to:0},N.query=null,N.text=null,N;if(N.composing=_,j&&(B||e.view.composing)){(H<T.range.from||H>T.range.to)&&!_&&!T.composing&&(N.active=!1);const P=y({char:t,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:V.$from}),K=`id_${Math.floor(Math.random()*4294967295)}`;P&&p({editor:e,state:D,range:P.range,isActive:T.active})&&(!g||g({editor:e,range:P.range,query:P.query,text:P.text,transaction:C}))?(N.active=!0,N.decorationId=T.decorationId?T.decorationId:K,N.range=P.range,N.query=P.query,N.text=P.text):N.active=!1}else N.active=!1;return N.active||(N.decorationId=null,N.range={from:0,to:0},N.query=null,N.text=null),N}},props:{handleKeyDown(C,T){var A,D,j,_;const{active:V,range:B}=w.getState(C.state);if(!V)return!1;if(T.key==="Escape"||T.key==="Esc"){const N=w.getState(C.state),z=(A=x?.decorationNode)!=null?A:null,P=z??(N?.decorationId?C.dom.querySelector(`[data-decoration-id="${N.decorationId}"]`):null);if(((D=b?.onKeyDown)==null?void 0:D.call(b,{view:C,event:T,range:N.range}))||!1)return!0;const Q={editor:e,range:N.range,query:N.query,text:N.text,items:[],command:le=>u({editor:e,range:N.range,props:le}),decorationNode:P,clientRect:P?()=>P.getBoundingClientRect()||null:null};return(j=b?.onExit)==null||j.call(b,Q),k(C,n),!0}return((_=b?.onKeyDown)==null?void 0:_.call(b,{view:C,event:T,range:B}))||!1},decorations(C){const{active:T,range:A,decorationId:D,query:j}=w.getState(C);if(!T)return null;const _=!j?.length,V=[a];return _&&V.push(d),te.create(C.doc,[Ce.inline(A.from,A.to,{nodeName:l,class:V.join(" "),"data-decoration-id":D,"data-decoration-content":c})])}}});return w}function hS({editor:n,overrideSuggestionOptions:e,extensionName:t,char:r="@"}){const s=new ae;return{editor:n,char:r,pluginKey:s,command:({editor:o,range:i,props:l})=>{var a,c,d;const u=o.view.state.selection.$to.nodeAfter;(a=u?.text)!=null&&a.startsWith(" ")&&(i.to+=1),o.chain().focus().insertContentAt(i,[{type:t,attrs:{...l,mentionSuggestionChar:r}},{type:"text",text:" "}]).run(),(d=(c=o.view.dom.ownerDocument.defaultView)==null?void 0:c.getSelection())==null||d.collapseToEnd()},allow:({state:o,range:i})=>{const l=o.doc.resolve(i.from),a=o.schema.nodes[t];return!!l.parent.type.contentMatch.matchType(a)},...e}}function Uf(n){return(n.options.suggestions.length?n.options.suggestions:[n.options.suggestion]).map(e=>hS({editor:n.editor,overrideSuggestionOptions:e,extensionName:n.name,char:e.char}))}function vc(n,e){const t=Uf(n),r=t.find(s=>s.char===e);return r||(t.length?t[0]:null)}var pS=Ie.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:n,suggestion:e}){var t,r;return`${(t=e?.char)!=null?t:"@"}${(r=n.attrs.label)!=null?r:n.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:n,node:e,suggestion:t}){var r,s;return["span",ne(this.HTMLAttributes,n.HTMLAttributes),`${(r=t?.char)!=null?r:"@"}${(s=e.attrs.label)!=null?s:e.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id"),renderHTML:n=>n.id?{"data-id":n.id}:{}},label:{default:null,parseHTML:n=>n.getAttribute("data-label"),renderHTML:n=>n.label?{"data-label":n.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:n=>n.getAttribute("data-mention-suggestion-char"),renderHTML:n=>({"data-mention-suggestion-char":n.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:n,HTMLAttributes:e}){const t=vc(this,n.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",ne({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:n,suggestion:t})];const r={...this.options};r.HTMLAttributes=ne({"data-type":this.name},this.options.HTMLAttributes,e);const s=this.options.renderHTML({options:r,node:n,suggestion:t});return typeof s=="string"?["span",ne({"data-type":this.name},this.options.HTMLAttributes,e),s]:s},...gf({nodeName:"mention",name:"@",selfClosing:!0,allowedAttributes:["id","label",{name:"mentionSuggestionChar",skipIfDefault:"@"}],parseAttributes:n=>{const e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=t.exec(n);for(;r!==null;){const[,s,o,i]=r,l=o??i;e[s==="char"?"mentionSuggestionChar":s]=l,r=t.exec(n)}return e},serializeAttributes:n=>Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${e==="mentionSuggestionChar"?"char":e}="${t}"`).join(" ")}),renderText({node:n}){const e={options:this.options,node:n,suggestion:vc(this,n.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel(e)):this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:n,state:e})=>{let t=!1;const{selection:r}=e,{empty:s,anchor:o}=r;if(!s)return!1;let i=new ze,l=0;return e.doc.nodesBetween(o-1,o,(a,c)=>{if(a.type.name===this.name)return t=!0,i=a,l=c,!1}),t&&n.insertText(this.options.deleteTriggerWithBackspace?"":i.attrs.mentionSuggestionChar,l,l+i.nodeSize),t})}},addProseMirrorPlugins(){return Uf(this).map(fS)}}),mS=pS,Bo,Xs="HoverCard",[Kf]=Mc(Xs,[Ac]),Ys=Ac(),[gS,Qs]=Kf(Xs),Jf=n=>{const{__scopeHoverCard:e,children:t,open:r,defaultOpen:s,onOpenChange:o,openDelay:i=700,closeDelay:l=300}=n,a=Ys(e),c=O.useRef(0),d=O.useRef(0),u=O.useRef(!1),f=O.useRef(!1),[h,p]=Ei({prop:r,defaultProp:s??!1,onChange:o,caller:Xs}),y=O.useCallback(()=>{clearTimeout(d.current),c.current=window.setTimeout(()=>p(!0),i)},[i,p]),g=O.useCallback(()=>{clearTimeout(c.current),!u.current&&!f.current&&(d.current=window.setTimeout(()=>p(!1),l))},[l,p]),x=O.useCallback(()=>p(!1),[p]);return O.useEffect(()=>()=>{clearTimeout(c.current),clearTimeout(d.current)},[]),m.jsx(gS,{scope:e,open:h,onOpenChange:p,onOpen:y,onClose:g,onDismiss:x,hasSelectionRef:u,isPointerDownOnContentRef:f,children:m.jsx(Nh,{...a,children:t})})};Jf.displayName=Xs;var Gf="HoverCardTrigger",Xf=O.forwardRef((n,e)=>{const{__scopeHoverCard:t,...r}=n,s=Qs(Gf,t),o=Ys(t);return m.jsx(vh,{asChild:!0,...o,children:m.jsx(Ni.a,{"data-state":s.open?"open":"closed",...r,ref:e,onPointerEnter:Ge(n.onPointerEnter,Is(s.onOpen)),onPointerLeave:Ge(n.onPointerLeave,Is(s.onClose)),onFocus:Ge(n.onFocus,s.onOpen),onBlur:Ge(n.onBlur,s.onClose),onTouchStart:Ge(n.onTouchStart,i=>i.preventDefault())})})});Xf.displayName=Gf;var Dl="HoverCardPortal",[yS,xS]=Kf(Dl,{forceMount:void 0}),Yf=n=>{const{__scopeHoverCard:e,forceMount:t,children:r,container:s}=n,o=Qs(Dl,e);return m.jsx(yS,{scope:e,forceMount:t,children:m.jsx(Oc,{present:t||o.open,children:m.jsx(Ch,{asChild:!0,container:s,children:r})})})};Yf.displayName=Dl;var Os="HoverCardContent",Qf=O.forwardRef((n,e)=>{const t=xS(Os,n.__scopeHoverCard),{forceMount:r=t.forceMount,...s}=n,o=Qs(Os,n.__scopeHoverCard);return m.jsx(Oc,{present:r||o.open,children:m.jsx(bS,{"data-state":o.open?"open":"closed",...s,onPointerEnter:Ge(n.onPointerEnter,Is(o.onOpen)),onPointerLeave:Ge(n.onPointerLeave,Is(o.onClose)),ref:e})})});Qf.displayName=Os;var bS=O.forwardRef((n,e)=>{const{__scopeHoverCard:t,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:i,...l}=n,a=Qs(Os,t),c=Ys(t),d=O.useRef(null),u=Ic(e,d),[f,h]=O.useState(!1);return O.useEffect(()=>{if(f){const p=document.body;return Bo=p.style.userSelect||p.style.webkitUserSelect,p.style.userSelect="none",p.style.webkitUserSelect="none",()=>{p.style.userSelect=Bo,p.style.webkitUserSelect=Bo}}},[f]),O.useEffect(()=>{if(d.current){const p=()=>{h(!1),a.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(a.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",p),()=>{document.removeEventListener("pointerup",p),a.hasSelectionRef.current=!1,a.isPointerDownOnContentRef.current=!1}}},[a.isPointerDownOnContentRef,a.hasSelectionRef]),O.useEffect(()=>{d.current&&wS(d.current).forEach(y=>y.setAttribute("tabindex","-1"))}),m.jsx(Eh,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:i,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:Ge(o,p=>{p.preventDefault()}),onDismiss:a.onDismiss,children:m.jsx(Th,{...c,...l,onPointerDown:Ge(l.onPointerDown,p=>{p.currentTarget.contains(p.target)&&h(!0),a.hasSelectionRef.current=!1,a.isPointerDownOnContentRef.current=!0}),ref:u,style:{...l.style,userSelect:f?"text":void 0,WebkitUserSelect:f?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})}),kS="HoverCardArrow",SS=O.forwardRef((n,e)=>{const{__scopeHoverCard:t,...r}=n,s=Ys(t);return m.jsx(Mh,{...s,...r,ref:e})});SS.displayName=kS;function Is(n){return e=>e.pointerType==="touch"?void 0:n()}function wS(n){const e=[],t=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;t.nextNode();)e.push(t.currentNode);return e}var vS=Jf,CS=Xf,NS=Yf,ES=Qf;function TS(n){const e=I.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=m.jsx(vS,{"data-slot":"hover-card",...t}),e[2]=t,e[3]=r):r=e[3],r}function MS(n){const e=I.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=m.jsx(CS,{"data-slot":"hover-card-trigger",...t}),e[2]=t,e[3]=r):r=e[3],r}function AS(n){const e=I.c(12);let t,r,s,o;e[0]!==n?({className:t,align:s,sideOffset:o,...r}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=o):(t=e[1],r=e[2],s=e[3],o=e[4]);const i=s===void 0?"center":s,l=o===void 0?4:o;let a;e[5]!==t?(a=U("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),e[5]=t,e[6]=a):a=e[6];let c;return e[7]!==i||e[8]!==r||e[9]!==l||e[10]!==a?(c=m.jsx(NS,{"data-slot":"hover-card-portal",children:m.jsx(ES,{"data-slot":"hover-card-content",align:i,sideOffset:l,className:a,...r})}),e[7]=i,e[8]=r,e[9]=l,e[10]=a,e[11]=c):c=e[11],c}const Zf=O.createContext(void 0);function OS(n,e){const t=e.split("."),r=t[0];if(!r)return;let s=n[r];for(let o=1;o<t.length&&s!==void 0;o++){const i=t[o];if(i)if(typeof s=="object"&&s!==null)s=s[i];else return}return s}function IS(n){const e=I.c(20),{node:t}=n,r=O.useContext(Zf),s=t.attrs.id??"",o=r!==void 0;let i;if(e[0]!==o||e[1]!==s||e[2]!==r){const y=o?OS(r,s):void 0;i=y!==void 0?typeof y=="object"?JSON.stringify(y,null,2):String(y):void 0,e[0]=o,e[1]=s,e[2]=r,e[3]=i}else i=e[3];const l=i;let a;e[4]!==s?(a=m.jsxs("span",{className:"bg-primary/20 text-primary px-1 rounded font-medium cursor-pointer",children:["@",s]}),e[4]=s,e[5]=a):a=e[5];const c=a;if(!o||l===void 0){let y;return e[6]!==c?(y=m.jsx(oc,{as:"span",children:c}),e[6]=c,e[7]=y):y=e[7],y}let d;e[8]!==c?(d=m.jsx(MS,{asChild:!0,children:c}),e[8]=c,e[9]=d):d=e[9];let u;e[10]!==s?(u=m.jsxs("div",{className:"text-xs font-medium text-muted-foreground",children:["@",s]}),e[10]=s,e[11]=u):u=e[11];let f;e[12]!==l?(f=m.jsx("pre",{className:"text-xs font-mono bg-muted/50 p-2 rounded overflow-auto max-h-[200px] whitespace-pre-wrap break-all",children:l}),e[12]=l,e[13]=f):f=e[13];let h;e[14]!==u||e[15]!==f?(h=m.jsx(AS,{className:"w-auto max-w-[400px] p-3",side:"top",align:"start",children:m.jsxs("div",{className:"space-y-1.5",children:[u,f]})}),e[14]=u,e[15]=f,e[16]=h):h=e[16];let p;return e[17]!==d||e[18]!==h?(p=m.jsx(oc,{as:"span",children:m.jsxs(TS,{openDelay:200,children:[d,h]})}),e[17]=d,e[18]=h,e[19]=p):p=e[19],p}function eh(n){const e=[];function t(r){for(const s of r)s.children?.length||e.push(s),s.children&&t(s.children)}return t(n),e}let Xe=th();function th(){return Ki(()=>({items:[],selectedIndex:0,command:null}))}function Cc(n,e){Xe.setState({items:n,command:e,selectedIndex:0})}function RS(){const{items:n,selectedIndex:e}=Xe.getState();n.length&&Xe.setState({selectedIndex:(e-1+n.length)%n.length})}function jS(){const{items:n,selectedIndex:e}=Xe.getState();n.length&&Xe.setState({selectedIndex:(e+1)%n.length})}function nh(){const{items:n,selectedIndex:e,command:t}=Xe.getState(),r=n[e];return r?(t?.(r),!0):!1}function Nc(){Xe=th()}function DS(){const n=I.c(7),e=Wo(Xe,LS),t=Wo(Xe,PS);if(!e.length)return null;let r;if(n[0]!==e||n[1]!==t){let o;n[3]!==t?(o=(i,l)=>m.jsx("button",{type:"button",onClick:()=>{Xe.setState({selectedIndex:l}),nh()},className:U("flex items-center w-full text-left px-3 py-1.5 text-sm rounded-md transition-colors",l===t?"bg-accent text-accent-foreground":"hover:bg-muted"),children:i.label},i.id),n[3]=t,n[4]=o):o=n[4],r=e.map(o),n[0]=e,n[1]=t,n[2]=r}else r=n[2];let s;return n[5]!==r?(s=m.jsx("div",{className:"bg-popover border border-border rounded-lg shadow-lg overflow-hidden min-w-[180px]",children:m.jsx("div",{className:"p-1",children:r})}),n[5]=r,n[6]=s):s=n[6],s}function PS(n){return n.selectedIndex}function LS(n){return n.items}function $S(){let n=null,e=null;return{onStart:t=>{Cc(t.items,t.command),n=new kf(DS,{editor:t.editor}),e=document.createElement("div"),e.style.cssText="position:absolute;z-index:9999";const r=t.clientRect?.();r&&(e.style.top=`${r.bottom+window.scrollY+4}px`,e.style.left=`${r.left+window.scrollX}px`),e.appendChild(n.element),document.body.appendChild(e)},onUpdate:t=>{Cc(t.items,t.command);const r=t.clientRect?.();r&&e&&(e.style.top=`${r.bottom+window.scrollY+4}px`,e.style.left=`${r.left+window.scrollX}px`)},onKeyDown:({event:t})=>t.key==="Escape"?(e?.remove(),n?.destroy(),Nc(),!0):t.key==="ArrowUp"?(RS(),!0):t.key==="ArrowDown"?(jS(),!0):t.key==="Enter"?nh():!1,onExit:()=>{e?.remove(),n?.destroy(),Nc()}}}const Fo=/@([\w.]+)/g;function zS(n,e){if(!n)return null;const t=eh(e),r=new Map(t.map(a=>[a.id,a]));if(!Fo.test(n))return n;Fo.lastIndex=0;const o=[];let i=0,l;for(;(l=Fo.exec(n))!==null;){const a=l[1]??"",c=l.index;c>i&&o.push({type:"text",text:n.slice(i,c)});const d=r.get(a);d?o.push({type:"mention",attrs:{id:d.id,label:d.label}}):o.push({type:"text",text:l[0]}),i=c+l[0].length}return i<n.length&&o.push({type:"text",text:n.slice(i)}),{type:"doc",content:[{type:"paragraph",content:o.length>0?o:void 0}]}}function Pl(n){const e=I.c(31),{mentions:t,value:r,onChange:s,placeholder:o,className:i,readOnly:l}=n,a=tg();let c;e[0]!==t||e[1]!==r?(c=zS(r,t),e[0]=t,e[1]=r,e[2]=c):c=e[2];const d=c,u=a!==void 0,f=!l;let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=cS.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,hardBreak:!1}),e[3]=h):h=e[3];let p;if(e[4]!==t||e[5]!==u){let A;e[7]!==t?(A=D=>{const{query:j}=D;return eh(t).filter(V=>V.label.toLowerCase().includes(j.toLowerCase())||V.id.toLowerCase().includes(j.toLowerCase()))},e[7]=t,e[8]=A):A=e[8],p=mS.configure({HTMLAttributes:{class:"bg-primary/20 text-primary px-1 rounded font-medium"},renderText:VS,renderHTML:FS,suggestion:{items:A,render:$S,command:BS}}).extend(u?{addNodeView(){return Mb(IS)}}:{}),e[4]=t,e[5]=u,e[6]=p}else p=e[6];let y;e[9]!==p?(y=[h,p],e[9]=p,e[10]=y):y=e[10];const g=o??"";let x;e[11]!==g?(x={attributes:{class:"prose prose-sm max-w-none focus:outline-none w-full min-h-[20px]","data-placeholder":g},handleKeyDown:_S},e[11]=g,e[12]=x):x=e[12];let b;e[13]!==s?(b=A=>{const{editor:D}=A;return s?.(D.getText().trim())},e[13]=s,e[14]=b):b=e[14];let S;e[15]!==d||e[16]!==f||e[17]!==y||e[18]!==x||e[19]!==b?(S={content:d,editable:f,extensions:y,editorProps:x,onUpdate:b},e[15]=d,e[16]=f,e[17]=y,e[18]=x,e[19]=b,e[20]=S):S=e[20];const v=Sb(S);let k;e[21]!==i?(k=U("rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",i),e[21]=i,e[22]=k):k=e[22];let w;e[23]!==v?(w=m.jsx(pb,{editor:v}),e[23]=v,e[24]=w):w=e[24];let C;e[25]!==k||e[26]!==w?(C=m.jsx("div",{className:k,children:w}),e[25]=k,e[26]=w,e[27]=C):C=e[27];const T=C;if(a!==void 0){let A;return e[28]!==T||e[29]!==a?(A=m.jsx(Zf.Provider,{value:a,children:T}),e[28]=T,e[29]=a,e[30]=A):A=e[30],A}return T}function _S(n,e){return e.key==="Enter"?(e.preventDefault(),!0):!1}function BS(n){const{editor:e,range:t,props:r}=n;e.chain().focus().insertContentAt(t,[{type:"mention",attrs:r}]).run()}function FS(n){const{options:e,node:t}=n;return["span",e.HTMLAttributes,`@${t.attrs.id}`]}function VS(n){const{node:e}=n;return`@${e.attrs.id}`}function HS(n){const e=I.c(8),{value:t,onChange:r,placeholder:s,readonly:o}=n,i=ad(),l=t??"";let a;e[0]!==r?(a=u=>r(u),e[0]=r,e[1]=a):a=e[1];const c=s||"Enter value...";let d;return e[2]!==i||e[3]!==o||e[4]!==l||e[5]!==a||e[6]!==c?(d=m.jsx(Pl,{mentions:i,value:l,onChange:a,placeholder:c,readOnly:o}),e[2]=i,e[3]=o,e[4]=l,e[5]=a,e[6]=c,e[7]=d):d=e[7],d}function WS(n){const e=I.c(8),{value:t,onChange:r,placeholder:s,readonly:o}=n,i=ad(),l=t??"";let a;e[0]!==r?(a=u=>r(u),e[0]=r,e[1]=a):a=e[1];const c=s||"Enter value...";let d;return e[2]!==i||e[3]!==o||e[4]!==l||e[5]!==a||e[6]!==c?(d=m.jsx(Pl,{mentions:i,value:l,onChange:a,placeholder:c,readOnly:o,className:"min-h-[80px]"}),e[2]=i,e[3]=o,e[4]=l,e[5]=a,e[6]=c,e[7]=d):d=e[7],d}function qS(n){const e=I.c(8),{value:t,onChange:r,readonly:s,id:o}=n,i=t??"";let l;e[0]!==r?(l=d=>r(d.target.value===""?void 0:Number(d.target.value)),e[0]=r,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=U("w-full rounded-md border border-input bg-background px-3 py-2 text-sm","ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50"),e[2]=a):a=e[2];let c;return e[3]!==o||e[4]!==s||e[5]!==i||e[6]!==l?(c=m.jsx("input",{id:o,type:"number",value:i,onChange:l,disabled:s,className:a}),e[3]=o,e[4]=s,e[5]=i,e[6]=l,e[7]=c):c=e[7],c}function US(n){const e=I.c(13),{value:t,onChange:r,readonly:s,id:o,label:i}=n,l=t??!1;let a;e[0]!==r?(a=f=>r(f.target.checked),e[0]=r,e[1]=a):a=e[1];let c;e[2]!==o||e[3]!==s||e[4]!==l||e[5]!==a?(c=m.jsx("input",{id:o,type:"checkbox",checked:l,onChange:a,disabled:s,className:"h-4 w-4 rounded border-input"}),e[2]=o,e[3]=s,e[4]=l,e[5]=a,e[6]=c):c=e[6];let d;e[7]!==i?(d=m.jsx("span",{className:"text-sm",children:i}),e[7]=i,e[8]=d):d=e[8];let u;return e[9]!==o||e[10]!==c||e[11]!==d?(u=m.jsxs("label",{htmlFor:o,className:"flex items-center gap-2 cursor-pointer",children:[c,d]}),e[9]=o,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function KS(n){const e=I.c(14),{value:t,onChange:r,readonly:s,id:o,options:i}=n;let l;e[0]!==i.enumOptions?(l=i.enumOptions??[],e[0]=i.enumOptions,e[1]=l):l=e[1];const a=l,c=t??"";let d;e[2]!==r?(d=y=>r(y.target.value),e[2]=r,e[3]=d):d=e[3];let u,f;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=U("w-full rounded-md border border-input bg-background px-3 py-2 text-sm","ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50"),f=m.jsx("option",{value:"",children:"Select..."}),e[4]=u,e[5]=f):(u=e[4],f=e[5]);let h;e[6]!==a?(h=a.map(JS),e[6]=a,e[7]=h):h=e[7];let p;return e[8]!==o||e[9]!==s||e[10]!==c||e[11]!==d||e[12]!==h?(p=m.jsxs("select",{id:o,value:c,onChange:d,disabled:s,className:u,children:[f,h]}),e[8]=o,e[9]=s,e[10]=c,e[11]=d,e[12]=h,e[13]=p):p=e[13],p}function JS(n){return m.jsx("option",{value:String(n.value),children:String(n.label)},String(n.value))}const GS={TextWidget:HS,TextareaWidget:WS,NumberWidget:qS,CheckboxWidget:US,SelectWidget:KS};function XS(n){switch(Array.isArray(n)?n[0]:n??"unknown"){case"string":return{Icon:Uc,color:"text-blue-500"};case"number":case"integer":return{Icon:Wc,color:"text-blue-500"};case"array":return{Icon:Fc,color:"text-purple-500"};case"object":return{Icon:Bc,color:"text-orange-500"};case"boolean":return{Icon:qc,color:"text-pink-500"};case"null":return{Icon:Ti,color:"text-gray-500"};default:return{Icon:Vc,color:"text-muted-foreground"}}}function YS(n){const e=I.c(36),{id:t,label:r,required:s,description:o,children:i,schema:l,hidden:a}=n;if(a){let k;return e[0]!==i?(k=m.jsx("div",{className:"hidden",children:i}),e[0]=i,e[1]=k):k=e[1],k}if(t==="root"){let k;return e[2]!==i?(k=m.jsx("div",{className:"space-y-4",children:i}),e[2]=i,e[3]=k):k=e[3],k}const c=Array.isArray(l.type)?l.type[0]:l.type??"string";let d,u,f,h,p,y,g;if(e[4]!==t||e[5]!==r||e[6]!==s||e[7]!==c){const{Icon:k,color:w}=XS(c);g="space-y-2",h="flex items-center gap-2",e[15]!==t||e[16]!==r?(p=m.jsx("label",{htmlFor:t,className:"text-sm font-medium leading-none",children:r}),e[15]=t,e[16]=r,e[17]=p):p=e[17],e[18]!==s?(y=s&&m.jsx("span",{className:"text-red-500 text-xs",children:"*"}),e[18]=s,e[19]=y):y=e[19],d=k,u=14,f=U(w,"ml-auto"),e[4]=t,e[5]=r,e[6]=s,e[7]=c,e[8]=d,e[9]=u,e[10]=f,e[11]=h,e[12]=p,e[13]=y,e[14]=g}else d=e[8],u=e[9],f=e[10],h=e[11],p=e[12],y=e[13],g=e[14];let x;e[20]!==d||e[21]!==u||e[22]!==f?(x=m.jsx(d,{size:u,className:f}),e[20]=d,e[21]=u,e[22]=f,e[23]=x):x=e[23];let b;e[24]!==h||e[25]!==p||e[26]!==y||e[27]!==x?(b=m.jsxs("div",{className:h,children:[p,y,x]}),e[24]=h,e[25]=p,e[26]=y,e[27]=x,e[28]=b):b=e[28];let S;e[29]!==o?(S=o&&m.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:o}),e[29]=o,e[30]=S):S=e[30];let v;return e[31]!==i||e[32]!==g||e[33]!==b||e[34]!==S?(v=m.jsxs("div",{className:g,children:[b,S,i]}),e[31]=i,e[32]=g,e[33]=b,e[34]=S,e[35]=v):v=e[35],v}function QS(n){const e=I.c(8),{properties:t,title:r}=n;if(!r||r==="Root"){let l;e[0]!==t?(l=t.map(ew),e[0]=t,e[1]=l):l=e[1];let a;return e[2]!==l?(a=m.jsx("div",{className:"space-y-4",children:l}),e[2]=l,e[3]=a):a=e[3],a}let o;e[4]!==t?(o=t.map(ZS),e[4]=t,e[5]=o):o=e[5];let i;return e[6]!==o?(i=m.jsx("div",{className:"pl-4 border-l-2 border-border/50 space-y-4",children:o}),e[6]=o,e[7]=i):i=e[7],i}function ZS(n){return m.jsx("div",{children:n.content},n.name)}function ew(n){return m.jsx("div",{children:n.content},n.name)}function tw(n){const e=I.c(11),{items:t,canAdd:r,onAddClick:s,title:o}=n;let i;e[0]!==t?(i=t.map(nw),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==i?(l=m.jsx("div",{className:"space-y-2",children:i}),e[2]=i,e[3]=l):l=e[3];let a;e[4]!==r||e[5]!==s||e[6]!==o?(a=r&&m.jsxs(me,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:s,children:["+ Add ",o||"item"]}),e[4]=r,e[5]=s,e[6]=o,e[7]=a):a=e[7];let c;return e[8]!==l||e[9]!==a?(c=m.jsxs("div",{className:"space-y-2",children:[l,a]}),e[8]=l,e[9]=a,e[10]=c):c=e[10],c}function nw(n){return m.jsx("div",{className:"flex gap-2 items-start",children:m.jsx("div",{className:"flex-1",children:n})},n.key||n.index)}function rw(){return null}function sw(){return null}const ow={FieldTemplate:YS,ObjectFieldTemplate:QS,ArrayFieldTemplate:tw,UnsupportedFieldTemplate:rw,ErrorListTemplate:sw};function iw(n){const e=I.c(6),{inputSchema:t,inputParams:r,mentions:s}=n;if(!t?.properties||!r)return null;let o;e[0]!==s?(o=(a,c,d)=>{const u=typeof c=="object"&&c!==null?JSON.stringify(c,null,2):String(c??""),f=Array.isArray(d.type)?d.type.join(" | "):d.type??"string";return m.jsxs("div",{className:"space-y-1.5",children:[m.jsxs("div",{className:"flex items-baseline gap-2",children:[m.jsx("span",{className:"text-sm font-medium text-foreground",children:a}),m.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:f})]}),d.description&&m.jsx("div",{className:"text-xs text-muted-foreground",children:d.description}),m.jsx("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2 text-sm",children:m.jsx(Pl,{mentions:s,value:u,readOnly:!0,className:"border-0 bg-transparent p-0"})})]},a)},e[0]=s,e[1]=o):o=e[1];const i=o;let l;return e[2]!==r||e[3]!==t.properties||e[4]!==i?(l=m.jsx("div",{className:"space-y-4",children:Object.entries(t.properties).map(a=>{const[c,d]=a,u=r[c];return i(c,u,d)})}),e[2]=r,e[3]=t.properties,e[4]=i,e[5]=l):l=e[5],l}function rh({inputSchema:n,inputParams:e,setInputParams:t,handleInputChange:r,mentions:s,readOnly:o}){const i=s??[];if(!n)return m.jsx("div",{className:"text-sm text-muted-foreground italic",children:"No arguments defined in schema."});if(o)return m.jsx(iw,{inputSchema:n,inputParams:e,mentions:i});const l=n,a=O.useRef(e??{}),c=d=>{const u=d.formData??{},f=a.current;if(t?.(u),r){for(const[h,p]of Object.entries(u))f[h]!==p&&r(h,p);for(const h of Object.keys(f))h in u||r(h,void 0)}a.current=u};return m.jsx(ld.Provider,{value:i,children:m.jsx(qh,{schema:l,formData:e,onChange:c,validator:Uh,widgets:GS,templates:ow,readonly:o,uiSchema:{"ui:submitButtonOptions":{norender:!0}},liveValidate:!1,className:"rjsf-form",omitExtraData:!0,liveOmit:!0,children:m.jsx(m.Fragment,{})})})}function lw(n){const e=I.c(33),{open:t,onOpenChange:r,inputSchema:s,onSubmit:o,isPending:i}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];const[a,c]=O.useState(l);let d;e[1]!==a||e[2]!==r||e[3]!==o?(d=async()=>{await o(a),r(!1),c({})},e[1]=a,e[2]=r,e[3]=o,e[4]=d):d=e[4];const u=d;let f;e[5]!==r?(f=T=>{T||c({}),r(T)},e[5]=r,e[6]=f):f=e[6];const h=f;let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsxs(dp,{children:[m.jsx(up,{children:"Workflow Input"}),m.jsx(fp,{children:"This workflow requires input values to run. Fill in the fields below to start the execution."})]}),e[7]=p):p=e[7];let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[8]=y):y=e[8];let g;e[9]!==a||e[10]!==s?(g=m.jsx("div",{className:"py-4",children:m.jsx(rh,{inputSchema:s,inputParams:a,setInputParams:c,mentions:y})}),e[9]=a,e[10]=s,e[11]=g):g=e[11];let x;e[12]!==h?(x=()=>h(!1),e[12]=h,e[13]=x):x=e[13];let b;e[14]!==i||e[15]!==x?(b=m.jsx(me,{variant:"outline",onClick:x,disabled:i,children:"Cancel"}),e[14]=i,e[15]=x,e[16]=b):b=e[16];let S;e[17]!==i?(S=i?m.jsx(Ds,{size:"xs"}):m.jsx(Li,{size:14}),e[17]=i,e[18]=S):S=e[18];let v;e[19]!==u||e[20]!==i||e[21]!==S?(v=m.jsxs(me,{onClick:u,disabled:i,className:"gap-2",children:[S,"Run Workflow"]}),e[19]=u,e[20]=i,e[21]=S,e[22]=v):v=e[22];let k;e[23]!==v||e[24]!==b?(k=m.jsxs(hp,{children:[b,v]}),e[23]=v,e[24]=b,e[25]=k):k=e[25];let w;e[26]!==k||e[27]!==g?(w=m.jsxs(pp,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[p,g,k]}),e[26]=k,e[27]=g,e[28]=w):w=e[28];let C;return e[29]!==h||e[30]!==t||e[31]!==w?(C=m.jsx(mp,{open:t,onOpenChange:h,children:w}),e[29]=h,e[30]=t,e[31]=w,e[32]=C):C=e[32],C}function aw(n){const e=I.c(26),{title:t,description:r,onSave:s}=n,i=Ci().location.href,{viewMode:l,setViewMode:a,showExecutionsList:c,toggleExecutionsList:d}=Ji(),{resetToOriginalWorkflow:u,setSelectedGatewayId:f}=Me(),h=od(),p=jn(),y=we();let g;e[0]!==t?(g=m.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:t}),e[0]=t,e[1]=g):g=e[1];let x;e[2]!==r?(x=r?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"•"}),m.jsx("span",{className:"text-xs text-muted-foreground font-normal truncate min-w-0 max-w-[20ch]",children:r})]}):null,e[2]=r,e[3]=x):x=e[3];let b;e[4]!==g||e[5]!==x?(b=m.jsx(Lc,{children:m.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[g,x]})}),e[4]=g,e[5]=x,e[6]=b):b=e[6];let S;e[7]!==h||e[8]!==s||e[9]!==u||e[10]!==p||e[11]!==f||e[12]!==a||e[13]!==c||e[14]!==t||e[15]!==d||e[16]!==y||e[17]!==i||e[18]!==l?(S=!y&&m.jsxs(m.Fragment,{children:[m.jsx(Oi,{title:t,url:i,icon:"workflow"}),m.jsx(O.Suspense,{fallback:m.jsx(Ds,{size:"xs"}),children:m.jsx(Wm,{selectedGatewayId:p,onGatewayChange:f,placeholder:"Select Agent"})}),m.jsx(ap,{value:l,onValueChange:a,size:"sm",options:[{value:"visual",icon:m.jsx(cp,{})},{value:"code",icon:m.jsx(Gc,{})}]}),m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:u,disabled:!h,"aria-label":"Reset changes",children:m.jsx(Pc,{size:14})})})}),m.jsx($t,{side:"bottom",children:"Reset changes"})]})}),m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:s,disabled:!h,"aria-label":"Save workflow",children:m.jsx(Ui,{size:14})})})}),m.jsx($t,{side:"bottom",children:"Save workflow"})]})}),m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:c?"secondary":"outline",size:"icon",className:"size-7 border border-input",onClick:d,"aria-label":c?"Hide runs":"Show runs",children:m.jsx(Jc,{size:14})})})}),m.jsx($t,{side:"bottom",children:c?"Hide runs":"Show runs"})]})})]}),e[7]=h,e[8]=s,e[9]=u,e[10]=p,e[11]=f,e[12]=a,e[13]=c,e[14]=t,e[15]=d,e[16]=y,e[17]=i,e[18]=l,e[19]=S):S=e[19];let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=m.jsx(uw,{}),e[20]=v):v=e[20];let k;e[21]!==S?(k=m.jsxs(Di,{children:[S,v]}),e[21]=S,e[22]=k):k=e[22];let w;return e[23]!==b||e[24]!==k?(w=m.jsxs(m.Fragment,{children:[b,k]}),e[23]=b,e[24]=k,e[25]=w):w=e[25],w}function cw(){const n=we(),{item:e}=Pn(n);return e?.completed_at_epoch_ms!=null}function dw(){const n=we(),{item:e}=Pn(n);return e?.status==="cancelled"}function uw(){const n=I.c(57),e=od(),t=cw(),r=dw(),s=we(),o=jn(),{handleRunWorkflow:i,isPending:l,requiresInput:a,inputSchema:c}=Qm(),d=pr(),[u,f]=O.useState(!1),{handleCancelWorkflow:h,isCancelling:p}=Zm(),{handleResumeWorkflow:y,isResuming:g}=eg(),x=s&&!t;let b;n[0]!==d?(b=d.some(fw),n[0]=d,n[1]=b):b=n[1];const S=b,v=!o,k=e||S||v||l||p,w=x||l;let C;n[2]!==S||n[3]!==v||n[4]!==e||n[5]!==r||n[6]!==w?(C=()=>r?"Workflow is currently cancelled":w?"Workflow is currently running":e?"Save your changes before running":v?"Select an Agent first":S?"Add at least one step to the workflow":null,n[2]=S,n[3]=v,n[4]=e,n[5]=r,n[6]=w,n[7]=C):C=n[7];const A=C();let D;n[8]!==h||n[9]!==y||n[10]!==i||n[11]!==c||n[12]!==r||n[13]!==w||n[14]!==a||n[15]!==s?(D=async()=>{if(a&&c){f(!0);return}if(r&&s){await y(s);return}if(w&&s){await h(s);return}await i({})},n[8]=h,n[9]=y,n[10]=i,n[11]=c,n[12]=r,n[13]=w,n[14]=a,n[15]=s,n[16]=D):D=n[16];const j=D;let _;n[17]!==i?(_=async Fe=>{await i(Fe)},n[17]=i,n[18]=_):_=n[18];const V=_,B=r?"Resume":s?t?"Replay":"Running...":a?"Run with input...":"Run workflow",H=!x&&"bg-primary text-primary-foreground hover:bg-primary/90";let N;n[19]!==H?(N=U("gap-2 h-7 px-3",H),n[19]=H,n[20]=N):N=n[20];let z;n[21]!==p||n[22]!==r||n[23]!==l||n[24]!==g||n[25]!==x?(z=(!x&&!l&&!p&&!g||r)&&m.jsx(Li,{size:14}),n[21]=p,n[22]=r,n[23]=l,n[24]=g,n[25]=x,n[26]=z):z=n[26];let P;n[27]!==p||n[28]!==r||n[29]!==l||n[30]!==g||n[31]!==x?(P=x&&!l&&!p&&!g&&!r&&m.jsx(Zh,{size:14}),n[27]=p,n[28]=r,n[29]=l,n[30]=g,n[31]=x,n[32]=P):P=n[32];let K;n[33]!==p||n[34]!==l||n[35]!==g?(K=(l||p||g)&&m.jsx(Ds,{size:"xs"}),n[33]=p,n[34]=l,n[35]=g,n[36]=K):K=n[36];let Q;n[37]!==B||n[38]!==j||n[39]!==k||n[40]!==N||n[41]!==z||n[42]!==P||n[43]!==K?(Q=m.jsxs(me,{variant:"default",size:"sm",className:N,disabled:k,onClick:j,children:[z,P,K,B]}),n[37]=B,n[38]=j,n[39]=k,n[40]=N,n[41]=z,n[42]=P,n[43]=K,n[44]=Q):Q=n[44];const le=Q;let X;n[45]!==le||n[46]!==A?(X=A?m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:le})}),m.jsx($t,{side:"bottom",children:A})]})}):le,n[45]=le,n[46]=A,n[47]=X):X=n[47];const fe=X;let se;n[48]!==V||n[49]!==c||n[50]!==l||n[51]!==a||n[52]!==u?(se=a&&c&&m.jsx(lw,{open:u,onOpenChange:f,inputSchema:c,onSubmit:V,isPending:l}),n[48]=V,n[49]=c,n[50]=l,n[51]=a,n[52]=u,n[53]=se):se=n[53];let J;return n[54]!==fe||n[55]!==se?(J=m.jsxs(m.Fragment,{children:[fe,se]}),n[54]=fe,n[55]=se,n[56]=J):J=n[56],J}function fw(n){return"toolName"in n.action&&(!n.action.toolName||n.action.toolName==="")}function hw(){const n=I.c(17),e=we(),t=pr(),{item:r}=Pn(e);if(!e||!r)return;let s;if(n[0]!==r.completed_steps?.error||n[1]!==r.completed_steps?.success||n[2]!==r.status||n[3]!==t){s={};let o;n[5]!==r.completed_steps?.success?(o=r.completed_steps?.success??[],n[5]=r.completed_steps?.success,n[6]=o):o=n[6];let i;n[7]!==o?(i=new Set(o),n[7]=o,n[8]=i):i=n[8];const l=i;let a;n[9]!==r.completed_steps?.error?(a=r.completed_steps?.error??[],n[9]=r.completed_steps?.error,n[10]=a):a=n[10];let c;n[11]!==a?(c=new Set(a),n[11]=a,n[12]=c):c=n[12];const d=c;let u;n[13]!==d||n[14]!==t||n[15]!==l?(u=-1,t.forEach((f,h)=>{(l.has(f.name)||d.has(f.name))&&(u=h)}),n[13]=d,n[14]=t,n[15]=l,n[16]=u):u=n[16],t.forEach((f,h)=>{let p="pending";d.has(f.name)?p="error":l.has(f.name)?p="success":r.status==="running"&&h===u+1&&(p="running"),s[f.name]={status:p,output:void 0,error:void 0,stepIndex:h}}),n[0]=r.completed_steps?.error,n[1]=r.completed_steps?.success,n[2]=r.status,n[3]=t,n[4]=s}else s=n[4];return s}function pw(n){const e=I.c(119),{step:t,index:r,isSelected:s,executionStatus:o,isSkipped:i,isLastStep:l,onSelect:a,onDelete:c,onDuplicate:d}=n,u=we(),{item:f}=Pn(u),h=f?.completed_at_epoch_ms;let p;e[0]!==f?.completed_steps?.success||e[1]!==t.name?(p=f?.completed_steps?.success?.includes(t.name)??!1,e[0]=f?.completed_steps?.success,e[1]=t.name,e[2]=p):p=e[2];const y=p;let g;e[3]!==f?.completed_steps?.error||e[4]!==t.name?(g=f?.completed_steps?.error?.includes(t.name)??!1,e[3]=f?.completed_steps?.error,e[4]=t.name,e[5]=g):g=e[5];const x=g,b="toolName"in t.action,S=b&&"connectionId"in t.action?t.action.connectionId:null,k=!!(b&&"toolName"in t.action?t.action.toolName:null);let w,C,T,A,D,j,_,V,B,H,N;if(e[6]!==S||e[7]!==o||e[8]!==k||e[9]!==r||e[10]!==y||e[11]!==x||e[12]!==l||e[13]!==s||e[14]!==i||e[15]!==b||e[16]!==c||e[17]!==d||e[18]!==a||e[19]!==t||e[20]!==u){const le=Nw(t);w=y?"success":x?"error":o?.status;const X=o!==void 0,fe=w==="success"||w==="error";let se=le.length>0?60:12;(w==="success"||w==="error")&&(se=se+32);let J,Fe,at;if(e[32]!==s||e[33]!==i||e[34]!==a||e[35]!==w){const $n=yw(w);let br;e[44]!==w?(br=xw(w),e[44]=w,e[45]=br):br=e[45],J=br;const ro=s&&"bg-background border-1 border-border outline outline-offset-3 outline-border/25",so=w==="running"&&"bg-accent/50",oo=i&&"opacity-50";e[46]!==ro||e[47]!==so||e[48]!==oo?(V=U("flex gap-2 items-start border-1 border-transparent px-4 w-full rounded-lg cursor-pointer group hover:bg-accent/30",ro,so,oo),e[46]=ro,e[47]=so,e[48]=oo,e[49]=V):V=e[49],B=a,H="button",N=0,e[50]!==a?(C=io=>{(io.key==="Enter"||io.key===" ")&&(io.preventDefault(),a())},e[50]=a,e[51]=C):C=e[51],at="w-5 flex flex-col items-center justify-center shrink-0 pt-3",Fe=U("text-xs font-mono opacity-75 h-8 flex items-center",$n),e[32]=s,e[33]=i,e[34]=a,e[35]=w,e[36]=J,e[37]=C,e[38]=Fe,e[39]=at,e[40]=V,e[41]=B,e[42]=H,e[43]=N}else J=e[36],C=e[37],Fe=e[38],at=e[39],V=e[40],B=e[41],H=e[42],N=e[43];const to=r+1;let en;e[52]!==Fe||e[53]!==to?(en=m.jsxs("span",{className:Fe,children:[to,"."]}),e[52]=Fe,e[53]=to,e[54]=en):en=e[54],e[55]!==at||e[56]!==en?(T=m.jsx("div",{className:at,children:en}),e[55]=at,e[56]=en,e[57]=T):T=e[57];let tn;e[58]!==J||e[59]!==r?(tn=r>0?m.jsx(Vo,{height:12,color:J}):m.jsx("div",{className:"h-3"}),e[58]=J,e[59]=r,e[60]=tn):tn=e[60];let nn;e[61]!==S||e[62]!==k||e[63]!==b||e[64]!==t.name?(nn=m.jsx(vw,{connectionId:S,isToolStep:b,hasToolSelected:k,stepName:t.name}),e[61]=S,e[62]=k,e[63]=b,e[64]=t.name,e[65]=nn):nn=e[65];let rn;e[66]!==J||e[67]!==fe||e[68]!==w?(rn=fe&&m.jsxs(m.Fragment,{children:[m.jsx(Vo,{height:8,color:J}),m.jsx(bw,{status:w})]}),e[66]=J,e[67]=fe,e[68]=w,e[69]=rn):rn=e[69];let sn;e[70]!==J||e[71]!==se||e[72]!==l||e[73]!==u?(sn=l&&u?null:m.jsx(Vo,{height:se,color:J}),e[70]=J,e[71]=se,e[72]=l,e[73]=u,e[74]=sn):sn=e[74],e[75]!==tn||e[76]!==nn||e[77]!==rn||e[78]!==sn?(A=m.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[tn,nn,rn,sn]}),e[75]=tn,e[76]=nn,e[77]=rn,e[78]=sn,e[79]=A):A=e[79],D="flex-1 flex flex-col gap-3 min-w-0 pt-3 pb-3";const no=k?"font-medium text-foreground":"text-foreground";let on;e[80]!==no?(on=U("text-sm truncate flex-1",no),e[80]=no,e[81]=on):on=e[81];let ln;e[82]!==t?(ln=Cw(t),e[82]=t,e[83]=ln):ln=e[83];let an;e[84]!==on||e[85]!==ln?(an=m.jsx("span",{className:on,children:ln}),e[84]=on,e[85]=ln,e[86]=an):an=e[86];let cn;e[87]!==X||e[88]!==w?(cn=X&&m.jsx(kw,{status:w}),e[87]=X,e[88]=w,e[89]=cn):cn=e[89];let dn;e[90]!==X||e[91]!==c||e[92]!==d?(dn=!X&&m.jsxs(yp,{children:[m.jsx(xp,{asChild:!0,children:m.jsx(me,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity",onClick:gw,children:m.jsx(gp,{size:14})})}),m.jsxs(bp,{align:"end",children:[m.jsxs(Fl,{onClick:$n=>{$n.stopPropagation(),d()},children:[m.jsx(wp,{size:14}),"Duplicate"]}),m.jsxs(Fl,{className:"text-destructive hover:bg-destructive/10! focus:text-destructive",onClick:$n=>{$n.stopPropagation(),c()},children:[m.jsx(Ah,{size:14,className:"text-destructive"}),"Delete"]})]})]}),e[90]=X,e[91]=c,e[92]=d,e[93]=dn):dn=e[93],e[94]!==an||e[95]!==cn||e[96]!==dn?(j=m.jsxs("div",{className:"flex items-center h-8",children:[an,cn,dn]}),e[94]=an,e[95]=cn,e[96]=dn,e[97]=j):j=e[97],_=le.length>0&&m.jsx("div",{className:"flex flex-wrap gap-1.5",children:le.map(mw)}),e[6]=S,e[7]=o,e[8]=k,e[9]=r,e[10]=y,e[11]=x,e[12]=l,e[13]=s,e[14]=i,e[15]=b,e[16]=c,e[17]=d,e[18]=a,e[19]=t,e[20]=u,e[21]=w,e[22]=C,e[23]=T,e[24]=A,e[25]=D,e[26]=j,e[27]=_,e[28]=V,e[29]=B,e[30]=H,e[31]=N}else w=e[21],C=e[22],T=e[23],A=e[24],D=e[25],j=e[26],_=e[27],V=e[28],B=e[29],H=e[30],N=e[31];let z;e[98]!==h||e[99]!==w?(z=w==="success"&&m.jsx(Sw,{completedAtEpochMs:h}),e[98]=h,e[99]=w,e[100]=z):z=e[100];let P;e[101]!==o?.error||e[102]!==w?(P=w==="error"&&m.jsx(ww,{error:o?.error}),e[101]=o?.error,e[102]=w,e[103]=P):P=e[103];let K;e[104]!==z||e[105]!==P||e[106]!==D||e[107]!==j||e[108]!==_?(K=m.jsxs("div",{className:D,children:[j,_,z,P]}),e[104]=z,e[105]=P,e[106]=D,e[107]=j,e[108]=_,e[109]=K):K=e[109];let Q;return e[110]!==C||e[111]!==T||e[112]!==A||e[113]!==K||e[114]!==V||e[115]!==B||e[116]!==H||e[117]!==N?(Q=m.jsxs("div",{className:V,onClick:B,role:H,tabIndex:N,onKeyDown:C,children:[T,A,K]}),e[110]=C,e[111]=T,e[112]=A,e[113]=K,e[114]=V,e[115]=B,e[116]=H,e[117]=N,e[118]=Q):Q=e[118],Q}function mw(n){return m.jsx("span",{className:"px-1.5 py-1 text-xs text-muted-foreground bg-background border border-border rounded-lg",children:n},n)}function gw(n){return n.stopPropagation()}function yw(n){switch(n){case"success":return"text-success";case"error":return"text-destructive";default:return"text-muted-foreground"}}function xw(n){switch(n){case"success":return"bg-success";case"error":return"bg-destructive";default:return"bg-border"}}function bw(n){const e=I.c(2),{status:t}=n;if(t==="success"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-4 rounded bg-success flex items-center justify-center",children:m.jsx(Vi,{size:8,className:"text-success-foreground"})}),e[0]=r):r=e[0],r}if(t==="error"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-4 rounded bg-destructive flex items-center justify-center",children:m.jsx($i,{size:8,className:"text-destructive-foreground"})}),e[1]=r):r=e[1],r}return null}function kw(n){const e=I.c(3),{status:t}=n;if(t==="success"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-7 flex items-center justify-center",children:m.jsx(Vi,{size:11,className:"text-success"})}),e[0]=r):r=e[0],r}if(t==="error"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-7 flex items-center justify-center",children:m.jsx($i,{size:11,className:"text-destructive"})}),e[1]=r):r=e[1],r}if(t==="running"){let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-7 flex items-center justify-center",children:m.jsx(tr,{size:11,className:"text-muted-foreground animate-spin"})}),e[2]=r):r=e[2],r}return null}function Sw(n){const e=I.c(8),{completedAtEpochMs:t}=n;let r,s;if(e[0]!==t){const a=t!=null?new Date(t):null;r=a?a.toISOString().split("T")[0]:null,s=a?a.toTimeString().split(" ")[0]:null,e[0]=t,e[1]=r,e[2]=s}else r=e[1],s=e[2];const o=s;let i;e[3]!==r||e[4]!==o?(i=r&&o&&m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Fh,{size:16,className:"text-success"}),m.jsx("span",{className:"text-xs text-success",children:r}),m.jsx("span",{className:"text-xs text-success",children:o})]}),e[3]=r,e[4]=o,e[5]=i):i=e[5];let l;return e[6]!==i?(l=m.jsx("div",{className:"inline-flex items-center gap-3 px-1.5 py-1 bg-success-foreground rounded-lg w-fit",children:i}),e[6]=i,e[7]=l):l=e[7],l}function ww(n){const e=I.c(3),{error:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx(qi,{size:16,className:"text-destructive"}),e[0]=r):r=e[0];const s=t||"Execution failed";let o;return e[1]!==s?(o=m.jsxs("div",{className:"inline-flex items-center gap-1.5 px-1.5 py-1 bg-destructive-foreground rounded-lg w-fit",children:[r,m.jsx("span",{className:"text-xs text-destructive",children:s})]}),e[1]=s,e[2]=o):o=e[2],o}function vw(n){const e=I.c(5),{connectionId:t,isToolStep:r,hasToolSelected:s,stepName:o}=n,i=Pi(t??"");if(r&&s&&i?.icon){let a;return e[0]!==i.icon||e[1]!==o?(a=m.jsx("div",{className:"size-8 rounded-lg border border-border/10 bg-background shadow-sm flex items-center justify-center overflow-hidden",children:m.jsx(js,{icon:i.icon,name:o,size:"xs",className:"border-0 rounded-none"})}),e[0]=i.icon,e[1]=o,e[2]=a):a=e[2],a}let l;return e[3]!==r?(l=m.jsx("div",{className:"size-8 rounded-lg border border-border/10 bg-background shadow-sm flex items-center justify-center",children:r?m.jsx(Zc,{size:16,className:"text-muted-foreground"}):m.jsx(Sp,{size:16,className:"text-muted-foreground"})}),e[3]=r,e[4]=l):l=e[4],l}function Vo(n){const e=I.c(7),{height:t,color:r}=n,s=r===void 0?"bg-border":r;let o;e[0]!==s?(o=U("w-px",s),e[0]=s,e[1]=o):o=e[1];let i;e[2]!==t?(i={height:t},e[2]=t,e[3]=i):i=e[3];let l;return e[4]!==o||e[5]!==i?(l=m.jsx("div",{className:o,style:i}),e[4]=o,e[5]=i,e[6]=l):l=e[6],l}function Cw(n){return n.name?n.name:"toolName"in n.action&&n.action.toolName?n.action.toolName:"code"in n.action?n.name||"Code Step":"Select tool..."}function Nw(n){const e=n.outputSchema;if(!e||typeof e!="object")return[];const t=e.properties;return!t||typeof t!="object"?[]:Object.keys(t).slice(0,5)}function Ew(n){const e=I.c(32),{className:t}=n,r=pr(),s=sd(),o=hw(),{setCurrentStepName:i,deleteStep:l,duplicateStep:a}=Me(),c=we();let d;e[0]!==o||e[1]!==r?(d=o?r.findIndex(S=>o[S.name]?.status==="error"):-1,e[0]=o,e[1]=r,e[2]=d):d=e[2];const u=d;let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=m.jsx("div",{children:"Loading..."}),e[3]=f):f=e[3];let h;e[4]!==t?(h=U("h-full flex flex-col p-8 overflow-auto",t),e[4]=t,e[5]=h):h=e[5];let p;if(e[6]!==s||e[7]!==l||e[8]!==a||e[9]!==u||e[10]!==i||e[11]!==o||e[12]!==r){let S;e[14]!==s||e[15]!==l||e[16]!==a||e[17]!==u||e[18]!==i||e[19]!==o||e[20]!==r.length?(S=(v,k)=>{const w=o?.[v.name],C=u!==-1&&k>u&&w?.status==="pending",T=k===r.length-1;return m.jsx(pw,{step:v,index:k,isSelected:v.name===s,executionStatus:w,isSkipped:C,isLastStep:T,onSelect:()=>i(v.name),onDelete:()=>l(v.name),onDuplicate:()=>a(v.name)},v.name)},e[14]=s,e[15]=l,e[16]=a,e[17]=u,e[18]=i,e[19]=o,e[20]=r.length,e[21]=S):S=e[21],p=r.map(S),e[6]=s,e[7]=l,e[8]=a,e[9]=u,e[10]=i,e[11]=o,e[12]=r,e[13]=p}else p=e[13];let y;e[22]!==p?(y=m.jsx("div",{className:"pt-3 -space-y-1",children:p}),e[22]=p,e[23]=y):y=e[23];let g;e[24]!==c?(g=c?null:m.jsx(Tw,{}),e[24]=c,e[25]=g):g=e[25];let x;e[26]!==y||e[27]!==g?(x=m.jsxs("div",{className:"w-full -space-y-1",children:[y,g]}),e[26]=y,e[27]=g,e[28]=x):x=e[28];let b;return e[29]!==h||e[30]!==x?(b=m.jsx(O.Suspense,{fallback:f,children:m.jsx("div",{className:h,children:x})}),e[29]=h,e[30]=x,e[31]=b):b=e[31],b}function Tw(){const n=I.c(8),{addToolStep:e}=Me();let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=m.jsx("div",{className:"w-5 shrink-0"}),n[0]=t):t=n[0];let r;n[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"w-px h-3 bg-border"}),n[1]=r):r=n[1];let s;n[2]===Symbol.for("react.memo_cache_sentinel")?(s=m.jsx(zc,{size:14}),n[2]=s):s=n[2];let o;n[3]!==e?(o=m.jsx(me,{variant:"outline",size:"icon",className:"size-8 rounded-lg",onClick:e,children:s}),n[3]=e,n[4]=o):o=n[4];let i;n[5]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx("div",{className:"w-px h-8",style:{backgroundImage:"repeating-linear-gradient(180deg, var(--border), var(--border) 4px, transparent 4px, transparent 8px)",backgroundPosition:"left top",backgroundRepeat:"repeat-y",backgroundSize:"2px 100%"}}),n[5]=i):i=n[5];let l;return n[6]!==o?(l=m.jsxs("div",{className:"flex gap-2 items-start px-4 pb-3",children:[t,m.jsxs("div",{className:"flex flex-col border-1 border-transparent items-center shrink-0",children:[r,o,i]})]}),n[6]=o,n[7]=l):l=n[7],l}function Mw(){const n=I.c(5),e=jn();let t;n[0]!==e?(t=e?new URL(`/mcp/gateway/${e}`,window.location.origin).href:"",n[0]=e,n[1]=t):t=n[1];const r=t,s=!!e;let o;return n[2]!==r||n[3]!==s?(o={url:r,enabled:s},n[2]=r,n[3]=s,n[4]=o):o=n[4],zi(o)}function Aw(n){const e=I.c(7),{className:t}=n;if(!jn()){let o;e[0]!==t?(o=U("flex flex-col h-full bg-sidebar",t),e[0]=t,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground p-4 text-center",children:"Select a gateway to see available tools"}),e[2]=i):i=e[2];let l;return e[3]!==o?(l=m.jsx("div",{className:o,children:i}),e[3]=o,e[4]=l):l=e[4],l}let s;return e[5]!==t?(s=m.jsx(Ow,{className:t}),e[5]=t,e[6]=s):s=e[6],s}function Ow(n){const e=I.c(38),{className:t}=n,{tools:r,isLoading:s,error:o}=Mw(),i=hr(),{updateStep:l}=Me(),c=i&&"toolName"in i.action&&"toolName"in i.action?i.action.toolName:null;let d;if(e[0]!==c||e[1]!==r){let k;e[3]!==c?(k=w=>w.name===c,e[3]=c,e[4]=k):k=e[4],d=r.find(k),e[0]=c,e[1]=r,e[2]=d}else d=e[2];const f=ng(r,d??null,Rw,Iw);let h;e[5]!==i||e[6]!==l?(h=k=>{i&&l(i.name,{action:{...i.action,toolName:k.name},outputSchema:k.outputSchema??{}})},e[5]=i,e[6]=l,e[7]=h):h=e[7];const p=h;if(s){let k;e[8]!==t?(k=U("flex flex-col h-full bg-sidebar",t),e[8]=t,e[9]=k):k=e[9];let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=m.jsx("div",{className:"flex-1 flex items-center justify-center",children:m.jsx(Ds,{size:"sm"})}),e[10]=w):w=e[10];let C;return e[11]!==k?(C=m.jsx("div",{className:k,children:w}),e[11]=k,e[12]=C):C=e[12],C}if(o){let k;e[13]!==t?(k=U("flex flex-col h-full bg-sidebar",t),e[13]=t,e[14]=k):k=e[14];let w;e[15]!==o.message?(w=m.jsxs("div",{className:"flex-1 flex items-center justify-center text-sm text-destructive p-4 text-center",children:["Failed to load tools: ",o.message]}),e[15]=o.message,e[16]=w):w=e[16];let C;return e[17]!==k||e[18]!==w?(C=m.jsx("div",{className:k,children:w}),e[17]=k,e[18]=w,e[19]=C):C=e[19],C}let y;e[20]!==t?(y=U("flex flex-col h-full bg-sidebar",t),e[20]=t,e[21]=y):y=e[21];let g;e[22]===Symbol.for("react.memo_cache_sentinel")?(g=m.jsx("span",{className:"text-base font-medium text-foreground",children:"Select tool"}),e[22]=g):g=e[22];let x;e[23]!==r.length?(x=m.jsx("div",{className:"flex items-start border-b border-border",children:m.jsxs("div",{className:"flex-1 flex items-center h-12 px-5",children:[g,m.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:["(",r.length,")"]})]})}),e[23]=r.length,e[24]=x):x=e[24];let b;if(e[25]!==p||e[26]!==f||e[27]!==c){let k;e[29]!==p||e[30]!==c?(k=w=>m.jsx(jw,{icon:null,title:w.name,description:w.description,isSelected:w.name===c,onClick:()=>p(w)},w.name),e[29]=p,e[30]=c,e[31]=k):k=e[31],b=f.map(k),e[25]=p,e[26]=f,e[27]=c,e[28]=b}else b=e[28];let S;e[32]!==b?(S=m.jsx("div",{className:"flex-1 overflow-auto",children:b}),e[32]=b,e[33]=S):S=e[33];let v;return e[34]!==y||e[35]!==x||e[36]!==S?(v=m.jsxs("div",{className:y,children:[x,S]}),e[34]=y,e[35]=x,e[36]=S,e[37]=v):v=e[37],v}function Iw(n,e){return n.name.localeCompare(e.name)}function Rw(n){return n.name}function jw(n){const e=I.c(20),{icon:t,title:r,description:s,isSelected:o,onClick:i}=n,l=o&&"bg-muted/50";let a;e[0]!==l?(a=U("flex items-start gap-2.5 min-h-14 px-5 py-4 cursor-pointer transition-colors","hover:bg-muted/50",l),e[0]=l,e[1]=a):a=e[1];let c;e[2]!==i?(c=y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),i())},e[2]=i,e[3]=c):c=e[3];let d;e[4]!==t||e[5]!==r?(d=m.jsx(js,{icon:t,name:r,size:"xs",className:"shadow-sm mt-0.5"}),e[4]=t,e[5]=r,e[6]=d):d=e[6];let u;e[7]!==r?(u=m.jsx("span",{className:"text-sm font-medium text-foreground truncate block",children:r}),e[7]=r,e[8]=u):u=e[8];let f;e[9]!==s?(f=s&&m.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:s}),e[9]=s,e[10]=f):f=e[10];let h;e[11]!==u||e[12]!==f?(h=m.jsxs("div",{className:"flex-1 min-w-0",children:[u,f]}),e[11]=u,e[12]=f,e[13]=h):h=e[13];let p;return e[14]!==i||e[15]!==a||e[16]!==c||e[17]!==d||e[18]!==h?(p=m.jsxs("div",{className:a,onClick:i,role:"button",tabIndex:0,onKeyDown:c,children:[d,h]}),e[14]=i,e[15]=a,e[16]=c,e[17]=d,e[18]=h,e[19]=p):p=e[19],p}var Ue="Accordion",Dw=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Ll,Pw,Lw]=Ih(Ue),[Zs]=Mc(Ue,[Lw,$c]),$l=$c(),sh=ee.forwardRef((n,e)=>{const{type:t,...r}=n,s=r,o=r;return m.jsx(Ll.Provider,{scope:n.__scopeAccordion,children:t==="multiple"?m.jsx(Bw,{...o,ref:e}):m.jsx(_w,{...s,ref:e})})});sh.displayName=Ue;var[oh,$w]=Zs(Ue),[ih,zw]=Zs(Ue,{collapsible:!1}),_w=ee.forwardRef((n,e)=>{const{value:t,defaultValue:r,onValueChange:s=()=>{},collapsible:o=!1,...i}=n,[l,a]=Ei({prop:t,defaultProp:r??"",onChange:s,caller:Ue});return m.jsx(oh,{scope:n.__scopeAccordion,value:ee.useMemo(()=>l?[l]:[],[l]),onItemOpen:a,onItemClose:ee.useCallback(()=>o&&a(""),[o,a]),children:m.jsx(ih,{scope:n.__scopeAccordion,collapsible:o,children:m.jsx(lh,{...i,ref:e})})})}),Bw=ee.forwardRef((n,e)=>{const{value:t,defaultValue:r,onValueChange:s=()=>{},...o}=n,[i,l]=Ei({prop:t,defaultProp:r??[],onChange:s,caller:Ue}),a=ee.useCallback(d=>l((u=[])=>[...u,d]),[l]),c=ee.useCallback(d=>l((u=[])=>u.filter(f=>f!==d)),[l]);return m.jsx(oh,{scope:n.__scopeAccordion,value:i,onItemOpen:a,onItemClose:c,children:m.jsx(ih,{scope:n.__scopeAccordion,collapsible:!0,children:m.jsx(lh,{...o,ref:e})})})}),[Fw,eo]=Zs(Ue),lh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,disabled:r,dir:s,orientation:o="vertical",...i}=n,l=ee.useRef(null),a=Ic(l,e),c=Pw(t),u=Rh(s)==="ltr",f=Ge(n.onKeyDown,h=>{if(!Dw.includes(h.key))return;const p=h.target,y=c().filter(T=>!T.ref.current?.disabled),g=y.findIndex(T=>T.ref.current===p),x=y.length;if(g===-1)return;h.preventDefault();let b=g;const S=0,v=x-1,k=()=>{b=g+1,b>v&&(b=S)},w=()=>{b=g-1,b<S&&(b=v)};switch(h.key){case"Home":b=S;break;case"End":b=v;break;case"ArrowRight":o==="horizontal"&&(u?k():w());break;case"ArrowDown":o==="vertical"&&k();break;case"ArrowLeft":o==="horizontal"&&(u?w():k());break;case"ArrowUp":o==="vertical"&&w();break}const C=b%x;y[C].ref.current?.focus()});return m.jsx(Fw,{scope:t,disabled:r,direction:s,orientation:o,children:m.jsx(Ll.Slot,{scope:t,children:m.jsx(Ni.div,{...i,"data-orientation":o,ref:a,onKeyDown:r?void 0:f})})})}),Rs="AccordionItem",[Vw,zl]=Zs(Rs),ah=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,value:r,...s}=n,o=eo(Rs,t),i=$w(Rs,t),l=$l(t),a=Oh(),c=r&&i.value.includes(r)||!1,d=o.disabled||n.disabled;return m.jsx(Vw,{scope:t,open:c,disabled:d,triggerId:a,children:m.jsx(ep,{"data-orientation":o.orientation,"data-state":ph(c),...l,...s,ref:e,disabled:d,open:c,onOpenChange:u=>{u?i.onItemOpen(r):i.onItemClose(r)}})})});ah.displayName=Rs;var ch="AccordionHeader",dh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,...r}=n,s=eo(Ue,t),o=zl(ch,t);return m.jsx(Ni.h3,{"data-orientation":s.orientation,"data-state":ph(o.open),"data-disabled":o.disabled?"":void 0,...r,ref:e})});dh.displayName=ch;var vi="AccordionTrigger",uh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,...r}=n,s=eo(Ue,t),o=zl(vi,t),i=zw(vi,t),l=$l(t);return m.jsx(Ll.ItemSlot,{scope:t,children:m.jsx(np,{"aria-disabled":o.open&&!i.collapsible||void 0,"data-orientation":s.orientation,id:o.triggerId,...l,...r,ref:e})})});uh.displayName=vi;var fh="AccordionContent",hh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,...r}=n,s=eo(Ue,t),o=zl(fh,t),i=$l(t);return m.jsx(tp,{role:"region","aria-labelledby":o.triggerId,"data-orientation":s.orientation,...i,...r,ref:e,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...n.style}})});hh.displayName=fh;function ph(n){return n?"open":"closed"}var Hw=sh,Ww=ah,qw=dh,Uw=uh,Kw=hh;function Jw(n){const e=I.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=m.jsx(Hw,{"data-slot":"accordion",...t}),e[2]=t,e[3]=r):r=e[3],r}function Gw(n){const e=I.c(8);let t,r;e[0]!==n?({className:t,...r}=n,e[0]=n,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let s;e[3]!==t?(s=U("border-b last:border-b-0",t),e[3]=t,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=m.jsx(Ww,{"data-slot":"accordion-item",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}function Xw(n){const e=I.c(11);let t,r,s;e[0]!==n?({className:r,children:t,...s}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s):(t=e[1],r=e[2],s=e[3]);let o;e[4]!==r?(o=U("focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-center justify-between gap-4 py-4 text-left text-sm font-medium transition-all outline-none hover:bg-accent/50 focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-90",r),e[4]=r,e[5]=o):o=e[5];let i;e[6]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx(kp,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 transition-transform duration-200"}),e[6]=i):i=e[6];let l;return e[7]!==t||e[8]!==s||e[9]!==o?(l=m.jsx(qw,{className:"flex",children:m.jsxs(Uw,{"data-slot":"accordion-trigger",className:o,...s,children:[t,i]})}),e[7]=t,e[8]=s,e[9]=o,e[10]=l):l=e[10],l}function Yw(n){const e=I.c(12);let t,r,s;e[0]!==n?({className:r,children:t,...s}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s):(t=e[1],r=e[2],s=e[3]);let o;e[4]!==r?(o=U("pt-0 pb-4",r),e[4]=r,e[5]=o):o=e[5];let i;e[6]!==t||e[7]!==o?(i=m.jsx("div",{className:o,children:t}),e[6]=t,e[7]=o,e[8]=i):i=e[8];let l;return e[9]!==s||e[10]!==i?(l=m.jsx(Kw,{"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",...s,children:i}),e[9]=s,e[10]=i,e[11]=l):l=e[11],l}var Qw=(n,e,t,r,s,o,i,l)=>{let a=document.documentElement,c=["light","dark"];function d(h){(Array.isArray(n)?n:[n]).forEach(p=>{let y=p==="class",g=y&&o?s.map(x=>o[x]||x):s;y?(a.classList.remove(...g),a.classList.add(o&&o[h]?o[h]:h)):a.setAttribute(p,h)}),u(h)}function u(h){l&&c.includes(h)&&(a.style.colorScheme=h)}function f(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let h=localStorage.getItem(e)||t,p=i&&h==="system"?f():h;d(p)}catch{}};O.createContext(void 0);O.memo(({forcedTheme:n,storageKey:e,attribute:t,enableSystem:r,enableColorScheme:s,defaultTheme:o,value:i,themes:l,nonce:a,scriptProps:c})=>{let d=JSON.stringify([t,e,o,n,l,i,r,s]).slice(1,-1);return O.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?a:"",dangerouslySetInnerHTML:{__html:`(${Qw.toString()})(${d})`}})});function Zw(n){const{updateStep:e}=Me(),r=n&&"toolName"in n.action&&"toolName"in n.action?n.action.toolName:null,{tool:s}=_l(r??"");n&&r&&s?.outputSchema&&(!n.outputSchema||Object.keys(n.outputSchema).length===0)&&queueMicrotask(()=>{e(n.name,{outputSchema:s.outputSchema})})}function ev(n){const e=I.c(25),{className:t}=n,r=hr(),{appendStep:s}=Me();if(Zw(r),!r){let f;e[0]!==t?(f=U("flex flex-col h-full bg-sidebar",t),e[0]=t,e[1]=f):f=e[1];let h;e[2]!==s?(h=()=>{s({type:"tool"})},e[2]=s,e[3]=h):h=e[3];let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsx(zc,{size:14}),e[4]=p):p=e[4];let y;e[5]!==h?(y=m.jsxs("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground gap-2 flex-col",children:["Select or create a step to configure",m.jsx(me,{variant:"ghost",size:"icon",className:"size-7",onClick:h,children:p})]}),e[5]=h,e[6]=y):y=e[6];let g;return e[7]!==f||e[8]!==y?(g=m.jsx("div",{className:f,children:y}),e[7]=f,e[8]=y,e[9]=g):g=e[9],g}let o;e[10]!==t?(o=U("flex flex-col h-full bg-sidebar overflow-scroll",t),e[10]=t,e[11]=o):o=e[11];let i,l,a,c,d;e[12]!==r?(i=m.jsx(tv,{step:r}),l=m.jsx(rv,{step:r}),a=m.jsx(sv,{step:r}),c=m.jsx(av,{step:r}),d=m.jsx(uv,{step:r}),e[12]=r,e[13]=i,e[14]=l,e[15]=a,e[16]=c,e[17]=d):(i=e[13],l=e[14],a=e[15],c=e[16],d=e[17]);let u;return e[18]!==o||e[19]!==i||e[20]!==l||e[21]!==a||e[22]!==c||e[23]!==d?(u=m.jsxs("div",{className:o,children:[i,l,a,c,d]}),e[18]=o,e[19]=i,e[20]=l,e[21]=a,e[22]=c,e[23]=d,e[24]=u):u=e[24],u}function tv(n){const e=I.c(15),{step:t}=n,s="toolName"in t.action&&"toolName"in t.action?t.action.toolName:null,o=we(),i=s??"";let l;e[0]!==i?(l=m.jsx(js,{icon:null,name:i,size:"xs",className:"shadow-sm"}),e[0]=i,e[1]=l):l=e[1];let a;e[2]!==s?(a=m.jsx("span",{className:"text-base font-medium text-foreground truncate flex-1",children:s}),e[2]=s,e[3]=a):a=e[3];let c;e[4]!==o?(c=o?null:m.jsx(nv,{}),e[4]=o,e[5]=c):c=e[5];let d;e[6]!==l||e[7]!==a||e[8]!==c?(d=m.jsxs("div",{className:"flex items-center gap-2",children:[l,a,c]}),e[6]=l,e[7]=a,e[8]=c,e[9]=d):d=e[9];let u;e[10]!==t.description?(u=t.description&&m.jsx("p",{className:"text-sm text-muted-foreground",children:t.description}),e[10]=t.description,e[11]=u):u=e[11];let f;return e[12]!==d||e[13]!==u?(f=m.jsxs("div",{className:"border-b border-border p-5 shrink-0 flex flex-col gap-2",children:[d,u]}),e[12]=d,e[13]=u,e[14]=f):f=e[14],f}function nv(){const n=I.c(9),e=hr(),{updateStep:t,startReplacingTool:r}=Me(),s=we(),i=e&&"toolName"in e.action?e.action.toolName:null;let l;n[0]!==e||n[1]!==r||n[2]!==i||n[3]!==s||n[4]!==t?(l=()=>{if(e){if(s){Ec.error("You cannot replace a tool while a workflow is executing.");return}i&&r(i),t(e.name,{action:{...e.action,toolName:""}})}},n[0]=e,n[1]=r,n[2]=i,n[3]=s,n[4]=t,n[5]=l):l=n[5];const a=l;let c;n[6]===Symbol.for("react.memo_cache_sentinel")?(c=m.jsx(Qc,{size:14}),n[6]=c):c=n[6];let d;return n[7]!==a?(d=m.jsx(me,{variant:"ghost",size:"icon",className:"size-7",onClick:a,title:"Replace tool",children:c}),n[7]=a,n[8]=d):d=n[8],d}function _l(n){const e=I.c(13),t=jn();let r;e[0]!==t?(r=t?new URL(`/mcp/gateway/${t}`,window.location.origin).href:"",e[0]=t,e[1]=r):r=e[1];const s=r,o=!!t;let i;e[2]!==s||e[3]!==o?(i={url:s,enabled:o},e[2]=s,e[3]=o,e[4]=i):i=e[4];const l=zi(i);let a;e[5]!==l.tools||e[6]!==n?(a=l.tools?.find(h=>h.name===n),e[5]=l.tools,e[6]=n,e[7]=a):a=e[7];const c=a,d=l.state==="connecting",u=l.state==="ready";let f;return e[8]!==l.error||e[9]!==d||e[10]!==u||e[11]!==c?(f={tool:c,isLoading:d,isReady:u,error:l.error},e[8]=l.error,e[9]=d,e[10]=u,e[11]=c,e[12]=f):f=e[12],f}function rv(n){const e=I.c(13),{step:t}=n,{updateStep:r}=Me(),o="toolName"in t.action&&"toolName"in t.action?t.action.toolName:null,i=we(),{tool:l}=_l(o??"");if(!l||!l.inputSchema)return null;let a;e[0]!==t.name||e[1]!==r?(a=x=>{r(t.name,{input:x})},e[0]=t.name,e[1]=r,e[2]=a):a=e[2];const c=a,d=i?"output":"input";let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=m.jsx(Xw,{className:"px-5 py-5",children:m.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Input"})}),e[3]=u):u=e[3];const f=l.inputSchema,h=t.input;let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=[],e[4]=p):p=e[4];let y;e[5]!==c||e[6]!==t.name||e[7]!==f||e[8]!==h?(y=m.jsxs(Gw,{value:"input",className:"border-b-0",children:[u,m.jsx(Yw,{className:"px-5 pt-2",children:m.jsx(rh,{inputSchema:f,inputParams:h,setInputParams:c,mentions:p},t.name)})]}),e[5]=c,e[6]=t.name,e[7]=f,e[8]=h,e[9]=y):y=e[9];let g;return e[10]!==d||e[11]!==y?(g=m.jsx(Jw,{type:"single",collapsible:!0,defaultValue:d,className:"border-b border-border shrink-0",children:y}),e[10]=d,e[11]=y,e[12]=g):g=e[12],g}function sv(n){const e=I.c(24),{step:t}=n,r=t.outputSchema,[s,o]=O.useState(!1),i=we(),{item:l}=Pn(i),a=!!(l?.completed_steps?.success?.includes(t.name)||l?.completed_steps?.error?.includes(t.name)),{output:c,error:d}=Um(i,a?t.name:void 0);let u;e[0]!==d||e[1]!==c?(u=c||(d?{error:d}:void 0),e[0]=d,e[1]=c,e[2]=u):u=e[2];const f=u,h=r&&typeof r=="object"?r.properties:void 0;let p;e[3]!==h?(p=h?Object.entries(h):[],e[3]=h,e[4]=p):p=e[4];const y=p,g=s?"flex-1 min-h-0 overflow-hidden":"shrink-0";let x;e[5]!==g?(x=U("flex flex-col border-b border-border",g),e[5]=g,e[6]=x):x=e[6];let b;e[7]!==s?(b=()=>o(!s),e[7]=s,e[8]=b):b=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=m.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Output"}),e[9]=S):S=e[9];let v;e[10]!==s?(v=m.jsxs("div",{className:"flex items-center justify-between",children:[S,s?m.jsx(Wi,{size:14,className:"text-muted-foreground"}):m.jsx(Hi,{size:14,className:"text-muted-foreground"})]}),e[10]=s,e[11]=v):v=e[11];let k;e[12]!==b||e[13]!==v?(k=m.jsx("div",{className:"p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:b,children:v}),e[12]=b,e[13]=v,e[14]=k):k=e[14];let w;e[15]!==f||e[16]!==s||e[17]!==y||e[18]!==i?(w=s&&m.jsxs("div",{className:"flex-1 min-h-0 overflow-auto px-5",children:[i&&f?m.jsx(On,{code:JSON.stringify(f,null,2),language:"json",height:"100%",readOnly:!0}):null,!i&&y.map(ov)]}),e[15]=f,e[16]=s,e[17]=y,e[18]=i,e[19]=w):w=e[19];let C;return e[20]!==x||e[21]!==k||e[22]!==w?(C=m.jsxs("div",{className:x,children:[k,w]}),e[20]=x,e[21]=k,e[22]=w,e[23]=C):C=e[23],C}function ov(n){const[e,t]=n;return m.jsx(lv,{name:e,schema:t},e)}function iv(n){switch(n){case"string":return{Icon:Uc,color:"text-blue-500"};case"number":case"integer":return{Icon:Wc,color:"text-blue-500"};case"array":return{Icon:Fc,color:"text-purple-500"};case"object":return{Icon:Bc,color:"text-orange-500"};case"boolean":return{Icon:qc,color:"text-pink-500"};case"null":return{Icon:Ti,color:"text-gray-500"};default:return{Icon:Vc,color:"text-muted-foreground"}}}function lv(n){const e=I.c(28),{name:t,schema:r}=n,s=hr(),o=r.type??"unknown";let i,l,a,c,d;if(e[0]!==o){const{Icon:v,color:k}=iv(o);d="flex items-center gap-2",c="flex-1 flex items-center gap-2",i=v,l=14,a=U(k),e[0]=o,e[1]=i,e[2]=l,e[3]=a,e[4]=c,e[5]=d}else i=e[1],l=e[2],a=e[3],c=e[4],d=e[5];let u;e[6]!==i||e[7]!==l||e[8]!==a?(u=m.jsx(i,{size:l,className:a}),e[6]=i,e[7]=l,e[8]=a,e[9]=u):u=e[9];let f;e[10]!==t?(f=m.jsx("span",{className:"text-sm font-medium text-foreground",children:t}),e[10]=t,e[11]=f):f=e[11];let h;e[12]!==c||e[13]!==u||e[14]!==f?(h=m.jsxs("div",{className:c,children:[u,f]}),e[12]=c,e[13]=u,e[14]=f,e[15]=h):h=e[15];let p;e[16]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsx(Xc,{size:14,className:"opacity-50"}),e[16]=p):p=e[16];const y=s?.name;let g;e[17]!==y?(g=m.jsxs("span",{className:"text-muted-foreground",children:[y,"."]}),e[17]=y,e[18]=g):g=e[18];let x;e[19]!==t?(x=m.jsx("div",{className:"bg-blue-500/10 text-blue-500 px-1 py-0.5 rounded",children:t}),e[19]=t,e[20]=x):x=e[20];let b;e[21]!==g||e[22]!==x?(b=m.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[p,g,x]}),e[21]=g,e[22]=x,e[23]=b):b=e[23];let S;return e[24]!==b||e[25]!==d||e[26]!==h?(S=m.jsxs("div",{className:d,children:[h,b]}),e[24]=b,e[25]=d,e[26]=h,e[27]=S):S=e[27],S}function av(n){const e=I.c(29),{step:t}=n,{updateStep:r}=Me(),s=we(),[o,i]=O.useState(!1),l="toolName"in t.action,a=l&&"toolName"in t.action?t.action.toolName:null,{tool:c}=_l(a??""),d=l&&"transformCode"in t.action?t.action.transformCode??null:null;let u;e[0]!==c?(u=()=>{if(!c?.outputSchema)return`interface Input {
|
|
147
147
|
// Tool output schema not available
|
|
148
148
|
}`;const T=c.outputSchema,A=T.properties;return A?`interface Input {
|
|
149
149
|
${Object.entries(A).map(j=>{const[_,V]=j,B=_r(V),H=!T.required?.includes(_);return` ${_}${H?"?":""}: ${B};`}).join(`
|
|
150
150
|
`)}
|
|
151
151
|
}`:`interface Input {
|
|
152
152
|
[key: string]: unknown;
|
|
153
|
-
}`},e[0]=c,e[1]=u):u=e[1];const f=u;let h;e[2]!==f||e[3]!==t.action||e[4]!==t.name||e[5]!==r?(h=()=>{if("transformCode"in t.action&&t.action.transformCode){i(
|
|
153
|
+
}`},e[0]=c,e[1]=u):u=e[1];const f=u;let h;e[2]!==f||e[3]!==t.action||e[4]!==t.name||e[5]!==r?(h=()=>{if("transformCode"in t.action&&t.action.transformCode){i(dv);return}const A=`${f()}
|
|
154
154
|
|
|
155
155
|
interface Output {
|
|
156
156
|
// Define your output type here
|
|
@@ -162,4 +162,4 @@ export default async function(input: Input): Promise<Output> {
|
|
|
162
162
|
return {
|
|
163
163
|
result: input,
|
|
164
164
|
};
|
|
165
|
-
}`;r(t.name,{action:{...t.action,transformCode:A}}),i(tv)},e[2]=f,e[3]=t.action,e[4]=t.name,e[5]=r,e[6]=h):h=e[6];const p=h;let y;e[7]!==t.action||e[8]!==t.name||e[9]!==r?(y=(T,A)=>{r(t.name,{action:{...t.action,transformCode:T},...A?{outputSchema:A}:{}})},e[7]=t.action,e[8]=t.name,e[9]=r,e[10]=y):y=e[10];const g=y;if("code"in t.action&&t.action.code)return null;const x=o?"flex-1 min-h-0 overflow-hidden":"shrink-0";let b;e[11]!==x?(b=J("flex flex-col flex-1 min-h-0 overflow-hidden border-b border-border",x),e[11]=x,e[12]=b):b=e[12];let S;e[13]===Symbol.for("react.memo_cache_sentinel")?(S=m.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Transform Code"}),e[13]=S):S=e[13];let v;e[14]!==o?(v=m.jsxs("div",{className:"flex items-center justify-between",children:[S,o?m.jsx(Wi,{size:14,className:"text-muted-foreground"}):m.jsx(Hi,{size:14,className:"text-muted-foreground"})]}),e[14]=o,e[15]=v):v=e[15];let k;e[16]!==v||e[17]!==p?(k=m.jsx("div",{className:"p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:p,children:v}),e[16]=v,e[17]=p,e[18]=k):k=e[18];let w;e[19]!==g||e[20]!==o||e[21]!==t.name||e[22]!==s||e[23]!==d?(w=o&&m.jsx("div",{className:"flex-1 min-h-0",children:m.jsx(On,{code:d,language:"typescript",readOnly:s!==void 0,onSave:g,height:"100%"},`transform-code-${t.name}-${s}`)}),e[19]=g,e[20]=o,e[21]=t.name,e[22]=s,e[23]=d,e[24]=w):w=e[24];let C;return e[25]!==b||e[26]!==k||e[27]!==w?(C=m.jsxs("div",{className:b,children:[k,w]}),e[25]=b,e[26]=k,e[27]=w,e[28]=C):C=e[28],C}function tv(n){return!n}function nv(n){return!n}function rv(n){const e=I.c(24),{step:t}=n,[r,s]=O.useState(!1),{updateStep:o}=Me(),i="code"in t.action&&t.action.code?t.action.code:null,l=Se();let a;e[0]!==t.action||e[1]!==t.name||e[2]!==o?(a=(b,S)=>{o(t.name,{action:{...t.action,code:b},...S?{outputSchema:S}:{}})},e[0]=t.action,e[1]=t.name,e[2]=o,e[3]=a):a=e[3];const c=a;if(!i)return null;const d=r?"flex-1 min-h-0 overflow-hidden":"shrink-0";let u;e[4]!==d?(u=J("flex flex-col border-b border-border",d),e[4]=d,e[5]=u):u=e[5];let f;e[6]!==r?(f=()=>s(!r),e[6]=r,e[7]=f):f=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=m.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Step Code"}),e[8]=h):h=e[8];let p;e[9]!==r?(p=m.jsxs("div",{className:"flex items-center justify-between",children:[h,r?m.jsx(Wi,{size:14,className:"text-muted-foreground"}):m.jsx(Hi,{size:14,className:"text-muted-foreground"})]}),e[9]=r,e[10]=p):p=e[10];let y;e[11]!==f||e[12]!==p?(y=m.jsx("div",{className:"p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:f,children:p}),e[11]=f,e[12]=p,e[13]=y):y=e[13];let g;e[14]!==i||e[15]!==c||e[16]!==r||e[17]!==t.name||e[18]!==l?(g=r&&m.jsx("div",{className:"flex-1 min-h-0",children:m.jsx(On,{onSave:(b,S)=>c(b,S),code:i,language:"typescript",height:"100%",readOnly:l!==void 0},`step-code-${t.name}-${l}`)}),e[14]=i,e[15]=c,e[16]=r,e[17]=t.name,e[18]=l,e[19]=g):g=e[19];let x;return e[20]!==u||e[21]!==y||e[22]!==g?(x=m.jsxs("div",{className:u,children:[y,g]}),e[20]=u,e[21]=y,e[22]=g,e[23]=x):x=e[23],x}function _r(n){if(Array.isArray(n.type))return n.type.map(t=>_r({...n,type:t})).join(" | ");switch(n.type){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"array":return n.items?`${_r(n.items)}[]`:"unknown[]";case"object":return n.properties?`{ ${Object.entries(n.properties).map(([r,s])=>{const o=_r(s),i=!n.required?.includes(r);return`${r}${i?"?":""}: ${o}`}).join("; ")} }`:"Record<string, unknown>";case"null":return"null";default:return"unknown"}}function sv(n){switch(n){case"success":return m.jsxs(un,{variant:"success",className:"gap-1",children:[m.jsx(Vi,{size:11}),"Success"]});case"error":case"failed":return m.jsxs(un,{variant:"destructive",className:"gap-1",children:[m.jsx(qi,{size:11}),"Error"]});case"running":return m.jsxs(un,{variant:"secondary",className:"gap-1",children:[m.jsx(jr,{size:11}),"Running"]});case"enqueued":return m.jsxs(un,{variant:"secondary",className:"gap-1",children:[m.jsx(jr,{size:11}),"On hold"]});case"cancelled":return m.jsxs(un,{variant:"secondary",className:"gap-1",children:[m.jsx(_c,{size:11}),"Cancelled"]});default:return m.jsxs(un,{variant:"secondary",className:"gap-1",children:[m.jsx(jr,{size:11}),n]})}}function ov(n){return`Run #${n.slice(-4).toUpperCase()}`}function iv(n){const e=I.c(21),{className:t}=n,{executions:r,isLoading:s}=Bm(),{setShowExecutionsList:o}=Ji(),{setTrackingExecutionId:i}=Me(),l=Se();let a;e[0]!==i?(a=S=>{i(S)},e[0]=i,e[1]=a):a=e[1];const c=a;let d;e[2]!==o?(d=()=>{o(!1)},e[2]=o,e[3]=d):d=e[3];const u=d;let f;e[4]!==t?(f=J("flex flex-col h-full bg-sidebar border-l border-border",t),e[4]=t,e[5]=f):f=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=m.jsx("p",{className:"flex-1 text-base font-medium text-foreground",children:"Runs"}),e[6]=h):h=e[6];let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsx(_c,{size:11}),e[7]=p):p=e[7];let y;e[8]!==u?(y=m.jsxs("div",{className:"flex items-center h-12 px-5 border-b border-border shrink-0",children:[h,m.jsx(me,{variant:"ghost",size:"icon",className:"size-7",onClick:u,children:p})]}),e[8]=u,e[9]=y):y=e[9];let g;e[10]!==r||e[11]!==c||e[12]!==s||e[13]!==l?(g=s?m.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Loading executions..."}):r.map((S,v)=>m.jsx(lv,{execution:S,isSelected:S.id===l,isFirst:v===0,onSelect:()=>c(S.id)},S.id)),e[10]=r,e[11]=c,e[12]=s,e[13]=l,e[14]=g):g=e[14];let x;e[15]!==g?(x=m.jsx("div",{className:"flex-1 overflow-auto",children:g}),e[15]=g,e[16]=x):x=e[16];let b;return e[17]!==f||e[18]!==y||e[19]!==x?(b=m.jsxs("div",{className:f,children:[y,x]}),e[17]=f,e[18]=y,e[19]=x,e[20]=b):b=e[20],b}function lv(n){const e=I.c(17),{execution:t,isSelected:r,isFirst:s,onSelect:o}=n,i=r&&"bg-accent/50",l=s&&r&&"bg-accent/50",a=!r&&"hover:bg-accent/30";let c;e[0]!==i||e[1]!==l||e[2]!==a?(c=J("flex flex-col justify-center h-[60px] px-4 border-b border-border cursor-pointer transition-colors",i,l,a),e[0]=i,e[1]=l,e[2]=a,e[3]=c):c=e[3];let d;e[4]!==t.status?(d=sv(t.status),e[4]=t.status,e[5]=d):d=e[5];let u;e[6]!==t.id?(u=ov(t.id),e[6]=t.id,e[7]=u):u=e[7];let f;e[8]!==u?(f=m.jsx("p",{className:"flex-1 text-base font-medium text-foreground",children:u}),e[8]=u,e[9]=f):f=e[9];let h;e[10]!==d||e[11]!==f?(h=m.jsxs("div",{className:"flex items-center gap-2 w-full",children:[d,f]}),e[10]=d,e[11]=f,e[12]=h):h=e[12];let p;return e[13]!==o||e[14]!==c||e[15]!==h?(p=m.jsx("div",{className:c,onClick:o,children:h}),e[13]=o,e[14]=c,e[15]=h,e[16]=p):p=e[16],p}function av(n){const e=I.c(9),{itemId:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},e[0]=r):r=e[0];const{connectionId:s}=Et(r),o=s??qt;let i;e[1]!==o?(i=qe(o),e[1]=o,e[2]=i):i=e[2];const l=i,a=Mi(o,"WORKFLOW",t,l),c=Ai(o,"WORKFLOW",l);let d;e[3]!==c||e[4]!==t?(d=async h=>{await c.update.mutateAsync({id:t,data:h})},e[3]=c,e[4]=t,e[5]=d):d=e[5];const u=d;let f;return e[6]!==a||e[7]!==u?(f={item:a,update:u},e[6]=a,e[7]=u,e[8]=f):f=e[8],f}function cv(n){const e=I.c(18),{workflow:t,onUpdate:r}=n,{setWorkflow:s}=Me();let o,i,l,a;if(e[0]!==t.description||e[1]!==t.id||e[2]!==t.steps||e[3]!==t.title){const u={title:t.title,description:t.description,steps:t.steps};o=On,i=`workflow-${t.id}`,l="100%",a=JSON.stringify(u,null,2),e[0]=t.description,e[1]=t.id,e[2]=t.steps,e[3]=t.title,e[4]=o,e[5]=i,e[6]=l,e[7]=a}else o=e[4],i=e[5],l=e[6],a=e[7];let c;e[8]!==r||e[9]!==s||e[10]!==t?(c=u=>{const f=JSON.parse(u);s({...t,...f}),r(f)},e[8]=r,e[9]=s,e[10]=t,e[11]=c):c=e[11];let d;return e[12]!==o||e[13]!==i||e[14]!==l||e[15]!==a||e[16]!==c?(d=m.jsx(o,{height:l,code:a,language:"json",onSave:c},i),e[12]=o,e[13]=i,e[14]=l,e[15]=a,e[16]=c,e[17]=d):d=e[17],d}function dv(){const n=I.c(12),{setTrackingExecutionId:e}=Me(),t=Se();let r;n[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"flex items-center justify-center h-full w-12",children:m.jsx(jh,{className:"w-4 h-4 text-muted-foreground"})}),n[0]=r):r=n[0];let s;n[1]===Symbol.for("react.memo_cache_sentinel")?(s=m.jsx("strong",{className:"text-base text-foreground",children:"Run"}),n[1]=s):s=n[1];let o;n[2]!==t?(o=m.jsxs("div",{className:"flex items-center h-full",children:[r,m.jsxs("p",{className:"flex gap-3 items-center h-full",children:[s,m.jsxs("span",{className:"text-sm text-muted-foreground",children:["#",t]})]})]}),n[2]=t,n[3]=o):o=n[3];let i;n[4]!==e?(i=()=>e(void 0),n[4]=e,n[5]=i):i=n[5];let l;n[6]===Symbol.for("react.memo_cache_sentinel")?(l=m.jsx(Ti,{className:"w-4 h-4 text-muted-foreground"}),n[6]=l):l=n[6];let a;n[7]!==i?(a=m.jsx(me,{variant:"ghost",size:"xs",onClick:i,children:l}),n[7]=i,n[8]=a):a=n[8];let c;return n[9]!==o||n[10]!==a?(c=m.jsxs("div",{className:"h-10 bg-accent flex items-center justify-between border-b border-border",children:[o,a]}),n[9]=o,n[10]=a,n[11]=c):c=n[11],c}function uv(n){const e=I.c(17),{onBack:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},e[0]=r):r=e[0];const{itemId:s}=Et(r);let o;e[1]!==s?(o={itemId:s},e[1]=s,e[2]=o):o=e[2];const{item:i,update:l}=av(o);let a;e[3]!==i?(a=JSON.stringify(i),e[3]=i,e[4]=a):a=e[4];const c=a;if(!i){let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=m.jsx("div",{className:"flex h-full w-full bg-background",children:m.jsx(_i,{icon:m.jsx(Hc,{className:"w-10 h-10 text-muted-foreground"}),title:"Workflow not found",description:"This workflow may have been deleted or you may not have access to it."})}),e[5]=h):h=e[5];let p;return e[6]!==t?(p=m.jsx(Sn,{onBack:t,children:h}),e[6]=t,e[7]=p):p=e[7],p}let d;e[8]!==i?(d={workflow:i,trackingExecutionId:void 0,currentStepTab:"input"},e[8]=i,e[9]=d):d=e[9];let u;e[10]!==t||e[11]!==l?(u=m.jsx(fv,{onBack:t,onUpdate:l}),e[10]=t,e[11]=l,e[12]=u):u=e[12];let f;return e[13]!==c||e[14]!==d||e[15]!==u?(f=m.jsx(Om,{initialState:d,children:u},c),e[13]=c,e[14]=d,e[15]=u,e[16]=f):f=e[16],f}function fv(n){const e=I.c(24),{onBack:t,onUpdate:r}=n,s=Rn(),o=Se(),{setOriginalWorkflow:i}=Me(),{viewMode:l,showExecutionsList:a}=Ji(),c=hr();let d;e[0]!==r||e[1]!==i||e[2]!==s?(d=async()=>{await r(s),i(s)},e[0]=r,e[1]=i,e[2]=s,e[3]=d):d=e[3];const u=d,f=c&&"toolName"in c.action,h=f?c.action.toolName:null,p=f&&!h&&!o,y=!p&&(c||o||!a);let g;e[4]!==u||e[5]!==s.description||e[6]!==s.title?(g=m.jsx(ew,{title:s.title,description:s.description,onSave:u}),e[4]=u,e[5]=s.description,e[6]=s.title,e[7]=g):g=e[7];let x;e[8]!==o?(x=o&&m.jsx(dv,{}),e[8]=o,e[9]=x):x=e[9];let b;e[10]!==r||e[11]!==a||e[12]!==y||e[13]!==p||e[14]!==l||e[15]!==s?(b=m.jsx("div",{className:"flex-1 overflow-hidden",children:l==="code"?m.jsx(cv,{workflow:s,onUpdate:r}):m.jsxs(Xh,{direction:"horizontal",className:"flex w-full h-full",children:[m.jsx(Bl,{defaultSize:50,minSize:30,children:m.jsx(xw,{})}),m.jsx(Yh,{}),m.jsxs(Bl,{defaultSize:50,minSize:25,children:[p&&m.jsx(Sw,{className:"border-l border-border"}),a&&m.jsx(iv,{}),y&&m.jsx(Uw,{className:"border-l border-border"})]})]})}),e[10]=r,e[11]=a,e[12]=y,e[13]=p,e[14]=l,e[15]=s,e[16]=b):b=e[16];let S;e[17]!==g||e[18]!==x||e[19]!==b?(S=m.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-background",children:[g,x,b]}),e[17]=g,e[18]=x,e[19]=b,e[20]=S):S=e[20];let v;return e[21]!==t||e[22]!==S?(v=m.jsx(Sn,{onBack:t,children:S}),e[21]=t,e[22]=S,e[23]=v):v=e[23],v}function hv(n){const e=I.c(5),{itemId:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},e[0]=r):r=e[0];const{connectionId:s}=Et(r),o=s??qt;let i;e[1]!==o?(i=qe(o),e[1]=o,e[2]=i):i=e[2];const a=Mi(o,"WORKFLOW_EXECUTION",t,i);let c;return e[3]!==a?(c={item:a},e[3]=a,e[4]=c):c=e[4],c}function pv(n){const e=I.c(13),{onBack:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},e[0]=r):r=e[0];const{itemId:s}=Et(r);let o;e[1]!==s?(o={itemId:s},e[1]=s,e[2]=o):o=e[2];const{item:i}=hv(o);if(!i){let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=m.jsx("div",{className:"flex h-full w-full bg-background",children:m.jsx(_i,{icon:m.jsx(Hc,{className:"w-10 h-10 text-muted-foreground"}),title:"Workflow execution not found",description:"This workflow execution may have been deleted or you may not have access to it."})}),e[3]=d):d=e[3];let u;return e[4]!==t?(u=m.jsx(Sn,{onBack:t,children:d}),e[4]=t,e[5]=u):u=e[5],u}let l;e[6]!==i?(l=JSON.stringify(i,null,2),e[6]=i,e[7]=l):l=e[7];let a;e[8]!==l?(a=m.jsx("div",{className:"flex flex-col h-full overflow-hidden bg-background",children:m.jsx(On,{height:"100%",code:l,language:"json",readOnly:!0})}),e[8]=l,e[9]=a):a=e[9];let c;return e[10]!==t||e[11]!==a?(c=m.jsx(Sn,{onBack:t,children:a}),e[10]=t,e[11]=a,e[12]=c):c=e[12],c}const mv={workflow:uv,workflow_execution:pv,prompt:cm};function gv(){const n=I.c(6),e=Rc();let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},n[0]=t):t=n[0];const r=Et(t),s=decodeURIComponent(r.itemId);let o;n[1]!==e.history?(o=()=>{e.history.back()},n[1]=e.history,n[2]=o):o=n[2];const i=o,l=yv;let a;return n[3]!==i||n[4]!==s?(a=m.jsx(ym,{itemId:s,onBack:i,onUpdate:l}),n[3]=i,n[4]=s,n[5]=a):a=n[5],a}async function yv(n){return Promise.resolve()}function xv(){const n=I.c(18),e=Rc();let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},n[0]=t):t=n[0];const r=Et(t),s=r.connectionId,o=decodeURIComponent(r.collectionName),i=decodeURIComponent(r.itemId);let l;n[1]!==e.history?(l=()=>{e.history.back()},n[1]=e.history,n[2]=l):l=n[2];const a=l,c=s??qt;let d;n[3]!==c?(d=qe(c),n[3]=c,n[4]=d):d=n[4];const f=Ai(c,o,d);let h;n[5]!==f||n[6]!==i?(h=async v=>{i&&await f.update.mutateAsync({id:i,data:v})},n[5]=f,n[6]=i,n[7]=h):h=n[7];const p=h;let y;n[8]!==o?(y=o?.toLowerCase(),n[8]=o,n[9]=y):y=n[9];const g=y,x=g&&mv[g];if(x){let v;return n[10]!==x||n[11]!==a||n[12]!==p||n[13]!==i?(v=m.jsx(x,{itemId:i,onBack:a,onUpdate:p}),n[10]=x,n[11]=a,n[12]=p,n[13]=i,n[14]=v):v=n[14],v}let b;n[15]===Symbol.for("react.memo_cache_sentinel")?(b=m.jsx(Ph,{size:36,className:"text-muted-foreground"}),n[15]=b):b=n[15];let S;return n[16]!==a?(S=m.jsx(_i,{icon:b,title:"No component defined",description:"No component for this collection was defined",buttonProps:{onClick:a,children:"Go back"}}),n[16]=a,n[17]=S):S=n[17],S}function bv(){const n=I.c(3);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},n[0]=e):e=n[0];const t=Et(e);if(decodeURIComponent(t.collectionName)==="tools"){let i;return n[1]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx(gv,{}),n[1]=i):i=n[1],i}let o;return n[2]===Symbol.for("react.memo_cache_sentinel")?(o=m.jsx(xv,{}),n[2]=o):o=n[2],o}function M2(){const n=I.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=m.jsx(Dc,{children:m.jsx(O.Suspense,{fallback:m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsx(tr,{size:32,className:"animate-spin text-muted-foreground"})}),children:m.jsx(bv,{})})}),n[0]=e):e=n[0],e}export{M2 as default};
|
|
165
|
+
}`;r(t.name,{action:{...t.action,transformCode:A}}),i(cv)},e[2]=f,e[3]=t.action,e[4]=t.name,e[5]=r,e[6]=h):h=e[6];const p=h;let y;e[7]!==t.action||e[8]!==t.name||e[9]!==r?(y=(T,A)=>{r(t.name,{action:{...t.action,transformCode:T},...A?{outputSchema:A}:{}})},e[7]=t.action,e[8]=t.name,e[9]=r,e[10]=y):y=e[10];const g=y;if("code"in t.action&&t.action.code)return null;const x=o?"flex-1 min-h-0 overflow-hidden":"shrink-0";let b;e[11]!==x?(b=U("flex flex-col flex-1 min-h-0 overflow-hidden border-b border-border",x),e[11]=x,e[12]=b):b=e[12];let S;e[13]===Symbol.for("react.memo_cache_sentinel")?(S=m.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Transform Code"}),e[13]=S):S=e[13];let v;e[14]!==o?(v=m.jsxs("div",{className:"flex items-center justify-between",children:[S,o?m.jsx(Wi,{size:14,className:"text-muted-foreground"}):m.jsx(Hi,{size:14,className:"text-muted-foreground"})]}),e[14]=o,e[15]=v):v=e[15];let k;e[16]!==v||e[17]!==p?(k=m.jsx("div",{className:"p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:p,children:v}),e[16]=v,e[17]=p,e[18]=k):k=e[18];let w;e[19]!==g||e[20]!==o||e[21]!==t.name||e[22]!==s||e[23]!==d?(w=o&&m.jsx("div",{className:"flex-1 min-h-0",children:m.jsx(On,{code:d,language:"typescript",readOnly:s!==void 0,onSave:g,height:"100%"},`transform-code-${t.name}-${s}`)}),e[19]=g,e[20]=o,e[21]=t.name,e[22]=s,e[23]=d,e[24]=w):w=e[24];let C;return e[25]!==b||e[26]!==k||e[27]!==w?(C=m.jsxs("div",{className:b,children:[k,w]}),e[25]=b,e[26]=k,e[27]=w,e[28]=C):C=e[28],C}function cv(n){return!n}function dv(n){return!n}function uv(n){const e=I.c(24),{step:t}=n,[r,s]=O.useState(!1),{updateStep:o}=Me(),i="code"in t.action&&t.action.code?t.action.code:null,l=we();let a;e[0]!==t.action||e[1]!==t.name||e[2]!==o?(a=(b,S)=>{o(t.name,{action:{...t.action,code:b},...S?{outputSchema:S}:{}})},e[0]=t.action,e[1]=t.name,e[2]=o,e[3]=a):a=e[3];const c=a;if(!i)return null;const d=r?"flex-1 min-h-0 overflow-hidden":"shrink-0";let u;e[4]!==d?(u=U("flex flex-col border-b border-border",d),e[4]=d,e[5]=u):u=e[5];let f;e[6]!==r?(f=()=>s(!r),e[6]=r,e[7]=f):f=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=m.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Step Code"}),e[8]=h):h=e[8];let p;e[9]!==r?(p=m.jsxs("div",{className:"flex items-center justify-between",children:[h,r?m.jsx(Wi,{size:14,className:"text-muted-foreground"}):m.jsx(Hi,{size:14,className:"text-muted-foreground"})]}),e[9]=r,e[10]=p):p=e[10];let y;e[11]!==f||e[12]!==p?(y=m.jsx("div",{className:"p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:f,children:p}),e[11]=f,e[12]=p,e[13]=y):y=e[13];let g;e[14]!==i||e[15]!==c||e[16]!==r||e[17]!==t.name||e[18]!==l?(g=r&&m.jsx("div",{className:"flex-1 min-h-0",children:m.jsx(On,{onSave:(b,S)=>c(b,S),code:i,language:"typescript",height:"100%",readOnly:l!==void 0},`step-code-${t.name}-${l}`)}),e[14]=i,e[15]=c,e[16]=r,e[17]=t.name,e[18]=l,e[19]=g):g=e[19];let x;return e[20]!==u||e[21]!==y||e[22]!==g?(x=m.jsxs("div",{className:u,children:[y,g]}),e[20]=u,e[21]=y,e[22]=g,e[23]=x):x=e[23],x}function _r(n){if(Array.isArray(n.type))return n.type.map(t=>_r({...n,type:t})).join(" | ");switch(n.type){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"array":return n.items?`${_r(n.items)}[]`:"unknown[]";case"object":return n.properties?`{ ${Object.entries(n.properties).map(([r,s])=>{const o=_r(s),i=!n.required?.includes(r);return`${r}${i?"?":""}: ${o}`}).join("; ")} }`:"Record<string, unknown>";case"null":return"null";default:return"unknown"}}function fv(n){switch(n){case"success":return m.jsxs(un,{variant:"success",className:"gap-1",children:[m.jsx(Vi,{size:11}),"Success"]});case"error":case"failed":return m.jsxs(un,{variant:"destructive",className:"gap-1",children:[m.jsx(qi,{size:11}),"Error"]});case"running":return m.jsxs(un,{variant:"secondary",className:"gap-1",children:[m.jsx(jr,{size:11}),"Running"]});case"enqueued":return m.jsxs(un,{variant:"secondary",className:"gap-1",children:[m.jsx(jr,{size:11}),"On hold"]});case"cancelled":return m.jsxs(un,{variant:"secondary",className:"gap-1",children:[m.jsx(_c,{size:11}),"Cancelled"]});default:return m.jsxs(un,{variant:"secondary",className:"gap-1",children:[m.jsx(jr,{size:11}),n]})}}function hv(n){return`Run #${n.slice(-4).toUpperCase()}`}function pv(n){const e=I.c(21),{className:t}=n,{executions:r,isLoading:s}=Km(),{setShowExecutionsList:o}=Ji(),{setTrackingExecutionId:i}=Me(),l=we();let a;e[0]!==i?(a=S=>{i(S)},e[0]=i,e[1]=a):a=e[1];const c=a;let d;e[2]!==o?(d=()=>{o(!1)},e[2]=o,e[3]=d):d=e[3];const u=d;let f;e[4]!==t?(f=U("flex flex-col h-full bg-sidebar border-l border-border",t),e[4]=t,e[5]=f):f=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=m.jsx("p",{className:"flex-1 text-base font-medium text-foreground",children:"Runs"}),e[6]=h):h=e[6];let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsx(_c,{size:11}),e[7]=p):p=e[7];let y;e[8]!==u?(y=m.jsxs("div",{className:"flex items-center h-12 px-5 border-b border-border shrink-0",children:[h,m.jsx(me,{variant:"ghost",size:"icon",className:"size-7",onClick:u,children:p})]}),e[8]=u,e[9]=y):y=e[9];let g;e[10]!==r||e[11]!==c||e[12]!==s||e[13]!==l?(g=s?m.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Loading executions..."}):r.map((S,v)=>m.jsx(mv,{execution:S,isSelected:S.id===l,isFirst:v===0,onSelect:()=>c(S.id)},S.id)),e[10]=r,e[11]=c,e[12]=s,e[13]=l,e[14]=g):g=e[14];let x;e[15]!==g?(x=m.jsx("div",{className:"flex-1 overflow-auto",children:g}),e[15]=g,e[16]=x):x=e[16];let b;return e[17]!==f||e[18]!==y||e[19]!==x?(b=m.jsxs("div",{className:f,children:[y,x]}),e[17]=f,e[18]=y,e[19]=x,e[20]=b):b=e[20],b}function mv(n){const e=I.c(17),{execution:t,isSelected:r,isFirst:s,onSelect:o}=n,i=r&&"bg-accent/50",l=s&&r&&"bg-accent/50",a=!r&&"hover:bg-accent/30";let c;e[0]!==i||e[1]!==l||e[2]!==a?(c=U("flex flex-col justify-center h-[60px] px-4 border-b border-border cursor-pointer transition-colors",i,l,a),e[0]=i,e[1]=l,e[2]=a,e[3]=c):c=e[3];let d;e[4]!==t.status?(d=fv(t.status),e[4]=t.status,e[5]=d):d=e[5];let u;e[6]!==t.id?(u=hv(t.id),e[6]=t.id,e[7]=u):u=e[7];let f;e[8]!==u?(f=m.jsx("p",{className:"flex-1 text-base font-medium text-foreground",children:u}),e[8]=u,e[9]=f):f=e[9];let h;e[10]!==d||e[11]!==f?(h=m.jsxs("div",{className:"flex items-center gap-2 w-full",children:[d,f]}),e[10]=d,e[11]=f,e[12]=h):h=e[12];let p;return e[13]!==o||e[14]!==c||e[15]!==h?(p=m.jsx("div",{className:c,onClick:o,children:h}),e[13]=o,e[14]=c,e[15]=h,e[16]=p):p=e[16],p}function gv(n){const e=I.c(9),{itemId:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},e[0]=r):r=e[0];const{connectionId:s}=Et(r),o=s??qt;let i;e[1]!==o?(i=qe(o),e[1]=o,e[2]=i):i=e[2];const l=i,a=Mi(o,"WORKFLOW",t,l),c=Ai(o,"WORKFLOW",l);let d;e[3]!==c||e[4]!==t?(d=async h=>{await c.update.mutateAsync({id:t,data:h})},e[3]=c,e[4]=t,e[5]=d):d=e[5];const u=d;let f;return e[6]!==a||e[7]!==u?(f={item:a,update:u},e[6]=a,e[7]=u,e[8]=f):f=e[8],f}function yv(n){const e=I.c(18),{workflow:t,onUpdate:r}=n,{setWorkflow:s}=Me();let o,i,l,a;if(e[0]!==t.description||e[1]!==t.id||e[2]!==t.steps||e[3]!==t.title){const u={title:t.title,description:t.description,steps:t.steps};o=On,i=`workflow-${t.id}`,l="100%",a=JSON.stringify(u,null,2),e[0]=t.description,e[1]=t.id,e[2]=t.steps,e[3]=t.title,e[4]=o,e[5]=i,e[6]=l,e[7]=a}else o=e[4],i=e[5],l=e[6],a=e[7];let c;e[8]!==r||e[9]!==s||e[10]!==t?(c=u=>{const f=JSON.parse(u);s({...t,...f}),r(f)},e[8]=r,e[9]=s,e[10]=t,e[11]=c):c=e[11];let d;return e[12]!==o||e[13]!==i||e[14]!==l||e[15]!==a||e[16]!==c?(d=m.jsx(o,{height:l,code:a,language:"json",onSave:c},i),e[12]=o,e[13]=i,e[14]=l,e[15]=a,e[16]=c,e[17]=d):d=e[17],d}function xv(){const n=I.c(12),{setTrackingExecutionId:e}=Me(),t=we();let r;n[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"flex items-center justify-center h-full w-12",children:m.jsx(jh,{className:"w-4 h-4 text-muted-foreground"})}),n[0]=r):r=n[0];let s;n[1]===Symbol.for("react.memo_cache_sentinel")?(s=m.jsx("strong",{className:"text-base text-foreground",children:"Run"}),n[1]=s):s=n[1];let o;n[2]!==t?(o=m.jsxs("div",{className:"flex items-center h-full",children:[r,m.jsxs("p",{className:"flex gap-3 items-center h-full",children:[s,m.jsxs("span",{className:"text-sm text-muted-foreground",children:["#",t]})]})]}),n[2]=t,n[3]=o):o=n[3];let i;n[4]!==e?(i=()=>e(void 0),n[4]=e,n[5]=i):i=n[5];let l;n[6]===Symbol.for("react.memo_cache_sentinel")?(l=m.jsx(Ti,{className:"w-4 h-4 text-muted-foreground"}),n[6]=l):l=n[6];let a;n[7]!==i?(a=m.jsx(me,{variant:"ghost",size:"xs",onClick:i,children:l}),n[7]=i,n[8]=a):a=n[8];let c;return n[9]!==o||n[10]!==a?(c=m.jsxs("div",{className:"h-10 bg-accent flex items-center justify-between border-b border-border",children:[o,a]}),n[9]=o,n[10]=a,n[11]=c):c=n[11],c}function bv(n){const e=I.c(17),{onBack:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},e[0]=r):r=e[0];const{itemId:s}=Et(r);let o;e[1]!==s?(o={itemId:s},e[1]=s,e[2]=o):o=e[2];const{item:i,update:l}=gv(o);let a;e[3]!==i?(a=JSON.stringify(i),e[3]=i,e[4]=a):a=e[4];const c=a;if(!i){let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=m.jsx("div",{className:"flex h-full w-full bg-background",children:m.jsx(_i,{icon:m.jsx(Hc,{className:"w-10 h-10 text-muted-foreground"}),title:"Workflow not found",description:"This workflow may have been deleted or you may not have access to it."})}),e[5]=h):h=e[5];let p;return e[6]!==t?(p=m.jsx(Sn,{onBack:t,children:h}),e[6]=t,e[7]=p):p=e[7],p}let d;e[8]!==i?(d={workflow:i,trackingExecutionId:void 0,currentStepTab:"input"},e[8]=i,e[9]=d):d=e[9];let u;e[10]!==t||e[11]!==l?(u=m.jsx(kv,{onBack:t,onUpdate:l}),e[10]=t,e[11]=l,e[12]=u):u=e[12];let f;return e[13]!==c||e[14]!==d||e[15]!==u?(f=m.jsx(Pm,{initialState:d,children:u},c),e[13]=c,e[14]=d,e[15]=u,e[16]=f):f=e[16],f}function kv(n){const e=I.c(24),{onBack:t,onUpdate:r}=n,s=Rn(),o=we(),{setOriginalWorkflow:i}=Me(),{viewMode:l,showExecutionsList:a}=Ji(),c=hr();let d;e[0]!==r||e[1]!==i||e[2]!==s?(d=async()=>{await r(s),i(s)},e[0]=r,e[1]=i,e[2]=s,e[3]=d):d=e[3];const u=d,f=c&&"toolName"in c.action,h=f?c.action.toolName:null,p=f&&!h&&!o,y=!p&&(c||o||!a);let g;e[4]!==u||e[5]!==s.description||e[6]!==s.title?(g=m.jsx(aw,{title:s.title,description:s.description,onSave:u}),e[4]=u,e[5]=s.description,e[6]=s.title,e[7]=g):g=e[7];let x;e[8]!==o?(x=o&&m.jsx(xv,{}),e[8]=o,e[9]=x):x=e[9];let b;e[10]!==r||e[11]!==a||e[12]!==y||e[13]!==p||e[14]!==l||e[15]!==s?(b=m.jsx("div",{className:"flex-1 overflow-hidden",children:l==="code"?m.jsx(yv,{workflow:s,onUpdate:r}):m.jsxs(Xh,{direction:"horizontal",className:"flex w-full h-full",children:[m.jsx(Bl,{defaultSize:50,minSize:30,children:m.jsx(Ew,{})}),m.jsx(Yh,{}),m.jsxs(Bl,{defaultSize:50,minSize:25,children:[p&&m.jsx(Aw,{className:"border-l border-border"}),a&&m.jsx(pv,{}),y&&m.jsx(ev,{className:"border-l border-border"})]})]})}),e[10]=r,e[11]=a,e[12]=y,e[13]=p,e[14]=l,e[15]=s,e[16]=b):b=e[16];let S;e[17]!==g||e[18]!==x||e[19]!==b?(S=m.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-background",children:[g,x,b]}),e[17]=g,e[18]=x,e[19]=b,e[20]=S):S=e[20];let v;return e[21]!==t||e[22]!==S?(v=m.jsx(Sn,{onBack:t,children:S}),e[21]=t,e[22]=S,e[23]=v):v=e[23],v}function Sv(n){const e=I.c(5),{itemId:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},e[0]=r):r=e[0];const{connectionId:s}=Et(r),o=s??qt;let i;e[1]!==o?(i=qe(o),e[1]=o,e[2]=i):i=e[2];const a=Mi(o,"WORKFLOW_EXECUTION",t,i);let c;return e[3]!==a?(c={item:a},e[3]=a,e[4]=c):c=e[4],c}function wv(n){const e=I.c(13),{onBack:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},e[0]=r):r=e[0];const{itemId:s}=Et(r);let o;e[1]!==s?(o={itemId:s},e[1]=s,e[2]=o):o=e[2];const{item:i}=Sv(o);if(!i){let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=m.jsx("div",{className:"flex h-full w-full bg-background",children:m.jsx(_i,{icon:m.jsx(Hc,{className:"w-10 h-10 text-muted-foreground"}),title:"Workflow execution not found",description:"This workflow execution may have been deleted or you may not have access to it."})}),e[3]=d):d=e[3];let u;return e[4]!==t?(u=m.jsx(Sn,{onBack:t,children:d}),e[4]=t,e[5]=u):u=e[5],u}let l;e[6]!==i?(l=JSON.stringify(i,null,2),e[6]=i,e[7]=l):l=e[7];let a;e[8]!==l?(a=m.jsx("div",{className:"flex flex-col h-full overflow-hidden bg-background",children:m.jsx(On,{height:"100%",code:l,language:"json",readOnly:!0})}),e[8]=l,e[9]=a):a=e[9];let c;return e[10]!==t||e[11]!==a?(c=m.jsx(Sn,{onBack:t,children:a}),e[10]=t,e[11]=a,e[12]=c):c=e[12],c}const vv={workflow:bv,workflow_execution:wv,prompt:pm};function Cv(){const n=I.c(6),e=Rc();let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},n[0]=t):t=n[0];const r=Et(t),s=decodeURIComponent(r.itemId);let o;n[1]!==e.history?(o=()=>{e.history.back()},n[1]=e.history,n[2]=o):o=n[2];const i=o,l=Nv;let a;return n[3]!==i||n[4]!==s?(a=m.jsx(wm,{itemId:s,onBack:i,onUpdate:l}),n[3]=i,n[4]=s,n[5]=a):a=n[5],a}async function Nv(n){return Promise.resolve()}function Ev(){const n=I.c(18),e=Rc();let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},n[0]=t):t=n[0];const r=Et(t),s=r.connectionId,o=decodeURIComponent(r.collectionName),i=decodeURIComponent(r.itemId);let l;n[1]!==e.history?(l=()=>{e.history.back()},n[1]=e.history,n[2]=l):l=n[2];const a=l,c=s??qt;let d;n[3]!==c?(d=qe(c),n[3]=c,n[4]=d):d=n[4];const f=Ai(c,o,d);let h;n[5]!==f||n[6]!==i?(h=async v=>{i&&await f.update.mutateAsync({id:i,data:v})},n[5]=f,n[6]=i,n[7]=h):h=n[7];const p=h;let y;n[8]!==o?(y=o?.toLowerCase(),n[8]=o,n[9]=y):y=n[9];const g=y,x=g&&vv[g];if(x){let v;return n[10]!==x||n[11]!==a||n[12]!==p||n[13]!==i?(v=m.jsx(x,{itemId:i,onBack:a,onUpdate:p}),n[10]=x,n[11]=a,n[12]=p,n[13]=i,n[14]=v):v=n[14],v}let b;n[15]===Symbol.for("react.memo_cache_sentinel")?(b=m.jsx(Dh,{size:36,className:"text-muted-foreground"}),n[15]=b):b=n[15];let S;return n[16]!==a?(S=m.jsx(_i,{icon:b,title:"No component defined",description:"No component for this collection was defined",buttonProps:{onClick:a,children:"Go back"}}),n[16]=a,n[17]=S):S=n[17],S}function Tv(){const n=I.c(3);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},n[0]=e):e=n[0];const t=Et(e);if(decodeURIComponent(t.collectionName)==="tools"){let i;return n[1]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx(Cv,{}),n[1]=i):i=n[1],i}let o;return n[2]===Symbol.for("react.memo_cache_sentinel")?(o=m.jsx(Ev,{}),n[2]=o):o=n[2],o}function $2(){const n=I.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=m.jsx(Dc,{children:m.jsx(O.Suspense,{fallback:m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsx(tr,{size:32,className:"animate-spin text-muted-foreground"})}),children:m.jsx(Tv,{})})}),n[0]=e):e=n[0],e}export{$2 as default};
|